diff --git a/api/electra/builderbid.go b/api/electra/builderbid.go index e593c92..c6b1630 100644 --- a/api/electra/builderbid.go +++ b/api/electra/builderbid.go @@ -37,5 +37,6 @@ func (b *BuilderBid) String() string { if err != nil { return fmt.Sprintf("ERR: %v", err) } + return string(data) } diff --git a/api/electra/builderbid_json.go b/api/electra/builderbid_json.go index 20d91a8..293d26b 100644 --- a/api/electra/builderbid_json.go +++ b/api/electra/builderbid_json.go @@ -51,6 +51,7 @@ func (b *BuilderBid) UnmarshalJSON(input []byte) error { if err := json.Unmarshal(input, &data); err != nil { return errors.Wrap(err, "invalid JSON") } + return b.unpack(&data) } diff --git a/api/electra/builderbid_yaml.go b/api/electra/builderbid_yaml.go index 47576b2..0ca8012 100644 --- a/api/electra/builderbid_yaml.go +++ b/api/electra/builderbid_yaml.go @@ -41,6 +41,7 @@ func (b *BuilderBid) MarshalYAML() ([]byte, error) { if err != nil { return nil, err } + return bytes.ReplaceAll(yamlBytes, []byte(`"`), []byte(`'`)), nil } @@ -51,5 +52,6 @@ func (b *BuilderBid) UnmarshalYAML(input []byte) error { if err := yaml.Unmarshal(input, &data); err != nil { return err } + return b.unpack(&data) } diff --git a/api/electra/executionpayloadandblobsbundle.go b/api/electra/executionpayloadandblobsbundle.go index 428ec08..91e6c85 100644 --- a/api/electra/executionpayloadandblobsbundle.go +++ b/api/electra/executionpayloadandblobsbundle.go @@ -33,5 +33,6 @@ func (e *ExecutionPayloadAndBlobsBundle) String() string { if err != nil { return fmt.Sprintf("ERR: %v", err) } + return string(data) } diff --git a/api/electra/executionpayloadandblobsbundle_json.go b/api/electra/executionpayloadandblobsbundle_json.go index 47721fb..13eb70a 100644 --- a/api/electra/executionpayloadandblobsbundle_json.go +++ b/api/electra/executionpayloadandblobsbundle_json.go @@ -41,6 +41,7 @@ func (e *ExecutionPayloadAndBlobsBundle) UnmarshalJSON(input []byte) error { if err := json.Unmarshal(input, &data); err != nil { return errors.Wrap(err, "invalid JSON") } + return e.unpack(&data) } diff --git a/api/electra/executionpayloadandblobsbundle_yaml.go b/api/electra/executionpayloadandblobsbundle_yaml.go index 317e29d..4d3b7ec 100644 --- a/api/electra/executionpayloadandblobsbundle_yaml.go +++ b/api/electra/executionpayloadandblobsbundle_yaml.go @@ -36,6 +36,7 @@ func (e *ExecutionPayloadAndBlobsBundle) MarshalYAML() ([]byte, error) { if err != nil { return nil, err } + return bytes.ReplaceAll(yamlBytes, []byte(`"`), []byte(`'`)), nil } @@ -46,5 +47,6 @@ func (e *ExecutionPayloadAndBlobsBundle) UnmarshalYAML(input []byte) error { if err := yaml.Unmarshal(input, &data); err != nil { return err } + return e.unpack(&data) } diff --git a/api/electra/signedbuilderbid.go b/api/electra/signedbuilderbid.go index 0012ae0..92d7ced 100644 --- a/api/electra/signedbuilderbid.go +++ b/api/electra/signedbuilderbid.go @@ -32,5 +32,6 @@ func (s *SignedBuilderBid) String() string { if err != nil { return fmt.Sprintf("ERR: %v", err) } + return string(data) } diff --git a/api/electra/signedbuilderbid_json.go b/api/electra/signedbuilderbid_json.go index be61493..a12f90b 100644 --- a/api/electra/signedbuilderbid_json.go +++ b/api/electra/signedbuilderbid_json.go @@ -43,6 +43,7 @@ func (s *SignedBuilderBid) UnmarshalJSON(input []byte) error { if err := json.Unmarshal(input, &data); err != nil { return errors.Wrap(err, "invalid JSON") } + return s.unpack(&data) } diff --git a/api/electra/signedbuilderbid_yaml.go b/api/electra/signedbuilderbid_yaml.go index 72a6042..842a58e 100644 --- a/api/electra/signedbuilderbid_yaml.go +++ b/api/electra/signedbuilderbid_yaml.go @@ -35,6 +35,7 @@ func (s *SignedBuilderBid) MarshalYAML() ([]byte, error) { if err != nil { return nil, err } + return bytes.ReplaceAll(yamlBytes, []byte(`"`), []byte(`'`)), nil } @@ -45,5 +46,6 @@ func (s *SignedBuilderBid) UnmarshalYAML(input []byte) error { if err := yaml.Unmarshal(input, &data); err != nil { return err } + return s.unpack(&data) } diff --git a/api/electra/submitblockrequest.go b/api/electra/submitblockrequest.go index 8c6edcb..a67fcd1 100644 --- a/api/electra/submitblockrequest.go +++ b/api/electra/submitblockrequest.go @@ -37,5 +37,6 @@ func (s *SubmitBlockRequest) String() string { if err != nil { return fmt.Sprintf("ERR: %v", err) } + return string(data) } diff --git a/api/electra/submitblockrequest_json.go b/api/electra/submitblockrequest_json.go index a0303ba..f994e34 100644 --- a/api/electra/submitblockrequest_json.go +++ b/api/electra/submitblockrequest_json.go @@ -50,6 +50,7 @@ func (s *SubmitBlockRequest) UnmarshalJSON(input []byte) error { if err := json.Unmarshal(input, &data); err != nil { return errors.Wrap(err, "invalid JSON") } + return s.unpack(&data) } @@ -80,5 +81,6 @@ func (s *SubmitBlockRequest) unpack(data *submitBlockRequestJSON) error { return errors.New("blobs bundle missing") } s.BlobsBundle = data.BlobsBundle + return nil } diff --git a/api/electra/submitblockrequest_yaml.go b/api/electra/submitblockrequest_yaml.go index f0a3b1b..2c31dc6 100644 --- a/api/electra/submitblockrequest_yaml.go +++ b/api/electra/submitblockrequest_yaml.go @@ -42,6 +42,7 @@ func (s *SubmitBlockRequest) MarshalYAML() ([]byte, error) { if err != nil { return nil, err } + return bytes.ReplaceAll(yamlBytes, []byte(`"`), []byte(`'`)), nil } @@ -52,5 +53,6 @@ func (s *SubmitBlockRequest) UnmarshalYAML(input []byte) error { if err := yaml.Unmarshal(input, &data); err != nil { return err } + return s.unpack(&data) } diff --git a/api/versionedexecutionpayload.go b/api/versionedexecutionpayload.go index 144e4cf..5d8ab13 100644 --- a/api/versionedexecutionpayload.go +++ b/api/versionedexecutionpayload.go @@ -75,6 +75,7 @@ func (v *VersionedExecutionPayload) BlockHash() (phase0.Hash32, error) { if v.Electra == nil { return phase0.Hash32{}, errors.New("no data") } + return v.Electra.BlockHash, nil default: return phase0.Hash32{}, errors.New("unsupported version") @@ -109,6 +110,7 @@ func (v *VersionedExecutionPayload) Transactions() ([]bellatrix.Transaction, err if v.Electra == nil { return nil, errors.New("no data") } + return v.Electra.Transactions, nil default: return nil, errors.New("unsupported version") diff --git a/api/versionedexecutionpayload_json.go b/api/versionedexecutionpayload_json.go index 9f8528b..8ff7613 100644 --- a/api/versionedexecutionpayload_json.go +++ b/api/versionedexecutionpayload_json.go @@ -88,6 +88,7 @@ func (v *VersionedExecutionPayload) MarshalJSON() ([]byte, error) { *versionJSON *denebVersionedExecutionPayloadJSON }{version, data} + return json.Marshal(payload) case spec.DataVersionElectra: if v.Electra == nil { @@ -100,6 +101,7 @@ func (v *VersionedExecutionPayload) MarshalJSON() ([]byte, error) { *versionJSON *electraVersionedExecutionPayloadJSON }{version, data} + return json.Marshal(payload) default: return nil, fmt.Errorf("unsupported data version %v", v.Version) diff --git a/api/versionedsubmitblindedblockresponse.go b/api/versionedsubmitblindedblockresponse.go index 0028ad3..1cfc776 100644 --- a/api/versionedsubmitblindedblockresponse.go +++ b/api/versionedsubmitblindedblockresponse.go @@ -84,6 +84,7 @@ func (v *VersionedSubmitBlindedBlockResponse) BlockHash() (phase0.Hash32, error) if v.Electra.ExecutionPayload == nil { return phase0.Hash32{}, errors.New("no execution payload") } + return v.Electra.ExecutionPayload.BlockHash, nil default: return phase0.Hash32{}, errors.New("unsupported version") @@ -124,6 +125,7 @@ func (v *VersionedSubmitBlindedBlockResponse) Transactions() ([]bellatrix.Transa if v.Electra.ExecutionPayload == nil { return nil, errors.New("no execution payload") } + return v.Electra.ExecutionPayload.Transactions, nil default: return nil, errors.New("unsupported version") @@ -143,6 +145,7 @@ func (v *VersionedSubmitBlindedBlockResponse) Blobs() ([]consensusdeneb.Blob, er if v.Deneb.BlobsBundle == nil { return nil, errors.New("no data blobs bundle") } + return v.Deneb.BlobsBundle.Blobs, nil case consensusspec.DataVersionElectra: if v.Electra == nil { @@ -151,6 +154,7 @@ func (v *VersionedSubmitBlindedBlockResponse) Blobs() ([]consensusdeneb.Blob, er if v.Electra.BlobsBundle == nil { return nil, errors.New("no data blobs bundle") } + return v.Electra.BlobsBundle.Blobs, nil default: return nil, errors.New("unsupported version") @@ -170,6 +174,7 @@ func (v *VersionedSubmitBlindedBlockResponse) BlobGasUsed() (uint64, error) { if v.Deneb.ExecutionPayload == nil { return 0, errors.New("no data execution payload") } + return v.Deneb.ExecutionPayload.BlobGasUsed, nil case consensusspec.DataVersionElectra: if v.Electra == nil { @@ -178,6 +183,7 @@ func (v *VersionedSubmitBlindedBlockResponse) BlobGasUsed() (uint64, error) { if v.Electra.ExecutionPayload == nil { return 0, errors.New("no data execution payload") } + return v.Electra.ExecutionPayload.BlobGasUsed, nil default: return 0, errors.New("unsupported version") @@ -197,6 +203,7 @@ func (v *VersionedSubmitBlindedBlockResponse) ExcessBlobGas() (uint64, error) { if v.Deneb.ExecutionPayload == nil { return 0, errors.New("no data execution payload") } + return v.Deneb.ExecutionPayload.ExcessBlobGas, nil case consensusspec.DataVersionElectra: if v.Electra == nil { @@ -205,6 +212,7 @@ func (v *VersionedSubmitBlindedBlockResponse) ExcessBlobGas() (uint64, error) { if v.Electra.ExecutionPayload == nil { return 0, errors.New("no data execution payload") } + return v.Electra.ExecutionPayload.ExcessBlobGas, nil default: return 0, errors.New("unsupported version") @@ -224,6 +232,7 @@ func (v *VersionedSubmitBlindedBlockResponse) DepositReceipts() ([]*consensusele if v.Electra.ExecutionPayload == nil { return nil, errors.New("no data execution payload") } + return v.Electra.ExecutionPayload.DepositReceipts, nil default: return nil, errors.New("unsupported version") @@ -243,6 +252,7 @@ func (v *VersionedSubmitBlindedBlockResponse) WithdrawalRequests() ([]*consensus if v.Electra.ExecutionPayload == nil { return nil, errors.New("no data execution payload") } + return v.Electra.ExecutionPayload.WithdrawalRequests, nil default: return nil, errors.New("unsupported version") diff --git a/api/versionedsubmitblindedblockresponse_json.go b/api/versionedsubmitblindedblockresponse_json.go index c62a713..3c33616 100644 --- a/api/versionedsubmitblindedblockresponse_json.go +++ b/api/versionedsubmitblindedblockresponse_json.go @@ -87,6 +87,7 @@ func (v *VersionedSubmitBlindedBlockResponse) MarshalJSON() ([]byte, error) { *versionJSON *electraVersionedExecutionPayloadAndBlobsBundleJSON }{version, data} + return json.Marshal(payload) default: return nil, fmt.Errorf("unsupported data version %v", v.Version) diff --git a/go.mod b/go.mod index 31ec4e4..00433f0 100644 --- a/go.mod +++ b/go.mod @@ -3,11 +3,12 @@ module github.com/attestantio/go-builder-client go 1.20 require ( - github.com/attestantio/go-eth2-client v0.21.4-0.20240506185515-2ff35ee939f2 + github.com/attestantio/go-eth2-client v0.21.4-0.20240506195511-4654a8b8bc37 github.com/ferranbt/fastssz v0.1.3 // go-yaml after 1.9.2 has memory issues due to https://github.com/goccy/go-yaml/issues/325; avoid. github.com/goccy/go-yaml v1.9.2 github.com/holiman/uint256 v1.2.4 + github.com/huandu/go-clone v1.6.0 github.com/pkg/errors v0.9.1 github.com/prometheus/client_golang v1.16.0 github.com/rs/zerolog v1.32.0 @@ -17,8 +18,6 @@ require ( gotest.tools v2.2.0+incompatible ) -require github.com/huandu/go-clone v1.6.0 - require ( github.com/beorn7/perks v1.0.1 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect diff --git a/go.sum b/go.sum index 1655d8d..24d9a54 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/attestantio/go-eth2-client v0.21.4-0.20240506185515-2ff35ee939f2 h1:zqs9KZ+QbCLw2R/CCdlNXd+bBYsgoNuw3ZNrz7MbyKw= -github.com/attestantio/go-eth2-client v0.21.4-0.20240506185515-2ff35ee939f2/go.mod h1:vhb0ZoQ6bz0kkoyxVbHDRrZTOJbwlY6udFkwfwrJZTE= +github.com/attestantio/go-eth2-client v0.21.4-0.20240506195511-4654a8b8bc37 h1:o6Ds0sAleeYlBs4NjmPI17QhbmbaaDH1sY7a7hDpVrs= +github.com/attestantio/go-eth2-client v0.21.4-0.20240506195511-4654a8b8bc37/go.mod h1:yzMl6JKut8ngKCRyv+6H9j2nNjS/+SMm3N+duf8iix8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= @@ -8,6 +8,7 @@ github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSV github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/fatih/color v1.10.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM= github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM= github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE= github.com/ferranbt/fastssz v0.1.3 h1:ZI+z3JH05h4kgmFXdHuR1aWYsgrg7o+Fw7/NCzM16Mo= @@ -17,11 +18,15 @@ github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= +github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q= +github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no= +github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= github.com/go-playground/validator/v10 v10.4.1 h1:pH2c5ADXtd66mxoE0Zm9SUhxE20r7aM3F26W0hOn+GE= -github.com/goccy/go-yaml v1.11.3 h1:B3W9IdWbvrUu2OYQGwvU1nZtvMQJPBKgBUuweJjLj6I= -github.com/goccy/go-yaml v1.11.3/go.mod h1:wKnAMd44+9JAAnGQpWVEgBzGt3YuTaQ4uXoHvE4m7WU= +github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4= +github.com/goccy/go-yaml v1.9.2 h1:2Njwzw+0+pjU2gb805ZC1B/uBuAs2VcZ3K+ZgHwDs7w= +github.com/goccy/go-yaml v1.9.2/go.mod h1:U/jl18uSupI5rdI2jmuCswEA2htH9eXfferR3KfscvA= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= @@ -44,8 +49,11 @@ github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZY github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y= +github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= +github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= +github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= @@ -85,16 +93,27 @@ go.opentelemetry.io/otel/metric v1.16.0 h1:RbrpwVG1Hfv85LgnZ7+txXioPDoh6EdbZHo26 go.opentelemetry.io/otel/metric v1.16.0/go.mod h1:QE47cpOmkwipPiefDwo2wDzwJrlfxxNYodqc4xnGCo4= go.opentelemetry.io/otel/trace v1.16.0 h1:8JRpaObFoW0pxuVPapkgH8UhHQj+bJW8jJsCZEu5MQs= go.opentelemetry.io/otel/trace v1.16.0/go.mod h1:Yt9vYq1SdNz3xdjZZK7wcXv1qv2pwLkqr2QVwea0ef0= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI= golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y= golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 h1:+cNy6SZtPcJQH3LJVLOSmiC7MMxXNOb3PU/VUEz+EhU= golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028/go.mod h1:NDW/Ps6MPRej6fsCIbMTohpP40sJ/P/vI1MoTEGwX90= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= diff --git a/spec/versionedsignedbuilderbid.go b/spec/versionedsignedbuilderbid.go index 022f821..1fbc781 100644 --- a/spec/versionedsignedbuilderbid.go +++ b/spec/versionedsignedbuilderbid.go @@ -93,6 +93,7 @@ func (v *VersionedSignedBuilderBid) Builder() (phase0.BLSPubKey, error) { if v.Electra.Message == nil { return phase0.BLSPubKey{}, errors.New("no data message") } + return v.Electra.Message.Pubkey, nil default: return phase0.BLSPubKey{}, errors.New("unsupported version") @@ -139,6 +140,7 @@ func (v *VersionedSignedBuilderBid) Value() (*uint256.Int, error) { if v.Electra.Message == nil { return nil, errors.New("no data message") } + return v.Electra.Message.Value, nil default: return nil, errors.New("unsupported version") @@ -197,6 +199,7 @@ func (v *VersionedSignedBuilderBid) BlockNumber() (uint64, error) { if v.Electra.Message.Header == nil { return 0, errors.New("no data message header") } + return v.Electra.Message.Header.BlockNumber, nil default: return 0, errors.New("unsupported version") @@ -255,6 +258,7 @@ func (v *VersionedSignedBuilderBid) BlockHash() (phase0.Hash32, error) { if v.Electra.Message.Header == nil { return phase0.Hash32{}, errors.New("no data message header") } + return v.Electra.Message.Header.BlockHash, nil default: return phase0.Hash32{}, errors.New("unsupported version") @@ -313,6 +317,7 @@ func (v *VersionedSignedBuilderBid) ParentHash() (phase0.Hash32, error) { if v.Electra.Message.Header == nil { return phase0.Hash32{}, errors.New("no data message header") } + return v.Electra.Message.Header.ParentHash, nil default: return phase0.Hash32{}, errors.New("unsupported version") @@ -371,6 +376,7 @@ func (v *VersionedSignedBuilderBid) StateRoot() (phase0.Root, error) { if v.Electra.Message.Header == nil { return phase0.Root{}, errors.New("no data message header") } + return v.Electra.Message.Header.StateRoot, nil default: return phase0.Root{}, errors.New("unsupported version") @@ -429,6 +435,7 @@ func (v *VersionedSignedBuilderBid) FeeRecipient() (consensusbellatrix.Execution if v.Electra.Message.Header == nil { return consensusbellatrix.ExecutionAddress{}, errors.New("no data message header") } + return v.Electra.Message.Header.FeeRecipient, nil default: return consensusbellatrix.ExecutionAddress{}, errors.New("unsupported version") @@ -487,6 +494,7 @@ func (v *VersionedSignedBuilderBid) Timestamp() (uint64, error) { if v.Electra.Message.Header == nil { return 0, errors.New("no data message header") } + return v.Electra.Message.Header.Timestamp, nil default: return 0, errors.New("unsupported version") @@ -545,6 +553,7 @@ func (v *VersionedSignedBuilderBid) TransactionsRoot() (phase0.Root, error) { if v.Electra.Message.Header == nil { return phase0.Root{}, errors.New("no data message header") } + return v.Electra.Message.Header.TransactionsRoot, nil default: return phase0.Root{}, errors.New("unsupported version") @@ -591,6 +600,7 @@ func (v *VersionedSignedBuilderBid) MessageHashTreeRoot() (phase0.Root, error) { if v.Electra.Message == nil { return phase0.Root{}, errors.New("no data message") } + return v.Electra.Message.HashTreeRoot() default: return phase0.Root{}, errors.New("unsupported version") @@ -649,6 +659,7 @@ func (v *VersionedSignedBuilderBid) HeaderHashTreeRoot() (phase0.Root, error) { if v.Electra.Message.Header == nil { return phase0.Root{}, errors.New("no data message header") } + return v.Electra.Message.Header.HashTreeRoot() default: return phase0.Root{}, errors.New("unsupported version") @@ -683,6 +694,7 @@ func (v *VersionedSignedBuilderBid) Signature() (phase0.BLSSignature, error) { if v.Electra == nil { return phase0.BLSSignature{}, errors.New("no data") } + return v.Electra.Signature, nil default: return phase0.BLSSignature{}, errors.New("unsupported version") diff --git a/spec/versionedsignedbuilderbid_json.go b/spec/versionedsignedbuilderbid_json.go index b9a5347..75efe76 100644 --- a/spec/versionedsignedbuilderbid_json.go +++ b/spec/versionedsignedbuilderbid_json.go @@ -101,6 +101,7 @@ func (v *VersionedSignedBuilderBid) MarshalJSON() ([]byte, error) { *versionJSON *electraVersionedSignedBuilderBidJSON }{version, data} + return json.Marshal(payload) default: return nil, fmt.Errorf("unsupported data version %v", v.Version) diff --git a/spec/versionedsubmitblockrequest.go b/spec/versionedsubmitblockrequest.go index 24d20e5..897c684 100644 --- a/spec/versionedsubmitblockrequest.go +++ b/spec/versionedsubmitblockrequest.go @@ -97,6 +97,7 @@ func (v *VersionedSubmitBlockRequest) Slot() (uint64, error) { if v.Electra.Message == nil { return 0, errors.New("no data message") } + return v.Electra.Message.Slot, nil default: return 0, errors.New("unsupported version") @@ -143,6 +144,7 @@ func (v *VersionedSubmitBlockRequest) BlockHash() (phase0.Hash32, error) { if v.Electra.Message == nil { return phase0.Hash32{}, errors.New("no data message") } + return v.Electra.Message.BlockHash, nil default: return phase0.Hash32{}, errors.New("unsupported version") @@ -189,6 +191,7 @@ func (v *VersionedSubmitBlockRequest) Builder() (phase0.BLSPubKey, error) { if v.Electra.Message == nil { return phase0.BLSPubKey{}, errors.New("no data message") } + return v.Electra.Message.BuilderPubkey, nil default: return phase0.BLSPubKey{}, errors.New("unsupported version") @@ -235,6 +238,7 @@ func (v *VersionedSubmitBlockRequest) ProposerFeeRecipient() (consensusbellatrix if v.Electra.Message == nil { return consensusbellatrix.ExecutionAddress{}, errors.New("no data message") } + return v.Electra.Message.ProposerFeeRecipient, nil default: return consensusbellatrix.ExecutionAddress{}, errors.New("unsupported version") @@ -281,6 +285,7 @@ func (v *VersionedSubmitBlockRequest) ProposerPubKey() (phase0.BLSPubKey, error) if v.Electra.Message == nil { return phase0.BLSPubKey{}, errors.New("no data message") } + return v.Electra.Message.ProposerPubkey, nil default: return phase0.BLSPubKey{}, errors.New("unsupported version") @@ -327,6 +332,7 @@ func (v *VersionedSubmitBlockRequest) ParentHash() (phase0.Hash32, error) { if v.Electra.Message == nil { return phase0.Hash32{}, errors.New("no data message") } + return v.Electra.Message.ParentHash, nil default: return phase0.Hash32{}, errors.New("unsupported version") @@ -373,6 +379,7 @@ func (v *VersionedSubmitBlockRequest) Value() (*uint256.Int, error) { if v.Electra.Message == nil { return nil, errors.New("no data message") } + return v.Electra.Message.Value, nil default: return nil, errors.New("unsupported version") @@ -419,6 +426,7 @@ func (v *VersionedSubmitBlockRequest) BidTrace() (*apiv1.BidTrace, error) { if v.Electra.Message == nil { return nil, errors.New("no data message") } + return v.Electra.Message, nil default: return nil, errors.New("unsupported version") @@ -453,6 +461,7 @@ func (v *VersionedSubmitBlockRequest) Signature() (phase0.BLSSignature, error) { if v.Electra == nil { return phase0.BLSSignature{}, errors.New("no data") } + return v.Electra.Signature, nil default: return phase0.BLSSignature{}, errors.New("unsupported version") @@ -499,6 +508,7 @@ func (v *VersionedSubmitBlockRequest) ExecutionPayloadBlockHash() (phase0.Hash32 if v.Electra.ExecutionPayload == nil { return phase0.Hash32{}, errors.New("no data execution payload") } + return v.Electra.ExecutionPayload.BlockHash, nil default: return phase0.Hash32{}, errors.New("unsupported version") @@ -545,6 +555,7 @@ func (v *VersionedSubmitBlockRequest) ExecutionPayloadParentHash() (phase0.Hash3 if v.Electra.ExecutionPayload == nil { return phase0.Hash32{}, errors.New("no data execution payload") } + return v.Electra.ExecutionPayload.ParentHash, nil default: return phase0.Hash32{}, errors.New("unsupported version") @@ -591,6 +602,7 @@ func (v *VersionedSubmitBlockRequest) PrevRandao() (phase0.Hash32, error) { if v.Electra.ExecutionPayload == nil { return phase0.Hash32{}, errors.New("no data execution payload") } + return v.Electra.ExecutionPayload.PrevRandao, nil default: return phase0.Hash32{}, errors.New("unsupported version") @@ -637,6 +649,7 @@ func (v *VersionedSubmitBlockRequest) GasLimit() (uint64, error) { if v.Electra.ExecutionPayload == nil { return 0, errors.New("no data execution payload") } + return v.Electra.ExecutionPayload.GasLimit, nil default: return 0, errors.New("unsupported version") @@ -683,6 +696,7 @@ func (v *VersionedSubmitBlockRequest) GasUsed() (uint64, error) { if v.Electra.ExecutionPayload == nil { return 0, errors.New("no data execution payload") } + return v.Electra.ExecutionPayload.GasUsed, nil default: return 0, errors.New("unsupported version") @@ -729,6 +743,7 @@ func (v *VersionedSubmitBlockRequest) BlockNumber() (uint64, error) { if v.Electra.ExecutionPayload == nil { return 0, errors.New("no data execution payload") } + return v.Electra.ExecutionPayload.BlockNumber, nil default: return 0, errors.New("unsupported version") @@ -775,6 +790,7 @@ func (v *VersionedSubmitBlockRequest) Timestamp() (uint64, error) { if v.Electra.ExecutionPayload == nil { return 0, errors.New("no data execution payload") } + return v.Electra.ExecutionPayload.Timestamp, nil default: return 0, errors.New("unsupported version") @@ -821,6 +837,7 @@ func (v *VersionedSubmitBlockRequest) Transactions() ([]consensusbellatrix.Trans if v.Electra.ExecutionPayload == nil { return nil, errors.New("no data execution payload") } + return v.Electra.ExecutionPayload.Transactions, nil default: return nil, errors.New("unsupported version") @@ -858,6 +875,7 @@ func (v *VersionedSubmitBlockRequest) Withdrawals() ([]*consensuscapella.Withdra if v.Electra.ExecutionPayload == nil { return nil, errors.New("no data execution payload") } + return v.Electra.ExecutionPayload.Withdrawals, nil default: return nil, errors.New("unsupported version") @@ -877,6 +895,7 @@ func (v *VersionedSubmitBlockRequest) Blobs() ([]consensusdeneb.Blob, error) { if v.Deneb.BlobsBundle == nil { return nil, errors.New("no data blobs bundle") } + return v.Deneb.BlobsBundle.Blobs, nil case consensusspec.DataVersionElectra: if v.Electra == nil { @@ -885,6 +904,7 @@ func (v *VersionedSubmitBlockRequest) Blobs() ([]consensusdeneb.Blob, error) { if v.Electra.BlobsBundle == nil { return nil, errors.New("no data blobs bundle") } + return v.Electra.BlobsBundle.Blobs, nil default: return nil, errors.New("unsupported version") @@ -904,6 +924,7 @@ func (v *VersionedSubmitBlockRequest) BlobGasUsed() (uint64, error) { if v.Deneb.ExecutionPayload == nil { return 0, errors.New("no data execution payload") } + return v.Deneb.ExecutionPayload.BlobGasUsed, nil case consensusspec.DataVersionElectra: if v.Electra == nil { @@ -912,6 +933,7 @@ func (v *VersionedSubmitBlockRequest) BlobGasUsed() (uint64, error) { if v.Electra.ExecutionPayload == nil { return 0, errors.New("no data execution payload") } + return v.Electra.ExecutionPayload.BlobGasUsed, nil default: return 0, errors.New("unsupported version") @@ -931,6 +953,7 @@ func (v *VersionedSubmitBlockRequest) ExcessBlobGas() (uint64, error) { if v.Deneb.ExecutionPayload == nil { return 0, errors.New("no data execution payload") } + return v.Deneb.ExecutionPayload.ExcessBlobGas, nil case consensusspec.DataVersionElectra: if v.Electra == nil { @@ -939,6 +962,7 @@ func (v *VersionedSubmitBlockRequest) ExcessBlobGas() (uint64, error) { if v.Electra.ExecutionPayload == nil { return 0, errors.New("no data execution payload") } + return v.Electra.ExecutionPayload.ExcessBlobGas, nil default: return 0, errors.New("unsupported version") @@ -958,6 +982,7 @@ func (v *VersionedSubmitBlockRequest) DepositReceipts() ([]*consensuselectra.Dep if v.Electra.ExecutionPayload == nil { return nil, errors.New("no data execution payload") } + return v.Electra.ExecutionPayload.DepositReceipts, nil default: return nil, errors.New("unsupported version") @@ -977,6 +1002,7 @@ func (v *VersionedSubmitBlockRequest) WithdrawalRequests() ([]*consensuselectra. if v.Electra.ExecutionPayload == nil { return nil, errors.New("no data execution payload") } + return v.Electra.ExecutionPayload.WithdrawalRequests, nil default: return nil, errors.New("unsupported version") diff --git a/spec/versionedsubmitblockrequest_json.go b/spec/versionedsubmitblockrequest_json.go index 11037b9..a5bb81a 100644 --- a/spec/versionedsubmitblockrequest_json.go +++ b/spec/versionedsubmitblockrequest_json.go @@ -97,6 +97,7 @@ func (v *VersionedSubmitBlockRequest) MarshalJSON() ([]byte, error) { *versionJSON *electraVersionedSubmitBlockRequestJSON }{version, data} + return json.Marshal(payload) default: return nil, fmt.Errorf("unsupported data version %v", v.Version)