Skip to content

Commit

Permalink
Add execution request support
Browse files Browse the repository at this point in the history
  • Loading branch information
jtraglia committed Oct 14, 2024
1 parent 1278068 commit 61a5230
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 38 deletions.
18 changes: 11 additions & 7 deletions common/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}`,
Expand Down Expand Up @@ -440,6 +441,9 @@ type BlockSubmissionInfo struct {
Blobs []deneb.Blob
BlobGasUsed uint64
ExcessBlobGas uint64
DepositRequests []*electra.DepositRequest
WithdrawalRequests []*electra.WithdrawalRequest
ConsolidationRequests []*electra.ConsolidationRequest
}

/*
Expand Down
6 changes: 4 additions & 2 deletions common/types_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
}
Expand All @@ -188,7 +190,7 @@ func BuilderBlockRequestToSignedBuilderBid(payload *VersionedSubmitBlockRequest,

return &builderSpec.VersionedSignedBuilderBid{
Version: spec.DataVersionElectra,
Electra: &builderApiDeneb.SignedBuilderBid{
Electra: &builderApiElectra.SignedBuilderBid{
Message: &builderBid,
Signature: sig,
},
Expand Down
15 changes: 15 additions & 0 deletions common/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -253,6 +265,9 @@ func GetBlockSubmissionInfo(submission *VersionedSubmitBlockRequest) (*BlockSubm
Blobs: blobs,
BlobGasUsed: blobGasUsed,
ExcessBlobGas: excessBlobGas,
DepositRequests: depositRequests,
WithdrawalRequests: withdrawalRequests,
ConsolidationRequests: consolidationRequests,
}, nil
}

Expand Down
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand Down
9 changes: 8 additions & 1 deletion services/api/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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},
Expand All @@ -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},
Expand Down
26 changes: 0 additions & 26 deletions services/api/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit 61a5230

Please sign in to comment.