diff --git a/api/versionedexecutionpayload_test.go b/api/versionedexecutionpayload_test.go index 680232e..3473187 100644 --- a/api/versionedexecutionpayload_test.go +++ b/api/versionedexecutionpayload_test.go @@ -43,6 +43,12 @@ func TestVersionedExecutionPayloadEmpty(t *testing.T) { } require.True(t, mismatch2.IsEmpty()) + mismatch3 := &api.VersionedExecutionPayload{ + Version: consensusspec.DataVersionDeneb, + Capella: &capella.ExecutionPayload{}, + } + require.True(t, mismatch3.IsEmpty()) + incorrectVersion := &api.VersionedExecutionPayload{ Version: consensusspec.DataVersionDeneb, Bellatrix: &bellatrix.ExecutionPayload{}, @@ -223,6 +229,29 @@ func TestVersionedExecutionPayloadTransactions(t *testing.T) { {0x01}, }, }, + { + name: "DenebNoData", + bid: &api.VersionedExecutionPayload{ + Version: consensusspec.DataVersionDeneb, + }, + err: "no data", + }, + { + name: "DenebGood", + bid: &api.VersionedExecutionPayload{ + Version: consensusspec.DataVersionDeneb, + Deneb: &deneb.ExecutionPayload{ + Transactions: []bellatrix.Transaction{ + {0x00}, + {0x01}, + }, + }, + }, + res: []bellatrix.Transaction{ + {0x00}, + {0x01}, + }, + }, } for _, test := range tests { diff --git a/spec/versionedsignedbuilderbid.go b/spec/versionedsignedbuilderbid.go index 2c33403..a478ef8 100644 --- a/spec/versionedsignedbuilderbid.go +++ b/spec/versionedsignedbuilderbid.go @@ -20,6 +20,7 @@ import ( "github.com/attestantio/go-builder-client/api/bellatrix" "github.com/attestantio/go-builder-client/api/capella" + "github.com/attestantio/go-builder-client/api/deneb" consensusspec "github.com/attestantio/go-eth2-client/spec" consensusbellatrix "github.com/attestantio/go-eth2-client/spec/bellatrix" "github.com/attestantio/go-eth2-client/spec/phase0" @@ -31,6 +32,7 @@ type VersionedSignedBuilderBid struct { Version consensusspec.DataVersion Bellatrix *bellatrix.SignedBuilderBid Capella *capella.SignedBuilderBid + Deneb *deneb.SignedBuilderBid } // IsEmpty returns true if there is no bid. @@ -40,6 +42,8 @@ func (v *VersionedSignedBuilderBid) IsEmpty() bool { return v.Bellatrix == nil case consensusspec.DataVersionCapella: return v.Capella == nil + case consensusspec.DataVersionDeneb: + return v.Deneb == nil default: return true } @@ -67,6 +71,14 @@ func (v *VersionedSignedBuilderBid) Builder() (phase0.BLSPubKey, error) { return phase0.BLSPubKey{}, errors.New("no data message") } return v.Capella.Message.Pubkey, nil + case consensusspec.DataVersionDeneb: + if v.Deneb == nil { + return phase0.BLSPubKey{}, errors.New("no data") + } + if v.Deneb.Message == nil { + return phase0.BLSPubKey{}, errors.New("no data message") + } + return v.Deneb.Message.Pubkey, nil default: return phase0.BLSPubKey{}, errors.New("unsupported version") } @@ -94,6 +106,14 @@ func (v *VersionedSignedBuilderBid) Value() (*uint256.Int, error) { return nil, errors.New("no data message") } return v.Capella.Message.Value, nil + case consensusspec.DataVersionDeneb: + if v.Deneb == nil { + return nil, errors.New("no data") + } + if v.Deneb.Message == nil { + return nil, errors.New("no data message") + } + return v.Deneb.Message.Value, nil default: return nil, errors.New("unsupported version") } @@ -127,6 +147,17 @@ func (v *VersionedSignedBuilderBid) BlockNumber() (uint64, error) { return 0, errors.New("no data message header") } return v.Capella.Message.Header.BlockNumber, nil + case consensusspec.DataVersionDeneb: + if v.Deneb == nil { + return 0, errors.New("no data") + } + if v.Deneb.Message == nil { + return 0, errors.New("no data message") + } + if v.Deneb.Message.Header == nil { + return 0, errors.New("no data message header") + } + return v.Deneb.Message.Header.BlockNumber, nil default: return 0, errors.New("unsupported version") } @@ -160,6 +191,17 @@ func (v *VersionedSignedBuilderBid) BlockHash() (phase0.Hash32, error) { return phase0.Hash32{}, errors.New("no data message header") } return v.Capella.Message.Header.BlockHash, nil + case consensusspec.DataVersionDeneb: + if v.Deneb == nil { + return phase0.Hash32{}, errors.New("no data") + } + if v.Deneb.Message == nil { + return phase0.Hash32{}, errors.New("no data message") + } + if v.Deneb.Message.Header == nil { + return phase0.Hash32{}, errors.New("no data message header") + } + return v.Deneb.Message.Header.BlockHash, nil default: return phase0.Hash32{}, errors.New("unsupported version") } @@ -193,6 +235,17 @@ func (v *VersionedSignedBuilderBid) ParentHash() (phase0.Hash32, error) { return phase0.Hash32{}, errors.New("no data message header") } return v.Capella.Message.Header.ParentHash, nil + case consensusspec.DataVersionDeneb: + if v.Deneb == nil { + return phase0.Hash32{}, errors.New("no data") + } + if v.Deneb.Message == nil { + return phase0.Hash32{}, errors.New("no data message") + } + if v.Deneb.Message.Header == nil { + return phase0.Hash32{}, errors.New("no data message header") + } + return v.Deneb.Message.Header.ParentHash, nil default: return phase0.Hash32{}, errors.New("unsupported version") } @@ -226,6 +279,17 @@ func (v *VersionedSignedBuilderBid) StateRoot() (phase0.Root, error) { return phase0.Root{}, errors.New("no data message header") } return v.Capella.Message.Header.StateRoot, nil + case consensusspec.DataVersionDeneb: + if v.Deneb == nil { + return phase0.Root{}, errors.New("no data") + } + if v.Deneb.Message == nil { + return phase0.Root{}, errors.New("no data message") + } + if v.Deneb.Message.Header == nil { + return phase0.Root{}, errors.New("no data message header") + } + return v.Deneb.Message.Header.StateRoot, nil default: return phase0.Root{}, errors.New("unsupported version") } @@ -259,6 +323,17 @@ func (v *VersionedSignedBuilderBid) FeeRecipient() (consensusbellatrix.Execution return consensusbellatrix.ExecutionAddress{}, errors.New("no data message header") } return v.Capella.Message.Header.FeeRecipient, nil + case consensusspec.DataVersionDeneb: + if v.Deneb == nil { + return consensusbellatrix.ExecutionAddress{}, errors.New("no data") + } + if v.Deneb.Message == nil { + return consensusbellatrix.ExecutionAddress{}, errors.New("no data message") + } + if v.Deneb.Message.Header == nil { + return consensusbellatrix.ExecutionAddress{}, errors.New("no data message header") + } + return v.Deneb.Message.Header.FeeRecipient, nil default: return consensusbellatrix.ExecutionAddress{}, errors.New("unsupported version") } @@ -292,6 +367,17 @@ func (v *VersionedSignedBuilderBid) Timestamp() (uint64, error) { return 0, errors.New("no data message header") } return v.Capella.Message.Header.Timestamp, nil + case consensusspec.DataVersionDeneb: + if v.Deneb == nil { + return 0, errors.New("no data") + } + if v.Deneb.Message == nil { + return 0, errors.New("no data message") + } + if v.Deneb.Message.Header == nil { + return 0, errors.New("no data message header") + } + return v.Deneb.Message.Header.Timestamp, nil default: return 0, errors.New("unsupported version") } @@ -325,6 +411,17 @@ func (v *VersionedSignedBuilderBid) TransactionsRoot() (phase0.Root, error) { return phase0.Root{}, errors.New("no data message header") } return v.Capella.Message.Header.TransactionsRoot, nil + case consensusspec.DataVersionDeneb: + if v.Deneb == nil { + return phase0.Root{}, errors.New("no data") + } + if v.Deneb.Message == nil { + return phase0.Root{}, errors.New("no data message") + } + if v.Deneb.Message.Header == nil { + return phase0.Root{}, errors.New("no data message header") + } + return v.Deneb.Message.Header.TransactionsRoot, nil default: return phase0.Root{}, errors.New("unsupported version") } @@ -352,6 +449,14 @@ func (v *VersionedSignedBuilderBid) MessageHashTreeRoot() (phase0.Root, error) { return phase0.Root{}, errors.New("no data message") } return v.Capella.Message.HashTreeRoot() + case consensusspec.DataVersionDeneb: + if v.Deneb == nil { + return phase0.Root{}, errors.New("no data") + } + if v.Deneb.Message == nil { + return phase0.Root{}, errors.New("no data message") + } + return v.Deneb.Message.HashTreeRoot() default: return phase0.Root{}, errors.New("unsupported version") } @@ -385,6 +490,17 @@ func (v *VersionedSignedBuilderBid) HeaderHashTreeRoot() (phase0.Root, error) { return phase0.Root{}, errors.New("no data message header") } return v.Capella.Message.Header.HashTreeRoot() + case consensusspec.DataVersionDeneb: + if v.Deneb == nil { + return phase0.Root{}, errors.New("no data") + } + if v.Deneb.Message == nil { + return phase0.Root{}, errors.New("no data message") + } + if v.Deneb.Message.Header == nil { + return phase0.Root{}, errors.New("no data message header") + } + return v.Deneb.Message.Header.HashTreeRoot() default: return phase0.Root{}, errors.New("unsupported version") } @@ -406,6 +522,11 @@ func (v *VersionedSignedBuilderBid) Signature() (phase0.BLSSignature, error) { return phase0.BLSSignature{}, errors.New("no data") } return v.Capella.Signature, nil + case consensusspec.DataVersionDeneb: + if v.Deneb == nil { + return phase0.BLSSignature{}, errors.New("no data") + } + return v.Deneb.Signature, nil default: return phase0.BLSSignature{}, errors.New("unsupported version") } diff --git a/spec/versionedsignedbuilderbid_json.go b/spec/versionedsignedbuilderbid_json.go index 8cff2c7..78cdfa6 100644 --- a/spec/versionedsignedbuilderbid_json.go +++ b/spec/versionedsignedbuilderbid_json.go @@ -19,6 +19,7 @@ import ( "github.com/attestantio/go-builder-client/api/bellatrix" "github.com/attestantio/go-builder-client/api/capella" + "github.com/attestantio/go-builder-client/api/deneb" "github.com/attestantio/go-eth2-client/spec" "github.com/pkg/errors" ) @@ -34,6 +35,10 @@ type capellaVersionedSignedBuilderBidJSON struct { Data *capella.SignedBuilderBid `json:"data"` } +type denebVersionedSignedBuilderBidJSON struct { + Data *deneb.SignedBuilderBid `json:"data"` +} + // MarshalJSON implements json.Marshaler. func (v *VersionedSignedBuilderBid) MarshalJSON() ([]byte, error) { version := &versionJSON{ @@ -65,6 +70,18 @@ func (v *VersionedSignedBuilderBid) MarshalJSON() ([]byte, error) { *capellaVersionedSignedBuilderBidJSON }{version, data} return json.Marshal(payload) + case spec.DataVersionDeneb: + if v.Deneb == nil { + return nil, errors.New("no deneb data") + } + data := &denebVersionedSignedBuilderBidJSON{ + Data: v.Deneb, + } + payload := struct { + *versionJSON + *denebVersionedSignedBuilderBidJSON + }{version, data} + return json.Marshal(payload) default: return nil, fmt.Errorf("unsupported data version %v", v.Version) } @@ -90,6 +107,12 @@ func (v *VersionedSignedBuilderBid) UnmarshalJSON(input []byte) error { return errors.Wrap(err, "invalid JSON") } v.Capella = data.Data + case spec.DataVersionDeneb: + var data denebVersionedSignedBuilderBidJSON + if err := json.Unmarshal(input, &data); err != nil { + return errors.Wrap(err, "invalid JSON") + } + v.Deneb = data.Data default: return fmt.Errorf("unsupported data version %v", metadata.Version) } diff --git a/spec/versionedsignedbuilderbid_json_test.go b/spec/versionedsignedbuilderbid_json_test.go index 3991593..f7c0b45 100644 --- a/spec/versionedsignedbuilderbid_json_test.go +++ b/spec/versionedsignedbuilderbid_json_test.go @@ -65,6 +65,15 @@ func TestVersionedSignedBuilderBidJSON(t *testing.T) { name: "GoodCapella", input: []byte(`{"version":"capella","data":{"message":{"header":{"parent_hash":"0x17f4eeae822cc81533016678413443b95e34517e67f12b4a3a92ff6b66f972ef","fee_recipient":"0x58E809C71e4885cB7B3f1D5c793AB04eD239d779","state_root":"0x3d6e230e6eceb8f3db582777b1500b8b31b9d268339e7b32bba8d6f1311b211d","receipts_root":"0xea760203509bdde017a506b12c825976d12b04db7bce9eca9e1ed007056a3f36","logs_bloom":"0x0c803a8d3c6642adee3185bd914c599317d96487831dabda82461f65700b2528781bdadf785664f9d8b11c4ee1139dfeb056125d2abd67e379cabc6d58f1c3ea304b97cf17fcd8a4c53f4dedeaa041acce062fc8fbc88ffc111577db4a936378749f2fd82b4bfcb880821dd5cbefee984bc1ad116096a64a44a2aac8a1791a7ad3a53d91c584ac69a8973daed6daee4432a198c9935fa0e5c2a4a6ca78b821a5b046e571a5c0961f469d40e429066755fec611afe25b560db07f989933556ce0cea4070ca47677b007b4b9857fc092625f82c84526737dc98e173e34fe6e4d0f1a400fd994298b7c2fa8187331c333c415f0499836ff0eed5c762bf570e67b44","prev_randao":"0x76ff751467270668df463600d26dba58297a986e649bac84ea856712d4779c00","block_number":"2983837628677007840","gas_limit":"6738255228996962210","gas_used":"5573520557770513197","timestamp":"1744720080366521389","extra_data":"0xc648","base_fee_per_gas":"88770397543877639215846057887940126737648744594802753726778414602657613619599","block_hash":"0x42c294e902bfc9884c1ce5fef156d4661bb8f0ff488bface37f18c3e7be64b0f","transactions_root":"0x8457d0eb7611a621e7a094059f087415ffcfc91714fc184a1f3c48db06b4d08b","withdrawals_root":"0x5c1a7e3e0eab917a7c0d677c6b692ed55ce05f07d572e09b1c06d558f474ea7a"},"value":"12345","pubkey":"0x010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101"},"signature":"0x010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101"}}`), }, + { + name: "BadDeneb", + input: []byte(`{"version":"deneb","data":[]}`), + err: "invalid JSON: invalid JSON: json: cannot unmarshal array into Go value of type deneb.signedBuilderBidJSON", + }, + { + name: "GoodDeneb", + input: []byte(`{"version":"deneb","data":{"message":{"header":{"parent_hash":"0x17f4eeae822cc81533016678413443b95e34517e67f12b4a3a92ff6b66f972ef","fee_recipient":"0x58E809C71e4885cB7B3f1D5c793AB04eD239d779","state_root":"0x3d6e230e6eceb8f3db582777b1500b8b31b9d268339e7b32bba8d6f1311b211d","receipts_root":"0xea760203509bdde017a506b12c825976d12b04db7bce9eca9e1ed007056a3f36","logs_bloom":"0x0c803a8d3c6642adee3185bd914c599317d96487831dabda82461f65700b2528781bdadf785664f9d8b11c4ee1139dfeb056125d2abd67e379cabc6d58f1c3ea304b97cf17fcd8a4c53f4dedeaa041acce062fc8fbc88ffc111577db4a936378749f2fd82b4bfcb880821dd5cbefee984bc1ad116096a64a44a2aac8a1791a7ad3a53d91c584ac69a8973daed6daee4432a198c9935fa0e5c2a4a6ca78b821a5b046e571a5c0961f469d40e429066755fec611afe25b560db07f989933556ce0cea4070ca47677b007b4b9857fc092625f82c84526737dc98e173e34fe6e4d0f1a400fd994298b7c2fa8187331c333c415f0499836ff0eed5c762bf570e67b44","prev_randao":"0x76ff751467270668df463600d26dba58297a986e649bac84ea856712d4779c00","block_number":"2983837628677007840","gas_limit":"6738255228996962210","gas_used":"5573520557770513197","timestamp":"1744720080366521389","extra_data":"0xc648","base_fee_per_gas":"88770397543877639215846057887940126737648744594802753726778414602657613619599","block_hash":"0x42c294e902bfc9884c1ce5fef156d4661bb8f0ff488bface37f18c3e7be64b0f","transactions_root":"0x8457d0eb7611a621e7a094059f087415ffcfc91714fc184a1f3c48db06b4d08b","withdrawals_root":"0x5c1a7e3e0eab917a7c0d677c6b692ed55ce05f07d572e09b1c06d558f474ea7a","data_gas_used":"4438756708366371443","excess_data_gas":"12504111653614393862"},"value":"12345","pubkey":"0x010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101","blinded_blobs_bundle":{"commitments":["0x95cc5099bbd8420d8ebade383c00a2346dace60a7604f768cd71501757b4d72eeb7d5474a6b615af10379d69aa9f478f","0xae9f2d2217013ef61f995f9074faead9ec24e8048440164ec3d6029b87d43686dd0c97c2df9554fc997d0d66c3a78929"],"proofs":["0xc6e27a3ae80243ba7ea88eab107a0675020e0745d75ab6a1553691007a50f7f99f597693ac33ae3cea63bf0b90a734ff","0xc6e27a3ae80243ba7ea88eab107a0675020e0745d75ab6a1553691007a50f7f99f597693ac33ae3cea63bf0b90a734ff"],"blob_roots":["0x3c1820c62034fc45c10abc983dbce08de28f303192dea32371a902b3e6a1fc29","0xba4d784293df28bab771a14df58cdbed9d8d64afd0ddf1c52dff3e25fcdd51df"]}},"signature":"0x010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101"}}`), + }, } for _, test := range tests { diff --git a/spec/versionedsignedbuilderbid_test.go b/spec/versionedsignedbuilderbid_test.go index 2aadd3c..5f36bcd 100644 --- a/spec/versionedsignedbuilderbid_test.go +++ b/spec/versionedsignedbuilderbid_test.go @@ -18,10 +18,12 @@ import ( "github.com/attestantio/go-builder-client/api/bellatrix" "github.com/attestantio/go-builder-client/api/capella" + "github.com/attestantio/go-builder-client/api/deneb" "github.com/attestantio/go-builder-client/spec" consensusspec "github.com/attestantio/go-eth2-client/spec" consensusbellatrix "github.com/attestantio/go-eth2-client/spec/bellatrix" consensuscapella "github.com/attestantio/go-eth2-client/spec/capella" + consensusdeneb "github.com/attestantio/go-eth2-client/spec/deneb" "github.com/attestantio/go-eth2-client/spec/phase0" "github.com/holiman/uint256" "github.com/stretchr/testify/require" @@ -147,6 +149,41 @@ func TestVersionedSignedBuilderBidBuilder(t *testing.T) { 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, }, }, + { + name: "DenebNoData", + bid: &spec.VersionedSignedBuilderBid{ + Version: consensusspec.DataVersionDeneb, + }, + err: "no data", + }, + { + name: "DenebNoDataMessage", + bid: &spec.VersionedSignedBuilderBid{ + Version: consensusspec.DataVersionDeneb, + Deneb: &deneb.SignedBuilderBid{}, + }, + err: "no data message", + }, + { + name: "DenebGood", + bid: &spec.VersionedSignedBuilderBid{ + Version: consensusspec.DataVersionDeneb, + Deneb: &deneb.SignedBuilderBid{ + Message: &deneb.BuilderBid{ + Pubkey: phase0.BLSPubKey{ + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, + }, + }, + }, + }, + res: phase0.BLSPubKey{ + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, + }, + }, } for _, test := range tests { @@ -234,6 +271,33 @@ func TestVersionedSignedBuilderBidValue(t *testing.T) { }, res: uint256.NewInt(12345), }, + { + name: "DenebNoData", + bid: &spec.VersionedSignedBuilderBid{ + Version: consensusspec.DataVersionDeneb, + }, + err: "no data", + }, + { + name: "DenebNoDataMessage", + bid: &spec.VersionedSignedBuilderBid{ + Version: consensusspec.DataVersionDeneb, + Deneb: &deneb.SignedBuilderBid{}, + }, + err: "no data message", + }, + { + name: "DenebGood", + bid: &spec.VersionedSignedBuilderBid{ + Version: consensusspec.DataVersionDeneb, + Deneb: &deneb.SignedBuilderBid{ + Message: &deneb.BuilderBid{ + Value: uint256.NewInt(12345), + }, + }, + }, + res: uint256.NewInt(12345), + }, } for _, test := range tests { @@ -345,6 +409,45 @@ func TestVersionedSignedBuilderBidBlockNumber(t *testing.T) { }, res: 123, }, + { + name: "DenebNoData", + bid: &spec.VersionedSignedBuilderBid{ + Version: consensusspec.DataVersionDeneb, + }, + err: "no data", + }, + { + name: "DenebNoDataMessage", + bid: &spec.VersionedSignedBuilderBid{ + Version: consensusspec.DataVersionDeneb, + Deneb: &deneb.SignedBuilderBid{}, + }, + err: "no data message", + }, + { + name: "DenebNoDataMessageHeader", + bid: &spec.VersionedSignedBuilderBid{ + Version: consensusspec.DataVersionDeneb, + Deneb: &deneb.SignedBuilderBid{ + Message: &deneb.BuilderBid{}, + }, + }, + err: "no data message header", + }, + { + name: "DenebGood", + bid: &spec.VersionedSignedBuilderBid{ + Version: consensusspec.DataVersionDeneb, + Deneb: &deneb.SignedBuilderBid{ + Message: &deneb.BuilderBid{ + Header: &consensusdeneb.ExecutionPayloadHeader{ + BlockNumber: 123, + }, + }, + }, + }, + res: 123, + }, } for _, test := range tests { @@ -468,6 +571,51 @@ func TestVersionedSignedBuilderBidParentHash(t *testing.T) { 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, }, }, + { + name: "DenebNoData", + bid: &spec.VersionedSignedBuilderBid{ + Version: consensusspec.DataVersionDeneb, + }, + err: "no data", + }, + { + name: "DenebNoDataMessage", + bid: &spec.VersionedSignedBuilderBid{ + Version: consensusspec.DataVersionDeneb, + Deneb: &deneb.SignedBuilderBid{}, + }, + err: "no data message", + }, + { + name: "DenebNoDataMessageHeader", + bid: &spec.VersionedSignedBuilderBid{ + Version: consensusspec.DataVersionDeneb, + Deneb: &deneb.SignedBuilderBid{ + Message: &deneb.BuilderBid{}, + }, + }, + err: "no data message header", + }, + { + name: "DenebGood", + bid: &spec.VersionedSignedBuilderBid{ + Version: consensusspec.DataVersionDeneb, + Deneb: &deneb.SignedBuilderBid{ + Message: &deneb.BuilderBid{ + Header: &consensusdeneb.ExecutionPayloadHeader{ + ParentHash: phase0.Hash32{ + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + }, + }, + }, + }, + }, + res: phase0.Hash32{ + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + }, + }, } for _, test := range tests { @@ -591,6 +739,51 @@ func TestVersionedSignedBuilderBidBlockHash(t *testing.T) { 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, }, }, + { + name: "DenebNoData", + bid: &spec.VersionedSignedBuilderBid{ + Version: consensusspec.DataVersionDeneb, + }, + err: "no data", + }, + { + name: "DenebNoDataMessage", + bid: &spec.VersionedSignedBuilderBid{ + Version: consensusspec.DataVersionDeneb, + Deneb: &deneb.SignedBuilderBid{}, + }, + err: "no data message", + }, + { + name: "DenebNoDataMessageHeader", + bid: &spec.VersionedSignedBuilderBid{ + Version: consensusspec.DataVersionDeneb, + Deneb: &deneb.SignedBuilderBid{ + Message: &deneb.BuilderBid{}, + }, + }, + err: "no data message header", + }, + { + name: "DenebGood", + bid: &spec.VersionedSignedBuilderBid{ + Version: consensusspec.DataVersionDeneb, + Deneb: &deneb.SignedBuilderBid{ + Message: &deneb.BuilderBid{ + Header: &consensusdeneb.ExecutionPayloadHeader{ + BlockHash: phase0.Hash32{ + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + }, + }, + }, + }, + }, + res: phase0.Hash32{ + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + }, + }, } for _, test := range tests { @@ -714,6 +907,51 @@ func TestVersionedSignedBuilderBidStateRoot(t *testing.T) { 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, }, }, + { + name: "DenebNoData", + bid: &spec.VersionedSignedBuilderBid{ + Version: consensusspec.DataVersionDeneb, + }, + err: "no data", + }, + { + name: "DenebNoDataMessage", + bid: &spec.VersionedSignedBuilderBid{ + Version: consensusspec.DataVersionDeneb, + Deneb: &deneb.SignedBuilderBid{}, + }, + err: "no data message", + }, + { + name: "DenebNoDataMessageHeader", + bid: &spec.VersionedSignedBuilderBid{ + Version: consensusspec.DataVersionDeneb, + Deneb: &deneb.SignedBuilderBid{ + Message: &deneb.BuilderBid{}, + }, + }, + err: "no data message header", + }, + { + name: "DenebGood", + bid: &spec.VersionedSignedBuilderBid{ + Version: consensusspec.DataVersionDeneb, + Deneb: &deneb.SignedBuilderBid{ + Message: &deneb.BuilderBid{ + Header: &consensusdeneb.ExecutionPayloadHeader{ + StateRoot: phase0.Root{ + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + }, + }, + }, + }, + }, + res: phase0.Root{ + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + }, + }, } for _, test := range tests { @@ -833,6 +1071,49 @@ func TestVersionedSignedBuilderBidFeeRecipient(t *testing.T) { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, }, }, + { + name: "DenebNoData", + bid: &spec.VersionedSignedBuilderBid{ + Version: consensusspec.DataVersionDeneb, + }, + err: "no data", + }, + { + name: "DenebNoDataMessage", + bid: &spec.VersionedSignedBuilderBid{ + Version: consensusspec.DataVersionDeneb, + Deneb: &deneb.SignedBuilderBid{}, + }, + err: "no data message", + }, + { + name: "DenebNoDataMessageHeader", + bid: &spec.VersionedSignedBuilderBid{ + Version: consensusspec.DataVersionDeneb, + Deneb: &deneb.SignedBuilderBid{ + Message: &deneb.BuilderBid{}, + }, + }, + err: "no data message header", + }, + { + name: "DenebGood", + bid: &spec.VersionedSignedBuilderBid{ + Version: consensusspec.DataVersionDeneb, + Deneb: &deneb.SignedBuilderBid{ + Message: &deneb.BuilderBid{ + Header: &consensusdeneb.ExecutionPayloadHeader{ + FeeRecipient: consensusbellatrix.ExecutionAddress{ + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, + }, + }, + }, + }, + }, + res: consensusbellatrix.ExecutionAddress{ + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, + }, + }, } for _, test := range tests { @@ -944,6 +1225,45 @@ func TestVersionedSignedBuilderBidTimestamp(t *testing.T) { }, res: 12345, }, + { + name: "DenebNoData", + bid: &spec.VersionedSignedBuilderBid{ + Version: consensusspec.DataVersionDeneb, + }, + err: "no data", + }, + { + name: "DenebNoDataMessage", + bid: &spec.VersionedSignedBuilderBid{ + Version: consensusspec.DataVersionDeneb, + Deneb: &deneb.SignedBuilderBid{}, + }, + err: "no data message", + }, + { + name: "DenebNoDataMessageHeader", + bid: &spec.VersionedSignedBuilderBid{ + Version: consensusspec.DataVersionDeneb, + Deneb: &deneb.SignedBuilderBid{ + Message: &deneb.BuilderBid{}, + }, + }, + err: "no data message header", + }, + { + name: "DenebGood", + bid: &spec.VersionedSignedBuilderBid{ + Version: consensusspec.DataVersionDeneb, + Deneb: &deneb.SignedBuilderBid{ + Message: &deneb.BuilderBid{ + Header: &consensusdeneb.ExecutionPayloadHeader{ + Timestamp: 12345, + }, + }, + }, + }, + res: 12345, + }, } for _, test := range tests { @@ -1067,6 +1387,51 @@ func TestVersionedSignedBuilderBidTransactionsRoot(t *testing.T) { 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, }, }, + { + name: "DenebNoData", + bid: &spec.VersionedSignedBuilderBid{ + Version: consensusspec.DataVersionDeneb, + }, + err: "no data", + }, + { + name: "DenebNoDataMessage", + bid: &spec.VersionedSignedBuilderBid{ + Version: consensusspec.DataVersionDeneb, + Deneb: &deneb.SignedBuilderBid{}, + }, + err: "no data message", + }, + { + name: "DenebNoDataMessageHeader", + bid: &spec.VersionedSignedBuilderBid{ + Version: consensusspec.DataVersionDeneb, + Deneb: &deneb.SignedBuilderBid{ + Message: &deneb.BuilderBid{}, + }, + }, + err: "no data message header", + }, + { + name: "DenebGood", + bid: &spec.VersionedSignedBuilderBid{ + Version: consensusspec.DataVersionDeneb, + Deneb: &deneb.SignedBuilderBid{ + Message: &deneb.BuilderBid{ + Header: &consensusdeneb.ExecutionPayloadHeader{ + TransactionsRoot: phase0.Root{ + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + }, + }, + }, + }, + }, + res: phase0.Root{ + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + }, + }, } for _, test := range tests { @@ -1162,6 +1527,40 @@ func TestVersionedSignedBuilderBidMessageHashTreeRoot(t *testing.T) { 0x9c, 0xd3, 0x88, 0x22, 0x62, 0x86, 0x11, 0x86, 0x5f, 0x74, 0x09, 0x8e, 0x04, 0x94, 0xf8, 0x4b, }, }, + { + name: "DenebNoData", + bid: &spec.VersionedSignedBuilderBid{ + Version: consensusspec.DataVersionDeneb, + }, + err: "no data", + }, + { + name: "DenebNoDataMessage", + bid: &spec.VersionedSignedBuilderBid{ + Version: consensusspec.DataVersionDeneb, + Deneb: &deneb.SignedBuilderBid{}, + }, + err: "no data message", + }, + { + name: "DenebGood", + bid: &spec.VersionedSignedBuilderBid{ + Version: consensusspec.DataVersionDeneb, + Deneb: &deneb.SignedBuilderBid{ + Message: &deneb.BuilderBid{ + Value: uint256.NewInt(12345), + Header: &consensusdeneb.ExecutionPayloadHeader{ + BaseFeePerGas: &uint256.Int{}, + }, + BlindedBlobsBundle: &deneb.BlindedBlobsBundle{}, + }, + }, + }, + res: phase0.Root{ + 0x31, 0x5d, 0x00, 0x52, 0x98, 0x8b, 0x3f, 0x54, 0xc3, 0x74, 0xa1, 0x87, 0x94, 0x30, 0xc8, 0x18, + 0x00, 0x0f, 0x60, 0x50, 0x4a, 0xaa, 0xcf, 0x5b, 0xa5, 0xa9, 0x73, 0xc8, 0xa0, 0xb1, 0x4f, 0xa1, + }, + }, } for _, test := range tests { @@ -1277,6 +1676,49 @@ func TestVersionedSignedBuilderBidHeaderHashTreeRoot(t *testing.T) { 0xad, 0x32, 0xf1, 0x55, 0x80, 0xa9, 0x38, 0xb1, 0x91, 0x4f, 0x93, 0xa9, 0x65, 0x2c, 0x0e, 0x2c, }, }, + { + name: "DenebNoData", + bid: &spec.VersionedSignedBuilderBid{ + Version: consensusspec.DataVersionDeneb, + }, + err: "no data", + }, + { + name: "DenebNoDataMessage", + bid: &spec.VersionedSignedBuilderBid{ + Version: consensusspec.DataVersionDeneb, + Deneb: &deneb.SignedBuilderBid{}, + }, + err: "no data message", + }, + { + name: "DenebNoDataMessageHeader", + bid: &spec.VersionedSignedBuilderBid{ + Version: consensusspec.DataVersionDeneb, + Deneb: &deneb.SignedBuilderBid{ + Message: &deneb.BuilderBid{}, + }, + }, + err: "no data message header", + }, + { + name: "DenebGood", + bid: &spec.VersionedSignedBuilderBid{ + Version: consensusspec.DataVersionDeneb, + Deneb: &deneb.SignedBuilderBid{ + Message: &deneb.BuilderBid{ + Value: uint256.NewInt(12345), + Header: &consensusdeneb.ExecutionPayloadHeader{ + BaseFeePerGas: &uint256.Int{}, + }, + }, + }, + }, + res: phase0.Root{ + 0x54, 0xb4, 0xb8, 0xb8, 0x97, 0x92, 0x9a, 0x1e, 0xde, 0x97, 0xd2, 0x9e, 0x95, 0x51, 0xd6, 0x10, + 0x22, 0x9f, 0x22, 0xc1, 0xa5, 0x9d, 0x18, 0x6d, 0x95, 0xae, 0xd2, 0x03, 0x33, 0x3b, 0x4e, 0x5e, + }, + }, } for _, test := range tests { @@ -1364,6 +1806,33 @@ func TestVersionedSignedBuilderSignature(t *testing.T) { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, }, }, + { + name: "DenebNoData", + bid: &spec.VersionedSignedBuilderBid{ + Version: consensusspec.DataVersionDeneb, + }, + err: "no data", + }, + { + name: "DenebGood", + bid: &spec.VersionedSignedBuilderBid{ + Version: consensusspec.DataVersionDeneb, + Deneb: &deneb.SignedBuilderBid{ + Signature: phase0.BLSSignature{ + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, + }, + }, + }, + res: phase0.BLSSignature{ + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, + }, + }, } for _, test := range tests { @@ -1457,6 +1926,39 @@ func TestVersionedSignedBuilderString(t *testing.T) { }, res: `{"version":"capella","data":{"message":{"header":{"parent_hash":"0x000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f","fee_recipient":"0x0000000000000000000000000000000000000000","state_root":"0x0000000000000000000000000000000000000000000000000000000000000000","receipts_root":"0x0000000000000000000000000000000000000000000000000000000000000000","logs_bloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","prev_randao":"0x0000000000000000000000000000000000000000000000000000000000000000","block_number":"0","gas_limit":"0","gas_used":"0","timestamp":"0","extra_data":"0x","base_fee_per_gas":"0","block_hash":"0x0000000000000000000000000000000000000000000000000000000000000000","transactions_root":"0x0000000000000000000000000000000000000000000000000000000000000000","withdrawals_root":"0x0000000000000000000000000000000000000000000000000000000000000000"},"value":"12345","pubkey":"0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"},"signature":"0x000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f0000000000000000000000000000000000000000000000000000000000000000"}}`, }, + { + name: "DenebNoData", + bid: &spec.VersionedSignedBuilderBid{ + Version: consensusspec.DataVersionDeneb, + }, + res: `ERR: json: error calling MarshalJSON for type *spec.VersionedSignedBuilderBid: no deneb data`, + }, + { + name: "DenebGood", + bid: &spec.VersionedSignedBuilderBid{ + Version: consensusspec.DataVersionDeneb, + Deneb: &deneb.SignedBuilderBid{ + Message: &deneb.BuilderBid{ + Header: &consensusdeneb.ExecutionPayloadHeader{ + ParentHash: phase0.Hash32{ + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + }, + BaseFeePerGas: uint256.NewInt(0), + }, + Value: uint256.NewInt(12345), + BlindedBlobsBundle: &deneb.BlindedBlobsBundle{}, + }, + Signature: phase0.BLSSignature{ + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, + }, + }, + }, + res: `{"version":"deneb","data":{"message":{"header":{"parent_hash":"0x000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f","fee_recipient":"0x0000000000000000000000000000000000000000","state_root":"0x0000000000000000000000000000000000000000000000000000000000000000","receipts_root":"0x0000000000000000000000000000000000000000000000000000000000000000","logs_bloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","prev_randao":"0x0000000000000000000000000000000000000000000000000000000000000000","block_number":"0","gas_limit":"0","gas_used":"0","timestamp":"0","extra_data":"0x","base_fee_per_gas":"0","block_hash":"0x0000000000000000000000000000000000000000000000000000000000000000","transactions_root":"0x0000000000000000000000000000000000000000000000000000000000000000","withdrawals_root":"0x0000000000000000000000000000000000000000000000000000000000000000","data_gas_used":"0","excess_data_gas":"0"},"value":"12345","pubkey":"0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","blinded_blobs_bundle":{"commitments":[],"proofs":[],"blob_roots":[]}},"signature":"0x000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f0000000000000000000000000000000000000000000000000000000000000000"}}`, + }, } for _, test := range tests {