Skip to content

Commit

Permalink
Tidy-ups.
Browse files Browse the repository at this point in the history
  • Loading branch information
mcdee committed Dec 26, 2022
1 parent 8a818b3 commit c1d4ef4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ require (
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
github.com/shibukawa/configdir v0.0.0-20170330084843-e180dbdc8da0 // indirect
github.com/shopspring/decimal v1.3.1 // indirect
github.com/spf13/afero v1.9.3 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,8 @@ github.com/sasha-s/go-deadlock v0.3.1 h1:sqv7fDNShgjcaxkO0JNcOAlr8B9+cV5Ey/OB71e
github.com/sasha-s/go-deadlock v0.3.1/go.mod h1:F73l+cr82YSh10GxyRI6qZiCgK64VaZjwesgfQ1/iLM=
github.com/shibukawa/configdir v0.0.0-20170330084843-e180dbdc8da0 h1:Xuk8ma/ibJ1fOy4Ee11vHhUFHQNpHhrBneOCNHVXS5w=
github.com/shibukawa/configdir v0.0.0-20170330084843-e180dbdc8da0/go.mod h1:7AwjWCpdPhkSmNAgUv5C7EJ4AbmjEB3r047r3DXWu3Y=
github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8=
github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=
Expand Down
22 changes: 13 additions & 9 deletions services/blockrelay/standard/auctionblock.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ func (s *Service) builderBid(ctx context.Context,
attribute.String("value", builderBid.Data.Message.Value.ToBig().String()),
)

var score *big.Int
switch builderBid.Version {
case consensusspec.DataVersionBellatrix:
if builderBid.Data == nil {
Expand Down Expand Up @@ -336,38 +337,39 @@ func (s *Service) builderBid(ctx context.Context,
errCh <- fmt.Errorf("%s: invalid signature", provider.Address())
return
}
score = builderBid.Data.Message.Value.ToBig()
case consensusspec.DataVersionCapella:
if builderBid.Data == nil {
if builderBid.Capella == nil {
span.SetStatus(codes.Error, "data missing")
errCh <- fmt.Errorf("%s: data missing", provider.Address())
return
}
if builderBid.Data.Message == nil {
if builderBid.Capella.Message == nil {
span.SetStatus(codes.Error, "data message missing")
errCh <- fmt.Errorf("%s: data message missing", provider.Address())
return
}
if builderBid.Data.Message.Header == nil {
if builderBid.Capella.Message.Header == nil {
span.SetStatus(codes.Error, "data message header missing")
errCh <- fmt.Errorf("%s: data message header missing", provider.Address())
return
}
if bytes.Equal(builderBid.Data.Message.Header.FeeRecipient[:], zeroExecutionAddress[:]) {
if bytes.Equal(builderBid.Capella.Message.Header.FeeRecipient[:], zeroExecutionAddress[:]) {
span.SetStatus(codes.Error, "zero fee recipient")
errCh <- fmt.Errorf("%s: zero fee recipient", provider.Address())
return
}
if zeroValue.Cmp(builderBid.Data.Message.Value) == 0 {
if zeroValue.Cmp(builderBid.Capella.Message.Value) == 0 {
span.SetStatus(codes.Error, "zero value")
errCh <- fmt.Errorf("%s: zero value", provider.Address())
return
}
if uint64(s.chainTime.StartOfSlot(slot).Unix()) != builderBid.Data.Message.Header.Timestamp {
if uint64(s.chainTime.StartOfSlot(slot).Unix()) != builderBid.Capella.Message.Header.Timestamp {
span.SetStatus(codes.Error, "incorrect timestamp")
errCh <- fmt.Errorf("%s: provided timestamp %d for slot %d not expected value of %d", provider.Address(), builderBid.Data.Message.Header.Timestamp, slot, s.chainTime.StartOfSlot(slot).Unix())
errCh <- fmt.Errorf("%s: provided timestamp %d for slot %d not expected value of %d", provider.Address(), builderBid.Capella.Message.Header.Timestamp, slot, s.chainTime.StartOfSlot(slot).Unix())
return
}
verified, err := s.verifyBidSignature(ctx, builderBid, provider)
verified, err := s.verifyBidSignature(ctx, relayConfig, builderBid, provider)
if err != nil {
span.SetStatus(codes.Error, "invalid bid signature")
errCh <- errors.Wrap(err, "error verifying bid signature")
Expand All @@ -379,15 +381,17 @@ func (s *Service) builderBid(ctx context.Context,
errCh <- fmt.Errorf("%s: invalid signature", provider.Address())
return
}
score = builderBid.Capella.Message.Value.ToBig()
default:
span.SetStatus(codes.Error, "unhandled builder bid data version")
errCh <- fmt.Errorf("%s: unhandled builder bid data version %v", provider.Address(), builderBid.Version)
return
}

respCh <- &builderBidResponse{
bid: builderBid,
provider: provider,
score: builderBid.Data.Message.Value.ToBig(),
score: score,
}
}

Expand Down

0 comments on commit c1d4ef4

Please sign in to comment.