Skip to content

Commit 7d6abf7

Browse files
authored
Merge branch 'staging' into 1415-send-signed-task-response-to-aggregator
2 parents 2a6d5fb + 439a6a0 commit 7d6abf7

File tree

24 files changed

+1037
-235
lines changed

24 files changed

+1037
-235
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ OS := $(shell uname -s)
66
CONFIG_FILE?=config-files/config.yaml
77
AGG_CONFIG_FILE?=config-files/config-aggregator.yaml
88

9-
OPERATOR_VERSION=v0.10.3
9+
OPERATOR_VERSION=v0.11.2
1010

1111
ifeq ($(OS),Linux)
1212
BUILD_ALL_FFI = $(MAKE) build_all_ffi_linux

aggregator/pkg/aggregator.go

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,13 @@ func (agg *Aggregator) Start(ctx context.Context) error {
225225
const MaxSentTxRetries = 5
226226

227227
func (agg *Aggregator) handleBlsAggServiceResponse(blsAggServiceResp blsagg.BlsAggregationServiceResponse) {
228+
defer func() {
229+
err := recover() //stops panics
230+
if err != nil {
231+
agg.logger.Error("handleBlsAggServiceResponse recovered from panic", "err", err)
232+
}
233+
}()
234+
228235
agg.taskMutex.Lock()
229236
agg.AggregatorConfig.BaseConfig.Logger.Info("- Locked Resources: Fetching task data")
230237
batchIdentifierHash := agg.batchesIdentifierHashByIdx[blsAggServiceResp.TaskIndex]
@@ -277,10 +284,15 @@ func (agg *Aggregator) handleBlsAggServiceResponse(blsAggServiceResp blsagg.BlsA
277284
}
278285

279286
agg.logger.Info("Sending aggregated response onchain", "taskIndex", blsAggServiceResp.TaskIndex,
280-
"batchIdentifierHash", "0x"+hex.EncodeToString(batchIdentifierHash[:]))
287+
"batchIdentifierHash", "0x"+hex.EncodeToString(batchIdentifierHash[:]), "merkleRoot", "0x"+hex.EncodeToString(batchData.BatchMerkleRoot[:]))
281288
receipt, err := agg.sendAggregatedResponse(batchIdentifierHash, batchData.BatchMerkleRoot, batchData.SenderAddress, nonSignerStakesAndSignature)
282289
if err == nil {
283-
agg.telemetry.TaskSentToEthereum(batchData.BatchMerkleRoot, receipt.TxHash.String())
290+
// In some cases, we may fail to retrieve the receipt for the transaction.
291+
txHash := "Unknown"
292+
if receipt != nil {
293+
txHash = receipt.TxHash.String()
294+
}
295+
agg.telemetry.TaskSentToEthereum(batchData.BatchMerkleRoot, txHash)
284296
agg.logger.Info("Aggregator successfully responded to task",
285297
"taskIndex", blsAggServiceResp.TaskIndex,
286298
"batchIdentifierHash", "0x"+hex.EncodeToString(batchIdentifierHash[:]))
@@ -384,8 +396,7 @@ func (agg *Aggregator) AddNewTask(batchMerkleRoot [32]byte, senderAddress [20]by
384396
quorumNums := eigentypes.QuorumNums{eigentypes.QuorumNum(QUORUM_NUMBER)}
385397
quorumThresholdPercentages := eigentypes.QuorumThresholdPercentages{eigentypes.QuorumThresholdPercentage(QUORUM_THRESHOLD)}
386398

387-
err := agg.blsAggregationService.InitializeNewTask(batchIndex, taskCreatedBlock, quorumNums, quorumThresholdPercentages, agg.AggregatorConfig.Aggregator.BlsServiceTaskTimeout)
388-
// FIXME(marian): When this errors, should we retry initializing new task? Logging fatal for now.
399+
err := agg.InitializeNewTaskRetryable(batchIndex, taskCreatedBlock, quorumNums, quorumThresholdPercentages, agg.AggregatorConfig.Aggregator.BlsServiceTaskTimeout)
389400
if err != nil {
390401
agg.logger.Fatalf("BLS aggregation service error when initializing new task: %s", err)
391402
}
@@ -399,7 +410,7 @@ func (agg *Aggregator) AddNewTask(batchMerkleRoot [32]byte, senderAddress [20]by
399410
// |---RETRYABLE---|
400411

401412
/*
402-
InitializeNewTask
413+
InitializeNewTaskRetryable
403414
Initialize a new task in the BLS Aggregation service
404415
- Errors:
405416
Permanent:
@@ -408,7 +419,7 @@ Initialize a new task in the BLS Aggregation service
408419
- All others.
409420
- Retry times (3 retries): 1 sec, 2 sec, 4 sec
410421
*/
411-
func (agg *Aggregator) InitializeNewTask(batchIndex uint32, taskCreatedBlock uint32, quorumNums eigentypes.QuorumNums, quorumThresholdPercentages eigentypes.QuorumThresholdPercentages, timeToExpiry time.Duration) error {
422+
func (agg *Aggregator) InitializeNewTaskRetryable(batchIndex uint32, taskCreatedBlock uint32, quorumNums eigentypes.QuorumNums, quorumThresholdPercentages eigentypes.QuorumThresholdPercentages, timeToExpiry time.Duration) error {
412423
initializeNewTask_func := func() error {
413424
err := agg.blsAggregationService.InitializeNewTask(batchIndex, taskCreatedBlock, quorumNums, quorumThresholdPercentages, timeToExpiry)
414425
if err != nil {
@@ -429,7 +440,7 @@ func (agg *Aggregator) ClearTasksFromMaps() {
429440
defer func() {
430441
err := recover() //stops panics
431442
if err != nil {
432-
agg.logger.Error("Recovered from panic", "err", err)
443+
agg.logger.Error("ClearTasksFromMaps Recovered from panic", "err", err)
433444
}
434445
}()
435446

aggregator/pkg/server.go

Lines changed: 3 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,8 @@ import (
66
"fmt"
77
"net/http"
88
"net/rpc"
9-
"strings"
109
"time"
1110

12-
"github.com/Layr-Labs/eigensdk-go/crypto/bls"
13-
eigentypes "github.com/Layr-Labs/eigensdk-go/types"
1411
retry "github.com/yetanotherco/aligned_layer/core"
1512
"github.com/yetanotherco/aligned_layer/core/types"
1613
)
@@ -72,7 +69,7 @@ func (agg *Aggregator) ProcessOperatorSignedTaskResponseV2(signedTaskResponse *t
7269

7370
agg.logger.Info("Starting bls signature process")
7471
go func() {
75-
err := agg.ProcessNewSignatureRetryable(
72+
err := agg.blsAggregationService.ProcessNewSignature(
7673
context.Background(), taskIndex, signedTaskResponse.BatchIdentifierHash,
7774
&signedTaskResponse.BlsSignature, signedTaskResponse.OperatorId,
7875
)
@@ -99,9 +96,6 @@ func (agg *Aggregator) ProcessOperatorSignedTaskResponseV2(signedTaskResponse *t
9996
*reply = 0
10097
}
10198

102-
agg.AggregatorConfig.BaseConfig.Logger.Info("- Unlocked Resources: Task response processing finished")
103-
agg.taskMutex.Unlock()
104-
10599
return nil
106100
}
107101

@@ -112,48 +106,12 @@ func (agg *Aggregator) ServerRunning(_ *struct{}, reply *int64) error {
112106
return nil
113107
}
114108

115-
// |---RETRYABLE---|
116-
117-
// TODO: Add Retryable
118-
/*
119-
- Errors:
120-
Permanent:
121-
- SignatureVerificationError: Verification of the sigature within the BLS Aggregation Service failed. (https://github.com/Layr-Labs/eigensdk-go/blob/dev/services/bls_aggregation/blsagg.go#L42).
122-
Transient:
123-
- All others.
124-
- Retry times (3 retries): 12 sec (1 Blocks), 24 sec (2 Blocks), 48 sec (4 Blocks)
125-
- NOTE: TaskNotFound errors from the BLS Aggregation service are Transient errors as block reorg's may lead to these errors being thrown.
126-
*/
127-
func (agg *Aggregator) ProcessNewSignatureRetryable(ctx context.Context, taskIndex uint32, taskResponse interface{}, blsSignature *bls.Signature, operatorId eigentypes.Bytes32) error {
128-
processNewSignature_func := func() error {
129-
err := agg.blsAggregationService.ProcessNewSignature(
130-
ctx, taskIndex, taskResponse,
131-
blsSignature, operatorId,
132-
)
133-
if err != nil {
134-
if strings.Contains(err.Error(), "Failed to verify signature") {
135-
err = retry.PermanentError{Inner: err}
136-
}
137-
}
138-
return err
139-
}
140-
141-
return retry.Retry(processNewSignature_func, retry.ChainRetryConfig())
142-
}
143-
144-
// Checks Internal mapping for Signed Task Response, returns its TaskIndex.
145-
/*
146-
- All errors are considered Transient Errors
147-
- Retry times (3 retries): 1 sec, 2 sec, 4 sec
148-
*/
149-
func (agg *Aggregator) GetTaskIndexRetryable(batchIdentifierHash [32]byte) (uint32, error) {
109+
func (agg *Aggregator) GetTaskIndex(batchIdentifierHash [32]byte) (uint32, error) {
150110
getTaskIndex_func := func() (uint32, error) {
151111
agg.taskMutex.Lock()
152-
agg.AggregatorConfig.BaseConfig.Logger.Info("- Locked Resources: Starting processing of Response")
153112
taskIndex, ok := agg.batchesIdxByIdentifierHash[batchIdentifierHash]
113+
agg.taskMutex.Unlock()
154114
if !ok {
155-
agg.taskMutex.Unlock()
156-
agg.logger.Info("- Unlocked Resources: Task not found in the internal map")
157115
return taskIndex, fmt.Errorf("Task not found in the internal map")
158116
} else {
159117
return taskIndex, nil

batcher/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)