diff --git a/go.mod b/go.mod index bcd55c05..6dda44f2 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index bf9e8072..3bceb575 100644 --- a/go.sum +++ b/go.sum @@ -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= diff --git a/services/blockrelay/standard/auctionblock.go b/services/blockrelay/standard/auctionblock.go index ea0684e2..e9560e82 100644 --- a/services/blockrelay/standard/auctionblock.go +++ b/services/blockrelay/standard/auctionblock.go @@ -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 { @@ -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") @@ -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, } }