Skip to content

Commit

Permalink
Fix call to flashbots_validateBuilderSubmissionV4 (#671)
Browse files Browse the repository at this point in the history
* fix(electra): send electra payload for flashbots_validateBuilderSubmissionV4

* Add electra case to VersionedSubmitBlockRequest.UnmarshalSSZ

---------

Co-authored-by: Justin Traglia <[email protected]>
  • Loading branch information
ryanschneider and jtraglia authored Jan 20, 2025
1 parent a6d2ce5 commit e5d991e
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions common/types_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,16 @@ type denebBuilderBlockValidationRequestJSON struct {
ParentBeaconBlockRoot string `json:"parent_beacon_block_root"`
}

type electraBuilderBlockValidationRequestJSON struct {
Message *builderApiV1.BidTrace `json:"message"`
ExecutionPayload *deneb.ExecutionPayload `json:"execution_payload"`
BlobsBundle *builderApiDeneb.BlobsBundle `json:"blobs_bundle"`
ExecutionRequests *electra.ExecutionRequests `json:"execution_requests"`
Signature string `json:"signature"`
RegisteredGasLimit uint64 `json:"registered_gas_limit,string"`
ParentBeaconBlockRoot string `json:"parent_beacon_block_root"`
}

func (r *BuilderBlockValidationRequest) MarshalJSON() ([]byte, error) {
switch r.Version { //nolint:exhaustive
case spec.DataVersionCapella:
Expand All @@ -355,11 +365,11 @@ func (r *BuilderBlockValidationRequest) MarshalJSON() ([]byte, error) {
ParentBeaconBlockRoot: r.ParentBeaconBlockRoot.String(),
})
case spec.DataVersionElectra:
// Electra uses the same ExecutionPayload as Deneb
return json.Marshal(&denebBuilderBlockValidationRequestJSON{
return json.Marshal(&electraBuilderBlockValidationRequestJSON{
Message: r.Electra.Message,
ExecutionPayload: r.Electra.ExecutionPayload,
BlobsBundle: r.Electra.BlobsBundle,
ExecutionRequests: r.Electra.ExecutionRequests,
Signature: r.Electra.Signature.String(),
RegisteredGasLimit: r.RegisteredGasLimit,
ParentBeaconBlockRoot: r.ParentBeaconBlockRoot.String(),
Expand Down Expand Up @@ -392,6 +402,12 @@ func (r *VersionedSubmitBlockRequest) MarshalSSZ() ([]byte, error) {

func (r *VersionedSubmitBlockRequest) UnmarshalSSZ(input []byte) error {
var err error
electraRequest := new(builderApiElectra.SubmitBlockRequest)
if err = electraRequest.UnmarshalSSZ(input); err == nil {
r.Version = spec.DataVersionElectra
r.Electra = electraRequest
return nil
}
denebRequest := new(builderApiDeneb.SubmitBlockRequest)
if err = denebRequest.UnmarshalSSZ(input); err == nil {
r.Version = spec.DataVersionDeneb
Expand Down

0 comments on commit e5d991e

Please sign in to comment.