Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove signed blinded beacon block wrapper #482

Merged
merged 3 commits into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ linters:
enable-all: true
disable:
- cyclop
- depguard
- forbidigo
- funlen
- gochecknoglobals
Expand Down Expand Up @@ -88,6 +89,10 @@ linters-settings:
# Because it's easier to read without the other fields.
#
- 'GetPayloadsFilters'
#
# Easier to read with only one of the versioned payloads.
#
- 'api.VersionedExecutionPayload'

#
# Structures outside our control that have a ton of settings. It doesn't
Expand Down
83 changes: 3 additions & 80 deletions common/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"github.com/attestantio/go-builder-client/api/capella"
apiv1 "github.com/attestantio/go-builder-client/api/v1"
"github.com/attestantio/go-builder-client/spec"
apiv1capella "github.com/attestantio/go-eth2-client/api/v1/capella"
consensusspec "github.com/attestantio/go-eth2-client/spec"
consensuscapella "github.com/attestantio/go-eth2-client/spec/capella"
"github.com/attestantio/go-eth2-client/spec/phase0"
Expand Down Expand Up @@ -141,8 +140,8 @@ type BuilderGetValidatorsResponseEntry struct {

type BidTraceV2 struct {
apiv1.BidTrace
BlockNumber uint64 `json:"block_number,string" db:"block_number"`
NumTx uint64 `json:"num_tx,string" db:"num_tx"`
BlockNumber uint64 `db:"block_number" json:"block_number,string"`
NumTx uint64 `db:"num_tx" json:"num_tx,string"`
}

type BidTraceV2JSON struct {
Expand Down Expand Up @@ -273,82 +272,6 @@ func (b *BidTraceV2WithTimestampJSON) ToCSVRecord() []string {
}
}

type SignedBlindedBeaconBlock struct {
Bellatrix *boostTypes.SignedBlindedBeaconBlock
Capella *apiv1capella.SignedBlindedBeaconBlock
}

func (s *SignedBlindedBeaconBlock) MarshalJSON() ([]byte, error) {
if s.Capella != nil {
return json.Marshal(s.Capella)
}
if s.Bellatrix != nil {
return json.Marshal(s.Bellatrix)
}
return nil, ErrEmptyPayload
}

func (s *SignedBlindedBeaconBlock) Slot() uint64 {
if s.Capella != nil {
return uint64(s.Capella.Message.Slot)
}
if s.Bellatrix != nil {
return s.Bellatrix.Message.Slot
}
return 0
}

func (s *SignedBlindedBeaconBlock) BlockHash() string {
if s.Capella != nil {
return s.Capella.Message.Body.ExecutionPayloadHeader.BlockHash.String()
}
if s.Bellatrix != nil {
return s.Bellatrix.Message.Body.ExecutionPayloadHeader.BlockHash.String()
}
return ""
}

func (s *SignedBlindedBeaconBlock) BlockNumber() uint64 {
if s.Capella != nil {
return s.Capella.Message.Body.ExecutionPayloadHeader.BlockNumber
}
if s.Bellatrix != nil {
return s.Bellatrix.Message.Body.ExecutionPayloadHeader.BlockNumber
}
return 0
}

func (s *SignedBlindedBeaconBlock) ProposerIndex() uint64 {
if s.Capella != nil {
return uint64(s.Capella.Message.ProposerIndex)
}
if s.Bellatrix != nil {
return s.Bellatrix.Message.ProposerIndex
}
return 0
}

func (s *SignedBlindedBeaconBlock) Signature() []byte {
if s.Capella != nil {
return s.Capella.Signature[:]
}
if s.Bellatrix != nil {
return s.Bellatrix.Signature[:]
}
return nil
}

//nolint:nolintlint,ireturn
func (s *SignedBlindedBeaconBlock) Message() boostTypes.HashTreeRoot {
if s.Capella != nil {
return s.Capella.Message
}
if s.Bellatrix != nil {
return s.Bellatrix.Message
}
return nil
}

type SignedBeaconBlock struct {
Capella *consensuscapella.SignedBeaconBlock
}
Expand Down Expand Up @@ -404,7 +327,7 @@ func (b *BuilderSubmitBlockRequest) HasExecutionPayload() bool {

func (b *BuilderSubmitBlockRequest) ExecutionPayloadResponse() (*api.VersionedExecutionPayload, error) {
if b.Capella != nil {
return &api.VersionedExecutionPayload{ //nolint:exhaustruct
return &api.VersionedExecutionPayload{
Version: consensusspec.DataVersionCapella,
Capella: b.Capella.ExecutionPayload,
}, nil
Expand Down
5 changes: 3 additions & 2 deletions common/types_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/attestantio/go-builder-client/api"
"github.com/attestantio/go-builder-client/api/capella"
"github.com/attestantio/go-builder-client/spec"
consensusapi "github.com/attestantio/go-eth2-client/api"
consensusspec "github.com/attestantio/go-eth2-client/spec"
consensuscapella "github.com/attestantio/go-eth2-client/spec/capella"
"github.com/attestantio/go-eth2-client/spec/phase0"
Expand Down Expand Up @@ -56,7 +57,7 @@ func BuildGetHeaderResponse(payload *BuilderSubmitBlockRequest, sk *bls.SecretKe

func BuildGetPayloadResponse(payload *BuilderSubmitBlockRequest) (*api.VersionedExecutionPayload, error) {
if payload.Capella != nil {
return &api.VersionedExecutionPayload{ //nolint:exhaustruct
return &api.VersionedExecutionPayload{
Version: consensusspec.DataVersionCapella,
Capella: payload.Capella.ExecutionPayload,
}, nil
Expand Down Expand Up @@ -147,7 +148,7 @@ func CapellaPayloadToPayloadHeader(p *consensuscapella.ExecutionPayload) (*conse
}, nil
}

func SignedBlindedBeaconBlockToBeaconBlock(signedBlindedBeaconBlock *SignedBlindedBeaconBlock, executionPayload *api.VersionedExecutionPayload) *SignedBeaconBlock {
func SignedBlindedBeaconBlockToBeaconBlock(signedBlindedBeaconBlock *consensusapi.VersionedSignedBlindedBeaconBlock, executionPayload *api.VersionedExecutionPayload) *SignedBeaconBlock {
var signedBeaconBlock SignedBeaconBlock
capellaBlindedBlock := signedBlindedBeaconBlock.Capella
if capellaBlindedBlock != nil {
Expand Down
5 changes: 3 additions & 2 deletions database/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"strings"
"time"

consensusapi "github.com/attestantio/go-eth2-client/api"
"github.com/flashbots/go-boost-utils/types"
"github.com/flashbots/mev-boost-relay/common"
"github.com/flashbots/mev-boost-relay/database/migrations"
Expand All @@ -34,7 +35,7 @@ type IDatabaseService interface {
GetExecutionPayloads(idFirst, idLast uint64) (entries []*ExecutionPayloadEntry, err error)
DeleteExecutionPayloads(idFirst, idLast uint64) error

SaveDeliveredPayload(bidTrace *common.BidTraceV2, signedBlindedBeaconBlock *common.SignedBlindedBeaconBlock, signedAt time.Time, publishMs uint64) error
SaveDeliveredPayload(bidTrace *common.BidTraceV2, signedBlindedBeaconBlock *consensusapi.VersionedSignedBlindedBeaconBlock, signedAt time.Time, publishMs uint64) error
GetNumDeliveredPayloads() (uint64, error)
GetRecentDeliveredPayloads(filters GetPayloadsFilters) ([]*DeliveredPayloadEntry, error)
GetDeliveredPayloads(idFirst, idLast uint64) (entries []*DeliveredPayloadEntry, err error)
Expand Down Expand Up @@ -267,7 +268,7 @@ func (s *DatabaseService) GetExecutionPayloadEntryBySlotPkHash(slot uint64, prop
return entry, err
}

func (s *DatabaseService) SaveDeliveredPayload(bidTrace *common.BidTraceV2, signedBlindedBeaconBlock *common.SignedBlindedBeaconBlock, signedAt time.Time, publishMs uint64) error {
func (s *DatabaseService) SaveDeliveredPayload(bidTrace *common.BidTraceV2, signedBlindedBeaconBlock *consensusapi.VersionedSignedBlindedBeaconBlock, signedAt time.Time, publishMs uint64) error {
_signedBlindedBeaconBlock, err := json.Marshal(signedBlindedBeaconBlock)
if err != nil {
return err
Expand Down
3 changes: 2 additions & 1 deletion database/mockdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"time"

consensusapi "github.com/attestantio/go-eth2-client/api"
"github.com/flashbots/go-boost-utils/types"
"github.com/flashbots/mev-boost-relay/common"
)
Expand Down Expand Up @@ -85,7 +86,7 @@ func (db MockDB) GetBuilderSubmissionsBySlots(slotFrom, slotTo uint64) (entries
return nil, nil
}

func (db MockDB) SaveDeliveredPayload(bidTrace *common.BidTraceV2, signedBlindedBeaconBlock *common.SignedBlindedBeaconBlock, signedAt time.Time, publishMs uint64) error {
func (db MockDB) SaveDeliveredPayload(bidTrace *common.BidTraceV2, signedBlindedBeaconBlock *consensusapi.VersionedSignedBlindedBeaconBlock, signedAt time.Time, publishMs uint64) error {
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion database/typesconv.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func ExecutionPayloadEntryToExecutionPayload(executionPayloadEntry *ExecutionPay
if err != nil {
return nil, err
}
return &api.VersionedExecutionPayload{ //nolint:exhaustruct
return &api.VersionedExecutionPayload{
Version: consensusspec.DataVersionCapella,
Capella: executionPayload,
}, nil
Expand Down
2 changes: 1 addition & 1 deletion datastore/memcached_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func testBuilderSubmitBlockRequest(pubkey phase0.BLSPubKey, signature phase0.BLS
}
case consensusspec.DataVersionDeneb:
fallthrough
case consensusspec.DataVersionPhase0, consensusspec.DataVersionAltair, consensusspec.DataVersionBellatrix:
case consensusspec.DataVersionUnknown, consensusspec.DataVersionPhase0, consensusspec.DataVersionAltair, consensusspec.DataVersionBellatrix:
fallthrough
default:
return common.BuilderSubmitBlockRequest{
Expand Down
2 changes: 1 addition & 1 deletion datastore/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ func (r *RedisCache) GetExecutionPayloadCapella(slot uint64, proposerPubkey, blo
return nil, err
}

return &api.VersionedExecutionPayload{ //nolint:exhaustruct
return &api.VersionedExecutionPayload{
Version: consensusspec.DataVersionCapella,
Capella: capellaPayload,
}, nil
Expand Down
24 changes: 13 additions & 11 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.20
require (
github.com/NYTimes/gziphandler v1.1.1
github.com/alicebob/miniredis/v2 v2.30.4
github.com/attestantio/go-builder-client v0.3.1
github.com/attestantio/go-builder-client v0.3.2-0.20230701110827-d0ecfee1ab62
github.com/attestantio/go-eth2-client v0.16.4
github.com/bradfitz/gomemcache v0.0.0-20230124162541-5f7a7d875746
github.com/btcsuite/btcd/btcutil v1.1.2
Expand All @@ -19,7 +19,7 @@ require (
github.com/jmoiron/sqlx v1.3.5
github.com/lib/pq v1.10.8
github.com/pkg/errors v0.9.1
github.com/r3labs/sse/v2 v2.8.1
github.com/r3labs/sse/v2 v2.10.0
github.com/sirupsen/logrus v1.9.3
github.com/spf13/cobra v1.6.1
github.com/stretchr/testify v1.8.4
Expand All @@ -45,22 +45,22 @@ require (
github.com/goccy/go-yaml v1.11.0 // indirect
github.com/gofrs/flock v0.8.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/klauspost/compress v1.15.15 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.18 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/mmcloughlin/addchain v0.4.0 // indirect
github.com/prometheus/client_golang v1.14.0 // indirect
github.com/prometheus/client_golang v1.16.0 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.39.0 // indirect
github.com/prometheus/procfs v0.9.0 // indirect
github.com/prometheus/common v0.42.0 // indirect
github.com/prometheus/procfs v0.10.1 // indirect
github.com/prysmaticlabs/go-bitfield v0.0.0-20210809151128-385d8c5e3fb7 // indirect
github.com/rogpeppe/go-internal v1.9.0 // indirect
github.com/rogpeppe/go-internal v1.11.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
google.golang.org/protobuf v1.28.1 // indirect
google.golang.org/protobuf v1.30.0 // indirect
rsc.io/tmplfunc v0.0.3 // indirect
)

Expand Down Expand Up @@ -97,9 +97,9 @@ require (
github.com/yuin/gopher-lua v1.1.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/zap v1.23.0 // indirect
golang.org/x/crypto v0.8.0 // indirect
golang.org/x/net v0.9.0 // indirect
golang.org/x/sys v0.8.0 // indirect
golang.org/x/crypto v0.10.0 // indirect
golang.org/x/net v0.10.0 // indirect
golang.org/x/sys v0.9.0 // indirect
gopkg.in/cenkalti/backoff.v1 v1.1.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand All @@ -114,3 +114,5 @@ retract (
v1.0.0-alpha2
v1.0.0-alpha1
)

replace github.com/attestantio/go-eth2-client => github.com/avalonche/go-eth2-client v0.0.0-20230720050755-dfcc05c7f873
Loading
Loading