From 26cfd4633f84f8fbb9ed196f5c1b054660e03b2c Mon Sep 17 00:00:00 2001 From: Franco Barpp Gomes Date: Tue, 13 Aug 2024 13:16:07 -0300 Subject: [PATCH] Submit checkpoint aggregation on finished aggregation process (#283) * feat: Submit checkpoint aggregation only on finished aggregation process * refactor: Fix typo * fix: Apply forceFinished into errored blsagg responses --- aggregator/aggregator.go | 8 +++++--- aggregator/blsagg/message_blsagg.go | 8 ++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/aggregator/aggregator.go b/aggregator/aggregator.go index 97838d05..4c903a74 100644 --- a/aggregator/aggregator.go +++ b/aggregator/aggregator.go @@ -35,7 +35,7 @@ const ( // this hardcoded here because it's also hardcoded in the contracts, but should // ideally be fetched from the contracts taskChallengeWindowBlock = 100 - taksResponseSubmissionBufferBlock = 15 + taskResponseSubmissionBufferBlock = 15 taskAggregationTimeout = 1 * time.Minute blockTime = 12 * time.Second avsName = "super-fast-finality-layer" @@ -286,7 +286,9 @@ func (agg *Aggregator) Start(ctx context.Context) error { return agg.Close() case blsAggServiceResp := <-agg.taskBlsAggregationService.GetResponseChannel(): agg.logger.Info("Received response from taskBlsAggregationService", "blsAggServiceResp", blsAggServiceResp) - go agg.sendAggregatedResponseToContract(blsAggServiceResp) + if blsAggServiceResp.Finished { + go agg.sendAggregatedResponseToContract(blsAggServiceResp) + } case blsAggServiceResp := <-agg.stateRootUpdateBlsAggregationService.GetResponseChannel(): agg.logger.Info("Received response from stateRootUpdateBlsAggregationService", "blsAggServiceResp", blsAggServiceResp) agg.handleStateRootUpdateReachedQuorum(blsAggServiceResp) @@ -411,7 +413,7 @@ func (agg *Aggregator) sendNewCheckpointTask() { quorumThresholds[i] = types.TASK_AGGREGATION_QUORUM_THRESHOLD } - taskTimeToExpiry := (taskChallengeWindowBlock-taksResponseSubmissionBufferBlock)*blockTime - taskAggregationTimeout + taskTimeToExpiry := (taskChallengeWindowBlock-taskResponseSubmissionBufferBlock)*blockTime - taskAggregationTimeout err = agg.taskBlsAggregationService.InitializeMessageIfNotExists( messages.CheckpointTaskResponse{ReferenceTaskIndex: taskIndex}.Key(), core.ConvertBytesToQuorumNumbers(newTask.QuorumNumbers), diff --git a/aggregator/blsagg/message_blsagg.go b/aggregator/blsagg/message_blsagg.go index d852e11f..365e7100 100644 --- a/aggregator/blsagg/message_blsagg.go +++ b/aggregator/blsagg/message_blsagg.go @@ -453,7 +453,7 @@ func (mbas *MessageBlsAggregatorService) getMessageBlsAggregationResponse(messag Message: message, MessageKey: message.Key(), Status: MessageBlsAggregationStatusNone, - Finished: false, + Finished: forceFinished, Err: MessageNotFoundErrorFn(messageDigest), } } @@ -465,7 +465,7 @@ func (mbas *MessageBlsAggregatorService) getMessageBlsAggregationResponse(messag Message: message, MessageKey: message.Key(), Status: MessageBlsAggregationStatusNone, - Finished: false, + Finished: forceFinished, Err: err, } } @@ -485,7 +485,7 @@ func (mbas *MessageBlsAggregatorService) getMessageBlsAggregationResponse(messag Message: message, MessageKey: message.Key(), Status: MessageBlsAggregationStatusNone, - Finished: false, + Finished: forceFinished, Err: err, } } @@ -511,7 +511,7 @@ func (mbas *MessageBlsAggregatorService) getMessageBlsAggregationResponse(messag Message: message, MessageKey: message.Key(), Status: MessageBlsAggregationStatusNone, - Finished: false, + Finished: forceFinished, Err: err, } }