Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add task index in the BlsAggregationServiceResponse when error #260

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading