From 4d86495441b59b1bea0c20bd0c9872a37a561ab8 Mon Sep 17 00:00:00 2001 From: Justin Traglia Date: Wed, 25 Sep 2024 13:32:57 -0500 Subject: [PATCH] Make necessary changes for alpha.6 --- api/electra/builderbid.go | 42 ---- api/electra/builderbid_json.go | 98 ---------- api/electra/builderbid_ssz.go | 185 ------------------ api/electra/builderbid_yaml.go | 57 ------ api/electra/executionpayloadandblobsbundle.go | 38 ---- .../executionpayloadandblobsbundle_json.go | 60 ------ .../executionpayloadandblobsbundle_ssz.go | 143 -------------- .../executionpayloadandblobsbundle_yaml.go | 52 ----- api/electra/generate.go | 20 -- api/electra/signedbuilderbid.go | 37 ---- api/electra/signedbuilderbid_json.go | 68 ------- api/electra/signedbuilderbid_ssz.go | 111 ----------- api/electra/signedbuilderbid_yaml.go | 51 ----- api/electra/submitblockrequest.go | 42 ---- api/electra/submitblockrequest_json.go | 86 -------- api/electra/submitblockrequest_ssz.go | 177 ----------------- api/electra/submitblockrequest_yaml.go | 58 ------ api/versionedexecutionpayload.go | 3 +- api/versionedexecutionpayload_json.go | 11 +- api/versionedexecutionpayloadheader.go | 3 +- api/versionedsubmitblindedblockresponse.go | 44 +---- ...ersionedsubmitblindedblockresponse_json.go | 3 +- go.mod | 3 + go.sum | 4 +- http/builderbid.go | 3 +- http/unblindproposal.go | 3 +- spec/versionedsignedbuilderbid.go | 3 +- spec/versionedsignedbuilderbid_json.go | 3 +- spec/versionedsubmitblockrequest.go | 64 +----- spec/versionedsubmitblockrequest_json.go | 3 +- 30 files changed, 18 insertions(+), 1457 deletions(-) delete mode 100644 api/electra/builderbid.go delete mode 100644 api/electra/builderbid_json.go delete mode 100644 api/electra/builderbid_ssz.go delete mode 100644 api/electra/builderbid_yaml.go delete mode 100644 api/electra/executionpayloadandblobsbundle.go delete mode 100644 api/electra/executionpayloadandblobsbundle_json.go delete mode 100644 api/electra/executionpayloadandblobsbundle_ssz.go delete mode 100644 api/electra/executionpayloadandblobsbundle_yaml.go delete mode 100644 api/electra/generate.go delete mode 100644 api/electra/signedbuilderbid.go delete mode 100644 api/electra/signedbuilderbid_json.go delete mode 100644 api/electra/signedbuilderbid_ssz.go delete mode 100644 api/electra/signedbuilderbid_yaml.go delete mode 100644 api/electra/submitblockrequest.go delete mode 100644 api/electra/submitblockrequest_json.go delete mode 100644 api/electra/submitblockrequest_ssz.go delete mode 100644 api/electra/submitblockrequest_yaml.go diff --git a/api/electra/builderbid.go b/api/electra/builderbid.go deleted file mode 100644 index c6b1630..0000000 --- a/api/electra/builderbid.go +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright © 2022 Attestant Limited. -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package electra - -import ( - "fmt" - - "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/goccy/go-yaml" - "github.com/holiman/uint256" -) - -// BuilderBid represents a BuilderBid. -type BuilderBid struct { - Header *electra.ExecutionPayloadHeader - BlobKZGCommitments []deneb.KZGCommitment `ssz-max:"4096" ssz-size:"?,48"` - Value *uint256.Int `ssz-size:"32"` - Pubkey phase0.BLSPubKey `ssz-size:"48"` -} - -// String returns a string version of the structure. -func (b *BuilderBid) String() string { - data, err := yaml.Marshal(b) - 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 deleted file mode 100644 index 293d26b..0000000 --- a/api/electra/builderbid_json.go +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright © 2024 Attestant Limited. -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package electra - -import ( - "encoding/hex" - "encoding/json" - "fmt" - "math/big" - "strings" - - "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/holiman/uint256" - "github.com/pkg/errors" -) - -// builderBidJSON is the spec representation of the struct. -type builderBidJSON struct { - Header *electra.ExecutionPayloadHeader `json:"header"` - BlobKZGCommitments []deneb.KZGCommitment `json:"blob_kzg_commitments"` - Value string `json:"value"` - Pubkey string `json:"pubkey"` -} - -// MarshalJSON implements json.Marshaler. -func (b *BuilderBid) MarshalJSON() ([]byte, error) { - return json.Marshal(&builderBidJSON{ - Header: b.Header, - BlobKZGCommitments: b.BlobKZGCommitments, - Value: fmt.Sprintf("%d", b.Value), - Pubkey: b.Pubkey.String(), - }) -} - -// UnmarshalJSON implements json.Unmarshaler. -func (b *BuilderBid) UnmarshalJSON(input []byte) error { - var data builderBidJSON - if err := json.Unmarshal(input, &data); err != nil { - return errors.Wrap(err, "invalid JSON") - } - - return b.unpack(&data) -} - -func (b *BuilderBid) unpack(data *builderBidJSON) error { - if data.Header == nil { - return errors.New("header missing") - } - b.Header = data.Header - - if data.Value == "" { - return errors.New("value missing") - } - value, success := new(big.Int).SetString(data.Value, 10) - if !success { - return errors.New("invalid value for value") - } - if value.Sign() == -1 { - return errors.New("value cannot be negative") - } - var overflow bool - b.Value, overflow = uint256.FromBig(value) - if overflow { - return errors.New("value overflow") - } - - if data.Pubkey == "" { - return errors.New("public key missing") - } - pubKey, err := hex.DecodeString(strings.TrimPrefix(data.Pubkey, "0x")) - if err != nil { - return errors.Wrap(err, "invalid value for public key") - } - if len(pubKey) != phase0.PublicKeyLength { - return errors.New("incorrect length for public key") - } - copy(b.Pubkey[:], pubKey) - - if data.BlobKZGCommitments == nil { - return errors.New("blob KZG commitments missing") - } - b.BlobKZGCommitments = data.BlobKZGCommitments - - return nil -} diff --git a/api/electra/builderbid_ssz.go b/api/electra/builderbid_ssz.go deleted file mode 100644 index baaf72a..0000000 --- a/api/electra/builderbid_ssz.go +++ /dev/null @@ -1,185 +0,0 @@ -// Code generated by fastssz. DO NOT EDIT. -// Hash: 4beadbfbd95d5654c51275d7c365975e67d9b7d964b5d245c7ac5c64964f4c7f -// Version: 0.1.3 -package electra - -import ( - "github.com/attestantio/go-eth2-client/spec/deneb" - "github.com/attestantio/go-eth2-client/spec/electra" - ssz "github.com/ferranbt/fastssz" - "github.com/holiman/uint256" -) - -// MarshalSSZ ssz marshals the BuilderBid object -func (b *BuilderBid) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} - -// MarshalSSZTo ssz marshals the BuilderBid object to a target array -func (b *BuilderBid) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(88) - - // Offset (0) 'Header' - dst = ssz.WriteOffset(dst, offset) - if b.Header == nil { - b.Header = new(electra.ExecutionPayloadHeader) - } - offset += b.Header.SizeSSZ() - - // Offset (1) 'BlobKZGCommitments' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.BlobKZGCommitments) * 48 - - // Field (2) 'Value' - value := b.Value.Bytes32() - for i := 0; i < 32; i++ { - dst = append(dst, value[31-i]) - } - - // Field (3) 'Pubkey' - dst = append(dst, b.Pubkey[:]...) - - // Field (0) 'Header' - if dst, err = b.Header.MarshalSSZTo(dst); err != nil { - return - } - - // Field (1) 'BlobKZGCommitments' - if size := len(b.BlobKZGCommitments); size > 4096 { - err = ssz.ErrListTooBigFn("BuilderBid.BlobKZGCommitments", size, 4096) - return - } - for ii := 0; ii < len(b.BlobKZGCommitments); ii++ { - dst = append(dst, b.BlobKZGCommitments[ii][:]...) - } - - return -} - -// UnmarshalSSZ ssz unmarshals the BuilderBid object -func (b *BuilderBid) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 88 { - return ssz.ErrSize - } - - tail := buf - var o0, o1 uint64 - - // Offset (0) 'Header' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } - - if o0 < 88 { - return ssz.ErrInvalidVariableOffset - } - - // Offset (1) 'BlobKZGCommitments' - if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 { - return ssz.ErrOffset - } - - // Field (2) 'Value' - value := make([]byte, 32) - for i := 0; i < 32; i++ { - value[i] = buf[39-i] - } - if b.Value == nil { - b.Value = new(uint256.Int) - } - b.Value.SetBytes32(value) - - // Field (3) 'Pubkey' - copy(b.Pubkey[:], buf[40:88]) - - // Field (0) 'Header' - { - buf = tail[o0:o1] - if b.Header == nil { - b.Header = new(electra.ExecutionPayloadHeader) - } - if err = b.Header.UnmarshalSSZ(buf); err != nil { - return err - } - } - - // Field (1) 'BlobKZGCommitments' - { - buf = tail[o1:] - num, err := ssz.DivideInt2(len(buf), 48, 4096) - if err != nil { - return err - } - b.BlobKZGCommitments = make([]deneb.KZGCommitment, num) - for ii := 0; ii < num; ii++ { - copy(b.BlobKZGCommitments[ii][:], buf[ii*48:(ii+1)*48]) - } - } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the BuilderBid object -func (b *BuilderBid) SizeSSZ() (size int) { - size = 88 - - // Field (0) 'Header' - if b.Header == nil { - b.Header = new(electra.ExecutionPayloadHeader) - } - size += b.Header.SizeSSZ() - - // Field (1) 'BlobKZGCommitments' - size += len(b.BlobKZGCommitments) * 48 - - return -} - -// HashTreeRoot ssz hashes the BuilderBid object -func (b *BuilderBid) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) -} - -// HashTreeRootWith ssz hashes the BuilderBid object with a hasher -func (b *BuilderBid) HashTreeRootWith(hh ssz.HashWalker) (err error) { - indx := hh.Index() - - // Field (0) 'Header' - if err = b.Header.HashTreeRootWith(hh); err != nil { - return - } - - // Field (1) 'BlobKZGCommitments' - { - if size := len(b.BlobKZGCommitments); size > 4096 { - err = ssz.ErrListTooBigFn("BuilderBid.BlobKZGCommitments", size, 4096) - return - } - subIndx := hh.Index() - for _, i := range b.BlobKZGCommitments { - hh.PutBytes(i[:]) - } - numItems := uint64(len(b.BlobKZGCommitments)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) - } - - // Field (2) 'Value' - value := b.Value.Bytes32() - for i, j := 0, 31; i < j; i, j = i+1, j-1 { - value[i], value[j] = value[j], value[i] - } - hh.PutBytes(value[:]) - - // Field (3) 'Pubkey' - hh.PutBytes(b.Pubkey[:]) - - hh.Merkleize(indx) - return -} - -// GetTree ssz hashes the BuilderBid object -func (b *BuilderBid) GetTree() (*ssz.Node, error) { - return ssz.ProofTree(b) -} diff --git a/api/electra/builderbid_yaml.go b/api/electra/builderbid_yaml.go deleted file mode 100644 index 0ca8012..0000000 --- a/api/electra/builderbid_yaml.go +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright © 2024 Attestant Limited. -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package electra - -import ( - "bytes" - "math/big" - - "github.com/attestantio/go-eth2-client/spec/deneb" - "github.com/attestantio/go-eth2-client/spec/electra" - "github.com/goccy/go-yaml" -) - -// builderBidYAML is the spec representation of the struct. -type builderBidYAML struct { - Header *electra.ExecutionPayloadHeader `yaml:"header"` - BlobKZGCommitments []deneb.KZGCommitment `yaml:"blob_kzg_commitments"` - Value *big.Int `yaml:"value"` - Pubkey string `yaml:"pubkey"` -} - -// MarshalYAML implements yaml.Marshaler. -func (b *BuilderBid) MarshalYAML() ([]byte, error) { - yamlBytes, err := yaml.MarshalWithOptions(&builderBidYAML{ - Header: b.Header, - BlobKZGCommitments: b.BlobKZGCommitments, - Value: b.Value.ToBig(), - Pubkey: b.Pubkey.String(), - }, yaml.Flow(true)) - if err != nil { - return nil, err - } - - return bytes.ReplaceAll(yamlBytes, []byte(`"`), []byte(`'`)), nil -} - -// UnmarshalYAML implements yaml.Unmarshaler. -func (b *BuilderBid) UnmarshalYAML(input []byte) error { - // We unmarshal to the JSON struct to save on duplicate code. - var data builderBidJSON - 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 deleted file mode 100644 index 91e6c85..0000000 --- a/api/electra/executionpayloadandblobsbundle.go +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright © 2024 Attestant Limited. -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package electra - -import ( - "fmt" - - "github.com/attestantio/go-builder-client/api/deneb" - "github.com/attestantio/go-eth2-client/spec/electra" - "github.com/goccy/go-yaml" -) - -// ExecutionPayloadAndBlobsBundle represents an execution layer payload. -type ExecutionPayloadAndBlobsBundle struct { - ExecutionPayload *electra.ExecutionPayload - BlobsBundle *deneb.BlobsBundle -} - -// String returns a string version of the structure. -func (e *ExecutionPayloadAndBlobsBundle) String() string { - data, err := yaml.Marshal(e) - 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 deleted file mode 100644 index 13eb70a..0000000 --- a/api/electra/executionpayloadandblobsbundle_json.go +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright © 2024 Attestant Limited. -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package electra - -import ( - "encoding/json" - - "github.com/attestantio/go-builder-client/api/deneb" - "github.com/attestantio/go-eth2-client/spec/electra" - "github.com/pkg/errors" -) - -// executionPayloadAndBlobsBundleJSON is the spec representation of the struct. -type executionPayloadAndBlobsBundleJSON struct { - ExecutionPayload *electra.ExecutionPayload `json:"execution_payload"` - BlobsBundle *deneb.BlobsBundle `json:"blobs_bundle"` -} - -// MarshalJSON implements json.Marshaler. -func (e *ExecutionPayloadAndBlobsBundle) MarshalJSON() ([]byte, error) { - return json.Marshal(&executionPayloadAndBlobsBundleJSON{ - ExecutionPayload: e.ExecutionPayload, - BlobsBundle: e.BlobsBundle, - }) -} - -// UnmarshalJSON implements json.Unmarshaler. -func (e *ExecutionPayloadAndBlobsBundle) UnmarshalJSON(input []byte) error { - var data executionPayloadAndBlobsBundleJSON - if err := json.Unmarshal(input, &data); err != nil { - return errors.Wrap(err, "invalid JSON") - } - - return e.unpack(&data) -} - -func (e *ExecutionPayloadAndBlobsBundle) unpack(data *executionPayloadAndBlobsBundleJSON) error { - if data.ExecutionPayload == nil { - return errors.New("execution payload missing") - } - e.ExecutionPayload = data.ExecutionPayload - - if data.BlobsBundle == nil { - return errors.New("blobs bundle missing") - } - e.BlobsBundle = data.BlobsBundle - - return nil -} diff --git a/api/electra/executionpayloadandblobsbundle_ssz.go b/api/electra/executionpayloadandblobsbundle_ssz.go deleted file mode 100644 index b4b1fe1..0000000 --- a/api/electra/executionpayloadandblobsbundle_ssz.go +++ /dev/null @@ -1,143 +0,0 @@ -// Code generated by fastssz. DO NOT EDIT. -// Hash: 4beadbfbd95d5654c51275d7c365975e67d9b7d964b5d245c7ac5c64964f4c7f -// Version: 0.1.3 -package electra - -import ( - "github.com/attestantio/go-builder-client/api/deneb" - "github.com/attestantio/go-eth2-client/spec/electra" - ssz "github.com/ferranbt/fastssz" -) - -// MarshalSSZ ssz marshals the ExecutionPayloadAndBlobsBundle object -func (e *ExecutionPayloadAndBlobsBundle) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(e) -} - -// MarshalSSZTo ssz marshals the ExecutionPayloadAndBlobsBundle object to a target array -func (e *ExecutionPayloadAndBlobsBundle) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(8) - - // Offset (0) 'ExecutionPayload' - dst = ssz.WriteOffset(dst, offset) - if e.ExecutionPayload == nil { - e.ExecutionPayload = new(electra.ExecutionPayload) - } - offset += e.ExecutionPayload.SizeSSZ() - - // Offset (1) 'BlobsBundle' - dst = ssz.WriteOffset(dst, offset) - if e.BlobsBundle == nil { - e.BlobsBundle = new(deneb.BlobsBundle) - } - offset += e.BlobsBundle.SizeSSZ() - - // Field (0) 'ExecutionPayload' - if dst, err = e.ExecutionPayload.MarshalSSZTo(dst); err != nil { - return - } - - // Field (1) 'BlobsBundle' - if dst, err = e.BlobsBundle.MarshalSSZTo(dst); err != nil { - return - } - - return -} - -// UnmarshalSSZ ssz unmarshals the ExecutionPayloadAndBlobsBundle object -func (e *ExecutionPayloadAndBlobsBundle) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 8 { - return ssz.ErrSize - } - - tail := buf - var o0, o1 uint64 - - // Offset (0) 'ExecutionPayload' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } - - if o0 < 8 { - return ssz.ErrInvalidVariableOffset - } - - // Offset (1) 'BlobsBundle' - if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 { - return ssz.ErrOffset - } - - // Field (0) 'ExecutionPayload' - { - buf = tail[o0:o1] - if e.ExecutionPayload == nil { - e.ExecutionPayload = new(electra.ExecutionPayload) - } - if err = e.ExecutionPayload.UnmarshalSSZ(buf); err != nil { - return err - } - } - - // Field (1) 'BlobsBundle' - { - buf = tail[o1:] - if e.BlobsBundle == nil { - e.BlobsBundle = new(deneb.BlobsBundle) - } - if err = e.BlobsBundle.UnmarshalSSZ(buf); err != nil { - return err - } - } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the ExecutionPayloadAndBlobsBundle object -func (e *ExecutionPayloadAndBlobsBundle) SizeSSZ() (size int) { - size = 8 - - // Field (0) 'ExecutionPayload' - if e.ExecutionPayload == nil { - e.ExecutionPayload = new(electra.ExecutionPayload) - } - size += e.ExecutionPayload.SizeSSZ() - - // Field (1) 'BlobsBundle' - if e.BlobsBundle == nil { - e.BlobsBundle = new(deneb.BlobsBundle) - } - size += e.BlobsBundle.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the ExecutionPayloadAndBlobsBundle object -func (e *ExecutionPayloadAndBlobsBundle) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(e) -} - -// HashTreeRootWith ssz hashes the ExecutionPayloadAndBlobsBundle object with a hasher -func (e *ExecutionPayloadAndBlobsBundle) HashTreeRootWith(hh ssz.HashWalker) (err error) { - indx := hh.Index() - - // Field (0) 'ExecutionPayload' - if err = e.ExecutionPayload.HashTreeRootWith(hh); err != nil { - return - } - - // Field (1) 'BlobsBundle' - if err = e.BlobsBundle.HashTreeRootWith(hh); err != nil { - return - } - - hh.Merkleize(indx) - return -} - -// GetTree ssz hashes the ExecutionPayloadAndBlobsBundle object -func (e *ExecutionPayloadAndBlobsBundle) GetTree() (*ssz.Node, error) { - return ssz.ProofTree(e) -} diff --git a/api/electra/executionpayloadandblobsbundle_yaml.go b/api/electra/executionpayloadandblobsbundle_yaml.go deleted file mode 100644 index 4d3b7ec..0000000 --- a/api/electra/executionpayloadandblobsbundle_yaml.go +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright © 2024 Attestant Limited. -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package electra - -import ( - "bytes" - - "github.com/attestantio/go-builder-client/api/deneb" - "github.com/attestantio/go-eth2-client/spec/electra" - "github.com/goccy/go-yaml" -) - -// executionPayloadAndBlobsBundleYAML is the spec representation of the struct. -type executionPayloadAndBlobsBundleYAML struct { - ExecutionPayload *electra.ExecutionPayload `yaml:"execution_payload"` - BlobsBundle *deneb.BlobsBundle `yaml:"blobs_bundle"` -} - -// MarshalYAML implements yaml.Marshaler. -func (e *ExecutionPayloadAndBlobsBundle) MarshalYAML() ([]byte, error) { - yamlBytes, err := yaml.MarshalWithOptions(&executionPayloadAndBlobsBundleYAML{ - ExecutionPayload: e.ExecutionPayload, - BlobsBundle: e.BlobsBundle, - }, yaml.Flow(true)) - if err != nil { - return nil, err - } - - return bytes.ReplaceAll(yamlBytes, []byte(`"`), []byte(`'`)), nil -} - -// UnmarshalYAML implements yaml.Unmarshaler. -func (e *ExecutionPayloadAndBlobsBundle) UnmarshalYAML(input []byte) error { - // We unmarshal to the JSON struct to save on duplicate code. - var data executionPayloadAndBlobsBundleJSON - if err := yaml.Unmarshal(input, &data); err != nil { - return err - } - - return e.unpack(&data) -} diff --git a/api/electra/generate.go b/api/electra/generate.go deleted file mode 100644 index 165275c..0000000 --- a/api/electra/generate.go +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright © 2024 Attestant Limited. -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package electra - -// Need to `go install github.com/ferranbt/fastssz/sszgen@latest` for this to work. -//go:generate rm -f builderbid_ssz.go executionpayloadandblobsbundle_ssz.go signedbuilderbid_ssz.go submitblockrequest_ssz.go -//nolint:revive -//go:generate sszgen --suffix ssz --include ../../../go-eth2-client/spec/phase0,../../../go-eth2-client/spec/bellatrix,../../../go-eth2-client/spec/capella,../../../go-eth2-client/spec/deneb,../../../go-eth2-client/spec/electra,../v1,../deneb --path . --objs BuilderBid,ExecutionPayloadAndBlobsBundle,SignedBuilderBid,SubmitBlockRequest -//go:generate goimports -w builderbid_ssz.go executionpayloadandblobsbundle_ssz.go signedbuilderbid_ssz.go submitblockrequest_ssz.go diff --git a/api/electra/signedbuilderbid.go b/api/electra/signedbuilderbid.go deleted file mode 100644 index 92d7ced..0000000 --- a/api/electra/signedbuilderbid.go +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright © 2022 Attestant Limited. -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package electra - -import ( - "fmt" - - "github.com/attestantio/go-eth2-client/spec/phase0" - "github.com/goccy/go-yaml" -) - -// SignedBuilderBid represents a SignedBuilderBid. -type SignedBuilderBid struct { - Message *BuilderBid - Signature phase0.BLSSignature `ssz-size:"96"` -} - -// String returns a string version of the structure. -func (s *SignedBuilderBid) String() string { - data, err := yaml.Marshal(s) - 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 deleted file mode 100644 index a12f90b..0000000 --- a/api/electra/signedbuilderbid_json.go +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright © 2024 Attestant Limited. -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package electra - -import ( - "encoding/hex" - "encoding/json" - "fmt" - "strings" - - "github.com/attestantio/go-eth2-client/spec/phase0" - "github.com/pkg/errors" -) - -// signedBuilderBidJSON is the spec representation of the struct. -type signedBuilderBidJSON struct { - Message *BuilderBid `json:"message"` - Signature string `json:"signature"` -} - -// MarshalJSON implements json.Marshaler. -func (s *SignedBuilderBid) MarshalJSON() ([]byte, error) { - return json.Marshal(&signedBuilderBidJSON{ - Message: s.Message, - Signature: fmt.Sprintf("%#x", s.Signature), - }) -} - -// UnmarshalJSON implements json.Unmarshaler. -func (s *SignedBuilderBid) UnmarshalJSON(input []byte) error { - var data signedBuilderBidJSON - if err := json.Unmarshal(input, &data); err != nil { - return errors.Wrap(err, "invalid JSON") - } - - return s.unpack(&data) -} - -func (s *SignedBuilderBid) unpack(data *signedBuilderBidJSON) error { - if data.Message == nil { - return errors.New("message missing") - } - s.Message = data.Message - if data.Signature == "" { - return errors.New("signature missing") - } - signature, err := hex.DecodeString(strings.TrimPrefix(data.Signature, "0x")) - if err != nil { - return errors.Wrap(err, "invalid value for signature") - } - if len(signature) != phase0.SignatureLength { - return errors.New("incorrect length for signature") - } - copy(s.Signature[:], signature) - - return nil -} diff --git a/api/electra/signedbuilderbid_ssz.go b/api/electra/signedbuilderbid_ssz.go deleted file mode 100644 index d7ecdba..0000000 --- a/api/electra/signedbuilderbid_ssz.go +++ /dev/null @@ -1,111 +0,0 @@ -// Code generated by fastssz. DO NOT EDIT. -// Hash: 4beadbfbd95d5654c51275d7c365975e67d9b7d964b5d245c7ac5c64964f4c7f -// Version: 0.1.3 -package electra - -import ( - ssz "github.com/ferranbt/fastssz" -) - -// MarshalSSZ ssz marshals the SignedBuilderBid object -func (s *SignedBuilderBid) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) -} - -// MarshalSSZTo ssz marshals the SignedBuilderBid object to a target array -func (s *SignedBuilderBid) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(100) - - // Offset (0) 'Message' - dst = ssz.WriteOffset(dst, offset) - if s.Message == nil { - s.Message = new(BuilderBid) - } - offset += s.Message.SizeSSZ() - - // Field (1) 'Signature' - dst = append(dst, s.Signature[:]...) - - // Field (0) 'Message' - if dst, err = s.Message.MarshalSSZTo(dst); err != nil { - return - } - - return -} - -// UnmarshalSSZ ssz unmarshals the SignedBuilderBid object -func (s *SignedBuilderBid) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 100 { - return ssz.ErrSize - } - - tail := buf - var o0 uint64 - - // Offset (0) 'Message' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } - - if o0 < 100 { - return ssz.ErrInvalidVariableOffset - } - - // Field (1) 'Signature' - copy(s.Signature[:], buf[4:100]) - - // Field (0) 'Message' - { - buf = tail[o0:] - if s.Message == nil { - s.Message = new(BuilderBid) - } - if err = s.Message.UnmarshalSSZ(buf); err != nil { - return err - } - } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the SignedBuilderBid object -func (s *SignedBuilderBid) SizeSSZ() (size int) { - size = 100 - - // Field (0) 'Message' - if s.Message == nil { - s.Message = new(BuilderBid) - } - size += s.Message.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the SignedBuilderBid object -func (s *SignedBuilderBid) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) -} - -// HashTreeRootWith ssz hashes the SignedBuilderBid object with a hasher -func (s *SignedBuilderBid) HashTreeRootWith(hh ssz.HashWalker) (err error) { - indx := hh.Index() - - // Field (0) 'Message' - if err = s.Message.HashTreeRootWith(hh); err != nil { - return - } - - // Field (1) 'Signature' - hh.PutBytes(s.Signature[:]) - - hh.Merkleize(indx) - return -} - -// GetTree ssz hashes the SignedBuilderBid object -func (s *SignedBuilderBid) GetTree() (*ssz.Node, error) { - return ssz.ProofTree(s) -} diff --git a/api/electra/signedbuilderbid_yaml.go b/api/electra/signedbuilderbid_yaml.go deleted file mode 100644 index 842a58e..0000000 --- a/api/electra/signedbuilderbid_yaml.go +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright © 2022 Attestant Limited. -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package electra - -import ( - "bytes" - "fmt" - - "github.com/goccy/go-yaml" -) - -// signedBuilderBidYAML is the spec representation of the struct. -type signedBuilderBidYAML struct { - Message *BuilderBid `yaml:"message"` - Signature string `yaml:"signature"` -} - -// MarshalYAML implements yaml.Marshaler. -func (s *SignedBuilderBid) MarshalYAML() ([]byte, error) { - yamlBytes, err := yaml.MarshalWithOptions(&signedBuilderBidYAML{ - Message: s.Message, - Signature: fmt.Sprintf("%#x", s.Signature), - }, yaml.Flow(true)) - if err != nil { - return nil, err - } - - return bytes.ReplaceAll(yamlBytes, []byte(`"`), []byte(`'`)), nil -} - -// UnmarshalYAML implements yaml.Unmarshaler. -func (s *SignedBuilderBid) UnmarshalYAML(input []byte) error { - // We unmarshal to the JSON struct to save on duplicate code. - var data signedBuilderBidJSON - 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 deleted file mode 100644 index 775e5c5..0000000 --- a/api/electra/submitblockrequest.go +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright © 2024 Attestant Limited. -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package electra - -import ( - "fmt" - - "github.com/attestantio/go-builder-client/api/deneb" - apiv1 "github.com/attestantio/go-builder-client/api/v1" - "github.com/attestantio/go-eth2-client/spec/electra" - "github.com/attestantio/go-eth2-client/spec/phase0" - "github.com/goccy/go-yaml" -) - -// SubmitBlockRequest is the request from the builder to submit a block. -type SubmitBlockRequest struct { - Message *apiv1.BidTrace - ExecutionPayload *electra.ExecutionPayload - BlobsBundle *deneb.BlobsBundle - Signature phase0.BLSSignature `ssz-size:"96"` -} - -// String returns a string version of the structure. -func (s *SubmitBlockRequest) String() string { - data, err := yaml.Marshal(s) - 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 deleted file mode 100644 index 72ee998..0000000 --- a/api/electra/submitblockrequest_json.go +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright © 2024 Attestant Limited. -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package electra - -import ( - "encoding/hex" - "encoding/json" - "fmt" - "strings" - - "github.com/attestantio/go-builder-client/api/deneb" - apiv1 "github.com/attestantio/go-builder-client/api/v1" - "github.com/attestantio/go-eth2-client/spec/electra" - "github.com/attestantio/go-eth2-client/spec/phase0" - "github.com/pkg/errors" -) - -// submitBlockRequestJSON is the spec representation of the struct. -type submitBlockRequestJSON struct { - Message *apiv1.BidTrace `json:"message"` - ExecutionPayload *electra.ExecutionPayload `json:"execution_payload"` - BlobsBundle *deneb.BlobsBundle `json:"blobs_bundle"` - Signature string `json:"signature"` -} - -// MarshalJSON implements json.Marshaler. -func (s *SubmitBlockRequest) MarshalJSON() ([]byte, error) { - return json.Marshal(&submitBlockRequestJSON{ - Signature: fmt.Sprintf("%#x", s.Signature), - Message: s.Message, - ExecutionPayload: s.ExecutionPayload, - BlobsBundle: s.BlobsBundle, - }) -} - -// UnmarshalJSON implements json.Unmarshaler. -func (s *SubmitBlockRequest) UnmarshalJSON(input []byte) error { - var data submitBlockRequestJSON - if err := json.Unmarshal(input, &data); err != nil { - return errors.Wrap(err, "invalid JSON") - } - - return s.unpack(&data) -} - -func (s *SubmitBlockRequest) unpack(data *submitBlockRequestJSON) error { - if data.Message == nil { - return errors.New("message missing") - } - s.Message = data.Message - - if data.Signature == "" { - return errors.New("signature missing") - } - signature, err := hex.DecodeString(strings.TrimPrefix(data.Signature, "0x")) - if err != nil { - return errors.Wrap(err, "invalid signature") - } - if len(signature) != phase0.SignatureLength { - return errors.New("incorrect length for signature") - } - copy(s.Signature[:], signature) - - if data.ExecutionPayload == nil { - return errors.New("execution payload missing") - } - s.ExecutionPayload = data.ExecutionPayload - - if data.BlobsBundle == nil { - return errors.New("blobs bundle missing") - } - s.BlobsBundle = data.BlobsBundle - - return nil -} diff --git a/api/electra/submitblockrequest_ssz.go b/api/electra/submitblockrequest_ssz.go deleted file mode 100644 index 8dfe9b8..0000000 --- a/api/electra/submitblockrequest_ssz.go +++ /dev/null @@ -1,177 +0,0 @@ -// Code generated by fastssz. DO NOT EDIT. -// Hash: 4beadbfbd95d5654c51275d7c365975e67d9b7d964b5d245c7ac5c64964f4c7f -// Version: 0.1.3 -package electra - -import ( - "github.com/attestantio/go-builder-client/api/deneb" - apiv1 "github.com/attestantio/go-builder-client/api/v1" - "github.com/attestantio/go-eth2-client/spec/electra" - ssz "github.com/ferranbt/fastssz" -) - -// MarshalSSZ ssz marshals the SubmitBlockRequest object -func (s *SubmitBlockRequest) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) -} - -// MarshalSSZTo ssz marshals the SubmitBlockRequest object to a target array -func (s *SubmitBlockRequest) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(340) - - // Field (0) 'Message' - if s.Message == nil { - s.Message = new(apiv1.BidTrace) - } - if dst, err = s.Message.MarshalSSZTo(dst); err != nil { - return - } - - // Offset (1) 'ExecutionPayload' - dst = ssz.WriteOffset(dst, offset) - if s.ExecutionPayload == nil { - s.ExecutionPayload = new(electra.ExecutionPayload) - } - offset += s.ExecutionPayload.SizeSSZ() - - // Offset (2) 'BlobsBundle' - dst = ssz.WriteOffset(dst, offset) - if s.BlobsBundle == nil { - s.BlobsBundle = new(deneb.BlobsBundle) - } - offset += s.BlobsBundle.SizeSSZ() - - // Field (3) 'Signature' - dst = append(dst, s.Signature[:]...) - - // Field (1) 'ExecutionPayload' - if dst, err = s.ExecutionPayload.MarshalSSZTo(dst); err != nil { - return - } - - // Field (2) 'BlobsBundle' - if dst, err = s.BlobsBundle.MarshalSSZTo(dst); err != nil { - return - } - - return -} - -// UnmarshalSSZ ssz unmarshals the SubmitBlockRequest object -func (s *SubmitBlockRequest) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 340 { - return ssz.ErrSize - } - - tail := buf - var o1, o2 uint64 - - // Field (0) 'Message' - if s.Message == nil { - s.Message = new(apiv1.BidTrace) - } - if err = s.Message.UnmarshalSSZ(buf[0:236]); err != nil { - return err - } - - // Offset (1) 'ExecutionPayload' - if o1 = ssz.ReadOffset(buf[236:240]); o1 > size { - return ssz.ErrOffset - } - - if o1 < 340 { - return ssz.ErrInvalidVariableOffset - } - - // Offset (2) 'BlobsBundle' - if o2 = ssz.ReadOffset(buf[240:244]); o2 > size || o1 > o2 { - return ssz.ErrOffset - } - - // Field (3) 'Signature' - copy(s.Signature[:], buf[244:340]) - - // Field (1) 'ExecutionPayload' - { - buf = tail[o1:o2] - if s.ExecutionPayload == nil { - s.ExecutionPayload = new(electra.ExecutionPayload) - } - if err = s.ExecutionPayload.UnmarshalSSZ(buf); err != nil { - return err - } - } - - // Field (2) 'BlobsBundle' - { - buf = tail[o2:] - if s.BlobsBundle == nil { - s.BlobsBundle = new(deneb.BlobsBundle) - } - if err = s.BlobsBundle.UnmarshalSSZ(buf); err != nil { - return err - } - } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the SubmitBlockRequest object -func (s *SubmitBlockRequest) SizeSSZ() (size int) { - size = 340 - - // Field (1) 'ExecutionPayload' - if s.ExecutionPayload == nil { - s.ExecutionPayload = new(electra.ExecutionPayload) - } - size += s.ExecutionPayload.SizeSSZ() - - // Field (2) 'BlobsBundle' - if s.BlobsBundle == nil { - s.BlobsBundle = new(deneb.BlobsBundle) - } - size += s.BlobsBundle.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the SubmitBlockRequest object -func (s *SubmitBlockRequest) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) -} - -// HashTreeRootWith ssz hashes the SubmitBlockRequest object with a hasher -func (s *SubmitBlockRequest) HashTreeRootWith(hh ssz.HashWalker) (err error) { - indx := hh.Index() - - // Field (0) 'Message' - if s.Message == nil { - s.Message = new(apiv1.BidTrace) - } - if err = s.Message.HashTreeRootWith(hh); err != nil { - return - } - - // Field (1) 'ExecutionPayload' - if err = s.ExecutionPayload.HashTreeRootWith(hh); err != nil { - return - } - - // Field (2) 'BlobsBundle' - if err = s.BlobsBundle.HashTreeRootWith(hh); err != nil { - return - } - - // Field (3) 'Signature' - hh.PutBytes(s.Signature[:]) - - hh.Merkleize(indx) - return -} - -// GetTree ssz hashes the SubmitBlockRequest object -func (s *SubmitBlockRequest) GetTree() (*ssz.Node, error) { - return ssz.ProofTree(s) -} diff --git a/api/electra/submitblockrequest_yaml.go b/api/electra/submitblockrequest_yaml.go deleted file mode 100644 index 02b794a..0000000 --- a/api/electra/submitblockrequest_yaml.go +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright © 2024 Attestant Limited. -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package electra - -import ( - "bytes" - "fmt" - - "github.com/attestantio/go-builder-client/api/deneb" - apiv1 "github.com/attestantio/go-builder-client/api/v1" - "github.com/attestantio/go-eth2-client/spec/electra" - "github.com/goccy/go-yaml" -) - -// submitBlockRequestYAML is the spec representation of the struct. -type submitBlockRequestYAML struct { - Message *apiv1.BidTrace `yaml:"message"` - ExecutionPayload *electra.ExecutionPayload `yaml:"execution_payload"` - BlobsBundle *deneb.BlobsBundle `yaml:"blobs_bundle"` - Signature string `yaml:"signature"` -} - -// MarshalYAML implements yaml.Marshaler. -func (s *SubmitBlockRequest) MarshalYAML() ([]byte, error) { - yamlBytes, err := yaml.MarshalWithOptions(&submitBlockRequestYAML{ - Message: s.Message, - Signature: fmt.Sprintf("%#x", s.Signature), - ExecutionPayload: s.ExecutionPayload, - BlobsBundle: s.BlobsBundle, - }, yaml.Flow(true)) - if err != nil { - return nil, err - } - - return bytes.ReplaceAll(yamlBytes, []byte(`"`), []byte(`'`)), nil -} - -// UnmarshalYAML implements yaml.Unmarshaler. -func (s *SubmitBlockRequest) UnmarshalYAML(input []byte) error { - // We unmarshal to the JSON struct to save on duplicate code. - var data submitBlockRequestJSON - 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 5d8ab13..ce0726f 100644 --- a/api/versionedexecutionpayload.go +++ b/api/versionedexecutionpayload.go @@ -18,7 +18,6 @@ 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" "github.com/pkg/errors" ) @@ -29,7 +28,7 @@ type VersionedExecutionPayload struct { Bellatrix *bellatrix.ExecutionPayload Capella *capella.ExecutionPayload Deneb *deneb.ExecutionPayload - Electra *electra.ExecutionPayload + Electra *deneb.ExecutionPayload } // IsEmpty returns true if there is no payload. diff --git a/api/versionedexecutionpayload_json.go b/api/versionedexecutionpayload_json.go index 8ff7613..d19d412 100644 --- a/api/versionedexecutionpayload_json.go +++ b/api/versionedexecutionpayload_json.go @@ -21,7 +21,6 @@ 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/pkg/errors" ) @@ -41,10 +40,6 @@ type denebVersionedExecutionPayloadJSON struct { Data *deneb.ExecutionPayload `json:"data"` } -type electraVersionedExecutionPayloadJSON struct { - Data *electra.ExecutionPayload `json:"data"` -} - // MarshalJSON implements json.Marshaler. func (v *VersionedExecutionPayload) MarshalJSON() ([]byte, error) { version := &versionJSON{ @@ -94,12 +89,12 @@ func (v *VersionedExecutionPayload) MarshalJSON() ([]byte, error) { if v.Electra == nil { return nil, errors.New("no electra data") } - data := &electraVersionedExecutionPayloadJSON{ + data := &denebVersionedExecutionPayloadJSON{ Data: v.Electra, } payload := struct { *versionJSON - *electraVersionedExecutionPayloadJSON + *denebVersionedExecutionPayloadJSON }{version, data} return json.Marshal(payload) @@ -135,7 +130,7 @@ func (v *VersionedExecutionPayload) UnmarshalJSON(input []byte) error { } v.Deneb = data.Data case spec.DataVersionElectra: - var data electraVersionedExecutionPayloadJSON + var data denebVersionedExecutionPayloadJSON if err := json.Unmarshal(input, &data); err != nil { return errors.Wrap(err, "invalid JSON") } diff --git a/api/versionedexecutionpayloadheader.go b/api/versionedexecutionpayloadheader.go index 4f81c3d..f6153dc 100644 --- a/api/versionedexecutionpayloadheader.go +++ b/api/versionedexecutionpayloadheader.go @@ -18,7 +18,6 @@ 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" ) // VersionedExecutionPayloadHeader contains a versioned ExecutionPayloadHeaderV1. @@ -27,7 +26,7 @@ type VersionedExecutionPayloadHeader struct { Bellatrix *bellatrix.ExecutionPayloadHeader `json:"bellatrix,omitempty"` Capella *capella.ExecutionPayloadHeader `json:"capella,omitempty"` Deneb *deneb.ExecutionPayloadHeader `json:"deneb,omitempty"` - Electra *electra.ExecutionPayloadHeader `json:"electra,omitempty"` + Electra *deneb.ExecutionPayloadHeader `json:"electra,omitempty"` } // IsEmpty returns true if there is no payload. diff --git a/api/versionedsubmitblindedblockresponse.go b/api/versionedsubmitblindedblockresponse.go index 2e3ac03..5dec7fc 100644 --- a/api/versionedsubmitblindedblockresponse.go +++ b/api/versionedsubmitblindedblockresponse.go @@ -15,12 +15,10 @@ package api import ( "github.com/attestantio/go-builder-client/api/deneb" - "github.com/attestantio/go-builder-client/api/electra" consensusspec "github.com/attestantio/go-eth2-client/spec" "github.com/attestantio/go-eth2-client/spec/bellatrix" "github.com/attestantio/go-eth2-client/spec/capella" consensusdeneb "github.com/attestantio/go-eth2-client/spec/deneb" - consensuselectra "github.com/attestantio/go-eth2-client/spec/electra" "github.com/attestantio/go-eth2-client/spec/phase0" "github.com/pkg/errors" ) @@ -31,7 +29,7 @@ type VersionedSubmitBlindedBlockResponse struct { Bellatrix *bellatrix.ExecutionPayload Capella *capella.ExecutionPayload Deneb *deneb.ExecutionPayloadAndBlobsBundle - Electra *electra.ExecutionPayloadAndBlobsBundle + Electra *deneb.ExecutionPayloadAndBlobsBundle } // IsEmpty returns true if there is no payload. @@ -218,43 +216,3 @@ func (v *VersionedSubmitBlindedBlockResponse) ExcessBlobGas() (uint64, error) { return 0, errors.New("unsupported version") } } - -// DepositRequests returns the deposit receipts of the execution payload. -func (v *VersionedSubmitBlindedBlockResponse) DepositRequests() ([]*consensuselectra.DepositRequest, error) { - if v == nil { - return nil, errors.New("nil struct") - } - switch v.Version { - case consensusspec.DataVersionElectra: - if v.Electra == nil { - return nil, errors.New("no data") - } - if v.Electra.ExecutionPayload == nil { - return nil, errors.New("no data execution payload") - } - - return v.Electra.ExecutionPayload.DepositRequests, nil - default: - return nil, errors.New("unsupported version") - } -} - -// WithdrawalRequests returns the execution layer withdrawal requests of the execution payload. -func (v *VersionedSubmitBlindedBlockResponse) WithdrawalRequests() ([]*consensuselectra.WithdrawalRequest, error) { - if v == nil { - return nil, errors.New("nil struct") - } - switch v.Version { - case consensusspec.DataVersionElectra: - if v.Electra == nil { - return nil, errors.New("no data") - } - 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 3c33616..bde8e52 100644 --- a/api/versionedsubmitblindedblockresponse_json.go +++ b/api/versionedsubmitblindedblockresponse_json.go @@ -18,7 +18,6 @@ import ( "fmt" "github.com/attestantio/go-builder-client/api/deneb" - "github.com/attestantio/go-builder-client/api/electra" "github.com/attestantio/go-eth2-client/spec" "github.com/pkg/errors" ) @@ -28,7 +27,7 @@ type denebVersionedExecutionPayloadAndBlobsBundleJSON struct { } type electraVersionedExecutionPayloadAndBlobsBundleJSON struct { - Data *electra.ExecutionPayloadAndBlobsBundle `json:"data"` + Data *deneb.ExecutionPayloadAndBlobsBundle `json:"data"` } // MarshalJSON implements json.Marshaler. diff --git a/go.mod b/go.mod index 3bcc6e1..e511320 100644 --- a/go.mod +++ b/go.mod @@ -46,3 +46,6 @@ require ( gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) + +// Remove this when attestantio merge's pk's PR. +replace github.com/attestantio/go-eth2-client => github.com/pk910/go-eth2-client v0.0.0-20240923174943-8d64565c83ca diff --git a/go.sum b/go.sum index ac8a6de..1b715ba 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,3 @@ -github.com/attestantio/go-eth2-client v0.21.7-0.20240701211822-0a60485fce68 h1:+sc+OAeTcWjQ5BwK6aajh9xnu8KYtIJNVqwbWx+KvQ4= -github.com/attestantio/go-eth2-client v0.21.7-0.20240701211822-0a60485fce68/go.mod h1:vy5jU/uDZ2+RcVzq5BfnG+bQ3/6uu9DGwCrGsPtjJ1A= 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= @@ -64,6 +62,8 @@ github.com/minio/sha256-simd v1.0.1 h1:6kaan5IFmwTNynnKKpDHe6FWHohJOHhCPchzK49dz github.com/minio/sha256-simd v1.0.1/go.mod h1:Pz6AKMiUdngCLpeTL/RJY1M9rUuPMYujV5xJjtbRSN8= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/pk910/go-eth2-client v0.0.0-20240923174943-8d64565c83ca h1:rc6VVR79GdE58Wx1Arh9QNo+0qmXOfYjWQhrbkSeoI0= +github.com/pk910/go-eth2-client v0.0.0-20240923174943-8d64565c83ca/go.mod h1:vy5jU/uDZ2+RcVzq5BfnG+bQ3/6uu9DGwCrGsPtjJ1A= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= diff --git a/http/builderbid.go b/http/builderbid.go index 5f4476c..493a56d 100644 --- a/http/builderbid.go +++ b/http/builderbid.go @@ -24,7 +24,6 @@ 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/api/electra" "github.com/attestantio/go-builder-client/spec" consensusspec "github.com/attestantio/go-eth2-client/spec" "github.com/attestantio/go-eth2-client/spec/phase0" @@ -131,7 +130,7 @@ func (*Service) signedBuilderBidFromJSON(res *httpResponse) ( ) case consensusspec.DataVersionElectra: response.Data.Electra, _, err = decodeJSONResponse(bytes.NewReader(res.body), - &electra.SignedBuilderBid{}, + &deneb.SignedBuilderBid{}, ) default: return nil, fmt.Errorf("unsupported block version %s", res.consensusVersion) diff --git a/http/unblindproposal.go b/http/unblindproposal.go index 637b4e5..6256b2f 100644 --- a/http/unblindproposal.go +++ b/http/unblindproposal.go @@ -23,7 +23,6 @@ import ( client "github.com/attestantio/go-builder-client" "github.com/attestantio/go-builder-client/api" apideneb "github.com/attestantio/go-builder-client/api/deneb" - apielectra "github.com/attestantio/go-builder-client/api/electra" consensusapi "github.com/attestantio/go-eth2-client/api" consensusapiv1deneb "github.com/attestantio/go-eth2-client/api/v1/deneb" consensusapiv1electra "github.com/attestantio/go-eth2-client/api/v1/electra" @@ -407,7 +406,7 @@ func (s *Service) unblindElectraProposal(ctx context.Context, switch httpResponse.contentType { case ContentTypeJSON: - bundle, _, err := decodeJSONResponse(bytes.NewReader(httpResponse.body), &apielectra.ExecutionPayloadAndBlobsBundle{}) + bundle, _, err := decodeJSONResponse(bytes.NewReader(httpResponse.body), &apideneb.ExecutionPayloadAndBlobsBundle{}) if err != nil { return nil, errors.Join(errors.New("failed to parse electra response"), err) } diff --git a/spec/versionedsignedbuilderbid.go b/spec/versionedsignedbuilderbid.go index 1fbc781..5c4af19 100644 --- a/spec/versionedsignedbuilderbid.go +++ b/spec/versionedsignedbuilderbid.go @@ -21,7 +21,6 @@ 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/api/electra" 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" @@ -34,7 +33,7 @@ type VersionedSignedBuilderBid struct { Bellatrix *bellatrix.SignedBuilderBid Capella *capella.SignedBuilderBid Deneb *deneb.SignedBuilderBid - Electra *electra.SignedBuilderBid + Electra *deneb.SignedBuilderBid } // IsEmpty returns true if there is no bid. diff --git a/spec/versionedsignedbuilderbid_json.go b/spec/versionedsignedbuilderbid_json.go index 75efe76..20a6257 100644 --- a/spec/versionedsignedbuilderbid_json.go +++ b/spec/versionedsignedbuilderbid_json.go @@ -20,7 +20,6 @@ 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/api/electra" "github.com/attestantio/go-eth2-client/spec" "github.com/pkg/errors" ) @@ -41,7 +40,7 @@ type denebVersionedSignedBuilderBidJSON struct { } type electraVersionedSignedBuilderBidJSON struct { - Data *electra.SignedBuilderBid `json:"data"` + Data *deneb.SignedBuilderBid `json:"data"` } // MarshalJSON implements json.Marshaler. diff --git a/spec/versionedsubmitblockrequest.go b/spec/versionedsubmitblockrequest.go index 50690e4..42ac01f 100644 --- a/spec/versionedsubmitblockrequest.go +++ b/spec/versionedsubmitblockrequest.go @@ -21,13 +21,11 @@ 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/api/electra" apiv1 "github.com/attestantio/go-builder-client/api/v1" 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" - consensuselectra "github.com/attestantio/go-eth2-client/spec/electra" "github.com/attestantio/go-eth2-client/spec/phase0" "github.com/holiman/uint256" ) @@ -38,7 +36,7 @@ type VersionedSubmitBlockRequest struct { Bellatrix *bellatrix.SubmitBlockRequest Capella *capella.SubmitBlockRequest Deneb *deneb.SubmitBlockRequest - Electra *electra.SubmitBlockRequest + Electra *deneb.SubmitBlockRequest } // IsEmpty returns true if there is no request. @@ -969,66 +967,6 @@ func (v *VersionedSubmitBlockRequest) ExcessBlobGas() (uint64, error) { } } -// DepositRequests returns the deposit receipts of the execution payload. -func (v *VersionedSubmitBlockRequest) DepositRequests() ([]*consensuselectra.DepositRequest, error) { - if v == nil { - return nil, errors.New("nil struct") - } - switch v.Version { - case consensusspec.DataVersionElectra: - if v.Electra == nil { - return nil, errors.New("no data") - } - if v.Electra.ExecutionPayload == nil { - return nil, errors.New("no data execution payload") - } - - return v.Electra.ExecutionPayload.DepositRequests, nil - default: - return nil, errors.New("unsupported version") - } -} - -// WithdrawalRequests returns the execution layer withdrawal requests of the execution payload. -func (v *VersionedSubmitBlockRequest) WithdrawalRequests() ([]*consensuselectra.WithdrawalRequest, error) { - if v == nil { - return nil, errors.New("nil struct") - } - switch v.Version { - case consensusspec.DataVersionElectra: - if v.Electra == nil { - return nil, errors.New("no data") - } - 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") - } -} - -// ConsolidationRequests returns the consolidation requests of the execution payload. -func (v *VersionedSubmitBlockRequest) ConsolidationRequests() ([]*consensuselectra.ConsolidationRequest, error) { - if v == nil { - return nil, errors.New("nil struct") - } - switch v.Version { - case consensusspec.DataVersionElectra: - if v.Electra == nil { - return nil, errors.New("no data") - } - if v.Electra.ExecutionPayload == nil { - return nil, errors.New("no data execution payload") - } - - return v.Electra.ExecutionPayload.ConsolidationRequests, nil - default: - return nil, errors.New("unsupported version") - } -} - // String returns a string version of the structure. func (v *VersionedSubmitBlockRequest) String() string { if v == nil { diff --git a/spec/versionedsubmitblockrequest_json.go b/spec/versionedsubmitblockrequest_json.go index a5bb81a..e24301c 100644 --- a/spec/versionedsubmitblockrequest_json.go +++ b/spec/versionedsubmitblockrequest_json.go @@ -20,7 +20,6 @@ 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/api/electra" "github.com/attestantio/go-eth2-client/spec" "github.com/pkg/errors" ) @@ -37,7 +36,7 @@ type denebVersionedSubmitBlockRequestJSON struct { } type electraVersionedSubmitBlockRequestJSON struct { - Data *electra.SubmitBlockRequest `json:"data"` + Data *deneb.SubmitBlockRequest `json:"data"` } // MarshalJSON implements json.Marshaler.