From 7d3752e146dd0bf6038bc479766d1beadb98b69a Mon Sep 17 00:00:00 2001 From: Fornax <23104993+0xfornax@users.noreply.github.com> Date: Thu, 9 Jul 2026 16:02:48 -0300 Subject: [PATCH] Replace fastssz with dynamic-ssz --- go.mod | 7 + go.sum | 6 + shared/services/beacon/client.go | 3 + .../services/beacon/client/std-http-client.go | 6 + shared/services/megapools.go | 14 +- shared/services/services.go | 2 +- shared/types/eth2/fork/deneb/block_deneb.go | 2 +- .../eth2/fork/deneb/block_deneb_encoding.go | 1204 --- .../types/eth2/fork/deneb/deneb_generated.go | 4682 ++++++++++++ shared/types/eth2/fork/deneb/state_deneb.go | 14 +- .../eth2/fork/deneb/state_deneb_encoding.go | 890 --- .../types/eth2/fork/electra/block_electra.go | 2 +- .../fork/electra/block_electra_encoding.go | 1850 ----- .../eth2/fork/electra/electra_generated.go | 6531 ++++++++++++++++ .../types/eth2/fork/electra/state_electra.go | 14 +- .../fork/electra/state_electra_encoding.go | 1115 --- shared/types/eth2/fork/fulu/block_fulu.go | 2 +- .../eth2/fork/fulu/block_fulu_encoding.go | 1850 ----- shared/types/eth2/fork/fulu/fulu_generated.go | 6591 ++++++++++++++++ shared/types/eth2/fork/fulu/state_fulu.go | 18 +- .../eth2/fork/fulu/state_fulu_encoding.go | 1143 --- shared/types/eth2/generic/block.go | 2 +- shared/types/eth2/generic/block_encoding.go | 1584 ---- shared/types/eth2/generic/dynssz.go | 13 + .../types/eth2/generic/generic_generated.go | 6790 +++++++++++++++++ shared/types/eth2/generic/state_encoding.go | 513 -- shared/types/eth2/generic/types_encoding.go | 1227 --- shared/types/eth2/proofs_test.go | 16 +- shared/types/eth2/streaming_test.go | 99 + shared/types/eth2/types.go | 44 +- shared/utils/validator/deposit-data.go | 6 +- .../utils/validator/set-withdrawal-creds.go | 4 +- shared/utils/validator/voluntary-exit.go | 4 +- sszgen.sh | 34 +- 34 files changed, 24830 insertions(+), 11452 deletions(-) delete mode 100644 shared/types/eth2/fork/deneb/block_deneb_encoding.go create mode 100644 shared/types/eth2/fork/deneb/deneb_generated.go delete mode 100644 shared/types/eth2/fork/deneb/state_deneb_encoding.go delete mode 100644 shared/types/eth2/fork/electra/block_electra_encoding.go create mode 100644 shared/types/eth2/fork/electra/electra_generated.go delete mode 100644 shared/types/eth2/fork/electra/state_electra_encoding.go delete mode 100644 shared/types/eth2/fork/fulu/block_fulu_encoding.go create mode 100644 shared/types/eth2/fork/fulu/fulu_generated.go delete mode 100644 shared/types/eth2/fork/fulu/state_fulu_encoding.go delete mode 100644 shared/types/eth2/generic/block_encoding.go create mode 100644 shared/types/eth2/generic/dynssz.go create mode 100644 shared/types/eth2/generic/generic_generated.go delete mode 100644 shared/types/eth2/generic/state_encoding.go delete mode 100644 shared/types/eth2/generic/types_encoding.go create mode 100644 shared/types/eth2/streaming_test.go diff --git a/go.mod b/go.mod index a079b7b8c..b8ddeb098 100644 --- a/go.mod +++ b/go.mod @@ -32,6 +32,7 @@ require ( github.com/klauspost/compress v1.17.9 github.com/mitchellh/go-homedir v1.1.0 github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 + github.com/pk910/dynamic-ssz v1.3.2 github.com/princjef/gomarkdoc v0.4.1 github.com/prometheus/client_golang v1.20.0 github.com/prysmaticlabs/go-bitfield v0.0.0-20240328144219-a1caa50c3a1e @@ -64,6 +65,7 @@ require ( github.com/bits-and-blooms/bitset v1.20.0 // indirect github.com/btcsuite/btcd/btcec/v2 v2.3.4 // indirect github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 // indirect + github.com/casbin/govaluate v1.10.0 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/cheggaaa/pb/v3 v3.0.8 // indirect github.com/cloudflare/circl v1.6.3 // indirect @@ -146,6 +148,7 @@ require ( github.com/opencontainers/image-spec v1.0.2 // indirect github.com/opentracing/opentracing-go v1.2.0 // indirect github.com/pjbgf/sha1cd v0.6.0 // indirect + github.com/pk910/hashtree-bindings v0.2.2 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/polydawn/refmt v0.89.1-0.20231129105047-37766d95467a // indirect github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect @@ -188,9 +191,11 @@ require ( go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.27.0 // indirect golang.org/x/crypto v0.51.0 // indirect + golang.org/x/mod v0.35.0 // indirect golang.org/x/net v0.55.0 // indirect golang.org/x/oauth2 v0.35.0 // indirect golang.org/x/sys v0.45.0 // indirect + golang.org/x/tools v0.44.0 // indirect golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect google.golang.org/grpc v1.80.0 // indirect @@ -202,3 +207,5 @@ require ( ) replace github.com/wealdtech/go-merkletree v1.0.1-0.20190605192610-2bb163c2ea2a => github.com/rocket-pool/go-merkletree v1.0.1-0.20220406020931-c262d9b976dd + +tool github.com/pk910/dynamic-ssz/dynssz-gen diff --git a/go.sum b/go.sum index e11169759..5f2f12644 100644 --- a/go.sum +++ b/go.sum @@ -113,6 +113,8 @@ github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku github.com/btcsuite/snappy-go v1.0.0/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY= github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= +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/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4= github.com/cenkalti/backoff/v5 v5.0.3 h1:ZN+IMa753KfX5hd8vVaMixjnqRZ3y8CuJKRKj1xcsSM= github.com/cenkalti/backoff/v5 v5.0.3/go.mod h1:rkhZdG3JZukswDf7f0cwqPNk4K0sa+F97BxZthm/crw= @@ -783,6 +785,10 @@ github.com/pion/webrtc/v3 v3.3.0 h1:Rf4u6n6U5t5sUxhYPQk/samzU/oDv7jk6BA5hyO2F9I= github.com/pion/webrtc/v3 v3.3.0/go.mod h1:hVmrDJvwhEertRWObeb1xzulzHGeVUoPlWvxdGzcfU0= github.com/pjbgf/sha1cd v0.6.0 h1:3WJ8Wz8gvDz29quX1OcEmkAlUg9diU4GxJHqs0/XiwU= github.com/pjbgf/sha1cd v0.6.0/go.mod h1:lhpGlyHLpQZoxMv8HcgXvZEhcGs0PG/vsZnEJ7H0iCM= +github.com/pk910/dynamic-ssz v1.3.2 h1:65UR/O+ss+U2Dn86Rdl7LwehHo3u2ElutduS/pcuUXE= +github.com/pk910/dynamic-ssz v1.3.2/go.mod h1:lqmnou2bjr2UWQ3C/L3082TGW0SFl/SwT7ionwM0+FU= +github.com/pk910/hashtree-bindings v0.2.2 h1:gkczxxekBW2NeMK9N3OLj7Jepe7zPmJGVwr8LyofGsA= +github.com/pk910/hashtree-bindings v0.2.2/go.mod h1:zrWt88783JmhBfcgni6kkIMYRdXTZi/FL//OyI5T/l4= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= diff --git a/shared/services/beacon/client.go b/shared/services/beacon/client.go index ba3a717f7..d5dae06f8 100644 --- a/shared/services/beacon/client.go +++ b/shared/services/beacon/client.go @@ -156,15 +156,18 @@ const ( // SSZ response go into these wrapper types. // You can stream Data into a deserializer. +// Size is the total SSZ payload size from Content-Length; <= 0 if unknown. // Fork is the consensus version, e.g, "deneb" or "electra" type BeaconStateSSZ struct { Data io.ReadCloser + Size int64 Fork string } type BeaconBlockSSZ struct { Data io.ReadCloser + Size int64 Fork string } diff --git a/shared/services/beacon/client/std-http-client.go b/shared/services/beacon/client/std-http-client.go index 5e909d56c..7380e9809 100644 --- a/shared/services/beacon/client/std-http-client.go +++ b/shared/services/beacon/client/std-http-client.go @@ -1028,6 +1028,7 @@ func (c *StandardHttpClient) GetBeaconStateSSZ(slot uint64) (*beacon.BeaconState return &beacon.BeaconStateSSZ{ Data: response.Body, + Size: response.ContentLength, Fork: response.Header.Get(ResponseConsensusVersionHeader), }, nil } @@ -1050,6 +1051,7 @@ func (c *StandardHttpClient) GetBeaconBlockSSZ(slot uint64) (*beacon.BeaconBlock return &beacon.BeaconBlockSSZ{ Data: response.Body, + Size: response.ContentLength, Fork: response.Header.Get(ResponseConsensusVersionHeader), }, true, nil } @@ -1213,6 +1215,10 @@ func (c *StandardHttpClient) sszRequest(requestPath string) (*http.Response, err return nil, err } request.Header.Set("Accept", RequestSSZContentType) + // Disable transparent compression: a compressed response has no + // Content-Length, which would force the buffered (non-streaming) SSZ + // decode path + request.Header.Set("Accept-Encoding", "identity") return http.DefaultClient.Do(request) } diff --git a/shared/services/megapools.go b/shared/services/megapools.go index 236a6f181..f982645ea 100644 --- a/shared/services/megapools.go +++ b/shared/services/megapools.go @@ -14,7 +14,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" - ssz "github.com/ferranbt/fastssz" + "github.com/pk910/dynamic-ssz/treeproof" "github.com/urfave/cli/v3" "golang.org/x/sync/errgroup" @@ -165,7 +165,7 @@ func GetWithdrawableEpochProof(c *cli.Command, wallet *wallet.Wallet, eth2Config return api.ValidatorWithdrawableEpochProof{}, err } - beaconState, err := eth2.NewBeaconState(beaconStateResponse.Data, beaconStateResponse.Fork) + beaconState, err := eth2.NewBeaconState(beaconStateResponse.Data, beaconStateResponse.Size, beaconStateResponse.Fork) if err != nil { return api.ValidatorWithdrawableEpochProof{}, err } @@ -722,7 +722,7 @@ func GetWithdrawalProofForSlot(c *cli.Command, slot uint64, validatorIndex uint6 return megapool.FinalBalanceProof{}, 0, nil, err } - beaconState, err := eth2.NewBeaconState(stateResponse.Data, stateResponse.Fork) + beaconState, err := eth2.NewBeaconState(stateResponse.Data, stateResponse.Size, stateResponse.Fork) if err != nil { return megapool.FinalBalanceProof{}, 0, nil, err } @@ -768,7 +768,7 @@ func GetWithdrawalProofForSlot(c *cli.Command, slot uint64, validatorIndex uint6 if err != nil { return megapool.FinalBalanceProof{}, 0, nil, err } - blockRootsState, err := eth2.NewBeaconState(blockRootsStateResponse.Data, blockRootsStateResponse.Fork) + blockRootsState, err := eth2.NewBeaconState(blockRootsStateResponse.Data, blockRootsStateResponse.Size, blockRootsStateResponse.Fork) if err != nil { return megapool.FinalBalanceProof{}, 0, nil, err } @@ -778,8 +778,8 @@ func GetWithdrawalProofForSlot(c *cli.Command, slot uint64, validatorIndex uint6 } // Get historical summary proof - var tree *ssz.Node - tree, err = fuluState.GetTree() + var tree *treeproof.Node + tree, err = generic.SSZ.GetTree(fuluState) if err != nil { return megapool.FinalBalanceProof{}, 0, nil, fmt.Errorf("could not get state tree: %w", err) } @@ -863,7 +863,7 @@ func FindWithdrawalBlockAndArrayPosition(slot uint64, validatorIndex uint64, bc } notFounds = 0 - beaconBlock, err := eth2.NewSignedBeaconBlock(blockResponse.Data, blockResponse.Fork) + beaconBlock, err := eth2.NewSignedBeaconBlock(blockResponse.Data, blockResponse.Size, blockResponse.Fork) if err != nil { return 0, nil, 0, nil, nil, err } diff --git a/shared/services/services.go b/shared/services/services.go index a64111dda..821d3687e 100644 --- a/shared/services/services.go +++ b/shared/services/services.go @@ -231,7 +231,7 @@ func GetBeaconState(bc beacon.Client) (eth2.BeaconState, error) { return nil, err } - beaconState, err := eth2.NewBeaconState(beaconStateResponse.Data, beaconStateResponse.Fork) + beaconState, err := eth2.NewBeaconState(beaconStateResponse.Data, beaconStateResponse.Size, beaconStateResponse.Fork) if err != nil { return nil, err } diff --git a/shared/types/eth2/fork/deneb/block_deneb.go b/shared/types/eth2/fork/deneb/block_deneb.go index 8608d0083..30cd94ee2 100644 --- a/shared/types/eth2/fork/deneb/block_deneb.go +++ b/shared/types/eth2/fork/deneb/block_deneb.go @@ -6,7 +6,7 @@ import "github.com/rocket-pool/smartnode/shared/types/eth2/generic" const BeaconBlockBodyChunksCeil uint64 = 16 func (b *SignedBeaconBlock) ProveWithdrawal(indexInWithdrawalsArray uint64) ([][]byte, error) { - tree, err := b.Block.GetTree() + tree, err := generic.SSZ.GetTree(b.Block) if err != nil { return nil, err } diff --git a/shared/types/eth2/fork/deneb/block_deneb_encoding.go b/shared/types/eth2/fork/deneb/block_deneb_encoding.go deleted file mode 100644 index 5c96558a7..000000000 --- a/shared/types/eth2/fork/deneb/block_deneb_encoding.go +++ /dev/null @@ -1,1204 +0,0 @@ -// Code generated by fastssz. DO NOT EDIT. -// Hash: c9745bfaa4c4ede7bef37acadc6c3463b1539b8c630e214b93e64de4949dc988 -// Version: 0.1.3 -package deneb - -import ( - ssz "github.com/ferranbt/fastssz" - - "github.com/rocket-pool/smartnode/shared/types/eth2/generic" -) - -// MarshalSSZ ssz marshals the BeaconBlock object -func (b *BeaconBlock) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} - -// MarshalSSZTo ssz marshals the BeaconBlock object to a target array -func (b *BeaconBlock) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(84) - - // Field (0) 'Slot' - dst = ssz.MarshalUint64(dst, b.Slot) - - // Field (1) 'ProposerIndex' - dst = ssz.MarshalUint64(dst, b.ProposerIndex) - - // Field (2) 'ParentRoot' - dst = append(dst, b.ParentRoot[:]...) - - // Field (3) 'StateRoot' - dst = append(dst, b.StateRoot[:]...) - - // Offset (4) 'Body' - dst = ssz.WriteOffset(dst, offset) - - // Field (4) 'Body' - if dst, err = b.Body.MarshalSSZTo(dst); err != nil { - return - } - - return -} - -// UnmarshalSSZ ssz unmarshals the BeaconBlock object -func (b *BeaconBlock) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 84 { - return ssz.ErrSize - } - - tail := buf - var o4 uint64 - - // Field (0) 'Slot' - b.Slot = ssz.UnmarshallUint64(buf[0:8]) - - // Field (1) 'ProposerIndex' - b.ProposerIndex = ssz.UnmarshallUint64(buf[8:16]) - - // Field (2) 'ParentRoot' - copy(b.ParentRoot[:], buf[16:48]) - - // Field (3) 'StateRoot' - copy(b.StateRoot[:], buf[48:80]) - - // Offset (4) 'Body' - if o4 = ssz.ReadOffset(buf[80:84]); o4 > size { - return ssz.ErrOffset - } - - if o4 != 84 { - return ssz.ErrInvalidVariableOffset - } - - // Field (4) 'Body' - { - buf = tail[o4:] - if b.Body == nil { - b.Body = new(BeaconBlockBody) - } - if err = b.Body.UnmarshalSSZ(buf); err != nil { - return err - } - } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the BeaconBlock object -func (b *BeaconBlock) SizeSSZ() (size int) { - size = 84 - - // Field (4) 'Body' - if b.Body == nil { - b.Body = new(BeaconBlockBody) - } - size += b.Body.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the BeaconBlock object -func (b *BeaconBlock) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) -} - -// HashTreeRootWith ssz hashes the BeaconBlock object with a hasher -func (b *BeaconBlock) HashTreeRootWith(hh ssz.HashWalker) (err error) { - indx := hh.Index() - - // Field (0) 'Slot' - hh.PutUint64(b.Slot) - - // Field (1) 'ProposerIndex' - hh.PutUint64(b.ProposerIndex) - - // Field (2) 'ParentRoot' - hh.PutBytes(b.ParentRoot[:]) - - // Field (3) 'StateRoot' - hh.PutBytes(b.StateRoot[:]) - - // Field (4) 'Body' - if err = b.Body.HashTreeRootWith(hh); err != nil { - return - } - - hh.Merkleize(indx) - return -} - -// GetTree ssz hashes the BeaconBlock object -func (b *BeaconBlock) GetTree() (*ssz.Node, error) { - return ssz.ProofTree(b) -} - -// MarshalSSZ ssz marshals the SignedBeaconBlock object -func (s *SignedBeaconBlock) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) -} - -// MarshalSSZTo ssz marshals the SignedBeaconBlock object to a target array -func (s *SignedBeaconBlock) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(100) - - // Offset (0) 'Block' - dst = ssz.WriteOffset(dst, offset) - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("SignedBeaconBlock.Signature", size, 96) - return - } - dst = append(dst, s.Signature...) - - // Field (0) 'Block' - if dst, err = s.Block.MarshalSSZTo(dst); err != nil { - return - } - - return -} - -// UnmarshalSSZ ssz unmarshals the SignedBeaconBlock object -func (s *SignedBeaconBlock) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 100 { - return ssz.ErrSize - } - - tail := buf - var o0 uint64 - - // Offset (0) 'Block' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } - - if o0 != 100 { - return ssz.ErrInvalidVariableOffset - } - - // Field (1) 'Signature' - if cap(s.Signature) == 0 { - s.Signature = make([]byte, 0, len(buf[4:100])) - } - s.Signature = append(s.Signature, buf[4:100]...) - - // Field (0) 'Block' - { - buf = tail[o0:] - if s.Block == nil { - s.Block = new(BeaconBlock) - } - if err = s.Block.UnmarshalSSZ(buf); err != nil { - return err - } - } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the SignedBeaconBlock object -func (s *SignedBeaconBlock) SizeSSZ() (size int) { - size = 100 - - // Field (0) 'Block' - if s.Block == nil { - s.Block = new(BeaconBlock) - } - size += s.Block.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the SignedBeaconBlock object -func (s *SignedBeaconBlock) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) -} - -// HashTreeRootWith ssz hashes the SignedBeaconBlock object with a hasher -func (s *SignedBeaconBlock) HashTreeRootWith(hh ssz.HashWalker) (err error) { - indx := hh.Index() - - // Field (0) 'Block' - if err = s.Block.HashTreeRootWith(hh); err != nil { - return - } - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("SignedBeaconBlock.Signature", size, 96) - return - } - hh.PutBytes(s.Signature) - - hh.Merkleize(indx) - return -} - -// GetTree ssz hashes the SignedBeaconBlock object -func (s *SignedBeaconBlock) GetTree() (*ssz.Node, error) { - return ssz.ProofTree(s) -} - -// MarshalSSZ ssz marshals the BeaconBlockBody object -func (b *BeaconBlockBody) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} - -// MarshalSSZTo ssz marshals the BeaconBlockBody object to a target array -func (b *BeaconBlockBody) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(392) - - // Field (0) 'RandaoReveal' - if size := len(b.RandaoReveal); size != 96 { - err = ssz.ErrBytesLengthFn("BeaconBlockBody.RandaoReveal", size, 96) - return - } - dst = append(dst, b.RandaoReveal...) - - // Field (1) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(generic.Eth1Data) - } - if dst, err = b.Eth1Data.MarshalSSZTo(dst); err != nil { - return - } - - // Field (2) 'Graffiti' - dst = append(dst, b.Graffiti[:]...) - - // Offset (3) 'ProposerSlashings' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.ProposerSlashings) * 416 - - // Offset (4) 'AttesterSlashings' - dst = ssz.WriteOffset(dst, offset) - for ii := 0; ii < len(b.AttesterSlashings); ii++ { - offset += 4 - offset += b.AttesterSlashings[ii].SizeSSZ() - } - - // Offset (5) 'Attestations' - dst = ssz.WriteOffset(dst, offset) - for ii := 0; ii < len(b.Attestations); ii++ { - offset += 4 - offset += b.Attestations[ii].SizeSSZ() - } - - // Offset (6) 'Deposits' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.Deposits) * 1240 - - // Offset (7) 'VoluntaryExits' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.VoluntaryExits) * 112 - - // Field (8) 'SyncAggregate' - if b.SyncAggregate == nil { - b.SyncAggregate = new(generic.SyncAggregate) - } - if dst, err = b.SyncAggregate.MarshalSSZTo(dst); err != nil { - return - } - - // Offset (9) 'ExecutionPayload' - dst = ssz.WriteOffset(dst, offset) - if b.ExecutionPayload == nil { - b.ExecutionPayload = new(ExecutionPayload) - } - offset += b.ExecutionPayload.SizeSSZ() - - // Offset (10) 'BlsToExecutionChanges' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.BlsToExecutionChanges) * 172 - - // Offset (11) 'BlobKzgCommitments' - dst = ssz.WriteOffset(dst, offset) - - // Field (3) 'ProposerSlashings' - if size := len(b.ProposerSlashings); size > 16 { - err = ssz.ErrListTooBigFn("BeaconBlockBody.ProposerSlashings", size, 16) - return - } - for ii := 0; ii < len(b.ProposerSlashings); ii++ { - if dst, err = b.ProposerSlashings[ii].MarshalSSZTo(dst); err != nil { - return - } - } - - // Field (4) 'AttesterSlashings' - if size := len(b.AttesterSlashings); size > 2 { - err = ssz.ErrListTooBigFn("BeaconBlockBody.AttesterSlashings", size, 2) - return - } - { - offset = 4 * len(b.AttesterSlashings) - for ii := 0; ii < len(b.AttesterSlashings); ii++ { - dst = ssz.WriteOffset(dst, offset) - offset += b.AttesterSlashings[ii].SizeSSZ() - } - } - for ii := 0; ii < len(b.AttesterSlashings); ii++ { - if dst, err = b.AttesterSlashings[ii].MarshalSSZTo(dst); err != nil { - return - } - } - - // Field (5) 'Attestations' - if size := len(b.Attestations); size > 128 { - err = ssz.ErrListTooBigFn("BeaconBlockBody.Attestations", size, 128) - return - } - { - offset = 4 * len(b.Attestations) - for ii := 0; ii < len(b.Attestations); ii++ { - dst = ssz.WriteOffset(dst, offset) - offset += b.Attestations[ii].SizeSSZ() - } - } - for ii := 0; ii < len(b.Attestations); ii++ { - if dst, err = b.Attestations[ii].MarshalSSZTo(dst); err != nil { - return - } - } - - // Field (6) 'Deposits' - if size := len(b.Deposits); size > 16 { - err = ssz.ErrListTooBigFn("BeaconBlockBody.Deposits", size, 16) - return - } - for ii := 0; ii < len(b.Deposits); ii++ { - if dst, err = b.Deposits[ii].MarshalSSZTo(dst); err != nil { - return - } - } - - // Field (7) 'VoluntaryExits' - if size := len(b.VoluntaryExits); size > 16 { - err = ssz.ErrListTooBigFn("BeaconBlockBody.VoluntaryExits", size, 16) - return - } - for ii := 0; ii < len(b.VoluntaryExits); ii++ { - if dst, err = b.VoluntaryExits[ii].MarshalSSZTo(dst); err != nil { - return - } - } - - // Field (9) 'ExecutionPayload' - if dst, err = b.ExecutionPayload.MarshalSSZTo(dst); err != nil { - return - } - - // Field (10) 'BlsToExecutionChanges' - if size := len(b.BlsToExecutionChanges); size > 16 { - err = ssz.ErrListTooBigFn("BeaconBlockBody.BlsToExecutionChanges", size, 16) - return - } - for ii := 0; ii < len(b.BlsToExecutionChanges); ii++ { - if dst, err = b.BlsToExecutionChanges[ii].MarshalSSZTo(dst); err != nil { - return - } - } - - // Field (11) 'BlobKzgCommitments' - if size := len(b.BlobKzgCommitments); size > 4096 { - err = ssz.ErrListTooBigFn("BeaconBlockBody.BlobKzgCommitments", size, 4096) - return - } - for ii := 0; ii < len(b.BlobKzgCommitments); ii++ { - dst = append(dst, b.BlobKzgCommitments[ii][:]...) - } - - return -} - -// UnmarshalSSZ ssz unmarshals the BeaconBlockBody object -func (b *BeaconBlockBody) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 392 { - return ssz.ErrSize - } - - tail := buf - var o3, o4, o5, o6, o7, o9, o10, o11 uint64 - - // Field (0) 'RandaoReveal' - if cap(b.RandaoReveal) == 0 { - b.RandaoReveal = make([]byte, 0, len(buf[0:96])) - } - b.RandaoReveal = append(b.RandaoReveal, buf[0:96]...) - - // Field (1) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(generic.Eth1Data) - } - if err = b.Eth1Data.UnmarshalSSZ(buf[96:168]); err != nil { - return err - } - - // Field (2) 'Graffiti' - copy(b.Graffiti[:], buf[168:200]) - - // Offset (3) 'ProposerSlashings' - if o3 = ssz.ReadOffset(buf[200:204]); o3 > size { - return ssz.ErrOffset - } - - if o3 != 392 { - return ssz.ErrInvalidVariableOffset - } - - // Offset (4) 'AttesterSlashings' - if o4 = ssz.ReadOffset(buf[204:208]); o4 > size || o3 > o4 { - return ssz.ErrOffset - } - - // Offset (5) 'Attestations' - if o5 = ssz.ReadOffset(buf[208:212]); o5 > size || o4 > o5 { - return ssz.ErrOffset - } - - // Offset (6) 'Deposits' - if o6 = ssz.ReadOffset(buf[212:216]); o6 > size || o5 > o6 { - return ssz.ErrOffset - } - - // Offset (7) 'VoluntaryExits' - if o7 = ssz.ReadOffset(buf[216:220]); o7 > size || o6 > o7 { - return ssz.ErrOffset - } - - // Field (8) 'SyncAggregate' - if b.SyncAggregate == nil { - b.SyncAggregate = new(generic.SyncAggregate) - } - if err = b.SyncAggregate.UnmarshalSSZ(buf[220:380]); err != nil { - return err - } - - // Offset (9) 'ExecutionPayload' - if o9 = ssz.ReadOffset(buf[380:384]); o9 > size || o7 > o9 { - return ssz.ErrOffset - } - - // Offset (10) 'BlsToExecutionChanges' - if o10 = ssz.ReadOffset(buf[384:388]); o10 > size || o9 > o10 { - return ssz.ErrOffset - } - - // Offset (11) 'BlobKzgCommitments' - if o11 = ssz.ReadOffset(buf[388:392]); o11 > size || o10 > o11 { - return ssz.ErrOffset - } - - // Field (3) 'ProposerSlashings' - { - buf = tail[o3:o4] - num, err := ssz.DivideInt2(len(buf), 416, 16) - if err != nil { - return err - } - b.ProposerSlashings = make([]*generic.ProposerSlashing, num) - for ii := 0; ii < num; ii++ { - if b.ProposerSlashings[ii] == nil { - b.ProposerSlashings[ii] = new(generic.ProposerSlashing) - } - if err = b.ProposerSlashings[ii].UnmarshalSSZ(buf[ii*416 : (ii+1)*416]); err != nil { - return err - } - } - } - - // Field (4) 'AttesterSlashings' - { - buf = tail[o4:o5] - num, err := ssz.DecodeDynamicLength(buf, 2) - if err != nil { - return err - } - b.AttesterSlashings = make([]*generic.AttesterSlashing, num) - err = ssz.UnmarshalDynamic(buf, num, func(indx int, buf []byte) (err error) { - if b.AttesterSlashings[indx] == nil { - b.AttesterSlashings[indx] = new(generic.AttesterSlashing) - } - if err = b.AttesterSlashings[indx].UnmarshalSSZ(buf); err != nil { - return err - } - return nil - }) - if err != nil { - return err - } - } - - // Field (5) 'Attestations' - { - buf = tail[o5:o6] - num, err := ssz.DecodeDynamicLength(buf, 128) - if err != nil { - return err - } - b.Attestations = make([]*generic.Attestation, num) - err = ssz.UnmarshalDynamic(buf, num, func(indx int, buf []byte) (err error) { - if b.Attestations[indx] == nil { - b.Attestations[indx] = new(generic.Attestation) - } - if err = b.Attestations[indx].UnmarshalSSZ(buf); err != nil { - return err - } - return nil - }) - if err != nil { - return err - } - } - - // Field (6) 'Deposits' - { - buf = tail[o6:o7] - num, err := ssz.DivideInt2(len(buf), 1240, 16) - if err != nil { - return err - } - b.Deposits = make([]*generic.Deposit, num) - for ii := 0; ii < num; ii++ { - if b.Deposits[ii] == nil { - b.Deposits[ii] = new(generic.Deposit) - } - if err = b.Deposits[ii].UnmarshalSSZ(buf[ii*1240 : (ii+1)*1240]); err != nil { - return err - } - } - } - - // Field (7) 'VoluntaryExits' - { - buf = tail[o7:o9] - num, err := ssz.DivideInt2(len(buf), 112, 16) - if err != nil { - return err - } - b.VoluntaryExits = make([]*generic.SignedVoluntaryExit, num) - for ii := 0; ii < num; ii++ { - if b.VoluntaryExits[ii] == nil { - b.VoluntaryExits[ii] = new(generic.SignedVoluntaryExit) - } - if err = b.VoluntaryExits[ii].UnmarshalSSZ(buf[ii*112 : (ii+1)*112]); err != nil { - return err - } - } - } - - // Field (9) 'ExecutionPayload' - { - buf = tail[o9:o10] - if b.ExecutionPayload == nil { - b.ExecutionPayload = new(ExecutionPayload) - } - if err = b.ExecutionPayload.UnmarshalSSZ(buf); err != nil { - return err - } - } - - // Field (10) 'BlsToExecutionChanges' - { - buf = tail[o10:o11] - num, err := ssz.DivideInt2(len(buf), 172, 16) - if err != nil { - return err - } - b.BlsToExecutionChanges = make([]*generic.SignedBLSToExecutionChange, num) - for ii := 0; ii < num; ii++ { - if b.BlsToExecutionChanges[ii] == nil { - b.BlsToExecutionChanges[ii] = new(generic.SignedBLSToExecutionChange) - } - if err = b.BlsToExecutionChanges[ii].UnmarshalSSZ(buf[ii*172 : (ii+1)*172]); err != nil { - return err - } - } - } - - // Field (11) 'BlobKzgCommitments' - { - buf = tail[o11:] - num, err := ssz.DivideInt2(len(buf), 48, 4096) - if err != nil { - return err - } - b.BlobKzgCommitments = make([][48]byte, num) - for ii := 0; ii < num; ii++ { - copy(b.BlobKzgCommitments[ii][:], buf[ii*48:(ii+1)*48]) - } - } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the BeaconBlockBody object -func (b *BeaconBlockBody) SizeSSZ() (size int) { - size = 392 - - // Field (3) 'ProposerSlashings' - size += len(b.ProposerSlashings) * 416 - - // Field (4) 'AttesterSlashings' - for ii := 0; ii < len(b.AttesterSlashings); ii++ { - size += 4 - size += b.AttesterSlashings[ii].SizeSSZ() - } - - // Field (5) 'Attestations' - for ii := 0; ii < len(b.Attestations); ii++ { - size += 4 - size += b.Attestations[ii].SizeSSZ() - } - - // Field (6) 'Deposits' - size += len(b.Deposits) * 1240 - - // Field (7) 'VoluntaryExits' - size += len(b.VoluntaryExits) * 112 - - // Field (9) 'ExecutionPayload' - if b.ExecutionPayload == nil { - b.ExecutionPayload = new(ExecutionPayload) - } - size += b.ExecutionPayload.SizeSSZ() - - // Field (10) 'BlsToExecutionChanges' - size += len(b.BlsToExecutionChanges) * 172 - - // Field (11) 'BlobKzgCommitments' - size += len(b.BlobKzgCommitments) * 48 - - return -} - -// HashTreeRoot ssz hashes the BeaconBlockBody object -func (b *BeaconBlockBody) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) -} - -// HashTreeRootWith ssz hashes the BeaconBlockBody object with a hasher -func (b *BeaconBlockBody) HashTreeRootWith(hh ssz.HashWalker) (err error) { - indx := hh.Index() - - // Field (0) 'RandaoReveal' - if size := len(b.RandaoReveal); size != 96 { - err = ssz.ErrBytesLengthFn("BeaconBlockBody.RandaoReveal", size, 96) - return - } - hh.PutBytes(b.RandaoReveal) - - // Field (1) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(generic.Eth1Data) - } - if err = b.Eth1Data.HashTreeRootWith(hh); err != nil { - return - } - - // Field (2) 'Graffiti' - hh.PutBytes(b.Graffiti[:]) - - // Field (3) 'ProposerSlashings' - { - subIndx := hh.Index() - num := uint64(len(b.ProposerSlashings)) - if num > 16 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range b.ProposerSlashings { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } - } - hh.MerkleizeWithMixin(subIndx, num, 16) - } - - // Field (4) 'AttesterSlashings' - { - subIndx := hh.Index() - num := uint64(len(b.AttesterSlashings)) - if num > 2 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range b.AttesterSlashings { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } - } - hh.MerkleizeWithMixin(subIndx, num, 2) - } - - // Field (5) 'Attestations' - { - subIndx := hh.Index() - num := uint64(len(b.Attestations)) - if num > 128 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range b.Attestations { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } - } - hh.MerkleizeWithMixin(subIndx, num, 128) - } - - // Field (6) 'Deposits' - { - subIndx := hh.Index() - num := uint64(len(b.Deposits)) - if num > 16 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range b.Deposits { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } - } - hh.MerkleizeWithMixin(subIndx, num, 16) - } - - // Field (7) 'VoluntaryExits' - { - subIndx := hh.Index() - num := uint64(len(b.VoluntaryExits)) - if num > 16 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range b.VoluntaryExits { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } - } - hh.MerkleizeWithMixin(subIndx, num, 16) - } - - // Field (8) 'SyncAggregate' - if b.SyncAggregate == nil { - b.SyncAggregate = new(generic.SyncAggregate) - } - if err = b.SyncAggregate.HashTreeRootWith(hh); err != nil { - return - } - - // Field (9) 'ExecutionPayload' - if err = b.ExecutionPayload.HashTreeRootWith(hh); err != nil { - return - } - - // Field (10) 'BlsToExecutionChanges' - { - subIndx := hh.Index() - num := uint64(len(b.BlsToExecutionChanges)) - if num > 16 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range b.BlsToExecutionChanges { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } - } - hh.MerkleizeWithMixin(subIndx, num, 16) - } - - // Field (11) 'BlobKzgCommitments' - { - if size := len(b.BlobKzgCommitments); size > 4096 { - err = ssz.ErrListTooBigFn("BeaconBlockBody.BlobKzgCommitments", size, 4096) - return - } - subIndx := hh.Index() - for _, i := range b.BlobKzgCommitments { - hh.PutBytes(i[:]) - } - numItems := uint64(len(b.BlobKzgCommitments)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) - } - - hh.Merkleize(indx) - return -} - -// GetTree ssz hashes the BeaconBlockBody object -func (b *BeaconBlockBody) GetTree() (*ssz.Node, error) { - return ssz.ProofTree(b) -} - -// MarshalSSZ ssz marshals the ExecutionPayload object -func (e *ExecutionPayload) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(e) -} - -// MarshalSSZTo ssz marshals the ExecutionPayload object to a target array -func (e *ExecutionPayload) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(528) - - // Field (0) 'ParentHash' - dst = append(dst, e.ParentHash[:]...) - - // Field (1) 'FeeRecipient' - dst = append(dst, e.FeeRecipient[:]...) - - // Field (2) 'StateRoot' - dst = append(dst, e.StateRoot[:]...) - - // Field (3) 'ReceiptsRoot' - dst = append(dst, e.ReceiptsRoot[:]...) - - // Field (4) 'LogsBloom' - dst = append(dst, e.LogsBloom[:]...) - - // Field (5) 'PrevRandao' - dst = append(dst, e.PrevRandao[:]...) - - // Field (6) 'BlockNumber' - dst = ssz.MarshalUint64(dst, e.BlockNumber) - - // Field (7) 'GasLimit' - dst = ssz.MarshalUint64(dst, e.GasLimit) - - // Field (8) 'GasUsed' - dst = ssz.MarshalUint64(dst, e.GasUsed) - - // Field (9) 'Timestamp' - dst = ssz.MarshalUint64(dst, e.Timestamp) - - // Offset (10) 'ExtraData' - dst = ssz.WriteOffset(dst, offset) - offset += len(e.ExtraData) - - // Field (11) 'BaseFeePerGas' - dst = append(dst, e.BaseFeePerGas[:]...) - - // Field (12) 'BlockHash' - dst = append(dst, e.BlockHash[:]...) - - // Offset (13) 'Transactions' - dst = ssz.WriteOffset(dst, offset) - for ii := 0; ii < len(e.Transactions); ii++ { - offset += 4 - offset += len(e.Transactions[ii]) - } - - // Offset (14) 'Withdrawals' - dst = ssz.WriteOffset(dst, offset) - - // Field (15) 'BlobGasUsed' - dst = ssz.MarshalUint64(dst, e.BlobGasUsed) - - // Field (16) 'ExcessBlobGas' - dst = ssz.MarshalUint64(dst, e.ExcessBlobGas) - - // Field (10) 'ExtraData' - if size := len(e.ExtraData); size > 32 { - err = ssz.ErrBytesLengthFn("ExecutionPayload.ExtraData", size, 32) - return - } - dst = append(dst, e.ExtraData...) - - // Field (13) 'Transactions' - if size := len(e.Transactions); size > 1048576 { - err = ssz.ErrListTooBigFn("ExecutionPayload.Transactions", size, 1048576) - return - } - { - offset = 4 * len(e.Transactions) - for ii := 0; ii < len(e.Transactions); ii++ { - dst = ssz.WriteOffset(dst, offset) - offset += len(e.Transactions[ii]) - } - } - for ii := 0; ii < len(e.Transactions); ii++ { - if size := len(e.Transactions[ii]); size > 1073741824 { - err = ssz.ErrBytesLengthFn("ExecutionPayload.Transactions[ii]", size, 1073741824) - return - } - dst = append(dst, e.Transactions[ii]...) - } - - // Field (14) 'Withdrawals' - if size := len(e.Withdrawals); size > 16 { - err = ssz.ErrListTooBigFn("ExecutionPayload.Withdrawals", size, 16) - return - } - for ii := 0; ii < len(e.Withdrawals); ii++ { - if dst, err = e.Withdrawals[ii].MarshalSSZTo(dst); err != nil { - return - } - } - - return -} - -// UnmarshalSSZ ssz unmarshals the ExecutionPayload object -func (e *ExecutionPayload) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 528 { - return ssz.ErrSize - } - - tail := buf - var o10, o13, o14 uint64 - - // Field (0) 'ParentHash' - copy(e.ParentHash[:], buf[0:32]) - - // Field (1) 'FeeRecipient' - copy(e.FeeRecipient[:], buf[32:52]) - - // Field (2) 'StateRoot' - copy(e.StateRoot[:], buf[52:84]) - - // Field (3) 'ReceiptsRoot' - copy(e.ReceiptsRoot[:], buf[84:116]) - - // Field (4) 'LogsBloom' - copy(e.LogsBloom[:], buf[116:372]) - - // Field (5) 'PrevRandao' - copy(e.PrevRandao[:], buf[372:404]) - - // Field (6) 'BlockNumber' - e.BlockNumber = ssz.UnmarshallUint64(buf[404:412]) - - // Field (7) 'GasLimit' - e.GasLimit = ssz.UnmarshallUint64(buf[412:420]) - - // Field (8) 'GasUsed' - e.GasUsed = ssz.UnmarshallUint64(buf[420:428]) - - // Field (9) 'Timestamp' - e.Timestamp = ssz.UnmarshallUint64(buf[428:436]) - - // Offset (10) 'ExtraData' - if o10 = ssz.ReadOffset(buf[436:440]); o10 > size { - return ssz.ErrOffset - } - - if o10 != 528 { - return ssz.ErrInvalidVariableOffset - } - - // Field (11) 'BaseFeePerGas' - copy(e.BaseFeePerGas[:], buf[440:472]) - - // Field (12) 'BlockHash' - copy(e.BlockHash[:], buf[472:504]) - - // Offset (13) 'Transactions' - if o13 = ssz.ReadOffset(buf[504:508]); o13 > size || o10 > o13 { - return ssz.ErrOffset - } - - // Offset (14) 'Withdrawals' - if o14 = ssz.ReadOffset(buf[508:512]); o14 > size || o13 > o14 { - return ssz.ErrOffset - } - - // Field (15) 'BlobGasUsed' - e.BlobGasUsed = ssz.UnmarshallUint64(buf[512:520]) - - // Field (16) 'ExcessBlobGas' - e.ExcessBlobGas = ssz.UnmarshallUint64(buf[520:528]) - - // Field (10) 'ExtraData' - { - buf = tail[o10:o13] - if len(buf) > 32 { - return ssz.ErrBytesLength - } - if cap(e.ExtraData) == 0 { - e.ExtraData = make([]byte, 0, len(buf)) - } - e.ExtraData = append(e.ExtraData, buf...) - } - - // Field (13) 'Transactions' - { - buf = tail[o13:o14] - num, err := ssz.DecodeDynamicLength(buf, 1048576) - if err != nil { - return err - } - e.Transactions = make([][]byte, num) - err = ssz.UnmarshalDynamic(buf, num, func(indx int, buf []byte) (err error) { - if len(buf) > 1073741824 { - return ssz.ErrBytesLength - } - if cap(e.Transactions[indx]) == 0 { - e.Transactions[indx] = make([]byte, 0, len(buf)) - } - e.Transactions[indx] = append(e.Transactions[indx], buf...) - return nil - }) - if err != nil { - return err - } - } - - // Field (14) 'Withdrawals' - { - buf = tail[o14:] - num, err := ssz.DivideInt2(len(buf), 44, 16) - if err != nil { - return err - } - e.Withdrawals = make([]*generic.Withdrawal, num) - for ii := 0; ii < num; ii++ { - if e.Withdrawals[ii] == nil { - e.Withdrawals[ii] = new(generic.Withdrawal) - } - if err = e.Withdrawals[ii].UnmarshalSSZ(buf[ii*44 : (ii+1)*44]); err != nil { - return err - } - } - } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the ExecutionPayload object -func (e *ExecutionPayload) SizeSSZ() (size int) { - size = 528 - - // Field (10) 'ExtraData' - size += len(e.ExtraData) - - // Field (13) 'Transactions' - for ii := 0; ii < len(e.Transactions); ii++ { - size += 4 - size += len(e.Transactions[ii]) - } - - // Field (14) 'Withdrawals' - size += len(e.Withdrawals) * 44 - - return -} - -// HashTreeRoot ssz hashes the ExecutionPayload object -func (e *ExecutionPayload) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(e) -} - -// HashTreeRootWith ssz hashes the ExecutionPayload object with a hasher -func (e *ExecutionPayload) HashTreeRootWith(hh ssz.HashWalker) (err error) { - indx := hh.Index() - - // Field (0) 'ParentHash' - hh.PutBytes(e.ParentHash[:]) - - // Field (1) 'FeeRecipient' - hh.PutBytes(e.FeeRecipient[:]) - - // Field (2) 'StateRoot' - hh.PutBytes(e.StateRoot[:]) - - // Field (3) 'ReceiptsRoot' - hh.PutBytes(e.ReceiptsRoot[:]) - - // Field (4) 'LogsBloom' - hh.PutBytes(e.LogsBloom[:]) - - // Field (5) 'PrevRandao' - hh.PutBytes(e.PrevRandao[:]) - - // Field (6) 'BlockNumber' - hh.PutUint64(e.BlockNumber) - - // Field (7) 'GasLimit' - hh.PutUint64(e.GasLimit) - - // Field (8) 'GasUsed' - hh.PutUint64(e.GasUsed) - - // Field (9) 'Timestamp' - hh.PutUint64(e.Timestamp) - - // Field (10) 'ExtraData' - { - elemIndx := hh.Index() - byteLen := uint64(len(e.ExtraData)) - if byteLen > 32 { - err = ssz.ErrIncorrectListSize - return - } - hh.Append(e.ExtraData) - hh.MerkleizeWithMixin(elemIndx, byteLen, (32+31)/32) - } - - // Field (11) 'BaseFeePerGas' - hh.PutBytes(e.BaseFeePerGas[:]) - - // Field (12) 'BlockHash' - hh.PutBytes(e.BlockHash[:]) - - // Field (13) 'Transactions' - { - subIndx := hh.Index() - num := uint64(len(e.Transactions)) - if num > 1048576 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range e.Transactions { - { - elemIndx := hh.Index() - byteLen := uint64(len(elem)) - if byteLen > 1073741824 { - err = ssz.ErrIncorrectListSize - return - } - hh.AppendBytes32(elem) - hh.MerkleizeWithMixin(elemIndx, byteLen, (1073741824+31)/32) - } - } - hh.MerkleizeWithMixin(subIndx, num, 1048576) - } - - // Field (14) 'Withdrawals' - { - subIndx := hh.Index() - num := uint64(len(e.Withdrawals)) - if num > 16 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range e.Withdrawals { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } - } - hh.MerkleizeWithMixin(subIndx, num, 16) - } - - // Field (15) 'BlobGasUsed' - hh.PutUint64(e.BlobGasUsed) - - // Field (16) 'ExcessBlobGas' - hh.PutUint64(e.ExcessBlobGas) - - hh.Merkleize(indx) - return -} - -// GetTree ssz hashes the ExecutionPayload object -func (e *ExecutionPayload) GetTree() (*ssz.Node, error) { - return ssz.ProofTree(e) -} diff --git a/shared/types/eth2/fork/deneb/deneb_generated.go b/shared/types/eth2/fork/deneb/deneb_generated.go new file mode 100644 index 000000000..21b05601f --- /dev/null +++ b/shared/types/eth2/fork/deneb/deneb_generated.go @@ -0,0 +1,4682 @@ +// Code generated by dynamic-ssz. DO NOT EDIT. +// Hash: 09c8c584a7ad6def2d6481cc65e07bf1d49d4d06bc5c705ce167655fc535b0af +// Version: v1.3.2 (https://github.com/pk910/dynamic-ssz) +package deneb + +import ( + "encoding/binary" + + "github.com/pk910/dynamic-ssz/hasher" + "github.com/pk910/dynamic-ssz/sszutils" + "github.com/rocket-pool/smartnode/shared/types/eth2/generic" +) + +var _ = sszutils.ErrListTooBig + +var _ = sszutils.Annotate[BeaconState](`ssz-static:"false"`) +var _ = sszutils.Annotate[SignedBeaconBlock](`ssz-static:"false"`) +var _ = sszutils.Annotate[BeaconBlock](`ssz-static:"false"`) +var _ = sszutils.Annotate[BeaconBlockBody](`ssz-static:"false"`) +var _ = sszutils.Annotate[ExecutionPayload](`ssz-static:"false"`) + +// MarshalSSZTo marshals the *BeaconState to SSZ-encoded bytes, appending to the provided buffer. +func (t *BeaconState) MarshalSSZTo(buf []byte) (dst []byte, err error) { + dst = buf + if t == nil { + t = new(BeaconState) + } + dstlen := len(dst) + { // Static Field #0 'GenesisTime' + dst = binary.LittleEndian.AppendUint64(dst, t.GenesisTime) + } + { // Static Field #1 'GenesisValidatorsRoot' + vlen := len(t.GenesisValidatorsRoot) + if vlen > 32 { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 32), "GenesisValidatorsRoot") + } + dst = append(dst, t.GenesisValidatorsRoot[:vlen]...) + if vlen < 32 { + dst = sszutils.AppendZeroPadding(dst, (32-vlen)*1) + } + } + { // Static Field #2 'Slot' + dst = binary.LittleEndian.AppendUint64(dst, t.Slot) + } + { // Static Field #3 'Fork' + t := t.Fork + if t == nil { + t = new(generic.Fork) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "Fork") + } + } + { // Static Field #4 'LatestBlockHeader' + t := t.LatestBlockHeader + if t == nil { + t = new(generic.BeaconBlockHeader) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "LatestBlockHeader") + } + } + { // Static Field #5 'BlockRoots' + t := &t.BlockRoots + dst = sszutils.MarshalFixedBytesSlice(dst, t[:8192]) + } + { // Static Field #6 'StateRoots' + t := &t.StateRoots + dst = sszutils.MarshalFixedBytesSlice(dst, t[:8192]) + } + // Offset Field #7 'HistoricalRoots' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #8 'Eth1Data' + t := t.Eth1Data + if t == nil { + t = new(generic.Eth1Data) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "Eth1Data") + } + } + // Offset Field #9 'Eth1DataVotes' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #10 'Eth1DepositIndex' + dst = binary.LittleEndian.AppendUint64(dst, t.Eth1DepositIndex) + } + // Offset Field #11 'Validators' + // Offset Field #12 'Balances' + dst = append(dst, 0, 0, 0, 0, 0, 0, 0, 0) + { // Static Field #13 'RandaoMixes' + t := t.RandaoMixes + vlen := len(t) + if vlen > 65536 { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 65536), "RandaoMixes") + } + for idx1 := range vlen { + vlen := len(t[idx1]) + if vlen > 32 { + return nil, sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, 32), "RandaoMixes[%d]", idx1) + } + dst = append(dst, t[idx1][:vlen]...) + if vlen < 32 { + dst = sszutils.AppendZeroPadding(dst, (32-vlen)*1) + } + } + if vlen < 65536 { + dst = sszutils.AppendZeroPadding(dst, (65536-vlen)*32) + } + } + { // Static Field #14 'Slashings' + t := t.Slashings + vlen := len(t) + if vlen > 8192 { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 8192), "Slashings") + } + dst = sszutils.MarshalUint64Slice(dst, t[:vlen]) + if vlen < 8192 { + dst = sszutils.AppendZeroPadding(dst, (8192-vlen)*8) + } + } + // Offset Field #15 'PreviousEpochParticipation' + // Offset Field #16 'CurrentEpochParticipation' + dst = append(dst, 0, 0, 0, 0, 0, 0, 0, 0) + { // Static Field #17 'JustificationBits' + dst = append(dst, t.JustificationBits[:1]...) + } + { // Static Field #18 'PreviousJustifiedCheckpoint' + t := t.PreviousJustifiedCheckpoint + if t == nil { + t = new(generic.Checkpoint) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } + } + { // Static Field #19 'CurrentJustifiedCheckpoint' + t := t.CurrentJustifiedCheckpoint + if t == nil { + t = new(generic.Checkpoint) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } + } + { // Static Field #20 'FinalizedCheckpoint' + t := t.FinalizedCheckpoint + if t == nil { + t = new(generic.Checkpoint) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "FinalizedCheckpoint") + } + } + // Offset Field #21 'InactivityScores' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #22 'CurrentSyncCommittee' + t := t.CurrentSyncCommittee + if t == nil { + t = new(generic.SyncCommittee) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "CurrentSyncCommittee") + } + } + { // Static Field #23 'NextSyncCommittee' + t := t.NextSyncCommittee + if t == nil { + t = new(generic.SyncCommittee) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "NextSyncCommittee") + } + } + // Offset Field #24 'LatestExecutionPayloadHeader' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #25 'NextWithdrawalIndex' + dst = binary.LittleEndian.AppendUint64(dst, t.NextWithdrawalIndex) + } + { // Static Field #26 'NextWithdrawalValidatorIndex' + dst = binary.LittleEndian.AppendUint64(dst, t.NextWithdrawalValidatorIndex) + } + // Offset Field #27 'HistoricalSummaries' + dst = append(dst, 0, 0, 0, 0) + { // Dynamic Field #7 'HistoricalRoots' + binary.LittleEndian.PutUint32(dst[dstlen+524464:], uint32(len(dst)-dstlen)) + t := t.HistoricalRoots + vlen := len(t) + if vlen > 16777216 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16777216), "HistoricalRoots") + } + for idx1 := range vlen { + vlen := len(t[idx1]) + if vlen > 32 { + return nil, sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, 32), "HistoricalRoots[%d]", idx1) + } + dst = append(dst, t[idx1][:vlen]...) + if vlen < 32 { + dst = sszutils.AppendZeroPadding(dst, (32-vlen)*1) + } + } + } + { // Dynamic Field #9 'Eth1DataVotes' + binary.LittleEndian.PutUint32(dst[dstlen+524540:], uint32(len(dst)-dstlen)) + t := t.Eth1DataVotes + vlen := len(t) + if vlen > 2048 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 2048), "Eth1DataVotes") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(generic.Eth1Data) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "Eth1DataVotes[%d]", idx1) + } + } + } + { // Dynamic Field #11 'Validators' + binary.LittleEndian.PutUint32(dst[dstlen+524552:], uint32(len(dst)-dstlen)) + t := t.Validators + vlen := len(t) + if vlen > 1099511627776 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1099511627776), "Validators") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(generic.Validator) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } + } + } + { // Dynamic Field #12 'Balances' + binary.LittleEndian.PutUint32(dst[dstlen+524556:], uint32(len(dst)-dstlen)) + t := t.Balances + vlen := len(t) + if vlen > 1099511627776 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1099511627776), "Balances") + } + dst = sszutils.MarshalUint64Slice(dst, t[:vlen]) + } + { // Dynamic Field #15 'PreviousEpochParticipation' + binary.LittleEndian.PutUint32(dst[dstlen+2687248:], uint32(len(dst)-dstlen)) + vlen := len(t.PreviousEpochParticipation) + if vlen > 1099511627776 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1099511627776), "PreviousEpochParticipation") + } + dst = append(dst, t.PreviousEpochParticipation[:]...) + } + { // Dynamic Field #16 'CurrentEpochParticipation' + binary.LittleEndian.PutUint32(dst[dstlen+2687252:], uint32(len(dst)-dstlen)) + vlen := len(t.CurrentEpochParticipation) + if vlen > 1099511627776 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1099511627776), "CurrentEpochParticipation") + } + dst = append(dst, t.CurrentEpochParticipation[:]...) + } + { // Dynamic Field #21 'InactivityScores' + binary.LittleEndian.PutUint32(dst[dstlen+2687377:], uint32(len(dst)-dstlen)) + t := t.InactivityScores + vlen := len(t) + if vlen > 1099511627776 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1099511627776), "InactivityScores") + } + dst = sszutils.MarshalUint64Slice(dst, t[:vlen]) + } + { // Dynamic Field #24 'LatestExecutionPayloadHeader' + binary.LittleEndian.PutUint32(dst[dstlen+2736629:], uint32(len(dst)-dstlen)) + t := t.LatestExecutionPayloadHeader + if t == nil { + t = new(generic.ExecutionPayloadHeader) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "LatestExecutionPayloadHeader") + } + } + { // Dynamic Field #27 'HistoricalSummaries' + binary.LittleEndian.PutUint32(dst[dstlen+2736649:], uint32(len(dst)-dstlen)) + t := t.HistoricalSummaries + vlen := len(t) + if vlen > 16777216 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16777216), "HistoricalSummaries") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(generic.HistoricalSummary) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "HistoricalSummaries[%d]", idx1) + } + } + } + return dst, nil +} + +// MarshalSSZDyn marshals the *BeaconState to SSZ-encoded bytes using dynamic specifications. +func (t *BeaconState) MarshalSSZDyn(_ sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + return t.MarshalSSZTo(buf) +} + +// MarshalSSZEncoder marshals the *BeaconState to the given SSZ encoder using dynamic specifications. +func (t *BeaconState) MarshalSSZEncoder(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + type encoderCtx struct { + ds sszutils.DynamicSpecs + exprs [0]uint64 + sizeFn1 func(ctx *encoderCtx, t [][]byte) (size int) + sizeFn2 func(ctx *encoderCtx, t []*generic.Eth1Data) (size int) + sizeFn3 func(ctx *encoderCtx, t []*generic.Validator) (size int) + sizeFn4 func(ctx *encoderCtx, t []uint64) (size int) + sizeFn5 func(ctx *encoderCtx, t []byte) (size int) + sizeFn6 func(ctx *encoderCtx, t []byte) (size int) + sizeFn7 func(ctx *encoderCtx, t []uint64) (size int) + sizeFn8 func(ctx *encoderCtx, t *generic.ExecutionPayloadHeader) (size int) + sizeFn9 func(ctx *encoderCtx, t []*generic.HistoricalSummary) (size int) + } + ctx := &encoderCtx{ds: ds} + canSeek := enc.Seekable() + // size for [][]byte + ctx.sizeFn1 = func(ctx *encoderCtx, t [][]byte) (size int) { + size += len(t) * 32 + return size + } + // size for []*generic.Eth1Data + ctx.sizeFn2 = func(ctx *encoderCtx, t []*generic.Eth1Data) (size int) { + size += len(t) * 72 + return size + } + // size for []*generic.Validator + ctx.sizeFn3 = func(ctx *encoderCtx, t []*generic.Validator) (size int) { + size += len(t) * 121 + return size + } + // size for []uint64 + ctx.sizeFn4 = func(ctx *encoderCtx, t []uint64) (size int) { + size += len(t) * 8 + return size + } + // size for []byte + ctx.sizeFn5 = func(ctx *encoderCtx, t []byte) (size int) { + size += len(t) + return size + } + // size for []byte + ctx.sizeFn6 = func(ctx *encoderCtx, t []byte) (size int) { + size += len(t) + return size + } + // size for []uint64 + ctx.sizeFn7 = func(ctx *encoderCtx, t []uint64) (size int) { + size += len(t) * 8 + return size + } + // size for *generic.ExecutionPayloadHeader + ctx.sizeFn8 = func(ctx *encoderCtx, t *generic.ExecutionPayloadHeader) (size int) { + size += t.SizeSSZDyn(ds) + return size + } + // size for []*generic.HistoricalSummary + ctx.sizeFn9 = func(ctx *encoderCtx, t []*generic.HistoricalSummary) (size int) { + size += len(t) * 64 + return size + } + if t == nil { + t = new(BeaconState) + } + dstlen := enc.GetPosition() + dynoff := uint32(2736653) + { // Field #0 'GenesisTime' + enc.EncodeUint64(t.GenesisTime) + } + { // Field #1 'GenesisValidatorsRoot' + vlen := len(t.GenesisValidatorsRoot) + if vlen > 32 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 32), "GenesisValidatorsRoot") + } + enc.EncodeBytes(t.GenesisValidatorsRoot[:vlen]) + if vlen < 32 { + enc.EncodeZeroPadding((32 - vlen) * 1) + } + } + { // Field #2 'Slot' + enc.EncodeUint64(t.Slot) + } + { // Field #3 'Fork' + t := t.Fork + if t == nil { + t = new(generic.Fork) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "Fork") + } else { + enc.SetBuffer(buf) + } + } + { // Field #4 'LatestBlockHeader' + t := t.LatestBlockHeader + if t == nil { + t = new(generic.BeaconBlockHeader) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") + } else { + enc.SetBuffer(buf) + } + } + { // Field #5 'BlockRoots' + t := &t.BlockRoots + for idx1 := range 8192 { + enc.EncodeBytes(t[idx1][:32]) + } + } + { // Field #6 'StateRoots' + t := &t.StateRoots + for idx1 := range 8192 { + enc.EncodeBytes(t[idx1][:32]) + } + } + // Offset #7 'HistoricalRoots' + offset7 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn1(ctx, t.HistoricalRoots)) + } + { // Field #8 'Eth1Data' + t := t.Eth1Data + if t == nil { + t = new(generic.Eth1Data) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "Eth1Data") + } else { + enc.SetBuffer(buf) + } + } + // Offset #9 'Eth1DataVotes' + offset9 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn2(ctx, t.Eth1DataVotes)) + } + { // Field #10 'Eth1DepositIndex' + enc.EncodeUint64(t.Eth1DepositIndex) + } + // Offset #11 'Validators' + offset11 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn3(ctx, t.Validators)) + } + // Offset #12 'Balances' + offset12 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn4(ctx, t.Balances)) + } + { // Field #13 'RandaoMixes' + t := t.RandaoMixes + vlen := len(t) + if vlen > 65536 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 65536), "RandaoMixes") + } + for idx1 := range vlen { + vlen := len(t[idx1]) + if vlen > 32 { + return sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, 32), "RandaoMixes[%d]", idx1) + } + enc.EncodeBytes(t[idx1][:vlen]) + if vlen < 32 { + enc.EncodeZeroPadding((32 - vlen) * 1) + } + } + if vlen < 65536 { + enc.EncodeZeroPadding((65536 - vlen) * 32) + } + } + { // Field #14 'Slashings' + t := t.Slashings + vlen := len(t) + if vlen > 8192 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 8192), "Slashings") + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + if vlen < 8192 { + enc.EncodeZeroPadding((8192 - vlen) * 8) + } + } + // Offset #15 'PreviousEpochParticipation' + offset15 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn5(ctx, t.PreviousEpochParticipation)) + } + // Offset #16 'CurrentEpochParticipation' + offset16 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn6(ctx, t.CurrentEpochParticipation)) + } + { // Field #17 'JustificationBits' + enc.EncodeBytes(t.JustificationBits[:1]) + } + { // Field #18 'PreviousJustifiedCheckpoint' + t := t.PreviousJustifiedCheckpoint + if t == nil { + t = new(generic.Checkpoint) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } else { + enc.SetBuffer(buf) + } + } + { // Field #19 'CurrentJustifiedCheckpoint' + t := t.CurrentJustifiedCheckpoint + if t == nil { + t = new(generic.Checkpoint) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } else { + enc.SetBuffer(buf) + } + } + { // Field #20 'FinalizedCheckpoint' + t := t.FinalizedCheckpoint + if t == nil { + t = new(generic.Checkpoint) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") + } else { + enc.SetBuffer(buf) + } + } + // Offset #21 'InactivityScores' + offset21 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn7(ctx, t.InactivityScores)) + } + { // Field #22 'CurrentSyncCommittee' + t := t.CurrentSyncCommittee + if t == nil { + t = new(generic.SyncCommittee) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "CurrentSyncCommittee") + } else { + enc.SetBuffer(buf) + } + } + { // Field #23 'NextSyncCommittee' + t := t.NextSyncCommittee + if t == nil { + t = new(generic.SyncCommittee) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "NextSyncCommittee") + } else { + enc.SetBuffer(buf) + } + } + // Offset #24 'LatestExecutionPayloadHeader' + offset24 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn8(ctx, t.LatestExecutionPayloadHeader)) + } + { // Field #25 'NextWithdrawalIndex' + enc.EncodeUint64(t.NextWithdrawalIndex) + } + { // Field #26 'NextWithdrawalValidatorIndex' + enc.EncodeUint64(t.NextWithdrawalValidatorIndex) + } + // Offset #27 'HistoricalSummaries' + offset27 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn9(ctx, t.HistoricalSummaries)) + } + { // Dynamic Field #7 'HistoricalRoots' + if canSeek { + enc.EncodeOffsetAt(offset7, uint32(enc.GetPosition()-dstlen)) + } + t := t.HistoricalRoots + vlen := len(t) + if vlen > 16777216 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16777216), "HistoricalRoots") + } + for idx1 := range vlen { + vlen := len(t[idx1]) + if vlen > 32 { + return sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, 32), "HistoricalRoots[%d]", idx1) + } + enc.EncodeBytes(t[idx1][:vlen]) + if vlen < 32 { + enc.EncodeZeroPadding((32 - vlen) * 1) + } + } + } + { // Dynamic Field #9 'Eth1DataVotes' + if canSeek { + enc.EncodeOffsetAt(offset9, uint32(enc.GetPosition()-dstlen)) + } + t := t.Eth1DataVotes + vlen := len(t) + if vlen > 2048 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 2048), "Eth1DataVotes") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(generic.Eth1Data) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "Eth1DataVotes[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #11 'Validators' + if canSeek { + enc.EncodeOffsetAt(offset11, uint32(enc.GetPosition()-dstlen)) + } + t := t.Validators + vlen := len(t) + if vlen > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1099511627776), "Validators") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(generic.Validator) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #12 'Balances' + if canSeek { + enc.EncodeOffsetAt(offset12, uint32(enc.GetPosition()-dstlen)) + } + t := t.Balances + vlen := len(t) + if vlen > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1099511627776), "Balances") + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + } + { // Dynamic Field #15 'PreviousEpochParticipation' + if canSeek { + enc.EncodeOffsetAt(offset15, uint32(enc.GetPosition()-dstlen)) + } + vlen := len(t.PreviousEpochParticipation) + if vlen > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1099511627776), "PreviousEpochParticipation") + } + enc.EncodeBytes(t.PreviousEpochParticipation[:]) + } + { // Dynamic Field #16 'CurrentEpochParticipation' + if canSeek { + enc.EncodeOffsetAt(offset16, uint32(enc.GetPosition()-dstlen)) + } + vlen := len(t.CurrentEpochParticipation) + if vlen > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1099511627776), "CurrentEpochParticipation") + } + enc.EncodeBytes(t.CurrentEpochParticipation[:]) + } + { // Dynamic Field #21 'InactivityScores' + if canSeek { + enc.EncodeOffsetAt(offset21, uint32(enc.GetPosition()-dstlen)) + } + t := t.InactivityScores + vlen := len(t) + if vlen > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1099511627776), "InactivityScores") + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + } + { // Dynamic Field #24 'LatestExecutionPayloadHeader' + if canSeek { + enc.EncodeOffsetAt(offset24, uint32(enc.GetPosition()-dstlen)) + } + t := t.LatestExecutionPayloadHeader + if t == nil { + t = new(generic.ExecutionPayloadHeader) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "LatestExecutionPayloadHeader") + } else { + enc.SetBuffer(buf) + } + } + { // Dynamic Field #27 'HistoricalSummaries' + if canSeek { + enc.EncodeOffsetAt(offset27, uint32(enc.GetPosition()-dstlen)) + } + t := t.HistoricalSummaries + vlen := len(t) + if vlen > 16777216 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16777216), "HistoricalSummaries") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(generic.HistoricalSummary) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "HistoricalSummaries[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + return nil +} + +// UnmarshalSSZ unmarshals the *BeaconState from SSZ-encoded bytes. +func (t *BeaconState) UnmarshalSSZ(buf []byte) (err error) { + buflen := len(buf) + if buflen < 2736653 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 2736653) + } + { // Field #0 'GenesisTime' (static) + buf := buf[0:8] + t.GenesisTime = binary.LittleEndian.Uint64(buf) + } + { // Field #1 'GenesisValidatorsRoot' (static) + buf := buf[8:40] + t.GenesisValidatorsRoot = sszutils.ExpandSlice(t.GenesisValidatorsRoot, 32) + copy(t.GenesisValidatorsRoot[:], buf) + } + { // Field #2 'Slot' (static) + buf := buf[40:48] + t.Slot = binary.LittleEndian.Uint64(buf) + } + { // Field #3 'Fork' (static) + buf := buf[48:64] + if t.Fork == nil { + t.Fork = new(generic.Fork) + } + if err = t.Fork.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "Fork") + } + } + { // Field #4 'LatestBlockHeader' (static) + buf := buf[64:176] + if t.LatestBlockHeader == nil { + t.LatestBlockHeader = new(generic.BeaconBlockHeader) + } + if err = t.LatestBlockHeader.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") + } + } + { // Field #5 'BlockRoots' (static) + buf := buf[176:262320] + val1 := t.BlockRoots + sszutils.UnmarshalFixedBytesSlice(val1[:8192], buf) + t.BlockRoots = val1 + } + { // Field #6 'StateRoots' (static) + buf := buf[262320:524464] + val2 := t.StateRoots + sszutils.UnmarshalFixedBytesSlice(val2[:8192], buf) + t.StateRoots = val2 + } + // Field #7 'HistoricalRoots' (offset) + offset7 := int(binary.LittleEndian.Uint32(buf[524464:524468])) + if offset7 != 2736653 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset7, 2736653), "HistoricalRoots:o") + } + { // Field #8 'Eth1Data' (static) + buf := buf[524468:524540] + if t.Eth1Data == nil { + t.Eth1Data = new(generic.Eth1Data) + } + if err = t.Eth1Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "Eth1Data") + } + } + // Field #9 'Eth1DataVotes' (offset) + offset9 := int(binary.LittleEndian.Uint32(buf[524540:524544])) + if offset9 < offset7 || offset9 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset9, offset7, buflen), "Eth1DataVotes:o") + } + { // Field #10 'Eth1DepositIndex' (static) + buf := buf[524544:524552] + t.Eth1DepositIndex = binary.LittleEndian.Uint64(buf) + } + // Field #11 'Validators' (offset) + offset11 := int(binary.LittleEndian.Uint32(buf[524552:524556])) + if offset11 < offset9 || offset11 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset11, offset9, buflen), "Validators:o") + } + // Field #12 'Balances' (offset) + offset12 := int(binary.LittleEndian.Uint32(buf[524556:524560])) + if offset12 < offset11 || offset12 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset12, offset11, buflen), "Balances:o") + } + { // Field #13 'RandaoMixes' (static) + buf := buf[524560:2621712] + val3 := t.RandaoMixes + val3 = sszutils.ExpandSlice(val3, 65536) + for idx1 := range 65536 { + buf := buf[32*idx1 : 32*(idx1+1)] + val3[idx1] = sszutils.ExpandSlice(val3[idx1], 32) + copy(val3[idx1][:], buf) + } + t.RandaoMixes = val3 + } + { // Field #14 'Slashings' (static) + buf := buf[2621712:2687248] + val4 := t.Slashings + val4 = sszutils.ExpandSlice(val4, 8192) + sszutils.UnmarshalUint64Slice(val4[:8192], buf) + t.Slashings = val4 + } + // Field #15 'PreviousEpochParticipation' (offset) + offset15 := int(binary.LittleEndian.Uint32(buf[2687248:2687252])) + if offset15 < offset12 || offset15 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset15, offset12, buflen), "PreviousEpochParticipation:o") + } + // Field #16 'CurrentEpochParticipation' (offset) + offset16 := int(binary.LittleEndian.Uint32(buf[2687252:2687256])) + if offset16 < offset15 || offset16 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset16, offset15, buflen), "CurrentEpochParticipation:o") + } + { // Field #17 'JustificationBits' (static) + buf := buf[2687256:2687257] + copy(t.JustificationBits[:], buf) + } + { // Field #18 'PreviousJustifiedCheckpoint' (static) + buf := buf[2687257:2687297] + if t.PreviousJustifiedCheckpoint == nil { + t.PreviousJustifiedCheckpoint = new(generic.Checkpoint) + } + if err = t.PreviousJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } + } + { // Field #19 'CurrentJustifiedCheckpoint' (static) + buf := buf[2687297:2687337] + if t.CurrentJustifiedCheckpoint == nil { + t.CurrentJustifiedCheckpoint = new(generic.Checkpoint) + } + if err = t.CurrentJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } + } + { // Field #20 'FinalizedCheckpoint' (static) + buf := buf[2687337:2687377] + if t.FinalizedCheckpoint == nil { + t.FinalizedCheckpoint = new(generic.Checkpoint) + } + if err = t.FinalizedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") + } + } + // Field #21 'InactivityScores' (offset) + offset21 := int(binary.LittleEndian.Uint32(buf[2687377:2687381])) + if offset21 < offset16 || offset21 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset21, offset16, buflen), "InactivityScores:o") + } + { // Field #22 'CurrentSyncCommittee' (static) + buf := buf[2687381:2712005] + if t.CurrentSyncCommittee == nil { + t.CurrentSyncCommittee = new(generic.SyncCommittee) + } + if err = t.CurrentSyncCommittee.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "CurrentSyncCommittee") + } + } + { // Field #23 'NextSyncCommittee' (static) + buf := buf[2712005:2736629] + if t.NextSyncCommittee == nil { + t.NextSyncCommittee = new(generic.SyncCommittee) + } + if err = t.NextSyncCommittee.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "NextSyncCommittee") + } + } + // Field #24 'LatestExecutionPayloadHeader' (offset) + offset24 := int(binary.LittleEndian.Uint32(buf[2736629:2736633])) + if offset24 < offset21 || offset24 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset24, offset21, buflen), "LatestExecutionPayloadHeader:o") + } + { // Field #25 'NextWithdrawalIndex' (static) + buf := buf[2736633:2736641] + t.NextWithdrawalIndex = binary.LittleEndian.Uint64(buf) + } + { // Field #26 'NextWithdrawalValidatorIndex' (static) + buf := buf[2736641:2736649] + t.NextWithdrawalValidatorIndex = binary.LittleEndian.Uint64(buf) + } + // Field #27 'HistoricalSummaries' (offset) + offset27 := int(binary.LittleEndian.Uint32(buf[2736649:2736653])) + if offset27 < offset24 || offset27 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset27, offset24, buflen), "HistoricalSummaries:o") + } + { // Field #7 'HistoricalRoots' (dynamic) + buf := buf[offset7:offset9] + val5 := t.HistoricalRoots + itemCount := len(buf) / 32 + if len(buf)%32 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 32), "HistoricalRoots") + } + if itemCount > 16777216 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 16777216), "HistoricalRoots") + } + val5 = sszutils.ExpandSlice(val5, itemCount) + for idx1 := range itemCount { + buf := buf[32*idx1 : 32*(idx1+1)] + val5[idx1] = sszutils.ExpandSlice(val5[idx1], 32) + copy(val5[idx1][:], buf) + } + t.HistoricalRoots = val5 + } + { // Field #9 'Eth1DataVotes' (dynamic) + buf := buf[offset9:offset11] + val6 := t.Eth1DataVotes + itemCount := len(buf) / 72 + if len(buf)%72 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 72), "Eth1DataVotes") + } + if itemCount > 2048 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 2048), "Eth1DataVotes") + } + val6 = sszutils.ExpandSlice(val6, itemCount) + for idx1 := range itemCount { + if val6[idx1] == nil { + val6[idx1] = new(generic.Eth1Data) + } + buf := buf[72*idx1 : 72*(idx1+1)] + if err = val6[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Eth1DataVotes[%d]", idx1) + } + } + t.Eth1DataVotes = val6 + } + { // Field #11 'Validators' (dynamic) + buf := buf[offset11:offset12] + val7 := t.Validators + itemCount := len(buf) / 121 + if len(buf)%121 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 121), "Validators") + } + if itemCount > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1099511627776), "Validators") + } + val7 = sszutils.ExpandSlice(val7, itemCount) + for idx1 := range itemCount { + if val7[idx1] == nil { + val7[idx1] = new(generic.Validator) + } + buf := buf[121*idx1 : 121*(idx1+1)] + if err = val7[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } + } + t.Validators = val7 + } + { // Field #12 'Balances' (dynamic) + buf := buf[offset12:offset15] + val8 := t.Balances + itemCount := len(buf) / 8 + if len(buf)%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 8), "Balances") + } + if itemCount > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1099511627776), "Balances") + } + val8 = sszutils.ExpandSlice(val8, itemCount) + sszutils.UnmarshalUint64Slice(val8, buf) + t.Balances = val8 + } + { // Field #15 'PreviousEpochParticipation' (dynamic) + buf := buf[offset15:offset16] + if len(buf) > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(len(buf), 1099511627776), "PreviousEpochParticipation") + } + t.PreviousEpochParticipation = sszutils.ExpandSlice(t.PreviousEpochParticipation, len(buf)) + copy(t.PreviousEpochParticipation[:], buf) + } + { // Field #16 'CurrentEpochParticipation' (dynamic) + buf := buf[offset16:offset21] + if len(buf) > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(len(buf), 1099511627776), "CurrentEpochParticipation") + } + t.CurrentEpochParticipation = sszutils.ExpandSlice(t.CurrentEpochParticipation, len(buf)) + copy(t.CurrentEpochParticipation[:], buf) + } + { // Field #21 'InactivityScores' (dynamic) + buf := buf[offset21:offset24] + val9 := t.InactivityScores + itemCount := len(buf) / 8 + if len(buf)%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 8), "InactivityScores") + } + if itemCount > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1099511627776), "InactivityScores") + } + val9 = sszutils.ExpandSlice(val9, itemCount) + sszutils.UnmarshalUint64Slice(val9, buf) + t.InactivityScores = val9 + } + { // Field #24 'LatestExecutionPayloadHeader' (dynamic) + buf := buf[offset24:offset27] + if t.LatestExecutionPayloadHeader == nil { + t.LatestExecutionPayloadHeader = new(generic.ExecutionPayloadHeader) + } + if err = t.LatestExecutionPayloadHeader.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "LatestExecutionPayloadHeader") + } + } + { // Field #27 'HistoricalSummaries' (dynamic) + buf := buf[offset27:] + val10 := t.HistoricalSummaries + itemCount := len(buf) / 64 + if len(buf)%64 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 64), "HistoricalSummaries") + } + if itemCount > 16777216 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 16777216), "HistoricalSummaries") + } + val10 = sszutils.ExpandSlice(val10, itemCount) + for idx1 := range itemCount { + if val10[idx1] == nil { + val10[idx1] = new(generic.HistoricalSummary) + } + buf := buf[64*idx1 : 64*(idx1+1)] + if err = val10[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "HistoricalSummaries[%d]", idx1) + } + } + t.HistoricalSummaries = val10 + } + return nil +} + +// UnmarshalSSZDyn unmarshals the *BeaconState from SSZ-encoded bytes using dynamic specifications. +func (t *BeaconState) UnmarshalSSZDyn(_ sszutils.DynamicSpecs, buf []byte) (err error) { + return t.UnmarshalSSZ(buf) +} + +// UnmarshalSSZDecoder unmarshals the *BeaconState from the given SSZ decoder using dynamic specifications. +func (t *BeaconState) UnmarshalSSZDecoder(ds sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { + maxOffset := uint32(dec.GetLength()) + startPos0 := dec.GetPosition() + if maxOffset < uint32(2736653) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(2736653)) + } + // Field #0 'GenesisTime' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "GenesisTime") + } else { + t.GenesisTime = val + } + // Field #1 'GenesisValidatorsRoot' (static) + t.GenesisValidatorsRoot = sszutils.ExpandSlice(t.GenesisValidatorsRoot, 32) + if _, err = dec.DecodeBytes(t.GenesisValidatorsRoot[:32]); err != nil { + return err + } + // Field #2 'Slot' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "Slot") + } else { + t.Slot = val + } + // Field #3 'Fork' (static) + if t.Fork == nil { + t.Fork = new(generic.Fork) + } + if err = t.Fork.UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPath(err, "Fork") + } + // Field #4 'LatestBlockHeader' (static) + if t.LatestBlockHeader == nil { + t.LatestBlockHeader = new(generic.BeaconBlockHeader) + } + if err = t.LatestBlockHeader.UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") + } + { // Field #5 'BlockRoots' (static) + val1 := t.BlockRoots + startPos1 := dec.GetPosition() + for idx1 := range 8192 { + if _, err = dec.DecodeBytes(val1[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos1+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos1+int(32*(idx1+1))), "BlockRoots[%d]", idx1) + } + } + t.BlockRoots = val1 + } + { // Field #6 'StateRoots' (static) + val2 := t.StateRoots + startPos2 := dec.GetPosition() + for idx1 := range 8192 { + if _, err = dec.DecodeBytes(val2[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos2+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos2+int(32*(idx1+1))), "StateRoots[%d]", idx1) + } + } + t.StateRoots = val2 + } + // Field #7 'HistoricalRoots' (offset) + offset7, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "HistoricalRoots") + } + if offset7 != uint32(2736653) { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset7, 2736653), "HistoricalRoots") + } + // Field #8 'Eth1Data' (static) + if t.Eth1Data == nil { + t.Eth1Data = new(generic.Eth1Data) + } + if err = t.Eth1Data.UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPath(err, "Eth1Data") + } + // Field #9 'Eth1DataVotes' (offset) + offset9, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Eth1DataVotes") + } + if offset9 < offset7 || offset9 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset9, offset7, maxOffset), "Eth1DataVotes") + } + // Field #10 'Eth1DepositIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "Eth1DepositIndex") + } else { + t.Eth1DepositIndex = val + } + // Field #11 'Validators' (offset) + offset11, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Validators") + } + if offset11 < offset9 || offset11 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset11, offset9, maxOffset), "Validators") + } + // Field #12 'Balances' (offset) + offset12, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Balances") + } + if offset12 < offset11 || offset12 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset12, offset11, maxOffset), "Balances") + } + { // Field #13 'RandaoMixes' (static) + val3 := t.RandaoMixes + val3 = sszutils.ExpandSlice(val3, 65536) + startPos3 := dec.GetPosition() + for idx1 := range 65536 { + val3[idx1] = sszutils.ExpandSlice(val3[idx1], 32) + if _, err = dec.DecodeBytes(val3[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos3+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos3+int(32*(idx1+1))), "RandaoMixes[%d]", idx1) + } + } + t.RandaoMixes = val3 + } + { // Field #14 'Slashings' (static) + val4 := t.Slashings + val4 = sszutils.ExpandSlice(val4, 8192) + if err = sszutils.DecodeUint64Slice(dec, val4[:8192]); err != nil { + return sszutils.ErrorWithPath(err, "Slashings") + } + t.Slashings = val4 + } + // Field #15 'PreviousEpochParticipation' (offset) + offset15, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "PreviousEpochParticipation") + } + if offset15 < offset12 || offset15 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset15, offset12, maxOffset), "PreviousEpochParticipation") + } + // Field #16 'CurrentEpochParticipation' (offset) + offset16, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "CurrentEpochParticipation") + } + if offset16 < offset15 || offset16 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset16, offset15, maxOffset), "CurrentEpochParticipation") + } + // Field #17 'JustificationBits' (static) + if _, err = dec.DecodeBytes(t.JustificationBits[:1]); err != nil { + return err + } + // Field #18 'PreviousJustifiedCheckpoint' (static) + if t.PreviousJustifiedCheckpoint == nil { + t.PreviousJustifiedCheckpoint = new(generic.Checkpoint) + } + if err = t.PreviousJustifiedCheckpoint.UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } + // Field #19 'CurrentJustifiedCheckpoint' (static) + if t.CurrentJustifiedCheckpoint == nil { + t.CurrentJustifiedCheckpoint = new(generic.Checkpoint) + } + if err = t.CurrentJustifiedCheckpoint.UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } + // Field #20 'FinalizedCheckpoint' (static) + if t.FinalizedCheckpoint == nil { + t.FinalizedCheckpoint = new(generic.Checkpoint) + } + if err = t.FinalizedCheckpoint.UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") + } + // Field #21 'InactivityScores' (offset) + offset21, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "InactivityScores") + } + if offset21 < offset16 || offset21 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset21, offset16, maxOffset), "InactivityScores") + } + // Field #22 'CurrentSyncCommittee' (static) + if t.CurrentSyncCommittee == nil { + t.CurrentSyncCommittee = new(generic.SyncCommittee) + } + if err = t.CurrentSyncCommittee.UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPath(err, "CurrentSyncCommittee") + } + // Field #23 'NextSyncCommittee' (static) + if t.NextSyncCommittee == nil { + t.NextSyncCommittee = new(generic.SyncCommittee) + } + if err = t.NextSyncCommittee.UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPath(err, "NextSyncCommittee") + } + // Field #24 'LatestExecutionPayloadHeader' (offset) + offset24, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "LatestExecutionPayloadHeader") + } + if offset24 < offset21 || offset24 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset24, offset21, maxOffset), "LatestExecutionPayloadHeader") + } + // Field #25 'NextWithdrawalIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "NextWithdrawalIndex") + } else { + t.NextWithdrawalIndex = val + } + // Field #26 'NextWithdrawalValidatorIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "NextWithdrawalValidatorIndex") + } else { + t.NextWithdrawalValidatorIndex = val + } + // Field #27 'HistoricalSummaries' (offset) + offset27, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "HistoricalSummaries") + } + if offset27 < offset24 || offset27 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset27, offset24, maxOffset), "HistoricalSummaries") + } + { // Field #7 'HistoricalRoots' (dynamic) + if dec.GetPosition() != startPos0+int(offset7) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset7)), "HistoricalRoots") + } + dec.PushLimit(int(offset9 - offset7)) + val5 := t.HistoricalRoots + sszLen := dec.GetLength() + itemCount := sszLen / 32 + if sszLen%32 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 32), "HistoricalRoots") + } + if itemCount > 16777216 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 16777216), "HistoricalRoots") + } + val5 = sszutils.ExpandSlice(val5, itemCount) + startPos4 := dec.GetPosition() + for idx1 := range itemCount { + val5[idx1] = sszutils.ExpandSlice(val5[idx1], 32) + if _, err = dec.DecodeBytes(val5[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos4+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos4+int(32*(idx1+1))), "HistoricalRoots[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "HistoricalRoots") + } + t.HistoricalRoots = val5 + } + { // Field #9 'Eth1DataVotes' (dynamic) + if dec.GetPosition() != startPos0+int(offset9) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset9)), "Eth1DataVotes") + } + dec.PushLimit(int(offset11 - offset9)) + val6 := t.Eth1DataVotes + sszLen := dec.GetLength() + itemCount := sszLen / 72 + if sszLen%72 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 72), "Eth1DataVotes") + } + if itemCount > 2048 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 2048), "Eth1DataVotes") + } + val6 = sszutils.ExpandSlice(val6, itemCount) + startPos5 := dec.GetPosition() + for idx1 := range itemCount { + if val6[idx1] == nil { + val6[idx1] = new(generic.Eth1Data) + } + if err = val6[idx1].UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPathf(err, "Eth1DataVotes[%d]", idx1) + } + if dec.GetPosition() != startPos5+int(72*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos5+int(72*(idx1+1))), "Eth1DataVotes[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Eth1DataVotes") + } + t.Eth1DataVotes = val6 + } + { // Field #11 'Validators' (dynamic) + if dec.GetPosition() != startPos0+int(offset11) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset11)), "Validators") + } + dec.PushLimit(int(offset12 - offset11)) + val7 := t.Validators + sszLen := dec.GetLength() + itemCount := sszLen / 121 + if sszLen%121 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 121), "Validators") + } + if itemCount > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1099511627776), "Validators") + } + val7 = sszutils.ExpandSlice(val7, itemCount) + startPos6 := dec.GetPosition() + for idx1 := range itemCount { + if val7[idx1] == nil { + val7[idx1] = new(generic.Validator) + } + if err = val7[idx1].UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } + if dec.GetPosition() != startPos6+int(121*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos6+int(121*(idx1+1))), "Validators[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Validators") + } + t.Validators = val7 + } + { // Field #12 'Balances' (dynamic) + if dec.GetPosition() != startPos0+int(offset12) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset12)), "Balances") + } + dec.PushLimit(int(offset15 - offset12)) + val8 := t.Balances + sszLen := dec.GetLength() + itemCount := sszLen / 8 + if sszLen%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 8), "Balances") + } + if itemCount > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1099511627776), "Balances") + } + val8 = sszutils.ExpandSlice(val8, itemCount) + if err = sszutils.DecodeUint64Slice(dec, val8); err != nil { + return sszutils.ErrorWithPath(err, "Balances") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Balances") + } + t.Balances = val8 + } + { // Field #15 'PreviousEpochParticipation' (dynamic) + if dec.GetPosition() != startPos0+int(offset15) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset15)), "PreviousEpochParticipation") + } + dec.PushLimit(int(offset16 - offset15)) + val9 := t.PreviousEpochParticipation + if dec.GetLength() > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(dec.GetLength(), 1099511627776), "PreviousEpochParticipation") + } + listLen := dec.GetLength() + val9 = sszutils.ExpandSlice(val9, listLen) + if _, err = dec.DecodeBytes(val9[:listLen]); err != nil { + return sszutils.ErrorWithPath(err, "PreviousEpochParticipation") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "PreviousEpochParticipation") + } + t.PreviousEpochParticipation = val9 + } + { // Field #16 'CurrentEpochParticipation' (dynamic) + if dec.GetPosition() != startPos0+int(offset16) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset16)), "CurrentEpochParticipation") + } + dec.PushLimit(int(offset21 - offset16)) + val10 := t.CurrentEpochParticipation + if dec.GetLength() > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(dec.GetLength(), 1099511627776), "CurrentEpochParticipation") + } + listLen := dec.GetLength() + val10 = sszutils.ExpandSlice(val10, listLen) + if _, err = dec.DecodeBytes(val10[:listLen]); err != nil { + return sszutils.ErrorWithPath(err, "CurrentEpochParticipation") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "CurrentEpochParticipation") + } + t.CurrentEpochParticipation = val10 + } + { // Field #21 'InactivityScores' (dynamic) + if dec.GetPosition() != startPos0+int(offset21) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset21)), "InactivityScores") + } + dec.PushLimit(int(offset24 - offset21)) + val11 := t.InactivityScores + sszLen := dec.GetLength() + itemCount := sszLen / 8 + if sszLen%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 8), "InactivityScores") + } + if itemCount > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1099511627776), "InactivityScores") + } + val11 = sszutils.ExpandSlice(val11, itemCount) + if err = sszutils.DecodeUint64Slice(dec, val11); err != nil { + return sszutils.ErrorWithPath(err, "InactivityScores") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "InactivityScores") + } + t.InactivityScores = val11 + } + { // Field #24 'LatestExecutionPayloadHeader' (dynamic) + if dec.GetPosition() != startPos0+int(offset24) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset24)), "LatestExecutionPayloadHeader") + } + dec.PushLimit(int(offset27 - offset24)) + val12 := t.LatestExecutionPayloadHeader + if val12 == nil { + val12 = new(generic.ExecutionPayloadHeader) + } + if err = val12.UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPath(err, "LatestExecutionPayloadHeader") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "LatestExecutionPayloadHeader") + } + t.LatestExecutionPayloadHeader = val12 + } + { // Field #27 'HistoricalSummaries' (dynamic) + if dec.GetPosition() != startPos0+int(offset27) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset27)), "HistoricalSummaries") + } + dec.PushLimit(int(maxOffset - offset27)) + val13 := t.HistoricalSummaries + sszLen := dec.GetLength() + itemCount := sszLen / 64 + if sszLen%64 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 64), "HistoricalSummaries") + } + if itemCount > 16777216 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 16777216), "HistoricalSummaries") + } + val13 = sszutils.ExpandSlice(val13, itemCount) + startPos7 := dec.GetPosition() + for idx1 := range itemCount { + if val13[idx1] == nil { + val13[idx1] = new(generic.HistoricalSummary) + } + if err = val13[idx1].UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPathf(err, "HistoricalSummaries[%d]", idx1) + } + if dec.GetPosition() != startPos7+int(64*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos7+int(64*(idx1+1))), "HistoricalSummaries[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "HistoricalSummaries") + } + t.HistoricalSummaries = val13 + } + return nil +} + +// SizeSSZDyn returns the SSZ encoded size of the *BeaconState using dynamic specifications. +func (t *BeaconState) SizeSSZDyn(ds sszutils.DynamicSpecs) (size int) { + if t == nil { + t = new(BeaconState) + } + // Field #0 'GenesisTime' static (8 bytes) + // Field #1 'GenesisValidatorsRoot' static (32 bytes) + // Field #2 'Slot' static (8 bytes) + // Field #3 'Fork' static (16 bytes) + // Field #4 'LatestBlockHeader' static (112 bytes) + // Field #5 'BlockRoots' static (262144 bytes) + // Field #6 'StateRoots' static (262144 bytes) + // Field #7 'HistoricalRoots' offset (4 bytes) + // Field #8 'Eth1Data' static (72 bytes) + // Field #9 'Eth1DataVotes' offset (4 bytes) + // Field #10 'Eth1DepositIndex' static (8 bytes) + // Field #11 'Validators' offset (4 bytes) + // Field #12 'Balances' offset (4 bytes) + // Field #13 'RandaoMixes' static (2097152 bytes) + // Field #14 'Slashings' static (65536 bytes) + // Field #15 'PreviousEpochParticipation' offset (4 bytes) + // Field #16 'CurrentEpochParticipation' offset (4 bytes) + // Field #17 'JustificationBits' static (1 bytes) + // Field #18 'PreviousJustifiedCheckpoint' static (40 bytes) + // Field #19 'CurrentJustifiedCheckpoint' static (40 bytes) + // Field #20 'FinalizedCheckpoint' static (40 bytes) + // Field #21 'InactivityScores' offset (4 bytes) + // Field #22 'CurrentSyncCommittee' static (24624 bytes) + // Field #23 'NextSyncCommittee' static (24624 bytes) + // Field #24 'LatestExecutionPayloadHeader' offset (4 bytes) + // Field #25 'NextWithdrawalIndex' static (8 bytes) + // Field #26 'NextWithdrawalValidatorIndex' static (8 bytes) + // Field #27 'HistoricalSummaries' offset (4 bytes) + size += 2736653 + { // Dynamic field #7 'HistoricalRoots' + size += len(t.HistoricalRoots) * 32 + } + { // Dynamic field #9 'Eth1DataVotes' + size += len(t.Eth1DataVotes) * 72 + } + { // Dynamic field #11 'Validators' + size += len(t.Validators) * 121 + } + { // Dynamic field #12 'Balances' + size += len(t.Balances) * 8 + } + { // Dynamic field #15 'PreviousEpochParticipation' + size += len(t.PreviousEpochParticipation) + } + { // Dynamic field #16 'CurrentEpochParticipation' + size += len(t.CurrentEpochParticipation) + } + { // Dynamic field #21 'InactivityScores' + size += len(t.InactivityScores) * 8 + } + { // Dynamic field #24 'LatestExecutionPayloadHeader' + size += t.LatestExecutionPayloadHeader.SizeSSZDyn(ds) + } + { // Dynamic field #27 'HistoricalSummaries' + size += len(t.HistoricalSummaries) * 64 + } + return size +} + +// HashTreeRootDyn computes the SSZ hash tree root of the *BeaconState using dynamic specifications. +func (t *BeaconState) HashTreeRootDyn(ds sszutils.DynamicSpecs) (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWithDyn(ds, hh) + if err == nil { + root, err = hh.HashRoot() + } + return + }) + return +} + +// HashTreeRootWithDyn computes the SSZ hash tree root of the *BeaconState using dynamic specifications and the given hash walker. +func (t *BeaconState) HashTreeRootWithDyn(ds sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + if t == nil { + t = new(BeaconState) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'GenesisTime' + hh.PutUint64(t.GenesisTime) + } + { // Field #1 'GenesisValidatorsRoot' + vlen := len(t.GenesisValidatorsRoot) + if vlen > 32 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 32), "GenesisValidatorsRoot") + } + val := t.GenesisValidatorsRoot[:] + if vlen < 32 { + val = sszutils.AppendZeroPadding(val, (32-vlen)*1) + } + hh.PutBytes(val[:32]) + } + { // Field #2 'Slot' + hh.PutUint64(t.Slot) + } + { // Field #3 'Fork' + t := t.Fork + if t == nil { + t = new(generic.Fork) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPath(err, "Fork") + } + } + { // Field #4 'LatestBlockHeader' + t := t.LatestBlockHeader + if t == nil { + t = new(generic.BeaconBlockHeader) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") + } + } + { // Field #5 'BlockRoots' + t := &t.BlockRoots + idx := hh.StartTree(sszutils.TreeTypeBinary) + var val1 *[32]byte + for idx1 := range 8192 { + if idx1 < 8192 { + val1 = &t[idx1] + } else if idx1 == 8192 { + val1 = new([32]byte) + } + hh.PutBytes(val1[:32]) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.Merkleize(idx) + } + { // Field #6 'StateRoots' + t := &t.StateRoots + idx := hh.StartTree(sszutils.TreeTypeBinary) + var val2 *[32]byte + for idx1 := range 8192 { + if idx1 < 8192 { + val2 = &t[idx1] + } else if idx1 == 8192 { + val2 = new([32]byte) + } + hh.PutBytes(val2[:32]) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.Merkleize(idx) + } + { // Field #7 'HistoricalRoots' + t := t.HistoricalRoots + vlen := uint64(len(t)) + if vlen > 16777216 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16777216), "HistoricalRoots") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + vlen := len(t[idx1]) + if vlen > 32 { + return sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, 32), "HistoricalRoots[%d]", idx1) + } + val := t[idx1][:] + if vlen < 32 { + val = sszutils.AppendZeroPadding(val, (32-vlen)*1) + } + hh.PutBytes(val[:32]) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(16777216, vlen, 32)) + } + { // Field #8 'Eth1Data' + t := t.Eth1Data + if t == nil { + t = new(generic.Eth1Data) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPath(err, "Eth1Data") + } + } + { // Field #9 'Eth1DataVotes' + t := t.Eth1DataVotes + vlen := uint64(len(t)) + if vlen > 2048 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 2048), "Eth1DataVotes") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(generic.Eth1Data) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPathf(err, "Eth1DataVotes[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(2048, vlen, 32)) + } + { // Field #10 'Eth1DepositIndex' + hh.PutUint64(t.Eth1DepositIndex) + } + { // Field #11 'Validators' + t := t.Validators + vlen := uint64(len(t)) + if vlen > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1099511627776), "Validators") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(generic.Validator) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(1099511627776, vlen, 32)) + } + { // Field #12 'Balances' + t := t.Balances + vlen := uint64(len(t)) + if vlen > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1099511627776), "Balances") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + sszutils.HashUint64Slice(hh, t) + hh.FillUpTo32() + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(1099511627776, vlen, 8)) + } + { // Field #13 'RandaoMixes' + t := t.RandaoMixes + vlen := len(t) + if vlen > 65536 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 65536), "RandaoMixes") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + var val3, val3Empty []byte + for idx1 := range 65536 { + if idx1 < vlen { + val3 = t[idx1] + } else if idx1 == vlen { + val3 = val3Empty + } + vlen := len(val3) + if vlen > 32 { + return sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, 32), "RandaoMixes[%d]", idx1) + } + val := val3[:] + if vlen < 32 { + val = sszutils.AppendZeroPadding(val, (32-vlen)*1) + } + hh.PutBytes(val[:32]) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.Merkleize(idx) + } + { // Field #14 'Slashings' + t := t.Slashings + vlen := len(t) + if vlen > 8192 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 8192), "Slashings") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + var val4, val4Empty uint64 + for idx1 := range 8192 { + if idx1 < vlen { + val4 = t[idx1] + } else if idx1 == vlen { + val4 = val4Empty + } + hh.AppendUint64(val4) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.FillUpTo32() + hh.Merkleize(idx) + } + { // Field #15 'PreviousEpochParticipation' + vlen := uint64(len(t.PreviousEpochParticipation)) + if vlen > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1099511627776), "PreviousEpochParticipation") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + hh.AppendBytes32(t.PreviousEpochParticipation[:]) + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(1099511627776, vlen, 1)) + } + { // Field #16 'CurrentEpochParticipation' + vlen := uint64(len(t.CurrentEpochParticipation)) + if vlen > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1099511627776), "CurrentEpochParticipation") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + hh.AppendBytes32(t.CurrentEpochParticipation[:]) + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(1099511627776, vlen, 1)) + } + { // Field #17 'JustificationBits' + hh.PutBytes(t.JustificationBits[:1]) + } + { // Field #18 'PreviousJustifiedCheckpoint' + t := t.PreviousJustifiedCheckpoint + if t == nil { + t = new(generic.Checkpoint) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } + } + { // Field #19 'CurrentJustifiedCheckpoint' + t := t.CurrentJustifiedCheckpoint + if t == nil { + t = new(generic.Checkpoint) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } + } + { // Field #20 'FinalizedCheckpoint' + t := t.FinalizedCheckpoint + if t == nil { + t = new(generic.Checkpoint) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") + } + } + { // Field #21 'InactivityScores' + t := t.InactivityScores + vlen := uint64(len(t)) + if vlen > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1099511627776), "InactivityScores") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + sszutils.HashUint64Slice(hh, t) + hh.FillUpTo32() + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(1099511627776, vlen, 8)) + } + { // Field #22 'CurrentSyncCommittee' + t := t.CurrentSyncCommittee + if t == nil { + t = new(generic.SyncCommittee) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPath(err, "CurrentSyncCommittee") + } + } + { // Field #23 'NextSyncCommittee' + t := t.NextSyncCommittee + if t == nil { + t = new(generic.SyncCommittee) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPath(err, "NextSyncCommittee") + } + } + { // Field #24 'LatestExecutionPayloadHeader' + t := t.LatestExecutionPayloadHeader + if t == nil { + t = new(generic.ExecutionPayloadHeader) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPath(err, "LatestExecutionPayloadHeader") + } + } + { // Field #25 'NextWithdrawalIndex' + hh.PutUint64(t.NextWithdrawalIndex) + } + { // Field #26 'NextWithdrawalValidatorIndex' + hh.PutUint64(t.NextWithdrawalValidatorIndex) + } + { // Field #27 'HistoricalSummaries' + t := t.HistoricalSummaries + vlen := uint64(len(t)) + if vlen > 16777216 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16777216), "HistoricalSummaries") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(generic.HistoricalSummary) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPathf(err, "HistoricalSummaries[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(16777216, vlen, 32)) + } + hh.Merkleize(idx) + return nil +} + +// MarshalSSZDyn marshals the *SignedBeaconBlock to SSZ-encoded bytes using dynamic specifications. +func (t *SignedBeaconBlock) MarshalSSZDyn(ds sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + dst = buf + if t == nil { + t = new(SignedBeaconBlock) + } + dstlen := len(dst) + // Offset Field #0 'Block' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #1 'Signature' + vlen := len(t.Signature) + if vlen > 96 { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 96), "Signature") + } + dst = append(dst, t.Signature[:vlen]...) + if vlen < 96 { + dst = sszutils.AppendZeroPadding(dst, (96-vlen)*1) + } + } + { // Dynamic Field #0 'Block' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.Block + if t == nil { + t = new(BeaconBlock) + } + if dst, err = t.MarshalSSZDyn(ds, dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "Block") + } + } + return dst, nil +} + +// MarshalSSZEncoder marshals the *SignedBeaconBlock to the given SSZ encoder using dynamic specifications. +func (t *SignedBeaconBlock) MarshalSSZEncoder(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + type encoderCtx struct { + ds sszutils.DynamicSpecs + exprs [0]uint64 + sizeFn1 func(ctx *encoderCtx, t *BeaconBlock) (size int) + } + ctx := &encoderCtx{ds: ds} + canSeek := enc.Seekable() + // size for *BeaconBlock + ctx.sizeFn1 = func(ctx *encoderCtx, t *BeaconBlock) (size int) { + size += t.SizeSSZDyn(ds) + return size + } + if t == nil { + t = new(SignedBeaconBlock) + } + dstlen := enc.GetPosition() + dynoff := uint32(100) + // Offset #0 'Block' + offset0 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn1(ctx, t.Block)) + } + { // Field #1 'Signature' + vlen := len(t.Signature) + if vlen > 96 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 96), "Signature") + } + enc.EncodeBytes(t.Signature[:vlen]) + if vlen < 96 { + enc.EncodeZeroPadding((96 - vlen) * 1) + } + } + { // Dynamic Field #0 'Block' + if canSeek { + enc.EncodeOffsetAt(offset0, uint32(enc.GetPosition()-dstlen)) + } + t := t.Block + if t == nil { + t = new(BeaconBlock) + } + if err = t.MarshalSSZEncoder(ds, enc); err != nil { + return sszutils.ErrorWithPath(err, "Block") + } + } + return nil +} + +// UnmarshalSSZDyn unmarshals the *SignedBeaconBlock from SSZ-encoded bytes using dynamic specifications. +func (t *SignedBeaconBlock) UnmarshalSSZDyn(ds sszutils.DynamicSpecs, buf []byte) (err error) { + buflen := len(buf) + if buflen < 100 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 100) + } + // Field #0 'Block' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 100 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset0, 100), "Block:o") + } + { // Field #1 'Signature' (static) + buf := buf[4:100] + t.Signature = sszutils.ExpandSlice(t.Signature, 96) + copy(t.Signature[:], buf) + } + { // Field #0 'Block' (dynamic) + buf := buf[offset0:] + if t.Block == nil { + t.Block = new(BeaconBlock) + } + if err = t.Block.UnmarshalSSZDyn(ds, buf); err != nil { + return sszutils.ErrorWithPath(err, "Block") + } + } + return nil +} + +// UnmarshalSSZDecoder unmarshals the *SignedBeaconBlock from the given SSZ decoder using dynamic specifications. +func (t *SignedBeaconBlock) UnmarshalSSZDecoder(ds sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { + maxOffset := uint32(dec.GetLength()) + startPos0 := dec.GetPosition() + if maxOffset < uint32(100) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(100)) + } + // Field #0 'Block' (offset) + offset0, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Block") + } + if offset0 != uint32(100) { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset0, 100), "Block") + } + // Field #1 'Signature' (static) + t.Signature = sszutils.ExpandSlice(t.Signature, 96) + if _, err = dec.DecodeBytes(t.Signature[:96]); err != nil { + return err + } + { // Field #0 'Block' (dynamic) + if dec.GetPosition() != startPos0+int(offset0) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset0)), "Block") + } + dec.PushLimit(int(maxOffset - offset0)) + val1 := t.Block + if val1 == nil { + val1 = new(BeaconBlock) + } + if err = val1.UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPath(err, "Block") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Block") + } + t.Block = val1 + } + return nil +} + +// SizeSSZDyn returns the SSZ encoded size of the *SignedBeaconBlock using dynamic specifications. +func (t *SignedBeaconBlock) SizeSSZDyn(ds sszutils.DynamicSpecs) (size int) { + if t == nil { + t = new(SignedBeaconBlock) + } + // Field #0 'Block' offset (4 bytes) + // Field #1 'Signature' static (96 bytes) + size += 100 + { // Dynamic field #0 'Block' + size += t.Block.SizeSSZDyn(ds) + } + return size +} + +// HashTreeRootDyn computes the SSZ hash tree root of the *SignedBeaconBlock using dynamic specifications. +func (t *SignedBeaconBlock) HashTreeRootDyn(ds sszutils.DynamicSpecs) (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWithDyn(ds, hh) + if err == nil { + root, err = hh.HashRoot() + } + return + }) + return +} + +// HashTreeRootWithDyn computes the SSZ hash tree root of the *SignedBeaconBlock using dynamic specifications and the given hash walker. +func (t *SignedBeaconBlock) HashTreeRootWithDyn(ds sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + if t == nil { + t = new(SignedBeaconBlock) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Block' + t := t.Block + if t == nil { + t = new(BeaconBlock) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPath(err, "Block") + } + } + { // Field #1 'Signature' + vlen := len(t.Signature) + if vlen > 96 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 96), "Signature") + } + val := t.Signature[:] + if vlen < 96 { + val = sszutils.AppendZeroPadding(val, (96-vlen)*1) + } + hh.PutBytes(val[:96]) + } + hh.Merkleize(idx) + return nil +} + +// MarshalSSZDyn marshals the *BeaconBlock to SSZ-encoded bytes using dynamic specifications. +func (t *BeaconBlock) MarshalSSZDyn(ds sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + dst = buf + if t == nil { + t = new(BeaconBlock) + } + dstlen := len(dst) + { // Static Field #0 'Slot' + dst = binary.LittleEndian.AppendUint64(dst, t.Slot) + } + { // Static Field #1 'ProposerIndex' + dst = binary.LittleEndian.AppendUint64(dst, t.ProposerIndex) + } + { // Static Field #2 'ParentRoot' + dst = append(dst, t.ParentRoot[:32]...) + } + { // Static Field #3 'StateRoot' + dst = append(dst, t.StateRoot[:32]...) + } + // Offset Field #4 'Body' + dst = append(dst, 0, 0, 0, 0) + { // Dynamic Field #4 'Body' + binary.LittleEndian.PutUint32(dst[dstlen+80:], uint32(len(dst)-dstlen)) + t := t.Body + if t == nil { + t = new(BeaconBlockBody) + } + if dst, err = t.MarshalSSZDyn(ds, dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "Body") + } + } + return dst, nil +} + +// MarshalSSZEncoder marshals the *BeaconBlock to the given SSZ encoder using dynamic specifications. +func (t *BeaconBlock) MarshalSSZEncoder(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + type encoderCtx struct { + ds sszutils.DynamicSpecs + exprs [0]uint64 + sizeFn1 func(ctx *encoderCtx, t *BeaconBlockBody) (size int) + } + ctx := &encoderCtx{ds: ds} + canSeek := enc.Seekable() + // size for *BeaconBlockBody + ctx.sizeFn1 = func(ctx *encoderCtx, t *BeaconBlockBody) (size int) { + size += t.SizeSSZDyn(ds) + return size + } + if t == nil { + t = new(BeaconBlock) + } + dstlen := enc.GetPosition() + dynoff := uint32(84) + { // Field #0 'Slot' + enc.EncodeUint64(t.Slot) + } + { // Field #1 'ProposerIndex' + enc.EncodeUint64(t.ProposerIndex) + } + { // Field #2 'ParentRoot' + enc.EncodeBytes(t.ParentRoot[:32]) + } + { // Field #3 'StateRoot' + enc.EncodeBytes(t.StateRoot[:32]) + } + // Offset #4 'Body' + offset4 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn1(ctx, t.Body)) + } + { // Dynamic Field #4 'Body' + if canSeek { + enc.EncodeOffsetAt(offset4, uint32(enc.GetPosition()-dstlen)) + } + t := t.Body + if t == nil { + t = new(BeaconBlockBody) + } + if err = t.MarshalSSZEncoder(ds, enc); err != nil { + return sszutils.ErrorWithPath(err, "Body") + } + } + return nil +} + +// UnmarshalSSZDyn unmarshals the *BeaconBlock from SSZ-encoded bytes using dynamic specifications. +func (t *BeaconBlock) UnmarshalSSZDyn(ds sszutils.DynamicSpecs, buf []byte) (err error) { + buflen := len(buf) + if buflen < 84 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 84) + } + { // Field #0 'Slot' (static) + buf := buf[0:8] + t.Slot = binary.LittleEndian.Uint64(buf) + } + { // Field #1 'ProposerIndex' (static) + buf := buf[8:16] + t.ProposerIndex = binary.LittleEndian.Uint64(buf) + } + { // Field #2 'ParentRoot' (static) + buf := buf[16:48] + copy(t.ParentRoot[:], buf) + } + { // Field #3 'StateRoot' (static) + buf := buf[48:80] + copy(t.StateRoot[:], buf) + } + // Field #4 'Body' (offset) + offset4 := int(binary.LittleEndian.Uint32(buf[80:84])) + if offset4 != 84 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset4, 84), "Body:o") + } + { // Field #4 'Body' (dynamic) + buf := buf[offset4:] + if t.Body == nil { + t.Body = new(BeaconBlockBody) + } + if err = t.Body.UnmarshalSSZDyn(ds, buf); err != nil { + return sszutils.ErrorWithPath(err, "Body") + } + } + return nil +} + +// UnmarshalSSZDecoder unmarshals the *BeaconBlock from the given SSZ decoder using dynamic specifications. +func (t *BeaconBlock) UnmarshalSSZDecoder(ds sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { + maxOffset := uint32(dec.GetLength()) + startPos0 := dec.GetPosition() + if maxOffset < uint32(84) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(84)) + } + // Field #0 'Slot' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "Slot") + } else { + t.Slot = val + } + // Field #1 'ProposerIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "ProposerIndex") + } else { + t.ProposerIndex = val + } + // Field #2 'ParentRoot' (static) + if _, err = dec.DecodeBytes(t.ParentRoot[:32]); err != nil { + return err + } + // Field #3 'StateRoot' (static) + if _, err = dec.DecodeBytes(t.StateRoot[:32]); err != nil { + return err + } + // Field #4 'Body' (offset) + offset4, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Body") + } + if offset4 != uint32(84) { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset4, 84), "Body") + } + { // Field #4 'Body' (dynamic) + if dec.GetPosition() != startPos0+int(offset4) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset4)), "Body") + } + dec.PushLimit(int(maxOffset - offset4)) + val1 := t.Body + if val1 == nil { + val1 = new(BeaconBlockBody) + } + if err = val1.UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPath(err, "Body") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Body") + } + t.Body = val1 + } + return nil +} + +// SizeSSZDyn returns the SSZ encoded size of the *BeaconBlock using dynamic specifications. +func (t *BeaconBlock) SizeSSZDyn(ds sszutils.DynamicSpecs) (size int) { + if t == nil { + t = new(BeaconBlock) + } + // Field #0 'Slot' static (8 bytes) + // Field #1 'ProposerIndex' static (8 bytes) + // Field #2 'ParentRoot' static (32 bytes) + // Field #3 'StateRoot' static (32 bytes) + // Field #4 'Body' offset (4 bytes) + size += 84 + { // Dynamic field #4 'Body' + size += t.Body.SizeSSZDyn(ds) + } + return size +} + +// HashTreeRootDyn computes the SSZ hash tree root of the *BeaconBlock using dynamic specifications. +func (t *BeaconBlock) HashTreeRootDyn(ds sszutils.DynamicSpecs) (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWithDyn(ds, hh) + if err == nil { + root, err = hh.HashRoot() + } + return + }) + return +} + +// HashTreeRootWithDyn computes the SSZ hash tree root of the *BeaconBlock using dynamic specifications and the given hash walker. +func (t *BeaconBlock) HashTreeRootWithDyn(ds sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + if t == nil { + t = new(BeaconBlock) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Slot' + hh.PutUint64(t.Slot) + } + { // Field #1 'ProposerIndex' + hh.PutUint64(t.ProposerIndex) + } + { // Field #2 'ParentRoot' + hh.PutBytes(t.ParentRoot[:32]) + } + { // Field #3 'StateRoot' + hh.PutBytes(t.StateRoot[:32]) + } + { // Field #4 'Body' + t := t.Body + if t == nil { + t = new(BeaconBlockBody) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPath(err, "Body") + } + } + hh.Merkleize(idx) + return nil +} + +// MarshalSSZDyn marshals the *BeaconBlockBody to SSZ-encoded bytes using dynamic specifications. +func (t *BeaconBlockBody) MarshalSSZDyn(ds sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + dst = buf + zeroBytes := sszutils.ZeroBytes() + if t == nil { + t = new(BeaconBlockBody) + } + dstlen := len(dst) + { // Static Field #0 'RandaoReveal' + vlen := len(t.RandaoReveal) + if vlen > 96 { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 96), "RandaoReveal") + } + dst = append(dst, t.RandaoReveal[:vlen]...) + if vlen < 96 { + dst = sszutils.AppendZeroPadding(dst, (96-vlen)*1) + } + } + { // Static Field #1 'Eth1Data' + t := t.Eth1Data + if t == nil { + t = new(generic.Eth1Data) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "Eth1Data") + } + } + { // Static Field #2 'Graffiti' + dst = append(dst, t.Graffiti[:32]...) + } + // Offset Field #3 'ProposerSlashings' + // Offset Field #4 'AttesterSlashings' + // Offset Field #5 'Attestations' + // Offset Field #6 'Deposits' + // Offset Field #7 'VoluntaryExits' + dst = append(dst, zeroBytes[:20]...) + { // Static Field #8 'SyncAggregate' + t := t.SyncAggregate + if t == nil { + t = new(generic.SyncAggregate) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "SyncAggregate") + } + } + // Offset Field #9 'ExecutionPayload' + // Offset Field #10 'BlsToExecutionChanges' + // Offset Field #11 'BlobKzgCommitments' + dst = append(dst, zeroBytes[:12]...) + { // Dynamic Field #3 'ProposerSlashings' + binary.LittleEndian.PutUint32(dst[dstlen+200:], uint32(len(dst)-dstlen)) + t := t.ProposerSlashings + vlen := len(t) + if vlen > 16 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16), "ProposerSlashings") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(generic.ProposerSlashing) + } + if dst, err = t.MarshalSSZDyn(ds, dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "ProposerSlashings[%d]", idx1) + } + } + } + { // Dynamic Field #4 'AttesterSlashings' + binary.LittleEndian.PutUint32(dst[dstlen+204:], uint32(len(dst)-dstlen)) + t := t.AttesterSlashings + vlen := len(t) + if vlen > 2 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 2), "AttesterSlashings") + } + dstlen := len(dst) + dst = sszutils.AppendZeroPadding(dst, vlen*4) + for idx1 := range vlen { + binary.LittleEndian.PutUint32(dst[dstlen+(idx1*4):], uint32(len(dst)-dstlen)) + t := t[idx1] + if t == nil { + t = new(generic.AttesterSlashing) + } + if dst, err = t.MarshalSSZDyn(ds, dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "AttesterSlashings[%d]", idx1) + } + } + } + { // Dynamic Field #5 'Attestations' + binary.LittleEndian.PutUint32(dst[dstlen+208:], uint32(len(dst)-dstlen)) + t := t.Attestations + vlen := len(t) + if vlen > 128 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 128), "Attestations") + } + dstlen := len(dst) + dst = sszutils.AppendZeroPadding(dst, vlen*4) + for idx1 := range vlen { + binary.LittleEndian.PutUint32(dst[dstlen+(idx1*4):], uint32(len(dst)-dstlen)) + t := t[idx1] + if t == nil { + t = new(generic.Attestation) + } + if dst, err = t.MarshalSSZDyn(ds, dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "Attestations[%d]", idx1) + } + } + } + { // Dynamic Field #6 'Deposits' + binary.LittleEndian.PutUint32(dst[dstlen+212:], uint32(len(dst)-dstlen)) + t := t.Deposits + vlen := len(t) + if vlen > 16 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16), "Deposits") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(generic.Deposit) + } + if dst, err = t.MarshalSSZDyn(ds, dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "Deposits[%d]", idx1) + } + } + } + { // Dynamic Field #7 'VoluntaryExits' + binary.LittleEndian.PutUint32(dst[dstlen+216:], uint32(len(dst)-dstlen)) + t := t.VoluntaryExits + vlen := len(t) + if vlen > 16 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16), "VoluntaryExits") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(generic.SignedVoluntaryExit) + } + if dst, err = t.MarshalSSZDyn(ds, dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "VoluntaryExits[%d]", idx1) + } + } + } + { // Dynamic Field #9 'ExecutionPayload' + binary.LittleEndian.PutUint32(dst[dstlen+380:], uint32(len(dst)-dstlen)) + t := t.ExecutionPayload + if t == nil { + t = new(ExecutionPayload) + } + if dst, err = t.MarshalSSZDyn(ds, dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "ExecutionPayload") + } + } + { // Dynamic Field #10 'BlsToExecutionChanges' + binary.LittleEndian.PutUint32(dst[dstlen+384:], uint32(len(dst)-dstlen)) + t := t.BlsToExecutionChanges + vlen := len(t) + if vlen > 16 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16), "BlsToExecutionChanges") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(generic.SignedBLSToExecutionChange) + } + if dst, err = t.MarshalSSZDyn(ds, dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "BlsToExecutionChanges[%d]", idx1) + } + } + } + { // Dynamic Field #11 'BlobKzgCommitments' + binary.LittleEndian.PutUint32(dst[dstlen+388:], uint32(len(dst)-dstlen)) + t := t.BlobKzgCommitments + vlen := len(t) + if vlen > 4096 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 4096), "BlobKzgCommitments") + } + dst = sszutils.MarshalFixedBytesSlice(dst, t[:vlen]) + } + return dst, nil +} + +// MarshalSSZEncoder marshals the *BeaconBlockBody to the given SSZ encoder using dynamic specifications. +func (t *BeaconBlockBody) MarshalSSZEncoder(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + type encoderCtx struct { + ds sszutils.DynamicSpecs + exprs [0]uint64 + sizeFn1 func(ctx *encoderCtx, t []*generic.ProposerSlashing) (size int) + sizeFn10 func(ctx *encoderCtx, t *generic.Attestation) (size int) + sizeFn2 func(ctx *encoderCtx, t []*generic.AttesterSlashing) (size int) + sizeFn3 func(ctx *encoderCtx, t []*generic.Attestation) (size int) + sizeFn4 func(ctx *encoderCtx, t []*generic.Deposit) (size int) + sizeFn5 func(ctx *encoderCtx, t []*generic.SignedVoluntaryExit) (size int) + sizeFn6 func(ctx *encoderCtx, t *ExecutionPayload) (size int) + sizeFn7 func(ctx *encoderCtx, t []*generic.SignedBLSToExecutionChange) (size int) + sizeFn8 func(ctx *encoderCtx, t [][48]byte) (size int) + sizeFn9 func(ctx *encoderCtx, t *generic.AttesterSlashing) (size int) + } + ctx := &encoderCtx{ds: ds} + canSeek := enc.Seekable() + // size for []*generic.ProposerSlashing + ctx.sizeFn1 = func(ctx *encoderCtx, t []*generic.ProposerSlashing) (size int) { + size += len(t) * 416 + return size + } + // size for []*generic.AttesterSlashing + ctx.sizeFn2 = func(ctx *encoderCtx, t []*generic.AttesterSlashing) (size int) { + vlen := len(t) + size += vlen * 4 // Offsets + for i1 := range vlen { + size += ctx.sizeFn9(ctx, t[i1]) + } + return size + } + // size for []*generic.Attestation + ctx.sizeFn3 = func(ctx *encoderCtx, t []*generic.Attestation) (size int) { + vlen := len(t) + size += vlen * 4 // Offsets + for i1 := range vlen { + size += ctx.sizeFn10(ctx, t[i1]) + } + return size + } + // size for []*generic.Deposit + ctx.sizeFn4 = func(ctx *encoderCtx, t []*generic.Deposit) (size int) { + size += len(t) * 1240 + return size + } + // size for []*generic.SignedVoluntaryExit + ctx.sizeFn5 = func(ctx *encoderCtx, t []*generic.SignedVoluntaryExit) (size int) { + size += len(t) * 112 + return size + } + // size for *ExecutionPayload + ctx.sizeFn6 = func(ctx *encoderCtx, t *ExecutionPayload) (size int) { + size += t.SizeSSZDyn(ds) + return size + } + // size for []*generic.SignedBLSToExecutionChange + ctx.sizeFn7 = func(ctx *encoderCtx, t []*generic.SignedBLSToExecutionChange) (size int) { + size += len(t) * 172 + return size + } + // size for [][48]byte + ctx.sizeFn8 = func(ctx *encoderCtx, t [][48]byte) (size int) { + size += len(t) * 48 + return size + } + // size for *generic.AttesterSlashing + ctx.sizeFn9 = func(ctx *encoderCtx, t *generic.AttesterSlashing) (size int) { + size += t.SizeSSZDyn(ds) + return size + } + // size for *generic.Attestation + ctx.sizeFn10 = func(ctx *encoderCtx, t *generic.Attestation) (size int) { + size += t.SizeSSZDyn(ds) + return size + } + if t == nil { + t = new(BeaconBlockBody) + } + dstlen := enc.GetPosition() + dynoff := uint32(392) + { // Field #0 'RandaoReveal' + vlen := len(t.RandaoReveal) + if vlen > 96 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 96), "RandaoReveal") + } + enc.EncodeBytes(t.RandaoReveal[:vlen]) + if vlen < 96 { + enc.EncodeZeroPadding((96 - vlen) * 1) + } + } + { // Field #1 'Eth1Data' + t := t.Eth1Data + if t == nil { + t = new(generic.Eth1Data) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "Eth1Data") + } else { + enc.SetBuffer(buf) + } + } + { // Field #2 'Graffiti' + enc.EncodeBytes(t.Graffiti[:32]) + } + // Offset #3 'ProposerSlashings' + offset3 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn1(ctx, t.ProposerSlashings)) + } + // Offset #4 'AttesterSlashings' + offset4 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn2(ctx, t.AttesterSlashings)) + } + // Offset #5 'Attestations' + offset5 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn3(ctx, t.Attestations)) + } + // Offset #6 'Deposits' + offset6 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn4(ctx, t.Deposits)) + } + // Offset #7 'VoluntaryExits' + offset7 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn5(ctx, t.VoluntaryExits)) + } + { // Field #8 'SyncAggregate' + t := t.SyncAggregate + if t == nil { + t = new(generic.SyncAggregate) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "SyncAggregate") + } else { + enc.SetBuffer(buf) + } + } + // Offset #9 'ExecutionPayload' + offset9 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn6(ctx, t.ExecutionPayload)) + } + // Offset #10 'BlsToExecutionChanges' + offset10 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn7(ctx, t.BlsToExecutionChanges)) + } + // Offset #11 'BlobKzgCommitments' + offset11 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn8(ctx, t.BlobKzgCommitments)) + } + { // Dynamic Field #3 'ProposerSlashings' + if canSeek { + enc.EncodeOffsetAt(offset3, uint32(enc.GetPosition()-dstlen)) + } + t := t.ProposerSlashings + vlen := len(t) + if vlen > 16 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16), "ProposerSlashings") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(generic.ProposerSlashing) + } + if err = t.MarshalSSZEncoder(ds, enc); err != nil { + return sszutils.ErrorWithPathf(err, "ProposerSlashings[%d]", idx1) + } + } + } + { // Dynamic Field #4 'AttesterSlashings' + if canSeek { + enc.EncodeOffsetAt(offset4, uint32(enc.GetPosition()-dstlen)) + } + t := t.AttesterSlashings + vlen := len(t) + if vlen > 2 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 2), "AttesterSlashings") + } + dstlen := enc.GetPosition() + if canSeek { + enc.EncodeZeroPadding(vlen * 4) + } else if vlen > 0 { + offset := vlen * 4 + enc.EncodeOffset(uint32(offset)) + for i := range vlen - 1 { + offset += ctx.sizeFn9(ctx, t[i]) + enc.EncodeOffset(uint32(offset)) + } + } + for idx1 := range vlen { + if canSeek { + enc.EncodeOffsetAt(dstlen+(idx1*4), uint32(enc.GetPosition()-dstlen)) + } + t := t[idx1] + if t == nil { + t = new(generic.AttesterSlashing) + } + if err = t.MarshalSSZEncoder(ds, enc); err != nil { + return sszutils.ErrorWithPathf(err, "AttesterSlashings[%d]", idx1) + } + } + } + { // Dynamic Field #5 'Attestations' + if canSeek { + enc.EncodeOffsetAt(offset5, uint32(enc.GetPosition()-dstlen)) + } + t := t.Attestations + vlen := len(t) + if vlen > 128 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 128), "Attestations") + } + dstlen := enc.GetPosition() + if canSeek { + enc.EncodeZeroPadding(vlen * 4) + } else if vlen > 0 { + offset := vlen * 4 + enc.EncodeOffset(uint32(offset)) + for i := range vlen - 1 { + offset += ctx.sizeFn10(ctx, t[i]) + enc.EncodeOffset(uint32(offset)) + } + } + for idx1 := range vlen { + if canSeek { + enc.EncodeOffsetAt(dstlen+(idx1*4), uint32(enc.GetPosition()-dstlen)) + } + t := t[idx1] + if t == nil { + t = new(generic.Attestation) + } + if err = t.MarshalSSZEncoder(ds, enc); err != nil { + return sszutils.ErrorWithPathf(err, "Attestations[%d]", idx1) + } + } + } + { // Dynamic Field #6 'Deposits' + if canSeek { + enc.EncodeOffsetAt(offset6, uint32(enc.GetPosition()-dstlen)) + } + t := t.Deposits + vlen := len(t) + if vlen > 16 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16), "Deposits") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(generic.Deposit) + } + if err = t.MarshalSSZEncoder(ds, enc); err != nil { + return sszutils.ErrorWithPathf(err, "Deposits[%d]", idx1) + } + } + } + { // Dynamic Field #7 'VoluntaryExits' + if canSeek { + enc.EncodeOffsetAt(offset7, uint32(enc.GetPosition()-dstlen)) + } + t := t.VoluntaryExits + vlen := len(t) + if vlen > 16 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16), "VoluntaryExits") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(generic.SignedVoluntaryExit) + } + if err = t.MarshalSSZEncoder(ds, enc); err != nil { + return sszutils.ErrorWithPathf(err, "VoluntaryExits[%d]", idx1) + } + } + } + { // Dynamic Field #9 'ExecutionPayload' + if canSeek { + enc.EncodeOffsetAt(offset9, uint32(enc.GetPosition()-dstlen)) + } + t := t.ExecutionPayload + if t == nil { + t = new(ExecutionPayload) + } + if err = t.MarshalSSZEncoder(ds, enc); err != nil { + return sszutils.ErrorWithPath(err, "ExecutionPayload") + } + } + { // Dynamic Field #10 'BlsToExecutionChanges' + if canSeek { + enc.EncodeOffsetAt(offset10, uint32(enc.GetPosition()-dstlen)) + } + t := t.BlsToExecutionChanges + vlen := len(t) + if vlen > 16 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16), "BlsToExecutionChanges") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(generic.SignedBLSToExecutionChange) + } + if err = t.MarshalSSZEncoder(ds, enc); err != nil { + return sszutils.ErrorWithPathf(err, "BlsToExecutionChanges[%d]", idx1) + } + } + } + { // Dynamic Field #11 'BlobKzgCommitments' + if canSeek { + enc.EncodeOffsetAt(offset11, uint32(enc.GetPosition()-dstlen)) + } + t := t.BlobKzgCommitments + vlen := len(t) + if vlen > 4096 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 4096), "BlobKzgCommitments") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:48]) + } + } + return nil +} + +// UnmarshalSSZDyn unmarshals the *BeaconBlockBody from SSZ-encoded bytes using dynamic specifications. +func (t *BeaconBlockBody) UnmarshalSSZDyn(ds sszutils.DynamicSpecs, buf []byte) (err error) { + buflen := len(buf) + if buflen < 392 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 392) + } + { // Field #0 'RandaoReveal' (static) + buf := buf[0:96] + t.RandaoReveal = sszutils.ExpandSlice(t.RandaoReveal, 96) + copy(t.RandaoReveal[:], buf) + } + { // Field #1 'Eth1Data' (static) + buf := buf[96:168] + if t.Eth1Data == nil { + t.Eth1Data = new(generic.Eth1Data) + } + if err = t.Eth1Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "Eth1Data") + } + } + { // Field #2 'Graffiti' (static) + buf := buf[168:200] + copy(t.Graffiti[:], buf) + } + // Field #3 'ProposerSlashings' (offset) + offset3 := int(binary.LittleEndian.Uint32(buf[200:204])) + if offset3 != 392 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset3, 392), "ProposerSlashings:o") + } + // Field #4 'AttesterSlashings' (offset) + offset4 := int(binary.LittleEndian.Uint32(buf[204:208])) + if offset4 < offset3 || offset4 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset4, offset3, buflen), "AttesterSlashings:o") + } + // Field #5 'Attestations' (offset) + offset5 := int(binary.LittleEndian.Uint32(buf[208:212])) + if offset5 < offset4 || offset5 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset5, offset4, buflen), "Attestations:o") + } + // Field #6 'Deposits' (offset) + offset6 := int(binary.LittleEndian.Uint32(buf[212:216])) + if offset6 < offset5 || offset6 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset6, offset5, buflen), "Deposits:o") + } + // Field #7 'VoluntaryExits' (offset) + offset7 := int(binary.LittleEndian.Uint32(buf[216:220])) + if offset7 < offset6 || offset7 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset7, offset6, buflen), "VoluntaryExits:o") + } + { // Field #8 'SyncAggregate' (static) + buf := buf[220:380] + if t.SyncAggregate == nil { + t.SyncAggregate = new(generic.SyncAggregate) + } + if err = t.SyncAggregate.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "SyncAggregate") + } + } + // Field #9 'ExecutionPayload' (offset) + offset9 := int(binary.LittleEndian.Uint32(buf[380:384])) + if offset9 < offset7 || offset9 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset9, offset7, buflen), "ExecutionPayload:o") + } + // Field #10 'BlsToExecutionChanges' (offset) + offset10 := int(binary.LittleEndian.Uint32(buf[384:388])) + if offset10 < offset9 || offset10 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset10, offset9, buflen), "BlsToExecutionChanges:o") + } + // Field #11 'BlobKzgCommitments' (offset) + offset11 := int(binary.LittleEndian.Uint32(buf[388:392])) + if offset11 < offset10 || offset11 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset11, offset10, buflen), "BlobKzgCommitments:o") + } + { // Field #3 'ProposerSlashings' (dynamic) + buf := buf[offset3:offset4] + val1 := t.ProposerSlashings + itemCount := len(buf) / 416 + if len(buf)%416 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 416), "ProposerSlashings") + } + if itemCount > 16 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 16), "ProposerSlashings") + } + val1 = sszutils.ExpandSlice(val1, itemCount) + for idx1 := range itemCount { + if val1[idx1] == nil { + val1[idx1] = new(generic.ProposerSlashing) + } + buf := buf[416*idx1 : 416*(idx1+1)] + if err = val1[idx1].UnmarshalSSZDyn(ds, buf); err != nil { + return sszutils.ErrorWithPathf(err, "ProposerSlashings[%d]", idx1) + } + } + t.ProposerSlashings = val1 + } + { // Field #4 'AttesterSlashings' (dynamic) + buf := buf[offset4:offset5] + val2 := t.AttesterSlashings + startOffset := int(0) + if len(buf) != 0 { + if len(buf) < 4 { + return sszutils.ErrorWithPath(sszutils.ErrListOffsetsEOFFn(len(buf), 4), "AttesterSlashings") + } + startOffset = int(binary.LittleEndian.Uint32(buf[0:4])) + } + itemCount := startOffset / 4 + if startOffset%4 != 0 || len(buf) < startOffset || (len(buf) != 0 && startOffset == 0) { + return sszutils.ErrorWithPath(sszutils.ErrInvalidListStartOffsetFn(startOffset, len(buf)), "AttesterSlashings") + } + if itemCount > 2 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 2), "AttesterSlashings") + } + val2 = sszutils.ExpandSlice(val2, itemCount) + for idx1 := range itemCount { + var endOffset int + if idx1 < itemCount-1 { + endOffset = int(binary.LittleEndian.Uint32(buf[(idx1+1)*4 : (idx1+2)*4])) + } else { + endOffset = len(buf) + } + if endOffset < startOffset || endOffset > len(buf) { + return sszutils.ErrorWithPathf(sszutils.ErrElementOffsetOutOfRangeFn(endOffset, startOffset, len(buf)), "AttesterSlashings[%d]", idx1) + } + buf := buf[startOffset:endOffset] + startOffset = endOffset + val3 := val2[idx1] + if val3 == nil { + val3 = new(generic.AttesterSlashing) + } + if err = val3.UnmarshalSSZDyn(ds, buf); err != nil { + return sszutils.ErrorWithPathf(err, "AttesterSlashings[%d]", idx1) + } + val2[idx1] = val3 + } + t.AttesterSlashings = val2 + } + { // Field #5 'Attestations' (dynamic) + buf := buf[offset5:offset6] + val4 := t.Attestations + startOffset := int(0) + if len(buf) != 0 { + if len(buf) < 4 { + return sszutils.ErrorWithPath(sszutils.ErrListOffsetsEOFFn(len(buf), 4), "Attestations") + } + startOffset = int(binary.LittleEndian.Uint32(buf[0:4])) + } + itemCount := startOffset / 4 + if startOffset%4 != 0 || len(buf) < startOffset || (len(buf) != 0 && startOffset == 0) { + return sszutils.ErrorWithPath(sszutils.ErrInvalidListStartOffsetFn(startOffset, len(buf)), "Attestations") + } + if itemCount > 128 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 128), "Attestations") + } + val4 = sszutils.ExpandSlice(val4, itemCount) + for idx1 := range itemCount { + var endOffset int + if idx1 < itemCount-1 { + endOffset = int(binary.LittleEndian.Uint32(buf[(idx1+1)*4 : (idx1+2)*4])) + } else { + endOffset = len(buf) + } + if endOffset < startOffset || endOffset > len(buf) { + return sszutils.ErrorWithPathf(sszutils.ErrElementOffsetOutOfRangeFn(endOffset, startOffset, len(buf)), "Attestations[%d]", idx1) + } + buf := buf[startOffset:endOffset] + startOffset = endOffset + val5 := val4[idx1] + if val5 == nil { + val5 = new(generic.Attestation) + } + if err = val5.UnmarshalSSZDyn(ds, buf); err != nil { + return sszutils.ErrorWithPathf(err, "Attestations[%d]", idx1) + } + val4[idx1] = val5 + } + t.Attestations = val4 + } + { // Field #6 'Deposits' (dynamic) + buf := buf[offset6:offset7] + val6 := t.Deposits + itemCount := len(buf) / 1240 + if len(buf)%1240 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 1240), "Deposits") + } + if itemCount > 16 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 16), "Deposits") + } + val6 = sszutils.ExpandSlice(val6, itemCount) + for idx1 := range itemCount { + if val6[idx1] == nil { + val6[idx1] = new(generic.Deposit) + } + buf := buf[1240*idx1 : 1240*(idx1+1)] + if err = val6[idx1].UnmarshalSSZDyn(ds, buf); err != nil { + return sszutils.ErrorWithPathf(err, "Deposits[%d]", idx1) + } + } + t.Deposits = val6 + } + { // Field #7 'VoluntaryExits' (dynamic) + buf := buf[offset7:offset9] + val7 := t.VoluntaryExits + itemCount := len(buf) / 112 + if len(buf)%112 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 112), "VoluntaryExits") + } + if itemCount > 16 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 16), "VoluntaryExits") + } + val7 = sszutils.ExpandSlice(val7, itemCount) + for idx1 := range itemCount { + if val7[idx1] == nil { + val7[idx1] = new(generic.SignedVoluntaryExit) + } + buf := buf[112*idx1 : 112*(idx1+1)] + if err = val7[idx1].UnmarshalSSZDyn(ds, buf); err != nil { + return sszutils.ErrorWithPathf(err, "VoluntaryExits[%d]", idx1) + } + } + t.VoluntaryExits = val7 + } + { // Field #9 'ExecutionPayload' (dynamic) + buf := buf[offset9:offset10] + if t.ExecutionPayload == nil { + t.ExecutionPayload = new(ExecutionPayload) + } + if err = t.ExecutionPayload.UnmarshalSSZDyn(ds, buf); err != nil { + return sszutils.ErrorWithPath(err, "ExecutionPayload") + } + } + { // Field #10 'BlsToExecutionChanges' (dynamic) + buf := buf[offset10:offset11] + val8 := t.BlsToExecutionChanges + itemCount := len(buf) / 172 + if len(buf)%172 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 172), "BlsToExecutionChanges") + } + if itemCount > 16 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 16), "BlsToExecutionChanges") + } + val8 = sszutils.ExpandSlice(val8, itemCount) + for idx1 := range itemCount { + if val8[idx1] == nil { + val8[idx1] = new(generic.SignedBLSToExecutionChange) + } + buf := buf[172*idx1 : 172*(idx1+1)] + if err = val8[idx1].UnmarshalSSZDyn(ds, buf); err != nil { + return sszutils.ErrorWithPathf(err, "BlsToExecutionChanges[%d]", idx1) + } + } + t.BlsToExecutionChanges = val8 + } + { // Field #11 'BlobKzgCommitments' (dynamic) + buf := buf[offset11:] + val9 := t.BlobKzgCommitments + itemCount := len(buf) / 48 + if len(buf)%48 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 48), "BlobKzgCommitments") + } + if itemCount > 4096 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 4096), "BlobKzgCommitments") + } + val9 = sszutils.ExpandSlice(val9, itemCount) + sszutils.UnmarshalFixedBytesSlice(val9[:itemCount], buf) + t.BlobKzgCommitments = val9 + } + return nil +} + +// UnmarshalSSZDecoder unmarshals the *BeaconBlockBody from the given SSZ decoder using dynamic specifications. +func (t *BeaconBlockBody) UnmarshalSSZDecoder(ds sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { + canSeek := dec.Seekable() + offsetSlices := [1][]uint32{ + sszutils.GetOffsetSlice(0), + } + defer func() { + sszutils.PutOffsetSlice(offsetSlices[0]) + }() + maxOffset := uint32(dec.GetLength()) + startPos0 := dec.GetPosition() + if maxOffset < uint32(392) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(392)) + } + // Field #0 'RandaoReveal' (static) + t.RandaoReveal = sszutils.ExpandSlice(t.RandaoReveal, 96) + if _, err = dec.DecodeBytes(t.RandaoReveal[:96]); err != nil { + return err + } + // Field #1 'Eth1Data' (static) + if t.Eth1Data == nil { + t.Eth1Data = new(generic.Eth1Data) + } + if err = t.Eth1Data.UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPath(err, "Eth1Data") + } + // Field #2 'Graffiti' (static) + if _, err = dec.DecodeBytes(t.Graffiti[:32]); err != nil { + return err + } + // Field #3 'ProposerSlashings' (offset) + offset3, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "ProposerSlashings") + } + if offset3 != uint32(392) { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset3, 392), "ProposerSlashings") + } + // Field #4 'AttesterSlashings' (offset) + offset4, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "AttesterSlashings") + } + if offset4 < offset3 || offset4 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset4, offset3, maxOffset), "AttesterSlashings") + } + // Field #5 'Attestations' (offset) + offset5, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Attestations") + } + if offset5 < offset4 || offset5 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset5, offset4, maxOffset), "Attestations") + } + // Field #6 'Deposits' (offset) + offset6, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Deposits") + } + if offset6 < offset5 || offset6 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset6, offset5, maxOffset), "Deposits") + } + // Field #7 'VoluntaryExits' (offset) + offset7, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "VoluntaryExits") + } + if offset7 < offset6 || offset7 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset7, offset6, maxOffset), "VoluntaryExits") + } + // Field #8 'SyncAggregate' (static) + if t.SyncAggregate == nil { + t.SyncAggregate = new(generic.SyncAggregate) + } + if err = t.SyncAggregate.UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPath(err, "SyncAggregate") + } + // Field #9 'ExecutionPayload' (offset) + offset9, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "ExecutionPayload") + } + if offset9 < offset7 || offset9 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset9, offset7, maxOffset), "ExecutionPayload") + } + // Field #10 'BlsToExecutionChanges' (offset) + offset10, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "BlsToExecutionChanges") + } + if offset10 < offset9 || offset10 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset10, offset9, maxOffset), "BlsToExecutionChanges") + } + // Field #11 'BlobKzgCommitments' (offset) + offset11, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "BlobKzgCommitments") + } + if offset11 < offset10 || offset11 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset11, offset10, maxOffset), "BlobKzgCommitments") + } + { // Field #3 'ProposerSlashings' (dynamic) + if dec.GetPosition() != startPos0+int(offset3) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset3)), "ProposerSlashings") + } + dec.PushLimit(int(offset4 - offset3)) + val1 := t.ProposerSlashings + sszLen := dec.GetLength() + itemCount := sszLen / 416 + if sszLen%416 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 416), "ProposerSlashings") + } + if itemCount > 16 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 16), "ProposerSlashings") + } + val1 = sszutils.ExpandSlice(val1, itemCount) + startPos1 := dec.GetPosition() + for idx1 := range itemCount { + if val1[idx1] == nil { + val1[idx1] = new(generic.ProposerSlashing) + } + if err = val1[idx1].UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPathf(err, "ProposerSlashings[%d]", idx1) + } + if dec.GetPosition() != startPos1+int(416*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos1+int(416*(idx1+1))), "ProposerSlashings[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "ProposerSlashings") + } + t.ProposerSlashings = val1 + } + { // Field #4 'AttesterSlashings' (dynamic) + if dec.GetPosition() != startPos0+int(offset4) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset4)), "AttesterSlashings") + } + dec.PushLimit(int(offset5 - offset4)) + val2 := t.AttesterSlashings + startOffset := uint32(0) + startPos2 := dec.GetPosition() + sszLen := uint32(dec.GetLength()) + if sszLen > 0 { + startOffset, err = dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "AttesterSlashings") + } + } + itemCount := int(startOffset / 4) + var offsets []uint32 + if canSeek { + dec.SkipBytes((itemCount - 1) * 4) + } else if itemCount > 1 { + offsetSlices[0] = sszutils.ExpandSlice(offsetSlices[0], itemCount-1) + offsets = offsetSlices[0] + for idx1 := range itemCount - 1 { + offset, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPathf(err, "AttesterSlashings[%d:o]", idx1) + } + offsets[idx1] = offset + } + } + if startOffset%4 != 0 || uint32(sszLen) < startOffset { + return sszutils.ErrorWithPath(sszutils.ErrInvalidListStartOffsetFn(startOffset, sszLen), "AttesterSlashings") + } + if itemCount > 2 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 2), "AttesterSlashings") + } + val2 = sszutils.ExpandSlice(val2, itemCount) + for idx1 := range itemCount { + var endOffset uint32 + if idx1 < itemCount-1 { + if canSeek { + endOffset = dec.DecodeOffsetAt(startPos2 + int((idx1+1)*4)) + } else { + endOffset = offsets[idx1] + } + } else { + endOffset = uint32(sszLen) + } + if endOffset < startOffset || endOffset > uint32(sszLen) { + return sszutils.ErrorWithPathf(sszutils.ErrElementOffsetOutOfRangeFn(endOffset, startOffset, sszLen), "AttesterSlashings[%d]", idx1) + } + itemSize := endOffset - startOffset + dec.PushLimit(int(itemSize)) + startOffset = endOffset + val3 := val2[idx1] + if val3 == nil { + val3 = new(generic.AttesterSlashing) + } + if err = val3.UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPathf(err, "AttesterSlashings[%d]", idx1) + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPathf(sszutils.ErrTrailingDataFn(diff), "AttesterSlashings[%d]", idx1) + } + val2[idx1] = val3 + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "AttesterSlashings") + } + t.AttesterSlashings = val2 + } + { // Field #5 'Attestations' (dynamic) + if dec.GetPosition() != startPos0+int(offset5) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset5)), "Attestations") + } + dec.PushLimit(int(offset6 - offset5)) + val4 := t.Attestations + startOffset := uint32(0) + startPos3 := dec.GetPosition() + sszLen := uint32(dec.GetLength()) + if sszLen > 0 { + startOffset, err = dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Attestations") + } + } + itemCount := int(startOffset / 4) + var offsets []uint32 + if canSeek { + dec.SkipBytes((itemCount - 1) * 4) + } else if itemCount > 1 { + offsetSlices[0] = sszutils.ExpandSlice(offsetSlices[0], itemCount-1) + offsets = offsetSlices[0] + for idx1 := range itemCount - 1 { + offset, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPathf(err, "Attestations[%d:o]", idx1) + } + offsets[idx1] = offset + } + } + if startOffset%4 != 0 || uint32(sszLen) < startOffset { + return sszutils.ErrorWithPath(sszutils.ErrInvalidListStartOffsetFn(startOffset, sszLen), "Attestations") + } + if itemCount > 128 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 128), "Attestations") + } + val4 = sszutils.ExpandSlice(val4, itemCount) + for idx1 := range itemCount { + var endOffset uint32 + if idx1 < itemCount-1 { + if canSeek { + endOffset = dec.DecodeOffsetAt(startPos3 + int((idx1+1)*4)) + } else { + endOffset = offsets[idx1] + } + } else { + endOffset = uint32(sszLen) + } + if endOffset < startOffset || endOffset > uint32(sszLen) { + return sszutils.ErrorWithPathf(sszutils.ErrElementOffsetOutOfRangeFn(endOffset, startOffset, sszLen), "Attestations[%d]", idx1) + } + itemSize := endOffset - startOffset + dec.PushLimit(int(itemSize)) + startOffset = endOffset + val5 := val4[idx1] + if val5 == nil { + val5 = new(generic.Attestation) + } + if err = val5.UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPathf(err, "Attestations[%d]", idx1) + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPathf(sszutils.ErrTrailingDataFn(diff), "Attestations[%d]", idx1) + } + val4[idx1] = val5 + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Attestations") + } + t.Attestations = val4 + } + { // Field #6 'Deposits' (dynamic) + if dec.GetPosition() != startPos0+int(offset6) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset6)), "Deposits") + } + dec.PushLimit(int(offset7 - offset6)) + val6 := t.Deposits + sszLen := dec.GetLength() + itemCount := sszLen / 1240 + if sszLen%1240 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 1240), "Deposits") + } + if itemCount > 16 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 16), "Deposits") + } + val6 = sszutils.ExpandSlice(val6, itemCount) + startPos4 := dec.GetPosition() + for idx1 := range itemCount { + if val6[idx1] == nil { + val6[idx1] = new(generic.Deposit) + } + if err = val6[idx1].UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPathf(err, "Deposits[%d]", idx1) + } + if dec.GetPosition() != startPos4+int(1240*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos4+int(1240*(idx1+1))), "Deposits[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Deposits") + } + t.Deposits = val6 + } + { // Field #7 'VoluntaryExits' (dynamic) + if dec.GetPosition() != startPos0+int(offset7) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset7)), "VoluntaryExits") + } + dec.PushLimit(int(offset9 - offset7)) + val7 := t.VoluntaryExits + sszLen := dec.GetLength() + itemCount := sszLen / 112 + if sszLen%112 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 112), "VoluntaryExits") + } + if itemCount > 16 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 16), "VoluntaryExits") + } + val7 = sszutils.ExpandSlice(val7, itemCount) + startPos5 := dec.GetPosition() + for idx1 := range itemCount { + if val7[idx1] == nil { + val7[idx1] = new(generic.SignedVoluntaryExit) + } + if err = val7[idx1].UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPathf(err, "VoluntaryExits[%d]", idx1) + } + if dec.GetPosition() != startPos5+int(112*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos5+int(112*(idx1+1))), "VoluntaryExits[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "VoluntaryExits") + } + t.VoluntaryExits = val7 + } + { // Field #9 'ExecutionPayload' (dynamic) + if dec.GetPosition() != startPos0+int(offset9) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset9)), "ExecutionPayload") + } + dec.PushLimit(int(offset10 - offset9)) + val8 := t.ExecutionPayload + if val8 == nil { + val8 = new(ExecutionPayload) + } + if err = val8.UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPath(err, "ExecutionPayload") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "ExecutionPayload") + } + t.ExecutionPayload = val8 + } + { // Field #10 'BlsToExecutionChanges' (dynamic) + if dec.GetPosition() != startPos0+int(offset10) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset10)), "BlsToExecutionChanges") + } + dec.PushLimit(int(offset11 - offset10)) + val9 := t.BlsToExecutionChanges + sszLen := dec.GetLength() + itemCount := sszLen / 172 + if sszLen%172 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 172), "BlsToExecutionChanges") + } + if itemCount > 16 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 16), "BlsToExecutionChanges") + } + val9 = sszutils.ExpandSlice(val9, itemCount) + startPos6 := dec.GetPosition() + for idx1 := range itemCount { + if val9[idx1] == nil { + val9[idx1] = new(generic.SignedBLSToExecutionChange) + } + if err = val9[idx1].UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPathf(err, "BlsToExecutionChanges[%d]", idx1) + } + if dec.GetPosition() != startPos6+int(172*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos6+int(172*(idx1+1))), "BlsToExecutionChanges[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "BlsToExecutionChanges") + } + t.BlsToExecutionChanges = val9 + } + { // Field #11 'BlobKzgCommitments' (dynamic) + if dec.GetPosition() != startPos0+int(offset11) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset11)), "BlobKzgCommitments") + } + dec.PushLimit(int(maxOffset - offset11)) + val10 := t.BlobKzgCommitments + sszLen := dec.GetLength() + itemCount := sszLen / 48 + if sszLen%48 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 48), "BlobKzgCommitments") + } + if itemCount > 4096 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 4096), "BlobKzgCommitments") + } + val10 = sszutils.ExpandSlice(val10, itemCount) + startPos7 := dec.GetPosition() + for idx1 := range itemCount { + if _, err = dec.DecodeBytes(val10[idx1][:48]); err != nil { + return err + } + if dec.GetPosition() != startPos7+int(48*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos7+int(48*(idx1+1))), "BlobKzgCommitments[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "BlobKzgCommitments") + } + t.BlobKzgCommitments = val10 + } + return nil +} + +// SizeSSZDyn returns the SSZ encoded size of the *BeaconBlockBody using dynamic specifications. +func (t *BeaconBlockBody) SizeSSZDyn(ds sszutils.DynamicSpecs) (size int) { + if t == nil { + t = new(BeaconBlockBody) + } + // Field #0 'RandaoReveal' static (96 bytes) + // Field #1 'Eth1Data' static (72 bytes) + // Field #2 'Graffiti' static (32 bytes) + // Field #3 'ProposerSlashings' offset (4 bytes) + // Field #4 'AttesterSlashings' offset (4 bytes) + // Field #5 'Attestations' offset (4 bytes) + // Field #6 'Deposits' offset (4 bytes) + // Field #7 'VoluntaryExits' offset (4 bytes) + // Field #8 'SyncAggregate' static (160 bytes) + // Field #9 'ExecutionPayload' offset (4 bytes) + // Field #10 'BlsToExecutionChanges' offset (4 bytes) + // Field #11 'BlobKzgCommitments' offset (4 bytes) + size += 392 + { // Dynamic field #3 'ProposerSlashings' + size += len(t.ProposerSlashings) * 416 + } + { // Dynamic field #4 'AttesterSlashings' + t := t.AttesterSlashings + vlen := len(t) + size += vlen * 4 // Offsets + for i1 := range vlen { + size += t[i1].SizeSSZDyn(ds) + } + } + { // Dynamic field #5 'Attestations' + t := t.Attestations + vlen := len(t) + size += vlen * 4 // Offsets + for i2 := range vlen { + size += t[i2].SizeSSZDyn(ds) + } + } + { // Dynamic field #6 'Deposits' + size += len(t.Deposits) * 1240 + } + { // Dynamic field #7 'VoluntaryExits' + size += len(t.VoluntaryExits) * 112 + } + { // Dynamic field #9 'ExecutionPayload' + size += t.ExecutionPayload.SizeSSZDyn(ds) + } + { // Dynamic field #10 'BlsToExecutionChanges' + size += len(t.BlsToExecutionChanges) * 172 + } + { // Dynamic field #11 'BlobKzgCommitments' + size += len(t.BlobKzgCommitments) * 48 + } + return size +} + +// HashTreeRootDyn computes the SSZ hash tree root of the *BeaconBlockBody using dynamic specifications. +func (t *BeaconBlockBody) HashTreeRootDyn(ds sszutils.DynamicSpecs) (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWithDyn(ds, hh) + if err == nil { + root, err = hh.HashRoot() + } + return + }) + return +} + +// HashTreeRootWithDyn computes the SSZ hash tree root of the *BeaconBlockBody using dynamic specifications and the given hash walker. +func (t *BeaconBlockBody) HashTreeRootWithDyn(ds sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + if t == nil { + t = new(BeaconBlockBody) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'RandaoReveal' + vlen := len(t.RandaoReveal) + if vlen > 96 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 96), "RandaoReveal") + } + val := t.RandaoReveal[:] + if vlen < 96 { + val = sszutils.AppendZeroPadding(val, (96-vlen)*1) + } + hh.PutBytes(val[:96]) + } + { // Field #1 'Eth1Data' + t := t.Eth1Data + if t == nil { + t = new(generic.Eth1Data) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPath(err, "Eth1Data") + } + } + { // Field #2 'Graffiti' + hh.PutBytes(t.Graffiti[:32]) + } + { // Field #3 'ProposerSlashings' + t := t.ProposerSlashings + vlen := uint64(len(t)) + if vlen > 16 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16), "ProposerSlashings") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(generic.ProposerSlashing) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPathf(err, "ProposerSlashings[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(16, vlen, 32)) + } + { // Field #4 'AttesterSlashings' + t := t.AttesterSlashings + vlen := uint64(len(t)) + if vlen > 2 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 2), "AttesterSlashings") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(generic.AttesterSlashing) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPathf(err, "AttesterSlashings[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(2, vlen, 32)) + } + { // Field #5 'Attestations' + t := t.Attestations + vlen := uint64(len(t)) + if vlen > 128 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 128), "Attestations") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(generic.Attestation) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPathf(err, "Attestations[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(128, vlen, 32)) + } + { // Field #6 'Deposits' + t := t.Deposits + vlen := uint64(len(t)) + if vlen > 16 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16), "Deposits") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(generic.Deposit) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPathf(err, "Deposits[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(16, vlen, 32)) + } + { // Field #7 'VoluntaryExits' + t := t.VoluntaryExits + vlen := uint64(len(t)) + if vlen > 16 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16), "VoluntaryExits") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(generic.SignedVoluntaryExit) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPathf(err, "VoluntaryExits[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(16, vlen, 32)) + } + { // Field #8 'SyncAggregate' + t := t.SyncAggregate + if t == nil { + t = new(generic.SyncAggregate) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPath(err, "SyncAggregate") + } + } + { // Field #9 'ExecutionPayload' + t := t.ExecutionPayload + if t == nil { + t = new(ExecutionPayload) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPath(err, "ExecutionPayload") + } + } + { // Field #10 'BlsToExecutionChanges' + t := t.BlsToExecutionChanges + vlen := uint64(len(t)) + if vlen > 16 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16), "BlsToExecutionChanges") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(generic.SignedBLSToExecutionChange) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPathf(err, "BlsToExecutionChanges[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(16, vlen, 32)) + } + { // Field #11 'BlobKzgCommitments' + t := t.BlobKzgCommitments + vlen := uint64(len(t)) + if vlen > 4096 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 4096), "BlobKzgCommitments") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + hh.PutBytes(t[idx1][:48]) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(4096, vlen, 32)) + } + hh.Merkleize(idx) + return nil +} + +// MarshalSSZTo marshals the *ExecutionPayload to SSZ-encoded bytes, appending to the provided buffer. +func (t *ExecutionPayload) MarshalSSZTo(buf []byte) (dst []byte, err error) { + dst = buf + if t == nil { + t = new(ExecutionPayload) + } + dstlen := len(dst) + { // Static Field #0 'ParentHash' + dst = append(dst, t.ParentHash[:32]...) + } + { // Static Field #1 'FeeRecipient' + dst = append(dst, t.FeeRecipient[:20]...) + } + { // Static Field #2 'StateRoot' + dst = append(dst, t.StateRoot[:32]...) + } + { // Static Field #3 'ReceiptsRoot' + dst = append(dst, t.ReceiptsRoot[:32]...) + } + { // Static Field #4 'LogsBloom' + dst = append(dst, t.LogsBloom[:256]...) + } + { // Static Field #5 'PrevRandao' + dst = append(dst, t.PrevRandao[:32]...) + } + { // Static Field #6 'BlockNumber' + dst = binary.LittleEndian.AppendUint64(dst, t.BlockNumber) + } + { // Static Field #7 'GasLimit' + dst = binary.LittleEndian.AppendUint64(dst, t.GasLimit) + } + { // Static Field #8 'GasUsed' + dst = binary.LittleEndian.AppendUint64(dst, t.GasUsed) + } + { // Static Field #9 'Timestamp' + dst = binary.LittleEndian.AppendUint64(dst, t.Timestamp) + } + // Offset Field #10 'ExtraData' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #11 'BaseFeePerGas' + dst = append(dst, t.BaseFeePerGas[:32]...) + } + { // Static Field #12 'BlockHash' + dst = append(dst, t.BlockHash[:32]...) + } + // Offset Field #13 'Transactions' + // Offset Field #14 'Withdrawals' + dst = append(dst, 0, 0, 0, 0, 0, 0, 0, 0) + { // Static Field #15 'BlobGasUsed' + dst = binary.LittleEndian.AppendUint64(dst, t.BlobGasUsed) + } + { // Static Field #16 'ExcessBlobGas' + dst = binary.LittleEndian.AppendUint64(dst, t.ExcessBlobGas) + } + { // Dynamic Field #10 'ExtraData' + binary.LittleEndian.PutUint32(dst[dstlen+436:], uint32(len(dst)-dstlen)) + vlen := len(t.ExtraData) + if vlen > 32 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 32), "ExtraData") + } + dst = append(dst, t.ExtraData[:]...) + } + { // Dynamic Field #13 'Transactions' + binary.LittleEndian.PutUint32(dst[dstlen+504:], uint32(len(dst)-dstlen)) + t := t.Transactions + vlen := len(t) + if vlen > 1048576 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1048576), "Transactions") + } + dstlen := len(dst) + dst = sszutils.AppendZeroPadding(dst, vlen*4) + for idx1 := range vlen { + binary.LittleEndian.PutUint32(dst[dstlen+(idx1*4):], uint32(len(dst)-dstlen)) + vlen := len(t[idx1]) + if vlen > 1073741824 { + return nil, sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(vlen, 1073741824), "Transactions[%d]", idx1) + } + dst = append(dst, t[idx1][:]...) + } + } + { // Dynamic Field #14 'Withdrawals' + binary.LittleEndian.PutUint32(dst[dstlen+508:], uint32(len(dst)-dstlen)) + t := t.Withdrawals + vlen := len(t) + if vlen > 16 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16), "Withdrawals") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(generic.Withdrawal) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "Withdrawals[%d]", idx1) + } + } + } + return dst, nil +} + +// MarshalSSZDyn marshals the *ExecutionPayload to SSZ-encoded bytes using dynamic specifications. +func (t *ExecutionPayload) MarshalSSZDyn(_ sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + return t.MarshalSSZTo(buf) +} + +// MarshalSSZEncoder marshals the *ExecutionPayload to the given SSZ encoder using dynamic specifications. +func (t *ExecutionPayload) MarshalSSZEncoder(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + type encoderCtx struct { + ds sszutils.DynamicSpecs + exprs [0]uint64 + sizeFn1 func(ctx *encoderCtx, t []byte) (size int) + sizeFn2 func(ctx *encoderCtx, t [][]byte) (size int) + sizeFn3 func(ctx *encoderCtx, t []*generic.Withdrawal) (size int) + sizeFn4 func(ctx *encoderCtx, t []byte) (size int) + } + ctx := &encoderCtx{ds: ds} + canSeek := enc.Seekable() + // size for []byte + ctx.sizeFn1 = func(ctx *encoderCtx, t []byte) (size int) { + size += len(t) + return size + } + // size for [][]byte + ctx.sizeFn2 = func(ctx *encoderCtx, t [][]byte) (size int) { + vlen := len(t) + size += vlen * 4 // Offsets + for i1 := range vlen { + size += ctx.sizeFn4(ctx, t[i1]) + } + return size + } + // size for []*generic.Withdrawal + ctx.sizeFn3 = func(ctx *encoderCtx, t []*generic.Withdrawal) (size int) { + size += len(t) * 44 + return size + } + // size for []byte + ctx.sizeFn4 = func(ctx *encoderCtx, t []byte) (size int) { + size += len(t) + return size + } + if t == nil { + t = new(ExecutionPayload) + } + dstlen := enc.GetPosition() + dynoff := uint32(528) + { // Field #0 'ParentHash' + enc.EncodeBytes(t.ParentHash[:32]) + } + { // Field #1 'FeeRecipient' + enc.EncodeBytes(t.FeeRecipient[:20]) + } + { // Field #2 'StateRoot' + enc.EncodeBytes(t.StateRoot[:32]) + } + { // Field #3 'ReceiptsRoot' + enc.EncodeBytes(t.ReceiptsRoot[:32]) + } + { // Field #4 'LogsBloom' + enc.EncodeBytes(t.LogsBloom[:256]) + } + { // Field #5 'PrevRandao' + enc.EncodeBytes(t.PrevRandao[:32]) + } + { // Field #6 'BlockNumber' + enc.EncodeUint64(t.BlockNumber) + } + { // Field #7 'GasLimit' + enc.EncodeUint64(t.GasLimit) + } + { // Field #8 'GasUsed' + enc.EncodeUint64(t.GasUsed) + } + { // Field #9 'Timestamp' + enc.EncodeUint64(t.Timestamp) + } + // Offset #10 'ExtraData' + offset10 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn1(ctx, t.ExtraData)) + } + { // Field #11 'BaseFeePerGas' + enc.EncodeBytes(t.BaseFeePerGas[:32]) + } + { // Field #12 'BlockHash' + enc.EncodeBytes(t.BlockHash[:32]) + } + // Offset #13 'Transactions' + offset13 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn2(ctx, t.Transactions)) + } + // Offset #14 'Withdrawals' + offset14 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn3(ctx, t.Withdrawals)) + } + { // Field #15 'BlobGasUsed' + enc.EncodeUint64(t.BlobGasUsed) + } + { // Field #16 'ExcessBlobGas' + enc.EncodeUint64(t.ExcessBlobGas) + } + { // Dynamic Field #10 'ExtraData' + if canSeek { + enc.EncodeOffsetAt(offset10, uint32(enc.GetPosition()-dstlen)) + } + vlen := len(t.ExtraData) + if vlen > 32 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 32), "ExtraData") + } + enc.EncodeBytes(t.ExtraData[:]) + } + { // Dynamic Field #13 'Transactions' + if canSeek { + enc.EncodeOffsetAt(offset13, uint32(enc.GetPosition()-dstlen)) + } + t := t.Transactions + vlen := len(t) + if vlen > 1048576 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1048576), "Transactions") + } + dstlen := enc.GetPosition() + if canSeek { + enc.EncodeZeroPadding(vlen * 4) + } else if vlen > 0 { + offset := vlen * 4 + enc.EncodeOffset(uint32(offset)) + for i := range vlen - 1 { + offset += ctx.sizeFn4(ctx, t[i]) + enc.EncodeOffset(uint32(offset)) + } + } + for idx1 := range vlen { + if canSeek { + enc.EncodeOffsetAt(dstlen+(idx1*4), uint32(enc.GetPosition()-dstlen)) + } + vlen := len(t[idx1]) + if vlen > 1073741824 { + return sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(vlen, 1073741824), "Transactions[%d]", idx1) + } + enc.EncodeBytes(t[idx1][:]) + } + } + { // Dynamic Field #14 'Withdrawals' + if canSeek { + enc.EncodeOffsetAt(offset14, uint32(enc.GetPosition()-dstlen)) + } + t := t.Withdrawals + vlen := len(t) + if vlen > 16 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16), "Withdrawals") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(generic.Withdrawal) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "Withdrawals[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + return nil +} + +// UnmarshalSSZ unmarshals the *ExecutionPayload from SSZ-encoded bytes. +func (t *ExecutionPayload) UnmarshalSSZ(buf []byte) (err error) { + buflen := len(buf) + if buflen < 528 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 528) + } + { // Field #0 'ParentHash' (static) + buf := buf[0:32] + copy(t.ParentHash[:], buf) + } + { // Field #1 'FeeRecipient' (static) + buf := buf[32:52] + copy(t.FeeRecipient[:], buf) + } + { // Field #2 'StateRoot' (static) + buf := buf[52:84] + copy(t.StateRoot[:], buf) + } + { // Field #3 'ReceiptsRoot' (static) + buf := buf[84:116] + copy(t.ReceiptsRoot[:], buf) + } + { // Field #4 'LogsBloom' (static) + buf := buf[116:372] + copy(t.LogsBloom[:], buf) + } + { // Field #5 'PrevRandao' (static) + buf := buf[372:404] + copy(t.PrevRandao[:], buf) + } + { // Field #6 'BlockNumber' (static) + buf := buf[404:412] + t.BlockNumber = binary.LittleEndian.Uint64(buf) + } + { // Field #7 'GasLimit' (static) + buf := buf[412:420] + t.GasLimit = binary.LittleEndian.Uint64(buf) + } + { // Field #8 'GasUsed' (static) + buf := buf[420:428] + t.GasUsed = binary.LittleEndian.Uint64(buf) + } + { // Field #9 'Timestamp' (static) + buf := buf[428:436] + t.Timestamp = binary.LittleEndian.Uint64(buf) + } + // Field #10 'ExtraData' (offset) + offset10 := int(binary.LittleEndian.Uint32(buf[436:440])) + if offset10 != 528 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset10, 528), "ExtraData:o") + } + { // Field #11 'BaseFeePerGas' (static) + buf := buf[440:472] + copy(t.BaseFeePerGas[:], buf) + } + { // Field #12 'BlockHash' (static) + buf := buf[472:504] + copy(t.BlockHash[:], buf) + } + // Field #13 'Transactions' (offset) + offset13 := int(binary.LittleEndian.Uint32(buf[504:508])) + if offset13 < offset10 || offset13 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset13, offset10, buflen), "Transactions:o") + } + // Field #14 'Withdrawals' (offset) + offset14 := int(binary.LittleEndian.Uint32(buf[508:512])) + if offset14 < offset13 || offset14 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset14, offset13, buflen), "Withdrawals:o") + } + { // Field #15 'BlobGasUsed' (static) + buf := buf[512:520] + t.BlobGasUsed = binary.LittleEndian.Uint64(buf) + } + { // Field #16 'ExcessBlobGas' (static) + buf := buf[520:528] + t.ExcessBlobGas = binary.LittleEndian.Uint64(buf) + } + { // Field #10 'ExtraData' (dynamic) + buf := buf[offset10:offset13] + if len(buf) > 32 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(len(buf), 32), "ExtraData") + } + t.ExtraData = sszutils.ExpandSlice(t.ExtraData, len(buf)) + copy(t.ExtraData[:], buf) + } + { // Field #13 'Transactions' (dynamic) + buf := buf[offset13:offset14] + val1 := t.Transactions + startOffset := int(0) + if len(buf) != 0 { + if len(buf) < 4 { + return sszutils.ErrorWithPath(sszutils.ErrListOffsetsEOFFn(len(buf), 4), "Transactions") + } + startOffset = int(binary.LittleEndian.Uint32(buf[0:4])) + } + itemCount := startOffset / 4 + if startOffset%4 != 0 || len(buf) < startOffset || (len(buf) != 0 && startOffset == 0) { + return sszutils.ErrorWithPath(sszutils.ErrInvalidListStartOffsetFn(startOffset, len(buf)), "Transactions") + } + if itemCount > 1048576 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1048576), "Transactions") + } + val1 = sszutils.ExpandSlice(val1, itemCount) + for idx1 := range itemCount { + var endOffset int + if idx1 < itemCount-1 { + endOffset = int(binary.LittleEndian.Uint32(buf[(idx1+1)*4 : (idx1+2)*4])) + } else { + endOffset = len(buf) + } + if endOffset < startOffset || endOffset > len(buf) { + return sszutils.ErrorWithPathf(sszutils.ErrElementOffsetOutOfRangeFn(endOffset, startOffset, len(buf)), "Transactions[%d]", idx1) + } + buf := buf[startOffset:endOffset] + startOffset = endOffset + val2 := val1[idx1] + if len(buf) > 1073741824 { + return sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(len(buf), 1073741824), "Transactions[%d]", idx1) + } + val2 = sszutils.ExpandSlice(val2, len(buf)) + copy(val2[:], buf) + val1[idx1] = val2 + } + t.Transactions = val1 + } + { // Field #14 'Withdrawals' (dynamic) + buf := buf[offset14:] + val3 := t.Withdrawals + itemCount := len(buf) / 44 + if len(buf)%44 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 44), "Withdrawals") + } + if itemCount > 16 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 16), "Withdrawals") + } + val3 = sszutils.ExpandSlice(val3, itemCount) + for idx1 := range itemCount { + if val3[idx1] == nil { + val3[idx1] = new(generic.Withdrawal) + } + buf := buf[44*idx1 : 44*(idx1+1)] + if err = val3[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Withdrawals[%d]", idx1) + } + } + t.Withdrawals = val3 + } + return nil +} + +// UnmarshalSSZDyn unmarshals the *ExecutionPayload from SSZ-encoded bytes using dynamic specifications. +func (t *ExecutionPayload) UnmarshalSSZDyn(_ sszutils.DynamicSpecs, buf []byte) (err error) { + return t.UnmarshalSSZ(buf) +} + +// UnmarshalSSZDecoder unmarshals the *ExecutionPayload from the given SSZ decoder using dynamic specifications. +func (t *ExecutionPayload) UnmarshalSSZDecoder(ds sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { + canSeek := dec.Seekable() + offsetSlices := [1][]uint32{ + sszutils.GetOffsetSlice(0), + } + defer func() { + sszutils.PutOffsetSlice(offsetSlices[0]) + }() + maxOffset := uint32(dec.GetLength()) + startPos0 := dec.GetPosition() + if maxOffset < uint32(528) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(528)) + } + // Field #0 'ParentHash' (static) + if _, err = dec.DecodeBytes(t.ParentHash[:32]); err != nil { + return err + } + // Field #1 'FeeRecipient' (static) + if _, err = dec.DecodeBytes(t.FeeRecipient[:20]); err != nil { + return err + } + // Field #2 'StateRoot' (static) + if _, err = dec.DecodeBytes(t.StateRoot[:32]); err != nil { + return err + } + // Field #3 'ReceiptsRoot' (static) + if _, err = dec.DecodeBytes(t.ReceiptsRoot[:32]); err != nil { + return err + } + // Field #4 'LogsBloom' (static) + if _, err = dec.DecodeBytes(t.LogsBloom[:256]); err != nil { + return err + } + // Field #5 'PrevRandao' (static) + if _, err = dec.DecodeBytes(t.PrevRandao[:32]); err != nil { + return err + } + // Field #6 'BlockNumber' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "BlockNumber") + } else { + t.BlockNumber = val + } + // Field #7 'GasLimit' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "GasLimit") + } else { + t.GasLimit = val + } + // Field #8 'GasUsed' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "GasUsed") + } else { + t.GasUsed = val + } + // Field #9 'Timestamp' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "Timestamp") + } else { + t.Timestamp = val + } + // Field #10 'ExtraData' (offset) + offset10, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "ExtraData") + } + if offset10 != uint32(528) { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset10, 528), "ExtraData") + } + // Field #11 'BaseFeePerGas' (static) + if _, err = dec.DecodeBytes(t.BaseFeePerGas[:32]); err != nil { + return err + } + // Field #12 'BlockHash' (static) + if _, err = dec.DecodeBytes(t.BlockHash[:32]); err != nil { + return err + } + // Field #13 'Transactions' (offset) + offset13, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Transactions") + } + if offset13 < offset10 || offset13 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset13, offset10, maxOffset), "Transactions") + } + // Field #14 'Withdrawals' (offset) + offset14, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Withdrawals") + } + if offset14 < offset13 || offset14 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset14, offset13, maxOffset), "Withdrawals") + } + // Field #15 'BlobGasUsed' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "BlobGasUsed") + } else { + t.BlobGasUsed = val + } + // Field #16 'ExcessBlobGas' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "ExcessBlobGas") + } else { + t.ExcessBlobGas = val + } + { // Field #10 'ExtraData' (dynamic) + if dec.GetPosition() != startPos0+int(offset10) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset10)), "ExtraData") + } + dec.PushLimit(int(offset13 - offset10)) + val1 := t.ExtraData + if dec.GetLength() > 32 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(dec.GetLength(), 32), "ExtraData") + } + listLen := dec.GetLength() + val1 = sszutils.ExpandSlice(val1, listLen) + if _, err = dec.DecodeBytes(val1[:listLen]); err != nil { + return sszutils.ErrorWithPath(err, "ExtraData") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "ExtraData") + } + t.ExtraData = val1 + } + { // Field #13 'Transactions' (dynamic) + if dec.GetPosition() != startPos0+int(offset13) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset13)), "Transactions") + } + dec.PushLimit(int(offset14 - offset13)) + val2 := t.Transactions + startOffset := uint32(0) + startPos1 := dec.GetPosition() + sszLen := uint32(dec.GetLength()) + if sszLen > 0 { + startOffset, err = dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Transactions") + } + } + itemCount := int(startOffset / 4) + var offsets []uint32 + if canSeek { + dec.SkipBytes((itemCount - 1) * 4) + } else if itemCount > 1 { + offsetSlices[0] = sszutils.ExpandSlice(offsetSlices[0], itemCount-1) + offsets = offsetSlices[0] + for idx1 := range itemCount - 1 { + offset, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPathf(err, "Transactions[%d:o]", idx1) + } + offsets[idx1] = offset + } + } + if startOffset%4 != 0 || uint32(sszLen) < startOffset { + return sszutils.ErrorWithPath(sszutils.ErrInvalidListStartOffsetFn(startOffset, sszLen), "Transactions") + } + if itemCount > 1048576 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1048576), "Transactions") + } + val2 = sszutils.ExpandSlice(val2, itemCount) + for idx1 := range itemCount { + var endOffset uint32 + if idx1 < itemCount-1 { + if canSeek { + endOffset = dec.DecodeOffsetAt(startPos1 + int((idx1+1)*4)) + } else { + endOffset = offsets[idx1] + } + } else { + endOffset = uint32(sszLen) + } + if endOffset < startOffset || endOffset > uint32(sszLen) { + return sszutils.ErrorWithPathf(sszutils.ErrElementOffsetOutOfRangeFn(endOffset, startOffset, sszLen), "Transactions[%d]", idx1) + } + itemSize := endOffset - startOffset + dec.PushLimit(int(itemSize)) + startOffset = endOffset + val3 := val2[idx1] + if dec.GetLength() > 1073741824 { + return sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(dec.GetLength(), 1073741824), "Transactions[%d]", idx1) + } + listLen := dec.GetLength() + val3 = sszutils.ExpandSlice(val3, listLen) + if _, err = dec.DecodeBytes(val3[:listLen]); err != nil { + return sszutils.ErrorWithPathf(err, "Transactions[%d]", idx1) + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPathf(sszutils.ErrTrailingDataFn(diff), "Transactions[%d]", idx1) + } + val2[idx1] = val3 + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Transactions") + } + t.Transactions = val2 + } + { // Field #14 'Withdrawals' (dynamic) + if dec.GetPosition() != startPos0+int(offset14) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset14)), "Withdrawals") + } + dec.PushLimit(int(maxOffset - offset14)) + val4 := t.Withdrawals + sszLen := dec.GetLength() + itemCount := sszLen / 44 + if sszLen%44 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 44), "Withdrawals") + } + if itemCount > 16 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 16), "Withdrawals") + } + val4 = sszutils.ExpandSlice(val4, itemCount) + startPos2 := dec.GetPosition() + for idx1 := range itemCount { + if val4[idx1] == nil { + val4[idx1] = new(generic.Withdrawal) + } + if err = val4[idx1].UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPathf(err, "Withdrawals[%d]", idx1) + } + if dec.GetPosition() != startPos2+int(44*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos2+int(44*(idx1+1))), "Withdrawals[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Withdrawals") + } + t.Withdrawals = val4 + } + return nil +} + +// SizeSSZ returns the SSZ encoded size of the *ExecutionPayload. +func (t *ExecutionPayload) SizeSSZ() (size int) { + if t == nil { + t = new(ExecutionPayload) + } + // Field #0 'ParentHash' static (32 bytes) + // Field #1 'FeeRecipient' static (20 bytes) + // Field #2 'StateRoot' static (32 bytes) + // Field #3 'ReceiptsRoot' static (32 bytes) + // Field #4 'LogsBloom' static (256 bytes) + // Field #5 'PrevRandao' static (32 bytes) + // Field #6 'BlockNumber' static (8 bytes) + // Field #7 'GasLimit' static (8 bytes) + // Field #8 'GasUsed' static (8 bytes) + // Field #9 'Timestamp' static (8 bytes) + // Field #10 'ExtraData' offset (4 bytes) + // Field #11 'BaseFeePerGas' static (32 bytes) + // Field #12 'BlockHash' static (32 bytes) + // Field #13 'Transactions' offset (4 bytes) + // Field #14 'Withdrawals' offset (4 bytes) + // Field #15 'BlobGasUsed' static (8 bytes) + // Field #16 'ExcessBlobGas' static (8 bytes) + size += 528 + { // Dynamic field #10 'ExtraData' + size += len(t.ExtraData) + } + { // Dynamic field #13 'Transactions' + t := t.Transactions + vlen := len(t) + size += vlen * 4 // Offsets + for i1 := range vlen { + size += len(t[i1]) + } + } + { // Dynamic field #14 'Withdrawals' + size += len(t.Withdrawals) * 44 + } + return size +} + +// SizeSSZDyn returns the SSZ encoded size of the *ExecutionPayload using dynamic specifications. +func (t *ExecutionPayload) SizeSSZDyn(_ sszutils.DynamicSpecs) (size int) { + return t.SizeSSZ() +} + +// HashTreeRootDyn computes the SSZ hash tree root of the *ExecutionPayload using dynamic specifications. +func (t *ExecutionPayload) HashTreeRootDyn(ds sszutils.DynamicSpecs) (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWithDyn(ds, hh) + if err == nil { + root, err = hh.HashRoot() + } + return + }) + return +} + +// HashTreeRootWithDyn computes the SSZ hash tree root of the *ExecutionPayload using dynamic specifications and the given hash walker. +func (t *ExecutionPayload) HashTreeRootWithDyn(ds sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + if t == nil { + t = new(ExecutionPayload) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'ParentHash' + hh.PutBytes(t.ParentHash[:32]) + } + { // Field #1 'FeeRecipient' + hh.PutBytes(t.FeeRecipient[:20]) + } + { // Field #2 'StateRoot' + hh.PutBytes(t.StateRoot[:32]) + } + { // Field #3 'ReceiptsRoot' + hh.PutBytes(t.ReceiptsRoot[:32]) + } + { // Field #4 'LogsBloom' + hh.PutBytes(t.LogsBloom[:256]) + } + { // Field #5 'PrevRandao' + hh.PutBytes(t.PrevRandao[:32]) + } + { // Field #6 'BlockNumber' + hh.PutUint64(t.BlockNumber) + } + { // Field #7 'GasLimit' + hh.PutUint64(t.GasLimit) + } + { // Field #8 'GasUsed' + hh.PutUint64(t.GasUsed) + } + { // Field #9 'Timestamp' + hh.PutUint64(t.Timestamp) + } + { // Field #10 'ExtraData' + vlen := uint64(len(t.ExtraData)) + if vlen > 32 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 32), "ExtraData") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + hh.AppendBytes32(t.ExtraData[:]) + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(32, vlen, 1)) + } + { // Field #11 'BaseFeePerGas' + hh.PutBytes(t.BaseFeePerGas[:32]) + } + { // Field #12 'BlockHash' + hh.PutBytes(t.BlockHash[:32]) + } + { // Field #13 'Transactions' + t := t.Transactions + vlen := uint64(len(t)) + if vlen > 1048576 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1048576), "Transactions") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + vlen := uint64(len(t[idx1])) + if vlen > 1073741824 { + return sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(vlen, 1073741824), "Transactions[%d]", idx1) + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + hh.AppendBytes32(t[idx1][:]) + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(1073741824, vlen, 1)) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(1048576, vlen, 32)) + } + { // Field #14 'Withdrawals' + t := t.Withdrawals + vlen := uint64(len(t)) + if vlen > 16 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16), "Withdrawals") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(generic.Withdrawal) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPathf(err, "Withdrawals[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(16, vlen, 32)) + } + { // Field #15 'BlobGasUsed' + hh.PutUint64(t.BlobGasUsed) + } + { // Field #16 'ExcessBlobGas' + hh.PutUint64(t.ExcessBlobGas) + } + hh.Merkleize(idx) + return nil +} diff --git a/shared/types/eth2/fork/deneb/state_deneb.go b/shared/types/eth2/fork/deneb/state_deneb.go index f2320c947..47ae40898 100644 --- a/shared/types/eth2/fork/deneb/state_deneb.go +++ b/shared/types/eth2/fork/deneb/state_deneb.go @@ -68,7 +68,7 @@ func GetGeneralizedIndexForValidators() uint64 { func (state *BeaconState) validatorStateProof(index uint64) ([][]byte, error) { // Convert the state to a proof tree - root, err := state.GetTree() + root, err := generic.SSZ.GetTree(state) if err != nil { return nil, fmt.Errorf("could not get state tree: %w", err) } @@ -84,7 +84,7 @@ func (state *BeaconState) validatorStateProof(index uint64) ([][]byte, error) { } // Sanity check that the proof leaf matches the expected validator - validatorHashTreeRoot, err := state.Validators[index].HashTreeRoot() + validatorHashTreeRoot, err := generic.SSZ.HashTreeRoot(state.Validators[index]) if err != nil { return nil, fmt.Errorf("could not get hash tree root for validator: %w", err) } @@ -114,7 +114,7 @@ func (state *BeaconState) ValidatorProof(index uint64) ([][]byte, error) { // The EL proves against BeaconBlockHeader root, so we need to merge the state proof with that. generalizedIndex := generic.BeaconBlockHeaderStateRootGeneralizedIndex - root, err := state.LatestBlockHeader.GetTree() + root, err := generic.SSZ.GetTree(state.LatestBlockHeader) if err != nil { return nil, fmt.Errorf("could not get block header tree: %w", err) } @@ -128,7 +128,7 @@ func (state *BeaconState) ValidatorProof(index uint64) ([][]byte, error) { func (state *BeaconState) blockHeaderToStateProof(blockHeader *generic.BeaconBlockHeader) ([][]byte, error) { generalizedIndex := generic.BeaconBlockHeaderStateRootGeneralizedIndex - root, err := blockHeader.GetTree() + root, err := generic.SSZ.GetTree(blockHeader) if err != nil { return nil, fmt.Errorf("could not get block header tree: %w", err) } @@ -144,7 +144,7 @@ func (state *BeaconState) HistoricalSummaryProof(slot uint64) ([][]byte, error) if !isHistorical { return nil, fmt.Errorf("slot %d is less than %d slots in the past from the state at slot %d, you must build a proof from the block_roots field instead", slot, generic.SlotsPerHistoricalRoot, state.Slot) } - tree, err := state.GetTree() + tree, err := generic.SSZ.GetTree(state) if err != nil { return nil, fmt.Errorf("could not get state tree: %w", err) } @@ -185,7 +185,7 @@ func (state *BeaconState) HistoricalSummaryBlockRootProof(slot int) ([][]byte, e } idx := slot % int(generic.SlotsPerHistoricalRoot) - tree, err := hsls.GetTree() + tree, err := generic.SSZ.GetTree(&hsls) if err != nil { return nil, fmt.Errorf("could not get historical summary lists tree: %w", err) } @@ -209,7 +209,7 @@ func (state *BeaconState) BlockRootProof(slot uint64) ([][]byte, error) { return nil, fmt.Errorf("slot %d is more than %d slots in the past from the state at slot %d, you must build a proof from the historical_summaries instead", slot, generic.SlotsPerHistoricalRoot, state.Slot) } - tree, err := state.GetTree() + tree, err := generic.SSZ.GetTree(state) if err != nil { return nil, fmt.Errorf("could not get state tree: %w", err) } diff --git a/shared/types/eth2/fork/deneb/state_deneb_encoding.go b/shared/types/eth2/fork/deneb/state_deneb_encoding.go deleted file mode 100644 index 28e7a7e2f..000000000 --- a/shared/types/eth2/fork/deneb/state_deneb_encoding.go +++ /dev/null @@ -1,890 +0,0 @@ -// Code generated by fastssz. DO NOT EDIT. -// Hash: c9745bfaa4c4ede7bef37acadc6c3463b1539b8c630e214b93e64de4949dc988 -// Version: 0.1.3 -package deneb - -import ( - ssz "github.com/ferranbt/fastssz" - - "github.com/rocket-pool/smartnode/shared/types/eth2/generic" -) - -// MarshalSSZ ssz marshals the BeaconState object -func (b *BeaconState) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} - -// MarshalSSZTo ssz marshals the BeaconState object to a target array -func (b *BeaconState) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(2736653) - - // Field (0) 'GenesisTime' - dst = ssz.MarshalUint64(dst, b.GenesisTime) - - // Field (1) 'GenesisValidatorsRoot' - if size := len(b.GenesisValidatorsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("BeaconState.GenesisValidatorsRoot", size, 32) - return - } - dst = append(dst, b.GenesisValidatorsRoot...) - - // Field (2) 'Slot' - dst = ssz.MarshalUint64(dst, b.Slot) - - // Field (3) 'Fork' - if b.Fork == nil { - b.Fork = new(generic.Fork) - } - if dst, err = b.Fork.MarshalSSZTo(dst); err != nil { - return - } - - // Field (4) 'LatestBlockHeader' - if b.LatestBlockHeader == nil { - b.LatestBlockHeader = new(generic.BeaconBlockHeader) - } - if dst, err = b.LatestBlockHeader.MarshalSSZTo(dst); err != nil { - return - } - - // Field (5) 'BlockRoots' - for ii := 0; ii < 8192; ii++ { - dst = append(dst, b.BlockRoots[ii][:]...) - } - - // Field (6) 'StateRoots' - for ii := 0; ii < 8192; ii++ { - dst = append(dst, b.StateRoots[ii][:]...) - } - - // Offset (7) 'HistoricalRoots' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.HistoricalRoots) * 32 - - // Field (8) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(generic.Eth1Data) - } - if dst, err = b.Eth1Data.MarshalSSZTo(dst); err != nil { - return - } - - // Offset (9) 'Eth1DataVotes' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.Eth1DataVotes) * 72 - - // Field (10) 'Eth1DepositIndex' - dst = ssz.MarshalUint64(dst, b.Eth1DepositIndex) - - // Offset (11) 'Validators' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.Validators) * 121 - - // Offset (12) 'Balances' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.Balances) * 8 - - // Field (13) 'RandaoMixes' - if size := len(b.RandaoMixes); size != 65536 { - err = ssz.ErrVectorLengthFn("BeaconState.RandaoMixes", size, 65536) - return - } - for ii := 0; ii < 65536; ii++ { - if size := len(b.RandaoMixes[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("BeaconState.RandaoMixes[ii]", size, 32) - return - } - dst = append(dst, b.RandaoMixes[ii]...) - } - - // Field (14) 'Slashings' - if size := len(b.Slashings); size != 8192 { - err = ssz.ErrVectorLengthFn("BeaconState.Slashings", size, 8192) - return - } - for ii := 0; ii < 8192; ii++ { - dst = ssz.MarshalUint64(dst, b.Slashings[ii]) - } - - // Offset (15) 'PreviousEpochParticipation' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.PreviousEpochParticipation) - - // Offset (16) 'CurrentEpochParticipation' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.CurrentEpochParticipation) - - // Field (17) 'JustificationBits' - dst = append(dst, b.JustificationBits[:]...) - - // Field (18) 'PreviousJustifiedCheckpoint' - if b.PreviousJustifiedCheckpoint == nil { - b.PreviousJustifiedCheckpoint = new(generic.Checkpoint) - } - if dst, err = b.PreviousJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { - return - } - - // Field (19) 'CurrentJustifiedCheckpoint' - if b.CurrentJustifiedCheckpoint == nil { - b.CurrentJustifiedCheckpoint = new(generic.Checkpoint) - } - if dst, err = b.CurrentJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { - return - } - - // Field (20) 'FinalizedCheckpoint' - if b.FinalizedCheckpoint == nil { - b.FinalizedCheckpoint = new(generic.Checkpoint) - } - if dst, err = b.FinalizedCheckpoint.MarshalSSZTo(dst); err != nil { - return - } - - // Offset (21) 'InactivityScores' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.InactivityScores) * 8 - - // Field (22) 'CurrentSyncCommittee' - if b.CurrentSyncCommittee == nil { - b.CurrentSyncCommittee = new(generic.SyncCommittee) - } - if dst, err = b.CurrentSyncCommittee.MarshalSSZTo(dst); err != nil { - return - } - - // Field (23) 'NextSyncCommittee' - if b.NextSyncCommittee == nil { - b.NextSyncCommittee = new(generic.SyncCommittee) - } - if dst, err = b.NextSyncCommittee.MarshalSSZTo(dst); err != nil { - return - } - - // Offset (24) 'LatestExecutionPayloadHeader' - dst = ssz.WriteOffset(dst, offset) - if b.LatestExecutionPayloadHeader == nil { - b.LatestExecutionPayloadHeader = new(generic.ExecutionPayloadHeader) - } - offset += b.LatestExecutionPayloadHeader.SizeSSZ() - - // Field (25) 'NextWithdrawalIndex' - dst = ssz.MarshalUint64(dst, b.NextWithdrawalIndex) - - // Field (26) 'NextWithdrawalValidatorIndex' - dst = ssz.MarshalUint64(dst, b.NextWithdrawalValidatorIndex) - - // Offset (27) 'HistoricalSummaries' - dst = ssz.WriteOffset(dst, offset) - - // Field (7) 'HistoricalRoots' - if size := len(b.HistoricalRoots); size > 16777216 { - err = ssz.ErrListTooBigFn("BeaconState.HistoricalRoots", size, 16777216) - return - } - for ii := 0; ii < len(b.HistoricalRoots); ii++ { - if size := len(b.HistoricalRoots[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("BeaconState.HistoricalRoots[ii]", size, 32) - return - } - dst = append(dst, b.HistoricalRoots[ii]...) - } - - // Field (9) 'Eth1DataVotes' - if size := len(b.Eth1DataVotes); size > 2048 { - err = ssz.ErrListTooBigFn("BeaconState.Eth1DataVotes", size, 2048) - return - } - for ii := 0; ii < len(b.Eth1DataVotes); ii++ { - if dst, err = b.Eth1DataVotes[ii].MarshalSSZTo(dst); err != nil { - return - } - } - - // Field (11) 'Validators' - if size := len(b.Validators); size > 1099511627776 { - err = ssz.ErrListTooBigFn("BeaconState.Validators", size, 1099511627776) - return - } - for ii := 0; ii < len(b.Validators); ii++ { - if dst, err = b.Validators[ii].MarshalSSZTo(dst); err != nil { - return - } - } - - // Field (12) 'Balances' - if size := len(b.Balances); size > 1099511627776 { - err = ssz.ErrListTooBigFn("BeaconState.Balances", size, 1099511627776) - return - } - for ii := 0; ii < len(b.Balances); ii++ { - dst = ssz.MarshalUint64(dst, b.Balances[ii]) - } - - // Field (15) 'PreviousEpochParticipation' - if size := len(b.PreviousEpochParticipation); size > 1099511627776 { - err = ssz.ErrBytesLengthFn("BeaconState.PreviousEpochParticipation", size, 1099511627776) - return - } - dst = append(dst, b.PreviousEpochParticipation...) - - // Field (16) 'CurrentEpochParticipation' - if size := len(b.CurrentEpochParticipation); size > 1099511627776 { - err = ssz.ErrBytesLengthFn("BeaconState.CurrentEpochParticipation", size, 1099511627776) - return - } - dst = append(dst, b.CurrentEpochParticipation...) - - // Field (21) 'InactivityScores' - if size := len(b.InactivityScores); size > 1099511627776 { - err = ssz.ErrListTooBigFn("BeaconState.InactivityScores", size, 1099511627776) - return - } - for ii := 0; ii < len(b.InactivityScores); ii++ { - dst = ssz.MarshalUint64(dst, b.InactivityScores[ii]) - } - - // Field (24) 'LatestExecutionPayloadHeader' - if dst, err = b.LatestExecutionPayloadHeader.MarshalSSZTo(dst); err != nil { - return - } - - // Field (27) 'HistoricalSummaries' - if size := len(b.HistoricalSummaries); size > 16777216 { - err = ssz.ErrListTooBigFn("BeaconState.HistoricalSummaries", size, 16777216) - return - } - for ii := 0; ii < len(b.HistoricalSummaries); ii++ { - if dst, err = b.HistoricalSummaries[ii].MarshalSSZTo(dst); err != nil { - return - } - } - - return -} - -// UnmarshalSSZ ssz unmarshals the BeaconState object -func (b *BeaconState) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 2736653 { - return ssz.ErrSize - } - - tail := buf - var o7, o9, o11, o12, o15, o16, o21, o24, o27 uint64 - - // Field (0) 'GenesisTime' - b.GenesisTime = ssz.UnmarshallUint64(buf[0:8]) - - // Field (1) 'GenesisValidatorsRoot' - if cap(b.GenesisValidatorsRoot) == 0 { - b.GenesisValidatorsRoot = make([]byte, 0, len(buf[8:40])) - } - b.GenesisValidatorsRoot = append(b.GenesisValidatorsRoot, buf[8:40]...) - - // Field (2) 'Slot' - b.Slot = ssz.UnmarshallUint64(buf[40:48]) - - // Field (3) 'Fork' - if b.Fork == nil { - b.Fork = new(generic.Fork) - } - if err = b.Fork.UnmarshalSSZ(buf[48:64]); err != nil { - return err - } - - // Field (4) 'LatestBlockHeader' - if b.LatestBlockHeader == nil { - b.LatestBlockHeader = new(generic.BeaconBlockHeader) - } - if err = b.LatestBlockHeader.UnmarshalSSZ(buf[64:176]); err != nil { - return err - } - - // Field (5) 'BlockRoots' - - for ii := 0; ii < 8192; ii++ { - copy(b.BlockRoots[ii][:], buf[176:262320][ii*32:(ii+1)*32]) - } - - // Field (6) 'StateRoots' - - for ii := 0; ii < 8192; ii++ { - copy(b.StateRoots[ii][:], buf[262320:524464][ii*32:(ii+1)*32]) - } - - // Offset (7) 'HistoricalRoots' - if o7 = ssz.ReadOffset(buf[524464:524468]); o7 > size { - return ssz.ErrOffset - } - - if o7 != 2736653 { - return ssz.ErrInvalidVariableOffset - } - - // Field (8) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(generic.Eth1Data) - } - if err = b.Eth1Data.UnmarshalSSZ(buf[524468:524540]); err != nil { - return err - } - - // Offset (9) 'Eth1DataVotes' - if o9 = ssz.ReadOffset(buf[524540:524544]); o9 > size || o7 > o9 { - return ssz.ErrOffset - } - - // Field (10) 'Eth1DepositIndex' - b.Eth1DepositIndex = ssz.UnmarshallUint64(buf[524544:524552]) - - // Offset (11) 'Validators' - if o11 = ssz.ReadOffset(buf[524552:524556]); o11 > size || o9 > o11 { - return ssz.ErrOffset - } - - // Offset (12) 'Balances' - if o12 = ssz.ReadOffset(buf[524556:524560]); o12 > size || o11 > o12 { - return ssz.ErrOffset - } - - // Field (13) 'RandaoMixes' - b.RandaoMixes = make([][]byte, 65536) - for ii := 0; ii < 65536; ii++ { - if cap(b.RandaoMixes[ii]) == 0 { - b.RandaoMixes[ii] = make([]byte, 0, len(buf[524560:2621712][ii*32:(ii+1)*32])) - } - b.RandaoMixes[ii] = append(b.RandaoMixes[ii], buf[524560:2621712][ii*32:(ii+1)*32]...) - } - - // Field (14) 'Slashings' - b.Slashings = ssz.ExtendUint64(b.Slashings, 8192) - for ii := 0; ii < 8192; ii++ { - b.Slashings[ii] = ssz.UnmarshallUint64(buf[2621712:2687248][ii*8 : (ii+1)*8]) - } - - // Offset (15) 'PreviousEpochParticipation' - if o15 = ssz.ReadOffset(buf[2687248:2687252]); o15 > size || o12 > o15 { - return ssz.ErrOffset - } - - // Offset (16) 'CurrentEpochParticipation' - if o16 = ssz.ReadOffset(buf[2687252:2687256]); o16 > size || o15 > o16 { - return ssz.ErrOffset - } - - // Field (17) 'JustificationBits' - copy(b.JustificationBits[:], buf[2687256:2687257]) - - // Field (18) 'PreviousJustifiedCheckpoint' - if b.PreviousJustifiedCheckpoint == nil { - b.PreviousJustifiedCheckpoint = new(generic.Checkpoint) - } - if err = b.PreviousJustifiedCheckpoint.UnmarshalSSZ(buf[2687257:2687297]); err != nil { - return err - } - - // Field (19) 'CurrentJustifiedCheckpoint' - if b.CurrentJustifiedCheckpoint == nil { - b.CurrentJustifiedCheckpoint = new(generic.Checkpoint) - } - if err = b.CurrentJustifiedCheckpoint.UnmarshalSSZ(buf[2687297:2687337]); err != nil { - return err - } - - // Field (20) 'FinalizedCheckpoint' - if b.FinalizedCheckpoint == nil { - b.FinalizedCheckpoint = new(generic.Checkpoint) - } - if err = b.FinalizedCheckpoint.UnmarshalSSZ(buf[2687337:2687377]); err != nil { - return err - } - - // Offset (21) 'InactivityScores' - if o21 = ssz.ReadOffset(buf[2687377:2687381]); o21 > size || o16 > o21 { - return ssz.ErrOffset - } - - // Field (22) 'CurrentSyncCommittee' - if b.CurrentSyncCommittee == nil { - b.CurrentSyncCommittee = new(generic.SyncCommittee) - } - if err = b.CurrentSyncCommittee.UnmarshalSSZ(buf[2687381:2712005]); err != nil { - return err - } - - // Field (23) 'NextSyncCommittee' - if b.NextSyncCommittee == nil { - b.NextSyncCommittee = new(generic.SyncCommittee) - } - if err = b.NextSyncCommittee.UnmarshalSSZ(buf[2712005:2736629]); err != nil { - return err - } - - // Offset (24) 'LatestExecutionPayloadHeader' - if o24 = ssz.ReadOffset(buf[2736629:2736633]); o24 > size || o21 > o24 { - return ssz.ErrOffset - } - - // Field (25) 'NextWithdrawalIndex' - b.NextWithdrawalIndex = ssz.UnmarshallUint64(buf[2736633:2736641]) - - // Field (26) 'NextWithdrawalValidatorIndex' - b.NextWithdrawalValidatorIndex = ssz.UnmarshallUint64(buf[2736641:2736649]) - - // Offset (27) 'HistoricalSummaries' - if o27 = ssz.ReadOffset(buf[2736649:2736653]); o27 > size || o24 > o27 { - return ssz.ErrOffset - } - - // Field (7) 'HistoricalRoots' - { - buf = tail[o7:o9] - num, err := ssz.DivideInt2(len(buf), 32, 16777216) - if err != nil { - return err - } - b.HistoricalRoots = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(b.HistoricalRoots[ii]) == 0 { - b.HistoricalRoots[ii] = make([]byte, 0, len(buf[ii*32:(ii+1)*32])) - } - b.HistoricalRoots[ii] = append(b.HistoricalRoots[ii], buf[ii*32:(ii+1)*32]...) - } - } - - // Field (9) 'Eth1DataVotes' - { - buf = tail[o9:o11] - num, err := ssz.DivideInt2(len(buf), 72, 2048) - if err != nil { - return err - } - b.Eth1DataVotes = make([]*generic.Eth1Data, num) - for ii := 0; ii < num; ii++ { - if b.Eth1DataVotes[ii] == nil { - b.Eth1DataVotes[ii] = new(generic.Eth1Data) - } - if err = b.Eth1DataVotes[ii].UnmarshalSSZ(buf[ii*72 : (ii+1)*72]); err != nil { - return err - } - } - } - - // Field (11) 'Validators' - { - buf = tail[o11:o12] - num, err := ssz.DivideInt2(len(buf), 121, 1099511627776) - if err != nil { - return err - } - b.Validators = make([]*generic.Validator, num) - for ii := 0; ii < num; ii++ { - if b.Validators[ii] == nil { - b.Validators[ii] = new(generic.Validator) - } - if err = b.Validators[ii].UnmarshalSSZ(buf[ii*121 : (ii+1)*121]); err != nil { - return err - } - } - } - - // Field (12) 'Balances' - { - buf = tail[o12:o15] - num, err := ssz.DivideInt2(len(buf), 8, 1099511627776) - if err != nil { - return err - } - b.Balances = ssz.ExtendUint64(b.Balances, num) - for ii := 0; ii < num; ii++ { - b.Balances[ii] = ssz.UnmarshallUint64(buf[ii*8 : (ii+1)*8]) - } - } - - // Field (15) 'PreviousEpochParticipation' - { - buf = tail[o15:o16] - if len(buf) > 1099511627776 { - return ssz.ErrBytesLength - } - if cap(b.PreviousEpochParticipation) == 0 { - b.PreviousEpochParticipation = make([]byte, 0, len(buf)) - } - b.PreviousEpochParticipation = append(b.PreviousEpochParticipation, buf...) - } - - // Field (16) 'CurrentEpochParticipation' - { - buf = tail[o16:o21] - if len(buf) > 1099511627776 { - return ssz.ErrBytesLength - } - if cap(b.CurrentEpochParticipation) == 0 { - b.CurrentEpochParticipation = make([]byte, 0, len(buf)) - } - b.CurrentEpochParticipation = append(b.CurrentEpochParticipation, buf...) - } - - // Field (21) 'InactivityScores' - { - buf = tail[o21:o24] - num, err := ssz.DivideInt2(len(buf), 8, 1099511627776) - if err != nil { - return err - } - b.InactivityScores = ssz.ExtendUint64(b.InactivityScores, num) - for ii := 0; ii < num; ii++ { - b.InactivityScores[ii] = ssz.UnmarshallUint64(buf[ii*8 : (ii+1)*8]) - } - } - - // Field (24) 'LatestExecutionPayloadHeader' - { - buf = tail[o24:o27] - if b.LatestExecutionPayloadHeader == nil { - b.LatestExecutionPayloadHeader = new(generic.ExecutionPayloadHeader) - } - if err = b.LatestExecutionPayloadHeader.UnmarshalSSZ(buf); err != nil { - return err - } - } - - // Field (27) 'HistoricalSummaries' - { - buf = tail[o27:] - num, err := ssz.DivideInt2(len(buf), 64, 16777216) - if err != nil { - return err - } - b.HistoricalSummaries = make([]*generic.HistoricalSummary, num) - for ii := 0; ii < num; ii++ { - if b.HistoricalSummaries[ii] == nil { - b.HistoricalSummaries[ii] = new(generic.HistoricalSummary) - } - if err = b.HistoricalSummaries[ii].UnmarshalSSZ(buf[ii*64 : (ii+1)*64]); err != nil { - return err - } - } - } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the BeaconState object -func (b *BeaconState) SizeSSZ() (size int) { - size = 2736653 - - // Field (7) 'HistoricalRoots' - size += len(b.HistoricalRoots) * 32 - - // Field (9) 'Eth1DataVotes' - size += len(b.Eth1DataVotes) * 72 - - // Field (11) 'Validators' - size += len(b.Validators) * 121 - - // Field (12) 'Balances' - size += len(b.Balances) * 8 - - // Field (15) 'PreviousEpochParticipation' - size += len(b.PreviousEpochParticipation) - - // Field (16) 'CurrentEpochParticipation' - size += len(b.CurrentEpochParticipation) - - // Field (21) 'InactivityScores' - size += len(b.InactivityScores) * 8 - - // Field (24) 'LatestExecutionPayloadHeader' - if b.LatestExecutionPayloadHeader == nil { - b.LatestExecutionPayloadHeader = new(generic.ExecutionPayloadHeader) - } - size += b.LatestExecutionPayloadHeader.SizeSSZ() - - // Field (27) 'HistoricalSummaries' - size += len(b.HistoricalSummaries) * 64 - - return -} - -// HashTreeRoot ssz hashes the BeaconState object -func (b *BeaconState) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) -} - -// HashTreeRootWith ssz hashes the BeaconState object with a hasher -func (b *BeaconState) HashTreeRootWith(hh ssz.HashWalker) (err error) { - indx := hh.Index() - - // Field (0) 'GenesisTime' - hh.PutUint64(b.GenesisTime) - - // Field (1) 'GenesisValidatorsRoot' - if size := len(b.GenesisValidatorsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("BeaconState.GenesisValidatorsRoot", size, 32) - return - } - hh.PutBytes(b.GenesisValidatorsRoot) - - // Field (2) 'Slot' - hh.PutUint64(b.Slot) - - // Field (3) 'Fork' - if b.Fork == nil { - b.Fork = new(generic.Fork) - } - if err = b.Fork.HashTreeRootWith(hh); err != nil { - return - } - - // Field (4) 'LatestBlockHeader' - if b.LatestBlockHeader == nil { - b.LatestBlockHeader = new(generic.BeaconBlockHeader) - } - if err = b.LatestBlockHeader.HashTreeRootWith(hh); err != nil { - return - } - - // Field (5) 'BlockRoots' - { - subIndx := hh.Index() - for _, i := range b.BlockRoots { - hh.Append(i[:]) - } - hh.Merkleize(subIndx) - } - - // Field (6) 'StateRoots' - { - subIndx := hh.Index() - for _, i := range b.StateRoots { - hh.Append(i[:]) - } - hh.Merkleize(subIndx) - } - - // Field (7) 'HistoricalRoots' - { - if size := len(b.HistoricalRoots); size > 16777216 { - err = ssz.ErrListTooBigFn("BeaconState.HistoricalRoots", size, 16777216) - return - } - subIndx := hh.Index() - for _, i := range b.HistoricalRoots { - if len(i) != 32 { - err = ssz.ErrBytesLength - return - } - hh.Append(i) - } - numItems := uint64(len(b.HistoricalRoots)) - hh.MerkleizeWithMixin(subIndx, numItems, 16777216) - } - - // Field (8) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(generic.Eth1Data) - } - if err = b.Eth1Data.HashTreeRootWith(hh); err != nil { - return - } - - // Field (9) 'Eth1DataVotes' - { - subIndx := hh.Index() - num := uint64(len(b.Eth1DataVotes)) - if num > 2048 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range b.Eth1DataVotes { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } - } - hh.MerkleizeWithMixin(subIndx, num, 2048) - } - - // Field (10) 'Eth1DepositIndex' - hh.PutUint64(b.Eth1DepositIndex) - - // Field (11) 'Validators' - { - subIndx := hh.Index() - num := uint64(len(b.Validators)) - if num > 1099511627776 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range b.Validators { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } - } - hh.MerkleizeWithMixin(subIndx, num, 1099511627776) - } - - // Field (12) 'Balances' - { - if size := len(b.Balances); size > 1099511627776 { - err = ssz.ErrListTooBigFn("BeaconState.Balances", size, 1099511627776) - return - } - subIndx := hh.Index() - for _, i := range b.Balances { - hh.AppendUint64(i) - } - hh.FillUpTo32() - numItems := uint64(len(b.Balances)) - hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(1099511627776, numItems, 8)) - } - - // Field (13) 'RandaoMixes' - { - if size := len(b.RandaoMixes); size != 65536 { - err = ssz.ErrVectorLengthFn("BeaconState.RandaoMixes", size, 65536) - return - } - subIndx := hh.Index() - for _, i := range b.RandaoMixes { - if len(i) != 32 { - err = ssz.ErrBytesLength - return - } - hh.Append(i) - } - hh.Merkleize(subIndx) - } - - // Field (14) 'Slashings' - { - if size := len(b.Slashings); size != 8192 { - err = ssz.ErrVectorLengthFn("BeaconState.Slashings", size, 8192) - return - } - subIndx := hh.Index() - for _, i := range b.Slashings { - hh.AppendUint64(i) - } - hh.Merkleize(subIndx) - } - - // Field (15) 'PreviousEpochParticipation' - { - elemIndx := hh.Index() - byteLen := uint64(len(b.PreviousEpochParticipation)) - if byteLen > 1099511627776 { - err = ssz.ErrIncorrectListSize - return - } - hh.Append(b.PreviousEpochParticipation) - hh.MerkleizeWithMixin(elemIndx, byteLen, (1099511627776+31)/32) - } - - // Field (16) 'CurrentEpochParticipation' - { - elemIndx := hh.Index() - byteLen := uint64(len(b.CurrentEpochParticipation)) - if byteLen > 1099511627776 { - err = ssz.ErrIncorrectListSize - return - } - hh.Append(b.CurrentEpochParticipation) - hh.MerkleizeWithMixin(elemIndx, byteLen, (1099511627776+31)/32) - } - - // Field (17) 'JustificationBits' - hh.PutBytes(b.JustificationBits[:]) - - // Field (18) 'PreviousJustifiedCheckpoint' - if b.PreviousJustifiedCheckpoint == nil { - b.PreviousJustifiedCheckpoint = new(generic.Checkpoint) - } - if err = b.PreviousJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { - return - } - - // Field (19) 'CurrentJustifiedCheckpoint' - if b.CurrentJustifiedCheckpoint == nil { - b.CurrentJustifiedCheckpoint = new(generic.Checkpoint) - } - if err = b.CurrentJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { - return - } - - // Field (20) 'FinalizedCheckpoint' - if b.FinalizedCheckpoint == nil { - b.FinalizedCheckpoint = new(generic.Checkpoint) - } - if err = b.FinalizedCheckpoint.HashTreeRootWith(hh); err != nil { - return - } - - // Field (21) 'InactivityScores' - { - if size := len(b.InactivityScores); size > 1099511627776 { - err = ssz.ErrListTooBigFn("BeaconState.InactivityScores", size, 1099511627776) - return - } - subIndx := hh.Index() - for _, i := range b.InactivityScores { - hh.AppendUint64(i) - } - hh.FillUpTo32() - numItems := uint64(len(b.InactivityScores)) - hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(1099511627776, numItems, 8)) - } - - // Field (22) 'CurrentSyncCommittee' - if b.CurrentSyncCommittee == nil { - b.CurrentSyncCommittee = new(generic.SyncCommittee) - } - if err = b.CurrentSyncCommittee.HashTreeRootWith(hh); err != nil { - return - } - - // Field (23) 'NextSyncCommittee' - if b.NextSyncCommittee == nil { - b.NextSyncCommittee = new(generic.SyncCommittee) - } - if err = b.NextSyncCommittee.HashTreeRootWith(hh); err != nil { - return - } - - // Field (24) 'LatestExecutionPayloadHeader' - if err = b.LatestExecutionPayloadHeader.HashTreeRootWith(hh); err != nil { - return - } - - // Field (25) 'NextWithdrawalIndex' - hh.PutUint64(b.NextWithdrawalIndex) - - // Field (26) 'NextWithdrawalValidatorIndex' - hh.PutUint64(b.NextWithdrawalValidatorIndex) - - // Field (27) 'HistoricalSummaries' - { - subIndx := hh.Index() - num := uint64(len(b.HistoricalSummaries)) - if num > 16777216 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range b.HistoricalSummaries { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } - } - hh.MerkleizeWithMixin(subIndx, num, 16777216) - } - - hh.Merkleize(indx) - return -} - -// GetTree ssz hashes the BeaconState object -func (b *BeaconState) GetTree() (*ssz.Node, error) { - return ssz.ProofTree(b) -} diff --git a/shared/types/eth2/fork/electra/block_electra.go b/shared/types/eth2/fork/electra/block_electra.go index ff1b3b25f..8ef01ebb8 100644 --- a/shared/types/eth2/fork/electra/block_electra.go +++ b/shared/types/eth2/fork/electra/block_electra.go @@ -10,7 +10,7 @@ import ( const BeaconBlockBodyChunksCeil uint64 = 16 func (b *SignedBeaconBlock) ProveWithdrawal(indexInWithdrawalsArray uint64) ([][]byte, error) { - tree, err := b.Block.GetTree() + tree, err := generic.SSZ.GetTree(b.Block) if err != nil { return nil, err } diff --git a/shared/types/eth2/fork/electra/block_electra_encoding.go b/shared/types/eth2/fork/electra/block_electra_encoding.go deleted file mode 100644 index e46ca29fd..000000000 --- a/shared/types/eth2/fork/electra/block_electra_encoding.go +++ /dev/null @@ -1,1850 +0,0 @@ -// Code generated by fastssz. DO NOT EDIT. -// Hash: 69e638a904e3884639a92c45d7fc9fb78e7f4fb79160efa6d2f186569d34b3b0 -// Version: 0.1.3 -package electra - -import ( - ssz "github.com/ferranbt/fastssz" - - "github.com/rocket-pool/smartnode/shared/types/eth2/generic" -) - -// MarshalSSZ ssz marshals the BeaconBlock object -func (b *BeaconBlock) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} - -// MarshalSSZTo ssz marshals the BeaconBlock object to a target array -func (b *BeaconBlock) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(84) - - // Field (0) 'Slot' - dst = ssz.MarshalUint64(dst, b.Slot) - - // Field (1) 'ProposerIndex' - dst = ssz.MarshalUint64(dst, b.ProposerIndex) - - // Field (2) 'ParentRoot' - dst = append(dst, b.ParentRoot[:]...) - - // Field (3) 'StateRoot' - dst = append(dst, b.StateRoot[:]...) - - // Offset (4) 'Body' - dst = ssz.WriteOffset(dst, offset) - - // Field (4) 'Body' - if dst, err = b.Body.MarshalSSZTo(dst); err != nil { - return - } - - return -} - -// UnmarshalSSZ ssz unmarshals the BeaconBlock object -func (b *BeaconBlock) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 84 { - return ssz.ErrSize - } - - tail := buf - var o4 uint64 - - // Field (0) 'Slot' - b.Slot = ssz.UnmarshallUint64(buf[0:8]) - - // Field (1) 'ProposerIndex' - b.ProposerIndex = ssz.UnmarshallUint64(buf[8:16]) - - // Field (2) 'ParentRoot' - copy(b.ParentRoot[:], buf[16:48]) - - // Field (3) 'StateRoot' - copy(b.StateRoot[:], buf[48:80]) - - // Offset (4) 'Body' - if o4 = ssz.ReadOffset(buf[80:84]); o4 > size { - return ssz.ErrOffset - } - - if o4 != 84 { - return ssz.ErrInvalidVariableOffset - } - - // Field (4) 'Body' - { - buf = tail[o4:] - if b.Body == nil { - b.Body = new(BeaconBlockBody) - } - if err = b.Body.UnmarshalSSZ(buf); err != nil { - return err - } - } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the BeaconBlock object -func (b *BeaconBlock) SizeSSZ() (size int) { - size = 84 - - // Field (4) 'Body' - if b.Body == nil { - b.Body = new(BeaconBlockBody) - } - size += b.Body.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the BeaconBlock object -func (b *BeaconBlock) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) -} - -// HashTreeRootWith ssz hashes the BeaconBlock object with a hasher -func (b *BeaconBlock) HashTreeRootWith(hh ssz.HashWalker) (err error) { - indx := hh.Index() - - // Field (0) 'Slot' - hh.PutUint64(b.Slot) - - // Field (1) 'ProposerIndex' - hh.PutUint64(b.ProposerIndex) - - // Field (2) 'ParentRoot' - hh.PutBytes(b.ParentRoot[:]) - - // Field (3) 'StateRoot' - hh.PutBytes(b.StateRoot[:]) - - // Field (4) 'Body' - if err = b.Body.HashTreeRootWith(hh); err != nil { - return - } - - hh.Merkleize(indx) - return -} - -// GetTree ssz hashes the BeaconBlock object -func (b *BeaconBlock) GetTree() (*ssz.Node, error) { - return ssz.ProofTree(b) -} - -// MarshalSSZ ssz marshals the SignedBeaconBlock object -func (s *SignedBeaconBlock) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) -} - -// MarshalSSZTo ssz marshals the SignedBeaconBlock object to a target array -func (s *SignedBeaconBlock) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(100) - - // Offset (0) 'Block' - dst = ssz.WriteOffset(dst, offset) - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("SignedBeaconBlock.Signature", size, 96) - return - } - dst = append(dst, s.Signature...) - - // Field (0) 'Block' - if dst, err = s.Block.MarshalSSZTo(dst); err != nil { - return - } - - return -} - -// UnmarshalSSZ ssz unmarshals the SignedBeaconBlock object -func (s *SignedBeaconBlock) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 100 { - return ssz.ErrSize - } - - tail := buf - var o0 uint64 - - // Offset (0) 'Block' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } - - if o0 != 100 { - return ssz.ErrInvalidVariableOffset - } - - // Field (1) 'Signature' - if cap(s.Signature) == 0 { - s.Signature = make([]byte, 0, len(buf[4:100])) - } - s.Signature = append(s.Signature, buf[4:100]...) - - // Field (0) 'Block' - { - buf = tail[o0:] - if s.Block == nil { - s.Block = new(BeaconBlock) - } - if err = s.Block.UnmarshalSSZ(buf); err != nil { - return err - } - } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the SignedBeaconBlock object -func (s *SignedBeaconBlock) SizeSSZ() (size int) { - size = 100 - - // Field (0) 'Block' - if s.Block == nil { - s.Block = new(BeaconBlock) - } - size += s.Block.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the SignedBeaconBlock object -func (s *SignedBeaconBlock) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) -} - -// HashTreeRootWith ssz hashes the SignedBeaconBlock object with a hasher -func (s *SignedBeaconBlock) HashTreeRootWith(hh ssz.HashWalker) (err error) { - indx := hh.Index() - - // Field (0) 'Block' - if err = s.Block.HashTreeRootWith(hh); err != nil { - return - } - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("SignedBeaconBlock.Signature", size, 96) - return - } - hh.PutBytes(s.Signature) - - hh.Merkleize(indx) - return -} - -// GetTree ssz hashes the SignedBeaconBlock object -func (s *SignedBeaconBlock) GetTree() (*ssz.Node, error) { - return ssz.ProofTree(s) -} - -// MarshalSSZ ssz marshals the BeaconBlockBody object -func (b *BeaconBlockBody) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} - -// MarshalSSZTo ssz marshals the BeaconBlockBody object to a target array -func (b *BeaconBlockBody) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(396) - - // Field (0) 'RandaoReveal' - if size := len(b.RandaoReveal); size != 96 { - err = ssz.ErrBytesLengthFn("BeaconBlockBody.RandaoReveal", size, 96) - return - } - dst = append(dst, b.RandaoReveal...) - - // Field (1) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(generic.Eth1Data) - } - if dst, err = b.Eth1Data.MarshalSSZTo(dst); err != nil { - return - } - - // Field (2) 'Graffiti' - dst = append(dst, b.Graffiti[:]...) - - // Offset (3) 'ProposerSlashings' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.ProposerSlashings) * 416 - - // Offset (4) 'AttesterSlashings' - dst = ssz.WriteOffset(dst, offset) - for ii := 0; ii < len(b.AttesterSlashings); ii++ { - offset += 4 - offset += b.AttesterSlashings[ii].SizeSSZ() - } - - // Offset (5) 'Attestations' - dst = ssz.WriteOffset(dst, offset) - for ii := 0; ii < len(b.Attestations); ii++ { - offset += 4 - offset += b.Attestations[ii].SizeSSZ() - } - - // Offset (6) 'Deposits' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.Deposits) * 1240 - - // Offset (7) 'VoluntaryExits' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.VoluntaryExits) * 112 - - // Field (8) 'SyncAggregate' - if b.SyncAggregate == nil { - b.SyncAggregate = new(generic.SyncAggregate) - } - if dst, err = b.SyncAggregate.MarshalSSZTo(dst); err != nil { - return - } - - // Offset (9) 'ExecutionPayload' - dst = ssz.WriteOffset(dst, offset) - if b.ExecutionPayload == nil { - b.ExecutionPayload = new(generic.ExecutionPayload) - } - offset += b.ExecutionPayload.SizeSSZ() - - // Offset (10) 'BlsToExecutionChanges' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.BlsToExecutionChanges) * 172 - - // Offset (11) 'BlobKzgCommitments' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.BlobKzgCommitments) * 48 - - // Offset (12) 'ExecutionRequests' - dst = ssz.WriteOffset(dst, offset) - - // Field (3) 'ProposerSlashings' - if size := len(b.ProposerSlashings); size > 16 { - err = ssz.ErrListTooBigFn("BeaconBlockBody.ProposerSlashings", size, 16) - return - } - for ii := 0; ii < len(b.ProposerSlashings); ii++ { - if dst, err = b.ProposerSlashings[ii].MarshalSSZTo(dst); err != nil { - return - } - } - - // Field (4) 'AttesterSlashings' - if size := len(b.AttesterSlashings); size > 1 { - err = ssz.ErrListTooBigFn("BeaconBlockBody.AttesterSlashings", size, 1) - return - } - { - offset = 4 * len(b.AttesterSlashings) - for ii := 0; ii < len(b.AttesterSlashings); ii++ { - dst = ssz.WriteOffset(dst, offset) - offset += b.AttesterSlashings[ii].SizeSSZ() - } - } - for ii := 0; ii < len(b.AttesterSlashings); ii++ { - if dst, err = b.AttesterSlashings[ii].MarshalSSZTo(dst); err != nil { - return - } - } - - // Field (5) 'Attestations' - if size := len(b.Attestations); size > 8 { - err = ssz.ErrListTooBigFn("BeaconBlockBody.Attestations", size, 8) - return - } - { - offset = 4 * len(b.Attestations) - for ii := 0; ii < len(b.Attestations); ii++ { - dst = ssz.WriteOffset(dst, offset) - offset += b.Attestations[ii].SizeSSZ() - } - } - for ii := 0; ii < len(b.Attestations); ii++ { - if dst, err = b.Attestations[ii].MarshalSSZTo(dst); err != nil { - return - } - } - - // Field (6) 'Deposits' - if size := len(b.Deposits); size > 16 { - err = ssz.ErrListTooBigFn("BeaconBlockBody.Deposits", size, 16) - return - } - for ii := 0; ii < len(b.Deposits); ii++ { - if dst, err = b.Deposits[ii].MarshalSSZTo(dst); err != nil { - return - } - } - - // Field (7) 'VoluntaryExits' - if size := len(b.VoluntaryExits); size > 16 { - err = ssz.ErrListTooBigFn("BeaconBlockBody.VoluntaryExits", size, 16) - return - } - for ii := 0; ii < len(b.VoluntaryExits); ii++ { - if dst, err = b.VoluntaryExits[ii].MarshalSSZTo(dst); err != nil { - return - } - } - - // Field (9) 'ExecutionPayload' - if dst, err = b.ExecutionPayload.MarshalSSZTo(dst); err != nil { - return - } - - // Field (10) 'BlsToExecutionChanges' - if size := len(b.BlsToExecutionChanges); size > 16 { - err = ssz.ErrListTooBigFn("BeaconBlockBody.BlsToExecutionChanges", size, 16) - return - } - for ii := 0; ii < len(b.BlsToExecutionChanges); ii++ { - if dst, err = b.BlsToExecutionChanges[ii].MarshalSSZTo(dst); err != nil { - return - } - } - - // Field (11) 'BlobKzgCommitments' - if size := len(b.BlobKzgCommitments); size > 4096 { - err = ssz.ErrListTooBigFn("BeaconBlockBody.BlobKzgCommitments", size, 4096) - return - } - for ii := 0; ii < len(b.BlobKzgCommitments); ii++ { - dst = append(dst, b.BlobKzgCommitments[ii][:]...) - } - - // Field (12) 'ExecutionRequests' - if dst, err = b.ExecutionRequests.MarshalSSZTo(dst); err != nil { - return - } - - return -} - -// UnmarshalSSZ ssz unmarshals the BeaconBlockBody object -func (b *BeaconBlockBody) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 396 { - return ssz.ErrSize - } - - tail := buf - var o3, o4, o5, o6, o7, o9, o10, o11, o12 uint64 - - // Field (0) 'RandaoReveal' - if cap(b.RandaoReveal) == 0 { - b.RandaoReveal = make([]byte, 0, len(buf[0:96])) - } - b.RandaoReveal = append(b.RandaoReveal, buf[0:96]...) - - // Field (1) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(generic.Eth1Data) - } - if err = b.Eth1Data.UnmarshalSSZ(buf[96:168]); err != nil { - return err - } - - // Field (2) 'Graffiti' - copy(b.Graffiti[:], buf[168:200]) - - // Offset (3) 'ProposerSlashings' - if o3 = ssz.ReadOffset(buf[200:204]); o3 > size { - return ssz.ErrOffset - } - - if o3 != 396 { - return ssz.ErrInvalidVariableOffset - } - - // Offset (4) 'AttesterSlashings' - if o4 = ssz.ReadOffset(buf[204:208]); o4 > size || o3 > o4 { - return ssz.ErrOffset - } - - // Offset (5) 'Attestations' - if o5 = ssz.ReadOffset(buf[208:212]); o5 > size || o4 > o5 { - return ssz.ErrOffset - } - - // Offset (6) 'Deposits' - if o6 = ssz.ReadOffset(buf[212:216]); o6 > size || o5 > o6 { - return ssz.ErrOffset - } - - // Offset (7) 'VoluntaryExits' - if o7 = ssz.ReadOffset(buf[216:220]); o7 > size || o6 > o7 { - return ssz.ErrOffset - } - - // Field (8) 'SyncAggregate' - if b.SyncAggregate == nil { - b.SyncAggregate = new(generic.SyncAggregate) - } - if err = b.SyncAggregate.UnmarshalSSZ(buf[220:380]); err != nil { - return err - } - - // Offset (9) 'ExecutionPayload' - if o9 = ssz.ReadOffset(buf[380:384]); o9 > size || o7 > o9 { - return ssz.ErrOffset - } - - // Offset (10) 'BlsToExecutionChanges' - if o10 = ssz.ReadOffset(buf[384:388]); o10 > size || o9 > o10 { - return ssz.ErrOffset - } - - // Offset (11) 'BlobKzgCommitments' - if o11 = ssz.ReadOffset(buf[388:392]); o11 > size || o10 > o11 { - return ssz.ErrOffset - } - - // Offset (12) 'ExecutionRequests' - if o12 = ssz.ReadOffset(buf[392:396]); o12 > size || o11 > o12 { - return ssz.ErrOffset - } - - // Field (3) 'ProposerSlashings' - { - buf = tail[o3:o4] - num, err := ssz.DivideInt2(len(buf), 416, 16) - if err != nil { - return err - } - b.ProposerSlashings = make([]*generic.ProposerSlashing, num) - for ii := 0; ii < num; ii++ { - if b.ProposerSlashings[ii] == nil { - b.ProposerSlashings[ii] = new(generic.ProposerSlashing) - } - if err = b.ProposerSlashings[ii].UnmarshalSSZ(buf[ii*416 : (ii+1)*416]); err != nil { - return err - } - } - } - - // Field (4) 'AttesterSlashings' - { - buf = tail[o4:o5] - num, err := ssz.DecodeDynamicLength(buf, 1) - if err != nil { - return err - } - b.AttesterSlashings = make([]*AttesterSlashing, num) - err = ssz.UnmarshalDynamic(buf, num, func(indx int, buf []byte) (err error) { - if b.AttesterSlashings[indx] == nil { - b.AttesterSlashings[indx] = new(AttesterSlashing) - } - if err = b.AttesterSlashings[indx].UnmarshalSSZ(buf); err != nil { - return err - } - return nil - }) - if err != nil { - return err - } - } - - // Field (5) 'Attestations' - { - buf = tail[o5:o6] - num, err := ssz.DecodeDynamicLength(buf, 8) - if err != nil { - return err - } - b.Attestations = make([]*Attestation, num) - err = ssz.UnmarshalDynamic(buf, num, func(indx int, buf []byte) (err error) { - if b.Attestations[indx] == nil { - b.Attestations[indx] = new(Attestation) - } - if err = b.Attestations[indx].UnmarshalSSZ(buf); err != nil { - return err - } - return nil - }) - if err != nil { - return err - } - } - - // Field (6) 'Deposits' - { - buf = tail[o6:o7] - num, err := ssz.DivideInt2(len(buf), 1240, 16) - if err != nil { - return err - } - b.Deposits = make([]*generic.Deposit, num) - for ii := 0; ii < num; ii++ { - if b.Deposits[ii] == nil { - b.Deposits[ii] = new(generic.Deposit) - } - if err = b.Deposits[ii].UnmarshalSSZ(buf[ii*1240 : (ii+1)*1240]); err != nil { - return err - } - } - } - - // Field (7) 'VoluntaryExits' - { - buf = tail[o7:o9] - num, err := ssz.DivideInt2(len(buf), 112, 16) - if err != nil { - return err - } - b.VoluntaryExits = make([]*generic.SignedVoluntaryExit, num) - for ii := 0; ii < num; ii++ { - if b.VoluntaryExits[ii] == nil { - b.VoluntaryExits[ii] = new(generic.SignedVoluntaryExit) - } - if err = b.VoluntaryExits[ii].UnmarshalSSZ(buf[ii*112 : (ii+1)*112]); err != nil { - return err - } - } - } - - // Field (9) 'ExecutionPayload' - { - buf = tail[o9:o10] - if b.ExecutionPayload == nil { - b.ExecutionPayload = new(generic.ExecutionPayload) - } - if err = b.ExecutionPayload.UnmarshalSSZ(buf); err != nil { - return err - } - } - - // Field (10) 'BlsToExecutionChanges' - { - buf = tail[o10:o11] - num, err := ssz.DivideInt2(len(buf), 172, 16) - if err != nil { - return err - } - b.BlsToExecutionChanges = make([]*generic.SignedBLSToExecutionChange, num) - for ii := 0; ii < num; ii++ { - if b.BlsToExecutionChanges[ii] == nil { - b.BlsToExecutionChanges[ii] = new(generic.SignedBLSToExecutionChange) - } - if err = b.BlsToExecutionChanges[ii].UnmarshalSSZ(buf[ii*172 : (ii+1)*172]); err != nil { - return err - } - } - } - - // Field (11) 'BlobKzgCommitments' - { - buf = tail[o11:o12] - num, err := ssz.DivideInt2(len(buf), 48, 4096) - if err != nil { - return err - } - b.BlobKzgCommitments = make([][48]byte, num) - for ii := 0; ii < num; ii++ { - copy(b.BlobKzgCommitments[ii][:], buf[ii*48:(ii+1)*48]) - } - } - - // Field (12) 'ExecutionRequests' - { - buf = tail[o12:] - if b.ExecutionRequests == nil { - b.ExecutionRequests = new(ExecutionRequests) - } - if err = b.ExecutionRequests.UnmarshalSSZ(buf); err != nil { - return err - } - } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the BeaconBlockBody object -func (b *BeaconBlockBody) SizeSSZ() (size int) { - size = 396 - - // Field (3) 'ProposerSlashings' - size += len(b.ProposerSlashings) * 416 - - // Field (4) 'AttesterSlashings' - for ii := 0; ii < len(b.AttesterSlashings); ii++ { - size += 4 - size += b.AttesterSlashings[ii].SizeSSZ() - } - - // Field (5) 'Attestations' - for ii := 0; ii < len(b.Attestations); ii++ { - size += 4 - size += b.Attestations[ii].SizeSSZ() - } - - // Field (6) 'Deposits' - size += len(b.Deposits) * 1240 - - // Field (7) 'VoluntaryExits' - size += len(b.VoluntaryExits) * 112 - - // Field (9) 'ExecutionPayload' - if b.ExecutionPayload == nil { - b.ExecutionPayload = new(generic.ExecutionPayload) - } - size += b.ExecutionPayload.SizeSSZ() - - // Field (10) 'BlsToExecutionChanges' - size += len(b.BlsToExecutionChanges) * 172 - - // Field (11) 'BlobKzgCommitments' - size += len(b.BlobKzgCommitments) * 48 - - // Field (12) 'ExecutionRequests' - if b.ExecutionRequests == nil { - b.ExecutionRequests = new(ExecutionRequests) - } - size += b.ExecutionRequests.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the BeaconBlockBody object -func (b *BeaconBlockBody) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) -} - -// HashTreeRootWith ssz hashes the BeaconBlockBody object with a hasher -func (b *BeaconBlockBody) HashTreeRootWith(hh ssz.HashWalker) (err error) { - indx := hh.Index() - - // Field (0) 'RandaoReveal' - if size := len(b.RandaoReveal); size != 96 { - err = ssz.ErrBytesLengthFn("BeaconBlockBody.RandaoReveal", size, 96) - return - } - hh.PutBytes(b.RandaoReveal) - - // Field (1) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(generic.Eth1Data) - } - if err = b.Eth1Data.HashTreeRootWith(hh); err != nil { - return - } - - // Field (2) 'Graffiti' - hh.PutBytes(b.Graffiti[:]) - - // Field (3) 'ProposerSlashings' - { - subIndx := hh.Index() - num := uint64(len(b.ProposerSlashings)) - if num > 16 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range b.ProposerSlashings { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } - } - hh.MerkleizeWithMixin(subIndx, num, 16) - } - - // Field (4) 'AttesterSlashings' - { - subIndx := hh.Index() - num := uint64(len(b.AttesterSlashings)) - if num > 1 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range b.AttesterSlashings { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } - } - hh.MerkleizeWithMixin(subIndx, num, 1) - } - - // Field (5) 'Attestations' - { - subIndx := hh.Index() - num := uint64(len(b.Attestations)) - if num > 8 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range b.Attestations { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } - } - hh.MerkleizeWithMixin(subIndx, num, 8) - } - - // Field (6) 'Deposits' - { - subIndx := hh.Index() - num := uint64(len(b.Deposits)) - if num > 16 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range b.Deposits { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } - } - hh.MerkleizeWithMixin(subIndx, num, 16) - } - - // Field (7) 'VoluntaryExits' - { - subIndx := hh.Index() - num := uint64(len(b.VoluntaryExits)) - if num > 16 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range b.VoluntaryExits { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } - } - hh.MerkleizeWithMixin(subIndx, num, 16) - } - - // Field (8) 'SyncAggregate' - if b.SyncAggregate == nil { - b.SyncAggregate = new(generic.SyncAggregate) - } - if err = b.SyncAggregate.HashTreeRootWith(hh); err != nil { - return - } - - // Field (9) 'ExecutionPayload' - if err = b.ExecutionPayload.HashTreeRootWith(hh); err != nil { - return - } - - // Field (10) 'BlsToExecutionChanges' - { - subIndx := hh.Index() - num := uint64(len(b.BlsToExecutionChanges)) - if num > 16 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range b.BlsToExecutionChanges { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } - } - hh.MerkleizeWithMixin(subIndx, num, 16) - } - - // Field (11) 'BlobKzgCommitments' - { - if size := len(b.BlobKzgCommitments); size > 4096 { - err = ssz.ErrListTooBigFn("BeaconBlockBody.BlobKzgCommitments", size, 4096) - return - } - subIndx := hh.Index() - for _, i := range b.BlobKzgCommitments { - hh.PutBytes(i[:]) - } - numItems := uint64(len(b.BlobKzgCommitments)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) - } - - // Field (12) 'ExecutionRequests' - if err = b.ExecutionRequests.HashTreeRootWith(hh); err != nil { - return - } - - hh.Merkleize(indx) - return -} - -// GetTree ssz hashes the BeaconBlockBody object -func (b *BeaconBlockBody) GetTree() (*ssz.Node, error) { - return ssz.ProofTree(b) -} - -// MarshalSSZ ssz marshals the Attestation object -func (a *Attestation) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(a) -} - -// MarshalSSZTo ssz marshals the Attestation object to a target array -func (a *Attestation) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(236) - - // Offset (0) 'AggregationBits' - dst = ssz.WriteOffset(dst, offset) - - // Field (1) 'Data' - if a.Data == nil { - a.Data = new(generic.AttestationData) - } - if dst, err = a.Data.MarshalSSZTo(dst); err != nil { - return - } - - // Field (2) 'Signature' - dst = append(dst, a.Signature[:]...) - - // Field (3) 'CommitteeBits' - if size := len(a.CommitteeBits); size != 8 { - err = ssz.ErrBytesLengthFn("Attestation.CommitteeBits", size, 8) - return - } - dst = append(dst, a.CommitteeBits...) - - // Field (0) 'AggregationBits' - if size := len(a.AggregationBits); size > 131072 { - err = ssz.ErrBytesLengthFn("Attestation.AggregationBits", size, 131072) - return - } - dst = append(dst, a.AggregationBits...) - - return -} - -// UnmarshalSSZ ssz unmarshals the Attestation object -func (a *Attestation) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 236 { - return ssz.ErrSize - } - - tail := buf - var o0 uint64 - - // Offset (0) 'AggregationBits' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } - - if o0 != 236 { - return ssz.ErrInvalidVariableOffset - } - - // Field (1) 'Data' - if a.Data == nil { - a.Data = new(generic.AttestationData) - } - if err = a.Data.UnmarshalSSZ(buf[4:132]); err != nil { - return err - } - - // Field (2) 'Signature' - copy(a.Signature[:], buf[132:228]) - - // Field (3) 'CommitteeBits' - if cap(a.CommitteeBits) == 0 { - a.CommitteeBits = make([]byte, 0, len(buf[228:236])) - } - a.CommitteeBits = append(a.CommitteeBits, buf[228:236]...) - - // Field (0) 'AggregationBits' - { - buf = tail[o0:] - if err = ssz.ValidateBitlist(buf, 131072); err != nil { - return err - } - if cap(a.AggregationBits) == 0 { - a.AggregationBits = make([]byte, 0, len(buf)) - } - a.AggregationBits = append(a.AggregationBits, buf...) - } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the Attestation object -func (a *Attestation) SizeSSZ() (size int) { - size = 236 - - // Field (0) 'AggregationBits' - size += len(a.AggregationBits) - - return -} - -// HashTreeRoot ssz hashes the Attestation object -func (a *Attestation) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(a) -} - -// HashTreeRootWith ssz hashes the Attestation object with a hasher -func (a *Attestation) HashTreeRootWith(hh ssz.HashWalker) (err error) { - indx := hh.Index() - - // Field (0) 'AggregationBits' - if len(a.AggregationBits) == 0 { - err = ssz.ErrEmptyBitlist - return - } - hh.PutBitlist(a.AggregationBits, 131072) - - // Field (1) 'Data' - if a.Data == nil { - a.Data = new(generic.AttestationData) - } - if err = a.Data.HashTreeRootWith(hh); err != nil { - return - } - - // Field (2) 'Signature' - hh.PutBytes(a.Signature[:]) - - // Field (3) 'CommitteeBits' - if size := len(a.CommitteeBits); size != 8 { - err = ssz.ErrBytesLengthFn("Attestation.CommitteeBits", size, 8) - return - } - hh.PutBytes(a.CommitteeBits) - - hh.Merkleize(indx) - return -} - -// GetTree ssz hashes the Attestation object -func (a *Attestation) GetTree() (*ssz.Node, error) { - return ssz.ProofTree(a) -} - -// MarshalSSZ ssz marshals the ExecutionRequests object -func (e *ExecutionRequests) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(e) -} - -// MarshalSSZTo ssz marshals the ExecutionRequests object to a target array -func (e *ExecutionRequests) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(12) - - // Offset (0) 'Deposits' - dst = ssz.WriteOffset(dst, offset) - offset += len(e.Deposits) * 192 - - // Offset (1) 'Withdrawals' - dst = ssz.WriteOffset(dst, offset) - offset += len(e.Withdrawals) * 76 - - // Offset (2) 'Consolidations' - dst = ssz.WriteOffset(dst, offset) - - // Field (0) 'Deposits' - if size := len(e.Deposits); size > 8192 { - err = ssz.ErrListTooBigFn("ExecutionRequests.Deposits", size, 8192) - return - } - for ii := 0; ii < len(e.Deposits); ii++ { - if dst, err = e.Deposits[ii].MarshalSSZTo(dst); err != nil { - return - } - } - - // Field (1) 'Withdrawals' - if size := len(e.Withdrawals); size > 16 { - err = ssz.ErrListTooBigFn("ExecutionRequests.Withdrawals", size, 16) - return - } - for ii := 0; ii < len(e.Withdrawals); ii++ { - if dst, err = e.Withdrawals[ii].MarshalSSZTo(dst); err != nil { - return - } - } - - // Field (2) 'Consolidations' - if size := len(e.Consolidations); size > 2 { - err = ssz.ErrListTooBigFn("ExecutionRequests.Consolidations", size, 2) - return - } - for ii := 0; ii < len(e.Consolidations); ii++ { - if dst, err = e.Consolidations[ii].MarshalSSZTo(dst); err != nil { - return - } - } - - return -} - -// UnmarshalSSZ ssz unmarshals the ExecutionRequests object -func (e *ExecutionRequests) 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) 'Deposits' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } - - if o0 != 12 { - return ssz.ErrInvalidVariableOffset - } - - // Offset (1) 'Withdrawals' - if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 { - return ssz.ErrOffset - } - - // Offset (2) 'Consolidations' - if o2 = ssz.ReadOffset(buf[8:12]); o2 > size || o1 > o2 { - return ssz.ErrOffset - } - - // Field (0) 'Deposits' - { - buf = tail[o0:o1] - num, err := ssz.DivideInt2(len(buf), 192, 8192) - if err != nil { - return err - } - e.Deposits = make([]*DepositRequest, num) - for ii := 0; ii < num; ii++ { - if e.Deposits[ii] == nil { - e.Deposits[ii] = new(DepositRequest) - } - if err = e.Deposits[ii].UnmarshalSSZ(buf[ii*192 : (ii+1)*192]); err != nil { - return err - } - } - } - - // Field (1) 'Withdrawals' - { - buf = tail[o1:o2] - num, err := ssz.DivideInt2(len(buf), 76, 16) - if err != nil { - return err - } - e.Withdrawals = make([]*WithdrawalRequest, num) - for ii := 0; ii < num; ii++ { - if e.Withdrawals[ii] == nil { - e.Withdrawals[ii] = new(WithdrawalRequest) - } - if err = e.Withdrawals[ii].UnmarshalSSZ(buf[ii*76 : (ii+1)*76]); err != nil { - return err - } - } - } - - // Field (2) 'Consolidations' - { - buf = tail[o2:] - num, err := ssz.DivideInt2(len(buf), 116, 2) - if err != nil { - return err - } - e.Consolidations = make([]*ConsolidationRequest, num) - for ii := 0; ii < num; ii++ { - if e.Consolidations[ii] == nil { - e.Consolidations[ii] = new(ConsolidationRequest) - } - if err = e.Consolidations[ii].UnmarshalSSZ(buf[ii*116 : (ii+1)*116]); err != nil { - return err - } - } - } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the ExecutionRequests object -func (e *ExecutionRequests) SizeSSZ() (size int) { - size = 12 - - // Field (0) 'Deposits' - size += len(e.Deposits) * 192 - - // Field (1) 'Withdrawals' - size += len(e.Withdrawals) * 76 - - // Field (2) 'Consolidations' - size += len(e.Consolidations) * 116 - - return -} - -// HashTreeRoot ssz hashes the ExecutionRequests object -func (e *ExecutionRequests) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(e) -} - -// HashTreeRootWith ssz hashes the ExecutionRequests object with a hasher -func (e *ExecutionRequests) HashTreeRootWith(hh ssz.HashWalker) (err error) { - indx := hh.Index() - - // Field (0) 'Deposits' - { - subIndx := hh.Index() - num := uint64(len(e.Deposits)) - if num > 8192 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range e.Deposits { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } - } - hh.MerkleizeWithMixin(subIndx, num, 8192) - } - - // Field (1) 'Withdrawals' - { - subIndx := hh.Index() - num := uint64(len(e.Withdrawals)) - if num > 16 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range e.Withdrawals { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } - } - hh.MerkleizeWithMixin(subIndx, num, 16) - } - - // Field (2) 'Consolidations' - { - subIndx := hh.Index() - num := uint64(len(e.Consolidations)) - if num > 2 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range e.Consolidations { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } - } - hh.MerkleizeWithMixin(subIndx, num, 2) - } - - hh.Merkleize(indx) - return -} - -// GetTree ssz hashes the ExecutionRequests object -func (e *ExecutionRequests) GetTree() (*ssz.Node, error) { - return ssz.ProofTree(e) -} - -// MarshalSSZ ssz marshals the DepositRequest object -func (d *DepositRequest) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(d) -} - -// MarshalSSZTo ssz marshals the DepositRequest object to a target array -func (d *DepositRequest) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - - // Field (0) 'Pubkey' - if size := len(d.Pubkey); size != 48 { - err = ssz.ErrBytesLengthFn("DepositRequest.Pubkey", size, 48) - return - } - dst = append(dst, d.Pubkey...) - - // Field (1) 'WithdrawalCredentials' - if size := len(d.WithdrawalCredentials); size != 32 { - err = ssz.ErrBytesLengthFn("DepositRequest.WithdrawalCredentials", size, 32) - return - } - dst = append(dst, d.WithdrawalCredentials...) - - // Field (2) 'Amount' - dst = ssz.MarshalUint64(dst, d.Amount) - - // Field (3) 'Signature' - if size := len(d.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("DepositRequest.Signature", size, 96) - return - } - dst = append(dst, d.Signature...) - - // Field (4) 'Index' - dst = ssz.MarshalUint64(dst, d.Index) - - return -} - -// UnmarshalSSZ ssz unmarshals the DepositRequest object -func (d *DepositRequest) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size != 192 { - return ssz.ErrSize - } - - // Field (0) 'Pubkey' - if cap(d.Pubkey) == 0 { - d.Pubkey = make([]byte, 0, len(buf[0:48])) - } - d.Pubkey = append(d.Pubkey, buf[0:48]...) - - // Field (1) 'WithdrawalCredentials' - if cap(d.WithdrawalCredentials) == 0 { - d.WithdrawalCredentials = make([]byte, 0, len(buf[48:80])) - } - d.WithdrawalCredentials = append(d.WithdrawalCredentials, buf[48:80]...) - - // Field (2) 'Amount' - d.Amount = ssz.UnmarshallUint64(buf[80:88]) - - // Field (3) 'Signature' - if cap(d.Signature) == 0 { - d.Signature = make([]byte, 0, len(buf[88:184])) - } - d.Signature = append(d.Signature, buf[88:184]...) - - // Field (4) 'Index' - d.Index = ssz.UnmarshallUint64(buf[184:192]) - - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the DepositRequest object -func (d *DepositRequest) SizeSSZ() (size int) { - size = 192 - return -} - -// HashTreeRoot ssz hashes the DepositRequest object -func (d *DepositRequest) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(d) -} - -// HashTreeRootWith ssz hashes the DepositRequest object with a hasher -func (d *DepositRequest) HashTreeRootWith(hh ssz.HashWalker) (err error) { - indx := hh.Index() - - // Field (0) 'Pubkey' - if size := len(d.Pubkey); size != 48 { - err = ssz.ErrBytesLengthFn("DepositRequest.Pubkey", size, 48) - return - } - hh.PutBytes(d.Pubkey) - - // Field (1) 'WithdrawalCredentials' - if size := len(d.WithdrawalCredentials); size != 32 { - err = ssz.ErrBytesLengthFn("DepositRequest.WithdrawalCredentials", size, 32) - return - } - hh.PutBytes(d.WithdrawalCredentials) - - // Field (2) 'Amount' - hh.PutUint64(d.Amount) - - // Field (3) 'Signature' - if size := len(d.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("DepositRequest.Signature", size, 96) - return - } - hh.PutBytes(d.Signature) - - // Field (4) 'Index' - hh.PutUint64(d.Index) - - hh.Merkleize(indx) - return -} - -// GetTree ssz hashes the DepositRequest object -func (d *DepositRequest) GetTree() (*ssz.Node, error) { - return ssz.ProofTree(d) -} - -// MarshalSSZ ssz marshals the WithdrawalRequest object -func (w *WithdrawalRequest) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(w) -} - -// MarshalSSZTo ssz marshals the WithdrawalRequest object to a target array -func (w *WithdrawalRequest) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - - // Field (0) 'SourceAddress' - if size := len(w.SourceAddress); size != 20 { - err = ssz.ErrBytesLengthFn("WithdrawalRequest.SourceAddress", size, 20) - return - } - dst = append(dst, w.SourceAddress...) - - // Field (1) 'ValidatorPubkey' - if size := len(w.ValidatorPubkey); size != 48 { - err = ssz.ErrBytesLengthFn("WithdrawalRequest.ValidatorPubkey", size, 48) - return - } - dst = append(dst, w.ValidatorPubkey...) - - // Field (2) 'Amount' - dst = ssz.MarshalUint64(dst, w.Amount) - - return -} - -// UnmarshalSSZ ssz unmarshals the WithdrawalRequest object -func (w *WithdrawalRequest) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size != 76 { - return ssz.ErrSize - } - - // Field (0) 'SourceAddress' - if cap(w.SourceAddress) == 0 { - w.SourceAddress = make([]byte, 0, len(buf[0:20])) - } - w.SourceAddress = append(w.SourceAddress, buf[0:20]...) - - // Field (1) 'ValidatorPubkey' - if cap(w.ValidatorPubkey) == 0 { - w.ValidatorPubkey = make([]byte, 0, len(buf[20:68])) - } - w.ValidatorPubkey = append(w.ValidatorPubkey, buf[20:68]...) - - // Field (2) 'Amount' - w.Amount = ssz.UnmarshallUint64(buf[68:76]) - - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the WithdrawalRequest object -func (w *WithdrawalRequest) SizeSSZ() (size int) { - size = 76 - return -} - -// HashTreeRoot ssz hashes the WithdrawalRequest object -func (w *WithdrawalRequest) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(w) -} - -// HashTreeRootWith ssz hashes the WithdrawalRequest object with a hasher -func (w *WithdrawalRequest) HashTreeRootWith(hh ssz.HashWalker) (err error) { - indx := hh.Index() - - // Field (0) 'SourceAddress' - if size := len(w.SourceAddress); size != 20 { - err = ssz.ErrBytesLengthFn("WithdrawalRequest.SourceAddress", size, 20) - return - } - hh.PutBytes(w.SourceAddress) - - // Field (1) 'ValidatorPubkey' - if size := len(w.ValidatorPubkey); size != 48 { - err = ssz.ErrBytesLengthFn("WithdrawalRequest.ValidatorPubkey", size, 48) - return - } - hh.PutBytes(w.ValidatorPubkey) - - // Field (2) 'Amount' - hh.PutUint64(w.Amount) - - hh.Merkleize(indx) - return -} - -// GetTree ssz hashes the WithdrawalRequest object -func (w *WithdrawalRequest) GetTree() (*ssz.Node, error) { - return ssz.ProofTree(w) -} - -// MarshalSSZ ssz marshals the ConsolidationRequest object -func (c *ConsolidationRequest) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(c) -} - -// MarshalSSZTo ssz marshals the ConsolidationRequest object to a target array -func (c *ConsolidationRequest) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - - // Field (0) 'SourceAddress' - if size := len(c.SourceAddress); size != 20 { - err = ssz.ErrBytesLengthFn("ConsolidationRequest.SourceAddress", size, 20) - return - } - dst = append(dst, c.SourceAddress...) - - // Field (1) 'SourcePubkey' - if size := len(c.SourcePubkey); size != 48 { - err = ssz.ErrBytesLengthFn("ConsolidationRequest.SourcePubkey", size, 48) - return - } - dst = append(dst, c.SourcePubkey...) - - // Field (2) 'TargetPubkey' - if size := len(c.TargetPubkey); size != 48 { - err = ssz.ErrBytesLengthFn("ConsolidationRequest.TargetPubkey", size, 48) - return - } - dst = append(dst, c.TargetPubkey...) - - return -} - -// UnmarshalSSZ ssz unmarshals the ConsolidationRequest object -func (c *ConsolidationRequest) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size != 116 { - return ssz.ErrSize - } - - // Field (0) 'SourceAddress' - if cap(c.SourceAddress) == 0 { - c.SourceAddress = make([]byte, 0, len(buf[0:20])) - } - c.SourceAddress = append(c.SourceAddress, buf[0:20]...) - - // Field (1) 'SourcePubkey' - if cap(c.SourcePubkey) == 0 { - c.SourcePubkey = make([]byte, 0, len(buf[20:68])) - } - c.SourcePubkey = append(c.SourcePubkey, buf[20:68]...) - - // Field (2) 'TargetPubkey' - if cap(c.TargetPubkey) == 0 { - c.TargetPubkey = make([]byte, 0, len(buf[68:116])) - } - c.TargetPubkey = append(c.TargetPubkey, buf[68:116]...) - - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the ConsolidationRequest object -func (c *ConsolidationRequest) SizeSSZ() (size int) { - size = 116 - return -} - -// HashTreeRoot ssz hashes the ConsolidationRequest object -func (c *ConsolidationRequest) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(c) -} - -// HashTreeRootWith ssz hashes the ConsolidationRequest object with a hasher -func (c *ConsolidationRequest) HashTreeRootWith(hh ssz.HashWalker) (err error) { - indx := hh.Index() - - // Field (0) 'SourceAddress' - if size := len(c.SourceAddress); size != 20 { - err = ssz.ErrBytesLengthFn("ConsolidationRequest.SourceAddress", size, 20) - return - } - hh.PutBytes(c.SourceAddress) - - // Field (1) 'SourcePubkey' - if size := len(c.SourcePubkey); size != 48 { - err = ssz.ErrBytesLengthFn("ConsolidationRequest.SourcePubkey", size, 48) - return - } - hh.PutBytes(c.SourcePubkey) - - // Field (2) 'TargetPubkey' - if size := len(c.TargetPubkey); size != 48 { - err = ssz.ErrBytesLengthFn("ConsolidationRequest.TargetPubkey", size, 48) - return - } - hh.PutBytes(c.TargetPubkey) - - hh.Merkleize(indx) - return -} - -// GetTree ssz hashes the ConsolidationRequest object -func (c *ConsolidationRequest) GetTree() (*ssz.Node, error) { - return ssz.ProofTree(c) -} - -// MarshalSSZ ssz marshals the AttesterSlashing object -func (a *AttesterSlashing) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(a) -} - -// MarshalSSZTo ssz marshals the AttesterSlashing object to a target array -func (a *AttesterSlashing) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(8) - - // Offset (0) 'Attestation1' - dst = ssz.WriteOffset(dst, offset) - if a.Attestation1 == nil { - a.Attestation1 = new(IndexedAttestation) - } - offset += a.Attestation1.SizeSSZ() - - // Offset (1) 'Attestation2' - dst = ssz.WriteOffset(dst, offset) - - // Field (0) 'Attestation1' - if dst, err = a.Attestation1.MarshalSSZTo(dst); err != nil { - return - } - - // Field (1) 'Attestation2' - if dst, err = a.Attestation2.MarshalSSZTo(dst); err != nil { - return - } - - return -} - -// UnmarshalSSZ ssz unmarshals the AttesterSlashing object -func (a *AttesterSlashing) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 8 { - return ssz.ErrSize - } - - tail := buf - var o0, o1 uint64 - - // Offset (0) 'Attestation1' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } - - if o0 != 8 { - return ssz.ErrInvalidVariableOffset - } - - // Offset (1) 'Attestation2' - if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 { - return ssz.ErrOffset - } - - // Field (0) 'Attestation1' - { - buf = tail[o0:o1] - if a.Attestation1 == nil { - a.Attestation1 = new(IndexedAttestation) - } - if err = a.Attestation1.UnmarshalSSZ(buf); err != nil { - return err - } - } - - // Field (1) 'Attestation2' - { - buf = tail[o1:] - if a.Attestation2 == nil { - a.Attestation2 = new(IndexedAttestation) - } - if err = a.Attestation2.UnmarshalSSZ(buf); err != nil { - return err - } - } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the AttesterSlashing object -func (a *AttesterSlashing) SizeSSZ() (size int) { - size = 8 - - // Field (0) 'Attestation1' - if a.Attestation1 == nil { - a.Attestation1 = new(IndexedAttestation) - } - size += a.Attestation1.SizeSSZ() - - // Field (1) 'Attestation2' - if a.Attestation2 == nil { - a.Attestation2 = new(IndexedAttestation) - } - size += a.Attestation2.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the AttesterSlashing object -func (a *AttesterSlashing) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(a) -} - -// HashTreeRootWith ssz hashes the AttesterSlashing object with a hasher -func (a *AttesterSlashing) HashTreeRootWith(hh ssz.HashWalker) (err error) { - indx := hh.Index() - - // Field (0) 'Attestation1' - if err = a.Attestation1.HashTreeRootWith(hh); err != nil { - return - } - - // Field (1) 'Attestation2' - if err = a.Attestation2.HashTreeRootWith(hh); err != nil { - return - } - - hh.Merkleize(indx) - return -} - -// GetTree ssz hashes the AttesterSlashing object -func (a *AttesterSlashing) GetTree() (*ssz.Node, error) { - return ssz.ProofTree(a) -} - -// MarshalSSZ ssz marshals the IndexedAttestation object -func (i *IndexedAttestation) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(i) -} - -// MarshalSSZTo ssz marshals the IndexedAttestation object to a target array -func (i *IndexedAttestation) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(228) - - // Offset (0) 'AttestingIndices' - dst = ssz.WriteOffset(dst, offset) - - // Field (1) 'Data' - if i.Data == nil { - i.Data = new(generic.AttestationData) - } - if dst, err = i.Data.MarshalSSZTo(dst); err != nil { - return - } - - // Field (2) 'Signature' - if size := len(i.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("IndexedAttestation.Signature", size, 96) - return - } - dst = append(dst, i.Signature...) - - // Field (0) 'AttestingIndices' - if size := len(i.AttestingIndices); size > 131072 { - err = ssz.ErrListTooBigFn("IndexedAttestation.AttestingIndices", size, 131072) - return - } - for ii := 0; ii < len(i.AttestingIndices); ii++ { - dst = ssz.MarshalUint64(dst, i.AttestingIndices[ii]) - } - - return -} - -// UnmarshalSSZ ssz unmarshals the IndexedAttestation object -func (i *IndexedAttestation) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 228 { - return ssz.ErrSize - } - - tail := buf - var o0 uint64 - - // Offset (0) 'AttestingIndices' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } - - if o0 != 228 { - return ssz.ErrInvalidVariableOffset - } - - // Field (1) 'Data' - if i.Data == nil { - i.Data = new(generic.AttestationData) - } - if err = i.Data.UnmarshalSSZ(buf[4:132]); err != nil { - return err - } - - // Field (2) 'Signature' - if cap(i.Signature) == 0 { - i.Signature = make([]byte, 0, len(buf[132:228])) - } - i.Signature = append(i.Signature, buf[132:228]...) - - // Field (0) 'AttestingIndices' - { - buf = tail[o0:] - num, err := ssz.DivideInt2(len(buf), 8, 131072) - if err != nil { - return err - } - i.AttestingIndices = ssz.ExtendUint64(i.AttestingIndices, num) - for ii := 0; ii < num; ii++ { - i.AttestingIndices[ii] = ssz.UnmarshallUint64(buf[ii*8 : (ii+1)*8]) - } - } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the IndexedAttestation object -func (i *IndexedAttestation) SizeSSZ() (size int) { - size = 228 - - // Field (0) 'AttestingIndices' - size += len(i.AttestingIndices) * 8 - - return -} - -// HashTreeRoot ssz hashes the IndexedAttestation object -func (i *IndexedAttestation) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(i) -} - -// HashTreeRootWith ssz hashes the IndexedAttestation object with a hasher -func (i *IndexedAttestation) HashTreeRootWith(hh ssz.HashWalker) (err error) { - indx := hh.Index() - - // Field (0) 'AttestingIndices' - { - if size := len(i.AttestingIndices); size > 131072 { - err = ssz.ErrListTooBigFn("IndexedAttestation.AttestingIndices", size, 131072) - return - } - subIndx := hh.Index() - for _, i := range i.AttestingIndices { - hh.AppendUint64(i) - } - hh.FillUpTo32() - numItems := uint64(len(i.AttestingIndices)) - hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(131072, numItems, 8)) - } - - // Field (1) 'Data' - if i.Data == nil { - i.Data = new(generic.AttestationData) - } - if err = i.Data.HashTreeRootWith(hh); err != nil { - return - } - - // Field (2) 'Signature' - if size := len(i.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("IndexedAttestation.Signature", size, 96) - return - } - hh.PutBytes(i.Signature) - - hh.Merkleize(indx) - return -} - -// GetTree ssz hashes the IndexedAttestation object -func (i *IndexedAttestation) GetTree() (*ssz.Node, error) { - return ssz.ProofTree(i) -} diff --git a/shared/types/eth2/fork/electra/electra_generated.go b/shared/types/eth2/fork/electra/electra_generated.go new file mode 100644 index 000000000..0100b49e4 --- /dev/null +++ b/shared/types/eth2/fork/electra/electra_generated.go @@ -0,0 +1,6531 @@ +// Code generated by dynamic-ssz. DO NOT EDIT. +// Hash: f88fe128b312fed2b95761b0c7ebb6bd1d401a5b841590203816f2f9657d98e6 +// Version: v1.3.2 (https://github.com/pk910/dynamic-ssz) +package electra + +import ( + "encoding/binary" + "math/bits" + + "github.com/pk910/dynamic-ssz/hasher" + "github.com/pk910/dynamic-ssz/sszutils" + go_bitfield "github.com/prysmaticlabs/go-bitfield" + "github.com/rocket-pool/smartnode/shared/types/eth2/generic" +) + +var _ = sszutils.ErrListTooBig + +var _ = sszutils.Annotate[BeaconState](`ssz-static:"false"`) +var _ = sszutils.Annotate[SignedBeaconBlock](`ssz-static:"false"`) +var _ = sszutils.Annotate[BeaconBlock](`ssz-static:"false"`) +var _ = sszutils.Annotate[BeaconBlockBody](`ssz-static:"false"`) +var _ = sszutils.Annotate[Attestation](`ssz-static:"false"`) +var _ = sszutils.Annotate[ExecutionRequests](`ssz-static:"false"`) +var _ = sszutils.Annotate[DepositRequest](`ssz-static:"true"`) +var _ = sszutils.Annotate[WithdrawalRequest](`ssz-static:"true"`) +var _ = sszutils.Annotate[ConsolidationRequest](`ssz-static:"true"`) +var _ = sszutils.Annotate[AttesterSlashing](`ssz-static:"false"`) +var _ = sszutils.Annotate[IndexedAttestation](`ssz-static:"false"`) + +// MarshalSSZTo marshals the *BeaconState to SSZ-encoded bytes, appending to the provided buffer. +func (t *BeaconState) MarshalSSZTo(buf []byte) (dst []byte, err error) { + dst = buf + zeroBytes := sszutils.ZeroBytes() + if t == nil { + t = new(BeaconState) + } + dstlen := len(dst) + { // Static Field #0 'GenesisTime' + dst = binary.LittleEndian.AppendUint64(dst, t.GenesisTime) + } + { // Static Field #1 'GenesisValidatorsRoot' + vlen := len(t.GenesisValidatorsRoot) + if vlen > 32 { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 32), "GenesisValidatorsRoot") + } + dst = append(dst, t.GenesisValidatorsRoot[:vlen]...) + if vlen < 32 { + dst = sszutils.AppendZeroPadding(dst, (32-vlen)*1) + } + } + { // Static Field #2 'Slot' + dst = binary.LittleEndian.AppendUint64(dst, t.Slot) + } + { // Static Field #3 'Fork' + t := t.Fork + if t == nil { + t = new(generic.Fork) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "Fork") + } + } + { // Static Field #4 'LatestBlockHeader' + t := t.LatestBlockHeader + if t == nil { + t = new(generic.BeaconBlockHeader) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "LatestBlockHeader") + } + } + { // Static Field #5 'BlockRoots' + t := &t.BlockRoots + dst = sszutils.MarshalFixedBytesSlice(dst, t[:8192]) + } + { // Static Field #6 'StateRoots' + t := &t.StateRoots + dst = sszutils.MarshalFixedBytesSlice(dst, t[:8192]) + } + // Offset Field #7 'HistoricalRoots' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #8 'Eth1Data' + t := t.Eth1Data + if t == nil { + t = new(generic.Eth1Data) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "Eth1Data") + } + } + // Offset Field #9 'Eth1DataVotes' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #10 'Eth1DepositIndex' + dst = binary.LittleEndian.AppendUint64(dst, t.Eth1DepositIndex) + } + // Offset Field #11 'Validators' + // Offset Field #12 'Balances' + dst = append(dst, 0, 0, 0, 0, 0, 0, 0, 0) + { // Static Field #13 'RandaoMixes' + t := t.RandaoMixes + vlen := len(t) + if vlen > 65536 { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 65536), "RandaoMixes") + } + for idx1 := range vlen { + vlen := len(t[idx1]) + if vlen > 32 { + return nil, sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, 32), "RandaoMixes[%d]", idx1) + } + dst = append(dst, t[idx1][:vlen]...) + if vlen < 32 { + dst = sszutils.AppendZeroPadding(dst, (32-vlen)*1) + } + } + if vlen < 65536 { + dst = sszutils.AppendZeroPadding(dst, (65536-vlen)*32) + } + } + { // Static Field #14 'Slashings' + t := t.Slashings + vlen := len(t) + if vlen > 8192 { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 8192), "Slashings") + } + dst = sszutils.MarshalUint64Slice(dst, t[:vlen]) + if vlen < 8192 { + dst = sszutils.AppendZeroPadding(dst, (8192-vlen)*8) + } + } + // Offset Field #15 'PreviousEpochParticipation' + // Offset Field #16 'CurrentEpochParticipation' + dst = append(dst, 0, 0, 0, 0, 0, 0, 0, 0) + { // Static Field #17 'JustificationBits' + dst = append(dst, t.JustificationBits[:1]...) + } + { // Static Field #18 'PreviousJustifiedCheckpoint' + t := t.PreviousJustifiedCheckpoint + if t == nil { + t = new(generic.Checkpoint) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } + } + { // Static Field #19 'CurrentJustifiedCheckpoint' + t := t.CurrentJustifiedCheckpoint + if t == nil { + t = new(generic.Checkpoint) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } + } + { // Static Field #20 'FinalizedCheckpoint' + t := t.FinalizedCheckpoint + if t == nil { + t = new(generic.Checkpoint) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "FinalizedCheckpoint") + } + } + // Offset Field #21 'InactivityScores' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #22 'CurrentSyncCommittee' + t := t.CurrentSyncCommittee + if t == nil { + t = new(generic.SyncCommittee) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "CurrentSyncCommittee") + } + } + { // Static Field #23 'NextSyncCommittee' + t := t.NextSyncCommittee + if t == nil { + t = new(generic.SyncCommittee) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "NextSyncCommittee") + } + } + // Offset Field #24 'LatestExecutionPayloadHeader' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #25 'NextWithdrawalIndex' + dst = binary.LittleEndian.AppendUint64(dst, t.NextWithdrawalIndex) + } + { // Static Field #26 'NextWithdrawalValidatorIndex' + dst = binary.LittleEndian.AppendUint64(dst, t.NextWithdrawalValidatorIndex) + } + // Offset Field #27 'HistoricalSummaries' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #28 'DepositRequestsStartIndex' + dst = binary.LittleEndian.AppendUint64(dst, t.DepositRequestsStartIndex) + } + { // Static Field #29 'DepositBalanceToConsume' + dst = binary.LittleEndian.AppendUint64(dst, t.DepositBalanceToConsume) + } + { // Static Field #30 'ExitBalanceToConsume' + dst = binary.LittleEndian.AppendUint64(dst, t.ExitBalanceToConsume) + } + { // Static Field #31 'EarliestExitEpoch' + dst = binary.LittleEndian.AppendUint64(dst, t.EarliestExitEpoch) + } + { // Static Field #32 'ConsolidationBalanceToConsume' + dst = binary.LittleEndian.AppendUint64(dst, t.ConsolidationBalanceToConsume) + } + { // Static Field #33 'EarliestConsolidationEpoch' + dst = binary.LittleEndian.AppendUint64(dst, t.EarliestConsolidationEpoch) + } + // Offset Field #34 'PendingDeposits' + // Offset Field #35 'PendingPartialWithdrawals' + // Offset Field #36 'PendingConsolidations' + dst = append(dst, zeroBytes[:12]...) + { // Dynamic Field #7 'HistoricalRoots' + binary.LittleEndian.PutUint32(dst[dstlen+524464:], uint32(len(dst)-dstlen)) + t := t.HistoricalRoots + vlen := len(t) + if vlen > 16777216 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16777216), "HistoricalRoots") + } + for idx1 := range vlen { + vlen := len(t[idx1]) + if vlen > 32 { + return nil, sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, 32), "HistoricalRoots[%d]", idx1) + } + dst = append(dst, t[idx1][:vlen]...) + if vlen < 32 { + dst = sszutils.AppendZeroPadding(dst, (32-vlen)*1) + } + } + } + { // Dynamic Field #9 'Eth1DataVotes' + binary.LittleEndian.PutUint32(dst[dstlen+524540:], uint32(len(dst)-dstlen)) + t := t.Eth1DataVotes + vlen := len(t) + if vlen > 2048 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 2048), "Eth1DataVotes") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(generic.Eth1Data) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "Eth1DataVotes[%d]", idx1) + } + } + } + { // Dynamic Field #11 'Validators' + binary.LittleEndian.PutUint32(dst[dstlen+524552:], uint32(len(dst)-dstlen)) + t := t.Validators + vlen := len(t) + if vlen > 1099511627776 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1099511627776), "Validators") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(generic.Validator) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } + } + } + { // Dynamic Field #12 'Balances' + binary.LittleEndian.PutUint32(dst[dstlen+524556:], uint32(len(dst)-dstlen)) + t := t.Balances + vlen := len(t) + if vlen > 1099511627776 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1099511627776), "Balances") + } + dst = sszutils.MarshalUint64Slice(dst, t[:vlen]) + } + { // Dynamic Field #15 'PreviousEpochParticipation' + binary.LittleEndian.PutUint32(dst[dstlen+2687248:], uint32(len(dst)-dstlen)) + vlen := len(t.PreviousEpochParticipation) + if vlen > 1099511627776 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1099511627776), "PreviousEpochParticipation") + } + dst = append(dst, t.PreviousEpochParticipation[:]...) + } + { // Dynamic Field #16 'CurrentEpochParticipation' + binary.LittleEndian.PutUint32(dst[dstlen+2687252:], uint32(len(dst)-dstlen)) + vlen := len(t.CurrentEpochParticipation) + if vlen > 1099511627776 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1099511627776), "CurrentEpochParticipation") + } + dst = append(dst, t.CurrentEpochParticipation[:]...) + } + { // Dynamic Field #21 'InactivityScores' + binary.LittleEndian.PutUint32(dst[dstlen+2687377:], uint32(len(dst)-dstlen)) + t := t.InactivityScores + vlen := len(t) + if vlen > 1099511627776 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1099511627776), "InactivityScores") + } + dst = sszutils.MarshalUint64Slice(dst, t[:vlen]) + } + { // Dynamic Field #24 'LatestExecutionPayloadHeader' + binary.LittleEndian.PutUint32(dst[dstlen+2736629:], uint32(len(dst)-dstlen)) + t := t.LatestExecutionPayloadHeader + if t == nil { + t = new(generic.ExecutionPayloadHeader) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "LatestExecutionPayloadHeader") + } + } + { // Dynamic Field #27 'HistoricalSummaries' + binary.LittleEndian.PutUint32(dst[dstlen+2736649:], uint32(len(dst)-dstlen)) + t := t.HistoricalSummaries + vlen := len(t) + if vlen > 16777216 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16777216), "HistoricalSummaries") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(generic.HistoricalSummary) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "HistoricalSummaries[%d]", idx1) + } + } + } + { // Dynamic Field #34 'PendingDeposits' + binary.LittleEndian.PutUint32(dst[dstlen+2736701:], uint32(len(dst)-dstlen)) + t := t.PendingDeposits + vlen := len(t) + if vlen > 134217728 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 134217728), "PendingDeposits") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(generic.PendingDeposit) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "PendingDeposits[%d]", idx1) + } + } + } + { // Dynamic Field #35 'PendingPartialWithdrawals' + binary.LittleEndian.PutUint32(dst[dstlen+2736705:], uint32(len(dst)-dstlen)) + t := t.PendingPartialWithdrawals + vlen := len(t) + if vlen > 134217728 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 134217728), "PendingPartialWithdrawals") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(generic.PendingPartialWithdrawal) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "PendingPartialWithdrawals[%d]", idx1) + } + } + } + { // Dynamic Field #36 'PendingConsolidations' + binary.LittleEndian.PutUint32(dst[dstlen+2736709:], uint32(len(dst)-dstlen)) + t := t.PendingConsolidations + vlen := len(t) + if vlen > 262144 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 262144), "PendingConsolidations") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(generic.PendingConsolidation) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "PendingConsolidations[%d]", idx1) + } + } + } + return dst, nil +} + +// MarshalSSZDyn marshals the *BeaconState to SSZ-encoded bytes using dynamic specifications. +func (t *BeaconState) MarshalSSZDyn(_ sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + return t.MarshalSSZTo(buf) +} + +// MarshalSSZEncoder marshals the *BeaconState to the given SSZ encoder using dynamic specifications. +func (t *BeaconState) MarshalSSZEncoder(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + type encoderCtx struct { + ds sszutils.DynamicSpecs + exprs [0]uint64 + sizeFn1 func(ctx *encoderCtx, t [][]byte) (size int) + sizeFn10 func(ctx *encoderCtx, t []*generic.PendingDeposit) (size int) + sizeFn11 func(ctx *encoderCtx, t []*generic.PendingPartialWithdrawal) (size int) + sizeFn12 func(ctx *encoderCtx, t []*generic.PendingConsolidation) (size int) + sizeFn2 func(ctx *encoderCtx, t []*generic.Eth1Data) (size int) + sizeFn3 func(ctx *encoderCtx, t []*generic.Validator) (size int) + sizeFn4 func(ctx *encoderCtx, t []uint64) (size int) + sizeFn5 func(ctx *encoderCtx, t []byte) (size int) + sizeFn6 func(ctx *encoderCtx, t []byte) (size int) + sizeFn7 func(ctx *encoderCtx, t []uint64) (size int) + sizeFn8 func(ctx *encoderCtx, t *generic.ExecutionPayloadHeader) (size int) + sizeFn9 func(ctx *encoderCtx, t []*generic.HistoricalSummary) (size int) + } + ctx := &encoderCtx{ds: ds} + canSeek := enc.Seekable() + // size for [][]byte + ctx.sizeFn1 = func(ctx *encoderCtx, t [][]byte) (size int) { + size += len(t) * 32 + return size + } + // size for []*generic.Eth1Data + ctx.sizeFn2 = func(ctx *encoderCtx, t []*generic.Eth1Data) (size int) { + size += len(t) * 72 + return size + } + // size for []*generic.Validator + ctx.sizeFn3 = func(ctx *encoderCtx, t []*generic.Validator) (size int) { + size += len(t) * 121 + return size + } + // size for []uint64 + ctx.sizeFn4 = func(ctx *encoderCtx, t []uint64) (size int) { + size += len(t) * 8 + return size + } + // size for []byte + ctx.sizeFn5 = func(ctx *encoderCtx, t []byte) (size int) { + size += len(t) + return size + } + // size for []byte + ctx.sizeFn6 = func(ctx *encoderCtx, t []byte) (size int) { + size += len(t) + return size + } + // size for []uint64 + ctx.sizeFn7 = func(ctx *encoderCtx, t []uint64) (size int) { + size += len(t) * 8 + return size + } + // size for *generic.ExecutionPayloadHeader + ctx.sizeFn8 = func(ctx *encoderCtx, t *generic.ExecutionPayloadHeader) (size int) { + size += t.SizeSSZDyn(ds) + return size + } + // size for []*generic.HistoricalSummary + ctx.sizeFn9 = func(ctx *encoderCtx, t []*generic.HistoricalSummary) (size int) { + size += len(t) * 64 + return size + } + // size for []*generic.PendingDeposit + ctx.sizeFn10 = func(ctx *encoderCtx, t []*generic.PendingDeposit) (size int) { + size += len(t) * 192 + return size + } + // size for []*generic.PendingPartialWithdrawal + ctx.sizeFn11 = func(ctx *encoderCtx, t []*generic.PendingPartialWithdrawal) (size int) { + size += len(t) * 24 + return size + } + // size for []*generic.PendingConsolidation + ctx.sizeFn12 = func(ctx *encoderCtx, t []*generic.PendingConsolidation) (size int) { + size += len(t) * 16 + return size + } + if t == nil { + t = new(BeaconState) + } + dstlen := enc.GetPosition() + dynoff := uint32(2736713) + { // Field #0 'GenesisTime' + enc.EncodeUint64(t.GenesisTime) + } + { // Field #1 'GenesisValidatorsRoot' + vlen := len(t.GenesisValidatorsRoot) + if vlen > 32 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 32), "GenesisValidatorsRoot") + } + enc.EncodeBytes(t.GenesisValidatorsRoot[:vlen]) + if vlen < 32 { + enc.EncodeZeroPadding((32 - vlen) * 1) + } + } + { // Field #2 'Slot' + enc.EncodeUint64(t.Slot) + } + { // Field #3 'Fork' + t := t.Fork + if t == nil { + t = new(generic.Fork) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "Fork") + } else { + enc.SetBuffer(buf) + } + } + { // Field #4 'LatestBlockHeader' + t := t.LatestBlockHeader + if t == nil { + t = new(generic.BeaconBlockHeader) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") + } else { + enc.SetBuffer(buf) + } + } + { // Field #5 'BlockRoots' + t := &t.BlockRoots + for idx1 := range 8192 { + enc.EncodeBytes(t[idx1][:32]) + } + } + { // Field #6 'StateRoots' + t := &t.StateRoots + for idx1 := range 8192 { + enc.EncodeBytes(t[idx1][:32]) + } + } + // Offset #7 'HistoricalRoots' + offset7 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn1(ctx, t.HistoricalRoots)) + } + { // Field #8 'Eth1Data' + t := t.Eth1Data + if t == nil { + t = new(generic.Eth1Data) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "Eth1Data") + } else { + enc.SetBuffer(buf) + } + } + // Offset #9 'Eth1DataVotes' + offset9 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn2(ctx, t.Eth1DataVotes)) + } + { // Field #10 'Eth1DepositIndex' + enc.EncodeUint64(t.Eth1DepositIndex) + } + // Offset #11 'Validators' + offset11 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn3(ctx, t.Validators)) + } + // Offset #12 'Balances' + offset12 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn4(ctx, t.Balances)) + } + { // Field #13 'RandaoMixes' + t := t.RandaoMixes + vlen := len(t) + if vlen > 65536 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 65536), "RandaoMixes") + } + for idx1 := range vlen { + vlen := len(t[idx1]) + if vlen > 32 { + return sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, 32), "RandaoMixes[%d]", idx1) + } + enc.EncodeBytes(t[idx1][:vlen]) + if vlen < 32 { + enc.EncodeZeroPadding((32 - vlen) * 1) + } + } + if vlen < 65536 { + enc.EncodeZeroPadding((65536 - vlen) * 32) + } + } + { // Field #14 'Slashings' + t := t.Slashings + vlen := len(t) + if vlen > 8192 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 8192), "Slashings") + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + if vlen < 8192 { + enc.EncodeZeroPadding((8192 - vlen) * 8) + } + } + // Offset #15 'PreviousEpochParticipation' + offset15 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn5(ctx, t.PreviousEpochParticipation)) + } + // Offset #16 'CurrentEpochParticipation' + offset16 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn6(ctx, t.CurrentEpochParticipation)) + } + { // Field #17 'JustificationBits' + enc.EncodeBytes(t.JustificationBits[:1]) + } + { // Field #18 'PreviousJustifiedCheckpoint' + t := t.PreviousJustifiedCheckpoint + if t == nil { + t = new(generic.Checkpoint) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } else { + enc.SetBuffer(buf) + } + } + { // Field #19 'CurrentJustifiedCheckpoint' + t := t.CurrentJustifiedCheckpoint + if t == nil { + t = new(generic.Checkpoint) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } else { + enc.SetBuffer(buf) + } + } + { // Field #20 'FinalizedCheckpoint' + t := t.FinalizedCheckpoint + if t == nil { + t = new(generic.Checkpoint) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") + } else { + enc.SetBuffer(buf) + } + } + // Offset #21 'InactivityScores' + offset21 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn7(ctx, t.InactivityScores)) + } + { // Field #22 'CurrentSyncCommittee' + t := t.CurrentSyncCommittee + if t == nil { + t = new(generic.SyncCommittee) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "CurrentSyncCommittee") + } else { + enc.SetBuffer(buf) + } + } + { // Field #23 'NextSyncCommittee' + t := t.NextSyncCommittee + if t == nil { + t = new(generic.SyncCommittee) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "NextSyncCommittee") + } else { + enc.SetBuffer(buf) + } + } + // Offset #24 'LatestExecutionPayloadHeader' + offset24 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn8(ctx, t.LatestExecutionPayloadHeader)) + } + { // Field #25 'NextWithdrawalIndex' + enc.EncodeUint64(t.NextWithdrawalIndex) + } + { // Field #26 'NextWithdrawalValidatorIndex' + enc.EncodeUint64(t.NextWithdrawalValidatorIndex) + } + // Offset #27 'HistoricalSummaries' + offset27 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn9(ctx, t.HistoricalSummaries)) + } + { // Field #28 'DepositRequestsStartIndex' + enc.EncodeUint64(t.DepositRequestsStartIndex) + } + { // Field #29 'DepositBalanceToConsume' + enc.EncodeUint64(t.DepositBalanceToConsume) + } + { // Field #30 'ExitBalanceToConsume' + enc.EncodeUint64(t.ExitBalanceToConsume) + } + { // Field #31 'EarliestExitEpoch' + enc.EncodeUint64(t.EarliestExitEpoch) + } + { // Field #32 'ConsolidationBalanceToConsume' + enc.EncodeUint64(t.ConsolidationBalanceToConsume) + } + { // Field #33 'EarliestConsolidationEpoch' + enc.EncodeUint64(t.EarliestConsolidationEpoch) + } + // Offset #34 'PendingDeposits' + offset34 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn10(ctx, t.PendingDeposits)) + } + // Offset #35 'PendingPartialWithdrawals' + offset35 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn11(ctx, t.PendingPartialWithdrawals)) + } + // Offset #36 'PendingConsolidations' + offset36 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn12(ctx, t.PendingConsolidations)) + } + { // Dynamic Field #7 'HistoricalRoots' + if canSeek { + enc.EncodeOffsetAt(offset7, uint32(enc.GetPosition()-dstlen)) + } + t := t.HistoricalRoots + vlen := len(t) + if vlen > 16777216 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16777216), "HistoricalRoots") + } + for idx1 := range vlen { + vlen := len(t[idx1]) + if vlen > 32 { + return sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, 32), "HistoricalRoots[%d]", idx1) + } + enc.EncodeBytes(t[idx1][:vlen]) + if vlen < 32 { + enc.EncodeZeroPadding((32 - vlen) * 1) + } + } + } + { // Dynamic Field #9 'Eth1DataVotes' + if canSeek { + enc.EncodeOffsetAt(offset9, uint32(enc.GetPosition()-dstlen)) + } + t := t.Eth1DataVotes + vlen := len(t) + if vlen > 2048 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 2048), "Eth1DataVotes") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(generic.Eth1Data) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "Eth1DataVotes[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #11 'Validators' + if canSeek { + enc.EncodeOffsetAt(offset11, uint32(enc.GetPosition()-dstlen)) + } + t := t.Validators + vlen := len(t) + if vlen > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1099511627776), "Validators") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(generic.Validator) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #12 'Balances' + if canSeek { + enc.EncodeOffsetAt(offset12, uint32(enc.GetPosition()-dstlen)) + } + t := t.Balances + vlen := len(t) + if vlen > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1099511627776), "Balances") + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + } + { // Dynamic Field #15 'PreviousEpochParticipation' + if canSeek { + enc.EncodeOffsetAt(offset15, uint32(enc.GetPosition()-dstlen)) + } + vlen := len(t.PreviousEpochParticipation) + if vlen > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1099511627776), "PreviousEpochParticipation") + } + enc.EncodeBytes(t.PreviousEpochParticipation[:]) + } + { // Dynamic Field #16 'CurrentEpochParticipation' + if canSeek { + enc.EncodeOffsetAt(offset16, uint32(enc.GetPosition()-dstlen)) + } + vlen := len(t.CurrentEpochParticipation) + if vlen > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1099511627776), "CurrentEpochParticipation") + } + enc.EncodeBytes(t.CurrentEpochParticipation[:]) + } + { // Dynamic Field #21 'InactivityScores' + if canSeek { + enc.EncodeOffsetAt(offset21, uint32(enc.GetPosition()-dstlen)) + } + t := t.InactivityScores + vlen := len(t) + if vlen > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1099511627776), "InactivityScores") + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + } + { // Dynamic Field #24 'LatestExecutionPayloadHeader' + if canSeek { + enc.EncodeOffsetAt(offset24, uint32(enc.GetPosition()-dstlen)) + } + t := t.LatestExecutionPayloadHeader + if t == nil { + t = new(generic.ExecutionPayloadHeader) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "LatestExecutionPayloadHeader") + } else { + enc.SetBuffer(buf) + } + } + { // Dynamic Field #27 'HistoricalSummaries' + if canSeek { + enc.EncodeOffsetAt(offset27, uint32(enc.GetPosition()-dstlen)) + } + t := t.HistoricalSummaries + vlen := len(t) + if vlen > 16777216 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16777216), "HistoricalSummaries") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(generic.HistoricalSummary) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "HistoricalSummaries[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #34 'PendingDeposits' + if canSeek { + enc.EncodeOffsetAt(offset34, uint32(enc.GetPosition()-dstlen)) + } + t := t.PendingDeposits + vlen := len(t) + if vlen > 134217728 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 134217728), "PendingDeposits") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(generic.PendingDeposit) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "PendingDeposits[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #35 'PendingPartialWithdrawals' + if canSeek { + enc.EncodeOffsetAt(offset35, uint32(enc.GetPosition()-dstlen)) + } + t := t.PendingPartialWithdrawals + vlen := len(t) + if vlen > 134217728 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 134217728), "PendingPartialWithdrawals") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(generic.PendingPartialWithdrawal) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "PendingPartialWithdrawals[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #36 'PendingConsolidations' + if canSeek { + enc.EncodeOffsetAt(offset36, uint32(enc.GetPosition()-dstlen)) + } + t := t.PendingConsolidations + vlen := len(t) + if vlen > 262144 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 262144), "PendingConsolidations") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(generic.PendingConsolidation) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "PendingConsolidations[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + return nil +} + +// UnmarshalSSZ unmarshals the *BeaconState from SSZ-encoded bytes. +func (t *BeaconState) UnmarshalSSZ(buf []byte) (err error) { + buflen := len(buf) + if buflen < 2736713 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 2736713) + } + { // Field #0 'GenesisTime' (static) + buf := buf[0:8] + t.GenesisTime = binary.LittleEndian.Uint64(buf) + } + { // Field #1 'GenesisValidatorsRoot' (static) + buf := buf[8:40] + t.GenesisValidatorsRoot = sszutils.ExpandSlice(t.GenesisValidatorsRoot, 32) + copy(t.GenesisValidatorsRoot[:], buf) + } + { // Field #2 'Slot' (static) + buf := buf[40:48] + t.Slot = binary.LittleEndian.Uint64(buf) + } + { // Field #3 'Fork' (static) + buf := buf[48:64] + if t.Fork == nil { + t.Fork = new(generic.Fork) + } + if err = t.Fork.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "Fork") + } + } + { // Field #4 'LatestBlockHeader' (static) + buf := buf[64:176] + if t.LatestBlockHeader == nil { + t.LatestBlockHeader = new(generic.BeaconBlockHeader) + } + if err = t.LatestBlockHeader.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") + } + } + { // Field #5 'BlockRoots' (static) + buf := buf[176:262320] + val1 := t.BlockRoots + sszutils.UnmarshalFixedBytesSlice(val1[:8192], buf) + t.BlockRoots = val1 + } + { // Field #6 'StateRoots' (static) + buf := buf[262320:524464] + val2 := t.StateRoots + sszutils.UnmarshalFixedBytesSlice(val2[:8192], buf) + t.StateRoots = val2 + } + // Field #7 'HistoricalRoots' (offset) + offset7 := int(binary.LittleEndian.Uint32(buf[524464:524468])) + if offset7 != 2736713 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset7, 2736713), "HistoricalRoots:o") + } + { // Field #8 'Eth1Data' (static) + buf := buf[524468:524540] + if t.Eth1Data == nil { + t.Eth1Data = new(generic.Eth1Data) + } + if err = t.Eth1Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "Eth1Data") + } + } + // Field #9 'Eth1DataVotes' (offset) + offset9 := int(binary.LittleEndian.Uint32(buf[524540:524544])) + if offset9 < offset7 || offset9 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset9, offset7, buflen), "Eth1DataVotes:o") + } + { // Field #10 'Eth1DepositIndex' (static) + buf := buf[524544:524552] + t.Eth1DepositIndex = binary.LittleEndian.Uint64(buf) + } + // Field #11 'Validators' (offset) + offset11 := int(binary.LittleEndian.Uint32(buf[524552:524556])) + if offset11 < offset9 || offset11 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset11, offset9, buflen), "Validators:o") + } + // Field #12 'Balances' (offset) + offset12 := int(binary.LittleEndian.Uint32(buf[524556:524560])) + if offset12 < offset11 || offset12 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset12, offset11, buflen), "Balances:o") + } + { // Field #13 'RandaoMixes' (static) + buf := buf[524560:2621712] + val3 := t.RandaoMixes + val3 = sszutils.ExpandSlice(val3, 65536) + for idx1 := range 65536 { + buf := buf[32*idx1 : 32*(idx1+1)] + val3[idx1] = sszutils.ExpandSlice(val3[idx1], 32) + copy(val3[idx1][:], buf) + } + t.RandaoMixes = val3 + } + { // Field #14 'Slashings' (static) + buf := buf[2621712:2687248] + val4 := t.Slashings + val4 = sszutils.ExpandSlice(val4, 8192) + sszutils.UnmarshalUint64Slice(val4[:8192], buf) + t.Slashings = val4 + } + // Field #15 'PreviousEpochParticipation' (offset) + offset15 := int(binary.LittleEndian.Uint32(buf[2687248:2687252])) + if offset15 < offset12 || offset15 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset15, offset12, buflen), "PreviousEpochParticipation:o") + } + // Field #16 'CurrentEpochParticipation' (offset) + offset16 := int(binary.LittleEndian.Uint32(buf[2687252:2687256])) + if offset16 < offset15 || offset16 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset16, offset15, buflen), "CurrentEpochParticipation:o") + } + { // Field #17 'JustificationBits' (static) + buf := buf[2687256:2687257] + copy(t.JustificationBits[:], buf) + } + { // Field #18 'PreviousJustifiedCheckpoint' (static) + buf := buf[2687257:2687297] + if t.PreviousJustifiedCheckpoint == nil { + t.PreviousJustifiedCheckpoint = new(generic.Checkpoint) + } + if err = t.PreviousJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } + } + { // Field #19 'CurrentJustifiedCheckpoint' (static) + buf := buf[2687297:2687337] + if t.CurrentJustifiedCheckpoint == nil { + t.CurrentJustifiedCheckpoint = new(generic.Checkpoint) + } + if err = t.CurrentJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } + } + { // Field #20 'FinalizedCheckpoint' (static) + buf := buf[2687337:2687377] + if t.FinalizedCheckpoint == nil { + t.FinalizedCheckpoint = new(generic.Checkpoint) + } + if err = t.FinalizedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") + } + } + // Field #21 'InactivityScores' (offset) + offset21 := int(binary.LittleEndian.Uint32(buf[2687377:2687381])) + if offset21 < offset16 || offset21 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset21, offset16, buflen), "InactivityScores:o") + } + { // Field #22 'CurrentSyncCommittee' (static) + buf := buf[2687381:2712005] + if t.CurrentSyncCommittee == nil { + t.CurrentSyncCommittee = new(generic.SyncCommittee) + } + if err = t.CurrentSyncCommittee.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "CurrentSyncCommittee") + } + } + { // Field #23 'NextSyncCommittee' (static) + buf := buf[2712005:2736629] + if t.NextSyncCommittee == nil { + t.NextSyncCommittee = new(generic.SyncCommittee) + } + if err = t.NextSyncCommittee.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "NextSyncCommittee") + } + } + // Field #24 'LatestExecutionPayloadHeader' (offset) + offset24 := int(binary.LittleEndian.Uint32(buf[2736629:2736633])) + if offset24 < offset21 || offset24 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset24, offset21, buflen), "LatestExecutionPayloadHeader:o") + } + { // Field #25 'NextWithdrawalIndex' (static) + buf := buf[2736633:2736641] + t.NextWithdrawalIndex = binary.LittleEndian.Uint64(buf) + } + { // Field #26 'NextWithdrawalValidatorIndex' (static) + buf := buf[2736641:2736649] + t.NextWithdrawalValidatorIndex = binary.LittleEndian.Uint64(buf) + } + // Field #27 'HistoricalSummaries' (offset) + offset27 := int(binary.LittleEndian.Uint32(buf[2736649:2736653])) + if offset27 < offset24 || offset27 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset27, offset24, buflen), "HistoricalSummaries:o") + } + { // Field #28 'DepositRequestsStartIndex' (static) + buf := buf[2736653:2736661] + t.DepositRequestsStartIndex = binary.LittleEndian.Uint64(buf) + } + { // Field #29 'DepositBalanceToConsume' (static) + buf := buf[2736661:2736669] + t.DepositBalanceToConsume = binary.LittleEndian.Uint64(buf) + } + { // Field #30 'ExitBalanceToConsume' (static) + buf := buf[2736669:2736677] + t.ExitBalanceToConsume = binary.LittleEndian.Uint64(buf) + } + { // Field #31 'EarliestExitEpoch' (static) + buf := buf[2736677:2736685] + t.EarliestExitEpoch = binary.LittleEndian.Uint64(buf) + } + { // Field #32 'ConsolidationBalanceToConsume' (static) + buf := buf[2736685:2736693] + t.ConsolidationBalanceToConsume = binary.LittleEndian.Uint64(buf) + } + { // Field #33 'EarliestConsolidationEpoch' (static) + buf := buf[2736693:2736701] + t.EarliestConsolidationEpoch = binary.LittleEndian.Uint64(buf) + } + // Field #34 'PendingDeposits' (offset) + offset34 := int(binary.LittleEndian.Uint32(buf[2736701:2736705])) + if offset34 < offset27 || offset34 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset34, offset27, buflen), "PendingDeposits:o") + } + // Field #35 'PendingPartialWithdrawals' (offset) + offset35 := int(binary.LittleEndian.Uint32(buf[2736705:2736709])) + if offset35 < offset34 || offset35 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset35, offset34, buflen), "PendingPartialWithdrawals:o") + } + // Field #36 'PendingConsolidations' (offset) + offset36 := int(binary.LittleEndian.Uint32(buf[2736709:2736713])) + if offset36 < offset35 || offset36 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset36, offset35, buflen), "PendingConsolidations:o") + } + { // Field #7 'HistoricalRoots' (dynamic) + buf := buf[offset7:offset9] + val5 := t.HistoricalRoots + itemCount := len(buf) / 32 + if len(buf)%32 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 32), "HistoricalRoots") + } + if itemCount > 16777216 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 16777216), "HistoricalRoots") + } + val5 = sszutils.ExpandSlice(val5, itemCount) + for idx1 := range itemCount { + buf := buf[32*idx1 : 32*(idx1+1)] + val5[idx1] = sszutils.ExpandSlice(val5[idx1], 32) + copy(val5[idx1][:], buf) + } + t.HistoricalRoots = val5 + } + { // Field #9 'Eth1DataVotes' (dynamic) + buf := buf[offset9:offset11] + val6 := t.Eth1DataVotes + itemCount := len(buf) / 72 + if len(buf)%72 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 72), "Eth1DataVotes") + } + if itemCount > 2048 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 2048), "Eth1DataVotes") + } + val6 = sszutils.ExpandSlice(val6, itemCount) + for idx1 := range itemCount { + if val6[idx1] == nil { + val6[idx1] = new(generic.Eth1Data) + } + buf := buf[72*idx1 : 72*(idx1+1)] + if err = val6[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Eth1DataVotes[%d]", idx1) + } + } + t.Eth1DataVotes = val6 + } + { // Field #11 'Validators' (dynamic) + buf := buf[offset11:offset12] + val7 := t.Validators + itemCount := len(buf) / 121 + if len(buf)%121 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 121), "Validators") + } + if itemCount > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1099511627776), "Validators") + } + val7 = sszutils.ExpandSlice(val7, itemCount) + for idx1 := range itemCount { + if val7[idx1] == nil { + val7[idx1] = new(generic.Validator) + } + buf := buf[121*idx1 : 121*(idx1+1)] + if err = val7[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } + } + t.Validators = val7 + } + { // Field #12 'Balances' (dynamic) + buf := buf[offset12:offset15] + val8 := t.Balances + itemCount := len(buf) / 8 + if len(buf)%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 8), "Balances") + } + if itemCount > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1099511627776), "Balances") + } + val8 = sszutils.ExpandSlice(val8, itemCount) + sszutils.UnmarshalUint64Slice(val8, buf) + t.Balances = val8 + } + { // Field #15 'PreviousEpochParticipation' (dynamic) + buf := buf[offset15:offset16] + if len(buf) > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(len(buf), 1099511627776), "PreviousEpochParticipation") + } + t.PreviousEpochParticipation = sszutils.ExpandSlice(t.PreviousEpochParticipation, len(buf)) + copy(t.PreviousEpochParticipation[:], buf) + } + { // Field #16 'CurrentEpochParticipation' (dynamic) + buf := buf[offset16:offset21] + if len(buf) > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(len(buf), 1099511627776), "CurrentEpochParticipation") + } + t.CurrentEpochParticipation = sszutils.ExpandSlice(t.CurrentEpochParticipation, len(buf)) + copy(t.CurrentEpochParticipation[:], buf) + } + { // Field #21 'InactivityScores' (dynamic) + buf := buf[offset21:offset24] + val9 := t.InactivityScores + itemCount := len(buf) / 8 + if len(buf)%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 8), "InactivityScores") + } + if itemCount > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1099511627776), "InactivityScores") + } + val9 = sszutils.ExpandSlice(val9, itemCount) + sszutils.UnmarshalUint64Slice(val9, buf) + t.InactivityScores = val9 + } + { // Field #24 'LatestExecutionPayloadHeader' (dynamic) + buf := buf[offset24:offset27] + if t.LatestExecutionPayloadHeader == nil { + t.LatestExecutionPayloadHeader = new(generic.ExecutionPayloadHeader) + } + if err = t.LatestExecutionPayloadHeader.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "LatestExecutionPayloadHeader") + } + } + { // Field #27 'HistoricalSummaries' (dynamic) + buf := buf[offset27:offset34] + val10 := t.HistoricalSummaries + itemCount := len(buf) / 64 + if len(buf)%64 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 64), "HistoricalSummaries") + } + if itemCount > 16777216 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 16777216), "HistoricalSummaries") + } + val10 = sszutils.ExpandSlice(val10, itemCount) + for idx1 := range itemCount { + if val10[idx1] == nil { + val10[idx1] = new(generic.HistoricalSummary) + } + buf := buf[64*idx1 : 64*(idx1+1)] + if err = val10[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "HistoricalSummaries[%d]", idx1) + } + } + t.HistoricalSummaries = val10 + } + { // Field #34 'PendingDeposits' (dynamic) + buf := buf[offset34:offset35] + val11 := t.PendingDeposits + itemCount := len(buf) / 192 + if len(buf)%192 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 192), "PendingDeposits") + } + if itemCount > 134217728 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 134217728), "PendingDeposits") + } + val11 = sszutils.ExpandSlice(val11, itemCount) + for idx1 := range itemCount { + if val11[idx1] == nil { + val11[idx1] = new(generic.PendingDeposit) + } + buf := buf[192*idx1 : 192*(idx1+1)] + if err = val11[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "PendingDeposits[%d]", idx1) + } + } + t.PendingDeposits = val11 + } + { // Field #35 'PendingPartialWithdrawals' (dynamic) + buf := buf[offset35:offset36] + val12 := t.PendingPartialWithdrawals + itemCount := len(buf) / 24 + if len(buf)%24 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 24), "PendingPartialWithdrawals") + } + if itemCount > 134217728 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 134217728), "PendingPartialWithdrawals") + } + val12 = sszutils.ExpandSlice(val12, itemCount) + for idx1 := range itemCount { + if val12[idx1] == nil { + val12[idx1] = new(generic.PendingPartialWithdrawal) + } + buf := buf[24*idx1 : 24*(idx1+1)] + if err = val12[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "PendingPartialWithdrawals[%d]", idx1) + } + } + t.PendingPartialWithdrawals = val12 + } + { // Field #36 'PendingConsolidations' (dynamic) + buf := buf[offset36:] + val13 := t.PendingConsolidations + itemCount := len(buf) / 16 + if len(buf)%16 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 16), "PendingConsolidations") + } + if itemCount > 262144 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 262144), "PendingConsolidations") + } + val13 = sszutils.ExpandSlice(val13, itemCount) + for idx1 := range itemCount { + if val13[idx1] == nil { + val13[idx1] = new(generic.PendingConsolidation) + } + buf := buf[16*idx1 : 16*(idx1+1)] + if err = val13[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "PendingConsolidations[%d]", idx1) + } + } + t.PendingConsolidations = val13 + } + return nil +} + +// UnmarshalSSZDyn unmarshals the *BeaconState from SSZ-encoded bytes using dynamic specifications. +func (t *BeaconState) UnmarshalSSZDyn(_ sszutils.DynamicSpecs, buf []byte) (err error) { + return t.UnmarshalSSZ(buf) +} + +// UnmarshalSSZDecoder unmarshals the *BeaconState from the given SSZ decoder using dynamic specifications. +func (t *BeaconState) UnmarshalSSZDecoder(ds sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { + maxOffset := uint32(dec.GetLength()) + startPos0 := dec.GetPosition() + if maxOffset < uint32(2736713) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(2736713)) + } + // Field #0 'GenesisTime' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "GenesisTime") + } else { + t.GenesisTime = val + } + // Field #1 'GenesisValidatorsRoot' (static) + t.GenesisValidatorsRoot = sszutils.ExpandSlice(t.GenesisValidatorsRoot, 32) + if _, err = dec.DecodeBytes(t.GenesisValidatorsRoot[:32]); err != nil { + return err + } + // Field #2 'Slot' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "Slot") + } else { + t.Slot = val + } + // Field #3 'Fork' (static) + if t.Fork == nil { + t.Fork = new(generic.Fork) + } + if err = t.Fork.UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPath(err, "Fork") + } + // Field #4 'LatestBlockHeader' (static) + if t.LatestBlockHeader == nil { + t.LatestBlockHeader = new(generic.BeaconBlockHeader) + } + if err = t.LatestBlockHeader.UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") + } + { // Field #5 'BlockRoots' (static) + val1 := t.BlockRoots + startPos1 := dec.GetPosition() + for idx1 := range 8192 { + if _, err = dec.DecodeBytes(val1[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos1+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos1+int(32*(idx1+1))), "BlockRoots[%d]", idx1) + } + } + t.BlockRoots = val1 + } + { // Field #6 'StateRoots' (static) + val2 := t.StateRoots + startPos2 := dec.GetPosition() + for idx1 := range 8192 { + if _, err = dec.DecodeBytes(val2[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos2+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos2+int(32*(idx1+1))), "StateRoots[%d]", idx1) + } + } + t.StateRoots = val2 + } + // Field #7 'HistoricalRoots' (offset) + offset7, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "HistoricalRoots") + } + if offset7 != uint32(2736713) { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset7, 2736713), "HistoricalRoots") + } + // Field #8 'Eth1Data' (static) + if t.Eth1Data == nil { + t.Eth1Data = new(generic.Eth1Data) + } + if err = t.Eth1Data.UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPath(err, "Eth1Data") + } + // Field #9 'Eth1DataVotes' (offset) + offset9, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Eth1DataVotes") + } + if offset9 < offset7 || offset9 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset9, offset7, maxOffset), "Eth1DataVotes") + } + // Field #10 'Eth1DepositIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "Eth1DepositIndex") + } else { + t.Eth1DepositIndex = val + } + // Field #11 'Validators' (offset) + offset11, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Validators") + } + if offset11 < offset9 || offset11 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset11, offset9, maxOffset), "Validators") + } + // Field #12 'Balances' (offset) + offset12, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Balances") + } + if offset12 < offset11 || offset12 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset12, offset11, maxOffset), "Balances") + } + { // Field #13 'RandaoMixes' (static) + val3 := t.RandaoMixes + val3 = sszutils.ExpandSlice(val3, 65536) + startPos3 := dec.GetPosition() + for idx1 := range 65536 { + val3[idx1] = sszutils.ExpandSlice(val3[idx1], 32) + if _, err = dec.DecodeBytes(val3[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos3+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos3+int(32*(idx1+1))), "RandaoMixes[%d]", idx1) + } + } + t.RandaoMixes = val3 + } + { // Field #14 'Slashings' (static) + val4 := t.Slashings + val4 = sszutils.ExpandSlice(val4, 8192) + if err = sszutils.DecodeUint64Slice(dec, val4[:8192]); err != nil { + return sszutils.ErrorWithPath(err, "Slashings") + } + t.Slashings = val4 + } + // Field #15 'PreviousEpochParticipation' (offset) + offset15, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "PreviousEpochParticipation") + } + if offset15 < offset12 || offset15 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset15, offset12, maxOffset), "PreviousEpochParticipation") + } + // Field #16 'CurrentEpochParticipation' (offset) + offset16, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "CurrentEpochParticipation") + } + if offset16 < offset15 || offset16 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset16, offset15, maxOffset), "CurrentEpochParticipation") + } + // Field #17 'JustificationBits' (static) + if _, err = dec.DecodeBytes(t.JustificationBits[:1]); err != nil { + return err + } + // Field #18 'PreviousJustifiedCheckpoint' (static) + if t.PreviousJustifiedCheckpoint == nil { + t.PreviousJustifiedCheckpoint = new(generic.Checkpoint) + } + if err = t.PreviousJustifiedCheckpoint.UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } + // Field #19 'CurrentJustifiedCheckpoint' (static) + if t.CurrentJustifiedCheckpoint == nil { + t.CurrentJustifiedCheckpoint = new(generic.Checkpoint) + } + if err = t.CurrentJustifiedCheckpoint.UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } + // Field #20 'FinalizedCheckpoint' (static) + if t.FinalizedCheckpoint == nil { + t.FinalizedCheckpoint = new(generic.Checkpoint) + } + if err = t.FinalizedCheckpoint.UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") + } + // Field #21 'InactivityScores' (offset) + offset21, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "InactivityScores") + } + if offset21 < offset16 || offset21 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset21, offset16, maxOffset), "InactivityScores") + } + // Field #22 'CurrentSyncCommittee' (static) + if t.CurrentSyncCommittee == nil { + t.CurrentSyncCommittee = new(generic.SyncCommittee) + } + if err = t.CurrentSyncCommittee.UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPath(err, "CurrentSyncCommittee") + } + // Field #23 'NextSyncCommittee' (static) + if t.NextSyncCommittee == nil { + t.NextSyncCommittee = new(generic.SyncCommittee) + } + if err = t.NextSyncCommittee.UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPath(err, "NextSyncCommittee") + } + // Field #24 'LatestExecutionPayloadHeader' (offset) + offset24, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "LatestExecutionPayloadHeader") + } + if offset24 < offset21 || offset24 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset24, offset21, maxOffset), "LatestExecutionPayloadHeader") + } + // Field #25 'NextWithdrawalIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "NextWithdrawalIndex") + } else { + t.NextWithdrawalIndex = val + } + // Field #26 'NextWithdrawalValidatorIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "NextWithdrawalValidatorIndex") + } else { + t.NextWithdrawalValidatorIndex = val + } + // Field #27 'HistoricalSummaries' (offset) + offset27, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "HistoricalSummaries") + } + if offset27 < offset24 || offset27 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset27, offset24, maxOffset), "HistoricalSummaries") + } + // Field #28 'DepositRequestsStartIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "DepositRequestsStartIndex") + } else { + t.DepositRequestsStartIndex = val + } + // Field #29 'DepositBalanceToConsume' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "DepositBalanceToConsume") + } else { + t.DepositBalanceToConsume = val + } + // Field #30 'ExitBalanceToConsume' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "ExitBalanceToConsume") + } else { + t.ExitBalanceToConsume = val + } + // Field #31 'EarliestExitEpoch' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "EarliestExitEpoch") + } else { + t.EarliestExitEpoch = val + } + // Field #32 'ConsolidationBalanceToConsume' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "ConsolidationBalanceToConsume") + } else { + t.ConsolidationBalanceToConsume = val + } + // Field #33 'EarliestConsolidationEpoch' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "EarliestConsolidationEpoch") + } else { + t.EarliestConsolidationEpoch = val + } + // Field #34 'PendingDeposits' (offset) + offset34, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "PendingDeposits") + } + if offset34 < offset27 || offset34 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset34, offset27, maxOffset), "PendingDeposits") + } + // Field #35 'PendingPartialWithdrawals' (offset) + offset35, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "PendingPartialWithdrawals") + } + if offset35 < offset34 || offset35 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset35, offset34, maxOffset), "PendingPartialWithdrawals") + } + // Field #36 'PendingConsolidations' (offset) + offset36, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "PendingConsolidations") + } + if offset36 < offset35 || offset36 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset36, offset35, maxOffset), "PendingConsolidations") + } + { // Field #7 'HistoricalRoots' (dynamic) + if dec.GetPosition() != startPos0+int(offset7) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset7)), "HistoricalRoots") + } + dec.PushLimit(int(offset9 - offset7)) + val5 := t.HistoricalRoots + sszLen := dec.GetLength() + itemCount := sszLen / 32 + if sszLen%32 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 32), "HistoricalRoots") + } + if itemCount > 16777216 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 16777216), "HistoricalRoots") + } + val5 = sszutils.ExpandSlice(val5, itemCount) + startPos4 := dec.GetPosition() + for idx1 := range itemCount { + val5[idx1] = sszutils.ExpandSlice(val5[idx1], 32) + if _, err = dec.DecodeBytes(val5[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos4+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos4+int(32*(idx1+1))), "HistoricalRoots[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "HistoricalRoots") + } + t.HistoricalRoots = val5 + } + { // Field #9 'Eth1DataVotes' (dynamic) + if dec.GetPosition() != startPos0+int(offset9) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset9)), "Eth1DataVotes") + } + dec.PushLimit(int(offset11 - offset9)) + val6 := t.Eth1DataVotes + sszLen := dec.GetLength() + itemCount := sszLen / 72 + if sszLen%72 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 72), "Eth1DataVotes") + } + if itemCount > 2048 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 2048), "Eth1DataVotes") + } + val6 = sszutils.ExpandSlice(val6, itemCount) + startPos5 := dec.GetPosition() + for idx1 := range itemCount { + if val6[idx1] == nil { + val6[idx1] = new(generic.Eth1Data) + } + if err = val6[idx1].UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPathf(err, "Eth1DataVotes[%d]", idx1) + } + if dec.GetPosition() != startPos5+int(72*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos5+int(72*(idx1+1))), "Eth1DataVotes[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Eth1DataVotes") + } + t.Eth1DataVotes = val6 + } + { // Field #11 'Validators' (dynamic) + if dec.GetPosition() != startPos0+int(offset11) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset11)), "Validators") + } + dec.PushLimit(int(offset12 - offset11)) + val7 := t.Validators + sszLen := dec.GetLength() + itemCount := sszLen / 121 + if sszLen%121 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 121), "Validators") + } + if itemCount > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1099511627776), "Validators") + } + val7 = sszutils.ExpandSlice(val7, itemCount) + startPos6 := dec.GetPosition() + for idx1 := range itemCount { + if val7[idx1] == nil { + val7[idx1] = new(generic.Validator) + } + if err = val7[idx1].UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } + if dec.GetPosition() != startPos6+int(121*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos6+int(121*(idx1+1))), "Validators[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Validators") + } + t.Validators = val7 + } + { // Field #12 'Balances' (dynamic) + if dec.GetPosition() != startPos0+int(offset12) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset12)), "Balances") + } + dec.PushLimit(int(offset15 - offset12)) + val8 := t.Balances + sszLen := dec.GetLength() + itemCount := sszLen / 8 + if sszLen%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 8), "Balances") + } + if itemCount > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1099511627776), "Balances") + } + val8 = sszutils.ExpandSlice(val8, itemCount) + if err = sszutils.DecodeUint64Slice(dec, val8); err != nil { + return sszutils.ErrorWithPath(err, "Balances") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Balances") + } + t.Balances = val8 + } + { // Field #15 'PreviousEpochParticipation' (dynamic) + if dec.GetPosition() != startPos0+int(offset15) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset15)), "PreviousEpochParticipation") + } + dec.PushLimit(int(offset16 - offset15)) + val9 := t.PreviousEpochParticipation + if dec.GetLength() > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(dec.GetLength(), 1099511627776), "PreviousEpochParticipation") + } + listLen := dec.GetLength() + val9 = sszutils.ExpandSlice(val9, listLen) + if _, err = dec.DecodeBytes(val9[:listLen]); err != nil { + return sszutils.ErrorWithPath(err, "PreviousEpochParticipation") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "PreviousEpochParticipation") + } + t.PreviousEpochParticipation = val9 + } + { // Field #16 'CurrentEpochParticipation' (dynamic) + if dec.GetPosition() != startPos0+int(offset16) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset16)), "CurrentEpochParticipation") + } + dec.PushLimit(int(offset21 - offset16)) + val10 := t.CurrentEpochParticipation + if dec.GetLength() > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(dec.GetLength(), 1099511627776), "CurrentEpochParticipation") + } + listLen := dec.GetLength() + val10 = sszutils.ExpandSlice(val10, listLen) + if _, err = dec.DecodeBytes(val10[:listLen]); err != nil { + return sszutils.ErrorWithPath(err, "CurrentEpochParticipation") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "CurrentEpochParticipation") + } + t.CurrentEpochParticipation = val10 + } + { // Field #21 'InactivityScores' (dynamic) + if dec.GetPosition() != startPos0+int(offset21) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset21)), "InactivityScores") + } + dec.PushLimit(int(offset24 - offset21)) + val11 := t.InactivityScores + sszLen := dec.GetLength() + itemCount := sszLen / 8 + if sszLen%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 8), "InactivityScores") + } + if itemCount > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1099511627776), "InactivityScores") + } + val11 = sszutils.ExpandSlice(val11, itemCount) + if err = sszutils.DecodeUint64Slice(dec, val11); err != nil { + return sszutils.ErrorWithPath(err, "InactivityScores") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "InactivityScores") + } + t.InactivityScores = val11 + } + { // Field #24 'LatestExecutionPayloadHeader' (dynamic) + if dec.GetPosition() != startPos0+int(offset24) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset24)), "LatestExecutionPayloadHeader") + } + dec.PushLimit(int(offset27 - offset24)) + val12 := t.LatestExecutionPayloadHeader + if val12 == nil { + val12 = new(generic.ExecutionPayloadHeader) + } + if err = val12.UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPath(err, "LatestExecutionPayloadHeader") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "LatestExecutionPayloadHeader") + } + t.LatestExecutionPayloadHeader = val12 + } + { // Field #27 'HistoricalSummaries' (dynamic) + if dec.GetPosition() != startPos0+int(offset27) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset27)), "HistoricalSummaries") + } + dec.PushLimit(int(offset34 - offset27)) + val13 := t.HistoricalSummaries + sszLen := dec.GetLength() + itemCount := sszLen / 64 + if sszLen%64 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 64), "HistoricalSummaries") + } + if itemCount > 16777216 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 16777216), "HistoricalSummaries") + } + val13 = sszutils.ExpandSlice(val13, itemCount) + startPos7 := dec.GetPosition() + for idx1 := range itemCount { + if val13[idx1] == nil { + val13[idx1] = new(generic.HistoricalSummary) + } + if err = val13[idx1].UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPathf(err, "HistoricalSummaries[%d]", idx1) + } + if dec.GetPosition() != startPos7+int(64*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos7+int(64*(idx1+1))), "HistoricalSummaries[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "HistoricalSummaries") + } + t.HistoricalSummaries = val13 + } + { // Field #34 'PendingDeposits' (dynamic) + if dec.GetPosition() != startPos0+int(offset34) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset34)), "PendingDeposits") + } + dec.PushLimit(int(offset35 - offset34)) + val14 := t.PendingDeposits + sszLen := dec.GetLength() + itemCount := sszLen / 192 + if sszLen%192 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 192), "PendingDeposits") + } + if itemCount > 134217728 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 134217728), "PendingDeposits") + } + val14 = sszutils.ExpandSlice(val14, itemCount) + startPos8 := dec.GetPosition() + for idx1 := range itemCount { + if val14[idx1] == nil { + val14[idx1] = new(generic.PendingDeposit) + } + if err = val14[idx1].UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPathf(err, "PendingDeposits[%d]", idx1) + } + if dec.GetPosition() != startPos8+int(192*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos8+int(192*(idx1+1))), "PendingDeposits[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "PendingDeposits") + } + t.PendingDeposits = val14 + } + { // Field #35 'PendingPartialWithdrawals' (dynamic) + if dec.GetPosition() != startPos0+int(offset35) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset35)), "PendingPartialWithdrawals") + } + dec.PushLimit(int(offset36 - offset35)) + val15 := t.PendingPartialWithdrawals + sszLen := dec.GetLength() + itemCount := sszLen / 24 + if sszLen%24 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 24), "PendingPartialWithdrawals") + } + if itemCount > 134217728 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 134217728), "PendingPartialWithdrawals") + } + val15 = sszutils.ExpandSlice(val15, itemCount) + startPos9 := dec.GetPosition() + for idx1 := range itemCount { + if val15[idx1] == nil { + val15[idx1] = new(generic.PendingPartialWithdrawal) + } + if err = val15[idx1].UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPathf(err, "PendingPartialWithdrawals[%d]", idx1) + } + if dec.GetPosition() != startPos9+int(24*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos9+int(24*(idx1+1))), "PendingPartialWithdrawals[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "PendingPartialWithdrawals") + } + t.PendingPartialWithdrawals = val15 + } + { // Field #36 'PendingConsolidations' (dynamic) + if dec.GetPosition() != startPos0+int(offset36) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset36)), "PendingConsolidations") + } + dec.PushLimit(int(maxOffset - offset36)) + val16 := t.PendingConsolidations + sszLen := dec.GetLength() + itemCount := sszLen / 16 + if sszLen%16 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 16), "PendingConsolidations") + } + if itemCount > 262144 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 262144), "PendingConsolidations") + } + val16 = sszutils.ExpandSlice(val16, itemCount) + startPos10 := dec.GetPosition() + for idx1 := range itemCount { + if val16[idx1] == nil { + val16[idx1] = new(generic.PendingConsolidation) + } + if err = val16[idx1].UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPathf(err, "PendingConsolidations[%d]", idx1) + } + if dec.GetPosition() != startPos10+int(16*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos10+int(16*(idx1+1))), "PendingConsolidations[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "PendingConsolidations") + } + t.PendingConsolidations = val16 + } + return nil +} + +// SizeSSZDyn returns the SSZ encoded size of the *BeaconState using dynamic specifications. +func (t *BeaconState) SizeSSZDyn(ds sszutils.DynamicSpecs) (size int) { + if t == nil { + t = new(BeaconState) + } + // Field #0 'GenesisTime' static (8 bytes) + // Field #1 'GenesisValidatorsRoot' static (32 bytes) + // Field #2 'Slot' static (8 bytes) + // Field #3 'Fork' static (16 bytes) + // Field #4 'LatestBlockHeader' static (112 bytes) + // Field #5 'BlockRoots' static (262144 bytes) + // Field #6 'StateRoots' static (262144 bytes) + // Field #7 'HistoricalRoots' offset (4 bytes) + // Field #8 'Eth1Data' static (72 bytes) + // Field #9 'Eth1DataVotes' offset (4 bytes) + // Field #10 'Eth1DepositIndex' static (8 bytes) + // Field #11 'Validators' offset (4 bytes) + // Field #12 'Balances' offset (4 bytes) + // Field #13 'RandaoMixes' static (2097152 bytes) + // Field #14 'Slashings' static (65536 bytes) + // Field #15 'PreviousEpochParticipation' offset (4 bytes) + // Field #16 'CurrentEpochParticipation' offset (4 bytes) + // Field #17 'JustificationBits' static (1 bytes) + // Field #18 'PreviousJustifiedCheckpoint' static (40 bytes) + // Field #19 'CurrentJustifiedCheckpoint' static (40 bytes) + // Field #20 'FinalizedCheckpoint' static (40 bytes) + // Field #21 'InactivityScores' offset (4 bytes) + // Field #22 'CurrentSyncCommittee' static (24624 bytes) + // Field #23 'NextSyncCommittee' static (24624 bytes) + // Field #24 'LatestExecutionPayloadHeader' offset (4 bytes) + // Field #25 'NextWithdrawalIndex' static (8 bytes) + // Field #26 'NextWithdrawalValidatorIndex' static (8 bytes) + // Field #27 'HistoricalSummaries' offset (4 bytes) + // Field #28 'DepositRequestsStartIndex' static (8 bytes) + // Field #29 'DepositBalanceToConsume' static (8 bytes) + // Field #30 'ExitBalanceToConsume' static (8 bytes) + // Field #31 'EarliestExitEpoch' static (8 bytes) + // Field #32 'ConsolidationBalanceToConsume' static (8 bytes) + // Field #33 'EarliestConsolidationEpoch' static (8 bytes) + // Field #34 'PendingDeposits' offset (4 bytes) + // Field #35 'PendingPartialWithdrawals' offset (4 bytes) + // Field #36 'PendingConsolidations' offset (4 bytes) + size += 2736713 + { // Dynamic field #7 'HistoricalRoots' + size += len(t.HistoricalRoots) * 32 + } + { // Dynamic field #9 'Eth1DataVotes' + size += len(t.Eth1DataVotes) * 72 + } + { // Dynamic field #11 'Validators' + size += len(t.Validators) * 121 + } + { // Dynamic field #12 'Balances' + size += len(t.Balances) * 8 + } + { // Dynamic field #15 'PreviousEpochParticipation' + size += len(t.PreviousEpochParticipation) + } + { // Dynamic field #16 'CurrentEpochParticipation' + size += len(t.CurrentEpochParticipation) + } + { // Dynamic field #21 'InactivityScores' + size += len(t.InactivityScores) * 8 + } + { // Dynamic field #24 'LatestExecutionPayloadHeader' + size += t.LatestExecutionPayloadHeader.SizeSSZDyn(ds) + } + { // Dynamic field #27 'HistoricalSummaries' + size += len(t.HistoricalSummaries) * 64 + } + { // Dynamic field #34 'PendingDeposits' + size += len(t.PendingDeposits) * 192 + } + { // Dynamic field #35 'PendingPartialWithdrawals' + size += len(t.PendingPartialWithdrawals) * 24 + } + { // Dynamic field #36 'PendingConsolidations' + size += len(t.PendingConsolidations) * 16 + } + return size +} + +// HashTreeRootDyn computes the SSZ hash tree root of the *BeaconState using dynamic specifications. +func (t *BeaconState) HashTreeRootDyn(ds sszutils.DynamicSpecs) (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWithDyn(ds, hh) + if err == nil { + root, err = hh.HashRoot() + } + return + }) + return +} + +// HashTreeRootWithDyn computes the SSZ hash tree root of the *BeaconState using dynamic specifications and the given hash walker. +func (t *BeaconState) HashTreeRootWithDyn(ds sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + if t == nil { + t = new(BeaconState) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'GenesisTime' + hh.PutUint64(t.GenesisTime) + } + { // Field #1 'GenesisValidatorsRoot' + vlen := len(t.GenesisValidatorsRoot) + if vlen > 32 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 32), "GenesisValidatorsRoot") + } + val := t.GenesisValidatorsRoot[:] + if vlen < 32 { + val = sszutils.AppendZeroPadding(val, (32-vlen)*1) + } + hh.PutBytes(val[:32]) + } + { // Field #2 'Slot' + hh.PutUint64(t.Slot) + } + { // Field #3 'Fork' + t := t.Fork + if t == nil { + t = new(generic.Fork) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPath(err, "Fork") + } + } + { // Field #4 'LatestBlockHeader' + t := t.LatestBlockHeader + if t == nil { + t = new(generic.BeaconBlockHeader) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") + } + } + { // Field #5 'BlockRoots' + t := &t.BlockRoots + idx := hh.StartTree(sszutils.TreeTypeBinary) + var val1 *[32]byte + for idx1 := range 8192 { + if idx1 < 8192 { + val1 = &t[idx1] + } else if idx1 == 8192 { + val1 = new([32]byte) + } + hh.PutBytes(val1[:32]) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.Merkleize(idx) + } + { // Field #6 'StateRoots' + t := &t.StateRoots + idx := hh.StartTree(sszutils.TreeTypeBinary) + var val2 *[32]byte + for idx1 := range 8192 { + if idx1 < 8192 { + val2 = &t[idx1] + } else if idx1 == 8192 { + val2 = new([32]byte) + } + hh.PutBytes(val2[:32]) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.Merkleize(idx) + } + { // Field #7 'HistoricalRoots' + t := t.HistoricalRoots + vlen := uint64(len(t)) + if vlen > 16777216 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16777216), "HistoricalRoots") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + vlen := len(t[idx1]) + if vlen > 32 { + return sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, 32), "HistoricalRoots[%d]", idx1) + } + val := t[idx1][:] + if vlen < 32 { + val = sszutils.AppendZeroPadding(val, (32-vlen)*1) + } + hh.PutBytes(val[:32]) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(16777216, vlen, 32)) + } + { // Field #8 'Eth1Data' + t := t.Eth1Data + if t == nil { + t = new(generic.Eth1Data) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPath(err, "Eth1Data") + } + } + { // Field #9 'Eth1DataVotes' + t := t.Eth1DataVotes + vlen := uint64(len(t)) + if vlen > 2048 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 2048), "Eth1DataVotes") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(generic.Eth1Data) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPathf(err, "Eth1DataVotes[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(2048, vlen, 32)) + } + { // Field #10 'Eth1DepositIndex' + hh.PutUint64(t.Eth1DepositIndex) + } + { // Field #11 'Validators' + t := t.Validators + vlen := uint64(len(t)) + if vlen > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1099511627776), "Validators") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(generic.Validator) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(1099511627776, vlen, 32)) + } + { // Field #12 'Balances' + t := t.Balances + vlen := uint64(len(t)) + if vlen > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1099511627776), "Balances") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + sszutils.HashUint64Slice(hh, t) + hh.FillUpTo32() + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(1099511627776, vlen, 8)) + } + { // Field #13 'RandaoMixes' + t := t.RandaoMixes + vlen := len(t) + if vlen > 65536 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 65536), "RandaoMixes") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + var val3, val3Empty []byte + for idx1 := range 65536 { + if idx1 < vlen { + val3 = t[idx1] + } else if idx1 == vlen { + val3 = val3Empty + } + vlen := len(val3) + if vlen > 32 { + return sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, 32), "RandaoMixes[%d]", idx1) + } + val := val3[:] + if vlen < 32 { + val = sszutils.AppendZeroPadding(val, (32-vlen)*1) + } + hh.PutBytes(val[:32]) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.Merkleize(idx) + } + { // Field #14 'Slashings' + t := t.Slashings + vlen := len(t) + if vlen > 8192 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 8192), "Slashings") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + var val4, val4Empty uint64 + for idx1 := range 8192 { + if idx1 < vlen { + val4 = t[idx1] + } else if idx1 == vlen { + val4 = val4Empty + } + hh.AppendUint64(val4) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.FillUpTo32() + hh.Merkleize(idx) + } + { // Field #15 'PreviousEpochParticipation' + vlen := uint64(len(t.PreviousEpochParticipation)) + if vlen > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1099511627776), "PreviousEpochParticipation") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + hh.AppendBytes32(t.PreviousEpochParticipation[:]) + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(1099511627776, vlen, 1)) + } + { // Field #16 'CurrentEpochParticipation' + vlen := uint64(len(t.CurrentEpochParticipation)) + if vlen > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1099511627776), "CurrentEpochParticipation") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + hh.AppendBytes32(t.CurrentEpochParticipation[:]) + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(1099511627776, vlen, 1)) + } + { // Field #17 'JustificationBits' + hh.PutBytes(t.JustificationBits[:1]) + } + { // Field #18 'PreviousJustifiedCheckpoint' + t := t.PreviousJustifiedCheckpoint + if t == nil { + t = new(generic.Checkpoint) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } + } + { // Field #19 'CurrentJustifiedCheckpoint' + t := t.CurrentJustifiedCheckpoint + if t == nil { + t = new(generic.Checkpoint) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } + } + { // Field #20 'FinalizedCheckpoint' + t := t.FinalizedCheckpoint + if t == nil { + t = new(generic.Checkpoint) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") + } + } + { // Field #21 'InactivityScores' + t := t.InactivityScores + vlen := uint64(len(t)) + if vlen > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1099511627776), "InactivityScores") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + sszutils.HashUint64Slice(hh, t) + hh.FillUpTo32() + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(1099511627776, vlen, 8)) + } + { // Field #22 'CurrentSyncCommittee' + t := t.CurrentSyncCommittee + if t == nil { + t = new(generic.SyncCommittee) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPath(err, "CurrentSyncCommittee") + } + } + { // Field #23 'NextSyncCommittee' + t := t.NextSyncCommittee + if t == nil { + t = new(generic.SyncCommittee) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPath(err, "NextSyncCommittee") + } + } + { // Field #24 'LatestExecutionPayloadHeader' + t := t.LatestExecutionPayloadHeader + if t == nil { + t = new(generic.ExecutionPayloadHeader) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPath(err, "LatestExecutionPayloadHeader") + } + } + { // Field #25 'NextWithdrawalIndex' + hh.PutUint64(t.NextWithdrawalIndex) + } + { // Field #26 'NextWithdrawalValidatorIndex' + hh.PutUint64(t.NextWithdrawalValidatorIndex) + } + { // Field #27 'HistoricalSummaries' + t := t.HistoricalSummaries + vlen := uint64(len(t)) + if vlen > 16777216 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16777216), "HistoricalSummaries") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(generic.HistoricalSummary) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPathf(err, "HistoricalSummaries[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(16777216, vlen, 32)) + } + { // Field #28 'DepositRequestsStartIndex' + hh.PutUint64(t.DepositRequestsStartIndex) + } + { // Field #29 'DepositBalanceToConsume' + hh.PutUint64(t.DepositBalanceToConsume) + } + { // Field #30 'ExitBalanceToConsume' + hh.PutUint64(t.ExitBalanceToConsume) + } + { // Field #31 'EarliestExitEpoch' + hh.PutUint64(t.EarliestExitEpoch) + } + { // Field #32 'ConsolidationBalanceToConsume' + hh.PutUint64(t.ConsolidationBalanceToConsume) + } + { // Field #33 'EarliestConsolidationEpoch' + hh.PutUint64(t.EarliestConsolidationEpoch) + } + { // Field #34 'PendingDeposits' + t := t.PendingDeposits + vlen := uint64(len(t)) + if vlen > 134217728 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 134217728), "PendingDeposits") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(generic.PendingDeposit) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPathf(err, "PendingDeposits[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(134217728, vlen, 32)) + } + { // Field #35 'PendingPartialWithdrawals' + t := t.PendingPartialWithdrawals + vlen := uint64(len(t)) + if vlen > 134217728 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 134217728), "PendingPartialWithdrawals") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(generic.PendingPartialWithdrawal) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPathf(err, "PendingPartialWithdrawals[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(134217728, vlen, 32)) + } + { // Field #36 'PendingConsolidations' + t := t.PendingConsolidations + vlen := uint64(len(t)) + if vlen > 262144 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 262144), "PendingConsolidations") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(generic.PendingConsolidation) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPathf(err, "PendingConsolidations[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(262144, vlen, 32)) + } + hh.Merkleize(idx) + return nil +} + +// MarshalSSZDyn marshals the *SignedBeaconBlock to SSZ-encoded bytes using dynamic specifications. +func (t *SignedBeaconBlock) MarshalSSZDyn(ds sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + dst = buf + if t == nil { + t = new(SignedBeaconBlock) + } + dstlen := len(dst) + // Offset Field #0 'Block' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #1 'Signature' + vlen := len(t.Signature) + if vlen > 96 { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 96), "Signature") + } + dst = append(dst, t.Signature[:vlen]...) + if vlen < 96 { + dst = sszutils.AppendZeroPadding(dst, (96-vlen)*1) + } + } + { // Dynamic Field #0 'Block' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.Block + if t == nil { + t = new(BeaconBlock) + } + if dst, err = t.MarshalSSZDyn(ds, dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "Block") + } + } + return dst, nil +} + +// MarshalSSZEncoder marshals the *SignedBeaconBlock to the given SSZ encoder using dynamic specifications. +func (t *SignedBeaconBlock) MarshalSSZEncoder(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + type encoderCtx struct { + ds sszutils.DynamicSpecs + exprs [0]uint64 + sizeFn1 func(ctx *encoderCtx, t *BeaconBlock) (size int) + } + ctx := &encoderCtx{ds: ds} + canSeek := enc.Seekable() + // size for *BeaconBlock + ctx.sizeFn1 = func(ctx *encoderCtx, t *BeaconBlock) (size int) { + size += t.SizeSSZDyn(ds) + return size + } + if t == nil { + t = new(SignedBeaconBlock) + } + dstlen := enc.GetPosition() + dynoff := uint32(100) + // Offset #0 'Block' + offset0 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn1(ctx, t.Block)) + } + { // Field #1 'Signature' + vlen := len(t.Signature) + if vlen > 96 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 96), "Signature") + } + enc.EncodeBytes(t.Signature[:vlen]) + if vlen < 96 { + enc.EncodeZeroPadding((96 - vlen) * 1) + } + } + { // Dynamic Field #0 'Block' + if canSeek { + enc.EncodeOffsetAt(offset0, uint32(enc.GetPosition()-dstlen)) + } + t := t.Block + if t == nil { + t = new(BeaconBlock) + } + if err = t.MarshalSSZEncoder(ds, enc); err != nil { + return sszutils.ErrorWithPath(err, "Block") + } + } + return nil +} + +// UnmarshalSSZDyn unmarshals the *SignedBeaconBlock from SSZ-encoded bytes using dynamic specifications. +func (t *SignedBeaconBlock) UnmarshalSSZDyn(ds sszutils.DynamicSpecs, buf []byte) (err error) { + buflen := len(buf) + if buflen < 100 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 100) + } + // Field #0 'Block' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 100 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset0, 100), "Block:o") + } + { // Field #1 'Signature' (static) + buf := buf[4:100] + t.Signature = sszutils.ExpandSlice(t.Signature, 96) + copy(t.Signature[:], buf) + } + { // Field #0 'Block' (dynamic) + buf := buf[offset0:] + if t.Block == nil { + t.Block = new(BeaconBlock) + } + if err = t.Block.UnmarshalSSZDyn(ds, buf); err != nil { + return sszutils.ErrorWithPath(err, "Block") + } + } + return nil +} + +// UnmarshalSSZDecoder unmarshals the *SignedBeaconBlock from the given SSZ decoder using dynamic specifications. +func (t *SignedBeaconBlock) UnmarshalSSZDecoder(ds sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { + maxOffset := uint32(dec.GetLength()) + startPos0 := dec.GetPosition() + if maxOffset < uint32(100) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(100)) + } + // Field #0 'Block' (offset) + offset0, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Block") + } + if offset0 != uint32(100) { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset0, 100), "Block") + } + // Field #1 'Signature' (static) + t.Signature = sszutils.ExpandSlice(t.Signature, 96) + if _, err = dec.DecodeBytes(t.Signature[:96]); err != nil { + return err + } + { // Field #0 'Block' (dynamic) + if dec.GetPosition() != startPos0+int(offset0) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset0)), "Block") + } + dec.PushLimit(int(maxOffset - offset0)) + val1 := t.Block + if val1 == nil { + val1 = new(BeaconBlock) + } + if err = val1.UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPath(err, "Block") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Block") + } + t.Block = val1 + } + return nil +} + +// SizeSSZDyn returns the SSZ encoded size of the *SignedBeaconBlock using dynamic specifications. +func (t *SignedBeaconBlock) SizeSSZDyn(ds sszutils.DynamicSpecs) (size int) { + if t == nil { + t = new(SignedBeaconBlock) + } + // Field #0 'Block' offset (4 bytes) + // Field #1 'Signature' static (96 bytes) + size += 100 + { // Dynamic field #0 'Block' + size += t.Block.SizeSSZDyn(ds) + } + return size +} + +// HashTreeRootDyn computes the SSZ hash tree root of the *SignedBeaconBlock using dynamic specifications. +func (t *SignedBeaconBlock) HashTreeRootDyn(ds sszutils.DynamicSpecs) (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWithDyn(ds, hh) + if err == nil { + root, err = hh.HashRoot() + } + return + }) + return +} + +// HashTreeRootWithDyn computes the SSZ hash tree root of the *SignedBeaconBlock using dynamic specifications and the given hash walker. +func (t *SignedBeaconBlock) HashTreeRootWithDyn(ds sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + if t == nil { + t = new(SignedBeaconBlock) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Block' + t := t.Block + if t == nil { + t = new(BeaconBlock) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPath(err, "Block") + } + } + { // Field #1 'Signature' + vlen := len(t.Signature) + if vlen > 96 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 96), "Signature") + } + val := t.Signature[:] + if vlen < 96 { + val = sszutils.AppendZeroPadding(val, (96-vlen)*1) + } + hh.PutBytes(val[:96]) + } + hh.Merkleize(idx) + return nil +} + +// MarshalSSZDyn marshals the *BeaconBlock to SSZ-encoded bytes using dynamic specifications. +func (t *BeaconBlock) MarshalSSZDyn(ds sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + dst = buf + if t == nil { + t = new(BeaconBlock) + } + dstlen := len(dst) + { // Static Field #0 'Slot' + dst = binary.LittleEndian.AppendUint64(dst, t.Slot) + } + { // Static Field #1 'ProposerIndex' + dst = binary.LittleEndian.AppendUint64(dst, t.ProposerIndex) + } + { // Static Field #2 'ParentRoot' + dst = append(dst, t.ParentRoot[:32]...) + } + { // Static Field #3 'StateRoot' + dst = append(dst, t.StateRoot[:32]...) + } + // Offset Field #4 'Body' + dst = append(dst, 0, 0, 0, 0) + { // Dynamic Field #4 'Body' + binary.LittleEndian.PutUint32(dst[dstlen+80:], uint32(len(dst)-dstlen)) + t := t.Body + if t == nil { + t = new(BeaconBlockBody) + } + if dst, err = t.MarshalSSZDyn(ds, dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "Body") + } + } + return dst, nil +} + +// MarshalSSZEncoder marshals the *BeaconBlock to the given SSZ encoder using dynamic specifications. +func (t *BeaconBlock) MarshalSSZEncoder(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + type encoderCtx struct { + ds sszutils.DynamicSpecs + exprs [0]uint64 + sizeFn1 func(ctx *encoderCtx, t *BeaconBlockBody) (size int) + } + ctx := &encoderCtx{ds: ds} + canSeek := enc.Seekable() + // size for *BeaconBlockBody + ctx.sizeFn1 = func(ctx *encoderCtx, t *BeaconBlockBody) (size int) { + size += t.SizeSSZDyn(ds) + return size + } + if t == nil { + t = new(BeaconBlock) + } + dstlen := enc.GetPosition() + dynoff := uint32(84) + { // Field #0 'Slot' + enc.EncodeUint64(t.Slot) + } + { // Field #1 'ProposerIndex' + enc.EncodeUint64(t.ProposerIndex) + } + { // Field #2 'ParentRoot' + enc.EncodeBytes(t.ParentRoot[:32]) + } + { // Field #3 'StateRoot' + enc.EncodeBytes(t.StateRoot[:32]) + } + // Offset #4 'Body' + offset4 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn1(ctx, t.Body)) + } + { // Dynamic Field #4 'Body' + if canSeek { + enc.EncodeOffsetAt(offset4, uint32(enc.GetPosition()-dstlen)) + } + t := t.Body + if t == nil { + t = new(BeaconBlockBody) + } + if err = t.MarshalSSZEncoder(ds, enc); err != nil { + return sszutils.ErrorWithPath(err, "Body") + } + } + return nil +} + +// UnmarshalSSZDyn unmarshals the *BeaconBlock from SSZ-encoded bytes using dynamic specifications. +func (t *BeaconBlock) UnmarshalSSZDyn(ds sszutils.DynamicSpecs, buf []byte) (err error) { + buflen := len(buf) + if buflen < 84 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 84) + } + { // Field #0 'Slot' (static) + buf := buf[0:8] + t.Slot = binary.LittleEndian.Uint64(buf) + } + { // Field #1 'ProposerIndex' (static) + buf := buf[8:16] + t.ProposerIndex = binary.LittleEndian.Uint64(buf) + } + { // Field #2 'ParentRoot' (static) + buf := buf[16:48] + copy(t.ParentRoot[:], buf) + } + { // Field #3 'StateRoot' (static) + buf := buf[48:80] + copy(t.StateRoot[:], buf) + } + // Field #4 'Body' (offset) + offset4 := int(binary.LittleEndian.Uint32(buf[80:84])) + if offset4 != 84 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset4, 84), "Body:o") + } + { // Field #4 'Body' (dynamic) + buf := buf[offset4:] + if t.Body == nil { + t.Body = new(BeaconBlockBody) + } + if err = t.Body.UnmarshalSSZDyn(ds, buf); err != nil { + return sszutils.ErrorWithPath(err, "Body") + } + } + return nil +} + +// UnmarshalSSZDecoder unmarshals the *BeaconBlock from the given SSZ decoder using dynamic specifications. +func (t *BeaconBlock) UnmarshalSSZDecoder(ds sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { + maxOffset := uint32(dec.GetLength()) + startPos0 := dec.GetPosition() + if maxOffset < uint32(84) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(84)) + } + // Field #0 'Slot' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "Slot") + } else { + t.Slot = val + } + // Field #1 'ProposerIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "ProposerIndex") + } else { + t.ProposerIndex = val + } + // Field #2 'ParentRoot' (static) + if _, err = dec.DecodeBytes(t.ParentRoot[:32]); err != nil { + return err + } + // Field #3 'StateRoot' (static) + if _, err = dec.DecodeBytes(t.StateRoot[:32]); err != nil { + return err + } + // Field #4 'Body' (offset) + offset4, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Body") + } + if offset4 != uint32(84) { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset4, 84), "Body") + } + { // Field #4 'Body' (dynamic) + if dec.GetPosition() != startPos0+int(offset4) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset4)), "Body") + } + dec.PushLimit(int(maxOffset - offset4)) + val1 := t.Body + if val1 == nil { + val1 = new(BeaconBlockBody) + } + if err = val1.UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPath(err, "Body") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Body") + } + t.Body = val1 + } + return nil +} + +// SizeSSZDyn returns the SSZ encoded size of the *BeaconBlock using dynamic specifications. +func (t *BeaconBlock) SizeSSZDyn(ds sszutils.DynamicSpecs) (size int) { + if t == nil { + t = new(BeaconBlock) + } + // Field #0 'Slot' static (8 bytes) + // Field #1 'ProposerIndex' static (8 bytes) + // Field #2 'ParentRoot' static (32 bytes) + // Field #3 'StateRoot' static (32 bytes) + // Field #4 'Body' offset (4 bytes) + size += 84 + { // Dynamic field #4 'Body' + size += t.Body.SizeSSZDyn(ds) + } + return size +} + +// HashTreeRootDyn computes the SSZ hash tree root of the *BeaconBlock using dynamic specifications. +func (t *BeaconBlock) HashTreeRootDyn(ds sszutils.DynamicSpecs) (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWithDyn(ds, hh) + if err == nil { + root, err = hh.HashRoot() + } + return + }) + return +} + +// HashTreeRootWithDyn computes the SSZ hash tree root of the *BeaconBlock using dynamic specifications and the given hash walker. +func (t *BeaconBlock) HashTreeRootWithDyn(ds sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + if t == nil { + t = new(BeaconBlock) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Slot' + hh.PutUint64(t.Slot) + } + { // Field #1 'ProposerIndex' + hh.PutUint64(t.ProposerIndex) + } + { // Field #2 'ParentRoot' + hh.PutBytes(t.ParentRoot[:32]) + } + { // Field #3 'StateRoot' + hh.PutBytes(t.StateRoot[:32]) + } + { // Field #4 'Body' + t := t.Body + if t == nil { + t = new(BeaconBlockBody) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPath(err, "Body") + } + } + hh.Merkleize(idx) + return nil +} + +// MarshalSSZDyn marshals the *BeaconBlockBody to SSZ-encoded bytes using dynamic specifications. +func (t *BeaconBlockBody) MarshalSSZDyn(ds sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + dst = buf + zeroBytes := sszutils.ZeroBytes() + if t == nil { + t = new(BeaconBlockBody) + } + dstlen := len(dst) + { // Static Field #0 'RandaoReveal' + vlen := len(t.RandaoReveal) + if vlen > 96 { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 96), "RandaoReveal") + } + dst = append(dst, t.RandaoReveal[:vlen]...) + if vlen < 96 { + dst = sszutils.AppendZeroPadding(dst, (96-vlen)*1) + } + } + { // Static Field #1 'Eth1Data' + t := t.Eth1Data + if t == nil { + t = new(generic.Eth1Data) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "Eth1Data") + } + } + { // Static Field #2 'Graffiti' + dst = append(dst, t.Graffiti[:32]...) + } + // Offset Field #3 'ProposerSlashings' + // Offset Field #4 'AttesterSlashings' + // Offset Field #5 'Attestations' + // Offset Field #6 'Deposits' + // Offset Field #7 'VoluntaryExits' + dst = append(dst, zeroBytes[:20]...) + { // Static Field #8 'SyncAggregate' + t := t.SyncAggregate + if t == nil { + t = new(generic.SyncAggregate) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "SyncAggregate") + } + } + // Offset Field #9 'ExecutionPayload' + // Offset Field #10 'BlsToExecutionChanges' + // Offset Field #11 'BlobKzgCommitments' + // Offset Field #12 'ExecutionRequests' + dst = append(dst, zeroBytes[:16]...) + { // Dynamic Field #3 'ProposerSlashings' + binary.LittleEndian.PutUint32(dst[dstlen+200:], uint32(len(dst)-dstlen)) + t := t.ProposerSlashings + vlen := len(t) + if vlen > 16 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16), "ProposerSlashings") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(generic.ProposerSlashing) + } + if dst, err = t.MarshalSSZDyn(ds, dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "ProposerSlashings[%d]", idx1) + } + } + } + { // Dynamic Field #4 'AttesterSlashings' + binary.LittleEndian.PutUint32(dst[dstlen+204:], uint32(len(dst)-dstlen)) + t := t.AttesterSlashings + vlen := len(t) + if vlen > 1 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1), "AttesterSlashings") + } + dstlen := len(dst) + dst = sszutils.AppendZeroPadding(dst, vlen*4) + for idx1 := range vlen { + binary.LittleEndian.PutUint32(dst[dstlen+(idx1*4):], uint32(len(dst)-dstlen)) + t := t[idx1] + if t == nil { + t = new(AttesterSlashing) + } + if dst, err = t.MarshalSSZDyn(ds, dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "AttesterSlashings[%d]", idx1) + } + } + } + { // Dynamic Field #5 'Attestations' + binary.LittleEndian.PutUint32(dst[dstlen+208:], uint32(len(dst)-dstlen)) + t := t.Attestations + vlen := len(t) + if vlen > 8 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 8), "Attestations") + } + dstlen := len(dst) + dst = sszutils.AppendZeroPadding(dst, vlen*4) + for idx1 := range vlen { + binary.LittleEndian.PutUint32(dst[dstlen+(idx1*4):], uint32(len(dst)-dstlen)) + t := t[idx1] + if t == nil { + t = new(Attestation) + } + if dst, err = t.MarshalSSZDyn(ds, dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "Attestations[%d]", idx1) + } + } + } + { // Dynamic Field #6 'Deposits' + binary.LittleEndian.PutUint32(dst[dstlen+212:], uint32(len(dst)-dstlen)) + t := t.Deposits + vlen := len(t) + if vlen > 16 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16), "Deposits") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(generic.Deposit) + } + if dst, err = t.MarshalSSZDyn(ds, dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "Deposits[%d]", idx1) + } + } + } + { // Dynamic Field #7 'VoluntaryExits' + binary.LittleEndian.PutUint32(dst[dstlen+216:], uint32(len(dst)-dstlen)) + t := t.VoluntaryExits + vlen := len(t) + if vlen > 16 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16), "VoluntaryExits") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(generic.SignedVoluntaryExit) + } + if dst, err = t.MarshalSSZDyn(ds, dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "VoluntaryExits[%d]", idx1) + } + } + } + { // Dynamic Field #9 'ExecutionPayload' + binary.LittleEndian.PutUint32(dst[dstlen+380:], uint32(len(dst)-dstlen)) + t := t.ExecutionPayload + if t == nil { + t = new(generic.ExecutionPayload) + } + if dst, err = t.MarshalSSZDyn(ds, dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "ExecutionPayload") + } + } + { // Dynamic Field #10 'BlsToExecutionChanges' + binary.LittleEndian.PutUint32(dst[dstlen+384:], uint32(len(dst)-dstlen)) + t := t.BlsToExecutionChanges + vlen := len(t) + if vlen > 16 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16), "BlsToExecutionChanges") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(generic.SignedBLSToExecutionChange) + } + if dst, err = t.MarshalSSZDyn(ds, dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "BlsToExecutionChanges[%d]", idx1) + } + } + } + { // Dynamic Field #11 'BlobKzgCommitments' + binary.LittleEndian.PutUint32(dst[dstlen+388:], uint32(len(dst)-dstlen)) + t := t.BlobKzgCommitments + vlen := len(t) + if vlen > 4096 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 4096), "BlobKzgCommitments") + } + dst = sszutils.MarshalFixedBytesSlice(dst, t[:vlen]) + } + { // Dynamic Field #12 'ExecutionRequests' + binary.LittleEndian.PutUint32(dst[dstlen+392:], uint32(len(dst)-dstlen)) + t := t.ExecutionRequests + if t == nil { + t = new(ExecutionRequests) + } + if dst, err = t.MarshalSSZDyn(ds, dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "ExecutionRequests") + } + } + return dst, nil +} + +// MarshalSSZEncoder marshals the *BeaconBlockBody to the given SSZ encoder using dynamic specifications. +func (t *BeaconBlockBody) MarshalSSZEncoder(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + type encoderCtx struct { + ds sszutils.DynamicSpecs + exprs [0]uint64 + sizeFn1 func(ctx *encoderCtx, t []*generic.ProposerSlashing) (size int) + sizeFn10 func(ctx *encoderCtx, t *AttesterSlashing) (size int) + sizeFn11 func(ctx *encoderCtx, t *Attestation) (size int) + sizeFn2 func(ctx *encoderCtx, t []*AttesterSlashing) (size int) + sizeFn3 func(ctx *encoderCtx, t []*Attestation) (size int) + sizeFn4 func(ctx *encoderCtx, t []*generic.Deposit) (size int) + sizeFn5 func(ctx *encoderCtx, t []*generic.SignedVoluntaryExit) (size int) + sizeFn6 func(ctx *encoderCtx, t *generic.ExecutionPayload) (size int) + sizeFn7 func(ctx *encoderCtx, t []*generic.SignedBLSToExecutionChange) (size int) + sizeFn8 func(ctx *encoderCtx, t [][48]byte) (size int) + sizeFn9 func(ctx *encoderCtx, t *ExecutionRequests) (size int) + } + ctx := &encoderCtx{ds: ds} + canSeek := enc.Seekable() + // size for []*generic.ProposerSlashing + ctx.sizeFn1 = func(ctx *encoderCtx, t []*generic.ProposerSlashing) (size int) { + size += len(t) * 416 + return size + } + // size for []*AttesterSlashing + ctx.sizeFn2 = func(ctx *encoderCtx, t []*AttesterSlashing) (size int) { + vlen := len(t) + size += vlen * 4 // Offsets + for i1 := range vlen { + size += ctx.sizeFn10(ctx, t[i1]) + } + return size + } + // size for []*Attestation + ctx.sizeFn3 = func(ctx *encoderCtx, t []*Attestation) (size int) { + vlen := len(t) + size += vlen * 4 // Offsets + for i1 := range vlen { + size += ctx.sizeFn11(ctx, t[i1]) + } + return size + } + // size for []*generic.Deposit + ctx.sizeFn4 = func(ctx *encoderCtx, t []*generic.Deposit) (size int) { + size += len(t) * 1240 + return size + } + // size for []*generic.SignedVoluntaryExit + ctx.sizeFn5 = func(ctx *encoderCtx, t []*generic.SignedVoluntaryExit) (size int) { + size += len(t) * 112 + return size + } + // size for *generic.ExecutionPayload + ctx.sizeFn6 = func(ctx *encoderCtx, t *generic.ExecutionPayload) (size int) { + size += t.SizeSSZDyn(ds) + return size + } + // size for []*generic.SignedBLSToExecutionChange + ctx.sizeFn7 = func(ctx *encoderCtx, t []*generic.SignedBLSToExecutionChange) (size int) { + size += len(t) * 172 + return size + } + // size for [][48]byte + ctx.sizeFn8 = func(ctx *encoderCtx, t [][48]byte) (size int) { + size += len(t) * 48 + return size + } + // size for *ExecutionRequests + ctx.sizeFn9 = func(ctx *encoderCtx, t *ExecutionRequests) (size int) { + size += t.SizeSSZDyn(ds) + return size + } + // size for *AttesterSlashing + ctx.sizeFn10 = func(ctx *encoderCtx, t *AttesterSlashing) (size int) { + size += t.SizeSSZDyn(ds) + return size + } + // size for *Attestation + ctx.sizeFn11 = func(ctx *encoderCtx, t *Attestation) (size int) { + size += t.SizeSSZDyn(ds) + return size + } + if t == nil { + t = new(BeaconBlockBody) + } + dstlen := enc.GetPosition() + dynoff := uint32(396) + { // Field #0 'RandaoReveal' + vlen := len(t.RandaoReveal) + if vlen > 96 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 96), "RandaoReveal") + } + enc.EncodeBytes(t.RandaoReveal[:vlen]) + if vlen < 96 { + enc.EncodeZeroPadding((96 - vlen) * 1) + } + } + { // Field #1 'Eth1Data' + t := t.Eth1Data + if t == nil { + t = new(generic.Eth1Data) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "Eth1Data") + } else { + enc.SetBuffer(buf) + } + } + { // Field #2 'Graffiti' + enc.EncodeBytes(t.Graffiti[:32]) + } + // Offset #3 'ProposerSlashings' + offset3 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn1(ctx, t.ProposerSlashings)) + } + // Offset #4 'AttesterSlashings' + offset4 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn2(ctx, t.AttesterSlashings)) + } + // Offset #5 'Attestations' + offset5 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn3(ctx, t.Attestations)) + } + // Offset #6 'Deposits' + offset6 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn4(ctx, t.Deposits)) + } + // Offset #7 'VoluntaryExits' + offset7 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn5(ctx, t.VoluntaryExits)) + } + { // Field #8 'SyncAggregate' + t := t.SyncAggregate + if t == nil { + t = new(generic.SyncAggregate) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "SyncAggregate") + } else { + enc.SetBuffer(buf) + } + } + // Offset #9 'ExecutionPayload' + offset9 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn6(ctx, t.ExecutionPayload)) + } + // Offset #10 'BlsToExecutionChanges' + offset10 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn7(ctx, t.BlsToExecutionChanges)) + } + // Offset #11 'BlobKzgCommitments' + offset11 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn8(ctx, t.BlobKzgCommitments)) + } + // Offset #12 'ExecutionRequests' + offset12 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn9(ctx, t.ExecutionRequests)) + } + { // Dynamic Field #3 'ProposerSlashings' + if canSeek { + enc.EncodeOffsetAt(offset3, uint32(enc.GetPosition()-dstlen)) + } + t := t.ProposerSlashings + vlen := len(t) + if vlen > 16 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16), "ProposerSlashings") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(generic.ProposerSlashing) + } + if err = t.MarshalSSZEncoder(ds, enc); err != nil { + return sszutils.ErrorWithPathf(err, "ProposerSlashings[%d]", idx1) + } + } + } + { // Dynamic Field #4 'AttesterSlashings' + if canSeek { + enc.EncodeOffsetAt(offset4, uint32(enc.GetPosition()-dstlen)) + } + t := t.AttesterSlashings + vlen := len(t) + if vlen > 1 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1), "AttesterSlashings") + } + dstlen := enc.GetPosition() + if canSeek { + enc.EncodeZeroPadding(vlen * 4) + } else if vlen > 0 { + offset := vlen * 4 + enc.EncodeOffset(uint32(offset)) + for i := range vlen - 1 { + offset += ctx.sizeFn10(ctx, t[i]) + enc.EncodeOffset(uint32(offset)) + } + } + for idx1 := range vlen { + if canSeek { + enc.EncodeOffsetAt(dstlen+(idx1*4), uint32(enc.GetPosition()-dstlen)) + } + t := t[idx1] + if t == nil { + t = new(AttesterSlashing) + } + if err = t.MarshalSSZEncoder(ds, enc); err != nil { + return sszutils.ErrorWithPathf(err, "AttesterSlashings[%d]", idx1) + } + } + } + { // Dynamic Field #5 'Attestations' + if canSeek { + enc.EncodeOffsetAt(offset5, uint32(enc.GetPosition()-dstlen)) + } + t := t.Attestations + vlen := len(t) + if vlen > 8 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 8), "Attestations") + } + dstlen := enc.GetPosition() + if canSeek { + enc.EncodeZeroPadding(vlen * 4) + } else if vlen > 0 { + offset := vlen * 4 + enc.EncodeOffset(uint32(offset)) + for i := range vlen - 1 { + offset += ctx.sizeFn11(ctx, t[i]) + enc.EncodeOffset(uint32(offset)) + } + } + for idx1 := range vlen { + if canSeek { + enc.EncodeOffsetAt(dstlen+(idx1*4), uint32(enc.GetPosition()-dstlen)) + } + t := t[idx1] + if t == nil { + t = new(Attestation) + } + if err = t.MarshalSSZEncoder(ds, enc); err != nil { + return sszutils.ErrorWithPathf(err, "Attestations[%d]", idx1) + } + } + } + { // Dynamic Field #6 'Deposits' + if canSeek { + enc.EncodeOffsetAt(offset6, uint32(enc.GetPosition()-dstlen)) + } + t := t.Deposits + vlen := len(t) + if vlen > 16 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16), "Deposits") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(generic.Deposit) + } + if err = t.MarshalSSZEncoder(ds, enc); err != nil { + return sszutils.ErrorWithPathf(err, "Deposits[%d]", idx1) + } + } + } + { // Dynamic Field #7 'VoluntaryExits' + if canSeek { + enc.EncodeOffsetAt(offset7, uint32(enc.GetPosition()-dstlen)) + } + t := t.VoluntaryExits + vlen := len(t) + if vlen > 16 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16), "VoluntaryExits") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(generic.SignedVoluntaryExit) + } + if err = t.MarshalSSZEncoder(ds, enc); err != nil { + return sszutils.ErrorWithPathf(err, "VoluntaryExits[%d]", idx1) + } + } + } + { // Dynamic Field #9 'ExecutionPayload' + if canSeek { + enc.EncodeOffsetAt(offset9, uint32(enc.GetPosition()-dstlen)) + } + t := t.ExecutionPayload + if t == nil { + t = new(generic.ExecutionPayload) + } + if err = t.MarshalSSZEncoder(ds, enc); err != nil { + return sszutils.ErrorWithPath(err, "ExecutionPayload") + } + } + { // Dynamic Field #10 'BlsToExecutionChanges' + if canSeek { + enc.EncodeOffsetAt(offset10, uint32(enc.GetPosition()-dstlen)) + } + t := t.BlsToExecutionChanges + vlen := len(t) + if vlen > 16 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16), "BlsToExecutionChanges") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(generic.SignedBLSToExecutionChange) + } + if err = t.MarshalSSZEncoder(ds, enc); err != nil { + return sszutils.ErrorWithPathf(err, "BlsToExecutionChanges[%d]", idx1) + } + } + } + { // Dynamic Field #11 'BlobKzgCommitments' + if canSeek { + enc.EncodeOffsetAt(offset11, uint32(enc.GetPosition()-dstlen)) + } + t := t.BlobKzgCommitments + vlen := len(t) + if vlen > 4096 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 4096), "BlobKzgCommitments") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:48]) + } + } + { // Dynamic Field #12 'ExecutionRequests' + if canSeek { + enc.EncodeOffsetAt(offset12, uint32(enc.GetPosition()-dstlen)) + } + t := t.ExecutionRequests + if t == nil { + t = new(ExecutionRequests) + } + if err = t.MarshalSSZEncoder(ds, enc); err != nil { + return sszutils.ErrorWithPath(err, "ExecutionRequests") + } + } + return nil +} + +// UnmarshalSSZDyn unmarshals the *BeaconBlockBody from SSZ-encoded bytes using dynamic specifications. +func (t *BeaconBlockBody) UnmarshalSSZDyn(ds sszutils.DynamicSpecs, buf []byte) (err error) { + buflen := len(buf) + if buflen < 396 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 396) + } + { // Field #0 'RandaoReveal' (static) + buf := buf[0:96] + t.RandaoReveal = sszutils.ExpandSlice(t.RandaoReveal, 96) + copy(t.RandaoReveal[:], buf) + } + { // Field #1 'Eth1Data' (static) + buf := buf[96:168] + if t.Eth1Data == nil { + t.Eth1Data = new(generic.Eth1Data) + } + if err = t.Eth1Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "Eth1Data") + } + } + { // Field #2 'Graffiti' (static) + buf := buf[168:200] + copy(t.Graffiti[:], buf) + } + // Field #3 'ProposerSlashings' (offset) + offset3 := int(binary.LittleEndian.Uint32(buf[200:204])) + if offset3 != 396 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset3, 396), "ProposerSlashings:o") + } + // Field #4 'AttesterSlashings' (offset) + offset4 := int(binary.LittleEndian.Uint32(buf[204:208])) + if offset4 < offset3 || offset4 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset4, offset3, buflen), "AttesterSlashings:o") + } + // Field #5 'Attestations' (offset) + offset5 := int(binary.LittleEndian.Uint32(buf[208:212])) + if offset5 < offset4 || offset5 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset5, offset4, buflen), "Attestations:o") + } + // Field #6 'Deposits' (offset) + offset6 := int(binary.LittleEndian.Uint32(buf[212:216])) + if offset6 < offset5 || offset6 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset6, offset5, buflen), "Deposits:o") + } + // Field #7 'VoluntaryExits' (offset) + offset7 := int(binary.LittleEndian.Uint32(buf[216:220])) + if offset7 < offset6 || offset7 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset7, offset6, buflen), "VoluntaryExits:o") + } + { // Field #8 'SyncAggregate' (static) + buf := buf[220:380] + if t.SyncAggregate == nil { + t.SyncAggregate = new(generic.SyncAggregate) + } + if err = t.SyncAggregate.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "SyncAggregate") + } + } + // Field #9 'ExecutionPayload' (offset) + offset9 := int(binary.LittleEndian.Uint32(buf[380:384])) + if offset9 < offset7 || offset9 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset9, offset7, buflen), "ExecutionPayload:o") + } + // Field #10 'BlsToExecutionChanges' (offset) + offset10 := int(binary.LittleEndian.Uint32(buf[384:388])) + if offset10 < offset9 || offset10 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset10, offset9, buflen), "BlsToExecutionChanges:o") + } + // Field #11 'BlobKzgCommitments' (offset) + offset11 := int(binary.LittleEndian.Uint32(buf[388:392])) + if offset11 < offset10 || offset11 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset11, offset10, buflen), "BlobKzgCommitments:o") + } + // Field #12 'ExecutionRequests' (offset) + offset12 := int(binary.LittleEndian.Uint32(buf[392:396])) + if offset12 < offset11 || offset12 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset12, offset11, buflen), "ExecutionRequests:o") + } + { // Field #3 'ProposerSlashings' (dynamic) + buf := buf[offset3:offset4] + val1 := t.ProposerSlashings + itemCount := len(buf) / 416 + if len(buf)%416 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 416), "ProposerSlashings") + } + if itemCount > 16 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 16), "ProposerSlashings") + } + val1 = sszutils.ExpandSlice(val1, itemCount) + for idx1 := range itemCount { + if val1[idx1] == nil { + val1[idx1] = new(generic.ProposerSlashing) + } + buf := buf[416*idx1 : 416*(idx1+1)] + if err = val1[idx1].UnmarshalSSZDyn(ds, buf); err != nil { + return sszutils.ErrorWithPathf(err, "ProposerSlashings[%d]", idx1) + } + } + t.ProposerSlashings = val1 + } + { // Field #4 'AttesterSlashings' (dynamic) + buf := buf[offset4:offset5] + val2 := t.AttesterSlashings + startOffset := int(0) + if len(buf) != 0 { + if len(buf) < 4 { + return sszutils.ErrorWithPath(sszutils.ErrListOffsetsEOFFn(len(buf), 4), "AttesterSlashings") + } + startOffset = int(binary.LittleEndian.Uint32(buf[0:4])) + } + itemCount := startOffset / 4 + if startOffset%4 != 0 || len(buf) < startOffset || (len(buf) != 0 && startOffset == 0) { + return sszutils.ErrorWithPath(sszutils.ErrInvalidListStartOffsetFn(startOffset, len(buf)), "AttesterSlashings") + } + if itemCount > 1 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1), "AttesterSlashings") + } + val2 = sszutils.ExpandSlice(val2, itemCount) + for idx1 := range itemCount { + var endOffset int + if idx1 < itemCount-1 { + endOffset = int(binary.LittleEndian.Uint32(buf[(idx1+1)*4 : (idx1+2)*4])) + } else { + endOffset = len(buf) + } + if endOffset < startOffset || endOffset > len(buf) { + return sszutils.ErrorWithPathf(sszutils.ErrElementOffsetOutOfRangeFn(endOffset, startOffset, len(buf)), "AttesterSlashings[%d]", idx1) + } + buf := buf[startOffset:endOffset] + startOffset = endOffset + val3 := val2[idx1] + if val3 == nil { + val3 = new(AttesterSlashing) + } + if err = val3.UnmarshalSSZDyn(ds, buf); err != nil { + return sszutils.ErrorWithPathf(err, "AttesterSlashings[%d]", idx1) + } + val2[idx1] = val3 + } + t.AttesterSlashings = val2 + } + { // Field #5 'Attestations' (dynamic) + buf := buf[offset5:offset6] + val4 := t.Attestations + startOffset := int(0) + if len(buf) != 0 { + if len(buf) < 4 { + return sszutils.ErrorWithPath(sszutils.ErrListOffsetsEOFFn(len(buf), 4), "Attestations") + } + startOffset = int(binary.LittleEndian.Uint32(buf[0:4])) + } + itemCount := startOffset / 4 + if startOffset%4 != 0 || len(buf) < startOffset || (len(buf) != 0 && startOffset == 0) { + return sszutils.ErrorWithPath(sszutils.ErrInvalidListStartOffsetFn(startOffset, len(buf)), "Attestations") + } + if itemCount > 8 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 8), "Attestations") + } + val4 = sszutils.ExpandSlice(val4, itemCount) + for idx1 := range itemCount { + var endOffset int + if idx1 < itemCount-1 { + endOffset = int(binary.LittleEndian.Uint32(buf[(idx1+1)*4 : (idx1+2)*4])) + } else { + endOffset = len(buf) + } + if endOffset < startOffset || endOffset > len(buf) { + return sszutils.ErrorWithPathf(sszutils.ErrElementOffsetOutOfRangeFn(endOffset, startOffset, len(buf)), "Attestations[%d]", idx1) + } + buf := buf[startOffset:endOffset] + startOffset = endOffset + val5 := val4[idx1] + if val5 == nil { + val5 = new(Attestation) + } + if err = val5.UnmarshalSSZDyn(ds, buf); err != nil { + return sszutils.ErrorWithPathf(err, "Attestations[%d]", idx1) + } + val4[idx1] = val5 + } + t.Attestations = val4 + } + { // Field #6 'Deposits' (dynamic) + buf := buf[offset6:offset7] + val6 := t.Deposits + itemCount := len(buf) / 1240 + if len(buf)%1240 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 1240), "Deposits") + } + if itemCount > 16 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 16), "Deposits") + } + val6 = sszutils.ExpandSlice(val6, itemCount) + for idx1 := range itemCount { + if val6[idx1] == nil { + val6[idx1] = new(generic.Deposit) + } + buf := buf[1240*idx1 : 1240*(idx1+1)] + if err = val6[idx1].UnmarshalSSZDyn(ds, buf); err != nil { + return sszutils.ErrorWithPathf(err, "Deposits[%d]", idx1) + } + } + t.Deposits = val6 + } + { // Field #7 'VoluntaryExits' (dynamic) + buf := buf[offset7:offset9] + val7 := t.VoluntaryExits + itemCount := len(buf) / 112 + if len(buf)%112 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 112), "VoluntaryExits") + } + if itemCount > 16 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 16), "VoluntaryExits") + } + val7 = sszutils.ExpandSlice(val7, itemCount) + for idx1 := range itemCount { + if val7[idx1] == nil { + val7[idx1] = new(generic.SignedVoluntaryExit) + } + buf := buf[112*idx1 : 112*(idx1+1)] + if err = val7[idx1].UnmarshalSSZDyn(ds, buf); err != nil { + return sszutils.ErrorWithPathf(err, "VoluntaryExits[%d]", idx1) + } + } + t.VoluntaryExits = val7 + } + { // Field #9 'ExecutionPayload' (dynamic) + buf := buf[offset9:offset10] + if t.ExecutionPayload == nil { + t.ExecutionPayload = new(generic.ExecutionPayload) + } + if err = t.ExecutionPayload.UnmarshalSSZDyn(ds, buf); err != nil { + return sszutils.ErrorWithPath(err, "ExecutionPayload") + } + } + { // Field #10 'BlsToExecutionChanges' (dynamic) + buf := buf[offset10:offset11] + val8 := t.BlsToExecutionChanges + itemCount := len(buf) / 172 + if len(buf)%172 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 172), "BlsToExecutionChanges") + } + if itemCount > 16 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 16), "BlsToExecutionChanges") + } + val8 = sszutils.ExpandSlice(val8, itemCount) + for idx1 := range itemCount { + if val8[idx1] == nil { + val8[idx1] = new(generic.SignedBLSToExecutionChange) + } + buf := buf[172*idx1 : 172*(idx1+1)] + if err = val8[idx1].UnmarshalSSZDyn(ds, buf); err != nil { + return sszutils.ErrorWithPathf(err, "BlsToExecutionChanges[%d]", idx1) + } + } + t.BlsToExecutionChanges = val8 + } + { // Field #11 'BlobKzgCommitments' (dynamic) + buf := buf[offset11:offset12] + val9 := t.BlobKzgCommitments + itemCount := len(buf) / 48 + if len(buf)%48 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 48), "BlobKzgCommitments") + } + if itemCount > 4096 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 4096), "BlobKzgCommitments") + } + val9 = sszutils.ExpandSlice(val9, itemCount) + sszutils.UnmarshalFixedBytesSlice(val9[:itemCount], buf) + t.BlobKzgCommitments = val9 + } + { // Field #12 'ExecutionRequests' (dynamic) + buf := buf[offset12:] + if t.ExecutionRequests == nil { + t.ExecutionRequests = new(ExecutionRequests) + } + if err = t.ExecutionRequests.UnmarshalSSZDyn(ds, buf); err != nil { + return sszutils.ErrorWithPath(err, "ExecutionRequests") + } + } + return nil +} + +// UnmarshalSSZDecoder unmarshals the *BeaconBlockBody from the given SSZ decoder using dynamic specifications. +func (t *BeaconBlockBody) UnmarshalSSZDecoder(ds sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { + canSeek := dec.Seekable() + offsetSlices := [1][]uint32{ + sszutils.GetOffsetSlice(0), + } + defer func() { + sszutils.PutOffsetSlice(offsetSlices[0]) + }() + maxOffset := uint32(dec.GetLength()) + startPos0 := dec.GetPosition() + if maxOffset < uint32(396) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(396)) + } + // Field #0 'RandaoReveal' (static) + t.RandaoReveal = sszutils.ExpandSlice(t.RandaoReveal, 96) + if _, err = dec.DecodeBytes(t.RandaoReveal[:96]); err != nil { + return err + } + // Field #1 'Eth1Data' (static) + if t.Eth1Data == nil { + t.Eth1Data = new(generic.Eth1Data) + } + if err = t.Eth1Data.UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPath(err, "Eth1Data") + } + // Field #2 'Graffiti' (static) + if _, err = dec.DecodeBytes(t.Graffiti[:32]); err != nil { + return err + } + // Field #3 'ProposerSlashings' (offset) + offset3, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "ProposerSlashings") + } + if offset3 != uint32(396) { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset3, 396), "ProposerSlashings") + } + // Field #4 'AttesterSlashings' (offset) + offset4, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "AttesterSlashings") + } + if offset4 < offset3 || offset4 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset4, offset3, maxOffset), "AttesterSlashings") + } + // Field #5 'Attestations' (offset) + offset5, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Attestations") + } + if offset5 < offset4 || offset5 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset5, offset4, maxOffset), "Attestations") + } + // Field #6 'Deposits' (offset) + offset6, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Deposits") + } + if offset6 < offset5 || offset6 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset6, offset5, maxOffset), "Deposits") + } + // Field #7 'VoluntaryExits' (offset) + offset7, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "VoluntaryExits") + } + if offset7 < offset6 || offset7 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset7, offset6, maxOffset), "VoluntaryExits") + } + // Field #8 'SyncAggregate' (static) + if t.SyncAggregate == nil { + t.SyncAggregate = new(generic.SyncAggregate) + } + if err = t.SyncAggregate.UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPath(err, "SyncAggregate") + } + // Field #9 'ExecutionPayload' (offset) + offset9, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "ExecutionPayload") + } + if offset9 < offset7 || offset9 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset9, offset7, maxOffset), "ExecutionPayload") + } + // Field #10 'BlsToExecutionChanges' (offset) + offset10, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "BlsToExecutionChanges") + } + if offset10 < offset9 || offset10 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset10, offset9, maxOffset), "BlsToExecutionChanges") + } + // Field #11 'BlobKzgCommitments' (offset) + offset11, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "BlobKzgCommitments") + } + if offset11 < offset10 || offset11 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset11, offset10, maxOffset), "BlobKzgCommitments") + } + // Field #12 'ExecutionRequests' (offset) + offset12, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "ExecutionRequests") + } + if offset12 < offset11 || offset12 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset12, offset11, maxOffset), "ExecutionRequests") + } + { // Field #3 'ProposerSlashings' (dynamic) + if dec.GetPosition() != startPos0+int(offset3) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset3)), "ProposerSlashings") + } + dec.PushLimit(int(offset4 - offset3)) + val1 := t.ProposerSlashings + sszLen := dec.GetLength() + itemCount := sszLen / 416 + if sszLen%416 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 416), "ProposerSlashings") + } + if itemCount > 16 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 16), "ProposerSlashings") + } + val1 = sszutils.ExpandSlice(val1, itemCount) + startPos1 := dec.GetPosition() + for idx1 := range itemCount { + if val1[idx1] == nil { + val1[idx1] = new(generic.ProposerSlashing) + } + if err = val1[idx1].UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPathf(err, "ProposerSlashings[%d]", idx1) + } + if dec.GetPosition() != startPos1+int(416*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos1+int(416*(idx1+1))), "ProposerSlashings[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "ProposerSlashings") + } + t.ProposerSlashings = val1 + } + { // Field #4 'AttesterSlashings' (dynamic) + if dec.GetPosition() != startPos0+int(offset4) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset4)), "AttesterSlashings") + } + dec.PushLimit(int(offset5 - offset4)) + val2 := t.AttesterSlashings + startOffset := uint32(0) + startPos2 := dec.GetPosition() + sszLen := uint32(dec.GetLength()) + if sszLen > 0 { + startOffset, err = dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "AttesterSlashings") + } + } + itemCount := int(startOffset / 4) + var offsets []uint32 + if canSeek { + dec.SkipBytes((itemCount - 1) * 4) + } else if itemCount > 1 { + offsetSlices[0] = sszutils.ExpandSlice(offsetSlices[0], itemCount-1) + offsets = offsetSlices[0] + for idx1 := range itemCount - 1 { + offset, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPathf(err, "AttesterSlashings[%d:o]", idx1) + } + offsets[idx1] = offset + } + } + if startOffset%4 != 0 || uint32(sszLen) < startOffset { + return sszutils.ErrorWithPath(sszutils.ErrInvalidListStartOffsetFn(startOffset, sszLen), "AttesterSlashings") + } + if itemCount > 1 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1), "AttesterSlashings") + } + val2 = sszutils.ExpandSlice(val2, itemCount) + for idx1 := range itemCount { + var endOffset uint32 + if idx1 < itemCount-1 { + if canSeek { + endOffset = dec.DecodeOffsetAt(startPos2 + int((idx1+1)*4)) + } else { + endOffset = offsets[idx1] + } + } else { + endOffset = uint32(sszLen) + } + if endOffset < startOffset || endOffset > uint32(sszLen) { + return sszutils.ErrorWithPathf(sszutils.ErrElementOffsetOutOfRangeFn(endOffset, startOffset, sszLen), "AttesterSlashings[%d]", idx1) + } + itemSize := endOffset - startOffset + dec.PushLimit(int(itemSize)) + startOffset = endOffset + val3 := val2[idx1] + if val3 == nil { + val3 = new(AttesterSlashing) + } + if err = val3.UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPathf(err, "AttesterSlashings[%d]", idx1) + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPathf(sszutils.ErrTrailingDataFn(diff), "AttesterSlashings[%d]", idx1) + } + val2[idx1] = val3 + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "AttesterSlashings") + } + t.AttesterSlashings = val2 + } + { // Field #5 'Attestations' (dynamic) + if dec.GetPosition() != startPos0+int(offset5) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset5)), "Attestations") + } + dec.PushLimit(int(offset6 - offset5)) + val4 := t.Attestations + startOffset := uint32(0) + startPos3 := dec.GetPosition() + sszLen := uint32(dec.GetLength()) + if sszLen > 0 { + startOffset, err = dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Attestations") + } + } + itemCount := int(startOffset / 4) + var offsets []uint32 + if canSeek { + dec.SkipBytes((itemCount - 1) * 4) + } else if itemCount > 1 { + offsetSlices[0] = sszutils.ExpandSlice(offsetSlices[0], itemCount-1) + offsets = offsetSlices[0] + for idx1 := range itemCount - 1 { + offset, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPathf(err, "Attestations[%d:o]", idx1) + } + offsets[idx1] = offset + } + } + if startOffset%4 != 0 || uint32(sszLen) < startOffset { + return sszutils.ErrorWithPath(sszutils.ErrInvalidListStartOffsetFn(startOffset, sszLen), "Attestations") + } + if itemCount > 8 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 8), "Attestations") + } + val4 = sszutils.ExpandSlice(val4, itemCount) + for idx1 := range itemCount { + var endOffset uint32 + if idx1 < itemCount-1 { + if canSeek { + endOffset = dec.DecodeOffsetAt(startPos3 + int((idx1+1)*4)) + } else { + endOffset = offsets[idx1] + } + } else { + endOffset = uint32(sszLen) + } + if endOffset < startOffset || endOffset > uint32(sszLen) { + return sszutils.ErrorWithPathf(sszutils.ErrElementOffsetOutOfRangeFn(endOffset, startOffset, sszLen), "Attestations[%d]", idx1) + } + itemSize := endOffset - startOffset + dec.PushLimit(int(itemSize)) + startOffset = endOffset + val5 := val4[idx1] + if val5 == nil { + val5 = new(Attestation) + } + if err = val5.UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPathf(err, "Attestations[%d]", idx1) + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPathf(sszutils.ErrTrailingDataFn(diff), "Attestations[%d]", idx1) + } + val4[idx1] = val5 + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Attestations") + } + t.Attestations = val4 + } + { // Field #6 'Deposits' (dynamic) + if dec.GetPosition() != startPos0+int(offset6) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset6)), "Deposits") + } + dec.PushLimit(int(offset7 - offset6)) + val6 := t.Deposits + sszLen := dec.GetLength() + itemCount := sszLen / 1240 + if sszLen%1240 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 1240), "Deposits") + } + if itemCount > 16 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 16), "Deposits") + } + val6 = sszutils.ExpandSlice(val6, itemCount) + startPos4 := dec.GetPosition() + for idx1 := range itemCount { + if val6[idx1] == nil { + val6[idx1] = new(generic.Deposit) + } + if err = val6[idx1].UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPathf(err, "Deposits[%d]", idx1) + } + if dec.GetPosition() != startPos4+int(1240*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos4+int(1240*(idx1+1))), "Deposits[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Deposits") + } + t.Deposits = val6 + } + { // Field #7 'VoluntaryExits' (dynamic) + if dec.GetPosition() != startPos0+int(offset7) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset7)), "VoluntaryExits") + } + dec.PushLimit(int(offset9 - offset7)) + val7 := t.VoluntaryExits + sszLen := dec.GetLength() + itemCount := sszLen / 112 + if sszLen%112 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 112), "VoluntaryExits") + } + if itemCount > 16 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 16), "VoluntaryExits") + } + val7 = sszutils.ExpandSlice(val7, itemCount) + startPos5 := dec.GetPosition() + for idx1 := range itemCount { + if val7[idx1] == nil { + val7[idx1] = new(generic.SignedVoluntaryExit) + } + if err = val7[idx1].UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPathf(err, "VoluntaryExits[%d]", idx1) + } + if dec.GetPosition() != startPos5+int(112*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos5+int(112*(idx1+1))), "VoluntaryExits[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "VoluntaryExits") + } + t.VoluntaryExits = val7 + } + { // Field #9 'ExecutionPayload' (dynamic) + if dec.GetPosition() != startPos0+int(offset9) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset9)), "ExecutionPayload") + } + dec.PushLimit(int(offset10 - offset9)) + val8 := t.ExecutionPayload + if val8 == nil { + val8 = new(generic.ExecutionPayload) + } + if err = val8.UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPath(err, "ExecutionPayload") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "ExecutionPayload") + } + t.ExecutionPayload = val8 + } + { // Field #10 'BlsToExecutionChanges' (dynamic) + if dec.GetPosition() != startPos0+int(offset10) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset10)), "BlsToExecutionChanges") + } + dec.PushLimit(int(offset11 - offset10)) + val9 := t.BlsToExecutionChanges + sszLen := dec.GetLength() + itemCount := sszLen / 172 + if sszLen%172 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 172), "BlsToExecutionChanges") + } + if itemCount > 16 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 16), "BlsToExecutionChanges") + } + val9 = sszutils.ExpandSlice(val9, itemCount) + startPos6 := dec.GetPosition() + for idx1 := range itemCount { + if val9[idx1] == nil { + val9[idx1] = new(generic.SignedBLSToExecutionChange) + } + if err = val9[idx1].UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPathf(err, "BlsToExecutionChanges[%d]", idx1) + } + if dec.GetPosition() != startPos6+int(172*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos6+int(172*(idx1+1))), "BlsToExecutionChanges[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "BlsToExecutionChanges") + } + t.BlsToExecutionChanges = val9 + } + { // Field #11 'BlobKzgCommitments' (dynamic) + if dec.GetPosition() != startPos0+int(offset11) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset11)), "BlobKzgCommitments") + } + dec.PushLimit(int(offset12 - offset11)) + val10 := t.BlobKzgCommitments + sszLen := dec.GetLength() + itemCount := sszLen / 48 + if sszLen%48 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 48), "BlobKzgCommitments") + } + if itemCount > 4096 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 4096), "BlobKzgCommitments") + } + val10 = sszutils.ExpandSlice(val10, itemCount) + startPos7 := dec.GetPosition() + for idx1 := range itemCount { + if _, err = dec.DecodeBytes(val10[idx1][:48]); err != nil { + return err + } + if dec.GetPosition() != startPos7+int(48*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos7+int(48*(idx1+1))), "BlobKzgCommitments[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "BlobKzgCommitments") + } + t.BlobKzgCommitments = val10 + } + { // Field #12 'ExecutionRequests' (dynamic) + if dec.GetPosition() != startPos0+int(offset12) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset12)), "ExecutionRequests") + } + dec.PushLimit(int(maxOffset - offset12)) + val11 := t.ExecutionRequests + if val11 == nil { + val11 = new(ExecutionRequests) + } + if err = val11.UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPath(err, "ExecutionRequests") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "ExecutionRequests") + } + t.ExecutionRequests = val11 + } + return nil +} + +// SizeSSZDyn returns the SSZ encoded size of the *BeaconBlockBody using dynamic specifications. +func (t *BeaconBlockBody) SizeSSZDyn(ds sszutils.DynamicSpecs) (size int) { + if t == nil { + t = new(BeaconBlockBody) + } + // Field #0 'RandaoReveal' static (96 bytes) + // Field #1 'Eth1Data' static (72 bytes) + // Field #2 'Graffiti' static (32 bytes) + // Field #3 'ProposerSlashings' offset (4 bytes) + // Field #4 'AttesterSlashings' offset (4 bytes) + // Field #5 'Attestations' offset (4 bytes) + // Field #6 'Deposits' offset (4 bytes) + // Field #7 'VoluntaryExits' offset (4 bytes) + // Field #8 'SyncAggregate' static (160 bytes) + // Field #9 'ExecutionPayload' offset (4 bytes) + // Field #10 'BlsToExecutionChanges' offset (4 bytes) + // Field #11 'BlobKzgCommitments' offset (4 bytes) + // Field #12 'ExecutionRequests' offset (4 bytes) + size += 396 + { // Dynamic field #3 'ProposerSlashings' + size += len(t.ProposerSlashings) * 416 + } + { // Dynamic field #4 'AttesterSlashings' + t := t.AttesterSlashings + vlen := len(t) + size += vlen * 4 // Offsets + for i1 := range vlen { + size += t[i1].SizeSSZDyn(ds) + } + } + { // Dynamic field #5 'Attestations' + t := t.Attestations + vlen := len(t) + size += vlen * 4 // Offsets + for i2 := range vlen { + size += t[i2].SizeSSZDyn(ds) + } + } + { // Dynamic field #6 'Deposits' + size += len(t.Deposits) * 1240 + } + { // Dynamic field #7 'VoluntaryExits' + size += len(t.VoluntaryExits) * 112 + } + { // Dynamic field #9 'ExecutionPayload' + size += t.ExecutionPayload.SizeSSZDyn(ds) + } + { // Dynamic field #10 'BlsToExecutionChanges' + size += len(t.BlsToExecutionChanges) * 172 + } + { // Dynamic field #11 'BlobKzgCommitments' + size += len(t.BlobKzgCommitments) * 48 + } + { // Dynamic field #12 'ExecutionRequests' + size += t.ExecutionRequests.SizeSSZDyn(ds) + } + return size +} + +// HashTreeRootDyn computes the SSZ hash tree root of the *BeaconBlockBody using dynamic specifications. +func (t *BeaconBlockBody) HashTreeRootDyn(ds sszutils.DynamicSpecs) (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWithDyn(ds, hh) + if err == nil { + root, err = hh.HashRoot() + } + return + }) + return +} + +// HashTreeRootWithDyn computes the SSZ hash tree root of the *BeaconBlockBody using dynamic specifications and the given hash walker. +func (t *BeaconBlockBody) HashTreeRootWithDyn(ds sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + if t == nil { + t = new(BeaconBlockBody) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'RandaoReveal' + vlen := len(t.RandaoReveal) + if vlen > 96 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 96), "RandaoReveal") + } + val := t.RandaoReveal[:] + if vlen < 96 { + val = sszutils.AppendZeroPadding(val, (96-vlen)*1) + } + hh.PutBytes(val[:96]) + } + { // Field #1 'Eth1Data' + t := t.Eth1Data + if t == nil { + t = new(generic.Eth1Data) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPath(err, "Eth1Data") + } + } + { // Field #2 'Graffiti' + hh.PutBytes(t.Graffiti[:32]) + } + { // Field #3 'ProposerSlashings' + t := t.ProposerSlashings + vlen := uint64(len(t)) + if vlen > 16 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16), "ProposerSlashings") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(generic.ProposerSlashing) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPathf(err, "ProposerSlashings[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(16, vlen, 32)) + } + { // Field #4 'AttesterSlashings' + t := t.AttesterSlashings + vlen := uint64(len(t)) + if vlen > 1 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1), "AttesterSlashings") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(AttesterSlashing) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPathf(err, "AttesterSlashings[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(1, vlen, 32)) + } + { // Field #5 'Attestations' + t := t.Attestations + vlen := uint64(len(t)) + if vlen > 8 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 8), "Attestations") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(Attestation) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPathf(err, "Attestations[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(8, vlen, 32)) + } + { // Field #6 'Deposits' + t := t.Deposits + vlen := uint64(len(t)) + if vlen > 16 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16), "Deposits") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(generic.Deposit) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPathf(err, "Deposits[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(16, vlen, 32)) + } + { // Field #7 'VoluntaryExits' + t := t.VoluntaryExits + vlen := uint64(len(t)) + if vlen > 16 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16), "VoluntaryExits") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(generic.SignedVoluntaryExit) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPathf(err, "VoluntaryExits[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(16, vlen, 32)) + } + { // Field #8 'SyncAggregate' + t := t.SyncAggregate + if t == nil { + t = new(generic.SyncAggregate) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPath(err, "SyncAggregate") + } + } + { // Field #9 'ExecutionPayload' + t := t.ExecutionPayload + if t == nil { + t = new(generic.ExecutionPayload) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPath(err, "ExecutionPayload") + } + } + { // Field #10 'BlsToExecutionChanges' + t := t.BlsToExecutionChanges + vlen := uint64(len(t)) + if vlen > 16 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16), "BlsToExecutionChanges") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(generic.SignedBLSToExecutionChange) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPathf(err, "BlsToExecutionChanges[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(16, vlen, 32)) + } + { // Field #11 'BlobKzgCommitments' + t := t.BlobKzgCommitments + vlen := uint64(len(t)) + if vlen > 4096 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 4096), "BlobKzgCommitments") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + hh.PutBytes(t[idx1][:48]) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(4096, vlen, 32)) + } + { // Field #12 'ExecutionRequests' + t := t.ExecutionRequests + if t == nil { + t = new(ExecutionRequests) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPath(err, "ExecutionRequests") + } + } + hh.Merkleize(idx) + return nil +} + +// MarshalSSZDyn marshals the *Attestation to SSZ-encoded bytes using dynamic specifications. +func (t *Attestation) MarshalSSZDyn(ds sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + dst = buf + if t == nil { + t = new(Attestation) + } + dstlen := len(dst) + // Offset Field #0 'AggregationBits' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #1 'Data' + t := t.Data + if t == nil { + t = new(generic.AttestationData) + } + if dst, err = t.MarshalSSZDyn(ds, dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "Data") + } + } + { // Static Field #2 'Signature' + dst = append(dst, t.Signature[:96]...) + } + { // Static Field #3 'CommitteeBits' + vlen := len(t.CommitteeBits) + if vlen > 8 { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 8), "CommitteeBits") + } + dst = append(dst, t.CommitteeBits[:vlen]...) + if vlen < 8 { + dst = sszutils.AppendZeroPadding(dst, (8-vlen)*1) + } + } + { // Dynamic Field #0 'AggregationBits' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.AggregationBits + vlen := len(t) + bval := []byte(t[:]) + if vlen == 0 { + bval = []byte{0x01} + } else if bval[vlen-1] == 0x00 { + return nil, sszutils.ErrorWithPath(sszutils.ErrBitlistNotTerminatedFn(), "AggregationBits") + } + if vlen > 0 { + bitCount := 8*(vlen-1) + bits.Len8(bval[vlen-1]) - 1 + if bitCount > 131072 { + return nil, sszutils.ErrorWithPath(sszutils.ErrBitlistLengthFn(bitCount, 131072), "AggregationBits") + } + } + dst = append(dst, bval...) + } + return dst, nil +} + +// MarshalSSZEncoder marshals the *Attestation to the given SSZ encoder using dynamic specifications. +func (t *Attestation) MarshalSSZEncoder(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + type encoderCtx struct { + ds sszutils.DynamicSpecs + exprs [0]uint64 + sizeFn1 func(ctx *encoderCtx, t go_bitfield.Bitlist) (size int) + } + ctx := &encoderCtx{ds: ds} + canSeek := enc.Seekable() + // size for go_bitfield.Bitlist + ctx.sizeFn1 = func(ctx *encoderCtx, t go_bitfield.Bitlist) (size int) { + if len(t) == 0 { + size += 1 + } else { + size += len(t) + } + return size + } + if t == nil { + t = new(Attestation) + } + dstlen := enc.GetPosition() + dynoff := uint32(236) + // Offset #0 'AggregationBits' + offset0 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn1(ctx, t.AggregationBits)) + } + { // Field #1 'Data' + t := t.Data + if t == nil { + t = new(generic.AttestationData) + } + if err = t.MarshalSSZEncoder(ds, enc); err != nil { + return sszutils.ErrorWithPath(err, "Data") + } + } + { // Field #2 'Signature' + enc.EncodeBytes(t.Signature[:96]) + } + { // Field #3 'CommitteeBits' + vlen := len(t.CommitteeBits) + if vlen > 8 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 8), "CommitteeBits") + } + enc.EncodeBytes(t.CommitteeBits[:vlen]) + if vlen < 8 { + enc.EncodeZeroPadding((8 - vlen) * 1) + } + } + { // Dynamic Field #0 'AggregationBits' + if canSeek { + enc.EncodeOffsetAt(offset0, uint32(enc.GetPosition()-dstlen)) + } + t := t.AggregationBits + vlen := len(t) + bval := []byte(t[:]) + if vlen == 0 { + bval = []byte{0x01} + } else if bval[vlen-1] == 0x00 { + return sszutils.ErrorWithPath(sszutils.ErrBitlistNotTerminatedFn(), "AggregationBits") + } + if vlen > 0 { + bitCount := 8*(vlen-1) + bits.Len8(bval[vlen-1]) - 1 + if bitCount > 131072 { + return sszutils.ErrorWithPath(sszutils.ErrBitlistLengthFn(bitCount, 131072), "AggregationBits") + } + } + enc.EncodeBytes(bval) + } + return nil +} + +// UnmarshalSSZDyn unmarshals the *Attestation from SSZ-encoded bytes using dynamic specifications. +func (t *Attestation) UnmarshalSSZDyn(ds sszutils.DynamicSpecs, buf []byte) (err error) { + buflen := len(buf) + if buflen < 236 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 236) + } + // Field #0 'AggregationBits' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 236 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset0, 236), "AggregationBits:o") + } + { // Field #1 'Data' (static) + buf := buf[4:132] + if t.Data == nil { + t.Data = new(generic.AttestationData) + } + if err = t.Data.UnmarshalSSZDyn(ds, buf); err != nil { + return sszutils.ErrorWithPath(err, "Data") + } + } + { // Field #2 'Signature' (static) + buf := buf[132:228] + copy(t.Signature[:], buf) + } + { // Field #3 'CommitteeBits' (static) + buf := buf[228:236] + t.CommitteeBits = sszutils.ExpandSlice(t.CommitteeBits, 8) + copy(t.CommitteeBits[:], buf) + } + { // Field #0 'AggregationBits' (dynamic) + buf := buf[offset0:] + val1 := t.AggregationBits + blen := len(buf) + if blen == 0 || buf[blen-1] == 0x00 { + return sszutils.ErrorWithPath(sszutils.ErrBitlistNotTerminatedFn(), "AggregationBits") + } + bitCount := 8*(blen-1) + int(bits.Len8(buf[blen-1])) - 1 + if bitCount > 131072 { + return sszutils.ErrorWithPath(sszutils.ErrBitlistLengthFn(bitCount, 131072), "AggregationBits") + } + val1 = sszutils.ExpandSlice(val1, blen) + copy(val1[:], buf) + t.AggregationBits = val1 + } + return nil +} + +// UnmarshalSSZDecoder unmarshals the *Attestation from the given SSZ decoder using dynamic specifications. +func (t *Attestation) UnmarshalSSZDecoder(ds sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { + maxOffset := uint32(dec.GetLength()) + startPos0 := dec.GetPosition() + if maxOffset < uint32(236) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(236)) + } + // Field #0 'AggregationBits' (offset) + offset0, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "AggregationBits") + } + if offset0 != uint32(236) { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset0, 236), "AggregationBits") + } + // Field #1 'Data' (static) + if t.Data == nil { + t.Data = new(generic.AttestationData) + } + if err = t.Data.UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPath(err, "Data") + } + // Field #2 'Signature' (static) + if _, err = dec.DecodeBytes(t.Signature[:96]); err != nil { + return err + } + // Field #3 'CommitteeBits' (static) + t.CommitteeBits = sszutils.ExpandSlice(t.CommitteeBits, 8) + if _, err = dec.DecodeBytes(t.CommitteeBits[:8]); err != nil { + return err + } + { // Field #0 'AggregationBits' (dynamic) + if dec.GetPosition() != startPos0+int(offset0) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset0)), "AggregationBits") + } + dec.PushLimit(int(maxOffset - offset0)) + val1 := t.AggregationBits + blen := dec.GetLength() + val1 = sszutils.ExpandSlice(val1, blen) + if _, err = dec.DecodeBytes(val1[:blen]); err != nil { + return sszutils.ErrorWithPath(err, "AggregationBits") + } + if blen == 0 || val1[blen-1] == 0x00 { + return sszutils.ErrorWithPath(sszutils.ErrBitlistNotTerminatedFn(), "AggregationBits") + } + bitCount := 8*(blen-1) + int(bits.Len8(val1[blen-1])) - 1 + if bitCount > 131072 { + return sszutils.ErrorWithPath(sszutils.ErrBitlistLengthFn(bitCount, 131072), "AggregationBits") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "AggregationBits") + } + t.AggregationBits = val1 + } + return nil +} + +// SizeSSZ returns the SSZ encoded size of the *Attestation. +func (t *Attestation) SizeSSZ() (size int) { + if t == nil { + t = new(Attestation) + } + // Field #0 'AggregationBits' offset (4 bytes) + // Field #1 'Data' static (128 bytes) + // Field #2 'Signature' static (96 bytes) + // Field #3 'CommitteeBits' static (8 bytes) + size += 236 + { // Dynamic field #0 'AggregationBits' + if len(t.AggregationBits) == 0 { + size += 1 + } else { + size += len(t.AggregationBits) + } + } + return size +} + +// SizeSSZDyn returns the SSZ encoded size of the *Attestation using dynamic specifications. +func (t *Attestation) SizeSSZDyn(_ sszutils.DynamicSpecs) (size int) { + return t.SizeSSZ() +} + +// HashTreeRootDyn computes the SSZ hash tree root of the *Attestation using dynamic specifications. +func (t *Attestation) HashTreeRootDyn(ds sszutils.DynamicSpecs) (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWithDyn(ds, hh) + if err == nil { + root, err = hh.HashRoot() + } + return + }) + return +} + +// HashTreeRootWithDyn computes the SSZ hash tree root of the *Attestation using dynamic specifications and the given hash walker. +func (t *Attestation) HashTreeRootWithDyn(ds sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + if t == nil { + t = new(Attestation) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'AggregationBits' + t := t.AggregationBits + if l := len(t); l > 0 && t[l-1] == 0x00 { + return sszutils.ErrorWithPath(sszutils.ErrBitlistNotTerminatedFn(), "AggregationBits") + } + idx := hh.StartTree(sszutils.TreeTypeNone) + bitlist, size := hasher.ParseBitlistWithHasher(hh, t[:]) + if size > 131072 { + return sszutils.ErrorWithPath(sszutils.ErrBitlistLengthFn(size, 131072), "AggregationBits") + } + hh.AppendBytes32(bitlist) + hh.MerkleizeWithMixin(idx, size, sszutils.CalculateBitlistLimit(131072)) + } + { // Field #1 'Data' + t := t.Data + if t == nil { + t = new(generic.AttestationData) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPath(err, "Data") + } + } + { // Field #2 'Signature' + hh.PutBytes(t.Signature[:96]) + } + { // Field #3 'CommitteeBits' + vlen := len(t.CommitteeBits) + if vlen > 8 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 8), "CommitteeBits") + } + val := t.CommitteeBits[:] + if vlen < 8 { + val = sszutils.AppendZeroPadding(val, (8-vlen)*1) + } + hh.PutBytes(val[:8]) + } + hh.Merkleize(idx) + return nil +} + +// MarshalSSZDyn marshals the *ExecutionRequests to SSZ-encoded bytes using dynamic specifications. +func (t *ExecutionRequests) MarshalSSZDyn(ds sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + dst = buf + zeroBytes := sszutils.ZeroBytes() + if t == nil { + t = new(ExecutionRequests) + } + dstlen := len(dst) + // Offset Field #0 'Deposits' + // Offset Field #1 'Withdrawals' + // Offset Field #2 'Consolidations' + dst = append(dst, zeroBytes[:12]...) + { // Dynamic Field #0 'Deposits' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.Deposits + vlen := len(t) + if vlen > 8192 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 8192), "Deposits") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(DepositRequest) + } + if dst, err = t.MarshalSSZDyn(ds, dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "Deposits[%d]", idx1) + } + } + } + { // Dynamic Field #1 'Withdrawals' + binary.LittleEndian.PutUint32(dst[dstlen+4:], uint32(len(dst)-dstlen)) + t := t.Withdrawals + vlen := len(t) + if vlen > 16 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16), "Withdrawals") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(WithdrawalRequest) + } + if dst, err = t.MarshalSSZDyn(ds, dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "Withdrawals[%d]", idx1) + } + } + } + { // Dynamic Field #2 'Consolidations' + binary.LittleEndian.PutUint32(dst[dstlen+8:], uint32(len(dst)-dstlen)) + t := t.Consolidations + vlen := len(t) + if vlen > 2 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 2), "Consolidations") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(ConsolidationRequest) + } + if dst, err = t.MarshalSSZDyn(ds, dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "Consolidations[%d]", idx1) + } + } + } + return dst, nil +} + +// MarshalSSZEncoder marshals the *ExecutionRequests to the given SSZ encoder using dynamic specifications. +func (t *ExecutionRequests) MarshalSSZEncoder(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + type encoderCtx struct { + ds sszutils.DynamicSpecs + exprs [0]uint64 + sizeFn1 func(ctx *encoderCtx, t []*DepositRequest) (size int) + sizeFn2 func(ctx *encoderCtx, t []*WithdrawalRequest) (size int) + sizeFn3 func(ctx *encoderCtx, t []*ConsolidationRequest) (size int) + } + ctx := &encoderCtx{ds: ds} + canSeek := enc.Seekable() + // size for []*DepositRequest + ctx.sizeFn1 = func(ctx *encoderCtx, t []*DepositRequest) (size int) { + size += len(t) * 192 + return size + } + // size for []*WithdrawalRequest + ctx.sizeFn2 = func(ctx *encoderCtx, t []*WithdrawalRequest) (size int) { + size += len(t) * 76 + return size + } + // size for []*ConsolidationRequest + ctx.sizeFn3 = func(ctx *encoderCtx, t []*ConsolidationRequest) (size int) { + size += len(t) * 116 + return size + } + if t == nil { + t = new(ExecutionRequests) + } + dstlen := enc.GetPosition() + dynoff := uint32(12) + // Offset #0 'Deposits' + offset0 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn1(ctx, t.Deposits)) + } + // Offset #1 'Withdrawals' + offset1 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn2(ctx, t.Withdrawals)) + } + // Offset #2 'Consolidations' + offset2 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn3(ctx, t.Consolidations)) + } + { // Dynamic Field #0 'Deposits' + if canSeek { + enc.EncodeOffsetAt(offset0, uint32(enc.GetPosition()-dstlen)) + } + t := t.Deposits + vlen := len(t) + if vlen > 8192 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 8192), "Deposits") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(DepositRequest) + } + if err = t.MarshalSSZEncoder(ds, enc); err != nil { + return sszutils.ErrorWithPathf(err, "Deposits[%d]", idx1) + } + } + } + { // Dynamic Field #1 'Withdrawals' + if canSeek { + enc.EncodeOffsetAt(offset1, uint32(enc.GetPosition()-dstlen)) + } + t := t.Withdrawals + vlen := len(t) + if vlen > 16 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16), "Withdrawals") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(WithdrawalRequest) + } + if err = t.MarshalSSZEncoder(ds, enc); err != nil { + return sszutils.ErrorWithPathf(err, "Withdrawals[%d]", idx1) + } + } + } + { // Dynamic Field #2 'Consolidations' + if canSeek { + enc.EncodeOffsetAt(offset2, uint32(enc.GetPosition()-dstlen)) + } + t := t.Consolidations + vlen := len(t) + if vlen > 2 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 2), "Consolidations") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(ConsolidationRequest) + } + if err = t.MarshalSSZEncoder(ds, enc); err != nil { + return sszutils.ErrorWithPathf(err, "Consolidations[%d]", idx1) + } + } + } + return nil +} + +// UnmarshalSSZDyn unmarshals the *ExecutionRequests from SSZ-encoded bytes using dynamic specifications. +func (t *ExecutionRequests) UnmarshalSSZDyn(ds sszutils.DynamicSpecs, buf []byte) (err error) { + buflen := len(buf) + if buflen < 12 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 12) + } + // Field #0 'Deposits' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 12 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset0, 12), "Deposits:o") + } + // Field #1 'Withdrawals' (offset) + offset1 := int(binary.LittleEndian.Uint32(buf[4:8])) + if offset1 < offset0 || offset1 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset1, offset0, buflen), "Withdrawals:o") + } + // Field #2 'Consolidations' (offset) + offset2 := int(binary.LittleEndian.Uint32(buf[8:12])) + if offset2 < offset1 || offset2 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset2, offset1, buflen), "Consolidations:o") + } + { // Field #0 'Deposits' (dynamic) + buf := buf[offset0:offset1] + val1 := t.Deposits + itemCount := len(buf) / 192 + if len(buf)%192 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 192), "Deposits") + } + if itemCount > 8192 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 8192), "Deposits") + } + val1 = sszutils.ExpandSlice(val1, itemCount) + for idx1 := range itemCount { + if val1[idx1] == nil { + val1[idx1] = new(DepositRequest) + } + buf := buf[192*idx1 : 192*(idx1+1)] + if err = val1[idx1].UnmarshalSSZDyn(ds, buf); err != nil { + return sszutils.ErrorWithPathf(err, "Deposits[%d]", idx1) + } + } + t.Deposits = val1 + } + { // Field #1 'Withdrawals' (dynamic) + buf := buf[offset1:offset2] + val2 := t.Withdrawals + itemCount := len(buf) / 76 + if len(buf)%76 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 76), "Withdrawals") + } + if itemCount > 16 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 16), "Withdrawals") + } + val2 = sszutils.ExpandSlice(val2, itemCount) + for idx1 := range itemCount { + if val2[idx1] == nil { + val2[idx1] = new(WithdrawalRequest) + } + buf := buf[76*idx1 : 76*(idx1+1)] + if err = val2[idx1].UnmarshalSSZDyn(ds, buf); err != nil { + return sszutils.ErrorWithPathf(err, "Withdrawals[%d]", idx1) + } + } + t.Withdrawals = val2 + } + { // Field #2 'Consolidations' (dynamic) + buf := buf[offset2:] + val3 := t.Consolidations + itemCount := len(buf) / 116 + if len(buf)%116 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 116), "Consolidations") + } + if itemCount > 2 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 2), "Consolidations") + } + val3 = sszutils.ExpandSlice(val3, itemCount) + for idx1 := range itemCount { + if val3[idx1] == nil { + val3[idx1] = new(ConsolidationRequest) + } + buf := buf[116*idx1 : 116*(idx1+1)] + if err = val3[idx1].UnmarshalSSZDyn(ds, buf); err != nil { + return sszutils.ErrorWithPathf(err, "Consolidations[%d]", idx1) + } + } + t.Consolidations = val3 + } + return nil +} + +// UnmarshalSSZDecoder unmarshals the *ExecutionRequests from the given SSZ decoder using dynamic specifications. +func (t *ExecutionRequests) UnmarshalSSZDecoder(ds sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { + maxOffset := uint32(dec.GetLength()) + startPos0 := dec.GetPosition() + if maxOffset < uint32(12) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(12)) + } + // Field #0 'Deposits' (offset) + offset0, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Deposits") + } + if offset0 != uint32(12) { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset0, 12), "Deposits") + } + // Field #1 'Withdrawals' (offset) + offset1, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Withdrawals") + } + if offset1 < offset0 || offset1 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset1, offset0, maxOffset), "Withdrawals") + } + // Field #2 'Consolidations' (offset) + offset2, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Consolidations") + } + if offset2 < offset1 || offset2 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset2, offset1, maxOffset), "Consolidations") + } + { // Field #0 'Deposits' (dynamic) + if dec.GetPosition() != startPos0+int(offset0) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset0)), "Deposits") + } + dec.PushLimit(int(offset1 - offset0)) + val1 := t.Deposits + sszLen := dec.GetLength() + itemCount := sszLen / 192 + if sszLen%192 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 192), "Deposits") + } + if itemCount > 8192 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 8192), "Deposits") + } + val1 = sszutils.ExpandSlice(val1, itemCount) + startPos1 := dec.GetPosition() + for idx1 := range itemCount { + if val1[idx1] == nil { + val1[idx1] = new(DepositRequest) + } + if err = val1[idx1].UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPathf(err, "Deposits[%d]", idx1) + } + if dec.GetPosition() != startPos1+int(192*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos1+int(192*(idx1+1))), "Deposits[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Deposits") + } + t.Deposits = val1 + } + { // Field #1 'Withdrawals' (dynamic) + if dec.GetPosition() != startPos0+int(offset1) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset1)), "Withdrawals") + } + dec.PushLimit(int(offset2 - offset1)) + val2 := t.Withdrawals + sszLen := dec.GetLength() + itemCount := sszLen / 76 + if sszLen%76 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 76), "Withdrawals") + } + if itemCount > 16 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 16), "Withdrawals") + } + val2 = sszutils.ExpandSlice(val2, itemCount) + startPos2 := dec.GetPosition() + for idx1 := range itemCount { + if val2[idx1] == nil { + val2[idx1] = new(WithdrawalRequest) + } + if err = val2[idx1].UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPathf(err, "Withdrawals[%d]", idx1) + } + if dec.GetPosition() != startPos2+int(76*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos2+int(76*(idx1+1))), "Withdrawals[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Withdrawals") + } + t.Withdrawals = val2 + } + { // Field #2 'Consolidations' (dynamic) + if dec.GetPosition() != startPos0+int(offset2) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset2)), "Consolidations") + } + dec.PushLimit(int(maxOffset - offset2)) + val3 := t.Consolidations + sszLen := dec.GetLength() + itemCount := sszLen / 116 + if sszLen%116 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 116), "Consolidations") + } + if itemCount > 2 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 2), "Consolidations") + } + val3 = sszutils.ExpandSlice(val3, itemCount) + startPos3 := dec.GetPosition() + for idx1 := range itemCount { + if val3[idx1] == nil { + val3[idx1] = new(ConsolidationRequest) + } + if err = val3[idx1].UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPathf(err, "Consolidations[%d]", idx1) + } + if dec.GetPosition() != startPos3+int(116*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos3+int(116*(idx1+1))), "Consolidations[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Consolidations") + } + t.Consolidations = val3 + } + return nil +} + +// SizeSSZ returns the SSZ encoded size of the *ExecutionRequests. +func (t *ExecutionRequests) SizeSSZ() (size int) { + if t == nil { + t = new(ExecutionRequests) + } + // Field #0 'Deposits' offset (4 bytes) + // Field #1 'Withdrawals' offset (4 bytes) + // Field #2 'Consolidations' offset (4 bytes) + size += 12 + { // Dynamic field #0 'Deposits' + size += len(t.Deposits) * 192 + } + { // Dynamic field #1 'Withdrawals' + size += len(t.Withdrawals) * 76 + } + { // Dynamic field #2 'Consolidations' + size += len(t.Consolidations) * 116 + } + return size +} + +// SizeSSZDyn returns the SSZ encoded size of the *ExecutionRequests using dynamic specifications. +func (t *ExecutionRequests) SizeSSZDyn(_ sszutils.DynamicSpecs) (size int) { + return t.SizeSSZ() +} + +// HashTreeRootDyn computes the SSZ hash tree root of the *ExecutionRequests using dynamic specifications. +func (t *ExecutionRequests) HashTreeRootDyn(ds sszutils.DynamicSpecs) (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWithDyn(ds, hh) + if err == nil { + root, err = hh.HashRoot() + } + return + }) + return +} + +// HashTreeRootWithDyn computes the SSZ hash tree root of the *ExecutionRequests using dynamic specifications and the given hash walker. +func (t *ExecutionRequests) HashTreeRootWithDyn(ds sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + if t == nil { + t = new(ExecutionRequests) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Deposits' + t := t.Deposits + vlen := uint64(len(t)) + if vlen > 8192 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 8192), "Deposits") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(DepositRequest) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPathf(err, "Deposits[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(8192, vlen, 32)) + } + { // Field #1 'Withdrawals' + t := t.Withdrawals + vlen := uint64(len(t)) + if vlen > 16 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16), "Withdrawals") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(WithdrawalRequest) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPathf(err, "Withdrawals[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(16, vlen, 32)) + } + { // Field #2 'Consolidations' + t := t.Consolidations + vlen := uint64(len(t)) + if vlen > 2 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 2), "Consolidations") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(ConsolidationRequest) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPathf(err, "Consolidations[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(2, vlen, 32)) + } + hh.Merkleize(idx) + return nil +} + +// MarshalSSZTo marshals the *DepositRequest to SSZ-encoded bytes, appending to the provided buffer. +func (t *DepositRequest) MarshalSSZTo(buf []byte) (dst []byte, err error) { + dst = buf + if t == nil { + t = new(DepositRequest) + } + { // Static Field #0 'Pubkey' + vlen := len(t.Pubkey) + if vlen > 48 { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 48), "Pubkey") + } + dst = append(dst, t.Pubkey[:vlen]...) + if vlen < 48 { + dst = sszutils.AppendZeroPadding(dst, (48-vlen)*1) + } + } + { // Static Field #1 'WithdrawalCredentials' + vlen := len(t.WithdrawalCredentials) + if vlen > 32 { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 32), "WithdrawalCredentials") + } + dst = append(dst, t.WithdrawalCredentials[:vlen]...) + if vlen < 32 { + dst = sszutils.AppendZeroPadding(dst, (32-vlen)*1) + } + } + { // Static Field #2 'Amount' + dst = binary.LittleEndian.AppendUint64(dst, t.Amount) + } + { // Static Field #3 'Signature' + vlen := len(t.Signature) + if vlen > 96 { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 96), "Signature") + } + dst = append(dst, t.Signature[:vlen]...) + if vlen < 96 { + dst = sszutils.AppendZeroPadding(dst, (96-vlen)*1) + } + } + { // Static Field #4 'Index' + dst = binary.LittleEndian.AppendUint64(dst, t.Index) + } + return dst, nil +} + +// MarshalSSZDyn marshals the *DepositRequest to SSZ-encoded bytes using dynamic specifications. +func (t *DepositRequest) MarshalSSZDyn(_ sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + return t.MarshalSSZTo(buf) +} + +// MarshalSSZEncoder marshals the *DepositRequest to the given SSZ encoder using dynamic specifications. +func (t *DepositRequest) MarshalSSZEncoder(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + if t == nil { + t = new(DepositRequest) + } + { // Field #0 'Pubkey' + vlen := len(t.Pubkey) + if vlen > 48 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 48), "Pubkey") + } + enc.EncodeBytes(t.Pubkey[:vlen]) + if vlen < 48 { + enc.EncodeZeroPadding((48 - vlen) * 1) + } + } + { // Field #1 'WithdrawalCredentials' + vlen := len(t.WithdrawalCredentials) + if vlen > 32 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 32), "WithdrawalCredentials") + } + enc.EncodeBytes(t.WithdrawalCredentials[:vlen]) + if vlen < 32 { + enc.EncodeZeroPadding((32 - vlen) * 1) + } + } + { // Field #2 'Amount' + enc.EncodeUint64(t.Amount) + } + { // Field #3 'Signature' + vlen := len(t.Signature) + if vlen > 96 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 96), "Signature") + } + enc.EncodeBytes(t.Signature[:vlen]) + if vlen < 96 { + enc.EncodeZeroPadding((96 - vlen) * 1) + } + } + { // Field #4 'Index' + enc.EncodeUint64(t.Index) + } + return nil +} + +// UnmarshalSSZ unmarshals the *DepositRequest from SSZ-encoded bytes. +func (t *DepositRequest) UnmarshalSSZ(buf []byte) (err error) { + buflen := len(buf) + if buflen < 192 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 192) + } + if buflen > 192 { + return sszutils.ErrTrailingDataFn(buflen - 192) + } + { // Field #0 'Pubkey' (static) + buf := buf[0:48] + t.Pubkey = sszutils.ExpandSlice(t.Pubkey, 48) + copy(t.Pubkey[:], buf) + } + { // Field #1 'WithdrawalCredentials' (static) + buf := buf[48:80] + t.WithdrawalCredentials = sszutils.ExpandSlice(t.WithdrawalCredentials, 32) + copy(t.WithdrawalCredentials[:], buf) + } + { // Field #2 'Amount' (static) + buf := buf[80:88] + t.Amount = binary.LittleEndian.Uint64(buf) + } + { // Field #3 'Signature' (static) + buf := buf[88:184] + t.Signature = sszutils.ExpandSlice(t.Signature, 96) + copy(t.Signature[:], buf) + } + { // Field #4 'Index' (static) + buf := buf[184:192] + t.Index = binary.LittleEndian.Uint64(buf) + } + return nil +} + +// UnmarshalSSZDyn unmarshals the *DepositRequest from SSZ-encoded bytes using dynamic specifications. +func (t *DepositRequest) UnmarshalSSZDyn(_ sszutils.DynamicSpecs, buf []byte) (err error) { + return t.UnmarshalSSZ(buf) +} + +// UnmarshalSSZDecoder unmarshals the *DepositRequest from the given SSZ decoder using dynamic specifications. +func (t *DepositRequest) UnmarshalSSZDecoder(_ sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { + maxOffset := uint32(dec.GetLength()) + if maxOffset < uint32(192) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(192)) + } + // Field #0 'Pubkey' (static) + t.Pubkey = sszutils.ExpandSlice(t.Pubkey, 48) + if _, err = dec.DecodeBytes(t.Pubkey[:48]); err != nil { + return err + } + // Field #1 'WithdrawalCredentials' (static) + t.WithdrawalCredentials = sszutils.ExpandSlice(t.WithdrawalCredentials, 32) + if _, err = dec.DecodeBytes(t.WithdrawalCredentials[:32]); err != nil { + return err + } + // Field #2 'Amount' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "Amount") + } else { + t.Amount = val + } + // Field #3 'Signature' (static) + t.Signature = sszutils.ExpandSlice(t.Signature, 96) + if _, err = dec.DecodeBytes(t.Signature[:96]); err != nil { + return err + } + // Field #4 'Index' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "Index") + } else { + t.Index = val + } + return nil +} + +// SizeSSZ returns the SSZ encoded size of the *DepositRequest. +func (t *DepositRequest) SizeSSZ() (size int) { + return 192 +} + +// SizeSSZDyn returns the SSZ encoded size of the *DepositRequest using dynamic specifications. +func (t *DepositRequest) SizeSSZDyn(_ sszutils.DynamicSpecs) (size int) { + return t.SizeSSZ() +} + +// HashTreeRoot computes the SSZ hash tree root of the *DepositRequest. +func (t *DepositRequest) 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 *DepositRequest using the given hash walker. +func (t *DepositRequest) HashTreeRootWith(hh sszutils.HashWalker) error { + if t == nil { + t = new(DepositRequest) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Pubkey' + vlen := len(t.Pubkey) + if vlen > 48 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 48), "Pubkey") + } + val := t.Pubkey[:] + if vlen < 48 { + val = sszutils.AppendZeroPadding(val, (48-vlen)*1) + } + hh.PutBytes(val[:48]) + } + { // Field #1 'WithdrawalCredentials' + vlen := len(t.WithdrawalCredentials) + if vlen > 32 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 32), "WithdrawalCredentials") + } + val := t.WithdrawalCredentials[:] + if vlen < 32 { + val = sszutils.AppendZeroPadding(val, (32-vlen)*1) + } + hh.PutBytes(val[:32]) + } + { // Field #2 'Amount' + hh.PutUint64(t.Amount) + } + { // Field #3 'Signature' + vlen := len(t.Signature) + if vlen > 96 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 96), "Signature") + } + val := t.Signature[:] + if vlen < 96 { + val = sszutils.AppendZeroPadding(val, (96-vlen)*1) + } + hh.PutBytes(val[:96]) + } + { // Field #4 'Index' + hh.PutUint64(t.Index) + } + hh.Merkleize(idx) + return nil +} + +// HashTreeRootDyn computes the SSZ hash tree root of the *DepositRequest using dynamic specifications. +func (t *DepositRequest) HashTreeRootDyn(ds sszutils.DynamicSpecs) (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWithDyn(ds, hh) + if err == nil { + root, err = hh.HashRoot() + } + return + }) + return +} + +// HashTreeRootWithDyn computes the SSZ hash tree root of the *DepositRequest using dynamic specifications and the given hash walker. +func (t *DepositRequest) HashTreeRootWithDyn(_ sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + return t.HashTreeRootWith(hh) +} + +// MarshalSSZTo marshals the *WithdrawalRequest to SSZ-encoded bytes, appending to the provided buffer. +func (t *WithdrawalRequest) MarshalSSZTo(buf []byte) (dst []byte, err error) { + dst = buf + if t == nil { + t = new(WithdrawalRequest) + } + { // Static Field #0 'SourceAddress' + vlen := len(t.SourceAddress) + if vlen > 20 { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 20), "SourceAddress") + } + dst = append(dst, t.SourceAddress[:vlen]...) + if vlen < 20 { + dst = sszutils.AppendZeroPadding(dst, (20-vlen)*1) + } + } + { // Static Field #1 'ValidatorPubkey' + vlen := len(t.ValidatorPubkey) + if vlen > 48 { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 48), "ValidatorPubkey") + } + dst = append(dst, t.ValidatorPubkey[:vlen]...) + if vlen < 48 { + dst = sszutils.AppendZeroPadding(dst, (48-vlen)*1) + } + } + { // Static Field #2 'Amount' + dst = binary.LittleEndian.AppendUint64(dst, t.Amount) + } + return dst, nil +} + +// MarshalSSZDyn marshals the *WithdrawalRequest to SSZ-encoded bytes using dynamic specifications. +func (t *WithdrawalRequest) MarshalSSZDyn(_ sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + return t.MarshalSSZTo(buf) +} + +// MarshalSSZEncoder marshals the *WithdrawalRequest to the given SSZ encoder using dynamic specifications. +func (t *WithdrawalRequest) MarshalSSZEncoder(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + if t == nil { + t = new(WithdrawalRequest) + } + { // Field #0 'SourceAddress' + vlen := len(t.SourceAddress) + if vlen > 20 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 20), "SourceAddress") + } + enc.EncodeBytes(t.SourceAddress[:vlen]) + if vlen < 20 { + enc.EncodeZeroPadding((20 - vlen) * 1) + } + } + { // Field #1 'ValidatorPubkey' + vlen := len(t.ValidatorPubkey) + if vlen > 48 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 48), "ValidatorPubkey") + } + enc.EncodeBytes(t.ValidatorPubkey[:vlen]) + if vlen < 48 { + enc.EncodeZeroPadding((48 - vlen) * 1) + } + } + { // Field #2 'Amount' + enc.EncodeUint64(t.Amount) + } + return nil +} + +// UnmarshalSSZ unmarshals the *WithdrawalRequest from SSZ-encoded bytes. +func (t *WithdrawalRequest) UnmarshalSSZ(buf []byte) (err error) { + buflen := len(buf) + if buflen < 76 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 76) + } + if buflen > 76 { + return sszutils.ErrTrailingDataFn(buflen - 76) + } + { // Field #0 'SourceAddress' (static) + buf := buf[0:20] + t.SourceAddress = sszutils.ExpandSlice(t.SourceAddress, 20) + copy(t.SourceAddress[:], buf) + } + { // Field #1 'ValidatorPubkey' (static) + buf := buf[20:68] + t.ValidatorPubkey = sszutils.ExpandSlice(t.ValidatorPubkey, 48) + copy(t.ValidatorPubkey[:], buf) + } + { // Field #2 'Amount' (static) + buf := buf[68:76] + t.Amount = binary.LittleEndian.Uint64(buf) + } + return nil +} + +// UnmarshalSSZDyn unmarshals the *WithdrawalRequest from SSZ-encoded bytes using dynamic specifications. +func (t *WithdrawalRequest) UnmarshalSSZDyn(_ sszutils.DynamicSpecs, buf []byte) (err error) { + return t.UnmarshalSSZ(buf) +} + +// UnmarshalSSZDecoder unmarshals the *WithdrawalRequest from the given SSZ decoder using dynamic specifications. +func (t *WithdrawalRequest) UnmarshalSSZDecoder(_ sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { + maxOffset := uint32(dec.GetLength()) + if maxOffset < uint32(76) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(76)) + } + // Field #0 'SourceAddress' (static) + t.SourceAddress = sszutils.ExpandSlice(t.SourceAddress, 20) + if _, err = dec.DecodeBytes(t.SourceAddress[:20]); err != nil { + return err + } + // Field #1 'ValidatorPubkey' (static) + t.ValidatorPubkey = sszutils.ExpandSlice(t.ValidatorPubkey, 48) + if _, err = dec.DecodeBytes(t.ValidatorPubkey[:48]); err != nil { + return err + } + // Field #2 'Amount' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "Amount") + } else { + t.Amount = val + } + return nil +} + +// SizeSSZ returns the SSZ encoded size of the *WithdrawalRequest. +func (t *WithdrawalRequest) SizeSSZ() (size int) { + return 76 +} + +// SizeSSZDyn returns the SSZ encoded size of the *WithdrawalRequest using dynamic specifications. +func (t *WithdrawalRequest) SizeSSZDyn(_ sszutils.DynamicSpecs) (size int) { + return t.SizeSSZ() +} + +// HashTreeRoot computes the SSZ hash tree root of the *WithdrawalRequest. +func (t *WithdrawalRequest) 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 *WithdrawalRequest using the given hash walker. +func (t *WithdrawalRequest) HashTreeRootWith(hh sszutils.HashWalker) error { + if t == nil { + t = new(WithdrawalRequest) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'SourceAddress' + vlen := len(t.SourceAddress) + if vlen > 20 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 20), "SourceAddress") + } + val := t.SourceAddress[:] + if vlen < 20 { + val = sszutils.AppendZeroPadding(val, (20-vlen)*1) + } + hh.PutBytes(val[:20]) + } + { // Field #1 'ValidatorPubkey' + vlen := len(t.ValidatorPubkey) + if vlen > 48 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 48), "ValidatorPubkey") + } + val := t.ValidatorPubkey[:] + if vlen < 48 { + val = sszutils.AppendZeroPadding(val, (48-vlen)*1) + } + hh.PutBytes(val[:48]) + } + { // Field #2 'Amount' + hh.PutUint64(t.Amount) + } + hh.Merkleize(idx) + return nil +} + +// HashTreeRootDyn computes the SSZ hash tree root of the *WithdrawalRequest using dynamic specifications. +func (t *WithdrawalRequest) HashTreeRootDyn(ds sszutils.DynamicSpecs) (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWithDyn(ds, hh) + if err == nil { + root, err = hh.HashRoot() + } + return + }) + return +} + +// HashTreeRootWithDyn computes the SSZ hash tree root of the *WithdrawalRequest using dynamic specifications and the given hash walker. +func (t *WithdrawalRequest) HashTreeRootWithDyn(_ sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + return t.HashTreeRootWith(hh) +} + +// MarshalSSZTo marshals the *ConsolidationRequest to SSZ-encoded bytes, appending to the provided buffer. +func (t *ConsolidationRequest) MarshalSSZTo(buf []byte) (dst []byte, err error) { + dst = buf + if t == nil { + t = new(ConsolidationRequest) + } + { // Static Field #0 'SourceAddress' + vlen := len(t.SourceAddress) + if vlen > 20 { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 20), "SourceAddress") + } + dst = append(dst, t.SourceAddress[:vlen]...) + if vlen < 20 { + dst = sszutils.AppendZeroPadding(dst, (20-vlen)*1) + } + } + { // Static Field #1 'SourcePubkey' + vlen := len(t.SourcePubkey) + if vlen > 48 { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 48), "SourcePubkey") + } + dst = append(dst, t.SourcePubkey[:vlen]...) + if vlen < 48 { + dst = sszutils.AppendZeroPadding(dst, (48-vlen)*1) + } + } + { // Static Field #2 'TargetPubkey' + vlen := len(t.TargetPubkey) + if vlen > 48 { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 48), "TargetPubkey") + } + dst = append(dst, t.TargetPubkey[:vlen]...) + if vlen < 48 { + dst = sszutils.AppendZeroPadding(dst, (48-vlen)*1) + } + } + return dst, nil +} + +// MarshalSSZDyn marshals the *ConsolidationRequest to SSZ-encoded bytes using dynamic specifications. +func (t *ConsolidationRequest) MarshalSSZDyn(_ sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + return t.MarshalSSZTo(buf) +} + +// MarshalSSZEncoder marshals the *ConsolidationRequest to the given SSZ encoder using dynamic specifications. +func (t *ConsolidationRequest) MarshalSSZEncoder(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + if t == nil { + t = new(ConsolidationRequest) + } + { // Field #0 'SourceAddress' + vlen := len(t.SourceAddress) + if vlen > 20 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 20), "SourceAddress") + } + enc.EncodeBytes(t.SourceAddress[:vlen]) + if vlen < 20 { + enc.EncodeZeroPadding((20 - vlen) * 1) + } + } + { // Field #1 'SourcePubkey' + vlen := len(t.SourcePubkey) + if vlen > 48 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 48), "SourcePubkey") + } + enc.EncodeBytes(t.SourcePubkey[:vlen]) + if vlen < 48 { + enc.EncodeZeroPadding((48 - vlen) * 1) + } + } + { // Field #2 'TargetPubkey' + vlen := len(t.TargetPubkey) + if vlen > 48 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 48), "TargetPubkey") + } + enc.EncodeBytes(t.TargetPubkey[:vlen]) + if vlen < 48 { + enc.EncodeZeroPadding((48 - vlen) * 1) + } + } + return nil +} + +// UnmarshalSSZ unmarshals the *ConsolidationRequest from SSZ-encoded bytes. +func (t *ConsolidationRequest) UnmarshalSSZ(buf []byte) (err error) { + buflen := len(buf) + if buflen < 116 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 116) + } + if buflen > 116 { + return sszutils.ErrTrailingDataFn(buflen - 116) + } + { // Field #0 'SourceAddress' (static) + buf := buf[0:20] + t.SourceAddress = sszutils.ExpandSlice(t.SourceAddress, 20) + copy(t.SourceAddress[:], buf) + } + { // Field #1 'SourcePubkey' (static) + buf := buf[20:68] + t.SourcePubkey = sszutils.ExpandSlice(t.SourcePubkey, 48) + copy(t.SourcePubkey[:], buf) + } + { // Field #2 'TargetPubkey' (static) + buf := buf[68:116] + t.TargetPubkey = sszutils.ExpandSlice(t.TargetPubkey, 48) + copy(t.TargetPubkey[:], buf) + } + return nil +} + +// UnmarshalSSZDyn unmarshals the *ConsolidationRequest from SSZ-encoded bytes using dynamic specifications. +func (t *ConsolidationRequest) UnmarshalSSZDyn(_ sszutils.DynamicSpecs, buf []byte) (err error) { + return t.UnmarshalSSZ(buf) +} + +// UnmarshalSSZDecoder unmarshals the *ConsolidationRequest from the given SSZ decoder using dynamic specifications. +func (t *ConsolidationRequest) UnmarshalSSZDecoder(_ sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { + maxOffset := uint32(dec.GetLength()) + if maxOffset < uint32(116) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(116)) + } + // Field #0 'SourceAddress' (static) + t.SourceAddress = sszutils.ExpandSlice(t.SourceAddress, 20) + if _, err = dec.DecodeBytes(t.SourceAddress[:20]); err != nil { + return err + } + // Field #1 'SourcePubkey' (static) + t.SourcePubkey = sszutils.ExpandSlice(t.SourcePubkey, 48) + if _, err = dec.DecodeBytes(t.SourcePubkey[:48]); err != nil { + return err + } + // Field #2 'TargetPubkey' (static) + t.TargetPubkey = sszutils.ExpandSlice(t.TargetPubkey, 48) + if _, err = dec.DecodeBytes(t.TargetPubkey[:48]); err != nil { + return err + } + return nil +} + +// SizeSSZ returns the SSZ encoded size of the *ConsolidationRequest. +func (t *ConsolidationRequest) SizeSSZ() (size int) { + return 116 +} + +// SizeSSZDyn returns the SSZ encoded size of the *ConsolidationRequest using dynamic specifications. +func (t *ConsolidationRequest) SizeSSZDyn(_ sszutils.DynamicSpecs) (size int) { + return t.SizeSSZ() +} + +// HashTreeRoot computes the SSZ hash tree root of the *ConsolidationRequest. +func (t *ConsolidationRequest) 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 *ConsolidationRequest using the given hash walker. +func (t *ConsolidationRequest) HashTreeRootWith(hh sszutils.HashWalker) error { + if t == nil { + t = new(ConsolidationRequest) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'SourceAddress' + vlen := len(t.SourceAddress) + if vlen > 20 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 20), "SourceAddress") + } + val := t.SourceAddress[:] + if vlen < 20 { + val = sszutils.AppendZeroPadding(val, (20-vlen)*1) + } + hh.PutBytes(val[:20]) + } + { // Field #1 'SourcePubkey' + vlen := len(t.SourcePubkey) + if vlen > 48 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 48), "SourcePubkey") + } + val := t.SourcePubkey[:] + if vlen < 48 { + val = sszutils.AppendZeroPadding(val, (48-vlen)*1) + } + hh.PutBytes(val[:48]) + } + { // Field #2 'TargetPubkey' + vlen := len(t.TargetPubkey) + if vlen > 48 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 48), "TargetPubkey") + } + val := t.TargetPubkey[:] + if vlen < 48 { + val = sszutils.AppendZeroPadding(val, (48-vlen)*1) + } + hh.PutBytes(val[:48]) + } + hh.Merkleize(idx) + return nil +} + +// HashTreeRootDyn computes the SSZ hash tree root of the *ConsolidationRequest using dynamic specifications. +func (t *ConsolidationRequest) HashTreeRootDyn(ds sszutils.DynamicSpecs) (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWithDyn(ds, hh) + if err == nil { + root, err = hh.HashRoot() + } + return + }) + return +} + +// HashTreeRootWithDyn computes the SSZ hash tree root of the *ConsolidationRequest using dynamic specifications and the given hash walker. +func (t *ConsolidationRequest) HashTreeRootWithDyn(_ sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + return t.HashTreeRootWith(hh) +} + +// MarshalSSZDyn marshals the *AttesterSlashing to SSZ-encoded bytes using dynamic specifications. +func (t *AttesterSlashing) MarshalSSZDyn(ds sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + dst = buf + if t == nil { + t = new(AttesterSlashing) + } + dstlen := len(dst) + // Offset Field #0 'Attestation1' + // Offset Field #1 'Attestation2' + dst = append(dst, 0, 0, 0, 0, 0, 0, 0, 0) + { // Dynamic Field #0 'Attestation1' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.Attestation1 + if t == nil { + t = new(IndexedAttestation) + } + if dst, err = t.MarshalSSZDyn(ds, dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "Attestation1") + } + } + { // Dynamic Field #1 'Attestation2' + binary.LittleEndian.PutUint32(dst[dstlen+4:], uint32(len(dst)-dstlen)) + t := t.Attestation2 + if t == nil { + t = new(IndexedAttestation) + } + if dst, err = t.MarshalSSZDyn(ds, dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "Attestation2") + } + } + return dst, nil +} + +// MarshalSSZEncoder marshals the *AttesterSlashing to the given SSZ encoder using dynamic specifications. +func (t *AttesterSlashing) MarshalSSZEncoder(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + type encoderCtx struct { + ds sszutils.DynamicSpecs + exprs [0]uint64 + sizeFn1 func(ctx *encoderCtx, t *IndexedAttestation) (size int) + } + ctx := &encoderCtx{ds: ds} + canSeek := enc.Seekable() + // size for *IndexedAttestation + ctx.sizeFn1 = func(ctx *encoderCtx, t *IndexedAttestation) (size int) { + size += t.SizeSSZDyn(ds) + return size + } + if t == nil { + t = new(AttesterSlashing) + } + dstlen := enc.GetPosition() + dynoff := uint32(8) + // Offset #0 'Attestation1' + offset0 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn1(ctx, t.Attestation1)) + } + // Offset #1 'Attestation2' + offset1 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn1(ctx, t.Attestation2)) + } + { // Dynamic Field #0 'Attestation1' + if canSeek { + enc.EncodeOffsetAt(offset0, uint32(enc.GetPosition()-dstlen)) + } + t := t.Attestation1 + if t == nil { + t = new(IndexedAttestation) + } + if err = t.MarshalSSZEncoder(ds, enc); err != nil { + return sszutils.ErrorWithPath(err, "Attestation1") + } + } + { // Dynamic Field #1 'Attestation2' + if canSeek { + enc.EncodeOffsetAt(offset1, uint32(enc.GetPosition()-dstlen)) + } + t := t.Attestation2 + if t == nil { + t = new(IndexedAttestation) + } + if err = t.MarshalSSZEncoder(ds, enc); err != nil { + return sszutils.ErrorWithPath(err, "Attestation2") + } + } + return nil +} + +// UnmarshalSSZDyn unmarshals the *AttesterSlashing from SSZ-encoded bytes using dynamic specifications. +func (t *AttesterSlashing) UnmarshalSSZDyn(ds sszutils.DynamicSpecs, buf []byte) (err error) { + buflen := len(buf) + if buflen < 8 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 8) + } + // Field #0 'Attestation1' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 8 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset0, 8), "Attestation1:o") + } + // Field #1 'Attestation2' (offset) + offset1 := int(binary.LittleEndian.Uint32(buf[4:8])) + if offset1 < offset0 || offset1 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset1, offset0, buflen), "Attestation2:o") + } + { // Field #0 'Attestation1' (dynamic) + buf := buf[offset0:offset1] + if t.Attestation1 == nil { + t.Attestation1 = new(IndexedAttestation) + } + if err = t.Attestation1.UnmarshalSSZDyn(ds, buf); err != nil { + return sszutils.ErrorWithPath(err, "Attestation1") + } + } + { // Field #1 'Attestation2' (dynamic) + buf := buf[offset1:] + if t.Attestation2 == nil { + t.Attestation2 = new(IndexedAttestation) + } + if err = t.Attestation2.UnmarshalSSZDyn(ds, buf); err != nil { + return sszutils.ErrorWithPath(err, "Attestation2") + } + } + return nil +} + +// UnmarshalSSZDecoder unmarshals the *AttesterSlashing from the given SSZ decoder using dynamic specifications. +func (t *AttesterSlashing) UnmarshalSSZDecoder(ds sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { + maxOffset := uint32(dec.GetLength()) + startPos0 := dec.GetPosition() + if maxOffset < uint32(8) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(8)) + } + // Field #0 'Attestation1' (offset) + offset0, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Attestation1") + } + if offset0 != uint32(8) { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset0, 8), "Attestation1") + } + // Field #1 'Attestation2' (offset) + offset1, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Attestation2") + } + if offset1 < offset0 || offset1 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset1, offset0, maxOffset), "Attestation2") + } + { // Field #0 'Attestation1' (dynamic) + if dec.GetPosition() != startPos0+int(offset0) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset0)), "Attestation1") + } + dec.PushLimit(int(offset1 - offset0)) + val1 := t.Attestation1 + if val1 == nil { + val1 = new(IndexedAttestation) + } + if err = val1.UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPath(err, "Attestation1") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Attestation1") + } + t.Attestation1 = val1 + } + { // Field #1 'Attestation2' (dynamic) + if dec.GetPosition() != startPos0+int(offset1) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset1)), "Attestation2") + } + dec.PushLimit(int(maxOffset - offset1)) + val2 := t.Attestation2 + if val2 == nil { + val2 = new(IndexedAttestation) + } + if err = val2.UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPath(err, "Attestation2") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Attestation2") + } + t.Attestation2 = val2 + } + return nil +} + +// SizeSSZDyn returns the SSZ encoded size of the *AttesterSlashing using dynamic specifications. +func (t *AttesterSlashing) SizeSSZDyn(ds sszutils.DynamicSpecs) (size int) { + if t == nil { + t = new(AttesterSlashing) + } + // Field #0 'Attestation1' offset (4 bytes) + // Field #1 'Attestation2' offset (4 bytes) + size += 8 + { // Dynamic field #0 'Attestation1' + size += t.Attestation1.SizeSSZDyn(ds) + } + { // Dynamic field #1 'Attestation2' + size += t.Attestation2.SizeSSZDyn(ds) + } + return size +} + +// HashTreeRootDyn computes the SSZ hash tree root of the *AttesterSlashing using dynamic specifications. +func (t *AttesterSlashing) HashTreeRootDyn(ds sszutils.DynamicSpecs) (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWithDyn(ds, hh) + if err == nil { + root, err = hh.HashRoot() + } + return + }) + return +} + +// HashTreeRootWithDyn computes the SSZ hash tree root of the *AttesterSlashing using dynamic specifications and the given hash walker. +func (t *AttesterSlashing) HashTreeRootWithDyn(ds sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + if t == nil { + t = new(AttesterSlashing) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Attestation1' + t := t.Attestation1 + if t == nil { + t = new(IndexedAttestation) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPath(err, "Attestation1") + } + } + { // Field #1 'Attestation2' + t := t.Attestation2 + if t == nil { + t = new(IndexedAttestation) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPath(err, "Attestation2") + } + } + hh.Merkleize(idx) + return nil +} + +// MarshalSSZDyn marshals the *IndexedAttestation to SSZ-encoded bytes using dynamic specifications. +func (t *IndexedAttestation) MarshalSSZDyn(ds sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + dst = buf + if t == nil { + t = new(IndexedAttestation) + } + dstlen := len(dst) + // Offset Field #0 'AttestingIndices' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #1 'Data' + t := t.Data + if t == nil { + t = new(generic.AttestationData) + } + if dst, err = t.MarshalSSZDyn(ds, dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "Data") + } + } + { // Static Field #2 'Signature' + vlen := len(t.Signature) + if vlen > 96 { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 96), "Signature") + } + dst = append(dst, t.Signature[:vlen]...) + if vlen < 96 { + dst = sszutils.AppendZeroPadding(dst, (96-vlen)*1) + } + } + { // Dynamic Field #0 'AttestingIndices' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.AttestingIndices + vlen := len(t) + if vlen > 131072 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 131072), "AttestingIndices") + } + dst = sszutils.MarshalUint64Slice(dst, t[:vlen]) + } + return dst, nil +} + +// MarshalSSZEncoder marshals the *IndexedAttestation to the given SSZ encoder using dynamic specifications. +func (t *IndexedAttestation) MarshalSSZEncoder(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + type encoderCtx struct { + ds sszutils.DynamicSpecs + exprs [0]uint64 + sizeFn1 func(ctx *encoderCtx, t []uint64) (size int) + } + ctx := &encoderCtx{ds: ds} + canSeek := enc.Seekable() + // size for []uint64 + ctx.sizeFn1 = func(ctx *encoderCtx, t []uint64) (size int) { + size += len(t) * 8 + return size + } + if t == nil { + t = new(IndexedAttestation) + } + dstlen := enc.GetPosition() + dynoff := uint32(228) + // Offset #0 'AttestingIndices' + offset0 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn1(ctx, t.AttestingIndices)) + } + { // Field #1 'Data' + t := t.Data + if t == nil { + t = new(generic.AttestationData) + } + if err = t.MarshalSSZEncoder(ds, enc); err != nil { + return sszutils.ErrorWithPath(err, "Data") + } + } + { // Field #2 'Signature' + vlen := len(t.Signature) + if vlen > 96 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 96), "Signature") + } + enc.EncodeBytes(t.Signature[:vlen]) + if vlen < 96 { + enc.EncodeZeroPadding((96 - vlen) * 1) + } + } + { // Dynamic Field #0 'AttestingIndices' + if canSeek { + enc.EncodeOffsetAt(offset0, uint32(enc.GetPosition()-dstlen)) + } + t := t.AttestingIndices + vlen := len(t) + if vlen > 131072 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 131072), "AttestingIndices") + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + } + return nil +} + +// UnmarshalSSZDyn unmarshals the *IndexedAttestation from SSZ-encoded bytes using dynamic specifications. +func (t *IndexedAttestation) UnmarshalSSZDyn(ds sszutils.DynamicSpecs, buf []byte) (err error) { + buflen := len(buf) + if buflen < 228 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 228) + } + // Field #0 'AttestingIndices' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 228 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset0, 228), "AttestingIndices:o") + } + { // Field #1 'Data' (static) + buf := buf[4:132] + if t.Data == nil { + t.Data = new(generic.AttestationData) + } + if err = t.Data.UnmarshalSSZDyn(ds, buf); err != nil { + return sszutils.ErrorWithPath(err, "Data") + } + } + { // Field #2 'Signature' (static) + buf := buf[132:228] + t.Signature = sszutils.ExpandSlice(t.Signature, 96) + copy(t.Signature[:], buf) + } + { // Field #0 'AttestingIndices' (dynamic) + buf := buf[offset0:] + val1 := t.AttestingIndices + itemCount := len(buf) / 8 + if len(buf)%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 8), "AttestingIndices") + } + if itemCount > 131072 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 131072), "AttestingIndices") + } + val1 = sszutils.ExpandSlice(val1, itemCount) + sszutils.UnmarshalUint64Slice(val1, buf) + t.AttestingIndices = val1 + } + return nil +} + +// UnmarshalSSZDecoder unmarshals the *IndexedAttestation from the given SSZ decoder using dynamic specifications. +func (t *IndexedAttestation) UnmarshalSSZDecoder(ds sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { + maxOffset := uint32(dec.GetLength()) + startPos0 := dec.GetPosition() + if maxOffset < uint32(228) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(228)) + } + // Field #0 'AttestingIndices' (offset) + offset0, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "AttestingIndices") + } + if offset0 != uint32(228) { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset0, 228), "AttestingIndices") + } + // Field #1 'Data' (static) + if t.Data == nil { + t.Data = new(generic.AttestationData) + } + if err = t.Data.UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPath(err, "Data") + } + // Field #2 'Signature' (static) + t.Signature = sszutils.ExpandSlice(t.Signature, 96) + if _, err = dec.DecodeBytes(t.Signature[:96]); err != nil { + return err + } + { // Field #0 'AttestingIndices' (dynamic) + if dec.GetPosition() != startPos0+int(offset0) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset0)), "AttestingIndices") + } + dec.PushLimit(int(maxOffset - offset0)) + val1 := t.AttestingIndices + sszLen := dec.GetLength() + itemCount := sszLen / 8 + if sszLen%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 8), "AttestingIndices") + } + if itemCount > 131072 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 131072), "AttestingIndices") + } + val1 = sszutils.ExpandSlice(val1, itemCount) + if err = sszutils.DecodeUint64Slice(dec, val1); err != nil { + return sszutils.ErrorWithPath(err, "AttestingIndices") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "AttestingIndices") + } + t.AttestingIndices = val1 + } + return nil +} + +// SizeSSZ returns the SSZ encoded size of the *IndexedAttestation. +func (t *IndexedAttestation) SizeSSZ() (size int) { + if t == nil { + t = new(IndexedAttestation) + } + // Field #0 'AttestingIndices' offset (4 bytes) + // Field #1 'Data' static (128 bytes) + // Field #2 'Signature' static (96 bytes) + size += 228 + { // Dynamic field #0 'AttestingIndices' + size += len(t.AttestingIndices) * 8 + } + return size +} + +// SizeSSZDyn returns the SSZ encoded size of the *IndexedAttestation using dynamic specifications. +func (t *IndexedAttestation) SizeSSZDyn(_ sszutils.DynamicSpecs) (size int) { + return t.SizeSSZ() +} + +// HashTreeRootDyn computes the SSZ hash tree root of the *IndexedAttestation using dynamic specifications. +func (t *IndexedAttestation) HashTreeRootDyn(ds sszutils.DynamicSpecs) (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWithDyn(ds, hh) + if err == nil { + root, err = hh.HashRoot() + } + return + }) + return +} + +// HashTreeRootWithDyn computes the SSZ hash tree root of the *IndexedAttestation using dynamic specifications and the given hash walker. +func (t *IndexedAttestation) HashTreeRootWithDyn(ds sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + if t == nil { + t = new(IndexedAttestation) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'AttestingIndices' + t := t.AttestingIndices + vlen := uint64(len(t)) + if vlen > 131072 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 131072), "AttestingIndices") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + sszutils.HashUint64Slice(hh, t) + hh.FillUpTo32() + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(131072, vlen, 8)) + } + { // Field #1 'Data' + t := t.Data + if t == nil { + t = new(generic.AttestationData) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPath(err, "Data") + } + } + { // Field #2 'Signature' + vlen := len(t.Signature) + if vlen > 96 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 96), "Signature") + } + val := t.Signature[:] + if vlen < 96 { + val = sszutils.AppendZeroPadding(val, (96-vlen)*1) + } + hh.PutBytes(val[:96]) + } + hh.Merkleize(idx) + return nil +} diff --git a/shared/types/eth2/fork/electra/state_electra.go b/shared/types/eth2/fork/electra/state_electra.go index da6f80ed4..c412a42b3 100644 --- a/shared/types/eth2/fork/electra/state_electra.go +++ b/shared/types/eth2/fork/electra/state_electra.go @@ -90,7 +90,7 @@ func (state *BeaconState) ValidatorAndSlotProof(validatorIndex uint64) ([][]byte return nil, nil, errors.New("validator index out of bounds") } - stateTree, err := state.GetTree() + stateTree, err := generic.SSZ.GetTree(state) if err != nil { return nil, nil, fmt.Errorf("could not get state tree: %w", err) } @@ -102,7 +102,7 @@ func (state *BeaconState) ValidatorAndSlotProof(validatorIndex uint64) ([][]byte } // Sanity check that the proof leaf matches the expected validator - validatorHashTreeRoot, err := state.Validators[validatorIndex].HashTreeRoot() + validatorHashTreeRoot, err := generic.SSZ.HashTreeRoot(state.Validators[validatorIndex]) if err != nil { return nil, nil, fmt.Errorf("could not get hash tree root for validator: %w", err) } @@ -118,7 +118,7 @@ func (state *BeaconState) ValidatorAndSlotProof(validatorIndex uint64) ([][]byte // Drop the state tree before doing more work so the GC can reclaim it. stateTree = nil - bhTree, err := state.LatestBlockHeader.GetTree() + bhTree, err := generic.SSZ.GetTree(state.LatestBlockHeader) if err != nil { return nil, nil, fmt.Errorf("could not get block header tree: %w", err) } @@ -140,7 +140,7 @@ func (state *BeaconState) ValidatorAndSlotProof(validatorIndex uint64) ([][]byte func (state *BeaconState) blockHeaderToStateProof(blockHeader *generic.BeaconBlockHeader) ([][]byte, error) { generalizedIndex := generic.BeaconBlockHeaderStateRootGeneralizedIndex - root, err := blockHeader.GetTree() + root, err := generic.SSZ.GetTree(blockHeader) if err != nil { return nil, fmt.Errorf("could not get block header tree: %w", err) } @@ -156,7 +156,7 @@ func (state *BeaconState) HistoricalSummaryProof(slot uint64, capellaOffset uint if !isHistorical { return nil, fmt.Errorf("slot %d is less than %d slots in the past from the state at slot %d, you must build a proof from the block_roots field instead", slot, generic.SlotsPerHistoricalRoot, state.Slot) } - tree, err := state.GetTree() + tree, err := generic.SSZ.GetTree(state) if err != nil { return nil, fmt.Errorf("could not get state tree: %w", err) } @@ -193,7 +193,7 @@ func (state *BeaconState) HistoricalSummaryBlockRootProof(slot int) ([][]byte, e } idx := slot % int(generic.SlotsPerHistoricalRoot) - tree, err := hsls.GetTree() + tree, err := generic.SSZ.GetTree(&hsls) if err != nil { return nil, fmt.Errorf("could not get historical summary lists tree: %w", err) } @@ -217,7 +217,7 @@ func (state *BeaconState) BlockRootProof(slot uint64) ([][]byte, error) { return nil, fmt.Errorf("slot %d is more than %d slots in the past from the state at slot %d, you must build a proof from the historical_summaries instead", slot, generic.SlotsPerHistoricalRoot, state.Slot) } - tree, err := state.GetTree() + tree, err := generic.SSZ.GetTree(state) if err != nil { return nil, fmt.Errorf("could not get state tree: %w", err) } diff --git a/shared/types/eth2/fork/electra/state_electra_encoding.go b/shared/types/eth2/fork/electra/state_electra_encoding.go deleted file mode 100644 index 3d6a07445..000000000 --- a/shared/types/eth2/fork/electra/state_electra_encoding.go +++ /dev/null @@ -1,1115 +0,0 @@ -// Code generated by fastssz. DO NOT EDIT. -// Hash: 69e638a904e3884639a92c45d7fc9fb78e7f4fb79160efa6d2f186569d34b3b0 -// Version: 0.1.3 -package electra - -import ( - ssz "github.com/ferranbt/fastssz" - - "github.com/rocket-pool/smartnode/shared/types/eth2/generic" -) - -// MarshalSSZ ssz marshals the BeaconState object -func (b *BeaconState) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} - -// MarshalSSZTo ssz marshals the BeaconState object to a target array -func (b *BeaconState) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(2736713) - - // Field (0) 'GenesisTime' - dst = ssz.MarshalUint64(dst, b.GenesisTime) - - // Field (1) 'GenesisValidatorsRoot' - if size := len(b.GenesisValidatorsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("BeaconState.GenesisValidatorsRoot", size, 32) - return - } - dst = append(dst, b.GenesisValidatorsRoot...) - - // Field (2) 'Slot' - dst = ssz.MarshalUint64(dst, b.Slot) - - // Field (3) 'Fork' - if b.Fork == nil { - b.Fork = new(generic.Fork) - } - if dst, err = b.Fork.MarshalSSZTo(dst); err != nil { - return - } - - // Field (4) 'LatestBlockHeader' - if b.LatestBlockHeader == nil { - b.LatestBlockHeader = new(generic.BeaconBlockHeader) - } - if dst, err = b.LatestBlockHeader.MarshalSSZTo(dst); err != nil { - return - } - - // Field (5) 'BlockRoots' - for ii := 0; ii < 8192; ii++ { - dst = append(dst, b.BlockRoots[ii][:]...) - } - - // Field (6) 'StateRoots' - for ii := 0; ii < 8192; ii++ { - dst = append(dst, b.StateRoots[ii][:]...) - } - - // Offset (7) 'HistoricalRoots' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.HistoricalRoots) * 32 - - // Field (8) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(generic.Eth1Data) - } - if dst, err = b.Eth1Data.MarshalSSZTo(dst); err != nil { - return - } - - // Offset (9) 'Eth1DataVotes' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.Eth1DataVotes) * 72 - - // Field (10) 'Eth1DepositIndex' - dst = ssz.MarshalUint64(dst, b.Eth1DepositIndex) - - // Offset (11) 'Validators' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.Validators) * 121 - - // Offset (12) 'Balances' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.Balances) * 8 - - // Field (13) 'RandaoMixes' - if size := len(b.RandaoMixes); size != 65536 { - err = ssz.ErrVectorLengthFn("BeaconState.RandaoMixes", size, 65536) - return - } - for ii := 0; ii < 65536; ii++ { - if size := len(b.RandaoMixes[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("BeaconState.RandaoMixes[ii]", size, 32) - return - } - dst = append(dst, b.RandaoMixes[ii]...) - } - - // Field (14) 'Slashings' - if size := len(b.Slashings); size != 8192 { - err = ssz.ErrVectorLengthFn("BeaconState.Slashings", size, 8192) - return - } - for ii := 0; ii < 8192; ii++ { - dst = ssz.MarshalUint64(dst, b.Slashings[ii]) - } - - // Offset (15) 'PreviousEpochParticipation' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.PreviousEpochParticipation) - - // Offset (16) 'CurrentEpochParticipation' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.CurrentEpochParticipation) - - // Field (17) 'JustificationBits' - dst = append(dst, b.JustificationBits[:]...) - - // Field (18) 'PreviousJustifiedCheckpoint' - if b.PreviousJustifiedCheckpoint == nil { - b.PreviousJustifiedCheckpoint = new(generic.Checkpoint) - } - if dst, err = b.PreviousJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { - return - } - - // Field (19) 'CurrentJustifiedCheckpoint' - if b.CurrentJustifiedCheckpoint == nil { - b.CurrentJustifiedCheckpoint = new(generic.Checkpoint) - } - if dst, err = b.CurrentJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { - return - } - - // Field (20) 'FinalizedCheckpoint' - if b.FinalizedCheckpoint == nil { - b.FinalizedCheckpoint = new(generic.Checkpoint) - } - if dst, err = b.FinalizedCheckpoint.MarshalSSZTo(dst); err != nil { - return - } - - // Offset (21) 'InactivityScores' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.InactivityScores) * 8 - - // Field (22) 'CurrentSyncCommittee' - if b.CurrentSyncCommittee == nil { - b.CurrentSyncCommittee = new(generic.SyncCommittee) - } - if dst, err = b.CurrentSyncCommittee.MarshalSSZTo(dst); err != nil { - return - } - - // Field (23) 'NextSyncCommittee' - if b.NextSyncCommittee == nil { - b.NextSyncCommittee = new(generic.SyncCommittee) - } - if dst, err = b.NextSyncCommittee.MarshalSSZTo(dst); err != nil { - return - } - - // Offset (24) 'LatestExecutionPayloadHeader' - dst = ssz.WriteOffset(dst, offset) - if b.LatestExecutionPayloadHeader == nil { - b.LatestExecutionPayloadHeader = new(generic.ExecutionPayloadHeader) - } - offset += b.LatestExecutionPayloadHeader.SizeSSZ() - - // Field (25) 'NextWithdrawalIndex' - dst = ssz.MarshalUint64(dst, b.NextWithdrawalIndex) - - // Field (26) 'NextWithdrawalValidatorIndex' - dst = ssz.MarshalUint64(dst, b.NextWithdrawalValidatorIndex) - - // Offset (27) 'HistoricalSummaries' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.HistoricalSummaries) * 64 - - // Field (28) 'DepositRequestsStartIndex' - dst = ssz.MarshalUint64(dst, b.DepositRequestsStartIndex) - - // Field (29) 'DepositBalanceToConsume' - dst = ssz.MarshalUint64(dst, b.DepositBalanceToConsume) - - // Field (30) 'ExitBalanceToConsume' - dst = ssz.MarshalUint64(dst, b.ExitBalanceToConsume) - - // Field (31) 'EarliestExitEpoch' - dst = ssz.MarshalUint64(dst, b.EarliestExitEpoch) - - // Field (32) 'ConsolidationBalanceToConsume' - dst = ssz.MarshalUint64(dst, b.ConsolidationBalanceToConsume) - - // Field (33) 'EarliestConsolidationEpoch' - dst = ssz.MarshalUint64(dst, b.EarliestConsolidationEpoch) - - // Offset (34) 'PendingDeposits' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.PendingDeposits) * 192 - - // Offset (35) 'PendingPartialWithdrawals' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.PendingPartialWithdrawals) * 24 - - // Offset (36) 'PendingConsolidations' - dst = ssz.WriteOffset(dst, offset) - - // Field (7) 'HistoricalRoots' - if size := len(b.HistoricalRoots); size > 16777216 { - err = ssz.ErrListTooBigFn("BeaconState.HistoricalRoots", size, 16777216) - return - } - for ii := 0; ii < len(b.HistoricalRoots); ii++ { - if size := len(b.HistoricalRoots[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("BeaconState.HistoricalRoots[ii]", size, 32) - return - } - dst = append(dst, b.HistoricalRoots[ii]...) - } - - // Field (9) 'Eth1DataVotes' - if size := len(b.Eth1DataVotes); size > 2048 { - err = ssz.ErrListTooBigFn("BeaconState.Eth1DataVotes", size, 2048) - return - } - for ii := 0; ii < len(b.Eth1DataVotes); ii++ { - if dst, err = b.Eth1DataVotes[ii].MarshalSSZTo(dst); err != nil { - return - } - } - - // Field (11) 'Validators' - if size := len(b.Validators); size > 1099511627776 { - err = ssz.ErrListTooBigFn("BeaconState.Validators", size, 1099511627776) - return - } - for ii := 0; ii < len(b.Validators); ii++ { - if dst, err = b.Validators[ii].MarshalSSZTo(dst); err != nil { - return - } - } - - // Field (12) 'Balances' - if size := len(b.Balances); size > 1099511627776 { - err = ssz.ErrListTooBigFn("BeaconState.Balances", size, 1099511627776) - return - } - for ii := 0; ii < len(b.Balances); ii++ { - dst = ssz.MarshalUint64(dst, b.Balances[ii]) - } - - // Field (15) 'PreviousEpochParticipation' - if size := len(b.PreviousEpochParticipation); size > 1099511627776 { - err = ssz.ErrBytesLengthFn("BeaconState.PreviousEpochParticipation", size, 1099511627776) - return - } - dst = append(dst, b.PreviousEpochParticipation...) - - // Field (16) 'CurrentEpochParticipation' - if size := len(b.CurrentEpochParticipation); size > 1099511627776 { - err = ssz.ErrBytesLengthFn("BeaconState.CurrentEpochParticipation", size, 1099511627776) - return - } - dst = append(dst, b.CurrentEpochParticipation...) - - // Field (21) 'InactivityScores' - if size := len(b.InactivityScores); size > 1099511627776 { - err = ssz.ErrListTooBigFn("BeaconState.InactivityScores", size, 1099511627776) - return - } - for ii := 0; ii < len(b.InactivityScores); ii++ { - dst = ssz.MarshalUint64(dst, b.InactivityScores[ii]) - } - - // Field (24) 'LatestExecutionPayloadHeader' - if dst, err = b.LatestExecutionPayloadHeader.MarshalSSZTo(dst); err != nil { - return - } - - // Field (27) 'HistoricalSummaries' - if size := len(b.HistoricalSummaries); size > 16777216 { - err = ssz.ErrListTooBigFn("BeaconState.HistoricalSummaries", size, 16777216) - return - } - for ii := 0; ii < len(b.HistoricalSummaries); ii++ { - if dst, err = b.HistoricalSummaries[ii].MarshalSSZTo(dst); err != nil { - return - } - } - - // Field (34) 'PendingDeposits' - if size := len(b.PendingDeposits); size > 134217728 { - err = ssz.ErrListTooBigFn("BeaconState.PendingDeposits", size, 134217728) - return - } - for ii := 0; ii < len(b.PendingDeposits); ii++ { - if dst, err = b.PendingDeposits[ii].MarshalSSZTo(dst); err != nil { - return - } - } - - // Field (35) 'PendingPartialWithdrawals' - if size := len(b.PendingPartialWithdrawals); size > 134217728 { - err = ssz.ErrListTooBigFn("BeaconState.PendingPartialWithdrawals", size, 134217728) - return - } - for ii := 0; ii < len(b.PendingPartialWithdrawals); ii++ { - if dst, err = b.PendingPartialWithdrawals[ii].MarshalSSZTo(dst); err != nil { - return - } - } - - // Field (36) 'PendingConsolidations' - if size := len(b.PendingConsolidations); size > 262144 { - err = ssz.ErrListTooBigFn("BeaconState.PendingConsolidations", size, 262144) - return - } - for ii := 0; ii < len(b.PendingConsolidations); ii++ { - if dst, err = b.PendingConsolidations[ii].MarshalSSZTo(dst); err != nil { - return - } - } - - return -} - -// UnmarshalSSZ ssz unmarshals the BeaconState object -func (b *BeaconState) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 2736713 { - return ssz.ErrSize - } - - tail := buf - var o7, o9, o11, o12, o15, o16, o21, o24, o27, o34, o35, o36 uint64 - - // Field (0) 'GenesisTime' - b.GenesisTime = ssz.UnmarshallUint64(buf[0:8]) - - // Field (1) 'GenesisValidatorsRoot' - if cap(b.GenesisValidatorsRoot) == 0 { - b.GenesisValidatorsRoot = make([]byte, 0, len(buf[8:40])) - } - b.GenesisValidatorsRoot = append(b.GenesisValidatorsRoot, buf[8:40]...) - - // Field (2) 'Slot' - b.Slot = ssz.UnmarshallUint64(buf[40:48]) - - // Field (3) 'Fork' - if b.Fork == nil { - b.Fork = new(generic.Fork) - } - if err = b.Fork.UnmarshalSSZ(buf[48:64]); err != nil { - return err - } - - // Field (4) 'LatestBlockHeader' - if b.LatestBlockHeader == nil { - b.LatestBlockHeader = new(generic.BeaconBlockHeader) - } - if err = b.LatestBlockHeader.UnmarshalSSZ(buf[64:176]); err != nil { - return err - } - - // Field (5) 'BlockRoots' - - for ii := 0; ii < 8192; ii++ { - copy(b.BlockRoots[ii][:], buf[176:262320][ii*32:(ii+1)*32]) - } - - // Field (6) 'StateRoots' - - for ii := 0; ii < 8192; ii++ { - copy(b.StateRoots[ii][:], buf[262320:524464][ii*32:(ii+1)*32]) - } - - // Offset (7) 'HistoricalRoots' - if o7 = ssz.ReadOffset(buf[524464:524468]); o7 > size { - return ssz.ErrOffset - } - - if o7 != 2736713 { - return ssz.ErrInvalidVariableOffset - } - - // Field (8) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(generic.Eth1Data) - } - if err = b.Eth1Data.UnmarshalSSZ(buf[524468:524540]); err != nil { - return err - } - - // Offset (9) 'Eth1DataVotes' - if o9 = ssz.ReadOffset(buf[524540:524544]); o9 > size || o7 > o9 { - return ssz.ErrOffset - } - - // Field (10) 'Eth1DepositIndex' - b.Eth1DepositIndex = ssz.UnmarshallUint64(buf[524544:524552]) - - // Offset (11) 'Validators' - if o11 = ssz.ReadOffset(buf[524552:524556]); o11 > size || o9 > o11 { - return ssz.ErrOffset - } - - // Offset (12) 'Balances' - if o12 = ssz.ReadOffset(buf[524556:524560]); o12 > size || o11 > o12 { - return ssz.ErrOffset - } - - // Field (13) 'RandaoMixes' - b.RandaoMixes = make([][]byte, 65536) - for ii := 0; ii < 65536; ii++ { - if cap(b.RandaoMixes[ii]) == 0 { - b.RandaoMixes[ii] = make([]byte, 0, len(buf[524560:2621712][ii*32:(ii+1)*32])) - } - b.RandaoMixes[ii] = append(b.RandaoMixes[ii], buf[524560:2621712][ii*32:(ii+1)*32]...) - } - - // Field (14) 'Slashings' - b.Slashings = ssz.ExtendUint64(b.Slashings, 8192) - for ii := 0; ii < 8192; ii++ { - b.Slashings[ii] = ssz.UnmarshallUint64(buf[2621712:2687248][ii*8 : (ii+1)*8]) - } - - // Offset (15) 'PreviousEpochParticipation' - if o15 = ssz.ReadOffset(buf[2687248:2687252]); o15 > size || o12 > o15 { - return ssz.ErrOffset - } - - // Offset (16) 'CurrentEpochParticipation' - if o16 = ssz.ReadOffset(buf[2687252:2687256]); o16 > size || o15 > o16 { - return ssz.ErrOffset - } - - // Field (17) 'JustificationBits' - copy(b.JustificationBits[:], buf[2687256:2687257]) - - // Field (18) 'PreviousJustifiedCheckpoint' - if b.PreviousJustifiedCheckpoint == nil { - b.PreviousJustifiedCheckpoint = new(generic.Checkpoint) - } - if err = b.PreviousJustifiedCheckpoint.UnmarshalSSZ(buf[2687257:2687297]); err != nil { - return err - } - - // Field (19) 'CurrentJustifiedCheckpoint' - if b.CurrentJustifiedCheckpoint == nil { - b.CurrentJustifiedCheckpoint = new(generic.Checkpoint) - } - if err = b.CurrentJustifiedCheckpoint.UnmarshalSSZ(buf[2687297:2687337]); err != nil { - return err - } - - // Field (20) 'FinalizedCheckpoint' - if b.FinalizedCheckpoint == nil { - b.FinalizedCheckpoint = new(generic.Checkpoint) - } - if err = b.FinalizedCheckpoint.UnmarshalSSZ(buf[2687337:2687377]); err != nil { - return err - } - - // Offset (21) 'InactivityScores' - if o21 = ssz.ReadOffset(buf[2687377:2687381]); o21 > size || o16 > o21 { - return ssz.ErrOffset - } - - // Field (22) 'CurrentSyncCommittee' - if b.CurrentSyncCommittee == nil { - b.CurrentSyncCommittee = new(generic.SyncCommittee) - } - if err = b.CurrentSyncCommittee.UnmarshalSSZ(buf[2687381:2712005]); err != nil { - return err - } - - // Field (23) 'NextSyncCommittee' - if b.NextSyncCommittee == nil { - b.NextSyncCommittee = new(generic.SyncCommittee) - } - if err = b.NextSyncCommittee.UnmarshalSSZ(buf[2712005:2736629]); err != nil { - return err - } - - // Offset (24) 'LatestExecutionPayloadHeader' - if o24 = ssz.ReadOffset(buf[2736629:2736633]); o24 > size || o21 > o24 { - return ssz.ErrOffset - } - - // Field (25) 'NextWithdrawalIndex' - b.NextWithdrawalIndex = ssz.UnmarshallUint64(buf[2736633:2736641]) - - // Field (26) 'NextWithdrawalValidatorIndex' - b.NextWithdrawalValidatorIndex = ssz.UnmarshallUint64(buf[2736641:2736649]) - - // Offset (27) 'HistoricalSummaries' - if o27 = ssz.ReadOffset(buf[2736649:2736653]); o27 > size || o24 > o27 { - return ssz.ErrOffset - } - - // Field (28) 'DepositRequestsStartIndex' - b.DepositRequestsStartIndex = ssz.UnmarshallUint64(buf[2736653:2736661]) - - // Field (29) 'DepositBalanceToConsume' - b.DepositBalanceToConsume = ssz.UnmarshallUint64(buf[2736661:2736669]) - - // Field (30) 'ExitBalanceToConsume' - b.ExitBalanceToConsume = ssz.UnmarshallUint64(buf[2736669:2736677]) - - // Field (31) 'EarliestExitEpoch' - b.EarliestExitEpoch = ssz.UnmarshallUint64(buf[2736677:2736685]) - - // Field (32) 'ConsolidationBalanceToConsume' - b.ConsolidationBalanceToConsume = ssz.UnmarshallUint64(buf[2736685:2736693]) - - // Field (33) 'EarliestConsolidationEpoch' - b.EarliestConsolidationEpoch = ssz.UnmarshallUint64(buf[2736693:2736701]) - - // Offset (34) 'PendingDeposits' - if o34 = ssz.ReadOffset(buf[2736701:2736705]); o34 > size || o27 > o34 { - return ssz.ErrOffset - } - - // Offset (35) 'PendingPartialWithdrawals' - if o35 = ssz.ReadOffset(buf[2736705:2736709]); o35 > size || o34 > o35 { - return ssz.ErrOffset - } - - // Offset (36) 'PendingConsolidations' - if o36 = ssz.ReadOffset(buf[2736709:2736713]); o36 > size || o35 > o36 { - return ssz.ErrOffset - } - - // Field (7) 'HistoricalRoots' - { - buf = tail[o7:o9] - num, err := ssz.DivideInt2(len(buf), 32, 16777216) - if err != nil { - return err - } - b.HistoricalRoots = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(b.HistoricalRoots[ii]) == 0 { - b.HistoricalRoots[ii] = make([]byte, 0, len(buf[ii*32:(ii+1)*32])) - } - b.HistoricalRoots[ii] = append(b.HistoricalRoots[ii], buf[ii*32:(ii+1)*32]...) - } - } - - // Field (9) 'Eth1DataVotes' - { - buf = tail[o9:o11] - num, err := ssz.DivideInt2(len(buf), 72, 2048) - if err != nil { - return err - } - b.Eth1DataVotes = make([]*generic.Eth1Data, num) - for ii := 0; ii < num; ii++ { - if b.Eth1DataVotes[ii] == nil { - b.Eth1DataVotes[ii] = new(generic.Eth1Data) - } - if err = b.Eth1DataVotes[ii].UnmarshalSSZ(buf[ii*72 : (ii+1)*72]); err != nil { - return err - } - } - } - - // Field (11) 'Validators' - { - buf = tail[o11:o12] - num, err := ssz.DivideInt2(len(buf), 121, 1099511627776) - if err != nil { - return err - } - b.Validators = make([]*generic.Validator, num) - for ii := 0; ii < num; ii++ { - if b.Validators[ii] == nil { - b.Validators[ii] = new(generic.Validator) - } - if err = b.Validators[ii].UnmarshalSSZ(buf[ii*121 : (ii+1)*121]); err != nil { - return err - } - } - } - - // Field (12) 'Balances' - { - buf = tail[o12:o15] - num, err := ssz.DivideInt2(len(buf), 8, 1099511627776) - if err != nil { - return err - } - b.Balances = ssz.ExtendUint64(b.Balances, num) - for ii := 0; ii < num; ii++ { - b.Balances[ii] = ssz.UnmarshallUint64(buf[ii*8 : (ii+1)*8]) - } - } - - // Field (15) 'PreviousEpochParticipation' - { - buf = tail[o15:o16] - if len(buf) > 1099511627776 { - return ssz.ErrBytesLength - } - if cap(b.PreviousEpochParticipation) == 0 { - b.PreviousEpochParticipation = make([]byte, 0, len(buf)) - } - b.PreviousEpochParticipation = append(b.PreviousEpochParticipation, buf...) - } - - // Field (16) 'CurrentEpochParticipation' - { - buf = tail[o16:o21] - if len(buf) > 1099511627776 { - return ssz.ErrBytesLength - } - if cap(b.CurrentEpochParticipation) == 0 { - b.CurrentEpochParticipation = make([]byte, 0, len(buf)) - } - b.CurrentEpochParticipation = append(b.CurrentEpochParticipation, buf...) - } - - // Field (21) 'InactivityScores' - { - buf = tail[o21:o24] - num, err := ssz.DivideInt2(len(buf), 8, 1099511627776) - if err != nil { - return err - } - b.InactivityScores = ssz.ExtendUint64(b.InactivityScores, num) - for ii := 0; ii < num; ii++ { - b.InactivityScores[ii] = ssz.UnmarshallUint64(buf[ii*8 : (ii+1)*8]) - } - } - - // Field (24) 'LatestExecutionPayloadHeader' - { - buf = tail[o24:o27] - if b.LatestExecutionPayloadHeader == nil { - b.LatestExecutionPayloadHeader = new(generic.ExecutionPayloadHeader) - } - if err = b.LatestExecutionPayloadHeader.UnmarshalSSZ(buf); err != nil { - return err - } - } - - // Field (27) 'HistoricalSummaries' - { - buf = tail[o27:o34] - num, err := ssz.DivideInt2(len(buf), 64, 16777216) - if err != nil { - return err - } - b.HistoricalSummaries = make([]*generic.HistoricalSummary, num) - for ii := 0; ii < num; ii++ { - if b.HistoricalSummaries[ii] == nil { - b.HistoricalSummaries[ii] = new(generic.HistoricalSummary) - } - if err = b.HistoricalSummaries[ii].UnmarshalSSZ(buf[ii*64 : (ii+1)*64]); err != nil { - return err - } - } - } - - // Field (34) 'PendingDeposits' - { - buf = tail[o34:o35] - num, err := ssz.DivideInt2(len(buf), 192, 134217728) - if err != nil { - return err - } - b.PendingDeposits = make([]*generic.PendingDeposit, num) - for ii := 0; ii < num; ii++ { - if b.PendingDeposits[ii] == nil { - b.PendingDeposits[ii] = new(generic.PendingDeposit) - } - if err = b.PendingDeposits[ii].UnmarshalSSZ(buf[ii*192 : (ii+1)*192]); err != nil { - return err - } - } - } - - // Field (35) 'PendingPartialWithdrawals' - { - buf = tail[o35:o36] - num, err := ssz.DivideInt2(len(buf), 24, 134217728) - if err != nil { - return err - } - b.PendingPartialWithdrawals = make([]*generic.PendingPartialWithdrawal, num) - for ii := 0; ii < num; ii++ { - if b.PendingPartialWithdrawals[ii] == nil { - b.PendingPartialWithdrawals[ii] = new(generic.PendingPartialWithdrawal) - } - if err = b.PendingPartialWithdrawals[ii].UnmarshalSSZ(buf[ii*24 : (ii+1)*24]); err != nil { - return err - } - } - } - - // Field (36) 'PendingConsolidations' - { - buf = tail[o36:] - num, err := ssz.DivideInt2(len(buf), 16, 262144) - if err != nil { - return err - } - b.PendingConsolidations = make([]*generic.PendingConsolidation, num) - for ii := 0; ii < num; ii++ { - if b.PendingConsolidations[ii] == nil { - b.PendingConsolidations[ii] = new(generic.PendingConsolidation) - } - if err = b.PendingConsolidations[ii].UnmarshalSSZ(buf[ii*16 : (ii+1)*16]); err != nil { - return err - } - } - } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the BeaconState object -func (b *BeaconState) SizeSSZ() (size int) { - size = 2736713 - - // Field (7) 'HistoricalRoots' - size += len(b.HistoricalRoots) * 32 - - // Field (9) 'Eth1DataVotes' - size += len(b.Eth1DataVotes) * 72 - - // Field (11) 'Validators' - size += len(b.Validators) * 121 - - // Field (12) 'Balances' - size += len(b.Balances) * 8 - - // Field (15) 'PreviousEpochParticipation' - size += len(b.PreviousEpochParticipation) - - // Field (16) 'CurrentEpochParticipation' - size += len(b.CurrentEpochParticipation) - - // Field (21) 'InactivityScores' - size += len(b.InactivityScores) * 8 - - // Field (24) 'LatestExecutionPayloadHeader' - if b.LatestExecutionPayloadHeader == nil { - b.LatestExecutionPayloadHeader = new(generic.ExecutionPayloadHeader) - } - size += b.LatestExecutionPayloadHeader.SizeSSZ() - - // Field (27) 'HistoricalSummaries' - size += len(b.HistoricalSummaries) * 64 - - // Field (34) 'PendingDeposits' - size += len(b.PendingDeposits) * 192 - - // Field (35) 'PendingPartialWithdrawals' - size += len(b.PendingPartialWithdrawals) * 24 - - // Field (36) 'PendingConsolidations' - size += len(b.PendingConsolidations) * 16 - - return -} - -// HashTreeRoot ssz hashes the BeaconState object -func (b *BeaconState) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) -} - -// HashTreeRootWith ssz hashes the BeaconState object with a hasher -func (b *BeaconState) HashTreeRootWith(hh ssz.HashWalker) (err error) { - indx := hh.Index() - - // Field (0) 'GenesisTime' - hh.PutUint64(b.GenesisTime) - - // Field (1) 'GenesisValidatorsRoot' - if size := len(b.GenesisValidatorsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("BeaconState.GenesisValidatorsRoot", size, 32) - return - } - hh.PutBytes(b.GenesisValidatorsRoot) - - // Field (2) 'Slot' - hh.PutUint64(b.Slot) - - // Field (3) 'Fork' - if b.Fork == nil { - b.Fork = new(generic.Fork) - } - if err = b.Fork.HashTreeRootWith(hh); err != nil { - return - } - - // Field (4) 'LatestBlockHeader' - if b.LatestBlockHeader == nil { - b.LatestBlockHeader = new(generic.BeaconBlockHeader) - } - if err = b.LatestBlockHeader.HashTreeRootWith(hh); err != nil { - return - } - - // Field (5) 'BlockRoots' - { - subIndx := hh.Index() - for _, i := range b.BlockRoots { - hh.Append(i[:]) - } - hh.Merkleize(subIndx) - } - - // Field (6) 'StateRoots' - { - subIndx := hh.Index() - for _, i := range b.StateRoots { - hh.Append(i[:]) - } - hh.Merkleize(subIndx) - } - - // Field (7) 'HistoricalRoots' - { - if size := len(b.HistoricalRoots); size > 16777216 { - err = ssz.ErrListTooBigFn("BeaconState.HistoricalRoots", size, 16777216) - return - } - subIndx := hh.Index() - for _, i := range b.HistoricalRoots { - if len(i) != 32 { - err = ssz.ErrBytesLength - return - } - hh.Append(i) - } - numItems := uint64(len(b.HistoricalRoots)) - hh.MerkleizeWithMixin(subIndx, numItems, 16777216) - } - - // Field (8) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(generic.Eth1Data) - } - if err = b.Eth1Data.HashTreeRootWith(hh); err != nil { - return - } - - // Field (9) 'Eth1DataVotes' - { - subIndx := hh.Index() - num := uint64(len(b.Eth1DataVotes)) - if num > 2048 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range b.Eth1DataVotes { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } - } - hh.MerkleizeWithMixin(subIndx, num, 2048) - } - - // Field (10) 'Eth1DepositIndex' - hh.PutUint64(b.Eth1DepositIndex) - - // Field (11) 'Validators' - { - subIndx := hh.Index() - num := uint64(len(b.Validators)) - if num > 1099511627776 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range b.Validators { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } - } - hh.MerkleizeWithMixin(subIndx, num, 1099511627776) - } - - // Field (12) 'Balances' - { - if size := len(b.Balances); size > 1099511627776 { - err = ssz.ErrListTooBigFn("BeaconState.Balances", size, 1099511627776) - return - } - subIndx := hh.Index() - for _, i := range b.Balances { - hh.AppendUint64(i) - } - hh.FillUpTo32() - numItems := uint64(len(b.Balances)) - hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(1099511627776, numItems, 8)) - } - - // Field (13) 'RandaoMixes' - { - if size := len(b.RandaoMixes); size != 65536 { - err = ssz.ErrVectorLengthFn("BeaconState.RandaoMixes", size, 65536) - return - } - subIndx := hh.Index() - for _, i := range b.RandaoMixes { - if len(i) != 32 { - err = ssz.ErrBytesLength - return - } - hh.Append(i) - } - hh.Merkleize(subIndx) - } - - // Field (14) 'Slashings' - { - if size := len(b.Slashings); size != 8192 { - err = ssz.ErrVectorLengthFn("BeaconState.Slashings", size, 8192) - return - } - subIndx := hh.Index() - for _, i := range b.Slashings { - hh.AppendUint64(i) - } - hh.Merkleize(subIndx) - } - - // Field (15) 'PreviousEpochParticipation' - { - elemIndx := hh.Index() - byteLen := uint64(len(b.PreviousEpochParticipation)) - if byteLen > 1099511627776 { - err = ssz.ErrIncorrectListSize - return - } - hh.Append(b.PreviousEpochParticipation) - hh.MerkleizeWithMixin(elemIndx, byteLen, (1099511627776+31)/32) - } - - // Field (16) 'CurrentEpochParticipation' - { - elemIndx := hh.Index() - byteLen := uint64(len(b.CurrentEpochParticipation)) - if byteLen > 1099511627776 { - err = ssz.ErrIncorrectListSize - return - } - hh.Append(b.CurrentEpochParticipation) - hh.MerkleizeWithMixin(elemIndx, byteLen, (1099511627776+31)/32) - } - - // Field (17) 'JustificationBits' - hh.PutBytes(b.JustificationBits[:]) - - // Field (18) 'PreviousJustifiedCheckpoint' - if b.PreviousJustifiedCheckpoint == nil { - b.PreviousJustifiedCheckpoint = new(generic.Checkpoint) - } - if err = b.PreviousJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { - return - } - - // Field (19) 'CurrentJustifiedCheckpoint' - if b.CurrentJustifiedCheckpoint == nil { - b.CurrentJustifiedCheckpoint = new(generic.Checkpoint) - } - if err = b.CurrentJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { - return - } - - // Field (20) 'FinalizedCheckpoint' - if b.FinalizedCheckpoint == nil { - b.FinalizedCheckpoint = new(generic.Checkpoint) - } - if err = b.FinalizedCheckpoint.HashTreeRootWith(hh); err != nil { - return - } - - // Field (21) 'InactivityScores' - { - if size := len(b.InactivityScores); size > 1099511627776 { - err = ssz.ErrListTooBigFn("BeaconState.InactivityScores", size, 1099511627776) - return - } - subIndx := hh.Index() - for _, i := range b.InactivityScores { - hh.AppendUint64(i) - } - hh.FillUpTo32() - numItems := uint64(len(b.InactivityScores)) - hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(1099511627776, numItems, 8)) - } - - // Field (22) 'CurrentSyncCommittee' - if b.CurrentSyncCommittee == nil { - b.CurrentSyncCommittee = new(generic.SyncCommittee) - } - if err = b.CurrentSyncCommittee.HashTreeRootWith(hh); err != nil { - return - } - - // Field (23) 'NextSyncCommittee' - if b.NextSyncCommittee == nil { - b.NextSyncCommittee = new(generic.SyncCommittee) - } - if err = b.NextSyncCommittee.HashTreeRootWith(hh); err != nil { - return - } - - // Field (24) 'LatestExecutionPayloadHeader' - if err = b.LatestExecutionPayloadHeader.HashTreeRootWith(hh); err != nil { - return - } - - // Field (25) 'NextWithdrawalIndex' - hh.PutUint64(b.NextWithdrawalIndex) - - // Field (26) 'NextWithdrawalValidatorIndex' - hh.PutUint64(b.NextWithdrawalValidatorIndex) - - // Field (27) 'HistoricalSummaries' - { - subIndx := hh.Index() - num := uint64(len(b.HistoricalSummaries)) - if num > 16777216 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range b.HistoricalSummaries { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } - } - hh.MerkleizeWithMixin(subIndx, num, 16777216) - } - - // Field (28) 'DepositRequestsStartIndex' - hh.PutUint64(b.DepositRequestsStartIndex) - - // Field (29) 'DepositBalanceToConsume' - hh.PutUint64(b.DepositBalanceToConsume) - - // Field (30) 'ExitBalanceToConsume' - hh.PutUint64(b.ExitBalanceToConsume) - - // Field (31) 'EarliestExitEpoch' - hh.PutUint64(b.EarliestExitEpoch) - - // Field (32) 'ConsolidationBalanceToConsume' - hh.PutUint64(b.ConsolidationBalanceToConsume) - - // Field (33) 'EarliestConsolidationEpoch' - hh.PutUint64(b.EarliestConsolidationEpoch) - - // Field (34) 'PendingDeposits' - { - subIndx := hh.Index() - num := uint64(len(b.PendingDeposits)) - if num > 134217728 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range b.PendingDeposits { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } - } - hh.MerkleizeWithMixin(subIndx, num, 134217728) - } - - // Field (35) 'PendingPartialWithdrawals' - { - subIndx := hh.Index() - num := uint64(len(b.PendingPartialWithdrawals)) - if num > 134217728 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range b.PendingPartialWithdrawals { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } - } - hh.MerkleizeWithMixin(subIndx, num, 134217728) - } - - // Field (36) 'PendingConsolidations' - { - subIndx := hh.Index() - num := uint64(len(b.PendingConsolidations)) - if num > 262144 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range b.PendingConsolidations { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } - } - hh.MerkleizeWithMixin(subIndx, num, 262144) - } - - hh.Merkleize(indx) - return -} - -// GetTree ssz hashes the BeaconState object -func (b *BeaconState) GetTree() (*ssz.Node, error) { - return ssz.ProofTree(b) -} diff --git a/shared/types/eth2/fork/fulu/block_fulu.go b/shared/types/eth2/fork/fulu/block_fulu.go index 8b64c92b8..3389dc0d5 100644 --- a/shared/types/eth2/fork/fulu/block_fulu.go +++ b/shared/types/eth2/fork/fulu/block_fulu.go @@ -10,7 +10,7 @@ import ( const BeaconBlockBodyChunksCeil uint64 = 16 func (b *SignedBeaconBlock) ProveWithdrawal(indexInWithdrawalsArray uint64) ([][]byte, error) { - tree, err := b.Block.GetTree() + tree, err := generic.SSZ.GetTree(b.Block) if err != nil { return nil, err } diff --git a/shared/types/eth2/fork/fulu/block_fulu_encoding.go b/shared/types/eth2/fork/fulu/block_fulu_encoding.go deleted file mode 100644 index be3316a3f..000000000 --- a/shared/types/eth2/fork/fulu/block_fulu_encoding.go +++ /dev/null @@ -1,1850 +0,0 @@ -// Code generated by fastssz. DO NOT EDIT. -// Hash: 69e638a904e3884639a92c45d7fc9fb78e7f4fb79160efa6d2f186569d34b3b0 -// Version: 0.1.3 -package fulu - -import ( - ssz "github.com/ferranbt/fastssz" - - "github.com/rocket-pool/smartnode/shared/types/eth2/generic" -) - -// MarshalSSZ ssz marshals the BeaconBlock object -func (b *BeaconBlock) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} - -// MarshalSSZTo ssz marshals the BeaconBlock object to a target array -func (b *BeaconBlock) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(84) - - // Field (0) 'Slot' - dst = ssz.MarshalUint64(dst, b.Slot) - - // Field (1) 'ProposerIndex' - dst = ssz.MarshalUint64(dst, b.ProposerIndex) - - // Field (2) 'ParentRoot' - dst = append(dst, b.ParentRoot[:]...) - - // Field (3) 'StateRoot' - dst = append(dst, b.StateRoot[:]...) - - // Offset (4) 'Body' - dst = ssz.WriteOffset(dst, offset) - - // Field (4) 'Body' - if dst, err = b.Body.MarshalSSZTo(dst); err != nil { - return - } - - return -} - -// UnmarshalSSZ ssz unmarshals the BeaconBlock object -func (b *BeaconBlock) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 84 { - return ssz.ErrSize - } - - tail := buf - var o4 uint64 - - // Field (0) 'Slot' - b.Slot = ssz.UnmarshallUint64(buf[0:8]) - - // Field (1) 'ProposerIndex' - b.ProposerIndex = ssz.UnmarshallUint64(buf[8:16]) - - // Field (2) 'ParentRoot' - copy(b.ParentRoot[:], buf[16:48]) - - // Field (3) 'StateRoot' - copy(b.StateRoot[:], buf[48:80]) - - // Offset (4) 'Body' - if o4 = ssz.ReadOffset(buf[80:84]); o4 > size { - return ssz.ErrOffset - } - - if o4 != 84 { - return ssz.ErrInvalidVariableOffset - } - - // Field (4) 'Body' - { - buf = tail[o4:] - if b.Body == nil { - b.Body = new(BeaconBlockBody) - } - if err = b.Body.UnmarshalSSZ(buf); err != nil { - return err - } - } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the BeaconBlock object -func (b *BeaconBlock) SizeSSZ() (size int) { - size = 84 - - // Field (4) 'Body' - if b.Body == nil { - b.Body = new(BeaconBlockBody) - } - size += b.Body.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the BeaconBlock object -func (b *BeaconBlock) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) -} - -// HashTreeRootWith ssz hashes the BeaconBlock object with a hasher -func (b *BeaconBlock) HashTreeRootWith(hh ssz.HashWalker) (err error) { - indx := hh.Index() - - // Field (0) 'Slot' - hh.PutUint64(b.Slot) - - // Field (1) 'ProposerIndex' - hh.PutUint64(b.ProposerIndex) - - // Field (2) 'ParentRoot' - hh.PutBytes(b.ParentRoot[:]) - - // Field (3) 'StateRoot' - hh.PutBytes(b.StateRoot[:]) - - // Field (4) 'Body' - if err = b.Body.HashTreeRootWith(hh); err != nil { - return - } - - hh.Merkleize(indx) - return -} - -// GetTree ssz hashes the BeaconBlock object -func (b *BeaconBlock) GetTree() (*ssz.Node, error) { - return ssz.ProofTree(b) -} - -// MarshalSSZ ssz marshals the SignedBeaconBlock object -func (s *SignedBeaconBlock) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) -} - -// MarshalSSZTo ssz marshals the SignedBeaconBlock object to a target array -func (s *SignedBeaconBlock) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(100) - - // Offset (0) 'Block' - dst = ssz.WriteOffset(dst, offset) - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("SignedBeaconBlock.Signature", size, 96) - return - } - dst = append(dst, s.Signature...) - - // Field (0) 'Block' - if dst, err = s.Block.MarshalSSZTo(dst); err != nil { - return - } - - return -} - -// UnmarshalSSZ ssz unmarshals the SignedBeaconBlock object -func (s *SignedBeaconBlock) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 100 { - return ssz.ErrSize - } - - tail := buf - var o0 uint64 - - // Offset (0) 'Block' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } - - if o0 != 100 { - return ssz.ErrInvalidVariableOffset - } - - // Field (1) 'Signature' - if cap(s.Signature) == 0 { - s.Signature = make([]byte, 0, len(buf[4:100])) - } - s.Signature = append(s.Signature, buf[4:100]...) - - // Field (0) 'Block' - { - buf = tail[o0:] - if s.Block == nil { - s.Block = new(BeaconBlock) - } - if err = s.Block.UnmarshalSSZ(buf); err != nil { - return err - } - } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the SignedBeaconBlock object -func (s *SignedBeaconBlock) SizeSSZ() (size int) { - size = 100 - - // Field (0) 'Block' - if s.Block == nil { - s.Block = new(BeaconBlock) - } - size += s.Block.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the SignedBeaconBlock object -func (s *SignedBeaconBlock) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) -} - -// HashTreeRootWith ssz hashes the SignedBeaconBlock object with a hasher -func (s *SignedBeaconBlock) HashTreeRootWith(hh ssz.HashWalker) (err error) { - indx := hh.Index() - - // Field (0) 'Block' - if err = s.Block.HashTreeRootWith(hh); err != nil { - return - } - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("SignedBeaconBlock.Signature", size, 96) - return - } - hh.PutBytes(s.Signature) - - hh.Merkleize(indx) - return -} - -// GetTree ssz hashes the SignedBeaconBlock object -func (s *SignedBeaconBlock) GetTree() (*ssz.Node, error) { - return ssz.ProofTree(s) -} - -// MarshalSSZ ssz marshals the BeaconBlockBody object -func (b *BeaconBlockBody) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} - -// MarshalSSZTo ssz marshals the BeaconBlockBody object to a target array -func (b *BeaconBlockBody) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(396) - - // Field (0) 'RandaoReveal' - if size := len(b.RandaoReveal); size != 96 { - err = ssz.ErrBytesLengthFn("BeaconBlockBody.RandaoReveal", size, 96) - return - } - dst = append(dst, b.RandaoReveal...) - - // Field (1) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(generic.Eth1Data) - } - if dst, err = b.Eth1Data.MarshalSSZTo(dst); err != nil { - return - } - - // Field (2) 'Graffiti' - dst = append(dst, b.Graffiti[:]...) - - // Offset (3) 'ProposerSlashings' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.ProposerSlashings) * 416 - - // Offset (4) 'AttesterSlashings' - dst = ssz.WriteOffset(dst, offset) - for ii := 0; ii < len(b.AttesterSlashings); ii++ { - offset += 4 - offset += b.AttesterSlashings[ii].SizeSSZ() - } - - // Offset (5) 'Attestations' - dst = ssz.WriteOffset(dst, offset) - for ii := 0; ii < len(b.Attestations); ii++ { - offset += 4 - offset += b.Attestations[ii].SizeSSZ() - } - - // Offset (6) 'Deposits' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.Deposits) * 1240 - - // Offset (7) 'VoluntaryExits' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.VoluntaryExits) * 112 - - // Field (8) 'SyncAggregate' - if b.SyncAggregate == nil { - b.SyncAggregate = new(generic.SyncAggregate) - } - if dst, err = b.SyncAggregate.MarshalSSZTo(dst); err != nil { - return - } - - // Offset (9) 'ExecutionPayload' - dst = ssz.WriteOffset(dst, offset) - if b.ExecutionPayload == nil { - b.ExecutionPayload = new(generic.ExecutionPayload) - } - offset += b.ExecutionPayload.SizeSSZ() - - // Offset (10) 'BlsToExecutionChanges' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.BlsToExecutionChanges) * 172 - - // Offset (11) 'BlobKzgCommitments' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.BlobKzgCommitments) * 48 - - // Offset (12) 'ExecutionRequests' - dst = ssz.WriteOffset(dst, offset) - - // Field (3) 'ProposerSlashings' - if size := len(b.ProposerSlashings); size > 16 { - err = ssz.ErrListTooBigFn("BeaconBlockBody.ProposerSlashings", size, 16) - return - } - for ii := 0; ii < len(b.ProposerSlashings); ii++ { - if dst, err = b.ProposerSlashings[ii].MarshalSSZTo(dst); err != nil { - return - } - } - - // Field (4) 'AttesterSlashings' - if size := len(b.AttesterSlashings); size > 1 { - err = ssz.ErrListTooBigFn("BeaconBlockBody.AttesterSlashings", size, 1) - return - } - { - offset = 4 * len(b.AttesterSlashings) - for ii := 0; ii < len(b.AttesterSlashings); ii++ { - dst = ssz.WriteOffset(dst, offset) - offset += b.AttesterSlashings[ii].SizeSSZ() - } - } - for ii := 0; ii < len(b.AttesterSlashings); ii++ { - if dst, err = b.AttesterSlashings[ii].MarshalSSZTo(dst); err != nil { - return - } - } - - // Field (5) 'Attestations' - if size := len(b.Attestations); size > 8 { - err = ssz.ErrListTooBigFn("BeaconBlockBody.Attestations", size, 8) - return - } - { - offset = 4 * len(b.Attestations) - for ii := 0; ii < len(b.Attestations); ii++ { - dst = ssz.WriteOffset(dst, offset) - offset += b.Attestations[ii].SizeSSZ() - } - } - for ii := 0; ii < len(b.Attestations); ii++ { - if dst, err = b.Attestations[ii].MarshalSSZTo(dst); err != nil { - return - } - } - - // Field (6) 'Deposits' - if size := len(b.Deposits); size > 16 { - err = ssz.ErrListTooBigFn("BeaconBlockBody.Deposits", size, 16) - return - } - for ii := 0; ii < len(b.Deposits); ii++ { - if dst, err = b.Deposits[ii].MarshalSSZTo(dst); err != nil { - return - } - } - - // Field (7) 'VoluntaryExits' - if size := len(b.VoluntaryExits); size > 16 { - err = ssz.ErrListTooBigFn("BeaconBlockBody.VoluntaryExits", size, 16) - return - } - for ii := 0; ii < len(b.VoluntaryExits); ii++ { - if dst, err = b.VoluntaryExits[ii].MarshalSSZTo(dst); err != nil { - return - } - } - - // Field (9) 'ExecutionPayload' - if dst, err = b.ExecutionPayload.MarshalSSZTo(dst); err != nil { - return - } - - // Field (10) 'BlsToExecutionChanges' - if size := len(b.BlsToExecutionChanges); size > 16 { - err = ssz.ErrListTooBigFn("BeaconBlockBody.BlsToExecutionChanges", size, 16) - return - } - for ii := 0; ii < len(b.BlsToExecutionChanges); ii++ { - if dst, err = b.BlsToExecutionChanges[ii].MarshalSSZTo(dst); err != nil { - return - } - } - - // Field (11) 'BlobKzgCommitments' - if size := len(b.BlobKzgCommitments); size > 4096 { - err = ssz.ErrListTooBigFn("BeaconBlockBody.BlobKzgCommitments", size, 4096) - return - } - for ii := 0; ii < len(b.BlobKzgCommitments); ii++ { - dst = append(dst, b.BlobKzgCommitments[ii][:]...) - } - - // Field (12) 'ExecutionRequests' - if dst, err = b.ExecutionRequests.MarshalSSZTo(dst); err != nil { - return - } - - return -} - -// UnmarshalSSZ ssz unmarshals the BeaconBlockBody object -func (b *BeaconBlockBody) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 396 { - return ssz.ErrSize - } - - tail := buf - var o3, o4, o5, o6, o7, o9, o10, o11, o12 uint64 - - // Field (0) 'RandaoReveal' - if cap(b.RandaoReveal) == 0 { - b.RandaoReveal = make([]byte, 0, len(buf[0:96])) - } - b.RandaoReveal = append(b.RandaoReveal, buf[0:96]...) - - // Field (1) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(generic.Eth1Data) - } - if err = b.Eth1Data.UnmarshalSSZ(buf[96:168]); err != nil { - return err - } - - // Field (2) 'Graffiti' - copy(b.Graffiti[:], buf[168:200]) - - // Offset (3) 'ProposerSlashings' - if o3 = ssz.ReadOffset(buf[200:204]); o3 > size { - return ssz.ErrOffset - } - - if o3 != 396 { - return ssz.ErrInvalidVariableOffset - } - - // Offset (4) 'AttesterSlashings' - if o4 = ssz.ReadOffset(buf[204:208]); o4 > size || o3 > o4 { - return ssz.ErrOffset - } - - // Offset (5) 'Attestations' - if o5 = ssz.ReadOffset(buf[208:212]); o5 > size || o4 > o5 { - return ssz.ErrOffset - } - - // Offset (6) 'Deposits' - if o6 = ssz.ReadOffset(buf[212:216]); o6 > size || o5 > o6 { - return ssz.ErrOffset - } - - // Offset (7) 'VoluntaryExits' - if o7 = ssz.ReadOffset(buf[216:220]); o7 > size || o6 > o7 { - return ssz.ErrOffset - } - - // Field (8) 'SyncAggregate' - if b.SyncAggregate == nil { - b.SyncAggregate = new(generic.SyncAggregate) - } - if err = b.SyncAggregate.UnmarshalSSZ(buf[220:380]); err != nil { - return err - } - - // Offset (9) 'ExecutionPayload' - if o9 = ssz.ReadOffset(buf[380:384]); o9 > size || o7 > o9 { - return ssz.ErrOffset - } - - // Offset (10) 'BlsToExecutionChanges' - if o10 = ssz.ReadOffset(buf[384:388]); o10 > size || o9 > o10 { - return ssz.ErrOffset - } - - // Offset (11) 'BlobKzgCommitments' - if o11 = ssz.ReadOffset(buf[388:392]); o11 > size || o10 > o11 { - return ssz.ErrOffset - } - - // Offset (12) 'ExecutionRequests' - if o12 = ssz.ReadOffset(buf[392:396]); o12 > size || o11 > o12 { - return ssz.ErrOffset - } - - // Field (3) 'ProposerSlashings' - { - buf = tail[o3:o4] - num, err := ssz.DivideInt2(len(buf), 416, 16) - if err != nil { - return err - } - b.ProposerSlashings = make([]*generic.ProposerSlashing, num) - for ii := 0; ii < num; ii++ { - if b.ProposerSlashings[ii] == nil { - b.ProposerSlashings[ii] = new(generic.ProposerSlashing) - } - if err = b.ProposerSlashings[ii].UnmarshalSSZ(buf[ii*416 : (ii+1)*416]); err != nil { - return err - } - } - } - - // Field (4) 'AttesterSlashings' - { - buf = tail[o4:o5] - num, err := ssz.DecodeDynamicLength(buf, 1) - if err != nil { - return err - } - b.AttesterSlashings = make([]*AttesterSlashing, num) - err = ssz.UnmarshalDynamic(buf, num, func(indx int, buf []byte) (err error) { - if b.AttesterSlashings[indx] == nil { - b.AttesterSlashings[indx] = new(AttesterSlashing) - } - if err = b.AttesterSlashings[indx].UnmarshalSSZ(buf); err != nil { - return err - } - return nil - }) - if err != nil { - return err - } - } - - // Field (5) 'Attestations' - { - buf = tail[o5:o6] - num, err := ssz.DecodeDynamicLength(buf, 8) - if err != nil { - return err - } - b.Attestations = make([]*Attestation, num) - err = ssz.UnmarshalDynamic(buf, num, func(indx int, buf []byte) (err error) { - if b.Attestations[indx] == nil { - b.Attestations[indx] = new(Attestation) - } - if err = b.Attestations[indx].UnmarshalSSZ(buf); err != nil { - return err - } - return nil - }) - if err != nil { - return err - } - } - - // Field (6) 'Deposits' - { - buf = tail[o6:o7] - num, err := ssz.DivideInt2(len(buf), 1240, 16) - if err != nil { - return err - } - b.Deposits = make([]*generic.Deposit, num) - for ii := 0; ii < num; ii++ { - if b.Deposits[ii] == nil { - b.Deposits[ii] = new(generic.Deposit) - } - if err = b.Deposits[ii].UnmarshalSSZ(buf[ii*1240 : (ii+1)*1240]); err != nil { - return err - } - } - } - - // Field (7) 'VoluntaryExits' - { - buf = tail[o7:o9] - num, err := ssz.DivideInt2(len(buf), 112, 16) - if err != nil { - return err - } - b.VoluntaryExits = make([]*generic.SignedVoluntaryExit, num) - for ii := 0; ii < num; ii++ { - if b.VoluntaryExits[ii] == nil { - b.VoluntaryExits[ii] = new(generic.SignedVoluntaryExit) - } - if err = b.VoluntaryExits[ii].UnmarshalSSZ(buf[ii*112 : (ii+1)*112]); err != nil { - return err - } - } - } - - // Field (9) 'ExecutionPayload' - { - buf = tail[o9:o10] - if b.ExecutionPayload == nil { - b.ExecutionPayload = new(generic.ExecutionPayload) - } - if err = b.ExecutionPayload.UnmarshalSSZ(buf); err != nil { - return err - } - } - - // Field (10) 'BlsToExecutionChanges' - { - buf = tail[o10:o11] - num, err := ssz.DivideInt2(len(buf), 172, 16) - if err != nil { - return err - } - b.BlsToExecutionChanges = make([]*generic.SignedBLSToExecutionChange, num) - for ii := 0; ii < num; ii++ { - if b.BlsToExecutionChanges[ii] == nil { - b.BlsToExecutionChanges[ii] = new(generic.SignedBLSToExecutionChange) - } - if err = b.BlsToExecutionChanges[ii].UnmarshalSSZ(buf[ii*172 : (ii+1)*172]); err != nil { - return err - } - } - } - - // Field (11) 'BlobKzgCommitments' - { - buf = tail[o11:o12] - num, err := ssz.DivideInt2(len(buf), 48, 4096) - if err != nil { - return err - } - b.BlobKzgCommitments = make([][48]byte, num) - for ii := 0; ii < num; ii++ { - copy(b.BlobKzgCommitments[ii][:], buf[ii*48:(ii+1)*48]) - } - } - - // Field (12) 'ExecutionRequests' - { - buf = tail[o12:] - if b.ExecutionRequests == nil { - b.ExecutionRequests = new(ExecutionRequests) - } - if err = b.ExecutionRequests.UnmarshalSSZ(buf); err != nil { - return err - } - } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the BeaconBlockBody object -func (b *BeaconBlockBody) SizeSSZ() (size int) { - size = 396 - - // Field (3) 'ProposerSlashings' - size += len(b.ProposerSlashings) * 416 - - // Field (4) 'AttesterSlashings' - for ii := 0; ii < len(b.AttesterSlashings); ii++ { - size += 4 - size += b.AttesterSlashings[ii].SizeSSZ() - } - - // Field (5) 'Attestations' - for ii := 0; ii < len(b.Attestations); ii++ { - size += 4 - size += b.Attestations[ii].SizeSSZ() - } - - // Field (6) 'Deposits' - size += len(b.Deposits) * 1240 - - // Field (7) 'VoluntaryExits' - size += len(b.VoluntaryExits) * 112 - - // Field (9) 'ExecutionPayload' - if b.ExecutionPayload == nil { - b.ExecutionPayload = new(generic.ExecutionPayload) - } - size += b.ExecutionPayload.SizeSSZ() - - // Field (10) 'BlsToExecutionChanges' - size += len(b.BlsToExecutionChanges) * 172 - - // Field (11) 'BlobKzgCommitments' - size += len(b.BlobKzgCommitments) * 48 - - // Field (12) 'ExecutionRequests' - if b.ExecutionRequests == nil { - b.ExecutionRequests = new(ExecutionRequests) - } - size += b.ExecutionRequests.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the BeaconBlockBody object -func (b *BeaconBlockBody) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) -} - -// HashTreeRootWith ssz hashes the BeaconBlockBody object with a hasher -func (b *BeaconBlockBody) HashTreeRootWith(hh ssz.HashWalker) (err error) { - indx := hh.Index() - - // Field (0) 'RandaoReveal' - if size := len(b.RandaoReveal); size != 96 { - err = ssz.ErrBytesLengthFn("BeaconBlockBody.RandaoReveal", size, 96) - return - } - hh.PutBytes(b.RandaoReveal) - - // Field (1) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(generic.Eth1Data) - } - if err = b.Eth1Data.HashTreeRootWith(hh); err != nil { - return - } - - // Field (2) 'Graffiti' - hh.PutBytes(b.Graffiti[:]) - - // Field (3) 'ProposerSlashings' - { - subIndx := hh.Index() - num := uint64(len(b.ProposerSlashings)) - if num > 16 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range b.ProposerSlashings { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } - } - hh.MerkleizeWithMixin(subIndx, num, 16) - } - - // Field (4) 'AttesterSlashings' - { - subIndx := hh.Index() - num := uint64(len(b.AttesterSlashings)) - if num > 1 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range b.AttesterSlashings { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } - } - hh.MerkleizeWithMixin(subIndx, num, 1) - } - - // Field (5) 'Attestations' - { - subIndx := hh.Index() - num := uint64(len(b.Attestations)) - if num > 8 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range b.Attestations { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } - } - hh.MerkleizeWithMixin(subIndx, num, 8) - } - - // Field (6) 'Deposits' - { - subIndx := hh.Index() - num := uint64(len(b.Deposits)) - if num > 16 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range b.Deposits { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } - } - hh.MerkleizeWithMixin(subIndx, num, 16) - } - - // Field (7) 'VoluntaryExits' - { - subIndx := hh.Index() - num := uint64(len(b.VoluntaryExits)) - if num > 16 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range b.VoluntaryExits { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } - } - hh.MerkleizeWithMixin(subIndx, num, 16) - } - - // Field (8) 'SyncAggregate' - if b.SyncAggregate == nil { - b.SyncAggregate = new(generic.SyncAggregate) - } - if err = b.SyncAggregate.HashTreeRootWith(hh); err != nil { - return - } - - // Field (9) 'ExecutionPayload' - if err = b.ExecutionPayload.HashTreeRootWith(hh); err != nil { - return - } - - // Field (10) 'BlsToExecutionChanges' - { - subIndx := hh.Index() - num := uint64(len(b.BlsToExecutionChanges)) - if num > 16 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range b.BlsToExecutionChanges { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } - } - hh.MerkleizeWithMixin(subIndx, num, 16) - } - - // Field (11) 'BlobKzgCommitments' - { - if size := len(b.BlobKzgCommitments); size > 4096 { - err = ssz.ErrListTooBigFn("BeaconBlockBody.BlobKzgCommitments", size, 4096) - return - } - subIndx := hh.Index() - for _, i := range b.BlobKzgCommitments { - hh.PutBytes(i[:]) - } - numItems := uint64(len(b.BlobKzgCommitments)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) - } - - // Field (12) 'ExecutionRequests' - if err = b.ExecutionRequests.HashTreeRootWith(hh); err != nil { - return - } - - hh.Merkleize(indx) - return -} - -// GetTree ssz hashes the BeaconBlockBody object -func (b *BeaconBlockBody) GetTree() (*ssz.Node, error) { - return ssz.ProofTree(b) -} - -// MarshalSSZ ssz marshals the Attestation object -func (a *Attestation) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(a) -} - -// MarshalSSZTo ssz marshals the Attestation object to a target array -func (a *Attestation) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(236) - - // Offset (0) 'AggregationBits' - dst = ssz.WriteOffset(dst, offset) - - // Field (1) 'Data' - if a.Data == nil { - a.Data = new(generic.AttestationData) - } - if dst, err = a.Data.MarshalSSZTo(dst); err != nil { - return - } - - // Field (2) 'Signature' - dst = append(dst, a.Signature[:]...) - - // Field (3) 'CommitteeBits' - if size := len(a.CommitteeBits); size != 8 { - err = ssz.ErrBytesLengthFn("Attestation.CommitteeBits", size, 8) - return - } - dst = append(dst, a.CommitteeBits...) - - // Field (0) 'AggregationBits' - if size := len(a.AggregationBits); size > 131072 { - err = ssz.ErrBytesLengthFn("Attestation.AggregationBits", size, 131072) - return - } - dst = append(dst, a.AggregationBits...) - - return -} - -// UnmarshalSSZ ssz unmarshals the Attestation object -func (a *Attestation) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 236 { - return ssz.ErrSize - } - - tail := buf - var o0 uint64 - - // Offset (0) 'AggregationBits' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } - - if o0 != 236 { - return ssz.ErrInvalidVariableOffset - } - - // Field (1) 'Data' - if a.Data == nil { - a.Data = new(generic.AttestationData) - } - if err = a.Data.UnmarshalSSZ(buf[4:132]); err != nil { - return err - } - - // Field (2) 'Signature' - copy(a.Signature[:], buf[132:228]) - - // Field (3) 'CommitteeBits' - if cap(a.CommitteeBits) == 0 { - a.CommitteeBits = make([]byte, 0, len(buf[228:236])) - } - a.CommitteeBits = append(a.CommitteeBits, buf[228:236]...) - - // Field (0) 'AggregationBits' - { - buf = tail[o0:] - if err = ssz.ValidateBitlist(buf, 131072); err != nil { - return err - } - if cap(a.AggregationBits) == 0 { - a.AggregationBits = make([]byte, 0, len(buf)) - } - a.AggregationBits = append(a.AggregationBits, buf...) - } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the Attestation object -func (a *Attestation) SizeSSZ() (size int) { - size = 236 - - // Field (0) 'AggregationBits' - size += len(a.AggregationBits) - - return -} - -// HashTreeRoot ssz hashes the Attestation object -func (a *Attestation) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(a) -} - -// HashTreeRootWith ssz hashes the Attestation object with a hasher -func (a *Attestation) HashTreeRootWith(hh ssz.HashWalker) (err error) { - indx := hh.Index() - - // Field (0) 'AggregationBits' - if len(a.AggregationBits) == 0 { - err = ssz.ErrEmptyBitlist - return - } - hh.PutBitlist(a.AggregationBits, 131072) - - // Field (1) 'Data' - if a.Data == nil { - a.Data = new(generic.AttestationData) - } - if err = a.Data.HashTreeRootWith(hh); err != nil { - return - } - - // Field (2) 'Signature' - hh.PutBytes(a.Signature[:]) - - // Field (3) 'CommitteeBits' - if size := len(a.CommitteeBits); size != 8 { - err = ssz.ErrBytesLengthFn("Attestation.CommitteeBits", size, 8) - return - } - hh.PutBytes(a.CommitteeBits) - - hh.Merkleize(indx) - return -} - -// GetTree ssz hashes the Attestation object -func (a *Attestation) GetTree() (*ssz.Node, error) { - return ssz.ProofTree(a) -} - -// MarshalSSZ ssz marshals the ExecutionRequests object -func (e *ExecutionRequests) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(e) -} - -// MarshalSSZTo ssz marshals the ExecutionRequests object to a target array -func (e *ExecutionRequests) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(12) - - // Offset (0) 'Deposits' - dst = ssz.WriteOffset(dst, offset) - offset += len(e.Deposits) * 192 - - // Offset (1) 'Withdrawals' - dst = ssz.WriteOffset(dst, offset) - offset += len(e.Withdrawals) * 76 - - // Offset (2) 'Consolidations' - dst = ssz.WriteOffset(dst, offset) - - // Field (0) 'Deposits' - if size := len(e.Deposits); size > 8192 { - err = ssz.ErrListTooBigFn("ExecutionRequests.Deposits", size, 8192) - return - } - for ii := 0; ii < len(e.Deposits); ii++ { - if dst, err = e.Deposits[ii].MarshalSSZTo(dst); err != nil { - return - } - } - - // Field (1) 'Withdrawals' - if size := len(e.Withdrawals); size > 16 { - err = ssz.ErrListTooBigFn("ExecutionRequests.Withdrawals", size, 16) - return - } - for ii := 0; ii < len(e.Withdrawals); ii++ { - if dst, err = e.Withdrawals[ii].MarshalSSZTo(dst); err != nil { - return - } - } - - // Field (2) 'Consolidations' - if size := len(e.Consolidations); size > 2 { - err = ssz.ErrListTooBigFn("ExecutionRequests.Consolidations", size, 2) - return - } - for ii := 0; ii < len(e.Consolidations); ii++ { - if dst, err = e.Consolidations[ii].MarshalSSZTo(dst); err != nil { - return - } - } - - return -} - -// UnmarshalSSZ ssz unmarshals the ExecutionRequests object -func (e *ExecutionRequests) 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) 'Deposits' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } - - if o0 != 12 { - return ssz.ErrInvalidVariableOffset - } - - // Offset (1) 'Withdrawals' - if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 { - return ssz.ErrOffset - } - - // Offset (2) 'Consolidations' - if o2 = ssz.ReadOffset(buf[8:12]); o2 > size || o1 > o2 { - return ssz.ErrOffset - } - - // Field (0) 'Deposits' - { - buf = tail[o0:o1] - num, err := ssz.DivideInt2(len(buf), 192, 8192) - if err != nil { - return err - } - e.Deposits = make([]*DepositRequest, num) - for ii := 0; ii < num; ii++ { - if e.Deposits[ii] == nil { - e.Deposits[ii] = new(DepositRequest) - } - if err = e.Deposits[ii].UnmarshalSSZ(buf[ii*192 : (ii+1)*192]); err != nil { - return err - } - } - } - - // Field (1) 'Withdrawals' - { - buf = tail[o1:o2] - num, err := ssz.DivideInt2(len(buf), 76, 16) - if err != nil { - return err - } - e.Withdrawals = make([]*WithdrawalRequest, num) - for ii := 0; ii < num; ii++ { - if e.Withdrawals[ii] == nil { - e.Withdrawals[ii] = new(WithdrawalRequest) - } - if err = e.Withdrawals[ii].UnmarshalSSZ(buf[ii*76 : (ii+1)*76]); err != nil { - return err - } - } - } - - // Field (2) 'Consolidations' - { - buf = tail[o2:] - num, err := ssz.DivideInt2(len(buf), 116, 2) - if err != nil { - return err - } - e.Consolidations = make([]*ConsolidationRequest, num) - for ii := 0; ii < num; ii++ { - if e.Consolidations[ii] == nil { - e.Consolidations[ii] = new(ConsolidationRequest) - } - if err = e.Consolidations[ii].UnmarshalSSZ(buf[ii*116 : (ii+1)*116]); err != nil { - return err - } - } - } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the ExecutionRequests object -func (e *ExecutionRequests) SizeSSZ() (size int) { - size = 12 - - // Field (0) 'Deposits' - size += len(e.Deposits) * 192 - - // Field (1) 'Withdrawals' - size += len(e.Withdrawals) * 76 - - // Field (2) 'Consolidations' - size += len(e.Consolidations) * 116 - - return -} - -// HashTreeRoot ssz hashes the ExecutionRequests object -func (e *ExecutionRequests) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(e) -} - -// HashTreeRootWith ssz hashes the ExecutionRequests object with a hasher -func (e *ExecutionRequests) HashTreeRootWith(hh ssz.HashWalker) (err error) { - indx := hh.Index() - - // Field (0) 'Deposits' - { - subIndx := hh.Index() - num := uint64(len(e.Deposits)) - if num > 8192 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range e.Deposits { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } - } - hh.MerkleizeWithMixin(subIndx, num, 8192) - } - - // Field (1) 'Withdrawals' - { - subIndx := hh.Index() - num := uint64(len(e.Withdrawals)) - if num > 16 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range e.Withdrawals { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } - } - hh.MerkleizeWithMixin(subIndx, num, 16) - } - - // Field (2) 'Consolidations' - { - subIndx := hh.Index() - num := uint64(len(e.Consolidations)) - if num > 2 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range e.Consolidations { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } - } - hh.MerkleizeWithMixin(subIndx, num, 2) - } - - hh.Merkleize(indx) - return -} - -// GetTree ssz hashes the ExecutionRequests object -func (e *ExecutionRequests) GetTree() (*ssz.Node, error) { - return ssz.ProofTree(e) -} - -// MarshalSSZ ssz marshals the DepositRequest object -func (d *DepositRequest) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(d) -} - -// MarshalSSZTo ssz marshals the DepositRequest object to a target array -func (d *DepositRequest) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - - // Field (0) 'Pubkey' - if size := len(d.Pubkey); size != 48 { - err = ssz.ErrBytesLengthFn("DepositRequest.Pubkey", size, 48) - return - } - dst = append(dst, d.Pubkey...) - - // Field (1) 'WithdrawalCredentials' - if size := len(d.WithdrawalCredentials); size != 32 { - err = ssz.ErrBytesLengthFn("DepositRequest.WithdrawalCredentials", size, 32) - return - } - dst = append(dst, d.WithdrawalCredentials...) - - // Field (2) 'Amount' - dst = ssz.MarshalUint64(dst, d.Amount) - - // Field (3) 'Signature' - if size := len(d.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("DepositRequest.Signature", size, 96) - return - } - dst = append(dst, d.Signature...) - - // Field (4) 'Index' - dst = ssz.MarshalUint64(dst, d.Index) - - return -} - -// UnmarshalSSZ ssz unmarshals the DepositRequest object -func (d *DepositRequest) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size != 192 { - return ssz.ErrSize - } - - // Field (0) 'Pubkey' - if cap(d.Pubkey) == 0 { - d.Pubkey = make([]byte, 0, len(buf[0:48])) - } - d.Pubkey = append(d.Pubkey, buf[0:48]...) - - // Field (1) 'WithdrawalCredentials' - if cap(d.WithdrawalCredentials) == 0 { - d.WithdrawalCredentials = make([]byte, 0, len(buf[48:80])) - } - d.WithdrawalCredentials = append(d.WithdrawalCredentials, buf[48:80]...) - - // Field (2) 'Amount' - d.Amount = ssz.UnmarshallUint64(buf[80:88]) - - // Field (3) 'Signature' - if cap(d.Signature) == 0 { - d.Signature = make([]byte, 0, len(buf[88:184])) - } - d.Signature = append(d.Signature, buf[88:184]...) - - // Field (4) 'Index' - d.Index = ssz.UnmarshallUint64(buf[184:192]) - - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the DepositRequest object -func (d *DepositRequest) SizeSSZ() (size int) { - size = 192 - return -} - -// HashTreeRoot ssz hashes the DepositRequest object -func (d *DepositRequest) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(d) -} - -// HashTreeRootWith ssz hashes the DepositRequest object with a hasher -func (d *DepositRequest) HashTreeRootWith(hh ssz.HashWalker) (err error) { - indx := hh.Index() - - // Field (0) 'Pubkey' - if size := len(d.Pubkey); size != 48 { - err = ssz.ErrBytesLengthFn("DepositRequest.Pubkey", size, 48) - return - } - hh.PutBytes(d.Pubkey) - - // Field (1) 'WithdrawalCredentials' - if size := len(d.WithdrawalCredentials); size != 32 { - err = ssz.ErrBytesLengthFn("DepositRequest.WithdrawalCredentials", size, 32) - return - } - hh.PutBytes(d.WithdrawalCredentials) - - // Field (2) 'Amount' - hh.PutUint64(d.Amount) - - // Field (3) 'Signature' - if size := len(d.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("DepositRequest.Signature", size, 96) - return - } - hh.PutBytes(d.Signature) - - // Field (4) 'Index' - hh.PutUint64(d.Index) - - hh.Merkleize(indx) - return -} - -// GetTree ssz hashes the DepositRequest object -func (d *DepositRequest) GetTree() (*ssz.Node, error) { - return ssz.ProofTree(d) -} - -// MarshalSSZ ssz marshals the WithdrawalRequest object -func (w *WithdrawalRequest) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(w) -} - -// MarshalSSZTo ssz marshals the WithdrawalRequest object to a target array -func (w *WithdrawalRequest) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - - // Field (0) 'SourceAddress' - if size := len(w.SourceAddress); size != 20 { - err = ssz.ErrBytesLengthFn("WithdrawalRequest.SourceAddress", size, 20) - return - } - dst = append(dst, w.SourceAddress...) - - // Field (1) 'ValidatorPubkey' - if size := len(w.ValidatorPubkey); size != 48 { - err = ssz.ErrBytesLengthFn("WithdrawalRequest.ValidatorPubkey", size, 48) - return - } - dst = append(dst, w.ValidatorPubkey...) - - // Field (2) 'Amount' - dst = ssz.MarshalUint64(dst, w.Amount) - - return -} - -// UnmarshalSSZ ssz unmarshals the WithdrawalRequest object -func (w *WithdrawalRequest) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size != 76 { - return ssz.ErrSize - } - - // Field (0) 'SourceAddress' - if cap(w.SourceAddress) == 0 { - w.SourceAddress = make([]byte, 0, len(buf[0:20])) - } - w.SourceAddress = append(w.SourceAddress, buf[0:20]...) - - // Field (1) 'ValidatorPubkey' - if cap(w.ValidatorPubkey) == 0 { - w.ValidatorPubkey = make([]byte, 0, len(buf[20:68])) - } - w.ValidatorPubkey = append(w.ValidatorPubkey, buf[20:68]...) - - // Field (2) 'Amount' - w.Amount = ssz.UnmarshallUint64(buf[68:76]) - - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the WithdrawalRequest object -func (w *WithdrawalRequest) SizeSSZ() (size int) { - size = 76 - return -} - -// HashTreeRoot ssz hashes the WithdrawalRequest object -func (w *WithdrawalRequest) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(w) -} - -// HashTreeRootWith ssz hashes the WithdrawalRequest object with a hasher -func (w *WithdrawalRequest) HashTreeRootWith(hh ssz.HashWalker) (err error) { - indx := hh.Index() - - // Field (0) 'SourceAddress' - if size := len(w.SourceAddress); size != 20 { - err = ssz.ErrBytesLengthFn("WithdrawalRequest.SourceAddress", size, 20) - return - } - hh.PutBytes(w.SourceAddress) - - // Field (1) 'ValidatorPubkey' - if size := len(w.ValidatorPubkey); size != 48 { - err = ssz.ErrBytesLengthFn("WithdrawalRequest.ValidatorPubkey", size, 48) - return - } - hh.PutBytes(w.ValidatorPubkey) - - // Field (2) 'Amount' - hh.PutUint64(w.Amount) - - hh.Merkleize(indx) - return -} - -// GetTree ssz hashes the WithdrawalRequest object -func (w *WithdrawalRequest) GetTree() (*ssz.Node, error) { - return ssz.ProofTree(w) -} - -// MarshalSSZ ssz marshals the ConsolidationRequest object -func (c *ConsolidationRequest) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(c) -} - -// MarshalSSZTo ssz marshals the ConsolidationRequest object to a target array -func (c *ConsolidationRequest) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - - // Field (0) 'SourceAddress' - if size := len(c.SourceAddress); size != 20 { - err = ssz.ErrBytesLengthFn("ConsolidationRequest.SourceAddress", size, 20) - return - } - dst = append(dst, c.SourceAddress...) - - // Field (1) 'SourcePubkey' - if size := len(c.SourcePubkey); size != 48 { - err = ssz.ErrBytesLengthFn("ConsolidationRequest.SourcePubkey", size, 48) - return - } - dst = append(dst, c.SourcePubkey...) - - // Field (2) 'TargetPubkey' - if size := len(c.TargetPubkey); size != 48 { - err = ssz.ErrBytesLengthFn("ConsolidationRequest.TargetPubkey", size, 48) - return - } - dst = append(dst, c.TargetPubkey...) - - return -} - -// UnmarshalSSZ ssz unmarshals the ConsolidationRequest object -func (c *ConsolidationRequest) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size != 116 { - return ssz.ErrSize - } - - // Field (0) 'SourceAddress' - if cap(c.SourceAddress) == 0 { - c.SourceAddress = make([]byte, 0, len(buf[0:20])) - } - c.SourceAddress = append(c.SourceAddress, buf[0:20]...) - - // Field (1) 'SourcePubkey' - if cap(c.SourcePubkey) == 0 { - c.SourcePubkey = make([]byte, 0, len(buf[20:68])) - } - c.SourcePubkey = append(c.SourcePubkey, buf[20:68]...) - - // Field (2) 'TargetPubkey' - if cap(c.TargetPubkey) == 0 { - c.TargetPubkey = make([]byte, 0, len(buf[68:116])) - } - c.TargetPubkey = append(c.TargetPubkey, buf[68:116]...) - - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the ConsolidationRequest object -func (c *ConsolidationRequest) SizeSSZ() (size int) { - size = 116 - return -} - -// HashTreeRoot ssz hashes the ConsolidationRequest object -func (c *ConsolidationRequest) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(c) -} - -// HashTreeRootWith ssz hashes the ConsolidationRequest object with a hasher -func (c *ConsolidationRequest) HashTreeRootWith(hh ssz.HashWalker) (err error) { - indx := hh.Index() - - // Field (0) 'SourceAddress' - if size := len(c.SourceAddress); size != 20 { - err = ssz.ErrBytesLengthFn("ConsolidationRequest.SourceAddress", size, 20) - return - } - hh.PutBytes(c.SourceAddress) - - // Field (1) 'SourcePubkey' - if size := len(c.SourcePubkey); size != 48 { - err = ssz.ErrBytesLengthFn("ConsolidationRequest.SourcePubkey", size, 48) - return - } - hh.PutBytes(c.SourcePubkey) - - // Field (2) 'TargetPubkey' - if size := len(c.TargetPubkey); size != 48 { - err = ssz.ErrBytesLengthFn("ConsolidationRequest.TargetPubkey", size, 48) - return - } - hh.PutBytes(c.TargetPubkey) - - hh.Merkleize(indx) - return -} - -// GetTree ssz hashes the ConsolidationRequest object -func (c *ConsolidationRequest) GetTree() (*ssz.Node, error) { - return ssz.ProofTree(c) -} - -// MarshalSSZ ssz marshals the AttesterSlashing object -func (a *AttesterSlashing) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(a) -} - -// MarshalSSZTo ssz marshals the AttesterSlashing object to a target array -func (a *AttesterSlashing) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(8) - - // Offset (0) 'Attestation1' - dst = ssz.WriteOffset(dst, offset) - if a.Attestation1 == nil { - a.Attestation1 = new(IndexedAttestation) - } - offset += a.Attestation1.SizeSSZ() - - // Offset (1) 'Attestation2' - dst = ssz.WriteOffset(dst, offset) - - // Field (0) 'Attestation1' - if dst, err = a.Attestation1.MarshalSSZTo(dst); err != nil { - return - } - - // Field (1) 'Attestation2' - if dst, err = a.Attestation2.MarshalSSZTo(dst); err != nil { - return - } - - return -} - -// UnmarshalSSZ ssz unmarshals the AttesterSlashing object -func (a *AttesterSlashing) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 8 { - return ssz.ErrSize - } - - tail := buf - var o0, o1 uint64 - - // Offset (0) 'Attestation1' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } - - if o0 != 8 { - return ssz.ErrInvalidVariableOffset - } - - // Offset (1) 'Attestation2' - if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 { - return ssz.ErrOffset - } - - // Field (0) 'Attestation1' - { - buf = tail[o0:o1] - if a.Attestation1 == nil { - a.Attestation1 = new(IndexedAttestation) - } - if err = a.Attestation1.UnmarshalSSZ(buf); err != nil { - return err - } - } - - // Field (1) 'Attestation2' - { - buf = tail[o1:] - if a.Attestation2 == nil { - a.Attestation2 = new(IndexedAttestation) - } - if err = a.Attestation2.UnmarshalSSZ(buf); err != nil { - return err - } - } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the AttesterSlashing object -func (a *AttesterSlashing) SizeSSZ() (size int) { - size = 8 - - // Field (0) 'Attestation1' - if a.Attestation1 == nil { - a.Attestation1 = new(IndexedAttestation) - } - size += a.Attestation1.SizeSSZ() - - // Field (1) 'Attestation2' - if a.Attestation2 == nil { - a.Attestation2 = new(IndexedAttestation) - } - size += a.Attestation2.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the AttesterSlashing object -func (a *AttesterSlashing) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(a) -} - -// HashTreeRootWith ssz hashes the AttesterSlashing object with a hasher -func (a *AttesterSlashing) HashTreeRootWith(hh ssz.HashWalker) (err error) { - indx := hh.Index() - - // Field (0) 'Attestation1' - if err = a.Attestation1.HashTreeRootWith(hh); err != nil { - return - } - - // Field (1) 'Attestation2' - if err = a.Attestation2.HashTreeRootWith(hh); err != nil { - return - } - - hh.Merkleize(indx) - return -} - -// GetTree ssz hashes the AttesterSlashing object -func (a *AttesterSlashing) GetTree() (*ssz.Node, error) { - return ssz.ProofTree(a) -} - -// MarshalSSZ ssz marshals the IndexedAttestation object -func (i *IndexedAttestation) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(i) -} - -// MarshalSSZTo ssz marshals the IndexedAttestation object to a target array -func (i *IndexedAttestation) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(228) - - // Offset (0) 'AttestingIndices' - dst = ssz.WriteOffset(dst, offset) - - // Field (1) 'Data' - if i.Data == nil { - i.Data = new(generic.AttestationData) - } - if dst, err = i.Data.MarshalSSZTo(dst); err != nil { - return - } - - // Field (2) 'Signature' - if size := len(i.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("IndexedAttestation.Signature", size, 96) - return - } - dst = append(dst, i.Signature...) - - // Field (0) 'AttestingIndices' - if size := len(i.AttestingIndices); size > 131072 { - err = ssz.ErrListTooBigFn("IndexedAttestation.AttestingIndices", size, 131072) - return - } - for ii := 0; ii < len(i.AttestingIndices); ii++ { - dst = ssz.MarshalUint64(dst, i.AttestingIndices[ii]) - } - - return -} - -// UnmarshalSSZ ssz unmarshals the IndexedAttestation object -func (i *IndexedAttestation) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 228 { - return ssz.ErrSize - } - - tail := buf - var o0 uint64 - - // Offset (0) 'AttestingIndices' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } - - if o0 != 228 { - return ssz.ErrInvalidVariableOffset - } - - // Field (1) 'Data' - if i.Data == nil { - i.Data = new(generic.AttestationData) - } - if err = i.Data.UnmarshalSSZ(buf[4:132]); err != nil { - return err - } - - // Field (2) 'Signature' - if cap(i.Signature) == 0 { - i.Signature = make([]byte, 0, len(buf[132:228])) - } - i.Signature = append(i.Signature, buf[132:228]...) - - // Field (0) 'AttestingIndices' - { - buf = tail[o0:] - num, err := ssz.DivideInt2(len(buf), 8, 131072) - if err != nil { - return err - } - i.AttestingIndices = ssz.ExtendUint64(i.AttestingIndices, num) - for ii := 0; ii < num; ii++ { - i.AttestingIndices[ii] = ssz.UnmarshallUint64(buf[ii*8 : (ii+1)*8]) - } - } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the IndexedAttestation object -func (i *IndexedAttestation) SizeSSZ() (size int) { - size = 228 - - // Field (0) 'AttestingIndices' - size += len(i.AttestingIndices) * 8 - - return -} - -// HashTreeRoot ssz hashes the IndexedAttestation object -func (i *IndexedAttestation) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(i) -} - -// HashTreeRootWith ssz hashes the IndexedAttestation object with a hasher -func (i *IndexedAttestation) HashTreeRootWith(hh ssz.HashWalker) (err error) { - indx := hh.Index() - - // Field (0) 'AttestingIndices' - { - if size := len(i.AttestingIndices); size > 131072 { - err = ssz.ErrListTooBigFn("IndexedAttestation.AttestingIndices", size, 131072) - return - } - subIndx := hh.Index() - for _, i := range i.AttestingIndices { - hh.AppendUint64(i) - } - hh.FillUpTo32() - numItems := uint64(len(i.AttestingIndices)) - hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(131072, numItems, 8)) - } - - // Field (1) 'Data' - if i.Data == nil { - i.Data = new(generic.AttestationData) - } - if err = i.Data.HashTreeRootWith(hh); err != nil { - return - } - - // Field (2) 'Signature' - if size := len(i.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("IndexedAttestation.Signature", size, 96) - return - } - hh.PutBytes(i.Signature) - - hh.Merkleize(indx) - return -} - -// GetTree ssz hashes the IndexedAttestation object -func (i *IndexedAttestation) GetTree() (*ssz.Node, error) { - return ssz.ProofTree(i) -} diff --git a/shared/types/eth2/fork/fulu/fulu_generated.go b/shared/types/eth2/fork/fulu/fulu_generated.go new file mode 100644 index 000000000..328525ac1 --- /dev/null +++ b/shared/types/eth2/fork/fulu/fulu_generated.go @@ -0,0 +1,6591 @@ +// Code generated by dynamic-ssz. DO NOT EDIT. +// Hash: 5f59cc7d8dcb1215bccdcf57028b35122e8d3c3bf8840d1a5cc9752648497bcb +// Version: v1.3.2 (https://github.com/pk910/dynamic-ssz) +package fulu + +import ( + "encoding/binary" + "math/bits" + + "github.com/pk910/dynamic-ssz/hasher" + "github.com/pk910/dynamic-ssz/sszutils" + go_bitfield "github.com/prysmaticlabs/go-bitfield" + "github.com/rocket-pool/smartnode/shared/types/eth2/generic" +) + +var _ = sszutils.ErrListTooBig + +var _ = sszutils.Annotate[BeaconState](`ssz-static:"false"`) +var _ = sszutils.Annotate[SignedBeaconBlock](`ssz-static:"false"`) +var _ = sszutils.Annotate[BeaconBlock](`ssz-static:"false"`) +var _ = sszutils.Annotate[BeaconBlockBody](`ssz-static:"false"`) +var _ = sszutils.Annotate[Attestation](`ssz-static:"false"`) +var _ = sszutils.Annotate[ExecutionRequests](`ssz-static:"false"`) +var _ = sszutils.Annotate[DepositRequest](`ssz-static:"true"`) +var _ = sszutils.Annotate[WithdrawalRequest](`ssz-static:"true"`) +var _ = sszutils.Annotate[ConsolidationRequest](`ssz-static:"true"`) +var _ = sszutils.Annotate[AttesterSlashing](`ssz-static:"false"`) +var _ = sszutils.Annotate[IndexedAttestation](`ssz-static:"false"`) + +// MarshalSSZTo marshals the *BeaconState to SSZ-encoded bytes, appending to the provided buffer. +func (t *BeaconState) MarshalSSZTo(buf []byte) (dst []byte, err error) { + dst = buf + zeroBytes := sszutils.ZeroBytes() + if t == nil { + t = new(BeaconState) + } + dstlen := len(dst) + { // Static Field #0 'GenesisTime' + dst = binary.LittleEndian.AppendUint64(dst, t.GenesisTime) + } + { // Static Field #1 'GenesisValidatorsRoot' + vlen := len(t.GenesisValidatorsRoot) + if vlen > 32 { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 32), "GenesisValidatorsRoot") + } + dst = append(dst, t.GenesisValidatorsRoot[:vlen]...) + if vlen < 32 { + dst = sszutils.AppendZeroPadding(dst, (32-vlen)*1) + } + } + { // Static Field #2 'Slot' + dst = binary.LittleEndian.AppendUint64(dst, t.Slot) + } + { // Static Field #3 'Fork' + t := t.Fork + if t == nil { + t = new(generic.Fork) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "Fork") + } + } + { // Static Field #4 'LatestBlockHeader' + t := t.LatestBlockHeader + if t == nil { + t = new(generic.BeaconBlockHeader) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "LatestBlockHeader") + } + } + { // Static Field #5 'BlockRoots' + t := &t.BlockRoots + dst = sszutils.MarshalFixedBytesSlice(dst, t[:8192]) + } + { // Static Field #6 'StateRoots' + t := &t.StateRoots + dst = sszutils.MarshalFixedBytesSlice(dst, t[:8192]) + } + // Offset Field #7 'HistoricalRoots' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #8 'Eth1Data' + t := t.Eth1Data + if t == nil { + t = new(generic.Eth1Data) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "Eth1Data") + } + } + // Offset Field #9 'Eth1DataVotes' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #10 'Eth1DepositIndex' + dst = binary.LittleEndian.AppendUint64(dst, t.Eth1DepositIndex) + } + // Offset Field #11 'Validators' + // Offset Field #12 'Balances' + dst = append(dst, 0, 0, 0, 0, 0, 0, 0, 0) + { // Static Field #13 'RandaoMixes' + t := t.RandaoMixes + vlen := len(t) + if vlen > 65536 { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 65536), "RandaoMixes") + } + for idx1 := range vlen { + vlen := len(t[idx1]) + if vlen > 32 { + return nil, sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, 32), "RandaoMixes[%d]", idx1) + } + dst = append(dst, t[idx1][:vlen]...) + if vlen < 32 { + dst = sszutils.AppendZeroPadding(dst, (32-vlen)*1) + } + } + if vlen < 65536 { + dst = sszutils.AppendZeroPadding(dst, (65536-vlen)*32) + } + } + { // Static Field #14 'Slashings' + t := t.Slashings + vlen := len(t) + if vlen > 8192 { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 8192), "Slashings") + } + dst = sszutils.MarshalUint64Slice(dst, t[:vlen]) + if vlen < 8192 { + dst = sszutils.AppendZeroPadding(dst, (8192-vlen)*8) + } + } + // Offset Field #15 'PreviousEpochParticipation' + // Offset Field #16 'CurrentEpochParticipation' + dst = append(dst, 0, 0, 0, 0, 0, 0, 0, 0) + { // Static Field #17 'JustificationBits' + dst = append(dst, t.JustificationBits[:1]...) + } + { // Static Field #18 'PreviousJustifiedCheckpoint' + t := t.PreviousJustifiedCheckpoint + if t == nil { + t = new(generic.Checkpoint) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } + } + { // Static Field #19 'CurrentJustifiedCheckpoint' + t := t.CurrentJustifiedCheckpoint + if t == nil { + t = new(generic.Checkpoint) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } + } + { // Static Field #20 'FinalizedCheckpoint' + t := t.FinalizedCheckpoint + if t == nil { + t = new(generic.Checkpoint) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "FinalizedCheckpoint") + } + } + // Offset Field #21 'InactivityScores' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #22 'CurrentSyncCommittee' + t := t.CurrentSyncCommittee + if t == nil { + t = new(generic.SyncCommittee) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "CurrentSyncCommittee") + } + } + { // Static Field #23 'NextSyncCommittee' + t := t.NextSyncCommittee + if t == nil { + t = new(generic.SyncCommittee) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "NextSyncCommittee") + } + } + // Offset Field #24 'LatestExecutionPayloadHeader' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #25 'NextWithdrawalIndex' + dst = binary.LittleEndian.AppendUint64(dst, t.NextWithdrawalIndex) + } + { // Static Field #26 'NextWithdrawalValidatorIndex' + dst = binary.LittleEndian.AppendUint64(dst, t.NextWithdrawalValidatorIndex) + } + // Offset Field #27 'HistoricalSummaries' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #28 'DepositRequestsStartIndex' + dst = binary.LittleEndian.AppendUint64(dst, t.DepositRequestsStartIndex) + } + { // Static Field #29 'DepositBalanceToConsume' + dst = binary.LittleEndian.AppendUint64(dst, t.DepositBalanceToConsume) + } + { // Static Field #30 'ExitBalanceToConsume' + dst = binary.LittleEndian.AppendUint64(dst, t.ExitBalanceToConsume) + } + { // Static Field #31 'EarliestExitEpoch' + dst = binary.LittleEndian.AppendUint64(dst, t.EarliestExitEpoch) + } + { // Static Field #32 'ConsolidationBalanceToConsume' + dst = binary.LittleEndian.AppendUint64(dst, t.ConsolidationBalanceToConsume) + } + { // Static Field #33 'EarliestConsolidationEpoch' + dst = binary.LittleEndian.AppendUint64(dst, t.EarliestConsolidationEpoch) + } + // Offset Field #34 'PendingDeposits' + // Offset Field #35 'PendingPartialWithdrawals' + // Offset Field #36 'PendingConsolidations' + dst = append(dst, zeroBytes[:12]...) + { // Static Field #37 'ProposerLookahead' + t := t.ProposerLookahead + vlen := len(t) + if vlen > 64 { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 64), "ProposerLookahead") + } + dst = sszutils.MarshalUint64Slice(dst, t[:vlen]) + if vlen < 64 { + dst = sszutils.AppendZeroPadding(dst, (64-vlen)*8) + } + } + { // Dynamic Field #7 'HistoricalRoots' + binary.LittleEndian.PutUint32(dst[dstlen+524464:], uint32(len(dst)-dstlen)) + t := t.HistoricalRoots + vlen := len(t) + if vlen > 16777216 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16777216), "HistoricalRoots") + } + for idx1 := range vlen { + vlen := len(t[idx1]) + if vlen > 32 { + return nil, sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, 32), "HistoricalRoots[%d]", idx1) + } + dst = append(dst, t[idx1][:vlen]...) + if vlen < 32 { + dst = sszutils.AppendZeroPadding(dst, (32-vlen)*1) + } + } + } + { // Dynamic Field #9 'Eth1DataVotes' + binary.LittleEndian.PutUint32(dst[dstlen+524540:], uint32(len(dst)-dstlen)) + t := t.Eth1DataVotes + vlen := len(t) + if vlen > 2048 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 2048), "Eth1DataVotes") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(generic.Eth1Data) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "Eth1DataVotes[%d]", idx1) + } + } + } + { // Dynamic Field #11 'Validators' + binary.LittleEndian.PutUint32(dst[dstlen+524552:], uint32(len(dst)-dstlen)) + t := t.Validators + vlen := len(t) + if vlen > 1099511627776 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1099511627776), "Validators") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(generic.Validator) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } + } + } + { // Dynamic Field #12 'Balances' + binary.LittleEndian.PutUint32(dst[dstlen+524556:], uint32(len(dst)-dstlen)) + t := t.Balances + vlen := len(t) + if vlen > 1099511627776 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1099511627776), "Balances") + } + dst = sszutils.MarshalUint64Slice(dst, t[:vlen]) + } + { // Dynamic Field #15 'PreviousEpochParticipation' + binary.LittleEndian.PutUint32(dst[dstlen+2687248:], uint32(len(dst)-dstlen)) + vlen := len(t.PreviousEpochParticipation) + if vlen > 1099511627776 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1099511627776), "PreviousEpochParticipation") + } + dst = append(dst, t.PreviousEpochParticipation[:]...) + } + { // Dynamic Field #16 'CurrentEpochParticipation' + binary.LittleEndian.PutUint32(dst[dstlen+2687252:], uint32(len(dst)-dstlen)) + vlen := len(t.CurrentEpochParticipation) + if vlen > 1099511627776 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1099511627776), "CurrentEpochParticipation") + } + dst = append(dst, t.CurrentEpochParticipation[:]...) + } + { // Dynamic Field #21 'InactivityScores' + binary.LittleEndian.PutUint32(dst[dstlen+2687377:], uint32(len(dst)-dstlen)) + t := t.InactivityScores + vlen := len(t) + if vlen > 1099511627776 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1099511627776), "InactivityScores") + } + dst = sszutils.MarshalUint64Slice(dst, t[:vlen]) + } + { // Dynamic Field #24 'LatestExecutionPayloadHeader' + binary.LittleEndian.PutUint32(dst[dstlen+2736629:], uint32(len(dst)-dstlen)) + t := t.LatestExecutionPayloadHeader + if t == nil { + t = new(generic.ExecutionPayloadHeader) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "LatestExecutionPayloadHeader") + } + } + { // Dynamic Field #27 'HistoricalSummaries' + binary.LittleEndian.PutUint32(dst[dstlen+2736649:], uint32(len(dst)-dstlen)) + t := t.HistoricalSummaries + vlen := len(t) + if vlen > 16777216 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16777216), "HistoricalSummaries") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(generic.HistoricalSummary) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "HistoricalSummaries[%d]", idx1) + } + } + } + { // Dynamic Field #34 'PendingDeposits' + binary.LittleEndian.PutUint32(dst[dstlen+2736701:], uint32(len(dst)-dstlen)) + t := t.PendingDeposits + vlen := len(t) + if vlen > 134217728 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 134217728), "PendingDeposits") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(generic.PendingDeposit) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "PendingDeposits[%d]", idx1) + } + } + } + { // Dynamic Field #35 'PendingPartialWithdrawals' + binary.LittleEndian.PutUint32(dst[dstlen+2736705:], uint32(len(dst)-dstlen)) + t := t.PendingPartialWithdrawals + vlen := len(t) + if vlen > 134217728 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 134217728), "PendingPartialWithdrawals") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(generic.PendingPartialWithdrawal) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "PendingPartialWithdrawals[%d]", idx1) + } + } + } + { // Dynamic Field #36 'PendingConsolidations' + binary.LittleEndian.PutUint32(dst[dstlen+2736709:], uint32(len(dst)-dstlen)) + t := t.PendingConsolidations + vlen := len(t) + if vlen > 262144 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 262144), "PendingConsolidations") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(generic.PendingConsolidation) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "PendingConsolidations[%d]", idx1) + } + } + } + return dst, nil +} + +// MarshalSSZDyn marshals the *BeaconState to SSZ-encoded bytes using dynamic specifications. +func (t *BeaconState) MarshalSSZDyn(_ sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + return t.MarshalSSZTo(buf) +} + +// MarshalSSZEncoder marshals the *BeaconState to the given SSZ encoder using dynamic specifications. +func (t *BeaconState) MarshalSSZEncoder(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + type encoderCtx struct { + ds sszutils.DynamicSpecs + exprs [0]uint64 + sizeFn1 func(ctx *encoderCtx, t [][]byte) (size int) + sizeFn10 func(ctx *encoderCtx, t []*generic.PendingDeposit) (size int) + sizeFn11 func(ctx *encoderCtx, t []*generic.PendingPartialWithdrawal) (size int) + sizeFn12 func(ctx *encoderCtx, t []*generic.PendingConsolidation) (size int) + sizeFn2 func(ctx *encoderCtx, t []*generic.Eth1Data) (size int) + sizeFn3 func(ctx *encoderCtx, t []*generic.Validator) (size int) + sizeFn4 func(ctx *encoderCtx, t []uint64) (size int) + sizeFn5 func(ctx *encoderCtx, t []byte) (size int) + sizeFn6 func(ctx *encoderCtx, t []byte) (size int) + sizeFn7 func(ctx *encoderCtx, t []uint64) (size int) + sizeFn8 func(ctx *encoderCtx, t *generic.ExecutionPayloadHeader) (size int) + sizeFn9 func(ctx *encoderCtx, t []*generic.HistoricalSummary) (size int) + } + ctx := &encoderCtx{ds: ds} + canSeek := enc.Seekable() + // size for [][]byte + ctx.sizeFn1 = func(ctx *encoderCtx, t [][]byte) (size int) { + size += len(t) * 32 + return size + } + // size for []*generic.Eth1Data + ctx.sizeFn2 = func(ctx *encoderCtx, t []*generic.Eth1Data) (size int) { + size += len(t) * 72 + return size + } + // size for []*generic.Validator + ctx.sizeFn3 = func(ctx *encoderCtx, t []*generic.Validator) (size int) { + size += len(t) * 121 + return size + } + // size for []uint64 + ctx.sizeFn4 = func(ctx *encoderCtx, t []uint64) (size int) { + size += len(t) * 8 + return size + } + // size for []byte + ctx.sizeFn5 = func(ctx *encoderCtx, t []byte) (size int) { + size += len(t) + return size + } + // size for []byte + ctx.sizeFn6 = func(ctx *encoderCtx, t []byte) (size int) { + size += len(t) + return size + } + // size for []uint64 + ctx.sizeFn7 = func(ctx *encoderCtx, t []uint64) (size int) { + size += len(t) * 8 + return size + } + // size for *generic.ExecutionPayloadHeader + ctx.sizeFn8 = func(ctx *encoderCtx, t *generic.ExecutionPayloadHeader) (size int) { + size += t.SizeSSZDyn(ds) + return size + } + // size for []*generic.HistoricalSummary + ctx.sizeFn9 = func(ctx *encoderCtx, t []*generic.HistoricalSummary) (size int) { + size += len(t) * 64 + return size + } + // size for []*generic.PendingDeposit + ctx.sizeFn10 = func(ctx *encoderCtx, t []*generic.PendingDeposit) (size int) { + size += len(t) * 192 + return size + } + // size for []*generic.PendingPartialWithdrawal + ctx.sizeFn11 = func(ctx *encoderCtx, t []*generic.PendingPartialWithdrawal) (size int) { + size += len(t) * 24 + return size + } + // size for []*generic.PendingConsolidation + ctx.sizeFn12 = func(ctx *encoderCtx, t []*generic.PendingConsolidation) (size int) { + size += len(t) * 16 + return size + } + if t == nil { + t = new(BeaconState) + } + dstlen := enc.GetPosition() + dynoff := uint32(2737225) + { // Field #0 'GenesisTime' + enc.EncodeUint64(t.GenesisTime) + } + { // Field #1 'GenesisValidatorsRoot' + vlen := len(t.GenesisValidatorsRoot) + if vlen > 32 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 32), "GenesisValidatorsRoot") + } + enc.EncodeBytes(t.GenesisValidatorsRoot[:vlen]) + if vlen < 32 { + enc.EncodeZeroPadding((32 - vlen) * 1) + } + } + { // Field #2 'Slot' + enc.EncodeUint64(t.Slot) + } + { // Field #3 'Fork' + t := t.Fork + if t == nil { + t = new(generic.Fork) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "Fork") + } else { + enc.SetBuffer(buf) + } + } + { // Field #4 'LatestBlockHeader' + t := t.LatestBlockHeader + if t == nil { + t = new(generic.BeaconBlockHeader) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") + } else { + enc.SetBuffer(buf) + } + } + { // Field #5 'BlockRoots' + t := &t.BlockRoots + for idx1 := range 8192 { + enc.EncodeBytes(t[idx1][:32]) + } + } + { // Field #6 'StateRoots' + t := &t.StateRoots + for idx1 := range 8192 { + enc.EncodeBytes(t[idx1][:32]) + } + } + // Offset #7 'HistoricalRoots' + offset7 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn1(ctx, t.HistoricalRoots)) + } + { // Field #8 'Eth1Data' + t := t.Eth1Data + if t == nil { + t = new(generic.Eth1Data) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "Eth1Data") + } else { + enc.SetBuffer(buf) + } + } + // Offset #9 'Eth1DataVotes' + offset9 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn2(ctx, t.Eth1DataVotes)) + } + { // Field #10 'Eth1DepositIndex' + enc.EncodeUint64(t.Eth1DepositIndex) + } + // Offset #11 'Validators' + offset11 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn3(ctx, t.Validators)) + } + // Offset #12 'Balances' + offset12 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn4(ctx, t.Balances)) + } + { // Field #13 'RandaoMixes' + t := t.RandaoMixes + vlen := len(t) + if vlen > 65536 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 65536), "RandaoMixes") + } + for idx1 := range vlen { + vlen := len(t[idx1]) + if vlen > 32 { + return sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, 32), "RandaoMixes[%d]", idx1) + } + enc.EncodeBytes(t[idx1][:vlen]) + if vlen < 32 { + enc.EncodeZeroPadding((32 - vlen) * 1) + } + } + if vlen < 65536 { + enc.EncodeZeroPadding((65536 - vlen) * 32) + } + } + { // Field #14 'Slashings' + t := t.Slashings + vlen := len(t) + if vlen > 8192 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 8192), "Slashings") + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + if vlen < 8192 { + enc.EncodeZeroPadding((8192 - vlen) * 8) + } + } + // Offset #15 'PreviousEpochParticipation' + offset15 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn5(ctx, t.PreviousEpochParticipation)) + } + // Offset #16 'CurrentEpochParticipation' + offset16 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn6(ctx, t.CurrentEpochParticipation)) + } + { // Field #17 'JustificationBits' + enc.EncodeBytes(t.JustificationBits[:1]) + } + { // Field #18 'PreviousJustifiedCheckpoint' + t := t.PreviousJustifiedCheckpoint + if t == nil { + t = new(generic.Checkpoint) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } else { + enc.SetBuffer(buf) + } + } + { // Field #19 'CurrentJustifiedCheckpoint' + t := t.CurrentJustifiedCheckpoint + if t == nil { + t = new(generic.Checkpoint) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } else { + enc.SetBuffer(buf) + } + } + { // Field #20 'FinalizedCheckpoint' + t := t.FinalizedCheckpoint + if t == nil { + t = new(generic.Checkpoint) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") + } else { + enc.SetBuffer(buf) + } + } + // Offset #21 'InactivityScores' + offset21 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn7(ctx, t.InactivityScores)) + } + { // Field #22 'CurrentSyncCommittee' + t := t.CurrentSyncCommittee + if t == nil { + t = new(generic.SyncCommittee) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "CurrentSyncCommittee") + } else { + enc.SetBuffer(buf) + } + } + { // Field #23 'NextSyncCommittee' + t := t.NextSyncCommittee + if t == nil { + t = new(generic.SyncCommittee) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "NextSyncCommittee") + } else { + enc.SetBuffer(buf) + } + } + // Offset #24 'LatestExecutionPayloadHeader' + offset24 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn8(ctx, t.LatestExecutionPayloadHeader)) + } + { // Field #25 'NextWithdrawalIndex' + enc.EncodeUint64(t.NextWithdrawalIndex) + } + { // Field #26 'NextWithdrawalValidatorIndex' + enc.EncodeUint64(t.NextWithdrawalValidatorIndex) + } + // Offset #27 'HistoricalSummaries' + offset27 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn9(ctx, t.HistoricalSummaries)) + } + { // Field #28 'DepositRequestsStartIndex' + enc.EncodeUint64(t.DepositRequestsStartIndex) + } + { // Field #29 'DepositBalanceToConsume' + enc.EncodeUint64(t.DepositBalanceToConsume) + } + { // Field #30 'ExitBalanceToConsume' + enc.EncodeUint64(t.ExitBalanceToConsume) + } + { // Field #31 'EarliestExitEpoch' + enc.EncodeUint64(t.EarliestExitEpoch) + } + { // Field #32 'ConsolidationBalanceToConsume' + enc.EncodeUint64(t.ConsolidationBalanceToConsume) + } + { // Field #33 'EarliestConsolidationEpoch' + enc.EncodeUint64(t.EarliestConsolidationEpoch) + } + // Offset #34 'PendingDeposits' + offset34 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn10(ctx, t.PendingDeposits)) + } + // Offset #35 'PendingPartialWithdrawals' + offset35 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn11(ctx, t.PendingPartialWithdrawals)) + } + // Offset #36 'PendingConsolidations' + offset36 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn12(ctx, t.PendingConsolidations)) + } + { // Field #37 'ProposerLookahead' + t := t.ProposerLookahead + vlen := len(t) + if vlen > 64 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 64), "ProposerLookahead") + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + if vlen < 64 { + enc.EncodeZeroPadding((64 - vlen) * 8) + } + } + { // Dynamic Field #7 'HistoricalRoots' + if canSeek { + enc.EncodeOffsetAt(offset7, uint32(enc.GetPosition()-dstlen)) + } + t := t.HistoricalRoots + vlen := len(t) + if vlen > 16777216 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16777216), "HistoricalRoots") + } + for idx1 := range vlen { + vlen := len(t[idx1]) + if vlen > 32 { + return sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, 32), "HistoricalRoots[%d]", idx1) + } + enc.EncodeBytes(t[idx1][:vlen]) + if vlen < 32 { + enc.EncodeZeroPadding((32 - vlen) * 1) + } + } + } + { // Dynamic Field #9 'Eth1DataVotes' + if canSeek { + enc.EncodeOffsetAt(offset9, uint32(enc.GetPosition()-dstlen)) + } + t := t.Eth1DataVotes + vlen := len(t) + if vlen > 2048 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 2048), "Eth1DataVotes") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(generic.Eth1Data) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "Eth1DataVotes[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #11 'Validators' + if canSeek { + enc.EncodeOffsetAt(offset11, uint32(enc.GetPosition()-dstlen)) + } + t := t.Validators + vlen := len(t) + if vlen > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1099511627776), "Validators") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(generic.Validator) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #12 'Balances' + if canSeek { + enc.EncodeOffsetAt(offset12, uint32(enc.GetPosition()-dstlen)) + } + t := t.Balances + vlen := len(t) + if vlen > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1099511627776), "Balances") + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + } + { // Dynamic Field #15 'PreviousEpochParticipation' + if canSeek { + enc.EncodeOffsetAt(offset15, uint32(enc.GetPosition()-dstlen)) + } + vlen := len(t.PreviousEpochParticipation) + if vlen > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1099511627776), "PreviousEpochParticipation") + } + enc.EncodeBytes(t.PreviousEpochParticipation[:]) + } + { // Dynamic Field #16 'CurrentEpochParticipation' + if canSeek { + enc.EncodeOffsetAt(offset16, uint32(enc.GetPosition()-dstlen)) + } + vlen := len(t.CurrentEpochParticipation) + if vlen > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1099511627776), "CurrentEpochParticipation") + } + enc.EncodeBytes(t.CurrentEpochParticipation[:]) + } + { // Dynamic Field #21 'InactivityScores' + if canSeek { + enc.EncodeOffsetAt(offset21, uint32(enc.GetPosition()-dstlen)) + } + t := t.InactivityScores + vlen := len(t) + if vlen > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1099511627776), "InactivityScores") + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + } + { // Dynamic Field #24 'LatestExecutionPayloadHeader' + if canSeek { + enc.EncodeOffsetAt(offset24, uint32(enc.GetPosition()-dstlen)) + } + t := t.LatestExecutionPayloadHeader + if t == nil { + t = new(generic.ExecutionPayloadHeader) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "LatestExecutionPayloadHeader") + } else { + enc.SetBuffer(buf) + } + } + { // Dynamic Field #27 'HistoricalSummaries' + if canSeek { + enc.EncodeOffsetAt(offset27, uint32(enc.GetPosition()-dstlen)) + } + t := t.HistoricalSummaries + vlen := len(t) + if vlen > 16777216 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16777216), "HistoricalSummaries") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(generic.HistoricalSummary) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "HistoricalSummaries[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #34 'PendingDeposits' + if canSeek { + enc.EncodeOffsetAt(offset34, uint32(enc.GetPosition()-dstlen)) + } + t := t.PendingDeposits + vlen := len(t) + if vlen > 134217728 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 134217728), "PendingDeposits") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(generic.PendingDeposit) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "PendingDeposits[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #35 'PendingPartialWithdrawals' + if canSeek { + enc.EncodeOffsetAt(offset35, uint32(enc.GetPosition()-dstlen)) + } + t := t.PendingPartialWithdrawals + vlen := len(t) + if vlen > 134217728 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 134217728), "PendingPartialWithdrawals") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(generic.PendingPartialWithdrawal) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "PendingPartialWithdrawals[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #36 'PendingConsolidations' + if canSeek { + enc.EncodeOffsetAt(offset36, uint32(enc.GetPosition()-dstlen)) + } + t := t.PendingConsolidations + vlen := len(t) + if vlen > 262144 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 262144), "PendingConsolidations") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(generic.PendingConsolidation) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "PendingConsolidations[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + return nil +} + +// UnmarshalSSZ unmarshals the *BeaconState from SSZ-encoded bytes. +func (t *BeaconState) UnmarshalSSZ(buf []byte) (err error) { + buflen := len(buf) + if buflen < 2737225 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 2737225) + } + { // Field #0 'GenesisTime' (static) + buf := buf[0:8] + t.GenesisTime = binary.LittleEndian.Uint64(buf) + } + { // Field #1 'GenesisValidatorsRoot' (static) + buf := buf[8:40] + t.GenesisValidatorsRoot = sszutils.ExpandSlice(t.GenesisValidatorsRoot, 32) + copy(t.GenesisValidatorsRoot[:], buf) + } + { // Field #2 'Slot' (static) + buf := buf[40:48] + t.Slot = binary.LittleEndian.Uint64(buf) + } + { // Field #3 'Fork' (static) + buf := buf[48:64] + if t.Fork == nil { + t.Fork = new(generic.Fork) + } + if err = t.Fork.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "Fork") + } + } + { // Field #4 'LatestBlockHeader' (static) + buf := buf[64:176] + if t.LatestBlockHeader == nil { + t.LatestBlockHeader = new(generic.BeaconBlockHeader) + } + if err = t.LatestBlockHeader.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") + } + } + { // Field #5 'BlockRoots' (static) + buf := buf[176:262320] + val1 := t.BlockRoots + sszutils.UnmarshalFixedBytesSlice(val1[:8192], buf) + t.BlockRoots = val1 + } + { // Field #6 'StateRoots' (static) + buf := buf[262320:524464] + val2 := t.StateRoots + sszutils.UnmarshalFixedBytesSlice(val2[:8192], buf) + t.StateRoots = val2 + } + // Field #7 'HistoricalRoots' (offset) + offset7 := int(binary.LittleEndian.Uint32(buf[524464:524468])) + if offset7 != 2737225 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset7, 2737225), "HistoricalRoots:o") + } + { // Field #8 'Eth1Data' (static) + buf := buf[524468:524540] + if t.Eth1Data == nil { + t.Eth1Data = new(generic.Eth1Data) + } + if err = t.Eth1Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "Eth1Data") + } + } + // Field #9 'Eth1DataVotes' (offset) + offset9 := int(binary.LittleEndian.Uint32(buf[524540:524544])) + if offset9 < offset7 || offset9 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset9, offset7, buflen), "Eth1DataVotes:o") + } + { // Field #10 'Eth1DepositIndex' (static) + buf := buf[524544:524552] + t.Eth1DepositIndex = binary.LittleEndian.Uint64(buf) + } + // Field #11 'Validators' (offset) + offset11 := int(binary.LittleEndian.Uint32(buf[524552:524556])) + if offset11 < offset9 || offset11 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset11, offset9, buflen), "Validators:o") + } + // Field #12 'Balances' (offset) + offset12 := int(binary.LittleEndian.Uint32(buf[524556:524560])) + if offset12 < offset11 || offset12 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset12, offset11, buflen), "Balances:o") + } + { // Field #13 'RandaoMixes' (static) + buf := buf[524560:2621712] + val3 := t.RandaoMixes + val3 = sszutils.ExpandSlice(val3, 65536) + for idx1 := range 65536 { + buf := buf[32*idx1 : 32*(idx1+1)] + val3[idx1] = sszutils.ExpandSlice(val3[idx1], 32) + copy(val3[idx1][:], buf) + } + t.RandaoMixes = val3 + } + { // Field #14 'Slashings' (static) + buf := buf[2621712:2687248] + val4 := t.Slashings + val4 = sszutils.ExpandSlice(val4, 8192) + sszutils.UnmarshalUint64Slice(val4[:8192], buf) + t.Slashings = val4 + } + // Field #15 'PreviousEpochParticipation' (offset) + offset15 := int(binary.LittleEndian.Uint32(buf[2687248:2687252])) + if offset15 < offset12 || offset15 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset15, offset12, buflen), "PreviousEpochParticipation:o") + } + // Field #16 'CurrentEpochParticipation' (offset) + offset16 := int(binary.LittleEndian.Uint32(buf[2687252:2687256])) + if offset16 < offset15 || offset16 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset16, offset15, buflen), "CurrentEpochParticipation:o") + } + { // Field #17 'JustificationBits' (static) + buf := buf[2687256:2687257] + copy(t.JustificationBits[:], buf) + } + { // Field #18 'PreviousJustifiedCheckpoint' (static) + buf := buf[2687257:2687297] + if t.PreviousJustifiedCheckpoint == nil { + t.PreviousJustifiedCheckpoint = new(generic.Checkpoint) + } + if err = t.PreviousJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } + } + { // Field #19 'CurrentJustifiedCheckpoint' (static) + buf := buf[2687297:2687337] + if t.CurrentJustifiedCheckpoint == nil { + t.CurrentJustifiedCheckpoint = new(generic.Checkpoint) + } + if err = t.CurrentJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } + } + { // Field #20 'FinalizedCheckpoint' (static) + buf := buf[2687337:2687377] + if t.FinalizedCheckpoint == nil { + t.FinalizedCheckpoint = new(generic.Checkpoint) + } + if err = t.FinalizedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") + } + } + // Field #21 'InactivityScores' (offset) + offset21 := int(binary.LittleEndian.Uint32(buf[2687377:2687381])) + if offset21 < offset16 || offset21 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset21, offset16, buflen), "InactivityScores:o") + } + { // Field #22 'CurrentSyncCommittee' (static) + buf := buf[2687381:2712005] + if t.CurrentSyncCommittee == nil { + t.CurrentSyncCommittee = new(generic.SyncCommittee) + } + if err = t.CurrentSyncCommittee.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "CurrentSyncCommittee") + } + } + { // Field #23 'NextSyncCommittee' (static) + buf := buf[2712005:2736629] + if t.NextSyncCommittee == nil { + t.NextSyncCommittee = new(generic.SyncCommittee) + } + if err = t.NextSyncCommittee.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "NextSyncCommittee") + } + } + // Field #24 'LatestExecutionPayloadHeader' (offset) + offset24 := int(binary.LittleEndian.Uint32(buf[2736629:2736633])) + if offset24 < offset21 || offset24 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset24, offset21, buflen), "LatestExecutionPayloadHeader:o") + } + { // Field #25 'NextWithdrawalIndex' (static) + buf := buf[2736633:2736641] + t.NextWithdrawalIndex = binary.LittleEndian.Uint64(buf) + } + { // Field #26 'NextWithdrawalValidatorIndex' (static) + buf := buf[2736641:2736649] + t.NextWithdrawalValidatorIndex = binary.LittleEndian.Uint64(buf) + } + // Field #27 'HistoricalSummaries' (offset) + offset27 := int(binary.LittleEndian.Uint32(buf[2736649:2736653])) + if offset27 < offset24 || offset27 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset27, offset24, buflen), "HistoricalSummaries:o") + } + { // Field #28 'DepositRequestsStartIndex' (static) + buf := buf[2736653:2736661] + t.DepositRequestsStartIndex = binary.LittleEndian.Uint64(buf) + } + { // Field #29 'DepositBalanceToConsume' (static) + buf := buf[2736661:2736669] + t.DepositBalanceToConsume = binary.LittleEndian.Uint64(buf) + } + { // Field #30 'ExitBalanceToConsume' (static) + buf := buf[2736669:2736677] + t.ExitBalanceToConsume = binary.LittleEndian.Uint64(buf) + } + { // Field #31 'EarliestExitEpoch' (static) + buf := buf[2736677:2736685] + t.EarliestExitEpoch = binary.LittleEndian.Uint64(buf) + } + { // Field #32 'ConsolidationBalanceToConsume' (static) + buf := buf[2736685:2736693] + t.ConsolidationBalanceToConsume = binary.LittleEndian.Uint64(buf) + } + { // Field #33 'EarliestConsolidationEpoch' (static) + buf := buf[2736693:2736701] + t.EarliestConsolidationEpoch = binary.LittleEndian.Uint64(buf) + } + // Field #34 'PendingDeposits' (offset) + offset34 := int(binary.LittleEndian.Uint32(buf[2736701:2736705])) + if offset34 < offset27 || offset34 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset34, offset27, buflen), "PendingDeposits:o") + } + // Field #35 'PendingPartialWithdrawals' (offset) + offset35 := int(binary.LittleEndian.Uint32(buf[2736705:2736709])) + if offset35 < offset34 || offset35 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset35, offset34, buflen), "PendingPartialWithdrawals:o") + } + // Field #36 'PendingConsolidations' (offset) + offset36 := int(binary.LittleEndian.Uint32(buf[2736709:2736713])) + if offset36 < offset35 || offset36 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset36, offset35, buflen), "PendingConsolidations:o") + } + { // Field #37 'ProposerLookahead' (static) + buf := buf[2736713:2737225] + val5 := t.ProposerLookahead + val5 = sszutils.ExpandSlice(val5, 64) + sszutils.UnmarshalUint64Slice(val5[:64], buf) + t.ProposerLookahead = val5 + } + { // Field #7 'HistoricalRoots' (dynamic) + buf := buf[offset7:offset9] + val6 := t.HistoricalRoots + itemCount := len(buf) / 32 + if len(buf)%32 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 32), "HistoricalRoots") + } + if itemCount > 16777216 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 16777216), "HistoricalRoots") + } + val6 = sszutils.ExpandSlice(val6, itemCount) + for idx1 := range itemCount { + buf := buf[32*idx1 : 32*(idx1+1)] + val6[idx1] = sszutils.ExpandSlice(val6[idx1], 32) + copy(val6[idx1][:], buf) + } + t.HistoricalRoots = val6 + } + { // Field #9 'Eth1DataVotes' (dynamic) + buf := buf[offset9:offset11] + val7 := t.Eth1DataVotes + itemCount := len(buf) / 72 + if len(buf)%72 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 72), "Eth1DataVotes") + } + if itemCount > 2048 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 2048), "Eth1DataVotes") + } + val7 = sszutils.ExpandSlice(val7, itemCount) + for idx1 := range itemCount { + if val7[idx1] == nil { + val7[idx1] = new(generic.Eth1Data) + } + buf := buf[72*idx1 : 72*(idx1+1)] + if err = val7[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Eth1DataVotes[%d]", idx1) + } + } + t.Eth1DataVotes = val7 + } + { // Field #11 'Validators' (dynamic) + buf := buf[offset11:offset12] + val8 := t.Validators + itemCount := len(buf) / 121 + if len(buf)%121 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 121), "Validators") + } + if itemCount > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1099511627776), "Validators") + } + val8 = sszutils.ExpandSlice(val8, itemCount) + for idx1 := range itemCount { + if val8[idx1] == nil { + val8[idx1] = new(generic.Validator) + } + buf := buf[121*idx1 : 121*(idx1+1)] + if err = val8[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } + } + t.Validators = val8 + } + { // Field #12 'Balances' (dynamic) + buf := buf[offset12:offset15] + val9 := t.Balances + itemCount := len(buf) / 8 + if len(buf)%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 8), "Balances") + } + if itemCount > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1099511627776), "Balances") + } + val9 = sszutils.ExpandSlice(val9, itemCount) + sszutils.UnmarshalUint64Slice(val9, buf) + t.Balances = val9 + } + { // Field #15 'PreviousEpochParticipation' (dynamic) + buf := buf[offset15:offset16] + if len(buf) > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(len(buf), 1099511627776), "PreviousEpochParticipation") + } + t.PreviousEpochParticipation = sszutils.ExpandSlice(t.PreviousEpochParticipation, len(buf)) + copy(t.PreviousEpochParticipation[:], buf) + } + { // Field #16 'CurrentEpochParticipation' (dynamic) + buf := buf[offset16:offset21] + if len(buf) > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(len(buf), 1099511627776), "CurrentEpochParticipation") + } + t.CurrentEpochParticipation = sszutils.ExpandSlice(t.CurrentEpochParticipation, len(buf)) + copy(t.CurrentEpochParticipation[:], buf) + } + { // Field #21 'InactivityScores' (dynamic) + buf := buf[offset21:offset24] + val10 := t.InactivityScores + itemCount := len(buf) / 8 + if len(buf)%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 8), "InactivityScores") + } + if itemCount > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1099511627776), "InactivityScores") + } + val10 = sszutils.ExpandSlice(val10, itemCount) + sszutils.UnmarshalUint64Slice(val10, buf) + t.InactivityScores = val10 + } + { // Field #24 'LatestExecutionPayloadHeader' (dynamic) + buf := buf[offset24:offset27] + if t.LatestExecutionPayloadHeader == nil { + t.LatestExecutionPayloadHeader = new(generic.ExecutionPayloadHeader) + } + if err = t.LatestExecutionPayloadHeader.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "LatestExecutionPayloadHeader") + } + } + { // Field #27 'HistoricalSummaries' (dynamic) + buf := buf[offset27:offset34] + val11 := t.HistoricalSummaries + itemCount := len(buf) / 64 + if len(buf)%64 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 64), "HistoricalSummaries") + } + if itemCount > 16777216 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 16777216), "HistoricalSummaries") + } + val11 = sszutils.ExpandSlice(val11, itemCount) + for idx1 := range itemCount { + if val11[idx1] == nil { + val11[idx1] = new(generic.HistoricalSummary) + } + buf := buf[64*idx1 : 64*(idx1+1)] + if err = val11[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "HistoricalSummaries[%d]", idx1) + } + } + t.HistoricalSummaries = val11 + } + { // Field #34 'PendingDeposits' (dynamic) + buf := buf[offset34:offset35] + val12 := t.PendingDeposits + itemCount := len(buf) / 192 + if len(buf)%192 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 192), "PendingDeposits") + } + if itemCount > 134217728 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 134217728), "PendingDeposits") + } + val12 = sszutils.ExpandSlice(val12, itemCount) + for idx1 := range itemCount { + if val12[idx1] == nil { + val12[idx1] = new(generic.PendingDeposit) + } + buf := buf[192*idx1 : 192*(idx1+1)] + if err = val12[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "PendingDeposits[%d]", idx1) + } + } + t.PendingDeposits = val12 + } + { // Field #35 'PendingPartialWithdrawals' (dynamic) + buf := buf[offset35:offset36] + val13 := t.PendingPartialWithdrawals + itemCount := len(buf) / 24 + if len(buf)%24 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 24), "PendingPartialWithdrawals") + } + if itemCount > 134217728 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 134217728), "PendingPartialWithdrawals") + } + val13 = sszutils.ExpandSlice(val13, itemCount) + for idx1 := range itemCount { + if val13[idx1] == nil { + val13[idx1] = new(generic.PendingPartialWithdrawal) + } + buf := buf[24*idx1 : 24*(idx1+1)] + if err = val13[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "PendingPartialWithdrawals[%d]", idx1) + } + } + t.PendingPartialWithdrawals = val13 + } + { // Field #36 'PendingConsolidations' (dynamic) + buf := buf[offset36:] + val14 := t.PendingConsolidations + itemCount := len(buf) / 16 + if len(buf)%16 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 16), "PendingConsolidations") + } + if itemCount > 262144 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 262144), "PendingConsolidations") + } + val14 = sszutils.ExpandSlice(val14, itemCount) + for idx1 := range itemCount { + if val14[idx1] == nil { + val14[idx1] = new(generic.PendingConsolidation) + } + buf := buf[16*idx1 : 16*(idx1+1)] + if err = val14[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "PendingConsolidations[%d]", idx1) + } + } + t.PendingConsolidations = val14 + } + return nil +} + +// UnmarshalSSZDyn unmarshals the *BeaconState from SSZ-encoded bytes using dynamic specifications. +func (t *BeaconState) UnmarshalSSZDyn(_ sszutils.DynamicSpecs, buf []byte) (err error) { + return t.UnmarshalSSZ(buf) +} + +// UnmarshalSSZDecoder unmarshals the *BeaconState from the given SSZ decoder using dynamic specifications. +func (t *BeaconState) UnmarshalSSZDecoder(ds sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { + maxOffset := uint32(dec.GetLength()) + startPos0 := dec.GetPosition() + if maxOffset < uint32(2737225) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(2737225)) + } + // Field #0 'GenesisTime' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "GenesisTime") + } else { + t.GenesisTime = val + } + // Field #1 'GenesisValidatorsRoot' (static) + t.GenesisValidatorsRoot = sszutils.ExpandSlice(t.GenesisValidatorsRoot, 32) + if _, err = dec.DecodeBytes(t.GenesisValidatorsRoot[:32]); err != nil { + return err + } + // Field #2 'Slot' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "Slot") + } else { + t.Slot = val + } + // Field #3 'Fork' (static) + if t.Fork == nil { + t.Fork = new(generic.Fork) + } + if err = t.Fork.UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPath(err, "Fork") + } + // Field #4 'LatestBlockHeader' (static) + if t.LatestBlockHeader == nil { + t.LatestBlockHeader = new(generic.BeaconBlockHeader) + } + if err = t.LatestBlockHeader.UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") + } + { // Field #5 'BlockRoots' (static) + val1 := t.BlockRoots + startPos1 := dec.GetPosition() + for idx1 := range 8192 { + if _, err = dec.DecodeBytes(val1[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos1+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos1+int(32*(idx1+1))), "BlockRoots[%d]", idx1) + } + } + t.BlockRoots = val1 + } + { // Field #6 'StateRoots' (static) + val2 := t.StateRoots + startPos2 := dec.GetPosition() + for idx1 := range 8192 { + if _, err = dec.DecodeBytes(val2[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos2+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos2+int(32*(idx1+1))), "StateRoots[%d]", idx1) + } + } + t.StateRoots = val2 + } + // Field #7 'HistoricalRoots' (offset) + offset7, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "HistoricalRoots") + } + if offset7 != uint32(2737225) { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset7, 2737225), "HistoricalRoots") + } + // Field #8 'Eth1Data' (static) + if t.Eth1Data == nil { + t.Eth1Data = new(generic.Eth1Data) + } + if err = t.Eth1Data.UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPath(err, "Eth1Data") + } + // Field #9 'Eth1DataVotes' (offset) + offset9, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Eth1DataVotes") + } + if offset9 < offset7 || offset9 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset9, offset7, maxOffset), "Eth1DataVotes") + } + // Field #10 'Eth1DepositIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "Eth1DepositIndex") + } else { + t.Eth1DepositIndex = val + } + // Field #11 'Validators' (offset) + offset11, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Validators") + } + if offset11 < offset9 || offset11 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset11, offset9, maxOffset), "Validators") + } + // Field #12 'Balances' (offset) + offset12, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Balances") + } + if offset12 < offset11 || offset12 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset12, offset11, maxOffset), "Balances") + } + { // Field #13 'RandaoMixes' (static) + val3 := t.RandaoMixes + val3 = sszutils.ExpandSlice(val3, 65536) + startPos3 := dec.GetPosition() + for idx1 := range 65536 { + val3[idx1] = sszutils.ExpandSlice(val3[idx1], 32) + if _, err = dec.DecodeBytes(val3[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos3+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos3+int(32*(idx1+1))), "RandaoMixes[%d]", idx1) + } + } + t.RandaoMixes = val3 + } + { // Field #14 'Slashings' (static) + val4 := t.Slashings + val4 = sszutils.ExpandSlice(val4, 8192) + if err = sszutils.DecodeUint64Slice(dec, val4[:8192]); err != nil { + return sszutils.ErrorWithPath(err, "Slashings") + } + t.Slashings = val4 + } + // Field #15 'PreviousEpochParticipation' (offset) + offset15, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "PreviousEpochParticipation") + } + if offset15 < offset12 || offset15 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset15, offset12, maxOffset), "PreviousEpochParticipation") + } + // Field #16 'CurrentEpochParticipation' (offset) + offset16, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "CurrentEpochParticipation") + } + if offset16 < offset15 || offset16 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset16, offset15, maxOffset), "CurrentEpochParticipation") + } + // Field #17 'JustificationBits' (static) + if _, err = dec.DecodeBytes(t.JustificationBits[:1]); err != nil { + return err + } + // Field #18 'PreviousJustifiedCheckpoint' (static) + if t.PreviousJustifiedCheckpoint == nil { + t.PreviousJustifiedCheckpoint = new(generic.Checkpoint) + } + if err = t.PreviousJustifiedCheckpoint.UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } + // Field #19 'CurrentJustifiedCheckpoint' (static) + if t.CurrentJustifiedCheckpoint == nil { + t.CurrentJustifiedCheckpoint = new(generic.Checkpoint) + } + if err = t.CurrentJustifiedCheckpoint.UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } + // Field #20 'FinalizedCheckpoint' (static) + if t.FinalizedCheckpoint == nil { + t.FinalizedCheckpoint = new(generic.Checkpoint) + } + if err = t.FinalizedCheckpoint.UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") + } + // Field #21 'InactivityScores' (offset) + offset21, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "InactivityScores") + } + if offset21 < offset16 || offset21 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset21, offset16, maxOffset), "InactivityScores") + } + // Field #22 'CurrentSyncCommittee' (static) + if t.CurrentSyncCommittee == nil { + t.CurrentSyncCommittee = new(generic.SyncCommittee) + } + if err = t.CurrentSyncCommittee.UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPath(err, "CurrentSyncCommittee") + } + // Field #23 'NextSyncCommittee' (static) + if t.NextSyncCommittee == nil { + t.NextSyncCommittee = new(generic.SyncCommittee) + } + if err = t.NextSyncCommittee.UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPath(err, "NextSyncCommittee") + } + // Field #24 'LatestExecutionPayloadHeader' (offset) + offset24, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "LatestExecutionPayloadHeader") + } + if offset24 < offset21 || offset24 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset24, offset21, maxOffset), "LatestExecutionPayloadHeader") + } + // Field #25 'NextWithdrawalIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "NextWithdrawalIndex") + } else { + t.NextWithdrawalIndex = val + } + // Field #26 'NextWithdrawalValidatorIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "NextWithdrawalValidatorIndex") + } else { + t.NextWithdrawalValidatorIndex = val + } + // Field #27 'HistoricalSummaries' (offset) + offset27, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "HistoricalSummaries") + } + if offset27 < offset24 || offset27 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset27, offset24, maxOffset), "HistoricalSummaries") + } + // Field #28 'DepositRequestsStartIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "DepositRequestsStartIndex") + } else { + t.DepositRequestsStartIndex = val + } + // Field #29 'DepositBalanceToConsume' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "DepositBalanceToConsume") + } else { + t.DepositBalanceToConsume = val + } + // Field #30 'ExitBalanceToConsume' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "ExitBalanceToConsume") + } else { + t.ExitBalanceToConsume = val + } + // Field #31 'EarliestExitEpoch' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "EarliestExitEpoch") + } else { + t.EarliestExitEpoch = val + } + // Field #32 'ConsolidationBalanceToConsume' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "ConsolidationBalanceToConsume") + } else { + t.ConsolidationBalanceToConsume = val + } + // Field #33 'EarliestConsolidationEpoch' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "EarliestConsolidationEpoch") + } else { + t.EarliestConsolidationEpoch = val + } + // Field #34 'PendingDeposits' (offset) + offset34, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "PendingDeposits") + } + if offset34 < offset27 || offset34 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset34, offset27, maxOffset), "PendingDeposits") + } + // Field #35 'PendingPartialWithdrawals' (offset) + offset35, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "PendingPartialWithdrawals") + } + if offset35 < offset34 || offset35 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset35, offset34, maxOffset), "PendingPartialWithdrawals") + } + // Field #36 'PendingConsolidations' (offset) + offset36, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "PendingConsolidations") + } + if offset36 < offset35 || offset36 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset36, offset35, maxOffset), "PendingConsolidations") + } + { // Field #37 'ProposerLookahead' (static) + val5 := t.ProposerLookahead + val5 = sszutils.ExpandSlice(val5, 64) + if err = sszutils.DecodeUint64Slice(dec, val5[:64]); err != nil { + return sszutils.ErrorWithPath(err, "ProposerLookahead") + } + t.ProposerLookahead = val5 + } + { // Field #7 'HistoricalRoots' (dynamic) + if dec.GetPosition() != startPos0+int(offset7) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset7)), "HistoricalRoots") + } + dec.PushLimit(int(offset9 - offset7)) + val6 := t.HistoricalRoots + sszLen := dec.GetLength() + itemCount := sszLen / 32 + if sszLen%32 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 32), "HistoricalRoots") + } + if itemCount > 16777216 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 16777216), "HistoricalRoots") + } + val6 = sszutils.ExpandSlice(val6, itemCount) + startPos4 := dec.GetPosition() + for idx1 := range itemCount { + val6[idx1] = sszutils.ExpandSlice(val6[idx1], 32) + if _, err = dec.DecodeBytes(val6[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos4+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos4+int(32*(idx1+1))), "HistoricalRoots[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "HistoricalRoots") + } + t.HistoricalRoots = val6 + } + { // Field #9 'Eth1DataVotes' (dynamic) + if dec.GetPosition() != startPos0+int(offset9) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset9)), "Eth1DataVotes") + } + dec.PushLimit(int(offset11 - offset9)) + val7 := t.Eth1DataVotes + sszLen := dec.GetLength() + itemCount := sszLen / 72 + if sszLen%72 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 72), "Eth1DataVotes") + } + if itemCount > 2048 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 2048), "Eth1DataVotes") + } + val7 = sszutils.ExpandSlice(val7, itemCount) + startPos5 := dec.GetPosition() + for idx1 := range itemCount { + if val7[idx1] == nil { + val7[idx1] = new(generic.Eth1Data) + } + if err = val7[idx1].UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPathf(err, "Eth1DataVotes[%d]", idx1) + } + if dec.GetPosition() != startPos5+int(72*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos5+int(72*(idx1+1))), "Eth1DataVotes[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Eth1DataVotes") + } + t.Eth1DataVotes = val7 + } + { // Field #11 'Validators' (dynamic) + if dec.GetPosition() != startPos0+int(offset11) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset11)), "Validators") + } + dec.PushLimit(int(offset12 - offset11)) + val8 := t.Validators + sszLen := dec.GetLength() + itemCount := sszLen / 121 + if sszLen%121 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 121), "Validators") + } + if itemCount > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1099511627776), "Validators") + } + val8 = sszutils.ExpandSlice(val8, itemCount) + startPos6 := dec.GetPosition() + for idx1 := range itemCount { + if val8[idx1] == nil { + val8[idx1] = new(generic.Validator) + } + if err = val8[idx1].UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } + if dec.GetPosition() != startPos6+int(121*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos6+int(121*(idx1+1))), "Validators[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Validators") + } + t.Validators = val8 + } + { // Field #12 'Balances' (dynamic) + if dec.GetPosition() != startPos0+int(offset12) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset12)), "Balances") + } + dec.PushLimit(int(offset15 - offset12)) + val9 := t.Balances + sszLen := dec.GetLength() + itemCount := sszLen / 8 + if sszLen%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 8), "Balances") + } + if itemCount > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1099511627776), "Balances") + } + val9 = sszutils.ExpandSlice(val9, itemCount) + if err = sszutils.DecodeUint64Slice(dec, val9); err != nil { + return sszutils.ErrorWithPath(err, "Balances") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Balances") + } + t.Balances = val9 + } + { // Field #15 'PreviousEpochParticipation' (dynamic) + if dec.GetPosition() != startPos0+int(offset15) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset15)), "PreviousEpochParticipation") + } + dec.PushLimit(int(offset16 - offset15)) + val10 := t.PreviousEpochParticipation + if dec.GetLength() > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(dec.GetLength(), 1099511627776), "PreviousEpochParticipation") + } + listLen := dec.GetLength() + val10 = sszutils.ExpandSlice(val10, listLen) + if _, err = dec.DecodeBytes(val10[:listLen]); err != nil { + return sszutils.ErrorWithPath(err, "PreviousEpochParticipation") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "PreviousEpochParticipation") + } + t.PreviousEpochParticipation = val10 + } + { // Field #16 'CurrentEpochParticipation' (dynamic) + if dec.GetPosition() != startPos0+int(offset16) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset16)), "CurrentEpochParticipation") + } + dec.PushLimit(int(offset21 - offset16)) + val11 := t.CurrentEpochParticipation + if dec.GetLength() > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(dec.GetLength(), 1099511627776), "CurrentEpochParticipation") + } + listLen := dec.GetLength() + val11 = sszutils.ExpandSlice(val11, listLen) + if _, err = dec.DecodeBytes(val11[:listLen]); err != nil { + return sszutils.ErrorWithPath(err, "CurrentEpochParticipation") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "CurrentEpochParticipation") + } + t.CurrentEpochParticipation = val11 + } + { // Field #21 'InactivityScores' (dynamic) + if dec.GetPosition() != startPos0+int(offset21) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset21)), "InactivityScores") + } + dec.PushLimit(int(offset24 - offset21)) + val12 := t.InactivityScores + sszLen := dec.GetLength() + itemCount := sszLen / 8 + if sszLen%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 8), "InactivityScores") + } + if itemCount > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1099511627776), "InactivityScores") + } + val12 = sszutils.ExpandSlice(val12, itemCount) + if err = sszutils.DecodeUint64Slice(dec, val12); err != nil { + return sszutils.ErrorWithPath(err, "InactivityScores") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "InactivityScores") + } + t.InactivityScores = val12 + } + { // Field #24 'LatestExecutionPayloadHeader' (dynamic) + if dec.GetPosition() != startPos0+int(offset24) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset24)), "LatestExecutionPayloadHeader") + } + dec.PushLimit(int(offset27 - offset24)) + val13 := t.LatestExecutionPayloadHeader + if val13 == nil { + val13 = new(generic.ExecutionPayloadHeader) + } + if err = val13.UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPath(err, "LatestExecutionPayloadHeader") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "LatestExecutionPayloadHeader") + } + t.LatestExecutionPayloadHeader = val13 + } + { // Field #27 'HistoricalSummaries' (dynamic) + if dec.GetPosition() != startPos0+int(offset27) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset27)), "HistoricalSummaries") + } + dec.PushLimit(int(offset34 - offset27)) + val14 := t.HistoricalSummaries + sszLen := dec.GetLength() + itemCount := sszLen / 64 + if sszLen%64 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 64), "HistoricalSummaries") + } + if itemCount > 16777216 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 16777216), "HistoricalSummaries") + } + val14 = sszutils.ExpandSlice(val14, itemCount) + startPos7 := dec.GetPosition() + for idx1 := range itemCount { + if val14[idx1] == nil { + val14[idx1] = new(generic.HistoricalSummary) + } + if err = val14[idx1].UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPathf(err, "HistoricalSummaries[%d]", idx1) + } + if dec.GetPosition() != startPos7+int(64*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos7+int(64*(idx1+1))), "HistoricalSummaries[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "HistoricalSummaries") + } + t.HistoricalSummaries = val14 + } + { // Field #34 'PendingDeposits' (dynamic) + if dec.GetPosition() != startPos0+int(offset34) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset34)), "PendingDeposits") + } + dec.PushLimit(int(offset35 - offset34)) + val15 := t.PendingDeposits + sszLen := dec.GetLength() + itemCount := sszLen / 192 + if sszLen%192 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 192), "PendingDeposits") + } + if itemCount > 134217728 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 134217728), "PendingDeposits") + } + val15 = sszutils.ExpandSlice(val15, itemCount) + startPos8 := dec.GetPosition() + for idx1 := range itemCount { + if val15[idx1] == nil { + val15[idx1] = new(generic.PendingDeposit) + } + if err = val15[idx1].UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPathf(err, "PendingDeposits[%d]", idx1) + } + if dec.GetPosition() != startPos8+int(192*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos8+int(192*(idx1+1))), "PendingDeposits[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "PendingDeposits") + } + t.PendingDeposits = val15 + } + { // Field #35 'PendingPartialWithdrawals' (dynamic) + if dec.GetPosition() != startPos0+int(offset35) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset35)), "PendingPartialWithdrawals") + } + dec.PushLimit(int(offset36 - offset35)) + val16 := t.PendingPartialWithdrawals + sszLen := dec.GetLength() + itemCount := sszLen / 24 + if sszLen%24 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 24), "PendingPartialWithdrawals") + } + if itemCount > 134217728 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 134217728), "PendingPartialWithdrawals") + } + val16 = sszutils.ExpandSlice(val16, itemCount) + startPos9 := dec.GetPosition() + for idx1 := range itemCount { + if val16[idx1] == nil { + val16[idx1] = new(generic.PendingPartialWithdrawal) + } + if err = val16[idx1].UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPathf(err, "PendingPartialWithdrawals[%d]", idx1) + } + if dec.GetPosition() != startPos9+int(24*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos9+int(24*(idx1+1))), "PendingPartialWithdrawals[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "PendingPartialWithdrawals") + } + t.PendingPartialWithdrawals = val16 + } + { // Field #36 'PendingConsolidations' (dynamic) + if dec.GetPosition() != startPos0+int(offset36) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset36)), "PendingConsolidations") + } + dec.PushLimit(int(maxOffset - offset36)) + val17 := t.PendingConsolidations + sszLen := dec.GetLength() + itemCount := sszLen / 16 + if sszLen%16 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 16), "PendingConsolidations") + } + if itemCount > 262144 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 262144), "PendingConsolidations") + } + val17 = sszutils.ExpandSlice(val17, itemCount) + startPos10 := dec.GetPosition() + for idx1 := range itemCount { + if val17[idx1] == nil { + val17[idx1] = new(generic.PendingConsolidation) + } + if err = val17[idx1].UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPathf(err, "PendingConsolidations[%d]", idx1) + } + if dec.GetPosition() != startPos10+int(16*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos10+int(16*(idx1+1))), "PendingConsolidations[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "PendingConsolidations") + } + t.PendingConsolidations = val17 + } + return nil +} + +// SizeSSZDyn returns the SSZ encoded size of the *BeaconState using dynamic specifications. +func (t *BeaconState) SizeSSZDyn(ds sszutils.DynamicSpecs) (size int) { + if t == nil { + t = new(BeaconState) + } + // Field #0 'GenesisTime' static (8 bytes) + // Field #1 'GenesisValidatorsRoot' static (32 bytes) + // Field #2 'Slot' static (8 bytes) + // Field #3 'Fork' static (16 bytes) + // Field #4 'LatestBlockHeader' static (112 bytes) + // Field #5 'BlockRoots' static (262144 bytes) + // Field #6 'StateRoots' static (262144 bytes) + // Field #7 'HistoricalRoots' offset (4 bytes) + // Field #8 'Eth1Data' static (72 bytes) + // Field #9 'Eth1DataVotes' offset (4 bytes) + // Field #10 'Eth1DepositIndex' static (8 bytes) + // Field #11 'Validators' offset (4 bytes) + // Field #12 'Balances' offset (4 bytes) + // Field #13 'RandaoMixes' static (2097152 bytes) + // Field #14 'Slashings' static (65536 bytes) + // Field #15 'PreviousEpochParticipation' offset (4 bytes) + // Field #16 'CurrentEpochParticipation' offset (4 bytes) + // Field #17 'JustificationBits' static (1 bytes) + // Field #18 'PreviousJustifiedCheckpoint' static (40 bytes) + // Field #19 'CurrentJustifiedCheckpoint' static (40 bytes) + // Field #20 'FinalizedCheckpoint' static (40 bytes) + // Field #21 'InactivityScores' offset (4 bytes) + // Field #22 'CurrentSyncCommittee' static (24624 bytes) + // Field #23 'NextSyncCommittee' static (24624 bytes) + // Field #24 'LatestExecutionPayloadHeader' offset (4 bytes) + // Field #25 'NextWithdrawalIndex' static (8 bytes) + // Field #26 'NextWithdrawalValidatorIndex' static (8 bytes) + // Field #27 'HistoricalSummaries' offset (4 bytes) + // Field #28 'DepositRequestsStartIndex' static (8 bytes) + // Field #29 'DepositBalanceToConsume' static (8 bytes) + // Field #30 'ExitBalanceToConsume' static (8 bytes) + // Field #31 'EarliestExitEpoch' static (8 bytes) + // Field #32 'ConsolidationBalanceToConsume' static (8 bytes) + // Field #33 'EarliestConsolidationEpoch' static (8 bytes) + // Field #34 'PendingDeposits' offset (4 bytes) + // Field #35 'PendingPartialWithdrawals' offset (4 bytes) + // Field #36 'PendingConsolidations' offset (4 bytes) + // Field #37 'ProposerLookahead' static (512 bytes) + size += 2737225 + { // Dynamic field #7 'HistoricalRoots' + size += len(t.HistoricalRoots) * 32 + } + { // Dynamic field #9 'Eth1DataVotes' + size += len(t.Eth1DataVotes) * 72 + } + { // Dynamic field #11 'Validators' + size += len(t.Validators) * 121 + } + { // Dynamic field #12 'Balances' + size += len(t.Balances) * 8 + } + { // Dynamic field #15 'PreviousEpochParticipation' + size += len(t.PreviousEpochParticipation) + } + { // Dynamic field #16 'CurrentEpochParticipation' + size += len(t.CurrentEpochParticipation) + } + { // Dynamic field #21 'InactivityScores' + size += len(t.InactivityScores) * 8 + } + { // Dynamic field #24 'LatestExecutionPayloadHeader' + size += t.LatestExecutionPayloadHeader.SizeSSZDyn(ds) + } + { // Dynamic field #27 'HistoricalSummaries' + size += len(t.HistoricalSummaries) * 64 + } + { // Dynamic field #34 'PendingDeposits' + size += len(t.PendingDeposits) * 192 + } + { // Dynamic field #35 'PendingPartialWithdrawals' + size += len(t.PendingPartialWithdrawals) * 24 + } + { // Dynamic field #36 'PendingConsolidations' + size += len(t.PendingConsolidations) * 16 + } + return size +} + +// HashTreeRootDyn computes the SSZ hash tree root of the *BeaconState using dynamic specifications. +func (t *BeaconState) HashTreeRootDyn(ds sszutils.DynamicSpecs) (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWithDyn(ds, hh) + if err == nil { + root, err = hh.HashRoot() + } + return + }) + return +} + +// HashTreeRootWithDyn computes the SSZ hash tree root of the *BeaconState using dynamic specifications and the given hash walker. +func (t *BeaconState) HashTreeRootWithDyn(ds sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + if t == nil { + t = new(BeaconState) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'GenesisTime' + hh.PutUint64(t.GenesisTime) + } + { // Field #1 'GenesisValidatorsRoot' + vlen := len(t.GenesisValidatorsRoot) + if vlen > 32 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 32), "GenesisValidatorsRoot") + } + val := t.GenesisValidatorsRoot[:] + if vlen < 32 { + val = sszutils.AppendZeroPadding(val, (32-vlen)*1) + } + hh.PutBytes(val[:32]) + } + { // Field #2 'Slot' + hh.PutUint64(t.Slot) + } + { // Field #3 'Fork' + t := t.Fork + if t == nil { + t = new(generic.Fork) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPath(err, "Fork") + } + } + { // Field #4 'LatestBlockHeader' + t := t.LatestBlockHeader + if t == nil { + t = new(generic.BeaconBlockHeader) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") + } + } + { // Field #5 'BlockRoots' + t := &t.BlockRoots + idx := hh.StartTree(sszutils.TreeTypeBinary) + var val1 *[32]byte + for idx1 := range 8192 { + if idx1 < 8192 { + val1 = &t[idx1] + } else if idx1 == 8192 { + val1 = new([32]byte) + } + hh.PutBytes(val1[:32]) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.Merkleize(idx) + } + { // Field #6 'StateRoots' + t := &t.StateRoots + idx := hh.StartTree(sszutils.TreeTypeBinary) + var val2 *[32]byte + for idx1 := range 8192 { + if idx1 < 8192 { + val2 = &t[idx1] + } else if idx1 == 8192 { + val2 = new([32]byte) + } + hh.PutBytes(val2[:32]) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.Merkleize(idx) + } + { // Field #7 'HistoricalRoots' + t := t.HistoricalRoots + vlen := uint64(len(t)) + if vlen > 16777216 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16777216), "HistoricalRoots") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + vlen := len(t[idx1]) + if vlen > 32 { + return sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, 32), "HistoricalRoots[%d]", idx1) + } + val := t[idx1][:] + if vlen < 32 { + val = sszutils.AppendZeroPadding(val, (32-vlen)*1) + } + hh.PutBytes(val[:32]) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(16777216, vlen, 32)) + } + { // Field #8 'Eth1Data' + t := t.Eth1Data + if t == nil { + t = new(generic.Eth1Data) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPath(err, "Eth1Data") + } + } + { // Field #9 'Eth1DataVotes' + t := t.Eth1DataVotes + vlen := uint64(len(t)) + if vlen > 2048 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 2048), "Eth1DataVotes") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(generic.Eth1Data) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPathf(err, "Eth1DataVotes[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(2048, vlen, 32)) + } + { // Field #10 'Eth1DepositIndex' + hh.PutUint64(t.Eth1DepositIndex) + } + { // Field #11 'Validators' + t := t.Validators + vlen := uint64(len(t)) + if vlen > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1099511627776), "Validators") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(generic.Validator) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(1099511627776, vlen, 32)) + } + { // Field #12 'Balances' + t := t.Balances + vlen := uint64(len(t)) + if vlen > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1099511627776), "Balances") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + sszutils.HashUint64Slice(hh, t) + hh.FillUpTo32() + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(1099511627776, vlen, 8)) + } + { // Field #13 'RandaoMixes' + t := t.RandaoMixes + vlen := len(t) + if vlen > 65536 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 65536), "RandaoMixes") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + var val3, val3Empty []byte + for idx1 := range 65536 { + if idx1 < vlen { + val3 = t[idx1] + } else if idx1 == vlen { + val3 = val3Empty + } + vlen := len(val3) + if vlen > 32 { + return sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, 32), "RandaoMixes[%d]", idx1) + } + val := val3[:] + if vlen < 32 { + val = sszutils.AppendZeroPadding(val, (32-vlen)*1) + } + hh.PutBytes(val[:32]) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.Merkleize(idx) + } + { // Field #14 'Slashings' + t := t.Slashings + vlen := len(t) + if vlen > 8192 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 8192), "Slashings") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + var val4, val4Empty uint64 + for idx1 := range 8192 { + if idx1 < vlen { + val4 = t[idx1] + } else if idx1 == vlen { + val4 = val4Empty + } + hh.AppendUint64(val4) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.FillUpTo32() + hh.Merkleize(idx) + } + { // Field #15 'PreviousEpochParticipation' + vlen := uint64(len(t.PreviousEpochParticipation)) + if vlen > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1099511627776), "PreviousEpochParticipation") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + hh.AppendBytes32(t.PreviousEpochParticipation[:]) + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(1099511627776, vlen, 1)) + } + { // Field #16 'CurrentEpochParticipation' + vlen := uint64(len(t.CurrentEpochParticipation)) + if vlen > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1099511627776), "CurrentEpochParticipation") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + hh.AppendBytes32(t.CurrentEpochParticipation[:]) + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(1099511627776, vlen, 1)) + } + { // Field #17 'JustificationBits' + hh.PutBytes(t.JustificationBits[:1]) + } + { // Field #18 'PreviousJustifiedCheckpoint' + t := t.PreviousJustifiedCheckpoint + if t == nil { + t = new(generic.Checkpoint) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } + } + { // Field #19 'CurrentJustifiedCheckpoint' + t := t.CurrentJustifiedCheckpoint + if t == nil { + t = new(generic.Checkpoint) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } + } + { // Field #20 'FinalizedCheckpoint' + t := t.FinalizedCheckpoint + if t == nil { + t = new(generic.Checkpoint) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") + } + } + { // Field #21 'InactivityScores' + t := t.InactivityScores + vlen := uint64(len(t)) + if vlen > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1099511627776), "InactivityScores") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + sszutils.HashUint64Slice(hh, t) + hh.FillUpTo32() + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(1099511627776, vlen, 8)) + } + { // Field #22 'CurrentSyncCommittee' + t := t.CurrentSyncCommittee + if t == nil { + t = new(generic.SyncCommittee) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPath(err, "CurrentSyncCommittee") + } + } + { // Field #23 'NextSyncCommittee' + t := t.NextSyncCommittee + if t == nil { + t = new(generic.SyncCommittee) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPath(err, "NextSyncCommittee") + } + } + { // Field #24 'LatestExecutionPayloadHeader' + t := t.LatestExecutionPayloadHeader + if t == nil { + t = new(generic.ExecutionPayloadHeader) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPath(err, "LatestExecutionPayloadHeader") + } + } + { // Field #25 'NextWithdrawalIndex' + hh.PutUint64(t.NextWithdrawalIndex) + } + { // Field #26 'NextWithdrawalValidatorIndex' + hh.PutUint64(t.NextWithdrawalValidatorIndex) + } + { // Field #27 'HistoricalSummaries' + t := t.HistoricalSummaries + vlen := uint64(len(t)) + if vlen > 16777216 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16777216), "HistoricalSummaries") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(generic.HistoricalSummary) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPathf(err, "HistoricalSummaries[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(16777216, vlen, 32)) + } + { // Field #28 'DepositRequestsStartIndex' + hh.PutUint64(t.DepositRequestsStartIndex) + } + { // Field #29 'DepositBalanceToConsume' + hh.PutUint64(t.DepositBalanceToConsume) + } + { // Field #30 'ExitBalanceToConsume' + hh.PutUint64(t.ExitBalanceToConsume) + } + { // Field #31 'EarliestExitEpoch' + hh.PutUint64(t.EarliestExitEpoch) + } + { // Field #32 'ConsolidationBalanceToConsume' + hh.PutUint64(t.ConsolidationBalanceToConsume) + } + { // Field #33 'EarliestConsolidationEpoch' + hh.PutUint64(t.EarliestConsolidationEpoch) + } + { // Field #34 'PendingDeposits' + t := t.PendingDeposits + vlen := uint64(len(t)) + if vlen > 134217728 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 134217728), "PendingDeposits") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(generic.PendingDeposit) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPathf(err, "PendingDeposits[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(134217728, vlen, 32)) + } + { // Field #35 'PendingPartialWithdrawals' + t := t.PendingPartialWithdrawals + vlen := uint64(len(t)) + if vlen > 134217728 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 134217728), "PendingPartialWithdrawals") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(generic.PendingPartialWithdrawal) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPathf(err, "PendingPartialWithdrawals[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(134217728, vlen, 32)) + } + { // Field #36 'PendingConsolidations' + t := t.PendingConsolidations + vlen := uint64(len(t)) + if vlen > 262144 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 262144), "PendingConsolidations") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(generic.PendingConsolidation) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPathf(err, "PendingConsolidations[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(262144, vlen, 32)) + } + { // Field #37 'ProposerLookahead' + t := t.ProposerLookahead + vlen := len(t) + if vlen > 64 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 64), "ProposerLookahead") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + var val5, val5Empty uint64 + for idx1 := range 64 { + if idx1 < vlen { + val5 = t[idx1] + } else if idx1 == vlen { + val5 = val5Empty + } + hh.AppendUint64(val5) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.FillUpTo32() + hh.Merkleize(idx) + } + hh.Merkleize(idx) + return nil +} + +// MarshalSSZDyn marshals the *SignedBeaconBlock to SSZ-encoded bytes using dynamic specifications. +func (t *SignedBeaconBlock) MarshalSSZDyn(ds sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + dst = buf + if t == nil { + t = new(SignedBeaconBlock) + } + dstlen := len(dst) + // Offset Field #0 'Block' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #1 'Signature' + vlen := len(t.Signature) + if vlen > 96 { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 96), "Signature") + } + dst = append(dst, t.Signature[:vlen]...) + if vlen < 96 { + dst = sszutils.AppendZeroPadding(dst, (96-vlen)*1) + } + } + { // Dynamic Field #0 'Block' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.Block + if t == nil { + t = new(BeaconBlock) + } + if dst, err = t.MarshalSSZDyn(ds, dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "Block") + } + } + return dst, nil +} + +// MarshalSSZEncoder marshals the *SignedBeaconBlock to the given SSZ encoder using dynamic specifications. +func (t *SignedBeaconBlock) MarshalSSZEncoder(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + type encoderCtx struct { + ds sszutils.DynamicSpecs + exprs [0]uint64 + sizeFn1 func(ctx *encoderCtx, t *BeaconBlock) (size int) + } + ctx := &encoderCtx{ds: ds} + canSeek := enc.Seekable() + // size for *BeaconBlock + ctx.sizeFn1 = func(ctx *encoderCtx, t *BeaconBlock) (size int) { + size += t.SizeSSZDyn(ds) + return size + } + if t == nil { + t = new(SignedBeaconBlock) + } + dstlen := enc.GetPosition() + dynoff := uint32(100) + // Offset #0 'Block' + offset0 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn1(ctx, t.Block)) + } + { // Field #1 'Signature' + vlen := len(t.Signature) + if vlen > 96 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 96), "Signature") + } + enc.EncodeBytes(t.Signature[:vlen]) + if vlen < 96 { + enc.EncodeZeroPadding((96 - vlen) * 1) + } + } + { // Dynamic Field #0 'Block' + if canSeek { + enc.EncodeOffsetAt(offset0, uint32(enc.GetPosition()-dstlen)) + } + t := t.Block + if t == nil { + t = new(BeaconBlock) + } + if err = t.MarshalSSZEncoder(ds, enc); err != nil { + return sszutils.ErrorWithPath(err, "Block") + } + } + return nil +} + +// UnmarshalSSZDyn unmarshals the *SignedBeaconBlock from SSZ-encoded bytes using dynamic specifications. +func (t *SignedBeaconBlock) UnmarshalSSZDyn(ds sszutils.DynamicSpecs, buf []byte) (err error) { + buflen := len(buf) + if buflen < 100 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 100) + } + // Field #0 'Block' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 100 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset0, 100), "Block:o") + } + { // Field #1 'Signature' (static) + buf := buf[4:100] + t.Signature = sszutils.ExpandSlice(t.Signature, 96) + copy(t.Signature[:], buf) + } + { // Field #0 'Block' (dynamic) + buf := buf[offset0:] + if t.Block == nil { + t.Block = new(BeaconBlock) + } + if err = t.Block.UnmarshalSSZDyn(ds, buf); err != nil { + return sszutils.ErrorWithPath(err, "Block") + } + } + return nil +} + +// UnmarshalSSZDecoder unmarshals the *SignedBeaconBlock from the given SSZ decoder using dynamic specifications. +func (t *SignedBeaconBlock) UnmarshalSSZDecoder(ds sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { + maxOffset := uint32(dec.GetLength()) + startPos0 := dec.GetPosition() + if maxOffset < uint32(100) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(100)) + } + // Field #0 'Block' (offset) + offset0, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Block") + } + if offset0 != uint32(100) { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset0, 100), "Block") + } + // Field #1 'Signature' (static) + t.Signature = sszutils.ExpandSlice(t.Signature, 96) + if _, err = dec.DecodeBytes(t.Signature[:96]); err != nil { + return err + } + { // Field #0 'Block' (dynamic) + if dec.GetPosition() != startPos0+int(offset0) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset0)), "Block") + } + dec.PushLimit(int(maxOffset - offset0)) + val1 := t.Block + if val1 == nil { + val1 = new(BeaconBlock) + } + if err = val1.UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPath(err, "Block") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Block") + } + t.Block = val1 + } + return nil +} + +// SizeSSZDyn returns the SSZ encoded size of the *SignedBeaconBlock using dynamic specifications. +func (t *SignedBeaconBlock) SizeSSZDyn(ds sszutils.DynamicSpecs) (size int) { + if t == nil { + t = new(SignedBeaconBlock) + } + // Field #0 'Block' offset (4 bytes) + // Field #1 'Signature' static (96 bytes) + size += 100 + { // Dynamic field #0 'Block' + size += t.Block.SizeSSZDyn(ds) + } + return size +} + +// HashTreeRootDyn computes the SSZ hash tree root of the *SignedBeaconBlock using dynamic specifications. +func (t *SignedBeaconBlock) HashTreeRootDyn(ds sszutils.DynamicSpecs) (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWithDyn(ds, hh) + if err == nil { + root, err = hh.HashRoot() + } + return + }) + return +} + +// HashTreeRootWithDyn computes the SSZ hash tree root of the *SignedBeaconBlock using dynamic specifications and the given hash walker. +func (t *SignedBeaconBlock) HashTreeRootWithDyn(ds sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + if t == nil { + t = new(SignedBeaconBlock) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Block' + t := t.Block + if t == nil { + t = new(BeaconBlock) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPath(err, "Block") + } + } + { // Field #1 'Signature' + vlen := len(t.Signature) + if vlen > 96 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 96), "Signature") + } + val := t.Signature[:] + if vlen < 96 { + val = sszutils.AppendZeroPadding(val, (96-vlen)*1) + } + hh.PutBytes(val[:96]) + } + hh.Merkleize(idx) + return nil +} + +// MarshalSSZDyn marshals the *BeaconBlock to SSZ-encoded bytes using dynamic specifications. +func (t *BeaconBlock) MarshalSSZDyn(ds sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + dst = buf + if t == nil { + t = new(BeaconBlock) + } + dstlen := len(dst) + { // Static Field #0 'Slot' + dst = binary.LittleEndian.AppendUint64(dst, t.Slot) + } + { // Static Field #1 'ProposerIndex' + dst = binary.LittleEndian.AppendUint64(dst, t.ProposerIndex) + } + { // Static Field #2 'ParentRoot' + dst = append(dst, t.ParentRoot[:32]...) + } + { // Static Field #3 'StateRoot' + dst = append(dst, t.StateRoot[:32]...) + } + // Offset Field #4 'Body' + dst = append(dst, 0, 0, 0, 0) + { // Dynamic Field #4 'Body' + binary.LittleEndian.PutUint32(dst[dstlen+80:], uint32(len(dst)-dstlen)) + t := t.Body + if t == nil { + t = new(BeaconBlockBody) + } + if dst, err = t.MarshalSSZDyn(ds, dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "Body") + } + } + return dst, nil +} + +// MarshalSSZEncoder marshals the *BeaconBlock to the given SSZ encoder using dynamic specifications. +func (t *BeaconBlock) MarshalSSZEncoder(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + type encoderCtx struct { + ds sszutils.DynamicSpecs + exprs [0]uint64 + sizeFn1 func(ctx *encoderCtx, t *BeaconBlockBody) (size int) + } + ctx := &encoderCtx{ds: ds} + canSeek := enc.Seekable() + // size for *BeaconBlockBody + ctx.sizeFn1 = func(ctx *encoderCtx, t *BeaconBlockBody) (size int) { + size += t.SizeSSZDyn(ds) + return size + } + if t == nil { + t = new(BeaconBlock) + } + dstlen := enc.GetPosition() + dynoff := uint32(84) + { // Field #0 'Slot' + enc.EncodeUint64(t.Slot) + } + { // Field #1 'ProposerIndex' + enc.EncodeUint64(t.ProposerIndex) + } + { // Field #2 'ParentRoot' + enc.EncodeBytes(t.ParentRoot[:32]) + } + { // Field #3 'StateRoot' + enc.EncodeBytes(t.StateRoot[:32]) + } + // Offset #4 'Body' + offset4 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn1(ctx, t.Body)) + } + { // Dynamic Field #4 'Body' + if canSeek { + enc.EncodeOffsetAt(offset4, uint32(enc.GetPosition()-dstlen)) + } + t := t.Body + if t == nil { + t = new(BeaconBlockBody) + } + if err = t.MarshalSSZEncoder(ds, enc); err != nil { + return sszutils.ErrorWithPath(err, "Body") + } + } + return nil +} + +// UnmarshalSSZDyn unmarshals the *BeaconBlock from SSZ-encoded bytes using dynamic specifications. +func (t *BeaconBlock) UnmarshalSSZDyn(ds sszutils.DynamicSpecs, buf []byte) (err error) { + buflen := len(buf) + if buflen < 84 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 84) + } + { // Field #0 'Slot' (static) + buf := buf[0:8] + t.Slot = binary.LittleEndian.Uint64(buf) + } + { // Field #1 'ProposerIndex' (static) + buf := buf[8:16] + t.ProposerIndex = binary.LittleEndian.Uint64(buf) + } + { // Field #2 'ParentRoot' (static) + buf := buf[16:48] + copy(t.ParentRoot[:], buf) + } + { // Field #3 'StateRoot' (static) + buf := buf[48:80] + copy(t.StateRoot[:], buf) + } + // Field #4 'Body' (offset) + offset4 := int(binary.LittleEndian.Uint32(buf[80:84])) + if offset4 != 84 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset4, 84), "Body:o") + } + { // Field #4 'Body' (dynamic) + buf := buf[offset4:] + if t.Body == nil { + t.Body = new(BeaconBlockBody) + } + if err = t.Body.UnmarshalSSZDyn(ds, buf); err != nil { + return sszutils.ErrorWithPath(err, "Body") + } + } + return nil +} + +// UnmarshalSSZDecoder unmarshals the *BeaconBlock from the given SSZ decoder using dynamic specifications. +func (t *BeaconBlock) UnmarshalSSZDecoder(ds sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { + maxOffset := uint32(dec.GetLength()) + startPos0 := dec.GetPosition() + if maxOffset < uint32(84) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(84)) + } + // Field #0 'Slot' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "Slot") + } else { + t.Slot = val + } + // Field #1 'ProposerIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "ProposerIndex") + } else { + t.ProposerIndex = val + } + // Field #2 'ParentRoot' (static) + if _, err = dec.DecodeBytes(t.ParentRoot[:32]); err != nil { + return err + } + // Field #3 'StateRoot' (static) + if _, err = dec.DecodeBytes(t.StateRoot[:32]); err != nil { + return err + } + // Field #4 'Body' (offset) + offset4, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Body") + } + if offset4 != uint32(84) { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset4, 84), "Body") + } + { // Field #4 'Body' (dynamic) + if dec.GetPosition() != startPos0+int(offset4) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset4)), "Body") + } + dec.PushLimit(int(maxOffset - offset4)) + val1 := t.Body + if val1 == nil { + val1 = new(BeaconBlockBody) + } + if err = val1.UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPath(err, "Body") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Body") + } + t.Body = val1 + } + return nil +} + +// SizeSSZDyn returns the SSZ encoded size of the *BeaconBlock using dynamic specifications. +func (t *BeaconBlock) SizeSSZDyn(ds sszutils.DynamicSpecs) (size int) { + if t == nil { + t = new(BeaconBlock) + } + // Field #0 'Slot' static (8 bytes) + // Field #1 'ProposerIndex' static (8 bytes) + // Field #2 'ParentRoot' static (32 bytes) + // Field #3 'StateRoot' static (32 bytes) + // Field #4 'Body' offset (4 bytes) + size += 84 + { // Dynamic field #4 'Body' + size += t.Body.SizeSSZDyn(ds) + } + return size +} + +// HashTreeRootDyn computes the SSZ hash tree root of the *BeaconBlock using dynamic specifications. +func (t *BeaconBlock) HashTreeRootDyn(ds sszutils.DynamicSpecs) (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWithDyn(ds, hh) + if err == nil { + root, err = hh.HashRoot() + } + return + }) + return +} + +// HashTreeRootWithDyn computes the SSZ hash tree root of the *BeaconBlock using dynamic specifications and the given hash walker. +func (t *BeaconBlock) HashTreeRootWithDyn(ds sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + if t == nil { + t = new(BeaconBlock) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Slot' + hh.PutUint64(t.Slot) + } + { // Field #1 'ProposerIndex' + hh.PutUint64(t.ProposerIndex) + } + { // Field #2 'ParentRoot' + hh.PutBytes(t.ParentRoot[:32]) + } + { // Field #3 'StateRoot' + hh.PutBytes(t.StateRoot[:32]) + } + { // Field #4 'Body' + t := t.Body + if t == nil { + t = new(BeaconBlockBody) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPath(err, "Body") + } + } + hh.Merkleize(idx) + return nil +} + +// MarshalSSZDyn marshals the *BeaconBlockBody to SSZ-encoded bytes using dynamic specifications. +func (t *BeaconBlockBody) MarshalSSZDyn(ds sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + dst = buf + zeroBytes := sszutils.ZeroBytes() + if t == nil { + t = new(BeaconBlockBody) + } + dstlen := len(dst) + { // Static Field #0 'RandaoReveal' + vlen := len(t.RandaoReveal) + if vlen > 96 { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 96), "RandaoReveal") + } + dst = append(dst, t.RandaoReveal[:vlen]...) + if vlen < 96 { + dst = sszutils.AppendZeroPadding(dst, (96-vlen)*1) + } + } + { // Static Field #1 'Eth1Data' + t := t.Eth1Data + if t == nil { + t = new(generic.Eth1Data) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "Eth1Data") + } + } + { // Static Field #2 'Graffiti' + dst = append(dst, t.Graffiti[:32]...) + } + // Offset Field #3 'ProposerSlashings' + // Offset Field #4 'AttesterSlashings' + // Offset Field #5 'Attestations' + // Offset Field #6 'Deposits' + // Offset Field #7 'VoluntaryExits' + dst = append(dst, zeroBytes[:20]...) + { // Static Field #8 'SyncAggregate' + t := t.SyncAggregate + if t == nil { + t = new(generic.SyncAggregate) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "SyncAggregate") + } + } + // Offset Field #9 'ExecutionPayload' + // Offset Field #10 'BlsToExecutionChanges' + // Offset Field #11 'BlobKzgCommitments' + // Offset Field #12 'ExecutionRequests' + dst = append(dst, zeroBytes[:16]...) + { // Dynamic Field #3 'ProposerSlashings' + binary.LittleEndian.PutUint32(dst[dstlen+200:], uint32(len(dst)-dstlen)) + t := t.ProposerSlashings + vlen := len(t) + if vlen > 16 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16), "ProposerSlashings") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(generic.ProposerSlashing) + } + if dst, err = t.MarshalSSZDyn(ds, dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "ProposerSlashings[%d]", idx1) + } + } + } + { // Dynamic Field #4 'AttesterSlashings' + binary.LittleEndian.PutUint32(dst[dstlen+204:], uint32(len(dst)-dstlen)) + t := t.AttesterSlashings + vlen := len(t) + if vlen > 1 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1), "AttesterSlashings") + } + dstlen := len(dst) + dst = sszutils.AppendZeroPadding(dst, vlen*4) + for idx1 := range vlen { + binary.LittleEndian.PutUint32(dst[dstlen+(idx1*4):], uint32(len(dst)-dstlen)) + t := t[idx1] + if t == nil { + t = new(AttesterSlashing) + } + if dst, err = t.MarshalSSZDyn(ds, dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "AttesterSlashings[%d]", idx1) + } + } + } + { // Dynamic Field #5 'Attestations' + binary.LittleEndian.PutUint32(dst[dstlen+208:], uint32(len(dst)-dstlen)) + t := t.Attestations + vlen := len(t) + if vlen > 8 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 8), "Attestations") + } + dstlen := len(dst) + dst = sszutils.AppendZeroPadding(dst, vlen*4) + for idx1 := range vlen { + binary.LittleEndian.PutUint32(dst[dstlen+(idx1*4):], uint32(len(dst)-dstlen)) + t := t[idx1] + if t == nil { + t = new(Attestation) + } + if dst, err = t.MarshalSSZDyn(ds, dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "Attestations[%d]", idx1) + } + } + } + { // Dynamic Field #6 'Deposits' + binary.LittleEndian.PutUint32(dst[dstlen+212:], uint32(len(dst)-dstlen)) + t := t.Deposits + vlen := len(t) + if vlen > 16 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16), "Deposits") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(generic.Deposit) + } + if dst, err = t.MarshalSSZDyn(ds, dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "Deposits[%d]", idx1) + } + } + } + { // Dynamic Field #7 'VoluntaryExits' + binary.LittleEndian.PutUint32(dst[dstlen+216:], uint32(len(dst)-dstlen)) + t := t.VoluntaryExits + vlen := len(t) + if vlen > 16 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16), "VoluntaryExits") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(generic.SignedVoluntaryExit) + } + if dst, err = t.MarshalSSZDyn(ds, dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "VoluntaryExits[%d]", idx1) + } + } + } + { // Dynamic Field #9 'ExecutionPayload' + binary.LittleEndian.PutUint32(dst[dstlen+380:], uint32(len(dst)-dstlen)) + t := t.ExecutionPayload + if t == nil { + t = new(generic.ExecutionPayload) + } + if dst, err = t.MarshalSSZDyn(ds, dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "ExecutionPayload") + } + } + { // Dynamic Field #10 'BlsToExecutionChanges' + binary.LittleEndian.PutUint32(dst[dstlen+384:], uint32(len(dst)-dstlen)) + t := t.BlsToExecutionChanges + vlen := len(t) + if vlen > 16 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16), "BlsToExecutionChanges") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(generic.SignedBLSToExecutionChange) + } + if dst, err = t.MarshalSSZDyn(ds, dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "BlsToExecutionChanges[%d]", idx1) + } + } + } + { // Dynamic Field #11 'BlobKzgCommitments' + binary.LittleEndian.PutUint32(dst[dstlen+388:], uint32(len(dst)-dstlen)) + t := t.BlobKzgCommitments + vlen := len(t) + if vlen > 4096 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 4096), "BlobKzgCommitments") + } + dst = sszutils.MarshalFixedBytesSlice(dst, t[:vlen]) + } + { // Dynamic Field #12 'ExecutionRequests' + binary.LittleEndian.PutUint32(dst[dstlen+392:], uint32(len(dst)-dstlen)) + t := t.ExecutionRequests + if t == nil { + t = new(ExecutionRequests) + } + if dst, err = t.MarshalSSZDyn(ds, dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "ExecutionRequests") + } + } + return dst, nil +} + +// MarshalSSZEncoder marshals the *BeaconBlockBody to the given SSZ encoder using dynamic specifications. +func (t *BeaconBlockBody) MarshalSSZEncoder(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + type encoderCtx struct { + ds sszutils.DynamicSpecs + exprs [0]uint64 + sizeFn1 func(ctx *encoderCtx, t []*generic.ProposerSlashing) (size int) + sizeFn10 func(ctx *encoderCtx, t *AttesterSlashing) (size int) + sizeFn11 func(ctx *encoderCtx, t *Attestation) (size int) + sizeFn2 func(ctx *encoderCtx, t []*AttesterSlashing) (size int) + sizeFn3 func(ctx *encoderCtx, t []*Attestation) (size int) + sizeFn4 func(ctx *encoderCtx, t []*generic.Deposit) (size int) + sizeFn5 func(ctx *encoderCtx, t []*generic.SignedVoluntaryExit) (size int) + sizeFn6 func(ctx *encoderCtx, t *generic.ExecutionPayload) (size int) + sizeFn7 func(ctx *encoderCtx, t []*generic.SignedBLSToExecutionChange) (size int) + sizeFn8 func(ctx *encoderCtx, t [][48]byte) (size int) + sizeFn9 func(ctx *encoderCtx, t *ExecutionRequests) (size int) + } + ctx := &encoderCtx{ds: ds} + canSeek := enc.Seekable() + // size for []*generic.ProposerSlashing + ctx.sizeFn1 = func(ctx *encoderCtx, t []*generic.ProposerSlashing) (size int) { + size += len(t) * 416 + return size + } + // size for []*AttesterSlashing + ctx.sizeFn2 = func(ctx *encoderCtx, t []*AttesterSlashing) (size int) { + vlen := len(t) + size += vlen * 4 // Offsets + for i1 := range vlen { + size += ctx.sizeFn10(ctx, t[i1]) + } + return size + } + // size for []*Attestation + ctx.sizeFn3 = func(ctx *encoderCtx, t []*Attestation) (size int) { + vlen := len(t) + size += vlen * 4 // Offsets + for i1 := range vlen { + size += ctx.sizeFn11(ctx, t[i1]) + } + return size + } + // size for []*generic.Deposit + ctx.sizeFn4 = func(ctx *encoderCtx, t []*generic.Deposit) (size int) { + size += len(t) * 1240 + return size + } + // size for []*generic.SignedVoluntaryExit + ctx.sizeFn5 = func(ctx *encoderCtx, t []*generic.SignedVoluntaryExit) (size int) { + size += len(t) * 112 + return size + } + // size for *generic.ExecutionPayload + ctx.sizeFn6 = func(ctx *encoderCtx, t *generic.ExecutionPayload) (size int) { + size += t.SizeSSZDyn(ds) + return size + } + // size for []*generic.SignedBLSToExecutionChange + ctx.sizeFn7 = func(ctx *encoderCtx, t []*generic.SignedBLSToExecutionChange) (size int) { + size += len(t) * 172 + return size + } + // size for [][48]byte + ctx.sizeFn8 = func(ctx *encoderCtx, t [][48]byte) (size int) { + size += len(t) * 48 + return size + } + // size for *ExecutionRequests + ctx.sizeFn9 = func(ctx *encoderCtx, t *ExecutionRequests) (size int) { + size += t.SizeSSZDyn(ds) + return size + } + // size for *AttesterSlashing + ctx.sizeFn10 = func(ctx *encoderCtx, t *AttesterSlashing) (size int) { + size += t.SizeSSZDyn(ds) + return size + } + // size for *Attestation + ctx.sizeFn11 = func(ctx *encoderCtx, t *Attestation) (size int) { + size += t.SizeSSZDyn(ds) + return size + } + if t == nil { + t = new(BeaconBlockBody) + } + dstlen := enc.GetPosition() + dynoff := uint32(396) + { // Field #0 'RandaoReveal' + vlen := len(t.RandaoReveal) + if vlen > 96 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 96), "RandaoReveal") + } + enc.EncodeBytes(t.RandaoReveal[:vlen]) + if vlen < 96 { + enc.EncodeZeroPadding((96 - vlen) * 1) + } + } + { // Field #1 'Eth1Data' + t := t.Eth1Data + if t == nil { + t = new(generic.Eth1Data) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "Eth1Data") + } else { + enc.SetBuffer(buf) + } + } + { // Field #2 'Graffiti' + enc.EncodeBytes(t.Graffiti[:32]) + } + // Offset #3 'ProposerSlashings' + offset3 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn1(ctx, t.ProposerSlashings)) + } + // Offset #4 'AttesterSlashings' + offset4 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn2(ctx, t.AttesterSlashings)) + } + // Offset #5 'Attestations' + offset5 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn3(ctx, t.Attestations)) + } + // Offset #6 'Deposits' + offset6 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn4(ctx, t.Deposits)) + } + // Offset #7 'VoluntaryExits' + offset7 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn5(ctx, t.VoluntaryExits)) + } + { // Field #8 'SyncAggregate' + t := t.SyncAggregate + if t == nil { + t = new(generic.SyncAggregate) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "SyncAggregate") + } else { + enc.SetBuffer(buf) + } + } + // Offset #9 'ExecutionPayload' + offset9 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn6(ctx, t.ExecutionPayload)) + } + // Offset #10 'BlsToExecutionChanges' + offset10 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn7(ctx, t.BlsToExecutionChanges)) + } + // Offset #11 'BlobKzgCommitments' + offset11 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn8(ctx, t.BlobKzgCommitments)) + } + // Offset #12 'ExecutionRequests' + offset12 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn9(ctx, t.ExecutionRequests)) + } + { // Dynamic Field #3 'ProposerSlashings' + if canSeek { + enc.EncodeOffsetAt(offset3, uint32(enc.GetPosition()-dstlen)) + } + t := t.ProposerSlashings + vlen := len(t) + if vlen > 16 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16), "ProposerSlashings") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(generic.ProposerSlashing) + } + if err = t.MarshalSSZEncoder(ds, enc); err != nil { + return sszutils.ErrorWithPathf(err, "ProposerSlashings[%d]", idx1) + } + } + } + { // Dynamic Field #4 'AttesterSlashings' + if canSeek { + enc.EncodeOffsetAt(offset4, uint32(enc.GetPosition()-dstlen)) + } + t := t.AttesterSlashings + vlen := len(t) + if vlen > 1 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1), "AttesterSlashings") + } + dstlen := enc.GetPosition() + if canSeek { + enc.EncodeZeroPadding(vlen * 4) + } else if vlen > 0 { + offset := vlen * 4 + enc.EncodeOffset(uint32(offset)) + for i := range vlen - 1 { + offset += ctx.sizeFn10(ctx, t[i]) + enc.EncodeOffset(uint32(offset)) + } + } + for idx1 := range vlen { + if canSeek { + enc.EncodeOffsetAt(dstlen+(idx1*4), uint32(enc.GetPosition()-dstlen)) + } + t := t[idx1] + if t == nil { + t = new(AttesterSlashing) + } + if err = t.MarshalSSZEncoder(ds, enc); err != nil { + return sszutils.ErrorWithPathf(err, "AttesterSlashings[%d]", idx1) + } + } + } + { // Dynamic Field #5 'Attestations' + if canSeek { + enc.EncodeOffsetAt(offset5, uint32(enc.GetPosition()-dstlen)) + } + t := t.Attestations + vlen := len(t) + if vlen > 8 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 8), "Attestations") + } + dstlen := enc.GetPosition() + if canSeek { + enc.EncodeZeroPadding(vlen * 4) + } else if vlen > 0 { + offset := vlen * 4 + enc.EncodeOffset(uint32(offset)) + for i := range vlen - 1 { + offset += ctx.sizeFn11(ctx, t[i]) + enc.EncodeOffset(uint32(offset)) + } + } + for idx1 := range vlen { + if canSeek { + enc.EncodeOffsetAt(dstlen+(idx1*4), uint32(enc.GetPosition()-dstlen)) + } + t := t[idx1] + if t == nil { + t = new(Attestation) + } + if err = t.MarshalSSZEncoder(ds, enc); err != nil { + return sszutils.ErrorWithPathf(err, "Attestations[%d]", idx1) + } + } + } + { // Dynamic Field #6 'Deposits' + if canSeek { + enc.EncodeOffsetAt(offset6, uint32(enc.GetPosition()-dstlen)) + } + t := t.Deposits + vlen := len(t) + if vlen > 16 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16), "Deposits") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(generic.Deposit) + } + if err = t.MarshalSSZEncoder(ds, enc); err != nil { + return sszutils.ErrorWithPathf(err, "Deposits[%d]", idx1) + } + } + } + { // Dynamic Field #7 'VoluntaryExits' + if canSeek { + enc.EncodeOffsetAt(offset7, uint32(enc.GetPosition()-dstlen)) + } + t := t.VoluntaryExits + vlen := len(t) + if vlen > 16 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16), "VoluntaryExits") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(generic.SignedVoluntaryExit) + } + if err = t.MarshalSSZEncoder(ds, enc); err != nil { + return sszutils.ErrorWithPathf(err, "VoluntaryExits[%d]", idx1) + } + } + } + { // Dynamic Field #9 'ExecutionPayload' + if canSeek { + enc.EncodeOffsetAt(offset9, uint32(enc.GetPosition()-dstlen)) + } + t := t.ExecutionPayload + if t == nil { + t = new(generic.ExecutionPayload) + } + if err = t.MarshalSSZEncoder(ds, enc); err != nil { + return sszutils.ErrorWithPath(err, "ExecutionPayload") + } + } + { // Dynamic Field #10 'BlsToExecutionChanges' + if canSeek { + enc.EncodeOffsetAt(offset10, uint32(enc.GetPosition()-dstlen)) + } + t := t.BlsToExecutionChanges + vlen := len(t) + if vlen > 16 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16), "BlsToExecutionChanges") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(generic.SignedBLSToExecutionChange) + } + if err = t.MarshalSSZEncoder(ds, enc); err != nil { + return sszutils.ErrorWithPathf(err, "BlsToExecutionChanges[%d]", idx1) + } + } + } + { // Dynamic Field #11 'BlobKzgCommitments' + if canSeek { + enc.EncodeOffsetAt(offset11, uint32(enc.GetPosition()-dstlen)) + } + t := t.BlobKzgCommitments + vlen := len(t) + if vlen > 4096 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 4096), "BlobKzgCommitments") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:48]) + } + } + { // Dynamic Field #12 'ExecutionRequests' + if canSeek { + enc.EncodeOffsetAt(offset12, uint32(enc.GetPosition()-dstlen)) + } + t := t.ExecutionRequests + if t == nil { + t = new(ExecutionRequests) + } + if err = t.MarshalSSZEncoder(ds, enc); err != nil { + return sszutils.ErrorWithPath(err, "ExecutionRequests") + } + } + return nil +} + +// UnmarshalSSZDyn unmarshals the *BeaconBlockBody from SSZ-encoded bytes using dynamic specifications. +func (t *BeaconBlockBody) UnmarshalSSZDyn(ds sszutils.DynamicSpecs, buf []byte) (err error) { + buflen := len(buf) + if buflen < 396 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 396) + } + { // Field #0 'RandaoReveal' (static) + buf := buf[0:96] + t.RandaoReveal = sszutils.ExpandSlice(t.RandaoReveal, 96) + copy(t.RandaoReveal[:], buf) + } + { // Field #1 'Eth1Data' (static) + buf := buf[96:168] + if t.Eth1Data == nil { + t.Eth1Data = new(generic.Eth1Data) + } + if err = t.Eth1Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "Eth1Data") + } + } + { // Field #2 'Graffiti' (static) + buf := buf[168:200] + copy(t.Graffiti[:], buf) + } + // Field #3 'ProposerSlashings' (offset) + offset3 := int(binary.LittleEndian.Uint32(buf[200:204])) + if offset3 != 396 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset3, 396), "ProposerSlashings:o") + } + // Field #4 'AttesterSlashings' (offset) + offset4 := int(binary.LittleEndian.Uint32(buf[204:208])) + if offset4 < offset3 || offset4 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset4, offset3, buflen), "AttesterSlashings:o") + } + // Field #5 'Attestations' (offset) + offset5 := int(binary.LittleEndian.Uint32(buf[208:212])) + if offset5 < offset4 || offset5 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset5, offset4, buflen), "Attestations:o") + } + // Field #6 'Deposits' (offset) + offset6 := int(binary.LittleEndian.Uint32(buf[212:216])) + if offset6 < offset5 || offset6 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset6, offset5, buflen), "Deposits:o") + } + // Field #7 'VoluntaryExits' (offset) + offset7 := int(binary.LittleEndian.Uint32(buf[216:220])) + if offset7 < offset6 || offset7 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset7, offset6, buflen), "VoluntaryExits:o") + } + { // Field #8 'SyncAggregate' (static) + buf := buf[220:380] + if t.SyncAggregate == nil { + t.SyncAggregate = new(generic.SyncAggregate) + } + if err = t.SyncAggregate.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "SyncAggregate") + } + } + // Field #9 'ExecutionPayload' (offset) + offset9 := int(binary.LittleEndian.Uint32(buf[380:384])) + if offset9 < offset7 || offset9 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset9, offset7, buflen), "ExecutionPayload:o") + } + // Field #10 'BlsToExecutionChanges' (offset) + offset10 := int(binary.LittleEndian.Uint32(buf[384:388])) + if offset10 < offset9 || offset10 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset10, offset9, buflen), "BlsToExecutionChanges:o") + } + // Field #11 'BlobKzgCommitments' (offset) + offset11 := int(binary.LittleEndian.Uint32(buf[388:392])) + if offset11 < offset10 || offset11 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset11, offset10, buflen), "BlobKzgCommitments:o") + } + // Field #12 'ExecutionRequests' (offset) + offset12 := int(binary.LittleEndian.Uint32(buf[392:396])) + if offset12 < offset11 || offset12 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset12, offset11, buflen), "ExecutionRequests:o") + } + { // Field #3 'ProposerSlashings' (dynamic) + buf := buf[offset3:offset4] + val1 := t.ProposerSlashings + itemCount := len(buf) / 416 + if len(buf)%416 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 416), "ProposerSlashings") + } + if itemCount > 16 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 16), "ProposerSlashings") + } + val1 = sszutils.ExpandSlice(val1, itemCount) + for idx1 := range itemCount { + if val1[idx1] == nil { + val1[idx1] = new(generic.ProposerSlashing) + } + buf := buf[416*idx1 : 416*(idx1+1)] + if err = val1[idx1].UnmarshalSSZDyn(ds, buf); err != nil { + return sszutils.ErrorWithPathf(err, "ProposerSlashings[%d]", idx1) + } + } + t.ProposerSlashings = val1 + } + { // Field #4 'AttesterSlashings' (dynamic) + buf := buf[offset4:offset5] + val2 := t.AttesterSlashings + startOffset := int(0) + if len(buf) != 0 { + if len(buf) < 4 { + return sszutils.ErrorWithPath(sszutils.ErrListOffsetsEOFFn(len(buf), 4), "AttesterSlashings") + } + startOffset = int(binary.LittleEndian.Uint32(buf[0:4])) + } + itemCount := startOffset / 4 + if startOffset%4 != 0 || len(buf) < startOffset || (len(buf) != 0 && startOffset == 0) { + return sszutils.ErrorWithPath(sszutils.ErrInvalidListStartOffsetFn(startOffset, len(buf)), "AttesterSlashings") + } + if itemCount > 1 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1), "AttesterSlashings") + } + val2 = sszutils.ExpandSlice(val2, itemCount) + for idx1 := range itemCount { + var endOffset int + if idx1 < itemCount-1 { + endOffset = int(binary.LittleEndian.Uint32(buf[(idx1+1)*4 : (idx1+2)*4])) + } else { + endOffset = len(buf) + } + if endOffset < startOffset || endOffset > len(buf) { + return sszutils.ErrorWithPathf(sszutils.ErrElementOffsetOutOfRangeFn(endOffset, startOffset, len(buf)), "AttesterSlashings[%d]", idx1) + } + buf := buf[startOffset:endOffset] + startOffset = endOffset + val3 := val2[idx1] + if val3 == nil { + val3 = new(AttesterSlashing) + } + if err = val3.UnmarshalSSZDyn(ds, buf); err != nil { + return sszutils.ErrorWithPathf(err, "AttesterSlashings[%d]", idx1) + } + val2[idx1] = val3 + } + t.AttesterSlashings = val2 + } + { // Field #5 'Attestations' (dynamic) + buf := buf[offset5:offset6] + val4 := t.Attestations + startOffset := int(0) + if len(buf) != 0 { + if len(buf) < 4 { + return sszutils.ErrorWithPath(sszutils.ErrListOffsetsEOFFn(len(buf), 4), "Attestations") + } + startOffset = int(binary.LittleEndian.Uint32(buf[0:4])) + } + itemCount := startOffset / 4 + if startOffset%4 != 0 || len(buf) < startOffset || (len(buf) != 0 && startOffset == 0) { + return sszutils.ErrorWithPath(sszutils.ErrInvalidListStartOffsetFn(startOffset, len(buf)), "Attestations") + } + if itemCount > 8 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 8), "Attestations") + } + val4 = sszutils.ExpandSlice(val4, itemCount) + for idx1 := range itemCount { + var endOffset int + if idx1 < itemCount-1 { + endOffset = int(binary.LittleEndian.Uint32(buf[(idx1+1)*4 : (idx1+2)*4])) + } else { + endOffset = len(buf) + } + if endOffset < startOffset || endOffset > len(buf) { + return sszutils.ErrorWithPathf(sszutils.ErrElementOffsetOutOfRangeFn(endOffset, startOffset, len(buf)), "Attestations[%d]", idx1) + } + buf := buf[startOffset:endOffset] + startOffset = endOffset + val5 := val4[idx1] + if val5 == nil { + val5 = new(Attestation) + } + if err = val5.UnmarshalSSZDyn(ds, buf); err != nil { + return sszutils.ErrorWithPathf(err, "Attestations[%d]", idx1) + } + val4[idx1] = val5 + } + t.Attestations = val4 + } + { // Field #6 'Deposits' (dynamic) + buf := buf[offset6:offset7] + val6 := t.Deposits + itemCount := len(buf) / 1240 + if len(buf)%1240 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 1240), "Deposits") + } + if itemCount > 16 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 16), "Deposits") + } + val6 = sszutils.ExpandSlice(val6, itemCount) + for idx1 := range itemCount { + if val6[idx1] == nil { + val6[idx1] = new(generic.Deposit) + } + buf := buf[1240*idx1 : 1240*(idx1+1)] + if err = val6[idx1].UnmarshalSSZDyn(ds, buf); err != nil { + return sszutils.ErrorWithPathf(err, "Deposits[%d]", idx1) + } + } + t.Deposits = val6 + } + { // Field #7 'VoluntaryExits' (dynamic) + buf := buf[offset7:offset9] + val7 := t.VoluntaryExits + itemCount := len(buf) / 112 + if len(buf)%112 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 112), "VoluntaryExits") + } + if itemCount > 16 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 16), "VoluntaryExits") + } + val7 = sszutils.ExpandSlice(val7, itemCount) + for idx1 := range itemCount { + if val7[idx1] == nil { + val7[idx1] = new(generic.SignedVoluntaryExit) + } + buf := buf[112*idx1 : 112*(idx1+1)] + if err = val7[idx1].UnmarshalSSZDyn(ds, buf); err != nil { + return sszutils.ErrorWithPathf(err, "VoluntaryExits[%d]", idx1) + } + } + t.VoluntaryExits = val7 + } + { // Field #9 'ExecutionPayload' (dynamic) + buf := buf[offset9:offset10] + if t.ExecutionPayload == nil { + t.ExecutionPayload = new(generic.ExecutionPayload) + } + if err = t.ExecutionPayload.UnmarshalSSZDyn(ds, buf); err != nil { + return sszutils.ErrorWithPath(err, "ExecutionPayload") + } + } + { // Field #10 'BlsToExecutionChanges' (dynamic) + buf := buf[offset10:offset11] + val8 := t.BlsToExecutionChanges + itemCount := len(buf) / 172 + if len(buf)%172 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 172), "BlsToExecutionChanges") + } + if itemCount > 16 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 16), "BlsToExecutionChanges") + } + val8 = sszutils.ExpandSlice(val8, itemCount) + for idx1 := range itemCount { + if val8[idx1] == nil { + val8[idx1] = new(generic.SignedBLSToExecutionChange) + } + buf := buf[172*idx1 : 172*(idx1+1)] + if err = val8[idx1].UnmarshalSSZDyn(ds, buf); err != nil { + return sszutils.ErrorWithPathf(err, "BlsToExecutionChanges[%d]", idx1) + } + } + t.BlsToExecutionChanges = val8 + } + { // Field #11 'BlobKzgCommitments' (dynamic) + buf := buf[offset11:offset12] + val9 := t.BlobKzgCommitments + itemCount := len(buf) / 48 + if len(buf)%48 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 48), "BlobKzgCommitments") + } + if itemCount > 4096 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 4096), "BlobKzgCommitments") + } + val9 = sszutils.ExpandSlice(val9, itemCount) + sszutils.UnmarshalFixedBytesSlice(val9[:itemCount], buf) + t.BlobKzgCommitments = val9 + } + { // Field #12 'ExecutionRequests' (dynamic) + buf := buf[offset12:] + if t.ExecutionRequests == nil { + t.ExecutionRequests = new(ExecutionRequests) + } + if err = t.ExecutionRequests.UnmarshalSSZDyn(ds, buf); err != nil { + return sszutils.ErrorWithPath(err, "ExecutionRequests") + } + } + return nil +} + +// UnmarshalSSZDecoder unmarshals the *BeaconBlockBody from the given SSZ decoder using dynamic specifications. +func (t *BeaconBlockBody) UnmarshalSSZDecoder(ds sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { + canSeek := dec.Seekable() + offsetSlices := [1][]uint32{ + sszutils.GetOffsetSlice(0), + } + defer func() { + sszutils.PutOffsetSlice(offsetSlices[0]) + }() + maxOffset := uint32(dec.GetLength()) + startPos0 := dec.GetPosition() + if maxOffset < uint32(396) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(396)) + } + // Field #0 'RandaoReveal' (static) + t.RandaoReveal = sszutils.ExpandSlice(t.RandaoReveal, 96) + if _, err = dec.DecodeBytes(t.RandaoReveal[:96]); err != nil { + return err + } + // Field #1 'Eth1Data' (static) + if t.Eth1Data == nil { + t.Eth1Data = new(generic.Eth1Data) + } + if err = t.Eth1Data.UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPath(err, "Eth1Data") + } + // Field #2 'Graffiti' (static) + if _, err = dec.DecodeBytes(t.Graffiti[:32]); err != nil { + return err + } + // Field #3 'ProposerSlashings' (offset) + offset3, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "ProposerSlashings") + } + if offset3 != uint32(396) { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset3, 396), "ProposerSlashings") + } + // Field #4 'AttesterSlashings' (offset) + offset4, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "AttesterSlashings") + } + if offset4 < offset3 || offset4 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset4, offset3, maxOffset), "AttesterSlashings") + } + // Field #5 'Attestations' (offset) + offset5, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Attestations") + } + if offset5 < offset4 || offset5 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset5, offset4, maxOffset), "Attestations") + } + // Field #6 'Deposits' (offset) + offset6, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Deposits") + } + if offset6 < offset5 || offset6 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset6, offset5, maxOffset), "Deposits") + } + // Field #7 'VoluntaryExits' (offset) + offset7, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "VoluntaryExits") + } + if offset7 < offset6 || offset7 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset7, offset6, maxOffset), "VoluntaryExits") + } + // Field #8 'SyncAggregate' (static) + if t.SyncAggregate == nil { + t.SyncAggregate = new(generic.SyncAggregate) + } + if err = t.SyncAggregate.UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPath(err, "SyncAggregate") + } + // Field #9 'ExecutionPayload' (offset) + offset9, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "ExecutionPayload") + } + if offset9 < offset7 || offset9 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset9, offset7, maxOffset), "ExecutionPayload") + } + // Field #10 'BlsToExecutionChanges' (offset) + offset10, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "BlsToExecutionChanges") + } + if offset10 < offset9 || offset10 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset10, offset9, maxOffset), "BlsToExecutionChanges") + } + // Field #11 'BlobKzgCommitments' (offset) + offset11, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "BlobKzgCommitments") + } + if offset11 < offset10 || offset11 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset11, offset10, maxOffset), "BlobKzgCommitments") + } + // Field #12 'ExecutionRequests' (offset) + offset12, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "ExecutionRequests") + } + if offset12 < offset11 || offset12 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset12, offset11, maxOffset), "ExecutionRequests") + } + { // Field #3 'ProposerSlashings' (dynamic) + if dec.GetPosition() != startPos0+int(offset3) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset3)), "ProposerSlashings") + } + dec.PushLimit(int(offset4 - offset3)) + val1 := t.ProposerSlashings + sszLen := dec.GetLength() + itemCount := sszLen / 416 + if sszLen%416 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 416), "ProposerSlashings") + } + if itemCount > 16 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 16), "ProposerSlashings") + } + val1 = sszutils.ExpandSlice(val1, itemCount) + startPos1 := dec.GetPosition() + for idx1 := range itemCount { + if val1[idx1] == nil { + val1[idx1] = new(generic.ProposerSlashing) + } + if err = val1[idx1].UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPathf(err, "ProposerSlashings[%d]", idx1) + } + if dec.GetPosition() != startPos1+int(416*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos1+int(416*(idx1+1))), "ProposerSlashings[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "ProposerSlashings") + } + t.ProposerSlashings = val1 + } + { // Field #4 'AttesterSlashings' (dynamic) + if dec.GetPosition() != startPos0+int(offset4) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset4)), "AttesterSlashings") + } + dec.PushLimit(int(offset5 - offset4)) + val2 := t.AttesterSlashings + startOffset := uint32(0) + startPos2 := dec.GetPosition() + sszLen := uint32(dec.GetLength()) + if sszLen > 0 { + startOffset, err = dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "AttesterSlashings") + } + } + itemCount := int(startOffset / 4) + var offsets []uint32 + if canSeek { + dec.SkipBytes((itemCount - 1) * 4) + } else if itemCount > 1 { + offsetSlices[0] = sszutils.ExpandSlice(offsetSlices[0], itemCount-1) + offsets = offsetSlices[0] + for idx1 := range itemCount - 1 { + offset, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPathf(err, "AttesterSlashings[%d:o]", idx1) + } + offsets[idx1] = offset + } + } + if startOffset%4 != 0 || uint32(sszLen) < startOffset { + return sszutils.ErrorWithPath(sszutils.ErrInvalidListStartOffsetFn(startOffset, sszLen), "AttesterSlashings") + } + if itemCount > 1 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1), "AttesterSlashings") + } + val2 = sszutils.ExpandSlice(val2, itemCount) + for idx1 := range itemCount { + var endOffset uint32 + if idx1 < itemCount-1 { + if canSeek { + endOffset = dec.DecodeOffsetAt(startPos2 + int((idx1+1)*4)) + } else { + endOffset = offsets[idx1] + } + } else { + endOffset = uint32(sszLen) + } + if endOffset < startOffset || endOffset > uint32(sszLen) { + return sszutils.ErrorWithPathf(sszutils.ErrElementOffsetOutOfRangeFn(endOffset, startOffset, sszLen), "AttesterSlashings[%d]", idx1) + } + itemSize := endOffset - startOffset + dec.PushLimit(int(itemSize)) + startOffset = endOffset + val3 := val2[idx1] + if val3 == nil { + val3 = new(AttesterSlashing) + } + if err = val3.UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPathf(err, "AttesterSlashings[%d]", idx1) + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPathf(sszutils.ErrTrailingDataFn(diff), "AttesterSlashings[%d]", idx1) + } + val2[idx1] = val3 + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "AttesterSlashings") + } + t.AttesterSlashings = val2 + } + { // Field #5 'Attestations' (dynamic) + if dec.GetPosition() != startPos0+int(offset5) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset5)), "Attestations") + } + dec.PushLimit(int(offset6 - offset5)) + val4 := t.Attestations + startOffset := uint32(0) + startPos3 := dec.GetPosition() + sszLen := uint32(dec.GetLength()) + if sszLen > 0 { + startOffset, err = dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Attestations") + } + } + itemCount := int(startOffset / 4) + var offsets []uint32 + if canSeek { + dec.SkipBytes((itemCount - 1) * 4) + } else if itemCount > 1 { + offsetSlices[0] = sszutils.ExpandSlice(offsetSlices[0], itemCount-1) + offsets = offsetSlices[0] + for idx1 := range itemCount - 1 { + offset, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPathf(err, "Attestations[%d:o]", idx1) + } + offsets[idx1] = offset + } + } + if startOffset%4 != 0 || uint32(sszLen) < startOffset { + return sszutils.ErrorWithPath(sszutils.ErrInvalidListStartOffsetFn(startOffset, sszLen), "Attestations") + } + if itemCount > 8 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 8), "Attestations") + } + val4 = sszutils.ExpandSlice(val4, itemCount) + for idx1 := range itemCount { + var endOffset uint32 + if idx1 < itemCount-1 { + if canSeek { + endOffset = dec.DecodeOffsetAt(startPos3 + int((idx1+1)*4)) + } else { + endOffset = offsets[idx1] + } + } else { + endOffset = uint32(sszLen) + } + if endOffset < startOffset || endOffset > uint32(sszLen) { + return sszutils.ErrorWithPathf(sszutils.ErrElementOffsetOutOfRangeFn(endOffset, startOffset, sszLen), "Attestations[%d]", idx1) + } + itemSize := endOffset - startOffset + dec.PushLimit(int(itemSize)) + startOffset = endOffset + val5 := val4[idx1] + if val5 == nil { + val5 = new(Attestation) + } + if err = val5.UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPathf(err, "Attestations[%d]", idx1) + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPathf(sszutils.ErrTrailingDataFn(diff), "Attestations[%d]", idx1) + } + val4[idx1] = val5 + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Attestations") + } + t.Attestations = val4 + } + { // Field #6 'Deposits' (dynamic) + if dec.GetPosition() != startPos0+int(offset6) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset6)), "Deposits") + } + dec.PushLimit(int(offset7 - offset6)) + val6 := t.Deposits + sszLen := dec.GetLength() + itemCount := sszLen / 1240 + if sszLen%1240 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 1240), "Deposits") + } + if itemCount > 16 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 16), "Deposits") + } + val6 = sszutils.ExpandSlice(val6, itemCount) + startPos4 := dec.GetPosition() + for idx1 := range itemCount { + if val6[idx1] == nil { + val6[idx1] = new(generic.Deposit) + } + if err = val6[idx1].UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPathf(err, "Deposits[%d]", idx1) + } + if dec.GetPosition() != startPos4+int(1240*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos4+int(1240*(idx1+1))), "Deposits[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Deposits") + } + t.Deposits = val6 + } + { // Field #7 'VoluntaryExits' (dynamic) + if dec.GetPosition() != startPos0+int(offset7) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset7)), "VoluntaryExits") + } + dec.PushLimit(int(offset9 - offset7)) + val7 := t.VoluntaryExits + sszLen := dec.GetLength() + itemCount := sszLen / 112 + if sszLen%112 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 112), "VoluntaryExits") + } + if itemCount > 16 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 16), "VoluntaryExits") + } + val7 = sszutils.ExpandSlice(val7, itemCount) + startPos5 := dec.GetPosition() + for idx1 := range itemCount { + if val7[idx1] == nil { + val7[idx1] = new(generic.SignedVoluntaryExit) + } + if err = val7[idx1].UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPathf(err, "VoluntaryExits[%d]", idx1) + } + if dec.GetPosition() != startPos5+int(112*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos5+int(112*(idx1+1))), "VoluntaryExits[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "VoluntaryExits") + } + t.VoluntaryExits = val7 + } + { // Field #9 'ExecutionPayload' (dynamic) + if dec.GetPosition() != startPos0+int(offset9) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset9)), "ExecutionPayload") + } + dec.PushLimit(int(offset10 - offset9)) + val8 := t.ExecutionPayload + if val8 == nil { + val8 = new(generic.ExecutionPayload) + } + if err = val8.UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPath(err, "ExecutionPayload") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "ExecutionPayload") + } + t.ExecutionPayload = val8 + } + { // Field #10 'BlsToExecutionChanges' (dynamic) + if dec.GetPosition() != startPos0+int(offset10) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset10)), "BlsToExecutionChanges") + } + dec.PushLimit(int(offset11 - offset10)) + val9 := t.BlsToExecutionChanges + sszLen := dec.GetLength() + itemCount := sszLen / 172 + if sszLen%172 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 172), "BlsToExecutionChanges") + } + if itemCount > 16 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 16), "BlsToExecutionChanges") + } + val9 = sszutils.ExpandSlice(val9, itemCount) + startPos6 := dec.GetPosition() + for idx1 := range itemCount { + if val9[idx1] == nil { + val9[idx1] = new(generic.SignedBLSToExecutionChange) + } + if err = val9[idx1].UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPathf(err, "BlsToExecutionChanges[%d]", idx1) + } + if dec.GetPosition() != startPos6+int(172*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos6+int(172*(idx1+1))), "BlsToExecutionChanges[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "BlsToExecutionChanges") + } + t.BlsToExecutionChanges = val9 + } + { // Field #11 'BlobKzgCommitments' (dynamic) + if dec.GetPosition() != startPos0+int(offset11) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset11)), "BlobKzgCommitments") + } + dec.PushLimit(int(offset12 - offset11)) + val10 := t.BlobKzgCommitments + sszLen := dec.GetLength() + itemCount := sszLen / 48 + if sszLen%48 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 48), "BlobKzgCommitments") + } + if itemCount > 4096 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 4096), "BlobKzgCommitments") + } + val10 = sszutils.ExpandSlice(val10, itemCount) + startPos7 := dec.GetPosition() + for idx1 := range itemCount { + if _, err = dec.DecodeBytes(val10[idx1][:48]); err != nil { + return err + } + if dec.GetPosition() != startPos7+int(48*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos7+int(48*(idx1+1))), "BlobKzgCommitments[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "BlobKzgCommitments") + } + t.BlobKzgCommitments = val10 + } + { // Field #12 'ExecutionRequests' (dynamic) + if dec.GetPosition() != startPos0+int(offset12) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset12)), "ExecutionRequests") + } + dec.PushLimit(int(maxOffset - offset12)) + val11 := t.ExecutionRequests + if val11 == nil { + val11 = new(ExecutionRequests) + } + if err = val11.UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPath(err, "ExecutionRequests") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "ExecutionRequests") + } + t.ExecutionRequests = val11 + } + return nil +} + +// SizeSSZDyn returns the SSZ encoded size of the *BeaconBlockBody using dynamic specifications. +func (t *BeaconBlockBody) SizeSSZDyn(ds sszutils.DynamicSpecs) (size int) { + if t == nil { + t = new(BeaconBlockBody) + } + // Field #0 'RandaoReveal' static (96 bytes) + // Field #1 'Eth1Data' static (72 bytes) + // Field #2 'Graffiti' static (32 bytes) + // Field #3 'ProposerSlashings' offset (4 bytes) + // Field #4 'AttesterSlashings' offset (4 bytes) + // Field #5 'Attestations' offset (4 bytes) + // Field #6 'Deposits' offset (4 bytes) + // Field #7 'VoluntaryExits' offset (4 bytes) + // Field #8 'SyncAggregate' static (160 bytes) + // Field #9 'ExecutionPayload' offset (4 bytes) + // Field #10 'BlsToExecutionChanges' offset (4 bytes) + // Field #11 'BlobKzgCommitments' offset (4 bytes) + // Field #12 'ExecutionRequests' offset (4 bytes) + size += 396 + { // Dynamic field #3 'ProposerSlashings' + size += len(t.ProposerSlashings) * 416 + } + { // Dynamic field #4 'AttesterSlashings' + t := t.AttesterSlashings + vlen := len(t) + size += vlen * 4 // Offsets + for i1 := range vlen { + size += t[i1].SizeSSZDyn(ds) + } + } + { // Dynamic field #5 'Attestations' + t := t.Attestations + vlen := len(t) + size += vlen * 4 // Offsets + for i2 := range vlen { + size += t[i2].SizeSSZDyn(ds) + } + } + { // Dynamic field #6 'Deposits' + size += len(t.Deposits) * 1240 + } + { // Dynamic field #7 'VoluntaryExits' + size += len(t.VoluntaryExits) * 112 + } + { // Dynamic field #9 'ExecutionPayload' + size += t.ExecutionPayload.SizeSSZDyn(ds) + } + { // Dynamic field #10 'BlsToExecutionChanges' + size += len(t.BlsToExecutionChanges) * 172 + } + { // Dynamic field #11 'BlobKzgCommitments' + size += len(t.BlobKzgCommitments) * 48 + } + { // Dynamic field #12 'ExecutionRequests' + size += t.ExecutionRequests.SizeSSZDyn(ds) + } + return size +} + +// HashTreeRootDyn computes the SSZ hash tree root of the *BeaconBlockBody using dynamic specifications. +func (t *BeaconBlockBody) HashTreeRootDyn(ds sszutils.DynamicSpecs) (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWithDyn(ds, hh) + if err == nil { + root, err = hh.HashRoot() + } + return + }) + return +} + +// HashTreeRootWithDyn computes the SSZ hash tree root of the *BeaconBlockBody using dynamic specifications and the given hash walker. +func (t *BeaconBlockBody) HashTreeRootWithDyn(ds sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + if t == nil { + t = new(BeaconBlockBody) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'RandaoReveal' + vlen := len(t.RandaoReveal) + if vlen > 96 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 96), "RandaoReveal") + } + val := t.RandaoReveal[:] + if vlen < 96 { + val = sszutils.AppendZeroPadding(val, (96-vlen)*1) + } + hh.PutBytes(val[:96]) + } + { // Field #1 'Eth1Data' + t := t.Eth1Data + if t == nil { + t = new(generic.Eth1Data) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPath(err, "Eth1Data") + } + } + { // Field #2 'Graffiti' + hh.PutBytes(t.Graffiti[:32]) + } + { // Field #3 'ProposerSlashings' + t := t.ProposerSlashings + vlen := uint64(len(t)) + if vlen > 16 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16), "ProposerSlashings") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(generic.ProposerSlashing) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPathf(err, "ProposerSlashings[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(16, vlen, 32)) + } + { // Field #4 'AttesterSlashings' + t := t.AttesterSlashings + vlen := uint64(len(t)) + if vlen > 1 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1), "AttesterSlashings") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(AttesterSlashing) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPathf(err, "AttesterSlashings[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(1, vlen, 32)) + } + { // Field #5 'Attestations' + t := t.Attestations + vlen := uint64(len(t)) + if vlen > 8 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 8), "Attestations") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(Attestation) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPathf(err, "Attestations[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(8, vlen, 32)) + } + { // Field #6 'Deposits' + t := t.Deposits + vlen := uint64(len(t)) + if vlen > 16 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16), "Deposits") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(generic.Deposit) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPathf(err, "Deposits[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(16, vlen, 32)) + } + { // Field #7 'VoluntaryExits' + t := t.VoluntaryExits + vlen := uint64(len(t)) + if vlen > 16 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16), "VoluntaryExits") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(generic.SignedVoluntaryExit) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPathf(err, "VoluntaryExits[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(16, vlen, 32)) + } + { // Field #8 'SyncAggregate' + t := t.SyncAggregate + if t == nil { + t = new(generic.SyncAggregate) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPath(err, "SyncAggregate") + } + } + { // Field #9 'ExecutionPayload' + t := t.ExecutionPayload + if t == nil { + t = new(generic.ExecutionPayload) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPath(err, "ExecutionPayload") + } + } + { // Field #10 'BlsToExecutionChanges' + t := t.BlsToExecutionChanges + vlen := uint64(len(t)) + if vlen > 16 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16), "BlsToExecutionChanges") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(generic.SignedBLSToExecutionChange) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPathf(err, "BlsToExecutionChanges[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(16, vlen, 32)) + } + { // Field #11 'BlobKzgCommitments' + t := t.BlobKzgCommitments + vlen := uint64(len(t)) + if vlen > 4096 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 4096), "BlobKzgCommitments") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + hh.PutBytes(t[idx1][:48]) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(4096, vlen, 32)) + } + { // Field #12 'ExecutionRequests' + t := t.ExecutionRequests + if t == nil { + t = new(ExecutionRequests) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPath(err, "ExecutionRequests") + } + } + hh.Merkleize(idx) + return nil +} + +// MarshalSSZDyn marshals the *Attestation to SSZ-encoded bytes using dynamic specifications. +func (t *Attestation) MarshalSSZDyn(ds sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + dst = buf + if t == nil { + t = new(Attestation) + } + dstlen := len(dst) + // Offset Field #0 'AggregationBits' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #1 'Data' + t := t.Data + if t == nil { + t = new(generic.AttestationData) + } + if dst, err = t.MarshalSSZDyn(ds, dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "Data") + } + } + { // Static Field #2 'Signature' + dst = append(dst, t.Signature[:96]...) + } + { // Static Field #3 'CommitteeBits' + vlen := len(t.CommitteeBits) + if vlen > 8 { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 8), "CommitteeBits") + } + dst = append(dst, t.CommitteeBits[:vlen]...) + if vlen < 8 { + dst = sszutils.AppendZeroPadding(dst, (8-vlen)*1) + } + } + { // Dynamic Field #0 'AggregationBits' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.AggregationBits + vlen := len(t) + bval := []byte(t[:]) + if vlen == 0 { + bval = []byte{0x01} + } else if bval[vlen-1] == 0x00 { + return nil, sszutils.ErrorWithPath(sszutils.ErrBitlistNotTerminatedFn(), "AggregationBits") + } + if vlen > 0 { + bitCount := 8*(vlen-1) + bits.Len8(bval[vlen-1]) - 1 + if bitCount > 131072 { + return nil, sszutils.ErrorWithPath(sszutils.ErrBitlistLengthFn(bitCount, 131072), "AggregationBits") + } + } + dst = append(dst, bval...) + } + return dst, nil +} + +// MarshalSSZEncoder marshals the *Attestation to the given SSZ encoder using dynamic specifications. +func (t *Attestation) MarshalSSZEncoder(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + type encoderCtx struct { + ds sszutils.DynamicSpecs + exprs [0]uint64 + sizeFn1 func(ctx *encoderCtx, t go_bitfield.Bitlist) (size int) + } + ctx := &encoderCtx{ds: ds} + canSeek := enc.Seekable() + // size for go_bitfield.Bitlist + ctx.sizeFn1 = func(ctx *encoderCtx, t go_bitfield.Bitlist) (size int) { + if len(t) == 0 { + size += 1 + } else { + size += len(t) + } + return size + } + if t == nil { + t = new(Attestation) + } + dstlen := enc.GetPosition() + dynoff := uint32(236) + // Offset #0 'AggregationBits' + offset0 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn1(ctx, t.AggregationBits)) + } + { // Field #1 'Data' + t := t.Data + if t == nil { + t = new(generic.AttestationData) + } + if err = t.MarshalSSZEncoder(ds, enc); err != nil { + return sszutils.ErrorWithPath(err, "Data") + } + } + { // Field #2 'Signature' + enc.EncodeBytes(t.Signature[:96]) + } + { // Field #3 'CommitteeBits' + vlen := len(t.CommitteeBits) + if vlen > 8 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 8), "CommitteeBits") + } + enc.EncodeBytes(t.CommitteeBits[:vlen]) + if vlen < 8 { + enc.EncodeZeroPadding((8 - vlen) * 1) + } + } + { // Dynamic Field #0 'AggregationBits' + if canSeek { + enc.EncodeOffsetAt(offset0, uint32(enc.GetPosition()-dstlen)) + } + t := t.AggregationBits + vlen := len(t) + bval := []byte(t[:]) + if vlen == 0 { + bval = []byte{0x01} + } else if bval[vlen-1] == 0x00 { + return sszutils.ErrorWithPath(sszutils.ErrBitlistNotTerminatedFn(), "AggregationBits") + } + if vlen > 0 { + bitCount := 8*(vlen-1) + bits.Len8(bval[vlen-1]) - 1 + if bitCount > 131072 { + return sszutils.ErrorWithPath(sszutils.ErrBitlistLengthFn(bitCount, 131072), "AggregationBits") + } + } + enc.EncodeBytes(bval) + } + return nil +} + +// UnmarshalSSZDyn unmarshals the *Attestation from SSZ-encoded bytes using dynamic specifications. +func (t *Attestation) UnmarshalSSZDyn(ds sszutils.DynamicSpecs, buf []byte) (err error) { + buflen := len(buf) + if buflen < 236 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 236) + } + // Field #0 'AggregationBits' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 236 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset0, 236), "AggregationBits:o") + } + { // Field #1 'Data' (static) + buf := buf[4:132] + if t.Data == nil { + t.Data = new(generic.AttestationData) + } + if err = t.Data.UnmarshalSSZDyn(ds, buf); err != nil { + return sszutils.ErrorWithPath(err, "Data") + } + } + { // Field #2 'Signature' (static) + buf := buf[132:228] + copy(t.Signature[:], buf) + } + { // Field #3 'CommitteeBits' (static) + buf := buf[228:236] + t.CommitteeBits = sszutils.ExpandSlice(t.CommitteeBits, 8) + copy(t.CommitteeBits[:], buf) + } + { // Field #0 'AggregationBits' (dynamic) + buf := buf[offset0:] + val1 := t.AggregationBits + blen := len(buf) + if blen == 0 || buf[blen-1] == 0x00 { + return sszutils.ErrorWithPath(sszutils.ErrBitlistNotTerminatedFn(), "AggregationBits") + } + bitCount := 8*(blen-1) + int(bits.Len8(buf[blen-1])) - 1 + if bitCount > 131072 { + return sszutils.ErrorWithPath(sszutils.ErrBitlistLengthFn(bitCount, 131072), "AggregationBits") + } + val1 = sszutils.ExpandSlice(val1, blen) + copy(val1[:], buf) + t.AggregationBits = val1 + } + return nil +} + +// UnmarshalSSZDecoder unmarshals the *Attestation from the given SSZ decoder using dynamic specifications. +func (t *Attestation) UnmarshalSSZDecoder(ds sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { + maxOffset := uint32(dec.GetLength()) + startPos0 := dec.GetPosition() + if maxOffset < uint32(236) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(236)) + } + // Field #0 'AggregationBits' (offset) + offset0, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "AggregationBits") + } + if offset0 != uint32(236) { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset0, 236), "AggregationBits") + } + // Field #1 'Data' (static) + if t.Data == nil { + t.Data = new(generic.AttestationData) + } + if err = t.Data.UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPath(err, "Data") + } + // Field #2 'Signature' (static) + if _, err = dec.DecodeBytes(t.Signature[:96]); err != nil { + return err + } + // Field #3 'CommitteeBits' (static) + t.CommitteeBits = sszutils.ExpandSlice(t.CommitteeBits, 8) + if _, err = dec.DecodeBytes(t.CommitteeBits[:8]); err != nil { + return err + } + { // Field #0 'AggregationBits' (dynamic) + if dec.GetPosition() != startPos0+int(offset0) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset0)), "AggregationBits") + } + dec.PushLimit(int(maxOffset - offset0)) + val1 := t.AggregationBits + blen := dec.GetLength() + val1 = sszutils.ExpandSlice(val1, blen) + if _, err = dec.DecodeBytes(val1[:blen]); err != nil { + return sszutils.ErrorWithPath(err, "AggregationBits") + } + if blen == 0 || val1[blen-1] == 0x00 { + return sszutils.ErrorWithPath(sszutils.ErrBitlistNotTerminatedFn(), "AggregationBits") + } + bitCount := 8*(blen-1) + int(bits.Len8(val1[blen-1])) - 1 + if bitCount > 131072 { + return sszutils.ErrorWithPath(sszutils.ErrBitlistLengthFn(bitCount, 131072), "AggregationBits") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "AggregationBits") + } + t.AggregationBits = val1 + } + return nil +} + +// SizeSSZ returns the SSZ encoded size of the *Attestation. +func (t *Attestation) SizeSSZ() (size int) { + if t == nil { + t = new(Attestation) + } + // Field #0 'AggregationBits' offset (4 bytes) + // Field #1 'Data' static (128 bytes) + // Field #2 'Signature' static (96 bytes) + // Field #3 'CommitteeBits' static (8 bytes) + size += 236 + { // Dynamic field #0 'AggregationBits' + if len(t.AggregationBits) == 0 { + size += 1 + } else { + size += len(t.AggregationBits) + } + } + return size +} + +// SizeSSZDyn returns the SSZ encoded size of the *Attestation using dynamic specifications. +func (t *Attestation) SizeSSZDyn(_ sszutils.DynamicSpecs) (size int) { + return t.SizeSSZ() +} + +// HashTreeRootDyn computes the SSZ hash tree root of the *Attestation using dynamic specifications. +func (t *Attestation) HashTreeRootDyn(ds sszutils.DynamicSpecs) (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWithDyn(ds, hh) + if err == nil { + root, err = hh.HashRoot() + } + return + }) + return +} + +// HashTreeRootWithDyn computes the SSZ hash tree root of the *Attestation using dynamic specifications and the given hash walker. +func (t *Attestation) HashTreeRootWithDyn(ds sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + if t == nil { + t = new(Attestation) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'AggregationBits' + t := t.AggregationBits + if l := len(t); l > 0 && t[l-1] == 0x00 { + return sszutils.ErrorWithPath(sszutils.ErrBitlistNotTerminatedFn(), "AggregationBits") + } + idx := hh.StartTree(sszutils.TreeTypeNone) + bitlist, size := hasher.ParseBitlistWithHasher(hh, t[:]) + if size > 131072 { + return sszutils.ErrorWithPath(sszutils.ErrBitlistLengthFn(size, 131072), "AggregationBits") + } + hh.AppendBytes32(bitlist) + hh.MerkleizeWithMixin(idx, size, sszutils.CalculateBitlistLimit(131072)) + } + { // Field #1 'Data' + t := t.Data + if t == nil { + t = new(generic.AttestationData) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPath(err, "Data") + } + } + { // Field #2 'Signature' + hh.PutBytes(t.Signature[:96]) + } + { // Field #3 'CommitteeBits' + vlen := len(t.CommitteeBits) + if vlen > 8 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 8), "CommitteeBits") + } + val := t.CommitteeBits[:] + if vlen < 8 { + val = sszutils.AppendZeroPadding(val, (8-vlen)*1) + } + hh.PutBytes(val[:8]) + } + hh.Merkleize(idx) + return nil +} + +// MarshalSSZDyn marshals the *ExecutionRequests to SSZ-encoded bytes using dynamic specifications. +func (t *ExecutionRequests) MarshalSSZDyn(ds sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + dst = buf + zeroBytes := sszutils.ZeroBytes() + if t == nil { + t = new(ExecutionRequests) + } + dstlen := len(dst) + // Offset Field #0 'Deposits' + // Offset Field #1 'Withdrawals' + // Offset Field #2 'Consolidations' + dst = append(dst, zeroBytes[:12]...) + { // Dynamic Field #0 'Deposits' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.Deposits + vlen := len(t) + if vlen > 8192 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 8192), "Deposits") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(DepositRequest) + } + if dst, err = t.MarshalSSZDyn(ds, dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "Deposits[%d]", idx1) + } + } + } + { // Dynamic Field #1 'Withdrawals' + binary.LittleEndian.PutUint32(dst[dstlen+4:], uint32(len(dst)-dstlen)) + t := t.Withdrawals + vlen := len(t) + if vlen > 16 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16), "Withdrawals") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(WithdrawalRequest) + } + if dst, err = t.MarshalSSZDyn(ds, dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "Withdrawals[%d]", idx1) + } + } + } + { // Dynamic Field #2 'Consolidations' + binary.LittleEndian.PutUint32(dst[dstlen+8:], uint32(len(dst)-dstlen)) + t := t.Consolidations + vlen := len(t) + if vlen > 2 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 2), "Consolidations") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(ConsolidationRequest) + } + if dst, err = t.MarshalSSZDyn(ds, dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "Consolidations[%d]", idx1) + } + } + } + return dst, nil +} + +// MarshalSSZEncoder marshals the *ExecutionRequests to the given SSZ encoder using dynamic specifications. +func (t *ExecutionRequests) MarshalSSZEncoder(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + type encoderCtx struct { + ds sszutils.DynamicSpecs + exprs [0]uint64 + sizeFn1 func(ctx *encoderCtx, t []*DepositRequest) (size int) + sizeFn2 func(ctx *encoderCtx, t []*WithdrawalRequest) (size int) + sizeFn3 func(ctx *encoderCtx, t []*ConsolidationRequest) (size int) + } + ctx := &encoderCtx{ds: ds} + canSeek := enc.Seekable() + // size for []*DepositRequest + ctx.sizeFn1 = func(ctx *encoderCtx, t []*DepositRequest) (size int) { + size += len(t) * 192 + return size + } + // size for []*WithdrawalRequest + ctx.sizeFn2 = func(ctx *encoderCtx, t []*WithdrawalRequest) (size int) { + size += len(t) * 76 + return size + } + // size for []*ConsolidationRequest + ctx.sizeFn3 = func(ctx *encoderCtx, t []*ConsolidationRequest) (size int) { + size += len(t) * 116 + return size + } + if t == nil { + t = new(ExecutionRequests) + } + dstlen := enc.GetPosition() + dynoff := uint32(12) + // Offset #0 'Deposits' + offset0 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn1(ctx, t.Deposits)) + } + // Offset #1 'Withdrawals' + offset1 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn2(ctx, t.Withdrawals)) + } + // Offset #2 'Consolidations' + offset2 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn3(ctx, t.Consolidations)) + } + { // Dynamic Field #0 'Deposits' + if canSeek { + enc.EncodeOffsetAt(offset0, uint32(enc.GetPosition()-dstlen)) + } + t := t.Deposits + vlen := len(t) + if vlen > 8192 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 8192), "Deposits") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(DepositRequest) + } + if err = t.MarshalSSZEncoder(ds, enc); err != nil { + return sszutils.ErrorWithPathf(err, "Deposits[%d]", idx1) + } + } + } + { // Dynamic Field #1 'Withdrawals' + if canSeek { + enc.EncodeOffsetAt(offset1, uint32(enc.GetPosition()-dstlen)) + } + t := t.Withdrawals + vlen := len(t) + if vlen > 16 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16), "Withdrawals") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(WithdrawalRequest) + } + if err = t.MarshalSSZEncoder(ds, enc); err != nil { + return sszutils.ErrorWithPathf(err, "Withdrawals[%d]", idx1) + } + } + } + { // Dynamic Field #2 'Consolidations' + if canSeek { + enc.EncodeOffsetAt(offset2, uint32(enc.GetPosition()-dstlen)) + } + t := t.Consolidations + vlen := len(t) + if vlen > 2 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 2), "Consolidations") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(ConsolidationRequest) + } + if err = t.MarshalSSZEncoder(ds, enc); err != nil { + return sszutils.ErrorWithPathf(err, "Consolidations[%d]", idx1) + } + } + } + return nil +} + +// UnmarshalSSZDyn unmarshals the *ExecutionRequests from SSZ-encoded bytes using dynamic specifications. +func (t *ExecutionRequests) UnmarshalSSZDyn(ds sszutils.DynamicSpecs, buf []byte) (err error) { + buflen := len(buf) + if buflen < 12 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 12) + } + // Field #0 'Deposits' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 12 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset0, 12), "Deposits:o") + } + // Field #1 'Withdrawals' (offset) + offset1 := int(binary.LittleEndian.Uint32(buf[4:8])) + if offset1 < offset0 || offset1 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset1, offset0, buflen), "Withdrawals:o") + } + // Field #2 'Consolidations' (offset) + offset2 := int(binary.LittleEndian.Uint32(buf[8:12])) + if offset2 < offset1 || offset2 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset2, offset1, buflen), "Consolidations:o") + } + { // Field #0 'Deposits' (dynamic) + buf := buf[offset0:offset1] + val1 := t.Deposits + itemCount := len(buf) / 192 + if len(buf)%192 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 192), "Deposits") + } + if itemCount > 8192 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 8192), "Deposits") + } + val1 = sszutils.ExpandSlice(val1, itemCount) + for idx1 := range itemCount { + if val1[idx1] == nil { + val1[idx1] = new(DepositRequest) + } + buf := buf[192*idx1 : 192*(idx1+1)] + if err = val1[idx1].UnmarshalSSZDyn(ds, buf); err != nil { + return sszutils.ErrorWithPathf(err, "Deposits[%d]", idx1) + } + } + t.Deposits = val1 + } + { // Field #1 'Withdrawals' (dynamic) + buf := buf[offset1:offset2] + val2 := t.Withdrawals + itemCount := len(buf) / 76 + if len(buf)%76 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 76), "Withdrawals") + } + if itemCount > 16 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 16), "Withdrawals") + } + val2 = sszutils.ExpandSlice(val2, itemCount) + for idx1 := range itemCount { + if val2[idx1] == nil { + val2[idx1] = new(WithdrawalRequest) + } + buf := buf[76*idx1 : 76*(idx1+1)] + if err = val2[idx1].UnmarshalSSZDyn(ds, buf); err != nil { + return sszutils.ErrorWithPathf(err, "Withdrawals[%d]", idx1) + } + } + t.Withdrawals = val2 + } + { // Field #2 'Consolidations' (dynamic) + buf := buf[offset2:] + val3 := t.Consolidations + itemCount := len(buf) / 116 + if len(buf)%116 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 116), "Consolidations") + } + if itemCount > 2 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 2), "Consolidations") + } + val3 = sszutils.ExpandSlice(val3, itemCount) + for idx1 := range itemCount { + if val3[idx1] == nil { + val3[idx1] = new(ConsolidationRequest) + } + buf := buf[116*idx1 : 116*(idx1+1)] + if err = val3[idx1].UnmarshalSSZDyn(ds, buf); err != nil { + return sszutils.ErrorWithPathf(err, "Consolidations[%d]", idx1) + } + } + t.Consolidations = val3 + } + return nil +} + +// UnmarshalSSZDecoder unmarshals the *ExecutionRequests from the given SSZ decoder using dynamic specifications. +func (t *ExecutionRequests) UnmarshalSSZDecoder(ds sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { + maxOffset := uint32(dec.GetLength()) + startPos0 := dec.GetPosition() + if maxOffset < uint32(12) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(12)) + } + // Field #0 'Deposits' (offset) + offset0, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Deposits") + } + if offset0 != uint32(12) { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset0, 12), "Deposits") + } + // Field #1 'Withdrawals' (offset) + offset1, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Withdrawals") + } + if offset1 < offset0 || offset1 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset1, offset0, maxOffset), "Withdrawals") + } + // Field #2 'Consolidations' (offset) + offset2, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Consolidations") + } + if offset2 < offset1 || offset2 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset2, offset1, maxOffset), "Consolidations") + } + { // Field #0 'Deposits' (dynamic) + if dec.GetPosition() != startPos0+int(offset0) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset0)), "Deposits") + } + dec.PushLimit(int(offset1 - offset0)) + val1 := t.Deposits + sszLen := dec.GetLength() + itemCount := sszLen / 192 + if sszLen%192 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 192), "Deposits") + } + if itemCount > 8192 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 8192), "Deposits") + } + val1 = sszutils.ExpandSlice(val1, itemCount) + startPos1 := dec.GetPosition() + for idx1 := range itemCount { + if val1[idx1] == nil { + val1[idx1] = new(DepositRequest) + } + if err = val1[idx1].UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPathf(err, "Deposits[%d]", idx1) + } + if dec.GetPosition() != startPos1+int(192*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos1+int(192*(idx1+1))), "Deposits[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Deposits") + } + t.Deposits = val1 + } + { // Field #1 'Withdrawals' (dynamic) + if dec.GetPosition() != startPos0+int(offset1) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset1)), "Withdrawals") + } + dec.PushLimit(int(offset2 - offset1)) + val2 := t.Withdrawals + sszLen := dec.GetLength() + itemCount := sszLen / 76 + if sszLen%76 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 76), "Withdrawals") + } + if itemCount > 16 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 16), "Withdrawals") + } + val2 = sszutils.ExpandSlice(val2, itemCount) + startPos2 := dec.GetPosition() + for idx1 := range itemCount { + if val2[idx1] == nil { + val2[idx1] = new(WithdrawalRequest) + } + if err = val2[idx1].UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPathf(err, "Withdrawals[%d]", idx1) + } + if dec.GetPosition() != startPos2+int(76*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos2+int(76*(idx1+1))), "Withdrawals[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Withdrawals") + } + t.Withdrawals = val2 + } + { // Field #2 'Consolidations' (dynamic) + if dec.GetPosition() != startPos0+int(offset2) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset2)), "Consolidations") + } + dec.PushLimit(int(maxOffset - offset2)) + val3 := t.Consolidations + sszLen := dec.GetLength() + itemCount := sszLen / 116 + if sszLen%116 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 116), "Consolidations") + } + if itemCount > 2 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 2), "Consolidations") + } + val3 = sszutils.ExpandSlice(val3, itemCount) + startPos3 := dec.GetPosition() + for idx1 := range itemCount { + if val3[idx1] == nil { + val3[idx1] = new(ConsolidationRequest) + } + if err = val3[idx1].UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPathf(err, "Consolidations[%d]", idx1) + } + if dec.GetPosition() != startPos3+int(116*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos3+int(116*(idx1+1))), "Consolidations[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Consolidations") + } + t.Consolidations = val3 + } + return nil +} + +// SizeSSZ returns the SSZ encoded size of the *ExecutionRequests. +func (t *ExecutionRequests) SizeSSZ() (size int) { + if t == nil { + t = new(ExecutionRequests) + } + // Field #0 'Deposits' offset (4 bytes) + // Field #1 'Withdrawals' offset (4 bytes) + // Field #2 'Consolidations' offset (4 bytes) + size += 12 + { // Dynamic field #0 'Deposits' + size += len(t.Deposits) * 192 + } + { // Dynamic field #1 'Withdrawals' + size += len(t.Withdrawals) * 76 + } + { // Dynamic field #2 'Consolidations' + size += len(t.Consolidations) * 116 + } + return size +} + +// SizeSSZDyn returns the SSZ encoded size of the *ExecutionRequests using dynamic specifications. +func (t *ExecutionRequests) SizeSSZDyn(_ sszutils.DynamicSpecs) (size int) { + return t.SizeSSZ() +} + +// HashTreeRootDyn computes the SSZ hash tree root of the *ExecutionRequests using dynamic specifications. +func (t *ExecutionRequests) HashTreeRootDyn(ds sszutils.DynamicSpecs) (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWithDyn(ds, hh) + if err == nil { + root, err = hh.HashRoot() + } + return + }) + return +} + +// HashTreeRootWithDyn computes the SSZ hash tree root of the *ExecutionRequests using dynamic specifications and the given hash walker. +func (t *ExecutionRequests) HashTreeRootWithDyn(ds sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + if t == nil { + t = new(ExecutionRequests) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Deposits' + t := t.Deposits + vlen := uint64(len(t)) + if vlen > 8192 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 8192), "Deposits") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(DepositRequest) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPathf(err, "Deposits[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(8192, vlen, 32)) + } + { // Field #1 'Withdrawals' + t := t.Withdrawals + vlen := uint64(len(t)) + if vlen > 16 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16), "Withdrawals") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(WithdrawalRequest) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPathf(err, "Withdrawals[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(16, vlen, 32)) + } + { // Field #2 'Consolidations' + t := t.Consolidations + vlen := uint64(len(t)) + if vlen > 2 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 2), "Consolidations") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(ConsolidationRequest) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPathf(err, "Consolidations[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(2, vlen, 32)) + } + hh.Merkleize(idx) + return nil +} + +// MarshalSSZTo marshals the *DepositRequest to SSZ-encoded bytes, appending to the provided buffer. +func (t *DepositRequest) MarshalSSZTo(buf []byte) (dst []byte, err error) { + dst = buf + if t == nil { + t = new(DepositRequest) + } + { // Static Field #0 'Pubkey' + vlen := len(t.Pubkey) + if vlen > 48 { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 48), "Pubkey") + } + dst = append(dst, t.Pubkey[:vlen]...) + if vlen < 48 { + dst = sszutils.AppendZeroPadding(dst, (48-vlen)*1) + } + } + { // Static Field #1 'WithdrawalCredentials' + vlen := len(t.WithdrawalCredentials) + if vlen > 32 { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 32), "WithdrawalCredentials") + } + dst = append(dst, t.WithdrawalCredentials[:vlen]...) + if vlen < 32 { + dst = sszutils.AppendZeroPadding(dst, (32-vlen)*1) + } + } + { // Static Field #2 'Amount' + dst = binary.LittleEndian.AppendUint64(dst, t.Amount) + } + { // Static Field #3 'Signature' + vlen := len(t.Signature) + if vlen > 96 { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 96), "Signature") + } + dst = append(dst, t.Signature[:vlen]...) + if vlen < 96 { + dst = sszutils.AppendZeroPadding(dst, (96-vlen)*1) + } + } + { // Static Field #4 'Index' + dst = binary.LittleEndian.AppendUint64(dst, t.Index) + } + return dst, nil +} + +// MarshalSSZDyn marshals the *DepositRequest to SSZ-encoded bytes using dynamic specifications. +func (t *DepositRequest) MarshalSSZDyn(_ sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + return t.MarshalSSZTo(buf) +} + +// MarshalSSZEncoder marshals the *DepositRequest to the given SSZ encoder using dynamic specifications. +func (t *DepositRequest) MarshalSSZEncoder(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + if t == nil { + t = new(DepositRequest) + } + { // Field #0 'Pubkey' + vlen := len(t.Pubkey) + if vlen > 48 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 48), "Pubkey") + } + enc.EncodeBytes(t.Pubkey[:vlen]) + if vlen < 48 { + enc.EncodeZeroPadding((48 - vlen) * 1) + } + } + { // Field #1 'WithdrawalCredentials' + vlen := len(t.WithdrawalCredentials) + if vlen > 32 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 32), "WithdrawalCredentials") + } + enc.EncodeBytes(t.WithdrawalCredentials[:vlen]) + if vlen < 32 { + enc.EncodeZeroPadding((32 - vlen) * 1) + } + } + { // Field #2 'Amount' + enc.EncodeUint64(t.Amount) + } + { // Field #3 'Signature' + vlen := len(t.Signature) + if vlen > 96 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 96), "Signature") + } + enc.EncodeBytes(t.Signature[:vlen]) + if vlen < 96 { + enc.EncodeZeroPadding((96 - vlen) * 1) + } + } + { // Field #4 'Index' + enc.EncodeUint64(t.Index) + } + return nil +} + +// UnmarshalSSZ unmarshals the *DepositRequest from SSZ-encoded bytes. +func (t *DepositRequest) UnmarshalSSZ(buf []byte) (err error) { + buflen := len(buf) + if buflen < 192 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 192) + } + if buflen > 192 { + return sszutils.ErrTrailingDataFn(buflen - 192) + } + { // Field #0 'Pubkey' (static) + buf := buf[0:48] + t.Pubkey = sszutils.ExpandSlice(t.Pubkey, 48) + copy(t.Pubkey[:], buf) + } + { // Field #1 'WithdrawalCredentials' (static) + buf := buf[48:80] + t.WithdrawalCredentials = sszutils.ExpandSlice(t.WithdrawalCredentials, 32) + copy(t.WithdrawalCredentials[:], buf) + } + { // Field #2 'Amount' (static) + buf := buf[80:88] + t.Amount = binary.LittleEndian.Uint64(buf) + } + { // Field #3 'Signature' (static) + buf := buf[88:184] + t.Signature = sszutils.ExpandSlice(t.Signature, 96) + copy(t.Signature[:], buf) + } + { // Field #4 'Index' (static) + buf := buf[184:192] + t.Index = binary.LittleEndian.Uint64(buf) + } + return nil +} + +// UnmarshalSSZDyn unmarshals the *DepositRequest from SSZ-encoded bytes using dynamic specifications. +func (t *DepositRequest) UnmarshalSSZDyn(_ sszutils.DynamicSpecs, buf []byte) (err error) { + return t.UnmarshalSSZ(buf) +} + +// UnmarshalSSZDecoder unmarshals the *DepositRequest from the given SSZ decoder using dynamic specifications. +func (t *DepositRequest) UnmarshalSSZDecoder(_ sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { + maxOffset := uint32(dec.GetLength()) + if maxOffset < uint32(192) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(192)) + } + // Field #0 'Pubkey' (static) + t.Pubkey = sszutils.ExpandSlice(t.Pubkey, 48) + if _, err = dec.DecodeBytes(t.Pubkey[:48]); err != nil { + return err + } + // Field #1 'WithdrawalCredentials' (static) + t.WithdrawalCredentials = sszutils.ExpandSlice(t.WithdrawalCredentials, 32) + if _, err = dec.DecodeBytes(t.WithdrawalCredentials[:32]); err != nil { + return err + } + // Field #2 'Amount' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "Amount") + } else { + t.Amount = val + } + // Field #3 'Signature' (static) + t.Signature = sszutils.ExpandSlice(t.Signature, 96) + if _, err = dec.DecodeBytes(t.Signature[:96]); err != nil { + return err + } + // Field #4 'Index' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "Index") + } else { + t.Index = val + } + return nil +} + +// SizeSSZ returns the SSZ encoded size of the *DepositRequest. +func (t *DepositRequest) SizeSSZ() (size int) { + return 192 +} + +// SizeSSZDyn returns the SSZ encoded size of the *DepositRequest using dynamic specifications. +func (t *DepositRequest) SizeSSZDyn(_ sszutils.DynamicSpecs) (size int) { + return t.SizeSSZ() +} + +// HashTreeRoot computes the SSZ hash tree root of the *DepositRequest. +func (t *DepositRequest) 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 *DepositRequest using the given hash walker. +func (t *DepositRequest) HashTreeRootWith(hh sszutils.HashWalker) error { + if t == nil { + t = new(DepositRequest) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Pubkey' + vlen := len(t.Pubkey) + if vlen > 48 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 48), "Pubkey") + } + val := t.Pubkey[:] + if vlen < 48 { + val = sszutils.AppendZeroPadding(val, (48-vlen)*1) + } + hh.PutBytes(val[:48]) + } + { // Field #1 'WithdrawalCredentials' + vlen := len(t.WithdrawalCredentials) + if vlen > 32 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 32), "WithdrawalCredentials") + } + val := t.WithdrawalCredentials[:] + if vlen < 32 { + val = sszutils.AppendZeroPadding(val, (32-vlen)*1) + } + hh.PutBytes(val[:32]) + } + { // Field #2 'Amount' + hh.PutUint64(t.Amount) + } + { // Field #3 'Signature' + vlen := len(t.Signature) + if vlen > 96 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 96), "Signature") + } + val := t.Signature[:] + if vlen < 96 { + val = sszutils.AppendZeroPadding(val, (96-vlen)*1) + } + hh.PutBytes(val[:96]) + } + { // Field #4 'Index' + hh.PutUint64(t.Index) + } + hh.Merkleize(idx) + return nil +} + +// HashTreeRootDyn computes the SSZ hash tree root of the *DepositRequest using dynamic specifications. +func (t *DepositRequest) HashTreeRootDyn(ds sszutils.DynamicSpecs) (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWithDyn(ds, hh) + if err == nil { + root, err = hh.HashRoot() + } + return + }) + return +} + +// HashTreeRootWithDyn computes the SSZ hash tree root of the *DepositRequest using dynamic specifications and the given hash walker. +func (t *DepositRequest) HashTreeRootWithDyn(_ sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + return t.HashTreeRootWith(hh) +} + +// MarshalSSZTo marshals the *WithdrawalRequest to SSZ-encoded bytes, appending to the provided buffer. +func (t *WithdrawalRequest) MarshalSSZTo(buf []byte) (dst []byte, err error) { + dst = buf + if t == nil { + t = new(WithdrawalRequest) + } + { // Static Field #0 'SourceAddress' + vlen := len(t.SourceAddress) + if vlen > 20 { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 20), "SourceAddress") + } + dst = append(dst, t.SourceAddress[:vlen]...) + if vlen < 20 { + dst = sszutils.AppendZeroPadding(dst, (20-vlen)*1) + } + } + { // Static Field #1 'ValidatorPubkey' + vlen := len(t.ValidatorPubkey) + if vlen > 48 { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 48), "ValidatorPubkey") + } + dst = append(dst, t.ValidatorPubkey[:vlen]...) + if vlen < 48 { + dst = sszutils.AppendZeroPadding(dst, (48-vlen)*1) + } + } + { // Static Field #2 'Amount' + dst = binary.LittleEndian.AppendUint64(dst, t.Amount) + } + return dst, nil +} + +// MarshalSSZDyn marshals the *WithdrawalRequest to SSZ-encoded bytes using dynamic specifications. +func (t *WithdrawalRequest) MarshalSSZDyn(_ sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + return t.MarshalSSZTo(buf) +} + +// MarshalSSZEncoder marshals the *WithdrawalRequest to the given SSZ encoder using dynamic specifications. +func (t *WithdrawalRequest) MarshalSSZEncoder(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + if t == nil { + t = new(WithdrawalRequest) + } + { // Field #0 'SourceAddress' + vlen := len(t.SourceAddress) + if vlen > 20 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 20), "SourceAddress") + } + enc.EncodeBytes(t.SourceAddress[:vlen]) + if vlen < 20 { + enc.EncodeZeroPadding((20 - vlen) * 1) + } + } + { // Field #1 'ValidatorPubkey' + vlen := len(t.ValidatorPubkey) + if vlen > 48 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 48), "ValidatorPubkey") + } + enc.EncodeBytes(t.ValidatorPubkey[:vlen]) + if vlen < 48 { + enc.EncodeZeroPadding((48 - vlen) * 1) + } + } + { // Field #2 'Amount' + enc.EncodeUint64(t.Amount) + } + return nil +} + +// UnmarshalSSZ unmarshals the *WithdrawalRequest from SSZ-encoded bytes. +func (t *WithdrawalRequest) UnmarshalSSZ(buf []byte) (err error) { + buflen := len(buf) + if buflen < 76 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 76) + } + if buflen > 76 { + return sszutils.ErrTrailingDataFn(buflen - 76) + } + { // Field #0 'SourceAddress' (static) + buf := buf[0:20] + t.SourceAddress = sszutils.ExpandSlice(t.SourceAddress, 20) + copy(t.SourceAddress[:], buf) + } + { // Field #1 'ValidatorPubkey' (static) + buf := buf[20:68] + t.ValidatorPubkey = sszutils.ExpandSlice(t.ValidatorPubkey, 48) + copy(t.ValidatorPubkey[:], buf) + } + { // Field #2 'Amount' (static) + buf := buf[68:76] + t.Amount = binary.LittleEndian.Uint64(buf) + } + return nil +} + +// UnmarshalSSZDyn unmarshals the *WithdrawalRequest from SSZ-encoded bytes using dynamic specifications. +func (t *WithdrawalRequest) UnmarshalSSZDyn(_ sszutils.DynamicSpecs, buf []byte) (err error) { + return t.UnmarshalSSZ(buf) +} + +// UnmarshalSSZDecoder unmarshals the *WithdrawalRequest from the given SSZ decoder using dynamic specifications. +func (t *WithdrawalRequest) UnmarshalSSZDecoder(_ sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { + maxOffset := uint32(dec.GetLength()) + if maxOffset < uint32(76) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(76)) + } + // Field #0 'SourceAddress' (static) + t.SourceAddress = sszutils.ExpandSlice(t.SourceAddress, 20) + if _, err = dec.DecodeBytes(t.SourceAddress[:20]); err != nil { + return err + } + // Field #1 'ValidatorPubkey' (static) + t.ValidatorPubkey = sszutils.ExpandSlice(t.ValidatorPubkey, 48) + if _, err = dec.DecodeBytes(t.ValidatorPubkey[:48]); err != nil { + return err + } + // Field #2 'Amount' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "Amount") + } else { + t.Amount = val + } + return nil +} + +// SizeSSZ returns the SSZ encoded size of the *WithdrawalRequest. +func (t *WithdrawalRequest) SizeSSZ() (size int) { + return 76 +} + +// SizeSSZDyn returns the SSZ encoded size of the *WithdrawalRequest using dynamic specifications. +func (t *WithdrawalRequest) SizeSSZDyn(_ sszutils.DynamicSpecs) (size int) { + return t.SizeSSZ() +} + +// HashTreeRoot computes the SSZ hash tree root of the *WithdrawalRequest. +func (t *WithdrawalRequest) 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 *WithdrawalRequest using the given hash walker. +func (t *WithdrawalRequest) HashTreeRootWith(hh sszutils.HashWalker) error { + if t == nil { + t = new(WithdrawalRequest) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'SourceAddress' + vlen := len(t.SourceAddress) + if vlen > 20 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 20), "SourceAddress") + } + val := t.SourceAddress[:] + if vlen < 20 { + val = sszutils.AppendZeroPadding(val, (20-vlen)*1) + } + hh.PutBytes(val[:20]) + } + { // Field #1 'ValidatorPubkey' + vlen := len(t.ValidatorPubkey) + if vlen > 48 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 48), "ValidatorPubkey") + } + val := t.ValidatorPubkey[:] + if vlen < 48 { + val = sszutils.AppendZeroPadding(val, (48-vlen)*1) + } + hh.PutBytes(val[:48]) + } + { // Field #2 'Amount' + hh.PutUint64(t.Amount) + } + hh.Merkleize(idx) + return nil +} + +// HashTreeRootDyn computes the SSZ hash tree root of the *WithdrawalRequest using dynamic specifications. +func (t *WithdrawalRequest) HashTreeRootDyn(ds sszutils.DynamicSpecs) (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWithDyn(ds, hh) + if err == nil { + root, err = hh.HashRoot() + } + return + }) + return +} + +// HashTreeRootWithDyn computes the SSZ hash tree root of the *WithdrawalRequest using dynamic specifications and the given hash walker. +func (t *WithdrawalRequest) HashTreeRootWithDyn(_ sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + return t.HashTreeRootWith(hh) +} + +// MarshalSSZTo marshals the *ConsolidationRequest to SSZ-encoded bytes, appending to the provided buffer. +func (t *ConsolidationRequest) MarshalSSZTo(buf []byte) (dst []byte, err error) { + dst = buf + if t == nil { + t = new(ConsolidationRequest) + } + { // Static Field #0 'SourceAddress' + vlen := len(t.SourceAddress) + if vlen > 20 { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 20), "SourceAddress") + } + dst = append(dst, t.SourceAddress[:vlen]...) + if vlen < 20 { + dst = sszutils.AppendZeroPadding(dst, (20-vlen)*1) + } + } + { // Static Field #1 'SourcePubkey' + vlen := len(t.SourcePubkey) + if vlen > 48 { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 48), "SourcePubkey") + } + dst = append(dst, t.SourcePubkey[:vlen]...) + if vlen < 48 { + dst = sszutils.AppendZeroPadding(dst, (48-vlen)*1) + } + } + { // Static Field #2 'TargetPubkey' + vlen := len(t.TargetPubkey) + if vlen > 48 { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 48), "TargetPubkey") + } + dst = append(dst, t.TargetPubkey[:vlen]...) + if vlen < 48 { + dst = sszutils.AppendZeroPadding(dst, (48-vlen)*1) + } + } + return dst, nil +} + +// MarshalSSZDyn marshals the *ConsolidationRequest to SSZ-encoded bytes using dynamic specifications. +func (t *ConsolidationRequest) MarshalSSZDyn(_ sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + return t.MarshalSSZTo(buf) +} + +// MarshalSSZEncoder marshals the *ConsolidationRequest to the given SSZ encoder using dynamic specifications. +func (t *ConsolidationRequest) MarshalSSZEncoder(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + if t == nil { + t = new(ConsolidationRequest) + } + { // Field #0 'SourceAddress' + vlen := len(t.SourceAddress) + if vlen > 20 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 20), "SourceAddress") + } + enc.EncodeBytes(t.SourceAddress[:vlen]) + if vlen < 20 { + enc.EncodeZeroPadding((20 - vlen) * 1) + } + } + { // Field #1 'SourcePubkey' + vlen := len(t.SourcePubkey) + if vlen > 48 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 48), "SourcePubkey") + } + enc.EncodeBytes(t.SourcePubkey[:vlen]) + if vlen < 48 { + enc.EncodeZeroPadding((48 - vlen) * 1) + } + } + { // Field #2 'TargetPubkey' + vlen := len(t.TargetPubkey) + if vlen > 48 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 48), "TargetPubkey") + } + enc.EncodeBytes(t.TargetPubkey[:vlen]) + if vlen < 48 { + enc.EncodeZeroPadding((48 - vlen) * 1) + } + } + return nil +} + +// UnmarshalSSZ unmarshals the *ConsolidationRequest from SSZ-encoded bytes. +func (t *ConsolidationRequest) UnmarshalSSZ(buf []byte) (err error) { + buflen := len(buf) + if buflen < 116 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 116) + } + if buflen > 116 { + return sszutils.ErrTrailingDataFn(buflen - 116) + } + { // Field #0 'SourceAddress' (static) + buf := buf[0:20] + t.SourceAddress = sszutils.ExpandSlice(t.SourceAddress, 20) + copy(t.SourceAddress[:], buf) + } + { // Field #1 'SourcePubkey' (static) + buf := buf[20:68] + t.SourcePubkey = sszutils.ExpandSlice(t.SourcePubkey, 48) + copy(t.SourcePubkey[:], buf) + } + { // Field #2 'TargetPubkey' (static) + buf := buf[68:116] + t.TargetPubkey = sszutils.ExpandSlice(t.TargetPubkey, 48) + copy(t.TargetPubkey[:], buf) + } + return nil +} + +// UnmarshalSSZDyn unmarshals the *ConsolidationRequest from SSZ-encoded bytes using dynamic specifications. +func (t *ConsolidationRequest) UnmarshalSSZDyn(_ sszutils.DynamicSpecs, buf []byte) (err error) { + return t.UnmarshalSSZ(buf) +} + +// UnmarshalSSZDecoder unmarshals the *ConsolidationRequest from the given SSZ decoder using dynamic specifications. +func (t *ConsolidationRequest) UnmarshalSSZDecoder(_ sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { + maxOffset := uint32(dec.GetLength()) + if maxOffset < uint32(116) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(116)) + } + // Field #0 'SourceAddress' (static) + t.SourceAddress = sszutils.ExpandSlice(t.SourceAddress, 20) + if _, err = dec.DecodeBytes(t.SourceAddress[:20]); err != nil { + return err + } + // Field #1 'SourcePubkey' (static) + t.SourcePubkey = sszutils.ExpandSlice(t.SourcePubkey, 48) + if _, err = dec.DecodeBytes(t.SourcePubkey[:48]); err != nil { + return err + } + // Field #2 'TargetPubkey' (static) + t.TargetPubkey = sszutils.ExpandSlice(t.TargetPubkey, 48) + if _, err = dec.DecodeBytes(t.TargetPubkey[:48]); err != nil { + return err + } + return nil +} + +// SizeSSZ returns the SSZ encoded size of the *ConsolidationRequest. +func (t *ConsolidationRequest) SizeSSZ() (size int) { + return 116 +} + +// SizeSSZDyn returns the SSZ encoded size of the *ConsolidationRequest using dynamic specifications. +func (t *ConsolidationRequest) SizeSSZDyn(_ sszutils.DynamicSpecs) (size int) { + return t.SizeSSZ() +} + +// HashTreeRoot computes the SSZ hash tree root of the *ConsolidationRequest. +func (t *ConsolidationRequest) 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 *ConsolidationRequest using the given hash walker. +func (t *ConsolidationRequest) HashTreeRootWith(hh sszutils.HashWalker) error { + if t == nil { + t = new(ConsolidationRequest) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'SourceAddress' + vlen := len(t.SourceAddress) + if vlen > 20 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 20), "SourceAddress") + } + val := t.SourceAddress[:] + if vlen < 20 { + val = sszutils.AppendZeroPadding(val, (20-vlen)*1) + } + hh.PutBytes(val[:20]) + } + { // Field #1 'SourcePubkey' + vlen := len(t.SourcePubkey) + if vlen > 48 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 48), "SourcePubkey") + } + val := t.SourcePubkey[:] + if vlen < 48 { + val = sszutils.AppendZeroPadding(val, (48-vlen)*1) + } + hh.PutBytes(val[:48]) + } + { // Field #2 'TargetPubkey' + vlen := len(t.TargetPubkey) + if vlen > 48 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 48), "TargetPubkey") + } + val := t.TargetPubkey[:] + if vlen < 48 { + val = sszutils.AppendZeroPadding(val, (48-vlen)*1) + } + hh.PutBytes(val[:48]) + } + hh.Merkleize(idx) + return nil +} + +// HashTreeRootDyn computes the SSZ hash tree root of the *ConsolidationRequest using dynamic specifications. +func (t *ConsolidationRequest) HashTreeRootDyn(ds sszutils.DynamicSpecs) (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWithDyn(ds, hh) + if err == nil { + root, err = hh.HashRoot() + } + return + }) + return +} + +// HashTreeRootWithDyn computes the SSZ hash tree root of the *ConsolidationRequest using dynamic specifications and the given hash walker. +func (t *ConsolidationRequest) HashTreeRootWithDyn(_ sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + return t.HashTreeRootWith(hh) +} + +// MarshalSSZDyn marshals the *AttesterSlashing to SSZ-encoded bytes using dynamic specifications. +func (t *AttesterSlashing) MarshalSSZDyn(ds sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + dst = buf + if t == nil { + t = new(AttesterSlashing) + } + dstlen := len(dst) + // Offset Field #0 'Attestation1' + // Offset Field #1 'Attestation2' + dst = append(dst, 0, 0, 0, 0, 0, 0, 0, 0) + { // Dynamic Field #0 'Attestation1' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.Attestation1 + if t == nil { + t = new(IndexedAttestation) + } + if dst, err = t.MarshalSSZDyn(ds, dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "Attestation1") + } + } + { // Dynamic Field #1 'Attestation2' + binary.LittleEndian.PutUint32(dst[dstlen+4:], uint32(len(dst)-dstlen)) + t := t.Attestation2 + if t == nil { + t = new(IndexedAttestation) + } + if dst, err = t.MarshalSSZDyn(ds, dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "Attestation2") + } + } + return dst, nil +} + +// MarshalSSZEncoder marshals the *AttesterSlashing to the given SSZ encoder using dynamic specifications. +func (t *AttesterSlashing) MarshalSSZEncoder(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + type encoderCtx struct { + ds sszutils.DynamicSpecs + exprs [0]uint64 + sizeFn1 func(ctx *encoderCtx, t *IndexedAttestation) (size int) + } + ctx := &encoderCtx{ds: ds} + canSeek := enc.Seekable() + // size for *IndexedAttestation + ctx.sizeFn1 = func(ctx *encoderCtx, t *IndexedAttestation) (size int) { + size += t.SizeSSZDyn(ds) + return size + } + if t == nil { + t = new(AttesterSlashing) + } + dstlen := enc.GetPosition() + dynoff := uint32(8) + // Offset #0 'Attestation1' + offset0 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn1(ctx, t.Attestation1)) + } + // Offset #1 'Attestation2' + offset1 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn1(ctx, t.Attestation2)) + } + { // Dynamic Field #0 'Attestation1' + if canSeek { + enc.EncodeOffsetAt(offset0, uint32(enc.GetPosition()-dstlen)) + } + t := t.Attestation1 + if t == nil { + t = new(IndexedAttestation) + } + if err = t.MarshalSSZEncoder(ds, enc); err != nil { + return sszutils.ErrorWithPath(err, "Attestation1") + } + } + { // Dynamic Field #1 'Attestation2' + if canSeek { + enc.EncodeOffsetAt(offset1, uint32(enc.GetPosition()-dstlen)) + } + t := t.Attestation2 + if t == nil { + t = new(IndexedAttestation) + } + if err = t.MarshalSSZEncoder(ds, enc); err != nil { + return sszutils.ErrorWithPath(err, "Attestation2") + } + } + return nil +} + +// UnmarshalSSZDyn unmarshals the *AttesterSlashing from SSZ-encoded bytes using dynamic specifications. +func (t *AttesterSlashing) UnmarshalSSZDyn(ds sszutils.DynamicSpecs, buf []byte) (err error) { + buflen := len(buf) + if buflen < 8 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 8) + } + // Field #0 'Attestation1' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 8 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset0, 8), "Attestation1:o") + } + // Field #1 'Attestation2' (offset) + offset1 := int(binary.LittleEndian.Uint32(buf[4:8])) + if offset1 < offset0 || offset1 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset1, offset0, buflen), "Attestation2:o") + } + { // Field #0 'Attestation1' (dynamic) + buf := buf[offset0:offset1] + if t.Attestation1 == nil { + t.Attestation1 = new(IndexedAttestation) + } + if err = t.Attestation1.UnmarshalSSZDyn(ds, buf); err != nil { + return sszutils.ErrorWithPath(err, "Attestation1") + } + } + { // Field #1 'Attestation2' (dynamic) + buf := buf[offset1:] + if t.Attestation2 == nil { + t.Attestation2 = new(IndexedAttestation) + } + if err = t.Attestation2.UnmarshalSSZDyn(ds, buf); err != nil { + return sszutils.ErrorWithPath(err, "Attestation2") + } + } + return nil +} + +// UnmarshalSSZDecoder unmarshals the *AttesterSlashing from the given SSZ decoder using dynamic specifications. +func (t *AttesterSlashing) UnmarshalSSZDecoder(ds sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { + maxOffset := uint32(dec.GetLength()) + startPos0 := dec.GetPosition() + if maxOffset < uint32(8) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(8)) + } + // Field #0 'Attestation1' (offset) + offset0, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Attestation1") + } + if offset0 != uint32(8) { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset0, 8), "Attestation1") + } + // Field #1 'Attestation2' (offset) + offset1, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Attestation2") + } + if offset1 < offset0 || offset1 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset1, offset0, maxOffset), "Attestation2") + } + { // Field #0 'Attestation1' (dynamic) + if dec.GetPosition() != startPos0+int(offset0) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset0)), "Attestation1") + } + dec.PushLimit(int(offset1 - offset0)) + val1 := t.Attestation1 + if val1 == nil { + val1 = new(IndexedAttestation) + } + if err = val1.UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPath(err, "Attestation1") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Attestation1") + } + t.Attestation1 = val1 + } + { // Field #1 'Attestation2' (dynamic) + if dec.GetPosition() != startPos0+int(offset1) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset1)), "Attestation2") + } + dec.PushLimit(int(maxOffset - offset1)) + val2 := t.Attestation2 + if val2 == nil { + val2 = new(IndexedAttestation) + } + if err = val2.UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPath(err, "Attestation2") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Attestation2") + } + t.Attestation2 = val2 + } + return nil +} + +// SizeSSZDyn returns the SSZ encoded size of the *AttesterSlashing using dynamic specifications. +func (t *AttesterSlashing) SizeSSZDyn(ds sszutils.DynamicSpecs) (size int) { + if t == nil { + t = new(AttesterSlashing) + } + // Field #0 'Attestation1' offset (4 bytes) + // Field #1 'Attestation2' offset (4 bytes) + size += 8 + { // Dynamic field #0 'Attestation1' + size += t.Attestation1.SizeSSZDyn(ds) + } + { // Dynamic field #1 'Attestation2' + size += t.Attestation2.SizeSSZDyn(ds) + } + return size +} + +// HashTreeRootDyn computes the SSZ hash tree root of the *AttesterSlashing using dynamic specifications. +func (t *AttesterSlashing) HashTreeRootDyn(ds sszutils.DynamicSpecs) (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWithDyn(ds, hh) + if err == nil { + root, err = hh.HashRoot() + } + return + }) + return +} + +// HashTreeRootWithDyn computes the SSZ hash tree root of the *AttesterSlashing using dynamic specifications and the given hash walker. +func (t *AttesterSlashing) HashTreeRootWithDyn(ds sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + if t == nil { + t = new(AttesterSlashing) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Attestation1' + t := t.Attestation1 + if t == nil { + t = new(IndexedAttestation) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPath(err, "Attestation1") + } + } + { // Field #1 'Attestation2' + t := t.Attestation2 + if t == nil { + t = new(IndexedAttestation) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPath(err, "Attestation2") + } + } + hh.Merkleize(idx) + return nil +} + +// MarshalSSZDyn marshals the *IndexedAttestation to SSZ-encoded bytes using dynamic specifications. +func (t *IndexedAttestation) MarshalSSZDyn(ds sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + dst = buf + if t == nil { + t = new(IndexedAttestation) + } + dstlen := len(dst) + // Offset Field #0 'AttestingIndices' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #1 'Data' + t := t.Data + if t == nil { + t = new(generic.AttestationData) + } + if dst, err = t.MarshalSSZDyn(ds, dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "Data") + } + } + { // Static Field #2 'Signature' + vlen := len(t.Signature) + if vlen > 96 { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 96), "Signature") + } + dst = append(dst, t.Signature[:vlen]...) + if vlen < 96 { + dst = sszutils.AppendZeroPadding(dst, (96-vlen)*1) + } + } + { // Dynamic Field #0 'AttestingIndices' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.AttestingIndices + vlen := len(t) + if vlen > 131072 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 131072), "AttestingIndices") + } + dst = sszutils.MarshalUint64Slice(dst, t[:vlen]) + } + return dst, nil +} + +// MarshalSSZEncoder marshals the *IndexedAttestation to the given SSZ encoder using dynamic specifications. +func (t *IndexedAttestation) MarshalSSZEncoder(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + type encoderCtx struct { + ds sszutils.DynamicSpecs + exprs [0]uint64 + sizeFn1 func(ctx *encoderCtx, t []uint64) (size int) + } + ctx := &encoderCtx{ds: ds} + canSeek := enc.Seekable() + // size for []uint64 + ctx.sizeFn1 = func(ctx *encoderCtx, t []uint64) (size int) { + size += len(t) * 8 + return size + } + if t == nil { + t = new(IndexedAttestation) + } + dstlen := enc.GetPosition() + dynoff := uint32(228) + // Offset #0 'AttestingIndices' + offset0 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn1(ctx, t.AttestingIndices)) + } + { // Field #1 'Data' + t := t.Data + if t == nil { + t = new(generic.AttestationData) + } + if err = t.MarshalSSZEncoder(ds, enc); err != nil { + return sszutils.ErrorWithPath(err, "Data") + } + } + { // Field #2 'Signature' + vlen := len(t.Signature) + if vlen > 96 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 96), "Signature") + } + enc.EncodeBytes(t.Signature[:vlen]) + if vlen < 96 { + enc.EncodeZeroPadding((96 - vlen) * 1) + } + } + { // Dynamic Field #0 'AttestingIndices' + if canSeek { + enc.EncodeOffsetAt(offset0, uint32(enc.GetPosition()-dstlen)) + } + t := t.AttestingIndices + vlen := len(t) + if vlen > 131072 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 131072), "AttestingIndices") + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + } + return nil +} + +// UnmarshalSSZDyn unmarshals the *IndexedAttestation from SSZ-encoded bytes using dynamic specifications. +func (t *IndexedAttestation) UnmarshalSSZDyn(ds sszutils.DynamicSpecs, buf []byte) (err error) { + buflen := len(buf) + if buflen < 228 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 228) + } + // Field #0 'AttestingIndices' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 228 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset0, 228), "AttestingIndices:o") + } + { // Field #1 'Data' (static) + buf := buf[4:132] + if t.Data == nil { + t.Data = new(generic.AttestationData) + } + if err = t.Data.UnmarshalSSZDyn(ds, buf); err != nil { + return sszutils.ErrorWithPath(err, "Data") + } + } + { // Field #2 'Signature' (static) + buf := buf[132:228] + t.Signature = sszutils.ExpandSlice(t.Signature, 96) + copy(t.Signature[:], buf) + } + { // Field #0 'AttestingIndices' (dynamic) + buf := buf[offset0:] + val1 := t.AttestingIndices + itemCount := len(buf) / 8 + if len(buf)%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 8), "AttestingIndices") + } + if itemCount > 131072 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 131072), "AttestingIndices") + } + val1 = sszutils.ExpandSlice(val1, itemCount) + sszutils.UnmarshalUint64Slice(val1, buf) + t.AttestingIndices = val1 + } + return nil +} + +// UnmarshalSSZDecoder unmarshals the *IndexedAttestation from the given SSZ decoder using dynamic specifications. +func (t *IndexedAttestation) UnmarshalSSZDecoder(ds sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { + maxOffset := uint32(dec.GetLength()) + startPos0 := dec.GetPosition() + if maxOffset < uint32(228) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(228)) + } + // Field #0 'AttestingIndices' (offset) + offset0, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "AttestingIndices") + } + if offset0 != uint32(228) { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset0, 228), "AttestingIndices") + } + // Field #1 'Data' (static) + if t.Data == nil { + t.Data = new(generic.AttestationData) + } + if err = t.Data.UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPath(err, "Data") + } + // Field #2 'Signature' (static) + t.Signature = sszutils.ExpandSlice(t.Signature, 96) + if _, err = dec.DecodeBytes(t.Signature[:96]); err != nil { + return err + } + { // Field #0 'AttestingIndices' (dynamic) + if dec.GetPosition() != startPos0+int(offset0) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset0)), "AttestingIndices") + } + dec.PushLimit(int(maxOffset - offset0)) + val1 := t.AttestingIndices + sszLen := dec.GetLength() + itemCount := sszLen / 8 + if sszLen%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 8), "AttestingIndices") + } + if itemCount > 131072 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 131072), "AttestingIndices") + } + val1 = sszutils.ExpandSlice(val1, itemCount) + if err = sszutils.DecodeUint64Slice(dec, val1); err != nil { + return sszutils.ErrorWithPath(err, "AttestingIndices") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "AttestingIndices") + } + t.AttestingIndices = val1 + } + return nil +} + +// SizeSSZ returns the SSZ encoded size of the *IndexedAttestation. +func (t *IndexedAttestation) SizeSSZ() (size int) { + if t == nil { + t = new(IndexedAttestation) + } + // Field #0 'AttestingIndices' offset (4 bytes) + // Field #1 'Data' static (128 bytes) + // Field #2 'Signature' static (96 bytes) + size += 228 + { // Dynamic field #0 'AttestingIndices' + size += len(t.AttestingIndices) * 8 + } + return size +} + +// SizeSSZDyn returns the SSZ encoded size of the *IndexedAttestation using dynamic specifications. +func (t *IndexedAttestation) SizeSSZDyn(_ sszutils.DynamicSpecs) (size int) { + return t.SizeSSZ() +} + +// HashTreeRootDyn computes the SSZ hash tree root of the *IndexedAttestation using dynamic specifications. +func (t *IndexedAttestation) HashTreeRootDyn(ds sszutils.DynamicSpecs) (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWithDyn(ds, hh) + if err == nil { + root, err = hh.HashRoot() + } + return + }) + return +} + +// HashTreeRootWithDyn computes the SSZ hash tree root of the *IndexedAttestation using dynamic specifications and the given hash walker. +func (t *IndexedAttestation) HashTreeRootWithDyn(ds sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + if t == nil { + t = new(IndexedAttestation) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'AttestingIndices' + t := t.AttestingIndices + vlen := uint64(len(t)) + if vlen > 131072 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 131072), "AttestingIndices") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + sszutils.HashUint64Slice(hh, t) + hh.FillUpTo32() + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(131072, vlen, 8)) + } + { // Field #1 'Data' + t := t.Data + if t == nil { + t = new(generic.AttestationData) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPath(err, "Data") + } + } + { // Field #2 'Signature' + vlen := len(t.Signature) + if vlen > 96 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 96), "Signature") + } + val := t.Signature[:] + if vlen < 96 { + val = sszutils.AppendZeroPadding(val, (96-vlen)*1) + } + hh.PutBytes(val[:96]) + } + hh.Merkleize(idx) + return nil +} diff --git a/shared/types/eth2/fork/fulu/state_fulu.go b/shared/types/eth2/fork/fulu/state_fulu.go index 9b517fc53..f98024f5f 100644 --- a/shared/types/eth2/fork/fulu/state_fulu.go +++ b/shared/types/eth2/fork/fulu/state_fulu.go @@ -93,7 +93,7 @@ func (state *BeaconState) ValidatorAndSlotProof(validatorIndex uint64) ([][]byte return nil, nil, errors.New("validator index out of bounds") } - stateTree, err := state.GetTree() + stateTree, err := generic.SSZ.GetTree(state) if err != nil { return nil, nil, fmt.Errorf("could not get state tree: %w", err) } @@ -105,7 +105,7 @@ func (state *BeaconState) ValidatorAndSlotProof(validatorIndex uint64) ([][]byte } // Sanity check that the proof leaf matches the expected validator - validatorHashTreeRoot, err := state.Validators[validatorIndex].HashTreeRoot() + validatorHashTreeRoot, err := generic.SSZ.HashTreeRoot(state.Validators[validatorIndex]) if err != nil { return nil, nil, fmt.Errorf("could not get hash tree root for validator: %w", err) } @@ -121,7 +121,7 @@ func (state *BeaconState) ValidatorAndSlotProof(validatorIndex uint64) ([][]byte // Drop the state tree before doing more work so the GC can reclaim it. stateTree = nil - bhTree, err := state.LatestBlockHeader.GetTree() + bhTree, err := generic.SSZ.GetTree(state.LatestBlockHeader) if err != nil { return nil, nil, fmt.Errorf("could not get block header tree: %w", err) } @@ -143,7 +143,7 @@ func (state *BeaconState) ValidatorAndSlotProof(validatorIndex uint64) ([][]byte func (state *BeaconState) blockHeaderToStateProof(blockHeader *generic.BeaconBlockHeader) ([][]byte, error) { generalizedIndex := generic.BeaconBlockHeaderStateRootGeneralizedIndex - root, err := blockHeader.GetTree() + root, err := generic.SSZ.GetTree(blockHeader) if err != nil { return nil, fmt.Errorf("could not get block header tree: %w", err) } @@ -159,7 +159,7 @@ func (state *BeaconState) HistoricalSummaryProof(slot uint64, capellaOffset uint if !isHistorical { return nil, fmt.Errorf("slot %d is less than %d slots in the past from the state at slot %d, you must build a proof from the block_roots field instead", slot, generic.SlotsPerHistoricalRoot, state.Slot) } - tree, err := state.GetTree() + tree, err := generic.SSZ.GetTree(state) if err != nil { return nil, fmt.Errorf("could not get state tree: %w", err) } @@ -197,7 +197,7 @@ func (state *BeaconState) HistoricalSummaryBlockRootProof(slot int) ([][]byte, e } idx := slot % int(generic.SlotsPerHistoricalRoot) - tree, err := hsls.GetTree() + tree, err := generic.SSZ.GetTree(&hsls) if err != nil { return nil, fmt.Errorf("could not get historical summary lists tree: %w", err) } @@ -221,7 +221,7 @@ func (state *BeaconState) BlockRootProof(slot uint64) ([][]byte, error) { return nil, fmt.Errorf("slot %d is more than %d slots in the past from the state at slot %d, you must build a proof from the historical_summaries instead", slot, generic.SlotsPerHistoricalRoot, state.Slot) } - tree, err := state.GetTree() + tree, err := generic.SSZ.GetTree(state) if err != nil { return nil, fmt.Errorf("could not get state tree: %w", err) } @@ -245,14 +245,14 @@ func (state *BeaconState) BlockRootProof(slot uint64) ([][]byte, error) { func (state *BeaconState) BlockHeaderProof() ([][]byte, error) { // Construct block header with state root - stateRoot, err := state.HashTreeRoot() + stateRoot, err := generic.SSZ.HashTreeRoot(state) if err != nil { return nil, fmt.Errorf("could not get state root: %w", err) } latestBlockHeader := state.LatestBlockHeader blockHeader := *latestBlockHeader blockHeader.StateRoot = stateRoot[:] - blockHeaderTree, err := blockHeader.GetTree() + blockHeaderTree, err := generic.SSZ.GetTree(&blockHeader) if err != nil { return nil, fmt.Errorf("could not get block header tree: %w", err) } diff --git a/shared/types/eth2/fork/fulu/state_fulu_encoding.go b/shared/types/eth2/fork/fulu/state_fulu_encoding.go deleted file mode 100644 index d6eacec78..000000000 --- a/shared/types/eth2/fork/fulu/state_fulu_encoding.go +++ /dev/null @@ -1,1143 +0,0 @@ -// Code generated by fastssz. DO NOT EDIT. -// Hash: e63808224385bd83b3c7ad051f80a6f5abeb410951500f8bd0c7c1453798acdd -// Version: 0.1.3 -package fulu - -import ( - ssz "github.com/ferranbt/fastssz" - - "github.com/rocket-pool/smartnode/shared/types/eth2/generic" -) - -// MarshalSSZ ssz marshals the BeaconState object -func (b *BeaconState) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} - -// MarshalSSZTo ssz marshals the BeaconState object to a target array -func (b *BeaconState) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(2737225) - - // Field (0) 'GenesisTime' - dst = ssz.MarshalUint64(dst, b.GenesisTime) - - // Field (1) 'GenesisValidatorsRoot' - if size := len(b.GenesisValidatorsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("BeaconState.GenesisValidatorsRoot", size, 32) - return - } - dst = append(dst, b.GenesisValidatorsRoot...) - - // Field (2) 'Slot' - dst = ssz.MarshalUint64(dst, b.Slot) - - // Field (3) 'Fork' - if b.Fork == nil { - b.Fork = new(generic.Fork) - } - if dst, err = b.Fork.MarshalSSZTo(dst); err != nil { - return - } - - // Field (4) 'LatestBlockHeader' - if b.LatestBlockHeader == nil { - b.LatestBlockHeader = new(generic.BeaconBlockHeader) - } - if dst, err = b.LatestBlockHeader.MarshalSSZTo(dst); err != nil { - return - } - - // Field (5) 'BlockRoots' - for ii := 0; ii < 8192; ii++ { - dst = append(dst, b.BlockRoots[ii][:]...) - } - - // Field (6) 'StateRoots' - for ii := 0; ii < 8192; ii++ { - dst = append(dst, b.StateRoots[ii][:]...) - } - - // Offset (7) 'HistoricalRoots' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.HistoricalRoots) * 32 - - // Field (8) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(generic.Eth1Data) - } - if dst, err = b.Eth1Data.MarshalSSZTo(dst); err != nil { - return - } - - // Offset (9) 'Eth1DataVotes' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.Eth1DataVotes) * 72 - - // Field (10) 'Eth1DepositIndex' - dst = ssz.MarshalUint64(dst, b.Eth1DepositIndex) - - // Offset (11) 'Validators' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.Validators) * 121 - - // Offset (12) 'Balances' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.Balances) * 8 - - // Field (13) 'RandaoMixes' - if size := len(b.RandaoMixes); size != 65536 { - err = ssz.ErrVectorLengthFn("BeaconState.RandaoMixes", size, 65536) - return - } - for ii := 0; ii < 65536; ii++ { - if size := len(b.RandaoMixes[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("BeaconState.RandaoMixes[ii]", size, 32) - return - } - dst = append(dst, b.RandaoMixes[ii]...) - } - - // Field (14) 'Slashings' - if size := len(b.Slashings); size != 8192 { - err = ssz.ErrVectorLengthFn("BeaconState.Slashings", size, 8192) - return - } - for ii := 0; ii < 8192; ii++ { - dst = ssz.MarshalUint64(dst, b.Slashings[ii]) - } - - // Offset (15) 'PreviousEpochParticipation' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.PreviousEpochParticipation) - - // Offset (16) 'CurrentEpochParticipation' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.CurrentEpochParticipation) - - // Field (17) 'JustificationBits' - dst = append(dst, b.JustificationBits[:]...) - - // Field (18) 'PreviousJustifiedCheckpoint' - if b.PreviousJustifiedCheckpoint == nil { - b.PreviousJustifiedCheckpoint = new(generic.Checkpoint) - } - if dst, err = b.PreviousJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { - return - } - - // Field (19) 'CurrentJustifiedCheckpoint' - if b.CurrentJustifiedCheckpoint == nil { - b.CurrentJustifiedCheckpoint = new(generic.Checkpoint) - } - if dst, err = b.CurrentJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { - return - } - - // Field (20) 'FinalizedCheckpoint' - if b.FinalizedCheckpoint == nil { - b.FinalizedCheckpoint = new(generic.Checkpoint) - } - if dst, err = b.FinalizedCheckpoint.MarshalSSZTo(dst); err != nil { - return - } - - // Offset (21) 'InactivityScores' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.InactivityScores) * 8 - - // Field (22) 'CurrentSyncCommittee' - if b.CurrentSyncCommittee == nil { - b.CurrentSyncCommittee = new(generic.SyncCommittee) - } - if dst, err = b.CurrentSyncCommittee.MarshalSSZTo(dst); err != nil { - return - } - - // Field (23) 'NextSyncCommittee' - if b.NextSyncCommittee == nil { - b.NextSyncCommittee = new(generic.SyncCommittee) - } - if dst, err = b.NextSyncCommittee.MarshalSSZTo(dst); err != nil { - return - } - - // Offset (24) 'LatestExecutionPayloadHeader' - dst = ssz.WriteOffset(dst, offset) - if b.LatestExecutionPayloadHeader == nil { - b.LatestExecutionPayloadHeader = new(generic.ExecutionPayloadHeader) - } - offset += b.LatestExecutionPayloadHeader.SizeSSZ() - - // Field (25) 'NextWithdrawalIndex' - dst = ssz.MarshalUint64(dst, b.NextWithdrawalIndex) - - // Field (26) 'NextWithdrawalValidatorIndex' - dst = ssz.MarshalUint64(dst, b.NextWithdrawalValidatorIndex) - - // Offset (27) 'HistoricalSummaries' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.HistoricalSummaries) * 64 - - // Field (28) 'DepositRequestsStartIndex' - dst = ssz.MarshalUint64(dst, b.DepositRequestsStartIndex) - - // Field (29) 'DepositBalanceToConsume' - dst = ssz.MarshalUint64(dst, b.DepositBalanceToConsume) - - // Field (30) 'ExitBalanceToConsume' - dst = ssz.MarshalUint64(dst, b.ExitBalanceToConsume) - - // Field (31) 'EarliestExitEpoch' - dst = ssz.MarshalUint64(dst, b.EarliestExitEpoch) - - // Field (32) 'ConsolidationBalanceToConsume' - dst = ssz.MarshalUint64(dst, b.ConsolidationBalanceToConsume) - - // Field (33) 'EarliestConsolidationEpoch' - dst = ssz.MarshalUint64(dst, b.EarliestConsolidationEpoch) - - // Offset (34) 'PendingDeposits' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.PendingDeposits) * 192 - - // Offset (35) 'PendingPartialWithdrawals' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.PendingPartialWithdrawals) * 24 - - // Offset (36) 'PendingConsolidations' - dst = ssz.WriteOffset(dst, offset) - - // Field (37) 'ProposerLookahead' - if size := len(b.ProposerLookahead); size != 64 { - err = ssz.ErrVectorLengthFn("BeaconState.ProposerLookahead", size, 64) - return - } - for ii := 0; ii < 64; ii++ { - dst = ssz.MarshalUint64(dst, b.ProposerLookahead[ii]) - } - - // Field (7) 'HistoricalRoots' - if size := len(b.HistoricalRoots); size > 16777216 { - err = ssz.ErrListTooBigFn("BeaconState.HistoricalRoots", size, 16777216) - return - } - for ii := 0; ii < len(b.HistoricalRoots); ii++ { - if size := len(b.HistoricalRoots[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("BeaconState.HistoricalRoots[ii]", size, 32) - return - } - dst = append(dst, b.HistoricalRoots[ii]...) - } - - // Field (9) 'Eth1DataVotes' - if size := len(b.Eth1DataVotes); size > 2048 { - err = ssz.ErrListTooBigFn("BeaconState.Eth1DataVotes", size, 2048) - return - } - for ii := 0; ii < len(b.Eth1DataVotes); ii++ { - if dst, err = b.Eth1DataVotes[ii].MarshalSSZTo(dst); err != nil { - return - } - } - - // Field (11) 'Validators' - if size := len(b.Validators); size > 1099511627776 { - err = ssz.ErrListTooBigFn("BeaconState.Validators", size, 1099511627776) - return - } - for ii := 0; ii < len(b.Validators); ii++ { - if dst, err = b.Validators[ii].MarshalSSZTo(dst); err != nil { - return - } - } - - // Field (12) 'Balances' - if size := len(b.Balances); size > 1099511627776 { - err = ssz.ErrListTooBigFn("BeaconState.Balances", size, 1099511627776) - return - } - for ii := 0; ii < len(b.Balances); ii++ { - dst = ssz.MarshalUint64(dst, b.Balances[ii]) - } - - // Field (15) 'PreviousEpochParticipation' - if size := len(b.PreviousEpochParticipation); size > 1099511627776 { - err = ssz.ErrBytesLengthFn("BeaconState.PreviousEpochParticipation", size, 1099511627776) - return - } - dst = append(dst, b.PreviousEpochParticipation...) - - // Field (16) 'CurrentEpochParticipation' - if size := len(b.CurrentEpochParticipation); size > 1099511627776 { - err = ssz.ErrBytesLengthFn("BeaconState.CurrentEpochParticipation", size, 1099511627776) - return - } - dst = append(dst, b.CurrentEpochParticipation...) - - // Field (21) 'InactivityScores' - if size := len(b.InactivityScores); size > 1099511627776 { - err = ssz.ErrListTooBigFn("BeaconState.InactivityScores", size, 1099511627776) - return - } - for ii := 0; ii < len(b.InactivityScores); ii++ { - dst = ssz.MarshalUint64(dst, b.InactivityScores[ii]) - } - - // Field (24) 'LatestExecutionPayloadHeader' - if dst, err = b.LatestExecutionPayloadHeader.MarshalSSZTo(dst); err != nil { - return - } - - // Field (27) 'HistoricalSummaries' - if size := len(b.HistoricalSummaries); size > 16777216 { - err = ssz.ErrListTooBigFn("BeaconState.HistoricalSummaries", size, 16777216) - return - } - for ii := 0; ii < len(b.HistoricalSummaries); ii++ { - if dst, err = b.HistoricalSummaries[ii].MarshalSSZTo(dst); err != nil { - return - } - } - - // Field (34) 'PendingDeposits' - if size := len(b.PendingDeposits); size > 134217728 { - err = ssz.ErrListTooBigFn("BeaconState.PendingDeposits", size, 134217728) - return - } - for ii := 0; ii < len(b.PendingDeposits); ii++ { - if dst, err = b.PendingDeposits[ii].MarshalSSZTo(dst); err != nil { - return - } - } - - // Field (35) 'PendingPartialWithdrawals' - if size := len(b.PendingPartialWithdrawals); size > 134217728 { - err = ssz.ErrListTooBigFn("BeaconState.PendingPartialWithdrawals", size, 134217728) - return - } - for ii := 0; ii < len(b.PendingPartialWithdrawals); ii++ { - if dst, err = b.PendingPartialWithdrawals[ii].MarshalSSZTo(dst); err != nil { - return - } - } - - // Field (36) 'PendingConsolidations' - if size := len(b.PendingConsolidations); size > 262144 { - err = ssz.ErrListTooBigFn("BeaconState.PendingConsolidations", size, 262144) - return - } - for ii := 0; ii < len(b.PendingConsolidations); ii++ { - if dst, err = b.PendingConsolidations[ii].MarshalSSZTo(dst); err != nil { - return - } - } - - return -} - -// UnmarshalSSZ ssz unmarshals the BeaconState object -func (b *BeaconState) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 2737225 { - return ssz.ErrSize - } - - tail := buf - var o7, o9, o11, o12, o15, o16, o21, o24, o27, o34, o35, o36 uint64 - - // Field (0) 'GenesisTime' - b.GenesisTime = ssz.UnmarshallUint64(buf[0:8]) - - // Field (1) 'GenesisValidatorsRoot' - if cap(b.GenesisValidatorsRoot) == 0 { - b.GenesisValidatorsRoot = make([]byte, 0, len(buf[8:40])) - } - b.GenesisValidatorsRoot = append(b.GenesisValidatorsRoot, buf[8:40]...) - - // Field (2) 'Slot' - b.Slot = ssz.UnmarshallUint64(buf[40:48]) - - // Field (3) 'Fork' - if b.Fork == nil { - b.Fork = new(generic.Fork) - } - if err = b.Fork.UnmarshalSSZ(buf[48:64]); err != nil { - return err - } - - // Field (4) 'LatestBlockHeader' - if b.LatestBlockHeader == nil { - b.LatestBlockHeader = new(generic.BeaconBlockHeader) - } - if err = b.LatestBlockHeader.UnmarshalSSZ(buf[64:176]); err != nil { - return err - } - - // Field (5) 'BlockRoots' - - for ii := 0; ii < 8192; ii++ { - copy(b.BlockRoots[ii][:], buf[176:262320][ii*32:(ii+1)*32]) - } - - // Field (6) 'StateRoots' - - for ii := 0; ii < 8192; ii++ { - copy(b.StateRoots[ii][:], buf[262320:524464][ii*32:(ii+1)*32]) - } - - // Offset (7) 'HistoricalRoots' - if o7 = ssz.ReadOffset(buf[524464:524468]); o7 > size { - return ssz.ErrOffset - } - - if o7 != 2737225 { - return ssz.ErrInvalidVariableOffset - } - - // Field (8) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(generic.Eth1Data) - } - if err = b.Eth1Data.UnmarshalSSZ(buf[524468:524540]); err != nil { - return err - } - - // Offset (9) 'Eth1DataVotes' - if o9 = ssz.ReadOffset(buf[524540:524544]); o9 > size || o7 > o9 { - return ssz.ErrOffset - } - - // Field (10) 'Eth1DepositIndex' - b.Eth1DepositIndex = ssz.UnmarshallUint64(buf[524544:524552]) - - // Offset (11) 'Validators' - if o11 = ssz.ReadOffset(buf[524552:524556]); o11 > size || o9 > o11 { - return ssz.ErrOffset - } - - // Offset (12) 'Balances' - if o12 = ssz.ReadOffset(buf[524556:524560]); o12 > size || o11 > o12 { - return ssz.ErrOffset - } - - // Field (13) 'RandaoMixes' - b.RandaoMixes = make([][]byte, 65536) - for ii := 0; ii < 65536; ii++ { - if cap(b.RandaoMixes[ii]) == 0 { - b.RandaoMixes[ii] = make([]byte, 0, len(buf[524560:2621712][ii*32:(ii+1)*32])) - } - b.RandaoMixes[ii] = append(b.RandaoMixes[ii], buf[524560:2621712][ii*32:(ii+1)*32]...) - } - - // Field (14) 'Slashings' - b.Slashings = ssz.ExtendUint64(b.Slashings, 8192) - for ii := 0; ii < 8192; ii++ { - b.Slashings[ii] = ssz.UnmarshallUint64(buf[2621712:2687248][ii*8 : (ii+1)*8]) - } - - // Offset (15) 'PreviousEpochParticipation' - if o15 = ssz.ReadOffset(buf[2687248:2687252]); o15 > size || o12 > o15 { - return ssz.ErrOffset - } - - // Offset (16) 'CurrentEpochParticipation' - if o16 = ssz.ReadOffset(buf[2687252:2687256]); o16 > size || o15 > o16 { - return ssz.ErrOffset - } - - // Field (17) 'JustificationBits' - copy(b.JustificationBits[:], buf[2687256:2687257]) - - // Field (18) 'PreviousJustifiedCheckpoint' - if b.PreviousJustifiedCheckpoint == nil { - b.PreviousJustifiedCheckpoint = new(generic.Checkpoint) - } - if err = b.PreviousJustifiedCheckpoint.UnmarshalSSZ(buf[2687257:2687297]); err != nil { - return err - } - - // Field (19) 'CurrentJustifiedCheckpoint' - if b.CurrentJustifiedCheckpoint == nil { - b.CurrentJustifiedCheckpoint = new(generic.Checkpoint) - } - if err = b.CurrentJustifiedCheckpoint.UnmarshalSSZ(buf[2687297:2687337]); err != nil { - return err - } - - // Field (20) 'FinalizedCheckpoint' - if b.FinalizedCheckpoint == nil { - b.FinalizedCheckpoint = new(generic.Checkpoint) - } - if err = b.FinalizedCheckpoint.UnmarshalSSZ(buf[2687337:2687377]); err != nil { - return err - } - - // Offset (21) 'InactivityScores' - if o21 = ssz.ReadOffset(buf[2687377:2687381]); o21 > size || o16 > o21 { - return ssz.ErrOffset - } - - // Field (22) 'CurrentSyncCommittee' - if b.CurrentSyncCommittee == nil { - b.CurrentSyncCommittee = new(generic.SyncCommittee) - } - if err = b.CurrentSyncCommittee.UnmarshalSSZ(buf[2687381:2712005]); err != nil { - return err - } - - // Field (23) 'NextSyncCommittee' - if b.NextSyncCommittee == nil { - b.NextSyncCommittee = new(generic.SyncCommittee) - } - if err = b.NextSyncCommittee.UnmarshalSSZ(buf[2712005:2736629]); err != nil { - return err - } - - // Offset (24) 'LatestExecutionPayloadHeader' - if o24 = ssz.ReadOffset(buf[2736629:2736633]); o24 > size || o21 > o24 { - return ssz.ErrOffset - } - - // Field (25) 'NextWithdrawalIndex' - b.NextWithdrawalIndex = ssz.UnmarshallUint64(buf[2736633:2736641]) - - // Field (26) 'NextWithdrawalValidatorIndex' - b.NextWithdrawalValidatorIndex = ssz.UnmarshallUint64(buf[2736641:2736649]) - - // Offset (27) 'HistoricalSummaries' - if o27 = ssz.ReadOffset(buf[2736649:2736653]); o27 > size || o24 > o27 { - return ssz.ErrOffset - } - - // Field (28) 'DepositRequestsStartIndex' - b.DepositRequestsStartIndex = ssz.UnmarshallUint64(buf[2736653:2736661]) - - // Field (29) 'DepositBalanceToConsume' - b.DepositBalanceToConsume = ssz.UnmarshallUint64(buf[2736661:2736669]) - - // Field (30) 'ExitBalanceToConsume' - b.ExitBalanceToConsume = ssz.UnmarshallUint64(buf[2736669:2736677]) - - // Field (31) 'EarliestExitEpoch' - b.EarliestExitEpoch = ssz.UnmarshallUint64(buf[2736677:2736685]) - - // Field (32) 'ConsolidationBalanceToConsume' - b.ConsolidationBalanceToConsume = ssz.UnmarshallUint64(buf[2736685:2736693]) - - // Field (33) 'EarliestConsolidationEpoch' - b.EarliestConsolidationEpoch = ssz.UnmarshallUint64(buf[2736693:2736701]) - - // Offset (34) 'PendingDeposits' - if o34 = ssz.ReadOffset(buf[2736701:2736705]); o34 > size || o27 > o34 { - return ssz.ErrOffset - } - - // Offset (35) 'PendingPartialWithdrawals' - if o35 = ssz.ReadOffset(buf[2736705:2736709]); o35 > size || o34 > o35 { - return ssz.ErrOffset - } - - // Offset (36) 'PendingConsolidations' - if o36 = ssz.ReadOffset(buf[2736709:2736713]); o36 > size || o35 > o36 { - return ssz.ErrOffset - } - - // Field (37) 'ProposerLookahead' - b.ProposerLookahead = ssz.ExtendUint64(b.ProposerLookahead, 64) - for ii := 0; ii < 64; ii++ { - b.ProposerLookahead[ii] = ssz.UnmarshallUint64(buf[2736713:2737225][ii*8 : (ii+1)*8]) - } - - // Field (7) 'HistoricalRoots' - { - buf = tail[o7:o9] - num, err := ssz.DivideInt2(len(buf), 32, 16777216) - if err != nil { - return err - } - b.HistoricalRoots = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(b.HistoricalRoots[ii]) == 0 { - b.HistoricalRoots[ii] = make([]byte, 0, len(buf[ii*32:(ii+1)*32])) - } - b.HistoricalRoots[ii] = append(b.HistoricalRoots[ii], buf[ii*32:(ii+1)*32]...) - } - } - - // Field (9) 'Eth1DataVotes' - { - buf = tail[o9:o11] - num, err := ssz.DivideInt2(len(buf), 72, 2048) - if err != nil { - return err - } - b.Eth1DataVotes = make([]*generic.Eth1Data, num) - for ii := 0; ii < num; ii++ { - if b.Eth1DataVotes[ii] == nil { - b.Eth1DataVotes[ii] = new(generic.Eth1Data) - } - if err = b.Eth1DataVotes[ii].UnmarshalSSZ(buf[ii*72 : (ii+1)*72]); err != nil { - return err - } - } - } - - // Field (11) 'Validators' - { - buf = tail[o11:o12] - num, err := ssz.DivideInt2(len(buf), 121, 1099511627776) - if err != nil { - return err - } - b.Validators = make([]*generic.Validator, num) - for ii := 0; ii < num; ii++ { - if b.Validators[ii] == nil { - b.Validators[ii] = new(generic.Validator) - } - if err = b.Validators[ii].UnmarshalSSZ(buf[ii*121 : (ii+1)*121]); err != nil { - return err - } - } - } - - // Field (12) 'Balances' - { - buf = tail[o12:o15] - num, err := ssz.DivideInt2(len(buf), 8, 1099511627776) - if err != nil { - return err - } - b.Balances = ssz.ExtendUint64(b.Balances, num) - for ii := 0; ii < num; ii++ { - b.Balances[ii] = ssz.UnmarshallUint64(buf[ii*8 : (ii+1)*8]) - } - } - - // Field (15) 'PreviousEpochParticipation' - { - buf = tail[o15:o16] - if len(buf) > 1099511627776 { - return ssz.ErrBytesLength - } - if cap(b.PreviousEpochParticipation) == 0 { - b.PreviousEpochParticipation = make([]byte, 0, len(buf)) - } - b.PreviousEpochParticipation = append(b.PreviousEpochParticipation, buf...) - } - - // Field (16) 'CurrentEpochParticipation' - { - buf = tail[o16:o21] - if len(buf) > 1099511627776 { - return ssz.ErrBytesLength - } - if cap(b.CurrentEpochParticipation) == 0 { - b.CurrentEpochParticipation = make([]byte, 0, len(buf)) - } - b.CurrentEpochParticipation = append(b.CurrentEpochParticipation, buf...) - } - - // Field (21) 'InactivityScores' - { - buf = tail[o21:o24] - num, err := ssz.DivideInt2(len(buf), 8, 1099511627776) - if err != nil { - return err - } - b.InactivityScores = ssz.ExtendUint64(b.InactivityScores, num) - for ii := 0; ii < num; ii++ { - b.InactivityScores[ii] = ssz.UnmarshallUint64(buf[ii*8 : (ii+1)*8]) - } - } - - // Field (24) 'LatestExecutionPayloadHeader' - { - buf = tail[o24:o27] - if b.LatestExecutionPayloadHeader == nil { - b.LatestExecutionPayloadHeader = new(generic.ExecutionPayloadHeader) - } - if err = b.LatestExecutionPayloadHeader.UnmarshalSSZ(buf); err != nil { - return err - } - } - - // Field (27) 'HistoricalSummaries' - { - buf = tail[o27:o34] - num, err := ssz.DivideInt2(len(buf), 64, 16777216) - if err != nil { - return err - } - b.HistoricalSummaries = make([]*generic.HistoricalSummary, num) - for ii := 0; ii < num; ii++ { - if b.HistoricalSummaries[ii] == nil { - b.HistoricalSummaries[ii] = new(generic.HistoricalSummary) - } - if err = b.HistoricalSummaries[ii].UnmarshalSSZ(buf[ii*64 : (ii+1)*64]); err != nil { - return err - } - } - } - - // Field (34) 'PendingDeposits' - { - buf = tail[o34:o35] - num, err := ssz.DivideInt2(len(buf), 192, 134217728) - if err != nil { - return err - } - b.PendingDeposits = make([]*generic.PendingDeposit, num) - for ii := 0; ii < num; ii++ { - if b.PendingDeposits[ii] == nil { - b.PendingDeposits[ii] = new(generic.PendingDeposit) - } - if err = b.PendingDeposits[ii].UnmarshalSSZ(buf[ii*192 : (ii+1)*192]); err != nil { - return err - } - } - } - - // Field (35) 'PendingPartialWithdrawals' - { - buf = tail[o35:o36] - num, err := ssz.DivideInt2(len(buf), 24, 134217728) - if err != nil { - return err - } - b.PendingPartialWithdrawals = make([]*generic.PendingPartialWithdrawal, num) - for ii := 0; ii < num; ii++ { - if b.PendingPartialWithdrawals[ii] == nil { - b.PendingPartialWithdrawals[ii] = new(generic.PendingPartialWithdrawal) - } - if err = b.PendingPartialWithdrawals[ii].UnmarshalSSZ(buf[ii*24 : (ii+1)*24]); err != nil { - return err - } - } - } - - // Field (36) 'PendingConsolidations' - { - buf = tail[o36:] - num, err := ssz.DivideInt2(len(buf), 16, 262144) - if err != nil { - return err - } - b.PendingConsolidations = make([]*generic.PendingConsolidation, num) - for ii := 0; ii < num; ii++ { - if b.PendingConsolidations[ii] == nil { - b.PendingConsolidations[ii] = new(generic.PendingConsolidation) - } - if err = b.PendingConsolidations[ii].UnmarshalSSZ(buf[ii*16 : (ii+1)*16]); err != nil { - return err - } - } - } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the BeaconState object -func (b *BeaconState) SizeSSZ() (size int) { - size = 2737225 - - // Field (7) 'HistoricalRoots' - size += len(b.HistoricalRoots) * 32 - - // Field (9) 'Eth1DataVotes' - size += len(b.Eth1DataVotes) * 72 - - // Field (11) 'Validators' - size += len(b.Validators) * 121 - - // Field (12) 'Balances' - size += len(b.Balances) * 8 - - // Field (15) 'PreviousEpochParticipation' - size += len(b.PreviousEpochParticipation) - - // Field (16) 'CurrentEpochParticipation' - size += len(b.CurrentEpochParticipation) - - // Field (21) 'InactivityScores' - size += len(b.InactivityScores) * 8 - - // Field (24) 'LatestExecutionPayloadHeader' - if b.LatestExecutionPayloadHeader == nil { - b.LatestExecutionPayloadHeader = new(generic.ExecutionPayloadHeader) - } - size += b.LatestExecutionPayloadHeader.SizeSSZ() - - // Field (27) 'HistoricalSummaries' - size += len(b.HistoricalSummaries) * 64 - - // Field (34) 'PendingDeposits' - size += len(b.PendingDeposits) * 192 - - // Field (35) 'PendingPartialWithdrawals' - size += len(b.PendingPartialWithdrawals) * 24 - - // Field (36) 'PendingConsolidations' - size += len(b.PendingConsolidations) * 16 - - return -} - -// HashTreeRoot ssz hashes the BeaconState object -func (b *BeaconState) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) -} - -// HashTreeRootWith ssz hashes the BeaconState object with a hasher -func (b *BeaconState) HashTreeRootWith(hh ssz.HashWalker) (err error) { - indx := hh.Index() - - // Field (0) 'GenesisTime' - hh.PutUint64(b.GenesisTime) - - // Field (1) 'GenesisValidatorsRoot' - if size := len(b.GenesisValidatorsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("BeaconState.GenesisValidatorsRoot", size, 32) - return - } - hh.PutBytes(b.GenesisValidatorsRoot) - - // Field (2) 'Slot' - hh.PutUint64(b.Slot) - - // Field (3) 'Fork' - if b.Fork == nil { - b.Fork = new(generic.Fork) - } - if err = b.Fork.HashTreeRootWith(hh); err != nil { - return - } - - // Field (4) 'LatestBlockHeader' - if b.LatestBlockHeader == nil { - b.LatestBlockHeader = new(generic.BeaconBlockHeader) - } - if err = b.LatestBlockHeader.HashTreeRootWith(hh); err != nil { - return - } - - // Field (5) 'BlockRoots' - { - subIndx := hh.Index() - for _, i := range b.BlockRoots { - hh.Append(i[:]) - } - hh.Merkleize(subIndx) - } - - // Field (6) 'StateRoots' - { - subIndx := hh.Index() - for _, i := range b.StateRoots { - hh.Append(i[:]) - } - hh.Merkleize(subIndx) - } - - // Field (7) 'HistoricalRoots' - { - if size := len(b.HistoricalRoots); size > 16777216 { - err = ssz.ErrListTooBigFn("BeaconState.HistoricalRoots", size, 16777216) - return - } - subIndx := hh.Index() - for _, i := range b.HistoricalRoots { - if len(i) != 32 { - err = ssz.ErrBytesLength - return - } - hh.Append(i) - } - numItems := uint64(len(b.HistoricalRoots)) - hh.MerkleizeWithMixin(subIndx, numItems, 16777216) - } - - // Field (8) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(generic.Eth1Data) - } - if err = b.Eth1Data.HashTreeRootWith(hh); err != nil { - return - } - - // Field (9) 'Eth1DataVotes' - { - subIndx := hh.Index() - num := uint64(len(b.Eth1DataVotes)) - if num > 2048 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range b.Eth1DataVotes { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } - } - hh.MerkleizeWithMixin(subIndx, num, 2048) - } - - // Field (10) 'Eth1DepositIndex' - hh.PutUint64(b.Eth1DepositIndex) - - // Field (11) 'Validators' - { - subIndx := hh.Index() - num := uint64(len(b.Validators)) - if num > 1099511627776 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range b.Validators { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } - } - hh.MerkleizeWithMixin(subIndx, num, 1099511627776) - } - - // Field (12) 'Balances' - { - if size := len(b.Balances); size > 1099511627776 { - err = ssz.ErrListTooBigFn("BeaconState.Balances", size, 1099511627776) - return - } - subIndx := hh.Index() - for _, i := range b.Balances { - hh.AppendUint64(i) - } - hh.FillUpTo32() - numItems := uint64(len(b.Balances)) - hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(1099511627776, numItems, 8)) - } - - // Field (13) 'RandaoMixes' - { - if size := len(b.RandaoMixes); size != 65536 { - err = ssz.ErrVectorLengthFn("BeaconState.RandaoMixes", size, 65536) - return - } - subIndx := hh.Index() - for _, i := range b.RandaoMixes { - if len(i) != 32 { - err = ssz.ErrBytesLength - return - } - hh.Append(i) - } - hh.Merkleize(subIndx) - } - - // Field (14) 'Slashings' - { - if size := len(b.Slashings); size != 8192 { - err = ssz.ErrVectorLengthFn("BeaconState.Slashings", size, 8192) - return - } - subIndx := hh.Index() - for _, i := range b.Slashings { - hh.AppendUint64(i) - } - hh.Merkleize(subIndx) - } - - // Field (15) 'PreviousEpochParticipation' - { - elemIndx := hh.Index() - byteLen := uint64(len(b.PreviousEpochParticipation)) - if byteLen > 1099511627776 { - err = ssz.ErrIncorrectListSize - return - } - hh.Append(b.PreviousEpochParticipation) - hh.MerkleizeWithMixin(elemIndx, byteLen, (1099511627776+31)/32) - } - - // Field (16) 'CurrentEpochParticipation' - { - elemIndx := hh.Index() - byteLen := uint64(len(b.CurrentEpochParticipation)) - if byteLen > 1099511627776 { - err = ssz.ErrIncorrectListSize - return - } - hh.Append(b.CurrentEpochParticipation) - hh.MerkleizeWithMixin(elemIndx, byteLen, (1099511627776+31)/32) - } - - // Field (17) 'JustificationBits' - hh.PutBytes(b.JustificationBits[:]) - - // Field (18) 'PreviousJustifiedCheckpoint' - if b.PreviousJustifiedCheckpoint == nil { - b.PreviousJustifiedCheckpoint = new(generic.Checkpoint) - } - if err = b.PreviousJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { - return - } - - // Field (19) 'CurrentJustifiedCheckpoint' - if b.CurrentJustifiedCheckpoint == nil { - b.CurrentJustifiedCheckpoint = new(generic.Checkpoint) - } - if err = b.CurrentJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { - return - } - - // Field (20) 'FinalizedCheckpoint' - if b.FinalizedCheckpoint == nil { - b.FinalizedCheckpoint = new(generic.Checkpoint) - } - if err = b.FinalizedCheckpoint.HashTreeRootWith(hh); err != nil { - return - } - - // Field (21) 'InactivityScores' - { - if size := len(b.InactivityScores); size > 1099511627776 { - err = ssz.ErrListTooBigFn("BeaconState.InactivityScores", size, 1099511627776) - return - } - subIndx := hh.Index() - for _, i := range b.InactivityScores { - hh.AppendUint64(i) - } - hh.FillUpTo32() - numItems := uint64(len(b.InactivityScores)) - hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(1099511627776, numItems, 8)) - } - - // Field (22) 'CurrentSyncCommittee' - if b.CurrentSyncCommittee == nil { - b.CurrentSyncCommittee = new(generic.SyncCommittee) - } - if err = b.CurrentSyncCommittee.HashTreeRootWith(hh); err != nil { - return - } - - // Field (23) 'NextSyncCommittee' - if b.NextSyncCommittee == nil { - b.NextSyncCommittee = new(generic.SyncCommittee) - } - if err = b.NextSyncCommittee.HashTreeRootWith(hh); err != nil { - return - } - - // Field (24) 'LatestExecutionPayloadHeader' - if err = b.LatestExecutionPayloadHeader.HashTreeRootWith(hh); err != nil { - return - } - - // Field (25) 'NextWithdrawalIndex' - hh.PutUint64(b.NextWithdrawalIndex) - - // Field (26) 'NextWithdrawalValidatorIndex' - hh.PutUint64(b.NextWithdrawalValidatorIndex) - - // Field (27) 'HistoricalSummaries' - { - subIndx := hh.Index() - num := uint64(len(b.HistoricalSummaries)) - if num > 16777216 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range b.HistoricalSummaries { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } - } - hh.MerkleizeWithMixin(subIndx, num, 16777216) - } - - // Field (28) 'DepositRequestsStartIndex' - hh.PutUint64(b.DepositRequestsStartIndex) - - // Field (29) 'DepositBalanceToConsume' - hh.PutUint64(b.DepositBalanceToConsume) - - // Field (30) 'ExitBalanceToConsume' - hh.PutUint64(b.ExitBalanceToConsume) - - // Field (31) 'EarliestExitEpoch' - hh.PutUint64(b.EarliestExitEpoch) - - // Field (32) 'ConsolidationBalanceToConsume' - hh.PutUint64(b.ConsolidationBalanceToConsume) - - // Field (33) 'EarliestConsolidationEpoch' - hh.PutUint64(b.EarliestConsolidationEpoch) - - // Field (34) 'PendingDeposits' - { - subIndx := hh.Index() - num := uint64(len(b.PendingDeposits)) - if num > 134217728 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range b.PendingDeposits { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } - } - hh.MerkleizeWithMixin(subIndx, num, 134217728) - } - - // Field (35) 'PendingPartialWithdrawals' - { - subIndx := hh.Index() - num := uint64(len(b.PendingPartialWithdrawals)) - if num > 134217728 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range b.PendingPartialWithdrawals { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } - } - hh.MerkleizeWithMixin(subIndx, num, 134217728) - } - - // Field (36) 'PendingConsolidations' - { - subIndx := hh.Index() - num := uint64(len(b.PendingConsolidations)) - if num > 262144 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range b.PendingConsolidations { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } - } - hh.MerkleizeWithMixin(subIndx, num, 262144) - } - - // Field (37) 'ProposerLookahead' - { - if size := len(b.ProposerLookahead); size != 64 { - err = ssz.ErrVectorLengthFn("BeaconState.ProposerLookahead", size, 64) - return - } - subIndx := hh.Index() - for _, i := range b.ProposerLookahead { - hh.AppendUint64(i) - } - hh.Merkleize(subIndx) - } - - hh.Merkleize(indx) - return -} - -// GetTree ssz hashes the BeaconState object -func (b *BeaconState) GetTree() (*ssz.Node, error) { - return ssz.ProofTree(b) -} diff --git a/shared/types/eth2/generic/block.go b/shared/types/eth2/generic/block.go index ff9b0a94e..4d763264a 100644 --- a/shared/types/eth2/generic/block.go +++ b/shared/types/eth2/generic/block.go @@ -37,7 +37,7 @@ type AttestationData struct { } type Attestation struct { - AggregationBits []byte `json:"aggregation_bits" ssz:"bitlist" ssz-max:"2048"` + AggregationBits []byte `json:"aggregation_bits" ssz:"bitlist" ssz-type:"bitlist" ssz-max:"2048"` Data *AttestationData `json:"data"` Signature [96]byte `json:"signature" ssz-size:"96"` } diff --git a/shared/types/eth2/generic/block_encoding.go b/shared/types/eth2/generic/block_encoding.go deleted file mode 100644 index 8f4f11319..000000000 --- a/shared/types/eth2/generic/block_encoding.go +++ /dev/null @@ -1,1584 +0,0 @@ -// Code generated by fastssz. DO NOT EDIT. -// Hash: 45dcf20c8163706ce0f2d8b0bde4b725e3eb6fcebbfc0b9cf9de80317ca8d032 -// Version: 0.1.3 -package generic - -import ( - ssz "github.com/ferranbt/fastssz" -) - -// MarshalSSZ ssz marshals the ProposerSlashing object -func (p *ProposerSlashing) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(p) -} - -// MarshalSSZTo ssz marshals the ProposerSlashing object to a target array -func (p *ProposerSlashing) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - - // Field (0) 'Header1' - if p.Header1 == nil { - p.Header1 = new(SignedBeaconBlockHeader) - } - if dst, err = p.Header1.MarshalSSZTo(dst); err != nil { - return - } - - // Field (1) 'Header2' - if p.Header2 == nil { - p.Header2 = new(SignedBeaconBlockHeader) - } - if dst, err = p.Header2.MarshalSSZTo(dst); err != nil { - return - } - - return -} - -// UnmarshalSSZ ssz unmarshals the ProposerSlashing object -func (p *ProposerSlashing) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size != 416 { - return ssz.ErrSize - } - - // Field (0) 'Header1' - if p.Header1 == nil { - p.Header1 = new(SignedBeaconBlockHeader) - } - if err = p.Header1.UnmarshalSSZ(buf[0:208]); err != nil { - return err - } - - // Field (1) 'Header2' - if p.Header2 == nil { - p.Header2 = new(SignedBeaconBlockHeader) - } - if err = p.Header2.UnmarshalSSZ(buf[208:416]); err != nil { - return err - } - - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the ProposerSlashing object -func (p *ProposerSlashing) SizeSSZ() (size int) { - size = 416 - return -} - -// HashTreeRoot ssz hashes the ProposerSlashing object -func (p *ProposerSlashing) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(p) -} - -// HashTreeRootWith ssz hashes the ProposerSlashing object with a hasher -func (p *ProposerSlashing) HashTreeRootWith(hh ssz.HashWalker) (err error) { - indx := hh.Index() - - // Field (0) 'Header1' - if p.Header1 == nil { - p.Header1 = new(SignedBeaconBlockHeader) - } - if err = p.Header1.HashTreeRootWith(hh); err != nil { - return - } - - // Field (1) 'Header2' - if p.Header2 == nil { - p.Header2 = new(SignedBeaconBlockHeader) - } - if err = p.Header2.HashTreeRootWith(hh); err != nil { - return - } - - hh.Merkleize(indx) - return -} - -// GetTree ssz hashes the ProposerSlashing object -func (p *ProposerSlashing) GetTree() (*ssz.Node, error) { - return ssz.ProofTree(p) -} - -// MarshalSSZ ssz marshals the SignedBeaconBlockHeader object -func (s *SignedBeaconBlockHeader) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) -} - -// MarshalSSZTo ssz marshals the SignedBeaconBlockHeader object to a target array -func (s *SignedBeaconBlockHeader) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - - // Field (0) 'Header' - if s.Header == nil { - s.Header = new(BeaconBlockHeader) - } - if dst, err = s.Header.MarshalSSZTo(dst); err != nil { - return - } - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("SignedBeaconBlockHeader.Signature", size, 96) - return - } - dst = append(dst, s.Signature...) - - return -} - -// UnmarshalSSZ ssz unmarshals the SignedBeaconBlockHeader object -func (s *SignedBeaconBlockHeader) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size != 208 { - return ssz.ErrSize - } - - // Field (0) 'Header' - if s.Header == nil { - s.Header = new(BeaconBlockHeader) - } - if err = s.Header.UnmarshalSSZ(buf[0:112]); err != nil { - return err - } - - // Field (1) 'Signature' - if cap(s.Signature) == 0 { - s.Signature = make([]byte, 0, len(buf[112:208])) - } - s.Signature = append(s.Signature, buf[112:208]...) - - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the SignedBeaconBlockHeader object -func (s *SignedBeaconBlockHeader) SizeSSZ() (size int) { - size = 208 - return -} - -// HashTreeRoot ssz hashes the SignedBeaconBlockHeader object -func (s *SignedBeaconBlockHeader) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) -} - -// HashTreeRootWith ssz hashes the SignedBeaconBlockHeader object with a hasher -func (s *SignedBeaconBlockHeader) HashTreeRootWith(hh ssz.HashWalker) (err error) { - indx := hh.Index() - - // Field (0) 'Header' - if s.Header == nil { - s.Header = new(BeaconBlockHeader) - } - if err = s.Header.HashTreeRootWith(hh); err != nil { - return - } - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("SignedBeaconBlockHeader.Signature", size, 96) - return - } - hh.PutBytes(s.Signature) - - hh.Merkleize(indx) - return -} - -// GetTree ssz hashes the SignedBeaconBlockHeader object -func (s *SignedBeaconBlockHeader) GetTree() (*ssz.Node, error) { - return ssz.ProofTree(s) -} - -// MarshalSSZ ssz marshals the AttesterSlashing object -func (a *AttesterSlashing) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(a) -} - -// MarshalSSZTo ssz marshals the AttesterSlashing object to a target array -func (a *AttesterSlashing) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(8) - - // Offset (0) 'Attestation1' - dst = ssz.WriteOffset(dst, offset) - if a.Attestation1 == nil { - a.Attestation1 = new(IndexedAttestation) - } - offset += a.Attestation1.SizeSSZ() - - // Offset (1) 'Attestation2' - dst = ssz.WriteOffset(dst, offset) - - // Field (0) 'Attestation1' - if dst, err = a.Attestation1.MarshalSSZTo(dst); err != nil { - return - } - - // Field (1) 'Attestation2' - if dst, err = a.Attestation2.MarshalSSZTo(dst); err != nil { - return - } - - return -} - -// UnmarshalSSZ ssz unmarshals the AttesterSlashing object -func (a *AttesterSlashing) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 8 { - return ssz.ErrSize - } - - tail := buf - var o0, o1 uint64 - - // Offset (0) 'Attestation1' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } - - if o0 != 8 { - return ssz.ErrInvalidVariableOffset - } - - // Offset (1) 'Attestation2' - if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 { - return ssz.ErrOffset - } - - // Field (0) 'Attestation1' - { - buf = tail[o0:o1] - if a.Attestation1 == nil { - a.Attestation1 = new(IndexedAttestation) - } - if err = a.Attestation1.UnmarshalSSZ(buf); err != nil { - return err - } - } - - // Field (1) 'Attestation2' - { - buf = tail[o1:] - if a.Attestation2 == nil { - a.Attestation2 = new(IndexedAttestation) - } - if err = a.Attestation2.UnmarshalSSZ(buf); err != nil { - return err - } - } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the AttesterSlashing object -func (a *AttesterSlashing) SizeSSZ() (size int) { - size = 8 - - // Field (0) 'Attestation1' - if a.Attestation1 == nil { - a.Attestation1 = new(IndexedAttestation) - } - size += a.Attestation1.SizeSSZ() - - // Field (1) 'Attestation2' - if a.Attestation2 == nil { - a.Attestation2 = new(IndexedAttestation) - } - size += a.Attestation2.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the AttesterSlashing object -func (a *AttesterSlashing) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(a) -} - -// HashTreeRootWith ssz hashes the AttesterSlashing object with a hasher -func (a *AttesterSlashing) HashTreeRootWith(hh ssz.HashWalker) (err error) { - indx := hh.Index() - - // Field (0) 'Attestation1' - if err = a.Attestation1.HashTreeRootWith(hh); err != nil { - return - } - - // Field (1) 'Attestation2' - if err = a.Attestation2.HashTreeRootWith(hh); err != nil { - return - } - - hh.Merkleize(indx) - return -} - -// GetTree ssz hashes the AttesterSlashing object -func (a *AttesterSlashing) GetTree() (*ssz.Node, error) { - return ssz.ProofTree(a) -} - -// MarshalSSZ ssz marshals the IndexedAttestation object -func (i *IndexedAttestation) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(i) -} - -// MarshalSSZTo ssz marshals the IndexedAttestation object to a target array -func (i *IndexedAttestation) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(228) - - // Offset (0) 'AttestationIndices' - dst = ssz.WriteOffset(dst, offset) - - // Field (1) 'Data' - if i.Data == nil { - i.Data = new(AttestationData) - } - if dst, err = i.Data.MarshalSSZTo(dst); err != nil { - return - } - - // Field (2) 'Signature' - if size := len(i.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("IndexedAttestation.Signature", size, 96) - return - } - dst = append(dst, i.Signature...) - - // Field (0) 'AttestationIndices' - if size := len(i.AttestationIndices); size > 2048 { - err = ssz.ErrListTooBigFn("IndexedAttestation.AttestationIndices", size, 2048) - return - } - for ii := 0; ii < len(i.AttestationIndices); ii++ { - dst = ssz.MarshalUint64(dst, i.AttestationIndices[ii]) - } - - return -} - -// UnmarshalSSZ ssz unmarshals the IndexedAttestation object -func (i *IndexedAttestation) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 228 { - return ssz.ErrSize - } - - tail := buf - var o0 uint64 - - // Offset (0) 'AttestationIndices' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } - - if o0 != 228 { - return ssz.ErrInvalidVariableOffset - } - - // Field (1) 'Data' - if i.Data == nil { - i.Data = new(AttestationData) - } - if err = i.Data.UnmarshalSSZ(buf[4:132]); err != nil { - return err - } - - // Field (2) 'Signature' - if cap(i.Signature) == 0 { - i.Signature = make([]byte, 0, len(buf[132:228])) - } - i.Signature = append(i.Signature, buf[132:228]...) - - // Field (0) 'AttestationIndices' - { - buf = tail[o0:] - num, err := ssz.DivideInt2(len(buf), 8, 2048) - if err != nil { - return err - } - i.AttestationIndices = ssz.ExtendUint64(i.AttestationIndices, num) - for ii := 0; ii < num; ii++ { - i.AttestationIndices[ii] = ssz.UnmarshallUint64(buf[ii*8 : (ii+1)*8]) - } - } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the IndexedAttestation object -func (i *IndexedAttestation) SizeSSZ() (size int) { - size = 228 - - // Field (0) 'AttestationIndices' - size += len(i.AttestationIndices) * 8 - - return -} - -// HashTreeRoot ssz hashes the IndexedAttestation object -func (i *IndexedAttestation) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(i) -} - -// HashTreeRootWith ssz hashes the IndexedAttestation object with a hasher -func (i *IndexedAttestation) HashTreeRootWith(hh ssz.HashWalker) (err error) { - indx := hh.Index() - - // Field (0) 'AttestationIndices' - { - if size := len(i.AttestationIndices); size > 2048 { - err = ssz.ErrListTooBigFn("IndexedAttestation.AttestationIndices", size, 2048) - return - } - subIndx := hh.Index() - for _, i := range i.AttestationIndices { - hh.AppendUint64(i) - } - hh.FillUpTo32() - numItems := uint64(len(i.AttestationIndices)) - hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(2048, numItems, 8)) - } - - // Field (1) 'Data' - if i.Data == nil { - i.Data = new(AttestationData) - } - if err = i.Data.HashTreeRootWith(hh); err != nil { - return - } - - // Field (2) 'Signature' - if size := len(i.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("IndexedAttestation.Signature", size, 96) - return - } - hh.PutBytes(i.Signature) - - hh.Merkleize(indx) - return -} - -// GetTree ssz hashes the IndexedAttestation object -func (i *IndexedAttestation) GetTree() (*ssz.Node, error) { - return ssz.ProofTree(i) -} - -// MarshalSSZ ssz marshals the AttestationData object -func (a *AttestationData) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(a) -} - -// MarshalSSZTo ssz marshals the AttestationData object to a target array -func (a *AttestationData) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - - // Field (0) 'Slot' - dst = ssz.MarshalUint64(dst, a.Slot) - - // Field (1) 'Index' - dst = ssz.MarshalUint64(dst, a.Index) - - // Field (2) 'BeaconBlockHash' - dst = append(dst, a.BeaconBlockHash[:]...) - - // Field (3) 'Source' - if a.Source == nil { - a.Source = new(Checkpoint) - } - if dst, err = a.Source.MarshalSSZTo(dst); err != nil { - return - } - - // Field (4) 'Target' - if a.Target == nil { - a.Target = new(Checkpoint) - } - if dst, err = a.Target.MarshalSSZTo(dst); err != nil { - return - } - - return -} - -// UnmarshalSSZ ssz unmarshals the AttestationData object -func (a *AttestationData) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size != 128 { - return ssz.ErrSize - } - - // Field (0) 'Slot' - a.Slot = ssz.UnmarshallUint64(buf[0:8]) - - // Field (1) 'Index' - a.Index = ssz.UnmarshallUint64(buf[8:16]) - - // Field (2) 'BeaconBlockHash' - copy(a.BeaconBlockHash[:], buf[16:48]) - - // Field (3) 'Source' - if a.Source == nil { - a.Source = new(Checkpoint) - } - if err = a.Source.UnmarshalSSZ(buf[48:88]); err != nil { - return err - } - - // Field (4) 'Target' - if a.Target == nil { - a.Target = new(Checkpoint) - } - if err = a.Target.UnmarshalSSZ(buf[88:128]); err != nil { - return err - } - - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the AttestationData object -func (a *AttestationData) SizeSSZ() (size int) { - size = 128 - return -} - -// HashTreeRoot ssz hashes the AttestationData object -func (a *AttestationData) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(a) -} - -// HashTreeRootWith ssz hashes the AttestationData object with a hasher -func (a *AttestationData) HashTreeRootWith(hh ssz.HashWalker) (err error) { - indx := hh.Index() - - // Field (0) 'Slot' - hh.PutUint64(a.Slot) - - // Field (1) 'Index' - hh.PutUint64(a.Index) - - // Field (2) 'BeaconBlockHash' - hh.PutBytes(a.BeaconBlockHash[:]) - - // Field (3) 'Source' - if a.Source == nil { - a.Source = new(Checkpoint) - } - if err = a.Source.HashTreeRootWith(hh); err != nil { - return - } - - // Field (4) 'Target' - if a.Target == nil { - a.Target = new(Checkpoint) - } - if err = a.Target.HashTreeRootWith(hh); err != nil { - return - } - - hh.Merkleize(indx) - return -} - -// GetTree ssz hashes the AttestationData object -func (a *AttestationData) GetTree() (*ssz.Node, error) { - return ssz.ProofTree(a) -} - -// MarshalSSZ ssz marshals the Attestation object -func (a *Attestation) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(a) -} - -// MarshalSSZTo ssz marshals the Attestation object to a target array -func (a *Attestation) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(228) - - // Offset (0) 'AggregationBits' - dst = ssz.WriteOffset(dst, offset) - - // Field (1) 'Data' - if a.Data == nil { - a.Data = new(AttestationData) - } - if dst, err = a.Data.MarshalSSZTo(dst); err != nil { - return - } - - // Field (2) 'Signature' - dst = append(dst, a.Signature[:]...) - - // Field (0) 'AggregationBits' - if size := len(a.AggregationBits); size > 2048 { - err = ssz.ErrBytesLengthFn("Attestation.AggregationBits", size, 2048) - return - } - dst = append(dst, a.AggregationBits...) - - return -} - -// UnmarshalSSZ ssz unmarshals the Attestation object -func (a *Attestation) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 228 { - return ssz.ErrSize - } - - tail := buf - var o0 uint64 - - // Offset (0) 'AggregationBits' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } - - if o0 != 228 { - return ssz.ErrInvalidVariableOffset - } - - // Field (1) 'Data' - if a.Data == nil { - a.Data = new(AttestationData) - } - if err = a.Data.UnmarshalSSZ(buf[4:132]); err != nil { - return err - } - - // Field (2) 'Signature' - copy(a.Signature[:], buf[132:228]) - - // Field (0) 'AggregationBits' - { - buf = tail[o0:] - if err = ssz.ValidateBitlist(buf, 2048); err != nil { - return err - } - if cap(a.AggregationBits) == 0 { - a.AggregationBits = make([]byte, 0, len(buf)) - } - a.AggregationBits = append(a.AggregationBits, buf...) - } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the Attestation object -func (a *Attestation) SizeSSZ() (size int) { - size = 228 - - // Field (0) 'AggregationBits' - size += len(a.AggregationBits) - - return -} - -// HashTreeRoot ssz hashes the Attestation object -func (a *Attestation) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(a) -} - -// HashTreeRootWith ssz hashes the Attestation object with a hasher -func (a *Attestation) HashTreeRootWith(hh ssz.HashWalker) (err error) { - indx := hh.Index() - - // Field (0) 'AggregationBits' - if len(a.AggregationBits) == 0 { - err = ssz.ErrEmptyBitlist - return - } - hh.PutBitlist(a.AggregationBits, 2048) - - // Field (1) 'Data' - if a.Data == nil { - a.Data = new(AttestationData) - } - if err = a.Data.HashTreeRootWith(hh); err != nil { - return - } - - // Field (2) 'Signature' - hh.PutBytes(a.Signature[:]) - - hh.Merkleize(indx) - return -} - -// GetTree ssz hashes the Attestation object -func (a *Attestation) GetTree() (*ssz.Node, error) { - return ssz.ProofTree(a) -} - -// MarshalSSZ ssz marshals the Deposit object -func (d *Deposit) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(d) -} - -// MarshalSSZTo ssz marshals the Deposit object to a target array -func (d *Deposit) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - - // Field (0) 'Proof' - if size := len(d.Proof); size != 33 { - err = ssz.ErrVectorLengthFn("Deposit.Proof", size, 33) - return - } - for ii := 0; ii < 33; ii++ { - if size := len(d.Proof[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("Deposit.Proof[ii]", size, 32) - return - } - dst = append(dst, d.Proof[ii]...) - } - - // Field (1) 'Data' - if d.Data == nil { - d.Data = new(DepositData) - } - if dst, err = d.Data.MarshalSSZTo(dst); err != nil { - return - } - - return -} - -// UnmarshalSSZ ssz unmarshals the Deposit object -func (d *Deposit) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size != 1240 { - return ssz.ErrSize - } - - // Field (0) 'Proof' - d.Proof = make([][]byte, 33) - for ii := 0; ii < 33; ii++ { - if cap(d.Proof[ii]) == 0 { - d.Proof[ii] = make([]byte, 0, len(buf[0:1056][ii*32:(ii+1)*32])) - } - d.Proof[ii] = append(d.Proof[ii], buf[0:1056][ii*32:(ii+1)*32]...) - } - - // Field (1) 'Data' - if d.Data == nil { - d.Data = new(DepositData) - } - if err = d.Data.UnmarshalSSZ(buf[1056:1240]); err != nil { - return err - } - - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the Deposit object -func (d *Deposit) SizeSSZ() (size int) { - size = 1240 - return -} - -// HashTreeRoot ssz hashes the Deposit object -func (d *Deposit) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(d) -} - -// HashTreeRootWith ssz hashes the Deposit object with a hasher -func (d *Deposit) HashTreeRootWith(hh ssz.HashWalker) (err error) { - indx := hh.Index() - - // Field (0) 'Proof' - { - if size := len(d.Proof); size != 33 { - err = ssz.ErrVectorLengthFn("Deposit.Proof", size, 33) - return - } - subIndx := hh.Index() - for _, i := range d.Proof { - if len(i) != 32 { - err = ssz.ErrBytesLength - return - } - hh.Append(i) - } - hh.Merkleize(subIndx) - } - - // Field (1) 'Data' - if d.Data == nil { - d.Data = new(DepositData) - } - if err = d.Data.HashTreeRootWith(hh); err != nil { - return - } - - hh.Merkleize(indx) - return -} - -// GetTree ssz hashes the Deposit object -func (d *Deposit) GetTree() (*ssz.Node, error) { - return ssz.ProofTree(d) -} - -// MarshalSSZ ssz marshals the SignedVoluntaryExit object -func (s *SignedVoluntaryExit) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) -} - -// MarshalSSZTo ssz marshals the SignedVoluntaryExit object to a target array -func (s *SignedVoluntaryExit) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - - // Field (0) 'Exit' - if s.Exit == nil { - s.Exit = new(VoluntaryExit) - } - if dst, err = s.Exit.MarshalSSZTo(dst); err != nil { - return - } - - // Field (1) 'Signature' - dst = append(dst, s.Signature[:]...) - - return -} - -// UnmarshalSSZ ssz unmarshals the SignedVoluntaryExit object -func (s *SignedVoluntaryExit) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size != 112 { - return ssz.ErrSize - } - - // Field (0) 'Exit' - if s.Exit == nil { - s.Exit = new(VoluntaryExit) - } - if err = s.Exit.UnmarshalSSZ(buf[0:16]); err != nil { - return err - } - - // Field (1) 'Signature' - copy(s.Signature[:], buf[16:112]) - - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the SignedVoluntaryExit object -func (s *SignedVoluntaryExit) SizeSSZ() (size int) { - size = 112 - return -} - -// HashTreeRoot ssz hashes the SignedVoluntaryExit object -func (s *SignedVoluntaryExit) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) -} - -// HashTreeRootWith ssz hashes the SignedVoluntaryExit object with a hasher -func (s *SignedVoluntaryExit) HashTreeRootWith(hh ssz.HashWalker) (err error) { - indx := hh.Index() - - // Field (0) 'Exit' - if s.Exit == nil { - s.Exit = new(VoluntaryExit) - } - if err = s.Exit.HashTreeRootWith(hh); err != nil { - return - } - - // Field (1) 'Signature' - hh.PutBytes(s.Signature[:]) - - hh.Merkleize(indx) - return -} - -// GetTree ssz hashes the SignedVoluntaryExit object -func (s *SignedVoluntaryExit) GetTree() (*ssz.Node, error) { - return ssz.ProofTree(s) -} - -// MarshalSSZ ssz marshals the SyncAggregate object -func (s *SyncAggregate) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) -} - -// MarshalSSZTo ssz marshals the SyncAggregate object to a target array -func (s *SyncAggregate) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - - // Field (0) 'SyncCommiteeBits' - if size := len(s.SyncCommiteeBits); size != 64 { - err = ssz.ErrBytesLengthFn("SyncAggregate.SyncCommiteeBits", size, 64) - return - } - dst = append(dst, s.SyncCommiteeBits...) - - // Field (1) 'SyncCommiteeSignature' - dst = append(dst, s.SyncCommiteeSignature[:]...) - - return -} - -// UnmarshalSSZ ssz unmarshals the SyncAggregate object -func (s *SyncAggregate) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size != 160 { - return ssz.ErrSize - } - - // Field (0) 'SyncCommiteeBits' - if cap(s.SyncCommiteeBits) == 0 { - s.SyncCommiteeBits = make([]byte, 0, len(buf[0:64])) - } - s.SyncCommiteeBits = append(s.SyncCommiteeBits, buf[0:64]...) - - // Field (1) 'SyncCommiteeSignature' - copy(s.SyncCommiteeSignature[:], buf[64:160]) - - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the SyncAggregate object -func (s *SyncAggregate) SizeSSZ() (size int) { - size = 160 - return -} - -// HashTreeRoot ssz hashes the SyncAggregate object -func (s *SyncAggregate) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) -} - -// HashTreeRootWith ssz hashes the SyncAggregate object with a hasher -func (s *SyncAggregate) HashTreeRootWith(hh ssz.HashWalker) (err error) { - indx := hh.Index() - - // Field (0) 'SyncCommiteeBits' - if size := len(s.SyncCommiteeBits); size != 64 { - err = ssz.ErrBytesLengthFn("SyncAggregate.SyncCommiteeBits", size, 64) - return - } - hh.PutBytes(s.SyncCommiteeBits) - - // Field (1) 'SyncCommiteeSignature' - hh.PutBytes(s.SyncCommiteeSignature[:]) - - hh.Merkleize(indx) - return -} - -// GetTree ssz hashes the SyncAggregate object -func (s *SyncAggregate) GetTree() (*ssz.Node, error) { - return ssz.ProofTree(s) -} - -// MarshalSSZ ssz marshals the ExecutionPayload object -func (e *ExecutionPayload) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(e) -} - -// MarshalSSZTo ssz marshals the ExecutionPayload object to a target array -func (e *ExecutionPayload) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(528) - - // Field (0) 'ParentHash' - dst = append(dst, e.ParentHash[:]...) - - // Field (1) 'FeeRecipient' - dst = append(dst, e.FeeRecipient[:]...) - - // Field (2) 'StateRoot' - dst = append(dst, e.StateRoot[:]...) - - // Field (3) 'ReceiptsRoot' - dst = append(dst, e.ReceiptsRoot[:]...) - - // Field (4) 'LogsBloom' - dst = append(dst, e.LogsBloom[:]...) - - // Field (5) 'PrevRandao' - dst = append(dst, e.PrevRandao[:]...) - - // Field (6) 'BlockNumber' - dst = ssz.MarshalUint64(dst, e.BlockNumber) - - // Field (7) 'GasLimit' - dst = ssz.MarshalUint64(dst, e.GasLimit) - - // Field (8) 'GasUsed' - dst = ssz.MarshalUint64(dst, e.GasUsed) - - // Field (9) 'Timestamp' - dst = ssz.MarshalUint64(dst, e.Timestamp) - - // Offset (10) 'ExtraData' - dst = ssz.WriteOffset(dst, offset) - offset += len(e.ExtraData) - - // Field (11) 'BaseFeePerGas' - dst = append(dst, e.BaseFeePerGas[:]...) - - // Field (12) 'BlockHash' - dst = append(dst, e.BlockHash[:]...) - - // Offset (13) 'Transactions' - dst = ssz.WriteOffset(dst, offset) - for ii := 0; ii < len(e.Transactions); ii++ { - offset += 4 - offset += len(e.Transactions[ii]) - } - - // Offset (14) 'Withdrawals' - dst = ssz.WriteOffset(dst, offset) - - // Field (15) 'BlobGasUsed' - dst = ssz.MarshalUint64(dst, e.BlobGasUsed) - - // Field (16) 'ExcessBlobGas' - dst = ssz.MarshalUint64(dst, e.ExcessBlobGas) - - // Field (10) 'ExtraData' - if size := len(e.ExtraData); size > 32 { - err = ssz.ErrBytesLengthFn("ExecutionPayload.ExtraData", size, 32) - return - } - dst = append(dst, e.ExtraData...) - - // Field (13) 'Transactions' - if size := len(e.Transactions); size > 1048576 { - err = ssz.ErrListTooBigFn("ExecutionPayload.Transactions", size, 1048576) - return - } - { - offset = 4 * len(e.Transactions) - for ii := 0; ii < len(e.Transactions); ii++ { - dst = ssz.WriteOffset(dst, offset) - offset += len(e.Transactions[ii]) - } - } - for ii := 0; ii < len(e.Transactions); ii++ { - if size := len(e.Transactions[ii]); size > 1073741824 { - err = ssz.ErrBytesLengthFn("ExecutionPayload.Transactions[ii]", size, 1073741824) - return - } - dst = append(dst, e.Transactions[ii]...) - } - - // Field (14) 'Withdrawals' - if size := len(e.Withdrawals); size > 16 { - err = ssz.ErrListTooBigFn("ExecutionPayload.Withdrawals", size, 16) - return - } - for ii := 0; ii < len(e.Withdrawals); ii++ { - if dst, err = e.Withdrawals[ii].MarshalSSZTo(dst); err != nil { - return - } - } - - return -} - -// UnmarshalSSZ ssz unmarshals the ExecutionPayload object -func (e *ExecutionPayload) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 528 { - return ssz.ErrSize - } - - tail := buf - var o10, o13, o14 uint64 - - // Field (0) 'ParentHash' - copy(e.ParentHash[:], buf[0:32]) - - // Field (1) 'FeeRecipient' - copy(e.FeeRecipient[:], buf[32:52]) - - // Field (2) 'StateRoot' - copy(e.StateRoot[:], buf[52:84]) - - // Field (3) 'ReceiptsRoot' - copy(e.ReceiptsRoot[:], buf[84:116]) - - // Field (4) 'LogsBloom' - copy(e.LogsBloom[:], buf[116:372]) - - // Field (5) 'PrevRandao' - copy(e.PrevRandao[:], buf[372:404]) - - // Field (6) 'BlockNumber' - e.BlockNumber = ssz.UnmarshallUint64(buf[404:412]) - - // Field (7) 'GasLimit' - e.GasLimit = ssz.UnmarshallUint64(buf[412:420]) - - // Field (8) 'GasUsed' - e.GasUsed = ssz.UnmarshallUint64(buf[420:428]) - - // Field (9) 'Timestamp' - e.Timestamp = ssz.UnmarshallUint64(buf[428:436]) - - // Offset (10) 'ExtraData' - if o10 = ssz.ReadOffset(buf[436:440]); o10 > size { - return ssz.ErrOffset - } - - if o10 != 528 { - return ssz.ErrInvalidVariableOffset - } - - // Field (11) 'BaseFeePerGas' - copy(e.BaseFeePerGas[:], buf[440:472]) - - // Field (12) 'BlockHash' - copy(e.BlockHash[:], buf[472:504]) - - // Offset (13) 'Transactions' - if o13 = ssz.ReadOffset(buf[504:508]); o13 > size || o10 > o13 { - return ssz.ErrOffset - } - - // Offset (14) 'Withdrawals' - if o14 = ssz.ReadOffset(buf[508:512]); o14 > size || o13 > o14 { - return ssz.ErrOffset - } - - // Field (15) 'BlobGasUsed' - e.BlobGasUsed = ssz.UnmarshallUint64(buf[512:520]) - - // Field (16) 'ExcessBlobGas' - e.ExcessBlobGas = ssz.UnmarshallUint64(buf[520:528]) - - // Field (10) 'ExtraData' - { - buf = tail[o10:o13] - if len(buf) > 32 { - return ssz.ErrBytesLength - } - if cap(e.ExtraData) == 0 { - e.ExtraData = make([]byte, 0, len(buf)) - } - e.ExtraData = append(e.ExtraData, buf...) - } - - // Field (13) 'Transactions' - { - buf = tail[o13:o14] - num, err := ssz.DecodeDynamicLength(buf, 1048576) - if err != nil { - return err - } - e.Transactions = make([][]byte, num) - err = ssz.UnmarshalDynamic(buf, num, func(indx int, buf []byte) (err error) { - if len(buf) > 1073741824 { - return ssz.ErrBytesLength - } - if cap(e.Transactions[indx]) == 0 { - e.Transactions[indx] = make([]byte, 0, len(buf)) - } - e.Transactions[indx] = append(e.Transactions[indx], buf...) - return nil - }) - if err != nil { - return err - } - } - - // Field (14) 'Withdrawals' - { - buf = tail[o14:] - num, err := ssz.DivideInt2(len(buf), 44, 16) - if err != nil { - return err - } - e.Withdrawals = make([]*Withdrawal, num) - for ii := 0; ii < num; ii++ { - if e.Withdrawals[ii] == nil { - e.Withdrawals[ii] = new(Withdrawal) - } - if err = e.Withdrawals[ii].UnmarshalSSZ(buf[ii*44 : (ii+1)*44]); err != nil { - return err - } - } - } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the ExecutionPayload object -func (e *ExecutionPayload) SizeSSZ() (size int) { - size = 528 - - // Field (10) 'ExtraData' - size += len(e.ExtraData) - - // Field (13) 'Transactions' - for ii := 0; ii < len(e.Transactions); ii++ { - size += 4 - size += len(e.Transactions[ii]) - } - - // Field (14) 'Withdrawals' - size += len(e.Withdrawals) * 44 - - return -} - -// HashTreeRoot ssz hashes the ExecutionPayload object -func (e *ExecutionPayload) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(e) -} - -// HashTreeRootWith ssz hashes the ExecutionPayload object with a hasher -func (e *ExecutionPayload) HashTreeRootWith(hh ssz.HashWalker) (err error) { - indx := hh.Index() - - // Field (0) 'ParentHash' - hh.PutBytes(e.ParentHash[:]) - - // Field (1) 'FeeRecipient' - hh.PutBytes(e.FeeRecipient[:]) - - // Field (2) 'StateRoot' - hh.PutBytes(e.StateRoot[:]) - - // Field (3) 'ReceiptsRoot' - hh.PutBytes(e.ReceiptsRoot[:]) - - // Field (4) 'LogsBloom' - hh.PutBytes(e.LogsBloom[:]) - - // Field (5) 'PrevRandao' - hh.PutBytes(e.PrevRandao[:]) - - // Field (6) 'BlockNumber' - hh.PutUint64(e.BlockNumber) - - // Field (7) 'GasLimit' - hh.PutUint64(e.GasLimit) - - // Field (8) 'GasUsed' - hh.PutUint64(e.GasUsed) - - // Field (9) 'Timestamp' - hh.PutUint64(e.Timestamp) - - // Field (10) 'ExtraData' - { - elemIndx := hh.Index() - byteLen := uint64(len(e.ExtraData)) - if byteLen > 32 { - err = ssz.ErrIncorrectListSize - return - } - hh.Append(e.ExtraData) - hh.MerkleizeWithMixin(elemIndx, byteLen, (32+31)/32) - } - - // Field (11) 'BaseFeePerGas' - hh.PutBytes(e.BaseFeePerGas[:]) - - // Field (12) 'BlockHash' - hh.PutBytes(e.BlockHash[:]) - - // Field (13) 'Transactions' - { - subIndx := hh.Index() - num := uint64(len(e.Transactions)) - if num > 1048576 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range e.Transactions { - { - elemIndx := hh.Index() - byteLen := uint64(len(elem)) - if byteLen > 1073741824 { - err = ssz.ErrIncorrectListSize - return - } - hh.AppendBytes32(elem) - hh.MerkleizeWithMixin(elemIndx, byteLen, (1073741824+31)/32) - } - } - hh.MerkleizeWithMixin(subIndx, num, 1048576) - } - - // Field (14) 'Withdrawals' - { - subIndx := hh.Index() - num := uint64(len(e.Withdrawals)) - if num > 16 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range e.Withdrawals { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } - } - hh.MerkleizeWithMixin(subIndx, num, 16) - } - - // Field (15) 'BlobGasUsed' - hh.PutUint64(e.BlobGasUsed) - - // Field (16) 'ExcessBlobGas' - hh.PutUint64(e.ExcessBlobGas) - - hh.Merkleize(indx) - return -} - -// GetTree ssz hashes the ExecutionPayload object -func (e *ExecutionPayload) GetTree() (*ssz.Node, error) { - return ssz.ProofTree(e) -} - -// MarshalSSZ ssz marshals the Withdrawal object -func (w *Withdrawal) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(w) -} - -// MarshalSSZTo ssz marshals the Withdrawal object to a target array -func (w *Withdrawal) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - - // Field (0) 'Index' - dst = ssz.MarshalUint64(dst, w.Index) - - // Field (1) 'ValidatorIndex' - dst = ssz.MarshalUint64(dst, w.ValidatorIndex) - - // Field (2) 'Address' - dst = append(dst, w.Address[:]...) - - // Field (3) 'Amount' - dst = ssz.MarshalUint64(dst, w.Amount) - - return -} - -// UnmarshalSSZ ssz unmarshals the Withdrawal object -func (w *Withdrawal) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size != 44 { - return ssz.ErrSize - } - - // Field (0) 'Index' - w.Index = ssz.UnmarshallUint64(buf[0:8]) - - // Field (1) 'ValidatorIndex' - w.ValidatorIndex = ssz.UnmarshallUint64(buf[8:16]) - - // Field (2) 'Address' - copy(w.Address[:], buf[16:36]) - - // Field (3) 'Amount' - w.Amount = ssz.UnmarshallUint64(buf[36:44]) - - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the Withdrawal object -func (w *Withdrawal) SizeSSZ() (size int) { - size = 44 - return -} - -// HashTreeRoot ssz hashes the Withdrawal object -func (w *Withdrawal) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(w) -} - -// HashTreeRootWith ssz hashes the Withdrawal object with a hasher -func (w *Withdrawal) HashTreeRootWith(hh ssz.HashWalker) (err error) { - indx := hh.Index() - - // Field (0) 'Index' - hh.PutUint64(w.Index) - - // Field (1) 'ValidatorIndex' - hh.PutUint64(w.ValidatorIndex) - - // Field (2) 'Address' - hh.PutBytes(w.Address[:]) - - // Field (3) 'Amount' - hh.PutUint64(w.Amount) - - hh.Merkleize(indx) - return -} - -// GetTree ssz hashes the Withdrawal object -func (w *Withdrawal) GetTree() (*ssz.Node, error) { - return ssz.ProofTree(w) -} - -// MarshalSSZ ssz marshals the BLSToExecutionChange object -func (b *BLSToExecutionChange) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} - -// MarshalSSZTo ssz marshals the BLSToExecutionChange object to a target array -func (b *BLSToExecutionChange) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - - // Field (0) 'ValidatorIndex' - dst = ssz.MarshalUint64(dst, b.ValidatorIndex) - - // Field (1) 'FromBLSPubKey' - dst = append(dst, b.FromBLSPubKey[:]...) - - // Field (2) 'ToExecutionAddress' - dst = append(dst, b.ToExecutionAddress[:]...) - - return -} - -// UnmarshalSSZ ssz unmarshals the BLSToExecutionChange object -func (b *BLSToExecutionChange) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size != 76 { - return ssz.ErrSize - } - - // Field (0) 'ValidatorIndex' - b.ValidatorIndex = ssz.UnmarshallUint64(buf[0:8]) - - // Field (1) 'FromBLSPubKey' - copy(b.FromBLSPubKey[:], buf[8:56]) - - // Field (2) 'ToExecutionAddress' - copy(b.ToExecutionAddress[:], buf[56:76]) - - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the BLSToExecutionChange object -func (b *BLSToExecutionChange) SizeSSZ() (size int) { - size = 76 - return -} - -// HashTreeRoot ssz hashes the BLSToExecutionChange object -func (b *BLSToExecutionChange) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) -} - -// HashTreeRootWith ssz hashes the BLSToExecutionChange object with a hasher -func (b *BLSToExecutionChange) HashTreeRootWith(hh ssz.HashWalker) (err error) { - indx := hh.Index() - - // Field (0) 'ValidatorIndex' - hh.PutUint64(b.ValidatorIndex) - - // Field (1) 'FromBLSPubKey' - hh.PutBytes(b.FromBLSPubKey[:]) - - // Field (2) 'ToExecutionAddress' - hh.PutBytes(b.ToExecutionAddress[:]) - - hh.Merkleize(indx) - return -} - -// GetTree ssz hashes the BLSToExecutionChange object -func (b *BLSToExecutionChange) GetTree() (*ssz.Node, error) { - return ssz.ProofTree(b) -} - -// MarshalSSZ ssz marshals the SignedBLSToExecutionChange object -func (s *SignedBLSToExecutionChange) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) -} - -// MarshalSSZTo ssz marshals the SignedBLSToExecutionChange object to a target array -func (s *SignedBLSToExecutionChange) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - - // Field (0) 'Message' - if s.Message == nil { - s.Message = new(BLSToExecutionChange) - } - if dst, err = s.Message.MarshalSSZTo(dst); err != nil { - return - } - - // Field (1) 'Signature' - dst = append(dst, s.Signature[:]...) - - return -} - -// UnmarshalSSZ ssz unmarshals the SignedBLSToExecutionChange object -func (s *SignedBLSToExecutionChange) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size != 172 { - return ssz.ErrSize - } - - // Field (0) 'Message' - if s.Message == nil { - s.Message = new(BLSToExecutionChange) - } - if err = s.Message.UnmarshalSSZ(buf[0:76]); err != nil { - return err - } - - // Field (1) 'Signature' - copy(s.Signature[:], buf[76:172]) - - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the SignedBLSToExecutionChange object -func (s *SignedBLSToExecutionChange) SizeSSZ() (size int) { - size = 172 - return -} - -// HashTreeRoot ssz hashes the SignedBLSToExecutionChange object -func (s *SignedBLSToExecutionChange) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) -} - -// HashTreeRootWith ssz hashes the SignedBLSToExecutionChange object with a hasher -func (s *SignedBLSToExecutionChange) HashTreeRootWith(hh ssz.HashWalker) (err error) { - indx := hh.Index() - - // Field (0) 'Message' - if s.Message == nil { - s.Message = new(BLSToExecutionChange) - } - if err = s.Message.HashTreeRootWith(hh); err != nil { - return - } - - // Field (1) 'Signature' - hh.PutBytes(s.Signature[:]) - - hh.Merkleize(indx) - return -} - -// GetTree ssz hashes the SignedBLSToExecutionChange object -func (s *SignedBLSToExecutionChange) GetTree() (*ssz.Node, error) { - return ssz.ProofTree(s) -} diff --git a/shared/types/eth2/generic/dynssz.go b/shared/types/eth2/generic/dynssz.go new file mode 100644 index 000000000..46f40ae16 --- /dev/null +++ b/shared/types/eth2/generic/dynssz.go @@ -0,0 +1,13 @@ +package generic + +import ( + dynssz "github.com/pk910/dynamic-ssz" +) + +// SSZ is the process-wide dynamic-ssz instance used for all beacon state and +// block encoding, hashing and merkle tree operations. The mainnet preset is +// baked into the static ssz-size/ssz-max struct tags, so no spec overrides are +// needed. Type descriptors are cached per instance — always use this singleton. +// The stream reader buffer is sized for beacon state downloads (~310 MB on +// mainnet); the 2 KB default would make far too many small reads. +var SSZ = dynssz.NewDynSsz(nil, dynssz.WithStreamReaderBufferSize(1<<20)) diff --git a/shared/types/eth2/generic/generic_generated.go b/shared/types/eth2/generic/generic_generated.go new file mode 100644 index 000000000..c09f4e8bd --- /dev/null +++ b/shared/types/eth2/generic/generic_generated.go @@ -0,0 +1,6790 @@ +// Code generated by dynamic-ssz. DO NOT EDIT. +// Hash: 21a3f903b868b8ed1b95750151fee1261581fa09d2f4cf79f63817c3cb23fe1f +// Version: v1.3.2 (https://github.com/pk910/dynamic-ssz) +package generic + +import ( + "encoding/binary" + "math/bits" + + "github.com/pk910/dynamic-ssz/hasher" + "github.com/pk910/dynamic-ssz/sszutils" +) + +var _ = sszutils.ErrListTooBig + +var _ = sszutils.Annotate[Fork](`ssz-static:"true"`) +var _ = sszutils.Annotate[BeaconBlockHeader](`ssz-static:"true"`) +var _ = sszutils.Annotate[Eth1Data](`ssz-static:"true"`) +var _ = sszutils.Annotate[Validator](`ssz-static:"true"`) +var _ = sszutils.Annotate[Checkpoint](`ssz-static:"true"`) +var _ = sszutils.Annotate[SyncCommittee](`ssz-static:"true"`) +var _ = sszutils.Annotate[HistoricalSummary](`ssz-static:"true"`) +var _ = sszutils.Annotate[HistoricalSummaryLists](`ssz-static:"true"`) +var _ = sszutils.Annotate[ExecutionPayloadHeader](`ssz-static:"false"`) +var _ = sszutils.Annotate[PendingDeposit](`ssz-static:"true"`) +var _ = sszutils.Annotate[PendingPartialWithdrawal](`ssz-static:"true"`) +var _ = sszutils.Annotate[PendingConsolidation](`ssz-static:"true"`) +var _ = sszutils.Annotate[ProposerSlashing](`ssz-static:"true"`) +var _ = sszutils.Annotate[SignedBeaconBlockHeader](`ssz-static:"true"`) +var _ = sszutils.Annotate[AttesterSlashing](`ssz-static:"false"`) +var _ = sszutils.Annotate[IndexedAttestation](`ssz-static:"false"`) +var _ = sszutils.Annotate[AttestationData](`ssz-static:"true"`) +var _ = sszutils.Annotate[Attestation](`ssz-static:"false"`) +var _ = sszutils.Annotate[Deposit](`ssz-static:"true"`) +var _ = sszutils.Annotate[SignedVoluntaryExit](`ssz-static:"true"`) +var _ = sszutils.Annotate[SyncAggregate](`ssz-static:"true"`) +var _ = sszutils.Annotate[ExecutionPayload](`ssz-static:"false"`) +var _ = sszutils.Annotate[Withdrawal](`ssz-static:"true"`) +var _ = sszutils.Annotate[BLSToExecutionChange](`ssz-static:"true"`) +var _ = sszutils.Annotate[SignedBLSToExecutionChange](`ssz-static:"true"`) +var _ = sszutils.Annotate[DepositDataNoSignature](`ssz-static:"true"`) +var _ = sszutils.Annotate[DepositData](`ssz-static:"true"`) +var _ = sszutils.Annotate[SigningRoot](`ssz-static:"true"`) +var _ = sszutils.Annotate[VoluntaryExit](`ssz-static:"true"`) +var _ = sszutils.Annotate[WithdrawalCredentialsChange](`ssz-static:"true"`) +var _ = sszutils.Annotate[Uint256](`ssz-static:"true"`) + +// MarshalSSZTo marshals the *Fork to SSZ-encoded bytes, appending to the provided buffer. +func (t *Fork) MarshalSSZTo(buf []byte) (dst []byte, err error) { + dst = buf + if t == nil { + t = new(Fork) + } + { // Static Field #0 'PreviousVersion' + vlen := len(t.PreviousVersion) + if vlen > 4 { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 4), "PreviousVersion") + } + dst = append(dst, t.PreviousVersion[:vlen]...) + if vlen < 4 { + dst = sszutils.AppendZeroPadding(dst, (4-vlen)*1) + } + } + { // Static Field #1 'CurrentVersion' + vlen := len(t.CurrentVersion) + if vlen > 4 { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 4), "CurrentVersion") + } + dst = append(dst, t.CurrentVersion[:vlen]...) + if vlen < 4 { + dst = sszutils.AppendZeroPadding(dst, (4-vlen)*1) + } + } + { // Static Field #2 'Epoch' + dst = binary.LittleEndian.AppendUint64(dst, t.Epoch) + } + return dst, nil +} + +// MarshalSSZDyn marshals the *Fork to SSZ-encoded bytes using dynamic specifications. +func (t *Fork) MarshalSSZDyn(_ sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + return t.MarshalSSZTo(buf) +} + +// MarshalSSZEncoder marshals the *Fork to the given SSZ encoder using dynamic specifications. +func (t *Fork) MarshalSSZEncoder(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + if t == nil { + t = new(Fork) + } + { // Field #0 'PreviousVersion' + vlen := len(t.PreviousVersion) + if vlen > 4 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 4), "PreviousVersion") + } + enc.EncodeBytes(t.PreviousVersion[:vlen]) + if vlen < 4 { + enc.EncodeZeroPadding((4 - vlen) * 1) + } + } + { // Field #1 'CurrentVersion' + vlen := len(t.CurrentVersion) + if vlen > 4 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 4), "CurrentVersion") + } + enc.EncodeBytes(t.CurrentVersion[:vlen]) + if vlen < 4 { + enc.EncodeZeroPadding((4 - vlen) * 1) + } + } + { // Field #2 'Epoch' + enc.EncodeUint64(t.Epoch) + } + return nil +} + +// UnmarshalSSZ unmarshals the *Fork from SSZ-encoded bytes. +func (t *Fork) UnmarshalSSZ(buf []byte) (err error) { + buflen := len(buf) + if buflen < 16 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 16) + } + if buflen > 16 { + return sszutils.ErrTrailingDataFn(buflen - 16) + } + { // Field #0 'PreviousVersion' (static) + buf := buf[0:4] + t.PreviousVersion = sszutils.ExpandSlice(t.PreviousVersion, 4) + copy(t.PreviousVersion[:], buf) + } + { // Field #1 'CurrentVersion' (static) + buf := buf[4:8] + t.CurrentVersion = sszutils.ExpandSlice(t.CurrentVersion, 4) + copy(t.CurrentVersion[:], buf) + } + { // Field #2 'Epoch' (static) + buf := buf[8:16] + t.Epoch = binary.LittleEndian.Uint64(buf) + } + return nil +} + +// UnmarshalSSZDyn unmarshals the *Fork from SSZ-encoded bytes using dynamic specifications. +func (t *Fork) UnmarshalSSZDyn(_ sszutils.DynamicSpecs, buf []byte) (err error) { + return t.UnmarshalSSZ(buf) +} + +// UnmarshalSSZDecoder unmarshals the *Fork from the given SSZ decoder using dynamic specifications. +func (t *Fork) UnmarshalSSZDecoder(_ sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { + maxOffset := uint32(dec.GetLength()) + if maxOffset < uint32(16) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(16)) + } + // Field #0 'PreviousVersion' (static) + t.PreviousVersion = sszutils.ExpandSlice(t.PreviousVersion, 4) + if _, err = dec.DecodeBytes(t.PreviousVersion[:4]); err != nil { + return err + } + // Field #1 'CurrentVersion' (static) + t.CurrentVersion = sszutils.ExpandSlice(t.CurrentVersion, 4) + if _, err = dec.DecodeBytes(t.CurrentVersion[:4]); err != nil { + return err + } + // Field #2 'Epoch' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "Epoch") + } else { + t.Epoch = val + } + return nil +} + +// SizeSSZ returns the SSZ encoded size of the *Fork. +func (t *Fork) SizeSSZ() (size int) { + return 16 +} + +// SizeSSZDyn returns the SSZ encoded size of the *Fork using dynamic specifications. +func (t *Fork) SizeSSZDyn(_ sszutils.DynamicSpecs) (size int) { + return t.SizeSSZ() +} + +// HashTreeRoot computes the SSZ hash tree root of the *Fork. +func (t *Fork) 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 *Fork using the given hash walker. +func (t *Fork) HashTreeRootWith(hh sszutils.HashWalker) error { + if t == nil { + t = new(Fork) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'PreviousVersion' + vlen := len(t.PreviousVersion) + if vlen > 4 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 4), "PreviousVersion") + } + val := t.PreviousVersion[:] + if vlen < 4 { + val = sszutils.AppendZeroPadding(val, (4-vlen)*1) + } + hh.PutBytes(val[:4]) + } + { // Field #1 'CurrentVersion' + vlen := len(t.CurrentVersion) + if vlen > 4 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 4), "CurrentVersion") + } + val := t.CurrentVersion[:] + if vlen < 4 { + val = sszutils.AppendZeroPadding(val, (4-vlen)*1) + } + hh.PutBytes(val[:4]) + } + { // Field #2 'Epoch' + hh.PutUint64(t.Epoch) + } + hh.Merkleize(idx) + return nil +} + +// HashTreeRootDyn computes the SSZ hash tree root of the *Fork using dynamic specifications. +func (t *Fork) HashTreeRootDyn(ds sszutils.DynamicSpecs) (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWithDyn(ds, hh) + if err == nil { + root, err = hh.HashRoot() + } + return + }) + return +} + +// HashTreeRootWithDyn computes the SSZ hash tree root of the *Fork using dynamic specifications and the given hash walker. +func (t *Fork) HashTreeRootWithDyn(_ sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + return t.HashTreeRootWith(hh) +} + +// MarshalSSZTo marshals the *BeaconBlockHeader to SSZ-encoded bytes, appending to the provided buffer. +func (t *BeaconBlockHeader) MarshalSSZTo(buf []byte) (dst []byte, err error) { + dst = buf + if t == nil { + t = new(BeaconBlockHeader) + } + { // Static Field #0 'Slot' + dst = binary.LittleEndian.AppendUint64(dst, t.Slot) + } + { // Static Field #1 'ProposerIndex' + dst = binary.LittleEndian.AppendUint64(dst, t.ProposerIndex) + } + { // Static Field #2 'ParentRoot' + vlen := len(t.ParentRoot) + if vlen > 32 { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 32), "ParentRoot") + } + dst = append(dst, t.ParentRoot[:vlen]...) + if vlen < 32 { + dst = sszutils.AppendZeroPadding(dst, (32-vlen)*1) + } + } + { // Static Field #3 'StateRoot' + vlen := len(t.StateRoot) + if vlen > 32 { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 32), "StateRoot") + } + dst = append(dst, t.StateRoot[:vlen]...) + if vlen < 32 { + dst = sszutils.AppendZeroPadding(dst, (32-vlen)*1) + } + } + { // Static Field #4 'BodyRoot' + vlen := len(t.BodyRoot) + if vlen > 32 { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 32), "BodyRoot") + } + dst = append(dst, t.BodyRoot[:vlen]...) + if vlen < 32 { + dst = sszutils.AppendZeroPadding(dst, (32-vlen)*1) + } + } + return dst, nil +} + +// MarshalSSZDyn marshals the *BeaconBlockHeader to SSZ-encoded bytes using dynamic specifications. +func (t *BeaconBlockHeader) MarshalSSZDyn(_ sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + return t.MarshalSSZTo(buf) +} + +// MarshalSSZEncoder marshals the *BeaconBlockHeader to the given SSZ encoder using dynamic specifications. +func (t *BeaconBlockHeader) MarshalSSZEncoder(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + if t == nil { + t = new(BeaconBlockHeader) + } + { // Field #0 'Slot' + enc.EncodeUint64(t.Slot) + } + { // Field #1 'ProposerIndex' + enc.EncodeUint64(t.ProposerIndex) + } + { // Field #2 'ParentRoot' + vlen := len(t.ParentRoot) + if vlen > 32 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 32), "ParentRoot") + } + enc.EncodeBytes(t.ParentRoot[:vlen]) + if vlen < 32 { + enc.EncodeZeroPadding((32 - vlen) * 1) + } + } + { // Field #3 'StateRoot' + vlen := len(t.StateRoot) + if vlen > 32 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 32), "StateRoot") + } + enc.EncodeBytes(t.StateRoot[:vlen]) + if vlen < 32 { + enc.EncodeZeroPadding((32 - vlen) * 1) + } + } + { // Field #4 'BodyRoot' + vlen := len(t.BodyRoot) + if vlen > 32 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 32), "BodyRoot") + } + enc.EncodeBytes(t.BodyRoot[:vlen]) + if vlen < 32 { + enc.EncodeZeroPadding((32 - vlen) * 1) + } + } + return nil +} + +// UnmarshalSSZ unmarshals the *BeaconBlockHeader from SSZ-encoded bytes. +func (t *BeaconBlockHeader) UnmarshalSSZ(buf []byte) (err error) { + buflen := len(buf) + if buflen < 112 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 112) + } + if buflen > 112 { + return sszutils.ErrTrailingDataFn(buflen - 112) + } + { // Field #0 'Slot' (static) + buf := buf[0:8] + t.Slot = binary.LittleEndian.Uint64(buf) + } + { // Field #1 'ProposerIndex' (static) + buf := buf[8:16] + t.ProposerIndex = binary.LittleEndian.Uint64(buf) + } + { // Field #2 'ParentRoot' (static) + buf := buf[16:48] + t.ParentRoot = sszutils.ExpandSlice(t.ParentRoot, 32) + copy(t.ParentRoot[:], buf) + } + { // Field #3 'StateRoot' (static) + buf := buf[48:80] + t.StateRoot = sszutils.ExpandSlice(t.StateRoot, 32) + copy(t.StateRoot[:], buf) + } + { // Field #4 'BodyRoot' (static) + buf := buf[80:112] + t.BodyRoot = sszutils.ExpandSlice(t.BodyRoot, 32) + copy(t.BodyRoot[:], buf) + } + return nil +} + +// UnmarshalSSZDyn unmarshals the *BeaconBlockHeader from SSZ-encoded bytes using dynamic specifications. +func (t *BeaconBlockHeader) UnmarshalSSZDyn(_ sszutils.DynamicSpecs, buf []byte) (err error) { + return t.UnmarshalSSZ(buf) +} + +// UnmarshalSSZDecoder unmarshals the *BeaconBlockHeader from the given SSZ decoder using dynamic specifications. +func (t *BeaconBlockHeader) UnmarshalSSZDecoder(_ sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { + maxOffset := uint32(dec.GetLength()) + if maxOffset < uint32(112) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(112)) + } + // Field #0 'Slot' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "Slot") + } else { + t.Slot = val + } + // Field #1 'ProposerIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "ProposerIndex") + } else { + t.ProposerIndex = val + } + // Field #2 'ParentRoot' (static) + t.ParentRoot = sszutils.ExpandSlice(t.ParentRoot, 32) + if _, err = dec.DecodeBytes(t.ParentRoot[:32]); err != nil { + return err + } + // Field #3 'StateRoot' (static) + t.StateRoot = sszutils.ExpandSlice(t.StateRoot, 32) + if _, err = dec.DecodeBytes(t.StateRoot[:32]); err != nil { + return err + } + // Field #4 'BodyRoot' (static) + t.BodyRoot = sszutils.ExpandSlice(t.BodyRoot, 32) + if _, err = dec.DecodeBytes(t.BodyRoot[:32]); err != nil { + return err + } + return nil +} + +// SizeSSZ returns the SSZ encoded size of the *BeaconBlockHeader. +func (t *BeaconBlockHeader) SizeSSZ() (size int) { + return 112 +} + +// SizeSSZDyn returns the SSZ encoded size of the *BeaconBlockHeader using dynamic specifications. +func (t *BeaconBlockHeader) SizeSSZDyn(_ sszutils.DynamicSpecs) (size int) { + return t.SizeSSZ() +} + +// HashTreeRoot computes the SSZ hash tree root of the *BeaconBlockHeader. +func (t *BeaconBlockHeader) 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 *BeaconBlockHeader using the given hash walker. +func (t *BeaconBlockHeader) HashTreeRootWith(hh sszutils.HashWalker) error { + if t == nil { + t = new(BeaconBlockHeader) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Slot' + hh.PutUint64(t.Slot) + } + { // Field #1 'ProposerIndex' + hh.PutUint64(t.ProposerIndex) + } + { // Field #2 'ParentRoot' + vlen := len(t.ParentRoot) + if vlen > 32 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 32), "ParentRoot") + } + val := t.ParentRoot[:] + if vlen < 32 { + val = sszutils.AppendZeroPadding(val, (32-vlen)*1) + } + hh.PutBytes(val[:32]) + } + { // Field #3 'StateRoot' + vlen := len(t.StateRoot) + if vlen > 32 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 32), "StateRoot") + } + val := t.StateRoot[:] + if vlen < 32 { + val = sszutils.AppendZeroPadding(val, (32-vlen)*1) + } + hh.PutBytes(val[:32]) + } + { // Field #4 'BodyRoot' + vlen := len(t.BodyRoot) + if vlen > 32 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 32), "BodyRoot") + } + val := t.BodyRoot[:] + if vlen < 32 { + val = sszutils.AppendZeroPadding(val, (32-vlen)*1) + } + hh.PutBytes(val[:32]) + } + hh.Merkleize(idx) + return nil +} + +// HashTreeRootDyn computes the SSZ hash tree root of the *BeaconBlockHeader using dynamic specifications. +func (t *BeaconBlockHeader) HashTreeRootDyn(ds sszutils.DynamicSpecs) (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWithDyn(ds, hh) + if err == nil { + root, err = hh.HashRoot() + } + return + }) + return +} + +// HashTreeRootWithDyn computes the SSZ hash tree root of the *BeaconBlockHeader using dynamic specifications and the given hash walker. +func (t *BeaconBlockHeader) HashTreeRootWithDyn(_ sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + return t.HashTreeRootWith(hh) +} + +// MarshalSSZTo marshals the *Eth1Data to SSZ-encoded bytes, appending to the provided buffer. +func (t *Eth1Data) MarshalSSZTo(buf []byte) (dst []byte, err error) { + dst = buf + if t == nil { + t = new(Eth1Data) + } + { // Static Field #0 'DepositRoot' + vlen := len(t.DepositRoot) + if vlen > 32 { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 32), "DepositRoot") + } + dst = append(dst, t.DepositRoot[:vlen]...) + if vlen < 32 { + dst = sszutils.AppendZeroPadding(dst, (32-vlen)*1) + } + } + { // Static Field #1 'DepositCount' + dst = binary.LittleEndian.AppendUint64(dst, t.DepositCount) + } + { // Static Field #2 'BlockHash' + vlen := len(t.BlockHash) + if vlen > 32 { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 32), "BlockHash") + } + dst = append(dst, t.BlockHash[:vlen]...) + if vlen < 32 { + dst = sszutils.AppendZeroPadding(dst, (32-vlen)*1) + } + } + return dst, nil +} + +// MarshalSSZDyn marshals the *Eth1Data to SSZ-encoded bytes using dynamic specifications. +func (t *Eth1Data) MarshalSSZDyn(_ sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + return t.MarshalSSZTo(buf) +} + +// MarshalSSZEncoder marshals the *Eth1Data to the given SSZ encoder using dynamic specifications. +func (t *Eth1Data) MarshalSSZEncoder(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + if t == nil { + t = new(Eth1Data) + } + { // Field #0 'DepositRoot' + vlen := len(t.DepositRoot) + if vlen > 32 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 32), "DepositRoot") + } + enc.EncodeBytes(t.DepositRoot[:vlen]) + if vlen < 32 { + enc.EncodeZeroPadding((32 - vlen) * 1) + } + } + { // Field #1 'DepositCount' + enc.EncodeUint64(t.DepositCount) + } + { // Field #2 'BlockHash' + vlen := len(t.BlockHash) + if vlen > 32 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 32), "BlockHash") + } + enc.EncodeBytes(t.BlockHash[:vlen]) + if vlen < 32 { + enc.EncodeZeroPadding((32 - vlen) * 1) + } + } + return nil +} + +// UnmarshalSSZ unmarshals the *Eth1Data from SSZ-encoded bytes. +func (t *Eth1Data) UnmarshalSSZ(buf []byte) (err error) { + buflen := len(buf) + if buflen < 72 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 72) + } + if buflen > 72 { + return sszutils.ErrTrailingDataFn(buflen - 72) + } + { // Field #0 'DepositRoot' (static) + buf := buf[0:32] + t.DepositRoot = sszutils.ExpandSlice(t.DepositRoot, 32) + copy(t.DepositRoot[:], buf) + } + { // Field #1 'DepositCount' (static) + buf := buf[32:40] + t.DepositCount = binary.LittleEndian.Uint64(buf) + } + { // Field #2 'BlockHash' (static) + buf := buf[40:72] + t.BlockHash = sszutils.ExpandSlice(t.BlockHash, 32) + copy(t.BlockHash[:], buf) + } + return nil +} + +// UnmarshalSSZDyn unmarshals the *Eth1Data from SSZ-encoded bytes using dynamic specifications. +func (t *Eth1Data) UnmarshalSSZDyn(_ sszutils.DynamicSpecs, buf []byte) (err error) { + return t.UnmarshalSSZ(buf) +} + +// UnmarshalSSZDecoder unmarshals the *Eth1Data from the given SSZ decoder using dynamic specifications. +func (t *Eth1Data) UnmarshalSSZDecoder(_ sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { + maxOffset := uint32(dec.GetLength()) + if maxOffset < uint32(72) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(72)) + } + // Field #0 'DepositRoot' (static) + t.DepositRoot = sszutils.ExpandSlice(t.DepositRoot, 32) + if _, err = dec.DecodeBytes(t.DepositRoot[:32]); err != nil { + return err + } + // Field #1 'DepositCount' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "DepositCount") + } else { + t.DepositCount = val + } + // Field #2 'BlockHash' (static) + t.BlockHash = sszutils.ExpandSlice(t.BlockHash, 32) + if _, err = dec.DecodeBytes(t.BlockHash[:32]); err != nil { + return err + } + return nil +} + +// SizeSSZ returns the SSZ encoded size of the *Eth1Data. +func (t *Eth1Data) SizeSSZ() (size int) { + return 72 +} + +// SizeSSZDyn returns the SSZ encoded size of the *Eth1Data using dynamic specifications. +func (t *Eth1Data) SizeSSZDyn(_ sszutils.DynamicSpecs) (size int) { + return t.SizeSSZ() +} + +// HashTreeRoot computes the SSZ hash tree root of the *Eth1Data. +func (t *Eth1Data) 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 *Eth1Data using the given hash walker. +func (t *Eth1Data) HashTreeRootWith(hh sszutils.HashWalker) error { + if t == nil { + t = new(Eth1Data) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'DepositRoot' + vlen := len(t.DepositRoot) + if vlen > 32 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 32), "DepositRoot") + } + val := t.DepositRoot[:] + if vlen < 32 { + val = sszutils.AppendZeroPadding(val, (32-vlen)*1) + } + hh.PutBytes(val[:32]) + } + { // Field #1 'DepositCount' + hh.PutUint64(t.DepositCount) + } + { // Field #2 'BlockHash' + vlen := len(t.BlockHash) + if vlen > 32 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 32), "BlockHash") + } + val := t.BlockHash[:] + if vlen < 32 { + val = sszutils.AppendZeroPadding(val, (32-vlen)*1) + } + hh.PutBytes(val[:32]) + } + hh.Merkleize(idx) + return nil +} + +// HashTreeRootDyn computes the SSZ hash tree root of the *Eth1Data using dynamic specifications. +func (t *Eth1Data) HashTreeRootDyn(ds sszutils.DynamicSpecs) (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWithDyn(ds, hh) + if err == nil { + root, err = hh.HashRoot() + } + return + }) + return +} + +// HashTreeRootWithDyn computes the SSZ hash tree root of the *Eth1Data using dynamic specifications and the given hash walker. +func (t *Eth1Data) HashTreeRootWithDyn(_ sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + return t.HashTreeRootWith(hh) +} + +// MarshalSSZTo marshals the *Validator to SSZ-encoded bytes, appending to the provided buffer. +func (t *Validator) MarshalSSZTo(buf []byte) (dst []byte, err error) { + dst = buf + if t == nil { + t = new(Validator) + } + { // Static Field #0 'Pubkey' + vlen := len(t.Pubkey) + if vlen > 48 { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 48), "Pubkey") + } + dst = append(dst, t.Pubkey[:vlen]...) + if vlen < 48 { + dst = sszutils.AppendZeroPadding(dst, (48-vlen)*1) + } + } + { // Static Field #1 'WithdrawalCredentials' + vlen := len(t.WithdrawalCredentials) + if vlen > 32 { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 32), "WithdrawalCredentials") + } + dst = append(dst, t.WithdrawalCredentials[:vlen]...) + if vlen < 32 { + dst = sszutils.AppendZeroPadding(dst, (32-vlen)*1) + } + } + { // Static Field #2 'EffectiveBalance' + dst = binary.LittleEndian.AppendUint64(dst, t.EffectiveBalance) + } + { // Static Field #3 'Slashed' + dst = sszutils.MarshalBool(dst, t.Slashed) + } + { // Static Field #4 'ActivationEligibilityEpoch' + dst = binary.LittleEndian.AppendUint64(dst, t.ActivationEligibilityEpoch) + } + { // Static Field #5 'ActivationEpoch' + dst = binary.LittleEndian.AppendUint64(dst, t.ActivationEpoch) + } + { // Static Field #6 'ExitEpoch' + dst = binary.LittleEndian.AppendUint64(dst, t.ExitEpoch) + } + { // Static Field #7 'WithdrawableEpoch' + dst = binary.LittleEndian.AppendUint64(dst, t.WithdrawableEpoch) + } + return dst, nil +} + +// MarshalSSZDyn marshals the *Validator to SSZ-encoded bytes using dynamic specifications. +func (t *Validator) MarshalSSZDyn(_ sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + return t.MarshalSSZTo(buf) +} + +// MarshalSSZEncoder marshals the *Validator to the given SSZ encoder using dynamic specifications. +func (t *Validator) MarshalSSZEncoder(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + if t == nil { + t = new(Validator) + } + { // Field #0 'Pubkey' + vlen := len(t.Pubkey) + if vlen > 48 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 48), "Pubkey") + } + enc.EncodeBytes(t.Pubkey[:vlen]) + if vlen < 48 { + enc.EncodeZeroPadding((48 - vlen) * 1) + } + } + { // Field #1 'WithdrawalCredentials' + vlen := len(t.WithdrawalCredentials) + if vlen > 32 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 32), "WithdrawalCredentials") + } + enc.EncodeBytes(t.WithdrawalCredentials[:vlen]) + if vlen < 32 { + enc.EncodeZeroPadding((32 - vlen) * 1) + } + } + { // Field #2 'EffectiveBalance' + enc.EncodeUint64(t.EffectiveBalance) + } + { // Field #3 'Slashed' + enc.EncodeBool(t.Slashed) + } + { // Field #4 'ActivationEligibilityEpoch' + enc.EncodeUint64(t.ActivationEligibilityEpoch) + } + { // Field #5 'ActivationEpoch' + enc.EncodeUint64(t.ActivationEpoch) + } + { // Field #6 'ExitEpoch' + enc.EncodeUint64(t.ExitEpoch) + } + { // Field #7 'WithdrawableEpoch' + enc.EncodeUint64(t.WithdrawableEpoch) + } + return nil +} + +// UnmarshalSSZ unmarshals the *Validator from SSZ-encoded bytes. +func (t *Validator) UnmarshalSSZ(buf []byte) (err error) { + buflen := len(buf) + if buflen < 121 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 121) + } + if buflen > 121 { + return sszutils.ErrTrailingDataFn(buflen - 121) + } + { // Field #0 'Pubkey' (static) + buf := buf[0:48] + t.Pubkey = sszutils.ExpandSlice(t.Pubkey, 48) + copy(t.Pubkey[:], buf) + } + { // Field #1 'WithdrawalCredentials' (static) + buf := buf[48:80] + t.WithdrawalCredentials = sszutils.ExpandSlice(t.WithdrawalCredentials, 32) + copy(t.WithdrawalCredentials[:], buf) + } + { // Field #2 'EffectiveBalance' (static) + buf := buf[80:88] + t.EffectiveBalance = binary.LittleEndian.Uint64(buf) + } + { // Field #3 'Slashed' (static) + buf := buf[88:89] + if buf[0] != 1 && buf[0] != 0 { + return sszutils.ErrInvalidBoolValueFn() + } + t.Slashed = buf[0] == 1 + } + { // Field #4 'ActivationEligibilityEpoch' (static) + buf := buf[89:97] + t.ActivationEligibilityEpoch = binary.LittleEndian.Uint64(buf) + } + { // Field #5 'ActivationEpoch' (static) + buf := buf[97:105] + t.ActivationEpoch = binary.LittleEndian.Uint64(buf) + } + { // Field #6 'ExitEpoch' (static) + buf := buf[105:113] + t.ExitEpoch = binary.LittleEndian.Uint64(buf) + } + { // Field #7 'WithdrawableEpoch' (static) + buf := buf[113:121] + t.WithdrawableEpoch = binary.LittleEndian.Uint64(buf) + } + return nil +} + +// UnmarshalSSZDyn unmarshals the *Validator from SSZ-encoded bytes using dynamic specifications. +func (t *Validator) UnmarshalSSZDyn(_ sszutils.DynamicSpecs, buf []byte) (err error) { + return t.UnmarshalSSZ(buf) +} + +// UnmarshalSSZDecoder unmarshals the *Validator from the given SSZ decoder using dynamic specifications. +func (t *Validator) UnmarshalSSZDecoder(_ sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { + maxOffset := uint32(dec.GetLength()) + if maxOffset < uint32(121) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(121)) + } + // Field #0 'Pubkey' (static) + t.Pubkey = sszutils.ExpandSlice(t.Pubkey, 48) + if _, err = dec.DecodeBytes(t.Pubkey[:48]); err != nil { + return err + } + // Field #1 'WithdrawalCredentials' (static) + t.WithdrawalCredentials = sszutils.ExpandSlice(t.WithdrawalCredentials, 32) + if _, err = dec.DecodeBytes(t.WithdrawalCredentials[:32]); err != nil { + return err + } + // Field #2 'EffectiveBalance' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "EffectiveBalance") + } else { + t.EffectiveBalance = val + } + // Field #3 'Slashed' (static) + if val, err := dec.DecodeBool(); err != nil { + return sszutils.ErrorWithPath(err, "Slashed") + } else { + t.Slashed = val + } + // Field #4 'ActivationEligibilityEpoch' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "ActivationEligibilityEpoch") + } else { + t.ActivationEligibilityEpoch = val + } + // Field #5 'ActivationEpoch' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "ActivationEpoch") + } else { + t.ActivationEpoch = val + } + // Field #6 'ExitEpoch' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "ExitEpoch") + } else { + t.ExitEpoch = val + } + // Field #7 'WithdrawableEpoch' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "WithdrawableEpoch") + } else { + t.WithdrawableEpoch = val + } + return nil +} + +// SizeSSZ returns the SSZ encoded size of the *Validator. +func (t *Validator) SizeSSZ() (size int) { + return 121 +} + +// SizeSSZDyn returns the SSZ encoded size of the *Validator using dynamic specifications. +func (t *Validator) SizeSSZDyn(_ sszutils.DynamicSpecs) (size int) { + return t.SizeSSZ() +} + +// HashTreeRoot computes the SSZ hash tree root of the *Validator. +func (t *Validator) 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 *Validator using the given hash walker. +func (t *Validator) HashTreeRootWith(hh sszutils.HashWalker) error { + if t == nil { + t = new(Validator) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Pubkey' + vlen := len(t.Pubkey) + if vlen > 48 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 48), "Pubkey") + } + val := t.Pubkey[:] + if vlen < 48 { + val = sszutils.AppendZeroPadding(val, (48-vlen)*1) + } + hh.PutBytes(val[:48]) + } + { // Field #1 'WithdrawalCredentials' + vlen := len(t.WithdrawalCredentials) + if vlen > 32 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 32), "WithdrawalCredentials") + } + val := t.WithdrawalCredentials[:] + if vlen < 32 { + val = sszutils.AppendZeroPadding(val, (32-vlen)*1) + } + hh.PutBytes(val[:32]) + } + { // Field #2 'EffectiveBalance' + hh.PutUint64(t.EffectiveBalance) + } + { // Field #3 'Slashed' + hh.PutBool(t.Slashed) + } + { // Field #4 'ActivationEligibilityEpoch' + hh.PutUint64(t.ActivationEligibilityEpoch) + } + { // Field #5 'ActivationEpoch' + hh.PutUint64(t.ActivationEpoch) + } + { // Field #6 'ExitEpoch' + hh.PutUint64(t.ExitEpoch) + } + { // Field #7 'WithdrawableEpoch' + hh.PutUint64(t.WithdrawableEpoch) + } + hh.Merkleize(idx) + return nil +} + +// HashTreeRootDyn computes the SSZ hash tree root of the *Validator using dynamic specifications. +func (t *Validator) HashTreeRootDyn(ds sszutils.DynamicSpecs) (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWithDyn(ds, hh) + if err == nil { + root, err = hh.HashRoot() + } + return + }) + return +} + +// HashTreeRootWithDyn computes the SSZ hash tree root of the *Validator using dynamic specifications and the given hash walker. +func (t *Validator) HashTreeRootWithDyn(_ sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + return t.HashTreeRootWith(hh) +} + +// MarshalSSZTo marshals the *Checkpoint to SSZ-encoded bytes, appending to the provided buffer. +func (t *Checkpoint) MarshalSSZTo(buf []byte) (dst []byte, err error) { + dst = buf + if t == nil { + t = new(Checkpoint) + } + { // Static Field #0 'Epoch' + dst = binary.LittleEndian.AppendUint64(dst, t.Epoch) + } + { // Static Field #1 'Root' + vlen := len(t.Root) + if vlen > 32 { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 32), "Root") + } + dst = append(dst, t.Root[:vlen]...) + if vlen < 32 { + dst = sszutils.AppendZeroPadding(dst, (32-vlen)*1) + } + } + return dst, nil +} + +// MarshalSSZDyn marshals the *Checkpoint to SSZ-encoded bytes using dynamic specifications. +func (t *Checkpoint) MarshalSSZDyn(_ sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + return t.MarshalSSZTo(buf) +} + +// MarshalSSZEncoder marshals the *Checkpoint to the given SSZ encoder using dynamic specifications. +func (t *Checkpoint) MarshalSSZEncoder(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + if t == nil { + t = new(Checkpoint) + } + { // Field #0 'Epoch' + enc.EncodeUint64(t.Epoch) + } + { // Field #1 'Root' + vlen := len(t.Root) + if vlen > 32 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 32), "Root") + } + enc.EncodeBytes(t.Root[:vlen]) + if vlen < 32 { + enc.EncodeZeroPadding((32 - vlen) * 1) + } + } + return nil +} + +// UnmarshalSSZ unmarshals the *Checkpoint from SSZ-encoded bytes. +func (t *Checkpoint) UnmarshalSSZ(buf []byte) (err error) { + buflen := len(buf) + if buflen < 40 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 40) + } + if buflen > 40 { + return sszutils.ErrTrailingDataFn(buflen - 40) + } + { // Field #0 'Epoch' (static) + buf := buf[0:8] + t.Epoch = binary.LittleEndian.Uint64(buf) + } + { // Field #1 'Root' (static) + buf := buf[8:40] + t.Root = sszutils.ExpandSlice(t.Root, 32) + copy(t.Root[:], buf) + } + return nil +} + +// UnmarshalSSZDyn unmarshals the *Checkpoint from SSZ-encoded bytes using dynamic specifications. +func (t *Checkpoint) UnmarshalSSZDyn(_ sszutils.DynamicSpecs, buf []byte) (err error) { + return t.UnmarshalSSZ(buf) +} + +// UnmarshalSSZDecoder unmarshals the *Checkpoint from the given SSZ decoder using dynamic specifications. +func (t *Checkpoint) UnmarshalSSZDecoder(_ sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { + maxOffset := uint32(dec.GetLength()) + if maxOffset < uint32(40) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(40)) + } + // Field #0 'Epoch' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "Epoch") + } else { + t.Epoch = val + } + // Field #1 'Root' (static) + t.Root = sszutils.ExpandSlice(t.Root, 32) + if _, err = dec.DecodeBytes(t.Root[:32]); err != nil { + return err + } + return nil +} + +// SizeSSZ returns the SSZ encoded size of the *Checkpoint. +func (t *Checkpoint) SizeSSZ() (size int) { + return 40 +} + +// SizeSSZDyn returns the SSZ encoded size of the *Checkpoint using dynamic specifications. +func (t *Checkpoint) SizeSSZDyn(_ sszutils.DynamicSpecs) (size int) { + return t.SizeSSZ() +} + +// HashTreeRoot computes the SSZ hash tree root of the *Checkpoint. +func (t *Checkpoint) 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 *Checkpoint using the given hash walker. +func (t *Checkpoint) HashTreeRootWith(hh sszutils.HashWalker) error { + if t == nil { + t = new(Checkpoint) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Epoch' + hh.PutUint64(t.Epoch) + } + { // Field #1 'Root' + vlen := len(t.Root) + if vlen > 32 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 32), "Root") + } + val := t.Root[:] + if vlen < 32 { + val = sszutils.AppendZeroPadding(val, (32-vlen)*1) + } + hh.PutBytes(val[:32]) + } + hh.Merkleize(idx) + return nil +} + +// HashTreeRootDyn computes the SSZ hash tree root of the *Checkpoint using dynamic specifications. +func (t *Checkpoint) HashTreeRootDyn(ds sszutils.DynamicSpecs) (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWithDyn(ds, hh) + if err == nil { + root, err = hh.HashRoot() + } + return + }) + return +} + +// HashTreeRootWithDyn computes the SSZ hash tree root of the *Checkpoint using dynamic specifications and the given hash walker. +func (t *Checkpoint) HashTreeRootWithDyn(_ sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + return t.HashTreeRootWith(hh) +} + +// MarshalSSZTo marshals the *SyncCommittee to SSZ-encoded bytes, appending to the provided buffer. +func (t *SyncCommittee) MarshalSSZTo(buf []byte) (dst []byte, err error) { + dst = buf + if t == nil { + t = new(SyncCommittee) + } + { // Static Field #0 'PubKeys' + t := t.PubKeys + vlen := len(t) + if vlen > 512 { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 512), "PubKeys") + } + for idx1 := range vlen { + vlen := len(t[idx1]) + if vlen > 48 { + return nil, sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, 48), "PubKeys[%d]", idx1) + } + dst = append(dst, t[idx1][:vlen]...) + if vlen < 48 { + dst = sszutils.AppendZeroPadding(dst, (48-vlen)*1) + } + } + if vlen < 512 { + dst = sszutils.AppendZeroPadding(dst, (512-vlen)*48) + } + } + { // Static Field #1 'AggregatePubKey' + dst = append(dst, t.AggregatePubKey[:48]...) + } + return dst, nil +} + +// MarshalSSZDyn marshals the *SyncCommittee to SSZ-encoded bytes using dynamic specifications. +func (t *SyncCommittee) MarshalSSZDyn(_ sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + return t.MarshalSSZTo(buf) +} + +// MarshalSSZEncoder marshals the *SyncCommittee to the given SSZ encoder using dynamic specifications. +func (t *SyncCommittee) MarshalSSZEncoder(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + if t == nil { + t = new(SyncCommittee) + } + { // Field #0 'PubKeys' + t := t.PubKeys + vlen := len(t) + if vlen > 512 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 512), "PubKeys") + } + for idx1 := range vlen { + vlen := len(t[idx1]) + if vlen > 48 { + return sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, 48), "PubKeys[%d]", idx1) + } + enc.EncodeBytes(t[idx1][:vlen]) + if vlen < 48 { + enc.EncodeZeroPadding((48 - vlen) * 1) + } + } + if vlen < 512 { + enc.EncodeZeroPadding((512 - vlen) * 48) + } + } + { // Field #1 'AggregatePubKey' + enc.EncodeBytes(t.AggregatePubKey[:48]) + } + return nil +} + +// UnmarshalSSZ unmarshals the *SyncCommittee from SSZ-encoded bytes. +func (t *SyncCommittee) UnmarshalSSZ(buf []byte) (err error) { + buflen := len(buf) + if buflen < 24624 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 24624) + } + if buflen > 24624 { + return sszutils.ErrTrailingDataFn(buflen - 24624) + } + { // Field #0 'PubKeys' (static) + buf := buf[0:24576] + val1 := t.PubKeys + val1 = sszutils.ExpandSlice(val1, 512) + for idx1 := range 512 { + buf := buf[48*idx1 : 48*(idx1+1)] + val1[idx1] = sszutils.ExpandSlice(val1[idx1], 48) + copy(val1[idx1][:], buf) + } + t.PubKeys = val1 + } + { // Field #1 'AggregatePubKey' (static) + buf := buf[24576:24624] + copy(t.AggregatePubKey[:], buf) + } + return nil +} + +// UnmarshalSSZDyn unmarshals the *SyncCommittee from SSZ-encoded bytes using dynamic specifications. +func (t *SyncCommittee) UnmarshalSSZDyn(_ sszutils.DynamicSpecs, buf []byte) (err error) { + return t.UnmarshalSSZ(buf) +} + +// UnmarshalSSZDecoder unmarshals the *SyncCommittee from the given SSZ decoder using dynamic specifications. +func (t *SyncCommittee) UnmarshalSSZDecoder(_ sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { + maxOffset := uint32(dec.GetLength()) + if maxOffset < uint32(24624) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(24624)) + } + { // Field #0 'PubKeys' (static) + val1 := t.PubKeys + val1 = sszutils.ExpandSlice(val1, 512) + startPos0 := dec.GetPosition() + for idx1 := range 512 { + val1[idx1] = sszutils.ExpandSlice(val1[idx1], 48) + if _, err = dec.DecodeBytes(val1[idx1][:48]); err != nil { + return err + } + if dec.GetPosition() != startPos0+int(48*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos0+int(48*(idx1+1))), "PubKeys[%d]", idx1) + } + } + t.PubKeys = val1 + } + // Field #1 'AggregatePubKey' (static) + if _, err = dec.DecodeBytes(t.AggregatePubKey[:48]); err != nil { + return err + } + return nil +} + +// SizeSSZ returns the SSZ encoded size of the *SyncCommittee. +func (t *SyncCommittee) SizeSSZ() (size int) { + return 24624 +} + +// SizeSSZDyn returns the SSZ encoded size of the *SyncCommittee using dynamic specifications. +func (t *SyncCommittee) SizeSSZDyn(_ sszutils.DynamicSpecs) (size int) { + return t.SizeSSZ() +} + +// HashTreeRoot computes the SSZ hash tree root of the *SyncCommittee. +func (t *SyncCommittee) 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 *SyncCommittee using the given hash walker. +func (t *SyncCommittee) HashTreeRootWith(hh sszutils.HashWalker) error { + if t == nil { + t = new(SyncCommittee) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'PubKeys' + t := t.PubKeys + vlen := len(t) + if vlen > 512 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 512), "PubKeys") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + var val1, val1Empty []byte + for idx1 := range 512 { + if idx1 < vlen { + val1 = t[idx1] + } else if idx1 == vlen { + val1 = val1Empty + } + vlen := len(val1) + if vlen > 48 { + return sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, 48), "PubKeys[%d]", idx1) + } + val := val1[:] + if vlen < 48 { + val = sszutils.AppendZeroPadding(val, (48-vlen)*1) + } + hh.PutBytes(val[:48]) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.Merkleize(idx) + } + { // Field #1 'AggregatePubKey' + hh.PutBytes(t.AggregatePubKey[:48]) + } + hh.Merkleize(idx) + return nil +} + +// HashTreeRootDyn computes the SSZ hash tree root of the *SyncCommittee using dynamic specifications. +func (t *SyncCommittee) HashTreeRootDyn(ds sszutils.DynamicSpecs) (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWithDyn(ds, hh) + if err == nil { + root, err = hh.HashRoot() + } + return + }) + return +} + +// HashTreeRootWithDyn computes the SSZ hash tree root of the *SyncCommittee using dynamic specifications and the given hash walker. +func (t *SyncCommittee) HashTreeRootWithDyn(_ sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + return t.HashTreeRootWith(hh) +} + +// MarshalSSZTo marshals the *HistoricalSummary to SSZ-encoded bytes, appending to the provided buffer. +func (t *HistoricalSummary) MarshalSSZTo(buf []byte) (dst []byte, err error) { + dst = buf + if t == nil { + t = new(HistoricalSummary) + } + { // Static Field #0 'BlockSummaryRoot' + dst = append(dst, t.BlockSummaryRoot[:32]...) + } + { // Static Field #1 'StateSummaryRoot' + dst = append(dst, t.StateSummaryRoot[:32]...) + } + return dst, nil +} + +// MarshalSSZDyn marshals the *HistoricalSummary to SSZ-encoded bytes using dynamic specifications. +func (t *HistoricalSummary) MarshalSSZDyn(_ sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + return t.MarshalSSZTo(buf) +} + +// MarshalSSZEncoder marshals the *HistoricalSummary to the given SSZ encoder using dynamic specifications. +func (t *HistoricalSummary) MarshalSSZEncoder(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + if t == nil { + t = new(HistoricalSummary) + } + { // Field #0 'BlockSummaryRoot' + enc.EncodeBytes(t.BlockSummaryRoot[:32]) + } + { // Field #1 'StateSummaryRoot' + enc.EncodeBytes(t.StateSummaryRoot[:32]) + } + return nil +} + +// UnmarshalSSZ unmarshals the *HistoricalSummary from SSZ-encoded bytes. +func (t *HistoricalSummary) UnmarshalSSZ(buf []byte) (err error) { + buflen := len(buf) + if buflen < 64 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 64) + } + if buflen > 64 { + return sszutils.ErrTrailingDataFn(buflen - 64) + } + { // Field #0 'BlockSummaryRoot' (static) + buf := buf[0:32] + copy(t.BlockSummaryRoot[:], buf) + } + { // Field #1 'StateSummaryRoot' (static) + buf := buf[32:64] + copy(t.StateSummaryRoot[:], buf) + } + return nil +} + +// UnmarshalSSZDyn unmarshals the *HistoricalSummary from SSZ-encoded bytes using dynamic specifications. +func (t *HistoricalSummary) UnmarshalSSZDyn(_ sszutils.DynamicSpecs, buf []byte) (err error) { + return t.UnmarshalSSZ(buf) +} + +// UnmarshalSSZDecoder unmarshals the *HistoricalSummary from the given SSZ decoder using dynamic specifications. +func (t *HistoricalSummary) UnmarshalSSZDecoder(_ sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { + maxOffset := uint32(dec.GetLength()) + if maxOffset < uint32(64) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(64)) + } + // Field #0 'BlockSummaryRoot' (static) + if _, err = dec.DecodeBytes(t.BlockSummaryRoot[:32]); err != nil { + return err + } + // Field #1 'StateSummaryRoot' (static) + if _, err = dec.DecodeBytes(t.StateSummaryRoot[:32]); err != nil { + return err + } + return nil +} + +// SizeSSZ returns the SSZ encoded size of the *HistoricalSummary. +func (t *HistoricalSummary) SizeSSZ() (size int) { + return 64 +} + +// SizeSSZDyn returns the SSZ encoded size of the *HistoricalSummary using dynamic specifications. +func (t *HistoricalSummary) SizeSSZDyn(_ sszutils.DynamicSpecs) (size int) { + return t.SizeSSZ() +} + +// HashTreeRoot computes the SSZ hash tree root of the *HistoricalSummary. +func (t *HistoricalSummary) 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 *HistoricalSummary using the given hash walker. +func (t *HistoricalSummary) HashTreeRootWith(hh sszutils.HashWalker) error { + if t == nil { + t = new(HistoricalSummary) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'BlockSummaryRoot' + hh.PutBytes(t.BlockSummaryRoot[:32]) + } + { // Field #1 'StateSummaryRoot' + hh.PutBytes(t.StateSummaryRoot[:32]) + } + hh.Merkleize(idx) + return nil +} + +// HashTreeRootDyn computes the SSZ hash tree root of the *HistoricalSummary using dynamic specifications. +func (t *HistoricalSummary) HashTreeRootDyn(ds sszutils.DynamicSpecs) (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWithDyn(ds, hh) + if err == nil { + root, err = hh.HashRoot() + } + return + }) + return +} + +// HashTreeRootWithDyn computes the SSZ hash tree root of the *HistoricalSummary using dynamic specifications and the given hash walker. +func (t *HistoricalSummary) HashTreeRootWithDyn(_ sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + return t.HashTreeRootWith(hh) +} + +// MarshalSSZTo marshals the *HistoricalSummaryLists to SSZ-encoded bytes, appending to the provided buffer. +func (t *HistoricalSummaryLists) MarshalSSZTo(buf []byte) (dst []byte, err error) { + dst = buf + if t == nil { + t = new(HistoricalSummaryLists) + } + { // Static Field #0 'BlockRoots' + t := &t.BlockRoots + dst = sszutils.MarshalFixedBytesSlice(dst, t[:8192]) + } + { // Static Field #1 'StateRoots' + t := &t.StateRoots + dst = sszutils.MarshalFixedBytesSlice(dst, t[:8192]) + } + return dst, nil +} + +// MarshalSSZDyn marshals the *HistoricalSummaryLists to SSZ-encoded bytes using dynamic specifications. +func (t *HistoricalSummaryLists) MarshalSSZDyn(_ sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + return t.MarshalSSZTo(buf) +} + +// MarshalSSZEncoder marshals the *HistoricalSummaryLists to the given SSZ encoder using dynamic specifications. +func (t *HistoricalSummaryLists) MarshalSSZEncoder(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + if t == nil { + t = new(HistoricalSummaryLists) + } + { // Field #0 'BlockRoots' + t := &t.BlockRoots + for idx1 := range 8192 { + enc.EncodeBytes(t[idx1][:32]) + } + } + { // Field #1 'StateRoots' + t := &t.StateRoots + for idx1 := range 8192 { + enc.EncodeBytes(t[idx1][:32]) + } + } + return nil +} + +// UnmarshalSSZ unmarshals the *HistoricalSummaryLists from SSZ-encoded bytes. +func (t *HistoricalSummaryLists) UnmarshalSSZ(buf []byte) (err error) { + buflen := len(buf) + if buflen < 524288 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 524288) + } + if buflen > 524288 { + return sszutils.ErrTrailingDataFn(buflen - 524288) + } + { // Field #0 'BlockRoots' (static) + buf := buf[0:262144] + val1 := t.BlockRoots + sszutils.UnmarshalFixedBytesSlice(val1[:8192], buf) + t.BlockRoots = val1 + } + { // Field #1 'StateRoots' (static) + buf := buf[262144:524288] + val2 := t.StateRoots + sszutils.UnmarshalFixedBytesSlice(val2[:8192], buf) + t.StateRoots = val2 + } + return nil +} + +// UnmarshalSSZDyn unmarshals the *HistoricalSummaryLists from SSZ-encoded bytes using dynamic specifications. +func (t *HistoricalSummaryLists) UnmarshalSSZDyn(_ sszutils.DynamicSpecs, buf []byte) (err error) { + return t.UnmarshalSSZ(buf) +} + +// UnmarshalSSZDecoder unmarshals the *HistoricalSummaryLists from the given SSZ decoder using dynamic specifications. +func (t *HistoricalSummaryLists) UnmarshalSSZDecoder(_ sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { + maxOffset := uint32(dec.GetLength()) + if maxOffset < uint32(524288) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(524288)) + } + { // Field #0 'BlockRoots' (static) + val1 := t.BlockRoots + startPos0 := dec.GetPosition() + for idx1 := range 8192 { + if _, err = dec.DecodeBytes(val1[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos0+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos0+int(32*(idx1+1))), "BlockRoots[%d]", idx1) + } + } + t.BlockRoots = val1 + } + { // Field #1 'StateRoots' (static) + val2 := t.StateRoots + startPos1 := dec.GetPosition() + for idx1 := range 8192 { + if _, err = dec.DecodeBytes(val2[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos1+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos1+int(32*(idx1+1))), "StateRoots[%d]", idx1) + } + } + t.StateRoots = val2 + } + return nil +} + +// SizeSSZ returns the SSZ encoded size of the *HistoricalSummaryLists. +func (t *HistoricalSummaryLists) SizeSSZ() (size int) { + return 524288 +} + +// SizeSSZDyn returns the SSZ encoded size of the *HistoricalSummaryLists using dynamic specifications. +func (t *HistoricalSummaryLists) SizeSSZDyn(_ sszutils.DynamicSpecs) (size int) { + return t.SizeSSZ() +} + +// HashTreeRoot computes the SSZ hash tree root of the *HistoricalSummaryLists. +func (t *HistoricalSummaryLists) 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 *HistoricalSummaryLists using the given hash walker. +func (t *HistoricalSummaryLists) HashTreeRootWith(hh sszutils.HashWalker) error { + if t == nil { + t = new(HistoricalSummaryLists) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'BlockRoots' + t := &t.BlockRoots + idx := hh.StartTree(sszutils.TreeTypeBinary) + var val1 *[32]byte + for idx1 := range 8192 { + if idx1 < 8192 { + val1 = &t[idx1] + } else if idx1 == 8192 { + val1 = new([32]byte) + } + hh.PutBytes(val1[:32]) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.Merkleize(idx) + } + { // Field #1 'StateRoots' + t := &t.StateRoots + idx := hh.StartTree(sszutils.TreeTypeBinary) + var val2 *[32]byte + for idx1 := range 8192 { + if idx1 < 8192 { + val2 = &t[idx1] + } else if idx1 == 8192 { + val2 = new([32]byte) + } + hh.PutBytes(val2[:32]) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.Merkleize(idx) + } + hh.Merkleize(idx) + return nil +} + +// HashTreeRootDyn computes the SSZ hash tree root of the *HistoricalSummaryLists using dynamic specifications. +func (t *HistoricalSummaryLists) HashTreeRootDyn(ds sszutils.DynamicSpecs) (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWithDyn(ds, hh) + if err == nil { + root, err = hh.HashRoot() + } + return + }) + return +} + +// HashTreeRootWithDyn computes the SSZ hash tree root of the *HistoricalSummaryLists using dynamic specifications and the given hash walker. +func (t *HistoricalSummaryLists) HashTreeRootWithDyn(_ sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + return t.HashTreeRootWith(hh) +} + +// MarshalSSZTo marshals the *ExecutionPayloadHeader to SSZ-encoded bytes, appending to the provided buffer. +func (t *ExecutionPayloadHeader) MarshalSSZTo(buf []byte) (dst []byte, err error) { + dst = buf + if t == nil { + t = new(ExecutionPayloadHeader) + } + dstlen := len(dst) + { // Static Field #0 'ParentHash' + dst = append(dst, t.ParentHash[:32]...) + } + { // Static Field #1 'FeeRecipient' + dst = append(dst, t.FeeRecipient[:20]...) + } + { // Static Field #2 'StateRoot' + dst = append(dst, t.StateRoot[:32]...) + } + { // Static Field #3 'ReceiptsRoot' + dst = append(dst, t.ReceiptsRoot[:32]...) + } + { // Static Field #4 'LogsBloom' + dst = append(dst, t.LogsBloom[:256]...) + } + { // Static Field #5 'PrevRandao' + dst = append(dst, t.PrevRandao[:32]...) + } + { // Static Field #6 'BlockNumber' + dst = binary.LittleEndian.AppendUint64(dst, t.BlockNumber) + } + { // Static Field #7 'GasLimit' + dst = binary.LittleEndian.AppendUint64(dst, t.GasLimit) + } + { // Static Field #8 'GasUsed' + dst = binary.LittleEndian.AppendUint64(dst, t.GasUsed) + } + { // Static Field #9 'Timestamp' + dst = binary.LittleEndian.AppendUint64(dst, t.Timestamp) + } + // Offset Field #10 'ExtraData' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #11 'BaseFeePerGas' + dst = append(dst, t.BaseFeePerGas[:32]...) + } + { // Static Field #12 'BlockHash' + dst = append(dst, t.BlockHash[:32]...) + } + { // Static Field #13 'TransactionsRoot' + dst = append(dst, t.TransactionsRoot[:32]...) + } + { // Static Field #14 'WithdrawalRoot' + dst = append(dst, t.WithdrawalRoot[:32]...) + } + { // Static Field #15 'BlobGasUsed' + dst = binary.LittleEndian.AppendUint64(dst, t.BlobGasUsed) + } + { // Static Field #16 'ExcessBlobGas' + dst = binary.LittleEndian.AppendUint64(dst, t.ExcessBlobGas) + } + { // Dynamic Field #10 'ExtraData' + binary.LittleEndian.PutUint32(dst[dstlen+436:], uint32(len(dst)-dstlen)) + vlen := len(t.ExtraData) + if vlen > 32 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 32), "ExtraData") + } + dst = append(dst, t.ExtraData[:]...) + } + return dst, nil +} + +// MarshalSSZDyn marshals the *ExecutionPayloadHeader to SSZ-encoded bytes using dynamic specifications. +func (t *ExecutionPayloadHeader) MarshalSSZDyn(_ sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + return t.MarshalSSZTo(buf) +} + +// MarshalSSZEncoder marshals the *ExecutionPayloadHeader to the given SSZ encoder using dynamic specifications. +func (t *ExecutionPayloadHeader) MarshalSSZEncoder(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + type encoderCtx struct { + ds sszutils.DynamicSpecs + exprs [0]uint64 + sizeFn1 func(ctx *encoderCtx, t []byte) (size int) + } + ctx := &encoderCtx{ds: ds} + canSeek := enc.Seekable() + // size for []byte + ctx.sizeFn1 = func(ctx *encoderCtx, t []byte) (size int) { + size += len(t) + return size + } + if t == nil { + t = new(ExecutionPayloadHeader) + } + dstlen := enc.GetPosition() + dynoff := uint32(584) + { // Field #0 'ParentHash' + enc.EncodeBytes(t.ParentHash[:32]) + } + { // Field #1 'FeeRecipient' + enc.EncodeBytes(t.FeeRecipient[:20]) + } + { // Field #2 'StateRoot' + enc.EncodeBytes(t.StateRoot[:32]) + } + { // Field #3 'ReceiptsRoot' + enc.EncodeBytes(t.ReceiptsRoot[:32]) + } + { // Field #4 'LogsBloom' + enc.EncodeBytes(t.LogsBloom[:256]) + } + { // Field #5 'PrevRandao' + enc.EncodeBytes(t.PrevRandao[:32]) + } + { // Field #6 'BlockNumber' + enc.EncodeUint64(t.BlockNumber) + } + { // Field #7 'GasLimit' + enc.EncodeUint64(t.GasLimit) + } + { // Field #8 'GasUsed' + enc.EncodeUint64(t.GasUsed) + } + { // Field #9 'Timestamp' + enc.EncodeUint64(t.Timestamp) + } + // Offset #10 'ExtraData' + offset10 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn1(ctx, t.ExtraData)) + } + { // Field #11 'BaseFeePerGas' + enc.EncodeBytes(t.BaseFeePerGas[:32]) + } + { // Field #12 'BlockHash' + enc.EncodeBytes(t.BlockHash[:32]) + } + { // Field #13 'TransactionsRoot' + enc.EncodeBytes(t.TransactionsRoot[:32]) + } + { // Field #14 'WithdrawalRoot' + enc.EncodeBytes(t.WithdrawalRoot[:32]) + } + { // Field #15 'BlobGasUsed' + enc.EncodeUint64(t.BlobGasUsed) + } + { // Field #16 'ExcessBlobGas' + enc.EncodeUint64(t.ExcessBlobGas) + } + { // Dynamic Field #10 'ExtraData' + if canSeek { + enc.EncodeOffsetAt(offset10, uint32(enc.GetPosition()-dstlen)) + } + vlen := len(t.ExtraData) + if vlen > 32 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 32), "ExtraData") + } + enc.EncodeBytes(t.ExtraData[:]) + } + return nil +} + +// UnmarshalSSZ unmarshals the *ExecutionPayloadHeader from SSZ-encoded bytes. +func (t *ExecutionPayloadHeader) UnmarshalSSZ(buf []byte) (err error) { + buflen := len(buf) + if buflen < 584 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 584) + } + { // Field #0 'ParentHash' (static) + buf := buf[0:32] + copy(t.ParentHash[:], buf) + } + { // Field #1 'FeeRecipient' (static) + buf := buf[32:52] + copy(t.FeeRecipient[:], buf) + } + { // Field #2 'StateRoot' (static) + buf := buf[52:84] + copy(t.StateRoot[:], buf) + } + { // Field #3 'ReceiptsRoot' (static) + buf := buf[84:116] + copy(t.ReceiptsRoot[:], buf) + } + { // Field #4 'LogsBloom' (static) + buf := buf[116:372] + copy(t.LogsBloom[:], buf) + } + { // Field #5 'PrevRandao' (static) + buf := buf[372:404] + copy(t.PrevRandao[:], buf) + } + { // Field #6 'BlockNumber' (static) + buf := buf[404:412] + t.BlockNumber = binary.LittleEndian.Uint64(buf) + } + { // Field #7 'GasLimit' (static) + buf := buf[412:420] + t.GasLimit = binary.LittleEndian.Uint64(buf) + } + { // Field #8 'GasUsed' (static) + buf := buf[420:428] + t.GasUsed = binary.LittleEndian.Uint64(buf) + } + { // Field #9 'Timestamp' (static) + buf := buf[428:436] + t.Timestamp = binary.LittleEndian.Uint64(buf) + } + // Field #10 'ExtraData' (offset) + offset10 := int(binary.LittleEndian.Uint32(buf[436:440])) + if offset10 != 584 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset10, 584), "ExtraData:o") + } + { // Field #11 'BaseFeePerGas' (static) + buf := buf[440:472] + copy(t.BaseFeePerGas[:], buf) + } + { // Field #12 'BlockHash' (static) + buf := buf[472:504] + copy(t.BlockHash[:], buf) + } + { // Field #13 'TransactionsRoot' (static) + buf := buf[504:536] + copy(t.TransactionsRoot[:], buf) + } + { // Field #14 'WithdrawalRoot' (static) + buf := buf[536:568] + copy(t.WithdrawalRoot[:], buf) + } + { // Field #15 'BlobGasUsed' (static) + buf := buf[568:576] + t.BlobGasUsed = binary.LittleEndian.Uint64(buf) + } + { // Field #16 'ExcessBlobGas' (static) + buf := buf[576:584] + t.ExcessBlobGas = binary.LittleEndian.Uint64(buf) + } + { // Field #10 'ExtraData' (dynamic) + buf := buf[offset10:] + if len(buf) > 32 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(len(buf), 32), "ExtraData") + } + t.ExtraData = sszutils.ExpandSlice(t.ExtraData, len(buf)) + copy(t.ExtraData[:], buf) + } + return nil +} + +// UnmarshalSSZDyn unmarshals the *ExecutionPayloadHeader from SSZ-encoded bytes using dynamic specifications. +func (t *ExecutionPayloadHeader) UnmarshalSSZDyn(_ sszutils.DynamicSpecs, buf []byte) (err error) { + return t.UnmarshalSSZ(buf) +} + +// UnmarshalSSZDecoder unmarshals the *ExecutionPayloadHeader from the given SSZ decoder using dynamic specifications. +func (t *ExecutionPayloadHeader) UnmarshalSSZDecoder(_ sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { + maxOffset := uint32(dec.GetLength()) + startPos0 := dec.GetPosition() + if maxOffset < uint32(584) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(584)) + } + // Field #0 'ParentHash' (static) + if _, err = dec.DecodeBytes(t.ParentHash[:32]); err != nil { + return err + } + // Field #1 'FeeRecipient' (static) + if _, err = dec.DecodeBytes(t.FeeRecipient[:20]); err != nil { + return err + } + // Field #2 'StateRoot' (static) + if _, err = dec.DecodeBytes(t.StateRoot[:32]); err != nil { + return err + } + // Field #3 'ReceiptsRoot' (static) + if _, err = dec.DecodeBytes(t.ReceiptsRoot[:32]); err != nil { + return err + } + // Field #4 'LogsBloom' (static) + if _, err = dec.DecodeBytes(t.LogsBloom[:256]); err != nil { + return err + } + // Field #5 'PrevRandao' (static) + if _, err = dec.DecodeBytes(t.PrevRandao[:32]); err != nil { + return err + } + // Field #6 'BlockNumber' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "BlockNumber") + } else { + t.BlockNumber = val + } + // Field #7 'GasLimit' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "GasLimit") + } else { + t.GasLimit = val + } + // Field #8 'GasUsed' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "GasUsed") + } else { + t.GasUsed = val + } + // Field #9 'Timestamp' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "Timestamp") + } else { + t.Timestamp = val + } + // Field #10 'ExtraData' (offset) + offset10, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "ExtraData") + } + if offset10 != uint32(584) { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset10, 584), "ExtraData") + } + // Field #11 'BaseFeePerGas' (static) + if _, err = dec.DecodeBytes(t.BaseFeePerGas[:32]); err != nil { + return err + } + // Field #12 'BlockHash' (static) + if _, err = dec.DecodeBytes(t.BlockHash[:32]); err != nil { + return err + } + // Field #13 'TransactionsRoot' (static) + if _, err = dec.DecodeBytes(t.TransactionsRoot[:32]); err != nil { + return err + } + // Field #14 'WithdrawalRoot' (static) + if _, err = dec.DecodeBytes(t.WithdrawalRoot[:32]); err != nil { + return err + } + // Field #15 'BlobGasUsed' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "BlobGasUsed") + } else { + t.BlobGasUsed = val + } + // Field #16 'ExcessBlobGas' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "ExcessBlobGas") + } else { + t.ExcessBlobGas = val + } + { // Field #10 'ExtraData' (dynamic) + if dec.GetPosition() != startPos0+int(offset10) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset10)), "ExtraData") + } + dec.PushLimit(int(maxOffset - offset10)) + val1 := t.ExtraData + if dec.GetLength() > 32 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(dec.GetLength(), 32), "ExtraData") + } + listLen := dec.GetLength() + val1 = sszutils.ExpandSlice(val1, listLen) + if _, err = dec.DecodeBytes(val1[:listLen]); err != nil { + return sszutils.ErrorWithPath(err, "ExtraData") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "ExtraData") + } + t.ExtraData = val1 + } + return nil +} + +// SizeSSZ returns the SSZ encoded size of the *ExecutionPayloadHeader. +func (t *ExecutionPayloadHeader) SizeSSZ() (size int) { + if t == nil { + t = new(ExecutionPayloadHeader) + } + // Field #0 'ParentHash' static (32 bytes) + // Field #1 'FeeRecipient' static (20 bytes) + // Field #2 'StateRoot' static (32 bytes) + // Field #3 'ReceiptsRoot' static (32 bytes) + // Field #4 'LogsBloom' static (256 bytes) + // Field #5 'PrevRandao' static (32 bytes) + // Field #6 'BlockNumber' static (8 bytes) + // Field #7 'GasLimit' static (8 bytes) + // Field #8 'GasUsed' static (8 bytes) + // Field #9 'Timestamp' static (8 bytes) + // Field #10 'ExtraData' offset (4 bytes) + // Field #11 'BaseFeePerGas' static (32 bytes) + // Field #12 'BlockHash' static (32 bytes) + // Field #13 'TransactionsRoot' static (32 bytes) + // Field #14 'WithdrawalRoot' static (32 bytes) + // Field #15 'BlobGasUsed' static (8 bytes) + // Field #16 'ExcessBlobGas' static (8 bytes) + size += 584 + { // Dynamic field #10 'ExtraData' + size += len(t.ExtraData) + } + return size +} + +// SizeSSZDyn returns the SSZ encoded size of the *ExecutionPayloadHeader using dynamic specifications. +func (t *ExecutionPayloadHeader) SizeSSZDyn(_ sszutils.DynamicSpecs) (size int) { + return t.SizeSSZ() +} + +// HashTreeRoot computes the SSZ hash tree root of the *ExecutionPayloadHeader. +func (t *ExecutionPayloadHeader) 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 *ExecutionPayloadHeader using the given hash walker. +func (t *ExecutionPayloadHeader) HashTreeRootWith(hh sszutils.HashWalker) error { + if t == nil { + t = new(ExecutionPayloadHeader) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'ParentHash' + hh.PutBytes(t.ParentHash[:32]) + } + { // Field #1 'FeeRecipient' + hh.PutBytes(t.FeeRecipient[:20]) + } + { // Field #2 'StateRoot' + hh.PutBytes(t.StateRoot[:32]) + } + { // Field #3 'ReceiptsRoot' + hh.PutBytes(t.ReceiptsRoot[:32]) + } + { // Field #4 'LogsBloom' + hh.PutBytes(t.LogsBloom[:256]) + } + { // Field #5 'PrevRandao' + hh.PutBytes(t.PrevRandao[:32]) + } + { // Field #6 'BlockNumber' + hh.PutUint64(t.BlockNumber) + } + { // Field #7 'GasLimit' + hh.PutUint64(t.GasLimit) + } + { // Field #8 'GasUsed' + hh.PutUint64(t.GasUsed) + } + { // Field #9 'Timestamp' + hh.PutUint64(t.Timestamp) + } + { // Field #10 'ExtraData' + vlen := uint64(len(t.ExtraData)) + if vlen > 32 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 32), "ExtraData") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + hh.AppendBytes32(t.ExtraData[:]) + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(32, vlen, 1)) + } + { // Field #11 'BaseFeePerGas' + hh.PutBytes(t.BaseFeePerGas[:32]) + } + { // Field #12 'BlockHash' + hh.PutBytes(t.BlockHash[:32]) + } + { // Field #13 'TransactionsRoot' + hh.PutBytes(t.TransactionsRoot[:32]) + } + { // Field #14 'WithdrawalRoot' + hh.PutBytes(t.WithdrawalRoot[:32]) + } + { // Field #15 'BlobGasUsed' + hh.PutUint64(t.BlobGasUsed) + } + { // Field #16 'ExcessBlobGas' + hh.PutUint64(t.ExcessBlobGas) + } + hh.Merkleize(idx) + return nil +} + +// HashTreeRootDyn computes the SSZ hash tree root of the *ExecutionPayloadHeader using dynamic specifications. +func (t *ExecutionPayloadHeader) HashTreeRootDyn(ds sszutils.DynamicSpecs) (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWithDyn(ds, hh) + if err == nil { + root, err = hh.HashRoot() + } + return + }) + return +} + +// HashTreeRootWithDyn computes the SSZ hash tree root of the *ExecutionPayloadHeader using dynamic specifications and the given hash walker. +func (t *ExecutionPayloadHeader) HashTreeRootWithDyn(_ sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + return t.HashTreeRootWith(hh) +} + +// MarshalSSZTo marshals the *PendingDeposit to SSZ-encoded bytes, appending to the provided buffer. +func (t *PendingDeposit) MarshalSSZTo(buf []byte) (dst []byte, err error) { + dst = buf + if t == nil { + t = new(PendingDeposit) + } + { // Static Field #0 'Pubkey' + vlen := len(t.Pubkey) + if vlen > 48 { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 48), "Pubkey") + } + dst = append(dst, t.Pubkey[:vlen]...) + if vlen < 48 { + dst = sszutils.AppendZeroPadding(dst, (48-vlen)*1) + } + } + { // Static Field #1 'WithdrawalCredentials' + vlen := len(t.WithdrawalCredentials) + if vlen > 32 { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 32), "WithdrawalCredentials") + } + dst = append(dst, t.WithdrawalCredentials[:vlen]...) + if vlen < 32 { + dst = sszutils.AppendZeroPadding(dst, (32-vlen)*1) + } + } + { // Static Field #2 'Amount' + dst = binary.LittleEndian.AppendUint64(dst, t.Amount) + } + { // Static Field #3 'Signature' + vlen := len(t.Signature) + if vlen > 96 { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 96), "Signature") + } + dst = append(dst, t.Signature[:vlen]...) + if vlen < 96 { + dst = sszutils.AppendZeroPadding(dst, (96-vlen)*1) + } + } + { // Static Field #4 'Slot' + dst = binary.LittleEndian.AppendUint64(dst, t.Slot) + } + return dst, nil +} + +// MarshalSSZDyn marshals the *PendingDeposit to SSZ-encoded bytes using dynamic specifications. +func (t *PendingDeposit) MarshalSSZDyn(_ sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + return t.MarshalSSZTo(buf) +} + +// MarshalSSZEncoder marshals the *PendingDeposit to the given SSZ encoder using dynamic specifications. +func (t *PendingDeposit) MarshalSSZEncoder(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + if t == nil { + t = new(PendingDeposit) + } + { // Field #0 'Pubkey' + vlen := len(t.Pubkey) + if vlen > 48 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 48), "Pubkey") + } + enc.EncodeBytes(t.Pubkey[:vlen]) + if vlen < 48 { + enc.EncodeZeroPadding((48 - vlen) * 1) + } + } + { // Field #1 'WithdrawalCredentials' + vlen := len(t.WithdrawalCredentials) + if vlen > 32 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 32), "WithdrawalCredentials") + } + enc.EncodeBytes(t.WithdrawalCredentials[:vlen]) + if vlen < 32 { + enc.EncodeZeroPadding((32 - vlen) * 1) + } + } + { // Field #2 'Amount' + enc.EncodeUint64(t.Amount) + } + { // Field #3 'Signature' + vlen := len(t.Signature) + if vlen > 96 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 96), "Signature") + } + enc.EncodeBytes(t.Signature[:vlen]) + if vlen < 96 { + enc.EncodeZeroPadding((96 - vlen) * 1) + } + } + { // Field #4 'Slot' + enc.EncodeUint64(t.Slot) + } + return nil +} + +// UnmarshalSSZ unmarshals the *PendingDeposit from SSZ-encoded bytes. +func (t *PendingDeposit) UnmarshalSSZ(buf []byte) (err error) { + buflen := len(buf) + if buflen < 192 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 192) + } + if buflen > 192 { + return sszutils.ErrTrailingDataFn(buflen - 192) + } + { // Field #0 'Pubkey' (static) + buf := buf[0:48] + t.Pubkey = sszutils.ExpandSlice(t.Pubkey, 48) + copy(t.Pubkey[:], buf) + } + { // Field #1 'WithdrawalCredentials' (static) + buf := buf[48:80] + t.WithdrawalCredentials = sszutils.ExpandSlice(t.WithdrawalCredentials, 32) + copy(t.WithdrawalCredentials[:], buf) + } + { // Field #2 'Amount' (static) + buf := buf[80:88] + t.Amount = binary.LittleEndian.Uint64(buf) + } + { // Field #3 'Signature' (static) + buf := buf[88:184] + t.Signature = sszutils.ExpandSlice(t.Signature, 96) + copy(t.Signature[:], buf) + } + { // Field #4 'Slot' (static) + buf := buf[184:192] + t.Slot = binary.LittleEndian.Uint64(buf) + } + return nil +} + +// UnmarshalSSZDyn unmarshals the *PendingDeposit from SSZ-encoded bytes using dynamic specifications. +func (t *PendingDeposit) UnmarshalSSZDyn(_ sszutils.DynamicSpecs, buf []byte) (err error) { + return t.UnmarshalSSZ(buf) +} + +// UnmarshalSSZDecoder unmarshals the *PendingDeposit from the given SSZ decoder using dynamic specifications. +func (t *PendingDeposit) UnmarshalSSZDecoder(_ sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { + maxOffset := uint32(dec.GetLength()) + if maxOffset < uint32(192) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(192)) + } + // Field #0 'Pubkey' (static) + t.Pubkey = sszutils.ExpandSlice(t.Pubkey, 48) + if _, err = dec.DecodeBytes(t.Pubkey[:48]); err != nil { + return err + } + // Field #1 'WithdrawalCredentials' (static) + t.WithdrawalCredentials = sszutils.ExpandSlice(t.WithdrawalCredentials, 32) + if _, err = dec.DecodeBytes(t.WithdrawalCredentials[:32]); err != nil { + return err + } + // Field #2 'Amount' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "Amount") + } else { + t.Amount = val + } + // Field #3 'Signature' (static) + t.Signature = sszutils.ExpandSlice(t.Signature, 96) + if _, err = dec.DecodeBytes(t.Signature[:96]); err != nil { + return err + } + // Field #4 'Slot' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "Slot") + } else { + t.Slot = val + } + return nil +} + +// SizeSSZ returns the SSZ encoded size of the *PendingDeposit. +func (t *PendingDeposit) SizeSSZ() (size int) { + return 192 +} + +// SizeSSZDyn returns the SSZ encoded size of the *PendingDeposit using dynamic specifications. +func (t *PendingDeposit) SizeSSZDyn(_ sszutils.DynamicSpecs) (size int) { + return t.SizeSSZ() +} + +// HashTreeRoot computes the SSZ hash tree root of the *PendingDeposit. +func (t *PendingDeposit) 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 *PendingDeposit using the given hash walker. +func (t *PendingDeposit) HashTreeRootWith(hh sszutils.HashWalker) error { + if t == nil { + t = new(PendingDeposit) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Pubkey' + vlen := len(t.Pubkey) + if vlen > 48 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 48), "Pubkey") + } + val := t.Pubkey[:] + if vlen < 48 { + val = sszutils.AppendZeroPadding(val, (48-vlen)*1) + } + hh.PutBytes(val[:48]) + } + { // Field #1 'WithdrawalCredentials' + vlen := len(t.WithdrawalCredentials) + if vlen > 32 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 32), "WithdrawalCredentials") + } + val := t.WithdrawalCredentials[:] + if vlen < 32 { + val = sszutils.AppendZeroPadding(val, (32-vlen)*1) + } + hh.PutBytes(val[:32]) + } + { // Field #2 'Amount' + hh.PutUint64(t.Amount) + } + { // Field #3 'Signature' + vlen := len(t.Signature) + if vlen > 96 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 96), "Signature") + } + val := t.Signature[:] + if vlen < 96 { + val = sszutils.AppendZeroPadding(val, (96-vlen)*1) + } + hh.PutBytes(val[:96]) + } + { // Field #4 'Slot' + hh.PutUint64(t.Slot) + } + hh.Merkleize(idx) + return nil +} + +// HashTreeRootDyn computes the SSZ hash tree root of the *PendingDeposit using dynamic specifications. +func (t *PendingDeposit) HashTreeRootDyn(ds sszutils.DynamicSpecs) (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWithDyn(ds, hh) + if err == nil { + root, err = hh.HashRoot() + } + return + }) + return +} + +// HashTreeRootWithDyn computes the SSZ hash tree root of the *PendingDeposit using dynamic specifications and the given hash walker. +func (t *PendingDeposit) HashTreeRootWithDyn(_ sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + return t.HashTreeRootWith(hh) +} + +// MarshalSSZTo marshals the *PendingPartialWithdrawal to SSZ-encoded bytes, appending to the provided buffer. +func (t *PendingPartialWithdrawal) MarshalSSZTo(buf []byte) (dst []byte, err error) { + dst = buf + if t == nil { + t = new(PendingPartialWithdrawal) + } + { // Static Field #0 'ValidatorIndex' + dst = binary.LittleEndian.AppendUint64(dst, t.ValidatorIndex) + } + { // Static Field #1 'Amount' + dst = binary.LittleEndian.AppendUint64(dst, t.Amount) + } + { // Static Field #2 'WithdrawableEpoch' + dst = binary.LittleEndian.AppendUint64(dst, t.WithdrawableEpoch) + } + return dst, nil +} + +// MarshalSSZDyn marshals the *PendingPartialWithdrawal to SSZ-encoded bytes using dynamic specifications. +func (t *PendingPartialWithdrawal) MarshalSSZDyn(_ sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + return t.MarshalSSZTo(buf) +} + +// MarshalSSZEncoder marshals the *PendingPartialWithdrawal to the given SSZ encoder using dynamic specifications. +func (t *PendingPartialWithdrawal) MarshalSSZEncoder(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + if t == nil { + t = new(PendingPartialWithdrawal) + } + { // Field #0 'ValidatorIndex' + enc.EncodeUint64(t.ValidatorIndex) + } + { // Field #1 'Amount' + enc.EncodeUint64(t.Amount) + } + { // Field #2 'WithdrawableEpoch' + enc.EncodeUint64(t.WithdrawableEpoch) + } + return nil +} + +// UnmarshalSSZ unmarshals the *PendingPartialWithdrawal from SSZ-encoded bytes. +func (t *PendingPartialWithdrawal) UnmarshalSSZ(buf []byte) (err error) { + buflen := len(buf) + if buflen < 24 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 24) + } + if buflen > 24 { + return sszutils.ErrTrailingDataFn(buflen - 24) + } + { // Field #0 'ValidatorIndex' (static) + buf := buf[0:8] + t.ValidatorIndex = binary.LittleEndian.Uint64(buf) + } + { // Field #1 'Amount' (static) + buf := buf[8:16] + t.Amount = binary.LittleEndian.Uint64(buf) + } + { // Field #2 'WithdrawableEpoch' (static) + buf := buf[16:24] + t.WithdrawableEpoch = binary.LittleEndian.Uint64(buf) + } + return nil +} + +// UnmarshalSSZDyn unmarshals the *PendingPartialWithdrawal from SSZ-encoded bytes using dynamic specifications. +func (t *PendingPartialWithdrawal) UnmarshalSSZDyn(_ sszutils.DynamicSpecs, buf []byte) (err error) { + return t.UnmarshalSSZ(buf) +} + +// UnmarshalSSZDecoder unmarshals the *PendingPartialWithdrawal from the given SSZ decoder using dynamic specifications. +func (t *PendingPartialWithdrawal) UnmarshalSSZDecoder(_ sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { + maxOffset := uint32(dec.GetLength()) + if maxOffset < uint32(24) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(24)) + } + // Field #0 'ValidatorIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "ValidatorIndex") + } else { + t.ValidatorIndex = val + } + // Field #1 'Amount' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "Amount") + } else { + t.Amount = val + } + // Field #2 'WithdrawableEpoch' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "WithdrawableEpoch") + } else { + t.WithdrawableEpoch = val + } + return nil +} + +// SizeSSZ returns the SSZ encoded size of the *PendingPartialWithdrawal. +func (t *PendingPartialWithdrawal) SizeSSZ() (size int) { + return 24 +} + +// SizeSSZDyn returns the SSZ encoded size of the *PendingPartialWithdrawal using dynamic specifications. +func (t *PendingPartialWithdrawal) SizeSSZDyn(_ sszutils.DynamicSpecs) (size int) { + return t.SizeSSZ() +} + +// HashTreeRoot computes the SSZ hash tree root of the *PendingPartialWithdrawal. +func (t *PendingPartialWithdrawal) 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 *PendingPartialWithdrawal using the given hash walker. +func (t *PendingPartialWithdrawal) HashTreeRootWith(hh sszutils.HashWalker) error { + if t == nil { + t = new(PendingPartialWithdrawal) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'ValidatorIndex' + hh.PutUint64(t.ValidatorIndex) + } + { // Field #1 'Amount' + hh.PutUint64(t.Amount) + } + { // Field #2 'WithdrawableEpoch' + hh.PutUint64(t.WithdrawableEpoch) + } + hh.Merkleize(idx) + return nil +} + +// HashTreeRootDyn computes the SSZ hash tree root of the *PendingPartialWithdrawal using dynamic specifications. +func (t *PendingPartialWithdrawal) HashTreeRootDyn(ds sszutils.DynamicSpecs) (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWithDyn(ds, hh) + if err == nil { + root, err = hh.HashRoot() + } + return + }) + return +} + +// HashTreeRootWithDyn computes the SSZ hash tree root of the *PendingPartialWithdrawal using dynamic specifications and the given hash walker. +func (t *PendingPartialWithdrawal) HashTreeRootWithDyn(_ sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + return t.HashTreeRootWith(hh) +} + +// MarshalSSZTo marshals the *PendingConsolidation to SSZ-encoded bytes, appending to the provided buffer. +func (t *PendingConsolidation) MarshalSSZTo(buf []byte) (dst []byte, err error) { + dst = buf + if t == nil { + t = new(PendingConsolidation) + } + { // Static Field #0 'SourceIndex' + dst = binary.LittleEndian.AppendUint64(dst, t.SourceIndex) + } + { // Static Field #1 'TargetIndex' + dst = binary.LittleEndian.AppendUint64(dst, t.TargetIndex) + } + return dst, nil +} + +// MarshalSSZDyn marshals the *PendingConsolidation to SSZ-encoded bytes using dynamic specifications. +func (t *PendingConsolidation) MarshalSSZDyn(_ sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + return t.MarshalSSZTo(buf) +} + +// MarshalSSZEncoder marshals the *PendingConsolidation to the given SSZ encoder using dynamic specifications. +func (t *PendingConsolidation) MarshalSSZEncoder(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + if t == nil { + t = new(PendingConsolidation) + } + { // Field #0 'SourceIndex' + enc.EncodeUint64(t.SourceIndex) + } + { // Field #1 'TargetIndex' + enc.EncodeUint64(t.TargetIndex) + } + return nil +} + +// UnmarshalSSZ unmarshals the *PendingConsolidation from SSZ-encoded bytes. +func (t *PendingConsolidation) UnmarshalSSZ(buf []byte) (err error) { + buflen := len(buf) + if buflen < 16 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 16) + } + if buflen > 16 { + return sszutils.ErrTrailingDataFn(buflen - 16) + } + { // Field #0 'SourceIndex' (static) + buf := buf[0:8] + t.SourceIndex = binary.LittleEndian.Uint64(buf) + } + { // Field #1 'TargetIndex' (static) + buf := buf[8:16] + t.TargetIndex = binary.LittleEndian.Uint64(buf) + } + return nil +} + +// UnmarshalSSZDyn unmarshals the *PendingConsolidation from SSZ-encoded bytes using dynamic specifications. +func (t *PendingConsolidation) UnmarshalSSZDyn(_ sszutils.DynamicSpecs, buf []byte) (err error) { + return t.UnmarshalSSZ(buf) +} + +// UnmarshalSSZDecoder unmarshals the *PendingConsolidation from the given SSZ decoder using dynamic specifications. +func (t *PendingConsolidation) UnmarshalSSZDecoder(_ sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { + maxOffset := uint32(dec.GetLength()) + if maxOffset < uint32(16) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(16)) + } + // Field #0 'SourceIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "SourceIndex") + } else { + t.SourceIndex = val + } + // Field #1 'TargetIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "TargetIndex") + } else { + t.TargetIndex = val + } + return nil +} + +// SizeSSZ returns the SSZ encoded size of the *PendingConsolidation. +func (t *PendingConsolidation) SizeSSZ() (size int) { + return 16 +} + +// SizeSSZDyn returns the SSZ encoded size of the *PendingConsolidation using dynamic specifications. +func (t *PendingConsolidation) SizeSSZDyn(_ sszutils.DynamicSpecs) (size int) { + return t.SizeSSZ() +} + +// HashTreeRoot computes the SSZ hash tree root of the *PendingConsolidation. +func (t *PendingConsolidation) 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 *PendingConsolidation using the given hash walker. +func (t *PendingConsolidation) HashTreeRootWith(hh sszutils.HashWalker) error { + if t == nil { + t = new(PendingConsolidation) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'SourceIndex' + hh.PutUint64(t.SourceIndex) + } + { // Field #1 'TargetIndex' + hh.PutUint64(t.TargetIndex) + } + hh.Merkleize(idx) + return nil +} + +// HashTreeRootDyn computes the SSZ hash tree root of the *PendingConsolidation using dynamic specifications. +func (t *PendingConsolidation) HashTreeRootDyn(ds sszutils.DynamicSpecs) (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWithDyn(ds, hh) + if err == nil { + root, err = hh.HashRoot() + } + return + }) + return +} + +// HashTreeRootWithDyn computes the SSZ hash tree root of the *PendingConsolidation using dynamic specifications and the given hash walker. +func (t *PendingConsolidation) HashTreeRootWithDyn(_ sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + return t.HashTreeRootWith(hh) +} + +// MarshalSSZDyn marshals the *ProposerSlashing to SSZ-encoded bytes using dynamic specifications. +func (t *ProposerSlashing) MarshalSSZDyn(ds sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + dst = buf + if t == nil { + t = new(ProposerSlashing) + } + { // Static Field #0 'Header1' + t := t.Header1 + if t == nil { + t = new(SignedBeaconBlockHeader) + } + if dst, err = t.MarshalSSZDyn(ds, dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "Header1") + } + } + { // Static Field #1 'Header2' + t := t.Header2 + if t == nil { + t = new(SignedBeaconBlockHeader) + } + if dst, err = t.MarshalSSZDyn(ds, dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "Header2") + } + } + return dst, nil +} + +// MarshalSSZEncoder marshals the *ProposerSlashing to the given SSZ encoder using dynamic specifications. +func (t *ProposerSlashing) MarshalSSZEncoder(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + if t == nil { + t = new(ProposerSlashing) + } + { // Field #0 'Header1' + t := t.Header1 + if t == nil { + t = new(SignedBeaconBlockHeader) + } + if err = t.MarshalSSZEncoder(ds, enc); err != nil { + return sszutils.ErrorWithPath(err, "Header1") + } + } + { // Field #1 'Header2' + t := t.Header2 + if t == nil { + t = new(SignedBeaconBlockHeader) + } + if err = t.MarshalSSZEncoder(ds, enc); err != nil { + return sszutils.ErrorWithPath(err, "Header2") + } + } + return nil +} + +// UnmarshalSSZDyn unmarshals the *ProposerSlashing from SSZ-encoded bytes using dynamic specifications. +func (t *ProposerSlashing) UnmarshalSSZDyn(ds sszutils.DynamicSpecs, buf []byte) (err error) { + buflen := len(buf) + if buflen < 416 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 416) + } + if buflen > 416 { + return sszutils.ErrTrailingDataFn(buflen - 416) + } + { // Field #0 'Header1' (static) + buf := buf[0:208] + if t.Header1 == nil { + t.Header1 = new(SignedBeaconBlockHeader) + } + if err = t.Header1.UnmarshalSSZDyn(ds, buf); err != nil { + return sszutils.ErrorWithPath(err, "Header1") + } + } + { // Field #1 'Header2' (static) + buf := buf[208:416] + if t.Header2 == nil { + t.Header2 = new(SignedBeaconBlockHeader) + } + if err = t.Header2.UnmarshalSSZDyn(ds, buf); err != nil { + return sszutils.ErrorWithPath(err, "Header2") + } + } + return nil +} + +// UnmarshalSSZDecoder unmarshals the *ProposerSlashing from the given SSZ decoder using dynamic specifications. +func (t *ProposerSlashing) UnmarshalSSZDecoder(ds sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { + maxOffset := uint32(dec.GetLength()) + if maxOffset < uint32(416) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(416)) + } + // Field #0 'Header1' (static) + if t.Header1 == nil { + t.Header1 = new(SignedBeaconBlockHeader) + } + if err = t.Header1.UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPath(err, "Header1") + } + // Field #1 'Header2' (static) + if t.Header2 == nil { + t.Header2 = new(SignedBeaconBlockHeader) + } + if err = t.Header2.UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPath(err, "Header2") + } + return nil +} + +// SizeSSZ returns the SSZ encoded size of the *ProposerSlashing. +func (t *ProposerSlashing) SizeSSZ() (size int) { + return 416 +} + +// SizeSSZDyn returns the SSZ encoded size of the *ProposerSlashing using dynamic specifications. +func (t *ProposerSlashing) SizeSSZDyn(_ sszutils.DynamicSpecs) (size int) { + return t.SizeSSZ() +} + +// HashTreeRootDyn computes the SSZ hash tree root of the *ProposerSlashing using dynamic specifications. +func (t *ProposerSlashing) HashTreeRootDyn(ds sszutils.DynamicSpecs) (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWithDyn(ds, hh) + if err == nil { + root, err = hh.HashRoot() + } + return + }) + return +} + +// HashTreeRootWithDyn computes the SSZ hash tree root of the *ProposerSlashing using dynamic specifications and the given hash walker. +func (t *ProposerSlashing) HashTreeRootWithDyn(ds sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + if t == nil { + t = new(ProposerSlashing) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Header1' + t := t.Header1 + if t == nil { + t = new(SignedBeaconBlockHeader) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPath(err, "Header1") + } + } + { // Field #1 'Header2' + t := t.Header2 + if t == nil { + t = new(SignedBeaconBlockHeader) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPath(err, "Header2") + } + } + hh.Merkleize(idx) + return nil +} + +// MarshalSSZDyn marshals the *SignedBeaconBlockHeader to SSZ-encoded bytes using dynamic specifications. +func (t *SignedBeaconBlockHeader) MarshalSSZDyn(ds sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + dst = buf + if t == nil { + t = new(SignedBeaconBlockHeader) + } + { // Static Field #0 'Header' + t := t.Header + if t == nil { + t = new(BeaconBlockHeader) + } + if dst, err = t.MarshalSSZDyn(ds, dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "Header") + } + } + { // Static Field #1 'Signature' + vlen := len(t.Signature) + if vlen > 96 { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 96), "Signature") + } + dst = append(dst, t.Signature[:vlen]...) + if vlen < 96 { + dst = sszutils.AppendZeroPadding(dst, (96-vlen)*1) + } + } + return dst, nil +} + +// MarshalSSZEncoder marshals the *SignedBeaconBlockHeader to the given SSZ encoder using dynamic specifications. +func (t *SignedBeaconBlockHeader) MarshalSSZEncoder(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + if t == nil { + t = new(SignedBeaconBlockHeader) + } + { // Field #0 'Header' + t := t.Header + if t == nil { + t = new(BeaconBlockHeader) + } + if err = t.MarshalSSZEncoder(ds, enc); err != nil { + return sszutils.ErrorWithPath(err, "Header") + } + } + { // Field #1 'Signature' + vlen := len(t.Signature) + if vlen > 96 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 96), "Signature") + } + enc.EncodeBytes(t.Signature[:vlen]) + if vlen < 96 { + enc.EncodeZeroPadding((96 - vlen) * 1) + } + } + return nil +} + +// UnmarshalSSZDyn unmarshals the *SignedBeaconBlockHeader from SSZ-encoded bytes using dynamic specifications. +func (t *SignedBeaconBlockHeader) UnmarshalSSZDyn(ds sszutils.DynamicSpecs, buf []byte) (err error) { + buflen := len(buf) + if buflen < 208 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 208) + } + if buflen > 208 { + return sszutils.ErrTrailingDataFn(buflen - 208) + } + { // Field #0 'Header' (static) + buf := buf[0:112] + if t.Header == nil { + t.Header = new(BeaconBlockHeader) + } + if err = t.Header.UnmarshalSSZDyn(ds, buf); err != nil { + return sszutils.ErrorWithPath(err, "Header") + } + } + { // Field #1 'Signature' (static) + buf := buf[112:208] + t.Signature = sszutils.ExpandSlice(t.Signature, 96) + copy(t.Signature[:], buf) + } + return nil +} + +// UnmarshalSSZDecoder unmarshals the *SignedBeaconBlockHeader from the given SSZ decoder using dynamic specifications. +func (t *SignedBeaconBlockHeader) UnmarshalSSZDecoder(ds sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { + maxOffset := uint32(dec.GetLength()) + if maxOffset < uint32(208) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(208)) + } + // Field #0 'Header' (static) + if t.Header == nil { + t.Header = new(BeaconBlockHeader) + } + if err = t.Header.UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPath(err, "Header") + } + // Field #1 'Signature' (static) + t.Signature = sszutils.ExpandSlice(t.Signature, 96) + if _, err = dec.DecodeBytes(t.Signature[:96]); err != nil { + return err + } + return nil +} + +// SizeSSZ returns the SSZ encoded size of the *SignedBeaconBlockHeader. +func (t *SignedBeaconBlockHeader) SizeSSZ() (size int) { + return 208 +} + +// SizeSSZDyn returns the SSZ encoded size of the *SignedBeaconBlockHeader using dynamic specifications. +func (t *SignedBeaconBlockHeader) SizeSSZDyn(_ sszutils.DynamicSpecs) (size int) { + return t.SizeSSZ() +} + +// HashTreeRootDyn computes the SSZ hash tree root of the *SignedBeaconBlockHeader using dynamic specifications. +func (t *SignedBeaconBlockHeader) HashTreeRootDyn(ds sszutils.DynamicSpecs) (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWithDyn(ds, hh) + if err == nil { + root, err = hh.HashRoot() + } + return + }) + return +} + +// HashTreeRootWithDyn computes the SSZ hash tree root of the *SignedBeaconBlockHeader using dynamic specifications and the given hash walker. +func (t *SignedBeaconBlockHeader) HashTreeRootWithDyn(ds sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + if t == nil { + t = new(SignedBeaconBlockHeader) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Header' + t := t.Header + if t == nil { + t = new(BeaconBlockHeader) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPath(err, "Header") + } + } + { // Field #1 'Signature' + vlen := len(t.Signature) + if vlen > 96 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 96), "Signature") + } + val := t.Signature[:] + if vlen < 96 { + val = sszutils.AppendZeroPadding(val, (96-vlen)*1) + } + hh.PutBytes(val[:96]) + } + hh.Merkleize(idx) + return nil +} + +// MarshalSSZDyn marshals the *AttesterSlashing to SSZ-encoded bytes using dynamic specifications. +func (t *AttesterSlashing) MarshalSSZDyn(ds sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + dst = buf + if t == nil { + t = new(AttesterSlashing) + } + dstlen := len(dst) + // Offset Field #0 'Attestation1' + // Offset Field #1 'Attestation2' + dst = append(dst, 0, 0, 0, 0, 0, 0, 0, 0) + { // Dynamic Field #0 'Attestation1' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.Attestation1 + if t == nil { + t = new(IndexedAttestation) + } + if dst, err = t.MarshalSSZDyn(ds, dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "Attestation1") + } + } + { // Dynamic Field #1 'Attestation2' + binary.LittleEndian.PutUint32(dst[dstlen+4:], uint32(len(dst)-dstlen)) + t := t.Attestation2 + if t == nil { + t = new(IndexedAttestation) + } + if dst, err = t.MarshalSSZDyn(ds, dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "Attestation2") + } + } + return dst, nil +} + +// MarshalSSZEncoder marshals the *AttesterSlashing to the given SSZ encoder using dynamic specifications. +func (t *AttesterSlashing) MarshalSSZEncoder(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + type encoderCtx struct { + ds sszutils.DynamicSpecs + exprs [0]uint64 + sizeFn1 func(ctx *encoderCtx, t *IndexedAttestation) (size int) + } + ctx := &encoderCtx{ds: ds} + canSeek := enc.Seekable() + // size for *IndexedAttestation + ctx.sizeFn1 = func(ctx *encoderCtx, t *IndexedAttestation) (size int) { + size += t.SizeSSZDyn(ds) + return size + } + if t == nil { + t = new(AttesterSlashing) + } + dstlen := enc.GetPosition() + dynoff := uint32(8) + // Offset #0 'Attestation1' + offset0 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn1(ctx, t.Attestation1)) + } + // Offset #1 'Attestation2' + offset1 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn1(ctx, t.Attestation2)) + } + { // Dynamic Field #0 'Attestation1' + if canSeek { + enc.EncodeOffsetAt(offset0, uint32(enc.GetPosition()-dstlen)) + } + t := t.Attestation1 + if t == nil { + t = new(IndexedAttestation) + } + if err = t.MarshalSSZEncoder(ds, enc); err != nil { + return sszutils.ErrorWithPath(err, "Attestation1") + } + } + { // Dynamic Field #1 'Attestation2' + if canSeek { + enc.EncodeOffsetAt(offset1, uint32(enc.GetPosition()-dstlen)) + } + t := t.Attestation2 + if t == nil { + t = new(IndexedAttestation) + } + if err = t.MarshalSSZEncoder(ds, enc); err != nil { + return sszutils.ErrorWithPath(err, "Attestation2") + } + } + return nil +} + +// UnmarshalSSZDyn unmarshals the *AttesterSlashing from SSZ-encoded bytes using dynamic specifications. +func (t *AttesterSlashing) UnmarshalSSZDyn(ds sszutils.DynamicSpecs, buf []byte) (err error) { + buflen := len(buf) + if buflen < 8 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 8) + } + // Field #0 'Attestation1' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 8 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset0, 8), "Attestation1:o") + } + // Field #1 'Attestation2' (offset) + offset1 := int(binary.LittleEndian.Uint32(buf[4:8])) + if offset1 < offset0 || offset1 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset1, offset0, buflen), "Attestation2:o") + } + { // Field #0 'Attestation1' (dynamic) + buf := buf[offset0:offset1] + if t.Attestation1 == nil { + t.Attestation1 = new(IndexedAttestation) + } + if err = t.Attestation1.UnmarshalSSZDyn(ds, buf); err != nil { + return sszutils.ErrorWithPath(err, "Attestation1") + } + } + { // Field #1 'Attestation2' (dynamic) + buf := buf[offset1:] + if t.Attestation2 == nil { + t.Attestation2 = new(IndexedAttestation) + } + if err = t.Attestation2.UnmarshalSSZDyn(ds, buf); err != nil { + return sszutils.ErrorWithPath(err, "Attestation2") + } + } + return nil +} + +// UnmarshalSSZDecoder unmarshals the *AttesterSlashing from the given SSZ decoder using dynamic specifications. +func (t *AttesterSlashing) UnmarshalSSZDecoder(ds sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { + maxOffset := uint32(dec.GetLength()) + startPos0 := dec.GetPosition() + if maxOffset < uint32(8) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(8)) + } + // Field #0 'Attestation1' (offset) + offset0, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Attestation1") + } + if offset0 != uint32(8) { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset0, 8), "Attestation1") + } + // Field #1 'Attestation2' (offset) + offset1, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Attestation2") + } + if offset1 < offset0 || offset1 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset1, offset0, maxOffset), "Attestation2") + } + { // Field #0 'Attestation1' (dynamic) + if dec.GetPosition() != startPos0+int(offset0) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset0)), "Attestation1") + } + dec.PushLimit(int(offset1 - offset0)) + val1 := t.Attestation1 + if val1 == nil { + val1 = new(IndexedAttestation) + } + if err = val1.UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPath(err, "Attestation1") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Attestation1") + } + t.Attestation1 = val1 + } + { // Field #1 'Attestation2' (dynamic) + if dec.GetPosition() != startPos0+int(offset1) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset1)), "Attestation2") + } + dec.PushLimit(int(maxOffset - offset1)) + val2 := t.Attestation2 + if val2 == nil { + val2 = new(IndexedAttestation) + } + if err = val2.UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPath(err, "Attestation2") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Attestation2") + } + t.Attestation2 = val2 + } + return nil +} + +// SizeSSZDyn returns the SSZ encoded size of the *AttesterSlashing using dynamic specifications. +func (t *AttesterSlashing) SizeSSZDyn(ds sszutils.DynamicSpecs) (size int) { + if t == nil { + t = new(AttesterSlashing) + } + // Field #0 'Attestation1' offset (4 bytes) + // Field #1 'Attestation2' offset (4 bytes) + size += 8 + { // Dynamic field #0 'Attestation1' + size += t.Attestation1.SizeSSZDyn(ds) + } + { // Dynamic field #1 'Attestation2' + size += t.Attestation2.SizeSSZDyn(ds) + } + return size +} + +// HashTreeRootDyn computes the SSZ hash tree root of the *AttesterSlashing using dynamic specifications. +func (t *AttesterSlashing) HashTreeRootDyn(ds sszutils.DynamicSpecs) (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWithDyn(ds, hh) + if err == nil { + root, err = hh.HashRoot() + } + return + }) + return +} + +// HashTreeRootWithDyn computes the SSZ hash tree root of the *AttesterSlashing using dynamic specifications and the given hash walker. +func (t *AttesterSlashing) HashTreeRootWithDyn(ds sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + if t == nil { + t = new(AttesterSlashing) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Attestation1' + t := t.Attestation1 + if t == nil { + t = new(IndexedAttestation) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPath(err, "Attestation1") + } + } + { // Field #1 'Attestation2' + t := t.Attestation2 + if t == nil { + t = new(IndexedAttestation) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPath(err, "Attestation2") + } + } + hh.Merkleize(idx) + return nil +} + +// MarshalSSZDyn marshals the *IndexedAttestation to SSZ-encoded bytes using dynamic specifications. +func (t *IndexedAttestation) MarshalSSZDyn(ds sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + dst = buf + if t == nil { + t = new(IndexedAttestation) + } + dstlen := len(dst) + // Offset Field #0 'AttestationIndices' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #1 'Data' + t := t.Data + if t == nil { + t = new(AttestationData) + } + if dst, err = t.MarshalSSZDyn(ds, dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "Data") + } + } + { // Static Field #2 'Signature' + vlen := len(t.Signature) + if vlen > 96 { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 96), "Signature") + } + dst = append(dst, t.Signature[:vlen]...) + if vlen < 96 { + dst = sszutils.AppendZeroPadding(dst, (96-vlen)*1) + } + } + { // Dynamic Field #0 'AttestationIndices' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.AttestationIndices + vlen := len(t) + if vlen > 2048 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 2048), "AttestationIndices") + } + dst = sszutils.MarshalUint64Slice(dst, t[:vlen]) + } + return dst, nil +} + +// MarshalSSZEncoder marshals the *IndexedAttestation to the given SSZ encoder using dynamic specifications. +func (t *IndexedAttestation) MarshalSSZEncoder(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + type encoderCtx struct { + ds sszutils.DynamicSpecs + exprs [0]uint64 + sizeFn1 func(ctx *encoderCtx, t []uint64) (size int) + } + ctx := &encoderCtx{ds: ds} + canSeek := enc.Seekable() + // size for []uint64 + ctx.sizeFn1 = func(ctx *encoderCtx, t []uint64) (size int) { + size += len(t) * 8 + return size + } + if t == nil { + t = new(IndexedAttestation) + } + dstlen := enc.GetPosition() + dynoff := uint32(228) + // Offset #0 'AttestationIndices' + offset0 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn1(ctx, t.AttestationIndices)) + } + { // Field #1 'Data' + t := t.Data + if t == nil { + t = new(AttestationData) + } + if err = t.MarshalSSZEncoder(ds, enc); err != nil { + return sszutils.ErrorWithPath(err, "Data") + } + } + { // Field #2 'Signature' + vlen := len(t.Signature) + if vlen > 96 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 96), "Signature") + } + enc.EncodeBytes(t.Signature[:vlen]) + if vlen < 96 { + enc.EncodeZeroPadding((96 - vlen) * 1) + } + } + { // Dynamic Field #0 'AttestationIndices' + if canSeek { + enc.EncodeOffsetAt(offset0, uint32(enc.GetPosition()-dstlen)) + } + t := t.AttestationIndices + vlen := len(t) + if vlen > 2048 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 2048), "AttestationIndices") + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + } + return nil +} + +// UnmarshalSSZDyn unmarshals the *IndexedAttestation from SSZ-encoded bytes using dynamic specifications. +func (t *IndexedAttestation) UnmarshalSSZDyn(ds sszutils.DynamicSpecs, buf []byte) (err error) { + buflen := len(buf) + if buflen < 228 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 228) + } + // Field #0 'AttestationIndices' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 228 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset0, 228), "AttestationIndices:o") + } + { // Field #1 'Data' (static) + buf := buf[4:132] + if t.Data == nil { + t.Data = new(AttestationData) + } + if err = t.Data.UnmarshalSSZDyn(ds, buf); err != nil { + return sszutils.ErrorWithPath(err, "Data") + } + } + { // Field #2 'Signature' (static) + buf := buf[132:228] + t.Signature = sszutils.ExpandSlice(t.Signature, 96) + copy(t.Signature[:], buf) + } + { // Field #0 'AttestationIndices' (dynamic) + buf := buf[offset0:] + val1 := t.AttestationIndices + itemCount := len(buf) / 8 + if len(buf)%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 8), "AttestationIndices") + } + if itemCount > 2048 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 2048), "AttestationIndices") + } + val1 = sszutils.ExpandSlice(val1, itemCount) + sszutils.UnmarshalUint64Slice(val1, buf) + t.AttestationIndices = val1 + } + return nil +} + +// UnmarshalSSZDecoder unmarshals the *IndexedAttestation from the given SSZ decoder using dynamic specifications. +func (t *IndexedAttestation) UnmarshalSSZDecoder(ds sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { + maxOffset := uint32(dec.GetLength()) + startPos0 := dec.GetPosition() + if maxOffset < uint32(228) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(228)) + } + // Field #0 'AttestationIndices' (offset) + offset0, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "AttestationIndices") + } + if offset0 != uint32(228) { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset0, 228), "AttestationIndices") + } + // Field #1 'Data' (static) + if t.Data == nil { + t.Data = new(AttestationData) + } + if err = t.Data.UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPath(err, "Data") + } + // Field #2 'Signature' (static) + t.Signature = sszutils.ExpandSlice(t.Signature, 96) + if _, err = dec.DecodeBytes(t.Signature[:96]); err != nil { + return err + } + { // Field #0 'AttestationIndices' (dynamic) + if dec.GetPosition() != startPos0+int(offset0) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset0)), "AttestationIndices") + } + dec.PushLimit(int(maxOffset - offset0)) + val1 := t.AttestationIndices + sszLen := dec.GetLength() + itemCount := sszLen / 8 + if sszLen%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 8), "AttestationIndices") + } + if itemCount > 2048 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 2048), "AttestationIndices") + } + val1 = sszutils.ExpandSlice(val1, itemCount) + if err = sszutils.DecodeUint64Slice(dec, val1); err != nil { + return sszutils.ErrorWithPath(err, "AttestationIndices") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "AttestationIndices") + } + t.AttestationIndices = val1 + } + return nil +} + +// SizeSSZ returns the SSZ encoded size of the *IndexedAttestation. +func (t *IndexedAttestation) SizeSSZ() (size int) { + if t == nil { + t = new(IndexedAttestation) + } + // Field #0 'AttestationIndices' offset (4 bytes) + // Field #1 'Data' static (128 bytes) + // Field #2 'Signature' static (96 bytes) + size += 228 + { // Dynamic field #0 'AttestationIndices' + size += len(t.AttestationIndices) * 8 + } + return size +} + +// SizeSSZDyn returns the SSZ encoded size of the *IndexedAttestation using dynamic specifications. +func (t *IndexedAttestation) SizeSSZDyn(_ sszutils.DynamicSpecs) (size int) { + return t.SizeSSZ() +} + +// HashTreeRootDyn computes the SSZ hash tree root of the *IndexedAttestation using dynamic specifications. +func (t *IndexedAttestation) HashTreeRootDyn(ds sszutils.DynamicSpecs) (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWithDyn(ds, hh) + if err == nil { + root, err = hh.HashRoot() + } + return + }) + return +} + +// HashTreeRootWithDyn computes the SSZ hash tree root of the *IndexedAttestation using dynamic specifications and the given hash walker. +func (t *IndexedAttestation) HashTreeRootWithDyn(ds sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + if t == nil { + t = new(IndexedAttestation) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'AttestationIndices' + t := t.AttestationIndices + vlen := uint64(len(t)) + if vlen > 2048 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 2048), "AttestationIndices") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + sszutils.HashUint64Slice(hh, t) + hh.FillUpTo32() + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(2048, vlen, 8)) + } + { // Field #1 'Data' + t := t.Data + if t == nil { + t = new(AttestationData) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPath(err, "Data") + } + } + { // Field #2 'Signature' + vlen := len(t.Signature) + if vlen > 96 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 96), "Signature") + } + val := t.Signature[:] + if vlen < 96 { + val = sszutils.AppendZeroPadding(val, (96-vlen)*1) + } + hh.PutBytes(val[:96]) + } + hh.Merkleize(idx) + return nil +} + +// MarshalSSZDyn marshals the *AttestationData to SSZ-encoded bytes using dynamic specifications. +func (t *AttestationData) MarshalSSZDyn(ds sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + dst = buf + if t == nil { + t = new(AttestationData) + } + { // Static Field #0 'Slot' + dst = binary.LittleEndian.AppendUint64(dst, t.Slot) + } + { // Static Field #1 'Index' + dst = binary.LittleEndian.AppendUint64(dst, t.Index) + } + { // Static Field #2 'BeaconBlockHash' + dst = append(dst, t.BeaconBlockHash[:32]...) + } + { // Static Field #3 'Source' + t := t.Source + if t == nil { + t = new(Checkpoint) + } + if dst, err = t.MarshalSSZDyn(ds, dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "Source") + } + } + { // Static Field #4 'Target' + t := t.Target + if t == nil { + t = new(Checkpoint) + } + if dst, err = t.MarshalSSZDyn(ds, dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "Target") + } + } + return dst, nil +} + +// MarshalSSZEncoder marshals the *AttestationData to the given SSZ encoder using dynamic specifications. +func (t *AttestationData) MarshalSSZEncoder(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + if t == nil { + t = new(AttestationData) + } + { // Field #0 'Slot' + enc.EncodeUint64(t.Slot) + } + { // Field #1 'Index' + enc.EncodeUint64(t.Index) + } + { // Field #2 'BeaconBlockHash' + enc.EncodeBytes(t.BeaconBlockHash[:32]) + } + { // Field #3 'Source' + t := t.Source + if t == nil { + t = new(Checkpoint) + } + if err = t.MarshalSSZEncoder(ds, enc); err != nil { + return sszutils.ErrorWithPath(err, "Source") + } + } + { // Field #4 'Target' + t := t.Target + if t == nil { + t = new(Checkpoint) + } + if err = t.MarshalSSZEncoder(ds, enc); err != nil { + return sszutils.ErrorWithPath(err, "Target") + } + } + return nil +} + +// UnmarshalSSZDyn unmarshals the *AttestationData from SSZ-encoded bytes using dynamic specifications. +func (t *AttestationData) UnmarshalSSZDyn(ds sszutils.DynamicSpecs, buf []byte) (err error) { + buflen := len(buf) + if buflen < 128 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 128) + } + if buflen > 128 { + return sszutils.ErrTrailingDataFn(buflen - 128) + } + { // Field #0 'Slot' (static) + buf := buf[0:8] + t.Slot = binary.LittleEndian.Uint64(buf) + } + { // Field #1 'Index' (static) + buf := buf[8:16] + t.Index = binary.LittleEndian.Uint64(buf) + } + { // Field #2 'BeaconBlockHash' (static) + buf := buf[16:48] + copy(t.BeaconBlockHash[:], buf) + } + { // Field #3 'Source' (static) + buf := buf[48:88] + if t.Source == nil { + t.Source = new(Checkpoint) + } + if err = t.Source.UnmarshalSSZDyn(ds, buf); err != nil { + return sszutils.ErrorWithPath(err, "Source") + } + } + { // Field #4 'Target' (static) + buf := buf[88:128] + if t.Target == nil { + t.Target = new(Checkpoint) + } + if err = t.Target.UnmarshalSSZDyn(ds, buf); err != nil { + return sszutils.ErrorWithPath(err, "Target") + } + } + return nil +} + +// UnmarshalSSZDecoder unmarshals the *AttestationData from the given SSZ decoder using dynamic specifications. +func (t *AttestationData) UnmarshalSSZDecoder(ds sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { + maxOffset := uint32(dec.GetLength()) + if maxOffset < uint32(128) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(128)) + } + // Field #0 'Slot' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "Slot") + } else { + t.Slot = val + } + // Field #1 'Index' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "Index") + } else { + t.Index = val + } + // Field #2 'BeaconBlockHash' (static) + if _, err = dec.DecodeBytes(t.BeaconBlockHash[:32]); err != nil { + return err + } + // Field #3 'Source' (static) + if t.Source == nil { + t.Source = new(Checkpoint) + } + if err = t.Source.UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPath(err, "Source") + } + // Field #4 'Target' (static) + if t.Target == nil { + t.Target = new(Checkpoint) + } + if err = t.Target.UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPath(err, "Target") + } + return nil +} + +// SizeSSZ returns the SSZ encoded size of the *AttestationData. +func (t *AttestationData) SizeSSZ() (size int) { + return 128 +} + +// SizeSSZDyn returns the SSZ encoded size of the *AttestationData using dynamic specifications. +func (t *AttestationData) SizeSSZDyn(_ sszutils.DynamicSpecs) (size int) { + return t.SizeSSZ() +} + +// HashTreeRootDyn computes the SSZ hash tree root of the *AttestationData using dynamic specifications. +func (t *AttestationData) HashTreeRootDyn(ds sszutils.DynamicSpecs) (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWithDyn(ds, hh) + if err == nil { + root, err = hh.HashRoot() + } + return + }) + return +} + +// HashTreeRootWithDyn computes the SSZ hash tree root of the *AttestationData using dynamic specifications and the given hash walker. +func (t *AttestationData) HashTreeRootWithDyn(ds sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + if t == nil { + t = new(AttestationData) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Slot' + hh.PutUint64(t.Slot) + } + { // Field #1 'Index' + hh.PutUint64(t.Index) + } + { // Field #2 'BeaconBlockHash' + hh.PutBytes(t.BeaconBlockHash[:32]) + } + { // Field #3 'Source' + t := t.Source + if t == nil { + t = new(Checkpoint) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPath(err, "Source") + } + } + { // Field #4 'Target' + t := t.Target + if t == nil { + t = new(Checkpoint) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPath(err, "Target") + } + } + hh.Merkleize(idx) + return nil +} + +// MarshalSSZDyn marshals the *Attestation to SSZ-encoded bytes using dynamic specifications. +func (t *Attestation) MarshalSSZDyn(ds sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + dst = buf + if t == nil { + t = new(Attestation) + } + dstlen := len(dst) + // Offset Field #0 'AggregationBits' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #1 'Data' + t := t.Data + if t == nil { + t = new(AttestationData) + } + if dst, err = t.MarshalSSZDyn(ds, dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "Data") + } + } + { // Static Field #2 'Signature' + dst = append(dst, t.Signature[:96]...) + } + { // Dynamic Field #0 'AggregationBits' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.AggregationBits + vlen := len(t) + bval := []byte(t[:]) + if vlen == 0 { + bval = []byte{0x01} + } else if bval[vlen-1] == 0x00 { + return nil, sszutils.ErrorWithPath(sszutils.ErrBitlistNotTerminatedFn(), "AggregationBits") + } + if vlen > 0 { + bitCount := 8*(vlen-1) + bits.Len8(bval[vlen-1]) - 1 + if bitCount > 2048 { + return nil, sszutils.ErrorWithPath(sszutils.ErrBitlistLengthFn(bitCount, 2048), "AggregationBits") + } + } + dst = append(dst, bval...) + } + return dst, nil +} + +// MarshalSSZEncoder marshals the *Attestation to the given SSZ encoder using dynamic specifications. +func (t *Attestation) MarshalSSZEncoder(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + type encoderCtx struct { + ds sszutils.DynamicSpecs + exprs [0]uint64 + sizeFn1 func(ctx *encoderCtx, t []byte) (size int) + } + ctx := &encoderCtx{ds: ds} + canSeek := enc.Seekable() + // size for []byte + ctx.sizeFn1 = func(ctx *encoderCtx, t []byte) (size int) { + if len(t) == 0 { + size += 1 + } else { + size += len(t) + } + return size + } + if t == nil { + t = new(Attestation) + } + dstlen := enc.GetPosition() + dynoff := uint32(228) + // Offset #0 'AggregationBits' + offset0 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn1(ctx, t.AggregationBits)) + } + { // Field #1 'Data' + t := t.Data + if t == nil { + t = new(AttestationData) + } + if err = t.MarshalSSZEncoder(ds, enc); err != nil { + return sszutils.ErrorWithPath(err, "Data") + } + } + { // Field #2 'Signature' + enc.EncodeBytes(t.Signature[:96]) + } + { // Dynamic Field #0 'AggregationBits' + if canSeek { + enc.EncodeOffsetAt(offset0, uint32(enc.GetPosition()-dstlen)) + } + t := t.AggregationBits + vlen := len(t) + bval := []byte(t[:]) + if vlen == 0 { + bval = []byte{0x01} + } else if bval[vlen-1] == 0x00 { + return sszutils.ErrorWithPath(sszutils.ErrBitlistNotTerminatedFn(), "AggregationBits") + } + if vlen > 0 { + bitCount := 8*(vlen-1) + bits.Len8(bval[vlen-1]) - 1 + if bitCount > 2048 { + return sszutils.ErrorWithPath(sszutils.ErrBitlistLengthFn(bitCount, 2048), "AggregationBits") + } + } + enc.EncodeBytes(bval) + } + return nil +} + +// UnmarshalSSZDyn unmarshals the *Attestation from SSZ-encoded bytes using dynamic specifications. +func (t *Attestation) UnmarshalSSZDyn(ds sszutils.DynamicSpecs, buf []byte) (err error) { + buflen := len(buf) + if buflen < 228 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 228) + } + // Field #0 'AggregationBits' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 228 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset0, 228), "AggregationBits:o") + } + { // Field #1 'Data' (static) + buf := buf[4:132] + if t.Data == nil { + t.Data = new(AttestationData) + } + if err = t.Data.UnmarshalSSZDyn(ds, buf); err != nil { + return sszutils.ErrorWithPath(err, "Data") + } + } + { // Field #2 'Signature' (static) + buf := buf[132:228] + copy(t.Signature[:], buf) + } + { // Field #0 'AggregationBits' (dynamic) + buf := buf[offset0:] + val1 := t.AggregationBits + blen := len(buf) + if blen == 0 || buf[blen-1] == 0x00 { + return sszutils.ErrorWithPath(sszutils.ErrBitlistNotTerminatedFn(), "AggregationBits") + } + bitCount := 8*(blen-1) + int(bits.Len8(buf[blen-1])) - 1 + if bitCount > 2048 { + return sszutils.ErrorWithPath(sszutils.ErrBitlistLengthFn(bitCount, 2048), "AggregationBits") + } + val1 = sszutils.ExpandSlice(val1, blen) + copy(val1[:], buf) + t.AggregationBits = val1 + } + return nil +} + +// UnmarshalSSZDecoder unmarshals the *Attestation from the given SSZ decoder using dynamic specifications. +func (t *Attestation) UnmarshalSSZDecoder(ds sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { + maxOffset := uint32(dec.GetLength()) + startPos0 := dec.GetPosition() + if maxOffset < uint32(228) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(228)) + } + // Field #0 'AggregationBits' (offset) + offset0, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "AggregationBits") + } + if offset0 != uint32(228) { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset0, 228), "AggregationBits") + } + // Field #1 'Data' (static) + if t.Data == nil { + t.Data = new(AttestationData) + } + if err = t.Data.UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPath(err, "Data") + } + // Field #2 'Signature' (static) + if _, err = dec.DecodeBytes(t.Signature[:96]); err != nil { + return err + } + { // Field #0 'AggregationBits' (dynamic) + if dec.GetPosition() != startPos0+int(offset0) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset0)), "AggregationBits") + } + dec.PushLimit(int(maxOffset - offset0)) + val1 := t.AggregationBits + blen := dec.GetLength() + val1 = sszutils.ExpandSlice(val1, blen) + if _, err = dec.DecodeBytes(val1[:blen]); err != nil { + return sszutils.ErrorWithPath(err, "AggregationBits") + } + if blen == 0 || val1[blen-1] == 0x00 { + return sszutils.ErrorWithPath(sszutils.ErrBitlistNotTerminatedFn(), "AggregationBits") + } + bitCount := 8*(blen-1) + int(bits.Len8(val1[blen-1])) - 1 + if bitCount > 2048 { + return sszutils.ErrorWithPath(sszutils.ErrBitlistLengthFn(bitCount, 2048), "AggregationBits") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "AggregationBits") + } + t.AggregationBits = val1 + } + return nil +} + +// SizeSSZ returns the SSZ encoded size of the *Attestation. +func (t *Attestation) SizeSSZ() (size int) { + if t == nil { + t = new(Attestation) + } + // Field #0 'AggregationBits' offset (4 bytes) + // Field #1 'Data' static (128 bytes) + // Field #2 'Signature' static (96 bytes) + size += 228 + { // Dynamic field #0 'AggregationBits' + if len(t.AggregationBits) == 0 { + size += 1 + } else { + size += len(t.AggregationBits) + } + } + return size +} + +// SizeSSZDyn returns the SSZ encoded size of the *Attestation using dynamic specifications. +func (t *Attestation) SizeSSZDyn(_ sszutils.DynamicSpecs) (size int) { + return t.SizeSSZ() +} + +// HashTreeRootDyn computes the SSZ hash tree root of the *Attestation using dynamic specifications. +func (t *Attestation) HashTreeRootDyn(ds sszutils.DynamicSpecs) (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWithDyn(ds, hh) + if err == nil { + root, err = hh.HashRoot() + } + return + }) + return +} + +// HashTreeRootWithDyn computes the SSZ hash tree root of the *Attestation using dynamic specifications and the given hash walker. +func (t *Attestation) HashTreeRootWithDyn(ds sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + if t == nil { + t = new(Attestation) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'AggregationBits' + t := t.AggregationBits + if l := len(t); l > 0 && t[l-1] == 0x00 { + return sszutils.ErrorWithPath(sszutils.ErrBitlistNotTerminatedFn(), "AggregationBits") + } + idx := hh.StartTree(sszutils.TreeTypeNone) + bitlist, size := hasher.ParseBitlistWithHasher(hh, t[:]) + if size > 2048 { + return sszutils.ErrorWithPath(sszutils.ErrBitlistLengthFn(size, 2048), "AggregationBits") + } + hh.AppendBytes32(bitlist) + hh.MerkleizeWithMixin(idx, size, sszutils.CalculateBitlistLimit(2048)) + } + { // Field #1 'Data' + t := t.Data + if t == nil { + t = new(AttestationData) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPath(err, "Data") + } + } + { // Field #2 'Signature' + hh.PutBytes(t.Signature[:96]) + } + hh.Merkleize(idx) + return nil +} + +// MarshalSSZDyn marshals the *Deposit to SSZ-encoded bytes using dynamic specifications. +func (t *Deposit) MarshalSSZDyn(ds sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + dst = buf + if t == nil { + t = new(Deposit) + } + { // Static Field #0 'Proof' + t := t.Proof + vlen := len(t) + if vlen > 33 { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 33), "Proof") + } + for idx1 := range vlen { + vlen := len(t[idx1]) + if vlen > 32 { + return nil, sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, 32), "Proof[%d]", idx1) + } + dst = append(dst, t[idx1][:vlen]...) + if vlen < 32 { + dst = sszutils.AppendZeroPadding(dst, (32-vlen)*1) + } + } + if vlen < 33 { + dst = sszutils.AppendZeroPadding(dst, (33-vlen)*32) + } + } + { // Static Field #1 'Data' + t := t.Data + if t == nil { + t = new(DepositData) + } + if dst, err = t.MarshalSSZDyn(ds, dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "Data") + } + } + return dst, nil +} + +// MarshalSSZEncoder marshals the *Deposit to the given SSZ encoder using dynamic specifications. +func (t *Deposit) MarshalSSZEncoder(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + if t == nil { + t = new(Deposit) + } + { // Field #0 'Proof' + t := t.Proof + vlen := len(t) + if vlen > 33 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 33), "Proof") + } + for idx1 := range vlen { + vlen := len(t[idx1]) + if vlen > 32 { + return sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, 32), "Proof[%d]", idx1) + } + enc.EncodeBytes(t[idx1][:vlen]) + if vlen < 32 { + enc.EncodeZeroPadding((32 - vlen) * 1) + } + } + if vlen < 33 { + enc.EncodeZeroPadding((33 - vlen) * 32) + } + } + { // Field #1 'Data' + t := t.Data + if t == nil { + t = new(DepositData) + } + if err = t.MarshalSSZEncoder(ds, enc); err != nil { + return sszutils.ErrorWithPath(err, "Data") + } + } + return nil +} + +// UnmarshalSSZDyn unmarshals the *Deposit from SSZ-encoded bytes using dynamic specifications. +func (t *Deposit) UnmarshalSSZDyn(ds sszutils.DynamicSpecs, buf []byte) (err error) { + buflen := len(buf) + if buflen < 1240 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 1240) + } + if buflen > 1240 { + return sszutils.ErrTrailingDataFn(buflen - 1240) + } + { // Field #0 'Proof' (static) + buf := buf[0:1056] + val1 := t.Proof + val1 = sszutils.ExpandSlice(val1, 33) + for idx1 := range 33 { + buf := buf[32*idx1 : 32*(idx1+1)] + val1[idx1] = sszutils.ExpandSlice(val1[idx1], 32) + copy(val1[idx1][:], buf) + } + t.Proof = val1 + } + { // Field #1 'Data' (static) + buf := buf[1056:1240] + if t.Data == nil { + t.Data = new(DepositData) + } + if err = t.Data.UnmarshalSSZDyn(ds, buf); err != nil { + return sszutils.ErrorWithPath(err, "Data") + } + } + return nil +} + +// UnmarshalSSZDecoder unmarshals the *Deposit from the given SSZ decoder using dynamic specifications. +func (t *Deposit) UnmarshalSSZDecoder(ds sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { + maxOffset := uint32(dec.GetLength()) + if maxOffset < uint32(1240) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(1240)) + } + { // Field #0 'Proof' (static) + val1 := t.Proof + val1 = sszutils.ExpandSlice(val1, 33) + startPos0 := dec.GetPosition() + for idx1 := range 33 { + val1[idx1] = sszutils.ExpandSlice(val1[idx1], 32) + if _, err = dec.DecodeBytes(val1[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos0+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos0+int(32*(idx1+1))), "Proof[%d]", idx1) + } + } + t.Proof = val1 + } + // Field #1 'Data' (static) + if t.Data == nil { + t.Data = new(DepositData) + } + if err = t.Data.UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPath(err, "Data") + } + return nil +} + +// SizeSSZ returns the SSZ encoded size of the *Deposit. +func (t *Deposit) SizeSSZ() (size int) { + return 1240 +} + +// SizeSSZDyn returns the SSZ encoded size of the *Deposit using dynamic specifications. +func (t *Deposit) SizeSSZDyn(_ sszutils.DynamicSpecs) (size int) { + return t.SizeSSZ() +} + +// HashTreeRootDyn computes the SSZ hash tree root of the *Deposit using dynamic specifications. +func (t *Deposit) HashTreeRootDyn(ds sszutils.DynamicSpecs) (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWithDyn(ds, hh) + if err == nil { + root, err = hh.HashRoot() + } + return + }) + return +} + +// HashTreeRootWithDyn computes the SSZ hash tree root of the *Deposit using dynamic specifications and the given hash walker. +func (t *Deposit) HashTreeRootWithDyn(ds sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + if t == nil { + t = new(Deposit) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Proof' + t := t.Proof + vlen := len(t) + if vlen > 33 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 33), "Proof") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + var val1, val1Empty []byte + for idx1 := range 33 { + if idx1 < vlen { + val1 = t[idx1] + } else if idx1 == vlen { + val1 = val1Empty + } + vlen := len(val1) + if vlen > 32 { + return sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, 32), "Proof[%d]", idx1) + } + val := val1[:] + if vlen < 32 { + val = sszutils.AppendZeroPadding(val, (32-vlen)*1) + } + hh.PutBytes(val[:32]) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.Merkleize(idx) + } + { // Field #1 'Data' + t := t.Data + if t == nil { + t = new(DepositData) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPath(err, "Data") + } + } + hh.Merkleize(idx) + return nil +} + +// MarshalSSZDyn marshals the *SignedVoluntaryExit to SSZ-encoded bytes using dynamic specifications. +func (t *SignedVoluntaryExit) MarshalSSZDyn(ds sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + dst = buf + if t == nil { + t = new(SignedVoluntaryExit) + } + { // Static Field #0 'Exit' + t := t.Exit + if t == nil { + t = new(VoluntaryExit) + } + if dst, err = t.MarshalSSZDyn(ds, dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "Exit") + } + } + { // Static Field #1 'Signature' + dst = append(dst, t.Signature[:96]...) + } + return dst, nil +} + +// MarshalSSZEncoder marshals the *SignedVoluntaryExit to the given SSZ encoder using dynamic specifications. +func (t *SignedVoluntaryExit) MarshalSSZEncoder(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + if t == nil { + t = new(SignedVoluntaryExit) + } + { // Field #0 'Exit' + t := t.Exit + if t == nil { + t = new(VoluntaryExit) + } + if err = t.MarshalSSZEncoder(ds, enc); err != nil { + return sszutils.ErrorWithPath(err, "Exit") + } + } + { // Field #1 'Signature' + enc.EncodeBytes(t.Signature[:96]) + } + return nil +} + +// UnmarshalSSZDyn unmarshals the *SignedVoluntaryExit from SSZ-encoded bytes using dynamic specifications. +func (t *SignedVoluntaryExit) UnmarshalSSZDyn(ds sszutils.DynamicSpecs, buf []byte) (err error) { + buflen := len(buf) + if buflen < 112 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 112) + } + if buflen > 112 { + return sszutils.ErrTrailingDataFn(buflen - 112) + } + { // Field #0 'Exit' (static) + buf := buf[0:16] + if t.Exit == nil { + t.Exit = new(VoluntaryExit) + } + if err = t.Exit.UnmarshalSSZDyn(ds, buf); err != nil { + return sszutils.ErrorWithPath(err, "Exit") + } + } + { // Field #1 'Signature' (static) + buf := buf[16:112] + copy(t.Signature[:], buf) + } + return nil +} + +// UnmarshalSSZDecoder unmarshals the *SignedVoluntaryExit from the given SSZ decoder using dynamic specifications. +func (t *SignedVoluntaryExit) UnmarshalSSZDecoder(ds sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { + maxOffset := uint32(dec.GetLength()) + if maxOffset < uint32(112) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(112)) + } + // Field #0 'Exit' (static) + if t.Exit == nil { + t.Exit = new(VoluntaryExit) + } + if err = t.Exit.UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPath(err, "Exit") + } + // Field #1 'Signature' (static) + if _, err = dec.DecodeBytes(t.Signature[:96]); err != nil { + return err + } + return nil +} + +// SizeSSZ returns the SSZ encoded size of the *SignedVoluntaryExit. +func (t *SignedVoluntaryExit) SizeSSZ() (size int) { + return 112 +} + +// SizeSSZDyn returns the SSZ encoded size of the *SignedVoluntaryExit using dynamic specifications. +func (t *SignedVoluntaryExit) SizeSSZDyn(_ sszutils.DynamicSpecs) (size int) { + return t.SizeSSZ() +} + +// HashTreeRootDyn computes the SSZ hash tree root of the *SignedVoluntaryExit using dynamic specifications. +func (t *SignedVoluntaryExit) HashTreeRootDyn(ds sszutils.DynamicSpecs) (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWithDyn(ds, hh) + if err == nil { + root, err = hh.HashRoot() + } + return + }) + return +} + +// HashTreeRootWithDyn computes the SSZ hash tree root of the *SignedVoluntaryExit using dynamic specifications and the given hash walker. +func (t *SignedVoluntaryExit) HashTreeRootWithDyn(ds sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + if t == nil { + t = new(SignedVoluntaryExit) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Exit' + t := t.Exit + if t == nil { + t = new(VoluntaryExit) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPath(err, "Exit") + } + } + { // Field #1 'Signature' + hh.PutBytes(t.Signature[:96]) + } + hh.Merkleize(idx) + return nil +} + +// MarshalSSZTo marshals the *SyncAggregate to SSZ-encoded bytes, appending to the provided buffer. +func (t *SyncAggregate) MarshalSSZTo(buf []byte) (dst []byte, err error) { + dst = buf + if t == nil { + t = new(SyncAggregate) + } + { // Static Field #0 'SyncCommiteeBits' + vlen := len(t.SyncCommiteeBits) + if vlen > 64 { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 64), "SyncCommiteeBits") + } + dst = append(dst, t.SyncCommiteeBits[:vlen]...) + if vlen < 64 { + dst = sszutils.AppendZeroPadding(dst, (64-vlen)*1) + } + } + { // Static Field #1 'SyncCommiteeSignature' + dst = append(dst, t.SyncCommiteeSignature[:96]...) + } + return dst, nil +} + +// MarshalSSZDyn marshals the *SyncAggregate to SSZ-encoded bytes using dynamic specifications. +func (t *SyncAggregate) MarshalSSZDyn(_ sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + return t.MarshalSSZTo(buf) +} + +// MarshalSSZEncoder marshals the *SyncAggregate to the given SSZ encoder using dynamic specifications. +func (t *SyncAggregate) MarshalSSZEncoder(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + if t == nil { + t = new(SyncAggregate) + } + { // Field #0 'SyncCommiteeBits' + vlen := len(t.SyncCommiteeBits) + if vlen > 64 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 64), "SyncCommiteeBits") + } + enc.EncodeBytes(t.SyncCommiteeBits[:vlen]) + if vlen < 64 { + enc.EncodeZeroPadding((64 - vlen) * 1) + } + } + { // Field #1 'SyncCommiteeSignature' + enc.EncodeBytes(t.SyncCommiteeSignature[:96]) + } + return nil +} + +// UnmarshalSSZ unmarshals the *SyncAggregate from SSZ-encoded bytes. +func (t *SyncAggregate) UnmarshalSSZ(buf []byte) (err error) { + buflen := len(buf) + if buflen < 160 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 160) + } + if buflen > 160 { + return sszutils.ErrTrailingDataFn(buflen - 160) + } + { // Field #0 'SyncCommiteeBits' (static) + buf := buf[0:64] + t.SyncCommiteeBits = sszutils.ExpandSlice(t.SyncCommiteeBits, 64) + copy(t.SyncCommiteeBits[:], buf) + } + { // Field #1 'SyncCommiteeSignature' (static) + buf := buf[64:160] + copy(t.SyncCommiteeSignature[:], buf) + } + return nil +} + +// UnmarshalSSZDyn unmarshals the *SyncAggregate from SSZ-encoded bytes using dynamic specifications. +func (t *SyncAggregate) UnmarshalSSZDyn(_ sszutils.DynamicSpecs, buf []byte) (err error) { + return t.UnmarshalSSZ(buf) +} + +// UnmarshalSSZDecoder unmarshals the *SyncAggregate from the given SSZ decoder using dynamic specifications. +func (t *SyncAggregate) UnmarshalSSZDecoder(_ sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { + maxOffset := uint32(dec.GetLength()) + if maxOffset < uint32(160) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(160)) + } + // Field #0 'SyncCommiteeBits' (static) + t.SyncCommiteeBits = sszutils.ExpandSlice(t.SyncCommiteeBits, 64) + if _, err = dec.DecodeBytes(t.SyncCommiteeBits[:64]); err != nil { + return err + } + // Field #1 'SyncCommiteeSignature' (static) + if _, err = dec.DecodeBytes(t.SyncCommiteeSignature[:96]); err != nil { + return err + } + return nil +} + +// SizeSSZ returns the SSZ encoded size of the *SyncAggregate. +func (t *SyncAggregate) SizeSSZ() (size int) { + return 160 +} + +// SizeSSZDyn returns the SSZ encoded size of the *SyncAggregate using dynamic specifications. +func (t *SyncAggregate) SizeSSZDyn(_ sszutils.DynamicSpecs) (size int) { + return t.SizeSSZ() +} + +// HashTreeRoot computes the SSZ hash tree root of the *SyncAggregate. +func (t *SyncAggregate) 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 *SyncAggregate using the given hash walker. +func (t *SyncAggregate) HashTreeRootWith(hh sszutils.HashWalker) error { + if t == nil { + t = new(SyncAggregate) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'SyncCommiteeBits' + vlen := len(t.SyncCommiteeBits) + if vlen > 64 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 64), "SyncCommiteeBits") + } + val := t.SyncCommiteeBits[:] + if vlen < 64 { + val = sszutils.AppendZeroPadding(val, (64-vlen)*1) + } + hh.PutBytes(val[:64]) + } + { // Field #1 'SyncCommiteeSignature' + hh.PutBytes(t.SyncCommiteeSignature[:96]) + } + hh.Merkleize(idx) + return nil +} + +// HashTreeRootDyn computes the SSZ hash tree root of the *SyncAggregate using dynamic specifications. +func (t *SyncAggregate) HashTreeRootDyn(ds sszutils.DynamicSpecs) (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWithDyn(ds, hh) + if err == nil { + root, err = hh.HashRoot() + } + return + }) + return +} + +// HashTreeRootWithDyn computes the SSZ hash tree root of the *SyncAggregate using dynamic specifications and the given hash walker. +func (t *SyncAggregate) HashTreeRootWithDyn(_ sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + return t.HashTreeRootWith(hh) +} + +// MarshalSSZDyn marshals the *ExecutionPayload to SSZ-encoded bytes using dynamic specifications. +func (t *ExecutionPayload) MarshalSSZDyn(ds sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + dst = buf + if t == nil { + t = new(ExecutionPayload) + } + dstlen := len(dst) + { // Static Field #0 'ParentHash' + dst = append(dst, t.ParentHash[:32]...) + } + { // Static Field #1 'FeeRecipient' + dst = append(dst, t.FeeRecipient[:20]...) + } + { // Static Field #2 'StateRoot' + dst = append(dst, t.StateRoot[:32]...) + } + { // Static Field #3 'ReceiptsRoot' + dst = append(dst, t.ReceiptsRoot[:32]...) + } + { // Static Field #4 'LogsBloom' + dst = append(dst, t.LogsBloom[:256]...) + } + { // Static Field #5 'PrevRandao' + dst = append(dst, t.PrevRandao[:32]...) + } + { // Static Field #6 'BlockNumber' + dst = binary.LittleEndian.AppendUint64(dst, t.BlockNumber) + } + { // Static Field #7 'GasLimit' + dst = binary.LittleEndian.AppendUint64(dst, t.GasLimit) + } + { // Static Field #8 'GasUsed' + dst = binary.LittleEndian.AppendUint64(dst, t.GasUsed) + } + { // Static Field #9 'Timestamp' + dst = binary.LittleEndian.AppendUint64(dst, t.Timestamp) + } + // Offset Field #10 'ExtraData' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #11 'BaseFeePerGas' + dst = append(dst, t.BaseFeePerGas[:32]...) + } + { // Static Field #12 'BlockHash' + dst = append(dst, t.BlockHash[:32]...) + } + // Offset Field #13 'Transactions' + // Offset Field #14 'Withdrawals' + dst = append(dst, 0, 0, 0, 0, 0, 0, 0, 0) + { // Static Field #15 'BlobGasUsed' + dst = binary.LittleEndian.AppendUint64(dst, t.BlobGasUsed) + } + { // Static Field #16 'ExcessBlobGas' + dst = binary.LittleEndian.AppendUint64(dst, t.ExcessBlobGas) + } + { // Dynamic Field #10 'ExtraData' + binary.LittleEndian.PutUint32(dst[dstlen+436:], uint32(len(dst)-dstlen)) + vlen := len(t.ExtraData) + if vlen > 32 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 32), "ExtraData") + } + dst = append(dst, t.ExtraData[:]...) + } + { // Dynamic Field #13 'Transactions' + binary.LittleEndian.PutUint32(dst[dstlen+504:], uint32(len(dst)-dstlen)) + t := t.Transactions + vlen := len(t) + if vlen > 1048576 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1048576), "Transactions") + } + dstlen := len(dst) + dst = sszutils.AppendZeroPadding(dst, vlen*4) + for idx1 := range vlen { + binary.LittleEndian.PutUint32(dst[dstlen+(idx1*4):], uint32(len(dst)-dstlen)) + vlen := len(t[idx1]) + if vlen > 1073741824 { + return nil, sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(vlen, 1073741824), "Transactions[%d]", idx1) + } + dst = append(dst, t[idx1][:]...) + } + } + { // Dynamic Field #14 'Withdrawals' + binary.LittleEndian.PutUint32(dst[dstlen+508:], uint32(len(dst)-dstlen)) + t := t.Withdrawals + vlen := len(t) + if vlen > 16 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16), "Withdrawals") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(Withdrawal) + } + if dst, err = t.MarshalSSZDyn(ds, dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "Withdrawals[%d]", idx1) + } + } + } + return dst, nil +} + +// MarshalSSZEncoder marshals the *ExecutionPayload to the given SSZ encoder using dynamic specifications. +func (t *ExecutionPayload) MarshalSSZEncoder(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + type encoderCtx struct { + ds sszutils.DynamicSpecs + exprs [0]uint64 + sizeFn1 func(ctx *encoderCtx, t []byte) (size int) + sizeFn2 func(ctx *encoderCtx, t [][]byte) (size int) + sizeFn3 func(ctx *encoderCtx, t []*Withdrawal) (size int) + sizeFn4 func(ctx *encoderCtx, t []byte) (size int) + } + ctx := &encoderCtx{ds: ds} + canSeek := enc.Seekable() + // size for []byte + ctx.sizeFn1 = func(ctx *encoderCtx, t []byte) (size int) { + size += len(t) + return size + } + // size for [][]byte + ctx.sizeFn2 = func(ctx *encoderCtx, t [][]byte) (size int) { + vlen := len(t) + size += vlen * 4 // Offsets + for i1 := range vlen { + size += ctx.sizeFn4(ctx, t[i1]) + } + return size + } + // size for []*Withdrawal + ctx.sizeFn3 = func(ctx *encoderCtx, t []*Withdrawal) (size int) { + size += len(t) * 44 + return size + } + // size for []byte + ctx.sizeFn4 = func(ctx *encoderCtx, t []byte) (size int) { + size += len(t) + return size + } + if t == nil { + t = new(ExecutionPayload) + } + dstlen := enc.GetPosition() + dynoff := uint32(528) + { // Field #0 'ParentHash' + enc.EncodeBytes(t.ParentHash[:32]) + } + { // Field #1 'FeeRecipient' + enc.EncodeBytes(t.FeeRecipient[:20]) + } + { // Field #2 'StateRoot' + enc.EncodeBytes(t.StateRoot[:32]) + } + { // Field #3 'ReceiptsRoot' + enc.EncodeBytes(t.ReceiptsRoot[:32]) + } + { // Field #4 'LogsBloom' + enc.EncodeBytes(t.LogsBloom[:256]) + } + { // Field #5 'PrevRandao' + enc.EncodeBytes(t.PrevRandao[:32]) + } + { // Field #6 'BlockNumber' + enc.EncodeUint64(t.BlockNumber) + } + { // Field #7 'GasLimit' + enc.EncodeUint64(t.GasLimit) + } + { // Field #8 'GasUsed' + enc.EncodeUint64(t.GasUsed) + } + { // Field #9 'Timestamp' + enc.EncodeUint64(t.Timestamp) + } + // Offset #10 'ExtraData' + offset10 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn1(ctx, t.ExtraData)) + } + { // Field #11 'BaseFeePerGas' + enc.EncodeBytes(t.BaseFeePerGas[:32]) + } + { // Field #12 'BlockHash' + enc.EncodeBytes(t.BlockHash[:32]) + } + // Offset #13 'Transactions' + offset13 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn2(ctx, t.Transactions)) + } + // Offset #14 'Withdrawals' + offset14 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn3(ctx, t.Withdrawals)) + } + { // Field #15 'BlobGasUsed' + enc.EncodeUint64(t.BlobGasUsed) + } + { // Field #16 'ExcessBlobGas' + enc.EncodeUint64(t.ExcessBlobGas) + } + { // Dynamic Field #10 'ExtraData' + if canSeek { + enc.EncodeOffsetAt(offset10, uint32(enc.GetPosition()-dstlen)) + } + vlen := len(t.ExtraData) + if vlen > 32 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 32), "ExtraData") + } + enc.EncodeBytes(t.ExtraData[:]) + } + { // Dynamic Field #13 'Transactions' + if canSeek { + enc.EncodeOffsetAt(offset13, uint32(enc.GetPosition()-dstlen)) + } + t := t.Transactions + vlen := len(t) + if vlen > 1048576 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1048576), "Transactions") + } + dstlen := enc.GetPosition() + if canSeek { + enc.EncodeZeroPadding(vlen * 4) + } else if vlen > 0 { + offset := vlen * 4 + enc.EncodeOffset(uint32(offset)) + for i := range vlen - 1 { + offset += ctx.sizeFn4(ctx, t[i]) + enc.EncodeOffset(uint32(offset)) + } + } + for idx1 := range vlen { + if canSeek { + enc.EncodeOffsetAt(dstlen+(idx1*4), uint32(enc.GetPosition()-dstlen)) + } + vlen := len(t[idx1]) + if vlen > 1073741824 { + return sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(vlen, 1073741824), "Transactions[%d]", idx1) + } + enc.EncodeBytes(t[idx1][:]) + } + } + { // Dynamic Field #14 'Withdrawals' + if canSeek { + enc.EncodeOffsetAt(offset14, uint32(enc.GetPosition()-dstlen)) + } + t := t.Withdrawals + vlen := len(t) + if vlen > 16 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16), "Withdrawals") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(Withdrawal) + } + if err = t.MarshalSSZEncoder(ds, enc); err != nil { + return sszutils.ErrorWithPathf(err, "Withdrawals[%d]", idx1) + } + } + } + return nil +} + +// UnmarshalSSZDyn unmarshals the *ExecutionPayload from SSZ-encoded bytes using dynamic specifications. +func (t *ExecutionPayload) UnmarshalSSZDyn(ds sszutils.DynamicSpecs, buf []byte) (err error) { + buflen := len(buf) + if buflen < 528 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 528) + } + { // Field #0 'ParentHash' (static) + buf := buf[0:32] + copy(t.ParentHash[:], buf) + } + { // Field #1 'FeeRecipient' (static) + buf := buf[32:52] + copy(t.FeeRecipient[:], buf) + } + { // Field #2 'StateRoot' (static) + buf := buf[52:84] + copy(t.StateRoot[:], buf) + } + { // Field #3 'ReceiptsRoot' (static) + buf := buf[84:116] + copy(t.ReceiptsRoot[:], buf) + } + { // Field #4 'LogsBloom' (static) + buf := buf[116:372] + copy(t.LogsBloom[:], buf) + } + { // Field #5 'PrevRandao' (static) + buf := buf[372:404] + copy(t.PrevRandao[:], buf) + } + { // Field #6 'BlockNumber' (static) + buf := buf[404:412] + t.BlockNumber = binary.LittleEndian.Uint64(buf) + } + { // Field #7 'GasLimit' (static) + buf := buf[412:420] + t.GasLimit = binary.LittleEndian.Uint64(buf) + } + { // Field #8 'GasUsed' (static) + buf := buf[420:428] + t.GasUsed = binary.LittleEndian.Uint64(buf) + } + { // Field #9 'Timestamp' (static) + buf := buf[428:436] + t.Timestamp = binary.LittleEndian.Uint64(buf) + } + // Field #10 'ExtraData' (offset) + offset10 := int(binary.LittleEndian.Uint32(buf[436:440])) + if offset10 != 528 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset10, 528), "ExtraData:o") + } + { // Field #11 'BaseFeePerGas' (static) + buf := buf[440:472] + copy(t.BaseFeePerGas[:], buf) + } + { // Field #12 'BlockHash' (static) + buf := buf[472:504] + copy(t.BlockHash[:], buf) + } + // Field #13 'Transactions' (offset) + offset13 := int(binary.LittleEndian.Uint32(buf[504:508])) + if offset13 < offset10 || offset13 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset13, offset10, buflen), "Transactions:o") + } + // Field #14 'Withdrawals' (offset) + offset14 := int(binary.LittleEndian.Uint32(buf[508:512])) + if offset14 < offset13 || offset14 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset14, offset13, buflen), "Withdrawals:o") + } + { // Field #15 'BlobGasUsed' (static) + buf := buf[512:520] + t.BlobGasUsed = binary.LittleEndian.Uint64(buf) + } + { // Field #16 'ExcessBlobGas' (static) + buf := buf[520:528] + t.ExcessBlobGas = binary.LittleEndian.Uint64(buf) + } + { // Field #10 'ExtraData' (dynamic) + buf := buf[offset10:offset13] + if len(buf) > 32 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(len(buf), 32), "ExtraData") + } + t.ExtraData = sszutils.ExpandSlice(t.ExtraData, len(buf)) + copy(t.ExtraData[:], buf) + } + { // Field #13 'Transactions' (dynamic) + buf := buf[offset13:offset14] + val1 := t.Transactions + startOffset := int(0) + if len(buf) != 0 { + if len(buf) < 4 { + return sszutils.ErrorWithPath(sszutils.ErrListOffsetsEOFFn(len(buf), 4), "Transactions") + } + startOffset = int(binary.LittleEndian.Uint32(buf[0:4])) + } + itemCount := startOffset / 4 + if startOffset%4 != 0 || len(buf) < startOffset || (len(buf) != 0 && startOffset == 0) { + return sszutils.ErrorWithPath(sszutils.ErrInvalidListStartOffsetFn(startOffset, len(buf)), "Transactions") + } + if itemCount > 1048576 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1048576), "Transactions") + } + val1 = sszutils.ExpandSlice(val1, itemCount) + for idx1 := range itemCount { + var endOffset int + if idx1 < itemCount-1 { + endOffset = int(binary.LittleEndian.Uint32(buf[(idx1+1)*4 : (idx1+2)*4])) + } else { + endOffset = len(buf) + } + if endOffset < startOffset || endOffset > len(buf) { + return sszutils.ErrorWithPathf(sszutils.ErrElementOffsetOutOfRangeFn(endOffset, startOffset, len(buf)), "Transactions[%d]", idx1) + } + buf := buf[startOffset:endOffset] + startOffset = endOffset + val2 := val1[idx1] + if len(buf) > 1073741824 { + return sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(len(buf), 1073741824), "Transactions[%d]", idx1) + } + val2 = sszutils.ExpandSlice(val2, len(buf)) + copy(val2[:], buf) + val1[idx1] = val2 + } + t.Transactions = val1 + } + { // Field #14 'Withdrawals' (dynamic) + buf := buf[offset14:] + val3 := t.Withdrawals + itemCount := len(buf) / 44 + if len(buf)%44 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 44), "Withdrawals") + } + if itemCount > 16 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 16), "Withdrawals") + } + val3 = sszutils.ExpandSlice(val3, itemCount) + for idx1 := range itemCount { + if val3[idx1] == nil { + val3[idx1] = new(Withdrawal) + } + buf := buf[44*idx1 : 44*(idx1+1)] + if err = val3[idx1].UnmarshalSSZDyn(ds, buf); err != nil { + return sszutils.ErrorWithPathf(err, "Withdrawals[%d]", idx1) + } + } + t.Withdrawals = val3 + } + return nil +} + +// UnmarshalSSZDecoder unmarshals the *ExecutionPayload from the given SSZ decoder using dynamic specifications. +func (t *ExecutionPayload) UnmarshalSSZDecoder(ds sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { + canSeek := dec.Seekable() + offsetSlices := [1][]uint32{ + sszutils.GetOffsetSlice(0), + } + defer func() { + sszutils.PutOffsetSlice(offsetSlices[0]) + }() + maxOffset := uint32(dec.GetLength()) + startPos0 := dec.GetPosition() + if maxOffset < uint32(528) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(528)) + } + // Field #0 'ParentHash' (static) + if _, err = dec.DecodeBytes(t.ParentHash[:32]); err != nil { + return err + } + // Field #1 'FeeRecipient' (static) + if _, err = dec.DecodeBytes(t.FeeRecipient[:20]); err != nil { + return err + } + // Field #2 'StateRoot' (static) + if _, err = dec.DecodeBytes(t.StateRoot[:32]); err != nil { + return err + } + // Field #3 'ReceiptsRoot' (static) + if _, err = dec.DecodeBytes(t.ReceiptsRoot[:32]); err != nil { + return err + } + // Field #4 'LogsBloom' (static) + if _, err = dec.DecodeBytes(t.LogsBloom[:256]); err != nil { + return err + } + // Field #5 'PrevRandao' (static) + if _, err = dec.DecodeBytes(t.PrevRandao[:32]); err != nil { + return err + } + // Field #6 'BlockNumber' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "BlockNumber") + } else { + t.BlockNumber = val + } + // Field #7 'GasLimit' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "GasLimit") + } else { + t.GasLimit = val + } + // Field #8 'GasUsed' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "GasUsed") + } else { + t.GasUsed = val + } + // Field #9 'Timestamp' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "Timestamp") + } else { + t.Timestamp = val + } + // Field #10 'ExtraData' (offset) + offset10, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "ExtraData") + } + if offset10 != uint32(528) { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset10, 528), "ExtraData") + } + // Field #11 'BaseFeePerGas' (static) + if _, err = dec.DecodeBytes(t.BaseFeePerGas[:32]); err != nil { + return err + } + // Field #12 'BlockHash' (static) + if _, err = dec.DecodeBytes(t.BlockHash[:32]); err != nil { + return err + } + // Field #13 'Transactions' (offset) + offset13, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Transactions") + } + if offset13 < offset10 || offset13 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset13, offset10, maxOffset), "Transactions") + } + // Field #14 'Withdrawals' (offset) + offset14, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Withdrawals") + } + if offset14 < offset13 || offset14 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset14, offset13, maxOffset), "Withdrawals") + } + // Field #15 'BlobGasUsed' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "BlobGasUsed") + } else { + t.BlobGasUsed = val + } + // Field #16 'ExcessBlobGas' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "ExcessBlobGas") + } else { + t.ExcessBlobGas = val + } + { // Field #10 'ExtraData' (dynamic) + if dec.GetPosition() != startPos0+int(offset10) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset10)), "ExtraData") + } + dec.PushLimit(int(offset13 - offset10)) + val1 := t.ExtraData + if dec.GetLength() > 32 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(dec.GetLength(), 32), "ExtraData") + } + listLen := dec.GetLength() + val1 = sszutils.ExpandSlice(val1, listLen) + if _, err = dec.DecodeBytes(val1[:listLen]); err != nil { + return sszutils.ErrorWithPath(err, "ExtraData") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "ExtraData") + } + t.ExtraData = val1 + } + { // Field #13 'Transactions' (dynamic) + if dec.GetPosition() != startPos0+int(offset13) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset13)), "Transactions") + } + dec.PushLimit(int(offset14 - offset13)) + val2 := t.Transactions + startOffset := uint32(0) + startPos1 := dec.GetPosition() + sszLen := uint32(dec.GetLength()) + if sszLen > 0 { + startOffset, err = dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Transactions") + } + } + itemCount := int(startOffset / 4) + var offsets []uint32 + if canSeek { + dec.SkipBytes((itemCount - 1) * 4) + } else if itemCount > 1 { + offsetSlices[0] = sszutils.ExpandSlice(offsetSlices[0], itemCount-1) + offsets = offsetSlices[0] + for idx1 := range itemCount - 1 { + offset, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPathf(err, "Transactions[%d:o]", idx1) + } + offsets[idx1] = offset + } + } + if startOffset%4 != 0 || uint32(sszLen) < startOffset { + return sszutils.ErrorWithPath(sszutils.ErrInvalidListStartOffsetFn(startOffset, sszLen), "Transactions") + } + if itemCount > 1048576 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1048576), "Transactions") + } + val2 = sszutils.ExpandSlice(val2, itemCount) + for idx1 := range itemCount { + var endOffset uint32 + if idx1 < itemCount-1 { + if canSeek { + endOffset = dec.DecodeOffsetAt(startPos1 + int((idx1+1)*4)) + } else { + endOffset = offsets[idx1] + } + } else { + endOffset = uint32(sszLen) + } + if endOffset < startOffset || endOffset > uint32(sszLen) { + return sszutils.ErrorWithPathf(sszutils.ErrElementOffsetOutOfRangeFn(endOffset, startOffset, sszLen), "Transactions[%d]", idx1) + } + itemSize := endOffset - startOffset + dec.PushLimit(int(itemSize)) + startOffset = endOffset + val3 := val2[idx1] + if dec.GetLength() > 1073741824 { + return sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(dec.GetLength(), 1073741824), "Transactions[%d]", idx1) + } + listLen := dec.GetLength() + val3 = sszutils.ExpandSlice(val3, listLen) + if _, err = dec.DecodeBytes(val3[:listLen]); err != nil { + return sszutils.ErrorWithPathf(err, "Transactions[%d]", idx1) + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPathf(sszutils.ErrTrailingDataFn(diff), "Transactions[%d]", idx1) + } + val2[idx1] = val3 + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Transactions") + } + t.Transactions = val2 + } + { // Field #14 'Withdrawals' (dynamic) + if dec.GetPosition() != startPos0+int(offset14) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset14)), "Withdrawals") + } + dec.PushLimit(int(maxOffset - offset14)) + val4 := t.Withdrawals + sszLen := dec.GetLength() + itemCount := sszLen / 44 + if sszLen%44 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 44), "Withdrawals") + } + if itemCount > 16 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 16), "Withdrawals") + } + val4 = sszutils.ExpandSlice(val4, itemCount) + startPos2 := dec.GetPosition() + for idx1 := range itemCount { + if val4[idx1] == nil { + val4[idx1] = new(Withdrawal) + } + if err = val4[idx1].UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPathf(err, "Withdrawals[%d]", idx1) + } + if dec.GetPosition() != startPos2+int(44*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos2+int(44*(idx1+1))), "Withdrawals[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Withdrawals") + } + t.Withdrawals = val4 + } + return nil +} + +// SizeSSZ returns the SSZ encoded size of the *ExecutionPayload. +func (t *ExecutionPayload) SizeSSZ() (size int) { + if t == nil { + t = new(ExecutionPayload) + } + // Field #0 'ParentHash' static (32 bytes) + // Field #1 'FeeRecipient' static (20 bytes) + // Field #2 'StateRoot' static (32 bytes) + // Field #3 'ReceiptsRoot' static (32 bytes) + // Field #4 'LogsBloom' static (256 bytes) + // Field #5 'PrevRandao' static (32 bytes) + // Field #6 'BlockNumber' static (8 bytes) + // Field #7 'GasLimit' static (8 bytes) + // Field #8 'GasUsed' static (8 bytes) + // Field #9 'Timestamp' static (8 bytes) + // Field #10 'ExtraData' offset (4 bytes) + // Field #11 'BaseFeePerGas' static (32 bytes) + // Field #12 'BlockHash' static (32 bytes) + // Field #13 'Transactions' offset (4 bytes) + // Field #14 'Withdrawals' offset (4 bytes) + // Field #15 'BlobGasUsed' static (8 bytes) + // Field #16 'ExcessBlobGas' static (8 bytes) + size += 528 + { // Dynamic field #10 'ExtraData' + size += len(t.ExtraData) + } + { // Dynamic field #13 'Transactions' + t := t.Transactions + vlen := len(t) + size += vlen * 4 // Offsets + for i1 := range vlen { + size += len(t[i1]) + } + } + { // Dynamic field #14 'Withdrawals' + size += len(t.Withdrawals) * 44 + } + return size +} + +// SizeSSZDyn returns the SSZ encoded size of the *ExecutionPayload using dynamic specifications. +func (t *ExecutionPayload) SizeSSZDyn(_ sszutils.DynamicSpecs) (size int) { + return t.SizeSSZ() +} + +// HashTreeRootDyn computes the SSZ hash tree root of the *ExecutionPayload using dynamic specifications. +func (t *ExecutionPayload) HashTreeRootDyn(ds sszutils.DynamicSpecs) (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWithDyn(ds, hh) + if err == nil { + root, err = hh.HashRoot() + } + return + }) + return +} + +// HashTreeRootWithDyn computes the SSZ hash tree root of the *ExecutionPayload using dynamic specifications and the given hash walker. +func (t *ExecutionPayload) HashTreeRootWithDyn(ds sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + if t == nil { + t = new(ExecutionPayload) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'ParentHash' + hh.PutBytes(t.ParentHash[:32]) + } + { // Field #1 'FeeRecipient' + hh.PutBytes(t.FeeRecipient[:20]) + } + { // Field #2 'StateRoot' + hh.PutBytes(t.StateRoot[:32]) + } + { // Field #3 'ReceiptsRoot' + hh.PutBytes(t.ReceiptsRoot[:32]) + } + { // Field #4 'LogsBloom' + hh.PutBytes(t.LogsBloom[:256]) + } + { // Field #5 'PrevRandao' + hh.PutBytes(t.PrevRandao[:32]) + } + { // Field #6 'BlockNumber' + hh.PutUint64(t.BlockNumber) + } + { // Field #7 'GasLimit' + hh.PutUint64(t.GasLimit) + } + { // Field #8 'GasUsed' + hh.PutUint64(t.GasUsed) + } + { // Field #9 'Timestamp' + hh.PutUint64(t.Timestamp) + } + { // Field #10 'ExtraData' + vlen := uint64(len(t.ExtraData)) + if vlen > 32 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 32), "ExtraData") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + hh.AppendBytes32(t.ExtraData[:]) + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(32, vlen, 1)) + } + { // Field #11 'BaseFeePerGas' + hh.PutBytes(t.BaseFeePerGas[:32]) + } + { // Field #12 'BlockHash' + hh.PutBytes(t.BlockHash[:32]) + } + { // Field #13 'Transactions' + t := t.Transactions + vlen := uint64(len(t)) + if vlen > 1048576 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1048576), "Transactions") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + vlen := uint64(len(t[idx1])) + if vlen > 1073741824 { + return sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(vlen, 1073741824), "Transactions[%d]", idx1) + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + hh.AppendBytes32(t[idx1][:]) + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(1073741824, vlen, 1)) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(1048576, vlen, 32)) + } + { // Field #14 'Withdrawals' + t := t.Withdrawals + vlen := uint64(len(t)) + if vlen > 16 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16), "Withdrawals") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(Withdrawal) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPathf(err, "Withdrawals[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(16, vlen, 32)) + } + { // Field #15 'BlobGasUsed' + hh.PutUint64(t.BlobGasUsed) + } + { // Field #16 'ExcessBlobGas' + hh.PutUint64(t.ExcessBlobGas) + } + hh.Merkleize(idx) + return nil +} + +// MarshalSSZTo marshals the *Withdrawal to SSZ-encoded bytes, appending to the provided buffer. +func (t *Withdrawal) MarshalSSZTo(buf []byte) (dst []byte, err error) { + dst = buf + if t == nil { + t = new(Withdrawal) + } + { // Static Field #0 'Index' + dst = binary.LittleEndian.AppendUint64(dst, t.Index) + } + { // Static Field #1 'ValidatorIndex' + dst = binary.LittleEndian.AppendUint64(dst, t.ValidatorIndex) + } + { // Static Field #2 'Address' + dst = append(dst, t.Address[:20]...) + } + { // Static Field #3 'Amount' + dst = binary.LittleEndian.AppendUint64(dst, t.Amount) + } + return dst, nil +} + +// MarshalSSZDyn marshals the *Withdrawal to SSZ-encoded bytes using dynamic specifications. +func (t *Withdrawal) MarshalSSZDyn(_ sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + return t.MarshalSSZTo(buf) +} + +// MarshalSSZEncoder marshals the *Withdrawal to the given SSZ encoder using dynamic specifications. +func (t *Withdrawal) MarshalSSZEncoder(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + if t == nil { + t = new(Withdrawal) + } + { // Field #0 'Index' + enc.EncodeUint64(t.Index) + } + { // Field #1 'ValidatorIndex' + enc.EncodeUint64(t.ValidatorIndex) + } + { // Field #2 'Address' + enc.EncodeBytes(t.Address[:20]) + } + { // Field #3 'Amount' + enc.EncodeUint64(t.Amount) + } + return nil +} + +// UnmarshalSSZ unmarshals the *Withdrawal from SSZ-encoded bytes. +func (t *Withdrawal) UnmarshalSSZ(buf []byte) (err error) { + buflen := len(buf) + if buflen < 44 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 44) + } + if buflen > 44 { + return sszutils.ErrTrailingDataFn(buflen - 44) + } + { // Field #0 'Index' (static) + buf := buf[0:8] + t.Index = binary.LittleEndian.Uint64(buf) + } + { // Field #1 'ValidatorIndex' (static) + buf := buf[8:16] + t.ValidatorIndex = binary.LittleEndian.Uint64(buf) + } + { // Field #2 'Address' (static) + buf := buf[16:36] + copy(t.Address[:], buf) + } + { // Field #3 'Amount' (static) + buf := buf[36:44] + t.Amount = binary.LittleEndian.Uint64(buf) + } + return nil +} + +// UnmarshalSSZDyn unmarshals the *Withdrawal from SSZ-encoded bytes using dynamic specifications. +func (t *Withdrawal) UnmarshalSSZDyn(_ sszutils.DynamicSpecs, buf []byte) (err error) { + return t.UnmarshalSSZ(buf) +} + +// UnmarshalSSZDecoder unmarshals the *Withdrawal from the given SSZ decoder using dynamic specifications. +func (t *Withdrawal) UnmarshalSSZDecoder(_ sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { + maxOffset := uint32(dec.GetLength()) + if maxOffset < uint32(44) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(44)) + } + // Field #0 'Index' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "Index") + } else { + t.Index = val + } + // Field #1 'ValidatorIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "ValidatorIndex") + } else { + t.ValidatorIndex = val + } + // Field #2 'Address' (static) + if _, err = dec.DecodeBytes(t.Address[:20]); err != nil { + return err + } + // Field #3 'Amount' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "Amount") + } else { + t.Amount = val + } + return nil +} + +// SizeSSZ returns the SSZ encoded size of the *Withdrawal. +func (t *Withdrawal) SizeSSZ() (size int) { + return 44 +} + +// SizeSSZDyn returns the SSZ encoded size of the *Withdrawal using dynamic specifications. +func (t *Withdrawal) SizeSSZDyn(_ sszutils.DynamicSpecs) (size int) { + return t.SizeSSZ() +} + +// HashTreeRoot computes the SSZ hash tree root of the *Withdrawal. +func (t *Withdrawal) 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 *Withdrawal using the given hash walker. +func (t *Withdrawal) HashTreeRootWith(hh sszutils.HashWalker) error { + if t == nil { + t = new(Withdrawal) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Index' + hh.PutUint64(t.Index) + } + { // Field #1 'ValidatorIndex' + hh.PutUint64(t.ValidatorIndex) + } + { // Field #2 'Address' + hh.PutBytes(t.Address[:20]) + } + { // Field #3 'Amount' + hh.PutUint64(t.Amount) + } + hh.Merkleize(idx) + return nil +} + +// HashTreeRootDyn computes the SSZ hash tree root of the *Withdrawal using dynamic specifications. +func (t *Withdrawal) HashTreeRootDyn(ds sszutils.DynamicSpecs) (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWithDyn(ds, hh) + if err == nil { + root, err = hh.HashRoot() + } + return + }) + return +} + +// HashTreeRootWithDyn computes the SSZ hash tree root of the *Withdrawal using dynamic specifications and the given hash walker. +func (t *Withdrawal) HashTreeRootWithDyn(_ sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + return t.HashTreeRootWith(hh) +} + +// MarshalSSZTo marshals the *BLSToExecutionChange to SSZ-encoded bytes, appending to the provided buffer. +func (t *BLSToExecutionChange) MarshalSSZTo(buf []byte) (dst []byte, err error) { + dst = buf + if t == nil { + t = new(BLSToExecutionChange) + } + { // Static Field #0 'ValidatorIndex' + dst = binary.LittleEndian.AppendUint64(dst, t.ValidatorIndex) + } + { // Static Field #1 'FromBLSPubKey' + dst = append(dst, t.FromBLSPubKey[:48]...) + } + { // Static Field #2 'ToExecutionAddress' + dst = append(dst, t.ToExecutionAddress[:20]...) + } + return dst, nil +} + +// MarshalSSZDyn marshals the *BLSToExecutionChange to SSZ-encoded bytes using dynamic specifications. +func (t *BLSToExecutionChange) MarshalSSZDyn(_ sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + return t.MarshalSSZTo(buf) +} + +// MarshalSSZEncoder marshals the *BLSToExecutionChange to the given SSZ encoder using dynamic specifications. +func (t *BLSToExecutionChange) MarshalSSZEncoder(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + if t == nil { + t = new(BLSToExecutionChange) + } + { // Field #0 'ValidatorIndex' + enc.EncodeUint64(t.ValidatorIndex) + } + { // Field #1 'FromBLSPubKey' + enc.EncodeBytes(t.FromBLSPubKey[:48]) + } + { // Field #2 'ToExecutionAddress' + enc.EncodeBytes(t.ToExecutionAddress[:20]) + } + return nil +} + +// UnmarshalSSZ unmarshals the *BLSToExecutionChange from SSZ-encoded bytes. +func (t *BLSToExecutionChange) UnmarshalSSZ(buf []byte) (err error) { + buflen := len(buf) + if buflen < 76 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 76) + } + if buflen > 76 { + return sszutils.ErrTrailingDataFn(buflen - 76) + } + { // Field #0 'ValidatorIndex' (static) + buf := buf[0:8] + t.ValidatorIndex = binary.LittleEndian.Uint64(buf) + } + { // Field #1 'FromBLSPubKey' (static) + buf := buf[8:56] + copy(t.FromBLSPubKey[:], buf) + } + { // Field #2 'ToExecutionAddress' (static) + buf := buf[56:76] + copy(t.ToExecutionAddress[:], buf) + } + return nil +} + +// UnmarshalSSZDyn unmarshals the *BLSToExecutionChange from SSZ-encoded bytes using dynamic specifications. +func (t *BLSToExecutionChange) UnmarshalSSZDyn(_ sszutils.DynamicSpecs, buf []byte) (err error) { + return t.UnmarshalSSZ(buf) +} + +// UnmarshalSSZDecoder unmarshals the *BLSToExecutionChange from the given SSZ decoder using dynamic specifications. +func (t *BLSToExecutionChange) UnmarshalSSZDecoder(_ sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { + maxOffset := uint32(dec.GetLength()) + if maxOffset < uint32(76) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(76)) + } + // Field #0 'ValidatorIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "ValidatorIndex") + } else { + t.ValidatorIndex = val + } + // Field #1 'FromBLSPubKey' (static) + if _, err = dec.DecodeBytes(t.FromBLSPubKey[:48]); err != nil { + return err + } + // Field #2 'ToExecutionAddress' (static) + if _, err = dec.DecodeBytes(t.ToExecutionAddress[:20]); err != nil { + return err + } + return nil +} + +// SizeSSZ returns the SSZ encoded size of the *BLSToExecutionChange. +func (t *BLSToExecutionChange) SizeSSZ() (size int) { + return 76 +} + +// SizeSSZDyn returns the SSZ encoded size of the *BLSToExecutionChange using dynamic specifications. +func (t *BLSToExecutionChange) SizeSSZDyn(_ sszutils.DynamicSpecs) (size int) { + return t.SizeSSZ() +} + +// HashTreeRoot computes the SSZ hash tree root of the *BLSToExecutionChange. +func (t *BLSToExecutionChange) 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 *BLSToExecutionChange using the given hash walker. +func (t *BLSToExecutionChange) HashTreeRootWith(hh sszutils.HashWalker) error { + if t == nil { + t = new(BLSToExecutionChange) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'ValidatorIndex' + hh.PutUint64(t.ValidatorIndex) + } + { // Field #1 'FromBLSPubKey' + hh.PutBytes(t.FromBLSPubKey[:48]) + } + { // Field #2 'ToExecutionAddress' + hh.PutBytes(t.ToExecutionAddress[:20]) + } + hh.Merkleize(idx) + return nil +} + +// HashTreeRootDyn computes the SSZ hash tree root of the *BLSToExecutionChange using dynamic specifications. +func (t *BLSToExecutionChange) HashTreeRootDyn(ds sszutils.DynamicSpecs) (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWithDyn(ds, hh) + if err == nil { + root, err = hh.HashRoot() + } + return + }) + return +} + +// HashTreeRootWithDyn computes the SSZ hash tree root of the *BLSToExecutionChange using dynamic specifications and the given hash walker. +func (t *BLSToExecutionChange) HashTreeRootWithDyn(_ sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + return t.HashTreeRootWith(hh) +} + +// MarshalSSZDyn marshals the *SignedBLSToExecutionChange to SSZ-encoded bytes using dynamic specifications. +func (t *SignedBLSToExecutionChange) MarshalSSZDyn(ds sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + dst = buf + if t == nil { + t = new(SignedBLSToExecutionChange) + } + { // Static Field #0 'Message' + t := t.Message + if t == nil { + t = new(BLSToExecutionChange) + } + if dst, err = t.MarshalSSZDyn(ds, dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "Message") + } + } + { // Static Field #1 'Signature' + dst = append(dst, t.Signature[:96]...) + } + return dst, nil +} + +// MarshalSSZEncoder marshals the *SignedBLSToExecutionChange to the given SSZ encoder using dynamic specifications. +func (t *SignedBLSToExecutionChange) MarshalSSZEncoder(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + if t == nil { + t = new(SignedBLSToExecutionChange) + } + { // Field #0 'Message' + t := t.Message + if t == nil { + t = new(BLSToExecutionChange) + } + if err = t.MarshalSSZEncoder(ds, enc); err != nil { + return sszutils.ErrorWithPath(err, "Message") + } + } + { // Field #1 'Signature' + enc.EncodeBytes(t.Signature[:96]) + } + return nil +} + +// UnmarshalSSZDyn unmarshals the *SignedBLSToExecutionChange from SSZ-encoded bytes using dynamic specifications. +func (t *SignedBLSToExecutionChange) UnmarshalSSZDyn(ds sszutils.DynamicSpecs, buf []byte) (err error) { + buflen := len(buf) + if buflen < 172 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 172) + } + if buflen > 172 { + return sszutils.ErrTrailingDataFn(buflen - 172) + } + { // Field #0 'Message' (static) + buf := buf[0:76] + if t.Message == nil { + t.Message = new(BLSToExecutionChange) + } + if err = t.Message.UnmarshalSSZDyn(ds, buf); err != nil { + return sszutils.ErrorWithPath(err, "Message") + } + } + { // Field #1 'Signature' (static) + buf := buf[76:172] + copy(t.Signature[:], buf) + } + return nil +} + +// UnmarshalSSZDecoder unmarshals the *SignedBLSToExecutionChange from the given SSZ decoder using dynamic specifications. +func (t *SignedBLSToExecutionChange) UnmarshalSSZDecoder(ds sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { + maxOffset := uint32(dec.GetLength()) + if maxOffset < uint32(172) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(172)) + } + // Field #0 'Message' (static) + if t.Message == nil { + t.Message = new(BLSToExecutionChange) + } + if err = t.Message.UnmarshalSSZDecoder(ds, dec); err != nil { + return sszutils.ErrorWithPath(err, "Message") + } + // Field #1 'Signature' (static) + if _, err = dec.DecodeBytes(t.Signature[:96]); err != nil { + return err + } + return nil +} + +// SizeSSZ returns the SSZ encoded size of the *SignedBLSToExecutionChange. +func (t *SignedBLSToExecutionChange) SizeSSZ() (size int) { + return 172 +} + +// SizeSSZDyn returns the SSZ encoded size of the *SignedBLSToExecutionChange using dynamic specifications. +func (t *SignedBLSToExecutionChange) SizeSSZDyn(_ sszutils.DynamicSpecs) (size int) { + return t.SizeSSZ() +} + +// HashTreeRootDyn computes the SSZ hash tree root of the *SignedBLSToExecutionChange using dynamic specifications. +func (t *SignedBLSToExecutionChange) HashTreeRootDyn(ds sszutils.DynamicSpecs) (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWithDyn(ds, hh) + if err == nil { + root, err = hh.HashRoot() + } + return + }) + return +} + +// HashTreeRootWithDyn computes the SSZ hash tree root of the *SignedBLSToExecutionChange using dynamic specifications and the given hash walker. +func (t *SignedBLSToExecutionChange) HashTreeRootWithDyn(ds sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + if t == nil { + t = new(SignedBLSToExecutionChange) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Message' + t := t.Message + if t == nil { + t = new(BLSToExecutionChange) + } + if err := t.HashTreeRootWithDyn(ds, hh); err != nil { + return sszutils.ErrorWithPath(err, "Message") + } + } + { // Field #1 'Signature' + hh.PutBytes(t.Signature[:96]) + } + hh.Merkleize(idx) + return nil +} + +// MarshalSSZTo marshals the *DepositDataNoSignature to SSZ-encoded bytes, appending to the provided buffer. +func (t *DepositDataNoSignature) MarshalSSZTo(buf []byte) (dst []byte, err error) { + dst = buf + if t == nil { + t = new(DepositDataNoSignature) + } + { // Static Field #0 'PublicKey' + vlen := len(t.PublicKey) + if vlen > 48 { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 48), "PublicKey") + } + dst = append(dst, t.PublicKey[:vlen]...) + if vlen < 48 { + dst = sszutils.AppendZeroPadding(dst, (48-vlen)*1) + } + } + { // Static Field #1 'WithdrawalCredentials' + vlen := len(t.WithdrawalCredentials) + if vlen > 32 { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 32), "WithdrawalCredentials") + } + dst = append(dst, t.WithdrawalCredentials[:vlen]...) + if vlen < 32 { + dst = sszutils.AppendZeroPadding(dst, (32-vlen)*1) + } + } + { // Static Field #2 'Amount' + dst = binary.LittleEndian.AppendUint64(dst, t.Amount) + } + return dst, nil +} + +// MarshalSSZDyn marshals the *DepositDataNoSignature to SSZ-encoded bytes using dynamic specifications. +func (t *DepositDataNoSignature) MarshalSSZDyn(_ sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + return t.MarshalSSZTo(buf) +} + +// MarshalSSZEncoder marshals the *DepositDataNoSignature to the given SSZ encoder using dynamic specifications. +func (t *DepositDataNoSignature) MarshalSSZEncoder(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + if t == nil { + t = new(DepositDataNoSignature) + } + { // Field #0 'PublicKey' + vlen := len(t.PublicKey) + if vlen > 48 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 48), "PublicKey") + } + enc.EncodeBytes(t.PublicKey[:vlen]) + if vlen < 48 { + enc.EncodeZeroPadding((48 - vlen) * 1) + } + } + { // Field #1 'WithdrawalCredentials' + vlen := len(t.WithdrawalCredentials) + if vlen > 32 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 32), "WithdrawalCredentials") + } + enc.EncodeBytes(t.WithdrawalCredentials[:vlen]) + if vlen < 32 { + enc.EncodeZeroPadding((32 - vlen) * 1) + } + } + { // Field #2 'Amount' + enc.EncodeUint64(t.Amount) + } + return nil +} + +// UnmarshalSSZ unmarshals the *DepositDataNoSignature from SSZ-encoded bytes. +func (t *DepositDataNoSignature) UnmarshalSSZ(buf []byte) (err error) { + buflen := len(buf) + if buflen < 88 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 88) + } + if buflen > 88 { + return sszutils.ErrTrailingDataFn(buflen - 88) + } + { // Field #0 'PublicKey' (static) + buf := buf[0:48] + t.PublicKey = sszutils.ExpandSlice(t.PublicKey, 48) + copy(t.PublicKey[:], buf) + } + { // Field #1 'WithdrawalCredentials' (static) + buf := buf[48:80] + t.WithdrawalCredentials = sszutils.ExpandSlice(t.WithdrawalCredentials, 32) + copy(t.WithdrawalCredentials[:], buf) + } + { // Field #2 'Amount' (static) + buf := buf[80:88] + t.Amount = binary.LittleEndian.Uint64(buf) + } + return nil +} + +// UnmarshalSSZDyn unmarshals the *DepositDataNoSignature from SSZ-encoded bytes using dynamic specifications. +func (t *DepositDataNoSignature) UnmarshalSSZDyn(_ sszutils.DynamicSpecs, buf []byte) (err error) { + return t.UnmarshalSSZ(buf) +} + +// UnmarshalSSZDecoder unmarshals the *DepositDataNoSignature from the given SSZ decoder using dynamic specifications. +func (t *DepositDataNoSignature) UnmarshalSSZDecoder(_ sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { + maxOffset := uint32(dec.GetLength()) + if maxOffset < uint32(88) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(88)) + } + // Field #0 'PublicKey' (static) + t.PublicKey = sszutils.ExpandSlice(t.PublicKey, 48) + if _, err = dec.DecodeBytes(t.PublicKey[:48]); err != nil { + return err + } + // Field #1 'WithdrawalCredentials' (static) + t.WithdrawalCredentials = sszutils.ExpandSlice(t.WithdrawalCredentials, 32) + if _, err = dec.DecodeBytes(t.WithdrawalCredentials[:32]); err != nil { + return err + } + // Field #2 'Amount' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "Amount") + } else { + t.Amount = val + } + return nil +} + +// SizeSSZ returns the SSZ encoded size of the *DepositDataNoSignature. +func (t *DepositDataNoSignature) SizeSSZ() (size int) { + return 88 +} + +// SizeSSZDyn returns the SSZ encoded size of the *DepositDataNoSignature using dynamic specifications. +func (t *DepositDataNoSignature) SizeSSZDyn(_ sszutils.DynamicSpecs) (size int) { + return t.SizeSSZ() +} + +// HashTreeRoot computes the SSZ hash tree root of the *DepositDataNoSignature. +func (t *DepositDataNoSignature) 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 *DepositDataNoSignature using the given hash walker. +func (t *DepositDataNoSignature) HashTreeRootWith(hh sszutils.HashWalker) error { + if t == nil { + t = new(DepositDataNoSignature) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'PublicKey' + vlen := len(t.PublicKey) + if vlen > 48 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 48), "PublicKey") + } + val := t.PublicKey[:] + if vlen < 48 { + val = sszutils.AppendZeroPadding(val, (48-vlen)*1) + } + hh.PutBytes(val[:48]) + } + { // Field #1 'WithdrawalCredentials' + vlen := len(t.WithdrawalCredentials) + if vlen > 32 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 32), "WithdrawalCredentials") + } + val := t.WithdrawalCredentials[:] + if vlen < 32 { + val = sszutils.AppendZeroPadding(val, (32-vlen)*1) + } + hh.PutBytes(val[:32]) + } + { // Field #2 'Amount' + hh.PutUint64(t.Amount) + } + hh.Merkleize(idx) + return nil +} + +// HashTreeRootDyn computes the SSZ hash tree root of the *DepositDataNoSignature using dynamic specifications. +func (t *DepositDataNoSignature) HashTreeRootDyn(ds sszutils.DynamicSpecs) (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWithDyn(ds, hh) + if err == nil { + root, err = hh.HashRoot() + } + return + }) + return +} + +// HashTreeRootWithDyn computes the SSZ hash tree root of the *DepositDataNoSignature using dynamic specifications and the given hash walker. +func (t *DepositDataNoSignature) HashTreeRootWithDyn(_ sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + return t.HashTreeRootWith(hh) +} + +// MarshalSSZTo marshals the *DepositData to SSZ-encoded bytes, appending to the provided buffer. +func (t *DepositData) MarshalSSZTo(buf []byte) (dst []byte, err error) { + dst = buf + if t == nil { + t = new(DepositData) + } + { // Static Field #0 'PublicKey' + vlen := len(t.PublicKey) + if vlen > 48 { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 48), "PublicKey") + } + dst = append(dst, t.PublicKey[:vlen]...) + if vlen < 48 { + dst = sszutils.AppendZeroPadding(dst, (48-vlen)*1) + } + } + { // Static Field #1 'WithdrawalCredentials' + vlen := len(t.WithdrawalCredentials) + if vlen > 32 { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 32), "WithdrawalCredentials") + } + dst = append(dst, t.WithdrawalCredentials[:vlen]...) + if vlen < 32 { + dst = sszutils.AppendZeroPadding(dst, (32-vlen)*1) + } + } + { // Static Field #2 'Amount' + dst = binary.LittleEndian.AppendUint64(dst, t.Amount) + } + { // Static Field #3 'Signature' + vlen := len(t.Signature) + if vlen > 96 { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 96), "Signature") + } + dst = append(dst, t.Signature[:vlen]...) + if vlen < 96 { + dst = sszutils.AppendZeroPadding(dst, (96-vlen)*1) + } + } + return dst, nil +} + +// MarshalSSZDyn marshals the *DepositData to SSZ-encoded bytes using dynamic specifications. +func (t *DepositData) MarshalSSZDyn(_ sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + return t.MarshalSSZTo(buf) +} + +// MarshalSSZEncoder marshals the *DepositData to the given SSZ encoder using dynamic specifications. +func (t *DepositData) MarshalSSZEncoder(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + if t == nil { + t = new(DepositData) + } + { // Field #0 'PublicKey' + vlen := len(t.PublicKey) + if vlen > 48 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 48), "PublicKey") + } + enc.EncodeBytes(t.PublicKey[:vlen]) + if vlen < 48 { + enc.EncodeZeroPadding((48 - vlen) * 1) + } + } + { // Field #1 'WithdrawalCredentials' + vlen := len(t.WithdrawalCredentials) + if vlen > 32 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 32), "WithdrawalCredentials") + } + enc.EncodeBytes(t.WithdrawalCredentials[:vlen]) + if vlen < 32 { + enc.EncodeZeroPadding((32 - vlen) * 1) + } + } + { // Field #2 'Amount' + enc.EncodeUint64(t.Amount) + } + { // Field #3 'Signature' + vlen := len(t.Signature) + if vlen > 96 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 96), "Signature") + } + enc.EncodeBytes(t.Signature[:vlen]) + if vlen < 96 { + enc.EncodeZeroPadding((96 - vlen) * 1) + } + } + return nil +} + +// UnmarshalSSZ unmarshals the *DepositData from SSZ-encoded bytes. +func (t *DepositData) UnmarshalSSZ(buf []byte) (err error) { + buflen := len(buf) + if buflen < 184 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 184) + } + if buflen > 184 { + return sszutils.ErrTrailingDataFn(buflen - 184) + } + { // Field #0 'PublicKey' (static) + buf := buf[0:48] + t.PublicKey = sszutils.ExpandSlice(t.PublicKey, 48) + copy(t.PublicKey[:], buf) + } + { // Field #1 'WithdrawalCredentials' (static) + buf := buf[48:80] + t.WithdrawalCredentials = sszutils.ExpandSlice(t.WithdrawalCredentials, 32) + copy(t.WithdrawalCredentials[:], buf) + } + { // Field #2 'Amount' (static) + buf := buf[80:88] + t.Amount = binary.LittleEndian.Uint64(buf) + } + { // Field #3 'Signature' (static) + buf := buf[88:184] + t.Signature = sszutils.ExpandSlice(t.Signature, 96) + copy(t.Signature[:], buf) + } + return nil +} + +// UnmarshalSSZDyn unmarshals the *DepositData from SSZ-encoded bytes using dynamic specifications. +func (t *DepositData) UnmarshalSSZDyn(_ sszutils.DynamicSpecs, buf []byte) (err error) { + return t.UnmarshalSSZ(buf) +} + +// UnmarshalSSZDecoder unmarshals the *DepositData from the given SSZ decoder using dynamic specifications. +func (t *DepositData) UnmarshalSSZDecoder(_ sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { + maxOffset := uint32(dec.GetLength()) + if maxOffset < uint32(184) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(184)) + } + // Field #0 'PublicKey' (static) + t.PublicKey = sszutils.ExpandSlice(t.PublicKey, 48) + if _, err = dec.DecodeBytes(t.PublicKey[:48]); err != nil { + return err + } + // Field #1 'WithdrawalCredentials' (static) + t.WithdrawalCredentials = sszutils.ExpandSlice(t.WithdrawalCredentials, 32) + if _, err = dec.DecodeBytes(t.WithdrawalCredentials[:32]); err != nil { + return err + } + // Field #2 'Amount' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "Amount") + } else { + t.Amount = val + } + // Field #3 'Signature' (static) + t.Signature = sszutils.ExpandSlice(t.Signature, 96) + if _, err = dec.DecodeBytes(t.Signature[:96]); err != nil { + return err + } + return nil +} + +// SizeSSZ returns the SSZ encoded size of the *DepositData. +func (t *DepositData) SizeSSZ() (size int) { + return 184 +} + +// SizeSSZDyn returns the SSZ encoded size of the *DepositData using dynamic specifications. +func (t *DepositData) SizeSSZDyn(_ sszutils.DynamicSpecs) (size int) { + return t.SizeSSZ() +} + +// HashTreeRoot computes the SSZ hash tree root of the *DepositData. +func (t *DepositData) 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 *DepositData using the given hash walker. +func (t *DepositData) HashTreeRootWith(hh sszutils.HashWalker) error { + if t == nil { + t = new(DepositData) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'PublicKey' + vlen := len(t.PublicKey) + if vlen > 48 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 48), "PublicKey") + } + val := t.PublicKey[:] + if vlen < 48 { + val = sszutils.AppendZeroPadding(val, (48-vlen)*1) + } + hh.PutBytes(val[:48]) + } + { // Field #1 'WithdrawalCredentials' + vlen := len(t.WithdrawalCredentials) + if vlen > 32 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 32), "WithdrawalCredentials") + } + val := t.WithdrawalCredentials[:] + if vlen < 32 { + val = sszutils.AppendZeroPadding(val, (32-vlen)*1) + } + hh.PutBytes(val[:32]) + } + { // Field #2 'Amount' + hh.PutUint64(t.Amount) + } + { // Field #3 'Signature' + vlen := len(t.Signature) + if vlen > 96 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 96), "Signature") + } + val := t.Signature[:] + if vlen < 96 { + val = sszutils.AppendZeroPadding(val, (96-vlen)*1) + } + hh.PutBytes(val[:96]) + } + hh.Merkleize(idx) + return nil +} + +// HashTreeRootDyn computes the SSZ hash tree root of the *DepositData using dynamic specifications. +func (t *DepositData) HashTreeRootDyn(ds sszutils.DynamicSpecs) (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWithDyn(ds, hh) + if err == nil { + root, err = hh.HashRoot() + } + return + }) + return +} + +// HashTreeRootWithDyn computes the SSZ hash tree root of the *DepositData using dynamic specifications and the given hash walker. +func (t *DepositData) HashTreeRootWithDyn(_ sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + return t.HashTreeRootWith(hh) +} + +// MarshalSSZTo marshals the *SigningRoot to SSZ-encoded bytes, appending to the provided buffer. +func (t *SigningRoot) MarshalSSZTo(buf []byte) (dst []byte, err error) { + dst = buf + if t == nil { + t = new(SigningRoot) + } + { // Static Field #0 'ObjectRoot' + vlen := len(t.ObjectRoot) + if vlen > 32 { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 32), "ObjectRoot") + } + dst = append(dst, t.ObjectRoot[:vlen]...) + if vlen < 32 { + dst = sszutils.AppendZeroPadding(dst, (32-vlen)*1) + } + } + { // Static Field #1 'Domain' + vlen := len(t.Domain) + if vlen > 32 { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 32), "Domain") + } + dst = append(dst, t.Domain[:vlen]...) + if vlen < 32 { + dst = sszutils.AppendZeroPadding(dst, (32-vlen)*1) + } + } + return dst, nil +} + +// MarshalSSZDyn marshals the *SigningRoot to SSZ-encoded bytes using dynamic specifications. +func (t *SigningRoot) MarshalSSZDyn(_ sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + return t.MarshalSSZTo(buf) +} + +// MarshalSSZEncoder marshals the *SigningRoot to the given SSZ encoder using dynamic specifications. +func (t *SigningRoot) MarshalSSZEncoder(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + if t == nil { + t = new(SigningRoot) + } + { // Field #0 'ObjectRoot' + vlen := len(t.ObjectRoot) + if vlen > 32 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 32), "ObjectRoot") + } + enc.EncodeBytes(t.ObjectRoot[:vlen]) + if vlen < 32 { + enc.EncodeZeroPadding((32 - vlen) * 1) + } + } + { // Field #1 'Domain' + vlen := len(t.Domain) + if vlen > 32 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 32), "Domain") + } + enc.EncodeBytes(t.Domain[:vlen]) + if vlen < 32 { + enc.EncodeZeroPadding((32 - vlen) * 1) + } + } + return nil +} + +// UnmarshalSSZ unmarshals the *SigningRoot from SSZ-encoded bytes. +func (t *SigningRoot) UnmarshalSSZ(buf []byte) (err error) { + buflen := len(buf) + if buflen < 64 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 64) + } + if buflen > 64 { + return sszutils.ErrTrailingDataFn(buflen - 64) + } + { // Field #0 'ObjectRoot' (static) + buf := buf[0:32] + t.ObjectRoot = sszutils.ExpandSlice(t.ObjectRoot, 32) + copy(t.ObjectRoot[:], buf) + } + { // Field #1 'Domain' (static) + buf := buf[32:64] + t.Domain = sszutils.ExpandSlice(t.Domain, 32) + copy(t.Domain[:], buf) + } + return nil +} + +// UnmarshalSSZDyn unmarshals the *SigningRoot from SSZ-encoded bytes using dynamic specifications. +func (t *SigningRoot) UnmarshalSSZDyn(_ sszutils.DynamicSpecs, buf []byte) (err error) { + return t.UnmarshalSSZ(buf) +} + +// UnmarshalSSZDecoder unmarshals the *SigningRoot from the given SSZ decoder using dynamic specifications. +func (t *SigningRoot) UnmarshalSSZDecoder(_ sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { + maxOffset := uint32(dec.GetLength()) + if maxOffset < uint32(64) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(64)) + } + // Field #0 'ObjectRoot' (static) + t.ObjectRoot = sszutils.ExpandSlice(t.ObjectRoot, 32) + if _, err = dec.DecodeBytes(t.ObjectRoot[:32]); err != nil { + return err + } + // Field #1 'Domain' (static) + t.Domain = sszutils.ExpandSlice(t.Domain, 32) + if _, err = dec.DecodeBytes(t.Domain[:32]); err != nil { + return err + } + return nil +} + +// SizeSSZ returns the SSZ encoded size of the *SigningRoot. +func (t *SigningRoot) SizeSSZ() (size int) { + return 64 +} + +// SizeSSZDyn returns the SSZ encoded size of the *SigningRoot using dynamic specifications. +func (t *SigningRoot) SizeSSZDyn(_ sszutils.DynamicSpecs) (size int) { + return t.SizeSSZ() +} + +// HashTreeRoot computes the SSZ hash tree root of the *SigningRoot. +func (t *SigningRoot) 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 *SigningRoot using the given hash walker. +func (t *SigningRoot) HashTreeRootWith(hh sszutils.HashWalker) error { + if t == nil { + t = new(SigningRoot) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'ObjectRoot' + vlen := len(t.ObjectRoot) + if vlen > 32 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 32), "ObjectRoot") + } + val := t.ObjectRoot[:] + if vlen < 32 { + val = sszutils.AppendZeroPadding(val, (32-vlen)*1) + } + hh.PutBytes(val[:32]) + } + { // Field #1 'Domain' + vlen := len(t.Domain) + if vlen > 32 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 32), "Domain") + } + val := t.Domain[:] + if vlen < 32 { + val = sszutils.AppendZeroPadding(val, (32-vlen)*1) + } + hh.PutBytes(val[:32]) + } + hh.Merkleize(idx) + return nil +} + +// HashTreeRootDyn computes the SSZ hash tree root of the *SigningRoot using dynamic specifications. +func (t *SigningRoot) HashTreeRootDyn(ds sszutils.DynamicSpecs) (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWithDyn(ds, hh) + if err == nil { + root, err = hh.HashRoot() + } + return + }) + return +} + +// HashTreeRootWithDyn computes the SSZ hash tree root of the *SigningRoot using dynamic specifications and the given hash walker. +func (t *SigningRoot) HashTreeRootWithDyn(_ sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + return t.HashTreeRootWith(hh) +} + +// MarshalSSZTo marshals the *VoluntaryExit to SSZ-encoded bytes, appending to the provided buffer. +func (t *VoluntaryExit) MarshalSSZTo(buf []byte) (dst []byte, err error) { + dst = buf + if t == nil { + t = new(VoluntaryExit) + } + { // Static Field #0 'Epoch' + dst = binary.LittleEndian.AppendUint64(dst, t.Epoch) + } + { // Static Field #1 'ValidatorIndex' + dst = binary.LittleEndian.AppendUint64(dst, t.ValidatorIndex) + } + return dst, nil +} + +// MarshalSSZDyn marshals the *VoluntaryExit to SSZ-encoded bytes using dynamic specifications. +func (t *VoluntaryExit) MarshalSSZDyn(_ sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + return t.MarshalSSZTo(buf) +} + +// MarshalSSZEncoder marshals the *VoluntaryExit to the given SSZ encoder using dynamic specifications. +func (t *VoluntaryExit) MarshalSSZEncoder(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + if t == nil { + t = new(VoluntaryExit) + } + { // Field #0 'Epoch' + enc.EncodeUint64(t.Epoch) + } + { // Field #1 'ValidatorIndex' + enc.EncodeUint64(t.ValidatorIndex) + } + return nil +} + +// UnmarshalSSZ unmarshals the *VoluntaryExit from SSZ-encoded bytes. +func (t *VoluntaryExit) UnmarshalSSZ(buf []byte) (err error) { + buflen := len(buf) + if buflen < 16 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 16) + } + if buflen > 16 { + return sszutils.ErrTrailingDataFn(buflen - 16) + } + { // Field #0 'Epoch' (static) + buf := buf[0:8] + t.Epoch = binary.LittleEndian.Uint64(buf) + } + { // Field #1 'ValidatorIndex' (static) + buf := buf[8:16] + t.ValidatorIndex = binary.LittleEndian.Uint64(buf) + } + return nil +} + +// UnmarshalSSZDyn unmarshals the *VoluntaryExit from SSZ-encoded bytes using dynamic specifications. +func (t *VoluntaryExit) UnmarshalSSZDyn(_ sszutils.DynamicSpecs, buf []byte) (err error) { + return t.UnmarshalSSZ(buf) +} + +// UnmarshalSSZDecoder unmarshals the *VoluntaryExit from the given SSZ decoder using dynamic specifications. +func (t *VoluntaryExit) UnmarshalSSZDecoder(_ sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { + maxOffset := uint32(dec.GetLength()) + if maxOffset < uint32(16) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(16)) + } + // Field #0 'Epoch' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "Epoch") + } else { + t.Epoch = val + } + // Field #1 'ValidatorIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "ValidatorIndex") + } else { + t.ValidatorIndex = val + } + return nil +} + +// SizeSSZ returns the SSZ encoded size of the *VoluntaryExit. +func (t *VoluntaryExit) SizeSSZ() (size int) { + return 16 +} + +// SizeSSZDyn returns the SSZ encoded size of the *VoluntaryExit using dynamic specifications. +func (t *VoluntaryExit) SizeSSZDyn(_ sszutils.DynamicSpecs) (size int) { + return t.SizeSSZ() +} + +// HashTreeRoot computes the SSZ hash tree root of the *VoluntaryExit. +func (t *VoluntaryExit) 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 *VoluntaryExit using the given hash walker. +func (t *VoluntaryExit) HashTreeRootWith(hh sszutils.HashWalker) error { + if t == nil { + t = new(VoluntaryExit) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Epoch' + hh.PutUint64(t.Epoch) + } + { // Field #1 'ValidatorIndex' + hh.PutUint64(t.ValidatorIndex) + } + hh.Merkleize(idx) + return nil +} + +// HashTreeRootDyn computes the SSZ hash tree root of the *VoluntaryExit using dynamic specifications. +func (t *VoluntaryExit) HashTreeRootDyn(ds sszutils.DynamicSpecs) (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWithDyn(ds, hh) + if err == nil { + root, err = hh.HashRoot() + } + return + }) + return +} + +// HashTreeRootWithDyn computes the SSZ hash tree root of the *VoluntaryExit using dynamic specifications and the given hash walker. +func (t *VoluntaryExit) HashTreeRootWithDyn(_ sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + return t.HashTreeRootWith(hh) +} + +// MarshalSSZTo marshals the *WithdrawalCredentialsChange to SSZ-encoded bytes, appending to the provided buffer. +func (t *WithdrawalCredentialsChange) MarshalSSZTo(buf []byte) (dst []byte, err error) { + dst = buf + if t == nil { + t = new(WithdrawalCredentialsChange) + } + { // Static Field #0 'ValidatorIndex' + dst = binary.LittleEndian.AppendUint64(dst, t.ValidatorIndex) + } + { // Static Field #1 'FromBLSPubkey' + dst = append(dst, t.FromBLSPubkey[:48]...) + } + { // Static Field #2 'ToExecutionAddress' + dst = append(dst, t.ToExecutionAddress[:20]...) + } + return dst, nil +} + +// MarshalSSZDyn marshals the *WithdrawalCredentialsChange to SSZ-encoded bytes using dynamic specifications. +func (t *WithdrawalCredentialsChange) MarshalSSZDyn(_ sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + return t.MarshalSSZTo(buf) +} + +// MarshalSSZEncoder marshals the *WithdrawalCredentialsChange to the given SSZ encoder using dynamic specifications. +func (t *WithdrawalCredentialsChange) MarshalSSZEncoder(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + if t == nil { + t = new(WithdrawalCredentialsChange) + } + { // Field #0 'ValidatorIndex' + enc.EncodeUint64(t.ValidatorIndex) + } + { // Field #1 'FromBLSPubkey' + enc.EncodeBytes(t.FromBLSPubkey[:48]) + } + { // Field #2 'ToExecutionAddress' + enc.EncodeBytes(t.ToExecutionAddress[:20]) + } + return nil +} + +// UnmarshalSSZ unmarshals the *WithdrawalCredentialsChange from SSZ-encoded bytes. +func (t *WithdrawalCredentialsChange) UnmarshalSSZ(buf []byte) (err error) { + buflen := len(buf) + if buflen < 76 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 76) + } + if buflen > 76 { + return sszutils.ErrTrailingDataFn(buflen - 76) + } + { // Field #0 'ValidatorIndex' (static) + buf := buf[0:8] + t.ValidatorIndex = binary.LittleEndian.Uint64(buf) + } + { // Field #1 'FromBLSPubkey' (static) + buf := buf[8:56] + copy(t.FromBLSPubkey[:], buf) + } + { // Field #2 'ToExecutionAddress' (static) + buf := buf[56:76] + copy(t.ToExecutionAddress[:], buf) + } + return nil +} + +// UnmarshalSSZDyn unmarshals the *WithdrawalCredentialsChange from SSZ-encoded bytes using dynamic specifications. +func (t *WithdrawalCredentialsChange) UnmarshalSSZDyn(_ sszutils.DynamicSpecs, buf []byte) (err error) { + return t.UnmarshalSSZ(buf) +} + +// UnmarshalSSZDecoder unmarshals the *WithdrawalCredentialsChange from the given SSZ decoder using dynamic specifications. +func (t *WithdrawalCredentialsChange) UnmarshalSSZDecoder(_ sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { + maxOffset := uint32(dec.GetLength()) + if maxOffset < uint32(76) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(76)) + } + // Field #0 'ValidatorIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "ValidatorIndex") + } else { + t.ValidatorIndex = val + } + // Field #1 'FromBLSPubkey' (static) + if _, err = dec.DecodeBytes(t.FromBLSPubkey[:48]); err != nil { + return err + } + // Field #2 'ToExecutionAddress' (static) + if _, err = dec.DecodeBytes(t.ToExecutionAddress[:20]); err != nil { + return err + } + return nil +} + +// SizeSSZ returns the SSZ encoded size of the *WithdrawalCredentialsChange. +func (t *WithdrawalCredentialsChange) SizeSSZ() (size int) { + return 76 +} + +// SizeSSZDyn returns the SSZ encoded size of the *WithdrawalCredentialsChange using dynamic specifications. +func (t *WithdrawalCredentialsChange) SizeSSZDyn(_ sszutils.DynamicSpecs) (size int) { + return t.SizeSSZ() +} + +// HashTreeRoot computes the SSZ hash tree root of the *WithdrawalCredentialsChange. +func (t *WithdrawalCredentialsChange) 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 *WithdrawalCredentialsChange using the given hash walker. +func (t *WithdrawalCredentialsChange) HashTreeRootWith(hh sszutils.HashWalker) error { + if t == nil { + t = new(WithdrawalCredentialsChange) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'ValidatorIndex' + hh.PutUint64(t.ValidatorIndex) + } + { // Field #1 'FromBLSPubkey' + hh.PutBytes(t.FromBLSPubkey[:48]) + } + { // Field #2 'ToExecutionAddress' + hh.PutBytes(t.ToExecutionAddress[:20]) + } + hh.Merkleize(idx) + return nil +} + +// HashTreeRootDyn computes the SSZ hash tree root of the *WithdrawalCredentialsChange using dynamic specifications. +func (t *WithdrawalCredentialsChange) HashTreeRootDyn(ds sszutils.DynamicSpecs) (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWithDyn(ds, hh) + if err == nil { + root, err = hh.HashRoot() + } + return + }) + return +} + +// HashTreeRootWithDyn computes the SSZ hash tree root of the *WithdrawalCredentialsChange using dynamic specifications and the given hash walker. +func (t *WithdrawalCredentialsChange) HashTreeRootWithDyn(_ sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + return t.HashTreeRootWith(hh) +} + +// MarshalSSZTo marshals the *Uint256 to SSZ-encoded bytes, appending to the provided buffer. +func (t *Uint256) MarshalSSZTo(buf []byte) (dst []byte, err error) { + dst = buf + if t == nil { + t = new(Uint256) + } + dst = append(dst, (*t)[:32]...) + return dst, nil +} + +// MarshalSSZDyn marshals the *Uint256 to SSZ-encoded bytes using dynamic specifications. +func (t *Uint256) MarshalSSZDyn(_ sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + return t.MarshalSSZTo(buf) +} + +// MarshalSSZEncoder marshals the *Uint256 to the given SSZ encoder using dynamic specifications. +func (t *Uint256) MarshalSSZEncoder(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + if t == nil { + t = new(Uint256) + } + enc.EncodeBytes((*t)[:32]) + return nil +} + +// UnmarshalSSZ unmarshals the *Uint256 from SSZ-encoded bytes. +func (t *Uint256) UnmarshalSSZ(buf []byte) (err error) { + if 32 > len(buf) { + return sszutils.ErrByteVectorEOFFn(len(buf), 32) + } + copy((*t)[:], buf) + return nil +} + +// UnmarshalSSZDyn unmarshals the *Uint256 from SSZ-encoded bytes using dynamic specifications. +func (t *Uint256) UnmarshalSSZDyn(_ sszutils.DynamicSpecs, buf []byte) (err error) { + return t.UnmarshalSSZ(buf) +} + +// UnmarshalSSZDecoder unmarshals the *Uint256 from the given SSZ decoder using dynamic specifications. +func (t *Uint256) UnmarshalSSZDecoder(_ sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { + if 32 > dec.GetLength() { + return sszutils.ErrByteVectorEOFFn(dec.GetLength(), 32) + } + if _, err = dec.DecodeBytes((*t)[:32]); err != nil { + return err + } + return nil +} + +// SizeSSZ returns the SSZ encoded size of the *Uint256. +func (t *Uint256) SizeSSZ() (size int) { + return 32 +} + +// SizeSSZDyn returns the SSZ encoded size of the *Uint256 using dynamic specifications. +func (t *Uint256) SizeSSZDyn(_ sszutils.DynamicSpecs) (size int) { + return t.SizeSSZ() +} + +// HashTreeRoot computes the SSZ hash tree root of the *Uint256. +func (t *Uint256) 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 *Uint256 using the given hash walker. +func (t *Uint256) HashTreeRootWith(hh sszutils.HashWalker) error { + if t == nil { + t = new(Uint256) + } + hh.PutBytes((*t)[:32]) + return nil +} + +// HashTreeRootDyn computes the SSZ hash tree root of the *Uint256 using dynamic specifications. +func (t *Uint256) HashTreeRootDyn(ds sszutils.DynamicSpecs) (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWithDyn(ds, hh) + if err == nil { + root, err = hh.HashRoot() + } + return + }) + return +} + +// HashTreeRootWithDyn computes the SSZ hash tree root of the *Uint256 using dynamic specifications and the given hash walker. +func (t *Uint256) HashTreeRootWithDyn(_ sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + return t.HashTreeRootWith(hh) +} diff --git a/shared/types/eth2/generic/state_encoding.go b/shared/types/eth2/generic/state_encoding.go deleted file mode 100644 index a8a30160b..000000000 --- a/shared/types/eth2/generic/state_encoding.go +++ /dev/null @@ -1,513 +0,0 @@ -// Code generated by fastssz. DO NOT EDIT. -// Hash: 45dcf20c8163706ce0f2d8b0bde4b725e3eb6fcebbfc0b9cf9de80317ca8d032 -// Version: 0.1.3 -package generic - -import ( - ssz "github.com/ferranbt/fastssz" -) - -// MarshalSSZ ssz marshals the PendingDeposit object -func (p *PendingDeposit) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(p) -} - -// MarshalSSZTo ssz marshals the PendingDeposit object to a target array -func (p *PendingDeposit) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - - // Field (0) 'Pubkey' - if size := len(p.Pubkey); size != 48 { - err = ssz.ErrBytesLengthFn("PendingDeposit.Pubkey", size, 48) - return - } - dst = append(dst, p.Pubkey...) - - // Field (1) 'WithdrawalCredentials' - if size := len(p.WithdrawalCredentials); size != 32 { - err = ssz.ErrBytesLengthFn("PendingDeposit.WithdrawalCredentials", size, 32) - return - } - dst = append(dst, p.WithdrawalCredentials...) - - // Field (2) 'Amount' - dst = ssz.MarshalUint64(dst, p.Amount) - - // Field (3) 'Signature' - if size := len(p.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("PendingDeposit.Signature", size, 96) - return - } - dst = append(dst, p.Signature...) - - // Field (4) 'Slot' - dst = ssz.MarshalUint64(dst, p.Slot) - - return -} - -// UnmarshalSSZ ssz unmarshals the PendingDeposit object -func (p *PendingDeposit) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size != 192 { - return ssz.ErrSize - } - - // Field (0) 'Pubkey' - if cap(p.Pubkey) == 0 { - p.Pubkey = make([]byte, 0, len(buf[0:48])) - } - p.Pubkey = append(p.Pubkey, buf[0:48]...) - - // Field (1) 'WithdrawalCredentials' - if cap(p.WithdrawalCredentials) == 0 { - p.WithdrawalCredentials = make([]byte, 0, len(buf[48:80])) - } - p.WithdrawalCredentials = append(p.WithdrawalCredentials, buf[48:80]...) - - // Field (2) 'Amount' - p.Amount = ssz.UnmarshallUint64(buf[80:88]) - - // Field (3) 'Signature' - if cap(p.Signature) == 0 { - p.Signature = make([]byte, 0, len(buf[88:184])) - } - p.Signature = append(p.Signature, buf[88:184]...) - - // Field (4) 'Slot' - p.Slot = ssz.UnmarshallUint64(buf[184:192]) - - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the PendingDeposit object -func (p *PendingDeposit) SizeSSZ() (size int) { - size = 192 - return -} - -// HashTreeRoot ssz hashes the PendingDeposit object -func (p *PendingDeposit) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(p) -} - -// HashTreeRootWith ssz hashes the PendingDeposit object with a hasher -func (p *PendingDeposit) HashTreeRootWith(hh ssz.HashWalker) (err error) { - indx := hh.Index() - - // Field (0) 'Pubkey' - if size := len(p.Pubkey); size != 48 { - err = ssz.ErrBytesLengthFn("PendingDeposit.Pubkey", size, 48) - return - } - hh.PutBytes(p.Pubkey) - - // Field (1) 'WithdrawalCredentials' - if size := len(p.WithdrawalCredentials); size != 32 { - err = ssz.ErrBytesLengthFn("PendingDeposit.WithdrawalCredentials", size, 32) - return - } - hh.PutBytes(p.WithdrawalCredentials) - - // Field (2) 'Amount' - hh.PutUint64(p.Amount) - - // Field (3) 'Signature' - if size := len(p.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("PendingDeposit.Signature", size, 96) - return - } - hh.PutBytes(p.Signature) - - // Field (4) 'Slot' - hh.PutUint64(p.Slot) - - hh.Merkleize(indx) - return -} - -// GetTree ssz hashes the PendingDeposit object -func (p *PendingDeposit) GetTree() (*ssz.Node, error) { - return ssz.ProofTree(p) -} - -// MarshalSSZ ssz marshals the PendingPartialWithdrawal object -func (p *PendingPartialWithdrawal) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(p) -} - -// MarshalSSZTo ssz marshals the PendingPartialWithdrawal object to a target array -func (p *PendingPartialWithdrawal) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - - // Field (0) 'ValidatorIndex' - dst = ssz.MarshalUint64(dst, p.ValidatorIndex) - - // Field (1) 'Amount' - dst = ssz.MarshalUint64(dst, p.Amount) - - // Field (2) 'WithdrawableEpoch' - dst = ssz.MarshalUint64(dst, p.WithdrawableEpoch) - - return -} - -// UnmarshalSSZ ssz unmarshals the PendingPartialWithdrawal object -func (p *PendingPartialWithdrawal) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size != 24 { - return ssz.ErrSize - } - - // Field (0) 'ValidatorIndex' - p.ValidatorIndex = ssz.UnmarshallUint64(buf[0:8]) - - // Field (1) 'Amount' - p.Amount = ssz.UnmarshallUint64(buf[8:16]) - - // Field (2) 'WithdrawableEpoch' - p.WithdrawableEpoch = ssz.UnmarshallUint64(buf[16:24]) - - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the PendingPartialWithdrawal object -func (p *PendingPartialWithdrawal) SizeSSZ() (size int) { - size = 24 - return -} - -// HashTreeRoot ssz hashes the PendingPartialWithdrawal object -func (p *PendingPartialWithdrawal) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(p) -} - -// HashTreeRootWith ssz hashes the PendingPartialWithdrawal object with a hasher -func (p *PendingPartialWithdrawal) HashTreeRootWith(hh ssz.HashWalker) (err error) { - indx := hh.Index() - - // Field (0) 'ValidatorIndex' - hh.PutUint64(p.ValidatorIndex) - - // Field (1) 'Amount' - hh.PutUint64(p.Amount) - - // Field (2) 'WithdrawableEpoch' - hh.PutUint64(p.WithdrawableEpoch) - - hh.Merkleize(indx) - return -} - -// GetTree ssz hashes the PendingPartialWithdrawal object -func (p *PendingPartialWithdrawal) GetTree() (*ssz.Node, error) { - return ssz.ProofTree(p) -} - -// MarshalSSZ ssz marshals the PendingConsolidation object -func (p *PendingConsolidation) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(p) -} - -// MarshalSSZTo ssz marshals the PendingConsolidation object to a target array -func (p *PendingConsolidation) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - - // Field (0) 'SourceIndex' - dst = ssz.MarshalUint64(dst, p.SourceIndex) - - // Field (1) 'TargetIndex' - dst = ssz.MarshalUint64(dst, p.TargetIndex) - - return -} - -// UnmarshalSSZ ssz unmarshals the PendingConsolidation object -func (p *PendingConsolidation) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size != 16 { - return ssz.ErrSize - } - - // Field (0) 'SourceIndex' - p.SourceIndex = ssz.UnmarshallUint64(buf[0:8]) - - // Field (1) 'TargetIndex' - p.TargetIndex = ssz.UnmarshallUint64(buf[8:16]) - - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the PendingConsolidation object -func (p *PendingConsolidation) SizeSSZ() (size int) { - size = 16 - return -} - -// HashTreeRoot ssz hashes the PendingConsolidation object -func (p *PendingConsolidation) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(p) -} - -// HashTreeRootWith ssz hashes the PendingConsolidation object with a hasher -func (p *PendingConsolidation) HashTreeRootWith(hh ssz.HashWalker) (err error) { - indx := hh.Index() - - // Field (0) 'SourceIndex' - hh.PutUint64(p.SourceIndex) - - // Field (1) 'TargetIndex' - hh.PutUint64(p.TargetIndex) - - hh.Merkleize(indx) - return -} - -// GetTree ssz hashes the PendingConsolidation object -func (p *PendingConsolidation) GetTree() (*ssz.Node, error) { - return ssz.ProofTree(p) -} - -// MarshalSSZ ssz marshals the ExecutionPayloadHeader object -func (e *ExecutionPayloadHeader) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(e) -} - -// MarshalSSZTo ssz marshals the ExecutionPayloadHeader object to a target array -func (e *ExecutionPayloadHeader) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(584) - - // Field (0) 'ParentHash' - dst = append(dst, e.ParentHash[:]...) - - // Field (1) 'FeeRecipient' - dst = append(dst, e.FeeRecipient[:]...) - - // Field (2) 'StateRoot' - dst = append(dst, e.StateRoot[:]...) - - // Field (3) 'ReceiptsRoot' - dst = append(dst, e.ReceiptsRoot[:]...) - - // Field (4) 'LogsBloom' - dst = append(dst, e.LogsBloom[:]...) - - // Field (5) 'PrevRandao' - dst = append(dst, e.PrevRandao[:]...) - - // Field (6) 'BlockNumber' - dst = ssz.MarshalUint64(dst, e.BlockNumber) - - // Field (7) 'GasLimit' - dst = ssz.MarshalUint64(dst, e.GasLimit) - - // Field (8) 'GasUsed' - dst = ssz.MarshalUint64(dst, e.GasUsed) - - // Field (9) 'Timestamp' - dst = ssz.MarshalUint64(dst, e.Timestamp) - - // Offset (10) 'ExtraData' - dst = ssz.WriteOffset(dst, offset) - - // Field (11) 'BaseFeePerGas' - dst = append(dst, e.BaseFeePerGas[:]...) - - // Field (12) 'BlockHash' - dst = append(dst, e.BlockHash[:]...) - - // Field (13) 'TransactionsRoot' - dst = append(dst, e.TransactionsRoot[:]...) - - // Field (14) 'WithdrawalRoot' - dst = append(dst, e.WithdrawalRoot[:]...) - - // Field (15) 'BlobGasUsed' - dst = ssz.MarshalUint64(dst, e.BlobGasUsed) - - // Field (16) 'ExcessBlobGas' - dst = ssz.MarshalUint64(dst, e.ExcessBlobGas) - - // Field (10) 'ExtraData' - if size := len(e.ExtraData); size > 32 { - err = ssz.ErrBytesLengthFn("ExecutionPayloadHeader.ExtraData", size, 32) - return - } - dst = append(dst, e.ExtraData...) - - return -} - -// UnmarshalSSZ ssz unmarshals the ExecutionPayloadHeader object -func (e *ExecutionPayloadHeader) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 584 { - return ssz.ErrSize - } - - tail := buf - var o10 uint64 - - // Field (0) 'ParentHash' - copy(e.ParentHash[:], buf[0:32]) - - // Field (1) 'FeeRecipient' - copy(e.FeeRecipient[:], buf[32:52]) - - // Field (2) 'StateRoot' - copy(e.StateRoot[:], buf[52:84]) - - // Field (3) 'ReceiptsRoot' - copy(e.ReceiptsRoot[:], buf[84:116]) - - // Field (4) 'LogsBloom' - copy(e.LogsBloom[:], buf[116:372]) - - // Field (5) 'PrevRandao' - copy(e.PrevRandao[:], buf[372:404]) - - // Field (6) 'BlockNumber' - e.BlockNumber = ssz.UnmarshallUint64(buf[404:412]) - - // Field (7) 'GasLimit' - e.GasLimit = ssz.UnmarshallUint64(buf[412:420]) - - // Field (8) 'GasUsed' - e.GasUsed = ssz.UnmarshallUint64(buf[420:428]) - - // Field (9) 'Timestamp' - e.Timestamp = ssz.UnmarshallUint64(buf[428:436]) - - // Offset (10) 'ExtraData' - if o10 = ssz.ReadOffset(buf[436:440]); o10 > size { - return ssz.ErrOffset - } - - if o10 != 584 { - return ssz.ErrInvalidVariableOffset - } - - // Field (11) 'BaseFeePerGas' - copy(e.BaseFeePerGas[:], buf[440:472]) - - // Field (12) 'BlockHash' - copy(e.BlockHash[:], buf[472:504]) - - // Field (13) 'TransactionsRoot' - copy(e.TransactionsRoot[:], buf[504:536]) - - // Field (14) 'WithdrawalRoot' - copy(e.WithdrawalRoot[:], buf[536:568]) - - // Field (15) 'BlobGasUsed' - e.BlobGasUsed = ssz.UnmarshallUint64(buf[568:576]) - - // Field (16) 'ExcessBlobGas' - e.ExcessBlobGas = ssz.UnmarshallUint64(buf[576:584]) - - // Field (10) 'ExtraData' - { - buf = tail[o10:] - if len(buf) > 32 { - return ssz.ErrBytesLength - } - if cap(e.ExtraData) == 0 { - e.ExtraData = make([]byte, 0, len(buf)) - } - e.ExtraData = append(e.ExtraData, buf...) - } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the ExecutionPayloadHeader object -func (e *ExecutionPayloadHeader) SizeSSZ() (size int) { - size = 584 - - // Field (10) 'ExtraData' - size += len(e.ExtraData) - - return -} - -// HashTreeRoot ssz hashes the ExecutionPayloadHeader object -func (e *ExecutionPayloadHeader) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(e) -} - -// HashTreeRootWith ssz hashes the ExecutionPayloadHeader object with a hasher -func (e *ExecutionPayloadHeader) HashTreeRootWith(hh ssz.HashWalker) (err error) { - indx := hh.Index() - - // Field (0) 'ParentHash' - hh.PutBytes(e.ParentHash[:]) - - // Field (1) 'FeeRecipient' - hh.PutBytes(e.FeeRecipient[:]) - - // Field (2) 'StateRoot' - hh.PutBytes(e.StateRoot[:]) - - // Field (3) 'ReceiptsRoot' - hh.PutBytes(e.ReceiptsRoot[:]) - - // Field (4) 'LogsBloom' - hh.PutBytes(e.LogsBloom[:]) - - // Field (5) 'PrevRandao' - hh.PutBytes(e.PrevRandao[:]) - - // Field (6) 'BlockNumber' - hh.PutUint64(e.BlockNumber) - - // Field (7) 'GasLimit' - hh.PutUint64(e.GasLimit) - - // Field (8) 'GasUsed' - hh.PutUint64(e.GasUsed) - - // Field (9) 'Timestamp' - hh.PutUint64(e.Timestamp) - - // Field (10) 'ExtraData' - { - elemIndx := hh.Index() - byteLen := uint64(len(e.ExtraData)) - if byteLen > 32 { - err = ssz.ErrIncorrectListSize - return - } - hh.Append(e.ExtraData) - hh.MerkleizeWithMixin(elemIndx, byteLen, (32+31)/32) - } - - // Field (11) 'BaseFeePerGas' - hh.PutBytes(e.BaseFeePerGas[:]) - - // Field (12) 'BlockHash' - hh.PutBytes(e.BlockHash[:]) - - // Field (13) 'TransactionsRoot' - hh.PutBytes(e.TransactionsRoot[:]) - - // Field (14) 'WithdrawalRoot' - hh.PutBytes(e.WithdrawalRoot[:]) - - // Field (15) 'BlobGasUsed' - hh.PutUint64(e.BlobGasUsed) - - // Field (16) 'ExcessBlobGas' - hh.PutUint64(e.ExcessBlobGas) - - hh.Merkleize(indx) - return -} - -// GetTree ssz hashes the ExecutionPayloadHeader object -func (e *ExecutionPayloadHeader) GetTree() (*ssz.Node, error) { - return ssz.ProofTree(e) -} diff --git a/shared/types/eth2/generic/types_encoding.go b/shared/types/eth2/generic/types_encoding.go deleted file mode 100644 index 4924617eb..000000000 --- a/shared/types/eth2/generic/types_encoding.go +++ /dev/null @@ -1,1227 +0,0 @@ -// Code generated by fastssz. DO NOT EDIT. -// Hash: 45dcf20c8163706ce0f2d8b0bde4b725e3eb6fcebbfc0b9cf9de80317ca8d032 -// Version: 0.1.3 -package generic - -import ( - ssz "github.com/ferranbt/fastssz" -) - -// MarshalSSZ ssz marshals the DepositDataNoSignature object -func (d *DepositDataNoSignature) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(d) -} - -// MarshalSSZTo ssz marshals the DepositDataNoSignature object to a target array -func (d *DepositDataNoSignature) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - - // Field (0) 'PublicKey' - if size := len(d.PublicKey); size != 48 { - err = ssz.ErrBytesLengthFn("DepositDataNoSignature.PublicKey", size, 48) - return - } - dst = append(dst, d.PublicKey...) - - // Field (1) 'WithdrawalCredentials' - if size := len(d.WithdrawalCredentials); size != 32 { - err = ssz.ErrBytesLengthFn("DepositDataNoSignature.WithdrawalCredentials", size, 32) - return - } - dst = append(dst, d.WithdrawalCredentials...) - - // Field (2) 'Amount' - dst = ssz.MarshalUint64(dst, d.Amount) - - return -} - -// UnmarshalSSZ ssz unmarshals the DepositDataNoSignature object -func (d *DepositDataNoSignature) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size != 88 { - return ssz.ErrSize - } - - // Field (0) 'PublicKey' - if cap(d.PublicKey) == 0 { - d.PublicKey = make([]byte, 0, len(buf[0:48])) - } - d.PublicKey = append(d.PublicKey, buf[0:48]...) - - // Field (1) 'WithdrawalCredentials' - if cap(d.WithdrawalCredentials) == 0 { - d.WithdrawalCredentials = make([]byte, 0, len(buf[48:80])) - } - d.WithdrawalCredentials = append(d.WithdrawalCredentials, buf[48:80]...) - - // Field (2) 'Amount' - d.Amount = ssz.UnmarshallUint64(buf[80:88]) - - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the DepositDataNoSignature object -func (d *DepositDataNoSignature) SizeSSZ() (size int) { - size = 88 - return -} - -// HashTreeRoot ssz hashes the DepositDataNoSignature object -func (d *DepositDataNoSignature) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(d) -} - -// HashTreeRootWith ssz hashes the DepositDataNoSignature object with a hasher -func (d *DepositDataNoSignature) HashTreeRootWith(hh ssz.HashWalker) (err error) { - indx := hh.Index() - - // Field (0) 'PublicKey' - if size := len(d.PublicKey); size != 48 { - err = ssz.ErrBytesLengthFn("DepositDataNoSignature.PublicKey", size, 48) - return - } - hh.PutBytes(d.PublicKey) - - // Field (1) 'WithdrawalCredentials' - if size := len(d.WithdrawalCredentials); size != 32 { - err = ssz.ErrBytesLengthFn("DepositDataNoSignature.WithdrawalCredentials", size, 32) - return - } - hh.PutBytes(d.WithdrawalCredentials) - - // Field (2) 'Amount' - hh.PutUint64(d.Amount) - - hh.Merkleize(indx) - return -} - -// GetTree ssz hashes the DepositDataNoSignature object -func (d *DepositDataNoSignature) GetTree() (*ssz.Node, error) { - return ssz.ProofTree(d) -} - -// MarshalSSZ ssz marshals the DepositData object -func (d *DepositData) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(d) -} - -// MarshalSSZTo ssz marshals the DepositData object to a target array -func (d *DepositData) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - - // Field (0) 'PublicKey' - if size := len(d.PublicKey); size != 48 { - err = ssz.ErrBytesLengthFn("DepositData.PublicKey", size, 48) - return - } - dst = append(dst, d.PublicKey...) - - // Field (1) 'WithdrawalCredentials' - if size := len(d.WithdrawalCredentials); size != 32 { - err = ssz.ErrBytesLengthFn("DepositData.WithdrawalCredentials", size, 32) - return - } - dst = append(dst, d.WithdrawalCredentials...) - - // Field (2) 'Amount' - dst = ssz.MarshalUint64(dst, d.Amount) - - // Field (3) 'Signature' - if size := len(d.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("DepositData.Signature", size, 96) - return - } - dst = append(dst, d.Signature...) - - return -} - -// UnmarshalSSZ ssz unmarshals the DepositData object -func (d *DepositData) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size != 184 { - return ssz.ErrSize - } - - // Field (0) 'PublicKey' - if cap(d.PublicKey) == 0 { - d.PublicKey = make([]byte, 0, len(buf[0:48])) - } - d.PublicKey = append(d.PublicKey, buf[0:48]...) - - // Field (1) 'WithdrawalCredentials' - if cap(d.WithdrawalCredentials) == 0 { - d.WithdrawalCredentials = make([]byte, 0, len(buf[48:80])) - } - d.WithdrawalCredentials = append(d.WithdrawalCredentials, buf[48:80]...) - - // Field (2) 'Amount' - d.Amount = ssz.UnmarshallUint64(buf[80:88]) - - // Field (3) 'Signature' - if cap(d.Signature) == 0 { - d.Signature = make([]byte, 0, len(buf[88:184])) - } - d.Signature = append(d.Signature, buf[88:184]...) - - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the DepositData object -func (d *DepositData) SizeSSZ() (size int) { - size = 184 - return -} - -// HashTreeRoot ssz hashes the DepositData object -func (d *DepositData) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(d) -} - -// HashTreeRootWith ssz hashes the DepositData object with a hasher -func (d *DepositData) HashTreeRootWith(hh ssz.HashWalker) (err error) { - indx := hh.Index() - - // Field (0) 'PublicKey' - if size := len(d.PublicKey); size != 48 { - err = ssz.ErrBytesLengthFn("DepositData.PublicKey", size, 48) - return - } - hh.PutBytes(d.PublicKey) - - // Field (1) 'WithdrawalCredentials' - if size := len(d.WithdrawalCredentials); size != 32 { - err = ssz.ErrBytesLengthFn("DepositData.WithdrawalCredentials", size, 32) - return - } - hh.PutBytes(d.WithdrawalCredentials) - - // Field (2) 'Amount' - hh.PutUint64(d.Amount) - - // Field (3) 'Signature' - if size := len(d.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("DepositData.Signature", size, 96) - return - } - hh.PutBytes(d.Signature) - - hh.Merkleize(indx) - return -} - -// GetTree ssz hashes the DepositData object -func (d *DepositData) GetTree() (*ssz.Node, error) { - return ssz.ProofTree(d) -} - -// MarshalSSZ ssz marshals the SigningRoot object -func (s *SigningRoot) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) -} - -// MarshalSSZTo ssz marshals the SigningRoot object to a target array -func (s *SigningRoot) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - - // Field (0) 'ObjectRoot' - if size := len(s.ObjectRoot); size != 32 { - err = ssz.ErrBytesLengthFn("SigningRoot.ObjectRoot", size, 32) - return - } - dst = append(dst, s.ObjectRoot...) - - // Field (1) 'Domain' - if size := len(s.Domain); size != 32 { - err = ssz.ErrBytesLengthFn("SigningRoot.Domain", size, 32) - return - } - dst = append(dst, s.Domain...) - - return -} - -// UnmarshalSSZ ssz unmarshals the SigningRoot object -func (s *SigningRoot) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size != 64 { - return ssz.ErrSize - } - - // Field (0) 'ObjectRoot' - if cap(s.ObjectRoot) == 0 { - s.ObjectRoot = make([]byte, 0, len(buf[0:32])) - } - s.ObjectRoot = append(s.ObjectRoot, buf[0:32]...) - - // Field (1) 'Domain' - if cap(s.Domain) == 0 { - s.Domain = make([]byte, 0, len(buf[32:64])) - } - s.Domain = append(s.Domain, buf[32:64]...) - - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the SigningRoot object -func (s *SigningRoot) SizeSSZ() (size int) { - size = 64 - return -} - -// HashTreeRoot ssz hashes the SigningRoot object -func (s *SigningRoot) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) -} - -// HashTreeRootWith ssz hashes the SigningRoot object with a hasher -func (s *SigningRoot) HashTreeRootWith(hh ssz.HashWalker) (err error) { - indx := hh.Index() - - // Field (0) 'ObjectRoot' - if size := len(s.ObjectRoot); size != 32 { - err = ssz.ErrBytesLengthFn("SigningRoot.ObjectRoot", size, 32) - return - } - hh.PutBytes(s.ObjectRoot) - - // Field (1) 'Domain' - if size := len(s.Domain); size != 32 { - err = ssz.ErrBytesLengthFn("SigningRoot.Domain", size, 32) - return - } - hh.PutBytes(s.Domain) - - hh.Merkleize(indx) - return -} - -// GetTree ssz hashes the SigningRoot object -func (s *SigningRoot) GetTree() (*ssz.Node, error) { - return ssz.ProofTree(s) -} - -// MarshalSSZ ssz marshals the VoluntaryExit object -func (v *VoluntaryExit) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(v) -} - -// MarshalSSZTo ssz marshals the VoluntaryExit object to a target array -func (v *VoluntaryExit) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - - // Field (0) 'Epoch' - dst = ssz.MarshalUint64(dst, v.Epoch) - - // Field (1) 'ValidatorIndex' - dst = ssz.MarshalUint64(dst, v.ValidatorIndex) - - return -} - -// UnmarshalSSZ ssz unmarshals the VoluntaryExit object -func (v *VoluntaryExit) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size != 16 { - return ssz.ErrSize - } - - // Field (0) 'Epoch' - v.Epoch = ssz.UnmarshallUint64(buf[0:8]) - - // Field (1) 'ValidatorIndex' - v.ValidatorIndex = ssz.UnmarshallUint64(buf[8:16]) - - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the VoluntaryExit object -func (v *VoluntaryExit) SizeSSZ() (size int) { - size = 16 - return -} - -// HashTreeRoot ssz hashes the VoluntaryExit object -func (v *VoluntaryExit) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(v) -} - -// HashTreeRootWith ssz hashes the VoluntaryExit object with a hasher -func (v *VoluntaryExit) HashTreeRootWith(hh ssz.HashWalker) (err error) { - indx := hh.Index() - - // Field (0) 'Epoch' - hh.PutUint64(v.Epoch) - - // Field (1) 'ValidatorIndex' - hh.PutUint64(v.ValidatorIndex) - - hh.Merkleize(indx) - return -} - -// GetTree ssz hashes the VoluntaryExit object -func (v *VoluntaryExit) GetTree() (*ssz.Node, error) { - return ssz.ProofTree(v) -} - -// MarshalSSZ ssz marshals the WithdrawalCredentialsChange object -func (w *WithdrawalCredentialsChange) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(w) -} - -// MarshalSSZTo ssz marshals the WithdrawalCredentialsChange object to a target array -func (w *WithdrawalCredentialsChange) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - - // Field (0) 'ValidatorIndex' - dst = ssz.MarshalUint64(dst, w.ValidatorIndex) - - // Field (1) 'FromBLSPubkey' - dst = append(dst, w.FromBLSPubkey[:]...) - - // Field (2) 'ToExecutionAddress' - dst = append(dst, w.ToExecutionAddress[:]...) - - return -} - -// UnmarshalSSZ ssz unmarshals the WithdrawalCredentialsChange object -func (w *WithdrawalCredentialsChange) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size != 76 { - return ssz.ErrSize - } - - // Field (0) 'ValidatorIndex' - w.ValidatorIndex = ssz.UnmarshallUint64(buf[0:8]) - - // Field (1) 'FromBLSPubkey' - copy(w.FromBLSPubkey[:], buf[8:56]) - - // Field (2) 'ToExecutionAddress' - copy(w.ToExecutionAddress[:], buf[56:76]) - - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the WithdrawalCredentialsChange object -func (w *WithdrawalCredentialsChange) SizeSSZ() (size int) { - size = 76 - return -} - -// HashTreeRoot ssz hashes the WithdrawalCredentialsChange object -func (w *WithdrawalCredentialsChange) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(w) -} - -// HashTreeRootWith ssz hashes the WithdrawalCredentialsChange object with a hasher -func (w *WithdrawalCredentialsChange) HashTreeRootWith(hh ssz.HashWalker) (err error) { - indx := hh.Index() - - // Field (0) 'ValidatorIndex' - hh.PutUint64(w.ValidatorIndex) - - // Field (1) 'FromBLSPubkey' - hh.PutBytes(w.FromBLSPubkey[:]) - - // Field (2) 'ToExecutionAddress' - hh.PutBytes(w.ToExecutionAddress[:]) - - hh.Merkleize(indx) - return -} - -// GetTree ssz hashes the WithdrawalCredentialsChange object -func (w *WithdrawalCredentialsChange) GetTree() (*ssz.Node, error) { - return ssz.ProofTree(w) -} - -// MarshalSSZ ssz marshals the Fork object -func (f *Fork) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(f) -} - -// MarshalSSZTo ssz marshals the Fork object to a target array -func (f *Fork) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - - // Field (0) 'PreviousVersion' - if size := len(f.PreviousVersion); size != 4 { - err = ssz.ErrBytesLengthFn("Fork.PreviousVersion", size, 4) - return - } - dst = append(dst, f.PreviousVersion...) - - // Field (1) 'CurrentVersion' - if size := len(f.CurrentVersion); size != 4 { - err = ssz.ErrBytesLengthFn("Fork.CurrentVersion", size, 4) - return - } - dst = append(dst, f.CurrentVersion...) - - // Field (2) 'Epoch' - dst = ssz.MarshalUint64(dst, f.Epoch) - - return -} - -// UnmarshalSSZ ssz unmarshals the Fork object -func (f *Fork) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size != 16 { - return ssz.ErrSize - } - - // Field (0) 'PreviousVersion' - if cap(f.PreviousVersion) == 0 { - f.PreviousVersion = make([]byte, 0, len(buf[0:4])) - } - f.PreviousVersion = append(f.PreviousVersion, buf[0:4]...) - - // Field (1) 'CurrentVersion' - if cap(f.CurrentVersion) == 0 { - f.CurrentVersion = make([]byte, 0, len(buf[4:8])) - } - f.CurrentVersion = append(f.CurrentVersion, buf[4:8]...) - - // Field (2) 'Epoch' - f.Epoch = ssz.UnmarshallUint64(buf[8:16]) - - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the Fork object -func (f *Fork) SizeSSZ() (size int) { - size = 16 - return -} - -// HashTreeRoot ssz hashes the Fork object -func (f *Fork) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(f) -} - -// HashTreeRootWith ssz hashes the Fork object with a hasher -func (f *Fork) HashTreeRootWith(hh ssz.HashWalker) (err error) { - indx := hh.Index() - - // Field (0) 'PreviousVersion' - if size := len(f.PreviousVersion); size != 4 { - err = ssz.ErrBytesLengthFn("Fork.PreviousVersion", size, 4) - return - } - hh.PutBytes(f.PreviousVersion) - - // Field (1) 'CurrentVersion' - if size := len(f.CurrentVersion); size != 4 { - err = ssz.ErrBytesLengthFn("Fork.CurrentVersion", size, 4) - return - } - hh.PutBytes(f.CurrentVersion) - - // Field (2) 'Epoch' - hh.PutUint64(f.Epoch) - - hh.Merkleize(indx) - return -} - -// GetTree ssz hashes the Fork object -func (f *Fork) GetTree() (*ssz.Node, error) { - return ssz.ProofTree(f) -} - -// MarshalSSZ ssz marshals the BeaconBlockHeader object -func (b *BeaconBlockHeader) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} - -// MarshalSSZTo ssz marshals the BeaconBlockHeader object to a target array -func (b *BeaconBlockHeader) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - - // Field (0) 'Slot' - dst = ssz.MarshalUint64(dst, b.Slot) - - // Field (1) 'ProposerIndex' - dst = ssz.MarshalUint64(dst, b.ProposerIndex) - - // Field (2) 'ParentRoot' - if size := len(b.ParentRoot); size != 32 { - err = ssz.ErrBytesLengthFn("BeaconBlockHeader.ParentRoot", size, 32) - return - } - dst = append(dst, b.ParentRoot...) - - // Field (3) 'StateRoot' - if size := len(b.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("BeaconBlockHeader.StateRoot", size, 32) - return - } - dst = append(dst, b.StateRoot...) - - // Field (4) 'BodyRoot' - if size := len(b.BodyRoot); size != 32 { - err = ssz.ErrBytesLengthFn("BeaconBlockHeader.BodyRoot", size, 32) - return - } - dst = append(dst, b.BodyRoot...) - - return -} - -// UnmarshalSSZ ssz unmarshals the BeaconBlockHeader object -func (b *BeaconBlockHeader) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size != 112 { - return ssz.ErrSize - } - - // Field (0) 'Slot' - b.Slot = ssz.UnmarshallUint64(buf[0:8]) - - // Field (1) 'ProposerIndex' - b.ProposerIndex = ssz.UnmarshallUint64(buf[8:16]) - - // Field (2) 'ParentRoot' - if cap(b.ParentRoot) == 0 { - b.ParentRoot = make([]byte, 0, len(buf[16:48])) - } - b.ParentRoot = append(b.ParentRoot, buf[16:48]...) - - // Field (3) 'StateRoot' - if cap(b.StateRoot) == 0 { - b.StateRoot = make([]byte, 0, len(buf[48:80])) - } - b.StateRoot = append(b.StateRoot, buf[48:80]...) - - // Field (4) 'BodyRoot' - if cap(b.BodyRoot) == 0 { - b.BodyRoot = make([]byte, 0, len(buf[80:112])) - } - b.BodyRoot = append(b.BodyRoot, buf[80:112]...) - - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the BeaconBlockHeader object -func (b *BeaconBlockHeader) SizeSSZ() (size int) { - size = 112 - return -} - -// HashTreeRoot ssz hashes the BeaconBlockHeader object -func (b *BeaconBlockHeader) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) -} - -// HashTreeRootWith ssz hashes the BeaconBlockHeader object with a hasher -func (b *BeaconBlockHeader) HashTreeRootWith(hh ssz.HashWalker) (err error) { - indx := hh.Index() - - // Field (0) 'Slot' - hh.PutUint64(b.Slot) - - // Field (1) 'ProposerIndex' - hh.PutUint64(b.ProposerIndex) - - // Field (2) 'ParentRoot' - if size := len(b.ParentRoot); size != 32 { - err = ssz.ErrBytesLengthFn("BeaconBlockHeader.ParentRoot", size, 32) - return - } - hh.PutBytes(b.ParentRoot) - - // Field (3) 'StateRoot' - if size := len(b.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("BeaconBlockHeader.StateRoot", size, 32) - return - } - hh.PutBytes(b.StateRoot) - - // Field (4) 'BodyRoot' - if size := len(b.BodyRoot); size != 32 { - err = ssz.ErrBytesLengthFn("BeaconBlockHeader.BodyRoot", size, 32) - return - } - hh.PutBytes(b.BodyRoot) - - hh.Merkleize(indx) - return -} - -// GetTree ssz hashes the BeaconBlockHeader object -func (b *BeaconBlockHeader) GetTree() (*ssz.Node, error) { - return ssz.ProofTree(b) -} - -// MarshalSSZ ssz marshals the Eth1Data object -func (e *Eth1Data) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(e) -} - -// MarshalSSZTo ssz marshals the Eth1Data object to a target array -func (e *Eth1Data) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - - // Field (0) 'DepositRoot' - if size := len(e.DepositRoot); size != 32 { - err = ssz.ErrBytesLengthFn("Eth1Data.DepositRoot", size, 32) - return - } - dst = append(dst, e.DepositRoot...) - - // Field (1) 'DepositCount' - dst = ssz.MarshalUint64(dst, e.DepositCount) - - // Field (2) 'BlockHash' - if size := len(e.BlockHash); size != 32 { - err = ssz.ErrBytesLengthFn("Eth1Data.BlockHash", size, 32) - return - } - dst = append(dst, e.BlockHash...) - - return -} - -// UnmarshalSSZ ssz unmarshals the Eth1Data object -func (e *Eth1Data) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size != 72 { - return ssz.ErrSize - } - - // Field (0) 'DepositRoot' - if cap(e.DepositRoot) == 0 { - e.DepositRoot = make([]byte, 0, len(buf[0:32])) - } - e.DepositRoot = append(e.DepositRoot, buf[0:32]...) - - // Field (1) 'DepositCount' - e.DepositCount = ssz.UnmarshallUint64(buf[32:40]) - - // Field (2) 'BlockHash' - if cap(e.BlockHash) == 0 { - e.BlockHash = make([]byte, 0, len(buf[40:72])) - } - e.BlockHash = append(e.BlockHash, buf[40:72]...) - - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the Eth1Data object -func (e *Eth1Data) SizeSSZ() (size int) { - size = 72 - return -} - -// HashTreeRoot ssz hashes the Eth1Data object -func (e *Eth1Data) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(e) -} - -// HashTreeRootWith ssz hashes the Eth1Data object with a hasher -func (e *Eth1Data) HashTreeRootWith(hh ssz.HashWalker) (err error) { - indx := hh.Index() - - // Field (0) 'DepositRoot' - if size := len(e.DepositRoot); size != 32 { - err = ssz.ErrBytesLengthFn("Eth1Data.DepositRoot", size, 32) - return - } - hh.PutBytes(e.DepositRoot) - - // Field (1) 'DepositCount' - hh.PutUint64(e.DepositCount) - - // Field (2) 'BlockHash' - if size := len(e.BlockHash); size != 32 { - err = ssz.ErrBytesLengthFn("Eth1Data.BlockHash", size, 32) - return - } - hh.PutBytes(e.BlockHash) - - hh.Merkleize(indx) - return -} - -// GetTree ssz hashes the Eth1Data object -func (e *Eth1Data) GetTree() (*ssz.Node, error) { - return ssz.ProofTree(e) -} - -// MarshalSSZ ssz marshals the Validator object -func (v *Validator) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(v) -} - -// MarshalSSZTo ssz marshals the Validator object to a target array -func (v *Validator) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - - // Field (0) 'Pubkey' - if size := len(v.Pubkey); size != 48 { - err = ssz.ErrBytesLengthFn("Validator.Pubkey", size, 48) - return - } - dst = append(dst, v.Pubkey...) - - // Field (1) 'WithdrawalCredentials' - if size := len(v.WithdrawalCredentials); size != 32 { - err = ssz.ErrBytesLengthFn("Validator.WithdrawalCredentials", size, 32) - return - } - dst = append(dst, v.WithdrawalCredentials...) - - // Field (2) 'EffectiveBalance' - dst = ssz.MarshalUint64(dst, v.EffectiveBalance) - - // Field (3) 'Slashed' - dst = ssz.MarshalBool(dst, v.Slashed) - - // Field (4) 'ActivationEligibilityEpoch' - dst = ssz.MarshalUint64(dst, v.ActivationEligibilityEpoch) - - // Field (5) 'ActivationEpoch' - dst = ssz.MarshalUint64(dst, v.ActivationEpoch) - - // Field (6) 'ExitEpoch' - dst = ssz.MarshalUint64(dst, v.ExitEpoch) - - // Field (7) 'WithdrawableEpoch' - dst = ssz.MarshalUint64(dst, v.WithdrawableEpoch) - - return -} - -// UnmarshalSSZ ssz unmarshals the Validator object -func (v *Validator) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size != 121 { - return ssz.ErrSize - } - - // Field (0) 'Pubkey' - if cap(v.Pubkey) == 0 { - v.Pubkey = make([]byte, 0, len(buf[0:48])) - } - v.Pubkey = append(v.Pubkey, buf[0:48]...) - - // Field (1) 'WithdrawalCredentials' - if cap(v.WithdrawalCredentials) == 0 { - v.WithdrawalCredentials = make([]byte, 0, len(buf[48:80])) - } - v.WithdrawalCredentials = append(v.WithdrawalCredentials, buf[48:80]...) - - // Field (2) 'EffectiveBalance' - v.EffectiveBalance = ssz.UnmarshallUint64(buf[80:88]) - - // Field (3) 'Slashed' - v.Slashed = ssz.UnmarshalBool(buf[88:89]) - - // Field (4) 'ActivationEligibilityEpoch' - v.ActivationEligibilityEpoch = ssz.UnmarshallUint64(buf[89:97]) - - // Field (5) 'ActivationEpoch' - v.ActivationEpoch = ssz.UnmarshallUint64(buf[97:105]) - - // Field (6) 'ExitEpoch' - v.ExitEpoch = ssz.UnmarshallUint64(buf[105:113]) - - // Field (7) 'WithdrawableEpoch' - v.WithdrawableEpoch = ssz.UnmarshallUint64(buf[113:121]) - - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the Validator object -func (v *Validator) SizeSSZ() (size int) { - size = 121 - return -} - -// HashTreeRoot ssz hashes the Validator object -func (v *Validator) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(v) -} - -// HashTreeRootWith ssz hashes the Validator object with a hasher -func (v *Validator) HashTreeRootWith(hh ssz.HashWalker) (err error) { - indx := hh.Index() - - // Field (0) 'Pubkey' - if size := len(v.Pubkey); size != 48 { - err = ssz.ErrBytesLengthFn("Validator.Pubkey", size, 48) - return - } - hh.PutBytes(v.Pubkey) - - // Field (1) 'WithdrawalCredentials' - if size := len(v.WithdrawalCredentials); size != 32 { - err = ssz.ErrBytesLengthFn("Validator.WithdrawalCredentials", size, 32) - return - } - hh.PutBytes(v.WithdrawalCredentials) - - // Field (2) 'EffectiveBalance' - hh.PutUint64(v.EffectiveBalance) - - // Field (3) 'Slashed' - hh.PutBool(v.Slashed) - - // Field (4) 'ActivationEligibilityEpoch' - hh.PutUint64(v.ActivationEligibilityEpoch) - - // Field (5) 'ActivationEpoch' - hh.PutUint64(v.ActivationEpoch) - - // Field (6) 'ExitEpoch' - hh.PutUint64(v.ExitEpoch) - - // Field (7) 'WithdrawableEpoch' - hh.PutUint64(v.WithdrawableEpoch) - - hh.Merkleize(indx) - return -} - -// GetTree ssz hashes the Validator object -func (v *Validator) GetTree() (*ssz.Node, error) { - return ssz.ProofTree(v) -} - -// MarshalSSZ ssz marshals the Checkpoint object -func (c *Checkpoint) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(c) -} - -// MarshalSSZTo ssz marshals the Checkpoint object to a target array -func (c *Checkpoint) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - - // Field (0) 'Epoch' - dst = ssz.MarshalUint64(dst, c.Epoch) - - // Field (1) 'Root' - if size := len(c.Root); size != 32 { - err = ssz.ErrBytesLengthFn("Checkpoint.Root", size, 32) - return - } - dst = append(dst, c.Root...) - - return -} - -// UnmarshalSSZ ssz unmarshals the Checkpoint object -func (c *Checkpoint) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size != 40 { - return ssz.ErrSize - } - - // Field (0) 'Epoch' - c.Epoch = ssz.UnmarshallUint64(buf[0:8]) - - // Field (1) 'Root' - if cap(c.Root) == 0 { - c.Root = make([]byte, 0, len(buf[8:40])) - } - c.Root = append(c.Root, buf[8:40]...) - - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the Checkpoint object -func (c *Checkpoint) SizeSSZ() (size int) { - size = 40 - return -} - -// HashTreeRoot ssz hashes the Checkpoint object -func (c *Checkpoint) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(c) -} - -// HashTreeRootWith ssz hashes the Checkpoint object with a hasher -func (c *Checkpoint) HashTreeRootWith(hh ssz.HashWalker) (err error) { - indx := hh.Index() - - // Field (0) 'Epoch' - hh.PutUint64(c.Epoch) - - // Field (1) 'Root' - if size := len(c.Root); size != 32 { - err = ssz.ErrBytesLengthFn("Checkpoint.Root", size, 32) - return - } - hh.PutBytes(c.Root) - - hh.Merkleize(indx) - return -} - -// GetTree ssz hashes the Checkpoint object -func (c *Checkpoint) GetTree() (*ssz.Node, error) { - return ssz.ProofTree(c) -} - -// MarshalSSZ ssz marshals the SyncCommittee object -func (s *SyncCommittee) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) -} - -// MarshalSSZTo ssz marshals the SyncCommittee object to a target array -func (s *SyncCommittee) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - - // Field (0) 'PubKeys' - if size := len(s.PubKeys); size != 512 { - err = ssz.ErrVectorLengthFn("SyncCommittee.PubKeys", size, 512) - return - } - for ii := 0; ii < 512; ii++ { - if size := len(s.PubKeys[ii]); size != 48 { - err = ssz.ErrBytesLengthFn("SyncCommittee.PubKeys[ii]", size, 48) - return - } - dst = append(dst, s.PubKeys[ii]...) - } - - // Field (1) 'AggregatePubKey' - dst = append(dst, s.AggregatePubKey[:]...) - - return -} - -// UnmarshalSSZ ssz unmarshals the SyncCommittee object -func (s *SyncCommittee) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size != 24624 { - return ssz.ErrSize - } - - // Field (0) 'PubKeys' - s.PubKeys = make([][]byte, 512) - for ii := 0; ii < 512; ii++ { - if cap(s.PubKeys[ii]) == 0 { - s.PubKeys[ii] = make([]byte, 0, len(buf[0:24576][ii*48:(ii+1)*48])) - } - s.PubKeys[ii] = append(s.PubKeys[ii], buf[0:24576][ii*48:(ii+1)*48]...) - } - - // Field (1) 'AggregatePubKey' - copy(s.AggregatePubKey[:], buf[24576:24624]) - - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the SyncCommittee object -func (s *SyncCommittee) SizeSSZ() (size int) { - size = 24624 - return -} - -// HashTreeRoot ssz hashes the SyncCommittee object -func (s *SyncCommittee) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) -} - -// HashTreeRootWith ssz hashes the SyncCommittee object with a hasher -func (s *SyncCommittee) HashTreeRootWith(hh ssz.HashWalker) (err error) { - indx := hh.Index() - - // Field (0) 'PubKeys' - { - if size := len(s.PubKeys); size != 512 { - err = ssz.ErrVectorLengthFn("SyncCommittee.PubKeys", size, 512) - return - } - subIndx := hh.Index() - for _, i := range s.PubKeys { - if len(i) != 48 { - err = ssz.ErrBytesLength - return - } - hh.PutBytes(i) - } - hh.Merkleize(subIndx) - } - - // Field (1) 'AggregatePubKey' - hh.PutBytes(s.AggregatePubKey[:]) - - hh.Merkleize(indx) - return -} - -// GetTree ssz hashes the SyncCommittee object -func (s *SyncCommittee) GetTree() (*ssz.Node, error) { - return ssz.ProofTree(s) -} - -// MarshalSSZ ssz marshals the HistoricalSummary object -func (h *HistoricalSummary) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(h) -} - -// MarshalSSZTo ssz marshals the HistoricalSummary object to a target array -func (h *HistoricalSummary) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - - // Field (0) 'BlockSummaryRoot' - dst = append(dst, h.BlockSummaryRoot[:]...) - - // Field (1) 'StateSummaryRoot' - dst = append(dst, h.StateSummaryRoot[:]...) - - return -} - -// UnmarshalSSZ ssz unmarshals the HistoricalSummary object -func (h *HistoricalSummary) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size != 64 { - return ssz.ErrSize - } - - // Field (0) 'BlockSummaryRoot' - copy(h.BlockSummaryRoot[:], buf[0:32]) - - // Field (1) 'StateSummaryRoot' - copy(h.StateSummaryRoot[:], buf[32:64]) - - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the HistoricalSummary object -func (h *HistoricalSummary) SizeSSZ() (size int) { - size = 64 - return -} - -// HashTreeRoot ssz hashes the HistoricalSummary object -func (h *HistoricalSummary) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(h) -} - -// HashTreeRootWith ssz hashes the HistoricalSummary object with a hasher -func (h *HistoricalSummary) HashTreeRootWith(hh ssz.HashWalker) (err error) { - indx := hh.Index() - - // Field (0) 'BlockSummaryRoot' - hh.PutBytes(h.BlockSummaryRoot[:]) - - // Field (1) 'StateSummaryRoot' - hh.PutBytes(h.StateSummaryRoot[:]) - - hh.Merkleize(indx) - return -} - -// GetTree ssz hashes the HistoricalSummary object -func (h *HistoricalSummary) GetTree() (*ssz.Node, error) { - return ssz.ProofTree(h) -} - -// MarshalSSZ ssz marshals the HistoricalSummaryLists object -func (h *HistoricalSummaryLists) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(h) -} - -// MarshalSSZTo ssz marshals the HistoricalSummaryLists object to a target array -func (h *HistoricalSummaryLists) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - - // Field (0) 'BlockRoots' - for ii := 0; ii < 8192; ii++ { - dst = append(dst, h.BlockRoots[ii][:]...) - } - - // Field (1) 'StateRoots' - for ii := 0; ii < 8192; ii++ { - dst = append(dst, h.StateRoots[ii][:]...) - } - - return -} - -// UnmarshalSSZ ssz unmarshals the HistoricalSummaryLists object -func (h *HistoricalSummaryLists) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size != 524288 { - return ssz.ErrSize - } - - // Field (0) 'BlockRoots' - - for ii := 0; ii < 8192; ii++ { - copy(h.BlockRoots[ii][:], buf[0:262144][ii*32:(ii+1)*32]) - } - - // Field (1) 'StateRoots' - - for ii := 0; ii < 8192; ii++ { - copy(h.StateRoots[ii][:], buf[262144:524288][ii*32:(ii+1)*32]) - } - - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the HistoricalSummaryLists object -func (h *HistoricalSummaryLists) SizeSSZ() (size int) { - size = 524288 - return -} - -// HashTreeRoot ssz hashes the HistoricalSummaryLists object -func (h *HistoricalSummaryLists) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(h) -} - -// HashTreeRootWith ssz hashes the HistoricalSummaryLists object with a hasher -func (h *HistoricalSummaryLists) HashTreeRootWith(hh ssz.HashWalker) (err error) { - indx := hh.Index() - - // Field (0) 'BlockRoots' - { - subIndx := hh.Index() - for _, i := range h.BlockRoots { - hh.Append(i[:]) - } - hh.Merkleize(subIndx) - } - - // Field (1) 'StateRoots' - { - subIndx := hh.Index() - for _, i := range h.StateRoots { - hh.Append(i[:]) - } - hh.Merkleize(subIndx) - } - - hh.Merkleize(indx) - return -} - -// GetTree ssz hashes the HistoricalSummaryLists object -func (h *HistoricalSummaryLists) GetTree() (*ssz.Node, error) { - return ssz.ProofTree(h) -} diff --git a/shared/types/eth2/proofs_test.go b/shared/types/eth2/proofs_test.go index 29f5d2f32..085cfe342 100644 --- a/shared/types/eth2/proofs_test.go +++ b/shared/types/eth2/proofs_test.go @@ -134,14 +134,14 @@ func validateStateProof(t *testing.T, leaf []byte, proof [][]byte, gid uint64, s state.LatestBlockHeader = &lbh }() // Set the state root in LatestBlockHeader before calculating the hash - stateRoot, err := state.HashTreeRoot() + stateRoot, err := generic.SSZ.HashTreeRoot(state) if err != nil { t.Fatalf("Failed to get state root: %v", err) } state.LatestBlockHeader.StateRoot = stateRoot[:] // The final hash must be the block root - finalHash, err := state.LatestBlockHeader.HashTreeRoot() + finalHash, err := generic.SSZ.HashTreeRoot(state.LatestBlockHeader) if err != nil { t.Fatalf("Failed to get block root: %v", err) } @@ -155,7 +155,7 @@ func validateStateProof(t *testing.T, leaf []byte, proof [][]byte, gid uint64, s } func getValidatorLeaf(t *testing.T, validator *generic.Validator) []byte { - root, err := validator.HashTreeRoot() + root, err := generic.SSZ.HashTreeRoot(validator) if err != nil { t.Fatalf("Failed to get validator root: %v", err) } @@ -165,7 +165,7 @@ func getValidatorLeaf(t *testing.T, validator *generic.Validator) []byte { func TestValidatorStateProof(t *testing.T) { state := &deneb.BeaconState{} - err := state.UnmarshalSSZ(testState) + err := generic.SSZ.UnmarshalSSZ(state, testState) if err != nil { t.Fatalf("Failed to unmarshal test state: %v", err) } @@ -219,7 +219,7 @@ func validateBlockProof(t *testing.T, leaf [32]byte, proof [][]byte, gid uint64, panic(err) } - expectedBlockRoot, err := block.Block.HashTreeRoot() + expectedBlockRoot, err := generic.SSZ.HashTreeRoot(block.Block) if err != nil { t.Fatalf("Failed to get block root: %v", err) } @@ -256,7 +256,7 @@ func validateBlockProof(t *testing.T, leaf [32]byte, proof [][]byte, gid uint64, func TestWithdrawalProof(t *testing.T) { block := &deneb.SignedBeaconBlock{} - err := block.UnmarshalSSZ(testBlock) + err := generic.SSZ.UnmarshalSSZ(block, testBlock) if err != nil { t.Fatalf("Failed to unmarshal test block: %v", err) } @@ -278,7 +278,7 @@ func TestWithdrawalProof(t *testing.T) { gid = gid*generic.BeaconBlockBodyExecutionPayloadChunksCeil + generic.BeaconBlockBodyExecutionPayloadWithdrawalsIndex gid = gid * 2 gid = gid*generic.BeaconBlockWithdrawalsArrayMax + uint64(idx) - leaf, err := withdrawal.HashTreeRoot() + leaf, err := generic.SSZ.HashTreeRoot(withdrawal) if err != nil { t.Fatalf("Failed to get withdrawal leaf: %v", err) } @@ -320,7 +320,7 @@ func TestBlockRootProof(t *testing.T) { copy(hsls.StateRoots[i][:], stateRootBytes) } - hslsTree, err := hsls.GetTree() + hslsTree, err := generic.SSZ.GetTree(&hsls) if err != nil { t.Fatalf("Failed to get historical summary lists tree: %v", err) } diff --git a/shared/types/eth2/streaming_test.go b/shared/types/eth2/streaming_test.go new file mode 100644 index 000000000..d71ff06d9 --- /dev/null +++ b/shared/types/eth2/streaming_test.go @@ -0,0 +1,99 @@ +package eth2 + +import ( + "bytes" + "io" + "testing" + + "github.com/rocket-pool/smartnode/shared/types/eth2/fork/deneb" + "github.com/rocket-pool/smartnode/shared/types/eth2/generic" +) + +// Verify that the streaming decode path produces a state identical to the +// buffered decode path +func TestBeaconStateStreamingDecode(t *testing.T) { + buffered := &deneb.BeaconState{} + if err := generic.SSZ.UnmarshalSSZ(buffered, testState); err != nil { + t.Fatalf("Failed to unmarshal test state: %v", err) + } + bufferedRoot, err := generic.SSZ.HashTreeRoot(buffered) + if err != nil { + t.Fatalf("Failed to get buffered state root: %v", err) + } + + streamed := &deneb.BeaconState{} + if err := generic.SSZ.UnmarshalSSZReader(streamed, bytes.NewReader(testState), len(testState)); err != nil { + t.Fatalf("Failed to stream-unmarshal test state: %v", err) + } + streamedRoot, err := generic.SSZ.HashTreeRoot(streamed) + if err != nil { + t.Fatalf("Failed to get streamed state root: %v", err) + } + + if bufferedRoot != streamedRoot { + t.Fatalf("streamed state root %x does not match buffered state root %x", streamedRoot, bufferedRoot) + } +} + +// Verify that decodeSSZ streams when the size is known and falls back to +// buffering when it isn't, producing identical results +func TestDecodeSSZSizeFallback(t *testing.T) { + streamed := &deneb.SignedBeaconBlock{} + if err := decodeSSZ(streamed, io.NopCloser(bytes.NewReader(testBlock)), int64(len(testBlock))); err != nil { + t.Fatalf("Failed to decode block with known size: %v", err) + } + + // A size of -1 mimics a response without Content-Length + buffered := &deneb.SignedBeaconBlock{} + if err := decodeSSZ(buffered, io.NopCloser(bytes.NewReader(testBlock)), -1); err != nil { + t.Fatalf("Failed to decode block with unknown size: %v", err) + } + + streamedRoot, err := generic.SSZ.HashTreeRoot(streamed.Block) + if err != nil { + t.Fatalf("Failed to get streamed block root: %v", err) + } + bufferedRoot, err := generic.SSZ.HashTreeRoot(buffered.Block) + if err != nil { + t.Fatalf("Failed to get buffered block root: %v", err) + } + if streamedRoot != bufferedRoot { + t.Fatalf("streamed block root %x does not match buffered block root %x", streamedRoot, bufferedRoot) + } +} + +func BenchmarkBeaconStateDecodeStreaming(b *testing.B) { + b.ReportAllocs() + for i := 0; i < b.N; i++ { + state := &deneb.BeaconState{} + if err := generic.SSZ.UnmarshalSSZReader(state, bytes.NewReader(testState), len(testState)); err != nil { + b.Fatalf("Failed to stream-unmarshal test state: %v", err) + } + } +} + +func BenchmarkBeaconStateDecodeBuffered(b *testing.B) { + b.ReportAllocs() + for i := 0; i < b.N; i++ { + state := &deneb.BeaconState{} + if err := generic.SSZ.UnmarshalSSZ(state, testState); err != nil { + b.Fatalf("Failed to unmarshal test state: %v", err) + } + } +} + +// Guards against merkle-tree/proof generation CPU regressions (issue #1103 +// asks for proof generation to be benchmarked) +func BenchmarkValidatorProof(b *testing.B) { + state := &deneb.BeaconState{} + if err := generic.SSZ.UnmarshalSSZ(state, testState); err != nil { + b.Fatalf("Failed to unmarshal test state: %v", err) + } + b.ResetTimer() + b.ReportAllocs() + for i := 0; i < b.N; i++ { + if _, err := state.ValidatorProof(555555); err != nil { + b.Fatalf("Failed to get validator proof: %v", err) + } + } +} diff --git a/shared/types/eth2/types.go b/shared/types/eth2/types.go index 259d73f5a..a873e1c3b 100644 --- a/shared/types/eth2/types.go +++ b/shared/types/eth2/types.go @@ -36,73 +36,79 @@ type SignedBeaconBlock interface { Withdrawals() []*generic.Withdrawal } -func NewBeaconState(data io.ReadCloser, fork string) (BeaconState, error) { - fork = strings.ToLower(fork) - +// decodeSSZ deserializes an SSZ payload into target. When the total payload +// size is known it streams directly from the reader, avoiding holding the +// whole serialized payload (~310 MB for a mainnet beacon state) in memory +// alongside the decoded struct. When the size is unknown (e.g. a chunked +// response without Content-Length) it falls back to buffering, since SSZ +// offsets cannot be interpreted without the total size. +func decodeSSZ(target any, data io.ReadCloser, size int64) error { defer func() { _ = data.Close() }() + if size > 0 { + return generic.SSZ.UnmarshalSSZReader(target, data, int(size)) + } + dataBytes, err := io.ReadAll(data) if err != nil { - return nil, err + return err } + return generic.SSZ.UnmarshalSSZ(target, dataBytes) +} + +func NewBeaconState(data io.ReadCloser, size int64, fork string) (BeaconState, error) { + fork = strings.ToLower(fork) switch fork { case "electra": out := &electra.BeaconState{} - err := out.UnmarshalSSZ(dataBytes) + err := decodeSSZ(out, data, size) if err != nil { return nil, err } return out, nil case "fulu": out := &fulu.BeaconState{} - err := out.UnmarshalSSZ(dataBytes) + err := decodeSSZ(out, data, size) if err != nil { return nil, err } return out, nil default: + _ = data.Close() return nil, fmt.Errorf("unsupported fork: %s", fork) } } -func NewSignedBeaconBlock(data io.ReadCloser, fork string) (SignedBeaconBlock, error) { +func NewSignedBeaconBlock(data io.ReadCloser, size int64, fork string) (SignedBeaconBlock, error) { fork = strings.ToLower(fork) - defer func() { - _ = data.Close() - }() - - dataBytes, err := io.ReadAll(data) - if err != nil { - return nil, err - } - switch fork { case "deneb": out := &deneb.SignedBeaconBlock{} - err := out.UnmarshalSSZ(dataBytes) + err := decodeSSZ(out, data, size) if err != nil { return nil, err } return out, nil case "electra": out := &electra.SignedBeaconBlock{} - err := out.UnmarshalSSZ(dataBytes) + err := decodeSSZ(out, data, size) if err != nil { return nil, err } return out, nil case "fulu": out := &fulu.SignedBeaconBlock{} - err := out.UnmarshalSSZ(dataBytes) + err := decodeSSZ(out, data, size) if err != nil { return nil, err } return out, nil default: + _ = data.Close() return nil, fmt.Errorf("unsupported fork: %s", fork) } } diff --git a/shared/utils/validator/deposit-data.go b/shared/utils/validator/deposit-data.go index bce66e378..5d8c1abbe 100644 --- a/shared/utils/validator/deposit-data.go +++ b/shared/utils/validator/deposit-data.go @@ -20,7 +20,7 @@ func GetDepositData(validatorKey *eth2types.BLSPrivateKey, withdrawalCredentials } // Get signing root - or, err := dd.HashTreeRoot() + or, err := generic.SSZ.HashTreeRoot(&dd) if err != nil { return generic.DepositData{}, common.Hash{}, err } @@ -31,7 +31,7 @@ func GetDepositData(validatorKey *eth2types.BLSPrivateKey, withdrawalCredentials } // Get signing root with domain - srHash, err := sr.HashTreeRoot() + srHash, err := generic.SSZ.HashTreeRoot(&sr) if err != nil { return generic.DepositData{}, common.Hash{}, err } @@ -45,7 +45,7 @@ func GetDepositData(validatorKey *eth2types.BLSPrivateKey, withdrawalCredentials } // Get deposit data root - depositDataRoot, err := depositData.HashTreeRoot() + depositDataRoot, err := generic.SSZ.HashTreeRoot(&depositData) if err != nil { return generic.DepositData{}, common.Hash{}, err } diff --git a/shared/utils/validator/set-withdrawal-creds.go b/shared/utils/validator/set-withdrawal-creds.go index bb691648c..6156ce19a 100644 --- a/shared/utils/validator/set-withdrawal-creds.go +++ b/shared/utils/validator/set-withdrawal-creds.go @@ -47,7 +47,7 @@ func GetSignedWithdrawalCredsChangeMessage(withdrawalKey *eth2types.BLSPrivateKe } // Get object root - or, err := message.HashTreeRoot() + or, err := generic.SSZ.HashTreeRoot(&message) if err != nil { return types.ValidatorSignature{}, err } @@ -58,7 +58,7 @@ func GetSignedWithdrawalCredsChangeMessage(withdrawalKey *eth2types.BLSPrivateKe Domain: signatureDomain, } - srHash, err := sr.HashTreeRoot() + srHash, err := generic.SSZ.HashTreeRoot(&sr) if err != nil { return types.ValidatorSignature{}, err } diff --git a/shared/utils/validator/voluntary-exit.go b/shared/utils/validator/voluntary-exit.go index cbe347156..96ccf31db 100644 --- a/shared/utils/validator/voluntary-exit.go +++ b/shared/utils/validator/voluntary-exit.go @@ -26,7 +26,7 @@ func GetSignedExitMessage(validatorKey *eth2types.BLSPrivateKey, validatorIndex } // Get object root - or, err := exitMessage.HashTreeRoot() + or, err := generic.SSZ.HashTreeRoot(&exitMessage) if err != nil { return types.ValidatorSignature{}, err } @@ -37,7 +37,7 @@ func GetSignedExitMessage(validatorKey *eth2types.BLSPrivateKey, validatorIndex Domain: signatureDomain, } - srHash, err := sr.HashTreeRoot() + srHash, err := generic.SSZ.HashTreeRoot(&sr) if err != nil { return types.ValidatorSignature{}, err } diff --git a/sszgen.sh b/sszgen.sh index 333e7f97e..6e5d32eb1 100755 --- a/sszgen.sh +++ b/sszgen.sh @@ -1,9 +1,29 @@ #!/bin/sh -# Generates the ssz encoding methods for eth2 types with fastssz -# Install sszgen with `go get github.com/ferranbt/fastssz/sszgen` -SSZGEN_CMD="go run github.com/ferranbt/fastssz/sszgen@v0.1.4" -find ./shared/types/eth2 -name "*_encoding.go" -exec sh -c 'head -1 {} | grep -q "Code generated by fastssz"' \; -exec rm {} \; -$SSZGEN_CMD --path ./shared/types/eth2/fork/deneb --include ./shared/types/eth2/generic -$SSZGEN_CMD --path ./shared/types/eth2/fork/electra --include ./shared/types/eth2/generic -$SSZGEN_CMD --path ./shared/types/eth2/generic --exclude-objs Uint256 +# Generates optimized SSZ methods for the eth2 beacon types with dynssz-gen. +# The generated methods are picked up automatically by the shared +# generic.SSZ (dynamic-ssz) instance; reflection is used for any type +# without generated code. +# NOTE: shared/services/rewards/ssz_types still uses fastssz (see its gen.sh). +set -e + +# dynssz-gen is a tool dependency pinned in go.mod (see the tool directive) +DYNSSZ_GEN="go tool dynssz-gen" + +find ./shared/types/eth2 -name "*_generated.go" -delete + +$DYNSSZ_GEN -package ./shared/types/eth2/generic -with-streaming \ + -types "Fork,BeaconBlockHeader,Eth1Data,Validator,Checkpoint,SyncCommittee,HistoricalSummary,HistoricalSummaryLists,ExecutionPayloadHeader,PendingDeposit,PendingPartialWithdrawal,PendingConsolidation,ProposerSlashing,SignedBeaconBlockHeader,AttesterSlashing,IndexedAttestation,AttestationData,Attestation,Deposit,SignedVoluntaryExit,SyncAggregate,ExecutionPayload,Withdrawal,BLSToExecutionChange,SignedBLSToExecutionChange,DepositDataNoSignature,DepositData,SigningRoot,VoluntaryExit,WithdrawalCredentialsChange,Uint256" \ + -output ./shared/types/eth2/generic/generic_generated.go + +$DYNSSZ_GEN -package ./shared/types/eth2/fork/deneb -with-streaming \ + -types "BeaconState,SignedBeaconBlock,BeaconBlock,BeaconBlockBody,ExecutionPayload" \ + -output ./shared/types/eth2/fork/deneb/deneb_generated.go + +$DYNSSZ_GEN -package ./shared/types/eth2/fork/electra -with-streaming \ + -types "BeaconState,SignedBeaconBlock,BeaconBlock,BeaconBlockBody,Attestation,ExecutionRequests,DepositRequest,WithdrawalRequest,ConsolidationRequest,AttesterSlashing,IndexedAttestation" \ + -output ./shared/types/eth2/fork/electra/electra_generated.go + +$DYNSSZ_GEN -package ./shared/types/eth2/fork/fulu -with-streaming \ + -types "BeaconState,SignedBeaconBlock,BeaconBlock,BeaconBlockBody,Attestation,ExecutionRequests,DepositRequest,WithdrawalRequest,ConsolidationRequest,AttesterSlashing,IndexedAttestation" \ + -output ./shared/types/eth2/fork/fulu/fulu_generated.go