diff --git a/common/types.go b/common/types.go index e119b960..5e02c387 100644 --- a/common/types.go +++ b/common/types.go @@ -12,6 +12,7 @@ import ( "github.com/attestantio/go-eth2-client/spec/bellatrix" "github.com/attestantio/go-eth2-client/spec/capella" "github.com/attestantio/go-eth2-client/spec/deneb" + "github.com/attestantio/go-eth2-client/spec/electra" "github.com/attestantio/go-eth2-client/spec/phase0" ssz "github.com/ferranbt/fastssz" boostSsz "github.com/flashbots/go-boost-utils/ssz" @@ -176,16 +177,16 @@ func NewEthNetworkDetails(networkName string) (ret *EthNetworkDetails, err error func (e *EthNetworkDetails) String() string { return fmt.Sprintf( `EthNetworkDetails{ - Name: %s, - GenesisForkVersionHex: %s, + Name: %s, + GenesisForkVersionHex: %s, GenesisValidatorsRootHex: %s, - BellatrixForkVersionHex: %s, - CapellaForkVersionHex: %s, + BellatrixForkVersionHex: %s, + CapellaForkVersionHex: %s, DenebForkVersionHex: %s, ElectraForkVersionHex: %s, - DomainBuilder: %x, - DomainBeaconProposerBellatrix: %x, - DomainBeaconProposerCapella: %x, + DomainBuilder: %x, + DomainBeaconProposerBellatrix: %x, + DomainBeaconProposerCapella: %x, DomainBeaconProposerDeneb: %x DomainBeaconProposerElectra: %x }`, @@ -440,6 +441,9 @@ type BlockSubmissionInfo struct { Blobs []deneb.Blob BlobGasUsed uint64 ExcessBlobGas uint64 + DepositRequests []*electra.DepositRequest + WithdrawalRequests []*electra.WithdrawalRequest + ConsolidationRequests []*electra.ConsolidationRequest } /* diff --git a/common/types_spec.go b/common/types_spec.go index d48544dd..0597a5aa 100644 --- a/common/types_spec.go +++ b/common/types_spec.go @@ -7,6 +7,7 @@ import ( builderApi "github.com/attestantio/go-builder-client/api" builderApiCapella "github.com/attestantio/go-builder-client/api/capella" builderApiDeneb "github.com/attestantio/go-builder-client/api/deneb" + builderApiElectra "github.com/attestantio/go-builder-client/api/electra" builderApiV1 "github.com/attestantio/go-builder-client/api/v1" builderSpec "github.com/attestantio/go-builder-client/spec" eth2Api "github.com/attestantio/go-eth2-client/api" @@ -174,9 +175,10 @@ func BuilderBlockRequestToSignedBuilderBid(payload *VersionedSubmitBlockRequest, }, }, nil case spec.DataVersionElectra: - builderBid := builderApiDeneb.BuilderBid{ + builderBid := builderApiElectra.BuilderBid{ Header: header.Electra, BlobKZGCommitments: payload.Electra.BlobsBundle.Commitments, + ExecutionRequests: payload.Electra.ExecutionRequests, Value: value, Pubkey: *pubkey, } @@ -188,7 +190,7 @@ func BuilderBlockRequestToSignedBuilderBid(payload *VersionedSubmitBlockRequest, return &builderSpec.VersionedSignedBuilderBid{ Version: spec.DataVersionElectra, - Electra: &builderApiDeneb.SignedBuilderBid{ + Electra: &builderApiElectra.SignedBuilderBid{ Message: &builderBid, Signature: sig, }, diff --git a/common/utils.go b/common/utils.go index fb8fbdd5..9ab66c21 100644 --- a/common/utils.go +++ b/common/utils.go @@ -238,6 +238,18 @@ func GetBlockSubmissionInfo(submission *VersionedSubmitBlockRequest) (*BlockSubm if submission.Version >= spec.DataVersionDeneb && err != nil { return nil, err } + depositRequests, err := submission.DepositRequests() + if submission.Version >= spec.DataVersionElectra && err != nil { + return nil, err + } + withdrawalRequests, err := submission.WithdrawalRequests() + if submission.Version >= spec.DataVersionElectra && err != nil { + return nil, err + } + consolidationRequests, err := submission.ConsolidationRequests() + if submission.Version >= spec.DataVersionElectra && err != nil { + return nil, err + } return &BlockSubmissionInfo{ BidTrace: bidTrace, Signature: signature, @@ -253,6 +265,9 @@ func GetBlockSubmissionInfo(submission *VersionedSubmitBlockRequest) (*BlockSubm Blobs: blobs, BlobGasUsed: blobGasUsed, ExcessBlobGas: excessBlobGas, + DepositRequests: depositRequests, + WithdrawalRequests: withdrawalRequests, + ConsolidationRequests: consolidationRequests, }, nil } diff --git a/go.mod b/go.mod index aa1f482f..886337d0 100644 --- a/go.mod +++ b/go.mod @@ -127,3 +127,6 @@ retract ( v1.0.0-alpha2 v1.0.0-alpha1 ) + +// Remove when go-builder-client is updated. +replace github.com/attestantio/go-builder-client => github.com/jtraglia/go-builder-client v0.4.6-0.20241014193815-df58bba2ab54 diff --git a/go.sum b/go.sum index faeb03d2..e26f620b 100644 --- a/go.sum +++ b/go.sum @@ -11,8 +11,6 @@ github.com/alicebob/gopher-json v0.0.0-20200520072559-a9ecdc9d1d3a h1:HbKu58rmZp github.com/alicebob/gopher-json v0.0.0-20200520072559-a9ecdc9d1d3a/go.mod h1:SGnFV6hVsYE877CKEZ6tDNTjaSXYUk6QqoIK6PrAtcc= github.com/alicebob/miniredis/v2 v2.32.1 h1:Bz7CciDnYSaa0mX5xODh6GUITRSx+cVhjNoOR4JssBo= github.com/alicebob/miniredis/v2 v2.32.1/go.mod h1:AqkLNAfUm0K07J28hnAyyQKf/x0YkCY/g5DCtuL01Mw= -github.com/attestantio/go-builder-client v0.5.1-0.20240925223414-5da8987dd6f3 h1:Ccyc8R6CJbnb5oTwjuYSa2XaYWFSN8R43Gh9V1zN3Dg= -github.com/attestantio/go-builder-client v0.5.1-0.20240925223414-5da8987dd6f3/go.mod h1:qM91NvVG+fepPBN2/MDLpWJ9I/zZtpZAkXa8T9GFOvM= github.com/attestantio/go-eth2-client v0.21.12-0.20241006200801-8fa702e3a895 h1:3uu4l7TK5PPVBvVUpwxftDpKFddEE3g196BYJbKYq4g= github.com/attestantio/go-eth2-client v0.21.12-0.20241006200801-8fa702e3a895/go.mod h1:vy5jU/uDZ2+RcVzq5BfnG+bQ3/6uu9DGwCrGsPtjJ1A= github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= @@ -179,6 +177,8 @@ github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJS github.com/jmoiron/sqlx v1.3.5 h1:vFFPA71p1o5gAeqtEAwLU4dnX2napprKtHr7PYIcN3g= github.com/jmoiron/sqlx v1.3.5/go.mod h1:nRVWtLre0KfCLJvgxzCsLVMogSvQ1zNJtpYr2Ccp0mQ= github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ= +github.com/jtraglia/go-builder-client v0.4.6-0.20241014193815-df58bba2ab54 h1:ip/ONBWDWPCGWNGrMXD2vvZH/ABjw5wKfcQ8z7a8MWo= +github.com/jtraglia/go-builder-client v0.4.6-0.20241014193815-df58bba2ab54/go.mod h1:UkqMh+CHZh63XDx3GdBLijRdFQu2Hyqh3n71V4G10Ws= github.com/karrick/godirwalk v1.16.1 h1:DynhcF+bztK8gooS0+NDJFrdNZjJ3gzVzC545UNA9iw= github.com/karrick/godirwalk v1.16.1/go.mod h1:j4mkqPuvaLI8mp1DroR3P6ad7cyYd4c1qeJ3RV7ULlk= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= diff --git a/services/api/types_test.go b/services/api/types_test.go index dc705ade..bbc7c8ac 100644 --- a/services/api/types_test.go +++ b/services/api/types_test.go @@ -5,12 +5,14 @@ import ( builderApiCapella "github.com/attestantio/go-builder-client/api/capella" builderApiDeneb "github.com/attestantio/go-builder-client/api/deneb" + builderApiElectra "github.com/attestantio/go-builder-client/api/electra" builderApiV1 "github.com/attestantio/go-builder-client/api/v1" builderSpec "github.com/attestantio/go-builder-client/spec" "github.com/attestantio/go-eth2-client/spec" "github.com/attestantio/go-eth2-client/spec/bellatrix" "github.com/attestantio/go-eth2-client/spec/capella" "github.com/attestantio/go-eth2-client/spec/deneb" + "github.com/attestantio/go-eth2-client/spec/electra" "github.com/attestantio/go-eth2-client/spec/phase0" "github.com/flashbots/go-boost-utils/bls" "github.com/flashbots/go-boost-utils/ssz" @@ -122,7 +124,7 @@ func TestBuilderBlockRequestToSignedBuilderBid(t *testing.T) { reqPayload: &common.VersionedSubmitBlockRequest{ VersionedSubmitBlockRequest: builderSpec.VersionedSubmitBlockRequest{ Version: spec.DataVersionElectra, - Electra: &builderApiDeneb.SubmitBlockRequest{ + Electra: &builderApiElectra.SubmitBlockRequest{ ExecutionPayload: &deneb.ExecutionPayload{ ParentHash: phase0.Hash32{0x01}, FeeRecipient: bellatrix.ExecutionAddress{0x02}, @@ -146,6 +148,11 @@ func TestBuilderBlockRequestToSignedBuilderBid(t *testing.T) { Proofs: []deneb.KZGProof{}, Blobs: []deneb.Blob{}, }, + ExecutionRequests: &electra.ExecutionRequests{ + Deposits: []*electra.DepositRequest{}, + Withdrawals: []*electra.WithdrawalRequest{}, + Consolidations: []*electra.ConsolidationRequest{}, + }, Message: &builderApiV1.BidTrace{ Slot: 1, ParentHash: phase0.Hash32{0x01}, diff --git a/services/api/utils.go b/services/api/utils.go index 563901fa..6e0616f3 100644 --- a/services/api/utils.go +++ b/services/api/utils.go @@ -6,10 +6,8 @@ import ( builderApi "github.com/attestantio/go-builder-client/api" "github.com/attestantio/go-eth2-client/spec" "github.com/attestantio/go-eth2-client/spec/capella" - "github.com/attestantio/go-eth2-client/spec/electra" "github.com/attestantio/go-eth2-client/spec/phase0" eth2UtilCapella "github.com/attestantio/go-eth2-client/util/capella" - eth2UtilElectra "github.com/attestantio/go-eth2-client/util/electra" "github.com/flashbots/go-boost-utils/bls" "github.com/flashbots/go-boost-utils/utils" "github.com/flashbots/mev-boost-relay/common" @@ -53,30 +51,6 @@ func ComputeWithdrawalsRoot(w []*capella.Withdrawal) (phase0.Root, error) { return withdrawals.HashTreeRoot() } -func ComputeDepositRequestsRoot(d []*electra.DepositRequest) (phase0.Root, error) { - if d == nil { - return phase0.Root{}, ErrNoDepositRequests - } - depositRequests := eth2UtilElectra.DepositRequests{DepositRequests: d} - return depositRequests.HashTreeRoot() -} - -func ComputeWithdrawalRequestsRoot(e []*electra.WithdrawalRequest) (phase0.Root, error) { - if e == nil { - return phase0.Root{}, ErrNoWithdrawalRequests - } - exits := eth2UtilElectra.WithdrawalRequests{WithdrawalRequests: e} - return exits.HashTreeRoot() -} - -func ComputeConsolidationRequestsRoot(c []*electra.ConsolidationRequest) (phase0.Root, error) { - if c == nil { - return phase0.Root{}, nil - } - consolidations := eth2UtilElectra.ConsolidationRequests{ConsolidationRequests: c} - return consolidations.HashTreeRoot() -} - func EqBlindedBlockContentsToBlockContents(bb *common.VersionedSignedBlindedBeaconBlock, payload *builderApi.VersionedSubmitBlindedBlockResponse) error { if bb.Version != payload.Version { return errors.Wrap(ErrPayloadMismatch, fmt.Sprintf("beacon block version %d does not match payload version %d", bb.Version, payload.Version))