@@ -225,6 +225,13 @@ func (agg *Aggregator) Start(ctx context.Context) error {
225225const MaxSentTxRetries = 5
226226
227227func (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
403414Initialize 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
0 commit comments