Skip to content

Commit

Permalink
feat: add task index in the BlsAggregationServiceResponse when error (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
fyInALT authored Jun 7, 2024
1 parent d9c2d13 commit 4a204d0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
12 changes: 8 additions & 4 deletions services/bls_aggregation/blsagg.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand All @@ -355,7 +358,8 @@ func (a *BlsAggregatorService) singleTaskAggregatorGoroutineFunc(
}
case <-taskExpiredTimer.C:
a.aggregatedResponsesC <- BlsAggregationServiceResponse{
Err: TaskExpiredErrorFn(taskIndex),
Err: TaskExpiredErrorFn(taskIndex),
TaskIndex: taskIndex,
}
return
}
Expand Down
7 changes: 7 additions & 0 deletions services/bls_aggregation/blsagg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 4a204d0

Please sign in to comment.