Skip to content

Commit

Permalink
Fix bls attestations test again (#12513)
Browse files Browse the repository at this point in the history
This time it does not use goroutines
  • Loading branch information
Giulio2002 authored Oct 28, 2024
1 parent 3cd48aa commit 916e84a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
1 change: 1 addition & 0 deletions cl/cltypes/bls_to_execution_change.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ func (*BLSToExecutionChange) Static() bool {
type SignedBLSToExecutionChangeWithGossipData struct {
SignedBLSToExecutionChange *SignedBLSToExecutionChange
GossipData *sentinel.GossipData
ImmediateVerification bool
}

type SignedBLSToExecutionChange struct {
Expand Down
4 changes: 3 additions & 1 deletion cl/phase1/network/services/batch_signature_verification.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ type BatchSignatureVerifier struct {
ctx context.Context
}

var ErrInvalidBlsSignature = errors.New("invalid bls signature")

// each AggregateVerification request has sentinel.SentinelClient and *sentinel.GossipData
// to make sure that we can validate it separately and in case of failure we ban corresponding
// GossipData.Peer or simply run F and publish GossipData in case signature verification succeeds.
Expand Down Expand Up @@ -181,7 +183,7 @@ func (b *BatchSignatureVerifier) runBatchVerification(signatures [][]byte, signR
monitor.ObserveBatchVerificationThroughput(time.Since(start), len(signatures))

if !valid {
return errors.New("batch invalid signature")
return ErrInvalidBlsSignature
}

return nil
Expand Down
4 changes: 4 additions & 0 deletions cl/phase1/network/services/bls_to_execution_change_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ func (s *blsToExecutionChangeService) ProcessMessage(ctx context.Context, subnet
},
}

if msg.ImmediateVerification {
return s.batchSignatureVerifier.ImmediateVerification(aggregateVerificationData)
}

// push the signatures to verify asynchronously and run final functions after that.
s.batchSignatureVerifier.AsyncVerifyBlsToExecutionChange(aggregateVerificationData)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ func (t *blsToExecutionChangeTestSuite) TestProcessMessage() {
},
Signature: [96]byte{1, 2, 3},
},
GossipData: nil,
GossipData: nil,
ImmediateVerification: true,
}

tests := []struct {
Expand Down Expand Up @@ -179,7 +180,7 @@ func (t *blsToExecutionChangeTestSuite) TestProcessMessage() {
t.gomockCtrl.RecordCall(t.mockFuncs, "BlsVerifyMultipleSignatures", gomock.Any(), gomock.Any(), gomock.Any()).Return(false, nil).Times(2)
},
msg: mockMsg,
specificErr: ErrIgnore,
specificErr: ErrInvalidBlsSignature,
wantErr: true,
},
{
Expand All @@ -206,9 +207,9 @@ func (t *blsToExecutionChangeTestSuite) TestProcessMessage() {
mockStateMutator.EXPECT().SetWithdrawalCredentialForValidatorAtIndex(int(mockMsg.SignedBLSToExecutionChange.Message.ValidatorIndex), mockNewWc).Times(1)
t.gomockCtrl.RecordCall(t.mockFuncs, "BlsVerifyMultipleSignatures", gomock.Any(), gomock.Any(), gomock.Any()).Return(true, nil).Times(1)
},
msg: mockMsg,
specificErr: ErrIgnore,
wantErr: true,
msg: mockMsg,
// specificErr: ErrInvalidBlsSignature,
// wantErr: true,
},
}

Expand Down

0 comments on commit 916e84a

Please sign in to comment.