Skip to content

Commit b333d36

Browse files
improve errors; merge tests
1 parent fc542d6 commit b333d36

File tree

4 files changed

+215
-225
lines changed

4 files changed

+215
-225
lines changed

beacon-chain/core/blocks/proposer_slashing.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ import (
1616
"google.golang.org/protobuf/proto"
1717
)
1818

19+
// ErrCouldNotVerifyBlockHeader is returned when a block header's signature cannot be verified.
20+
var ErrCouldNotVerifyBlockHeader = errors.New("could not verify beacon block header")
21+
1922
type slashValidatorFunc func(
2023
ctx context.Context,
2124
st state.BeaconState,
@@ -114,7 +117,7 @@ func VerifyProposerSlashing(
114117
for _, header := range headers {
115118
if err := signing.ComputeDomainVerifySigningRoot(beaconState, pIdx, slots.ToEpoch(hSlot),
116119
header.Header, params.BeaconConfig().DomainBeaconProposer, header.Signature); err != nil {
117-
return errors.Wrap(err, "could not verify beacon block header")
120+
return errors.Wrap(ErrCouldNotVerifyBlockHeader, err.Error())
118121
}
119122
}
120123
return nil

beacon-chain/sync/validate_beacon_blocks.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package sync
33
import (
44
"context"
55
"fmt"
6-
"strings"
76
"time"
87

98
pubsub "github.com/libp2p/go-libp2p-pubsub"
@@ -533,7 +532,7 @@ func (s *Service) detectAndBroadcastEquivocation(ctx context.Context, blk interf
533532

534533
// Verify the slashing against current state
535534
if err := blocks.VerifyProposerSlashing(headState, slashing); err != nil {
536-
if strings.Contains(err.Error(), "could not verify beacon block header") {
535+
if errors.Is(err, blocks.ErrCouldNotVerifyBlockHeader) {
537536
return errors.Wrap(ErrSlashingSignatureFailure, err.Error())
538537
}
539538
return errors.Wrap(err, "could not verify proposer slashing")

0 commit comments

Comments
 (0)