diff --git a/api/bellatrix/builderbid_encoding.go b/api/bellatrix/builderbid_encoding.go index f39d3df..996a25f 100644 --- a/api/bellatrix/builderbid_encoding.go +++ b/api/bellatrix/builderbid_encoding.go @@ -1,135 +1,158 @@ -// Code generated by fastssz. DO NOT EDIT. -// Hash: 8f5fa2fa080ee2a1206a4f6749963d98a297611dfb1fa050514dccb7f92da116 +// Code generated by dynamic-ssz. DO NOT EDIT. +// Hash: 0320b1a213ffd50392da1508ded175aa3393866af8cb3c49e11a1f567072cc2e +// Version: v1.2.2 (https://github.com/pk910/dynamic-ssz) package bellatrix import ( + "encoding/binary" + "github.com/attestantio/go-eth2-client/spec/bellatrix" - ssz "github.com/ferranbt/fastssz" "github.com/holiman/uint256" + dynssz "github.com/pk910/dynamic-ssz" + "github.com/pk910/dynamic-ssz/hasher" + "github.com/pk910/dynamic-ssz/sszutils" ) -// MarshalSSZ ssz marshals the BuilderBid object -func (b *BuilderBid) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) +var _ = sszutils.ErrListTooBig + +// MarshalSSZ marshals the *BuilderBid to SSZ-encoded bytes. +func (t *BuilderBid) MarshalSSZ() ([]byte, error) { + return dynssz.GetGlobalDynSsz().MarshalSSZ(t) } -// MarshalSSZTo ssz marshals the BuilderBid object to a target array -func (b *BuilderBid) MarshalSSZTo(buf []byte) (dst []byte, err error) { +// MarshalSSZTo marshals the *BuilderBid to SSZ-encoded bytes, appending to the provided buffer. +func (t *BuilderBid) MarshalSSZTo(buf []byte) (dst []byte, err error) { dst = buf - offset := int(84) - - // Offset (0) 'Header' - dst = ssz.WriteOffset(dst, offset) - if b.Header == nil { - b.Header = new(bellatrix.ExecutionPayloadHeader) + if t == nil { + t = new(BuilderBid) } - offset += b.Header.SizeSSZ() - - // Field (1) 'Value' - value := b.Value.Bytes32() - for i := 0; i < 32; i++ { - dst = append(dst, value[31-i]) + dstlen := len(dst) + // Offset Field #0 'Header' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #1 'Value' + t := t.Value + if t == nil { + t = new(uint256.Int) + } + dst = sszutils.MarshalUint64Slice(dst, (*t)[:4]) } - - // Field (2) 'Pubkey' - dst = append(dst, b.Pubkey[:]...) - - // Field (0) 'Header' - if dst, err = b.Header.MarshalSSZTo(dst); err != nil { - return + { // Static Field #2 'Pubkey' + dst = append(dst, t.Pubkey[:48]...) } - - return -} - -// UnmarshalSSZ ssz unmarshals the BuilderBid object -func (b *BuilderBid) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 84 { - return ssz.ErrSize + { // Dynamic Field #0 'Header' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.Header + if t == nil { + t = new(bellatrix.ExecutionPayloadHeader) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "Header") + } } + return dst, nil +} - tail := buf - var o0 uint64 - - // Offset (0) 'Header' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset +// UnmarshalSSZ unmarshals the *BuilderBid from SSZ-encoded bytes. +func (t *BuilderBid) UnmarshalSSZ(buf []byte) (err error) { + buflen := len(buf) + if buflen < 84 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 84) } - - if o0 < 84 { - return ssz.ErrInvalidVariableOffset + // Field #0 'Header' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 84 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset0, 84), "Header:o") } - - // Field (1) 'Value' - value := make([]byte, 32) - for i := 0; i < 32; i++ { - value[i] = buf[35-i] + { // Field #1 'Value' (static) + buf := buf[4:36] + val1 := t.Value + if val1 == nil { + val1 = new(uint256.Int) + } + sszutils.UnmarshalUint64Slice((*val1)[:4], buf) + t.Value = val1 } - if b.Value == nil { - b.Value = new(uint256.Int) + { // Field #2 'Pubkey' (static) + buf := buf[36:84] + copy(t.Pubkey[:], buf) } - b.Value.SetBytes32(value) - - // Field (2) 'Pubkey' - copy(b.Pubkey[:], buf[36:84]) - - // Field (0) 'Header' - { - buf = tail[o0:] - if b.Header == nil { - b.Header = new(bellatrix.ExecutionPayloadHeader) + { // Field #0 'Header' (dynamic) + buf := buf[offset0:] + if t.Header == nil { + t.Header = new(bellatrix.ExecutionPayloadHeader) } - if err = b.Header.UnmarshalSSZ(buf); err != nil { - return err + if err = t.Header.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "Header") } } - return err + return nil } -// SizeSSZ returns the ssz encoded size in bytes for the BuilderBid object -func (b *BuilderBid) SizeSSZ() (size int) { - size = 84 - - // Field (0) 'Header' - if b.Header == nil { - b.Header = new(bellatrix.ExecutionPayloadHeader) +// SizeSSZ returns the SSZ encoded size of the *BuilderBid. +func (t *BuilderBid) SizeSSZ() (size int) { + if t == nil { + t = new(BuilderBid) } - size += b.Header.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the BuilderBid object -func (b *BuilderBid) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) + // Field #0 'Header' offset (4 bytes) + // Field #1 'Value' static (32 bytes) + // Field #2 'Pubkey' static (48 bytes) + size += 84 + { // Dynamic field #0 'Header' + size += t.Header.SizeSSZ() + } + return size } -// 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 { +// HashTreeRoot computes the SSZ hash tree root of the *BuilderBid. +func (t *BuilderBid) HashTreeRoot() (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWith(hh) + if err == nil { + root, err = hh.HashRoot() + } return - } - - // Field (1) '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 (2) '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) +// HashTreeRootWith computes the SSZ hash tree root of the *BuilderBid using the given hash walker. +func (t *BuilderBid) HashTreeRootWith(hh sszutils.HashWalker) error { + if t == nil { + t = new(BuilderBid) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Header' + t := t.Header + if t == nil { + t = new(bellatrix.ExecutionPayloadHeader) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPath(err, "Header") + } + } + { // Field #1 'Value' + t := t.Value + if t == nil { + t = new(uint256.Int) + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + var val1, val1Empty uint64 + for idx1 := range 4 { + if idx1 < 4 { + val1 = (*t)[idx1] + } else if idx1 == 4 { + val1 = val1Empty + } + hh.AppendUint64(val1) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.FillUpTo32() + hh.Merkleize(idx) + } + { // Field #2 'Pubkey' + hh.PutBytes(t.Pubkey[:48]) + } + hh.Merkleize(idx) + return nil } diff --git a/api/bellatrix/generate.go b/api/bellatrix/generate.go index 59fc2a8..c262abf 100644 --- a/api/bellatrix/generate.go +++ b/api/bellatrix/generate.go @@ -13,8 +13,7 @@ package bellatrix -// Need to `go install github.com/ferranbt/fastssz/sszgen@latest` for this to work. -//go:generate rm -f builderbid_encoding.go signedbuilderbid_encoding.go +// Need to `go install github.com/pk910/dynamic-ssz/dynssz-gen@latest` for this to work. +//go:generate rm -f builderbid_encoding.go signedbuilderbid_encoding.go submitblock_encoding.go //nolint:revive -//go:generate sszgen -include ../../../go-eth2-client/spec/bellatrix,../../../go-eth2-client/spec/phase0 --path . --objs BuilderBid,SignedBuilderBid -//go:generate goimports -w builderbid_encoding.go signedbuilderbid_encoding.go +//go:generate dynssz-gen -package . -legacy -without-dynamic-expressions -types BuilderBid:builderbid_encoding.go,SignedBuilderBid:signedbuilderbid_encoding.go,SubmitBlockRequest:submitblock_encoding.go diff --git a/api/bellatrix/signedbuilderbid_encoding.go b/api/bellatrix/signedbuilderbid_encoding.go index 69717c1..81ac74a 100644 --- a/api/bellatrix/signedbuilderbid_encoding.go +++ b/api/bellatrix/signedbuilderbid_encoding.go @@ -1,111 +1,118 @@ -// Code generated by fastssz. DO NOT EDIT. -// Hash: 8e2d0dda73eccd7623eb97af984b6e665f4f121bdef0a35390f2afd2ff34259c -// Version: 0.1.3-dev +// Code generated by dynamic-ssz. DO NOT EDIT. +// Hash: 5f0adcbd8eb5537467d7661d49cdf8c72fef9cf3e869362fb4db07c91803a8f6 +// Version: v1.2.2 (https://github.com/pk910/dynamic-ssz) package bellatrix import ( - ssz "github.com/ferranbt/fastssz" + "encoding/binary" + + dynssz "github.com/pk910/dynamic-ssz" + "github.com/pk910/dynamic-ssz/hasher" + "github.com/pk910/dynamic-ssz/sszutils" ) -// MarshalSSZ ssz marshals the SignedBuilderBid object -func (s *SignedBuilderBid) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) +var _ = sszutils.ErrListTooBig + +// MarshalSSZ marshals the *SignedBuilderBid to SSZ-encoded bytes. +func (t *SignedBuilderBid) MarshalSSZ() ([]byte, error) { + return dynssz.GetGlobalDynSsz().MarshalSSZ(t) } -// MarshalSSZTo ssz marshals the SignedBuilderBid object to a target array -func (s *SignedBuilderBid) MarshalSSZTo(buf []byte) (dst []byte, err error) { +// MarshalSSZTo marshals the *SignedBuilderBid to SSZ-encoded bytes, appending to the provided buffer. +func (t *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) + if t == nil { + t = new(SignedBuilderBid) } - 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 + dstlen := len(dst) + // Offset Field #0 'Message' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #1 'Signature' + dst = append(dst, t.Signature[:96]...) } - - return + { // Dynamic Field #0 'Message' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.Message + if t == nil { + t = new(BuilderBid) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "Message") + } + } + return dst, nil } -// 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 +// UnmarshalSSZ unmarshals the *SignedBuilderBid from SSZ-encoded bytes. +func (t *SignedBuilderBid) UnmarshalSSZ(buf []byte) (err error) { + buflen := len(buf) + if buflen < 100 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 100) } - - tail := buf - var o0 uint64 - - // Offset (0) 'Message' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset + // Field #0 'Message' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 100 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset0, 100), "Message:o") } - - if o0 < 100 { - return ssz.ErrInvalidVariableOffset + { // Field #1 'Signature' (static) + buf := buf[4:100] + copy(t.Signature[:], buf) } - - // Field (1) 'Signature' - copy(s.Signature[:], buf[4:100]) - - // Field (0) 'Message' - { - buf = tail[o0:] - if s.Message == nil { - s.Message = new(BuilderBid) + { // Field #0 'Message' (dynamic) + buf := buf[offset0:] + if t.Message == nil { + t.Message = new(BuilderBid) } - if err = s.Message.UnmarshalSSZ(buf); err != nil { - return err + if err = t.Message.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "Message") } } - return err + return nil } -// 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) +// SizeSSZ returns the SSZ encoded size of the *SignedBuilderBid. +func (t *SignedBuilderBid) SizeSSZ() (size int) { + if t == nil { + t = new(SignedBuilderBid) } - size += s.Message.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the SignedBuilderBid object -func (s *SignedBuilderBid) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) + // Field #0 'Message' offset (4 bytes) + // Field #1 'Signature' static (96 bytes) + size += 100 + { // Dynamic field #0 'Message' + size += t.Message.SizeSSZ() + } + return size } -// 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 { +// HashTreeRoot computes the SSZ hash tree root of the *SignedBuilderBid. +func (t *SignedBuilderBid) HashTreeRoot() (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWith(hh) + if err == nil { + root, err = hh.HashRoot() + } 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) +// HashTreeRootWith computes the SSZ hash tree root of the *SignedBuilderBid using the given hash walker. +func (t *SignedBuilderBid) HashTreeRootWith(hh sszutils.HashWalker) error { + if t == nil { + t = new(SignedBuilderBid) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Message' + t := t.Message + if t == nil { + t = new(BuilderBid) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPath(err, "Message") + } + } + { // Field #1 'Signature' + hh.PutBytes(t.Signature[:96]) + } + hh.Merkleize(idx) + return nil } diff --git a/api/bellatrix/submitblock_encoding.go b/api/bellatrix/submitblock_encoding.go index 9e1e220..d1b9bdb 100644 --- a/api/bellatrix/submitblock_encoding.go +++ b/api/bellatrix/submitblock_encoding.go @@ -1,137 +1,148 @@ -// Code generated by fastssz. DO NOT EDIT. -// Hash: 8e2d0dda73eccd7623eb97af984b6e665f4f121bdef0a35390f2afd2ff34259c -// Version: 0.1.3-dev +// Code generated by dynamic-ssz. DO NOT EDIT. +// Hash: b3f2ede19b13979a9c2be90662fc0cdba0d596036f32c580dafe66cde4f02fc7 +// Version: v1.2.2 (https://github.com/pk910/dynamic-ssz) package bellatrix import ( - v1 "github.com/attestantio/go-builder-client/api/v1" + "encoding/binary" + + "github.com/attestantio/go-builder-client/api/v1" "github.com/attestantio/go-eth2-client/spec/bellatrix" - ssz "github.com/ferranbt/fastssz" + dynssz "github.com/pk910/dynamic-ssz" + "github.com/pk910/dynamic-ssz/hasher" + "github.com/pk910/dynamic-ssz/sszutils" ) -// MarshalSSZ ssz marshals the SubmitBlockRequest object -func (s *SubmitBlockRequest) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) +var _ = sszutils.ErrListTooBig + +// MarshalSSZ marshals the *SubmitBlockRequest to SSZ-encoded bytes. +func (t *SubmitBlockRequest) MarshalSSZ() ([]byte, error) { + return dynssz.GetGlobalDynSsz().MarshalSSZ(t) } -// MarshalSSZTo ssz marshals the SubmitBlockRequest object to a target array -func (s *SubmitBlockRequest) MarshalSSZTo(buf []byte) (dst []byte, err error) { +// MarshalSSZTo marshals the *SubmitBlockRequest to SSZ-encoded bytes, appending to the provided buffer. +func (t *SubmitBlockRequest) MarshalSSZTo(buf []byte) (dst []byte, err error) { dst = buf - offset := int(336) - - // Field (0) 'Message' - if s.Message == nil { - s.Message = new(v1.BidTrace) + if t == nil { + t = new(SubmitBlockRequest) } - if dst, err = s.Message.MarshalSSZTo(dst); err != nil { - return + dstlen := len(dst) + { // Static Field #0 'Message' + t := t.Message + if t == nil { + t = new(v1.BidTrace) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "Message") + } } - - // Offset (1) 'ExecutionPayload' - dst = ssz.WriteOffset(dst, offset) - if s.ExecutionPayload == nil { - s.ExecutionPayload = new(bellatrix.ExecutionPayload) + // Offset Field #1 'ExecutionPayload' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #2 'Signature' + dst = append(dst, t.Signature[:96]...) } - offset += s.ExecutionPayload.SizeSSZ() - - // Field (2) 'Signature' - dst = append(dst, s.Signature[:]...) - - // Field (1) 'ExecutionPayload' - if dst, err = s.ExecutionPayload.MarshalSSZTo(dst); err != nil { - return + { // Dynamic Field #1 'ExecutionPayload' + binary.LittleEndian.PutUint32(dst[dstlen+236:], uint32(len(dst)-dstlen)) + t := t.ExecutionPayload + if t == nil { + t = new(bellatrix.ExecutionPayload) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "ExecutionPayload") + } } - - return + return dst, nil } -// UnmarshalSSZ ssz unmarshals the SubmitBlockRequest object -func (s *SubmitBlockRequest) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 336 { - return ssz.ErrSize - } - - tail := buf - var o1 uint64 - - // Field (0) 'Message' - if s.Message == nil { - s.Message = new(v1.BidTrace) +// UnmarshalSSZ unmarshals the *SubmitBlockRequest from SSZ-encoded bytes. +func (t *SubmitBlockRequest) UnmarshalSSZ(buf []byte) (err error) { + buflen := len(buf) + if buflen < 336 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 336) } - if err = s.Message.UnmarshalSSZ(buf[0:236]); err != nil { - return err + { // Field #0 'Message' (static) + buf := buf[0:236] + if t.Message == nil { + t.Message = new(v1.BidTrace) + } + if err = t.Message.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "Message") + } } - - // Offset (1) 'ExecutionPayload' - if o1 = ssz.ReadOffset(buf[236:240]); o1 > size { - return ssz.ErrOffset + // Field #1 'ExecutionPayload' (offset) + offset1 := int(binary.LittleEndian.Uint32(buf[236:240])) + if offset1 != 336 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset1, 336), "ExecutionPayload:o") } - - if o1 < 336 { - return ssz.ErrInvalidVariableOffset + { // Field #2 'Signature' (static) + buf := buf[240:336] + copy(t.Signature[:], buf) } - - // Field (2) 'Signature' - copy(s.Signature[:], buf[240:336]) - - // Field (1) 'ExecutionPayload' - { - buf = tail[o1:] - if s.ExecutionPayload == nil { - s.ExecutionPayload = new(bellatrix.ExecutionPayload) + { // Field #1 'ExecutionPayload' (dynamic) + buf := buf[offset1:] + if t.ExecutionPayload == nil { + t.ExecutionPayload = new(bellatrix.ExecutionPayload) } - if err = s.ExecutionPayload.UnmarshalSSZ(buf); err != nil { - return err + if err = t.ExecutionPayload.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "ExecutionPayload") } } - return err + return nil } -// SizeSSZ returns the ssz encoded size in bytes for the SubmitBlockRequest object -func (s *SubmitBlockRequest) SizeSSZ() (size int) { - size = 336 - - // Field (1) 'ExecutionPayload' - if s.ExecutionPayload == nil { - s.ExecutionPayload = new(bellatrix.ExecutionPayload) +// SizeSSZ returns the SSZ encoded size of the *SubmitBlockRequest. +func (t *SubmitBlockRequest) SizeSSZ() (size int) { + if t == nil { + t = new(SubmitBlockRequest) } - size += s.ExecutionPayload.SizeSSZ() - - return + // Field #0 'Message' static (236 bytes) + // Field #1 'ExecutionPayload' offset (4 bytes) + // Field #2 'Signature' static (96 bytes) + size += 336 + { // Dynamic field #1 'ExecutionPayload' + size += t.ExecutionPayload.SizeSSZ() + } + return size } -// HashTreeRoot ssz hashes the SubmitBlockRequest object -func (s *SubmitBlockRequest) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) +// HashTreeRoot computes the SSZ hash tree root of the *SubmitBlockRequest. +func (t *SubmitBlockRequest) HashTreeRoot() (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWith(hh) + if err == nil { + root, err = hh.HashRoot() + } + return + }) + return } - -// 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(v1.BidTrace) +// HashTreeRootWith computes the SSZ hash tree root of the *SubmitBlockRequest using the given hash walker. +func (t *SubmitBlockRequest) HashTreeRootWith(hh sszutils.HashWalker) error { + if t == nil { + t = new(SubmitBlockRequest) } - if err = s.Message.HashTreeRootWith(hh); err != nil { - return + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Message' + t := t.Message + if t == nil { + t = new(v1.BidTrace) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPath(err, "Message") + } } - - // Field (1) 'ExecutionPayload' - if err = s.ExecutionPayload.HashTreeRootWith(hh); err != nil { - return + { // Field #1 'ExecutionPayload' + t := t.ExecutionPayload + if t == nil { + t = new(bellatrix.ExecutionPayload) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPath(err, "ExecutionPayload") + } } - - // Field (2) '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) + { // Field #2 'Signature' + hh.PutBytes(t.Signature[:96]) + } + hh.Merkleize(idx) + return nil } diff --git a/api/capella/builderbid_ssz.go b/api/capella/builderbid_ssz.go index 9f2181d..a8659bf 100644 --- a/api/capella/builderbid_ssz.go +++ b/api/capella/builderbid_ssz.go @@ -1,136 +1,158 @@ -// Code generated by fastssz. DO NOT EDIT. -// Hash: 9eb249d7f5f08129f3d3a9bd85af740731ca3ae3150677f16209e6b728acd4f5 -// Version: 0.1.3 +// Code generated by dynamic-ssz. DO NOT EDIT. +// Hash: 90e0ae80d5714d80b3c6f5420710047c78d88cd57f2531191b8e75d276c499ea +// Version: v1.2.2 (https://github.com/pk910/dynamic-ssz) package capella import ( + "encoding/binary" + "github.com/attestantio/go-eth2-client/spec/capella" - ssz "github.com/ferranbt/fastssz" "github.com/holiman/uint256" + dynssz "github.com/pk910/dynamic-ssz" + "github.com/pk910/dynamic-ssz/hasher" + "github.com/pk910/dynamic-ssz/sszutils" ) -// MarshalSSZ ssz marshals the BuilderBid object -func (b *BuilderBid) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) +var _ = sszutils.ErrListTooBig + +// MarshalSSZ marshals the *BuilderBid to SSZ-encoded bytes. +func (t *BuilderBid) MarshalSSZ() ([]byte, error) { + return dynssz.GetGlobalDynSsz().MarshalSSZ(t) } -// MarshalSSZTo ssz marshals the BuilderBid object to a target array -func (b *BuilderBid) MarshalSSZTo(buf []byte) (dst []byte, err error) { +// MarshalSSZTo marshals the *BuilderBid to SSZ-encoded bytes, appending to the provided buffer. +func (t *BuilderBid) MarshalSSZTo(buf []byte) (dst []byte, err error) { dst = buf - offset := int(84) - - // Offset (0) 'Header' - dst = ssz.WriteOffset(dst, offset) - if b.Header == nil { - b.Header = new(capella.ExecutionPayloadHeader) + if t == nil { + t = new(BuilderBid) } - offset += b.Header.SizeSSZ() - - // Field (1) 'Value' - value := b.Value.Bytes32() - for i := 0; i < 32; i++ { - dst = append(dst, value[31-i]) + dstlen := len(dst) + // Offset Field #0 'Header' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #1 'Value' + t := t.Value + if t == nil { + t = new(uint256.Int) + } + dst = sszutils.MarshalUint64Slice(dst, (*t)[:4]) } - - // Field (2) 'Pubkey' - dst = append(dst, b.Pubkey[:]...) - - // Field (0) 'Header' - if dst, err = b.Header.MarshalSSZTo(dst); err != nil { - return + { // Static Field #2 'Pubkey' + dst = append(dst, t.Pubkey[:48]...) } - - return -} - -// UnmarshalSSZ ssz unmarshals the BuilderBid object -func (b *BuilderBid) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 84 { - return ssz.ErrSize + { // Dynamic Field #0 'Header' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.Header + if t == nil { + t = new(capella.ExecutionPayloadHeader) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "Header") + } } + return dst, nil +} - tail := buf - var o0 uint64 - - // Offset (0) 'Header' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset +// UnmarshalSSZ unmarshals the *BuilderBid from SSZ-encoded bytes. +func (t *BuilderBid) UnmarshalSSZ(buf []byte) (err error) { + buflen := len(buf) + if buflen < 84 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 84) } - - if o0 < 84 { - return ssz.ErrInvalidVariableOffset + // Field #0 'Header' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 84 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset0, 84), "Header:o") } - - // Field (1) 'Value' - value := make([]byte, 32) - for i := 0; i < 32; i++ { - value[i] = buf[35-i] + { // Field #1 'Value' (static) + buf := buf[4:36] + val1 := t.Value + if val1 == nil { + val1 = new(uint256.Int) + } + sszutils.UnmarshalUint64Slice((*val1)[:4], buf) + t.Value = val1 } - if b.Value == nil { - b.Value = new(uint256.Int) + { // Field #2 'Pubkey' (static) + buf := buf[36:84] + copy(t.Pubkey[:], buf) } - b.Value.SetBytes32(value) - - // Field (2) 'Pubkey' - copy(b.Pubkey[:], buf[36:84]) - - // Field (0) 'Header' - { - buf = tail[o0:] - if b.Header == nil { - b.Header = new(capella.ExecutionPayloadHeader) + { // Field #0 'Header' (dynamic) + buf := buf[offset0:] + if t.Header == nil { + t.Header = new(capella.ExecutionPayloadHeader) } - if err = b.Header.UnmarshalSSZ(buf); err != nil { - return err + if err = t.Header.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "Header") } } - return err + return nil } -// SizeSSZ returns the ssz encoded size in bytes for the BuilderBid object -func (b *BuilderBid) SizeSSZ() (size int) { - size = 84 - - // Field (0) 'Header' - if b.Header == nil { - b.Header = new(capella.ExecutionPayloadHeader) +// SizeSSZ returns the SSZ encoded size of the *BuilderBid. +func (t *BuilderBid) SizeSSZ() (size int) { + if t == nil { + t = new(BuilderBid) } - size += b.Header.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the BuilderBid object -func (b *BuilderBid) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) + // Field #0 'Header' offset (4 bytes) + // Field #1 'Value' static (32 bytes) + // Field #2 'Pubkey' static (48 bytes) + size += 84 + { // Dynamic field #0 'Header' + size += t.Header.SizeSSZ() + } + return size } -// 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 { +// HashTreeRoot computes the SSZ hash tree root of the *BuilderBid. +func (t *BuilderBid) HashTreeRoot() (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWith(hh) + if err == nil { + root, err = hh.HashRoot() + } return - } - - // Field (1) '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 (2) '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) +// HashTreeRootWith computes the SSZ hash tree root of the *BuilderBid using the given hash walker. +func (t *BuilderBid) HashTreeRootWith(hh sszutils.HashWalker) error { + if t == nil { + t = new(BuilderBid) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Header' + t := t.Header + if t == nil { + t = new(capella.ExecutionPayloadHeader) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPath(err, "Header") + } + } + { // Field #1 'Value' + t := t.Value + if t == nil { + t = new(uint256.Int) + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + var val1, val1Empty uint64 + for idx1 := range 4 { + if idx1 < 4 { + val1 = (*t)[idx1] + } else if idx1 == 4 { + val1 = val1Empty + } + hh.AppendUint64(val1) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.FillUpTo32() + hh.Merkleize(idx) + } + { // Field #2 'Pubkey' + hh.PutBytes(t.Pubkey[:48]) + } + hh.Merkleize(idx) + return nil } diff --git a/api/capella/generate.go b/api/capella/generate.go index e455020..f4eb7d5 100644 --- a/api/capella/generate.go +++ b/api/capella/generate.go @@ -13,8 +13,7 @@ package capella -// Need to `go install github.com/ferranbt/fastssz/sszgen@latest` for this to work. +// Need to `go install github.com/pk910/dynamic-ssz/dynssz-gen@latest` for this to work. //go:generate rm -f builderbid_ssz.go signedbuilderbid_ssz.go submitblockrequest_ssz.go //nolint:revive -//go:generate sszgen --suffix ssz --include ../../../go-eth2-client/spec/capella,../../../go-eth2-client/spec/bellatrix,../../../go-eth2-client/spec/phase0,../v1 --path . --objs BuilderBid,SignedBuilderBid,SubmitBlockRequest -//go:generate goimports -w builderbid_ssz.go signedbuilderbid_ssz.go submitblockrequest_ssz.go +//go:generate dynssz-gen -package . -legacy -without-dynamic-expressions -types BuilderBid:builderbid_ssz.go,SignedBuilderBid:signedbuilderbid_ssz.go,SubmitBlockRequest:submitblockrequest_ssz.go diff --git a/api/capella/signedbuilderbid_ssz.go b/api/capella/signedbuilderbid_ssz.go index 0ad2b04..30ed4bb 100644 --- a/api/capella/signedbuilderbid_ssz.go +++ b/api/capella/signedbuilderbid_ssz.go @@ -1,111 +1,118 @@ -// Code generated by fastssz. DO NOT EDIT. -// Hash: 9eb249d7f5f08129f3d3a9bd85af740731ca3ae3150677f16209e6b728acd4f5 -// Version: 0.1.3 +// Code generated by dynamic-ssz. DO NOT EDIT. +// Hash: 0e0c8ab23bc339c33f93d05f1486154977c625ad87ace52b489780ce1a49284f +// Version: v1.2.2 (https://github.com/pk910/dynamic-ssz) package capella import ( - ssz "github.com/ferranbt/fastssz" + "encoding/binary" + + dynssz "github.com/pk910/dynamic-ssz" + "github.com/pk910/dynamic-ssz/hasher" + "github.com/pk910/dynamic-ssz/sszutils" ) -// MarshalSSZ ssz marshals the SignedBuilderBid object -func (s *SignedBuilderBid) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) +var _ = sszutils.ErrListTooBig + +// MarshalSSZ marshals the *SignedBuilderBid to SSZ-encoded bytes. +func (t *SignedBuilderBid) MarshalSSZ() ([]byte, error) { + return dynssz.GetGlobalDynSsz().MarshalSSZ(t) } -// MarshalSSZTo ssz marshals the SignedBuilderBid object to a target array -func (s *SignedBuilderBid) MarshalSSZTo(buf []byte) (dst []byte, err error) { +// MarshalSSZTo marshals the *SignedBuilderBid to SSZ-encoded bytes, appending to the provided buffer. +func (t *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) + if t == nil { + t = new(SignedBuilderBid) } - 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 + dstlen := len(dst) + // Offset Field #0 'Message' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #1 'Signature' + dst = append(dst, t.Signature[:96]...) } - - return + { // Dynamic Field #0 'Message' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.Message + if t == nil { + t = new(BuilderBid) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "Message") + } + } + return dst, nil } -// 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 +// UnmarshalSSZ unmarshals the *SignedBuilderBid from SSZ-encoded bytes. +func (t *SignedBuilderBid) UnmarshalSSZ(buf []byte) (err error) { + buflen := len(buf) + if buflen < 100 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 100) } - - tail := buf - var o0 uint64 - - // Offset (0) 'Message' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset + // Field #0 'Message' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 100 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset0, 100), "Message:o") } - - if o0 < 100 { - return ssz.ErrInvalidVariableOffset + { // Field #1 'Signature' (static) + buf := buf[4:100] + copy(t.Signature[:], buf) } - - // Field (1) 'Signature' - copy(s.Signature[:], buf[4:100]) - - // Field (0) 'Message' - { - buf = tail[o0:] - if s.Message == nil { - s.Message = new(BuilderBid) + { // Field #0 'Message' (dynamic) + buf := buf[offset0:] + if t.Message == nil { + t.Message = new(BuilderBid) } - if err = s.Message.UnmarshalSSZ(buf); err != nil { - return err + if err = t.Message.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "Message") } } - return err + return nil } -// 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) +// SizeSSZ returns the SSZ encoded size of the *SignedBuilderBid. +func (t *SignedBuilderBid) SizeSSZ() (size int) { + if t == nil { + t = new(SignedBuilderBid) } - size += s.Message.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the SignedBuilderBid object -func (s *SignedBuilderBid) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) + // Field #0 'Message' offset (4 bytes) + // Field #1 'Signature' static (96 bytes) + size += 100 + { // Dynamic field #0 'Message' + size += t.Message.SizeSSZ() + } + return size } -// 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 { +// HashTreeRoot computes the SSZ hash tree root of the *SignedBuilderBid. +func (t *SignedBuilderBid) HashTreeRoot() (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWith(hh) + if err == nil { + root, err = hh.HashRoot() + } 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) +// HashTreeRootWith computes the SSZ hash tree root of the *SignedBuilderBid using the given hash walker. +func (t *SignedBuilderBid) HashTreeRootWith(hh sszutils.HashWalker) error { + if t == nil { + t = new(SignedBuilderBid) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Message' + t := t.Message + if t == nil { + t = new(BuilderBid) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPath(err, "Message") + } + } + { // Field #1 'Signature' + hh.PutBytes(t.Signature[:96]) + } + hh.Merkleize(idx) + return nil } diff --git a/api/capella/submitblockrequest_ssz.go b/api/capella/submitblockrequest_ssz.go index 373547a..48a82d4 100644 --- a/api/capella/submitblockrequest_ssz.go +++ b/api/capella/submitblockrequest_ssz.go @@ -1,137 +1,148 @@ -// Code generated by fastssz. DO NOT EDIT. -// Hash: 36e3e8dd9d5d6e07166f777975c61a28b0f3a97bfeb5b51137d5591ae2a289a2 -// Version: 0.1.3 +// Code generated by dynamic-ssz. DO NOT EDIT. +// Hash: 33d88ef16b1c9e6d96335ac5dca30742e620bf5a1f287fa77962115ebb59565f +// Version: v1.2.2 (https://github.com/pk910/dynamic-ssz) package capella import ( - v1 "github.com/attestantio/go-builder-client/api/v1" + "encoding/binary" + + "github.com/attestantio/go-builder-client/api/v1" "github.com/attestantio/go-eth2-client/spec/capella" - ssz "github.com/ferranbt/fastssz" + dynssz "github.com/pk910/dynamic-ssz" + "github.com/pk910/dynamic-ssz/hasher" + "github.com/pk910/dynamic-ssz/sszutils" ) -// MarshalSSZ ssz marshals the SubmitBlockRequest object -func (s *SubmitBlockRequest) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) +var _ = sszutils.ErrListTooBig + +// MarshalSSZ marshals the *SubmitBlockRequest to SSZ-encoded bytes. +func (t *SubmitBlockRequest) MarshalSSZ() ([]byte, error) { + return dynssz.GetGlobalDynSsz().MarshalSSZ(t) } -// MarshalSSZTo ssz marshals the SubmitBlockRequest object to a target array -func (s *SubmitBlockRequest) MarshalSSZTo(buf []byte) (dst []byte, err error) { +// MarshalSSZTo marshals the *SubmitBlockRequest to SSZ-encoded bytes, appending to the provided buffer. +func (t *SubmitBlockRequest) MarshalSSZTo(buf []byte) (dst []byte, err error) { dst = buf - offset := int(336) - - // Field (0) 'Message' - if s.Message == nil { - s.Message = new(v1.BidTrace) + if t == nil { + t = new(SubmitBlockRequest) } - if dst, err = s.Message.MarshalSSZTo(dst); err != nil { - return + dstlen := len(dst) + { // Static Field #0 'Message' + t := t.Message + if t == nil { + t = new(v1.BidTrace) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "Message") + } } - - // Offset (1) 'ExecutionPayload' - dst = ssz.WriteOffset(dst, offset) - if s.ExecutionPayload == nil { - s.ExecutionPayload = new(capella.ExecutionPayload) + // Offset Field #1 'ExecutionPayload' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #2 'Signature' + dst = append(dst, t.Signature[:96]...) } - offset += s.ExecutionPayload.SizeSSZ() - - // Field (2) 'Signature' - dst = append(dst, s.Signature[:]...) - - // Field (1) 'ExecutionPayload' - if dst, err = s.ExecutionPayload.MarshalSSZTo(dst); err != nil { - return + { // Dynamic Field #1 'ExecutionPayload' + binary.LittleEndian.PutUint32(dst[dstlen+236:], uint32(len(dst)-dstlen)) + t := t.ExecutionPayload + if t == nil { + t = new(capella.ExecutionPayload) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "ExecutionPayload") + } } - - return + return dst, nil } -// UnmarshalSSZ ssz unmarshals the SubmitBlockRequest object -func (s *SubmitBlockRequest) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 336 { - return ssz.ErrSize - } - - tail := buf - var o1 uint64 - - // Field (0) 'Message' - if s.Message == nil { - s.Message = new(v1.BidTrace) +// UnmarshalSSZ unmarshals the *SubmitBlockRequest from SSZ-encoded bytes. +func (t *SubmitBlockRequest) UnmarshalSSZ(buf []byte) (err error) { + buflen := len(buf) + if buflen < 336 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 336) } - if err = s.Message.UnmarshalSSZ(buf[0:236]); err != nil { - return err + { // Field #0 'Message' (static) + buf := buf[0:236] + if t.Message == nil { + t.Message = new(v1.BidTrace) + } + if err = t.Message.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "Message") + } } - - // Offset (1) 'ExecutionPayload' - if o1 = ssz.ReadOffset(buf[236:240]); o1 > size { - return ssz.ErrOffset + // Field #1 'ExecutionPayload' (offset) + offset1 := int(binary.LittleEndian.Uint32(buf[236:240])) + if offset1 != 336 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset1, 336), "ExecutionPayload:o") } - - if o1 < 336 { - return ssz.ErrInvalidVariableOffset + { // Field #2 'Signature' (static) + buf := buf[240:336] + copy(t.Signature[:], buf) } - - // Field (2) 'Signature' - copy(s.Signature[:], buf[240:336]) - - // Field (1) 'ExecutionPayload' - { - buf = tail[o1:] - if s.ExecutionPayload == nil { - s.ExecutionPayload = new(capella.ExecutionPayload) + { // Field #1 'ExecutionPayload' (dynamic) + buf := buf[offset1:] + if t.ExecutionPayload == nil { + t.ExecutionPayload = new(capella.ExecutionPayload) } - if err = s.ExecutionPayload.UnmarshalSSZ(buf); err != nil { - return err + if err = t.ExecutionPayload.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "ExecutionPayload") } } - return err + return nil } -// SizeSSZ returns the ssz encoded size in bytes for the SubmitBlockRequest object -func (s *SubmitBlockRequest) SizeSSZ() (size int) { - size = 336 - - // Field (1) 'ExecutionPayload' - if s.ExecutionPayload == nil { - s.ExecutionPayload = new(capella.ExecutionPayload) +// SizeSSZ returns the SSZ encoded size of the *SubmitBlockRequest. +func (t *SubmitBlockRequest) SizeSSZ() (size int) { + if t == nil { + t = new(SubmitBlockRequest) } - size += s.ExecutionPayload.SizeSSZ() - - return + // Field #0 'Message' static (236 bytes) + // Field #1 'ExecutionPayload' offset (4 bytes) + // Field #2 'Signature' static (96 bytes) + size += 336 + { // Dynamic field #1 'ExecutionPayload' + size += t.ExecutionPayload.SizeSSZ() + } + return size } -// HashTreeRoot ssz hashes the SubmitBlockRequest object -func (s *SubmitBlockRequest) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) +// HashTreeRoot computes the SSZ hash tree root of the *SubmitBlockRequest. +func (t *SubmitBlockRequest) HashTreeRoot() (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWith(hh) + if err == nil { + root, err = hh.HashRoot() + } + return + }) + return } - -// 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(v1.BidTrace) +// HashTreeRootWith computes the SSZ hash tree root of the *SubmitBlockRequest using the given hash walker. +func (t *SubmitBlockRequest) HashTreeRootWith(hh sszutils.HashWalker) error { + if t == nil { + t = new(SubmitBlockRequest) } - if err = s.Message.HashTreeRootWith(hh); err != nil { - return + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Message' + t := t.Message + if t == nil { + t = new(v1.BidTrace) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPath(err, "Message") + } } - - // Field (1) 'ExecutionPayload' - if err = s.ExecutionPayload.HashTreeRootWith(hh); err != nil { - return + { // Field #1 'ExecutionPayload' + t := t.ExecutionPayload + if t == nil { + t = new(capella.ExecutionPayload) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPath(err, "ExecutionPayload") + } } - - // Field (2) '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) + { // Field #2 'Signature' + hh.PutBytes(t.Signature[:96]) + } + hh.Merkleize(idx) + return nil } diff --git a/api/deneb/blobsbundle_ssz.go b/api/deneb/blobsbundle_ssz.go index bd4be81..42628f3 100644 --- a/api/deneb/blobsbundle_ssz.go +++ b/api/deneb/blobsbundle_ssz.go @@ -1,208 +1,220 @@ -// Code generated by fastssz. DO NOT EDIT. -// Hash: 966ad2b2b4b70f8314d658e73c8e77c264f52d051894da2d69c4208ee6af1378 -// Version: 0.1.3 +// Code generated by dynamic-ssz. DO NOT EDIT. +// Hash: b7889288072c895880b042595d9757aba0df3ba806effa251340e2b911d7e269 +// Version: v1.2.2 (https://github.com/pk910/dynamic-ssz) package deneb import ( - "github.com/attestantio/go-eth2-client/spec/deneb" - ssz "github.com/ferranbt/fastssz" + "encoding/binary" + + dynssz "github.com/pk910/dynamic-ssz" + "github.com/pk910/dynamic-ssz/hasher" + "github.com/pk910/dynamic-ssz/sszutils" ) -// MarshalSSZ ssz marshals the BlobsBundle object -func (b *BlobsBundle) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) +var _ = sszutils.ErrListTooBig + +// MarshalSSZ marshals the *BlobsBundle to SSZ-encoded bytes. +func (t *BlobsBundle) MarshalSSZ() ([]byte, error) { + return dynssz.GetGlobalDynSsz().MarshalSSZ(t) } -// MarshalSSZTo ssz marshals the BlobsBundle object to a target array -func (b *BlobsBundle) MarshalSSZTo(buf []byte) (dst []byte, err error) { +// MarshalSSZTo marshals the *BlobsBundle to SSZ-encoded bytes, appending to the provided buffer. +func (t *BlobsBundle) MarshalSSZTo(buf []byte) (dst []byte, err error) { dst = buf - offset := int(12) - - // Offset (0) 'Commitments' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.Commitments) * 48 - - // Offset (1) 'Proofs' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.Proofs) * 48 - - // Offset (2) 'Blobs' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.Blobs) * 131072 - - // Field (0) 'Commitments' - if size := len(b.Commitments); size > 4096 { - err = ssz.ErrListTooBigFn("BlobsBundle.Commitments", size, 4096) - return - } - for ii := 0; ii < len(b.Commitments); ii++ { - dst = append(dst, b.Commitments[ii][:]...) - } - - // Field (1) 'Proofs' - if size := len(b.Proofs); size > 4096 { - err = ssz.ErrListTooBigFn("BlobsBundle.Proofs", size, 4096) - return - } - for ii := 0; ii < len(b.Proofs); ii++ { - dst = append(dst, b.Proofs[ii][:]...) + zeroBytes := sszutils.ZeroBytes() + if t == nil { + t = new(BlobsBundle) + } + dstlen := len(dst) + // Offset Field #0 'Commitments' + // Offset Field #1 'Proofs' + // Offset Field #2 'Blobs' + dst = append(dst, zeroBytes[:12]...) + { // Dynamic Field #0 'Commitments' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.Commitments + vlen := len(t) + if vlen > 4096 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 4096), "Commitments") + } + for idx1 := range vlen { + dst = append(dst, t[idx1][:48]...) + } } - - // Field (2) 'Blobs' - if size := len(b.Blobs); size > 4096 { - err = ssz.ErrListTooBigFn("BlobsBundle.Blobs", size, 4096) - return + { // Dynamic Field #1 'Proofs' + binary.LittleEndian.PutUint32(dst[dstlen+4:], uint32(len(dst)-dstlen)) + t := t.Proofs + vlen := len(t) + if vlen > 4096 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 4096), "Proofs") + } + for idx1 := range vlen { + dst = append(dst, t[idx1][:48]...) + } } - for ii := 0; ii < len(b.Blobs); ii++ { - dst = append(dst, b.Blobs[ii][:]...) + { // Dynamic Field #2 'Blobs' + binary.LittleEndian.PutUint32(dst[dstlen+8:], uint32(len(dst)-dstlen)) + t := t.Blobs + vlen := len(t) + if vlen > 4096 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 4096), "Blobs") + } + for idx1 := range vlen { + dst = append(dst, t[idx1][:131072]...) + } } - - return + return dst, nil } -// UnmarshalSSZ ssz unmarshals the BlobsBundle object -func (b *BlobsBundle) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 12 { - return ssz.ErrSize - } - - tail := buf - var o0, o1, o2 uint64 - - // Offset (0) 'Commitments' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } - - if o0 < 12 { - return ssz.ErrInvalidVariableOffset - } - - // Offset (1) 'Proofs' - if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 { - return ssz.ErrOffset - } - - // Offset (2) 'Blobs' - if o2 = ssz.ReadOffset(buf[8:12]); o2 > size || o1 > o2 { - return ssz.ErrOffset - } - - // Field (0) 'Commitments' - { - buf = tail[o0:o1] - num, err := ssz.DivideInt2(len(buf), 48, 4096) - if err != nil { - return err +// UnmarshalSSZ unmarshals the *BlobsBundle from SSZ-encoded bytes. +func (t *BlobsBundle) UnmarshalSSZ(buf []byte) (err error) { + buflen := len(buf) + if buflen < 12 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 12) + } + // Field #0 'Commitments' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 12 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset0, 12), "Commitments:o") + } + // Field #1 'Proofs' (offset) + offset1 := int(binary.LittleEndian.Uint32(buf[4:8])) + if offset1 < offset0 || offset1 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset1, offset0, buflen), "Proofs:o") + } + // Field #2 'Blobs' (offset) + offset2 := int(binary.LittleEndian.Uint32(buf[8:12])) + if offset2 < offset1 || offset2 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset2, offset1, buflen), "Blobs:o") + } + { // Field #0 'Commitments' (dynamic) + buf := buf[offset0:offset1] + val1 := t.Commitments + itemCount := len(buf) / 48 + if len(buf)%48 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 48), "Commitments") } - b.Commitments = make([]deneb.KZGCommitment, num) - for ii := 0; ii < num; ii++ { - copy(b.Commitments[ii][:], buf[ii*48:(ii+1)*48]) + val1 = sszutils.ExpandSlice(val1, itemCount) + for idx1 := range itemCount { + buf := buf[48*idx1 : 48*(idx1+1)] + copy(val1[idx1][:], buf) } - } - - // Field (1) 'Proofs' - { - buf = tail[o1:o2] - num, err := ssz.DivideInt2(len(buf), 48, 4096) - if err != nil { - return err + t.Commitments = val1 + } + { // Field #1 'Proofs' (dynamic) + buf := buf[offset1:offset2] + val2 := t.Proofs + itemCount := len(buf) / 48 + if len(buf)%48 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 48), "Proofs") } - b.Proofs = make([]deneb.KZGProof, num) - for ii := 0; ii < num; ii++ { - copy(b.Proofs[ii][:], buf[ii*48:(ii+1)*48]) + val2 = sszutils.ExpandSlice(val2, itemCount) + for idx1 := range itemCount { + buf := buf[48*idx1 : 48*(idx1+1)] + copy(val2[idx1][:], buf) } - } - - // Field (2) 'Blobs' - { - buf = tail[o2:] - num, err := ssz.DivideInt2(len(buf), 131072, 4096) - if err != nil { - return err + t.Proofs = val2 + } + { // Field #2 'Blobs' (dynamic) + buf := buf[offset2:] + val3 := t.Blobs + itemCount := len(buf) / 131072 + if len(buf)%131072 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 131072), "Blobs") } - b.Blobs = make([]deneb.Blob, num) - for ii := 0; ii < num; ii++ { - copy(b.Blobs[ii][:], buf[ii*131072:(ii+1)*131072]) + val3 = sszutils.ExpandSlice(val3, itemCount) + for idx1 := range itemCount { + buf := buf[131072*idx1 : 131072*(idx1+1)] + copy(val3[idx1][:], buf) } + t.Blobs = val3 } - return err + return nil } -// SizeSSZ returns the ssz encoded size in bytes for the BlobsBundle object -func (b *BlobsBundle) SizeSSZ() (size int) { - size = 12 - - // Field (0) 'Commitments' - size += len(b.Commitments) * 48 - - // Field (1) 'Proofs' - size += len(b.Proofs) * 48 - - // Field (2) 'Blobs' - size += len(b.Blobs) * 131072 - - return +// SizeSSZ returns the SSZ encoded size of the *BlobsBundle. +func (t *BlobsBundle) SizeSSZ() (size int) { + if t == nil { + t = new(BlobsBundle) + } + // Field #0 'Commitments' offset (4 bytes) + // Field #1 'Proofs' offset (4 bytes) + // Field #2 'Blobs' offset (4 bytes) + size += 12 + { // Dynamic field #0 'Commitments' + size += len(t.Commitments) * 48 + } + { // Dynamic field #1 'Proofs' + size += len(t.Proofs) * 48 + } + { // Dynamic field #2 'Blobs' + size += len(t.Blobs) * 131072 + } + return size } -// HashTreeRoot ssz hashes the BlobsBundle object -func (b *BlobsBundle) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) +// HashTreeRoot computes the SSZ hash tree root of the *BlobsBundle. +func (t *BlobsBundle) HashTreeRoot() (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWith(hh) + if err == nil { + root, err = hh.HashRoot() + } + return + }) + return } - -// HashTreeRootWith ssz hashes the BlobsBundle object with a hasher -func (b *BlobsBundle) HashTreeRootWith(hh ssz.HashWalker) (err error) { - indx := hh.Index() - - // Field (0) 'Commitments' - { - if size := len(b.Commitments); size > 4096 { - err = ssz.ErrListTooBigFn("BlobsBundle.Commitments", size, 4096) - return +// HashTreeRootWith computes the SSZ hash tree root of the *BlobsBundle using the given hash walker. +func (t *BlobsBundle) HashTreeRootWith(hh sszutils.HashWalker) error { + if t == nil { + t = new(BlobsBundle) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Commitments' + t := t.Commitments + vlen := uint64(len(t)) + if vlen > 4096 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 4096), "Commitments") } - subIndx := hh.Index() - for _, i := range b.Commitments { - hh.PutBytes(i[:]) + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + hh.PutBytes(t[idx1][:48]) + if (idx1+1)%256 == 0 { + hh.Collapse() + } } - numItems := uint64(len(b.Commitments)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(4096, vlen, 32)) } - - // Field (1) 'Proofs' - { - if size := len(b.Proofs); size > 4096 { - err = ssz.ErrListTooBigFn("BlobsBundle.Proofs", size, 4096) - return + { // Field #1 'Proofs' + t := t.Proofs + vlen := uint64(len(t)) + if vlen > 4096 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 4096), "Proofs") } - subIndx := hh.Index() - for _, i := range b.Proofs { - hh.PutBytes(i[:]) + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + hh.PutBytes(t[idx1][:48]) + if (idx1+1)%256 == 0 { + hh.Collapse() + } } - numItems := uint64(len(b.Proofs)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(4096, vlen, 32)) } - - // Field (2) 'Blobs' - { - if size := len(b.Blobs); size > 4096 { - err = ssz.ErrListTooBigFn("BlobsBundle.Blobs", size, 4096) - return + { // Field #2 'Blobs' + t := t.Blobs + vlen := uint64(len(t)) + if vlen > 4096 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 4096), "Blobs") } - subIndx := hh.Index() - for _, i := range b.Blobs { - hh.PutBytes(i[:]) + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + hh.PutBytes(t[idx1][:131072]) + if (idx1+1)%256 == 0 { + hh.Collapse() + } } - numItems := uint64(len(b.Blobs)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(4096, vlen, 32)) } - - hh.Merkleize(indx) - return -} - -// GetTree ssz hashes the BlobsBundle object -func (b *BlobsBundle) GetTree() (*ssz.Node, error) { - return ssz.ProofTree(b) + hh.Merkleize(idx) + return nil } diff --git a/api/deneb/builderbid_ssz.go b/api/deneb/builderbid_ssz.go index 1ea5961..a0e8484 100644 --- a/api/deneb/builderbid_ssz.go +++ b/api/deneb/builderbid_ssz.go @@ -1,184 +1,208 @@ -// Code generated by fastssz. DO NOT EDIT. -// Hash: 7892d1b8a34d12e16ce7b5e0af8aef325f91e09b3a36208f80b706f3ffed4b78 -// Version: 0.1.3 +// Code generated by dynamic-ssz. DO NOT EDIT. +// Hash: 549e5d34fc1b8bcfc4ef5137a15c2199b8572d8b5d26de8f0d93925f3ad90006 +// Version: v1.2.2 (https://github.com/pk910/dynamic-ssz) package deneb import ( + "encoding/binary" + "github.com/attestantio/go-eth2-client/spec/deneb" - ssz "github.com/ferranbt/fastssz" "github.com/holiman/uint256" + dynssz "github.com/pk910/dynamic-ssz" + "github.com/pk910/dynamic-ssz/hasher" + "github.com/pk910/dynamic-ssz/sszutils" ) -// MarshalSSZ ssz marshals the BuilderBid object -func (b *BuilderBid) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) +var _ = sszutils.ErrListTooBig + +// MarshalSSZ marshals the *BuilderBid to SSZ-encoded bytes. +func (t *BuilderBid) MarshalSSZ() ([]byte, error) { + return dynssz.GetGlobalDynSsz().MarshalSSZ(t) } -// MarshalSSZTo ssz marshals the BuilderBid object to a target array -func (b *BuilderBid) MarshalSSZTo(buf []byte) (dst []byte, err error) { +// MarshalSSZTo marshals the *BuilderBid to SSZ-encoded bytes, appending to the provided buffer. +func (t *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(deneb.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]) + if t == nil { + t = new(BuilderBid) + } + dstlen := len(dst) + // Offset Field #0 'Header' + // Offset Field #1 'BlobKZGCommitments' + dst = append(dst, 0, 0, 0, 0, 0, 0, 0, 0) + { // Static Field #2 'Value' + t := t.Value + if t == nil { + t = new(uint256.Int) + } + dst = sszutils.MarshalUint64Slice(dst, (*t)[:4]) } - - // Field (3) 'Pubkey' - dst = append(dst, b.Pubkey[:]...) - - // Field (0) 'Header' - if dst, err = b.Header.MarshalSSZTo(dst); err != nil { - return + { // Static Field #3 'Pubkey' + dst = append(dst, t.Pubkey[:48]...) } - - // Field (1) 'BlobKZGCommitments' - if size := len(b.BlobKZGCommitments); size > 4096 { - err = ssz.ErrListTooBigFn("BuilderBid.BlobKZGCommitments", size, 4096) - return + { // Dynamic Field #0 'Header' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.Header + if t == nil { + t = new(deneb.ExecutionPayloadHeader) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "Header") + } } - for ii := 0; ii < len(b.BlobKZGCommitments); ii++ { - dst = append(dst, b.BlobKZGCommitments[ii][:]...) + { // Dynamic Field #1 'BlobKZGCommitments' + binary.LittleEndian.PutUint32(dst[dstlen+4:], uint32(len(dst)-dstlen)) + t := t.BlobKZGCommitments + vlen := len(t) + if vlen > 4096 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 4096), "BlobKZGCommitments") + } + for idx1 := range vlen { + dst = append(dst, t[idx1][:48]...) + } } - - return + return dst, nil } -// 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] +// UnmarshalSSZ unmarshals the *BuilderBid from SSZ-encoded bytes. +func (t *BuilderBid) UnmarshalSSZ(buf []byte) (err error) { + buflen := len(buf) + if buflen < 88 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 88) + } + // Field #0 'Header' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 88 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset0, 88), "Header:o") + } + // Field #1 'BlobKZGCommitments' (offset) + offset1 := int(binary.LittleEndian.Uint32(buf[4:8])) + if offset1 < offset0 || offset1 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset1, offset0, buflen), "BlobKZGCommitments:o") + } + { // Field #2 'Value' (static) + buf := buf[8:40] + val1 := t.Value + if val1 == nil { + val1 = new(uint256.Int) + } + sszutils.UnmarshalUint64Slice((*val1)[:4], buf) + t.Value = val1 } - if b.Value == nil { - b.Value = new(uint256.Int) + { // Field #3 'Pubkey' (static) + buf := buf[40:88] + copy(t.Pubkey[:], buf) } - 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(deneb.ExecutionPayloadHeader) + { // Field #0 'Header' (dynamic) + buf := buf[offset0:offset1] + if t.Header == nil { + t.Header = new(deneb.ExecutionPayloadHeader) } - if err = b.Header.UnmarshalSSZ(buf); err != nil { - return err + if err = t.Header.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "Header") } } - - // Field (1) 'BlobKZGCommitments' - { - buf = tail[o1:] - num, err := ssz.DivideInt2(len(buf), 48, 4096) - if err != nil { - return err + { // Field #1 'BlobKZGCommitments' (dynamic) + buf := buf[offset1:] + val2 := t.BlobKZGCommitments + itemCount := len(buf) / 48 + if len(buf)%48 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 48), "BlobKZGCommitments") } - b.BlobKZGCommitments = make([]deneb.KZGCommitment, num) - for ii := 0; ii < num; ii++ { - copy(b.BlobKZGCommitments[ii][:], buf[ii*48:(ii+1)*48]) + val2 = sszutils.ExpandSlice(val2, itemCount) + for idx1 := range itemCount { + buf := buf[48*idx1 : 48*(idx1+1)] + copy(val2[idx1][:], buf) } + t.BlobKZGCommitments = val2 } - return err + return nil } -// 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(deneb.ExecutionPayloadHeader) +// SizeSSZ returns the SSZ encoded size of the *BuilderBid. +func (t *BuilderBid) SizeSSZ() (size int) { + if t == nil { + t = new(BuilderBid) } - 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) + // Field #0 'Header' offset (4 bytes) + // Field #1 'BlobKZGCommitments' offset (4 bytes) + // Field #2 'Value' static (32 bytes) + // Field #3 'Pubkey' static (48 bytes) + size += 88 + { // Dynamic field #0 'Header' + size += t.Header.SizeSSZ() + } + { // Dynamic field #1 'BlobKZGCommitments' + size += len(t.BlobKZGCommitments) * 48 + } + return size } -// 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 { +// HashTreeRoot computes the SSZ hash tree root of the *BuilderBid. +func (t *BuilderBid) HashTreeRoot() (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWith(hh) + if err == nil { + root, err = hh.HashRoot() + } return + }) + return +} +// HashTreeRootWith computes the SSZ hash tree root of the *BuilderBid using the given hash walker. +func (t *BuilderBid) HashTreeRootWith(hh sszutils.HashWalker) error { + if t == nil { + t = new(BuilderBid) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Header' + t := t.Header + if t == nil { + t = new(deneb.ExecutionPayloadHeader) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPath(err, "Header") + } } - - // Field (1) 'BlobKZGCommitments' - { - if size := len(b.BlobKZGCommitments); size > 4096 { - err = ssz.ErrListTooBigFn("BuilderBid.BlobKZGCommitments", size, 4096) - return + { // Field #1 'BlobKZGCommitments' + t := t.BlobKZGCommitments + vlen := uint64(len(t)) + if vlen > 4096 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 4096), "BlobKZGCommitments") } - subIndx := hh.Index() - for _, i := range b.BlobKZGCommitments { - hh.PutBytes(i[:]) + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + hh.PutBytes(t[idx1][:48]) + if (idx1+1)%256 == 0 { + hh.Collapse() + } } - numItems := uint64(len(b.BlobKZGCommitments)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(4096, vlen, 32)) } - - // 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] + { // Field #2 'Value' + t := t.Value + if t == nil { + t = new(uint256.Int) + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + var val1, val1Empty uint64 + for idx1 := range 4 { + if idx1 < 4 { + val1 = (*t)[idx1] + } else if idx1 == 4 { + val1 = val1Empty + } + hh.AppendUint64(val1) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.FillUpTo32() + hh.Merkleize(idx) } - 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) + { // Field #3 'Pubkey' + hh.PutBytes(t.Pubkey[:48]) + } + hh.Merkleize(idx) + return nil } diff --git a/api/deneb/executionpayloadandblobsbundle_ssz.go b/api/deneb/executionpayloadandblobsbundle_ssz.go index 217f38b..63a64c9 100644 --- a/api/deneb/executionpayloadandblobsbundle_ssz.go +++ b/api/deneb/executionpayloadandblobsbundle_ssz.go @@ -1,142 +1,146 @@ -// Code generated by fastssz. DO NOT EDIT. -// Hash: 10a07cbc20d028173c2b950c0cc71c32a3a1707e138761dc4753721b2a976658 -// Version: 0.1.3 +// Code generated by dynamic-ssz. DO NOT EDIT. +// Hash: f1ee82f04d28a2325fa1ca7d02df912b13b626e245ee0245ddf44c6839291ebe +// Version: v1.2.2 (https://github.com/pk910/dynamic-ssz) package deneb import ( + "encoding/binary" + "github.com/attestantio/go-eth2-client/spec/deneb" - ssz "github.com/ferranbt/fastssz" + dynssz "github.com/pk910/dynamic-ssz" + "github.com/pk910/dynamic-ssz/hasher" + "github.com/pk910/dynamic-ssz/sszutils" ) -// MarshalSSZ ssz marshals the ExecutionPayloadAndBlobsBundle object -func (e *ExecutionPayloadAndBlobsBundle) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(e) +var _ = sszutils.ErrListTooBig + +// MarshalSSZ marshals the *ExecutionPayloadAndBlobsBundle to SSZ-encoded bytes. +func (t *ExecutionPayloadAndBlobsBundle) MarshalSSZ() ([]byte, error) { + return dynssz.GetGlobalDynSsz().MarshalSSZ(t) } -// MarshalSSZTo ssz marshals the ExecutionPayloadAndBlobsBundle object to a target array -func (e *ExecutionPayloadAndBlobsBundle) MarshalSSZTo(buf []byte) (dst []byte, err error) { +// MarshalSSZTo marshals the *ExecutionPayloadAndBlobsBundle to SSZ-encoded bytes, appending to the provided buffer. +func (t *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(deneb.ExecutionPayload) + if t == nil { + t = new(ExecutionPayloadAndBlobsBundle) } - offset += e.ExecutionPayload.SizeSSZ() - - // Offset (1) 'BlobsBundle' - dst = ssz.WriteOffset(dst, offset) - if e.BlobsBundle == nil { - e.BlobsBundle = new(BlobsBundle) - } - offset += e.BlobsBundle.SizeSSZ() - - // Field (0) 'ExecutionPayload' - if dst, err = e.ExecutionPayload.MarshalSSZTo(dst); err != nil { - return + dstlen := len(dst) + // Offset Field #0 'ExecutionPayload' + // Offset Field #1 'BlobsBundle' + dst = append(dst, 0, 0, 0, 0, 0, 0, 0, 0) + { // Dynamic Field #0 'ExecutionPayload' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.ExecutionPayload + if t == nil { + t = new(deneb.ExecutionPayload) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "ExecutionPayload") + } } - - // Field (1) 'BlobsBundle' - if dst, err = e.BlobsBundle.MarshalSSZTo(dst); err != nil { - return + { // Dynamic Field #1 'BlobsBundle' + binary.LittleEndian.PutUint32(dst[dstlen+4:], uint32(len(dst)-dstlen)) + t := t.BlobsBundle + if t == nil { + t = new(BlobsBundle) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "BlobsBundle") + } } - - return + return dst, nil } -// 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 +// UnmarshalSSZ unmarshals the *ExecutionPayloadAndBlobsBundle from SSZ-encoded bytes. +func (t *ExecutionPayloadAndBlobsBundle) UnmarshalSSZ(buf []byte) (err error) { + buflen := len(buf) + if buflen < 8 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 8) } - - tail := buf - var o0, o1 uint64 - - // Offset (0) 'ExecutionPayload' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset + // Field #0 'ExecutionPayload' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 8 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset0, 8), "ExecutionPayload:o") } - - if o0 < 8 { - return ssz.ErrInvalidVariableOffset - } - - // Offset (1) 'BlobsBundle' - if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 { - return ssz.ErrOffset + // Field #1 'BlobsBundle' (offset) + offset1 := int(binary.LittleEndian.Uint32(buf[4:8])) + if offset1 < offset0 || offset1 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset1, offset0, buflen), "BlobsBundle:o") } - - // Field (0) 'ExecutionPayload' - { - buf = tail[o0:o1] - if e.ExecutionPayload == nil { - e.ExecutionPayload = new(deneb.ExecutionPayload) + { // Field #0 'ExecutionPayload' (dynamic) + buf := buf[offset0:offset1] + if t.ExecutionPayload == nil { + t.ExecutionPayload = new(deneb.ExecutionPayload) } - if err = e.ExecutionPayload.UnmarshalSSZ(buf); err != nil { - return err + if err = t.ExecutionPayload.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "ExecutionPayload") } } - - // Field (1) 'BlobsBundle' - { - buf = tail[o1:] - if e.BlobsBundle == nil { - e.BlobsBundle = new(BlobsBundle) + { // Field #1 'BlobsBundle' (dynamic) + buf := buf[offset1:] + if t.BlobsBundle == nil { + t.BlobsBundle = new(BlobsBundle) } - if err = e.BlobsBundle.UnmarshalSSZ(buf); err != nil { - return err + if err = t.BlobsBundle.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "BlobsBundle") } } - return err + return nil } -// 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(deneb.ExecutionPayload) +// SizeSSZ returns the SSZ encoded size of the *ExecutionPayloadAndBlobsBundle. +func (t *ExecutionPayloadAndBlobsBundle) SizeSSZ() (size int) { + if t == nil { + t = new(ExecutionPayloadAndBlobsBundle) } - size += e.ExecutionPayload.SizeSSZ() - - // Field (1) 'BlobsBundle' - if e.BlobsBundle == nil { - e.BlobsBundle = new(BlobsBundle) + // Field #0 'ExecutionPayload' offset (4 bytes) + // Field #1 'BlobsBundle' offset (4 bytes) + size += 8 + { // Dynamic field #0 'ExecutionPayload' + size += t.ExecutionPayload.SizeSSZ() } - 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 + { // Dynamic field #1 'BlobsBundle' + size += t.BlobsBundle.SizeSSZ() } + return size +} - // Field (1) 'BlobsBundle' - if err = e.BlobsBundle.HashTreeRootWith(hh); err != nil { +// HashTreeRoot computes the SSZ hash tree root of the *ExecutionPayloadAndBlobsBundle. +func (t *ExecutionPayloadAndBlobsBundle) HashTreeRoot() (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWith(hh) + if err == nil { + root, err = hh.HashRoot() + } return - } - - hh.Merkleize(indx) + }) return } - -// GetTree ssz hashes the ExecutionPayloadAndBlobsBundle object -func (e *ExecutionPayloadAndBlobsBundle) GetTree() (*ssz.Node, error) { - return ssz.ProofTree(e) +// HashTreeRootWith computes the SSZ hash tree root of the *ExecutionPayloadAndBlobsBundle using the given hash walker. +func (t *ExecutionPayloadAndBlobsBundle) HashTreeRootWith(hh sszutils.HashWalker) error { + if t == nil { + t = new(ExecutionPayloadAndBlobsBundle) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'ExecutionPayload' + t := t.ExecutionPayload + if t == nil { + t = new(deneb.ExecutionPayload) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPath(err, "ExecutionPayload") + } + } + { // Field #1 'BlobsBundle' + t := t.BlobsBundle + if t == nil { + t = new(BlobsBundle) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPath(err, "BlobsBundle") + } + } + hh.Merkleize(idx) + return nil } diff --git a/api/deneb/generate.go b/api/deneb/generate.go new file mode 100644 index 0000000..142a884 --- /dev/null +++ b/api/deneb/generate.go @@ -0,0 +1,19 @@ +// Copyright © 2026 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 deneb + +//nolint:revive +// Need to `go install github.com/pk910/dynamic-ssz/dynssz-gen@latest` for this to work. +//go:generate rm -f signedbuilderbid_ssz.go submitblockrequest_ssz.go builderbid_ssz.go blobsbundle_ssz.go executionpayloadandblobsbundle_ssz.go +//go:generate dynssz-gen -package . -legacy -without-dynamic-expressions -types BuilderBid:builderbid_ssz.go,SignedBuilderBid:signedbuilderbid_ssz.go,SubmitBlockRequest:submitblockrequest_ssz.go,BlobsBundle:blobsbundle_ssz.go,ExecutionPayloadAndBlobsBundle:executionpayloadandblobsbundle_ssz.go diff --git a/api/deneb/signedbuilderbid_ssz.go b/api/deneb/signedbuilderbid_ssz.go index ac3aac1..d6dd905 100644 --- a/api/deneb/signedbuilderbid_ssz.go +++ b/api/deneb/signedbuilderbid_ssz.go @@ -1,111 +1,118 @@ -// Code generated by fastssz. DO NOT EDIT. -// Hash: 9eb249d7f5f08129f3d3a9bd85af740731ca3ae3150677f16209e6b728acd4f5 -// Version: 0.1.3 +// Code generated by dynamic-ssz. DO NOT EDIT. +// Hash: 7666a8a5ec68befe7d9edd4ceadd514283b9a3002af38efb5f7486e2edb88162 +// Version: v1.2.2 (https://github.com/pk910/dynamic-ssz) package deneb import ( - ssz "github.com/ferranbt/fastssz" + "encoding/binary" + + dynssz "github.com/pk910/dynamic-ssz" + "github.com/pk910/dynamic-ssz/hasher" + "github.com/pk910/dynamic-ssz/sszutils" ) -// MarshalSSZ ssz marshals the SignedBuilderBid object -func (s *SignedBuilderBid) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) +var _ = sszutils.ErrListTooBig + +// MarshalSSZ marshals the *SignedBuilderBid to SSZ-encoded bytes. +func (t *SignedBuilderBid) MarshalSSZ() ([]byte, error) { + return dynssz.GetGlobalDynSsz().MarshalSSZ(t) } -// MarshalSSZTo ssz marshals the SignedBuilderBid object to a target array -func (s *SignedBuilderBid) MarshalSSZTo(buf []byte) (dst []byte, err error) { +// MarshalSSZTo marshals the *SignedBuilderBid to SSZ-encoded bytes, appending to the provided buffer. +func (t *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) + if t == nil { + t = new(SignedBuilderBid) } - 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 + dstlen := len(dst) + // Offset Field #0 'Message' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #1 'Signature' + dst = append(dst, t.Signature[:96]...) } - - return + { // Dynamic Field #0 'Message' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.Message + if t == nil { + t = new(BuilderBid) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "Message") + } + } + return dst, nil } -// 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 +// UnmarshalSSZ unmarshals the *SignedBuilderBid from SSZ-encoded bytes. +func (t *SignedBuilderBid) UnmarshalSSZ(buf []byte) (err error) { + buflen := len(buf) + if buflen < 100 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 100) } - - tail := buf - var o0 uint64 - - // Offset (0) 'Message' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset + // Field #0 'Message' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 100 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset0, 100), "Message:o") } - - if o0 < 100 { - return ssz.ErrInvalidVariableOffset + { // Field #1 'Signature' (static) + buf := buf[4:100] + copy(t.Signature[:], buf) } - - // Field (1) 'Signature' - copy(s.Signature[:], buf[4:100]) - - // Field (0) 'Message' - { - buf = tail[o0:] - if s.Message == nil { - s.Message = new(BuilderBid) + { // Field #0 'Message' (dynamic) + buf := buf[offset0:] + if t.Message == nil { + t.Message = new(BuilderBid) } - if err = s.Message.UnmarshalSSZ(buf); err != nil { - return err + if err = t.Message.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "Message") } } - return err + return nil } -// 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) +// SizeSSZ returns the SSZ encoded size of the *SignedBuilderBid. +func (t *SignedBuilderBid) SizeSSZ() (size int) { + if t == nil { + t = new(SignedBuilderBid) } - size += s.Message.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the SignedBuilderBid object -func (s *SignedBuilderBid) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) + // Field #0 'Message' offset (4 bytes) + // Field #1 'Signature' static (96 bytes) + size += 100 + { // Dynamic field #0 'Message' + size += t.Message.SizeSSZ() + } + return size } -// 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 { +// HashTreeRoot computes the SSZ hash tree root of the *SignedBuilderBid. +func (t *SignedBuilderBid) HashTreeRoot() (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWith(hh) + if err == nil { + root, err = hh.HashRoot() + } 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) +// HashTreeRootWith computes the SSZ hash tree root of the *SignedBuilderBid using the given hash walker. +func (t *SignedBuilderBid) HashTreeRootWith(hh sszutils.HashWalker) error { + if t == nil { + t = new(SignedBuilderBid) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Message' + t := t.Message + if t == nil { + t = new(BuilderBid) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPath(err, "Message") + } + } + { // Field #1 'Signature' + hh.PutBytes(t.Signature[:96]) + } + hh.Merkleize(idx) + return nil } diff --git a/api/deneb/submitblockrequest_ssz.go b/api/deneb/submitblockrequest_ssz.go index bd0cc9a..eb600fc 100644 --- a/api/deneb/submitblockrequest_ssz.go +++ b/api/deneb/submitblockrequest_ssz.go @@ -1,176 +1,186 @@ -// Code generated by fastssz. DO NOT EDIT. -// Hash: ab124b93579f8996010b3c7fe144fdc154d151bbcb4848aa2eb177c45631019e -// Version: 0.1.3 +// Code generated by dynamic-ssz. DO NOT EDIT. +// Hash: 688f501471b84316305445c9ee5a2913119ef57b3318bc0980ad222dd377d43a +// Version: v1.2.2 (https://github.com/pk910/dynamic-ssz) package deneb import ( - apiv1 "github.com/attestantio/go-builder-client/api/v1" + "encoding/binary" + + "github.com/attestantio/go-builder-client/api/v1" "github.com/attestantio/go-eth2-client/spec/deneb" - ssz "github.com/ferranbt/fastssz" + dynssz "github.com/pk910/dynamic-ssz" + "github.com/pk910/dynamic-ssz/hasher" + "github.com/pk910/dynamic-ssz/sszutils" ) -// MarshalSSZ ssz marshals the SubmitBlockRequest object -func (s *SubmitBlockRequest) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) +var _ = sszutils.ErrListTooBig + +// MarshalSSZ marshals the *SubmitBlockRequest to SSZ-encoded bytes. +func (t *SubmitBlockRequest) MarshalSSZ() ([]byte, error) { + return dynssz.GetGlobalDynSsz().MarshalSSZ(t) } -// MarshalSSZTo ssz marshals the SubmitBlockRequest object to a target array -func (s *SubmitBlockRequest) MarshalSSZTo(buf []byte) (dst []byte, err error) { +// MarshalSSZTo marshals the *SubmitBlockRequest to SSZ-encoded bytes, appending to the provided buffer. +func (t *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(deneb.ExecutionPayload) - } - offset += s.ExecutionPayload.SizeSSZ() - - // Offset (2) 'BlobsBundle' - dst = ssz.WriteOffset(dst, offset) - if s.BlobsBundle == nil { - s.BlobsBundle = new(BlobsBundle) + if t == nil { + t = new(SubmitBlockRequest) + } + dstlen := len(dst) + { // Static Field #0 'Message' + t := t.Message + if t == nil { + t = new(v1.BidTrace) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "Message") + } } - 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 + // Offset Field #1 'ExecutionPayload' + // Offset Field #2 'BlobsBundle' + dst = append(dst, 0, 0, 0, 0, 0, 0, 0, 0) + { // Static Field #3 'Signature' + dst = append(dst, t.Signature[:96]...) + } + { // Dynamic Field #1 'ExecutionPayload' + binary.LittleEndian.PutUint32(dst[dstlen+236:], uint32(len(dst)-dstlen)) + t := t.ExecutionPayload + if t == nil { + t = new(deneb.ExecutionPayload) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "ExecutionPayload") + } } - - // Field (2) 'BlobsBundle' - if dst, err = s.BlobsBundle.MarshalSSZTo(dst); err != nil { - return + { // Dynamic Field #2 'BlobsBundle' + binary.LittleEndian.PutUint32(dst[dstlen+240:], uint32(len(dst)-dstlen)) + t := t.BlobsBundle + if t == nil { + t = new(BlobsBundle) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "BlobsBundle") + } } - - return + return dst, nil } -// 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 +// UnmarshalSSZ unmarshals the *SubmitBlockRequest from SSZ-encoded bytes. +func (t *SubmitBlockRequest) UnmarshalSSZ(buf []byte) (err error) { + buflen := len(buf) + if buflen < 340 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 340) } - - tail := buf - var o1, o2 uint64 - - // Field (0) 'Message' - if s.Message == nil { - s.Message = new(apiv1.BidTrace) + { // Field #0 'Message' (static) + buf := buf[0:236] + if t.Message == nil { + t.Message = new(v1.BidTrace) + } + if err = t.Message.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "Message") + } } - if err = s.Message.UnmarshalSSZ(buf[0:236]); err != nil { - return err + // Field #1 'ExecutionPayload' (offset) + offset1 := int(binary.LittleEndian.Uint32(buf[236:240])) + if offset1 != 340 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset1, 340), "ExecutionPayload:o") } - - // Offset (1) 'ExecutionPayload' - if o1 = ssz.ReadOffset(buf[236:240]); o1 > size { - return ssz.ErrOffset + // Field #2 'BlobsBundle' (offset) + offset2 := int(binary.LittleEndian.Uint32(buf[240:244])) + if offset2 < offset1 || offset2 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset2, offset1, buflen), "BlobsBundle:o") } - - 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' (static) + buf := buf[244:340] + copy(t.Signature[:], buf) } - - // Field (3) 'Signature' - copy(s.Signature[:], buf[244:340]) - - // Field (1) 'ExecutionPayload' - { - buf = tail[o1:o2] - if s.ExecutionPayload == nil { - s.ExecutionPayload = new(deneb.ExecutionPayload) + { // Field #1 'ExecutionPayload' (dynamic) + buf := buf[offset1:offset2] + if t.ExecutionPayload == nil { + t.ExecutionPayload = new(deneb.ExecutionPayload) } - if err = s.ExecutionPayload.UnmarshalSSZ(buf); err != nil { - return err + if err = t.ExecutionPayload.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "ExecutionPayload") } } - - // Field (2) 'BlobsBundle' - { - buf = tail[o2:] - if s.BlobsBundle == nil { - s.BlobsBundle = new(BlobsBundle) + { // Field #2 'BlobsBundle' (dynamic) + buf := buf[offset2:] + if t.BlobsBundle == nil { + t.BlobsBundle = new(BlobsBundle) } - if err = s.BlobsBundle.UnmarshalSSZ(buf); err != nil { - return err + if err = t.BlobsBundle.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "BlobsBundle") } } - return err + return nil } -// 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(deneb.ExecutionPayload) +// SizeSSZ returns the SSZ encoded size of the *SubmitBlockRequest. +func (t *SubmitBlockRequest) SizeSSZ() (size int) { + if t == nil { + t = new(SubmitBlockRequest) } - size += s.ExecutionPayload.SizeSSZ() - - // Field (2) 'BlobsBundle' - if s.BlobsBundle == nil { - s.BlobsBundle = new(BlobsBundle) + // Field #0 'Message' static (236 bytes) + // Field #1 'ExecutionPayload' offset (4 bytes) + // Field #2 'BlobsBundle' offset (4 bytes) + // Field #3 'Signature' static (96 bytes) + size += 340 + { // Dynamic field #1 'ExecutionPayload' + size += t.ExecutionPayload.SizeSSZ() } - size += s.BlobsBundle.SizeSSZ() - - return + { // Dynamic field #2 'BlobsBundle' + size += t.BlobsBundle.SizeSSZ() + } + return size } -// HashTreeRoot ssz hashes the SubmitBlockRequest object -func (s *SubmitBlockRequest) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) +// HashTreeRoot computes the SSZ hash tree root of the *SubmitBlockRequest. +func (t *SubmitBlockRequest) HashTreeRoot() (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWith(hh) + if err == nil { + root, err = hh.HashRoot() + } + return + }) + return } - -// 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) +// HashTreeRootWith computes the SSZ hash tree root of the *SubmitBlockRequest using the given hash walker. +func (t *SubmitBlockRequest) HashTreeRootWith(hh sszutils.HashWalker) error { + if t == nil { + t = new(SubmitBlockRequest) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Message' + t := t.Message + if t == nil { + t = new(v1.BidTrace) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPath(err, "Message") + } } - if err = s.Message.HashTreeRootWith(hh); err != nil { - return + { // Field #1 'ExecutionPayload' + t := t.ExecutionPayload + if t == nil { + t = new(deneb.ExecutionPayload) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPath(err, "ExecutionPayload") + } } - - // Field (1) 'ExecutionPayload' - if err = s.ExecutionPayload.HashTreeRootWith(hh); err != nil { - return + { // Field #2 'BlobsBundle' + t := t.BlobsBundle + if t == nil { + t = new(BlobsBundle) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPath(err, "BlobsBundle") + } } - - // Field (2) 'BlobsBundle' - if err = s.BlobsBundle.HashTreeRootWith(hh); err != nil { - return + { // Field #3 'Signature' + hh.PutBytes(t.Signature[:96]) } - - // 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) + hh.Merkleize(idx) + return nil } diff --git a/api/electra/builderbid_ssz.go b/api/electra/builderbid_ssz.go index 67578f0..9fb5aae 100644 --- a/api/electra/builderbid_ssz.go +++ b/api/electra/builderbid_ssz.go @@ -1,220 +1,248 @@ -// Code generated by fastssz. DO NOT EDIT. -// Hash: 1d68284d4973a1f64251c36b9648dd4da39cfde9d340a6a63f8a9f5b022fecb8 -// Version: 0.1.4 +// Code generated by dynamic-ssz. DO NOT EDIT. +// Hash: 01a6ea7264b38339a5403cc97ae4bdc3f543893e9fc42ce88edc8dde05ae7c71 +// Version: v1.2.2 (https://github.com/pk910/dynamic-ssz) package electra import ( + "encoding/binary" + "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" + dynssz "github.com/pk910/dynamic-ssz" + "github.com/pk910/dynamic-ssz/hasher" + "github.com/pk910/dynamic-ssz/sszutils" ) -// MarshalSSZ ssz marshals the BuilderBid object -func (b *BuilderBid) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) +var _ = sszutils.ErrListTooBig + +// MarshalSSZ marshals the *BuilderBid to SSZ-encoded bytes. +func (t *BuilderBid) MarshalSSZ() ([]byte, error) { + return dynssz.GetGlobalDynSsz().MarshalSSZ(t) } -// MarshalSSZTo ssz marshals the BuilderBid object to a target array -func (b *BuilderBid) MarshalSSZTo(buf []byte) (dst []byte, err error) { +// MarshalSSZTo marshals the *BuilderBid to SSZ-encoded bytes, appending to the provided buffer. +func (t *BuilderBid) MarshalSSZTo(buf []byte) (dst []byte, err error) { dst = buf - offset := int(92) - - // Offset (0) 'Header' - dst = ssz.WriteOffset(dst, offset) - if b.Header == nil { - b.Header = new(deneb.ExecutionPayloadHeader) + zeroBytes := sszutils.ZeroBytes() + if t == nil { + t = new(BuilderBid) + } + dstlen := len(dst) + // Offset Field #0 'Header' + // Offset Field #1 'BlobKZGCommitments' + // Offset Field #2 'ExecutionRequests' + dst = append(dst, zeroBytes[:12]...) + { // Static Field #3 'Value' + t := t.Value + if t == nil { + t = new(uint256.Int) + } + dst = sszutils.MarshalUint64Slice(dst, (*t)[:4]) } - offset += b.Header.SizeSSZ() - - // Offset (1) 'BlobKZGCommitments' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.BlobKZGCommitments) * 48 - - // Offset (2) 'ExecutionRequests' - dst = ssz.WriteOffset(dst, offset) - - // Field (3) 'Value' - value := b.Value.Bytes32() - for i := 0; i < 32; i++ { - dst = append(dst, value[31-i]) + { // Static Field #4 'Pubkey' + dst = append(dst, t.Pubkey[:48]...) } - - // Field (4) '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 + { // Dynamic Field #0 'Header' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.Header + if t == nil { + t = new(deneb.ExecutionPayloadHeader) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "Header") + } } - for ii := 0; ii < len(b.BlobKZGCommitments); ii++ { - dst = append(dst, b.BlobKZGCommitments[ii][:]...) + { // Dynamic Field #1 'BlobKZGCommitments' + binary.LittleEndian.PutUint32(dst[dstlen+4:], uint32(len(dst)-dstlen)) + t := t.BlobKZGCommitments + vlen := len(t) + if vlen > 4096 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 4096), "BlobKZGCommitments") + } + for idx1 := range vlen { + dst = append(dst, t[idx1][:48]...) + } } - - // Field (2) 'ExecutionRequests' - if dst, err = b.ExecutionRequests.MarshalSSZTo(dst); err != nil { - return + { // Dynamic Field #2 'ExecutionRequests' + binary.LittleEndian.PutUint32(dst[dstlen+8:], uint32(len(dst)-dstlen)) + t := t.ExecutionRequests + if t == nil { + t = new(electra.ExecutionRequests) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "ExecutionRequests") + } } - - return + return dst, nil } -// UnmarshalSSZ ssz unmarshals the BuilderBid object -func (b *BuilderBid) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 92 { - return ssz.ErrSize - } - - tail := buf - var o0, o1, o2 uint64 - - // Offset (0) 'Header' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } - - if o0 != 92 { - return ssz.ErrInvalidVariableOffset - } - - // Offset (1) 'BlobKZGCommitments' - if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 { - return ssz.ErrOffset - } - - // Offset (2) 'ExecutionRequests' - if o2 = ssz.ReadOffset(buf[8:12]); o2 > size || o1 > o2 { - return ssz.ErrOffset - } - - // Field (3) 'Value' - value := make([]byte, 32) - for i := 0; i < 32; i++ { - value[i] = buf[43-i] +// UnmarshalSSZ unmarshals the *BuilderBid from SSZ-encoded bytes. +func (t *BuilderBid) UnmarshalSSZ(buf []byte) (err error) { + buflen := len(buf) + if buflen < 92 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 92) + } + // Field #0 'Header' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 92 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset0, 92), "Header:o") + } + // Field #1 'BlobKZGCommitments' (offset) + offset1 := int(binary.LittleEndian.Uint32(buf[4:8])) + if offset1 < offset0 || offset1 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset1, offset0, buflen), "BlobKZGCommitments:o") + } + // Field #2 'ExecutionRequests' (offset) + offset2 := int(binary.LittleEndian.Uint32(buf[8:12])) + if offset2 < offset1 || offset2 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset2, offset1, buflen), "ExecutionRequests:o") + } + { // Field #3 'Value' (static) + buf := buf[12:44] + val1 := t.Value + if val1 == nil { + val1 = new(uint256.Int) + } + sszutils.UnmarshalUint64Slice((*val1)[:4], buf) + t.Value = val1 } - if b.Value == nil { - b.Value = new(uint256.Int) + { // Field #4 'Pubkey' (static) + buf := buf[44:92] + copy(t.Pubkey[:], buf) } - b.Value.SetBytes32(value) - - // Field (4) 'Pubkey' - copy(b.Pubkey[:], buf[44:92]) - - // Field (0) 'Header' - { - buf = tail[o0:o1] - if b.Header == nil { - b.Header = new(deneb.ExecutionPayloadHeader) + { // Field #0 'Header' (dynamic) + buf := buf[offset0:offset1] + if t.Header == nil { + t.Header = new(deneb.ExecutionPayloadHeader) } - if err = b.Header.UnmarshalSSZ(buf); err != nil { - return err + if err = t.Header.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "Header") } } - - // Field (1) 'BlobKZGCommitments' - { - buf = tail[o1:o2] - num, err := ssz.DivideInt2(len(buf), 48, 4096) - if err != nil { - return err + { // Field #1 'BlobKZGCommitments' (dynamic) + buf := buf[offset1:offset2] + val2 := t.BlobKZGCommitments + itemCount := len(buf) / 48 + if len(buf)%48 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 48), "BlobKZGCommitments") } - b.BlobKZGCommitments = make([]deneb.KZGCommitment, num) - for ii := 0; ii < num; ii++ { - copy(b.BlobKZGCommitments[ii][:], buf[ii*48:(ii+1)*48]) + val2 = sszutils.ExpandSlice(val2, itemCount) + for idx1 := range itemCount { + buf := buf[48*idx1 : 48*(idx1+1)] + copy(val2[idx1][:], buf) } + t.BlobKZGCommitments = val2 } - - // Field (2) 'ExecutionRequests' - { - buf = tail[o2:] - if b.ExecutionRequests == nil { - b.ExecutionRequests = new(electra.ExecutionRequests) + { // Field #2 'ExecutionRequests' (dynamic) + buf := buf[offset2:] + if t.ExecutionRequests == nil { + t.ExecutionRequests = new(electra.ExecutionRequests) } - if err = b.ExecutionRequests.UnmarshalSSZ(buf); err != nil { - return err + if err = t.ExecutionRequests.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "ExecutionRequests") } } - return err + return nil } -// SizeSSZ returns the ssz encoded size in bytes for the BuilderBid object -func (b *BuilderBid) SizeSSZ() (size int) { - size = 92 - - // Field (0) 'Header' - if b.Header == nil { - b.Header = new(deneb.ExecutionPayloadHeader) +// SizeSSZ returns the SSZ encoded size of the *BuilderBid. +func (t *BuilderBid) SizeSSZ() (size int) { + if t == nil { + t = new(BuilderBid) } - size += b.Header.SizeSSZ() - - // Field (1) 'BlobKZGCommitments' - size += len(b.BlobKZGCommitments) * 48 - - // Field (2) 'ExecutionRequests' - if b.ExecutionRequests == nil { - b.ExecutionRequests = new(electra.ExecutionRequests) + // Field #0 'Header' offset (4 bytes) + // Field #1 'BlobKZGCommitments' offset (4 bytes) + // Field #2 'ExecutionRequests' offset (4 bytes) + // Field #3 'Value' static (32 bytes) + // Field #4 'Pubkey' static (48 bytes) + size += 92 + { // Dynamic field #0 'Header' + size += t.Header.SizeSSZ() } - size += b.ExecutionRequests.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the BuilderBid object -func (b *BuilderBid) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) + { // Dynamic field #1 'BlobKZGCommitments' + size += len(t.BlobKZGCommitments) * 48 + } + { // Dynamic field #2 'ExecutionRequests' + size += t.ExecutionRequests.SizeSSZ() + } + return size } -// 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 { +// HashTreeRoot computes the SSZ hash tree root of the *BuilderBid. +func (t *BuilderBid) HashTreeRoot() (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWith(hh) + if err == nil { + root, err = hh.HashRoot() + } return + }) + return +} +// HashTreeRootWith computes the SSZ hash tree root of the *BuilderBid using the given hash walker. +func (t *BuilderBid) HashTreeRootWith(hh sszutils.HashWalker) error { + if t == nil { + t = new(BuilderBid) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Header' + t := t.Header + if t == nil { + t = new(deneb.ExecutionPayloadHeader) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPath(err, "Header") + } } - - // Field (1) 'BlobKZGCommitments' - { - if size := len(b.BlobKZGCommitments); size > 4096 { - err = ssz.ErrListTooBigFn("BuilderBid.BlobKZGCommitments", size, 4096) - return + { // Field #1 'BlobKZGCommitments' + t := t.BlobKZGCommitments + vlen := uint64(len(t)) + if vlen > 4096 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 4096), "BlobKZGCommitments") } - subIndx := hh.Index() - for _, i := range b.BlobKZGCommitments { - hh.PutBytes(i[:]) + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + hh.PutBytes(t[idx1][:48]) + if (idx1+1)%256 == 0 { + hh.Collapse() + } } - numItems := uint64(len(b.BlobKZGCommitments)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(4096, vlen, 32)) } - - // Field (2) 'ExecutionRequests' - if err = b.ExecutionRequests.HashTreeRootWith(hh); err != nil { - return + { // Field #2 'ExecutionRequests' + t := t.ExecutionRequests + if t == nil { + t = new(electra.ExecutionRequests) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPath(err, "ExecutionRequests") + } } - - // Field (3) '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] + { // Field #3 'Value' + t := t.Value + if t == nil { + t = new(uint256.Int) + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + var val1, val1Empty uint64 + for idx1 := range 4 { + if idx1 < 4 { + val1 = (*t)[idx1] + } else if idx1 == 4 { + val1 = val1Empty + } + hh.AppendUint64(val1) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.FillUpTo32() + hh.Merkleize(idx) } - hh.PutBytes(value[:]) - - // Field (4) '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) + { // Field #4 'Pubkey' + hh.PutBytes(t.Pubkey[:48]) + } + hh.Merkleize(idx) + return nil } diff --git a/api/electra/generate.go b/api/electra/generate.go index 6cc6ae4..c5cbca5 100644 --- a/api/electra/generate.go +++ b/api/electra/generate.go @@ -14,7 +14,6 @@ package electra //nolint:revive -// Need to `go install github.com/ferranbt/fastssz/sszgen@latest` for this to work. +// Need to `go install github.com/pk910/dynamic-ssz/dynssz-gen@latest` for this to work. //go:generate rm -f builderbid_ssz.go signedbuilderbid_ssz.go submitblockrequest_ssz.go -//go:generate sszgen --suffix ssz --include ../../../go-eth2-client/spec/electra,../../../go-eth2-client/spec/deneb,../../../go-eth2-client/spec/capella,../../../go-eth2-client/spec/bellatrix,../../../go-eth2-client/spec/phase0,../v1,../deneb --path . --objs BuilderBid,SignedBuilderBid,SubmitBlockRequest -//go:generate goimports -w builderbid_ssz.go signedbuilderbid_ssz.go submitblockrequest_ssz.go +//go:generate dynssz-gen -package . -legacy -without-dynamic-expressions -types BuilderBid:builderbid_ssz.go,SignedBuilderBid:signedbuilderbid_ssz.go,SubmitBlockRequest:submitblockrequest_ssz.go diff --git a/api/electra/signedbuilderbid_ssz.go b/api/electra/signedbuilderbid_ssz.go index 56c93f5..2767b27 100644 --- a/api/electra/signedbuilderbid_ssz.go +++ b/api/electra/signedbuilderbid_ssz.go @@ -1,107 +1,118 @@ -// Code generated by fastssz. DO NOT EDIT. -// Hash: 1d68284d4973a1f64251c36b9648dd4da39cfde9d340a6a63f8a9f5b022fecb8 -// Version: 0.1.4 +// Code generated by dynamic-ssz. DO NOT EDIT. +// Hash: c03d558eabf9edcf57d67b4b40a8c95c2389dd98278fe74a5146c9b94e824feb +// Version: v1.2.2 (https://github.com/pk910/dynamic-ssz) package electra import ( - ssz "github.com/ferranbt/fastssz" + "encoding/binary" + + dynssz "github.com/pk910/dynamic-ssz" + "github.com/pk910/dynamic-ssz/hasher" + "github.com/pk910/dynamic-ssz/sszutils" ) -// MarshalSSZ ssz marshals the SignedBuilderBid object -func (s *SignedBuilderBid) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) +var _ = sszutils.ErrListTooBig + +// MarshalSSZ marshals the *SignedBuilderBid to SSZ-encoded bytes. +func (t *SignedBuilderBid) MarshalSSZ() ([]byte, error) { + return dynssz.GetGlobalDynSsz().MarshalSSZ(t) } -// MarshalSSZTo ssz marshals the SignedBuilderBid object to a target array -func (s *SignedBuilderBid) MarshalSSZTo(buf []byte) (dst []byte, err error) { +// MarshalSSZTo marshals the *SignedBuilderBid to SSZ-encoded bytes, appending to the provided buffer. +func (t *SignedBuilderBid) MarshalSSZTo(buf []byte) (dst []byte, err error) { dst = buf - offset := int(100) - - // Offset (0) 'Message' - dst = ssz.WriteOffset(dst, offset) - - // Field (1) 'Signature' - dst = append(dst, s.Signature[:]...) - - // Field (0) 'Message' - if dst, err = s.Message.MarshalSSZTo(dst); err != nil { - return + if t == nil { + t = new(SignedBuilderBid) } - - return + dstlen := len(dst) + // Offset Field #0 'Message' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #1 'Signature' + dst = append(dst, t.Signature[:96]...) + } + { // Dynamic Field #0 'Message' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.Message + if t == nil { + t = new(BuilderBid) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "Message") + } + } + return dst, nil } -// 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 +// UnmarshalSSZ unmarshals the *SignedBuilderBid from SSZ-encoded bytes. +func (t *SignedBuilderBid) UnmarshalSSZ(buf []byte) (err error) { + buflen := len(buf) + if buflen < 100 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 100) } - - tail := buf - var o0 uint64 - - // Offset (0) 'Message' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset + // Field #0 'Message' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 100 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset0, 100), "Message:o") } - - if o0 != 100 { - return ssz.ErrInvalidVariableOffset + { // Field #1 'Signature' (static) + buf := buf[4:100] + copy(t.Signature[:], buf) } - - // Field (1) 'Signature' - copy(s.Signature[:], buf[4:100]) - - // Field (0) 'Message' - { - buf = tail[o0:] - if s.Message == nil { - s.Message = new(BuilderBid) + { // Field #0 'Message' (dynamic) + buf := buf[offset0:] + if t.Message == nil { + t.Message = new(BuilderBid) } - if err = s.Message.UnmarshalSSZ(buf); err != nil { - return err + if err = t.Message.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "Message") } } - return err + return nil } -// 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) +// SizeSSZ returns the SSZ encoded size of the *SignedBuilderBid. +func (t *SignedBuilderBid) SizeSSZ() (size int) { + if t == nil { + t = new(SignedBuilderBid) } - size += s.Message.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the SignedBuilderBid object -func (s *SignedBuilderBid) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) + // Field #0 'Message' offset (4 bytes) + // Field #1 'Signature' static (96 bytes) + size += 100 + { // Dynamic field #0 'Message' + size += t.Message.SizeSSZ() + } + return size } -// 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 { +// HashTreeRoot computes the SSZ hash tree root of the *SignedBuilderBid. +func (t *SignedBuilderBid) HashTreeRoot() (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWith(hh) + if err == nil { + root, err = hh.HashRoot() + } 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) +// HashTreeRootWith computes the SSZ hash tree root of the *SignedBuilderBid using the given hash walker. +func (t *SignedBuilderBid) HashTreeRootWith(hh sszutils.HashWalker) error { + if t == nil { + t = new(SignedBuilderBid) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Message' + t := t.Message + if t == nil { + t = new(BuilderBid) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPath(err, "Message") + } + } + { // Field #1 'Signature' + hh.PutBytes(t.Signature[:96]) + } + hh.Merkleize(idx) + return nil } diff --git a/api/electra/submitblockrequest_ssz.go b/api/electra/submitblockrequest_ssz.go index cb19d64..36819cd 100644 --- a/api/electra/submitblockrequest_ssz.go +++ b/api/electra/submitblockrequest_ssz.go @@ -1,213 +1,227 @@ -// Code generated by fastssz. DO NOT EDIT. -// Hash: 1d68284d4973a1f64251c36b9648dd4da39cfde9d340a6a63f8a9f5b022fecb8 -// Version: 0.1.4 +// Code generated by dynamic-ssz. DO NOT EDIT. +// Hash: 6ed76dd62257573a0314e578ed2202bbc4f09814e44e6bb0f1a81a7af5e6e254 +// Version: v1.2.2 (https://github.com/pk910/dynamic-ssz) package electra import ( - apideneb "github.com/attestantio/go-builder-client/api/deneb" - apiv1 "github.com/attestantio/go-builder-client/api/v1" + "encoding/binary" + + deneb1 "github.com/attestantio/go-builder-client/api/deneb" + "github.com/attestantio/go-builder-client/api/v1" "github.com/attestantio/go-eth2-client/spec/deneb" "github.com/attestantio/go-eth2-client/spec/electra" - ssz "github.com/ferranbt/fastssz" + dynssz "github.com/pk910/dynamic-ssz" + "github.com/pk910/dynamic-ssz/hasher" + "github.com/pk910/dynamic-ssz/sszutils" ) -// MarshalSSZ ssz marshals the SubmitBlockRequest object -func (s *SubmitBlockRequest) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) +var _ = sszutils.ErrListTooBig + +// MarshalSSZ marshals the *SubmitBlockRequest to SSZ-encoded bytes. +func (t *SubmitBlockRequest) MarshalSSZ() ([]byte, error) { + return dynssz.GetGlobalDynSsz().MarshalSSZ(t) } -// MarshalSSZTo ssz marshals the SubmitBlockRequest object to a target array -func (s *SubmitBlockRequest) MarshalSSZTo(buf []byte) (dst []byte, err error) { +// MarshalSSZTo marshals the *SubmitBlockRequest to SSZ-encoded bytes, appending to the provided buffer. +func (t *SubmitBlockRequest) MarshalSSZTo(buf []byte) (dst []byte, err error) { dst = buf - offset := int(344) - - // 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(deneb.ExecutionPayload) - } - offset += s.ExecutionPayload.SizeSSZ() - - // Offset (2) 'BlobsBundle' - dst = ssz.WriteOffset(dst, offset) - if s.BlobsBundle == nil { - s.BlobsBundle = new(apideneb.BlobsBundle) + zeroBytes := sszutils.ZeroBytes() + if t == nil { + t = new(SubmitBlockRequest) + } + dstlen := len(dst) + { // Static Field #0 'Message' + t := t.Message + if t == nil { + t = new(v1.BidTrace) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "Message") + } } - offset += s.BlobsBundle.SizeSSZ() - - // Offset (3) 'ExecutionRequests' - dst = ssz.WriteOffset(dst, offset) - - // Field (4) 'Signature' - dst = append(dst, s.Signature[:]...) - - // Field (1) 'ExecutionPayload' - if dst, err = s.ExecutionPayload.MarshalSSZTo(dst); err != nil { - return + // Offset Field #1 'ExecutionPayload' + // Offset Field #2 'BlobsBundle' + // Offset Field #3 'ExecutionRequests' + dst = append(dst, zeroBytes[:12]...) + { // Static Field #4 'Signature' + dst = append(dst, t.Signature[:96]...) + } + { // Dynamic Field #1 'ExecutionPayload' + binary.LittleEndian.PutUint32(dst[dstlen+236:], uint32(len(dst)-dstlen)) + t := t.ExecutionPayload + if t == nil { + t = new(deneb.ExecutionPayload) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "ExecutionPayload") + } } - - // Field (2) 'BlobsBundle' - if dst, err = s.BlobsBundle.MarshalSSZTo(dst); err != nil { - return + { // Dynamic Field #2 'BlobsBundle' + binary.LittleEndian.PutUint32(dst[dstlen+240:], uint32(len(dst)-dstlen)) + t := t.BlobsBundle + if t == nil { + t = new(deneb1.BlobsBundle) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "BlobsBundle") + } } - - // Field (3) 'ExecutionRequests' - if dst, err = s.ExecutionRequests.MarshalSSZTo(dst); err != nil { - return + { // Dynamic Field #3 'ExecutionRequests' + binary.LittleEndian.PutUint32(dst[dstlen+244:], uint32(len(dst)-dstlen)) + t := t.ExecutionRequests + if t == nil { + t = new(electra.ExecutionRequests) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "ExecutionRequests") + } } - - return + return dst, nil } -// UnmarshalSSZ ssz unmarshals the SubmitBlockRequest object -func (s *SubmitBlockRequest) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 344 { - return ssz.ErrSize +// UnmarshalSSZ unmarshals the *SubmitBlockRequest from SSZ-encoded bytes. +func (t *SubmitBlockRequest) UnmarshalSSZ(buf []byte) (err error) { + buflen := len(buf) + if buflen < 344 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 344) } - - tail := buf - var o1, o2, o3 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 != 344 { - return ssz.ErrInvalidVariableOffset - } - - // Offset (2) 'BlobsBundle' - if o2 = ssz.ReadOffset(buf[240:244]); o2 > size || o1 > o2 { - return ssz.ErrOffset - } - - // Offset (3) 'ExecutionRequests' - if o3 = ssz.ReadOffset(buf[244:248]); o3 > size || o2 > o3 { - return ssz.ErrOffset + { // Field #0 'Message' (static) + buf := buf[0:236] + if t.Message == nil { + t.Message = new(v1.BidTrace) + } + if err = t.Message.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "Message") + } } - - // Field (4) 'Signature' - copy(s.Signature[:], buf[248:344]) - - // Field (1) 'ExecutionPayload' - { - buf = tail[o1:o2] - if s.ExecutionPayload == nil { - s.ExecutionPayload = new(deneb.ExecutionPayload) + // Field #1 'ExecutionPayload' (offset) + offset1 := int(binary.LittleEndian.Uint32(buf[236:240])) + if offset1 != 344 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset1, 344), "ExecutionPayload:o") + } + // Field #2 'BlobsBundle' (offset) + offset2 := int(binary.LittleEndian.Uint32(buf[240:244])) + if offset2 < offset1 || offset2 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset2, offset1, buflen), "BlobsBundle:o") + } + // Field #3 'ExecutionRequests' (offset) + offset3 := int(binary.LittleEndian.Uint32(buf[244:248])) + if offset3 < offset2 || offset3 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset3, offset2, buflen), "ExecutionRequests:o") + } + { // Field #4 'Signature' (static) + buf := buf[248:344] + copy(t.Signature[:], buf) + } + { // Field #1 'ExecutionPayload' (dynamic) + buf := buf[offset1:offset2] + if t.ExecutionPayload == nil { + t.ExecutionPayload = new(deneb.ExecutionPayload) } - if err = s.ExecutionPayload.UnmarshalSSZ(buf); err != nil { - return err + if err = t.ExecutionPayload.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "ExecutionPayload") } } - - // Field (2) 'BlobsBundle' - { - buf = tail[o2:o3] - if s.BlobsBundle == nil { - s.BlobsBundle = new(apideneb.BlobsBundle) + { // Field #2 'BlobsBundle' (dynamic) + buf := buf[offset2:offset3] + if t.BlobsBundle == nil { + t.BlobsBundle = new(deneb1.BlobsBundle) } - if err = s.BlobsBundle.UnmarshalSSZ(buf); err != nil { - return err + if err = t.BlobsBundle.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "BlobsBundle") } } - - // Field (3) 'ExecutionRequests' - { - buf = tail[o3:] - if s.ExecutionRequests == nil { - s.ExecutionRequests = new(electra.ExecutionRequests) + { // Field #3 'ExecutionRequests' (dynamic) + buf := buf[offset3:] + if t.ExecutionRequests == nil { + t.ExecutionRequests = new(electra.ExecutionRequests) } - if err = s.ExecutionRequests.UnmarshalSSZ(buf); err != nil { - return err + if err = t.ExecutionRequests.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "ExecutionRequests") } } - return err + return nil } -// SizeSSZ returns the ssz encoded size in bytes for the SubmitBlockRequest object -func (s *SubmitBlockRequest) SizeSSZ() (size int) { - size = 344 - - // Field (1) 'ExecutionPayload' - if s.ExecutionPayload == nil { - s.ExecutionPayload = new(deneb.ExecutionPayload) +// SizeSSZ returns the SSZ encoded size of the *SubmitBlockRequest. +func (t *SubmitBlockRequest) SizeSSZ() (size int) { + if t == nil { + t = new(SubmitBlockRequest) } - size += s.ExecutionPayload.SizeSSZ() - - // Field (2) 'BlobsBundle' - if s.BlobsBundle == nil { - s.BlobsBundle = new(apideneb.BlobsBundle) + // Field #0 'Message' static (236 bytes) + // Field #1 'ExecutionPayload' offset (4 bytes) + // Field #2 'BlobsBundle' offset (4 bytes) + // Field #3 'ExecutionRequests' offset (4 bytes) + // Field #4 'Signature' static (96 bytes) + size += 344 + { // Dynamic field #1 'ExecutionPayload' + size += t.ExecutionPayload.SizeSSZ() } - size += s.BlobsBundle.SizeSSZ() - - // Field (3) 'ExecutionRequests' - if s.ExecutionRequests == nil { - s.ExecutionRequests = new(electra.ExecutionRequests) + { // Dynamic field #2 'BlobsBundle' + size += t.BlobsBundle.SizeSSZ() } - size += s.ExecutionRequests.SizeSSZ() - - return + { // Dynamic field #3 'ExecutionRequests' + size += t.ExecutionRequests.SizeSSZ() + } + return size } -// HashTreeRoot ssz hashes the SubmitBlockRequest object -func (s *SubmitBlockRequest) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) +// HashTreeRoot computes the SSZ hash tree root of the *SubmitBlockRequest. +func (t *SubmitBlockRequest) HashTreeRoot() (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWith(hh) + if err == nil { + root, err = hh.HashRoot() + } + return + }) + return } - -// 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) +// HashTreeRootWith computes the SSZ hash tree root of the *SubmitBlockRequest using the given hash walker. +func (t *SubmitBlockRequest) HashTreeRootWith(hh sszutils.HashWalker) error { + if t == nil { + t = new(SubmitBlockRequest) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Message' + t := t.Message + if t == nil { + t = new(v1.BidTrace) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPath(err, "Message") + } } - if err = s.Message.HashTreeRootWith(hh); err != nil { - return + { // Field #1 'ExecutionPayload' + t := t.ExecutionPayload + if t == nil { + t = new(deneb.ExecutionPayload) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPath(err, "ExecutionPayload") + } } - - // Field (1) 'ExecutionPayload' - if err = s.ExecutionPayload.HashTreeRootWith(hh); err != nil { - return + { // Field #2 'BlobsBundle' + t := t.BlobsBundle + if t == nil { + t = new(deneb1.BlobsBundle) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPath(err, "BlobsBundle") + } } - - // Field (2) 'BlobsBundle' - if err = s.BlobsBundle.HashTreeRootWith(hh); err != nil { - return + { // Field #3 'ExecutionRequests' + t := t.ExecutionRequests + if t == nil { + t = new(electra.ExecutionRequests) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPath(err, "ExecutionRequests") + } } - - // Field (3) 'ExecutionRequests' - if err = s.ExecutionRequests.HashTreeRootWith(hh); err != nil { - return + { // Field #4 'Signature' + hh.PutBytes(t.Signature[:96]) } - - // Field (4) '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) + hh.Merkleize(idx) + return nil } diff --git a/api/fulu/blobsbundle_ssz.go b/api/fulu/blobsbundle_ssz.go index bb73c8c..59485f0 100644 --- a/api/fulu/blobsbundle_ssz.go +++ b/api/fulu/blobsbundle_ssz.go @@ -1,207 +1,220 @@ -// Code generated by fastssz. DO NOT EDIT. -// Hash: b20fd3fa36a90f0d2dfc51a0390f2c30f66d1b12329c79ff0dea63ed2849f592 -// Version: 0.1.3 +// Code generated by dynamic-ssz. DO NOT EDIT. +// Hash: 166b904e30e499c02f1b5a1eb42ec1897833e1ca30b452791f1957fb33cb57c1 +// Version: v1.2.2 (https://github.com/pk910/dynamic-ssz) package fulu import ( - "github.com/attestantio/go-eth2-client/spec/deneb" - ssz "github.com/ferranbt/fastssz" + "encoding/binary" + + dynssz "github.com/pk910/dynamic-ssz" + "github.com/pk910/dynamic-ssz/hasher" + "github.com/pk910/dynamic-ssz/sszutils" ) -// MarshalSSZ ssz marshals the BlobsBundle object -func (b *BlobsBundle) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) +var _ = sszutils.ErrListTooBig + +// MarshalSSZ marshals the *BlobsBundle to SSZ-encoded bytes. +func (t *BlobsBundle) MarshalSSZ() ([]byte, error) { + return dynssz.GetGlobalDynSsz().MarshalSSZ(t) } -// MarshalSSZTo ssz marshals the BlobsBundle object to a target array -func (b *BlobsBundle) MarshalSSZTo(buf []byte) (dst []byte, err error) { +// MarshalSSZTo marshals the *BlobsBundle to SSZ-encoded bytes, appending to the provided buffer. +func (t *BlobsBundle) MarshalSSZTo(buf []byte) (dst []byte, err error) { dst = buf - offset := int(12) - - // Offset (0) 'Commitments' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.Commitments) * 48 - - // Offset (1) 'Proofs' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.Proofs) * 48 - - // Offset (2) 'Blobs' - dst = ssz.WriteOffset(dst, offset) - - // Field (0) 'Commitments' - if size := len(b.Commitments); size > 4096 { - err = ssz.ErrListTooBigFn("BlobsBundle.Commitments", size, 4096) - return - } - for ii := 0; ii < len(b.Commitments); ii++ { - dst = append(dst, b.Commitments[ii][:]...) - } - - // Field (1) 'Proofs' - if size := len(b.Proofs); size > 33554432 { - err = ssz.ErrListTooBigFn("BlobsBundle.Proofs", size, 33554432) - return - } - for ii := 0; ii < len(b.Proofs); ii++ { - dst = append(dst, b.Proofs[ii][:]...) + zeroBytes := sszutils.ZeroBytes() + if t == nil { + t = new(BlobsBundle) + } + dstlen := len(dst) + // Offset Field #0 'Commitments' + // Offset Field #1 'Proofs' + // Offset Field #2 'Blobs' + dst = append(dst, zeroBytes[:12]...) + { // Dynamic Field #0 'Commitments' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.Commitments + vlen := len(t) + if vlen > 4096 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 4096), "Commitments") + } + for idx1 := range vlen { + dst = append(dst, t[idx1][:48]...) + } } - - // Field (2) 'Blobs' - if size := len(b.Blobs); size > 4096 { - err = ssz.ErrListTooBigFn("BlobsBundle.Blobs", size, 4096) - return + { // Dynamic Field #1 'Proofs' + binary.LittleEndian.PutUint32(dst[dstlen+4:], uint32(len(dst)-dstlen)) + t := t.Proofs + vlen := len(t) + if vlen > 33554432 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 33554432), "Proofs") + } + for idx1 := range vlen { + dst = append(dst, t[idx1][:48]...) + } } - for ii := 0; ii < len(b.Blobs); ii++ { - dst = append(dst, b.Blobs[ii][:]...) + { // Dynamic Field #2 'Blobs' + binary.LittleEndian.PutUint32(dst[dstlen+8:], uint32(len(dst)-dstlen)) + t := t.Blobs + vlen := len(t) + if vlen > 4096 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 4096), "Blobs") + } + for idx1 := range vlen { + dst = append(dst, t[idx1][:131072]...) + } } - - return + return dst, nil } -// UnmarshalSSZ ssz unmarshals the BlobsBundle object -func (b *BlobsBundle) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 12 { - return ssz.ErrSize - } - - tail := buf - var o0, o1, o2 uint64 - - // Offset (0) 'Commitments' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } - - if o0 != 12 { - return ssz.ErrInvalidVariableOffset - } - - // Offset (1) 'Proofs' - if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 { - return ssz.ErrOffset - } - - // Offset (2) 'Blobs' - if o2 = ssz.ReadOffset(buf[8:12]); o2 > size || o1 > o2 { - return ssz.ErrOffset - } - - // Field (0) 'Commitments' - { - buf = tail[o0:o1] - num, err := ssz.DivideInt2(len(buf), 48, 4096) - if err != nil { - return err +// UnmarshalSSZ unmarshals the *BlobsBundle from SSZ-encoded bytes. +func (t *BlobsBundle) UnmarshalSSZ(buf []byte) (err error) { + buflen := len(buf) + if buflen < 12 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 12) + } + // Field #0 'Commitments' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 12 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset0, 12), "Commitments:o") + } + // Field #1 'Proofs' (offset) + offset1 := int(binary.LittleEndian.Uint32(buf[4:8])) + if offset1 < offset0 || offset1 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset1, offset0, buflen), "Proofs:o") + } + // Field #2 'Blobs' (offset) + offset2 := int(binary.LittleEndian.Uint32(buf[8:12])) + if offset2 < offset1 || offset2 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset2, offset1, buflen), "Blobs:o") + } + { // Field #0 'Commitments' (dynamic) + buf := buf[offset0:offset1] + val1 := t.Commitments + itemCount := len(buf) / 48 + if len(buf)%48 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 48), "Commitments") } - b.Commitments = make([]deneb.KZGCommitment, num) - for ii := 0; ii < num; ii++ { - copy(b.Commitments[ii][:], buf[ii*48:(ii+1)*48]) + val1 = sszutils.ExpandSlice(val1, itemCount) + for idx1 := range itemCount { + buf := buf[48*idx1 : 48*(idx1+1)] + copy(val1[idx1][:], buf) } - } - - // Field (1) 'Proofs' - { - buf = tail[o1:o2] - num, err := ssz.DivideInt2(len(buf), 48, 33554432) - if err != nil { - return err + t.Commitments = val1 + } + { // Field #1 'Proofs' (dynamic) + buf := buf[offset1:offset2] + val2 := t.Proofs + itemCount := len(buf) / 48 + if len(buf)%48 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 48), "Proofs") } - b.Proofs = make([]deneb.KZGProof, num) - for ii := 0; ii < num; ii++ { - copy(b.Proofs[ii][:], buf[ii*48:(ii+1)*48]) + val2 = sszutils.ExpandSlice(val2, itemCount) + for idx1 := range itemCount { + buf := buf[48*idx1 : 48*(idx1+1)] + copy(val2[idx1][:], buf) } - } - - // Field (2) 'Blobs' - { - buf = tail[o2:] - num, err := ssz.DivideInt2(len(buf), 131072, 4096) - if err != nil { - return err + t.Proofs = val2 + } + { // Field #2 'Blobs' (dynamic) + buf := buf[offset2:] + val3 := t.Blobs + itemCount := len(buf) / 131072 + if len(buf)%131072 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 131072), "Blobs") } - b.Blobs = make([]deneb.Blob, num) - for ii := 0; ii < num; ii++ { - copy(b.Blobs[ii][:], buf[ii*131072:(ii+1)*131072]) + val3 = sszutils.ExpandSlice(val3, itemCount) + for idx1 := range itemCount { + buf := buf[131072*idx1 : 131072*(idx1+1)] + copy(val3[idx1][:], buf) } + t.Blobs = val3 } - return err + return nil } -// SizeSSZ returns the ssz encoded size in bytes for the BlobsBundle object -func (b *BlobsBundle) SizeSSZ() (size int) { - size = 12 - - // Field (0) 'Commitments' - size += len(b.Commitments) * 48 - - // Field (1) 'Proofs' - size += len(b.Proofs) * 48 - - // Field (2) 'Blobs' - size += len(b.Blobs) * 131072 - - return +// SizeSSZ returns the SSZ encoded size of the *BlobsBundle. +func (t *BlobsBundle) SizeSSZ() (size int) { + if t == nil { + t = new(BlobsBundle) + } + // Field #0 'Commitments' offset (4 bytes) + // Field #1 'Proofs' offset (4 bytes) + // Field #2 'Blobs' offset (4 bytes) + size += 12 + { // Dynamic field #0 'Commitments' + size += len(t.Commitments) * 48 + } + { // Dynamic field #1 'Proofs' + size += len(t.Proofs) * 48 + } + { // Dynamic field #2 'Blobs' + size += len(t.Blobs) * 131072 + } + return size } -// HashTreeRoot ssz hashes the BlobsBundle object -func (b *BlobsBundle) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) +// HashTreeRoot computes the SSZ hash tree root of the *BlobsBundle. +func (t *BlobsBundle) HashTreeRoot() (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWith(hh) + if err == nil { + root, err = hh.HashRoot() + } + return + }) + return } - -// HashTreeRootWith ssz hashes the BlobsBundle object with a hasher -func (b *BlobsBundle) HashTreeRootWith(hh ssz.HashWalker) (err error) { - indx := hh.Index() - - // Field (0) 'Commitments' - { - if size := len(b.Commitments); size > 4096 { - err = ssz.ErrListTooBigFn("BlobsBundle.Commitments", size, 4096) - return +// HashTreeRootWith computes the SSZ hash tree root of the *BlobsBundle using the given hash walker. +func (t *BlobsBundle) HashTreeRootWith(hh sszutils.HashWalker) error { + if t == nil { + t = new(BlobsBundle) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Commitments' + t := t.Commitments + vlen := uint64(len(t)) + if vlen > 4096 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 4096), "Commitments") } - subIndx := hh.Index() - for _, i := range b.Commitments { - hh.PutBytes(i[:]) + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + hh.PutBytes(t[idx1][:48]) + if (idx1+1)%256 == 0 { + hh.Collapse() + } } - numItems := uint64(len(b.Commitments)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(4096, vlen, 32)) } - - // Field (1) 'Proofs' - { - if size := len(b.Proofs); size > 33554432 { - err = ssz.ErrListTooBigFn("BlobsBundle.Proofs", size, 33554432) - return + { // Field #1 'Proofs' + t := t.Proofs + vlen := uint64(len(t)) + if vlen > 33554432 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 33554432), "Proofs") } - subIndx := hh.Index() - for _, i := range b.Proofs { - hh.PutBytes(i[:]) + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + hh.PutBytes(t[idx1][:48]) + if (idx1+1)%256 == 0 { + hh.Collapse() + } } - numItems := uint64(len(b.Proofs)) - hh.MerkleizeWithMixin(subIndx, numItems, 33554432) + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(33554432, vlen, 32)) } - - // Field (2) 'Blobs' - { - if size := len(b.Blobs); size > 4096 { - err = ssz.ErrListTooBigFn("BlobsBundle.Blobs", size, 4096) - return + { // Field #2 'Blobs' + t := t.Blobs + vlen := uint64(len(t)) + if vlen > 4096 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 4096), "Blobs") } - subIndx := hh.Index() - for _, i := range b.Blobs { - hh.PutBytes(i[:]) + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + hh.PutBytes(t[idx1][:131072]) + if (idx1+1)%256 == 0 { + hh.Collapse() + } } - numItems := uint64(len(b.Blobs)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(4096, vlen, 32)) } - - hh.Merkleize(indx) - return -} - -// GetTree ssz hashes the BlobsBundle object -func (b *BlobsBundle) GetTree() (*ssz.Node, error) { - return ssz.ProofTree(b) + hh.Merkleize(idx) + return nil } diff --git a/api/fulu/executionpayloadandblobsbundle_ssz.go b/api/fulu/executionpayloadandblobsbundle_ssz.go index d92a104..521e276 100644 --- a/api/fulu/executionpayloadandblobsbundle_ssz.go +++ b/api/fulu/executionpayloadandblobsbundle_ssz.go @@ -1,138 +1,146 @@ -// Code generated by fastssz. DO NOT EDIT. -// Hash: b20fd3fa36a90f0d2dfc51a0390f2c30f66d1b12329c79ff0dea63ed2849f592 -// Version: 0.1.3 +// Code generated by dynamic-ssz. DO NOT EDIT. +// Hash: 661742718945ee054edb13acb343080395529c84ab844a5863f5bc135c61e144 +// Version: v1.2.2 (https://github.com/pk910/dynamic-ssz) package fulu import ( + "encoding/binary" + "github.com/attestantio/go-eth2-client/spec/deneb" - ssz "github.com/ferranbt/fastssz" + dynssz "github.com/pk910/dynamic-ssz" + "github.com/pk910/dynamic-ssz/hasher" + "github.com/pk910/dynamic-ssz/sszutils" ) -// MarshalSSZ ssz marshals the ExecutionPayloadAndBlobsBundle object -func (e *ExecutionPayloadAndBlobsBundle) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(e) +var _ = sszutils.ErrListTooBig + +// MarshalSSZ marshals the *ExecutionPayloadAndBlobsBundle to SSZ-encoded bytes. +func (t *ExecutionPayloadAndBlobsBundle) MarshalSSZ() ([]byte, error) { + return dynssz.GetGlobalDynSsz().MarshalSSZ(t) } -// MarshalSSZTo ssz marshals the ExecutionPayloadAndBlobsBundle object to a target array -func (e *ExecutionPayloadAndBlobsBundle) MarshalSSZTo(buf []byte) (dst []byte, err error) { +// MarshalSSZTo marshals the *ExecutionPayloadAndBlobsBundle to SSZ-encoded bytes, appending to the provided buffer. +func (t *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(deneb.ExecutionPayload) + if t == nil { + t = new(ExecutionPayloadAndBlobsBundle) } - offset += e.ExecutionPayload.SizeSSZ() - - // Offset (1) 'BlobsBundle' - dst = ssz.WriteOffset(dst, offset) - - // Field (0) 'ExecutionPayload' - if dst, err = e.ExecutionPayload.MarshalSSZTo(dst); err != nil { - return + dstlen := len(dst) + // Offset Field #0 'ExecutionPayload' + // Offset Field #1 'BlobsBundle' + dst = append(dst, 0, 0, 0, 0, 0, 0, 0, 0) + { // Dynamic Field #0 'ExecutionPayload' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.ExecutionPayload + if t == nil { + t = new(deneb.ExecutionPayload) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "ExecutionPayload") + } } - - // Field (1) 'BlobsBundle' - if dst, err = e.BlobsBundle.MarshalSSZTo(dst); err != nil { - return + { // Dynamic Field #1 'BlobsBundle' + binary.LittleEndian.PutUint32(dst[dstlen+4:], uint32(len(dst)-dstlen)) + t := t.BlobsBundle + if t == nil { + t = new(BlobsBundle) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "BlobsBundle") + } } - - return + return dst, nil } -// 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 +// UnmarshalSSZ unmarshals the *ExecutionPayloadAndBlobsBundle from SSZ-encoded bytes. +func (t *ExecutionPayloadAndBlobsBundle) UnmarshalSSZ(buf []byte) (err error) { + buflen := len(buf) + if buflen < 8 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 8) } - - tail := buf - var o0, o1 uint64 - - // Offset (0) 'ExecutionPayload' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset + // Field #0 'ExecutionPayload' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 8 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset0, 8), "ExecutionPayload:o") } - - if o0 != 8 { - return ssz.ErrInvalidVariableOffset + // Field #1 'BlobsBundle' (offset) + offset1 := int(binary.LittleEndian.Uint32(buf[4:8])) + if offset1 < offset0 || offset1 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset1, offset0, buflen), "BlobsBundle:o") } - - // 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(deneb.ExecutionPayload) + { // Field #0 'ExecutionPayload' (dynamic) + buf := buf[offset0:offset1] + if t.ExecutionPayload == nil { + t.ExecutionPayload = new(deneb.ExecutionPayload) } - if err = e.ExecutionPayload.UnmarshalSSZ(buf); err != nil { - return err + if err = t.ExecutionPayload.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "ExecutionPayload") } } - - // Field (1) 'BlobsBundle' - { - buf = tail[o1:] - if e.BlobsBundle == nil { - e.BlobsBundle = new(BlobsBundle) + { // Field #1 'BlobsBundle' (dynamic) + buf := buf[offset1:] + if t.BlobsBundle == nil { + t.BlobsBundle = new(BlobsBundle) } - if err = e.BlobsBundle.UnmarshalSSZ(buf); err != nil { - return err + if err = t.BlobsBundle.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "BlobsBundle") } } - return err + return nil } -// 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(deneb.ExecutionPayload) +// SizeSSZ returns the SSZ encoded size of the *ExecutionPayloadAndBlobsBundle. +func (t *ExecutionPayloadAndBlobsBundle) SizeSSZ() (size int) { + if t == nil { + t = new(ExecutionPayloadAndBlobsBundle) } - size += e.ExecutionPayload.SizeSSZ() - - // Field (1) 'BlobsBundle' - if e.BlobsBundle == nil { - e.BlobsBundle = new(BlobsBundle) + // Field #0 'ExecutionPayload' offset (4 bytes) + // Field #1 'BlobsBundle' offset (4 bytes) + size += 8 + { // Dynamic field #0 'ExecutionPayload' + size += t.ExecutionPayload.SizeSSZ() } - 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 + { // Dynamic field #1 'BlobsBundle' + size += t.BlobsBundle.SizeSSZ() } + return size +} - // Field (1) 'BlobsBundle' - if err = e.BlobsBundle.HashTreeRootWith(hh); err != nil { +// HashTreeRoot computes the SSZ hash tree root of the *ExecutionPayloadAndBlobsBundle. +func (t *ExecutionPayloadAndBlobsBundle) HashTreeRoot() (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWith(hh) + if err == nil { + root, err = hh.HashRoot() + } return - } - - hh.Merkleize(indx) + }) return } - -// GetTree ssz hashes the ExecutionPayloadAndBlobsBundle object -func (e *ExecutionPayloadAndBlobsBundle) GetTree() (*ssz.Node, error) { - return ssz.ProofTree(e) +// HashTreeRootWith computes the SSZ hash tree root of the *ExecutionPayloadAndBlobsBundle using the given hash walker. +func (t *ExecutionPayloadAndBlobsBundle) HashTreeRootWith(hh sszutils.HashWalker) error { + if t == nil { + t = new(ExecutionPayloadAndBlobsBundle) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'ExecutionPayload' + t := t.ExecutionPayload + if t == nil { + t = new(deneb.ExecutionPayload) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPath(err, "ExecutionPayload") + } + } + { // Field #1 'BlobsBundle' + t := t.BlobsBundle + if t == nil { + t = new(BlobsBundle) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPath(err, "BlobsBundle") + } + } + hh.Merkleize(idx) + return nil } diff --git a/api/fulu/generate.go b/api/fulu/generate.go index 0700273..7b85573 100644 --- a/api/fulu/generate.go +++ b/api/fulu/generate.go @@ -14,7 +14,6 @@ package fulu //nolint:revive -// Need to `go install github.com/ferranbt/fastssz/sszgen@latest` for this to work. +// Need to `go install github.com/pk910/dynamic-ssz/dynssz-gen@latest` for this to work. //go:generate rm -f blobsbundle_ssz.go executionpayloadandblobsbundle_ssz.go submitblockrequest_ssz.go -//go:generate sszgen --suffix ssz --include ../../../go-eth2-client/spec/electra,../../../go-eth2-client/spec/deneb,../../../go-eth2-client/spec/capella,../../../go-eth2-client/spec/bellatrix,../../../go-eth2-client/spec/phase0,../v1,../deneb --path . --objs BlobsBundle,ExecutionPayloadAndBlobsBundle,SubmitBlockRequest -//go:generate goimports -w blobsbundle_ssz.go executionpayloadandblobsbundle_ssz.go submitblockrequest_ssz.go +//go:generate dynssz-gen -package . -legacy -without-dynamic-expressions -types BlobsBundle:blobsbundle_ssz.go,ExecutionPayloadAndBlobsBundle:executionpayloadandblobsbundle_ssz.go,SubmitBlockRequest:submitblockrequest_ssz.go diff --git a/api/fulu/submitblockrequest_ssz.go b/api/fulu/submitblockrequest_ssz.go index 871a924..878b1cd 100644 --- a/api/fulu/submitblockrequest_ssz.go +++ b/api/fulu/submitblockrequest_ssz.go @@ -1,212 +1,226 @@ -// Code generated by fastssz. DO NOT EDIT. -// Hash: b20fd3fa36a90f0d2dfc51a0390f2c30f66d1b12329c79ff0dea63ed2849f592 -// Version: 0.1.3 +// Code generated by dynamic-ssz. DO NOT EDIT. +// Hash: 3439056b903f53c23c61114771c2733e467cda2cc8f81048e1d9b68798fef5a0 +// Version: v1.2.2 (https://github.com/pk910/dynamic-ssz) package fulu import ( - apiv1 "github.com/attestantio/go-builder-client/api/v1" + "encoding/binary" + + "github.com/attestantio/go-builder-client/api/v1" "github.com/attestantio/go-eth2-client/spec/deneb" "github.com/attestantio/go-eth2-client/spec/electra" - ssz "github.com/ferranbt/fastssz" + dynssz "github.com/pk910/dynamic-ssz" + "github.com/pk910/dynamic-ssz/hasher" + "github.com/pk910/dynamic-ssz/sszutils" ) -// MarshalSSZ ssz marshals the SubmitBlockRequest object -func (s *SubmitBlockRequest) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) +var _ = sszutils.ErrListTooBig + +// MarshalSSZ marshals the *SubmitBlockRequest to SSZ-encoded bytes. +func (t *SubmitBlockRequest) MarshalSSZ() ([]byte, error) { + return dynssz.GetGlobalDynSsz().MarshalSSZ(t) } -// MarshalSSZTo ssz marshals the SubmitBlockRequest object to a target array -func (s *SubmitBlockRequest) MarshalSSZTo(buf []byte) (dst []byte, err error) { +// MarshalSSZTo marshals the *SubmitBlockRequest to SSZ-encoded bytes, appending to the provided buffer. +func (t *SubmitBlockRequest) MarshalSSZTo(buf []byte) (dst []byte, err error) { dst = buf - offset := int(344) - - // 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(deneb.ExecutionPayload) - } - offset += s.ExecutionPayload.SizeSSZ() - - // Offset (2) 'BlobsBundle' - dst = ssz.WriteOffset(dst, offset) - if s.BlobsBundle == nil { - s.BlobsBundle = new(BlobsBundle) + zeroBytes := sszutils.ZeroBytes() + if t == nil { + t = new(SubmitBlockRequest) + } + dstlen := len(dst) + { // Static Field #0 'Message' + t := t.Message + if t == nil { + t = new(v1.BidTrace) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "Message") + } } - offset += s.BlobsBundle.SizeSSZ() - - // Offset (3) 'ExecutionRequests' - dst = ssz.WriteOffset(dst, offset) - - // Field (4) 'Signature' - dst = append(dst, s.Signature[:]...) - - // Field (1) 'ExecutionPayload' - if dst, err = s.ExecutionPayload.MarshalSSZTo(dst); err != nil { - return + // Offset Field #1 'ExecutionPayload' + // Offset Field #2 'BlobsBundle' + // Offset Field #3 'ExecutionRequests' + dst = append(dst, zeroBytes[:12]...) + { // Static Field #4 'Signature' + dst = append(dst, t.Signature[:96]...) + } + { // Dynamic Field #1 'ExecutionPayload' + binary.LittleEndian.PutUint32(dst[dstlen+236:], uint32(len(dst)-dstlen)) + t := t.ExecutionPayload + if t == nil { + t = new(deneb.ExecutionPayload) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "ExecutionPayload") + } } - - // Field (2) 'BlobsBundle' - if dst, err = s.BlobsBundle.MarshalSSZTo(dst); err != nil { - return + { // Dynamic Field #2 'BlobsBundle' + binary.LittleEndian.PutUint32(dst[dstlen+240:], uint32(len(dst)-dstlen)) + t := t.BlobsBundle + if t == nil { + t = new(BlobsBundle) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "BlobsBundle") + } } - - // Field (3) 'ExecutionRequests' - if dst, err = s.ExecutionRequests.MarshalSSZTo(dst); err != nil { - return + { // Dynamic Field #3 'ExecutionRequests' + binary.LittleEndian.PutUint32(dst[dstlen+244:], uint32(len(dst)-dstlen)) + t := t.ExecutionRequests + if t == nil { + t = new(electra.ExecutionRequests) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "ExecutionRequests") + } } - - return + return dst, nil } -// UnmarshalSSZ ssz unmarshals the SubmitBlockRequest object -func (s *SubmitBlockRequest) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 344 { - return ssz.ErrSize +// UnmarshalSSZ unmarshals the *SubmitBlockRequest from SSZ-encoded bytes. +func (t *SubmitBlockRequest) UnmarshalSSZ(buf []byte) (err error) { + buflen := len(buf) + if buflen < 344 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 344) } - - tail := buf - var o1, o2, o3 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 != 344 { - return ssz.ErrInvalidVariableOffset - } - - // Offset (2) 'BlobsBundle' - if o2 = ssz.ReadOffset(buf[240:244]); o2 > size || o1 > o2 { - return ssz.ErrOffset - } - - // Offset (3) 'ExecutionRequests' - if o3 = ssz.ReadOffset(buf[244:248]); o3 > size || o2 > o3 { - return ssz.ErrOffset + { // Field #0 'Message' (static) + buf := buf[0:236] + if t.Message == nil { + t.Message = new(v1.BidTrace) + } + if err = t.Message.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "Message") + } } - - // Field (4) 'Signature' - copy(s.Signature[:], buf[248:344]) - - // Field (1) 'ExecutionPayload' - { - buf = tail[o1:o2] - if s.ExecutionPayload == nil { - s.ExecutionPayload = new(deneb.ExecutionPayload) + // Field #1 'ExecutionPayload' (offset) + offset1 := int(binary.LittleEndian.Uint32(buf[236:240])) + if offset1 != 344 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset1, 344), "ExecutionPayload:o") + } + // Field #2 'BlobsBundle' (offset) + offset2 := int(binary.LittleEndian.Uint32(buf[240:244])) + if offset2 < offset1 || offset2 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset2, offset1, buflen), "BlobsBundle:o") + } + // Field #3 'ExecutionRequests' (offset) + offset3 := int(binary.LittleEndian.Uint32(buf[244:248])) + if offset3 < offset2 || offset3 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset3, offset2, buflen), "ExecutionRequests:o") + } + { // Field #4 'Signature' (static) + buf := buf[248:344] + copy(t.Signature[:], buf) + } + { // Field #1 'ExecutionPayload' (dynamic) + buf := buf[offset1:offset2] + if t.ExecutionPayload == nil { + t.ExecutionPayload = new(deneb.ExecutionPayload) } - if err = s.ExecutionPayload.UnmarshalSSZ(buf); err != nil { - return err + if err = t.ExecutionPayload.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "ExecutionPayload") } } - - // Field (2) 'BlobsBundle' - { - buf = tail[o2:o3] - if s.BlobsBundle == nil { - s.BlobsBundle = new(BlobsBundle) + { // Field #2 'BlobsBundle' (dynamic) + buf := buf[offset2:offset3] + if t.BlobsBundle == nil { + t.BlobsBundle = new(BlobsBundle) } - if err = s.BlobsBundle.UnmarshalSSZ(buf); err != nil { - return err + if err = t.BlobsBundle.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "BlobsBundle") } } - - // Field (3) 'ExecutionRequests' - { - buf = tail[o3:] - if s.ExecutionRequests == nil { - s.ExecutionRequests = new(electra.ExecutionRequests) + { // Field #3 'ExecutionRequests' (dynamic) + buf := buf[offset3:] + if t.ExecutionRequests == nil { + t.ExecutionRequests = new(electra.ExecutionRequests) } - if err = s.ExecutionRequests.UnmarshalSSZ(buf); err != nil { - return err + if err = t.ExecutionRequests.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "ExecutionRequests") } } - return err + return nil } -// SizeSSZ returns the ssz encoded size in bytes for the SubmitBlockRequest object -func (s *SubmitBlockRequest) SizeSSZ() (size int) { - size = 344 - - // Field (1) 'ExecutionPayload' - if s.ExecutionPayload == nil { - s.ExecutionPayload = new(deneb.ExecutionPayload) +// SizeSSZ returns the SSZ encoded size of the *SubmitBlockRequest. +func (t *SubmitBlockRequest) SizeSSZ() (size int) { + if t == nil { + t = new(SubmitBlockRequest) } - size += s.ExecutionPayload.SizeSSZ() - - // Field (2) 'BlobsBundle' - if s.BlobsBundle == nil { - s.BlobsBundle = new(BlobsBundle) + // Field #0 'Message' static (236 bytes) + // Field #1 'ExecutionPayload' offset (4 bytes) + // Field #2 'BlobsBundle' offset (4 bytes) + // Field #3 'ExecutionRequests' offset (4 bytes) + // Field #4 'Signature' static (96 bytes) + size += 344 + { // Dynamic field #1 'ExecutionPayload' + size += t.ExecutionPayload.SizeSSZ() } - size += s.BlobsBundle.SizeSSZ() - - // Field (3) 'ExecutionRequests' - if s.ExecutionRequests == nil { - s.ExecutionRequests = new(electra.ExecutionRequests) + { // Dynamic field #2 'BlobsBundle' + size += t.BlobsBundle.SizeSSZ() } - size += s.ExecutionRequests.SizeSSZ() - - return + { // Dynamic field #3 'ExecutionRequests' + size += t.ExecutionRequests.SizeSSZ() + } + return size } -// HashTreeRoot ssz hashes the SubmitBlockRequest object -func (s *SubmitBlockRequest) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) +// HashTreeRoot computes the SSZ hash tree root of the *SubmitBlockRequest. +func (t *SubmitBlockRequest) HashTreeRoot() (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWith(hh) + if err == nil { + root, err = hh.HashRoot() + } + return + }) + return } - -// 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) +// HashTreeRootWith computes the SSZ hash tree root of the *SubmitBlockRequest using the given hash walker. +func (t *SubmitBlockRequest) HashTreeRootWith(hh sszutils.HashWalker) error { + if t == nil { + t = new(SubmitBlockRequest) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Message' + t := t.Message + if t == nil { + t = new(v1.BidTrace) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPath(err, "Message") + } } - if err = s.Message.HashTreeRootWith(hh); err != nil { - return + { // Field #1 'ExecutionPayload' + t := t.ExecutionPayload + if t == nil { + t = new(deneb.ExecutionPayload) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPath(err, "ExecutionPayload") + } } - - // Field (1) 'ExecutionPayload' - if err = s.ExecutionPayload.HashTreeRootWith(hh); err != nil { - return + { // Field #2 'BlobsBundle' + t := t.BlobsBundle + if t == nil { + t = new(BlobsBundle) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPath(err, "BlobsBundle") + } } - - // Field (2) 'BlobsBundle' - if err = s.BlobsBundle.HashTreeRootWith(hh); err != nil { - return + { // Field #3 'ExecutionRequests' + t := t.ExecutionRequests + if t == nil { + t = new(electra.ExecutionRequests) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPath(err, "ExecutionRequests") + } } - - // Field (3) 'ExecutionRequests' - if err = s.ExecutionRequests.HashTreeRootWith(hh); err != nil { - return + { // Field #4 'Signature' + hh.PutBytes(t.Signature[:96]) } - - // Field (4) '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) + hh.Merkleize(idx) + return nil } diff --git a/go.mod b/go.mod index af3db3c..fa9fad0 100644 --- a/go.mod +++ b/go.mod @@ -20,8 +20,11 @@ require ( gotest.tools v2.2.0+incompatible ) +require github.com/pk910/dynamic-ssz v1.2.3-0.20260322192200-54c8e263d730 + require ( github.com/beorn7/perks v1.0.1 // indirect + github.com/casbin/govaluate v1.10.0 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/emicklei/dot v1.6.4 // indirect @@ -29,12 +32,13 @@ require ( github.com/go-logr/logr v1.4.2 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/google/go-cmp v0.6.0 // indirect - github.com/klauspost/cpuid/v2 v2.2.9 // indirect + github.com/klauspost/cpuid/v2 v2.3.0 // indirect github.com/mattn/go-colorable v0.1.14 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/minio/sha256-simd v1.0.1 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect + github.com/pk910/hashtree-bindings v0.1.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/prometheus/client_model v0.6.1 // indirect github.com/prometheus/common v0.55.0 // indirect diff --git a/go.sum b/go.sum index bac49f9..f9dfab6 100644 --- a/go.sum +++ b/go.sum @@ -2,6 +2,8 @@ github.com/attestantio/go-eth2-client v0.27.1 h1:g7bm+gG/p+gfzYdEuxuAepVWYb8EO+2 github.com/attestantio/go-eth2-client v0.27.1/go.mod h1:fvULSL9WtNskkOB4i+Yyr6BKpNHXvmpGZj9969fCrfY= 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/casbin/govaluate v1.10.0 h1:ffGw51/hYH3w3rZcxO/KcaUIDOLP84w7nsidMVgaDG0= +github.com/casbin/govaluate v1.10.0/go.mod h1:G/UnbIjZk/0uMNaLwZZmFQrR72tYRZWQkO70si/iR7A= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= @@ -44,8 +46,8 @@ github.com/huandu/go-clone/generic v1.6.0 h1:Wgmt/fUZ28r16F2Y3APotFD59sHk1p78K0X github.com/huandu/go-clone/generic v1.6.0/go.mod h1:xgd9ZebcMsBWWcBx5mVMCoqMX24gLWr5lQicr+nVXNs= github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA= github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= -github.com/klauspost/cpuid/v2 v2.2.9 h1:66ze0taIn2H33fBvCkXuv9BmCwDfafmiIVpKV9kKGuY= -github.com/klauspost/cpuid/v2 v2.2.9/go.mod h1:rqkxqrZ1EhYM9G+hXH7YdowN5R5RGN6NK4QwQ3WMXF8= +github.com/klauspost/cpuid/v2 v2.3.0 h1:S4CRMLnYUhGeDFDqkGriYKdfoFlDnMtqTiI/sFzhA9Y= +github.com/klauspost/cpuid/v2 v2.3.0/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -67,6 +69,10 @@ github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyua github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= +github.com/pk910/dynamic-ssz v1.2.3-0.20260322192200-54c8e263d730 h1:PBi7dDkT/n4eYWrPZjDtA2SwYXfP7L/B7cDnzqxqQm4= +github.com/pk910/dynamic-ssz v1.2.3-0.20260322192200-54c8e263d730/go.mod h1:NmeFF4jxzVwWC8cnEhUB7xMI++8hd/0OZvZHFrUvFfs= +github.com/pk910/hashtree-bindings v0.1.0 h1:w7NyRWFi2OaYEFvo9ADcE/QU6PMuVLl3hBgx92KiH9c= +github.com/pk910/hashtree-bindings v0.1.0/go.mod h1:zrWt88783JmhBfcgni6kkIMYRdXTZi/FL//OyI5T/l4= 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=