From 63dddb3d3611fb85d1cb5996abf6f36e6c06c741 Mon Sep 17 00:00:00 2001 From: fyInALT Date: Thu, 6 Jun 2024 16:32:02 +0800 Subject: [PATCH] feat: add task index in the BlsAggregationServiceResponse when error --- services/bls_aggregation/blsagg.go | 12 ++++++++---- services/bls_aggregation/blsagg_test.go | 7 +++++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/services/bls_aggregation/blsagg.go b/services/bls_aggregation/blsagg.go index 9514bb2b..394bf993 100644 --- a/services/bls_aggregation/blsagg.go +++ b/services/bls_aggregation/blsagg.go @@ -235,14 +235,16 @@ func (a *BlsAggregatorService) singleTaskAggregatorGoroutineFunc( operatorsAvsStateDict, err := a.avsRegistryService.GetOperatorsAvsStateAtBlock(context.Background(), quorumNumbers, taskCreatedBlock) if err != nil { a.aggregatedResponsesC <- BlsAggregationServiceResponse{ - Err: TaskInitializationErrorFn(fmt.Errorf("AggregatorService failed to get operators state from avs registry at blockNum %d: %w", taskCreatedBlock, err), taskIndex), + Err: TaskInitializationErrorFn(fmt.Errorf("AggregatorService failed to get operators state from avs registry at blockNum %d: %w", taskCreatedBlock, err), taskIndex), + TaskIndex: taskIndex, } return } quorumsAvsStakeDict, err := a.avsRegistryService.GetQuorumsAvsStateAtBlock(context.Background(), quorumNumbers, taskCreatedBlock) if err != nil { a.aggregatedResponsesC <- BlsAggregationServiceResponse{ - Err: TaskInitializationErrorFn(fmt.Errorf("Aggregator failed to get quorums state from avs registry: %w", err), taskIndex), + Err: TaskInitializationErrorFn(fmt.Errorf("Aggregator failed to get quorums state from avs registry: %w", err), taskIndex), + TaskIndex: taskIndex, } return } @@ -330,7 +332,8 @@ func (a *BlsAggregatorService) singleTaskAggregatorGoroutineFunc( indices, err := a.avsRegistryService.GetCheckSignaturesIndices(&bind.CallOpts{}, taskCreatedBlock, quorumNumbers, nonSignersOperatorIds) if err != nil { a.aggregatedResponsesC <- BlsAggregationServiceResponse{ - Err: utils.WrapError(errors.New("Failed to get check signatures indices"), err), + Err: utils.WrapError(errors.New("Failed to get check signatures indices"), err), + TaskIndex: taskIndex, } return } @@ -355,7 +358,8 @@ func (a *BlsAggregatorService) singleTaskAggregatorGoroutineFunc( } case <-taskExpiredTimer.C: a.aggregatedResponsesC <- BlsAggregationServiceResponse{ - Err: TaskExpiredErrorFn(taskIndex), + Err: TaskExpiredErrorFn(taskIndex), + TaskIndex: taskIndex, } return } diff --git a/services/bls_aggregation/blsagg_test.go b/services/bls_aggregation/blsagg_test.go index 21e565ef..cba95de4 100644 --- a/services/bls_aggregation/blsagg_test.go +++ b/services/bls_aggregation/blsagg_test.go @@ -85,6 +85,7 @@ func TestBlsAgg(t *testing.T) { } gotAggregationServiceResponse := <-blsAggServ.aggregatedResponsesC require.Equal(t, wantAggregationServiceResponse, gotAggregationServiceResponse) + require.EqualValues(t, taskIndex, gotAggregationServiceResponse.TaskIndex) }) t.Run("1 quorum 3 operator 3 correct signatures", func(t *testing.T) { @@ -147,6 +148,7 @@ func TestBlsAgg(t *testing.T) { } gotAggregationServiceResponse := <-blsAggServ.aggregatedResponsesC require.Equal(t, wantAggregationServiceResponse, gotAggregationServiceResponse) + require.EqualValues(t, taskIndex, gotAggregationServiceResponse.TaskIndex) }) t.Run("2 quorums 2 operators 2 correct signatures", func(t *testing.T) { @@ -538,6 +540,7 @@ func TestBlsAgg(t *testing.T) { } gotAggregationServiceResponse := <-blsAggServ.aggregatedResponsesC require.EqualValues(t, wantAggregationServiceResponse, gotAggregationServiceResponse) + require.EqualValues(t, taskIndex, gotAggregationServiceResponse.TaskIndex) }) t.Run("2 quorums 1 operators which just stake one quorum; 1 signatures - task expired", func(t *testing.T) { @@ -570,6 +573,7 @@ func TestBlsAgg(t *testing.T) { } gotAggregationServiceResponse := <-blsAggServ.aggregatedResponsesC require.EqualValues(t, wantAggregationServiceResponse, gotAggregationServiceResponse) + require.EqualValues(t, taskIndex, gotAggregationServiceResponse.TaskIndex) }) t.Run("2 quorums 2 operators, 1 operator which just stake one quorum; 1 signatures - task expired", func(t *testing.T) { @@ -607,6 +611,7 @@ func TestBlsAgg(t *testing.T) { } gotAggregationServiceResponse := <-blsAggServ.aggregatedResponsesC require.EqualValues(t, wantAggregationServiceResponse, gotAggregationServiceResponse) + require.EqualValues(t, taskIndex, gotAggregationServiceResponse.TaskIndex) }) t.Run("send signature of task that isn't initialized - task not found error", func(t *testing.T) { @@ -683,6 +688,7 @@ func TestBlsAgg(t *testing.T) { } gotAggregationServiceResponse := <-blsAggServ.aggregatedResponsesC require.Equal(t, wantAggregationServiceResponse, gotAggregationServiceResponse) + require.EqualValues(t, taskIndex, gotAggregationServiceResponse.TaskIndex) }) t.Run("1 quorum 2 operator 2 signatures on 2 different msgs - task expired", func(t *testing.T) { @@ -724,6 +730,7 @@ func TestBlsAgg(t *testing.T) { } gotAggregationServiceResponse := <-blsAggServ.aggregatedResponsesC require.Equal(t, wantAggregationServiceResponse, gotAggregationServiceResponse) + require.EqualValues(t, taskIndex, gotAggregationServiceResponse.TaskIndex) }) t.Run("1 quorum 1 operator 1 invalid signature (TaskResponseDigest does not match TaskResponse)", func(t *testing.T) {