Skip to content

Commit

Permalink
add nimbus error
Browse files Browse the repository at this point in the history
  • Loading branch information
dB2510 committed Jul 19, 2022
1 parent 3dba8ba commit 5540420
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
5 changes: 3 additions & 2 deletions core/bcast/bcast.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,9 @@ func (b Broadcaster) Broadcast(ctx context.Context, duty core.Duty,
}

err = b.eth2Cl.SubmitAttestations(ctx, []*eth2p0.Attestation{&att.Attestation})
if err != nil && strings.Contains(err.Error(), "PriorAttestationKnown") {
// Lighthouse isn't idempotent, so just swallow this non-issue.
if err != nil && (strings.Contains(err.Error(), "PriorAttestationKnown") ||
strings.Contains(err.Error(), "No peers on libp2p topic")) {
// Lighthouse and Nimbus aren't idempotent, so just swallow this non-issue.
// See reference github.com/attestantio/[email protected]/multi/submitattestations.go:38
err = nil
}
Expand Down
9 changes: 7 additions & 2 deletions core/bcast/bcast_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,19 @@ func TestBroadcastAttestation(t *testing.T) {

aggData := core.Attestation{Attestation: *testutil.RandomAttestation()}

// Assert output and return lighthouse known error on duplicates
// Assert output and return lighthouse and nimbus known error on duplicates
var submitted int
mock.SubmitAttestationsFunc = func(ctx context.Context, attestations []*eth2p0.Attestation) error {
require.Len(t, attestations, 1)
require.Equal(t, aggData.Attestation, *attestations[0])

submitted++
if submitted > 1 {
if submitted > 2 {
// Non-idempotent error returned by lighthouse but swallowed by bcast.
return errors.New("Verification: PriorAttestationKnown")
} else if submitted > 1 {
// Non-idempotent error returned by nimbus but swallowed by bcast.
return errors.New(`"message":"No peers on libp2p topic"`)
}

return nil
Expand All @@ -61,6 +64,8 @@ func TestBroadcastAttestation(t *testing.T) {
require.NoError(t, err)
err = bcaster.Broadcast(ctx, core.Duty{Type: core.DutyAttester}, "", aggData)
require.NoError(t, err)
err = bcaster.Broadcast(ctx, core.Duty{Type: core.DutyAttester}, "", aggData)
require.NoError(t, err)
}

func TestBroadcastBeaconBlock(t *testing.T) {
Expand Down

0 comments on commit 5540420

Please sign in to comment.