diff --git a/.gitignore b/.gitignore index 3ca50baddf8e..d10a570db1b4 100644 --- a/.gitignore +++ b/.gitignore @@ -58,3 +58,5 @@ CLAUDE.local.md # Downloaded external test data (make testdata) third_party/testdata +# methodical generated tests, which include large fixtures +testing/spectest/methodical diff --git a/api/client/builder/BUILD.bazel b/api/client/builder/BUILD.bazel index a86059b42ffa..a137999120b1 100644 --- a/api/client/builder/BUILD.bazel +++ b/api/client/builder/BUILD.bazel @@ -31,8 +31,8 @@ go_library( "//proto/prysm/v1alpha1:go_default_library", "//runtime/version:go_default_library", "@com_github_ethereum_go_ethereum//common/hexutil:go_default_library", + "@com_github_offchainlabs_methodical_ssz//ssz:go_default_library", "@com_github_pkg_errors//:go_default_library", - "@com_github_prysmaticlabs_fastssz//:go_default_library", "@com_github_sirupsen_logrus//:go_default_library", "@io_opentelemetry_go_contrib_instrumentation_net_http_otelhttp//:go_default_library", "@org_golang_google_protobuf//proto:go_default_library", diff --git a/api/client/builder/bid.go b/api/client/builder/bid.go index 6740ef7f90f7..32af1b005fcf 100644 --- a/api/client/builder/bid.go +++ b/api/client/builder/bid.go @@ -1,6 +1,7 @@ package builder import ( + "github.com/OffchainLabs/methodical-ssz/ssz" consensus_types "github.com/OffchainLabs/prysm/v7/consensus-types" "github.com/OffchainLabs/prysm/v7/consensus-types/blocks" "github.com/OffchainLabs/prysm/v7/consensus-types/interfaces" @@ -8,7 +9,6 @@ import ( v1 "github.com/OffchainLabs/prysm/v7/proto/engine/v1" ethpb "github.com/OffchainLabs/prysm/v7/proto/prysm/v1alpha1" "github.com/OffchainLabs/prysm/v7/runtime/version" - ssz "github.com/prysmaticlabs/fastssz" ) // SignedBid is an interface describing the method set of a signed builder bid. diff --git a/beacon-chain/blockchain/head_test.go b/beacon-chain/blockchain/head_test.go index dab5f3230ad3..f3e1f099beed 100644 --- a/beacon-chain/blockchain/head_test.go +++ b/beacon-chain/blockchain/head_test.go @@ -167,8 +167,10 @@ func Test_notifyNewHeadEvent(t *testing.T) { require.NoError(t, err) require.NoError(t, srv.cfg.ForkChoiceStore.InsertNode(t.Context(), st, blk)) require.NoError(t, srv.notifyNewHeadEvent(t.Context(), 1, newHeadStateRoot, newHeadRoot)) + require.Eventually(t, func() bool { + return len(notifier.ReceivedEvents()) == 1 + }, 5*time.Second, 50*time.Millisecond, "Expected exactly 1 state notification") events := notifier.ReceivedEvents() - require.Equal(t, 1, len(events)) eventHead, ok := events[0].Data.(*statefeed.HeadData) require.Equal(t, true, ok) @@ -233,8 +235,10 @@ func Test_notifyNewHeadEvent(t *testing.T) { require.NoError(t, srv.cfg.ForkChoiceStore.InsertNode(t.Context(), st, blk)) err = srv.notifyNewHeadEvent(t.Context(), epoch2Start, newHeadStateRoot, newHeadRoot) require.NoError(t, err) + require.Eventually(t, func() bool { + return len(notifier.ReceivedEvents()) == 1 + }, 5*time.Second, 50*time.Millisecond, "Expected exactly 1 state notification") events := notifier.ReceivedEvents() - require.Equal(t, 1, len(events)) eventHead, ok := events[0].Data.(*statefeed.HeadData) require.Equal(t, true, ok) @@ -263,8 +267,10 @@ func Test_notifyNewHeadEvent(t *testing.T) { require.NoError(t, srv.cfg.ForkChoiceStore.InsertNode(t.Context(), st, blk)) newHeadSlot := params.BeaconConfig().SlotsPerEpoch require.NoError(t, srv.notifyNewHeadEvent(t.Context(), newHeadSlot, newHeadStateRoot, newHeadRoot)) + require.Eventually(t, func() bool { + return len(notifier.ReceivedEvents()) == 1 + }, 5*time.Second, 50*time.Millisecond, "Expected exactly 1 state notification") events := notifier.ReceivedEvents() - require.Equal(t, 1, len(events)) eventHead, ok := events[0].Data.(*statefeed.HeadData) require.Equal(t, true, ok) @@ -292,8 +298,10 @@ func Test_notifyNewHeadEvent(t *testing.T) { require.NoError(t, srv.cfg.ForkChoiceStore.InsertNode(t.Context(), st, blk)) newHeadSlot := params.BeaconConfig().SlotsPerEpoch require.NoError(t, srv.notifyNewHeadEvent(t.Context(), newHeadSlot, [32]byte{2}, newHeadRoot)) + require.Eventually(t, func() bool { + return len(notifier.ReceivedEvents()) == 1 + }, 5*time.Second, 50*time.Millisecond, "Expected exactly 1 state notification") events := notifier.ReceivedEvents() - require.Equal(t, 1, len(events)) eventHead, ok := events[0].Data.(*statefeed.HeadData) require.Equal(t, true, ok) diff --git a/beacon-chain/core/gloas/BUILD.bazel b/beacon-chain/core/gloas/BUILD.bazel index 7429cd265a7d..c0f8e93d99f6 100644 --- a/beacon-chain/core/gloas/BUILD.bazel +++ b/beacon-chain/core/gloas/BUILD.bazel @@ -89,7 +89,7 @@ go_test( "//testing/require:go_default_library", "//testing/util:go_default_library", "//time/slots:go_default_library", - "@com_github_prysmaticlabs_fastssz//:go_default_library", + "@com_github_offchainlabs_methodical_ssz//ssz:go_default_library", "@com_github_prysmaticlabs_go_bitfield//:go_default_library", "@org_golang_google_protobuf//proto:go_default_library", ], diff --git a/beacon-chain/core/gloas/bid_test.go b/beacon-chain/core/gloas/bid_test.go index 97ba2a080831..4992ebdea4b5 100644 --- a/beacon-chain/core/gloas/bid_test.go +++ b/beacon-chain/core/gloas/bid_test.go @@ -4,6 +4,9 @@ import ( "bytes" "testing" + ssz "github.com/OffchainLabs/methodical-ssz/ssz" + "google.golang.org/protobuf/proto" + "github.com/OffchainLabs/prysm/v7/beacon-chain/core/signing" state_native "github.com/OffchainLabs/prysm/v7/beacon-chain/state/state-native" "github.com/OffchainLabs/prysm/v7/config/params" @@ -18,8 +21,6 @@ import ( "github.com/OffchainLabs/prysm/v7/runtime/version" "github.com/OffchainLabs/prysm/v7/testing/require" "github.com/OffchainLabs/prysm/v7/time/slots" - fastssz "github.com/prysmaticlabs/fastssz" - "google.golang.org/protobuf/proto" ) type stubBlockBody struct { @@ -91,7 +92,7 @@ func (s stubBlock) Version() int { return s.v } func (s stubBlock) AsSignRequestObject() (validatorpb.SignRequestObject, error) { return nil, nil } -func (s stubBlock) HashTreeRootWith(*fastssz.Hasher) error { return nil } +func (s stubBlock) HashTreeRootWith(*ssz.Hasher) error { return nil } func buildGloasState(t *testing.T, slot primitives.Slot, proposerIdx primitives.ValidatorIndex, builderIdx primitives.BuilderIndex, balance uint64, randao [32]byte, latestHash [32]byte, builderPubkey [48]byte) *state_native.BeaconState { t.Helper() diff --git a/beacon-chain/core/signing/BUILD.bazel b/beacon-chain/core/signing/BUILD.bazel index bb4753267b58..be05e1d5850c 100644 --- a/beacon-chain/core/signing/BUILD.bazel +++ b/beacon-chain/core/signing/BUILD.bazel @@ -15,8 +15,8 @@ go_library( "//crypto/bls:go_default_library", "//encoding/bytesutil:go_default_library", "//proto/prysm/v1alpha1:go_default_library", + "@com_github_offchainlabs_methodical_ssz//ssz:go_default_library", "@com_github_pkg_errors//:go_default_library", - "@com_github_prysmaticlabs_fastssz//:go_default_library", ], ) diff --git a/beacon-chain/core/signing/signing_root.go b/beacon-chain/core/signing/signing_root.go index 392bb5b2e4d4..deb31ee97c3e 100644 --- a/beacon-chain/core/signing/signing_root.go +++ b/beacon-chain/core/signing/signing_root.go @@ -3,6 +3,7 @@ package signing import ( "sync" + "github.com/OffchainLabs/methodical-ssz/ssz" "github.com/OffchainLabs/prysm/v7/beacon-chain/state" "github.com/OffchainLabs/prysm/v7/config/params" "github.com/OffchainLabs/prysm/v7/consensus-types/primitives" @@ -10,7 +11,6 @@ import ( "github.com/OffchainLabs/prysm/v7/encoding/bytesutil" ethpb "github.com/OffchainLabs/prysm/v7/proto/prysm/v1alpha1" "github.com/pkg/errors" - fssz "github.com/prysmaticlabs/fastssz" ) // ForkVersionByteLength length of fork version byte array. @@ -55,13 +55,13 @@ const ( ) // ComputeDomainAndSign computes the domain and signing root and sign it using the passed in private key. -func ComputeDomainAndSign(st state.ReadOnlyBeaconState, epoch primitives.Epoch, obj fssz.HashRoot, domain [4]byte, key bls.SecretKey) ([]byte, error) { +func ComputeDomainAndSign(st state.ReadOnlyBeaconState, epoch primitives.Epoch, obj ssz.HashRoot, domain [4]byte, key bls.SecretKey) ([]byte, error) { return ComputeDomainAndSignWithoutState(st.Fork(), epoch, domain, st.GenesisValidatorsRoot(), obj, key) } // ComputeDomainAndSignWithoutState offers the same functionality as ComputeDomainAndSign without the need to provide a BeaconState. // This is particularly helpful for signing values in tests. -func ComputeDomainAndSignWithoutState(fork *ethpb.Fork, epoch primitives.Epoch, domain [4]byte, vr []byte, obj fssz.HashRoot, key bls.SecretKey) ([]byte, error) { +func ComputeDomainAndSignWithoutState(fork *ethpb.Fork, epoch primitives.Epoch, domain [4]byte, vr []byte, obj ssz.HashRoot, key bls.SecretKey) ([]byte, error) { // EIP-7044: Beginning in Deneb, fix the fork version to Capella for signed exits. // This allows for signed validator exits to be valid forever. if domain == params.BeaconConfig().DomainVoluntaryExit && epoch >= params.BeaconConfig().DenebForkEpoch { @@ -94,7 +94,7 @@ func ComputeDomainAndSignWithoutState(fork *ethpb.Fork, epoch primitives.Epoch, // object_root=hash_tree_root(ssz_object), // domain=domain, // )) -func ComputeSigningRoot(object fssz.HashRoot, domain []byte) ([32]byte, error) { +func ComputeSigningRoot(object ssz.HashRoot, domain []byte) ([32]byte, error) { return Data(object.HashTreeRoot, domain) } @@ -119,7 +119,7 @@ func ComputeSigningRootForRoot(root [32]byte, domain []byte) ([32]byte, error) { } // ComputeDomainVerifySigningRoot computes domain and verifies signing root of an object given the beacon state, validator index and signature. -func ComputeDomainVerifySigningRoot(st state.ReadOnlyBeaconState, index primitives.ValidatorIndex, epoch primitives.Epoch, obj fssz.HashRoot, domain [4]byte, sig []byte) error { +func ComputeDomainVerifySigningRoot(st state.ReadOnlyBeaconState, index primitives.ValidatorIndex, epoch primitives.Epoch, obj ssz.HashRoot, domain [4]byte, sig []byte) error { v, err := st.ValidatorAtIndex(index) if err != nil { return err @@ -132,7 +132,7 @@ func ComputeDomainVerifySigningRoot(st state.ReadOnlyBeaconState, index primitiv } // VerifySigningRoot verifies the signing root of an object given its public key, signature and domain. -func VerifySigningRoot(obj fssz.HashRoot, pub, signature, domain []byte) error { +func VerifySigningRoot(obj ssz.HashRoot, pub, signature, domain []byte) error { publicKey, err := bls.PublicKeyFromBytes(pub) if err != nil { return errors.Wrap(err, "could not convert bytes to public key") diff --git a/beacon-chain/db/filesystem/BUILD.bazel b/beacon-chain/db/filesystem/BUILD.bazel index 98b7717b240e..0ab324241f1d 100644 --- a/beacon-chain/db/filesystem/BUILD.bazel +++ b/beacon-chain/db/filesystem/BUILD.bazel @@ -67,7 +67,7 @@ go_test( "//testing/require:go_default_library", "//testing/util:go_default_library", "//time/slots:go_default_library", - "@com_github_prysmaticlabs_fastssz//:go_default_library", + "@com_github_offchainlabs_methodical_ssz//ssz:go_default_library", "@com_github_spf13_afero//:go_default_library", ], ) diff --git a/beacon-chain/db/filesystem/blob_test.go b/beacon-chain/db/filesystem/blob_test.go index f1ebcff35617..eeb2e0c71713 100644 --- a/beacon-chain/db/filesystem/blob_test.go +++ b/beacon-chain/db/filesystem/blob_test.go @@ -8,6 +8,9 @@ import ( "sync" "testing" + "github.com/OffchainLabs/methodical-ssz/ssz" + "github.com/spf13/afero" + "github.com/OffchainLabs/prysm/v7/beacon-chain/db" "github.com/OffchainLabs/prysm/v7/beacon-chain/verification" "github.com/OffchainLabs/prysm/v7/config/params" @@ -16,8 +19,6 @@ import ( "github.com/OffchainLabs/prysm/v7/testing/require" "github.com/OffchainLabs/prysm/v7/testing/util" "github.com/OffchainLabs/prysm/v7/time/slots" - ssz "github.com/prysmaticlabs/fastssz" - "github.com/spf13/afero" ) func TestBlobStorage_SaveBlobData(t *testing.T) { diff --git a/beacon-chain/db/kv/BUILD.bazel b/beacon-chain/db/kv/BUILD.bazel index 3dd68b05f5f6..e940ce4ef7c5 100644 --- a/beacon-chain/db/kv/BUILD.bazel +++ b/beacon-chain/db/kv/BUILD.bazel @@ -74,10 +74,10 @@ go_library( "@com_github_ethereum_go_ethereum//common:go_default_library", "@com_github_ethereum_go_ethereum//common/hexutil:go_default_library", "@com_github_golang_snappy//:go_default_library", + "@com_github_offchainlabs_methodical_ssz//ssz:go_default_library", "@com_github_pkg_errors//:go_default_library", "@com_github_prometheus_client_golang//prometheus:go_default_library", "@com_github_prometheus_client_golang//prometheus/promauto:go_default_library", - "@com_github_prysmaticlabs_fastssz//:go_default_library", "@com_github_prysmaticlabs_prombbolt//:go_default_library", "@com_github_schollz_progressbar_v3//:go_default_library", "@com_github_sirupsen_logrus//:go_default_library", @@ -132,6 +132,7 @@ go_test( "//config/params:go_default_library", "//consensus-types/blocks:go_default_library", "//consensus-types/interfaces:go_default_library", + "//consensus-types/interfaces/testing:go_default_library", "//consensus-types/light-client:go_default_library", "//consensus-types/primitives:go_default_library", "//encoding/bytesutil:go_default_library", diff --git a/beacon-chain/db/kv/blocks.go b/beacon-chain/db/kv/blocks.go index b32a43d777c3..a817bb6f9762 100644 --- a/beacon-chain/db/kv/blocks.go +++ b/beacon-chain/db/kv/blocks.go @@ -6,6 +6,12 @@ import ( "fmt" "slices" + "github.com/OffchainLabs/methodical-ssz/ssz" + "github.com/ethereum/go-ethereum/common" + "github.com/golang/snappy" + "github.com/pkg/errors" + bolt "go.etcd.io/bbolt" + "github.com/OffchainLabs/prysm/v7/beacon-chain/db/filters" "github.com/OffchainLabs/prysm/v7/config/params" "github.com/OffchainLabs/prysm/v7/consensus-types/blocks" @@ -17,11 +23,6 @@ import ( ethpb "github.com/OffchainLabs/prysm/v7/proto/prysm/v1alpha1" "github.com/OffchainLabs/prysm/v7/runtime/version" "github.com/OffchainLabs/prysm/v7/time/slots" - "github.com/ethereum/go-ethereum/common" - "github.com/golang/snappy" - "github.com/pkg/errors" - ssz "github.com/prysmaticlabs/fastssz" - bolt "go.etcd.io/bbolt" ) // Used to represent errors for inconsistent slot ranges. diff --git a/beacon-chain/db/kv/encoding.go b/beacon-chain/db/kv/encoding.go index e7de24fabfad..338d3f51a1b5 100644 --- a/beacon-chain/db/kv/encoding.go +++ b/beacon-chain/db/kv/encoding.go @@ -5,11 +5,12 @@ import ( "errors" "reflect" - "github.com/OffchainLabs/prysm/v7/monitoring/tracing/trace" - ethpb "github.com/OffchainLabs/prysm/v7/proto/prysm/v1alpha1" + "github.com/OffchainLabs/methodical-ssz/ssz" "github.com/golang/snappy" - fastssz "github.com/prysmaticlabs/fastssz" "google.golang.org/protobuf/proto" + + "github.com/OffchainLabs/prysm/v7/monitoring/tracing/trace" + ethpb "github.com/OffchainLabs/prysm/v7/proto/prysm/v1alpha1" ) func decode(ctx context.Context, data []byte, dst proto.Message) error { @@ -25,7 +26,7 @@ func decode(ctx context.Context, data []byte, dst proto.Message) error { return err } if isSSZStorageFormat(dst) { - return dst.(fastssz.Unmarshaler).UnmarshalSSZ(data) + return dst.(ssz.Unmarshaler).UnmarshalSSZ(data) } return proto.Unmarshal(data, dst) } @@ -44,7 +45,7 @@ func encode(ctx context.Context, msg proto.Message) ([]byte, error) { var enc []byte var err error if isSSZStorageFormat(msg) { - enc, err = msg.(fastssz.Marshaler).MarshalSSZ() + enc, err = msg.(ssz.Marshaler).MarshalSSZ() if err != nil { return nil, err } diff --git a/beacon-chain/db/kv/kv_test.go b/beacon-chain/db/kv/kv_test.go index dd21942d059d..6762043fa3a2 100644 --- a/beacon-chain/db/kv/kv_test.go +++ b/beacon-chain/db/kv/kv_test.go @@ -10,7 +10,7 @@ import ( "github.com/OffchainLabs/prysm/v7/cmd/beacon-chain/flags" "github.com/OffchainLabs/prysm/v7/config/features" "github.com/OffchainLabs/prysm/v7/consensus-types/blocks" - "github.com/OffchainLabs/prysm/v7/consensus-types/interfaces" + interfacestest "github.com/OffchainLabs/prysm/v7/consensus-types/interfaces/testing" ethpb "github.com/OffchainLabs/prysm/v7/proto/prysm/v1alpha1" "github.com/OffchainLabs/prysm/v7/runtime/version" "github.com/OffchainLabs/prysm/v7/testing/require" @@ -19,15 +19,6 @@ import ( bolt "go.etcd.io/bbolt" ) -func requireBlocksEqual(t testing.TB, want, got interfaces.ReadOnlySignedBeaconBlock) { - wantPb, err := want.Proto() - require.NoError(t, err) - - gotPb, err := got.Proto() - require.NoError(t, err) - require.DeepEqual(t, wantPb, gotPb) -} - // setupDB instantiates and returns a Store instance. func setupDB(t testing.TB) *Store { db, err := NewKVStore(t.Context(), t.TempDir()) @@ -161,8 +152,14 @@ func Test_setupBlockStorageType(t *testing.T) { require.NoError(t, store.SaveHeadBlockRoot(ctx, root)) retrievedBlk, err := store.Block(ctx, root) require.NoError(t, err) + if retrievedBlk == nil { + t.Fatal("retrieved block is nil") + } + rRoot, err := retrievedBlk.Block().HashTreeRoot() + require.NoError(t, err) + require.Equal(t, root, rRoot) require.Equal(t, false, retrievedBlk.IsBlinded()) - requireBlocksEqual(t, wrappedBlock, retrievedBlk) + interfacestest.RequireBlocksEqual(t, wrappedBlock, retrievedBlk) }) t.Run("fresh database with default settings should store blinded", func(t *testing.T) { resetFn := features.InitWithReset(&features.Flags{ @@ -186,7 +183,7 @@ func Test_setupBlockStorageType(t *testing.T) { wantedBlk, err := wrappedBlock.ToBlinded() require.NoError(t, err) - requireBlocksEqual(t, wantedBlk, retrievedBlk) + interfacestest.RequireBlocksEqual(t, wantedBlk, retrievedBlk) }) t.Run("existing database with blinded blocks but no key in metadata bucket should continue storing blinded blocks", func(t *testing.T) { store := setupDB(t) @@ -206,7 +203,7 @@ func Test_setupBlockStorageType(t *testing.T) { retrievedBlk, err := store.Block(ctx, root) require.NoError(t, err) require.Equal(t, true, retrievedBlk.IsBlinded()) - requireBlocksEqual(t, wrappedBlock, retrievedBlk) + interfacestest.RequireBlocksEqual(t, wrappedBlock, retrievedBlk) // We then delete the key from the bucket. require.NoError(t, store.db.Update(func(tx *bolt.Tx) error { @@ -272,7 +269,7 @@ func Test_setupBlockStorageType(t *testing.T) { retrievedBlk, err := store.Block(ctx, root) require.NoError(t, err) require.Equal(t, false, retrievedBlk.IsBlinded()) - requireBlocksEqual(t, wrappedBlock, retrievedBlk) + interfacestest.RequireBlocksEqual(t, wrappedBlock, retrievedBlk) // Not a fresh database, has full blocks already and should continue being that way. err = store.setupBlockStorageType(ctx) @@ -318,7 +315,7 @@ func Test_setupBlockStorageType(t *testing.T) { require.Equal(t, true, retrievedBlk.IsBlinded()) wantedBlk, err := wrappedBlock.ToBlinded() require.NoError(t, err) - requireBlocksEqual(t, wantedBlk, retrievedBlk) + interfacestest.RequireBlocksEqual(t, wantedBlk, retrievedBlk) // Trying to enable full blocks with a database that is already storing blinded blocks should error. resetFn := features.InitWithReset(&features.Flags{ diff --git a/beacon-chain/db/slasherkv/BUILD.bazel b/beacon-chain/db/slasherkv/BUILD.bazel index 8ff95cc40efc..6b98e6c1631d 100644 --- a/beacon-chain/db/slasherkv/BUILD.bazel +++ b/beacon-chain/db/slasherkv/BUILD.bazel @@ -29,7 +29,6 @@ go_library( "@com_github_pkg_errors//:go_default_library", "@com_github_prometheus_client_golang//prometheus:go_default_library", "@com_github_prometheus_client_golang//prometheus/promauto:go_default_library", - "@com_github_prysmaticlabs_fastssz//:go_default_library", "@com_github_sirupsen_logrus//:go_default_library", "@io_etcd_go_bbolt//:go_default_library", "@org_golang_x_sync//errgroup:go_default_library", @@ -55,7 +54,6 @@ go_test( "//runtime/version:go_default_library", "//testing/require:go_default_library", "//time/slots:go_default_library", - "@com_github_prysmaticlabs_fastssz//:go_default_library", "@com_github_sirupsen_logrus//:go_default_library", "@com_github_sirupsen_logrus//hooks/test:go_default_library", "@io_etcd_go_bbolt//:go_default_library", diff --git a/beacon-chain/db/slasherkv/slasher.go b/beacon-chain/db/slasherkv/slasher.go index 3246c501bd11..40124f825b99 100644 --- a/beacon-chain/db/slasherkv/slasher.go +++ b/beacon-chain/db/slasherkv/slasher.go @@ -8,6 +8,11 @@ import ( "sort" "sync" + "github.com/golang/snappy" + "github.com/pkg/errors" + bolt "go.etcd.io/bbolt" + "golang.org/x/sync/errgroup" + "github.com/OffchainLabs/prysm/v7/beacon-chain/db/kv" slashertypes "github.com/OffchainLabs/prysm/v7/beacon-chain/slasher/types" "github.com/OffchainLabs/prysm/v7/consensus-types/primitives" @@ -15,11 +20,6 @@ import ( "github.com/OffchainLabs/prysm/v7/monitoring/tracing/trace" ethpb "github.com/OffchainLabs/prysm/v7/proto/prysm/v1alpha1" "github.com/OffchainLabs/prysm/v7/runtime/version" - "github.com/golang/snappy" - "github.com/pkg/errors" - ssz "github.com/prysmaticlabs/fastssz" - bolt "go.etcd.io/bbolt" - "golang.org/x/sync/errgroup" ) const ( @@ -361,7 +361,7 @@ func (s *Store) LoadSlasherChunks( encodedKeys := make([][]byte, 0, keysCount) // Encode kind. - encodedKind := ssz.MarshalUint8(make([]byte, 0), uint8(kind)) + encodedKind := []byte{byte(kind)} // Encode keys. for _, chunkKey := range chunkKeys { @@ -423,7 +423,7 @@ func (s *Store) SaveSlasherChunks( chunksCount := len(chunks) // Encode kind. - encodedKind := ssz.MarshalUint8(make([]byte, 0), uint8(kind)) + encodedKind := []byte{byte(kind)} // Encode keys and chunks. encodedKeys := make([][]byte, chunksCount) @@ -660,7 +660,7 @@ func keyForValidatorProposal(slot primitives.Slot, proposerIndex primitives.Vali func encodeSlasherChunk(chunk []uint16) ([]byte, error) { val := make([]byte, 0) for i := range chunk { - val = append(val, ssz.MarshalUint16(make([]byte, 0), chunk[i])...) + val = binary.LittleEndian.AppendUint16(val, chunk[i]) } if len(val) == 0 { return nil, errors.New("cannot encode empty chunk") @@ -681,7 +681,7 @@ func decodeSlasherChunk(enc []byte) ([]uint16, error) { } chunk := make([]uint16, 0) for i := 0; i < len(chunkBytes); i += 2 { - distance := ssz.UnmarshallUint16(chunkBytes[i : i+2]) + distance := binary.LittleEndian.Uint16(chunkBytes[i : i+2]) chunk = append(chunk, distance) } return chunk, nil diff --git a/beacon-chain/db/slasherkv/slasher_test.go b/beacon-chain/db/slasherkv/slasher_test.go index ced8939beb86..c5fa54039e3f 100644 --- a/beacon-chain/db/slasherkv/slasher_test.go +++ b/beacon-chain/db/slasherkv/slasher_test.go @@ -14,7 +14,6 @@ import ( ethpb "github.com/OffchainLabs/prysm/v7/proto/prysm/v1alpha1" "github.com/OffchainLabs/prysm/v7/runtime/version" "github.com/OffchainLabs/prysm/v7/testing/require" - ssz "github.com/prysmaticlabs/fastssz" ) func TestStore_AttestationRecordForValidator_SaveRetrieve(t *testing.T) { @@ -217,7 +216,7 @@ func TestStore_SlasherChunk_SaveRetrieve(t *testing.T) { for i := range totalChunks { // Create chunk key. - chunkKey := ssz.MarshalUint64(make([]byte, 0), uint64(i)) + chunkKey := binary.LittleEndian.AppendUint64(make([]byte, 0), uint64(i)) minChunkKeys[i] = chunkKey // Create chunk. @@ -236,7 +235,7 @@ func TestStore_SlasherChunk_SaveRetrieve(t *testing.T) { for i := range totalChunks { // Create chunk key. - chunkKey := ssz.MarshalUint64(make([]byte, 0), uint64(i+1)) + chunkKey := binary.LittleEndian.AppendUint64(make([]byte, 0), uint64(i+1)) maxChunkKeys[i] = chunkKey // Create chunk. @@ -317,7 +316,7 @@ func TestStore_SlasherChunk_PreventsSavingWrongLength(t *testing.T) { chunks := make([][]uint16, totalChunks) for i := range totalChunks { chunks[i] = []uint16{} - chunkKeys[i] = ssz.MarshalUint64(make([]byte, 0), uint64(i)) + chunkKeys[i] = binary.LittleEndian.AppendUint64(make([]byte, 0), uint64(i)) } // We should get an error if saving empty chunks. err := beaconDB.SaveSlasherChunks(ctx, slashertypes.MinSpan, chunkKeys, chunks) @@ -456,12 +455,15 @@ func Test_encodeDecodeAttestationRecord(t *testing.T) { t.Fatalf("encodeAttestationRecord() error = %v, wantErr %v", err, tt.wantErr) } decoded, err := decodeAttestationRecord(got) - if (err != nil) != tt.wantErr { - t.Fatalf("decodeAttestationRecord() error = %v, wantErr %v", err, tt.wantErr) + if tt.wantErr { + if err == nil { + t.Fatalf("decodeAttestationRecord() error = %v, wantErr %v", err, tt.wantErr) + } + return } - - if !tt.wantErr && !reflect.DeepEqual(tt.attWrapper, decoded) { - t.Errorf("Did not match got = %v, want %v", tt.attWrapper, decoded) + if !tt.wantErr { + require.DeepSSZEqual(t, tt.attWrapper.IndexedAttestation, decoded.IndexedAttestation) + require.Equal(t, tt.attWrapper.DataRoot, decoded.DataRoot) } }) } diff --git a/beacon-chain/p2p/BUILD.bazel b/beacon-chain/p2p/BUILD.bazel index fff6024e33d3..a9256955f392 100644 --- a/beacon-chain/p2p/BUILD.bazel +++ b/beacon-chain/p2p/BUILD.bazel @@ -110,11 +110,11 @@ go_library( "@com_github_libp2p_go_mplex//:go_default_library", "@com_github_multiformats_go_multiaddr//:go_default_library", "@com_github_multiformats_go_multiaddr//net:go_default_library", + "@com_github_offchainlabs_methodical_ssz//ssz:go_default_library", "@com_github_patrickmn_go_cache//:go_default_library", "@com_github_pkg_errors//:go_default_library", "@com_github_prometheus_client_golang//prometheus:go_default_library", "@com_github_prometheus_client_golang//prometheus/promauto:go_default_library", - "@com_github_prysmaticlabs_fastssz//:go_default_library", "@com_github_prysmaticlabs_go_bitfield//:go_default_library", "@com_github_sirupsen_logrus//:go_default_library", "@org_golang_google_protobuf//proto:go_default_library", diff --git a/beacon-chain/p2p/broadcaster.go b/beacon-chain/p2p/broadcaster.go index 4d48feddf350..079c5ab09497 100644 --- a/beacon-chain/p2p/broadcaster.go +++ b/beacon-chain/p2p/broadcaster.go @@ -10,6 +10,12 @@ import ( "sync/atomic" "time" + "github.com/OffchainLabs/methodical-ssz/ssz" + pubsub "github.com/libp2p/go-libp2p-pubsub" + "github.com/pkg/errors" + "github.com/sirupsen/logrus" + "google.golang.org/protobuf/proto" + "github.com/OffchainLabs/prysm/v7/beacon-chain/core/altair" "github.com/OffchainLabs/prysm/v7/beacon-chain/core/helpers" "github.com/OffchainLabs/prysm/v7/beacon-chain/core/peerdas" @@ -24,11 +30,6 @@ import ( "github.com/OffchainLabs/prysm/v7/monitoring/tracing/trace" ethpb "github.com/OffchainLabs/prysm/v7/proto/prysm/v1alpha1" "github.com/OffchainLabs/prysm/v7/time/slots" - pubsub "github.com/libp2p/go-libp2p-pubsub" - "github.com/pkg/errors" - ssz "github.com/prysmaticlabs/fastssz" - "github.com/sirupsen/logrus" - "google.golang.org/protobuf/proto" ) const minimumPeersPerSubnetForBroadcast = 1 diff --git a/beacon-chain/p2p/encoder/BUILD.bazel b/beacon-chain/p2p/encoder/BUILD.bazel index 48a51b1a6ffc..b8178895d91c 100644 --- a/beacon-chain/p2p/encoder/BUILD.bazel +++ b/beacon-chain/p2p/encoder/BUILD.bazel @@ -18,8 +18,8 @@ go_library( "//math:go_default_library", "@com_github_gogo_protobuf//proto:go_default_library", "@com_github_golang_snappy//:go_default_library", + "@com_github_offchainlabs_methodical_ssz//ssz:go_default_library", "@com_github_pkg_errors//:go_default_library", - "@com_github_prysmaticlabs_fastssz//:go_default_library", ], ) @@ -41,7 +41,7 @@ go_test( "@com_github_gogo_protobuf//proto:go_default_library", "@com_github_golang_snappy//:go_default_library", "@com_github_google_go_cmp//cmp:go_default_library", - "@com_github_prysmaticlabs_fastssz//:go_default_library", + "@com_github_offchainlabs_methodical_ssz//ssz:go_default_library", "@org_golang_google_protobuf//proto:go_default_library", "@org_golang_google_protobuf//reflect/protoreflect:go_default_library", "@org_golang_google_protobuf//testing/protocmp:go_default_library", diff --git a/beacon-chain/p2p/encoder/network_encoding.go b/beacon-chain/p2p/encoder/network_encoding.go index 849da5c49571..1e612e6e825a 100644 --- a/beacon-chain/p2p/encoder/network_encoding.go +++ b/beacon-chain/p2p/encoder/network_encoding.go @@ -3,7 +3,7 @@ package encoder import ( "io" - ssz "github.com/prysmaticlabs/fastssz" + "github.com/OffchainLabs/methodical-ssz/ssz" ) // NetworkEncoding represents an encoder compatible with Ethereum consensus p2p. diff --git a/beacon-chain/p2p/encoder/ssz.go b/beacon-chain/p2p/encoder/ssz.go index a50a97257a4b..e5d538952d33 100644 --- a/beacon-chain/p2p/encoder/ssz.go +++ b/beacon-chain/p2p/encoder/ssz.go @@ -5,12 +5,13 @@ import ( "io" "sync" - "github.com/OffchainLabs/prysm/v7/config/params" - "github.com/OffchainLabs/prysm/v7/math" + "github.com/OffchainLabs/methodical-ssz/ssz" "github.com/gogo/protobuf/proto" "github.com/golang/snappy" "github.com/pkg/errors" - fastssz "github.com/prysmaticlabs/fastssz" + + "github.com/OffchainLabs/prysm/v7/config/params" + "github.com/OffchainLabs/prysm/v7/math" ) var _ NetworkEncoding = (*SszNetworkEncoder)(nil) @@ -34,7 +35,7 @@ type SszNetworkEncoder struct{} const ProtocolSuffixSSZSnappy = "ssz_snappy" // EncodeGossip the proto gossip message to the io.Writer. -func (_ SszNetworkEncoder) EncodeGossip(w io.Writer, msg fastssz.Marshaler) (int, error) { +func (_ SszNetworkEncoder) EncodeGossip(w io.Writer, msg ssz.Marshaler) (int, error) { if msg == nil { return 0, nil } @@ -51,7 +52,7 @@ func (_ SszNetworkEncoder) EncodeGossip(w io.Writer, msg fastssz.Marshaler) (int // EncodeWithMaxLength the proto message to the io.Writer. This encoding prefixes the byte slice with a protobuf varint // to indicate the size of the message. This checks that the encoded message isn't larger than the provided max limit. -func (_ SszNetworkEncoder) EncodeWithMaxLength(w io.Writer, msg fastssz.Marshaler) (int, error) { +func (_ SszNetworkEncoder) EncodeWithMaxLength(w io.Writer, msg ssz.Marshaler) (int, error) { if msg == nil { return 0, nil } @@ -74,12 +75,12 @@ func (_ SszNetworkEncoder) EncodeWithMaxLength(w io.Writer, msg fastssz.Marshale return writeSnappyBuffer(w, b) } -func doDecode(b []byte, to fastssz.Unmarshaler) error { +func doDecode(b []byte, to ssz.Unmarshaler) error { return to.UnmarshalSSZ(b) } // DecodeGossip decodes the bytes to the protobuf gossip message provided. -func (_ SszNetworkEncoder) DecodeGossip(b []byte, to fastssz.Unmarshaler) error { +func (_ SszNetworkEncoder) DecodeGossip(b []byte, to ssz.Unmarshaler) error { if uint64(len(b)) > MaxCompressedLen(MaxPayloadSize) { return fmt.Errorf("gossip message exceeds maximum compressed limit: %d", MaxCompressedLen(MaxPayloadSize)) } @@ -108,7 +109,7 @@ func DecodeSnappy(msg []byte, maxSize uint64) ([]byte, error) { // DecodeWithMaxLength the bytes from io.Reader to the protobuf message provided. // This checks that the decoded message isn't larger than the provided max limit. -func (e SszNetworkEncoder) DecodeWithMaxLength(r io.Reader, to fastssz.Unmarshaler) error { +func (e SszNetworkEncoder) DecodeWithMaxLength(r io.Reader, to ssz.Unmarshaler) error { msgLen, err := readVarint(r) if err != nil { return err diff --git a/beacon-chain/p2p/encoder/ssz_test.go b/beacon-chain/p2p/encoder/ssz_test.go index 9eb2c932b506..b6df71eeb0c4 100644 --- a/beacon-chain/p2p/encoder/ssz_test.go +++ b/beacon-chain/p2p/encoder/ssz_test.go @@ -8,25 +8,26 @@ import ( "math" "testing" + "github.com/OffchainLabs/methodical-ssz/ssz" + gogo "github.com/gogo/protobuf/proto" + "github.com/google/go-cmp/cmp" + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/reflect/protoreflect" + "google.golang.org/protobuf/testing/protocmp" + "github.com/OffchainLabs/prysm/v7/beacon-chain/p2p/encoder" "github.com/OffchainLabs/prysm/v7/config/params" ethpb "github.com/OffchainLabs/prysm/v7/proto/prysm/v1alpha1" "github.com/OffchainLabs/prysm/v7/testing/assert" "github.com/OffchainLabs/prysm/v7/testing/require" "github.com/OffchainLabs/prysm/v7/testing/util" - gogo "github.com/gogo/protobuf/proto" - "github.com/google/go-cmp/cmp" - fastssz "github.com/prysmaticlabs/fastssz" - "google.golang.org/protobuf/proto" - "google.golang.org/protobuf/reflect/protoreflect" - "google.golang.org/protobuf/testing/protocmp" ) -// Define an interface that combines fastssz.Marshaler and proto.Message +// Define an interface that combines ssz.Marshaler and proto.Message type MarshalerProtoMessage interface { - fastssz.Marshaler + ssz.Marshaler proto.Message - fastssz.Unmarshaler + ssz.Unmarshaler } type MarshalerProtoCreator interface { diff --git a/beacon-chain/p2p/sender.go b/beacon-chain/p2p/sender.go index 6a65ca2640d2..59c01471c3b9 100644 --- a/beacon-chain/p2p/sender.go +++ b/beacon-chain/p2p/sender.go @@ -3,15 +3,16 @@ package p2p import ( "context" - "github.com/OffchainLabs/prysm/v7/monitoring/tracing" - "github.com/OffchainLabs/prysm/v7/monitoring/tracing/trace" + "github.com/OffchainLabs/methodical-ssz/ssz" "github.com/kr/pretty" "github.com/libp2p/go-libp2p/core/network" "github.com/libp2p/go-libp2p/core/peer" "github.com/libp2p/go-libp2p/core/protocol" "github.com/pkg/errors" - ssz "github.com/prysmaticlabs/fastssz" "github.com/sirupsen/logrus" + + "github.com/OffchainLabs/prysm/v7/monitoring/tracing" + "github.com/OffchainLabs/prysm/v7/monitoring/tracing/trace" ) // Send a message to a specific peer. The returned stream may be used for reading, but has been diff --git a/beacon-chain/p2p/testing/BUILD.bazel b/beacon-chain/p2p/testing/BUILD.bazel index 9a8e8f624ab8..4a58241ac842 100644 --- a/beacon-chain/p2p/testing/BUILD.bazel +++ b/beacon-chain/p2p/testing/BUILD.bazel @@ -51,7 +51,7 @@ go_library( "@com_github_libp2p_go_libp2p//p2p/transport/tcp:go_default_library", "@com_github_libp2p_go_libp2p_pubsub//:go_default_library", "@com_github_multiformats_go_multiaddr//:go_default_library", - "@com_github_prysmaticlabs_fastssz//:go_default_library", + "@com_github_offchainlabs_methodical_ssz//ssz:go_default_library", "@com_github_sirupsen_logrus//:go_default_library", "@org_golang_google_protobuf//proto:go_default_library", ], diff --git a/beacon-chain/p2p/testing/p2p.go b/beacon-chain/p2p/testing/p2p.go index ebc0c3b12547..5597a957db5e 100644 --- a/beacon-chain/p2p/testing/p2p.go +++ b/beacon-chain/p2p/testing/p2p.go @@ -11,6 +11,7 @@ import ( "testing" "time" + "github.com/OffchainLabs/methodical-ssz/ssz" "github.com/OffchainLabs/prysm/v7/beacon-chain/core/peerdas" "github.com/OffchainLabs/prysm/v7/beacon-chain/p2p/encoder" "github.com/OffchainLabs/prysm/v7/beacon-chain/p2p/partialdatacolumnbroadcaster" @@ -37,7 +38,6 @@ import ( "github.com/libp2p/go-libp2p/core/protocol" "github.com/libp2p/go-libp2p/p2p/transport/tcp" "github.com/multiformats/go-multiaddr" - ssz "github.com/prysmaticlabs/fastssz" "github.com/sirupsen/logrus" "google.golang.org/protobuf/proto" ) diff --git a/beacon-chain/p2p/types/BUILD.bazel b/beacon-chain/p2p/types/BUILD.bazel index de2644eee024..a60fd1849307 100644 --- a/beacon-chain/p2p/types/BUILD.bazel +++ b/beacon-chain/p2p/types/BUILD.bazel @@ -28,8 +28,8 @@ go_library( "//proto/engine/v1:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//proto/prysm/v1alpha1/metadata:go_default_library", + "@com_github_offchainlabs_methodical_ssz//ssz:go_default_library", "@com_github_pkg_errors//:go_default_library", - "@com_github_prysmaticlabs_fastssz//:go_default_library", ], ) @@ -49,6 +49,6 @@ go_test( "//runtime/version:go_default_library", "//testing/assert:go_default_library", "//testing/require:go_default_library", - "@com_github_prysmaticlabs_fastssz//:go_default_library", + "@com_github_offchainlabs_methodical_ssz//ssz:go_default_library", ], ) diff --git a/beacon-chain/p2p/types/object_mapping.go b/beacon-chain/p2p/types/object_mapping.go index 69307f39265c..eb4ec1322898 100644 --- a/beacon-chain/p2p/types/object_mapping.go +++ b/beacon-chain/p2p/types/object_mapping.go @@ -1,6 +1,7 @@ package types import ( + "github.com/OffchainLabs/methodical-ssz/ssz" "github.com/OffchainLabs/prysm/v7/config/params" "github.com/OffchainLabs/prysm/v7/consensus-types/blocks" "github.com/OffchainLabs/prysm/v7/consensus-types/interfaces" @@ -10,7 +11,6 @@ import ( enginev1 "github.com/OffchainLabs/prysm/v7/proto/engine/v1" ethpb "github.com/OffchainLabs/prysm/v7/proto/prysm/v1alpha1" "github.com/OffchainLabs/prysm/v7/proto/prysm/v1alpha1/metadata" - ssz "github.com/prysmaticlabs/fastssz" ) func init() { diff --git a/beacon-chain/p2p/types/types.go b/beacon-chain/p2p/types/types.go index 8243adc26de5..06a502ea859b 100644 --- a/beacon-chain/p2p/types/types.go +++ b/beacon-chain/p2p/types/types.go @@ -8,11 +8,12 @@ import ( "encoding/binary" "sort" + "github.com/OffchainLabs/methodical-ssz/ssz" + "github.com/pkg/errors" + fieldparams "github.com/OffchainLabs/prysm/v7/config/fieldparams" "github.com/OffchainLabs/prysm/v7/config/params" eth "github.com/OffchainLabs/prysm/v7/proto/prysm/v1alpha1" - "github.com/pkg/errors" - ssz "github.com/prysmaticlabs/fastssz" ) const ( @@ -20,6 +21,8 @@ const ( bytesPerLengthOffset = 4 ) +var ErrIncorrectByteSize = errors.New("incorrect byte size") + // SSZBytes is a bytes slice that satisfies the fast-ssz interface. type SSZBytes []byte @@ -74,7 +77,7 @@ func (r *BeaconBlockByRootsReq) UnmarshalSSZ(buf []byte) error { return errors.Errorf("expected buffer with length of up to %d but received length %d", maxLength, bufLen) } if bufLen%fieldparams.RootLength != 0 { - return ssz.ErrIncorrectByteSize + return ErrIncorrectByteSize } numOfRoots := bufLen / fieldparams.RootLength roots := make([][fieldparams.RootLength]byte, 0, numOfRoots) @@ -171,7 +174,7 @@ func (b *BlobSidecarsByRootReq) UnmarshalSSZ(buf []byte) error { return errors.Wrapf(ssz.ErrIncorrectListSize, "expected buffer with length of up to %d but received length %d", maxLength, bufLen) } if bufLen%blobIdSize != 0 { - return errors.Wrapf(ssz.ErrIncorrectByteSize, "size=%d", bufLen) + return errors.Wrapf(ErrIncorrectByteSize, "size=%d", bufLen) } count := bufLen / blobIdSize *b = make([]*eth.BlobIdentifier, count) diff --git a/beacon-chain/p2p/types/types_test.go b/beacon-chain/p2p/types/types_test.go index 0859a89d7287..4549dde643f1 100644 --- a/beacon-chain/p2p/types/types_test.go +++ b/beacon-chain/p2p/types/types_test.go @@ -4,6 +4,8 @@ import ( "encoding/hex" "testing" + "github.com/OffchainLabs/methodical-ssz/ssz" + fieldparams "github.com/OffchainLabs/prysm/v7/config/fieldparams" "github.com/OffchainLabs/prysm/v7/config/params" "github.com/OffchainLabs/prysm/v7/consensus-types/primitives" @@ -11,7 +13,6 @@ import ( eth "github.com/OffchainLabs/prysm/v7/proto/prysm/v1alpha1" "github.com/OffchainLabs/prysm/v7/testing/assert" "github.com/OffchainLabs/prysm/v7/testing/require" - ssz "github.com/prysmaticlabs/fastssz" ) func generateBlobIdentifiers(n int) []*eth.BlobIdentifier { @@ -60,7 +61,7 @@ func TestBlobSidecarsByRootReq_MarshalSSZ(t *testing.T) { in = append(in, byte(0)) return in }, - unmarshalErr: ssz.ErrIncorrectByteSize, + unmarshalErr: ErrIncorrectByteSize, }, } @@ -313,7 +314,7 @@ func TestDataColumnSidecarsByRootReq_MarshalUnmarshal(t *testing.T) { name string ids []*eth.DataColumnsByRootIdentifier marshalErr error - unmarshalErr string + unmarshalErr error unmarshalMod func([]byte) []byte }{ { @@ -334,7 +335,7 @@ func TestDataColumnSidecarsByRootReq_MarshalUnmarshal(t *testing.T) { in = append(in, byte(0)) return in }, - unmarshalErr: "a is not evenly divisble by b", + unmarshalErr: ssz.ErrIncorrectListSize, }, { name: "size too big", @@ -345,7 +346,7 @@ func TestDataColumnSidecarsByRootReq_MarshalUnmarshal(t *testing.T) { in = append(in, add...) return in }, - unmarshalErr: "a/b is greater than max", + unmarshalErr: ssz.ErrListTooBig, }, } @@ -365,8 +366,8 @@ func TestDataColumnSidecarsByRootReq_MarshalUnmarshal(t *testing.T) { got := &DataColumnsByRootIdentifiers{} err = got.UnmarshalSSZ(bytes) - if c.unmarshalErr != "" { - require.ErrorContains(t, c.unmarshalErr, err) + if c.unmarshalErr != nil { + require.ErrorIs(t, err, c.unmarshalErr) return } require.NoError(t, err) diff --git a/beacon-chain/rpc/eth/beacon/BUILD.bazel b/beacon-chain/rpc/eth/beacon/BUILD.bazel index 4aede6818253..e7005b529eea 100644 --- a/beacon-chain/rpc/eth/beacon/BUILD.bazel +++ b/beacon-chain/rpc/eth/beacon/BUILD.bazel @@ -63,10 +63,10 @@ go_library( "//runtime/version:go_default_library", "//time/slots:go_default_library", "@com_github_ethereum_go_ethereum//common/hexutil:go_default_library", + "@com_github_offchainlabs_methodical_ssz//ssz:go_default_library", "@com_github_pkg_errors//:go_default_library", "@com_github_prometheus_client_golang//prometheus:go_default_library", "@com_github_prometheus_client_golang//prometheus/promauto:go_default_library", - "@com_github_prysmaticlabs_fastssz//:go_default_library", "@com_github_sirupsen_logrus//:go_default_library", "@org_golang_google_grpc//codes:go_default_library", "@org_golang_google_grpc//status:go_default_library", @@ -136,7 +136,6 @@ go_test( "//time/slots:go_default_library", "@com_github_ethereum_go_ethereum//common/hexutil:go_default_library", "@com_github_pkg_errors//:go_default_library", - "@com_github_prysmaticlabs_fastssz//:go_default_library", "@com_github_prysmaticlabs_go_bitfield//:go_default_library", "@com_github_sirupsen_logrus//hooks/test:go_default_library", "@com_github_stretchr_testify//mock:go_default_library", diff --git a/beacon-chain/rpc/eth/beacon/handlers.go b/beacon-chain/rpc/eth/beacon/handlers.go index 2680c36c413e..fed10725db44 100644 --- a/beacon-chain/rpc/eth/beacon/handlers.go +++ b/beacon-chain/rpc/eth/beacon/handlers.go @@ -10,6 +10,11 @@ import ( "strconv" "time" + "github.com/OffchainLabs/methodical-ssz/ssz" + "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/pkg/errors" + "github.com/sirupsen/logrus" + "github.com/OffchainLabs/prysm/v7/api" "github.com/OffchainLabs/prysm/v7/api/server/structs" "github.com/OffchainLabs/prysm/v7/beacon-chain/blockchain/kzg" @@ -31,10 +36,6 @@ import ( eth "github.com/OffchainLabs/prysm/v7/proto/prysm/v1alpha1" "github.com/OffchainLabs/prysm/v7/runtime/version" "github.com/OffchainLabs/prysm/v7/time/slots" - "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/pkg/errors" - ssz "github.com/prysmaticlabs/fastssz" - "github.com/sirupsen/logrus" ) const ( @@ -1725,7 +1726,7 @@ func (s *Server) GetProposerLookahead(w http.ResponseWriter, r *http.Request) { sszLen := (*primitives.ValidatorIndex)(nil).SizeSSZ() sszData := make([]byte, len(pl)*sszLen) for i, idx := range pl { - copy(sszData[i*sszLen:(i+1)*sszLen], ssz.MarshalUint64([]byte{}, uint64(idx))) + copy(sszData[i*sszLen:(i+1)*sszLen], primitives.MarshalUint64([]byte{}, uint64(idx))) } httputil.WriteSsz(w, sszData) } else { diff --git a/beacon-chain/rpc/eth/beacon/handlers_test.go b/beacon-chain/rpc/eth/beacon/handlers_test.go index f2028d27fa0e..f583dc94dcc3 100644 --- a/beacon-chain/rpc/eth/beacon/handlers_test.go +++ b/beacon-chain/rpc/eth/beacon/handlers_test.go @@ -13,6 +13,12 @@ import ( "time" "github.com/OffchainLabs/go-bitfield" + "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/pkg/errors" + logTest "github.com/sirupsen/logrus/hooks/test" + "github.com/stretchr/testify/mock" + "go.uber.org/mock/gomock" + "github.com/OffchainLabs/prysm/v7/api" "github.com/OffchainLabs/prysm/v7/api/server/structs" "github.com/OffchainLabs/prysm/v7/beacon-chain/blockchain/kzg" @@ -34,6 +40,7 @@ import ( "github.com/OffchainLabs/prysm/v7/consensus-types/primitives" "github.com/OffchainLabs/prysm/v7/crypto/bls" "github.com/OffchainLabs/prysm/v7/encoding/bytesutil" + ssz "github.com/OffchainLabs/prysm/v7/encoding/ssz" "github.com/OffchainLabs/prysm/v7/network/httputil" eth "github.com/OffchainLabs/prysm/v7/proto/prysm/v1alpha1" "github.com/OffchainLabs/prysm/v7/runtime/version" @@ -42,12 +49,6 @@ import ( "github.com/OffchainLabs/prysm/v7/testing/require" "github.com/OffchainLabs/prysm/v7/testing/util" "github.com/OffchainLabs/prysm/v7/time/slots" - "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/pkg/errors" - ssz "github.com/prysmaticlabs/fastssz" - logTest "github.com/sirupsen/logrus/hooks/test" - "github.com/stretchr/testify/mock" - "go.uber.org/mock/gomock" ) // fillGloasBlockTestData populates a Gloas block with non-zero test values for the @@ -4755,7 +4756,7 @@ func TestGetProposerLookahead(t *testing.T) { start := i * validatorIndexSize end := start + validatorIndexSize - idx := ssz.UnmarshallUint64(responseBytes[start:end]) + idx := ssz.UnmarshalUint64(responseBytes[start:end]) recoveredIndices[i] = primitives.ValidatorIndex(idx) } require.DeepEqual(t, lookahead, recoveredIndices) diff --git a/beacon-chain/rpc/eth/light-client/BUILD.bazel b/beacon-chain/rpc/eth/light-client/BUILD.bazel index 1fa3b165e534..e926850fd1d7 100644 --- a/beacon-chain/rpc/eth/light-client/BUILD.bazel +++ b/beacon-chain/rpc/eth/light-client/BUILD.bazel @@ -22,7 +22,6 @@ go_library( "//time/slots:go_default_library", "@com_github_ethereum_go_ethereum//common/hexutil:go_default_library", "@com_github_pkg_errors//:go_default_library", - "@com_github_prysmaticlabs_fastssz//:go_default_library", ], ) @@ -51,7 +50,7 @@ go_test( "//testing/require:go_default_library", "//testing/util:go_default_library", "@com_github_ethereum_go_ethereum//common/hexutil:go_default_library", - "@com_github_prysmaticlabs_fastssz//:go_default_library", + "@com_github_offchainlabs_methodical_ssz//ssz:go_default_library", "@org_golang_google_protobuf//proto:go_default_library", ], ) diff --git a/beacon-chain/rpc/eth/light-client/handlers.go b/beacon-chain/rpc/eth/light-client/handlers.go index 53bccff78d8b..b2badf755128 100644 --- a/beacon-chain/rpc/eth/light-client/handlers.go +++ b/beacon-chain/rpc/eth/light-client/handlers.go @@ -1,9 +1,13 @@ package lightclient import ( + "encoding/binary" "fmt" "net/http" + "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/pkg/errors" + "github.com/OffchainLabs/prysm/v7/api" "github.com/OffchainLabs/prysm/v7/api/server/structs" lightclient "github.com/OffchainLabs/prysm/v7/beacon-chain/light-client" @@ -14,9 +18,6 @@ import ( "github.com/OffchainLabs/prysm/v7/network/httputil" "github.com/OffchainLabs/prysm/v7/runtime/version" "github.com/OffchainLabs/prysm/v7/time/slots" - "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/pkg/errors" - ssz "github.com/prysmaticlabs/fastssz" ) // GetLightClientBootstrap - implements https://github.com/ethereum/beacon-APIs/blob/263f4ed6c263c967f13279c7a9f5629b51c5fc55/apis/beacon/light_client/bootstrap.yaml @@ -129,7 +130,7 @@ func (s *Server) GetLightClientUpdatesByRange(w http.ResponseWriter, req *http.R } var chunkLength []byte - chunkLength = ssz.MarshalUint64(chunkLength, uint64(len(updateSSZ)+4)) + chunkLength = binary.LittleEndian.AppendUint64(chunkLength, uint64(len(updateSSZ)+4)) if _, err := w.Write(chunkLength); err != nil { httputil.HandleError(w, "Could not write chunk length: "+err.Error(), http.StatusInternalServerError) return diff --git a/beacon-chain/rpc/eth/light-client/handlers_test.go b/beacon-chain/rpc/eth/light-client/handlers_test.go index 2d036ed9862e..310ad5404ed8 100644 --- a/beacon-chain/rpc/eth/light-client/handlers_test.go +++ b/beacon-chain/rpc/eth/light-client/handlers_test.go @@ -11,6 +11,10 @@ import ( "strconv" "testing" + "github.com/OffchainLabs/methodical-ssz/ssz" + "github.com/ethereum/go-ethereum/common/hexutil" + "google.golang.org/protobuf/proto" + "github.com/OffchainLabs/prysm/v7/api/server/structs" "github.com/OffchainLabs/prysm/v7/async/event" blockchainTest "github.com/OffchainLabs/prysm/v7/beacon-chain/blockchain/testing" @@ -30,9 +34,6 @@ import ( "github.com/OffchainLabs/prysm/v7/runtime/version" "github.com/OffchainLabs/prysm/v7/testing/require" "github.com/OffchainLabs/prysm/v7/testing/util" - "github.com/ethereum/go-ethereum/common/hexutil" - ssz "github.com/prysmaticlabs/fastssz" - "google.golang.org/protobuf/proto" ) func TestLightClientHandler_GetLightClientBootstrap(t *testing.T) { @@ -309,7 +310,7 @@ func TestLightClientHandler_GetLightClientByRange(t *testing.T) { offset := 0 for i := 0; offset < writer.Body.Len(); i++ { - updateLen := int(ssz.UnmarshallUint64(writer.Body.Bytes()[offset:offset+8]) - 4) + updateLen := int(primitives.UnmarshalUint64(writer.Body.Bytes()[offset:offset+8]) - 4) offset += 12 var resp proto.Message @@ -423,7 +424,7 @@ func TestLightClientHandler_GetLightClientByRange(t *testing.T) { require.Equal(t, http.StatusOK, writer.Code) offset := 0 - updateLen := int(ssz.UnmarshallUint64(writer.Body.Bytes()[offset:offset+8]) - 4) + updateLen := int(primitives.UnmarshalUint64(writer.Body.Bytes()[offset:offset+8]) - 4) offset += 12 var resp proto.Message switch testVersion { @@ -448,7 +449,7 @@ func TestLightClientHandler_GetLightClientByRange(t *testing.T) { require.DeepSSZEqual(t, u0ssz, writer.Body.Bytes()[offset:offset+updateLen]) offset += updateLen - updateLen = int(ssz.UnmarshallUint64(writer.Body.Bytes()[offset:offset+8]) - 4) + updateLen = int(primitives.UnmarshalUint64(writer.Body.Bytes()[offset:offset+8]) - 4) offset += 12 var resp1 proto.Message switch testVersion + 1 { diff --git a/beacon-chain/rpc/prysm/v1alpha1/validator/BUILD.bazel b/beacon-chain/rpc/prysm/v1alpha1/validator/BUILD.bazel index 1e5d89374434..d0c50f151b97 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/validator/BUILD.bazel +++ b/beacon-chain/rpc/prysm/v1alpha1/validator/BUILD.bazel @@ -97,6 +97,7 @@ go_library( "//crypto/hash:go_default_library", "//crypto/rand:go_default_library", "//encoding/bytesutil:go_default_library", + "//encoding/ssz:go_default_library", "//genesis:go_default_library", "//io/logs:go_default_library", "//math:go_default_library", @@ -116,10 +117,10 @@ go_library( "@com_github_ethereum_go_ethereum//common:go_default_library", "@com_github_ethereum_go_ethereum//common/hexutil:go_default_library", "@com_github_golang_protobuf//ptypes/empty", + "@com_github_offchainlabs_methodical_ssz//ssz:go_default_library", "@com_github_pkg_errors//:go_default_library", "@com_github_prometheus_client_golang//prometheus:go_default_library", "@com_github_prometheus_client_golang//prometheus/promauto:go_default_library", - "@com_github_prysmaticlabs_fastssz//:go_default_library", "@com_github_prysmaticlabs_go_bitfield//:go_default_library", "@com_github_sirupsen_logrus//:go_default_library", "@org_golang_google_grpc//codes:go_default_library", @@ -178,6 +179,7 @@ common_deps = [ "//crypto/bls/blst:go_default_library", "//crypto/bls/common:go_default_library", "//encoding/bytesutil:go_default_library", + "//encoding/ssz:go_default_library", "//genesis:go_default_library", "//proto/engine/v1:go_default_library", "//proto/eth/v1:go_default_library", @@ -267,6 +269,5 @@ go_test( embed = [":go_default_library"], deps = common_deps + [ "//proto/prysm/v1alpha1/attestation/aggregation/testing:go_default_library", - "//proto/prysm/wrappers:go_default_library", ], ) diff --git a/beacon-chain/slasher/BUILD.bazel b/beacon-chain/slasher/BUILD.bazel index 42e844c5cf20..8e2d9445044a 100644 --- a/beacon-chain/slasher/BUILD.bazel +++ b/beacon-chain/slasher/BUILD.bazel @@ -46,7 +46,6 @@ go_library( "@com_github_pkg_errors//:go_default_library", "@com_github_prometheus_client_golang//prometheus:go_default_library", "@com_github_prometheus_client_golang//prometheus/promauto:go_default_library", - "@com_github_prysmaticlabs_fastssz//:go_default_library", "@com_github_sirupsen_logrus//:go_default_library", ], ) @@ -88,7 +87,6 @@ go_test( "//testing/require:go_default_library", "//testing/util:go_default_library", "//time/slots:go_default_library", - "@com_github_prysmaticlabs_fastssz//:go_default_library", "@com_github_sirupsen_logrus//:go_default_library", "@com_github_sirupsen_logrus//hooks/test:go_default_library", ], diff --git a/beacon-chain/slasher/params.go b/beacon-chain/slasher/params.go index e8ae28aa5816..bd6b22513bf5 100644 --- a/beacon-chain/slasher/params.go +++ b/beacon-chain/slasher/params.go @@ -1,8 +1,9 @@ package slasher import ( + "encoding/binary" + "github.com/OffchainLabs/prysm/v7/consensus-types/primitives" - ssz "github.com/prysmaticlabs/fastssz" ) // Parameters for slashing detection. @@ -159,7 +160,7 @@ func (p *Parameters) validatorOffset(validatorIndex primitives.ValidatorIndex) u // validatorChunkIndex * width + chunkIndex = 2*4 + 2 = 10 func (p *Parameters) flatSliceID(validatorChunkIndex, chunkIndex uint64) []byte { width := p.historyLength.Div(p.chunkSize) - return ssz.MarshalUint64(make([]byte, 0), uint64(width.Mul(validatorChunkIndex).Add(chunkIndex))) + return binary.LittleEndian.AppendUint64(make([]byte, 0), uint64(width.Mul(validatorChunkIndex).Add(chunkIndex))) } // ValidatorIndexesInChunk Given a validator chunk index, we determine all the validators diff --git a/beacon-chain/slasher/params_test.go b/beacon-chain/slasher/params_test.go index f9c79c66ad14..6f0a7041791a 100644 --- a/beacon-chain/slasher/params_test.go +++ b/beacon-chain/slasher/params_test.go @@ -1,12 +1,12 @@ package slasher import ( + "encoding/binary" "reflect" "testing" "github.com/OffchainLabs/prysm/v7/consensus-types/primitives" "github.com/OffchainLabs/prysm/v7/testing/assert" - ssz "github.com/prysmaticlabs/fastssz" ) func TestDefaultParams(t *testing.T) { @@ -299,7 +299,7 @@ func TestParams_flatSliceID(t *testing.T) { historyLength: tt.fields.historyLength, } got := c.flatSliceID(tt.validatorChunkIndex, tt.chunkIndex) - decoded := ssz.UnmarshallUint64(got) + decoded := binary.LittleEndian.Uint64(got) if decoded != tt.want { t.Errorf("diskKey() = %v, want %v", got, tt.want) } diff --git a/beacon-chain/state/state-native/BUILD.bazel b/beacon-chain/state/state-native/BUILD.bazel index 5bb9c02e6d7f..22f7e6c5edce 100644 --- a/beacon-chain/state/state-native/BUILD.bazel +++ b/beacon-chain/state/state-native/BUILD.bazel @@ -84,10 +84,10 @@ go_library( "//proto/prysm/wrappers:go_default_library", "//runtime/version:go_default_library", "//time/slots:go_default_library", + "@com_github_offchainlabs_methodical_ssz//ssz:go_default_library", "@com_github_pkg_errors//:go_default_library", "@com_github_prometheus_client_golang//prometheus:go_default_library", "@com_github_prometheus_client_golang//prometheus/promauto:go_default_library", - "@com_github_prysmaticlabs_fastssz//:go_default_library", "@com_github_prysmaticlabs_go_bitfield//:go_default_library", "@com_github_sirupsen_logrus//:go_default_library", "@org_golang_google_protobuf//proto:go_default_library", diff --git a/beacon-chain/state/state-native/custom-types/BUILD.bazel b/beacon-chain/state/state-native/custom-types/BUILD.bazel index 4f2423b2965c..472853b4b0ac 100644 --- a/beacon-chain/state/state-native/custom-types/BUILD.bazel +++ b/beacon-chain/state/state-native/custom-types/BUILD.bazel @@ -13,7 +13,7 @@ go_library( visibility = ["//visibility:public"], deps = [ "//config/fieldparams:go_default_library", - "@com_github_prysmaticlabs_fastssz//:go_default_library", + "@com_github_offchainlabs_methodical_ssz//ssz:go_default_library", ], ) diff --git a/beacon-chain/state/state-native/custom-types/block_roots.go b/beacon-chain/state/state-native/custom-types/block_roots.go index adad6ebaaaeb..cf1b06286fe8 100644 --- a/beacon-chain/state/state-native/custom-types/block_roots.go +++ b/beacon-chain/state/state-native/custom-types/block_roots.go @@ -3,24 +3,25 @@ package customtypes import ( "fmt" + "github.com/OffchainLabs/methodical-ssz/ssz" + fieldparams "github.com/OffchainLabs/prysm/v7/config/fieldparams" - fssz "github.com/prysmaticlabs/fastssz" ) -var _ fssz.HashRoot = (BlockRoots)([][32]byte{}) -var _ fssz.Marshaler = (*BlockRoots)(nil) -var _ fssz.Unmarshaler = (*BlockRoots)(nil) +var _ ssz.HashRoot = (BlockRoots)([][32]byte{}) +var _ ssz.Marshaler = (*BlockRoots)(nil) +var _ ssz.Unmarshaler = (*BlockRoots)(nil) // BlockRoots represents block roots of the beacon state. type BlockRoots [][32]byte // HashTreeRoot returns calculated hash root. func (r BlockRoots) HashTreeRoot() ([32]byte, error) { - return fssz.HashWithDefaultHasher(r) + return ssz.HashWithDefaultHasher(r) } // HashTreeRootWith hashes a BlockRoots object with a Hasher from the default HasherPool. -func (r BlockRoots) HashTreeRootWith(hh *fssz.Hasher) error { +func (r BlockRoots) HashTreeRootWith(hh *ssz.Hasher) error { index := hh.Index() for _, sRoot := range r { hh.Append(sRoot[:]) diff --git a/beacon-chain/state/state-native/custom-types/historical_roots.go b/beacon-chain/state/state-native/custom-types/historical_roots.go index 0f132e42020d..b399fcc74ebd 100644 --- a/beacon-chain/state/state-native/custom-types/historical_roots.go +++ b/beacon-chain/state/state-native/custom-types/historical_roots.go @@ -3,23 +3,23 @@ package customtypes import ( "fmt" - fssz "github.com/prysmaticlabs/fastssz" + "github.com/OffchainLabs/methodical-ssz/ssz" ) -var _ fssz.HashRoot = (HistoricalRoots)([][32]byte{}) -var _ fssz.Marshaler = (*HistoricalRoots)(nil) -var _ fssz.Unmarshaler = (*HistoricalRoots)(nil) +var _ ssz.HashRoot = (HistoricalRoots)([][32]byte{}) +var _ ssz.Marshaler = (*HistoricalRoots)(nil) +var _ ssz.Unmarshaler = (*HistoricalRoots)(nil) // HistoricalRoots represents a 32 bytes HistoricalRoots object in Ethereum beacon chain consensus. type HistoricalRoots [][32]byte // HashTreeRoot returns calculated hash root. func (r HistoricalRoots) HashTreeRoot() ([32]byte, error) { - return fssz.HashWithDefaultHasher(r) + return ssz.HashWithDefaultHasher(r) } // HashTreeRootWith hashes a HistoricalRoots object with a Hasher from the default HasherPool. -func (r HistoricalRoots) HashTreeRootWith(hh *fssz.Hasher) error { +func (r HistoricalRoots) HashTreeRootWith(hh *ssz.Hasher) error { index := hh.Index() for _, sRoot := range r { hh.Append(sRoot[:]) diff --git a/beacon-chain/state/state-native/custom-types/randao_mixes.go b/beacon-chain/state/state-native/custom-types/randao_mixes.go index 8262b5835e11..3d262ef63788 100644 --- a/beacon-chain/state/state-native/custom-types/randao_mixes.go +++ b/beacon-chain/state/state-native/custom-types/randao_mixes.go @@ -3,24 +3,25 @@ package customtypes import ( "fmt" + "github.com/OffchainLabs/methodical-ssz/ssz" + fieldparams "github.com/OffchainLabs/prysm/v7/config/fieldparams" - fssz "github.com/prysmaticlabs/fastssz" ) -var _ fssz.HashRoot = (RandaoMixes)([][32]byte{}) -var _ fssz.Marshaler = (*RandaoMixes)(nil) -var _ fssz.Unmarshaler = (*RandaoMixes)(nil) +var _ ssz.HashRoot = (RandaoMixes)([][32]byte{}) +var _ ssz.Marshaler = (*RandaoMixes)(nil) +var _ ssz.Unmarshaler = (*RandaoMixes)(nil) // RandaoMixes represents RANDAO mixes of the beacon state. type RandaoMixes [][32]byte // HashTreeRoot returns calculated hash root. func (r RandaoMixes) HashTreeRoot() ([32]byte, error) { - return fssz.HashWithDefaultHasher(r) + return ssz.HashWithDefaultHasher(r) } // HashTreeRootWith hashes a RandaoMixes object with a Hasher from the default HasherPool. -func (r RandaoMixes) HashTreeRootWith(hh *fssz.Hasher) error { +func (r RandaoMixes) HashTreeRootWith(hh *ssz.Hasher) error { index := hh.Index() for _, sRoot := range r { hh.Append(sRoot[:]) diff --git a/beacon-chain/state/state-native/custom-types/state_roots.go b/beacon-chain/state/state-native/custom-types/state_roots.go index b10010682d5e..edb74deaadad 100644 --- a/beacon-chain/state/state-native/custom-types/state_roots.go +++ b/beacon-chain/state/state-native/custom-types/state_roots.go @@ -3,24 +3,25 @@ package customtypes import ( "fmt" + "github.com/OffchainLabs/methodical-ssz/ssz" + fieldparams "github.com/OffchainLabs/prysm/v7/config/fieldparams" - fssz "github.com/prysmaticlabs/fastssz" ) -var _ fssz.HashRoot = (StateRoots)([][32]byte{}) -var _ fssz.Marshaler = (*StateRoots)(nil) -var _ fssz.Unmarshaler = (*StateRoots)(nil) +var _ ssz.HashRoot = (StateRoots)([][32]byte{}) +var _ ssz.Marshaler = (*StateRoots)(nil) +var _ ssz.Unmarshaler = (*StateRoots)(nil) // StateRoots represents block roots of the beacon state. type StateRoots [][32]byte // HashTreeRoot returns calculated hash root. func (r StateRoots) HashTreeRoot() ([32]byte, error) { - return fssz.HashWithDefaultHasher(r) + return ssz.HashWithDefaultHasher(r) } // HashTreeRootWith hashes a StateRoots object with a Hasher from the default HasherPool. -func (r StateRoots) HashTreeRootWith(hh *fssz.Hasher) error { +func (r StateRoots) HashTreeRootWith(hh *ssz.Hasher) error { index := hh.Index() for _, sRoot := range r { hh.Append(sRoot[:]) diff --git a/beacon-chain/state/state-native/ssz.go b/beacon-chain/state/state-native/ssz.go index e7fe76cc78f1..7cc47e789534 100644 --- a/beacon-chain/state/state-native/ssz.go +++ b/beacon-chain/state/state-native/ssz.go @@ -1,8 +1,8 @@ package state_native import ( + "github.com/OffchainLabs/methodical-ssz/ssz" "github.com/pkg/errors" - ssz "github.com/prysmaticlabs/fastssz" ) var errAssertionFailed = errors.New("failed to convert interface to proto state") diff --git a/beacon-chain/sync/BUILD.bazel b/beacon-chain/sync/BUILD.bazel index 1b84ac810508..13ea625812a4 100644 --- a/beacon-chain/sync/BUILD.bazel +++ b/beacon-chain/sync/BUILD.bazel @@ -162,11 +162,11 @@ go_library( "@com_github_libp2p_go_libp2p//core/protocol:go_default_library", "@com_github_libp2p_go_libp2p_pubsub//:go_default_library", "@com_github_libp2p_go_mplex//:go_default_library", + "@com_github_offchainlabs_methodical_ssz//ssz:go_default_library", "@com_github_patrickmn_go_cache//:go_default_library", "@com_github_pkg_errors//:go_default_library", "@com_github_prometheus_client_golang//prometheus:go_default_library", "@com_github_prometheus_client_golang//prometheus/promauto:go_default_library", - "@com_github_prysmaticlabs_fastssz//:go_default_library", "@com_github_prysmaticlabs_go_bitfield//:go_default_library", "@com_github_sirupsen_logrus//:go_default_library", "@com_github_trailofbits_go_mutexasserts//:go_default_library", @@ -333,11 +333,11 @@ go_test( "@com_github_libp2p_go_libp2p//p2p/transport/quic:go_default_library", "@com_github_libp2p_go_libp2p_pubsub//:go_default_library", "@com_github_libp2p_go_libp2p_pubsub//pb:go_default_library", + "@com_github_offchainlabs_methodical_ssz//ssz:go_default_library", "@com_github_patrickmn_go_cache//:go_default_library", "@com_github_pkg_errors//:go_default_library", "@com_github_prometheus_client_golang//prometheus:go_default_library", "@com_github_prometheus_client_model//go:go_default_library", - "@com_github_prysmaticlabs_fastssz//:go_default_library", "@com_github_prysmaticlabs_go_bitfield//:go_default_library", "@com_github_sirupsen_logrus//:go_default_library", "@com_github_sirupsen_logrus//hooks/test:go_default_library", diff --git a/beacon-chain/sync/decode_pubsub.go b/beacon-chain/sync/decode_pubsub.go index 7d9ff2b0f061..ff5194fa912e 100644 --- a/beacon-chain/sync/decode_pubsub.go +++ b/beacon-chain/sync/decode_pubsub.go @@ -4,6 +4,10 @@ import ( "reflect" "strings" + "github.com/OffchainLabs/methodical-ssz/ssz" + pubsub "github.com/libp2p/go-libp2p-pubsub" + "github.com/pkg/errors" + "github.com/OffchainLabs/prysm/v7/beacon-chain/blockchain" "github.com/OffchainLabs/prysm/v7/beacon-chain/p2p" "github.com/OffchainLabs/prysm/v7/beacon-chain/p2p/types" @@ -11,9 +15,6 @@ import ( "github.com/OffchainLabs/prysm/v7/config/params" "github.com/OffchainLabs/prysm/v7/encoding/bytesutil" ethpb "github.com/OffchainLabs/prysm/v7/proto/prysm/v1alpha1" - pubsub "github.com/libp2p/go-libp2p-pubsub" - "github.com/pkg/errors" - ssz "github.com/prysmaticlabs/fastssz" ) var errNilPubsubMessage = errors.New("nil pubsub message") diff --git a/beacon-chain/sync/rpc.go b/beacon-chain/sync/rpc.go index 3f2ff84d5943..8d360bb3d093 100644 --- a/beacon-chain/sync/rpc.go +++ b/beacon-chain/sync/rpc.go @@ -7,6 +7,12 @@ import ( "strings" "time" + "github.com/OffchainLabs/methodical-ssz/ssz" + libp2pcore "github.com/libp2p/go-libp2p/core" + "github.com/libp2p/go-libp2p/core/network" + "github.com/pkg/errors" + "github.com/sirupsen/logrus" + "github.com/OffchainLabs/prysm/v7/beacon-chain/p2p" p2ptypes "github.com/OffchainLabs/prysm/v7/beacon-chain/p2p/types" "github.com/OffchainLabs/prysm/v7/config/features" @@ -14,11 +20,6 @@ import ( "github.com/OffchainLabs/prysm/v7/monitoring/tracing" "github.com/OffchainLabs/prysm/v7/monitoring/tracing/trace" "github.com/OffchainLabs/prysm/v7/runtime/version" - libp2pcore "github.com/libp2p/go-libp2p/core" - "github.com/libp2p/go-libp2p/core/network" - "github.com/pkg/errors" - ssz "github.com/prysmaticlabs/fastssz" - "github.com/sirupsen/logrus" ) var ( diff --git a/beacon-chain/sync/rpc_status.go b/beacon-chain/sync/rpc_status.go index 9ba8dfb4c0e3..40a7f22da4f8 100644 --- a/beacon-chain/sync/rpc_status.go +++ b/beacon-chain/sync/rpc_status.go @@ -6,6 +6,13 @@ import ( "fmt" "sync" + ssz "github.com/OffchainLabs/methodical-ssz/ssz" + libp2pcore "github.com/libp2p/go-libp2p/core" + "github.com/libp2p/go-libp2p/core/network" + "github.com/libp2p/go-libp2p/core/peer" + "github.com/pkg/errors" + "github.com/sirupsen/logrus" + "github.com/OffchainLabs/prysm/v7/async" "github.com/OffchainLabs/prysm/v7/beacon-chain/p2p" "github.com/OffchainLabs/prysm/v7/beacon-chain/p2p/peers" @@ -18,12 +25,6 @@ import ( pb "github.com/OffchainLabs/prysm/v7/proto/prysm/v1alpha1" prysmTime "github.com/OffchainLabs/prysm/v7/time" "github.com/OffchainLabs/prysm/v7/time/slots" - libp2pcore "github.com/libp2p/go-libp2p/core" - "github.com/libp2p/go-libp2p/core/network" - "github.com/libp2p/go-libp2p/core/peer" - "github.com/pkg/errors" - ssz "github.com/prysmaticlabs/fastssz" - "github.com/sirupsen/logrus" ) const maxFutureStatusHeadSlot = 1 diff --git a/beacon-chain/sync/validate_data_column_gloas_test.go b/beacon-chain/sync/validate_data_column_gloas_test.go index 384e6f3c902c..a8d826813d6d 100644 --- a/beacon-chain/sync/validate_data_column_gloas_test.go +++ b/beacon-chain/sync/validate_data_column_gloas_test.go @@ -8,6 +8,11 @@ import ( "testing" "time" + ssz "github.com/OffchainLabs/methodical-ssz/ssz" + pubsub "github.com/libp2p/go-libp2p-pubsub" + pb "github.com/libp2p/go-libp2p-pubsub/pb" + "github.com/libp2p/go-libp2p/core/peer" + "github.com/OffchainLabs/prysm/v7/beacon-chain/blockchain/kzg" mock "github.com/OffchainLabs/prysm/v7/beacon-chain/blockchain/testing" "github.com/OffchainLabs/prysm/v7/beacon-chain/core/feed" @@ -29,10 +34,6 @@ import ( ethpb "github.com/OffchainLabs/prysm/v7/proto/prysm/v1alpha1" "github.com/OffchainLabs/prysm/v7/testing/require" "github.com/OffchainLabs/prysm/v7/testing/util" - pubsub "github.com/libp2p/go-libp2p-pubsub" - pb "github.com/libp2p/go-libp2p-pubsub/pb" - "github.com/libp2p/go-libp2p/core/peer" - ssz "github.com/prysmaticlabs/fastssz" ) func gloasFixture(t *testing.T) (*ethpb.DataColumnSidecarGloas, interfaces.ReadOnlySignedBeaconBlock) { diff --git a/beacon-chain/sync/validate_data_column_test.go b/beacon-chain/sync/validate_data_column_test.go index 877c4c639e4e..5aa775ecbfe6 100644 --- a/beacon-chain/sync/validate_data_column_test.go +++ b/beacon-chain/sync/validate_data_column_test.go @@ -6,6 +6,11 @@ import ( "testing" "time" + ssz "github.com/OffchainLabs/methodical-ssz/ssz" + pubsub "github.com/libp2p/go-libp2p-pubsub" + pb "github.com/libp2p/go-libp2p-pubsub/pb" + "github.com/pkg/errors" + "github.com/OffchainLabs/prysm/v7/beacon-chain/blockchain/kzg" mock "github.com/OffchainLabs/prysm/v7/beacon-chain/blockchain/testing" "github.com/OffchainLabs/prysm/v7/beacon-chain/core/peerdas" @@ -20,10 +25,6 @@ import ( ethpb "github.com/OffchainLabs/prysm/v7/proto/prysm/v1alpha1" "github.com/OffchainLabs/prysm/v7/testing/require" "github.com/OffchainLabs/prysm/v7/testing/util" - pubsub "github.com/libp2p/go-libp2p-pubsub" - pb "github.com/libp2p/go-libp2p-pubsub/pb" - "github.com/pkg/errors" - ssz "github.com/prysmaticlabs/fastssz" ) func TestValidateDataColumn(t *testing.T) { diff --git a/build/gen/BUILD.bazel b/build/gen/BUILD.bazel index cc4e5c087bb0..6dc39216aed0 100644 --- a/build/gen/BUILD.bazel +++ b/build/gen/BUILD.bazel @@ -36,7 +36,6 @@ go_test( "bazel_test.go", "cache_test.go", "proto_test.go", - "ssz_test.go", ], embed = [":go_default_library"], deps = [ diff --git a/build/gen/bazel.go b/build/gen/bazel.go index 1e3d1eb623d4..153fab0b9925 100644 --- a/build/gen/bazel.go +++ b/build/gen/bazel.go @@ -6,7 +6,7 @@ package main // - proto/ssz_proto_library.bzl -> the mainnet/minimal SSZ substitution dicts // - proto/**/BUILD.bazel -> the proto package list + plugin mode // (go_proto_library) and the SSZ targets -// (ssz_gen_marshal) +// (ssz_methodical) // // Nothing else in build/gen hardcodes this config. When Bazel is eventually // removed, only this file needs to change. @@ -56,51 +56,6 @@ func topLevelAssignments(f *build.File) map[string]build.Expr { return env } -// evalStringList resolves an expression to a flat slice of strings. -func evalStringList(e build.Expr, env map[string]build.Expr) ([]string, error) { - switch v := e.(type) { - case *build.StringExpr: - return []string{v.Value}, nil - case *build.ListExpr: - var out []string - for _, item := range v.List { - sub, err := evalStringList(item, env) - if err != nil { - return nil, fmt.Errorf("list item: %w", err) - } - - out = append(out, sub...) - } - - return out, nil - case *build.Ident: - ref, ok := env[v.Name] - if !ok { - return nil, fmt.Errorf("unresolved identifier %q", v.Name) - } - - return evalStringList(ref, env) - case *build.BinaryExpr: - if v.Op != "+" { - return nil, fmt.Errorf("unsupported binary op %q", v.Op) - } - - left, err := evalStringList(v.X, env) - if err != nil { - return nil, fmt.Errorf("left side of +: %w", err) - } - - right, err := evalStringList(v.Y, env) - if err != nil { - return nil, fmt.Errorf("right side of +: %w", err) - } - - return append(left, right...), nil - default: - return nil, fmt.Errorf("unsupported expression %T", e) - } -} - // loadSSZDicts returns the mainnet and minimal SSZ-size substitution maps. func loadSSZDicts() (mainnet, minimal map[string]string, err error) { f, err := parseBazel(sszProtoLibraryBzl) @@ -227,103 +182,57 @@ func compilerMode(r *build.Rule) string { return modeStock } -// loadSSZTargets returns the SSZ generation targets read from the -// ssz_gen_marshal rules across proto/**/BUILD.bazel, in (sorted path, file) +// methodicalTarget describes one ssz_methodical rule: the config file and +// output file (both relative to the proto package dir) plus an optional +// generated-package-name override. +type methodicalTarget struct { + pkg string // proto package dir, e.g. "proto/prysm/v1alpha1" + configFile string // config_file attr, relative to pkg + out string // out attr, relative to pkg + overridePkg string // override_package_name attr, "" if unset +} + +// loadMethodicalTargets returns the SSZ generation targets read from the +// ssz_methodical rules across proto/**/BUILD.bazel, in (sorted path, file) // order. -func loadSSZTargets() ([]sszTarget, error) { +func loadMethodicalTargets() ([]methodicalTarget, error) { files, err := buildBazelFiles() if err != nil { return nil, fmt.Errorf("build bazel files: %w", err) } - var targets []sszTarget + var targets []methodicalTarget for _, path := range files { f, err := parseBazel(path) if err != nil { return nil, fmt.Errorf("parse bazel: %w", err) } - rules := f.Rules("ssz_gen_marshal") + rules := f.Rules("ssz_methodical") if len(rules) == 0 { continue } - env := topLevelAssignments(f) pkg := filepath.ToSlash(filepath.Dir(path)) for _, r := range rules { - t, err := sszTargetFromRule(r, env, pkg) - if err != nil { - return nil, fmt.Errorf("%s: %s: %w", path, r.Name(), err) + cfg := r.AttrString("config_file") + if cfg == "" { + return nil, fmt.Errorf("%s: %s: missing config_file", path, r.Name()) } - targets = append(targets, t) - } - } - - return targets, nil -} - -// sszTargetFromRule converts a single ssz_gen_marshal rule into an sszTarget. -func sszTargetFromRule(r *build.Rule, env map[string]build.Expr, pkg string) (sszTarget, error) { - out := r.AttrString("out") - if out == "" { - return sszTarget{}, fmt.Errorf("missing out") - } - - objs, err := attrStringList(r, env, "objs") - if err != nil { - return sszTarget{}, fmt.Errorf("objs: %w", err) - } - - exclude, err := attrStringList(r, env, "exclude_objs") - if err != nil { - return sszTarget{}, fmt.Errorf("exclude_objs: %w", err) - } - - includes, err := attrStringList(r, env, "includes") - if err != nil { - return sszTarget{}, fmt.Errorf("includes: %w", err) - } - - libInc, protoInc := splitIncludes(includes) - - return sszTarget{ - pkg: pkg, - out: out, - libInc: libInc, - protoInc: protoInc, - objs: objs, - exclude: exclude, - }, nil -} - -// attrStringList resolves a rule attribute to a string slice, or nil if absent. -func attrStringList(r *build.Rule, env map[string]build.Expr, key string) ([]string, error) { - e := r.Attr(key) - if e == nil { - return nil, nil - } - - return evalStringList(e, env) -} - -// splitIncludes maps Bazel include labels (e.g. "//math:go_default_library") to -// the two buckets the sszgen invocation expects: proto packages (whose .pb.go -// must be staged) and plain Go library import paths. -func splitIncludes(labels []string) (libInc, protoInc []string) { - for _, l := range labels { - path := strings.TrimPrefix(l, "//") - if i := strings.IndexByte(path, ':'); i >= 0 { - path = path[:i] - } + out := r.AttrString("out") + if out == "" { + return nil, fmt.Errorf("%s: %s: missing out", path, r.Name()) + } - if strings.HasPrefix(path, "proto/") { - protoInc = append(protoInc, path) - continue + targets = append(targets, methodicalTarget{ + pkg: pkg, + configFile: cfg, + out: out, + overridePkg: r.AttrString("override_package_name"), + }) } - - libInc = append(libInc, path) } - return libInc, protoInc + return targets, nil } diff --git a/build/gen/bazel_test.go b/build/gen/bazel_test.go index da7ddbb95c50..e2078b4ad472 100644 --- a/build/gen/bazel_test.go +++ b/build/gen/bazel_test.go @@ -73,60 +73,6 @@ mapping = {"k": "v"} }) } -func TestEvalStringList(t *testing.T) { - // exprOf parses `name = ` and returns the RHS expression plus the - // surrounding env, so identifiers can be resolved against sibling bindings. - exprOf := func(t *testing.T, src string) (build.Expr, map[string]build.Expr) { - t.Helper() - env := topLevelAssignments(parseContent(t, src)) - e, ok := env["target"] - require.Equal(t, true, ok) - - return e, env - } - - t.Run("resolves a single string", func(t *testing.T) { - e, env := exprOf(t, `target = "a"`) - got, err := evalStringList(e, env) - require.NoError(t, err) - require.DeepEqual(t, []string{"a"}, got) - }) - - t.Run("flattens a flat list", func(t *testing.T) { - e, env := exprOf(t, `target = ["a", "b", "c"]`) - got, err := evalStringList(e, env) - require.NoError(t, err) - require.DeepEqual(t, []string{"a", "b", "c"}, got) - }) - - t.Run("resolves an identifier reference", func(t *testing.T) { - e, env := exprOf(t, ` - base = ["a", "b"] - target = base - `) - got, err := evalStringList(e, env) - require.NoError(t, err) - require.DeepEqual(t, []string{"a", "b"}, got) - }) - - t.Run("concatenates with the + operator", func(t *testing.T) { - e, env := exprOf(t, ` - base = ["a"] - target = base + ["b"] + ["c"] - `) - got, err := evalStringList(e, env) - require.NoError(t, err) - require.DeepEqual(t, []string{"a", "b", "c"}, got) - }) - - t.Run("errors on an unsupported expression kind", func(t *testing.T) { - e, env := exprOf(t, `target = 42`) - got, err := evalStringList(e, env) - require.IsNil(t, got) - require.ErrorContains(t, "unsupported expression", err) - }) -} - func TestLoadSSZDicts(t *testing.T) { // writeSSZBzl creates proto/ssz_proto_library.bzl under a temp dir and // chdirs into it, so loadSSZDicts resolves its fixed relative path there. @@ -258,7 +204,7 @@ func TestCompilerMode(t *testing.T) { require.Equal(t, modeCastGRPC, compilerMode(rules[0])) } -func TestLoadSSZTargets(t *testing.T) { +func TestLoadMethodicalTargets(t *testing.T) { // writeBuild writes proto//BUILD.bazel with the given content under dir. writeBuild := func(t *testing.T, dir, pkg, content string) { t.Helper() @@ -270,52 +216,51 @@ func TestLoadSSZTargets(t *testing.T) { dir := t.TempDir() // "bbb" is written first but must sort after "aaa". writeBuild(t, dir, "bbb", ` -ssz_gen_marshal( - name = "ssz_b", +ssz_methodical( + name = "methodical_b", + deps = [":go_proto"], + config_file = "b.yaml", out = "b.ssz.go", - objs = ["B"], ) `) - // "aaa" holds two rules; both must appear, in file order. + // "aaa" holds two rules; both must appear, in file order. The second omits + // override_package_name to exercise the optional attr. writeBuild(t, dir, "aaa", ` -COMMON = ["//math:go_default_library"] -ssz_gen_marshal( - name = "ssz_a1", +ssz_methodical( + name = "methodical_a1", + deps = [":go_proto"], + config_file = "a1.yaml", + override_package_name = "eth", out = "a1.ssz.go", - objs = ["A1"], - exclude_objs = ["Skip"], - includes = COMMON + ["//proto/eth:go_default_library"], ) -ssz_gen_marshal( - name = "ssz_a2", +ssz_methodical( + name = "methodical_a2", + config_file = "a2.yaml", out = "a2.ssz.go", - objs = ["A2"], ) `) - // No ssz_gen_marshal rule -> skipped entirely. + // No ssz_methodical rule -> skipped entirely. writeBuild(t, dir, "ccc", `go_library(name = "go_default_library")`) t.Chdir(dir) - got, err := loadSSZTargets() + got, err := loadMethodicalTargets() require.NoError(t, err) - require.DeepEqual(t, []sszTarget{ + require.DeepEqual(t, []methodicalTarget{ { - pkg: "proto/aaa", - out: "a1.ssz.go", - libInc: []string{"math"}, - protoInc: []string{"proto/eth"}, - objs: []string{"A1"}, - exclude: []string{"Skip"}, + pkg: "proto/aaa", + configFile: "a1.yaml", + out: "a1.ssz.go", + overridePkg: "eth", }, { - pkg: "proto/aaa", - out: "a2.ssz.go", - objs: []string{"A2"}, + pkg: "proto/aaa", + configFile: "a2.yaml", + out: "a2.ssz.go", }, { - pkg: "proto/bbb", - out: "b.ssz.go", - objs: []string{"B"}, + pkg: "proto/bbb", + configFile: "b.yaml", + out: "b.ssz.go", }, }, got) } diff --git a/build/gen/cache.go b/build/gen/cache.go index 01f7231b4bcd..73c21aa93e27 100644 --- a/build/gen/cache.go +++ b/build/gen/cache.go @@ -179,9 +179,9 @@ func protoFiles() ([]string, error) { } func sszFiles() ([]string, error) { - targets, err := loadSSZTargets() + targets, err := loadMethodicalTargets() if err != nil { - return nil, fmt.Errorf("loadSSZTargets: %w", err) + return nil, fmt.Errorf("loadMethodicalTargets: %w", err) } bzl, err := buildBazelFiles() @@ -191,15 +191,14 @@ func sszFiles() ([]string, error) { files := slices.Clone(bzl) for _, target := range targets { - for _, dir := range append([]string{target.pkg}, target.protoInc...) { - pbs, err := pbgoFiles(dir) - if err != nil { - return nil, fmt.Errorf("pbgoFiles %s: %w", dir, err) - } - - files = append(files, pbs...) + pbs, err := pbgoFiles(target.pkg) + if err != nil { + return nil, fmt.Errorf("pbgoFiles %s: %w", target.pkg, err) } + files = append(files, pbs...) + files = append(files, filepath.ToSlash(filepath.Join(target.pkg, target.configFile))) + out := filepath.ToSlash(filepath.Join(target.pkg, target.out)) minOut := strings.TrimSuffix(out, ".ssz.go") + ".minimal.ssz.go" files = append(files, out, minOut) diff --git a/build/gen/cache_test.go b/build/gen/cache_test.go index c6407156ff25..8f2db7b24be1 100644 --- a/build/gen/cache_test.go +++ b/build/gen/cache_test.go @@ -140,11 +140,12 @@ func TestSpecificFiles(t *testing.T) { t.Run("ssz delegates to sszFiles", func(t *testing.T) { writeRepo(t, map[string]string{ "proto/foo/service.pb.go": "package foo\n", + "proto/foo/gateway.yaml": "package: foo\n", "proto/foo/BUILD.bazel": ` - ssz_gen_marshal( - name = "ssz_foo", + ssz_methodical( + name = "methodical_foo", + config_file = "gateway.yaml", out = "x.ssz.go", - objs = ["X"], ) `, }) diff --git a/build/gen/proto.go b/build/gen/proto.go index 09b40eec6cd9..8ec01604e934 100644 --- a/build/gen/proto.go +++ b/build/gen/proto.go @@ -41,16 +41,6 @@ const ( modeStock = "stock" ) -// typeDiffering lists the generated *.pb.go whose Go -// field TYPE differs between mainnet and minimal. -var typeDiffering = map[string]bool{ - "proto/prysm/v1alpha1/attestation.pb.go": true, - "proto/prysm/v1alpha1/sync_committee.pb.go": true, - "proto/prysm/v1alpha1/beacon_core_types.pb.go": true, - "proto/prysm/v1alpha1/gloas.pb.go": true, - "proto/eth/v1/beacon_block.pb.go": true, -} - func protoPkgDirs(pkgs map[string]string) []string { dirs := make([]string, 0, len(pkgs)) for dir := range pkgs { @@ -99,9 +89,15 @@ func genProto() error { return fmt.Errorf("generate minimal: %w", err) } - // Write each mainnet *.pb.go back to its source-relative path: - // - untagged for config-invariant protos - // - //go:build !minimal file plus a .minimal.pb.go twin for the type-differing ones. + // Write each mainnet *.pb.go back to its source-relative path. When the + // mainnet and minimal generated code is byte-identical the proto is + // config-invariant and is written once, untagged. When they differ -- a + // field's Go type changed (e.g. Bitvector512 vs Bitvector32) or an + // ssz-size/ssz-max struct tag changed with the network -- the file is split + // into a //go:build !minimal file plus a .minimal.pb.go twin. Keeping + // both variants in the tree lets the SSZ generator read the correct sizes + // for each network via -tags minimal, and lets `go build -tags minimal` + // select the right sources with no build-time codegen. err = filepath.WalkDir(outMain, func(path string, d os.DirEntry, err error) error { if err != nil || d.IsDir() || !strings.HasSuffix(path, ".pb.go") { return err @@ -113,7 +109,18 @@ func genProto() error { } rel = filepath.ToSlash(rel) - if !typeDiffering[rel] { + mainData, err := os.ReadFile(path) // #nosec G304 -- path is under our own temp out dir + if err != nil { + return fmt.Errorf("readFile: %w", err) + } + + minPath := filepath.Join(outMin, rel) + minData, err := os.ReadFile(minPath) // #nosec G304 -- minPath is under our own temp out dir + if err != nil { + return fmt.Errorf("readFile: %w", err) + } + + if bytes.Equal(mainData, minData) { return copyFile(path, rel) } @@ -123,7 +130,7 @@ func genProto() error { minTwin := strings.TrimSuffix(rel, ".pb.go") + ".minimal.pb.go" - if err := writeTagged("minimal", filepath.Join(outMin, rel), minTwin); err != nil { + if err := writeTagged("minimal", minPath, minTwin); err != nil { return fmt.Errorf("writeTagged: %w", err) } @@ -170,36 +177,6 @@ func applyGenModes(root string) error { }) } -func emitMinimalPbgo(dir string) error { - _, minimal, err := loadSSZDicts() - if err != nil { - return fmt.Errorf("load SSZ dicts: %w", err) - } - - pkgs, err := loadProtoPkgs() - if err != nil { - return fmt.Errorf("load proto pkgs: %w", err) - } - - tmpRoot, err := os.MkdirTemp("", "gen-minpb-") - if err != nil { - return fmt.Errorf("mkdirTemp: %w", err) - } - defer func() { _ = os.RemoveAll(tmpRoot) }() - - googleapisInc, err := fetchGoogleapis(filepath.Join(tmpRoot, "googleapis")) - if err != nil { - return fmt.Errorf("fetch googleapis: %w", err) - } - - binDir, err := buildProtoPlugins(tmpRoot) - if err != nil { - return fmt.Errorf("build proto plugins: %w", err) - } - - return generateNetwork(minimal, dir, binDir, googleapisInc, pkgs) -} - func fetchGoogleapis(dest string) (string, error) { url := fmt.Sprintf("https://github.com/googleapis/googleapis/archive/%s.zip", googleapisPin) diff --git a/build/gen/ssz.go b/build/gen/ssz.go index 1e0bb2c34e5f..bf0513a1286a 100644 --- a/build/gen/ssz.go +++ b/build/gen/ssz.go @@ -4,96 +4,100 @@ import ( "fmt" "os" "path/filepath" - "slices" + "strconv" "strings" ) -type sszTarget struct { - pkg, out string - libInc []string - protoInc []string - objs []string - exclude []string -} - +// genSSZ runs the methodical SSZ generator for every ssz_methodical target +// declared across proto/**/BUILD.bazel. +// +// The Bazel ssz_methodical rule (see //tools:methodical.bzl) hands methodical a +// pre-built package inventory through the genception GOPACKAGESDRIVER because +// the go toolchain is not usable inside the Bazel sandbox. Here we run outside +// any sandbox, so methodical's golang.org/x/tools/go/packages loads resolve +// against the real module via the standard `go list` driver -- none of the +// genception plumbing (custom driver, JSON inventory, .pb.go staging) is +// needed. methodical loads the package named by the config file's `package:` +// field straight from the module. +// +// Each target is generated twice: once for mainnet (default build tags) and +// once for minimal (--build-tags=minimal, which makes methodical's package +// loader pick up the //go:build minimal .pb.go sources written by `make gen +// proto`), and always written as a //go:build !minimal file plus a +// .minimal.ssz.go twin. This requires `make gen proto` to have run first +// so both .pb.go variants are on disk. func genSSZ() error { - targets, err := loadSSZTargets() - if err != nil { - return fmt.Errorf("load SSZ targets: %w", err) - } - - minPb, err := os.MkdirTemp("", "gen-minpb-") + targets, err := loadMethodicalTargets() if err != nil { - return fmt.Errorf("mkdirTemp: %w", err) + return fmt.Errorf("load methodical targets: %w", err) } - defer func() { _ = os.RemoveAll(minPb) }() - if err := emitMinimalPbgo(minPb); err != nil { - return fmt.Errorf("emit minimal pb.go: %w", err) + // Progressive merkleization is gated OFF by default so that generated + // hash_tree_root values match the current (non-progressive) spectest + // fixtures. This mirrors the //tools:disable_progressive_merkleization + // default set in .bazelrc. Set SSZ_PROGRESSIVE=1 to generate the + // progressive form once upstream fixtures move to it. + progressive, _ := strconv.ParseBool(os.Getenv("SSZ_PROGRESSIVE")) + if progressive { + fmt.Println("SSZ_PROGRESSIVE=1: generating with progressive merkleization ON") } - for _, target := range targets { - if err := genSSZTarget(target, minPb); err != nil { - return fmt.Errorf("gen SSZ target: %w", err) + for _, t := range targets { + if err := genMethodical(t, !progressive); err != nil { + return fmt.Errorf("gen methodical %s/%s: %w", t.pkg, t.out, err) } } return nil } -func genSSZTarget(t sszTarget, minPb string) error { - fmt.Printf("generating %s/%s\n", t.pkg, t.out) - - mainnet, err := sszgenOne(t, "") +// genMethodical generates a single target for both networks and always writes a +// build-tagged mainnet/minimal pair. +// +// We deliberately do not collapse to one untagged file when the two outputs +// match. Whether a target differs across networks depends on the progressive +// flag (progressive collections merkleize size-independently, so a target that +// differs under bounded merkleization can become identical under progressive) +// and on the bounded sizes themselves. A compare-and-collapse would make the +// .minimal.ssz.go twins appear and disappear as those inputs change; we accept +// the duplication of an identical twin to keep the generated file set stable. +func genMethodical(t methodicalTarget, disableProgressive bool) error { + out := filepath.Join(t.pkg, t.out) + fmt.Printf("generating %s\n", out) + + // methodical stamps the //go:build header itself (--go-build-constraint), so + // both this harness and the Bazel ssz_methodical rule produce byte-identical + // files. The mainnet variant loads the default sources and is constrained to + // !minimal; the minimal variant loads -tags minimal sources and is + // constrained to minimal. + mainnet, err := methodicalOne(t, disableProgressive, nil, "!minimal") if err != nil { return fmt.Errorf("mainnet: %w", err) } - minimal, err := sszgenOne(t, minPb) + minimal, err := methodicalOne(t, disableProgressive, []string{"minimal"}, "minimal") if err != nil { return fmt.Errorf("minimal: %w", err) } - if mainnet == minimal { - if err := os.WriteFile(filepath.Join(t.pkg, t.out), []byte(mainnet), 0o600); err != nil { - return fmt.Errorf("writeFile: %w", err) - } - - return nil - } - - if err := os.WriteFile(filepath.Join(t.pkg, t.out), []byte("//go:build !minimal\n\n"+mainnet), 0o600); err != nil { + if err := os.WriteFile(out, []byte(mainnet), 0o600); err != nil { return fmt.Errorf("writeFile: %w", err) } - minOut := strings.TrimSuffix(t.out, ".ssz.go") + ".minimal.ssz.go" - if err := os.WriteFile(filepath.Join(t.pkg, minOut), []byte("//go:build minimal\n\n"+minimal), 0o600); err != nil { + minOut := filepath.Join(t.pkg, strings.TrimSuffix(t.out, ".ssz.go")+".minimal.ssz.go") + if err := os.WriteFile(minOut, []byte(minimal), 0o600); err != nil { return fmt.Errorf("writeFile: %w", err) } return nil } -func sszgenOne(t sszTarget, root string) (string, error) { - stage := filepath.Join(root, t.pkg, ".sszgen_tmp") - if err := stagePbgo(filepath.Join(root, t.pkg), stage); err != nil { - return "", fmt.Errorf("stagePbgo: %w", err) - } - - defer unstage(stage) - - inc := slices.Clone(t.libInc) - for _, p := range t.protoInc { - istage := filepath.Join(root, p, ".sszinc_tmp") - if err := stagePbgo(filepath.Join(root, p), istage); err != nil { - return "", fmt.Errorf("stagePbgo: %w", err) - } - - defer unstage(istage) - inc = append(inc, istage) - } - - tmp, err := os.CreateTemp("", "sszgen-*.go") +// methodicalOne runs `go tool ssz gen` for one target and returns the generated +// source. buildTags selects which tag-gated .pb.go variant methodical's package +// loader sees (nil for the default/mainnet build); buildConstraint is the +// //go:build header methodical stamps on the output ("" for none). +func methodicalOne(t methodicalTarget, disableProgressive bool, buildTags []string, buildConstraint string) (string, error) { + tmp, err := os.CreateTemp("", "methodical-*.go") if err != nil { return "", fmt.Errorf("createTemp: %w", err) } @@ -105,69 +109,32 @@ func sszgenOne(t sszTarget, root string) (string, error) { defer func() { _ = os.Remove(tmpName) }() - args := []string{"--output=" + tmpName, "--path=" + stage, "--objs=" + strings.Join(t.objs, ",")} - if len(inc) > 0 { - args = append(args, "--include="+strings.Join(inc, ",")) + args := []string{ + "tool", "ssz", "gen", + "--config=" + filepath.Join(t.pkg, t.configFile), + "--output=" + tmpName, } - - if len(t.exclude) > 0 { - args = append(args, "--exclude-objs="+strings.Join(t.exclude, ",")) + if t.overridePkg != "" { + args = append(args, "--override-package-name="+t.overridePkg) } - - if err := sh("go", append([]string{"tool", "sszgen"}, args...)...); err != nil { - return "", fmt.Errorf("sh: %w", err) + if disableProgressive { + args = append(args, "--disable-progressive") } - - data, err := os.ReadFile(tmpName) // #nosec G304 -- tmpName is our own os.CreateTemp output - if err != nil { - return "", fmt.Errorf("readFile: %w", err) + if len(buildTags) > 0 { + args = append(args, "--build-tags="+strings.Join(buildTags, ",")) } - - var b strings.Builder - for _, line := range strings.SplitAfter(string(data), "\n") { - if strings.Contains(line, "// Hash: ") { - continue - } - - b.WriteString(line) + if buildConstraint != "" { + args = append(args, "--go-build-constraint="+buildConstraint) } - return b.String(), nil -} - -// stagePbgo copies pkgDir's .pb.go files into stageDir, skipping .minimal.pb.go -// twins. -// -// The .minimal.pb.go twins are not fed to sszgen: the minimal variant is -// regenerated from .proto files into a temp dir at gen time and they are proto -// outputs already covered by the proto manifest. -func stagePbgo(pkgDir, stageDir string) error { - if err := os.MkdirAll(stageDir, 0o750); err != nil { - return fmt.Errorf("mkdirAll: %w", err) + if err := sh("go", args...); err != nil { + return "", fmt.Errorf("sh: %w", err) } - entries, err := os.ReadDir(pkgDir) + data, err := os.ReadFile(tmpName) // #nosec G304 -- tmpName is our own os.CreateTemp output if err != nil { - return fmt.Errorf("readDir: %w", err) - } - - for _, e := range entries { - name := e.Name() - if !strings.HasSuffix(name, ".pb.go") || strings.HasSuffix(name, ".minimal.pb.go") { - continue - } - - data, err := os.ReadFile(filepath.Join(pkgDir, name)) // #nosec G304 -- pkgDir/name from a controlled ReadDir of repo proto packages - if err != nil { - return fmt.Errorf("readFile: %w", err) - } - - if err := os.WriteFile(filepath.Join(stageDir, name), data, 0o600); err != nil { - return fmt.Errorf("writeFile: %w", err) - } + return "", fmt.Errorf("readFile: %w", err) } - return nil + return string(data), nil } - -func unstage(dir string) { _ = os.RemoveAll(dir) } diff --git a/build/gen/ssz_test.go b/build/gen/ssz_test.go deleted file mode 100644 index 1856cd2f723f..000000000000 --- a/build/gen/ssz_test.go +++ /dev/null @@ -1,57 +0,0 @@ -package main - -import ( - "os" - "path/filepath" - "testing" - - "github.com/OffchainLabs/prysm/v7/testing/require" -) - -func TestStagePbgo(t *testing.T) { - t.Run("copies .pb.go files, skipping minimal and non-pb.go", func(t *testing.T) { - dir := t.TempDir() - pkgDir := filepath.Join(dir, "pkg") - require.NoError(t, os.MkdirAll(pkgDir, 0o700)) - write := func(name, content string) { - require.NoError(t, os.WriteFile(filepath.Join(pkgDir, name), []byte(content), 0o600)) - } - write("foo.pb.go", "package foo\n") - write("bar.pb.go", "package bar\n") - write("baz.minimal.pb.go", "package baz\n") // excluded - write("types.go", "package x\n") // excluded - write("README.txt", "nope\n") // excluded - - stageDir := filepath.Join(dir, "stage") - require.NoError(t, stagePbgo(pkgDir, stageDir)) - - entries, err := os.ReadDir(stageDir) - require.NoError(t, err) - var names []string - for _, e := range entries { - names = append(names, e.Name()) - } - // os.ReadDir returns entries sorted by name. - require.DeepEqual(t, []string{"bar.pb.go", "foo.pb.go"}, names) - - got, err := os.ReadFile(filepath.Join(stageDir, "foo.pb.go")) - require.NoError(t, err) - require.Equal(t, "package foo\n", string(got)) - }) - - t.Run("errors when the stage dir cannot be created", func(t *testing.T) { - dir := t.TempDir() - // A file where a parent dir is expected makes MkdirAll fail. - blocker := filepath.Join(dir, "blocker") - require.NoError(t, os.WriteFile(blocker, []byte("x"), 0o600)) - - err := stagePbgo(dir, filepath.Join(blocker, "stage")) - require.ErrorContains(t, "mkdirAll:", err) - }) - - t.Run("errors when the package dir cannot be read", func(t *testing.T) { - dir := t.TempDir() - err := stagePbgo(filepath.Join(dir, "missing"), filepath.Join(dir, "stage")) - require.ErrorContains(t, "readDir:", err) - }) -} diff --git a/changelog/kasey_methodical-ssz-migration.md b/changelog/kasey_methodical-ssz-migration.md new file mode 100644 index 000000000000..5395b949309d --- /dev/null +++ b/changelog/kasey_methodical-ssz-migration.md @@ -0,0 +1,9 @@ +### Changed + +- SSZ marshalling, unmarshalling and hash tree roots are now generated by + `methodical-ssz` instead of `fastssz`. Generated code is emitted as a + mainnet/minimal pair per target, driven by per-package `*.yaml` configs. +- Both codegen paths (Bazel `ssz_methodical` and `//build/gen`) stamp the + `//go:build (!)minimal` constraint via methodical's `--go-build-constraint` + flag, making their output byte-identical; the drift check no longer masks + build-constraint differences. diff --git a/cmd/prysmctl/p2p/BUILD.bazel b/cmd/prysmctl/p2p/BUILD.bazel index 8453683f18f4..ddb6c6950e70 100644 --- a/cmd/prysmctl/p2p/BUILD.bazel +++ b/cmd/prysmctl/p2p/BUILD.bazel @@ -45,8 +45,8 @@ go_library( "@com_github_libp2p_go_libp2p//p2p/security/noise:go_default_library", "@com_github_libp2p_go_libp2p//p2p/transport/quic:go_default_library", "@com_github_libp2p_go_libp2p//p2p/transport/tcp:go_default_library", + "@com_github_offchainlabs_methodical_ssz//ssz:go_default_library", "@com_github_pkg_errors//:go_default_library", - "@com_github_prysmaticlabs_fastssz//:go_default_library", "@com_github_prysmaticlabs_go_bitfield//:go_default_library", "@com_github_sirupsen_logrus//:go_default_library", "@com_github_urfave_cli_v2//:go_default_library", diff --git a/cmd/prysmctl/p2p/client.go b/cmd/prysmctl/p2p/client.go index b6c483383712..c955011c32f5 100644 --- a/cmd/prysmctl/p2p/client.go +++ b/cmd/prysmctl/p2p/client.go @@ -8,6 +8,20 @@ import ( "time" "github.com/OffchainLabs/go-bitfield" + "github.com/OffchainLabs/methodical-ssz/ssz" + "github.com/libp2p/go-libp2p" + "github.com/libp2p/go-libp2p/core/crypto" + "github.com/libp2p/go-libp2p/core/host" + corenet "github.com/libp2p/go-libp2p/core/network" + "github.com/libp2p/go-libp2p/core/peer" + "github.com/libp2p/go-libp2p/core/protocol" + "github.com/libp2p/go-libp2p/p2p/security/noise" + libp2pquic "github.com/libp2p/go-libp2p/p2p/transport/quic" + libp2ptcp "github.com/libp2p/go-libp2p/p2p/transport/tcp" + "github.com/pkg/errors" + "google.golang.org/grpc" + "google.golang.org/protobuf/types/known/emptypb" + "github.com/OffchainLabs/prysm/v7/beacon-chain/p2p" "github.com/OffchainLabs/prysm/v7/beacon-chain/p2p/encoder" "github.com/OffchainLabs/prysm/v7/config/params" @@ -21,19 +35,6 @@ import ( "github.com/OffchainLabs/prysm/v7/proto/prysm/v1alpha1/metadata" "github.com/OffchainLabs/prysm/v7/runtime/version" "github.com/OffchainLabs/prysm/v7/time/slots" - "github.com/libp2p/go-libp2p" - "github.com/libp2p/go-libp2p/core/crypto" - "github.com/libp2p/go-libp2p/core/host" - corenet "github.com/libp2p/go-libp2p/core/network" - "github.com/libp2p/go-libp2p/core/peer" - "github.com/libp2p/go-libp2p/core/protocol" - "github.com/libp2p/go-libp2p/p2p/security/noise" - libp2pquic "github.com/libp2p/go-libp2p/p2p/transport/quic" - libp2ptcp "github.com/libp2p/go-libp2p/p2p/transport/tcp" - "github.com/pkg/errors" - ssz "github.com/prysmaticlabs/fastssz" - "google.golang.org/grpc" - "google.golang.org/protobuf/types/known/emptypb" ) // A minimal client for peering with beacon nodes over libp2p and sending p2p RPC requests for data. diff --git a/cmd/prysmctl/p2p/handler.go b/cmd/prysmctl/p2p/handler.go index 6008d896810a..e04217d6650c 100644 --- a/cmd/prysmctl/p2p/handler.go +++ b/cmd/prysmctl/p2p/handler.go @@ -6,13 +6,15 @@ import ( "runtime/debug" "strings" - "github.com/OffchainLabs/prysm/v7/beacon-chain/p2p" - p2ptypes "github.com/OffchainLabs/prysm/v7/beacon-chain/p2p/types" + "github.com/OffchainLabs/methodical-ssz/ssz" + libp2pcore "github.com/libp2p/go-libp2p/core" corenet "github.com/libp2p/go-libp2p/core/network" "github.com/libp2p/go-libp2p/core/protocol" "github.com/pkg/errors" - ssz "github.com/prysmaticlabs/fastssz" + + "github.com/OffchainLabs/prysm/v7/beacon-chain/p2p" + p2ptypes "github.com/OffchainLabs/prysm/v7/beacon-chain/p2p/types" ) type rpcHandler func(context.Context, any, libp2pcore.Stream) error diff --git a/config/features/flags.go b/config/features/flags.go index f387f5a797ce..c90ffd2b5d13 100644 --- a/config/features/flags.go +++ b/config/features/flags.go @@ -97,8 +97,8 @@ var ( } enableDoppelGangerProtection = &cli.BoolFlag{ Name: "enable-doppelganger", - Usage: `Enables the validator to perform a doppelganger check. - This is not a foolproof method to find duplicate instances in the network. + Usage: `Enables the validator to perform a doppelganger check. + This is not a foolproof method to find duplicate instances in the network. Your validator will still be vulnerable if it is being run in unsafe configurations.`, } disableStakinContractCheck = &cli.BoolFlag{ diff --git a/consensus-types/blocks/BUILD.bazel b/consensus-types/blocks/BUILD.bazel index 5ad850a27f65..ddde451d483a 100644 --- a/consensus-types/blocks/BUILD.bazel +++ b/consensus-types/blocks/BUILD.bazel @@ -25,6 +25,7 @@ go_library( deps = [ "//beacon-chain/core/signing:go_default_library", "//beacon-chain/state/stateutil:go_default_library", + "//config/features:go_default_library", "//config/fieldparams:go_default_library", "//config/params:go_default_library", "//consensus-types:go_default_library", @@ -42,8 +43,8 @@ go_library( "//runtime/version:go_default_library", "@com_github_libp2p_go_libp2p//core/peer:go_default_library", "@com_github_libp2p_go_libp2p_pubsub//partialmessages:go_default_library", + "@com_github_offchainlabs_methodical_ssz//ssz:go_default_library", "@com_github_pkg_errors//:go_default_library", - "@com_github_prysmaticlabs_fastssz//:go_default_library", "@com_github_prysmaticlabs_go_bitfield//:go_default_library", "@com_github_sirupsen_logrus//:go_default_library", "@org_golang_google_protobuf//proto:go_default_library", @@ -71,6 +72,7 @@ go_test( embed = [":go_default_library"], deps = [ "//beacon-chain/core/signing:go_default_library", + "//config/features:go_default_library", "//config/fieldparams:go_default_library", "//config/params:go_default_library", "//consensus-types:go_default_library", @@ -79,6 +81,7 @@ go_test( "//container/trie:go_default_library", "//crypto/hash/htr:go_default_library", "//encoding/bytesutil:go_default_library", + "//encoding/ssz:go_default_library", "//proto/engine/v1:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//proto/prysm/v1alpha1/validator-client:go_default_library", @@ -87,8 +90,8 @@ go_test( "//testing/require:go_default_library", "@com_github_libp2p_go_libp2p//core/peer:go_default_library", "@com_github_libp2p_go_libp2p_pubsub//partialmessages:go_default_library", + "@com_github_offchainlabs_methodical_ssz//ssz:go_default_library", "@com_github_pkg_errors//:go_default_library", - "@com_github_prysmaticlabs_fastssz//:go_default_library", "@com_github_prysmaticlabs_go_bitfield//:go_default_library", ], ) diff --git a/consensus-types/blocks/execution.go b/consensus-types/blocks/execution.go index 7fe662915715..8a974eb23e8d 100644 --- a/consensus-types/blocks/execution.go +++ b/consensus-types/blocks/execution.go @@ -3,6 +3,7 @@ package blocks import ( "bytes" + "github.com/OffchainLabs/methodical-ssz/ssz" fieldparams "github.com/OffchainLabs/prysm/v7/config/fieldparams" consensus_types "github.com/OffchainLabs/prysm/v7/consensus-types" "github.com/OffchainLabs/prysm/v7/consensus-types/interfaces" @@ -10,7 +11,6 @@ import ( enginev1 "github.com/OffchainLabs/prysm/v7/proto/engine/v1" "github.com/OffchainLabs/prysm/v7/proto/prysm/wrappers" "github.com/pkg/errors" - fastssz "github.com/prysmaticlabs/fastssz" "google.golang.org/protobuf/proto" ) @@ -104,7 +104,7 @@ func (e executionPayload) HashTreeRoot() ([32]byte, error) { } // HashTreeRootWith -- -func (e executionPayload) HashTreeRootWith(hh *fastssz.Hasher) error { +func (e executionPayload) HashTreeRootWith(hh *ssz.Hasher) error { return e.p.HashTreeRootWith(hh) } @@ -267,7 +267,7 @@ func (e executionPayloadHeader) HashTreeRoot() ([32]byte, error) { } // HashTreeRootWith -- -func (e executionPayloadHeader) HashTreeRootWith(hh *fastssz.Hasher) error { +func (e executionPayloadHeader) HashTreeRootWith(hh *ssz.Hasher) error { return e.p.HashTreeRootWith(hh) } @@ -458,7 +458,7 @@ func (e executionPayloadCapella) HashTreeRoot() ([32]byte, error) { } // HashTreeRootWith -- -func (e executionPayloadCapella) HashTreeRootWith(hh *fastssz.Hasher) error { +func (e executionPayloadCapella) HashTreeRootWith(hh *ssz.Hasher) error { return e.p.HashTreeRootWith(hh) } @@ -621,7 +621,7 @@ func (e executionPayloadHeaderCapella) HashTreeRoot() ([32]byte, error) { } // HashTreeRootWith -- -func (e executionPayloadHeaderCapella) HashTreeRootWith(hh *fastssz.Hasher) error { +func (e executionPayloadHeaderCapella) HashTreeRootWith(hh *ssz.Hasher) error { return e.p.HashTreeRootWith(hh) } @@ -930,7 +930,7 @@ func (e executionPayloadHeaderDeneb) HashTreeRoot() ([32]byte, error) { } // HashTreeRootWith -- -func (e executionPayloadHeaderDeneb) HashTreeRootWith(hh *fastssz.Hasher) error { +func (e executionPayloadHeaderDeneb) HashTreeRootWith(hh *ssz.Hasher) error { return e.p.HashTreeRootWith(hh) } @@ -1093,7 +1093,7 @@ func (e executionPayloadDeneb) HashTreeRoot() ([32]byte, error) { } // HashTreeRootWith -- -func (e executionPayloadDeneb) HashTreeRootWith(hh *fastssz.Hasher) error { +func (e executionPayloadDeneb) HashTreeRootWith(hh *ssz.Hasher) error { return e.p.HashTreeRootWith(hh) } @@ -1254,7 +1254,7 @@ func (e executionPayloadGloas) HashTreeRoot() ([32]byte, error) { } // HashTreeRootWith -- -func (e executionPayloadGloas) HashTreeRootWith(hh *fastssz.Hasher) error { +func (e executionPayloadGloas) HashTreeRootWith(hh *ssz.Hasher) error { return e.p.HashTreeRootWith(hh) } diff --git a/consensus-types/blocks/getters.go b/consensus-types/blocks/getters.go index 0cd00855b200..8c76b2fb6a15 100644 --- a/consensus-types/blocks/getters.go +++ b/consensus-types/blocks/getters.go @@ -3,6 +3,9 @@ package blocks import ( "fmt" + "github.com/OffchainLabs/methodical-ssz/ssz" + "github.com/pkg/errors" + field_params "github.com/OffchainLabs/prysm/v7/config/fieldparams" consensus_types "github.com/OffchainLabs/prysm/v7/consensus-types" "github.com/OffchainLabs/prysm/v7/consensus-types/interfaces" @@ -11,8 +14,6 @@ import ( eth "github.com/OffchainLabs/prysm/v7/proto/prysm/v1alpha1" validatorpb "github.com/OffchainLabs/prysm/v7/proto/prysm/v1alpha1/validator-client" "github.com/OffchainLabs/prysm/v7/runtime/version" - "github.com/pkg/errors" - ssz "github.com/prysmaticlabs/fastssz" ) // BeaconBlockIsNil checks if any composite field of input signed beacon block is nil. @@ -497,7 +498,7 @@ func (b *SignedBeaconBlock) MarshalSSZTo(dst []byte) ([]byte, error) { // SizeSSZ returns the size of the serialized signed block // // WARNING: This function panics. It is required to change the signature -// of fastssz's SizeSSZ() interface function to avoid panicking. +// of the SizeSSZ() interface function to avoid panicking. // Changing the signature causes very problematic issues with wealdtech deps. // For the time being panicking is preferable. // lint:nopanic -- Panic warning is communicated in godoc commentary. @@ -913,7 +914,7 @@ func (b *BeaconBlock) MarshalSSZTo(dst []byte) ([]byte, error) { // SizeSSZ returns the size of the serialized block. // // WARNING: This function panics. It is required to change the signature -// of fastssz's SizeSSZ() interface function to avoid panicking. +// of the SizeSSZ() interface function to avoid panicking. // Changing the signature causes very problematic issues with wealdtech deps. // For the time being panicking is preferable. // lint:nopanic -- Panic is communicated in godoc. diff --git a/consensus-types/blocks/getters_test.go b/consensus-types/blocks/getters_test.go index 30a90f33cf10..b6d5dbf4014f 100644 --- a/consensus-types/blocks/getters_test.go +++ b/consensus-types/blocks/getters_test.go @@ -3,7 +3,9 @@ package blocks import ( "testing" - "github.com/OffchainLabs/go-bitfield" + bitfield "github.com/OffchainLabs/go-bitfield" + ssz "github.com/OffchainLabs/methodical-ssz/ssz" + fieldparams "github.com/OffchainLabs/prysm/v7/config/fieldparams" consensus_types "github.com/OffchainLabs/prysm/v7/consensus-types" "github.com/OffchainLabs/prysm/v7/consensus-types/interfaces" @@ -15,7 +17,6 @@ import ( "github.com/OffchainLabs/prysm/v7/runtime/version" "github.com/OffchainLabs/prysm/v7/testing/assert" "github.com/OffchainLabs/prysm/v7/testing/require" - ssz "github.com/prysmaticlabs/fastssz" ) func Test_BeaconBlockIsNil(t *testing.T) { diff --git a/consensus-types/blocks/kzg.go b/consensus-types/blocks/kzg.go index 3ce1a14d3b28..2eb4083a4c71 100644 --- a/consensus-types/blocks/kzg.go +++ b/consensus-types/blocks/kzg.go @@ -245,7 +245,7 @@ func topLevelRoots(body interfaces.ReadOnlyBeaconBlockBody) ([][]byte, error) { // Proposer slashings ps := body.ProposerSlashings() - root, err = ssz.MerkleizeListSSZ(ps, params.BeaconConfig().MaxProposerSlashings) + root, err = blockBodyListRoot(body.Version(), ps, params.BeaconConfig().MaxProposerSlashings) if err != nil { return nil, err } @@ -255,9 +255,9 @@ func topLevelRoots(body interfaces.ReadOnlyBeaconBlockBody) ([][]byte, error) { as := body.AttesterSlashings() bodyVersion := body.Version() if bodyVersion < version.Electra { - root, err = ssz.MerkleizeListSSZ(as, params.BeaconConfig().MaxAttesterSlashings) + root, err = blockBodyListRoot(bodyVersion, as, params.BeaconConfig().MaxAttesterSlashings) } else { - root, err = ssz.MerkleizeListSSZ(as, params.BeaconConfig().MaxAttesterSlashingsElectra) + root, err = blockBodyListRoot(bodyVersion, as, params.BeaconConfig().MaxAttesterSlashingsElectra) } if err != nil { return nil, err @@ -267,9 +267,9 @@ func topLevelRoots(body interfaces.ReadOnlyBeaconBlockBody) ([][]byte, error) { // Attestations att := body.Attestations() if bodyVersion < version.Electra { - root, err = ssz.MerkleizeListSSZ(att, params.BeaconConfig().MaxAttestations) + root, err = blockBodyListRoot(bodyVersion, att, params.BeaconConfig().MaxAttestations) } else { - root, err = ssz.MerkleizeListSSZ(att, params.BeaconConfig().MaxAttestationsElectra) + root, err = blockBodyListRoot(bodyVersion, att, params.BeaconConfig().MaxAttestationsElectra) } if err != nil { return nil, err @@ -278,7 +278,7 @@ func topLevelRoots(body interfaces.ReadOnlyBeaconBlockBody) ([][]byte, error) { // Deposits dep := body.Deposits() - root, err = ssz.MerkleizeListSSZ(dep, params.BeaconConfig().MaxDeposits) + root, err = blockBodyListRoot(body.Version(), dep, params.BeaconConfig().MaxDeposits) if err != nil { return nil, err } @@ -286,7 +286,7 @@ func topLevelRoots(body interfaces.ReadOnlyBeaconBlockBody) ([][]byte, error) { // Voluntary Exits ve := body.VoluntaryExits() - root, err = ssz.MerkleizeListSSZ(ve, params.BeaconConfig().MaxVoluntaryExits) + root, err = blockBodyListRoot(body.Version(), ve, params.BeaconConfig().MaxVoluntaryExits) if err != nil { return nil, err } @@ -319,7 +319,7 @@ func topLevelRoots(body interfaces.ReadOnlyBeaconBlockBody) ([][]byte, error) { if err != nil { return nil, err } - root, err = ssz.MerkleizeListSSZ(bls, params.BeaconConfig().MaxBlsToExecutionChanges) + root, err = blockBodyListRoot(body.Version(), bls, params.BeaconConfig().MaxBlsToExecutionChanges) if err != nil { return nil, err } diff --git a/consensus-types/blocks/partialdatacolumn_test.go b/consensus-types/blocks/partialdatacolumn_test.go index 5f34a819fc1b..027f66be6275 100644 --- a/consensus-types/blocks/partialdatacolumn_test.go +++ b/consensus-types/blocks/partialdatacolumn_test.go @@ -315,7 +315,8 @@ func TestMarshalPartsMetadata(t *testing.T) { Available: bitfield.NewBitlist(32768), Requests: bitfield.NewBitlist(1), }, - wantErr: "Available", + // TODO: restore "Available" once methodical-ssz includes the field name in the error. + wantErr: "list length is higher than max value", }, { name: "requests too large", @@ -323,7 +324,8 @@ func TestMarshalPartsMetadata(t *testing.T) { Available: bitfield.NewBitlist(1), Requests: bitfield.NewBitlist(32768), }, - wantErr: "Requests", + // TODO: restore "Requests" once methodical-ssz includes the field name in the error. + wantErr: "list length is higher than max value", }, } @@ -423,7 +425,8 @@ func TestPartialDataColumn_PartsMetadata(t *testing.T) { // 32768 bits serializes to 4097 bytes, one over the 4096-byte ssz_max. Included: bitfield.NewBitlist(32768), }, - expectErr: "Available", + // TODO: restore "Available" once methodical-ssz includes the field name in the error. + expectErr: "list length is higher than max value", }, } @@ -492,7 +495,8 @@ func TestPartialDataColumn_cellsToSendToPeer(t *testing.T) { p := mustNewPartialColumn(t, 1, 0) p.Column[0] = []byte{1} _, _, err := p.cellsToSendToPeer(testPeerMeta(1, nil, []uint64{0})) - require.ErrorContains(t, "PartialColumn", err) + // TODO: restore "PartialColumn" once methodical-ssz includes the field name in the error. + require.ErrorContains(t, "bytes array does not have the correct length", err) }, }, { @@ -501,7 +505,8 @@ func TestPartialDataColumn_cellsToSendToPeer(t *testing.T) { p := mustNewPartialColumn(t, 1, 0) p.KzgProofs[0] = []byte{1} _, _, err := p.cellsToSendToPeer(testPeerMeta(1, nil, []uint64{0})) - require.ErrorContains(t, "KzgProofs", err) + // TODO: restore "KzgProofs" once methodical-ssz includes the field name in the error. + require.ErrorContains(t, "bytes array does not have the correct length", err) }, }, } @@ -536,7 +541,8 @@ func TestPartialDataColumn_buildPartialColumnHeader(t *testing.T) { p := mustNewPartialColumn(t, 2, 0) p.KzgCommitments[0] = []byte{1} _, err := p.buildPartialColumnHeader() - require.ErrorContains(t, "KzgCommitments", err) + // TODO: restore "KzgCommitments" once methodical-ssz includes the field name in the error. + require.ErrorContains(t, "bytes array does not have the correct length", err) }, }, { @@ -545,7 +551,8 @@ func TestPartialDataColumn_buildPartialColumnHeader(t *testing.T) { p := mustNewPartialColumn(t, 2, 0) p.KzgCommitmentsInclusionProof = p.KzgCommitmentsInclusionProof[:3] _, err := p.buildPartialColumnHeader() - require.ErrorContains(t, "KzgCommitmentsInclusionProof", err) + // TODO: restore "KzgCommitmentsInclusionProof" once methodical-ssz includes the field name in the error. + require.ErrorContains(t, "bytes array does not have the correct length", err) }, }, } diff --git a/consensus-types/blocks/proofs.go b/consensus-types/blocks/proofs.go index cd6045da0859..c6cafff0ddaa 100644 --- a/consensus-types/blocks/proofs.go +++ b/consensus-types/blocks/proofs.go @@ -7,6 +7,8 @@ import ( "fmt" "github.com/OffchainLabs/prysm/v7/beacon-chain/state/stateutil" + "github.com/OffchainLabs/prysm/v7/config/features" + fieldparams "github.com/OffchainLabs/prysm/v7/config/fieldparams" "github.com/OffchainLabs/prysm/v7/config/params" "github.com/OffchainLabs/prysm/v7/consensus-types/interfaces" "github.com/OffchainLabs/prysm/v7/container/trie" @@ -44,6 +46,8 @@ func ComputeBlockBodyFieldRoots(ctx context.Context, blockBody *BeaconBlockBody) fieldRoots = make([][]byte, 13) case version.Fulu: fieldRoots = make([][]byte, 13) + case version.Gloas: + fieldRoots = make([][]byte, 13) default: return nil, fmt.Errorf("unknown block body version %s", version.String(blockBody.version)) } @@ -74,7 +78,7 @@ func ComputeBlockBodyFieldRoots(ctx context.Context, blockBody *BeaconBlockBody) // Proposer slashings ps := blockBody.ProposerSlashings() - root, err = ssz.MerkleizeListSSZ(ps, params.BeaconConfig().MaxProposerSlashings) + root, err = blockBodyListRoot(blockBody.version, ps, params.BeaconConfig().MaxProposerSlashings) if err != nil { return nil, err } @@ -84,9 +88,9 @@ func ComputeBlockBodyFieldRoots(ctx context.Context, blockBody *BeaconBlockBody) as := blockBody.AttesterSlashings() bodyVersion := blockBody.Version() if bodyVersion < version.Electra { - root, err = ssz.MerkleizeListSSZ(as, params.BeaconConfig().MaxAttesterSlashings) + root, err = blockBodyListRoot(bodyVersion, as, params.BeaconConfig().MaxAttesterSlashings) } else { - root, err = ssz.MerkleizeListSSZ(as, params.BeaconConfig().MaxAttesterSlashingsElectra) + root, err = blockBodyListRoot(bodyVersion, as, params.BeaconConfig().MaxAttesterSlashingsElectra) } if err != nil { return nil, err @@ -96,9 +100,9 @@ func ComputeBlockBodyFieldRoots(ctx context.Context, blockBody *BeaconBlockBody) // Attestations att := blockBody.Attestations() if bodyVersion < version.Electra { - root, err = ssz.MerkleizeListSSZ(att, params.BeaconConfig().MaxAttestations) + root, err = blockBodyListRoot(bodyVersion, att, params.BeaconConfig().MaxAttestations) } else { - root, err = ssz.MerkleizeListSSZ(att, params.BeaconConfig().MaxAttestationsElectra) + root, err = blockBodyListRoot(bodyVersion, att, params.BeaconConfig().MaxAttestationsElectra) } if err != nil { return nil, err @@ -107,7 +111,7 @@ func ComputeBlockBodyFieldRoots(ctx context.Context, blockBody *BeaconBlockBody) // Deposits dep := blockBody.Deposits() - root, err = ssz.MerkleizeListSSZ(dep, params.BeaconConfig().MaxDeposits) + root, err = blockBodyListRoot(blockBody.version, dep, params.BeaconConfig().MaxDeposits) if err != nil { return nil, err } @@ -115,7 +119,7 @@ func ComputeBlockBodyFieldRoots(ctx context.Context, blockBody *BeaconBlockBody) // Voluntary Exits ve := blockBody.VoluntaryExits() - root, err = ssz.MerkleizeListSSZ(ve, params.BeaconConfig().MaxVoluntaryExits) + root, err = blockBodyListRoot(blockBody.version, ve, params.BeaconConfig().MaxVoluntaryExits) if err != nil { return nil, err } @@ -134,7 +138,7 @@ func ComputeBlockBodyFieldRoots(ctx context.Context, blockBody *BeaconBlockBody) copy(fieldRoots[8], root[:]) } - if blockBody.version >= version.Bellatrix { + if blockBody.version >= version.Bellatrix && blockBody.version < version.Gloas { // Execution Payload ep, err := blockBody.Execution() if err != nil { @@ -147,20 +151,20 @@ func ComputeBlockBodyFieldRoots(ctx context.Context, blockBody *BeaconBlockBody) copy(fieldRoots[9], root[:]) } - if blockBody.version >= version.Capella { + if blockBody.version >= version.Capella && blockBody.version < version.Gloas { // BLS Changes bls, err := blockBody.BLSToExecutionChanges() if err != nil { return nil, err } - root, err = ssz.MerkleizeListSSZ(bls, params.BeaconConfig().MaxBlsToExecutionChanges) + root, err = blockBodyListRoot(blockBody.version, bls, params.BeaconConfig().MaxBlsToExecutionChanges) if err != nil { return nil, err } copy(fieldRoots[10], root[:]) } - if blockBody.version >= version.Deneb { + if blockBody.version >= version.Deneb && blockBody.version < version.Gloas { // KZG commitments roots := make([][32]byte, len(blockBody.blobKzgCommitments)) for i, commitment := range blockBody.blobKzgCommitments { @@ -180,7 +184,7 @@ func ComputeBlockBodyFieldRoots(ctx context.Context, blockBody *BeaconBlockBody) copy(fieldRoots[11], root[:]) } - if blockBody.version >= version.Electra { + if blockBody.version >= version.Electra && blockBody.version < version.Gloas { // Execution Requests er, err := blockBody.ExecutionRequests() if err != nil { @@ -192,9 +196,68 @@ func ComputeBlockBodyFieldRoots(ctx context.Context, blockBody *BeaconBlockBody) } copy(fieldRoots[12], root[:]) } + if blockBody.version >= version.Gloas { + if err := computeGloasBlockBodyFieldRoots(blockBody, fieldRoots); err != nil { + return nil, err + } + } return fieldRoots, nil } +func blockBodyListRoot[T ssz.Hashable](bodyVersion int, elements []T, limit uint64) ([32]byte, error) { + if bodyVersion >= version.Gloas && features.Get().EnableProgressiveSSZ { + if uint64(len(elements)) > limit { + return [32]byte{}, fmt.Errorf("slice exceeds max length %d", limit) + } + return ssz.MerkleizeListSSZProgressive(elements) + } + return ssz.MerkleizeListSSZ(elements, limit) +} + +func computeGloasBlockBodyFieldRoots(blockBody *BeaconBlockBody, fieldRoots [][]byte) error { + bls, err := blockBody.BLSToExecutionChanges() + if err != nil { + return err + } + root, err := blockBodyListRoot(blockBody.version, bls, params.BeaconConfig().MaxBlsToExecutionChanges) + if err != nil { + return err + } + copy(fieldRoots[9], root[:]) + + bid, err := blockBody.SignedExecutionPayloadBid() + if err != nil { + return err + } + root, err = bid.HashTreeRoot() + if err != nil { + return err + } + copy(fieldRoots[10], root[:]) + + payloadAttestations, err := blockBody.PayloadAttestations() + if err != nil { + return err + } + root, err = blockBodyListRoot(blockBody.version, payloadAttestations, fieldparams.MaxPayloadAttestations) + if err != nil { + return err + } + copy(fieldRoots[11], root[:]) + + parentExecutionRequests, err := blockBody.ParentExecutionRequests() + if err != nil { + return err + } + root, err = parentExecutionRequests.HashTreeRoot() + if err != nil { + return err + } + copy(fieldRoots[12], root[:]) + + return nil +} + func PayloadProof(ctx context.Context, block interfaces.ReadOnlyBeaconBlock) ([][]byte, error) { i := block.Body() blockBody, ok := i.(*BeaconBlockBody) diff --git a/consensus-types/blocks/proofs_test.go b/consensus-types/blocks/proofs_test.go index be0380215b7a..d6d751cfaf10 100644 --- a/consensus-types/blocks/proofs_test.go +++ b/consensus-types/blocks/proofs_test.go @@ -3,7 +3,10 @@ package blocks import ( "testing" + "github.com/OffchainLabs/prysm/v7/config/features" + fieldparams "github.com/OffchainLabs/prysm/v7/config/fieldparams" "github.com/OffchainLabs/prysm/v7/container/trie" + "github.com/OffchainLabs/prysm/v7/encoding/ssz" "github.com/OffchainLabs/prysm/v7/testing/require" ) @@ -144,3 +147,37 @@ func TestComputeBlockBodyFieldRoots_Electra(t *testing.T) { require.DeepEqual(t, correctHash[:], hash) } + +func TestComputeBlockBodyFieldRoots_Gloas_ProgressiveSSZGate(t *testing.T) { + blockBodyGloas := hydrateBeaconBlockBodyGloas() + i, err := NewBeaconBlockBody(blockBodyGloas) + require.NoError(t, err) + + b, ok := i.(*BeaconBlockBody) + require.Equal(t, true, ok) + + reset := features.InitWithReset(&features.Flags{}) + defer reset() + + legacyRoots, err := ComputeBlockBodyFieldRoots(t.Context(), b) + require.NoError(t, err) + require.Equal(t, 13, len(legacyRoots)) + + payloadAttestations, err := b.PayloadAttestations() + require.NoError(t, err) + expectedLegacyPayloadAttestationsRoot, err := ssz.MerkleizeListSSZ(payloadAttestations, fieldparams.MaxPayloadAttestations) + require.NoError(t, err) + require.DeepEqual(t, expectedLegacyPayloadAttestationsRoot[:], legacyRoots[11]) + + reset = features.InitWithReset(&features.Flags{EnableProgressiveSSZ: true}) + defer reset() + + progressiveRoots, err := ComputeBlockBodyFieldRoots(t.Context(), b) + require.NoError(t, err) + require.Equal(t, 13, len(progressiveRoots)) + + expectedProgressivePayloadAttestationsRoot, err := ssz.MerkleizeListSSZProgressive(payloadAttestations) + require.NoError(t, err) + require.DeepEqual(t, expectedProgressivePayloadAttestationsRoot[:], progressiveRoots[11]) + require.DeepNotSSZEqual(t, legacyRoots[11], progressiveRoots[11]) +} diff --git a/consensus-types/hdiff/BUILD.bazel b/consensus-types/hdiff/BUILD.bazel index 7c582dc25edb..280afb20f8fe 100644 --- a/consensus-types/hdiff/BUILD.bazel +++ b/consensus-types/hdiff/BUILD.bazel @@ -27,8 +27,8 @@ go_library( "//proto/prysm/v1alpha1:go_default_library", "//runtime/version:go_default_library", "@com_github_golang_snappy//:go_default_library", + "@com_github_offchainlabs_methodical_ssz//ssz:go_default_library", "@com_github_pkg_errors//:go_default_library", - "@com_github_prysmaticlabs_fastssz//:go_default_library", "@com_github_prysmaticlabs_go_bitfield//:go_default_library", "@com_github_sirupsen_logrus//:go_default_library", "@org_golang_google_protobuf//proto:go_default_library", diff --git a/consensus-types/hdiff/state_diff.go b/consensus-types/hdiff/state_diff.go index 84942e465f95..6e0b65a282fa 100644 --- a/consensus-types/hdiff/state_diff.go +++ b/consensus-types/hdiff/state_diff.go @@ -7,6 +7,7 @@ import ( "slices" "github.com/OffchainLabs/go-bitfield" + "github.com/OffchainLabs/methodical-ssz/ssz" "github.com/OffchainLabs/prysm/v7/beacon-chain/core/altair" "github.com/OffchainLabs/prysm/v7/beacon-chain/core/capella" "github.com/OffchainLabs/prysm/v7/beacon-chain/core/deneb" @@ -25,7 +26,6 @@ import ( "github.com/OffchainLabs/prysm/v7/runtime/version" "github.com/golang/snappy" "github.com/pkg/errors" - ssz "github.com/prysmaticlabs/fastssz" "github.com/sirupsen/logrus" "google.golang.org/protobuf/proto" ) diff --git a/consensus-types/interfaces/BUILD.bazel b/consensus-types/interfaces/BUILD.bazel index d5f84203ccb9..47d4794476a2 100644 --- a/consensus-types/interfaces/BUILD.bazel +++ b/consensus-types/interfaces/BUILD.bazel @@ -18,8 +18,8 @@ go_library( "//proto/engine/v1:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//proto/prysm/v1alpha1/validator-client:go_default_library", + "@com_github_offchainlabs_methodical_ssz//ssz:go_default_library", "@com_github_pkg_errors//:go_default_library", - "@com_github_prysmaticlabs_fastssz//:go_default_library", "@org_golang_google_protobuf//proto:go_default_library", ], ) diff --git a/consensus-types/interfaces/beacon_block.go b/consensus-types/interfaces/beacon_block.go index 2fab7a10ac1e..b6e5e659f916 100644 --- a/consensus-types/interfaces/beacon_block.go +++ b/consensus-types/interfaces/beacon_block.go @@ -1,13 +1,13 @@ package interfaces import ( + "github.com/OffchainLabs/methodical-ssz/ssz" field_params "github.com/OffchainLabs/prysm/v7/config/fieldparams" "github.com/OffchainLabs/prysm/v7/consensus-types/primitives" enginev1 "github.com/OffchainLabs/prysm/v7/proto/engine/v1" ethpb "github.com/OffchainLabs/prysm/v7/proto/prysm/v1alpha1" validatorpb "github.com/OffchainLabs/prysm/v7/proto/prysm/v1alpha1/validator-client" "github.com/pkg/errors" - ssz "github.com/prysmaticlabs/fastssz" "google.golang.org/protobuf/proto" ) diff --git a/consensus-types/interfaces/light_client.go b/consensus-types/interfaces/light_client.go index fe774fe19843..b0af18d5c29d 100644 --- a/consensus-types/interfaces/light_client.go +++ b/consensus-types/interfaces/light_client.go @@ -1,10 +1,10 @@ package interfaces import ( + "github.com/OffchainLabs/methodical-ssz/ssz" fieldparams "github.com/OffchainLabs/prysm/v7/config/fieldparams" "github.com/OffchainLabs/prysm/v7/consensus-types/primitives" pb "github.com/OffchainLabs/prysm/v7/proto/prysm/v1alpha1" - ssz "github.com/prysmaticlabs/fastssz" "google.golang.org/protobuf/proto" ) diff --git a/consensus-types/interfaces/testing/BUILD.bazel b/consensus-types/interfaces/testing/BUILD.bazel new file mode 100644 index 000000000000..ec423b978667 --- /dev/null +++ b/consensus-types/interfaces/testing/BUILD.bazel @@ -0,0 +1,13 @@ +load("@prysm//tools/go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + testonly = True, + srcs = ["equality.go"], + importpath = "github.com/OffchainLabs/prysm/v7/consensus-types/interfaces/testing", + visibility = ["//visibility:public"], + deps = [ + "//consensus-types/interfaces:go_default_library", + "//testing/require:go_default_library", + ], +) diff --git a/consensus-types/interfaces/testing/equality.go b/consensus-types/interfaces/testing/equality.go new file mode 100644 index 000000000000..3b60de9b8af6 --- /dev/null +++ b/consensus-types/interfaces/testing/equality.go @@ -0,0 +1,23 @@ +// Package testing provides shared test helpers for the consensus-types +// block interfaces. +package testing + +import ( + "testing" + + "github.com/OffchainLabs/prysm/v7/consensus-types/interfaces" + "github.com/OffchainLabs/prysm/v7/testing/require" +) + +// RequireBlocksEqual asserts that two signed beacon blocks are equal by their +// SSZ-logical proto content. Unlike reflect.DeepEqual on the block wrappers, this +// treats nil and empty slices as equal, which matters because an empty list +// round-trips through SSZ (e.g. storage) as a non-nil empty slice. +func RequireBlocksEqual(t *testing.T, want, got interfaces.ReadOnlySignedBeaconBlock) { + t.Helper() + wp, err := want.Proto() + require.NoError(t, err) + gp, err := got.Proto() + require.NoError(t, err) + require.DeepSSZEqual(t, wp, gp) +} diff --git a/consensus-types/mock/BUILD.bazel b/consensus-types/mock/BUILD.bazel index de3f370e106e..bbf59cc15f05 100644 --- a/consensus-types/mock/BUILD.bazel +++ b/consensus-types/mock/BUILD.bazel @@ -13,7 +13,7 @@ go_library( "//proto/eth/v1:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//proto/prysm/v1alpha1/validator-client:go_default_library", - "@com_github_prysmaticlabs_fastssz//:go_default_library", + "@com_github_offchainlabs_methodical_ssz//ssz:go_default_library", "@org_golang_google_protobuf//proto:go_default_library", ], ) diff --git a/consensus-types/mock/block.go b/consensus-types/mock/block.go index 423c3c0db419..592276f1832a 100644 --- a/consensus-types/mock/block.go +++ b/consensus-types/mock/block.go @@ -3,6 +3,9 @@ package mock import ( + "github.com/OffchainLabs/methodical-ssz/ssz" + "google.golang.org/protobuf/proto" + field_params "github.com/OffchainLabs/prysm/v7/config/fieldparams" "github.com/OffchainLabs/prysm/v7/consensus-types/interfaces" "github.com/OffchainLabs/prysm/v7/consensus-types/primitives" @@ -10,8 +13,6 @@ import ( ethpb "github.com/OffchainLabs/prysm/v7/proto/eth/v1" eth "github.com/OffchainLabs/prysm/v7/proto/prysm/v1alpha1" validatorpb "github.com/OffchainLabs/prysm/v7/proto/prysm/v1alpha1/validator-client" - ssz "github.com/prysmaticlabs/fastssz" - "google.golang.org/protobuf/proto" ) type SignedBeaconBlock struct { diff --git a/consensus-types/primitives/BUILD.bazel b/consensus-types/primitives/BUILD.bazel index 8a8a7089f10e..95651dd24b09 100644 --- a/consensus-types/primitives/BUILD.bazel +++ b/consensus-types/primitives/BUILD.bazel @@ -24,7 +24,7 @@ go_library( deps = [ "//math:go_default_library", "@com_github_ethereum_go_ethereum//common:go_default_library", - "@com_github_prysmaticlabs_fastssz//:go_default_library", + "@com_github_offchainlabs_methodical_ssz//ssz:go_default_library", "@com_github_prysmaticlabs_go_bitfield//:go_default_library", ], ) diff --git a/consensus-types/primitives/builder_index.go b/consensus-types/primitives/builder_index.go index 838395ba4d35..66466efcbde0 100644 --- a/consensus-types/primitives/builder_index.go +++ b/consensus-types/primitives/builder_index.go @@ -3,12 +3,12 @@ package primitives import ( "fmt" - fssz "github.com/prysmaticlabs/fastssz" + "github.com/OffchainLabs/methodical-ssz/ssz" ) -var _ fssz.HashRoot = (BuilderIndex)(0) -var _ fssz.Marshaler = (*BuilderIndex)(nil) -var _ fssz.Unmarshaler = (*BuilderIndex)(nil) +var _ ssz.HashRoot = (BuilderIndex)(0) +var _ ssz.Marshaler = (*BuilderIndex)(nil) +var _ ssz.Unmarshaler = (*BuilderIndex)(nil) // BuilderIndex is an index into the builder registry. type BuilderIndex uint64 @@ -25,11 +25,11 @@ func (b BuilderIndex) ToValidatorIndex() ValidatorIndex { // HashTreeRoot returns the SSZ hash tree root of the index. func (b BuilderIndex) HashTreeRoot() ([32]byte, error) { - return fssz.HashWithDefaultHasher(b) + return ssz.HashWithDefaultHasher(b) } // HashTreeRootWith appends the SSZ uint64 representation of the index to the given hasher. -func (b BuilderIndex) HashTreeRootWith(hh *fssz.Hasher) error { +func (b BuilderIndex) HashTreeRootWith(hh *ssz.Hasher) error { hh.PutUint64(uint64(b)) return nil } @@ -39,7 +39,7 @@ func (b *BuilderIndex) UnmarshalSSZ(buf []byte) error { if len(buf) != b.SizeSSZ() { return fmt.Errorf("expected buffer of length %d received %d", b.SizeSSZ(), len(buf)) } - *b = BuilderIndex(fssz.UnmarshallUint64(buf)) + *b = BuilderIndex(UnmarshalUint64(buf)) return nil } @@ -54,7 +54,7 @@ func (b *BuilderIndex) MarshalSSZTo(dst []byte) ([]byte, error) { // MarshalSSZ encodes the index as an SSZ uint64. func (b *BuilderIndex) MarshalSSZ() ([]byte, error) { - marshalled := fssz.MarshalUint64([]byte{}, uint64(*b)) + marshalled := MarshalUint64([]byte{}, uint64(*b)) return marshalled, nil } diff --git a/consensus-types/primitives/committee_index.go b/consensus-types/primitives/committee_index.go index 28abfde83ffd..073224544c13 100644 --- a/consensus-types/primitives/committee_index.go +++ b/consensus-types/primitives/committee_index.go @@ -3,23 +3,23 @@ package primitives import ( "fmt" - fssz "github.com/prysmaticlabs/fastssz" + "github.com/OffchainLabs/methodical-ssz/ssz" ) -var _ fssz.HashRoot = (CommitteeIndex)(0) -var _ fssz.Marshaler = (*CommitteeIndex)(nil) -var _ fssz.Unmarshaler = (*CommitteeIndex)(nil) +var _ ssz.HashRoot = (CommitteeIndex)(0) +var _ ssz.Marshaler = (*CommitteeIndex)(nil) +var _ ssz.Unmarshaler = (*CommitteeIndex)(nil) // CommitteeIndex -- type CommitteeIndex uint64 // HashTreeRoot returns calculated hash root. func (c CommitteeIndex) HashTreeRoot() ([32]byte, error) { - return fssz.HashWithDefaultHasher(c) + return ssz.HashWithDefaultHasher(c) } // HashTreeRootWith -- -func (c CommitteeIndex) HashTreeRootWith(hh *fssz.Hasher) error { +func (c CommitteeIndex) HashTreeRootWith(hh *ssz.Hasher) error { hh.PutUint64(uint64(c)) return nil } @@ -29,7 +29,7 @@ func (c *CommitteeIndex) UnmarshalSSZ(buf []byte) error { if len(buf) != c.SizeSSZ() { return fmt.Errorf("expected buffer of length %d receiced %d", c.SizeSSZ(), len(buf)) } - *c = CommitteeIndex(fssz.UnmarshallUint64(buf)) + *c = CommitteeIndex(UnmarshalUint64(buf)) return nil } @@ -44,7 +44,7 @@ func (c *CommitteeIndex) MarshalSSZTo(dst []byte) ([]byte, error) { // MarshalSSZ -- func (c *CommitteeIndex) MarshalSSZ() ([]byte, error) { - marshalled := fssz.MarshalUint64([]byte{}, uint64(*c)) + marshalled := MarshalUint64([]byte{}, uint64(*c)) return marshalled, nil } diff --git a/consensus-types/primitives/domain.go b/consensus-types/primitives/domain.go index e3263009eb88..7e7168720ddc 100644 --- a/consensus-types/primitives/domain.go +++ b/consensus-types/primitives/domain.go @@ -3,23 +3,23 @@ package primitives import ( "fmt" - fssz "github.com/prysmaticlabs/fastssz" + "github.com/OffchainLabs/methodical-ssz/ssz" ) -var _ fssz.HashRoot = (Domain)([]byte{}) -var _ fssz.Marshaler = (*Domain)(nil) -var _ fssz.Unmarshaler = (*Domain)(nil) +var _ ssz.HashRoot = (Domain)([]byte{}) +var _ ssz.Marshaler = (*Domain)(nil) +var _ ssz.Unmarshaler = (*Domain)(nil) // Domain represents a 32 bytes domain object in Ethereum beacon chain consensus. type Domain []byte // HashTreeRoot -- func (d Domain) HashTreeRoot() ([32]byte, error) { - return fssz.HashWithDefaultHasher(d) + return ssz.HashWithDefaultHasher(d) } // HashTreeRootWith -- -func (d Domain) HashTreeRootWith(hh *fssz.Hasher) error { +func (d Domain) HashTreeRootWith(hh *ssz.Hasher) error { hh.PutBytes(d[:]) return nil } diff --git a/consensus-types/primitives/epoch.go b/consensus-types/primitives/epoch.go index f099373fa241..8c604d974d20 100644 --- a/consensus-types/primitives/epoch.go +++ b/consensus-types/primitives/epoch.go @@ -3,13 +3,13 @@ package primitives import ( "fmt" + "github.com/OffchainLabs/methodical-ssz/ssz" "github.com/OffchainLabs/prysm/v7/math" - fssz "github.com/prysmaticlabs/fastssz" ) -var _ fssz.HashRoot = (Epoch)(0) -var _ fssz.Marshaler = (*Epoch)(nil) -var _ fssz.Unmarshaler = (*Epoch)(nil) +var _ ssz.HashRoot = (Epoch)(0) +var _ ssz.Marshaler = (*Epoch)(nil) +var _ ssz.Unmarshaler = (*Epoch)(nil) // Epoch represents a single epoch. type Epoch uint64 @@ -113,11 +113,11 @@ func (e Epoch) SafeMod(x uint64) (Epoch, error) { // HashTreeRoot -- func (e Epoch) HashTreeRoot() ([32]byte, error) { - return fssz.HashWithDefaultHasher(e) + return ssz.HashWithDefaultHasher(e) } // HashTreeRootWith -- -func (e Epoch) HashTreeRootWith(hh *fssz.Hasher) error { +func (e Epoch) HashTreeRootWith(hh *ssz.Hasher) error { hh.PutUint64(uint64(e)) return nil } @@ -127,7 +127,7 @@ func (e *Epoch) UnmarshalSSZ(buf []byte) error { if len(buf) != e.SizeSSZ() { return fmt.Errorf("expected buffer of length %d received %d", e.SizeSSZ(), len(buf)) } - *e = Epoch(fssz.UnmarshallUint64(buf)) + *e = Epoch(UnmarshalUint64(buf)) return nil } @@ -142,7 +142,7 @@ func (e *Epoch) MarshalSSZTo(dst []byte) ([]byte, error) { // MarshalSSZ -- func (e *Epoch) MarshalSSZ() ([]byte, error) { - marshalled := fssz.MarshalUint64([]byte{}, uint64(*e)) + marshalled := MarshalUint64([]byte{}, uint64(*e)) return marshalled, nil } diff --git a/consensus-types/primitives/slot.go b/consensus-types/primitives/slot.go index da147608d562..1c146b56d67c 100644 --- a/consensus-types/primitives/slot.go +++ b/consensus-types/primitives/slot.go @@ -3,13 +3,14 @@ package primitives import ( "fmt" + "github.com/OffchainLabs/methodical-ssz/ssz" + "github.com/OffchainLabs/prysm/v7/math" - fssz "github.com/prysmaticlabs/fastssz" ) -var _ fssz.HashRoot = (Slot)(0) -var _ fssz.Marshaler = (*Slot)(nil) -var _ fssz.Unmarshaler = (*Slot)(nil) +var _ ssz.HashRoot = (Slot)(0) +var _ ssz.Marshaler = (*Slot)(nil) +var _ ssz.Unmarshaler = (*Slot)(nil) // Slot represents a single slot. type Slot uint64 @@ -169,11 +170,11 @@ func (s Slot) SafeModSlot(x Slot) (Slot, error) { // HashTreeRoot -- func (s Slot) HashTreeRoot() ([32]byte, error) { - return fssz.HashWithDefaultHasher(s) + return ssz.HashWithDefaultHasher(s) } // HashTreeRootWith -- -func (s Slot) HashTreeRootWith(hh *fssz.Hasher) error { +func (s Slot) HashTreeRootWith(hh *ssz.Hasher) error { hh.PutUint64(uint64(s)) return nil } @@ -183,7 +184,7 @@ func (s *Slot) UnmarshalSSZ(buf []byte) error { if len(buf) != s.SizeSSZ() { return fmt.Errorf("expected buffer of length %d received %d", s.SizeSSZ(), len(buf)) } - *s = Slot(fssz.UnmarshallUint64(buf)) + *s = Slot(UnmarshalUint64(buf)) return nil } @@ -198,7 +199,7 @@ func (s *Slot) MarshalSSZTo(dst []byte) ([]byte, error) { // MarshalSSZ -- func (s *Slot) MarshalSSZ() ([]byte, error) { - marshalled := fssz.MarshalUint64([]byte{}, uint64(*s)) + marshalled := MarshalUint64([]byte{}, uint64(*s)) return marshalled, nil } diff --git a/consensus-types/primitives/sszbytes.go b/consensus-types/primitives/sszbytes.go index 7e37586dd479..8c70dfe1f69f 100644 --- a/consensus-types/primitives/sszbytes.go +++ b/consensus-types/primitives/sszbytes.go @@ -1,7 +1,7 @@ package primitives import ( - fssz "github.com/prysmaticlabs/fastssz" + "github.com/OffchainLabs/methodical-ssz/ssz" ) // SSZBytes -- @@ -9,11 +9,11 @@ type SSZBytes []byte // HashTreeRoot -- func (b *SSZBytes) HashTreeRoot() ([32]byte, error) { - return fssz.HashWithDefaultHasher(b) + return ssz.HashWithDefaultHasher(b) } // HashTreeRootWith -- -func (b *SSZBytes) HashTreeRootWith(hh *fssz.Hasher) error { +func (b *SSZBytes) HashTreeRootWith(hh *ssz.Hasher) error { indx := hh.Index() hh.PutBytes(*b) hh.Merkleize(indx) diff --git a/consensus-types/primitives/sszuint64.go b/consensus-types/primitives/sszuint64.go index dfd733d28022..3bb15539373a 100644 --- a/consensus-types/primitives/sszuint64.go +++ b/consensus-types/primitives/sszuint64.go @@ -4,12 +4,25 @@ import ( "encoding/binary" "fmt" - fssz "github.com/prysmaticlabs/fastssz" + "github.com/OffchainLabs/methodical-ssz/ssz" ) -var _ fssz.HashRoot = (Epoch)(0) -var _ fssz.Marshaler = (*Epoch)(nil) -var _ fssz.Unmarshaler = (*Epoch)(nil) +var _ ssz.HashRoot = (Epoch)(0) +var _ ssz.Marshaler = (*Epoch)(nil) +var _ ssz.Unmarshaler = (*Epoch)(nil) + +// MarshalUint64 appends the SSZ (little-endian) encoding of i to dst and +// returns the extended buffer. These uint64 serialization helpers live in the +// primitives package, rather than encoding/ssz, because encoding/ssz depends +// on primitives (transitively), so primitives cannot import it. +func MarshalUint64(dst []byte, i uint64) []byte { + return binary.LittleEndian.AppendUint64(dst, i) +} + +// UnmarshalUint64 decodes a little-endian uint64 from the first 8 bytes of src. +func UnmarshalUint64(src []byte) uint64 { + return binary.LittleEndian.Uint64(src) +} // SSZUint64 -- type SSZUint64 uint64 @@ -30,7 +43,7 @@ func (s *SSZUint64) MarshalSSZTo(dst []byte) ([]byte, error) { // MarshalSSZ -- func (s *SSZUint64) MarshalSSZ() ([]byte, error) { - marshalled := fssz.MarshalUint64([]byte{}, uint64(*s)) + marshalled := MarshalUint64([]byte{}, uint64(*s)) return marshalled, nil } @@ -39,7 +52,7 @@ func (s *SSZUint64) UnmarshalSSZ(buf []byte) error { if len(buf) != s.SizeSSZ() { return fmt.Errorf("expected buffer of length %d received %d", s.SizeSSZ(), len(buf)) } - *s = SSZUint64(fssz.UnmarshallUint64(buf)) + *s = SSZUint64(UnmarshalUint64(buf)) return nil } @@ -53,7 +66,7 @@ func (s *SSZUint64) HashTreeRoot() ([32]byte, error) { } // HashTreeRootWith -- -func (s *SSZUint64) HashTreeRootWith(hh *fssz.Hasher) error { +func (s *SSZUint64) HashTreeRootWith(hh *ssz.Hasher) error { indx := hh.Index() hh.PutUint64(uint64(*s)) hh.Merkleize(indx) diff --git a/consensus-types/primitives/validator.go b/consensus-types/primitives/validator.go index a166e3bb3a89..f6377fde6f92 100644 --- a/consensus-types/primitives/validator.go +++ b/consensus-types/primitives/validator.go @@ -3,12 +3,12 @@ package primitives import ( "fmt" - fssz "github.com/prysmaticlabs/fastssz" + "github.com/OffchainLabs/methodical-ssz/ssz" ) -var _ fssz.HashRoot = (ValidatorIndex)(0) -var _ fssz.Marshaler = (*ValidatorIndex)(nil) -var _ fssz.Unmarshaler = (*ValidatorIndex)(nil) +var _ ssz.HashRoot = (ValidatorIndex)(0) +var _ ssz.Marshaler = (*ValidatorIndex)(nil) +var _ ssz.Unmarshaler = (*ValidatorIndex)(nil) // BuilderIndexFlag marks a ValidatorIndex as a BuilderIndex when the bit is set. // @@ -68,11 +68,11 @@ func (v ValidatorIndex) Mod(x uint64) ValidatorIndex { // HashTreeRoot -- func (v ValidatorIndex) HashTreeRoot() ([32]byte, error) { - return fssz.HashWithDefaultHasher(v) + return ssz.HashWithDefaultHasher(v) } // HashTreeRootWith -- -func (v ValidatorIndex) HashTreeRootWith(hh *fssz.Hasher) error { +func (v ValidatorIndex) HashTreeRootWith(hh *ssz.Hasher) error { hh.PutUint64(uint64(v)) return nil } @@ -82,7 +82,7 @@ func (v *ValidatorIndex) UnmarshalSSZ(buf []byte) error { if len(buf) != v.SizeSSZ() { return fmt.Errorf("expected buffer of length %d received %d", v.SizeSSZ(), len(buf)) } - *v = ValidatorIndex(fssz.UnmarshallUint64(buf)) + *v = ValidatorIndex(UnmarshalUint64(buf)) return nil } @@ -97,7 +97,7 @@ func (v *ValidatorIndex) MarshalSSZTo(dst []byte) ([]byte, error) { // MarshalSSZ -- func (v *ValidatorIndex) MarshalSSZ() ([]byte, error) { - marshalled := fssz.MarshalUint64([]byte{}, uint64(*v)) + marshalled := MarshalUint64([]byte{}, uint64(*v)) return marshalled, nil } diff --git a/consensus-types/primitives/wei.go b/consensus-types/primitives/wei.go index 7e7d12bd2b51..77118610ccfb 100644 --- a/consensus-types/primitives/wei.go +++ b/consensus-types/primitives/wei.go @@ -5,7 +5,7 @@ import ( "math/big" "slices" - fssz "github.com/prysmaticlabs/fastssz" + "github.com/OffchainLabs/methodical-ssz/ssz" ) // ZW returns a non-nil zero value for primitives.Wei @@ -19,17 +19,17 @@ type Wei *big.Int // Gwei is a denomination of 1e9 Wei represented as an uint64. type Gwei uint64 -var _ fssz.HashRoot = (Gwei)(0) -var _ fssz.Marshaler = (*Gwei)(nil) -var _ fssz.Unmarshaler = (*Gwei)(nil) +var _ ssz.HashRoot = (Gwei)(0) +var _ ssz.Marshaler = (*Gwei)(nil) +var _ ssz.Unmarshaler = (*Gwei)(nil) // HashTreeRoot -- func (g Gwei) HashTreeRoot() ([32]byte, error) { - return fssz.HashWithDefaultHasher(g) + return ssz.HashWithDefaultHasher(g) } // HashTreeRootWith -- -func (g Gwei) HashTreeRootWith(hh *fssz.Hasher) error { +func (g Gwei) HashTreeRootWith(hh *ssz.Hasher) error { hh.PutUint64(uint64(g)) return nil } @@ -39,7 +39,7 @@ func (g *Gwei) UnmarshalSSZ(buf []byte) error { if len(buf) != g.SizeSSZ() { return fmt.Errorf("expected buffer of length %d received %d", g.SizeSSZ(), len(buf)) } - *g = Gwei(fssz.UnmarshallUint64(buf)) + *g = Gwei(UnmarshalUint64(buf)) return nil } @@ -54,7 +54,7 @@ func (g *Gwei) MarshalSSZTo(dst []byte) ([]byte, error) { // MarshalSSZ -- func (g *Gwei) MarshalSSZ() ([]byte, error) { - marshalled := fssz.MarshalUint64([]byte{}, uint64(*g)) + marshalled := MarshalUint64([]byte{}, uint64(*g)) return marshalled, nil } diff --git a/crypto/hash/BUILD.bazel b/crypto/hash/BUILD.bazel index 8c1f95e8fb0d..dc8e7f1b1de7 100644 --- a/crypto/hash/BUILD.bazel +++ b/crypto/hash/BUILD.bazel @@ -9,7 +9,7 @@ go_library( "//encoding/bytesutil:go_default_library", "@com_github_minio_highwayhash//:go_default_library", "@com_github_minio_sha256_simd//:go_default_library", - "@com_github_prysmaticlabs_fastssz//:go_default_library", + "@com_github_offchainlabs_methodical_ssz//ssz:go_default_library", "@org_golang_google_protobuf//proto:go_default_library", "@org_golang_x_crypto//sha3:go_default_library", ], diff --git a/crypto/hash/hash.go b/crypto/hash/hash.go index d0473c0d494c..6d08bbe93f84 100644 --- a/crypto/hash/hash.go +++ b/crypto/hash/hash.go @@ -7,12 +7,13 @@ import ( "reflect" "sync" - "github.com/OffchainLabs/prysm/v7/encoding/bytesutil" + "github.com/OffchainLabs/methodical-ssz/ssz" "github.com/minio/highwayhash" "github.com/minio/sha256-simd" - fastssz "github.com/prysmaticlabs/fastssz" "golang.org/x/crypto/sha3" "google.golang.org/protobuf/proto" + + "github.com/OffchainLabs/prysm/v7/encoding/bytesutil" ) // ErrNilProto can occur when attempting to hash a protobuf message that is nil @@ -108,7 +109,7 @@ func Proto(msg proto.Message) (result [32]byte, err error) { return [32]byte{}, ErrNilProto } var data []byte - if m, ok := msg.(fastssz.Marshaler); ok { + if m, ok := msg.(ssz.Marshaler); ok { data, err = m.MarshalSSZ() } else { data, err = proto.Marshal(msg) diff --git a/deps.bzl b/deps.bzl index d0741a9ada7a..d6da5f29eabb 100644 --- a/deps.bzl +++ b/deps.bzl @@ -608,6 +608,12 @@ def prysm_deps(): sum = "h1:ybO8RBeh29qrxIhCA9E8gKY6xfONU9T6G6aP9DTKfLE=", version = "v1.5.7", ) + go_repository( + name = "com_github_dave_jennifer", + importpath = "github.com/dave/jennifer", + sum = "h1:B4jJJDHelWcDhlRQxWeo0Npa/pYKBLrirAQoTN45txo=", + version = "v1.7.1", + ) go_repository( name = "com_github_davecgh_go_spew", importpath = "github.com/davecgh/go-spew", @@ -2481,6 +2487,12 @@ def prysm_deps(): sum = "h1:nM8dBAQZzHLzzM14FaAHXnHTAXZIst69v5xWuS48y/c=", version = "v0.2.3", ) + go_repository( + name = "com_github_offchainlabs_methodical_ssz", + importpath = "github.com/OffchainLabs/methodical-ssz", + sum = "h1:X7Rtbyy16t/ruqtADWyYg8GSfJlO9gfXyxmHpB3oYvQ=", + version = "v0.0.0-20260703104215-9be4f5c6a334", + ) go_repository( name = "com_github_oklog_oklog", importpath = "github.com/oklog/oklog", @@ -4599,14 +4611,14 @@ def prysm_deps(): go_repository( name = "org_golang_google_genproto_googleapis_api", importpath = "google.golang.org/genproto/googleapis/api", - sum = "h1:tu/dtnW1o3wfaxCOjSLn5IRX4YDcJrtlpzYkhHhGaC4=", - version = "v0.0.0-20260226221140-a57be14db171", + sum = "h1:Kjn0N0tCrDgiAFW+lGO4JZ3ck44CehvJQMAwj9QF0G8=", + version = "v0.0.0-20260526163538-3dc84a4a5aaa", ) go_repository( name = "org_golang_google_genproto_googleapis_rpc", importpath = "google.golang.org/genproto/googleapis/rpc", - sum = "h1:ggcbiqK8WWh6l1dnltU4BgWGIGo+EVYxCaAPih/zQXQ=", - version = "v0.0.0-20260226221140-a57be14db171", + sum = "h1:mZHHdPZl0dbGHCflZgAq/Q468DWVFcU2whhB2KAo8fk=", + version = "v0.0.0-20260526163538-3dc84a4a5aaa", ) go_repository( name = "org_golang_google_grpc", diff --git a/encoding/ssz/BUILD.bazel b/encoding/ssz/BUILD.bazel index 4419e71fc0c8..ba58eb0e306c 100644 --- a/encoding/ssz/BUILD.bazel +++ b/encoding/ssz/BUILD.bazel @@ -40,14 +40,10 @@ go_test( ":go_default_library", "//config/features:go_default_library", "//config/fieldparams:go_default_library", - "//config/params:go_default_library", "//crypto/hash:go_default_library", "//proto/prysm/v1alpha1:go_default_library", - "//proto/prysm/wrappers:go_default_library", "//testing/assert:go_default_library", "//testing/require:go_default_library", - "@com_github_pkg_errors//:go_default_library", - "@com_github_prysmaticlabs_fastssz//:go_default_library", "@com_github_prysmaticlabs_go_bitfield//:go_default_library", ], ) diff --git a/encoding/ssz/detect/BUILD.bazel b/encoding/ssz/detect/BUILD.bazel index 3a38d7217a81..eaa31170ddb3 100644 --- a/encoding/ssz/detect/BUILD.bazel +++ b/encoding/ssz/detect/BUILD.bazel @@ -20,8 +20,8 @@ go_library( "//proto/prysm/v1alpha1:go_default_library", "//runtime/version:go_default_library", "//time/slots:go_default_library", + "@com_github_offchainlabs_methodical_ssz//ssz:go_default_library", "@com_github_pkg_errors//:go_default_library", - "@com_github_prysmaticlabs_fastssz//:go_default_library", ], ) diff --git a/encoding/ssz/detect/configfork.go b/encoding/ssz/detect/configfork.go index da3e9b7adf0e..a70b3c9771ed 100644 --- a/encoding/ssz/detect/configfork.go +++ b/encoding/ssz/detect/configfork.go @@ -3,6 +3,9 @@ package detect import ( "fmt" + "github.com/OffchainLabs/methodical-ssz/ssz" + "github.com/pkg/errors" + "github.com/OffchainLabs/prysm/v7/beacon-chain/state" state_native "github.com/OffchainLabs/prysm/v7/beacon-chain/state/state-native" fieldparams "github.com/OffchainLabs/prysm/v7/config/fieldparams" @@ -14,8 +17,6 @@ import ( ethpb "github.com/OffchainLabs/prysm/v7/proto/prysm/v1alpha1" "github.com/OffchainLabs/prysm/v7/runtime/version" "github.com/OffchainLabs/prysm/v7/time/slots" - "github.com/pkg/errors" - ssz "github.com/prysmaticlabs/fastssz" ) // VersionedUnmarshaler represents the intersection of Configuration (eg mainnet, testnet) and Fork (eg phase0, altair). diff --git a/encoding/ssz/helpers.go b/encoding/ssz/helpers.go index 73a218bae598..6866b9d228b4 100644 --- a/encoding/ssz/helpers.go +++ b/encoding/ssz/helpers.go @@ -16,6 +16,11 @@ const ( BytesPerChunk = 32 ) +// UnmarshalUint64 decodes a little-endian uint64 from the first 8 bytes of buf. +func UnmarshalUint64(buf []byte) uint64 { + return binary.LittleEndian.Uint64(buf) +} + // BitlistRoot returns the mix in length of a bitwise Merkleized bitfield. func BitlistRoot(bfield bitfield.Bitfield, maxCapacity uint64) ([32]byte, error) { limit := (maxCapacity + 255) / 256 diff --git a/encoding/ssz/htrutils_fuzz_test.go b/encoding/ssz/htrutils_fuzz_test.go index 2154da9df581..b1a428d4161a 100644 --- a/encoding/ssz/htrutils_fuzz_test.go +++ b/encoding/ssz/htrutils_fuzz_test.go @@ -5,12 +5,7 @@ package ssz_test import ( "testing" - "github.com/OffchainLabs/prysm/v7/config/params" "github.com/OffchainLabs/prysm/v7/encoding/ssz" - pb "github.com/OffchainLabs/prysm/v7/proto/prysm/v1alpha1" - "github.com/OffchainLabs/prysm/v7/proto/prysm/wrappers" - "github.com/pkg/errors" - fssz "github.com/prysmaticlabs/fastssz" ) func FuzzUint64Root(f *testing.F) { @@ -19,33 +14,6 @@ func FuzzUint64Root(f *testing.F) { }) } -func FuzzForkRoot(f *testing.F) { - frk := &pb.Fork{ - PreviousVersion: params.BeaconConfig().GenesisForkVersion, - CurrentVersion: params.BeaconConfig().AltairForkVersion, - Epoch: 100, - } - example, err := frk.MarshalSSZ() - if err != nil { - f.Fatal(err) - } - f.Add(example) - - f.Fuzz(func(t *testing.T, b []byte) { - frk := &pb.Fork{} - if err := frk.UnmarshalSSZ(b); err != nil { - if errors.Is(err, fssz.ErrSize) { - return - } - t.Fatal(err) - } - - if _, err := wrappers.ForkRoot(frk); err != nil { - t.Fatal(err) - } - }) -} - func FuzzPackChunks(f *testing.F) { f.Fuzz(func(t *testing.T, b []byte) { if _, err := ssz.PackByChunk([][]byte{b}); err != nil { diff --git a/go.mod b/go.mod index 52e3b76a546c..fb4d00415225 100644 --- a/go.mod +++ b/go.mod @@ -5,6 +5,7 @@ go 1.26.5 require ( github.com/OffchainLabs/go-bitfield v0.0.0-20260504143531-5cbb6d0f5f2e github.com/OffchainLabs/hashtree v0.2.3 + github.com/OffchainLabs/methodical-ssz v0.0.0-20260703104215-9be4f5c6a334 github.com/aristanetworks/goarista v0.0.0-20200805130819-fd197cf57d96 github.com/bazelbuild/buildtools v0.0.0-20260528135316-84fa6c32aee6 github.com/bazelbuild/rules_go v0.23.2 @@ -136,6 +137,7 @@ require ( github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.7 // indirect github.com/crate-crypto/go-eth-kzg v1.5.0 // indirect + github.com/dave/jennifer v1.7.1 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c // indirect github.com/dchest/siphash v1.2.3 // indirect @@ -314,7 +316,7 @@ replace github.com/json-iterator/go => github.com/prestonvanloon/go v1.1.7-0.201 replace github.com/tyler-smith/go-bip39 => ./third_party/go-bip39 tool ( - github.com/prysmaticlabs/fastssz/sszgen + github.com/OffchainLabs/methodical-ssz/cmd/ssz github.com/prysmaticlabs/protoc-gen-go-cast go.uber.org/mock/mockgen gotest.tools/gotestsum diff --git a/go.sum b/go.sum index 66bf88046f23..0a4e64f203e0 100644 --- a/go.sum +++ b/go.sum @@ -35,6 +35,8 @@ github.com/OffchainLabs/go-bitfield v0.0.0-20260504143531-5cbb6d0f5f2e h1:M9Ia6E github.com/OffchainLabs/go-bitfield v0.0.0-20260504143531-5cbb6d0f5f2e/go.mod h1:6TZI4FU6zT8x6ZfWa1J8YQ2NgW0wLV/W3fHRca8ISBo= github.com/OffchainLabs/hashtree v0.2.3 h1:nM8dBAQZzHLzzM14FaAHXnHTAXZIst69v5xWuS48y/c= github.com/OffchainLabs/hashtree v0.2.3/go.mod h1:b07+cRZs+eAR8TR57CB9TQlt5Gnl/06Xs76xt/1wq0M= +github.com/OffchainLabs/methodical-ssz v0.0.0-20260703104215-9be4f5c6a334 h1:X7Rtbyy16t/ruqtADWyYg8GSfJlO9gfXyxmHpB3oYvQ= +github.com/OffchainLabs/methodical-ssz v0.0.0-20260703104215-9be4f5c6a334/go.mod h1:V1D4kNhhNQ7jltlUDOZfSt750UypPV0wkhakdlcrEd0= github.com/ProjectZKM/Ziren/crates/go-runtime/zkvm_runtime v0.0.0-20251001021608-1fe7b43fc4d6 h1:1zYrtlhrZ6/b6SAjLSfKzWtdgqK0U+HtH/VcBWh1BaU= github.com/ProjectZKM/Ziren/crates/go-runtime/zkvm_runtime v0.0.0-20251001021608-1fe7b43fc4d6/go.mod h1:ioLG6R+5bUSO1oeGSDxOV3FADARuMoytZCSX6MEMQkI= github.com/STARRY-S/zip v0.2.3 h1:luE4dMvRPDOWQdeDdUxUoZkzUIpTccdKdhHHsQJ1fm4= @@ -160,6 +162,8 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3 github.com/cyberdelia/templates v0.0.0-20141128023046-ca7fffd4298c/go.mod h1:GyV+0YP4qX0UQ7r2MoYZ+AvYDp12OF5yg4q8rGnyNh4= github.com/d4l3k/messagediff v1.2.1 h1:ZcAIMYsUg0EAp9X+tt8/enBE/Q8Yd5kzPynLyKptt9U= github.com/d4l3k/messagediff v1.2.1/go.mod h1:Oozbb1TVXFac9FtSIxHBMnBCq2qeH/2KkEQxENCrlLo= +github.com/dave/jennifer v1.7.1 h1:B4jJJDHelWcDhlRQxWeo0Npa/pYKBLrirAQoTN45txo= +github.com/dave/jennifer v1.7.1/go.mod h1:nXbxhEmQfOZhWml3D1cDK5M1FLnMSozpbFN/m3RmGZc= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= diff --git a/hack/check-bazel-drift.sh b/hack/check-bazel-drift.sh index 06c6eb524a0a..bcf4f91dce99 100755 --- a/hack/check-bazel-drift.sh +++ b/hack/check-bazel-drift.sh @@ -21,18 +21,37 @@ arraylength=${#file_list[@]} searchstring="OffchainLabs/prysm/v7/" # Copy pb.go files from bazel-bin to original folder where .proto is. +copied=() for ((i = 0; i < arraylength; i++)); do - color "34" "$destination" destination=${file_list[i]#*$searchstring} - cp -R -L "${file_list[i]}" "$destination" + copied=("${copied[@]}" "$destination") + color "34" "$destination" + # Bazel's protoc output carries no //go:build constraint, while `make gen` + # (build/gen/proto.go) stamps one on the preset-varying pb.go pairs. If the + # committed file leads with a constraint and the Bazel copy does not, + # re-prepend it so both codegen paths produce identical files. + constraint="" + if [ -f "$destination" ]; then + committed_first=$(head -n 1 "$destination") + if [[ "$committed_first" == "//go:build "* && "$(head -n 1 "${file_list[i]}")" != "//go:build "* ]]; then + constraint="$committed_first" + fi + fi + if [ -n "$constraint" ]; then + chmod 755 "$destination" + { printf '%s\n\n' "$constraint"; cat -- "${file_list[i]}"; } > "$destination" + else + cp -R -L "${file_list[i]}" "$destination" + fi chmod 755 "$destination" done -# Run goimports on newly generated protos -# formats imports properly. -# https://github.com/gogo/protobuf/issues/554 -goimports -w proto -gofmt -s -w proto +# Run goimports on the newly copied protos to format imports properly +# (https://github.com/gogo/protobuf/issues/554). Scope it to the files this +# script wrote: reformatting files it didn't touch (e.g. the `make gen` +# authored *.minimal.ssz.go twins) would show up as spurious drift. +goimports -w "${copied[@]}" +gofmt -s -w "${copied[@]}" # --- ssz.go files -------------------------------------------------------- @@ -58,25 +77,22 @@ for ((i = 0; i < arraylength; i++)); do done # --- drift check -------------------------------------------------------- -# After regeneration, the only differences from the committed tree we tolerate -# are the two known-benign ones between this Bazel output and `make gen`: -# - the protoc version header, in some pb.go file: +# After regeneration, the only difference from the committed tree we tolerate +# is the known-benign protoc version header change between this Bazel output +# and `make gen`, in some pb.go files: # -// protoc (unknown) # +// protoc v3.21.7 -# - the leading build constraint, in some pb.go and .ssz.go files: -# -//go:build !minimal -# - # Any other added/removed line under proto/ is real drift and fails the script. +# In particular the //go:build (!)minimal constraints must match: both codegen +# paths stamp them via methodical's --go-build-constraint flag. color "34" "Checking generated-code drift..." # Keep only the diff's added/removed content lines (drop file headers, hunk -# headers and context), then strip out the two known-benign changes. Whatever +# headers and context), then strip out the known-benign change. Whatever # remains is real drift. drift=$(git diff -U0 -- proto | grep -E '^[-+]' | grep -vE '^(---|\+\+\+) ' | # file headers - grep -vE '^-[[:space:]]*$' | # removed blank line - grep -vE '^-//go:build !minimal$' | # removed build constraint grep -vE '^-//[[:space:]]+protoc[[:space:]]+\(unknown\)$' | # old protoc version grep -vE '^\+//[[:space:]]+protoc[[:space:]]+v3\.21\.7$' || true) # new protoc version # `|| true`: a clean tree makes the final grep exit non-zero (no lines left), diff --git a/nogo_config.json b/nogo_config.json index fc0c61159b9a..213ff23716bc 100644 --- a/nogo_config.json +++ b/nogo_config.json @@ -222,6 +222,7 @@ }, "appendclipped": { "exclude_files": { + ".*\\.ssz\\.go": "Generated code is ok", "external/.*": "Third party code" } }, @@ -257,7 +258,8 @@ }, "rangeint": { "exclude_files": { - "external/.*": "Third party code" + "external/.*": "Third party code", + ".*\\.ssz\\.go": "Generated code is ok" } }, "reflecttypefor": { diff --git a/proto/engine/v1/BUILD.bazel b/proto/engine/v1/BUILD.bazel index c8c28521f714..f8c6dceeff78 100644 --- a/proto/engine/v1/BUILD.bazel +++ b/proto/engine/v1/BUILD.bazel @@ -10,7 +10,7 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") load("@rules_proto//proto:defs.bzl", "proto_library") load("//proto:ssz_proto_library.bzl", "ssz_proto_files") -load("//tools:ssz.bzl", "SSZ_DEPS", "ssz_gen_marshal") +load("//tools:methodical.bzl", "ssz_methodical") proto_library( name = "proto", @@ -27,33 +27,13 @@ proto_library( ############################################################################## # Go ############################################################################## -ssz_gen_marshal( - name = "ssz_generated_files", + +ssz_methodical( + name = "methodical_engine", + deps = [":go_proto"], + config_file = "engine.yaml", + override_package_name = "enginev1", out = "engine.ssz.go", - go_proto = ":go_proto", - includes = [ - "//consensus-types/primitives:go_default_library", - ], - objs = [ - "ExecutionPayload", - "ExecutionPayloadCapella", - "ExecutionPayloadHeader", - "ExecutionPayloadHeaderCapella", - "ExecutionPayloadHeaderDeneb", - "ExecutionPayloadDeneb", - "ExecutionPayloadGloas", - "ExecutionPayloadDenebAndBlobsBundle", - "ExecutionPayloadDenebAndBlobsBundleV2", - "BlindedBlobsBundle", - "BlobsBundle", - "BlobsBundleV2", - "Withdrawal", - "WithdrawalRequest", - "DepositRequest", - "ConsolidationRequest", - "ExecutionRequests", - "ExecutionRequestsGloas", - ], ) go_proto_library( @@ -84,7 +64,7 @@ go_library( "fulu.go", "gloas.go", "json_marshal_unmarshal.go", - ":ssz_generated_files", # keep + ":methodical_engine", # keep ], embed = [ ":go_proto", @@ -102,7 +82,6 @@ go_library( "@com_github_ethereum_go_ethereum//core/types:go_default_library", "@com_github_golang_protobuf//proto:go_default_library", "@com_github_pkg_errors//:go_default_library", - "@com_github_prysmaticlabs_fastssz//:go_default_library", "@com_github_sirupsen_logrus//:go_default_library", "@googleapis//google/api:annotations_go_proto", "@io_bazel_rules_go//proto/wkt:descriptor_go_proto", @@ -110,6 +89,7 @@ go_library( "@org_golang_google_protobuf//encoding/protojson:go_default_library", "@org_golang_google_protobuf//reflect/protoreflect:go_default_library", "@org_golang_google_protobuf//runtime/protoimpl:go_default_library", + "@com_github_offchainlabs_methodical_ssz//ssz:go_default_library", ], # keep ) @@ -119,7 +99,7 @@ ssz_proto_files( "electra.proto", "execution_engine.proto", "fulu.proto", - "gloas.proto", + "gloas.proto", ], config = select({ "//conditions:default": "mainnet", diff --git a/proto/engine/v1/engine.minimal.ssz.go b/proto/engine/v1/engine.minimal.ssz.go index 5c9f12ceef7b..fdecf76a4d6d 100644 --- a/proto/engine/v1/engine.minimal.ssz.go +++ b/proto/engine/v1/engine.minimal.ssz.go @@ -1,258 +1,647 @@ //go:build minimal -// Code generated by fastssz. DO NOT EDIT. package enginev1 import ( - github_com_OffchainLabs_prysm_v7_consensus_types_primitives "github.com/OffchainLabs/prysm/v7/consensus-types/primitives" - ssz "github.com/prysmaticlabs/fastssz" + binary "encoding/binary" + "fmt" + ssz "github.com/OffchainLabs/methodical-ssz/ssz" ) -// MarshalSSZ ssz marshals the WithdrawalRequest object -func (w *WithdrawalRequest) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(w) +func (c *BlobsBundle) SizeSSZ() int { + size := 12 + size += len(c.KzgCommitments) * 48 + size += len(c.Proofs) * 48 + size += len(c.Blobs) * 131072 + return size } -// MarshalSSZTo ssz marshals the WithdrawalRequest object to a target array -func (w *WithdrawalRequest) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *BlobsBundle) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (0) 'SourceAddress' - if size := len(w.SourceAddress); size != 20 { - err = ssz.ErrBytesLengthFn("--.SourceAddress", size, 20) - return - } - dst = append(dst, w.SourceAddress...) +func (c *BlobsBundle) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 12 - // Field (1) 'ValidatorPubkey' - if size := len(w.ValidatorPubkey); size != 48 { - err = ssz.ErrBytesLengthFn("--.ValidatorPubkey", size, 48) - return + // Field 0: KzgCommitments + dst = ssz.WriteOffset(dst, offset) + offset += len(c.KzgCommitments) * 48 + + // Field 1: Proofs + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Proofs) * 48 + + // Field 2: Blobs + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Blobs) * 131072 + + // Field 0: KzgCommitments + if len(c.KzgCommitments) > 4096 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.KzgCommitments { + if len(o) != 48 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) } - dst = append(dst, w.ValidatorPubkey...) - // Field (2) 'Amount' - dst = ssz.MarshalUint(dst, w.Amount) + // Field 1: Proofs + if len(c.Proofs) > 4096 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.Proofs { + if len(o) != 48 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) + } - return + // Field 2: Blobs + if len(c.Blobs) > 4096 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.Blobs { + if len(o) != 131072 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the WithdrawalRequest object -func (w *WithdrawalRequest) UnmarshalSSZ(buf []byte) error { +func (c *BlobsBundle) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 76 { + if size < 12 { return ssz.ErrSize } - // Field (0) 'SourceAddress' - if cap(w.SourceAddress) == 0 { - w.SourceAddress = make([]byte, 0, len(buf[0:20])) + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.KzgCommitments + if sszVarOffset0 != 12 { + return ssz.ErrInvalidVariableOffset } - w.SourceAddress = append(w.SourceAddress, buf[0:20]...) + if sszVarOffset0 > size { + return ssz.ErrOffset + } + sszVarOffset1 := ssz.ReadOffset(buf[4:8]) // c.Proofs + if sszVarOffset1 > size || sszVarOffset1 < sszVarOffset0 { + return ssz.ErrOffset + } + sszVarOffset2 := ssz.ReadOffset(buf[8:12]) // c.Blobs + if sszVarOffset2 > size || sszVarOffset2 < sszVarOffset1 { + return ssz.ErrOffset + } + sszSlice0 := buf[sszVarOffset0:sszVarOffset1] // c.KzgCommitments + sszSlice1 := buf[sszVarOffset1:sszVarOffset2] // c.Proofs + sszSlice2 := buf[sszVarOffset2:] // c.Blobs + + // Field 0: KzgCommitments + { + if len(sszSlice0)%48 != 0 { + return fmt.Errorf("misaligned bytes: c.KzgCommitments length is %d, which is not a multiple of 48: %w", len(sszSlice0), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice0) / 48 + if numElem > 4096 { + return fmt.Errorf("ssz-max exceeded: c.KzgCommitments has %d elements, ssz-max is 4096: %w", numElem, ssz.ErrListTooBig) + } + c.KzgCommitments = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte + + tmpSlice := sszSlice0[i*48 : (1+i)*48] + tmp = make([]byte, 0, 48) + tmp = append(tmp, tmpSlice...) + c.KzgCommitments[i] = tmp + } + } + + // Field 1: Proofs + { + if len(sszSlice1)%48 != 0 { + return fmt.Errorf("misaligned bytes: c.Proofs length is %d, which is not a multiple of 48: %w", len(sszSlice1), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice1) / 48 + if numElem > 4096 { + return fmt.Errorf("ssz-max exceeded: c.Proofs has %d elements, ssz-max is 4096: %w", numElem, ssz.ErrListTooBig) + } + c.Proofs = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte - // Field (1) 'ValidatorPubkey' - if cap(w.ValidatorPubkey) == 0 { - w.ValidatorPubkey = make([]byte, 0, len(buf[20:68])) + tmpSlice := sszSlice1[i*48 : (1+i)*48] + tmp = make([]byte, 0, 48) + tmp = append(tmp, tmpSlice...) + c.Proofs[i] = tmp + } } - w.ValidatorPubkey = append(w.ValidatorPubkey, buf[20:68]...) - // Field (2) 'Amount' - w.Amount = ssz.UnmarshallUint[uint64](buf[68:76]) + // Field 2: Blobs + { + if len(sszSlice2)%131072 != 0 { + return fmt.Errorf("misaligned bytes: c.Blobs length is %d, which is not a multiple of 131072: %w", len(sszSlice2), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice2) / 131072 + if numElem > 4096 { + return fmt.Errorf("ssz-max exceeded: c.Blobs has %d elements, ssz-max is 4096: %w", numElem, ssz.ErrListTooBig) + } + c.Blobs = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte + tmpSlice := sszSlice2[i*131072 : (1+i)*131072] + tmp = make([]byte, 0, 131072) + tmp = append(tmp, tmpSlice...) + c.Blobs[i] = tmp + } + } return err } -// SizeSSZ returns the ssz encoded size in bytes for the WithdrawalRequest object -func (w *WithdrawalRequest) SizeSSZ() (size int) { - size = 76 - return +func (c *BlobsBundle) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRoot ssz hashes the WithdrawalRequest object -func (w *WithdrawalRequest) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(w) +func (c *BlobsBundle) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: KzgCommitments + { + if len(c.KzgCommitments) > 4096 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.KzgCommitments { + if len(o) != 48 { + return ssz.ErrBytesLength + } + hh.PutBytes(o) + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.KzgCommitments)), 4096) + } + // Field 1: Proofs + { + if len(c.Proofs) > 4096 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.Proofs { + if len(o) != 48 { + return ssz.ErrBytesLength + } + hh.PutBytes(o) + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Proofs)), 4096) + } + // Field 2: Blobs + { + if len(c.Blobs) > 4096 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.Blobs { + if len(o) != 131072 { + return ssz.ErrBytesLength + } + hh.PutBytes(o) + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Blobs)), 4096) + } + hh.Merkleize(indx) + return nil } -// HashTreeRootWith ssz hashes the WithdrawalRequest object with a hasher -func (w *WithdrawalRequest) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() +func (c *BlobsBundleV2) SizeSSZ() int { + size := 12 + size += len(c.KzgCommitments) * 48 + size += len(c.Proofs) * 48 + size += len(c.Blobs) * 131072 + return size +} - // Field (0) 'SourceAddress' - if size := len(w.SourceAddress); size != 20 { - err = ssz.ErrBytesLengthFn("--.SourceAddress", size, 20) - return - } - hh.PutBytes(w.SourceAddress) +func (c *BlobsBundleV2) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} + +func (c *BlobsBundleV2) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 12 + + // Field 0: KzgCommitments + dst = ssz.WriteOffset(dst, offset) + offset += len(c.KzgCommitments) * 48 + + // Field 1: Proofs + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Proofs) * 48 - // Field (1) 'ValidatorPubkey' - if size := len(w.ValidatorPubkey); size != 48 { - err = ssz.ErrBytesLengthFn("--.ValidatorPubkey", size, 48) - return + // Field 2: Blobs + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Blobs) * 131072 + + // Field 0: KzgCommitments + if len(c.KzgCommitments) > 4096 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.KzgCommitments { + if len(o) != 48 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) } - hh.PutBytes(w.ValidatorPubkey) - // Field (2) 'Amount' - ssz.PutUint(hh, w.Amount) + // Field 1: Proofs + if len(c.Proofs) > 33554432 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.Proofs { + if len(o) != 48 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) + } - hh.Merkleize(indx) - return + // Field 2: Blobs + if len(c.Blobs) > 4096 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.Blobs { + if len(o) != 131072 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) + } + return dst, err } -// MarshalSSZ ssz marshals the DepositRequest object -func (d *DepositRequest) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(d) -} +func (c *BlobsBundleV2) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 12 { + return ssz.ErrSize + } -// MarshalSSZTo ssz marshals the DepositRequest object to a target array -func (d *DepositRequest) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.KzgCommitments + if sszVarOffset0 != 12 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset0 > size { + return ssz.ErrOffset + } + sszVarOffset1 := ssz.ReadOffset(buf[4:8]) // c.Proofs + if sszVarOffset1 > size || sszVarOffset1 < sszVarOffset0 { + return ssz.ErrOffset + } + sszVarOffset2 := ssz.ReadOffset(buf[8:12]) // c.Blobs + if sszVarOffset2 > size || sszVarOffset2 < sszVarOffset1 { + return ssz.ErrOffset + } + sszSlice0 := buf[sszVarOffset0:sszVarOffset1] // c.KzgCommitments + sszSlice1 := buf[sszVarOffset1:sszVarOffset2] // c.Proofs + sszSlice2 := buf[sszVarOffset2:] // c.Blobs - // Field (0) 'Pubkey' - if size := len(d.Pubkey); size != 48 { - err = ssz.ErrBytesLengthFn("--.Pubkey", size, 48) - return + // Field 0: KzgCommitments + { + if len(sszSlice0)%48 != 0 { + return fmt.Errorf("misaligned bytes: c.KzgCommitments length is %d, which is not a multiple of 48: %w", len(sszSlice0), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice0) / 48 + if numElem > 4096 { + return fmt.Errorf("ssz-max exceeded: c.KzgCommitments has %d elements, ssz-max is 4096: %w", numElem, ssz.ErrListTooBig) + } + c.KzgCommitments = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte + + tmpSlice := sszSlice0[i*48 : (1+i)*48] + tmp = make([]byte, 0, 48) + tmp = append(tmp, tmpSlice...) + c.KzgCommitments[i] = tmp + } + } + + // Field 1: Proofs + { + if len(sszSlice1)%48 != 0 { + return fmt.Errorf("misaligned bytes: c.Proofs length is %d, which is not a multiple of 48: %w", len(sszSlice1), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice1) / 48 + if numElem > 33554432 { + return fmt.Errorf("ssz-max exceeded: c.Proofs has %d elements, ssz-max is 33554432: %w", numElem, ssz.ErrListTooBig) + } + c.Proofs = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte + + tmpSlice := sszSlice1[i*48 : (1+i)*48] + tmp = make([]byte, 0, 48) + tmp = append(tmp, tmpSlice...) + c.Proofs[i] = tmp + } } - dst = append(dst, d.Pubkey...) - // Field (1) 'WithdrawalCredentials' - if size := len(d.WithdrawalCredentials); size != 32 { - err = ssz.ErrBytesLengthFn("--.WithdrawalCredentials", size, 32) - return + // Field 2: Blobs + { + if len(sszSlice2)%131072 != 0 { + return fmt.Errorf("misaligned bytes: c.Blobs length is %d, which is not a multiple of 131072: %w", len(sszSlice2), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice2) / 131072 + if numElem > 4096 { + return fmt.Errorf("ssz-max exceeded: c.Blobs has %d elements, ssz-max is 4096: %w", numElem, ssz.ErrListTooBig) + } + c.Blobs = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte + + tmpSlice := sszSlice2[i*131072 : (1+i)*131072] + tmp = make([]byte, 0, 131072) + tmp = append(tmp, tmpSlice...) + c.Blobs[i] = tmp + } } - dst = append(dst, d.WithdrawalCredentials...) + return err +} - // Field (2) 'Amount' - dst = ssz.MarshalUint(dst, d.Amount) +func (c *BlobsBundleV2) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (3) 'Signature' - if size := len(d.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return +func (c *BlobsBundleV2) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: KzgCommitments + { + if len(c.KzgCommitments) > 4096 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.KzgCommitments { + if len(o) != 48 { + return ssz.ErrBytesLength + } + hh.PutBytes(o) + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.KzgCommitments)), 4096) + } + // Field 1: Proofs + { + if len(c.Proofs) > 33554432 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.Proofs { + if len(o) != 48 { + return ssz.ErrBytesLength + } + hh.PutBytes(o) + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Proofs)), 33554432) + } + // Field 2: Blobs + { + if len(c.Blobs) > 4096 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.Blobs { + if len(o) != 131072 { + return ssz.ErrBytesLength + } + hh.PutBytes(o) + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Blobs)), 4096) } - dst = append(dst, d.Signature...) + hh.Merkleize(indx) + return nil +} - // Field (4) 'Index' - dst = ssz.MarshalUint(dst, d.Index) +func (c *BuilderDepositRequest) SizeSSZ() int { + size := 184 - return + return size } -// UnmarshalSSZ ssz unmarshals the DepositRequest object -func (d *DepositRequest) UnmarshalSSZ(buf []byte) error { +func (c *BuilderDepositRequest) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} + +func (c *BuilderDepositRequest) MarshalSSZTo(dst []byte) ([]byte, error) { var err error - size := uint64(len(buf)) - if size != 192 { - return ssz.ErrSize + + // Field 0: Pubkey + if len(c.Pubkey) != 48 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.Pubkey...) - // Field (0) 'Pubkey' - if cap(d.Pubkey) == 0 { - d.Pubkey = make([]byte, 0, len(buf[0:48])) + // Field 1: WithdrawalCredentials + if len(c.WithdrawalCredentials) != 32 { + return nil, ssz.ErrBytesLength } - d.Pubkey = append(d.Pubkey, buf[0:48]...) + dst = append(dst, c.WithdrawalCredentials...) - // Field (1) 'WithdrawalCredentials' - if cap(d.WithdrawalCredentials) == 0 { - d.WithdrawalCredentials = make([]byte, 0, len(buf[48:80])) + // Field 2: Amount + dst = binary.LittleEndian.AppendUint64(dst, c.Amount) + + // Field 3: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } - d.WithdrawalCredentials = append(d.WithdrawalCredentials, buf[48:80]...) + dst = append(dst, c.Signature...) - // Field (2) 'Amount' - d.Amount = ssz.UnmarshallUint[uint64](buf[80:88]) + return dst, err +} - // Field (3) 'Signature' - if cap(d.Signature) == 0 { - d.Signature = make([]byte, 0, len(buf[88:184])) +func (c *BuilderDepositRequest) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 184 { + return ssz.ErrSize } - d.Signature = append(d.Signature, buf[88:184]...) - // Field (4) 'Index' - d.Index = ssz.UnmarshallUint[uint64](buf[184:192]) + sszSlice0 := buf[0:48] // c.Pubkey + sszSlice1 := buf[48:80] // c.WithdrawalCredentials + sszSlice2 := buf[80:88] // c.Amount + sszSlice3 := buf[88:184] // c.Signature + + // Field 0: Pubkey + c.Pubkey = make([]byte, 0, 48) + c.Pubkey = append(c.Pubkey, sszSlice0...) + // Field 1: WithdrawalCredentials + c.WithdrawalCredentials = make([]byte, 0, 32) + c.WithdrawalCredentials = append(c.WithdrawalCredentials, sszSlice1...) + + // Field 2: Amount + c.Amount = binary.LittleEndian.Uint64(sszSlice2) + + // Field 3: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice3...) return err } -// SizeSSZ returns the ssz encoded size in bytes for the DepositRequest object -func (d *DepositRequest) SizeSSZ() (size int) { - size = 192 - return +func (c *BuilderDepositRequest) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} + +func (c *BuilderDepositRequest) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Pubkey + if len(c.Pubkey) != 48 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Pubkey) + // Field 1: WithdrawalCredentials + if len(c.WithdrawalCredentials) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.WithdrawalCredentials) + // Field 2: Amount + hh.PutUint64(c.Amount) + // Field 3: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Signature) + hh.Merkleize(indx) + return nil } -// HashTreeRoot ssz hashes the DepositRequest object -func (d *DepositRequest) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(d) +func (c *BuilderExitRequest) SizeSSZ() int { + size := 68 + + return size } -// HashTreeRootWith ssz hashes the DepositRequest object with a hasher -func (d *DepositRequest) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() +func (c *BuilderExitRequest) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (0) 'Pubkey' - if size := len(d.Pubkey); size != 48 { - err = ssz.ErrBytesLengthFn("--.Pubkey", size, 48) - return +func (c *BuilderExitRequest) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + + // Field 0: SourceAddress + if len(c.SourceAddress) != 20 { + return nil, ssz.ErrBytesLength } - hh.PutBytes(d.Pubkey) + dst = append(dst, c.SourceAddress...) - // Field (1) 'WithdrawalCredentials' - if size := len(d.WithdrawalCredentials); size != 32 { - err = ssz.ErrBytesLengthFn("--.WithdrawalCredentials", size, 32) - return + // Field 1: Pubkey + if len(c.Pubkey) != 48 { + return nil, ssz.ErrBytesLength } - hh.PutBytes(d.WithdrawalCredentials) + dst = append(dst, c.Pubkey...) - // Field (2) 'Amount' - ssz.PutUint(hh, d.Amount) + return dst, err +} - // Field (3) 'Signature' - if size := len(d.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return +func (c *BuilderExitRequest) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 68 { + return ssz.ErrSize } - hh.PutBytes(d.Signature) - // Field (4) 'Index' - ssz.PutUint(hh, d.Index) + sszSlice0 := buf[0:20] // c.SourceAddress + sszSlice1 := buf[20:68] // c.Pubkey + + // Field 0: SourceAddress + c.SourceAddress = make([]byte, 0, 20) + c.SourceAddress = append(c.SourceAddress, sszSlice0...) + + // Field 1: Pubkey + c.Pubkey = make([]byte, 0, 48) + c.Pubkey = append(c.Pubkey, sszSlice1...) + return err +} + +func (c *BuilderExitRequest) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} +func (c *BuilderExitRequest) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: SourceAddress + if len(c.SourceAddress) != 20 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.SourceAddress) + // Field 1: Pubkey + if len(c.Pubkey) != 48 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Pubkey) hh.Merkleize(indx) - return + return nil +} + +func (c *ConsolidationRequest) SizeSSZ() int { + size := 116 + + return size } -// MarshalSSZ ssz marshals the ConsolidationRequest object func (c *ConsolidationRequest) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(c) + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the ConsolidationRequest object to a target array -func (c *ConsolidationRequest) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *ConsolidationRequest) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (0) 'SourceAddress' - if size := len(c.SourceAddress); size != 20 { - err = ssz.ErrBytesLengthFn("--.SourceAddress", size, 20) - return + // Field 0: SourceAddress + if len(c.SourceAddress) != 20 { + return nil, ssz.ErrBytesLength } dst = append(dst, c.SourceAddress...) - // Field (1) 'SourcePubkey' - if size := len(c.SourcePubkey); size != 48 { - err = ssz.ErrBytesLengthFn("--.SourcePubkey", size, 48) - return + // Field 1: SourcePubkey + if len(c.SourcePubkey) != 48 { + return nil, ssz.ErrBytesLength } dst = append(dst, c.SourcePubkey...) - // Field (2) 'TargetPubkey' - if size := len(c.TargetPubkey); size != 48 { - err = ssz.ErrBytesLengthFn("--.TargetPubkey", size, 48) - return + // Field 2: TargetPubkey + if len(c.TargetPubkey) != 48 { + return nil, ssz.ErrBytesLength } dst = append(dst, c.TargetPubkey...) - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the ConsolidationRequest object func (c *ConsolidationRequest) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) @@ -260,4353 +649,3528 @@ func (c *ConsolidationRequest) UnmarshalSSZ(buf []byte) error { 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]...) + sszSlice0 := buf[0:20] // c.SourceAddress + sszSlice1 := buf[20:68] // c.SourcePubkey + sszSlice2 := buf[68:116] // c.TargetPubkey - // 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 0: SourceAddress + c.SourceAddress = make([]byte, 0, 20) + c.SourceAddress = append(c.SourceAddress, sszSlice0...) - // 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]...) + // Field 1: SourcePubkey + c.SourcePubkey = make([]byte, 0, 48) + c.SourcePubkey = append(c.SourcePubkey, sszSlice1...) + // Field 2: TargetPubkey + c.TargetPubkey = make([]byte, 0, 48) + c.TargetPubkey = append(c.TargetPubkey, sszSlice2...) 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) + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the ConsolidationRequest object with a hasher func (c *ConsolidationRequest) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'SourceAddress' - if size := len(c.SourceAddress); size != 20 { - err = ssz.ErrBytesLengthFn("--.SourceAddress", size, 20) - return + // Field 0: SourceAddress + if len(c.SourceAddress) != 20 { + return ssz.ErrBytesLength } hh.PutBytes(c.SourceAddress) - - // Field (1) 'SourcePubkey' - if size := len(c.SourcePubkey); size != 48 { - err = ssz.ErrBytesLengthFn("--.SourcePubkey", size, 48) - return + // Field 1: SourcePubkey + if len(c.SourcePubkey) != 48 { + return ssz.ErrBytesLength } hh.PutBytes(c.SourcePubkey) - - // Field (2) 'TargetPubkey' - if size := len(c.TargetPubkey); size != 48 { - err = ssz.ErrBytesLengthFn("--.TargetPubkey", size, 48) - return + // Field 2: TargetPubkey + if len(c.TargetPubkey) != 48 { + return ssz.ErrBytesLength } hh.PutBytes(c.TargetPubkey) - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the ExecutionRequests object -func (e *ExecutionRequests) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(e) + return nil } -// 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) +func (c *DepositRequest) SizeSSZ() int { + size := 192 - // Offset (0) 'Deposits' - dst = ssz.WriteOffset(dst, offset) - offset += len(e.Deposits) * 192 + return size +} - // Offset (1) 'Withdrawals' - dst = ssz.WriteOffset(dst, offset) - offset += len(e.Withdrawals) * 76 +func (c *DepositRequest) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Offset (2) 'Consolidations' - dst = ssz.WriteOffset(dst, offset) - offset += len(e.Consolidations) * 116 +func (c *DepositRequest) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (0) 'Deposits' - if size := len(e.Deposits); size > 8192 { - err = ssz.ErrListTooBigFn("--.Deposits", size, 8192) - return - } - for ii := 0; ii < len(e.Deposits); ii++ { - if dst, err = e.Deposits[ii].MarshalSSZTo(dst); err != nil { - return - } + // Field 0: Pubkey + if len(c.Pubkey) != 48 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.Pubkey...) - // Field (1) 'Withdrawals' - if size := len(e.Withdrawals); size > 16 { - err = ssz.ErrListTooBigFn("--.Withdrawals", size, 16) - return - } - for ii := 0; ii < len(e.Withdrawals); ii++ { - if dst, err = e.Withdrawals[ii].MarshalSSZTo(dst); err != nil { - return - } + // Field 1: WithdrawalCredentials + if len(c.WithdrawalCredentials) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.WithdrawalCredentials...) - // Field (2) 'Consolidations' - if size := len(e.Consolidations); size > 2 { - err = ssz.ErrListTooBigFn("--.Consolidations", size, 2) - return - } - for ii := 0; ii < len(e.Consolidations); ii++ { - if dst, err = e.Consolidations[ii].MarshalSSZTo(dst); err != nil { - return - } + // Field 2: Amount + dst = binary.LittleEndian.AppendUint64(dst, c.Amount) + + // Field 3: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.Signature...) - return + // Field 4: Index + dst = binary.LittleEndian.AppendUint64(dst, c.Index) + + return dst, err } -// UnmarshalSSZ ssz unmarshals the ExecutionRequests object -func (e *ExecutionRequests) UnmarshalSSZ(buf []byte) error { +func (c *DepositRequest) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 12 { + if size != 192 { return ssz.ErrSize } - tail := buf - var o0, o1, o2 uint64 + sszSlice0 := buf[0:48] // c.Pubkey + sszSlice1 := buf[48:80] // c.WithdrawalCredentials + sszSlice2 := buf[80:88] // c.Amount + sszSlice3 := buf[88:184] // c.Signature + sszSlice4 := buf[184:192] // c.Index - // Offset (0) 'Deposits' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } + // Field 0: Pubkey + c.Pubkey = make([]byte, 0, 48) + c.Pubkey = append(c.Pubkey, sszSlice0...) - if o0 != 12 { - return ssz.ErrInvalidVariableOffset - } + // Field 1: WithdrawalCredentials + c.WithdrawalCredentials = make([]byte, 0, 32) + c.WithdrawalCredentials = append(c.WithdrawalCredentials, sszSlice1...) - // Offset (1) 'Withdrawals' - if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 { - return ssz.ErrOffset - } + // Field 2: Amount + c.Amount = binary.LittleEndian.Uint64(sszSlice2) - // 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 3: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice3...) - // 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 - } - } - } + // Field 4: Index + c.Index = binary.LittleEndian.Uint64(sszSlice4) 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) +func (c *DepositRequest) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the ExecutionRequests object with a hasher -func (e *ExecutionRequests) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *DepositRequest) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() + // Field 0: Pubkey + if len(c.Pubkey) != 48 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Pubkey) + // Field 1: WithdrawalCredentials + if len(c.WithdrawalCredentials) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.WithdrawalCredentials) + // Field 2: Amount + hh.PutUint64(c.Amount) + // Field 3: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Signature) + // Field 4: Index + hh.PutUint64(c.Index) + hh.Merkleize(indx) + return nil +} - // 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) +func (c *ExecutionPayload) SizeSSZ() int { + size := 508 + size += len(c.ExtraData) + for _, o := range c.Transactions { + size += 4 + size += len(o) } - - hh.Merkleize(indx) - return + return size } -// MarshalSSZ ssz marshals the ExecutionPayload object -func (e *ExecutionPayload) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(e) +func (c *ExecutionPayload) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the ExecutionPayload object to a target array -func (e *ExecutionPayload) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(508) +func (c *ExecutionPayload) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 508 - // Field (0) 'ParentHash' - if size := len(e.ParentHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentHash", size, 32) - return + // Field 0: ParentHash + if len(c.ParentHash) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.ParentHash...) + dst = append(dst, c.ParentHash...) - // Field (1) 'FeeRecipient' - if size := len(e.FeeRecipient); size != 20 { - err = ssz.ErrBytesLengthFn("--.FeeRecipient", size, 20) - return + // Field 1: FeeRecipient + if len(c.FeeRecipient) != 20 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.FeeRecipient...) + dst = append(dst, c.FeeRecipient...) - // Field (2) 'StateRoot' - if size := len(e.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return + // Field 2: StateRoot + if len(c.StateRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.StateRoot...) + dst = append(dst, c.StateRoot...) - // Field (3) 'ReceiptsRoot' - if size := len(e.ReceiptsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ReceiptsRoot", size, 32) - return + // Field 3: ReceiptsRoot + if len(c.ReceiptsRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.ReceiptsRoot...) + dst = append(dst, c.ReceiptsRoot...) - // Field (4) 'LogsBloom' - if size := len(e.LogsBloom); size != 256 { - err = ssz.ErrBytesLengthFn("--.LogsBloom", size, 256) - return + // Field 4: LogsBloom + if len(c.LogsBloom) != 256 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.LogsBloom...) + dst = append(dst, c.LogsBloom...) - // Field (5) 'PrevRandao' - if size := len(e.PrevRandao); size != 32 { - err = ssz.ErrBytesLengthFn("--.PrevRandao", size, 32) - return + // Field 5: PrevRandao + if len(c.PrevRandao) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.PrevRandao...) + dst = append(dst, c.PrevRandao...) - // Field (6) 'BlockNumber' - dst = ssz.MarshalUint(dst, e.BlockNumber) + // Field 6: BlockNumber + dst = binary.LittleEndian.AppendUint64(dst, c.BlockNumber) - // Field (7) 'GasLimit' - dst = ssz.MarshalUint(dst, e.GasLimit) + // Field 7: GasLimit + dst = binary.LittleEndian.AppendUint64(dst, c.GasLimit) - // Field (8) 'GasUsed' - dst = ssz.MarshalUint(dst, e.GasUsed) + // Field 8: GasUsed + dst = binary.LittleEndian.AppendUint64(dst, c.GasUsed) - // Field (9) 'Timestamp' - dst = ssz.MarshalUint(dst, e.Timestamp) + // Field 9: Timestamp + dst = binary.LittleEndian.AppendUint64(dst, c.Timestamp) - // Offset (10) 'ExtraData' + // Field 10: ExtraData dst = ssz.WriteOffset(dst, offset) - offset += len(e.ExtraData) + offset += len(c.ExtraData) - // Field (11) 'BaseFeePerGas' - if size := len(e.BaseFeePerGas); size != 32 { - err = ssz.ErrBytesLengthFn("--.BaseFeePerGas", size, 32) - return + // Field 11: BaseFeePerGas + if len(c.BaseFeePerGas) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.BaseFeePerGas...) + dst = append(dst, c.BaseFeePerGas...) - // Field (12) 'BlockHash' - if size := len(e.BlockHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockHash", size, 32) - return + // Field 12: BlockHash + if len(c.BlockHash) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.BlockHash...) + dst = append(dst, c.BlockHash...) - // Offset (13) 'Transactions' + // Field 13: Transactions dst = ssz.WriteOffset(dst, offset) - for ii := 0; ii < len(e.Transactions); ii++ { + for _, o := range c.Transactions { offset += 4 - offset += len(e.Transactions[ii]) + offset += len(o) } - // Field (10) 'ExtraData' - if size := len(e.ExtraData); size > 32 { - err = ssz.ErrBytesLengthFn("--.ExtraData", size, 32) - return + // Field 10: ExtraData + if len(c.ExtraData) > 32 { + return nil, ssz.ErrListTooBig } - dst = append(dst, e.ExtraData...) + dst = append(dst, c.ExtraData...) - // Field (13) 'Transactions' - if size := len(e.Transactions); size > 1048576 { - err = ssz.ErrListTooBigFn("--.Transactions", size, 1048576) - return + // Field 13: Transactions + if len(c.Transactions) > 1048576 { + return nil, ssz.ErrListTooBig } { - offset = 4 * len(e.Transactions) - for ii := 0; ii < len(e.Transactions); ii++ { + offset = 4 * len(c.Transactions) + for _, o := range c.Transactions { dst = ssz.WriteOffset(dst, offset) - offset += len(e.Transactions[ii]) + offset += len(o) } } - for ii := 0; ii < len(e.Transactions); ii++ { - if size := len(e.Transactions[ii]); size > 1073741824 { - err = ssz.ErrBytesLengthFn("--.Transactions[ii]", size, 1073741824) - return + for _, o := range c.Transactions { + if len(o) > 1073741824 { + return nil, ssz.ErrListTooBig } - dst = append(dst, e.Transactions[ii]...) + dst = append(dst, o...) } - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the ExecutionPayload object -func (e *ExecutionPayload) UnmarshalSSZ(buf []byte) error { +func (c *ExecutionPayload) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size < 508 { return ssz.ErrSize } - tail := buf - var o10, o13 uint64 - - // Field (0) 'ParentHash' - if cap(e.ParentHash) == 0 { - e.ParentHash = make([]byte, 0, len(buf[0:32])) + sszSlice0 := buf[0:32] // c.ParentHash + sszSlice1 := buf[32:52] // c.FeeRecipient + sszSlice2 := buf[52:84] // c.StateRoot + sszSlice3 := buf[84:116] // c.ReceiptsRoot + sszSlice4 := buf[116:372] // c.LogsBloom + sszSlice5 := buf[372:404] // c.PrevRandao + sszSlice6 := buf[404:412] // c.BlockNumber + sszSlice7 := buf[412:420] // c.GasLimit + sszSlice8 := buf[420:428] // c.GasUsed + sszSlice9 := buf[428:436] // c.Timestamp + sszSlice11 := buf[440:472] // c.BaseFeePerGas + sszSlice12 := buf[472:504] // c.BlockHash + + sszVarOffset10 := ssz.ReadOffset(buf[436:440]) // c.ExtraData + if sszVarOffset10 != 508 { + return ssz.ErrInvalidVariableOffset } - e.ParentHash = append(e.ParentHash, buf[0:32]...) - - // Field (1) 'FeeRecipient' - if cap(e.FeeRecipient) == 0 { - e.FeeRecipient = make([]byte, 0, len(buf[32:52])) + if sszVarOffset10 > size { + return ssz.ErrOffset } - e.FeeRecipient = append(e.FeeRecipient, buf[32:52]...) - - // Field (2) 'StateRoot' - if cap(e.StateRoot) == 0 { - e.StateRoot = make([]byte, 0, len(buf[52:84])) + sszVarOffset13 := ssz.ReadOffset(buf[504:508]) // c.Transactions + if sszVarOffset13 > size || sszVarOffset13 < sszVarOffset10 { + return ssz.ErrOffset } - e.StateRoot = append(e.StateRoot, buf[52:84]...) + sszSlice10 := buf[sszVarOffset10:sszVarOffset13] // c.ExtraData + sszSlice13 := buf[sszVarOffset13:] // c.Transactions - // Field (3) 'ReceiptsRoot' - if cap(e.ReceiptsRoot) == 0 { - e.ReceiptsRoot = make([]byte, 0, len(buf[84:116])) - } - e.ReceiptsRoot = append(e.ReceiptsRoot, buf[84:116]...) + // Field 0: ParentHash + c.ParentHash = make([]byte, 0, 32) + c.ParentHash = append(c.ParentHash, sszSlice0...) - // Field (4) 'LogsBloom' - if cap(e.LogsBloom) == 0 { - e.LogsBloom = make([]byte, 0, len(buf[116:372])) - } - e.LogsBloom = append(e.LogsBloom, buf[116:372]...) + // Field 1: FeeRecipient + c.FeeRecipient = make([]byte, 0, 20) + c.FeeRecipient = append(c.FeeRecipient, sszSlice1...) - // Field (5) 'PrevRandao' - if cap(e.PrevRandao) == 0 { - e.PrevRandao = make([]byte, 0, len(buf[372:404])) - } - e.PrevRandao = append(e.PrevRandao, buf[372:404]...) + // Field 2: StateRoot + c.StateRoot = make([]byte, 0, 32) + c.StateRoot = append(c.StateRoot, sszSlice2...) - // Field (6) 'BlockNumber' - e.BlockNumber = ssz.UnmarshallUint[uint64](buf[404:412]) + // Field 3: ReceiptsRoot + c.ReceiptsRoot = make([]byte, 0, 32) + c.ReceiptsRoot = append(c.ReceiptsRoot, sszSlice3...) - // Field (7) 'GasLimit' - e.GasLimit = ssz.UnmarshallUint[uint64](buf[412:420]) + // Field 4: LogsBloom + c.LogsBloom = make([]byte, 0, 256) + c.LogsBloom = append(c.LogsBloom, sszSlice4...) - // Field (8) 'GasUsed' - e.GasUsed = ssz.UnmarshallUint[uint64](buf[420:428]) + // Field 5: PrevRandao + c.PrevRandao = make([]byte, 0, 32) + c.PrevRandao = append(c.PrevRandao, sszSlice5...) - // Field (9) 'Timestamp' - e.Timestamp = ssz.UnmarshallUint[uint64](buf[428:436]) + // Field 6: BlockNumber + c.BlockNumber = binary.LittleEndian.Uint64(sszSlice6) - // Offset (10) 'ExtraData' - if o10 = ssz.ReadOffset(buf[436:440]); o10 > size { - return ssz.ErrOffset - } + // Field 7: GasLimit + c.GasLimit = binary.LittleEndian.Uint64(sszSlice7) - if o10 != 508 { - return ssz.ErrInvalidVariableOffset - } + // Field 8: GasUsed + c.GasUsed = binary.LittleEndian.Uint64(sszSlice8) - // Field (11) 'BaseFeePerGas' - if cap(e.BaseFeePerGas) == 0 { - e.BaseFeePerGas = make([]byte, 0, len(buf[440:472])) - } - e.BaseFeePerGas = append(e.BaseFeePerGas, buf[440:472]...) + // Field 9: Timestamp + c.Timestamp = binary.LittleEndian.Uint64(sszSlice9) - // Field (12) 'BlockHash' - if cap(e.BlockHash) == 0 { - e.BlockHash = make([]byte, 0, len(buf[472:504])) - } - e.BlockHash = append(e.BlockHash, buf[472:504]...) + // Field 10: ExtraData + c.ExtraData = append([]byte{}, sszSlice10...) - // Offset (13) 'Transactions' - if o13 = ssz.ReadOffset(buf[504:508]); o13 > size || o10 > o13 { - return ssz.ErrOffset - } + // Field 11: BaseFeePerGas + c.BaseFeePerGas = make([]byte, 0, 32) + c.BaseFeePerGas = append(c.BaseFeePerGas, sszSlice11...) - // 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 12: BlockHash + c.BlockHash = make([]byte, 0, 32) + c.BlockHash = append(c.BlockHash, sszSlice12...) - // Field (13) 'Transactions' + // Field 13: Transactions { - buf = tail[o13:] - 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 + // empty lists are zero length, so make sure there is room for an offset + // before attempting to unmarshal it + if len(sszSlice13) > 3 { + startOffset := ssz.ReadOffset(sszSlice13[0:4]) + if startOffset == 0 { + return fmt.Errorf("encountered invalid offset of 0 when decoding c.Transactions") + } + if startOffset%4 != 0 { + return fmt.Errorf("misaligned list bytes: when decoding c.Transactions, end-of-list offset is %d, which is not a multiple of 4 (offset size)", startOffset) } - if cap(e.Transactions[indx]) == 0 { - e.Transactions[indx] = make([]byte, 0, len(buf)) + listLen := startOffset / 4 + if listLen > 1048576 { + return fmt.Errorf("ssz-max exceeded: c.Transactions has %d elements, ssz-max is 1048576: %w", listLen, ssz.ErrListTooBig) } - e.Transactions[indx] = append(e.Transactions[indx], buf...) - return nil - }) - if err != nil { - return err + totalVarBytes := uint64(len(sszSlice13)) + if totalVarBytes < startOffset { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.Transactions") + } + c.Transactions = make([][]byte, listLen) + var tmpSlice []byte + for i := uint64(0); i < listLen; i++ { + var tmp []byte + + endOffset := totalVarBytes + if i+1 != listLen { + endOffset = ssz.ReadOffset(sszSlice13[(i+1)*4 : (i+2)*4]) + if totalVarBytes < endOffset { + return fmt.Errorf("offset %d points past the end of buffer when decoding c.Transactions", endOffset) + } + } + if endOffset < startOffset { + return fmt.Errorf("offset %d is not greater than start offset %d when decoding c.Transactions", endOffset, startOffset) + } + tmpSlice = sszSlice13[startOffset:endOffset] + tmp = append([]byte{}, tmpSlice...) + c.Transactions[i] = tmp + startOffset = endOffset + } + } else { + if len(sszSlice13) > 0 { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.Transactions") + } + c.Transactions = make([][]byte, 0) } } return err } -// SizeSSZ returns the ssz encoded size in bytes for the ExecutionPayload object -func (e *ExecutionPayload) SizeSSZ() (size int) { - size = 508 - - // 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]) +func (c *ExecutionPayload) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - - return + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// 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.Hasher) (err error) { +func (c *ExecutionPayload) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() + // Field 0: ParentHash + if len(c.ParentHash) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ParentHash) + // Field 1: FeeRecipient + if len(c.FeeRecipient) != 20 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.FeeRecipient) + // Field 2: StateRoot + if len(c.StateRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.StateRoot) + // Field 3: ReceiptsRoot + if len(c.ReceiptsRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ReceiptsRoot) + // Field 4: LogsBloom + if len(c.LogsBloom) != 256 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.LogsBloom) + // Field 5: PrevRandao + if len(c.PrevRandao) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.PrevRandao) + // Field 6: BlockNumber + hh.PutUint64(c.BlockNumber) + // Field 7: GasLimit + hh.PutUint64(c.GasLimit) + // Field 8: GasUsed + hh.PutUint64(c.GasUsed) + // Field 9: Timestamp + hh.PutUint64(c.Timestamp) + // Field 10: ExtraData - // Field (0) 'ParentHash' - if size := len(e.ParentHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentHash", size, 32) - return - } - hh.PutBytes(e.ParentHash) - - // Field (1) 'FeeRecipient' - if size := len(e.FeeRecipient); size != 20 { - err = ssz.ErrBytesLengthFn("--.FeeRecipient", size, 20) - return - } - hh.PutBytes(e.FeeRecipient) - - // Field (2) 'StateRoot' - if size := len(e.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return - } - hh.PutBytes(e.StateRoot) - - // Field (3) 'ReceiptsRoot' - if size := len(e.ReceiptsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ReceiptsRoot", size, 32) - return - } - hh.PutBytes(e.ReceiptsRoot) - - // Field (4) 'LogsBloom' - if size := len(e.LogsBloom); size != 256 { - err = ssz.ErrBytesLengthFn("--.LogsBloom", size, 256) - return - } - hh.PutBytes(e.LogsBloom) - - // Field (5) 'PrevRandao' - if size := len(e.PrevRandao); size != 32 { - err = ssz.ErrBytesLengthFn("--.PrevRandao", size, 32) - return - } - hh.PutBytes(e.PrevRandao) - - // Field (6) 'BlockNumber' - ssz.PutUint(hh, e.BlockNumber) - - // Field (7) 'GasLimit' - ssz.PutUint(hh, e.GasLimit) - - // Field (8) 'GasUsed' - ssz.PutUint(hh, e.GasUsed) - - // Field (9) 'Timestamp' - ssz.PutUint(hh, e.Timestamp) - - // Field (10) 'ExtraData' { - elemIndx := hh.Index() - byteLen := uint64(len(e.ExtraData)) - if byteLen > 32 { - err = ssz.ErrIncorrectListSize - return + if len(c.ExtraData) > 32 { + return ssz.ErrBytesLength } - hh.AppendBytes32(e.ExtraData) - hh.MerkleizeWithMixin(elemIndx, byteLen, (32+31)/32) + subIndx := hh.Index() + hh.AppendBytes32(c.ExtraData) + numItems := uint64(len(c.ExtraData)) + hh.MerkleizeWithMixin(subIndx, numItems, (32*1+31)/32) } - // Field (11) 'BaseFeePerGas' - if size := len(e.BaseFeePerGas); size != 32 { - err = ssz.ErrBytesLengthFn("--.BaseFeePerGas", size, 32) - return + // Field 11: BaseFeePerGas + if len(c.BaseFeePerGas) != 32 { + return ssz.ErrBytesLength } - hh.PutBytes(e.BaseFeePerGas) - - // Field (12) 'BlockHash' - if size := len(e.BlockHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockHash", size, 32) - return + hh.PutBytes(c.BaseFeePerGas) + // Field 12: BlockHash + if len(c.BlockHash) != 32 { + return ssz.ErrBytesLength } - hh.PutBytes(e.BlockHash) - - // Field (13) 'Transactions' + hh.PutBytes(c.BlockHash) + // Field 13: Transactions { - subIndx := hh.Index() - num := uint64(len(e.Transactions)) - if num > 1048576 { - err = ssz.ErrIncorrectListSize - return + if len(c.Transactions) > 1048576 { + return ssz.ErrListTooBig } - for _, elem := range e.Transactions { + subIndx := hh.Index() + for _, o := range c.Transactions { + { - elemIndx := hh.Index() - byteLen := uint64(len(elem)) - if byteLen > 1073741824 { - err = ssz.ErrIncorrectListSize - return + if len(o) > 1073741824 { + return ssz.ErrBytesLength } - hh.AppendBytes32(elem) - hh.MerkleizeWithMixin(elemIndx, byteLen, (1073741824+31)/32) + subIndx := hh.Index() + hh.AppendBytes32(o) + numItems := uint64(len(o)) + hh.MerkleizeWithMixin(subIndx, numItems, (1073741824*1+31)/32) } + } - hh.MerkleizeWithMixin(subIndx, num, 1048576) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Transactions)), 1048576) } - hh.Merkleize(indx) - return + return nil +} + +func (c *ExecutionPayloadCapella) SizeSSZ() int { + size := 512 + size += len(c.ExtraData) + for _, o := range c.Transactions { + size += 4 + size += len(o) + } + size += len(c.Withdrawals) * 44 + return size } -// MarshalSSZ ssz marshals the ExecutionPayloadCapella object -func (e *ExecutionPayloadCapella) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(e) +func (c *ExecutionPayloadCapella) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the ExecutionPayloadCapella object to a target array -func (e *ExecutionPayloadCapella) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(512) +func (c *ExecutionPayloadCapella) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 512 - // Field (0) 'ParentHash' - if size := len(e.ParentHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentHash", size, 32) - return + // Field 0: ParentHash + if len(c.ParentHash) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.ParentHash...) + dst = append(dst, c.ParentHash...) - // Field (1) 'FeeRecipient' - if size := len(e.FeeRecipient); size != 20 { - err = ssz.ErrBytesLengthFn("--.FeeRecipient", size, 20) - return + // Field 1: FeeRecipient + if len(c.FeeRecipient) != 20 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.FeeRecipient...) + dst = append(dst, c.FeeRecipient...) - // Field (2) 'StateRoot' - if size := len(e.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return + // Field 2: StateRoot + if len(c.StateRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.StateRoot...) + dst = append(dst, c.StateRoot...) - // Field (3) 'ReceiptsRoot' - if size := len(e.ReceiptsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ReceiptsRoot", size, 32) - return + // Field 3: ReceiptsRoot + if len(c.ReceiptsRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.ReceiptsRoot...) + dst = append(dst, c.ReceiptsRoot...) - // Field (4) 'LogsBloom' - if size := len(e.LogsBloom); size != 256 { - err = ssz.ErrBytesLengthFn("--.LogsBloom", size, 256) - return + // Field 4: LogsBloom + if len(c.LogsBloom) != 256 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.LogsBloom...) + dst = append(dst, c.LogsBloom...) - // Field (5) 'PrevRandao' - if size := len(e.PrevRandao); size != 32 { - err = ssz.ErrBytesLengthFn("--.PrevRandao", size, 32) - return + // Field 5: PrevRandao + if len(c.PrevRandao) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.PrevRandao...) + dst = append(dst, c.PrevRandao...) - // Field (6) 'BlockNumber' - dst = ssz.MarshalUint(dst, e.BlockNumber) + // Field 6: BlockNumber + dst = binary.LittleEndian.AppendUint64(dst, c.BlockNumber) - // Field (7) 'GasLimit' - dst = ssz.MarshalUint(dst, e.GasLimit) + // Field 7: GasLimit + dst = binary.LittleEndian.AppendUint64(dst, c.GasLimit) - // Field (8) 'GasUsed' - dst = ssz.MarshalUint(dst, e.GasUsed) + // Field 8: GasUsed + dst = binary.LittleEndian.AppendUint64(dst, c.GasUsed) - // Field (9) 'Timestamp' - dst = ssz.MarshalUint(dst, e.Timestamp) + // Field 9: Timestamp + dst = binary.LittleEndian.AppendUint64(dst, c.Timestamp) - // Offset (10) 'ExtraData' + // Field 10: ExtraData dst = ssz.WriteOffset(dst, offset) - offset += len(e.ExtraData) + offset += len(c.ExtraData) - // Field (11) 'BaseFeePerGas' - if size := len(e.BaseFeePerGas); size != 32 { - err = ssz.ErrBytesLengthFn("--.BaseFeePerGas", size, 32) - return + // Field 11: BaseFeePerGas + if len(c.BaseFeePerGas) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.BaseFeePerGas...) + dst = append(dst, c.BaseFeePerGas...) - // Field (12) 'BlockHash' - if size := len(e.BlockHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockHash", size, 32) - return + // Field 12: BlockHash + if len(c.BlockHash) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.BlockHash...) + dst = append(dst, c.BlockHash...) - // Offset (13) 'Transactions' + // Field 13: Transactions dst = ssz.WriteOffset(dst, offset) - for ii := 0; ii < len(e.Transactions); ii++ { + for _, o := range c.Transactions { offset += 4 - offset += len(e.Transactions[ii]) + offset += len(o) } - // Offset (14) 'Withdrawals' + // Field 14: Withdrawals dst = ssz.WriteOffset(dst, offset) - offset += len(e.Withdrawals) * 44 + offset += len(c.Withdrawals) * 44 - // Field (10) 'ExtraData' - if size := len(e.ExtraData); size > 32 { - err = ssz.ErrBytesLengthFn("--.ExtraData", size, 32) - return + // Field 10: ExtraData + if len(c.ExtraData) > 32 { + return nil, ssz.ErrListTooBig } - dst = append(dst, e.ExtraData...) + dst = append(dst, c.ExtraData...) - // Field (13) 'Transactions' - if size := len(e.Transactions); size > 1048576 { - err = ssz.ErrListTooBigFn("--.Transactions", size, 1048576) - return + // Field 13: Transactions + if len(c.Transactions) > 1048576 { + return nil, ssz.ErrListTooBig } { - offset = 4 * len(e.Transactions) - for ii := 0; ii < len(e.Transactions); ii++ { + offset = 4 * len(c.Transactions) + for _, o := range c.Transactions { dst = ssz.WriteOffset(dst, offset) - offset += len(e.Transactions[ii]) + offset += len(o) } } - for ii := 0; ii < len(e.Transactions); ii++ { - if size := len(e.Transactions[ii]); size > 1073741824 { - err = ssz.ErrBytesLengthFn("--.Transactions[ii]", size, 1073741824) - return + for _, o := range c.Transactions { + if len(o) > 1073741824 { + return nil, ssz.ErrListTooBig } - dst = append(dst, e.Transactions[ii]...) + dst = append(dst, o...) } - // Field (14) 'Withdrawals' - if size := len(e.Withdrawals); size > 4 { - err = ssz.ErrListTooBigFn("--.Withdrawals", size, 4) - return + // Field 14: Withdrawals + if len(c.Withdrawals) > 4 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(e.Withdrawals); ii++ { - if dst, err = e.Withdrawals[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.Withdrawals { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Withdrawals: %w", err) } } - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the ExecutionPayloadCapella object -func (e *ExecutionPayloadCapella) UnmarshalSSZ(buf []byte) error { +func (c *ExecutionPayloadCapella) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size < 512 { return ssz.ErrSize } - tail := buf - var o10, o13, o14 uint64 - - // Field (0) 'ParentHash' - if cap(e.ParentHash) == 0 { - e.ParentHash = make([]byte, 0, len(buf[0:32])) + sszSlice0 := buf[0:32] // c.ParentHash + sszSlice1 := buf[32:52] // c.FeeRecipient + sszSlice2 := buf[52:84] // c.StateRoot + sszSlice3 := buf[84:116] // c.ReceiptsRoot + sszSlice4 := buf[116:372] // c.LogsBloom + sszSlice5 := buf[372:404] // c.PrevRandao + sszSlice6 := buf[404:412] // c.BlockNumber + sszSlice7 := buf[412:420] // c.GasLimit + sszSlice8 := buf[420:428] // c.GasUsed + sszSlice9 := buf[428:436] // c.Timestamp + sszSlice11 := buf[440:472] // c.BaseFeePerGas + sszSlice12 := buf[472:504] // c.BlockHash + + sszVarOffset10 := ssz.ReadOffset(buf[436:440]) // c.ExtraData + if sszVarOffset10 != 512 { + return ssz.ErrInvalidVariableOffset } - e.ParentHash = append(e.ParentHash, buf[0:32]...) - - // Field (1) 'FeeRecipient' - if cap(e.FeeRecipient) == 0 { - e.FeeRecipient = make([]byte, 0, len(buf[32:52])) + if sszVarOffset10 > size { + return ssz.ErrOffset } - e.FeeRecipient = append(e.FeeRecipient, buf[32:52]...) - - // Field (2) 'StateRoot' - if cap(e.StateRoot) == 0 { - e.StateRoot = make([]byte, 0, len(buf[52:84])) + sszVarOffset13 := ssz.ReadOffset(buf[504:508]) // c.Transactions + if sszVarOffset13 > size || sszVarOffset13 < sszVarOffset10 { + return ssz.ErrOffset } - e.StateRoot = append(e.StateRoot, buf[52:84]...) - - // Field (3) 'ReceiptsRoot' - if cap(e.ReceiptsRoot) == 0 { - e.ReceiptsRoot = make([]byte, 0, len(buf[84:116])) + sszVarOffset14 := ssz.ReadOffset(buf[508:512]) // c.Withdrawals + if sszVarOffset14 > size || sszVarOffset14 < sszVarOffset13 { + return ssz.ErrOffset } - e.ReceiptsRoot = append(e.ReceiptsRoot, buf[84:116]...) + sszSlice10 := buf[sszVarOffset10:sszVarOffset13] // c.ExtraData + sszSlice13 := buf[sszVarOffset13:sszVarOffset14] // c.Transactions + sszSlice14 := buf[sszVarOffset14:] // c.Withdrawals - // Field (4) 'LogsBloom' - if cap(e.LogsBloom) == 0 { - e.LogsBloom = make([]byte, 0, len(buf[116:372])) - } - e.LogsBloom = append(e.LogsBloom, buf[116:372]...) + // Field 0: ParentHash + c.ParentHash = make([]byte, 0, 32) + c.ParentHash = append(c.ParentHash, sszSlice0...) - // Field (5) 'PrevRandao' - if cap(e.PrevRandao) == 0 { - e.PrevRandao = make([]byte, 0, len(buf[372:404])) - } - e.PrevRandao = append(e.PrevRandao, buf[372:404]...) + // Field 1: FeeRecipient + c.FeeRecipient = make([]byte, 0, 20) + c.FeeRecipient = append(c.FeeRecipient, sszSlice1...) - // Field (6) 'BlockNumber' - e.BlockNumber = ssz.UnmarshallUint[uint64](buf[404:412]) + // Field 2: StateRoot + c.StateRoot = make([]byte, 0, 32) + c.StateRoot = append(c.StateRoot, sszSlice2...) - // Field (7) 'GasLimit' - e.GasLimit = ssz.UnmarshallUint[uint64](buf[412:420]) + // Field 3: ReceiptsRoot + c.ReceiptsRoot = make([]byte, 0, 32) + c.ReceiptsRoot = append(c.ReceiptsRoot, sszSlice3...) - // Field (8) 'GasUsed' - e.GasUsed = ssz.UnmarshallUint[uint64](buf[420:428]) + // Field 4: LogsBloom + c.LogsBloom = make([]byte, 0, 256) + c.LogsBloom = append(c.LogsBloom, sszSlice4...) - // Field (9) 'Timestamp' - e.Timestamp = ssz.UnmarshallUint[uint64](buf[428:436]) + // Field 5: PrevRandao + c.PrevRandao = make([]byte, 0, 32) + c.PrevRandao = append(c.PrevRandao, sszSlice5...) - // Offset (10) 'ExtraData' - if o10 = ssz.ReadOffset(buf[436:440]); o10 > size { - return ssz.ErrOffset - } + // Field 6: BlockNumber + c.BlockNumber = binary.LittleEndian.Uint64(sszSlice6) - if o10 != 512 { - return ssz.ErrInvalidVariableOffset - } + // Field 7: GasLimit + c.GasLimit = binary.LittleEndian.Uint64(sszSlice7) - // Field (11) 'BaseFeePerGas' - if cap(e.BaseFeePerGas) == 0 { - e.BaseFeePerGas = make([]byte, 0, len(buf[440:472])) - } - e.BaseFeePerGas = append(e.BaseFeePerGas, buf[440:472]...) + // Field 8: GasUsed + c.GasUsed = binary.LittleEndian.Uint64(sszSlice8) - // Field (12) 'BlockHash' - if cap(e.BlockHash) == 0 { - e.BlockHash = make([]byte, 0, len(buf[472:504])) - } - e.BlockHash = append(e.BlockHash, buf[472:504]...) + // Field 9: Timestamp + c.Timestamp = binary.LittleEndian.Uint64(sszSlice9) - // Offset (13) 'Transactions' - if o13 = ssz.ReadOffset(buf[504:508]); o13 > size || o10 > o13 { - return ssz.ErrOffset - } + // Field 10: ExtraData + c.ExtraData = append([]byte{}, sszSlice10...) - // Offset (14) 'Withdrawals' - if o14 = ssz.ReadOffset(buf[508:512]); o14 > size || o13 > o14 { - return ssz.ErrOffset - } + // Field 11: BaseFeePerGas + c.BaseFeePerGas = make([]byte, 0, 32) + c.BaseFeePerGas = append(c.BaseFeePerGas, sszSlice11...) - // 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 12: BlockHash + c.BlockHash = make([]byte, 0, 32) + c.BlockHash = append(c.BlockHash, sszSlice12...) - // Field (13) 'Transactions' + // 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 + // empty lists are zero length, so make sure there is room for an offset + // before attempting to unmarshal it + if len(sszSlice13) > 3 { + startOffset := ssz.ReadOffset(sszSlice13[0:4]) + if startOffset == 0 { + return fmt.Errorf("encountered invalid offset of 0 when decoding c.Transactions") + } + if startOffset%4 != 0 { + return fmt.Errorf("misaligned list bytes: when decoding c.Transactions, end-of-list offset is %d, which is not a multiple of 4 (offset size)", startOffset) + } + listLen := startOffset / 4 + if listLen > 1048576 { + return fmt.Errorf("ssz-max exceeded: c.Transactions has %d elements, ssz-max is 1048576: %w", listLen, ssz.ErrListTooBig) } - if cap(e.Transactions[indx]) == 0 { - e.Transactions[indx] = make([]byte, 0, len(buf)) + totalVarBytes := uint64(len(sszSlice13)) + if totalVarBytes < startOffset { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.Transactions") } - e.Transactions[indx] = append(e.Transactions[indx], buf...) - return nil - }) - if err != nil { - return err + c.Transactions = make([][]byte, listLen) + var tmpSlice []byte + for i := uint64(0); i < listLen; i++ { + var tmp []byte + + endOffset := totalVarBytes + if i+1 != listLen { + endOffset = ssz.ReadOffset(sszSlice13[(i+1)*4 : (i+2)*4]) + if totalVarBytes < endOffset { + return fmt.Errorf("offset %d points past the end of buffer when decoding c.Transactions", endOffset) + } + } + if endOffset < startOffset { + return fmt.Errorf("offset %d is not greater than start offset %d when decoding c.Transactions", endOffset, startOffset) + } + tmpSlice = sszSlice13[startOffset:endOffset] + tmp = append([]byte{}, tmpSlice...) + c.Transactions[i] = tmp + startOffset = endOffset + } + } else { + if len(sszSlice13) > 0 { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.Transactions") + } + c.Transactions = make([][]byte, 0) } } - // Field (14) 'Withdrawals' + // Field 14: Withdrawals { - buf = tail[o14:] - num, err := ssz.DivideInt2(len(buf), 44, 4) - 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 + if len(sszSlice14)%44 != 0 { + return fmt.Errorf("misaligned bytes: c.Withdrawals length is %d, which is not a multiple of 44: %w", len(sszSlice14), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice14) / 44 + if numElem > 4 { + return fmt.Errorf("ssz-max exceeded: c.Withdrawals has %d elements, ssz-max is 4: %w", numElem, ssz.ErrListTooBig) + } + c.Withdrawals = make([]*Withdrawal, numElem) + for i := 0; i < numElem; i++ { + var tmp *Withdrawal + tmp = new(Withdrawal) + tmpSlice := sszSlice14[i*44 : (1+i)*44] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Withdrawals: %w", err) } + c.Withdrawals[i] = tmp } } return err } -// SizeSSZ returns the ssz encoded size in bytes for the ExecutionPayloadCapella object -func (e *ExecutionPayloadCapella) SizeSSZ() (size int) { - size = 512 - - // 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]) +func (c *ExecutionPayloadCapella) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - - // Field (14) 'Withdrawals' - size += len(e.Withdrawals) * 44 - - return -} - -// HashTreeRoot ssz hashes the ExecutionPayloadCapella object -func (e *ExecutionPayloadCapella) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(e) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the ExecutionPayloadCapella object with a hasher -func (e *ExecutionPayloadCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *ExecutionPayloadCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() + // Field 0: ParentHash + if len(c.ParentHash) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ParentHash) + // Field 1: FeeRecipient + if len(c.FeeRecipient) != 20 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.FeeRecipient) + // Field 2: StateRoot + if len(c.StateRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.StateRoot) + // Field 3: ReceiptsRoot + if len(c.ReceiptsRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ReceiptsRoot) + // Field 4: LogsBloom + if len(c.LogsBloom) != 256 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.LogsBloom) + // Field 5: PrevRandao + if len(c.PrevRandao) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.PrevRandao) + // Field 6: BlockNumber + hh.PutUint64(c.BlockNumber) + // Field 7: GasLimit + hh.PutUint64(c.GasLimit) + // Field 8: GasUsed + hh.PutUint64(c.GasUsed) + // Field 9: Timestamp + hh.PutUint64(c.Timestamp) + // Field 10: ExtraData - // Field (0) 'ParentHash' - if size := len(e.ParentHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentHash", size, 32) - return - } - hh.PutBytes(e.ParentHash) - - // Field (1) 'FeeRecipient' - if size := len(e.FeeRecipient); size != 20 { - err = ssz.ErrBytesLengthFn("--.FeeRecipient", size, 20) - return - } - hh.PutBytes(e.FeeRecipient) - - // Field (2) 'StateRoot' - if size := len(e.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return - } - hh.PutBytes(e.StateRoot) - - // Field (3) 'ReceiptsRoot' - if size := len(e.ReceiptsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ReceiptsRoot", size, 32) - return - } - hh.PutBytes(e.ReceiptsRoot) - - // Field (4) 'LogsBloom' - if size := len(e.LogsBloom); size != 256 { - err = ssz.ErrBytesLengthFn("--.LogsBloom", size, 256) - return - } - hh.PutBytes(e.LogsBloom) - - // Field (5) 'PrevRandao' - if size := len(e.PrevRandao); size != 32 { - err = ssz.ErrBytesLengthFn("--.PrevRandao", size, 32) - return - } - hh.PutBytes(e.PrevRandao) - - // Field (6) 'BlockNumber' - ssz.PutUint(hh, e.BlockNumber) - - // Field (7) 'GasLimit' - ssz.PutUint(hh, e.GasLimit) - - // Field (8) 'GasUsed' - ssz.PutUint(hh, e.GasUsed) - - // Field (9) 'Timestamp' - ssz.PutUint(hh, e.Timestamp) - - // Field (10) 'ExtraData' { - elemIndx := hh.Index() - byteLen := uint64(len(e.ExtraData)) - if byteLen > 32 { - err = ssz.ErrIncorrectListSize - return + if len(c.ExtraData) > 32 { + return ssz.ErrBytesLength } - hh.AppendBytes32(e.ExtraData) - hh.MerkleizeWithMixin(elemIndx, byteLen, (32+31)/32) + subIndx := hh.Index() + hh.AppendBytes32(c.ExtraData) + numItems := uint64(len(c.ExtraData)) + hh.MerkleizeWithMixin(subIndx, numItems, (32*1+31)/32) } - // Field (11) 'BaseFeePerGas' - if size := len(e.BaseFeePerGas); size != 32 { - err = ssz.ErrBytesLengthFn("--.BaseFeePerGas", size, 32) - return + // Field 11: BaseFeePerGas + if len(c.BaseFeePerGas) != 32 { + return ssz.ErrBytesLength } - hh.PutBytes(e.BaseFeePerGas) - - // Field (12) 'BlockHash' - if size := len(e.BlockHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockHash", size, 32) - return + hh.PutBytes(c.BaseFeePerGas) + // Field 12: BlockHash + if len(c.BlockHash) != 32 { + return ssz.ErrBytesLength } - hh.PutBytes(e.BlockHash) - - // Field (13) 'Transactions' + hh.PutBytes(c.BlockHash) + // Field 13: Transactions { - subIndx := hh.Index() - num := uint64(len(e.Transactions)) - if num > 1048576 { - err = ssz.ErrIncorrectListSize - return + if len(c.Transactions) > 1048576 { + return ssz.ErrListTooBig } - for _, elem := range e.Transactions { + subIndx := hh.Index() + for _, o := range c.Transactions { + { - elemIndx := hh.Index() - byteLen := uint64(len(elem)) - if byteLen > 1073741824 { - err = ssz.ErrIncorrectListSize - return + if len(o) > 1073741824 { + return ssz.ErrBytesLength } - hh.AppendBytes32(elem) - hh.MerkleizeWithMixin(elemIndx, byteLen, (1073741824+31)/32) + subIndx := hh.Index() + hh.AppendBytes32(o) + numItems := uint64(len(o)) + hh.MerkleizeWithMixin(subIndx, numItems, (1073741824*1+31)/32) } + } - hh.MerkleizeWithMixin(subIndx, num, 1048576) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Transactions)), 1048576) } - - // Field (14) 'Withdrawals' + // Field 14: Withdrawals { + if len(c.Withdrawals) > 4 { + return ssz.ErrListTooBig + } subIndx := hh.Index() - num := uint64(len(e.Withdrawals)) - if num > 4 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range e.Withdrawals { - if err = elem.HashTreeRootWith(hh); err != nil { - return + for _, o := range c.Withdrawals { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Withdrawals: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 4) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Withdrawals)), 4) } - hh.Merkleize(indx) - return + return nil +} + +func (c *ExecutionPayloadDeneb) SizeSSZ() int { + size := 528 + size += len(c.ExtraData) + for _, o := range c.Transactions { + size += 4 + size += len(o) + } + size += len(c.Withdrawals) * 44 + return size } -// MarshalSSZ ssz marshals the ExecutionPayloadDeneb object -func (e *ExecutionPayloadDeneb) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(e) +func (c *ExecutionPayloadDeneb) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the ExecutionPayloadDeneb object to a target array -func (e *ExecutionPayloadDeneb) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(528) +func (c *ExecutionPayloadDeneb) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 528 - // Field (0) 'ParentHash' - if size := len(e.ParentHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentHash", size, 32) - return + // Field 0: ParentHash + if len(c.ParentHash) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.ParentHash...) + dst = append(dst, c.ParentHash...) - // Field (1) 'FeeRecipient' - if size := len(e.FeeRecipient); size != 20 { - err = ssz.ErrBytesLengthFn("--.FeeRecipient", size, 20) - return + // Field 1: FeeRecipient + if len(c.FeeRecipient) != 20 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.FeeRecipient...) + dst = append(dst, c.FeeRecipient...) - // Field (2) 'StateRoot' - if size := len(e.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return + // Field 2: StateRoot + if len(c.StateRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.StateRoot...) + dst = append(dst, c.StateRoot...) - // Field (3) 'ReceiptsRoot' - if size := len(e.ReceiptsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ReceiptsRoot", size, 32) - return + // Field 3: ReceiptsRoot + if len(c.ReceiptsRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.ReceiptsRoot...) + dst = append(dst, c.ReceiptsRoot...) - // Field (4) 'LogsBloom' - if size := len(e.LogsBloom); size != 256 { - err = ssz.ErrBytesLengthFn("--.LogsBloom", size, 256) - return + // Field 4: LogsBloom + if len(c.LogsBloom) != 256 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.LogsBloom...) + dst = append(dst, c.LogsBloom...) - // Field (5) 'PrevRandao' - if size := len(e.PrevRandao); size != 32 { - err = ssz.ErrBytesLengthFn("--.PrevRandao", size, 32) - return + // Field 5: PrevRandao + if len(c.PrevRandao) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.PrevRandao...) + dst = append(dst, c.PrevRandao...) - // Field (6) 'BlockNumber' - dst = ssz.MarshalUint(dst, e.BlockNumber) + // Field 6: BlockNumber + dst = binary.LittleEndian.AppendUint64(dst, c.BlockNumber) - // Field (7) 'GasLimit' - dst = ssz.MarshalUint(dst, e.GasLimit) + // Field 7: GasLimit + dst = binary.LittleEndian.AppendUint64(dst, c.GasLimit) - // Field (8) 'GasUsed' - dst = ssz.MarshalUint(dst, e.GasUsed) + // Field 8: GasUsed + dst = binary.LittleEndian.AppendUint64(dst, c.GasUsed) - // Field (9) 'Timestamp' - dst = ssz.MarshalUint(dst, e.Timestamp) + // Field 9: Timestamp + dst = binary.LittleEndian.AppendUint64(dst, c.Timestamp) - // Offset (10) 'ExtraData' + // Field 10: ExtraData dst = ssz.WriteOffset(dst, offset) - offset += len(e.ExtraData) + offset += len(c.ExtraData) - // Field (11) 'BaseFeePerGas' - if size := len(e.BaseFeePerGas); size != 32 { - err = ssz.ErrBytesLengthFn("--.BaseFeePerGas", size, 32) - return + // Field 11: BaseFeePerGas + if len(c.BaseFeePerGas) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.BaseFeePerGas...) + dst = append(dst, c.BaseFeePerGas...) - // Field (12) 'BlockHash' - if size := len(e.BlockHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockHash", size, 32) - return + // Field 12: BlockHash + if len(c.BlockHash) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.BlockHash...) + dst = append(dst, c.BlockHash...) - // Offset (13) 'Transactions' + // Field 13: Transactions dst = ssz.WriteOffset(dst, offset) - for ii := 0; ii < len(e.Transactions); ii++ { + for _, o := range c.Transactions { offset += 4 - offset += len(e.Transactions[ii]) + offset += len(o) } - // Offset (14) 'Withdrawals' + // Field 14: Withdrawals dst = ssz.WriteOffset(dst, offset) - offset += len(e.Withdrawals) * 44 + offset += len(c.Withdrawals) * 44 - // Field (15) 'BlobGasUsed' - dst = ssz.MarshalUint(dst, e.BlobGasUsed) + // Field 15: BlobGasUsed + dst = binary.LittleEndian.AppendUint64(dst, c.BlobGasUsed) - // Field (16) 'ExcessBlobGas' - dst = ssz.MarshalUint(dst, e.ExcessBlobGas) + // Field 16: ExcessBlobGas + dst = binary.LittleEndian.AppendUint64(dst, c.ExcessBlobGas) - // Field (10) 'ExtraData' - if size := len(e.ExtraData); size > 32 { - err = ssz.ErrBytesLengthFn("--.ExtraData", size, 32) - return + // Field 10: ExtraData + if len(c.ExtraData) > 32 { + return nil, ssz.ErrListTooBig } - dst = append(dst, e.ExtraData...) + dst = append(dst, c.ExtraData...) - // Field (13) 'Transactions' - if size := len(e.Transactions); size > 1048576 { - err = ssz.ErrListTooBigFn("--.Transactions", size, 1048576) - return + // Field 13: Transactions + if len(c.Transactions) > 1048576 { + return nil, ssz.ErrListTooBig } { - offset = 4 * len(e.Transactions) - for ii := 0; ii < len(e.Transactions); ii++ { + offset = 4 * len(c.Transactions) + for _, o := range c.Transactions { dst = ssz.WriteOffset(dst, offset) - offset += len(e.Transactions[ii]) + offset += len(o) } } - for ii := 0; ii < len(e.Transactions); ii++ { - if size := len(e.Transactions[ii]); size > 1073741824 { - err = ssz.ErrBytesLengthFn("--.Transactions[ii]", size, 1073741824) - return + for _, o := range c.Transactions { + if len(o) > 1073741824 { + return nil, ssz.ErrListTooBig } - dst = append(dst, e.Transactions[ii]...) + dst = append(dst, o...) } - // Field (14) 'Withdrawals' - if size := len(e.Withdrawals); size > 4 { - err = ssz.ErrListTooBigFn("--.Withdrawals", size, 4) - return + // Field 14: Withdrawals + if len(c.Withdrawals) > 4 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(e.Withdrawals); ii++ { - if dst, err = e.Withdrawals[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.Withdrawals { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Withdrawals: %w", err) } } - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the ExecutionPayloadDeneb object -func (e *ExecutionPayloadDeneb) UnmarshalSSZ(buf []byte) error { +func (c *ExecutionPayloadDeneb) 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' - if cap(e.ParentHash) == 0 { - e.ParentHash = make([]byte, 0, len(buf[0:32])) - } - e.ParentHash = append(e.ParentHash, buf[0:32]...) - - // Field (1) 'FeeRecipient' - if cap(e.FeeRecipient) == 0 { - e.FeeRecipient = make([]byte, 0, len(buf[32:52])) - } - e.FeeRecipient = append(e.FeeRecipient, buf[32:52]...) - - // Field (2) 'StateRoot' - if cap(e.StateRoot) == 0 { - e.StateRoot = make([]byte, 0, len(buf[52:84])) + sszSlice0 := buf[0:32] // c.ParentHash + sszSlice1 := buf[32:52] // c.FeeRecipient + sszSlice2 := buf[52:84] // c.StateRoot + sszSlice3 := buf[84:116] // c.ReceiptsRoot + sszSlice4 := buf[116:372] // c.LogsBloom + sszSlice5 := buf[372:404] // c.PrevRandao + sszSlice6 := buf[404:412] // c.BlockNumber + sszSlice7 := buf[412:420] // c.GasLimit + sszSlice8 := buf[420:428] // c.GasUsed + sszSlice9 := buf[428:436] // c.Timestamp + sszSlice11 := buf[440:472] // c.BaseFeePerGas + sszSlice12 := buf[472:504] // c.BlockHash + sszSlice15 := buf[512:520] // c.BlobGasUsed + sszSlice16 := buf[520:528] // c.ExcessBlobGas + + sszVarOffset10 := ssz.ReadOffset(buf[436:440]) // c.ExtraData + if sszVarOffset10 != 528 { + return ssz.ErrInvalidVariableOffset } - e.StateRoot = append(e.StateRoot, buf[52:84]...) - - // Field (3) 'ReceiptsRoot' - if cap(e.ReceiptsRoot) == 0 { - e.ReceiptsRoot = make([]byte, 0, len(buf[84:116])) + if sszVarOffset10 > size { + return ssz.ErrOffset } - e.ReceiptsRoot = append(e.ReceiptsRoot, buf[84:116]...) - - // Field (4) 'LogsBloom' - if cap(e.LogsBloom) == 0 { - e.LogsBloom = make([]byte, 0, len(buf[116:372])) + sszVarOffset13 := ssz.ReadOffset(buf[504:508]) // c.Transactions + if sszVarOffset13 > size || sszVarOffset13 < sszVarOffset10 { + return ssz.ErrOffset } - e.LogsBloom = append(e.LogsBloom, buf[116:372]...) - - // Field (5) 'PrevRandao' - if cap(e.PrevRandao) == 0 { - e.PrevRandao = make([]byte, 0, len(buf[372:404])) + sszVarOffset14 := ssz.ReadOffset(buf[508:512]) // c.Withdrawals + if sszVarOffset14 > size || sszVarOffset14 < sszVarOffset13 { + return ssz.ErrOffset } - e.PrevRandao = append(e.PrevRandao, buf[372:404]...) + sszSlice10 := buf[sszVarOffset10:sszVarOffset13] // c.ExtraData + sszSlice13 := buf[sszVarOffset13:sszVarOffset14] // c.Transactions + sszSlice14 := buf[sszVarOffset14:] // c.Withdrawals - // Field (6) 'BlockNumber' - e.BlockNumber = ssz.UnmarshallUint[uint64](buf[404:412]) + // Field 0: ParentHash + c.ParentHash = make([]byte, 0, 32) + c.ParentHash = append(c.ParentHash, sszSlice0...) - // Field (7) 'GasLimit' - e.GasLimit = ssz.UnmarshallUint[uint64](buf[412:420]) + // Field 1: FeeRecipient + c.FeeRecipient = make([]byte, 0, 20) + c.FeeRecipient = append(c.FeeRecipient, sszSlice1...) - // Field (8) 'GasUsed' - e.GasUsed = ssz.UnmarshallUint[uint64](buf[420:428]) + // Field 2: StateRoot + c.StateRoot = make([]byte, 0, 32) + c.StateRoot = append(c.StateRoot, sszSlice2...) - // Field (9) 'Timestamp' - e.Timestamp = ssz.UnmarshallUint[uint64](buf[428:436]) + // Field 3: ReceiptsRoot + c.ReceiptsRoot = make([]byte, 0, 32) + c.ReceiptsRoot = append(c.ReceiptsRoot, sszSlice3...) - // Offset (10) 'ExtraData' - if o10 = ssz.ReadOffset(buf[436:440]); o10 > size { - return ssz.ErrOffset - } + // Field 4: LogsBloom + c.LogsBloom = make([]byte, 0, 256) + c.LogsBloom = append(c.LogsBloom, sszSlice4...) - if o10 != 528 { - return ssz.ErrInvalidVariableOffset - } + // Field 5: PrevRandao + c.PrevRandao = make([]byte, 0, 32) + c.PrevRandao = append(c.PrevRandao, sszSlice5...) - // Field (11) 'BaseFeePerGas' - if cap(e.BaseFeePerGas) == 0 { - e.BaseFeePerGas = make([]byte, 0, len(buf[440:472])) - } - e.BaseFeePerGas = append(e.BaseFeePerGas, buf[440:472]...) + // Field 6: BlockNumber + c.BlockNumber = binary.LittleEndian.Uint64(sszSlice6) - // Field (12) 'BlockHash' - if cap(e.BlockHash) == 0 { - e.BlockHash = make([]byte, 0, len(buf[472:504])) - } - e.BlockHash = append(e.BlockHash, buf[472:504]...) + // Field 7: GasLimit + c.GasLimit = binary.LittleEndian.Uint64(sszSlice7) - // Offset (13) 'Transactions' - if o13 = ssz.ReadOffset(buf[504:508]); o13 > size || o10 > o13 { - return ssz.ErrOffset - } + // Field 8: GasUsed + c.GasUsed = binary.LittleEndian.Uint64(sszSlice8) - // Offset (14) 'Withdrawals' - if o14 = ssz.ReadOffset(buf[508:512]); o14 > size || o13 > o14 { - return ssz.ErrOffset - } + // Field 9: Timestamp + c.Timestamp = binary.LittleEndian.Uint64(sszSlice9) - // Field (15) 'BlobGasUsed' - e.BlobGasUsed = ssz.UnmarshallUint[uint64](buf[512:520]) + // Field 10: ExtraData + c.ExtraData = append([]byte{}, sszSlice10...) - // Field (16) 'ExcessBlobGas' - e.ExcessBlobGas = ssz.UnmarshallUint[uint64](buf[520:528]) + // Field 11: BaseFeePerGas + c.BaseFeePerGas = make([]byte, 0, 32) + c.BaseFeePerGas = append(c.BaseFeePerGas, sszSlice11...) - // 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 12: BlockHash + c.BlockHash = make([]byte, 0, 32) + c.BlockHash = append(c.BlockHash, sszSlice12...) - // Field (13) 'Transactions' + // 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 + // empty lists are zero length, so make sure there is room for an offset + // before attempting to unmarshal it + if len(sszSlice13) > 3 { + startOffset := ssz.ReadOffset(sszSlice13[0:4]) + if startOffset == 0 { + return fmt.Errorf("encountered invalid offset of 0 when decoding c.Transactions") + } + if startOffset%4 != 0 { + return fmt.Errorf("misaligned list bytes: when decoding c.Transactions, end-of-list offset is %d, which is not a multiple of 4 (offset size)", startOffset) + } + listLen := startOffset / 4 + if listLen > 1048576 { + return fmt.Errorf("ssz-max exceeded: c.Transactions has %d elements, ssz-max is 1048576: %w", listLen, ssz.ErrListTooBig) + } + totalVarBytes := uint64(len(sszSlice13)) + if totalVarBytes < startOffset { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.Transactions") } - if cap(e.Transactions[indx]) == 0 { - e.Transactions[indx] = make([]byte, 0, len(buf)) + c.Transactions = make([][]byte, listLen) + var tmpSlice []byte + for i := uint64(0); i < listLen; i++ { + var tmp []byte + + endOffset := totalVarBytes + if i+1 != listLen { + endOffset = ssz.ReadOffset(sszSlice13[(i+1)*4 : (i+2)*4]) + if totalVarBytes < endOffset { + return fmt.Errorf("offset %d points past the end of buffer when decoding c.Transactions", endOffset) + } + } + if endOffset < startOffset { + return fmt.Errorf("offset %d is not greater than start offset %d when decoding c.Transactions", endOffset, startOffset) + } + tmpSlice = sszSlice13[startOffset:endOffset] + tmp = append([]byte{}, tmpSlice...) + c.Transactions[i] = tmp + startOffset = endOffset } - e.Transactions[indx] = append(e.Transactions[indx], buf...) - return nil - }) - if err != nil { - return err + } else { + if len(sszSlice13) > 0 { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.Transactions") + } + c.Transactions = make([][]byte, 0) } } - // Field (14) 'Withdrawals' + // Field 14: Withdrawals { - buf = tail[o14:] - num, err := ssz.DivideInt2(len(buf), 44, 4) - 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 + if len(sszSlice14)%44 != 0 { + return fmt.Errorf("misaligned bytes: c.Withdrawals length is %d, which is not a multiple of 44: %w", len(sszSlice14), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice14) / 44 + if numElem > 4 { + return fmt.Errorf("ssz-max exceeded: c.Withdrawals has %d elements, ssz-max is 4: %w", numElem, ssz.ErrListTooBig) + } + c.Withdrawals = make([]*Withdrawal, numElem) + for i := 0; i < numElem; i++ { + var tmp *Withdrawal + tmp = new(Withdrawal) + tmpSlice := sszSlice14[i*44 : (1+i)*44] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Withdrawals: %w", err) } + c.Withdrawals[i] = tmp } } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the ExecutionPayloadDeneb object -func (e *ExecutionPayloadDeneb) 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 15: BlobGasUsed + c.BlobGasUsed = binary.LittleEndian.Uint64(sszSlice15) - // Field (14) 'Withdrawals' - size += len(e.Withdrawals) * 44 - - return + // Field 16: ExcessBlobGas + c.ExcessBlobGas = binary.LittleEndian.Uint64(sszSlice16) + return err } -// HashTreeRoot ssz hashes the ExecutionPayloadDeneb object -func (e *ExecutionPayloadDeneb) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(e) +func (c *ExecutionPayloadDeneb) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the ExecutionPayloadDeneb object with a hasher -func (e *ExecutionPayloadDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *ExecutionPayloadDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() + // Field 0: ParentHash + if len(c.ParentHash) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ParentHash) + // Field 1: FeeRecipient + if len(c.FeeRecipient) != 20 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.FeeRecipient) + // Field 2: StateRoot + if len(c.StateRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.StateRoot) + // Field 3: ReceiptsRoot + if len(c.ReceiptsRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ReceiptsRoot) + // Field 4: LogsBloom + if len(c.LogsBloom) != 256 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.LogsBloom) + // Field 5: PrevRandao + if len(c.PrevRandao) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.PrevRandao) + // Field 6: BlockNumber + hh.PutUint64(c.BlockNumber) + // Field 7: GasLimit + hh.PutUint64(c.GasLimit) + // Field 8: GasUsed + hh.PutUint64(c.GasUsed) + // Field 9: Timestamp + hh.PutUint64(c.Timestamp) + // Field 10: ExtraData - // Field (0) 'ParentHash' - if size := len(e.ParentHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentHash", size, 32) - return - } - hh.PutBytes(e.ParentHash) - - // Field (1) 'FeeRecipient' - if size := len(e.FeeRecipient); size != 20 { - err = ssz.ErrBytesLengthFn("--.FeeRecipient", size, 20) - return - } - hh.PutBytes(e.FeeRecipient) - - // Field (2) 'StateRoot' - if size := len(e.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return - } - hh.PutBytes(e.StateRoot) - - // Field (3) 'ReceiptsRoot' - if size := len(e.ReceiptsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ReceiptsRoot", size, 32) - return - } - hh.PutBytes(e.ReceiptsRoot) - - // Field (4) 'LogsBloom' - if size := len(e.LogsBloom); size != 256 { - err = ssz.ErrBytesLengthFn("--.LogsBloom", size, 256) - return - } - hh.PutBytes(e.LogsBloom) - - // Field (5) 'PrevRandao' - if size := len(e.PrevRandao); size != 32 { - err = ssz.ErrBytesLengthFn("--.PrevRandao", size, 32) - return - } - hh.PutBytes(e.PrevRandao) - - // Field (6) 'BlockNumber' - ssz.PutUint(hh, e.BlockNumber) - - // Field (7) 'GasLimit' - ssz.PutUint(hh, e.GasLimit) - - // Field (8) 'GasUsed' - ssz.PutUint(hh, e.GasUsed) - - // Field (9) 'Timestamp' - ssz.PutUint(hh, e.Timestamp) - - // Field (10) 'ExtraData' { - elemIndx := hh.Index() - byteLen := uint64(len(e.ExtraData)) - if byteLen > 32 { - err = ssz.ErrIncorrectListSize - return + if len(c.ExtraData) > 32 { + return ssz.ErrBytesLength } - hh.AppendBytes32(e.ExtraData) - hh.MerkleizeWithMixin(elemIndx, byteLen, (32+31)/32) + subIndx := hh.Index() + hh.AppendBytes32(c.ExtraData) + numItems := uint64(len(c.ExtraData)) + hh.MerkleizeWithMixin(subIndx, numItems, (32*1+31)/32) } - // Field (11) 'BaseFeePerGas' - if size := len(e.BaseFeePerGas); size != 32 { - err = ssz.ErrBytesLengthFn("--.BaseFeePerGas", size, 32) - return + // Field 11: BaseFeePerGas + if len(c.BaseFeePerGas) != 32 { + return ssz.ErrBytesLength } - hh.PutBytes(e.BaseFeePerGas) - - // Field (12) 'BlockHash' - if size := len(e.BlockHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockHash", size, 32) - return + hh.PutBytes(c.BaseFeePerGas) + // Field 12: BlockHash + if len(c.BlockHash) != 32 { + return ssz.ErrBytesLength } - hh.PutBytes(e.BlockHash) - - // Field (13) 'Transactions' + hh.PutBytes(c.BlockHash) + // Field 13: Transactions { - subIndx := hh.Index() - num := uint64(len(e.Transactions)) - if num > 1048576 { - err = ssz.ErrIncorrectListSize - return + if len(c.Transactions) > 1048576 { + return ssz.ErrListTooBig } - for _, elem := range e.Transactions { + subIndx := hh.Index() + for _, o := range c.Transactions { + { - elemIndx := hh.Index() - byteLen := uint64(len(elem)) - if byteLen > 1073741824 { - err = ssz.ErrIncorrectListSize - return + if len(o) > 1073741824 { + return ssz.ErrBytesLength } - hh.AppendBytes32(elem) - hh.MerkleizeWithMixin(elemIndx, byteLen, (1073741824+31)/32) + subIndx := hh.Index() + hh.AppendBytes32(o) + numItems := uint64(len(o)) + hh.MerkleizeWithMixin(subIndx, numItems, (1073741824*1+31)/32) } + } - hh.MerkleizeWithMixin(subIndx, num, 1048576) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Transactions)), 1048576) } - - // Field (14) 'Withdrawals' + // Field 14: Withdrawals { + if len(c.Withdrawals) > 4 { + return ssz.ErrListTooBig + } subIndx := hh.Index() - num := uint64(len(e.Withdrawals)) - if num > 4 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range e.Withdrawals { - if err = elem.HashTreeRootWith(hh); err != nil { - return + for _, o := range c.Withdrawals { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Withdrawals: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 4) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Withdrawals)), 4) } - - // Field (15) 'BlobGasUsed' - ssz.PutUint(hh, e.BlobGasUsed) - - // Field (16) 'ExcessBlobGas' - ssz.PutUint(hh, e.ExcessBlobGas) - + // Field 15: BlobGasUsed + hh.PutUint64(c.BlobGasUsed) + // Field 16: ExcessBlobGas + hh.PutUint64(c.ExcessBlobGas) hh.Merkleize(indx) - return + return nil +} + +func (c *ExecutionPayloadGloas) SizeSSZ() int { + size := 540 + size += len(c.ExtraData) + for _, o := range c.Transactions { + size += 4 + size += len(o) + } + size += len(c.Withdrawals) * 44 + size += len(c.BlockAccessList) + return size } -// MarshalSSZ ssz marshals the ExecutionPayloadGloas object -func (e *ExecutionPayloadGloas) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(e) +func (c *ExecutionPayloadGloas) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the ExecutionPayloadGloas object to a target array -func (e *ExecutionPayloadGloas) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(540) +func (c *ExecutionPayloadGloas) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 540 - // Field (0) 'ParentHash' - if size := len(e.ParentHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentHash", size, 32) - return + // Field 0: ParentHash + if len(c.ParentHash) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.ParentHash...) + dst = append(dst, c.ParentHash...) - // Field (1) 'FeeRecipient' - if size := len(e.FeeRecipient); size != 20 { - err = ssz.ErrBytesLengthFn("--.FeeRecipient", size, 20) - return + // Field 1: FeeRecipient + if len(c.FeeRecipient) != 20 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.FeeRecipient...) + dst = append(dst, c.FeeRecipient...) - // Field (2) 'StateRoot' - if size := len(e.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return + // Field 2: StateRoot + if len(c.StateRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.StateRoot...) + dst = append(dst, c.StateRoot...) - // Field (3) 'ReceiptsRoot' - if size := len(e.ReceiptsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ReceiptsRoot", size, 32) - return + // Field 3: ReceiptsRoot + if len(c.ReceiptsRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.ReceiptsRoot...) + dst = append(dst, c.ReceiptsRoot...) - // Field (4) 'LogsBloom' - if size := len(e.LogsBloom); size != 256 { - err = ssz.ErrBytesLengthFn("--.LogsBloom", size, 256) - return + // Field 4: LogsBloom + if len(c.LogsBloom) != 256 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.LogsBloom...) + dst = append(dst, c.LogsBloom...) - // Field (5) 'PrevRandao' - if size := len(e.PrevRandao); size != 32 { - err = ssz.ErrBytesLengthFn("--.PrevRandao", size, 32) - return + // Field 5: PrevRandao + if len(c.PrevRandao) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.PrevRandao...) + dst = append(dst, c.PrevRandao...) - // Field (6) 'BlockNumber' - dst = ssz.MarshalUint(dst, e.BlockNumber) + // Field 6: BlockNumber + dst = binary.LittleEndian.AppendUint64(dst, c.BlockNumber) - // Field (7) 'GasLimit' - dst = ssz.MarshalUint(dst, e.GasLimit) + // Field 7: GasLimit + dst = binary.LittleEndian.AppendUint64(dst, c.GasLimit) - // Field (8) 'GasUsed' - dst = ssz.MarshalUint(dst, e.GasUsed) + // Field 8: GasUsed + dst = binary.LittleEndian.AppendUint64(dst, c.GasUsed) - // Field (9) 'Timestamp' - dst = ssz.MarshalUint(dst, e.Timestamp) + // Field 9: Timestamp + dst = binary.LittleEndian.AppendUint64(dst, c.Timestamp) - // Offset (10) 'ExtraData' + // Field 10: ExtraData dst = ssz.WriteOffset(dst, offset) - offset += len(e.ExtraData) + offset += len(c.ExtraData) - // Field (11) 'BaseFeePerGas' - if size := len(e.BaseFeePerGas); size != 32 { - err = ssz.ErrBytesLengthFn("--.BaseFeePerGas", size, 32) - return + // Field 11: BaseFeePerGas + if len(c.BaseFeePerGas) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.BaseFeePerGas...) + dst = append(dst, c.BaseFeePerGas...) - // Field (12) 'BlockHash' - if size := len(e.BlockHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockHash", size, 32) - return + // Field 12: BlockHash + if len(c.BlockHash) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.BlockHash...) + dst = append(dst, c.BlockHash...) - // Offset (13) 'Transactions' + // Field 13: Transactions dst = ssz.WriteOffset(dst, offset) - for ii := 0; ii < len(e.Transactions); ii++ { + for _, o := range c.Transactions { offset += 4 - offset += len(e.Transactions[ii]) + offset += len(o) } - // Offset (14) 'Withdrawals' + // Field 14: Withdrawals dst = ssz.WriteOffset(dst, offset) - offset += len(e.Withdrawals) * 44 + offset += len(c.Withdrawals) * 44 - // Field (15) 'BlobGasUsed' - dst = ssz.MarshalUint(dst, e.BlobGasUsed) + // Field 15: BlobGasUsed + dst = binary.LittleEndian.AppendUint64(dst, c.BlobGasUsed) - // Field (16) 'ExcessBlobGas' - dst = ssz.MarshalUint(dst, e.ExcessBlobGas) + // Field 16: ExcessBlobGas + dst = binary.LittleEndian.AppendUint64(dst, c.ExcessBlobGas) - // Offset (17) 'BlockAccessList' + // Field 17: BlockAccessList dst = ssz.WriteOffset(dst, offset) - offset += len(e.BlockAccessList) + offset += len(c.BlockAccessList) - // Field (18) 'SlotNumber' - dst = ssz.MarshalUint(dst, e.SlotNumber) + // Field 18: SlotNumber + if dst, err = c.SlotNumber.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SlotNumber: %w", err) + } - // Field (10) 'ExtraData' - if size := len(e.ExtraData); size > 32 { - err = ssz.ErrBytesLengthFn("--.ExtraData", size, 32) - return + // Field 10: ExtraData + if len(c.ExtraData) > 32 { + return nil, ssz.ErrListTooBig } - dst = append(dst, e.ExtraData...) + dst = append(dst, c.ExtraData...) - // Field (13) 'Transactions' - if size := len(e.Transactions); size > 1048576 { - err = ssz.ErrListTooBigFn("--.Transactions", size, 1048576) - return + // Field 13: Transactions + if len(c.Transactions) > 1048576 { + return nil, ssz.ErrListTooBig } { - offset = 4 * len(e.Transactions) - for ii := 0; ii < len(e.Transactions); ii++ { + offset = 4 * len(c.Transactions) + for _, o := range c.Transactions { dst = ssz.WriteOffset(dst, offset) - offset += len(e.Transactions[ii]) + offset += len(o) } } - for ii := 0; ii < len(e.Transactions); ii++ { - if size := len(e.Transactions[ii]); size > 1073741824 { - err = ssz.ErrBytesLengthFn("--.Transactions[ii]", size, 1073741824) - return + for _, o := range c.Transactions { + if len(o) > 1073741824 { + return nil, ssz.ErrListTooBig } - dst = append(dst, e.Transactions[ii]...) + dst = append(dst, o...) } - // Field (14) 'Withdrawals' - if size := len(e.Withdrawals); size > 4 { - err = ssz.ErrListTooBigFn("--.Withdrawals", size, 4) - return + // Field 14: Withdrawals + if len(c.Withdrawals) > 4 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(e.Withdrawals); ii++ { - if dst, err = e.Withdrawals[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.Withdrawals { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Withdrawals: %w", err) } } - // Field (17) 'BlockAccessList' - if size := len(e.BlockAccessList); size > 1073741824 { - err = ssz.ErrBytesLengthFn("--.BlockAccessList", size, 1073741824) - return + // Field 17: BlockAccessList + if len(c.BlockAccessList) > 1073741824 { + return nil, ssz.ErrListTooBig } - dst = append(dst, e.BlockAccessList...) - - return + dst = append(dst, c.BlockAccessList...) + return dst, err } -// UnmarshalSSZ ssz unmarshals the ExecutionPayloadGloas object -func (e *ExecutionPayloadGloas) UnmarshalSSZ(buf []byte) error { +func (c *ExecutionPayloadGloas) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size < 540 { return ssz.ErrSize } - tail := buf - var o10, o13, o14, o17 uint64 - - // Field (0) 'ParentHash' - if cap(e.ParentHash) == 0 { - e.ParentHash = make([]byte, 0, len(buf[0:32])) - } - e.ParentHash = append(e.ParentHash, buf[0:32]...) - - // Field (1) 'FeeRecipient' - if cap(e.FeeRecipient) == 0 { - e.FeeRecipient = make([]byte, 0, len(buf[32:52])) + sszSlice0 := buf[0:32] // c.ParentHash + sszSlice1 := buf[32:52] // c.FeeRecipient + sszSlice2 := buf[52:84] // c.StateRoot + sszSlice3 := buf[84:116] // c.ReceiptsRoot + sszSlice4 := buf[116:372] // c.LogsBloom + sszSlice5 := buf[372:404] // c.PrevRandao + sszSlice6 := buf[404:412] // c.BlockNumber + sszSlice7 := buf[412:420] // c.GasLimit + sszSlice8 := buf[420:428] // c.GasUsed + sszSlice9 := buf[428:436] // c.Timestamp + sszSlice11 := buf[440:472] // c.BaseFeePerGas + sszSlice12 := buf[472:504] // c.BlockHash + sszSlice15 := buf[512:520] // c.BlobGasUsed + sszSlice16 := buf[520:528] // c.ExcessBlobGas + sszSlice18 := buf[532:540] // c.SlotNumber + + sszVarOffset10 := ssz.ReadOffset(buf[436:440]) // c.ExtraData + if sszVarOffset10 != 540 { + return ssz.ErrInvalidVariableOffset } - e.FeeRecipient = append(e.FeeRecipient, buf[32:52]...) - - // Field (2) 'StateRoot' - if cap(e.StateRoot) == 0 { - e.StateRoot = make([]byte, 0, len(buf[52:84])) + if sszVarOffset10 > size { + return ssz.ErrOffset } - e.StateRoot = append(e.StateRoot, buf[52:84]...) - - // Field (3) 'ReceiptsRoot' - if cap(e.ReceiptsRoot) == 0 { - e.ReceiptsRoot = make([]byte, 0, len(buf[84:116])) + sszVarOffset13 := ssz.ReadOffset(buf[504:508]) // c.Transactions + if sszVarOffset13 > size || sszVarOffset13 < sszVarOffset10 { + return ssz.ErrOffset } - e.ReceiptsRoot = append(e.ReceiptsRoot, buf[84:116]...) - - // Field (4) 'LogsBloom' - if cap(e.LogsBloom) == 0 { - e.LogsBloom = make([]byte, 0, len(buf[116:372])) + sszVarOffset14 := ssz.ReadOffset(buf[508:512]) // c.Withdrawals + if sszVarOffset14 > size || sszVarOffset14 < sszVarOffset13 { + return ssz.ErrOffset } - e.LogsBloom = append(e.LogsBloom, buf[116:372]...) - - // Field (5) 'PrevRandao' - if cap(e.PrevRandao) == 0 { - e.PrevRandao = make([]byte, 0, len(buf[372:404])) + sszVarOffset17 := ssz.ReadOffset(buf[528:532]) // c.BlockAccessList + if sszVarOffset17 > size || sszVarOffset17 < sszVarOffset14 { + return ssz.ErrOffset } - e.PrevRandao = append(e.PrevRandao, buf[372:404]...) - - // Field (6) 'BlockNumber' - e.BlockNumber = ssz.UnmarshallUint[uint64](buf[404:412]) + sszSlice10 := buf[sszVarOffset10:sszVarOffset13] // c.ExtraData + sszSlice13 := buf[sszVarOffset13:sszVarOffset14] // c.Transactions + sszSlice14 := buf[sszVarOffset14:sszVarOffset17] // c.Withdrawals + sszSlice17 := buf[sszVarOffset17:] // c.BlockAccessList - // Field (7) 'GasLimit' - e.GasLimit = ssz.UnmarshallUint[uint64](buf[412:420]) + // Field 0: ParentHash + c.ParentHash = make([]byte, 0, 32) + c.ParentHash = append(c.ParentHash, sszSlice0...) - // Field (8) 'GasUsed' - e.GasUsed = ssz.UnmarshallUint[uint64](buf[420:428]) + // Field 1: FeeRecipient + c.FeeRecipient = make([]byte, 0, 20) + c.FeeRecipient = append(c.FeeRecipient, sszSlice1...) - // Field (9) 'Timestamp' - e.Timestamp = ssz.UnmarshallUint[uint64](buf[428:436]) - - // Offset (10) 'ExtraData' - if o10 = ssz.ReadOffset(buf[436:440]); o10 > size { - return ssz.ErrOffset - } + // Field 2: StateRoot + c.StateRoot = make([]byte, 0, 32) + c.StateRoot = append(c.StateRoot, sszSlice2...) - if o10 != 540 { - return ssz.ErrInvalidVariableOffset - } + // Field 3: ReceiptsRoot + c.ReceiptsRoot = make([]byte, 0, 32) + c.ReceiptsRoot = append(c.ReceiptsRoot, sszSlice3...) - // Field (11) 'BaseFeePerGas' - if cap(e.BaseFeePerGas) == 0 { - e.BaseFeePerGas = make([]byte, 0, len(buf[440:472])) - } - e.BaseFeePerGas = append(e.BaseFeePerGas, buf[440:472]...) + // Field 4: LogsBloom + c.LogsBloom = make([]byte, 0, 256) + c.LogsBloom = append(c.LogsBloom, sszSlice4...) - // Field (12) 'BlockHash' - if cap(e.BlockHash) == 0 { - e.BlockHash = make([]byte, 0, len(buf[472:504])) - } - e.BlockHash = append(e.BlockHash, buf[472:504]...) + // Field 5: PrevRandao + c.PrevRandao = make([]byte, 0, 32) + c.PrevRandao = append(c.PrevRandao, sszSlice5...) - // Offset (13) 'Transactions' - if o13 = ssz.ReadOffset(buf[504:508]); o13 > size || o10 > o13 { - return ssz.ErrOffset - } + // Field 6: BlockNumber + c.BlockNumber = binary.LittleEndian.Uint64(sszSlice6) - // Offset (14) 'Withdrawals' - if o14 = ssz.ReadOffset(buf[508:512]); o14 > size || o13 > o14 { - return ssz.ErrOffset - } + // Field 7: GasLimit + c.GasLimit = binary.LittleEndian.Uint64(sszSlice7) - // Field (15) 'BlobGasUsed' - e.BlobGasUsed = ssz.UnmarshallUint[uint64](buf[512:520]) + // Field 8: GasUsed + c.GasUsed = binary.LittleEndian.Uint64(sszSlice8) - // Field (16) 'ExcessBlobGas' - e.ExcessBlobGas = ssz.UnmarshallUint[uint64](buf[520:528]) + // Field 9: Timestamp + c.Timestamp = binary.LittleEndian.Uint64(sszSlice9) - // Offset (17) 'BlockAccessList' - if o17 = ssz.ReadOffset(buf[528:532]); o17 > size || o14 > o17 { - return ssz.ErrOffset - } + // Field 10: ExtraData + c.ExtraData = append([]byte{}, sszSlice10...) - // Field (18) 'SlotNumber' - e.SlotNumber = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[532:540]) + // Field 11: BaseFeePerGas + c.BaseFeePerGas = make([]byte, 0, 32) + c.BaseFeePerGas = append(c.BaseFeePerGas, sszSlice11...) - // 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 12: BlockHash + c.BlockHash = make([]byte, 0, 32) + c.BlockHash = append(c.BlockHash, sszSlice12...) - // Field (13) 'Transactions' + // 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 + // empty lists are zero length, so make sure there is room for an offset + // before attempting to unmarshal it + if len(sszSlice13) > 3 { + startOffset := ssz.ReadOffset(sszSlice13[0:4]) + if startOffset == 0 { + return fmt.Errorf("encountered invalid offset of 0 when decoding c.Transactions") } - if cap(e.Transactions[indx]) == 0 { - e.Transactions[indx] = make([]byte, 0, len(buf)) + if startOffset%4 != 0 { + return fmt.Errorf("misaligned list bytes: when decoding c.Transactions, end-of-list offset is %d, which is not a multiple of 4 (offset size)", startOffset) } - e.Transactions[indx] = append(e.Transactions[indx], buf...) - return nil - }) - if err != nil { - return err - } - } - - // Field (14) 'Withdrawals' - { - buf = tail[o14:o17] - num, err := ssz.DivideInt2(len(buf), 44, 4) - 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) + listLen := startOffset / 4 + if listLen > 1048576 { + return fmt.Errorf("ssz-max exceeded: c.Transactions has %d elements, ssz-max is 1048576: %w", listLen, ssz.ErrListTooBig) + } + totalVarBytes := uint64(len(sszSlice13)) + if totalVarBytes < startOffset { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.Transactions") + } + c.Transactions = make([][]byte, listLen) + var tmpSlice []byte + for i := uint64(0); i < listLen; i++ { + var tmp []byte + + endOffset := totalVarBytes + if i+1 != listLen { + endOffset = ssz.ReadOffset(sszSlice13[(i+1)*4 : (i+2)*4]) + if totalVarBytes < endOffset { + return fmt.Errorf("offset %d points past the end of buffer when decoding c.Transactions", endOffset) + } + } + if endOffset < startOffset { + return fmt.Errorf("offset %d is not greater than start offset %d when decoding c.Transactions", endOffset, startOffset) + } + tmpSlice = sszSlice13[startOffset:endOffset] + tmp = append([]byte{}, tmpSlice...) + c.Transactions[i] = tmp + startOffset = endOffset } - if err = e.Withdrawals[ii].UnmarshalSSZ(buf[ii*44 : (ii+1)*44]); err != nil { - return err + } else { + if len(sszSlice13) > 0 { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.Transactions") } + c.Transactions = make([][]byte, 0) } } - // Field (17) 'BlockAccessList' + // Field 14: Withdrawals { - buf = tail[o17:] - if len(buf) > 1073741824 { - return ssz.ErrBytesLength - } - if cap(e.BlockAccessList) == 0 { - e.BlockAccessList = make([]byte, 0, len(buf)) + if len(sszSlice14)%44 != 0 { + return fmt.Errorf("misaligned bytes: c.Withdrawals length is %d, which is not a multiple of 44: %w", len(sszSlice14), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice14) / 44 + if numElem > 4 { + return fmt.Errorf("ssz-max exceeded: c.Withdrawals has %d elements, ssz-max is 4: %w", numElem, ssz.ErrListTooBig) + } + c.Withdrawals = make([]*Withdrawal, numElem) + for i := 0; i < numElem; i++ { + var tmp *Withdrawal + tmp = new(Withdrawal) + tmpSlice := sszSlice14[i*44 : (1+i)*44] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Withdrawals: %w", err) + } + c.Withdrawals[i] = tmp } - e.BlockAccessList = append(e.BlockAccessList, buf...) } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the ExecutionPayloadGloas object -func (e *ExecutionPayloadGloas) SizeSSZ() (size int) { - size = 540 - - // 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 15: BlobGasUsed + c.BlobGasUsed = binary.LittleEndian.Uint64(sszSlice15) - // Field (14) 'Withdrawals' - size += len(e.Withdrawals) * 44 + // Field 16: ExcessBlobGas + c.ExcessBlobGas = binary.LittleEndian.Uint64(sszSlice16) - // Field (17) 'BlockAccessList' - size += len(e.BlockAccessList) + // Field 17: BlockAccessList + c.BlockAccessList = append([]byte{}, sszSlice17...) - return + // Field 18: SlotNumber + if err = c.SlotNumber.UnmarshalSSZ(sszSlice18); err != nil { + return fmt.Errorf("SlotNumber: %w", err) + } + return err } -// HashTreeRoot ssz hashes the ExecutionPayloadGloas object -func (e *ExecutionPayloadGloas) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(e) +func (c *ExecutionPayloadGloas) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the ExecutionPayloadGloas object with a hasher -func (e *ExecutionPayloadGloas) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *ExecutionPayloadGloas) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() + // Field 0: ParentHash + if len(c.ParentHash) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ParentHash) + // Field 1: FeeRecipient + if len(c.FeeRecipient) != 20 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.FeeRecipient) + // Field 2: StateRoot + if len(c.StateRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.StateRoot) + // Field 3: ReceiptsRoot + if len(c.ReceiptsRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ReceiptsRoot) + // Field 4: LogsBloom + if len(c.LogsBloom) != 256 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.LogsBloom) + // Field 5: PrevRandao + if len(c.PrevRandao) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.PrevRandao) + // Field 6: BlockNumber + hh.PutUint64(c.BlockNumber) + // Field 7: GasLimit + hh.PutUint64(c.GasLimit) + // Field 8: GasUsed + hh.PutUint64(c.GasUsed) + // Field 9: Timestamp + hh.PutUint64(c.Timestamp) + // Field 10: ExtraData - // Field (0) 'ParentHash' - if size := len(e.ParentHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentHash", size, 32) - return - } - hh.PutBytes(e.ParentHash) - - // Field (1) 'FeeRecipient' - if size := len(e.FeeRecipient); size != 20 { - err = ssz.ErrBytesLengthFn("--.FeeRecipient", size, 20) - return - } - hh.PutBytes(e.FeeRecipient) - - // Field (2) 'StateRoot' - if size := len(e.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return - } - hh.PutBytes(e.StateRoot) - - // Field (3) 'ReceiptsRoot' - if size := len(e.ReceiptsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ReceiptsRoot", size, 32) - return - } - hh.PutBytes(e.ReceiptsRoot) - - // Field (4) 'LogsBloom' - if size := len(e.LogsBloom); size != 256 { - err = ssz.ErrBytesLengthFn("--.LogsBloom", size, 256) - return - } - hh.PutBytes(e.LogsBloom) - - // Field (5) 'PrevRandao' - if size := len(e.PrevRandao); size != 32 { - err = ssz.ErrBytesLengthFn("--.PrevRandao", size, 32) - return - } - hh.PutBytes(e.PrevRandao) - - // Field (6) 'BlockNumber' - ssz.PutUint(hh, e.BlockNumber) - - // Field (7) 'GasLimit' - ssz.PutUint(hh, e.GasLimit) - - // Field (8) 'GasUsed' - ssz.PutUint(hh, e.GasUsed) - - // Field (9) 'Timestamp' - ssz.PutUint(hh, e.Timestamp) - - // Field (10) 'ExtraData' { - elemIndx := hh.Index() - byteLen := uint64(len(e.ExtraData)) - if byteLen > 32 { - err = ssz.ErrIncorrectListSize - return + if len(c.ExtraData) > 32 { + return ssz.ErrBytesLength } - hh.AppendBytes32(e.ExtraData) - hh.MerkleizeWithMixin(elemIndx, byteLen, (32+31)/32) + subIndx := hh.Index() + hh.AppendBytes32(c.ExtraData) + numItems := uint64(len(c.ExtraData)) + hh.MerkleizeWithMixin(subIndx, numItems, (32*1+31)/32) } - // Field (11) 'BaseFeePerGas' - if size := len(e.BaseFeePerGas); size != 32 { - err = ssz.ErrBytesLengthFn("--.BaseFeePerGas", size, 32) - return + // Field 11: BaseFeePerGas + if len(c.BaseFeePerGas) != 32 { + return ssz.ErrBytesLength } - hh.PutBytes(e.BaseFeePerGas) - - // Field (12) 'BlockHash' - if size := len(e.BlockHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockHash", size, 32) - return + hh.PutBytes(c.BaseFeePerGas) + // Field 12: BlockHash + if len(c.BlockHash) != 32 { + return ssz.ErrBytesLength } - hh.PutBytes(e.BlockHash) - - // Field (13) 'Transactions' + hh.PutBytes(c.BlockHash) + // Field 13: Transactions { - subIndx := hh.Index() - num := uint64(len(e.Transactions)) - if num > 1048576 { - err = ssz.ErrIncorrectListSize - return + if len(c.Transactions) > 1048576 { + return ssz.ErrListTooBig } - for _, elem := range e.Transactions { + subIndx := hh.Index() + for _, o := range c.Transactions { + { - elemIndx := hh.Index() - byteLen := uint64(len(elem)) - if byteLen > 1073741824 { - err = ssz.ErrIncorrectListSize - return + if len(o) > 1073741824 { + return ssz.ErrBytesLength } - hh.AppendBytes32(elem) - hh.MerkleizeWithMixin(elemIndx, byteLen, (1073741824+31)/32) + subIndx := hh.Index() + hh.AppendBytes32(o) + numItems := uint64(len(o)) + hh.MerkleizeWithMixin(subIndx, numItems, (1073741824*1+31)/32) } + } - hh.MerkleizeWithMixin(subIndx, num, 1048576) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Transactions)), 1048576) } - - // Field (14) 'Withdrawals' + // Field 14: Withdrawals { + if len(c.Withdrawals) > 4 { + return ssz.ErrListTooBig + } subIndx := hh.Index() - num := uint64(len(e.Withdrawals)) - if num > 4 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range e.Withdrawals { - if err = elem.HashTreeRootWith(hh); err != nil { - return + for _, o := range c.Withdrawals { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Withdrawals: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 4) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Withdrawals)), 4) } + // Field 15: BlobGasUsed + hh.PutUint64(c.BlobGasUsed) + // Field 16: ExcessBlobGas + hh.PutUint64(c.ExcessBlobGas) + // Field 17: BlockAccessList - // Field (15) 'BlobGasUsed' - ssz.PutUint(hh, e.BlobGasUsed) - - // Field (16) 'ExcessBlobGas' - ssz.PutUint(hh, e.ExcessBlobGas) - - // Field (17) 'BlockAccessList' { - elemIndx := hh.Index() - byteLen := uint64(len(e.BlockAccessList)) - if byteLen > 1073741824 { - err = ssz.ErrIncorrectListSize - return + if len(c.BlockAccessList) > 1073741824 { + return ssz.ErrBytesLength } - hh.AppendBytes32(e.BlockAccessList) - hh.MerkleizeWithMixin(elemIndx, byteLen, (1073741824+31)/32) + subIndx := hh.Index() + hh.AppendBytes32(c.BlockAccessList) + numItems := uint64(len(c.BlockAccessList)) + hh.MerkleizeWithMixin(subIndx, numItems, (1073741824*1+31)/32) } - // Field (18) 'SlotNumber' - ssz.PutUint(hh, e.SlotNumber) - + // Field 18: SlotNumber + if err := c.SlotNumber.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SlotNumber: %w", err) + } hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the ExecutionPayloadDenebAndBlobsBundle object -func (e *ExecutionPayloadDenebAndBlobsBundle) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(e) +func (c *ExecutionPayloadDenebAndBlobsBundle) SizeSSZ() int { + size := 8 + if c.Payload == nil { + c.Payload = new(ExecutionPayloadDeneb) + } + size += c.Payload.SizeSSZ() + if c.BlobsBundle == nil { + c.BlobsBundle = new(BlobsBundle) + } + size += c.BlobsBundle.SizeSSZ() + return size } -// MarshalSSZTo ssz marshals the ExecutionPayloadDenebAndBlobsBundle object to a target array -func (e *ExecutionPayloadDenebAndBlobsBundle) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(8) +func (c *ExecutionPayloadDenebAndBlobsBundle) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Offset (0) 'Payload' - dst = ssz.WriteOffset(dst, offset) - if e.Payload == nil { - e.Payload = new(ExecutionPayloadDeneb) - } - offset += e.Payload.SizeSSZ() +func (c *ExecutionPayloadDenebAndBlobsBundle) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 8 - // Offset (1) 'BlobsBundle' - dst = ssz.WriteOffset(dst, offset) - if e.BlobsBundle == nil { - e.BlobsBundle = new(BlobsBundle) + // Field 0: Payload + if c.Payload == nil { + c.Payload = new(ExecutionPayloadDeneb) } - offset += e.BlobsBundle.SizeSSZ() + dst = ssz.WriteOffset(dst, offset) + offset += c.Payload.SizeSSZ() - // Field (0) 'Payload' - if dst, err = e.Payload.MarshalSSZTo(dst); err != nil { - return + // Field 1: BlobsBundle + if c.BlobsBundle == nil { + c.BlobsBundle = new(BlobsBundle) } + dst = ssz.WriteOffset(dst, offset) + offset += c.BlobsBundle.SizeSSZ() - // Field (1) 'BlobsBundle' - if dst, err = e.BlobsBundle.MarshalSSZTo(dst); err != nil { - return + // Field 0: Payload + if dst, err = c.Payload.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Payload: %w", err) } - return + // Field 1: BlobsBundle + if dst, err = c.BlobsBundle.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("BlobsBundle: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the ExecutionPayloadDenebAndBlobsBundle object -func (e *ExecutionPayloadDenebAndBlobsBundle) UnmarshalSSZ(buf []byte) error { +func (c *ExecutionPayloadDenebAndBlobsBundle) 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) 'Payload' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } - - if o0 != 8 { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Payload + if sszVarOffset0 != 8 { return ssz.ErrInvalidVariableOffset } - - // Offset (1) 'BlobsBundle' - if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 { + if sszVarOffset0 > size { return ssz.ErrOffset } + sszVarOffset1 := ssz.ReadOffset(buf[4:8]) // c.BlobsBundle + if sszVarOffset1 > size || sszVarOffset1 < sszVarOffset0 { + return ssz.ErrOffset + } + sszSlice0 := buf[sszVarOffset0:sszVarOffset1] // c.Payload + sszSlice1 := buf[sszVarOffset1:] // c.BlobsBundle - // Field (0) 'Payload' - { - buf = tail[o0:o1] - if e.Payload == nil { - e.Payload = new(ExecutionPayloadDeneb) - } - if err = e.Payload.UnmarshalSSZ(buf); err != nil { - return err - } + // Field 0: Payload + c.Payload = new(ExecutionPayloadDeneb) + if err = c.Payload.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Payload: %w", err) } - // Field (1) 'BlobsBundle' - { - buf = tail[o1:] - if e.BlobsBundle == nil { - e.BlobsBundle = new(BlobsBundle) - } - if err = e.BlobsBundle.UnmarshalSSZ(buf); err != nil { - return err - } + // Field 1: BlobsBundle + c.BlobsBundle = new(BlobsBundle) + if err = c.BlobsBundle.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("BlobsBundle: %w", err) } return err } -// SizeSSZ returns the ssz encoded size in bytes for the ExecutionPayloadDenebAndBlobsBundle object -func (e *ExecutionPayloadDenebAndBlobsBundle) SizeSSZ() (size int) { - size = 8 - - // Field (0) 'Payload' - if e.Payload == nil { - e.Payload = new(ExecutionPayloadDeneb) - } - size += e.Payload.SizeSSZ() - - // Field (1) 'BlobsBundle' - if e.BlobsBundle == nil { - e.BlobsBundle = new(BlobsBundle) +func (c *ExecutionPayloadDenebAndBlobsBundle) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - size += e.BlobsBundle.SizeSSZ() - - return + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRoot ssz hashes the ExecutionPayloadDenebAndBlobsBundle object -func (e *ExecutionPayloadDenebAndBlobsBundle) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(e) -} - -// HashTreeRootWith ssz hashes the ExecutionPayloadDenebAndBlobsBundle object with a hasher -func (e *ExecutionPayloadDenebAndBlobsBundle) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *ExecutionPayloadDenebAndBlobsBundle) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Payload' - if err = e.Payload.HashTreeRootWith(hh); err != nil { - return + // Field 0: Payload + if err := c.Payload.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Payload: %w", err) } - - // Field (1) 'BlobsBundle' - if err = e.BlobsBundle.HashTreeRootWith(hh); err != nil { - return + // Field 1: BlobsBundle + if err := c.BlobsBundle.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("BlobsBundle: %w", err) } - hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the ExecutionPayloadDenebAndBlobsBundleV2 object -func (e *ExecutionPayloadDenebAndBlobsBundleV2) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(e) +func (c *ExecutionPayloadDenebAndBlobsBundleV2) SizeSSZ() int { + size := 8 + if c.Payload == nil { + c.Payload = new(ExecutionPayloadDeneb) + } + size += c.Payload.SizeSSZ() + if c.BlobsBundle == nil { + c.BlobsBundle = new(BlobsBundleV2) + } + size += c.BlobsBundle.SizeSSZ() + return size } -// MarshalSSZTo ssz marshals the ExecutionPayloadDenebAndBlobsBundleV2 object to a target array -func (e *ExecutionPayloadDenebAndBlobsBundleV2) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(8) +func (c *ExecutionPayloadDenebAndBlobsBundleV2) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Offset (0) 'Payload' - dst = ssz.WriteOffset(dst, offset) - if e.Payload == nil { - e.Payload = new(ExecutionPayloadDeneb) - } - offset += e.Payload.SizeSSZ() +func (c *ExecutionPayloadDenebAndBlobsBundleV2) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 8 - // Offset (1) 'BlobsBundle' - dst = ssz.WriteOffset(dst, offset) - if e.BlobsBundle == nil { - e.BlobsBundle = new(BlobsBundleV2) + // Field 0: Payload + if c.Payload == nil { + c.Payload = new(ExecutionPayloadDeneb) } - offset += e.BlobsBundle.SizeSSZ() + dst = ssz.WriteOffset(dst, offset) + offset += c.Payload.SizeSSZ() - // Field (0) 'Payload' - if dst, err = e.Payload.MarshalSSZTo(dst); err != nil { - return + // Field 1: BlobsBundle + if c.BlobsBundle == nil { + c.BlobsBundle = new(BlobsBundleV2) } + dst = ssz.WriteOffset(dst, offset) + offset += c.BlobsBundle.SizeSSZ() - // Field (1) 'BlobsBundle' - if dst, err = e.BlobsBundle.MarshalSSZTo(dst); err != nil { - return + // Field 0: Payload + if dst, err = c.Payload.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Payload: %w", err) } - return + // Field 1: BlobsBundle + if dst, err = c.BlobsBundle.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("BlobsBundle: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the ExecutionPayloadDenebAndBlobsBundleV2 object -func (e *ExecutionPayloadDenebAndBlobsBundleV2) UnmarshalSSZ(buf []byte) error { +func (c *ExecutionPayloadDenebAndBlobsBundleV2) 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) 'Payload' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } - - if o0 != 8 { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Payload + if sszVarOffset0 != 8 { return ssz.ErrInvalidVariableOffset } - - // Offset (1) 'BlobsBundle' - if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 { + if sszVarOffset0 > size { return ssz.ErrOffset } + sszVarOffset1 := ssz.ReadOffset(buf[4:8]) // c.BlobsBundle + if sszVarOffset1 > size || sszVarOffset1 < sszVarOffset0 { + return ssz.ErrOffset + } + sszSlice0 := buf[sszVarOffset0:sszVarOffset1] // c.Payload + sszSlice1 := buf[sszVarOffset1:] // c.BlobsBundle - // Field (0) 'Payload' - { - buf = tail[o0:o1] - if e.Payload == nil { - e.Payload = new(ExecutionPayloadDeneb) - } - if err = e.Payload.UnmarshalSSZ(buf); err != nil { - return err - } + // Field 0: Payload + c.Payload = new(ExecutionPayloadDeneb) + if err = c.Payload.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Payload: %w", err) } - // Field (1) 'BlobsBundle' - { - buf = tail[o1:] - if e.BlobsBundle == nil { - e.BlobsBundle = new(BlobsBundleV2) - } - if err = e.BlobsBundle.UnmarshalSSZ(buf); err != nil { - return err - } + // Field 1: BlobsBundle + c.BlobsBundle = new(BlobsBundleV2) + if err = c.BlobsBundle.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("BlobsBundle: %w", err) } return err } -// SizeSSZ returns the ssz encoded size in bytes for the ExecutionPayloadDenebAndBlobsBundleV2 object -func (e *ExecutionPayloadDenebAndBlobsBundleV2) SizeSSZ() (size int) { - size = 8 - - // Field (0) 'Payload' - if e.Payload == nil { - e.Payload = new(ExecutionPayloadDeneb) - } - size += e.Payload.SizeSSZ() - - // Field (1) 'BlobsBundle' - if e.BlobsBundle == nil { - e.BlobsBundle = new(BlobsBundleV2) +func (c *ExecutionPayloadDenebAndBlobsBundleV2) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - size += e.BlobsBundle.SizeSSZ() - - return + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRoot ssz hashes the ExecutionPayloadDenebAndBlobsBundleV2 object -func (e *ExecutionPayloadDenebAndBlobsBundleV2) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(e) -} - -// HashTreeRootWith ssz hashes the ExecutionPayloadDenebAndBlobsBundleV2 object with a hasher -func (e *ExecutionPayloadDenebAndBlobsBundleV2) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *ExecutionPayloadDenebAndBlobsBundleV2) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Payload' - if err = e.Payload.HashTreeRootWith(hh); err != nil { - return + // Field 0: Payload + if err := c.Payload.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Payload: %w", err) } - - // Field (1) 'BlobsBundle' - if err = e.BlobsBundle.HashTreeRootWith(hh); err != nil { - return + // Field 1: BlobsBundle + if err := c.BlobsBundle.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("BlobsBundle: %w", err) } - hh.Merkleize(indx) - return + return nil +} + +func (c *ExecutionPayloadHeader) SizeSSZ() int { + size := 536 + size += len(c.ExtraData) + return size } -// MarshalSSZ ssz marshals the ExecutionPayloadHeader object -func (e *ExecutionPayloadHeader) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(e) +func (c *ExecutionPayloadHeader) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the ExecutionPayloadHeader object to a target array -func (e *ExecutionPayloadHeader) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(536) +func (c *ExecutionPayloadHeader) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 536 - // Field (0) 'ParentHash' - if size := len(e.ParentHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentHash", size, 32) - return + // Field 0: ParentHash + if len(c.ParentHash) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.ParentHash...) + dst = append(dst, c.ParentHash...) - // Field (1) 'FeeRecipient' - if size := len(e.FeeRecipient); size != 20 { - err = ssz.ErrBytesLengthFn("--.FeeRecipient", size, 20) - return + // Field 1: FeeRecipient + if len(c.FeeRecipient) != 20 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.FeeRecipient...) + dst = append(dst, c.FeeRecipient...) - // Field (2) 'StateRoot' - if size := len(e.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return + // Field 2: StateRoot + if len(c.StateRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.StateRoot...) + dst = append(dst, c.StateRoot...) - // Field (3) 'ReceiptsRoot' - if size := len(e.ReceiptsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ReceiptsRoot", size, 32) - return + // Field 3: ReceiptsRoot + if len(c.ReceiptsRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.ReceiptsRoot...) + dst = append(dst, c.ReceiptsRoot...) - // Field (4) 'LogsBloom' - if size := len(e.LogsBloom); size != 256 { - err = ssz.ErrBytesLengthFn("--.LogsBloom", size, 256) - return + // Field 4: LogsBloom + if len(c.LogsBloom) != 256 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.LogsBloom...) + dst = append(dst, c.LogsBloom...) - // Field (5) 'PrevRandao' - if size := len(e.PrevRandao); size != 32 { - err = ssz.ErrBytesLengthFn("--.PrevRandao", size, 32) - return + // Field 5: PrevRandao + if len(c.PrevRandao) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.PrevRandao...) + dst = append(dst, c.PrevRandao...) - // Field (6) 'BlockNumber' - dst = ssz.MarshalUint(dst, e.BlockNumber) + // Field 6: BlockNumber + dst = binary.LittleEndian.AppendUint64(dst, c.BlockNumber) - // Field (7) 'GasLimit' - dst = ssz.MarshalUint(dst, e.GasLimit) + // Field 7: GasLimit + dst = binary.LittleEndian.AppendUint64(dst, c.GasLimit) - // Field (8) 'GasUsed' - dst = ssz.MarshalUint(dst, e.GasUsed) + // Field 8: GasUsed + dst = binary.LittleEndian.AppendUint64(dst, c.GasUsed) - // Field (9) 'Timestamp' - dst = ssz.MarshalUint(dst, e.Timestamp) + // Field 9: Timestamp + dst = binary.LittleEndian.AppendUint64(dst, c.Timestamp) - // Offset (10) 'ExtraData' + // Field 10: ExtraData dst = ssz.WriteOffset(dst, offset) - offset += len(e.ExtraData) + offset += len(c.ExtraData) - // Field (11) 'BaseFeePerGas' - if size := len(e.BaseFeePerGas); size != 32 { - err = ssz.ErrBytesLengthFn("--.BaseFeePerGas", size, 32) - return + // Field 11: BaseFeePerGas + if len(c.BaseFeePerGas) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.BaseFeePerGas...) + dst = append(dst, c.BaseFeePerGas...) - // Field (12) 'BlockHash' - if size := len(e.BlockHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockHash", size, 32) - return + // Field 12: BlockHash + if len(c.BlockHash) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.BlockHash...) + dst = append(dst, c.BlockHash...) - // Field (13) 'TransactionsRoot' - if size := len(e.TransactionsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.TransactionsRoot", size, 32) - return + // Field 13: TransactionsRoot + if len(c.TransactionsRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.TransactionsRoot...) + dst = append(dst, c.TransactionsRoot...) - // Field (10) 'ExtraData' - if size := len(e.ExtraData); size > 32 { - err = ssz.ErrBytesLengthFn("--.ExtraData", size, 32) - return + // Field 10: ExtraData + if len(c.ExtraData) > 32 { + return nil, ssz.ErrListTooBig } - dst = append(dst, e.ExtraData...) - - return + dst = append(dst, c.ExtraData...) + return dst, err } -// UnmarshalSSZ ssz unmarshals the ExecutionPayloadHeader object -func (e *ExecutionPayloadHeader) UnmarshalSSZ(buf []byte) error { +func (c *ExecutionPayloadHeader) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size < 536 { return ssz.ErrSize } - tail := buf - var o10 uint64 - - // Field (0) 'ParentHash' - if cap(e.ParentHash) == 0 { - e.ParentHash = make([]byte, 0, len(buf[0:32])) + sszSlice0 := buf[0:32] // c.ParentHash + sszSlice1 := buf[32:52] // c.FeeRecipient + sszSlice2 := buf[52:84] // c.StateRoot + sszSlice3 := buf[84:116] // c.ReceiptsRoot + sszSlice4 := buf[116:372] // c.LogsBloom + sszSlice5 := buf[372:404] // c.PrevRandao + sszSlice6 := buf[404:412] // c.BlockNumber + sszSlice7 := buf[412:420] // c.GasLimit + sszSlice8 := buf[420:428] // c.GasUsed + sszSlice9 := buf[428:436] // c.Timestamp + sszSlice11 := buf[440:472] // c.BaseFeePerGas + sszSlice12 := buf[472:504] // c.BlockHash + sszSlice13 := buf[504:536] // c.TransactionsRoot + + sszVarOffset10 := ssz.ReadOffset(buf[436:440]) // c.ExtraData + if sszVarOffset10 != 536 { + return ssz.ErrInvalidVariableOffset } - e.ParentHash = append(e.ParentHash, buf[0:32]...) - - // Field (1) 'FeeRecipient' - if cap(e.FeeRecipient) == 0 { - e.FeeRecipient = make([]byte, 0, len(buf[32:52])) + if sszVarOffset10 > size { + return ssz.ErrOffset } - e.FeeRecipient = append(e.FeeRecipient, buf[32:52]...) + sszSlice10 := buf[sszVarOffset10:] // c.ExtraData - // Field (2) 'StateRoot' - if cap(e.StateRoot) == 0 { - e.StateRoot = make([]byte, 0, len(buf[52:84])) - } - e.StateRoot = append(e.StateRoot, buf[52:84]...) + // Field 0: ParentHash + c.ParentHash = make([]byte, 0, 32) + c.ParentHash = append(c.ParentHash, sszSlice0...) - // Field (3) 'ReceiptsRoot' - if cap(e.ReceiptsRoot) == 0 { - e.ReceiptsRoot = make([]byte, 0, len(buf[84:116])) - } - e.ReceiptsRoot = append(e.ReceiptsRoot, buf[84:116]...) + // Field 1: FeeRecipient + c.FeeRecipient = make([]byte, 0, 20) + c.FeeRecipient = append(c.FeeRecipient, sszSlice1...) - // Field (4) 'LogsBloom' - if cap(e.LogsBloom) == 0 { - e.LogsBloom = make([]byte, 0, len(buf[116:372])) - } - e.LogsBloom = append(e.LogsBloom, buf[116:372]...) + // Field 2: StateRoot + c.StateRoot = make([]byte, 0, 32) + c.StateRoot = append(c.StateRoot, sszSlice2...) - // Field (5) 'PrevRandao' - if cap(e.PrevRandao) == 0 { - e.PrevRandao = make([]byte, 0, len(buf[372:404])) - } - e.PrevRandao = append(e.PrevRandao, buf[372:404]...) + // Field 3: ReceiptsRoot + c.ReceiptsRoot = make([]byte, 0, 32) + c.ReceiptsRoot = append(c.ReceiptsRoot, sszSlice3...) - // Field (6) 'BlockNumber' - e.BlockNumber = ssz.UnmarshallUint[uint64](buf[404:412]) + // Field 4: LogsBloom + c.LogsBloom = make([]byte, 0, 256) + c.LogsBloom = append(c.LogsBloom, sszSlice4...) - // Field (7) 'GasLimit' - e.GasLimit = ssz.UnmarshallUint[uint64](buf[412:420]) + // Field 5: PrevRandao + c.PrevRandao = make([]byte, 0, 32) + c.PrevRandao = append(c.PrevRandao, sszSlice5...) - // Field (8) 'GasUsed' - e.GasUsed = ssz.UnmarshallUint[uint64](buf[420:428]) + // Field 6: BlockNumber + c.BlockNumber = binary.LittleEndian.Uint64(sszSlice6) - // Field (9) 'Timestamp' - e.Timestamp = ssz.UnmarshallUint[uint64](buf[428:436]) + // Field 7: GasLimit + c.GasLimit = binary.LittleEndian.Uint64(sszSlice7) - // Offset (10) 'ExtraData' - if o10 = ssz.ReadOffset(buf[436:440]); o10 > size { - return ssz.ErrOffset - } + // Field 8: GasUsed + c.GasUsed = binary.LittleEndian.Uint64(sszSlice8) - if o10 != 536 { - return ssz.ErrInvalidVariableOffset - } + // Field 9: Timestamp + c.Timestamp = binary.LittleEndian.Uint64(sszSlice9) - // Field (11) 'BaseFeePerGas' - if cap(e.BaseFeePerGas) == 0 { - e.BaseFeePerGas = make([]byte, 0, len(buf[440:472])) - } - e.BaseFeePerGas = append(e.BaseFeePerGas, buf[440:472]...) + // Field 10: ExtraData + c.ExtraData = append([]byte{}, sszSlice10...) - // Field (12) 'BlockHash' - if cap(e.BlockHash) == 0 { - e.BlockHash = make([]byte, 0, len(buf[472:504])) - } - e.BlockHash = append(e.BlockHash, buf[472:504]...) + // Field 11: BaseFeePerGas + c.BaseFeePerGas = make([]byte, 0, 32) + c.BaseFeePerGas = append(c.BaseFeePerGas, sszSlice11...) - // Field (13) 'TransactionsRoot' - if cap(e.TransactionsRoot) == 0 { - e.TransactionsRoot = make([]byte, 0, len(buf[504:536])) - } - e.TransactionsRoot = append(e.TransactionsRoot, buf[504:536]...) + // Field 12: BlockHash + c.BlockHash = make([]byte, 0, 32) + c.BlockHash = append(c.BlockHash, sszSlice12...) - // 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...) - } + // Field 13: TransactionsRoot + c.TransactionsRoot = make([]byte, 0, 32) + c.TransactionsRoot = append(c.TransactionsRoot, sszSlice13...) return err } -// SizeSSZ returns the ssz encoded size in bytes for the ExecutionPayloadHeader object -func (e *ExecutionPayloadHeader) SizeSSZ() (size int) { - size = 536 - - // 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) +func (c *ExecutionPayloadHeader) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the ExecutionPayloadHeader object with a hasher -func (e *ExecutionPayloadHeader) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *ExecutionPayloadHeader) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() + // Field 0: ParentHash + if len(c.ParentHash) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ParentHash) + // Field 1: FeeRecipient + if len(c.FeeRecipient) != 20 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.FeeRecipient) + // Field 2: StateRoot + if len(c.StateRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.StateRoot) + // Field 3: ReceiptsRoot + if len(c.ReceiptsRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ReceiptsRoot) + // Field 4: LogsBloom + if len(c.LogsBloom) != 256 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.LogsBloom) + // Field 5: PrevRandao + if len(c.PrevRandao) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.PrevRandao) + // Field 6: BlockNumber + hh.PutUint64(c.BlockNumber) + // Field 7: GasLimit + hh.PutUint64(c.GasLimit) + // Field 8: GasUsed + hh.PutUint64(c.GasUsed) + // Field 9: Timestamp + hh.PutUint64(c.Timestamp) + // Field 10: ExtraData - // Field (0) 'ParentHash' - if size := len(e.ParentHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentHash", size, 32) - return - } - hh.PutBytes(e.ParentHash) - - // Field (1) 'FeeRecipient' - if size := len(e.FeeRecipient); size != 20 { - err = ssz.ErrBytesLengthFn("--.FeeRecipient", size, 20) - return - } - hh.PutBytes(e.FeeRecipient) - - // Field (2) 'StateRoot' - if size := len(e.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return - } - hh.PutBytes(e.StateRoot) - - // Field (3) 'ReceiptsRoot' - if size := len(e.ReceiptsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ReceiptsRoot", size, 32) - return - } - hh.PutBytes(e.ReceiptsRoot) - - // Field (4) 'LogsBloom' - if size := len(e.LogsBloom); size != 256 { - err = ssz.ErrBytesLengthFn("--.LogsBloom", size, 256) - return - } - hh.PutBytes(e.LogsBloom) - - // Field (5) 'PrevRandao' - if size := len(e.PrevRandao); size != 32 { - err = ssz.ErrBytesLengthFn("--.PrevRandao", size, 32) - return - } - hh.PutBytes(e.PrevRandao) - - // Field (6) 'BlockNumber' - ssz.PutUint(hh, e.BlockNumber) - - // Field (7) 'GasLimit' - ssz.PutUint(hh, e.GasLimit) - - // Field (8) 'GasUsed' - ssz.PutUint(hh, e.GasUsed) - - // Field (9) 'Timestamp' - ssz.PutUint(hh, e.Timestamp) - - // Field (10) 'ExtraData' { - elemIndx := hh.Index() - byteLen := uint64(len(e.ExtraData)) - if byteLen > 32 { - err = ssz.ErrIncorrectListSize - return + if len(c.ExtraData) > 32 { + return ssz.ErrBytesLength } - hh.AppendBytes32(e.ExtraData) - hh.MerkleizeWithMixin(elemIndx, byteLen, (32+31)/32) + subIndx := hh.Index() + hh.AppendBytes32(c.ExtraData) + numItems := uint64(len(c.ExtraData)) + hh.MerkleizeWithMixin(subIndx, numItems, (32*1+31)/32) } - // Field (11) 'BaseFeePerGas' - if size := len(e.BaseFeePerGas); size != 32 { - err = ssz.ErrBytesLengthFn("--.BaseFeePerGas", size, 32) - return + // Field 11: BaseFeePerGas + if len(c.BaseFeePerGas) != 32 { + return ssz.ErrBytesLength } - hh.PutBytes(e.BaseFeePerGas) - - // Field (12) 'BlockHash' - if size := len(e.BlockHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockHash", size, 32) - return + hh.PutBytes(c.BaseFeePerGas) + // Field 12: BlockHash + if len(c.BlockHash) != 32 { + return ssz.ErrBytesLength } - hh.PutBytes(e.BlockHash) - - // Field (13) 'TransactionsRoot' - if size := len(e.TransactionsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.TransactionsRoot", size, 32) - return + hh.PutBytes(c.BlockHash) + // Field 13: TransactionsRoot + if len(c.TransactionsRoot) != 32 { + return ssz.ErrBytesLength } - hh.PutBytes(e.TransactionsRoot) - + hh.PutBytes(c.TransactionsRoot) hh.Merkleize(indx) - return + return nil +} + +func (c *ExecutionPayloadHeaderCapella) SizeSSZ() int { + size := 568 + size += len(c.ExtraData) + return size } -// MarshalSSZ ssz marshals the ExecutionPayloadHeaderCapella object -func (e *ExecutionPayloadHeaderCapella) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(e) +func (c *ExecutionPayloadHeaderCapella) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the ExecutionPayloadHeaderCapella object to a target array -func (e *ExecutionPayloadHeaderCapella) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(568) +func (c *ExecutionPayloadHeaderCapella) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 568 - // Field (0) 'ParentHash' - if size := len(e.ParentHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentHash", size, 32) - return + // Field 0: ParentHash + if len(c.ParentHash) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.ParentHash...) + dst = append(dst, c.ParentHash...) - // Field (1) 'FeeRecipient' - if size := len(e.FeeRecipient); size != 20 { - err = ssz.ErrBytesLengthFn("--.FeeRecipient", size, 20) - return + // Field 1: FeeRecipient + if len(c.FeeRecipient) != 20 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.FeeRecipient...) + dst = append(dst, c.FeeRecipient...) - // Field (2) 'StateRoot' - if size := len(e.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return + // Field 2: StateRoot + if len(c.StateRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.StateRoot...) + dst = append(dst, c.StateRoot...) - // Field (3) 'ReceiptsRoot' - if size := len(e.ReceiptsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ReceiptsRoot", size, 32) - return + // Field 3: ReceiptsRoot + if len(c.ReceiptsRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.ReceiptsRoot...) + dst = append(dst, c.ReceiptsRoot...) - // Field (4) 'LogsBloom' - if size := len(e.LogsBloom); size != 256 { - err = ssz.ErrBytesLengthFn("--.LogsBloom", size, 256) - return + // Field 4: LogsBloom + if len(c.LogsBloom) != 256 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.LogsBloom...) + dst = append(dst, c.LogsBloom...) - // Field (5) 'PrevRandao' - if size := len(e.PrevRandao); size != 32 { - err = ssz.ErrBytesLengthFn("--.PrevRandao", size, 32) - return + // Field 5: PrevRandao + if len(c.PrevRandao) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.PrevRandao...) + dst = append(dst, c.PrevRandao...) - // Field (6) 'BlockNumber' - dst = ssz.MarshalUint(dst, e.BlockNumber) + // Field 6: BlockNumber + dst = binary.LittleEndian.AppendUint64(dst, c.BlockNumber) - // Field (7) 'GasLimit' - dst = ssz.MarshalUint(dst, e.GasLimit) + // Field 7: GasLimit + dst = binary.LittleEndian.AppendUint64(dst, c.GasLimit) - // Field (8) 'GasUsed' - dst = ssz.MarshalUint(dst, e.GasUsed) + // Field 8: GasUsed + dst = binary.LittleEndian.AppendUint64(dst, c.GasUsed) - // Field (9) 'Timestamp' - dst = ssz.MarshalUint(dst, e.Timestamp) + // Field 9: Timestamp + dst = binary.LittleEndian.AppendUint64(dst, c.Timestamp) - // Offset (10) 'ExtraData' + // Field 10: ExtraData dst = ssz.WriteOffset(dst, offset) - offset += len(e.ExtraData) + offset += len(c.ExtraData) - // Field (11) 'BaseFeePerGas' - if size := len(e.BaseFeePerGas); size != 32 { - err = ssz.ErrBytesLengthFn("--.BaseFeePerGas", size, 32) - return + // Field 11: BaseFeePerGas + if len(c.BaseFeePerGas) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.BaseFeePerGas...) + dst = append(dst, c.BaseFeePerGas...) - // Field (12) 'BlockHash' - if size := len(e.BlockHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockHash", size, 32) - return + // Field 12: BlockHash + if len(c.BlockHash) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.BlockHash...) + dst = append(dst, c.BlockHash...) - // Field (13) 'TransactionsRoot' - if size := len(e.TransactionsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.TransactionsRoot", size, 32) - return + // Field 13: TransactionsRoot + if len(c.TransactionsRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.TransactionsRoot...) + dst = append(dst, c.TransactionsRoot...) - // Field (14) 'WithdrawalsRoot' - if size := len(e.WithdrawalsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.WithdrawalsRoot", size, 32) - return + // Field 14: WithdrawalsRoot + if len(c.WithdrawalsRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.WithdrawalsRoot...) + dst = append(dst, c.WithdrawalsRoot...) - // Field (10) 'ExtraData' - if size := len(e.ExtraData); size > 32 { - err = ssz.ErrBytesLengthFn("--.ExtraData", size, 32) - return + // Field 10: ExtraData + if len(c.ExtraData) > 32 { + return nil, ssz.ErrListTooBig } - dst = append(dst, e.ExtraData...) - - return + dst = append(dst, c.ExtraData...) + return dst, err } -// UnmarshalSSZ ssz unmarshals the ExecutionPayloadHeaderCapella object -func (e *ExecutionPayloadHeaderCapella) UnmarshalSSZ(buf []byte) error { +func (c *ExecutionPayloadHeaderCapella) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size < 568 { return ssz.ErrSize } - tail := buf - var o10 uint64 - - // Field (0) 'ParentHash' - if cap(e.ParentHash) == 0 { - e.ParentHash = make([]byte, 0, len(buf[0:32])) + sszSlice0 := buf[0:32] // c.ParentHash + sszSlice1 := buf[32:52] // c.FeeRecipient + sszSlice2 := buf[52:84] // c.StateRoot + sszSlice3 := buf[84:116] // c.ReceiptsRoot + sszSlice4 := buf[116:372] // c.LogsBloom + sszSlice5 := buf[372:404] // c.PrevRandao + sszSlice6 := buf[404:412] // c.BlockNumber + sszSlice7 := buf[412:420] // c.GasLimit + sszSlice8 := buf[420:428] // c.GasUsed + sszSlice9 := buf[428:436] // c.Timestamp + sszSlice11 := buf[440:472] // c.BaseFeePerGas + sszSlice12 := buf[472:504] // c.BlockHash + sszSlice13 := buf[504:536] // c.TransactionsRoot + sszSlice14 := buf[536:568] // c.WithdrawalsRoot + + sszVarOffset10 := ssz.ReadOffset(buf[436:440]) // c.ExtraData + if sszVarOffset10 != 568 { + return ssz.ErrInvalidVariableOffset } - e.ParentHash = append(e.ParentHash, buf[0:32]...) - - // Field (1) 'FeeRecipient' - if cap(e.FeeRecipient) == 0 { - e.FeeRecipient = make([]byte, 0, len(buf[32:52])) + if sszVarOffset10 > size { + return ssz.ErrOffset } - e.FeeRecipient = append(e.FeeRecipient, buf[32:52]...) + sszSlice10 := buf[sszVarOffset10:] // c.ExtraData - // Field (2) 'StateRoot' - if cap(e.StateRoot) == 0 { - e.StateRoot = make([]byte, 0, len(buf[52:84])) - } - e.StateRoot = append(e.StateRoot, buf[52:84]...) + // Field 0: ParentHash + c.ParentHash = make([]byte, 0, 32) + c.ParentHash = append(c.ParentHash, sszSlice0...) - // Field (3) 'ReceiptsRoot' - if cap(e.ReceiptsRoot) == 0 { - e.ReceiptsRoot = make([]byte, 0, len(buf[84:116])) - } - e.ReceiptsRoot = append(e.ReceiptsRoot, buf[84:116]...) + // Field 1: FeeRecipient + c.FeeRecipient = make([]byte, 0, 20) + c.FeeRecipient = append(c.FeeRecipient, sszSlice1...) - // Field (4) 'LogsBloom' - if cap(e.LogsBloom) == 0 { - e.LogsBloom = make([]byte, 0, len(buf[116:372])) - } - e.LogsBloom = append(e.LogsBloom, buf[116:372]...) + // Field 2: StateRoot + c.StateRoot = make([]byte, 0, 32) + c.StateRoot = append(c.StateRoot, sszSlice2...) - // Field (5) 'PrevRandao' - if cap(e.PrevRandao) == 0 { - e.PrevRandao = make([]byte, 0, len(buf[372:404])) - } - e.PrevRandao = append(e.PrevRandao, buf[372:404]...) + // Field 3: ReceiptsRoot + c.ReceiptsRoot = make([]byte, 0, 32) + c.ReceiptsRoot = append(c.ReceiptsRoot, sszSlice3...) - // Field (6) 'BlockNumber' - e.BlockNumber = ssz.UnmarshallUint[uint64](buf[404:412]) + // Field 4: LogsBloom + c.LogsBloom = make([]byte, 0, 256) + c.LogsBloom = append(c.LogsBloom, sszSlice4...) - // Field (7) 'GasLimit' - e.GasLimit = ssz.UnmarshallUint[uint64](buf[412:420]) + // Field 5: PrevRandao + c.PrevRandao = make([]byte, 0, 32) + c.PrevRandao = append(c.PrevRandao, sszSlice5...) - // Field (8) 'GasUsed' - e.GasUsed = ssz.UnmarshallUint[uint64](buf[420:428]) + // Field 6: BlockNumber + c.BlockNumber = binary.LittleEndian.Uint64(sszSlice6) - // Field (9) 'Timestamp' - e.Timestamp = ssz.UnmarshallUint[uint64](buf[428:436]) + // Field 7: GasLimit + c.GasLimit = binary.LittleEndian.Uint64(sszSlice7) - // Offset (10) 'ExtraData' - if o10 = ssz.ReadOffset(buf[436:440]); o10 > size { - return ssz.ErrOffset - } + // Field 8: GasUsed + c.GasUsed = binary.LittleEndian.Uint64(sszSlice8) - if o10 != 568 { - return ssz.ErrInvalidVariableOffset - } + // Field 9: Timestamp + c.Timestamp = binary.LittleEndian.Uint64(sszSlice9) - // Field (11) 'BaseFeePerGas' - if cap(e.BaseFeePerGas) == 0 { - e.BaseFeePerGas = make([]byte, 0, len(buf[440:472])) - } - e.BaseFeePerGas = append(e.BaseFeePerGas, buf[440:472]...) + // Field 10: ExtraData + c.ExtraData = append([]byte{}, sszSlice10...) - // Field (12) 'BlockHash' - if cap(e.BlockHash) == 0 { - e.BlockHash = make([]byte, 0, len(buf[472:504])) - } - e.BlockHash = append(e.BlockHash, buf[472:504]...) + // Field 11: BaseFeePerGas + c.BaseFeePerGas = make([]byte, 0, 32) + c.BaseFeePerGas = append(c.BaseFeePerGas, sszSlice11...) - // Field (13) 'TransactionsRoot' - if cap(e.TransactionsRoot) == 0 { - e.TransactionsRoot = make([]byte, 0, len(buf[504:536])) - } - e.TransactionsRoot = append(e.TransactionsRoot, buf[504:536]...) + // Field 12: BlockHash + c.BlockHash = make([]byte, 0, 32) + c.BlockHash = append(c.BlockHash, sszSlice12...) - // Field (14) 'WithdrawalsRoot' - if cap(e.WithdrawalsRoot) == 0 { - e.WithdrawalsRoot = make([]byte, 0, len(buf[536:568])) - } - e.WithdrawalsRoot = append(e.WithdrawalsRoot, buf[536:568]...) + // Field 13: TransactionsRoot + c.TransactionsRoot = make([]byte, 0, 32) + c.TransactionsRoot = append(c.TransactionsRoot, sszSlice13...) - // 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...) - } + // Field 14: WithdrawalsRoot + c.WithdrawalsRoot = make([]byte, 0, 32) + c.WithdrawalsRoot = append(c.WithdrawalsRoot, sszSlice14...) return err } -// SizeSSZ returns the ssz encoded size in bytes for the ExecutionPayloadHeaderCapella object -func (e *ExecutionPayloadHeaderCapella) SizeSSZ() (size int) { - size = 568 - - // Field (10) 'ExtraData' - size += len(e.ExtraData) - - return -} - -// HashTreeRoot ssz hashes the ExecutionPayloadHeaderCapella object -func (e *ExecutionPayloadHeaderCapella) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(e) +func (c *ExecutionPayloadHeaderCapella) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the ExecutionPayloadHeaderCapella object with a hasher -func (e *ExecutionPayloadHeaderCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *ExecutionPayloadHeaderCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() + // Field 0: ParentHash + if len(c.ParentHash) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ParentHash) + // Field 1: FeeRecipient + if len(c.FeeRecipient) != 20 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.FeeRecipient) + // Field 2: StateRoot + if len(c.StateRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.StateRoot) + // Field 3: ReceiptsRoot + if len(c.ReceiptsRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ReceiptsRoot) + // Field 4: LogsBloom + if len(c.LogsBloom) != 256 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.LogsBloom) + // Field 5: PrevRandao + if len(c.PrevRandao) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.PrevRandao) + // Field 6: BlockNumber + hh.PutUint64(c.BlockNumber) + // Field 7: GasLimit + hh.PutUint64(c.GasLimit) + // Field 8: GasUsed + hh.PutUint64(c.GasUsed) + // Field 9: Timestamp + hh.PutUint64(c.Timestamp) + // Field 10: ExtraData - // Field (0) 'ParentHash' - if size := len(e.ParentHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentHash", size, 32) - return - } - hh.PutBytes(e.ParentHash) - - // Field (1) 'FeeRecipient' - if size := len(e.FeeRecipient); size != 20 { - err = ssz.ErrBytesLengthFn("--.FeeRecipient", size, 20) - return - } - hh.PutBytes(e.FeeRecipient) - - // Field (2) 'StateRoot' - if size := len(e.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return - } - hh.PutBytes(e.StateRoot) - - // Field (3) 'ReceiptsRoot' - if size := len(e.ReceiptsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ReceiptsRoot", size, 32) - return - } - hh.PutBytes(e.ReceiptsRoot) - - // Field (4) 'LogsBloom' - if size := len(e.LogsBloom); size != 256 { - err = ssz.ErrBytesLengthFn("--.LogsBloom", size, 256) - return - } - hh.PutBytes(e.LogsBloom) - - // Field (5) 'PrevRandao' - if size := len(e.PrevRandao); size != 32 { - err = ssz.ErrBytesLengthFn("--.PrevRandao", size, 32) - return - } - hh.PutBytes(e.PrevRandao) - - // Field (6) 'BlockNumber' - ssz.PutUint(hh, e.BlockNumber) - - // Field (7) 'GasLimit' - ssz.PutUint(hh, e.GasLimit) - - // Field (8) 'GasUsed' - ssz.PutUint(hh, e.GasUsed) - - // Field (9) 'Timestamp' - ssz.PutUint(hh, e.Timestamp) - - // Field (10) 'ExtraData' { - elemIndx := hh.Index() - byteLen := uint64(len(e.ExtraData)) - if byteLen > 32 { - err = ssz.ErrIncorrectListSize - return + if len(c.ExtraData) > 32 { + return ssz.ErrBytesLength } - hh.AppendBytes32(e.ExtraData) - hh.MerkleizeWithMixin(elemIndx, byteLen, (32+31)/32) + subIndx := hh.Index() + hh.AppendBytes32(c.ExtraData) + numItems := uint64(len(c.ExtraData)) + hh.MerkleizeWithMixin(subIndx, numItems, (32*1+31)/32) } - // Field (11) 'BaseFeePerGas' - if size := len(e.BaseFeePerGas); size != 32 { - err = ssz.ErrBytesLengthFn("--.BaseFeePerGas", size, 32) - return + // Field 11: BaseFeePerGas + if len(c.BaseFeePerGas) != 32 { + return ssz.ErrBytesLength } - hh.PutBytes(e.BaseFeePerGas) - - // Field (12) 'BlockHash' - if size := len(e.BlockHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockHash", size, 32) - return + hh.PutBytes(c.BaseFeePerGas) + // Field 12: BlockHash + if len(c.BlockHash) != 32 { + return ssz.ErrBytesLength } - hh.PutBytes(e.BlockHash) - - // Field (13) 'TransactionsRoot' - if size := len(e.TransactionsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.TransactionsRoot", size, 32) - return + hh.PutBytes(c.BlockHash) + // Field 13: TransactionsRoot + if len(c.TransactionsRoot) != 32 { + return ssz.ErrBytesLength } - hh.PutBytes(e.TransactionsRoot) - - // Field (14) 'WithdrawalsRoot' - if size := len(e.WithdrawalsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.WithdrawalsRoot", size, 32) - return + hh.PutBytes(c.TransactionsRoot) + // Field 14: WithdrawalsRoot + if len(c.WithdrawalsRoot) != 32 { + return ssz.ErrBytesLength } - hh.PutBytes(e.WithdrawalsRoot) - + hh.PutBytes(c.WithdrawalsRoot) hh.Merkleize(indx) - return + return nil +} + +func (c *ExecutionPayloadHeaderDeneb) SizeSSZ() int { + size := 584 + size += len(c.ExtraData) + return size } -// MarshalSSZ ssz marshals the ExecutionPayloadHeaderDeneb object -func (e *ExecutionPayloadHeaderDeneb) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(e) +func (c *ExecutionPayloadHeaderDeneb) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the ExecutionPayloadHeaderDeneb object to a target array -func (e *ExecutionPayloadHeaderDeneb) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(584) +func (c *ExecutionPayloadHeaderDeneb) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 584 - // Field (0) 'ParentHash' - if size := len(e.ParentHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentHash", size, 32) - return + // Field 0: ParentHash + if len(c.ParentHash) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.ParentHash...) + dst = append(dst, c.ParentHash...) - // Field (1) 'FeeRecipient' - if size := len(e.FeeRecipient); size != 20 { - err = ssz.ErrBytesLengthFn("--.FeeRecipient", size, 20) - return + // Field 1: FeeRecipient + if len(c.FeeRecipient) != 20 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.FeeRecipient...) + dst = append(dst, c.FeeRecipient...) - // Field (2) 'StateRoot' - if size := len(e.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return + // Field 2: StateRoot + if len(c.StateRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.StateRoot...) + dst = append(dst, c.StateRoot...) - // Field (3) 'ReceiptsRoot' - if size := len(e.ReceiptsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ReceiptsRoot", size, 32) - return + // Field 3: ReceiptsRoot + if len(c.ReceiptsRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.ReceiptsRoot...) + dst = append(dst, c.ReceiptsRoot...) - // Field (4) 'LogsBloom' - if size := len(e.LogsBloom); size != 256 { - err = ssz.ErrBytesLengthFn("--.LogsBloom", size, 256) - return + // Field 4: LogsBloom + if len(c.LogsBloom) != 256 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.LogsBloom...) + dst = append(dst, c.LogsBloom...) - // Field (5) 'PrevRandao' - if size := len(e.PrevRandao); size != 32 { - err = ssz.ErrBytesLengthFn("--.PrevRandao", size, 32) - return + // Field 5: PrevRandao + if len(c.PrevRandao) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.PrevRandao...) + dst = append(dst, c.PrevRandao...) - // Field (6) 'BlockNumber' - dst = ssz.MarshalUint(dst, e.BlockNumber) + // Field 6: BlockNumber + dst = binary.LittleEndian.AppendUint64(dst, c.BlockNumber) - // Field (7) 'GasLimit' - dst = ssz.MarshalUint(dst, e.GasLimit) + // Field 7: GasLimit + dst = binary.LittleEndian.AppendUint64(dst, c.GasLimit) - // Field (8) 'GasUsed' - dst = ssz.MarshalUint(dst, e.GasUsed) + // Field 8: GasUsed + dst = binary.LittleEndian.AppendUint64(dst, c.GasUsed) - // Field (9) 'Timestamp' - dst = ssz.MarshalUint(dst, e.Timestamp) + // Field 9: Timestamp + dst = binary.LittleEndian.AppendUint64(dst, c.Timestamp) - // Offset (10) 'ExtraData' + // Field 10: ExtraData dst = ssz.WriteOffset(dst, offset) - offset += len(e.ExtraData) + offset += len(c.ExtraData) - // Field (11) 'BaseFeePerGas' - if size := len(e.BaseFeePerGas); size != 32 { - err = ssz.ErrBytesLengthFn("--.BaseFeePerGas", size, 32) - return + // Field 11: BaseFeePerGas + if len(c.BaseFeePerGas) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.BaseFeePerGas...) + dst = append(dst, c.BaseFeePerGas...) - // Field (12) 'BlockHash' - if size := len(e.BlockHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockHash", size, 32) - return + // Field 12: BlockHash + if len(c.BlockHash) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.BlockHash...) + dst = append(dst, c.BlockHash...) - // Field (13) 'TransactionsRoot' - if size := len(e.TransactionsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.TransactionsRoot", size, 32) - return + // Field 13: TransactionsRoot + if len(c.TransactionsRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.TransactionsRoot...) + dst = append(dst, c.TransactionsRoot...) - // Field (14) 'WithdrawalsRoot' - if size := len(e.WithdrawalsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.WithdrawalsRoot", size, 32) - return + // Field 14: WithdrawalsRoot + if len(c.WithdrawalsRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.WithdrawalsRoot...) + dst = append(dst, c.WithdrawalsRoot...) - // Field (15) 'BlobGasUsed' - dst = ssz.MarshalUint(dst, e.BlobGasUsed) + // Field 15: BlobGasUsed + dst = binary.LittleEndian.AppendUint64(dst, c.BlobGasUsed) - // Field (16) 'ExcessBlobGas' - dst = ssz.MarshalUint(dst, e.ExcessBlobGas) + // Field 16: ExcessBlobGas + dst = binary.LittleEndian.AppendUint64(dst, c.ExcessBlobGas) - // Field (10) 'ExtraData' - if size := len(e.ExtraData); size > 32 { - err = ssz.ErrBytesLengthFn("--.ExtraData", size, 32) - return + // Field 10: ExtraData + if len(c.ExtraData) > 32 { + return nil, ssz.ErrListTooBig } - dst = append(dst, e.ExtraData...) - - return + dst = append(dst, c.ExtraData...) + return dst, err } -// UnmarshalSSZ ssz unmarshals the ExecutionPayloadHeaderDeneb object -func (e *ExecutionPayloadHeaderDeneb) UnmarshalSSZ(buf []byte) error { +func (c *ExecutionPayloadHeaderDeneb) 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' - if cap(e.ParentHash) == 0 { - e.ParentHash = make([]byte, 0, len(buf[0:32])) - } - e.ParentHash = append(e.ParentHash, buf[0:32]...) - - // Field (1) 'FeeRecipient' - if cap(e.FeeRecipient) == 0 { - e.FeeRecipient = make([]byte, 0, len(buf[32:52])) - } - e.FeeRecipient = append(e.FeeRecipient, buf[32:52]...) - - // Field (2) 'StateRoot' - if cap(e.StateRoot) == 0 { - e.StateRoot = make([]byte, 0, len(buf[52:84])) - } - e.StateRoot = append(e.StateRoot, buf[52:84]...) - - // Field (3) 'ReceiptsRoot' - if cap(e.ReceiptsRoot) == 0 { - e.ReceiptsRoot = make([]byte, 0, len(buf[84:116])) - } - e.ReceiptsRoot = append(e.ReceiptsRoot, buf[84:116]...) - - // Field (4) 'LogsBloom' - if cap(e.LogsBloom) == 0 { - e.LogsBloom = make([]byte, 0, len(buf[116:372])) - } - e.LogsBloom = append(e.LogsBloom, buf[116:372]...) - - // Field (5) 'PrevRandao' - if cap(e.PrevRandao) == 0 { - e.PrevRandao = make([]byte, 0, len(buf[372:404])) - } - e.PrevRandao = append(e.PrevRandao, buf[372:404]...) - - // Field (6) 'BlockNumber' - e.BlockNumber = ssz.UnmarshallUint[uint64](buf[404:412]) - - // Field (7) 'GasLimit' - e.GasLimit = ssz.UnmarshallUint[uint64](buf[412:420]) - - // Field (8) 'GasUsed' - e.GasUsed = ssz.UnmarshallUint[uint64](buf[420:428]) - - // Field (9) 'Timestamp' - e.Timestamp = ssz.UnmarshallUint[uint64](buf[428:436]) - - // Offset (10) 'ExtraData' - if o10 = ssz.ReadOffset(buf[436:440]); o10 > size { - return ssz.ErrOffset - } - - if o10 != 584 { + sszSlice0 := buf[0:32] // c.ParentHash + sszSlice1 := buf[32:52] // c.FeeRecipient + sszSlice2 := buf[52:84] // c.StateRoot + sszSlice3 := buf[84:116] // c.ReceiptsRoot + sszSlice4 := buf[116:372] // c.LogsBloom + sszSlice5 := buf[372:404] // c.PrevRandao + sszSlice6 := buf[404:412] // c.BlockNumber + sszSlice7 := buf[412:420] // c.GasLimit + sszSlice8 := buf[420:428] // c.GasUsed + sszSlice9 := buf[428:436] // c.Timestamp + sszSlice11 := buf[440:472] // c.BaseFeePerGas + sszSlice12 := buf[472:504] // c.BlockHash + sszSlice13 := buf[504:536] // c.TransactionsRoot + sszSlice14 := buf[536:568] // c.WithdrawalsRoot + sszSlice15 := buf[568:576] // c.BlobGasUsed + sszSlice16 := buf[576:584] // c.ExcessBlobGas + + sszVarOffset10 := ssz.ReadOffset(buf[436:440]) // c.ExtraData + if sszVarOffset10 != 584 { return ssz.ErrInvalidVariableOffset } - - // Field (11) 'BaseFeePerGas' - if cap(e.BaseFeePerGas) == 0 { - e.BaseFeePerGas = make([]byte, 0, len(buf[440:472])) - } - e.BaseFeePerGas = append(e.BaseFeePerGas, buf[440:472]...) - - // Field (12) 'BlockHash' - if cap(e.BlockHash) == 0 { - e.BlockHash = make([]byte, 0, len(buf[472:504])) - } - e.BlockHash = append(e.BlockHash, buf[472:504]...) - - // Field (13) 'TransactionsRoot' - if cap(e.TransactionsRoot) == 0 { - e.TransactionsRoot = make([]byte, 0, len(buf[504:536])) - } - e.TransactionsRoot = append(e.TransactionsRoot, buf[504:536]...) - - // Field (14) 'WithdrawalsRoot' - if cap(e.WithdrawalsRoot) == 0 { - e.WithdrawalsRoot = make([]byte, 0, len(buf[536:568])) - } - e.WithdrawalsRoot = append(e.WithdrawalsRoot, buf[536:568]...) - - // Field (15) 'BlobGasUsed' - e.BlobGasUsed = ssz.UnmarshallUint[uint64](buf[568:576]) - - // Field (16) 'ExcessBlobGas' - e.ExcessBlobGas = ssz.UnmarshallUint[uint64](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 ExecutionPayloadHeaderDeneb object -func (e *ExecutionPayloadHeaderDeneb) SizeSSZ() (size int) { - size = 584 - - // Field (10) 'ExtraData' - size += len(e.ExtraData) - - return -} - -// HashTreeRoot ssz hashes the ExecutionPayloadHeaderDeneb object -func (e *ExecutionPayloadHeaderDeneb) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(e) -} - -// HashTreeRootWith ssz hashes the ExecutionPayloadHeaderDeneb object with a hasher -func (e *ExecutionPayloadHeaderDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'ParentHash' - if size := len(e.ParentHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentHash", size, 32) - return - } - hh.PutBytes(e.ParentHash) - - // Field (1) 'FeeRecipient' - if size := len(e.FeeRecipient); size != 20 { - err = ssz.ErrBytesLengthFn("--.FeeRecipient", size, 20) - return - } - hh.PutBytes(e.FeeRecipient) - - // Field (2) 'StateRoot' - if size := len(e.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return - } - hh.PutBytes(e.StateRoot) - - // Field (3) 'ReceiptsRoot' - if size := len(e.ReceiptsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ReceiptsRoot", size, 32) - return - } - hh.PutBytes(e.ReceiptsRoot) - - // Field (4) 'LogsBloom' - if size := len(e.LogsBloom); size != 256 { - err = ssz.ErrBytesLengthFn("--.LogsBloom", size, 256) - return - } - hh.PutBytes(e.LogsBloom) - - // Field (5) 'PrevRandao' - if size := len(e.PrevRandao); size != 32 { - err = ssz.ErrBytesLengthFn("--.PrevRandao", size, 32) - return - } - hh.PutBytes(e.PrevRandao) - - // Field (6) 'BlockNumber' - ssz.PutUint(hh, e.BlockNumber) - - // Field (7) 'GasLimit' - ssz.PutUint(hh, e.GasLimit) - - // Field (8) 'GasUsed' - ssz.PutUint(hh, e.GasUsed) - - // Field (9) 'Timestamp' - ssz.PutUint(hh, e.Timestamp) - - // Field (10) 'ExtraData' - { - elemIndx := hh.Index() - byteLen := uint64(len(e.ExtraData)) - if byteLen > 32 { - err = ssz.ErrIncorrectListSize - return - } - hh.AppendBytes32(e.ExtraData) - hh.MerkleizeWithMixin(elemIndx, byteLen, (32+31)/32) - } - - // Field (11) 'BaseFeePerGas' - if size := len(e.BaseFeePerGas); size != 32 { - err = ssz.ErrBytesLengthFn("--.BaseFeePerGas", size, 32) - return - } - hh.PutBytes(e.BaseFeePerGas) - - // Field (12) 'BlockHash' - if size := len(e.BlockHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockHash", size, 32) - return - } - hh.PutBytes(e.BlockHash) - - // Field (13) 'TransactionsRoot' - if size := len(e.TransactionsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.TransactionsRoot", size, 32) - return + if sszVarOffset10 > size { + return ssz.ErrOffset } - hh.PutBytes(e.TransactionsRoot) + sszSlice10 := buf[sszVarOffset10:] // c.ExtraData - // Field (14) 'WithdrawalsRoot' - if size := len(e.WithdrawalsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.WithdrawalsRoot", size, 32) - return - } - hh.PutBytes(e.WithdrawalsRoot) + // Field 0: ParentHash + c.ParentHash = make([]byte, 0, 32) + c.ParentHash = append(c.ParentHash, sszSlice0...) - // Field (15) 'BlobGasUsed' - ssz.PutUint(hh, e.BlobGasUsed) + // Field 1: FeeRecipient + c.FeeRecipient = make([]byte, 0, 20) + c.FeeRecipient = append(c.FeeRecipient, sszSlice1...) - // Field (16) 'ExcessBlobGas' - ssz.PutUint(hh, e.ExcessBlobGas) + // Field 2: StateRoot + c.StateRoot = make([]byte, 0, 32) + c.StateRoot = append(c.StateRoot, sszSlice2...) - hh.Merkleize(indx) - return -} + // Field 3: ReceiptsRoot + c.ReceiptsRoot = make([]byte, 0, 32) + c.ReceiptsRoot = append(c.ReceiptsRoot, sszSlice3...) -// MarshalSSZ ssz marshals the Withdrawal object -func (w *Withdrawal) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(w) -} + // Field 4: LogsBloom + c.LogsBloom = make([]byte, 0, 256) + c.LogsBloom = append(c.LogsBloom, sszSlice4...) -// MarshalSSZTo ssz marshals the Withdrawal object to a target array -func (w *Withdrawal) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf + // Field 5: PrevRandao + c.PrevRandao = make([]byte, 0, 32) + c.PrevRandao = append(c.PrevRandao, sszSlice5...) - // Field (0) 'Index' - dst = ssz.MarshalUint(dst, w.Index) + // Field 6: BlockNumber + c.BlockNumber = binary.LittleEndian.Uint64(sszSlice6) - // Field (1) 'ValidatorIndex' - dst = ssz.MarshalUint(dst, w.ValidatorIndex) + // Field 7: GasLimit + c.GasLimit = binary.LittleEndian.Uint64(sszSlice7) - // Field (2) 'Address' - if size := len(w.Address); size != 20 { - err = ssz.ErrBytesLengthFn("--.Address", size, 20) - return - } - dst = append(dst, w.Address...) + // Field 8: GasUsed + c.GasUsed = binary.LittleEndian.Uint64(sszSlice8) - // Field (3) 'Amount' - dst = ssz.MarshalUint(dst, w.Amount) + // Field 9: Timestamp + c.Timestamp = binary.LittleEndian.Uint64(sszSlice9) - return -} + // Field 10: ExtraData + c.ExtraData = append([]byte{}, sszSlice10...) -// 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 11: BaseFeePerGas + c.BaseFeePerGas = make([]byte, 0, 32) + c.BaseFeePerGas = append(c.BaseFeePerGas, sszSlice11...) - // Field (0) 'Index' - w.Index = ssz.UnmarshallUint[uint64](buf[0:8]) + // Field 12: BlockHash + c.BlockHash = make([]byte, 0, 32) + c.BlockHash = append(c.BlockHash, sszSlice12...) - // Field (1) 'ValidatorIndex' - w.ValidatorIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[8:16]) + // Field 13: TransactionsRoot + c.TransactionsRoot = make([]byte, 0, 32) + c.TransactionsRoot = append(c.TransactionsRoot, sszSlice13...) - // Field (2) 'Address' - if cap(w.Address) == 0 { - w.Address = make([]byte, 0, len(buf[16:36])) - } - w.Address = append(w.Address, buf[16:36]...) + // Field 14: WithdrawalsRoot + c.WithdrawalsRoot = make([]byte, 0, 32) + c.WithdrawalsRoot = append(c.WithdrawalsRoot, sszSlice14...) - // Field (3) 'Amount' - w.Amount = ssz.UnmarshallUint[uint64](buf[36:44]) + // Field 15: BlobGasUsed + c.BlobGasUsed = binary.LittleEndian.Uint64(sszSlice15) + // Field 16: ExcessBlobGas + c.ExcessBlobGas = binary.LittleEndian.Uint64(sszSlice16) 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.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'Index' - ssz.PutUint(hh, w.Index) - - // Field (1) 'ValidatorIndex' - ssz.PutUint(hh, w.ValidatorIndex) - - // Field (2) 'Address' - if size := len(w.Address); size != 20 { - err = ssz.ErrBytesLengthFn("--.Address", size, 20) - return +func (c *ExecutionPayloadHeaderDeneb) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - hh.PutBytes(w.Address) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (3) 'Amount' - ssz.PutUint(hh, w.Amount) +func (c *ExecutionPayloadHeaderDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: ParentHash + if len(c.ParentHash) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ParentHash) + // Field 1: FeeRecipient + if len(c.FeeRecipient) != 20 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.FeeRecipient) + // Field 2: StateRoot + if len(c.StateRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.StateRoot) + // Field 3: ReceiptsRoot + if len(c.ReceiptsRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ReceiptsRoot) + // Field 4: LogsBloom + if len(c.LogsBloom) != 256 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.LogsBloom) + // Field 5: PrevRandao + if len(c.PrevRandao) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.PrevRandao) + // Field 6: BlockNumber + hh.PutUint64(c.BlockNumber) + // Field 7: GasLimit + hh.PutUint64(c.GasLimit) + // Field 8: GasUsed + hh.PutUint64(c.GasUsed) + // Field 9: Timestamp + hh.PutUint64(c.Timestamp) + // Field 10: ExtraData + { + if len(c.ExtraData) > 32 { + return ssz.ErrBytesLength + } + subIndx := hh.Index() + hh.AppendBytes32(c.ExtraData) + numItems := uint64(len(c.ExtraData)) + hh.MerkleizeWithMixin(subIndx, numItems, (32*1+31)/32) + } + + // Field 11: BaseFeePerGas + if len(c.BaseFeePerGas) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.BaseFeePerGas) + // Field 12: BlockHash + if len(c.BlockHash) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.BlockHash) + // Field 13: TransactionsRoot + if len(c.TransactionsRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.TransactionsRoot) + // Field 14: WithdrawalsRoot + if len(c.WithdrawalsRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.WithdrawalsRoot) + // Field 15: BlobGasUsed + hh.PutUint64(c.BlobGasUsed) + // Field 16: ExcessBlobGas + hh.PutUint64(c.ExcessBlobGas) hh.Merkleize(indx) - return + return nil +} + +func (c *ExecutionRequests) SizeSSZ() int { + size := 12 + size += len(c.Deposits) * 192 + size += len(c.Withdrawals) * 76 + size += len(c.Consolidations) * 116 + return size } -// MarshalSSZ ssz marshals the BlobsBundle object -func (b *BlobsBundle) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) +func (c *ExecutionRequests) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the BlobsBundle object to a target array -func (b *BlobsBundle) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(12) +func (c *ExecutionRequests) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 12 - // Offset (0) 'KzgCommitments' + // Field 0: Deposits dst = ssz.WriteOffset(dst, offset) - offset += len(b.KzgCommitments) * 48 + offset += len(c.Deposits) * 192 - // Offset (1) 'Proofs' + // Field 1: Withdrawals dst = ssz.WriteOffset(dst, offset) - offset += len(b.Proofs) * 48 + offset += len(c.Withdrawals) * 76 - // Offset (2) 'Blobs' + // Field 2: Consolidations dst = ssz.WriteOffset(dst, offset) - offset += len(b.Blobs) * 131072 + offset += len(c.Consolidations) * 116 - // Field (0) 'KzgCommitments' - if size := len(b.KzgCommitments); size > 4096 { - err = ssz.ErrListTooBigFn("--.KzgCommitments", size, 4096) - return + // Field 0: Deposits + if len(c.Deposits) > 8192 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.KzgCommitments); ii++ { - if size := len(b.KzgCommitments[ii]); size != 48 { - err = ssz.ErrBytesLengthFn("--.KzgCommitments[ii]", size, 48) - return + for _, o := range c.Deposits { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Deposits: %w", err) } - dst = append(dst, b.KzgCommitments[ii]...) } - // Field (1) 'Proofs' - if size := len(b.Proofs); size > 4096 { - err = ssz.ErrListTooBigFn("--.Proofs", size, 4096) - return + // Field 1: Withdrawals + if len(c.Withdrawals) > 16 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.Proofs); ii++ { - if size := len(b.Proofs[ii]); size != 48 { - err = ssz.ErrBytesLengthFn("--.Proofs[ii]", size, 48) - return + for _, o := range c.Withdrawals { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Withdrawals: %w", err) } - dst = append(dst, b.Proofs[ii]...) } - // Field (2) 'Blobs' - if size := len(b.Blobs); size > 4096 { - err = ssz.ErrListTooBigFn("--.Blobs", size, 4096) - return + // Field 2: Consolidations + if len(c.Consolidations) > 2 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.Blobs); ii++ { - if size := len(b.Blobs[ii]); size != 131072 { - err = ssz.ErrBytesLengthFn("--.Blobs[ii]", size, 131072) - return + for _, o := range c.Consolidations { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Consolidations: %w", err) } - dst = append(dst, b.Blobs[ii]...) } - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the BlobsBundle object -func (b *BlobsBundle) UnmarshalSSZ(buf []byte) error { +func (c *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) 'KzgCommitments' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } - - if o0 != 12 { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Deposits + if sszVarOffset0 != 12 { return ssz.ErrInvalidVariableOffset } - - // Offset (1) 'Proofs' - if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 { + if sszVarOffset0 > size { return ssz.ErrOffset } - - // Offset (2) 'Blobs' - if o2 = ssz.ReadOffset(buf[8:12]); o2 > size || o1 > o2 { + sszVarOffset1 := ssz.ReadOffset(buf[4:8]) // c.Withdrawals + if sszVarOffset1 > size || sszVarOffset1 < sszVarOffset0 { + return ssz.ErrOffset + } + sszVarOffset2 := ssz.ReadOffset(buf[8:12]) // c.Consolidations + if sszVarOffset2 > size || sszVarOffset2 < sszVarOffset1 { return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:sszVarOffset1] // c.Deposits + sszSlice1 := buf[sszVarOffset1:sszVarOffset2] // c.Withdrawals + sszSlice2 := buf[sszVarOffset2:] // c.Consolidations - // Field (0) 'KzgCommitments' + // Field 0: Deposits { - buf = tail[o0:o1] - num, err := ssz.DivideInt2(len(buf), 48, 4096) - if err != nil { - return err - } - b.KzgCommitments = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(b.KzgCommitments[ii]) == 0 { - b.KzgCommitments[ii] = make([]byte, 0, len(buf[ii*48:(ii+1)*48])) + if len(sszSlice0)%192 != 0 { + return fmt.Errorf("misaligned bytes: c.Deposits length is %d, which is not a multiple of 192: %w", len(sszSlice0), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice0) / 192 + if numElem > 8192 { + return fmt.Errorf("ssz-max exceeded: c.Deposits has %d elements, ssz-max is 8192: %w", numElem, ssz.ErrListTooBig) + } + c.Deposits = make([]*DepositRequest, numElem) + for i := 0; i < numElem; i++ { + var tmp *DepositRequest + tmp = new(DepositRequest) + tmpSlice := sszSlice0[i*192 : (1+i)*192] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Deposits: %w", err) } - b.KzgCommitments[ii] = append(b.KzgCommitments[ii], buf[ii*48:(ii+1)*48]...) + c.Deposits[i] = tmp } } - // Field (1) 'Proofs' + // Field 1: Withdrawals { - buf = tail[o1:o2] - num, err := ssz.DivideInt2(len(buf), 48, 4096) - if err != nil { - return err - } - b.Proofs = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(b.Proofs[ii]) == 0 { - b.Proofs[ii] = make([]byte, 0, len(buf[ii*48:(ii+1)*48])) + if len(sszSlice1)%76 != 0 { + return fmt.Errorf("misaligned bytes: c.Withdrawals length is %d, which is not a multiple of 76: %w", len(sszSlice1), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice1) / 76 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.Withdrawals has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.Withdrawals = make([]*WithdrawalRequest, numElem) + for i := 0; i < numElem; i++ { + var tmp *WithdrawalRequest + tmp = new(WithdrawalRequest) + tmpSlice := sszSlice1[i*76 : (1+i)*76] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Withdrawals: %w", err) } - b.Proofs[ii] = append(b.Proofs[ii], buf[ii*48:(ii+1)*48]...) + c.Withdrawals[i] = tmp } } - // Field (2) 'Blobs' + // Field 2: Consolidations { - buf = tail[o2:] - num, err := ssz.DivideInt2(len(buf), 131072, 4096) - if err != nil { - return err - } - b.Blobs = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(b.Blobs[ii]) == 0 { - b.Blobs[ii] = make([]byte, 0, len(buf[ii*131072:(ii+1)*131072])) + if len(sszSlice2)%116 != 0 { + return fmt.Errorf("misaligned bytes: c.Consolidations length is %d, which is not a multiple of 116: %w", len(sszSlice2), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice2) / 116 + if numElem > 2 { + return fmt.Errorf("ssz-max exceeded: c.Consolidations has %d elements, ssz-max is 2: %w", numElem, ssz.ErrListTooBig) + } + c.Consolidations = make([]*ConsolidationRequest, numElem) + for i := 0; i < numElem; i++ { + var tmp *ConsolidationRequest + tmp = new(ConsolidationRequest) + tmpSlice := sszSlice2[i*116 : (1+i)*116] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Consolidations: %w", err) } - b.Blobs[ii] = append(b.Blobs[ii], buf[ii*131072:(ii+1)*131072]...) + c.Consolidations[i] = tmp } } return err } -// SizeSSZ returns the ssz encoded size in bytes for the BlobsBundle object -func (b *BlobsBundle) SizeSSZ() (size int) { - size = 12 - - // Field (0) 'KzgCommitments' - size += len(b.KzgCommitments) * 48 - - // Field (1) 'Proofs' - size += len(b.Proofs) * 48 - - // Field (2) 'Blobs' - size += len(b.Blobs) * 131072 - - return -} - -// HashTreeRoot ssz hashes the BlobsBundle object -func (b *BlobsBundle) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) +func (c *ExecutionRequests) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the BlobsBundle object with a hasher -func (b *BlobsBundle) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *ExecutionRequests) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'KzgCommitments' + // Field 0: Deposits { - if size := len(b.KzgCommitments); size > 4096 { - err = ssz.ErrListTooBigFn("--.KzgCommitments", size, 4096) - return + if len(c.Deposits) > 8192 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range b.KzgCommitments { - if len(i) != 48 { - err = ssz.ErrBytesLength - return + for _, o := range c.Deposits { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Deposits: %w", err) } - hh.PutBytes(i) } - - numItems := uint64(len(b.KzgCommitments)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Deposits)), 8192) } - - // Field (1) 'Proofs' + // Field 1: Withdrawals { - if size := len(b.Proofs); size > 4096 { - err = ssz.ErrListTooBigFn("--.Proofs", size, 4096) - return + if len(c.Withdrawals) > 16 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range b.Proofs { - if len(i) != 48 { - err = ssz.ErrBytesLength - return + for _, o := range c.Withdrawals { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Withdrawals: %w", err) } - hh.PutBytes(i) } - - numItems := uint64(len(b.Proofs)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Withdrawals)), 16) } - - // Field (2) 'Blobs' + // Field 2: Consolidations { - if size := len(b.Blobs); size > 4096 { - err = ssz.ErrListTooBigFn("--.Blobs", size, 4096) - return + if len(c.Consolidations) > 2 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range b.Blobs { - if len(i) != 131072 { - err = ssz.ErrBytesLength - return + for _, o := range c.Consolidations { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Consolidations: %w", err) } - hh.PutBytes(i) } - - numItems := uint64(len(b.Blobs)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Consolidations)), 2) } - hh.Merkleize(indx) - return + return nil +} + +func (c *ExecutionRequestsGloas) SizeSSZ() int { + size := 20 + size += len(c.Deposits) * 192 + size += len(c.Withdrawals) * 76 + size += len(c.Consolidations) * 116 + size += len(c.BuilderDeposits) * 184 + size += len(c.BuilderExits) * 68 + return size } -// MarshalSSZ ssz marshals the BlobsBundleV2 object -func (b *BlobsBundleV2) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) +func (c *ExecutionRequestsGloas) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the BlobsBundleV2 object to a target array -func (b *BlobsBundleV2) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(12) +func (c *ExecutionRequestsGloas) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 20 + + // Field 0: Deposits + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Deposits) * 192 + + // Field 1: Withdrawals + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Withdrawals) * 76 - // Offset (0) 'KzgCommitments' + // Field 2: Consolidations dst = ssz.WriteOffset(dst, offset) - offset += len(b.KzgCommitments) * 48 + offset += len(c.Consolidations) * 116 - // Offset (1) 'Proofs' + // Field 3: BuilderDeposits dst = ssz.WriteOffset(dst, offset) - offset += len(b.Proofs) * 48 + offset += len(c.BuilderDeposits) * 184 - // Offset (2) 'Blobs' + // Field 4: BuilderExits dst = ssz.WriteOffset(dst, offset) - offset += len(b.Blobs) * 131072 + offset += len(c.BuilderExits) * 68 + + // Field 0: Deposits + if len(c.Deposits) > 8192 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.Deposits { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Deposits: %w", err) + } + } - // Field (0) 'KzgCommitments' - if size := len(b.KzgCommitments); size > 4096 { - err = ssz.ErrListTooBigFn("--.KzgCommitments", size, 4096) - return + // Field 1: Withdrawals + if len(c.Withdrawals) > 16 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.KzgCommitments); ii++ { - if size := len(b.KzgCommitments[ii]); size != 48 { - err = ssz.ErrBytesLengthFn("--.KzgCommitments[ii]", size, 48) - return + for _, o := range c.Withdrawals { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Withdrawals: %w", err) } - dst = append(dst, b.KzgCommitments[ii]...) } - // Field (1) 'Proofs' - if size := len(b.Proofs); size > 33554432 { - err = ssz.ErrListTooBigFn("--.Proofs", size, 33554432) - return + // Field 2: Consolidations + if len(c.Consolidations) > 2 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.Proofs); ii++ { - if size := len(b.Proofs[ii]); size != 48 { - err = ssz.ErrBytesLengthFn("--.Proofs[ii]", size, 48) - return + for _, o := range c.Consolidations { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Consolidations: %w", err) } - dst = append(dst, b.Proofs[ii]...) } - // Field (2) 'Blobs' - if size := len(b.Blobs); size > 4096 { - err = ssz.ErrListTooBigFn("--.Blobs", size, 4096) - return + // Field 3: BuilderDeposits + if len(c.BuilderDeposits) > 256 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.Blobs); ii++ { - if size := len(b.Blobs[ii]); size != 131072 { - err = ssz.ErrBytesLengthFn("--.Blobs[ii]", size, 131072) - return + for _, o := range c.BuilderDeposits { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("BuilderDeposits: %w", err) } - dst = append(dst, b.Blobs[ii]...) } - return + // Field 4: BuilderExits + if len(c.BuilderExits) > 16 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.BuilderExits { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("BuilderExits: %w", err) + } + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the BlobsBundleV2 object -func (b *BlobsBundleV2) UnmarshalSSZ(buf []byte) error { +func (c *ExecutionRequestsGloas) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 12 { + if size < 20 { return ssz.ErrSize } - tail := buf - var o0, o1, o2 uint64 - - // Offset (0) 'KzgCommitments' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Deposits + if sszVarOffset0 != 20 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset0 > size { return ssz.ErrOffset } - - if o0 != 12 { - return ssz.ErrInvalidVariableOffset + sszVarOffset1 := ssz.ReadOffset(buf[4:8]) // c.Withdrawals + if sszVarOffset1 > size || sszVarOffset1 < sszVarOffset0 { + return ssz.ErrOffset } - - // Offset (1) 'Proofs' - if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 { + sszVarOffset2 := ssz.ReadOffset(buf[8:12]) // c.Consolidations + if sszVarOffset2 > size || sszVarOffset2 < sszVarOffset1 { return ssz.ErrOffset } - - // Offset (2) 'Blobs' - if o2 = ssz.ReadOffset(buf[8:12]); o2 > size || o1 > o2 { + sszVarOffset3 := ssz.ReadOffset(buf[12:16]) // c.BuilderDeposits + if sszVarOffset3 > size || sszVarOffset3 < sszVarOffset2 { + return ssz.ErrOffset + } + sszVarOffset4 := ssz.ReadOffset(buf[16:20]) // c.BuilderExits + if sszVarOffset4 > size || sszVarOffset4 < sszVarOffset3 { return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:sszVarOffset1] // c.Deposits + sszSlice1 := buf[sszVarOffset1:sszVarOffset2] // c.Withdrawals + sszSlice2 := buf[sszVarOffset2:sszVarOffset3] // c.Consolidations + sszSlice3 := buf[sszVarOffset3:sszVarOffset4] // c.BuilderDeposits + sszSlice4 := buf[sszVarOffset4:] // c.BuilderExits - // Field (0) 'KzgCommitments' + // Field 0: Deposits { - buf = tail[o0:o1] - num, err := ssz.DivideInt2(len(buf), 48, 4096) - if err != nil { - return err - } - b.KzgCommitments = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(b.KzgCommitments[ii]) == 0 { - b.KzgCommitments[ii] = make([]byte, 0, len(buf[ii*48:(ii+1)*48])) + if len(sszSlice0)%192 != 0 { + return fmt.Errorf("misaligned bytes: c.Deposits length is %d, which is not a multiple of 192: %w", len(sszSlice0), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice0) / 192 + if numElem > 8192 { + return fmt.Errorf("ssz-max exceeded: c.Deposits has %d elements, ssz-max is 8192: %w", numElem, ssz.ErrListTooBig) + } + c.Deposits = make([]*DepositRequest, numElem) + for i := 0; i < numElem; i++ { + var tmp *DepositRequest + tmp = new(DepositRequest) + tmpSlice := sszSlice0[i*192 : (1+i)*192] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Deposits: %w", err) } - b.KzgCommitments[ii] = append(b.KzgCommitments[ii], buf[ii*48:(ii+1)*48]...) + c.Deposits[i] = tmp } } - // Field (1) 'Proofs' + // Field 1: Withdrawals { - buf = tail[o1:o2] - num, err := ssz.DivideInt2(len(buf), 48, 33554432) - if err != nil { - return err - } - b.Proofs = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(b.Proofs[ii]) == 0 { - b.Proofs[ii] = make([]byte, 0, len(buf[ii*48:(ii+1)*48])) + if len(sszSlice1)%76 != 0 { + return fmt.Errorf("misaligned bytes: c.Withdrawals length is %d, which is not a multiple of 76: %w", len(sszSlice1), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice1) / 76 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.Withdrawals has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.Withdrawals = make([]*WithdrawalRequest, numElem) + for i := 0; i < numElem; i++ { + var tmp *WithdrawalRequest + tmp = new(WithdrawalRequest) + tmpSlice := sszSlice1[i*76 : (1+i)*76] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Withdrawals: %w", err) } - b.Proofs[ii] = append(b.Proofs[ii], buf[ii*48:(ii+1)*48]...) + c.Withdrawals[i] = tmp } } - // Field (2) 'Blobs' + // Field 2: Consolidations { - buf = tail[o2:] - num, err := ssz.DivideInt2(len(buf), 131072, 4096) - if err != nil { - return err - } - b.Blobs = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(b.Blobs[ii]) == 0 { - b.Blobs[ii] = make([]byte, 0, len(buf[ii*131072:(ii+1)*131072])) + if len(sszSlice2)%116 != 0 { + return fmt.Errorf("misaligned bytes: c.Consolidations length is %d, which is not a multiple of 116: %w", len(sszSlice2), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice2) / 116 + if numElem > 2 { + return fmt.Errorf("ssz-max exceeded: c.Consolidations has %d elements, ssz-max is 2: %w", numElem, ssz.ErrListTooBig) + } + c.Consolidations = make([]*ConsolidationRequest, numElem) + for i := 0; i < numElem; i++ { + var tmp *ConsolidationRequest + tmp = new(ConsolidationRequest) + tmpSlice := sszSlice2[i*116 : (1+i)*116] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Consolidations: %w", err) } - b.Blobs[ii] = append(b.Blobs[ii], buf[ii*131072:(ii+1)*131072]...) + c.Consolidations[i] = tmp } } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the BlobsBundleV2 object -func (b *BlobsBundleV2) SizeSSZ() (size int) { - size = 12 - // Field (0) 'KzgCommitments' - size += len(b.KzgCommitments) * 48 - - // Field (1) 'Proofs' - size += len(b.Proofs) * 48 - - // Field (2) 'Blobs' - size += len(b.Blobs) * 131072 + // Field 3: BuilderDeposits + { + if len(sszSlice3)%184 != 0 { + return fmt.Errorf("misaligned bytes: c.BuilderDeposits length is %d, which is not a multiple of 184: %w", len(sszSlice3), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice3) / 184 + if numElem > 256 { + return fmt.Errorf("ssz-max exceeded: c.BuilderDeposits has %d elements, ssz-max is 256: %w", numElem, ssz.ErrListTooBig) + } + c.BuilderDeposits = make([]*BuilderDepositRequest, numElem) + for i := 0; i < numElem; i++ { + var tmp *BuilderDepositRequest + tmp = new(BuilderDepositRequest) + tmpSlice := sszSlice3[i*184 : (1+i)*184] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("BuilderDeposits: %w", err) + } + c.BuilderDeposits[i] = tmp + } + } - return + // Field 4: BuilderExits + { + if len(sszSlice4)%68 != 0 { + return fmt.Errorf("misaligned bytes: c.BuilderExits length is %d, which is not a multiple of 68: %w", len(sszSlice4), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice4) / 68 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.BuilderExits has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.BuilderExits = make([]*BuilderExitRequest, numElem) + for i := 0; i < numElem; i++ { + var tmp *BuilderExitRequest + tmp = new(BuilderExitRequest) + tmpSlice := sszSlice4[i*68 : (1+i)*68] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("BuilderExits: %w", err) + } + c.BuilderExits[i] = tmp + } + } + return err } -// HashTreeRoot ssz hashes the BlobsBundleV2 object -func (b *BlobsBundleV2) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) +func (c *ExecutionRequestsGloas) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the BlobsBundleV2 object with a hasher -func (b *BlobsBundleV2) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *ExecutionRequestsGloas) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'KzgCommitments' + // Field 0: Deposits { - if size := len(b.KzgCommitments); size > 4096 { - err = ssz.ErrListTooBigFn("--.KzgCommitments", size, 4096) - return + if len(c.Deposits) > 8192 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range b.KzgCommitments { - if len(i) != 48 { - err = ssz.ErrBytesLength - return + for _, o := range c.Deposits { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Deposits: %w", err) } - hh.PutBytes(i) } - - numItems := uint64(len(b.KzgCommitments)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Deposits)), 8192) } - - // Field (1) 'Proofs' + // Field 1: Withdrawals { - if size := len(b.Proofs); size > 33554432 { - err = ssz.ErrListTooBigFn("--.Proofs", size, 33554432) - return + if len(c.Withdrawals) > 16 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range b.Proofs { - if len(i) != 48 { - err = ssz.ErrBytesLength - return + for _, o := range c.Withdrawals { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Withdrawals: %w", err) } - hh.PutBytes(i) } - - numItems := uint64(len(b.Proofs)) - hh.MerkleizeWithMixin(subIndx, numItems, 33554432) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Withdrawals)), 16) } - - // Field (2) 'Blobs' + // Field 2: Consolidations { - if size := len(b.Blobs); size > 4096 { - err = ssz.ErrListTooBigFn("--.Blobs", size, 4096) - return + if len(c.Consolidations) > 2 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range b.Blobs { - if len(i) != 131072 { - err = ssz.ErrBytesLength - return + for _, o := range c.Consolidations { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Consolidations: %w", err) } - hh.PutBytes(i) } - - numItems := uint64(len(b.Blobs)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) - } - - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the BuilderDepositRequest object -func (b *BuilderDepositRequest) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} - -// MarshalSSZTo ssz marshals the BuilderDepositRequest object to a target array -func (b *BuilderDepositRequest) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - - // Field (0) 'Pubkey' - if size := len(b.Pubkey); size != 48 { - err = ssz.ErrBytesLengthFn("--.Pubkey", size, 48) - return + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Consolidations)), 2) } - dst = append(dst, b.Pubkey...) - - // Field (1) 'WithdrawalCredentials' - if size := len(b.WithdrawalCredentials); size != 32 { - err = ssz.ErrBytesLengthFn("--.WithdrawalCredentials", size, 32) - return + // Field 3: BuilderDeposits + { + if len(c.BuilderDeposits) > 256 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.BuilderDeposits { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("BuilderDeposits: %w", err) + } + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.BuilderDeposits)), 256) } - dst = append(dst, b.WithdrawalCredentials...) - - // Field (2) 'Amount' - dst = ssz.MarshalUint(dst, b.Amount) - - // Field (3) 'Signature' - if size := len(b.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 4: BuilderExits + { + if len(c.BuilderExits) > 16 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.BuilderExits { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("BuilderExits: %w", err) + } + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.BuilderExits)), 16) } - dst = append(dst, b.Signature...) - - return + hh.Merkleize(indx) + return nil } -// UnmarshalSSZ ssz unmarshals the BuilderDepositRequest object -func (b *BuilderDepositRequest) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size != 184 { - return ssz.ErrSize - } - - // Field (0) 'Pubkey' - if cap(b.Pubkey) == 0 { - b.Pubkey = make([]byte, 0, len(buf[0:48])) - } - b.Pubkey = append(b.Pubkey, buf[0:48]...) - - // Field (1) 'WithdrawalCredentials' - if cap(b.WithdrawalCredentials) == 0 { - b.WithdrawalCredentials = make([]byte, 0, len(buf[48:80])) - } - b.WithdrawalCredentials = append(b.WithdrawalCredentials, buf[48:80]...) - - // Field (2) 'Amount' - b.Amount = ssz.UnmarshallUint[uint64](buf[80:88]) - - // Field (3) 'Signature' - if cap(b.Signature) == 0 { - b.Signature = make([]byte, 0, len(buf[88:184])) - } - b.Signature = append(b.Signature, buf[88:184]...) - - return err -} +func (c *Withdrawal) SizeSSZ() int { + size := 44 -// SizeSSZ returns the ssz encoded size in bytes for the BuilderDepositRequest object -func (b *BuilderDepositRequest) SizeSSZ() (size int) { - size = 184 - return + return size } -// HashTreeRoot ssz hashes the BuilderDepositRequest object -func (b *BuilderDepositRequest) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) +func (c *Withdrawal) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// HashTreeRootWith ssz hashes the BuilderDepositRequest object with a hasher -func (b *BuilderDepositRequest) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'Pubkey' - if size := len(b.Pubkey); size != 48 { - err = ssz.ErrBytesLengthFn("--.Pubkey", size, 48) - return - } - hh.PutBytes(b.Pubkey) - - // Field (1) 'WithdrawalCredentials' - if size := len(b.WithdrawalCredentials); size != 32 { - err = ssz.ErrBytesLengthFn("--.WithdrawalCredentials", size, 32) - return - } - hh.PutBytes(b.WithdrawalCredentials) +func (c *Withdrawal) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (2) 'Amount' - ssz.PutUint(hh, b.Amount) + // Field 0: Index + dst = binary.LittleEndian.AppendUint64(dst, c.Index) - // Field (3) 'Signature' - if size := len(b.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 1: ValidatorIndex + if dst, err = c.ValidatorIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ValidatorIndex: %w", err) } - hh.PutBytes(b.Signature) - - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the BuilderExitRequest object -func (b *BuilderExitRequest) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} - -// MarshalSSZTo ssz marshals the BuilderExitRequest object to a target array -func (b *BuilderExitRequest) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - // Field (0) 'SourceAddress' - if size := len(b.SourceAddress); size != 20 { - err = ssz.ErrBytesLengthFn("--.SourceAddress", size, 20) - return + // Field 2: Address + if len(c.Address) != 20 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.SourceAddress...) + dst = append(dst, c.Address...) - // Field (1) 'Pubkey' - if size := len(b.Pubkey); size != 48 { - err = ssz.ErrBytesLengthFn("--.Pubkey", size, 48) - return - } - dst = append(dst, b.Pubkey...) + // Field 3: Amount + dst = binary.LittleEndian.AppendUint64(dst, c.Amount) - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the BuilderExitRequest object -func (b *BuilderExitRequest) UnmarshalSSZ(buf []byte) error { +func (c *Withdrawal) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 68 { + if size != 44 { return ssz.ErrSize } - // Field (0) 'SourceAddress' - if cap(b.SourceAddress) == 0 { - b.SourceAddress = make([]byte, 0, len(buf[0:20])) - } - b.SourceAddress = append(b.SourceAddress, buf[0:20]...) + sszSlice0 := buf[0:8] // c.Index + sszSlice1 := buf[8:16] // c.ValidatorIndex + sszSlice2 := buf[16:36] // c.Address + sszSlice3 := buf[36:44] // c.Amount - // Field (1) 'Pubkey' - if cap(b.Pubkey) == 0 { - b.Pubkey = make([]byte, 0, len(buf[20:68])) + // Field 0: Index + c.Index = binary.LittleEndian.Uint64(sszSlice0) + + // Field 1: ValidatorIndex + if err = c.ValidatorIndex.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("ValidatorIndex: %w", err) } - b.Pubkey = append(b.Pubkey, buf[20:68]...) - return err -} + // Field 2: Address + c.Address = make([]byte, 0, 20) + c.Address = append(c.Address, sszSlice2...) -// SizeSSZ returns the ssz encoded size in bytes for the BuilderExitRequest object -func (b *BuilderExitRequest) SizeSSZ() (size int) { - size = 68 - return + // Field 3: Amount + c.Amount = binary.LittleEndian.Uint64(sszSlice3) + return err } -// HashTreeRoot ssz hashes the BuilderExitRequest object -func (b *BuilderExitRequest) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) +func (c *Withdrawal) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the BuilderExitRequest object with a hasher -func (b *BuilderExitRequest) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *Withdrawal) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'SourceAddress' - if size := len(b.SourceAddress); size != 20 { - err = ssz.ErrBytesLengthFn("--.SourceAddress", size, 20) - return - } - hh.PutBytes(b.SourceAddress) - - // Field (1) 'Pubkey' - if size := len(b.Pubkey); size != 48 { - err = ssz.ErrBytesLengthFn("--.Pubkey", size, 48) - return - } - hh.PutBytes(b.Pubkey) - + // Field 0: Index + hh.PutUint64(c.Index) + // Field 1: ValidatorIndex + if err := c.ValidatorIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ValidatorIndex: %w", err) + } + // Field 2: Address + if len(c.Address) != 20 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Address) + // Field 3: Amount + hh.PutUint64(c.Amount) hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the ExecutionRequestsGloas object -func (e *ExecutionRequestsGloas) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(e) + return nil } -// MarshalSSZTo ssz marshals the ExecutionRequestsGloas object to a target array -func (e *ExecutionRequestsGloas) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(20) +func (c *WithdrawalRequest) SizeSSZ() int { + size := 76 - // 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) - offset += len(e.Consolidations) * 116 - - // Offset (3) 'BuilderDeposits' - dst = ssz.WriteOffset(dst, offset) - offset += len(e.BuilderDeposits) * 184 - - // Offset (4) 'BuilderExits' - dst = ssz.WriteOffset(dst, offset) - offset += len(e.BuilderExits) * 68 + return size +} - // Field (0) 'Deposits' - if size := len(e.Deposits); size > 8192 { - err = ssz.ErrListTooBigFn("--.Deposits", size, 8192) - return - } - for ii := 0; ii < len(e.Deposits); ii++ { - if dst, err = e.Deposits[ii].MarshalSSZTo(dst); err != nil { - return - } - } +func (c *WithdrawalRequest) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (1) 'Withdrawals' - if size := len(e.Withdrawals); size > 16 { - err = ssz.ErrListTooBigFn("--.Withdrawals", size, 16) - return - } - for ii := 0; ii < len(e.Withdrawals); ii++ { - if dst, err = e.Withdrawals[ii].MarshalSSZTo(dst); err != nil { - return - } - } +func (c *WithdrawalRequest) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (2) 'Consolidations' - if size := len(e.Consolidations); size > 2 { - err = ssz.ErrListTooBigFn("--.Consolidations", size, 2) - return - } - for ii := 0; ii < len(e.Consolidations); ii++ { - if dst, err = e.Consolidations[ii].MarshalSSZTo(dst); err != nil { - return - } + // Field 0: SourceAddress + if len(c.SourceAddress) != 20 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.SourceAddress...) - // Field (3) 'BuilderDeposits' - if size := len(e.BuilderDeposits); size > 256 { - err = ssz.ErrListTooBigFn("--.BuilderDeposits", size, 256) - return - } - for ii := 0; ii < len(e.BuilderDeposits); ii++ { - if dst, err = e.BuilderDeposits[ii].MarshalSSZTo(dst); err != nil { - return - } + // Field 1: ValidatorPubkey + if len(c.ValidatorPubkey) != 48 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.ValidatorPubkey...) - // Field (4) 'BuilderExits' - if size := len(e.BuilderExits); size > 16 { - err = ssz.ErrListTooBigFn("--.BuilderExits", size, 16) - return - } - for ii := 0; ii < len(e.BuilderExits); ii++ { - if dst, err = e.BuilderExits[ii].MarshalSSZTo(dst); err != nil { - return - } - } + // Field 2: Amount + dst = binary.LittleEndian.AppendUint64(dst, c.Amount) - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the ExecutionRequestsGloas object -func (e *ExecutionRequestsGloas) UnmarshalSSZ(buf []byte) error { +func (c *WithdrawalRequest) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 20 { + if size != 76 { return ssz.ErrSize } - tail := buf - var o0, o1, o2, o3, o4 uint64 - - // Offset (0) 'Deposits' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } - - if o0 != 20 { - 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 - } - - // Offset (3) 'BuilderDeposits' - if o3 = ssz.ReadOffset(buf[12:16]); o3 > size || o2 > o3 { - return ssz.ErrOffset - } - - // Offset (4) 'BuilderExits' - if o4 = ssz.ReadOffset(buf[16:20]); o4 > size || o3 > o4 { - 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 - } - } - } + sszSlice0 := buf[0:20] // c.SourceAddress + sszSlice1 := buf[20:68] // c.ValidatorPubkey + sszSlice2 := buf[68:76] // c.Amount - // Field (2) 'Consolidations' - { - buf = tail[o2:o3] - 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 - } - } - } + // Field 0: SourceAddress + c.SourceAddress = make([]byte, 0, 20) + c.SourceAddress = append(c.SourceAddress, sszSlice0...) - // Field (3) 'BuilderDeposits' - { - buf = tail[o3:o4] - num, err := ssz.DivideInt2(len(buf), 184, 256) - if err != nil { - return err - } - e.BuilderDeposits = make([]*BuilderDepositRequest, num) - for ii := 0; ii < num; ii++ { - if e.BuilderDeposits[ii] == nil { - e.BuilderDeposits[ii] = new(BuilderDepositRequest) - } - if err = e.BuilderDeposits[ii].UnmarshalSSZ(buf[ii*184 : (ii+1)*184]); err != nil { - return err - } - } - } + // Field 1: ValidatorPubkey + c.ValidatorPubkey = make([]byte, 0, 48) + c.ValidatorPubkey = append(c.ValidatorPubkey, sszSlice1...) - // Field (4) 'BuilderExits' - { - buf = tail[o4:] - num, err := ssz.DivideInt2(len(buf), 68, 16) - if err != nil { - return err - } - e.BuilderExits = make([]*BuilderExitRequest, num) - for ii := 0; ii < num; ii++ { - if e.BuilderExits[ii] == nil { - e.BuilderExits[ii] = new(BuilderExitRequest) - } - if err = e.BuilderExits[ii].UnmarshalSSZ(buf[ii*68 : (ii+1)*68]); err != nil { - return err - } - } - } + // Field 2: Amount + c.Amount = binary.LittleEndian.Uint64(sszSlice2) return err } -// SizeSSZ returns the ssz encoded size in bytes for the ExecutionRequestsGloas object -func (e *ExecutionRequestsGloas) SizeSSZ() (size int) { - size = 20 - - // Field (0) 'Deposits' - size += len(e.Deposits) * 192 - - // Field (1) 'Withdrawals' - size += len(e.Withdrawals) * 76 - - // Field (2) 'Consolidations' - size += len(e.Consolidations) * 116 - - // Field (3) 'BuilderDeposits' - size += len(e.BuilderDeposits) * 184 - - // Field (4) 'BuilderExits' - size += len(e.BuilderExits) * 68 - - return -} - -// HashTreeRoot ssz hashes the ExecutionRequestsGloas object -func (e *ExecutionRequestsGloas) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(e) +func (c *WithdrawalRequest) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the ExecutionRequestsGloas object with a hasher -func (e *ExecutionRequestsGloas) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *WithdrawalRequest) HashTreeRootWith(hh *ssz.Hasher) (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) - } - - // Field (3) 'BuilderDeposits' - { - subIndx := hh.Index() - num := uint64(len(e.BuilderDeposits)) - if num > 256 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range e.BuilderDeposits { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } - } - hh.MerkleizeWithMixin(subIndx, num, 256) + // Field 0: SourceAddress + if len(c.SourceAddress) != 20 { + return ssz.ErrBytesLength } - - // Field (4) 'BuilderExits' - { - subIndx := hh.Index() - num := uint64(len(e.BuilderExits)) - if num > 16 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range e.BuilderExits { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } - } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.PutBytes(c.SourceAddress) + // Field 1: ValidatorPubkey + if len(c.ValidatorPubkey) != 48 { + return ssz.ErrBytesLength } - + hh.PutBytes(c.ValidatorPubkey) + // Field 2: Amount + hh.PutUint64(c.Amount) hh.Merkleize(indx) - return + return nil } diff --git a/proto/engine/v1/engine.ssz.go b/proto/engine/v1/engine.ssz.go index a8f4f8634622..e4d601fda6a8 100644 --- a/proto/engine/v1/engine.ssz.go +++ b/proto/engine/v1/engine.ssz.go @@ -1,258 +1,647 @@ //go:build !minimal -// Code generated by fastssz. DO NOT EDIT. package enginev1 import ( - github_com_OffchainLabs_prysm_v7_consensus_types_primitives "github.com/OffchainLabs/prysm/v7/consensus-types/primitives" - ssz "github.com/prysmaticlabs/fastssz" + binary "encoding/binary" + "fmt" + ssz "github.com/OffchainLabs/methodical-ssz/ssz" ) -// MarshalSSZ ssz marshals the WithdrawalRequest object -func (w *WithdrawalRequest) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(w) +func (c *BlobsBundle) SizeSSZ() int { + size := 12 + size += len(c.KzgCommitments) * 48 + size += len(c.Proofs) * 48 + size += len(c.Blobs) * 131072 + return size } -// MarshalSSZTo ssz marshals the WithdrawalRequest object to a target array -func (w *WithdrawalRequest) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *BlobsBundle) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (0) 'SourceAddress' - if size := len(w.SourceAddress); size != 20 { - err = ssz.ErrBytesLengthFn("--.SourceAddress", size, 20) - return - } - dst = append(dst, w.SourceAddress...) +func (c *BlobsBundle) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 12 - // Field (1) 'ValidatorPubkey' - if size := len(w.ValidatorPubkey); size != 48 { - err = ssz.ErrBytesLengthFn("--.ValidatorPubkey", size, 48) - return + // Field 0: KzgCommitments + dst = ssz.WriteOffset(dst, offset) + offset += len(c.KzgCommitments) * 48 + + // Field 1: Proofs + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Proofs) * 48 + + // Field 2: Blobs + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Blobs) * 131072 + + // Field 0: KzgCommitments + if len(c.KzgCommitments) > 4096 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.KzgCommitments { + if len(o) != 48 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) } - dst = append(dst, w.ValidatorPubkey...) - // Field (2) 'Amount' - dst = ssz.MarshalUint(dst, w.Amount) + // Field 1: Proofs + if len(c.Proofs) > 4096 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.Proofs { + if len(o) != 48 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) + } - return + // Field 2: Blobs + if len(c.Blobs) > 4096 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.Blobs { + if len(o) != 131072 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the WithdrawalRequest object -func (w *WithdrawalRequest) UnmarshalSSZ(buf []byte) error { +func (c *BlobsBundle) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 76 { + if size < 12 { return ssz.ErrSize } - // Field (0) 'SourceAddress' - if cap(w.SourceAddress) == 0 { - w.SourceAddress = make([]byte, 0, len(buf[0:20])) + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.KzgCommitments + if sszVarOffset0 != 12 { + return ssz.ErrInvalidVariableOffset } - w.SourceAddress = append(w.SourceAddress, buf[0:20]...) + if sszVarOffset0 > size { + return ssz.ErrOffset + } + sszVarOffset1 := ssz.ReadOffset(buf[4:8]) // c.Proofs + if sszVarOffset1 > size || sszVarOffset1 < sszVarOffset0 { + return ssz.ErrOffset + } + sszVarOffset2 := ssz.ReadOffset(buf[8:12]) // c.Blobs + if sszVarOffset2 > size || sszVarOffset2 < sszVarOffset1 { + return ssz.ErrOffset + } + sszSlice0 := buf[sszVarOffset0:sszVarOffset1] // c.KzgCommitments + sszSlice1 := buf[sszVarOffset1:sszVarOffset2] // c.Proofs + sszSlice2 := buf[sszVarOffset2:] // c.Blobs + + // Field 0: KzgCommitments + { + if len(sszSlice0)%48 != 0 { + return fmt.Errorf("misaligned bytes: c.KzgCommitments length is %d, which is not a multiple of 48: %w", len(sszSlice0), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice0) / 48 + if numElem > 4096 { + return fmt.Errorf("ssz-max exceeded: c.KzgCommitments has %d elements, ssz-max is 4096: %w", numElem, ssz.ErrListTooBig) + } + c.KzgCommitments = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte + + tmpSlice := sszSlice0[i*48 : (1+i)*48] + tmp = make([]byte, 0, 48) + tmp = append(tmp, tmpSlice...) + c.KzgCommitments[i] = tmp + } + } + + // Field 1: Proofs + { + if len(sszSlice1)%48 != 0 { + return fmt.Errorf("misaligned bytes: c.Proofs length is %d, which is not a multiple of 48: %w", len(sszSlice1), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice1) / 48 + if numElem > 4096 { + return fmt.Errorf("ssz-max exceeded: c.Proofs has %d elements, ssz-max is 4096: %w", numElem, ssz.ErrListTooBig) + } + c.Proofs = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte - // Field (1) 'ValidatorPubkey' - if cap(w.ValidatorPubkey) == 0 { - w.ValidatorPubkey = make([]byte, 0, len(buf[20:68])) + tmpSlice := sszSlice1[i*48 : (1+i)*48] + tmp = make([]byte, 0, 48) + tmp = append(tmp, tmpSlice...) + c.Proofs[i] = tmp + } } - w.ValidatorPubkey = append(w.ValidatorPubkey, buf[20:68]...) - // Field (2) 'Amount' - w.Amount = ssz.UnmarshallUint[uint64](buf[68:76]) + // Field 2: Blobs + { + if len(sszSlice2)%131072 != 0 { + return fmt.Errorf("misaligned bytes: c.Blobs length is %d, which is not a multiple of 131072: %w", len(sszSlice2), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice2) / 131072 + if numElem > 4096 { + return fmt.Errorf("ssz-max exceeded: c.Blobs has %d elements, ssz-max is 4096: %w", numElem, ssz.ErrListTooBig) + } + c.Blobs = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte + tmpSlice := sszSlice2[i*131072 : (1+i)*131072] + tmp = make([]byte, 0, 131072) + tmp = append(tmp, tmpSlice...) + c.Blobs[i] = tmp + } + } return err } -// SizeSSZ returns the ssz encoded size in bytes for the WithdrawalRequest object -func (w *WithdrawalRequest) SizeSSZ() (size int) { - size = 76 - return +func (c *BlobsBundle) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRoot ssz hashes the WithdrawalRequest object -func (w *WithdrawalRequest) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(w) +func (c *BlobsBundle) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: KzgCommitments + { + if len(c.KzgCommitments) > 4096 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.KzgCommitments { + if len(o) != 48 { + return ssz.ErrBytesLength + } + hh.PutBytes(o) + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.KzgCommitments)), 4096) + } + // Field 1: Proofs + { + if len(c.Proofs) > 4096 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.Proofs { + if len(o) != 48 { + return ssz.ErrBytesLength + } + hh.PutBytes(o) + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Proofs)), 4096) + } + // Field 2: Blobs + { + if len(c.Blobs) > 4096 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.Blobs { + if len(o) != 131072 { + return ssz.ErrBytesLength + } + hh.PutBytes(o) + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Blobs)), 4096) + } + hh.Merkleize(indx) + return nil } -// HashTreeRootWith ssz hashes the WithdrawalRequest object with a hasher -func (w *WithdrawalRequest) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() +func (c *BlobsBundleV2) SizeSSZ() int { + size := 12 + size += len(c.KzgCommitments) * 48 + size += len(c.Proofs) * 48 + size += len(c.Blobs) * 131072 + return size +} - // Field (0) 'SourceAddress' - if size := len(w.SourceAddress); size != 20 { - err = ssz.ErrBytesLengthFn("--.SourceAddress", size, 20) - return - } - hh.PutBytes(w.SourceAddress) +func (c *BlobsBundleV2) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} + +func (c *BlobsBundleV2) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 12 + + // Field 0: KzgCommitments + dst = ssz.WriteOffset(dst, offset) + offset += len(c.KzgCommitments) * 48 + + // Field 1: Proofs + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Proofs) * 48 - // Field (1) 'ValidatorPubkey' - if size := len(w.ValidatorPubkey); size != 48 { - err = ssz.ErrBytesLengthFn("--.ValidatorPubkey", size, 48) - return + // Field 2: Blobs + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Blobs) * 131072 + + // Field 0: KzgCommitments + if len(c.KzgCommitments) > 4096 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.KzgCommitments { + if len(o) != 48 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) } - hh.PutBytes(w.ValidatorPubkey) - // Field (2) 'Amount' - ssz.PutUint(hh, w.Amount) + // Field 1: Proofs + if len(c.Proofs) > 33554432 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.Proofs { + if len(o) != 48 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) + } - hh.Merkleize(indx) - return + // Field 2: Blobs + if len(c.Blobs) > 4096 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.Blobs { + if len(o) != 131072 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) + } + return dst, err } -// MarshalSSZ ssz marshals the DepositRequest object -func (d *DepositRequest) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(d) -} +func (c *BlobsBundleV2) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 12 { + return ssz.ErrSize + } -// MarshalSSZTo ssz marshals the DepositRequest object to a target array -func (d *DepositRequest) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.KzgCommitments + if sszVarOffset0 != 12 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset0 > size { + return ssz.ErrOffset + } + sszVarOffset1 := ssz.ReadOffset(buf[4:8]) // c.Proofs + if sszVarOffset1 > size || sszVarOffset1 < sszVarOffset0 { + return ssz.ErrOffset + } + sszVarOffset2 := ssz.ReadOffset(buf[8:12]) // c.Blobs + if sszVarOffset2 > size || sszVarOffset2 < sszVarOffset1 { + return ssz.ErrOffset + } + sszSlice0 := buf[sszVarOffset0:sszVarOffset1] // c.KzgCommitments + sszSlice1 := buf[sszVarOffset1:sszVarOffset2] // c.Proofs + sszSlice2 := buf[sszVarOffset2:] // c.Blobs - // Field (0) 'Pubkey' - if size := len(d.Pubkey); size != 48 { - err = ssz.ErrBytesLengthFn("--.Pubkey", size, 48) - return + // Field 0: KzgCommitments + { + if len(sszSlice0)%48 != 0 { + return fmt.Errorf("misaligned bytes: c.KzgCommitments length is %d, which is not a multiple of 48: %w", len(sszSlice0), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice0) / 48 + if numElem > 4096 { + return fmt.Errorf("ssz-max exceeded: c.KzgCommitments has %d elements, ssz-max is 4096: %w", numElem, ssz.ErrListTooBig) + } + c.KzgCommitments = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte + + tmpSlice := sszSlice0[i*48 : (1+i)*48] + tmp = make([]byte, 0, 48) + tmp = append(tmp, tmpSlice...) + c.KzgCommitments[i] = tmp + } + } + + // Field 1: Proofs + { + if len(sszSlice1)%48 != 0 { + return fmt.Errorf("misaligned bytes: c.Proofs length is %d, which is not a multiple of 48: %w", len(sszSlice1), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice1) / 48 + if numElem > 33554432 { + return fmt.Errorf("ssz-max exceeded: c.Proofs has %d elements, ssz-max is 33554432: %w", numElem, ssz.ErrListTooBig) + } + c.Proofs = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte + + tmpSlice := sszSlice1[i*48 : (1+i)*48] + tmp = make([]byte, 0, 48) + tmp = append(tmp, tmpSlice...) + c.Proofs[i] = tmp + } } - dst = append(dst, d.Pubkey...) - // Field (1) 'WithdrawalCredentials' - if size := len(d.WithdrawalCredentials); size != 32 { - err = ssz.ErrBytesLengthFn("--.WithdrawalCredentials", size, 32) - return + // Field 2: Blobs + { + if len(sszSlice2)%131072 != 0 { + return fmt.Errorf("misaligned bytes: c.Blobs length is %d, which is not a multiple of 131072: %w", len(sszSlice2), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice2) / 131072 + if numElem > 4096 { + return fmt.Errorf("ssz-max exceeded: c.Blobs has %d elements, ssz-max is 4096: %w", numElem, ssz.ErrListTooBig) + } + c.Blobs = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte + + tmpSlice := sszSlice2[i*131072 : (1+i)*131072] + tmp = make([]byte, 0, 131072) + tmp = append(tmp, tmpSlice...) + c.Blobs[i] = tmp + } } - dst = append(dst, d.WithdrawalCredentials...) + return err +} - // Field (2) 'Amount' - dst = ssz.MarshalUint(dst, d.Amount) +func (c *BlobsBundleV2) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (3) 'Signature' - if size := len(d.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return +func (c *BlobsBundleV2) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: KzgCommitments + { + if len(c.KzgCommitments) > 4096 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.KzgCommitments { + if len(o) != 48 { + return ssz.ErrBytesLength + } + hh.PutBytes(o) + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.KzgCommitments)), 4096) + } + // Field 1: Proofs + { + if len(c.Proofs) > 33554432 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.Proofs { + if len(o) != 48 { + return ssz.ErrBytesLength + } + hh.PutBytes(o) + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Proofs)), 33554432) + } + // Field 2: Blobs + { + if len(c.Blobs) > 4096 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.Blobs { + if len(o) != 131072 { + return ssz.ErrBytesLength + } + hh.PutBytes(o) + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Blobs)), 4096) } - dst = append(dst, d.Signature...) + hh.Merkleize(indx) + return nil +} - // Field (4) 'Index' - dst = ssz.MarshalUint(dst, d.Index) +func (c *BuilderDepositRequest) SizeSSZ() int { + size := 184 - return + return size } -// UnmarshalSSZ ssz unmarshals the DepositRequest object -func (d *DepositRequest) UnmarshalSSZ(buf []byte) error { +func (c *BuilderDepositRequest) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} + +func (c *BuilderDepositRequest) MarshalSSZTo(dst []byte) ([]byte, error) { var err error - size := uint64(len(buf)) - if size != 192 { - return ssz.ErrSize + + // Field 0: Pubkey + if len(c.Pubkey) != 48 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.Pubkey...) - // Field (0) 'Pubkey' - if cap(d.Pubkey) == 0 { - d.Pubkey = make([]byte, 0, len(buf[0:48])) + // Field 1: WithdrawalCredentials + if len(c.WithdrawalCredentials) != 32 { + return nil, ssz.ErrBytesLength } - d.Pubkey = append(d.Pubkey, buf[0:48]...) + dst = append(dst, c.WithdrawalCredentials...) - // Field (1) 'WithdrawalCredentials' - if cap(d.WithdrawalCredentials) == 0 { - d.WithdrawalCredentials = make([]byte, 0, len(buf[48:80])) + // Field 2: Amount + dst = binary.LittleEndian.AppendUint64(dst, c.Amount) + + // Field 3: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } - d.WithdrawalCredentials = append(d.WithdrawalCredentials, buf[48:80]...) + dst = append(dst, c.Signature...) - // Field (2) 'Amount' - d.Amount = ssz.UnmarshallUint[uint64](buf[80:88]) + return dst, err +} - // Field (3) 'Signature' - if cap(d.Signature) == 0 { - d.Signature = make([]byte, 0, len(buf[88:184])) +func (c *BuilderDepositRequest) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 184 { + return ssz.ErrSize } - d.Signature = append(d.Signature, buf[88:184]...) - // Field (4) 'Index' - d.Index = ssz.UnmarshallUint[uint64](buf[184:192]) + sszSlice0 := buf[0:48] // c.Pubkey + sszSlice1 := buf[48:80] // c.WithdrawalCredentials + sszSlice2 := buf[80:88] // c.Amount + sszSlice3 := buf[88:184] // c.Signature + + // Field 0: Pubkey + c.Pubkey = make([]byte, 0, 48) + c.Pubkey = append(c.Pubkey, sszSlice0...) + // Field 1: WithdrawalCredentials + c.WithdrawalCredentials = make([]byte, 0, 32) + c.WithdrawalCredentials = append(c.WithdrawalCredentials, sszSlice1...) + + // Field 2: Amount + c.Amount = binary.LittleEndian.Uint64(sszSlice2) + + // Field 3: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice3...) return err } -// SizeSSZ returns the ssz encoded size in bytes for the DepositRequest object -func (d *DepositRequest) SizeSSZ() (size int) { - size = 192 - return +func (c *BuilderDepositRequest) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} + +func (c *BuilderDepositRequest) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Pubkey + if len(c.Pubkey) != 48 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Pubkey) + // Field 1: WithdrawalCredentials + if len(c.WithdrawalCredentials) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.WithdrawalCredentials) + // Field 2: Amount + hh.PutUint64(c.Amount) + // Field 3: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Signature) + hh.Merkleize(indx) + return nil } -// HashTreeRoot ssz hashes the DepositRequest object -func (d *DepositRequest) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(d) +func (c *BuilderExitRequest) SizeSSZ() int { + size := 68 + + return size } -// HashTreeRootWith ssz hashes the DepositRequest object with a hasher -func (d *DepositRequest) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() +func (c *BuilderExitRequest) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (0) 'Pubkey' - if size := len(d.Pubkey); size != 48 { - err = ssz.ErrBytesLengthFn("--.Pubkey", size, 48) - return +func (c *BuilderExitRequest) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + + // Field 0: SourceAddress + if len(c.SourceAddress) != 20 { + return nil, ssz.ErrBytesLength } - hh.PutBytes(d.Pubkey) + dst = append(dst, c.SourceAddress...) - // Field (1) 'WithdrawalCredentials' - if size := len(d.WithdrawalCredentials); size != 32 { - err = ssz.ErrBytesLengthFn("--.WithdrawalCredentials", size, 32) - return + // Field 1: Pubkey + if len(c.Pubkey) != 48 { + return nil, ssz.ErrBytesLength } - hh.PutBytes(d.WithdrawalCredentials) + dst = append(dst, c.Pubkey...) - // Field (2) 'Amount' - ssz.PutUint(hh, d.Amount) + return dst, err +} - // Field (3) 'Signature' - if size := len(d.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return +func (c *BuilderExitRequest) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 68 { + return ssz.ErrSize } - hh.PutBytes(d.Signature) - // Field (4) 'Index' - ssz.PutUint(hh, d.Index) + sszSlice0 := buf[0:20] // c.SourceAddress + sszSlice1 := buf[20:68] // c.Pubkey + + // Field 0: SourceAddress + c.SourceAddress = make([]byte, 0, 20) + c.SourceAddress = append(c.SourceAddress, sszSlice0...) + + // Field 1: Pubkey + c.Pubkey = make([]byte, 0, 48) + c.Pubkey = append(c.Pubkey, sszSlice1...) + return err +} + +func (c *BuilderExitRequest) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} +func (c *BuilderExitRequest) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: SourceAddress + if len(c.SourceAddress) != 20 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.SourceAddress) + // Field 1: Pubkey + if len(c.Pubkey) != 48 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Pubkey) hh.Merkleize(indx) - return + return nil +} + +func (c *ConsolidationRequest) SizeSSZ() int { + size := 116 + + return size } -// MarshalSSZ ssz marshals the ConsolidationRequest object func (c *ConsolidationRequest) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(c) + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the ConsolidationRequest object to a target array -func (c *ConsolidationRequest) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *ConsolidationRequest) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (0) 'SourceAddress' - if size := len(c.SourceAddress); size != 20 { - err = ssz.ErrBytesLengthFn("--.SourceAddress", size, 20) - return + // Field 0: SourceAddress + if len(c.SourceAddress) != 20 { + return nil, ssz.ErrBytesLength } dst = append(dst, c.SourceAddress...) - // Field (1) 'SourcePubkey' - if size := len(c.SourcePubkey); size != 48 { - err = ssz.ErrBytesLengthFn("--.SourcePubkey", size, 48) - return + // Field 1: SourcePubkey + if len(c.SourcePubkey) != 48 { + return nil, ssz.ErrBytesLength } dst = append(dst, c.SourcePubkey...) - // Field (2) 'TargetPubkey' - if size := len(c.TargetPubkey); size != 48 { - err = ssz.ErrBytesLengthFn("--.TargetPubkey", size, 48) - return + // Field 2: TargetPubkey + if len(c.TargetPubkey) != 48 { + return nil, ssz.ErrBytesLength } dst = append(dst, c.TargetPubkey...) - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the ConsolidationRequest object func (c *ConsolidationRequest) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) @@ -260,4353 +649,3528 @@ func (c *ConsolidationRequest) UnmarshalSSZ(buf []byte) error { 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]...) + sszSlice0 := buf[0:20] // c.SourceAddress + sszSlice1 := buf[20:68] // c.SourcePubkey + sszSlice2 := buf[68:116] // c.TargetPubkey - // 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 0: SourceAddress + c.SourceAddress = make([]byte, 0, 20) + c.SourceAddress = append(c.SourceAddress, sszSlice0...) - // 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]...) + // Field 1: SourcePubkey + c.SourcePubkey = make([]byte, 0, 48) + c.SourcePubkey = append(c.SourcePubkey, sszSlice1...) + // Field 2: TargetPubkey + c.TargetPubkey = make([]byte, 0, 48) + c.TargetPubkey = append(c.TargetPubkey, sszSlice2...) 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) + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the ConsolidationRequest object with a hasher func (c *ConsolidationRequest) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'SourceAddress' - if size := len(c.SourceAddress); size != 20 { - err = ssz.ErrBytesLengthFn("--.SourceAddress", size, 20) - return + // Field 0: SourceAddress + if len(c.SourceAddress) != 20 { + return ssz.ErrBytesLength } hh.PutBytes(c.SourceAddress) - - // Field (1) 'SourcePubkey' - if size := len(c.SourcePubkey); size != 48 { - err = ssz.ErrBytesLengthFn("--.SourcePubkey", size, 48) - return + // Field 1: SourcePubkey + if len(c.SourcePubkey) != 48 { + return ssz.ErrBytesLength } hh.PutBytes(c.SourcePubkey) - - // Field (2) 'TargetPubkey' - if size := len(c.TargetPubkey); size != 48 { - err = ssz.ErrBytesLengthFn("--.TargetPubkey", size, 48) - return + // Field 2: TargetPubkey + if len(c.TargetPubkey) != 48 { + return ssz.ErrBytesLength } hh.PutBytes(c.TargetPubkey) - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the ExecutionRequests object -func (e *ExecutionRequests) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(e) + return nil } -// 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) +func (c *DepositRequest) SizeSSZ() int { + size := 192 - // Offset (0) 'Deposits' - dst = ssz.WriteOffset(dst, offset) - offset += len(e.Deposits) * 192 + return size +} - // Offset (1) 'Withdrawals' - dst = ssz.WriteOffset(dst, offset) - offset += len(e.Withdrawals) * 76 +func (c *DepositRequest) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Offset (2) 'Consolidations' - dst = ssz.WriteOffset(dst, offset) - offset += len(e.Consolidations) * 116 +func (c *DepositRequest) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (0) 'Deposits' - if size := len(e.Deposits); size > 8192 { - err = ssz.ErrListTooBigFn("--.Deposits", size, 8192) - return - } - for ii := 0; ii < len(e.Deposits); ii++ { - if dst, err = e.Deposits[ii].MarshalSSZTo(dst); err != nil { - return - } + // Field 0: Pubkey + if len(c.Pubkey) != 48 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.Pubkey...) - // Field (1) 'Withdrawals' - if size := len(e.Withdrawals); size > 16 { - err = ssz.ErrListTooBigFn("--.Withdrawals", size, 16) - return - } - for ii := 0; ii < len(e.Withdrawals); ii++ { - if dst, err = e.Withdrawals[ii].MarshalSSZTo(dst); err != nil { - return - } + // Field 1: WithdrawalCredentials + if len(c.WithdrawalCredentials) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.WithdrawalCredentials...) - // Field (2) 'Consolidations' - if size := len(e.Consolidations); size > 2 { - err = ssz.ErrListTooBigFn("--.Consolidations", size, 2) - return - } - for ii := 0; ii < len(e.Consolidations); ii++ { - if dst, err = e.Consolidations[ii].MarshalSSZTo(dst); err != nil { - return - } + // Field 2: Amount + dst = binary.LittleEndian.AppendUint64(dst, c.Amount) + + // Field 3: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.Signature...) - return + // Field 4: Index + dst = binary.LittleEndian.AppendUint64(dst, c.Index) + + return dst, err } -// UnmarshalSSZ ssz unmarshals the ExecutionRequests object -func (e *ExecutionRequests) UnmarshalSSZ(buf []byte) error { +func (c *DepositRequest) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 12 { + if size != 192 { return ssz.ErrSize } - tail := buf - var o0, o1, o2 uint64 + sszSlice0 := buf[0:48] // c.Pubkey + sszSlice1 := buf[48:80] // c.WithdrawalCredentials + sszSlice2 := buf[80:88] // c.Amount + sszSlice3 := buf[88:184] // c.Signature + sszSlice4 := buf[184:192] // c.Index - // Offset (0) 'Deposits' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } + // Field 0: Pubkey + c.Pubkey = make([]byte, 0, 48) + c.Pubkey = append(c.Pubkey, sszSlice0...) - if o0 != 12 { - return ssz.ErrInvalidVariableOffset - } + // Field 1: WithdrawalCredentials + c.WithdrawalCredentials = make([]byte, 0, 32) + c.WithdrawalCredentials = append(c.WithdrawalCredentials, sszSlice1...) - // Offset (1) 'Withdrawals' - if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 { - return ssz.ErrOffset - } + // Field 2: Amount + c.Amount = binary.LittleEndian.Uint64(sszSlice2) - // 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 3: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice3...) - // 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 - } - } - } + // Field 4: Index + c.Index = binary.LittleEndian.Uint64(sszSlice4) 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) +func (c *DepositRequest) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the ExecutionRequests object with a hasher -func (e *ExecutionRequests) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *DepositRequest) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() + // Field 0: Pubkey + if len(c.Pubkey) != 48 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Pubkey) + // Field 1: WithdrawalCredentials + if len(c.WithdrawalCredentials) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.WithdrawalCredentials) + // Field 2: Amount + hh.PutUint64(c.Amount) + // Field 3: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Signature) + // Field 4: Index + hh.PutUint64(c.Index) + hh.Merkleize(indx) + return nil +} - // 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) +func (c *ExecutionPayload) SizeSSZ() int { + size := 508 + size += len(c.ExtraData) + for _, o := range c.Transactions { + size += 4 + size += len(o) } - - hh.Merkleize(indx) - return + return size } -// MarshalSSZ ssz marshals the ExecutionPayload object -func (e *ExecutionPayload) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(e) +func (c *ExecutionPayload) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the ExecutionPayload object to a target array -func (e *ExecutionPayload) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(508) +func (c *ExecutionPayload) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 508 - // Field (0) 'ParentHash' - if size := len(e.ParentHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentHash", size, 32) - return + // Field 0: ParentHash + if len(c.ParentHash) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.ParentHash...) + dst = append(dst, c.ParentHash...) - // Field (1) 'FeeRecipient' - if size := len(e.FeeRecipient); size != 20 { - err = ssz.ErrBytesLengthFn("--.FeeRecipient", size, 20) - return + // Field 1: FeeRecipient + if len(c.FeeRecipient) != 20 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.FeeRecipient...) + dst = append(dst, c.FeeRecipient...) - // Field (2) 'StateRoot' - if size := len(e.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return + // Field 2: StateRoot + if len(c.StateRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.StateRoot...) + dst = append(dst, c.StateRoot...) - // Field (3) 'ReceiptsRoot' - if size := len(e.ReceiptsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ReceiptsRoot", size, 32) - return + // Field 3: ReceiptsRoot + if len(c.ReceiptsRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.ReceiptsRoot...) + dst = append(dst, c.ReceiptsRoot...) - // Field (4) 'LogsBloom' - if size := len(e.LogsBloom); size != 256 { - err = ssz.ErrBytesLengthFn("--.LogsBloom", size, 256) - return + // Field 4: LogsBloom + if len(c.LogsBloom) != 256 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.LogsBloom...) + dst = append(dst, c.LogsBloom...) - // Field (5) 'PrevRandao' - if size := len(e.PrevRandao); size != 32 { - err = ssz.ErrBytesLengthFn("--.PrevRandao", size, 32) - return + // Field 5: PrevRandao + if len(c.PrevRandao) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.PrevRandao...) + dst = append(dst, c.PrevRandao...) - // Field (6) 'BlockNumber' - dst = ssz.MarshalUint(dst, e.BlockNumber) + // Field 6: BlockNumber + dst = binary.LittleEndian.AppendUint64(dst, c.BlockNumber) - // Field (7) 'GasLimit' - dst = ssz.MarshalUint(dst, e.GasLimit) + // Field 7: GasLimit + dst = binary.LittleEndian.AppendUint64(dst, c.GasLimit) - // Field (8) 'GasUsed' - dst = ssz.MarshalUint(dst, e.GasUsed) + // Field 8: GasUsed + dst = binary.LittleEndian.AppendUint64(dst, c.GasUsed) - // Field (9) 'Timestamp' - dst = ssz.MarshalUint(dst, e.Timestamp) + // Field 9: Timestamp + dst = binary.LittleEndian.AppendUint64(dst, c.Timestamp) - // Offset (10) 'ExtraData' + // Field 10: ExtraData dst = ssz.WriteOffset(dst, offset) - offset += len(e.ExtraData) + offset += len(c.ExtraData) - // Field (11) 'BaseFeePerGas' - if size := len(e.BaseFeePerGas); size != 32 { - err = ssz.ErrBytesLengthFn("--.BaseFeePerGas", size, 32) - return + // Field 11: BaseFeePerGas + if len(c.BaseFeePerGas) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.BaseFeePerGas...) + dst = append(dst, c.BaseFeePerGas...) - // Field (12) 'BlockHash' - if size := len(e.BlockHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockHash", size, 32) - return + // Field 12: BlockHash + if len(c.BlockHash) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.BlockHash...) + dst = append(dst, c.BlockHash...) - // Offset (13) 'Transactions' + // Field 13: Transactions dst = ssz.WriteOffset(dst, offset) - for ii := 0; ii < len(e.Transactions); ii++ { + for _, o := range c.Transactions { offset += 4 - offset += len(e.Transactions[ii]) + offset += len(o) } - // Field (10) 'ExtraData' - if size := len(e.ExtraData); size > 32 { - err = ssz.ErrBytesLengthFn("--.ExtraData", size, 32) - return + // Field 10: ExtraData + if len(c.ExtraData) > 32 { + return nil, ssz.ErrListTooBig } - dst = append(dst, e.ExtraData...) + dst = append(dst, c.ExtraData...) - // Field (13) 'Transactions' - if size := len(e.Transactions); size > 1048576 { - err = ssz.ErrListTooBigFn("--.Transactions", size, 1048576) - return + // Field 13: Transactions + if len(c.Transactions) > 1048576 { + return nil, ssz.ErrListTooBig } { - offset = 4 * len(e.Transactions) - for ii := 0; ii < len(e.Transactions); ii++ { + offset = 4 * len(c.Transactions) + for _, o := range c.Transactions { dst = ssz.WriteOffset(dst, offset) - offset += len(e.Transactions[ii]) + offset += len(o) } } - for ii := 0; ii < len(e.Transactions); ii++ { - if size := len(e.Transactions[ii]); size > 1073741824 { - err = ssz.ErrBytesLengthFn("--.Transactions[ii]", size, 1073741824) - return + for _, o := range c.Transactions { + if len(o) > 1073741824 { + return nil, ssz.ErrListTooBig } - dst = append(dst, e.Transactions[ii]...) + dst = append(dst, o...) } - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the ExecutionPayload object -func (e *ExecutionPayload) UnmarshalSSZ(buf []byte) error { +func (c *ExecutionPayload) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size < 508 { return ssz.ErrSize } - tail := buf - var o10, o13 uint64 - - // Field (0) 'ParentHash' - if cap(e.ParentHash) == 0 { - e.ParentHash = make([]byte, 0, len(buf[0:32])) + sszSlice0 := buf[0:32] // c.ParentHash + sszSlice1 := buf[32:52] // c.FeeRecipient + sszSlice2 := buf[52:84] // c.StateRoot + sszSlice3 := buf[84:116] // c.ReceiptsRoot + sszSlice4 := buf[116:372] // c.LogsBloom + sszSlice5 := buf[372:404] // c.PrevRandao + sszSlice6 := buf[404:412] // c.BlockNumber + sszSlice7 := buf[412:420] // c.GasLimit + sszSlice8 := buf[420:428] // c.GasUsed + sszSlice9 := buf[428:436] // c.Timestamp + sszSlice11 := buf[440:472] // c.BaseFeePerGas + sszSlice12 := buf[472:504] // c.BlockHash + + sszVarOffset10 := ssz.ReadOffset(buf[436:440]) // c.ExtraData + if sszVarOffset10 != 508 { + return ssz.ErrInvalidVariableOffset } - e.ParentHash = append(e.ParentHash, buf[0:32]...) - - // Field (1) 'FeeRecipient' - if cap(e.FeeRecipient) == 0 { - e.FeeRecipient = make([]byte, 0, len(buf[32:52])) + if sszVarOffset10 > size { + return ssz.ErrOffset } - e.FeeRecipient = append(e.FeeRecipient, buf[32:52]...) - - // Field (2) 'StateRoot' - if cap(e.StateRoot) == 0 { - e.StateRoot = make([]byte, 0, len(buf[52:84])) + sszVarOffset13 := ssz.ReadOffset(buf[504:508]) // c.Transactions + if sszVarOffset13 > size || sszVarOffset13 < sszVarOffset10 { + return ssz.ErrOffset } - e.StateRoot = append(e.StateRoot, buf[52:84]...) + sszSlice10 := buf[sszVarOffset10:sszVarOffset13] // c.ExtraData + sszSlice13 := buf[sszVarOffset13:] // c.Transactions - // Field (3) 'ReceiptsRoot' - if cap(e.ReceiptsRoot) == 0 { - e.ReceiptsRoot = make([]byte, 0, len(buf[84:116])) - } - e.ReceiptsRoot = append(e.ReceiptsRoot, buf[84:116]...) + // Field 0: ParentHash + c.ParentHash = make([]byte, 0, 32) + c.ParentHash = append(c.ParentHash, sszSlice0...) - // Field (4) 'LogsBloom' - if cap(e.LogsBloom) == 0 { - e.LogsBloom = make([]byte, 0, len(buf[116:372])) - } - e.LogsBloom = append(e.LogsBloom, buf[116:372]...) + // Field 1: FeeRecipient + c.FeeRecipient = make([]byte, 0, 20) + c.FeeRecipient = append(c.FeeRecipient, sszSlice1...) - // Field (5) 'PrevRandao' - if cap(e.PrevRandao) == 0 { - e.PrevRandao = make([]byte, 0, len(buf[372:404])) - } - e.PrevRandao = append(e.PrevRandao, buf[372:404]...) + // Field 2: StateRoot + c.StateRoot = make([]byte, 0, 32) + c.StateRoot = append(c.StateRoot, sszSlice2...) - // Field (6) 'BlockNumber' - e.BlockNumber = ssz.UnmarshallUint[uint64](buf[404:412]) + // Field 3: ReceiptsRoot + c.ReceiptsRoot = make([]byte, 0, 32) + c.ReceiptsRoot = append(c.ReceiptsRoot, sszSlice3...) - // Field (7) 'GasLimit' - e.GasLimit = ssz.UnmarshallUint[uint64](buf[412:420]) + // Field 4: LogsBloom + c.LogsBloom = make([]byte, 0, 256) + c.LogsBloom = append(c.LogsBloom, sszSlice4...) - // Field (8) 'GasUsed' - e.GasUsed = ssz.UnmarshallUint[uint64](buf[420:428]) + // Field 5: PrevRandao + c.PrevRandao = make([]byte, 0, 32) + c.PrevRandao = append(c.PrevRandao, sszSlice5...) - // Field (9) 'Timestamp' - e.Timestamp = ssz.UnmarshallUint[uint64](buf[428:436]) + // Field 6: BlockNumber + c.BlockNumber = binary.LittleEndian.Uint64(sszSlice6) - // Offset (10) 'ExtraData' - if o10 = ssz.ReadOffset(buf[436:440]); o10 > size { - return ssz.ErrOffset - } + // Field 7: GasLimit + c.GasLimit = binary.LittleEndian.Uint64(sszSlice7) - if o10 != 508 { - return ssz.ErrInvalidVariableOffset - } + // Field 8: GasUsed + c.GasUsed = binary.LittleEndian.Uint64(sszSlice8) - // Field (11) 'BaseFeePerGas' - if cap(e.BaseFeePerGas) == 0 { - e.BaseFeePerGas = make([]byte, 0, len(buf[440:472])) - } - e.BaseFeePerGas = append(e.BaseFeePerGas, buf[440:472]...) + // Field 9: Timestamp + c.Timestamp = binary.LittleEndian.Uint64(sszSlice9) - // Field (12) 'BlockHash' - if cap(e.BlockHash) == 0 { - e.BlockHash = make([]byte, 0, len(buf[472:504])) - } - e.BlockHash = append(e.BlockHash, buf[472:504]...) + // Field 10: ExtraData + c.ExtraData = append([]byte{}, sszSlice10...) - // Offset (13) 'Transactions' - if o13 = ssz.ReadOffset(buf[504:508]); o13 > size || o10 > o13 { - return ssz.ErrOffset - } + // Field 11: BaseFeePerGas + c.BaseFeePerGas = make([]byte, 0, 32) + c.BaseFeePerGas = append(c.BaseFeePerGas, sszSlice11...) - // 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 12: BlockHash + c.BlockHash = make([]byte, 0, 32) + c.BlockHash = append(c.BlockHash, sszSlice12...) - // Field (13) 'Transactions' + // Field 13: Transactions { - buf = tail[o13:] - 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 + // empty lists are zero length, so make sure there is room for an offset + // before attempting to unmarshal it + if len(sszSlice13) > 3 { + startOffset := ssz.ReadOffset(sszSlice13[0:4]) + if startOffset == 0 { + return fmt.Errorf("encountered invalid offset of 0 when decoding c.Transactions") + } + if startOffset%4 != 0 { + return fmt.Errorf("misaligned list bytes: when decoding c.Transactions, end-of-list offset is %d, which is not a multiple of 4 (offset size)", startOffset) } - if cap(e.Transactions[indx]) == 0 { - e.Transactions[indx] = make([]byte, 0, len(buf)) + listLen := startOffset / 4 + if listLen > 1048576 { + return fmt.Errorf("ssz-max exceeded: c.Transactions has %d elements, ssz-max is 1048576: %w", listLen, ssz.ErrListTooBig) } - e.Transactions[indx] = append(e.Transactions[indx], buf...) - return nil - }) - if err != nil { - return err + totalVarBytes := uint64(len(sszSlice13)) + if totalVarBytes < startOffset { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.Transactions") + } + c.Transactions = make([][]byte, listLen) + var tmpSlice []byte + for i := uint64(0); i < listLen; i++ { + var tmp []byte + + endOffset := totalVarBytes + if i+1 != listLen { + endOffset = ssz.ReadOffset(sszSlice13[(i+1)*4 : (i+2)*4]) + if totalVarBytes < endOffset { + return fmt.Errorf("offset %d points past the end of buffer when decoding c.Transactions", endOffset) + } + } + if endOffset < startOffset { + return fmt.Errorf("offset %d is not greater than start offset %d when decoding c.Transactions", endOffset, startOffset) + } + tmpSlice = sszSlice13[startOffset:endOffset] + tmp = append([]byte{}, tmpSlice...) + c.Transactions[i] = tmp + startOffset = endOffset + } + } else { + if len(sszSlice13) > 0 { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.Transactions") + } + c.Transactions = make([][]byte, 0) } } return err } -// SizeSSZ returns the ssz encoded size in bytes for the ExecutionPayload object -func (e *ExecutionPayload) SizeSSZ() (size int) { - size = 508 - - // 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]) +func (c *ExecutionPayload) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - - return + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// 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.Hasher) (err error) { +func (c *ExecutionPayload) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() + // Field 0: ParentHash + if len(c.ParentHash) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ParentHash) + // Field 1: FeeRecipient + if len(c.FeeRecipient) != 20 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.FeeRecipient) + // Field 2: StateRoot + if len(c.StateRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.StateRoot) + // Field 3: ReceiptsRoot + if len(c.ReceiptsRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ReceiptsRoot) + // Field 4: LogsBloom + if len(c.LogsBloom) != 256 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.LogsBloom) + // Field 5: PrevRandao + if len(c.PrevRandao) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.PrevRandao) + // Field 6: BlockNumber + hh.PutUint64(c.BlockNumber) + // Field 7: GasLimit + hh.PutUint64(c.GasLimit) + // Field 8: GasUsed + hh.PutUint64(c.GasUsed) + // Field 9: Timestamp + hh.PutUint64(c.Timestamp) + // Field 10: ExtraData - // Field (0) 'ParentHash' - if size := len(e.ParentHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentHash", size, 32) - return - } - hh.PutBytes(e.ParentHash) - - // Field (1) 'FeeRecipient' - if size := len(e.FeeRecipient); size != 20 { - err = ssz.ErrBytesLengthFn("--.FeeRecipient", size, 20) - return - } - hh.PutBytes(e.FeeRecipient) - - // Field (2) 'StateRoot' - if size := len(e.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return - } - hh.PutBytes(e.StateRoot) - - // Field (3) 'ReceiptsRoot' - if size := len(e.ReceiptsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ReceiptsRoot", size, 32) - return - } - hh.PutBytes(e.ReceiptsRoot) - - // Field (4) 'LogsBloom' - if size := len(e.LogsBloom); size != 256 { - err = ssz.ErrBytesLengthFn("--.LogsBloom", size, 256) - return - } - hh.PutBytes(e.LogsBloom) - - // Field (5) 'PrevRandao' - if size := len(e.PrevRandao); size != 32 { - err = ssz.ErrBytesLengthFn("--.PrevRandao", size, 32) - return - } - hh.PutBytes(e.PrevRandao) - - // Field (6) 'BlockNumber' - ssz.PutUint(hh, e.BlockNumber) - - // Field (7) 'GasLimit' - ssz.PutUint(hh, e.GasLimit) - - // Field (8) 'GasUsed' - ssz.PutUint(hh, e.GasUsed) - - // Field (9) 'Timestamp' - ssz.PutUint(hh, e.Timestamp) - - // Field (10) 'ExtraData' { - elemIndx := hh.Index() - byteLen := uint64(len(e.ExtraData)) - if byteLen > 32 { - err = ssz.ErrIncorrectListSize - return + if len(c.ExtraData) > 32 { + return ssz.ErrBytesLength } - hh.AppendBytes32(e.ExtraData) - hh.MerkleizeWithMixin(elemIndx, byteLen, (32+31)/32) + subIndx := hh.Index() + hh.AppendBytes32(c.ExtraData) + numItems := uint64(len(c.ExtraData)) + hh.MerkleizeWithMixin(subIndx, numItems, (32*1+31)/32) } - // Field (11) 'BaseFeePerGas' - if size := len(e.BaseFeePerGas); size != 32 { - err = ssz.ErrBytesLengthFn("--.BaseFeePerGas", size, 32) - return + // Field 11: BaseFeePerGas + if len(c.BaseFeePerGas) != 32 { + return ssz.ErrBytesLength } - hh.PutBytes(e.BaseFeePerGas) - - // Field (12) 'BlockHash' - if size := len(e.BlockHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockHash", size, 32) - return + hh.PutBytes(c.BaseFeePerGas) + // Field 12: BlockHash + if len(c.BlockHash) != 32 { + return ssz.ErrBytesLength } - hh.PutBytes(e.BlockHash) - - // Field (13) 'Transactions' + hh.PutBytes(c.BlockHash) + // Field 13: Transactions { - subIndx := hh.Index() - num := uint64(len(e.Transactions)) - if num > 1048576 { - err = ssz.ErrIncorrectListSize - return + if len(c.Transactions) > 1048576 { + return ssz.ErrListTooBig } - for _, elem := range e.Transactions { + subIndx := hh.Index() + for _, o := range c.Transactions { + { - elemIndx := hh.Index() - byteLen := uint64(len(elem)) - if byteLen > 1073741824 { - err = ssz.ErrIncorrectListSize - return + if len(o) > 1073741824 { + return ssz.ErrBytesLength } - hh.AppendBytes32(elem) - hh.MerkleizeWithMixin(elemIndx, byteLen, (1073741824+31)/32) + subIndx := hh.Index() + hh.AppendBytes32(o) + numItems := uint64(len(o)) + hh.MerkleizeWithMixin(subIndx, numItems, (1073741824*1+31)/32) } + } - hh.MerkleizeWithMixin(subIndx, num, 1048576) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Transactions)), 1048576) } - hh.Merkleize(indx) - return + return nil +} + +func (c *ExecutionPayloadCapella) SizeSSZ() int { + size := 512 + size += len(c.ExtraData) + for _, o := range c.Transactions { + size += 4 + size += len(o) + } + size += len(c.Withdrawals) * 44 + return size } -// MarshalSSZ ssz marshals the ExecutionPayloadCapella object -func (e *ExecutionPayloadCapella) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(e) +func (c *ExecutionPayloadCapella) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the ExecutionPayloadCapella object to a target array -func (e *ExecutionPayloadCapella) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(512) +func (c *ExecutionPayloadCapella) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 512 - // Field (0) 'ParentHash' - if size := len(e.ParentHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentHash", size, 32) - return + // Field 0: ParentHash + if len(c.ParentHash) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.ParentHash...) + dst = append(dst, c.ParentHash...) - // Field (1) 'FeeRecipient' - if size := len(e.FeeRecipient); size != 20 { - err = ssz.ErrBytesLengthFn("--.FeeRecipient", size, 20) - return + // Field 1: FeeRecipient + if len(c.FeeRecipient) != 20 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.FeeRecipient...) + dst = append(dst, c.FeeRecipient...) - // Field (2) 'StateRoot' - if size := len(e.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return + // Field 2: StateRoot + if len(c.StateRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.StateRoot...) + dst = append(dst, c.StateRoot...) - // Field (3) 'ReceiptsRoot' - if size := len(e.ReceiptsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ReceiptsRoot", size, 32) - return + // Field 3: ReceiptsRoot + if len(c.ReceiptsRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.ReceiptsRoot...) + dst = append(dst, c.ReceiptsRoot...) - // Field (4) 'LogsBloom' - if size := len(e.LogsBloom); size != 256 { - err = ssz.ErrBytesLengthFn("--.LogsBloom", size, 256) - return + // Field 4: LogsBloom + if len(c.LogsBloom) != 256 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.LogsBloom...) + dst = append(dst, c.LogsBloom...) - // Field (5) 'PrevRandao' - if size := len(e.PrevRandao); size != 32 { - err = ssz.ErrBytesLengthFn("--.PrevRandao", size, 32) - return + // Field 5: PrevRandao + if len(c.PrevRandao) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.PrevRandao...) + dst = append(dst, c.PrevRandao...) - // Field (6) 'BlockNumber' - dst = ssz.MarshalUint(dst, e.BlockNumber) + // Field 6: BlockNumber + dst = binary.LittleEndian.AppendUint64(dst, c.BlockNumber) - // Field (7) 'GasLimit' - dst = ssz.MarshalUint(dst, e.GasLimit) + // Field 7: GasLimit + dst = binary.LittleEndian.AppendUint64(dst, c.GasLimit) - // Field (8) 'GasUsed' - dst = ssz.MarshalUint(dst, e.GasUsed) + // Field 8: GasUsed + dst = binary.LittleEndian.AppendUint64(dst, c.GasUsed) - // Field (9) 'Timestamp' - dst = ssz.MarshalUint(dst, e.Timestamp) + // Field 9: Timestamp + dst = binary.LittleEndian.AppendUint64(dst, c.Timestamp) - // Offset (10) 'ExtraData' + // Field 10: ExtraData dst = ssz.WriteOffset(dst, offset) - offset += len(e.ExtraData) + offset += len(c.ExtraData) - // Field (11) 'BaseFeePerGas' - if size := len(e.BaseFeePerGas); size != 32 { - err = ssz.ErrBytesLengthFn("--.BaseFeePerGas", size, 32) - return + // Field 11: BaseFeePerGas + if len(c.BaseFeePerGas) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.BaseFeePerGas...) + dst = append(dst, c.BaseFeePerGas...) - // Field (12) 'BlockHash' - if size := len(e.BlockHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockHash", size, 32) - return + // Field 12: BlockHash + if len(c.BlockHash) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.BlockHash...) + dst = append(dst, c.BlockHash...) - // Offset (13) 'Transactions' + // Field 13: Transactions dst = ssz.WriteOffset(dst, offset) - for ii := 0; ii < len(e.Transactions); ii++ { + for _, o := range c.Transactions { offset += 4 - offset += len(e.Transactions[ii]) + offset += len(o) } - // Offset (14) 'Withdrawals' + // Field 14: Withdrawals dst = ssz.WriteOffset(dst, offset) - offset += len(e.Withdrawals) * 44 + offset += len(c.Withdrawals) * 44 - // Field (10) 'ExtraData' - if size := len(e.ExtraData); size > 32 { - err = ssz.ErrBytesLengthFn("--.ExtraData", size, 32) - return + // Field 10: ExtraData + if len(c.ExtraData) > 32 { + return nil, ssz.ErrListTooBig } - dst = append(dst, e.ExtraData...) + dst = append(dst, c.ExtraData...) - // Field (13) 'Transactions' - if size := len(e.Transactions); size > 1048576 { - err = ssz.ErrListTooBigFn("--.Transactions", size, 1048576) - return + // Field 13: Transactions + if len(c.Transactions) > 1048576 { + return nil, ssz.ErrListTooBig } { - offset = 4 * len(e.Transactions) - for ii := 0; ii < len(e.Transactions); ii++ { + offset = 4 * len(c.Transactions) + for _, o := range c.Transactions { dst = ssz.WriteOffset(dst, offset) - offset += len(e.Transactions[ii]) + offset += len(o) } } - for ii := 0; ii < len(e.Transactions); ii++ { - if size := len(e.Transactions[ii]); size > 1073741824 { - err = ssz.ErrBytesLengthFn("--.Transactions[ii]", size, 1073741824) - return + for _, o := range c.Transactions { + if len(o) > 1073741824 { + return nil, ssz.ErrListTooBig } - dst = append(dst, e.Transactions[ii]...) + dst = append(dst, o...) } - // Field (14) 'Withdrawals' - if size := len(e.Withdrawals); size > 16 { - err = ssz.ErrListTooBigFn("--.Withdrawals", size, 16) - return + // Field 14: Withdrawals + if len(c.Withdrawals) > 16 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(e.Withdrawals); ii++ { - if dst, err = e.Withdrawals[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.Withdrawals { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Withdrawals: %w", err) } } - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the ExecutionPayloadCapella object -func (e *ExecutionPayloadCapella) UnmarshalSSZ(buf []byte) error { +func (c *ExecutionPayloadCapella) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size < 512 { return ssz.ErrSize } - tail := buf - var o10, o13, o14 uint64 - - // Field (0) 'ParentHash' - if cap(e.ParentHash) == 0 { - e.ParentHash = make([]byte, 0, len(buf[0:32])) + sszSlice0 := buf[0:32] // c.ParentHash + sszSlice1 := buf[32:52] // c.FeeRecipient + sszSlice2 := buf[52:84] // c.StateRoot + sszSlice3 := buf[84:116] // c.ReceiptsRoot + sszSlice4 := buf[116:372] // c.LogsBloom + sszSlice5 := buf[372:404] // c.PrevRandao + sszSlice6 := buf[404:412] // c.BlockNumber + sszSlice7 := buf[412:420] // c.GasLimit + sszSlice8 := buf[420:428] // c.GasUsed + sszSlice9 := buf[428:436] // c.Timestamp + sszSlice11 := buf[440:472] // c.BaseFeePerGas + sszSlice12 := buf[472:504] // c.BlockHash + + sszVarOffset10 := ssz.ReadOffset(buf[436:440]) // c.ExtraData + if sszVarOffset10 != 512 { + return ssz.ErrInvalidVariableOffset } - e.ParentHash = append(e.ParentHash, buf[0:32]...) - - // Field (1) 'FeeRecipient' - if cap(e.FeeRecipient) == 0 { - e.FeeRecipient = make([]byte, 0, len(buf[32:52])) + if sszVarOffset10 > size { + return ssz.ErrOffset } - e.FeeRecipient = append(e.FeeRecipient, buf[32:52]...) - - // Field (2) 'StateRoot' - if cap(e.StateRoot) == 0 { - e.StateRoot = make([]byte, 0, len(buf[52:84])) + sszVarOffset13 := ssz.ReadOffset(buf[504:508]) // c.Transactions + if sszVarOffset13 > size || sszVarOffset13 < sszVarOffset10 { + return ssz.ErrOffset } - e.StateRoot = append(e.StateRoot, buf[52:84]...) - - // Field (3) 'ReceiptsRoot' - if cap(e.ReceiptsRoot) == 0 { - e.ReceiptsRoot = make([]byte, 0, len(buf[84:116])) + sszVarOffset14 := ssz.ReadOffset(buf[508:512]) // c.Withdrawals + if sszVarOffset14 > size || sszVarOffset14 < sszVarOffset13 { + return ssz.ErrOffset } - e.ReceiptsRoot = append(e.ReceiptsRoot, buf[84:116]...) + sszSlice10 := buf[sszVarOffset10:sszVarOffset13] // c.ExtraData + sszSlice13 := buf[sszVarOffset13:sszVarOffset14] // c.Transactions + sszSlice14 := buf[sszVarOffset14:] // c.Withdrawals - // Field (4) 'LogsBloom' - if cap(e.LogsBloom) == 0 { - e.LogsBloom = make([]byte, 0, len(buf[116:372])) - } - e.LogsBloom = append(e.LogsBloom, buf[116:372]...) + // Field 0: ParentHash + c.ParentHash = make([]byte, 0, 32) + c.ParentHash = append(c.ParentHash, sszSlice0...) - // Field (5) 'PrevRandao' - if cap(e.PrevRandao) == 0 { - e.PrevRandao = make([]byte, 0, len(buf[372:404])) - } - e.PrevRandao = append(e.PrevRandao, buf[372:404]...) + // Field 1: FeeRecipient + c.FeeRecipient = make([]byte, 0, 20) + c.FeeRecipient = append(c.FeeRecipient, sszSlice1...) - // Field (6) 'BlockNumber' - e.BlockNumber = ssz.UnmarshallUint[uint64](buf[404:412]) + // Field 2: StateRoot + c.StateRoot = make([]byte, 0, 32) + c.StateRoot = append(c.StateRoot, sszSlice2...) - // Field (7) 'GasLimit' - e.GasLimit = ssz.UnmarshallUint[uint64](buf[412:420]) + // Field 3: ReceiptsRoot + c.ReceiptsRoot = make([]byte, 0, 32) + c.ReceiptsRoot = append(c.ReceiptsRoot, sszSlice3...) - // Field (8) 'GasUsed' - e.GasUsed = ssz.UnmarshallUint[uint64](buf[420:428]) + // Field 4: LogsBloom + c.LogsBloom = make([]byte, 0, 256) + c.LogsBloom = append(c.LogsBloom, sszSlice4...) - // Field (9) 'Timestamp' - e.Timestamp = ssz.UnmarshallUint[uint64](buf[428:436]) + // Field 5: PrevRandao + c.PrevRandao = make([]byte, 0, 32) + c.PrevRandao = append(c.PrevRandao, sszSlice5...) - // Offset (10) 'ExtraData' - if o10 = ssz.ReadOffset(buf[436:440]); o10 > size { - return ssz.ErrOffset - } + // Field 6: BlockNumber + c.BlockNumber = binary.LittleEndian.Uint64(sszSlice6) - if o10 != 512 { - return ssz.ErrInvalidVariableOffset - } + // Field 7: GasLimit + c.GasLimit = binary.LittleEndian.Uint64(sszSlice7) - // Field (11) 'BaseFeePerGas' - if cap(e.BaseFeePerGas) == 0 { - e.BaseFeePerGas = make([]byte, 0, len(buf[440:472])) - } - e.BaseFeePerGas = append(e.BaseFeePerGas, buf[440:472]...) + // Field 8: GasUsed + c.GasUsed = binary.LittleEndian.Uint64(sszSlice8) - // Field (12) 'BlockHash' - if cap(e.BlockHash) == 0 { - e.BlockHash = make([]byte, 0, len(buf[472:504])) - } - e.BlockHash = append(e.BlockHash, buf[472:504]...) + // Field 9: Timestamp + c.Timestamp = binary.LittleEndian.Uint64(sszSlice9) - // Offset (13) 'Transactions' - if o13 = ssz.ReadOffset(buf[504:508]); o13 > size || o10 > o13 { - return ssz.ErrOffset - } + // Field 10: ExtraData + c.ExtraData = append([]byte{}, sszSlice10...) - // Offset (14) 'Withdrawals' - if o14 = ssz.ReadOffset(buf[508:512]); o14 > size || o13 > o14 { - return ssz.ErrOffset - } + // Field 11: BaseFeePerGas + c.BaseFeePerGas = make([]byte, 0, 32) + c.BaseFeePerGas = append(c.BaseFeePerGas, sszSlice11...) - // 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 12: BlockHash + c.BlockHash = make([]byte, 0, 32) + c.BlockHash = append(c.BlockHash, sszSlice12...) - // Field (13) 'Transactions' + // 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 + // empty lists are zero length, so make sure there is room for an offset + // before attempting to unmarshal it + if len(sszSlice13) > 3 { + startOffset := ssz.ReadOffset(sszSlice13[0:4]) + if startOffset == 0 { + return fmt.Errorf("encountered invalid offset of 0 when decoding c.Transactions") + } + if startOffset%4 != 0 { + return fmt.Errorf("misaligned list bytes: when decoding c.Transactions, end-of-list offset is %d, which is not a multiple of 4 (offset size)", startOffset) + } + listLen := startOffset / 4 + if listLen > 1048576 { + return fmt.Errorf("ssz-max exceeded: c.Transactions has %d elements, ssz-max is 1048576: %w", listLen, ssz.ErrListTooBig) } - if cap(e.Transactions[indx]) == 0 { - e.Transactions[indx] = make([]byte, 0, len(buf)) + totalVarBytes := uint64(len(sszSlice13)) + if totalVarBytes < startOffset { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.Transactions") } - e.Transactions[indx] = append(e.Transactions[indx], buf...) - return nil - }) - if err != nil { - return err + c.Transactions = make([][]byte, listLen) + var tmpSlice []byte + for i := uint64(0); i < listLen; i++ { + var tmp []byte + + endOffset := totalVarBytes + if i+1 != listLen { + endOffset = ssz.ReadOffset(sszSlice13[(i+1)*4 : (i+2)*4]) + if totalVarBytes < endOffset { + return fmt.Errorf("offset %d points past the end of buffer when decoding c.Transactions", endOffset) + } + } + if endOffset < startOffset { + return fmt.Errorf("offset %d is not greater than start offset %d when decoding c.Transactions", endOffset, startOffset) + } + tmpSlice = sszSlice13[startOffset:endOffset] + tmp = append([]byte{}, tmpSlice...) + c.Transactions[i] = tmp + startOffset = endOffset + } + } else { + if len(sszSlice13) > 0 { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.Transactions") + } + c.Transactions = make([][]byte, 0) } } - // Field (14) 'Withdrawals' + // 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 + if len(sszSlice14)%44 != 0 { + return fmt.Errorf("misaligned bytes: c.Withdrawals length is %d, which is not a multiple of 44: %w", len(sszSlice14), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice14) / 44 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.Withdrawals has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.Withdrawals = make([]*Withdrawal, numElem) + for i := 0; i < numElem; i++ { + var tmp *Withdrawal + tmp = new(Withdrawal) + tmpSlice := sszSlice14[i*44 : (1+i)*44] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Withdrawals: %w", err) } + c.Withdrawals[i] = tmp } } return err } -// SizeSSZ returns the ssz encoded size in bytes for the ExecutionPayloadCapella object -func (e *ExecutionPayloadCapella) SizeSSZ() (size int) { - size = 512 - - // 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]) +func (c *ExecutionPayloadCapella) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - - // Field (14) 'Withdrawals' - size += len(e.Withdrawals) * 44 - - return -} - -// HashTreeRoot ssz hashes the ExecutionPayloadCapella object -func (e *ExecutionPayloadCapella) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(e) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the ExecutionPayloadCapella object with a hasher -func (e *ExecutionPayloadCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *ExecutionPayloadCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() + // Field 0: ParentHash + if len(c.ParentHash) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ParentHash) + // Field 1: FeeRecipient + if len(c.FeeRecipient) != 20 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.FeeRecipient) + // Field 2: StateRoot + if len(c.StateRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.StateRoot) + // Field 3: ReceiptsRoot + if len(c.ReceiptsRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ReceiptsRoot) + // Field 4: LogsBloom + if len(c.LogsBloom) != 256 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.LogsBloom) + // Field 5: PrevRandao + if len(c.PrevRandao) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.PrevRandao) + // Field 6: BlockNumber + hh.PutUint64(c.BlockNumber) + // Field 7: GasLimit + hh.PutUint64(c.GasLimit) + // Field 8: GasUsed + hh.PutUint64(c.GasUsed) + // Field 9: Timestamp + hh.PutUint64(c.Timestamp) + // Field 10: ExtraData - // Field (0) 'ParentHash' - if size := len(e.ParentHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentHash", size, 32) - return - } - hh.PutBytes(e.ParentHash) - - // Field (1) 'FeeRecipient' - if size := len(e.FeeRecipient); size != 20 { - err = ssz.ErrBytesLengthFn("--.FeeRecipient", size, 20) - return - } - hh.PutBytes(e.FeeRecipient) - - // Field (2) 'StateRoot' - if size := len(e.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return - } - hh.PutBytes(e.StateRoot) - - // Field (3) 'ReceiptsRoot' - if size := len(e.ReceiptsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ReceiptsRoot", size, 32) - return - } - hh.PutBytes(e.ReceiptsRoot) - - // Field (4) 'LogsBloom' - if size := len(e.LogsBloom); size != 256 { - err = ssz.ErrBytesLengthFn("--.LogsBloom", size, 256) - return - } - hh.PutBytes(e.LogsBloom) - - // Field (5) 'PrevRandao' - if size := len(e.PrevRandao); size != 32 { - err = ssz.ErrBytesLengthFn("--.PrevRandao", size, 32) - return - } - hh.PutBytes(e.PrevRandao) - - // Field (6) 'BlockNumber' - ssz.PutUint(hh, e.BlockNumber) - - // Field (7) 'GasLimit' - ssz.PutUint(hh, e.GasLimit) - - // Field (8) 'GasUsed' - ssz.PutUint(hh, e.GasUsed) - - // Field (9) 'Timestamp' - ssz.PutUint(hh, e.Timestamp) - - // Field (10) 'ExtraData' { - elemIndx := hh.Index() - byteLen := uint64(len(e.ExtraData)) - if byteLen > 32 { - err = ssz.ErrIncorrectListSize - return + if len(c.ExtraData) > 32 { + return ssz.ErrBytesLength } - hh.AppendBytes32(e.ExtraData) - hh.MerkleizeWithMixin(elemIndx, byteLen, (32+31)/32) + subIndx := hh.Index() + hh.AppendBytes32(c.ExtraData) + numItems := uint64(len(c.ExtraData)) + hh.MerkleizeWithMixin(subIndx, numItems, (32*1+31)/32) } - // Field (11) 'BaseFeePerGas' - if size := len(e.BaseFeePerGas); size != 32 { - err = ssz.ErrBytesLengthFn("--.BaseFeePerGas", size, 32) - return + // Field 11: BaseFeePerGas + if len(c.BaseFeePerGas) != 32 { + return ssz.ErrBytesLength } - hh.PutBytes(e.BaseFeePerGas) - - // Field (12) 'BlockHash' - if size := len(e.BlockHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockHash", size, 32) - return + hh.PutBytes(c.BaseFeePerGas) + // Field 12: BlockHash + if len(c.BlockHash) != 32 { + return ssz.ErrBytesLength } - hh.PutBytes(e.BlockHash) - - // Field (13) 'Transactions' + hh.PutBytes(c.BlockHash) + // Field 13: Transactions { - subIndx := hh.Index() - num := uint64(len(e.Transactions)) - if num > 1048576 { - err = ssz.ErrIncorrectListSize - return + if len(c.Transactions) > 1048576 { + return ssz.ErrListTooBig } - for _, elem := range e.Transactions { + subIndx := hh.Index() + for _, o := range c.Transactions { + { - elemIndx := hh.Index() - byteLen := uint64(len(elem)) - if byteLen > 1073741824 { - err = ssz.ErrIncorrectListSize - return + if len(o) > 1073741824 { + return ssz.ErrBytesLength } - hh.AppendBytes32(elem) - hh.MerkleizeWithMixin(elemIndx, byteLen, (1073741824+31)/32) + subIndx := hh.Index() + hh.AppendBytes32(o) + numItems := uint64(len(o)) + hh.MerkleizeWithMixin(subIndx, numItems, (1073741824*1+31)/32) } + } - hh.MerkleizeWithMixin(subIndx, num, 1048576) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Transactions)), 1048576) } - - // Field (14) 'Withdrawals' + // Field 14: Withdrawals { + if len(c.Withdrawals) > 16 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.Withdrawals { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Withdrawals: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Withdrawals)), 16) } - hh.Merkleize(indx) - return + return nil +} + +func (c *ExecutionPayloadDeneb) SizeSSZ() int { + size := 528 + size += len(c.ExtraData) + for _, o := range c.Transactions { + size += 4 + size += len(o) + } + size += len(c.Withdrawals) * 44 + return size } -// MarshalSSZ ssz marshals the ExecutionPayloadDeneb object -func (e *ExecutionPayloadDeneb) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(e) +func (c *ExecutionPayloadDeneb) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the ExecutionPayloadDeneb object to a target array -func (e *ExecutionPayloadDeneb) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(528) +func (c *ExecutionPayloadDeneb) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 528 - // Field (0) 'ParentHash' - if size := len(e.ParentHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentHash", size, 32) - return + // Field 0: ParentHash + if len(c.ParentHash) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.ParentHash...) + dst = append(dst, c.ParentHash...) - // Field (1) 'FeeRecipient' - if size := len(e.FeeRecipient); size != 20 { - err = ssz.ErrBytesLengthFn("--.FeeRecipient", size, 20) - return + // Field 1: FeeRecipient + if len(c.FeeRecipient) != 20 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.FeeRecipient...) + dst = append(dst, c.FeeRecipient...) - // Field (2) 'StateRoot' - if size := len(e.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return + // Field 2: StateRoot + if len(c.StateRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.StateRoot...) + dst = append(dst, c.StateRoot...) - // Field (3) 'ReceiptsRoot' - if size := len(e.ReceiptsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ReceiptsRoot", size, 32) - return + // Field 3: ReceiptsRoot + if len(c.ReceiptsRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.ReceiptsRoot...) + dst = append(dst, c.ReceiptsRoot...) - // Field (4) 'LogsBloom' - if size := len(e.LogsBloom); size != 256 { - err = ssz.ErrBytesLengthFn("--.LogsBloom", size, 256) - return + // Field 4: LogsBloom + if len(c.LogsBloom) != 256 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.LogsBloom...) + dst = append(dst, c.LogsBloom...) - // Field (5) 'PrevRandao' - if size := len(e.PrevRandao); size != 32 { - err = ssz.ErrBytesLengthFn("--.PrevRandao", size, 32) - return + // Field 5: PrevRandao + if len(c.PrevRandao) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.PrevRandao...) + dst = append(dst, c.PrevRandao...) - // Field (6) 'BlockNumber' - dst = ssz.MarshalUint(dst, e.BlockNumber) + // Field 6: BlockNumber + dst = binary.LittleEndian.AppendUint64(dst, c.BlockNumber) - // Field (7) 'GasLimit' - dst = ssz.MarshalUint(dst, e.GasLimit) + // Field 7: GasLimit + dst = binary.LittleEndian.AppendUint64(dst, c.GasLimit) - // Field (8) 'GasUsed' - dst = ssz.MarshalUint(dst, e.GasUsed) + // Field 8: GasUsed + dst = binary.LittleEndian.AppendUint64(dst, c.GasUsed) - // Field (9) 'Timestamp' - dst = ssz.MarshalUint(dst, e.Timestamp) + // Field 9: Timestamp + dst = binary.LittleEndian.AppendUint64(dst, c.Timestamp) - // Offset (10) 'ExtraData' + // Field 10: ExtraData dst = ssz.WriteOffset(dst, offset) - offset += len(e.ExtraData) + offset += len(c.ExtraData) - // Field (11) 'BaseFeePerGas' - if size := len(e.BaseFeePerGas); size != 32 { - err = ssz.ErrBytesLengthFn("--.BaseFeePerGas", size, 32) - return + // Field 11: BaseFeePerGas + if len(c.BaseFeePerGas) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.BaseFeePerGas...) + dst = append(dst, c.BaseFeePerGas...) - // Field (12) 'BlockHash' - if size := len(e.BlockHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockHash", size, 32) - return + // Field 12: BlockHash + if len(c.BlockHash) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.BlockHash...) + dst = append(dst, c.BlockHash...) - // Offset (13) 'Transactions' + // Field 13: Transactions dst = ssz.WriteOffset(dst, offset) - for ii := 0; ii < len(e.Transactions); ii++ { + for _, o := range c.Transactions { offset += 4 - offset += len(e.Transactions[ii]) + offset += len(o) } - // Offset (14) 'Withdrawals' + // Field 14: Withdrawals dst = ssz.WriteOffset(dst, offset) - offset += len(e.Withdrawals) * 44 + offset += len(c.Withdrawals) * 44 - // Field (15) 'BlobGasUsed' - dst = ssz.MarshalUint(dst, e.BlobGasUsed) + // Field 15: BlobGasUsed + dst = binary.LittleEndian.AppendUint64(dst, c.BlobGasUsed) - // Field (16) 'ExcessBlobGas' - dst = ssz.MarshalUint(dst, e.ExcessBlobGas) + // Field 16: ExcessBlobGas + dst = binary.LittleEndian.AppendUint64(dst, c.ExcessBlobGas) - // Field (10) 'ExtraData' - if size := len(e.ExtraData); size > 32 { - err = ssz.ErrBytesLengthFn("--.ExtraData", size, 32) - return + // Field 10: ExtraData + if len(c.ExtraData) > 32 { + return nil, ssz.ErrListTooBig } - dst = append(dst, e.ExtraData...) + dst = append(dst, c.ExtraData...) - // Field (13) 'Transactions' - if size := len(e.Transactions); size > 1048576 { - err = ssz.ErrListTooBigFn("--.Transactions", size, 1048576) - return + // Field 13: Transactions + if len(c.Transactions) > 1048576 { + return nil, ssz.ErrListTooBig } { - offset = 4 * len(e.Transactions) - for ii := 0; ii < len(e.Transactions); ii++ { + offset = 4 * len(c.Transactions) + for _, o := range c.Transactions { dst = ssz.WriteOffset(dst, offset) - offset += len(e.Transactions[ii]) + offset += len(o) } } - for ii := 0; ii < len(e.Transactions); ii++ { - if size := len(e.Transactions[ii]); size > 1073741824 { - err = ssz.ErrBytesLengthFn("--.Transactions[ii]", size, 1073741824) - return + for _, o := range c.Transactions { + if len(o) > 1073741824 { + return nil, ssz.ErrListTooBig } - dst = append(dst, e.Transactions[ii]...) + dst = append(dst, o...) } - // Field (14) 'Withdrawals' - if size := len(e.Withdrawals); size > 16 { - err = ssz.ErrListTooBigFn("--.Withdrawals", size, 16) - return + // Field 14: Withdrawals + if len(c.Withdrawals) > 16 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(e.Withdrawals); ii++ { - if dst, err = e.Withdrawals[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.Withdrawals { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Withdrawals: %w", err) } } - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the ExecutionPayloadDeneb object -func (e *ExecutionPayloadDeneb) UnmarshalSSZ(buf []byte) error { +func (c *ExecutionPayloadDeneb) 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' - if cap(e.ParentHash) == 0 { - e.ParentHash = make([]byte, 0, len(buf[0:32])) - } - e.ParentHash = append(e.ParentHash, buf[0:32]...) - - // Field (1) 'FeeRecipient' - if cap(e.FeeRecipient) == 0 { - e.FeeRecipient = make([]byte, 0, len(buf[32:52])) - } - e.FeeRecipient = append(e.FeeRecipient, buf[32:52]...) - - // Field (2) 'StateRoot' - if cap(e.StateRoot) == 0 { - e.StateRoot = make([]byte, 0, len(buf[52:84])) + sszSlice0 := buf[0:32] // c.ParentHash + sszSlice1 := buf[32:52] // c.FeeRecipient + sszSlice2 := buf[52:84] // c.StateRoot + sszSlice3 := buf[84:116] // c.ReceiptsRoot + sszSlice4 := buf[116:372] // c.LogsBloom + sszSlice5 := buf[372:404] // c.PrevRandao + sszSlice6 := buf[404:412] // c.BlockNumber + sszSlice7 := buf[412:420] // c.GasLimit + sszSlice8 := buf[420:428] // c.GasUsed + sszSlice9 := buf[428:436] // c.Timestamp + sszSlice11 := buf[440:472] // c.BaseFeePerGas + sszSlice12 := buf[472:504] // c.BlockHash + sszSlice15 := buf[512:520] // c.BlobGasUsed + sszSlice16 := buf[520:528] // c.ExcessBlobGas + + sszVarOffset10 := ssz.ReadOffset(buf[436:440]) // c.ExtraData + if sszVarOffset10 != 528 { + return ssz.ErrInvalidVariableOffset } - e.StateRoot = append(e.StateRoot, buf[52:84]...) - - // Field (3) 'ReceiptsRoot' - if cap(e.ReceiptsRoot) == 0 { - e.ReceiptsRoot = make([]byte, 0, len(buf[84:116])) + if sszVarOffset10 > size { + return ssz.ErrOffset } - e.ReceiptsRoot = append(e.ReceiptsRoot, buf[84:116]...) - - // Field (4) 'LogsBloom' - if cap(e.LogsBloom) == 0 { - e.LogsBloom = make([]byte, 0, len(buf[116:372])) + sszVarOffset13 := ssz.ReadOffset(buf[504:508]) // c.Transactions + if sszVarOffset13 > size || sszVarOffset13 < sszVarOffset10 { + return ssz.ErrOffset } - e.LogsBloom = append(e.LogsBloom, buf[116:372]...) - - // Field (5) 'PrevRandao' - if cap(e.PrevRandao) == 0 { - e.PrevRandao = make([]byte, 0, len(buf[372:404])) + sszVarOffset14 := ssz.ReadOffset(buf[508:512]) // c.Withdrawals + if sszVarOffset14 > size || sszVarOffset14 < sszVarOffset13 { + return ssz.ErrOffset } - e.PrevRandao = append(e.PrevRandao, buf[372:404]...) + sszSlice10 := buf[sszVarOffset10:sszVarOffset13] // c.ExtraData + sszSlice13 := buf[sszVarOffset13:sszVarOffset14] // c.Transactions + sszSlice14 := buf[sszVarOffset14:] // c.Withdrawals - // Field (6) 'BlockNumber' - e.BlockNumber = ssz.UnmarshallUint[uint64](buf[404:412]) + // Field 0: ParentHash + c.ParentHash = make([]byte, 0, 32) + c.ParentHash = append(c.ParentHash, sszSlice0...) - // Field (7) 'GasLimit' - e.GasLimit = ssz.UnmarshallUint[uint64](buf[412:420]) + // Field 1: FeeRecipient + c.FeeRecipient = make([]byte, 0, 20) + c.FeeRecipient = append(c.FeeRecipient, sszSlice1...) - // Field (8) 'GasUsed' - e.GasUsed = ssz.UnmarshallUint[uint64](buf[420:428]) + // Field 2: StateRoot + c.StateRoot = make([]byte, 0, 32) + c.StateRoot = append(c.StateRoot, sszSlice2...) - // Field (9) 'Timestamp' - e.Timestamp = ssz.UnmarshallUint[uint64](buf[428:436]) + // Field 3: ReceiptsRoot + c.ReceiptsRoot = make([]byte, 0, 32) + c.ReceiptsRoot = append(c.ReceiptsRoot, sszSlice3...) - // Offset (10) 'ExtraData' - if o10 = ssz.ReadOffset(buf[436:440]); o10 > size { - return ssz.ErrOffset - } + // Field 4: LogsBloom + c.LogsBloom = make([]byte, 0, 256) + c.LogsBloom = append(c.LogsBloom, sszSlice4...) - if o10 != 528 { - return ssz.ErrInvalidVariableOffset - } + // Field 5: PrevRandao + c.PrevRandao = make([]byte, 0, 32) + c.PrevRandao = append(c.PrevRandao, sszSlice5...) - // Field (11) 'BaseFeePerGas' - if cap(e.BaseFeePerGas) == 0 { - e.BaseFeePerGas = make([]byte, 0, len(buf[440:472])) - } - e.BaseFeePerGas = append(e.BaseFeePerGas, buf[440:472]...) + // Field 6: BlockNumber + c.BlockNumber = binary.LittleEndian.Uint64(sszSlice6) - // Field (12) 'BlockHash' - if cap(e.BlockHash) == 0 { - e.BlockHash = make([]byte, 0, len(buf[472:504])) - } - e.BlockHash = append(e.BlockHash, buf[472:504]...) + // Field 7: GasLimit + c.GasLimit = binary.LittleEndian.Uint64(sszSlice7) - // Offset (13) 'Transactions' - if o13 = ssz.ReadOffset(buf[504:508]); o13 > size || o10 > o13 { - return ssz.ErrOffset - } + // Field 8: GasUsed + c.GasUsed = binary.LittleEndian.Uint64(sszSlice8) - // Offset (14) 'Withdrawals' - if o14 = ssz.ReadOffset(buf[508:512]); o14 > size || o13 > o14 { - return ssz.ErrOffset - } + // Field 9: Timestamp + c.Timestamp = binary.LittleEndian.Uint64(sszSlice9) - // Field (15) 'BlobGasUsed' - e.BlobGasUsed = ssz.UnmarshallUint[uint64](buf[512:520]) + // Field 10: ExtraData + c.ExtraData = append([]byte{}, sszSlice10...) - // Field (16) 'ExcessBlobGas' - e.ExcessBlobGas = ssz.UnmarshallUint[uint64](buf[520:528]) + // Field 11: BaseFeePerGas + c.BaseFeePerGas = make([]byte, 0, 32) + c.BaseFeePerGas = append(c.BaseFeePerGas, sszSlice11...) - // 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 12: BlockHash + c.BlockHash = make([]byte, 0, 32) + c.BlockHash = append(c.BlockHash, sszSlice12...) - // Field (13) 'Transactions' + // 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 + // empty lists are zero length, so make sure there is room for an offset + // before attempting to unmarshal it + if len(sszSlice13) > 3 { + startOffset := ssz.ReadOffset(sszSlice13[0:4]) + if startOffset == 0 { + return fmt.Errorf("encountered invalid offset of 0 when decoding c.Transactions") + } + if startOffset%4 != 0 { + return fmt.Errorf("misaligned list bytes: when decoding c.Transactions, end-of-list offset is %d, which is not a multiple of 4 (offset size)", startOffset) + } + listLen := startOffset / 4 + if listLen > 1048576 { + return fmt.Errorf("ssz-max exceeded: c.Transactions has %d elements, ssz-max is 1048576: %w", listLen, ssz.ErrListTooBig) + } + totalVarBytes := uint64(len(sszSlice13)) + if totalVarBytes < startOffset { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.Transactions") } - if cap(e.Transactions[indx]) == 0 { - e.Transactions[indx] = make([]byte, 0, len(buf)) + c.Transactions = make([][]byte, listLen) + var tmpSlice []byte + for i := uint64(0); i < listLen; i++ { + var tmp []byte + + endOffset := totalVarBytes + if i+1 != listLen { + endOffset = ssz.ReadOffset(sszSlice13[(i+1)*4 : (i+2)*4]) + if totalVarBytes < endOffset { + return fmt.Errorf("offset %d points past the end of buffer when decoding c.Transactions", endOffset) + } + } + if endOffset < startOffset { + return fmt.Errorf("offset %d is not greater than start offset %d when decoding c.Transactions", endOffset, startOffset) + } + tmpSlice = sszSlice13[startOffset:endOffset] + tmp = append([]byte{}, tmpSlice...) + c.Transactions[i] = tmp + startOffset = endOffset } - e.Transactions[indx] = append(e.Transactions[indx], buf...) - return nil - }) - if err != nil { - return err + } else { + if len(sszSlice13) > 0 { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.Transactions") + } + c.Transactions = make([][]byte, 0) } } - // Field (14) 'Withdrawals' + // 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 + if len(sszSlice14)%44 != 0 { + return fmt.Errorf("misaligned bytes: c.Withdrawals length is %d, which is not a multiple of 44: %w", len(sszSlice14), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice14) / 44 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.Withdrawals has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.Withdrawals = make([]*Withdrawal, numElem) + for i := 0; i < numElem; i++ { + var tmp *Withdrawal + tmp = new(Withdrawal) + tmpSlice := sszSlice14[i*44 : (1+i)*44] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Withdrawals: %w", err) } + c.Withdrawals[i] = tmp } } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the ExecutionPayloadDeneb object -func (e *ExecutionPayloadDeneb) 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 15: BlobGasUsed + c.BlobGasUsed = binary.LittleEndian.Uint64(sszSlice15) - // Field (14) 'Withdrawals' - size += len(e.Withdrawals) * 44 - - return + // Field 16: ExcessBlobGas + c.ExcessBlobGas = binary.LittleEndian.Uint64(sszSlice16) + return err } -// HashTreeRoot ssz hashes the ExecutionPayloadDeneb object -func (e *ExecutionPayloadDeneb) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(e) +func (c *ExecutionPayloadDeneb) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the ExecutionPayloadDeneb object with a hasher -func (e *ExecutionPayloadDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *ExecutionPayloadDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() + // Field 0: ParentHash + if len(c.ParentHash) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ParentHash) + // Field 1: FeeRecipient + if len(c.FeeRecipient) != 20 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.FeeRecipient) + // Field 2: StateRoot + if len(c.StateRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.StateRoot) + // Field 3: ReceiptsRoot + if len(c.ReceiptsRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ReceiptsRoot) + // Field 4: LogsBloom + if len(c.LogsBloom) != 256 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.LogsBloom) + // Field 5: PrevRandao + if len(c.PrevRandao) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.PrevRandao) + // Field 6: BlockNumber + hh.PutUint64(c.BlockNumber) + // Field 7: GasLimit + hh.PutUint64(c.GasLimit) + // Field 8: GasUsed + hh.PutUint64(c.GasUsed) + // Field 9: Timestamp + hh.PutUint64(c.Timestamp) + // Field 10: ExtraData - // Field (0) 'ParentHash' - if size := len(e.ParentHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentHash", size, 32) - return - } - hh.PutBytes(e.ParentHash) - - // Field (1) 'FeeRecipient' - if size := len(e.FeeRecipient); size != 20 { - err = ssz.ErrBytesLengthFn("--.FeeRecipient", size, 20) - return - } - hh.PutBytes(e.FeeRecipient) - - // Field (2) 'StateRoot' - if size := len(e.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return - } - hh.PutBytes(e.StateRoot) - - // Field (3) 'ReceiptsRoot' - if size := len(e.ReceiptsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ReceiptsRoot", size, 32) - return - } - hh.PutBytes(e.ReceiptsRoot) - - // Field (4) 'LogsBloom' - if size := len(e.LogsBloom); size != 256 { - err = ssz.ErrBytesLengthFn("--.LogsBloom", size, 256) - return - } - hh.PutBytes(e.LogsBloom) - - // Field (5) 'PrevRandao' - if size := len(e.PrevRandao); size != 32 { - err = ssz.ErrBytesLengthFn("--.PrevRandao", size, 32) - return - } - hh.PutBytes(e.PrevRandao) - - // Field (6) 'BlockNumber' - ssz.PutUint(hh, e.BlockNumber) - - // Field (7) 'GasLimit' - ssz.PutUint(hh, e.GasLimit) - - // Field (8) 'GasUsed' - ssz.PutUint(hh, e.GasUsed) - - // Field (9) 'Timestamp' - ssz.PutUint(hh, e.Timestamp) - - // Field (10) 'ExtraData' { - elemIndx := hh.Index() - byteLen := uint64(len(e.ExtraData)) - if byteLen > 32 { - err = ssz.ErrIncorrectListSize - return + if len(c.ExtraData) > 32 { + return ssz.ErrBytesLength } - hh.AppendBytes32(e.ExtraData) - hh.MerkleizeWithMixin(elemIndx, byteLen, (32+31)/32) + subIndx := hh.Index() + hh.AppendBytes32(c.ExtraData) + numItems := uint64(len(c.ExtraData)) + hh.MerkleizeWithMixin(subIndx, numItems, (32*1+31)/32) } - // Field (11) 'BaseFeePerGas' - if size := len(e.BaseFeePerGas); size != 32 { - err = ssz.ErrBytesLengthFn("--.BaseFeePerGas", size, 32) - return + // Field 11: BaseFeePerGas + if len(c.BaseFeePerGas) != 32 { + return ssz.ErrBytesLength } - hh.PutBytes(e.BaseFeePerGas) - - // Field (12) 'BlockHash' - if size := len(e.BlockHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockHash", size, 32) - return + hh.PutBytes(c.BaseFeePerGas) + // Field 12: BlockHash + if len(c.BlockHash) != 32 { + return ssz.ErrBytesLength } - hh.PutBytes(e.BlockHash) - - // Field (13) 'Transactions' + hh.PutBytes(c.BlockHash) + // Field 13: Transactions { - subIndx := hh.Index() - num := uint64(len(e.Transactions)) - if num > 1048576 { - err = ssz.ErrIncorrectListSize - return + if len(c.Transactions) > 1048576 { + return ssz.ErrListTooBig } - for _, elem := range e.Transactions { + subIndx := hh.Index() + for _, o := range c.Transactions { + { - elemIndx := hh.Index() - byteLen := uint64(len(elem)) - if byteLen > 1073741824 { - err = ssz.ErrIncorrectListSize - return + if len(o) > 1073741824 { + return ssz.ErrBytesLength } - hh.AppendBytes32(elem) - hh.MerkleizeWithMixin(elemIndx, byteLen, (1073741824+31)/32) + subIndx := hh.Index() + hh.AppendBytes32(o) + numItems := uint64(len(o)) + hh.MerkleizeWithMixin(subIndx, numItems, (1073741824*1+31)/32) } + } - hh.MerkleizeWithMixin(subIndx, num, 1048576) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Transactions)), 1048576) } - - // Field (14) 'Withdrawals' + // Field 14: Withdrawals { + if len(c.Withdrawals) > 16 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.Withdrawals { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Withdrawals: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Withdrawals)), 16) } - - // Field (15) 'BlobGasUsed' - ssz.PutUint(hh, e.BlobGasUsed) - - // Field (16) 'ExcessBlobGas' - ssz.PutUint(hh, e.ExcessBlobGas) - + // Field 15: BlobGasUsed + hh.PutUint64(c.BlobGasUsed) + // Field 16: ExcessBlobGas + hh.PutUint64(c.ExcessBlobGas) hh.Merkleize(indx) - return + return nil +} + +func (c *ExecutionPayloadGloas) SizeSSZ() int { + size := 540 + size += len(c.ExtraData) + for _, o := range c.Transactions { + size += 4 + size += len(o) + } + size += len(c.Withdrawals) * 44 + size += len(c.BlockAccessList) + return size } -// MarshalSSZ ssz marshals the ExecutionPayloadGloas object -func (e *ExecutionPayloadGloas) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(e) +func (c *ExecutionPayloadGloas) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the ExecutionPayloadGloas object to a target array -func (e *ExecutionPayloadGloas) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(540) +func (c *ExecutionPayloadGloas) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 540 - // Field (0) 'ParentHash' - if size := len(e.ParentHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentHash", size, 32) - return + // Field 0: ParentHash + if len(c.ParentHash) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.ParentHash...) + dst = append(dst, c.ParentHash...) - // Field (1) 'FeeRecipient' - if size := len(e.FeeRecipient); size != 20 { - err = ssz.ErrBytesLengthFn("--.FeeRecipient", size, 20) - return + // Field 1: FeeRecipient + if len(c.FeeRecipient) != 20 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.FeeRecipient...) + dst = append(dst, c.FeeRecipient...) - // Field (2) 'StateRoot' - if size := len(e.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return + // Field 2: StateRoot + if len(c.StateRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.StateRoot...) + dst = append(dst, c.StateRoot...) - // Field (3) 'ReceiptsRoot' - if size := len(e.ReceiptsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ReceiptsRoot", size, 32) - return + // Field 3: ReceiptsRoot + if len(c.ReceiptsRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.ReceiptsRoot...) + dst = append(dst, c.ReceiptsRoot...) - // Field (4) 'LogsBloom' - if size := len(e.LogsBloom); size != 256 { - err = ssz.ErrBytesLengthFn("--.LogsBloom", size, 256) - return + // Field 4: LogsBloom + if len(c.LogsBloom) != 256 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.LogsBloom...) + dst = append(dst, c.LogsBloom...) - // Field (5) 'PrevRandao' - if size := len(e.PrevRandao); size != 32 { - err = ssz.ErrBytesLengthFn("--.PrevRandao", size, 32) - return + // Field 5: PrevRandao + if len(c.PrevRandao) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.PrevRandao...) + dst = append(dst, c.PrevRandao...) - // Field (6) 'BlockNumber' - dst = ssz.MarshalUint(dst, e.BlockNumber) + // Field 6: BlockNumber + dst = binary.LittleEndian.AppendUint64(dst, c.BlockNumber) - // Field (7) 'GasLimit' - dst = ssz.MarshalUint(dst, e.GasLimit) + // Field 7: GasLimit + dst = binary.LittleEndian.AppendUint64(dst, c.GasLimit) - // Field (8) 'GasUsed' - dst = ssz.MarshalUint(dst, e.GasUsed) + // Field 8: GasUsed + dst = binary.LittleEndian.AppendUint64(dst, c.GasUsed) - // Field (9) 'Timestamp' - dst = ssz.MarshalUint(dst, e.Timestamp) + // Field 9: Timestamp + dst = binary.LittleEndian.AppendUint64(dst, c.Timestamp) - // Offset (10) 'ExtraData' + // Field 10: ExtraData dst = ssz.WriteOffset(dst, offset) - offset += len(e.ExtraData) + offset += len(c.ExtraData) - // Field (11) 'BaseFeePerGas' - if size := len(e.BaseFeePerGas); size != 32 { - err = ssz.ErrBytesLengthFn("--.BaseFeePerGas", size, 32) - return + // Field 11: BaseFeePerGas + if len(c.BaseFeePerGas) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.BaseFeePerGas...) + dst = append(dst, c.BaseFeePerGas...) - // Field (12) 'BlockHash' - if size := len(e.BlockHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockHash", size, 32) - return + // Field 12: BlockHash + if len(c.BlockHash) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.BlockHash...) + dst = append(dst, c.BlockHash...) - // Offset (13) 'Transactions' + // Field 13: Transactions dst = ssz.WriteOffset(dst, offset) - for ii := 0; ii < len(e.Transactions); ii++ { + for _, o := range c.Transactions { offset += 4 - offset += len(e.Transactions[ii]) + offset += len(o) } - // Offset (14) 'Withdrawals' + // Field 14: Withdrawals dst = ssz.WriteOffset(dst, offset) - offset += len(e.Withdrawals) * 44 + offset += len(c.Withdrawals) * 44 - // Field (15) 'BlobGasUsed' - dst = ssz.MarshalUint(dst, e.BlobGasUsed) + // Field 15: BlobGasUsed + dst = binary.LittleEndian.AppendUint64(dst, c.BlobGasUsed) - // Field (16) 'ExcessBlobGas' - dst = ssz.MarshalUint(dst, e.ExcessBlobGas) + // Field 16: ExcessBlobGas + dst = binary.LittleEndian.AppendUint64(dst, c.ExcessBlobGas) - // Offset (17) 'BlockAccessList' + // Field 17: BlockAccessList dst = ssz.WriteOffset(dst, offset) - offset += len(e.BlockAccessList) + offset += len(c.BlockAccessList) - // Field (18) 'SlotNumber' - dst = ssz.MarshalUint(dst, e.SlotNumber) + // Field 18: SlotNumber + if dst, err = c.SlotNumber.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SlotNumber: %w", err) + } - // Field (10) 'ExtraData' - if size := len(e.ExtraData); size > 32 { - err = ssz.ErrBytesLengthFn("--.ExtraData", size, 32) - return + // Field 10: ExtraData + if len(c.ExtraData) > 32 { + return nil, ssz.ErrListTooBig } - dst = append(dst, e.ExtraData...) + dst = append(dst, c.ExtraData...) - // Field (13) 'Transactions' - if size := len(e.Transactions); size > 1048576 { - err = ssz.ErrListTooBigFn("--.Transactions", size, 1048576) - return + // Field 13: Transactions + if len(c.Transactions) > 1048576 { + return nil, ssz.ErrListTooBig } { - offset = 4 * len(e.Transactions) - for ii := 0; ii < len(e.Transactions); ii++ { + offset = 4 * len(c.Transactions) + for _, o := range c.Transactions { dst = ssz.WriteOffset(dst, offset) - offset += len(e.Transactions[ii]) + offset += len(o) } } - for ii := 0; ii < len(e.Transactions); ii++ { - if size := len(e.Transactions[ii]); size > 1073741824 { - err = ssz.ErrBytesLengthFn("--.Transactions[ii]", size, 1073741824) - return + for _, o := range c.Transactions { + if len(o) > 1073741824 { + return nil, ssz.ErrListTooBig } - dst = append(dst, e.Transactions[ii]...) + dst = append(dst, o...) } - // Field (14) 'Withdrawals' - if size := len(e.Withdrawals); size > 16 { - err = ssz.ErrListTooBigFn("--.Withdrawals", size, 16) - return + // Field 14: Withdrawals + if len(c.Withdrawals) > 16 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(e.Withdrawals); ii++ { - if dst, err = e.Withdrawals[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.Withdrawals { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Withdrawals: %w", err) } } - // Field (17) 'BlockAccessList' - if size := len(e.BlockAccessList); size > 1073741824 { - err = ssz.ErrBytesLengthFn("--.BlockAccessList", size, 1073741824) - return + // Field 17: BlockAccessList + if len(c.BlockAccessList) > 1073741824 { + return nil, ssz.ErrListTooBig } - dst = append(dst, e.BlockAccessList...) - - return + dst = append(dst, c.BlockAccessList...) + return dst, err } -// UnmarshalSSZ ssz unmarshals the ExecutionPayloadGloas object -func (e *ExecutionPayloadGloas) UnmarshalSSZ(buf []byte) error { +func (c *ExecutionPayloadGloas) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size < 540 { return ssz.ErrSize } - tail := buf - var o10, o13, o14, o17 uint64 - - // Field (0) 'ParentHash' - if cap(e.ParentHash) == 0 { - e.ParentHash = make([]byte, 0, len(buf[0:32])) - } - e.ParentHash = append(e.ParentHash, buf[0:32]...) - - // Field (1) 'FeeRecipient' - if cap(e.FeeRecipient) == 0 { - e.FeeRecipient = make([]byte, 0, len(buf[32:52])) + sszSlice0 := buf[0:32] // c.ParentHash + sszSlice1 := buf[32:52] // c.FeeRecipient + sszSlice2 := buf[52:84] // c.StateRoot + sszSlice3 := buf[84:116] // c.ReceiptsRoot + sszSlice4 := buf[116:372] // c.LogsBloom + sszSlice5 := buf[372:404] // c.PrevRandao + sszSlice6 := buf[404:412] // c.BlockNumber + sszSlice7 := buf[412:420] // c.GasLimit + sszSlice8 := buf[420:428] // c.GasUsed + sszSlice9 := buf[428:436] // c.Timestamp + sszSlice11 := buf[440:472] // c.BaseFeePerGas + sszSlice12 := buf[472:504] // c.BlockHash + sszSlice15 := buf[512:520] // c.BlobGasUsed + sszSlice16 := buf[520:528] // c.ExcessBlobGas + sszSlice18 := buf[532:540] // c.SlotNumber + + sszVarOffset10 := ssz.ReadOffset(buf[436:440]) // c.ExtraData + if sszVarOffset10 != 540 { + return ssz.ErrInvalidVariableOffset } - e.FeeRecipient = append(e.FeeRecipient, buf[32:52]...) - - // Field (2) 'StateRoot' - if cap(e.StateRoot) == 0 { - e.StateRoot = make([]byte, 0, len(buf[52:84])) + if sszVarOffset10 > size { + return ssz.ErrOffset } - e.StateRoot = append(e.StateRoot, buf[52:84]...) - - // Field (3) 'ReceiptsRoot' - if cap(e.ReceiptsRoot) == 0 { - e.ReceiptsRoot = make([]byte, 0, len(buf[84:116])) + sszVarOffset13 := ssz.ReadOffset(buf[504:508]) // c.Transactions + if sszVarOffset13 > size || sszVarOffset13 < sszVarOffset10 { + return ssz.ErrOffset } - e.ReceiptsRoot = append(e.ReceiptsRoot, buf[84:116]...) - - // Field (4) 'LogsBloom' - if cap(e.LogsBloom) == 0 { - e.LogsBloom = make([]byte, 0, len(buf[116:372])) + sszVarOffset14 := ssz.ReadOffset(buf[508:512]) // c.Withdrawals + if sszVarOffset14 > size || sszVarOffset14 < sszVarOffset13 { + return ssz.ErrOffset } - e.LogsBloom = append(e.LogsBloom, buf[116:372]...) - - // Field (5) 'PrevRandao' - if cap(e.PrevRandao) == 0 { - e.PrevRandao = make([]byte, 0, len(buf[372:404])) + sszVarOffset17 := ssz.ReadOffset(buf[528:532]) // c.BlockAccessList + if sszVarOffset17 > size || sszVarOffset17 < sszVarOffset14 { + return ssz.ErrOffset } - e.PrevRandao = append(e.PrevRandao, buf[372:404]...) - - // Field (6) 'BlockNumber' - e.BlockNumber = ssz.UnmarshallUint[uint64](buf[404:412]) + sszSlice10 := buf[sszVarOffset10:sszVarOffset13] // c.ExtraData + sszSlice13 := buf[sszVarOffset13:sszVarOffset14] // c.Transactions + sszSlice14 := buf[sszVarOffset14:sszVarOffset17] // c.Withdrawals + sszSlice17 := buf[sszVarOffset17:] // c.BlockAccessList - // Field (7) 'GasLimit' - e.GasLimit = ssz.UnmarshallUint[uint64](buf[412:420]) + // Field 0: ParentHash + c.ParentHash = make([]byte, 0, 32) + c.ParentHash = append(c.ParentHash, sszSlice0...) - // Field (8) 'GasUsed' - e.GasUsed = ssz.UnmarshallUint[uint64](buf[420:428]) + // Field 1: FeeRecipient + c.FeeRecipient = make([]byte, 0, 20) + c.FeeRecipient = append(c.FeeRecipient, sszSlice1...) - // Field (9) 'Timestamp' - e.Timestamp = ssz.UnmarshallUint[uint64](buf[428:436]) - - // Offset (10) 'ExtraData' - if o10 = ssz.ReadOffset(buf[436:440]); o10 > size { - return ssz.ErrOffset - } + // Field 2: StateRoot + c.StateRoot = make([]byte, 0, 32) + c.StateRoot = append(c.StateRoot, sszSlice2...) - if o10 != 540 { - return ssz.ErrInvalidVariableOffset - } + // Field 3: ReceiptsRoot + c.ReceiptsRoot = make([]byte, 0, 32) + c.ReceiptsRoot = append(c.ReceiptsRoot, sszSlice3...) - // Field (11) 'BaseFeePerGas' - if cap(e.BaseFeePerGas) == 0 { - e.BaseFeePerGas = make([]byte, 0, len(buf[440:472])) - } - e.BaseFeePerGas = append(e.BaseFeePerGas, buf[440:472]...) + // Field 4: LogsBloom + c.LogsBloom = make([]byte, 0, 256) + c.LogsBloom = append(c.LogsBloom, sszSlice4...) - // Field (12) 'BlockHash' - if cap(e.BlockHash) == 0 { - e.BlockHash = make([]byte, 0, len(buf[472:504])) - } - e.BlockHash = append(e.BlockHash, buf[472:504]...) + // Field 5: PrevRandao + c.PrevRandao = make([]byte, 0, 32) + c.PrevRandao = append(c.PrevRandao, sszSlice5...) - // Offset (13) 'Transactions' - if o13 = ssz.ReadOffset(buf[504:508]); o13 > size || o10 > o13 { - return ssz.ErrOffset - } + // Field 6: BlockNumber + c.BlockNumber = binary.LittleEndian.Uint64(sszSlice6) - // Offset (14) 'Withdrawals' - if o14 = ssz.ReadOffset(buf[508:512]); o14 > size || o13 > o14 { - return ssz.ErrOffset - } + // Field 7: GasLimit + c.GasLimit = binary.LittleEndian.Uint64(sszSlice7) - // Field (15) 'BlobGasUsed' - e.BlobGasUsed = ssz.UnmarshallUint[uint64](buf[512:520]) + // Field 8: GasUsed + c.GasUsed = binary.LittleEndian.Uint64(sszSlice8) - // Field (16) 'ExcessBlobGas' - e.ExcessBlobGas = ssz.UnmarshallUint[uint64](buf[520:528]) + // Field 9: Timestamp + c.Timestamp = binary.LittleEndian.Uint64(sszSlice9) - // Offset (17) 'BlockAccessList' - if o17 = ssz.ReadOffset(buf[528:532]); o17 > size || o14 > o17 { - return ssz.ErrOffset - } + // Field 10: ExtraData + c.ExtraData = append([]byte{}, sszSlice10...) - // Field (18) 'SlotNumber' - e.SlotNumber = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[532:540]) + // Field 11: BaseFeePerGas + c.BaseFeePerGas = make([]byte, 0, 32) + c.BaseFeePerGas = append(c.BaseFeePerGas, sszSlice11...) - // 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 12: BlockHash + c.BlockHash = make([]byte, 0, 32) + c.BlockHash = append(c.BlockHash, sszSlice12...) - // Field (13) 'Transactions' + // 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 + // empty lists are zero length, so make sure there is room for an offset + // before attempting to unmarshal it + if len(sszSlice13) > 3 { + startOffset := ssz.ReadOffset(sszSlice13[0:4]) + if startOffset == 0 { + return fmt.Errorf("encountered invalid offset of 0 when decoding c.Transactions") } - if cap(e.Transactions[indx]) == 0 { - e.Transactions[indx] = make([]byte, 0, len(buf)) + if startOffset%4 != 0 { + return fmt.Errorf("misaligned list bytes: when decoding c.Transactions, end-of-list offset is %d, which is not a multiple of 4 (offset size)", startOffset) } - e.Transactions[indx] = append(e.Transactions[indx], buf...) - return nil - }) - if err != nil { - return err - } - } - - // Field (14) 'Withdrawals' - { - buf = tail[o14:o17] - 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) + listLen := startOffset / 4 + if listLen > 1048576 { + return fmt.Errorf("ssz-max exceeded: c.Transactions has %d elements, ssz-max is 1048576: %w", listLen, ssz.ErrListTooBig) + } + totalVarBytes := uint64(len(sszSlice13)) + if totalVarBytes < startOffset { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.Transactions") + } + c.Transactions = make([][]byte, listLen) + var tmpSlice []byte + for i := uint64(0); i < listLen; i++ { + var tmp []byte + + endOffset := totalVarBytes + if i+1 != listLen { + endOffset = ssz.ReadOffset(sszSlice13[(i+1)*4 : (i+2)*4]) + if totalVarBytes < endOffset { + return fmt.Errorf("offset %d points past the end of buffer when decoding c.Transactions", endOffset) + } + } + if endOffset < startOffset { + return fmt.Errorf("offset %d is not greater than start offset %d when decoding c.Transactions", endOffset, startOffset) + } + tmpSlice = sszSlice13[startOffset:endOffset] + tmp = append([]byte{}, tmpSlice...) + c.Transactions[i] = tmp + startOffset = endOffset } - if err = e.Withdrawals[ii].UnmarshalSSZ(buf[ii*44 : (ii+1)*44]); err != nil { - return err + } else { + if len(sszSlice13) > 0 { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.Transactions") } + c.Transactions = make([][]byte, 0) } } - // Field (17) 'BlockAccessList' + // Field 14: Withdrawals { - buf = tail[o17:] - if len(buf) > 1073741824 { - return ssz.ErrBytesLength - } - if cap(e.BlockAccessList) == 0 { - e.BlockAccessList = make([]byte, 0, len(buf)) + if len(sszSlice14)%44 != 0 { + return fmt.Errorf("misaligned bytes: c.Withdrawals length is %d, which is not a multiple of 44: %w", len(sszSlice14), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice14) / 44 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.Withdrawals has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.Withdrawals = make([]*Withdrawal, numElem) + for i := 0; i < numElem; i++ { + var tmp *Withdrawal + tmp = new(Withdrawal) + tmpSlice := sszSlice14[i*44 : (1+i)*44] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Withdrawals: %w", err) + } + c.Withdrawals[i] = tmp } - e.BlockAccessList = append(e.BlockAccessList, buf...) } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the ExecutionPayloadGloas object -func (e *ExecutionPayloadGloas) SizeSSZ() (size int) { - size = 540 - - // 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 15: BlobGasUsed + c.BlobGasUsed = binary.LittleEndian.Uint64(sszSlice15) - // Field (14) 'Withdrawals' - size += len(e.Withdrawals) * 44 + // Field 16: ExcessBlobGas + c.ExcessBlobGas = binary.LittleEndian.Uint64(sszSlice16) - // Field (17) 'BlockAccessList' - size += len(e.BlockAccessList) + // Field 17: BlockAccessList + c.BlockAccessList = append([]byte{}, sszSlice17...) - return + // Field 18: SlotNumber + if err = c.SlotNumber.UnmarshalSSZ(sszSlice18); err != nil { + return fmt.Errorf("SlotNumber: %w", err) + } + return err } -// HashTreeRoot ssz hashes the ExecutionPayloadGloas object -func (e *ExecutionPayloadGloas) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(e) +func (c *ExecutionPayloadGloas) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the ExecutionPayloadGloas object with a hasher -func (e *ExecutionPayloadGloas) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *ExecutionPayloadGloas) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() + // Field 0: ParentHash + if len(c.ParentHash) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ParentHash) + // Field 1: FeeRecipient + if len(c.FeeRecipient) != 20 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.FeeRecipient) + // Field 2: StateRoot + if len(c.StateRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.StateRoot) + // Field 3: ReceiptsRoot + if len(c.ReceiptsRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ReceiptsRoot) + // Field 4: LogsBloom + if len(c.LogsBloom) != 256 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.LogsBloom) + // Field 5: PrevRandao + if len(c.PrevRandao) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.PrevRandao) + // Field 6: BlockNumber + hh.PutUint64(c.BlockNumber) + // Field 7: GasLimit + hh.PutUint64(c.GasLimit) + // Field 8: GasUsed + hh.PutUint64(c.GasUsed) + // Field 9: Timestamp + hh.PutUint64(c.Timestamp) + // Field 10: ExtraData - // Field (0) 'ParentHash' - if size := len(e.ParentHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentHash", size, 32) - return - } - hh.PutBytes(e.ParentHash) - - // Field (1) 'FeeRecipient' - if size := len(e.FeeRecipient); size != 20 { - err = ssz.ErrBytesLengthFn("--.FeeRecipient", size, 20) - return - } - hh.PutBytes(e.FeeRecipient) - - // Field (2) 'StateRoot' - if size := len(e.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return - } - hh.PutBytes(e.StateRoot) - - // Field (3) 'ReceiptsRoot' - if size := len(e.ReceiptsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ReceiptsRoot", size, 32) - return - } - hh.PutBytes(e.ReceiptsRoot) - - // Field (4) 'LogsBloom' - if size := len(e.LogsBloom); size != 256 { - err = ssz.ErrBytesLengthFn("--.LogsBloom", size, 256) - return - } - hh.PutBytes(e.LogsBloom) - - // Field (5) 'PrevRandao' - if size := len(e.PrevRandao); size != 32 { - err = ssz.ErrBytesLengthFn("--.PrevRandao", size, 32) - return - } - hh.PutBytes(e.PrevRandao) - - // Field (6) 'BlockNumber' - ssz.PutUint(hh, e.BlockNumber) - - // Field (7) 'GasLimit' - ssz.PutUint(hh, e.GasLimit) - - // Field (8) 'GasUsed' - ssz.PutUint(hh, e.GasUsed) - - // Field (9) 'Timestamp' - ssz.PutUint(hh, e.Timestamp) - - // Field (10) 'ExtraData' { - elemIndx := hh.Index() - byteLen := uint64(len(e.ExtraData)) - if byteLen > 32 { - err = ssz.ErrIncorrectListSize - return + if len(c.ExtraData) > 32 { + return ssz.ErrBytesLength } - hh.AppendBytes32(e.ExtraData) - hh.MerkleizeWithMixin(elemIndx, byteLen, (32+31)/32) + subIndx := hh.Index() + hh.AppendBytes32(c.ExtraData) + numItems := uint64(len(c.ExtraData)) + hh.MerkleizeWithMixin(subIndx, numItems, (32*1+31)/32) } - // Field (11) 'BaseFeePerGas' - if size := len(e.BaseFeePerGas); size != 32 { - err = ssz.ErrBytesLengthFn("--.BaseFeePerGas", size, 32) - return + // Field 11: BaseFeePerGas + if len(c.BaseFeePerGas) != 32 { + return ssz.ErrBytesLength } - hh.PutBytes(e.BaseFeePerGas) - - // Field (12) 'BlockHash' - if size := len(e.BlockHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockHash", size, 32) - return + hh.PutBytes(c.BaseFeePerGas) + // Field 12: BlockHash + if len(c.BlockHash) != 32 { + return ssz.ErrBytesLength } - hh.PutBytes(e.BlockHash) - - // Field (13) 'Transactions' + hh.PutBytes(c.BlockHash) + // Field 13: Transactions { - subIndx := hh.Index() - num := uint64(len(e.Transactions)) - if num > 1048576 { - err = ssz.ErrIncorrectListSize - return + if len(c.Transactions) > 1048576 { + return ssz.ErrListTooBig } - for _, elem := range e.Transactions { + subIndx := hh.Index() + for _, o := range c.Transactions { + { - elemIndx := hh.Index() - byteLen := uint64(len(elem)) - if byteLen > 1073741824 { - err = ssz.ErrIncorrectListSize - return + if len(o) > 1073741824 { + return ssz.ErrBytesLength } - hh.AppendBytes32(elem) - hh.MerkleizeWithMixin(elemIndx, byteLen, (1073741824+31)/32) + subIndx := hh.Index() + hh.AppendBytes32(o) + numItems := uint64(len(o)) + hh.MerkleizeWithMixin(subIndx, numItems, (1073741824*1+31)/32) } + } - hh.MerkleizeWithMixin(subIndx, num, 1048576) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Transactions)), 1048576) } - - // Field (14) 'Withdrawals' + // Field 14: Withdrawals { + if len(c.Withdrawals) > 16 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.Withdrawals { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Withdrawals: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Withdrawals)), 16) } + // Field 15: BlobGasUsed + hh.PutUint64(c.BlobGasUsed) + // Field 16: ExcessBlobGas + hh.PutUint64(c.ExcessBlobGas) + // Field 17: BlockAccessList - // Field (15) 'BlobGasUsed' - ssz.PutUint(hh, e.BlobGasUsed) - - // Field (16) 'ExcessBlobGas' - ssz.PutUint(hh, e.ExcessBlobGas) - - // Field (17) 'BlockAccessList' { - elemIndx := hh.Index() - byteLen := uint64(len(e.BlockAccessList)) - if byteLen > 1073741824 { - err = ssz.ErrIncorrectListSize - return + if len(c.BlockAccessList) > 1073741824 { + return ssz.ErrBytesLength } - hh.AppendBytes32(e.BlockAccessList) - hh.MerkleizeWithMixin(elemIndx, byteLen, (1073741824+31)/32) + subIndx := hh.Index() + hh.AppendBytes32(c.BlockAccessList) + numItems := uint64(len(c.BlockAccessList)) + hh.MerkleizeWithMixin(subIndx, numItems, (1073741824*1+31)/32) } - // Field (18) 'SlotNumber' - ssz.PutUint(hh, e.SlotNumber) - + // Field 18: SlotNumber + if err := c.SlotNumber.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SlotNumber: %w", err) + } hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the ExecutionPayloadDenebAndBlobsBundle object -func (e *ExecutionPayloadDenebAndBlobsBundle) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(e) +func (c *ExecutionPayloadDenebAndBlobsBundle) SizeSSZ() int { + size := 8 + if c.Payload == nil { + c.Payload = new(ExecutionPayloadDeneb) + } + size += c.Payload.SizeSSZ() + if c.BlobsBundle == nil { + c.BlobsBundle = new(BlobsBundle) + } + size += c.BlobsBundle.SizeSSZ() + return size } -// MarshalSSZTo ssz marshals the ExecutionPayloadDenebAndBlobsBundle object to a target array -func (e *ExecutionPayloadDenebAndBlobsBundle) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(8) +func (c *ExecutionPayloadDenebAndBlobsBundle) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Offset (0) 'Payload' - dst = ssz.WriteOffset(dst, offset) - if e.Payload == nil { - e.Payload = new(ExecutionPayloadDeneb) - } - offset += e.Payload.SizeSSZ() +func (c *ExecutionPayloadDenebAndBlobsBundle) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 8 - // Offset (1) 'BlobsBundle' - dst = ssz.WriteOffset(dst, offset) - if e.BlobsBundle == nil { - e.BlobsBundle = new(BlobsBundle) + // Field 0: Payload + if c.Payload == nil { + c.Payload = new(ExecutionPayloadDeneb) } - offset += e.BlobsBundle.SizeSSZ() + dst = ssz.WriteOffset(dst, offset) + offset += c.Payload.SizeSSZ() - // Field (0) 'Payload' - if dst, err = e.Payload.MarshalSSZTo(dst); err != nil { - return + // Field 1: BlobsBundle + if c.BlobsBundle == nil { + c.BlobsBundle = new(BlobsBundle) } + dst = ssz.WriteOffset(dst, offset) + offset += c.BlobsBundle.SizeSSZ() - // Field (1) 'BlobsBundle' - if dst, err = e.BlobsBundle.MarshalSSZTo(dst); err != nil { - return + // Field 0: Payload + if dst, err = c.Payload.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Payload: %w", err) } - return + // Field 1: BlobsBundle + if dst, err = c.BlobsBundle.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("BlobsBundle: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the ExecutionPayloadDenebAndBlobsBundle object -func (e *ExecutionPayloadDenebAndBlobsBundle) UnmarshalSSZ(buf []byte) error { +func (c *ExecutionPayloadDenebAndBlobsBundle) 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) 'Payload' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } - - if o0 != 8 { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Payload + if sszVarOffset0 != 8 { return ssz.ErrInvalidVariableOffset } - - // Offset (1) 'BlobsBundle' - if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 { + if sszVarOffset0 > size { return ssz.ErrOffset } + sszVarOffset1 := ssz.ReadOffset(buf[4:8]) // c.BlobsBundle + if sszVarOffset1 > size || sszVarOffset1 < sszVarOffset0 { + return ssz.ErrOffset + } + sszSlice0 := buf[sszVarOffset0:sszVarOffset1] // c.Payload + sszSlice1 := buf[sszVarOffset1:] // c.BlobsBundle - // Field (0) 'Payload' - { - buf = tail[o0:o1] - if e.Payload == nil { - e.Payload = new(ExecutionPayloadDeneb) - } - if err = e.Payload.UnmarshalSSZ(buf); err != nil { - return err - } + // Field 0: Payload + c.Payload = new(ExecutionPayloadDeneb) + if err = c.Payload.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Payload: %w", err) } - // Field (1) 'BlobsBundle' - { - buf = tail[o1:] - if e.BlobsBundle == nil { - e.BlobsBundle = new(BlobsBundle) - } - if err = e.BlobsBundle.UnmarshalSSZ(buf); err != nil { - return err - } + // Field 1: BlobsBundle + c.BlobsBundle = new(BlobsBundle) + if err = c.BlobsBundle.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("BlobsBundle: %w", err) } return err } -// SizeSSZ returns the ssz encoded size in bytes for the ExecutionPayloadDenebAndBlobsBundle object -func (e *ExecutionPayloadDenebAndBlobsBundle) SizeSSZ() (size int) { - size = 8 - - // Field (0) 'Payload' - if e.Payload == nil { - e.Payload = new(ExecutionPayloadDeneb) - } - size += e.Payload.SizeSSZ() - - // Field (1) 'BlobsBundle' - if e.BlobsBundle == nil { - e.BlobsBundle = new(BlobsBundle) +func (c *ExecutionPayloadDenebAndBlobsBundle) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - size += e.BlobsBundle.SizeSSZ() - - return + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRoot ssz hashes the ExecutionPayloadDenebAndBlobsBundle object -func (e *ExecutionPayloadDenebAndBlobsBundle) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(e) -} - -// HashTreeRootWith ssz hashes the ExecutionPayloadDenebAndBlobsBundle object with a hasher -func (e *ExecutionPayloadDenebAndBlobsBundle) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *ExecutionPayloadDenebAndBlobsBundle) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Payload' - if err = e.Payload.HashTreeRootWith(hh); err != nil { - return + // Field 0: Payload + if err := c.Payload.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Payload: %w", err) } - - // Field (1) 'BlobsBundle' - if err = e.BlobsBundle.HashTreeRootWith(hh); err != nil { - return + // Field 1: BlobsBundle + if err := c.BlobsBundle.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("BlobsBundle: %w", err) } - hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the ExecutionPayloadDenebAndBlobsBundleV2 object -func (e *ExecutionPayloadDenebAndBlobsBundleV2) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(e) +func (c *ExecutionPayloadDenebAndBlobsBundleV2) SizeSSZ() int { + size := 8 + if c.Payload == nil { + c.Payload = new(ExecutionPayloadDeneb) + } + size += c.Payload.SizeSSZ() + if c.BlobsBundle == nil { + c.BlobsBundle = new(BlobsBundleV2) + } + size += c.BlobsBundle.SizeSSZ() + return size } -// MarshalSSZTo ssz marshals the ExecutionPayloadDenebAndBlobsBundleV2 object to a target array -func (e *ExecutionPayloadDenebAndBlobsBundleV2) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(8) +func (c *ExecutionPayloadDenebAndBlobsBundleV2) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Offset (0) 'Payload' - dst = ssz.WriteOffset(dst, offset) - if e.Payload == nil { - e.Payload = new(ExecutionPayloadDeneb) - } - offset += e.Payload.SizeSSZ() +func (c *ExecutionPayloadDenebAndBlobsBundleV2) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 8 - // Offset (1) 'BlobsBundle' - dst = ssz.WriteOffset(dst, offset) - if e.BlobsBundle == nil { - e.BlobsBundle = new(BlobsBundleV2) + // Field 0: Payload + if c.Payload == nil { + c.Payload = new(ExecutionPayloadDeneb) } - offset += e.BlobsBundle.SizeSSZ() + dst = ssz.WriteOffset(dst, offset) + offset += c.Payload.SizeSSZ() - // Field (0) 'Payload' - if dst, err = e.Payload.MarshalSSZTo(dst); err != nil { - return + // Field 1: BlobsBundle + if c.BlobsBundle == nil { + c.BlobsBundle = new(BlobsBundleV2) } + dst = ssz.WriteOffset(dst, offset) + offset += c.BlobsBundle.SizeSSZ() - // Field (1) 'BlobsBundle' - if dst, err = e.BlobsBundle.MarshalSSZTo(dst); err != nil { - return + // Field 0: Payload + if dst, err = c.Payload.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Payload: %w", err) } - return + // Field 1: BlobsBundle + if dst, err = c.BlobsBundle.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("BlobsBundle: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the ExecutionPayloadDenebAndBlobsBundleV2 object -func (e *ExecutionPayloadDenebAndBlobsBundleV2) UnmarshalSSZ(buf []byte) error { +func (c *ExecutionPayloadDenebAndBlobsBundleV2) 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) 'Payload' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } - - if o0 != 8 { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Payload + if sszVarOffset0 != 8 { return ssz.ErrInvalidVariableOffset } - - // Offset (1) 'BlobsBundle' - if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 { + if sszVarOffset0 > size { return ssz.ErrOffset } + sszVarOffset1 := ssz.ReadOffset(buf[4:8]) // c.BlobsBundle + if sszVarOffset1 > size || sszVarOffset1 < sszVarOffset0 { + return ssz.ErrOffset + } + sszSlice0 := buf[sszVarOffset0:sszVarOffset1] // c.Payload + sszSlice1 := buf[sszVarOffset1:] // c.BlobsBundle - // Field (0) 'Payload' - { - buf = tail[o0:o1] - if e.Payload == nil { - e.Payload = new(ExecutionPayloadDeneb) - } - if err = e.Payload.UnmarshalSSZ(buf); err != nil { - return err - } + // Field 0: Payload + c.Payload = new(ExecutionPayloadDeneb) + if err = c.Payload.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Payload: %w", err) } - // Field (1) 'BlobsBundle' - { - buf = tail[o1:] - if e.BlobsBundle == nil { - e.BlobsBundle = new(BlobsBundleV2) - } - if err = e.BlobsBundle.UnmarshalSSZ(buf); err != nil { - return err - } + // Field 1: BlobsBundle + c.BlobsBundle = new(BlobsBundleV2) + if err = c.BlobsBundle.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("BlobsBundle: %w", err) } return err } -// SizeSSZ returns the ssz encoded size in bytes for the ExecutionPayloadDenebAndBlobsBundleV2 object -func (e *ExecutionPayloadDenebAndBlobsBundleV2) SizeSSZ() (size int) { - size = 8 - - // Field (0) 'Payload' - if e.Payload == nil { - e.Payload = new(ExecutionPayloadDeneb) - } - size += e.Payload.SizeSSZ() - - // Field (1) 'BlobsBundle' - if e.BlobsBundle == nil { - e.BlobsBundle = new(BlobsBundleV2) +func (c *ExecutionPayloadDenebAndBlobsBundleV2) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - size += e.BlobsBundle.SizeSSZ() - - return + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRoot ssz hashes the ExecutionPayloadDenebAndBlobsBundleV2 object -func (e *ExecutionPayloadDenebAndBlobsBundleV2) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(e) -} - -// HashTreeRootWith ssz hashes the ExecutionPayloadDenebAndBlobsBundleV2 object with a hasher -func (e *ExecutionPayloadDenebAndBlobsBundleV2) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *ExecutionPayloadDenebAndBlobsBundleV2) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Payload' - if err = e.Payload.HashTreeRootWith(hh); err != nil { - return + // Field 0: Payload + if err := c.Payload.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Payload: %w", err) } - - // Field (1) 'BlobsBundle' - if err = e.BlobsBundle.HashTreeRootWith(hh); err != nil { - return + // Field 1: BlobsBundle + if err := c.BlobsBundle.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("BlobsBundle: %w", err) } - hh.Merkleize(indx) - return + return nil +} + +func (c *ExecutionPayloadHeader) SizeSSZ() int { + size := 536 + size += len(c.ExtraData) + return size } -// MarshalSSZ ssz marshals the ExecutionPayloadHeader object -func (e *ExecutionPayloadHeader) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(e) +func (c *ExecutionPayloadHeader) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the ExecutionPayloadHeader object to a target array -func (e *ExecutionPayloadHeader) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(536) +func (c *ExecutionPayloadHeader) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 536 - // Field (0) 'ParentHash' - if size := len(e.ParentHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentHash", size, 32) - return + // Field 0: ParentHash + if len(c.ParentHash) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.ParentHash...) + dst = append(dst, c.ParentHash...) - // Field (1) 'FeeRecipient' - if size := len(e.FeeRecipient); size != 20 { - err = ssz.ErrBytesLengthFn("--.FeeRecipient", size, 20) - return + // Field 1: FeeRecipient + if len(c.FeeRecipient) != 20 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.FeeRecipient...) + dst = append(dst, c.FeeRecipient...) - // Field (2) 'StateRoot' - if size := len(e.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return + // Field 2: StateRoot + if len(c.StateRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.StateRoot...) + dst = append(dst, c.StateRoot...) - // Field (3) 'ReceiptsRoot' - if size := len(e.ReceiptsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ReceiptsRoot", size, 32) - return + // Field 3: ReceiptsRoot + if len(c.ReceiptsRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.ReceiptsRoot...) + dst = append(dst, c.ReceiptsRoot...) - // Field (4) 'LogsBloom' - if size := len(e.LogsBloom); size != 256 { - err = ssz.ErrBytesLengthFn("--.LogsBloom", size, 256) - return + // Field 4: LogsBloom + if len(c.LogsBloom) != 256 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.LogsBloom...) + dst = append(dst, c.LogsBloom...) - // Field (5) 'PrevRandao' - if size := len(e.PrevRandao); size != 32 { - err = ssz.ErrBytesLengthFn("--.PrevRandao", size, 32) - return + // Field 5: PrevRandao + if len(c.PrevRandao) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.PrevRandao...) + dst = append(dst, c.PrevRandao...) - // Field (6) 'BlockNumber' - dst = ssz.MarshalUint(dst, e.BlockNumber) + // Field 6: BlockNumber + dst = binary.LittleEndian.AppendUint64(dst, c.BlockNumber) - // Field (7) 'GasLimit' - dst = ssz.MarshalUint(dst, e.GasLimit) + // Field 7: GasLimit + dst = binary.LittleEndian.AppendUint64(dst, c.GasLimit) - // Field (8) 'GasUsed' - dst = ssz.MarshalUint(dst, e.GasUsed) + // Field 8: GasUsed + dst = binary.LittleEndian.AppendUint64(dst, c.GasUsed) - // Field (9) 'Timestamp' - dst = ssz.MarshalUint(dst, e.Timestamp) + // Field 9: Timestamp + dst = binary.LittleEndian.AppendUint64(dst, c.Timestamp) - // Offset (10) 'ExtraData' + // Field 10: ExtraData dst = ssz.WriteOffset(dst, offset) - offset += len(e.ExtraData) + offset += len(c.ExtraData) - // Field (11) 'BaseFeePerGas' - if size := len(e.BaseFeePerGas); size != 32 { - err = ssz.ErrBytesLengthFn("--.BaseFeePerGas", size, 32) - return + // Field 11: BaseFeePerGas + if len(c.BaseFeePerGas) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.BaseFeePerGas...) + dst = append(dst, c.BaseFeePerGas...) - // Field (12) 'BlockHash' - if size := len(e.BlockHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockHash", size, 32) - return + // Field 12: BlockHash + if len(c.BlockHash) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.BlockHash...) + dst = append(dst, c.BlockHash...) - // Field (13) 'TransactionsRoot' - if size := len(e.TransactionsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.TransactionsRoot", size, 32) - return + // Field 13: TransactionsRoot + if len(c.TransactionsRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.TransactionsRoot...) + dst = append(dst, c.TransactionsRoot...) - // Field (10) 'ExtraData' - if size := len(e.ExtraData); size > 32 { - err = ssz.ErrBytesLengthFn("--.ExtraData", size, 32) - return + // Field 10: ExtraData + if len(c.ExtraData) > 32 { + return nil, ssz.ErrListTooBig } - dst = append(dst, e.ExtraData...) - - return + dst = append(dst, c.ExtraData...) + return dst, err } -// UnmarshalSSZ ssz unmarshals the ExecutionPayloadHeader object -func (e *ExecutionPayloadHeader) UnmarshalSSZ(buf []byte) error { +func (c *ExecutionPayloadHeader) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size < 536 { return ssz.ErrSize } - tail := buf - var o10 uint64 - - // Field (0) 'ParentHash' - if cap(e.ParentHash) == 0 { - e.ParentHash = make([]byte, 0, len(buf[0:32])) + sszSlice0 := buf[0:32] // c.ParentHash + sszSlice1 := buf[32:52] // c.FeeRecipient + sszSlice2 := buf[52:84] // c.StateRoot + sszSlice3 := buf[84:116] // c.ReceiptsRoot + sszSlice4 := buf[116:372] // c.LogsBloom + sszSlice5 := buf[372:404] // c.PrevRandao + sszSlice6 := buf[404:412] // c.BlockNumber + sszSlice7 := buf[412:420] // c.GasLimit + sszSlice8 := buf[420:428] // c.GasUsed + sszSlice9 := buf[428:436] // c.Timestamp + sszSlice11 := buf[440:472] // c.BaseFeePerGas + sszSlice12 := buf[472:504] // c.BlockHash + sszSlice13 := buf[504:536] // c.TransactionsRoot + + sszVarOffset10 := ssz.ReadOffset(buf[436:440]) // c.ExtraData + if sszVarOffset10 != 536 { + return ssz.ErrInvalidVariableOffset } - e.ParentHash = append(e.ParentHash, buf[0:32]...) - - // Field (1) 'FeeRecipient' - if cap(e.FeeRecipient) == 0 { - e.FeeRecipient = make([]byte, 0, len(buf[32:52])) + if sszVarOffset10 > size { + return ssz.ErrOffset } - e.FeeRecipient = append(e.FeeRecipient, buf[32:52]...) + sszSlice10 := buf[sszVarOffset10:] // c.ExtraData - // Field (2) 'StateRoot' - if cap(e.StateRoot) == 0 { - e.StateRoot = make([]byte, 0, len(buf[52:84])) - } - e.StateRoot = append(e.StateRoot, buf[52:84]...) + // Field 0: ParentHash + c.ParentHash = make([]byte, 0, 32) + c.ParentHash = append(c.ParentHash, sszSlice0...) - // Field (3) 'ReceiptsRoot' - if cap(e.ReceiptsRoot) == 0 { - e.ReceiptsRoot = make([]byte, 0, len(buf[84:116])) - } - e.ReceiptsRoot = append(e.ReceiptsRoot, buf[84:116]...) + // Field 1: FeeRecipient + c.FeeRecipient = make([]byte, 0, 20) + c.FeeRecipient = append(c.FeeRecipient, sszSlice1...) - // Field (4) 'LogsBloom' - if cap(e.LogsBloom) == 0 { - e.LogsBloom = make([]byte, 0, len(buf[116:372])) - } - e.LogsBloom = append(e.LogsBloom, buf[116:372]...) + // Field 2: StateRoot + c.StateRoot = make([]byte, 0, 32) + c.StateRoot = append(c.StateRoot, sszSlice2...) - // Field (5) 'PrevRandao' - if cap(e.PrevRandao) == 0 { - e.PrevRandao = make([]byte, 0, len(buf[372:404])) - } - e.PrevRandao = append(e.PrevRandao, buf[372:404]...) + // Field 3: ReceiptsRoot + c.ReceiptsRoot = make([]byte, 0, 32) + c.ReceiptsRoot = append(c.ReceiptsRoot, sszSlice3...) - // Field (6) 'BlockNumber' - e.BlockNumber = ssz.UnmarshallUint[uint64](buf[404:412]) + // Field 4: LogsBloom + c.LogsBloom = make([]byte, 0, 256) + c.LogsBloom = append(c.LogsBloom, sszSlice4...) - // Field (7) 'GasLimit' - e.GasLimit = ssz.UnmarshallUint[uint64](buf[412:420]) + // Field 5: PrevRandao + c.PrevRandao = make([]byte, 0, 32) + c.PrevRandao = append(c.PrevRandao, sszSlice5...) - // Field (8) 'GasUsed' - e.GasUsed = ssz.UnmarshallUint[uint64](buf[420:428]) + // Field 6: BlockNumber + c.BlockNumber = binary.LittleEndian.Uint64(sszSlice6) - // Field (9) 'Timestamp' - e.Timestamp = ssz.UnmarshallUint[uint64](buf[428:436]) + // Field 7: GasLimit + c.GasLimit = binary.LittleEndian.Uint64(sszSlice7) - // Offset (10) 'ExtraData' - if o10 = ssz.ReadOffset(buf[436:440]); o10 > size { - return ssz.ErrOffset - } + // Field 8: GasUsed + c.GasUsed = binary.LittleEndian.Uint64(sszSlice8) - if o10 != 536 { - return ssz.ErrInvalidVariableOffset - } + // Field 9: Timestamp + c.Timestamp = binary.LittleEndian.Uint64(sszSlice9) - // Field (11) 'BaseFeePerGas' - if cap(e.BaseFeePerGas) == 0 { - e.BaseFeePerGas = make([]byte, 0, len(buf[440:472])) - } - e.BaseFeePerGas = append(e.BaseFeePerGas, buf[440:472]...) + // Field 10: ExtraData + c.ExtraData = append([]byte{}, sszSlice10...) - // Field (12) 'BlockHash' - if cap(e.BlockHash) == 0 { - e.BlockHash = make([]byte, 0, len(buf[472:504])) - } - e.BlockHash = append(e.BlockHash, buf[472:504]...) + // Field 11: BaseFeePerGas + c.BaseFeePerGas = make([]byte, 0, 32) + c.BaseFeePerGas = append(c.BaseFeePerGas, sszSlice11...) - // Field (13) 'TransactionsRoot' - if cap(e.TransactionsRoot) == 0 { - e.TransactionsRoot = make([]byte, 0, len(buf[504:536])) - } - e.TransactionsRoot = append(e.TransactionsRoot, buf[504:536]...) + // Field 12: BlockHash + c.BlockHash = make([]byte, 0, 32) + c.BlockHash = append(c.BlockHash, sszSlice12...) - // 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...) - } + // Field 13: TransactionsRoot + c.TransactionsRoot = make([]byte, 0, 32) + c.TransactionsRoot = append(c.TransactionsRoot, sszSlice13...) return err } -// SizeSSZ returns the ssz encoded size in bytes for the ExecutionPayloadHeader object -func (e *ExecutionPayloadHeader) SizeSSZ() (size int) { - size = 536 - - // 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) +func (c *ExecutionPayloadHeader) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the ExecutionPayloadHeader object with a hasher -func (e *ExecutionPayloadHeader) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *ExecutionPayloadHeader) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() + // Field 0: ParentHash + if len(c.ParentHash) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ParentHash) + // Field 1: FeeRecipient + if len(c.FeeRecipient) != 20 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.FeeRecipient) + // Field 2: StateRoot + if len(c.StateRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.StateRoot) + // Field 3: ReceiptsRoot + if len(c.ReceiptsRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ReceiptsRoot) + // Field 4: LogsBloom + if len(c.LogsBloom) != 256 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.LogsBloom) + // Field 5: PrevRandao + if len(c.PrevRandao) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.PrevRandao) + // Field 6: BlockNumber + hh.PutUint64(c.BlockNumber) + // Field 7: GasLimit + hh.PutUint64(c.GasLimit) + // Field 8: GasUsed + hh.PutUint64(c.GasUsed) + // Field 9: Timestamp + hh.PutUint64(c.Timestamp) + // Field 10: ExtraData - // Field (0) 'ParentHash' - if size := len(e.ParentHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentHash", size, 32) - return - } - hh.PutBytes(e.ParentHash) - - // Field (1) 'FeeRecipient' - if size := len(e.FeeRecipient); size != 20 { - err = ssz.ErrBytesLengthFn("--.FeeRecipient", size, 20) - return - } - hh.PutBytes(e.FeeRecipient) - - // Field (2) 'StateRoot' - if size := len(e.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return - } - hh.PutBytes(e.StateRoot) - - // Field (3) 'ReceiptsRoot' - if size := len(e.ReceiptsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ReceiptsRoot", size, 32) - return - } - hh.PutBytes(e.ReceiptsRoot) - - // Field (4) 'LogsBloom' - if size := len(e.LogsBloom); size != 256 { - err = ssz.ErrBytesLengthFn("--.LogsBloom", size, 256) - return - } - hh.PutBytes(e.LogsBloom) - - // Field (5) 'PrevRandao' - if size := len(e.PrevRandao); size != 32 { - err = ssz.ErrBytesLengthFn("--.PrevRandao", size, 32) - return - } - hh.PutBytes(e.PrevRandao) - - // Field (6) 'BlockNumber' - ssz.PutUint(hh, e.BlockNumber) - - // Field (7) 'GasLimit' - ssz.PutUint(hh, e.GasLimit) - - // Field (8) 'GasUsed' - ssz.PutUint(hh, e.GasUsed) - - // Field (9) 'Timestamp' - ssz.PutUint(hh, e.Timestamp) - - // Field (10) 'ExtraData' { - elemIndx := hh.Index() - byteLen := uint64(len(e.ExtraData)) - if byteLen > 32 { - err = ssz.ErrIncorrectListSize - return + if len(c.ExtraData) > 32 { + return ssz.ErrBytesLength } - hh.AppendBytes32(e.ExtraData) - hh.MerkleizeWithMixin(elemIndx, byteLen, (32+31)/32) + subIndx := hh.Index() + hh.AppendBytes32(c.ExtraData) + numItems := uint64(len(c.ExtraData)) + hh.MerkleizeWithMixin(subIndx, numItems, (32*1+31)/32) } - // Field (11) 'BaseFeePerGas' - if size := len(e.BaseFeePerGas); size != 32 { - err = ssz.ErrBytesLengthFn("--.BaseFeePerGas", size, 32) - return + // Field 11: BaseFeePerGas + if len(c.BaseFeePerGas) != 32 { + return ssz.ErrBytesLength } - hh.PutBytes(e.BaseFeePerGas) - - // Field (12) 'BlockHash' - if size := len(e.BlockHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockHash", size, 32) - return + hh.PutBytes(c.BaseFeePerGas) + // Field 12: BlockHash + if len(c.BlockHash) != 32 { + return ssz.ErrBytesLength } - hh.PutBytes(e.BlockHash) - - // Field (13) 'TransactionsRoot' - if size := len(e.TransactionsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.TransactionsRoot", size, 32) - return + hh.PutBytes(c.BlockHash) + // Field 13: TransactionsRoot + if len(c.TransactionsRoot) != 32 { + return ssz.ErrBytesLength } - hh.PutBytes(e.TransactionsRoot) - + hh.PutBytes(c.TransactionsRoot) hh.Merkleize(indx) - return + return nil +} + +func (c *ExecutionPayloadHeaderCapella) SizeSSZ() int { + size := 568 + size += len(c.ExtraData) + return size } -// MarshalSSZ ssz marshals the ExecutionPayloadHeaderCapella object -func (e *ExecutionPayloadHeaderCapella) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(e) +func (c *ExecutionPayloadHeaderCapella) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the ExecutionPayloadHeaderCapella object to a target array -func (e *ExecutionPayloadHeaderCapella) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(568) +func (c *ExecutionPayloadHeaderCapella) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 568 - // Field (0) 'ParentHash' - if size := len(e.ParentHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentHash", size, 32) - return + // Field 0: ParentHash + if len(c.ParentHash) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.ParentHash...) + dst = append(dst, c.ParentHash...) - // Field (1) 'FeeRecipient' - if size := len(e.FeeRecipient); size != 20 { - err = ssz.ErrBytesLengthFn("--.FeeRecipient", size, 20) - return + // Field 1: FeeRecipient + if len(c.FeeRecipient) != 20 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.FeeRecipient...) + dst = append(dst, c.FeeRecipient...) - // Field (2) 'StateRoot' - if size := len(e.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return + // Field 2: StateRoot + if len(c.StateRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.StateRoot...) + dst = append(dst, c.StateRoot...) - // Field (3) 'ReceiptsRoot' - if size := len(e.ReceiptsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ReceiptsRoot", size, 32) - return + // Field 3: ReceiptsRoot + if len(c.ReceiptsRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.ReceiptsRoot...) + dst = append(dst, c.ReceiptsRoot...) - // Field (4) 'LogsBloom' - if size := len(e.LogsBloom); size != 256 { - err = ssz.ErrBytesLengthFn("--.LogsBloom", size, 256) - return + // Field 4: LogsBloom + if len(c.LogsBloom) != 256 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.LogsBloom...) + dst = append(dst, c.LogsBloom...) - // Field (5) 'PrevRandao' - if size := len(e.PrevRandao); size != 32 { - err = ssz.ErrBytesLengthFn("--.PrevRandao", size, 32) - return + // Field 5: PrevRandao + if len(c.PrevRandao) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.PrevRandao...) + dst = append(dst, c.PrevRandao...) - // Field (6) 'BlockNumber' - dst = ssz.MarshalUint(dst, e.BlockNumber) + // Field 6: BlockNumber + dst = binary.LittleEndian.AppendUint64(dst, c.BlockNumber) - // Field (7) 'GasLimit' - dst = ssz.MarshalUint(dst, e.GasLimit) + // Field 7: GasLimit + dst = binary.LittleEndian.AppendUint64(dst, c.GasLimit) - // Field (8) 'GasUsed' - dst = ssz.MarshalUint(dst, e.GasUsed) + // Field 8: GasUsed + dst = binary.LittleEndian.AppendUint64(dst, c.GasUsed) - // Field (9) 'Timestamp' - dst = ssz.MarshalUint(dst, e.Timestamp) + // Field 9: Timestamp + dst = binary.LittleEndian.AppendUint64(dst, c.Timestamp) - // Offset (10) 'ExtraData' + // Field 10: ExtraData dst = ssz.WriteOffset(dst, offset) - offset += len(e.ExtraData) + offset += len(c.ExtraData) - // Field (11) 'BaseFeePerGas' - if size := len(e.BaseFeePerGas); size != 32 { - err = ssz.ErrBytesLengthFn("--.BaseFeePerGas", size, 32) - return + // Field 11: BaseFeePerGas + if len(c.BaseFeePerGas) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.BaseFeePerGas...) + dst = append(dst, c.BaseFeePerGas...) - // Field (12) 'BlockHash' - if size := len(e.BlockHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockHash", size, 32) - return + // Field 12: BlockHash + if len(c.BlockHash) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.BlockHash...) + dst = append(dst, c.BlockHash...) - // Field (13) 'TransactionsRoot' - if size := len(e.TransactionsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.TransactionsRoot", size, 32) - return + // Field 13: TransactionsRoot + if len(c.TransactionsRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.TransactionsRoot...) + dst = append(dst, c.TransactionsRoot...) - // Field (14) 'WithdrawalsRoot' - if size := len(e.WithdrawalsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.WithdrawalsRoot", size, 32) - return + // Field 14: WithdrawalsRoot + if len(c.WithdrawalsRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.WithdrawalsRoot...) + dst = append(dst, c.WithdrawalsRoot...) - // Field (10) 'ExtraData' - if size := len(e.ExtraData); size > 32 { - err = ssz.ErrBytesLengthFn("--.ExtraData", size, 32) - return + // Field 10: ExtraData + if len(c.ExtraData) > 32 { + return nil, ssz.ErrListTooBig } - dst = append(dst, e.ExtraData...) - - return + dst = append(dst, c.ExtraData...) + return dst, err } -// UnmarshalSSZ ssz unmarshals the ExecutionPayloadHeaderCapella object -func (e *ExecutionPayloadHeaderCapella) UnmarshalSSZ(buf []byte) error { +func (c *ExecutionPayloadHeaderCapella) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size < 568 { return ssz.ErrSize } - tail := buf - var o10 uint64 - - // Field (0) 'ParentHash' - if cap(e.ParentHash) == 0 { - e.ParentHash = make([]byte, 0, len(buf[0:32])) + sszSlice0 := buf[0:32] // c.ParentHash + sszSlice1 := buf[32:52] // c.FeeRecipient + sszSlice2 := buf[52:84] // c.StateRoot + sszSlice3 := buf[84:116] // c.ReceiptsRoot + sszSlice4 := buf[116:372] // c.LogsBloom + sszSlice5 := buf[372:404] // c.PrevRandao + sszSlice6 := buf[404:412] // c.BlockNumber + sszSlice7 := buf[412:420] // c.GasLimit + sszSlice8 := buf[420:428] // c.GasUsed + sszSlice9 := buf[428:436] // c.Timestamp + sszSlice11 := buf[440:472] // c.BaseFeePerGas + sszSlice12 := buf[472:504] // c.BlockHash + sszSlice13 := buf[504:536] // c.TransactionsRoot + sszSlice14 := buf[536:568] // c.WithdrawalsRoot + + sszVarOffset10 := ssz.ReadOffset(buf[436:440]) // c.ExtraData + if sszVarOffset10 != 568 { + return ssz.ErrInvalidVariableOffset } - e.ParentHash = append(e.ParentHash, buf[0:32]...) - - // Field (1) 'FeeRecipient' - if cap(e.FeeRecipient) == 0 { - e.FeeRecipient = make([]byte, 0, len(buf[32:52])) + if sszVarOffset10 > size { + return ssz.ErrOffset } - e.FeeRecipient = append(e.FeeRecipient, buf[32:52]...) + sszSlice10 := buf[sszVarOffset10:] // c.ExtraData - // Field (2) 'StateRoot' - if cap(e.StateRoot) == 0 { - e.StateRoot = make([]byte, 0, len(buf[52:84])) - } - e.StateRoot = append(e.StateRoot, buf[52:84]...) + // Field 0: ParentHash + c.ParentHash = make([]byte, 0, 32) + c.ParentHash = append(c.ParentHash, sszSlice0...) - // Field (3) 'ReceiptsRoot' - if cap(e.ReceiptsRoot) == 0 { - e.ReceiptsRoot = make([]byte, 0, len(buf[84:116])) - } - e.ReceiptsRoot = append(e.ReceiptsRoot, buf[84:116]...) + // Field 1: FeeRecipient + c.FeeRecipient = make([]byte, 0, 20) + c.FeeRecipient = append(c.FeeRecipient, sszSlice1...) - // Field (4) 'LogsBloom' - if cap(e.LogsBloom) == 0 { - e.LogsBloom = make([]byte, 0, len(buf[116:372])) - } - e.LogsBloom = append(e.LogsBloom, buf[116:372]...) + // Field 2: StateRoot + c.StateRoot = make([]byte, 0, 32) + c.StateRoot = append(c.StateRoot, sszSlice2...) - // Field (5) 'PrevRandao' - if cap(e.PrevRandao) == 0 { - e.PrevRandao = make([]byte, 0, len(buf[372:404])) - } - e.PrevRandao = append(e.PrevRandao, buf[372:404]...) + // Field 3: ReceiptsRoot + c.ReceiptsRoot = make([]byte, 0, 32) + c.ReceiptsRoot = append(c.ReceiptsRoot, sszSlice3...) - // Field (6) 'BlockNumber' - e.BlockNumber = ssz.UnmarshallUint[uint64](buf[404:412]) + // Field 4: LogsBloom + c.LogsBloom = make([]byte, 0, 256) + c.LogsBloom = append(c.LogsBloom, sszSlice4...) - // Field (7) 'GasLimit' - e.GasLimit = ssz.UnmarshallUint[uint64](buf[412:420]) + // Field 5: PrevRandao + c.PrevRandao = make([]byte, 0, 32) + c.PrevRandao = append(c.PrevRandao, sszSlice5...) - // Field (8) 'GasUsed' - e.GasUsed = ssz.UnmarshallUint[uint64](buf[420:428]) + // Field 6: BlockNumber + c.BlockNumber = binary.LittleEndian.Uint64(sszSlice6) - // Field (9) 'Timestamp' - e.Timestamp = ssz.UnmarshallUint[uint64](buf[428:436]) + // Field 7: GasLimit + c.GasLimit = binary.LittleEndian.Uint64(sszSlice7) - // Offset (10) 'ExtraData' - if o10 = ssz.ReadOffset(buf[436:440]); o10 > size { - return ssz.ErrOffset - } + // Field 8: GasUsed + c.GasUsed = binary.LittleEndian.Uint64(sszSlice8) - if o10 != 568 { - return ssz.ErrInvalidVariableOffset - } + // Field 9: Timestamp + c.Timestamp = binary.LittleEndian.Uint64(sszSlice9) - // Field (11) 'BaseFeePerGas' - if cap(e.BaseFeePerGas) == 0 { - e.BaseFeePerGas = make([]byte, 0, len(buf[440:472])) - } - e.BaseFeePerGas = append(e.BaseFeePerGas, buf[440:472]...) + // Field 10: ExtraData + c.ExtraData = append([]byte{}, sszSlice10...) - // Field (12) 'BlockHash' - if cap(e.BlockHash) == 0 { - e.BlockHash = make([]byte, 0, len(buf[472:504])) - } - e.BlockHash = append(e.BlockHash, buf[472:504]...) + // Field 11: BaseFeePerGas + c.BaseFeePerGas = make([]byte, 0, 32) + c.BaseFeePerGas = append(c.BaseFeePerGas, sszSlice11...) - // Field (13) 'TransactionsRoot' - if cap(e.TransactionsRoot) == 0 { - e.TransactionsRoot = make([]byte, 0, len(buf[504:536])) - } - e.TransactionsRoot = append(e.TransactionsRoot, buf[504:536]...) + // Field 12: BlockHash + c.BlockHash = make([]byte, 0, 32) + c.BlockHash = append(c.BlockHash, sszSlice12...) - // Field (14) 'WithdrawalsRoot' - if cap(e.WithdrawalsRoot) == 0 { - e.WithdrawalsRoot = make([]byte, 0, len(buf[536:568])) - } - e.WithdrawalsRoot = append(e.WithdrawalsRoot, buf[536:568]...) + // Field 13: TransactionsRoot + c.TransactionsRoot = make([]byte, 0, 32) + c.TransactionsRoot = append(c.TransactionsRoot, sszSlice13...) - // 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...) - } + // Field 14: WithdrawalsRoot + c.WithdrawalsRoot = make([]byte, 0, 32) + c.WithdrawalsRoot = append(c.WithdrawalsRoot, sszSlice14...) return err } -// SizeSSZ returns the ssz encoded size in bytes for the ExecutionPayloadHeaderCapella object -func (e *ExecutionPayloadHeaderCapella) SizeSSZ() (size int) { - size = 568 - - // Field (10) 'ExtraData' - size += len(e.ExtraData) - - return -} - -// HashTreeRoot ssz hashes the ExecutionPayloadHeaderCapella object -func (e *ExecutionPayloadHeaderCapella) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(e) +func (c *ExecutionPayloadHeaderCapella) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the ExecutionPayloadHeaderCapella object with a hasher -func (e *ExecutionPayloadHeaderCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *ExecutionPayloadHeaderCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() + // Field 0: ParentHash + if len(c.ParentHash) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ParentHash) + // Field 1: FeeRecipient + if len(c.FeeRecipient) != 20 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.FeeRecipient) + // Field 2: StateRoot + if len(c.StateRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.StateRoot) + // Field 3: ReceiptsRoot + if len(c.ReceiptsRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ReceiptsRoot) + // Field 4: LogsBloom + if len(c.LogsBloom) != 256 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.LogsBloom) + // Field 5: PrevRandao + if len(c.PrevRandao) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.PrevRandao) + // Field 6: BlockNumber + hh.PutUint64(c.BlockNumber) + // Field 7: GasLimit + hh.PutUint64(c.GasLimit) + // Field 8: GasUsed + hh.PutUint64(c.GasUsed) + // Field 9: Timestamp + hh.PutUint64(c.Timestamp) + // Field 10: ExtraData - // Field (0) 'ParentHash' - if size := len(e.ParentHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentHash", size, 32) - return - } - hh.PutBytes(e.ParentHash) - - // Field (1) 'FeeRecipient' - if size := len(e.FeeRecipient); size != 20 { - err = ssz.ErrBytesLengthFn("--.FeeRecipient", size, 20) - return - } - hh.PutBytes(e.FeeRecipient) - - // Field (2) 'StateRoot' - if size := len(e.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return - } - hh.PutBytes(e.StateRoot) - - // Field (3) 'ReceiptsRoot' - if size := len(e.ReceiptsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ReceiptsRoot", size, 32) - return - } - hh.PutBytes(e.ReceiptsRoot) - - // Field (4) 'LogsBloom' - if size := len(e.LogsBloom); size != 256 { - err = ssz.ErrBytesLengthFn("--.LogsBloom", size, 256) - return - } - hh.PutBytes(e.LogsBloom) - - // Field (5) 'PrevRandao' - if size := len(e.PrevRandao); size != 32 { - err = ssz.ErrBytesLengthFn("--.PrevRandao", size, 32) - return - } - hh.PutBytes(e.PrevRandao) - - // Field (6) 'BlockNumber' - ssz.PutUint(hh, e.BlockNumber) - - // Field (7) 'GasLimit' - ssz.PutUint(hh, e.GasLimit) - - // Field (8) 'GasUsed' - ssz.PutUint(hh, e.GasUsed) - - // Field (9) 'Timestamp' - ssz.PutUint(hh, e.Timestamp) - - // Field (10) 'ExtraData' { - elemIndx := hh.Index() - byteLen := uint64(len(e.ExtraData)) - if byteLen > 32 { - err = ssz.ErrIncorrectListSize - return + if len(c.ExtraData) > 32 { + return ssz.ErrBytesLength } - hh.AppendBytes32(e.ExtraData) - hh.MerkleizeWithMixin(elemIndx, byteLen, (32+31)/32) + subIndx := hh.Index() + hh.AppendBytes32(c.ExtraData) + numItems := uint64(len(c.ExtraData)) + hh.MerkleizeWithMixin(subIndx, numItems, (32*1+31)/32) } - // Field (11) 'BaseFeePerGas' - if size := len(e.BaseFeePerGas); size != 32 { - err = ssz.ErrBytesLengthFn("--.BaseFeePerGas", size, 32) - return + // Field 11: BaseFeePerGas + if len(c.BaseFeePerGas) != 32 { + return ssz.ErrBytesLength } - hh.PutBytes(e.BaseFeePerGas) - - // Field (12) 'BlockHash' - if size := len(e.BlockHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockHash", size, 32) - return + hh.PutBytes(c.BaseFeePerGas) + // Field 12: BlockHash + if len(c.BlockHash) != 32 { + return ssz.ErrBytesLength } - hh.PutBytes(e.BlockHash) - - // Field (13) 'TransactionsRoot' - if size := len(e.TransactionsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.TransactionsRoot", size, 32) - return + hh.PutBytes(c.BlockHash) + // Field 13: TransactionsRoot + if len(c.TransactionsRoot) != 32 { + return ssz.ErrBytesLength } - hh.PutBytes(e.TransactionsRoot) - - // Field (14) 'WithdrawalsRoot' - if size := len(e.WithdrawalsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.WithdrawalsRoot", size, 32) - return + hh.PutBytes(c.TransactionsRoot) + // Field 14: WithdrawalsRoot + if len(c.WithdrawalsRoot) != 32 { + return ssz.ErrBytesLength } - hh.PutBytes(e.WithdrawalsRoot) - + hh.PutBytes(c.WithdrawalsRoot) hh.Merkleize(indx) - return + return nil +} + +func (c *ExecutionPayloadHeaderDeneb) SizeSSZ() int { + size := 584 + size += len(c.ExtraData) + return size } -// MarshalSSZ ssz marshals the ExecutionPayloadHeaderDeneb object -func (e *ExecutionPayloadHeaderDeneb) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(e) +func (c *ExecutionPayloadHeaderDeneb) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the ExecutionPayloadHeaderDeneb object to a target array -func (e *ExecutionPayloadHeaderDeneb) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(584) +func (c *ExecutionPayloadHeaderDeneb) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 584 - // Field (0) 'ParentHash' - if size := len(e.ParentHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentHash", size, 32) - return + // Field 0: ParentHash + if len(c.ParentHash) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.ParentHash...) + dst = append(dst, c.ParentHash...) - // Field (1) 'FeeRecipient' - if size := len(e.FeeRecipient); size != 20 { - err = ssz.ErrBytesLengthFn("--.FeeRecipient", size, 20) - return + // Field 1: FeeRecipient + if len(c.FeeRecipient) != 20 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.FeeRecipient...) + dst = append(dst, c.FeeRecipient...) - // Field (2) 'StateRoot' - if size := len(e.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return + // Field 2: StateRoot + if len(c.StateRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.StateRoot...) + dst = append(dst, c.StateRoot...) - // Field (3) 'ReceiptsRoot' - if size := len(e.ReceiptsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ReceiptsRoot", size, 32) - return + // Field 3: ReceiptsRoot + if len(c.ReceiptsRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.ReceiptsRoot...) + dst = append(dst, c.ReceiptsRoot...) - // Field (4) 'LogsBloom' - if size := len(e.LogsBloom); size != 256 { - err = ssz.ErrBytesLengthFn("--.LogsBloom", size, 256) - return + // Field 4: LogsBloom + if len(c.LogsBloom) != 256 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.LogsBloom...) + dst = append(dst, c.LogsBloom...) - // Field (5) 'PrevRandao' - if size := len(e.PrevRandao); size != 32 { - err = ssz.ErrBytesLengthFn("--.PrevRandao", size, 32) - return + // Field 5: PrevRandao + if len(c.PrevRandao) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.PrevRandao...) + dst = append(dst, c.PrevRandao...) - // Field (6) 'BlockNumber' - dst = ssz.MarshalUint(dst, e.BlockNumber) + // Field 6: BlockNumber + dst = binary.LittleEndian.AppendUint64(dst, c.BlockNumber) - // Field (7) 'GasLimit' - dst = ssz.MarshalUint(dst, e.GasLimit) + // Field 7: GasLimit + dst = binary.LittleEndian.AppendUint64(dst, c.GasLimit) - // Field (8) 'GasUsed' - dst = ssz.MarshalUint(dst, e.GasUsed) + // Field 8: GasUsed + dst = binary.LittleEndian.AppendUint64(dst, c.GasUsed) - // Field (9) 'Timestamp' - dst = ssz.MarshalUint(dst, e.Timestamp) + // Field 9: Timestamp + dst = binary.LittleEndian.AppendUint64(dst, c.Timestamp) - // Offset (10) 'ExtraData' + // Field 10: ExtraData dst = ssz.WriteOffset(dst, offset) - offset += len(e.ExtraData) + offset += len(c.ExtraData) - // Field (11) 'BaseFeePerGas' - if size := len(e.BaseFeePerGas); size != 32 { - err = ssz.ErrBytesLengthFn("--.BaseFeePerGas", size, 32) - return + // Field 11: BaseFeePerGas + if len(c.BaseFeePerGas) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.BaseFeePerGas...) + dst = append(dst, c.BaseFeePerGas...) - // Field (12) 'BlockHash' - if size := len(e.BlockHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockHash", size, 32) - return + // Field 12: BlockHash + if len(c.BlockHash) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.BlockHash...) + dst = append(dst, c.BlockHash...) - // Field (13) 'TransactionsRoot' - if size := len(e.TransactionsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.TransactionsRoot", size, 32) - return + // Field 13: TransactionsRoot + if len(c.TransactionsRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.TransactionsRoot...) + dst = append(dst, c.TransactionsRoot...) - // Field (14) 'WithdrawalsRoot' - if size := len(e.WithdrawalsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.WithdrawalsRoot", size, 32) - return + // Field 14: WithdrawalsRoot + if len(c.WithdrawalsRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.WithdrawalsRoot...) + dst = append(dst, c.WithdrawalsRoot...) - // Field (15) 'BlobGasUsed' - dst = ssz.MarshalUint(dst, e.BlobGasUsed) + // Field 15: BlobGasUsed + dst = binary.LittleEndian.AppendUint64(dst, c.BlobGasUsed) - // Field (16) 'ExcessBlobGas' - dst = ssz.MarshalUint(dst, e.ExcessBlobGas) + // Field 16: ExcessBlobGas + dst = binary.LittleEndian.AppendUint64(dst, c.ExcessBlobGas) - // Field (10) 'ExtraData' - if size := len(e.ExtraData); size > 32 { - err = ssz.ErrBytesLengthFn("--.ExtraData", size, 32) - return + // Field 10: ExtraData + if len(c.ExtraData) > 32 { + return nil, ssz.ErrListTooBig } - dst = append(dst, e.ExtraData...) - - return + dst = append(dst, c.ExtraData...) + return dst, err } -// UnmarshalSSZ ssz unmarshals the ExecutionPayloadHeaderDeneb object -func (e *ExecutionPayloadHeaderDeneb) UnmarshalSSZ(buf []byte) error { +func (c *ExecutionPayloadHeaderDeneb) 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' - if cap(e.ParentHash) == 0 { - e.ParentHash = make([]byte, 0, len(buf[0:32])) - } - e.ParentHash = append(e.ParentHash, buf[0:32]...) - - // Field (1) 'FeeRecipient' - if cap(e.FeeRecipient) == 0 { - e.FeeRecipient = make([]byte, 0, len(buf[32:52])) - } - e.FeeRecipient = append(e.FeeRecipient, buf[32:52]...) - - // Field (2) 'StateRoot' - if cap(e.StateRoot) == 0 { - e.StateRoot = make([]byte, 0, len(buf[52:84])) - } - e.StateRoot = append(e.StateRoot, buf[52:84]...) - - // Field (3) 'ReceiptsRoot' - if cap(e.ReceiptsRoot) == 0 { - e.ReceiptsRoot = make([]byte, 0, len(buf[84:116])) - } - e.ReceiptsRoot = append(e.ReceiptsRoot, buf[84:116]...) - - // Field (4) 'LogsBloom' - if cap(e.LogsBloom) == 0 { - e.LogsBloom = make([]byte, 0, len(buf[116:372])) - } - e.LogsBloom = append(e.LogsBloom, buf[116:372]...) - - // Field (5) 'PrevRandao' - if cap(e.PrevRandao) == 0 { - e.PrevRandao = make([]byte, 0, len(buf[372:404])) - } - e.PrevRandao = append(e.PrevRandao, buf[372:404]...) - - // Field (6) 'BlockNumber' - e.BlockNumber = ssz.UnmarshallUint[uint64](buf[404:412]) - - // Field (7) 'GasLimit' - e.GasLimit = ssz.UnmarshallUint[uint64](buf[412:420]) - - // Field (8) 'GasUsed' - e.GasUsed = ssz.UnmarshallUint[uint64](buf[420:428]) - - // Field (9) 'Timestamp' - e.Timestamp = ssz.UnmarshallUint[uint64](buf[428:436]) - - // Offset (10) 'ExtraData' - if o10 = ssz.ReadOffset(buf[436:440]); o10 > size { - return ssz.ErrOffset - } - - if o10 != 584 { + sszSlice0 := buf[0:32] // c.ParentHash + sszSlice1 := buf[32:52] // c.FeeRecipient + sszSlice2 := buf[52:84] // c.StateRoot + sszSlice3 := buf[84:116] // c.ReceiptsRoot + sszSlice4 := buf[116:372] // c.LogsBloom + sszSlice5 := buf[372:404] // c.PrevRandao + sszSlice6 := buf[404:412] // c.BlockNumber + sszSlice7 := buf[412:420] // c.GasLimit + sszSlice8 := buf[420:428] // c.GasUsed + sszSlice9 := buf[428:436] // c.Timestamp + sszSlice11 := buf[440:472] // c.BaseFeePerGas + sszSlice12 := buf[472:504] // c.BlockHash + sszSlice13 := buf[504:536] // c.TransactionsRoot + sszSlice14 := buf[536:568] // c.WithdrawalsRoot + sszSlice15 := buf[568:576] // c.BlobGasUsed + sszSlice16 := buf[576:584] // c.ExcessBlobGas + + sszVarOffset10 := ssz.ReadOffset(buf[436:440]) // c.ExtraData + if sszVarOffset10 != 584 { return ssz.ErrInvalidVariableOffset } - - // Field (11) 'BaseFeePerGas' - if cap(e.BaseFeePerGas) == 0 { - e.BaseFeePerGas = make([]byte, 0, len(buf[440:472])) - } - e.BaseFeePerGas = append(e.BaseFeePerGas, buf[440:472]...) - - // Field (12) 'BlockHash' - if cap(e.BlockHash) == 0 { - e.BlockHash = make([]byte, 0, len(buf[472:504])) - } - e.BlockHash = append(e.BlockHash, buf[472:504]...) - - // Field (13) 'TransactionsRoot' - if cap(e.TransactionsRoot) == 0 { - e.TransactionsRoot = make([]byte, 0, len(buf[504:536])) - } - e.TransactionsRoot = append(e.TransactionsRoot, buf[504:536]...) - - // Field (14) 'WithdrawalsRoot' - if cap(e.WithdrawalsRoot) == 0 { - e.WithdrawalsRoot = make([]byte, 0, len(buf[536:568])) - } - e.WithdrawalsRoot = append(e.WithdrawalsRoot, buf[536:568]...) - - // Field (15) 'BlobGasUsed' - e.BlobGasUsed = ssz.UnmarshallUint[uint64](buf[568:576]) - - // Field (16) 'ExcessBlobGas' - e.ExcessBlobGas = ssz.UnmarshallUint[uint64](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 ExecutionPayloadHeaderDeneb object -func (e *ExecutionPayloadHeaderDeneb) SizeSSZ() (size int) { - size = 584 - - // Field (10) 'ExtraData' - size += len(e.ExtraData) - - return -} - -// HashTreeRoot ssz hashes the ExecutionPayloadHeaderDeneb object -func (e *ExecutionPayloadHeaderDeneb) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(e) -} - -// HashTreeRootWith ssz hashes the ExecutionPayloadHeaderDeneb object with a hasher -func (e *ExecutionPayloadHeaderDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'ParentHash' - if size := len(e.ParentHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentHash", size, 32) - return - } - hh.PutBytes(e.ParentHash) - - // Field (1) 'FeeRecipient' - if size := len(e.FeeRecipient); size != 20 { - err = ssz.ErrBytesLengthFn("--.FeeRecipient", size, 20) - return - } - hh.PutBytes(e.FeeRecipient) - - // Field (2) 'StateRoot' - if size := len(e.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return - } - hh.PutBytes(e.StateRoot) - - // Field (3) 'ReceiptsRoot' - if size := len(e.ReceiptsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ReceiptsRoot", size, 32) - return - } - hh.PutBytes(e.ReceiptsRoot) - - // Field (4) 'LogsBloom' - if size := len(e.LogsBloom); size != 256 { - err = ssz.ErrBytesLengthFn("--.LogsBloom", size, 256) - return - } - hh.PutBytes(e.LogsBloom) - - // Field (5) 'PrevRandao' - if size := len(e.PrevRandao); size != 32 { - err = ssz.ErrBytesLengthFn("--.PrevRandao", size, 32) - return - } - hh.PutBytes(e.PrevRandao) - - // Field (6) 'BlockNumber' - ssz.PutUint(hh, e.BlockNumber) - - // Field (7) 'GasLimit' - ssz.PutUint(hh, e.GasLimit) - - // Field (8) 'GasUsed' - ssz.PutUint(hh, e.GasUsed) - - // Field (9) 'Timestamp' - ssz.PutUint(hh, e.Timestamp) - - // Field (10) 'ExtraData' - { - elemIndx := hh.Index() - byteLen := uint64(len(e.ExtraData)) - if byteLen > 32 { - err = ssz.ErrIncorrectListSize - return - } - hh.AppendBytes32(e.ExtraData) - hh.MerkleizeWithMixin(elemIndx, byteLen, (32+31)/32) - } - - // Field (11) 'BaseFeePerGas' - if size := len(e.BaseFeePerGas); size != 32 { - err = ssz.ErrBytesLengthFn("--.BaseFeePerGas", size, 32) - return - } - hh.PutBytes(e.BaseFeePerGas) - - // Field (12) 'BlockHash' - if size := len(e.BlockHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockHash", size, 32) - return - } - hh.PutBytes(e.BlockHash) - - // Field (13) 'TransactionsRoot' - if size := len(e.TransactionsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.TransactionsRoot", size, 32) - return + if sszVarOffset10 > size { + return ssz.ErrOffset } - hh.PutBytes(e.TransactionsRoot) + sszSlice10 := buf[sszVarOffset10:] // c.ExtraData - // Field (14) 'WithdrawalsRoot' - if size := len(e.WithdrawalsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.WithdrawalsRoot", size, 32) - return - } - hh.PutBytes(e.WithdrawalsRoot) + // Field 0: ParentHash + c.ParentHash = make([]byte, 0, 32) + c.ParentHash = append(c.ParentHash, sszSlice0...) - // Field (15) 'BlobGasUsed' - ssz.PutUint(hh, e.BlobGasUsed) + // Field 1: FeeRecipient + c.FeeRecipient = make([]byte, 0, 20) + c.FeeRecipient = append(c.FeeRecipient, sszSlice1...) - // Field (16) 'ExcessBlobGas' - ssz.PutUint(hh, e.ExcessBlobGas) + // Field 2: StateRoot + c.StateRoot = make([]byte, 0, 32) + c.StateRoot = append(c.StateRoot, sszSlice2...) - hh.Merkleize(indx) - return -} + // Field 3: ReceiptsRoot + c.ReceiptsRoot = make([]byte, 0, 32) + c.ReceiptsRoot = append(c.ReceiptsRoot, sszSlice3...) -// MarshalSSZ ssz marshals the Withdrawal object -func (w *Withdrawal) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(w) -} + // Field 4: LogsBloom + c.LogsBloom = make([]byte, 0, 256) + c.LogsBloom = append(c.LogsBloom, sszSlice4...) -// MarshalSSZTo ssz marshals the Withdrawal object to a target array -func (w *Withdrawal) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf + // Field 5: PrevRandao + c.PrevRandao = make([]byte, 0, 32) + c.PrevRandao = append(c.PrevRandao, sszSlice5...) - // Field (0) 'Index' - dst = ssz.MarshalUint(dst, w.Index) + // Field 6: BlockNumber + c.BlockNumber = binary.LittleEndian.Uint64(sszSlice6) - // Field (1) 'ValidatorIndex' - dst = ssz.MarshalUint(dst, w.ValidatorIndex) + // Field 7: GasLimit + c.GasLimit = binary.LittleEndian.Uint64(sszSlice7) - // Field (2) 'Address' - if size := len(w.Address); size != 20 { - err = ssz.ErrBytesLengthFn("--.Address", size, 20) - return - } - dst = append(dst, w.Address...) + // Field 8: GasUsed + c.GasUsed = binary.LittleEndian.Uint64(sszSlice8) - // Field (3) 'Amount' - dst = ssz.MarshalUint(dst, w.Amount) + // Field 9: Timestamp + c.Timestamp = binary.LittleEndian.Uint64(sszSlice9) - return -} + // Field 10: ExtraData + c.ExtraData = append([]byte{}, sszSlice10...) -// 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 11: BaseFeePerGas + c.BaseFeePerGas = make([]byte, 0, 32) + c.BaseFeePerGas = append(c.BaseFeePerGas, sszSlice11...) - // Field (0) 'Index' - w.Index = ssz.UnmarshallUint[uint64](buf[0:8]) + // Field 12: BlockHash + c.BlockHash = make([]byte, 0, 32) + c.BlockHash = append(c.BlockHash, sszSlice12...) - // Field (1) 'ValidatorIndex' - w.ValidatorIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[8:16]) + // Field 13: TransactionsRoot + c.TransactionsRoot = make([]byte, 0, 32) + c.TransactionsRoot = append(c.TransactionsRoot, sszSlice13...) - // Field (2) 'Address' - if cap(w.Address) == 0 { - w.Address = make([]byte, 0, len(buf[16:36])) - } - w.Address = append(w.Address, buf[16:36]...) + // Field 14: WithdrawalsRoot + c.WithdrawalsRoot = make([]byte, 0, 32) + c.WithdrawalsRoot = append(c.WithdrawalsRoot, sszSlice14...) - // Field (3) 'Amount' - w.Amount = ssz.UnmarshallUint[uint64](buf[36:44]) + // Field 15: BlobGasUsed + c.BlobGasUsed = binary.LittleEndian.Uint64(sszSlice15) + // Field 16: ExcessBlobGas + c.ExcessBlobGas = binary.LittleEndian.Uint64(sszSlice16) 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.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'Index' - ssz.PutUint(hh, w.Index) - - // Field (1) 'ValidatorIndex' - ssz.PutUint(hh, w.ValidatorIndex) - - // Field (2) 'Address' - if size := len(w.Address); size != 20 { - err = ssz.ErrBytesLengthFn("--.Address", size, 20) - return +func (c *ExecutionPayloadHeaderDeneb) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - hh.PutBytes(w.Address) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (3) 'Amount' - ssz.PutUint(hh, w.Amount) +func (c *ExecutionPayloadHeaderDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: ParentHash + if len(c.ParentHash) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ParentHash) + // Field 1: FeeRecipient + if len(c.FeeRecipient) != 20 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.FeeRecipient) + // Field 2: StateRoot + if len(c.StateRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.StateRoot) + // Field 3: ReceiptsRoot + if len(c.ReceiptsRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ReceiptsRoot) + // Field 4: LogsBloom + if len(c.LogsBloom) != 256 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.LogsBloom) + // Field 5: PrevRandao + if len(c.PrevRandao) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.PrevRandao) + // Field 6: BlockNumber + hh.PutUint64(c.BlockNumber) + // Field 7: GasLimit + hh.PutUint64(c.GasLimit) + // Field 8: GasUsed + hh.PutUint64(c.GasUsed) + // Field 9: Timestamp + hh.PutUint64(c.Timestamp) + // Field 10: ExtraData + { + if len(c.ExtraData) > 32 { + return ssz.ErrBytesLength + } + subIndx := hh.Index() + hh.AppendBytes32(c.ExtraData) + numItems := uint64(len(c.ExtraData)) + hh.MerkleizeWithMixin(subIndx, numItems, (32*1+31)/32) + } + + // Field 11: BaseFeePerGas + if len(c.BaseFeePerGas) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.BaseFeePerGas) + // Field 12: BlockHash + if len(c.BlockHash) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.BlockHash) + // Field 13: TransactionsRoot + if len(c.TransactionsRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.TransactionsRoot) + // Field 14: WithdrawalsRoot + if len(c.WithdrawalsRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.WithdrawalsRoot) + // Field 15: BlobGasUsed + hh.PutUint64(c.BlobGasUsed) + // Field 16: ExcessBlobGas + hh.PutUint64(c.ExcessBlobGas) hh.Merkleize(indx) - return + return nil +} + +func (c *ExecutionRequests) SizeSSZ() int { + size := 12 + size += len(c.Deposits) * 192 + size += len(c.Withdrawals) * 76 + size += len(c.Consolidations) * 116 + return size } -// MarshalSSZ ssz marshals the BlobsBundle object -func (b *BlobsBundle) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) +func (c *ExecutionRequests) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the BlobsBundle object to a target array -func (b *BlobsBundle) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(12) +func (c *ExecutionRequests) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 12 - // Offset (0) 'KzgCommitments' + // Field 0: Deposits dst = ssz.WriteOffset(dst, offset) - offset += len(b.KzgCommitments) * 48 + offset += len(c.Deposits) * 192 - // Offset (1) 'Proofs' + // Field 1: Withdrawals dst = ssz.WriteOffset(dst, offset) - offset += len(b.Proofs) * 48 + offset += len(c.Withdrawals) * 76 - // Offset (2) 'Blobs' + // Field 2: Consolidations dst = ssz.WriteOffset(dst, offset) - offset += len(b.Blobs) * 131072 + offset += len(c.Consolidations) * 116 - // Field (0) 'KzgCommitments' - if size := len(b.KzgCommitments); size > 4096 { - err = ssz.ErrListTooBigFn("--.KzgCommitments", size, 4096) - return + // Field 0: Deposits + if len(c.Deposits) > 8192 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.KzgCommitments); ii++ { - if size := len(b.KzgCommitments[ii]); size != 48 { - err = ssz.ErrBytesLengthFn("--.KzgCommitments[ii]", size, 48) - return + for _, o := range c.Deposits { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Deposits: %w", err) } - dst = append(dst, b.KzgCommitments[ii]...) } - // Field (1) 'Proofs' - if size := len(b.Proofs); size > 4096 { - err = ssz.ErrListTooBigFn("--.Proofs", size, 4096) - return + // Field 1: Withdrawals + if len(c.Withdrawals) > 16 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.Proofs); ii++ { - if size := len(b.Proofs[ii]); size != 48 { - err = ssz.ErrBytesLengthFn("--.Proofs[ii]", size, 48) - return + for _, o := range c.Withdrawals { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Withdrawals: %w", err) } - dst = append(dst, b.Proofs[ii]...) } - // Field (2) 'Blobs' - if size := len(b.Blobs); size > 4096 { - err = ssz.ErrListTooBigFn("--.Blobs", size, 4096) - return + // Field 2: Consolidations + if len(c.Consolidations) > 2 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.Blobs); ii++ { - if size := len(b.Blobs[ii]); size != 131072 { - err = ssz.ErrBytesLengthFn("--.Blobs[ii]", size, 131072) - return + for _, o := range c.Consolidations { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Consolidations: %w", err) } - dst = append(dst, b.Blobs[ii]...) } - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the BlobsBundle object -func (b *BlobsBundle) UnmarshalSSZ(buf []byte) error { +func (c *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) 'KzgCommitments' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } - - if o0 != 12 { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Deposits + if sszVarOffset0 != 12 { return ssz.ErrInvalidVariableOffset } - - // Offset (1) 'Proofs' - if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 { + if sszVarOffset0 > size { return ssz.ErrOffset } - - // Offset (2) 'Blobs' - if o2 = ssz.ReadOffset(buf[8:12]); o2 > size || o1 > o2 { + sszVarOffset1 := ssz.ReadOffset(buf[4:8]) // c.Withdrawals + if sszVarOffset1 > size || sszVarOffset1 < sszVarOffset0 { + return ssz.ErrOffset + } + sszVarOffset2 := ssz.ReadOffset(buf[8:12]) // c.Consolidations + if sszVarOffset2 > size || sszVarOffset2 < sszVarOffset1 { return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:sszVarOffset1] // c.Deposits + sszSlice1 := buf[sszVarOffset1:sszVarOffset2] // c.Withdrawals + sszSlice2 := buf[sszVarOffset2:] // c.Consolidations - // Field (0) 'KzgCommitments' + // Field 0: Deposits { - buf = tail[o0:o1] - num, err := ssz.DivideInt2(len(buf), 48, 4096) - if err != nil { - return err - } - b.KzgCommitments = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(b.KzgCommitments[ii]) == 0 { - b.KzgCommitments[ii] = make([]byte, 0, len(buf[ii*48:(ii+1)*48])) + if len(sszSlice0)%192 != 0 { + return fmt.Errorf("misaligned bytes: c.Deposits length is %d, which is not a multiple of 192: %w", len(sszSlice0), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice0) / 192 + if numElem > 8192 { + return fmt.Errorf("ssz-max exceeded: c.Deposits has %d elements, ssz-max is 8192: %w", numElem, ssz.ErrListTooBig) + } + c.Deposits = make([]*DepositRequest, numElem) + for i := 0; i < numElem; i++ { + var tmp *DepositRequest + tmp = new(DepositRequest) + tmpSlice := sszSlice0[i*192 : (1+i)*192] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Deposits: %w", err) } - b.KzgCommitments[ii] = append(b.KzgCommitments[ii], buf[ii*48:(ii+1)*48]...) + c.Deposits[i] = tmp } } - // Field (1) 'Proofs' + // Field 1: Withdrawals { - buf = tail[o1:o2] - num, err := ssz.DivideInt2(len(buf), 48, 4096) - if err != nil { - return err - } - b.Proofs = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(b.Proofs[ii]) == 0 { - b.Proofs[ii] = make([]byte, 0, len(buf[ii*48:(ii+1)*48])) + if len(sszSlice1)%76 != 0 { + return fmt.Errorf("misaligned bytes: c.Withdrawals length is %d, which is not a multiple of 76: %w", len(sszSlice1), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice1) / 76 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.Withdrawals has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.Withdrawals = make([]*WithdrawalRequest, numElem) + for i := 0; i < numElem; i++ { + var tmp *WithdrawalRequest + tmp = new(WithdrawalRequest) + tmpSlice := sszSlice1[i*76 : (1+i)*76] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Withdrawals: %w", err) } - b.Proofs[ii] = append(b.Proofs[ii], buf[ii*48:(ii+1)*48]...) + c.Withdrawals[i] = tmp } } - // Field (2) 'Blobs' + // Field 2: Consolidations { - buf = tail[o2:] - num, err := ssz.DivideInt2(len(buf), 131072, 4096) - if err != nil { - return err - } - b.Blobs = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(b.Blobs[ii]) == 0 { - b.Blobs[ii] = make([]byte, 0, len(buf[ii*131072:(ii+1)*131072])) + if len(sszSlice2)%116 != 0 { + return fmt.Errorf("misaligned bytes: c.Consolidations length is %d, which is not a multiple of 116: %w", len(sszSlice2), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice2) / 116 + if numElem > 2 { + return fmt.Errorf("ssz-max exceeded: c.Consolidations has %d elements, ssz-max is 2: %w", numElem, ssz.ErrListTooBig) + } + c.Consolidations = make([]*ConsolidationRequest, numElem) + for i := 0; i < numElem; i++ { + var tmp *ConsolidationRequest + tmp = new(ConsolidationRequest) + tmpSlice := sszSlice2[i*116 : (1+i)*116] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Consolidations: %w", err) } - b.Blobs[ii] = append(b.Blobs[ii], buf[ii*131072:(ii+1)*131072]...) + c.Consolidations[i] = tmp } } return err } -// SizeSSZ returns the ssz encoded size in bytes for the BlobsBundle object -func (b *BlobsBundle) SizeSSZ() (size int) { - size = 12 - - // Field (0) 'KzgCommitments' - size += len(b.KzgCommitments) * 48 - - // Field (1) 'Proofs' - size += len(b.Proofs) * 48 - - // Field (2) 'Blobs' - size += len(b.Blobs) * 131072 - - return -} - -// HashTreeRoot ssz hashes the BlobsBundle object -func (b *BlobsBundle) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) +func (c *ExecutionRequests) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the BlobsBundle object with a hasher -func (b *BlobsBundle) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *ExecutionRequests) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'KzgCommitments' + // Field 0: Deposits { - if size := len(b.KzgCommitments); size > 4096 { - err = ssz.ErrListTooBigFn("--.KzgCommitments", size, 4096) - return + if len(c.Deposits) > 8192 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range b.KzgCommitments { - if len(i) != 48 { - err = ssz.ErrBytesLength - return + for _, o := range c.Deposits { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Deposits: %w", err) } - hh.PutBytes(i) } - - numItems := uint64(len(b.KzgCommitments)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Deposits)), 8192) } - - // Field (1) 'Proofs' + // Field 1: Withdrawals { - if size := len(b.Proofs); size > 4096 { - err = ssz.ErrListTooBigFn("--.Proofs", size, 4096) - return + if len(c.Withdrawals) > 16 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range b.Proofs { - if len(i) != 48 { - err = ssz.ErrBytesLength - return + for _, o := range c.Withdrawals { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Withdrawals: %w", err) } - hh.PutBytes(i) } - - numItems := uint64(len(b.Proofs)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Withdrawals)), 16) } - - // Field (2) 'Blobs' + // Field 2: Consolidations { - if size := len(b.Blobs); size > 4096 { - err = ssz.ErrListTooBigFn("--.Blobs", size, 4096) - return + if len(c.Consolidations) > 2 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range b.Blobs { - if len(i) != 131072 { - err = ssz.ErrBytesLength - return + for _, o := range c.Consolidations { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Consolidations: %w", err) } - hh.PutBytes(i) } - - numItems := uint64(len(b.Blobs)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Consolidations)), 2) } - hh.Merkleize(indx) - return + return nil +} + +func (c *ExecutionRequestsGloas) SizeSSZ() int { + size := 20 + size += len(c.Deposits) * 192 + size += len(c.Withdrawals) * 76 + size += len(c.Consolidations) * 116 + size += len(c.BuilderDeposits) * 184 + size += len(c.BuilderExits) * 68 + return size } -// MarshalSSZ ssz marshals the BlobsBundleV2 object -func (b *BlobsBundleV2) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) +func (c *ExecutionRequestsGloas) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the BlobsBundleV2 object to a target array -func (b *BlobsBundleV2) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(12) +func (c *ExecutionRequestsGloas) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 20 + + // Field 0: Deposits + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Deposits) * 192 + + // Field 1: Withdrawals + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Withdrawals) * 76 - // Offset (0) 'KzgCommitments' + // Field 2: Consolidations dst = ssz.WriteOffset(dst, offset) - offset += len(b.KzgCommitments) * 48 + offset += len(c.Consolidations) * 116 - // Offset (1) 'Proofs' + // Field 3: BuilderDeposits dst = ssz.WriteOffset(dst, offset) - offset += len(b.Proofs) * 48 + offset += len(c.BuilderDeposits) * 184 - // Offset (2) 'Blobs' + // Field 4: BuilderExits dst = ssz.WriteOffset(dst, offset) - offset += len(b.Blobs) * 131072 + offset += len(c.BuilderExits) * 68 + + // Field 0: Deposits + if len(c.Deposits) > 8192 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.Deposits { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Deposits: %w", err) + } + } - // Field (0) 'KzgCommitments' - if size := len(b.KzgCommitments); size > 4096 { - err = ssz.ErrListTooBigFn("--.KzgCommitments", size, 4096) - return + // Field 1: Withdrawals + if len(c.Withdrawals) > 16 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.KzgCommitments); ii++ { - if size := len(b.KzgCommitments[ii]); size != 48 { - err = ssz.ErrBytesLengthFn("--.KzgCommitments[ii]", size, 48) - return + for _, o := range c.Withdrawals { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Withdrawals: %w", err) } - dst = append(dst, b.KzgCommitments[ii]...) } - // Field (1) 'Proofs' - if size := len(b.Proofs); size > 33554432 { - err = ssz.ErrListTooBigFn("--.Proofs", size, 33554432) - return + // Field 2: Consolidations + if len(c.Consolidations) > 2 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.Proofs); ii++ { - if size := len(b.Proofs[ii]); size != 48 { - err = ssz.ErrBytesLengthFn("--.Proofs[ii]", size, 48) - return + for _, o := range c.Consolidations { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Consolidations: %w", err) } - dst = append(dst, b.Proofs[ii]...) } - // Field (2) 'Blobs' - if size := len(b.Blobs); size > 4096 { - err = ssz.ErrListTooBigFn("--.Blobs", size, 4096) - return + // Field 3: BuilderDeposits + if len(c.BuilderDeposits) > 256 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.Blobs); ii++ { - if size := len(b.Blobs[ii]); size != 131072 { - err = ssz.ErrBytesLengthFn("--.Blobs[ii]", size, 131072) - return + for _, o := range c.BuilderDeposits { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("BuilderDeposits: %w", err) } - dst = append(dst, b.Blobs[ii]...) } - return + // Field 4: BuilderExits + if len(c.BuilderExits) > 16 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.BuilderExits { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("BuilderExits: %w", err) + } + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the BlobsBundleV2 object -func (b *BlobsBundleV2) UnmarshalSSZ(buf []byte) error { +func (c *ExecutionRequestsGloas) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 12 { + if size < 20 { return ssz.ErrSize } - tail := buf - var o0, o1, o2 uint64 - - // Offset (0) 'KzgCommitments' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Deposits + if sszVarOffset0 != 20 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset0 > size { return ssz.ErrOffset } - - if o0 != 12 { - return ssz.ErrInvalidVariableOffset + sszVarOffset1 := ssz.ReadOffset(buf[4:8]) // c.Withdrawals + if sszVarOffset1 > size || sszVarOffset1 < sszVarOffset0 { + return ssz.ErrOffset } - - // Offset (1) 'Proofs' - if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 { + sszVarOffset2 := ssz.ReadOffset(buf[8:12]) // c.Consolidations + if sszVarOffset2 > size || sszVarOffset2 < sszVarOffset1 { return ssz.ErrOffset } - - // Offset (2) 'Blobs' - if o2 = ssz.ReadOffset(buf[8:12]); o2 > size || o1 > o2 { + sszVarOffset3 := ssz.ReadOffset(buf[12:16]) // c.BuilderDeposits + if sszVarOffset3 > size || sszVarOffset3 < sszVarOffset2 { + return ssz.ErrOffset + } + sszVarOffset4 := ssz.ReadOffset(buf[16:20]) // c.BuilderExits + if sszVarOffset4 > size || sszVarOffset4 < sszVarOffset3 { return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:sszVarOffset1] // c.Deposits + sszSlice1 := buf[sszVarOffset1:sszVarOffset2] // c.Withdrawals + sszSlice2 := buf[sszVarOffset2:sszVarOffset3] // c.Consolidations + sszSlice3 := buf[sszVarOffset3:sszVarOffset4] // c.BuilderDeposits + sszSlice4 := buf[sszVarOffset4:] // c.BuilderExits - // Field (0) 'KzgCommitments' + // Field 0: Deposits { - buf = tail[o0:o1] - num, err := ssz.DivideInt2(len(buf), 48, 4096) - if err != nil { - return err - } - b.KzgCommitments = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(b.KzgCommitments[ii]) == 0 { - b.KzgCommitments[ii] = make([]byte, 0, len(buf[ii*48:(ii+1)*48])) + if len(sszSlice0)%192 != 0 { + return fmt.Errorf("misaligned bytes: c.Deposits length is %d, which is not a multiple of 192: %w", len(sszSlice0), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice0) / 192 + if numElem > 8192 { + return fmt.Errorf("ssz-max exceeded: c.Deposits has %d elements, ssz-max is 8192: %w", numElem, ssz.ErrListTooBig) + } + c.Deposits = make([]*DepositRequest, numElem) + for i := 0; i < numElem; i++ { + var tmp *DepositRequest + tmp = new(DepositRequest) + tmpSlice := sszSlice0[i*192 : (1+i)*192] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Deposits: %w", err) } - b.KzgCommitments[ii] = append(b.KzgCommitments[ii], buf[ii*48:(ii+1)*48]...) + c.Deposits[i] = tmp } } - // Field (1) 'Proofs' + // Field 1: Withdrawals { - buf = tail[o1:o2] - num, err := ssz.DivideInt2(len(buf), 48, 33554432) - if err != nil { - return err - } - b.Proofs = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(b.Proofs[ii]) == 0 { - b.Proofs[ii] = make([]byte, 0, len(buf[ii*48:(ii+1)*48])) + if len(sszSlice1)%76 != 0 { + return fmt.Errorf("misaligned bytes: c.Withdrawals length is %d, which is not a multiple of 76: %w", len(sszSlice1), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice1) / 76 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.Withdrawals has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.Withdrawals = make([]*WithdrawalRequest, numElem) + for i := 0; i < numElem; i++ { + var tmp *WithdrawalRequest + tmp = new(WithdrawalRequest) + tmpSlice := sszSlice1[i*76 : (1+i)*76] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Withdrawals: %w", err) } - b.Proofs[ii] = append(b.Proofs[ii], buf[ii*48:(ii+1)*48]...) + c.Withdrawals[i] = tmp } } - // Field (2) 'Blobs' + // Field 2: Consolidations { - buf = tail[o2:] - num, err := ssz.DivideInt2(len(buf), 131072, 4096) - if err != nil { - return err - } - b.Blobs = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(b.Blobs[ii]) == 0 { - b.Blobs[ii] = make([]byte, 0, len(buf[ii*131072:(ii+1)*131072])) + if len(sszSlice2)%116 != 0 { + return fmt.Errorf("misaligned bytes: c.Consolidations length is %d, which is not a multiple of 116: %w", len(sszSlice2), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice2) / 116 + if numElem > 2 { + return fmt.Errorf("ssz-max exceeded: c.Consolidations has %d elements, ssz-max is 2: %w", numElem, ssz.ErrListTooBig) + } + c.Consolidations = make([]*ConsolidationRequest, numElem) + for i := 0; i < numElem; i++ { + var tmp *ConsolidationRequest + tmp = new(ConsolidationRequest) + tmpSlice := sszSlice2[i*116 : (1+i)*116] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Consolidations: %w", err) } - b.Blobs[ii] = append(b.Blobs[ii], buf[ii*131072:(ii+1)*131072]...) + c.Consolidations[i] = tmp } } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the BlobsBundleV2 object -func (b *BlobsBundleV2) SizeSSZ() (size int) { - size = 12 - // Field (0) 'KzgCommitments' - size += len(b.KzgCommitments) * 48 - - // Field (1) 'Proofs' - size += len(b.Proofs) * 48 - - // Field (2) 'Blobs' - size += len(b.Blobs) * 131072 + // Field 3: BuilderDeposits + { + if len(sszSlice3)%184 != 0 { + return fmt.Errorf("misaligned bytes: c.BuilderDeposits length is %d, which is not a multiple of 184: %w", len(sszSlice3), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice3) / 184 + if numElem > 256 { + return fmt.Errorf("ssz-max exceeded: c.BuilderDeposits has %d elements, ssz-max is 256: %w", numElem, ssz.ErrListTooBig) + } + c.BuilderDeposits = make([]*BuilderDepositRequest, numElem) + for i := 0; i < numElem; i++ { + var tmp *BuilderDepositRequest + tmp = new(BuilderDepositRequest) + tmpSlice := sszSlice3[i*184 : (1+i)*184] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("BuilderDeposits: %w", err) + } + c.BuilderDeposits[i] = tmp + } + } - return + // Field 4: BuilderExits + { + if len(sszSlice4)%68 != 0 { + return fmt.Errorf("misaligned bytes: c.BuilderExits length is %d, which is not a multiple of 68: %w", len(sszSlice4), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice4) / 68 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.BuilderExits has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.BuilderExits = make([]*BuilderExitRequest, numElem) + for i := 0; i < numElem; i++ { + var tmp *BuilderExitRequest + tmp = new(BuilderExitRequest) + tmpSlice := sszSlice4[i*68 : (1+i)*68] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("BuilderExits: %w", err) + } + c.BuilderExits[i] = tmp + } + } + return err } -// HashTreeRoot ssz hashes the BlobsBundleV2 object -func (b *BlobsBundleV2) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) +func (c *ExecutionRequestsGloas) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the BlobsBundleV2 object with a hasher -func (b *BlobsBundleV2) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *ExecutionRequestsGloas) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'KzgCommitments' + // Field 0: Deposits { - if size := len(b.KzgCommitments); size > 4096 { - err = ssz.ErrListTooBigFn("--.KzgCommitments", size, 4096) - return + if len(c.Deposits) > 8192 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range b.KzgCommitments { - if len(i) != 48 { - err = ssz.ErrBytesLength - return + for _, o := range c.Deposits { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Deposits: %w", err) } - hh.PutBytes(i) } - - numItems := uint64(len(b.KzgCommitments)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Deposits)), 8192) } - - // Field (1) 'Proofs' + // Field 1: Withdrawals { - if size := len(b.Proofs); size > 33554432 { - err = ssz.ErrListTooBigFn("--.Proofs", size, 33554432) - return + if len(c.Withdrawals) > 16 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range b.Proofs { - if len(i) != 48 { - err = ssz.ErrBytesLength - return + for _, o := range c.Withdrawals { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Withdrawals: %w", err) } - hh.PutBytes(i) } - - numItems := uint64(len(b.Proofs)) - hh.MerkleizeWithMixin(subIndx, numItems, 33554432) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Withdrawals)), 16) } - - // Field (2) 'Blobs' + // Field 2: Consolidations { - if size := len(b.Blobs); size > 4096 { - err = ssz.ErrListTooBigFn("--.Blobs", size, 4096) - return + if len(c.Consolidations) > 2 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range b.Blobs { - if len(i) != 131072 { - err = ssz.ErrBytesLength - return + for _, o := range c.Consolidations { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Consolidations: %w", err) } - hh.PutBytes(i) } - - numItems := uint64(len(b.Blobs)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) - } - - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the BuilderDepositRequest object -func (b *BuilderDepositRequest) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} - -// MarshalSSZTo ssz marshals the BuilderDepositRequest object to a target array -func (b *BuilderDepositRequest) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - - // Field (0) 'Pubkey' - if size := len(b.Pubkey); size != 48 { - err = ssz.ErrBytesLengthFn("--.Pubkey", size, 48) - return + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Consolidations)), 2) } - dst = append(dst, b.Pubkey...) - - // Field (1) 'WithdrawalCredentials' - if size := len(b.WithdrawalCredentials); size != 32 { - err = ssz.ErrBytesLengthFn("--.WithdrawalCredentials", size, 32) - return + // Field 3: BuilderDeposits + { + if len(c.BuilderDeposits) > 256 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.BuilderDeposits { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("BuilderDeposits: %w", err) + } + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.BuilderDeposits)), 256) } - dst = append(dst, b.WithdrawalCredentials...) - - // Field (2) 'Amount' - dst = ssz.MarshalUint(dst, b.Amount) - - // Field (3) 'Signature' - if size := len(b.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 4: BuilderExits + { + if len(c.BuilderExits) > 16 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.BuilderExits { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("BuilderExits: %w", err) + } + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.BuilderExits)), 16) } - dst = append(dst, b.Signature...) - - return + hh.Merkleize(indx) + return nil } -// UnmarshalSSZ ssz unmarshals the BuilderDepositRequest object -func (b *BuilderDepositRequest) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size != 184 { - return ssz.ErrSize - } - - // Field (0) 'Pubkey' - if cap(b.Pubkey) == 0 { - b.Pubkey = make([]byte, 0, len(buf[0:48])) - } - b.Pubkey = append(b.Pubkey, buf[0:48]...) - - // Field (1) 'WithdrawalCredentials' - if cap(b.WithdrawalCredentials) == 0 { - b.WithdrawalCredentials = make([]byte, 0, len(buf[48:80])) - } - b.WithdrawalCredentials = append(b.WithdrawalCredentials, buf[48:80]...) - - // Field (2) 'Amount' - b.Amount = ssz.UnmarshallUint[uint64](buf[80:88]) - - // Field (3) 'Signature' - if cap(b.Signature) == 0 { - b.Signature = make([]byte, 0, len(buf[88:184])) - } - b.Signature = append(b.Signature, buf[88:184]...) - - return err -} +func (c *Withdrawal) SizeSSZ() int { + size := 44 -// SizeSSZ returns the ssz encoded size in bytes for the BuilderDepositRequest object -func (b *BuilderDepositRequest) SizeSSZ() (size int) { - size = 184 - return + return size } -// HashTreeRoot ssz hashes the BuilderDepositRequest object -func (b *BuilderDepositRequest) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) +func (c *Withdrawal) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// HashTreeRootWith ssz hashes the BuilderDepositRequest object with a hasher -func (b *BuilderDepositRequest) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'Pubkey' - if size := len(b.Pubkey); size != 48 { - err = ssz.ErrBytesLengthFn("--.Pubkey", size, 48) - return - } - hh.PutBytes(b.Pubkey) - - // Field (1) 'WithdrawalCredentials' - if size := len(b.WithdrawalCredentials); size != 32 { - err = ssz.ErrBytesLengthFn("--.WithdrawalCredentials", size, 32) - return - } - hh.PutBytes(b.WithdrawalCredentials) +func (c *Withdrawal) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (2) 'Amount' - ssz.PutUint(hh, b.Amount) + // Field 0: Index + dst = binary.LittleEndian.AppendUint64(dst, c.Index) - // Field (3) 'Signature' - if size := len(b.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 1: ValidatorIndex + if dst, err = c.ValidatorIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ValidatorIndex: %w", err) } - hh.PutBytes(b.Signature) - - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the BuilderExitRequest object -func (b *BuilderExitRequest) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} - -// MarshalSSZTo ssz marshals the BuilderExitRequest object to a target array -func (b *BuilderExitRequest) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - // Field (0) 'SourceAddress' - if size := len(b.SourceAddress); size != 20 { - err = ssz.ErrBytesLengthFn("--.SourceAddress", size, 20) - return + // Field 2: Address + if len(c.Address) != 20 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.SourceAddress...) + dst = append(dst, c.Address...) - // Field (1) 'Pubkey' - if size := len(b.Pubkey); size != 48 { - err = ssz.ErrBytesLengthFn("--.Pubkey", size, 48) - return - } - dst = append(dst, b.Pubkey...) + // Field 3: Amount + dst = binary.LittleEndian.AppendUint64(dst, c.Amount) - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the BuilderExitRequest object -func (b *BuilderExitRequest) UnmarshalSSZ(buf []byte) error { +func (c *Withdrawal) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 68 { + if size != 44 { return ssz.ErrSize } - // Field (0) 'SourceAddress' - if cap(b.SourceAddress) == 0 { - b.SourceAddress = make([]byte, 0, len(buf[0:20])) - } - b.SourceAddress = append(b.SourceAddress, buf[0:20]...) + sszSlice0 := buf[0:8] // c.Index + sszSlice1 := buf[8:16] // c.ValidatorIndex + sszSlice2 := buf[16:36] // c.Address + sszSlice3 := buf[36:44] // c.Amount - // Field (1) 'Pubkey' - if cap(b.Pubkey) == 0 { - b.Pubkey = make([]byte, 0, len(buf[20:68])) + // Field 0: Index + c.Index = binary.LittleEndian.Uint64(sszSlice0) + + // Field 1: ValidatorIndex + if err = c.ValidatorIndex.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("ValidatorIndex: %w", err) } - b.Pubkey = append(b.Pubkey, buf[20:68]...) - return err -} + // Field 2: Address + c.Address = make([]byte, 0, 20) + c.Address = append(c.Address, sszSlice2...) -// SizeSSZ returns the ssz encoded size in bytes for the BuilderExitRequest object -func (b *BuilderExitRequest) SizeSSZ() (size int) { - size = 68 - return + // Field 3: Amount + c.Amount = binary.LittleEndian.Uint64(sszSlice3) + return err } -// HashTreeRoot ssz hashes the BuilderExitRequest object -func (b *BuilderExitRequest) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) +func (c *Withdrawal) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the BuilderExitRequest object with a hasher -func (b *BuilderExitRequest) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *Withdrawal) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'SourceAddress' - if size := len(b.SourceAddress); size != 20 { - err = ssz.ErrBytesLengthFn("--.SourceAddress", size, 20) - return - } - hh.PutBytes(b.SourceAddress) - - // Field (1) 'Pubkey' - if size := len(b.Pubkey); size != 48 { - err = ssz.ErrBytesLengthFn("--.Pubkey", size, 48) - return - } - hh.PutBytes(b.Pubkey) - + // Field 0: Index + hh.PutUint64(c.Index) + // Field 1: ValidatorIndex + if err := c.ValidatorIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ValidatorIndex: %w", err) + } + // Field 2: Address + if len(c.Address) != 20 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Address) + // Field 3: Amount + hh.PutUint64(c.Amount) hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the ExecutionRequestsGloas object -func (e *ExecutionRequestsGloas) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(e) + return nil } -// MarshalSSZTo ssz marshals the ExecutionRequestsGloas object to a target array -func (e *ExecutionRequestsGloas) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(20) +func (c *WithdrawalRequest) SizeSSZ() int { + size := 76 - // 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) - offset += len(e.Consolidations) * 116 - - // Offset (3) 'BuilderDeposits' - dst = ssz.WriteOffset(dst, offset) - offset += len(e.BuilderDeposits) * 184 - - // Offset (4) 'BuilderExits' - dst = ssz.WriteOffset(dst, offset) - offset += len(e.BuilderExits) * 68 + return size +} - // Field (0) 'Deposits' - if size := len(e.Deposits); size > 8192 { - err = ssz.ErrListTooBigFn("--.Deposits", size, 8192) - return - } - for ii := 0; ii < len(e.Deposits); ii++ { - if dst, err = e.Deposits[ii].MarshalSSZTo(dst); err != nil { - return - } - } +func (c *WithdrawalRequest) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (1) 'Withdrawals' - if size := len(e.Withdrawals); size > 16 { - err = ssz.ErrListTooBigFn("--.Withdrawals", size, 16) - return - } - for ii := 0; ii < len(e.Withdrawals); ii++ { - if dst, err = e.Withdrawals[ii].MarshalSSZTo(dst); err != nil { - return - } - } +func (c *WithdrawalRequest) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (2) 'Consolidations' - if size := len(e.Consolidations); size > 2 { - err = ssz.ErrListTooBigFn("--.Consolidations", size, 2) - return - } - for ii := 0; ii < len(e.Consolidations); ii++ { - if dst, err = e.Consolidations[ii].MarshalSSZTo(dst); err != nil { - return - } + // Field 0: SourceAddress + if len(c.SourceAddress) != 20 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.SourceAddress...) - // Field (3) 'BuilderDeposits' - if size := len(e.BuilderDeposits); size > 256 { - err = ssz.ErrListTooBigFn("--.BuilderDeposits", size, 256) - return - } - for ii := 0; ii < len(e.BuilderDeposits); ii++ { - if dst, err = e.BuilderDeposits[ii].MarshalSSZTo(dst); err != nil { - return - } + // Field 1: ValidatorPubkey + if len(c.ValidatorPubkey) != 48 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.ValidatorPubkey...) - // Field (4) 'BuilderExits' - if size := len(e.BuilderExits); size > 16 { - err = ssz.ErrListTooBigFn("--.BuilderExits", size, 16) - return - } - for ii := 0; ii < len(e.BuilderExits); ii++ { - if dst, err = e.BuilderExits[ii].MarshalSSZTo(dst); err != nil { - return - } - } + // Field 2: Amount + dst = binary.LittleEndian.AppendUint64(dst, c.Amount) - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the ExecutionRequestsGloas object -func (e *ExecutionRequestsGloas) UnmarshalSSZ(buf []byte) error { +func (c *WithdrawalRequest) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 20 { + if size != 76 { return ssz.ErrSize } - tail := buf - var o0, o1, o2, o3, o4 uint64 - - // Offset (0) 'Deposits' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } - - if o0 != 20 { - 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 - } - - // Offset (3) 'BuilderDeposits' - if o3 = ssz.ReadOffset(buf[12:16]); o3 > size || o2 > o3 { - return ssz.ErrOffset - } - - // Offset (4) 'BuilderExits' - if o4 = ssz.ReadOffset(buf[16:20]); o4 > size || o3 > o4 { - 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 - } - } - } + sszSlice0 := buf[0:20] // c.SourceAddress + sszSlice1 := buf[20:68] // c.ValidatorPubkey + sszSlice2 := buf[68:76] // c.Amount - // Field (2) 'Consolidations' - { - buf = tail[o2:o3] - 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 - } - } - } + // Field 0: SourceAddress + c.SourceAddress = make([]byte, 0, 20) + c.SourceAddress = append(c.SourceAddress, sszSlice0...) - // Field (3) 'BuilderDeposits' - { - buf = tail[o3:o4] - num, err := ssz.DivideInt2(len(buf), 184, 256) - if err != nil { - return err - } - e.BuilderDeposits = make([]*BuilderDepositRequest, num) - for ii := 0; ii < num; ii++ { - if e.BuilderDeposits[ii] == nil { - e.BuilderDeposits[ii] = new(BuilderDepositRequest) - } - if err = e.BuilderDeposits[ii].UnmarshalSSZ(buf[ii*184 : (ii+1)*184]); err != nil { - return err - } - } - } + // Field 1: ValidatorPubkey + c.ValidatorPubkey = make([]byte, 0, 48) + c.ValidatorPubkey = append(c.ValidatorPubkey, sszSlice1...) - // Field (4) 'BuilderExits' - { - buf = tail[o4:] - num, err := ssz.DivideInt2(len(buf), 68, 16) - if err != nil { - return err - } - e.BuilderExits = make([]*BuilderExitRequest, num) - for ii := 0; ii < num; ii++ { - if e.BuilderExits[ii] == nil { - e.BuilderExits[ii] = new(BuilderExitRequest) - } - if err = e.BuilderExits[ii].UnmarshalSSZ(buf[ii*68 : (ii+1)*68]); err != nil { - return err - } - } - } + // Field 2: Amount + c.Amount = binary.LittleEndian.Uint64(sszSlice2) return err } -// SizeSSZ returns the ssz encoded size in bytes for the ExecutionRequestsGloas object -func (e *ExecutionRequestsGloas) SizeSSZ() (size int) { - size = 20 - - // Field (0) 'Deposits' - size += len(e.Deposits) * 192 - - // Field (1) 'Withdrawals' - size += len(e.Withdrawals) * 76 - - // Field (2) 'Consolidations' - size += len(e.Consolidations) * 116 - - // Field (3) 'BuilderDeposits' - size += len(e.BuilderDeposits) * 184 - - // Field (4) 'BuilderExits' - size += len(e.BuilderExits) * 68 - - return -} - -// HashTreeRoot ssz hashes the ExecutionRequestsGloas object -func (e *ExecutionRequestsGloas) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(e) +func (c *WithdrawalRequest) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the ExecutionRequestsGloas object with a hasher -func (e *ExecutionRequestsGloas) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *WithdrawalRequest) HashTreeRootWith(hh *ssz.Hasher) (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) - } - - // Field (3) 'BuilderDeposits' - { - subIndx := hh.Index() - num := uint64(len(e.BuilderDeposits)) - if num > 256 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range e.BuilderDeposits { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } - } - hh.MerkleizeWithMixin(subIndx, num, 256) + // Field 0: SourceAddress + if len(c.SourceAddress) != 20 { + return ssz.ErrBytesLength } - - // Field (4) 'BuilderExits' - { - subIndx := hh.Index() - num := uint64(len(e.BuilderExits)) - if num > 16 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range e.BuilderExits { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } - } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.PutBytes(c.SourceAddress) + // Field 1: ValidatorPubkey + if len(c.ValidatorPubkey) != 48 { + return ssz.ErrBytesLength } - + hh.PutBytes(c.ValidatorPubkey) + // Field 2: Amount + hh.PutUint64(c.Amount) hh.Merkleize(indx) - return + return nil } diff --git a/proto/engine/v1/engine.yaml b/proto/engine/v1/engine.yaml new file mode 100644 index 000000000000..10406a3433dc --- /dev/null +++ b/proto/engine/v1/engine.yaml @@ -0,0 +1,21 @@ +package: "github.com/OffchainLabs/prysm/v7/proto/engine/v1" +types: + - name: "BlobsBundle" + - name: "BlobsBundleV2" + - name: "BuilderDepositRequest" + - name: "BuilderExitRequest" + - name: "ConsolidationRequest" + - name: "DepositRequest" + - name: "ExecutionPayload" + - name: "ExecutionPayloadCapella" + - name: "ExecutionPayloadDeneb" + - name: "ExecutionPayloadGloas" + - name: "ExecutionPayloadDenebAndBlobsBundle" + - name: "ExecutionPayloadDenebAndBlobsBundleV2" + - name: "ExecutionPayloadHeader" + - name: "ExecutionPayloadHeaderCapella" + - name: "ExecutionPayloadHeaderDeneb" + - name: "ExecutionRequests" + - name: "ExecutionRequestsGloas" + - name: "Withdrawal" + - name: "WithdrawalRequest" diff --git a/proto/engine/v1/execution_engine.minimal.pb.go b/proto/engine/v1/execution_engine.minimal.pb.go new file mode 100644 index 000000000000..22a6a9080bed --- /dev/null +++ b/proto/engine/v1/execution_engine.minimal.pb.go @@ -0,0 +1,2800 @@ +//go:build minimal + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.3 +// protoc (unknown) +// source: proto/engine/v1/execution_engine.proto + +package enginev1 + +import ( + reflect "reflect" + sync "sync" + + github_com_OffchainLabs_prysm_v7_consensus_types_primitives "github.com/OffchainLabs/prysm/v7/consensus-types/primitives" + _ "github.com/OffchainLabs/prysm/v7/proto/eth/ext" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type PayloadStatus_Status int32 + +const ( + PayloadStatus_UNKNOWN PayloadStatus_Status = 0 + PayloadStatus_VALID PayloadStatus_Status = 1 + PayloadStatus_INVALID PayloadStatus_Status = 2 + PayloadStatus_SYNCING PayloadStatus_Status = 3 + PayloadStatus_ACCEPTED PayloadStatus_Status = 4 + PayloadStatus_INVALID_BLOCK_HASH PayloadStatus_Status = 5 +) + +// Enum value maps for PayloadStatus_Status. +var ( + PayloadStatus_Status_name = map[int32]string{ + 0: "UNKNOWN", + 1: "VALID", + 2: "INVALID", + 3: "SYNCING", + 4: "ACCEPTED", + 5: "INVALID_BLOCK_HASH", + } + PayloadStatus_Status_value = map[string]int32{ + "UNKNOWN": 0, + "VALID": 1, + "INVALID": 2, + "SYNCING": 3, + "ACCEPTED": 4, + "INVALID_BLOCK_HASH": 5, + } +) + +func (x PayloadStatus_Status) Enum() *PayloadStatus_Status { + p := new(PayloadStatus_Status) + *p = x + return p +} + +func (x PayloadStatus_Status) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (PayloadStatus_Status) Descriptor() protoreflect.EnumDescriptor { + return file_proto_engine_v1_execution_engine_proto_enumTypes[0].Descriptor() +} + +func (PayloadStatus_Status) Type() protoreflect.EnumType { + return &file_proto_engine_v1_execution_engine_proto_enumTypes[0] +} + +func (x PayloadStatus_Status) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use PayloadStatus_Status.Descriptor instead. +func (PayloadStatus_Status) EnumDescriptor() ([]byte, []int) { + return file_proto_engine_v1_execution_engine_proto_rawDescGZIP(), []int{15, 0} +} + +type ExecutionPayload struct { + state protoimpl.MessageState `protogen:"open.v1"` + ParentHash []byte `protobuf:"bytes,1,opt,name=parent_hash,json=parentHash,proto3" json:"parent_hash,omitempty" ssz-size:"32"` + FeeRecipient []byte `protobuf:"bytes,2,opt,name=fee_recipient,json=feeRecipient,proto3" json:"fee_recipient,omitempty" ssz-size:"20"` + StateRoot []byte `protobuf:"bytes,3,opt,name=state_root,json=stateRoot,proto3" json:"state_root,omitempty" ssz-size:"32"` + ReceiptsRoot []byte `protobuf:"bytes,4,opt,name=receipts_root,json=receiptsRoot,proto3" json:"receipts_root,omitempty" ssz-size:"32"` + LogsBloom []byte `protobuf:"bytes,5,opt,name=logs_bloom,json=logsBloom,proto3" json:"logs_bloom,omitempty" ssz-size:"256"` + PrevRandao []byte `protobuf:"bytes,6,opt,name=prev_randao,json=prevRandao,proto3" json:"prev_randao,omitempty" ssz-size:"32"` + BlockNumber uint64 `protobuf:"varint,7,opt,name=block_number,json=blockNumber,proto3" json:"block_number,omitempty"` + GasLimit uint64 `protobuf:"varint,8,opt,name=gas_limit,json=gasLimit,proto3" json:"gas_limit,omitempty"` + GasUsed uint64 `protobuf:"varint,9,opt,name=gas_used,json=gasUsed,proto3" json:"gas_used,omitempty"` + Timestamp uint64 `protobuf:"varint,10,opt,name=timestamp,proto3" json:"timestamp,omitempty"` + ExtraData []byte `protobuf:"bytes,11,opt,name=extra_data,json=extraData,proto3" json:"extra_data,omitempty" ssz-max:"32"` + BaseFeePerGas []byte `protobuf:"bytes,12,opt,name=base_fee_per_gas,json=baseFeePerGas,proto3" json:"base_fee_per_gas,omitempty" ssz-size:"32"` + BlockHash []byte `protobuf:"bytes,13,opt,name=block_hash,json=blockHash,proto3" json:"block_hash,omitempty" ssz-size:"32"` + Transactions [][]byte `protobuf:"bytes,14,rep,name=transactions,proto3" json:"transactions,omitempty" ssz-max:"1048576,1073741824" ssz-size:"?,?"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ExecutionPayload) Reset() { + *x = ExecutionPayload{} + mi := &file_proto_engine_v1_execution_engine_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ExecutionPayload) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ExecutionPayload) ProtoMessage() {} + +func (x *ExecutionPayload) ProtoReflect() protoreflect.Message { + mi := &file_proto_engine_v1_execution_engine_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ExecutionPayload.ProtoReflect.Descriptor instead. +func (*ExecutionPayload) Descriptor() ([]byte, []int) { + return file_proto_engine_v1_execution_engine_proto_rawDescGZIP(), []int{0} +} + +func (x *ExecutionPayload) GetParentHash() []byte { + if x != nil { + return x.ParentHash + } + return nil +} + +func (x *ExecutionPayload) GetFeeRecipient() []byte { + if x != nil { + return x.FeeRecipient + } + return nil +} + +func (x *ExecutionPayload) GetStateRoot() []byte { + if x != nil { + return x.StateRoot + } + return nil +} + +func (x *ExecutionPayload) GetReceiptsRoot() []byte { + if x != nil { + return x.ReceiptsRoot + } + return nil +} + +func (x *ExecutionPayload) GetLogsBloom() []byte { + if x != nil { + return x.LogsBloom + } + return nil +} + +func (x *ExecutionPayload) GetPrevRandao() []byte { + if x != nil { + return x.PrevRandao + } + return nil +} + +func (x *ExecutionPayload) GetBlockNumber() uint64 { + if x != nil { + return x.BlockNumber + } + return 0 +} + +func (x *ExecutionPayload) GetGasLimit() uint64 { + if x != nil { + return x.GasLimit + } + return 0 +} + +func (x *ExecutionPayload) GetGasUsed() uint64 { + if x != nil { + return x.GasUsed + } + return 0 +} + +func (x *ExecutionPayload) GetTimestamp() uint64 { + if x != nil { + return x.Timestamp + } + return 0 +} + +func (x *ExecutionPayload) GetExtraData() []byte { + if x != nil { + return x.ExtraData + } + return nil +} + +func (x *ExecutionPayload) GetBaseFeePerGas() []byte { + if x != nil { + return x.BaseFeePerGas + } + return nil +} + +func (x *ExecutionPayload) GetBlockHash() []byte { + if x != nil { + return x.BlockHash + } + return nil +} + +func (x *ExecutionPayload) GetTransactions() [][]byte { + if x != nil { + return x.Transactions + } + return nil +} + +type ExecutionPayloadCapella struct { + state protoimpl.MessageState `protogen:"open.v1"` + ParentHash []byte `protobuf:"bytes,1,opt,name=parent_hash,json=parentHash,proto3" json:"parent_hash,omitempty" ssz-size:"32"` + FeeRecipient []byte `protobuf:"bytes,2,opt,name=fee_recipient,json=feeRecipient,proto3" json:"fee_recipient,omitempty" ssz-size:"20"` + StateRoot []byte `protobuf:"bytes,3,opt,name=state_root,json=stateRoot,proto3" json:"state_root,omitempty" ssz-size:"32"` + ReceiptsRoot []byte `protobuf:"bytes,4,opt,name=receipts_root,json=receiptsRoot,proto3" json:"receipts_root,omitempty" ssz-size:"32"` + LogsBloom []byte `protobuf:"bytes,5,opt,name=logs_bloom,json=logsBloom,proto3" json:"logs_bloom,omitempty" ssz-size:"256"` + PrevRandao []byte `protobuf:"bytes,6,opt,name=prev_randao,json=prevRandao,proto3" json:"prev_randao,omitempty" ssz-size:"32"` + BlockNumber uint64 `protobuf:"varint,7,opt,name=block_number,json=blockNumber,proto3" json:"block_number,omitempty"` + GasLimit uint64 `protobuf:"varint,8,opt,name=gas_limit,json=gasLimit,proto3" json:"gas_limit,omitempty"` + GasUsed uint64 `protobuf:"varint,9,opt,name=gas_used,json=gasUsed,proto3" json:"gas_used,omitempty"` + Timestamp uint64 `protobuf:"varint,10,opt,name=timestamp,proto3" json:"timestamp,omitempty"` + ExtraData []byte `protobuf:"bytes,11,opt,name=extra_data,json=extraData,proto3" json:"extra_data,omitempty" ssz-max:"32"` + BaseFeePerGas []byte `protobuf:"bytes,12,opt,name=base_fee_per_gas,json=baseFeePerGas,proto3" json:"base_fee_per_gas,omitempty" ssz-size:"32"` + BlockHash []byte `protobuf:"bytes,13,opt,name=block_hash,json=blockHash,proto3" json:"block_hash,omitempty" ssz-size:"32"` + Transactions [][]byte `protobuf:"bytes,14,rep,name=transactions,proto3" json:"transactions,omitempty" ssz-max:"1048576,1073741824" ssz-size:"?,?"` + Withdrawals []*Withdrawal `protobuf:"bytes,15,rep,name=withdrawals,proto3" json:"withdrawals,omitempty" ssz-max:"4"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ExecutionPayloadCapella) Reset() { + *x = ExecutionPayloadCapella{} + mi := &file_proto_engine_v1_execution_engine_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ExecutionPayloadCapella) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ExecutionPayloadCapella) ProtoMessage() {} + +func (x *ExecutionPayloadCapella) ProtoReflect() protoreflect.Message { + mi := &file_proto_engine_v1_execution_engine_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ExecutionPayloadCapella.ProtoReflect.Descriptor instead. +func (*ExecutionPayloadCapella) Descriptor() ([]byte, []int) { + return file_proto_engine_v1_execution_engine_proto_rawDescGZIP(), []int{1} +} + +func (x *ExecutionPayloadCapella) GetParentHash() []byte { + if x != nil { + return x.ParentHash + } + return nil +} + +func (x *ExecutionPayloadCapella) GetFeeRecipient() []byte { + if x != nil { + return x.FeeRecipient + } + return nil +} + +func (x *ExecutionPayloadCapella) GetStateRoot() []byte { + if x != nil { + return x.StateRoot + } + return nil +} + +func (x *ExecutionPayloadCapella) GetReceiptsRoot() []byte { + if x != nil { + return x.ReceiptsRoot + } + return nil +} + +func (x *ExecutionPayloadCapella) GetLogsBloom() []byte { + if x != nil { + return x.LogsBloom + } + return nil +} + +func (x *ExecutionPayloadCapella) GetPrevRandao() []byte { + if x != nil { + return x.PrevRandao + } + return nil +} + +func (x *ExecutionPayloadCapella) GetBlockNumber() uint64 { + if x != nil { + return x.BlockNumber + } + return 0 +} + +func (x *ExecutionPayloadCapella) GetGasLimit() uint64 { + if x != nil { + return x.GasLimit + } + return 0 +} + +func (x *ExecutionPayloadCapella) GetGasUsed() uint64 { + if x != nil { + return x.GasUsed + } + return 0 +} + +func (x *ExecutionPayloadCapella) GetTimestamp() uint64 { + if x != nil { + return x.Timestamp + } + return 0 +} + +func (x *ExecutionPayloadCapella) GetExtraData() []byte { + if x != nil { + return x.ExtraData + } + return nil +} + +func (x *ExecutionPayloadCapella) GetBaseFeePerGas() []byte { + if x != nil { + return x.BaseFeePerGas + } + return nil +} + +func (x *ExecutionPayloadCapella) GetBlockHash() []byte { + if x != nil { + return x.BlockHash + } + return nil +} + +func (x *ExecutionPayloadCapella) GetTransactions() [][]byte { + if x != nil { + return x.Transactions + } + return nil +} + +func (x *ExecutionPayloadCapella) GetWithdrawals() []*Withdrawal { + if x != nil { + return x.Withdrawals + } + return nil +} + +type ExecutionPayloadDeneb struct { + state protoimpl.MessageState `protogen:"open.v1"` + ParentHash []byte `protobuf:"bytes,1,opt,name=parent_hash,json=parentHash,proto3" json:"parent_hash,omitempty" ssz-size:"32"` + FeeRecipient []byte `protobuf:"bytes,2,opt,name=fee_recipient,json=feeRecipient,proto3" json:"fee_recipient,omitempty" ssz-size:"20"` + StateRoot []byte `protobuf:"bytes,3,opt,name=state_root,json=stateRoot,proto3" json:"state_root,omitempty" ssz-size:"32"` + ReceiptsRoot []byte `protobuf:"bytes,4,opt,name=receipts_root,json=receiptsRoot,proto3" json:"receipts_root,omitempty" ssz-size:"32"` + LogsBloom []byte `protobuf:"bytes,5,opt,name=logs_bloom,json=logsBloom,proto3" json:"logs_bloom,omitempty" ssz-size:"256"` + PrevRandao []byte `protobuf:"bytes,6,opt,name=prev_randao,json=prevRandao,proto3" json:"prev_randao,omitempty" ssz-size:"32"` + BlockNumber uint64 `protobuf:"varint,7,opt,name=block_number,json=blockNumber,proto3" json:"block_number,omitempty"` + GasLimit uint64 `protobuf:"varint,8,opt,name=gas_limit,json=gasLimit,proto3" json:"gas_limit,omitempty"` + GasUsed uint64 `protobuf:"varint,9,opt,name=gas_used,json=gasUsed,proto3" json:"gas_used,omitempty"` + Timestamp uint64 `protobuf:"varint,10,opt,name=timestamp,proto3" json:"timestamp,omitempty"` + ExtraData []byte `protobuf:"bytes,11,opt,name=extra_data,json=extraData,proto3" json:"extra_data,omitempty" ssz-max:"32"` + BaseFeePerGas []byte `protobuf:"bytes,12,opt,name=base_fee_per_gas,json=baseFeePerGas,proto3" json:"base_fee_per_gas,omitempty" ssz-size:"32"` + BlockHash []byte `protobuf:"bytes,13,opt,name=block_hash,json=blockHash,proto3" json:"block_hash,omitempty" ssz-size:"32"` + Transactions [][]byte `protobuf:"bytes,14,rep,name=transactions,proto3" json:"transactions,omitempty" ssz-max:"1048576,1073741824" ssz-size:"?,?"` + Withdrawals []*Withdrawal `protobuf:"bytes,15,rep,name=withdrawals,proto3" json:"withdrawals,omitempty" ssz-max:"4"` + BlobGasUsed uint64 `protobuf:"varint,16,opt,name=blob_gas_used,json=blobGasUsed,proto3" json:"blob_gas_used,omitempty"` + ExcessBlobGas uint64 `protobuf:"varint,17,opt,name=excess_blob_gas,json=excessBlobGas,proto3" json:"excess_blob_gas,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ExecutionPayloadDeneb) Reset() { + *x = ExecutionPayloadDeneb{} + mi := &file_proto_engine_v1_execution_engine_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ExecutionPayloadDeneb) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ExecutionPayloadDeneb) ProtoMessage() {} + +func (x *ExecutionPayloadDeneb) ProtoReflect() protoreflect.Message { + mi := &file_proto_engine_v1_execution_engine_proto_msgTypes[2] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ExecutionPayloadDeneb.ProtoReflect.Descriptor instead. +func (*ExecutionPayloadDeneb) Descriptor() ([]byte, []int) { + return file_proto_engine_v1_execution_engine_proto_rawDescGZIP(), []int{2} +} + +func (x *ExecutionPayloadDeneb) GetParentHash() []byte { + if x != nil { + return x.ParentHash + } + return nil +} + +func (x *ExecutionPayloadDeneb) GetFeeRecipient() []byte { + if x != nil { + return x.FeeRecipient + } + return nil +} + +func (x *ExecutionPayloadDeneb) GetStateRoot() []byte { + if x != nil { + return x.StateRoot + } + return nil +} + +func (x *ExecutionPayloadDeneb) GetReceiptsRoot() []byte { + if x != nil { + return x.ReceiptsRoot + } + return nil +} + +func (x *ExecutionPayloadDeneb) GetLogsBloom() []byte { + if x != nil { + return x.LogsBloom + } + return nil +} + +func (x *ExecutionPayloadDeneb) GetPrevRandao() []byte { + if x != nil { + return x.PrevRandao + } + return nil +} + +func (x *ExecutionPayloadDeneb) GetBlockNumber() uint64 { + if x != nil { + return x.BlockNumber + } + return 0 +} + +func (x *ExecutionPayloadDeneb) GetGasLimit() uint64 { + if x != nil { + return x.GasLimit + } + return 0 +} + +func (x *ExecutionPayloadDeneb) GetGasUsed() uint64 { + if x != nil { + return x.GasUsed + } + return 0 +} + +func (x *ExecutionPayloadDeneb) GetTimestamp() uint64 { + if x != nil { + return x.Timestamp + } + return 0 +} + +func (x *ExecutionPayloadDeneb) GetExtraData() []byte { + if x != nil { + return x.ExtraData + } + return nil +} + +func (x *ExecutionPayloadDeneb) GetBaseFeePerGas() []byte { + if x != nil { + return x.BaseFeePerGas + } + return nil +} + +func (x *ExecutionPayloadDeneb) GetBlockHash() []byte { + if x != nil { + return x.BlockHash + } + return nil +} + +func (x *ExecutionPayloadDeneb) GetTransactions() [][]byte { + if x != nil { + return x.Transactions + } + return nil +} + +func (x *ExecutionPayloadDeneb) GetWithdrawals() []*Withdrawal { + if x != nil { + return x.Withdrawals + } + return nil +} + +func (x *ExecutionPayloadDeneb) GetBlobGasUsed() uint64 { + if x != nil { + return x.BlobGasUsed + } + return 0 +} + +func (x *ExecutionPayloadDeneb) GetExcessBlobGas() uint64 { + if x != nil { + return x.ExcessBlobGas + } + return 0 +} + +type ExecutionPayloadGloas struct { + state protoimpl.MessageState `protogen:"open.v1"` + ParentHash []byte `protobuf:"bytes,1,opt,name=parent_hash,json=parentHash,proto3" json:"parent_hash,omitempty" ssz-size:"32"` + FeeRecipient []byte `protobuf:"bytes,2,opt,name=fee_recipient,json=feeRecipient,proto3" json:"fee_recipient,omitempty" ssz-size:"20"` + StateRoot []byte `protobuf:"bytes,3,opt,name=state_root,json=stateRoot,proto3" json:"state_root,omitempty" ssz-size:"32"` + ReceiptsRoot []byte `protobuf:"bytes,4,opt,name=receipts_root,json=receiptsRoot,proto3" json:"receipts_root,omitempty" ssz-size:"32"` + LogsBloom []byte `protobuf:"bytes,5,opt,name=logs_bloom,json=logsBloom,proto3" json:"logs_bloom,omitempty" ssz-size:"256"` + PrevRandao []byte `protobuf:"bytes,6,opt,name=prev_randao,json=prevRandao,proto3" json:"prev_randao,omitempty" ssz-size:"32"` + BlockNumber uint64 `protobuf:"varint,7,opt,name=block_number,json=blockNumber,proto3" json:"block_number,omitempty"` + GasLimit uint64 `protobuf:"varint,8,opt,name=gas_limit,json=gasLimit,proto3" json:"gas_limit,omitempty"` + GasUsed uint64 `protobuf:"varint,9,opt,name=gas_used,json=gasUsed,proto3" json:"gas_used,omitempty"` + Timestamp uint64 `protobuf:"varint,10,opt,name=timestamp,proto3" json:"timestamp,omitempty"` + ExtraData []byte `protobuf:"bytes,11,opt,name=extra_data,json=extraData,proto3" json:"extra_data,omitempty" ssz-max:"32"` + BaseFeePerGas []byte `protobuf:"bytes,12,opt,name=base_fee_per_gas,json=baseFeePerGas,proto3" json:"base_fee_per_gas,omitempty" ssz-size:"32"` + BlockHash []byte `protobuf:"bytes,13,opt,name=block_hash,json=blockHash,proto3" json:"block_hash,omitempty" ssz-size:"32"` + Transactions [][]byte `protobuf:"bytes,14,rep,name=transactions,proto3" json:"transactions,omitempty" ssz-max:"1048576,1073741824" ssz-size:"?,?"` + Withdrawals []*Withdrawal `protobuf:"bytes,15,rep,name=withdrawals,proto3" json:"withdrawals,omitempty" ssz-max:"4"` + BlobGasUsed uint64 `protobuf:"varint,16,opt,name=blob_gas_used,json=blobGasUsed,proto3" json:"blob_gas_used,omitempty"` + ExcessBlobGas uint64 `protobuf:"varint,17,opt,name=excess_blob_gas,json=excessBlobGas,proto3" json:"excess_blob_gas,omitempty"` + BlockAccessList []byte `protobuf:"bytes,18,opt,name=block_access_list,json=blockAccessList,proto3" json:"block_access_list,omitempty" ssz-max:"1073741824"` + SlotNumber github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot `protobuf:"varint,19,opt,name=slot_number,json=slotNumber,proto3" json:"slot_number,omitempty" cast-type:"github.com/OffchainLabs/prysm/v7/consensus-types/primitives.Slot"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ExecutionPayloadGloas) Reset() { + *x = ExecutionPayloadGloas{} + mi := &file_proto_engine_v1_execution_engine_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ExecutionPayloadGloas) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ExecutionPayloadGloas) ProtoMessage() {} + +func (x *ExecutionPayloadGloas) ProtoReflect() protoreflect.Message { + mi := &file_proto_engine_v1_execution_engine_proto_msgTypes[3] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ExecutionPayloadGloas.ProtoReflect.Descriptor instead. +func (*ExecutionPayloadGloas) Descriptor() ([]byte, []int) { + return file_proto_engine_v1_execution_engine_proto_rawDescGZIP(), []int{3} +} + +func (x *ExecutionPayloadGloas) GetParentHash() []byte { + if x != nil { + return x.ParentHash + } + return nil +} + +func (x *ExecutionPayloadGloas) GetFeeRecipient() []byte { + if x != nil { + return x.FeeRecipient + } + return nil +} + +func (x *ExecutionPayloadGloas) GetStateRoot() []byte { + if x != nil { + return x.StateRoot + } + return nil +} + +func (x *ExecutionPayloadGloas) GetReceiptsRoot() []byte { + if x != nil { + return x.ReceiptsRoot + } + return nil +} + +func (x *ExecutionPayloadGloas) GetLogsBloom() []byte { + if x != nil { + return x.LogsBloom + } + return nil +} + +func (x *ExecutionPayloadGloas) GetPrevRandao() []byte { + if x != nil { + return x.PrevRandao + } + return nil +} + +func (x *ExecutionPayloadGloas) GetBlockNumber() uint64 { + if x != nil { + return x.BlockNumber + } + return 0 +} + +func (x *ExecutionPayloadGloas) GetGasLimit() uint64 { + if x != nil { + return x.GasLimit + } + return 0 +} + +func (x *ExecutionPayloadGloas) GetGasUsed() uint64 { + if x != nil { + return x.GasUsed + } + return 0 +} + +func (x *ExecutionPayloadGloas) GetTimestamp() uint64 { + if x != nil { + return x.Timestamp + } + return 0 +} + +func (x *ExecutionPayloadGloas) GetExtraData() []byte { + if x != nil { + return x.ExtraData + } + return nil +} + +func (x *ExecutionPayloadGloas) GetBaseFeePerGas() []byte { + if x != nil { + return x.BaseFeePerGas + } + return nil +} + +func (x *ExecutionPayloadGloas) GetBlockHash() []byte { + if x != nil { + return x.BlockHash + } + return nil +} + +func (x *ExecutionPayloadGloas) GetTransactions() [][]byte { + if x != nil { + return x.Transactions + } + return nil +} + +func (x *ExecutionPayloadGloas) GetWithdrawals() []*Withdrawal { + if x != nil { + return x.Withdrawals + } + return nil +} + +func (x *ExecutionPayloadGloas) GetBlobGasUsed() uint64 { + if x != nil { + return x.BlobGasUsed + } + return 0 +} + +func (x *ExecutionPayloadGloas) GetExcessBlobGas() uint64 { + if x != nil { + return x.ExcessBlobGas + } + return 0 +} + +func (x *ExecutionPayloadGloas) GetBlockAccessList() []byte { + if x != nil { + return x.BlockAccessList + } + return nil +} + +func (x *ExecutionPayloadGloas) GetSlotNumber() github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot { + if x != nil { + return x.SlotNumber + } + return github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot(0) +} + +type ExecutionPayloadCapellaWithValue struct { + state protoimpl.MessageState `protogen:"open.v1"` + Payload *ExecutionPayloadCapella `protobuf:"bytes,1,opt,name=payload,proto3" json:"payload,omitempty"` + Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ExecutionPayloadCapellaWithValue) Reset() { + *x = ExecutionPayloadCapellaWithValue{} + mi := &file_proto_engine_v1_execution_engine_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ExecutionPayloadCapellaWithValue) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ExecutionPayloadCapellaWithValue) ProtoMessage() {} + +func (x *ExecutionPayloadCapellaWithValue) ProtoReflect() protoreflect.Message { + mi := &file_proto_engine_v1_execution_engine_proto_msgTypes[4] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ExecutionPayloadCapellaWithValue.ProtoReflect.Descriptor instead. +func (*ExecutionPayloadCapellaWithValue) Descriptor() ([]byte, []int) { + return file_proto_engine_v1_execution_engine_proto_rawDescGZIP(), []int{4} +} + +func (x *ExecutionPayloadCapellaWithValue) GetPayload() *ExecutionPayloadCapella { + if x != nil { + return x.Payload + } + return nil +} + +func (x *ExecutionPayloadCapellaWithValue) GetValue() []byte { + if x != nil { + return x.Value + } + return nil +} + +type ExecutionPayloadDenebAndBlobsBundle struct { + state protoimpl.MessageState `protogen:"open.v1"` + Payload *ExecutionPayloadDeneb `protobuf:"bytes,1,opt,name=payload,proto3" json:"payload,omitempty"` + BlobsBundle *BlobsBundle `protobuf:"bytes,2,opt,name=blobs_bundle,json=blobsBundle,proto3" json:"blobs_bundle,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ExecutionPayloadDenebAndBlobsBundle) Reset() { + *x = ExecutionPayloadDenebAndBlobsBundle{} + mi := &file_proto_engine_v1_execution_engine_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ExecutionPayloadDenebAndBlobsBundle) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ExecutionPayloadDenebAndBlobsBundle) ProtoMessage() {} + +func (x *ExecutionPayloadDenebAndBlobsBundle) ProtoReflect() protoreflect.Message { + mi := &file_proto_engine_v1_execution_engine_proto_msgTypes[5] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ExecutionPayloadDenebAndBlobsBundle.ProtoReflect.Descriptor instead. +func (*ExecutionPayloadDenebAndBlobsBundle) Descriptor() ([]byte, []int) { + return file_proto_engine_v1_execution_engine_proto_rawDescGZIP(), []int{5} +} + +func (x *ExecutionPayloadDenebAndBlobsBundle) GetPayload() *ExecutionPayloadDeneb { + if x != nil { + return x.Payload + } + return nil +} + +func (x *ExecutionPayloadDenebAndBlobsBundle) GetBlobsBundle() *BlobsBundle { + if x != nil { + return x.BlobsBundle + } + return nil +} + +type ExecutionPayloadDenebAndBlobsBundleV2 struct { + state protoimpl.MessageState `protogen:"open.v1"` + Payload *ExecutionPayloadDeneb `protobuf:"bytes,1,opt,name=payload,proto3" json:"payload,omitempty"` + BlobsBundle *BlobsBundleV2 `protobuf:"bytes,2,opt,name=blobs_bundle,json=blobsBundle,proto3" json:"blobs_bundle,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ExecutionPayloadDenebAndBlobsBundleV2) Reset() { + *x = ExecutionPayloadDenebAndBlobsBundleV2{} + mi := &file_proto_engine_v1_execution_engine_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ExecutionPayloadDenebAndBlobsBundleV2) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ExecutionPayloadDenebAndBlobsBundleV2) ProtoMessage() {} + +func (x *ExecutionPayloadDenebAndBlobsBundleV2) ProtoReflect() protoreflect.Message { + mi := &file_proto_engine_v1_execution_engine_proto_msgTypes[6] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ExecutionPayloadDenebAndBlobsBundleV2.ProtoReflect.Descriptor instead. +func (*ExecutionPayloadDenebAndBlobsBundleV2) Descriptor() ([]byte, []int) { + return file_proto_engine_v1_execution_engine_proto_rawDescGZIP(), []int{6} +} + +func (x *ExecutionPayloadDenebAndBlobsBundleV2) GetPayload() *ExecutionPayloadDeneb { + if x != nil { + return x.Payload + } + return nil +} + +func (x *ExecutionPayloadDenebAndBlobsBundleV2) GetBlobsBundle() *BlobsBundleV2 { + if x != nil { + return x.BlobsBundle + } + return nil +} + +type ExecutionPayloadDenebWithValueAndBlobsBundle struct { + state protoimpl.MessageState `protogen:"open.v1"` + Payload *ExecutionPayloadDeneb `protobuf:"bytes,1,opt,name=payload,proto3" json:"payload,omitempty"` + Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` + BlobsBundle *BlobsBundle `protobuf:"bytes,3,opt,name=blobs_bundle,json=blobsBundle,proto3" json:"blobs_bundle,omitempty"` + ShouldOverrideBuilder bool `protobuf:"varint,4,opt,name=should_override_builder,json=shouldOverrideBuilder,proto3" json:"should_override_builder,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ExecutionPayloadDenebWithValueAndBlobsBundle) Reset() { + *x = ExecutionPayloadDenebWithValueAndBlobsBundle{} + mi := &file_proto_engine_v1_execution_engine_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ExecutionPayloadDenebWithValueAndBlobsBundle) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ExecutionPayloadDenebWithValueAndBlobsBundle) ProtoMessage() {} + +func (x *ExecutionPayloadDenebWithValueAndBlobsBundle) ProtoReflect() protoreflect.Message { + mi := &file_proto_engine_v1_execution_engine_proto_msgTypes[7] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ExecutionPayloadDenebWithValueAndBlobsBundle.ProtoReflect.Descriptor instead. +func (*ExecutionPayloadDenebWithValueAndBlobsBundle) Descriptor() ([]byte, []int) { + return file_proto_engine_v1_execution_engine_proto_rawDescGZIP(), []int{7} +} + +func (x *ExecutionPayloadDenebWithValueAndBlobsBundle) GetPayload() *ExecutionPayloadDeneb { + if x != nil { + return x.Payload + } + return nil +} + +func (x *ExecutionPayloadDenebWithValueAndBlobsBundle) GetValue() []byte { + if x != nil { + return x.Value + } + return nil +} + +func (x *ExecutionPayloadDenebWithValueAndBlobsBundle) GetBlobsBundle() *BlobsBundle { + if x != nil { + return x.BlobsBundle + } + return nil +} + +func (x *ExecutionPayloadDenebWithValueAndBlobsBundle) GetShouldOverrideBuilder() bool { + if x != nil { + return x.ShouldOverrideBuilder + } + return false +} + +type ExecutionPayloadHeader struct { + state protoimpl.MessageState `protogen:"open.v1"` + ParentHash []byte `protobuf:"bytes,1,opt,name=parent_hash,json=parentHash,proto3" json:"parent_hash,omitempty" ssz-size:"32"` + FeeRecipient []byte `protobuf:"bytes,2,opt,name=fee_recipient,json=feeRecipient,proto3" json:"fee_recipient,omitempty" ssz-size:"20"` + StateRoot []byte `protobuf:"bytes,3,opt,name=state_root,json=stateRoot,proto3" json:"state_root,omitempty" ssz-size:"32"` + ReceiptsRoot []byte `protobuf:"bytes,4,opt,name=receipts_root,json=receiptsRoot,proto3" json:"receipts_root,omitempty" ssz-size:"32"` + LogsBloom []byte `protobuf:"bytes,5,opt,name=logs_bloom,json=logsBloom,proto3" json:"logs_bloom,omitempty" ssz-size:"256"` + PrevRandao []byte `protobuf:"bytes,6,opt,name=prev_randao,json=prevRandao,proto3" json:"prev_randao,omitempty" ssz-size:"32"` + BlockNumber uint64 `protobuf:"varint,7,opt,name=block_number,json=blockNumber,proto3" json:"block_number,omitempty"` + GasLimit uint64 `protobuf:"varint,8,opt,name=gas_limit,json=gasLimit,proto3" json:"gas_limit,omitempty"` + GasUsed uint64 `protobuf:"varint,9,opt,name=gas_used,json=gasUsed,proto3" json:"gas_used,omitempty"` + Timestamp uint64 `protobuf:"varint,10,opt,name=timestamp,proto3" json:"timestamp,omitempty"` + ExtraData []byte `protobuf:"bytes,11,opt,name=extra_data,json=extraData,proto3" json:"extra_data,omitempty" ssz-max:"32"` + BaseFeePerGas []byte `protobuf:"bytes,12,opt,name=base_fee_per_gas,json=baseFeePerGas,proto3" json:"base_fee_per_gas,omitempty" ssz-size:"32"` + BlockHash []byte `protobuf:"bytes,13,opt,name=block_hash,json=blockHash,proto3" json:"block_hash,omitempty" ssz-size:"32"` + TransactionsRoot []byte `protobuf:"bytes,14,opt,name=transactions_root,json=transactionsRoot,proto3" json:"transactions_root,omitempty" ssz-size:"32"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ExecutionPayloadHeader) Reset() { + *x = ExecutionPayloadHeader{} + mi := &file_proto_engine_v1_execution_engine_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ExecutionPayloadHeader) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ExecutionPayloadHeader) ProtoMessage() {} + +func (x *ExecutionPayloadHeader) ProtoReflect() protoreflect.Message { + mi := &file_proto_engine_v1_execution_engine_proto_msgTypes[8] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ExecutionPayloadHeader.ProtoReflect.Descriptor instead. +func (*ExecutionPayloadHeader) Descriptor() ([]byte, []int) { + return file_proto_engine_v1_execution_engine_proto_rawDescGZIP(), []int{8} +} + +func (x *ExecutionPayloadHeader) GetParentHash() []byte { + if x != nil { + return x.ParentHash + } + return nil +} + +func (x *ExecutionPayloadHeader) GetFeeRecipient() []byte { + if x != nil { + return x.FeeRecipient + } + return nil +} + +func (x *ExecutionPayloadHeader) GetStateRoot() []byte { + if x != nil { + return x.StateRoot + } + return nil +} + +func (x *ExecutionPayloadHeader) GetReceiptsRoot() []byte { + if x != nil { + return x.ReceiptsRoot + } + return nil +} + +func (x *ExecutionPayloadHeader) GetLogsBloom() []byte { + if x != nil { + return x.LogsBloom + } + return nil +} + +func (x *ExecutionPayloadHeader) GetPrevRandao() []byte { + if x != nil { + return x.PrevRandao + } + return nil +} + +func (x *ExecutionPayloadHeader) GetBlockNumber() uint64 { + if x != nil { + return x.BlockNumber + } + return 0 +} + +func (x *ExecutionPayloadHeader) GetGasLimit() uint64 { + if x != nil { + return x.GasLimit + } + return 0 +} + +func (x *ExecutionPayloadHeader) GetGasUsed() uint64 { + if x != nil { + return x.GasUsed + } + return 0 +} + +func (x *ExecutionPayloadHeader) GetTimestamp() uint64 { + if x != nil { + return x.Timestamp + } + return 0 +} + +func (x *ExecutionPayloadHeader) GetExtraData() []byte { + if x != nil { + return x.ExtraData + } + return nil +} + +func (x *ExecutionPayloadHeader) GetBaseFeePerGas() []byte { + if x != nil { + return x.BaseFeePerGas + } + return nil +} + +func (x *ExecutionPayloadHeader) GetBlockHash() []byte { + if x != nil { + return x.BlockHash + } + return nil +} + +func (x *ExecutionPayloadHeader) GetTransactionsRoot() []byte { + if x != nil { + return x.TransactionsRoot + } + return nil +} + +type ExecutionPayloadHeaderCapella struct { + state protoimpl.MessageState `protogen:"open.v1"` + ParentHash []byte `protobuf:"bytes,1,opt,name=parent_hash,json=parentHash,proto3" json:"parent_hash,omitempty" ssz-size:"32"` + FeeRecipient []byte `protobuf:"bytes,2,opt,name=fee_recipient,json=feeRecipient,proto3" json:"fee_recipient,omitempty" ssz-size:"20"` + StateRoot []byte `protobuf:"bytes,3,opt,name=state_root,json=stateRoot,proto3" json:"state_root,omitempty" ssz-size:"32"` + ReceiptsRoot []byte `protobuf:"bytes,4,opt,name=receipts_root,json=receiptsRoot,proto3" json:"receipts_root,omitempty" ssz-size:"32"` + LogsBloom []byte `protobuf:"bytes,5,opt,name=logs_bloom,json=logsBloom,proto3" json:"logs_bloom,omitempty" ssz-size:"256"` + PrevRandao []byte `protobuf:"bytes,6,opt,name=prev_randao,json=prevRandao,proto3" json:"prev_randao,omitempty" ssz-size:"32"` + BlockNumber uint64 `protobuf:"varint,7,opt,name=block_number,json=blockNumber,proto3" json:"block_number,omitempty"` + GasLimit uint64 `protobuf:"varint,8,opt,name=gas_limit,json=gasLimit,proto3" json:"gas_limit,omitempty"` + GasUsed uint64 `protobuf:"varint,9,opt,name=gas_used,json=gasUsed,proto3" json:"gas_used,omitempty"` + Timestamp uint64 `protobuf:"varint,10,opt,name=timestamp,proto3" json:"timestamp,omitempty"` + ExtraData []byte `protobuf:"bytes,11,opt,name=extra_data,json=extraData,proto3" json:"extra_data,omitempty" ssz-max:"32"` + BaseFeePerGas []byte `protobuf:"bytes,12,opt,name=base_fee_per_gas,json=baseFeePerGas,proto3" json:"base_fee_per_gas,omitempty" ssz-size:"32"` + BlockHash []byte `protobuf:"bytes,13,opt,name=block_hash,json=blockHash,proto3" json:"block_hash,omitempty" ssz-size:"32"` + TransactionsRoot []byte `protobuf:"bytes,14,opt,name=transactions_root,json=transactionsRoot,proto3" json:"transactions_root,omitempty" ssz-size:"32"` + WithdrawalsRoot []byte `protobuf:"bytes,15,opt,name=withdrawals_root,json=withdrawalsRoot,proto3" json:"withdrawals_root,omitempty" ssz-size:"32"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ExecutionPayloadHeaderCapella) Reset() { + *x = ExecutionPayloadHeaderCapella{} + mi := &file_proto_engine_v1_execution_engine_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ExecutionPayloadHeaderCapella) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ExecutionPayloadHeaderCapella) ProtoMessage() {} + +func (x *ExecutionPayloadHeaderCapella) ProtoReflect() protoreflect.Message { + mi := &file_proto_engine_v1_execution_engine_proto_msgTypes[9] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ExecutionPayloadHeaderCapella.ProtoReflect.Descriptor instead. +func (*ExecutionPayloadHeaderCapella) Descriptor() ([]byte, []int) { + return file_proto_engine_v1_execution_engine_proto_rawDescGZIP(), []int{9} +} + +func (x *ExecutionPayloadHeaderCapella) GetParentHash() []byte { + if x != nil { + return x.ParentHash + } + return nil +} + +func (x *ExecutionPayloadHeaderCapella) GetFeeRecipient() []byte { + if x != nil { + return x.FeeRecipient + } + return nil +} + +func (x *ExecutionPayloadHeaderCapella) GetStateRoot() []byte { + if x != nil { + return x.StateRoot + } + return nil +} + +func (x *ExecutionPayloadHeaderCapella) GetReceiptsRoot() []byte { + if x != nil { + return x.ReceiptsRoot + } + return nil +} + +func (x *ExecutionPayloadHeaderCapella) GetLogsBloom() []byte { + if x != nil { + return x.LogsBloom + } + return nil +} + +func (x *ExecutionPayloadHeaderCapella) GetPrevRandao() []byte { + if x != nil { + return x.PrevRandao + } + return nil +} + +func (x *ExecutionPayloadHeaderCapella) GetBlockNumber() uint64 { + if x != nil { + return x.BlockNumber + } + return 0 +} + +func (x *ExecutionPayloadHeaderCapella) GetGasLimit() uint64 { + if x != nil { + return x.GasLimit + } + return 0 +} + +func (x *ExecutionPayloadHeaderCapella) GetGasUsed() uint64 { + if x != nil { + return x.GasUsed + } + return 0 +} + +func (x *ExecutionPayloadHeaderCapella) GetTimestamp() uint64 { + if x != nil { + return x.Timestamp + } + return 0 +} + +func (x *ExecutionPayloadHeaderCapella) GetExtraData() []byte { + if x != nil { + return x.ExtraData + } + return nil +} + +func (x *ExecutionPayloadHeaderCapella) GetBaseFeePerGas() []byte { + if x != nil { + return x.BaseFeePerGas + } + return nil +} + +func (x *ExecutionPayloadHeaderCapella) GetBlockHash() []byte { + if x != nil { + return x.BlockHash + } + return nil +} + +func (x *ExecutionPayloadHeaderCapella) GetTransactionsRoot() []byte { + if x != nil { + return x.TransactionsRoot + } + return nil +} + +func (x *ExecutionPayloadHeaderCapella) GetWithdrawalsRoot() []byte { + if x != nil { + return x.WithdrawalsRoot + } + return nil +} + +type ExecutionPayloadHeaderDeneb struct { + state protoimpl.MessageState `protogen:"open.v1"` + ParentHash []byte `protobuf:"bytes,1,opt,name=parent_hash,json=parentHash,proto3" json:"parent_hash,omitempty" ssz-size:"32"` + FeeRecipient []byte `protobuf:"bytes,2,opt,name=fee_recipient,json=feeRecipient,proto3" json:"fee_recipient,omitempty" ssz-size:"20"` + StateRoot []byte `protobuf:"bytes,3,opt,name=state_root,json=stateRoot,proto3" json:"state_root,omitempty" ssz-size:"32"` + ReceiptsRoot []byte `protobuf:"bytes,4,opt,name=receipts_root,json=receiptsRoot,proto3" json:"receipts_root,omitempty" ssz-size:"32"` + LogsBloom []byte `protobuf:"bytes,5,opt,name=logs_bloom,json=logsBloom,proto3" json:"logs_bloom,omitempty" ssz-size:"256"` + PrevRandao []byte `protobuf:"bytes,6,opt,name=prev_randao,json=prevRandao,proto3" json:"prev_randao,omitempty" ssz-size:"32"` + BlockNumber uint64 `protobuf:"varint,7,opt,name=block_number,json=blockNumber,proto3" json:"block_number,omitempty"` + GasLimit uint64 `protobuf:"varint,8,opt,name=gas_limit,json=gasLimit,proto3" json:"gas_limit,omitempty"` + GasUsed uint64 `protobuf:"varint,9,opt,name=gas_used,json=gasUsed,proto3" json:"gas_used,omitempty"` + Timestamp uint64 `protobuf:"varint,10,opt,name=timestamp,proto3" json:"timestamp,omitempty"` + ExtraData []byte `protobuf:"bytes,11,opt,name=extra_data,json=extraData,proto3" json:"extra_data,omitempty" ssz-max:"32"` + BaseFeePerGas []byte `protobuf:"bytes,12,opt,name=base_fee_per_gas,json=baseFeePerGas,proto3" json:"base_fee_per_gas,omitempty" ssz-size:"32"` + BlockHash []byte `protobuf:"bytes,13,opt,name=block_hash,json=blockHash,proto3" json:"block_hash,omitempty" ssz-size:"32"` + TransactionsRoot []byte `protobuf:"bytes,14,opt,name=transactions_root,json=transactionsRoot,proto3" json:"transactions_root,omitempty" ssz-size:"32"` + WithdrawalsRoot []byte `protobuf:"bytes,15,opt,name=withdrawals_root,json=withdrawalsRoot,proto3" json:"withdrawals_root,omitempty" ssz-size:"32"` + BlobGasUsed uint64 `protobuf:"varint,16,opt,name=blob_gas_used,json=blobGasUsed,proto3" json:"blob_gas_used,omitempty"` + ExcessBlobGas uint64 `protobuf:"varint,17,opt,name=excess_blob_gas,json=excessBlobGas,proto3" json:"excess_blob_gas,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ExecutionPayloadHeaderDeneb) Reset() { + *x = ExecutionPayloadHeaderDeneb{} + mi := &file_proto_engine_v1_execution_engine_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ExecutionPayloadHeaderDeneb) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ExecutionPayloadHeaderDeneb) ProtoMessage() {} + +func (x *ExecutionPayloadHeaderDeneb) ProtoReflect() protoreflect.Message { + mi := &file_proto_engine_v1_execution_engine_proto_msgTypes[10] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ExecutionPayloadHeaderDeneb.ProtoReflect.Descriptor instead. +func (*ExecutionPayloadHeaderDeneb) Descriptor() ([]byte, []int) { + return file_proto_engine_v1_execution_engine_proto_rawDescGZIP(), []int{10} +} + +func (x *ExecutionPayloadHeaderDeneb) GetParentHash() []byte { + if x != nil { + return x.ParentHash + } + return nil +} + +func (x *ExecutionPayloadHeaderDeneb) GetFeeRecipient() []byte { + if x != nil { + return x.FeeRecipient + } + return nil +} + +func (x *ExecutionPayloadHeaderDeneb) GetStateRoot() []byte { + if x != nil { + return x.StateRoot + } + return nil +} + +func (x *ExecutionPayloadHeaderDeneb) GetReceiptsRoot() []byte { + if x != nil { + return x.ReceiptsRoot + } + return nil +} + +func (x *ExecutionPayloadHeaderDeneb) GetLogsBloom() []byte { + if x != nil { + return x.LogsBloom + } + return nil +} + +func (x *ExecutionPayloadHeaderDeneb) GetPrevRandao() []byte { + if x != nil { + return x.PrevRandao + } + return nil +} + +func (x *ExecutionPayloadHeaderDeneb) GetBlockNumber() uint64 { + if x != nil { + return x.BlockNumber + } + return 0 +} + +func (x *ExecutionPayloadHeaderDeneb) GetGasLimit() uint64 { + if x != nil { + return x.GasLimit + } + return 0 +} + +func (x *ExecutionPayloadHeaderDeneb) GetGasUsed() uint64 { + if x != nil { + return x.GasUsed + } + return 0 +} + +func (x *ExecutionPayloadHeaderDeneb) GetTimestamp() uint64 { + if x != nil { + return x.Timestamp + } + return 0 +} + +func (x *ExecutionPayloadHeaderDeneb) GetExtraData() []byte { + if x != nil { + return x.ExtraData + } + return nil +} + +func (x *ExecutionPayloadHeaderDeneb) GetBaseFeePerGas() []byte { + if x != nil { + return x.BaseFeePerGas + } + return nil +} + +func (x *ExecutionPayloadHeaderDeneb) GetBlockHash() []byte { + if x != nil { + return x.BlockHash + } + return nil +} + +func (x *ExecutionPayloadHeaderDeneb) GetTransactionsRoot() []byte { + if x != nil { + return x.TransactionsRoot + } + return nil +} + +func (x *ExecutionPayloadHeaderDeneb) GetWithdrawalsRoot() []byte { + if x != nil { + return x.WithdrawalsRoot + } + return nil +} + +func (x *ExecutionPayloadHeaderDeneb) GetBlobGasUsed() uint64 { + if x != nil { + return x.BlobGasUsed + } + return 0 +} + +func (x *ExecutionPayloadHeaderDeneb) GetExcessBlobGas() uint64 { + if x != nil { + return x.ExcessBlobGas + } + return 0 +} + +type PayloadAttributes struct { + state protoimpl.MessageState `protogen:"open.v1"` + Timestamp uint64 `protobuf:"varint,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"` + PrevRandao []byte `protobuf:"bytes,2,opt,name=prev_randao,json=prevRandao,proto3" json:"prev_randao,omitempty" ssz-size:"32"` + SuggestedFeeRecipient []byte `protobuf:"bytes,3,opt,name=suggested_fee_recipient,json=suggestedFeeRecipient,proto3" json:"suggested_fee_recipient,omitempty" ssz-size:"20"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *PayloadAttributes) Reset() { + *x = PayloadAttributes{} + mi := &file_proto_engine_v1_execution_engine_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *PayloadAttributes) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PayloadAttributes) ProtoMessage() {} + +func (x *PayloadAttributes) ProtoReflect() protoreflect.Message { + mi := &file_proto_engine_v1_execution_engine_proto_msgTypes[11] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PayloadAttributes.ProtoReflect.Descriptor instead. +func (*PayloadAttributes) Descriptor() ([]byte, []int) { + return file_proto_engine_v1_execution_engine_proto_rawDescGZIP(), []int{11} +} + +func (x *PayloadAttributes) GetTimestamp() uint64 { + if x != nil { + return x.Timestamp + } + return 0 +} + +func (x *PayloadAttributes) GetPrevRandao() []byte { + if x != nil { + return x.PrevRandao + } + return nil +} + +func (x *PayloadAttributes) GetSuggestedFeeRecipient() []byte { + if x != nil { + return x.SuggestedFeeRecipient + } + return nil +} + +type PayloadAttributesV2 struct { + state protoimpl.MessageState `protogen:"open.v1"` + Timestamp uint64 `protobuf:"varint,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"` + PrevRandao []byte `protobuf:"bytes,2,opt,name=prev_randao,json=prevRandao,proto3" json:"prev_randao,omitempty" ssz-size:"32"` + SuggestedFeeRecipient []byte `protobuf:"bytes,3,opt,name=suggested_fee_recipient,json=suggestedFeeRecipient,proto3" json:"suggested_fee_recipient,omitempty" ssz-size:"20"` + Withdrawals []*Withdrawal `protobuf:"bytes,4,rep,name=withdrawals,proto3" json:"withdrawals,omitempty" ssz-max:"4"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *PayloadAttributesV2) Reset() { + *x = PayloadAttributesV2{} + mi := &file_proto_engine_v1_execution_engine_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *PayloadAttributesV2) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PayloadAttributesV2) ProtoMessage() {} + +func (x *PayloadAttributesV2) ProtoReflect() protoreflect.Message { + mi := &file_proto_engine_v1_execution_engine_proto_msgTypes[12] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PayloadAttributesV2.ProtoReflect.Descriptor instead. +func (*PayloadAttributesV2) Descriptor() ([]byte, []int) { + return file_proto_engine_v1_execution_engine_proto_rawDescGZIP(), []int{12} +} + +func (x *PayloadAttributesV2) GetTimestamp() uint64 { + if x != nil { + return x.Timestamp + } + return 0 +} + +func (x *PayloadAttributesV2) GetPrevRandao() []byte { + if x != nil { + return x.PrevRandao + } + return nil +} + +func (x *PayloadAttributesV2) GetSuggestedFeeRecipient() []byte { + if x != nil { + return x.SuggestedFeeRecipient + } + return nil +} + +func (x *PayloadAttributesV2) GetWithdrawals() []*Withdrawal { + if x != nil { + return x.Withdrawals + } + return nil +} + +type PayloadAttributesV3 struct { + state protoimpl.MessageState `protogen:"open.v1"` + Timestamp uint64 `protobuf:"varint,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"` + PrevRandao []byte `protobuf:"bytes,2,opt,name=prev_randao,json=prevRandao,proto3" json:"prev_randao,omitempty" ssz-size:"32"` + SuggestedFeeRecipient []byte `protobuf:"bytes,3,opt,name=suggested_fee_recipient,json=suggestedFeeRecipient,proto3" json:"suggested_fee_recipient,omitempty" ssz-size:"20"` + Withdrawals []*Withdrawal `protobuf:"bytes,4,rep,name=withdrawals,proto3" json:"withdrawals,omitempty" ssz-max:"4"` + ParentBeaconBlockRoot []byte `protobuf:"bytes,5,opt,name=parent_beacon_block_root,json=parentBeaconBlockRoot,proto3" json:"parent_beacon_block_root,omitempty" ssz-size:"32"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *PayloadAttributesV3) Reset() { + *x = PayloadAttributesV3{} + mi := &file_proto_engine_v1_execution_engine_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *PayloadAttributesV3) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PayloadAttributesV3) ProtoMessage() {} + +func (x *PayloadAttributesV3) ProtoReflect() protoreflect.Message { + mi := &file_proto_engine_v1_execution_engine_proto_msgTypes[13] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PayloadAttributesV3.ProtoReflect.Descriptor instead. +func (*PayloadAttributesV3) Descriptor() ([]byte, []int) { + return file_proto_engine_v1_execution_engine_proto_rawDescGZIP(), []int{13} +} + +func (x *PayloadAttributesV3) GetTimestamp() uint64 { + if x != nil { + return x.Timestamp + } + return 0 +} + +func (x *PayloadAttributesV3) GetPrevRandao() []byte { + if x != nil { + return x.PrevRandao + } + return nil +} + +func (x *PayloadAttributesV3) GetSuggestedFeeRecipient() []byte { + if x != nil { + return x.SuggestedFeeRecipient + } + return nil +} + +func (x *PayloadAttributesV3) GetWithdrawals() []*Withdrawal { + if x != nil { + return x.Withdrawals + } + return nil +} + +func (x *PayloadAttributesV3) GetParentBeaconBlockRoot() []byte { + if x != nil { + return x.ParentBeaconBlockRoot + } + return nil +} + +type PayloadAttributesV4 struct { + state protoimpl.MessageState `protogen:"open.v1"` + Timestamp uint64 `protobuf:"varint,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"` + PrevRandao []byte `protobuf:"bytes,2,opt,name=prev_randao,json=prevRandao,proto3" json:"prev_randao,omitempty" ssz-size:"32"` + SuggestedFeeRecipient []byte `protobuf:"bytes,3,opt,name=suggested_fee_recipient,json=suggestedFeeRecipient,proto3" json:"suggested_fee_recipient,omitempty" ssz-size:"20"` + Withdrawals []*Withdrawal `protobuf:"bytes,4,rep,name=withdrawals,proto3" json:"withdrawals,omitempty" ssz-max:"4"` + ParentBeaconBlockRoot []byte `protobuf:"bytes,5,opt,name=parent_beacon_block_root,json=parentBeaconBlockRoot,proto3" json:"parent_beacon_block_root,omitempty" ssz-size:"32"` + SlotNumber uint64 `protobuf:"varint,6,opt,name=slot_number,json=slotNumber,proto3" json:"slot_number,omitempty"` + TargetGasLimit uint64 `protobuf:"varint,7,opt,name=target_gas_limit,json=targetGasLimit,proto3" json:"target_gas_limit,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *PayloadAttributesV4) Reset() { + *x = PayloadAttributesV4{} + mi := &file_proto_engine_v1_execution_engine_proto_msgTypes[14] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *PayloadAttributesV4) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PayloadAttributesV4) ProtoMessage() {} + +func (x *PayloadAttributesV4) ProtoReflect() protoreflect.Message { + mi := &file_proto_engine_v1_execution_engine_proto_msgTypes[14] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PayloadAttributesV4.ProtoReflect.Descriptor instead. +func (*PayloadAttributesV4) Descriptor() ([]byte, []int) { + return file_proto_engine_v1_execution_engine_proto_rawDescGZIP(), []int{14} +} + +func (x *PayloadAttributesV4) GetTimestamp() uint64 { + if x != nil { + return x.Timestamp + } + return 0 +} + +func (x *PayloadAttributesV4) GetPrevRandao() []byte { + if x != nil { + return x.PrevRandao + } + return nil +} + +func (x *PayloadAttributesV4) GetSuggestedFeeRecipient() []byte { + if x != nil { + return x.SuggestedFeeRecipient + } + return nil +} + +func (x *PayloadAttributesV4) GetWithdrawals() []*Withdrawal { + if x != nil { + return x.Withdrawals + } + return nil +} + +func (x *PayloadAttributesV4) GetParentBeaconBlockRoot() []byte { + if x != nil { + return x.ParentBeaconBlockRoot + } + return nil +} + +func (x *PayloadAttributesV4) GetSlotNumber() uint64 { + if x != nil { + return x.SlotNumber + } + return 0 +} + +func (x *PayloadAttributesV4) GetTargetGasLimit() uint64 { + if x != nil { + return x.TargetGasLimit + } + return 0 +} + +type PayloadStatus struct { + state protoimpl.MessageState `protogen:"open.v1"` + Status PayloadStatus_Status `protobuf:"varint,1,opt,name=status,proto3,enum=ethereum.engine.v1.PayloadStatus_Status" json:"status,omitempty"` + LatestValidHash []byte `protobuf:"bytes,2,opt,name=latest_valid_hash,json=latestValidHash,proto3" json:"latest_valid_hash,omitempty" ssz-size:"32"` + ValidationError string `protobuf:"bytes,3,opt,name=validation_error,json=validationError,proto3" json:"validation_error,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *PayloadStatus) Reset() { + *x = PayloadStatus{} + mi := &file_proto_engine_v1_execution_engine_proto_msgTypes[15] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *PayloadStatus) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PayloadStatus) ProtoMessage() {} + +func (x *PayloadStatus) ProtoReflect() protoreflect.Message { + mi := &file_proto_engine_v1_execution_engine_proto_msgTypes[15] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PayloadStatus.ProtoReflect.Descriptor instead. +func (*PayloadStatus) Descriptor() ([]byte, []int) { + return file_proto_engine_v1_execution_engine_proto_rawDescGZIP(), []int{15} +} + +func (x *PayloadStatus) GetStatus() PayloadStatus_Status { + if x != nil { + return x.Status + } + return PayloadStatus_UNKNOWN +} + +func (x *PayloadStatus) GetLatestValidHash() []byte { + if x != nil { + return x.LatestValidHash + } + return nil +} + +func (x *PayloadStatus) GetValidationError() string { + if x != nil { + return x.ValidationError + } + return "" +} + +type ForkchoiceState struct { + state protoimpl.MessageState `protogen:"open.v1"` + HeadBlockHash []byte `protobuf:"bytes,1,opt,name=head_block_hash,json=headBlockHash,proto3" json:"head_block_hash,omitempty" ssz-size:"32"` + SafeBlockHash []byte `protobuf:"bytes,2,opt,name=safe_block_hash,json=safeBlockHash,proto3" json:"safe_block_hash,omitempty" ssz-size:"32"` + FinalizedBlockHash []byte `protobuf:"bytes,3,opt,name=finalized_block_hash,json=finalizedBlockHash,proto3" json:"finalized_block_hash,omitempty" ssz-size:"32"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ForkchoiceState) Reset() { + *x = ForkchoiceState{} + mi := &file_proto_engine_v1_execution_engine_proto_msgTypes[16] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ForkchoiceState) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ForkchoiceState) ProtoMessage() {} + +func (x *ForkchoiceState) ProtoReflect() protoreflect.Message { + mi := &file_proto_engine_v1_execution_engine_proto_msgTypes[16] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ForkchoiceState.ProtoReflect.Descriptor instead. +func (*ForkchoiceState) Descriptor() ([]byte, []int) { + return file_proto_engine_v1_execution_engine_proto_rawDescGZIP(), []int{16} +} + +func (x *ForkchoiceState) GetHeadBlockHash() []byte { + if x != nil { + return x.HeadBlockHash + } + return nil +} + +func (x *ForkchoiceState) GetSafeBlockHash() []byte { + if x != nil { + return x.SafeBlockHash + } + return nil +} + +func (x *ForkchoiceState) GetFinalizedBlockHash() []byte { + if x != nil { + return x.FinalizedBlockHash + } + return nil +} + +type Withdrawal struct { + state protoimpl.MessageState `protogen:"open.v1"` + Index uint64 `protobuf:"varint,1,opt,name=index,proto3" json:"index,omitempty"` + ValidatorIndex github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex `protobuf:"varint,2,opt,name=validator_index,json=validatorIndex,proto3" json:"validator_index,omitempty" cast-type:"github.com/OffchainLabs/prysm/v7/consensus-types/primitives.ValidatorIndex"` + Address []byte `protobuf:"bytes,3,opt,name=address,proto3" json:"address,omitempty" ssz-size:"20"` + Amount uint64 `protobuf:"varint,4,opt,name=amount,proto3" json:"amount,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Withdrawal) Reset() { + *x = Withdrawal{} + mi := &file_proto_engine_v1_execution_engine_proto_msgTypes[17] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Withdrawal) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Withdrawal) ProtoMessage() {} + +func (x *Withdrawal) ProtoReflect() protoreflect.Message { + mi := &file_proto_engine_v1_execution_engine_proto_msgTypes[17] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Withdrawal.ProtoReflect.Descriptor instead. +func (*Withdrawal) Descriptor() ([]byte, []int) { + return file_proto_engine_v1_execution_engine_proto_rawDescGZIP(), []int{17} +} + +func (x *Withdrawal) GetIndex() uint64 { + if x != nil { + return x.Index + } + return 0 +} + +func (x *Withdrawal) GetValidatorIndex() github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex { + if x != nil { + return x.ValidatorIndex + } + return github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex(0) +} + +func (x *Withdrawal) GetAddress() []byte { + if x != nil { + return x.Address + } + return nil +} + +func (x *Withdrawal) GetAmount() uint64 { + if x != nil { + return x.Amount + } + return 0 +} + +type BlobsBundle struct { + state protoimpl.MessageState `protogen:"open.v1"` + KzgCommitments [][]byte `protobuf:"bytes,1,rep,name=kzg_commitments,json=kzgCommitments,proto3" json:"kzg_commitments,omitempty" ssz-max:"4096" ssz-size:"?,48"` + Proofs [][]byte `protobuf:"bytes,2,rep,name=proofs,proto3" json:"proofs,omitempty" ssz-max:"4096" ssz-size:"?,48"` + Blobs [][]byte `protobuf:"bytes,3,rep,name=blobs,proto3" json:"blobs,omitempty" ssz-max:"4096" ssz-size:"?,131072"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *BlobsBundle) Reset() { + *x = BlobsBundle{} + mi := &file_proto_engine_v1_execution_engine_proto_msgTypes[18] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *BlobsBundle) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*BlobsBundle) ProtoMessage() {} + +func (x *BlobsBundle) ProtoReflect() protoreflect.Message { + mi := &file_proto_engine_v1_execution_engine_proto_msgTypes[18] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use BlobsBundle.ProtoReflect.Descriptor instead. +func (*BlobsBundle) Descriptor() ([]byte, []int) { + return file_proto_engine_v1_execution_engine_proto_rawDescGZIP(), []int{18} +} + +func (x *BlobsBundle) GetKzgCommitments() [][]byte { + if x != nil { + return x.KzgCommitments + } + return nil +} + +func (x *BlobsBundle) GetProofs() [][]byte { + if x != nil { + return x.Proofs + } + return nil +} + +func (x *BlobsBundle) GetBlobs() [][]byte { + if x != nil { + return x.Blobs + } + return nil +} + +type BlobsBundleV2 struct { + state protoimpl.MessageState `protogen:"open.v1"` + KzgCommitments [][]byte `protobuf:"bytes,1,rep,name=kzg_commitments,json=kzgCommitments,proto3" json:"kzg_commitments,omitempty" ssz-max:"4096" ssz-size:"?,48"` + Proofs [][]byte `protobuf:"bytes,2,rep,name=proofs,proto3" json:"proofs,omitempty" ssz-max:"33554432" ssz-size:"?,48"` + Blobs [][]byte `protobuf:"bytes,3,rep,name=blobs,proto3" json:"blobs,omitempty" ssz-max:"4096" ssz-size:"?,131072"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *BlobsBundleV2) Reset() { + *x = BlobsBundleV2{} + mi := &file_proto_engine_v1_execution_engine_proto_msgTypes[19] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *BlobsBundleV2) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*BlobsBundleV2) ProtoMessage() {} + +func (x *BlobsBundleV2) ProtoReflect() protoreflect.Message { + mi := &file_proto_engine_v1_execution_engine_proto_msgTypes[19] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use BlobsBundleV2.ProtoReflect.Descriptor instead. +func (*BlobsBundleV2) Descriptor() ([]byte, []int) { + return file_proto_engine_v1_execution_engine_proto_rawDescGZIP(), []int{19} +} + +func (x *BlobsBundleV2) GetKzgCommitments() [][]byte { + if x != nil { + return x.KzgCommitments + } + return nil +} + +func (x *BlobsBundleV2) GetProofs() [][]byte { + if x != nil { + return x.Proofs + } + return nil +} + +func (x *BlobsBundleV2) GetBlobs() [][]byte { + if x != nil { + return x.Blobs + } + return nil +} + +type Blob struct { + state protoimpl.MessageState `protogen:"open.v1"` + Data []byte `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty" ssz-size:"131072"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Blob) Reset() { + *x = Blob{} + mi := &file_proto_engine_v1_execution_engine_proto_msgTypes[20] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Blob) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Blob) ProtoMessage() {} + +func (x *Blob) ProtoReflect() protoreflect.Message { + mi := &file_proto_engine_v1_execution_engine_proto_msgTypes[20] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Blob.ProtoReflect.Descriptor instead. +func (*Blob) Descriptor() ([]byte, []int) { + return file_proto_engine_v1_execution_engine_proto_rawDescGZIP(), []int{20} +} + +func (x *Blob) GetData() []byte { + if x != nil { + return x.Data + } + return nil +} + +type BlobAndProof struct { + state protoimpl.MessageState `protogen:"open.v1"` + Blob []byte `protobuf:"bytes,1,opt,name=blob,proto3" json:"blob,omitempty" ssz-size:"131072"` + KzgProof []byte `protobuf:"bytes,2,opt,name=kzg_proof,json=kzgProof,proto3" json:"kzg_proof,omitempty" ssz-size:"48"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *BlobAndProof) Reset() { + *x = BlobAndProof{} + mi := &file_proto_engine_v1_execution_engine_proto_msgTypes[21] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *BlobAndProof) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*BlobAndProof) ProtoMessage() {} + +func (x *BlobAndProof) ProtoReflect() protoreflect.Message { + mi := &file_proto_engine_v1_execution_engine_proto_msgTypes[21] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use BlobAndProof.ProtoReflect.Descriptor instead. +func (*BlobAndProof) Descriptor() ([]byte, []int) { + return file_proto_engine_v1_execution_engine_proto_rawDescGZIP(), []int{21} +} + +func (x *BlobAndProof) GetBlob() []byte { + if x != nil { + return x.Blob + } + return nil +} + +func (x *BlobAndProof) GetKzgProof() []byte { + if x != nil { + return x.KzgProof + } + return nil +} + +type BlobAndProofV2 struct { + state protoimpl.MessageState `protogen:"open.v1"` + Blob []byte `protobuf:"bytes,1,opt,name=blob,proto3" json:"blob,omitempty" ssz-size:"131072"` + KzgProofs [][]byte `protobuf:"bytes,2,rep,name=kzg_proofs,json=kzgProofs,proto3" json:"kzg_proofs,omitempty" ssz-max:"33554432" ssz-size:"48"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *BlobAndProofV2) Reset() { + *x = BlobAndProofV2{} + mi := &file_proto_engine_v1_execution_engine_proto_msgTypes[22] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *BlobAndProofV2) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*BlobAndProofV2) ProtoMessage() {} + +func (x *BlobAndProofV2) ProtoReflect() protoreflect.Message { + mi := &file_proto_engine_v1_execution_engine_proto_msgTypes[22] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use BlobAndProofV2.ProtoReflect.Descriptor instead. +func (*BlobAndProofV2) Descriptor() ([]byte, []int) { + return file_proto_engine_v1_execution_engine_proto_rawDescGZIP(), []int{22} +} + +func (x *BlobAndProofV2) GetBlob() []byte { + if x != nil { + return x.Blob + } + return nil +} + +func (x *BlobAndProofV2) GetKzgProofs() [][]byte { + if x != nil { + return x.KzgProofs + } + return nil +} + +var File_proto_engine_v1_execution_engine_proto protoreflect.FileDescriptor + +var file_proto_engine_v1_execution_engine_proto_rawDesc = []byte{ + 0x0a, 0x26, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x2f, 0x76, + 0x31, 0x2f, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x65, 0x6e, 0x67, 0x69, + 0x6e, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x12, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, + 0x75, 0x6d, 0x2e, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x1a, 0x1b, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x74, 0x68, 0x2f, 0x65, 0x78, 0x74, 0x2f, 0x6f, 0x70, 0x74, 0x69, + 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xc8, 0x04, 0x0a, 0x10, 0x45, 0x78, + 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x27, + 0x0a, 0x0b, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x0a, 0x70, 0x61, 0x72, + 0x65, 0x6e, 0x74, 0x48, 0x61, 0x73, 0x68, 0x12, 0x2b, 0x0a, 0x0d, 0x66, 0x65, 0x65, 0x5f, 0x72, + 0x65, 0x63, 0x69, 0x70, 0x69, 0x65, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, + 0x8a, 0xb5, 0x18, 0x02, 0x32, 0x30, 0x52, 0x0c, 0x66, 0x65, 0x65, 0x52, 0x65, 0x63, 0x69, 0x70, + 0x69, 0x65, 0x6e, 0x74, 0x12, 0x25, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x65, 0x5f, 0x72, 0x6f, + 0x6f, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, + 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, 0x65, 0x52, 0x6f, 0x6f, 0x74, 0x12, 0x2b, 0x0a, 0x0d, 0x72, + 0x65, 0x63, 0x65, 0x69, 0x70, 0x74, 0x73, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x0c, 0x72, 0x65, 0x63, 0x65, + 0x69, 0x70, 0x74, 0x73, 0x52, 0x6f, 0x6f, 0x74, 0x12, 0x26, 0x0a, 0x0a, 0x6c, 0x6f, 0x67, 0x73, + 0x5f, 0x62, 0x6c, 0x6f, 0x6f, 0x6d, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x07, 0x8a, 0xb5, + 0x18, 0x03, 0x32, 0x35, 0x36, 0x52, 0x09, 0x6c, 0x6f, 0x67, 0x73, 0x42, 0x6c, 0x6f, 0x6f, 0x6d, + 0x12, 0x27, 0x0a, 0x0b, 0x70, 0x72, 0x65, 0x76, 0x5f, 0x72, 0x61, 0x6e, 0x64, 0x61, 0x6f, 0x18, + 0x06, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x0a, 0x70, + 0x72, 0x65, 0x76, 0x52, 0x61, 0x6e, 0x64, 0x61, 0x6f, 0x12, 0x21, 0x0a, 0x0c, 0x62, 0x6c, 0x6f, + 0x63, 0x6b, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x07, 0x20, 0x01, 0x28, 0x04, 0x52, + 0x0b, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x1b, 0x0a, 0x09, + 0x67, 0x61, 0x73, 0x5f, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x08, 0x20, 0x01, 0x28, 0x04, 0x52, + 0x08, 0x67, 0x61, 0x73, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x12, 0x19, 0x0a, 0x08, 0x67, 0x61, 0x73, + 0x5f, 0x75, 0x73, 0x65, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x67, 0x61, 0x73, + 0x55, 0x73, 0x65, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, + 0x70, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, + 0x6d, 0x70, 0x12, 0x25, 0x0a, 0x0a, 0x65, 0x78, 0x74, 0x72, 0x61, 0x5f, 0x64, 0x61, 0x74, 0x61, + 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x92, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x09, + 0x65, 0x78, 0x74, 0x72, 0x61, 0x44, 0x61, 0x74, 0x61, 0x12, 0x2f, 0x0a, 0x10, 0x62, 0x61, 0x73, + 0x65, 0x5f, 0x66, 0x65, 0x65, 0x5f, 0x70, 0x65, 0x72, 0x5f, 0x67, 0x61, 0x73, 0x18, 0x0c, 0x20, + 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x0d, 0x62, 0x61, 0x73, + 0x65, 0x46, 0x65, 0x65, 0x50, 0x65, 0x72, 0x47, 0x61, 0x73, 0x12, 0x25, 0x0a, 0x0a, 0x62, 0x6c, + 0x6f, 0x63, 0x6b, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, + 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x09, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x61, 0x73, + 0x68, 0x12, 0x41, 0x0a, 0x0c, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, + 0x73, 0x18, 0x0e, 0x20, 0x03, 0x28, 0x0c, 0x42, 0x1d, 0x8a, 0xb5, 0x18, 0x03, 0x3f, 0x2c, 0x3f, + 0x92, 0xb5, 0x18, 0x12, 0x31, 0x30, 0x34, 0x38, 0x35, 0x37, 0x36, 0x2c, 0x31, 0x30, 0x37, 0x33, + 0x37, 0x34, 0x31, 0x38, 0x32, 0x34, 0x52, 0x0c, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, + 0x69, 0x6f, 0x6e, 0x73, 0x22, 0x98, 0x05, 0x0a, 0x17, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, + 0x6f, 0x6e, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x43, 0x61, 0x70, 0x65, 0x6c, 0x6c, 0x61, + 0x12, 0x27, 0x0a, 0x0b, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x0a, 0x70, + 0x61, 0x72, 0x65, 0x6e, 0x74, 0x48, 0x61, 0x73, 0x68, 0x12, 0x2b, 0x0a, 0x0d, 0x66, 0x65, 0x65, + 0x5f, 0x72, 0x65, 0x63, 0x69, 0x70, 0x69, 0x65, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, + 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x32, 0x30, 0x52, 0x0c, 0x66, 0x65, 0x65, 0x52, 0x65, 0x63, + 0x69, 0x70, 0x69, 0x65, 0x6e, 0x74, 0x12, 0x25, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x65, 0x5f, + 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, + 0x33, 0x32, 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, 0x65, 0x52, 0x6f, 0x6f, 0x74, 0x12, 0x2b, 0x0a, + 0x0d, 0x72, 0x65, 0x63, 0x65, 0x69, 0x70, 0x74, 0x73, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x04, + 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x0c, 0x72, 0x65, + 0x63, 0x65, 0x69, 0x70, 0x74, 0x73, 0x52, 0x6f, 0x6f, 0x74, 0x12, 0x26, 0x0a, 0x0a, 0x6c, 0x6f, + 0x67, 0x73, 0x5f, 0x62, 0x6c, 0x6f, 0x6f, 0x6d, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x07, + 0x8a, 0xb5, 0x18, 0x03, 0x32, 0x35, 0x36, 0x52, 0x09, 0x6c, 0x6f, 0x67, 0x73, 0x42, 0x6c, 0x6f, + 0x6f, 0x6d, 0x12, 0x27, 0x0a, 0x0b, 0x70, 0x72, 0x65, 0x76, 0x5f, 0x72, 0x61, 0x6e, 0x64, 0x61, + 0x6f, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, + 0x0a, 0x70, 0x72, 0x65, 0x76, 0x52, 0x61, 0x6e, 0x64, 0x61, 0x6f, 0x12, 0x21, 0x0a, 0x0c, 0x62, + 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x07, 0x20, 0x01, 0x28, + 0x04, 0x52, 0x0b, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x1b, + 0x0a, 0x09, 0x67, 0x61, 0x73, 0x5f, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x08, 0x20, 0x01, 0x28, + 0x04, 0x52, 0x08, 0x67, 0x61, 0x73, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x12, 0x19, 0x0a, 0x08, 0x67, + 0x61, 0x73, 0x5f, 0x75, 0x73, 0x65, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x67, + 0x61, 0x73, 0x55, 0x73, 0x65, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, + 0x61, 0x6d, 0x70, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, + 0x74, 0x61, 0x6d, 0x70, 0x12, 0x25, 0x0a, 0x0a, 0x65, 0x78, 0x74, 0x72, 0x61, 0x5f, 0x64, 0x61, + 0x74, 0x61, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x92, 0xb5, 0x18, 0x02, 0x33, 0x32, + 0x52, 0x09, 0x65, 0x78, 0x74, 0x72, 0x61, 0x44, 0x61, 0x74, 0x61, 0x12, 0x2f, 0x0a, 0x10, 0x62, + 0x61, 0x73, 0x65, 0x5f, 0x66, 0x65, 0x65, 0x5f, 0x70, 0x65, 0x72, 0x5f, 0x67, 0x61, 0x73, 0x18, + 0x0c, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x0d, 0x62, + 0x61, 0x73, 0x65, 0x46, 0x65, 0x65, 0x50, 0x65, 0x72, 0x47, 0x61, 0x73, 0x12, 0x25, 0x0a, 0x0a, + 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x0c, + 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x09, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x48, + 0x61, 0x73, 0x68, 0x12, 0x41, 0x0a, 0x0c, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, + 0x6f, 0x6e, 0x73, 0x18, 0x0e, 0x20, 0x03, 0x28, 0x0c, 0x42, 0x1d, 0x8a, 0xb5, 0x18, 0x03, 0x3f, + 0x2c, 0x3f, 0x92, 0xb5, 0x18, 0x12, 0x31, 0x30, 0x34, 0x38, 0x35, 0x37, 0x36, 0x2c, 0x31, 0x30, + 0x37, 0x33, 0x37, 0x34, 0x31, 0x38, 0x32, 0x34, 0x52, 0x0c, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, + 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x47, 0x0a, 0x0b, 0x77, 0x69, 0x74, 0x68, 0x64, 0x72, + 0x61, 0x77, 0x61, 0x6c, 0x73, 0x18, 0x0f, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x65, 0x74, + 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x2e, 0x76, 0x31, + 0x2e, 0x57, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x61, 0x6c, 0x42, 0x05, 0x92, 0xb5, 0x18, + 0x01, 0x34, 0x52, 0x0b, 0x77, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x61, 0x6c, 0x73, 0x22, + 0xe2, 0x05, 0x0a, 0x15, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x61, 0x79, + 0x6c, 0x6f, 0x61, 0x64, 0x44, 0x65, 0x6e, 0x65, 0x62, 0x12, 0x27, 0x0a, 0x0b, 0x70, 0x61, 0x72, + 0x65, 0x6e, 0x74, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, + 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x0a, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x48, 0x61, + 0x73, 0x68, 0x12, 0x2b, 0x0a, 0x0d, 0x66, 0x65, 0x65, 0x5f, 0x72, 0x65, 0x63, 0x69, 0x70, 0x69, + 0x65, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x32, + 0x30, 0x52, 0x0c, 0x66, 0x65, 0x65, 0x52, 0x65, 0x63, 0x69, 0x70, 0x69, 0x65, 0x6e, 0x74, 0x12, + 0x25, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x65, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x09, 0x73, 0x74, 0x61, + 0x74, 0x65, 0x52, 0x6f, 0x6f, 0x74, 0x12, 0x2b, 0x0a, 0x0d, 0x72, 0x65, 0x63, 0x65, 0x69, 0x70, + 0x74, 0x73, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, + 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x0c, 0x72, 0x65, 0x63, 0x65, 0x69, 0x70, 0x74, 0x73, 0x52, + 0x6f, 0x6f, 0x74, 0x12, 0x26, 0x0a, 0x0a, 0x6c, 0x6f, 0x67, 0x73, 0x5f, 0x62, 0x6c, 0x6f, 0x6f, + 0x6d, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x07, 0x8a, 0xb5, 0x18, 0x03, 0x32, 0x35, 0x36, + 0x52, 0x09, 0x6c, 0x6f, 0x67, 0x73, 0x42, 0x6c, 0x6f, 0x6f, 0x6d, 0x12, 0x27, 0x0a, 0x0b, 0x70, + 0x72, 0x65, 0x76, 0x5f, 0x72, 0x61, 0x6e, 0x64, 0x61, 0x6f, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0c, + 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x0a, 0x70, 0x72, 0x65, 0x76, 0x52, 0x61, + 0x6e, 0x64, 0x61, 0x6f, 0x12, 0x21, 0x0a, 0x0c, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x6e, 0x75, + 0x6d, 0x62, 0x65, 0x72, 0x18, 0x07, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, 0x62, 0x6c, 0x6f, 0x63, + 0x6b, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x1b, 0x0a, 0x09, 0x67, 0x61, 0x73, 0x5f, 0x6c, + 0x69, 0x6d, 0x69, 0x74, 0x18, 0x08, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x67, 0x61, 0x73, 0x4c, + 0x69, 0x6d, 0x69, 0x74, 0x12, 0x19, 0x0a, 0x08, 0x67, 0x61, 0x73, 0x5f, 0x75, 0x73, 0x65, 0x64, + 0x18, 0x09, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x67, 0x61, 0x73, 0x55, 0x73, 0x65, 0x64, 0x12, + 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x0a, 0x20, 0x01, + 0x28, 0x04, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x25, 0x0a, + 0x0a, 0x65, 0x78, 0x74, 0x72, 0x61, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x18, 0x0b, 0x20, 0x01, 0x28, + 0x0c, 0x42, 0x06, 0x92, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x09, 0x65, 0x78, 0x74, 0x72, 0x61, + 0x44, 0x61, 0x74, 0x61, 0x12, 0x2f, 0x0a, 0x10, 0x62, 0x61, 0x73, 0x65, 0x5f, 0x66, 0x65, 0x65, + 0x5f, 0x70, 0x65, 0x72, 0x5f, 0x67, 0x61, 0x73, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, + 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x0d, 0x62, 0x61, 0x73, 0x65, 0x46, 0x65, 0x65, 0x50, + 0x65, 0x72, 0x47, 0x61, 0x73, 0x12, 0x25, 0x0a, 0x0a, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x68, + 0x61, 0x73, 0x68, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, + 0x32, 0x52, 0x09, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x61, 0x73, 0x68, 0x12, 0x41, 0x0a, 0x0c, + 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x0e, 0x20, 0x03, + 0x28, 0x0c, 0x42, 0x1d, 0x8a, 0xb5, 0x18, 0x03, 0x3f, 0x2c, 0x3f, 0x92, 0xb5, 0x18, 0x12, 0x31, + 0x30, 0x34, 0x38, 0x35, 0x37, 0x36, 0x2c, 0x31, 0x30, 0x37, 0x33, 0x37, 0x34, 0x31, 0x38, 0x32, + 0x34, 0x52, 0x0c, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, + 0x47, 0x0a, 0x0b, 0x77, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x61, 0x6c, 0x73, 0x18, 0x0f, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, + 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x57, 0x69, 0x74, 0x68, 0x64, 0x72, + 0x61, 0x77, 0x61, 0x6c, 0x42, 0x05, 0x92, 0xb5, 0x18, 0x01, 0x34, 0x52, 0x0b, 0x77, 0x69, 0x74, + 0x68, 0x64, 0x72, 0x61, 0x77, 0x61, 0x6c, 0x73, 0x12, 0x22, 0x0a, 0x0d, 0x62, 0x6c, 0x6f, 0x62, + 0x5f, 0x67, 0x61, 0x73, 0x5f, 0x75, 0x73, 0x65, 0x64, 0x18, 0x10, 0x20, 0x01, 0x28, 0x04, 0x52, + 0x0b, 0x62, 0x6c, 0x6f, 0x62, 0x47, 0x61, 0x73, 0x55, 0x73, 0x65, 0x64, 0x12, 0x26, 0x0a, 0x0f, + 0x65, 0x78, 0x63, 0x65, 0x73, 0x73, 0x5f, 0x62, 0x6c, 0x6f, 0x62, 0x5f, 0x67, 0x61, 0x73, 0x18, + 0x11, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0d, 0x65, 0x78, 0x63, 0x65, 0x73, 0x73, 0x42, 0x6c, 0x6f, + 0x62, 0x47, 0x61, 0x73, 0x22, 0x85, 0x07, 0x0a, 0x15, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, + 0x6f, 0x6e, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x47, 0x6c, 0x6f, 0x61, 0x73, 0x12, 0x27, + 0x0a, 0x0b, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x0a, 0x70, 0x61, 0x72, + 0x65, 0x6e, 0x74, 0x48, 0x61, 0x73, 0x68, 0x12, 0x2b, 0x0a, 0x0d, 0x66, 0x65, 0x65, 0x5f, 0x72, + 0x65, 0x63, 0x69, 0x70, 0x69, 0x65, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, + 0x8a, 0xb5, 0x18, 0x02, 0x32, 0x30, 0x52, 0x0c, 0x66, 0x65, 0x65, 0x52, 0x65, 0x63, 0x69, 0x70, + 0x69, 0x65, 0x6e, 0x74, 0x12, 0x25, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x65, 0x5f, 0x72, 0x6f, + 0x6f, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, + 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, 0x65, 0x52, 0x6f, 0x6f, 0x74, 0x12, 0x2b, 0x0a, 0x0d, 0x72, + 0x65, 0x63, 0x65, 0x69, 0x70, 0x74, 0x73, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x0c, 0x72, 0x65, 0x63, 0x65, + 0x69, 0x70, 0x74, 0x73, 0x52, 0x6f, 0x6f, 0x74, 0x12, 0x26, 0x0a, 0x0a, 0x6c, 0x6f, 0x67, 0x73, + 0x5f, 0x62, 0x6c, 0x6f, 0x6f, 0x6d, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x07, 0x8a, 0xb5, + 0x18, 0x03, 0x32, 0x35, 0x36, 0x52, 0x09, 0x6c, 0x6f, 0x67, 0x73, 0x42, 0x6c, 0x6f, 0x6f, 0x6d, + 0x12, 0x27, 0x0a, 0x0b, 0x70, 0x72, 0x65, 0x76, 0x5f, 0x72, 0x61, 0x6e, 0x64, 0x61, 0x6f, 0x18, + 0x06, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x0a, 0x70, + 0x72, 0x65, 0x76, 0x52, 0x61, 0x6e, 0x64, 0x61, 0x6f, 0x12, 0x21, 0x0a, 0x0c, 0x62, 0x6c, 0x6f, + 0x63, 0x6b, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x07, 0x20, 0x01, 0x28, 0x04, 0x52, + 0x0b, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x1b, 0x0a, 0x09, + 0x67, 0x61, 0x73, 0x5f, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x08, 0x20, 0x01, 0x28, 0x04, 0x52, + 0x08, 0x67, 0x61, 0x73, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x12, 0x19, 0x0a, 0x08, 0x67, 0x61, 0x73, + 0x5f, 0x75, 0x73, 0x65, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x67, 0x61, 0x73, + 0x55, 0x73, 0x65, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, + 0x70, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, + 0x6d, 0x70, 0x12, 0x25, 0x0a, 0x0a, 0x65, 0x78, 0x74, 0x72, 0x61, 0x5f, 0x64, 0x61, 0x74, 0x61, + 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x92, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x09, + 0x65, 0x78, 0x74, 0x72, 0x61, 0x44, 0x61, 0x74, 0x61, 0x12, 0x2f, 0x0a, 0x10, 0x62, 0x61, 0x73, + 0x65, 0x5f, 0x66, 0x65, 0x65, 0x5f, 0x70, 0x65, 0x72, 0x5f, 0x67, 0x61, 0x73, 0x18, 0x0c, 0x20, + 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x0d, 0x62, 0x61, 0x73, + 0x65, 0x46, 0x65, 0x65, 0x50, 0x65, 0x72, 0x47, 0x61, 0x73, 0x12, 0x25, 0x0a, 0x0a, 0x62, 0x6c, + 0x6f, 0x63, 0x6b, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, + 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x09, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x61, 0x73, + 0x68, 0x12, 0x41, 0x0a, 0x0c, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, + 0x73, 0x18, 0x0e, 0x20, 0x03, 0x28, 0x0c, 0x42, 0x1d, 0x8a, 0xb5, 0x18, 0x03, 0x3f, 0x2c, 0x3f, + 0x92, 0xb5, 0x18, 0x12, 0x31, 0x30, 0x34, 0x38, 0x35, 0x37, 0x36, 0x2c, 0x31, 0x30, 0x37, 0x33, + 0x37, 0x34, 0x31, 0x38, 0x32, 0x34, 0x52, 0x0c, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, + 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x47, 0x0a, 0x0b, 0x77, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, + 0x61, 0x6c, 0x73, 0x18, 0x0f, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x65, 0x74, 0x68, 0x65, + 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x57, + 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x61, 0x6c, 0x42, 0x05, 0x92, 0xb5, 0x18, 0x01, 0x34, + 0x52, 0x0b, 0x77, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x61, 0x6c, 0x73, 0x12, 0x22, 0x0a, + 0x0d, 0x62, 0x6c, 0x6f, 0x62, 0x5f, 0x67, 0x61, 0x73, 0x5f, 0x75, 0x73, 0x65, 0x64, 0x18, 0x10, + 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, 0x62, 0x6c, 0x6f, 0x62, 0x47, 0x61, 0x73, 0x55, 0x73, 0x65, + 0x64, 0x12, 0x26, 0x0a, 0x0f, 0x65, 0x78, 0x63, 0x65, 0x73, 0x73, 0x5f, 0x62, 0x6c, 0x6f, 0x62, + 0x5f, 0x67, 0x61, 0x73, 0x18, 0x11, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0d, 0x65, 0x78, 0x63, 0x65, + 0x73, 0x73, 0x42, 0x6c, 0x6f, 0x62, 0x47, 0x61, 0x73, 0x12, 0x3a, 0x0a, 0x11, 0x62, 0x6c, 0x6f, + 0x63, 0x6b, 0x5f, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x12, + 0x20, 0x01, 0x28, 0x0c, 0x42, 0x0e, 0x92, 0xb5, 0x18, 0x0a, 0x31, 0x30, 0x37, 0x33, 0x37, 0x34, + 0x31, 0x38, 0x32, 0x34, 0x52, 0x0f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x41, 0x63, 0x63, 0x65, 0x73, + 0x73, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x65, 0x0a, 0x0b, 0x73, 0x6c, 0x6f, 0x74, 0x5f, 0x6e, 0x75, + 0x6d, 0x62, 0x65, 0x72, 0x18, 0x13, 0x20, 0x01, 0x28, 0x04, 0x42, 0x44, 0x82, 0xb5, 0x18, 0x40, + 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x4f, 0x66, 0x66, 0x63, 0x68, + 0x61, 0x69, 0x6e, 0x4c, 0x61, 0x62, 0x73, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x37, + 0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x73, + 0x2f, 0x70, 0x72, 0x69, 0x6d, 0x69, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x53, 0x6c, 0x6f, 0x74, + 0x52, 0x0a, 0x73, 0x6c, 0x6f, 0x74, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x22, 0x7f, 0x0a, 0x20, + 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, + 0x43, 0x61, 0x70, 0x65, 0x6c, 0x6c, 0x61, 0x57, 0x69, 0x74, 0x68, 0x56, 0x61, 0x6c, 0x75, 0x65, + 0x12, 0x45, 0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x2b, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x6e, 0x67, + 0x69, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, 0x6e, + 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x43, 0x61, 0x70, 0x65, 0x6c, 0x6c, 0x61, 0x52, 0x07, + 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0xae, 0x01, + 0x0a, 0x23, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x61, 0x79, 0x6c, 0x6f, + 0x61, 0x64, 0x44, 0x65, 0x6e, 0x65, 0x62, 0x41, 0x6e, 0x64, 0x42, 0x6c, 0x6f, 0x62, 0x73, 0x42, + 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x12, 0x43, 0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, + 0x6d, 0x2e, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x78, 0x65, 0x63, + 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x44, 0x65, 0x6e, 0x65, + 0x62, 0x52, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x42, 0x0a, 0x0c, 0x62, 0x6c, + 0x6f, 0x62, 0x73, 0x5f, 0x62, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x1f, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x6e, 0x67, 0x69, + 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x42, 0x6c, 0x6f, 0x62, 0x73, 0x42, 0x75, 0x6e, 0x64, 0x6c, + 0x65, 0x52, 0x0b, 0x62, 0x6c, 0x6f, 0x62, 0x73, 0x42, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x22, 0xb2, + 0x01, 0x0a, 0x25, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x61, 0x79, 0x6c, + 0x6f, 0x61, 0x64, 0x44, 0x65, 0x6e, 0x65, 0x62, 0x41, 0x6e, 0x64, 0x42, 0x6c, 0x6f, 0x62, 0x73, + 0x42, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x56, 0x32, 0x12, 0x43, 0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c, + 0x6f, 0x61, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x65, 0x74, 0x68, 0x65, + 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x45, + 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x44, + 0x65, 0x6e, 0x65, 0x62, 0x52, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x44, 0x0a, + 0x0c, 0x62, 0x6c, 0x6f, 0x62, 0x73, 0x5f, 0x62, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, + 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x42, 0x6c, 0x6f, 0x62, 0x73, 0x42, 0x75, + 0x6e, 0x64, 0x6c, 0x65, 0x56, 0x32, 0x52, 0x0b, 0x62, 0x6c, 0x6f, 0x62, 0x73, 0x42, 0x75, 0x6e, + 0x64, 0x6c, 0x65, 0x22, 0x85, 0x02, 0x0a, 0x2c, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, + 0x6e, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x44, 0x65, 0x6e, 0x65, 0x62, 0x57, 0x69, 0x74, + 0x68, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x41, 0x6e, 0x64, 0x42, 0x6c, 0x6f, 0x62, 0x73, 0x42, 0x75, + 0x6e, 0x64, 0x6c, 0x65, 0x12, 0x43, 0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, + 0x2e, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x78, 0x65, 0x63, 0x75, + 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x44, 0x65, 0x6e, 0x65, 0x62, + 0x52, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, + 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, + 0x42, 0x0a, 0x0c, 0x62, 0x6c, 0x6f, 0x62, 0x73, 0x5f, 0x62, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, + 0x2e, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x42, 0x6c, 0x6f, 0x62, 0x73, + 0x42, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x52, 0x0b, 0x62, 0x6c, 0x6f, 0x62, 0x73, 0x42, 0x75, 0x6e, + 0x64, 0x6c, 0x65, 0x12, 0x36, 0x0a, 0x17, 0x73, 0x68, 0x6f, 0x75, 0x6c, 0x64, 0x5f, 0x6f, 0x76, + 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x5f, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x18, 0x04, + 0x20, 0x01, 0x28, 0x08, 0x52, 0x15, 0x73, 0x68, 0x6f, 0x75, 0x6c, 0x64, 0x4f, 0x76, 0x65, 0x72, + 0x72, 0x69, 0x64, 0x65, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x22, 0xc0, 0x04, 0x0a, 0x16, + 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, + 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x27, 0x0a, 0x0b, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, + 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, + 0x02, 0x33, 0x32, 0x52, 0x0a, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x48, 0x61, 0x73, 0x68, 0x12, + 0x2b, 0x0a, 0x0d, 0x66, 0x65, 0x65, 0x5f, 0x72, 0x65, 0x63, 0x69, 0x70, 0x69, 0x65, 0x6e, 0x74, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x32, 0x30, 0x52, 0x0c, + 0x66, 0x65, 0x65, 0x52, 0x65, 0x63, 0x69, 0x70, 0x69, 0x65, 0x6e, 0x74, 0x12, 0x25, 0x0a, 0x0a, + 0x73, 0x74, 0x61, 0x74, 0x65, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, + 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, 0x65, 0x52, + 0x6f, 0x6f, 0x74, 0x12, 0x2b, 0x0a, 0x0d, 0x72, 0x65, 0x63, 0x65, 0x69, 0x70, 0x74, 0x73, 0x5f, + 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, + 0x33, 0x32, 0x52, 0x0c, 0x72, 0x65, 0x63, 0x65, 0x69, 0x70, 0x74, 0x73, 0x52, 0x6f, 0x6f, 0x74, + 0x12, 0x26, 0x0a, 0x0a, 0x6c, 0x6f, 0x67, 0x73, 0x5f, 0x62, 0x6c, 0x6f, 0x6f, 0x6d, 0x18, 0x05, + 0x20, 0x01, 0x28, 0x0c, 0x42, 0x07, 0x8a, 0xb5, 0x18, 0x03, 0x32, 0x35, 0x36, 0x52, 0x09, 0x6c, + 0x6f, 0x67, 0x73, 0x42, 0x6c, 0x6f, 0x6f, 0x6d, 0x12, 0x27, 0x0a, 0x0b, 0x70, 0x72, 0x65, 0x76, + 0x5f, 0x72, 0x61, 0x6e, 0x64, 0x61, 0x6f, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, + 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x0a, 0x70, 0x72, 0x65, 0x76, 0x52, 0x61, 0x6e, 0x64, 0x61, + 0x6f, 0x12, 0x21, 0x0a, 0x0c, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, + 0x72, 0x18, 0x07, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x4e, 0x75, + 0x6d, 0x62, 0x65, 0x72, 0x12, 0x1b, 0x0a, 0x09, 0x67, 0x61, 0x73, 0x5f, 0x6c, 0x69, 0x6d, 0x69, + 0x74, 0x18, 0x08, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x67, 0x61, 0x73, 0x4c, 0x69, 0x6d, 0x69, + 0x74, 0x12, 0x19, 0x0a, 0x08, 0x67, 0x61, 0x73, 0x5f, 0x75, 0x73, 0x65, 0x64, 0x18, 0x09, 0x20, + 0x01, 0x28, 0x04, 0x52, 0x07, 0x67, 0x61, 0x73, 0x55, 0x73, 0x65, 0x64, 0x12, 0x1c, 0x0a, 0x09, + 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x04, 0x52, + 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x25, 0x0a, 0x0a, 0x65, 0x78, + 0x74, 0x72, 0x61, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, + 0x92, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x09, 0x65, 0x78, 0x74, 0x72, 0x61, 0x44, 0x61, 0x74, + 0x61, 0x12, 0x2f, 0x0a, 0x10, 0x62, 0x61, 0x73, 0x65, 0x5f, 0x66, 0x65, 0x65, 0x5f, 0x70, 0x65, + 0x72, 0x5f, 0x67, 0x61, 0x73, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, + 0x02, 0x33, 0x32, 0x52, 0x0d, 0x62, 0x61, 0x73, 0x65, 0x46, 0x65, 0x65, 0x50, 0x65, 0x72, 0x47, + 0x61, 0x73, 0x12, 0x25, 0x0a, 0x0a, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x68, 0x61, 0x73, 0x68, + 0x18, 0x0d, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x09, + 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x61, 0x73, 0x68, 0x12, 0x33, 0x0a, 0x11, 0x74, 0x72, 0x61, + 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x0e, + 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x10, 0x74, 0x72, + 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x6f, 0x6f, 0x74, 0x22, 0xfa, + 0x04, 0x0a, 0x1d, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x61, 0x79, 0x6c, + 0x6f, 0x61, 0x64, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x43, 0x61, 0x70, 0x65, 0x6c, 0x6c, 0x61, + 0x12, 0x27, 0x0a, 0x0b, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x0a, 0x70, + 0x61, 0x72, 0x65, 0x6e, 0x74, 0x48, 0x61, 0x73, 0x68, 0x12, 0x2b, 0x0a, 0x0d, 0x66, 0x65, 0x65, + 0x5f, 0x72, 0x65, 0x63, 0x69, 0x70, 0x69, 0x65, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, + 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x32, 0x30, 0x52, 0x0c, 0x66, 0x65, 0x65, 0x52, 0x65, 0x63, + 0x69, 0x70, 0x69, 0x65, 0x6e, 0x74, 0x12, 0x25, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x65, 0x5f, + 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, + 0x33, 0x32, 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, 0x65, 0x52, 0x6f, 0x6f, 0x74, 0x12, 0x2b, 0x0a, + 0x0d, 0x72, 0x65, 0x63, 0x65, 0x69, 0x70, 0x74, 0x73, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x04, + 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x0c, 0x72, 0x65, + 0x63, 0x65, 0x69, 0x70, 0x74, 0x73, 0x52, 0x6f, 0x6f, 0x74, 0x12, 0x26, 0x0a, 0x0a, 0x6c, 0x6f, + 0x67, 0x73, 0x5f, 0x62, 0x6c, 0x6f, 0x6f, 0x6d, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x07, + 0x8a, 0xb5, 0x18, 0x03, 0x32, 0x35, 0x36, 0x52, 0x09, 0x6c, 0x6f, 0x67, 0x73, 0x42, 0x6c, 0x6f, + 0x6f, 0x6d, 0x12, 0x27, 0x0a, 0x0b, 0x70, 0x72, 0x65, 0x76, 0x5f, 0x72, 0x61, 0x6e, 0x64, 0x61, + 0x6f, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, + 0x0a, 0x70, 0x72, 0x65, 0x76, 0x52, 0x61, 0x6e, 0x64, 0x61, 0x6f, 0x12, 0x21, 0x0a, 0x0c, 0x62, + 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x07, 0x20, 0x01, 0x28, + 0x04, 0x52, 0x0b, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x1b, + 0x0a, 0x09, 0x67, 0x61, 0x73, 0x5f, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x08, 0x20, 0x01, 0x28, + 0x04, 0x52, 0x08, 0x67, 0x61, 0x73, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x12, 0x19, 0x0a, 0x08, 0x67, + 0x61, 0x73, 0x5f, 0x75, 0x73, 0x65, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x67, + 0x61, 0x73, 0x55, 0x73, 0x65, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, + 0x61, 0x6d, 0x70, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, + 0x74, 0x61, 0x6d, 0x70, 0x12, 0x25, 0x0a, 0x0a, 0x65, 0x78, 0x74, 0x72, 0x61, 0x5f, 0x64, 0x61, + 0x74, 0x61, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x92, 0xb5, 0x18, 0x02, 0x33, 0x32, + 0x52, 0x09, 0x65, 0x78, 0x74, 0x72, 0x61, 0x44, 0x61, 0x74, 0x61, 0x12, 0x2f, 0x0a, 0x10, 0x62, + 0x61, 0x73, 0x65, 0x5f, 0x66, 0x65, 0x65, 0x5f, 0x70, 0x65, 0x72, 0x5f, 0x67, 0x61, 0x73, 0x18, + 0x0c, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x0d, 0x62, + 0x61, 0x73, 0x65, 0x46, 0x65, 0x65, 0x50, 0x65, 0x72, 0x47, 0x61, 0x73, 0x12, 0x25, 0x0a, 0x0a, + 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x0c, + 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x09, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x48, + 0x61, 0x73, 0x68, 0x12, 0x33, 0x0a, 0x11, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, + 0x6f, 0x6e, 0x73, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, + 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x10, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, + 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x6f, 0x6f, 0x74, 0x12, 0x31, 0x0a, 0x10, 0x77, 0x69, 0x74, 0x68, + 0x64, 0x72, 0x61, 0x77, 0x61, 0x6c, 0x73, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x0f, 0x20, 0x01, + 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x0f, 0x77, 0x69, 0x74, 0x68, + 0x64, 0x72, 0x61, 0x77, 0x61, 0x6c, 0x73, 0x52, 0x6f, 0x6f, 0x74, 0x22, 0xc4, 0x05, 0x0a, 0x1b, + 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, + 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x44, 0x65, 0x6e, 0x65, 0x62, 0x12, 0x27, 0x0a, 0x0b, 0x70, + 0x61, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, + 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x0a, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, + 0x48, 0x61, 0x73, 0x68, 0x12, 0x2b, 0x0a, 0x0d, 0x66, 0x65, 0x65, 0x5f, 0x72, 0x65, 0x63, 0x69, + 0x70, 0x69, 0x65, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, + 0x02, 0x32, 0x30, 0x52, 0x0c, 0x66, 0x65, 0x65, 0x52, 0x65, 0x63, 0x69, 0x70, 0x69, 0x65, 0x6e, + 0x74, 0x12, 0x25, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x65, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x09, 0x73, + 0x74, 0x61, 0x74, 0x65, 0x52, 0x6f, 0x6f, 0x74, 0x12, 0x2b, 0x0a, 0x0d, 0x72, 0x65, 0x63, 0x65, + 0x69, 0x70, 0x74, 0x73, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x42, + 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x0c, 0x72, 0x65, 0x63, 0x65, 0x69, 0x70, 0x74, + 0x73, 0x52, 0x6f, 0x6f, 0x74, 0x12, 0x26, 0x0a, 0x0a, 0x6c, 0x6f, 0x67, 0x73, 0x5f, 0x62, 0x6c, + 0x6f, 0x6f, 0x6d, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x07, 0x8a, 0xb5, 0x18, 0x03, 0x32, + 0x35, 0x36, 0x52, 0x09, 0x6c, 0x6f, 0x67, 0x73, 0x42, 0x6c, 0x6f, 0x6f, 0x6d, 0x12, 0x27, 0x0a, + 0x0b, 0x70, 0x72, 0x65, 0x76, 0x5f, 0x72, 0x61, 0x6e, 0x64, 0x61, 0x6f, 0x18, 0x06, 0x20, 0x01, + 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x0a, 0x70, 0x72, 0x65, 0x76, + 0x52, 0x61, 0x6e, 0x64, 0x61, 0x6f, 0x12, 0x21, 0x0a, 0x0c, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, + 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x07, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, 0x62, 0x6c, + 0x6f, 0x63, 0x6b, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x1b, 0x0a, 0x09, 0x67, 0x61, 0x73, + 0x5f, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x08, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x67, 0x61, + 0x73, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x12, 0x19, 0x0a, 0x08, 0x67, 0x61, 0x73, 0x5f, 0x75, 0x73, + 0x65, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x67, 0x61, 0x73, 0x55, 0x73, 0x65, + 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x0a, + 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, + 0x25, 0x0a, 0x0a, 0x65, 0x78, 0x74, 0x72, 0x61, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x18, 0x0b, 0x20, + 0x01, 0x28, 0x0c, 0x42, 0x06, 0x92, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x09, 0x65, 0x78, 0x74, + 0x72, 0x61, 0x44, 0x61, 0x74, 0x61, 0x12, 0x2f, 0x0a, 0x10, 0x62, 0x61, 0x73, 0x65, 0x5f, 0x66, + 0x65, 0x65, 0x5f, 0x70, 0x65, 0x72, 0x5f, 0x67, 0x61, 0x73, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0c, + 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x0d, 0x62, 0x61, 0x73, 0x65, 0x46, 0x65, + 0x65, 0x50, 0x65, 0x72, 0x47, 0x61, 0x73, 0x12, 0x25, 0x0a, 0x0a, 0x62, 0x6c, 0x6f, 0x63, 0x6b, + 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, + 0x02, 0x33, 0x32, 0x52, 0x09, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x61, 0x73, 0x68, 0x12, 0x33, + 0x0a, 0x11, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x5f, 0x72, + 0x6f, 0x6f, 0x74, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, + 0x32, 0x52, 0x10, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, + 0x6f, 0x6f, 0x74, 0x12, 0x31, 0x0a, 0x10, 0x77, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x61, + 0x6c, 0x73, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, + 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x0f, 0x77, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x61, + 0x6c, 0x73, 0x52, 0x6f, 0x6f, 0x74, 0x12, 0x22, 0x0a, 0x0d, 0x62, 0x6c, 0x6f, 0x62, 0x5f, 0x67, + 0x61, 0x73, 0x5f, 0x75, 0x73, 0x65, 0x64, 0x18, 0x10, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, 0x62, + 0x6c, 0x6f, 0x62, 0x47, 0x61, 0x73, 0x55, 0x73, 0x65, 0x64, 0x12, 0x26, 0x0a, 0x0f, 0x65, 0x78, + 0x63, 0x65, 0x73, 0x73, 0x5f, 0x62, 0x6c, 0x6f, 0x62, 0x5f, 0x67, 0x61, 0x73, 0x18, 0x11, 0x20, + 0x01, 0x28, 0x04, 0x52, 0x0d, 0x65, 0x78, 0x63, 0x65, 0x73, 0x73, 0x42, 0x6c, 0x6f, 0x62, 0x47, + 0x61, 0x73, 0x22, 0x9a, 0x01, 0x0a, 0x11, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x41, 0x74, + 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, + 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x74, 0x69, 0x6d, + 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x27, 0x0a, 0x0b, 0x70, 0x72, 0x65, 0x76, 0x5f, 0x72, + 0x61, 0x6e, 0x64, 0x61, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, + 0x02, 0x33, 0x32, 0x52, 0x0a, 0x70, 0x72, 0x65, 0x76, 0x52, 0x61, 0x6e, 0x64, 0x61, 0x6f, 0x12, + 0x3e, 0x0a, 0x17, 0x73, 0x75, 0x67, 0x67, 0x65, 0x73, 0x74, 0x65, 0x64, 0x5f, 0x66, 0x65, 0x65, + 0x5f, 0x72, 0x65, 0x63, 0x69, 0x70, 0x69, 0x65, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, + 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x32, 0x30, 0x52, 0x15, 0x73, 0x75, 0x67, 0x67, 0x65, 0x73, + 0x74, 0x65, 0x64, 0x46, 0x65, 0x65, 0x52, 0x65, 0x63, 0x69, 0x70, 0x69, 0x65, 0x6e, 0x74, 0x22, + 0xe5, 0x01, 0x0a, 0x13, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x41, 0x74, 0x74, 0x72, 0x69, + 0x62, 0x75, 0x74, 0x65, 0x73, 0x56, 0x32, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, + 0x74, 0x61, 0x6d, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, + 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x27, 0x0a, 0x0b, 0x70, 0x72, 0x65, 0x76, 0x5f, 0x72, 0x61, + 0x6e, 0x64, 0x61, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, + 0x33, 0x32, 0x52, 0x0a, 0x70, 0x72, 0x65, 0x76, 0x52, 0x61, 0x6e, 0x64, 0x61, 0x6f, 0x12, 0x3e, + 0x0a, 0x17, 0x73, 0x75, 0x67, 0x67, 0x65, 0x73, 0x74, 0x65, 0x64, 0x5f, 0x66, 0x65, 0x65, 0x5f, + 0x72, 0x65, 0x63, 0x69, 0x70, 0x69, 0x65, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x42, + 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x32, 0x30, 0x52, 0x15, 0x73, 0x75, 0x67, 0x67, 0x65, 0x73, 0x74, + 0x65, 0x64, 0x46, 0x65, 0x65, 0x52, 0x65, 0x63, 0x69, 0x70, 0x69, 0x65, 0x6e, 0x74, 0x12, 0x47, + 0x0a, 0x0b, 0x77, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x61, 0x6c, 0x73, 0x18, 0x04, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, + 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x57, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, + 0x77, 0x61, 0x6c, 0x42, 0x05, 0x92, 0xb5, 0x18, 0x01, 0x34, 0x52, 0x0b, 0x77, 0x69, 0x74, 0x68, + 0x64, 0x72, 0x61, 0x77, 0x61, 0x6c, 0x73, 0x22, 0xa6, 0x02, 0x0a, 0x13, 0x50, 0x61, 0x79, 0x6c, + 0x6f, 0x61, 0x64, 0x41, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x56, 0x33, 0x12, + 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x04, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x27, 0x0a, + 0x0b, 0x70, 0x72, 0x65, 0x76, 0x5f, 0x72, 0x61, 0x6e, 0x64, 0x61, 0x6f, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x0a, 0x70, 0x72, 0x65, 0x76, + 0x52, 0x61, 0x6e, 0x64, 0x61, 0x6f, 0x12, 0x3e, 0x0a, 0x17, 0x73, 0x75, 0x67, 0x67, 0x65, 0x73, + 0x74, 0x65, 0x64, 0x5f, 0x66, 0x65, 0x65, 0x5f, 0x72, 0x65, 0x63, 0x69, 0x70, 0x69, 0x65, 0x6e, + 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x32, 0x30, 0x52, + 0x15, 0x73, 0x75, 0x67, 0x67, 0x65, 0x73, 0x74, 0x65, 0x64, 0x46, 0x65, 0x65, 0x52, 0x65, 0x63, + 0x69, 0x70, 0x69, 0x65, 0x6e, 0x74, 0x12, 0x47, 0x0a, 0x0b, 0x77, 0x69, 0x74, 0x68, 0x64, 0x72, + 0x61, 0x77, 0x61, 0x6c, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x65, 0x74, + 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x2e, 0x76, 0x31, + 0x2e, 0x57, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x61, 0x6c, 0x42, 0x05, 0x92, 0xb5, 0x18, + 0x01, 0x34, 0x52, 0x0b, 0x77, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x61, 0x6c, 0x73, 0x12, + 0x3f, 0x0a, 0x18, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x62, 0x65, 0x61, 0x63, 0x6f, 0x6e, + 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x15, 0x70, 0x61, 0x72, 0x65, 0x6e, + 0x74, 0x42, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x6f, 0x6f, 0x74, + 0x22, 0xf1, 0x02, 0x0a, 0x13, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x41, 0x74, 0x74, 0x72, + 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x56, 0x34, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, + 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x74, 0x69, 0x6d, + 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x27, 0x0a, 0x0b, 0x70, 0x72, 0x65, 0x76, 0x5f, 0x72, + 0x61, 0x6e, 0x64, 0x61, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, + 0x02, 0x33, 0x32, 0x52, 0x0a, 0x70, 0x72, 0x65, 0x76, 0x52, 0x61, 0x6e, 0x64, 0x61, 0x6f, 0x12, + 0x3e, 0x0a, 0x17, 0x73, 0x75, 0x67, 0x67, 0x65, 0x73, 0x74, 0x65, 0x64, 0x5f, 0x66, 0x65, 0x65, + 0x5f, 0x72, 0x65, 0x63, 0x69, 0x70, 0x69, 0x65, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, + 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x32, 0x30, 0x52, 0x15, 0x73, 0x75, 0x67, 0x67, 0x65, 0x73, + 0x74, 0x65, 0x64, 0x46, 0x65, 0x65, 0x52, 0x65, 0x63, 0x69, 0x70, 0x69, 0x65, 0x6e, 0x74, 0x12, + 0x47, 0x0a, 0x0b, 0x77, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x61, 0x6c, 0x73, 0x18, 0x04, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, + 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x57, 0x69, 0x74, 0x68, 0x64, 0x72, + 0x61, 0x77, 0x61, 0x6c, 0x42, 0x05, 0x92, 0xb5, 0x18, 0x01, 0x34, 0x52, 0x0b, 0x77, 0x69, 0x74, + 0x68, 0x64, 0x72, 0x61, 0x77, 0x61, 0x6c, 0x73, 0x12, 0x3f, 0x0a, 0x18, 0x70, 0x61, 0x72, 0x65, + 0x6e, 0x74, 0x5f, 0x62, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, + 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, + 0x33, 0x32, 0x52, 0x15, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x42, 0x65, 0x61, 0x63, 0x6f, 0x6e, + 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x6f, 0x6f, 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x6c, 0x6f, + 0x74, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x06, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0a, + 0x73, 0x6c, 0x6f, 0x74, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x28, 0x0a, 0x10, 0x74, 0x61, + 0x72, 0x67, 0x65, 0x74, 0x5f, 0x67, 0x61, 0x73, 0x5f, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x07, + 0x20, 0x01, 0x28, 0x04, 0x52, 0x0e, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x47, 0x61, 0x73, 0x4c, + 0x69, 0x6d, 0x69, 0x74, 0x22, 0x92, 0x02, 0x0a, 0x0d, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, + 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x40, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x28, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, + 0x6d, 0x2e, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x61, 0x79, 0x6c, + 0x6f, 0x61, 0x64, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, + 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x32, 0x0a, 0x11, 0x6c, 0x61, 0x74, 0x65, + 0x73, 0x74, 0x5f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x0f, 0x6c, 0x61, 0x74, + 0x65, 0x73, 0x74, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x48, 0x61, 0x73, 0x68, 0x12, 0x29, 0x0a, 0x10, + 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x65, 0x72, 0x72, 0x6f, 0x72, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x60, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, + 0x73, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x09, + 0x0a, 0x05, 0x56, 0x41, 0x4c, 0x49, 0x44, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x49, 0x4e, 0x56, + 0x41, 0x4c, 0x49, 0x44, 0x10, 0x02, 0x12, 0x0b, 0x0a, 0x07, 0x53, 0x59, 0x4e, 0x43, 0x49, 0x4e, + 0x47, 0x10, 0x03, 0x12, 0x0c, 0x0a, 0x08, 0x41, 0x43, 0x43, 0x45, 0x50, 0x54, 0x45, 0x44, 0x10, + 0x04, 0x12, 0x16, 0x0a, 0x12, 0x49, 0x4e, 0x56, 0x41, 0x4c, 0x49, 0x44, 0x5f, 0x42, 0x4c, 0x4f, + 0x43, 0x4b, 0x5f, 0x48, 0x41, 0x53, 0x48, 0x10, 0x05, 0x22, 0xab, 0x01, 0x0a, 0x0f, 0x46, 0x6f, + 0x72, 0x6b, 0x63, 0x68, 0x6f, 0x69, 0x63, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x2e, 0x0a, + 0x0f, 0x68, 0x65, 0x61, 0x64, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x68, 0x61, 0x73, 0x68, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x0d, + 0x68, 0x65, 0x61, 0x64, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x61, 0x73, 0x68, 0x12, 0x2e, 0x0a, + 0x0f, 0x73, 0x61, 0x66, 0x65, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x68, 0x61, 0x73, 0x68, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x0d, + 0x73, 0x61, 0x66, 0x65, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x61, 0x73, 0x68, 0x12, 0x38, 0x0a, + 0x14, 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, + 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, + 0x02, 0x33, 0x32, 0x52, 0x12, 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x42, 0x6c, + 0x6f, 0x63, 0x6b, 0x48, 0x61, 0x73, 0x68, 0x22, 0xd5, 0x01, 0x0a, 0x0a, 0x57, 0x69, 0x74, 0x68, + 0x64, 0x72, 0x61, 0x77, 0x61, 0x6c, 0x12, 0x14, 0x0a, 0x05, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x77, 0x0a, 0x0f, + 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x5f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x04, 0x42, 0x4e, 0x82, 0xb5, 0x18, 0x4a, 0x67, 0x69, 0x74, 0x68, 0x75, + 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x4f, 0x66, 0x66, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x4c, 0x61, + 0x62, 0x73, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x37, 0x2f, 0x63, 0x6f, 0x6e, 0x73, + 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x70, 0x72, 0x69, 0x6d, + 0x69, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, + 0x49, 0x6e, 0x64, 0x65, 0x78, 0x52, 0x0e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, + 0x49, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x20, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x32, 0x30, 0x52, 0x07, + 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, + 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x22, + 0x9e, 0x01, 0x0a, 0x0b, 0x42, 0x6c, 0x6f, 0x62, 0x73, 0x42, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x12, + 0x39, 0x0a, 0x0f, 0x6b, 0x7a, 0x67, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x6d, 0x65, 0x6e, + 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0c, 0x42, 0x10, 0x8a, 0xb5, 0x18, 0x04, 0x3f, 0x2c, + 0x34, 0x38, 0x92, 0xb5, 0x18, 0x04, 0x34, 0x30, 0x39, 0x36, 0x52, 0x0e, 0x6b, 0x7a, 0x67, 0x43, + 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x28, 0x0a, 0x06, 0x70, 0x72, + 0x6f, 0x6f, 0x66, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0c, 0x42, 0x10, 0x8a, 0xb5, 0x18, 0x04, + 0x3f, 0x2c, 0x34, 0x38, 0x92, 0xb5, 0x18, 0x04, 0x34, 0x30, 0x39, 0x36, 0x52, 0x06, 0x70, 0x72, + 0x6f, 0x6f, 0x66, 0x73, 0x12, 0x2a, 0x0a, 0x05, 0x62, 0x6c, 0x6f, 0x62, 0x73, 0x18, 0x03, 0x20, + 0x03, 0x28, 0x0c, 0x42, 0x14, 0x8a, 0xb5, 0x18, 0x08, 0x3f, 0x2c, 0x31, 0x33, 0x31, 0x30, 0x37, + 0x32, 0x92, 0xb5, 0x18, 0x04, 0x34, 0x30, 0x39, 0x36, 0x52, 0x05, 0x62, 0x6c, 0x6f, 0x62, 0x73, + 0x22, 0xa4, 0x01, 0x0a, 0x0d, 0x42, 0x6c, 0x6f, 0x62, 0x73, 0x42, 0x75, 0x6e, 0x64, 0x6c, 0x65, + 0x56, 0x32, 0x12, 0x39, 0x0a, 0x0f, 0x6b, 0x7a, 0x67, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, + 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0c, 0x42, 0x10, 0x8a, 0xb5, 0x18, + 0x04, 0x3f, 0x2c, 0x34, 0x38, 0x92, 0xb5, 0x18, 0x04, 0x34, 0x30, 0x39, 0x36, 0x52, 0x0e, 0x6b, + 0x7a, 0x67, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x2c, 0x0a, + 0x06, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0c, 0x42, 0x14, 0x8a, + 0xb5, 0x18, 0x04, 0x3f, 0x2c, 0x34, 0x38, 0x92, 0xb5, 0x18, 0x08, 0x33, 0x33, 0x35, 0x35, 0x34, + 0x34, 0x33, 0x32, 0x52, 0x06, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x73, 0x12, 0x2a, 0x0a, 0x05, 0x62, + 0x6c, 0x6f, 0x62, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0c, 0x42, 0x14, 0x8a, 0xb5, 0x18, 0x08, + 0x3f, 0x2c, 0x31, 0x33, 0x31, 0x30, 0x37, 0x32, 0x92, 0xb5, 0x18, 0x04, 0x34, 0x30, 0x39, 0x36, + 0x52, 0x05, 0x62, 0x6c, 0x6f, 0x62, 0x73, 0x22, 0x26, 0x0a, 0x04, 0x42, 0x6c, 0x6f, 0x62, 0x12, + 0x1e, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x0a, 0x8a, + 0xb5, 0x18, 0x06, 0x31, 0x33, 0x31, 0x30, 0x37, 0x32, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, + 0x53, 0x0a, 0x0c, 0x42, 0x6c, 0x6f, 0x62, 0x41, 0x6e, 0x64, 0x50, 0x72, 0x6f, 0x6f, 0x66, 0x12, + 0x1e, 0x0a, 0x04, 0x62, 0x6c, 0x6f, 0x62, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x0a, 0x8a, + 0xb5, 0x18, 0x06, 0x31, 0x33, 0x31, 0x30, 0x37, 0x32, 0x52, 0x04, 0x62, 0x6c, 0x6f, 0x62, 0x12, + 0x23, 0x0a, 0x09, 0x6b, 0x7a, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x34, 0x38, 0x52, 0x08, 0x6b, 0x7a, 0x67, 0x50, + 0x72, 0x6f, 0x6f, 0x66, 0x22, 0x63, 0x0a, 0x0e, 0x42, 0x6c, 0x6f, 0x62, 0x41, 0x6e, 0x64, 0x50, + 0x72, 0x6f, 0x6f, 0x66, 0x56, 0x32, 0x12, 0x1e, 0x0a, 0x04, 0x62, 0x6c, 0x6f, 0x62, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0c, 0x42, 0x0a, 0x8a, 0xb5, 0x18, 0x06, 0x31, 0x33, 0x31, 0x30, 0x37, 0x32, + 0x52, 0x04, 0x62, 0x6c, 0x6f, 0x62, 0x12, 0x31, 0x0a, 0x0a, 0x6b, 0x7a, 0x67, 0x5f, 0x70, 0x72, + 0x6f, 0x6f, 0x66, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0c, 0x42, 0x12, 0x8a, 0xb5, 0x18, 0x02, + 0x34, 0x38, 0x92, 0xb5, 0x18, 0x08, 0x33, 0x33, 0x35, 0x35, 0x34, 0x34, 0x33, 0x32, 0x52, 0x09, + 0x6b, 0x7a, 0x67, 0x50, 0x72, 0x6f, 0x6f, 0x66, 0x73, 0x42, 0x95, 0x01, 0x0a, 0x16, 0x6f, 0x72, + 0x67, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x6e, 0x67, 0x69, 0x6e, + 0x65, 0x2e, 0x76, 0x31, 0x42, 0x14, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x45, + 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x39, 0x67, 0x69, + 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x4f, 0x66, 0x66, 0x63, 0x68, 0x61, 0x69, + 0x6e, 0x4c, 0x61, 0x62, 0x73, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x37, 0x2f, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x65, + 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x76, 0x31, 0xaa, 0x02, 0x12, 0x45, 0x74, 0x68, 0x65, 0x72, 0x65, + 0x75, 0x6d, 0x2e, 0x45, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x12, 0x45, + 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x5c, 0x45, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x5c, 0x76, + 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_proto_engine_v1_execution_engine_proto_rawDescOnce sync.Once + file_proto_engine_v1_execution_engine_proto_rawDescData = file_proto_engine_v1_execution_engine_proto_rawDesc +) + +func file_proto_engine_v1_execution_engine_proto_rawDescGZIP() []byte { + file_proto_engine_v1_execution_engine_proto_rawDescOnce.Do(func() { + file_proto_engine_v1_execution_engine_proto_rawDescData = protoimpl.X.CompressGZIP(file_proto_engine_v1_execution_engine_proto_rawDescData) + }) + return file_proto_engine_v1_execution_engine_proto_rawDescData +} + +var file_proto_engine_v1_execution_engine_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_proto_engine_v1_execution_engine_proto_msgTypes = make([]protoimpl.MessageInfo, 23) +var file_proto_engine_v1_execution_engine_proto_goTypes = []any{ + (PayloadStatus_Status)(0), // 0: ethereum.engine.v1.PayloadStatus.Status + (*ExecutionPayload)(nil), // 1: ethereum.engine.v1.ExecutionPayload + (*ExecutionPayloadCapella)(nil), // 2: ethereum.engine.v1.ExecutionPayloadCapella + (*ExecutionPayloadDeneb)(nil), // 3: ethereum.engine.v1.ExecutionPayloadDeneb + (*ExecutionPayloadGloas)(nil), // 4: ethereum.engine.v1.ExecutionPayloadGloas + (*ExecutionPayloadCapellaWithValue)(nil), // 5: ethereum.engine.v1.ExecutionPayloadCapellaWithValue + (*ExecutionPayloadDenebAndBlobsBundle)(nil), // 6: ethereum.engine.v1.ExecutionPayloadDenebAndBlobsBundle + (*ExecutionPayloadDenebAndBlobsBundleV2)(nil), // 7: ethereum.engine.v1.ExecutionPayloadDenebAndBlobsBundleV2 + (*ExecutionPayloadDenebWithValueAndBlobsBundle)(nil), // 8: ethereum.engine.v1.ExecutionPayloadDenebWithValueAndBlobsBundle + (*ExecutionPayloadHeader)(nil), // 9: ethereum.engine.v1.ExecutionPayloadHeader + (*ExecutionPayloadHeaderCapella)(nil), // 10: ethereum.engine.v1.ExecutionPayloadHeaderCapella + (*ExecutionPayloadHeaderDeneb)(nil), // 11: ethereum.engine.v1.ExecutionPayloadHeaderDeneb + (*PayloadAttributes)(nil), // 12: ethereum.engine.v1.PayloadAttributes + (*PayloadAttributesV2)(nil), // 13: ethereum.engine.v1.PayloadAttributesV2 + (*PayloadAttributesV3)(nil), // 14: ethereum.engine.v1.PayloadAttributesV3 + (*PayloadAttributesV4)(nil), // 15: ethereum.engine.v1.PayloadAttributesV4 + (*PayloadStatus)(nil), // 16: ethereum.engine.v1.PayloadStatus + (*ForkchoiceState)(nil), // 17: ethereum.engine.v1.ForkchoiceState + (*Withdrawal)(nil), // 18: ethereum.engine.v1.Withdrawal + (*BlobsBundle)(nil), // 19: ethereum.engine.v1.BlobsBundle + (*BlobsBundleV2)(nil), // 20: ethereum.engine.v1.BlobsBundleV2 + (*Blob)(nil), // 21: ethereum.engine.v1.Blob + (*BlobAndProof)(nil), // 22: ethereum.engine.v1.BlobAndProof + (*BlobAndProofV2)(nil), // 23: ethereum.engine.v1.BlobAndProofV2 +} +var file_proto_engine_v1_execution_engine_proto_depIdxs = []int32{ + 18, // 0: ethereum.engine.v1.ExecutionPayloadCapella.withdrawals:type_name -> ethereum.engine.v1.Withdrawal + 18, // 1: ethereum.engine.v1.ExecutionPayloadDeneb.withdrawals:type_name -> ethereum.engine.v1.Withdrawal + 18, // 2: ethereum.engine.v1.ExecutionPayloadGloas.withdrawals:type_name -> ethereum.engine.v1.Withdrawal + 2, // 3: ethereum.engine.v1.ExecutionPayloadCapellaWithValue.payload:type_name -> ethereum.engine.v1.ExecutionPayloadCapella + 3, // 4: ethereum.engine.v1.ExecutionPayloadDenebAndBlobsBundle.payload:type_name -> ethereum.engine.v1.ExecutionPayloadDeneb + 19, // 5: ethereum.engine.v1.ExecutionPayloadDenebAndBlobsBundle.blobs_bundle:type_name -> ethereum.engine.v1.BlobsBundle + 3, // 6: ethereum.engine.v1.ExecutionPayloadDenebAndBlobsBundleV2.payload:type_name -> ethereum.engine.v1.ExecutionPayloadDeneb + 20, // 7: ethereum.engine.v1.ExecutionPayloadDenebAndBlobsBundleV2.blobs_bundle:type_name -> ethereum.engine.v1.BlobsBundleV2 + 3, // 8: ethereum.engine.v1.ExecutionPayloadDenebWithValueAndBlobsBundle.payload:type_name -> ethereum.engine.v1.ExecutionPayloadDeneb + 19, // 9: ethereum.engine.v1.ExecutionPayloadDenebWithValueAndBlobsBundle.blobs_bundle:type_name -> ethereum.engine.v1.BlobsBundle + 18, // 10: ethereum.engine.v1.PayloadAttributesV2.withdrawals:type_name -> ethereum.engine.v1.Withdrawal + 18, // 11: ethereum.engine.v1.PayloadAttributesV3.withdrawals:type_name -> ethereum.engine.v1.Withdrawal + 18, // 12: ethereum.engine.v1.PayloadAttributesV4.withdrawals:type_name -> ethereum.engine.v1.Withdrawal + 0, // 13: ethereum.engine.v1.PayloadStatus.status:type_name -> ethereum.engine.v1.PayloadStatus.Status + 14, // [14:14] is the sub-list for method output_type + 14, // [14:14] is the sub-list for method input_type + 14, // [14:14] is the sub-list for extension type_name + 14, // [14:14] is the sub-list for extension extendee + 0, // [0:14] is the sub-list for field type_name +} + +func init() { file_proto_engine_v1_execution_engine_proto_init() } +func file_proto_engine_v1_execution_engine_proto_init() { + if File_proto_engine_v1_execution_engine_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_proto_engine_v1_execution_engine_proto_rawDesc, + NumEnums: 1, + NumMessages: 23, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_proto_engine_v1_execution_engine_proto_goTypes, + DependencyIndexes: file_proto_engine_v1_execution_engine_proto_depIdxs, + EnumInfos: file_proto_engine_v1_execution_engine_proto_enumTypes, + MessageInfos: file_proto_engine_v1_execution_engine_proto_msgTypes, + }.Build() + File_proto_engine_v1_execution_engine_proto = out.File + file_proto_engine_v1_execution_engine_proto_rawDesc = nil + file_proto_engine_v1_execution_engine_proto_goTypes = nil + file_proto_engine_v1_execution_engine_proto_depIdxs = nil +} diff --git a/proto/engine/v1/execution_engine.pb.go b/proto/engine/v1/execution_engine.pb.go index ac60d9ec237d..e255d9405348 100755 --- a/proto/engine/v1/execution_engine.pb.go +++ b/proto/engine/v1/execution_engine.pb.go @@ -1,3 +1,5 @@ +//go:build !minimal + // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.36.3 diff --git a/proto/eth/ext/BUILD.bazel b/proto/eth/ext/BUILD.bazel index e514b54f42aa..f6b9531ccdc5 100644 --- a/proto/eth/ext/BUILD.bazel +++ b/proto/eth/ext/BUILD.bazel @@ -17,7 +17,6 @@ proto_library( ) load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") -load("//tools:ssz.bzl", "SSZ_DEPS", "ssz_gen_marshal") go_proto_library( name = "go_proto", @@ -42,7 +41,7 @@ go_library( embed = [":ext_go_proto"], importpath = "github.com/OffchainLabs/prysm/v7/proto/eth/ext", visibility = ["//visibility:public"], - deps = SSZ_DEPS + [ + deps = [ "@com_github_golang_protobuf//proto:go_default_library", "@io_bazel_rules_go//proto/wkt:descriptor_go_proto", "@io_bazel_rules_go//proto/wkt:empty_go_proto", diff --git a/proto/eth/v1/BUILD.bazel b/proto/eth/v1/BUILD.bazel index 739dd63ad484..1bf975db28e8 100644 --- a/proto/eth/v1/BUILD.bazel +++ b/proto/eth/v1/BUILD.bazel @@ -29,37 +29,14 @@ proto_library( load("@io_bazel_rules_go//go:def.bzl", "go_library") load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") load("//proto:ssz_proto_library.bzl", "ssz_proto_files") -load("//tools:ssz.bzl", "SSZ_DEPS", "ssz_gen_marshal") +load("//tools:methodical.bzl", "ssz_methodical") -ssz_gen_marshal( - name = "ssz_generated_files", - go_proto = ":go_proto", +ssz_methodical( + name = "methodical_gateway", + deps = [":go_proto"], + config_file = "gateway.yaml", + override_package_name = "v1", out = "gateway.ssz.go", - includes = [ - "//consensus-types/primitives:go_default_library", - "//proto/engine/v1:go_default_library", - ], - objs = [ - "AggregateAttestationAndProof", - "Attestation", - "AttestationData", - "AttesterSlashing", - "BeaconBlock", - "BeaconBlockHeader", - "Checkpoint", - "Deposit", - "DepositData", - "Eth1Data", - "IndexedAttestation", - "ProposerSlashing", - "SignedAggregateAttestationAndProof", - "SignedBeaconBlock", - "SignedBeaconBlockHeader", - "SignedVoluntaryExit", - "SyncAggregate", - "Validator", - "VoluntaryExit", - ], ) go_proto_library( @@ -86,15 +63,16 @@ go_proto_library( go_library( name = "go_default_library", srcs = [ - ":ssz_generated_files", + ":methodical_gateway", ], embed = [ ":go_proto", ], importpath = "github.com/OffchainLabs/prysm/v7/proto/eth/v1", visibility = ["//visibility:public"], - deps = SSZ_DEPS + [ + deps = [ "@org_golang_google_protobuf//types/descriptorpb", + "@com_github_offchainlabs_methodical_ssz//ssz:go_default_library", ], ) diff --git a/proto/eth/v1/events.pb.go b/proto/eth/v1/events.pb.go new file mode 100755 index 000000000000..a3fc1279d2ee --- /dev/null +++ b/proto/eth/v1/events.pb.go @@ -0,0 +1,498 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.3 +// protoc v3.21.7 +// source: proto/eth/v1/events.proto + +package v1 + +import ( + reflect "reflect" + sync "sync" + + github_com_OffchainLabs_prysm_v7_consensus_types_primitives "github.com/OffchainLabs/prysm/v7/consensus-types/primitives" + _ "github.com/OffchainLabs/prysm/v7/proto/eth/ext" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + _ "google.golang.org/protobuf/types/descriptorpb" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type EventHead struct { + state protoimpl.MessageState `protogen:"open.v1"` + Slot github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot `protobuf:"varint,1,opt,name=slot,proto3" json:"slot,omitempty" cast-type:"github.com/OffchainLabs/prysm/v7/consensus-types/primitives.Slot"` + Block []byte `protobuf:"bytes,2,opt,name=block,proto3" json:"block,omitempty" ssz-size:"32"` + State []byte `protobuf:"bytes,3,opt,name=state,proto3" json:"state,omitempty" ssz-size:"32"` + EpochTransition bool `protobuf:"varint,4,opt,name=epoch_transition,json=epochTransition,proto3" json:"epoch_transition,omitempty"` + PreviousDutyDependentRoot []byte `protobuf:"bytes,5,opt,name=previous_duty_dependent_root,json=previousDutyDependentRoot,proto3" json:"previous_duty_dependent_root,omitempty" ssz-size:"32"` + CurrentDutyDependentRoot []byte `protobuf:"bytes,6,opt,name=current_duty_dependent_root,json=currentDutyDependentRoot,proto3" json:"current_duty_dependent_root,omitempty" ssz-size:"32"` + ExecutionOptimistic bool `protobuf:"varint,7,opt,name=execution_optimistic,json=executionOptimistic,proto3" json:"execution_optimistic,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *EventHead) Reset() { + *x = EventHead{} + mi := &file_proto_eth_v1_events_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *EventHead) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*EventHead) ProtoMessage() {} + +func (x *EventHead) ProtoReflect() protoreflect.Message { + mi := &file_proto_eth_v1_events_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use EventHead.ProtoReflect.Descriptor instead. +func (*EventHead) Descriptor() ([]byte, []int) { + return file_proto_eth_v1_events_proto_rawDescGZIP(), []int{0} +} + +func (x *EventHead) GetSlot() github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot { + if x != nil { + return x.Slot + } + return github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot(0) +} + +func (x *EventHead) GetBlock() []byte { + if x != nil { + return x.Block + } + return nil +} + +func (x *EventHead) GetState() []byte { + if x != nil { + return x.State + } + return nil +} + +func (x *EventHead) GetEpochTransition() bool { + if x != nil { + return x.EpochTransition + } + return false +} + +func (x *EventHead) GetPreviousDutyDependentRoot() []byte { + if x != nil { + return x.PreviousDutyDependentRoot + } + return nil +} + +func (x *EventHead) GetCurrentDutyDependentRoot() []byte { + if x != nil { + return x.CurrentDutyDependentRoot + } + return nil +} + +func (x *EventHead) GetExecutionOptimistic() bool { + if x != nil { + return x.ExecutionOptimistic + } + return false +} + +type EventBlock struct { + state protoimpl.MessageState `protogen:"open.v1"` + Slot github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot `protobuf:"varint,1,opt,name=slot,proto3" json:"slot,omitempty" cast-type:"github.com/OffchainLabs/prysm/v7/consensus-types/primitives.Slot"` + Block []byte `protobuf:"bytes,2,opt,name=block,proto3" json:"block,omitempty" ssz-size:"32"` + ExecutionOptimistic bool `protobuf:"varint,3,opt,name=execution_optimistic,json=executionOptimistic,proto3" json:"execution_optimistic,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *EventBlock) Reset() { + *x = EventBlock{} + mi := &file_proto_eth_v1_events_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *EventBlock) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*EventBlock) ProtoMessage() {} + +func (x *EventBlock) ProtoReflect() protoreflect.Message { + mi := &file_proto_eth_v1_events_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use EventBlock.ProtoReflect.Descriptor instead. +func (*EventBlock) Descriptor() ([]byte, []int) { + return file_proto_eth_v1_events_proto_rawDescGZIP(), []int{1} +} + +func (x *EventBlock) GetSlot() github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot { + if x != nil { + return x.Slot + } + return github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot(0) +} + +func (x *EventBlock) GetBlock() []byte { + if x != nil { + return x.Block + } + return nil +} + +func (x *EventBlock) GetExecutionOptimistic() bool { + if x != nil { + return x.ExecutionOptimistic + } + return false +} + +type EventChainReorg struct { + state protoimpl.MessageState `protogen:"open.v1"` + Slot github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot `protobuf:"varint,1,opt,name=slot,proto3" json:"slot,omitempty" cast-type:"github.com/OffchainLabs/prysm/v7/consensus-types/primitives.Slot"` + Depth uint64 `protobuf:"varint,2,opt,name=depth,proto3" json:"depth,omitempty"` + OldHeadBlock []byte `protobuf:"bytes,3,opt,name=old_head_block,json=oldHeadBlock,proto3" json:"old_head_block,omitempty" ssz-size:"32"` + NewHeadBlock []byte `protobuf:"bytes,4,opt,name=new_head_block,json=newHeadBlock,proto3" json:"new_head_block,omitempty" ssz-size:"32"` + OldHeadState []byte `protobuf:"bytes,5,opt,name=old_head_state,json=oldHeadState,proto3" json:"old_head_state,omitempty" ssz-size:"32"` + NewHeadState []byte `protobuf:"bytes,6,opt,name=new_head_state,json=newHeadState,proto3" json:"new_head_state,omitempty" ssz-size:"32"` + Epoch github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Epoch `protobuf:"varint,7,opt,name=epoch,proto3" json:"epoch,omitempty" cast-type:"github.com/OffchainLabs/prysm/v7/consensus-types/primitives.Epoch"` + ExecutionOptimistic bool `protobuf:"varint,8,opt,name=execution_optimistic,json=executionOptimistic,proto3" json:"execution_optimistic,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *EventChainReorg) Reset() { + *x = EventChainReorg{} + mi := &file_proto_eth_v1_events_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *EventChainReorg) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*EventChainReorg) ProtoMessage() {} + +func (x *EventChainReorg) ProtoReflect() protoreflect.Message { + mi := &file_proto_eth_v1_events_proto_msgTypes[2] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use EventChainReorg.ProtoReflect.Descriptor instead. +func (*EventChainReorg) Descriptor() ([]byte, []int) { + return file_proto_eth_v1_events_proto_rawDescGZIP(), []int{2} +} + +func (x *EventChainReorg) GetSlot() github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot { + if x != nil { + return x.Slot + } + return github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot(0) +} + +func (x *EventChainReorg) GetDepth() uint64 { + if x != nil { + return x.Depth + } + return 0 +} + +func (x *EventChainReorg) GetOldHeadBlock() []byte { + if x != nil { + return x.OldHeadBlock + } + return nil +} + +func (x *EventChainReorg) GetNewHeadBlock() []byte { + if x != nil { + return x.NewHeadBlock + } + return nil +} + +func (x *EventChainReorg) GetOldHeadState() []byte { + if x != nil { + return x.OldHeadState + } + return nil +} + +func (x *EventChainReorg) GetNewHeadState() []byte { + if x != nil { + return x.NewHeadState + } + return nil +} + +func (x *EventChainReorg) GetEpoch() github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Epoch { + if x != nil { + return x.Epoch + } + return github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Epoch(0) +} + +func (x *EventChainReorg) GetExecutionOptimistic() bool { + if x != nil { + return x.ExecutionOptimistic + } + return false +} + +type EventFinalizedCheckpoint struct { + state protoimpl.MessageState `protogen:"open.v1"` + Block []byte `protobuf:"bytes,1,opt,name=block,proto3" json:"block,omitempty" ssz-size:"32"` + State []byte `protobuf:"bytes,2,opt,name=state,proto3" json:"state,omitempty" ssz-size:"32"` + Epoch github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Epoch `protobuf:"varint,3,opt,name=epoch,proto3" json:"epoch,omitempty" cast-type:"github.com/OffchainLabs/prysm/v7/consensus-types/primitives.Epoch"` + ExecutionOptimistic bool `protobuf:"varint,4,opt,name=execution_optimistic,json=executionOptimistic,proto3" json:"execution_optimistic,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *EventFinalizedCheckpoint) Reset() { + *x = EventFinalizedCheckpoint{} + mi := &file_proto_eth_v1_events_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *EventFinalizedCheckpoint) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*EventFinalizedCheckpoint) ProtoMessage() {} + +func (x *EventFinalizedCheckpoint) ProtoReflect() protoreflect.Message { + mi := &file_proto_eth_v1_events_proto_msgTypes[3] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use EventFinalizedCheckpoint.ProtoReflect.Descriptor instead. +func (*EventFinalizedCheckpoint) Descriptor() ([]byte, []int) { + return file_proto_eth_v1_events_proto_rawDescGZIP(), []int{3} +} + +func (x *EventFinalizedCheckpoint) GetBlock() []byte { + if x != nil { + return x.Block + } + return nil +} + +func (x *EventFinalizedCheckpoint) GetState() []byte { + if x != nil { + return x.State + } + return nil +} + +func (x *EventFinalizedCheckpoint) GetEpoch() github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Epoch { + if x != nil { + return x.Epoch + } + return github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Epoch(0) +} + +func (x *EventFinalizedCheckpoint) GetExecutionOptimistic() bool { + if x != nil { + return x.ExecutionOptimistic + } + return false +} + +var File_proto_eth_v1_events_proto protoreflect.FileDescriptor + +var file_proto_eth_v1_events_proto_rawDesc = []byte{ + 0x0a, 0x19, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x74, 0x68, 0x2f, 0x76, 0x31, 0x2f, 0x65, + 0x76, 0x65, 0x6e, 0x74, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0f, 0x65, 0x74, 0x68, + 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x1a, 0x20, 0x67, 0x6f, + 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, 0x65, + 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1b, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x74, 0x68, 0x2f, 0x65, 0x78, 0x74, 0x2f, 0x6f, 0x70, + 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x8f, 0x03, 0x0a, 0x09, + 0x45, 0x76, 0x65, 0x6e, 0x74, 0x48, 0x65, 0x61, 0x64, 0x12, 0x58, 0x0a, 0x04, 0x73, 0x6c, 0x6f, + 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x42, 0x44, 0x82, 0xb5, 0x18, 0x40, 0x67, 0x69, 0x74, + 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x4f, 0x66, 0x66, 0x63, 0x68, 0x61, 0x69, 0x6e, + 0x4c, 0x61, 0x62, 0x73, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x37, 0x2f, 0x63, 0x6f, + 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x70, 0x72, + 0x69, 0x6d, 0x69, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x53, 0x6c, 0x6f, 0x74, 0x52, 0x04, 0x73, + 0x6c, 0x6f, 0x74, 0x12, 0x1c, 0x0a, 0x05, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x05, 0x62, 0x6c, 0x6f, 0x63, + 0x6b, 0x12, 0x1c, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, + 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x12, + 0x29, 0x0a, 0x10, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x5f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x69, 0x74, + 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0f, 0x65, 0x70, 0x6f, 0x63, 0x68, + 0x54, 0x72, 0x61, 0x6e, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x47, 0x0a, 0x1c, 0x70, 0x72, + 0x65, 0x76, 0x69, 0x6f, 0x75, 0x73, 0x5f, 0x64, 0x75, 0x74, 0x79, 0x5f, 0x64, 0x65, 0x70, 0x65, + 0x6e, 0x64, 0x65, 0x6e, 0x74, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0c, + 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x19, 0x70, 0x72, 0x65, 0x76, 0x69, 0x6f, + 0x75, 0x73, 0x44, 0x75, 0x74, 0x79, 0x44, 0x65, 0x70, 0x65, 0x6e, 0x64, 0x65, 0x6e, 0x74, 0x52, + 0x6f, 0x6f, 0x74, 0x12, 0x45, 0x0a, 0x1b, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x64, + 0x75, 0x74, 0x79, 0x5f, 0x64, 0x65, 0x70, 0x65, 0x6e, 0x64, 0x65, 0x6e, 0x74, 0x5f, 0x72, 0x6f, + 0x6f, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, + 0x52, 0x18, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x44, 0x75, 0x74, 0x79, 0x44, 0x65, 0x70, + 0x65, 0x6e, 0x64, 0x65, 0x6e, 0x74, 0x52, 0x6f, 0x6f, 0x74, 0x12, 0x31, 0x0a, 0x14, 0x65, 0x78, + 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6d, 0x69, 0x73, 0x74, + 0x69, 0x63, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x13, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, + 0x69, 0x6f, 0x6e, 0x4f, 0x70, 0x74, 0x69, 0x6d, 0x69, 0x73, 0x74, 0x69, 0x63, 0x22, 0xb7, 0x01, + 0x0a, 0x0a, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x58, 0x0a, 0x04, + 0x73, 0x6c, 0x6f, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x42, 0x44, 0x82, 0xb5, 0x18, 0x40, + 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x4f, 0x66, 0x66, 0x63, 0x68, + 0x61, 0x69, 0x6e, 0x4c, 0x61, 0x62, 0x73, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x37, + 0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x73, + 0x2f, 0x70, 0x72, 0x69, 0x6d, 0x69, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x53, 0x6c, 0x6f, 0x74, + 0x52, 0x04, 0x73, 0x6c, 0x6f, 0x74, 0x12, 0x1c, 0x0a, 0x05, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x05, 0x62, + 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x31, 0x0a, 0x14, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, + 0x6e, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6d, 0x69, 0x73, 0x74, 0x69, 0x63, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x08, 0x52, 0x13, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x4f, 0x70, 0x74, + 0x69, 0x6d, 0x69, 0x73, 0x74, 0x69, 0x63, 0x22, 0xc9, 0x03, 0x0a, 0x0f, 0x45, 0x76, 0x65, 0x6e, + 0x74, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x52, 0x65, 0x6f, 0x72, 0x67, 0x12, 0x58, 0x0a, 0x04, 0x73, + 0x6c, 0x6f, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x42, 0x44, 0x82, 0xb5, 0x18, 0x40, 0x67, + 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x4f, 0x66, 0x66, 0x63, 0x68, 0x61, + 0x69, 0x6e, 0x4c, 0x61, 0x62, 0x73, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x37, 0x2f, + 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, + 0x70, 0x72, 0x69, 0x6d, 0x69, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x53, 0x6c, 0x6f, 0x74, 0x52, + 0x04, 0x73, 0x6c, 0x6f, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x64, 0x65, 0x70, 0x74, 0x68, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x64, 0x65, 0x70, 0x74, 0x68, 0x12, 0x2c, 0x0a, 0x0e, 0x6f, + 0x6c, 0x64, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x0c, 0x6f, 0x6c, 0x64, + 0x48, 0x65, 0x61, 0x64, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x2c, 0x0a, 0x0e, 0x6e, 0x65, 0x77, + 0x5f, 0x68, 0x65, 0x61, 0x64, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x0c, 0x6e, 0x65, 0x77, 0x48, 0x65, + 0x61, 0x64, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x2c, 0x0a, 0x0e, 0x6f, 0x6c, 0x64, 0x5f, 0x68, + 0x65, 0x61, 0x64, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0c, 0x42, + 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x0c, 0x6f, 0x6c, 0x64, 0x48, 0x65, 0x61, 0x64, + 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x2c, 0x0a, 0x0e, 0x6e, 0x65, 0x77, 0x5f, 0x68, 0x65, 0x61, + 0x64, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, + 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x0c, 0x6e, 0x65, 0x77, 0x48, 0x65, 0x61, 0x64, 0x53, 0x74, + 0x61, 0x74, 0x65, 0x12, 0x5b, 0x0a, 0x05, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x18, 0x07, 0x20, 0x01, + 0x28, 0x04, 0x42, 0x45, 0x82, 0xb5, 0x18, 0x41, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, + 0x6f, 0x6d, 0x2f, 0x4f, 0x66, 0x66, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x4c, 0x61, 0x62, 0x73, 0x2f, + 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x37, 0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, + 0x75, 0x73, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x70, 0x72, 0x69, 0x6d, 0x69, 0x74, 0x69, + 0x76, 0x65, 0x73, 0x2e, 0x45, 0x70, 0x6f, 0x63, 0x68, 0x52, 0x05, 0x65, 0x70, 0x6f, 0x63, 0x68, + 0x12, 0x31, 0x0a, 0x14, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6f, 0x70, + 0x74, 0x69, 0x6d, 0x69, 0x73, 0x74, 0x69, 0x63, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x13, + 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x4f, 0x70, 0x74, 0x69, 0x6d, 0x69, 0x73, + 0x74, 0x69, 0x63, 0x22, 0xe6, 0x01, 0x0a, 0x18, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x46, 0x69, 0x6e, + 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, + 0x12, 0x1c, 0x0a, 0x05, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x42, + 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x05, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x1c, + 0x0a, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, + 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x12, 0x5b, 0x0a, 0x05, + 0x65, 0x70, 0x6f, 0x63, 0x68, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x42, 0x45, 0x82, 0xb5, 0x18, + 0x41, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x4f, 0x66, 0x66, 0x63, + 0x68, 0x61, 0x69, 0x6e, 0x4c, 0x61, 0x62, 0x73, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, + 0x37, 0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2d, 0x74, 0x79, 0x70, 0x65, + 0x73, 0x2f, 0x70, 0x72, 0x69, 0x6d, 0x69, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x45, 0x70, 0x6f, + 0x63, 0x68, 0x52, 0x05, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x12, 0x31, 0x0a, 0x14, 0x65, 0x78, 0x65, + 0x63, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6d, 0x69, 0x73, 0x74, 0x69, + 0x63, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x13, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, + 0x6f, 0x6e, 0x4f, 0x70, 0x74, 0x69, 0x6d, 0x69, 0x73, 0x74, 0x69, 0x63, 0x42, 0x7d, 0x0a, 0x13, + 0x6f, 0x72, 0x67, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, + 0x2e, 0x76, 0x31, 0x42, 0x11, 0x42, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x45, 0x76, 0x65, 0x6e, 0x74, + 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x2d, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, + 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x4f, 0x66, 0x66, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x4c, 0x61, 0x62, + 0x73, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x37, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x2f, 0x65, 0x74, 0x68, 0x2f, 0x76, 0x31, 0xaa, 0x02, 0x0f, 0x45, 0x74, 0x68, 0x65, 0x72, 0x65, + 0x75, 0x6d, 0x2e, 0x45, 0x74, 0x68, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x0f, 0x45, 0x74, 0x68, 0x65, + 0x72, 0x65, 0x75, 0x6d, 0x5c, 0x45, 0x74, 0x68, 0x5c, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, +} + +var ( + file_proto_eth_v1_events_proto_rawDescOnce sync.Once + file_proto_eth_v1_events_proto_rawDescData = file_proto_eth_v1_events_proto_rawDesc +) + +func file_proto_eth_v1_events_proto_rawDescGZIP() []byte { + file_proto_eth_v1_events_proto_rawDescOnce.Do(func() { + file_proto_eth_v1_events_proto_rawDescData = protoimpl.X.CompressGZIP(file_proto_eth_v1_events_proto_rawDescData) + }) + return file_proto_eth_v1_events_proto_rawDescData +} + +var file_proto_eth_v1_events_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +var file_proto_eth_v1_events_proto_goTypes = []any{ + (*EventHead)(nil), // 0: ethereum.eth.v1.EventHead + (*EventBlock)(nil), // 1: ethereum.eth.v1.EventBlock + (*EventChainReorg)(nil), // 2: ethereum.eth.v1.EventChainReorg + (*EventFinalizedCheckpoint)(nil), // 3: ethereum.eth.v1.EventFinalizedCheckpoint +} +var file_proto_eth_v1_events_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_proto_eth_v1_events_proto_init() } +func file_proto_eth_v1_events_proto_init() { + if File_proto_eth_v1_events_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_proto_eth_v1_events_proto_rawDesc, + NumEnums: 0, + NumMessages: 4, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_proto_eth_v1_events_proto_goTypes, + DependencyIndexes: file_proto_eth_v1_events_proto_depIdxs, + MessageInfos: file_proto_eth_v1_events_proto_msgTypes, + }.Build() + File_proto_eth_v1_events_proto = out.File + file_proto_eth_v1_events_proto_rawDesc = nil + file_proto_eth_v1_events_proto_goTypes = nil + file_proto_eth_v1_events_proto_depIdxs = nil +} diff --git a/proto/eth/v1/gateway.minimal.ssz.go b/proto/eth/v1/gateway.minimal.ssz.go index e9ba8d4d3799..f899b0d02613 100644 --- a/proto/eth/v1/gateway.minimal.ssz.go +++ b/proto/eth/v1/gateway.minimal.ssz.go @@ -1,2468 +1,2416 @@ //go:build minimal -// Code generated by fastssz. DO NOT EDIT. package v1 import ( - github_com_OffchainLabs_prysm_v7_consensus_types_primitives "github.com/OffchainLabs/prysm/v7/consensus-types/primitives" - ssz "github.com/prysmaticlabs/fastssz" + binary "encoding/binary" + "fmt" + go_bitfield "github.com/OffchainLabs/go-bitfield" + ssz "github.com/OffchainLabs/methodical-ssz/ssz" ) -// MarshalSSZ ssz marshals the Attestation object -func (a *Attestation) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(a) +func (c *AggregateAttestationAndProof) SizeSSZ() int { + size := 108 + if c.Aggregate == nil { + c.Aggregate = new(Attestation) + } + size += c.Aggregate.SizeSSZ() + return size } -// 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) +func (c *AggregateAttestationAndProof) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Offset (0) 'AggregationBits' - dst = ssz.WriteOffset(dst, offset) - offset += len(a.AggregationBits) +func (c *AggregateAttestationAndProof) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 108 - // Field (1) 'Data' - if a.Data == nil { - a.Data = new(AttestationData) - } - if dst, err = a.Data.MarshalSSZTo(dst); err != nil { - return + // Field 0: AggregatorIndex + if dst, err = c.AggregatorIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("AggregatorIndex: %w", err) } - // Field (2) 'Signature' - if size := len(a.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 1: Aggregate + if c.Aggregate == nil { + c.Aggregate = new(Attestation) } - dst = append(dst, a.Signature...) + dst = ssz.WriteOffset(dst, offset) + offset += c.Aggregate.SizeSSZ() - // Field (0) 'AggregationBits' - if size := len(a.AggregationBits); size > 2048 { - err = ssz.ErrBytesLengthFn("--.AggregationBits", size, 2048) - return + // Field 2: SelectionProof + if len(c.SelectionProof) != 96 { + return nil, ssz.ErrBytesLength } - dst = append(dst, a.AggregationBits...) + dst = append(dst, c.SelectionProof...) - return + // Field 1: Aggregate + if dst, err = c.Aggregate.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Aggregate: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the Attestation object -func (a *Attestation) UnmarshalSSZ(buf []byte) error { +func (c *AggregateAttestationAndProof) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 228 { + if size < 108 { return ssz.ErrSize } - tail := buf - var o0 uint64 - - // Offset (0) 'AggregationBits' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } + sszSlice0 := buf[0:8] // c.AggregatorIndex + sszSlice2 := buf[12:108] // c.SelectionProof - if o0 != 228 { + sszVarOffset1 := ssz.ReadOffset(buf[8:12]) // c.Aggregate + if sszVarOffset1 != 108 { 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 + if sszVarOffset1 > size { + return ssz.ErrOffset } + sszSlice1 := buf[sszVarOffset1:] // c.Aggregate - // Field (2) 'Signature' - if cap(a.Signature) == 0 { - a.Signature = make([]byte, 0, len(buf[132:228])) + // Field 0: AggregatorIndex + if err = c.AggregatorIndex.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("AggregatorIndex: %w", err) } - a.Signature = append(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...) + // Field 1: Aggregate + c.Aggregate = new(Attestation) + if err = c.Aggregate.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Aggregate: %w", err) } - 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 + // Field 2: SelectionProof + c.SelectionProof = make([]byte, 0, 96) + c.SelectionProof = append(c.SelectionProof, sszSlice2...) + return err } -// HashTreeRoot ssz hashes the Attestation object -func (a *Attestation) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(a) +func (c *AggregateAttestationAndProof) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the Attestation object with a hasher -func (a *Attestation) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *AggregateAttestationAndProof) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'AggregationBits' - if len(a.AggregationBits) == 0 { - err = ssz.ErrEmptyBitlist - return + // Field 0: AggregatorIndex + if err := c.AggregatorIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("AggregatorIndex: %w", err) } - hh.PutBitlist(a.AggregationBits, 2048) - - // Field (1) 'Data' - if err = a.Data.HashTreeRootWith(hh); err != nil { - return + // Field 1: Aggregate + if err := c.Aggregate.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Aggregate: %w", err) } - - // Field (2) 'Signature' - if size := len(a.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 2: SelectionProof + if len(c.SelectionProof) != 96 { + return ssz.ErrBytesLength } - hh.PutBytes(a.Signature) - + hh.PutBytes(c.SelectionProof) hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the AggregateAttestationAndProof object -func (a *AggregateAttestationAndProof) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(a) +func (c *Attestation) SizeSSZ() int { + size := 228 + size += len(c.AggregationBits) + return size } -// MarshalSSZTo ssz marshals the AggregateAttestationAndProof object to a target array -func (a *AggregateAttestationAndProof) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(108) +func (c *Attestation) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (0) 'AggregatorIndex' - dst = ssz.MarshalUint(dst, a.AggregatorIndex) +func (c *Attestation) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 228 - // Offset (1) 'Aggregate' + // Field 0: AggregationBits dst = ssz.WriteOffset(dst, offset) - if a.Aggregate == nil { - a.Aggregate = new(Attestation) - } - offset += a.Aggregate.SizeSSZ() + offset += len(c.AggregationBits) - // Field (2) 'SelectionProof' - if size := len(a.SelectionProof); size != 96 { - err = ssz.ErrBytesLengthFn("--.SelectionProof", size, 96) - return + // Field 1: Data + if c.Data == nil { + c.Data = new(AttestationData) + } + if dst, err = c.Data.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Data: %w", err) } - dst = append(dst, a.SelectionProof...) - // Field (1) 'Aggregate' - if dst, err = a.Aggregate.MarshalSSZTo(dst); err != nil { - return + // Field 2: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.Signature...) - return + // Field 0: AggregationBits + if len(c.AggregationBits) > 2048 { + return nil, ssz.ErrListTooBig + } + dst = append(dst, c.AggregationBits...) + return dst, err } -// UnmarshalSSZ ssz unmarshals the AggregateAttestationAndProof object -func (a *AggregateAttestationAndProof) UnmarshalSSZ(buf []byte) error { +func (c *Attestation) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 108 { + if size < 228 { return ssz.ErrSize } - tail := buf - var o1 uint64 - - // Field (0) 'AggregatorIndex' - a.AggregatorIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[0:8]) + sszSlice1 := buf[4:132] // c.Data + sszSlice2 := buf[132:228] // c.Signature - // Offset (1) 'Aggregate' - if o1 = ssz.ReadOffset(buf[8:12]); o1 > size { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.AggregationBits + if sszVarOffset0 != 228 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset0 > size { return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:] // c.AggregationBits - if o1 != 108 { - return ssz.ErrInvalidVariableOffset + // Field 0: AggregationBits + if err = ssz.ValidateBitlist(sszSlice0, 2048); err != nil { + return fmt.Errorf("AggregationBits: %w", err) } + c.AggregationBits = append([]byte{}, go_bitfield.Bitlist(sszSlice0)...) - // Field (2) 'SelectionProof' - if cap(a.SelectionProof) == 0 { - a.SelectionProof = make([]byte, 0, len(buf[12:108])) + // Field 1: Data + c.Data = new(AttestationData) + if err = c.Data.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Data: %w", err) } - a.SelectionProof = append(a.SelectionProof, buf[12:108]...) - // Field (1) 'Aggregate' - { - buf = tail[o1:] - if a.Aggregate == nil { - a.Aggregate = new(Attestation) - } - if err = a.Aggregate.UnmarshalSSZ(buf); err != nil { - return err - } - } + // Field 2: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice2...) return err } -// SizeSSZ returns the ssz encoded size in bytes for the AggregateAttestationAndProof object -func (a *AggregateAttestationAndProof) SizeSSZ() (size int) { - size = 108 - - // Field (1) 'Aggregate' - if a.Aggregate == nil { - a.Aggregate = new(Attestation) +func (c *Attestation) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - size += a.Aggregate.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the AggregateAttestationAndProof object -func (a *AggregateAttestationAndProof) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(a) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the AggregateAttestationAndProof object with a hasher -func (a *AggregateAttestationAndProof) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *Attestation) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'AggregatorIndex' - ssz.PutUint(hh, a.AggregatorIndex) - - // Field (1) 'Aggregate' - if err = a.Aggregate.HashTreeRootWith(hh); err != nil { - return - } - - // Field (2) 'SelectionProof' - if size := len(a.SelectionProof); size != 96 { - err = ssz.ErrBytesLengthFn("--.SelectionProof", size, 96) - return - } - hh.PutBytes(a.SelectionProof) - - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the SignedAggregateAttestationAndProof object -func (s *SignedAggregateAttestationAndProof) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) -} - -// MarshalSSZTo ssz marshals the SignedAggregateAttestationAndProof object to a target array -func (s *SignedAggregateAttestationAndProof) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(100) - - // Offset (0) 'Message' - dst = ssz.WriteOffset(dst, offset) - if s.Message == nil { - s.Message = new(AggregateAttestationAndProof) - } - offset += s.Message.SizeSSZ() - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return - } - dst = append(dst, s.Signature...) - - // Field (0) 'Message' - if dst, err = s.Message.MarshalSSZTo(dst); err != nil { - return + // Field 0: AggregationBits + if len(c.AggregationBits) == 0 { + return ssz.ErrEmptyBitlist } - - return -} - -// UnmarshalSSZ ssz unmarshals the SignedAggregateAttestationAndProof object -func (s *SignedAggregateAttestationAndProof) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 100 { - return ssz.ErrSize + hh.PutBitlist(c.AggregationBits, 2048) + // Field 1: Data + if err := c.Data.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Data: %w", err) } - - tail := buf - var o0 uint64 - - // Offset (0) 'Message' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset + // Field 2: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength } - - 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) 'Message' - { - buf = tail[o0:] - if s.Message == nil { - s.Message = new(AggregateAttestationAndProof) - } - if err = s.Message.UnmarshalSSZ(buf); err != nil { - return err - } - } - return err + hh.PutBytes(c.Signature) + hh.Merkleize(indx) + return nil } -// SizeSSZ returns the ssz encoded size in bytes for the SignedAggregateAttestationAndProof object -func (s *SignedAggregateAttestationAndProof) SizeSSZ() (size int) { - size = 100 - - // Field (0) 'Message' - if s.Message == nil { - s.Message = new(AggregateAttestationAndProof) - } - size += s.Message.SizeSSZ() +func (c *AttestationData) SizeSSZ() int { + size := 128 - return + return size } -// HashTreeRoot ssz hashes the SignedAggregateAttestationAndProof object -func (s *SignedAggregateAttestationAndProof) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) +func (c *AttestationData) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// HashTreeRootWith ssz hashes the SignedAggregateAttestationAndProof object with a hasher -func (s *SignedAggregateAttestationAndProof) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() +func (c *AttestationData) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (0) 'Message' - if err = s.Message.HashTreeRootWith(hh); err != nil { - return + // Field 0: Slot + if dst, err = c.Slot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Slot: %w", err) } - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 1: Index + if dst, err = c.Index.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Index: %w", err) } - hh.PutBytes(s.Signature) - - hh.Merkleize(indx) - return -} - -// 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.MarshalUint(dst, a.Slot) - - // Field (1) 'Index' - dst = ssz.MarshalUint(dst, a.Index) - - // Field (2) 'BeaconBlockRoot' - if size := len(a.BeaconBlockRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.BeaconBlockRoot", size, 32) - return + // Field 2: BeaconBlockRoot + if len(c.BeaconBlockRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, a.BeaconBlockRoot...) + dst = append(dst, c.BeaconBlockRoot...) - // Field (3) 'Source' - if a.Source == nil { - a.Source = new(Checkpoint) + // Field 3: Source + if c.Source == nil { + c.Source = new(Checkpoint) } - if dst, err = a.Source.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.Source.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Source: %w", err) } - // Field (4) 'Target' - if a.Target == nil { - a.Target = new(Checkpoint) + // Field 4: Target + if c.Target == nil { + c.Target = new(Checkpoint) } - if dst, err = a.Target.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.Target.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Target: %w", err) } - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the AttestationData object -func (a *AttestationData) UnmarshalSSZ(buf []byte) error { +func (c *AttestationData) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size != 128 { return ssz.ErrSize } - // Field (0) 'Slot' - a.Slot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[0:8]) - - // Field (1) 'Index' - a.Index = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.CommitteeIndex](buf[8:16]) + sszSlice0 := buf[0:8] // c.Slot + sszSlice1 := buf[8:16] // c.Index + sszSlice2 := buf[16:48] // c.BeaconBlockRoot + sszSlice3 := buf[48:88] // c.Source + sszSlice4 := buf[88:128] // c.Target - // Field (2) 'BeaconBlockRoot' - if cap(a.BeaconBlockRoot) == 0 { - a.BeaconBlockRoot = make([]byte, 0, len(buf[16:48])) + // Field 0: Slot + if err = c.Slot.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Slot: %w", err) } - a.BeaconBlockRoot = append(a.BeaconBlockRoot, 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 1: Index + if err = c.Index.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Index: %w", err) } - // Field (4) 'Target' - if a.Target == nil { - a.Target = new(Checkpoint) - } - if err = a.Target.UnmarshalSSZ(buf[88:128]); err != nil { - return err + // Field 2: BeaconBlockRoot + c.BeaconBlockRoot = make([]byte, 0, 32) + c.BeaconBlockRoot = append(c.BeaconBlockRoot, sszSlice2...) + + // Field 3: Source + c.Source = new(Checkpoint) + if err = c.Source.UnmarshalSSZ(sszSlice3); err != nil { + return fmt.Errorf("Source: %w", err) } + // Field 4: Target + c.Target = new(Checkpoint) + if err = c.Target.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("Target: %w", 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) +func (c *AttestationData) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the AttestationData object with a hasher -func (a *AttestationData) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *AttestationData) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Slot' - ssz.PutUint(hh, a.Slot) - - // Field (1) 'Index' - ssz.PutUint(hh, a.Index) - - // Field (2) 'BeaconBlockRoot' - if size := len(a.BeaconBlockRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.BeaconBlockRoot", size, 32) - return + // Field 0: Slot + if err := c.Slot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Slot: %w", err) } - hh.PutBytes(a.BeaconBlockRoot) - - // Field (3) 'Source' - if err = a.Source.HashTreeRootWith(hh); err != nil { - return + // Field 1: Index + if err := c.Index.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Index: %w", err) } - - // Field (4) 'Target' - if err = a.Target.HashTreeRootWith(hh); err != nil { - return + // Field 2: BeaconBlockRoot + if len(c.BeaconBlockRoot) != 32 { + return ssz.ErrBytesLength } - - hh.Merkleize(indx) - return -} - -// 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.MarshalUint(dst, c.Epoch) - - // Field (1) 'Root' - if size := len(c.Root); size != 32 { - err = ssz.ErrBytesLengthFn("--.Root", size, 32) - return + hh.PutBytes(c.BeaconBlockRoot) + // Field 3: Source + if err := c.Source.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Source: %w", err) } - 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.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Epoch](buf[0:8]) - - // Field (1) 'Root' - if cap(c.Root) == 0 { - c.Root = make([]byte, 0, len(buf[8:40])) + // Field 4: Target + if err := c.Target.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Target: %w", err) } - 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) + hh.Merkleize(indx) + return nil } -// HashTreeRootWith ssz hashes the Checkpoint object with a hasher -func (c *Checkpoint) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'Epoch' - ssz.PutUint(hh, c.Epoch) - - // Field (1) 'Root' - if size := len(c.Root); size != 32 { - err = ssz.ErrBytesLengthFn("--.Root", size, 32) - return +func (c *AttesterSlashing) SizeSSZ() int { + size := 8 + if c.Attestation_1 == nil { + c.Attestation_1 = new(IndexedAttestation) } - hh.PutBytes(c.Root) - - hh.Merkleize(indx) - return + size += c.Attestation_1.SizeSSZ() + if c.Attestation_2 == nil { + c.Attestation_2 = new(IndexedAttestation) + } + size += c.Attestation_2.SizeSSZ() + return size } -// MarshalSSZ ssz marshals the BeaconBlock object -func (b *BeaconBlock) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) +func (c *AttesterSlashing) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// 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.MarshalUint(dst, b.Slot) - - // Field (1) 'ProposerIndex' - dst = ssz.MarshalUint(dst, b.ProposerIndex) +func (c *AttesterSlashing) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 8 - // Field (2) 'ParentRoot' - if size := len(b.ParentRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentRoot", size, 32) - return + // Field 0: Attestation_1 + if c.Attestation_1 == nil { + c.Attestation_1 = new(IndexedAttestation) } - dst = append(dst, b.ParentRoot...) + dst = ssz.WriteOffset(dst, offset) + offset += c.Attestation_1.SizeSSZ() - // Field (3) 'StateRoot' - if size := len(b.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return + // Field 1: Attestation_2 + if c.Attestation_2 == nil { + c.Attestation_2 = new(IndexedAttestation) } - dst = append(dst, b.StateRoot...) - - // Offset (4) 'Body' dst = ssz.WriteOffset(dst, offset) - if b.Body == nil { - b.Body = new(BeaconBlockBody) - } - offset += b.Body.SizeSSZ() + offset += c.Attestation_2.SizeSSZ() - // Field (4) 'Body' - if dst, err = b.Body.MarshalSSZTo(dst); err != nil { - return + // Field 0: Attestation_1 + if dst, err = c.Attestation_1.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Attestation_1: %w", err) } - return + // Field 1: Attestation_2 + if dst, err = c.Attestation_2.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Attestation_2: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the BeaconBlock object -func (b *BeaconBlock) UnmarshalSSZ(buf []byte) error { +func (c *AttesterSlashing) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 84 { + if size < 8 { return ssz.ErrSize } - tail := buf - var o4 uint64 - - // Field (0) 'Slot' - b.Slot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[0:8]) - - // Field (1) 'ProposerIndex' - b.ProposerIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[8:16]) - - // Field (2) 'ParentRoot' - if cap(b.ParentRoot) == 0 { - b.ParentRoot = make([]byte, 0, len(buf[16:48])) + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Attestation_1 + if sszVarOffset0 != 8 { + return ssz.ErrInvalidVariableOffset } - 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])) + if sszVarOffset0 > size { + return ssz.ErrOffset } - b.StateRoot = append(b.StateRoot, buf[48:80]...) - - // Offset (4) 'Body' - if o4 = ssz.ReadOffset(buf[80:84]); o4 > size { + sszVarOffset1 := ssz.ReadOffset(buf[4:8]) // c.Attestation_2 + if sszVarOffset1 > size || sszVarOffset1 < sszVarOffset0 { return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:sszVarOffset1] // c.Attestation_1 + sszSlice1 := buf[sszVarOffset1:] // c.Attestation_2 - if o4 != 84 { - return ssz.ErrInvalidVariableOffset + // Field 0: Attestation_1 + c.Attestation_1 = new(IndexedAttestation) + if err = c.Attestation_1.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Attestation_1: %w", err) } - // Field (4) 'Body' - { - buf = tail[o4:] - if b.Body == nil { - b.Body = new(BeaconBlockBody) - } - if err = b.Body.UnmarshalSSZ(buf); err != nil { - return err - } + // Field 1: Attestation_2 + c.Attestation_2 = new(IndexedAttestation) + if err = c.Attestation_2.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Attestation_2: %w", 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) +func (c *AttesterSlashing) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - size += b.Body.SizeSSZ() - - return + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// 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.Hasher) (err error) { +func (c *AttesterSlashing) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Slot' - ssz.PutUint(hh, b.Slot) - - // Field (1) 'ProposerIndex' - ssz.PutUint(hh, b.ProposerIndex) - - // Field (2) 'ParentRoot' - if size := len(b.ParentRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentRoot", size, 32) - return + // Field 0: Attestation_1 + if err := c.Attestation_1.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Attestation_1: %w", err) } - hh.PutBytes(b.ParentRoot) - - // Field (3) 'StateRoot' - if size := len(b.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return + // Field 1: Attestation_2 + if err := c.Attestation_2.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Attestation_2: %w", err) } - hh.PutBytes(b.StateRoot) + hh.Merkleize(indx) + return nil +} - // Field (4) 'Body' - if err = b.Body.HashTreeRootWith(hh); err != nil { - return +func (c *BeaconBlock) SizeSSZ() int { + size := 84 + if c.Body == nil { + c.Body = new(BeaconBlockBody) } - - hh.Merkleize(indx) - return + size += c.Body.SizeSSZ() + return size } -// MarshalSSZ ssz marshals the SignedBeaconBlock object -func (s *SignedBeaconBlock) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) +func (c *BeaconBlock) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// 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) +func (c *BeaconBlock) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 84 + + // Field 0: Slot + if dst, err = c.Slot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Slot: %w", err) + } - // Offset (0) 'Block' - dst = ssz.WriteOffset(dst, offset) - if s.Block == nil { - s.Block = new(BeaconBlock) + // Field 1: ProposerIndex + if dst, err = c.ProposerIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ProposerIndex: %w", err) } - offset += s.Block.SizeSSZ() - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 2: ParentRoot + if len(c.ParentRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, s.Signature...) + dst = append(dst, c.ParentRoot...) - // Field (0) 'Block' - if dst, err = s.Block.MarshalSSZTo(dst); err != nil { - return + // Field 3: StateRoot + if len(c.StateRoot) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.StateRoot...) + + // Field 4: Body + if c.Body == nil { + c.Body = new(BeaconBlockBody) + } + dst = ssz.WriteOffset(dst, offset) + offset += c.Body.SizeSSZ() - return + // Field 4: Body + if dst, err = c.Body.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Body: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the SignedBeaconBlock object -func (s *SignedBeaconBlock) UnmarshalSSZ(buf []byte) error { +func (c *BeaconBlock) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 100 { + if size < 84 { return ssz.ErrSize } - tail := buf - var o0 uint64 + sszSlice0 := buf[0:8] // c.Slot + sszSlice1 := buf[8:16] // c.ProposerIndex + sszSlice2 := buf[16:48] // c.ParentRoot + sszSlice3 := buf[48:80] // c.StateRoot - // Offset (0) 'Block' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { + sszVarOffset4 := ssz.ReadOffset(buf[80:84]) // c.Body + if sszVarOffset4 != 84 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset4 > size { return ssz.ErrOffset } + sszSlice4 := buf[sszVarOffset4:] // c.Body - if o0 != 100 { - return ssz.ErrInvalidVariableOffset + // Field 0: Slot + if err = c.Slot.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Slot: %w", err) } - // Field (1) 'Signature' - if cap(s.Signature) == 0 { - s.Signature = make([]byte, 0, len(buf[4:100])) + // Field 1: ProposerIndex + if err = c.ProposerIndex.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("ProposerIndex: %w", err) } - 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 -} + // Field 2: ParentRoot + c.ParentRoot = make([]byte, 0, 32) + c.ParentRoot = append(c.ParentRoot, sszSlice2...) -// SizeSSZ returns the ssz encoded size in bytes for the SignedBeaconBlock object -func (s *SignedBeaconBlock) SizeSSZ() (size int) { - size = 100 + // Field 3: StateRoot + c.StateRoot = make([]byte, 0, 32) + c.StateRoot = append(c.StateRoot, sszSlice3...) - // Field (0) 'Block' - if s.Block == nil { - s.Block = new(BeaconBlock) + // Field 4: Body + c.Body = new(BeaconBlockBody) + if err = c.Body.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("Body: %w", err) } - size += s.Block.SizeSSZ() - - return + return err } -// HashTreeRoot ssz hashes the SignedBeaconBlock object -func (s *SignedBeaconBlock) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) +func (c *BeaconBlock) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the SignedBeaconBlock object with a hasher -func (s *SignedBeaconBlock) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *BeaconBlock) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Block' - if err = s.Block.HashTreeRootWith(hh); err != nil { - return + // Field 0: Slot + if err := c.Slot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Slot: %w", err) } - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 1: ProposerIndex + if err := c.ProposerIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ProposerIndex: %w", err) + } + // Field 2: ParentRoot + if len(c.ParentRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ParentRoot) + // Field 3: StateRoot + if len(c.StateRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.StateRoot) + // Field 4: Body + if err := c.Body.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Body: %w", err) } - hh.PutBytes(s.Signature) - hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the BeaconBlockBody object -func (b *BeaconBlockBody) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) +func (c *BeaconBlockBody) SizeSSZ() int { + size := 220 + size += len(c.ProposerSlashings) * 416 + for _, o := range c.AttesterSlashings { + size += 4 + size += o.SizeSSZ() + } + for _, o := range c.Attestations { + size += 4 + size += o.SizeSSZ() + } + size += len(c.Deposits) * 1240 + size += len(c.VoluntaryExits) * 112 + return size } -// MarshalSSZTo ssz marshals the BeaconBlockBody object to a target array -func (b *BeaconBlockBody) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(220) +func (c *BeaconBlockBody) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (0) 'RandaoReveal' - if size := len(b.RandaoReveal); size != 96 { - err = ssz.ErrBytesLengthFn("--.RandaoReveal", size, 96) - return +func (c *BeaconBlockBody) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 220 + + // Field 0: RandaoReveal + if len(c.RandaoReveal) != 96 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.RandaoReveal...) + dst = append(dst, c.RandaoReveal...) - // Field (1) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(Eth1Data) + // Field 1: Eth1Data + if c.Eth1Data == nil { + c.Eth1Data = new(Eth1Data) } - if dst, err = b.Eth1Data.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.Eth1Data.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Eth1Data: %w", err) } - // Field (2) 'Graffiti' - if size := len(b.Graffiti); size != 32 { - err = ssz.ErrBytesLengthFn("--.Graffiti", size, 32) - return + // Field 2: Graffiti + if len(c.Graffiti) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.Graffiti...) + dst = append(dst, c.Graffiti...) - // Offset (3) 'ProposerSlashings' + // Field 3: ProposerSlashings dst = ssz.WriteOffset(dst, offset) - offset += len(b.ProposerSlashings) * 416 + offset += len(c.ProposerSlashings) * 416 - // Offset (4) 'AttesterSlashings' + // Field 4: AttesterSlashings dst = ssz.WriteOffset(dst, offset) - for ii := 0; ii < len(b.AttesterSlashings); ii++ { + for _, o := range c.AttesterSlashings { offset += 4 - offset += b.AttesterSlashings[ii].SizeSSZ() + offset += o.SizeSSZ() } - // Offset (5) 'Attestations' + // Field 5: Attestations dst = ssz.WriteOffset(dst, offset) - for ii := 0; ii < len(b.Attestations); ii++ { + for _, o := range c.Attestations { offset += 4 - offset += b.Attestations[ii].SizeSSZ() + offset += o.SizeSSZ() } - // Offset (6) 'Deposits' + // Field 6: Deposits dst = ssz.WriteOffset(dst, offset) - offset += len(b.Deposits) * 1240 + offset += len(c.Deposits) * 1240 - // Offset (7) 'VoluntaryExits' + // Field 7: VoluntaryExits dst = ssz.WriteOffset(dst, offset) - offset += len(b.VoluntaryExits) * 112 + offset += len(c.VoluntaryExits) * 112 - // Field (3) 'ProposerSlashings' - if size := len(b.ProposerSlashings); size > 16 { - err = ssz.ErrListTooBigFn("--.ProposerSlashings", size, 16) - return + // Field 3: ProposerSlashings + if len(c.ProposerSlashings) > 16 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.ProposerSlashings); ii++ { - if dst, err = b.ProposerSlashings[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.ProposerSlashings { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ProposerSlashings: %w", err) } } - // Field (4) 'AttesterSlashings' - if size := len(b.AttesterSlashings); size > 2 { - err = ssz.ErrListTooBigFn("--.AttesterSlashings", size, 2) - return + // Field 4: AttesterSlashings + if len(c.AttesterSlashings) > 2 { + return nil, ssz.ErrListTooBig } { - offset = 4 * len(b.AttesterSlashings) - for ii := 0; ii < len(b.AttesterSlashings); ii++ { + offset = 4 * len(c.AttesterSlashings) + for _, o := range c.AttesterSlashings { dst = ssz.WriteOffset(dst, offset) - offset += b.AttesterSlashings[ii].SizeSSZ() + offset += o.SizeSSZ() } } - for ii := 0; ii < len(b.AttesterSlashings); ii++ { - if dst, err = b.AttesterSlashings[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.AttesterSlashings { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("AttesterSlashings: %w", err) } } - // Field (5) 'Attestations' - if size := len(b.Attestations); size > 128 { - err = ssz.ErrListTooBigFn("--.Attestations", size, 128) - return + // Field 5: Attestations + if len(c.Attestations) > 128 { + return nil, ssz.ErrListTooBig } { - offset = 4 * len(b.Attestations) - for ii := 0; ii < len(b.Attestations); ii++ { + offset = 4 * len(c.Attestations) + for _, o := range c.Attestations { dst = ssz.WriteOffset(dst, offset) - offset += b.Attestations[ii].SizeSSZ() + offset += o.SizeSSZ() } } - for ii := 0; ii < len(b.Attestations); ii++ { - if dst, err = b.Attestations[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.Attestations { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Attestations: %w", err) } } - // Field (6) 'Deposits' - if size := len(b.Deposits); size > 16 { - err = ssz.ErrListTooBigFn("--.Deposits", size, 16) - return + // Field 6: Deposits + if len(c.Deposits) > 16 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.Deposits); ii++ { - if dst, err = b.Deposits[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.Deposits { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Deposits: %w", err) } } - // Field (7) 'VoluntaryExits' - if size := len(b.VoluntaryExits); size > 16 { - err = ssz.ErrListTooBigFn("--.VoluntaryExits", size, 16) - return + // Field 7: VoluntaryExits + if len(c.VoluntaryExits) > 16 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.VoluntaryExits); ii++ { - if dst, err = b.VoluntaryExits[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.VoluntaryExits { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("VoluntaryExits: %w", err) } } - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the BeaconBlockBody object -func (b *BeaconBlockBody) UnmarshalSSZ(buf []byte) error { +func (c *BeaconBlockBody) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size < 220 { return ssz.ErrSize } - tail := buf - var o3, o4, o5, o6, o7 uint64 + sszSlice0 := buf[0:96] // c.RandaoReveal + sszSlice1 := buf[96:168] // c.Eth1Data + sszSlice2 := buf[168:200] // c.Graffiti - // 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(Eth1Data) - } - if err = b.Eth1Data.UnmarshalSSZ(buf[96:168]); err != nil { - return err - } - - // Field (2) 'Graffiti' - if cap(b.Graffiti) == 0 { - b.Graffiti = make([]byte, 0, len(buf[168:200])) + sszVarOffset3 := ssz.ReadOffset(buf[200:204]) // c.ProposerSlashings + if sszVarOffset3 != 220 { + return ssz.ErrInvalidVariableOffset } - b.Graffiti = append(b.Graffiti, buf[168:200]...) - - // Offset (3) 'ProposerSlashings' - if o3 = ssz.ReadOffset(buf[200:204]); o3 > size { + if sszVarOffset3 > size { return ssz.ErrOffset } - - if o3 != 220 { - return ssz.ErrInvalidVariableOffset + sszVarOffset4 := ssz.ReadOffset(buf[204:208]) // c.AttesterSlashings + if sszVarOffset4 > size || sszVarOffset4 < sszVarOffset3 { + return ssz.ErrOffset } - - // Offset (4) 'AttesterSlashings' - if o4 = ssz.ReadOffset(buf[204:208]); o4 > size || o3 > o4 { + sszVarOffset5 := ssz.ReadOffset(buf[208:212]) // c.Attestations + if sszVarOffset5 > size || sszVarOffset5 < sszVarOffset4 { return ssz.ErrOffset } - - // Offset (5) 'Attestations' - if o5 = ssz.ReadOffset(buf[208:212]); o5 > size || o4 > o5 { + sszVarOffset6 := ssz.ReadOffset(buf[212:216]) // c.Deposits + if sszVarOffset6 > size || sszVarOffset6 < sszVarOffset5 { return ssz.ErrOffset } - - // Offset (6) 'Deposits' - if o6 = ssz.ReadOffset(buf[212:216]); o6 > size || o5 > o6 { + sszVarOffset7 := ssz.ReadOffset(buf[216:220]) // c.VoluntaryExits + if sszVarOffset7 > size || sszVarOffset7 < sszVarOffset6 { return ssz.ErrOffset } + sszSlice3 := buf[sszVarOffset3:sszVarOffset4] // c.ProposerSlashings + sszSlice4 := buf[sszVarOffset4:sszVarOffset5] // c.AttesterSlashings + sszSlice5 := buf[sszVarOffset5:sszVarOffset6] // c.Attestations + sszSlice6 := buf[sszVarOffset6:sszVarOffset7] // c.Deposits + sszSlice7 := buf[sszVarOffset7:] // c.VoluntaryExits - // Offset (7) 'VoluntaryExits' - if o7 = ssz.ReadOffset(buf[216:220]); o7 > size || o6 > o7 { - return ssz.ErrOffset + // Field 0: RandaoReveal + c.RandaoReveal = make([]byte, 0, 96) + c.RandaoReveal = append(c.RandaoReveal, sszSlice0...) + + // Field 1: Eth1Data + c.Eth1Data = new(Eth1Data) + if err = c.Eth1Data.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Eth1Data: %w", err) } - // Field (3) 'ProposerSlashings' + // Field 2: Graffiti + c.Graffiti = make([]byte, 0, 32) + c.Graffiti = append(c.Graffiti, sszSlice2...) + + // Field 3: ProposerSlashings { - buf = tail[o3:o4] - num, err := ssz.DivideInt2(len(buf), 416, 16) - if err != nil { - return err + if len(sszSlice3)%416 != 0 { + return fmt.Errorf("misaligned bytes: c.ProposerSlashings length is %d, which is not a multiple of 416: %w", len(sszSlice3), ssz.ErrIncorrectListSize) } - b.ProposerSlashings = make([]*ProposerSlashing, num) - for ii := 0; ii < num; ii++ { - if b.ProposerSlashings[ii] == nil { - b.ProposerSlashings[ii] = new(ProposerSlashing) - } - if err = b.ProposerSlashings[ii].UnmarshalSSZ(buf[ii*416 : (ii+1)*416]); err != nil { - return err + numElem := len(sszSlice3) / 416 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.ProposerSlashings has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.ProposerSlashings = make([]*ProposerSlashing, numElem) + for i := 0; i < numElem; i++ { + var tmp *ProposerSlashing + tmp = new(ProposerSlashing) + tmpSlice := sszSlice3[i*416 : (1+i)*416] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("ProposerSlashings: %w", err) } + c.ProposerSlashings[i] = tmp } } - // Field (4) 'AttesterSlashings' + // Field 4: AttesterSlashings { - buf = tail[o4:o5] - num, err := ssz.DecodeDynamicLength(buf, 2) - 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) + // empty lists are zero length, so make sure there is room for an offset + // before attempting to unmarshal it + if len(sszSlice4) > 3 { + startOffset := ssz.ReadOffset(sszSlice4[0:4]) + if startOffset == 0 { + return fmt.Errorf("encountered invalid offset of 0 when decoding c.AttesterSlashings") + } + if startOffset%4 != 0 { + return fmt.Errorf("misaligned list bytes: when decoding c.AttesterSlashings, end-of-list offset is %d, which is not a multiple of 4 (offset size)", startOffset) + } + listLen := startOffset / 4 + if listLen > 2 { + return fmt.Errorf("ssz-max exceeded: c.AttesterSlashings has %d elements, ssz-max is 2: %w", listLen, ssz.ErrListTooBig) } - if err = b.AttesterSlashings[indx].UnmarshalSSZ(buf); err != nil { - return err + totalVarBytes := uint64(len(sszSlice4)) + if totalVarBytes < startOffset { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.AttesterSlashings") } - return nil - }) - if err != nil { - return err + c.AttesterSlashings = make([]*AttesterSlashing, listLen) + var tmpSlice []byte + for i := uint64(0); i < listLen; i++ { + var tmp *AttesterSlashing + tmp = new(AttesterSlashing) + endOffset := totalVarBytes + if i+1 != listLen { + endOffset = ssz.ReadOffset(sszSlice4[(i+1)*4 : (i+2)*4]) + if totalVarBytes < endOffset { + return fmt.Errorf("offset %d points past the end of buffer when decoding c.AttesterSlashings", endOffset) + } + } + if endOffset < startOffset { + return fmt.Errorf("offset %d is not greater than start offset %d when decoding c.AttesterSlashings", endOffset, startOffset) + } + tmpSlice = sszSlice4[startOffset:endOffset] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("AttesterSlashings: %w", err) + } + c.AttesterSlashings[i] = tmp + startOffset = endOffset + } + } else { + if len(sszSlice4) > 0 { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.AttesterSlashings") + } + c.AttesterSlashings = make([]*AttesterSlashing, 0) } } - // Field (5) 'Attestations' + // Field 5: Attestations { - buf = tail[o5:o6] - num, err := ssz.DecodeDynamicLength(buf, 128) - 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) + // empty lists are zero length, so make sure there is room for an offset + // before attempting to unmarshal it + if len(sszSlice5) > 3 { + startOffset := ssz.ReadOffset(sszSlice5[0:4]) + if startOffset == 0 { + return fmt.Errorf("encountered invalid offset of 0 when decoding c.Attestations") } - if err = b.Attestations[indx].UnmarshalSSZ(buf); err != nil { - return err + if startOffset%4 != 0 { + return fmt.Errorf("misaligned list bytes: when decoding c.Attestations, end-of-list offset is %d, which is not a multiple of 4 (offset size)", startOffset) } - return nil - }) - if err != nil { - return err + listLen := startOffset / 4 + if listLen > 128 { + return fmt.Errorf("ssz-max exceeded: c.Attestations has %d elements, ssz-max is 128: %w", listLen, ssz.ErrListTooBig) + } + totalVarBytes := uint64(len(sszSlice5)) + if totalVarBytes < startOffset { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.Attestations") + } + c.Attestations = make([]*Attestation, listLen) + var tmpSlice []byte + for i := uint64(0); i < listLen; i++ { + var tmp *Attestation + tmp = new(Attestation) + endOffset := totalVarBytes + if i+1 != listLen { + endOffset = ssz.ReadOffset(sszSlice5[(i+1)*4 : (i+2)*4]) + if totalVarBytes < endOffset { + return fmt.Errorf("offset %d points past the end of buffer when decoding c.Attestations", endOffset) + } + } + if endOffset < startOffset { + return fmt.Errorf("offset %d is not greater than start offset %d when decoding c.Attestations", endOffset, startOffset) + } + tmpSlice = sszSlice5[startOffset:endOffset] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Attestations: %w", err) + } + c.Attestations[i] = tmp + startOffset = endOffset + } + } else { + if len(sszSlice5) > 0 { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.Attestations") + } + c.Attestations = make([]*Attestation, 0) } } - // Field (6) 'Deposits' + // Field 6: Deposits { - buf = tail[o6:o7] - num, err := ssz.DivideInt2(len(buf), 1240, 16) - if err != nil { - return err + if len(sszSlice6)%1240 != 0 { + return fmt.Errorf("misaligned bytes: c.Deposits length is %d, which is not a multiple of 1240: %w", len(sszSlice6), ssz.ErrIncorrectListSize) } - b.Deposits = make([]*Deposit, num) - for ii := 0; ii < num; ii++ { - if b.Deposits[ii] == nil { - b.Deposits[ii] = new(Deposit) - } - if err = b.Deposits[ii].UnmarshalSSZ(buf[ii*1240 : (ii+1)*1240]); err != nil { - return err + numElem := len(sszSlice6) / 1240 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.Deposits has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.Deposits = make([]*Deposit, numElem) + for i := 0; i < numElem; i++ { + var tmp *Deposit + tmp = new(Deposit) + tmpSlice := sszSlice6[i*1240 : (1+i)*1240] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Deposits: %w", err) } + c.Deposits[i] = tmp } } - // Field (7) 'VoluntaryExits' + // Field 7: VoluntaryExits { - buf = tail[o7:] - num, err := ssz.DivideInt2(len(buf), 112, 16) - if err != nil { - return err + if len(sszSlice7)%112 != 0 { + return fmt.Errorf("misaligned bytes: c.VoluntaryExits length is %d, which is not a multiple of 112: %w", len(sszSlice7), ssz.ErrIncorrectListSize) } - b.VoluntaryExits = make([]*SignedVoluntaryExit, num) - for ii := 0; ii < num; ii++ { - if b.VoluntaryExits[ii] == nil { - b.VoluntaryExits[ii] = new(SignedVoluntaryExit) - } - if err = b.VoluntaryExits[ii].UnmarshalSSZ(buf[ii*112 : (ii+1)*112]); err != nil { - return err + numElem := len(sszSlice7) / 112 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.VoluntaryExits has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.VoluntaryExits = make([]*SignedVoluntaryExit, numElem) + for i := 0; i < numElem; i++ { + var tmp *SignedVoluntaryExit + tmp = new(SignedVoluntaryExit) + tmpSlice := sszSlice7[i*112 : (1+i)*112] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("VoluntaryExits: %w", err) } + c.VoluntaryExits[i] = tmp } } return err } -// SizeSSZ returns the ssz encoded size in bytes for the BeaconBlockBody object -func (b *BeaconBlockBody) SizeSSZ() (size int) { - size = 220 - - // 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() +func (c *BeaconBlockBody) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - - // 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 - - return -} - -// HashTreeRoot ssz hashes the BeaconBlockBody object -func (b *BeaconBlockBody) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the BeaconBlockBody object with a hasher -func (b *BeaconBlockBody) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *BeaconBlockBody) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'RandaoReveal' - if size := len(b.RandaoReveal); size != 96 { - err = ssz.ErrBytesLengthFn("--.RandaoReveal", size, 96) - return + // Field 0: RandaoReveal + if len(c.RandaoReveal) != 96 { + return ssz.ErrBytesLength } - hh.PutBytes(b.RandaoReveal) - - // Field (1) 'Eth1Data' - if err = b.Eth1Data.HashTreeRootWith(hh); err != nil { - return + hh.PutBytes(c.RandaoReveal) + // Field 1: Eth1Data + if err := c.Eth1Data.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Eth1Data: %w", err) } - - // Field (2) 'Graffiti' - if size := len(b.Graffiti); size != 32 { - err = ssz.ErrBytesLengthFn("--.Graffiti", size, 32) - return + // Field 2: Graffiti + if len(c.Graffiti) != 32 { + return ssz.ErrBytesLength } - hh.PutBytes(b.Graffiti) - - // Field (3) 'ProposerSlashings' + hh.PutBytes(c.Graffiti) + // Field 3: ProposerSlashings { - subIndx := hh.Index() - num := uint64(len(b.ProposerSlashings)) - if num > 16 { - err = ssz.ErrIncorrectListSize - return + if len(c.ProposerSlashings) > 16 { + return ssz.ErrListTooBig } - for _, elem := range b.ProposerSlashings { - if err = elem.HashTreeRootWith(hh); err != nil { - return + subIndx := hh.Index() + for _, o := range c.ProposerSlashings { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ProposerSlashings: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.ProposerSlashings)), 16) } - - // Field (4) 'AttesterSlashings' + // Field 4: AttesterSlashings { - subIndx := hh.Index() - num := uint64(len(b.AttesterSlashings)) - if num > 2 { - err = ssz.ErrIncorrectListSize - return + if len(c.AttesterSlashings) > 2 { + return ssz.ErrListTooBig } - for _, elem := range b.AttesterSlashings { - if err = elem.HashTreeRootWith(hh); err != nil { - return + subIndx := hh.Index() + for _, o := range c.AttesterSlashings { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("AttesterSlashings: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 2) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.AttesterSlashings)), 2) } - - // Field (5) 'Attestations' + // Field 5: Attestations { - subIndx := hh.Index() - num := uint64(len(b.Attestations)) - if num > 128 { - err = ssz.ErrIncorrectListSize - return + if len(c.Attestations) > 128 { + return ssz.ErrListTooBig } - for _, elem := range b.Attestations { - if err = elem.HashTreeRootWith(hh); err != nil { - return + subIndx := hh.Index() + for _, o := range c.Attestations { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Attestations: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 128) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Attestations)), 128) } - - // Field (6) 'Deposits' + // Field 6: Deposits { - subIndx := hh.Index() - num := uint64(len(b.Deposits)) - if num > 16 { - err = ssz.ErrIncorrectListSize - return + if len(c.Deposits) > 16 { + return ssz.ErrListTooBig } - for _, elem := range b.Deposits { - if err = elem.HashTreeRootWith(hh); err != nil { - return + subIndx := hh.Index() + for _, o := range c.Deposits { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Deposits: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Deposits)), 16) } - - // Field (7) 'VoluntaryExits' + // Field 7: VoluntaryExits { - subIndx := hh.Index() - num := uint64(len(b.VoluntaryExits)) - if num > 16 { - err = ssz.ErrIncorrectListSize - return + if len(c.VoluntaryExits) > 16 { + return ssz.ErrListTooBig } - for _, elem := range b.VoluntaryExits { - if err = elem.HashTreeRootWith(hh); err != nil { - return + subIndx := hh.Index() + for _, o := range c.VoluntaryExits { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("VoluntaryExits: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.VoluntaryExits)), 16) } - hh.Merkleize(indx) - return + return nil +} + +func (c *BeaconBlockHeader) SizeSSZ() int { + size := 112 + + return size } -// MarshalSSZ ssz marshals the ProposerSlashing object -func (p *ProposerSlashing) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(p) +func (c *BeaconBlockHeader) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the ProposerSlashing object to a target array -func (p *ProposerSlashing) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *BeaconBlockHeader) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (0) 'SignedHeader_1' - if p.SignedHeader_1 == nil { - p.SignedHeader_1 = new(SignedBeaconBlockHeader) + // Field 0: Slot + if dst, err = c.Slot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Slot: %w", err) } - if dst, err = p.SignedHeader_1.MarshalSSZTo(dst); err != nil { - return + + // Field 1: ProposerIndex + if dst, err = c.ProposerIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ProposerIndex: %w", err) } - // Field (1) 'SignedHeader_2' - if p.SignedHeader_2 == nil { - p.SignedHeader_2 = new(SignedBeaconBlockHeader) + // Field 2: ParentRoot + if len(c.ParentRoot) != 32 { + return nil, ssz.ErrBytesLength } - if dst, err = p.SignedHeader_2.MarshalSSZTo(dst); err != nil { - return + dst = append(dst, c.ParentRoot...) + + // Field 3: StateRoot + if len(c.StateRoot) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.StateRoot...) + + // Field 4: BodyRoot + if len(c.BodyRoot) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.BodyRoot...) - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the ProposerSlashing object -func (p *ProposerSlashing) UnmarshalSSZ(buf []byte) error { +func (c *BeaconBlockHeader) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 416 { + if size != 112 { return ssz.ErrSize } - // Field (0) 'SignedHeader_1' - if p.SignedHeader_1 == nil { - p.SignedHeader_1 = new(SignedBeaconBlockHeader) - } - if err = p.SignedHeader_1.UnmarshalSSZ(buf[0:208]); err != nil { - return err - } + sszSlice0 := buf[0:8] // c.Slot + sszSlice1 := buf[8:16] // c.ProposerIndex + sszSlice2 := buf[16:48] // c.ParentRoot + sszSlice3 := buf[48:80] // c.StateRoot + sszSlice4 := buf[80:112] // c.BodyRoot - // Field (1) 'SignedHeader_2' - if p.SignedHeader_2 == nil { - p.SignedHeader_2 = new(SignedBeaconBlockHeader) + // Field 0: Slot + if err = c.Slot.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Slot: %w", err) } - if err = p.SignedHeader_2.UnmarshalSSZ(buf[208:416]); err != nil { - return err + + // Field 1: ProposerIndex + if err = c.ProposerIndex.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("ProposerIndex: %w", err) } - return err -} + // Field 2: ParentRoot + c.ParentRoot = make([]byte, 0, 32) + c.ParentRoot = append(c.ParentRoot, sszSlice2...) -// SizeSSZ returns the ssz encoded size in bytes for the ProposerSlashing object -func (p *ProposerSlashing) SizeSSZ() (size int) { - size = 416 - return + // Field 3: StateRoot + c.StateRoot = make([]byte, 0, 32) + c.StateRoot = append(c.StateRoot, sszSlice3...) + + // Field 4: BodyRoot + c.BodyRoot = make([]byte, 0, 32) + c.BodyRoot = append(c.BodyRoot, sszSlice4...) + return err } -// HashTreeRoot ssz hashes the ProposerSlashing object -func (p *ProposerSlashing) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(p) +func (c *BeaconBlockHeader) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the ProposerSlashing object with a hasher -func (p *ProposerSlashing) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *BeaconBlockHeader) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'SignedHeader_1' - if err = p.SignedHeader_1.HashTreeRootWith(hh); err != nil { - return + // Field 0: Slot + if err := c.Slot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Slot: %w", err) } - - // Field (1) 'SignedHeader_2' - if err = p.SignedHeader_2.HashTreeRootWith(hh); err != nil { - return + // Field 1: ProposerIndex + if err := c.ProposerIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ProposerIndex: %w", err) } - + // Field 2: ParentRoot + if len(c.ParentRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ParentRoot) + // Field 3: StateRoot + if len(c.StateRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.StateRoot) + // Field 4: BodyRoot + if len(c.BodyRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.BodyRoot) hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the AttesterSlashing object -func (a *AttesterSlashing) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(a) -} +func (c *Checkpoint) SizeSSZ() int { + size := 40 -// 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) + return size +} - // Offset (0) 'Attestation_1' - dst = ssz.WriteOffset(dst, offset) - if a.Attestation_1 == nil { - a.Attestation_1 = new(IndexedAttestation) - } - offset += a.Attestation_1.SizeSSZ() +func (c *Checkpoint) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Offset (1) 'Attestation_2' - dst = ssz.WriteOffset(dst, offset) - if a.Attestation_2 == nil { - a.Attestation_2 = new(IndexedAttestation) - } - offset += a.Attestation_2.SizeSSZ() +func (c *Checkpoint) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (0) 'Attestation_1' - if dst, err = a.Attestation_1.MarshalSSZTo(dst); err != nil { - return + // Field 0: Epoch + if dst, err = c.Epoch.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Epoch: %w", err) } - // Field (1) 'Attestation_2' - if dst, err = a.Attestation_2.MarshalSSZTo(dst); err != nil { - return + // Field 1: Root + if len(c.Root) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.Root...) - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the AttesterSlashing object -func (a *AttesterSlashing) UnmarshalSSZ(buf []byte) error { +func (c *Checkpoint) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 8 { + if size != 40 { return ssz.ErrSize } - tail := buf - var o0, o1 uint64 - - // Offset (0) 'Attestation_1' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } - - if o0 != 8 { - return ssz.ErrInvalidVariableOffset - } + sszSlice0 := buf[0:8] // c.Epoch + sszSlice1 := buf[8:40] // c.Root - // Offset (1) 'Attestation_2' - if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 { - return ssz.ErrOffset + // Field 0: Epoch + if err = c.Epoch.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Epoch: %w", err) } - // Field (0) 'Attestation_1' - { - buf = tail[o0:o1] - if a.Attestation_1 == nil { - a.Attestation_1 = new(IndexedAttestation) - } - if err = a.Attestation_1.UnmarshalSSZ(buf); err != nil { - return err - } - } - - // Field (1) 'Attestation_2' - { - buf = tail[o1:] - if a.Attestation_2 == nil { - a.Attestation_2 = new(IndexedAttestation) - } - if err = a.Attestation_2.UnmarshalSSZ(buf); err != nil { - return err - } - } + // Field 1: Root + c.Root = make([]byte, 0, 32) + c.Root = append(c.Root, sszSlice1...) return err } -// SizeSSZ returns the ssz encoded size in bytes for the AttesterSlashing object -func (a *AttesterSlashing) SizeSSZ() (size int) { - size = 8 - - // Field (0) 'Attestation_1' - if a.Attestation_1 == nil { - a.Attestation_1 = new(IndexedAttestation) - } - size += a.Attestation_1.SizeSSZ() - - // Field (1) 'Attestation_2' - if a.Attestation_2 == nil { - a.Attestation_2 = new(IndexedAttestation) +func (c *Checkpoint) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - size += a.Attestation_2.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the AttesterSlashing object -func (a *AttesterSlashing) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(a) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the AttesterSlashing object with a hasher -func (a *AttesterSlashing) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *Checkpoint) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Attestation_1' - if err = a.Attestation_1.HashTreeRootWith(hh); err != nil { - return + // Field 0: Epoch + if err := c.Epoch.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Epoch: %w", err) } - - // Field (1) 'Attestation_2' - if err = a.Attestation_2.HashTreeRootWith(hh); err != nil { - return + // Field 1: Root + if len(c.Root) != 32 { + return ssz.ErrBytesLength } - + hh.PutBytes(c.Root) hh.Merkleize(indx) - return + return nil +} + +func (c *Deposit) SizeSSZ() int { + size := 1240 + + return size } -// MarshalSSZ ssz marshals the Deposit object -func (d *Deposit) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(d) +func (c *Deposit) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the Deposit object to a target array -func (d *Deposit) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *Deposit) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (0) 'Proof' - if size := len(d.Proof); size != 33 { - err = ssz.ErrVectorLengthFn("--.Proof", size, 33) - return + // Field 0: Proof + if len(c.Proof) != 33 { + return nil, ssz.ErrBytesLength } - for ii := 0; ii < 33; ii++ { - if size := len(d.Proof[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.Proof[ii]", size, 32) - return + for _, o := range c.Proof { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, d.Proof[ii]...) + dst = append(dst, o...) } - // Field (1) 'Data' - if d.Data == nil { - d.Data = new(Deposit_Data) + // Field 1: Data + if c.Data == nil { + c.Data = new(Deposit_Data) } - if dst, err = d.Data.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.Data.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Data: %w", err) } - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the Deposit object -func (d *Deposit) UnmarshalSSZ(buf []byte) error { +func (c *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])) + sszSlice0 := buf[0:1056] // c.Proof + sszSlice1 := buf[1056:1240] // c.Data + + // Field 0: Proof + { + c.Proof = make([][]byte, 33) + for i := 0; i < 33; i++ { + var tmp []byte + + tmpSlice := sszSlice0[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.Proof[i] = tmp } - 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(Deposit_Data) - } - if err = d.Data.UnmarshalSSZ(buf[1056:1240]); err != nil { - return err + // Field 1: Data + c.Data = new(Deposit_Data) + if err = c.Data.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Data: %w", 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) +func (c *Deposit) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the Deposit object with a hasher -func (d *Deposit) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *Deposit) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Proof' + // Field 0: Proof { - if size := len(d.Proof); size != 33 { - err = ssz.ErrVectorLengthFn("--.Proof", size, 33) - return + if len(c.Proof) != 33 { + return ssz.ErrVectorLength } subIndx := hh.Index() - for _, i := range d.Proof { - if len(i) != 32 { - err = ssz.ErrBytesLength - return + for _, o := range c.Proof { + if len(o) != 32 { + return ssz.ErrBytesLength } - hh.Append(i) + hh.Append(o) } hh.Merkleize(subIndx) } - - // Field (1) 'Data' - if err = d.Data.HashTreeRootWith(hh); err != nil { - return + // Field 1: Data + if err := c.Data.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Data: %w", err) } - hh.Merkleize(indx) - return + return nil +} + +func (c *Deposit_Data) SizeSSZ() int { + size := 184 + + return size } -// MarshalSSZ ssz marshals the VoluntaryExit object -func (v *VoluntaryExit) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(v) +func (c *Deposit_Data) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the VoluntaryExit object to a target array -func (v *VoluntaryExit) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *Deposit_Data) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + + // Field 0: Pubkey + if len(c.Pubkey) != 48 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.Pubkey...) + + // Field 1: WithdrawalCredentials + if len(c.WithdrawalCredentials) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.WithdrawalCredentials...) - // Field (0) 'Epoch' - dst = ssz.MarshalUint(dst, v.Epoch) + // Field 2: Amount + dst = binary.LittleEndian.AppendUint64(dst, c.Amount) - // Field (1) 'ValidatorIndex' - dst = ssz.MarshalUint(dst, v.ValidatorIndex) + // Field 3: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.Signature...) - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the VoluntaryExit object -func (v *VoluntaryExit) UnmarshalSSZ(buf []byte) error { +func (c *Deposit_Data) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 16 { + if size != 184 { return ssz.ErrSize } - // Field (0) 'Epoch' - v.Epoch = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Epoch](buf[0:8]) + sszSlice0 := buf[0:48] // c.Pubkey + sszSlice1 := buf[48:80] // c.WithdrawalCredentials + sszSlice2 := buf[80:88] // c.Amount + sszSlice3 := buf[88:184] // c.Signature - // Field (1) 'ValidatorIndex' - v.ValidatorIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[8:16]) + // Field 0: Pubkey + c.Pubkey = make([]byte, 0, 48) + c.Pubkey = append(c.Pubkey, sszSlice0...) - return err -} + // Field 1: WithdrawalCredentials + c.WithdrawalCredentials = make([]byte, 0, 32) + c.WithdrawalCredentials = append(c.WithdrawalCredentials, sszSlice1...) -// SizeSSZ returns the ssz encoded size in bytes for the VoluntaryExit object -func (v *VoluntaryExit) SizeSSZ() (size int) { - size = 16 - return + // Field 2: Amount + c.Amount = binary.LittleEndian.Uint64(sszSlice2) + + // Field 3: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice3...) + return err } -// HashTreeRoot ssz hashes the VoluntaryExit object -func (v *VoluntaryExit) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(v) +func (c *Deposit_Data) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the VoluntaryExit object with a hasher -func (v *VoluntaryExit) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *Deposit_Data) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() + // Field 0: Pubkey + if len(c.Pubkey) != 48 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Pubkey) + // Field 1: WithdrawalCredentials + if len(c.WithdrawalCredentials) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.WithdrawalCredentials) + // Field 2: Amount + hh.PutUint64(c.Amount) + // Field 3: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Signature) + hh.Merkleize(indx) + return nil +} - // Field (0) 'Epoch' - ssz.PutUint(hh, v.Epoch) - - // Field (1) 'ValidatorIndex' - ssz.PutUint(hh, v.ValidatorIndex) +func (c *Eth1Data) SizeSSZ() int { + size := 72 - hh.Merkleize(indx) - return + return size } -// MarshalSSZ ssz marshals the SignedVoluntaryExit object -func (s *SignedVoluntaryExit) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) +func (c *Eth1Data) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the SignedVoluntaryExit object to a target array -func (s *SignedVoluntaryExit) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *Eth1Data) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (0) 'Message' - if s.Message == nil { - s.Message = new(VoluntaryExit) - } - if dst, err = s.Message.MarshalSSZTo(dst); err != nil { - return + // Field 0: DepositRoot + if len(c.DepositRoot) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.DepositRoot...) + + // Field 1: DepositCount + dst = binary.LittleEndian.AppendUint64(dst, c.DepositCount) - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 2: BlockHash + if len(c.BlockHash) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, s.Signature...) + dst = append(dst, c.BlockHash...) - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the SignedVoluntaryExit object -func (s *SignedVoluntaryExit) UnmarshalSSZ(buf []byte) error { +func (c *Eth1Data) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 112 { + if size != 72 { return ssz.ErrSize } - // Field (0) 'Message' - if s.Message == nil { - s.Message = new(VoluntaryExit) - } - if err = s.Message.UnmarshalSSZ(buf[0:16]); err != nil { - return err - } + sszSlice0 := buf[0:32] // c.DepositRoot + sszSlice1 := buf[32:40] // c.DepositCount + sszSlice2 := buf[40:72] // c.BlockHash - // Field (1) 'Signature' - if cap(s.Signature) == 0 { - s.Signature = make([]byte, 0, len(buf[16:112])) - } - s.Signature = append(s.Signature, buf[16:112]...) + // Field 0: DepositRoot + c.DepositRoot = make([]byte, 0, 32) + c.DepositRoot = append(c.DepositRoot, sszSlice0...) - return err -} + // Field 1: DepositCount + c.DepositCount = binary.LittleEndian.Uint64(sszSlice1) -// SizeSSZ returns the ssz encoded size in bytes for the SignedVoluntaryExit object -func (s *SignedVoluntaryExit) SizeSSZ() (size int) { - size = 112 - return + // Field 2: BlockHash + c.BlockHash = make([]byte, 0, 32) + c.BlockHash = append(c.BlockHash, sszSlice2...) + return err } -// HashTreeRoot ssz hashes the SignedVoluntaryExit object -func (s *SignedVoluntaryExit) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) +func (c *Eth1Data) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the SignedVoluntaryExit object with a hasher -func (s *SignedVoluntaryExit) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *Eth1Data) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Message' - if err = s.Message.HashTreeRootWith(hh); err != nil { - return - } - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return - } - hh.PutBytes(s.Signature) - + // Field 0: DepositRoot + if len(c.DepositRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.DepositRoot) + // Field 1: DepositCount + hh.PutUint64(c.DepositCount) + // Field 2: BlockHash + if len(c.BlockHash) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.BlockHash) hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the Eth1Data object -func (e *Eth1Data) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(e) +func (c *IndexedAttestation) SizeSSZ() int { + size := 228 + size += len(c.AttestingIndices) * 8 + return size } -// MarshalSSZTo ssz marshals the Eth1Data object to a target array -func (e *Eth1Data) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *IndexedAttestation) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (0) 'DepositRoot' - if size := len(e.DepositRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.DepositRoot", size, 32) - return - } - dst = append(dst, e.DepositRoot...) +func (c *IndexedAttestation) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 228 + + // Field 0: AttestingIndices + dst = ssz.WriteOffset(dst, offset) + offset += len(c.AttestingIndices) * 8 - // Field (1) 'DepositCount' - dst = ssz.MarshalUint(dst, e.DepositCount) + // Field 1: Data + if c.Data == nil { + c.Data = new(AttestationData) + } + if dst, err = c.Data.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Data: %w", err) + } - // Field (2) 'BlockHash' - if size := len(e.BlockHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockHash", size, 32) - return + // Field 2: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.BlockHash...) + dst = append(dst, c.Signature...) - return + // Field 0: AttestingIndices + if len(c.AttestingIndices) > 2048 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.AttestingIndices { + dst = binary.LittleEndian.AppendUint64(dst, o) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the Eth1Data object -func (e *Eth1Data) UnmarshalSSZ(buf []byte) error { +func (c *IndexedAttestation) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 72 { + if size < 228 { return ssz.ErrSize } - // Field (0) 'DepositRoot' - if cap(e.DepositRoot) == 0 { - e.DepositRoot = make([]byte, 0, len(buf[0:32])) + sszSlice1 := buf[4:132] // c.Data + sszSlice2 := buf[132:228] // c.Signature + + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.AttestingIndices + if sszVarOffset0 != 228 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset0 > size { + return ssz.ErrOffset } - e.DepositRoot = append(e.DepositRoot, buf[0:32]...) + sszSlice0 := buf[sszVarOffset0:] // c.AttestingIndices + + // Field 0: AttestingIndices + { + if len(sszSlice0)%8 != 0 { + return fmt.Errorf("misaligned bytes: c.AttestingIndices length is %d, which is not a multiple of 8: %w", len(sszSlice0), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice0) / 8 + if numElem > 2048 { + return fmt.Errorf("ssz-max exceeded: c.AttestingIndices has %d elements, ssz-max is 2048: %w", numElem, ssz.ErrListTooBig) + } + c.AttestingIndices = make([]uint64, numElem) + for i := 0; i < numElem; i++ { + var tmp uint64 - // Field (1) 'DepositCount' - e.DepositCount = ssz.UnmarshallUint[uint64](buf[32:40]) + tmpSlice := sszSlice0[i*8 : (1+i)*8] + tmp = binary.LittleEndian.Uint64(tmpSlice) + c.AttestingIndices[i] = tmp + } + } - // Field (2) 'BlockHash' - if cap(e.BlockHash) == 0 { - e.BlockHash = make([]byte, 0, len(buf[40:72])) + // Field 1: Data + c.Data = new(AttestationData) + if err = c.Data.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Data: %w", err) } - e.BlockHash = append(e.BlockHash, buf[40:72]...) + // Field 2: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice2...) 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) +func (c *IndexedAttestation) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the Eth1Data object with a hasher -func (e *Eth1Data) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *IndexedAttestation) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'DepositRoot' - if size := len(e.DepositRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.DepositRoot", size, 32) - return + // Field 0: AttestingIndices + { + if len(c.AttestingIndices) > 2048 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.AttestingIndices { + hh.AppendUint64(o) + } + hh.FillUpTo32() + numItems := uint64(len(c.AttestingIndices)) + hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(2048, numItems, 8)) } - hh.PutBytes(e.DepositRoot) - - // Field (1) 'DepositCount' - ssz.PutUint(hh, e.DepositCount) - - // Field (2) 'BlockHash' - if size := len(e.BlockHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockHash", size, 32) - return + // Field 1: Data + if err := c.Data.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Data: %w", err) } - hh.PutBytes(e.BlockHash) - + // Field 2: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Signature) hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the BeaconBlockHeader object -func (b *BeaconBlockHeader) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} +func (c *ProposerSlashing) SizeSSZ() int { + size := 416 -// MarshalSSZTo ssz marshals the BeaconBlockHeader object to a target array -func (b *BeaconBlockHeader) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf + return size +} - // Field (0) 'Slot' - dst = ssz.MarshalUint(dst, b.Slot) +func (c *ProposerSlashing) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (1) 'ProposerIndex' - dst = ssz.MarshalUint(dst, b.ProposerIndex) +func (c *ProposerSlashing) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (2) 'ParentRoot' - if size := len(b.ParentRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentRoot", size, 32) - return + // Field 0: SignedHeader_1 + if c.SignedHeader_1 == nil { + c.SignedHeader_1 = new(SignedBeaconBlockHeader) } - dst = append(dst, b.ParentRoot...) - - // Field (3) 'StateRoot' - if size := len(b.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return + if dst, err = c.SignedHeader_1.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SignedHeader_1: %w", err) } - dst = append(dst, b.StateRoot...) - // Field (4) 'BodyRoot' - if size := len(b.BodyRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.BodyRoot", size, 32) - return + // Field 1: SignedHeader_2 + if c.SignedHeader_2 == nil { + c.SignedHeader_2 = new(SignedBeaconBlockHeader) + } + if dst, err = c.SignedHeader_2.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SignedHeader_2: %w", err) } - dst = append(dst, b.BodyRoot...) - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the BeaconBlockHeader object -func (b *BeaconBlockHeader) UnmarshalSSZ(buf []byte) error { +func (c *ProposerSlashing) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 112 { + if size != 416 { return ssz.ErrSize } - // Field (0) 'Slot' - b.Slot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[0:8]) - - // Field (1) 'ProposerIndex' - b.ProposerIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](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]...) + sszSlice0 := buf[0:208] // c.SignedHeader_1 + sszSlice1 := buf[208:416] // c.SignedHeader_2 - // Field (3) 'StateRoot' - if cap(b.StateRoot) == 0 { - b.StateRoot = make([]byte, 0, len(buf[48:80])) + // Field 0: SignedHeader_1 + c.SignedHeader_1 = new(SignedBeaconBlockHeader) + if err = c.SignedHeader_1.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("SignedHeader_1: %w", err) } - 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])) + // Field 1: SignedHeader_2 + c.SignedHeader_2 = new(SignedBeaconBlockHeader) + if err = c.SignedHeader_2.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("SignedHeader_2: %w", err) } - 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) +func (c *ProposerSlashing) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the BeaconBlockHeader object with a hasher -func (b *BeaconBlockHeader) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *ProposerSlashing) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Slot' - ssz.PutUint(hh, b.Slot) - - // Field (1) 'ProposerIndex' - ssz.PutUint(hh, b.ProposerIndex) - - // Field (2) 'ParentRoot' - if size := len(b.ParentRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentRoot", size, 32) - return + // Field 0: SignedHeader_1 + if err := c.SignedHeader_1.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SignedHeader_1: %w", err) } - hh.PutBytes(b.ParentRoot) - - // Field (3) 'StateRoot' - if size := len(b.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return + // Field 1: SignedHeader_2 + if err := c.SignedHeader_2.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SignedHeader_2: %w", err) } - hh.PutBytes(b.StateRoot) + hh.Merkleize(indx) + return nil +} - // Field (4) 'BodyRoot' - if size := len(b.BodyRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.BodyRoot", size, 32) - return +func (c *SignedAggregateAttestationAndProof) SizeSSZ() int { + size := 100 + if c.Message == nil { + c.Message = new(AggregateAttestationAndProof) } - hh.PutBytes(b.BodyRoot) - - hh.Merkleize(indx) - return + size += c.Message.SizeSSZ() + return size } -// MarshalSSZ ssz marshals the SignedBeaconBlockHeader object -func (s *SignedBeaconBlockHeader) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) +func (c *SignedAggregateAttestationAndProof) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the SignedBeaconBlockHeader object to a target array -func (s *SignedBeaconBlockHeader) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *SignedAggregateAttestationAndProof) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 100 - // Field (0) 'Message' - if s.Message == nil { - s.Message = new(BeaconBlockHeader) - } - if dst, err = s.Message.MarshalSSZTo(dst); err != nil { - return + // Field 0: Message + if c.Message == nil { + c.Message = new(AggregateAttestationAndProof) } + dst = ssz.WriteOffset(dst, offset) + offset += c.Message.SizeSSZ() - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 1: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } - dst = append(dst, s.Signature...) + dst = append(dst, c.Signature...) - return + // Field 0: Message + if dst, err = c.Message.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Message: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the SignedBeaconBlockHeader object -func (s *SignedBeaconBlockHeader) UnmarshalSSZ(buf []byte) error { +func (c *SignedAggregateAttestationAndProof) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 208 { + if size < 100 { return ssz.ErrSize } - // Field (0) 'Message' - if s.Message == nil { - s.Message = new(BeaconBlockHeader) + sszSlice1 := buf[4:100] // c.Signature + + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Message + if sszVarOffset0 != 100 { + return ssz.ErrInvalidVariableOffset } - if err = s.Message.UnmarshalSSZ(buf[0:112]); err != nil { - return err + if sszVarOffset0 > size { + return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:] // c.Message - // Field (1) 'Signature' - if cap(s.Signature) == 0 { - s.Signature = make([]byte, 0, len(buf[112:208])) + // Field 0: Message + c.Message = new(AggregateAttestationAndProof) + if err = c.Message.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Message: %w", err) } - s.Signature = append(s.Signature, buf[112:208]...) + // Field 1: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice1...) 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) +func (c *SignedAggregateAttestationAndProof) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the SignedBeaconBlockHeader object with a hasher -func (s *SignedBeaconBlockHeader) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *SignedAggregateAttestationAndProof) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Message' - if err = s.Message.HashTreeRootWith(hh); err != nil { - return + // Field 0: Message + if err := c.Message.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Message: %w", err) } - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 1: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength } - hh.PutBytes(s.Signature) - + hh.PutBytes(c.Signature) hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the IndexedAttestation object -func (i *IndexedAttestation) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(i) +func (c *SignedBeaconBlock) SizeSSZ() int { + size := 100 + if c.Block == nil { + c.Block = new(BeaconBlock) + } + size += c.Block.SizeSSZ() + return size } -// 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) +func (c *SignedBeaconBlock) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Offset (0) 'AttestingIndices' - dst = ssz.WriteOffset(dst, offset) - offset += len(i.AttestingIndices) * 8 +func (c *SignedBeaconBlock) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 100 - // Field (1) 'Data' - if i.Data == nil { - i.Data = new(AttestationData) - } - if dst, err = i.Data.MarshalSSZTo(dst); err != nil { - return + // Field 0: Block + if c.Block == nil { + c.Block = new(BeaconBlock) } + dst = ssz.WriteOffset(dst, offset) + offset += c.Block.SizeSSZ() - // Field (2) 'Signature' - if size := len(i.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 1: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } - dst = append(dst, i.Signature...) + dst = append(dst, c.Signature...) - // Field (0) 'AttestingIndices' - if size := len(i.AttestingIndices); size > 2048 { - err = ssz.ErrListTooBigFn("--.AttestingIndices", size, 2048) - return - } - for ii := 0; ii < len(i.AttestingIndices); ii++ { - dst = ssz.MarshalUint(dst, i.AttestingIndices[ii]) + // Field 0: Block + if dst, err = c.Block.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Block: %w", err) } - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the IndexedAttestation object -func (i *IndexedAttestation) UnmarshalSSZ(buf []byte) error { +func (c *SignedBeaconBlock) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 228 { + if size < 100 { return ssz.ErrSize } - tail := buf - var o0 uint64 - - // Offset (0) 'AttestingIndices' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } + sszSlice1 := buf[4:100] // c.Signature - if o0 != 228 { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Block + if sszVarOffset0 != 100 { 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 + if sszVarOffset0 > size { + return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:] // c.Block - // Field (2) 'Signature' - if cap(i.Signature) == 0 { - i.Signature = make([]byte, 0, len(buf[132:228])) + // Field 0: Block + c.Block = new(BeaconBlock) + if err = c.Block.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Block: %w", err) } - i.Signature = append(i.Signature, buf[132:228]...) - // Field (0) 'AttestingIndices' - { - buf = tail[o0:] - num, err := ssz.DivideInt2(len(buf), 8, 2048) - if err != nil { - return err - } - i.AttestingIndices = ssz.ExtendUint(i.AttestingIndices, num) - for ii := 0; ii < num; ii++ { - i.AttestingIndices[ii] = ssz.UnmarshallUint[uint64](buf[ii*8 : (ii+1)*8]) - } - } + // Field 1: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice1...) 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) +func (c *SignedBeaconBlock) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the IndexedAttestation object with a hasher -func (i *IndexedAttestation) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *SignedBeaconBlock) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'AttestingIndices' - { - if size := len(i.AttestingIndices); size > 2048 { - err = ssz.ErrListTooBigFn("--.AttestingIndices", size, 2048) - return - } - subIndx := hh.Index() - for _, i := range i.AttestingIndices { - ssz.AppendUint(hh, i) - } - hh.FillUpTo32() - - numItems := uint64(len(i.AttestingIndices)) - hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(2048, numItems, 8)) + // Field 0: Block + if err := c.Block.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Block: %w", err) } - - // Field (1) 'Data' - if err = i.Data.HashTreeRootWith(hh); err != nil { - return + // Field 1: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength } + hh.PutBytes(c.Signature) + hh.Merkleize(indx) + return nil +} - // Field (2) 'Signature' - if size := len(i.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return - } - hh.PutBytes(i.Signature) +func (c *SignedBeaconBlockHeader) SizeSSZ() int { + size := 208 - hh.Merkleize(indx) - return + return size } -// MarshalSSZ ssz marshals the SyncAggregate object -func (s *SyncAggregate) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) +func (c *SignedBeaconBlockHeader) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the SyncAggregate object to a target array -func (s *SyncAggregate) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *SignedBeaconBlockHeader) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (0) 'SyncCommitteeBits' - if size := len(s.SyncCommitteeBits); size != 4 { - err = ssz.ErrBytesLengthFn("--.SyncCommitteeBits", size, 4) - return + // Field 0: Message + if c.Message == nil { + c.Message = new(BeaconBlockHeader) + } + if dst, err = c.Message.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Message: %w", err) } - dst = append(dst, s.SyncCommitteeBits...) - // Field (1) 'SyncCommitteeSignature' - if size := len(s.SyncCommitteeSignature); size != 96 { - err = ssz.ErrBytesLengthFn("--.SyncCommitteeSignature", size, 96) - return + // Field 1: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } - dst = append(dst, s.SyncCommitteeSignature...) + dst = append(dst, c.Signature...) - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the SyncAggregate object -func (s *SyncAggregate) UnmarshalSSZ(buf []byte) error { +func (c *SignedBeaconBlockHeader) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 100 { + if size != 208 { return ssz.ErrSize } - // Field (0) 'SyncCommitteeBits' - if cap(s.SyncCommitteeBits) == 0 { - s.SyncCommitteeBits = make([]byte, 0, len(buf[0:4])) - } - s.SyncCommitteeBits = append(s.SyncCommitteeBits, buf[0:4]...) + sszSlice0 := buf[0:112] // c.Message + sszSlice1 := buf[112:208] // c.Signature - // Field (1) 'SyncCommitteeSignature' - if cap(s.SyncCommitteeSignature) == 0 { - s.SyncCommitteeSignature = make([]byte, 0, len(buf[4:100])) + // Field 0: Message + c.Message = new(BeaconBlockHeader) + if err = c.Message.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Message: %w", err) } - s.SyncCommitteeSignature = append(s.SyncCommitteeSignature, buf[4:100]...) + // Field 1: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice1...) return err } -// SizeSSZ returns the ssz encoded size in bytes for the SyncAggregate object -func (s *SyncAggregate) SizeSSZ() (size int) { - size = 100 - return -} - -// HashTreeRoot ssz hashes the SyncAggregate object -func (s *SyncAggregate) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) +func (c *SignedBeaconBlockHeader) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the SyncAggregate object with a hasher -func (s *SyncAggregate) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *SignedBeaconBlockHeader) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'SyncCommitteeBits' - if size := len(s.SyncCommitteeBits); size != 4 { - err = ssz.ErrBytesLengthFn("--.SyncCommitteeBits", size, 4) - return + // Field 0: Message + if err := c.Message.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Message: %w", err) } - hh.PutBytes(s.SyncCommitteeBits) - - // Field (1) 'SyncCommitteeSignature' - if size := len(s.SyncCommitteeSignature); size != 96 { - err = ssz.ErrBytesLengthFn("--.SyncCommitteeSignature", size, 96) - return + // Field 1: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength } - hh.PutBytes(s.SyncCommitteeSignature) - + hh.PutBytes(c.Signature) hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the Deposit_Data object -func (d *Deposit_Data) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(d) +func (c *SignedVoluntaryExit) SizeSSZ() int { + size := 112 + + return size } -// MarshalSSZTo ssz marshals the Deposit_Data object to a target array -func (d *Deposit_Data) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *SignedVoluntaryExit) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (0) 'Pubkey' - if size := len(d.Pubkey); size != 48 { - err = ssz.ErrBytesLengthFn("--.Pubkey", size, 48) - return - } - dst = append(dst, d.Pubkey...) +func (c *SignedVoluntaryExit) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (1) 'WithdrawalCredentials' - if size := len(d.WithdrawalCredentials); size != 32 { - err = ssz.ErrBytesLengthFn("--.WithdrawalCredentials", size, 32) - return + // Field 0: Message + if c.Message == nil { + c.Message = new(VoluntaryExit) + } + if dst, err = c.Message.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Message: %w", err) } - dst = append(dst, d.WithdrawalCredentials...) - - // Field (2) 'Amount' - dst = ssz.MarshalUint(dst, d.Amount) - // Field (3) 'Signature' - if size := len(d.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 1: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } - dst = append(dst, d.Signature...) + dst = append(dst, c.Signature...) - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the Deposit_Data object -func (d *Deposit_Data) UnmarshalSSZ(buf []byte) error { +func (c *SignedVoluntaryExit) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 184 { + if size != 112 { 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]...) + sszSlice0 := buf[0:16] // c.Message + sszSlice1 := buf[16:112] // c.Signature - // Field (1) 'WithdrawalCredentials' - if cap(d.WithdrawalCredentials) == 0 { - d.WithdrawalCredentials = make([]byte, 0, len(buf[48:80])) + // Field 0: Message + c.Message = new(VoluntaryExit) + if err = c.Message.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Message: %w", err) } - d.WithdrawalCredentials = append(d.WithdrawalCredentials, buf[48:80]...) - // Field (2) 'Amount' - d.Amount = ssz.UnmarshallUint[uint64](buf[80:88]) + // Field 1: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice1...) + return err +} - // Field (3) 'Signature' - if cap(d.Signature) == 0 { - d.Signature = make([]byte, 0, len(buf[88:184])) +func (c *SignedVoluntaryExit) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - d.Signature = append(d.Signature, buf[88:184]...) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - return err +func (c *SignedVoluntaryExit) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Message + if err := c.Message.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Message: %w", err) + } + // Field 1: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Signature) + hh.Merkleize(indx) + return nil } -// SizeSSZ returns the ssz encoded size in bytes for the Deposit_Data object -func (d *Deposit_Data) SizeSSZ() (size int) { - size = 184 - return +func (c *SyncAggregate) SizeSSZ() int { + size := 100 + + return size } -// HashTreeRoot ssz hashes the Deposit_Data object -func (d *Deposit_Data) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(d) +func (c *SyncAggregate) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// HashTreeRootWith ssz hashes the Deposit_Data object with a hasher -func (d *Deposit_Data) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() +func (c *SyncAggregate) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (0) 'Pubkey' - if size := len(d.Pubkey); size != 48 { - err = ssz.ErrBytesLengthFn("--.Pubkey", size, 48) - return + // Field 0: SyncCommitteeBits + if len([]byte(c.SyncCommitteeBits)) != 4 { + return nil, ssz.ErrBytesLength } - hh.PutBytes(d.Pubkey) + dst = append(dst, []byte(c.SyncCommitteeBits)...) + + // Field 1: SyncCommitteeSignature + if len(c.SyncCommitteeSignature) != 96 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.SyncCommitteeSignature...) + + return dst, err +} - // Field (1) 'WithdrawalCredentials' - if size := len(d.WithdrawalCredentials); size != 32 { - err = ssz.ErrBytesLengthFn("--.WithdrawalCredentials", size, 32) - return +func (c *SyncAggregate) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 100 { + return ssz.ErrSize } - hh.PutBytes(d.WithdrawalCredentials) - // Field (2) 'Amount' - ssz.PutUint(hh, d.Amount) + sszSlice0 := buf[0:4] // c.SyncCommitteeBits + sszSlice1 := buf[4:100] // c.SyncCommitteeSignature + + // Field 0: SyncCommitteeBits + c.SyncCommitteeBits = make([]byte, 0, 4) + c.SyncCommitteeBits = append(c.SyncCommitteeBits, go_bitfield.Bitvector32(sszSlice0)...) + + // Field 1: SyncCommitteeSignature + c.SyncCommitteeSignature = make([]byte, 0, 96) + c.SyncCommitteeSignature = append(c.SyncCommitteeSignature, sszSlice1...) + return err +} - // Field (3) 'Signature' - if size := len(d.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return +func (c *SyncAggregate) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - hh.PutBytes(d.Signature) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} +func (c *SyncAggregate) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: SyncCommitteeBits + if len([]byte(c.SyncCommitteeBits)) != 4 { + return ssz.ErrBytesLength + } + hh.PutBytes([]byte(c.SyncCommitteeBits)) + // Field 1: SyncCommitteeSignature + if len(c.SyncCommitteeSignature) != 96 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.SyncCommitteeSignature) hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the Validator object -func (v *Validator) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(v) +func (c *Validator) SizeSSZ() int { + size := 121 + + return size +} + +func (c *Validator) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the Validator object to a target array -func (v *Validator) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *Validator) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (0) 'Pubkey' - if size := len(v.Pubkey); size != 48 { - err = ssz.ErrBytesLengthFn("--.Pubkey", size, 48) - return + // Field 0: Pubkey + if len(c.Pubkey) != 48 { + return nil, ssz.ErrBytesLength } - dst = append(dst, v.Pubkey...) + dst = append(dst, c.Pubkey...) - // Field (1) 'WithdrawalCredentials' - if size := len(v.WithdrawalCredentials); size != 32 { - err = ssz.ErrBytesLengthFn("--.WithdrawalCredentials", size, 32) - return + // Field 1: WithdrawalCredentials + if len(c.WithdrawalCredentials) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, v.WithdrawalCredentials...) + dst = append(dst, c.WithdrawalCredentials...) - // Field (2) 'EffectiveBalance' - dst = ssz.MarshalUint(dst, v.EffectiveBalance) + // Field 2: EffectiveBalance + dst = binary.LittleEndian.AppendUint64(dst, c.EffectiveBalance) - // Field (3) 'Slashed' - dst = ssz.MarshalBool(dst, v.Slashed) + // Field 3: Slashed + if c.Slashed { + dst = append(dst, 1) + } else { + dst = append(dst, 0) + } - // Field (4) 'ActivationEligibilityEpoch' - dst = ssz.MarshalUint(dst, v.ActivationEligibilityEpoch) + // Field 4: ActivationEligibilityEpoch + if dst, err = c.ActivationEligibilityEpoch.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ActivationEligibilityEpoch: %w", err) + } - // Field (5) 'ActivationEpoch' - dst = ssz.MarshalUint(dst, v.ActivationEpoch) + // Field 5: ActivationEpoch + if dst, err = c.ActivationEpoch.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ActivationEpoch: %w", err) + } - // Field (6) 'ExitEpoch' - dst = ssz.MarshalUint(dst, v.ExitEpoch) + // Field 6: ExitEpoch + if dst, err = c.ExitEpoch.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ExitEpoch: %w", err) + } - // Field (7) 'WithdrawableEpoch' - dst = ssz.MarshalUint(dst, v.WithdrawableEpoch) + // Field 7: WithdrawableEpoch + if dst, err = c.WithdrawableEpoch.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("WithdrawableEpoch: %w", err) + } - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the Validator object -func (v *Validator) UnmarshalSSZ(buf []byte) error { +func (c *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]...) + sszSlice0 := buf[0:48] // c.Pubkey + sszSlice1 := buf[48:80] // c.WithdrawalCredentials + sszSlice2 := buf[80:88] // c.EffectiveBalance + sszSlice3 := buf[88:89] // c.Slashed + sszSlice4 := buf[89:97] // c.ActivationEligibilityEpoch + sszSlice5 := buf[97:105] // c.ActivationEpoch + sszSlice6 := buf[105:113] // c.ExitEpoch + sszSlice7 := buf[113:121] // c.WithdrawableEpoch - // 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 0: Pubkey + c.Pubkey = make([]byte, 0, 48) + c.Pubkey = append(c.Pubkey, sszSlice0...) - // Field (2) 'EffectiveBalance' - v.EffectiveBalance = ssz.UnmarshallUint[uint64](buf[80:88]) + // Field 1: WithdrawalCredentials + c.WithdrawalCredentials = make([]byte, 0, 32) + c.WithdrawalCredentials = append(c.WithdrawalCredentials, sszSlice1...) - // Field (3) 'Slashed' - v.Slashed, err = ssz.DecodeBool(buf[88:89]) - if err != nil { - return err - } + // Field 2: EffectiveBalance + c.EffectiveBalance = binary.LittleEndian.Uint64(sszSlice2) - // Field (4) 'ActivationEligibilityEpoch' - v.ActivationEligibilityEpoch = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Epoch](buf[89:97]) + // Field 3: Slashed + if sszSlice3[0] > 1 { + return ssz.ErrInvalidSerialization + } + if sszSlice3[0] == 1 { + c.Slashed = true + } else { + c.Slashed = false + } - // Field (5) 'ActivationEpoch' - v.ActivationEpoch = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Epoch](buf[97:105]) + // Field 4: ActivationEligibilityEpoch + if err = c.ActivationEligibilityEpoch.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("ActivationEligibilityEpoch: %w", err) + } - // Field (6) 'ExitEpoch' - v.ExitEpoch = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Epoch](buf[105:113]) + // Field 5: ActivationEpoch + if err = c.ActivationEpoch.UnmarshalSSZ(sszSlice5); err != nil { + return fmt.Errorf("ActivationEpoch: %w", err) + } - // Field (7) 'WithdrawableEpoch' - v.WithdrawableEpoch = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Epoch](buf[113:121]) + // Field 6: ExitEpoch + if err = c.ExitEpoch.UnmarshalSSZ(sszSlice6); err != nil { + return fmt.Errorf("ExitEpoch: %w", err) + } + // Field 7: WithdrawableEpoch + if err = c.WithdrawableEpoch.UnmarshalSSZ(sszSlice7); err != nil { + return fmt.Errorf("WithdrawableEpoch: %w", err) + } return err } -// SizeSSZ returns the ssz encoded size in bytes for the Validator object -func (v *Validator) SizeSSZ() (size int) { - size = 121 - return +func (c *Validator) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} + +func (c *Validator) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Pubkey + if len(c.Pubkey) != 48 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Pubkey) + // Field 1: WithdrawalCredentials + if len(c.WithdrawalCredentials) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.WithdrawalCredentials) + // Field 2: EffectiveBalance + hh.PutUint64(c.EffectiveBalance) + // Field 3: Slashed + hh.PutBool(c.Slashed) + // Field 4: ActivationEligibilityEpoch + if err := c.ActivationEligibilityEpoch.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ActivationEligibilityEpoch: %w", err) + } + // Field 5: ActivationEpoch + if err := c.ActivationEpoch.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ActivationEpoch: %w", err) + } + // Field 6: ExitEpoch + if err := c.ExitEpoch.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ExitEpoch: %w", err) + } + // Field 7: WithdrawableEpoch + if err := c.WithdrawableEpoch.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("WithdrawableEpoch: %w", err) + } + hh.Merkleize(indx) + return nil +} + +func (c *VoluntaryExit) SizeSSZ() int { + size := 16 + + return size } -// HashTreeRoot ssz hashes the Validator object -func (v *Validator) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(v) +func (c *VoluntaryExit) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// HashTreeRootWith ssz hashes the Validator object with a hasher -func (v *Validator) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() +func (c *VoluntaryExit) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (0) 'Pubkey' - if size := len(v.Pubkey); size != 48 { - err = ssz.ErrBytesLengthFn("--.Pubkey", size, 48) - return + // Field 0: Epoch + if dst, err = c.Epoch.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Epoch: %w", err) } - hh.PutBytes(v.Pubkey) - // Field (1) 'WithdrawalCredentials' - if size := len(v.WithdrawalCredentials); size != 32 { - err = ssz.ErrBytesLengthFn("--.WithdrawalCredentials", size, 32) - return + // Field 1: ValidatorIndex + if dst, err = c.ValidatorIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ValidatorIndex: %w", err) } - hh.PutBytes(v.WithdrawalCredentials) - // Field (2) 'EffectiveBalance' - ssz.PutUint(hh, v.EffectiveBalance) + return dst, err +} - // Field (3) 'Slashed' - hh.PutBool(v.Slashed) +func (c *VoluntaryExit) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 16 { + return ssz.ErrSize + } - // Field (4) 'ActivationEligibilityEpoch' - ssz.PutUint(hh, v.ActivationEligibilityEpoch) + sszSlice0 := buf[0:8] // c.Epoch + sszSlice1 := buf[8:16] // c.ValidatorIndex - // Field (5) 'ActivationEpoch' - ssz.PutUint(hh, v.ActivationEpoch) + // Field 0: Epoch + if err = c.Epoch.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Epoch: %w", err) + } - // Field (6) 'ExitEpoch' - ssz.PutUint(hh, v.ExitEpoch) + // Field 1: ValidatorIndex + if err = c.ValidatorIndex.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("ValidatorIndex: %w", err) + } + return err +} - // Field (7) 'WithdrawableEpoch' - ssz.PutUint(hh, v.WithdrawableEpoch) +func (c *VoluntaryExit) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} +func (c *VoluntaryExit) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Epoch + if err := c.Epoch.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Epoch: %w", err) + } + // Field 1: ValidatorIndex + if err := c.ValidatorIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ValidatorIndex: %w", err) + } hh.Merkleize(indx) - return + return nil } diff --git a/proto/eth/v1/gateway.ssz.go b/proto/eth/v1/gateway.ssz.go index 3a8fce6f6701..d37c30f6b268 100644 --- a/proto/eth/v1/gateway.ssz.go +++ b/proto/eth/v1/gateway.ssz.go @@ -1,2468 +1,2416 @@ //go:build !minimal -// Code generated by fastssz. DO NOT EDIT. package v1 import ( - github_com_OffchainLabs_prysm_v7_consensus_types_primitives "github.com/OffchainLabs/prysm/v7/consensus-types/primitives" - ssz "github.com/prysmaticlabs/fastssz" + binary "encoding/binary" + "fmt" + go_bitfield "github.com/OffchainLabs/go-bitfield" + ssz "github.com/OffchainLabs/methodical-ssz/ssz" ) -// MarshalSSZ ssz marshals the Attestation object -func (a *Attestation) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(a) +func (c *AggregateAttestationAndProof) SizeSSZ() int { + size := 108 + if c.Aggregate == nil { + c.Aggregate = new(Attestation) + } + size += c.Aggregate.SizeSSZ() + return size } -// 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) +func (c *AggregateAttestationAndProof) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Offset (0) 'AggregationBits' - dst = ssz.WriteOffset(dst, offset) - offset += len(a.AggregationBits) +func (c *AggregateAttestationAndProof) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 108 - // Field (1) 'Data' - if a.Data == nil { - a.Data = new(AttestationData) - } - if dst, err = a.Data.MarshalSSZTo(dst); err != nil { - return + // Field 0: AggregatorIndex + if dst, err = c.AggregatorIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("AggregatorIndex: %w", err) } - // Field (2) 'Signature' - if size := len(a.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 1: Aggregate + if c.Aggregate == nil { + c.Aggregate = new(Attestation) } - dst = append(dst, a.Signature...) + dst = ssz.WriteOffset(dst, offset) + offset += c.Aggregate.SizeSSZ() - // Field (0) 'AggregationBits' - if size := len(a.AggregationBits); size > 2048 { - err = ssz.ErrBytesLengthFn("--.AggregationBits", size, 2048) - return + // Field 2: SelectionProof + if len(c.SelectionProof) != 96 { + return nil, ssz.ErrBytesLength } - dst = append(dst, a.AggregationBits...) + dst = append(dst, c.SelectionProof...) - return + // Field 1: Aggregate + if dst, err = c.Aggregate.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Aggregate: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the Attestation object -func (a *Attestation) UnmarshalSSZ(buf []byte) error { +func (c *AggregateAttestationAndProof) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 228 { + if size < 108 { return ssz.ErrSize } - tail := buf - var o0 uint64 - - // Offset (0) 'AggregationBits' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } + sszSlice0 := buf[0:8] // c.AggregatorIndex + sszSlice2 := buf[12:108] // c.SelectionProof - if o0 != 228 { + sszVarOffset1 := ssz.ReadOffset(buf[8:12]) // c.Aggregate + if sszVarOffset1 != 108 { 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 + if sszVarOffset1 > size { + return ssz.ErrOffset } + sszSlice1 := buf[sszVarOffset1:] // c.Aggregate - // Field (2) 'Signature' - if cap(a.Signature) == 0 { - a.Signature = make([]byte, 0, len(buf[132:228])) + // Field 0: AggregatorIndex + if err = c.AggregatorIndex.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("AggregatorIndex: %w", err) } - a.Signature = append(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...) + // Field 1: Aggregate + c.Aggregate = new(Attestation) + if err = c.Aggregate.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Aggregate: %w", err) } - 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 + // Field 2: SelectionProof + c.SelectionProof = make([]byte, 0, 96) + c.SelectionProof = append(c.SelectionProof, sszSlice2...) + return err } -// HashTreeRoot ssz hashes the Attestation object -func (a *Attestation) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(a) +func (c *AggregateAttestationAndProof) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the Attestation object with a hasher -func (a *Attestation) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *AggregateAttestationAndProof) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'AggregationBits' - if len(a.AggregationBits) == 0 { - err = ssz.ErrEmptyBitlist - return + // Field 0: AggregatorIndex + if err := c.AggregatorIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("AggregatorIndex: %w", err) } - hh.PutBitlist(a.AggregationBits, 2048) - - // Field (1) 'Data' - if err = a.Data.HashTreeRootWith(hh); err != nil { - return + // Field 1: Aggregate + if err := c.Aggregate.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Aggregate: %w", err) } - - // Field (2) 'Signature' - if size := len(a.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 2: SelectionProof + if len(c.SelectionProof) != 96 { + return ssz.ErrBytesLength } - hh.PutBytes(a.Signature) - + hh.PutBytes(c.SelectionProof) hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the AggregateAttestationAndProof object -func (a *AggregateAttestationAndProof) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(a) +func (c *Attestation) SizeSSZ() int { + size := 228 + size += len(c.AggregationBits) + return size } -// MarshalSSZTo ssz marshals the AggregateAttestationAndProof object to a target array -func (a *AggregateAttestationAndProof) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(108) +func (c *Attestation) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (0) 'AggregatorIndex' - dst = ssz.MarshalUint(dst, a.AggregatorIndex) +func (c *Attestation) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 228 - // Offset (1) 'Aggregate' + // Field 0: AggregationBits dst = ssz.WriteOffset(dst, offset) - if a.Aggregate == nil { - a.Aggregate = new(Attestation) - } - offset += a.Aggregate.SizeSSZ() + offset += len(c.AggregationBits) - // Field (2) 'SelectionProof' - if size := len(a.SelectionProof); size != 96 { - err = ssz.ErrBytesLengthFn("--.SelectionProof", size, 96) - return + // Field 1: Data + if c.Data == nil { + c.Data = new(AttestationData) + } + if dst, err = c.Data.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Data: %w", err) } - dst = append(dst, a.SelectionProof...) - // Field (1) 'Aggregate' - if dst, err = a.Aggregate.MarshalSSZTo(dst); err != nil { - return + // Field 2: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.Signature...) - return + // Field 0: AggregationBits + if len(c.AggregationBits) > 2048 { + return nil, ssz.ErrListTooBig + } + dst = append(dst, c.AggregationBits...) + return dst, err } -// UnmarshalSSZ ssz unmarshals the AggregateAttestationAndProof object -func (a *AggregateAttestationAndProof) UnmarshalSSZ(buf []byte) error { +func (c *Attestation) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 108 { + if size < 228 { return ssz.ErrSize } - tail := buf - var o1 uint64 - - // Field (0) 'AggregatorIndex' - a.AggregatorIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[0:8]) + sszSlice1 := buf[4:132] // c.Data + sszSlice2 := buf[132:228] // c.Signature - // Offset (1) 'Aggregate' - if o1 = ssz.ReadOffset(buf[8:12]); o1 > size { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.AggregationBits + if sszVarOffset0 != 228 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset0 > size { return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:] // c.AggregationBits - if o1 != 108 { - return ssz.ErrInvalidVariableOffset + // Field 0: AggregationBits + if err = ssz.ValidateBitlist(sszSlice0, 2048); err != nil { + return fmt.Errorf("AggregationBits: %w", err) } + c.AggregationBits = append([]byte{}, go_bitfield.Bitlist(sszSlice0)...) - // Field (2) 'SelectionProof' - if cap(a.SelectionProof) == 0 { - a.SelectionProof = make([]byte, 0, len(buf[12:108])) + // Field 1: Data + c.Data = new(AttestationData) + if err = c.Data.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Data: %w", err) } - a.SelectionProof = append(a.SelectionProof, buf[12:108]...) - // Field (1) 'Aggregate' - { - buf = tail[o1:] - if a.Aggregate == nil { - a.Aggregate = new(Attestation) - } - if err = a.Aggregate.UnmarshalSSZ(buf); err != nil { - return err - } - } + // Field 2: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice2...) return err } -// SizeSSZ returns the ssz encoded size in bytes for the AggregateAttestationAndProof object -func (a *AggregateAttestationAndProof) SizeSSZ() (size int) { - size = 108 - - // Field (1) 'Aggregate' - if a.Aggregate == nil { - a.Aggregate = new(Attestation) +func (c *Attestation) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - size += a.Aggregate.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the AggregateAttestationAndProof object -func (a *AggregateAttestationAndProof) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(a) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the AggregateAttestationAndProof object with a hasher -func (a *AggregateAttestationAndProof) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *Attestation) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'AggregatorIndex' - ssz.PutUint(hh, a.AggregatorIndex) - - // Field (1) 'Aggregate' - if err = a.Aggregate.HashTreeRootWith(hh); err != nil { - return - } - - // Field (2) 'SelectionProof' - if size := len(a.SelectionProof); size != 96 { - err = ssz.ErrBytesLengthFn("--.SelectionProof", size, 96) - return - } - hh.PutBytes(a.SelectionProof) - - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the SignedAggregateAttestationAndProof object -func (s *SignedAggregateAttestationAndProof) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) -} - -// MarshalSSZTo ssz marshals the SignedAggregateAttestationAndProof object to a target array -func (s *SignedAggregateAttestationAndProof) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(100) - - // Offset (0) 'Message' - dst = ssz.WriteOffset(dst, offset) - if s.Message == nil { - s.Message = new(AggregateAttestationAndProof) - } - offset += s.Message.SizeSSZ() - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return - } - dst = append(dst, s.Signature...) - - // Field (0) 'Message' - if dst, err = s.Message.MarshalSSZTo(dst); err != nil { - return + // Field 0: AggregationBits + if len(c.AggregationBits) == 0 { + return ssz.ErrEmptyBitlist } - - return -} - -// UnmarshalSSZ ssz unmarshals the SignedAggregateAttestationAndProof object -func (s *SignedAggregateAttestationAndProof) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 100 { - return ssz.ErrSize + hh.PutBitlist(c.AggregationBits, 2048) + // Field 1: Data + if err := c.Data.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Data: %w", err) } - - tail := buf - var o0 uint64 - - // Offset (0) 'Message' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset + // Field 2: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength } - - 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) 'Message' - { - buf = tail[o0:] - if s.Message == nil { - s.Message = new(AggregateAttestationAndProof) - } - if err = s.Message.UnmarshalSSZ(buf); err != nil { - return err - } - } - return err + hh.PutBytes(c.Signature) + hh.Merkleize(indx) + return nil } -// SizeSSZ returns the ssz encoded size in bytes for the SignedAggregateAttestationAndProof object -func (s *SignedAggregateAttestationAndProof) SizeSSZ() (size int) { - size = 100 - - // Field (0) 'Message' - if s.Message == nil { - s.Message = new(AggregateAttestationAndProof) - } - size += s.Message.SizeSSZ() +func (c *AttestationData) SizeSSZ() int { + size := 128 - return + return size } -// HashTreeRoot ssz hashes the SignedAggregateAttestationAndProof object -func (s *SignedAggregateAttestationAndProof) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) +func (c *AttestationData) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// HashTreeRootWith ssz hashes the SignedAggregateAttestationAndProof object with a hasher -func (s *SignedAggregateAttestationAndProof) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() +func (c *AttestationData) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (0) 'Message' - if err = s.Message.HashTreeRootWith(hh); err != nil { - return + // Field 0: Slot + if dst, err = c.Slot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Slot: %w", err) } - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 1: Index + if dst, err = c.Index.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Index: %w", err) } - hh.PutBytes(s.Signature) - - hh.Merkleize(indx) - return -} - -// 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.MarshalUint(dst, a.Slot) - - // Field (1) 'Index' - dst = ssz.MarshalUint(dst, a.Index) - - // Field (2) 'BeaconBlockRoot' - if size := len(a.BeaconBlockRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.BeaconBlockRoot", size, 32) - return + // Field 2: BeaconBlockRoot + if len(c.BeaconBlockRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, a.BeaconBlockRoot...) + dst = append(dst, c.BeaconBlockRoot...) - // Field (3) 'Source' - if a.Source == nil { - a.Source = new(Checkpoint) + // Field 3: Source + if c.Source == nil { + c.Source = new(Checkpoint) } - if dst, err = a.Source.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.Source.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Source: %w", err) } - // Field (4) 'Target' - if a.Target == nil { - a.Target = new(Checkpoint) + // Field 4: Target + if c.Target == nil { + c.Target = new(Checkpoint) } - if dst, err = a.Target.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.Target.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Target: %w", err) } - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the AttestationData object -func (a *AttestationData) UnmarshalSSZ(buf []byte) error { +func (c *AttestationData) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size != 128 { return ssz.ErrSize } - // Field (0) 'Slot' - a.Slot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[0:8]) - - // Field (1) 'Index' - a.Index = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.CommitteeIndex](buf[8:16]) + sszSlice0 := buf[0:8] // c.Slot + sszSlice1 := buf[8:16] // c.Index + sszSlice2 := buf[16:48] // c.BeaconBlockRoot + sszSlice3 := buf[48:88] // c.Source + sszSlice4 := buf[88:128] // c.Target - // Field (2) 'BeaconBlockRoot' - if cap(a.BeaconBlockRoot) == 0 { - a.BeaconBlockRoot = make([]byte, 0, len(buf[16:48])) + // Field 0: Slot + if err = c.Slot.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Slot: %w", err) } - a.BeaconBlockRoot = append(a.BeaconBlockRoot, 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 1: Index + if err = c.Index.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Index: %w", err) } - // Field (4) 'Target' - if a.Target == nil { - a.Target = new(Checkpoint) - } - if err = a.Target.UnmarshalSSZ(buf[88:128]); err != nil { - return err + // Field 2: BeaconBlockRoot + c.BeaconBlockRoot = make([]byte, 0, 32) + c.BeaconBlockRoot = append(c.BeaconBlockRoot, sszSlice2...) + + // Field 3: Source + c.Source = new(Checkpoint) + if err = c.Source.UnmarshalSSZ(sszSlice3); err != nil { + return fmt.Errorf("Source: %w", err) } + // Field 4: Target + c.Target = new(Checkpoint) + if err = c.Target.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("Target: %w", 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) +func (c *AttestationData) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the AttestationData object with a hasher -func (a *AttestationData) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *AttestationData) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Slot' - ssz.PutUint(hh, a.Slot) - - // Field (1) 'Index' - ssz.PutUint(hh, a.Index) - - // Field (2) 'BeaconBlockRoot' - if size := len(a.BeaconBlockRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.BeaconBlockRoot", size, 32) - return + // Field 0: Slot + if err := c.Slot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Slot: %w", err) } - hh.PutBytes(a.BeaconBlockRoot) - - // Field (3) 'Source' - if err = a.Source.HashTreeRootWith(hh); err != nil { - return + // Field 1: Index + if err := c.Index.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Index: %w", err) } - - // Field (4) 'Target' - if err = a.Target.HashTreeRootWith(hh); err != nil { - return + // Field 2: BeaconBlockRoot + if len(c.BeaconBlockRoot) != 32 { + return ssz.ErrBytesLength } - - hh.Merkleize(indx) - return -} - -// 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.MarshalUint(dst, c.Epoch) - - // Field (1) 'Root' - if size := len(c.Root); size != 32 { - err = ssz.ErrBytesLengthFn("--.Root", size, 32) - return + hh.PutBytes(c.BeaconBlockRoot) + // Field 3: Source + if err := c.Source.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Source: %w", err) } - 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.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Epoch](buf[0:8]) - - // Field (1) 'Root' - if cap(c.Root) == 0 { - c.Root = make([]byte, 0, len(buf[8:40])) + // Field 4: Target + if err := c.Target.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Target: %w", err) } - 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) + hh.Merkleize(indx) + return nil } -// HashTreeRootWith ssz hashes the Checkpoint object with a hasher -func (c *Checkpoint) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'Epoch' - ssz.PutUint(hh, c.Epoch) - - // Field (1) 'Root' - if size := len(c.Root); size != 32 { - err = ssz.ErrBytesLengthFn("--.Root", size, 32) - return +func (c *AttesterSlashing) SizeSSZ() int { + size := 8 + if c.Attestation_1 == nil { + c.Attestation_1 = new(IndexedAttestation) } - hh.PutBytes(c.Root) - - hh.Merkleize(indx) - return + size += c.Attestation_1.SizeSSZ() + if c.Attestation_2 == nil { + c.Attestation_2 = new(IndexedAttestation) + } + size += c.Attestation_2.SizeSSZ() + return size } -// MarshalSSZ ssz marshals the BeaconBlock object -func (b *BeaconBlock) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) +func (c *AttesterSlashing) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// 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.MarshalUint(dst, b.Slot) - - // Field (1) 'ProposerIndex' - dst = ssz.MarshalUint(dst, b.ProposerIndex) +func (c *AttesterSlashing) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 8 - // Field (2) 'ParentRoot' - if size := len(b.ParentRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentRoot", size, 32) - return + // Field 0: Attestation_1 + if c.Attestation_1 == nil { + c.Attestation_1 = new(IndexedAttestation) } - dst = append(dst, b.ParentRoot...) + dst = ssz.WriteOffset(dst, offset) + offset += c.Attestation_1.SizeSSZ() - // Field (3) 'StateRoot' - if size := len(b.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return + // Field 1: Attestation_2 + if c.Attestation_2 == nil { + c.Attestation_2 = new(IndexedAttestation) } - dst = append(dst, b.StateRoot...) - - // Offset (4) 'Body' dst = ssz.WriteOffset(dst, offset) - if b.Body == nil { - b.Body = new(BeaconBlockBody) - } - offset += b.Body.SizeSSZ() + offset += c.Attestation_2.SizeSSZ() - // Field (4) 'Body' - if dst, err = b.Body.MarshalSSZTo(dst); err != nil { - return + // Field 0: Attestation_1 + if dst, err = c.Attestation_1.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Attestation_1: %w", err) } - return + // Field 1: Attestation_2 + if dst, err = c.Attestation_2.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Attestation_2: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the BeaconBlock object -func (b *BeaconBlock) UnmarshalSSZ(buf []byte) error { +func (c *AttesterSlashing) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 84 { + if size < 8 { return ssz.ErrSize } - tail := buf - var o4 uint64 - - // Field (0) 'Slot' - b.Slot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[0:8]) - - // Field (1) 'ProposerIndex' - b.ProposerIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[8:16]) - - // Field (2) 'ParentRoot' - if cap(b.ParentRoot) == 0 { - b.ParentRoot = make([]byte, 0, len(buf[16:48])) + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Attestation_1 + if sszVarOffset0 != 8 { + return ssz.ErrInvalidVariableOffset } - 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])) + if sszVarOffset0 > size { + return ssz.ErrOffset } - b.StateRoot = append(b.StateRoot, buf[48:80]...) - - // Offset (4) 'Body' - if o4 = ssz.ReadOffset(buf[80:84]); o4 > size { + sszVarOffset1 := ssz.ReadOffset(buf[4:8]) // c.Attestation_2 + if sszVarOffset1 > size || sszVarOffset1 < sszVarOffset0 { return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:sszVarOffset1] // c.Attestation_1 + sszSlice1 := buf[sszVarOffset1:] // c.Attestation_2 - if o4 != 84 { - return ssz.ErrInvalidVariableOffset + // Field 0: Attestation_1 + c.Attestation_1 = new(IndexedAttestation) + if err = c.Attestation_1.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Attestation_1: %w", err) } - // Field (4) 'Body' - { - buf = tail[o4:] - if b.Body == nil { - b.Body = new(BeaconBlockBody) - } - if err = b.Body.UnmarshalSSZ(buf); err != nil { - return err - } + // Field 1: Attestation_2 + c.Attestation_2 = new(IndexedAttestation) + if err = c.Attestation_2.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Attestation_2: %w", 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) +func (c *AttesterSlashing) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - size += b.Body.SizeSSZ() - - return + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// 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.Hasher) (err error) { +func (c *AttesterSlashing) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Slot' - ssz.PutUint(hh, b.Slot) - - // Field (1) 'ProposerIndex' - ssz.PutUint(hh, b.ProposerIndex) - - // Field (2) 'ParentRoot' - if size := len(b.ParentRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentRoot", size, 32) - return + // Field 0: Attestation_1 + if err := c.Attestation_1.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Attestation_1: %w", err) } - hh.PutBytes(b.ParentRoot) - - // Field (3) 'StateRoot' - if size := len(b.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return + // Field 1: Attestation_2 + if err := c.Attestation_2.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Attestation_2: %w", err) } - hh.PutBytes(b.StateRoot) + hh.Merkleize(indx) + return nil +} - // Field (4) 'Body' - if err = b.Body.HashTreeRootWith(hh); err != nil { - return +func (c *BeaconBlock) SizeSSZ() int { + size := 84 + if c.Body == nil { + c.Body = new(BeaconBlockBody) } - - hh.Merkleize(indx) - return + size += c.Body.SizeSSZ() + return size } -// MarshalSSZ ssz marshals the SignedBeaconBlock object -func (s *SignedBeaconBlock) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) +func (c *BeaconBlock) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// 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) +func (c *BeaconBlock) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 84 + + // Field 0: Slot + if dst, err = c.Slot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Slot: %w", err) + } - // Offset (0) 'Block' - dst = ssz.WriteOffset(dst, offset) - if s.Block == nil { - s.Block = new(BeaconBlock) + // Field 1: ProposerIndex + if dst, err = c.ProposerIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ProposerIndex: %w", err) } - offset += s.Block.SizeSSZ() - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 2: ParentRoot + if len(c.ParentRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, s.Signature...) + dst = append(dst, c.ParentRoot...) - // Field (0) 'Block' - if dst, err = s.Block.MarshalSSZTo(dst); err != nil { - return + // Field 3: StateRoot + if len(c.StateRoot) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.StateRoot...) + + // Field 4: Body + if c.Body == nil { + c.Body = new(BeaconBlockBody) + } + dst = ssz.WriteOffset(dst, offset) + offset += c.Body.SizeSSZ() - return + // Field 4: Body + if dst, err = c.Body.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Body: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the SignedBeaconBlock object -func (s *SignedBeaconBlock) UnmarshalSSZ(buf []byte) error { +func (c *BeaconBlock) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 100 { + if size < 84 { return ssz.ErrSize } - tail := buf - var o0 uint64 + sszSlice0 := buf[0:8] // c.Slot + sszSlice1 := buf[8:16] // c.ProposerIndex + sszSlice2 := buf[16:48] // c.ParentRoot + sszSlice3 := buf[48:80] // c.StateRoot - // Offset (0) 'Block' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { + sszVarOffset4 := ssz.ReadOffset(buf[80:84]) // c.Body + if sszVarOffset4 != 84 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset4 > size { return ssz.ErrOffset } + sszSlice4 := buf[sszVarOffset4:] // c.Body - if o0 != 100 { - return ssz.ErrInvalidVariableOffset + // Field 0: Slot + if err = c.Slot.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Slot: %w", err) } - // Field (1) 'Signature' - if cap(s.Signature) == 0 { - s.Signature = make([]byte, 0, len(buf[4:100])) + // Field 1: ProposerIndex + if err = c.ProposerIndex.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("ProposerIndex: %w", err) } - 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 -} + // Field 2: ParentRoot + c.ParentRoot = make([]byte, 0, 32) + c.ParentRoot = append(c.ParentRoot, sszSlice2...) -// SizeSSZ returns the ssz encoded size in bytes for the SignedBeaconBlock object -func (s *SignedBeaconBlock) SizeSSZ() (size int) { - size = 100 + // Field 3: StateRoot + c.StateRoot = make([]byte, 0, 32) + c.StateRoot = append(c.StateRoot, sszSlice3...) - // Field (0) 'Block' - if s.Block == nil { - s.Block = new(BeaconBlock) + // Field 4: Body + c.Body = new(BeaconBlockBody) + if err = c.Body.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("Body: %w", err) } - size += s.Block.SizeSSZ() - - return + return err } -// HashTreeRoot ssz hashes the SignedBeaconBlock object -func (s *SignedBeaconBlock) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) +func (c *BeaconBlock) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the SignedBeaconBlock object with a hasher -func (s *SignedBeaconBlock) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *BeaconBlock) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Block' - if err = s.Block.HashTreeRootWith(hh); err != nil { - return + // Field 0: Slot + if err := c.Slot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Slot: %w", err) } - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 1: ProposerIndex + if err := c.ProposerIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ProposerIndex: %w", err) + } + // Field 2: ParentRoot + if len(c.ParentRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ParentRoot) + // Field 3: StateRoot + if len(c.StateRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.StateRoot) + // Field 4: Body + if err := c.Body.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Body: %w", err) } - hh.PutBytes(s.Signature) - hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the BeaconBlockBody object -func (b *BeaconBlockBody) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) +func (c *BeaconBlockBody) SizeSSZ() int { + size := 220 + size += len(c.ProposerSlashings) * 416 + for _, o := range c.AttesterSlashings { + size += 4 + size += o.SizeSSZ() + } + for _, o := range c.Attestations { + size += 4 + size += o.SizeSSZ() + } + size += len(c.Deposits) * 1240 + size += len(c.VoluntaryExits) * 112 + return size } -// MarshalSSZTo ssz marshals the BeaconBlockBody object to a target array -func (b *BeaconBlockBody) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(220) +func (c *BeaconBlockBody) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (0) 'RandaoReveal' - if size := len(b.RandaoReveal); size != 96 { - err = ssz.ErrBytesLengthFn("--.RandaoReveal", size, 96) - return +func (c *BeaconBlockBody) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 220 + + // Field 0: RandaoReveal + if len(c.RandaoReveal) != 96 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.RandaoReveal...) + dst = append(dst, c.RandaoReveal...) - // Field (1) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(Eth1Data) + // Field 1: Eth1Data + if c.Eth1Data == nil { + c.Eth1Data = new(Eth1Data) } - if dst, err = b.Eth1Data.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.Eth1Data.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Eth1Data: %w", err) } - // Field (2) 'Graffiti' - if size := len(b.Graffiti); size != 32 { - err = ssz.ErrBytesLengthFn("--.Graffiti", size, 32) - return + // Field 2: Graffiti + if len(c.Graffiti) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.Graffiti...) + dst = append(dst, c.Graffiti...) - // Offset (3) 'ProposerSlashings' + // Field 3: ProposerSlashings dst = ssz.WriteOffset(dst, offset) - offset += len(b.ProposerSlashings) * 416 + offset += len(c.ProposerSlashings) * 416 - // Offset (4) 'AttesterSlashings' + // Field 4: AttesterSlashings dst = ssz.WriteOffset(dst, offset) - for ii := 0; ii < len(b.AttesterSlashings); ii++ { + for _, o := range c.AttesterSlashings { offset += 4 - offset += b.AttesterSlashings[ii].SizeSSZ() + offset += o.SizeSSZ() } - // Offset (5) 'Attestations' + // Field 5: Attestations dst = ssz.WriteOffset(dst, offset) - for ii := 0; ii < len(b.Attestations); ii++ { + for _, o := range c.Attestations { offset += 4 - offset += b.Attestations[ii].SizeSSZ() + offset += o.SizeSSZ() } - // Offset (6) 'Deposits' + // Field 6: Deposits dst = ssz.WriteOffset(dst, offset) - offset += len(b.Deposits) * 1240 + offset += len(c.Deposits) * 1240 - // Offset (7) 'VoluntaryExits' + // Field 7: VoluntaryExits dst = ssz.WriteOffset(dst, offset) - offset += len(b.VoluntaryExits) * 112 + offset += len(c.VoluntaryExits) * 112 - // Field (3) 'ProposerSlashings' - if size := len(b.ProposerSlashings); size > 16 { - err = ssz.ErrListTooBigFn("--.ProposerSlashings", size, 16) - return + // Field 3: ProposerSlashings + if len(c.ProposerSlashings) > 16 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.ProposerSlashings); ii++ { - if dst, err = b.ProposerSlashings[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.ProposerSlashings { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ProposerSlashings: %w", err) } } - // Field (4) 'AttesterSlashings' - if size := len(b.AttesterSlashings); size > 2 { - err = ssz.ErrListTooBigFn("--.AttesterSlashings", size, 2) - return + // Field 4: AttesterSlashings + if len(c.AttesterSlashings) > 2 { + return nil, ssz.ErrListTooBig } { - offset = 4 * len(b.AttesterSlashings) - for ii := 0; ii < len(b.AttesterSlashings); ii++ { + offset = 4 * len(c.AttesterSlashings) + for _, o := range c.AttesterSlashings { dst = ssz.WriteOffset(dst, offset) - offset += b.AttesterSlashings[ii].SizeSSZ() + offset += o.SizeSSZ() } } - for ii := 0; ii < len(b.AttesterSlashings); ii++ { - if dst, err = b.AttesterSlashings[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.AttesterSlashings { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("AttesterSlashings: %w", err) } } - // Field (5) 'Attestations' - if size := len(b.Attestations); size > 128 { - err = ssz.ErrListTooBigFn("--.Attestations", size, 128) - return + // Field 5: Attestations + if len(c.Attestations) > 128 { + return nil, ssz.ErrListTooBig } { - offset = 4 * len(b.Attestations) - for ii := 0; ii < len(b.Attestations); ii++ { + offset = 4 * len(c.Attestations) + for _, o := range c.Attestations { dst = ssz.WriteOffset(dst, offset) - offset += b.Attestations[ii].SizeSSZ() + offset += o.SizeSSZ() } } - for ii := 0; ii < len(b.Attestations); ii++ { - if dst, err = b.Attestations[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.Attestations { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Attestations: %w", err) } } - // Field (6) 'Deposits' - if size := len(b.Deposits); size > 16 { - err = ssz.ErrListTooBigFn("--.Deposits", size, 16) - return + // Field 6: Deposits + if len(c.Deposits) > 16 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.Deposits); ii++ { - if dst, err = b.Deposits[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.Deposits { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Deposits: %w", err) } } - // Field (7) 'VoluntaryExits' - if size := len(b.VoluntaryExits); size > 16 { - err = ssz.ErrListTooBigFn("--.VoluntaryExits", size, 16) - return + // Field 7: VoluntaryExits + if len(c.VoluntaryExits) > 16 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.VoluntaryExits); ii++ { - if dst, err = b.VoluntaryExits[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.VoluntaryExits { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("VoluntaryExits: %w", err) } } - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the BeaconBlockBody object -func (b *BeaconBlockBody) UnmarshalSSZ(buf []byte) error { +func (c *BeaconBlockBody) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size < 220 { return ssz.ErrSize } - tail := buf - var o3, o4, o5, o6, o7 uint64 + sszSlice0 := buf[0:96] // c.RandaoReveal + sszSlice1 := buf[96:168] // c.Eth1Data + sszSlice2 := buf[168:200] // c.Graffiti - // 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(Eth1Data) - } - if err = b.Eth1Data.UnmarshalSSZ(buf[96:168]); err != nil { - return err - } - - // Field (2) 'Graffiti' - if cap(b.Graffiti) == 0 { - b.Graffiti = make([]byte, 0, len(buf[168:200])) + sszVarOffset3 := ssz.ReadOffset(buf[200:204]) // c.ProposerSlashings + if sszVarOffset3 != 220 { + return ssz.ErrInvalidVariableOffset } - b.Graffiti = append(b.Graffiti, buf[168:200]...) - - // Offset (3) 'ProposerSlashings' - if o3 = ssz.ReadOffset(buf[200:204]); o3 > size { + if sszVarOffset3 > size { return ssz.ErrOffset } - - if o3 != 220 { - return ssz.ErrInvalidVariableOffset + sszVarOffset4 := ssz.ReadOffset(buf[204:208]) // c.AttesterSlashings + if sszVarOffset4 > size || sszVarOffset4 < sszVarOffset3 { + return ssz.ErrOffset } - - // Offset (4) 'AttesterSlashings' - if o4 = ssz.ReadOffset(buf[204:208]); o4 > size || o3 > o4 { + sszVarOffset5 := ssz.ReadOffset(buf[208:212]) // c.Attestations + if sszVarOffset5 > size || sszVarOffset5 < sszVarOffset4 { return ssz.ErrOffset } - - // Offset (5) 'Attestations' - if o5 = ssz.ReadOffset(buf[208:212]); o5 > size || o4 > o5 { + sszVarOffset6 := ssz.ReadOffset(buf[212:216]) // c.Deposits + if sszVarOffset6 > size || sszVarOffset6 < sszVarOffset5 { return ssz.ErrOffset } - - // Offset (6) 'Deposits' - if o6 = ssz.ReadOffset(buf[212:216]); o6 > size || o5 > o6 { + sszVarOffset7 := ssz.ReadOffset(buf[216:220]) // c.VoluntaryExits + if sszVarOffset7 > size || sszVarOffset7 < sszVarOffset6 { return ssz.ErrOffset } + sszSlice3 := buf[sszVarOffset3:sszVarOffset4] // c.ProposerSlashings + sszSlice4 := buf[sszVarOffset4:sszVarOffset5] // c.AttesterSlashings + sszSlice5 := buf[sszVarOffset5:sszVarOffset6] // c.Attestations + sszSlice6 := buf[sszVarOffset6:sszVarOffset7] // c.Deposits + sszSlice7 := buf[sszVarOffset7:] // c.VoluntaryExits - // Offset (7) 'VoluntaryExits' - if o7 = ssz.ReadOffset(buf[216:220]); o7 > size || o6 > o7 { - return ssz.ErrOffset + // Field 0: RandaoReveal + c.RandaoReveal = make([]byte, 0, 96) + c.RandaoReveal = append(c.RandaoReveal, sszSlice0...) + + // Field 1: Eth1Data + c.Eth1Data = new(Eth1Data) + if err = c.Eth1Data.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Eth1Data: %w", err) } - // Field (3) 'ProposerSlashings' + // Field 2: Graffiti + c.Graffiti = make([]byte, 0, 32) + c.Graffiti = append(c.Graffiti, sszSlice2...) + + // Field 3: ProposerSlashings { - buf = tail[o3:o4] - num, err := ssz.DivideInt2(len(buf), 416, 16) - if err != nil { - return err + if len(sszSlice3)%416 != 0 { + return fmt.Errorf("misaligned bytes: c.ProposerSlashings length is %d, which is not a multiple of 416: %w", len(sszSlice3), ssz.ErrIncorrectListSize) } - b.ProposerSlashings = make([]*ProposerSlashing, num) - for ii := 0; ii < num; ii++ { - if b.ProposerSlashings[ii] == nil { - b.ProposerSlashings[ii] = new(ProposerSlashing) - } - if err = b.ProposerSlashings[ii].UnmarshalSSZ(buf[ii*416 : (ii+1)*416]); err != nil { - return err + numElem := len(sszSlice3) / 416 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.ProposerSlashings has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.ProposerSlashings = make([]*ProposerSlashing, numElem) + for i := 0; i < numElem; i++ { + var tmp *ProposerSlashing + tmp = new(ProposerSlashing) + tmpSlice := sszSlice3[i*416 : (1+i)*416] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("ProposerSlashings: %w", err) } + c.ProposerSlashings[i] = tmp } } - // Field (4) 'AttesterSlashings' + // Field 4: AttesterSlashings { - buf = tail[o4:o5] - num, err := ssz.DecodeDynamicLength(buf, 2) - 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) + // empty lists are zero length, so make sure there is room for an offset + // before attempting to unmarshal it + if len(sszSlice4) > 3 { + startOffset := ssz.ReadOffset(sszSlice4[0:4]) + if startOffset == 0 { + return fmt.Errorf("encountered invalid offset of 0 when decoding c.AttesterSlashings") + } + if startOffset%4 != 0 { + return fmt.Errorf("misaligned list bytes: when decoding c.AttesterSlashings, end-of-list offset is %d, which is not a multiple of 4 (offset size)", startOffset) + } + listLen := startOffset / 4 + if listLen > 2 { + return fmt.Errorf("ssz-max exceeded: c.AttesterSlashings has %d elements, ssz-max is 2: %w", listLen, ssz.ErrListTooBig) } - if err = b.AttesterSlashings[indx].UnmarshalSSZ(buf); err != nil { - return err + totalVarBytes := uint64(len(sszSlice4)) + if totalVarBytes < startOffset { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.AttesterSlashings") } - return nil - }) - if err != nil { - return err + c.AttesterSlashings = make([]*AttesterSlashing, listLen) + var tmpSlice []byte + for i := uint64(0); i < listLen; i++ { + var tmp *AttesterSlashing + tmp = new(AttesterSlashing) + endOffset := totalVarBytes + if i+1 != listLen { + endOffset = ssz.ReadOffset(sszSlice4[(i+1)*4 : (i+2)*4]) + if totalVarBytes < endOffset { + return fmt.Errorf("offset %d points past the end of buffer when decoding c.AttesterSlashings", endOffset) + } + } + if endOffset < startOffset { + return fmt.Errorf("offset %d is not greater than start offset %d when decoding c.AttesterSlashings", endOffset, startOffset) + } + tmpSlice = sszSlice4[startOffset:endOffset] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("AttesterSlashings: %w", err) + } + c.AttesterSlashings[i] = tmp + startOffset = endOffset + } + } else { + if len(sszSlice4) > 0 { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.AttesterSlashings") + } + c.AttesterSlashings = make([]*AttesterSlashing, 0) } } - // Field (5) 'Attestations' + // Field 5: Attestations { - buf = tail[o5:o6] - num, err := ssz.DecodeDynamicLength(buf, 128) - 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) + // empty lists are zero length, so make sure there is room for an offset + // before attempting to unmarshal it + if len(sszSlice5) > 3 { + startOffset := ssz.ReadOffset(sszSlice5[0:4]) + if startOffset == 0 { + return fmt.Errorf("encountered invalid offset of 0 when decoding c.Attestations") } - if err = b.Attestations[indx].UnmarshalSSZ(buf); err != nil { - return err + if startOffset%4 != 0 { + return fmt.Errorf("misaligned list bytes: when decoding c.Attestations, end-of-list offset is %d, which is not a multiple of 4 (offset size)", startOffset) } - return nil - }) - if err != nil { - return err + listLen := startOffset / 4 + if listLen > 128 { + return fmt.Errorf("ssz-max exceeded: c.Attestations has %d elements, ssz-max is 128: %w", listLen, ssz.ErrListTooBig) + } + totalVarBytes := uint64(len(sszSlice5)) + if totalVarBytes < startOffset { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.Attestations") + } + c.Attestations = make([]*Attestation, listLen) + var tmpSlice []byte + for i := uint64(0); i < listLen; i++ { + var tmp *Attestation + tmp = new(Attestation) + endOffset := totalVarBytes + if i+1 != listLen { + endOffset = ssz.ReadOffset(sszSlice5[(i+1)*4 : (i+2)*4]) + if totalVarBytes < endOffset { + return fmt.Errorf("offset %d points past the end of buffer when decoding c.Attestations", endOffset) + } + } + if endOffset < startOffset { + return fmt.Errorf("offset %d is not greater than start offset %d when decoding c.Attestations", endOffset, startOffset) + } + tmpSlice = sszSlice5[startOffset:endOffset] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Attestations: %w", err) + } + c.Attestations[i] = tmp + startOffset = endOffset + } + } else { + if len(sszSlice5) > 0 { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.Attestations") + } + c.Attestations = make([]*Attestation, 0) } } - // Field (6) 'Deposits' + // Field 6: Deposits { - buf = tail[o6:o7] - num, err := ssz.DivideInt2(len(buf), 1240, 16) - if err != nil { - return err + if len(sszSlice6)%1240 != 0 { + return fmt.Errorf("misaligned bytes: c.Deposits length is %d, which is not a multiple of 1240: %w", len(sszSlice6), ssz.ErrIncorrectListSize) } - b.Deposits = make([]*Deposit, num) - for ii := 0; ii < num; ii++ { - if b.Deposits[ii] == nil { - b.Deposits[ii] = new(Deposit) - } - if err = b.Deposits[ii].UnmarshalSSZ(buf[ii*1240 : (ii+1)*1240]); err != nil { - return err + numElem := len(sszSlice6) / 1240 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.Deposits has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.Deposits = make([]*Deposit, numElem) + for i := 0; i < numElem; i++ { + var tmp *Deposit + tmp = new(Deposit) + tmpSlice := sszSlice6[i*1240 : (1+i)*1240] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Deposits: %w", err) } + c.Deposits[i] = tmp } } - // Field (7) 'VoluntaryExits' + // Field 7: VoluntaryExits { - buf = tail[o7:] - num, err := ssz.DivideInt2(len(buf), 112, 16) - if err != nil { - return err + if len(sszSlice7)%112 != 0 { + return fmt.Errorf("misaligned bytes: c.VoluntaryExits length is %d, which is not a multiple of 112: %w", len(sszSlice7), ssz.ErrIncorrectListSize) } - b.VoluntaryExits = make([]*SignedVoluntaryExit, num) - for ii := 0; ii < num; ii++ { - if b.VoluntaryExits[ii] == nil { - b.VoluntaryExits[ii] = new(SignedVoluntaryExit) - } - if err = b.VoluntaryExits[ii].UnmarshalSSZ(buf[ii*112 : (ii+1)*112]); err != nil { - return err + numElem := len(sszSlice7) / 112 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.VoluntaryExits has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.VoluntaryExits = make([]*SignedVoluntaryExit, numElem) + for i := 0; i < numElem; i++ { + var tmp *SignedVoluntaryExit + tmp = new(SignedVoluntaryExit) + tmpSlice := sszSlice7[i*112 : (1+i)*112] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("VoluntaryExits: %w", err) } + c.VoluntaryExits[i] = tmp } } return err } -// SizeSSZ returns the ssz encoded size in bytes for the BeaconBlockBody object -func (b *BeaconBlockBody) SizeSSZ() (size int) { - size = 220 - - // 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() +func (c *BeaconBlockBody) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - - // 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 - - return -} - -// HashTreeRoot ssz hashes the BeaconBlockBody object -func (b *BeaconBlockBody) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the BeaconBlockBody object with a hasher -func (b *BeaconBlockBody) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *BeaconBlockBody) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'RandaoReveal' - if size := len(b.RandaoReveal); size != 96 { - err = ssz.ErrBytesLengthFn("--.RandaoReveal", size, 96) - return + // Field 0: RandaoReveal + if len(c.RandaoReveal) != 96 { + return ssz.ErrBytesLength } - hh.PutBytes(b.RandaoReveal) - - // Field (1) 'Eth1Data' - if err = b.Eth1Data.HashTreeRootWith(hh); err != nil { - return + hh.PutBytes(c.RandaoReveal) + // Field 1: Eth1Data + if err := c.Eth1Data.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Eth1Data: %w", err) } - - // Field (2) 'Graffiti' - if size := len(b.Graffiti); size != 32 { - err = ssz.ErrBytesLengthFn("--.Graffiti", size, 32) - return + // Field 2: Graffiti + if len(c.Graffiti) != 32 { + return ssz.ErrBytesLength } - hh.PutBytes(b.Graffiti) - - // Field (3) 'ProposerSlashings' + hh.PutBytes(c.Graffiti) + // Field 3: ProposerSlashings { - subIndx := hh.Index() - num := uint64(len(b.ProposerSlashings)) - if num > 16 { - err = ssz.ErrIncorrectListSize - return + if len(c.ProposerSlashings) > 16 { + return ssz.ErrListTooBig } - for _, elem := range b.ProposerSlashings { - if err = elem.HashTreeRootWith(hh); err != nil { - return + subIndx := hh.Index() + for _, o := range c.ProposerSlashings { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ProposerSlashings: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.ProposerSlashings)), 16) } - - // Field (4) 'AttesterSlashings' + // Field 4: AttesterSlashings { - subIndx := hh.Index() - num := uint64(len(b.AttesterSlashings)) - if num > 2 { - err = ssz.ErrIncorrectListSize - return + if len(c.AttesterSlashings) > 2 { + return ssz.ErrListTooBig } - for _, elem := range b.AttesterSlashings { - if err = elem.HashTreeRootWith(hh); err != nil { - return + subIndx := hh.Index() + for _, o := range c.AttesterSlashings { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("AttesterSlashings: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 2) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.AttesterSlashings)), 2) } - - // Field (5) 'Attestations' + // Field 5: Attestations { - subIndx := hh.Index() - num := uint64(len(b.Attestations)) - if num > 128 { - err = ssz.ErrIncorrectListSize - return + if len(c.Attestations) > 128 { + return ssz.ErrListTooBig } - for _, elem := range b.Attestations { - if err = elem.HashTreeRootWith(hh); err != nil { - return + subIndx := hh.Index() + for _, o := range c.Attestations { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Attestations: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 128) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Attestations)), 128) } - - // Field (6) 'Deposits' + // Field 6: Deposits { - subIndx := hh.Index() - num := uint64(len(b.Deposits)) - if num > 16 { - err = ssz.ErrIncorrectListSize - return + if len(c.Deposits) > 16 { + return ssz.ErrListTooBig } - for _, elem := range b.Deposits { - if err = elem.HashTreeRootWith(hh); err != nil { - return + subIndx := hh.Index() + for _, o := range c.Deposits { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Deposits: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Deposits)), 16) } - - // Field (7) 'VoluntaryExits' + // Field 7: VoluntaryExits { - subIndx := hh.Index() - num := uint64(len(b.VoluntaryExits)) - if num > 16 { - err = ssz.ErrIncorrectListSize - return + if len(c.VoluntaryExits) > 16 { + return ssz.ErrListTooBig } - for _, elem := range b.VoluntaryExits { - if err = elem.HashTreeRootWith(hh); err != nil { - return + subIndx := hh.Index() + for _, o := range c.VoluntaryExits { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("VoluntaryExits: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.VoluntaryExits)), 16) } - hh.Merkleize(indx) - return + return nil +} + +func (c *BeaconBlockHeader) SizeSSZ() int { + size := 112 + + return size } -// MarshalSSZ ssz marshals the ProposerSlashing object -func (p *ProposerSlashing) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(p) +func (c *BeaconBlockHeader) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the ProposerSlashing object to a target array -func (p *ProposerSlashing) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *BeaconBlockHeader) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (0) 'SignedHeader_1' - if p.SignedHeader_1 == nil { - p.SignedHeader_1 = new(SignedBeaconBlockHeader) + // Field 0: Slot + if dst, err = c.Slot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Slot: %w", err) } - if dst, err = p.SignedHeader_1.MarshalSSZTo(dst); err != nil { - return + + // Field 1: ProposerIndex + if dst, err = c.ProposerIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ProposerIndex: %w", err) } - // Field (1) 'SignedHeader_2' - if p.SignedHeader_2 == nil { - p.SignedHeader_2 = new(SignedBeaconBlockHeader) + // Field 2: ParentRoot + if len(c.ParentRoot) != 32 { + return nil, ssz.ErrBytesLength } - if dst, err = p.SignedHeader_2.MarshalSSZTo(dst); err != nil { - return + dst = append(dst, c.ParentRoot...) + + // Field 3: StateRoot + if len(c.StateRoot) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.StateRoot...) + + // Field 4: BodyRoot + if len(c.BodyRoot) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.BodyRoot...) - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the ProposerSlashing object -func (p *ProposerSlashing) UnmarshalSSZ(buf []byte) error { +func (c *BeaconBlockHeader) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 416 { + if size != 112 { return ssz.ErrSize } - // Field (0) 'SignedHeader_1' - if p.SignedHeader_1 == nil { - p.SignedHeader_1 = new(SignedBeaconBlockHeader) - } - if err = p.SignedHeader_1.UnmarshalSSZ(buf[0:208]); err != nil { - return err - } + sszSlice0 := buf[0:8] // c.Slot + sszSlice1 := buf[8:16] // c.ProposerIndex + sszSlice2 := buf[16:48] // c.ParentRoot + sszSlice3 := buf[48:80] // c.StateRoot + sszSlice4 := buf[80:112] // c.BodyRoot - // Field (1) 'SignedHeader_2' - if p.SignedHeader_2 == nil { - p.SignedHeader_2 = new(SignedBeaconBlockHeader) + // Field 0: Slot + if err = c.Slot.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Slot: %w", err) } - if err = p.SignedHeader_2.UnmarshalSSZ(buf[208:416]); err != nil { - return err + + // Field 1: ProposerIndex + if err = c.ProposerIndex.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("ProposerIndex: %w", err) } - return err -} + // Field 2: ParentRoot + c.ParentRoot = make([]byte, 0, 32) + c.ParentRoot = append(c.ParentRoot, sszSlice2...) -// SizeSSZ returns the ssz encoded size in bytes for the ProposerSlashing object -func (p *ProposerSlashing) SizeSSZ() (size int) { - size = 416 - return + // Field 3: StateRoot + c.StateRoot = make([]byte, 0, 32) + c.StateRoot = append(c.StateRoot, sszSlice3...) + + // Field 4: BodyRoot + c.BodyRoot = make([]byte, 0, 32) + c.BodyRoot = append(c.BodyRoot, sszSlice4...) + return err } -// HashTreeRoot ssz hashes the ProposerSlashing object -func (p *ProposerSlashing) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(p) +func (c *BeaconBlockHeader) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the ProposerSlashing object with a hasher -func (p *ProposerSlashing) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *BeaconBlockHeader) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'SignedHeader_1' - if err = p.SignedHeader_1.HashTreeRootWith(hh); err != nil { - return + // Field 0: Slot + if err := c.Slot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Slot: %w", err) } - - // Field (1) 'SignedHeader_2' - if err = p.SignedHeader_2.HashTreeRootWith(hh); err != nil { - return + // Field 1: ProposerIndex + if err := c.ProposerIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ProposerIndex: %w", err) } - + // Field 2: ParentRoot + if len(c.ParentRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ParentRoot) + // Field 3: StateRoot + if len(c.StateRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.StateRoot) + // Field 4: BodyRoot + if len(c.BodyRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.BodyRoot) hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the AttesterSlashing object -func (a *AttesterSlashing) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(a) -} +func (c *Checkpoint) SizeSSZ() int { + size := 40 -// 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) + return size +} - // Offset (0) 'Attestation_1' - dst = ssz.WriteOffset(dst, offset) - if a.Attestation_1 == nil { - a.Attestation_1 = new(IndexedAttestation) - } - offset += a.Attestation_1.SizeSSZ() +func (c *Checkpoint) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Offset (1) 'Attestation_2' - dst = ssz.WriteOffset(dst, offset) - if a.Attestation_2 == nil { - a.Attestation_2 = new(IndexedAttestation) - } - offset += a.Attestation_2.SizeSSZ() +func (c *Checkpoint) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (0) 'Attestation_1' - if dst, err = a.Attestation_1.MarshalSSZTo(dst); err != nil { - return + // Field 0: Epoch + if dst, err = c.Epoch.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Epoch: %w", err) } - // Field (1) 'Attestation_2' - if dst, err = a.Attestation_2.MarshalSSZTo(dst); err != nil { - return + // Field 1: Root + if len(c.Root) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.Root...) - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the AttesterSlashing object -func (a *AttesterSlashing) UnmarshalSSZ(buf []byte) error { +func (c *Checkpoint) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 8 { + if size != 40 { return ssz.ErrSize } - tail := buf - var o0, o1 uint64 - - // Offset (0) 'Attestation_1' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } - - if o0 != 8 { - return ssz.ErrInvalidVariableOffset - } + sszSlice0 := buf[0:8] // c.Epoch + sszSlice1 := buf[8:40] // c.Root - // Offset (1) 'Attestation_2' - if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 { - return ssz.ErrOffset + // Field 0: Epoch + if err = c.Epoch.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Epoch: %w", err) } - // Field (0) 'Attestation_1' - { - buf = tail[o0:o1] - if a.Attestation_1 == nil { - a.Attestation_1 = new(IndexedAttestation) - } - if err = a.Attestation_1.UnmarshalSSZ(buf); err != nil { - return err - } - } - - // Field (1) 'Attestation_2' - { - buf = tail[o1:] - if a.Attestation_2 == nil { - a.Attestation_2 = new(IndexedAttestation) - } - if err = a.Attestation_2.UnmarshalSSZ(buf); err != nil { - return err - } - } + // Field 1: Root + c.Root = make([]byte, 0, 32) + c.Root = append(c.Root, sszSlice1...) return err } -// SizeSSZ returns the ssz encoded size in bytes for the AttesterSlashing object -func (a *AttesterSlashing) SizeSSZ() (size int) { - size = 8 - - // Field (0) 'Attestation_1' - if a.Attestation_1 == nil { - a.Attestation_1 = new(IndexedAttestation) - } - size += a.Attestation_1.SizeSSZ() - - // Field (1) 'Attestation_2' - if a.Attestation_2 == nil { - a.Attestation_2 = new(IndexedAttestation) +func (c *Checkpoint) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - size += a.Attestation_2.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the AttesterSlashing object -func (a *AttesterSlashing) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(a) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the AttesterSlashing object with a hasher -func (a *AttesterSlashing) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *Checkpoint) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Attestation_1' - if err = a.Attestation_1.HashTreeRootWith(hh); err != nil { - return + // Field 0: Epoch + if err := c.Epoch.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Epoch: %w", err) } - - // Field (1) 'Attestation_2' - if err = a.Attestation_2.HashTreeRootWith(hh); err != nil { - return + // Field 1: Root + if len(c.Root) != 32 { + return ssz.ErrBytesLength } - + hh.PutBytes(c.Root) hh.Merkleize(indx) - return + return nil +} + +func (c *Deposit) SizeSSZ() int { + size := 1240 + + return size } -// MarshalSSZ ssz marshals the Deposit object -func (d *Deposit) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(d) +func (c *Deposit) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the Deposit object to a target array -func (d *Deposit) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *Deposit) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (0) 'Proof' - if size := len(d.Proof); size != 33 { - err = ssz.ErrVectorLengthFn("--.Proof", size, 33) - return + // Field 0: Proof + if len(c.Proof) != 33 { + return nil, ssz.ErrBytesLength } - for ii := 0; ii < 33; ii++ { - if size := len(d.Proof[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.Proof[ii]", size, 32) - return + for _, o := range c.Proof { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, d.Proof[ii]...) + dst = append(dst, o...) } - // Field (1) 'Data' - if d.Data == nil { - d.Data = new(Deposit_Data) + // Field 1: Data + if c.Data == nil { + c.Data = new(Deposit_Data) } - if dst, err = d.Data.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.Data.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Data: %w", err) } - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the Deposit object -func (d *Deposit) UnmarshalSSZ(buf []byte) error { +func (c *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])) + sszSlice0 := buf[0:1056] // c.Proof + sszSlice1 := buf[1056:1240] // c.Data + + // Field 0: Proof + { + c.Proof = make([][]byte, 33) + for i := 0; i < 33; i++ { + var tmp []byte + + tmpSlice := sszSlice0[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.Proof[i] = tmp } - 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(Deposit_Data) - } - if err = d.Data.UnmarshalSSZ(buf[1056:1240]); err != nil { - return err + // Field 1: Data + c.Data = new(Deposit_Data) + if err = c.Data.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Data: %w", 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) +func (c *Deposit) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the Deposit object with a hasher -func (d *Deposit) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *Deposit) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Proof' + // Field 0: Proof { - if size := len(d.Proof); size != 33 { - err = ssz.ErrVectorLengthFn("--.Proof", size, 33) - return + if len(c.Proof) != 33 { + return ssz.ErrVectorLength } subIndx := hh.Index() - for _, i := range d.Proof { - if len(i) != 32 { - err = ssz.ErrBytesLength - return + for _, o := range c.Proof { + if len(o) != 32 { + return ssz.ErrBytesLength } - hh.Append(i) + hh.Append(o) } hh.Merkleize(subIndx) } - - // Field (1) 'Data' - if err = d.Data.HashTreeRootWith(hh); err != nil { - return + // Field 1: Data + if err := c.Data.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Data: %w", err) } - hh.Merkleize(indx) - return + return nil +} + +func (c *Deposit_Data) SizeSSZ() int { + size := 184 + + return size } -// MarshalSSZ ssz marshals the VoluntaryExit object -func (v *VoluntaryExit) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(v) +func (c *Deposit_Data) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the VoluntaryExit object to a target array -func (v *VoluntaryExit) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *Deposit_Data) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + + // Field 0: Pubkey + if len(c.Pubkey) != 48 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.Pubkey...) + + // Field 1: WithdrawalCredentials + if len(c.WithdrawalCredentials) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.WithdrawalCredentials...) - // Field (0) 'Epoch' - dst = ssz.MarshalUint(dst, v.Epoch) + // Field 2: Amount + dst = binary.LittleEndian.AppendUint64(dst, c.Amount) - // Field (1) 'ValidatorIndex' - dst = ssz.MarshalUint(dst, v.ValidatorIndex) + // Field 3: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.Signature...) - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the VoluntaryExit object -func (v *VoluntaryExit) UnmarshalSSZ(buf []byte) error { +func (c *Deposit_Data) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 16 { + if size != 184 { return ssz.ErrSize } - // Field (0) 'Epoch' - v.Epoch = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Epoch](buf[0:8]) + sszSlice0 := buf[0:48] // c.Pubkey + sszSlice1 := buf[48:80] // c.WithdrawalCredentials + sszSlice2 := buf[80:88] // c.Amount + sszSlice3 := buf[88:184] // c.Signature - // Field (1) 'ValidatorIndex' - v.ValidatorIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[8:16]) + // Field 0: Pubkey + c.Pubkey = make([]byte, 0, 48) + c.Pubkey = append(c.Pubkey, sszSlice0...) - return err -} + // Field 1: WithdrawalCredentials + c.WithdrawalCredentials = make([]byte, 0, 32) + c.WithdrawalCredentials = append(c.WithdrawalCredentials, sszSlice1...) -// SizeSSZ returns the ssz encoded size in bytes for the VoluntaryExit object -func (v *VoluntaryExit) SizeSSZ() (size int) { - size = 16 - return + // Field 2: Amount + c.Amount = binary.LittleEndian.Uint64(sszSlice2) + + // Field 3: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice3...) + return err } -// HashTreeRoot ssz hashes the VoluntaryExit object -func (v *VoluntaryExit) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(v) +func (c *Deposit_Data) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the VoluntaryExit object with a hasher -func (v *VoluntaryExit) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *Deposit_Data) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() + // Field 0: Pubkey + if len(c.Pubkey) != 48 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Pubkey) + // Field 1: WithdrawalCredentials + if len(c.WithdrawalCredentials) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.WithdrawalCredentials) + // Field 2: Amount + hh.PutUint64(c.Amount) + // Field 3: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Signature) + hh.Merkleize(indx) + return nil +} - // Field (0) 'Epoch' - ssz.PutUint(hh, v.Epoch) - - // Field (1) 'ValidatorIndex' - ssz.PutUint(hh, v.ValidatorIndex) +func (c *Eth1Data) SizeSSZ() int { + size := 72 - hh.Merkleize(indx) - return + return size } -// MarshalSSZ ssz marshals the SignedVoluntaryExit object -func (s *SignedVoluntaryExit) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) +func (c *Eth1Data) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the SignedVoluntaryExit object to a target array -func (s *SignedVoluntaryExit) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *Eth1Data) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (0) 'Message' - if s.Message == nil { - s.Message = new(VoluntaryExit) - } - if dst, err = s.Message.MarshalSSZTo(dst); err != nil { - return + // Field 0: DepositRoot + if len(c.DepositRoot) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.DepositRoot...) + + // Field 1: DepositCount + dst = binary.LittleEndian.AppendUint64(dst, c.DepositCount) - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 2: BlockHash + if len(c.BlockHash) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, s.Signature...) + dst = append(dst, c.BlockHash...) - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the SignedVoluntaryExit object -func (s *SignedVoluntaryExit) UnmarshalSSZ(buf []byte) error { +func (c *Eth1Data) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 112 { + if size != 72 { return ssz.ErrSize } - // Field (0) 'Message' - if s.Message == nil { - s.Message = new(VoluntaryExit) - } - if err = s.Message.UnmarshalSSZ(buf[0:16]); err != nil { - return err - } + sszSlice0 := buf[0:32] // c.DepositRoot + sszSlice1 := buf[32:40] // c.DepositCount + sszSlice2 := buf[40:72] // c.BlockHash - // Field (1) 'Signature' - if cap(s.Signature) == 0 { - s.Signature = make([]byte, 0, len(buf[16:112])) - } - s.Signature = append(s.Signature, buf[16:112]...) + // Field 0: DepositRoot + c.DepositRoot = make([]byte, 0, 32) + c.DepositRoot = append(c.DepositRoot, sszSlice0...) - return err -} + // Field 1: DepositCount + c.DepositCount = binary.LittleEndian.Uint64(sszSlice1) -// SizeSSZ returns the ssz encoded size in bytes for the SignedVoluntaryExit object -func (s *SignedVoluntaryExit) SizeSSZ() (size int) { - size = 112 - return + // Field 2: BlockHash + c.BlockHash = make([]byte, 0, 32) + c.BlockHash = append(c.BlockHash, sszSlice2...) + return err } -// HashTreeRoot ssz hashes the SignedVoluntaryExit object -func (s *SignedVoluntaryExit) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) +func (c *Eth1Data) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the SignedVoluntaryExit object with a hasher -func (s *SignedVoluntaryExit) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *Eth1Data) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Message' - if err = s.Message.HashTreeRootWith(hh); err != nil { - return - } - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return - } - hh.PutBytes(s.Signature) - + // Field 0: DepositRoot + if len(c.DepositRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.DepositRoot) + // Field 1: DepositCount + hh.PutUint64(c.DepositCount) + // Field 2: BlockHash + if len(c.BlockHash) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.BlockHash) hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the Eth1Data object -func (e *Eth1Data) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(e) +func (c *IndexedAttestation) SizeSSZ() int { + size := 228 + size += len(c.AttestingIndices) * 8 + return size } -// MarshalSSZTo ssz marshals the Eth1Data object to a target array -func (e *Eth1Data) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *IndexedAttestation) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (0) 'DepositRoot' - if size := len(e.DepositRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.DepositRoot", size, 32) - return - } - dst = append(dst, e.DepositRoot...) +func (c *IndexedAttestation) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 228 + + // Field 0: AttestingIndices + dst = ssz.WriteOffset(dst, offset) + offset += len(c.AttestingIndices) * 8 - // Field (1) 'DepositCount' - dst = ssz.MarshalUint(dst, e.DepositCount) + // Field 1: Data + if c.Data == nil { + c.Data = new(AttestationData) + } + if dst, err = c.Data.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Data: %w", err) + } - // Field (2) 'BlockHash' - if size := len(e.BlockHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockHash", size, 32) - return + // Field 2: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } - dst = append(dst, e.BlockHash...) + dst = append(dst, c.Signature...) - return + // Field 0: AttestingIndices + if len(c.AttestingIndices) > 2048 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.AttestingIndices { + dst = binary.LittleEndian.AppendUint64(dst, o) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the Eth1Data object -func (e *Eth1Data) UnmarshalSSZ(buf []byte) error { +func (c *IndexedAttestation) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 72 { + if size < 228 { return ssz.ErrSize } - // Field (0) 'DepositRoot' - if cap(e.DepositRoot) == 0 { - e.DepositRoot = make([]byte, 0, len(buf[0:32])) + sszSlice1 := buf[4:132] // c.Data + sszSlice2 := buf[132:228] // c.Signature + + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.AttestingIndices + if sszVarOffset0 != 228 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset0 > size { + return ssz.ErrOffset } - e.DepositRoot = append(e.DepositRoot, buf[0:32]...) + sszSlice0 := buf[sszVarOffset0:] // c.AttestingIndices + + // Field 0: AttestingIndices + { + if len(sszSlice0)%8 != 0 { + return fmt.Errorf("misaligned bytes: c.AttestingIndices length is %d, which is not a multiple of 8: %w", len(sszSlice0), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice0) / 8 + if numElem > 2048 { + return fmt.Errorf("ssz-max exceeded: c.AttestingIndices has %d elements, ssz-max is 2048: %w", numElem, ssz.ErrListTooBig) + } + c.AttestingIndices = make([]uint64, numElem) + for i := 0; i < numElem; i++ { + var tmp uint64 - // Field (1) 'DepositCount' - e.DepositCount = ssz.UnmarshallUint[uint64](buf[32:40]) + tmpSlice := sszSlice0[i*8 : (1+i)*8] + tmp = binary.LittleEndian.Uint64(tmpSlice) + c.AttestingIndices[i] = tmp + } + } - // Field (2) 'BlockHash' - if cap(e.BlockHash) == 0 { - e.BlockHash = make([]byte, 0, len(buf[40:72])) + // Field 1: Data + c.Data = new(AttestationData) + if err = c.Data.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Data: %w", err) } - e.BlockHash = append(e.BlockHash, buf[40:72]...) + // Field 2: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice2...) 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) +func (c *IndexedAttestation) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the Eth1Data object with a hasher -func (e *Eth1Data) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *IndexedAttestation) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'DepositRoot' - if size := len(e.DepositRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.DepositRoot", size, 32) - return + // Field 0: AttestingIndices + { + if len(c.AttestingIndices) > 2048 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.AttestingIndices { + hh.AppendUint64(o) + } + hh.FillUpTo32() + numItems := uint64(len(c.AttestingIndices)) + hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(2048, numItems, 8)) } - hh.PutBytes(e.DepositRoot) - - // Field (1) 'DepositCount' - ssz.PutUint(hh, e.DepositCount) - - // Field (2) 'BlockHash' - if size := len(e.BlockHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockHash", size, 32) - return + // Field 1: Data + if err := c.Data.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Data: %w", err) } - hh.PutBytes(e.BlockHash) - + // Field 2: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Signature) hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the BeaconBlockHeader object -func (b *BeaconBlockHeader) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} +func (c *ProposerSlashing) SizeSSZ() int { + size := 416 -// MarshalSSZTo ssz marshals the BeaconBlockHeader object to a target array -func (b *BeaconBlockHeader) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf + return size +} - // Field (0) 'Slot' - dst = ssz.MarshalUint(dst, b.Slot) +func (c *ProposerSlashing) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (1) 'ProposerIndex' - dst = ssz.MarshalUint(dst, b.ProposerIndex) +func (c *ProposerSlashing) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (2) 'ParentRoot' - if size := len(b.ParentRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentRoot", size, 32) - return + // Field 0: SignedHeader_1 + if c.SignedHeader_1 == nil { + c.SignedHeader_1 = new(SignedBeaconBlockHeader) } - dst = append(dst, b.ParentRoot...) - - // Field (3) 'StateRoot' - if size := len(b.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return + if dst, err = c.SignedHeader_1.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SignedHeader_1: %w", err) } - dst = append(dst, b.StateRoot...) - // Field (4) 'BodyRoot' - if size := len(b.BodyRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.BodyRoot", size, 32) - return + // Field 1: SignedHeader_2 + if c.SignedHeader_2 == nil { + c.SignedHeader_2 = new(SignedBeaconBlockHeader) + } + if dst, err = c.SignedHeader_2.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SignedHeader_2: %w", err) } - dst = append(dst, b.BodyRoot...) - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the BeaconBlockHeader object -func (b *BeaconBlockHeader) UnmarshalSSZ(buf []byte) error { +func (c *ProposerSlashing) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 112 { + if size != 416 { return ssz.ErrSize } - // Field (0) 'Slot' - b.Slot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[0:8]) - - // Field (1) 'ProposerIndex' - b.ProposerIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](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]...) + sszSlice0 := buf[0:208] // c.SignedHeader_1 + sszSlice1 := buf[208:416] // c.SignedHeader_2 - // Field (3) 'StateRoot' - if cap(b.StateRoot) == 0 { - b.StateRoot = make([]byte, 0, len(buf[48:80])) + // Field 0: SignedHeader_1 + c.SignedHeader_1 = new(SignedBeaconBlockHeader) + if err = c.SignedHeader_1.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("SignedHeader_1: %w", err) } - 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])) + // Field 1: SignedHeader_2 + c.SignedHeader_2 = new(SignedBeaconBlockHeader) + if err = c.SignedHeader_2.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("SignedHeader_2: %w", err) } - 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) +func (c *ProposerSlashing) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the BeaconBlockHeader object with a hasher -func (b *BeaconBlockHeader) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *ProposerSlashing) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Slot' - ssz.PutUint(hh, b.Slot) - - // Field (1) 'ProposerIndex' - ssz.PutUint(hh, b.ProposerIndex) - - // Field (2) 'ParentRoot' - if size := len(b.ParentRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentRoot", size, 32) - return + // Field 0: SignedHeader_1 + if err := c.SignedHeader_1.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SignedHeader_1: %w", err) } - hh.PutBytes(b.ParentRoot) - - // Field (3) 'StateRoot' - if size := len(b.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return + // Field 1: SignedHeader_2 + if err := c.SignedHeader_2.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SignedHeader_2: %w", err) } - hh.PutBytes(b.StateRoot) + hh.Merkleize(indx) + return nil +} - // Field (4) 'BodyRoot' - if size := len(b.BodyRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.BodyRoot", size, 32) - return +func (c *SignedAggregateAttestationAndProof) SizeSSZ() int { + size := 100 + if c.Message == nil { + c.Message = new(AggregateAttestationAndProof) } - hh.PutBytes(b.BodyRoot) - - hh.Merkleize(indx) - return + size += c.Message.SizeSSZ() + return size } -// MarshalSSZ ssz marshals the SignedBeaconBlockHeader object -func (s *SignedBeaconBlockHeader) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) +func (c *SignedAggregateAttestationAndProof) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the SignedBeaconBlockHeader object to a target array -func (s *SignedBeaconBlockHeader) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *SignedAggregateAttestationAndProof) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 100 - // Field (0) 'Message' - if s.Message == nil { - s.Message = new(BeaconBlockHeader) - } - if dst, err = s.Message.MarshalSSZTo(dst); err != nil { - return + // Field 0: Message + if c.Message == nil { + c.Message = new(AggregateAttestationAndProof) } + dst = ssz.WriteOffset(dst, offset) + offset += c.Message.SizeSSZ() - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 1: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } - dst = append(dst, s.Signature...) + dst = append(dst, c.Signature...) - return + // Field 0: Message + if dst, err = c.Message.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Message: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the SignedBeaconBlockHeader object -func (s *SignedBeaconBlockHeader) UnmarshalSSZ(buf []byte) error { +func (c *SignedAggregateAttestationAndProof) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 208 { + if size < 100 { return ssz.ErrSize } - // Field (0) 'Message' - if s.Message == nil { - s.Message = new(BeaconBlockHeader) + sszSlice1 := buf[4:100] // c.Signature + + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Message + if sszVarOffset0 != 100 { + return ssz.ErrInvalidVariableOffset } - if err = s.Message.UnmarshalSSZ(buf[0:112]); err != nil { - return err + if sszVarOffset0 > size { + return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:] // c.Message - // Field (1) 'Signature' - if cap(s.Signature) == 0 { - s.Signature = make([]byte, 0, len(buf[112:208])) + // Field 0: Message + c.Message = new(AggregateAttestationAndProof) + if err = c.Message.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Message: %w", err) } - s.Signature = append(s.Signature, buf[112:208]...) + // Field 1: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice1...) 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) +func (c *SignedAggregateAttestationAndProof) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the SignedBeaconBlockHeader object with a hasher -func (s *SignedBeaconBlockHeader) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *SignedAggregateAttestationAndProof) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Message' - if err = s.Message.HashTreeRootWith(hh); err != nil { - return + // Field 0: Message + if err := c.Message.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Message: %w", err) } - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 1: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength } - hh.PutBytes(s.Signature) - + hh.PutBytes(c.Signature) hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the IndexedAttestation object -func (i *IndexedAttestation) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(i) +func (c *SignedBeaconBlock) SizeSSZ() int { + size := 100 + if c.Block == nil { + c.Block = new(BeaconBlock) + } + size += c.Block.SizeSSZ() + return size } -// 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) +func (c *SignedBeaconBlock) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Offset (0) 'AttestingIndices' - dst = ssz.WriteOffset(dst, offset) - offset += len(i.AttestingIndices) * 8 +func (c *SignedBeaconBlock) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 100 - // Field (1) 'Data' - if i.Data == nil { - i.Data = new(AttestationData) - } - if dst, err = i.Data.MarshalSSZTo(dst); err != nil { - return + // Field 0: Block + if c.Block == nil { + c.Block = new(BeaconBlock) } + dst = ssz.WriteOffset(dst, offset) + offset += c.Block.SizeSSZ() - // Field (2) 'Signature' - if size := len(i.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 1: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } - dst = append(dst, i.Signature...) + dst = append(dst, c.Signature...) - // Field (0) 'AttestingIndices' - if size := len(i.AttestingIndices); size > 2048 { - err = ssz.ErrListTooBigFn("--.AttestingIndices", size, 2048) - return - } - for ii := 0; ii < len(i.AttestingIndices); ii++ { - dst = ssz.MarshalUint(dst, i.AttestingIndices[ii]) + // Field 0: Block + if dst, err = c.Block.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Block: %w", err) } - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the IndexedAttestation object -func (i *IndexedAttestation) UnmarshalSSZ(buf []byte) error { +func (c *SignedBeaconBlock) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 228 { + if size < 100 { return ssz.ErrSize } - tail := buf - var o0 uint64 - - // Offset (0) 'AttestingIndices' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } + sszSlice1 := buf[4:100] // c.Signature - if o0 != 228 { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Block + if sszVarOffset0 != 100 { 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 + if sszVarOffset0 > size { + return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:] // c.Block - // Field (2) 'Signature' - if cap(i.Signature) == 0 { - i.Signature = make([]byte, 0, len(buf[132:228])) + // Field 0: Block + c.Block = new(BeaconBlock) + if err = c.Block.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Block: %w", err) } - i.Signature = append(i.Signature, buf[132:228]...) - // Field (0) 'AttestingIndices' - { - buf = tail[o0:] - num, err := ssz.DivideInt2(len(buf), 8, 2048) - if err != nil { - return err - } - i.AttestingIndices = ssz.ExtendUint(i.AttestingIndices, num) - for ii := 0; ii < num; ii++ { - i.AttestingIndices[ii] = ssz.UnmarshallUint[uint64](buf[ii*8 : (ii+1)*8]) - } - } + // Field 1: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice1...) 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) +func (c *SignedBeaconBlock) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the IndexedAttestation object with a hasher -func (i *IndexedAttestation) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *SignedBeaconBlock) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'AttestingIndices' - { - if size := len(i.AttestingIndices); size > 2048 { - err = ssz.ErrListTooBigFn("--.AttestingIndices", size, 2048) - return - } - subIndx := hh.Index() - for _, i := range i.AttestingIndices { - ssz.AppendUint(hh, i) - } - hh.FillUpTo32() - - numItems := uint64(len(i.AttestingIndices)) - hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(2048, numItems, 8)) + // Field 0: Block + if err := c.Block.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Block: %w", err) } - - // Field (1) 'Data' - if err = i.Data.HashTreeRootWith(hh); err != nil { - return + // Field 1: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength } + hh.PutBytes(c.Signature) + hh.Merkleize(indx) + return nil +} - // Field (2) 'Signature' - if size := len(i.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return - } - hh.PutBytes(i.Signature) +func (c *SignedBeaconBlockHeader) SizeSSZ() int { + size := 208 - hh.Merkleize(indx) - return + return size } -// MarshalSSZ ssz marshals the SyncAggregate object -func (s *SyncAggregate) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) +func (c *SignedBeaconBlockHeader) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the SyncAggregate object to a target array -func (s *SyncAggregate) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *SignedBeaconBlockHeader) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (0) 'SyncCommitteeBits' - if size := len(s.SyncCommitteeBits); size != 64 { - err = ssz.ErrBytesLengthFn("--.SyncCommitteeBits", size, 64) - return + // Field 0: Message + if c.Message == nil { + c.Message = new(BeaconBlockHeader) + } + if dst, err = c.Message.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Message: %w", err) } - dst = append(dst, s.SyncCommitteeBits...) - // Field (1) 'SyncCommitteeSignature' - if size := len(s.SyncCommitteeSignature); size != 96 { - err = ssz.ErrBytesLengthFn("--.SyncCommitteeSignature", size, 96) - return + // Field 1: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } - dst = append(dst, s.SyncCommitteeSignature...) + dst = append(dst, c.Signature...) - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the SyncAggregate object -func (s *SyncAggregate) UnmarshalSSZ(buf []byte) error { +func (c *SignedBeaconBlockHeader) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 160 { + if size != 208 { return ssz.ErrSize } - // Field (0) 'SyncCommitteeBits' - if cap(s.SyncCommitteeBits) == 0 { - s.SyncCommitteeBits = make([]byte, 0, len(buf[0:64])) - } - s.SyncCommitteeBits = append(s.SyncCommitteeBits, buf[0:64]...) + sszSlice0 := buf[0:112] // c.Message + sszSlice1 := buf[112:208] // c.Signature - // Field (1) 'SyncCommitteeSignature' - if cap(s.SyncCommitteeSignature) == 0 { - s.SyncCommitteeSignature = make([]byte, 0, len(buf[64:160])) + // Field 0: Message + c.Message = new(BeaconBlockHeader) + if err = c.Message.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Message: %w", err) } - s.SyncCommitteeSignature = append(s.SyncCommitteeSignature, buf[64:160]...) + // Field 1: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice1...) 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) +func (c *SignedBeaconBlockHeader) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the SyncAggregate object with a hasher -func (s *SyncAggregate) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *SignedBeaconBlockHeader) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'SyncCommitteeBits' - if size := len(s.SyncCommitteeBits); size != 64 { - err = ssz.ErrBytesLengthFn("--.SyncCommitteeBits", size, 64) - return + // Field 0: Message + if err := c.Message.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Message: %w", err) } - hh.PutBytes(s.SyncCommitteeBits) - - // Field (1) 'SyncCommitteeSignature' - if size := len(s.SyncCommitteeSignature); size != 96 { - err = ssz.ErrBytesLengthFn("--.SyncCommitteeSignature", size, 96) - return + // Field 1: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength } - hh.PutBytes(s.SyncCommitteeSignature) - + hh.PutBytes(c.Signature) hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the Deposit_Data object -func (d *Deposit_Data) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(d) +func (c *SignedVoluntaryExit) SizeSSZ() int { + size := 112 + + return size } -// MarshalSSZTo ssz marshals the Deposit_Data object to a target array -func (d *Deposit_Data) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *SignedVoluntaryExit) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (0) 'Pubkey' - if size := len(d.Pubkey); size != 48 { - err = ssz.ErrBytesLengthFn("--.Pubkey", size, 48) - return - } - dst = append(dst, d.Pubkey...) +func (c *SignedVoluntaryExit) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (1) 'WithdrawalCredentials' - if size := len(d.WithdrawalCredentials); size != 32 { - err = ssz.ErrBytesLengthFn("--.WithdrawalCredentials", size, 32) - return + // Field 0: Message + if c.Message == nil { + c.Message = new(VoluntaryExit) + } + if dst, err = c.Message.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Message: %w", err) } - dst = append(dst, d.WithdrawalCredentials...) - - // Field (2) 'Amount' - dst = ssz.MarshalUint(dst, d.Amount) - // Field (3) 'Signature' - if size := len(d.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 1: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } - dst = append(dst, d.Signature...) + dst = append(dst, c.Signature...) - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the Deposit_Data object -func (d *Deposit_Data) UnmarshalSSZ(buf []byte) error { +func (c *SignedVoluntaryExit) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 184 { + if size != 112 { 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]...) + sszSlice0 := buf[0:16] // c.Message + sszSlice1 := buf[16:112] // c.Signature - // Field (1) 'WithdrawalCredentials' - if cap(d.WithdrawalCredentials) == 0 { - d.WithdrawalCredentials = make([]byte, 0, len(buf[48:80])) + // Field 0: Message + c.Message = new(VoluntaryExit) + if err = c.Message.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Message: %w", err) } - d.WithdrawalCredentials = append(d.WithdrawalCredentials, buf[48:80]...) - // Field (2) 'Amount' - d.Amount = ssz.UnmarshallUint[uint64](buf[80:88]) + // Field 1: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice1...) + return err +} - // Field (3) 'Signature' - if cap(d.Signature) == 0 { - d.Signature = make([]byte, 0, len(buf[88:184])) +func (c *SignedVoluntaryExit) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - d.Signature = append(d.Signature, buf[88:184]...) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - return err +func (c *SignedVoluntaryExit) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Message + if err := c.Message.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Message: %w", err) + } + // Field 1: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Signature) + hh.Merkleize(indx) + return nil } -// SizeSSZ returns the ssz encoded size in bytes for the Deposit_Data object -func (d *Deposit_Data) SizeSSZ() (size int) { - size = 184 - return +func (c *SyncAggregate) SizeSSZ() int { + size := 160 + + return size } -// HashTreeRoot ssz hashes the Deposit_Data object -func (d *Deposit_Data) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(d) +func (c *SyncAggregate) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// HashTreeRootWith ssz hashes the Deposit_Data object with a hasher -func (d *Deposit_Data) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() +func (c *SyncAggregate) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (0) 'Pubkey' - if size := len(d.Pubkey); size != 48 { - err = ssz.ErrBytesLengthFn("--.Pubkey", size, 48) - return + // Field 0: SyncCommitteeBits + if len([]byte(c.SyncCommitteeBits)) != 64 { + return nil, ssz.ErrBytesLength } - hh.PutBytes(d.Pubkey) + dst = append(dst, []byte(c.SyncCommitteeBits)...) + + // Field 1: SyncCommitteeSignature + if len(c.SyncCommitteeSignature) != 96 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.SyncCommitteeSignature...) + + return dst, err +} - // Field (1) 'WithdrawalCredentials' - if size := len(d.WithdrawalCredentials); size != 32 { - err = ssz.ErrBytesLengthFn("--.WithdrawalCredentials", size, 32) - return +func (c *SyncAggregate) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 160 { + return ssz.ErrSize } - hh.PutBytes(d.WithdrawalCredentials) - // Field (2) 'Amount' - ssz.PutUint(hh, d.Amount) + sszSlice0 := buf[0:64] // c.SyncCommitteeBits + sszSlice1 := buf[64:160] // c.SyncCommitteeSignature + + // Field 0: SyncCommitteeBits + c.SyncCommitteeBits = make([]byte, 0, 64) + c.SyncCommitteeBits = append(c.SyncCommitteeBits, go_bitfield.Bitvector512(sszSlice0)...) + + // Field 1: SyncCommitteeSignature + c.SyncCommitteeSignature = make([]byte, 0, 96) + c.SyncCommitteeSignature = append(c.SyncCommitteeSignature, sszSlice1...) + return err +} - // Field (3) 'Signature' - if size := len(d.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return +func (c *SyncAggregate) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - hh.PutBytes(d.Signature) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} +func (c *SyncAggregate) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: SyncCommitteeBits + if len([]byte(c.SyncCommitteeBits)) != 64 { + return ssz.ErrBytesLength + } + hh.PutBytes([]byte(c.SyncCommitteeBits)) + // Field 1: SyncCommitteeSignature + if len(c.SyncCommitteeSignature) != 96 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.SyncCommitteeSignature) hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the Validator object -func (v *Validator) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(v) +func (c *Validator) SizeSSZ() int { + size := 121 + + return size +} + +func (c *Validator) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the Validator object to a target array -func (v *Validator) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *Validator) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (0) 'Pubkey' - if size := len(v.Pubkey); size != 48 { - err = ssz.ErrBytesLengthFn("--.Pubkey", size, 48) - return + // Field 0: Pubkey + if len(c.Pubkey) != 48 { + return nil, ssz.ErrBytesLength } - dst = append(dst, v.Pubkey...) + dst = append(dst, c.Pubkey...) - // Field (1) 'WithdrawalCredentials' - if size := len(v.WithdrawalCredentials); size != 32 { - err = ssz.ErrBytesLengthFn("--.WithdrawalCredentials", size, 32) - return + // Field 1: WithdrawalCredentials + if len(c.WithdrawalCredentials) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, v.WithdrawalCredentials...) + dst = append(dst, c.WithdrawalCredentials...) - // Field (2) 'EffectiveBalance' - dst = ssz.MarshalUint(dst, v.EffectiveBalance) + // Field 2: EffectiveBalance + dst = binary.LittleEndian.AppendUint64(dst, c.EffectiveBalance) - // Field (3) 'Slashed' - dst = ssz.MarshalBool(dst, v.Slashed) + // Field 3: Slashed + if c.Slashed { + dst = append(dst, 1) + } else { + dst = append(dst, 0) + } - // Field (4) 'ActivationEligibilityEpoch' - dst = ssz.MarshalUint(dst, v.ActivationEligibilityEpoch) + // Field 4: ActivationEligibilityEpoch + if dst, err = c.ActivationEligibilityEpoch.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ActivationEligibilityEpoch: %w", err) + } - // Field (5) 'ActivationEpoch' - dst = ssz.MarshalUint(dst, v.ActivationEpoch) + // Field 5: ActivationEpoch + if dst, err = c.ActivationEpoch.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ActivationEpoch: %w", err) + } - // Field (6) 'ExitEpoch' - dst = ssz.MarshalUint(dst, v.ExitEpoch) + // Field 6: ExitEpoch + if dst, err = c.ExitEpoch.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ExitEpoch: %w", err) + } - // Field (7) 'WithdrawableEpoch' - dst = ssz.MarshalUint(dst, v.WithdrawableEpoch) + // Field 7: WithdrawableEpoch + if dst, err = c.WithdrawableEpoch.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("WithdrawableEpoch: %w", err) + } - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the Validator object -func (v *Validator) UnmarshalSSZ(buf []byte) error { +func (c *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]...) + sszSlice0 := buf[0:48] // c.Pubkey + sszSlice1 := buf[48:80] // c.WithdrawalCredentials + sszSlice2 := buf[80:88] // c.EffectiveBalance + sszSlice3 := buf[88:89] // c.Slashed + sszSlice4 := buf[89:97] // c.ActivationEligibilityEpoch + sszSlice5 := buf[97:105] // c.ActivationEpoch + sszSlice6 := buf[105:113] // c.ExitEpoch + sszSlice7 := buf[113:121] // c.WithdrawableEpoch - // 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 0: Pubkey + c.Pubkey = make([]byte, 0, 48) + c.Pubkey = append(c.Pubkey, sszSlice0...) - // Field (2) 'EffectiveBalance' - v.EffectiveBalance = ssz.UnmarshallUint[uint64](buf[80:88]) + // Field 1: WithdrawalCredentials + c.WithdrawalCredentials = make([]byte, 0, 32) + c.WithdrawalCredentials = append(c.WithdrawalCredentials, sszSlice1...) - // Field (3) 'Slashed' - v.Slashed, err = ssz.DecodeBool(buf[88:89]) - if err != nil { - return err - } + // Field 2: EffectiveBalance + c.EffectiveBalance = binary.LittleEndian.Uint64(sszSlice2) - // Field (4) 'ActivationEligibilityEpoch' - v.ActivationEligibilityEpoch = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Epoch](buf[89:97]) + // Field 3: Slashed + if sszSlice3[0] > 1 { + return ssz.ErrInvalidSerialization + } + if sszSlice3[0] == 1 { + c.Slashed = true + } else { + c.Slashed = false + } - // Field (5) 'ActivationEpoch' - v.ActivationEpoch = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Epoch](buf[97:105]) + // Field 4: ActivationEligibilityEpoch + if err = c.ActivationEligibilityEpoch.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("ActivationEligibilityEpoch: %w", err) + } - // Field (6) 'ExitEpoch' - v.ExitEpoch = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Epoch](buf[105:113]) + // Field 5: ActivationEpoch + if err = c.ActivationEpoch.UnmarshalSSZ(sszSlice5); err != nil { + return fmt.Errorf("ActivationEpoch: %w", err) + } - // Field (7) 'WithdrawableEpoch' - v.WithdrawableEpoch = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Epoch](buf[113:121]) + // Field 6: ExitEpoch + if err = c.ExitEpoch.UnmarshalSSZ(sszSlice6); err != nil { + return fmt.Errorf("ExitEpoch: %w", err) + } + // Field 7: WithdrawableEpoch + if err = c.WithdrawableEpoch.UnmarshalSSZ(sszSlice7); err != nil { + return fmt.Errorf("WithdrawableEpoch: %w", err) + } return err } -// SizeSSZ returns the ssz encoded size in bytes for the Validator object -func (v *Validator) SizeSSZ() (size int) { - size = 121 - return +func (c *Validator) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} + +func (c *Validator) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Pubkey + if len(c.Pubkey) != 48 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Pubkey) + // Field 1: WithdrawalCredentials + if len(c.WithdrawalCredentials) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.WithdrawalCredentials) + // Field 2: EffectiveBalance + hh.PutUint64(c.EffectiveBalance) + // Field 3: Slashed + hh.PutBool(c.Slashed) + // Field 4: ActivationEligibilityEpoch + if err := c.ActivationEligibilityEpoch.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ActivationEligibilityEpoch: %w", err) + } + // Field 5: ActivationEpoch + if err := c.ActivationEpoch.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ActivationEpoch: %w", err) + } + // Field 6: ExitEpoch + if err := c.ExitEpoch.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ExitEpoch: %w", err) + } + // Field 7: WithdrawableEpoch + if err := c.WithdrawableEpoch.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("WithdrawableEpoch: %w", err) + } + hh.Merkleize(indx) + return nil +} + +func (c *VoluntaryExit) SizeSSZ() int { + size := 16 + + return size } -// HashTreeRoot ssz hashes the Validator object -func (v *Validator) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(v) +func (c *VoluntaryExit) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// HashTreeRootWith ssz hashes the Validator object with a hasher -func (v *Validator) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() +func (c *VoluntaryExit) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (0) 'Pubkey' - if size := len(v.Pubkey); size != 48 { - err = ssz.ErrBytesLengthFn("--.Pubkey", size, 48) - return + // Field 0: Epoch + if dst, err = c.Epoch.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Epoch: %w", err) } - hh.PutBytes(v.Pubkey) - // Field (1) 'WithdrawalCredentials' - if size := len(v.WithdrawalCredentials); size != 32 { - err = ssz.ErrBytesLengthFn("--.WithdrawalCredentials", size, 32) - return + // Field 1: ValidatorIndex + if dst, err = c.ValidatorIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ValidatorIndex: %w", err) } - hh.PutBytes(v.WithdrawalCredentials) - // Field (2) 'EffectiveBalance' - ssz.PutUint(hh, v.EffectiveBalance) + return dst, err +} - // Field (3) 'Slashed' - hh.PutBool(v.Slashed) +func (c *VoluntaryExit) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 16 { + return ssz.ErrSize + } - // Field (4) 'ActivationEligibilityEpoch' - ssz.PutUint(hh, v.ActivationEligibilityEpoch) + sszSlice0 := buf[0:8] // c.Epoch + sszSlice1 := buf[8:16] // c.ValidatorIndex - // Field (5) 'ActivationEpoch' - ssz.PutUint(hh, v.ActivationEpoch) + // Field 0: Epoch + if err = c.Epoch.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Epoch: %w", err) + } - // Field (6) 'ExitEpoch' - ssz.PutUint(hh, v.ExitEpoch) + // Field 1: ValidatorIndex + if err = c.ValidatorIndex.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("ValidatorIndex: %w", err) + } + return err +} - // Field (7) 'WithdrawableEpoch' - ssz.PutUint(hh, v.WithdrawableEpoch) +func (c *VoluntaryExit) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} +func (c *VoluntaryExit) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Epoch + if err := c.Epoch.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Epoch: %w", err) + } + // Field 1: ValidatorIndex + if err := c.ValidatorIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ValidatorIndex: %w", err) + } hh.Merkleize(indx) - return + return nil } diff --git a/proto/eth/v1/gateway.yaml b/proto/eth/v1/gateway.yaml new file mode 100644 index 000000000000..3beb988bcb85 --- /dev/null +++ b/proto/eth/v1/gateway.yaml @@ -0,0 +1,22 @@ +package: "github.com/OffchainLabs/prysm/v7/proto/eth/v1" +types: + - name: "AggregateAttestationAndProof" + - name: "Attestation" + - name: "AttestationData" + - name: "AttesterSlashing" + - name: "BeaconBlock" + - name: "BeaconBlockBody" + - name: "BeaconBlockHeader" + - name: "Checkpoint" + - name: "Deposit" + - name: "Deposit_Data" + - name: "Eth1Data" + - name: "IndexedAttestation" + - name: "ProposerSlashing" + - name: "SignedAggregateAttestationAndProof" + - name: "SignedBeaconBlock" + - name: "SignedBeaconBlockHeader" + - name: "SignedVoluntaryExit" + - name: "SyncAggregate" + - name: "Validator" + - name: "VoluntaryExit" diff --git a/proto/prysm/v1alpha1/BUILD.bazel b/proto/prysm/v1alpha1/BUILD.bazel index 687cf0bce3b6..a817a15d1660 100644 --- a/proto/prysm/v1alpha1/BUILD.bazel +++ b/proto/prysm/v1alpha1/BUILD.bazel @@ -10,7 +10,7 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") load("@rules_proto//proto:defs.bzl", "proto_library") load("//proto:ssz_proto_library.bzl", "ssz_proto_files") -load("//tools:ssz.bzl", "SSZ_DEPS", "ssz_gen_marshal") +load("//tools:methodical.bzl", "ssz_methodical") proto_library( name = "proto", @@ -45,332 +45,76 @@ proto_library( # Go ############################################################################## -ssz_phase0_objs = [ - "AggregateAttestationAndProof", - "Attestation", - "AttestationData", - "AttesterSlashing", - "BeaconBlock", - "BeaconBlockHeader", - "BeaconState", - "Checkpoint", - "Deposit", - "Deposit_Data", - "DepositMessage", - "ENRForkID", - "Eth1Data", - "Fork", - "ForkData", - "HistoricalBatch", - "IndexedAttestation", - "PowBlock", - "ProposerSlashing", - "SignedAggregateAttestationAndProof", - "SignedBeaconBlock", - "SignedBeaconBlockHeader", - "SignedVoluntaryExit", - "SigningData", - "Status", - "Status", - "Validator", - "ValidatorBalance", - "ValidatorIdentity", - "VoluntaryExit", -] - -ssz_altair_objs = [ - "BeaconBlockAltair", - "BeaconBlockBodyAltair", - "BeaconStateAltair", - "ContributionAndProof", - "LightClientHeaderAltair", - "LightClientBootstrapAltair", - "LightClientUpdateAltair", - "LightClientFinalityUpdateAltair", - "LightClientOptimisticUpdateAltair", - "SignedBeaconBlockAltair", - "SignedContributionAndProof", - "SyncAggregate", - "SyncAggregate", - "SyncAggregatorSelectionData", - "SyncCommittee", - "SyncCommitteeContribution", - "SyncCommitteeMessage", -] - -ssz_bellatrix_objs = [ - "BeaconBlockBellatrix", - "BeaconBlockBodyBellatrix", - "BeaconStateBellatrix", - "BlindedBeaconBlockBellatrix", - "BlindedBeaconBlockBodyBellatrix", - "SignedBeaconBlockBellatrix", - "SignedBlindedBeaconBlockBellatrix", -] - -ssz_capella_objs = [ - "BLSToExecutionChange", - "BeaconBlockBodyCapella", - "BeaconBlockCapella", - "BeaconStateCapella", - "BlindedBeaconBlockBodyCapella", - "BlindedBeaconBlockCapella", - "BuilderBidCapella", - "HistoricalSummary", - "LightClientHeaderCapella", - "LightClientBootstrapCapella", - "LightClientUpdateCapella", - "LightClientFinalityUpdateCapella", - "LightClientOptimisticUpdateCapella", - "SignedBLSToExecutionChange", - "SignedBeaconBlockCapella", - "SignedBlindedBeaconBlockCapella", - "Withdrawal", - "SignedBuilderBidCapella", -] - -ssz_deneb_objs = [ - "BeaconBlockBodyDeneb", - "BeaconBlockContentsDeneb", - "BeaconBlockDeneb", - "BeaconStateDeneb", - "BlindedBeaconBlockBodyDeneb", - "BlindedBeaconBlockDeneb", - "BlobIdentifier", - "BlobSidecar", - "BlobSidecars", - "BuilderBidDeneb", - "LightClientHeaderDeneb", - "LightClientBootstrapDeneb", - "LightClientUpdateDeneb", - "LightClientFinalityUpdateDeneb", - "LightClientOptimisticUpdateDeneb", - "SignedBeaconBlockContentsDeneb", - "SignedBeaconBlockDeneb", - "SignedBlindedBeaconBlockDeneb", - "SignedBuilderBidDeneb", -] - -ssz_electra_objs = [ - "AggregateAttestationAndProofElectra", - "AggregateAttestationAndProofSingle", - "AttestationElectra", - "AttesterSlashingElectra", - "BeaconBlockElectra", - "BeaconBlockBodyElectra", - "BeaconBlockContentsElectra", - "BeaconStateElectra", - "BlindedBeaconBlockBodyElectra", - "BlindedBeaconBlockElectra", - "BuilderBidElectra", - "Consolidation", - "IndexedAttestationElectra", - "LightClientHeaderElectra", - "LightClientBootstrapElectra", - "LightClientUpdateElectra", - "LightClientFinalityUpdateElectra", - "PendingDeposit", - "PendingDeposits", - "PendingConsolidation", - "PendingPartialWithdrawal", - "SignedAggregateAttestationAndProofElectra", - "SignedAggregateAttestationAndProofSingle", - "SignedBeaconBlockContentsElectra", - "SignedBeaconBlockElectra", - "SignedBlindedBeaconBlockElectra", - "SignedConsolidation", - "SingleAttestation", - "SignedBuilderBidElectra", -] - -ssz_fulu_objs = [ - "BeaconBlockContentsFulu", - "BeaconStateFulu", - "BlindedBeaconBlockFulu", - "DataColumnIdentifier", - "DataColumnsByRootIdentifier", - "DataColumnSidecar", - "PartialDataColumnPartsMetadata", - "PartialDataColumnSidecar", - "StatusV2", - "SignedBeaconBlockContentsFulu", - "SignedBeaconBlockFulu", - "SignedBlindedBeaconBlockFulu", -] - -ssz_gloas_objs = [ - "AggregateAttestationAndProofGloas", - "AttesterSlashingGloas", - "IndexedAttestationGloas", - "BlindedExecutionPayloadEnvelope", - "BuilderPendingPayment", - "BuilderPendingWithdrawal", - "DataColumnSidecarGloas", - "ExecutionPayloadEnvelope", - "PTCs", - "ProposerPreferences", - "SignedProposerPreferences", - "SignedAggregateAttestationAndProofGloas", - "PayloadAttestation", - "PayloadAttestationData", - "PayloadAttestationMessage", - "ExecutionPayloadBid", - "SignedExecutionPayloadBid", - "SignedBlindedExecutionPayloadEnvelope", - "SignedExecutionPayloadEnvelope", - "SignedExecutionPayloadEnvelopeContents", - "BeaconBlockGloas", - "BeaconBlockContentsGloas", - "SignedBeaconBlockGloas", - "BeaconStateGloas", -] - -ssz_gloas_builder_api_objs = [ - "RequestAuthV1", - "SignedRequestAuthV1", - "BuilderPreferencesV1", - "BuilderPreferencesRequestV1", -] - -ssz_gen_marshal( - name = "ssz_generated_phase0", +ssz_methodical( + name = "methodical_phase0", + deps = [":go_proto"], + config_file = "phase0.yaml", + override_package_name = "eth", out = "phase0.ssz.go", - go_proto = ":go_proto", - includes = [ - "//consensus-types/primitives:go_default_library", - "//math:go_default_library", - "//proto/engine/v1:go_default_library", - ], - objs = ssz_phase0_objs, ) -ssz_gen_marshal( - name = "ssz_generated_altair", +ssz_methodical( + name = "methodical_altair", + deps = [":go_proto"], + config_file = "altair.yaml", + override_package_name = "eth", out = "altair.ssz.go", - exclude_objs = ssz_phase0_objs, - go_proto = ":go_proto", - includes = [ - "//consensus-types/primitives:go_default_library", - "//math:go_default_library", - "//proto/engine/v1:go_default_library", - ], - objs = ssz_altair_objs, ) -ssz_gen_marshal( - name = "ssz_generated_bellatrix", +ssz_methodical( + name = "methodical_bellatrix", + deps = [":go_proto"], + config_file = "bellatrix.yaml", + override_package_name = "eth", out = "bellatrix.ssz.go", - exclude_objs = ssz_phase0_objs + ssz_altair_objs, - go_proto = ":go_proto", - includes = [ - "//consensus-types/primitives:go_default_library", - "//math:go_default_library", - "//proto/engine/v1:go_default_library", - ], - objs = ssz_bellatrix_objs, ) -ssz_gen_marshal( - name = "ssz_generated_capella", +ssz_methodical( + name = "methodical_capella", + deps = [":go_proto"], + config_file = "capella.yaml", + override_package_name = "eth", out = "capella.ssz.go", - exclude_objs = ssz_phase0_objs + ssz_altair_objs + ssz_bellatrix_objs, - go_proto = ":go_proto", - includes = [ - "//consensus-types/primitives:go_default_library", - "//math:go_default_library", - "//proto/engine/v1:go_default_library", - ], - objs = ssz_capella_objs, ) -ssz_gen_marshal( - name = "ssz_generated_deneb", +ssz_methodical( + name = "methodical_deneb", + deps = [":go_proto"], + config_file = "deneb.yaml", + override_package_name = "eth", out = "deneb.ssz.go", - exclude_objs = ssz_phase0_objs + ssz_altair_objs + ssz_bellatrix_objs + ssz_capella_objs, - go_proto = ":go_proto", - includes = [ - "//consensus-types/primitives:go_default_library", - "//math:go_default_library", - "//proto/engine/v1:go_default_library", - ], - objs = ssz_deneb_objs, ) -ssz_gen_marshal( - name = "ssz_generated_electra", +ssz_methodical( + name = "methodical_electra", + deps = [":go_proto"], + config_file = "electra.yaml", + override_package_name = "eth", out = "electra.ssz.go", - exclude_objs = ssz_phase0_objs + ssz_altair_objs + ssz_bellatrix_objs + ssz_capella_objs + ssz_deneb_objs, - go_proto = ":go_proto", - includes = [ - "//consensus-types/primitives:go_default_library", - "//math:go_default_library", - "//proto/engine/v1:go_default_library", - ], - objs = ssz_electra_objs, ) -ssz_gen_marshal( - name = "ssz_generated_fulu", +ssz_methodical( + name = "methodical_fulu", + deps = [":go_proto"], + config_file = "fulu.yaml", + override_package_name = "eth", out = "fulu.ssz.go", - exclude_objs = ssz_phase0_objs + ssz_altair_objs + ssz_bellatrix_objs + ssz_capella_objs + ssz_deneb_objs + ssz_electra_objs, - go_proto = ":go_proto", - includes = [ - "//consensus-types/primitives:go_default_library", - "//math:go_default_library", - "//proto/engine/v1:go_default_library", - ], - objs = ssz_fulu_objs, ) -ssz_gen_marshal( - name = "ssz_generated_gloas", +ssz_methodical( + name = "methodical_gloas", + deps = [":go_proto"], + config_file = "gloas.yaml", + override_package_name = "eth", out = "gloas.ssz.go", - exclude_objs = ssz_phase0_objs + ssz_altair_objs + ssz_bellatrix_objs + ssz_capella_objs + ssz_deneb_objs + ssz_electra_objs + ssz_fulu_objs, - go_proto = ":go_proto", - includes = [ - "//consensus-types/primitives:go_default_library", - "//math:go_default_library", - "//proto/engine/v1:go_default_library", - ], - objs = ssz_gloas_objs, ) -ssz_gen_marshal( - name = "ssz_generated_gloas_builder_api", - out = "gloas_builder_api.ssz.go", - exclude_objs = ssz_phase0_objs + ssz_altair_objs + ssz_bellatrix_objs + ssz_capella_objs + ssz_deneb_objs + ssz_electra_objs + ssz_fulu_objs + ssz_gloas_objs, - go_proto = ":go_proto", - includes = [ - "//consensus-types/primitives:go_default_library", - "//math:go_default_library", - "//proto/engine/v1:go_default_library", - ], - objs = ssz_gloas_builder_api_objs, -) - -ssz_gen_marshal( - name = "ssz_generated_non_core", +ssz_methodical( + name = "methodical_non_core", + deps = [":go_proto"], + config_file = "non-core.yaml", out = "non-core.ssz.go", - go_proto = ":go_proto", - includes = [ - "//consensus-types/primitives:go_default_library", - "//math:go_default_library", - "//proto/engine/v1:go_default_library", - ], - objs = [ - "BeaconBlocksByRangeRequest", - "BlobSidecarsByRangeRequest", - "DataColumnSidecarsByRangeRequest", - "ExecutionPayloadEnvelopesByRangeRequest", - "MetaDataV0", - "MetaDataV1", - "MetaDataV2", - "SignedValidatorRegistrationV1", - "ValidatorRegistrationV1", - "BuilderBid", - "SignedBuilderBid", - "DepositSnapshot", - ], + override_package_name = "eth", ) go_proto_library( @@ -413,23 +157,21 @@ go_library( "sync_committee_minimal.go", # keep "payload_attestation_mainnet.go", "payload_attestation_minimal.go", # keep + ":methodical_altair", # keep + ":methodical_bellatrix", # keep + ":methodical_capella", # keep + ":methodical_deneb", # keep + ":methodical_electra", # keep + ":methodical_fulu", # keep + ":methodical_gloas", # keep + ":methodical_non_core", # keep + ":methodical_phase0", # keep "validator.go", - ":ssz_generated_altair", # keep - ":ssz_generated_bellatrix", # keep - ":ssz_generated_capella", # keep - ":ssz_generated_deneb", # keep - ":ssz_generated_electra", # keep - ":ssz_generated_fulu", # keep - ":ssz_generated_gloas", # keep - ":ssz_generated_gloas_builder_api", # keep - ":ssz_generated_non_core", # keep - ":ssz_generated_phase0", # keep ], embed = [":go_proto"], importpath = "github.com/OffchainLabs/prysm/v7/proto/prysm/v1alpha1", visibility = ["//visibility:public"], - deps = SSZ_DEPS + [ - "//consensus-types/primitives:go_default_library", + deps = [ "//encoding/bytesutil:go_default_library", "//math:go_default_library", "//proto/engine/v1:go_default_library", @@ -437,6 +179,8 @@ go_library( "//runtime/version:go_default_library", "@com_github_golang_protobuf//proto:go_default_library", "@com_github_pkg_errors//:go_default_library", + "@com_github_offchainlabs_methodical_ssz//ssz:go_default_library", + "@com_github_prysmaticlabs_fastssz//:go_default_library", "@com_github_prysmaticlabs_go_bitfield//:go_default_library", # keep "@com_github_sirupsen_logrus//:go_default_library", "@com_github_sirupsen_logrus//hooks/test:go_default_library", @@ -467,7 +211,7 @@ ssz_proto_files( "blobs.proto", "data_columns.proto", "gloas.proto", - "gloas_builder_api.proto", + "gloas_builder_api.proto", "light_client.proto", "partial_data_columns.proto", "sync_committee.proto", diff --git a/proto/prysm/v1alpha1/altair.minimal.ssz.go b/proto/prysm/v1alpha1/altair.minimal.ssz.go index 73d7a7c441d8..d3ceb8c1c4ef 100644 --- a/proto/prysm/v1alpha1/altair.minimal.ssz.go +++ b/proto/prysm/v1alpha1/altair.minimal.ssz.go @@ -1,2789 +1,2740 @@ //go:build minimal -// Code generated by fastssz. DO NOT EDIT. package eth import ( - github_com_OffchainLabs_prysm_v7_consensus_types_primitives "github.com/OffchainLabs/prysm/v7/consensus-types/primitives" - ssz "github.com/prysmaticlabs/fastssz" + binary "encoding/binary" + "fmt" + go_bitfield "github.com/OffchainLabs/go-bitfield" + ssz "github.com/OffchainLabs/methodical-ssz/ssz" ) -// MarshalSSZ ssz marshals the SignedBeaconBlockAltair object -func (s *SignedBeaconBlockAltair) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) -} - -// MarshalSSZTo ssz marshals the SignedBeaconBlockAltair object to a target array -func (s *SignedBeaconBlockAltair) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(100) - - // Offset (0) 'Block' - dst = ssz.WriteOffset(dst, offset) - if s.Block == nil { - s.Block = new(BeaconBlockAltair) - } - offset += s.Block.SizeSSZ() - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return +func (c *BeaconBlockAltair) SizeSSZ() int { + size := 84 + if c.Body == nil { + c.Body = new(BeaconBlockBodyAltair) } - dst = append(dst, s.Signature...) - - // Field (0) 'Block' - if dst, err = s.Block.MarshalSSZTo(dst); err != nil { - return - } - - return + size += c.Body.SizeSSZ() + return size } -// UnmarshalSSZ ssz unmarshals the SignedBeaconBlockAltair object -func (s *SignedBeaconBlockAltair) 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(BeaconBlockAltair) - } - if err = s.Block.UnmarshalSSZ(buf); err != nil { - return err - } - } - return err +func (c *BeaconBlockAltair) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// SizeSSZ returns the ssz encoded size in bytes for the SignedBeaconBlockAltair object -func (s *SignedBeaconBlockAltair) SizeSSZ() (size int) { - size = 100 +func (c *BeaconBlockAltair) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 84 - // Field (0) 'Block' - if s.Block == nil { - s.Block = new(BeaconBlockAltair) + // Field 0: Slot + if dst, err = c.Slot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Slot: %w", err) } - size += s.Block.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the SignedBeaconBlockAltair object -func (s *SignedBeaconBlockAltair) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) -} -// HashTreeRootWith ssz hashes the SignedBeaconBlockAltair object with a hasher -func (s *SignedBeaconBlockAltair) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'Block' - if err = s.Block.HashTreeRootWith(hh); err != nil { - return + // Field 1: ProposerIndex + if dst, err = c.ProposerIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ProposerIndex: %w", err) } - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 2: ParentRoot + if len(c.ParentRoot) != 32 { + return nil, ssz.ErrBytesLength } - hh.PutBytes(s.Signature) - - hh.Merkleize(indx) - return -} + dst = append(dst, c.ParentRoot...) -// MarshalSSZ ssz marshals the BeaconBlockAltair object -func (b *BeaconBlockAltair) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} - -// MarshalSSZTo ssz marshals the BeaconBlockAltair object to a target array -func (b *BeaconBlockAltair) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(84) - - // Field (0) 'Slot' - dst = ssz.MarshalUint(dst, b.Slot) - - // Field (1) 'ProposerIndex' - dst = ssz.MarshalUint(dst, b.ProposerIndex) - - // Field (2) 'ParentRoot' - if size := len(b.ParentRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentRoot", size, 32) - return + // Field 3: StateRoot + if len(c.StateRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.ParentRoot...) + dst = append(dst, c.StateRoot...) - // Field (3) 'StateRoot' - if size := len(b.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return + // Field 4: Body + if c.Body == nil { + c.Body = new(BeaconBlockBodyAltair) } - dst = append(dst, b.StateRoot...) - - // Offset (4) 'Body' dst = ssz.WriteOffset(dst, offset) - if b.Body == nil { - b.Body = new(BeaconBlockBodyAltair) - } - offset += b.Body.SizeSSZ() + offset += c.Body.SizeSSZ() - // Field (4) 'Body' - if dst, err = b.Body.MarshalSSZTo(dst); err != nil { - return + // Field 4: Body + if dst, err = c.Body.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Body: %w", err) } - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the BeaconBlockAltair object -func (b *BeaconBlockAltair) UnmarshalSSZ(buf []byte) error { +func (c *BeaconBlockAltair) 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.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[0:8]) - - // Field (1) 'ProposerIndex' - b.ProposerIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](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]...) + sszSlice0 := buf[0:8] // c.Slot + sszSlice1 := buf[8:16] // c.ProposerIndex + sszSlice2 := buf[16:48] // c.ParentRoot + sszSlice3 := buf[48:80] // c.StateRoot - // Field (3) 'StateRoot' - if cap(b.StateRoot) == 0 { - b.StateRoot = make([]byte, 0, len(buf[48:80])) + sszVarOffset4 := ssz.ReadOffset(buf[80:84]) // c.Body + if sszVarOffset4 != 84 { + return ssz.ErrInvalidVariableOffset } - b.StateRoot = append(b.StateRoot, buf[48:80]...) - - // Offset (4) 'Body' - if o4 = ssz.ReadOffset(buf[80:84]); o4 > size { + if sszVarOffset4 > size { return ssz.ErrOffset } + sszSlice4 := buf[sszVarOffset4:] // c.Body - if o4 != 84 { - return ssz.ErrInvalidVariableOffset + // Field 0: Slot + if err = c.Slot.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Slot: %w", err) } - // Field (4) 'Body' - { - buf = tail[o4:] - if b.Body == nil { - b.Body = new(BeaconBlockBodyAltair) - } - if err = b.Body.UnmarshalSSZ(buf); err != nil { - return err - } + // Field 1: ProposerIndex + if err = c.ProposerIndex.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("ProposerIndex: %w", err) } - return err -} -// SizeSSZ returns the ssz encoded size in bytes for the BeaconBlockAltair object -func (b *BeaconBlockAltair) SizeSSZ() (size int) { - size = 84 + // Field 2: ParentRoot + c.ParentRoot = make([]byte, 0, 32) + c.ParentRoot = append(c.ParentRoot, sszSlice2...) - // Field (4) 'Body' - if b.Body == nil { - b.Body = new(BeaconBlockBodyAltair) - } - size += b.Body.SizeSSZ() + // Field 3: StateRoot + c.StateRoot = make([]byte, 0, 32) + c.StateRoot = append(c.StateRoot, sszSlice3...) - return + // Field 4: Body + c.Body = new(BeaconBlockBodyAltair) + if err = c.Body.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("Body: %w", err) + } + return err } -// HashTreeRoot ssz hashes the BeaconBlockAltair object -func (b *BeaconBlockAltair) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) +func (c *BeaconBlockAltair) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the BeaconBlockAltair object with a hasher -func (b *BeaconBlockAltair) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *BeaconBlockAltair) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Slot' - ssz.PutUint(hh, b.Slot) - - // Field (1) 'ProposerIndex' - ssz.PutUint(hh, b.ProposerIndex) - - // Field (2) 'ParentRoot' - if size := len(b.ParentRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentRoot", size, 32) - return + // Field 0: Slot + if err := c.Slot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Slot: %w", err) } - hh.PutBytes(b.ParentRoot) - - // Field (3) 'StateRoot' - if size := len(b.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return + // Field 1: ProposerIndex + if err := c.ProposerIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ProposerIndex: %w", err) } - hh.PutBytes(b.StateRoot) - - // Field (4) 'Body' - if err = b.Body.HashTreeRootWith(hh); err != nil { - return + // Field 2: ParentRoot + if len(c.ParentRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ParentRoot) + // Field 3: StateRoot + if len(c.StateRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.StateRoot) + // Field 4: Body + if err := c.Body.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Body: %w", err) } - hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the BeaconBlockBodyAltair object -func (b *BeaconBlockBodyAltair) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) +func (c *BeaconBlockBodyAltair) SizeSSZ() int { + size := 320 + size += len(c.ProposerSlashings) * 416 + for _, o := range c.AttesterSlashings { + size += 4 + size += o.SizeSSZ() + } + for _, o := range c.Attestations { + size += 4 + size += o.SizeSSZ() + } + size += len(c.Deposits) * 1240 + size += len(c.VoluntaryExits) * 112 + return size } -// MarshalSSZTo ssz marshals the BeaconBlockBodyAltair object to a target array -func (b *BeaconBlockBodyAltair) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(320) +func (c *BeaconBlockBodyAltair) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} + +func (c *BeaconBlockBodyAltair) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 320 - // Field (0) 'RandaoReveal' - if size := len(b.RandaoReveal); size != 96 { - err = ssz.ErrBytesLengthFn("--.RandaoReveal", size, 96) - return + // Field 0: RandaoReveal + if len(c.RandaoReveal) != 96 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.RandaoReveal...) + dst = append(dst, c.RandaoReveal...) - // Field (1) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(Eth1Data) + // Field 1: Eth1Data + if c.Eth1Data == nil { + c.Eth1Data = new(Eth1Data) } - if dst, err = b.Eth1Data.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.Eth1Data.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Eth1Data: %w", err) } - // Field (2) 'Graffiti' - if size := len(b.Graffiti); size != 32 { - err = ssz.ErrBytesLengthFn("--.Graffiti", size, 32) - return + // Field 2: Graffiti + if len(c.Graffiti) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.Graffiti...) + dst = append(dst, c.Graffiti...) - // Offset (3) 'ProposerSlashings' + // Field 3: ProposerSlashings dst = ssz.WriteOffset(dst, offset) - offset += len(b.ProposerSlashings) * 416 + offset += len(c.ProposerSlashings) * 416 - // Offset (4) 'AttesterSlashings' + // Field 4: AttesterSlashings dst = ssz.WriteOffset(dst, offset) - for ii := 0; ii < len(b.AttesterSlashings); ii++ { + for _, o := range c.AttesterSlashings { offset += 4 - offset += b.AttesterSlashings[ii].SizeSSZ() + offset += o.SizeSSZ() } - // Offset (5) 'Attestations' + // Field 5: Attestations dst = ssz.WriteOffset(dst, offset) - for ii := 0; ii < len(b.Attestations); ii++ { + for _, o := range c.Attestations { offset += 4 - offset += b.Attestations[ii].SizeSSZ() + offset += o.SizeSSZ() } - // Offset (6) 'Deposits' + // Field 6: Deposits dst = ssz.WriteOffset(dst, offset) - offset += len(b.Deposits) * 1240 + offset += len(c.Deposits) * 1240 - // Offset (7) 'VoluntaryExits' + // Field 7: VoluntaryExits dst = ssz.WriteOffset(dst, offset) - offset += len(b.VoluntaryExits) * 112 + offset += len(c.VoluntaryExits) * 112 - // Field (8) 'SyncAggregate' - if b.SyncAggregate == nil { - b.SyncAggregate = new(SyncAggregate) + // Field 8: SyncAggregate + if c.SyncAggregate == nil { + c.SyncAggregate = new(SyncAggregate) } - if dst, err = b.SyncAggregate.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.SyncAggregate.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SyncAggregate: %w", err) } - // Field (3) 'ProposerSlashings' - if size := len(b.ProposerSlashings); size > 16 { - err = ssz.ErrListTooBigFn("--.ProposerSlashings", size, 16) - return + // Field 3: ProposerSlashings + if len(c.ProposerSlashings) > 16 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.ProposerSlashings); ii++ { - if dst, err = b.ProposerSlashings[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.ProposerSlashings { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ProposerSlashings: %w", err) } } - // Field (4) 'AttesterSlashings' - if size := len(b.AttesterSlashings); size > 2 { - err = ssz.ErrListTooBigFn("--.AttesterSlashings", size, 2) - return + // Field 4: AttesterSlashings + if len(c.AttesterSlashings) > 2 { + return nil, ssz.ErrListTooBig } { - offset = 4 * len(b.AttesterSlashings) - for ii := 0; ii < len(b.AttesterSlashings); ii++ { + offset = 4 * len(c.AttesterSlashings) + for _, o := range c.AttesterSlashings { dst = ssz.WriteOffset(dst, offset) - offset += b.AttesterSlashings[ii].SizeSSZ() + offset += o.SizeSSZ() } } - for ii := 0; ii < len(b.AttesterSlashings); ii++ { - if dst, err = b.AttesterSlashings[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.AttesterSlashings { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("AttesterSlashings: %w", err) } } - // Field (5) 'Attestations' - if size := len(b.Attestations); size > 128 { - err = ssz.ErrListTooBigFn("--.Attestations", size, 128) - return + // Field 5: Attestations + if len(c.Attestations) > 128 { + return nil, ssz.ErrListTooBig } { - offset = 4 * len(b.Attestations) - for ii := 0; ii < len(b.Attestations); ii++ { + offset = 4 * len(c.Attestations) + for _, o := range c.Attestations { dst = ssz.WriteOffset(dst, offset) - offset += b.Attestations[ii].SizeSSZ() + offset += o.SizeSSZ() } } - for ii := 0; ii < len(b.Attestations); ii++ { - if dst, err = b.Attestations[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.Attestations { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Attestations: %w", err) } } - // Field (6) 'Deposits' - if size := len(b.Deposits); size > 16 { - err = ssz.ErrListTooBigFn("--.Deposits", size, 16) - return + // Field 6: Deposits + if len(c.Deposits) > 16 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.Deposits); ii++ { - if dst, err = b.Deposits[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.Deposits { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Deposits: %w", err) } } - // Field (7) 'VoluntaryExits' - if size := len(b.VoluntaryExits); size > 16 { - err = ssz.ErrListTooBigFn("--.VoluntaryExits", size, 16) - return + // Field 7: VoluntaryExits + if len(c.VoluntaryExits) > 16 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.VoluntaryExits); ii++ { - if dst, err = b.VoluntaryExits[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.VoluntaryExits { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("VoluntaryExits: %w", err) } } - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the BeaconBlockBodyAltair object -func (b *BeaconBlockBodyAltair) UnmarshalSSZ(buf []byte) error { +func (c *BeaconBlockBodyAltair) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size < 320 { return ssz.ErrSize } - tail := buf - var o3, o4, o5, o6, o7 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(Eth1Data) - } - if err = b.Eth1Data.UnmarshalSSZ(buf[96:168]); err != nil { - return err - } + sszSlice0 := buf[0:96] // c.RandaoReveal + sszSlice1 := buf[96:168] // c.Eth1Data + sszSlice2 := buf[168:200] // c.Graffiti + sszSlice8 := buf[220:320] // c.SyncAggregate - // Field (2) 'Graffiti' - if cap(b.Graffiti) == 0 { - b.Graffiti = make([]byte, 0, len(buf[168:200])) + sszVarOffset3 := ssz.ReadOffset(buf[200:204]) // c.ProposerSlashings + if sszVarOffset3 != 320 { + return ssz.ErrInvalidVariableOffset } - b.Graffiti = append(b.Graffiti, buf[168:200]...) - - // Offset (3) 'ProposerSlashings' - if o3 = ssz.ReadOffset(buf[200:204]); o3 > size { + if sszVarOffset3 > size { return ssz.ErrOffset } - - if o3 != 320 { - return ssz.ErrInvalidVariableOffset - } - - // Offset (4) 'AttesterSlashings' - if o4 = ssz.ReadOffset(buf[204:208]); o4 > size || o3 > o4 { + sszVarOffset4 := ssz.ReadOffset(buf[204:208]) // c.AttesterSlashings + if sszVarOffset4 > size || sszVarOffset4 < sszVarOffset3 { return ssz.ErrOffset } - - // Offset (5) 'Attestations' - if o5 = ssz.ReadOffset(buf[208:212]); o5 > size || o4 > o5 { + sszVarOffset5 := ssz.ReadOffset(buf[208:212]) // c.Attestations + if sszVarOffset5 > size || sszVarOffset5 < sszVarOffset4 { return ssz.ErrOffset } - - // Offset (6) 'Deposits' - if o6 = ssz.ReadOffset(buf[212:216]); o6 > size || o5 > o6 { + sszVarOffset6 := ssz.ReadOffset(buf[212:216]) // c.Deposits + if sszVarOffset6 > size || sszVarOffset6 < sszVarOffset5 { return ssz.ErrOffset } - - // Offset (7) 'VoluntaryExits' - if o7 = ssz.ReadOffset(buf[216:220]); o7 > size || o6 > o7 { + sszVarOffset7 := ssz.ReadOffset(buf[216:220]) // c.VoluntaryExits + if sszVarOffset7 > size || sszVarOffset7 < sszVarOffset6 { return ssz.ErrOffset } + sszSlice3 := buf[sszVarOffset3:sszVarOffset4] // c.ProposerSlashings + sszSlice4 := buf[sszVarOffset4:sszVarOffset5] // c.AttesterSlashings + sszSlice5 := buf[sszVarOffset5:sszVarOffset6] // c.Attestations + sszSlice6 := buf[sszVarOffset6:sszVarOffset7] // c.Deposits + sszSlice7 := buf[sszVarOffset7:] // c.VoluntaryExits - // Field (8) 'SyncAggregate' - if b.SyncAggregate == nil { - b.SyncAggregate = new(SyncAggregate) - } - if err = b.SyncAggregate.UnmarshalSSZ(buf[220:320]); err != nil { - return err + // Field 0: RandaoReveal + c.RandaoReveal = make([]byte, 0, 96) + c.RandaoReveal = append(c.RandaoReveal, sszSlice0...) + + // Field 1: Eth1Data + c.Eth1Data = new(Eth1Data) + if err = c.Eth1Data.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Eth1Data: %w", err) } - // Field (3) 'ProposerSlashings' + // Field 2: Graffiti + c.Graffiti = make([]byte, 0, 32) + c.Graffiti = append(c.Graffiti, sszSlice2...) + + // Field 3: ProposerSlashings { - buf = tail[o3:o4] - num, err := ssz.DivideInt2(len(buf), 416, 16) - if err != nil { - return err - } - b.ProposerSlashings = make([]*ProposerSlashing, num) - for ii := 0; ii < num; ii++ { - if b.ProposerSlashings[ii] == nil { - b.ProposerSlashings[ii] = new(ProposerSlashing) - } - if err = b.ProposerSlashings[ii].UnmarshalSSZ(buf[ii*416 : (ii+1)*416]); err != nil { - return err + if len(sszSlice3)%416 != 0 { + return fmt.Errorf("misaligned bytes: c.ProposerSlashings length is %d, which is not a multiple of 416: %w", len(sszSlice3), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice3) / 416 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.ProposerSlashings has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.ProposerSlashings = make([]*ProposerSlashing, numElem) + for i := 0; i < numElem; i++ { + var tmp *ProposerSlashing + tmp = new(ProposerSlashing) + tmpSlice := sszSlice3[i*416 : (1+i)*416] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("ProposerSlashings: %w", err) } + c.ProposerSlashings[i] = tmp } } - // Field (4) 'AttesterSlashings' + // Field 4: AttesterSlashings { - buf = tail[o4:o5] - num, err := ssz.DecodeDynamicLength(buf, 2) - 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) + // empty lists are zero length, so make sure there is room for an offset + // before attempting to unmarshal it + if len(sszSlice4) > 3 { + startOffset := ssz.ReadOffset(sszSlice4[0:4]) + if startOffset == 0 { + return fmt.Errorf("encountered invalid offset of 0 when decoding c.AttesterSlashings") + } + if startOffset%4 != 0 { + return fmt.Errorf("misaligned list bytes: when decoding c.AttesterSlashings, end-of-list offset is %d, which is not a multiple of 4 (offset size)", startOffset) + } + listLen := startOffset / 4 + if listLen > 2 { + return fmt.Errorf("ssz-max exceeded: c.AttesterSlashings has %d elements, ssz-max is 2: %w", listLen, ssz.ErrListTooBig) + } + totalVarBytes := uint64(len(sszSlice4)) + if totalVarBytes < startOffset { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.AttesterSlashings") } - if err = b.AttesterSlashings[indx].UnmarshalSSZ(buf); err != nil { - return err + c.AttesterSlashings = make([]*AttesterSlashing, listLen) + var tmpSlice []byte + for i := uint64(0); i < listLen; i++ { + var tmp *AttesterSlashing + tmp = new(AttesterSlashing) + endOffset := totalVarBytes + if i+1 != listLen { + endOffset = ssz.ReadOffset(sszSlice4[(i+1)*4 : (i+2)*4]) + if totalVarBytes < endOffset { + return fmt.Errorf("offset %d points past the end of buffer when decoding c.AttesterSlashings", endOffset) + } + } + if endOffset < startOffset { + return fmt.Errorf("offset %d is not greater than start offset %d when decoding c.AttesterSlashings", endOffset, startOffset) + } + tmpSlice = sszSlice4[startOffset:endOffset] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("AttesterSlashings: %w", err) + } + c.AttesterSlashings[i] = tmp + startOffset = endOffset } - return nil - }) - if err != nil { - return err + } else { + if len(sszSlice4) > 0 { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.AttesterSlashings") + } + c.AttesterSlashings = make([]*AttesterSlashing, 0) } } - // Field (5) 'Attestations' + // Field 5: Attestations { - buf = tail[o5:o6] - num, err := ssz.DecodeDynamicLength(buf, 128) - 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) + // empty lists are zero length, so make sure there is room for an offset + // before attempting to unmarshal it + if len(sszSlice5) > 3 { + startOffset := ssz.ReadOffset(sszSlice5[0:4]) + if startOffset == 0 { + return fmt.Errorf("encountered invalid offset of 0 when decoding c.Attestations") + } + if startOffset%4 != 0 { + return fmt.Errorf("misaligned list bytes: when decoding c.Attestations, end-of-list offset is %d, which is not a multiple of 4 (offset size)", startOffset) + } + listLen := startOffset / 4 + if listLen > 128 { + return fmt.Errorf("ssz-max exceeded: c.Attestations has %d elements, ssz-max is 128: %w", listLen, ssz.ErrListTooBig) } - if err = b.Attestations[indx].UnmarshalSSZ(buf); err != nil { - return err + totalVarBytes := uint64(len(sszSlice5)) + if totalVarBytes < startOffset { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.Attestations") } - return nil - }) - if err != nil { - return err + c.Attestations = make([]*Attestation, listLen) + var tmpSlice []byte + for i := uint64(0); i < listLen; i++ { + var tmp *Attestation + tmp = new(Attestation) + endOffset := totalVarBytes + if i+1 != listLen { + endOffset = ssz.ReadOffset(sszSlice5[(i+1)*4 : (i+2)*4]) + if totalVarBytes < endOffset { + return fmt.Errorf("offset %d points past the end of buffer when decoding c.Attestations", endOffset) + } + } + if endOffset < startOffset { + return fmt.Errorf("offset %d is not greater than start offset %d when decoding c.Attestations", endOffset, startOffset) + } + tmpSlice = sszSlice5[startOffset:endOffset] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Attestations: %w", err) + } + c.Attestations[i] = tmp + startOffset = endOffset + } + } else { + if len(sszSlice5) > 0 { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.Attestations") + } + c.Attestations = make([]*Attestation, 0) } } - // Field (6) 'Deposits' + // Field 6: Deposits { - buf = tail[o6:o7] - num, err := ssz.DivideInt2(len(buf), 1240, 16) - if err != nil { - return err - } - b.Deposits = make([]*Deposit, num) - for ii := 0; ii < num; ii++ { - if b.Deposits[ii] == nil { - b.Deposits[ii] = new(Deposit) - } - if err = b.Deposits[ii].UnmarshalSSZ(buf[ii*1240 : (ii+1)*1240]); err != nil { - return err + if len(sszSlice6)%1240 != 0 { + return fmt.Errorf("misaligned bytes: c.Deposits length is %d, which is not a multiple of 1240: %w", len(sszSlice6), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice6) / 1240 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.Deposits has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.Deposits = make([]*Deposit, numElem) + for i := 0; i < numElem; i++ { + var tmp *Deposit + tmp = new(Deposit) + tmpSlice := sszSlice6[i*1240 : (1+i)*1240] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Deposits: %w", err) } + c.Deposits[i] = tmp } } - // Field (7) 'VoluntaryExits' + // Field 7: VoluntaryExits { - buf = tail[o7:] - num, err := ssz.DivideInt2(len(buf), 112, 16) - if err != nil { - return err - } - b.VoluntaryExits = make([]*SignedVoluntaryExit, num) - for ii := 0; ii < num; ii++ { - if b.VoluntaryExits[ii] == nil { - b.VoluntaryExits[ii] = new(SignedVoluntaryExit) - } - if err = b.VoluntaryExits[ii].UnmarshalSSZ(buf[ii*112 : (ii+1)*112]); err != nil { - return err + if len(sszSlice7)%112 != 0 { + return fmt.Errorf("misaligned bytes: c.VoluntaryExits length is %d, which is not a multiple of 112: %w", len(sszSlice7), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice7) / 112 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.VoluntaryExits has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.VoluntaryExits = make([]*SignedVoluntaryExit, numElem) + for i := 0; i < numElem; i++ { + var tmp *SignedVoluntaryExit + tmp = new(SignedVoluntaryExit) + tmpSlice := sszSlice7[i*112 : (1+i)*112] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("VoluntaryExits: %w", err) } + c.VoluntaryExits[i] = tmp } } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the BeaconBlockBodyAltair object -func (b *BeaconBlockBodyAltair) SizeSSZ() (size int) { - size = 320 - - // 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 8: SyncAggregate + c.SyncAggregate = new(SyncAggregate) + if err = c.SyncAggregate.UnmarshalSSZ(sszSlice8); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) } - - // Field (6) 'Deposits' - size += len(b.Deposits) * 1240 - - // Field (7) 'VoluntaryExits' - size += len(b.VoluntaryExits) * 112 - - return + return err } -// HashTreeRoot ssz hashes the BeaconBlockBodyAltair object -func (b *BeaconBlockBodyAltair) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) +func (c *BeaconBlockBodyAltair) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the BeaconBlockBodyAltair object with a hasher -func (b *BeaconBlockBodyAltair) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *BeaconBlockBodyAltair) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'RandaoReveal' - if size := len(b.RandaoReveal); size != 96 { - err = ssz.ErrBytesLengthFn("--.RandaoReveal", size, 96) - return + // Field 0: RandaoReveal + if len(c.RandaoReveal) != 96 { + return ssz.ErrBytesLength } - hh.PutBytes(b.RandaoReveal) - - // Field (1) 'Eth1Data' - if err = b.Eth1Data.HashTreeRootWith(hh); err != nil { - return + hh.PutBytes(c.RandaoReveal) + // Field 1: Eth1Data + if err := c.Eth1Data.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Eth1Data: %w", err) } - - // Field (2) 'Graffiti' - if size := len(b.Graffiti); size != 32 { - err = ssz.ErrBytesLengthFn("--.Graffiti", size, 32) - return + // Field 2: Graffiti + if len(c.Graffiti) != 32 { + return ssz.ErrBytesLength } - hh.PutBytes(b.Graffiti) - - // Field (3) 'ProposerSlashings' + hh.PutBytes(c.Graffiti) + // Field 3: ProposerSlashings { + if len(c.ProposerSlashings) > 16 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.ProposerSlashings { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ProposerSlashings: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.ProposerSlashings)), 16) } - - // Field (4) 'AttesterSlashings' + // Field 4: AttesterSlashings { + if len(c.AttesterSlashings) > 2 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.AttesterSlashings { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("AttesterSlashings: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 2) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.AttesterSlashings)), 2) } - - // Field (5) 'Attestations' + // Field 5: Attestations { + if len(c.Attestations) > 128 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.Attestations { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Attestations: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 128) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Attestations)), 128) } - - // Field (6) 'Deposits' + // Field 6: Deposits { + if len(c.Deposits) > 16 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.Deposits { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Deposits: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Deposits)), 16) } - - // Field (7) 'VoluntaryExits' + // Field 7: VoluntaryExits { + if len(c.VoluntaryExits) > 16 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.VoluntaryExits { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("VoluntaryExits: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.VoluntaryExits)), 16) } - - // Field (8) 'SyncAggregate' - if err = b.SyncAggregate.HashTreeRootWith(hh); err != nil { - return - } - - hh.Merkleize(indx) - return -} - -// 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) 'SyncCommitteeBits' - if size := len(s.SyncCommitteeBits); size != 4 { - err = ssz.ErrBytesLengthFn("--.SyncCommitteeBits", size, 4) - return - } - dst = append(dst, s.SyncCommitteeBits...) - - // Field (1) 'SyncCommitteeSignature' - if size := len(s.SyncCommitteeSignature); size != 96 { - err = ssz.ErrBytesLengthFn("--.SyncCommitteeSignature", size, 96) - return - } - dst = append(dst, s.SyncCommitteeSignature...) - - return -} - -// UnmarshalSSZ ssz unmarshals the SyncAggregate object -func (s *SyncAggregate) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size != 100 { - return ssz.ErrSize - } - - // Field (0) 'SyncCommitteeBits' - if cap(s.SyncCommitteeBits) == 0 { - s.SyncCommitteeBits = make([]byte, 0, len(buf[0:4])) - } - s.SyncCommitteeBits = append(s.SyncCommitteeBits, buf[0:4]...) - - // Field (1) 'SyncCommitteeSignature' - if cap(s.SyncCommitteeSignature) == 0 { - s.SyncCommitteeSignature = make([]byte, 0, len(buf[4:100])) - } - s.SyncCommitteeSignature = append(s.SyncCommitteeSignature, buf[4:100]...) - - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the SyncAggregate object -func (s *SyncAggregate) SizeSSZ() (size int) { - size = 100 - 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.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'SyncCommitteeBits' - if size := len(s.SyncCommitteeBits); size != 4 { - err = ssz.ErrBytesLengthFn("--.SyncCommitteeBits", size, 4) - return - } - hh.PutBytes(s.SyncCommitteeBits) - - // Field (1) 'SyncCommitteeSignature' - if size := len(s.SyncCommitteeSignature); size != 96 { - err = ssz.ErrBytesLengthFn("--.SyncCommitteeSignature", size, 96) - return + // Field 8: SyncAggregate + if err := c.SyncAggregate.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) } - hh.PutBytes(s.SyncCommitteeSignature) - hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the SyncCommittee object -func (s *SyncCommittee) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) +func (c *BeaconStateAltair) SizeSSZ() int { + size := 10229 + size += len(c.HistoricalRoots) * 32 + size += len(c.Eth1DataVotes) * 72 + size += len(c.Validators) * 121 + size += len(c.Balances) * 8 + size += len(c.PreviousEpochParticipation) + size += len(c.CurrentEpochParticipation) + size += len(c.InactivityScores) * 8 + return size } -// 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 != 32 { - err = ssz.ErrVectorLengthFn("--.Pubkeys", size, 32) - return - } - for ii := 0; ii < 32; ii++ { - if size := len(s.Pubkeys[ii]); size != 48 { - err = ssz.ErrBytesLengthFn("--.Pubkeys[ii]", size, 48) - return - } - dst = append(dst, s.Pubkeys[ii]...) - } - - // Field (1) 'AggregatePubkey' - if size := len(s.AggregatePubkey); size != 48 { - err = ssz.ErrBytesLengthFn("--.AggregatePubkey", size, 48) - return - } - dst = append(dst, s.AggregatePubkey...) - - return +func (c *BeaconStateAltair) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// UnmarshalSSZ ssz unmarshals the SyncCommittee object -func (s *SyncCommittee) UnmarshalSSZ(buf []byte) error { +func (c *BeaconStateAltair) MarshalSSZTo(dst []byte) ([]byte, error) { var err error - size := uint64(len(buf)) - if size != 1584 { - return ssz.ErrSize - } + offset := 10229 - // Field (0) 'Pubkeys' - s.Pubkeys = make([][]byte, 32) - for ii := 0; ii < 32; ii++ { - if cap(s.Pubkeys[ii]) == 0 { - s.Pubkeys[ii] = make([]byte, 0, len(buf[0:1536][ii*48:(ii+1)*48])) - } - s.Pubkeys[ii] = append(s.Pubkeys[ii], buf[0:1536][ii*48:(ii+1)*48]...) - } + // Field 0: GenesisTime + dst = binary.LittleEndian.AppendUint64(dst, c.GenesisTime) - // Field (1) 'AggregatePubkey' - if cap(s.AggregatePubkey) == 0 { - s.AggregatePubkey = make([]byte, 0, len(buf[1536:1584])) + // Field 1: GenesisValidatorsRoot + if len(c.GenesisValidatorsRoot) != 32 { + return nil, ssz.ErrBytesLength } - s.AggregatePubkey = append(s.AggregatePubkey, buf[1536:1584]...) + dst = append(dst, c.GenesisValidatorsRoot...) - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the SyncCommittee object -func (s *SyncCommittee) SizeSSZ() (size int) { - size = 1584 - 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.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'Pubkeys' - { - if size := len(s.Pubkeys); size != 32 { - err = ssz.ErrVectorLengthFn("--.Pubkeys", size, 32) - return - } - subIndx := hh.Index() - for _, i := range s.Pubkeys { - if len(i) != 48 { - err = ssz.ErrBytesLength - return - } - hh.PutBytes(i) - } - hh.Merkleize(subIndx) + // Field 2: Slot + if dst, err = c.Slot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Slot: %w", err) } - // Field (1) 'AggregatePubkey' - if size := len(s.AggregatePubkey); size != 48 { - err = ssz.ErrBytesLengthFn("--.AggregatePubkey", size, 48) - return + // Field 3: Fork + if c.Fork == nil { + c.Fork = new(Fork) } - hh.PutBytes(s.AggregatePubkey) - - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the BeaconStateAltair object -func (b *BeaconStateAltair) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} - -// MarshalSSZTo ssz marshals the BeaconStateAltair object to a target array -func (b *BeaconStateAltair) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(10229) - - // Field (0) 'GenesisTime' - dst = ssz.MarshalUint(dst, b.GenesisTime) - - // Field (1) 'GenesisValidatorsRoot' - if size := len(b.GenesisValidatorsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.GenesisValidatorsRoot", size, 32) - return + if dst, err = c.Fork.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Fork: %w", err) } - dst = append(dst, b.GenesisValidatorsRoot...) - // Field (2) 'Slot' - dst = ssz.MarshalUint(dst, b.Slot) - - // Field (3) 'Fork' - if b.Fork == nil { - b.Fork = new(Fork) + // Field 4: LatestBlockHeader + if c.LatestBlockHeader == nil { + c.LatestBlockHeader = new(BeaconBlockHeader) } - if dst, err = b.Fork.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.LatestBlockHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("LatestBlockHeader: %w", err) } - // Field (4) 'LatestBlockHeader' - if b.LatestBlockHeader == nil { - b.LatestBlockHeader = new(BeaconBlockHeader) - } - if dst, err = b.LatestBlockHeader.MarshalSSZTo(dst); err != nil { - return + // Field 5: BlockRoots + if len(c.BlockRoots) != 64 { + return nil, ssz.ErrBytesLength } - - // Field (5) 'BlockRoots' - if size := len(b.BlockRoots); size != 64 { - err = ssz.ErrVectorLengthFn("--.BlockRoots", size, 64) - return - } - for ii := 0; ii < 64; ii++ { - if size := len(b.BlockRoots[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockRoots[ii]", size, 32) - return + for _, o := range c.BlockRoots { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.BlockRoots[ii]...) + dst = append(dst, o...) } - // Field (6) 'StateRoots' - if size := len(b.StateRoots); size != 64 { - err = ssz.ErrVectorLengthFn("--.StateRoots", size, 64) - return + // Field 6: StateRoots + if len(c.StateRoots) != 64 { + return nil, ssz.ErrBytesLength } - for ii := 0; ii < 64; ii++ { - if size := len(b.StateRoots[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoots[ii]", size, 32) - return + for _, o := range c.StateRoots { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.StateRoots[ii]...) + dst = append(dst, o...) } - // Offset (7) 'HistoricalRoots' + // Field 7: HistoricalRoots dst = ssz.WriteOffset(dst, offset) - offset += len(b.HistoricalRoots) * 32 + offset += len(c.HistoricalRoots) * 32 - // Field (8) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(Eth1Data) + // Field 8: Eth1Data + if c.Eth1Data == nil { + c.Eth1Data = new(Eth1Data) } - if dst, err = b.Eth1Data.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.Eth1Data.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Eth1Data: %w", err) } - // Offset (9) 'Eth1DataVotes' + // Field 9: Eth1DataVotes dst = ssz.WriteOffset(dst, offset) - offset += len(b.Eth1DataVotes) * 72 + offset += len(c.Eth1DataVotes) * 72 - // Field (10) 'Eth1DepositIndex' - dst = ssz.MarshalUint(dst, b.Eth1DepositIndex) + // Field 10: Eth1DepositIndex + dst = binary.LittleEndian.AppendUint64(dst, c.Eth1DepositIndex) - // Offset (11) 'Validators' + // Field 11: Validators dst = ssz.WriteOffset(dst, offset) - offset += len(b.Validators) * 121 + offset += len(c.Validators) * 121 - // Offset (12) 'Balances' + // Field 12: Balances dst = ssz.WriteOffset(dst, offset) - offset += len(b.Balances) * 8 + offset += len(c.Balances) * 8 - // Field (13) 'RandaoMixes' - if size := len(b.RandaoMixes); size != 64 { - err = ssz.ErrVectorLengthFn("--.RandaoMixes", size, 64) - return + // Field 13: RandaoMixes + if len(c.RandaoMixes) != 64 { + return nil, ssz.ErrBytesLength } - for ii := 0; ii < 64; ii++ { - if size := len(b.RandaoMixes[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.RandaoMixes[ii]", size, 32) - return + for _, o := range c.RandaoMixes { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.RandaoMixes[ii]...) + dst = append(dst, o...) } - // Field (14) 'Slashings' - if size := len(b.Slashings); size != 64 { - err = ssz.ErrVectorLengthFn("--.Slashings", size, 64) - return + // Field 14: Slashings + if len(c.Slashings) != 64 { + return nil, ssz.ErrBytesLength } - for ii := 0; ii < 64; ii++ { - dst = ssz.MarshalUint(dst, b.Slashings[ii]) + for _, o := range c.Slashings { + dst = binary.LittleEndian.AppendUint64(dst, o) } - // Offset (15) 'PreviousEpochParticipation' + // Field 15: PreviousEpochParticipation dst = ssz.WriteOffset(dst, offset) - offset += len(b.PreviousEpochParticipation) + offset += len(c.PreviousEpochParticipation) - // Offset (16) 'CurrentEpochParticipation' + // Field 16: CurrentEpochParticipation dst = ssz.WriteOffset(dst, offset) - offset += len(b.CurrentEpochParticipation) + offset += len(c.CurrentEpochParticipation) - // Field (17) 'JustificationBits' - if size := len(b.JustificationBits); size != 1 { - err = ssz.ErrBytesLengthFn("--.JustificationBits", size, 1) - return + // Field 17: JustificationBits + if len([]byte(c.JustificationBits)) != 1 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.JustificationBits...) + dst = append(dst, []byte(c.JustificationBits)...) - // Field (18) 'PreviousJustifiedCheckpoint' - if b.PreviousJustifiedCheckpoint == nil { - b.PreviousJustifiedCheckpoint = new(Checkpoint) + // Field 18: PreviousJustifiedCheckpoint + if c.PreviousJustifiedCheckpoint == nil { + c.PreviousJustifiedCheckpoint = new(Checkpoint) } - if dst, err = b.PreviousJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.PreviousJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("PreviousJustifiedCheckpoint: %w", err) } - // Field (19) 'CurrentJustifiedCheckpoint' - if b.CurrentJustifiedCheckpoint == nil { - b.CurrentJustifiedCheckpoint = new(Checkpoint) + // Field 19: CurrentJustifiedCheckpoint + if c.CurrentJustifiedCheckpoint == nil { + c.CurrentJustifiedCheckpoint = new(Checkpoint) } - if dst, err = b.CurrentJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.CurrentJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("CurrentJustifiedCheckpoint: %w", err) } - // Field (20) 'FinalizedCheckpoint' - if b.FinalizedCheckpoint == nil { - b.FinalizedCheckpoint = new(Checkpoint) + // Field 20: FinalizedCheckpoint + if c.FinalizedCheckpoint == nil { + c.FinalizedCheckpoint = new(Checkpoint) } - if dst, err = b.FinalizedCheckpoint.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.FinalizedCheckpoint.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("FinalizedCheckpoint: %w", err) } - // Offset (21) 'InactivityScores' + // Field 21: InactivityScores dst = ssz.WriteOffset(dst, offset) - offset += len(b.InactivityScores) * 8 + offset += len(c.InactivityScores) * 8 - // Field (22) 'CurrentSyncCommittee' - if b.CurrentSyncCommittee == nil { - b.CurrentSyncCommittee = new(SyncCommittee) + // Field 22: CurrentSyncCommittee + if c.CurrentSyncCommittee == nil { + c.CurrentSyncCommittee = new(SyncCommittee) } - if dst, err = b.CurrentSyncCommittee.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.CurrentSyncCommittee.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("CurrentSyncCommittee: %w", err) } - // Field (23) 'NextSyncCommittee' - if b.NextSyncCommittee == nil { - b.NextSyncCommittee = new(SyncCommittee) + // Field 23: NextSyncCommittee + if c.NextSyncCommittee == nil { + c.NextSyncCommittee = new(SyncCommittee) } - if dst, err = b.NextSyncCommittee.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.NextSyncCommittee.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("NextSyncCommittee: %w", err) } - // Field (7) 'HistoricalRoots' - if size := len(b.HistoricalRoots); size > 16777216 { - err = ssz.ErrListTooBigFn("--.HistoricalRoots", size, 16777216) - return + // Field 7: HistoricalRoots + if len(c.HistoricalRoots) > 16777216 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.HistoricalRoots); ii++ { - if size := len(b.HistoricalRoots[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.HistoricalRoots[ii]", size, 32) - return + for _, o := range c.HistoricalRoots { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.HistoricalRoots[ii]...) + dst = append(dst, o...) } - // Field (9) 'Eth1DataVotes' - if size := len(b.Eth1DataVotes); size > 32 { - err = ssz.ErrListTooBigFn("--.Eth1DataVotes", size, 32) - return + // Field 9: Eth1DataVotes + if len(c.Eth1DataVotes) > 32 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.Eth1DataVotes); ii++ { - if dst, err = b.Eth1DataVotes[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.Eth1DataVotes { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Eth1DataVotes: %w", err) } } - // Field (11) 'Validators' - if size := len(b.Validators); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.Validators", size, 1099511627776) - return + // Field 11: Validators + if len(c.Validators) > 1099511627776 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.Validators); ii++ { - if dst, err = b.Validators[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.Validators { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Validators: %w", err) } } - // Field (12) 'Balances' - if size := len(b.Balances); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.Balances", size, 1099511627776) - return + // Field 12: Balances + if len(c.Balances) > 1099511627776 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.Balances); ii++ { - dst = ssz.MarshalUint(dst, b.Balances[ii]) + for _, o := range c.Balances { + dst = binary.LittleEndian.AppendUint64(dst, o) } - // Field (15) 'PreviousEpochParticipation' - if size := len(b.PreviousEpochParticipation); size > 1099511627776 { - err = ssz.ErrBytesLengthFn("--.PreviousEpochParticipation", size, 1099511627776) - return + // Field 15: PreviousEpochParticipation + if len(c.PreviousEpochParticipation) > 1099511627776 { + return nil, ssz.ErrListTooBig } - dst = append(dst, b.PreviousEpochParticipation...) + dst = append(dst, c.PreviousEpochParticipation...) - // Field (16) 'CurrentEpochParticipation' - if size := len(b.CurrentEpochParticipation); size > 1099511627776 { - err = ssz.ErrBytesLengthFn("--.CurrentEpochParticipation", size, 1099511627776) - return + // Field 16: CurrentEpochParticipation + if len(c.CurrentEpochParticipation) > 1099511627776 { + return nil, ssz.ErrListTooBig } - dst = append(dst, b.CurrentEpochParticipation...) + dst = append(dst, c.CurrentEpochParticipation...) - // Field (21) 'InactivityScores' - if size := len(b.InactivityScores); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.InactivityScores", size, 1099511627776) - return + // Field 21: InactivityScores + if len(c.InactivityScores) > 1099511627776 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.InactivityScores); ii++ { - dst = ssz.MarshalUint(dst, b.InactivityScores[ii]) + for _, o := range c.InactivityScores { + dst = binary.LittleEndian.AppendUint64(dst, o) } - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the BeaconStateAltair object -func (b *BeaconStateAltair) UnmarshalSSZ(buf []byte) error { +func (c *BeaconStateAltair) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size < 10229 { return ssz.ErrSize } - tail := buf - var o7, o9, o11, o12, o15, o16, o21 uint64 - - // Field (0) 'GenesisTime' - b.GenesisTime = ssz.UnmarshallUint[uint64](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.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[40:48]) - - // Field (3) 'Fork' - if b.Fork == nil { - b.Fork = new(Fork) - } - if err = b.Fork.UnmarshalSSZ(buf[48:64]); err != nil { - return err - } - - // Field (4) 'LatestBlockHeader' - if b.LatestBlockHeader == nil { - b.LatestBlockHeader = new(BeaconBlockHeader) - } - if err = b.LatestBlockHeader.UnmarshalSSZ(buf[64:176]); err != nil { - return err - } - - // Field (5) 'BlockRoots' - b.BlockRoots = make([][]byte, 64) - for ii := 0; ii < 64; ii++ { - if cap(b.BlockRoots[ii]) == 0 { - b.BlockRoots[ii] = make([]byte, 0, len(buf[176:2224][ii*32:(ii+1)*32])) - } - b.BlockRoots[ii] = append(b.BlockRoots[ii], buf[176:2224][ii*32:(ii+1)*32]...) - } - - // Field (6) 'StateRoots' - b.StateRoots = make([][]byte, 64) - for ii := 0; ii < 64; ii++ { - if cap(b.StateRoots[ii]) == 0 { - b.StateRoots[ii] = make([]byte, 0, len(buf[2224:4272][ii*32:(ii+1)*32])) - } - b.StateRoots[ii] = append(b.StateRoots[ii], buf[2224:4272][ii*32:(ii+1)*32]...) + sszSlice0 := buf[0:8] // c.GenesisTime + sszSlice1 := buf[8:40] // c.GenesisValidatorsRoot + sszSlice2 := buf[40:48] // c.Slot + sszSlice3 := buf[48:64] // c.Fork + sszSlice4 := buf[64:176] // c.LatestBlockHeader + sszSlice5 := buf[176:2224] // c.BlockRoots + sszSlice6 := buf[2224:4272] // c.StateRoots + sszSlice8 := buf[4276:4348] // c.Eth1Data + sszSlice10 := buf[4352:4360] // c.Eth1DepositIndex + sszSlice13 := buf[4368:6416] // c.RandaoMixes + sszSlice14 := buf[6416:6928] // c.Slashings + sszSlice17 := buf[6936:6937] // c.JustificationBits + sszSlice18 := buf[6937:6977] // c.PreviousJustifiedCheckpoint + sszSlice19 := buf[6977:7017] // c.CurrentJustifiedCheckpoint + sszSlice20 := buf[7017:7057] // c.FinalizedCheckpoint + sszSlice22 := buf[7061:8645] // c.CurrentSyncCommittee + sszSlice23 := buf[8645:10229] // c.NextSyncCommittee + + sszVarOffset7 := ssz.ReadOffset(buf[4272:4276]) // c.HistoricalRoots + if sszVarOffset7 != 10229 { + return ssz.ErrInvalidVariableOffset } - - // Offset (7) 'HistoricalRoots' - if o7 = ssz.ReadOffset(buf[4272:4276]); o7 > size { + if sszVarOffset7 > size { return ssz.ErrOffset } - - if o7 != 10229 { - return ssz.ErrInvalidVariableOffset + sszVarOffset9 := ssz.ReadOffset(buf[4348:4352]) // c.Eth1DataVotes + if sszVarOffset9 > size || sszVarOffset9 < sszVarOffset7 { + return ssz.ErrOffset } - - // Field (8) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(Eth1Data) + sszVarOffset11 := ssz.ReadOffset(buf[4360:4364]) // c.Validators + if sszVarOffset11 > size || sszVarOffset11 < sszVarOffset9 { + return ssz.ErrOffset } - if err = b.Eth1Data.UnmarshalSSZ(buf[4276:4348]); err != nil { - return err + sszVarOffset12 := ssz.ReadOffset(buf[4364:4368]) // c.Balances + if sszVarOffset12 > size || sszVarOffset12 < sszVarOffset11 { + return ssz.ErrOffset } - - // Offset (9) 'Eth1DataVotes' - if o9 = ssz.ReadOffset(buf[4348:4352]); o9 > size || o7 > o9 { + sszVarOffset15 := ssz.ReadOffset(buf[6928:6932]) // c.PreviousEpochParticipation + if sszVarOffset15 > size || sszVarOffset15 < sszVarOffset12 { return ssz.ErrOffset } - - // Field (10) 'Eth1DepositIndex' - b.Eth1DepositIndex = ssz.UnmarshallUint[uint64](buf[4352:4360]) - - // Offset (11) 'Validators' - if o11 = ssz.ReadOffset(buf[4360:4364]); o11 > size || o9 > o11 { + sszVarOffset16 := ssz.ReadOffset(buf[6932:6936]) // c.CurrentEpochParticipation + if sszVarOffset16 > size || sszVarOffset16 < sszVarOffset15 { return ssz.ErrOffset } - - // Offset (12) 'Balances' - if o12 = ssz.ReadOffset(buf[4364:4368]); o12 > size || o11 > o12 { + sszVarOffset21 := ssz.ReadOffset(buf[7057:7061]) // c.InactivityScores + if sszVarOffset21 > size || sszVarOffset21 < sszVarOffset16 { return ssz.ErrOffset } + sszSlice7 := buf[sszVarOffset7:sszVarOffset9] // c.HistoricalRoots + sszSlice9 := buf[sszVarOffset9:sszVarOffset11] // c.Eth1DataVotes + sszSlice11 := buf[sszVarOffset11:sszVarOffset12] // c.Validators + sszSlice12 := buf[sszVarOffset12:sszVarOffset15] // c.Balances + sszSlice15 := buf[sszVarOffset15:sszVarOffset16] // c.PreviousEpochParticipation + sszSlice16 := buf[sszVarOffset16:sszVarOffset21] // c.CurrentEpochParticipation + sszSlice21 := buf[sszVarOffset21:] // c.InactivityScores - // Field (13) 'RandaoMixes' - b.RandaoMixes = make([][]byte, 64) - for ii := 0; ii < 64; ii++ { - if cap(b.RandaoMixes[ii]) == 0 { - b.RandaoMixes[ii] = make([]byte, 0, len(buf[4368:6416][ii*32:(ii+1)*32])) - } - b.RandaoMixes[ii] = append(b.RandaoMixes[ii], buf[4368:6416][ii*32:(ii+1)*32]...) - } + // Field 0: GenesisTime + c.GenesisTime = binary.LittleEndian.Uint64(sszSlice0) - // Field (14) 'Slashings' - b.Slashings = ssz.ExtendUint(b.Slashings, 64) - for ii := 0; ii < 64; ii++ { - b.Slashings[ii] = ssz.UnmarshallUint[uint64](buf[6416:6928][ii*8 : (ii+1)*8]) - } + // Field 1: GenesisValidatorsRoot + c.GenesisValidatorsRoot = make([]byte, 0, 32) + c.GenesisValidatorsRoot = append(c.GenesisValidatorsRoot, sszSlice1...) - // Offset (15) 'PreviousEpochParticipation' - if o15 = ssz.ReadOffset(buf[6928:6932]); o15 > size || o12 > o15 { - return ssz.ErrOffset + // Field 2: Slot + if err = c.Slot.UnmarshalSSZ(sszSlice2); err != nil { + return fmt.Errorf("Slot: %w", err) } - // Offset (16) 'CurrentEpochParticipation' - if o16 = ssz.ReadOffset(buf[6932:6936]); o16 > size || o15 > o16 { - return ssz.ErrOffset + // Field 3: Fork + c.Fork = new(Fork) + if err = c.Fork.UnmarshalSSZ(sszSlice3); err != nil { + return fmt.Errorf("Fork: %w", err) } - // Field (17) 'JustificationBits' - if cap(b.JustificationBits) == 0 { - b.JustificationBits = make([]byte, 0, len(buf[6936:6937])) + // Field 4: LatestBlockHeader + c.LatestBlockHeader = new(BeaconBlockHeader) + if err = c.LatestBlockHeader.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("LatestBlockHeader: %w", err) } - b.JustificationBits = append(b.JustificationBits, buf[6936:6937]...) - // Field (18) 'PreviousJustifiedCheckpoint' - if b.PreviousJustifiedCheckpoint == nil { - b.PreviousJustifiedCheckpoint = new(Checkpoint) - } - if err = b.PreviousJustifiedCheckpoint.UnmarshalSSZ(buf[6937:6977]); err != nil { - return err - } + // Field 5: BlockRoots + { + c.BlockRoots = make([][]byte, 64) + for i := 0; i < 64; i++ { + var tmp []byte - // Field (19) 'CurrentJustifiedCheckpoint' - if b.CurrentJustifiedCheckpoint == nil { - b.CurrentJustifiedCheckpoint = new(Checkpoint) - } - if err = b.CurrentJustifiedCheckpoint.UnmarshalSSZ(buf[6977:7017]); err != nil { - return err + tmpSlice := sszSlice5[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.BlockRoots[i] = tmp + } } - // Field (20) 'FinalizedCheckpoint' - if b.FinalizedCheckpoint == nil { - b.FinalizedCheckpoint = new(Checkpoint) - } - if err = b.FinalizedCheckpoint.UnmarshalSSZ(buf[7017:7057]); err != nil { - return err - } + // Field 6: StateRoots + { + c.StateRoots = make([][]byte, 64) + for i := 0; i < 64; i++ { + var tmp []byte - // Offset (21) 'InactivityScores' - if o21 = ssz.ReadOffset(buf[7057:7061]); o21 > size || o16 > o21 { - return ssz.ErrOffset + tmpSlice := sszSlice6[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.StateRoots[i] = tmp + } } - // Field (22) 'CurrentSyncCommittee' - if b.CurrentSyncCommittee == nil { - b.CurrentSyncCommittee = new(SyncCommittee) - } - if err = b.CurrentSyncCommittee.UnmarshalSSZ(buf[7061:8645]); err != nil { - return err - } + // Field 7: HistoricalRoots + { + if len(sszSlice7)%32 != 0 { + return fmt.Errorf("misaligned bytes: c.HistoricalRoots length is %d, which is not a multiple of 32: %w", len(sszSlice7), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice7) / 32 + if numElem > 16777216 { + return fmt.Errorf("ssz-max exceeded: c.HistoricalRoots has %d elements, ssz-max is 16777216: %w", numElem, ssz.ErrListTooBig) + } + c.HistoricalRoots = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte - // Field (23) 'NextSyncCommittee' - if b.NextSyncCommittee == nil { - b.NextSyncCommittee = new(SyncCommittee) - } - if err = b.NextSyncCommittee.UnmarshalSSZ(buf[8645:10229]); err != nil { - return err + tmpSlice := sszSlice7[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.HistoricalRoots[i] = tmp + } } - // 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 8: Eth1Data + c.Eth1Data = new(Eth1Data) + if err = c.Eth1Data.UnmarshalSSZ(sszSlice8); err != nil { + return fmt.Errorf("Eth1Data: %w", err) } - // Field (9) 'Eth1DataVotes' + // Field 9: Eth1DataVotes { - buf = tail[o9:o11] - num, err := ssz.DivideInt2(len(buf), 72, 32) - if err != nil { - return err - } - b.Eth1DataVotes = make([]*Eth1Data, num) - for ii := 0; ii < num; ii++ { - if b.Eth1DataVotes[ii] == nil { - b.Eth1DataVotes[ii] = new(Eth1Data) - } - if err = b.Eth1DataVotes[ii].UnmarshalSSZ(buf[ii*72 : (ii+1)*72]); err != nil { - return err + if len(sszSlice9)%72 != 0 { + return fmt.Errorf("misaligned bytes: c.Eth1DataVotes length is %d, which is not a multiple of 72: %w", len(sszSlice9), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice9) / 72 + if numElem > 32 { + return fmt.Errorf("ssz-max exceeded: c.Eth1DataVotes has %d elements, ssz-max is 32: %w", numElem, ssz.ErrListTooBig) + } + c.Eth1DataVotes = make([]*Eth1Data, numElem) + for i := 0; i < numElem; i++ { + var tmp *Eth1Data + tmp = new(Eth1Data) + tmpSlice := sszSlice9[i*72 : (1+i)*72] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Eth1DataVotes: %w", err) } + c.Eth1DataVotes[i] = tmp } } - // Field (11) 'Validators' + // Field 10: Eth1DepositIndex + c.Eth1DepositIndex = binary.LittleEndian.Uint64(sszSlice10) + + // Field 11: Validators { - buf = tail[o11:o12] - num, err := ssz.DivideInt2(len(buf), 121, 1099511627776) - if err != nil { - return err - } - b.Validators = make([]*Validator, num) - for ii := 0; ii < num; ii++ { - if b.Validators[ii] == nil { - b.Validators[ii] = new(Validator) - } - if err = b.Validators[ii].UnmarshalSSZ(buf[ii*121 : (ii+1)*121]); err != nil { - return err + if len(sszSlice11)%121 != 0 { + return fmt.Errorf("misaligned bytes: c.Validators length is %d, which is not a multiple of 121: %w", len(sszSlice11), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice11) / 121 + if numElem > 1099511627776 { + return fmt.Errorf("ssz-max exceeded: c.Validators has %d elements, ssz-max is 1099511627776: %w", numElem, ssz.ErrListTooBig) + } + c.Validators = make([]*Validator, numElem) + for i := 0; i < numElem; i++ { + var tmp *Validator + tmp = new(Validator) + tmpSlice := sszSlice11[i*121 : (1+i)*121] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Validators: %w", err) } + c.Validators[i] = tmp } } - // Field (12) 'Balances' + // Field 12: Balances { - buf = tail[o12:o15] - num, err := ssz.DivideInt2(len(buf), 8, 1099511627776) - if err != nil { - return err + if len(sszSlice12)%8 != 0 { + return fmt.Errorf("misaligned bytes: c.Balances length is %d, which is not a multiple of 8: %w", len(sszSlice12), ssz.ErrIncorrectListSize) } - b.Balances = ssz.ExtendUint(b.Balances, num) - for ii := 0; ii < num; ii++ { - b.Balances[ii] = ssz.UnmarshallUint[uint64](buf[ii*8 : (ii+1)*8]) + numElem := len(sszSlice12) / 8 + if numElem > 1099511627776 { + return fmt.Errorf("ssz-max exceeded: c.Balances has %d elements, ssz-max is 1099511627776: %w", numElem, ssz.ErrListTooBig) } - } + c.Balances = make([]uint64, numElem) + for i := 0; i < numElem; i++ { + var tmp uint64 - // Field (15) 'PreviousEpochParticipation' - { - buf = tail[o15:o16] - if len(buf) > 1099511627776 { - return ssz.ErrBytesLength + tmpSlice := sszSlice12[i*8 : (1+i)*8] + tmp = binary.LittleEndian.Uint64(tmpSlice) + c.Balances[i] = tmp } - if cap(b.PreviousEpochParticipation) == 0 { - b.PreviousEpochParticipation = make([]byte, 0, len(buf)) - } - b.PreviousEpochParticipation = append(b.PreviousEpochParticipation, buf...) } - // Field (16) 'CurrentEpochParticipation' + // Field 13: RandaoMixes { - buf = tail[o16:o21] - if len(buf) > 1099511627776 { - return ssz.ErrBytesLength - } - if cap(b.CurrentEpochParticipation) == 0 { - b.CurrentEpochParticipation = make([]byte, 0, len(buf)) + c.RandaoMixes = make([][]byte, 64) + for i := 0; i < 64; i++ { + var tmp []byte + + tmpSlice := sszSlice13[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.RandaoMixes[i] = tmp } - b.CurrentEpochParticipation = append(b.CurrentEpochParticipation, buf...) } - // Field (21) 'InactivityScores' + // Field 14: Slashings { - buf = tail[o21:] - num, err := ssz.DivideInt2(len(buf), 8, 1099511627776) - if err != nil { - return err - } - b.InactivityScores = ssz.ExtendUint(b.InactivityScores, num) - for ii := 0; ii < num; ii++ { - b.InactivityScores[ii] = ssz.UnmarshallUint[uint64](buf[ii*8 : (ii+1)*8]) + c.Slashings = make([]uint64, 64) + for i := 0; i < 64; i++ { + var tmp uint64 + + tmpSlice := sszSlice14[i*8 : (1+i)*8] + tmp = binary.LittleEndian.Uint64(tmpSlice) + c.Slashings[i] = tmp } } - return err -} -// SizeSSZ returns the ssz encoded size in bytes for the BeaconStateAltair object -func (b *BeaconStateAltair) SizeSSZ() (size int) { - size = 10229 + // Field 15: PreviousEpochParticipation + c.PreviousEpochParticipation = append([]byte{}, sszSlice15...) - // Field (7) 'HistoricalRoots' - size += len(b.HistoricalRoots) * 32 + // Field 16: CurrentEpochParticipation + c.CurrentEpochParticipation = append([]byte{}, sszSlice16...) - // Field (9) 'Eth1DataVotes' - size += len(b.Eth1DataVotes) * 72 + // Field 17: JustificationBits + c.JustificationBits = make([]byte, 0, 1) + c.JustificationBits = append(c.JustificationBits, go_bitfield.Bitvector4(sszSlice17)...) - // 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 - - return -} + // Field 18: PreviousJustifiedCheckpoint + c.PreviousJustifiedCheckpoint = new(Checkpoint) + if err = c.PreviousJustifiedCheckpoint.UnmarshalSSZ(sszSlice18); err != nil { + return fmt.Errorf("PreviousJustifiedCheckpoint: %w", err) + } -// HashTreeRoot ssz hashes the BeaconStateAltair object -func (b *BeaconStateAltair) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) -} + // Field 19: CurrentJustifiedCheckpoint + c.CurrentJustifiedCheckpoint = new(Checkpoint) + if err = c.CurrentJustifiedCheckpoint.UnmarshalSSZ(sszSlice19); err != nil { + return fmt.Errorf("CurrentJustifiedCheckpoint: %w", err) + } -// HashTreeRootWith ssz hashes the BeaconStateAltair object with a hasher -func (b *BeaconStateAltair) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() + // Field 20: FinalizedCheckpoint + c.FinalizedCheckpoint = new(Checkpoint) + if err = c.FinalizedCheckpoint.UnmarshalSSZ(sszSlice20); err != nil { + return fmt.Errorf("FinalizedCheckpoint: %w", err) + } - // Field (0) 'GenesisTime' - ssz.PutUint(hh, b.GenesisTime) + // Field 21: InactivityScores + { + if len(sszSlice21)%8 != 0 { + return fmt.Errorf("misaligned bytes: c.InactivityScores length is %d, which is not a multiple of 8: %w", len(sszSlice21), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice21) / 8 + if numElem > 1099511627776 { + return fmt.Errorf("ssz-max exceeded: c.InactivityScores has %d elements, ssz-max is 1099511627776: %w", numElem, ssz.ErrListTooBig) + } + c.InactivityScores = make([]uint64, numElem) + for i := 0; i < numElem; i++ { + var tmp uint64 - // Field (1) 'GenesisValidatorsRoot' - if size := len(b.GenesisValidatorsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.GenesisValidatorsRoot", size, 32) - return + tmpSlice := sszSlice21[i*8 : (1+i)*8] + tmp = binary.LittleEndian.Uint64(tmpSlice) + c.InactivityScores[i] = tmp + } } - hh.PutBytes(b.GenesisValidatorsRoot) - // Field (2) 'Slot' - ssz.PutUint(hh, b.Slot) + // Field 22: CurrentSyncCommittee + c.CurrentSyncCommittee = new(SyncCommittee) + if err = c.CurrentSyncCommittee.UnmarshalSSZ(sszSlice22); err != nil { + return fmt.Errorf("CurrentSyncCommittee: %w", err) + } - // Field (3) 'Fork' - if err = b.Fork.HashTreeRootWith(hh); err != nil { - return + // Field 23: NextSyncCommittee + c.NextSyncCommittee = new(SyncCommittee) + if err = c.NextSyncCommittee.UnmarshalSSZ(sszSlice23); err != nil { + return fmt.Errorf("NextSyncCommittee: %w", err) } + return err +} - // Field (4) 'LatestBlockHeader' - if err = b.LatestBlockHeader.HashTreeRootWith(hh); err != nil { - return +func (c *BeaconStateAltair) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (5) 'BlockRoots' +func (c *BeaconStateAltair) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: GenesisTime + hh.PutUint64(c.GenesisTime) + // Field 1: GenesisValidatorsRoot + if len(c.GenesisValidatorsRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.GenesisValidatorsRoot) + // Field 2: Slot + if err := c.Slot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Slot: %w", err) + } + // Field 3: Fork + if err := c.Fork.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Fork: %w", err) + } + // Field 4: LatestBlockHeader + if err := c.LatestBlockHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("LatestBlockHeader: %w", err) + } + // Field 5: BlockRoots { - if size := len(b.BlockRoots); size != 64 { - err = ssz.ErrVectorLengthFn("--.BlockRoots", size, 64) - return + if len(c.BlockRoots) != 64 { + return ssz.ErrVectorLength } subIndx := hh.Index() - for _, i := range b.BlockRoots { - if len(i) != 32 { - err = ssz.ErrBytesLength - return + for _, o := range c.BlockRoots { + if len(o) != 32 { + return ssz.ErrBytesLength } - hh.Append(i) + hh.Append(o) } hh.Merkleize(subIndx) } - - // Field (6) 'StateRoots' + // Field 6: StateRoots { - if size := len(b.StateRoots); size != 64 { - err = ssz.ErrVectorLengthFn("--.StateRoots", size, 64) - return + if len(c.StateRoots) != 64 { + return ssz.ErrVectorLength } subIndx := hh.Index() - for _, i := range b.StateRoots { - if len(i) != 32 { - err = ssz.ErrBytesLength - return + for _, o := range c.StateRoots { + if len(o) != 32 { + return ssz.ErrBytesLength } - hh.Append(i) + hh.Append(o) } hh.Merkleize(subIndx) } - - // Field (7) 'HistoricalRoots' + // Field 7: HistoricalRoots { - if size := len(b.HistoricalRoots); size > 16777216 { - err = ssz.ErrListTooBigFn("--.HistoricalRoots", size, 16777216) - return + if len(c.HistoricalRoots) > 16777216 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range b.HistoricalRoots { - if len(i) != 32 { - err = ssz.ErrBytesLength - return + for _, o := range c.HistoricalRoots { + if len(o) != 32 { + return ssz.ErrBytesLength } - hh.Append(i) + hh.Append(o) } - - numItems := uint64(len(b.HistoricalRoots)) - hh.MerkleizeWithMixin(subIndx, numItems, 16777216) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.HistoricalRoots)), 16777216) } - - // Field (8) 'Eth1Data' - if err = b.Eth1Data.HashTreeRootWith(hh); err != nil { - return + // Field 8: Eth1Data + if err := c.Eth1Data.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Eth1Data: %w", err) } - - // Field (9) 'Eth1DataVotes' + // Field 9: Eth1DataVotes { + if len(c.Eth1DataVotes) > 32 { + return ssz.ErrListTooBig + } subIndx := hh.Index() - num := uint64(len(b.Eth1DataVotes)) - if num > 32 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range b.Eth1DataVotes { - if err = elem.HashTreeRootWith(hh); err != nil { - return + for _, o := range c.Eth1DataVotes { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Eth1DataVotes: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 32) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Eth1DataVotes)), 32) } - - // Field (10) 'Eth1DepositIndex' - ssz.PutUint(hh, b.Eth1DepositIndex) - - // Field (11) 'Validators' + // Field 10: Eth1DepositIndex + hh.PutUint64(c.Eth1DepositIndex) + // Field 11: Validators { + if len(c.Validators) > 1099511627776 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.Validators { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Validators: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 1099511627776) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Validators)), 1099511627776) } - - // Field (12) 'Balances' + // Field 12: Balances { - if size := len(b.Balances); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.Balances", size, 1099511627776) - return + if len(c.Balances) > 1099511627776 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range b.Balances { - ssz.AppendUint(hh, i) + for _, o := range c.Balances { + hh.AppendUint64(o) } hh.FillUpTo32() - - numItems := uint64(len(b.Balances)) + numItems := uint64(len(c.Balances)) hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(1099511627776, numItems, 8)) } - - // Field (13) 'RandaoMixes' + // Field 13: RandaoMixes { - if size := len(b.RandaoMixes); size != 64 { - err = ssz.ErrVectorLengthFn("--.RandaoMixes", size, 64) - return + if len(c.RandaoMixes) != 64 { + return ssz.ErrVectorLength } subIndx := hh.Index() - for _, i := range b.RandaoMixes { - if len(i) != 32 { - err = ssz.ErrBytesLength - return + for _, o := range c.RandaoMixes { + if len(o) != 32 { + return ssz.ErrBytesLength } - hh.Append(i) + hh.Append(o) } hh.Merkleize(subIndx) } - - // Field (14) 'Slashings' + // Field 14: Slashings { - if size := len(b.Slashings); size != 64 { - err = ssz.ErrVectorLengthFn("--.Slashings", size, 64) - return + if len(c.Slashings) != 64 { + return ssz.ErrVectorLength } subIndx := hh.Index() - for _, i := range b.Slashings { - ssz.AppendUint(hh, i) + for _, o := range c.Slashings { + hh.AppendUint64(o) } hh.Merkleize(subIndx) } + // Field 15: PreviousEpochParticipation - // Field (15) 'PreviousEpochParticipation' { - elemIndx := hh.Index() - byteLen := uint64(len(b.PreviousEpochParticipation)) - if byteLen > 1099511627776 { - err = ssz.ErrIncorrectListSize - return + if len(c.PreviousEpochParticipation) > 1099511627776 { + return ssz.ErrBytesLength } - hh.AppendBytes32(b.PreviousEpochParticipation) - hh.MerkleizeWithMixin(elemIndx, byteLen, (1099511627776+31)/32) + subIndx := hh.Index() + hh.AppendBytes32(c.PreviousEpochParticipation) + numItems := uint64(len(c.PreviousEpochParticipation)) + hh.MerkleizeWithMixin(subIndx, numItems, (1099511627776*1+31)/32) } - // Field (16) 'CurrentEpochParticipation' + // Field 16: CurrentEpochParticipation + { - elemIndx := hh.Index() - byteLen := uint64(len(b.CurrentEpochParticipation)) - if byteLen > 1099511627776 { - err = ssz.ErrIncorrectListSize - return + if len(c.CurrentEpochParticipation) > 1099511627776 { + return ssz.ErrBytesLength } - hh.AppendBytes32(b.CurrentEpochParticipation) - hh.MerkleizeWithMixin(elemIndx, byteLen, (1099511627776+31)/32) + subIndx := hh.Index() + hh.AppendBytes32(c.CurrentEpochParticipation) + numItems := uint64(len(c.CurrentEpochParticipation)) + hh.MerkleizeWithMixin(subIndx, numItems, (1099511627776*1+31)/32) } - // Field (17) 'JustificationBits' - if size := len(b.JustificationBits); size != 1 { - err = ssz.ErrBytesLengthFn("--.JustificationBits", size, 1) - return + // Field 17: JustificationBits + if len([]byte(c.JustificationBits)) != 1 { + return ssz.ErrBytesLength } - hh.PutBytes(b.JustificationBits) - - // Field (18) 'PreviousJustifiedCheckpoint' - if err = b.PreviousJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { - return + hh.PutBytes([]byte(c.JustificationBits)) + // Field 18: PreviousJustifiedCheckpoint + if err := c.PreviousJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("PreviousJustifiedCheckpoint: %w", err) } - - // Field (19) 'CurrentJustifiedCheckpoint' - if err = b.CurrentJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { - return + // Field 19: CurrentJustifiedCheckpoint + if err := c.CurrentJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("CurrentJustifiedCheckpoint: %w", err) } - - // Field (20) 'FinalizedCheckpoint' - if err = b.FinalizedCheckpoint.HashTreeRootWith(hh); err != nil { - return + // Field 20: FinalizedCheckpoint + if err := c.FinalizedCheckpoint.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("FinalizedCheckpoint: %w", err) } - - // Field (21) 'InactivityScores' + // Field 21: InactivityScores { - if size := len(b.InactivityScores); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.InactivityScores", size, 1099511627776) - return + if len(c.InactivityScores) > 1099511627776 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range b.InactivityScores { - ssz.AppendUint(hh, i) + for _, o := range c.InactivityScores { + hh.AppendUint64(o) } hh.FillUpTo32() + numItems := uint64(len(c.InactivityScores)) + hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(1099511627776, numItems, 8)) + } + // Field 22: CurrentSyncCommittee + if err := c.CurrentSyncCommittee.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("CurrentSyncCommittee: %w", err) + } + // Field 23: NextSyncCommittee + if err := c.NextSyncCommittee.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("NextSyncCommittee: %w", err) + } + hh.Merkleize(indx) + return nil +} + +func (c *ContributionAndProof) SizeSSZ() int { + size := 249 + + return size +} + +func (c *ContributionAndProof) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} + +func (c *ContributionAndProof) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + + // Field 0: AggregatorIndex + if dst, err = c.AggregatorIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("AggregatorIndex: %w", err) + } + + // Field 1: Contribution + if c.Contribution == nil { + c.Contribution = new(SyncCommitteeContribution) + } + if dst, err = c.Contribution.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Contribution: %w", err) + } + + // Field 2: SelectionProof + if len(c.SelectionProof) != 96 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.SelectionProof...) + + return dst, err +} + +func (c *ContributionAndProof) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 249 { + return ssz.ErrSize + } + + sszSlice0 := buf[0:8] // c.AggregatorIndex + sszSlice1 := buf[8:153] // c.Contribution + sszSlice2 := buf[153:249] // c.SelectionProof - numItems := uint64(len(b.InactivityScores)) - hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(1099511627776, numItems, 8)) + // Field 0: AggregatorIndex + if err = c.AggregatorIndex.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("AggregatorIndex: %w", err) } - // Field (22) 'CurrentSyncCommittee' - if err = b.CurrentSyncCommittee.HashTreeRootWith(hh); err != nil { - return + // Field 1: Contribution + c.Contribution = new(SyncCommitteeContribution) + if err = c.Contribution.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Contribution: %w", err) } - // Field (23) 'NextSyncCommittee' - if err = b.NextSyncCommittee.HashTreeRootWith(hh); err != nil { - return + // Field 2: SelectionProof + c.SelectionProof = make([]byte, 0, 96) + c.SelectionProof = append(c.SelectionProof, sszSlice2...) + return err +} + +func (c *ContributionAndProof) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} +func (c *ContributionAndProof) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: AggregatorIndex + if err := c.AggregatorIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("AggregatorIndex: %w", err) + } + // Field 1: Contribution + if err := c.Contribution.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Contribution: %w", err) + } + // Field 2: SelectionProof + if len(c.SelectionProof) != 96 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.SelectionProof) hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the SyncAggregatorSelectionData object -func (s *SyncAggregatorSelectionData) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) +func (c *LightClientHeaderAltair) SizeSSZ() int { + size := 112 + + return size } -// MarshalSSZTo ssz marshals the SyncAggregatorSelectionData object to a target array -func (s *SyncAggregatorSelectionData) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *LightClientHeaderAltair) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (0) 'Slot' - dst = ssz.MarshalUint(dst, s.Slot) +func (c *LightClientHeaderAltair) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (1) 'SubcommitteeIndex' - dst = ssz.MarshalUint(dst, s.SubcommitteeIndex) + // Field 0: Beacon + if c.Beacon == nil { + c.Beacon = new(BeaconBlockHeader) + } + if dst, err = c.Beacon.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Beacon: %w", err) + } - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the SyncAggregatorSelectionData object -func (s *SyncAggregatorSelectionData) UnmarshalSSZ(buf []byte) error { +func (c *LightClientHeaderAltair) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 16 { + if size != 112 { return ssz.ErrSize } - // Field (0) 'Slot' - s.Slot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[0:8]) - - // Field (1) 'SubcommitteeIndex' - s.SubcommitteeIndex = ssz.UnmarshallUint[uint64](buf[8:16]) + sszSlice0 := buf[0:112] // c.Beacon + // Field 0: Beacon + c.Beacon = new(BeaconBlockHeader) + if err = c.Beacon.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Beacon: %w", err) + } return err } -// SizeSSZ returns the ssz encoded size in bytes for the SyncAggregatorSelectionData object -func (s *SyncAggregatorSelectionData) SizeSSZ() (size int) { - size = 16 - return -} - -// HashTreeRoot ssz hashes the SyncAggregatorSelectionData object -func (s *SyncAggregatorSelectionData) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) +func (c *LightClientHeaderAltair) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the SyncAggregatorSelectionData object with a hasher -func (s *SyncAggregatorSelectionData) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *LightClientHeaderAltair) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() + // Field 0: Beacon + if err := c.Beacon.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Beacon: %w", err) + } + hh.Merkleize(indx) + return nil +} - // Field (0) 'Slot' - ssz.PutUint(hh, s.Slot) - - // Field (1) 'SubcommitteeIndex' - ssz.PutUint(hh, s.SubcommitteeIndex) +func (c *LightClientBootstrapAltair) SizeSSZ() int { + size := 1856 - hh.Merkleize(indx) - return + return size } -// MarshalSSZ ssz marshals the LightClientBootstrapAltair object -func (l *LightClientBootstrapAltair) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(l) +func (c *LightClientBootstrapAltair) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the LightClientBootstrapAltair object to a target array -func (l *LightClientBootstrapAltair) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *LightClientBootstrapAltair) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (0) 'Header' - if l.Header == nil { - l.Header = new(LightClientHeaderAltair) + // Field 0: Header + if c.Header == nil { + c.Header = new(LightClientHeaderAltair) } - if dst, err = l.Header.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.Header.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Header: %w", err) } - // Field (1) 'CurrentSyncCommittee' - if l.CurrentSyncCommittee == nil { - l.CurrentSyncCommittee = new(SyncCommittee) + // Field 1: CurrentSyncCommittee + if c.CurrentSyncCommittee == nil { + c.CurrentSyncCommittee = new(SyncCommittee) } - if dst, err = l.CurrentSyncCommittee.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.CurrentSyncCommittee.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("CurrentSyncCommittee: %w", err) } - // Field (2) 'CurrentSyncCommitteeBranch' - if size := len(l.CurrentSyncCommitteeBranch); size != 5 { - err = ssz.ErrVectorLengthFn("--.CurrentSyncCommitteeBranch", size, 5) - return + // Field 2: CurrentSyncCommitteeBranch + if len(c.CurrentSyncCommitteeBranch) != 5 { + return nil, ssz.ErrBytesLength } - for ii := 0; ii < 5; ii++ { - if size := len(l.CurrentSyncCommitteeBranch[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.CurrentSyncCommitteeBranch[ii]", size, 32) - return + for _, o := range c.CurrentSyncCommitteeBranch { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, l.CurrentSyncCommitteeBranch[ii]...) + dst = append(dst, o...) } - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the LightClientBootstrapAltair object -func (l *LightClientBootstrapAltair) UnmarshalSSZ(buf []byte) error { +func (c *LightClientBootstrapAltair) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size != 1856 { return ssz.ErrSize } - // Field (0) 'Header' - if l.Header == nil { - l.Header = new(LightClientHeaderAltair) - } - if err = l.Header.UnmarshalSSZ(buf[0:112]); err != nil { - return err - } + sszSlice0 := buf[0:112] // c.Header + sszSlice1 := buf[112:1696] // c.CurrentSyncCommittee + sszSlice2 := buf[1696:1856] // c.CurrentSyncCommitteeBranch - // Field (1) 'CurrentSyncCommittee' - if l.CurrentSyncCommittee == nil { - l.CurrentSyncCommittee = new(SyncCommittee) + // Field 0: Header + c.Header = new(LightClientHeaderAltair) + if err = c.Header.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Header: %w", err) } - if err = l.CurrentSyncCommittee.UnmarshalSSZ(buf[112:1696]); err != nil { - return err + + // Field 1: CurrentSyncCommittee + c.CurrentSyncCommittee = new(SyncCommittee) + if err = c.CurrentSyncCommittee.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("CurrentSyncCommittee: %w", err) } - // Field (2) 'CurrentSyncCommitteeBranch' - l.CurrentSyncCommitteeBranch = make([][]byte, 5) - for ii := 0; ii < 5; ii++ { - if cap(l.CurrentSyncCommitteeBranch[ii]) == 0 { - l.CurrentSyncCommitteeBranch[ii] = make([]byte, 0, len(buf[1696:1856][ii*32:(ii+1)*32])) + // Field 2: CurrentSyncCommitteeBranch + { + c.CurrentSyncCommitteeBranch = make([][]byte, 5) + for i := 0; i < 5; i++ { + var tmp []byte + + tmpSlice := sszSlice2[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.CurrentSyncCommitteeBranch[i] = tmp } - l.CurrentSyncCommitteeBranch[ii] = append(l.CurrentSyncCommitteeBranch[ii], buf[1696:1856][ii*32:(ii+1)*32]...) } - return err } -// SizeSSZ returns the ssz encoded size in bytes for the LightClientBootstrapAltair object -func (l *LightClientBootstrapAltair) SizeSSZ() (size int) { - size = 1856 - return -} - -// HashTreeRoot ssz hashes the LightClientBootstrapAltair object -func (l *LightClientBootstrapAltair) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(l) +func (c *LightClientBootstrapAltair) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the LightClientBootstrapAltair object with a hasher -func (l *LightClientBootstrapAltair) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *LightClientBootstrapAltair) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Header' - if err = l.Header.HashTreeRootWith(hh); err != nil { - return + // Field 0: Header + if err := c.Header.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Header: %w", err) } - - // Field (1) 'CurrentSyncCommittee' - if err = l.CurrentSyncCommittee.HashTreeRootWith(hh); err != nil { - return + // Field 1: CurrentSyncCommittee + if err := c.CurrentSyncCommittee.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("CurrentSyncCommittee: %w", err) } - - // Field (2) 'CurrentSyncCommitteeBranch' + // Field 2: CurrentSyncCommitteeBranch { - if size := len(l.CurrentSyncCommitteeBranch); size != 5 { - err = ssz.ErrVectorLengthFn("--.CurrentSyncCommitteeBranch", size, 5) - return + if len(c.CurrentSyncCommitteeBranch) != 5 { + return ssz.ErrVectorLength } subIndx := hh.Index() - for _, i := range l.CurrentSyncCommitteeBranch { - if len(i) != 32 { - err = ssz.ErrBytesLength - return + for _, o := range c.CurrentSyncCommitteeBranch { + if len(o) != 32 { + return ssz.ErrBytesLength } - hh.Append(i) + hh.Append(o) } hh.Merkleize(subIndx) } - hh.Merkleize(indx) - return + return nil +} + +func (c *LightClientUpdateAltair) SizeSSZ() int { + size := 2268 + + return size } -// MarshalSSZ ssz marshals the LightClientUpdateAltair object -func (l *LightClientUpdateAltair) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(l) +func (c *LightClientUpdateAltair) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the LightClientUpdateAltair object to a target array -func (l *LightClientUpdateAltair) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *LightClientUpdateAltair) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (0) 'AttestedHeader' - if l.AttestedHeader == nil { - l.AttestedHeader = new(LightClientHeaderAltair) + // Field 0: AttestedHeader + if c.AttestedHeader == nil { + c.AttestedHeader = new(LightClientHeaderAltair) } - if dst, err = l.AttestedHeader.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.AttestedHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("AttestedHeader: %w", err) } - // Field (1) 'NextSyncCommittee' - if l.NextSyncCommittee == nil { - l.NextSyncCommittee = new(SyncCommittee) + // Field 1: NextSyncCommittee + if c.NextSyncCommittee == nil { + c.NextSyncCommittee = new(SyncCommittee) } - if dst, err = l.NextSyncCommittee.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.NextSyncCommittee.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("NextSyncCommittee: %w", err) } - // Field (2) 'NextSyncCommitteeBranch' - if size := len(l.NextSyncCommitteeBranch); size != 5 { - err = ssz.ErrVectorLengthFn("--.NextSyncCommitteeBranch", size, 5) - return + // Field 2: NextSyncCommitteeBranch + if len(c.NextSyncCommitteeBranch) != 5 { + return nil, ssz.ErrBytesLength } - for ii := 0; ii < 5; ii++ { - if size := len(l.NextSyncCommitteeBranch[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.NextSyncCommitteeBranch[ii]", size, 32) - return + for _, o := range c.NextSyncCommitteeBranch { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, l.NextSyncCommitteeBranch[ii]...) + dst = append(dst, o...) } - // Field (3) 'FinalizedHeader' - if l.FinalizedHeader == nil { - l.FinalizedHeader = new(LightClientHeaderAltair) + // Field 3: FinalizedHeader + if c.FinalizedHeader == nil { + c.FinalizedHeader = new(LightClientHeaderAltair) } - if dst, err = l.FinalizedHeader.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.FinalizedHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("FinalizedHeader: %w", err) } - // Field (4) 'FinalityBranch' - if size := len(l.FinalityBranch); size != 6 { - err = ssz.ErrVectorLengthFn("--.FinalityBranch", size, 6) - return + // Field 4: FinalityBranch + if len(c.FinalityBranch) != 6 { + return nil, ssz.ErrBytesLength } - for ii := 0; ii < 6; ii++ { - if size := len(l.FinalityBranch[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.FinalityBranch[ii]", size, 32) - return + for _, o := range c.FinalityBranch { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, l.FinalityBranch[ii]...) + dst = append(dst, o...) } - // Field (5) 'SyncAggregate' - if l.SyncAggregate == nil { - l.SyncAggregate = new(SyncAggregate) + // Field 5: SyncAggregate + if c.SyncAggregate == nil { + c.SyncAggregate = new(SyncAggregate) } - if dst, err = l.SyncAggregate.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.SyncAggregate.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SyncAggregate: %w", err) } - // Field (6) 'SignatureSlot' - dst = ssz.MarshalUint(dst, l.SignatureSlot) + // Field 6: SignatureSlot + if dst, err = c.SignatureSlot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SignatureSlot: %w", err) + } - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the LightClientUpdateAltair object -func (l *LightClientUpdateAltair) UnmarshalSSZ(buf []byte) error { +func (c *LightClientUpdateAltair) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size != 2268 { return ssz.ErrSize } - // Field (0) 'AttestedHeader' - if l.AttestedHeader == nil { - l.AttestedHeader = new(LightClientHeaderAltair) - } - if err = l.AttestedHeader.UnmarshalSSZ(buf[0:112]); err != nil { - return err - } + sszSlice0 := buf[0:112] // c.AttestedHeader + sszSlice1 := buf[112:1696] // c.NextSyncCommittee + sszSlice2 := buf[1696:1856] // c.NextSyncCommitteeBranch + sszSlice3 := buf[1856:1968] // c.FinalizedHeader + sszSlice4 := buf[1968:2160] // c.FinalityBranch + sszSlice5 := buf[2160:2260] // c.SyncAggregate + sszSlice6 := buf[2260:2268] // c.SignatureSlot - // Field (1) 'NextSyncCommittee' - if l.NextSyncCommittee == nil { - l.NextSyncCommittee = new(SyncCommittee) + // Field 0: AttestedHeader + c.AttestedHeader = new(LightClientHeaderAltair) + if err = c.AttestedHeader.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("AttestedHeader: %w", err) } - if err = l.NextSyncCommittee.UnmarshalSSZ(buf[112:1696]); err != nil { - return err + + // Field 1: NextSyncCommittee + c.NextSyncCommittee = new(SyncCommittee) + if err = c.NextSyncCommittee.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("NextSyncCommittee: %w", err) } - // Field (2) 'NextSyncCommitteeBranch' - l.NextSyncCommitteeBranch = make([][]byte, 5) - for ii := 0; ii < 5; ii++ { - if cap(l.NextSyncCommitteeBranch[ii]) == 0 { - l.NextSyncCommitteeBranch[ii] = make([]byte, 0, len(buf[1696:1856][ii*32:(ii+1)*32])) + // Field 2: NextSyncCommitteeBranch + { + c.NextSyncCommitteeBranch = make([][]byte, 5) + for i := 0; i < 5; i++ { + var tmp []byte + + tmpSlice := sszSlice2[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.NextSyncCommitteeBranch[i] = tmp } - l.NextSyncCommitteeBranch[ii] = append(l.NextSyncCommitteeBranch[ii], buf[1696:1856][ii*32:(ii+1)*32]...) } - // Field (3) 'FinalizedHeader' - if l.FinalizedHeader == nil { - l.FinalizedHeader = new(LightClientHeaderAltair) - } - if err = l.FinalizedHeader.UnmarshalSSZ(buf[1856:1968]); err != nil { - return err + // Field 3: FinalizedHeader + c.FinalizedHeader = new(LightClientHeaderAltair) + if err = c.FinalizedHeader.UnmarshalSSZ(sszSlice3); err != nil { + return fmt.Errorf("FinalizedHeader: %w", err) } - // Field (4) 'FinalityBranch' - l.FinalityBranch = make([][]byte, 6) - for ii := 0; ii < 6; ii++ { - if cap(l.FinalityBranch[ii]) == 0 { - l.FinalityBranch[ii] = make([]byte, 0, len(buf[1968:2160][ii*32:(ii+1)*32])) + // Field 4: FinalityBranch + { + c.FinalityBranch = make([][]byte, 6) + for i := 0; i < 6; i++ { + var tmp []byte + + tmpSlice := sszSlice4[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.FinalityBranch[i] = tmp } - l.FinalityBranch[ii] = append(l.FinalityBranch[ii], buf[1968:2160][ii*32:(ii+1)*32]...) } - // Field (5) 'SyncAggregate' - if l.SyncAggregate == nil { - l.SyncAggregate = new(SyncAggregate) + // Field 5: SyncAggregate + c.SyncAggregate = new(SyncAggregate) + if err = c.SyncAggregate.UnmarshalSSZ(sszSlice5); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) } - if err = l.SyncAggregate.UnmarshalSSZ(buf[2160:2260]); err != nil { - return err - } - - // Field (6) 'SignatureSlot' - l.SignatureSlot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[2260:2268]) + // Field 6: SignatureSlot + if err = c.SignatureSlot.UnmarshalSSZ(sszSlice6); err != nil { + return fmt.Errorf("SignatureSlot: %w", err) + } return err } -// SizeSSZ returns the ssz encoded size in bytes for the LightClientUpdateAltair object -func (l *LightClientUpdateAltair) SizeSSZ() (size int) { - size = 2268 - return -} - -// HashTreeRoot ssz hashes the LightClientUpdateAltair object -func (l *LightClientUpdateAltair) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(l) +func (c *LightClientUpdateAltair) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the LightClientUpdateAltair object with a hasher -func (l *LightClientUpdateAltair) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *LightClientUpdateAltair) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'AttestedHeader' - if err = l.AttestedHeader.HashTreeRootWith(hh); err != nil { - return + // Field 0: AttestedHeader + if err := c.AttestedHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("AttestedHeader: %w", err) } - - // Field (1) 'NextSyncCommittee' - if err = l.NextSyncCommittee.HashTreeRootWith(hh); err != nil { - return + // Field 1: NextSyncCommittee + if err := c.NextSyncCommittee.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("NextSyncCommittee: %w", err) } - - // Field (2) 'NextSyncCommitteeBranch' + // Field 2: NextSyncCommitteeBranch { - if size := len(l.NextSyncCommitteeBranch); size != 5 { - err = ssz.ErrVectorLengthFn("--.NextSyncCommitteeBranch", size, 5) - return + if len(c.NextSyncCommitteeBranch) != 5 { + return ssz.ErrVectorLength } subIndx := hh.Index() - for _, i := range l.NextSyncCommitteeBranch { - if len(i) != 32 { - err = ssz.ErrBytesLength - return + for _, o := range c.NextSyncCommitteeBranch { + if len(o) != 32 { + return ssz.ErrBytesLength } - hh.Append(i) + hh.Append(o) } hh.Merkleize(subIndx) } - - // Field (3) 'FinalizedHeader' - if err = l.FinalizedHeader.HashTreeRootWith(hh); err != nil { - return + // Field 3: FinalizedHeader + if err := c.FinalizedHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("FinalizedHeader: %w", err) } - - // Field (4) 'FinalityBranch' + // Field 4: FinalityBranch { - if size := len(l.FinalityBranch); size != 6 { - err = ssz.ErrVectorLengthFn("--.FinalityBranch", size, 6) - return + if len(c.FinalityBranch) != 6 { + return ssz.ErrVectorLength } subIndx := hh.Index() - for _, i := range l.FinalityBranch { - if len(i) != 32 { - err = ssz.ErrBytesLength - return + for _, o := range c.FinalityBranch { + if len(o) != 32 { + return ssz.ErrBytesLength } - hh.Append(i) + hh.Append(o) } hh.Merkleize(subIndx) } - - // Field (5) 'SyncAggregate' - if err = l.SyncAggregate.HashTreeRootWith(hh); err != nil { - return + // Field 5: SyncAggregate + if err := c.SyncAggregate.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) } + // Field 6: SignatureSlot + if err := c.SignatureSlot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SignatureSlot: %w", err) + } + hh.Merkleize(indx) + return nil +} - // Field (6) 'SignatureSlot' - ssz.PutUint(hh, l.SignatureSlot) +func (c *LightClientFinalityUpdateAltair) SizeSSZ() int { + size := 524 - hh.Merkleize(indx) - return + return size } -// MarshalSSZ ssz marshals the LightClientFinalityUpdateAltair object -func (l *LightClientFinalityUpdateAltair) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(l) +func (c *LightClientFinalityUpdateAltair) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the LightClientFinalityUpdateAltair object to a target array -func (l *LightClientFinalityUpdateAltair) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *LightClientFinalityUpdateAltair) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (0) 'AttestedHeader' - if l.AttestedHeader == nil { - l.AttestedHeader = new(LightClientHeaderAltair) + // Field 0: AttestedHeader + if c.AttestedHeader == nil { + c.AttestedHeader = new(LightClientHeaderAltair) } - if dst, err = l.AttestedHeader.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.AttestedHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("AttestedHeader: %w", err) } - // Field (1) 'FinalizedHeader' - if l.FinalizedHeader == nil { - l.FinalizedHeader = new(LightClientHeaderAltair) + // Field 1: FinalizedHeader + if c.FinalizedHeader == nil { + c.FinalizedHeader = new(LightClientHeaderAltair) } - if dst, err = l.FinalizedHeader.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.FinalizedHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("FinalizedHeader: %w", err) } - // Field (2) 'FinalityBranch' - if size := len(l.FinalityBranch); size != 6 { - err = ssz.ErrVectorLengthFn("--.FinalityBranch", size, 6) - return + // Field 2: FinalityBranch + if len(c.FinalityBranch) != 6 { + return nil, ssz.ErrBytesLength } - for ii := 0; ii < 6; ii++ { - if size := len(l.FinalityBranch[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.FinalityBranch[ii]", size, 32) - return + for _, o := range c.FinalityBranch { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, l.FinalityBranch[ii]...) + dst = append(dst, o...) } - // Field (3) 'SyncAggregate' - if l.SyncAggregate == nil { - l.SyncAggregate = new(SyncAggregate) + // Field 3: SyncAggregate + if c.SyncAggregate == nil { + c.SyncAggregate = new(SyncAggregate) } - if dst, err = l.SyncAggregate.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.SyncAggregate.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SyncAggregate: %w", err) } - // Field (4) 'SignatureSlot' - dst = ssz.MarshalUint(dst, l.SignatureSlot) + // Field 4: SignatureSlot + if dst, err = c.SignatureSlot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SignatureSlot: %w", err) + } - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the LightClientFinalityUpdateAltair object -func (l *LightClientFinalityUpdateAltair) UnmarshalSSZ(buf []byte) error { +func (c *LightClientFinalityUpdateAltair) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size != 524 { return ssz.ErrSize } - // Field (0) 'AttestedHeader' - if l.AttestedHeader == nil { - l.AttestedHeader = new(LightClientHeaderAltair) - } - if err = l.AttestedHeader.UnmarshalSSZ(buf[0:112]); err != nil { - return err - } + sszSlice0 := buf[0:112] // c.AttestedHeader + sszSlice1 := buf[112:224] // c.FinalizedHeader + sszSlice2 := buf[224:416] // c.FinalityBranch + sszSlice3 := buf[416:516] // c.SyncAggregate + sszSlice4 := buf[516:524] // c.SignatureSlot - // Field (1) 'FinalizedHeader' - if l.FinalizedHeader == nil { - l.FinalizedHeader = new(LightClientHeaderAltair) + // Field 0: AttestedHeader + c.AttestedHeader = new(LightClientHeaderAltair) + if err = c.AttestedHeader.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("AttestedHeader: %w", err) } - if err = l.FinalizedHeader.UnmarshalSSZ(buf[112:224]); err != nil { - return err + + // Field 1: FinalizedHeader + c.FinalizedHeader = new(LightClientHeaderAltair) + if err = c.FinalizedHeader.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("FinalizedHeader: %w", err) } - // Field (2) 'FinalityBranch' - l.FinalityBranch = make([][]byte, 6) - for ii := 0; ii < 6; ii++ { - if cap(l.FinalityBranch[ii]) == 0 { - l.FinalityBranch[ii] = make([]byte, 0, len(buf[224:416][ii*32:(ii+1)*32])) + // Field 2: FinalityBranch + { + c.FinalityBranch = make([][]byte, 6) + for i := 0; i < 6; i++ { + var tmp []byte + + tmpSlice := sszSlice2[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.FinalityBranch[i] = tmp } - l.FinalityBranch[ii] = append(l.FinalityBranch[ii], buf[224:416][ii*32:(ii+1)*32]...) } - // Field (3) 'SyncAggregate' - if l.SyncAggregate == nil { - l.SyncAggregate = new(SyncAggregate) - } - if err = l.SyncAggregate.UnmarshalSSZ(buf[416:516]); err != nil { - return err + // Field 3: SyncAggregate + c.SyncAggregate = new(SyncAggregate) + if err = c.SyncAggregate.UnmarshalSSZ(sszSlice3); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) } - // Field (4) 'SignatureSlot' - l.SignatureSlot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[516:524]) - + // Field 4: SignatureSlot + if err = c.SignatureSlot.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("SignatureSlot: %w", err) + } return err } -// SizeSSZ returns the ssz encoded size in bytes for the LightClientFinalityUpdateAltair object -func (l *LightClientFinalityUpdateAltair) SizeSSZ() (size int) { - size = 524 - return -} - -// HashTreeRoot ssz hashes the LightClientFinalityUpdateAltair object -func (l *LightClientFinalityUpdateAltair) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(l) +func (c *LightClientFinalityUpdateAltair) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the LightClientFinalityUpdateAltair object with a hasher -func (l *LightClientFinalityUpdateAltair) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *LightClientFinalityUpdateAltair) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'AttestedHeader' - if err = l.AttestedHeader.HashTreeRootWith(hh); err != nil { - return + // Field 0: AttestedHeader + if err := c.AttestedHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("AttestedHeader: %w", err) } - - // Field (1) 'FinalizedHeader' - if err = l.FinalizedHeader.HashTreeRootWith(hh); err != nil { - return + // Field 1: FinalizedHeader + if err := c.FinalizedHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("FinalizedHeader: %w", err) } - - // Field (2) 'FinalityBranch' + // Field 2: FinalityBranch { - if size := len(l.FinalityBranch); size != 6 { - err = ssz.ErrVectorLengthFn("--.FinalityBranch", size, 6) - return + if len(c.FinalityBranch) != 6 { + return ssz.ErrVectorLength } subIndx := hh.Index() - for _, i := range l.FinalityBranch { - if len(i) != 32 { - err = ssz.ErrBytesLength - return + for _, o := range c.FinalityBranch { + if len(o) != 32 { + return ssz.ErrBytesLength } - hh.Append(i) + hh.Append(o) } hh.Merkleize(subIndx) } - - // Field (3) 'SyncAggregate' - if err = l.SyncAggregate.HashTreeRootWith(hh); err != nil { - return + // Field 3: SyncAggregate + if err := c.SyncAggregate.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) + } + // Field 4: SignatureSlot + if err := c.SignatureSlot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SignatureSlot: %w", err) } + hh.Merkleize(indx) + return nil +} - // Field (4) 'SignatureSlot' - ssz.PutUint(hh, l.SignatureSlot) +func (c *LightClientOptimisticUpdateAltair) SizeSSZ() int { + size := 220 - hh.Merkleize(indx) - return + return size } -// MarshalSSZ ssz marshals the LightClientOptimisticUpdateAltair object -func (l *LightClientOptimisticUpdateAltair) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(l) +func (c *LightClientOptimisticUpdateAltair) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the LightClientOptimisticUpdateAltair object to a target array -func (l *LightClientOptimisticUpdateAltair) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *LightClientOptimisticUpdateAltair) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (0) 'AttestedHeader' - if l.AttestedHeader == nil { - l.AttestedHeader = new(LightClientHeaderAltair) + // Field 0: AttestedHeader + if c.AttestedHeader == nil { + c.AttestedHeader = new(LightClientHeaderAltair) } - if dst, err = l.AttestedHeader.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.AttestedHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("AttestedHeader: %w", err) } - // Field (1) 'SyncAggregate' - if l.SyncAggregate == nil { - l.SyncAggregate = new(SyncAggregate) + // Field 1: SyncAggregate + if c.SyncAggregate == nil { + c.SyncAggregate = new(SyncAggregate) } - if dst, err = l.SyncAggregate.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.SyncAggregate.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SyncAggregate: %w", err) } - // Field (2) 'SignatureSlot' - dst = ssz.MarshalUint(dst, l.SignatureSlot) + // Field 2: SignatureSlot + if dst, err = c.SignatureSlot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SignatureSlot: %w", err) + } - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the LightClientOptimisticUpdateAltair object -func (l *LightClientOptimisticUpdateAltair) UnmarshalSSZ(buf []byte) error { +func (c *LightClientOptimisticUpdateAltair) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size != 220 { return ssz.ErrSize } - // Field (0) 'AttestedHeader' - if l.AttestedHeader == nil { - l.AttestedHeader = new(LightClientHeaderAltair) - } - if err = l.AttestedHeader.UnmarshalSSZ(buf[0:112]); err != nil { - return err - } + sszSlice0 := buf[0:112] // c.AttestedHeader + sszSlice1 := buf[112:212] // c.SyncAggregate + sszSlice2 := buf[212:220] // c.SignatureSlot - // Field (1) 'SyncAggregate' - if l.SyncAggregate == nil { - l.SyncAggregate = new(SyncAggregate) - } - if err = l.SyncAggregate.UnmarshalSSZ(buf[112:212]); err != nil { - return err + // Field 0: AttestedHeader + c.AttestedHeader = new(LightClientHeaderAltair) + if err = c.AttestedHeader.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("AttestedHeader: %w", err) } - // Field (2) 'SignatureSlot' - l.SignatureSlot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[212:220]) + // Field 1: SyncAggregate + c.SyncAggregate = new(SyncAggregate) + if err = c.SyncAggregate.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) + } + // Field 2: SignatureSlot + if err = c.SignatureSlot.UnmarshalSSZ(sszSlice2); err != nil { + return fmt.Errorf("SignatureSlot: %w", err) + } return err } -// SizeSSZ returns the ssz encoded size in bytes for the LightClientOptimisticUpdateAltair object -func (l *LightClientOptimisticUpdateAltair) SizeSSZ() (size int) { - size = 220 - return -} - -// HashTreeRoot ssz hashes the LightClientOptimisticUpdateAltair object -func (l *LightClientOptimisticUpdateAltair) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(l) +func (c *LightClientOptimisticUpdateAltair) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the LightClientOptimisticUpdateAltair object with a hasher -func (l *LightClientOptimisticUpdateAltair) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *LightClientOptimisticUpdateAltair) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'AttestedHeader' - if err = l.AttestedHeader.HashTreeRootWith(hh); err != nil { - return + // Field 0: AttestedHeader + if err := c.AttestedHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("AttestedHeader: %w", err) } - - // Field (1) 'SyncAggregate' - if err = l.SyncAggregate.HashTreeRootWith(hh); err != nil { - return + // Field 1: SyncAggregate + if err := c.SyncAggregate.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) + } + // Field 2: SignatureSlot + if err := c.SignatureSlot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SignatureSlot: %w", err) } - - // Field (2) 'SignatureSlot' - ssz.PutUint(hh, l.SignatureSlot) - hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the LightClientHeaderAltair object -func (l *LightClientHeaderAltair) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(l) +func (c *SignedBeaconBlockAltair) SizeSSZ() int { + size := 100 + if c.Block == nil { + c.Block = new(BeaconBlockAltair) + } + size += c.Block.SizeSSZ() + return size +} + +func (c *SignedBeaconBlockAltair) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the LightClientHeaderAltair object to a target array -func (l *LightClientHeaderAltair) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *SignedBeaconBlockAltair) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 100 - // Field (0) 'Beacon' - if l.Beacon == nil { - l.Beacon = new(BeaconBlockHeader) + // Field 0: Block + if c.Block == nil { + c.Block = new(BeaconBlockAltair) } - if dst, err = l.Beacon.MarshalSSZTo(dst); err != nil { - return + dst = ssz.WriteOffset(dst, offset) + offset += c.Block.SizeSSZ() + + // Field 1: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.Signature...) - return + // Field 0: Block + if dst, err = c.Block.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Block: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the LightClientHeaderAltair object -func (l *LightClientHeaderAltair) UnmarshalSSZ(buf []byte) error { +func (c *SignedBeaconBlockAltair) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 112 { + if size < 100 { return ssz.ErrSize } - // Field (0) 'Beacon' - if l.Beacon == nil { - l.Beacon = new(BeaconBlockHeader) + sszSlice1 := buf[4:100] // c.Signature + + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Block + if sszVarOffset0 != 100 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset0 > size { + return ssz.ErrOffset } - if err = l.Beacon.UnmarshalSSZ(buf[0:112]); err != nil { - return err + sszSlice0 := buf[sszVarOffset0:] // c.Block + + // Field 0: Block + c.Block = new(BeaconBlockAltair) + if err = c.Block.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Block: %w", err) } + // Field 1: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice1...) return err } -// SizeSSZ returns the ssz encoded size in bytes for the LightClientHeaderAltair object -func (l *LightClientHeaderAltair) SizeSSZ() (size int) { - size = 112 - return -} - -// HashTreeRoot ssz hashes the LightClientHeaderAltair object -func (l *LightClientHeaderAltair) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(l) +func (c *SignedBeaconBlockAltair) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the LightClientHeaderAltair object with a hasher -func (l *LightClientHeaderAltair) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *SignedBeaconBlockAltair) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Beacon' - if err = l.Beacon.HashTreeRootWith(hh); err != nil { - return + // Field 0: Block + if err := c.Block.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Block: %w", err) } - + // Field 1: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Signature) hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the SyncCommitteeMessage object -func (s *SyncCommitteeMessage) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) +func (c *SignedContributionAndProof) SizeSSZ() int { + size := 345 + + return size } -// MarshalSSZTo ssz marshals the SyncCommitteeMessage object to a target array -func (s *SyncCommitteeMessage) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *SignedContributionAndProof) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (0) 'Slot' - dst = ssz.MarshalUint(dst, s.Slot) +func (c *SignedContributionAndProof) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (1) 'BlockRoot' - if size := len(s.BlockRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockRoot", size, 32) - return + // Field 0: Message + if c.Message == nil { + c.Message = new(ContributionAndProof) + } + if dst, err = c.Message.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Message: %w", err) } - dst = append(dst, s.BlockRoot...) - - // Field (2) 'ValidatorIndex' - dst = ssz.MarshalUint(dst, s.ValidatorIndex) - // Field (3) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 1: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } - dst = append(dst, s.Signature...) + dst = append(dst, c.Signature...) - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the SyncCommitteeMessage object -func (s *SyncCommitteeMessage) UnmarshalSSZ(buf []byte) error { +func (c *SignedContributionAndProof) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 144 { + if size != 345 { return ssz.ErrSize } - // Field (0) 'Slot' - s.Slot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[0:8]) + sszSlice0 := buf[0:249] // c.Message + sszSlice1 := buf[249:345] // c.Signature - // Field (1) 'BlockRoot' - if cap(s.BlockRoot) == 0 { - s.BlockRoot = make([]byte, 0, len(buf[8:40])) + // Field 0: Message + c.Message = new(ContributionAndProof) + if err = c.Message.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Message: %w", err) } - s.BlockRoot = append(s.BlockRoot, buf[8:40]...) - // Field (2) 'ValidatorIndex' - s.ValidatorIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[40:48]) + // Field 1: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice1...) + return err +} - // Field (3) 'Signature' - if cap(s.Signature) == 0 { - s.Signature = make([]byte, 0, len(buf[48:144])) +func (c *SignedContributionAndProof) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - s.Signature = append(s.Signature, buf[48:144]...) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - return err +func (c *SignedContributionAndProof) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Message + if err := c.Message.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Message: %w", err) + } + // Field 1: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Signature) + hh.Merkleize(indx) + return nil } -// SizeSSZ returns the ssz encoded size in bytes for the SyncCommitteeMessage object -func (s *SyncCommitteeMessage) SizeSSZ() (size int) { - size = 144 - return +func (c *SyncAggregate) SizeSSZ() int { + size := 100 + + return size } -// HashTreeRoot ssz hashes the SyncCommitteeMessage object -func (s *SyncCommitteeMessage) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) +func (c *SyncAggregate) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// HashTreeRootWith ssz hashes the SyncCommitteeMessage object with a hasher -func (s *SyncCommitteeMessage) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() +func (c *SyncAggregate) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (0) 'Slot' - ssz.PutUint(hh, s.Slot) + // Field 0: SyncCommitteeBits + if len([]byte(c.SyncCommitteeBits)) != 4 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, []byte(c.SyncCommitteeBits)...) - // Field (1) 'BlockRoot' - if size := len(s.BlockRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockRoot", size, 32) - return + // Field 1: SyncCommitteeSignature + if len(c.SyncCommitteeSignature) != 96 { + return nil, ssz.ErrBytesLength } - hh.PutBytes(s.BlockRoot) + dst = append(dst, c.SyncCommitteeSignature...) - // Field (2) 'ValidatorIndex' - ssz.PutUint(hh, s.ValidatorIndex) + return dst, err +} - // Field (3) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return +func (c *SyncAggregate) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 100 { + return ssz.ErrSize } - hh.PutBytes(s.Signature) - hh.Merkleize(indx) - return -} + sszSlice0 := buf[0:4] // c.SyncCommitteeBits + sszSlice1 := buf[4:100] // c.SyncCommitteeSignature -// MarshalSSZ ssz marshals the SignedContributionAndProof object -func (s *SignedContributionAndProof) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) + // Field 0: SyncCommitteeBits + c.SyncCommitteeBits = make([]byte, 0, 4) + c.SyncCommitteeBits = append(c.SyncCommitteeBits, go_bitfield.Bitvector32(sszSlice0)...) + + // Field 1: SyncCommitteeSignature + c.SyncCommitteeSignature = make([]byte, 0, 96) + c.SyncCommitteeSignature = append(c.SyncCommitteeSignature, sszSlice1...) + return err } -// MarshalSSZTo ssz marshals the SignedContributionAndProof object to a target array -func (s *SignedContributionAndProof) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *SyncAggregate) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (0) 'Message' - if s.Message == nil { - s.Message = new(ContributionAndProof) +func (c *SyncAggregate) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: SyncCommitteeBits + if len([]byte(c.SyncCommitteeBits)) != 4 { + return ssz.ErrBytesLength } - if dst, err = s.Message.MarshalSSZTo(dst); err != nil { - return + hh.PutBytes([]byte(c.SyncCommitteeBits)) + // Field 1: SyncCommitteeSignature + if len(c.SyncCommitteeSignature) != 96 { + return ssz.ErrBytesLength } + hh.PutBytes(c.SyncCommitteeSignature) + hh.Merkleize(indx) + return nil +} + +func (c *SyncAggregatorSelectionData) SizeSSZ() int { + size := 16 + + return size +} + +func (c *SyncAggregatorSelectionData) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} + +func (c *SyncAggregatorSelectionData) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 0: Slot + if dst, err = c.Slot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Slot: %w", err) } - dst = append(dst, s.Signature...) - return + // Field 1: SubcommitteeIndex + dst = binary.LittleEndian.AppendUint64(dst, c.SubcommitteeIndex) + + return dst, err } -// UnmarshalSSZ ssz unmarshals the SignedContributionAndProof object -func (s *SignedContributionAndProof) UnmarshalSSZ(buf []byte) error { +func (c *SyncAggregatorSelectionData) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 345 { + if size != 16 { return ssz.ErrSize } - // Field (0) 'Message' - if s.Message == nil { - s.Message = new(ContributionAndProof) - } - if err = s.Message.UnmarshalSSZ(buf[0:249]); err != nil { - return err - } + sszSlice0 := buf[0:8] // c.Slot + sszSlice1 := buf[8:16] // c.SubcommitteeIndex - // Field (1) 'Signature' - if cap(s.Signature) == 0 { - s.Signature = make([]byte, 0, len(buf[249:345])) + // Field 0: Slot + if err = c.Slot.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Slot: %w", err) } - s.Signature = append(s.Signature, buf[249:345]...) + // Field 1: SubcommitteeIndex + c.SubcommitteeIndex = binary.LittleEndian.Uint64(sszSlice1) return err } -// SizeSSZ returns the ssz encoded size in bytes for the SignedContributionAndProof object -func (s *SignedContributionAndProof) SizeSSZ() (size int) { - size = 345 - return -} - -// HashTreeRoot ssz hashes the SignedContributionAndProof object -func (s *SignedContributionAndProof) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) +func (c *SyncAggregatorSelectionData) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the SignedContributionAndProof object with a hasher -func (s *SignedContributionAndProof) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *SyncAggregatorSelectionData) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Message' - if err = s.Message.HashTreeRootWith(hh); err != nil { - return - } - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 0: Slot + if err := c.Slot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Slot: %w", err) } - hh.PutBytes(s.Signature) - + // Field 1: SubcommitteeIndex + hh.PutUint64(c.SubcommitteeIndex) hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the ContributionAndProof object -func (c *ContributionAndProof) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(c) +func (c *SyncCommittee) SizeSSZ() int { + size := 1584 + + return size } -// MarshalSSZTo ssz marshals the ContributionAndProof object to a target array -func (c *ContributionAndProof) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *SyncCommittee) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (0) 'AggregatorIndex' - dst = ssz.MarshalUint(dst, c.AggregatorIndex) +func (c *SyncCommittee) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (1) 'Contribution' - if c.Contribution == nil { - c.Contribution = new(SyncCommitteeContribution) + // Field 0: Pubkeys + if len(c.Pubkeys) != 32 { + return nil, ssz.ErrBytesLength } - if dst, err = c.Contribution.MarshalSSZTo(dst); err != nil { - return + for _, o := range c.Pubkeys { + if len(o) != 48 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) } - // Field (2) 'SelectionProof' - if size := len(c.SelectionProof); size != 96 { - err = ssz.ErrBytesLengthFn("--.SelectionProof", size, 96) - return + // Field 1: AggregatePubkey + if len(c.AggregatePubkey) != 48 { + return nil, ssz.ErrBytesLength } - dst = append(dst, c.SelectionProof...) + dst = append(dst, c.AggregatePubkey...) - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the ContributionAndProof object -func (c *ContributionAndProof) UnmarshalSSZ(buf []byte) error { +func (c *SyncCommittee) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 249 { + if size != 1584 { return ssz.ErrSize } - // Field (0) 'AggregatorIndex' - c.AggregatorIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[0:8]) + sszSlice0 := buf[0:1536] // c.Pubkeys + sszSlice1 := buf[1536:1584] // c.AggregatePubkey - // Field (1) 'Contribution' - if c.Contribution == nil { - c.Contribution = new(SyncCommitteeContribution) - } - if err = c.Contribution.UnmarshalSSZ(buf[8:153]); err != nil { - return err - } + // Field 0: Pubkeys + { + c.Pubkeys = make([][]byte, 32) + for i := 0; i < 32; i++ { + var tmp []byte - // Field (2) 'SelectionProof' - if cap(c.SelectionProof) == 0 { - c.SelectionProof = make([]byte, 0, len(buf[153:249])) + tmpSlice := sszSlice0[i*48 : (1+i)*48] + tmp = make([]byte, 0, 48) + tmp = append(tmp, tmpSlice...) + c.Pubkeys[i] = tmp + } } - c.SelectionProof = append(c.SelectionProof, buf[153:249]...) + // Field 1: AggregatePubkey + c.AggregatePubkey = make([]byte, 0, 48) + c.AggregatePubkey = append(c.AggregatePubkey, sszSlice1...) return err } -// SizeSSZ returns the ssz encoded size in bytes for the ContributionAndProof object -func (c *ContributionAndProof) SizeSSZ() (size int) { - size = 249 - return -} - -// HashTreeRoot ssz hashes the ContributionAndProof object -func (c *ContributionAndProof) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(c) +func (c *SyncCommittee) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the ContributionAndProof object with a hasher -func (c *ContributionAndProof) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *SyncCommittee) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'AggregatorIndex' - ssz.PutUint(hh, c.AggregatorIndex) - - // Field (1) 'Contribution' - if err = c.Contribution.HashTreeRootWith(hh); err != nil { - return + // Field 0: Pubkeys + { + if len(c.Pubkeys) != 32 { + return ssz.ErrVectorLength + } + subIndx := hh.Index() + for _, o := range c.Pubkeys { + if len(o) != 48 { + return ssz.ErrBytesLength + } + hh.PutBytes(o) + } + hh.Merkleize(subIndx) } - - // Field (2) 'SelectionProof' - if size := len(c.SelectionProof); size != 96 { - err = ssz.ErrBytesLengthFn("--.SelectionProof", size, 96) - return + // Field 1: AggregatePubkey + if len(c.AggregatePubkey) != 48 { + return ssz.ErrBytesLength } - hh.PutBytes(c.SelectionProof) - + hh.PutBytes(c.AggregatePubkey) hh.Merkleize(indx) - return + return nil +} + +func (c *SyncCommitteeContribution) SizeSSZ() int { + size := 145 + + return size } -// MarshalSSZ ssz marshals the SyncCommitteeContribution object -func (s *SyncCommitteeContribution) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) +func (c *SyncCommitteeContribution) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the SyncCommitteeContribution object to a target array -func (s *SyncCommitteeContribution) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *SyncCommitteeContribution) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (0) 'Slot' - dst = ssz.MarshalUint(dst, s.Slot) + // Field 0: Slot + if dst, err = c.Slot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Slot: %w", err) + } - // Field (1) 'BlockRoot' - if size := len(s.BlockRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockRoot", size, 32) - return + // Field 1: BlockRoot + if len(c.BlockRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, s.BlockRoot...) + dst = append(dst, c.BlockRoot...) - // Field (2) 'SubcommitteeIndex' - dst = ssz.MarshalUint(dst, s.SubcommitteeIndex) + // Field 2: SubcommitteeIndex + dst = binary.LittleEndian.AppendUint64(dst, c.SubcommitteeIndex) - // Field (3) 'AggregationBits' - if size := len(s.AggregationBits); size != 1 { - err = ssz.ErrBytesLengthFn("--.AggregationBits", size, 1) - return + // Field 3: AggregationBits + if len([]byte(c.AggregationBits)) != 1 { + return nil, ssz.ErrBytesLength } - dst = append(dst, s.AggregationBits...) + dst = append(dst, []byte(c.AggregationBits)...) - // Field (4) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 4: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } - dst = append(dst, s.Signature...) + dst = append(dst, c.Signature...) - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the SyncCommitteeContribution object -func (s *SyncCommitteeContribution) UnmarshalSSZ(buf []byte) error { +func (c *SyncCommitteeContribution) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size != 145 { return ssz.ErrSize } - // Field (0) 'Slot' - s.Slot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[0:8]) + sszSlice0 := buf[0:8] // c.Slot + sszSlice1 := buf[8:40] // c.BlockRoot + sszSlice2 := buf[40:48] // c.SubcommitteeIndex + sszSlice3 := buf[48:49] // c.AggregationBits + sszSlice4 := buf[49:145] // c.Signature - // Field (1) 'BlockRoot' - if cap(s.BlockRoot) == 0 { - s.BlockRoot = make([]byte, 0, len(buf[8:40])) + // Field 0: Slot + if err = c.Slot.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Slot: %w", err) } - s.BlockRoot = append(s.BlockRoot, buf[8:40]...) - // Field (2) 'SubcommitteeIndex' - s.SubcommitteeIndex = ssz.UnmarshallUint[uint64](buf[40:48]) + // Field 1: BlockRoot + c.BlockRoot = make([]byte, 0, 32) + c.BlockRoot = append(c.BlockRoot, sszSlice1...) - // Field (3) 'AggregationBits' - if cap(s.AggregationBits) == 0 { - s.AggregationBits = make([]byte, 0, len(buf[48:49])) - } - s.AggregationBits = append(s.AggregationBits, buf[48:49]...) + // Field 2: SubcommitteeIndex + c.SubcommitteeIndex = binary.LittleEndian.Uint64(sszSlice2) - // Field (4) 'Signature' - if cap(s.Signature) == 0 { - s.Signature = make([]byte, 0, len(buf[49:145])) - } - s.Signature = append(s.Signature, buf[49:145]...) + // Field 3: AggregationBits + c.AggregationBits = make([]byte, 0, 1) + c.AggregationBits = append(c.AggregationBits, go_bitfield.Bitvector8(sszSlice3)...) + // Field 4: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice4...) return err } -// SizeSSZ returns the ssz encoded size in bytes for the SyncCommitteeContribution object -func (s *SyncCommitteeContribution) SizeSSZ() (size int) { - size = 145 - return +func (c *SyncCommitteeContribution) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} + +func (c *SyncCommitteeContribution) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Slot + if err := c.Slot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Slot: %w", err) + } + // Field 1: BlockRoot + if len(c.BlockRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.BlockRoot) + // Field 2: SubcommitteeIndex + hh.PutUint64(c.SubcommitteeIndex) + // Field 3: AggregationBits + if len([]byte(c.AggregationBits)) != 1 { + return ssz.ErrBytesLength + } + hh.PutBytes([]byte(c.AggregationBits)) + // Field 4: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Signature) + hh.Merkleize(indx) + return nil } -// HashTreeRoot ssz hashes the SyncCommitteeContribution object -func (s *SyncCommitteeContribution) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) +func (c *SyncCommitteeMessage) SizeSSZ() int { + size := 144 + + return size } -// HashTreeRootWith ssz hashes the SyncCommitteeContribution object with a hasher -func (s *SyncCommitteeContribution) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() +func (c *SyncCommitteeMessage) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} + +func (c *SyncCommitteeMessage) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + + // Field 0: Slot + if dst, err = c.Slot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Slot: %w", err) + } + + // Field 1: BlockRoot + if len(c.BlockRoot) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.BlockRoot...) + + // Field 2: ValidatorIndex + if dst, err = c.ValidatorIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ValidatorIndex: %w", err) + } + + // Field 3: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.Signature...) + + return dst, err +} + +func (c *SyncCommitteeMessage) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 144 { + return ssz.ErrSize + } - // Field (0) 'Slot' - ssz.PutUint(hh, s.Slot) + sszSlice0 := buf[0:8] // c.Slot + sszSlice1 := buf[8:40] // c.BlockRoot + sszSlice2 := buf[40:48] // c.ValidatorIndex + sszSlice3 := buf[48:144] // c.Signature - // Field (1) 'BlockRoot' - if size := len(s.BlockRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockRoot", size, 32) - return + // Field 0: Slot + if err = c.Slot.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Slot: %w", err) } - hh.PutBytes(s.BlockRoot) - // Field (2) 'SubcommitteeIndex' - ssz.PutUint(hh, s.SubcommitteeIndex) + // Field 1: BlockRoot + c.BlockRoot = make([]byte, 0, 32) + c.BlockRoot = append(c.BlockRoot, sszSlice1...) - // Field (3) 'AggregationBits' - if size := len(s.AggregationBits); size != 1 { - err = ssz.ErrBytesLengthFn("--.AggregationBits", size, 1) - return + // Field 2: ValidatorIndex + if err = c.ValidatorIndex.UnmarshalSSZ(sszSlice2); err != nil { + return fmt.Errorf("ValidatorIndex: %w", err) } - hh.PutBytes(s.AggregationBits) - // Field (4) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 3: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice3...) + return err +} + +func (c *SyncCommitteeMessage) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - hh.PutBytes(s.Signature) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} +func (c *SyncCommitteeMessage) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Slot + if err := c.Slot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Slot: %w", err) + } + // Field 1: BlockRoot + if len(c.BlockRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.BlockRoot) + // Field 2: ValidatorIndex + if err := c.ValidatorIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ValidatorIndex: %w", err) + } + // Field 3: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Signature) hh.Merkleize(indx) - return + return nil } diff --git a/proto/prysm/v1alpha1/altair.ssz.go b/proto/prysm/v1alpha1/altair.ssz.go index 9256ca31d5b0..ca5c9795e105 100644 --- a/proto/prysm/v1alpha1/altair.ssz.go +++ b/proto/prysm/v1alpha1/altair.ssz.go @@ -1,2789 +1,2740 @@ //go:build !minimal -// Code generated by fastssz. DO NOT EDIT. package eth import ( - github_com_OffchainLabs_prysm_v7_consensus_types_primitives "github.com/OffchainLabs/prysm/v7/consensus-types/primitives" - ssz "github.com/prysmaticlabs/fastssz" + binary "encoding/binary" + "fmt" + go_bitfield "github.com/OffchainLabs/go-bitfield" + ssz "github.com/OffchainLabs/methodical-ssz/ssz" ) -// MarshalSSZ ssz marshals the SignedBeaconBlockAltair object -func (s *SignedBeaconBlockAltair) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) -} - -// MarshalSSZTo ssz marshals the SignedBeaconBlockAltair object to a target array -func (s *SignedBeaconBlockAltair) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(100) - - // Offset (0) 'Block' - dst = ssz.WriteOffset(dst, offset) - if s.Block == nil { - s.Block = new(BeaconBlockAltair) - } - offset += s.Block.SizeSSZ() - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return +func (c *BeaconBlockAltair) SizeSSZ() int { + size := 84 + if c.Body == nil { + c.Body = new(BeaconBlockBodyAltair) } - dst = append(dst, s.Signature...) - - // Field (0) 'Block' - if dst, err = s.Block.MarshalSSZTo(dst); err != nil { - return - } - - return + size += c.Body.SizeSSZ() + return size } -// UnmarshalSSZ ssz unmarshals the SignedBeaconBlockAltair object -func (s *SignedBeaconBlockAltair) 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(BeaconBlockAltair) - } - if err = s.Block.UnmarshalSSZ(buf); err != nil { - return err - } - } - return err +func (c *BeaconBlockAltair) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// SizeSSZ returns the ssz encoded size in bytes for the SignedBeaconBlockAltair object -func (s *SignedBeaconBlockAltair) SizeSSZ() (size int) { - size = 100 +func (c *BeaconBlockAltair) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 84 - // Field (0) 'Block' - if s.Block == nil { - s.Block = new(BeaconBlockAltair) + // Field 0: Slot + if dst, err = c.Slot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Slot: %w", err) } - size += s.Block.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the SignedBeaconBlockAltair object -func (s *SignedBeaconBlockAltair) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) -} -// HashTreeRootWith ssz hashes the SignedBeaconBlockAltair object with a hasher -func (s *SignedBeaconBlockAltair) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'Block' - if err = s.Block.HashTreeRootWith(hh); err != nil { - return + // Field 1: ProposerIndex + if dst, err = c.ProposerIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ProposerIndex: %w", err) } - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 2: ParentRoot + if len(c.ParentRoot) != 32 { + return nil, ssz.ErrBytesLength } - hh.PutBytes(s.Signature) - - hh.Merkleize(indx) - return -} + dst = append(dst, c.ParentRoot...) -// MarshalSSZ ssz marshals the BeaconBlockAltair object -func (b *BeaconBlockAltair) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} - -// MarshalSSZTo ssz marshals the BeaconBlockAltair object to a target array -func (b *BeaconBlockAltair) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(84) - - // Field (0) 'Slot' - dst = ssz.MarshalUint(dst, b.Slot) - - // Field (1) 'ProposerIndex' - dst = ssz.MarshalUint(dst, b.ProposerIndex) - - // Field (2) 'ParentRoot' - if size := len(b.ParentRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentRoot", size, 32) - return + // Field 3: StateRoot + if len(c.StateRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.ParentRoot...) + dst = append(dst, c.StateRoot...) - // Field (3) 'StateRoot' - if size := len(b.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return + // Field 4: Body + if c.Body == nil { + c.Body = new(BeaconBlockBodyAltair) } - dst = append(dst, b.StateRoot...) - - // Offset (4) 'Body' dst = ssz.WriteOffset(dst, offset) - if b.Body == nil { - b.Body = new(BeaconBlockBodyAltair) - } - offset += b.Body.SizeSSZ() + offset += c.Body.SizeSSZ() - // Field (4) 'Body' - if dst, err = b.Body.MarshalSSZTo(dst); err != nil { - return + // Field 4: Body + if dst, err = c.Body.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Body: %w", err) } - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the BeaconBlockAltair object -func (b *BeaconBlockAltair) UnmarshalSSZ(buf []byte) error { +func (c *BeaconBlockAltair) 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.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[0:8]) - - // Field (1) 'ProposerIndex' - b.ProposerIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](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]...) + sszSlice0 := buf[0:8] // c.Slot + sszSlice1 := buf[8:16] // c.ProposerIndex + sszSlice2 := buf[16:48] // c.ParentRoot + sszSlice3 := buf[48:80] // c.StateRoot - // Field (3) 'StateRoot' - if cap(b.StateRoot) == 0 { - b.StateRoot = make([]byte, 0, len(buf[48:80])) + sszVarOffset4 := ssz.ReadOffset(buf[80:84]) // c.Body + if sszVarOffset4 != 84 { + return ssz.ErrInvalidVariableOffset } - b.StateRoot = append(b.StateRoot, buf[48:80]...) - - // Offset (4) 'Body' - if o4 = ssz.ReadOffset(buf[80:84]); o4 > size { + if sszVarOffset4 > size { return ssz.ErrOffset } + sszSlice4 := buf[sszVarOffset4:] // c.Body - if o4 != 84 { - return ssz.ErrInvalidVariableOffset + // Field 0: Slot + if err = c.Slot.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Slot: %w", err) } - // Field (4) 'Body' - { - buf = tail[o4:] - if b.Body == nil { - b.Body = new(BeaconBlockBodyAltair) - } - if err = b.Body.UnmarshalSSZ(buf); err != nil { - return err - } + // Field 1: ProposerIndex + if err = c.ProposerIndex.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("ProposerIndex: %w", err) } - return err -} -// SizeSSZ returns the ssz encoded size in bytes for the BeaconBlockAltair object -func (b *BeaconBlockAltair) SizeSSZ() (size int) { - size = 84 + // Field 2: ParentRoot + c.ParentRoot = make([]byte, 0, 32) + c.ParentRoot = append(c.ParentRoot, sszSlice2...) - // Field (4) 'Body' - if b.Body == nil { - b.Body = new(BeaconBlockBodyAltair) - } - size += b.Body.SizeSSZ() + // Field 3: StateRoot + c.StateRoot = make([]byte, 0, 32) + c.StateRoot = append(c.StateRoot, sszSlice3...) - return + // Field 4: Body + c.Body = new(BeaconBlockBodyAltair) + if err = c.Body.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("Body: %w", err) + } + return err } -// HashTreeRoot ssz hashes the BeaconBlockAltair object -func (b *BeaconBlockAltair) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) +func (c *BeaconBlockAltair) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the BeaconBlockAltair object with a hasher -func (b *BeaconBlockAltair) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *BeaconBlockAltair) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Slot' - ssz.PutUint(hh, b.Slot) - - // Field (1) 'ProposerIndex' - ssz.PutUint(hh, b.ProposerIndex) - - // Field (2) 'ParentRoot' - if size := len(b.ParentRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentRoot", size, 32) - return + // Field 0: Slot + if err := c.Slot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Slot: %w", err) } - hh.PutBytes(b.ParentRoot) - - // Field (3) 'StateRoot' - if size := len(b.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return + // Field 1: ProposerIndex + if err := c.ProposerIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ProposerIndex: %w", err) } - hh.PutBytes(b.StateRoot) - - // Field (4) 'Body' - if err = b.Body.HashTreeRootWith(hh); err != nil { - return + // Field 2: ParentRoot + if len(c.ParentRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ParentRoot) + // Field 3: StateRoot + if len(c.StateRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.StateRoot) + // Field 4: Body + if err := c.Body.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Body: %w", err) } - hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the BeaconBlockBodyAltair object -func (b *BeaconBlockBodyAltair) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) +func (c *BeaconBlockBodyAltair) SizeSSZ() int { + size := 380 + size += len(c.ProposerSlashings) * 416 + for _, o := range c.AttesterSlashings { + size += 4 + size += o.SizeSSZ() + } + for _, o := range c.Attestations { + size += 4 + size += o.SizeSSZ() + } + size += len(c.Deposits) * 1240 + size += len(c.VoluntaryExits) * 112 + return size } -// MarshalSSZTo ssz marshals the BeaconBlockBodyAltair object to a target array -func (b *BeaconBlockBodyAltair) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(380) +func (c *BeaconBlockBodyAltair) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} + +func (c *BeaconBlockBodyAltair) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 380 - // Field (0) 'RandaoReveal' - if size := len(b.RandaoReveal); size != 96 { - err = ssz.ErrBytesLengthFn("--.RandaoReveal", size, 96) - return + // Field 0: RandaoReveal + if len(c.RandaoReveal) != 96 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.RandaoReveal...) + dst = append(dst, c.RandaoReveal...) - // Field (1) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(Eth1Data) + // Field 1: Eth1Data + if c.Eth1Data == nil { + c.Eth1Data = new(Eth1Data) } - if dst, err = b.Eth1Data.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.Eth1Data.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Eth1Data: %w", err) } - // Field (2) 'Graffiti' - if size := len(b.Graffiti); size != 32 { - err = ssz.ErrBytesLengthFn("--.Graffiti", size, 32) - return + // Field 2: Graffiti + if len(c.Graffiti) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.Graffiti...) + dst = append(dst, c.Graffiti...) - // Offset (3) 'ProposerSlashings' + // Field 3: ProposerSlashings dst = ssz.WriteOffset(dst, offset) - offset += len(b.ProposerSlashings) * 416 + offset += len(c.ProposerSlashings) * 416 - // Offset (4) 'AttesterSlashings' + // Field 4: AttesterSlashings dst = ssz.WriteOffset(dst, offset) - for ii := 0; ii < len(b.AttesterSlashings); ii++ { + for _, o := range c.AttesterSlashings { offset += 4 - offset += b.AttesterSlashings[ii].SizeSSZ() + offset += o.SizeSSZ() } - // Offset (5) 'Attestations' + // Field 5: Attestations dst = ssz.WriteOffset(dst, offset) - for ii := 0; ii < len(b.Attestations); ii++ { + for _, o := range c.Attestations { offset += 4 - offset += b.Attestations[ii].SizeSSZ() + offset += o.SizeSSZ() } - // Offset (6) 'Deposits' + // Field 6: Deposits dst = ssz.WriteOffset(dst, offset) - offset += len(b.Deposits) * 1240 + offset += len(c.Deposits) * 1240 - // Offset (7) 'VoluntaryExits' + // Field 7: VoluntaryExits dst = ssz.WriteOffset(dst, offset) - offset += len(b.VoluntaryExits) * 112 + offset += len(c.VoluntaryExits) * 112 - // Field (8) 'SyncAggregate' - if b.SyncAggregate == nil { - b.SyncAggregate = new(SyncAggregate) + // Field 8: SyncAggregate + if c.SyncAggregate == nil { + c.SyncAggregate = new(SyncAggregate) } - if dst, err = b.SyncAggregate.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.SyncAggregate.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SyncAggregate: %w", err) } - // Field (3) 'ProposerSlashings' - if size := len(b.ProposerSlashings); size > 16 { - err = ssz.ErrListTooBigFn("--.ProposerSlashings", size, 16) - return + // Field 3: ProposerSlashings + if len(c.ProposerSlashings) > 16 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.ProposerSlashings); ii++ { - if dst, err = b.ProposerSlashings[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.ProposerSlashings { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ProposerSlashings: %w", err) } } - // Field (4) 'AttesterSlashings' - if size := len(b.AttesterSlashings); size > 2 { - err = ssz.ErrListTooBigFn("--.AttesterSlashings", size, 2) - return + // Field 4: AttesterSlashings + if len(c.AttesterSlashings) > 2 { + return nil, ssz.ErrListTooBig } { - offset = 4 * len(b.AttesterSlashings) - for ii := 0; ii < len(b.AttesterSlashings); ii++ { + offset = 4 * len(c.AttesterSlashings) + for _, o := range c.AttesterSlashings { dst = ssz.WriteOffset(dst, offset) - offset += b.AttesterSlashings[ii].SizeSSZ() + offset += o.SizeSSZ() } } - for ii := 0; ii < len(b.AttesterSlashings); ii++ { - if dst, err = b.AttesterSlashings[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.AttesterSlashings { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("AttesterSlashings: %w", err) } } - // Field (5) 'Attestations' - if size := len(b.Attestations); size > 128 { - err = ssz.ErrListTooBigFn("--.Attestations", size, 128) - return + // Field 5: Attestations + if len(c.Attestations) > 128 { + return nil, ssz.ErrListTooBig } { - offset = 4 * len(b.Attestations) - for ii := 0; ii < len(b.Attestations); ii++ { + offset = 4 * len(c.Attestations) + for _, o := range c.Attestations { dst = ssz.WriteOffset(dst, offset) - offset += b.Attestations[ii].SizeSSZ() + offset += o.SizeSSZ() } } - for ii := 0; ii < len(b.Attestations); ii++ { - if dst, err = b.Attestations[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.Attestations { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Attestations: %w", err) } } - // Field (6) 'Deposits' - if size := len(b.Deposits); size > 16 { - err = ssz.ErrListTooBigFn("--.Deposits", size, 16) - return + // Field 6: Deposits + if len(c.Deposits) > 16 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.Deposits); ii++ { - if dst, err = b.Deposits[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.Deposits { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Deposits: %w", err) } } - // Field (7) 'VoluntaryExits' - if size := len(b.VoluntaryExits); size > 16 { - err = ssz.ErrListTooBigFn("--.VoluntaryExits", size, 16) - return + // Field 7: VoluntaryExits + if len(c.VoluntaryExits) > 16 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.VoluntaryExits); ii++ { - if dst, err = b.VoluntaryExits[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.VoluntaryExits { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("VoluntaryExits: %w", err) } } - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the BeaconBlockBodyAltair object -func (b *BeaconBlockBodyAltair) UnmarshalSSZ(buf []byte) error { +func (c *BeaconBlockBodyAltair) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size < 380 { return ssz.ErrSize } - tail := buf - var o3, o4, o5, o6, o7 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(Eth1Data) - } - if err = b.Eth1Data.UnmarshalSSZ(buf[96:168]); err != nil { - return err - } + sszSlice0 := buf[0:96] // c.RandaoReveal + sszSlice1 := buf[96:168] // c.Eth1Data + sszSlice2 := buf[168:200] // c.Graffiti + sszSlice8 := buf[220:380] // c.SyncAggregate - // Field (2) 'Graffiti' - if cap(b.Graffiti) == 0 { - b.Graffiti = make([]byte, 0, len(buf[168:200])) + sszVarOffset3 := ssz.ReadOffset(buf[200:204]) // c.ProposerSlashings + if sszVarOffset3 != 380 { + return ssz.ErrInvalidVariableOffset } - b.Graffiti = append(b.Graffiti, buf[168:200]...) - - // Offset (3) 'ProposerSlashings' - if o3 = ssz.ReadOffset(buf[200:204]); o3 > size { + if sszVarOffset3 > size { return ssz.ErrOffset } - - if o3 != 380 { - return ssz.ErrInvalidVariableOffset - } - - // Offset (4) 'AttesterSlashings' - if o4 = ssz.ReadOffset(buf[204:208]); o4 > size || o3 > o4 { + sszVarOffset4 := ssz.ReadOffset(buf[204:208]) // c.AttesterSlashings + if sszVarOffset4 > size || sszVarOffset4 < sszVarOffset3 { return ssz.ErrOffset } - - // Offset (5) 'Attestations' - if o5 = ssz.ReadOffset(buf[208:212]); o5 > size || o4 > o5 { + sszVarOffset5 := ssz.ReadOffset(buf[208:212]) // c.Attestations + if sszVarOffset5 > size || sszVarOffset5 < sszVarOffset4 { return ssz.ErrOffset } - - // Offset (6) 'Deposits' - if o6 = ssz.ReadOffset(buf[212:216]); o6 > size || o5 > o6 { + sszVarOffset6 := ssz.ReadOffset(buf[212:216]) // c.Deposits + if sszVarOffset6 > size || sszVarOffset6 < sszVarOffset5 { return ssz.ErrOffset } - - // Offset (7) 'VoluntaryExits' - if o7 = ssz.ReadOffset(buf[216:220]); o7 > size || o6 > o7 { + sszVarOffset7 := ssz.ReadOffset(buf[216:220]) // c.VoluntaryExits + if sszVarOffset7 > size || sszVarOffset7 < sszVarOffset6 { return ssz.ErrOffset } + sszSlice3 := buf[sszVarOffset3:sszVarOffset4] // c.ProposerSlashings + sszSlice4 := buf[sszVarOffset4:sszVarOffset5] // c.AttesterSlashings + sszSlice5 := buf[sszVarOffset5:sszVarOffset6] // c.Attestations + sszSlice6 := buf[sszVarOffset6:sszVarOffset7] // c.Deposits + sszSlice7 := buf[sszVarOffset7:] // c.VoluntaryExits - // Field (8) 'SyncAggregate' - if b.SyncAggregate == nil { - b.SyncAggregate = new(SyncAggregate) - } - if err = b.SyncAggregate.UnmarshalSSZ(buf[220:380]); err != nil { - return err + // Field 0: RandaoReveal + c.RandaoReveal = make([]byte, 0, 96) + c.RandaoReveal = append(c.RandaoReveal, sszSlice0...) + + // Field 1: Eth1Data + c.Eth1Data = new(Eth1Data) + if err = c.Eth1Data.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Eth1Data: %w", err) } - // Field (3) 'ProposerSlashings' + // Field 2: Graffiti + c.Graffiti = make([]byte, 0, 32) + c.Graffiti = append(c.Graffiti, sszSlice2...) + + // Field 3: ProposerSlashings { - buf = tail[o3:o4] - num, err := ssz.DivideInt2(len(buf), 416, 16) - if err != nil { - return err - } - b.ProposerSlashings = make([]*ProposerSlashing, num) - for ii := 0; ii < num; ii++ { - if b.ProposerSlashings[ii] == nil { - b.ProposerSlashings[ii] = new(ProposerSlashing) - } - if err = b.ProposerSlashings[ii].UnmarshalSSZ(buf[ii*416 : (ii+1)*416]); err != nil { - return err + if len(sszSlice3)%416 != 0 { + return fmt.Errorf("misaligned bytes: c.ProposerSlashings length is %d, which is not a multiple of 416: %w", len(sszSlice3), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice3) / 416 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.ProposerSlashings has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.ProposerSlashings = make([]*ProposerSlashing, numElem) + for i := 0; i < numElem; i++ { + var tmp *ProposerSlashing + tmp = new(ProposerSlashing) + tmpSlice := sszSlice3[i*416 : (1+i)*416] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("ProposerSlashings: %w", err) } + c.ProposerSlashings[i] = tmp } } - // Field (4) 'AttesterSlashings' + // Field 4: AttesterSlashings { - buf = tail[o4:o5] - num, err := ssz.DecodeDynamicLength(buf, 2) - 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) + // empty lists are zero length, so make sure there is room for an offset + // before attempting to unmarshal it + if len(sszSlice4) > 3 { + startOffset := ssz.ReadOffset(sszSlice4[0:4]) + if startOffset == 0 { + return fmt.Errorf("encountered invalid offset of 0 when decoding c.AttesterSlashings") + } + if startOffset%4 != 0 { + return fmt.Errorf("misaligned list bytes: when decoding c.AttesterSlashings, end-of-list offset is %d, which is not a multiple of 4 (offset size)", startOffset) + } + listLen := startOffset / 4 + if listLen > 2 { + return fmt.Errorf("ssz-max exceeded: c.AttesterSlashings has %d elements, ssz-max is 2: %w", listLen, ssz.ErrListTooBig) + } + totalVarBytes := uint64(len(sszSlice4)) + if totalVarBytes < startOffset { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.AttesterSlashings") } - if err = b.AttesterSlashings[indx].UnmarshalSSZ(buf); err != nil { - return err + c.AttesterSlashings = make([]*AttesterSlashing, listLen) + var tmpSlice []byte + for i := uint64(0); i < listLen; i++ { + var tmp *AttesterSlashing + tmp = new(AttesterSlashing) + endOffset := totalVarBytes + if i+1 != listLen { + endOffset = ssz.ReadOffset(sszSlice4[(i+1)*4 : (i+2)*4]) + if totalVarBytes < endOffset { + return fmt.Errorf("offset %d points past the end of buffer when decoding c.AttesterSlashings", endOffset) + } + } + if endOffset < startOffset { + return fmt.Errorf("offset %d is not greater than start offset %d when decoding c.AttesterSlashings", endOffset, startOffset) + } + tmpSlice = sszSlice4[startOffset:endOffset] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("AttesterSlashings: %w", err) + } + c.AttesterSlashings[i] = tmp + startOffset = endOffset } - return nil - }) - if err != nil { - return err + } else { + if len(sszSlice4) > 0 { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.AttesterSlashings") + } + c.AttesterSlashings = make([]*AttesterSlashing, 0) } } - // Field (5) 'Attestations' + // Field 5: Attestations { - buf = tail[o5:o6] - num, err := ssz.DecodeDynamicLength(buf, 128) - 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) + // empty lists are zero length, so make sure there is room for an offset + // before attempting to unmarshal it + if len(sszSlice5) > 3 { + startOffset := ssz.ReadOffset(sszSlice5[0:4]) + if startOffset == 0 { + return fmt.Errorf("encountered invalid offset of 0 when decoding c.Attestations") + } + if startOffset%4 != 0 { + return fmt.Errorf("misaligned list bytes: when decoding c.Attestations, end-of-list offset is %d, which is not a multiple of 4 (offset size)", startOffset) + } + listLen := startOffset / 4 + if listLen > 128 { + return fmt.Errorf("ssz-max exceeded: c.Attestations has %d elements, ssz-max is 128: %w", listLen, ssz.ErrListTooBig) } - if err = b.Attestations[indx].UnmarshalSSZ(buf); err != nil { - return err + totalVarBytes := uint64(len(sszSlice5)) + if totalVarBytes < startOffset { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.Attestations") } - return nil - }) - if err != nil { - return err + c.Attestations = make([]*Attestation, listLen) + var tmpSlice []byte + for i := uint64(0); i < listLen; i++ { + var tmp *Attestation + tmp = new(Attestation) + endOffset := totalVarBytes + if i+1 != listLen { + endOffset = ssz.ReadOffset(sszSlice5[(i+1)*4 : (i+2)*4]) + if totalVarBytes < endOffset { + return fmt.Errorf("offset %d points past the end of buffer when decoding c.Attestations", endOffset) + } + } + if endOffset < startOffset { + return fmt.Errorf("offset %d is not greater than start offset %d when decoding c.Attestations", endOffset, startOffset) + } + tmpSlice = sszSlice5[startOffset:endOffset] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Attestations: %w", err) + } + c.Attestations[i] = tmp + startOffset = endOffset + } + } else { + if len(sszSlice5) > 0 { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.Attestations") + } + c.Attestations = make([]*Attestation, 0) } } - // Field (6) 'Deposits' + // Field 6: Deposits { - buf = tail[o6:o7] - num, err := ssz.DivideInt2(len(buf), 1240, 16) - if err != nil { - return err - } - b.Deposits = make([]*Deposit, num) - for ii := 0; ii < num; ii++ { - if b.Deposits[ii] == nil { - b.Deposits[ii] = new(Deposit) - } - if err = b.Deposits[ii].UnmarshalSSZ(buf[ii*1240 : (ii+1)*1240]); err != nil { - return err + if len(sszSlice6)%1240 != 0 { + return fmt.Errorf("misaligned bytes: c.Deposits length is %d, which is not a multiple of 1240: %w", len(sszSlice6), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice6) / 1240 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.Deposits has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.Deposits = make([]*Deposit, numElem) + for i := 0; i < numElem; i++ { + var tmp *Deposit + tmp = new(Deposit) + tmpSlice := sszSlice6[i*1240 : (1+i)*1240] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Deposits: %w", err) } + c.Deposits[i] = tmp } } - // Field (7) 'VoluntaryExits' + // Field 7: VoluntaryExits { - buf = tail[o7:] - num, err := ssz.DivideInt2(len(buf), 112, 16) - if err != nil { - return err - } - b.VoluntaryExits = make([]*SignedVoluntaryExit, num) - for ii := 0; ii < num; ii++ { - if b.VoluntaryExits[ii] == nil { - b.VoluntaryExits[ii] = new(SignedVoluntaryExit) - } - if err = b.VoluntaryExits[ii].UnmarshalSSZ(buf[ii*112 : (ii+1)*112]); err != nil { - return err + if len(sszSlice7)%112 != 0 { + return fmt.Errorf("misaligned bytes: c.VoluntaryExits length is %d, which is not a multiple of 112: %w", len(sszSlice7), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice7) / 112 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.VoluntaryExits has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.VoluntaryExits = make([]*SignedVoluntaryExit, numElem) + for i := 0; i < numElem; i++ { + var tmp *SignedVoluntaryExit + tmp = new(SignedVoluntaryExit) + tmpSlice := sszSlice7[i*112 : (1+i)*112] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("VoluntaryExits: %w", err) } + c.VoluntaryExits[i] = tmp } } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the BeaconBlockBodyAltair object -func (b *BeaconBlockBodyAltair) SizeSSZ() (size int) { - size = 380 - - // 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 8: SyncAggregate + c.SyncAggregate = new(SyncAggregate) + if err = c.SyncAggregate.UnmarshalSSZ(sszSlice8); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) } - - // Field (6) 'Deposits' - size += len(b.Deposits) * 1240 - - // Field (7) 'VoluntaryExits' - size += len(b.VoluntaryExits) * 112 - - return + return err } -// HashTreeRoot ssz hashes the BeaconBlockBodyAltair object -func (b *BeaconBlockBodyAltair) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) +func (c *BeaconBlockBodyAltair) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the BeaconBlockBodyAltair object with a hasher -func (b *BeaconBlockBodyAltair) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *BeaconBlockBodyAltair) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'RandaoReveal' - if size := len(b.RandaoReveal); size != 96 { - err = ssz.ErrBytesLengthFn("--.RandaoReveal", size, 96) - return + // Field 0: RandaoReveal + if len(c.RandaoReveal) != 96 { + return ssz.ErrBytesLength } - hh.PutBytes(b.RandaoReveal) - - // Field (1) 'Eth1Data' - if err = b.Eth1Data.HashTreeRootWith(hh); err != nil { - return + hh.PutBytes(c.RandaoReveal) + // Field 1: Eth1Data + if err := c.Eth1Data.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Eth1Data: %w", err) } - - // Field (2) 'Graffiti' - if size := len(b.Graffiti); size != 32 { - err = ssz.ErrBytesLengthFn("--.Graffiti", size, 32) - return + // Field 2: Graffiti + if len(c.Graffiti) != 32 { + return ssz.ErrBytesLength } - hh.PutBytes(b.Graffiti) - - // Field (3) 'ProposerSlashings' + hh.PutBytes(c.Graffiti) + // Field 3: ProposerSlashings { + if len(c.ProposerSlashings) > 16 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.ProposerSlashings { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ProposerSlashings: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.ProposerSlashings)), 16) } - - // Field (4) 'AttesterSlashings' + // Field 4: AttesterSlashings { + if len(c.AttesterSlashings) > 2 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.AttesterSlashings { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("AttesterSlashings: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 2) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.AttesterSlashings)), 2) } - - // Field (5) 'Attestations' + // Field 5: Attestations { + if len(c.Attestations) > 128 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.Attestations { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Attestations: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 128) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Attestations)), 128) } - - // Field (6) 'Deposits' + // Field 6: Deposits { + if len(c.Deposits) > 16 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.Deposits { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Deposits: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Deposits)), 16) } - - // Field (7) 'VoluntaryExits' + // Field 7: VoluntaryExits { + if len(c.VoluntaryExits) > 16 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.VoluntaryExits { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("VoluntaryExits: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.VoluntaryExits)), 16) } - - // Field (8) 'SyncAggregate' - if err = b.SyncAggregate.HashTreeRootWith(hh); err != nil { - return - } - - hh.Merkleize(indx) - return -} - -// 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) 'SyncCommitteeBits' - if size := len(s.SyncCommitteeBits); size != 64 { - err = ssz.ErrBytesLengthFn("--.SyncCommitteeBits", size, 64) - return - } - dst = append(dst, s.SyncCommitteeBits...) - - // Field (1) 'SyncCommitteeSignature' - if size := len(s.SyncCommitteeSignature); size != 96 { - err = ssz.ErrBytesLengthFn("--.SyncCommitteeSignature", size, 96) - return - } - dst = append(dst, s.SyncCommitteeSignature...) - - 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) 'SyncCommitteeBits' - if cap(s.SyncCommitteeBits) == 0 { - s.SyncCommitteeBits = make([]byte, 0, len(buf[0:64])) - } - s.SyncCommitteeBits = append(s.SyncCommitteeBits, buf[0:64]...) - - // Field (1) 'SyncCommitteeSignature' - if cap(s.SyncCommitteeSignature) == 0 { - s.SyncCommitteeSignature = make([]byte, 0, len(buf[64:160])) - } - s.SyncCommitteeSignature = append(s.SyncCommitteeSignature, 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.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'SyncCommitteeBits' - if size := len(s.SyncCommitteeBits); size != 64 { - err = ssz.ErrBytesLengthFn("--.SyncCommitteeBits", size, 64) - return - } - hh.PutBytes(s.SyncCommitteeBits) - - // Field (1) 'SyncCommitteeSignature' - if size := len(s.SyncCommitteeSignature); size != 96 { - err = ssz.ErrBytesLengthFn("--.SyncCommitteeSignature", size, 96) - return + // Field 8: SyncAggregate + if err := c.SyncAggregate.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) } - hh.PutBytes(s.SyncCommitteeSignature) - hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the SyncCommittee object -func (s *SyncCommittee) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) +func (c *BeaconStateAltair) SizeSSZ() int { + size := 2736629 + size += len(c.HistoricalRoots) * 32 + size += len(c.Eth1DataVotes) * 72 + size += len(c.Validators) * 121 + size += len(c.Balances) * 8 + size += len(c.PreviousEpochParticipation) + size += len(c.CurrentEpochParticipation) + size += len(c.InactivityScores) * 8 + return size } -// 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("--.Pubkeys", size, 512) - return - } - for ii := 0; ii < 512; ii++ { - if size := len(s.Pubkeys[ii]); size != 48 { - err = ssz.ErrBytesLengthFn("--.Pubkeys[ii]", size, 48) - return - } - dst = append(dst, s.Pubkeys[ii]...) - } - - // Field (1) 'AggregatePubkey' - if size := len(s.AggregatePubkey); size != 48 { - err = ssz.ErrBytesLengthFn("--.AggregatePubkey", size, 48) - return - } - dst = append(dst, s.AggregatePubkey...) - - return +func (c *BeaconStateAltair) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// UnmarshalSSZ ssz unmarshals the SyncCommittee object -func (s *SyncCommittee) UnmarshalSSZ(buf []byte) error { +func (c *BeaconStateAltair) MarshalSSZTo(dst []byte) ([]byte, error) { var err error - size := uint64(len(buf)) - if size != 24624 { - return ssz.ErrSize - } + offset := 2736629 - // 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 0: GenesisTime + dst = binary.LittleEndian.AppendUint64(dst, c.GenesisTime) - // Field (1) 'AggregatePubkey' - if cap(s.AggregatePubkey) == 0 { - s.AggregatePubkey = make([]byte, 0, len(buf[24576:24624])) + // Field 1: GenesisValidatorsRoot + if len(c.GenesisValidatorsRoot) != 32 { + return nil, ssz.ErrBytesLength } - s.AggregatePubkey = append(s.AggregatePubkey, buf[24576:24624]...) + dst = append(dst, c.GenesisValidatorsRoot...) - 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.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'Pubkeys' - { - if size := len(s.Pubkeys); size != 512 { - err = ssz.ErrVectorLengthFn("--.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 2: Slot + if dst, err = c.Slot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Slot: %w", err) } - // Field (1) 'AggregatePubkey' - if size := len(s.AggregatePubkey); size != 48 { - err = ssz.ErrBytesLengthFn("--.AggregatePubkey", size, 48) - return + // Field 3: Fork + if c.Fork == nil { + c.Fork = new(Fork) } - hh.PutBytes(s.AggregatePubkey) - - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the BeaconStateAltair object -func (b *BeaconStateAltair) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} - -// MarshalSSZTo ssz marshals the BeaconStateAltair object to a target array -func (b *BeaconStateAltair) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(2736629) - - // Field (0) 'GenesisTime' - dst = ssz.MarshalUint(dst, b.GenesisTime) - - // Field (1) 'GenesisValidatorsRoot' - if size := len(b.GenesisValidatorsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.GenesisValidatorsRoot", size, 32) - return + if dst, err = c.Fork.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Fork: %w", err) } - dst = append(dst, b.GenesisValidatorsRoot...) - // Field (2) 'Slot' - dst = ssz.MarshalUint(dst, b.Slot) - - // Field (3) 'Fork' - if b.Fork == nil { - b.Fork = new(Fork) + // Field 4: LatestBlockHeader + if c.LatestBlockHeader == nil { + c.LatestBlockHeader = new(BeaconBlockHeader) } - if dst, err = b.Fork.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.LatestBlockHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("LatestBlockHeader: %w", err) } - // Field (4) 'LatestBlockHeader' - if b.LatestBlockHeader == nil { - b.LatestBlockHeader = new(BeaconBlockHeader) - } - if dst, err = b.LatestBlockHeader.MarshalSSZTo(dst); err != nil { - return + // Field 5: BlockRoots + if len(c.BlockRoots) != 8192 { + return nil, ssz.ErrBytesLength } - - // Field (5) 'BlockRoots' - if size := len(b.BlockRoots); size != 8192 { - err = ssz.ErrVectorLengthFn("--.BlockRoots", size, 8192) - return - } - for ii := 0; ii < 8192; ii++ { - if size := len(b.BlockRoots[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockRoots[ii]", size, 32) - return + for _, o := range c.BlockRoots { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.BlockRoots[ii]...) + dst = append(dst, o...) } - // Field (6) 'StateRoots' - if size := len(b.StateRoots); size != 8192 { - err = ssz.ErrVectorLengthFn("--.StateRoots", size, 8192) - return + // Field 6: StateRoots + if len(c.StateRoots) != 8192 { + return nil, ssz.ErrBytesLength } - for ii := 0; ii < 8192; ii++ { - if size := len(b.StateRoots[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoots[ii]", size, 32) - return + for _, o := range c.StateRoots { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.StateRoots[ii]...) + dst = append(dst, o...) } - // Offset (7) 'HistoricalRoots' + // Field 7: HistoricalRoots dst = ssz.WriteOffset(dst, offset) - offset += len(b.HistoricalRoots) * 32 + offset += len(c.HistoricalRoots) * 32 - // Field (8) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(Eth1Data) + // Field 8: Eth1Data + if c.Eth1Data == nil { + c.Eth1Data = new(Eth1Data) } - if dst, err = b.Eth1Data.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.Eth1Data.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Eth1Data: %w", err) } - // Offset (9) 'Eth1DataVotes' + // Field 9: Eth1DataVotes dst = ssz.WriteOffset(dst, offset) - offset += len(b.Eth1DataVotes) * 72 + offset += len(c.Eth1DataVotes) * 72 - // Field (10) 'Eth1DepositIndex' - dst = ssz.MarshalUint(dst, b.Eth1DepositIndex) + // Field 10: Eth1DepositIndex + dst = binary.LittleEndian.AppendUint64(dst, c.Eth1DepositIndex) - // Offset (11) 'Validators' + // Field 11: Validators dst = ssz.WriteOffset(dst, offset) - offset += len(b.Validators) * 121 + offset += len(c.Validators) * 121 - // Offset (12) 'Balances' + // Field 12: Balances dst = ssz.WriteOffset(dst, offset) - offset += len(b.Balances) * 8 + offset += len(c.Balances) * 8 - // Field (13) 'RandaoMixes' - if size := len(b.RandaoMixes); size != 65536 { - err = ssz.ErrVectorLengthFn("--.RandaoMixes", size, 65536) - return + // Field 13: RandaoMixes + if len(c.RandaoMixes) != 65536 { + return nil, ssz.ErrBytesLength } - for ii := 0; ii < 65536; ii++ { - if size := len(b.RandaoMixes[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.RandaoMixes[ii]", size, 32) - return + for _, o := range c.RandaoMixes { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.RandaoMixes[ii]...) + dst = append(dst, o...) } - // Field (14) 'Slashings' - if size := len(b.Slashings); size != 8192 { - err = ssz.ErrVectorLengthFn("--.Slashings", size, 8192) - return + // Field 14: Slashings + if len(c.Slashings) != 8192 { + return nil, ssz.ErrBytesLength } - for ii := 0; ii < 8192; ii++ { - dst = ssz.MarshalUint(dst, b.Slashings[ii]) + for _, o := range c.Slashings { + dst = binary.LittleEndian.AppendUint64(dst, o) } - // Offset (15) 'PreviousEpochParticipation' + // Field 15: PreviousEpochParticipation dst = ssz.WriteOffset(dst, offset) - offset += len(b.PreviousEpochParticipation) + offset += len(c.PreviousEpochParticipation) - // Offset (16) 'CurrentEpochParticipation' + // Field 16: CurrentEpochParticipation dst = ssz.WriteOffset(dst, offset) - offset += len(b.CurrentEpochParticipation) + offset += len(c.CurrentEpochParticipation) - // Field (17) 'JustificationBits' - if size := len(b.JustificationBits); size != 1 { - err = ssz.ErrBytesLengthFn("--.JustificationBits", size, 1) - return + // Field 17: JustificationBits + if len([]byte(c.JustificationBits)) != 1 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.JustificationBits...) + dst = append(dst, []byte(c.JustificationBits)...) - // Field (18) 'PreviousJustifiedCheckpoint' - if b.PreviousJustifiedCheckpoint == nil { - b.PreviousJustifiedCheckpoint = new(Checkpoint) + // Field 18: PreviousJustifiedCheckpoint + if c.PreviousJustifiedCheckpoint == nil { + c.PreviousJustifiedCheckpoint = new(Checkpoint) } - if dst, err = b.PreviousJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.PreviousJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("PreviousJustifiedCheckpoint: %w", err) } - // Field (19) 'CurrentJustifiedCheckpoint' - if b.CurrentJustifiedCheckpoint == nil { - b.CurrentJustifiedCheckpoint = new(Checkpoint) + // Field 19: CurrentJustifiedCheckpoint + if c.CurrentJustifiedCheckpoint == nil { + c.CurrentJustifiedCheckpoint = new(Checkpoint) } - if dst, err = b.CurrentJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.CurrentJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("CurrentJustifiedCheckpoint: %w", err) } - // Field (20) 'FinalizedCheckpoint' - if b.FinalizedCheckpoint == nil { - b.FinalizedCheckpoint = new(Checkpoint) + // Field 20: FinalizedCheckpoint + if c.FinalizedCheckpoint == nil { + c.FinalizedCheckpoint = new(Checkpoint) } - if dst, err = b.FinalizedCheckpoint.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.FinalizedCheckpoint.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("FinalizedCheckpoint: %w", err) } - // Offset (21) 'InactivityScores' + // Field 21: InactivityScores dst = ssz.WriteOffset(dst, offset) - offset += len(b.InactivityScores) * 8 + offset += len(c.InactivityScores) * 8 - // Field (22) 'CurrentSyncCommittee' - if b.CurrentSyncCommittee == nil { - b.CurrentSyncCommittee = new(SyncCommittee) + // Field 22: CurrentSyncCommittee + if c.CurrentSyncCommittee == nil { + c.CurrentSyncCommittee = new(SyncCommittee) } - if dst, err = b.CurrentSyncCommittee.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.CurrentSyncCommittee.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("CurrentSyncCommittee: %w", err) } - // Field (23) 'NextSyncCommittee' - if b.NextSyncCommittee == nil { - b.NextSyncCommittee = new(SyncCommittee) + // Field 23: NextSyncCommittee + if c.NextSyncCommittee == nil { + c.NextSyncCommittee = new(SyncCommittee) } - if dst, err = b.NextSyncCommittee.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.NextSyncCommittee.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("NextSyncCommittee: %w", err) } - // Field (7) 'HistoricalRoots' - if size := len(b.HistoricalRoots); size > 16777216 { - err = ssz.ErrListTooBigFn("--.HistoricalRoots", size, 16777216) - return + // Field 7: HistoricalRoots + if len(c.HistoricalRoots) > 16777216 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.HistoricalRoots); ii++ { - if size := len(b.HistoricalRoots[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.HistoricalRoots[ii]", size, 32) - return + for _, o := range c.HistoricalRoots { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.HistoricalRoots[ii]...) + dst = append(dst, o...) } - // Field (9) 'Eth1DataVotes' - if size := len(b.Eth1DataVotes); size > 2048 { - err = ssz.ErrListTooBigFn("--.Eth1DataVotes", size, 2048) - return + // Field 9: Eth1DataVotes + if len(c.Eth1DataVotes) > 2048 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.Eth1DataVotes); ii++ { - if dst, err = b.Eth1DataVotes[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.Eth1DataVotes { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Eth1DataVotes: %w", err) } } - // Field (11) 'Validators' - if size := len(b.Validators); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.Validators", size, 1099511627776) - return + // Field 11: Validators + if len(c.Validators) > 1099511627776 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.Validators); ii++ { - if dst, err = b.Validators[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.Validators { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Validators: %w", err) } } - // Field (12) 'Balances' - if size := len(b.Balances); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.Balances", size, 1099511627776) - return + // Field 12: Balances + if len(c.Balances) > 1099511627776 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.Balances); ii++ { - dst = ssz.MarshalUint(dst, b.Balances[ii]) + for _, o := range c.Balances { + dst = binary.LittleEndian.AppendUint64(dst, o) } - // Field (15) 'PreviousEpochParticipation' - if size := len(b.PreviousEpochParticipation); size > 1099511627776 { - err = ssz.ErrBytesLengthFn("--.PreviousEpochParticipation", size, 1099511627776) - return + // Field 15: PreviousEpochParticipation + if len(c.PreviousEpochParticipation) > 1099511627776 { + return nil, ssz.ErrListTooBig } - dst = append(dst, b.PreviousEpochParticipation...) + dst = append(dst, c.PreviousEpochParticipation...) - // Field (16) 'CurrentEpochParticipation' - if size := len(b.CurrentEpochParticipation); size > 1099511627776 { - err = ssz.ErrBytesLengthFn("--.CurrentEpochParticipation", size, 1099511627776) - return + // Field 16: CurrentEpochParticipation + if len(c.CurrentEpochParticipation) > 1099511627776 { + return nil, ssz.ErrListTooBig } - dst = append(dst, b.CurrentEpochParticipation...) + dst = append(dst, c.CurrentEpochParticipation...) - // Field (21) 'InactivityScores' - if size := len(b.InactivityScores); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.InactivityScores", size, 1099511627776) - return + // Field 21: InactivityScores + if len(c.InactivityScores) > 1099511627776 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.InactivityScores); ii++ { - dst = ssz.MarshalUint(dst, b.InactivityScores[ii]) + for _, o := range c.InactivityScores { + dst = binary.LittleEndian.AppendUint64(dst, o) } - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the BeaconStateAltair object -func (b *BeaconStateAltair) UnmarshalSSZ(buf []byte) error { +func (c *BeaconStateAltair) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size < 2736629 { return ssz.ErrSize } - tail := buf - var o7, o9, o11, o12, o15, o16, o21 uint64 - - // Field (0) 'GenesisTime' - b.GenesisTime = ssz.UnmarshallUint[uint64](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.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[40:48]) - - // Field (3) 'Fork' - if b.Fork == nil { - b.Fork = new(Fork) - } - if err = b.Fork.UnmarshalSSZ(buf[48:64]); err != nil { - return err - } - - // Field (4) 'LatestBlockHeader' - if b.LatestBlockHeader == nil { - b.LatestBlockHeader = new(BeaconBlockHeader) - } - if err = b.LatestBlockHeader.UnmarshalSSZ(buf[64:176]); err != nil { - return err - } - - // Field (5) 'BlockRoots' - b.BlockRoots = make([][]byte, 8192) - for ii := 0; ii < 8192; ii++ { - if cap(b.BlockRoots[ii]) == 0 { - b.BlockRoots[ii] = make([]byte, 0, len(buf[176:262320][ii*32:(ii+1)*32])) - } - b.BlockRoots[ii] = append(b.BlockRoots[ii], buf[176:262320][ii*32:(ii+1)*32]...) - } - - // Field (6) 'StateRoots' - b.StateRoots = make([][]byte, 8192) - for ii := 0; ii < 8192; ii++ { - if cap(b.StateRoots[ii]) == 0 { - b.StateRoots[ii] = make([]byte, 0, len(buf[262320:524464][ii*32:(ii+1)*32])) - } - b.StateRoots[ii] = append(b.StateRoots[ii], buf[262320:524464][ii*32:(ii+1)*32]...) + sszSlice0 := buf[0:8] // c.GenesisTime + sszSlice1 := buf[8:40] // c.GenesisValidatorsRoot + sszSlice2 := buf[40:48] // c.Slot + sszSlice3 := buf[48:64] // c.Fork + sszSlice4 := buf[64:176] // c.LatestBlockHeader + sszSlice5 := buf[176:262320] // c.BlockRoots + sszSlice6 := buf[262320:524464] // c.StateRoots + sszSlice8 := buf[524468:524540] // c.Eth1Data + sszSlice10 := buf[524544:524552] // c.Eth1DepositIndex + sszSlice13 := buf[524560:2621712] // c.RandaoMixes + sszSlice14 := buf[2621712:2687248] // c.Slashings + sszSlice17 := buf[2687256:2687257] // c.JustificationBits + sszSlice18 := buf[2687257:2687297] // c.PreviousJustifiedCheckpoint + sszSlice19 := buf[2687297:2687337] // c.CurrentJustifiedCheckpoint + sszSlice20 := buf[2687337:2687377] // c.FinalizedCheckpoint + sszSlice22 := buf[2687381:2712005] // c.CurrentSyncCommittee + sszSlice23 := buf[2712005:2736629] // c.NextSyncCommittee + + sszVarOffset7 := ssz.ReadOffset(buf[524464:524468]) // c.HistoricalRoots + if sszVarOffset7 != 2736629 { + return ssz.ErrInvalidVariableOffset } - - // Offset (7) 'HistoricalRoots' - if o7 = ssz.ReadOffset(buf[524464:524468]); o7 > size { + if sszVarOffset7 > size { return ssz.ErrOffset } - - if o7 != 2736629 { - return ssz.ErrInvalidVariableOffset + sszVarOffset9 := ssz.ReadOffset(buf[524540:524544]) // c.Eth1DataVotes + if sszVarOffset9 > size || sszVarOffset9 < sszVarOffset7 { + return ssz.ErrOffset } - - // Field (8) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(Eth1Data) + sszVarOffset11 := ssz.ReadOffset(buf[524552:524556]) // c.Validators + if sszVarOffset11 > size || sszVarOffset11 < sszVarOffset9 { + return ssz.ErrOffset } - if err = b.Eth1Data.UnmarshalSSZ(buf[524468:524540]); err != nil { - return err + sszVarOffset12 := ssz.ReadOffset(buf[524556:524560]) // c.Balances + if sszVarOffset12 > size || sszVarOffset12 < sszVarOffset11 { + return ssz.ErrOffset } - - // Offset (9) 'Eth1DataVotes' - if o9 = ssz.ReadOffset(buf[524540:524544]); o9 > size || o7 > o9 { + sszVarOffset15 := ssz.ReadOffset(buf[2687248:2687252]) // c.PreviousEpochParticipation + if sszVarOffset15 > size || sszVarOffset15 < sszVarOffset12 { return ssz.ErrOffset } - - // Field (10) 'Eth1DepositIndex' - b.Eth1DepositIndex = ssz.UnmarshallUint[uint64](buf[524544:524552]) - - // Offset (11) 'Validators' - if o11 = ssz.ReadOffset(buf[524552:524556]); o11 > size || o9 > o11 { + sszVarOffset16 := ssz.ReadOffset(buf[2687252:2687256]) // c.CurrentEpochParticipation + if sszVarOffset16 > size || sszVarOffset16 < sszVarOffset15 { return ssz.ErrOffset } - - // Offset (12) 'Balances' - if o12 = ssz.ReadOffset(buf[524556:524560]); o12 > size || o11 > o12 { + sszVarOffset21 := ssz.ReadOffset(buf[2687377:2687381]) // c.InactivityScores + if sszVarOffset21 > size || sszVarOffset21 < sszVarOffset16 { return ssz.ErrOffset } + sszSlice7 := buf[sszVarOffset7:sszVarOffset9] // c.HistoricalRoots + sszSlice9 := buf[sszVarOffset9:sszVarOffset11] // c.Eth1DataVotes + sszSlice11 := buf[sszVarOffset11:sszVarOffset12] // c.Validators + sszSlice12 := buf[sszVarOffset12:sszVarOffset15] // c.Balances + sszSlice15 := buf[sszVarOffset15:sszVarOffset16] // c.PreviousEpochParticipation + sszSlice16 := buf[sszVarOffset16:sszVarOffset21] // c.CurrentEpochParticipation + sszSlice21 := buf[sszVarOffset21:] // c.InactivityScores - // 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 0: GenesisTime + c.GenesisTime = binary.LittleEndian.Uint64(sszSlice0) - // Field (14) 'Slashings' - b.Slashings = ssz.ExtendUint(b.Slashings, 8192) - for ii := 0; ii < 8192; ii++ { - b.Slashings[ii] = ssz.UnmarshallUint[uint64](buf[2621712:2687248][ii*8 : (ii+1)*8]) - } + // Field 1: GenesisValidatorsRoot + c.GenesisValidatorsRoot = make([]byte, 0, 32) + c.GenesisValidatorsRoot = append(c.GenesisValidatorsRoot, sszSlice1...) - // Offset (15) 'PreviousEpochParticipation' - if o15 = ssz.ReadOffset(buf[2687248:2687252]); o15 > size || o12 > o15 { - return ssz.ErrOffset + // Field 2: Slot + if err = c.Slot.UnmarshalSSZ(sszSlice2); err != nil { + return fmt.Errorf("Slot: %w", err) } - // Offset (16) 'CurrentEpochParticipation' - if o16 = ssz.ReadOffset(buf[2687252:2687256]); o16 > size || o15 > o16 { - return ssz.ErrOffset + // Field 3: Fork + c.Fork = new(Fork) + if err = c.Fork.UnmarshalSSZ(sszSlice3); err != nil { + return fmt.Errorf("Fork: %w", err) } - // Field (17) 'JustificationBits' - if cap(b.JustificationBits) == 0 { - b.JustificationBits = make([]byte, 0, len(buf[2687256:2687257])) + // Field 4: LatestBlockHeader + c.LatestBlockHeader = new(BeaconBlockHeader) + if err = c.LatestBlockHeader.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("LatestBlockHeader: %w", err) } - b.JustificationBits = append(b.JustificationBits, buf[2687256:2687257]...) - // Field (18) 'PreviousJustifiedCheckpoint' - if b.PreviousJustifiedCheckpoint == nil { - b.PreviousJustifiedCheckpoint = new(Checkpoint) - } - if err = b.PreviousJustifiedCheckpoint.UnmarshalSSZ(buf[2687257:2687297]); err != nil { - return err - } + // Field 5: BlockRoots + { + c.BlockRoots = make([][]byte, 8192) + for i := 0; i < 8192; i++ { + var tmp []byte - // Field (19) 'CurrentJustifiedCheckpoint' - if b.CurrentJustifiedCheckpoint == nil { - b.CurrentJustifiedCheckpoint = new(Checkpoint) - } - if err = b.CurrentJustifiedCheckpoint.UnmarshalSSZ(buf[2687297:2687337]); err != nil { - return err + tmpSlice := sszSlice5[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.BlockRoots[i] = tmp + } } - // Field (20) 'FinalizedCheckpoint' - if b.FinalizedCheckpoint == nil { - b.FinalizedCheckpoint = new(Checkpoint) - } - if err = b.FinalizedCheckpoint.UnmarshalSSZ(buf[2687337:2687377]); err != nil { - return err - } + // Field 6: StateRoots + { + c.StateRoots = make([][]byte, 8192) + for i := 0; i < 8192; i++ { + var tmp []byte - // Offset (21) 'InactivityScores' - if o21 = ssz.ReadOffset(buf[2687377:2687381]); o21 > size || o16 > o21 { - return ssz.ErrOffset + tmpSlice := sszSlice6[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.StateRoots[i] = tmp + } } - // Field (22) 'CurrentSyncCommittee' - if b.CurrentSyncCommittee == nil { - b.CurrentSyncCommittee = new(SyncCommittee) - } - if err = b.CurrentSyncCommittee.UnmarshalSSZ(buf[2687381:2712005]); err != nil { - return err - } + // Field 7: HistoricalRoots + { + if len(sszSlice7)%32 != 0 { + return fmt.Errorf("misaligned bytes: c.HistoricalRoots length is %d, which is not a multiple of 32: %w", len(sszSlice7), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice7) / 32 + if numElem > 16777216 { + return fmt.Errorf("ssz-max exceeded: c.HistoricalRoots has %d elements, ssz-max is 16777216: %w", numElem, ssz.ErrListTooBig) + } + c.HistoricalRoots = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte - // Field (23) 'NextSyncCommittee' - if b.NextSyncCommittee == nil { - b.NextSyncCommittee = new(SyncCommittee) - } - if err = b.NextSyncCommittee.UnmarshalSSZ(buf[2712005:2736629]); err != nil { - return err + tmpSlice := sszSlice7[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.HistoricalRoots[i] = tmp + } } - // 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 8: Eth1Data + c.Eth1Data = new(Eth1Data) + if err = c.Eth1Data.UnmarshalSSZ(sszSlice8); err != nil { + return fmt.Errorf("Eth1Data: %w", err) } - // Field (9) 'Eth1DataVotes' + // Field 9: Eth1DataVotes { - buf = tail[o9:o11] - num, err := ssz.DivideInt2(len(buf), 72, 2048) - if err != nil { - return err - } - b.Eth1DataVotes = make([]*Eth1Data, num) - for ii := 0; ii < num; ii++ { - if b.Eth1DataVotes[ii] == nil { - b.Eth1DataVotes[ii] = new(Eth1Data) - } - if err = b.Eth1DataVotes[ii].UnmarshalSSZ(buf[ii*72 : (ii+1)*72]); err != nil { - return err + if len(sszSlice9)%72 != 0 { + return fmt.Errorf("misaligned bytes: c.Eth1DataVotes length is %d, which is not a multiple of 72: %w", len(sszSlice9), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice9) / 72 + if numElem > 2048 { + return fmt.Errorf("ssz-max exceeded: c.Eth1DataVotes has %d elements, ssz-max is 2048: %w", numElem, ssz.ErrListTooBig) + } + c.Eth1DataVotes = make([]*Eth1Data, numElem) + for i := 0; i < numElem; i++ { + var tmp *Eth1Data + tmp = new(Eth1Data) + tmpSlice := sszSlice9[i*72 : (1+i)*72] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Eth1DataVotes: %w", err) } + c.Eth1DataVotes[i] = tmp } } - // Field (11) 'Validators' + // Field 10: Eth1DepositIndex + c.Eth1DepositIndex = binary.LittleEndian.Uint64(sszSlice10) + + // Field 11: Validators { - buf = tail[o11:o12] - num, err := ssz.DivideInt2(len(buf), 121, 1099511627776) - if err != nil { - return err - } - b.Validators = make([]*Validator, num) - for ii := 0; ii < num; ii++ { - if b.Validators[ii] == nil { - b.Validators[ii] = new(Validator) - } - if err = b.Validators[ii].UnmarshalSSZ(buf[ii*121 : (ii+1)*121]); err != nil { - return err + if len(sszSlice11)%121 != 0 { + return fmt.Errorf("misaligned bytes: c.Validators length is %d, which is not a multiple of 121: %w", len(sszSlice11), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice11) / 121 + if numElem > 1099511627776 { + return fmt.Errorf("ssz-max exceeded: c.Validators has %d elements, ssz-max is 1099511627776: %w", numElem, ssz.ErrListTooBig) + } + c.Validators = make([]*Validator, numElem) + for i := 0; i < numElem; i++ { + var tmp *Validator + tmp = new(Validator) + tmpSlice := sszSlice11[i*121 : (1+i)*121] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Validators: %w", err) } + c.Validators[i] = tmp } } - // Field (12) 'Balances' + // Field 12: Balances { - buf = tail[o12:o15] - num, err := ssz.DivideInt2(len(buf), 8, 1099511627776) - if err != nil { - return err + if len(sszSlice12)%8 != 0 { + return fmt.Errorf("misaligned bytes: c.Balances length is %d, which is not a multiple of 8: %w", len(sszSlice12), ssz.ErrIncorrectListSize) } - b.Balances = ssz.ExtendUint(b.Balances, num) - for ii := 0; ii < num; ii++ { - b.Balances[ii] = ssz.UnmarshallUint[uint64](buf[ii*8 : (ii+1)*8]) + numElem := len(sszSlice12) / 8 + if numElem > 1099511627776 { + return fmt.Errorf("ssz-max exceeded: c.Balances has %d elements, ssz-max is 1099511627776: %w", numElem, ssz.ErrListTooBig) } - } + c.Balances = make([]uint64, numElem) + for i := 0; i < numElem; i++ { + var tmp uint64 - // Field (15) 'PreviousEpochParticipation' - { - buf = tail[o15:o16] - if len(buf) > 1099511627776 { - return ssz.ErrBytesLength + tmpSlice := sszSlice12[i*8 : (1+i)*8] + tmp = binary.LittleEndian.Uint64(tmpSlice) + c.Balances[i] = tmp } - if cap(b.PreviousEpochParticipation) == 0 { - b.PreviousEpochParticipation = make([]byte, 0, len(buf)) - } - b.PreviousEpochParticipation = append(b.PreviousEpochParticipation, buf...) } - // Field (16) 'CurrentEpochParticipation' + // Field 13: RandaoMixes { - buf = tail[o16:o21] - if len(buf) > 1099511627776 { - return ssz.ErrBytesLength - } - if cap(b.CurrentEpochParticipation) == 0 { - b.CurrentEpochParticipation = make([]byte, 0, len(buf)) + c.RandaoMixes = make([][]byte, 65536) + for i := 0; i < 65536; i++ { + var tmp []byte + + tmpSlice := sszSlice13[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.RandaoMixes[i] = tmp } - b.CurrentEpochParticipation = append(b.CurrentEpochParticipation, buf...) } - // Field (21) 'InactivityScores' + // Field 14: Slashings { - buf = tail[o21:] - num, err := ssz.DivideInt2(len(buf), 8, 1099511627776) - if err != nil { - return err - } - b.InactivityScores = ssz.ExtendUint(b.InactivityScores, num) - for ii := 0; ii < num; ii++ { - b.InactivityScores[ii] = ssz.UnmarshallUint[uint64](buf[ii*8 : (ii+1)*8]) + c.Slashings = make([]uint64, 8192) + for i := 0; i < 8192; i++ { + var tmp uint64 + + tmpSlice := sszSlice14[i*8 : (1+i)*8] + tmp = binary.LittleEndian.Uint64(tmpSlice) + c.Slashings[i] = tmp } } - return err -} -// SizeSSZ returns the ssz encoded size in bytes for the BeaconStateAltair object -func (b *BeaconStateAltair) SizeSSZ() (size int) { - size = 2736629 + // Field 15: PreviousEpochParticipation + c.PreviousEpochParticipation = append([]byte{}, sszSlice15...) - // Field (7) 'HistoricalRoots' - size += len(b.HistoricalRoots) * 32 + // Field 16: CurrentEpochParticipation + c.CurrentEpochParticipation = append([]byte{}, sszSlice16...) - // Field (9) 'Eth1DataVotes' - size += len(b.Eth1DataVotes) * 72 + // Field 17: JustificationBits + c.JustificationBits = make([]byte, 0, 1) + c.JustificationBits = append(c.JustificationBits, go_bitfield.Bitvector4(sszSlice17)...) - // 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 - - return -} + // Field 18: PreviousJustifiedCheckpoint + c.PreviousJustifiedCheckpoint = new(Checkpoint) + if err = c.PreviousJustifiedCheckpoint.UnmarshalSSZ(sszSlice18); err != nil { + return fmt.Errorf("PreviousJustifiedCheckpoint: %w", err) + } -// HashTreeRoot ssz hashes the BeaconStateAltair object -func (b *BeaconStateAltair) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) -} + // Field 19: CurrentJustifiedCheckpoint + c.CurrentJustifiedCheckpoint = new(Checkpoint) + if err = c.CurrentJustifiedCheckpoint.UnmarshalSSZ(sszSlice19); err != nil { + return fmt.Errorf("CurrentJustifiedCheckpoint: %w", err) + } -// HashTreeRootWith ssz hashes the BeaconStateAltair object with a hasher -func (b *BeaconStateAltair) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() + // Field 20: FinalizedCheckpoint + c.FinalizedCheckpoint = new(Checkpoint) + if err = c.FinalizedCheckpoint.UnmarshalSSZ(sszSlice20); err != nil { + return fmt.Errorf("FinalizedCheckpoint: %w", err) + } - // Field (0) 'GenesisTime' - ssz.PutUint(hh, b.GenesisTime) + // Field 21: InactivityScores + { + if len(sszSlice21)%8 != 0 { + return fmt.Errorf("misaligned bytes: c.InactivityScores length is %d, which is not a multiple of 8: %w", len(sszSlice21), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice21) / 8 + if numElem > 1099511627776 { + return fmt.Errorf("ssz-max exceeded: c.InactivityScores has %d elements, ssz-max is 1099511627776: %w", numElem, ssz.ErrListTooBig) + } + c.InactivityScores = make([]uint64, numElem) + for i := 0; i < numElem; i++ { + var tmp uint64 - // Field (1) 'GenesisValidatorsRoot' - if size := len(b.GenesisValidatorsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.GenesisValidatorsRoot", size, 32) - return + tmpSlice := sszSlice21[i*8 : (1+i)*8] + tmp = binary.LittleEndian.Uint64(tmpSlice) + c.InactivityScores[i] = tmp + } } - hh.PutBytes(b.GenesisValidatorsRoot) - // Field (2) 'Slot' - ssz.PutUint(hh, b.Slot) + // Field 22: CurrentSyncCommittee + c.CurrentSyncCommittee = new(SyncCommittee) + if err = c.CurrentSyncCommittee.UnmarshalSSZ(sszSlice22); err != nil { + return fmt.Errorf("CurrentSyncCommittee: %w", err) + } - // Field (3) 'Fork' - if err = b.Fork.HashTreeRootWith(hh); err != nil { - return + // Field 23: NextSyncCommittee + c.NextSyncCommittee = new(SyncCommittee) + if err = c.NextSyncCommittee.UnmarshalSSZ(sszSlice23); err != nil { + return fmt.Errorf("NextSyncCommittee: %w", err) } + return err +} - // Field (4) 'LatestBlockHeader' - if err = b.LatestBlockHeader.HashTreeRootWith(hh); err != nil { - return +func (c *BeaconStateAltair) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (5) 'BlockRoots' +func (c *BeaconStateAltair) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: GenesisTime + hh.PutUint64(c.GenesisTime) + // Field 1: GenesisValidatorsRoot + if len(c.GenesisValidatorsRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.GenesisValidatorsRoot) + // Field 2: Slot + if err := c.Slot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Slot: %w", err) + } + // Field 3: Fork + if err := c.Fork.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Fork: %w", err) + } + // Field 4: LatestBlockHeader + if err := c.LatestBlockHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("LatestBlockHeader: %w", err) + } + // Field 5: BlockRoots { - if size := len(b.BlockRoots); size != 8192 { - err = ssz.ErrVectorLengthFn("--.BlockRoots", size, 8192) - return + if len(c.BlockRoots) != 8192 { + return ssz.ErrVectorLength } subIndx := hh.Index() - for _, i := range b.BlockRoots { - if len(i) != 32 { - err = ssz.ErrBytesLength - return + for _, o := range c.BlockRoots { + if len(o) != 32 { + return ssz.ErrBytesLength } - hh.Append(i) + hh.Append(o) } hh.Merkleize(subIndx) } - - // Field (6) 'StateRoots' + // Field 6: StateRoots { - if size := len(b.StateRoots); size != 8192 { - err = ssz.ErrVectorLengthFn("--.StateRoots", size, 8192) - return + if len(c.StateRoots) != 8192 { + return ssz.ErrVectorLength } subIndx := hh.Index() - for _, i := range b.StateRoots { - if len(i) != 32 { - err = ssz.ErrBytesLength - return + for _, o := range c.StateRoots { + if len(o) != 32 { + return ssz.ErrBytesLength } - hh.Append(i) + hh.Append(o) } hh.Merkleize(subIndx) } - - // Field (7) 'HistoricalRoots' + // Field 7: HistoricalRoots { - if size := len(b.HistoricalRoots); size > 16777216 { - err = ssz.ErrListTooBigFn("--.HistoricalRoots", size, 16777216) - return + if len(c.HistoricalRoots) > 16777216 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range b.HistoricalRoots { - if len(i) != 32 { - err = ssz.ErrBytesLength - return + for _, o := range c.HistoricalRoots { + if len(o) != 32 { + return ssz.ErrBytesLength } - hh.Append(i) + hh.Append(o) } - - numItems := uint64(len(b.HistoricalRoots)) - hh.MerkleizeWithMixin(subIndx, numItems, 16777216) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.HistoricalRoots)), 16777216) } - - // Field (8) 'Eth1Data' - if err = b.Eth1Data.HashTreeRootWith(hh); err != nil { - return + // Field 8: Eth1Data + if err := c.Eth1Data.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Eth1Data: %w", err) } - - // Field (9) 'Eth1DataVotes' + // Field 9: Eth1DataVotes { + if len(c.Eth1DataVotes) > 2048 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.Eth1DataVotes { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Eth1DataVotes: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 2048) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Eth1DataVotes)), 2048) } - - // Field (10) 'Eth1DepositIndex' - ssz.PutUint(hh, b.Eth1DepositIndex) - - // Field (11) 'Validators' + // Field 10: Eth1DepositIndex + hh.PutUint64(c.Eth1DepositIndex) + // Field 11: Validators { + if len(c.Validators) > 1099511627776 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.Validators { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Validators: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 1099511627776) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Validators)), 1099511627776) } - - // Field (12) 'Balances' + // Field 12: Balances { - if size := len(b.Balances); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.Balances", size, 1099511627776) - return + if len(c.Balances) > 1099511627776 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range b.Balances { - ssz.AppendUint(hh, i) + for _, o := range c.Balances { + hh.AppendUint64(o) } hh.FillUpTo32() - - numItems := uint64(len(b.Balances)) + numItems := uint64(len(c.Balances)) hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(1099511627776, numItems, 8)) } - - // Field (13) 'RandaoMixes' + // Field 13: RandaoMixes { - if size := len(b.RandaoMixes); size != 65536 { - err = ssz.ErrVectorLengthFn("--.RandaoMixes", size, 65536) - return + if len(c.RandaoMixes) != 65536 { + return ssz.ErrVectorLength } subIndx := hh.Index() - for _, i := range b.RandaoMixes { - if len(i) != 32 { - err = ssz.ErrBytesLength - return + for _, o := range c.RandaoMixes { + if len(o) != 32 { + return ssz.ErrBytesLength } - hh.Append(i) + hh.Append(o) } hh.Merkleize(subIndx) } - - // Field (14) 'Slashings' + // Field 14: Slashings { - if size := len(b.Slashings); size != 8192 { - err = ssz.ErrVectorLengthFn("--.Slashings", size, 8192) - return + if len(c.Slashings) != 8192 { + return ssz.ErrVectorLength } subIndx := hh.Index() - for _, i := range b.Slashings { - ssz.AppendUint(hh, i) + for _, o := range c.Slashings { + hh.AppendUint64(o) } hh.Merkleize(subIndx) } + // Field 15: PreviousEpochParticipation - // Field (15) 'PreviousEpochParticipation' { - elemIndx := hh.Index() - byteLen := uint64(len(b.PreviousEpochParticipation)) - if byteLen > 1099511627776 { - err = ssz.ErrIncorrectListSize - return + if len(c.PreviousEpochParticipation) > 1099511627776 { + return ssz.ErrBytesLength } - hh.AppendBytes32(b.PreviousEpochParticipation) - hh.MerkleizeWithMixin(elemIndx, byteLen, (1099511627776+31)/32) + subIndx := hh.Index() + hh.AppendBytes32(c.PreviousEpochParticipation) + numItems := uint64(len(c.PreviousEpochParticipation)) + hh.MerkleizeWithMixin(subIndx, numItems, (1099511627776*1+31)/32) } - // Field (16) 'CurrentEpochParticipation' + // Field 16: CurrentEpochParticipation + { - elemIndx := hh.Index() - byteLen := uint64(len(b.CurrentEpochParticipation)) - if byteLen > 1099511627776 { - err = ssz.ErrIncorrectListSize - return + if len(c.CurrentEpochParticipation) > 1099511627776 { + return ssz.ErrBytesLength } - hh.AppendBytes32(b.CurrentEpochParticipation) - hh.MerkleizeWithMixin(elemIndx, byteLen, (1099511627776+31)/32) + subIndx := hh.Index() + hh.AppendBytes32(c.CurrentEpochParticipation) + numItems := uint64(len(c.CurrentEpochParticipation)) + hh.MerkleizeWithMixin(subIndx, numItems, (1099511627776*1+31)/32) } - // Field (17) 'JustificationBits' - if size := len(b.JustificationBits); size != 1 { - err = ssz.ErrBytesLengthFn("--.JustificationBits", size, 1) - return + // Field 17: JustificationBits + if len([]byte(c.JustificationBits)) != 1 { + return ssz.ErrBytesLength } - hh.PutBytes(b.JustificationBits) - - // Field (18) 'PreviousJustifiedCheckpoint' - if err = b.PreviousJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { - return + hh.PutBytes([]byte(c.JustificationBits)) + // Field 18: PreviousJustifiedCheckpoint + if err := c.PreviousJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("PreviousJustifiedCheckpoint: %w", err) } - - // Field (19) 'CurrentJustifiedCheckpoint' - if err = b.CurrentJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { - return + // Field 19: CurrentJustifiedCheckpoint + if err := c.CurrentJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("CurrentJustifiedCheckpoint: %w", err) } - - // Field (20) 'FinalizedCheckpoint' - if err = b.FinalizedCheckpoint.HashTreeRootWith(hh); err != nil { - return + // Field 20: FinalizedCheckpoint + if err := c.FinalizedCheckpoint.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("FinalizedCheckpoint: %w", err) } - - // Field (21) 'InactivityScores' + // Field 21: InactivityScores { - if size := len(b.InactivityScores); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.InactivityScores", size, 1099511627776) - return + if len(c.InactivityScores) > 1099511627776 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range b.InactivityScores { - ssz.AppendUint(hh, i) + for _, o := range c.InactivityScores { + hh.AppendUint64(o) } hh.FillUpTo32() + numItems := uint64(len(c.InactivityScores)) + hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(1099511627776, numItems, 8)) + } + // Field 22: CurrentSyncCommittee + if err := c.CurrentSyncCommittee.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("CurrentSyncCommittee: %w", err) + } + // Field 23: NextSyncCommittee + if err := c.NextSyncCommittee.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("NextSyncCommittee: %w", err) + } + hh.Merkleize(indx) + return nil +} + +func (c *ContributionAndProof) SizeSSZ() int { + size := 264 + + return size +} + +func (c *ContributionAndProof) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} + +func (c *ContributionAndProof) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + + // Field 0: AggregatorIndex + if dst, err = c.AggregatorIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("AggregatorIndex: %w", err) + } + + // Field 1: Contribution + if c.Contribution == nil { + c.Contribution = new(SyncCommitteeContribution) + } + if dst, err = c.Contribution.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Contribution: %w", err) + } + + // Field 2: SelectionProof + if len(c.SelectionProof) != 96 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.SelectionProof...) + + return dst, err +} + +func (c *ContributionAndProof) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 264 { + return ssz.ErrSize + } + + sszSlice0 := buf[0:8] // c.AggregatorIndex + sszSlice1 := buf[8:168] // c.Contribution + sszSlice2 := buf[168:264] // c.SelectionProof - numItems := uint64(len(b.InactivityScores)) - hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(1099511627776, numItems, 8)) + // Field 0: AggregatorIndex + if err = c.AggregatorIndex.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("AggregatorIndex: %w", err) } - // Field (22) 'CurrentSyncCommittee' - if err = b.CurrentSyncCommittee.HashTreeRootWith(hh); err != nil { - return + // Field 1: Contribution + c.Contribution = new(SyncCommitteeContribution) + if err = c.Contribution.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Contribution: %w", err) } - // Field (23) 'NextSyncCommittee' - if err = b.NextSyncCommittee.HashTreeRootWith(hh); err != nil { - return + // Field 2: SelectionProof + c.SelectionProof = make([]byte, 0, 96) + c.SelectionProof = append(c.SelectionProof, sszSlice2...) + return err +} + +func (c *ContributionAndProof) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} +func (c *ContributionAndProof) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: AggregatorIndex + if err := c.AggregatorIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("AggregatorIndex: %w", err) + } + // Field 1: Contribution + if err := c.Contribution.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Contribution: %w", err) + } + // Field 2: SelectionProof + if len(c.SelectionProof) != 96 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.SelectionProof) hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the SyncAggregatorSelectionData object -func (s *SyncAggregatorSelectionData) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) +func (c *LightClientHeaderAltair) SizeSSZ() int { + size := 112 + + return size } -// MarshalSSZTo ssz marshals the SyncAggregatorSelectionData object to a target array -func (s *SyncAggregatorSelectionData) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *LightClientHeaderAltair) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (0) 'Slot' - dst = ssz.MarshalUint(dst, s.Slot) +func (c *LightClientHeaderAltair) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (1) 'SubcommitteeIndex' - dst = ssz.MarshalUint(dst, s.SubcommitteeIndex) + // Field 0: Beacon + if c.Beacon == nil { + c.Beacon = new(BeaconBlockHeader) + } + if dst, err = c.Beacon.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Beacon: %w", err) + } - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the SyncAggregatorSelectionData object -func (s *SyncAggregatorSelectionData) UnmarshalSSZ(buf []byte) error { +func (c *LightClientHeaderAltair) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 16 { + if size != 112 { return ssz.ErrSize } - // Field (0) 'Slot' - s.Slot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[0:8]) - - // Field (1) 'SubcommitteeIndex' - s.SubcommitteeIndex = ssz.UnmarshallUint[uint64](buf[8:16]) + sszSlice0 := buf[0:112] // c.Beacon + // Field 0: Beacon + c.Beacon = new(BeaconBlockHeader) + if err = c.Beacon.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Beacon: %w", err) + } return err } -// SizeSSZ returns the ssz encoded size in bytes for the SyncAggregatorSelectionData object -func (s *SyncAggregatorSelectionData) SizeSSZ() (size int) { - size = 16 - return -} - -// HashTreeRoot ssz hashes the SyncAggregatorSelectionData object -func (s *SyncAggregatorSelectionData) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) +func (c *LightClientHeaderAltair) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the SyncAggregatorSelectionData object with a hasher -func (s *SyncAggregatorSelectionData) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *LightClientHeaderAltair) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() + // Field 0: Beacon + if err := c.Beacon.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Beacon: %w", err) + } + hh.Merkleize(indx) + return nil +} - // Field (0) 'Slot' - ssz.PutUint(hh, s.Slot) - - // Field (1) 'SubcommitteeIndex' - ssz.PutUint(hh, s.SubcommitteeIndex) +func (c *LightClientBootstrapAltair) SizeSSZ() int { + size := 24896 - hh.Merkleize(indx) - return + return size } -// MarshalSSZ ssz marshals the LightClientBootstrapAltair object -func (l *LightClientBootstrapAltair) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(l) +func (c *LightClientBootstrapAltair) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the LightClientBootstrapAltair object to a target array -func (l *LightClientBootstrapAltair) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *LightClientBootstrapAltair) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (0) 'Header' - if l.Header == nil { - l.Header = new(LightClientHeaderAltair) + // Field 0: Header + if c.Header == nil { + c.Header = new(LightClientHeaderAltair) } - if dst, err = l.Header.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.Header.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Header: %w", err) } - // Field (1) 'CurrentSyncCommittee' - if l.CurrentSyncCommittee == nil { - l.CurrentSyncCommittee = new(SyncCommittee) + // Field 1: CurrentSyncCommittee + if c.CurrentSyncCommittee == nil { + c.CurrentSyncCommittee = new(SyncCommittee) } - if dst, err = l.CurrentSyncCommittee.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.CurrentSyncCommittee.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("CurrentSyncCommittee: %w", err) } - // Field (2) 'CurrentSyncCommitteeBranch' - if size := len(l.CurrentSyncCommitteeBranch); size != 5 { - err = ssz.ErrVectorLengthFn("--.CurrentSyncCommitteeBranch", size, 5) - return + // Field 2: CurrentSyncCommitteeBranch + if len(c.CurrentSyncCommitteeBranch) != 5 { + return nil, ssz.ErrBytesLength } - for ii := 0; ii < 5; ii++ { - if size := len(l.CurrentSyncCommitteeBranch[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.CurrentSyncCommitteeBranch[ii]", size, 32) - return + for _, o := range c.CurrentSyncCommitteeBranch { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, l.CurrentSyncCommitteeBranch[ii]...) + dst = append(dst, o...) } - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the LightClientBootstrapAltair object -func (l *LightClientBootstrapAltair) UnmarshalSSZ(buf []byte) error { +func (c *LightClientBootstrapAltair) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size != 24896 { return ssz.ErrSize } - // Field (0) 'Header' - if l.Header == nil { - l.Header = new(LightClientHeaderAltair) - } - if err = l.Header.UnmarshalSSZ(buf[0:112]); err != nil { - return err - } + sszSlice0 := buf[0:112] // c.Header + sszSlice1 := buf[112:24736] // c.CurrentSyncCommittee + sszSlice2 := buf[24736:24896] // c.CurrentSyncCommitteeBranch - // Field (1) 'CurrentSyncCommittee' - if l.CurrentSyncCommittee == nil { - l.CurrentSyncCommittee = new(SyncCommittee) + // Field 0: Header + c.Header = new(LightClientHeaderAltair) + if err = c.Header.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Header: %w", err) } - if err = l.CurrentSyncCommittee.UnmarshalSSZ(buf[112:24736]); err != nil { - return err + + // Field 1: CurrentSyncCommittee + c.CurrentSyncCommittee = new(SyncCommittee) + if err = c.CurrentSyncCommittee.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("CurrentSyncCommittee: %w", err) } - // Field (2) 'CurrentSyncCommitteeBranch' - l.CurrentSyncCommitteeBranch = make([][]byte, 5) - for ii := 0; ii < 5; ii++ { - if cap(l.CurrentSyncCommitteeBranch[ii]) == 0 { - l.CurrentSyncCommitteeBranch[ii] = make([]byte, 0, len(buf[24736:24896][ii*32:(ii+1)*32])) + // Field 2: CurrentSyncCommitteeBranch + { + c.CurrentSyncCommitteeBranch = make([][]byte, 5) + for i := 0; i < 5; i++ { + var tmp []byte + + tmpSlice := sszSlice2[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.CurrentSyncCommitteeBranch[i] = tmp } - l.CurrentSyncCommitteeBranch[ii] = append(l.CurrentSyncCommitteeBranch[ii], buf[24736:24896][ii*32:(ii+1)*32]...) } - return err } -// SizeSSZ returns the ssz encoded size in bytes for the LightClientBootstrapAltair object -func (l *LightClientBootstrapAltair) SizeSSZ() (size int) { - size = 24896 - return -} - -// HashTreeRoot ssz hashes the LightClientBootstrapAltair object -func (l *LightClientBootstrapAltair) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(l) +func (c *LightClientBootstrapAltair) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the LightClientBootstrapAltair object with a hasher -func (l *LightClientBootstrapAltair) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *LightClientBootstrapAltair) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Header' - if err = l.Header.HashTreeRootWith(hh); err != nil { - return + // Field 0: Header + if err := c.Header.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Header: %w", err) } - - // Field (1) 'CurrentSyncCommittee' - if err = l.CurrentSyncCommittee.HashTreeRootWith(hh); err != nil { - return + // Field 1: CurrentSyncCommittee + if err := c.CurrentSyncCommittee.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("CurrentSyncCommittee: %w", err) } - - // Field (2) 'CurrentSyncCommitteeBranch' + // Field 2: CurrentSyncCommitteeBranch { - if size := len(l.CurrentSyncCommitteeBranch); size != 5 { - err = ssz.ErrVectorLengthFn("--.CurrentSyncCommitteeBranch", size, 5) - return + if len(c.CurrentSyncCommitteeBranch) != 5 { + return ssz.ErrVectorLength } subIndx := hh.Index() - for _, i := range l.CurrentSyncCommitteeBranch { - if len(i) != 32 { - err = ssz.ErrBytesLength - return + for _, o := range c.CurrentSyncCommitteeBranch { + if len(o) != 32 { + return ssz.ErrBytesLength } - hh.Append(i) + hh.Append(o) } hh.Merkleize(subIndx) } - hh.Merkleize(indx) - return + return nil +} + +func (c *LightClientUpdateAltair) SizeSSZ() int { + size := 25368 + + return size } -// MarshalSSZ ssz marshals the LightClientUpdateAltair object -func (l *LightClientUpdateAltair) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(l) +func (c *LightClientUpdateAltair) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the LightClientUpdateAltair object to a target array -func (l *LightClientUpdateAltair) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *LightClientUpdateAltair) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (0) 'AttestedHeader' - if l.AttestedHeader == nil { - l.AttestedHeader = new(LightClientHeaderAltair) + // Field 0: AttestedHeader + if c.AttestedHeader == nil { + c.AttestedHeader = new(LightClientHeaderAltair) } - if dst, err = l.AttestedHeader.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.AttestedHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("AttestedHeader: %w", err) } - // Field (1) 'NextSyncCommittee' - if l.NextSyncCommittee == nil { - l.NextSyncCommittee = new(SyncCommittee) + // Field 1: NextSyncCommittee + if c.NextSyncCommittee == nil { + c.NextSyncCommittee = new(SyncCommittee) } - if dst, err = l.NextSyncCommittee.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.NextSyncCommittee.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("NextSyncCommittee: %w", err) } - // Field (2) 'NextSyncCommitteeBranch' - if size := len(l.NextSyncCommitteeBranch); size != 5 { - err = ssz.ErrVectorLengthFn("--.NextSyncCommitteeBranch", size, 5) - return + // Field 2: NextSyncCommitteeBranch + if len(c.NextSyncCommitteeBranch) != 5 { + return nil, ssz.ErrBytesLength } - for ii := 0; ii < 5; ii++ { - if size := len(l.NextSyncCommitteeBranch[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.NextSyncCommitteeBranch[ii]", size, 32) - return + for _, o := range c.NextSyncCommitteeBranch { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, l.NextSyncCommitteeBranch[ii]...) + dst = append(dst, o...) } - // Field (3) 'FinalizedHeader' - if l.FinalizedHeader == nil { - l.FinalizedHeader = new(LightClientHeaderAltair) + // Field 3: FinalizedHeader + if c.FinalizedHeader == nil { + c.FinalizedHeader = new(LightClientHeaderAltair) } - if dst, err = l.FinalizedHeader.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.FinalizedHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("FinalizedHeader: %w", err) } - // Field (4) 'FinalityBranch' - if size := len(l.FinalityBranch); size != 6 { - err = ssz.ErrVectorLengthFn("--.FinalityBranch", size, 6) - return + // Field 4: FinalityBranch + if len(c.FinalityBranch) != 6 { + return nil, ssz.ErrBytesLength } - for ii := 0; ii < 6; ii++ { - if size := len(l.FinalityBranch[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.FinalityBranch[ii]", size, 32) - return + for _, o := range c.FinalityBranch { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, l.FinalityBranch[ii]...) + dst = append(dst, o...) } - // Field (5) 'SyncAggregate' - if l.SyncAggregate == nil { - l.SyncAggregate = new(SyncAggregate) + // Field 5: SyncAggregate + if c.SyncAggregate == nil { + c.SyncAggregate = new(SyncAggregate) } - if dst, err = l.SyncAggregate.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.SyncAggregate.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SyncAggregate: %w", err) } - // Field (6) 'SignatureSlot' - dst = ssz.MarshalUint(dst, l.SignatureSlot) + // Field 6: SignatureSlot + if dst, err = c.SignatureSlot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SignatureSlot: %w", err) + } - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the LightClientUpdateAltair object -func (l *LightClientUpdateAltair) UnmarshalSSZ(buf []byte) error { +func (c *LightClientUpdateAltair) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size != 25368 { return ssz.ErrSize } - // Field (0) 'AttestedHeader' - if l.AttestedHeader == nil { - l.AttestedHeader = new(LightClientHeaderAltair) - } - if err = l.AttestedHeader.UnmarshalSSZ(buf[0:112]); err != nil { - return err - } + sszSlice0 := buf[0:112] // c.AttestedHeader + sszSlice1 := buf[112:24736] // c.NextSyncCommittee + sszSlice2 := buf[24736:24896] // c.NextSyncCommitteeBranch + sszSlice3 := buf[24896:25008] // c.FinalizedHeader + sszSlice4 := buf[25008:25200] // c.FinalityBranch + sszSlice5 := buf[25200:25360] // c.SyncAggregate + sszSlice6 := buf[25360:25368] // c.SignatureSlot - // Field (1) 'NextSyncCommittee' - if l.NextSyncCommittee == nil { - l.NextSyncCommittee = new(SyncCommittee) + // Field 0: AttestedHeader + c.AttestedHeader = new(LightClientHeaderAltair) + if err = c.AttestedHeader.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("AttestedHeader: %w", err) } - if err = l.NextSyncCommittee.UnmarshalSSZ(buf[112:24736]); err != nil { - return err + + // Field 1: NextSyncCommittee + c.NextSyncCommittee = new(SyncCommittee) + if err = c.NextSyncCommittee.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("NextSyncCommittee: %w", err) } - // Field (2) 'NextSyncCommitteeBranch' - l.NextSyncCommitteeBranch = make([][]byte, 5) - for ii := 0; ii < 5; ii++ { - if cap(l.NextSyncCommitteeBranch[ii]) == 0 { - l.NextSyncCommitteeBranch[ii] = make([]byte, 0, len(buf[24736:24896][ii*32:(ii+1)*32])) + // Field 2: NextSyncCommitteeBranch + { + c.NextSyncCommitteeBranch = make([][]byte, 5) + for i := 0; i < 5; i++ { + var tmp []byte + + tmpSlice := sszSlice2[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.NextSyncCommitteeBranch[i] = tmp } - l.NextSyncCommitteeBranch[ii] = append(l.NextSyncCommitteeBranch[ii], buf[24736:24896][ii*32:(ii+1)*32]...) } - // Field (3) 'FinalizedHeader' - if l.FinalizedHeader == nil { - l.FinalizedHeader = new(LightClientHeaderAltair) - } - if err = l.FinalizedHeader.UnmarshalSSZ(buf[24896:25008]); err != nil { - return err + // Field 3: FinalizedHeader + c.FinalizedHeader = new(LightClientHeaderAltair) + if err = c.FinalizedHeader.UnmarshalSSZ(sszSlice3); err != nil { + return fmt.Errorf("FinalizedHeader: %w", err) } - // Field (4) 'FinalityBranch' - l.FinalityBranch = make([][]byte, 6) - for ii := 0; ii < 6; ii++ { - if cap(l.FinalityBranch[ii]) == 0 { - l.FinalityBranch[ii] = make([]byte, 0, len(buf[25008:25200][ii*32:(ii+1)*32])) + // Field 4: FinalityBranch + { + c.FinalityBranch = make([][]byte, 6) + for i := 0; i < 6; i++ { + var tmp []byte + + tmpSlice := sszSlice4[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.FinalityBranch[i] = tmp } - l.FinalityBranch[ii] = append(l.FinalityBranch[ii], buf[25008:25200][ii*32:(ii+1)*32]...) } - // Field (5) 'SyncAggregate' - if l.SyncAggregate == nil { - l.SyncAggregate = new(SyncAggregate) + // Field 5: SyncAggregate + c.SyncAggregate = new(SyncAggregate) + if err = c.SyncAggregate.UnmarshalSSZ(sszSlice5); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) } - if err = l.SyncAggregate.UnmarshalSSZ(buf[25200:25360]); err != nil { - return err - } - - // Field (6) 'SignatureSlot' - l.SignatureSlot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[25360:25368]) + // Field 6: SignatureSlot + if err = c.SignatureSlot.UnmarshalSSZ(sszSlice6); err != nil { + return fmt.Errorf("SignatureSlot: %w", err) + } return err } -// SizeSSZ returns the ssz encoded size in bytes for the LightClientUpdateAltair object -func (l *LightClientUpdateAltair) SizeSSZ() (size int) { - size = 25368 - return -} - -// HashTreeRoot ssz hashes the LightClientUpdateAltair object -func (l *LightClientUpdateAltair) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(l) +func (c *LightClientUpdateAltair) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the LightClientUpdateAltair object with a hasher -func (l *LightClientUpdateAltair) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *LightClientUpdateAltair) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'AttestedHeader' - if err = l.AttestedHeader.HashTreeRootWith(hh); err != nil { - return + // Field 0: AttestedHeader + if err := c.AttestedHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("AttestedHeader: %w", err) } - - // Field (1) 'NextSyncCommittee' - if err = l.NextSyncCommittee.HashTreeRootWith(hh); err != nil { - return + // Field 1: NextSyncCommittee + if err := c.NextSyncCommittee.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("NextSyncCommittee: %w", err) } - - // Field (2) 'NextSyncCommitteeBranch' + // Field 2: NextSyncCommitteeBranch { - if size := len(l.NextSyncCommitteeBranch); size != 5 { - err = ssz.ErrVectorLengthFn("--.NextSyncCommitteeBranch", size, 5) - return + if len(c.NextSyncCommitteeBranch) != 5 { + return ssz.ErrVectorLength } subIndx := hh.Index() - for _, i := range l.NextSyncCommitteeBranch { - if len(i) != 32 { - err = ssz.ErrBytesLength - return + for _, o := range c.NextSyncCommitteeBranch { + if len(o) != 32 { + return ssz.ErrBytesLength } - hh.Append(i) + hh.Append(o) } hh.Merkleize(subIndx) } - - // Field (3) 'FinalizedHeader' - if err = l.FinalizedHeader.HashTreeRootWith(hh); err != nil { - return + // Field 3: FinalizedHeader + if err := c.FinalizedHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("FinalizedHeader: %w", err) } - - // Field (4) 'FinalityBranch' + // Field 4: FinalityBranch { - if size := len(l.FinalityBranch); size != 6 { - err = ssz.ErrVectorLengthFn("--.FinalityBranch", size, 6) - return + if len(c.FinalityBranch) != 6 { + return ssz.ErrVectorLength } subIndx := hh.Index() - for _, i := range l.FinalityBranch { - if len(i) != 32 { - err = ssz.ErrBytesLength - return + for _, o := range c.FinalityBranch { + if len(o) != 32 { + return ssz.ErrBytesLength } - hh.Append(i) + hh.Append(o) } hh.Merkleize(subIndx) } - - // Field (5) 'SyncAggregate' - if err = l.SyncAggregate.HashTreeRootWith(hh); err != nil { - return + // Field 5: SyncAggregate + if err := c.SyncAggregate.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) } + // Field 6: SignatureSlot + if err := c.SignatureSlot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SignatureSlot: %w", err) + } + hh.Merkleize(indx) + return nil +} - // Field (6) 'SignatureSlot' - ssz.PutUint(hh, l.SignatureSlot) +func (c *LightClientFinalityUpdateAltair) SizeSSZ() int { + size := 584 - hh.Merkleize(indx) - return + return size } -// MarshalSSZ ssz marshals the LightClientFinalityUpdateAltair object -func (l *LightClientFinalityUpdateAltair) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(l) +func (c *LightClientFinalityUpdateAltair) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the LightClientFinalityUpdateAltair object to a target array -func (l *LightClientFinalityUpdateAltair) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *LightClientFinalityUpdateAltair) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (0) 'AttestedHeader' - if l.AttestedHeader == nil { - l.AttestedHeader = new(LightClientHeaderAltair) + // Field 0: AttestedHeader + if c.AttestedHeader == nil { + c.AttestedHeader = new(LightClientHeaderAltair) } - if dst, err = l.AttestedHeader.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.AttestedHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("AttestedHeader: %w", err) } - // Field (1) 'FinalizedHeader' - if l.FinalizedHeader == nil { - l.FinalizedHeader = new(LightClientHeaderAltair) + // Field 1: FinalizedHeader + if c.FinalizedHeader == nil { + c.FinalizedHeader = new(LightClientHeaderAltair) } - if dst, err = l.FinalizedHeader.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.FinalizedHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("FinalizedHeader: %w", err) } - // Field (2) 'FinalityBranch' - if size := len(l.FinalityBranch); size != 6 { - err = ssz.ErrVectorLengthFn("--.FinalityBranch", size, 6) - return + // Field 2: FinalityBranch + if len(c.FinalityBranch) != 6 { + return nil, ssz.ErrBytesLength } - for ii := 0; ii < 6; ii++ { - if size := len(l.FinalityBranch[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.FinalityBranch[ii]", size, 32) - return + for _, o := range c.FinalityBranch { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, l.FinalityBranch[ii]...) + dst = append(dst, o...) } - // Field (3) 'SyncAggregate' - if l.SyncAggregate == nil { - l.SyncAggregate = new(SyncAggregate) + // Field 3: SyncAggregate + if c.SyncAggregate == nil { + c.SyncAggregate = new(SyncAggregate) } - if dst, err = l.SyncAggregate.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.SyncAggregate.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SyncAggregate: %w", err) } - // Field (4) 'SignatureSlot' - dst = ssz.MarshalUint(dst, l.SignatureSlot) + // Field 4: SignatureSlot + if dst, err = c.SignatureSlot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SignatureSlot: %w", err) + } - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the LightClientFinalityUpdateAltair object -func (l *LightClientFinalityUpdateAltair) UnmarshalSSZ(buf []byte) error { +func (c *LightClientFinalityUpdateAltair) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size != 584 { return ssz.ErrSize } - // Field (0) 'AttestedHeader' - if l.AttestedHeader == nil { - l.AttestedHeader = new(LightClientHeaderAltair) - } - if err = l.AttestedHeader.UnmarshalSSZ(buf[0:112]); err != nil { - return err - } + sszSlice0 := buf[0:112] // c.AttestedHeader + sszSlice1 := buf[112:224] // c.FinalizedHeader + sszSlice2 := buf[224:416] // c.FinalityBranch + sszSlice3 := buf[416:576] // c.SyncAggregate + sszSlice4 := buf[576:584] // c.SignatureSlot - // Field (1) 'FinalizedHeader' - if l.FinalizedHeader == nil { - l.FinalizedHeader = new(LightClientHeaderAltair) + // Field 0: AttestedHeader + c.AttestedHeader = new(LightClientHeaderAltair) + if err = c.AttestedHeader.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("AttestedHeader: %w", err) } - if err = l.FinalizedHeader.UnmarshalSSZ(buf[112:224]); err != nil { - return err + + // Field 1: FinalizedHeader + c.FinalizedHeader = new(LightClientHeaderAltair) + if err = c.FinalizedHeader.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("FinalizedHeader: %w", err) } - // Field (2) 'FinalityBranch' - l.FinalityBranch = make([][]byte, 6) - for ii := 0; ii < 6; ii++ { - if cap(l.FinalityBranch[ii]) == 0 { - l.FinalityBranch[ii] = make([]byte, 0, len(buf[224:416][ii*32:(ii+1)*32])) + // Field 2: FinalityBranch + { + c.FinalityBranch = make([][]byte, 6) + for i := 0; i < 6; i++ { + var tmp []byte + + tmpSlice := sszSlice2[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.FinalityBranch[i] = tmp } - l.FinalityBranch[ii] = append(l.FinalityBranch[ii], buf[224:416][ii*32:(ii+1)*32]...) } - // Field (3) 'SyncAggregate' - if l.SyncAggregate == nil { - l.SyncAggregate = new(SyncAggregate) - } - if err = l.SyncAggregate.UnmarshalSSZ(buf[416:576]); err != nil { - return err + // Field 3: SyncAggregate + c.SyncAggregate = new(SyncAggregate) + if err = c.SyncAggregate.UnmarshalSSZ(sszSlice3); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) } - // Field (4) 'SignatureSlot' - l.SignatureSlot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[576:584]) - + // Field 4: SignatureSlot + if err = c.SignatureSlot.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("SignatureSlot: %w", err) + } return err } -// SizeSSZ returns the ssz encoded size in bytes for the LightClientFinalityUpdateAltair object -func (l *LightClientFinalityUpdateAltair) SizeSSZ() (size int) { - size = 584 - return -} - -// HashTreeRoot ssz hashes the LightClientFinalityUpdateAltair object -func (l *LightClientFinalityUpdateAltair) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(l) +func (c *LightClientFinalityUpdateAltair) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the LightClientFinalityUpdateAltair object with a hasher -func (l *LightClientFinalityUpdateAltair) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *LightClientFinalityUpdateAltair) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'AttestedHeader' - if err = l.AttestedHeader.HashTreeRootWith(hh); err != nil { - return + // Field 0: AttestedHeader + if err := c.AttestedHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("AttestedHeader: %w", err) } - - // Field (1) 'FinalizedHeader' - if err = l.FinalizedHeader.HashTreeRootWith(hh); err != nil { - return + // Field 1: FinalizedHeader + if err := c.FinalizedHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("FinalizedHeader: %w", err) } - - // Field (2) 'FinalityBranch' + // Field 2: FinalityBranch { - if size := len(l.FinalityBranch); size != 6 { - err = ssz.ErrVectorLengthFn("--.FinalityBranch", size, 6) - return + if len(c.FinalityBranch) != 6 { + return ssz.ErrVectorLength } subIndx := hh.Index() - for _, i := range l.FinalityBranch { - if len(i) != 32 { - err = ssz.ErrBytesLength - return + for _, o := range c.FinalityBranch { + if len(o) != 32 { + return ssz.ErrBytesLength } - hh.Append(i) + hh.Append(o) } hh.Merkleize(subIndx) } - - // Field (3) 'SyncAggregate' - if err = l.SyncAggregate.HashTreeRootWith(hh); err != nil { - return + // Field 3: SyncAggregate + if err := c.SyncAggregate.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) + } + // Field 4: SignatureSlot + if err := c.SignatureSlot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SignatureSlot: %w", err) } + hh.Merkleize(indx) + return nil +} - // Field (4) 'SignatureSlot' - ssz.PutUint(hh, l.SignatureSlot) +func (c *LightClientOptimisticUpdateAltair) SizeSSZ() int { + size := 280 - hh.Merkleize(indx) - return + return size } -// MarshalSSZ ssz marshals the LightClientOptimisticUpdateAltair object -func (l *LightClientOptimisticUpdateAltair) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(l) +func (c *LightClientOptimisticUpdateAltair) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the LightClientOptimisticUpdateAltair object to a target array -func (l *LightClientOptimisticUpdateAltair) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *LightClientOptimisticUpdateAltair) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (0) 'AttestedHeader' - if l.AttestedHeader == nil { - l.AttestedHeader = new(LightClientHeaderAltair) + // Field 0: AttestedHeader + if c.AttestedHeader == nil { + c.AttestedHeader = new(LightClientHeaderAltair) } - if dst, err = l.AttestedHeader.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.AttestedHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("AttestedHeader: %w", err) } - // Field (1) 'SyncAggregate' - if l.SyncAggregate == nil { - l.SyncAggregate = new(SyncAggregate) + // Field 1: SyncAggregate + if c.SyncAggregate == nil { + c.SyncAggregate = new(SyncAggregate) } - if dst, err = l.SyncAggregate.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.SyncAggregate.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SyncAggregate: %w", err) } - // Field (2) 'SignatureSlot' - dst = ssz.MarshalUint(dst, l.SignatureSlot) + // Field 2: SignatureSlot + if dst, err = c.SignatureSlot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SignatureSlot: %w", err) + } - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the LightClientOptimisticUpdateAltair object -func (l *LightClientOptimisticUpdateAltair) UnmarshalSSZ(buf []byte) error { +func (c *LightClientOptimisticUpdateAltair) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size != 280 { return ssz.ErrSize } - // Field (0) 'AttestedHeader' - if l.AttestedHeader == nil { - l.AttestedHeader = new(LightClientHeaderAltair) - } - if err = l.AttestedHeader.UnmarshalSSZ(buf[0:112]); err != nil { - return err - } + sszSlice0 := buf[0:112] // c.AttestedHeader + sszSlice1 := buf[112:272] // c.SyncAggregate + sszSlice2 := buf[272:280] // c.SignatureSlot - // Field (1) 'SyncAggregate' - if l.SyncAggregate == nil { - l.SyncAggregate = new(SyncAggregate) - } - if err = l.SyncAggregate.UnmarshalSSZ(buf[112:272]); err != nil { - return err + // Field 0: AttestedHeader + c.AttestedHeader = new(LightClientHeaderAltair) + if err = c.AttestedHeader.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("AttestedHeader: %w", err) } - // Field (2) 'SignatureSlot' - l.SignatureSlot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[272:280]) + // Field 1: SyncAggregate + c.SyncAggregate = new(SyncAggregate) + if err = c.SyncAggregate.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) + } + // Field 2: SignatureSlot + if err = c.SignatureSlot.UnmarshalSSZ(sszSlice2); err != nil { + return fmt.Errorf("SignatureSlot: %w", err) + } return err } -// SizeSSZ returns the ssz encoded size in bytes for the LightClientOptimisticUpdateAltair object -func (l *LightClientOptimisticUpdateAltair) SizeSSZ() (size int) { - size = 280 - return -} - -// HashTreeRoot ssz hashes the LightClientOptimisticUpdateAltair object -func (l *LightClientOptimisticUpdateAltair) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(l) +func (c *LightClientOptimisticUpdateAltair) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the LightClientOptimisticUpdateAltair object with a hasher -func (l *LightClientOptimisticUpdateAltair) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *LightClientOptimisticUpdateAltair) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'AttestedHeader' - if err = l.AttestedHeader.HashTreeRootWith(hh); err != nil { - return + // Field 0: AttestedHeader + if err := c.AttestedHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("AttestedHeader: %w", err) } - - // Field (1) 'SyncAggregate' - if err = l.SyncAggregate.HashTreeRootWith(hh); err != nil { - return + // Field 1: SyncAggregate + if err := c.SyncAggregate.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) + } + // Field 2: SignatureSlot + if err := c.SignatureSlot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SignatureSlot: %w", err) } - - // Field (2) 'SignatureSlot' - ssz.PutUint(hh, l.SignatureSlot) - hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the LightClientHeaderAltair object -func (l *LightClientHeaderAltair) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(l) +func (c *SignedBeaconBlockAltair) SizeSSZ() int { + size := 100 + if c.Block == nil { + c.Block = new(BeaconBlockAltair) + } + size += c.Block.SizeSSZ() + return size +} + +func (c *SignedBeaconBlockAltair) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the LightClientHeaderAltair object to a target array -func (l *LightClientHeaderAltair) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *SignedBeaconBlockAltair) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 100 - // Field (0) 'Beacon' - if l.Beacon == nil { - l.Beacon = new(BeaconBlockHeader) + // Field 0: Block + if c.Block == nil { + c.Block = new(BeaconBlockAltair) } - if dst, err = l.Beacon.MarshalSSZTo(dst); err != nil { - return + dst = ssz.WriteOffset(dst, offset) + offset += c.Block.SizeSSZ() + + // Field 1: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.Signature...) - return + // Field 0: Block + if dst, err = c.Block.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Block: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the LightClientHeaderAltair object -func (l *LightClientHeaderAltair) UnmarshalSSZ(buf []byte) error { +func (c *SignedBeaconBlockAltair) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 112 { + if size < 100 { return ssz.ErrSize } - // Field (0) 'Beacon' - if l.Beacon == nil { - l.Beacon = new(BeaconBlockHeader) + sszSlice1 := buf[4:100] // c.Signature + + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Block + if sszVarOffset0 != 100 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset0 > size { + return ssz.ErrOffset } - if err = l.Beacon.UnmarshalSSZ(buf[0:112]); err != nil { - return err + sszSlice0 := buf[sszVarOffset0:] // c.Block + + // Field 0: Block + c.Block = new(BeaconBlockAltair) + if err = c.Block.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Block: %w", err) } + // Field 1: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice1...) return err } -// SizeSSZ returns the ssz encoded size in bytes for the LightClientHeaderAltair object -func (l *LightClientHeaderAltair) SizeSSZ() (size int) { - size = 112 - return -} - -// HashTreeRoot ssz hashes the LightClientHeaderAltair object -func (l *LightClientHeaderAltair) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(l) +func (c *SignedBeaconBlockAltair) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the LightClientHeaderAltair object with a hasher -func (l *LightClientHeaderAltair) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *SignedBeaconBlockAltair) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Beacon' - if err = l.Beacon.HashTreeRootWith(hh); err != nil { - return + // Field 0: Block + if err := c.Block.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Block: %w", err) } - + // Field 1: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Signature) hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the SyncCommitteeMessage object -func (s *SyncCommitteeMessage) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) +func (c *SignedContributionAndProof) SizeSSZ() int { + size := 360 + + return size } -// MarshalSSZTo ssz marshals the SyncCommitteeMessage object to a target array -func (s *SyncCommitteeMessage) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *SignedContributionAndProof) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (0) 'Slot' - dst = ssz.MarshalUint(dst, s.Slot) +func (c *SignedContributionAndProof) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (1) 'BlockRoot' - if size := len(s.BlockRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockRoot", size, 32) - return + // Field 0: Message + if c.Message == nil { + c.Message = new(ContributionAndProof) + } + if dst, err = c.Message.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Message: %w", err) } - dst = append(dst, s.BlockRoot...) - - // Field (2) 'ValidatorIndex' - dst = ssz.MarshalUint(dst, s.ValidatorIndex) - // Field (3) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 1: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } - dst = append(dst, s.Signature...) + dst = append(dst, c.Signature...) - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the SyncCommitteeMessage object -func (s *SyncCommitteeMessage) UnmarshalSSZ(buf []byte) error { +func (c *SignedContributionAndProof) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 144 { + if size != 360 { return ssz.ErrSize } - // Field (0) 'Slot' - s.Slot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[0:8]) + sszSlice0 := buf[0:264] // c.Message + sszSlice1 := buf[264:360] // c.Signature - // Field (1) 'BlockRoot' - if cap(s.BlockRoot) == 0 { - s.BlockRoot = make([]byte, 0, len(buf[8:40])) + // Field 0: Message + c.Message = new(ContributionAndProof) + if err = c.Message.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Message: %w", err) } - s.BlockRoot = append(s.BlockRoot, buf[8:40]...) - // Field (2) 'ValidatorIndex' - s.ValidatorIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[40:48]) + // Field 1: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice1...) + return err +} - // Field (3) 'Signature' - if cap(s.Signature) == 0 { - s.Signature = make([]byte, 0, len(buf[48:144])) +func (c *SignedContributionAndProof) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - s.Signature = append(s.Signature, buf[48:144]...) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - return err +func (c *SignedContributionAndProof) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Message + if err := c.Message.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Message: %w", err) + } + // Field 1: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Signature) + hh.Merkleize(indx) + return nil } -// SizeSSZ returns the ssz encoded size in bytes for the SyncCommitteeMessage object -func (s *SyncCommitteeMessage) SizeSSZ() (size int) { - size = 144 - return +func (c *SyncAggregate) SizeSSZ() int { + size := 160 + + return size } -// HashTreeRoot ssz hashes the SyncCommitteeMessage object -func (s *SyncCommitteeMessage) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) +func (c *SyncAggregate) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// HashTreeRootWith ssz hashes the SyncCommitteeMessage object with a hasher -func (s *SyncCommitteeMessage) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() +func (c *SyncAggregate) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (0) 'Slot' - ssz.PutUint(hh, s.Slot) + // Field 0: SyncCommitteeBits + if len([]byte(c.SyncCommitteeBits)) != 64 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, []byte(c.SyncCommitteeBits)...) - // Field (1) 'BlockRoot' - if size := len(s.BlockRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockRoot", size, 32) - return + // Field 1: SyncCommitteeSignature + if len(c.SyncCommitteeSignature) != 96 { + return nil, ssz.ErrBytesLength } - hh.PutBytes(s.BlockRoot) + dst = append(dst, c.SyncCommitteeSignature...) - // Field (2) 'ValidatorIndex' - ssz.PutUint(hh, s.ValidatorIndex) + return dst, err +} - // Field (3) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return +func (c *SyncAggregate) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 160 { + return ssz.ErrSize } - hh.PutBytes(s.Signature) - hh.Merkleize(indx) - return -} + sszSlice0 := buf[0:64] // c.SyncCommitteeBits + sszSlice1 := buf[64:160] // c.SyncCommitteeSignature -// MarshalSSZ ssz marshals the SignedContributionAndProof object -func (s *SignedContributionAndProof) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) + // Field 0: SyncCommitteeBits + c.SyncCommitteeBits = make([]byte, 0, 64) + c.SyncCommitteeBits = append(c.SyncCommitteeBits, go_bitfield.Bitvector512(sszSlice0)...) + + // Field 1: SyncCommitteeSignature + c.SyncCommitteeSignature = make([]byte, 0, 96) + c.SyncCommitteeSignature = append(c.SyncCommitteeSignature, sszSlice1...) + return err } -// MarshalSSZTo ssz marshals the SignedContributionAndProof object to a target array -func (s *SignedContributionAndProof) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *SyncAggregate) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (0) 'Message' - if s.Message == nil { - s.Message = new(ContributionAndProof) +func (c *SyncAggregate) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: SyncCommitteeBits + if len([]byte(c.SyncCommitteeBits)) != 64 { + return ssz.ErrBytesLength } - if dst, err = s.Message.MarshalSSZTo(dst); err != nil { - return + hh.PutBytes([]byte(c.SyncCommitteeBits)) + // Field 1: SyncCommitteeSignature + if len(c.SyncCommitteeSignature) != 96 { + return ssz.ErrBytesLength } + hh.PutBytes(c.SyncCommitteeSignature) + hh.Merkleize(indx) + return nil +} + +func (c *SyncAggregatorSelectionData) SizeSSZ() int { + size := 16 + + return size +} + +func (c *SyncAggregatorSelectionData) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} + +func (c *SyncAggregatorSelectionData) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 0: Slot + if dst, err = c.Slot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Slot: %w", err) } - dst = append(dst, s.Signature...) - return + // Field 1: SubcommitteeIndex + dst = binary.LittleEndian.AppendUint64(dst, c.SubcommitteeIndex) + + return dst, err } -// UnmarshalSSZ ssz unmarshals the SignedContributionAndProof object -func (s *SignedContributionAndProof) UnmarshalSSZ(buf []byte) error { +func (c *SyncAggregatorSelectionData) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 360 { + if size != 16 { return ssz.ErrSize } - // Field (0) 'Message' - if s.Message == nil { - s.Message = new(ContributionAndProof) - } - if err = s.Message.UnmarshalSSZ(buf[0:264]); err != nil { - return err - } + sszSlice0 := buf[0:8] // c.Slot + sszSlice1 := buf[8:16] // c.SubcommitteeIndex - // Field (1) 'Signature' - if cap(s.Signature) == 0 { - s.Signature = make([]byte, 0, len(buf[264:360])) + // Field 0: Slot + if err = c.Slot.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Slot: %w", err) } - s.Signature = append(s.Signature, buf[264:360]...) + // Field 1: SubcommitteeIndex + c.SubcommitteeIndex = binary.LittleEndian.Uint64(sszSlice1) return err } -// SizeSSZ returns the ssz encoded size in bytes for the SignedContributionAndProof object -func (s *SignedContributionAndProof) SizeSSZ() (size int) { - size = 360 - return -} - -// HashTreeRoot ssz hashes the SignedContributionAndProof object -func (s *SignedContributionAndProof) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) +func (c *SyncAggregatorSelectionData) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the SignedContributionAndProof object with a hasher -func (s *SignedContributionAndProof) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *SyncAggregatorSelectionData) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Message' - if err = s.Message.HashTreeRootWith(hh); err != nil { - return - } - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 0: Slot + if err := c.Slot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Slot: %w", err) } - hh.PutBytes(s.Signature) - + // Field 1: SubcommitteeIndex + hh.PutUint64(c.SubcommitteeIndex) hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the ContributionAndProof object -func (c *ContributionAndProof) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(c) +func (c *SyncCommittee) SizeSSZ() int { + size := 24624 + + return size } -// MarshalSSZTo ssz marshals the ContributionAndProof object to a target array -func (c *ContributionAndProof) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *SyncCommittee) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (0) 'AggregatorIndex' - dst = ssz.MarshalUint(dst, c.AggregatorIndex) +func (c *SyncCommittee) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (1) 'Contribution' - if c.Contribution == nil { - c.Contribution = new(SyncCommitteeContribution) + // Field 0: Pubkeys + if len(c.Pubkeys) != 512 { + return nil, ssz.ErrBytesLength } - if dst, err = c.Contribution.MarshalSSZTo(dst); err != nil { - return + for _, o := range c.Pubkeys { + if len(o) != 48 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) } - // Field (2) 'SelectionProof' - if size := len(c.SelectionProof); size != 96 { - err = ssz.ErrBytesLengthFn("--.SelectionProof", size, 96) - return + // Field 1: AggregatePubkey + if len(c.AggregatePubkey) != 48 { + return nil, ssz.ErrBytesLength } - dst = append(dst, c.SelectionProof...) + dst = append(dst, c.AggregatePubkey...) - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the ContributionAndProof object -func (c *ContributionAndProof) UnmarshalSSZ(buf []byte) error { +func (c *SyncCommittee) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 264 { + if size != 24624 { return ssz.ErrSize } - // Field (0) 'AggregatorIndex' - c.AggregatorIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[0:8]) + sszSlice0 := buf[0:24576] // c.Pubkeys + sszSlice1 := buf[24576:24624] // c.AggregatePubkey - // Field (1) 'Contribution' - if c.Contribution == nil { - c.Contribution = new(SyncCommitteeContribution) - } - if err = c.Contribution.UnmarshalSSZ(buf[8:168]); err != nil { - return err - } + // Field 0: Pubkeys + { + c.Pubkeys = make([][]byte, 512) + for i := 0; i < 512; i++ { + var tmp []byte - // Field (2) 'SelectionProof' - if cap(c.SelectionProof) == 0 { - c.SelectionProof = make([]byte, 0, len(buf[168:264])) + tmpSlice := sszSlice0[i*48 : (1+i)*48] + tmp = make([]byte, 0, 48) + tmp = append(tmp, tmpSlice...) + c.Pubkeys[i] = tmp + } } - c.SelectionProof = append(c.SelectionProof, buf[168:264]...) + // Field 1: AggregatePubkey + c.AggregatePubkey = make([]byte, 0, 48) + c.AggregatePubkey = append(c.AggregatePubkey, sszSlice1...) return err } -// SizeSSZ returns the ssz encoded size in bytes for the ContributionAndProof object -func (c *ContributionAndProof) SizeSSZ() (size int) { - size = 264 - return -} - -// HashTreeRoot ssz hashes the ContributionAndProof object -func (c *ContributionAndProof) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(c) +func (c *SyncCommittee) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the ContributionAndProof object with a hasher -func (c *ContributionAndProof) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *SyncCommittee) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'AggregatorIndex' - ssz.PutUint(hh, c.AggregatorIndex) - - // Field (1) 'Contribution' - if err = c.Contribution.HashTreeRootWith(hh); err != nil { - return + // Field 0: Pubkeys + { + if len(c.Pubkeys) != 512 { + return ssz.ErrVectorLength + } + subIndx := hh.Index() + for _, o := range c.Pubkeys { + if len(o) != 48 { + return ssz.ErrBytesLength + } + hh.PutBytes(o) + } + hh.Merkleize(subIndx) } - - // Field (2) 'SelectionProof' - if size := len(c.SelectionProof); size != 96 { - err = ssz.ErrBytesLengthFn("--.SelectionProof", size, 96) - return + // Field 1: AggregatePubkey + if len(c.AggregatePubkey) != 48 { + return ssz.ErrBytesLength } - hh.PutBytes(c.SelectionProof) - + hh.PutBytes(c.AggregatePubkey) hh.Merkleize(indx) - return + return nil +} + +func (c *SyncCommitteeContribution) SizeSSZ() int { + size := 160 + + return size } -// MarshalSSZ ssz marshals the SyncCommitteeContribution object -func (s *SyncCommitteeContribution) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) +func (c *SyncCommitteeContribution) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the SyncCommitteeContribution object to a target array -func (s *SyncCommitteeContribution) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *SyncCommitteeContribution) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (0) 'Slot' - dst = ssz.MarshalUint(dst, s.Slot) + // Field 0: Slot + if dst, err = c.Slot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Slot: %w", err) + } - // Field (1) 'BlockRoot' - if size := len(s.BlockRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockRoot", size, 32) - return + // Field 1: BlockRoot + if len(c.BlockRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, s.BlockRoot...) + dst = append(dst, c.BlockRoot...) - // Field (2) 'SubcommitteeIndex' - dst = ssz.MarshalUint(dst, s.SubcommitteeIndex) + // Field 2: SubcommitteeIndex + dst = binary.LittleEndian.AppendUint64(dst, c.SubcommitteeIndex) - // Field (3) 'AggregationBits' - if size := len(s.AggregationBits); size != 16 { - err = ssz.ErrBytesLengthFn("--.AggregationBits", size, 16) - return + // Field 3: AggregationBits + if len([]byte(c.AggregationBits)) != 16 { + return nil, ssz.ErrBytesLength } - dst = append(dst, s.AggregationBits...) + dst = append(dst, []byte(c.AggregationBits)...) - // Field (4) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 4: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } - dst = append(dst, s.Signature...) + dst = append(dst, c.Signature...) - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the SyncCommitteeContribution object -func (s *SyncCommitteeContribution) UnmarshalSSZ(buf []byte) error { +func (c *SyncCommitteeContribution) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size != 160 { return ssz.ErrSize } - // Field (0) 'Slot' - s.Slot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[0:8]) + sszSlice0 := buf[0:8] // c.Slot + sszSlice1 := buf[8:40] // c.BlockRoot + sszSlice2 := buf[40:48] // c.SubcommitteeIndex + sszSlice3 := buf[48:64] // c.AggregationBits + sszSlice4 := buf[64:160] // c.Signature - // Field (1) 'BlockRoot' - if cap(s.BlockRoot) == 0 { - s.BlockRoot = make([]byte, 0, len(buf[8:40])) + // Field 0: Slot + if err = c.Slot.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Slot: %w", err) } - s.BlockRoot = append(s.BlockRoot, buf[8:40]...) - // Field (2) 'SubcommitteeIndex' - s.SubcommitteeIndex = ssz.UnmarshallUint[uint64](buf[40:48]) + // Field 1: BlockRoot + c.BlockRoot = make([]byte, 0, 32) + c.BlockRoot = append(c.BlockRoot, sszSlice1...) - // Field (3) 'AggregationBits' - if cap(s.AggregationBits) == 0 { - s.AggregationBits = make([]byte, 0, len(buf[48:64])) - } - s.AggregationBits = append(s.AggregationBits, buf[48:64]...) + // Field 2: SubcommitteeIndex + c.SubcommitteeIndex = binary.LittleEndian.Uint64(sszSlice2) - // Field (4) 'Signature' - if cap(s.Signature) == 0 { - s.Signature = make([]byte, 0, len(buf[64:160])) - } - s.Signature = append(s.Signature, buf[64:160]...) + // Field 3: AggregationBits + c.AggregationBits = make([]byte, 0, 16) + c.AggregationBits = append(c.AggregationBits, go_bitfield.Bitvector128(sszSlice3)...) + // Field 4: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice4...) return err } -// SizeSSZ returns the ssz encoded size in bytes for the SyncCommitteeContribution object -func (s *SyncCommitteeContribution) SizeSSZ() (size int) { - size = 160 - return +func (c *SyncCommitteeContribution) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} + +func (c *SyncCommitteeContribution) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Slot + if err := c.Slot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Slot: %w", err) + } + // Field 1: BlockRoot + if len(c.BlockRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.BlockRoot) + // Field 2: SubcommitteeIndex + hh.PutUint64(c.SubcommitteeIndex) + // Field 3: AggregationBits + if len([]byte(c.AggregationBits)) != 16 { + return ssz.ErrBytesLength + } + hh.PutBytes([]byte(c.AggregationBits)) + // Field 4: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Signature) + hh.Merkleize(indx) + return nil } -// HashTreeRoot ssz hashes the SyncCommitteeContribution object -func (s *SyncCommitteeContribution) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) +func (c *SyncCommitteeMessage) SizeSSZ() int { + size := 144 + + return size } -// HashTreeRootWith ssz hashes the SyncCommitteeContribution object with a hasher -func (s *SyncCommitteeContribution) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() +func (c *SyncCommitteeMessage) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} + +func (c *SyncCommitteeMessage) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + + // Field 0: Slot + if dst, err = c.Slot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Slot: %w", err) + } + + // Field 1: BlockRoot + if len(c.BlockRoot) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.BlockRoot...) + + // Field 2: ValidatorIndex + if dst, err = c.ValidatorIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ValidatorIndex: %w", err) + } + + // Field 3: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.Signature...) + + return dst, err +} + +func (c *SyncCommitteeMessage) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 144 { + return ssz.ErrSize + } - // Field (0) 'Slot' - ssz.PutUint(hh, s.Slot) + sszSlice0 := buf[0:8] // c.Slot + sszSlice1 := buf[8:40] // c.BlockRoot + sszSlice2 := buf[40:48] // c.ValidatorIndex + sszSlice3 := buf[48:144] // c.Signature - // Field (1) 'BlockRoot' - if size := len(s.BlockRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockRoot", size, 32) - return + // Field 0: Slot + if err = c.Slot.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Slot: %w", err) } - hh.PutBytes(s.BlockRoot) - // Field (2) 'SubcommitteeIndex' - ssz.PutUint(hh, s.SubcommitteeIndex) + // Field 1: BlockRoot + c.BlockRoot = make([]byte, 0, 32) + c.BlockRoot = append(c.BlockRoot, sszSlice1...) - // Field (3) 'AggregationBits' - if size := len(s.AggregationBits); size != 16 { - err = ssz.ErrBytesLengthFn("--.AggregationBits", size, 16) - return + // Field 2: ValidatorIndex + if err = c.ValidatorIndex.UnmarshalSSZ(sszSlice2); err != nil { + return fmt.Errorf("ValidatorIndex: %w", err) } - hh.PutBytes(s.AggregationBits) - // Field (4) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 3: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice3...) + return err +} + +func (c *SyncCommitteeMessage) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - hh.PutBytes(s.Signature) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} +func (c *SyncCommitteeMessage) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Slot + if err := c.Slot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Slot: %w", err) + } + // Field 1: BlockRoot + if len(c.BlockRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.BlockRoot) + // Field 2: ValidatorIndex + if err := c.ValidatorIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ValidatorIndex: %w", err) + } + // Field 3: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Signature) hh.Merkleize(indx) - return + return nil } diff --git a/proto/prysm/v1alpha1/altair.yaml b/proto/prysm/v1alpha1/altair.yaml new file mode 100644 index 000000000000..00b4c0c1c6d6 --- /dev/null +++ b/proto/prysm/v1alpha1/altair.yaml @@ -0,0 +1,18 @@ +package: "github.com/OffchainLabs/prysm/v7/proto/prysm/v1alpha1" +types: + - name: "BeaconBlockAltair" + - name: "BeaconBlockBodyAltair" + - name: "BeaconStateAltair" + - name: "ContributionAndProof" + - name: "LightClientHeaderAltair" + - name: "LightClientBootstrapAltair" + - name: "LightClientUpdateAltair" + - name: "LightClientFinalityUpdateAltair" + - name: "LightClientOptimisticUpdateAltair" + - name: "SignedBeaconBlockAltair" + - name: "SignedContributionAndProof" + - name: "SyncAggregate" + - name: "SyncAggregatorSelectionData" + - name: "SyncCommittee" + - name: "SyncCommitteeContribution" + - name: "SyncCommitteeMessage" diff --git a/proto/prysm/v1alpha1/attestation.go b/proto/prysm/v1alpha1/attestation.go index eafb0e4b4559..4b4d244796b6 100644 --- a/proto/prysm/v1alpha1/attestation.go +++ b/proto/prysm/v1alpha1/attestation.go @@ -2,10 +2,10 @@ package eth import ( "github.com/OffchainLabs/go-bitfield" + "github.com/OffchainLabs/methodical-ssz/ssz" "github.com/OffchainLabs/prysm/v7/consensus-types/primitives" "github.com/OffchainLabs/prysm/v7/encoding/bytesutil" "github.com/OffchainLabs/prysm/v7/runtime/version" - ssz "github.com/prysmaticlabs/fastssz" "google.golang.org/protobuf/proto" ) diff --git a/proto/prysm/v1alpha1/beacon_state.minimal.pb.go b/proto/prysm/v1alpha1/beacon_state.minimal.pb.go new file mode 100644 index 000000000000..75b835676032 --- /dev/null +++ b/proto/prysm/v1alpha1/beacon_state.minimal.pb.go @@ -0,0 +1,3711 @@ +//go:build minimal + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.3 +// protoc (unknown) +// source: proto/prysm/v1alpha1/beacon_state.proto + +package eth + +import ( + reflect "reflect" + sync "sync" + + github_com_OffchainLabs_go_bitfield "github.com/OffchainLabs/go-bitfield" + github_com_OffchainLabs_prysm_v7_consensus_types_primitives "github.com/OffchainLabs/prysm/v7/consensus-types/primitives" + v1 "github.com/OffchainLabs/prysm/v7/proto/engine/v1" + _ "github.com/OffchainLabs/prysm/v7/proto/eth/ext" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type BeaconState struct { + state protoimpl.MessageState `protogen:"open.v1"` + GenesisTime uint64 `protobuf:"varint,1001,opt,name=genesis_time,json=genesisTime,proto3" json:"genesis_time,omitempty"` + GenesisValidatorsRoot []byte `protobuf:"bytes,1002,opt,name=genesis_validators_root,json=genesisValidatorsRoot,proto3" json:"genesis_validators_root,omitempty" ssz-size:"32"` + Slot github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot `protobuf:"varint,1003,opt,name=slot,proto3" json:"slot,omitempty" cast-type:"github.com/OffchainLabs/prysm/v7/consensus-types/primitives.Slot"` + Fork *Fork `protobuf:"bytes,1004,opt,name=fork,proto3" json:"fork,omitempty"` + LatestBlockHeader *BeaconBlockHeader `protobuf:"bytes,2001,opt,name=latest_block_header,json=latestBlockHeader,proto3" json:"latest_block_header,omitempty"` + BlockRoots [][]byte `protobuf:"bytes,2002,rep,name=block_roots,json=blockRoots,proto3" json:"block_roots,omitempty" ssz-size:"64,32"` + StateRoots [][]byte `protobuf:"bytes,2003,rep,name=state_roots,json=stateRoots,proto3" json:"state_roots,omitempty" ssz-size:"64,32"` + HistoricalRoots [][]byte `protobuf:"bytes,2004,rep,name=historical_roots,json=historicalRoots,proto3" json:"historical_roots,omitempty" ssz-max:"16777216" ssz-size:"?,32"` + Eth1Data *Eth1Data `protobuf:"bytes,3001,opt,name=eth1_data,json=eth1Data,proto3" json:"eth1_data,omitempty"` + Eth1DataVotes []*Eth1Data `protobuf:"bytes,3002,rep,name=eth1_data_votes,json=eth1DataVotes,proto3" json:"eth1_data_votes,omitempty" ssz-max:"32"` + Eth1DepositIndex uint64 `protobuf:"varint,3003,opt,name=eth1_deposit_index,json=eth1DepositIndex,proto3" json:"eth1_deposit_index,omitempty"` + Validators []*Validator `protobuf:"bytes,4001,rep,name=validators,proto3" json:"validators,omitempty" ssz-max:"1099511627776"` + Balances []uint64 `protobuf:"varint,4002,rep,packed,name=balances,proto3" json:"balances,omitempty" ssz-max:"1099511627776"` + RandaoMixes [][]byte `protobuf:"bytes,5001,rep,name=randao_mixes,json=randaoMixes,proto3" json:"randao_mixes,omitempty" ssz-size:"64,32"` + Slashings []uint64 `protobuf:"varint,6001,rep,packed,name=slashings,proto3" json:"slashings,omitempty" ssz-size:"64"` + PreviousEpochAttestations []*PendingAttestation `protobuf:"bytes,7001,rep,name=previous_epoch_attestations,json=previousEpochAttestations,proto3" json:"previous_epoch_attestations,omitempty" ssz-max:"1024"` + CurrentEpochAttestations []*PendingAttestation `protobuf:"bytes,7002,rep,name=current_epoch_attestations,json=currentEpochAttestations,proto3" json:"current_epoch_attestations,omitempty" ssz-max:"1024"` + JustificationBits github_com_OffchainLabs_go_bitfield.Bitvector4 `protobuf:"bytes,8001,opt,name=justification_bits,json=justificationBits,proto3" json:"justification_bits,omitempty" cast-type:"github.com/OffchainLabs/go-bitfield.Bitvector4" ssz-size:"1"` + PreviousJustifiedCheckpoint *Checkpoint `protobuf:"bytes,8002,opt,name=previous_justified_checkpoint,json=previousJustifiedCheckpoint,proto3" json:"previous_justified_checkpoint,omitempty"` + CurrentJustifiedCheckpoint *Checkpoint `protobuf:"bytes,8003,opt,name=current_justified_checkpoint,json=currentJustifiedCheckpoint,proto3" json:"current_justified_checkpoint,omitempty"` + FinalizedCheckpoint *Checkpoint `protobuf:"bytes,8004,opt,name=finalized_checkpoint,json=finalizedCheckpoint,proto3" json:"finalized_checkpoint,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *BeaconState) Reset() { + *x = BeaconState{} + mi := &file_proto_prysm_v1alpha1_beacon_state_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *BeaconState) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*BeaconState) ProtoMessage() {} + +func (x *BeaconState) ProtoReflect() protoreflect.Message { + mi := &file_proto_prysm_v1alpha1_beacon_state_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use BeaconState.ProtoReflect.Descriptor instead. +func (*BeaconState) Descriptor() ([]byte, []int) { + return file_proto_prysm_v1alpha1_beacon_state_proto_rawDescGZIP(), []int{0} +} + +func (x *BeaconState) GetGenesisTime() uint64 { + if x != nil { + return x.GenesisTime + } + return 0 +} + +func (x *BeaconState) GetGenesisValidatorsRoot() []byte { + if x != nil { + return x.GenesisValidatorsRoot + } + return nil +} + +func (x *BeaconState) GetSlot() github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot { + if x != nil { + return x.Slot + } + return github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot(0) +} + +func (x *BeaconState) GetFork() *Fork { + if x != nil { + return x.Fork + } + return nil +} + +func (x *BeaconState) GetLatestBlockHeader() *BeaconBlockHeader { + if x != nil { + return x.LatestBlockHeader + } + return nil +} + +func (x *BeaconState) GetBlockRoots() [][]byte { + if x != nil { + return x.BlockRoots + } + return nil +} + +func (x *BeaconState) GetStateRoots() [][]byte { + if x != nil { + return x.StateRoots + } + return nil +} + +func (x *BeaconState) GetHistoricalRoots() [][]byte { + if x != nil { + return x.HistoricalRoots + } + return nil +} + +func (x *BeaconState) GetEth1Data() *Eth1Data { + if x != nil { + return x.Eth1Data + } + return nil +} + +func (x *BeaconState) GetEth1DataVotes() []*Eth1Data { + if x != nil { + return x.Eth1DataVotes + } + return nil +} + +func (x *BeaconState) GetEth1DepositIndex() uint64 { + if x != nil { + return x.Eth1DepositIndex + } + return 0 +} + +func (x *BeaconState) GetValidators() []*Validator { + if x != nil { + return x.Validators + } + return nil +} + +func (x *BeaconState) GetBalances() []uint64 { + if x != nil { + return x.Balances + } + return nil +} + +func (x *BeaconState) GetRandaoMixes() [][]byte { + if x != nil { + return x.RandaoMixes + } + return nil +} + +func (x *BeaconState) GetSlashings() []uint64 { + if x != nil { + return x.Slashings + } + return nil +} + +func (x *BeaconState) GetPreviousEpochAttestations() []*PendingAttestation { + if x != nil { + return x.PreviousEpochAttestations + } + return nil +} + +func (x *BeaconState) GetCurrentEpochAttestations() []*PendingAttestation { + if x != nil { + return x.CurrentEpochAttestations + } + return nil +} + +func (x *BeaconState) GetJustificationBits() github_com_OffchainLabs_go_bitfield.Bitvector4 { + if x != nil { + return x.JustificationBits + } + return github_com_OffchainLabs_go_bitfield.Bitvector4(nil) +} + +func (x *BeaconState) GetPreviousJustifiedCheckpoint() *Checkpoint { + if x != nil { + return x.PreviousJustifiedCheckpoint + } + return nil +} + +func (x *BeaconState) GetCurrentJustifiedCheckpoint() *Checkpoint { + if x != nil { + return x.CurrentJustifiedCheckpoint + } + return nil +} + +func (x *BeaconState) GetFinalizedCheckpoint() *Checkpoint { + if x != nil { + return x.FinalizedCheckpoint + } + return nil +} + +type PendingAttestation struct { + state protoimpl.MessageState `protogen:"open.v1"` + AggregationBits github_com_OffchainLabs_go_bitfield.Bitlist `protobuf:"bytes,1,opt,name=aggregation_bits,json=aggregationBits,proto3" json:"aggregation_bits,omitempty" cast-type:"github.com/OffchainLabs/go-bitfield.Bitlist" ssz-max:"2048"` + Data *AttestationData `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` + InclusionDelay github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot `protobuf:"varint,3,opt,name=inclusion_delay,json=inclusionDelay,proto3" json:"inclusion_delay,omitempty" cast-type:"github.com/OffchainLabs/prysm/v7/consensus-types/primitives.Slot"` + ProposerIndex github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex `protobuf:"varint,4,opt,name=proposer_index,json=proposerIndex,proto3" json:"proposer_index,omitempty" cast-type:"github.com/OffchainLabs/prysm/v7/consensus-types/primitives.ValidatorIndex"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *PendingAttestation) Reset() { + *x = PendingAttestation{} + mi := &file_proto_prysm_v1alpha1_beacon_state_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *PendingAttestation) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PendingAttestation) ProtoMessage() {} + +func (x *PendingAttestation) ProtoReflect() protoreflect.Message { + mi := &file_proto_prysm_v1alpha1_beacon_state_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PendingAttestation.ProtoReflect.Descriptor instead. +func (*PendingAttestation) Descriptor() ([]byte, []int) { + return file_proto_prysm_v1alpha1_beacon_state_proto_rawDescGZIP(), []int{1} +} + +func (x *PendingAttestation) GetAggregationBits() github_com_OffchainLabs_go_bitfield.Bitlist { + if x != nil { + return x.AggregationBits + } + return github_com_OffchainLabs_go_bitfield.Bitlist(nil) +} + +func (x *PendingAttestation) GetData() *AttestationData { + if x != nil { + return x.Data + } + return nil +} + +func (x *PendingAttestation) GetInclusionDelay() github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot { + if x != nil { + return x.InclusionDelay + } + return github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot(0) +} + +func (x *PendingAttestation) GetProposerIndex() github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex { + if x != nil { + return x.ProposerIndex + } + return github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex(0) +} + +type HistoricalBatch struct { + state protoimpl.MessageState `protogen:"open.v1"` + BlockRoots [][]byte `protobuf:"bytes,1,rep,name=block_roots,json=blockRoots,proto3" json:"block_roots,omitempty" ssz-size:"64,32"` + StateRoots [][]byte `protobuf:"bytes,2,rep,name=state_roots,json=stateRoots,proto3" json:"state_roots,omitempty" ssz-size:"64,32"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *HistoricalBatch) Reset() { + *x = HistoricalBatch{} + mi := &file_proto_prysm_v1alpha1_beacon_state_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *HistoricalBatch) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*HistoricalBatch) ProtoMessage() {} + +func (x *HistoricalBatch) ProtoReflect() protoreflect.Message { + mi := &file_proto_prysm_v1alpha1_beacon_state_proto_msgTypes[2] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use HistoricalBatch.ProtoReflect.Descriptor instead. +func (*HistoricalBatch) Descriptor() ([]byte, []int) { + return file_proto_prysm_v1alpha1_beacon_state_proto_rawDescGZIP(), []int{2} +} + +func (x *HistoricalBatch) GetBlockRoots() [][]byte { + if x != nil { + return x.BlockRoots + } + return nil +} + +func (x *HistoricalBatch) GetStateRoots() [][]byte { + if x != nil { + return x.StateRoots + } + return nil +} + +type StateSummary struct { + state protoimpl.MessageState `protogen:"open.v1"` + Slot github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot `protobuf:"varint,1,opt,name=slot,proto3" json:"slot,omitempty" cast-type:"github.com/OffchainLabs/prysm/v7/consensus-types/primitives.Slot"` + Root []byte `protobuf:"bytes,2,opt,name=root,proto3" json:"root,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *StateSummary) Reset() { + *x = StateSummary{} + mi := &file_proto_prysm_v1alpha1_beacon_state_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *StateSummary) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*StateSummary) ProtoMessage() {} + +func (x *StateSummary) ProtoReflect() protoreflect.Message { + mi := &file_proto_prysm_v1alpha1_beacon_state_proto_msgTypes[3] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use StateSummary.ProtoReflect.Descriptor instead. +func (*StateSummary) Descriptor() ([]byte, []int) { + return file_proto_prysm_v1alpha1_beacon_state_proto_rawDescGZIP(), []int{3} +} + +func (x *StateSummary) GetSlot() github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot { + if x != nil { + return x.Slot + } + return github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot(0) +} + +func (x *StateSummary) GetRoot() []byte { + if x != nil { + return x.Root + } + return nil +} + +type SigningData struct { + state protoimpl.MessageState `protogen:"open.v1"` + ObjectRoot []byte `protobuf:"bytes,1,opt,name=object_root,json=objectRoot,proto3" json:"object_root,omitempty" ssz-size:"32"` + Domain []byte `protobuf:"bytes,2,opt,name=domain,proto3" json:"domain,omitempty" ssz-size:"32"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SigningData) Reset() { + *x = SigningData{} + mi := &file_proto_prysm_v1alpha1_beacon_state_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SigningData) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SigningData) ProtoMessage() {} + +func (x *SigningData) ProtoReflect() protoreflect.Message { + mi := &file_proto_prysm_v1alpha1_beacon_state_proto_msgTypes[4] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SigningData.ProtoReflect.Descriptor instead. +func (*SigningData) Descriptor() ([]byte, []int) { + return file_proto_prysm_v1alpha1_beacon_state_proto_rawDescGZIP(), []int{4} +} + +func (x *SigningData) GetObjectRoot() []byte { + if x != nil { + return x.ObjectRoot + } + return nil +} + +func (x *SigningData) GetDomain() []byte { + if x != nil { + return x.Domain + } + return nil +} + +type ForkData struct { + state protoimpl.MessageState `protogen:"open.v1"` + CurrentVersion []byte `protobuf:"bytes,4,opt,name=current_version,json=currentVersion,proto3" json:"current_version,omitempty" ssz-size:"4"` + GenesisValidatorsRoot []byte `protobuf:"bytes,2,opt,name=genesis_validators_root,json=genesisValidatorsRoot,proto3" json:"genesis_validators_root,omitempty" ssz-size:"32"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ForkData) Reset() { + *x = ForkData{} + mi := &file_proto_prysm_v1alpha1_beacon_state_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ForkData) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ForkData) ProtoMessage() {} + +func (x *ForkData) ProtoReflect() protoreflect.Message { + mi := &file_proto_prysm_v1alpha1_beacon_state_proto_msgTypes[5] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ForkData.ProtoReflect.Descriptor instead. +func (*ForkData) Descriptor() ([]byte, []int) { + return file_proto_prysm_v1alpha1_beacon_state_proto_rawDescGZIP(), []int{5} +} + +func (x *ForkData) GetCurrentVersion() []byte { + if x != nil { + return x.CurrentVersion + } + return nil +} + +func (x *ForkData) GetGenesisValidatorsRoot() []byte { + if x != nil { + return x.GenesisValidatorsRoot + } + return nil +} + +type CheckPtInfo struct { + state protoimpl.MessageState `protogen:"open.v1"` + Seed []byte `protobuf:"bytes,1,opt,name=seed,proto3" json:"seed,omitempty"` + GenesisRoot []byte `protobuf:"bytes,2,opt,name=genesis_root,json=genesisRoot,proto3" json:"genesis_root,omitempty"` + ActiveIndices []uint64 `protobuf:"varint,3,rep,packed,name=active_indices,json=activeIndices,proto3" json:"active_indices,omitempty"` + PubKeys [][]byte `protobuf:"bytes,4,rep,name=pub_keys,json=pubKeys,proto3" json:"pub_keys,omitempty"` + Fork *Fork `protobuf:"bytes,5,opt,name=fork,proto3" json:"fork,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CheckPtInfo) Reset() { + *x = CheckPtInfo{} + mi := &file_proto_prysm_v1alpha1_beacon_state_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CheckPtInfo) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CheckPtInfo) ProtoMessage() {} + +func (x *CheckPtInfo) ProtoReflect() protoreflect.Message { + mi := &file_proto_prysm_v1alpha1_beacon_state_proto_msgTypes[6] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CheckPtInfo.ProtoReflect.Descriptor instead. +func (*CheckPtInfo) Descriptor() ([]byte, []int) { + return file_proto_prysm_v1alpha1_beacon_state_proto_rawDescGZIP(), []int{6} +} + +func (x *CheckPtInfo) GetSeed() []byte { + if x != nil { + return x.Seed + } + return nil +} + +func (x *CheckPtInfo) GetGenesisRoot() []byte { + if x != nil { + return x.GenesisRoot + } + return nil +} + +func (x *CheckPtInfo) GetActiveIndices() []uint64 { + if x != nil { + return x.ActiveIndices + } + return nil +} + +func (x *CheckPtInfo) GetPubKeys() [][]byte { + if x != nil { + return x.PubKeys + } + return nil +} + +func (x *CheckPtInfo) GetFork() *Fork { + if x != nil { + return x.Fork + } + return nil +} + +type DepositMessage struct { + state protoimpl.MessageState `protogen:"open.v1"` + PublicKey []byte `protobuf:"bytes,1,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty" spec-name:"pubkey" ssz-size:"48"` + WithdrawalCredentials []byte `protobuf:"bytes,2,opt,name=withdrawal_credentials,json=withdrawalCredentials,proto3" json:"withdrawal_credentials,omitempty" ssz-size:"32"` + Amount uint64 `protobuf:"varint,3,opt,name=amount,proto3" json:"amount,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *DepositMessage) Reset() { + *x = DepositMessage{} + mi := &file_proto_prysm_v1alpha1_beacon_state_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *DepositMessage) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DepositMessage) ProtoMessage() {} + +func (x *DepositMessage) ProtoReflect() protoreflect.Message { + mi := &file_proto_prysm_v1alpha1_beacon_state_proto_msgTypes[7] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DepositMessage.ProtoReflect.Descriptor instead. +func (*DepositMessage) Descriptor() ([]byte, []int) { + return file_proto_prysm_v1alpha1_beacon_state_proto_rawDescGZIP(), []int{7} +} + +func (x *DepositMessage) GetPublicKey() []byte { + if x != nil { + return x.PublicKey + } + return nil +} + +func (x *DepositMessage) GetWithdrawalCredentials() []byte { + if x != nil { + return x.WithdrawalCredentials + } + return nil +} + +func (x *DepositMessage) GetAmount() uint64 { + if x != nil { + return x.Amount + } + return 0 +} + +type PowBlock struct { + state protoimpl.MessageState `protogen:"open.v1"` + BlockHash []byte `protobuf:"bytes,1,opt,name=block_hash,json=blockHash,proto3" json:"block_hash,omitempty" ssz-size:"32"` + ParentHash []byte `protobuf:"bytes,2,opt,name=parent_hash,json=parentHash,proto3" json:"parent_hash,omitempty" ssz-size:"32"` + TotalDifficulty []byte `protobuf:"bytes,3,opt,name=total_difficulty,json=totalDifficulty,proto3" json:"total_difficulty,omitempty" ssz-size:"32"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *PowBlock) Reset() { + *x = PowBlock{} + mi := &file_proto_prysm_v1alpha1_beacon_state_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *PowBlock) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PowBlock) ProtoMessage() {} + +func (x *PowBlock) ProtoReflect() protoreflect.Message { + mi := &file_proto_prysm_v1alpha1_beacon_state_proto_msgTypes[8] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PowBlock.ProtoReflect.Descriptor instead. +func (*PowBlock) Descriptor() ([]byte, []int) { + return file_proto_prysm_v1alpha1_beacon_state_proto_rawDescGZIP(), []int{8} +} + +func (x *PowBlock) GetBlockHash() []byte { + if x != nil { + return x.BlockHash + } + return nil +} + +func (x *PowBlock) GetParentHash() []byte { + if x != nil { + return x.ParentHash + } + return nil +} + +func (x *PowBlock) GetTotalDifficulty() []byte { + if x != nil { + return x.TotalDifficulty + } + return nil +} + +type BeaconStateAltair struct { + state protoimpl.MessageState `protogen:"open.v1"` + GenesisTime uint64 `protobuf:"varint,1001,opt,name=genesis_time,json=genesisTime,proto3" json:"genesis_time,omitempty"` + GenesisValidatorsRoot []byte `protobuf:"bytes,1002,opt,name=genesis_validators_root,json=genesisValidatorsRoot,proto3" json:"genesis_validators_root,omitempty" ssz-size:"32"` + Slot github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot `protobuf:"varint,1003,opt,name=slot,proto3" json:"slot,omitempty" cast-type:"github.com/OffchainLabs/prysm/v7/consensus-types/primitives.Slot"` + Fork *Fork `protobuf:"bytes,1004,opt,name=fork,proto3" json:"fork,omitempty"` + LatestBlockHeader *BeaconBlockHeader `protobuf:"bytes,2001,opt,name=latest_block_header,json=latestBlockHeader,proto3" json:"latest_block_header,omitempty"` + BlockRoots [][]byte `protobuf:"bytes,2002,rep,name=block_roots,json=blockRoots,proto3" json:"block_roots,omitempty" ssz-size:"64,32"` + StateRoots [][]byte `protobuf:"bytes,2003,rep,name=state_roots,json=stateRoots,proto3" json:"state_roots,omitempty" ssz-size:"64,32"` + HistoricalRoots [][]byte `protobuf:"bytes,2004,rep,name=historical_roots,json=historicalRoots,proto3" json:"historical_roots,omitempty" ssz-max:"16777216" ssz-size:"?,32"` + Eth1Data *Eth1Data `protobuf:"bytes,3001,opt,name=eth1_data,json=eth1Data,proto3" json:"eth1_data,omitempty"` + Eth1DataVotes []*Eth1Data `protobuf:"bytes,3002,rep,name=eth1_data_votes,json=eth1DataVotes,proto3" json:"eth1_data_votes,omitempty" ssz-max:"32"` + Eth1DepositIndex uint64 `protobuf:"varint,3003,opt,name=eth1_deposit_index,json=eth1DepositIndex,proto3" json:"eth1_deposit_index,omitempty"` + Validators []*Validator `protobuf:"bytes,4001,rep,name=validators,proto3" json:"validators,omitempty" ssz-max:"1099511627776"` + Balances []uint64 `protobuf:"varint,4002,rep,packed,name=balances,proto3" json:"balances,omitempty" ssz-max:"1099511627776"` + RandaoMixes [][]byte `protobuf:"bytes,5001,rep,name=randao_mixes,json=randaoMixes,proto3" json:"randao_mixes,omitempty" ssz-size:"64,32"` + Slashings []uint64 `protobuf:"varint,6001,rep,packed,name=slashings,proto3" json:"slashings,omitempty" ssz-size:"64"` + PreviousEpochParticipation []byte `protobuf:"bytes,7001,opt,name=previous_epoch_participation,json=previousEpochParticipation,proto3" json:"previous_epoch_participation,omitempty" ssz-max:"1099511627776"` + CurrentEpochParticipation []byte `protobuf:"bytes,7002,opt,name=current_epoch_participation,json=currentEpochParticipation,proto3" json:"current_epoch_participation,omitempty" ssz-max:"1099511627776"` + JustificationBits github_com_OffchainLabs_go_bitfield.Bitvector4 `protobuf:"bytes,8001,opt,name=justification_bits,json=justificationBits,proto3" json:"justification_bits,omitempty" cast-type:"github.com/OffchainLabs/go-bitfield.Bitvector4" ssz-size:"1"` + PreviousJustifiedCheckpoint *Checkpoint `protobuf:"bytes,8002,opt,name=previous_justified_checkpoint,json=previousJustifiedCheckpoint,proto3" json:"previous_justified_checkpoint,omitempty"` + CurrentJustifiedCheckpoint *Checkpoint `protobuf:"bytes,8003,opt,name=current_justified_checkpoint,json=currentJustifiedCheckpoint,proto3" json:"current_justified_checkpoint,omitempty"` + FinalizedCheckpoint *Checkpoint `protobuf:"bytes,8004,opt,name=finalized_checkpoint,json=finalizedCheckpoint,proto3" json:"finalized_checkpoint,omitempty"` + InactivityScores []uint64 `protobuf:"varint,9001,rep,packed,name=inactivity_scores,json=inactivityScores,proto3" json:"inactivity_scores,omitempty" ssz-max:"1099511627776"` + CurrentSyncCommittee *SyncCommittee `protobuf:"bytes,9002,opt,name=current_sync_committee,json=currentSyncCommittee,proto3" json:"current_sync_committee,omitempty"` + NextSyncCommittee *SyncCommittee `protobuf:"bytes,9003,opt,name=next_sync_committee,json=nextSyncCommittee,proto3" json:"next_sync_committee,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *BeaconStateAltair) Reset() { + *x = BeaconStateAltair{} + mi := &file_proto_prysm_v1alpha1_beacon_state_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *BeaconStateAltair) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*BeaconStateAltair) ProtoMessage() {} + +func (x *BeaconStateAltair) ProtoReflect() protoreflect.Message { + mi := &file_proto_prysm_v1alpha1_beacon_state_proto_msgTypes[9] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use BeaconStateAltair.ProtoReflect.Descriptor instead. +func (*BeaconStateAltair) Descriptor() ([]byte, []int) { + return file_proto_prysm_v1alpha1_beacon_state_proto_rawDescGZIP(), []int{9} +} + +func (x *BeaconStateAltair) GetGenesisTime() uint64 { + if x != nil { + return x.GenesisTime + } + return 0 +} + +func (x *BeaconStateAltair) GetGenesisValidatorsRoot() []byte { + if x != nil { + return x.GenesisValidatorsRoot + } + return nil +} + +func (x *BeaconStateAltair) GetSlot() github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot { + if x != nil { + return x.Slot + } + return github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot(0) +} + +func (x *BeaconStateAltair) GetFork() *Fork { + if x != nil { + return x.Fork + } + return nil +} + +func (x *BeaconStateAltair) GetLatestBlockHeader() *BeaconBlockHeader { + if x != nil { + return x.LatestBlockHeader + } + return nil +} + +func (x *BeaconStateAltair) GetBlockRoots() [][]byte { + if x != nil { + return x.BlockRoots + } + return nil +} + +func (x *BeaconStateAltair) GetStateRoots() [][]byte { + if x != nil { + return x.StateRoots + } + return nil +} + +func (x *BeaconStateAltair) GetHistoricalRoots() [][]byte { + if x != nil { + return x.HistoricalRoots + } + return nil +} + +func (x *BeaconStateAltair) GetEth1Data() *Eth1Data { + if x != nil { + return x.Eth1Data + } + return nil +} + +func (x *BeaconStateAltair) GetEth1DataVotes() []*Eth1Data { + if x != nil { + return x.Eth1DataVotes + } + return nil +} + +func (x *BeaconStateAltair) GetEth1DepositIndex() uint64 { + if x != nil { + return x.Eth1DepositIndex + } + return 0 +} + +func (x *BeaconStateAltair) GetValidators() []*Validator { + if x != nil { + return x.Validators + } + return nil +} + +func (x *BeaconStateAltair) GetBalances() []uint64 { + if x != nil { + return x.Balances + } + return nil +} + +func (x *BeaconStateAltair) GetRandaoMixes() [][]byte { + if x != nil { + return x.RandaoMixes + } + return nil +} + +func (x *BeaconStateAltair) GetSlashings() []uint64 { + if x != nil { + return x.Slashings + } + return nil +} + +func (x *BeaconStateAltair) GetPreviousEpochParticipation() []byte { + if x != nil { + return x.PreviousEpochParticipation + } + return nil +} + +func (x *BeaconStateAltair) GetCurrentEpochParticipation() []byte { + if x != nil { + return x.CurrentEpochParticipation + } + return nil +} + +func (x *BeaconStateAltair) GetJustificationBits() github_com_OffchainLabs_go_bitfield.Bitvector4 { + if x != nil { + return x.JustificationBits + } + return github_com_OffchainLabs_go_bitfield.Bitvector4(nil) +} + +func (x *BeaconStateAltair) GetPreviousJustifiedCheckpoint() *Checkpoint { + if x != nil { + return x.PreviousJustifiedCheckpoint + } + return nil +} + +func (x *BeaconStateAltair) GetCurrentJustifiedCheckpoint() *Checkpoint { + if x != nil { + return x.CurrentJustifiedCheckpoint + } + return nil +} + +func (x *BeaconStateAltair) GetFinalizedCheckpoint() *Checkpoint { + if x != nil { + return x.FinalizedCheckpoint + } + return nil +} + +func (x *BeaconStateAltair) GetInactivityScores() []uint64 { + if x != nil { + return x.InactivityScores + } + return nil +} + +func (x *BeaconStateAltair) GetCurrentSyncCommittee() *SyncCommittee { + if x != nil { + return x.CurrentSyncCommittee + } + return nil +} + +func (x *BeaconStateAltair) GetNextSyncCommittee() *SyncCommittee { + if x != nil { + return x.NextSyncCommittee + } + return nil +} + +type SyncAggregatorSelectionData struct { + state protoimpl.MessageState `protogen:"open.v1"` + Slot github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot `protobuf:"varint,1,opt,name=slot,proto3" json:"slot,omitempty" cast-type:"github.com/OffchainLabs/prysm/v7/consensus-types/primitives.Slot"` + SubcommitteeIndex uint64 `protobuf:"varint,2,opt,name=subcommittee_index,json=subcommitteeIndex,proto3" json:"subcommittee_index,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SyncAggregatorSelectionData) Reset() { + *x = SyncAggregatorSelectionData{} + mi := &file_proto_prysm_v1alpha1_beacon_state_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SyncAggregatorSelectionData) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SyncAggregatorSelectionData) ProtoMessage() {} + +func (x *SyncAggregatorSelectionData) ProtoReflect() protoreflect.Message { + mi := &file_proto_prysm_v1alpha1_beacon_state_proto_msgTypes[10] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SyncAggregatorSelectionData.ProtoReflect.Descriptor instead. +func (*SyncAggregatorSelectionData) Descriptor() ([]byte, []int) { + return file_proto_prysm_v1alpha1_beacon_state_proto_rawDescGZIP(), []int{10} +} + +func (x *SyncAggregatorSelectionData) GetSlot() github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot { + if x != nil { + return x.Slot + } + return github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot(0) +} + +func (x *SyncAggregatorSelectionData) GetSubcommitteeIndex() uint64 { + if x != nil { + return x.SubcommitteeIndex + } + return 0 +} + +type BeaconStateBellatrix struct { + state protoimpl.MessageState `protogen:"open.v1"` + GenesisTime uint64 `protobuf:"varint,1001,opt,name=genesis_time,json=genesisTime,proto3" json:"genesis_time,omitempty"` + GenesisValidatorsRoot []byte `protobuf:"bytes,1002,opt,name=genesis_validators_root,json=genesisValidatorsRoot,proto3" json:"genesis_validators_root,omitempty" ssz-size:"32"` + Slot github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot `protobuf:"varint,1003,opt,name=slot,proto3" json:"slot,omitempty" cast-type:"github.com/OffchainLabs/prysm/v7/consensus-types/primitives.Slot"` + Fork *Fork `protobuf:"bytes,1004,opt,name=fork,proto3" json:"fork,omitempty"` + LatestBlockHeader *BeaconBlockHeader `protobuf:"bytes,2001,opt,name=latest_block_header,json=latestBlockHeader,proto3" json:"latest_block_header,omitempty"` + BlockRoots [][]byte `protobuf:"bytes,2002,rep,name=block_roots,json=blockRoots,proto3" json:"block_roots,omitempty" ssz-size:"64,32"` + StateRoots [][]byte `protobuf:"bytes,2003,rep,name=state_roots,json=stateRoots,proto3" json:"state_roots,omitempty" ssz-size:"64,32"` + HistoricalRoots [][]byte `protobuf:"bytes,2004,rep,name=historical_roots,json=historicalRoots,proto3" json:"historical_roots,omitempty" ssz-max:"16777216" ssz-size:"?,32"` + Eth1Data *Eth1Data `protobuf:"bytes,3001,opt,name=eth1_data,json=eth1Data,proto3" json:"eth1_data,omitempty"` + Eth1DataVotes []*Eth1Data `protobuf:"bytes,3002,rep,name=eth1_data_votes,json=eth1DataVotes,proto3" json:"eth1_data_votes,omitempty" ssz-max:"32"` + Eth1DepositIndex uint64 `protobuf:"varint,3003,opt,name=eth1_deposit_index,json=eth1DepositIndex,proto3" json:"eth1_deposit_index,omitempty"` + Validators []*Validator `protobuf:"bytes,4001,rep,name=validators,proto3" json:"validators,omitempty" ssz-max:"1099511627776"` + Balances []uint64 `protobuf:"varint,4002,rep,packed,name=balances,proto3" json:"balances,omitempty" ssz-max:"1099511627776"` + RandaoMixes [][]byte `protobuf:"bytes,5001,rep,name=randao_mixes,json=randaoMixes,proto3" json:"randao_mixes,omitempty" ssz-size:"64,32"` + Slashings []uint64 `protobuf:"varint,6001,rep,packed,name=slashings,proto3" json:"slashings,omitempty" ssz-size:"64"` + PreviousEpochParticipation []byte `protobuf:"bytes,7001,opt,name=previous_epoch_participation,json=previousEpochParticipation,proto3" json:"previous_epoch_participation,omitempty" ssz-max:"1099511627776"` + CurrentEpochParticipation []byte `protobuf:"bytes,7002,opt,name=current_epoch_participation,json=currentEpochParticipation,proto3" json:"current_epoch_participation,omitempty" ssz-max:"1099511627776"` + JustificationBits github_com_OffchainLabs_go_bitfield.Bitvector4 `protobuf:"bytes,8001,opt,name=justification_bits,json=justificationBits,proto3" json:"justification_bits,omitempty" cast-type:"github.com/OffchainLabs/go-bitfield.Bitvector4" ssz-size:"1"` + PreviousJustifiedCheckpoint *Checkpoint `protobuf:"bytes,8002,opt,name=previous_justified_checkpoint,json=previousJustifiedCheckpoint,proto3" json:"previous_justified_checkpoint,omitempty"` + CurrentJustifiedCheckpoint *Checkpoint `protobuf:"bytes,8003,opt,name=current_justified_checkpoint,json=currentJustifiedCheckpoint,proto3" json:"current_justified_checkpoint,omitempty"` + FinalizedCheckpoint *Checkpoint `protobuf:"bytes,8004,opt,name=finalized_checkpoint,json=finalizedCheckpoint,proto3" json:"finalized_checkpoint,omitempty"` + InactivityScores []uint64 `protobuf:"varint,9001,rep,packed,name=inactivity_scores,json=inactivityScores,proto3" json:"inactivity_scores,omitempty" ssz-max:"1099511627776"` + CurrentSyncCommittee *SyncCommittee `protobuf:"bytes,9002,opt,name=current_sync_committee,json=currentSyncCommittee,proto3" json:"current_sync_committee,omitempty"` + NextSyncCommittee *SyncCommittee `protobuf:"bytes,9003,opt,name=next_sync_committee,json=nextSyncCommittee,proto3" json:"next_sync_committee,omitempty"` + LatestExecutionPayloadHeader *v1.ExecutionPayloadHeader `protobuf:"bytes,10001,opt,name=latest_execution_payload_header,json=latestExecutionPayloadHeader,proto3" json:"latest_execution_payload_header,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *BeaconStateBellatrix) Reset() { + *x = BeaconStateBellatrix{} + mi := &file_proto_prysm_v1alpha1_beacon_state_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *BeaconStateBellatrix) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*BeaconStateBellatrix) ProtoMessage() {} + +func (x *BeaconStateBellatrix) ProtoReflect() protoreflect.Message { + mi := &file_proto_prysm_v1alpha1_beacon_state_proto_msgTypes[11] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use BeaconStateBellatrix.ProtoReflect.Descriptor instead. +func (*BeaconStateBellatrix) Descriptor() ([]byte, []int) { + return file_proto_prysm_v1alpha1_beacon_state_proto_rawDescGZIP(), []int{11} +} + +func (x *BeaconStateBellatrix) GetGenesisTime() uint64 { + if x != nil { + return x.GenesisTime + } + return 0 +} + +func (x *BeaconStateBellatrix) GetGenesisValidatorsRoot() []byte { + if x != nil { + return x.GenesisValidatorsRoot + } + return nil +} + +func (x *BeaconStateBellatrix) GetSlot() github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot { + if x != nil { + return x.Slot + } + return github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot(0) +} + +func (x *BeaconStateBellatrix) GetFork() *Fork { + if x != nil { + return x.Fork + } + return nil +} + +func (x *BeaconStateBellatrix) GetLatestBlockHeader() *BeaconBlockHeader { + if x != nil { + return x.LatestBlockHeader + } + return nil +} + +func (x *BeaconStateBellatrix) GetBlockRoots() [][]byte { + if x != nil { + return x.BlockRoots + } + return nil +} + +func (x *BeaconStateBellatrix) GetStateRoots() [][]byte { + if x != nil { + return x.StateRoots + } + return nil +} + +func (x *BeaconStateBellatrix) GetHistoricalRoots() [][]byte { + if x != nil { + return x.HistoricalRoots + } + return nil +} + +func (x *BeaconStateBellatrix) GetEth1Data() *Eth1Data { + if x != nil { + return x.Eth1Data + } + return nil +} + +func (x *BeaconStateBellatrix) GetEth1DataVotes() []*Eth1Data { + if x != nil { + return x.Eth1DataVotes + } + return nil +} + +func (x *BeaconStateBellatrix) GetEth1DepositIndex() uint64 { + if x != nil { + return x.Eth1DepositIndex + } + return 0 +} + +func (x *BeaconStateBellatrix) GetValidators() []*Validator { + if x != nil { + return x.Validators + } + return nil +} + +func (x *BeaconStateBellatrix) GetBalances() []uint64 { + if x != nil { + return x.Balances + } + return nil +} + +func (x *BeaconStateBellatrix) GetRandaoMixes() [][]byte { + if x != nil { + return x.RandaoMixes + } + return nil +} + +func (x *BeaconStateBellatrix) GetSlashings() []uint64 { + if x != nil { + return x.Slashings + } + return nil +} + +func (x *BeaconStateBellatrix) GetPreviousEpochParticipation() []byte { + if x != nil { + return x.PreviousEpochParticipation + } + return nil +} + +func (x *BeaconStateBellatrix) GetCurrentEpochParticipation() []byte { + if x != nil { + return x.CurrentEpochParticipation + } + return nil +} + +func (x *BeaconStateBellatrix) GetJustificationBits() github_com_OffchainLabs_go_bitfield.Bitvector4 { + if x != nil { + return x.JustificationBits + } + return github_com_OffchainLabs_go_bitfield.Bitvector4(nil) +} + +func (x *BeaconStateBellatrix) GetPreviousJustifiedCheckpoint() *Checkpoint { + if x != nil { + return x.PreviousJustifiedCheckpoint + } + return nil +} + +func (x *BeaconStateBellatrix) GetCurrentJustifiedCheckpoint() *Checkpoint { + if x != nil { + return x.CurrentJustifiedCheckpoint + } + return nil +} + +func (x *BeaconStateBellatrix) GetFinalizedCheckpoint() *Checkpoint { + if x != nil { + return x.FinalizedCheckpoint + } + return nil +} + +func (x *BeaconStateBellatrix) GetInactivityScores() []uint64 { + if x != nil { + return x.InactivityScores + } + return nil +} + +func (x *BeaconStateBellatrix) GetCurrentSyncCommittee() *SyncCommittee { + if x != nil { + return x.CurrentSyncCommittee + } + return nil +} + +func (x *BeaconStateBellatrix) GetNextSyncCommittee() *SyncCommittee { + if x != nil { + return x.NextSyncCommittee + } + return nil +} + +func (x *BeaconStateBellatrix) GetLatestExecutionPayloadHeader() *v1.ExecutionPayloadHeader { + if x != nil { + return x.LatestExecutionPayloadHeader + } + return nil +} + +type BeaconStateCapella struct { + state protoimpl.MessageState `protogen:"open.v1"` + GenesisTime uint64 `protobuf:"varint,1001,opt,name=genesis_time,json=genesisTime,proto3" json:"genesis_time,omitempty"` + GenesisValidatorsRoot []byte `protobuf:"bytes,1002,opt,name=genesis_validators_root,json=genesisValidatorsRoot,proto3" json:"genesis_validators_root,omitempty" ssz-size:"32"` + Slot github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot `protobuf:"varint,1003,opt,name=slot,proto3" json:"slot,omitempty" cast-type:"github.com/OffchainLabs/prysm/v7/consensus-types/primitives.Slot"` + Fork *Fork `protobuf:"bytes,1004,opt,name=fork,proto3" json:"fork,omitempty"` + LatestBlockHeader *BeaconBlockHeader `protobuf:"bytes,2001,opt,name=latest_block_header,json=latestBlockHeader,proto3" json:"latest_block_header,omitempty"` + BlockRoots [][]byte `protobuf:"bytes,2002,rep,name=block_roots,json=blockRoots,proto3" json:"block_roots,omitempty" ssz-size:"64,32"` + StateRoots [][]byte `protobuf:"bytes,2003,rep,name=state_roots,json=stateRoots,proto3" json:"state_roots,omitempty" ssz-size:"64,32"` + HistoricalRoots [][]byte `protobuf:"bytes,2004,rep,name=historical_roots,json=historicalRoots,proto3" json:"historical_roots,omitempty" ssz-max:"16777216" ssz-size:"?,32"` + Eth1Data *Eth1Data `protobuf:"bytes,3001,opt,name=eth1_data,json=eth1Data,proto3" json:"eth1_data,omitempty"` + Eth1DataVotes []*Eth1Data `protobuf:"bytes,3002,rep,name=eth1_data_votes,json=eth1DataVotes,proto3" json:"eth1_data_votes,omitempty" ssz-max:"32"` + Eth1DepositIndex uint64 `protobuf:"varint,3003,opt,name=eth1_deposit_index,json=eth1DepositIndex,proto3" json:"eth1_deposit_index,omitempty"` + Validators []*Validator `protobuf:"bytes,4001,rep,name=validators,proto3" json:"validators,omitempty" ssz-max:"1099511627776"` + Balances []uint64 `protobuf:"varint,4002,rep,packed,name=balances,proto3" json:"balances,omitempty" ssz-max:"1099511627776"` + RandaoMixes [][]byte `protobuf:"bytes,5001,rep,name=randao_mixes,json=randaoMixes,proto3" json:"randao_mixes,omitempty" ssz-size:"64,32"` + Slashings []uint64 `protobuf:"varint,6001,rep,packed,name=slashings,proto3" json:"slashings,omitempty" ssz-size:"64"` + PreviousEpochParticipation []byte `protobuf:"bytes,7001,opt,name=previous_epoch_participation,json=previousEpochParticipation,proto3" json:"previous_epoch_participation,omitempty" ssz-max:"1099511627776"` + CurrentEpochParticipation []byte `protobuf:"bytes,7002,opt,name=current_epoch_participation,json=currentEpochParticipation,proto3" json:"current_epoch_participation,omitempty" ssz-max:"1099511627776"` + JustificationBits github_com_OffchainLabs_go_bitfield.Bitvector4 `protobuf:"bytes,8001,opt,name=justification_bits,json=justificationBits,proto3" json:"justification_bits,omitempty" cast-type:"github.com/OffchainLabs/go-bitfield.Bitvector4" ssz-size:"1"` + PreviousJustifiedCheckpoint *Checkpoint `protobuf:"bytes,8002,opt,name=previous_justified_checkpoint,json=previousJustifiedCheckpoint,proto3" json:"previous_justified_checkpoint,omitempty"` + CurrentJustifiedCheckpoint *Checkpoint `protobuf:"bytes,8003,opt,name=current_justified_checkpoint,json=currentJustifiedCheckpoint,proto3" json:"current_justified_checkpoint,omitempty"` + FinalizedCheckpoint *Checkpoint `protobuf:"bytes,8004,opt,name=finalized_checkpoint,json=finalizedCheckpoint,proto3" json:"finalized_checkpoint,omitempty"` + InactivityScores []uint64 `protobuf:"varint,9001,rep,packed,name=inactivity_scores,json=inactivityScores,proto3" json:"inactivity_scores,omitempty" ssz-max:"1099511627776"` + CurrentSyncCommittee *SyncCommittee `protobuf:"bytes,9002,opt,name=current_sync_committee,json=currentSyncCommittee,proto3" json:"current_sync_committee,omitempty"` + NextSyncCommittee *SyncCommittee `protobuf:"bytes,9003,opt,name=next_sync_committee,json=nextSyncCommittee,proto3" json:"next_sync_committee,omitempty"` + LatestExecutionPayloadHeader *v1.ExecutionPayloadHeaderCapella `protobuf:"bytes,10001,opt,name=latest_execution_payload_header,json=latestExecutionPayloadHeader,proto3" json:"latest_execution_payload_header,omitempty"` + NextWithdrawalIndex uint64 `protobuf:"varint,11001,opt,name=next_withdrawal_index,json=nextWithdrawalIndex,proto3" json:"next_withdrawal_index,omitempty"` + NextWithdrawalValidatorIndex github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex `protobuf:"varint,11002,opt,name=next_withdrawal_validator_index,json=nextWithdrawalValidatorIndex,proto3" json:"next_withdrawal_validator_index,omitempty" cast-type:"github.com/OffchainLabs/prysm/v7/consensus-types/primitives.ValidatorIndex"` + HistoricalSummaries []*HistoricalSummary `protobuf:"bytes,11003,rep,name=historical_summaries,json=historicalSummaries,proto3" json:"historical_summaries,omitempty" ssz-max:"16777216"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *BeaconStateCapella) Reset() { + *x = BeaconStateCapella{} + mi := &file_proto_prysm_v1alpha1_beacon_state_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *BeaconStateCapella) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*BeaconStateCapella) ProtoMessage() {} + +func (x *BeaconStateCapella) ProtoReflect() protoreflect.Message { + mi := &file_proto_prysm_v1alpha1_beacon_state_proto_msgTypes[12] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use BeaconStateCapella.ProtoReflect.Descriptor instead. +func (*BeaconStateCapella) Descriptor() ([]byte, []int) { + return file_proto_prysm_v1alpha1_beacon_state_proto_rawDescGZIP(), []int{12} +} + +func (x *BeaconStateCapella) GetGenesisTime() uint64 { + if x != nil { + return x.GenesisTime + } + return 0 +} + +func (x *BeaconStateCapella) GetGenesisValidatorsRoot() []byte { + if x != nil { + return x.GenesisValidatorsRoot + } + return nil +} + +func (x *BeaconStateCapella) GetSlot() github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot { + if x != nil { + return x.Slot + } + return github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot(0) +} + +func (x *BeaconStateCapella) GetFork() *Fork { + if x != nil { + return x.Fork + } + return nil +} + +func (x *BeaconStateCapella) GetLatestBlockHeader() *BeaconBlockHeader { + if x != nil { + return x.LatestBlockHeader + } + return nil +} + +func (x *BeaconStateCapella) GetBlockRoots() [][]byte { + if x != nil { + return x.BlockRoots + } + return nil +} + +func (x *BeaconStateCapella) GetStateRoots() [][]byte { + if x != nil { + return x.StateRoots + } + return nil +} + +func (x *BeaconStateCapella) GetHistoricalRoots() [][]byte { + if x != nil { + return x.HistoricalRoots + } + return nil +} + +func (x *BeaconStateCapella) GetEth1Data() *Eth1Data { + if x != nil { + return x.Eth1Data + } + return nil +} + +func (x *BeaconStateCapella) GetEth1DataVotes() []*Eth1Data { + if x != nil { + return x.Eth1DataVotes + } + return nil +} + +func (x *BeaconStateCapella) GetEth1DepositIndex() uint64 { + if x != nil { + return x.Eth1DepositIndex + } + return 0 +} + +func (x *BeaconStateCapella) GetValidators() []*Validator { + if x != nil { + return x.Validators + } + return nil +} + +func (x *BeaconStateCapella) GetBalances() []uint64 { + if x != nil { + return x.Balances + } + return nil +} + +func (x *BeaconStateCapella) GetRandaoMixes() [][]byte { + if x != nil { + return x.RandaoMixes + } + return nil +} + +func (x *BeaconStateCapella) GetSlashings() []uint64 { + if x != nil { + return x.Slashings + } + return nil +} + +func (x *BeaconStateCapella) GetPreviousEpochParticipation() []byte { + if x != nil { + return x.PreviousEpochParticipation + } + return nil +} + +func (x *BeaconStateCapella) GetCurrentEpochParticipation() []byte { + if x != nil { + return x.CurrentEpochParticipation + } + return nil +} + +func (x *BeaconStateCapella) GetJustificationBits() github_com_OffchainLabs_go_bitfield.Bitvector4 { + if x != nil { + return x.JustificationBits + } + return github_com_OffchainLabs_go_bitfield.Bitvector4(nil) +} + +func (x *BeaconStateCapella) GetPreviousJustifiedCheckpoint() *Checkpoint { + if x != nil { + return x.PreviousJustifiedCheckpoint + } + return nil +} + +func (x *BeaconStateCapella) GetCurrentJustifiedCheckpoint() *Checkpoint { + if x != nil { + return x.CurrentJustifiedCheckpoint + } + return nil +} + +func (x *BeaconStateCapella) GetFinalizedCheckpoint() *Checkpoint { + if x != nil { + return x.FinalizedCheckpoint + } + return nil +} + +func (x *BeaconStateCapella) GetInactivityScores() []uint64 { + if x != nil { + return x.InactivityScores + } + return nil +} + +func (x *BeaconStateCapella) GetCurrentSyncCommittee() *SyncCommittee { + if x != nil { + return x.CurrentSyncCommittee + } + return nil +} + +func (x *BeaconStateCapella) GetNextSyncCommittee() *SyncCommittee { + if x != nil { + return x.NextSyncCommittee + } + return nil +} + +func (x *BeaconStateCapella) GetLatestExecutionPayloadHeader() *v1.ExecutionPayloadHeaderCapella { + if x != nil { + return x.LatestExecutionPayloadHeader + } + return nil +} + +func (x *BeaconStateCapella) GetNextWithdrawalIndex() uint64 { + if x != nil { + return x.NextWithdrawalIndex + } + return 0 +} + +func (x *BeaconStateCapella) GetNextWithdrawalValidatorIndex() github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex { + if x != nil { + return x.NextWithdrawalValidatorIndex + } + return github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex(0) +} + +func (x *BeaconStateCapella) GetHistoricalSummaries() []*HistoricalSummary { + if x != nil { + return x.HistoricalSummaries + } + return nil +} + +type BeaconStateDeneb struct { + state protoimpl.MessageState `protogen:"open.v1"` + GenesisTime uint64 `protobuf:"varint,1001,opt,name=genesis_time,json=genesisTime,proto3" json:"genesis_time,omitempty"` + GenesisValidatorsRoot []byte `protobuf:"bytes,1002,opt,name=genesis_validators_root,json=genesisValidatorsRoot,proto3" json:"genesis_validators_root,omitempty" ssz-size:"32"` + Slot github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot `protobuf:"varint,1003,opt,name=slot,proto3" json:"slot,omitempty" cast-type:"github.com/OffchainLabs/prysm/v7/consensus-types/primitives.Slot"` + Fork *Fork `protobuf:"bytes,1004,opt,name=fork,proto3" json:"fork,omitempty"` + LatestBlockHeader *BeaconBlockHeader `protobuf:"bytes,2001,opt,name=latest_block_header,json=latestBlockHeader,proto3" json:"latest_block_header,omitempty"` + BlockRoots [][]byte `protobuf:"bytes,2002,rep,name=block_roots,json=blockRoots,proto3" json:"block_roots,omitempty" ssz-size:"64,32"` + StateRoots [][]byte `protobuf:"bytes,2003,rep,name=state_roots,json=stateRoots,proto3" json:"state_roots,omitempty" ssz-size:"64,32"` + HistoricalRoots [][]byte `protobuf:"bytes,2004,rep,name=historical_roots,json=historicalRoots,proto3" json:"historical_roots,omitempty" ssz-max:"16777216" ssz-size:"?,32"` + Eth1Data *Eth1Data `protobuf:"bytes,3001,opt,name=eth1_data,json=eth1Data,proto3" json:"eth1_data,omitempty"` + Eth1DataVotes []*Eth1Data `protobuf:"bytes,3002,rep,name=eth1_data_votes,json=eth1DataVotes,proto3" json:"eth1_data_votes,omitempty" ssz-max:"32"` + Eth1DepositIndex uint64 `protobuf:"varint,3003,opt,name=eth1_deposit_index,json=eth1DepositIndex,proto3" json:"eth1_deposit_index,omitempty"` + Validators []*Validator `protobuf:"bytes,4001,rep,name=validators,proto3" json:"validators,omitempty" ssz-max:"1099511627776"` + Balances []uint64 `protobuf:"varint,4002,rep,packed,name=balances,proto3" json:"balances,omitempty" ssz-max:"1099511627776"` + RandaoMixes [][]byte `protobuf:"bytes,5001,rep,name=randao_mixes,json=randaoMixes,proto3" json:"randao_mixes,omitempty" ssz-size:"64,32"` + Slashings []uint64 `protobuf:"varint,6001,rep,packed,name=slashings,proto3" json:"slashings,omitempty" ssz-size:"64"` + PreviousEpochParticipation []byte `protobuf:"bytes,7001,opt,name=previous_epoch_participation,json=previousEpochParticipation,proto3" json:"previous_epoch_participation,omitempty" ssz-max:"1099511627776"` + CurrentEpochParticipation []byte `protobuf:"bytes,7002,opt,name=current_epoch_participation,json=currentEpochParticipation,proto3" json:"current_epoch_participation,omitempty" ssz-max:"1099511627776"` + JustificationBits github_com_OffchainLabs_go_bitfield.Bitvector4 `protobuf:"bytes,8001,opt,name=justification_bits,json=justificationBits,proto3" json:"justification_bits,omitempty" cast-type:"github.com/OffchainLabs/go-bitfield.Bitvector4" ssz-size:"1"` + PreviousJustifiedCheckpoint *Checkpoint `protobuf:"bytes,8002,opt,name=previous_justified_checkpoint,json=previousJustifiedCheckpoint,proto3" json:"previous_justified_checkpoint,omitempty"` + CurrentJustifiedCheckpoint *Checkpoint `protobuf:"bytes,8003,opt,name=current_justified_checkpoint,json=currentJustifiedCheckpoint,proto3" json:"current_justified_checkpoint,omitempty"` + FinalizedCheckpoint *Checkpoint `protobuf:"bytes,8004,opt,name=finalized_checkpoint,json=finalizedCheckpoint,proto3" json:"finalized_checkpoint,omitempty"` + InactivityScores []uint64 `protobuf:"varint,9001,rep,packed,name=inactivity_scores,json=inactivityScores,proto3" json:"inactivity_scores,omitempty" ssz-max:"1099511627776"` + CurrentSyncCommittee *SyncCommittee `protobuf:"bytes,9002,opt,name=current_sync_committee,json=currentSyncCommittee,proto3" json:"current_sync_committee,omitempty"` + NextSyncCommittee *SyncCommittee `protobuf:"bytes,9003,opt,name=next_sync_committee,json=nextSyncCommittee,proto3" json:"next_sync_committee,omitempty"` + LatestExecutionPayloadHeader *v1.ExecutionPayloadHeaderDeneb `protobuf:"bytes,10001,opt,name=latest_execution_payload_header,json=latestExecutionPayloadHeader,proto3" json:"latest_execution_payload_header,omitempty"` + NextWithdrawalIndex uint64 `protobuf:"varint,11001,opt,name=next_withdrawal_index,json=nextWithdrawalIndex,proto3" json:"next_withdrawal_index,omitempty"` + NextWithdrawalValidatorIndex github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex `protobuf:"varint,11002,opt,name=next_withdrawal_validator_index,json=nextWithdrawalValidatorIndex,proto3" json:"next_withdrawal_validator_index,omitempty" cast-type:"github.com/OffchainLabs/prysm/v7/consensus-types/primitives.ValidatorIndex"` + HistoricalSummaries []*HistoricalSummary `protobuf:"bytes,11003,rep,name=historical_summaries,json=historicalSummaries,proto3" json:"historical_summaries,omitempty" ssz-max:"16777216"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *BeaconStateDeneb) Reset() { + *x = BeaconStateDeneb{} + mi := &file_proto_prysm_v1alpha1_beacon_state_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *BeaconStateDeneb) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*BeaconStateDeneb) ProtoMessage() {} + +func (x *BeaconStateDeneb) ProtoReflect() protoreflect.Message { + mi := &file_proto_prysm_v1alpha1_beacon_state_proto_msgTypes[13] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use BeaconStateDeneb.ProtoReflect.Descriptor instead. +func (*BeaconStateDeneb) Descriptor() ([]byte, []int) { + return file_proto_prysm_v1alpha1_beacon_state_proto_rawDescGZIP(), []int{13} +} + +func (x *BeaconStateDeneb) GetGenesisTime() uint64 { + if x != nil { + return x.GenesisTime + } + return 0 +} + +func (x *BeaconStateDeneb) GetGenesisValidatorsRoot() []byte { + if x != nil { + return x.GenesisValidatorsRoot + } + return nil +} + +func (x *BeaconStateDeneb) GetSlot() github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot { + if x != nil { + return x.Slot + } + return github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot(0) +} + +func (x *BeaconStateDeneb) GetFork() *Fork { + if x != nil { + return x.Fork + } + return nil +} + +func (x *BeaconStateDeneb) GetLatestBlockHeader() *BeaconBlockHeader { + if x != nil { + return x.LatestBlockHeader + } + return nil +} + +func (x *BeaconStateDeneb) GetBlockRoots() [][]byte { + if x != nil { + return x.BlockRoots + } + return nil +} + +func (x *BeaconStateDeneb) GetStateRoots() [][]byte { + if x != nil { + return x.StateRoots + } + return nil +} + +func (x *BeaconStateDeneb) GetHistoricalRoots() [][]byte { + if x != nil { + return x.HistoricalRoots + } + return nil +} + +func (x *BeaconStateDeneb) GetEth1Data() *Eth1Data { + if x != nil { + return x.Eth1Data + } + return nil +} + +func (x *BeaconStateDeneb) GetEth1DataVotes() []*Eth1Data { + if x != nil { + return x.Eth1DataVotes + } + return nil +} + +func (x *BeaconStateDeneb) GetEth1DepositIndex() uint64 { + if x != nil { + return x.Eth1DepositIndex + } + return 0 +} + +func (x *BeaconStateDeneb) GetValidators() []*Validator { + if x != nil { + return x.Validators + } + return nil +} + +func (x *BeaconStateDeneb) GetBalances() []uint64 { + if x != nil { + return x.Balances + } + return nil +} + +func (x *BeaconStateDeneb) GetRandaoMixes() [][]byte { + if x != nil { + return x.RandaoMixes + } + return nil +} + +func (x *BeaconStateDeneb) GetSlashings() []uint64 { + if x != nil { + return x.Slashings + } + return nil +} + +func (x *BeaconStateDeneb) GetPreviousEpochParticipation() []byte { + if x != nil { + return x.PreviousEpochParticipation + } + return nil +} + +func (x *BeaconStateDeneb) GetCurrentEpochParticipation() []byte { + if x != nil { + return x.CurrentEpochParticipation + } + return nil +} + +func (x *BeaconStateDeneb) GetJustificationBits() github_com_OffchainLabs_go_bitfield.Bitvector4 { + if x != nil { + return x.JustificationBits + } + return github_com_OffchainLabs_go_bitfield.Bitvector4(nil) +} + +func (x *BeaconStateDeneb) GetPreviousJustifiedCheckpoint() *Checkpoint { + if x != nil { + return x.PreviousJustifiedCheckpoint + } + return nil +} + +func (x *BeaconStateDeneb) GetCurrentJustifiedCheckpoint() *Checkpoint { + if x != nil { + return x.CurrentJustifiedCheckpoint + } + return nil +} + +func (x *BeaconStateDeneb) GetFinalizedCheckpoint() *Checkpoint { + if x != nil { + return x.FinalizedCheckpoint + } + return nil +} + +func (x *BeaconStateDeneb) GetInactivityScores() []uint64 { + if x != nil { + return x.InactivityScores + } + return nil +} + +func (x *BeaconStateDeneb) GetCurrentSyncCommittee() *SyncCommittee { + if x != nil { + return x.CurrentSyncCommittee + } + return nil +} + +func (x *BeaconStateDeneb) GetNextSyncCommittee() *SyncCommittee { + if x != nil { + return x.NextSyncCommittee + } + return nil +} + +func (x *BeaconStateDeneb) GetLatestExecutionPayloadHeader() *v1.ExecutionPayloadHeaderDeneb { + if x != nil { + return x.LatestExecutionPayloadHeader + } + return nil +} + +func (x *BeaconStateDeneb) GetNextWithdrawalIndex() uint64 { + if x != nil { + return x.NextWithdrawalIndex + } + return 0 +} + +func (x *BeaconStateDeneb) GetNextWithdrawalValidatorIndex() github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex { + if x != nil { + return x.NextWithdrawalValidatorIndex + } + return github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex(0) +} + +func (x *BeaconStateDeneb) GetHistoricalSummaries() []*HistoricalSummary { + if x != nil { + return x.HistoricalSummaries + } + return nil +} + +type BeaconStateElectra struct { + state protoimpl.MessageState `protogen:"open.v1"` + GenesisTime uint64 `protobuf:"varint,1001,opt,name=genesis_time,json=genesisTime,proto3" json:"genesis_time,omitempty"` + GenesisValidatorsRoot []byte `protobuf:"bytes,1002,opt,name=genesis_validators_root,json=genesisValidatorsRoot,proto3" json:"genesis_validators_root,omitempty" ssz-size:"32"` + Slot github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot `protobuf:"varint,1003,opt,name=slot,proto3" json:"slot,omitempty" cast-type:"github.com/OffchainLabs/prysm/v7/consensus-types/primitives.Slot"` + Fork *Fork `protobuf:"bytes,1004,opt,name=fork,proto3" json:"fork,omitempty"` + LatestBlockHeader *BeaconBlockHeader `protobuf:"bytes,2001,opt,name=latest_block_header,json=latestBlockHeader,proto3" json:"latest_block_header,omitempty"` + BlockRoots [][]byte `protobuf:"bytes,2002,rep,name=block_roots,json=blockRoots,proto3" json:"block_roots,omitempty" ssz-size:"64,32"` + StateRoots [][]byte `protobuf:"bytes,2003,rep,name=state_roots,json=stateRoots,proto3" json:"state_roots,omitempty" ssz-size:"64,32"` + HistoricalRoots [][]byte `protobuf:"bytes,2004,rep,name=historical_roots,json=historicalRoots,proto3" json:"historical_roots,omitempty" ssz-max:"16777216" ssz-size:"?,32"` + Eth1Data *Eth1Data `protobuf:"bytes,3001,opt,name=eth1_data,json=eth1Data,proto3" json:"eth1_data,omitempty"` + Eth1DataVotes []*Eth1Data `protobuf:"bytes,3002,rep,name=eth1_data_votes,json=eth1DataVotes,proto3" json:"eth1_data_votes,omitempty" ssz-max:"32"` + Eth1DepositIndex uint64 `protobuf:"varint,3003,opt,name=eth1_deposit_index,json=eth1DepositIndex,proto3" json:"eth1_deposit_index,omitempty"` + Validators []*Validator `protobuf:"bytes,4001,rep,name=validators,proto3" json:"validators,omitempty" ssz-max:"1099511627776"` + Balances []uint64 `protobuf:"varint,4002,rep,packed,name=balances,proto3" json:"balances,omitempty" ssz-max:"1099511627776"` + RandaoMixes [][]byte `protobuf:"bytes,5001,rep,name=randao_mixes,json=randaoMixes,proto3" json:"randao_mixes,omitempty" ssz-size:"64,32"` + Slashings []uint64 `protobuf:"varint,6001,rep,packed,name=slashings,proto3" json:"slashings,omitempty" ssz-size:"64"` + PreviousEpochParticipation []byte `protobuf:"bytes,7001,opt,name=previous_epoch_participation,json=previousEpochParticipation,proto3" json:"previous_epoch_participation,omitempty" ssz-max:"1099511627776"` + CurrentEpochParticipation []byte `protobuf:"bytes,7002,opt,name=current_epoch_participation,json=currentEpochParticipation,proto3" json:"current_epoch_participation,omitempty" ssz-max:"1099511627776"` + JustificationBits github_com_OffchainLabs_go_bitfield.Bitvector4 `protobuf:"bytes,8001,opt,name=justification_bits,json=justificationBits,proto3" json:"justification_bits,omitempty" cast-type:"github.com/OffchainLabs/go-bitfield.Bitvector4" ssz-size:"1"` + PreviousJustifiedCheckpoint *Checkpoint `protobuf:"bytes,8002,opt,name=previous_justified_checkpoint,json=previousJustifiedCheckpoint,proto3" json:"previous_justified_checkpoint,omitempty"` + CurrentJustifiedCheckpoint *Checkpoint `protobuf:"bytes,8003,opt,name=current_justified_checkpoint,json=currentJustifiedCheckpoint,proto3" json:"current_justified_checkpoint,omitempty"` + FinalizedCheckpoint *Checkpoint `protobuf:"bytes,8004,opt,name=finalized_checkpoint,json=finalizedCheckpoint,proto3" json:"finalized_checkpoint,omitempty"` + InactivityScores []uint64 `protobuf:"varint,9001,rep,packed,name=inactivity_scores,json=inactivityScores,proto3" json:"inactivity_scores,omitempty" ssz-max:"1099511627776"` + CurrentSyncCommittee *SyncCommittee `protobuf:"bytes,9002,opt,name=current_sync_committee,json=currentSyncCommittee,proto3" json:"current_sync_committee,omitempty"` + NextSyncCommittee *SyncCommittee `protobuf:"bytes,9003,opt,name=next_sync_committee,json=nextSyncCommittee,proto3" json:"next_sync_committee,omitempty"` + LatestExecutionPayloadHeader *v1.ExecutionPayloadHeaderDeneb `protobuf:"bytes,10001,opt,name=latest_execution_payload_header,json=latestExecutionPayloadHeader,proto3" json:"latest_execution_payload_header,omitempty"` + NextWithdrawalIndex uint64 `protobuf:"varint,11001,opt,name=next_withdrawal_index,json=nextWithdrawalIndex,proto3" json:"next_withdrawal_index,omitempty"` + NextWithdrawalValidatorIndex github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex `protobuf:"varint,11002,opt,name=next_withdrawal_validator_index,json=nextWithdrawalValidatorIndex,proto3" json:"next_withdrawal_validator_index,omitempty" cast-type:"github.com/OffchainLabs/prysm/v7/consensus-types/primitives.ValidatorIndex"` + HistoricalSummaries []*HistoricalSummary `protobuf:"bytes,11003,rep,name=historical_summaries,json=historicalSummaries,proto3" json:"historical_summaries,omitempty" ssz-max:"16777216"` + DepositRequestsStartIndex uint64 `protobuf:"varint,12001,opt,name=deposit_requests_start_index,json=depositRequestsStartIndex,proto3" json:"deposit_requests_start_index,omitempty"` + DepositBalanceToConsume github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Gwei `protobuf:"varint,12002,opt,name=deposit_balance_to_consume,json=depositBalanceToConsume,proto3" json:"deposit_balance_to_consume,omitempty" cast-type:"github.com/OffchainLabs/prysm/v7/consensus-types/primitives.Gwei"` + ExitBalanceToConsume github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Gwei `protobuf:"varint,12003,opt,name=exit_balance_to_consume,json=exitBalanceToConsume,proto3" json:"exit_balance_to_consume,omitempty" cast-type:"github.com/OffchainLabs/prysm/v7/consensus-types/primitives.Gwei"` + EarliestExitEpoch github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Epoch `protobuf:"varint,12004,opt,name=earliest_exit_epoch,json=earliestExitEpoch,proto3" json:"earliest_exit_epoch,omitempty" cast-type:"github.com/OffchainLabs/prysm/v7/consensus-types/primitives.Epoch"` + ConsolidationBalanceToConsume github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Gwei `protobuf:"varint,12005,opt,name=consolidation_balance_to_consume,json=consolidationBalanceToConsume,proto3" json:"consolidation_balance_to_consume,omitempty" cast-type:"github.com/OffchainLabs/prysm/v7/consensus-types/primitives.Gwei"` + EarliestConsolidationEpoch github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Epoch `protobuf:"varint,12006,opt,name=earliest_consolidation_epoch,json=earliestConsolidationEpoch,proto3" json:"earliest_consolidation_epoch,omitempty" cast-type:"github.com/OffchainLabs/prysm/v7/consensus-types/primitives.Epoch"` + PendingDeposits []*PendingDeposit `protobuf:"bytes,12007,rep,name=pending_deposits,json=pendingDeposits,proto3" json:"pending_deposits,omitempty" ssz-max:"134217728"` + PendingPartialWithdrawals []*PendingPartialWithdrawal `protobuf:"bytes,12008,rep,name=pending_partial_withdrawals,json=pendingPartialWithdrawals,proto3" json:"pending_partial_withdrawals,omitempty" ssz-max:"64"` + PendingConsolidations []*PendingConsolidation `protobuf:"bytes,12009,rep,name=pending_consolidations,json=pendingConsolidations,proto3" json:"pending_consolidations,omitempty" ssz-max:"64"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *BeaconStateElectra) Reset() { + *x = BeaconStateElectra{} + mi := &file_proto_prysm_v1alpha1_beacon_state_proto_msgTypes[14] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *BeaconStateElectra) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*BeaconStateElectra) ProtoMessage() {} + +func (x *BeaconStateElectra) ProtoReflect() protoreflect.Message { + mi := &file_proto_prysm_v1alpha1_beacon_state_proto_msgTypes[14] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use BeaconStateElectra.ProtoReflect.Descriptor instead. +func (*BeaconStateElectra) Descriptor() ([]byte, []int) { + return file_proto_prysm_v1alpha1_beacon_state_proto_rawDescGZIP(), []int{14} +} + +func (x *BeaconStateElectra) GetGenesisTime() uint64 { + if x != nil { + return x.GenesisTime + } + return 0 +} + +func (x *BeaconStateElectra) GetGenesisValidatorsRoot() []byte { + if x != nil { + return x.GenesisValidatorsRoot + } + return nil +} + +func (x *BeaconStateElectra) GetSlot() github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot { + if x != nil { + return x.Slot + } + return github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot(0) +} + +func (x *BeaconStateElectra) GetFork() *Fork { + if x != nil { + return x.Fork + } + return nil +} + +func (x *BeaconStateElectra) GetLatestBlockHeader() *BeaconBlockHeader { + if x != nil { + return x.LatestBlockHeader + } + return nil +} + +func (x *BeaconStateElectra) GetBlockRoots() [][]byte { + if x != nil { + return x.BlockRoots + } + return nil +} + +func (x *BeaconStateElectra) GetStateRoots() [][]byte { + if x != nil { + return x.StateRoots + } + return nil +} + +func (x *BeaconStateElectra) GetHistoricalRoots() [][]byte { + if x != nil { + return x.HistoricalRoots + } + return nil +} + +func (x *BeaconStateElectra) GetEth1Data() *Eth1Data { + if x != nil { + return x.Eth1Data + } + return nil +} + +func (x *BeaconStateElectra) GetEth1DataVotes() []*Eth1Data { + if x != nil { + return x.Eth1DataVotes + } + return nil +} + +func (x *BeaconStateElectra) GetEth1DepositIndex() uint64 { + if x != nil { + return x.Eth1DepositIndex + } + return 0 +} + +func (x *BeaconStateElectra) GetValidators() []*Validator { + if x != nil { + return x.Validators + } + return nil +} + +func (x *BeaconStateElectra) GetBalances() []uint64 { + if x != nil { + return x.Balances + } + return nil +} + +func (x *BeaconStateElectra) GetRandaoMixes() [][]byte { + if x != nil { + return x.RandaoMixes + } + return nil +} + +func (x *BeaconStateElectra) GetSlashings() []uint64 { + if x != nil { + return x.Slashings + } + return nil +} + +func (x *BeaconStateElectra) GetPreviousEpochParticipation() []byte { + if x != nil { + return x.PreviousEpochParticipation + } + return nil +} + +func (x *BeaconStateElectra) GetCurrentEpochParticipation() []byte { + if x != nil { + return x.CurrentEpochParticipation + } + return nil +} + +func (x *BeaconStateElectra) GetJustificationBits() github_com_OffchainLabs_go_bitfield.Bitvector4 { + if x != nil { + return x.JustificationBits + } + return github_com_OffchainLabs_go_bitfield.Bitvector4(nil) +} + +func (x *BeaconStateElectra) GetPreviousJustifiedCheckpoint() *Checkpoint { + if x != nil { + return x.PreviousJustifiedCheckpoint + } + return nil +} + +func (x *BeaconStateElectra) GetCurrentJustifiedCheckpoint() *Checkpoint { + if x != nil { + return x.CurrentJustifiedCheckpoint + } + return nil +} + +func (x *BeaconStateElectra) GetFinalizedCheckpoint() *Checkpoint { + if x != nil { + return x.FinalizedCheckpoint + } + return nil +} + +func (x *BeaconStateElectra) GetInactivityScores() []uint64 { + if x != nil { + return x.InactivityScores + } + return nil +} + +func (x *BeaconStateElectra) GetCurrentSyncCommittee() *SyncCommittee { + if x != nil { + return x.CurrentSyncCommittee + } + return nil +} + +func (x *BeaconStateElectra) GetNextSyncCommittee() *SyncCommittee { + if x != nil { + return x.NextSyncCommittee + } + return nil +} + +func (x *BeaconStateElectra) GetLatestExecutionPayloadHeader() *v1.ExecutionPayloadHeaderDeneb { + if x != nil { + return x.LatestExecutionPayloadHeader + } + return nil +} + +func (x *BeaconStateElectra) GetNextWithdrawalIndex() uint64 { + if x != nil { + return x.NextWithdrawalIndex + } + return 0 +} + +func (x *BeaconStateElectra) GetNextWithdrawalValidatorIndex() github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex { + if x != nil { + return x.NextWithdrawalValidatorIndex + } + return github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex(0) +} + +func (x *BeaconStateElectra) GetHistoricalSummaries() []*HistoricalSummary { + if x != nil { + return x.HistoricalSummaries + } + return nil +} + +func (x *BeaconStateElectra) GetDepositRequestsStartIndex() uint64 { + if x != nil { + return x.DepositRequestsStartIndex + } + return 0 +} + +func (x *BeaconStateElectra) GetDepositBalanceToConsume() github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Gwei { + if x != nil { + return x.DepositBalanceToConsume + } + return github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Gwei(0) +} + +func (x *BeaconStateElectra) GetExitBalanceToConsume() github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Gwei { + if x != nil { + return x.ExitBalanceToConsume + } + return github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Gwei(0) +} + +func (x *BeaconStateElectra) GetEarliestExitEpoch() github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Epoch { + if x != nil { + return x.EarliestExitEpoch + } + return github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Epoch(0) +} + +func (x *BeaconStateElectra) GetConsolidationBalanceToConsume() github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Gwei { + if x != nil { + return x.ConsolidationBalanceToConsume + } + return github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Gwei(0) +} + +func (x *BeaconStateElectra) GetEarliestConsolidationEpoch() github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Epoch { + if x != nil { + return x.EarliestConsolidationEpoch + } + return github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Epoch(0) +} + +func (x *BeaconStateElectra) GetPendingDeposits() []*PendingDeposit { + if x != nil { + return x.PendingDeposits + } + return nil +} + +func (x *BeaconStateElectra) GetPendingPartialWithdrawals() []*PendingPartialWithdrawal { + if x != nil { + return x.PendingPartialWithdrawals + } + return nil +} + +func (x *BeaconStateElectra) GetPendingConsolidations() []*PendingConsolidation { + if x != nil { + return x.PendingConsolidations + } + return nil +} + +type BeaconStateFulu struct { + state protoimpl.MessageState `protogen:"open.v1"` + GenesisTime uint64 `protobuf:"varint,1001,opt,name=genesis_time,json=genesisTime,proto3" json:"genesis_time,omitempty"` + GenesisValidatorsRoot []byte `protobuf:"bytes,1002,opt,name=genesis_validators_root,json=genesisValidatorsRoot,proto3" json:"genesis_validators_root,omitempty" ssz-size:"32"` + Slot github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot `protobuf:"varint,1003,opt,name=slot,proto3" json:"slot,omitempty" cast-type:"github.com/OffchainLabs/prysm/v7/consensus-types/primitives.Slot"` + Fork *Fork `protobuf:"bytes,1004,opt,name=fork,proto3" json:"fork,omitempty"` + LatestBlockHeader *BeaconBlockHeader `protobuf:"bytes,2001,opt,name=latest_block_header,json=latestBlockHeader,proto3" json:"latest_block_header,omitempty"` + BlockRoots [][]byte `protobuf:"bytes,2002,rep,name=block_roots,json=blockRoots,proto3" json:"block_roots,omitempty" ssz-size:"64,32"` + StateRoots [][]byte `protobuf:"bytes,2003,rep,name=state_roots,json=stateRoots,proto3" json:"state_roots,omitempty" ssz-size:"64,32"` + HistoricalRoots [][]byte `protobuf:"bytes,2004,rep,name=historical_roots,json=historicalRoots,proto3" json:"historical_roots,omitempty" ssz-max:"16777216" ssz-size:"?,32"` + Eth1Data *Eth1Data `protobuf:"bytes,3001,opt,name=eth1_data,json=eth1Data,proto3" json:"eth1_data,omitempty"` + Eth1DataVotes []*Eth1Data `protobuf:"bytes,3002,rep,name=eth1_data_votes,json=eth1DataVotes,proto3" json:"eth1_data_votes,omitempty" ssz-max:"32"` + Eth1DepositIndex uint64 `protobuf:"varint,3003,opt,name=eth1_deposit_index,json=eth1DepositIndex,proto3" json:"eth1_deposit_index,omitempty"` + Validators []*Validator `protobuf:"bytes,4001,rep,name=validators,proto3" json:"validators,omitempty" ssz-max:"1099511627776"` + Balances []uint64 `protobuf:"varint,4002,rep,packed,name=balances,proto3" json:"balances,omitempty" ssz-max:"1099511627776"` + RandaoMixes [][]byte `protobuf:"bytes,5001,rep,name=randao_mixes,json=randaoMixes,proto3" json:"randao_mixes,omitempty" ssz-size:"64,32"` + Slashings []uint64 `protobuf:"varint,6001,rep,packed,name=slashings,proto3" json:"slashings,omitempty" ssz-size:"64"` + PreviousEpochParticipation []byte `protobuf:"bytes,7001,opt,name=previous_epoch_participation,json=previousEpochParticipation,proto3" json:"previous_epoch_participation,omitempty" ssz-max:"1099511627776"` + CurrentEpochParticipation []byte `protobuf:"bytes,7002,opt,name=current_epoch_participation,json=currentEpochParticipation,proto3" json:"current_epoch_participation,omitempty" ssz-max:"1099511627776"` + JustificationBits github_com_OffchainLabs_go_bitfield.Bitvector4 `protobuf:"bytes,8001,opt,name=justification_bits,json=justificationBits,proto3" json:"justification_bits,omitempty" cast-type:"github.com/OffchainLabs/go-bitfield.Bitvector4" ssz-size:"1"` + PreviousJustifiedCheckpoint *Checkpoint `protobuf:"bytes,8002,opt,name=previous_justified_checkpoint,json=previousJustifiedCheckpoint,proto3" json:"previous_justified_checkpoint,omitempty"` + CurrentJustifiedCheckpoint *Checkpoint `protobuf:"bytes,8003,opt,name=current_justified_checkpoint,json=currentJustifiedCheckpoint,proto3" json:"current_justified_checkpoint,omitempty"` + FinalizedCheckpoint *Checkpoint `protobuf:"bytes,8004,opt,name=finalized_checkpoint,json=finalizedCheckpoint,proto3" json:"finalized_checkpoint,omitempty"` + InactivityScores []uint64 `protobuf:"varint,9001,rep,packed,name=inactivity_scores,json=inactivityScores,proto3" json:"inactivity_scores,omitempty" ssz-max:"1099511627776"` + CurrentSyncCommittee *SyncCommittee `protobuf:"bytes,9002,opt,name=current_sync_committee,json=currentSyncCommittee,proto3" json:"current_sync_committee,omitempty"` + NextSyncCommittee *SyncCommittee `protobuf:"bytes,9003,opt,name=next_sync_committee,json=nextSyncCommittee,proto3" json:"next_sync_committee,omitempty"` + LatestExecutionPayloadHeader *v1.ExecutionPayloadHeaderDeneb `protobuf:"bytes,10001,opt,name=latest_execution_payload_header,json=latestExecutionPayloadHeader,proto3" json:"latest_execution_payload_header,omitempty"` + NextWithdrawalIndex uint64 `protobuf:"varint,11001,opt,name=next_withdrawal_index,json=nextWithdrawalIndex,proto3" json:"next_withdrawal_index,omitempty"` + NextWithdrawalValidatorIndex github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex `protobuf:"varint,11002,opt,name=next_withdrawal_validator_index,json=nextWithdrawalValidatorIndex,proto3" json:"next_withdrawal_validator_index,omitempty" cast-type:"github.com/OffchainLabs/prysm/v7/consensus-types/primitives.ValidatorIndex"` + HistoricalSummaries []*HistoricalSummary `protobuf:"bytes,11003,rep,name=historical_summaries,json=historicalSummaries,proto3" json:"historical_summaries,omitempty" ssz-max:"16777216"` + DepositRequestsStartIndex uint64 `protobuf:"varint,12001,opt,name=deposit_requests_start_index,json=depositRequestsStartIndex,proto3" json:"deposit_requests_start_index,omitempty"` + DepositBalanceToConsume github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Gwei `protobuf:"varint,12002,opt,name=deposit_balance_to_consume,json=depositBalanceToConsume,proto3" json:"deposit_balance_to_consume,omitempty" cast-type:"github.com/OffchainLabs/prysm/v7/consensus-types/primitives.Gwei"` + ExitBalanceToConsume github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Gwei `protobuf:"varint,12003,opt,name=exit_balance_to_consume,json=exitBalanceToConsume,proto3" json:"exit_balance_to_consume,omitempty" cast-type:"github.com/OffchainLabs/prysm/v7/consensus-types/primitives.Gwei"` + EarliestExitEpoch github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Epoch `protobuf:"varint,12004,opt,name=earliest_exit_epoch,json=earliestExitEpoch,proto3" json:"earliest_exit_epoch,omitempty" cast-type:"github.com/OffchainLabs/prysm/v7/consensus-types/primitives.Epoch"` + ConsolidationBalanceToConsume github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Gwei `protobuf:"varint,12005,opt,name=consolidation_balance_to_consume,json=consolidationBalanceToConsume,proto3" json:"consolidation_balance_to_consume,omitempty" cast-type:"github.com/OffchainLabs/prysm/v7/consensus-types/primitives.Gwei"` + EarliestConsolidationEpoch github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Epoch `protobuf:"varint,12006,opt,name=earliest_consolidation_epoch,json=earliestConsolidationEpoch,proto3" json:"earliest_consolidation_epoch,omitempty" cast-type:"github.com/OffchainLabs/prysm/v7/consensus-types/primitives.Epoch"` + PendingDeposits []*PendingDeposit `protobuf:"bytes,12007,rep,name=pending_deposits,json=pendingDeposits,proto3" json:"pending_deposits,omitempty" ssz-max:"134217728"` + PendingPartialWithdrawals []*PendingPartialWithdrawal `protobuf:"bytes,12008,rep,name=pending_partial_withdrawals,json=pendingPartialWithdrawals,proto3" json:"pending_partial_withdrawals,omitempty" ssz-max:"64"` + PendingConsolidations []*PendingConsolidation `protobuf:"bytes,12009,rep,name=pending_consolidations,json=pendingConsolidations,proto3" json:"pending_consolidations,omitempty" ssz-max:"64"` + ProposerLookahead []github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex `protobuf:"varint,13001,rep,packed,name=proposer_lookahead,json=proposerLookahead,proto3" json:"proposer_lookahead,omitempty" cast-type:"github.com/OffchainLabs/prysm/v7/consensus-types/primitives.ValidatorIndex" ssz-size:"16"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *BeaconStateFulu) Reset() { + *x = BeaconStateFulu{} + mi := &file_proto_prysm_v1alpha1_beacon_state_proto_msgTypes[15] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *BeaconStateFulu) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*BeaconStateFulu) ProtoMessage() {} + +func (x *BeaconStateFulu) ProtoReflect() protoreflect.Message { + mi := &file_proto_prysm_v1alpha1_beacon_state_proto_msgTypes[15] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use BeaconStateFulu.ProtoReflect.Descriptor instead. +func (*BeaconStateFulu) Descriptor() ([]byte, []int) { + return file_proto_prysm_v1alpha1_beacon_state_proto_rawDescGZIP(), []int{15} +} + +func (x *BeaconStateFulu) GetGenesisTime() uint64 { + if x != nil { + return x.GenesisTime + } + return 0 +} + +func (x *BeaconStateFulu) GetGenesisValidatorsRoot() []byte { + if x != nil { + return x.GenesisValidatorsRoot + } + return nil +} + +func (x *BeaconStateFulu) GetSlot() github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot { + if x != nil { + return x.Slot + } + return github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot(0) +} + +func (x *BeaconStateFulu) GetFork() *Fork { + if x != nil { + return x.Fork + } + return nil +} + +func (x *BeaconStateFulu) GetLatestBlockHeader() *BeaconBlockHeader { + if x != nil { + return x.LatestBlockHeader + } + return nil +} + +func (x *BeaconStateFulu) GetBlockRoots() [][]byte { + if x != nil { + return x.BlockRoots + } + return nil +} + +func (x *BeaconStateFulu) GetStateRoots() [][]byte { + if x != nil { + return x.StateRoots + } + return nil +} + +func (x *BeaconStateFulu) GetHistoricalRoots() [][]byte { + if x != nil { + return x.HistoricalRoots + } + return nil +} + +func (x *BeaconStateFulu) GetEth1Data() *Eth1Data { + if x != nil { + return x.Eth1Data + } + return nil +} + +func (x *BeaconStateFulu) GetEth1DataVotes() []*Eth1Data { + if x != nil { + return x.Eth1DataVotes + } + return nil +} + +func (x *BeaconStateFulu) GetEth1DepositIndex() uint64 { + if x != nil { + return x.Eth1DepositIndex + } + return 0 +} + +func (x *BeaconStateFulu) GetValidators() []*Validator { + if x != nil { + return x.Validators + } + return nil +} + +func (x *BeaconStateFulu) GetBalances() []uint64 { + if x != nil { + return x.Balances + } + return nil +} + +func (x *BeaconStateFulu) GetRandaoMixes() [][]byte { + if x != nil { + return x.RandaoMixes + } + return nil +} + +func (x *BeaconStateFulu) GetSlashings() []uint64 { + if x != nil { + return x.Slashings + } + return nil +} + +func (x *BeaconStateFulu) GetPreviousEpochParticipation() []byte { + if x != nil { + return x.PreviousEpochParticipation + } + return nil +} + +func (x *BeaconStateFulu) GetCurrentEpochParticipation() []byte { + if x != nil { + return x.CurrentEpochParticipation + } + return nil +} + +func (x *BeaconStateFulu) GetJustificationBits() github_com_OffchainLabs_go_bitfield.Bitvector4 { + if x != nil { + return x.JustificationBits + } + return github_com_OffchainLabs_go_bitfield.Bitvector4(nil) +} + +func (x *BeaconStateFulu) GetPreviousJustifiedCheckpoint() *Checkpoint { + if x != nil { + return x.PreviousJustifiedCheckpoint + } + return nil +} + +func (x *BeaconStateFulu) GetCurrentJustifiedCheckpoint() *Checkpoint { + if x != nil { + return x.CurrentJustifiedCheckpoint + } + return nil +} + +func (x *BeaconStateFulu) GetFinalizedCheckpoint() *Checkpoint { + if x != nil { + return x.FinalizedCheckpoint + } + return nil +} + +func (x *BeaconStateFulu) GetInactivityScores() []uint64 { + if x != nil { + return x.InactivityScores + } + return nil +} + +func (x *BeaconStateFulu) GetCurrentSyncCommittee() *SyncCommittee { + if x != nil { + return x.CurrentSyncCommittee + } + return nil +} + +func (x *BeaconStateFulu) GetNextSyncCommittee() *SyncCommittee { + if x != nil { + return x.NextSyncCommittee + } + return nil +} + +func (x *BeaconStateFulu) GetLatestExecutionPayloadHeader() *v1.ExecutionPayloadHeaderDeneb { + if x != nil { + return x.LatestExecutionPayloadHeader + } + return nil +} + +func (x *BeaconStateFulu) GetNextWithdrawalIndex() uint64 { + if x != nil { + return x.NextWithdrawalIndex + } + return 0 +} + +func (x *BeaconStateFulu) GetNextWithdrawalValidatorIndex() github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex { + if x != nil { + return x.NextWithdrawalValidatorIndex + } + return github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex(0) +} + +func (x *BeaconStateFulu) GetHistoricalSummaries() []*HistoricalSummary { + if x != nil { + return x.HistoricalSummaries + } + return nil +} + +func (x *BeaconStateFulu) GetDepositRequestsStartIndex() uint64 { + if x != nil { + return x.DepositRequestsStartIndex + } + return 0 +} + +func (x *BeaconStateFulu) GetDepositBalanceToConsume() github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Gwei { + if x != nil { + return x.DepositBalanceToConsume + } + return github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Gwei(0) +} + +func (x *BeaconStateFulu) GetExitBalanceToConsume() github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Gwei { + if x != nil { + return x.ExitBalanceToConsume + } + return github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Gwei(0) +} + +func (x *BeaconStateFulu) GetEarliestExitEpoch() github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Epoch { + if x != nil { + return x.EarliestExitEpoch + } + return github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Epoch(0) +} + +func (x *BeaconStateFulu) GetConsolidationBalanceToConsume() github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Gwei { + if x != nil { + return x.ConsolidationBalanceToConsume + } + return github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Gwei(0) +} + +func (x *BeaconStateFulu) GetEarliestConsolidationEpoch() github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Epoch { + if x != nil { + return x.EarliestConsolidationEpoch + } + return github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Epoch(0) +} + +func (x *BeaconStateFulu) GetPendingDeposits() []*PendingDeposit { + if x != nil { + return x.PendingDeposits + } + return nil +} + +func (x *BeaconStateFulu) GetPendingPartialWithdrawals() []*PendingPartialWithdrawal { + if x != nil { + return x.PendingPartialWithdrawals + } + return nil +} + +func (x *BeaconStateFulu) GetPendingConsolidations() []*PendingConsolidation { + if x != nil { + return x.PendingConsolidations + } + return nil +} + +func (x *BeaconStateFulu) GetProposerLookahead() []github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex { + if x != nil { + return x.ProposerLookahead + } + return []github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex(nil) +} + +var File_proto_prysm_v1alpha1_beacon_state_proto protoreflect.FileDescriptor + +var file_proto_prysm_v1alpha1_beacon_state_proto_rawDesc = []byte{ + 0x0a, 0x27, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x31, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2f, 0x62, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x5f, 0x73, 0x74, + 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x15, 0x65, 0x74, 0x68, 0x65, 0x72, + 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, + 0x1a, 0x26, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x31, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2f, 0x61, 0x74, 0x74, 0x65, 0x73, 0x74, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x2c, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, + 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2f, 0x62, + 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x73, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x26, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x6e, + 0x67, 0x69, 0x6e, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, + 0x6e, 0x5f, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1b, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x74, 0x68, 0x2f, 0x65, 0x78, 0x74, 0x2f, 0x6f, 0x70, + 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x23, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, + 0x31, 0x2f, 0x65, 0x69, 0x70, 0x5f, 0x37, 0x32, 0x35, 0x31, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x22, 0x8a, 0x0c, 0x0a, 0x0b, 0x42, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, + 0x12, 0x22, 0x0a, 0x0c, 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x5f, 0x74, 0x69, 0x6d, 0x65, + 0x18, 0xe9, 0x07, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, + 0x54, 0x69, 0x6d, 0x65, 0x12, 0x3f, 0x0a, 0x17, 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x5f, + 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x18, + 0xea, 0x07, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x15, + 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, + 0x73, 0x52, 0x6f, 0x6f, 0x74, 0x12, 0x59, 0x0a, 0x04, 0x73, 0x6c, 0x6f, 0x74, 0x18, 0xeb, 0x07, + 0x20, 0x01, 0x28, 0x04, 0x42, 0x44, 0x82, 0xb5, 0x18, 0x40, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, + 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x4f, 0x66, 0x66, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x4c, 0x61, 0x62, + 0x73, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x37, 0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x65, + 0x6e, 0x73, 0x75, 0x73, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x70, 0x72, 0x69, 0x6d, 0x69, + 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x53, 0x6c, 0x6f, 0x74, 0x52, 0x04, 0x73, 0x6c, 0x6f, 0x74, + 0x12, 0x30, 0x0a, 0x04, 0x66, 0x6f, 0x72, 0x6b, 0x18, 0xec, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x1b, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, + 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x46, 0x6f, 0x72, 0x6b, 0x52, 0x04, 0x66, 0x6f, + 0x72, 0x6b, 0x12, 0x59, 0x0a, 0x13, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x62, 0x6c, 0x6f, + 0x63, 0x6b, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0xd1, 0x0f, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x28, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, + 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x42, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x42, + 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x52, 0x11, 0x6c, 0x61, 0x74, 0x65, + 0x73, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x2b, 0x0a, + 0x0b, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x73, 0x18, 0xd2, 0x0f, 0x20, + 0x03, 0x28, 0x0c, 0x42, 0x09, 0x8a, 0xb5, 0x18, 0x05, 0x36, 0x34, 0x2c, 0x33, 0x32, 0x52, 0x0a, + 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x6f, 0x6f, 0x74, 0x73, 0x12, 0x2b, 0x0a, 0x0b, 0x73, 0x74, + 0x61, 0x74, 0x65, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x73, 0x18, 0xd3, 0x0f, 0x20, 0x03, 0x28, 0x0c, + 0x42, 0x09, 0x8a, 0xb5, 0x18, 0x05, 0x36, 0x34, 0x2c, 0x33, 0x32, 0x52, 0x0a, 0x73, 0x74, 0x61, + 0x74, 0x65, 0x52, 0x6f, 0x6f, 0x74, 0x73, 0x12, 0x40, 0x0a, 0x10, 0x68, 0x69, 0x73, 0x74, 0x6f, + 0x72, 0x69, 0x63, 0x61, 0x6c, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x73, 0x18, 0xd4, 0x0f, 0x20, 0x03, + 0x28, 0x0c, 0x42, 0x14, 0x8a, 0xb5, 0x18, 0x04, 0x3f, 0x2c, 0x33, 0x32, 0x92, 0xb5, 0x18, 0x08, + 0x31, 0x36, 0x37, 0x37, 0x37, 0x32, 0x31, 0x36, 0x52, 0x0f, 0x68, 0x69, 0x73, 0x74, 0x6f, 0x72, + 0x69, 0x63, 0x61, 0x6c, 0x52, 0x6f, 0x6f, 0x74, 0x73, 0x12, 0x3d, 0x0a, 0x09, 0x65, 0x74, 0x68, + 0x31, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x18, 0xb9, 0x17, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, + 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, + 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x45, 0x74, 0x68, 0x31, 0x44, 0x61, 0x74, 0x61, 0x52, 0x08, + 0x65, 0x74, 0x68, 0x31, 0x44, 0x61, 0x74, 0x61, 0x12, 0x50, 0x0a, 0x0f, 0x65, 0x74, 0x68, 0x31, + 0x5f, 0x64, 0x61, 0x74, 0x61, 0x5f, 0x76, 0x6f, 0x74, 0x65, 0x73, 0x18, 0xba, 0x17, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, + 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x45, 0x74, 0x68, 0x31, 0x44, + 0x61, 0x74, 0x61, 0x42, 0x06, 0x92, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x0d, 0x65, 0x74, 0x68, + 0x31, 0x44, 0x61, 0x74, 0x61, 0x56, 0x6f, 0x74, 0x65, 0x73, 0x12, 0x2d, 0x0a, 0x12, 0x65, 0x74, + 0x68, 0x31, 0x5f, 0x64, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x5f, 0x69, 0x6e, 0x64, 0x65, 0x78, + 0x18, 0xbb, 0x17, 0x20, 0x01, 0x28, 0x04, 0x52, 0x10, 0x65, 0x74, 0x68, 0x31, 0x44, 0x65, 0x70, + 0x6f, 0x73, 0x69, 0x74, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x54, 0x0a, 0x0a, 0x76, 0x61, 0x6c, + 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x18, 0xa1, 0x1f, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, + 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, + 0x42, 0x11, 0x92, 0xb5, 0x18, 0x0d, 0x31, 0x30, 0x39, 0x39, 0x35, 0x31, 0x31, 0x36, 0x32, 0x37, + 0x37, 0x37, 0x36, 0x52, 0x0a, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x12, + 0x2e, 0x0a, 0x08, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x18, 0xa2, 0x1f, 0x20, 0x03, + 0x28, 0x04, 0x42, 0x11, 0x92, 0xb5, 0x18, 0x0d, 0x31, 0x30, 0x39, 0x39, 0x35, 0x31, 0x31, 0x36, + 0x32, 0x37, 0x37, 0x37, 0x36, 0x52, 0x08, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x12, + 0x2d, 0x0a, 0x0c, 0x72, 0x61, 0x6e, 0x64, 0x61, 0x6f, 0x5f, 0x6d, 0x69, 0x78, 0x65, 0x73, 0x18, + 0x89, 0x27, 0x20, 0x03, 0x28, 0x0c, 0x42, 0x09, 0x8a, 0xb5, 0x18, 0x05, 0x36, 0x34, 0x2c, 0x33, + 0x32, 0x52, 0x0b, 0x72, 0x61, 0x6e, 0x64, 0x61, 0x6f, 0x4d, 0x69, 0x78, 0x65, 0x73, 0x12, 0x25, + 0x0a, 0x09, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x73, 0x18, 0xf1, 0x2e, 0x20, 0x03, + 0x28, 0x04, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x36, 0x34, 0x52, 0x09, 0x73, 0x6c, 0x61, 0x73, + 0x68, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x74, 0x0a, 0x1b, 0x70, 0x72, 0x65, 0x76, 0x69, 0x6f, 0x75, + 0x73, 0x5f, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x5f, 0x61, 0x74, 0x74, 0x65, 0x73, 0x74, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xd9, 0x36, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x65, 0x74, + 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, + 0x68, 0x61, 0x31, 0x2e, 0x50, 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x41, 0x74, 0x74, 0x65, 0x73, + 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x08, 0x92, 0xb5, 0x18, 0x04, 0x31, 0x30, 0x32, 0x34, + 0x52, 0x19, 0x70, 0x72, 0x65, 0x76, 0x69, 0x6f, 0x75, 0x73, 0x45, 0x70, 0x6f, 0x63, 0x68, 0x41, + 0x74, 0x74, 0x65, 0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x72, 0x0a, 0x1a, 0x63, + 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x5f, 0x61, 0x74, 0x74, + 0x65, 0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xda, 0x36, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x29, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, + 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x50, 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, + 0x41, 0x74, 0x74, 0x65, 0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x08, 0x92, 0xb5, 0x18, + 0x04, 0x31, 0x30, 0x32, 0x34, 0x52, 0x18, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x45, 0x70, + 0x6f, 0x63, 0x68, 0x41, 0x74, 0x74, 0x65, 0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, + 0x67, 0x0a, 0x12, 0x6a, 0x75, 0x73, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x5f, 0x62, 0x69, 0x74, 0x73, 0x18, 0xc1, 0x3e, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x37, 0x82, 0xb5, + 0x18, 0x2e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x4f, 0x66, 0x66, + 0x63, 0x68, 0x61, 0x69, 0x6e, 0x4c, 0x61, 0x62, 0x73, 0x2f, 0x67, 0x6f, 0x2d, 0x62, 0x69, 0x74, + 0x66, 0x69, 0x65, 0x6c, 0x64, 0x2e, 0x42, 0x69, 0x74, 0x76, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x34, + 0x8a, 0xb5, 0x18, 0x01, 0x31, 0x52, 0x11, 0x6a, 0x75, 0x73, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x69, 0x74, 0x73, 0x12, 0x66, 0x0a, 0x1d, 0x70, 0x72, 0x65, 0x76, + 0x69, 0x6f, 0x75, 0x73, 0x5f, 0x6a, 0x75, 0x73, 0x74, 0x69, 0x66, 0x69, 0x65, 0x64, 0x5f, 0x63, + 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0xc2, 0x3e, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x21, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, + 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, + 0x69, 0x6e, 0x74, 0x52, 0x1b, 0x70, 0x72, 0x65, 0x76, 0x69, 0x6f, 0x75, 0x73, 0x4a, 0x75, 0x73, + 0x74, 0x69, 0x66, 0x69, 0x65, 0x64, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, + 0x12, 0x64, 0x0a, 0x1c, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x6a, 0x75, 0x73, 0x74, + 0x69, 0x66, 0x69, 0x65, 0x64, 0x5f, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, + 0x18, 0xc3, 0x3e, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, + 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, + 0x43, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x52, 0x1a, 0x63, 0x75, 0x72, 0x72, + 0x65, 0x6e, 0x74, 0x4a, 0x75, 0x73, 0x74, 0x69, 0x66, 0x69, 0x65, 0x64, 0x43, 0x68, 0x65, 0x63, + 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x55, 0x0a, 0x14, 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x69, + 0x7a, 0x65, 0x64, 0x5f, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0xc4, + 0x3e, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, + 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x43, 0x68, + 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x52, 0x13, 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x69, + 0x7a, 0x65, 0x64, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x22, 0x9a, 0x03, + 0x0a, 0x12, 0x50, 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x41, 0x74, 0x74, 0x65, 0x73, 0x74, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x62, 0x0a, 0x10, 0x61, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x5f, 0x62, 0x69, 0x74, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x37, + 0x82, 0xb5, 0x18, 0x2b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x4f, + 0x66, 0x66, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x4c, 0x61, 0x62, 0x73, 0x2f, 0x67, 0x6f, 0x2d, 0x62, + 0x69, 0x74, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x2e, 0x42, 0x69, 0x74, 0x6c, 0x69, 0x73, 0x74, 0x92, + 0xb5, 0x18, 0x04, 0x32, 0x30, 0x34, 0x38, 0x52, 0x0f, 0x61, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x69, 0x74, 0x73, 0x12, 0x3a, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, + 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x41, + 0x74, 0x74, 0x65, 0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x44, 0x61, 0x74, 0x61, 0x52, 0x04, + 0x64, 0x61, 0x74, 0x61, 0x12, 0x6d, 0x0a, 0x0f, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x73, 0x69, 0x6f, + 0x6e, 0x5f, 0x64, 0x65, 0x6c, 0x61, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x42, 0x44, 0x82, + 0xb5, 0x18, 0x40, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x4f, 0x66, + 0x66, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x4c, 0x61, 0x62, 0x73, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, + 0x2f, 0x76, 0x37, 0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2d, 0x74, 0x79, + 0x70, 0x65, 0x73, 0x2f, 0x70, 0x72, 0x69, 0x6d, 0x69, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x53, + 0x6c, 0x6f, 0x74, 0x52, 0x0e, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x73, 0x69, 0x6f, 0x6e, 0x44, 0x65, + 0x6c, 0x61, 0x79, 0x12, 0x75, 0x0a, 0x0e, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x65, 0x72, 0x5f, + 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x42, 0x4e, 0x82, 0xb5, 0x18, + 0x4a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x4f, 0x66, 0x66, 0x63, + 0x68, 0x61, 0x69, 0x6e, 0x4c, 0x61, 0x62, 0x73, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, + 0x37, 0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2d, 0x74, 0x79, 0x70, 0x65, + 0x73, 0x2f, 0x70, 0x72, 0x69, 0x6d, 0x69, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x56, 0x61, 0x6c, + 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x52, 0x0d, 0x70, 0x72, 0x6f, + 0x70, 0x6f, 0x73, 0x65, 0x72, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x22, 0x69, 0x0a, 0x0f, 0x48, 0x69, + 0x73, 0x74, 0x6f, 0x72, 0x69, 0x63, 0x61, 0x6c, 0x42, 0x61, 0x74, 0x63, 0x68, 0x12, 0x2a, 0x0a, + 0x0b, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, + 0x28, 0x0c, 0x42, 0x09, 0x8a, 0xb5, 0x18, 0x05, 0x36, 0x34, 0x2c, 0x33, 0x32, 0x52, 0x0a, 0x62, + 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x6f, 0x6f, 0x74, 0x73, 0x12, 0x2a, 0x0a, 0x0b, 0x73, 0x74, 0x61, + 0x74, 0x65, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0c, 0x42, 0x09, + 0x8a, 0xb5, 0x18, 0x05, 0x36, 0x34, 0x2c, 0x33, 0x32, 0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x65, + 0x52, 0x6f, 0x6f, 0x74, 0x73, 0x22, 0x7c, 0x0a, 0x0c, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x75, + 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x12, 0x58, 0x0a, 0x04, 0x73, 0x6c, 0x6f, 0x74, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x04, 0x42, 0x44, 0x82, 0xb5, 0x18, 0x40, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, + 0x63, 0x6f, 0x6d, 0x2f, 0x4f, 0x66, 0x66, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x4c, 0x61, 0x62, 0x73, + 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x37, 0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, + 0x73, 0x75, 0x73, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x70, 0x72, 0x69, 0x6d, 0x69, 0x74, + 0x69, 0x76, 0x65, 0x73, 0x2e, 0x53, 0x6c, 0x6f, 0x74, 0x52, 0x04, 0x73, 0x6c, 0x6f, 0x74, 0x12, + 0x12, 0x0a, 0x04, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x72, + 0x6f, 0x6f, 0x74, 0x22, 0x56, 0x0a, 0x0b, 0x53, 0x69, 0x67, 0x6e, 0x69, 0x6e, 0x67, 0x44, 0x61, + 0x74, 0x61, 0x12, 0x27, 0x0a, 0x0b, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x72, 0x6f, 0x6f, + 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, + 0x0a, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x6f, 0x6f, 0x74, 0x12, 0x1e, 0x0a, 0x06, 0x64, + 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, + 0x02, 0x33, 0x32, 0x52, 0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x22, 0x7a, 0x0a, 0x08, 0x46, + 0x6f, 0x72, 0x6b, 0x44, 0x61, 0x74, 0x61, 0x12, 0x2e, 0x0a, 0x0f, 0x63, 0x75, 0x72, 0x72, 0x65, + 0x6e, 0x74, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, + 0x42, 0x05, 0x8a, 0xb5, 0x18, 0x01, 0x34, 0x52, 0x0e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, + 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x3e, 0x0a, 0x17, 0x67, 0x65, 0x6e, 0x65, 0x73, + 0x69, 0x73, 0x5f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x5f, 0x72, 0x6f, + 0x6f, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, + 0x52, 0x15, 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, + 0x6f, 0x72, 0x73, 0x52, 0x6f, 0x6f, 0x74, 0x22, 0xb7, 0x01, 0x0a, 0x0b, 0x43, 0x68, 0x65, 0x63, + 0x6b, 0x50, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x65, 0x65, 0x64, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x73, 0x65, 0x65, 0x64, 0x12, 0x21, 0x0a, 0x0c, 0x67, + 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x0c, 0x52, 0x0b, 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x52, 0x6f, 0x6f, 0x74, 0x12, 0x25, + 0x0a, 0x0e, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x5f, 0x69, 0x6e, 0x64, 0x69, 0x63, 0x65, 0x73, + 0x18, 0x03, 0x20, 0x03, 0x28, 0x04, 0x52, 0x0d, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x49, 0x6e, + 0x64, 0x69, 0x63, 0x65, 0x73, 0x12, 0x19, 0x0a, 0x08, 0x70, 0x75, 0x62, 0x5f, 0x6b, 0x65, 0x79, + 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x07, 0x70, 0x75, 0x62, 0x4b, 0x65, 0x79, 0x73, + 0x12, 0x2f, 0x0a, 0x04, 0x66, 0x6f, 0x72, 0x6b, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, + 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x46, 0x6f, 0x72, 0x6b, 0x52, 0x04, 0x66, 0x6f, 0x72, + 0x6b, 0x22, 0x98, 0x01, 0x0a, 0x0e, 0x44, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x4d, 0x65, 0x73, + 0x73, 0x61, 0x67, 0x65, 0x12, 0x2f, 0x0a, 0x0a, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x5f, 0x6b, + 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x10, 0x8a, 0xb5, 0x18, 0x02, 0x34, 0x38, + 0x9a, 0xb5, 0x18, 0x06, 0x70, 0x75, 0x62, 0x6b, 0x65, 0x79, 0x52, 0x09, 0x70, 0x75, 0x62, 0x6c, + 0x69, 0x63, 0x4b, 0x65, 0x79, 0x12, 0x3d, 0x0a, 0x16, 0x77, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, + 0x77, 0x61, 0x6c, 0x5f, 0x63, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x73, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x15, 0x77, + 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x61, 0x6c, 0x43, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, + 0x69, 0x61, 0x6c, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x8d, 0x01, 0x0a, + 0x08, 0x50, 0x6f, 0x77, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x25, 0x0a, 0x0a, 0x62, 0x6c, 0x6f, + 0x63, 0x6b, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, + 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x09, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x61, 0x73, 0x68, + 0x12, 0x27, 0x0a, 0x0b, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x0a, 0x70, + 0x61, 0x72, 0x65, 0x6e, 0x74, 0x48, 0x61, 0x73, 0x68, 0x12, 0x31, 0x0a, 0x10, 0x74, 0x6f, 0x74, + 0x61, 0x6c, 0x5f, 0x64, 0x69, 0x66, 0x66, 0x69, 0x63, 0x75, 0x6c, 0x74, 0x79, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x0f, 0x74, 0x6f, 0x74, + 0x61, 0x6c, 0x44, 0x69, 0x66, 0x66, 0x69, 0x63, 0x75, 0x6c, 0x74, 0x79, 0x22, 0xc5, 0x0d, 0x0a, + 0x11, 0x42, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x41, 0x6c, 0x74, 0x61, + 0x69, 0x72, 0x12, 0x22, 0x0a, 0x0c, 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x5f, 0x74, 0x69, + 0x6d, 0x65, 0x18, 0xe9, 0x07, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, 0x67, 0x65, 0x6e, 0x65, 0x73, + 0x69, 0x73, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x3f, 0x0a, 0x17, 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, + 0x73, 0x5f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x5f, 0x72, 0x6f, 0x6f, + 0x74, 0x18, 0xea, 0x07, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, + 0x52, 0x15, 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, + 0x6f, 0x72, 0x73, 0x52, 0x6f, 0x6f, 0x74, 0x12, 0x59, 0x0a, 0x04, 0x73, 0x6c, 0x6f, 0x74, 0x18, + 0xeb, 0x07, 0x20, 0x01, 0x28, 0x04, 0x42, 0x44, 0x82, 0xb5, 0x18, 0x40, 0x67, 0x69, 0x74, 0x68, + 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x4f, 0x66, 0x66, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x4c, + 0x61, 0x62, 0x73, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x37, 0x2f, 0x63, 0x6f, 0x6e, + 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x70, 0x72, 0x69, + 0x6d, 0x69, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x53, 0x6c, 0x6f, 0x74, 0x52, 0x04, 0x73, 0x6c, + 0x6f, 0x74, 0x12, 0x30, 0x0a, 0x04, 0x66, 0x6f, 0x72, 0x6b, 0x18, 0xec, 0x07, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x1b, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, + 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x46, 0x6f, 0x72, 0x6b, 0x52, 0x04, + 0x66, 0x6f, 0x72, 0x6b, 0x12, 0x59, 0x0a, 0x13, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x62, + 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0xd1, 0x0f, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, + 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x42, 0x65, 0x61, 0x63, 0x6f, + 0x6e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x52, 0x11, 0x6c, 0x61, + 0x74, 0x65, 0x73, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, + 0x2b, 0x0a, 0x0b, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x73, 0x18, 0xd2, + 0x0f, 0x20, 0x03, 0x28, 0x0c, 0x42, 0x09, 0x8a, 0xb5, 0x18, 0x05, 0x36, 0x34, 0x2c, 0x33, 0x32, + 0x52, 0x0a, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x6f, 0x6f, 0x74, 0x73, 0x12, 0x2b, 0x0a, 0x0b, + 0x73, 0x74, 0x61, 0x74, 0x65, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x73, 0x18, 0xd3, 0x0f, 0x20, 0x03, + 0x28, 0x0c, 0x42, 0x09, 0x8a, 0xb5, 0x18, 0x05, 0x36, 0x34, 0x2c, 0x33, 0x32, 0x52, 0x0a, 0x73, + 0x74, 0x61, 0x74, 0x65, 0x52, 0x6f, 0x6f, 0x74, 0x73, 0x12, 0x40, 0x0a, 0x10, 0x68, 0x69, 0x73, + 0x74, 0x6f, 0x72, 0x69, 0x63, 0x61, 0x6c, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x73, 0x18, 0xd4, 0x0f, + 0x20, 0x03, 0x28, 0x0c, 0x42, 0x14, 0x8a, 0xb5, 0x18, 0x04, 0x3f, 0x2c, 0x33, 0x32, 0x92, 0xb5, + 0x18, 0x08, 0x31, 0x36, 0x37, 0x37, 0x37, 0x32, 0x31, 0x36, 0x52, 0x0f, 0x68, 0x69, 0x73, 0x74, + 0x6f, 0x72, 0x69, 0x63, 0x61, 0x6c, 0x52, 0x6f, 0x6f, 0x74, 0x73, 0x12, 0x3d, 0x0a, 0x09, 0x65, + 0x74, 0x68, 0x31, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x18, 0xb9, 0x17, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x1f, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, + 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x45, 0x74, 0x68, 0x31, 0x44, 0x61, 0x74, 0x61, + 0x52, 0x08, 0x65, 0x74, 0x68, 0x31, 0x44, 0x61, 0x74, 0x61, 0x12, 0x50, 0x0a, 0x0f, 0x65, 0x74, + 0x68, 0x31, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x5f, 0x76, 0x6f, 0x74, 0x65, 0x73, 0x18, 0xba, 0x17, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, + 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x45, 0x74, 0x68, + 0x31, 0x44, 0x61, 0x74, 0x61, 0x42, 0x06, 0x92, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x0d, 0x65, + 0x74, 0x68, 0x31, 0x44, 0x61, 0x74, 0x61, 0x56, 0x6f, 0x74, 0x65, 0x73, 0x12, 0x2d, 0x0a, 0x12, + 0x65, 0x74, 0x68, 0x31, 0x5f, 0x64, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x5f, 0x69, 0x6e, 0x64, + 0x65, 0x78, 0x18, 0xbb, 0x17, 0x20, 0x01, 0x28, 0x04, 0x52, 0x10, 0x65, 0x74, 0x68, 0x31, 0x44, + 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x54, 0x0a, 0x0a, 0x76, + 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x18, 0xa1, 0x1f, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x20, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, + 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, + 0x6f, 0x72, 0x42, 0x11, 0x92, 0xb5, 0x18, 0x0d, 0x31, 0x30, 0x39, 0x39, 0x35, 0x31, 0x31, 0x36, + 0x32, 0x37, 0x37, 0x37, 0x36, 0x52, 0x0a, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, + 0x73, 0x12, 0x2e, 0x0a, 0x08, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x18, 0xa2, 0x1f, + 0x20, 0x03, 0x28, 0x04, 0x42, 0x11, 0x92, 0xb5, 0x18, 0x0d, 0x31, 0x30, 0x39, 0x39, 0x35, 0x31, + 0x31, 0x36, 0x32, 0x37, 0x37, 0x37, 0x36, 0x52, 0x08, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, + 0x73, 0x12, 0x2d, 0x0a, 0x0c, 0x72, 0x61, 0x6e, 0x64, 0x61, 0x6f, 0x5f, 0x6d, 0x69, 0x78, 0x65, + 0x73, 0x18, 0x89, 0x27, 0x20, 0x03, 0x28, 0x0c, 0x42, 0x09, 0x8a, 0xb5, 0x18, 0x05, 0x36, 0x34, + 0x2c, 0x33, 0x32, 0x52, 0x0b, 0x72, 0x61, 0x6e, 0x64, 0x61, 0x6f, 0x4d, 0x69, 0x78, 0x65, 0x73, + 0x12, 0x25, 0x0a, 0x09, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x73, 0x18, 0xf1, 0x2e, + 0x20, 0x03, 0x28, 0x04, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x36, 0x34, 0x52, 0x09, 0x73, 0x6c, + 0x61, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x54, 0x0a, 0x1c, 0x70, 0x72, 0x65, 0x76, 0x69, + 0x6f, 0x75, 0x73, 0x5f, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x5f, 0x70, 0x61, 0x72, 0x74, 0x69, 0x63, + 0x69, 0x70, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0xd9, 0x36, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x11, + 0x92, 0xb5, 0x18, 0x0d, 0x31, 0x30, 0x39, 0x39, 0x35, 0x31, 0x31, 0x36, 0x32, 0x37, 0x37, 0x37, + 0x36, 0x52, 0x1a, 0x70, 0x72, 0x65, 0x76, 0x69, 0x6f, 0x75, 0x73, 0x45, 0x70, 0x6f, 0x63, 0x68, + 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x52, 0x0a, + 0x1b, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x5f, 0x70, + 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0xda, 0x36, 0x20, + 0x01, 0x28, 0x0c, 0x42, 0x11, 0x92, 0xb5, 0x18, 0x0d, 0x31, 0x30, 0x39, 0x39, 0x35, 0x31, 0x31, + 0x36, 0x32, 0x37, 0x37, 0x37, 0x36, 0x52, 0x19, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x45, + 0x70, 0x6f, 0x63, 0x68, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x12, 0x67, 0x0a, 0x12, 0x6a, 0x75, 0x73, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x5f, 0x62, 0x69, 0x74, 0x73, 0x18, 0xc1, 0x3e, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x37, + 0x82, 0xb5, 0x18, 0x2e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x4f, + 0x66, 0x66, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x4c, 0x61, 0x62, 0x73, 0x2f, 0x67, 0x6f, 0x2d, 0x62, + 0x69, 0x74, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x2e, 0x42, 0x69, 0x74, 0x76, 0x65, 0x63, 0x74, 0x6f, + 0x72, 0x34, 0x8a, 0xb5, 0x18, 0x01, 0x31, 0x52, 0x11, 0x6a, 0x75, 0x73, 0x74, 0x69, 0x66, 0x69, + 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x69, 0x74, 0x73, 0x12, 0x66, 0x0a, 0x1d, 0x70, 0x72, + 0x65, 0x76, 0x69, 0x6f, 0x75, 0x73, 0x5f, 0x6a, 0x75, 0x73, 0x74, 0x69, 0x66, 0x69, 0x65, 0x64, + 0x5f, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0xc2, 0x3e, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, + 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x43, 0x68, 0x65, 0x63, 0x6b, + 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x52, 0x1b, 0x70, 0x72, 0x65, 0x76, 0x69, 0x6f, 0x75, 0x73, 0x4a, + 0x75, 0x73, 0x74, 0x69, 0x66, 0x69, 0x65, 0x64, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, + 0x6e, 0x74, 0x12, 0x64, 0x0a, 0x1c, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x6a, 0x75, + 0x73, 0x74, 0x69, 0x66, 0x69, 0x65, 0x64, 0x5f, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, + 0x6e, 0x74, 0x18, 0xc3, 0x3e, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x65, 0x74, 0x68, 0x65, + 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, + 0x31, 0x2e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x52, 0x1a, 0x63, 0x75, + 0x72, 0x72, 0x65, 0x6e, 0x74, 0x4a, 0x75, 0x73, 0x74, 0x69, 0x66, 0x69, 0x65, 0x64, 0x43, 0x68, + 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x55, 0x0a, 0x14, 0x66, 0x69, 0x6e, 0x61, + 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x5f, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, + 0x18, 0xc4, 0x3e, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, + 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, + 0x43, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x52, 0x13, 0x66, 0x69, 0x6e, 0x61, + 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x12, + 0x3f, 0x0a, 0x11, 0x69, 0x6e, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x5f, 0x73, 0x63, + 0x6f, 0x72, 0x65, 0x73, 0x18, 0xa9, 0x46, 0x20, 0x03, 0x28, 0x04, 0x42, 0x11, 0x92, 0xb5, 0x18, + 0x0d, 0x31, 0x30, 0x39, 0x39, 0x35, 0x31, 0x31, 0x36, 0x32, 0x37, 0x37, 0x37, 0x36, 0x52, 0x10, + 0x69, 0x6e, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x53, 0x63, 0x6f, 0x72, 0x65, 0x73, + 0x12, 0x5b, 0x0a, 0x16, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x73, 0x79, 0x6e, 0x63, + 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x18, 0xaa, 0x46, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x24, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, + 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x53, 0x79, 0x6e, 0x63, 0x43, 0x6f, + 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x52, 0x14, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, + 0x53, 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x12, 0x55, 0x0a, + 0x13, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x73, 0x79, 0x6e, 0x63, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, + 0x74, 0x74, 0x65, 0x65, 0x18, 0xab, 0x46, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x65, 0x74, + 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, + 0x68, 0x61, 0x31, 0x2e, 0x53, 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, + 0x65, 0x52, 0x11, 0x6e, 0x65, 0x78, 0x74, 0x53, 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6d, 0x6d, 0x69, + 0x74, 0x74, 0x65, 0x65, 0x22, 0xa6, 0x01, 0x0a, 0x1b, 0x53, 0x79, 0x6e, 0x63, 0x41, 0x67, 0x67, + 0x72, 0x65, 0x67, 0x61, 0x74, 0x6f, 0x72, 0x53, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, + 0x44, 0x61, 0x74, 0x61, 0x12, 0x58, 0x0a, 0x04, 0x73, 0x6c, 0x6f, 0x74, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x04, 0x42, 0x44, 0x82, 0xb5, 0x18, 0x40, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, + 0x6f, 0x6d, 0x2f, 0x4f, 0x66, 0x66, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x4c, 0x61, 0x62, 0x73, 0x2f, + 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x37, 0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, + 0x75, 0x73, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x70, 0x72, 0x69, 0x6d, 0x69, 0x74, 0x69, + 0x76, 0x65, 0x73, 0x2e, 0x53, 0x6c, 0x6f, 0x74, 0x52, 0x04, 0x73, 0x6c, 0x6f, 0x74, 0x12, 0x2d, + 0x0a, 0x12, 0x73, 0x75, 0x62, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x5f, 0x69, + 0x6e, 0x64, 0x65, 0x78, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x11, 0x73, 0x75, 0x62, 0x63, + 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x22, 0xbc, 0x0e, + 0x0a, 0x14, 0x42, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x42, 0x65, 0x6c, + 0x6c, 0x61, 0x74, 0x72, 0x69, 0x78, 0x12, 0x22, 0x0a, 0x0c, 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, + 0x73, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0xe9, 0x07, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, 0x67, + 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x3f, 0x0a, 0x17, 0x67, 0x65, + 0x6e, 0x65, 0x73, 0x69, 0x73, 0x5f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, + 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0xea, 0x07, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, + 0x18, 0x02, 0x33, 0x32, 0x52, 0x15, 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x56, 0x61, 0x6c, + 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x52, 0x6f, 0x6f, 0x74, 0x12, 0x59, 0x0a, 0x04, 0x73, + 0x6c, 0x6f, 0x74, 0x18, 0xeb, 0x07, 0x20, 0x01, 0x28, 0x04, 0x42, 0x44, 0x82, 0xb5, 0x18, 0x40, + 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x4f, 0x66, 0x66, 0x63, 0x68, + 0x61, 0x69, 0x6e, 0x4c, 0x61, 0x62, 0x73, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x37, + 0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x73, + 0x2f, 0x70, 0x72, 0x69, 0x6d, 0x69, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x53, 0x6c, 0x6f, 0x74, + 0x52, 0x04, 0x73, 0x6c, 0x6f, 0x74, 0x12, 0x30, 0x0a, 0x04, 0x66, 0x6f, 0x72, 0x6b, 0x18, 0xec, + 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, + 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x46, 0x6f, + 0x72, 0x6b, 0x52, 0x04, 0x66, 0x6f, 0x72, 0x6b, 0x12, 0x59, 0x0a, 0x13, 0x6c, 0x61, 0x74, 0x65, + 0x73, 0x74, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, + 0xd1, 0x0f, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, + 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x42, + 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, + 0x52, 0x11, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x65, 0x61, + 0x64, 0x65, 0x72, 0x12, 0x2b, 0x0a, 0x0b, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x72, 0x6f, 0x6f, + 0x74, 0x73, 0x18, 0xd2, 0x0f, 0x20, 0x03, 0x28, 0x0c, 0x42, 0x09, 0x8a, 0xb5, 0x18, 0x05, 0x36, + 0x34, 0x2c, 0x33, 0x32, 0x52, 0x0a, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x6f, 0x6f, 0x74, 0x73, + 0x12, 0x2b, 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x65, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x73, 0x18, + 0xd3, 0x0f, 0x20, 0x03, 0x28, 0x0c, 0x42, 0x09, 0x8a, 0xb5, 0x18, 0x05, 0x36, 0x34, 0x2c, 0x33, + 0x32, 0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x65, 0x52, 0x6f, 0x6f, 0x74, 0x73, 0x12, 0x40, 0x0a, + 0x10, 0x68, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x69, 0x63, 0x61, 0x6c, 0x5f, 0x72, 0x6f, 0x6f, 0x74, + 0x73, 0x18, 0xd4, 0x0f, 0x20, 0x03, 0x28, 0x0c, 0x42, 0x14, 0x8a, 0xb5, 0x18, 0x04, 0x3f, 0x2c, + 0x33, 0x32, 0x92, 0xb5, 0x18, 0x08, 0x31, 0x36, 0x37, 0x37, 0x37, 0x32, 0x31, 0x36, 0x52, 0x0f, + 0x68, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x69, 0x63, 0x61, 0x6c, 0x52, 0x6f, 0x6f, 0x74, 0x73, 0x12, + 0x3d, 0x0a, 0x09, 0x65, 0x74, 0x68, 0x31, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x18, 0xb9, 0x17, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, + 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x45, 0x74, 0x68, 0x31, + 0x44, 0x61, 0x74, 0x61, 0x52, 0x08, 0x65, 0x74, 0x68, 0x31, 0x44, 0x61, 0x74, 0x61, 0x12, 0x50, + 0x0a, 0x0f, 0x65, 0x74, 0x68, 0x31, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x5f, 0x76, 0x6f, 0x74, 0x65, + 0x73, 0x18, 0xba, 0x17, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, + 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, + 0x2e, 0x45, 0x74, 0x68, 0x31, 0x44, 0x61, 0x74, 0x61, 0x42, 0x06, 0x92, 0xb5, 0x18, 0x02, 0x33, + 0x32, 0x52, 0x0d, 0x65, 0x74, 0x68, 0x31, 0x44, 0x61, 0x74, 0x61, 0x56, 0x6f, 0x74, 0x65, 0x73, + 0x12, 0x2d, 0x0a, 0x12, 0x65, 0x74, 0x68, 0x31, 0x5f, 0x64, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, + 0x5f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0xbb, 0x17, 0x20, 0x01, 0x28, 0x04, 0x52, 0x10, 0x65, + 0x74, 0x68, 0x31, 0x44, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x12, + 0x54, 0x0a, 0x0a, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x18, 0xa1, 0x1f, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, + 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x56, 0x61, 0x6c, + 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x42, 0x11, 0x92, 0xb5, 0x18, 0x0d, 0x31, 0x30, 0x39, 0x39, + 0x35, 0x31, 0x31, 0x36, 0x32, 0x37, 0x37, 0x37, 0x36, 0x52, 0x0a, 0x76, 0x61, 0x6c, 0x69, 0x64, + 0x61, 0x74, 0x6f, 0x72, 0x73, 0x12, 0x2e, 0x0a, 0x08, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, + 0x73, 0x18, 0xa2, 0x1f, 0x20, 0x03, 0x28, 0x04, 0x42, 0x11, 0x92, 0xb5, 0x18, 0x0d, 0x31, 0x30, + 0x39, 0x39, 0x35, 0x31, 0x31, 0x36, 0x32, 0x37, 0x37, 0x37, 0x36, 0x52, 0x08, 0x62, 0x61, 0x6c, + 0x61, 0x6e, 0x63, 0x65, 0x73, 0x12, 0x2d, 0x0a, 0x0c, 0x72, 0x61, 0x6e, 0x64, 0x61, 0x6f, 0x5f, + 0x6d, 0x69, 0x78, 0x65, 0x73, 0x18, 0x89, 0x27, 0x20, 0x03, 0x28, 0x0c, 0x42, 0x09, 0x8a, 0xb5, + 0x18, 0x05, 0x36, 0x34, 0x2c, 0x33, 0x32, 0x52, 0x0b, 0x72, 0x61, 0x6e, 0x64, 0x61, 0x6f, 0x4d, + 0x69, 0x78, 0x65, 0x73, 0x12, 0x25, 0x0a, 0x09, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x69, 0x6e, 0x67, + 0x73, 0x18, 0xf1, 0x2e, 0x20, 0x03, 0x28, 0x04, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x36, 0x34, + 0x52, 0x09, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x54, 0x0a, 0x1c, 0x70, + 0x72, 0x65, 0x76, 0x69, 0x6f, 0x75, 0x73, 0x5f, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x5f, 0x70, 0x61, + 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0xd9, 0x36, 0x20, 0x01, + 0x28, 0x0c, 0x42, 0x11, 0x92, 0xb5, 0x18, 0x0d, 0x31, 0x30, 0x39, 0x39, 0x35, 0x31, 0x31, 0x36, + 0x32, 0x37, 0x37, 0x37, 0x36, 0x52, 0x1a, 0x70, 0x72, 0x65, 0x76, 0x69, 0x6f, 0x75, 0x73, 0x45, + 0x70, 0x6f, 0x63, 0x68, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x12, 0x52, 0x0a, 0x1b, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x65, 0x70, 0x6f, + 0x63, 0x68, 0x5f, 0x70, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x18, 0xda, 0x36, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x11, 0x92, 0xb5, 0x18, 0x0d, 0x31, 0x30, 0x39, + 0x39, 0x35, 0x31, 0x31, 0x36, 0x32, 0x37, 0x37, 0x37, 0x36, 0x52, 0x19, 0x63, 0x75, 0x72, 0x72, + 0x65, 0x6e, 0x74, 0x45, 0x70, 0x6f, 0x63, 0x68, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x67, 0x0a, 0x12, 0x6a, 0x75, 0x73, 0x74, 0x69, 0x66, 0x69, + 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x62, 0x69, 0x74, 0x73, 0x18, 0xc1, 0x3e, 0x20, 0x01, + 0x28, 0x0c, 0x42, 0x37, 0x82, 0xb5, 0x18, 0x2e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, + 0x6f, 0x6d, 0x2f, 0x4f, 0x66, 0x66, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x4c, 0x61, 0x62, 0x73, 0x2f, + 0x67, 0x6f, 0x2d, 0x62, 0x69, 0x74, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x2e, 0x42, 0x69, 0x74, 0x76, + 0x65, 0x63, 0x74, 0x6f, 0x72, 0x34, 0x8a, 0xb5, 0x18, 0x01, 0x31, 0x52, 0x11, 0x6a, 0x75, 0x73, + 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x69, 0x74, 0x73, 0x12, 0x66, + 0x0a, 0x1d, 0x70, 0x72, 0x65, 0x76, 0x69, 0x6f, 0x75, 0x73, 0x5f, 0x6a, 0x75, 0x73, 0x74, 0x69, + 0x66, 0x69, 0x65, 0x64, 0x5f, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, + 0xc2, 0x3e, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, + 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x43, + 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x52, 0x1b, 0x70, 0x72, 0x65, 0x76, 0x69, + 0x6f, 0x75, 0x73, 0x4a, 0x75, 0x73, 0x74, 0x69, 0x66, 0x69, 0x65, 0x64, 0x43, 0x68, 0x65, 0x63, + 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x64, 0x0a, 0x1c, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, + 0x74, 0x5f, 0x6a, 0x75, 0x73, 0x74, 0x69, 0x66, 0x69, 0x65, 0x64, 0x5f, 0x63, 0x68, 0x65, 0x63, + 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0xc3, 0x3e, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, + 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, + 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, + 0x52, 0x1a, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x4a, 0x75, 0x73, 0x74, 0x69, 0x66, 0x69, + 0x65, 0x64, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x55, 0x0a, 0x14, + 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x5f, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x70, + 0x6f, 0x69, 0x6e, 0x74, 0x18, 0xc4, 0x3e, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x65, 0x74, + 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, + 0x68, 0x61, 0x31, 0x2e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x52, 0x13, + 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, + 0x69, 0x6e, 0x74, 0x12, 0x3f, 0x0a, 0x11, 0x69, 0x6e, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, + 0x79, 0x5f, 0x73, 0x63, 0x6f, 0x72, 0x65, 0x73, 0x18, 0xa9, 0x46, 0x20, 0x03, 0x28, 0x04, 0x42, + 0x11, 0x92, 0xb5, 0x18, 0x0d, 0x31, 0x30, 0x39, 0x39, 0x35, 0x31, 0x31, 0x36, 0x32, 0x37, 0x37, + 0x37, 0x36, 0x52, 0x10, 0x69, 0x6e, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x53, 0x63, + 0x6f, 0x72, 0x65, 0x73, 0x12, 0x5b, 0x0a, 0x16, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x5f, + 0x73, 0x79, 0x6e, 0x63, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x18, 0xaa, + 0x46, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, + 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x53, 0x79, + 0x6e, 0x63, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x52, 0x14, 0x63, 0x75, 0x72, + 0x72, 0x65, 0x6e, 0x74, 0x53, 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, + 0x65, 0x12, 0x55, 0x0a, 0x13, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x73, 0x79, 0x6e, 0x63, 0x5f, 0x63, + 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x18, 0xab, 0x46, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x24, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, + 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x53, 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6d, 0x6d, + 0x69, 0x74, 0x74, 0x65, 0x65, 0x52, 0x11, 0x6e, 0x65, 0x78, 0x74, 0x53, 0x79, 0x6e, 0x63, 0x43, + 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x12, 0x72, 0x0a, 0x1f, 0x6c, 0x61, 0x74, 0x65, + 0x73, 0x74, 0x5f, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x70, 0x61, 0x79, + 0x6c, 0x6f, 0x61, 0x64, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x91, 0x4e, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x6e, + 0x67, 0x69, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, + 0x6e, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x52, 0x1c, + 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x50, + 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x22, 0xfb, 0x10, 0x0a, + 0x12, 0x42, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x43, 0x61, 0x70, 0x65, + 0x6c, 0x6c, 0x61, 0x12, 0x22, 0x0a, 0x0c, 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x5f, 0x74, + 0x69, 0x6d, 0x65, 0x18, 0xe9, 0x07, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, 0x67, 0x65, 0x6e, 0x65, + 0x73, 0x69, 0x73, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x3f, 0x0a, 0x17, 0x67, 0x65, 0x6e, 0x65, 0x73, + 0x69, 0x73, 0x5f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x5f, 0x72, 0x6f, + 0x6f, 0x74, 0x18, 0xea, 0x07, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, + 0x32, 0x52, 0x15, 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, + 0x74, 0x6f, 0x72, 0x73, 0x52, 0x6f, 0x6f, 0x74, 0x12, 0x59, 0x0a, 0x04, 0x73, 0x6c, 0x6f, 0x74, + 0x18, 0xeb, 0x07, 0x20, 0x01, 0x28, 0x04, 0x42, 0x44, 0x82, 0xb5, 0x18, 0x40, 0x67, 0x69, 0x74, + 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x4f, 0x66, 0x66, 0x63, 0x68, 0x61, 0x69, 0x6e, + 0x4c, 0x61, 0x62, 0x73, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x37, 0x2f, 0x63, 0x6f, + 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x70, 0x72, + 0x69, 0x6d, 0x69, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x53, 0x6c, 0x6f, 0x74, 0x52, 0x04, 0x73, + 0x6c, 0x6f, 0x74, 0x12, 0x30, 0x0a, 0x04, 0x66, 0x6f, 0x72, 0x6b, 0x18, 0xec, 0x07, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, + 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x46, 0x6f, 0x72, 0x6b, 0x52, + 0x04, 0x66, 0x6f, 0x72, 0x6b, 0x12, 0x59, 0x0a, 0x13, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x5f, + 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0xd1, 0x0f, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, + 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x42, 0x65, 0x61, 0x63, + 0x6f, 0x6e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x52, 0x11, 0x6c, + 0x61, 0x74, 0x65, 0x73, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, + 0x12, 0x2b, 0x0a, 0x0b, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x73, 0x18, + 0xd2, 0x0f, 0x20, 0x03, 0x28, 0x0c, 0x42, 0x09, 0x8a, 0xb5, 0x18, 0x05, 0x36, 0x34, 0x2c, 0x33, + 0x32, 0x52, 0x0a, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x6f, 0x6f, 0x74, 0x73, 0x12, 0x2b, 0x0a, + 0x0b, 0x73, 0x74, 0x61, 0x74, 0x65, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x73, 0x18, 0xd3, 0x0f, 0x20, + 0x03, 0x28, 0x0c, 0x42, 0x09, 0x8a, 0xb5, 0x18, 0x05, 0x36, 0x34, 0x2c, 0x33, 0x32, 0x52, 0x0a, + 0x73, 0x74, 0x61, 0x74, 0x65, 0x52, 0x6f, 0x6f, 0x74, 0x73, 0x12, 0x40, 0x0a, 0x10, 0x68, 0x69, + 0x73, 0x74, 0x6f, 0x72, 0x69, 0x63, 0x61, 0x6c, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x73, 0x18, 0xd4, + 0x0f, 0x20, 0x03, 0x28, 0x0c, 0x42, 0x14, 0x8a, 0xb5, 0x18, 0x04, 0x3f, 0x2c, 0x33, 0x32, 0x92, + 0xb5, 0x18, 0x08, 0x31, 0x36, 0x37, 0x37, 0x37, 0x32, 0x31, 0x36, 0x52, 0x0f, 0x68, 0x69, 0x73, + 0x74, 0x6f, 0x72, 0x69, 0x63, 0x61, 0x6c, 0x52, 0x6f, 0x6f, 0x74, 0x73, 0x12, 0x3d, 0x0a, 0x09, + 0x65, 0x74, 0x68, 0x31, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x18, 0xb9, 0x17, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x1f, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, + 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x45, 0x74, 0x68, 0x31, 0x44, 0x61, 0x74, + 0x61, 0x52, 0x08, 0x65, 0x74, 0x68, 0x31, 0x44, 0x61, 0x74, 0x61, 0x12, 0x50, 0x0a, 0x0f, 0x65, + 0x74, 0x68, 0x31, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x5f, 0x76, 0x6f, 0x74, 0x65, 0x73, 0x18, 0xba, + 0x17, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, + 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x45, 0x74, + 0x68, 0x31, 0x44, 0x61, 0x74, 0x61, 0x42, 0x06, 0x92, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x0d, + 0x65, 0x74, 0x68, 0x31, 0x44, 0x61, 0x74, 0x61, 0x56, 0x6f, 0x74, 0x65, 0x73, 0x12, 0x2d, 0x0a, + 0x12, 0x65, 0x74, 0x68, 0x31, 0x5f, 0x64, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x5f, 0x69, 0x6e, + 0x64, 0x65, 0x78, 0x18, 0xbb, 0x17, 0x20, 0x01, 0x28, 0x04, 0x52, 0x10, 0x65, 0x74, 0x68, 0x31, + 0x44, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x54, 0x0a, 0x0a, + 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x18, 0xa1, 0x1f, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x20, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, + 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, + 0x74, 0x6f, 0x72, 0x42, 0x11, 0x92, 0xb5, 0x18, 0x0d, 0x31, 0x30, 0x39, 0x39, 0x35, 0x31, 0x31, + 0x36, 0x32, 0x37, 0x37, 0x37, 0x36, 0x52, 0x0a, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, + 0x72, 0x73, 0x12, 0x2e, 0x0a, 0x08, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x18, 0xa2, + 0x1f, 0x20, 0x03, 0x28, 0x04, 0x42, 0x11, 0x92, 0xb5, 0x18, 0x0d, 0x31, 0x30, 0x39, 0x39, 0x35, + 0x31, 0x31, 0x36, 0x32, 0x37, 0x37, 0x37, 0x36, 0x52, 0x08, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, + 0x65, 0x73, 0x12, 0x2d, 0x0a, 0x0c, 0x72, 0x61, 0x6e, 0x64, 0x61, 0x6f, 0x5f, 0x6d, 0x69, 0x78, + 0x65, 0x73, 0x18, 0x89, 0x27, 0x20, 0x03, 0x28, 0x0c, 0x42, 0x09, 0x8a, 0xb5, 0x18, 0x05, 0x36, + 0x34, 0x2c, 0x33, 0x32, 0x52, 0x0b, 0x72, 0x61, 0x6e, 0x64, 0x61, 0x6f, 0x4d, 0x69, 0x78, 0x65, + 0x73, 0x12, 0x25, 0x0a, 0x09, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x73, 0x18, 0xf1, + 0x2e, 0x20, 0x03, 0x28, 0x04, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x36, 0x34, 0x52, 0x09, 0x73, + 0x6c, 0x61, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x54, 0x0a, 0x1c, 0x70, 0x72, 0x65, 0x76, + 0x69, 0x6f, 0x75, 0x73, 0x5f, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x5f, 0x70, 0x61, 0x72, 0x74, 0x69, + 0x63, 0x69, 0x70, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0xd9, 0x36, 0x20, 0x01, 0x28, 0x0c, 0x42, + 0x11, 0x92, 0xb5, 0x18, 0x0d, 0x31, 0x30, 0x39, 0x39, 0x35, 0x31, 0x31, 0x36, 0x32, 0x37, 0x37, + 0x37, 0x36, 0x52, 0x1a, 0x70, 0x72, 0x65, 0x76, 0x69, 0x6f, 0x75, 0x73, 0x45, 0x70, 0x6f, 0x63, + 0x68, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x52, + 0x0a, 0x1b, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x5f, + 0x70, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0xda, 0x36, + 0x20, 0x01, 0x28, 0x0c, 0x42, 0x11, 0x92, 0xb5, 0x18, 0x0d, 0x31, 0x30, 0x39, 0x39, 0x35, 0x31, + 0x31, 0x36, 0x32, 0x37, 0x37, 0x37, 0x36, 0x52, 0x19, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, + 0x45, 0x70, 0x6f, 0x63, 0x68, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x12, 0x67, 0x0a, 0x12, 0x6a, 0x75, 0x73, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x5f, 0x62, 0x69, 0x74, 0x73, 0x18, 0xc1, 0x3e, 0x20, 0x01, 0x28, 0x0c, 0x42, + 0x37, 0x82, 0xb5, 0x18, 0x2e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, + 0x4f, 0x66, 0x66, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x4c, 0x61, 0x62, 0x73, 0x2f, 0x67, 0x6f, 0x2d, + 0x62, 0x69, 0x74, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x2e, 0x42, 0x69, 0x74, 0x76, 0x65, 0x63, 0x74, + 0x6f, 0x72, 0x34, 0x8a, 0xb5, 0x18, 0x01, 0x31, 0x52, 0x11, 0x6a, 0x75, 0x73, 0x74, 0x69, 0x66, + 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x69, 0x74, 0x73, 0x12, 0x66, 0x0a, 0x1d, 0x70, + 0x72, 0x65, 0x76, 0x69, 0x6f, 0x75, 0x73, 0x5f, 0x6a, 0x75, 0x73, 0x74, 0x69, 0x66, 0x69, 0x65, + 0x64, 0x5f, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0xc2, 0x3e, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, + 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x43, 0x68, 0x65, 0x63, + 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x52, 0x1b, 0x70, 0x72, 0x65, 0x76, 0x69, 0x6f, 0x75, 0x73, + 0x4a, 0x75, 0x73, 0x74, 0x69, 0x66, 0x69, 0x65, 0x64, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, + 0x69, 0x6e, 0x74, 0x12, 0x64, 0x0a, 0x1c, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x6a, + 0x75, 0x73, 0x74, 0x69, 0x66, 0x69, 0x65, 0x64, 0x5f, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, + 0x69, 0x6e, 0x74, 0x18, 0xc3, 0x3e, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x65, 0x74, 0x68, + 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, + 0x61, 0x31, 0x2e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x52, 0x1a, 0x63, + 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x4a, 0x75, 0x73, 0x74, 0x69, 0x66, 0x69, 0x65, 0x64, 0x43, + 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x55, 0x0a, 0x14, 0x66, 0x69, 0x6e, + 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x5f, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, + 0x74, 0x18, 0xc4, 0x3e, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, + 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, + 0x2e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x52, 0x13, 0x66, 0x69, 0x6e, + 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, + 0x12, 0x3f, 0x0a, 0x11, 0x69, 0x6e, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x5f, 0x73, + 0x63, 0x6f, 0x72, 0x65, 0x73, 0x18, 0xa9, 0x46, 0x20, 0x03, 0x28, 0x04, 0x42, 0x11, 0x92, 0xb5, + 0x18, 0x0d, 0x31, 0x30, 0x39, 0x39, 0x35, 0x31, 0x31, 0x36, 0x32, 0x37, 0x37, 0x37, 0x36, 0x52, + 0x10, 0x69, 0x6e, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x53, 0x63, 0x6f, 0x72, 0x65, + 0x73, 0x12, 0x5b, 0x0a, 0x16, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x73, 0x79, 0x6e, + 0x63, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x18, 0xaa, 0x46, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, + 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x53, 0x79, 0x6e, 0x63, 0x43, + 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x52, 0x14, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, + 0x74, 0x53, 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x12, 0x55, + 0x0a, 0x13, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x73, 0x79, 0x6e, 0x63, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, + 0x69, 0x74, 0x74, 0x65, 0x65, 0x18, 0xab, 0x46, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x65, + 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, + 0x70, 0x68, 0x61, 0x31, 0x2e, 0x53, 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, + 0x65, 0x65, 0x52, 0x11, 0x6e, 0x65, 0x78, 0x74, 0x53, 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6d, 0x6d, + 0x69, 0x74, 0x74, 0x65, 0x65, 0x12, 0x79, 0x0a, 0x1f, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x5f, + 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, + 0x64, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x91, 0x4e, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x31, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x6e, 0x67, 0x69, 0x6e, + 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x61, + 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x43, 0x61, 0x70, 0x65, 0x6c, + 0x6c, 0x61, 0x52, 0x1c, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, + 0x69, 0x6f, 0x6e, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, + 0x12, 0x33, 0x0a, 0x15, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x77, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, + 0x77, 0x61, 0x6c, 0x5f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0xf9, 0x55, 0x20, 0x01, 0x28, 0x04, + 0x52, 0x13, 0x6e, 0x65, 0x78, 0x74, 0x57, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x61, 0x6c, + 0x49, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x96, 0x01, 0x0a, 0x1f, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x77, + 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x61, 0x6c, 0x5f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, + 0x74, 0x6f, 0x72, 0x5f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0xfa, 0x55, 0x20, 0x01, 0x28, 0x04, + 0x42, 0x4e, 0x82, 0xb5, 0x18, 0x4a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, + 0x2f, 0x4f, 0x66, 0x66, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x4c, 0x61, 0x62, 0x73, 0x2f, 0x70, 0x72, + 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x37, 0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, + 0x2d, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x70, 0x72, 0x69, 0x6d, 0x69, 0x74, 0x69, 0x76, 0x65, + 0x73, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x49, 0x6e, 0x64, 0x65, 0x78, + 0x52, 0x1c, 0x6e, 0x65, 0x78, 0x74, 0x57, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x61, 0x6c, + 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x6a, + 0x0a, 0x14, 0x68, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x69, 0x63, 0x61, 0x6c, 0x5f, 0x73, 0x75, 0x6d, + 0x6d, 0x61, 0x72, 0x69, 0x65, 0x73, 0x18, 0xfb, 0x55, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x28, 0x2e, + 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, + 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x69, 0x63, 0x61, 0x6c, + 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x42, 0x0c, 0x92, 0xb5, 0x18, 0x08, 0x31, 0x36, 0x37, + 0x37, 0x37, 0x32, 0x31, 0x36, 0x52, 0x13, 0x68, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x69, 0x63, 0x61, + 0x6c, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x69, 0x65, 0x73, 0x22, 0xf7, 0x10, 0x0a, 0x10, 0x42, + 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x44, 0x65, 0x6e, 0x65, 0x62, 0x12, + 0x22, 0x0a, 0x0c, 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, + 0xe9, 0x07, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x54, + 0x69, 0x6d, 0x65, 0x12, 0x3f, 0x0a, 0x17, 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x5f, 0x76, + 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0xea, + 0x07, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x15, 0x67, + 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, + 0x52, 0x6f, 0x6f, 0x74, 0x12, 0x59, 0x0a, 0x04, 0x73, 0x6c, 0x6f, 0x74, 0x18, 0xeb, 0x07, 0x20, + 0x01, 0x28, 0x04, 0x42, 0x44, 0x82, 0xb5, 0x18, 0x40, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, + 0x63, 0x6f, 0x6d, 0x2f, 0x4f, 0x66, 0x66, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x4c, 0x61, 0x62, 0x73, + 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x37, 0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, + 0x73, 0x75, 0x73, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x70, 0x72, 0x69, 0x6d, 0x69, 0x74, + 0x69, 0x76, 0x65, 0x73, 0x2e, 0x53, 0x6c, 0x6f, 0x74, 0x52, 0x04, 0x73, 0x6c, 0x6f, 0x74, 0x12, + 0x30, 0x0a, 0x04, 0x66, 0x6f, 0x72, 0x6b, 0x18, 0xec, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, + 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x46, 0x6f, 0x72, 0x6b, 0x52, 0x04, 0x66, 0x6f, 0x72, + 0x6b, 0x12, 0x59, 0x0a, 0x13, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x62, 0x6c, 0x6f, 0x63, + 0x6b, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0xd1, 0x0f, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x28, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, + 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x42, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x42, 0x6c, + 0x6f, 0x63, 0x6b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x52, 0x11, 0x6c, 0x61, 0x74, 0x65, 0x73, + 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x2b, 0x0a, 0x0b, + 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x73, 0x18, 0xd2, 0x0f, 0x20, 0x03, + 0x28, 0x0c, 0x42, 0x09, 0x8a, 0xb5, 0x18, 0x05, 0x36, 0x34, 0x2c, 0x33, 0x32, 0x52, 0x0a, 0x62, + 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x6f, 0x6f, 0x74, 0x73, 0x12, 0x2b, 0x0a, 0x0b, 0x73, 0x74, 0x61, + 0x74, 0x65, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x73, 0x18, 0xd3, 0x0f, 0x20, 0x03, 0x28, 0x0c, 0x42, + 0x09, 0x8a, 0xb5, 0x18, 0x05, 0x36, 0x34, 0x2c, 0x33, 0x32, 0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, + 0x65, 0x52, 0x6f, 0x6f, 0x74, 0x73, 0x12, 0x40, 0x0a, 0x10, 0x68, 0x69, 0x73, 0x74, 0x6f, 0x72, + 0x69, 0x63, 0x61, 0x6c, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x73, 0x18, 0xd4, 0x0f, 0x20, 0x03, 0x28, + 0x0c, 0x42, 0x14, 0x8a, 0xb5, 0x18, 0x04, 0x3f, 0x2c, 0x33, 0x32, 0x92, 0xb5, 0x18, 0x08, 0x31, + 0x36, 0x37, 0x37, 0x37, 0x32, 0x31, 0x36, 0x52, 0x0f, 0x68, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x69, + 0x63, 0x61, 0x6c, 0x52, 0x6f, 0x6f, 0x74, 0x73, 0x12, 0x3d, 0x0a, 0x09, 0x65, 0x74, 0x68, 0x31, + 0x5f, 0x64, 0x61, 0x74, 0x61, 0x18, 0xb9, 0x17, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x65, + 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, + 0x70, 0x68, 0x61, 0x31, 0x2e, 0x45, 0x74, 0x68, 0x31, 0x44, 0x61, 0x74, 0x61, 0x52, 0x08, 0x65, + 0x74, 0x68, 0x31, 0x44, 0x61, 0x74, 0x61, 0x12, 0x50, 0x0a, 0x0f, 0x65, 0x74, 0x68, 0x31, 0x5f, + 0x64, 0x61, 0x74, 0x61, 0x5f, 0x76, 0x6f, 0x74, 0x65, 0x73, 0x18, 0xba, 0x17, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x1f, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, + 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x45, 0x74, 0x68, 0x31, 0x44, 0x61, + 0x74, 0x61, 0x42, 0x06, 0x92, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x0d, 0x65, 0x74, 0x68, 0x31, + 0x44, 0x61, 0x74, 0x61, 0x56, 0x6f, 0x74, 0x65, 0x73, 0x12, 0x2d, 0x0a, 0x12, 0x65, 0x74, 0x68, + 0x31, 0x5f, 0x64, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x5f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, + 0xbb, 0x17, 0x20, 0x01, 0x28, 0x04, 0x52, 0x10, 0x65, 0x74, 0x68, 0x31, 0x44, 0x65, 0x70, 0x6f, + 0x73, 0x69, 0x74, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x54, 0x0a, 0x0a, 0x76, 0x61, 0x6c, 0x69, + 0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x18, 0xa1, 0x1f, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, + 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, + 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x42, + 0x11, 0x92, 0xb5, 0x18, 0x0d, 0x31, 0x30, 0x39, 0x39, 0x35, 0x31, 0x31, 0x36, 0x32, 0x37, 0x37, + 0x37, 0x36, 0x52, 0x0a, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x12, 0x2e, + 0x0a, 0x08, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x18, 0xa2, 0x1f, 0x20, 0x03, 0x28, + 0x04, 0x42, 0x11, 0x92, 0xb5, 0x18, 0x0d, 0x31, 0x30, 0x39, 0x39, 0x35, 0x31, 0x31, 0x36, 0x32, + 0x37, 0x37, 0x37, 0x36, 0x52, 0x08, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x12, 0x2d, + 0x0a, 0x0c, 0x72, 0x61, 0x6e, 0x64, 0x61, 0x6f, 0x5f, 0x6d, 0x69, 0x78, 0x65, 0x73, 0x18, 0x89, + 0x27, 0x20, 0x03, 0x28, 0x0c, 0x42, 0x09, 0x8a, 0xb5, 0x18, 0x05, 0x36, 0x34, 0x2c, 0x33, 0x32, + 0x52, 0x0b, 0x72, 0x61, 0x6e, 0x64, 0x61, 0x6f, 0x4d, 0x69, 0x78, 0x65, 0x73, 0x12, 0x25, 0x0a, + 0x09, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x73, 0x18, 0xf1, 0x2e, 0x20, 0x03, 0x28, + 0x04, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x36, 0x34, 0x52, 0x09, 0x73, 0x6c, 0x61, 0x73, 0x68, + 0x69, 0x6e, 0x67, 0x73, 0x12, 0x54, 0x0a, 0x1c, 0x70, 0x72, 0x65, 0x76, 0x69, 0x6f, 0x75, 0x73, + 0x5f, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x5f, 0x70, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x18, 0xd9, 0x36, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x11, 0x92, 0xb5, 0x18, + 0x0d, 0x31, 0x30, 0x39, 0x39, 0x35, 0x31, 0x31, 0x36, 0x32, 0x37, 0x37, 0x37, 0x36, 0x52, 0x1a, + 0x70, 0x72, 0x65, 0x76, 0x69, 0x6f, 0x75, 0x73, 0x45, 0x70, 0x6f, 0x63, 0x68, 0x50, 0x61, 0x72, + 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x52, 0x0a, 0x1b, 0x63, 0x75, + 0x72, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x5f, 0x70, 0x61, 0x72, 0x74, + 0x69, 0x63, 0x69, 0x70, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0xda, 0x36, 0x20, 0x01, 0x28, 0x0c, + 0x42, 0x11, 0x92, 0xb5, 0x18, 0x0d, 0x31, 0x30, 0x39, 0x39, 0x35, 0x31, 0x31, 0x36, 0x32, 0x37, + 0x37, 0x37, 0x36, 0x52, 0x19, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x45, 0x70, 0x6f, 0x63, + 0x68, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x67, + 0x0a, 0x12, 0x6a, 0x75, 0x73, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, + 0x62, 0x69, 0x74, 0x73, 0x18, 0xc1, 0x3e, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x37, 0x82, 0xb5, 0x18, + 0x2e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x4f, 0x66, 0x66, 0x63, + 0x68, 0x61, 0x69, 0x6e, 0x4c, 0x61, 0x62, 0x73, 0x2f, 0x67, 0x6f, 0x2d, 0x62, 0x69, 0x74, 0x66, + 0x69, 0x65, 0x6c, 0x64, 0x2e, 0x42, 0x69, 0x74, 0x76, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x34, 0x8a, + 0xb5, 0x18, 0x01, 0x31, 0x52, 0x11, 0x6a, 0x75, 0x73, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x42, 0x69, 0x74, 0x73, 0x12, 0x66, 0x0a, 0x1d, 0x70, 0x72, 0x65, 0x76, 0x69, + 0x6f, 0x75, 0x73, 0x5f, 0x6a, 0x75, 0x73, 0x74, 0x69, 0x66, 0x69, 0x65, 0x64, 0x5f, 0x63, 0x68, + 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0xc2, 0x3e, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x21, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, + 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, + 0x6e, 0x74, 0x52, 0x1b, 0x70, 0x72, 0x65, 0x76, 0x69, 0x6f, 0x75, 0x73, 0x4a, 0x75, 0x73, 0x74, + 0x69, 0x66, 0x69, 0x65, 0x64, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x12, + 0x64, 0x0a, 0x1c, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x6a, 0x75, 0x73, 0x74, 0x69, + 0x66, 0x69, 0x65, 0x64, 0x5f, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, + 0xc3, 0x3e, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, + 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x43, + 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x52, 0x1a, 0x63, 0x75, 0x72, 0x72, 0x65, + 0x6e, 0x74, 0x4a, 0x75, 0x73, 0x74, 0x69, 0x66, 0x69, 0x65, 0x64, 0x43, 0x68, 0x65, 0x63, 0x6b, + 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x55, 0x0a, 0x14, 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x7a, + 0x65, 0x64, 0x5f, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0xc4, 0x3e, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, + 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x43, 0x68, 0x65, + 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x52, 0x13, 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x7a, + 0x65, 0x64, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x3f, 0x0a, 0x11, + 0x69, 0x6e, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x5f, 0x73, 0x63, 0x6f, 0x72, 0x65, + 0x73, 0x18, 0xa9, 0x46, 0x20, 0x03, 0x28, 0x04, 0x42, 0x11, 0x92, 0xb5, 0x18, 0x0d, 0x31, 0x30, + 0x39, 0x39, 0x35, 0x31, 0x31, 0x36, 0x32, 0x37, 0x37, 0x37, 0x36, 0x52, 0x10, 0x69, 0x6e, 0x61, + 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x53, 0x63, 0x6f, 0x72, 0x65, 0x73, 0x12, 0x5b, 0x0a, + 0x16, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x73, 0x79, 0x6e, 0x63, 0x5f, 0x63, 0x6f, + 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x18, 0xaa, 0x46, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x24, + 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x53, 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6d, 0x6d, 0x69, + 0x74, 0x74, 0x65, 0x65, 0x52, 0x14, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x53, 0x79, 0x6e, + 0x63, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x12, 0x55, 0x0a, 0x13, 0x6e, 0x65, + 0x78, 0x74, 0x5f, 0x73, 0x79, 0x6e, 0x63, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, + 0x65, 0x18, 0xab, 0x46, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, + 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, + 0x2e, 0x53, 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x52, 0x11, + 0x6e, 0x65, 0x78, 0x74, 0x53, 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, + 0x65, 0x12, 0x77, 0x0a, 0x1f, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x65, 0x78, 0x65, 0x63, + 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x5f, 0x68, 0x65, + 0x61, 0x64, 0x65, 0x72, 0x18, 0x91, 0x4e, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2f, 0x2e, 0x65, 0x74, + 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x2e, 0x76, 0x31, + 0x2e, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, + 0x64, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x44, 0x65, 0x6e, 0x65, 0x62, 0x52, 0x1c, 0x6c, 0x61, + 0x74, 0x65, 0x73, 0x74, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x61, 0x79, + 0x6c, 0x6f, 0x61, 0x64, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x33, 0x0a, 0x15, 0x6e, 0x65, + 0x78, 0x74, 0x5f, 0x77, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x61, 0x6c, 0x5f, 0x69, 0x6e, + 0x64, 0x65, 0x78, 0x18, 0xf9, 0x55, 0x20, 0x01, 0x28, 0x04, 0x52, 0x13, 0x6e, 0x65, 0x78, 0x74, + 0x57, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x61, 0x6c, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x12, + 0x96, 0x01, 0x0a, 0x1f, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x77, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, + 0x77, 0x61, 0x6c, 0x5f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x5f, 0x69, 0x6e, + 0x64, 0x65, 0x78, 0x18, 0xfa, 0x55, 0x20, 0x01, 0x28, 0x04, 0x42, 0x4e, 0x82, 0xb5, 0x18, 0x4a, + 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x4f, 0x66, 0x66, 0x63, 0x68, + 0x61, 0x69, 0x6e, 0x4c, 0x61, 0x62, 0x73, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x37, + 0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x73, + 0x2f, 0x70, 0x72, 0x69, 0x6d, 0x69, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x56, 0x61, 0x6c, 0x69, + 0x64, 0x61, 0x74, 0x6f, 0x72, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x52, 0x1c, 0x6e, 0x65, 0x78, 0x74, + 0x57, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x61, 0x6c, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, + 0x74, 0x6f, 0x72, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x6a, 0x0a, 0x14, 0x68, 0x69, 0x73, 0x74, + 0x6f, 0x72, 0x69, 0x63, 0x61, 0x6c, 0x5f, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x69, 0x65, 0x73, + 0x18, 0xfb, 0x55, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, + 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, + 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x69, 0x63, 0x61, 0x6c, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, + 0x79, 0x42, 0x0c, 0x92, 0xb5, 0x18, 0x08, 0x31, 0x36, 0x37, 0x37, 0x37, 0x32, 0x31, 0x36, 0x52, + 0x13, 0x68, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x69, 0x63, 0x61, 0x6c, 0x53, 0x75, 0x6d, 0x6d, 0x61, + 0x72, 0x69, 0x65, 0x73, 0x22, 0x9b, 0x19, 0x0a, 0x12, 0x42, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x53, + 0x74, 0x61, 0x74, 0x65, 0x45, 0x6c, 0x65, 0x63, 0x74, 0x72, 0x61, 0x12, 0x22, 0x0a, 0x0c, 0x67, + 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0xe9, 0x07, 0x20, 0x01, + 0x28, 0x04, 0x52, 0x0b, 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x54, 0x69, 0x6d, 0x65, 0x12, + 0x3f, 0x0a, 0x17, 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x5f, 0x76, 0x61, 0x6c, 0x69, 0x64, + 0x61, 0x74, 0x6f, 0x72, 0x73, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0xea, 0x07, 0x20, 0x01, 0x28, + 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x15, 0x67, 0x65, 0x6e, 0x65, 0x73, + 0x69, 0x73, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x52, 0x6f, 0x6f, 0x74, + 0x12, 0x59, 0x0a, 0x04, 0x73, 0x6c, 0x6f, 0x74, 0x18, 0xeb, 0x07, 0x20, 0x01, 0x28, 0x04, 0x42, + 0x44, 0x82, 0xb5, 0x18, 0x40, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, + 0x4f, 0x66, 0x66, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x4c, 0x61, 0x62, 0x73, 0x2f, 0x70, 0x72, 0x79, + 0x73, 0x6d, 0x2f, 0x76, 0x37, 0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2d, + 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x70, 0x72, 0x69, 0x6d, 0x69, 0x74, 0x69, 0x76, 0x65, 0x73, + 0x2e, 0x53, 0x6c, 0x6f, 0x74, 0x52, 0x04, 0x73, 0x6c, 0x6f, 0x74, 0x12, 0x30, 0x0a, 0x04, 0x66, + 0x6f, 0x72, 0x6b, 0x18, 0xec, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x65, 0x74, 0x68, + 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, + 0x61, 0x31, 0x2e, 0x46, 0x6f, 0x72, 0x6b, 0x52, 0x04, 0x66, 0x6f, 0x72, 0x6b, 0x12, 0x59, 0x0a, + 0x13, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x68, 0x65, + 0x61, 0x64, 0x65, 0x72, 0x18, 0xd1, 0x0f, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x65, 0x74, + 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, + 0x68, 0x61, 0x31, 0x2e, 0x42, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x48, + 0x65, 0x61, 0x64, 0x65, 0x72, 0x52, 0x11, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x42, 0x6c, 0x6f, + 0x63, 0x6b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x2b, 0x0a, 0x0b, 0x62, 0x6c, 0x6f, 0x63, + 0x6b, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x73, 0x18, 0xd2, 0x0f, 0x20, 0x03, 0x28, 0x0c, 0x42, 0x09, + 0x8a, 0xb5, 0x18, 0x05, 0x36, 0x34, 0x2c, 0x33, 0x32, 0x52, 0x0a, 0x62, 0x6c, 0x6f, 0x63, 0x6b, + 0x52, 0x6f, 0x6f, 0x74, 0x73, 0x12, 0x2b, 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x65, 0x5f, 0x72, + 0x6f, 0x6f, 0x74, 0x73, 0x18, 0xd3, 0x0f, 0x20, 0x03, 0x28, 0x0c, 0x42, 0x09, 0x8a, 0xb5, 0x18, + 0x05, 0x36, 0x34, 0x2c, 0x33, 0x32, 0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x65, 0x52, 0x6f, 0x6f, + 0x74, 0x73, 0x12, 0x40, 0x0a, 0x10, 0x68, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x69, 0x63, 0x61, 0x6c, + 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x73, 0x18, 0xd4, 0x0f, 0x20, 0x03, 0x28, 0x0c, 0x42, 0x14, 0x8a, + 0xb5, 0x18, 0x04, 0x3f, 0x2c, 0x33, 0x32, 0x92, 0xb5, 0x18, 0x08, 0x31, 0x36, 0x37, 0x37, 0x37, + 0x32, 0x31, 0x36, 0x52, 0x0f, 0x68, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x69, 0x63, 0x61, 0x6c, 0x52, + 0x6f, 0x6f, 0x74, 0x73, 0x12, 0x3d, 0x0a, 0x09, 0x65, 0x74, 0x68, 0x31, 0x5f, 0x64, 0x61, 0x74, + 0x61, 0x18, 0xb9, 0x17, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, + 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, + 0x2e, 0x45, 0x74, 0x68, 0x31, 0x44, 0x61, 0x74, 0x61, 0x52, 0x08, 0x65, 0x74, 0x68, 0x31, 0x44, + 0x61, 0x74, 0x61, 0x12, 0x50, 0x0a, 0x0f, 0x65, 0x74, 0x68, 0x31, 0x5f, 0x64, 0x61, 0x74, 0x61, + 0x5f, 0x76, 0x6f, 0x74, 0x65, 0x73, 0x18, 0xba, 0x17, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1f, 0x2e, + 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, + 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x45, 0x74, 0x68, 0x31, 0x44, 0x61, 0x74, 0x61, 0x42, 0x06, + 0x92, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x0d, 0x65, 0x74, 0x68, 0x31, 0x44, 0x61, 0x74, 0x61, + 0x56, 0x6f, 0x74, 0x65, 0x73, 0x12, 0x2d, 0x0a, 0x12, 0x65, 0x74, 0x68, 0x31, 0x5f, 0x64, 0x65, + 0x70, 0x6f, 0x73, 0x69, 0x74, 0x5f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0xbb, 0x17, 0x20, 0x01, + 0x28, 0x04, 0x52, 0x10, 0x65, 0x74, 0x68, 0x31, 0x44, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x49, + 0x6e, 0x64, 0x65, 0x78, 0x12, 0x54, 0x0a, 0x0a, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, + 0x72, 0x73, 0x18, 0xa1, 0x1f, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x65, 0x74, 0x68, 0x65, + 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, + 0x31, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x42, 0x11, 0x92, 0xb5, 0x18, + 0x0d, 0x31, 0x30, 0x39, 0x39, 0x35, 0x31, 0x31, 0x36, 0x32, 0x37, 0x37, 0x37, 0x36, 0x52, 0x0a, + 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x12, 0x2e, 0x0a, 0x08, 0x62, 0x61, + 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x18, 0xa2, 0x1f, 0x20, 0x03, 0x28, 0x04, 0x42, 0x11, 0x92, + 0xb5, 0x18, 0x0d, 0x31, 0x30, 0x39, 0x39, 0x35, 0x31, 0x31, 0x36, 0x32, 0x37, 0x37, 0x37, 0x36, + 0x52, 0x08, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x12, 0x2d, 0x0a, 0x0c, 0x72, 0x61, + 0x6e, 0x64, 0x61, 0x6f, 0x5f, 0x6d, 0x69, 0x78, 0x65, 0x73, 0x18, 0x89, 0x27, 0x20, 0x03, 0x28, + 0x0c, 0x42, 0x09, 0x8a, 0xb5, 0x18, 0x05, 0x36, 0x34, 0x2c, 0x33, 0x32, 0x52, 0x0b, 0x72, 0x61, + 0x6e, 0x64, 0x61, 0x6f, 0x4d, 0x69, 0x78, 0x65, 0x73, 0x12, 0x25, 0x0a, 0x09, 0x73, 0x6c, 0x61, + 0x73, 0x68, 0x69, 0x6e, 0x67, 0x73, 0x18, 0xf1, 0x2e, 0x20, 0x03, 0x28, 0x04, 0x42, 0x06, 0x8a, + 0xb5, 0x18, 0x02, 0x36, 0x34, 0x52, 0x09, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x73, + 0x12, 0x54, 0x0a, 0x1c, 0x70, 0x72, 0x65, 0x76, 0x69, 0x6f, 0x75, 0x73, 0x5f, 0x65, 0x70, 0x6f, + 0x63, 0x68, 0x5f, 0x70, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x18, 0xd9, 0x36, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x11, 0x92, 0xb5, 0x18, 0x0d, 0x31, 0x30, 0x39, + 0x39, 0x35, 0x31, 0x31, 0x36, 0x32, 0x37, 0x37, 0x37, 0x36, 0x52, 0x1a, 0x70, 0x72, 0x65, 0x76, + 0x69, 0x6f, 0x75, 0x73, 0x45, 0x70, 0x6f, 0x63, 0x68, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, + 0x70, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x52, 0x0a, 0x1b, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, + 0x74, 0x5f, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x5f, 0x70, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0xda, 0x36, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x11, 0x92, 0xb5, + 0x18, 0x0d, 0x31, 0x30, 0x39, 0x39, 0x35, 0x31, 0x31, 0x36, 0x32, 0x37, 0x37, 0x37, 0x36, 0x52, + 0x19, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x45, 0x70, 0x6f, 0x63, 0x68, 0x50, 0x61, 0x72, + 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x67, 0x0a, 0x12, 0x6a, 0x75, + 0x73, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x62, 0x69, 0x74, 0x73, + 0x18, 0xc1, 0x3e, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x37, 0x82, 0xb5, 0x18, 0x2e, 0x67, 0x69, 0x74, + 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x4f, 0x66, 0x66, 0x63, 0x68, 0x61, 0x69, 0x6e, + 0x4c, 0x61, 0x62, 0x73, 0x2f, 0x67, 0x6f, 0x2d, 0x62, 0x69, 0x74, 0x66, 0x69, 0x65, 0x6c, 0x64, + 0x2e, 0x42, 0x69, 0x74, 0x76, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x34, 0x8a, 0xb5, 0x18, 0x01, 0x31, + 0x52, 0x11, 0x6a, 0x75, 0x73, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, + 0x69, 0x74, 0x73, 0x12, 0x66, 0x0a, 0x1d, 0x70, 0x72, 0x65, 0x76, 0x69, 0x6f, 0x75, 0x73, 0x5f, + 0x6a, 0x75, 0x73, 0x74, 0x69, 0x66, 0x69, 0x65, 0x64, 0x5f, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x70, + 0x6f, 0x69, 0x6e, 0x74, 0x18, 0xc2, 0x3e, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x65, 0x74, + 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, + 0x68, 0x61, 0x31, 0x2e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x52, 0x1b, + 0x70, 0x72, 0x65, 0x76, 0x69, 0x6f, 0x75, 0x73, 0x4a, 0x75, 0x73, 0x74, 0x69, 0x66, 0x69, 0x65, + 0x64, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x64, 0x0a, 0x1c, 0x63, + 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x6a, 0x75, 0x73, 0x74, 0x69, 0x66, 0x69, 0x65, 0x64, + 0x5f, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0xc3, 0x3e, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, + 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x43, 0x68, 0x65, 0x63, 0x6b, + 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x52, 0x1a, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x4a, 0x75, + 0x73, 0x74, 0x69, 0x66, 0x69, 0x65, 0x64, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, + 0x74, 0x12, 0x55, 0x0a, 0x14, 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x5f, 0x63, + 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0xc4, 0x3e, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x21, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, + 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, + 0x69, 0x6e, 0x74, 0x52, 0x13, 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x43, 0x68, + 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x3f, 0x0a, 0x11, 0x69, 0x6e, 0x61, 0x63, + 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x5f, 0x73, 0x63, 0x6f, 0x72, 0x65, 0x73, 0x18, 0xa9, 0x46, + 0x20, 0x03, 0x28, 0x04, 0x42, 0x11, 0x92, 0xb5, 0x18, 0x0d, 0x31, 0x30, 0x39, 0x39, 0x35, 0x31, + 0x31, 0x36, 0x32, 0x37, 0x37, 0x37, 0x36, 0x52, 0x10, 0x69, 0x6e, 0x61, 0x63, 0x74, 0x69, 0x76, + 0x69, 0x74, 0x79, 0x53, 0x63, 0x6f, 0x72, 0x65, 0x73, 0x12, 0x5b, 0x0a, 0x16, 0x63, 0x75, 0x72, + 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x73, 0x79, 0x6e, 0x63, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, + 0x74, 0x65, 0x65, 0x18, 0xaa, 0x46, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x65, 0x74, 0x68, + 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, + 0x61, 0x31, 0x2e, 0x53, 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, + 0x52, 0x14, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x53, 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6d, + 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x12, 0x55, 0x0a, 0x13, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x73, + 0x79, 0x6e, 0x63, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x18, 0xab, 0x46, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, + 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x53, 0x79, 0x6e, + 0x63, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x52, 0x11, 0x6e, 0x65, 0x78, 0x74, + 0x53, 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x12, 0x77, 0x0a, + 0x1f, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, + 0x6e, 0x5f, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, + 0x18, 0x91, 0x4e, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2f, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, + 0x75, 0x6d, 0x2e, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x78, 0x65, + 0x63, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x48, 0x65, 0x61, + 0x64, 0x65, 0x72, 0x44, 0x65, 0x6e, 0x65, 0x62, 0x52, 0x1c, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, + 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, + 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x33, 0x0a, 0x15, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x77, + 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x61, 0x6c, 0x5f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, + 0xf9, 0x55, 0x20, 0x01, 0x28, 0x04, 0x52, 0x13, 0x6e, 0x65, 0x78, 0x74, 0x57, 0x69, 0x74, 0x68, + 0x64, 0x72, 0x61, 0x77, 0x61, 0x6c, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x96, 0x01, 0x0a, 0x1f, + 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x77, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x61, 0x6c, 0x5f, + 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x5f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, + 0xfa, 0x55, 0x20, 0x01, 0x28, 0x04, 0x42, 0x4e, 0x82, 0xb5, 0x18, 0x4a, 0x67, 0x69, 0x74, 0x68, + 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x4f, 0x66, 0x66, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x4c, + 0x61, 0x62, 0x73, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x37, 0x2f, 0x63, 0x6f, 0x6e, + 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x70, 0x72, 0x69, + 0x6d, 0x69, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, + 0x72, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x52, 0x1c, 0x6e, 0x65, 0x78, 0x74, 0x57, 0x69, 0x74, 0x68, + 0x64, 0x72, 0x61, 0x77, 0x61, 0x6c, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x49, + 0x6e, 0x64, 0x65, 0x78, 0x12, 0x6a, 0x0a, 0x14, 0x68, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x69, 0x63, + 0x61, 0x6c, 0x5f, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x69, 0x65, 0x73, 0x18, 0xfb, 0x55, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, + 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x48, 0x69, 0x73, 0x74, + 0x6f, 0x72, 0x69, 0x63, 0x61, 0x6c, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x42, 0x0c, 0x92, + 0xb5, 0x18, 0x08, 0x31, 0x36, 0x37, 0x37, 0x37, 0x32, 0x31, 0x36, 0x52, 0x13, 0x68, 0x69, 0x73, + 0x74, 0x6f, 0x72, 0x69, 0x63, 0x61, 0x6c, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x69, 0x65, 0x73, + 0x12, 0x40, 0x0a, 0x1c, 0x64, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x5f, 0x72, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x73, 0x5f, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x69, 0x6e, 0x64, 0x65, 0x78, + 0x18, 0xe1, 0x5d, 0x20, 0x01, 0x28, 0x04, 0x52, 0x19, 0x64, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x53, 0x74, 0x61, 0x72, 0x74, 0x49, 0x6e, 0x64, + 0x65, 0x78, 0x12, 0x82, 0x01, 0x0a, 0x1a, 0x64, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x5f, 0x62, + 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x5f, 0x74, 0x6f, 0x5f, 0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6d, + 0x65, 0x18, 0xe2, 0x5d, 0x20, 0x01, 0x28, 0x04, 0x42, 0x44, 0x82, 0xb5, 0x18, 0x40, 0x67, 0x69, + 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x4f, 0x66, 0x66, 0x63, 0x68, 0x61, 0x69, + 0x6e, 0x4c, 0x61, 0x62, 0x73, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x37, 0x2f, 0x63, + 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x70, + 0x72, 0x69, 0x6d, 0x69, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x47, 0x77, 0x65, 0x69, 0x52, 0x17, + 0x64, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x54, 0x6f, + 0x43, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x12, 0x7c, 0x0a, 0x17, 0x65, 0x78, 0x69, 0x74, 0x5f, + 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x5f, 0x74, 0x6f, 0x5f, 0x63, 0x6f, 0x6e, 0x73, 0x75, + 0x6d, 0x65, 0x18, 0xe3, 0x5d, 0x20, 0x01, 0x28, 0x04, 0x42, 0x44, 0x82, 0xb5, 0x18, 0x40, 0x67, + 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x4f, 0x66, 0x66, 0x63, 0x68, 0x61, + 0x69, 0x6e, 0x4c, 0x61, 0x62, 0x73, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x37, 0x2f, + 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, + 0x70, 0x72, 0x69, 0x6d, 0x69, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x47, 0x77, 0x65, 0x69, 0x52, + 0x14, 0x65, 0x78, 0x69, 0x74, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x54, 0x6f, 0x43, 0x6f, + 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x12, 0x76, 0x0a, 0x13, 0x65, 0x61, 0x72, 0x6c, 0x69, 0x65, 0x73, + 0x74, 0x5f, 0x65, 0x78, 0x69, 0x74, 0x5f, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x18, 0xe4, 0x5d, 0x20, + 0x01, 0x28, 0x04, 0x42, 0x45, 0x82, 0xb5, 0x18, 0x41, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, + 0x63, 0x6f, 0x6d, 0x2f, 0x4f, 0x66, 0x66, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x4c, 0x61, 0x62, 0x73, + 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x37, 0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, + 0x73, 0x75, 0x73, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x70, 0x72, 0x69, 0x6d, 0x69, 0x74, + 0x69, 0x76, 0x65, 0x73, 0x2e, 0x45, 0x70, 0x6f, 0x63, 0x68, 0x52, 0x11, 0x65, 0x61, 0x72, 0x6c, + 0x69, 0x65, 0x73, 0x74, 0x45, 0x78, 0x69, 0x74, 0x45, 0x70, 0x6f, 0x63, 0x68, 0x12, 0x8e, 0x01, + 0x0a, 0x20, 0x63, 0x6f, 0x6e, 0x73, 0x6f, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, + 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x5f, 0x74, 0x6f, 0x5f, 0x63, 0x6f, 0x6e, 0x73, 0x75, + 0x6d, 0x65, 0x18, 0xe5, 0x5d, 0x20, 0x01, 0x28, 0x04, 0x42, 0x44, 0x82, 0xb5, 0x18, 0x40, 0x67, + 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x4f, 0x66, 0x66, 0x63, 0x68, 0x61, + 0x69, 0x6e, 0x4c, 0x61, 0x62, 0x73, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x37, 0x2f, + 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, + 0x70, 0x72, 0x69, 0x6d, 0x69, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x47, 0x77, 0x65, 0x69, 0x52, + 0x1d, 0x63, 0x6f, 0x6e, 0x73, 0x6f, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x61, + 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x54, 0x6f, 0x43, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x12, 0x88, + 0x01, 0x0a, 0x1c, 0x65, 0x61, 0x72, 0x6c, 0x69, 0x65, 0x73, 0x74, 0x5f, 0x63, 0x6f, 0x6e, 0x73, + 0x6f, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x18, + 0xe6, 0x5d, 0x20, 0x01, 0x28, 0x04, 0x42, 0x45, 0x82, 0xb5, 0x18, 0x41, 0x67, 0x69, 0x74, 0x68, + 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x4f, 0x66, 0x66, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x4c, + 0x61, 0x62, 0x73, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x37, 0x2f, 0x63, 0x6f, 0x6e, + 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x70, 0x72, 0x69, + 0x6d, 0x69, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x45, 0x70, 0x6f, 0x63, 0x68, 0x52, 0x1a, 0x65, + 0x61, 0x72, 0x6c, 0x69, 0x65, 0x73, 0x74, 0x43, 0x6f, 0x6e, 0x73, 0x6f, 0x6c, 0x69, 0x64, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x70, 0x6f, 0x63, 0x68, 0x12, 0x60, 0x0a, 0x10, 0x70, 0x65, 0x6e, + 0x64, 0x69, 0x6e, 0x67, 0x5f, 0x64, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x73, 0x18, 0xe7, 0x5d, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, + 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x50, 0x65, 0x6e, + 0x64, 0x69, 0x6e, 0x67, 0x44, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x42, 0x0d, 0x92, 0xb5, 0x18, + 0x09, 0x31, 0x33, 0x34, 0x32, 0x31, 0x37, 0x37, 0x32, 0x38, 0x52, 0x0f, 0x70, 0x65, 0x6e, 0x64, + 0x69, 0x6e, 0x67, 0x44, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x73, 0x12, 0x78, 0x0a, 0x1b, 0x70, + 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x5f, 0x70, 0x61, 0x72, 0x74, 0x69, 0x61, 0x6c, 0x5f, 0x77, + 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x61, 0x6c, 0x73, 0x18, 0xe8, 0x5d, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x2f, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, + 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x50, 0x65, 0x6e, 0x64, 0x69, 0x6e, + 0x67, 0x50, 0x61, 0x72, 0x74, 0x69, 0x61, 0x6c, 0x57, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, + 0x61, 0x6c, 0x42, 0x06, 0x92, 0xb5, 0x18, 0x02, 0x36, 0x34, 0x52, 0x19, 0x70, 0x65, 0x6e, 0x64, + 0x69, 0x6e, 0x67, 0x50, 0x61, 0x72, 0x74, 0x69, 0x61, 0x6c, 0x57, 0x69, 0x74, 0x68, 0x64, 0x72, + 0x61, 0x77, 0x61, 0x6c, 0x73, 0x12, 0x6b, 0x0a, 0x16, 0x70, 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, + 0x5f, 0x63, 0x6f, 0x6e, 0x73, 0x6f, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, + 0xe9, 0x5d, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, + 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x50, + 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6e, 0x73, 0x6f, 0x6c, 0x69, 0x64, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x42, 0x06, 0x92, 0xb5, 0x18, 0x02, 0x36, 0x34, 0x52, 0x15, 0x70, 0x65, 0x6e, + 0x64, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6e, 0x73, 0x6f, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x73, 0x22, 0x9f, 0x1a, 0x0a, 0x0f, 0x42, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x53, 0x74, 0x61, + 0x74, 0x65, 0x46, 0x75, 0x6c, 0x75, 0x12, 0x22, 0x0a, 0x0c, 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, + 0x73, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0xe9, 0x07, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, 0x67, + 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x3f, 0x0a, 0x17, 0x67, 0x65, + 0x6e, 0x65, 0x73, 0x69, 0x73, 0x5f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, + 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0xea, 0x07, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, + 0x18, 0x02, 0x33, 0x32, 0x52, 0x15, 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x56, 0x61, 0x6c, + 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x52, 0x6f, 0x6f, 0x74, 0x12, 0x59, 0x0a, 0x04, 0x73, + 0x6c, 0x6f, 0x74, 0x18, 0xeb, 0x07, 0x20, 0x01, 0x28, 0x04, 0x42, 0x44, 0x82, 0xb5, 0x18, 0x40, + 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x4f, 0x66, 0x66, 0x63, 0x68, + 0x61, 0x69, 0x6e, 0x4c, 0x61, 0x62, 0x73, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x37, + 0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x73, + 0x2f, 0x70, 0x72, 0x69, 0x6d, 0x69, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x53, 0x6c, 0x6f, 0x74, + 0x52, 0x04, 0x73, 0x6c, 0x6f, 0x74, 0x12, 0x30, 0x0a, 0x04, 0x66, 0x6f, 0x72, 0x6b, 0x18, 0xec, + 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, + 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x46, 0x6f, + 0x72, 0x6b, 0x52, 0x04, 0x66, 0x6f, 0x72, 0x6b, 0x12, 0x59, 0x0a, 0x13, 0x6c, 0x61, 0x74, 0x65, + 0x73, 0x74, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, + 0xd1, 0x0f, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, + 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x42, + 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, + 0x52, 0x11, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x65, 0x61, + 0x64, 0x65, 0x72, 0x12, 0x2b, 0x0a, 0x0b, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x72, 0x6f, 0x6f, + 0x74, 0x73, 0x18, 0xd2, 0x0f, 0x20, 0x03, 0x28, 0x0c, 0x42, 0x09, 0x8a, 0xb5, 0x18, 0x05, 0x36, + 0x34, 0x2c, 0x33, 0x32, 0x52, 0x0a, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x6f, 0x6f, 0x74, 0x73, + 0x12, 0x2b, 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x65, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x73, 0x18, + 0xd3, 0x0f, 0x20, 0x03, 0x28, 0x0c, 0x42, 0x09, 0x8a, 0xb5, 0x18, 0x05, 0x36, 0x34, 0x2c, 0x33, + 0x32, 0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x65, 0x52, 0x6f, 0x6f, 0x74, 0x73, 0x12, 0x40, 0x0a, + 0x10, 0x68, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x69, 0x63, 0x61, 0x6c, 0x5f, 0x72, 0x6f, 0x6f, 0x74, + 0x73, 0x18, 0xd4, 0x0f, 0x20, 0x03, 0x28, 0x0c, 0x42, 0x14, 0x8a, 0xb5, 0x18, 0x04, 0x3f, 0x2c, + 0x33, 0x32, 0x92, 0xb5, 0x18, 0x08, 0x31, 0x36, 0x37, 0x37, 0x37, 0x32, 0x31, 0x36, 0x52, 0x0f, + 0x68, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x69, 0x63, 0x61, 0x6c, 0x52, 0x6f, 0x6f, 0x74, 0x73, 0x12, + 0x3d, 0x0a, 0x09, 0x65, 0x74, 0x68, 0x31, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x18, 0xb9, 0x17, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, + 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x45, 0x74, 0x68, 0x31, + 0x44, 0x61, 0x74, 0x61, 0x52, 0x08, 0x65, 0x74, 0x68, 0x31, 0x44, 0x61, 0x74, 0x61, 0x12, 0x50, + 0x0a, 0x0f, 0x65, 0x74, 0x68, 0x31, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x5f, 0x76, 0x6f, 0x74, 0x65, + 0x73, 0x18, 0xba, 0x17, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, + 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, + 0x2e, 0x45, 0x74, 0x68, 0x31, 0x44, 0x61, 0x74, 0x61, 0x42, 0x06, 0x92, 0xb5, 0x18, 0x02, 0x33, + 0x32, 0x52, 0x0d, 0x65, 0x74, 0x68, 0x31, 0x44, 0x61, 0x74, 0x61, 0x56, 0x6f, 0x74, 0x65, 0x73, + 0x12, 0x2d, 0x0a, 0x12, 0x65, 0x74, 0x68, 0x31, 0x5f, 0x64, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, + 0x5f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0xbb, 0x17, 0x20, 0x01, 0x28, 0x04, 0x52, 0x10, 0x65, + 0x74, 0x68, 0x31, 0x44, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x12, + 0x54, 0x0a, 0x0a, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x18, 0xa1, 0x1f, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, + 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x56, 0x61, 0x6c, + 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x42, 0x11, 0x92, 0xb5, 0x18, 0x0d, 0x31, 0x30, 0x39, 0x39, + 0x35, 0x31, 0x31, 0x36, 0x32, 0x37, 0x37, 0x37, 0x36, 0x52, 0x0a, 0x76, 0x61, 0x6c, 0x69, 0x64, + 0x61, 0x74, 0x6f, 0x72, 0x73, 0x12, 0x2e, 0x0a, 0x08, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, + 0x73, 0x18, 0xa2, 0x1f, 0x20, 0x03, 0x28, 0x04, 0x42, 0x11, 0x92, 0xb5, 0x18, 0x0d, 0x31, 0x30, + 0x39, 0x39, 0x35, 0x31, 0x31, 0x36, 0x32, 0x37, 0x37, 0x37, 0x36, 0x52, 0x08, 0x62, 0x61, 0x6c, + 0x61, 0x6e, 0x63, 0x65, 0x73, 0x12, 0x2d, 0x0a, 0x0c, 0x72, 0x61, 0x6e, 0x64, 0x61, 0x6f, 0x5f, + 0x6d, 0x69, 0x78, 0x65, 0x73, 0x18, 0x89, 0x27, 0x20, 0x03, 0x28, 0x0c, 0x42, 0x09, 0x8a, 0xb5, + 0x18, 0x05, 0x36, 0x34, 0x2c, 0x33, 0x32, 0x52, 0x0b, 0x72, 0x61, 0x6e, 0x64, 0x61, 0x6f, 0x4d, + 0x69, 0x78, 0x65, 0x73, 0x12, 0x25, 0x0a, 0x09, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x69, 0x6e, 0x67, + 0x73, 0x18, 0xf1, 0x2e, 0x20, 0x03, 0x28, 0x04, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x36, 0x34, + 0x52, 0x09, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x54, 0x0a, 0x1c, 0x70, + 0x72, 0x65, 0x76, 0x69, 0x6f, 0x75, 0x73, 0x5f, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x5f, 0x70, 0x61, + 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0xd9, 0x36, 0x20, 0x01, + 0x28, 0x0c, 0x42, 0x11, 0x92, 0xb5, 0x18, 0x0d, 0x31, 0x30, 0x39, 0x39, 0x35, 0x31, 0x31, 0x36, + 0x32, 0x37, 0x37, 0x37, 0x36, 0x52, 0x1a, 0x70, 0x72, 0x65, 0x76, 0x69, 0x6f, 0x75, 0x73, 0x45, + 0x70, 0x6f, 0x63, 0x68, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x12, 0x52, 0x0a, 0x1b, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x65, 0x70, 0x6f, + 0x63, 0x68, 0x5f, 0x70, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x18, 0xda, 0x36, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x11, 0x92, 0xb5, 0x18, 0x0d, 0x31, 0x30, 0x39, + 0x39, 0x35, 0x31, 0x31, 0x36, 0x32, 0x37, 0x37, 0x37, 0x36, 0x52, 0x19, 0x63, 0x75, 0x72, 0x72, + 0x65, 0x6e, 0x74, 0x45, 0x70, 0x6f, 0x63, 0x68, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x67, 0x0a, 0x12, 0x6a, 0x75, 0x73, 0x74, 0x69, 0x66, 0x69, + 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x62, 0x69, 0x74, 0x73, 0x18, 0xc1, 0x3e, 0x20, 0x01, + 0x28, 0x0c, 0x42, 0x37, 0x82, 0xb5, 0x18, 0x2e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, + 0x6f, 0x6d, 0x2f, 0x4f, 0x66, 0x66, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x4c, 0x61, 0x62, 0x73, 0x2f, + 0x67, 0x6f, 0x2d, 0x62, 0x69, 0x74, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x2e, 0x42, 0x69, 0x74, 0x76, + 0x65, 0x63, 0x74, 0x6f, 0x72, 0x34, 0x8a, 0xb5, 0x18, 0x01, 0x31, 0x52, 0x11, 0x6a, 0x75, 0x73, + 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x69, 0x74, 0x73, 0x12, 0x66, + 0x0a, 0x1d, 0x70, 0x72, 0x65, 0x76, 0x69, 0x6f, 0x75, 0x73, 0x5f, 0x6a, 0x75, 0x73, 0x74, 0x69, + 0x66, 0x69, 0x65, 0x64, 0x5f, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, + 0xc2, 0x3e, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, + 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x43, + 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x52, 0x1b, 0x70, 0x72, 0x65, 0x76, 0x69, + 0x6f, 0x75, 0x73, 0x4a, 0x75, 0x73, 0x74, 0x69, 0x66, 0x69, 0x65, 0x64, 0x43, 0x68, 0x65, 0x63, + 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x64, 0x0a, 0x1c, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, + 0x74, 0x5f, 0x6a, 0x75, 0x73, 0x74, 0x69, 0x66, 0x69, 0x65, 0x64, 0x5f, 0x63, 0x68, 0x65, 0x63, + 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0xc3, 0x3e, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, + 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, + 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, + 0x52, 0x1a, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x4a, 0x75, 0x73, 0x74, 0x69, 0x66, 0x69, + 0x65, 0x64, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x55, 0x0a, 0x14, + 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x5f, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x70, + 0x6f, 0x69, 0x6e, 0x74, 0x18, 0xc4, 0x3e, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x65, 0x74, + 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, + 0x68, 0x61, 0x31, 0x2e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x52, 0x13, + 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, + 0x69, 0x6e, 0x74, 0x12, 0x3f, 0x0a, 0x11, 0x69, 0x6e, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, + 0x79, 0x5f, 0x73, 0x63, 0x6f, 0x72, 0x65, 0x73, 0x18, 0xa9, 0x46, 0x20, 0x03, 0x28, 0x04, 0x42, + 0x11, 0x92, 0xb5, 0x18, 0x0d, 0x31, 0x30, 0x39, 0x39, 0x35, 0x31, 0x31, 0x36, 0x32, 0x37, 0x37, + 0x37, 0x36, 0x52, 0x10, 0x69, 0x6e, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x53, 0x63, + 0x6f, 0x72, 0x65, 0x73, 0x12, 0x5b, 0x0a, 0x16, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x5f, + 0x73, 0x79, 0x6e, 0x63, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x18, 0xaa, + 0x46, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, + 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x53, 0x79, + 0x6e, 0x63, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x52, 0x14, 0x63, 0x75, 0x72, + 0x72, 0x65, 0x6e, 0x74, 0x53, 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, + 0x65, 0x12, 0x55, 0x0a, 0x13, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x73, 0x79, 0x6e, 0x63, 0x5f, 0x63, + 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x18, 0xab, 0x46, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x24, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, + 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x53, 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6d, 0x6d, + 0x69, 0x74, 0x74, 0x65, 0x65, 0x52, 0x11, 0x6e, 0x65, 0x78, 0x74, 0x53, 0x79, 0x6e, 0x63, 0x43, + 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x12, 0x77, 0x0a, 0x1f, 0x6c, 0x61, 0x74, 0x65, + 0x73, 0x74, 0x5f, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x70, 0x61, 0x79, + 0x6c, 0x6f, 0x61, 0x64, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x91, 0x4e, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x2f, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x6e, + 0x67, 0x69, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, + 0x6e, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x44, 0x65, + 0x6e, 0x65, 0x62, 0x52, 0x1c, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x45, 0x78, 0x65, 0x63, 0x75, + 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x48, 0x65, 0x61, 0x64, 0x65, + 0x72, 0x12, 0x33, 0x0a, 0x15, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x77, 0x69, 0x74, 0x68, 0x64, 0x72, + 0x61, 0x77, 0x61, 0x6c, 0x5f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0xf9, 0x55, 0x20, 0x01, 0x28, + 0x04, 0x52, 0x13, 0x6e, 0x65, 0x78, 0x74, 0x57, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x61, + 0x6c, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x96, 0x01, 0x0a, 0x1f, 0x6e, 0x65, 0x78, 0x74, 0x5f, + 0x77, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x61, 0x6c, 0x5f, 0x76, 0x61, 0x6c, 0x69, 0x64, + 0x61, 0x74, 0x6f, 0x72, 0x5f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0xfa, 0x55, 0x20, 0x01, 0x28, + 0x04, 0x42, 0x4e, 0x82, 0xb5, 0x18, 0x4a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, + 0x6d, 0x2f, 0x4f, 0x66, 0x66, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x4c, 0x61, 0x62, 0x73, 0x2f, 0x70, + 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x37, 0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, + 0x73, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x70, 0x72, 0x69, 0x6d, 0x69, 0x74, 0x69, 0x76, + 0x65, 0x73, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x49, 0x6e, 0x64, 0x65, + 0x78, 0x52, 0x1c, 0x6e, 0x65, 0x78, 0x74, 0x57, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x61, + 0x6c, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x12, + 0x6a, 0x0a, 0x14, 0x68, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x69, 0x63, 0x61, 0x6c, 0x5f, 0x73, 0x75, + 0x6d, 0x6d, 0x61, 0x72, 0x69, 0x65, 0x73, 0x18, 0xfb, 0x55, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x28, + 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x69, 0x63, 0x61, + 0x6c, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x42, 0x0c, 0x92, 0xb5, 0x18, 0x08, 0x31, 0x36, + 0x37, 0x37, 0x37, 0x32, 0x31, 0x36, 0x52, 0x13, 0x68, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x69, 0x63, + 0x61, 0x6c, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x69, 0x65, 0x73, 0x12, 0x40, 0x0a, 0x1c, 0x64, + 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x5f, + 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0xe1, 0x5d, 0x20, 0x01, + 0x28, 0x04, 0x52, 0x19, 0x64, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x73, 0x53, 0x74, 0x61, 0x72, 0x74, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x82, 0x01, + 0x0a, 0x1a, 0x64, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x5f, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, + 0x65, 0x5f, 0x74, 0x6f, 0x5f, 0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x18, 0xe2, 0x5d, 0x20, + 0x01, 0x28, 0x04, 0x42, 0x44, 0x82, 0xb5, 0x18, 0x40, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, + 0x63, 0x6f, 0x6d, 0x2f, 0x4f, 0x66, 0x66, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x4c, 0x61, 0x62, 0x73, + 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x37, 0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, + 0x73, 0x75, 0x73, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x70, 0x72, 0x69, 0x6d, 0x69, 0x74, + 0x69, 0x76, 0x65, 0x73, 0x2e, 0x47, 0x77, 0x65, 0x69, 0x52, 0x17, 0x64, 0x65, 0x70, 0x6f, 0x73, + 0x69, 0x74, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x54, 0x6f, 0x43, 0x6f, 0x6e, 0x73, 0x75, + 0x6d, 0x65, 0x12, 0x7c, 0x0a, 0x17, 0x65, 0x78, 0x69, 0x74, 0x5f, 0x62, 0x61, 0x6c, 0x61, 0x6e, + 0x63, 0x65, 0x5f, 0x74, 0x6f, 0x5f, 0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x18, 0xe3, 0x5d, + 0x20, 0x01, 0x28, 0x04, 0x42, 0x44, 0x82, 0xb5, 0x18, 0x40, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, + 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x4f, 0x66, 0x66, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x4c, 0x61, 0x62, + 0x73, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x37, 0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x65, + 0x6e, 0x73, 0x75, 0x73, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x70, 0x72, 0x69, 0x6d, 0x69, + 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x47, 0x77, 0x65, 0x69, 0x52, 0x14, 0x65, 0x78, 0x69, 0x74, + 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x54, 0x6f, 0x43, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, + 0x12, 0x76, 0x0a, 0x13, 0x65, 0x61, 0x72, 0x6c, 0x69, 0x65, 0x73, 0x74, 0x5f, 0x65, 0x78, 0x69, + 0x74, 0x5f, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x18, 0xe4, 0x5d, 0x20, 0x01, 0x28, 0x04, 0x42, 0x45, + 0x82, 0xb5, 0x18, 0x41, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x4f, + 0x66, 0x66, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x4c, 0x61, 0x62, 0x73, 0x2f, 0x70, 0x72, 0x79, 0x73, + 0x6d, 0x2f, 0x76, 0x37, 0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2d, 0x74, + 0x79, 0x70, 0x65, 0x73, 0x2f, 0x70, 0x72, 0x69, 0x6d, 0x69, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, + 0x45, 0x70, 0x6f, 0x63, 0x68, 0x52, 0x11, 0x65, 0x61, 0x72, 0x6c, 0x69, 0x65, 0x73, 0x74, 0x45, + 0x78, 0x69, 0x74, 0x45, 0x70, 0x6f, 0x63, 0x68, 0x12, 0x8e, 0x01, 0x0a, 0x20, 0x63, 0x6f, 0x6e, + 0x73, 0x6f, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x62, 0x61, 0x6c, 0x61, 0x6e, + 0x63, 0x65, 0x5f, 0x74, 0x6f, 0x5f, 0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x18, 0xe5, 0x5d, + 0x20, 0x01, 0x28, 0x04, 0x42, 0x44, 0x82, 0xb5, 0x18, 0x40, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, + 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x4f, 0x66, 0x66, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x4c, 0x61, 0x62, + 0x73, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x37, 0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x65, + 0x6e, 0x73, 0x75, 0x73, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x70, 0x72, 0x69, 0x6d, 0x69, + 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x47, 0x77, 0x65, 0x69, 0x52, 0x1d, 0x63, 0x6f, 0x6e, 0x73, + 0x6f, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, + 0x54, 0x6f, 0x43, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x12, 0x88, 0x01, 0x0a, 0x1c, 0x65, 0x61, + 0x72, 0x6c, 0x69, 0x65, 0x73, 0x74, 0x5f, 0x63, 0x6f, 0x6e, 0x73, 0x6f, 0x6c, 0x69, 0x64, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x18, 0xe6, 0x5d, 0x20, 0x01, 0x28, + 0x04, 0x42, 0x45, 0x82, 0xb5, 0x18, 0x41, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, + 0x6d, 0x2f, 0x4f, 0x66, 0x66, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x4c, 0x61, 0x62, 0x73, 0x2f, 0x70, + 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x37, 0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, + 0x73, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x70, 0x72, 0x69, 0x6d, 0x69, 0x74, 0x69, 0x76, + 0x65, 0x73, 0x2e, 0x45, 0x70, 0x6f, 0x63, 0x68, 0x52, 0x1a, 0x65, 0x61, 0x72, 0x6c, 0x69, 0x65, + 0x73, 0x74, 0x43, 0x6f, 0x6e, 0x73, 0x6f, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x45, + 0x70, 0x6f, 0x63, 0x68, 0x12, 0x60, 0x0a, 0x10, 0x70, 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x5f, + 0x64, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x73, 0x18, 0xe7, 0x5d, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x25, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, + 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x50, 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x44, + 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x42, 0x0d, 0x92, 0xb5, 0x18, 0x09, 0x31, 0x33, 0x34, 0x32, + 0x31, 0x37, 0x37, 0x32, 0x38, 0x52, 0x0f, 0x70, 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x44, 0x65, + 0x70, 0x6f, 0x73, 0x69, 0x74, 0x73, 0x12, 0x78, 0x0a, 0x1b, 0x70, 0x65, 0x6e, 0x64, 0x69, 0x6e, + 0x67, 0x5f, 0x70, 0x61, 0x72, 0x74, 0x69, 0x61, 0x6c, 0x5f, 0x77, 0x69, 0x74, 0x68, 0x64, 0x72, + 0x61, 0x77, 0x61, 0x6c, 0x73, 0x18, 0xe8, 0x5d, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2f, 0x2e, 0x65, + 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, + 0x70, 0x68, 0x61, 0x31, 0x2e, 0x50, 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x50, 0x61, 0x72, 0x74, + 0x69, 0x61, 0x6c, 0x57, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x61, 0x6c, 0x42, 0x06, 0x92, + 0xb5, 0x18, 0x02, 0x36, 0x34, 0x52, 0x19, 0x70, 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x50, 0x61, + 0x72, 0x74, 0x69, 0x61, 0x6c, 0x57, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x61, 0x6c, 0x73, + 0x12, 0x6b, 0x0a, 0x16, 0x70, 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x5f, 0x63, 0x6f, 0x6e, 0x73, + 0x6f, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xe9, 0x5d, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x2b, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, + 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x50, 0x65, 0x6e, 0x64, 0x69, 0x6e, + 0x67, 0x43, 0x6f, 0x6e, 0x73, 0x6f, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x06, + 0x92, 0xb5, 0x18, 0x02, 0x36, 0x34, 0x52, 0x15, 0x70, 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x43, + 0x6f, 0x6e, 0x73, 0x6f, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x84, 0x01, + 0x0a, 0x12, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x65, 0x72, 0x5f, 0x6c, 0x6f, 0x6f, 0x6b, 0x61, + 0x68, 0x65, 0x61, 0x64, 0x18, 0xc9, 0x65, 0x20, 0x03, 0x28, 0x04, 0x42, 0x54, 0x82, 0xb5, 0x18, + 0x4a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x4f, 0x66, 0x66, 0x63, + 0x68, 0x61, 0x69, 0x6e, 0x4c, 0x61, 0x62, 0x73, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, + 0x37, 0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2d, 0x74, 0x79, 0x70, 0x65, + 0x73, 0x2f, 0x70, 0x72, 0x69, 0x6d, 0x69, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x56, 0x61, 0x6c, + 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x8a, 0xb5, 0x18, 0x02, 0x31, + 0x36, 0x52, 0x11, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x65, 0x72, 0x4c, 0x6f, 0x6f, 0x6b, 0x61, + 0x68, 0x65, 0x61, 0x64, 0x42, 0x9a, 0x01, 0x0a, 0x19, 0x6f, 0x72, 0x67, 0x2e, 0x65, 0x74, 0x68, + 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, + 0x61, 0x31, 0x42, 0x10, 0x42, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x50, + 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x39, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, + 0x6f, 0x6d, 0x2f, 0x4f, 0x66, 0x66, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x4c, 0x61, 0x62, 0x73, 0x2f, + 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x37, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x70, + 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x3b, 0x65, 0x74, + 0x68, 0xaa, 0x02, 0x15, 0x45, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x45, 0x74, 0x68, + 0x2e, 0x56, 0x31, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xca, 0x02, 0x15, 0x45, 0x74, 0x68, 0x65, + 0x72, 0x65, 0x75, 0x6d, 0x5c, 0x45, 0x74, 0x68, 0x5c, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, + 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_proto_prysm_v1alpha1_beacon_state_proto_rawDescOnce sync.Once + file_proto_prysm_v1alpha1_beacon_state_proto_rawDescData = file_proto_prysm_v1alpha1_beacon_state_proto_rawDesc +) + +func file_proto_prysm_v1alpha1_beacon_state_proto_rawDescGZIP() []byte { + file_proto_prysm_v1alpha1_beacon_state_proto_rawDescOnce.Do(func() { + file_proto_prysm_v1alpha1_beacon_state_proto_rawDescData = protoimpl.X.CompressGZIP(file_proto_prysm_v1alpha1_beacon_state_proto_rawDescData) + }) + return file_proto_prysm_v1alpha1_beacon_state_proto_rawDescData +} + +var file_proto_prysm_v1alpha1_beacon_state_proto_msgTypes = make([]protoimpl.MessageInfo, 16) +var file_proto_prysm_v1alpha1_beacon_state_proto_goTypes = []any{ + (*BeaconState)(nil), // 0: ethereum.eth.v1alpha1.BeaconState + (*PendingAttestation)(nil), // 1: ethereum.eth.v1alpha1.PendingAttestation + (*HistoricalBatch)(nil), // 2: ethereum.eth.v1alpha1.HistoricalBatch + (*StateSummary)(nil), // 3: ethereum.eth.v1alpha1.StateSummary + (*SigningData)(nil), // 4: ethereum.eth.v1alpha1.SigningData + (*ForkData)(nil), // 5: ethereum.eth.v1alpha1.ForkData + (*CheckPtInfo)(nil), // 6: ethereum.eth.v1alpha1.CheckPtInfo + (*DepositMessage)(nil), // 7: ethereum.eth.v1alpha1.DepositMessage + (*PowBlock)(nil), // 8: ethereum.eth.v1alpha1.PowBlock + (*BeaconStateAltair)(nil), // 9: ethereum.eth.v1alpha1.BeaconStateAltair + (*SyncAggregatorSelectionData)(nil), // 10: ethereum.eth.v1alpha1.SyncAggregatorSelectionData + (*BeaconStateBellatrix)(nil), // 11: ethereum.eth.v1alpha1.BeaconStateBellatrix + (*BeaconStateCapella)(nil), // 12: ethereum.eth.v1alpha1.BeaconStateCapella + (*BeaconStateDeneb)(nil), // 13: ethereum.eth.v1alpha1.BeaconStateDeneb + (*BeaconStateElectra)(nil), // 14: ethereum.eth.v1alpha1.BeaconStateElectra + (*BeaconStateFulu)(nil), // 15: ethereum.eth.v1alpha1.BeaconStateFulu + (*Fork)(nil), // 16: ethereum.eth.v1alpha1.Fork + (*BeaconBlockHeader)(nil), // 17: ethereum.eth.v1alpha1.BeaconBlockHeader + (*Eth1Data)(nil), // 18: ethereum.eth.v1alpha1.Eth1Data + (*Validator)(nil), // 19: ethereum.eth.v1alpha1.Validator + (*Checkpoint)(nil), // 20: ethereum.eth.v1alpha1.Checkpoint + (*AttestationData)(nil), // 21: ethereum.eth.v1alpha1.AttestationData + (*SyncCommittee)(nil), // 22: ethereum.eth.v1alpha1.SyncCommittee + (*v1.ExecutionPayloadHeader)(nil), // 23: ethereum.engine.v1.ExecutionPayloadHeader + (*v1.ExecutionPayloadHeaderCapella)(nil), // 24: ethereum.engine.v1.ExecutionPayloadHeaderCapella + (*HistoricalSummary)(nil), // 25: ethereum.eth.v1alpha1.HistoricalSummary + (*v1.ExecutionPayloadHeaderDeneb)(nil), // 26: ethereum.engine.v1.ExecutionPayloadHeaderDeneb + (*PendingDeposit)(nil), // 27: ethereum.eth.v1alpha1.PendingDeposit + (*PendingPartialWithdrawal)(nil), // 28: ethereum.eth.v1alpha1.PendingPartialWithdrawal + (*PendingConsolidation)(nil), // 29: ethereum.eth.v1alpha1.PendingConsolidation +} +var file_proto_prysm_v1alpha1_beacon_state_proto_depIdxs = []int32{ + 16, // 0: ethereum.eth.v1alpha1.BeaconState.fork:type_name -> ethereum.eth.v1alpha1.Fork + 17, // 1: ethereum.eth.v1alpha1.BeaconState.latest_block_header:type_name -> ethereum.eth.v1alpha1.BeaconBlockHeader + 18, // 2: ethereum.eth.v1alpha1.BeaconState.eth1_data:type_name -> ethereum.eth.v1alpha1.Eth1Data + 18, // 3: ethereum.eth.v1alpha1.BeaconState.eth1_data_votes:type_name -> ethereum.eth.v1alpha1.Eth1Data + 19, // 4: ethereum.eth.v1alpha1.BeaconState.validators:type_name -> ethereum.eth.v1alpha1.Validator + 1, // 5: ethereum.eth.v1alpha1.BeaconState.previous_epoch_attestations:type_name -> ethereum.eth.v1alpha1.PendingAttestation + 1, // 6: ethereum.eth.v1alpha1.BeaconState.current_epoch_attestations:type_name -> ethereum.eth.v1alpha1.PendingAttestation + 20, // 7: ethereum.eth.v1alpha1.BeaconState.previous_justified_checkpoint:type_name -> ethereum.eth.v1alpha1.Checkpoint + 20, // 8: ethereum.eth.v1alpha1.BeaconState.current_justified_checkpoint:type_name -> ethereum.eth.v1alpha1.Checkpoint + 20, // 9: ethereum.eth.v1alpha1.BeaconState.finalized_checkpoint:type_name -> ethereum.eth.v1alpha1.Checkpoint + 21, // 10: ethereum.eth.v1alpha1.PendingAttestation.data:type_name -> ethereum.eth.v1alpha1.AttestationData + 16, // 11: ethereum.eth.v1alpha1.CheckPtInfo.fork:type_name -> ethereum.eth.v1alpha1.Fork + 16, // 12: ethereum.eth.v1alpha1.BeaconStateAltair.fork:type_name -> ethereum.eth.v1alpha1.Fork + 17, // 13: ethereum.eth.v1alpha1.BeaconStateAltair.latest_block_header:type_name -> ethereum.eth.v1alpha1.BeaconBlockHeader + 18, // 14: ethereum.eth.v1alpha1.BeaconStateAltair.eth1_data:type_name -> ethereum.eth.v1alpha1.Eth1Data + 18, // 15: ethereum.eth.v1alpha1.BeaconStateAltair.eth1_data_votes:type_name -> ethereum.eth.v1alpha1.Eth1Data + 19, // 16: ethereum.eth.v1alpha1.BeaconStateAltair.validators:type_name -> ethereum.eth.v1alpha1.Validator + 20, // 17: ethereum.eth.v1alpha1.BeaconStateAltair.previous_justified_checkpoint:type_name -> ethereum.eth.v1alpha1.Checkpoint + 20, // 18: ethereum.eth.v1alpha1.BeaconStateAltair.current_justified_checkpoint:type_name -> ethereum.eth.v1alpha1.Checkpoint + 20, // 19: ethereum.eth.v1alpha1.BeaconStateAltair.finalized_checkpoint:type_name -> ethereum.eth.v1alpha1.Checkpoint + 22, // 20: ethereum.eth.v1alpha1.BeaconStateAltair.current_sync_committee:type_name -> ethereum.eth.v1alpha1.SyncCommittee + 22, // 21: ethereum.eth.v1alpha1.BeaconStateAltair.next_sync_committee:type_name -> ethereum.eth.v1alpha1.SyncCommittee + 16, // 22: ethereum.eth.v1alpha1.BeaconStateBellatrix.fork:type_name -> ethereum.eth.v1alpha1.Fork + 17, // 23: ethereum.eth.v1alpha1.BeaconStateBellatrix.latest_block_header:type_name -> ethereum.eth.v1alpha1.BeaconBlockHeader + 18, // 24: ethereum.eth.v1alpha1.BeaconStateBellatrix.eth1_data:type_name -> ethereum.eth.v1alpha1.Eth1Data + 18, // 25: ethereum.eth.v1alpha1.BeaconStateBellatrix.eth1_data_votes:type_name -> ethereum.eth.v1alpha1.Eth1Data + 19, // 26: ethereum.eth.v1alpha1.BeaconStateBellatrix.validators:type_name -> ethereum.eth.v1alpha1.Validator + 20, // 27: ethereum.eth.v1alpha1.BeaconStateBellatrix.previous_justified_checkpoint:type_name -> ethereum.eth.v1alpha1.Checkpoint + 20, // 28: ethereum.eth.v1alpha1.BeaconStateBellatrix.current_justified_checkpoint:type_name -> ethereum.eth.v1alpha1.Checkpoint + 20, // 29: ethereum.eth.v1alpha1.BeaconStateBellatrix.finalized_checkpoint:type_name -> ethereum.eth.v1alpha1.Checkpoint + 22, // 30: ethereum.eth.v1alpha1.BeaconStateBellatrix.current_sync_committee:type_name -> ethereum.eth.v1alpha1.SyncCommittee + 22, // 31: ethereum.eth.v1alpha1.BeaconStateBellatrix.next_sync_committee:type_name -> ethereum.eth.v1alpha1.SyncCommittee + 23, // 32: ethereum.eth.v1alpha1.BeaconStateBellatrix.latest_execution_payload_header:type_name -> ethereum.engine.v1.ExecutionPayloadHeader + 16, // 33: ethereum.eth.v1alpha1.BeaconStateCapella.fork:type_name -> ethereum.eth.v1alpha1.Fork + 17, // 34: ethereum.eth.v1alpha1.BeaconStateCapella.latest_block_header:type_name -> ethereum.eth.v1alpha1.BeaconBlockHeader + 18, // 35: ethereum.eth.v1alpha1.BeaconStateCapella.eth1_data:type_name -> ethereum.eth.v1alpha1.Eth1Data + 18, // 36: ethereum.eth.v1alpha1.BeaconStateCapella.eth1_data_votes:type_name -> ethereum.eth.v1alpha1.Eth1Data + 19, // 37: ethereum.eth.v1alpha1.BeaconStateCapella.validators:type_name -> ethereum.eth.v1alpha1.Validator + 20, // 38: ethereum.eth.v1alpha1.BeaconStateCapella.previous_justified_checkpoint:type_name -> ethereum.eth.v1alpha1.Checkpoint + 20, // 39: ethereum.eth.v1alpha1.BeaconStateCapella.current_justified_checkpoint:type_name -> ethereum.eth.v1alpha1.Checkpoint + 20, // 40: ethereum.eth.v1alpha1.BeaconStateCapella.finalized_checkpoint:type_name -> ethereum.eth.v1alpha1.Checkpoint + 22, // 41: ethereum.eth.v1alpha1.BeaconStateCapella.current_sync_committee:type_name -> ethereum.eth.v1alpha1.SyncCommittee + 22, // 42: ethereum.eth.v1alpha1.BeaconStateCapella.next_sync_committee:type_name -> ethereum.eth.v1alpha1.SyncCommittee + 24, // 43: ethereum.eth.v1alpha1.BeaconStateCapella.latest_execution_payload_header:type_name -> ethereum.engine.v1.ExecutionPayloadHeaderCapella + 25, // 44: ethereum.eth.v1alpha1.BeaconStateCapella.historical_summaries:type_name -> ethereum.eth.v1alpha1.HistoricalSummary + 16, // 45: ethereum.eth.v1alpha1.BeaconStateDeneb.fork:type_name -> ethereum.eth.v1alpha1.Fork + 17, // 46: ethereum.eth.v1alpha1.BeaconStateDeneb.latest_block_header:type_name -> ethereum.eth.v1alpha1.BeaconBlockHeader + 18, // 47: ethereum.eth.v1alpha1.BeaconStateDeneb.eth1_data:type_name -> ethereum.eth.v1alpha1.Eth1Data + 18, // 48: ethereum.eth.v1alpha1.BeaconStateDeneb.eth1_data_votes:type_name -> ethereum.eth.v1alpha1.Eth1Data + 19, // 49: ethereum.eth.v1alpha1.BeaconStateDeneb.validators:type_name -> ethereum.eth.v1alpha1.Validator + 20, // 50: ethereum.eth.v1alpha1.BeaconStateDeneb.previous_justified_checkpoint:type_name -> ethereum.eth.v1alpha1.Checkpoint + 20, // 51: ethereum.eth.v1alpha1.BeaconStateDeneb.current_justified_checkpoint:type_name -> ethereum.eth.v1alpha1.Checkpoint + 20, // 52: ethereum.eth.v1alpha1.BeaconStateDeneb.finalized_checkpoint:type_name -> ethereum.eth.v1alpha1.Checkpoint + 22, // 53: ethereum.eth.v1alpha1.BeaconStateDeneb.current_sync_committee:type_name -> ethereum.eth.v1alpha1.SyncCommittee + 22, // 54: ethereum.eth.v1alpha1.BeaconStateDeneb.next_sync_committee:type_name -> ethereum.eth.v1alpha1.SyncCommittee + 26, // 55: ethereum.eth.v1alpha1.BeaconStateDeneb.latest_execution_payload_header:type_name -> ethereum.engine.v1.ExecutionPayloadHeaderDeneb + 25, // 56: ethereum.eth.v1alpha1.BeaconStateDeneb.historical_summaries:type_name -> ethereum.eth.v1alpha1.HistoricalSummary + 16, // 57: ethereum.eth.v1alpha1.BeaconStateElectra.fork:type_name -> ethereum.eth.v1alpha1.Fork + 17, // 58: ethereum.eth.v1alpha1.BeaconStateElectra.latest_block_header:type_name -> ethereum.eth.v1alpha1.BeaconBlockHeader + 18, // 59: ethereum.eth.v1alpha1.BeaconStateElectra.eth1_data:type_name -> ethereum.eth.v1alpha1.Eth1Data + 18, // 60: ethereum.eth.v1alpha1.BeaconStateElectra.eth1_data_votes:type_name -> ethereum.eth.v1alpha1.Eth1Data + 19, // 61: ethereum.eth.v1alpha1.BeaconStateElectra.validators:type_name -> ethereum.eth.v1alpha1.Validator + 20, // 62: ethereum.eth.v1alpha1.BeaconStateElectra.previous_justified_checkpoint:type_name -> ethereum.eth.v1alpha1.Checkpoint + 20, // 63: ethereum.eth.v1alpha1.BeaconStateElectra.current_justified_checkpoint:type_name -> ethereum.eth.v1alpha1.Checkpoint + 20, // 64: ethereum.eth.v1alpha1.BeaconStateElectra.finalized_checkpoint:type_name -> ethereum.eth.v1alpha1.Checkpoint + 22, // 65: ethereum.eth.v1alpha1.BeaconStateElectra.current_sync_committee:type_name -> ethereum.eth.v1alpha1.SyncCommittee + 22, // 66: ethereum.eth.v1alpha1.BeaconStateElectra.next_sync_committee:type_name -> ethereum.eth.v1alpha1.SyncCommittee + 26, // 67: ethereum.eth.v1alpha1.BeaconStateElectra.latest_execution_payload_header:type_name -> ethereum.engine.v1.ExecutionPayloadHeaderDeneb + 25, // 68: ethereum.eth.v1alpha1.BeaconStateElectra.historical_summaries:type_name -> ethereum.eth.v1alpha1.HistoricalSummary + 27, // 69: ethereum.eth.v1alpha1.BeaconStateElectra.pending_deposits:type_name -> ethereum.eth.v1alpha1.PendingDeposit + 28, // 70: ethereum.eth.v1alpha1.BeaconStateElectra.pending_partial_withdrawals:type_name -> ethereum.eth.v1alpha1.PendingPartialWithdrawal + 29, // 71: ethereum.eth.v1alpha1.BeaconStateElectra.pending_consolidations:type_name -> ethereum.eth.v1alpha1.PendingConsolidation + 16, // 72: ethereum.eth.v1alpha1.BeaconStateFulu.fork:type_name -> ethereum.eth.v1alpha1.Fork + 17, // 73: ethereum.eth.v1alpha1.BeaconStateFulu.latest_block_header:type_name -> ethereum.eth.v1alpha1.BeaconBlockHeader + 18, // 74: ethereum.eth.v1alpha1.BeaconStateFulu.eth1_data:type_name -> ethereum.eth.v1alpha1.Eth1Data + 18, // 75: ethereum.eth.v1alpha1.BeaconStateFulu.eth1_data_votes:type_name -> ethereum.eth.v1alpha1.Eth1Data + 19, // 76: ethereum.eth.v1alpha1.BeaconStateFulu.validators:type_name -> ethereum.eth.v1alpha1.Validator + 20, // 77: ethereum.eth.v1alpha1.BeaconStateFulu.previous_justified_checkpoint:type_name -> ethereum.eth.v1alpha1.Checkpoint + 20, // 78: ethereum.eth.v1alpha1.BeaconStateFulu.current_justified_checkpoint:type_name -> ethereum.eth.v1alpha1.Checkpoint + 20, // 79: ethereum.eth.v1alpha1.BeaconStateFulu.finalized_checkpoint:type_name -> ethereum.eth.v1alpha1.Checkpoint + 22, // 80: ethereum.eth.v1alpha1.BeaconStateFulu.current_sync_committee:type_name -> ethereum.eth.v1alpha1.SyncCommittee + 22, // 81: ethereum.eth.v1alpha1.BeaconStateFulu.next_sync_committee:type_name -> ethereum.eth.v1alpha1.SyncCommittee + 26, // 82: ethereum.eth.v1alpha1.BeaconStateFulu.latest_execution_payload_header:type_name -> ethereum.engine.v1.ExecutionPayloadHeaderDeneb + 25, // 83: ethereum.eth.v1alpha1.BeaconStateFulu.historical_summaries:type_name -> ethereum.eth.v1alpha1.HistoricalSummary + 27, // 84: ethereum.eth.v1alpha1.BeaconStateFulu.pending_deposits:type_name -> ethereum.eth.v1alpha1.PendingDeposit + 28, // 85: ethereum.eth.v1alpha1.BeaconStateFulu.pending_partial_withdrawals:type_name -> ethereum.eth.v1alpha1.PendingPartialWithdrawal + 29, // 86: ethereum.eth.v1alpha1.BeaconStateFulu.pending_consolidations:type_name -> ethereum.eth.v1alpha1.PendingConsolidation + 87, // [87:87] is the sub-list for method output_type + 87, // [87:87] is the sub-list for method input_type + 87, // [87:87] is the sub-list for extension type_name + 87, // [87:87] is the sub-list for extension extendee + 0, // [0:87] is the sub-list for field type_name +} + +func init() { file_proto_prysm_v1alpha1_beacon_state_proto_init() } +func file_proto_prysm_v1alpha1_beacon_state_proto_init() { + if File_proto_prysm_v1alpha1_beacon_state_proto != nil { + return + } + file_proto_prysm_v1alpha1_attestation_proto_init() + file_proto_prysm_v1alpha1_beacon_core_types_proto_init() + file_proto_prysm_v1alpha1_eip_7251_proto_init() + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_proto_prysm_v1alpha1_beacon_state_proto_rawDesc, + NumEnums: 0, + NumMessages: 16, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_proto_prysm_v1alpha1_beacon_state_proto_goTypes, + DependencyIndexes: file_proto_prysm_v1alpha1_beacon_state_proto_depIdxs, + MessageInfos: file_proto_prysm_v1alpha1_beacon_state_proto_msgTypes, + }.Build() + File_proto_prysm_v1alpha1_beacon_state_proto = out.File + file_proto_prysm_v1alpha1_beacon_state_proto_rawDesc = nil + file_proto_prysm_v1alpha1_beacon_state_proto_goTypes = nil + file_proto_prysm_v1alpha1_beacon_state_proto_depIdxs = nil +} diff --git a/proto/prysm/v1alpha1/beacon_state.pb.go b/proto/prysm/v1alpha1/beacon_state.pb.go index b674b2087f4b..348fc6e3843f 100755 --- a/proto/prysm/v1alpha1/beacon_state.pb.go +++ b/proto/prysm/v1alpha1/beacon_state.pb.go @@ -1,3 +1,5 @@ +//go:build !minimal + // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.36.3 diff --git a/proto/prysm/v1alpha1/bellatrix.minimal.ssz.go b/proto/prysm/v1alpha1/bellatrix.minimal.ssz.go index 762aa926cc58..944ef1b50007 100644 --- a/proto/prysm/v1alpha1/bellatrix.minimal.ssz.go +++ b/proto/prysm/v1alpha1/bellatrix.minimal.ssz.go @@ -1,2331 +1,2252 @@ //go:build minimal -// Code generated by fastssz. DO NOT EDIT. package eth import ( - github_com_OffchainLabs_prysm_v7_consensus_types_primitives "github.com/OffchainLabs/prysm/v7/consensus-types/primitives" + binary "encoding/binary" + "fmt" + go_bitfield "github.com/OffchainLabs/go-bitfield" + ssz "github.com/OffchainLabs/methodical-ssz/ssz" v1 "github.com/OffchainLabs/prysm/v7/proto/engine/v1" - ssz "github.com/prysmaticlabs/fastssz" ) -// MarshalSSZ ssz marshals the SignedBeaconBlockBellatrix object -func (s *SignedBeaconBlockBellatrix) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) -} - -// MarshalSSZTo ssz marshals the SignedBeaconBlockBellatrix object to a target array -func (s *SignedBeaconBlockBellatrix) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(100) - - // Offset (0) 'Block' - dst = ssz.WriteOffset(dst, offset) - if s.Block == nil { - s.Block = new(BeaconBlockBellatrix) - } - offset += s.Block.SizeSSZ() - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return - } - dst = append(dst, s.Signature...) - - // Field (0) 'Block' - if dst, err = s.Block.MarshalSSZTo(dst); err != nil { - return +func (c *BeaconBlockBellatrix) SizeSSZ() int { + size := 84 + if c.Body == nil { + c.Body = new(BeaconBlockBodyBellatrix) } - - return + size += c.Body.SizeSSZ() + return size } -// UnmarshalSSZ ssz unmarshals the SignedBeaconBlockBellatrix object -func (s *SignedBeaconBlockBellatrix) 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(BeaconBlockBellatrix) - } - if err = s.Block.UnmarshalSSZ(buf); err != nil { - return err - } - } - return err +func (c *BeaconBlockBellatrix) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// SizeSSZ returns the ssz encoded size in bytes for the SignedBeaconBlockBellatrix object -func (s *SignedBeaconBlockBellatrix) SizeSSZ() (size int) { - size = 100 +func (c *BeaconBlockBellatrix) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 84 - // Field (0) 'Block' - if s.Block == nil { - s.Block = new(BeaconBlockBellatrix) + // Field 0: Slot + if dst, err = c.Slot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Slot: %w", err) } - size += s.Block.SizeSSZ() - - return -} -// HashTreeRoot ssz hashes the SignedBeaconBlockBellatrix object -func (s *SignedBeaconBlockBellatrix) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) -} - -// HashTreeRootWith ssz hashes the SignedBeaconBlockBellatrix object with a hasher -func (s *SignedBeaconBlockBellatrix) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'Block' - if err = s.Block.HashTreeRootWith(hh); err != nil { - return + // Field 1: ProposerIndex + if dst, err = c.ProposerIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ProposerIndex: %w", err) } - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 2: ParentRoot + if len(c.ParentRoot) != 32 { + return nil, ssz.ErrBytesLength } - hh.PutBytes(s.Signature) - - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the BeaconBlockBellatrix object -func (b *BeaconBlockBellatrix) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} - -// MarshalSSZTo ssz marshals the BeaconBlockBellatrix object to a target array -func (b *BeaconBlockBellatrix) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(84) - - // Field (0) 'Slot' - dst = ssz.MarshalUint(dst, b.Slot) - - // Field (1) 'ProposerIndex' - dst = ssz.MarshalUint(dst, b.ProposerIndex) + dst = append(dst, c.ParentRoot...) - // Field (2) 'ParentRoot' - if size := len(b.ParentRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentRoot", size, 32) - return + // Field 3: StateRoot + if len(c.StateRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.ParentRoot...) + dst = append(dst, c.StateRoot...) - // Field (3) 'StateRoot' - if size := len(b.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return + // Field 4: Body + if c.Body == nil { + c.Body = new(BeaconBlockBodyBellatrix) } - dst = append(dst, b.StateRoot...) - - // Offset (4) 'Body' dst = ssz.WriteOffset(dst, offset) - if b.Body == nil { - b.Body = new(BeaconBlockBodyBellatrix) - } - offset += b.Body.SizeSSZ() + offset += c.Body.SizeSSZ() - // Field (4) 'Body' - if dst, err = b.Body.MarshalSSZTo(dst); err != nil { - return + // Field 4: Body + if dst, err = c.Body.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Body: %w", err) } - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the BeaconBlockBellatrix object -func (b *BeaconBlockBellatrix) UnmarshalSSZ(buf []byte) error { +func (c *BeaconBlockBellatrix) 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.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[0:8]) + sszSlice0 := buf[0:8] // c.Slot + sszSlice1 := buf[8:16] // c.ProposerIndex + sszSlice2 := buf[16:48] // c.ParentRoot + sszSlice3 := buf[48:80] // c.StateRoot - // Field (1) 'ProposerIndex' - b.ProposerIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](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])) + sszVarOffset4 := ssz.ReadOffset(buf[80:84]) // c.Body + if sszVarOffset4 != 84 { + return ssz.ErrInvalidVariableOffset } - b.StateRoot = append(b.StateRoot, buf[48:80]...) - - // Offset (4) 'Body' - if o4 = ssz.ReadOffset(buf[80:84]); o4 > size { + if sszVarOffset4 > size { return ssz.ErrOffset } + sszSlice4 := buf[sszVarOffset4:] // c.Body - if o4 != 84 { - return ssz.ErrInvalidVariableOffset + // Field 0: Slot + if err = c.Slot.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Slot: %w", err) } - // Field (4) 'Body' - { - buf = tail[o4:] - if b.Body == nil { - b.Body = new(BeaconBlockBodyBellatrix) - } - if err = b.Body.UnmarshalSSZ(buf); err != nil { - return err - } + // Field 1: ProposerIndex + if err = c.ProposerIndex.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("ProposerIndex: %w", err) } - return err -} -// SizeSSZ returns the ssz encoded size in bytes for the BeaconBlockBellatrix object -func (b *BeaconBlockBellatrix) SizeSSZ() (size int) { - size = 84 + // Field 2: ParentRoot + c.ParentRoot = make([]byte, 0, 32) + c.ParentRoot = append(c.ParentRoot, sszSlice2...) - // Field (4) 'Body' - if b.Body == nil { - b.Body = new(BeaconBlockBodyBellatrix) - } - size += b.Body.SizeSSZ() + // Field 3: StateRoot + c.StateRoot = make([]byte, 0, 32) + c.StateRoot = append(c.StateRoot, sszSlice3...) - return + // Field 4: Body + c.Body = new(BeaconBlockBodyBellatrix) + if err = c.Body.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("Body: %w", err) + } + return err } -// HashTreeRoot ssz hashes the BeaconBlockBellatrix object -func (b *BeaconBlockBellatrix) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) +func (c *BeaconBlockBellatrix) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the BeaconBlockBellatrix object with a hasher -func (b *BeaconBlockBellatrix) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *BeaconBlockBellatrix) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Slot' - ssz.PutUint(hh, b.Slot) - - // Field (1) 'ProposerIndex' - ssz.PutUint(hh, b.ProposerIndex) - - // Field (2) 'ParentRoot' - if size := len(b.ParentRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentRoot", size, 32) - return + // Field 0: Slot + if err := c.Slot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Slot: %w", err) } - hh.PutBytes(b.ParentRoot) - - // Field (3) 'StateRoot' - if size := len(b.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return + // Field 1: ProposerIndex + if err := c.ProposerIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ProposerIndex: %w", err) } - hh.PutBytes(b.StateRoot) - - // Field (4) 'Body' - if err = b.Body.HashTreeRootWith(hh); err != nil { - return + // Field 2: ParentRoot + if len(c.ParentRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ParentRoot) + // Field 3: StateRoot + if len(c.StateRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.StateRoot) + // Field 4: Body + if err := c.Body.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Body: %w", err) } - hh.Merkleize(indx) - return + return nil +} + +func (c *BeaconBlockBodyBellatrix) SizeSSZ() int { + size := 324 + size += len(c.ProposerSlashings) * 416 + for _, o := range c.AttesterSlashings { + size += 4 + size += o.SizeSSZ() + } + for _, o := range c.Attestations { + size += 4 + size += o.SizeSSZ() + } + size += len(c.Deposits) * 1240 + size += len(c.VoluntaryExits) * 112 + if c.ExecutionPayload == nil { + c.ExecutionPayload = new(v1.ExecutionPayload) + } + size += c.ExecutionPayload.SizeSSZ() + return size } -// MarshalSSZ ssz marshals the BeaconBlockBodyBellatrix object -func (b *BeaconBlockBodyBellatrix) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) +func (c *BeaconBlockBodyBellatrix) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the BeaconBlockBodyBellatrix object to a target array -func (b *BeaconBlockBodyBellatrix) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(324) +func (c *BeaconBlockBodyBellatrix) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 324 - // Field (0) 'RandaoReveal' - if size := len(b.RandaoReveal); size != 96 { - err = ssz.ErrBytesLengthFn("--.RandaoReveal", size, 96) - return + // Field 0: RandaoReveal + if len(c.RandaoReveal) != 96 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.RandaoReveal...) + dst = append(dst, c.RandaoReveal...) - // Field (1) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(Eth1Data) + // Field 1: Eth1Data + if c.Eth1Data == nil { + c.Eth1Data = new(Eth1Data) } - if dst, err = b.Eth1Data.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.Eth1Data.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Eth1Data: %w", err) } - // Field (2) 'Graffiti' - if size := len(b.Graffiti); size != 32 { - err = ssz.ErrBytesLengthFn("--.Graffiti", size, 32) - return + // Field 2: Graffiti + if len(c.Graffiti) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.Graffiti...) + dst = append(dst, c.Graffiti...) - // Offset (3) 'ProposerSlashings' + // Field 3: ProposerSlashings dst = ssz.WriteOffset(dst, offset) - offset += len(b.ProposerSlashings) * 416 + offset += len(c.ProposerSlashings) * 416 - // Offset (4) 'AttesterSlashings' + // Field 4: AttesterSlashings dst = ssz.WriteOffset(dst, offset) - for ii := 0; ii < len(b.AttesterSlashings); ii++ { + for _, o := range c.AttesterSlashings { offset += 4 - offset += b.AttesterSlashings[ii].SizeSSZ() + offset += o.SizeSSZ() } - // Offset (5) 'Attestations' + // Field 5: Attestations dst = ssz.WriteOffset(dst, offset) - for ii := 0; ii < len(b.Attestations); ii++ { + for _, o := range c.Attestations { offset += 4 - offset += b.Attestations[ii].SizeSSZ() + offset += o.SizeSSZ() } - // Offset (6) 'Deposits' + // Field 6: Deposits dst = ssz.WriteOffset(dst, offset) - offset += len(b.Deposits) * 1240 + offset += len(c.Deposits) * 1240 - // Offset (7) 'VoluntaryExits' + // Field 7: VoluntaryExits dst = ssz.WriteOffset(dst, offset) - offset += len(b.VoluntaryExits) * 112 + offset += len(c.VoluntaryExits) * 112 - // Field (8) 'SyncAggregate' - if b.SyncAggregate == nil { - b.SyncAggregate = new(SyncAggregate) + // Field 8: SyncAggregate + if c.SyncAggregate == nil { + c.SyncAggregate = new(SyncAggregate) } - if dst, err = b.SyncAggregate.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.SyncAggregate.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SyncAggregate: %w", err) } - // Offset (9) 'ExecutionPayload' - dst = ssz.WriteOffset(dst, offset) - if b.ExecutionPayload == nil { - b.ExecutionPayload = new(v1.ExecutionPayload) + // Field 9: ExecutionPayload + if c.ExecutionPayload == nil { + c.ExecutionPayload = new(v1.ExecutionPayload) } - offset += b.ExecutionPayload.SizeSSZ() + dst = ssz.WriteOffset(dst, offset) + offset += c.ExecutionPayload.SizeSSZ() - // Field (3) 'ProposerSlashings' - if size := len(b.ProposerSlashings); size > 16 { - err = ssz.ErrListTooBigFn("--.ProposerSlashings", size, 16) - return + // Field 3: ProposerSlashings + if len(c.ProposerSlashings) > 16 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.ProposerSlashings); ii++ { - if dst, err = b.ProposerSlashings[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.ProposerSlashings { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ProposerSlashings: %w", err) } } - // Field (4) 'AttesterSlashings' - if size := len(b.AttesterSlashings); size > 2 { - err = ssz.ErrListTooBigFn("--.AttesterSlashings", size, 2) - return + // Field 4: AttesterSlashings + if len(c.AttesterSlashings) > 2 { + return nil, ssz.ErrListTooBig } { - offset = 4 * len(b.AttesterSlashings) - for ii := 0; ii < len(b.AttesterSlashings); ii++ { + offset = 4 * len(c.AttesterSlashings) + for _, o := range c.AttesterSlashings { dst = ssz.WriteOffset(dst, offset) - offset += b.AttesterSlashings[ii].SizeSSZ() + offset += o.SizeSSZ() } } - for ii := 0; ii < len(b.AttesterSlashings); ii++ { - if dst, err = b.AttesterSlashings[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.AttesterSlashings { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("AttesterSlashings: %w", err) } } - // Field (5) 'Attestations' - if size := len(b.Attestations); size > 128 { - err = ssz.ErrListTooBigFn("--.Attestations", size, 128) - return + // Field 5: Attestations + if len(c.Attestations) > 128 { + return nil, ssz.ErrListTooBig } { - offset = 4 * len(b.Attestations) - for ii := 0; ii < len(b.Attestations); ii++ { + offset = 4 * len(c.Attestations) + for _, o := range c.Attestations { dst = ssz.WriteOffset(dst, offset) - offset += b.Attestations[ii].SizeSSZ() + offset += o.SizeSSZ() } } - for ii := 0; ii < len(b.Attestations); ii++ { - if dst, err = b.Attestations[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.Attestations { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Attestations: %w", err) } } - // Field (6) 'Deposits' - if size := len(b.Deposits); size > 16 { - err = ssz.ErrListTooBigFn("--.Deposits", size, 16) - return + // Field 6: Deposits + if len(c.Deposits) > 16 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.Deposits); ii++ { - if dst, err = b.Deposits[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.Deposits { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Deposits: %w", err) } } - // Field (7) 'VoluntaryExits' - if size := len(b.VoluntaryExits); size > 16 { - err = ssz.ErrListTooBigFn("--.VoluntaryExits", size, 16) - return + // Field 7: VoluntaryExits + if len(c.VoluntaryExits) > 16 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.VoluntaryExits); ii++ { - if dst, err = b.VoluntaryExits[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.VoluntaryExits { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("VoluntaryExits: %w", err) } } - // Field (9) 'ExecutionPayload' - if dst, err = b.ExecutionPayload.MarshalSSZTo(dst); err != nil { - return + // Field 9: ExecutionPayload + if dst, err = c.ExecutionPayload.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ExecutionPayload: %w", err) } - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the BeaconBlockBodyBellatrix object -func (b *BeaconBlockBodyBellatrix) UnmarshalSSZ(buf []byte) error { +func (c *BeaconBlockBodyBellatrix) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size < 324 { return ssz.ErrSize } - tail := buf - var o3, o4, o5, o6, o7, o9 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(Eth1Data) - } - if err = b.Eth1Data.UnmarshalSSZ(buf[96:168]); err != nil { - return err - } + sszSlice0 := buf[0:96] // c.RandaoReveal + sszSlice1 := buf[96:168] // c.Eth1Data + sszSlice2 := buf[168:200] // c.Graffiti + sszSlice8 := buf[220:320] // c.SyncAggregate - // Field (2) 'Graffiti' - if cap(b.Graffiti) == 0 { - b.Graffiti = make([]byte, 0, len(buf[168:200])) + sszVarOffset3 := ssz.ReadOffset(buf[200:204]) // c.ProposerSlashings + if sszVarOffset3 != 324 { + return ssz.ErrInvalidVariableOffset } - b.Graffiti = append(b.Graffiti, buf[168:200]...) - - // Offset (3) 'ProposerSlashings' - if o3 = ssz.ReadOffset(buf[200:204]); o3 > size { + if sszVarOffset3 > size { return ssz.ErrOffset } - - if o3 != 324 { - return ssz.ErrInvalidVariableOffset + sszVarOffset4 := ssz.ReadOffset(buf[204:208]) // c.AttesterSlashings + if sszVarOffset4 > size || sszVarOffset4 < sszVarOffset3 { + return ssz.ErrOffset } - - // Offset (4) 'AttesterSlashings' - if o4 = ssz.ReadOffset(buf[204:208]); o4 > size || o3 > o4 { + sszVarOffset5 := ssz.ReadOffset(buf[208:212]) // c.Attestations + if sszVarOffset5 > size || sszVarOffset5 < sszVarOffset4 { return ssz.ErrOffset } - - // Offset (5) 'Attestations' - if o5 = ssz.ReadOffset(buf[208:212]); o5 > size || o4 > o5 { + sszVarOffset6 := ssz.ReadOffset(buf[212:216]) // c.Deposits + if sszVarOffset6 > size || sszVarOffset6 < sszVarOffset5 { return ssz.ErrOffset } - - // Offset (6) 'Deposits' - if o6 = ssz.ReadOffset(buf[212:216]); o6 > size || o5 > o6 { + sszVarOffset7 := ssz.ReadOffset(buf[216:220]) // c.VoluntaryExits + if sszVarOffset7 > size || sszVarOffset7 < sszVarOffset6 { return ssz.ErrOffset } - - // Offset (7) 'VoluntaryExits' - if o7 = ssz.ReadOffset(buf[216:220]); o7 > size || o6 > o7 { + sszVarOffset9 := ssz.ReadOffset(buf[320:324]) // c.ExecutionPayload + if sszVarOffset9 > size || sszVarOffset9 < sszVarOffset7 { return ssz.ErrOffset } + sszSlice3 := buf[sszVarOffset3:sszVarOffset4] // c.ProposerSlashings + sszSlice4 := buf[sszVarOffset4:sszVarOffset5] // c.AttesterSlashings + sszSlice5 := buf[sszVarOffset5:sszVarOffset6] // c.Attestations + sszSlice6 := buf[sszVarOffset6:sszVarOffset7] // c.Deposits + sszSlice7 := buf[sszVarOffset7:sszVarOffset9] // c.VoluntaryExits + sszSlice9 := buf[sszVarOffset9:] // c.ExecutionPayload - // Field (8) 'SyncAggregate' - if b.SyncAggregate == nil { - b.SyncAggregate = new(SyncAggregate) - } - if err = b.SyncAggregate.UnmarshalSSZ(buf[220:320]); err != nil { - return err - } + // Field 0: RandaoReveal + c.RandaoReveal = make([]byte, 0, 96) + c.RandaoReveal = append(c.RandaoReveal, sszSlice0...) - // Offset (9) 'ExecutionPayload' - if o9 = ssz.ReadOffset(buf[320:324]); o9 > size || o7 > o9 { - return ssz.ErrOffset + // Field 1: Eth1Data + c.Eth1Data = new(Eth1Data) + if err = c.Eth1Data.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Eth1Data: %w", err) } - // Field (3) 'ProposerSlashings' + // Field 2: Graffiti + c.Graffiti = make([]byte, 0, 32) + c.Graffiti = append(c.Graffiti, sszSlice2...) + + // Field 3: ProposerSlashings { - buf = tail[o3:o4] - num, err := ssz.DivideInt2(len(buf), 416, 16) - if err != nil { - return err - } - b.ProposerSlashings = make([]*ProposerSlashing, num) - for ii := 0; ii < num; ii++ { - if b.ProposerSlashings[ii] == nil { - b.ProposerSlashings[ii] = new(ProposerSlashing) - } - if err = b.ProposerSlashings[ii].UnmarshalSSZ(buf[ii*416 : (ii+1)*416]); err != nil { - return err + if len(sszSlice3)%416 != 0 { + return fmt.Errorf("misaligned bytes: c.ProposerSlashings length is %d, which is not a multiple of 416: %w", len(sszSlice3), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice3) / 416 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.ProposerSlashings has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.ProposerSlashings = make([]*ProposerSlashing, numElem) + for i := 0; i < numElem; i++ { + var tmp *ProposerSlashing + tmp = new(ProposerSlashing) + tmpSlice := sszSlice3[i*416 : (1+i)*416] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("ProposerSlashings: %w", err) } + c.ProposerSlashings[i] = tmp } } - // Field (4) 'AttesterSlashings' + // Field 4: AttesterSlashings { - buf = tail[o4:o5] - num, err := ssz.DecodeDynamicLength(buf, 2) - 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) + // empty lists are zero length, so make sure there is room for an offset + // before attempting to unmarshal it + if len(sszSlice4) > 3 { + startOffset := ssz.ReadOffset(sszSlice4[0:4]) + if startOffset == 0 { + return fmt.Errorf("encountered invalid offset of 0 when decoding c.AttesterSlashings") } - if err = b.AttesterSlashings[indx].UnmarshalSSZ(buf); err != nil { - return err + if startOffset%4 != 0 { + return fmt.Errorf("misaligned list bytes: when decoding c.AttesterSlashings, end-of-list offset is %d, which is not a multiple of 4 (offset size)", startOffset) } - 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([]*Attestation, num) - err = ssz.UnmarshalDynamic(buf, num, func(indx int, buf []byte) (err error) { - if b.Attestations[indx] == nil { - b.Attestations[indx] = new(Attestation) + listLen := startOffset / 4 + if listLen > 2 { + return fmt.Errorf("ssz-max exceeded: c.AttesterSlashings has %d elements, ssz-max is 2: %w", listLen, ssz.ErrListTooBig) + } + totalVarBytes := uint64(len(sszSlice4)) + if totalVarBytes < startOffset { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.AttesterSlashings") } - if err = b.Attestations[indx].UnmarshalSSZ(buf); err != nil { - return err + c.AttesterSlashings = make([]*AttesterSlashing, listLen) + var tmpSlice []byte + for i := uint64(0); i < listLen; i++ { + var tmp *AttesterSlashing + tmp = new(AttesterSlashing) + endOffset := totalVarBytes + if i+1 != listLen { + endOffset = ssz.ReadOffset(sszSlice4[(i+1)*4 : (i+2)*4]) + if totalVarBytes < endOffset { + return fmt.Errorf("offset %d points past the end of buffer when decoding c.AttesterSlashings", endOffset) + } + } + if endOffset < startOffset { + return fmt.Errorf("offset %d is not greater than start offset %d when decoding c.AttesterSlashings", endOffset, startOffset) + } + tmpSlice = sszSlice4[startOffset:endOffset] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("AttesterSlashings: %w", err) + } + c.AttesterSlashings[i] = tmp + startOffset = endOffset } - return nil - }) - if err != nil { - return err + } else { + if len(sszSlice4) > 0 { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.AttesterSlashings") + } + c.AttesterSlashings = make([]*AttesterSlashing, 0) } } - // Field (6) 'Deposits' + // Field 5: Attestations { - buf = tail[o6:o7] - num, err := ssz.DivideInt2(len(buf), 1240, 16) - if err != nil { - return err - } - b.Deposits = make([]*Deposit, num) - for ii := 0; ii < num; ii++ { - if b.Deposits[ii] == nil { - b.Deposits[ii] = new(Deposit) + // empty lists are zero length, so make sure there is room for an offset + // before attempting to unmarshal it + if len(sszSlice5) > 3 { + startOffset := ssz.ReadOffset(sszSlice5[0:4]) + if startOffset == 0 { + return fmt.Errorf("encountered invalid offset of 0 when decoding c.Attestations") + } + if startOffset%4 != 0 { + return fmt.Errorf("misaligned list bytes: when decoding c.Attestations, end-of-list offset is %d, which is not a multiple of 4 (offset size)", startOffset) } - if err = b.Deposits[ii].UnmarshalSSZ(buf[ii*1240 : (ii+1)*1240]); err != nil { - return err + listLen := startOffset / 4 + if listLen > 128 { + return fmt.Errorf("ssz-max exceeded: c.Attestations has %d elements, ssz-max is 128: %w", listLen, ssz.ErrListTooBig) } + totalVarBytes := uint64(len(sszSlice5)) + if totalVarBytes < startOffset { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.Attestations") + } + c.Attestations = make([]*Attestation, listLen) + var tmpSlice []byte + for i := uint64(0); i < listLen; i++ { + var tmp *Attestation + tmp = new(Attestation) + endOffset := totalVarBytes + if i+1 != listLen { + endOffset = ssz.ReadOffset(sszSlice5[(i+1)*4 : (i+2)*4]) + if totalVarBytes < endOffset { + return fmt.Errorf("offset %d points past the end of buffer when decoding c.Attestations", endOffset) + } + } + if endOffset < startOffset { + return fmt.Errorf("offset %d is not greater than start offset %d when decoding c.Attestations", endOffset, startOffset) + } + tmpSlice = sszSlice5[startOffset:endOffset] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Attestations: %w", err) + } + c.Attestations[i] = tmp + startOffset = endOffset + } + } else { + if len(sszSlice5) > 0 { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.Attestations") + } + c.Attestations = make([]*Attestation, 0) } } - // Field (7) 'VoluntaryExits' + // Field 6: Deposits { - buf = tail[o7:o9] - num, err := ssz.DivideInt2(len(buf), 112, 16) - if err != nil { - return err - } - b.VoluntaryExits = make([]*SignedVoluntaryExit, num) - for ii := 0; ii < num; ii++ { - if b.VoluntaryExits[ii] == nil { - b.VoluntaryExits[ii] = new(SignedVoluntaryExit) - } - if err = b.VoluntaryExits[ii].UnmarshalSSZ(buf[ii*112 : (ii+1)*112]); err != nil { - return err + if len(sszSlice6)%1240 != 0 { + return fmt.Errorf("misaligned bytes: c.Deposits length is %d, which is not a multiple of 1240: %w", len(sszSlice6), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice6) / 1240 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.Deposits has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.Deposits = make([]*Deposit, numElem) + for i := 0; i < numElem; i++ { + var tmp *Deposit + tmp = new(Deposit) + tmpSlice := sszSlice6[i*1240 : (1+i)*1240] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Deposits: %w", err) } + c.Deposits[i] = tmp } } - // Field (9) 'ExecutionPayload' + // Field 7: VoluntaryExits { - buf = tail[o9:] - if b.ExecutionPayload == nil { - b.ExecutionPayload = new(v1.ExecutionPayload) - } - if err = b.ExecutionPayload.UnmarshalSSZ(buf); err != nil { - return err + if len(sszSlice7)%112 != 0 { + return fmt.Errorf("misaligned bytes: c.VoluntaryExits length is %d, which is not a multiple of 112: %w", len(sszSlice7), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice7) / 112 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.VoluntaryExits has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.VoluntaryExits = make([]*SignedVoluntaryExit, numElem) + for i := 0; i < numElem; i++ { + var tmp *SignedVoluntaryExit + tmp = new(SignedVoluntaryExit) + tmpSlice := sszSlice7[i*112 : (1+i)*112] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("VoluntaryExits: %w", err) + } + c.VoluntaryExits[i] = tmp } } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the BeaconBlockBodyBellatrix object -func (b *BeaconBlockBodyBellatrix) SizeSSZ() (size int) { - size = 324 - - // 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 8: SyncAggregate + c.SyncAggregate = new(SyncAggregate) + if err = c.SyncAggregate.UnmarshalSSZ(sszSlice8); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) } - // 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(v1.ExecutionPayload) + // Field 9: ExecutionPayload + c.ExecutionPayload = new(v1.ExecutionPayload) + if err = c.ExecutionPayload.UnmarshalSSZ(sszSlice9); err != nil { + return fmt.Errorf("ExecutionPayload: %w", err) } - size += b.ExecutionPayload.SizeSSZ() - - return + return err } -// HashTreeRoot ssz hashes the BeaconBlockBodyBellatrix object -func (b *BeaconBlockBodyBellatrix) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) +func (c *BeaconBlockBodyBellatrix) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the BeaconBlockBodyBellatrix object with a hasher -func (b *BeaconBlockBodyBellatrix) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *BeaconBlockBodyBellatrix) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'RandaoReveal' - if size := len(b.RandaoReveal); size != 96 { - err = ssz.ErrBytesLengthFn("--.RandaoReveal", size, 96) - return + // Field 0: RandaoReveal + if len(c.RandaoReveal) != 96 { + return ssz.ErrBytesLength } - hh.PutBytes(b.RandaoReveal) - - // Field (1) 'Eth1Data' - if err = b.Eth1Data.HashTreeRootWith(hh); err != nil { - return + hh.PutBytes(c.RandaoReveal) + // Field 1: Eth1Data + if err := c.Eth1Data.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Eth1Data: %w", err) } - - // Field (2) 'Graffiti' - if size := len(b.Graffiti); size != 32 { - err = ssz.ErrBytesLengthFn("--.Graffiti", size, 32) - return + // Field 2: Graffiti + if len(c.Graffiti) != 32 { + return ssz.ErrBytesLength } - hh.PutBytes(b.Graffiti) - - // Field (3) 'ProposerSlashings' + hh.PutBytes(c.Graffiti) + // Field 3: ProposerSlashings { + if len(c.ProposerSlashings) > 16 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.ProposerSlashings { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ProposerSlashings: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.ProposerSlashings)), 16) } - - // Field (4) 'AttesterSlashings' + // Field 4: AttesterSlashings { + if len(c.AttesterSlashings) > 2 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.AttesterSlashings { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("AttesterSlashings: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 2) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.AttesterSlashings)), 2) } - - // Field (5) 'Attestations' + // Field 5: Attestations { + if len(c.Attestations) > 128 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.Attestations { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Attestations: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 128) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Attestations)), 128) } - - // Field (6) 'Deposits' + // Field 6: Deposits { + if len(c.Deposits) > 16 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.Deposits { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Deposits: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Deposits)), 16) } - - // Field (7) 'VoluntaryExits' + // Field 7: VoluntaryExits { + if len(c.VoluntaryExits) > 16 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.VoluntaryExits { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("VoluntaryExits: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.VoluntaryExits)), 16) } - - // Field (8) 'SyncAggregate' - if err = b.SyncAggregate.HashTreeRootWith(hh); err != nil { - return + // Field 8: SyncAggregate + if err := c.SyncAggregate.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) } - - // Field (9) 'ExecutionPayload' - if err = b.ExecutionPayload.HashTreeRootWith(hh); err != nil { - return + // Field 9: ExecutionPayload + if err := c.ExecutionPayload.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ExecutionPayload: %w", err) } - hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the SignedBlindedBeaconBlockBellatrix object -func (s *SignedBlindedBeaconBlockBellatrix) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) +func (c *BeaconStateBellatrix) SizeSSZ() int { + size := 10233 + size += len(c.HistoricalRoots) * 32 + size += len(c.Eth1DataVotes) * 72 + size += len(c.Validators) * 121 + size += len(c.Balances) * 8 + size += len(c.PreviousEpochParticipation) + size += len(c.CurrentEpochParticipation) + size += len(c.InactivityScores) * 8 + if c.LatestExecutionPayloadHeader == nil { + c.LatestExecutionPayloadHeader = new(v1.ExecutionPayloadHeader) + } + size += c.LatestExecutionPayloadHeader.SizeSSZ() + return size } -// MarshalSSZTo ssz marshals the SignedBlindedBeaconBlockBellatrix object to a target array -func (s *SignedBlindedBeaconBlockBellatrix) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(100) - - // Offset (0) 'Block' - dst = ssz.WriteOffset(dst, offset) - if s.Block == nil { - s.Block = new(BlindedBeaconBlockBellatrix) - } - offset += s.Block.SizeSSZ() - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return - } - dst = append(dst, s.Signature...) - - // Field (0) 'Block' - if dst, err = s.Block.MarshalSSZTo(dst); err != nil { - return - } - - return +func (c *BeaconStateBellatrix) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// UnmarshalSSZ ssz unmarshals the SignedBlindedBeaconBlockBellatrix object -func (s *SignedBlindedBeaconBlockBellatrix) UnmarshalSSZ(buf []byte) error { +func (c *BeaconStateBellatrix) MarshalSSZTo(dst []byte) ([]byte, error) { var err error - size := uint64(len(buf)) - if size < 100 { - return ssz.ErrSize - } + offset := 10233 - tail := buf - var o0 uint64 + // Field 0: GenesisTime + dst = binary.LittleEndian.AppendUint64(dst, c.GenesisTime) - // Offset (0) 'Block' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset + // Field 1: GenesisValidatorsRoot + if len(c.GenesisValidatorsRoot) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.GenesisValidatorsRoot...) - if o0 != 100 { - return ssz.ErrInvalidVariableOffset + // Field 2: Slot + if dst, err = c.Slot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Slot: %w", err) } - // Field (1) 'Signature' - if cap(s.Signature) == 0 { - s.Signature = make([]byte, 0, len(buf[4:100])) + // Field 3: Fork + if c.Fork == nil { + c.Fork = new(Fork) } - s.Signature = append(s.Signature, buf[4:100]...) - - // Field (0) 'Block' - { - buf = tail[o0:] - if s.Block == nil { - s.Block = new(BlindedBeaconBlockBellatrix) - } - if err = s.Block.UnmarshalSSZ(buf); err != nil { - return err - } + if dst, err = c.Fork.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Fork: %w", err) } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the SignedBlindedBeaconBlockBellatrix object -func (s *SignedBlindedBeaconBlockBellatrix) SizeSSZ() (size int) { - size = 100 - // Field (0) 'Block' - if s.Block == nil { - s.Block = new(BlindedBeaconBlockBellatrix) + // Field 4: LatestBlockHeader + if c.LatestBlockHeader == nil { + c.LatestBlockHeader = new(BeaconBlockHeader) } - size += s.Block.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the SignedBlindedBeaconBlockBellatrix object -func (s *SignedBlindedBeaconBlockBellatrix) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) -} - -// HashTreeRootWith ssz hashes the SignedBlindedBeaconBlockBellatrix object with a hasher -func (s *SignedBlindedBeaconBlockBellatrix) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'Block' - if err = s.Block.HashTreeRootWith(hh); err != nil { - return + if dst, err = c.LatestBlockHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("LatestBlockHeader: %w", err) } - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 5: BlockRoots + if len(c.BlockRoots) != 64 { + return nil, ssz.ErrBytesLength } - hh.PutBytes(s.Signature) - - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the BlindedBeaconBlockBellatrix object -func (b *BlindedBeaconBlockBellatrix) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} - -// MarshalSSZTo ssz marshals the BlindedBeaconBlockBellatrix object to a target array -func (b *BlindedBeaconBlockBellatrix) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(84) - - // Field (0) 'Slot' - dst = ssz.MarshalUint(dst, b.Slot) - - // Field (1) 'ProposerIndex' - dst = ssz.MarshalUint(dst, b.ProposerIndex) - - // Field (2) 'ParentRoot' - if size := len(b.ParentRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentRoot", size, 32) - return + for _, o := range c.BlockRoots { + if len(o) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) } - dst = append(dst, b.ParentRoot...) - // Field (3) 'StateRoot' - if size := len(b.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return + // Field 6: StateRoots + if len(c.StateRoots) != 64 { + return nil, ssz.ErrBytesLength + } + for _, o := range c.StateRoots { + if len(o) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) } - dst = append(dst, b.StateRoot...) - // Offset (4) 'Body' + // Field 7: HistoricalRoots dst = ssz.WriteOffset(dst, offset) - if b.Body == nil { - b.Body = new(BlindedBeaconBlockBodyBellatrix) - } - offset += b.Body.SizeSSZ() + offset += len(c.HistoricalRoots) * 32 - // Field (4) 'Body' - if dst, err = b.Body.MarshalSSZTo(dst); err != nil { - return + // Field 8: Eth1Data + if c.Eth1Data == nil { + c.Eth1Data = new(Eth1Data) } - - return -} - -// UnmarshalSSZ ssz unmarshals the BlindedBeaconBlockBellatrix object -func (b *BlindedBeaconBlockBellatrix) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 84 { - return ssz.ErrSize + if dst, err = c.Eth1Data.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Eth1Data: %w", err) } - tail := buf - var o4 uint64 - - // Field (0) 'Slot' - b.Slot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[0:8]) - - // Field (1) 'ProposerIndex' - b.ProposerIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[8:16]) + // Field 9: Eth1DataVotes + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Eth1DataVotes) * 72 - // 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 10: Eth1DepositIndex + dst = binary.LittleEndian.AppendUint64(dst, c.Eth1DepositIndex) - // 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 11: Validators + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Validators) * 121 - // Offset (4) 'Body' - if o4 = ssz.ReadOffset(buf[80:84]); o4 > size { - return ssz.ErrOffset - } + // Field 12: Balances + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Balances) * 8 - if o4 != 84 { - return ssz.ErrInvalidVariableOffset + // Field 13: RandaoMixes + if len(c.RandaoMixes) != 64 { + return nil, ssz.ErrBytesLength } - - // Field (4) 'Body' - { - buf = tail[o4:] - if b.Body == nil { - b.Body = new(BlindedBeaconBlockBodyBellatrix) - } - if err = b.Body.UnmarshalSSZ(buf); err != nil { - return err + for _, o := range c.RandaoMixes { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, o...) } - return err -} -// SizeSSZ returns the ssz encoded size in bytes for the BlindedBeaconBlockBellatrix object -func (b *BlindedBeaconBlockBellatrix) SizeSSZ() (size int) { - size = 84 - - // Field (4) 'Body' - if b.Body == nil { - b.Body = new(BlindedBeaconBlockBodyBellatrix) + // Field 14: Slashings + if len(c.Slashings) != 64 { + return nil, ssz.ErrBytesLength + } + for _, o := range c.Slashings { + dst = binary.LittleEndian.AppendUint64(dst, o) } - size += b.Body.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the BlindedBeaconBlockBellatrix object -func (b *BlindedBeaconBlockBellatrix) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) -} - -// HashTreeRootWith ssz hashes the BlindedBeaconBlockBellatrix object with a hasher -func (b *BlindedBeaconBlockBellatrix) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'Slot' - ssz.PutUint(hh, b.Slot) - // Field (1) 'ProposerIndex' - ssz.PutUint(hh, b.ProposerIndex) + // Field 15: PreviousEpochParticipation + dst = ssz.WriteOffset(dst, offset) + offset += len(c.PreviousEpochParticipation) - // Field (2) 'ParentRoot' - if size := len(b.ParentRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentRoot", size, 32) - return - } - hh.PutBytes(b.ParentRoot) + // Field 16: CurrentEpochParticipation + dst = ssz.WriteOffset(dst, offset) + offset += len(c.CurrentEpochParticipation) - // Field (3) 'StateRoot' - if size := len(b.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return + // Field 17: JustificationBits + if len([]byte(c.JustificationBits)) != 1 { + return nil, ssz.ErrBytesLength } - hh.PutBytes(b.StateRoot) + dst = append(dst, []byte(c.JustificationBits)...) - // Field (4) 'Body' - if err = b.Body.HashTreeRootWith(hh); err != nil { - return + // Field 18: PreviousJustifiedCheckpoint + if c.PreviousJustifiedCheckpoint == nil { + c.PreviousJustifiedCheckpoint = new(Checkpoint) } - - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the BlindedBeaconBlockBodyBellatrix object -func (b *BlindedBeaconBlockBodyBellatrix) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} - -// MarshalSSZTo ssz marshals the BlindedBeaconBlockBodyBellatrix object to a target array -func (b *BlindedBeaconBlockBodyBellatrix) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(324) - - // Field (0) 'RandaoReveal' - if size := len(b.RandaoReveal); size != 96 { - err = ssz.ErrBytesLengthFn("--.RandaoReveal", size, 96) - return + if dst, err = c.PreviousJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("PreviousJustifiedCheckpoint: %w", err) } - dst = append(dst, b.RandaoReveal...) - // Field (1) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(Eth1Data) + // Field 19: CurrentJustifiedCheckpoint + if c.CurrentJustifiedCheckpoint == nil { + c.CurrentJustifiedCheckpoint = new(Checkpoint) } - if dst, err = b.Eth1Data.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.CurrentJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("CurrentJustifiedCheckpoint: %w", err) } - // Field (2) 'Graffiti' - if size := len(b.Graffiti); size != 32 { - err = ssz.ErrBytesLengthFn("--.Graffiti", size, 32) - return + // Field 20: FinalizedCheckpoint + if c.FinalizedCheckpoint == nil { + c.FinalizedCheckpoint = new(Checkpoint) + } + if dst, err = c.FinalizedCheckpoint.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("FinalizedCheckpoint: %w", err) } - dst = append(dst, b.Graffiti...) - // Offset (3) 'ProposerSlashings' + // Field 21: InactivityScores dst = ssz.WriteOffset(dst, offset) - offset += len(b.ProposerSlashings) * 416 + offset += len(c.InactivityScores) * 8 - // Offset (4) 'AttesterSlashings' - dst = ssz.WriteOffset(dst, offset) - for ii := 0; ii < len(b.AttesterSlashings); ii++ { - offset += 4 - offset += b.AttesterSlashings[ii].SizeSSZ() + // Field 22: CurrentSyncCommittee + if c.CurrentSyncCommittee == nil { + c.CurrentSyncCommittee = new(SyncCommittee) } - - // Offset (5) 'Attestations' - dst = ssz.WriteOffset(dst, offset) - for ii := 0; ii < len(b.Attestations); ii++ { - offset += 4 - offset += b.Attestations[ii].SizeSSZ() + if dst, err = c.CurrentSyncCommittee.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("CurrentSyncCommittee: %w", err) } - // 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(SyncAggregate) + // Field 23: NextSyncCommittee + if c.NextSyncCommittee == nil { + c.NextSyncCommittee = new(SyncCommittee) } - if dst, err = b.SyncAggregate.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.NextSyncCommittee.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("NextSyncCommittee: %w", err) } - // Offset (9) 'ExecutionPayloadHeader' - dst = ssz.WriteOffset(dst, offset) - if b.ExecutionPayloadHeader == nil { - b.ExecutionPayloadHeader = new(v1.ExecutionPayloadHeader) + // Field 24: LatestExecutionPayloadHeader + if c.LatestExecutionPayloadHeader == nil { + c.LatestExecutionPayloadHeader = new(v1.ExecutionPayloadHeader) } - offset += b.ExecutionPayloadHeader.SizeSSZ() + dst = ssz.WriteOffset(dst, offset) + offset += c.LatestExecutionPayloadHeader.SizeSSZ() - // Field (3) 'ProposerSlashings' - if size := len(b.ProposerSlashings); size > 16 { - err = ssz.ErrListTooBigFn("--.ProposerSlashings", size, 16) - return + // Field 7: HistoricalRoots + if len(c.HistoricalRoots) > 16777216 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.ProposerSlashings); ii++ { - if dst, err = b.ProposerSlashings[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.HistoricalRoots { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, o...) } - // Field (4) 'AttesterSlashings' - if size := len(b.AttesterSlashings); size > 2 { - err = ssz.ErrListTooBigFn("--.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() - } + // Field 9: Eth1DataVotes + if len(c.Eth1DataVotes) > 32 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.AttesterSlashings); ii++ { - if dst, err = b.AttesterSlashings[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.Eth1DataVotes { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Eth1DataVotes: %w", err) } } - // Field (5) 'Attestations' - if size := len(b.Attestations); size > 128 { - err = ssz.ErrListTooBigFn("--.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() - } + // Field 11: Validators + if len(c.Validators) > 1099511627776 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.Attestations); ii++ { - if dst, err = b.Attestations[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.Validators { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Validators: %w", err) } } - // Field (6) 'Deposits' - if size := len(b.Deposits); size > 16 { - err = ssz.ErrListTooBigFn("--.Deposits", size, 16) - return + // Field 12: Balances + if len(c.Balances) > 1099511627776 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.Deposits); ii++ { - if dst, err = b.Deposits[ii].MarshalSSZTo(dst); err != nil { - return - } + for _, o := range c.Balances { + dst = binary.LittleEndian.AppendUint64(dst, o) } - // Field (7) 'VoluntaryExits' - if size := len(b.VoluntaryExits); size > 16 { - err = ssz.ErrListTooBigFn("--.VoluntaryExits", size, 16) - return + // Field 15: PreviousEpochParticipation + if len(c.PreviousEpochParticipation) > 1099511627776 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.VoluntaryExits); ii++ { - if dst, err = b.VoluntaryExits[ii].MarshalSSZTo(dst); err != nil { - return - } + dst = append(dst, c.PreviousEpochParticipation...) + + // Field 16: CurrentEpochParticipation + if len(c.CurrentEpochParticipation) > 1099511627776 { + return nil, ssz.ErrListTooBig } + dst = append(dst, c.CurrentEpochParticipation...) - // Field (9) 'ExecutionPayloadHeader' - if dst, err = b.ExecutionPayloadHeader.MarshalSSZTo(dst); err != nil { - return + // Field 21: InactivityScores + if len(c.InactivityScores) > 1099511627776 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.InactivityScores { + dst = binary.LittleEndian.AppendUint64(dst, o) } - return + // Field 24: LatestExecutionPayloadHeader + if dst, err = c.LatestExecutionPayloadHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("LatestExecutionPayloadHeader: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the BlindedBeaconBlockBodyBellatrix object -func (b *BlindedBeaconBlockBodyBellatrix) UnmarshalSSZ(buf []byte) error { +func (c *BeaconStateBellatrix) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 324 { + if size < 10233 { return ssz.ErrSize } - tail := buf - var o3, o4, o5, o6, o7, o9 uint64 - - // Field (0) 'RandaoReveal' - if cap(b.RandaoReveal) == 0 { - b.RandaoReveal = make([]byte, 0, len(buf[0:96])) + sszSlice0 := buf[0:8] // c.GenesisTime + sszSlice1 := buf[8:40] // c.GenesisValidatorsRoot + sszSlice2 := buf[40:48] // c.Slot + sszSlice3 := buf[48:64] // c.Fork + sszSlice4 := buf[64:176] // c.LatestBlockHeader + sszSlice5 := buf[176:2224] // c.BlockRoots + sszSlice6 := buf[2224:4272] // c.StateRoots + sszSlice8 := buf[4276:4348] // c.Eth1Data + sszSlice10 := buf[4352:4360] // c.Eth1DepositIndex + sszSlice13 := buf[4368:6416] // c.RandaoMixes + sszSlice14 := buf[6416:6928] // c.Slashings + sszSlice17 := buf[6936:6937] // c.JustificationBits + sszSlice18 := buf[6937:6977] // c.PreviousJustifiedCheckpoint + sszSlice19 := buf[6977:7017] // c.CurrentJustifiedCheckpoint + sszSlice20 := buf[7017:7057] // c.FinalizedCheckpoint + sszSlice22 := buf[7061:8645] // c.CurrentSyncCommittee + sszSlice23 := buf[8645:10229] // c.NextSyncCommittee + + sszVarOffset7 := ssz.ReadOffset(buf[4272:4276]) // c.HistoricalRoots + if sszVarOffset7 != 10233 { + return ssz.ErrInvalidVariableOffset } - b.RandaoReveal = append(b.RandaoReveal, buf[0:96]...) - - // Field (1) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(Eth1Data) + if sszVarOffset7 > size { + return ssz.ErrOffset } - if err = b.Eth1Data.UnmarshalSSZ(buf[96:168]); err != nil { - return err - } - - // Field (2) 'Graffiti' - if cap(b.Graffiti) == 0 { - b.Graffiti = make([]byte, 0, len(buf[168:200])) + sszVarOffset9 := ssz.ReadOffset(buf[4348:4352]) // c.Eth1DataVotes + if sszVarOffset9 > size || sszVarOffset9 < sszVarOffset7 { + return ssz.ErrOffset } - b.Graffiti = append(b.Graffiti, buf[168:200]...) - - // Offset (3) 'ProposerSlashings' - if o3 = ssz.ReadOffset(buf[200:204]); o3 > size { + sszVarOffset11 := ssz.ReadOffset(buf[4360:4364]) // c.Validators + if sszVarOffset11 > size || sszVarOffset11 < sszVarOffset9 { return ssz.ErrOffset } - - if o3 != 324 { - return ssz.ErrInvalidVariableOffset + sszVarOffset12 := ssz.ReadOffset(buf[4364:4368]) // c.Balances + if sszVarOffset12 > size || sszVarOffset12 < sszVarOffset11 { + return ssz.ErrOffset } - - // Offset (4) 'AttesterSlashings' - if o4 = ssz.ReadOffset(buf[204:208]); o4 > size || o3 > o4 { + sszVarOffset15 := ssz.ReadOffset(buf[6928:6932]) // c.PreviousEpochParticipation + if sszVarOffset15 > size || sszVarOffset15 < sszVarOffset12 { return ssz.ErrOffset } - - // Offset (5) 'Attestations' - if o5 = ssz.ReadOffset(buf[208:212]); o5 > size || o4 > o5 { + sszVarOffset16 := ssz.ReadOffset(buf[6932:6936]) // c.CurrentEpochParticipation + if sszVarOffset16 > size || sszVarOffset16 < sszVarOffset15 { return ssz.ErrOffset } - - // Offset (6) 'Deposits' - if o6 = ssz.ReadOffset(buf[212:216]); o6 > size || o5 > o6 { + sszVarOffset21 := ssz.ReadOffset(buf[7057:7061]) // c.InactivityScores + if sszVarOffset21 > size || sszVarOffset21 < sszVarOffset16 { return ssz.ErrOffset } - - // Offset (7) 'VoluntaryExits' - if o7 = ssz.ReadOffset(buf[216:220]); o7 > size || o6 > o7 { + sszVarOffset24 := ssz.ReadOffset(buf[10229:10233]) // c.LatestExecutionPayloadHeader + if sszVarOffset24 > size || sszVarOffset24 < sszVarOffset21 { return ssz.ErrOffset } + sszSlice7 := buf[sszVarOffset7:sszVarOffset9] // c.HistoricalRoots + sszSlice9 := buf[sszVarOffset9:sszVarOffset11] // c.Eth1DataVotes + sszSlice11 := buf[sszVarOffset11:sszVarOffset12] // c.Validators + sszSlice12 := buf[sszVarOffset12:sszVarOffset15] // c.Balances + sszSlice15 := buf[sszVarOffset15:sszVarOffset16] // c.PreviousEpochParticipation + sszSlice16 := buf[sszVarOffset16:sszVarOffset21] // c.CurrentEpochParticipation + sszSlice21 := buf[sszVarOffset21:sszVarOffset24] // c.InactivityScores + sszSlice24 := buf[sszVarOffset24:] // c.LatestExecutionPayloadHeader + + // Field 0: GenesisTime + c.GenesisTime = binary.LittleEndian.Uint64(sszSlice0) - // Field (8) 'SyncAggregate' - if b.SyncAggregate == nil { - b.SyncAggregate = new(SyncAggregate) + // Field 1: GenesisValidatorsRoot + c.GenesisValidatorsRoot = make([]byte, 0, 32) + c.GenesisValidatorsRoot = append(c.GenesisValidatorsRoot, sszSlice1...) + + // Field 2: Slot + if err = c.Slot.UnmarshalSSZ(sszSlice2); err != nil { + return fmt.Errorf("Slot: %w", err) } - if err = b.SyncAggregate.UnmarshalSSZ(buf[220:320]); err != nil { - return err + + // Field 3: Fork + c.Fork = new(Fork) + if err = c.Fork.UnmarshalSSZ(sszSlice3); err != nil { + return fmt.Errorf("Fork: %w", err) } - // Offset (9) 'ExecutionPayloadHeader' - if o9 = ssz.ReadOffset(buf[320:324]); o9 > size || o7 > o9 { - return ssz.ErrOffset + // Field 4: LatestBlockHeader + c.LatestBlockHeader = new(BeaconBlockHeader) + if err = c.LatestBlockHeader.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("LatestBlockHeader: %w", err) } - // Field (3) 'ProposerSlashings' + // Field 5: BlockRoots { - buf = tail[o3:o4] - num, err := ssz.DivideInt2(len(buf), 416, 16) - if err != nil { - return err - } - b.ProposerSlashings = make([]*ProposerSlashing, num) - for ii := 0; ii < num; ii++ { - if b.ProposerSlashings[ii] == nil { - b.ProposerSlashings[ii] = new(ProposerSlashing) - } - if err = b.ProposerSlashings[ii].UnmarshalSSZ(buf[ii*416 : (ii+1)*416]); err != nil { - return err - } + c.BlockRoots = make([][]byte, 64) + for i := 0; i < 64; i++ { + var tmp []byte + + tmpSlice := sszSlice5[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.BlockRoots[i] = tmp } } - // Field (4) 'AttesterSlashings' + // Field 6: StateRoots { - buf = tail[o4:o5] - num, err := ssz.DecodeDynamicLength(buf, 2) - 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 + c.StateRoots = make([][]byte, 64) + for i := 0; i < 64; i++ { + var tmp []byte + + tmpSlice := sszSlice6[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.StateRoots[i] = tmp } } - // Field (5) 'Attestations' + // Field 7: HistoricalRoots { - buf = tail[o5:o6] - num, err := ssz.DecodeDynamicLength(buf, 128) - 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 + if len(sszSlice7)%32 != 0 { + return fmt.Errorf("misaligned bytes: c.HistoricalRoots length is %d, which is not a multiple of 32: %w", len(sszSlice7), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice7) / 32 + if numElem > 16777216 { + return fmt.Errorf("ssz-max exceeded: c.HistoricalRoots has %d elements, ssz-max is 16777216: %w", numElem, ssz.ErrListTooBig) } + c.HistoricalRoots = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte + + tmpSlice := sszSlice7[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.HistoricalRoots[i] = tmp + } + } + + // Field 8: Eth1Data + c.Eth1Data = new(Eth1Data) + if err = c.Eth1Data.UnmarshalSSZ(sszSlice8); err != nil { + return fmt.Errorf("Eth1Data: %w", err) } - // Field (6) 'Deposits' + // Field 9: Eth1DataVotes { - buf = tail[o6:o7] - num, err := ssz.DivideInt2(len(buf), 1240, 16) - if err != nil { - return err - } - b.Deposits = make([]*Deposit, num) - for ii := 0; ii < num; ii++ { - if b.Deposits[ii] == nil { - b.Deposits[ii] = new(Deposit) - } - if err = b.Deposits[ii].UnmarshalSSZ(buf[ii*1240 : (ii+1)*1240]); err != nil { - return err + if len(sszSlice9)%72 != 0 { + return fmt.Errorf("misaligned bytes: c.Eth1DataVotes length is %d, which is not a multiple of 72: %w", len(sszSlice9), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice9) / 72 + if numElem > 32 { + return fmt.Errorf("ssz-max exceeded: c.Eth1DataVotes has %d elements, ssz-max is 32: %w", numElem, ssz.ErrListTooBig) + } + c.Eth1DataVotes = make([]*Eth1Data, numElem) + for i := 0; i < numElem; i++ { + var tmp *Eth1Data + tmp = new(Eth1Data) + tmpSlice := sszSlice9[i*72 : (1+i)*72] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Eth1DataVotes: %w", err) } + c.Eth1DataVotes[i] = tmp } } - // Field (7) 'VoluntaryExits' + // Field 10: Eth1DepositIndex + c.Eth1DepositIndex = binary.LittleEndian.Uint64(sszSlice10) + + // Field 11: Validators { - buf = tail[o7:o9] - num, err := ssz.DivideInt2(len(buf), 112, 16) - if err != nil { - return err - } - b.VoluntaryExits = make([]*SignedVoluntaryExit, num) - for ii := 0; ii < num; ii++ { - if b.VoluntaryExits[ii] == nil { - b.VoluntaryExits[ii] = new(SignedVoluntaryExit) - } - if err = b.VoluntaryExits[ii].UnmarshalSSZ(buf[ii*112 : (ii+1)*112]); err != nil { - return err + if len(sszSlice11)%121 != 0 { + return fmt.Errorf("misaligned bytes: c.Validators length is %d, which is not a multiple of 121: %w", len(sszSlice11), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice11) / 121 + if numElem > 1099511627776 { + return fmt.Errorf("ssz-max exceeded: c.Validators has %d elements, ssz-max is 1099511627776: %w", numElem, ssz.ErrListTooBig) + } + c.Validators = make([]*Validator, numElem) + for i := 0; i < numElem; i++ { + var tmp *Validator + tmp = new(Validator) + tmpSlice := sszSlice11[i*121 : (1+i)*121] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Validators: %w", err) } + c.Validators[i] = tmp } } - // Field (9) 'ExecutionPayloadHeader' + // Field 12: Balances { - buf = tail[o9:] - if b.ExecutionPayloadHeader == nil { - b.ExecutionPayloadHeader = new(v1.ExecutionPayloadHeader) + if len(sszSlice12)%8 != 0 { + return fmt.Errorf("misaligned bytes: c.Balances length is %d, which is not a multiple of 8: %w", len(sszSlice12), ssz.ErrIncorrectListSize) } - if err = b.ExecutionPayloadHeader.UnmarshalSSZ(buf); err != nil { - return err + numElem := len(sszSlice12) / 8 + if numElem > 1099511627776 { + return fmt.Errorf("ssz-max exceeded: c.Balances has %d elements, ssz-max is 1099511627776: %w", numElem, ssz.ErrListTooBig) } - } - return err -} + c.Balances = make([]uint64, numElem) + for i := 0; i < numElem; i++ { + var tmp uint64 -// SizeSSZ returns the ssz encoded size in bytes for the BlindedBeaconBlockBodyBellatrix object -func (b *BlindedBeaconBlockBodyBellatrix) SizeSSZ() (size int) { - size = 324 + tmpSlice := sszSlice12[i*8 : (1+i)*8] + tmp = binary.LittleEndian.Uint64(tmpSlice) + c.Balances[i] = tmp + } + } - // Field (3) 'ProposerSlashings' - size += len(b.ProposerSlashings) * 416 + // Field 13: RandaoMixes + { + c.RandaoMixes = make([][]byte, 64) + for i := 0; i < 64; i++ { + var tmp []byte - // Field (4) 'AttesterSlashings' - for ii := 0; ii < len(b.AttesterSlashings); ii++ { - size += 4 - size += b.AttesterSlashings[ii].SizeSSZ() + tmpSlice := sszSlice13[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.RandaoMixes[i] = tmp + } } - // Field (5) 'Attestations' - for ii := 0; ii < len(b.Attestations); ii++ { - size += 4 - size += b.Attestations[ii].SizeSSZ() + // Field 14: Slashings + { + c.Slashings = make([]uint64, 64) + for i := 0; i < 64; i++ { + var tmp uint64 + + tmpSlice := sszSlice14[i*8 : (1+i)*8] + tmp = binary.LittleEndian.Uint64(tmpSlice) + c.Slashings[i] = tmp + } } - // Field (6) 'Deposits' - size += len(b.Deposits) * 1240 + // Field 15: PreviousEpochParticipation + c.PreviousEpochParticipation = append([]byte{}, sszSlice15...) + + // Field 16: CurrentEpochParticipation + c.CurrentEpochParticipation = append([]byte{}, sszSlice16...) - // Field (7) 'VoluntaryExits' - size += len(b.VoluntaryExits) * 112 + // Field 17: JustificationBits + c.JustificationBits = make([]byte, 0, 1) + c.JustificationBits = append(c.JustificationBits, go_bitfield.Bitvector4(sszSlice17)...) - // Field (9) 'ExecutionPayloadHeader' - if b.ExecutionPayloadHeader == nil { - b.ExecutionPayloadHeader = new(v1.ExecutionPayloadHeader) + // Field 18: PreviousJustifiedCheckpoint + c.PreviousJustifiedCheckpoint = new(Checkpoint) + if err = c.PreviousJustifiedCheckpoint.UnmarshalSSZ(sszSlice18); err != nil { + return fmt.Errorf("PreviousJustifiedCheckpoint: %w", err) } - size += b.ExecutionPayloadHeader.SizeSSZ() - return -} + // Field 19: CurrentJustifiedCheckpoint + c.CurrentJustifiedCheckpoint = new(Checkpoint) + if err = c.CurrentJustifiedCheckpoint.UnmarshalSSZ(sszSlice19); err != nil { + return fmt.Errorf("CurrentJustifiedCheckpoint: %w", err) + } -// HashTreeRoot ssz hashes the BlindedBeaconBlockBodyBellatrix object -func (b *BlindedBeaconBlockBodyBellatrix) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) -} + // Field 20: FinalizedCheckpoint + c.FinalizedCheckpoint = new(Checkpoint) + if err = c.FinalizedCheckpoint.UnmarshalSSZ(sszSlice20); err != nil { + return fmt.Errorf("FinalizedCheckpoint: %w", err) + } -// HashTreeRootWith ssz hashes the BlindedBeaconBlockBodyBellatrix object with a hasher -func (b *BlindedBeaconBlockBodyBellatrix) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() + // Field 21: InactivityScores + { + if len(sszSlice21)%8 != 0 { + return fmt.Errorf("misaligned bytes: c.InactivityScores length is %d, which is not a multiple of 8: %w", len(sszSlice21), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice21) / 8 + if numElem > 1099511627776 { + return fmt.Errorf("ssz-max exceeded: c.InactivityScores has %d elements, ssz-max is 1099511627776: %w", numElem, ssz.ErrListTooBig) + } + c.InactivityScores = make([]uint64, numElem) + for i := 0; i < numElem; i++ { + var tmp uint64 + + tmpSlice := sszSlice21[i*8 : (1+i)*8] + tmp = binary.LittleEndian.Uint64(tmpSlice) + c.InactivityScores[i] = tmp + } + } - // Field (0) 'RandaoReveal' - if size := len(b.RandaoReveal); size != 96 { - err = ssz.ErrBytesLengthFn("--.RandaoReveal", size, 96) - return + // Field 22: CurrentSyncCommittee + c.CurrentSyncCommittee = new(SyncCommittee) + if err = c.CurrentSyncCommittee.UnmarshalSSZ(sszSlice22); err != nil { + return fmt.Errorf("CurrentSyncCommittee: %w", err) } - hh.PutBytes(b.RandaoReveal) - // Field (1) 'Eth1Data' - if err = b.Eth1Data.HashTreeRootWith(hh); err != nil { - return + // Field 23: NextSyncCommittee + c.NextSyncCommittee = new(SyncCommittee) + if err = c.NextSyncCommittee.UnmarshalSSZ(sszSlice23); err != nil { + return fmt.Errorf("NextSyncCommittee: %w", err) } - // Field (2) 'Graffiti' - if size := len(b.Graffiti); size != 32 { - err = ssz.ErrBytesLengthFn("--.Graffiti", size, 32) - return + // Field 24: LatestExecutionPayloadHeader + c.LatestExecutionPayloadHeader = new(v1.ExecutionPayloadHeader) + if err = c.LatestExecutionPayloadHeader.UnmarshalSSZ(sszSlice24); err != nil { + return fmt.Errorf("LatestExecutionPayloadHeader: %w", err) } - hh.PutBytes(b.Graffiti) + return err +} - // Field (3) 'ProposerSlashings' +func (c *BeaconStateBellatrix) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} + +func (c *BeaconStateBellatrix) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: GenesisTime + hh.PutUint64(c.GenesisTime) + // Field 1: GenesisValidatorsRoot + if len(c.GenesisValidatorsRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.GenesisValidatorsRoot) + // Field 2: Slot + if err := c.Slot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Slot: %w", err) + } + // Field 3: Fork + if err := c.Fork.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Fork: %w", err) + } + // Field 4: LatestBlockHeader + if err := c.LatestBlockHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("LatestBlockHeader: %w", err) + } + // Field 5: BlockRoots { + if len(c.BlockRoots) != 64 { + return ssz.ErrVectorLength + } 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 + for _, o := range c.BlockRoots { + if len(o) != 32 { + return ssz.ErrBytesLength } + hh.Append(o) } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.Merkleize(subIndx) } - - // Field (4) 'AttesterSlashings' + // Field 6: StateRoots { + if len(c.StateRoots) != 64 { + return ssz.ErrVectorLength + } 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 + for _, o := range c.StateRoots { + if len(o) != 32 { + return ssz.ErrBytesLength } + hh.Append(o) } - hh.MerkleizeWithMixin(subIndx, num, 2) + hh.Merkleize(subIndx) } - - // Field (5) 'Attestations' + // Field 7: HistoricalRoots { + if len(c.HistoricalRoots) > 16777216 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.HistoricalRoots { + if len(o) != 32 { + return ssz.ErrBytesLength } + hh.Append(o) } - hh.MerkleizeWithMixin(subIndx, num, 128) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.HistoricalRoots)), 16777216) } - - // Field (6) 'Deposits' + // Field 8: Eth1Data + if err := c.Eth1Data.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Eth1Data: %w", err) + } + // Field 9: Eth1DataVotes { + if len(c.Eth1DataVotes) > 32 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.Eth1DataVotes { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Eth1DataVotes: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Eth1DataVotes)), 32) } - - // Field (7) 'VoluntaryExits' + // Field 10: Eth1DepositIndex + hh.PutUint64(c.Eth1DepositIndex) + // Field 11: Validators { + if len(c.Validators) > 1099511627776 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.Validators { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Validators: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Validators)), 1099511627776) } - - // Field (8) 'SyncAggregate' - if err = b.SyncAggregate.HashTreeRootWith(hh); err != nil { - return + // Field 12: Balances + { + if len(c.Balances) > 1099511627776 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.Balances { + hh.AppendUint64(o) + } + hh.FillUpTo32() + numItems := uint64(len(c.Balances)) + hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(1099511627776, numItems, 8)) } - - // Field (9) 'ExecutionPayloadHeader' - if err = b.ExecutionPayloadHeader.HashTreeRootWith(hh); err != nil { - return + // Field 13: RandaoMixes + { + if len(c.RandaoMixes) != 64 { + return ssz.ErrVectorLength + } + subIndx := hh.Index() + for _, o := range c.RandaoMixes { + if len(o) != 32 { + return ssz.ErrBytesLength + } + hh.Append(o) + } + hh.Merkleize(subIndx) } + // Field 14: Slashings + { + if len(c.Slashings) != 64 { + return ssz.ErrVectorLength + } + subIndx := hh.Index() + for _, o := range c.Slashings { + hh.AppendUint64(o) + } + hh.Merkleize(subIndx) + } + // Field 15: PreviousEpochParticipation - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the BeaconStateBellatrix object -func (b *BeaconStateBellatrix) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} - -// MarshalSSZTo ssz marshals the BeaconStateBellatrix object to a target array -func (b *BeaconStateBellatrix) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(10233) - - // Field (0) 'GenesisTime' - dst = ssz.MarshalUint(dst, b.GenesisTime) - - // Field (1) 'GenesisValidatorsRoot' - if size := len(b.GenesisValidatorsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.GenesisValidatorsRoot", size, 32) - return + { + if len(c.PreviousEpochParticipation) > 1099511627776 { + return ssz.ErrBytesLength + } + subIndx := hh.Index() + hh.AppendBytes32(c.PreviousEpochParticipation) + numItems := uint64(len(c.PreviousEpochParticipation)) + hh.MerkleizeWithMixin(subIndx, numItems, (1099511627776*1+31)/32) } - dst = append(dst, b.GenesisValidatorsRoot...) - // Field (2) 'Slot' - dst = ssz.MarshalUint(dst, b.Slot) + // Field 16: CurrentEpochParticipation - // Field (3) 'Fork' - if b.Fork == nil { - b.Fork = new(Fork) - } - if dst, err = b.Fork.MarshalSSZTo(dst); err != nil { - return + { + if len(c.CurrentEpochParticipation) > 1099511627776 { + return ssz.ErrBytesLength + } + subIndx := hh.Index() + hh.AppendBytes32(c.CurrentEpochParticipation) + numItems := uint64(len(c.CurrentEpochParticipation)) + hh.MerkleizeWithMixin(subIndx, numItems, (1099511627776*1+31)/32) } - // Field (4) 'LatestBlockHeader' - if b.LatestBlockHeader == nil { - b.LatestBlockHeader = new(BeaconBlockHeader) + // Field 17: JustificationBits + if len([]byte(c.JustificationBits)) != 1 { + return ssz.ErrBytesLength } - if dst, err = b.LatestBlockHeader.MarshalSSZTo(dst); err != nil { - return + hh.PutBytes([]byte(c.JustificationBits)) + // Field 18: PreviousJustifiedCheckpoint + if err := c.PreviousJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("PreviousJustifiedCheckpoint: %w", err) } - - // Field (5) 'BlockRoots' - if size := len(b.BlockRoots); size != 64 { - err = ssz.ErrVectorLengthFn("--.BlockRoots", size, 64) - return + // Field 19: CurrentJustifiedCheckpoint + if err := c.CurrentJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("CurrentJustifiedCheckpoint: %w", err) } - for ii := 0; ii < 64; ii++ { - if size := len(b.BlockRoots[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockRoots[ii]", size, 32) - return - } - dst = append(dst, b.BlockRoots[ii]...) + // Field 20: FinalizedCheckpoint + if err := c.FinalizedCheckpoint.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("FinalizedCheckpoint: %w", err) } - - // Field (6) 'StateRoots' - if size := len(b.StateRoots); size != 64 { - err = ssz.ErrVectorLengthFn("--.StateRoots", size, 64) - return - } - for ii := 0; ii < 64; ii++ { - if size := len(b.StateRoots[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoots[ii]", size, 32) - return + // Field 21: InactivityScores + { + if len(c.InactivityScores) > 1099511627776 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.InactivityScores { + hh.AppendUint64(o) } - dst = append(dst, b.StateRoots[ii]...) + hh.FillUpTo32() + numItems := uint64(len(c.InactivityScores)) + hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(1099511627776, numItems, 8)) } - - // Offset (7) 'HistoricalRoots' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.HistoricalRoots) * 32 - - // Field (8) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(Eth1Data) + // Field 22: CurrentSyncCommittee + if err := c.CurrentSyncCommittee.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("CurrentSyncCommittee: %w", err) } - if dst, err = b.Eth1Data.MarshalSSZTo(dst); err != nil { - return + // Field 23: NextSyncCommittee + if err := c.NextSyncCommittee.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("NextSyncCommittee: %w", err) } + // Field 24: LatestExecutionPayloadHeader + if err := c.LatestExecutionPayloadHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("LatestExecutionPayloadHeader: %w", err) + } + hh.Merkleize(indx) + return nil +} - // Offset (9) 'Eth1DataVotes' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.Eth1DataVotes) * 72 - - // Field (10) 'Eth1DepositIndex' - dst = ssz.MarshalUint(dst, b.Eth1DepositIndex) +func (c *BlindedBeaconBlockBellatrix) SizeSSZ() int { + size := 84 + if c.Body == nil { + c.Body = new(BlindedBeaconBlockBodyBellatrix) + } + size += c.Body.SizeSSZ() + return size +} - // Offset (11) 'Validators' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.Validators) * 121 +func (c *BlindedBeaconBlockBellatrix) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Offset (12) 'Balances' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.Balances) * 8 +func (c *BlindedBeaconBlockBellatrix) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 84 - // Field (13) 'RandaoMixes' - if size := len(b.RandaoMixes); size != 64 { - err = ssz.ErrVectorLengthFn("--.RandaoMixes", size, 64) - return - } - for ii := 0; ii < 64; ii++ { - if size := len(b.RandaoMixes[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.RandaoMixes[ii]", size, 32) - return - } - dst = append(dst, b.RandaoMixes[ii]...) + // Field 0: Slot + if dst, err = c.Slot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Slot: %w", err) } - // Field (14) 'Slashings' - if size := len(b.Slashings); size != 64 { - err = ssz.ErrVectorLengthFn("--.Slashings", size, 64) - return + // Field 1: ProposerIndex + if dst, err = c.ProposerIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ProposerIndex: %w", err) } - for ii := 0; ii < 64; ii++ { - dst = ssz.MarshalUint(dst, b.Slashings[ii]) + + // Field 2: ParentRoot + if len(c.ParentRoot) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.ParentRoot...) - // Offset (15) 'PreviousEpochParticipation' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.PreviousEpochParticipation) + // Field 3: StateRoot + if len(c.StateRoot) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.StateRoot...) - // Offset (16) 'CurrentEpochParticipation' + // Field 4: Body + if c.Body == nil { + c.Body = new(BlindedBeaconBlockBodyBellatrix) + } dst = ssz.WriteOffset(dst, offset) - offset += len(b.CurrentEpochParticipation) + offset += c.Body.SizeSSZ() - // Field (17) 'JustificationBits' - if size := len(b.JustificationBits); size != 1 { - err = ssz.ErrBytesLengthFn("--.JustificationBits", size, 1) - return + // Field 4: Body + if dst, err = c.Body.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Body: %w", err) } - dst = append(dst, b.JustificationBits...) + return dst, err +} - // Field (18) 'PreviousJustifiedCheckpoint' - if b.PreviousJustifiedCheckpoint == nil { - b.PreviousJustifiedCheckpoint = new(Checkpoint) - } - if dst, err = b.PreviousJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { - return +func (c *BlindedBeaconBlockBellatrix) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 84 { + return ssz.ErrSize } - // Field (19) 'CurrentJustifiedCheckpoint' - if b.CurrentJustifiedCheckpoint == nil { - b.CurrentJustifiedCheckpoint = new(Checkpoint) + sszSlice0 := buf[0:8] // c.Slot + sszSlice1 := buf[8:16] // c.ProposerIndex + sszSlice2 := buf[16:48] // c.ParentRoot + sszSlice3 := buf[48:80] // c.StateRoot + + sszVarOffset4 := ssz.ReadOffset(buf[80:84]) // c.Body + if sszVarOffset4 != 84 { + return ssz.ErrInvalidVariableOffset } - if dst, err = b.CurrentJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { - return + if sszVarOffset4 > size { + return ssz.ErrOffset } + sszSlice4 := buf[sszVarOffset4:] // c.Body - // Field (20) 'FinalizedCheckpoint' - if b.FinalizedCheckpoint == nil { - b.FinalizedCheckpoint = new(Checkpoint) + // Field 0: Slot + if err = c.Slot.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Slot: %w", err) } - if dst, err = b.FinalizedCheckpoint.MarshalSSZTo(dst); err != nil { - return + + // Field 1: ProposerIndex + if err = c.ProposerIndex.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("ProposerIndex: %w", err) } - // Offset (21) 'InactivityScores' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.InactivityScores) * 8 + // Field 2: ParentRoot + c.ParentRoot = make([]byte, 0, 32) + c.ParentRoot = append(c.ParentRoot, sszSlice2...) - // Field (22) 'CurrentSyncCommittee' - if b.CurrentSyncCommittee == nil { - b.CurrentSyncCommittee = new(SyncCommittee) - } - if dst, err = b.CurrentSyncCommittee.MarshalSSZTo(dst); err != nil { - return - } + // Field 3: StateRoot + c.StateRoot = make([]byte, 0, 32) + c.StateRoot = append(c.StateRoot, sszSlice3...) - // Field (23) 'NextSyncCommittee' - if b.NextSyncCommittee == nil { - b.NextSyncCommittee = new(SyncCommittee) - } - if dst, err = b.NextSyncCommittee.MarshalSSZTo(dst); err != nil { - return + // Field 4: Body + c.Body = new(BlindedBeaconBlockBodyBellatrix) + if err = c.Body.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("Body: %w", err) } + return err +} - // Offset (24) 'LatestExecutionPayloadHeader' - dst = ssz.WriteOffset(dst, offset) - if b.LatestExecutionPayloadHeader == nil { - b.LatestExecutionPayloadHeader = new(v1.ExecutionPayloadHeader) +func (c *BlindedBeaconBlockBellatrix) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - offset += b.LatestExecutionPayloadHeader.SizeSSZ() + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (7) 'HistoricalRoots' - if size := len(b.HistoricalRoots); size > 16777216 { - err = ssz.ErrListTooBigFn("--.HistoricalRoots", size, 16777216) - return - } - for ii := 0; ii < len(b.HistoricalRoots); ii++ { - if size := len(b.HistoricalRoots[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.HistoricalRoots[ii]", size, 32) - return - } - dst = append(dst, b.HistoricalRoots[ii]...) +func (c *BlindedBeaconBlockBellatrix) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Slot + if err := c.Slot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Slot: %w", err) } - - // Field (9) 'Eth1DataVotes' - if size := len(b.Eth1DataVotes); size > 32 { - err = ssz.ErrListTooBigFn("--.Eth1DataVotes", size, 32) - return + // Field 1: ProposerIndex + if err := c.ProposerIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ProposerIndex: %w", err) } - for ii := 0; ii < len(b.Eth1DataVotes); ii++ { - if dst, err = b.Eth1DataVotes[ii].MarshalSSZTo(dst); err != nil { - return - } + // Field 2: ParentRoot + if len(c.ParentRoot) != 32 { + return ssz.ErrBytesLength } - - // Field (11) 'Validators' - if size := len(b.Validators); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.Validators", size, 1099511627776) - return + hh.PutBytes(c.ParentRoot) + // Field 3: StateRoot + if len(c.StateRoot) != 32 { + return ssz.ErrBytesLength } - for ii := 0; ii < len(b.Validators); ii++ { - if dst, err = b.Validators[ii].MarshalSSZTo(dst); err != nil { - return - } + hh.PutBytes(c.StateRoot) + // Field 4: Body + if err := c.Body.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Body: %w", err) } + hh.Merkleize(indx) + return nil +} - // Field (12) 'Balances' - if size := len(b.Balances); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.Balances", size, 1099511627776) - return +func (c *BlindedBeaconBlockBodyBellatrix) SizeSSZ() int { + size := 324 + size += len(c.ProposerSlashings) * 416 + for _, o := range c.AttesterSlashings { + size += 4 + size += o.SizeSSZ() } - for ii := 0; ii < len(b.Balances); ii++ { - dst = ssz.MarshalUint(dst, b.Balances[ii]) + for _, o := range c.Attestations { + size += 4 + size += o.SizeSSZ() } - - // Field (15) 'PreviousEpochParticipation' - if size := len(b.PreviousEpochParticipation); size > 1099511627776 { - err = ssz.ErrBytesLengthFn("--.PreviousEpochParticipation", size, 1099511627776) - return + size += len(c.Deposits) * 1240 + size += len(c.VoluntaryExits) * 112 + if c.ExecutionPayloadHeader == nil { + c.ExecutionPayloadHeader = new(v1.ExecutionPayloadHeader) } - dst = append(dst, b.PreviousEpochParticipation...) + size += c.ExecutionPayloadHeader.SizeSSZ() + return size +} + +func (c *BlindedBeaconBlockBodyBellatrix) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (16) 'CurrentEpochParticipation' - if size := len(b.CurrentEpochParticipation); size > 1099511627776 { - err = ssz.ErrBytesLengthFn("--.CurrentEpochParticipation", size, 1099511627776) - return +func (c *BlindedBeaconBlockBodyBellatrix) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 324 + + // Field 0: RandaoReveal + if len(c.RandaoReveal) != 96 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.CurrentEpochParticipation...) + dst = append(dst, c.RandaoReveal...) - // Field (21) 'InactivityScores' - if size := len(b.InactivityScores); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.InactivityScores", size, 1099511627776) - return + // Field 1: Eth1Data + if c.Eth1Data == nil { + c.Eth1Data = new(Eth1Data) } - for ii := 0; ii < len(b.InactivityScores); ii++ { - dst = ssz.MarshalUint(dst, b.InactivityScores[ii]) + if dst, err = c.Eth1Data.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Eth1Data: %w", err) } - // Field (24) 'LatestExecutionPayloadHeader' - if dst, err = b.LatestExecutionPayloadHeader.MarshalSSZTo(dst); err != nil { - return + // Field 2: Graffiti + if len(c.Graffiti) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.Graffiti...) - return -} + // Field 3: ProposerSlashings + dst = ssz.WriteOffset(dst, offset) + offset += len(c.ProposerSlashings) * 416 -// UnmarshalSSZ ssz unmarshals the BeaconStateBellatrix object -func (b *BeaconStateBellatrix) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 10233 { - return ssz.ErrSize + // Field 4: AttesterSlashings + dst = ssz.WriteOffset(dst, offset) + for _, o := range c.AttesterSlashings { + offset += 4 + offset += o.SizeSSZ() } - tail := buf - var o7, o9, o11, o12, o15, o16, o21, o24 uint64 - - // Field (0) 'GenesisTime' - b.GenesisTime = ssz.UnmarshallUint[uint64](buf[0:8]) - - // Field (1) 'GenesisValidatorsRoot' - if cap(b.GenesisValidatorsRoot) == 0 { - b.GenesisValidatorsRoot = make([]byte, 0, len(buf[8:40])) + // Field 5: Attestations + dst = ssz.WriteOffset(dst, offset) + for _, o := range c.Attestations { + offset += 4 + offset += o.SizeSSZ() } - b.GenesisValidatorsRoot = append(b.GenesisValidatorsRoot, buf[8:40]...) - // Field (2) 'Slot' - b.Slot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[40:48]) + // Field 6: Deposits + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Deposits) * 1240 + + // Field 7: VoluntaryExits + dst = ssz.WriteOffset(dst, offset) + offset += len(c.VoluntaryExits) * 112 - // Field (3) 'Fork' - if b.Fork == nil { - b.Fork = new(Fork) + // Field 8: SyncAggregate + if c.SyncAggregate == nil { + c.SyncAggregate = new(SyncAggregate) } - if err = b.Fork.UnmarshalSSZ(buf[48:64]); err != nil { - return err + if dst, err = c.SyncAggregate.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SyncAggregate: %w", err) } - // Field (4) 'LatestBlockHeader' - if b.LatestBlockHeader == nil { - b.LatestBlockHeader = new(BeaconBlockHeader) - } - if err = b.LatestBlockHeader.UnmarshalSSZ(buf[64:176]); err != nil { - return err + // Field 9: ExecutionPayloadHeader + if c.ExecutionPayloadHeader == nil { + c.ExecutionPayloadHeader = new(v1.ExecutionPayloadHeader) } + dst = ssz.WriteOffset(dst, offset) + offset += c.ExecutionPayloadHeader.SizeSSZ() - // Field (5) 'BlockRoots' - b.BlockRoots = make([][]byte, 64) - for ii := 0; ii < 64; ii++ { - if cap(b.BlockRoots[ii]) == 0 { - b.BlockRoots[ii] = make([]byte, 0, len(buf[176:2224][ii*32:(ii+1)*32])) + // Field 3: ProposerSlashings + if len(c.ProposerSlashings) > 16 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.ProposerSlashings { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ProposerSlashings: %w", err) } - b.BlockRoots[ii] = append(b.BlockRoots[ii], buf[176:2224][ii*32:(ii+1)*32]...) } - // Field (6) 'StateRoots' - b.StateRoots = make([][]byte, 64) - for ii := 0; ii < 64; ii++ { - if cap(b.StateRoots[ii]) == 0 { - b.StateRoots[ii] = make([]byte, 0, len(buf[2224:4272][ii*32:(ii+1)*32])) + // Field 4: AttesterSlashings + if len(c.AttesterSlashings) > 2 { + return nil, ssz.ErrListTooBig + } + { + offset = 4 * len(c.AttesterSlashings) + for _, o := range c.AttesterSlashings { + dst = ssz.WriteOffset(dst, offset) + offset += o.SizeSSZ() } - b.StateRoots[ii] = append(b.StateRoots[ii], buf[2224:4272][ii*32:(ii+1)*32]...) } - - // Offset (7) 'HistoricalRoots' - if o7 = ssz.ReadOffset(buf[4272:4276]); o7 > size { - return ssz.ErrOffset + for _, o := range c.AttesterSlashings { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("AttesterSlashings: %w", err) + } } - if o7 != 10233 { - return ssz.ErrInvalidVariableOffset + // Field 5: Attestations + if len(c.Attestations) > 128 { + return nil, ssz.ErrListTooBig } - - // Field (8) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(Eth1Data) + { + offset = 4 * len(c.Attestations) + for _, o := range c.Attestations { + dst = ssz.WriteOffset(dst, offset) + offset += o.SizeSSZ() + } } - if err = b.Eth1Data.UnmarshalSSZ(buf[4276:4348]); err != nil { - return err + for _, o := range c.Attestations { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Attestations: %w", err) + } } - // Offset (9) 'Eth1DataVotes' - if o9 = ssz.ReadOffset(buf[4348:4352]); o9 > size || o7 > o9 { - return ssz.ErrOffset + // Field 6: Deposits + if len(c.Deposits) > 16 { + return nil, ssz.ErrListTooBig } - - // Field (10) 'Eth1DepositIndex' - b.Eth1DepositIndex = ssz.UnmarshallUint[uint64](buf[4352:4360]) - - // Offset (11) 'Validators' - if o11 = ssz.ReadOffset(buf[4360:4364]); o11 > size || o9 > o11 { - return ssz.ErrOffset + for _, o := range c.Deposits { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Deposits: %w", err) + } } - // Offset (12) 'Balances' - if o12 = ssz.ReadOffset(buf[4364:4368]); o12 > size || o11 > o12 { - return ssz.ErrOffset + // Field 7: VoluntaryExits + if len(c.VoluntaryExits) > 16 { + return nil, ssz.ErrListTooBig } - - // Field (13) 'RandaoMixes' - b.RandaoMixes = make([][]byte, 64) - for ii := 0; ii < 64; ii++ { - if cap(b.RandaoMixes[ii]) == 0 { - b.RandaoMixes[ii] = make([]byte, 0, len(buf[4368:6416][ii*32:(ii+1)*32])) + for _, o := range c.VoluntaryExits { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("VoluntaryExits: %w", err) } - b.RandaoMixes[ii] = append(b.RandaoMixes[ii], buf[4368:6416][ii*32:(ii+1)*32]...) - } - - // Field (14) 'Slashings' - b.Slashings = ssz.ExtendUint(b.Slashings, 64) - for ii := 0; ii < 64; ii++ { - b.Slashings[ii] = ssz.UnmarshallUint[uint64](buf[6416:6928][ii*8 : (ii+1)*8]) } - // Offset (15) 'PreviousEpochParticipation' - if o15 = ssz.ReadOffset(buf[6928:6932]); o15 > size || o12 > o15 { - return ssz.ErrOffset + // Field 9: ExecutionPayloadHeader + if dst, err = c.ExecutionPayloadHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ExecutionPayloadHeader: %w", err) } + return dst, err +} - // Offset (16) 'CurrentEpochParticipation' - if o16 = ssz.ReadOffset(buf[6932:6936]); o16 > size || o15 > o16 { - return ssz.ErrOffset +func (c *BlindedBeaconBlockBodyBellatrix) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 324 { + return ssz.ErrSize } - // Field (17) 'JustificationBits' - if cap(b.JustificationBits) == 0 { - b.JustificationBits = make([]byte, 0, len(buf[6936:6937])) - } - b.JustificationBits = append(b.JustificationBits, buf[6936:6937]...) + sszSlice0 := buf[0:96] // c.RandaoReveal + sszSlice1 := buf[96:168] // c.Eth1Data + sszSlice2 := buf[168:200] // c.Graffiti + sszSlice8 := buf[220:320] // c.SyncAggregate - // Field (18) 'PreviousJustifiedCheckpoint' - if b.PreviousJustifiedCheckpoint == nil { - b.PreviousJustifiedCheckpoint = new(Checkpoint) + sszVarOffset3 := ssz.ReadOffset(buf[200:204]) // c.ProposerSlashings + if sszVarOffset3 != 324 { + return ssz.ErrInvalidVariableOffset } - if err = b.PreviousJustifiedCheckpoint.UnmarshalSSZ(buf[6937:6977]); err != nil { - return err + if sszVarOffset3 > size { + return ssz.ErrOffset } - - // Field (19) 'CurrentJustifiedCheckpoint' - if b.CurrentJustifiedCheckpoint == nil { - b.CurrentJustifiedCheckpoint = new(Checkpoint) + sszVarOffset4 := ssz.ReadOffset(buf[204:208]) // c.AttesterSlashings + if sszVarOffset4 > size || sszVarOffset4 < sszVarOffset3 { + return ssz.ErrOffset } - if err = b.CurrentJustifiedCheckpoint.UnmarshalSSZ(buf[6977:7017]); err != nil { - return err + sszVarOffset5 := ssz.ReadOffset(buf[208:212]) // c.Attestations + if sszVarOffset5 > size || sszVarOffset5 < sszVarOffset4 { + return ssz.ErrOffset } - - // Field (20) 'FinalizedCheckpoint' - if b.FinalizedCheckpoint == nil { - b.FinalizedCheckpoint = new(Checkpoint) + sszVarOffset6 := ssz.ReadOffset(buf[212:216]) // c.Deposits + if sszVarOffset6 > size || sszVarOffset6 < sszVarOffset5 { + return ssz.ErrOffset } - if err = b.FinalizedCheckpoint.UnmarshalSSZ(buf[7017:7057]); err != nil { - return err + sszVarOffset7 := ssz.ReadOffset(buf[216:220]) // c.VoluntaryExits + if sszVarOffset7 > size || sszVarOffset7 < sszVarOffset6 { + return ssz.ErrOffset } - - // Offset (21) 'InactivityScores' - if o21 = ssz.ReadOffset(buf[7057:7061]); o21 > size || o16 > o21 { + sszVarOffset9 := ssz.ReadOffset(buf[320:324]) // c.ExecutionPayloadHeader + if sszVarOffset9 > size || sszVarOffset9 < sszVarOffset7 { return ssz.ErrOffset } + sszSlice3 := buf[sszVarOffset3:sszVarOffset4] // c.ProposerSlashings + sszSlice4 := buf[sszVarOffset4:sszVarOffset5] // c.AttesterSlashings + sszSlice5 := buf[sszVarOffset5:sszVarOffset6] // c.Attestations + sszSlice6 := buf[sszVarOffset6:sszVarOffset7] // c.Deposits + sszSlice7 := buf[sszVarOffset7:sszVarOffset9] // c.VoluntaryExits + sszSlice9 := buf[sszVarOffset9:] // c.ExecutionPayloadHeader - // Field (22) 'CurrentSyncCommittee' - if b.CurrentSyncCommittee == nil { - b.CurrentSyncCommittee = new(SyncCommittee) - } - if err = b.CurrentSyncCommittee.UnmarshalSSZ(buf[7061:8645]); err != nil { - return err - } + // Field 0: RandaoReveal + c.RandaoReveal = make([]byte, 0, 96) + c.RandaoReveal = append(c.RandaoReveal, sszSlice0...) - // Field (23) 'NextSyncCommittee' - if b.NextSyncCommittee == nil { - b.NextSyncCommittee = new(SyncCommittee) - } - if err = b.NextSyncCommittee.UnmarshalSSZ(buf[8645:10229]); err != nil { - return err + // Field 1: Eth1Data + c.Eth1Data = new(Eth1Data) + if err = c.Eth1Data.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Eth1Data: %w", err) } - // Offset (24) 'LatestExecutionPayloadHeader' - if o24 = ssz.ReadOffset(buf[10229:10233]); o24 > size || o21 > o24 { - return ssz.ErrOffset - } + // Field 2: Graffiti + c.Graffiti = make([]byte, 0, 32) + c.Graffiti = append(c.Graffiti, sszSlice2...) - // Field (7) 'HistoricalRoots' + // Field 3: ProposerSlashings { - 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])) + if len(sszSlice3)%416 != 0 { + return fmt.Errorf("misaligned bytes: c.ProposerSlashings length is %d, which is not a multiple of 416: %w", len(sszSlice3), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice3) / 416 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.ProposerSlashings has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.ProposerSlashings = make([]*ProposerSlashing, numElem) + for i := 0; i < numElem; i++ { + var tmp *ProposerSlashing + tmp = new(ProposerSlashing) + tmpSlice := sszSlice3[i*416 : (1+i)*416] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("ProposerSlashings: %w", err) } - b.HistoricalRoots[ii] = append(b.HistoricalRoots[ii], buf[ii*32:(ii+1)*32]...) + c.ProposerSlashings[i] = tmp } } - // Field (9) 'Eth1DataVotes' + // Field 4: AttesterSlashings { - buf = tail[o9:o11] - num, err := ssz.DivideInt2(len(buf), 72, 32) - if err != nil { - return err - } - b.Eth1DataVotes = make([]*Eth1Data, num) - for ii := 0; ii < num; ii++ { - if b.Eth1DataVotes[ii] == nil { - b.Eth1DataVotes[ii] = new(Eth1Data) + // empty lists are zero length, so make sure there is room for an offset + // before attempting to unmarshal it + if len(sszSlice4) > 3 { + startOffset := ssz.ReadOffset(sszSlice4[0:4]) + if startOffset == 0 { + return fmt.Errorf("encountered invalid offset of 0 when decoding c.AttesterSlashings") } - if err = b.Eth1DataVotes[ii].UnmarshalSSZ(buf[ii*72 : (ii+1)*72]); err != nil { - return err + if startOffset%4 != 0 { + return fmt.Errorf("misaligned list bytes: when decoding c.AttesterSlashings, end-of-list offset is %d, which is not a multiple of 4 (offset size)", startOffset) } - } - } - - // Field (11) 'Validators' - { - buf = tail[o11:o12] - num, err := ssz.DivideInt2(len(buf), 121, 1099511627776) - if err != nil { - return err - } - b.Validators = make([]*Validator, num) - for ii := 0; ii < num; ii++ { - if b.Validators[ii] == nil { - b.Validators[ii] = new(Validator) + listLen := startOffset / 4 + if listLen > 2 { + return fmt.Errorf("ssz-max exceeded: c.AttesterSlashings has %d elements, ssz-max is 2: %w", listLen, ssz.ErrListTooBig) } - if err = b.Validators[ii].UnmarshalSSZ(buf[ii*121 : (ii+1)*121]); err != nil { - return err + totalVarBytes := uint64(len(sszSlice4)) + if totalVarBytes < startOffset { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.AttesterSlashings") } + c.AttesterSlashings = make([]*AttesterSlashing, listLen) + var tmpSlice []byte + for i := uint64(0); i < listLen; i++ { + var tmp *AttesterSlashing + tmp = new(AttesterSlashing) + endOffset := totalVarBytes + if i+1 != listLen { + endOffset = ssz.ReadOffset(sszSlice4[(i+1)*4 : (i+2)*4]) + if totalVarBytes < endOffset { + return fmt.Errorf("offset %d points past the end of buffer when decoding c.AttesterSlashings", endOffset) + } + } + if endOffset < startOffset { + return fmt.Errorf("offset %d is not greater than start offset %d when decoding c.AttesterSlashings", endOffset, startOffset) + } + tmpSlice = sszSlice4[startOffset:endOffset] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("AttesterSlashings: %w", err) + } + c.AttesterSlashings[i] = tmp + startOffset = endOffset + } + } else { + if len(sszSlice4) > 0 { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.AttesterSlashings") + } + c.AttesterSlashings = make([]*AttesterSlashing, 0) } } - // Field (12) 'Balances' + // Field 5: Attestations { - buf = tail[o12:o15] - num, err := ssz.DivideInt2(len(buf), 8, 1099511627776) - if err != nil { - return err - } - b.Balances = ssz.ExtendUint(b.Balances, num) - for ii := 0; ii < num; ii++ { - b.Balances[ii] = ssz.UnmarshallUint[uint64](buf[ii*8 : (ii+1)*8]) + // empty lists are zero length, so make sure there is room for an offset + // before attempting to unmarshal it + if len(sszSlice5) > 3 { + startOffset := ssz.ReadOffset(sszSlice5[0:4]) + if startOffset == 0 { + return fmt.Errorf("encountered invalid offset of 0 when decoding c.Attestations") + } + if startOffset%4 != 0 { + return fmt.Errorf("misaligned list bytes: when decoding c.Attestations, end-of-list offset is %d, which is not a multiple of 4 (offset size)", startOffset) + } + listLen := startOffset / 4 + if listLen > 128 { + return fmt.Errorf("ssz-max exceeded: c.Attestations has %d elements, ssz-max is 128: %w", listLen, ssz.ErrListTooBig) + } + totalVarBytes := uint64(len(sszSlice5)) + if totalVarBytes < startOffset { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.Attestations") + } + c.Attestations = make([]*Attestation, listLen) + var tmpSlice []byte + for i := uint64(0); i < listLen; i++ { + var tmp *Attestation + tmp = new(Attestation) + endOffset := totalVarBytes + if i+1 != listLen { + endOffset = ssz.ReadOffset(sszSlice5[(i+1)*4 : (i+2)*4]) + if totalVarBytes < endOffset { + return fmt.Errorf("offset %d points past the end of buffer when decoding c.Attestations", endOffset) + } + } + if endOffset < startOffset { + return fmt.Errorf("offset %d is not greater than start offset %d when decoding c.Attestations", endOffset, startOffset) + } + tmpSlice = sszSlice5[startOffset:endOffset] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Attestations: %w", err) + } + c.Attestations[i] = tmp + startOffset = endOffset + } + } else { + if len(sszSlice5) > 0 { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.Attestations") + } + c.Attestations = make([]*Attestation, 0) } } - // Field (15) 'PreviousEpochParticipation' + // Field 6: Deposits { - buf = tail[o15:o16] - if len(buf) > 1099511627776 { - return ssz.ErrBytesLength - } - if cap(b.PreviousEpochParticipation) == 0 { - b.PreviousEpochParticipation = make([]byte, 0, len(buf)) + if len(sszSlice6)%1240 != 0 { + return fmt.Errorf("misaligned bytes: c.Deposits length is %d, which is not a multiple of 1240: %w", len(sszSlice6), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice6) / 1240 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.Deposits has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.Deposits = make([]*Deposit, numElem) + for i := 0; i < numElem; i++ { + var tmp *Deposit + tmp = new(Deposit) + tmpSlice := sszSlice6[i*1240 : (1+i)*1240] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Deposits: %w", err) + } + c.Deposits[i] = tmp } - b.PreviousEpochParticipation = append(b.PreviousEpochParticipation, buf...) } - // Field (16) 'CurrentEpochParticipation' + // Field 7: VoluntaryExits { - buf = tail[o16:o21] - if len(buf) > 1099511627776 { - return ssz.ErrBytesLength - } - if cap(b.CurrentEpochParticipation) == 0 { - b.CurrentEpochParticipation = make([]byte, 0, len(buf)) + if len(sszSlice7)%112 != 0 { + return fmt.Errorf("misaligned bytes: c.VoluntaryExits length is %d, which is not a multiple of 112: %w", len(sszSlice7), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice7) / 112 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.VoluntaryExits has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.VoluntaryExits = make([]*SignedVoluntaryExit, numElem) + for i := 0; i < numElem; i++ { + var tmp *SignedVoluntaryExit + tmp = new(SignedVoluntaryExit) + tmpSlice := sszSlice7[i*112 : (1+i)*112] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("VoluntaryExits: %w", err) + } + c.VoluntaryExits[i] = tmp } - 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.ExtendUint(b.InactivityScores, num) - for ii := 0; ii < num; ii++ { - b.InactivityScores[ii] = ssz.UnmarshallUint[uint64](buf[ii*8 : (ii+1)*8]) - } + // Field 8: SyncAggregate + c.SyncAggregate = new(SyncAggregate) + if err = c.SyncAggregate.UnmarshalSSZ(sszSlice8); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) } - // Field (24) 'LatestExecutionPayloadHeader' - { - buf = tail[o24:] - if b.LatestExecutionPayloadHeader == nil { - b.LatestExecutionPayloadHeader = new(v1.ExecutionPayloadHeader) - } - if err = b.LatestExecutionPayloadHeader.UnmarshalSSZ(buf); err != nil { - return err - } + // Field 9: ExecutionPayloadHeader + c.ExecutionPayloadHeader = new(v1.ExecutionPayloadHeader) + if err = c.ExecutionPayloadHeader.UnmarshalSSZ(sszSlice9); err != nil { + return fmt.Errorf("ExecutionPayloadHeader: %w", err) } return err } -// SizeSSZ returns the ssz encoded size in bytes for the BeaconStateBellatrix object -func (b *BeaconStateBellatrix) SizeSSZ() (size int) { - size = 10233 - - // 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(v1.ExecutionPayloadHeader) +func (c *BlindedBeaconBlockBodyBellatrix) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - size += b.LatestExecutionPayloadHeader.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the BeaconStateBellatrix object -func (b *BeaconStateBellatrix) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the BeaconStateBellatrix object with a hasher -func (b *BeaconStateBellatrix) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *BlindedBeaconBlockBodyBellatrix) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'GenesisTime' - ssz.PutUint(hh, b.GenesisTime) - - // Field (1) 'GenesisValidatorsRoot' - if size := len(b.GenesisValidatorsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.GenesisValidatorsRoot", size, 32) - return + // Field 0: RandaoReveal + if len(c.RandaoReveal) != 96 { + return ssz.ErrBytesLength } - hh.PutBytes(b.GenesisValidatorsRoot) - - // Field (2) 'Slot' - ssz.PutUint(hh, b.Slot) - - // Field (3) 'Fork' - if err = b.Fork.HashTreeRootWith(hh); err != nil { - return + hh.PutBytes(c.RandaoReveal) + // Field 1: Eth1Data + if err := c.Eth1Data.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Eth1Data: %w", err) } - - // Field (4) 'LatestBlockHeader' - if err = b.LatestBlockHeader.HashTreeRootWith(hh); err != nil { - return + // Field 2: Graffiti + if len(c.Graffiti) != 32 { + return ssz.ErrBytesLength } - - // Field (5) 'BlockRoots' + hh.PutBytes(c.Graffiti) + // Field 3: ProposerSlashings { - if size := len(b.BlockRoots); size != 64 { - err = ssz.ErrVectorLengthFn("--.BlockRoots", size, 64) - return + if len(c.ProposerSlashings) > 16 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range b.BlockRoots { - if len(i) != 32 { - err = ssz.ErrBytesLength - return + for _, o := range c.ProposerSlashings { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ProposerSlashings: %w", err) } - hh.Append(i) } - hh.Merkleize(subIndx) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.ProposerSlashings)), 16) } - - // Field (6) 'StateRoots' + // Field 4: AttesterSlashings { - if size := len(b.StateRoots); size != 64 { - err = ssz.ErrVectorLengthFn("--.StateRoots", size, 64) - return + if len(c.AttesterSlashings) > 2 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range b.StateRoots { - if len(i) != 32 { - err = ssz.ErrBytesLength - return + for _, o := range c.AttesterSlashings { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("AttesterSlashings: %w", err) } - hh.Append(i) } - hh.Merkleize(subIndx) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.AttesterSlashings)), 2) } - - // Field (7) 'HistoricalRoots' + // Field 5: Attestations { - if size := len(b.HistoricalRoots); size > 16777216 { - err = ssz.ErrListTooBigFn("--.HistoricalRoots", size, 16777216) - return + if len(c.Attestations) > 128 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range b.HistoricalRoots { - if len(i) != 32 { - err = ssz.ErrBytesLength - return + for _, o := range c.Attestations { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Attestations: %w", err) } - hh.Append(i) } - - numItems := uint64(len(b.HistoricalRoots)) - hh.MerkleizeWithMixin(subIndx, numItems, 16777216) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Attestations)), 128) } - - // Field (8) 'Eth1Data' - if err = b.Eth1Data.HashTreeRootWith(hh); err != nil { - return - } - - // Field (9) 'Eth1DataVotes' + // Field 6: Deposits { + if len(c.Deposits) > 16 { + return ssz.ErrListTooBig + } subIndx := hh.Index() - num := uint64(len(b.Eth1DataVotes)) - if num > 32 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range b.Eth1DataVotes { - if err = elem.HashTreeRootWith(hh); err != nil { - return + for _, o := range c.Deposits { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Deposits: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 32) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Deposits)), 16) } - - // Field (10) 'Eth1DepositIndex' - ssz.PutUint(hh, b.Eth1DepositIndex) - - // Field (11) 'Validators' + // Field 7: VoluntaryExits { + if len(c.VoluntaryExits) > 16 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.VoluntaryExits { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("VoluntaryExits: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 1099511627776) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.VoluntaryExits)), 16) + } + // Field 8: SyncAggregate + if err := c.SyncAggregate.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) + } + // Field 9: ExecutionPayloadHeader + if err := c.ExecutionPayloadHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ExecutionPayloadHeader: %w", err) } + hh.Merkleize(indx) + return nil +} - // Field (12) 'Balances' - { - if size := len(b.Balances); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.Balances", size, 1099511627776) - return - } - subIndx := hh.Index() - for _, i := range b.Balances { - ssz.AppendUint(hh, i) - } - hh.FillUpTo32() +func (c *SignedBeaconBlockBellatrix) SizeSSZ() int { + size := 100 + if c.Block == nil { + c.Block = new(BeaconBlockBellatrix) + } + size += c.Block.SizeSSZ() + return size +} - numItems := uint64(len(b.Balances)) - hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(1099511627776, numItems, 8)) +func (c *SignedBeaconBlockBellatrix) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} + +func (c *SignedBeaconBlockBellatrix) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 100 + + // Field 0: Block + if c.Block == nil { + c.Block = new(BeaconBlockBellatrix) } + dst = ssz.WriteOffset(dst, offset) + offset += c.Block.SizeSSZ() - // Field (13) 'RandaoMixes' - { - if size := len(b.RandaoMixes); size != 64 { - err = ssz.ErrVectorLengthFn("--.RandaoMixes", size, 64) - return - } - subIndx := hh.Index() - for _, i := range b.RandaoMixes { - if len(i) != 32 { - err = ssz.ErrBytesLength - return - } - hh.Append(i) - } - hh.Merkleize(subIndx) + // Field 1: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.Signature...) - // Field (14) 'Slashings' - { - if size := len(b.Slashings); size != 64 { - err = ssz.ErrVectorLengthFn("--.Slashings", size, 64) - return - } - subIndx := hh.Index() - for _, i := range b.Slashings { - ssz.AppendUint(hh, i) - } - hh.Merkleize(subIndx) + // Field 0: Block + if dst, err = c.Block.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Block: %w", err) } + return dst, err +} - // Field (15) 'PreviousEpochParticipation' - { - elemIndx := hh.Index() - byteLen := uint64(len(b.PreviousEpochParticipation)) - if byteLen > 1099511627776 { - err = ssz.ErrIncorrectListSize - return - } - hh.AppendBytes32(b.PreviousEpochParticipation) - hh.MerkleizeWithMixin(elemIndx, byteLen, (1099511627776+31)/32) +func (c *SignedBeaconBlockBellatrix) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 100 { + return ssz.ErrSize } - // Field (16) 'CurrentEpochParticipation' - { - elemIndx := hh.Index() - byteLen := uint64(len(b.CurrentEpochParticipation)) - if byteLen > 1099511627776 { - err = ssz.ErrIncorrectListSize - return - } - hh.AppendBytes32(b.CurrentEpochParticipation) - hh.MerkleizeWithMixin(elemIndx, byteLen, (1099511627776+31)/32) + sszSlice1 := buf[4:100] // c.Signature + + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Block + if sszVarOffset0 != 100 { + return ssz.ErrInvalidVariableOffset } + if sszVarOffset0 > size { + return ssz.ErrOffset + } + sszSlice0 := buf[sszVarOffset0:] // c.Block - // Field (17) 'JustificationBits' - if size := len(b.JustificationBits); size != 1 { - err = ssz.ErrBytesLengthFn("--.JustificationBits", size, 1) - return + // Field 0: Block + c.Block = new(BeaconBlockBellatrix) + if err = c.Block.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Block: %w", err) } - hh.PutBytes(b.JustificationBits) - // Field (18) 'PreviousJustifiedCheckpoint' - if err = b.PreviousJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { - return + // Field 1: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice1...) + return err +} + +func (c *SignedBeaconBlockBellatrix) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (19) 'CurrentJustifiedCheckpoint' - if err = b.CurrentJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { - return +func (c *SignedBeaconBlockBellatrix) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Block + if err := c.Block.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Block: %w", err) + } + // Field 1: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength } + hh.PutBytes(c.Signature) + hh.Merkleize(indx) + return nil +} - // Field (20) 'FinalizedCheckpoint' - if err = b.FinalizedCheckpoint.HashTreeRootWith(hh); err != nil { - return +func (c *SignedBlindedBeaconBlockBellatrix) SizeSSZ() int { + size := 100 + if c.Block == nil { + c.Block = new(BlindedBeaconBlockBellatrix) } + size += c.Block.SizeSSZ() + return size +} - // Field (21) 'InactivityScores' - { - if size := len(b.InactivityScores); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.InactivityScores", size, 1099511627776) - return - } - subIndx := hh.Index() - for _, i := range b.InactivityScores { - ssz.AppendUint(hh, i) - } - hh.FillUpTo32() +func (c *SignedBlindedBeaconBlockBellatrix) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - numItems := uint64(len(b.InactivityScores)) - hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(1099511627776, numItems, 8)) +func (c *SignedBlindedBeaconBlockBellatrix) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 100 + + // Field 0: Block + if c.Block == nil { + c.Block = new(BlindedBeaconBlockBellatrix) } + dst = ssz.WriteOffset(dst, offset) + offset += c.Block.SizeSSZ() + + // Field 1: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.Signature...) - // Field (22) 'CurrentSyncCommittee' - if err = b.CurrentSyncCommittee.HashTreeRootWith(hh); err != nil { - return + // Field 0: Block + if dst, err = c.Block.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Block: %w", err) } + return dst, err +} - // Field (23) 'NextSyncCommittee' - if err = b.NextSyncCommittee.HashTreeRootWith(hh); err != nil { - return +func (c *SignedBlindedBeaconBlockBellatrix) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 100 { + return ssz.ErrSize } - // Field (24) 'LatestExecutionPayloadHeader' - if err = b.LatestExecutionPayloadHeader.HashTreeRootWith(hh); err != nil { - return + sszSlice1 := buf[4:100] // c.Signature + + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Block + if sszVarOffset0 != 100 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset0 > size { + return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:] // c.Block + // Field 0: Block + c.Block = new(BlindedBeaconBlockBellatrix) + if err = c.Block.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Block: %w", err) + } + + // Field 1: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice1...) + return err +} + +func (c *SignedBlindedBeaconBlockBellatrix) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} + +func (c *SignedBlindedBeaconBlockBellatrix) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Block + if err := c.Block.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Block: %w", err) + } + // Field 1: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Signature) hh.Merkleize(indx) - return + return nil } diff --git a/proto/prysm/v1alpha1/bellatrix.ssz.go b/proto/prysm/v1alpha1/bellatrix.ssz.go index a9951814f2cb..7edb38fc8e1a 100644 --- a/proto/prysm/v1alpha1/bellatrix.ssz.go +++ b/proto/prysm/v1alpha1/bellatrix.ssz.go @@ -1,2331 +1,2252 @@ //go:build !minimal -// Code generated by fastssz. DO NOT EDIT. package eth import ( - github_com_OffchainLabs_prysm_v7_consensus_types_primitives "github.com/OffchainLabs/prysm/v7/consensus-types/primitives" + binary "encoding/binary" + "fmt" + go_bitfield "github.com/OffchainLabs/go-bitfield" + ssz "github.com/OffchainLabs/methodical-ssz/ssz" v1 "github.com/OffchainLabs/prysm/v7/proto/engine/v1" - ssz "github.com/prysmaticlabs/fastssz" ) -// MarshalSSZ ssz marshals the SignedBeaconBlockBellatrix object -func (s *SignedBeaconBlockBellatrix) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) -} - -// MarshalSSZTo ssz marshals the SignedBeaconBlockBellatrix object to a target array -func (s *SignedBeaconBlockBellatrix) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(100) - - // Offset (0) 'Block' - dst = ssz.WriteOffset(dst, offset) - if s.Block == nil { - s.Block = new(BeaconBlockBellatrix) - } - offset += s.Block.SizeSSZ() - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return - } - dst = append(dst, s.Signature...) - - // Field (0) 'Block' - if dst, err = s.Block.MarshalSSZTo(dst); err != nil { - return +func (c *BeaconBlockBellatrix) SizeSSZ() int { + size := 84 + if c.Body == nil { + c.Body = new(BeaconBlockBodyBellatrix) } - - return + size += c.Body.SizeSSZ() + return size } -// UnmarshalSSZ ssz unmarshals the SignedBeaconBlockBellatrix object -func (s *SignedBeaconBlockBellatrix) 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(BeaconBlockBellatrix) - } - if err = s.Block.UnmarshalSSZ(buf); err != nil { - return err - } - } - return err +func (c *BeaconBlockBellatrix) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// SizeSSZ returns the ssz encoded size in bytes for the SignedBeaconBlockBellatrix object -func (s *SignedBeaconBlockBellatrix) SizeSSZ() (size int) { - size = 100 +func (c *BeaconBlockBellatrix) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 84 - // Field (0) 'Block' - if s.Block == nil { - s.Block = new(BeaconBlockBellatrix) + // Field 0: Slot + if dst, err = c.Slot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Slot: %w", err) } - size += s.Block.SizeSSZ() - - return -} -// HashTreeRoot ssz hashes the SignedBeaconBlockBellatrix object -func (s *SignedBeaconBlockBellatrix) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) -} - -// HashTreeRootWith ssz hashes the SignedBeaconBlockBellatrix object with a hasher -func (s *SignedBeaconBlockBellatrix) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'Block' - if err = s.Block.HashTreeRootWith(hh); err != nil { - return + // Field 1: ProposerIndex + if dst, err = c.ProposerIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ProposerIndex: %w", err) } - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 2: ParentRoot + if len(c.ParentRoot) != 32 { + return nil, ssz.ErrBytesLength } - hh.PutBytes(s.Signature) - - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the BeaconBlockBellatrix object -func (b *BeaconBlockBellatrix) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} - -// MarshalSSZTo ssz marshals the BeaconBlockBellatrix object to a target array -func (b *BeaconBlockBellatrix) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(84) - - // Field (0) 'Slot' - dst = ssz.MarshalUint(dst, b.Slot) - - // Field (1) 'ProposerIndex' - dst = ssz.MarshalUint(dst, b.ProposerIndex) + dst = append(dst, c.ParentRoot...) - // Field (2) 'ParentRoot' - if size := len(b.ParentRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentRoot", size, 32) - return + // Field 3: StateRoot + if len(c.StateRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.ParentRoot...) + dst = append(dst, c.StateRoot...) - // Field (3) 'StateRoot' - if size := len(b.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return + // Field 4: Body + if c.Body == nil { + c.Body = new(BeaconBlockBodyBellatrix) } - dst = append(dst, b.StateRoot...) - - // Offset (4) 'Body' dst = ssz.WriteOffset(dst, offset) - if b.Body == nil { - b.Body = new(BeaconBlockBodyBellatrix) - } - offset += b.Body.SizeSSZ() + offset += c.Body.SizeSSZ() - // Field (4) 'Body' - if dst, err = b.Body.MarshalSSZTo(dst); err != nil { - return + // Field 4: Body + if dst, err = c.Body.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Body: %w", err) } - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the BeaconBlockBellatrix object -func (b *BeaconBlockBellatrix) UnmarshalSSZ(buf []byte) error { +func (c *BeaconBlockBellatrix) 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.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[0:8]) + sszSlice0 := buf[0:8] // c.Slot + sszSlice1 := buf[8:16] // c.ProposerIndex + sszSlice2 := buf[16:48] // c.ParentRoot + sszSlice3 := buf[48:80] // c.StateRoot - // Field (1) 'ProposerIndex' - b.ProposerIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](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])) + sszVarOffset4 := ssz.ReadOffset(buf[80:84]) // c.Body + if sszVarOffset4 != 84 { + return ssz.ErrInvalidVariableOffset } - b.StateRoot = append(b.StateRoot, buf[48:80]...) - - // Offset (4) 'Body' - if o4 = ssz.ReadOffset(buf[80:84]); o4 > size { + if sszVarOffset4 > size { return ssz.ErrOffset } + sszSlice4 := buf[sszVarOffset4:] // c.Body - if o4 != 84 { - return ssz.ErrInvalidVariableOffset + // Field 0: Slot + if err = c.Slot.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Slot: %w", err) } - // Field (4) 'Body' - { - buf = tail[o4:] - if b.Body == nil { - b.Body = new(BeaconBlockBodyBellatrix) - } - if err = b.Body.UnmarshalSSZ(buf); err != nil { - return err - } + // Field 1: ProposerIndex + if err = c.ProposerIndex.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("ProposerIndex: %w", err) } - return err -} -// SizeSSZ returns the ssz encoded size in bytes for the BeaconBlockBellatrix object -func (b *BeaconBlockBellatrix) SizeSSZ() (size int) { - size = 84 + // Field 2: ParentRoot + c.ParentRoot = make([]byte, 0, 32) + c.ParentRoot = append(c.ParentRoot, sszSlice2...) - // Field (4) 'Body' - if b.Body == nil { - b.Body = new(BeaconBlockBodyBellatrix) - } - size += b.Body.SizeSSZ() + // Field 3: StateRoot + c.StateRoot = make([]byte, 0, 32) + c.StateRoot = append(c.StateRoot, sszSlice3...) - return + // Field 4: Body + c.Body = new(BeaconBlockBodyBellatrix) + if err = c.Body.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("Body: %w", err) + } + return err } -// HashTreeRoot ssz hashes the BeaconBlockBellatrix object -func (b *BeaconBlockBellatrix) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) +func (c *BeaconBlockBellatrix) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the BeaconBlockBellatrix object with a hasher -func (b *BeaconBlockBellatrix) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *BeaconBlockBellatrix) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Slot' - ssz.PutUint(hh, b.Slot) - - // Field (1) 'ProposerIndex' - ssz.PutUint(hh, b.ProposerIndex) - - // Field (2) 'ParentRoot' - if size := len(b.ParentRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentRoot", size, 32) - return + // Field 0: Slot + if err := c.Slot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Slot: %w", err) } - hh.PutBytes(b.ParentRoot) - - // Field (3) 'StateRoot' - if size := len(b.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return + // Field 1: ProposerIndex + if err := c.ProposerIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ProposerIndex: %w", err) } - hh.PutBytes(b.StateRoot) - - // Field (4) 'Body' - if err = b.Body.HashTreeRootWith(hh); err != nil { - return + // Field 2: ParentRoot + if len(c.ParentRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ParentRoot) + // Field 3: StateRoot + if len(c.StateRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.StateRoot) + // Field 4: Body + if err := c.Body.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Body: %w", err) } - hh.Merkleize(indx) - return + return nil +} + +func (c *BeaconBlockBodyBellatrix) SizeSSZ() int { + size := 384 + size += len(c.ProposerSlashings) * 416 + for _, o := range c.AttesterSlashings { + size += 4 + size += o.SizeSSZ() + } + for _, o := range c.Attestations { + size += 4 + size += o.SizeSSZ() + } + size += len(c.Deposits) * 1240 + size += len(c.VoluntaryExits) * 112 + if c.ExecutionPayload == nil { + c.ExecutionPayload = new(v1.ExecutionPayload) + } + size += c.ExecutionPayload.SizeSSZ() + return size } -// MarshalSSZ ssz marshals the BeaconBlockBodyBellatrix object -func (b *BeaconBlockBodyBellatrix) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) +func (c *BeaconBlockBodyBellatrix) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the BeaconBlockBodyBellatrix object to a target array -func (b *BeaconBlockBodyBellatrix) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(384) +func (c *BeaconBlockBodyBellatrix) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 384 - // Field (0) 'RandaoReveal' - if size := len(b.RandaoReveal); size != 96 { - err = ssz.ErrBytesLengthFn("--.RandaoReveal", size, 96) - return + // Field 0: RandaoReveal + if len(c.RandaoReveal) != 96 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.RandaoReveal...) + dst = append(dst, c.RandaoReveal...) - // Field (1) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(Eth1Data) + // Field 1: Eth1Data + if c.Eth1Data == nil { + c.Eth1Data = new(Eth1Data) } - if dst, err = b.Eth1Data.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.Eth1Data.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Eth1Data: %w", err) } - // Field (2) 'Graffiti' - if size := len(b.Graffiti); size != 32 { - err = ssz.ErrBytesLengthFn("--.Graffiti", size, 32) - return + // Field 2: Graffiti + if len(c.Graffiti) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.Graffiti...) + dst = append(dst, c.Graffiti...) - // Offset (3) 'ProposerSlashings' + // Field 3: ProposerSlashings dst = ssz.WriteOffset(dst, offset) - offset += len(b.ProposerSlashings) * 416 + offset += len(c.ProposerSlashings) * 416 - // Offset (4) 'AttesterSlashings' + // Field 4: AttesterSlashings dst = ssz.WriteOffset(dst, offset) - for ii := 0; ii < len(b.AttesterSlashings); ii++ { + for _, o := range c.AttesterSlashings { offset += 4 - offset += b.AttesterSlashings[ii].SizeSSZ() + offset += o.SizeSSZ() } - // Offset (5) 'Attestations' + // Field 5: Attestations dst = ssz.WriteOffset(dst, offset) - for ii := 0; ii < len(b.Attestations); ii++ { + for _, o := range c.Attestations { offset += 4 - offset += b.Attestations[ii].SizeSSZ() + offset += o.SizeSSZ() } - // Offset (6) 'Deposits' + // Field 6: Deposits dst = ssz.WriteOffset(dst, offset) - offset += len(b.Deposits) * 1240 + offset += len(c.Deposits) * 1240 - // Offset (7) 'VoluntaryExits' + // Field 7: VoluntaryExits dst = ssz.WriteOffset(dst, offset) - offset += len(b.VoluntaryExits) * 112 + offset += len(c.VoluntaryExits) * 112 - // Field (8) 'SyncAggregate' - if b.SyncAggregate == nil { - b.SyncAggregate = new(SyncAggregate) + // Field 8: SyncAggregate + if c.SyncAggregate == nil { + c.SyncAggregate = new(SyncAggregate) } - if dst, err = b.SyncAggregate.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.SyncAggregate.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SyncAggregate: %w", err) } - // Offset (9) 'ExecutionPayload' - dst = ssz.WriteOffset(dst, offset) - if b.ExecutionPayload == nil { - b.ExecutionPayload = new(v1.ExecutionPayload) + // Field 9: ExecutionPayload + if c.ExecutionPayload == nil { + c.ExecutionPayload = new(v1.ExecutionPayload) } - offset += b.ExecutionPayload.SizeSSZ() + dst = ssz.WriteOffset(dst, offset) + offset += c.ExecutionPayload.SizeSSZ() - // Field (3) 'ProposerSlashings' - if size := len(b.ProposerSlashings); size > 16 { - err = ssz.ErrListTooBigFn("--.ProposerSlashings", size, 16) - return + // Field 3: ProposerSlashings + if len(c.ProposerSlashings) > 16 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.ProposerSlashings); ii++ { - if dst, err = b.ProposerSlashings[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.ProposerSlashings { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ProposerSlashings: %w", err) } } - // Field (4) 'AttesterSlashings' - if size := len(b.AttesterSlashings); size > 2 { - err = ssz.ErrListTooBigFn("--.AttesterSlashings", size, 2) - return + // Field 4: AttesterSlashings + if len(c.AttesterSlashings) > 2 { + return nil, ssz.ErrListTooBig } { - offset = 4 * len(b.AttesterSlashings) - for ii := 0; ii < len(b.AttesterSlashings); ii++ { + offset = 4 * len(c.AttesterSlashings) + for _, o := range c.AttesterSlashings { dst = ssz.WriteOffset(dst, offset) - offset += b.AttesterSlashings[ii].SizeSSZ() + offset += o.SizeSSZ() } } - for ii := 0; ii < len(b.AttesterSlashings); ii++ { - if dst, err = b.AttesterSlashings[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.AttesterSlashings { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("AttesterSlashings: %w", err) } } - // Field (5) 'Attestations' - if size := len(b.Attestations); size > 128 { - err = ssz.ErrListTooBigFn("--.Attestations", size, 128) - return + // Field 5: Attestations + if len(c.Attestations) > 128 { + return nil, ssz.ErrListTooBig } { - offset = 4 * len(b.Attestations) - for ii := 0; ii < len(b.Attestations); ii++ { + offset = 4 * len(c.Attestations) + for _, o := range c.Attestations { dst = ssz.WriteOffset(dst, offset) - offset += b.Attestations[ii].SizeSSZ() + offset += o.SizeSSZ() } } - for ii := 0; ii < len(b.Attestations); ii++ { - if dst, err = b.Attestations[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.Attestations { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Attestations: %w", err) } } - // Field (6) 'Deposits' - if size := len(b.Deposits); size > 16 { - err = ssz.ErrListTooBigFn("--.Deposits", size, 16) - return + // Field 6: Deposits + if len(c.Deposits) > 16 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.Deposits); ii++ { - if dst, err = b.Deposits[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.Deposits { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Deposits: %w", err) } } - // Field (7) 'VoluntaryExits' - if size := len(b.VoluntaryExits); size > 16 { - err = ssz.ErrListTooBigFn("--.VoluntaryExits", size, 16) - return + // Field 7: VoluntaryExits + if len(c.VoluntaryExits) > 16 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.VoluntaryExits); ii++ { - if dst, err = b.VoluntaryExits[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.VoluntaryExits { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("VoluntaryExits: %w", err) } } - // Field (9) 'ExecutionPayload' - if dst, err = b.ExecutionPayload.MarshalSSZTo(dst); err != nil { - return + // Field 9: ExecutionPayload + if dst, err = c.ExecutionPayload.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ExecutionPayload: %w", err) } - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the BeaconBlockBodyBellatrix object -func (b *BeaconBlockBodyBellatrix) UnmarshalSSZ(buf []byte) error { +func (c *BeaconBlockBodyBellatrix) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size < 384 { return ssz.ErrSize } - tail := buf - var o3, o4, o5, o6, o7, o9 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(Eth1Data) - } - if err = b.Eth1Data.UnmarshalSSZ(buf[96:168]); err != nil { - return err - } + sszSlice0 := buf[0:96] // c.RandaoReveal + sszSlice1 := buf[96:168] // c.Eth1Data + sszSlice2 := buf[168:200] // c.Graffiti + sszSlice8 := buf[220:380] // c.SyncAggregate - // Field (2) 'Graffiti' - if cap(b.Graffiti) == 0 { - b.Graffiti = make([]byte, 0, len(buf[168:200])) + sszVarOffset3 := ssz.ReadOffset(buf[200:204]) // c.ProposerSlashings + if sszVarOffset3 != 384 { + return ssz.ErrInvalidVariableOffset } - b.Graffiti = append(b.Graffiti, buf[168:200]...) - - // Offset (3) 'ProposerSlashings' - if o3 = ssz.ReadOffset(buf[200:204]); o3 > size { + if sszVarOffset3 > size { return ssz.ErrOffset } - - if o3 != 384 { - return ssz.ErrInvalidVariableOffset + sszVarOffset4 := ssz.ReadOffset(buf[204:208]) // c.AttesterSlashings + if sszVarOffset4 > size || sszVarOffset4 < sszVarOffset3 { + return ssz.ErrOffset } - - // Offset (4) 'AttesterSlashings' - if o4 = ssz.ReadOffset(buf[204:208]); o4 > size || o3 > o4 { + sszVarOffset5 := ssz.ReadOffset(buf[208:212]) // c.Attestations + if sszVarOffset5 > size || sszVarOffset5 < sszVarOffset4 { return ssz.ErrOffset } - - // Offset (5) 'Attestations' - if o5 = ssz.ReadOffset(buf[208:212]); o5 > size || o4 > o5 { + sszVarOffset6 := ssz.ReadOffset(buf[212:216]) // c.Deposits + if sszVarOffset6 > size || sszVarOffset6 < sszVarOffset5 { return ssz.ErrOffset } - - // Offset (6) 'Deposits' - if o6 = ssz.ReadOffset(buf[212:216]); o6 > size || o5 > o6 { + sszVarOffset7 := ssz.ReadOffset(buf[216:220]) // c.VoluntaryExits + if sszVarOffset7 > size || sszVarOffset7 < sszVarOffset6 { return ssz.ErrOffset } - - // Offset (7) 'VoluntaryExits' - if o7 = ssz.ReadOffset(buf[216:220]); o7 > size || o6 > o7 { + sszVarOffset9 := ssz.ReadOffset(buf[380:384]) // c.ExecutionPayload + if sszVarOffset9 > size || sszVarOffset9 < sszVarOffset7 { return ssz.ErrOffset } + sszSlice3 := buf[sszVarOffset3:sszVarOffset4] // c.ProposerSlashings + sszSlice4 := buf[sszVarOffset4:sszVarOffset5] // c.AttesterSlashings + sszSlice5 := buf[sszVarOffset5:sszVarOffset6] // c.Attestations + sszSlice6 := buf[sszVarOffset6:sszVarOffset7] // c.Deposits + sszSlice7 := buf[sszVarOffset7:sszVarOffset9] // c.VoluntaryExits + sszSlice9 := buf[sszVarOffset9:] // c.ExecutionPayload - // Field (8) 'SyncAggregate' - if b.SyncAggregate == nil { - b.SyncAggregate = new(SyncAggregate) - } - if err = b.SyncAggregate.UnmarshalSSZ(buf[220:380]); err != nil { - return err - } + // Field 0: RandaoReveal + c.RandaoReveal = make([]byte, 0, 96) + c.RandaoReveal = append(c.RandaoReveal, sszSlice0...) - // Offset (9) 'ExecutionPayload' - if o9 = ssz.ReadOffset(buf[380:384]); o9 > size || o7 > o9 { - return ssz.ErrOffset + // Field 1: Eth1Data + c.Eth1Data = new(Eth1Data) + if err = c.Eth1Data.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Eth1Data: %w", err) } - // Field (3) 'ProposerSlashings' + // Field 2: Graffiti + c.Graffiti = make([]byte, 0, 32) + c.Graffiti = append(c.Graffiti, sszSlice2...) + + // Field 3: ProposerSlashings { - buf = tail[o3:o4] - num, err := ssz.DivideInt2(len(buf), 416, 16) - if err != nil { - return err - } - b.ProposerSlashings = make([]*ProposerSlashing, num) - for ii := 0; ii < num; ii++ { - if b.ProposerSlashings[ii] == nil { - b.ProposerSlashings[ii] = new(ProposerSlashing) - } - if err = b.ProposerSlashings[ii].UnmarshalSSZ(buf[ii*416 : (ii+1)*416]); err != nil { - return err + if len(sszSlice3)%416 != 0 { + return fmt.Errorf("misaligned bytes: c.ProposerSlashings length is %d, which is not a multiple of 416: %w", len(sszSlice3), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice3) / 416 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.ProposerSlashings has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.ProposerSlashings = make([]*ProposerSlashing, numElem) + for i := 0; i < numElem; i++ { + var tmp *ProposerSlashing + tmp = new(ProposerSlashing) + tmpSlice := sszSlice3[i*416 : (1+i)*416] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("ProposerSlashings: %w", err) } + c.ProposerSlashings[i] = tmp } } - // Field (4) 'AttesterSlashings' + // Field 4: AttesterSlashings { - buf = tail[o4:o5] - num, err := ssz.DecodeDynamicLength(buf, 2) - 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) + // empty lists are zero length, so make sure there is room for an offset + // before attempting to unmarshal it + if len(sszSlice4) > 3 { + startOffset := ssz.ReadOffset(sszSlice4[0:4]) + if startOffset == 0 { + return fmt.Errorf("encountered invalid offset of 0 when decoding c.AttesterSlashings") } - if err = b.AttesterSlashings[indx].UnmarshalSSZ(buf); err != nil { - return err + if startOffset%4 != 0 { + return fmt.Errorf("misaligned list bytes: when decoding c.AttesterSlashings, end-of-list offset is %d, which is not a multiple of 4 (offset size)", startOffset) } - 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([]*Attestation, num) - err = ssz.UnmarshalDynamic(buf, num, func(indx int, buf []byte) (err error) { - if b.Attestations[indx] == nil { - b.Attestations[indx] = new(Attestation) + listLen := startOffset / 4 + if listLen > 2 { + return fmt.Errorf("ssz-max exceeded: c.AttesterSlashings has %d elements, ssz-max is 2: %w", listLen, ssz.ErrListTooBig) + } + totalVarBytes := uint64(len(sszSlice4)) + if totalVarBytes < startOffset { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.AttesterSlashings") } - if err = b.Attestations[indx].UnmarshalSSZ(buf); err != nil { - return err + c.AttesterSlashings = make([]*AttesterSlashing, listLen) + var tmpSlice []byte + for i := uint64(0); i < listLen; i++ { + var tmp *AttesterSlashing + tmp = new(AttesterSlashing) + endOffset := totalVarBytes + if i+1 != listLen { + endOffset = ssz.ReadOffset(sszSlice4[(i+1)*4 : (i+2)*4]) + if totalVarBytes < endOffset { + return fmt.Errorf("offset %d points past the end of buffer when decoding c.AttesterSlashings", endOffset) + } + } + if endOffset < startOffset { + return fmt.Errorf("offset %d is not greater than start offset %d when decoding c.AttesterSlashings", endOffset, startOffset) + } + tmpSlice = sszSlice4[startOffset:endOffset] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("AttesterSlashings: %w", err) + } + c.AttesterSlashings[i] = tmp + startOffset = endOffset } - return nil - }) - if err != nil { - return err + } else { + if len(sszSlice4) > 0 { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.AttesterSlashings") + } + c.AttesterSlashings = make([]*AttesterSlashing, 0) } } - // Field (6) 'Deposits' + // Field 5: Attestations { - buf = tail[o6:o7] - num, err := ssz.DivideInt2(len(buf), 1240, 16) - if err != nil { - return err - } - b.Deposits = make([]*Deposit, num) - for ii := 0; ii < num; ii++ { - if b.Deposits[ii] == nil { - b.Deposits[ii] = new(Deposit) + // empty lists are zero length, so make sure there is room for an offset + // before attempting to unmarshal it + if len(sszSlice5) > 3 { + startOffset := ssz.ReadOffset(sszSlice5[0:4]) + if startOffset == 0 { + return fmt.Errorf("encountered invalid offset of 0 when decoding c.Attestations") + } + if startOffset%4 != 0 { + return fmt.Errorf("misaligned list bytes: when decoding c.Attestations, end-of-list offset is %d, which is not a multiple of 4 (offset size)", startOffset) } - if err = b.Deposits[ii].UnmarshalSSZ(buf[ii*1240 : (ii+1)*1240]); err != nil { - return err + listLen := startOffset / 4 + if listLen > 128 { + return fmt.Errorf("ssz-max exceeded: c.Attestations has %d elements, ssz-max is 128: %w", listLen, ssz.ErrListTooBig) } + totalVarBytes := uint64(len(sszSlice5)) + if totalVarBytes < startOffset { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.Attestations") + } + c.Attestations = make([]*Attestation, listLen) + var tmpSlice []byte + for i := uint64(0); i < listLen; i++ { + var tmp *Attestation + tmp = new(Attestation) + endOffset := totalVarBytes + if i+1 != listLen { + endOffset = ssz.ReadOffset(sszSlice5[(i+1)*4 : (i+2)*4]) + if totalVarBytes < endOffset { + return fmt.Errorf("offset %d points past the end of buffer when decoding c.Attestations", endOffset) + } + } + if endOffset < startOffset { + return fmt.Errorf("offset %d is not greater than start offset %d when decoding c.Attestations", endOffset, startOffset) + } + tmpSlice = sszSlice5[startOffset:endOffset] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Attestations: %w", err) + } + c.Attestations[i] = tmp + startOffset = endOffset + } + } else { + if len(sszSlice5) > 0 { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.Attestations") + } + c.Attestations = make([]*Attestation, 0) } } - // Field (7) 'VoluntaryExits' + // Field 6: Deposits { - buf = tail[o7:o9] - num, err := ssz.DivideInt2(len(buf), 112, 16) - if err != nil { - return err - } - b.VoluntaryExits = make([]*SignedVoluntaryExit, num) - for ii := 0; ii < num; ii++ { - if b.VoluntaryExits[ii] == nil { - b.VoluntaryExits[ii] = new(SignedVoluntaryExit) - } - if err = b.VoluntaryExits[ii].UnmarshalSSZ(buf[ii*112 : (ii+1)*112]); err != nil { - return err + if len(sszSlice6)%1240 != 0 { + return fmt.Errorf("misaligned bytes: c.Deposits length is %d, which is not a multiple of 1240: %w", len(sszSlice6), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice6) / 1240 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.Deposits has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.Deposits = make([]*Deposit, numElem) + for i := 0; i < numElem; i++ { + var tmp *Deposit + tmp = new(Deposit) + tmpSlice := sszSlice6[i*1240 : (1+i)*1240] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Deposits: %w", err) } + c.Deposits[i] = tmp } } - // Field (9) 'ExecutionPayload' + // Field 7: VoluntaryExits { - buf = tail[o9:] - if b.ExecutionPayload == nil { - b.ExecutionPayload = new(v1.ExecutionPayload) - } - if err = b.ExecutionPayload.UnmarshalSSZ(buf); err != nil { - return err + if len(sszSlice7)%112 != 0 { + return fmt.Errorf("misaligned bytes: c.VoluntaryExits length is %d, which is not a multiple of 112: %w", len(sszSlice7), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice7) / 112 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.VoluntaryExits has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.VoluntaryExits = make([]*SignedVoluntaryExit, numElem) + for i := 0; i < numElem; i++ { + var tmp *SignedVoluntaryExit + tmp = new(SignedVoluntaryExit) + tmpSlice := sszSlice7[i*112 : (1+i)*112] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("VoluntaryExits: %w", err) + } + c.VoluntaryExits[i] = tmp } } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the BeaconBlockBodyBellatrix object -func (b *BeaconBlockBodyBellatrix) SizeSSZ() (size int) { - size = 384 - - // 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 8: SyncAggregate + c.SyncAggregate = new(SyncAggregate) + if err = c.SyncAggregate.UnmarshalSSZ(sszSlice8); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) } - // 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(v1.ExecutionPayload) + // Field 9: ExecutionPayload + c.ExecutionPayload = new(v1.ExecutionPayload) + if err = c.ExecutionPayload.UnmarshalSSZ(sszSlice9); err != nil { + return fmt.Errorf("ExecutionPayload: %w", err) } - size += b.ExecutionPayload.SizeSSZ() - - return + return err } -// HashTreeRoot ssz hashes the BeaconBlockBodyBellatrix object -func (b *BeaconBlockBodyBellatrix) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) +func (c *BeaconBlockBodyBellatrix) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the BeaconBlockBodyBellatrix object with a hasher -func (b *BeaconBlockBodyBellatrix) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *BeaconBlockBodyBellatrix) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'RandaoReveal' - if size := len(b.RandaoReveal); size != 96 { - err = ssz.ErrBytesLengthFn("--.RandaoReveal", size, 96) - return + // Field 0: RandaoReveal + if len(c.RandaoReveal) != 96 { + return ssz.ErrBytesLength } - hh.PutBytes(b.RandaoReveal) - - // Field (1) 'Eth1Data' - if err = b.Eth1Data.HashTreeRootWith(hh); err != nil { - return + hh.PutBytes(c.RandaoReveal) + // Field 1: Eth1Data + if err := c.Eth1Data.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Eth1Data: %w", err) } - - // Field (2) 'Graffiti' - if size := len(b.Graffiti); size != 32 { - err = ssz.ErrBytesLengthFn("--.Graffiti", size, 32) - return + // Field 2: Graffiti + if len(c.Graffiti) != 32 { + return ssz.ErrBytesLength } - hh.PutBytes(b.Graffiti) - - // Field (3) 'ProposerSlashings' + hh.PutBytes(c.Graffiti) + // Field 3: ProposerSlashings { + if len(c.ProposerSlashings) > 16 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.ProposerSlashings { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ProposerSlashings: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.ProposerSlashings)), 16) } - - // Field (4) 'AttesterSlashings' + // Field 4: AttesterSlashings { + if len(c.AttesterSlashings) > 2 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.AttesterSlashings { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("AttesterSlashings: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 2) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.AttesterSlashings)), 2) } - - // Field (5) 'Attestations' + // Field 5: Attestations { + if len(c.Attestations) > 128 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.Attestations { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Attestations: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 128) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Attestations)), 128) } - - // Field (6) 'Deposits' + // Field 6: Deposits { + if len(c.Deposits) > 16 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.Deposits { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Deposits: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Deposits)), 16) } - - // Field (7) 'VoluntaryExits' + // Field 7: VoluntaryExits { + if len(c.VoluntaryExits) > 16 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.VoluntaryExits { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("VoluntaryExits: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.VoluntaryExits)), 16) } - - // Field (8) 'SyncAggregate' - if err = b.SyncAggregate.HashTreeRootWith(hh); err != nil { - return + // Field 8: SyncAggregate + if err := c.SyncAggregate.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) } - - // Field (9) 'ExecutionPayload' - if err = b.ExecutionPayload.HashTreeRootWith(hh); err != nil { - return + // Field 9: ExecutionPayload + if err := c.ExecutionPayload.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ExecutionPayload: %w", err) } - hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the SignedBlindedBeaconBlockBellatrix object -func (s *SignedBlindedBeaconBlockBellatrix) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) +func (c *BeaconStateBellatrix) SizeSSZ() int { + size := 2736633 + size += len(c.HistoricalRoots) * 32 + size += len(c.Eth1DataVotes) * 72 + size += len(c.Validators) * 121 + size += len(c.Balances) * 8 + size += len(c.PreviousEpochParticipation) + size += len(c.CurrentEpochParticipation) + size += len(c.InactivityScores) * 8 + if c.LatestExecutionPayloadHeader == nil { + c.LatestExecutionPayloadHeader = new(v1.ExecutionPayloadHeader) + } + size += c.LatestExecutionPayloadHeader.SizeSSZ() + return size } -// MarshalSSZTo ssz marshals the SignedBlindedBeaconBlockBellatrix object to a target array -func (s *SignedBlindedBeaconBlockBellatrix) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(100) - - // Offset (0) 'Block' - dst = ssz.WriteOffset(dst, offset) - if s.Block == nil { - s.Block = new(BlindedBeaconBlockBellatrix) - } - offset += s.Block.SizeSSZ() - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return - } - dst = append(dst, s.Signature...) - - // Field (0) 'Block' - if dst, err = s.Block.MarshalSSZTo(dst); err != nil { - return - } - - return +func (c *BeaconStateBellatrix) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// UnmarshalSSZ ssz unmarshals the SignedBlindedBeaconBlockBellatrix object -func (s *SignedBlindedBeaconBlockBellatrix) UnmarshalSSZ(buf []byte) error { +func (c *BeaconStateBellatrix) MarshalSSZTo(dst []byte) ([]byte, error) { var err error - size := uint64(len(buf)) - if size < 100 { - return ssz.ErrSize - } + offset := 2736633 - tail := buf - var o0 uint64 + // Field 0: GenesisTime + dst = binary.LittleEndian.AppendUint64(dst, c.GenesisTime) - // Offset (0) 'Block' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset + // Field 1: GenesisValidatorsRoot + if len(c.GenesisValidatorsRoot) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.GenesisValidatorsRoot...) - if o0 != 100 { - return ssz.ErrInvalidVariableOffset + // Field 2: Slot + if dst, err = c.Slot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Slot: %w", err) } - // Field (1) 'Signature' - if cap(s.Signature) == 0 { - s.Signature = make([]byte, 0, len(buf[4:100])) + // Field 3: Fork + if c.Fork == nil { + c.Fork = new(Fork) } - s.Signature = append(s.Signature, buf[4:100]...) - - // Field (0) 'Block' - { - buf = tail[o0:] - if s.Block == nil { - s.Block = new(BlindedBeaconBlockBellatrix) - } - if err = s.Block.UnmarshalSSZ(buf); err != nil { - return err - } + if dst, err = c.Fork.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Fork: %w", err) } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the SignedBlindedBeaconBlockBellatrix object -func (s *SignedBlindedBeaconBlockBellatrix) SizeSSZ() (size int) { - size = 100 - // Field (0) 'Block' - if s.Block == nil { - s.Block = new(BlindedBeaconBlockBellatrix) + // Field 4: LatestBlockHeader + if c.LatestBlockHeader == nil { + c.LatestBlockHeader = new(BeaconBlockHeader) } - size += s.Block.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the SignedBlindedBeaconBlockBellatrix object -func (s *SignedBlindedBeaconBlockBellatrix) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) -} - -// HashTreeRootWith ssz hashes the SignedBlindedBeaconBlockBellatrix object with a hasher -func (s *SignedBlindedBeaconBlockBellatrix) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'Block' - if err = s.Block.HashTreeRootWith(hh); err != nil { - return + if dst, err = c.LatestBlockHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("LatestBlockHeader: %w", err) } - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 5: BlockRoots + if len(c.BlockRoots) != 8192 { + return nil, ssz.ErrBytesLength } - hh.PutBytes(s.Signature) - - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the BlindedBeaconBlockBellatrix object -func (b *BlindedBeaconBlockBellatrix) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} - -// MarshalSSZTo ssz marshals the BlindedBeaconBlockBellatrix object to a target array -func (b *BlindedBeaconBlockBellatrix) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(84) - - // Field (0) 'Slot' - dst = ssz.MarshalUint(dst, b.Slot) - - // Field (1) 'ProposerIndex' - dst = ssz.MarshalUint(dst, b.ProposerIndex) - - // Field (2) 'ParentRoot' - if size := len(b.ParentRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentRoot", size, 32) - return + for _, o := range c.BlockRoots { + if len(o) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) } - dst = append(dst, b.ParentRoot...) - // Field (3) 'StateRoot' - if size := len(b.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return + // Field 6: StateRoots + if len(c.StateRoots) != 8192 { + return nil, ssz.ErrBytesLength + } + for _, o := range c.StateRoots { + if len(o) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) } - dst = append(dst, b.StateRoot...) - // Offset (4) 'Body' + // Field 7: HistoricalRoots dst = ssz.WriteOffset(dst, offset) - if b.Body == nil { - b.Body = new(BlindedBeaconBlockBodyBellatrix) - } - offset += b.Body.SizeSSZ() + offset += len(c.HistoricalRoots) * 32 - // Field (4) 'Body' - if dst, err = b.Body.MarshalSSZTo(dst); err != nil { - return + // Field 8: Eth1Data + if c.Eth1Data == nil { + c.Eth1Data = new(Eth1Data) } - - return -} - -// UnmarshalSSZ ssz unmarshals the BlindedBeaconBlockBellatrix object -func (b *BlindedBeaconBlockBellatrix) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 84 { - return ssz.ErrSize + if dst, err = c.Eth1Data.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Eth1Data: %w", err) } - tail := buf - var o4 uint64 - - // Field (0) 'Slot' - b.Slot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[0:8]) - - // Field (1) 'ProposerIndex' - b.ProposerIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[8:16]) + // Field 9: Eth1DataVotes + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Eth1DataVotes) * 72 - // 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 10: Eth1DepositIndex + dst = binary.LittleEndian.AppendUint64(dst, c.Eth1DepositIndex) - // 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 11: Validators + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Validators) * 121 - // Offset (4) 'Body' - if o4 = ssz.ReadOffset(buf[80:84]); o4 > size { - return ssz.ErrOffset - } + // Field 12: Balances + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Balances) * 8 - if o4 != 84 { - return ssz.ErrInvalidVariableOffset + // Field 13: RandaoMixes + if len(c.RandaoMixes) != 65536 { + return nil, ssz.ErrBytesLength } - - // Field (4) 'Body' - { - buf = tail[o4:] - if b.Body == nil { - b.Body = new(BlindedBeaconBlockBodyBellatrix) - } - if err = b.Body.UnmarshalSSZ(buf); err != nil { - return err + for _, o := range c.RandaoMixes { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, o...) } - return err -} -// SizeSSZ returns the ssz encoded size in bytes for the BlindedBeaconBlockBellatrix object -func (b *BlindedBeaconBlockBellatrix) SizeSSZ() (size int) { - size = 84 - - // Field (4) 'Body' - if b.Body == nil { - b.Body = new(BlindedBeaconBlockBodyBellatrix) + // Field 14: Slashings + if len(c.Slashings) != 8192 { + return nil, ssz.ErrBytesLength + } + for _, o := range c.Slashings { + dst = binary.LittleEndian.AppendUint64(dst, o) } - size += b.Body.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the BlindedBeaconBlockBellatrix object -func (b *BlindedBeaconBlockBellatrix) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) -} - -// HashTreeRootWith ssz hashes the BlindedBeaconBlockBellatrix object with a hasher -func (b *BlindedBeaconBlockBellatrix) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'Slot' - ssz.PutUint(hh, b.Slot) - // Field (1) 'ProposerIndex' - ssz.PutUint(hh, b.ProposerIndex) + // Field 15: PreviousEpochParticipation + dst = ssz.WriteOffset(dst, offset) + offset += len(c.PreviousEpochParticipation) - // Field (2) 'ParentRoot' - if size := len(b.ParentRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentRoot", size, 32) - return - } - hh.PutBytes(b.ParentRoot) + // Field 16: CurrentEpochParticipation + dst = ssz.WriteOffset(dst, offset) + offset += len(c.CurrentEpochParticipation) - // Field (3) 'StateRoot' - if size := len(b.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return + // Field 17: JustificationBits + if len([]byte(c.JustificationBits)) != 1 { + return nil, ssz.ErrBytesLength } - hh.PutBytes(b.StateRoot) + dst = append(dst, []byte(c.JustificationBits)...) - // Field (4) 'Body' - if err = b.Body.HashTreeRootWith(hh); err != nil { - return + // Field 18: PreviousJustifiedCheckpoint + if c.PreviousJustifiedCheckpoint == nil { + c.PreviousJustifiedCheckpoint = new(Checkpoint) } - - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the BlindedBeaconBlockBodyBellatrix object -func (b *BlindedBeaconBlockBodyBellatrix) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} - -// MarshalSSZTo ssz marshals the BlindedBeaconBlockBodyBellatrix object to a target array -func (b *BlindedBeaconBlockBodyBellatrix) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(384) - - // Field (0) 'RandaoReveal' - if size := len(b.RandaoReveal); size != 96 { - err = ssz.ErrBytesLengthFn("--.RandaoReveal", size, 96) - return + if dst, err = c.PreviousJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("PreviousJustifiedCheckpoint: %w", err) } - dst = append(dst, b.RandaoReveal...) - // Field (1) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(Eth1Data) + // Field 19: CurrentJustifiedCheckpoint + if c.CurrentJustifiedCheckpoint == nil { + c.CurrentJustifiedCheckpoint = new(Checkpoint) } - if dst, err = b.Eth1Data.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.CurrentJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("CurrentJustifiedCheckpoint: %w", err) } - // Field (2) 'Graffiti' - if size := len(b.Graffiti); size != 32 { - err = ssz.ErrBytesLengthFn("--.Graffiti", size, 32) - return + // Field 20: FinalizedCheckpoint + if c.FinalizedCheckpoint == nil { + c.FinalizedCheckpoint = new(Checkpoint) + } + if dst, err = c.FinalizedCheckpoint.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("FinalizedCheckpoint: %w", err) } - dst = append(dst, b.Graffiti...) - // Offset (3) 'ProposerSlashings' + // Field 21: InactivityScores dst = ssz.WriteOffset(dst, offset) - offset += len(b.ProposerSlashings) * 416 + offset += len(c.InactivityScores) * 8 - // Offset (4) 'AttesterSlashings' - dst = ssz.WriteOffset(dst, offset) - for ii := 0; ii < len(b.AttesterSlashings); ii++ { - offset += 4 - offset += b.AttesterSlashings[ii].SizeSSZ() + // Field 22: CurrentSyncCommittee + if c.CurrentSyncCommittee == nil { + c.CurrentSyncCommittee = new(SyncCommittee) } - - // Offset (5) 'Attestations' - dst = ssz.WriteOffset(dst, offset) - for ii := 0; ii < len(b.Attestations); ii++ { - offset += 4 - offset += b.Attestations[ii].SizeSSZ() + if dst, err = c.CurrentSyncCommittee.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("CurrentSyncCommittee: %w", err) } - // 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(SyncAggregate) + // Field 23: NextSyncCommittee + if c.NextSyncCommittee == nil { + c.NextSyncCommittee = new(SyncCommittee) } - if dst, err = b.SyncAggregate.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.NextSyncCommittee.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("NextSyncCommittee: %w", err) } - // Offset (9) 'ExecutionPayloadHeader' - dst = ssz.WriteOffset(dst, offset) - if b.ExecutionPayloadHeader == nil { - b.ExecutionPayloadHeader = new(v1.ExecutionPayloadHeader) + // Field 24: LatestExecutionPayloadHeader + if c.LatestExecutionPayloadHeader == nil { + c.LatestExecutionPayloadHeader = new(v1.ExecutionPayloadHeader) } - offset += b.ExecutionPayloadHeader.SizeSSZ() + dst = ssz.WriteOffset(dst, offset) + offset += c.LatestExecutionPayloadHeader.SizeSSZ() - // Field (3) 'ProposerSlashings' - if size := len(b.ProposerSlashings); size > 16 { - err = ssz.ErrListTooBigFn("--.ProposerSlashings", size, 16) - return + // Field 7: HistoricalRoots + if len(c.HistoricalRoots) > 16777216 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.ProposerSlashings); ii++ { - if dst, err = b.ProposerSlashings[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.HistoricalRoots { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, o...) } - // Field (4) 'AttesterSlashings' - if size := len(b.AttesterSlashings); size > 2 { - err = ssz.ErrListTooBigFn("--.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() - } + // Field 9: Eth1DataVotes + if len(c.Eth1DataVotes) > 2048 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.AttesterSlashings); ii++ { - if dst, err = b.AttesterSlashings[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.Eth1DataVotes { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Eth1DataVotes: %w", err) } } - // Field (5) 'Attestations' - if size := len(b.Attestations); size > 128 { - err = ssz.ErrListTooBigFn("--.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() - } + // Field 11: Validators + if len(c.Validators) > 1099511627776 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.Attestations); ii++ { - if dst, err = b.Attestations[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.Validators { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Validators: %w", err) } } - // Field (6) 'Deposits' - if size := len(b.Deposits); size > 16 { - err = ssz.ErrListTooBigFn("--.Deposits", size, 16) - return + // Field 12: Balances + if len(c.Balances) > 1099511627776 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.Deposits); ii++ { - if dst, err = b.Deposits[ii].MarshalSSZTo(dst); err != nil { - return - } + for _, o := range c.Balances { + dst = binary.LittleEndian.AppendUint64(dst, o) } - // Field (7) 'VoluntaryExits' - if size := len(b.VoluntaryExits); size > 16 { - err = ssz.ErrListTooBigFn("--.VoluntaryExits", size, 16) - return + // Field 15: PreviousEpochParticipation + if len(c.PreviousEpochParticipation) > 1099511627776 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.VoluntaryExits); ii++ { - if dst, err = b.VoluntaryExits[ii].MarshalSSZTo(dst); err != nil { - return - } + dst = append(dst, c.PreviousEpochParticipation...) + + // Field 16: CurrentEpochParticipation + if len(c.CurrentEpochParticipation) > 1099511627776 { + return nil, ssz.ErrListTooBig } + dst = append(dst, c.CurrentEpochParticipation...) - // Field (9) 'ExecutionPayloadHeader' - if dst, err = b.ExecutionPayloadHeader.MarshalSSZTo(dst); err != nil { - return + // Field 21: InactivityScores + if len(c.InactivityScores) > 1099511627776 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.InactivityScores { + dst = binary.LittleEndian.AppendUint64(dst, o) } - return + // Field 24: LatestExecutionPayloadHeader + if dst, err = c.LatestExecutionPayloadHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("LatestExecutionPayloadHeader: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the BlindedBeaconBlockBodyBellatrix object -func (b *BlindedBeaconBlockBodyBellatrix) UnmarshalSSZ(buf []byte) error { +func (c *BeaconStateBellatrix) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 384 { + if size < 2736633 { return ssz.ErrSize } - tail := buf - var o3, o4, o5, o6, o7, o9 uint64 - - // Field (0) 'RandaoReveal' - if cap(b.RandaoReveal) == 0 { - b.RandaoReveal = make([]byte, 0, len(buf[0:96])) + sszSlice0 := buf[0:8] // c.GenesisTime + sszSlice1 := buf[8:40] // c.GenesisValidatorsRoot + sszSlice2 := buf[40:48] // c.Slot + sszSlice3 := buf[48:64] // c.Fork + sszSlice4 := buf[64:176] // c.LatestBlockHeader + sszSlice5 := buf[176:262320] // c.BlockRoots + sszSlice6 := buf[262320:524464] // c.StateRoots + sszSlice8 := buf[524468:524540] // c.Eth1Data + sszSlice10 := buf[524544:524552] // c.Eth1DepositIndex + sszSlice13 := buf[524560:2621712] // c.RandaoMixes + sszSlice14 := buf[2621712:2687248] // c.Slashings + sszSlice17 := buf[2687256:2687257] // c.JustificationBits + sszSlice18 := buf[2687257:2687297] // c.PreviousJustifiedCheckpoint + sszSlice19 := buf[2687297:2687337] // c.CurrentJustifiedCheckpoint + sszSlice20 := buf[2687337:2687377] // c.FinalizedCheckpoint + sszSlice22 := buf[2687381:2712005] // c.CurrentSyncCommittee + sszSlice23 := buf[2712005:2736629] // c.NextSyncCommittee + + sszVarOffset7 := ssz.ReadOffset(buf[524464:524468]) // c.HistoricalRoots + if sszVarOffset7 != 2736633 { + return ssz.ErrInvalidVariableOffset } - b.RandaoReveal = append(b.RandaoReveal, buf[0:96]...) - - // Field (1) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(Eth1Data) + if sszVarOffset7 > size { + return ssz.ErrOffset } - if err = b.Eth1Data.UnmarshalSSZ(buf[96:168]); err != nil { - return err - } - - // Field (2) 'Graffiti' - if cap(b.Graffiti) == 0 { - b.Graffiti = make([]byte, 0, len(buf[168:200])) + sszVarOffset9 := ssz.ReadOffset(buf[524540:524544]) // c.Eth1DataVotes + if sszVarOffset9 > size || sszVarOffset9 < sszVarOffset7 { + return ssz.ErrOffset } - b.Graffiti = append(b.Graffiti, buf[168:200]...) - - // Offset (3) 'ProposerSlashings' - if o3 = ssz.ReadOffset(buf[200:204]); o3 > size { + sszVarOffset11 := ssz.ReadOffset(buf[524552:524556]) // c.Validators + if sszVarOffset11 > size || sszVarOffset11 < sszVarOffset9 { return ssz.ErrOffset } - - if o3 != 384 { - return ssz.ErrInvalidVariableOffset + sszVarOffset12 := ssz.ReadOffset(buf[524556:524560]) // c.Balances + if sszVarOffset12 > size || sszVarOffset12 < sszVarOffset11 { + return ssz.ErrOffset } - - // Offset (4) 'AttesterSlashings' - if o4 = ssz.ReadOffset(buf[204:208]); o4 > size || o3 > o4 { + sszVarOffset15 := ssz.ReadOffset(buf[2687248:2687252]) // c.PreviousEpochParticipation + if sszVarOffset15 > size || sszVarOffset15 < sszVarOffset12 { return ssz.ErrOffset } - - // Offset (5) 'Attestations' - if o5 = ssz.ReadOffset(buf[208:212]); o5 > size || o4 > o5 { + sszVarOffset16 := ssz.ReadOffset(buf[2687252:2687256]) // c.CurrentEpochParticipation + if sszVarOffset16 > size || sszVarOffset16 < sszVarOffset15 { return ssz.ErrOffset } - - // Offset (6) 'Deposits' - if o6 = ssz.ReadOffset(buf[212:216]); o6 > size || o5 > o6 { + sszVarOffset21 := ssz.ReadOffset(buf[2687377:2687381]) // c.InactivityScores + if sszVarOffset21 > size || sszVarOffset21 < sszVarOffset16 { return ssz.ErrOffset } - - // Offset (7) 'VoluntaryExits' - if o7 = ssz.ReadOffset(buf[216:220]); o7 > size || o6 > o7 { + sszVarOffset24 := ssz.ReadOffset(buf[2736629:2736633]) // c.LatestExecutionPayloadHeader + if sszVarOffset24 > size || sszVarOffset24 < sszVarOffset21 { return ssz.ErrOffset } + sszSlice7 := buf[sszVarOffset7:sszVarOffset9] // c.HistoricalRoots + sszSlice9 := buf[sszVarOffset9:sszVarOffset11] // c.Eth1DataVotes + sszSlice11 := buf[sszVarOffset11:sszVarOffset12] // c.Validators + sszSlice12 := buf[sszVarOffset12:sszVarOffset15] // c.Balances + sszSlice15 := buf[sszVarOffset15:sszVarOffset16] // c.PreviousEpochParticipation + sszSlice16 := buf[sszVarOffset16:sszVarOffset21] // c.CurrentEpochParticipation + sszSlice21 := buf[sszVarOffset21:sszVarOffset24] // c.InactivityScores + sszSlice24 := buf[sszVarOffset24:] // c.LatestExecutionPayloadHeader + + // Field 0: GenesisTime + c.GenesisTime = binary.LittleEndian.Uint64(sszSlice0) - // Field (8) 'SyncAggregate' - if b.SyncAggregate == nil { - b.SyncAggregate = new(SyncAggregate) + // Field 1: GenesisValidatorsRoot + c.GenesisValidatorsRoot = make([]byte, 0, 32) + c.GenesisValidatorsRoot = append(c.GenesisValidatorsRoot, sszSlice1...) + + // Field 2: Slot + if err = c.Slot.UnmarshalSSZ(sszSlice2); err != nil { + return fmt.Errorf("Slot: %w", err) } - if err = b.SyncAggregate.UnmarshalSSZ(buf[220:380]); err != nil { - return err + + // Field 3: Fork + c.Fork = new(Fork) + if err = c.Fork.UnmarshalSSZ(sszSlice3); err != nil { + return fmt.Errorf("Fork: %w", err) } - // Offset (9) 'ExecutionPayloadHeader' - if o9 = ssz.ReadOffset(buf[380:384]); o9 > size || o7 > o9 { - return ssz.ErrOffset + // Field 4: LatestBlockHeader + c.LatestBlockHeader = new(BeaconBlockHeader) + if err = c.LatestBlockHeader.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("LatestBlockHeader: %w", err) } - // Field (3) 'ProposerSlashings' + // Field 5: BlockRoots { - buf = tail[o3:o4] - num, err := ssz.DivideInt2(len(buf), 416, 16) - if err != nil { - return err - } - b.ProposerSlashings = make([]*ProposerSlashing, num) - for ii := 0; ii < num; ii++ { - if b.ProposerSlashings[ii] == nil { - b.ProposerSlashings[ii] = new(ProposerSlashing) - } - if err = b.ProposerSlashings[ii].UnmarshalSSZ(buf[ii*416 : (ii+1)*416]); err != nil { - return err - } + c.BlockRoots = make([][]byte, 8192) + for i := 0; i < 8192; i++ { + var tmp []byte + + tmpSlice := sszSlice5[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.BlockRoots[i] = tmp } } - // Field (4) 'AttesterSlashings' + // Field 6: StateRoots { - buf = tail[o4:o5] - num, err := ssz.DecodeDynamicLength(buf, 2) - 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 + c.StateRoots = make([][]byte, 8192) + for i := 0; i < 8192; i++ { + var tmp []byte + + tmpSlice := sszSlice6[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.StateRoots[i] = tmp } } - // Field (5) 'Attestations' + // Field 7: HistoricalRoots { - buf = tail[o5:o6] - num, err := ssz.DecodeDynamicLength(buf, 128) - 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 + if len(sszSlice7)%32 != 0 { + return fmt.Errorf("misaligned bytes: c.HistoricalRoots length is %d, which is not a multiple of 32: %w", len(sszSlice7), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice7) / 32 + if numElem > 16777216 { + return fmt.Errorf("ssz-max exceeded: c.HistoricalRoots has %d elements, ssz-max is 16777216: %w", numElem, ssz.ErrListTooBig) } + c.HistoricalRoots = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte + + tmpSlice := sszSlice7[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.HistoricalRoots[i] = tmp + } + } + + // Field 8: Eth1Data + c.Eth1Data = new(Eth1Data) + if err = c.Eth1Data.UnmarshalSSZ(sszSlice8); err != nil { + return fmt.Errorf("Eth1Data: %w", err) } - // Field (6) 'Deposits' + // Field 9: Eth1DataVotes { - buf = tail[o6:o7] - num, err := ssz.DivideInt2(len(buf), 1240, 16) - if err != nil { - return err - } - b.Deposits = make([]*Deposit, num) - for ii := 0; ii < num; ii++ { - if b.Deposits[ii] == nil { - b.Deposits[ii] = new(Deposit) - } - if err = b.Deposits[ii].UnmarshalSSZ(buf[ii*1240 : (ii+1)*1240]); err != nil { - return err + if len(sszSlice9)%72 != 0 { + return fmt.Errorf("misaligned bytes: c.Eth1DataVotes length is %d, which is not a multiple of 72: %w", len(sszSlice9), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice9) / 72 + if numElem > 2048 { + return fmt.Errorf("ssz-max exceeded: c.Eth1DataVotes has %d elements, ssz-max is 2048: %w", numElem, ssz.ErrListTooBig) + } + c.Eth1DataVotes = make([]*Eth1Data, numElem) + for i := 0; i < numElem; i++ { + var tmp *Eth1Data + tmp = new(Eth1Data) + tmpSlice := sszSlice9[i*72 : (1+i)*72] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Eth1DataVotes: %w", err) } + c.Eth1DataVotes[i] = tmp } } - // Field (7) 'VoluntaryExits' + // Field 10: Eth1DepositIndex + c.Eth1DepositIndex = binary.LittleEndian.Uint64(sszSlice10) + + // Field 11: Validators { - buf = tail[o7:o9] - num, err := ssz.DivideInt2(len(buf), 112, 16) - if err != nil { - return err - } - b.VoluntaryExits = make([]*SignedVoluntaryExit, num) - for ii := 0; ii < num; ii++ { - if b.VoluntaryExits[ii] == nil { - b.VoluntaryExits[ii] = new(SignedVoluntaryExit) - } - if err = b.VoluntaryExits[ii].UnmarshalSSZ(buf[ii*112 : (ii+1)*112]); err != nil { - return err + if len(sszSlice11)%121 != 0 { + return fmt.Errorf("misaligned bytes: c.Validators length is %d, which is not a multiple of 121: %w", len(sszSlice11), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice11) / 121 + if numElem > 1099511627776 { + return fmt.Errorf("ssz-max exceeded: c.Validators has %d elements, ssz-max is 1099511627776: %w", numElem, ssz.ErrListTooBig) + } + c.Validators = make([]*Validator, numElem) + for i := 0; i < numElem; i++ { + var tmp *Validator + tmp = new(Validator) + tmpSlice := sszSlice11[i*121 : (1+i)*121] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Validators: %w", err) } + c.Validators[i] = tmp } } - // Field (9) 'ExecutionPayloadHeader' + // Field 12: Balances { - buf = tail[o9:] - if b.ExecutionPayloadHeader == nil { - b.ExecutionPayloadHeader = new(v1.ExecutionPayloadHeader) + if len(sszSlice12)%8 != 0 { + return fmt.Errorf("misaligned bytes: c.Balances length is %d, which is not a multiple of 8: %w", len(sszSlice12), ssz.ErrIncorrectListSize) } - if err = b.ExecutionPayloadHeader.UnmarshalSSZ(buf); err != nil { - return err + numElem := len(sszSlice12) / 8 + if numElem > 1099511627776 { + return fmt.Errorf("ssz-max exceeded: c.Balances has %d elements, ssz-max is 1099511627776: %w", numElem, ssz.ErrListTooBig) } - } - return err -} + c.Balances = make([]uint64, numElem) + for i := 0; i < numElem; i++ { + var tmp uint64 -// SizeSSZ returns the ssz encoded size in bytes for the BlindedBeaconBlockBodyBellatrix object -func (b *BlindedBeaconBlockBodyBellatrix) SizeSSZ() (size int) { - size = 384 + tmpSlice := sszSlice12[i*8 : (1+i)*8] + tmp = binary.LittleEndian.Uint64(tmpSlice) + c.Balances[i] = tmp + } + } - // Field (3) 'ProposerSlashings' - size += len(b.ProposerSlashings) * 416 + // Field 13: RandaoMixes + { + c.RandaoMixes = make([][]byte, 65536) + for i := 0; i < 65536; i++ { + var tmp []byte - // Field (4) 'AttesterSlashings' - for ii := 0; ii < len(b.AttesterSlashings); ii++ { - size += 4 - size += b.AttesterSlashings[ii].SizeSSZ() + tmpSlice := sszSlice13[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.RandaoMixes[i] = tmp + } } - // Field (5) 'Attestations' - for ii := 0; ii < len(b.Attestations); ii++ { - size += 4 - size += b.Attestations[ii].SizeSSZ() + // Field 14: Slashings + { + c.Slashings = make([]uint64, 8192) + for i := 0; i < 8192; i++ { + var tmp uint64 + + tmpSlice := sszSlice14[i*8 : (1+i)*8] + tmp = binary.LittleEndian.Uint64(tmpSlice) + c.Slashings[i] = tmp + } } - // Field (6) 'Deposits' - size += len(b.Deposits) * 1240 + // Field 15: PreviousEpochParticipation + c.PreviousEpochParticipation = append([]byte{}, sszSlice15...) + + // Field 16: CurrentEpochParticipation + c.CurrentEpochParticipation = append([]byte{}, sszSlice16...) - // Field (7) 'VoluntaryExits' - size += len(b.VoluntaryExits) * 112 + // Field 17: JustificationBits + c.JustificationBits = make([]byte, 0, 1) + c.JustificationBits = append(c.JustificationBits, go_bitfield.Bitvector4(sszSlice17)...) - // Field (9) 'ExecutionPayloadHeader' - if b.ExecutionPayloadHeader == nil { - b.ExecutionPayloadHeader = new(v1.ExecutionPayloadHeader) + // Field 18: PreviousJustifiedCheckpoint + c.PreviousJustifiedCheckpoint = new(Checkpoint) + if err = c.PreviousJustifiedCheckpoint.UnmarshalSSZ(sszSlice18); err != nil { + return fmt.Errorf("PreviousJustifiedCheckpoint: %w", err) } - size += b.ExecutionPayloadHeader.SizeSSZ() - return -} + // Field 19: CurrentJustifiedCheckpoint + c.CurrentJustifiedCheckpoint = new(Checkpoint) + if err = c.CurrentJustifiedCheckpoint.UnmarshalSSZ(sszSlice19); err != nil { + return fmt.Errorf("CurrentJustifiedCheckpoint: %w", err) + } -// HashTreeRoot ssz hashes the BlindedBeaconBlockBodyBellatrix object -func (b *BlindedBeaconBlockBodyBellatrix) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) -} + // Field 20: FinalizedCheckpoint + c.FinalizedCheckpoint = new(Checkpoint) + if err = c.FinalizedCheckpoint.UnmarshalSSZ(sszSlice20); err != nil { + return fmt.Errorf("FinalizedCheckpoint: %w", err) + } -// HashTreeRootWith ssz hashes the BlindedBeaconBlockBodyBellatrix object with a hasher -func (b *BlindedBeaconBlockBodyBellatrix) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() + // Field 21: InactivityScores + { + if len(sszSlice21)%8 != 0 { + return fmt.Errorf("misaligned bytes: c.InactivityScores length is %d, which is not a multiple of 8: %w", len(sszSlice21), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice21) / 8 + if numElem > 1099511627776 { + return fmt.Errorf("ssz-max exceeded: c.InactivityScores has %d elements, ssz-max is 1099511627776: %w", numElem, ssz.ErrListTooBig) + } + c.InactivityScores = make([]uint64, numElem) + for i := 0; i < numElem; i++ { + var tmp uint64 + + tmpSlice := sszSlice21[i*8 : (1+i)*8] + tmp = binary.LittleEndian.Uint64(tmpSlice) + c.InactivityScores[i] = tmp + } + } - // Field (0) 'RandaoReveal' - if size := len(b.RandaoReveal); size != 96 { - err = ssz.ErrBytesLengthFn("--.RandaoReveal", size, 96) - return + // Field 22: CurrentSyncCommittee + c.CurrentSyncCommittee = new(SyncCommittee) + if err = c.CurrentSyncCommittee.UnmarshalSSZ(sszSlice22); err != nil { + return fmt.Errorf("CurrentSyncCommittee: %w", err) } - hh.PutBytes(b.RandaoReveal) - // Field (1) 'Eth1Data' - if err = b.Eth1Data.HashTreeRootWith(hh); err != nil { - return + // Field 23: NextSyncCommittee + c.NextSyncCommittee = new(SyncCommittee) + if err = c.NextSyncCommittee.UnmarshalSSZ(sszSlice23); err != nil { + return fmt.Errorf("NextSyncCommittee: %w", err) } - // Field (2) 'Graffiti' - if size := len(b.Graffiti); size != 32 { - err = ssz.ErrBytesLengthFn("--.Graffiti", size, 32) - return + // Field 24: LatestExecutionPayloadHeader + c.LatestExecutionPayloadHeader = new(v1.ExecutionPayloadHeader) + if err = c.LatestExecutionPayloadHeader.UnmarshalSSZ(sszSlice24); err != nil { + return fmt.Errorf("LatestExecutionPayloadHeader: %w", err) } - hh.PutBytes(b.Graffiti) + return err +} - // Field (3) 'ProposerSlashings' +func (c *BeaconStateBellatrix) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} + +func (c *BeaconStateBellatrix) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: GenesisTime + hh.PutUint64(c.GenesisTime) + // Field 1: GenesisValidatorsRoot + if len(c.GenesisValidatorsRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.GenesisValidatorsRoot) + // Field 2: Slot + if err := c.Slot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Slot: %w", err) + } + // Field 3: Fork + if err := c.Fork.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Fork: %w", err) + } + // Field 4: LatestBlockHeader + if err := c.LatestBlockHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("LatestBlockHeader: %w", err) + } + // Field 5: BlockRoots { + if len(c.BlockRoots) != 8192 { + return ssz.ErrVectorLength + } 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 + for _, o := range c.BlockRoots { + if len(o) != 32 { + return ssz.ErrBytesLength } + hh.Append(o) } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.Merkleize(subIndx) } - - // Field (4) 'AttesterSlashings' + // Field 6: StateRoots { + if len(c.StateRoots) != 8192 { + return ssz.ErrVectorLength + } 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 + for _, o := range c.StateRoots { + if len(o) != 32 { + return ssz.ErrBytesLength } + hh.Append(o) } - hh.MerkleizeWithMixin(subIndx, num, 2) + hh.Merkleize(subIndx) } - - // Field (5) 'Attestations' + // Field 7: HistoricalRoots { + if len(c.HistoricalRoots) > 16777216 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.HistoricalRoots { + if len(o) != 32 { + return ssz.ErrBytesLength } + hh.Append(o) } - hh.MerkleizeWithMixin(subIndx, num, 128) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.HistoricalRoots)), 16777216) } - - // Field (6) 'Deposits' + // Field 8: Eth1Data + if err := c.Eth1Data.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Eth1Data: %w", err) + } + // Field 9: Eth1DataVotes { + if len(c.Eth1DataVotes) > 2048 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.Eth1DataVotes { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Eth1DataVotes: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Eth1DataVotes)), 2048) } - - // Field (7) 'VoluntaryExits' + // Field 10: Eth1DepositIndex + hh.PutUint64(c.Eth1DepositIndex) + // Field 11: Validators { + if len(c.Validators) > 1099511627776 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.Validators { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Validators: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Validators)), 1099511627776) } - - // Field (8) 'SyncAggregate' - if err = b.SyncAggregate.HashTreeRootWith(hh); err != nil { - return + // Field 12: Balances + { + if len(c.Balances) > 1099511627776 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.Balances { + hh.AppendUint64(o) + } + hh.FillUpTo32() + numItems := uint64(len(c.Balances)) + hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(1099511627776, numItems, 8)) } - - // Field (9) 'ExecutionPayloadHeader' - if err = b.ExecutionPayloadHeader.HashTreeRootWith(hh); err != nil { - return + // Field 13: RandaoMixes + { + if len(c.RandaoMixes) != 65536 { + return ssz.ErrVectorLength + } + subIndx := hh.Index() + for _, o := range c.RandaoMixes { + if len(o) != 32 { + return ssz.ErrBytesLength + } + hh.Append(o) + } + hh.Merkleize(subIndx) } + // Field 14: Slashings + { + if len(c.Slashings) != 8192 { + return ssz.ErrVectorLength + } + subIndx := hh.Index() + for _, o := range c.Slashings { + hh.AppendUint64(o) + } + hh.Merkleize(subIndx) + } + // Field 15: PreviousEpochParticipation - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the BeaconStateBellatrix object -func (b *BeaconStateBellatrix) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} - -// MarshalSSZTo ssz marshals the BeaconStateBellatrix object to a target array -func (b *BeaconStateBellatrix) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(2736633) - - // Field (0) 'GenesisTime' - dst = ssz.MarshalUint(dst, b.GenesisTime) - - // Field (1) 'GenesisValidatorsRoot' - if size := len(b.GenesisValidatorsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.GenesisValidatorsRoot", size, 32) - return + { + if len(c.PreviousEpochParticipation) > 1099511627776 { + return ssz.ErrBytesLength + } + subIndx := hh.Index() + hh.AppendBytes32(c.PreviousEpochParticipation) + numItems := uint64(len(c.PreviousEpochParticipation)) + hh.MerkleizeWithMixin(subIndx, numItems, (1099511627776*1+31)/32) } - dst = append(dst, b.GenesisValidatorsRoot...) - // Field (2) 'Slot' - dst = ssz.MarshalUint(dst, b.Slot) + // Field 16: CurrentEpochParticipation - // Field (3) 'Fork' - if b.Fork == nil { - b.Fork = new(Fork) - } - if dst, err = b.Fork.MarshalSSZTo(dst); err != nil { - return + { + if len(c.CurrentEpochParticipation) > 1099511627776 { + return ssz.ErrBytesLength + } + subIndx := hh.Index() + hh.AppendBytes32(c.CurrentEpochParticipation) + numItems := uint64(len(c.CurrentEpochParticipation)) + hh.MerkleizeWithMixin(subIndx, numItems, (1099511627776*1+31)/32) } - // Field (4) 'LatestBlockHeader' - if b.LatestBlockHeader == nil { - b.LatestBlockHeader = new(BeaconBlockHeader) + // Field 17: JustificationBits + if len([]byte(c.JustificationBits)) != 1 { + return ssz.ErrBytesLength } - if dst, err = b.LatestBlockHeader.MarshalSSZTo(dst); err != nil { - return + hh.PutBytes([]byte(c.JustificationBits)) + // Field 18: PreviousJustifiedCheckpoint + if err := c.PreviousJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("PreviousJustifiedCheckpoint: %w", err) } - - // Field (5) 'BlockRoots' - if size := len(b.BlockRoots); size != 8192 { - err = ssz.ErrVectorLengthFn("--.BlockRoots", size, 8192) - return + // Field 19: CurrentJustifiedCheckpoint + if err := c.CurrentJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("CurrentJustifiedCheckpoint: %w", err) } - for ii := 0; ii < 8192; ii++ { - if size := len(b.BlockRoots[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockRoots[ii]", size, 32) - return - } - dst = append(dst, b.BlockRoots[ii]...) + // Field 20: FinalizedCheckpoint + if err := c.FinalizedCheckpoint.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("FinalizedCheckpoint: %w", err) } - - // Field (6) 'StateRoots' - if size := len(b.StateRoots); size != 8192 { - err = ssz.ErrVectorLengthFn("--.StateRoots", size, 8192) - return - } - for ii := 0; ii < 8192; ii++ { - if size := len(b.StateRoots[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoots[ii]", size, 32) - return + // Field 21: InactivityScores + { + if len(c.InactivityScores) > 1099511627776 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.InactivityScores { + hh.AppendUint64(o) } - dst = append(dst, b.StateRoots[ii]...) + hh.FillUpTo32() + numItems := uint64(len(c.InactivityScores)) + hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(1099511627776, numItems, 8)) } - - // Offset (7) 'HistoricalRoots' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.HistoricalRoots) * 32 - - // Field (8) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(Eth1Data) + // Field 22: CurrentSyncCommittee + if err := c.CurrentSyncCommittee.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("CurrentSyncCommittee: %w", err) } - if dst, err = b.Eth1Data.MarshalSSZTo(dst); err != nil { - return + // Field 23: NextSyncCommittee + if err := c.NextSyncCommittee.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("NextSyncCommittee: %w", err) } + // Field 24: LatestExecutionPayloadHeader + if err := c.LatestExecutionPayloadHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("LatestExecutionPayloadHeader: %w", err) + } + hh.Merkleize(indx) + return nil +} - // Offset (9) 'Eth1DataVotes' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.Eth1DataVotes) * 72 - - // Field (10) 'Eth1DepositIndex' - dst = ssz.MarshalUint(dst, b.Eth1DepositIndex) +func (c *BlindedBeaconBlockBellatrix) SizeSSZ() int { + size := 84 + if c.Body == nil { + c.Body = new(BlindedBeaconBlockBodyBellatrix) + } + size += c.Body.SizeSSZ() + return size +} - // Offset (11) 'Validators' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.Validators) * 121 +func (c *BlindedBeaconBlockBellatrix) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Offset (12) 'Balances' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.Balances) * 8 +func (c *BlindedBeaconBlockBellatrix) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 84 - // Field (13) 'RandaoMixes' - if size := len(b.RandaoMixes); size != 65536 { - err = ssz.ErrVectorLengthFn("--.RandaoMixes", size, 65536) - return - } - for ii := 0; ii < 65536; ii++ { - if size := len(b.RandaoMixes[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.RandaoMixes[ii]", size, 32) - return - } - dst = append(dst, b.RandaoMixes[ii]...) + // Field 0: Slot + if dst, err = c.Slot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Slot: %w", err) } - // Field (14) 'Slashings' - if size := len(b.Slashings); size != 8192 { - err = ssz.ErrVectorLengthFn("--.Slashings", size, 8192) - return + // Field 1: ProposerIndex + if dst, err = c.ProposerIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ProposerIndex: %w", err) } - for ii := 0; ii < 8192; ii++ { - dst = ssz.MarshalUint(dst, b.Slashings[ii]) + + // Field 2: ParentRoot + if len(c.ParentRoot) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.ParentRoot...) - // Offset (15) 'PreviousEpochParticipation' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.PreviousEpochParticipation) + // Field 3: StateRoot + if len(c.StateRoot) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.StateRoot...) - // Offset (16) 'CurrentEpochParticipation' + // Field 4: Body + if c.Body == nil { + c.Body = new(BlindedBeaconBlockBodyBellatrix) + } dst = ssz.WriteOffset(dst, offset) - offset += len(b.CurrentEpochParticipation) + offset += c.Body.SizeSSZ() - // Field (17) 'JustificationBits' - if size := len(b.JustificationBits); size != 1 { - err = ssz.ErrBytesLengthFn("--.JustificationBits", size, 1) - return + // Field 4: Body + if dst, err = c.Body.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Body: %w", err) } - dst = append(dst, b.JustificationBits...) + return dst, err +} - // Field (18) 'PreviousJustifiedCheckpoint' - if b.PreviousJustifiedCheckpoint == nil { - b.PreviousJustifiedCheckpoint = new(Checkpoint) - } - if dst, err = b.PreviousJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { - return +func (c *BlindedBeaconBlockBellatrix) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 84 { + return ssz.ErrSize } - // Field (19) 'CurrentJustifiedCheckpoint' - if b.CurrentJustifiedCheckpoint == nil { - b.CurrentJustifiedCheckpoint = new(Checkpoint) + sszSlice0 := buf[0:8] // c.Slot + sszSlice1 := buf[8:16] // c.ProposerIndex + sszSlice2 := buf[16:48] // c.ParentRoot + sszSlice3 := buf[48:80] // c.StateRoot + + sszVarOffset4 := ssz.ReadOffset(buf[80:84]) // c.Body + if sszVarOffset4 != 84 { + return ssz.ErrInvalidVariableOffset } - if dst, err = b.CurrentJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { - return + if sszVarOffset4 > size { + return ssz.ErrOffset } + sszSlice4 := buf[sszVarOffset4:] // c.Body - // Field (20) 'FinalizedCheckpoint' - if b.FinalizedCheckpoint == nil { - b.FinalizedCheckpoint = new(Checkpoint) + // Field 0: Slot + if err = c.Slot.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Slot: %w", err) } - if dst, err = b.FinalizedCheckpoint.MarshalSSZTo(dst); err != nil { - return + + // Field 1: ProposerIndex + if err = c.ProposerIndex.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("ProposerIndex: %w", err) } - // Offset (21) 'InactivityScores' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.InactivityScores) * 8 + // Field 2: ParentRoot + c.ParentRoot = make([]byte, 0, 32) + c.ParentRoot = append(c.ParentRoot, sszSlice2...) - // Field (22) 'CurrentSyncCommittee' - if b.CurrentSyncCommittee == nil { - b.CurrentSyncCommittee = new(SyncCommittee) - } - if dst, err = b.CurrentSyncCommittee.MarshalSSZTo(dst); err != nil { - return - } + // Field 3: StateRoot + c.StateRoot = make([]byte, 0, 32) + c.StateRoot = append(c.StateRoot, sszSlice3...) - // Field (23) 'NextSyncCommittee' - if b.NextSyncCommittee == nil { - b.NextSyncCommittee = new(SyncCommittee) - } - if dst, err = b.NextSyncCommittee.MarshalSSZTo(dst); err != nil { - return + // Field 4: Body + c.Body = new(BlindedBeaconBlockBodyBellatrix) + if err = c.Body.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("Body: %w", err) } + return err +} - // Offset (24) 'LatestExecutionPayloadHeader' - dst = ssz.WriteOffset(dst, offset) - if b.LatestExecutionPayloadHeader == nil { - b.LatestExecutionPayloadHeader = new(v1.ExecutionPayloadHeader) +func (c *BlindedBeaconBlockBellatrix) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - offset += b.LatestExecutionPayloadHeader.SizeSSZ() + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (7) 'HistoricalRoots' - if size := len(b.HistoricalRoots); size > 16777216 { - err = ssz.ErrListTooBigFn("--.HistoricalRoots", size, 16777216) - return - } - for ii := 0; ii < len(b.HistoricalRoots); ii++ { - if size := len(b.HistoricalRoots[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.HistoricalRoots[ii]", size, 32) - return - } - dst = append(dst, b.HistoricalRoots[ii]...) +func (c *BlindedBeaconBlockBellatrix) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Slot + if err := c.Slot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Slot: %w", err) } - - // Field (9) 'Eth1DataVotes' - if size := len(b.Eth1DataVotes); size > 2048 { - err = ssz.ErrListTooBigFn("--.Eth1DataVotes", size, 2048) - return + // Field 1: ProposerIndex + if err := c.ProposerIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ProposerIndex: %w", err) } - for ii := 0; ii < len(b.Eth1DataVotes); ii++ { - if dst, err = b.Eth1DataVotes[ii].MarshalSSZTo(dst); err != nil { - return - } + // Field 2: ParentRoot + if len(c.ParentRoot) != 32 { + return ssz.ErrBytesLength } - - // Field (11) 'Validators' - if size := len(b.Validators); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.Validators", size, 1099511627776) - return + hh.PutBytes(c.ParentRoot) + // Field 3: StateRoot + if len(c.StateRoot) != 32 { + return ssz.ErrBytesLength } - for ii := 0; ii < len(b.Validators); ii++ { - if dst, err = b.Validators[ii].MarshalSSZTo(dst); err != nil { - return - } + hh.PutBytes(c.StateRoot) + // Field 4: Body + if err := c.Body.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Body: %w", err) } + hh.Merkleize(indx) + return nil +} - // Field (12) 'Balances' - if size := len(b.Balances); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.Balances", size, 1099511627776) - return +func (c *BlindedBeaconBlockBodyBellatrix) SizeSSZ() int { + size := 384 + size += len(c.ProposerSlashings) * 416 + for _, o := range c.AttesterSlashings { + size += 4 + size += o.SizeSSZ() } - for ii := 0; ii < len(b.Balances); ii++ { - dst = ssz.MarshalUint(dst, b.Balances[ii]) + for _, o := range c.Attestations { + size += 4 + size += o.SizeSSZ() } - - // Field (15) 'PreviousEpochParticipation' - if size := len(b.PreviousEpochParticipation); size > 1099511627776 { - err = ssz.ErrBytesLengthFn("--.PreviousEpochParticipation", size, 1099511627776) - return + size += len(c.Deposits) * 1240 + size += len(c.VoluntaryExits) * 112 + if c.ExecutionPayloadHeader == nil { + c.ExecutionPayloadHeader = new(v1.ExecutionPayloadHeader) } - dst = append(dst, b.PreviousEpochParticipation...) + size += c.ExecutionPayloadHeader.SizeSSZ() + return size +} + +func (c *BlindedBeaconBlockBodyBellatrix) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (16) 'CurrentEpochParticipation' - if size := len(b.CurrentEpochParticipation); size > 1099511627776 { - err = ssz.ErrBytesLengthFn("--.CurrentEpochParticipation", size, 1099511627776) - return +func (c *BlindedBeaconBlockBodyBellatrix) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 384 + + // Field 0: RandaoReveal + if len(c.RandaoReveal) != 96 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.CurrentEpochParticipation...) + dst = append(dst, c.RandaoReveal...) - // Field (21) 'InactivityScores' - if size := len(b.InactivityScores); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.InactivityScores", size, 1099511627776) - return + // Field 1: Eth1Data + if c.Eth1Data == nil { + c.Eth1Data = new(Eth1Data) } - for ii := 0; ii < len(b.InactivityScores); ii++ { - dst = ssz.MarshalUint(dst, b.InactivityScores[ii]) + if dst, err = c.Eth1Data.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Eth1Data: %w", err) } - // Field (24) 'LatestExecutionPayloadHeader' - if dst, err = b.LatestExecutionPayloadHeader.MarshalSSZTo(dst); err != nil { - return + // Field 2: Graffiti + if len(c.Graffiti) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.Graffiti...) - return -} + // Field 3: ProposerSlashings + dst = ssz.WriteOffset(dst, offset) + offset += len(c.ProposerSlashings) * 416 -// UnmarshalSSZ ssz unmarshals the BeaconStateBellatrix object -func (b *BeaconStateBellatrix) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 2736633 { - return ssz.ErrSize + // Field 4: AttesterSlashings + dst = ssz.WriteOffset(dst, offset) + for _, o := range c.AttesterSlashings { + offset += 4 + offset += o.SizeSSZ() } - tail := buf - var o7, o9, o11, o12, o15, o16, o21, o24 uint64 - - // Field (0) 'GenesisTime' - b.GenesisTime = ssz.UnmarshallUint[uint64](buf[0:8]) - - // Field (1) 'GenesisValidatorsRoot' - if cap(b.GenesisValidatorsRoot) == 0 { - b.GenesisValidatorsRoot = make([]byte, 0, len(buf[8:40])) + // Field 5: Attestations + dst = ssz.WriteOffset(dst, offset) + for _, o := range c.Attestations { + offset += 4 + offset += o.SizeSSZ() } - b.GenesisValidatorsRoot = append(b.GenesisValidatorsRoot, buf[8:40]...) - // Field (2) 'Slot' - b.Slot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[40:48]) + // Field 6: Deposits + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Deposits) * 1240 + + // Field 7: VoluntaryExits + dst = ssz.WriteOffset(dst, offset) + offset += len(c.VoluntaryExits) * 112 - // Field (3) 'Fork' - if b.Fork == nil { - b.Fork = new(Fork) + // Field 8: SyncAggregate + if c.SyncAggregate == nil { + c.SyncAggregate = new(SyncAggregate) } - if err = b.Fork.UnmarshalSSZ(buf[48:64]); err != nil { - return err + if dst, err = c.SyncAggregate.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SyncAggregate: %w", err) } - // Field (4) 'LatestBlockHeader' - if b.LatestBlockHeader == nil { - b.LatestBlockHeader = new(BeaconBlockHeader) - } - if err = b.LatestBlockHeader.UnmarshalSSZ(buf[64:176]); err != nil { - return err + // Field 9: ExecutionPayloadHeader + if c.ExecutionPayloadHeader == nil { + c.ExecutionPayloadHeader = new(v1.ExecutionPayloadHeader) } + dst = ssz.WriteOffset(dst, offset) + offset += c.ExecutionPayloadHeader.SizeSSZ() - // Field (5) 'BlockRoots' - b.BlockRoots = make([][]byte, 8192) - for ii := 0; ii < 8192; ii++ { - if cap(b.BlockRoots[ii]) == 0 { - b.BlockRoots[ii] = make([]byte, 0, len(buf[176:262320][ii*32:(ii+1)*32])) + // Field 3: ProposerSlashings + if len(c.ProposerSlashings) > 16 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.ProposerSlashings { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ProposerSlashings: %w", err) } - b.BlockRoots[ii] = append(b.BlockRoots[ii], buf[176:262320][ii*32:(ii+1)*32]...) } - // Field (6) 'StateRoots' - b.StateRoots = make([][]byte, 8192) - for ii := 0; ii < 8192; ii++ { - if cap(b.StateRoots[ii]) == 0 { - b.StateRoots[ii] = make([]byte, 0, len(buf[262320:524464][ii*32:(ii+1)*32])) + // Field 4: AttesterSlashings + if len(c.AttesterSlashings) > 2 { + return nil, ssz.ErrListTooBig + } + { + offset = 4 * len(c.AttesterSlashings) + for _, o := range c.AttesterSlashings { + dst = ssz.WriteOffset(dst, offset) + offset += o.SizeSSZ() } - b.StateRoots[ii] = append(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 + for _, o := range c.AttesterSlashings { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("AttesterSlashings: %w", err) + } } - if o7 != 2736633 { - return ssz.ErrInvalidVariableOffset + // Field 5: Attestations + if len(c.Attestations) > 128 { + return nil, ssz.ErrListTooBig } - - // Field (8) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(Eth1Data) + { + offset = 4 * len(c.Attestations) + for _, o := range c.Attestations { + dst = ssz.WriteOffset(dst, offset) + offset += o.SizeSSZ() + } } - if err = b.Eth1Data.UnmarshalSSZ(buf[524468:524540]); err != nil { - return err + for _, o := range c.Attestations { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Attestations: %w", err) + } } - // Offset (9) 'Eth1DataVotes' - if o9 = ssz.ReadOffset(buf[524540:524544]); o9 > size || o7 > o9 { - return ssz.ErrOffset + // Field 6: Deposits + if len(c.Deposits) > 16 { + return nil, ssz.ErrListTooBig } - - // Field (10) 'Eth1DepositIndex' - b.Eth1DepositIndex = ssz.UnmarshallUint[uint64](buf[524544:524552]) - - // Offset (11) 'Validators' - if o11 = ssz.ReadOffset(buf[524552:524556]); o11 > size || o9 > o11 { - return ssz.ErrOffset + for _, o := range c.Deposits { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Deposits: %w", err) + } } - // Offset (12) 'Balances' - if o12 = ssz.ReadOffset(buf[524556:524560]); o12 > size || o11 > o12 { - return ssz.ErrOffset + // Field 7: VoluntaryExits + if len(c.VoluntaryExits) > 16 { + return nil, ssz.ErrListTooBig } - - // 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])) + for _, o := range c.VoluntaryExits { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("VoluntaryExits: %w", err) } - b.RandaoMixes[ii] = append(b.RandaoMixes[ii], buf[524560:2621712][ii*32:(ii+1)*32]...) - } - - // Field (14) 'Slashings' - b.Slashings = ssz.ExtendUint(b.Slashings, 8192) - for ii := 0; ii < 8192; ii++ { - b.Slashings[ii] = ssz.UnmarshallUint[uint64](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 + // Field 9: ExecutionPayloadHeader + if dst, err = c.ExecutionPayloadHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ExecutionPayloadHeader: %w", err) } + return dst, err +} - // Offset (16) 'CurrentEpochParticipation' - if o16 = ssz.ReadOffset(buf[2687252:2687256]); o16 > size || o15 > o16 { - return ssz.ErrOffset +func (c *BlindedBeaconBlockBodyBellatrix) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 384 { + return ssz.ErrSize } - // Field (17) 'JustificationBits' - if cap(b.JustificationBits) == 0 { - b.JustificationBits = make([]byte, 0, len(buf[2687256:2687257])) - } - b.JustificationBits = append(b.JustificationBits, buf[2687256:2687257]...) + sszSlice0 := buf[0:96] // c.RandaoReveal + sszSlice1 := buf[96:168] // c.Eth1Data + sszSlice2 := buf[168:200] // c.Graffiti + sszSlice8 := buf[220:380] // c.SyncAggregate - // Field (18) 'PreviousJustifiedCheckpoint' - if b.PreviousJustifiedCheckpoint == nil { - b.PreviousJustifiedCheckpoint = new(Checkpoint) + sszVarOffset3 := ssz.ReadOffset(buf[200:204]) // c.ProposerSlashings + if sszVarOffset3 != 384 { + return ssz.ErrInvalidVariableOffset } - if err = b.PreviousJustifiedCheckpoint.UnmarshalSSZ(buf[2687257:2687297]); err != nil { - return err + if sszVarOffset3 > size { + return ssz.ErrOffset } - - // Field (19) 'CurrentJustifiedCheckpoint' - if b.CurrentJustifiedCheckpoint == nil { - b.CurrentJustifiedCheckpoint = new(Checkpoint) + sszVarOffset4 := ssz.ReadOffset(buf[204:208]) // c.AttesterSlashings + if sszVarOffset4 > size || sszVarOffset4 < sszVarOffset3 { + return ssz.ErrOffset } - if err = b.CurrentJustifiedCheckpoint.UnmarshalSSZ(buf[2687297:2687337]); err != nil { - return err + sszVarOffset5 := ssz.ReadOffset(buf[208:212]) // c.Attestations + if sszVarOffset5 > size || sszVarOffset5 < sszVarOffset4 { + return ssz.ErrOffset } - - // Field (20) 'FinalizedCheckpoint' - if b.FinalizedCheckpoint == nil { - b.FinalizedCheckpoint = new(Checkpoint) + sszVarOffset6 := ssz.ReadOffset(buf[212:216]) // c.Deposits + if sszVarOffset6 > size || sszVarOffset6 < sszVarOffset5 { + return ssz.ErrOffset } - if err = b.FinalizedCheckpoint.UnmarshalSSZ(buf[2687337:2687377]); err != nil { - return err + sszVarOffset7 := ssz.ReadOffset(buf[216:220]) // c.VoluntaryExits + if sszVarOffset7 > size || sszVarOffset7 < sszVarOffset6 { + return ssz.ErrOffset } - - // Offset (21) 'InactivityScores' - if o21 = ssz.ReadOffset(buf[2687377:2687381]); o21 > size || o16 > o21 { + sszVarOffset9 := ssz.ReadOffset(buf[380:384]) // c.ExecutionPayloadHeader + if sszVarOffset9 > size || sszVarOffset9 < sszVarOffset7 { return ssz.ErrOffset } + sszSlice3 := buf[sszVarOffset3:sszVarOffset4] // c.ProposerSlashings + sszSlice4 := buf[sszVarOffset4:sszVarOffset5] // c.AttesterSlashings + sszSlice5 := buf[sszVarOffset5:sszVarOffset6] // c.Attestations + sszSlice6 := buf[sszVarOffset6:sszVarOffset7] // c.Deposits + sszSlice7 := buf[sszVarOffset7:sszVarOffset9] // c.VoluntaryExits + sszSlice9 := buf[sszVarOffset9:] // c.ExecutionPayloadHeader - // Field (22) 'CurrentSyncCommittee' - if b.CurrentSyncCommittee == nil { - b.CurrentSyncCommittee = new(SyncCommittee) - } - if err = b.CurrentSyncCommittee.UnmarshalSSZ(buf[2687381:2712005]); err != nil { - return err - } + // Field 0: RandaoReveal + c.RandaoReveal = make([]byte, 0, 96) + c.RandaoReveal = append(c.RandaoReveal, sszSlice0...) - // Field (23) 'NextSyncCommittee' - if b.NextSyncCommittee == nil { - b.NextSyncCommittee = new(SyncCommittee) - } - if err = b.NextSyncCommittee.UnmarshalSSZ(buf[2712005:2736629]); err != nil { - return err + // Field 1: Eth1Data + c.Eth1Data = new(Eth1Data) + if err = c.Eth1Data.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Eth1Data: %w", err) } - // Offset (24) 'LatestExecutionPayloadHeader' - if o24 = ssz.ReadOffset(buf[2736629:2736633]); o24 > size || o21 > o24 { - return ssz.ErrOffset - } + // Field 2: Graffiti + c.Graffiti = make([]byte, 0, 32) + c.Graffiti = append(c.Graffiti, sszSlice2...) - // Field (7) 'HistoricalRoots' + // Field 3: ProposerSlashings { - 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])) + if len(sszSlice3)%416 != 0 { + return fmt.Errorf("misaligned bytes: c.ProposerSlashings length is %d, which is not a multiple of 416: %w", len(sszSlice3), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice3) / 416 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.ProposerSlashings has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.ProposerSlashings = make([]*ProposerSlashing, numElem) + for i := 0; i < numElem; i++ { + var tmp *ProposerSlashing + tmp = new(ProposerSlashing) + tmpSlice := sszSlice3[i*416 : (1+i)*416] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("ProposerSlashings: %w", err) } - b.HistoricalRoots[ii] = append(b.HistoricalRoots[ii], buf[ii*32:(ii+1)*32]...) + c.ProposerSlashings[i] = tmp } } - // Field (9) 'Eth1DataVotes' + // Field 4: AttesterSlashings { - buf = tail[o9:o11] - num, err := ssz.DivideInt2(len(buf), 72, 2048) - if err != nil { - return err - } - b.Eth1DataVotes = make([]*Eth1Data, num) - for ii := 0; ii < num; ii++ { - if b.Eth1DataVotes[ii] == nil { - b.Eth1DataVotes[ii] = new(Eth1Data) + // empty lists are zero length, so make sure there is room for an offset + // before attempting to unmarshal it + if len(sszSlice4) > 3 { + startOffset := ssz.ReadOffset(sszSlice4[0:4]) + if startOffset == 0 { + return fmt.Errorf("encountered invalid offset of 0 when decoding c.AttesterSlashings") } - if err = b.Eth1DataVotes[ii].UnmarshalSSZ(buf[ii*72 : (ii+1)*72]); err != nil { - return err + if startOffset%4 != 0 { + return fmt.Errorf("misaligned list bytes: when decoding c.AttesterSlashings, end-of-list offset is %d, which is not a multiple of 4 (offset size)", startOffset) } - } - } - - // Field (11) 'Validators' - { - buf = tail[o11:o12] - num, err := ssz.DivideInt2(len(buf), 121, 1099511627776) - if err != nil { - return err - } - b.Validators = make([]*Validator, num) - for ii := 0; ii < num; ii++ { - if b.Validators[ii] == nil { - b.Validators[ii] = new(Validator) + listLen := startOffset / 4 + if listLen > 2 { + return fmt.Errorf("ssz-max exceeded: c.AttesterSlashings has %d elements, ssz-max is 2: %w", listLen, ssz.ErrListTooBig) } - if err = b.Validators[ii].UnmarshalSSZ(buf[ii*121 : (ii+1)*121]); err != nil { - return err + totalVarBytes := uint64(len(sszSlice4)) + if totalVarBytes < startOffset { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.AttesterSlashings") } + c.AttesterSlashings = make([]*AttesterSlashing, listLen) + var tmpSlice []byte + for i := uint64(0); i < listLen; i++ { + var tmp *AttesterSlashing + tmp = new(AttesterSlashing) + endOffset := totalVarBytes + if i+1 != listLen { + endOffset = ssz.ReadOffset(sszSlice4[(i+1)*4 : (i+2)*4]) + if totalVarBytes < endOffset { + return fmt.Errorf("offset %d points past the end of buffer when decoding c.AttesterSlashings", endOffset) + } + } + if endOffset < startOffset { + return fmt.Errorf("offset %d is not greater than start offset %d when decoding c.AttesterSlashings", endOffset, startOffset) + } + tmpSlice = sszSlice4[startOffset:endOffset] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("AttesterSlashings: %w", err) + } + c.AttesterSlashings[i] = tmp + startOffset = endOffset + } + } else { + if len(sszSlice4) > 0 { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.AttesterSlashings") + } + c.AttesterSlashings = make([]*AttesterSlashing, 0) } } - // Field (12) 'Balances' + // Field 5: Attestations { - buf = tail[o12:o15] - num, err := ssz.DivideInt2(len(buf), 8, 1099511627776) - if err != nil { - return err - } - b.Balances = ssz.ExtendUint(b.Balances, num) - for ii := 0; ii < num; ii++ { - b.Balances[ii] = ssz.UnmarshallUint[uint64](buf[ii*8 : (ii+1)*8]) + // empty lists are zero length, so make sure there is room for an offset + // before attempting to unmarshal it + if len(sszSlice5) > 3 { + startOffset := ssz.ReadOffset(sszSlice5[0:4]) + if startOffset == 0 { + return fmt.Errorf("encountered invalid offset of 0 when decoding c.Attestations") + } + if startOffset%4 != 0 { + return fmt.Errorf("misaligned list bytes: when decoding c.Attestations, end-of-list offset is %d, which is not a multiple of 4 (offset size)", startOffset) + } + listLen := startOffset / 4 + if listLen > 128 { + return fmt.Errorf("ssz-max exceeded: c.Attestations has %d elements, ssz-max is 128: %w", listLen, ssz.ErrListTooBig) + } + totalVarBytes := uint64(len(sszSlice5)) + if totalVarBytes < startOffset { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.Attestations") + } + c.Attestations = make([]*Attestation, listLen) + var tmpSlice []byte + for i := uint64(0); i < listLen; i++ { + var tmp *Attestation + tmp = new(Attestation) + endOffset := totalVarBytes + if i+1 != listLen { + endOffset = ssz.ReadOffset(sszSlice5[(i+1)*4 : (i+2)*4]) + if totalVarBytes < endOffset { + return fmt.Errorf("offset %d points past the end of buffer when decoding c.Attestations", endOffset) + } + } + if endOffset < startOffset { + return fmt.Errorf("offset %d is not greater than start offset %d when decoding c.Attestations", endOffset, startOffset) + } + tmpSlice = sszSlice5[startOffset:endOffset] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Attestations: %w", err) + } + c.Attestations[i] = tmp + startOffset = endOffset + } + } else { + if len(sszSlice5) > 0 { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.Attestations") + } + c.Attestations = make([]*Attestation, 0) } } - // Field (15) 'PreviousEpochParticipation' + // Field 6: Deposits { - buf = tail[o15:o16] - if len(buf) > 1099511627776 { - return ssz.ErrBytesLength - } - if cap(b.PreviousEpochParticipation) == 0 { - b.PreviousEpochParticipation = make([]byte, 0, len(buf)) + if len(sszSlice6)%1240 != 0 { + return fmt.Errorf("misaligned bytes: c.Deposits length is %d, which is not a multiple of 1240: %w", len(sszSlice6), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice6) / 1240 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.Deposits has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.Deposits = make([]*Deposit, numElem) + for i := 0; i < numElem; i++ { + var tmp *Deposit + tmp = new(Deposit) + tmpSlice := sszSlice6[i*1240 : (1+i)*1240] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Deposits: %w", err) + } + c.Deposits[i] = tmp } - b.PreviousEpochParticipation = append(b.PreviousEpochParticipation, buf...) } - // Field (16) 'CurrentEpochParticipation' + // Field 7: VoluntaryExits { - buf = tail[o16:o21] - if len(buf) > 1099511627776 { - return ssz.ErrBytesLength - } - if cap(b.CurrentEpochParticipation) == 0 { - b.CurrentEpochParticipation = make([]byte, 0, len(buf)) + if len(sszSlice7)%112 != 0 { + return fmt.Errorf("misaligned bytes: c.VoluntaryExits length is %d, which is not a multiple of 112: %w", len(sszSlice7), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice7) / 112 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.VoluntaryExits has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.VoluntaryExits = make([]*SignedVoluntaryExit, numElem) + for i := 0; i < numElem; i++ { + var tmp *SignedVoluntaryExit + tmp = new(SignedVoluntaryExit) + tmpSlice := sszSlice7[i*112 : (1+i)*112] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("VoluntaryExits: %w", err) + } + c.VoluntaryExits[i] = tmp } - 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.ExtendUint(b.InactivityScores, num) - for ii := 0; ii < num; ii++ { - b.InactivityScores[ii] = ssz.UnmarshallUint[uint64](buf[ii*8 : (ii+1)*8]) - } + // Field 8: SyncAggregate + c.SyncAggregate = new(SyncAggregate) + if err = c.SyncAggregate.UnmarshalSSZ(sszSlice8); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) } - // Field (24) 'LatestExecutionPayloadHeader' - { - buf = tail[o24:] - if b.LatestExecutionPayloadHeader == nil { - b.LatestExecutionPayloadHeader = new(v1.ExecutionPayloadHeader) - } - if err = b.LatestExecutionPayloadHeader.UnmarshalSSZ(buf); err != nil { - return err - } + // Field 9: ExecutionPayloadHeader + c.ExecutionPayloadHeader = new(v1.ExecutionPayloadHeader) + if err = c.ExecutionPayloadHeader.UnmarshalSSZ(sszSlice9); err != nil { + return fmt.Errorf("ExecutionPayloadHeader: %w", err) } return err } -// SizeSSZ returns the ssz encoded size in bytes for the BeaconStateBellatrix object -func (b *BeaconStateBellatrix) SizeSSZ() (size int) { - size = 2736633 - - // 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(v1.ExecutionPayloadHeader) +func (c *BlindedBeaconBlockBodyBellatrix) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - size += b.LatestExecutionPayloadHeader.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the BeaconStateBellatrix object -func (b *BeaconStateBellatrix) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the BeaconStateBellatrix object with a hasher -func (b *BeaconStateBellatrix) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *BlindedBeaconBlockBodyBellatrix) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'GenesisTime' - ssz.PutUint(hh, b.GenesisTime) - - // Field (1) 'GenesisValidatorsRoot' - if size := len(b.GenesisValidatorsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.GenesisValidatorsRoot", size, 32) - return + // Field 0: RandaoReveal + if len(c.RandaoReveal) != 96 { + return ssz.ErrBytesLength } - hh.PutBytes(b.GenesisValidatorsRoot) - - // Field (2) 'Slot' - ssz.PutUint(hh, b.Slot) - - // Field (3) 'Fork' - if err = b.Fork.HashTreeRootWith(hh); err != nil { - return + hh.PutBytes(c.RandaoReveal) + // Field 1: Eth1Data + if err := c.Eth1Data.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Eth1Data: %w", err) } - - // Field (4) 'LatestBlockHeader' - if err = b.LatestBlockHeader.HashTreeRootWith(hh); err != nil { - return + // Field 2: Graffiti + if len(c.Graffiti) != 32 { + return ssz.ErrBytesLength } - - // Field (5) 'BlockRoots' + hh.PutBytes(c.Graffiti) + // Field 3: ProposerSlashings { - if size := len(b.BlockRoots); size != 8192 { - err = ssz.ErrVectorLengthFn("--.BlockRoots", size, 8192) - return + if len(c.ProposerSlashings) > 16 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range b.BlockRoots { - if len(i) != 32 { - err = ssz.ErrBytesLength - return + for _, o := range c.ProposerSlashings { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ProposerSlashings: %w", err) } - hh.Append(i) } - hh.Merkleize(subIndx) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.ProposerSlashings)), 16) } - - // Field (6) 'StateRoots' + // Field 4: AttesterSlashings { - if size := len(b.StateRoots); size != 8192 { - err = ssz.ErrVectorLengthFn("--.StateRoots", size, 8192) - return + if len(c.AttesterSlashings) > 2 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range b.StateRoots { - if len(i) != 32 { - err = ssz.ErrBytesLength - return + for _, o := range c.AttesterSlashings { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("AttesterSlashings: %w", err) } - hh.Append(i) } - hh.Merkleize(subIndx) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.AttesterSlashings)), 2) } - - // Field (7) 'HistoricalRoots' + // Field 5: Attestations { - if size := len(b.HistoricalRoots); size > 16777216 { - err = ssz.ErrListTooBigFn("--.HistoricalRoots", size, 16777216) - return + if len(c.Attestations) > 128 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range b.HistoricalRoots { - if len(i) != 32 { - err = ssz.ErrBytesLength - return + for _, o := range c.Attestations { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Attestations: %w", err) } - hh.Append(i) } - - numItems := uint64(len(b.HistoricalRoots)) - hh.MerkleizeWithMixin(subIndx, numItems, 16777216) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Attestations)), 128) } - - // Field (8) 'Eth1Data' - if err = b.Eth1Data.HashTreeRootWith(hh); err != nil { - return - } - - // Field (9) 'Eth1DataVotes' + // Field 6: Deposits { + if len(c.Deposits) > 16 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.Deposits { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Deposits: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 2048) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Deposits)), 16) } - - // Field (10) 'Eth1DepositIndex' - ssz.PutUint(hh, b.Eth1DepositIndex) - - // Field (11) 'Validators' + // Field 7: VoluntaryExits { + if len(c.VoluntaryExits) > 16 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.VoluntaryExits { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("VoluntaryExits: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 1099511627776) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.VoluntaryExits)), 16) + } + // Field 8: SyncAggregate + if err := c.SyncAggregate.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) + } + // Field 9: ExecutionPayloadHeader + if err := c.ExecutionPayloadHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ExecutionPayloadHeader: %w", err) } + hh.Merkleize(indx) + return nil +} - // Field (12) 'Balances' - { - if size := len(b.Balances); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.Balances", size, 1099511627776) - return - } - subIndx := hh.Index() - for _, i := range b.Balances { - ssz.AppendUint(hh, i) - } - hh.FillUpTo32() +func (c *SignedBeaconBlockBellatrix) SizeSSZ() int { + size := 100 + if c.Block == nil { + c.Block = new(BeaconBlockBellatrix) + } + size += c.Block.SizeSSZ() + return size +} - numItems := uint64(len(b.Balances)) - hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(1099511627776, numItems, 8)) +func (c *SignedBeaconBlockBellatrix) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} + +func (c *SignedBeaconBlockBellatrix) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 100 + + // Field 0: Block + if c.Block == nil { + c.Block = new(BeaconBlockBellatrix) } + dst = ssz.WriteOffset(dst, offset) + offset += c.Block.SizeSSZ() - // Field (13) 'RandaoMixes' - { - if size := len(b.RandaoMixes); size != 65536 { - err = ssz.ErrVectorLengthFn("--.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 1: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.Signature...) - // Field (14) 'Slashings' - { - if size := len(b.Slashings); size != 8192 { - err = ssz.ErrVectorLengthFn("--.Slashings", size, 8192) - return - } - subIndx := hh.Index() - for _, i := range b.Slashings { - ssz.AppendUint(hh, i) - } - hh.Merkleize(subIndx) + // Field 0: Block + if dst, err = c.Block.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Block: %w", err) } + return dst, err +} - // Field (15) 'PreviousEpochParticipation' - { - elemIndx := hh.Index() - byteLen := uint64(len(b.PreviousEpochParticipation)) - if byteLen > 1099511627776 { - err = ssz.ErrIncorrectListSize - return - } - hh.AppendBytes32(b.PreviousEpochParticipation) - hh.MerkleizeWithMixin(elemIndx, byteLen, (1099511627776+31)/32) +func (c *SignedBeaconBlockBellatrix) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 100 { + return ssz.ErrSize } - // Field (16) 'CurrentEpochParticipation' - { - elemIndx := hh.Index() - byteLen := uint64(len(b.CurrentEpochParticipation)) - if byteLen > 1099511627776 { - err = ssz.ErrIncorrectListSize - return - } - hh.AppendBytes32(b.CurrentEpochParticipation) - hh.MerkleizeWithMixin(elemIndx, byteLen, (1099511627776+31)/32) + sszSlice1 := buf[4:100] // c.Signature + + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Block + if sszVarOffset0 != 100 { + return ssz.ErrInvalidVariableOffset } + if sszVarOffset0 > size { + return ssz.ErrOffset + } + sszSlice0 := buf[sszVarOffset0:] // c.Block - // Field (17) 'JustificationBits' - if size := len(b.JustificationBits); size != 1 { - err = ssz.ErrBytesLengthFn("--.JustificationBits", size, 1) - return + // Field 0: Block + c.Block = new(BeaconBlockBellatrix) + if err = c.Block.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Block: %w", err) } - hh.PutBytes(b.JustificationBits) - // Field (18) 'PreviousJustifiedCheckpoint' - if err = b.PreviousJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { - return + // Field 1: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice1...) + return err +} + +func (c *SignedBeaconBlockBellatrix) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (19) 'CurrentJustifiedCheckpoint' - if err = b.CurrentJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { - return +func (c *SignedBeaconBlockBellatrix) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Block + if err := c.Block.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Block: %w", err) + } + // Field 1: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength } + hh.PutBytes(c.Signature) + hh.Merkleize(indx) + return nil +} - // Field (20) 'FinalizedCheckpoint' - if err = b.FinalizedCheckpoint.HashTreeRootWith(hh); err != nil { - return +func (c *SignedBlindedBeaconBlockBellatrix) SizeSSZ() int { + size := 100 + if c.Block == nil { + c.Block = new(BlindedBeaconBlockBellatrix) } + size += c.Block.SizeSSZ() + return size +} - // Field (21) 'InactivityScores' - { - if size := len(b.InactivityScores); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.InactivityScores", size, 1099511627776) - return - } - subIndx := hh.Index() - for _, i := range b.InactivityScores { - ssz.AppendUint(hh, i) - } - hh.FillUpTo32() +func (c *SignedBlindedBeaconBlockBellatrix) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - numItems := uint64(len(b.InactivityScores)) - hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(1099511627776, numItems, 8)) +func (c *SignedBlindedBeaconBlockBellatrix) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 100 + + // Field 0: Block + if c.Block == nil { + c.Block = new(BlindedBeaconBlockBellatrix) } + dst = ssz.WriteOffset(dst, offset) + offset += c.Block.SizeSSZ() + + // Field 1: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.Signature...) - // Field (22) 'CurrentSyncCommittee' - if err = b.CurrentSyncCommittee.HashTreeRootWith(hh); err != nil { - return + // Field 0: Block + if dst, err = c.Block.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Block: %w", err) } + return dst, err +} - // Field (23) 'NextSyncCommittee' - if err = b.NextSyncCommittee.HashTreeRootWith(hh); err != nil { - return +func (c *SignedBlindedBeaconBlockBellatrix) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 100 { + return ssz.ErrSize } - // Field (24) 'LatestExecutionPayloadHeader' - if err = b.LatestExecutionPayloadHeader.HashTreeRootWith(hh); err != nil { - return + sszSlice1 := buf[4:100] // c.Signature + + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Block + if sszVarOffset0 != 100 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset0 > size { + return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:] // c.Block + // Field 0: Block + c.Block = new(BlindedBeaconBlockBellatrix) + if err = c.Block.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Block: %w", err) + } + + // Field 1: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice1...) + return err +} + +func (c *SignedBlindedBeaconBlockBellatrix) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} + +func (c *SignedBlindedBeaconBlockBellatrix) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Block + if err := c.Block.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Block: %w", err) + } + // Field 1: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Signature) hh.Merkleize(indx) - return + return nil } diff --git a/proto/prysm/v1alpha1/bellatrix.yaml b/proto/prysm/v1alpha1/bellatrix.yaml new file mode 100644 index 000000000000..89a2502e5cd6 --- /dev/null +++ b/proto/prysm/v1alpha1/bellatrix.yaml @@ -0,0 +1,9 @@ +package: "github.com/OffchainLabs/prysm/v7/proto/prysm/v1alpha1" +types: + - name: "BeaconBlockBellatrix" + - name: "BeaconBlockBodyBellatrix" + - name: "BeaconStateBellatrix" + - name: "BlindedBeaconBlockBellatrix" + - name: "BlindedBeaconBlockBodyBellatrix" + - name: "SignedBeaconBlockBellatrix" + - name: "SignedBlindedBeaconBlockBellatrix" diff --git a/proto/prysm/v1alpha1/capella.minimal.ssz.go b/proto/prysm/v1alpha1/capella.minimal.ssz.go index cbff66bae1d5..4f026ac076ef 100644 --- a/proto/prysm/v1alpha1/capella.minimal.ssz.go +++ b/proto/prysm/v1alpha1/capella.minimal.ssz.go @@ -1,3885 +1,3694 @@ //go:build minimal -// Code generated by fastssz. DO NOT EDIT. package eth import ( - github_com_OffchainLabs_prysm_v7_consensus_types_primitives "github.com/OffchainLabs/prysm/v7/consensus-types/primitives" + binary "encoding/binary" + "fmt" + go_bitfield "github.com/OffchainLabs/go-bitfield" + ssz "github.com/OffchainLabs/methodical-ssz/ssz" v1 "github.com/OffchainLabs/prysm/v7/proto/engine/v1" - ssz "github.com/prysmaticlabs/fastssz" ) -// MarshalSSZ ssz marshals the SignedBeaconBlockCapella object -func (s *SignedBeaconBlockCapella) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) -} - -// MarshalSSZTo ssz marshals the SignedBeaconBlockCapella object to a target array -func (s *SignedBeaconBlockCapella) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(100) - - // Offset (0) 'Block' - dst = ssz.WriteOffset(dst, offset) - if s.Block == nil { - s.Block = new(BeaconBlockCapella) - } - offset += s.Block.SizeSSZ() - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.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 SignedBeaconBlockCapella object -func (s *SignedBeaconBlockCapella) 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(BeaconBlockCapella) - } - if err = s.Block.UnmarshalSSZ(buf); err != nil { - return err - } - } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the SignedBeaconBlockCapella object -func (s *SignedBeaconBlockCapella) SizeSSZ() (size int) { - size = 100 - - // Field (0) 'Block' - if s.Block == nil { - s.Block = new(BeaconBlockCapella) +func (c *BeaconBlockBodyCapella) SizeSSZ() int { + size := 328 + size += len(c.ProposerSlashings) * 416 + for _, o := range c.AttesterSlashings { + size += 4 + size += o.SizeSSZ() } - size += s.Block.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the SignedBeaconBlockCapella object -func (s *SignedBeaconBlockCapella) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) -} - -// HashTreeRootWith ssz hashes the SignedBeaconBlockCapella object with a hasher -func (s *SignedBeaconBlockCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'Block' - if err = s.Block.HashTreeRootWith(hh); err != nil { - return + for _, o := range c.Attestations { + size += 4 + size += o.SizeSSZ() } - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + size += len(c.Deposits) * 1240 + size += len(c.VoluntaryExits) * 112 + if c.ExecutionPayload == nil { + c.ExecutionPayload = new(v1.ExecutionPayloadCapella) } - hh.PutBytes(s.Signature) - - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the BeaconBlockCapella object -func (b *BeaconBlockCapella) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) + size += c.ExecutionPayload.SizeSSZ() + size += len(c.BlsToExecutionChanges) * 172 + return size } -// MarshalSSZTo ssz marshals the BeaconBlockCapella object to a target array -func (b *BeaconBlockCapella) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(84) - - // Field (0) 'Slot' - dst = ssz.MarshalUint(dst, b.Slot) - - // Field (1) 'ProposerIndex' - dst = ssz.MarshalUint(dst, b.ProposerIndex) - - // Field (2) 'ParentRoot' - if size := len(b.ParentRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentRoot", size, 32) - return - } - dst = append(dst, b.ParentRoot...) - - // Field (3) 'StateRoot' - if size := len(b.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return - } - dst = append(dst, b.StateRoot...) - - // Offset (4) 'Body' - dst = ssz.WriteOffset(dst, offset) - if b.Body == nil { - b.Body = new(BeaconBlockBodyCapella) - } - offset += b.Body.SizeSSZ() - - // Field (4) 'Body' - if dst, err = b.Body.MarshalSSZTo(dst); err != nil { - return - } - - return +func (c *BeaconBlockBodyCapella) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// UnmarshalSSZ ssz unmarshals the BeaconBlockCapella object -func (b *BeaconBlockCapella) UnmarshalSSZ(buf []byte) error { +func (c *BeaconBlockBodyCapella) MarshalSSZTo(dst []byte) ([]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.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[0:8]) - - // Field (1) 'ProposerIndex' - b.ProposerIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](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]...) - - // 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(BeaconBlockBodyCapella) - } - if err = b.Body.UnmarshalSSZ(buf); err != nil { - return err - } - } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the BeaconBlockCapella object -func (b *BeaconBlockCapella) SizeSSZ() (size int) { - size = 84 - - // Field (4) 'Body' - if b.Body == nil { - b.Body = new(BeaconBlockBodyCapella) - } - size += b.Body.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the BeaconBlockCapella object -func (b *BeaconBlockCapella) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) -} - -// HashTreeRootWith ssz hashes the BeaconBlockCapella object with a hasher -func (b *BeaconBlockCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'Slot' - ssz.PutUint(hh, b.Slot) - - // Field (1) 'ProposerIndex' - ssz.PutUint(hh, b.ProposerIndex) + offset := 328 - // Field (2) 'ParentRoot' - if size := len(b.ParentRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentRoot", size, 32) - return + // Field 0: RandaoReveal + if len(c.RandaoReveal) != 96 { + return nil, ssz.ErrBytesLength } - hh.PutBytes(b.ParentRoot) + dst = append(dst, c.RandaoReveal...) - // Field (3) 'StateRoot' - if size := len(b.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return + // Field 1: Eth1Data + if c.Eth1Data == nil { + c.Eth1Data = new(Eth1Data) } - hh.PutBytes(b.StateRoot) - - // Field (4) 'Body' - if err = b.Body.HashTreeRootWith(hh); err != nil { - return - } - - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the BeaconBlockBodyCapella object -func (b *BeaconBlockBodyCapella) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} - -// MarshalSSZTo ssz marshals the BeaconBlockBodyCapella object to a target array -func (b *BeaconBlockBodyCapella) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(328) - - // Field (0) 'RandaoReveal' - if size := len(b.RandaoReveal); size != 96 { - err = ssz.ErrBytesLengthFn("--.RandaoReveal", size, 96) - return - } - dst = append(dst, b.RandaoReveal...) - - // Field (1) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(Eth1Data) - } - if dst, err = b.Eth1Data.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.Eth1Data.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Eth1Data: %w", err) } - // Field (2) 'Graffiti' - if size := len(b.Graffiti); size != 32 { - err = ssz.ErrBytesLengthFn("--.Graffiti", size, 32) - return + // Field 2: Graffiti + if len(c.Graffiti) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.Graffiti...) + dst = append(dst, c.Graffiti...) - // Offset (3) 'ProposerSlashings' + // Field 3: ProposerSlashings dst = ssz.WriteOffset(dst, offset) - offset += len(b.ProposerSlashings) * 416 + offset += len(c.ProposerSlashings) * 416 - // Offset (4) 'AttesterSlashings' + // Field 4: AttesterSlashings dst = ssz.WriteOffset(dst, offset) - for ii := 0; ii < len(b.AttesterSlashings); ii++ { + for _, o := range c.AttesterSlashings { offset += 4 - offset += b.AttesterSlashings[ii].SizeSSZ() + offset += o.SizeSSZ() } - // Offset (5) 'Attestations' + // Field 5: Attestations dst = ssz.WriteOffset(dst, offset) - for ii := 0; ii < len(b.Attestations); ii++ { + for _, o := range c.Attestations { offset += 4 - offset += b.Attestations[ii].SizeSSZ() + offset += o.SizeSSZ() } - // Offset (6) 'Deposits' + // Field 6: Deposits dst = ssz.WriteOffset(dst, offset) - offset += len(b.Deposits) * 1240 + offset += len(c.Deposits) * 1240 - // Offset (7) 'VoluntaryExits' + // Field 7: VoluntaryExits dst = ssz.WriteOffset(dst, offset) - offset += len(b.VoluntaryExits) * 112 + offset += len(c.VoluntaryExits) * 112 - // Field (8) 'SyncAggregate' - if b.SyncAggregate == nil { - b.SyncAggregate = new(SyncAggregate) + // Field 8: SyncAggregate + if c.SyncAggregate == nil { + c.SyncAggregate = new(SyncAggregate) } - if dst, err = b.SyncAggregate.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.SyncAggregate.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SyncAggregate: %w", err) } - // Offset (9) 'ExecutionPayload' - dst = ssz.WriteOffset(dst, offset) - if b.ExecutionPayload == nil { - b.ExecutionPayload = new(v1.ExecutionPayloadCapella) + // Field 9: ExecutionPayload + if c.ExecutionPayload == nil { + c.ExecutionPayload = new(v1.ExecutionPayloadCapella) } - offset += b.ExecutionPayload.SizeSSZ() + dst = ssz.WriteOffset(dst, offset) + offset += c.ExecutionPayload.SizeSSZ() - // Offset (10) 'BlsToExecutionChanges' + // Field 10: BlsToExecutionChanges dst = ssz.WriteOffset(dst, offset) - offset += len(b.BlsToExecutionChanges) * 172 + offset += len(c.BlsToExecutionChanges) * 172 - // Field (3) 'ProposerSlashings' - if size := len(b.ProposerSlashings); size > 16 { - err = ssz.ErrListTooBigFn("--.ProposerSlashings", size, 16) - return + // Field 3: ProposerSlashings + if len(c.ProposerSlashings) > 16 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.ProposerSlashings); ii++ { - if dst, err = b.ProposerSlashings[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.ProposerSlashings { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ProposerSlashings: %w", err) } } - // Field (4) 'AttesterSlashings' - if size := len(b.AttesterSlashings); size > 2 { - err = ssz.ErrListTooBigFn("--.AttesterSlashings", size, 2) - return + // Field 4: AttesterSlashings + if len(c.AttesterSlashings) > 2 { + return nil, ssz.ErrListTooBig } { - offset = 4 * len(b.AttesterSlashings) - for ii := 0; ii < len(b.AttesterSlashings); ii++ { + offset = 4 * len(c.AttesterSlashings) + for _, o := range c.AttesterSlashings { dst = ssz.WriteOffset(dst, offset) - offset += b.AttesterSlashings[ii].SizeSSZ() + offset += o.SizeSSZ() } } - for ii := 0; ii < len(b.AttesterSlashings); ii++ { - if dst, err = b.AttesterSlashings[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.AttesterSlashings { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("AttesterSlashings: %w", err) } } - // Field (5) 'Attestations' - if size := len(b.Attestations); size > 128 { - err = ssz.ErrListTooBigFn("--.Attestations", size, 128) - return + // Field 5: Attestations + if len(c.Attestations) > 128 { + return nil, ssz.ErrListTooBig } { - offset = 4 * len(b.Attestations) - for ii := 0; ii < len(b.Attestations); ii++ { + offset = 4 * len(c.Attestations) + for _, o := range c.Attestations { dst = ssz.WriteOffset(dst, offset) - offset += b.Attestations[ii].SizeSSZ() + offset += o.SizeSSZ() } } - for ii := 0; ii < len(b.Attestations); ii++ { - if dst, err = b.Attestations[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.Attestations { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Attestations: %w", err) } } - // Field (6) 'Deposits' - if size := len(b.Deposits); size > 16 { - err = ssz.ErrListTooBigFn("--.Deposits", size, 16) - return + // Field 6: Deposits + if len(c.Deposits) > 16 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.Deposits); ii++ { - if dst, err = b.Deposits[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.Deposits { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Deposits: %w", err) } } - // Field (7) 'VoluntaryExits' - if size := len(b.VoluntaryExits); size > 16 { - err = ssz.ErrListTooBigFn("--.VoluntaryExits", size, 16) - return + // Field 7: VoluntaryExits + if len(c.VoluntaryExits) > 16 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.VoluntaryExits); ii++ { - if dst, err = b.VoluntaryExits[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.VoluntaryExits { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("VoluntaryExits: %w", err) } } - // Field (9) 'ExecutionPayload' - if dst, err = b.ExecutionPayload.MarshalSSZTo(dst); err != nil { - return + // Field 9: ExecutionPayload + if dst, err = c.ExecutionPayload.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ExecutionPayload: %w", err) } - // Field (10) 'BlsToExecutionChanges' - if size := len(b.BlsToExecutionChanges); size > 16 { - err = ssz.ErrListTooBigFn("--.BlsToExecutionChanges", size, 16) - return + // Field 10: BlsToExecutionChanges + if len(c.BlsToExecutionChanges) > 16 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.BlsToExecutionChanges); ii++ { - if dst, err = b.BlsToExecutionChanges[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.BlsToExecutionChanges { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("BlsToExecutionChanges: %w", err) } } - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the BeaconBlockBodyCapella object -func (b *BeaconBlockBodyCapella) UnmarshalSSZ(buf []byte) error { +func (c *BeaconBlockBodyCapella) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size < 328 { return ssz.ErrSize } - tail := buf - var o3, o4, o5, o6, o7, o9, o10 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]...) + sszSlice0 := buf[0:96] // c.RandaoReveal + sszSlice1 := buf[96:168] // c.Eth1Data + sszSlice2 := buf[168:200] // c.Graffiti + sszSlice8 := buf[220:320] // c.SyncAggregate - // Field (1) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(Eth1Data) - } - if err = b.Eth1Data.UnmarshalSSZ(buf[96:168]); err != nil { - return err + sszVarOffset3 := ssz.ReadOffset(buf[200:204]) // c.ProposerSlashings + if sszVarOffset3 != 328 { + return ssz.ErrInvalidVariableOffset } - - // Field (2) 'Graffiti' - if cap(b.Graffiti) == 0 { - b.Graffiti = make([]byte, 0, len(buf[168:200])) + if sszVarOffset3 > size { + return ssz.ErrOffset } - b.Graffiti = append(b.Graffiti, buf[168:200]...) - - // Offset (3) 'ProposerSlashings' - if o3 = ssz.ReadOffset(buf[200:204]); o3 > size { + sszVarOffset4 := ssz.ReadOffset(buf[204:208]) // c.AttesterSlashings + if sszVarOffset4 > size || sszVarOffset4 < sszVarOffset3 { return ssz.ErrOffset } - - if o3 != 328 { - return ssz.ErrInvalidVariableOffset + sszVarOffset5 := ssz.ReadOffset(buf[208:212]) // c.Attestations + if sszVarOffset5 > size || sszVarOffset5 < sszVarOffset4 { + return ssz.ErrOffset } - - // Offset (4) 'AttesterSlashings' - if o4 = ssz.ReadOffset(buf[204:208]); o4 > size || o3 > o4 { + sszVarOffset6 := ssz.ReadOffset(buf[212:216]) // c.Deposits + if sszVarOffset6 > size || sszVarOffset6 < sszVarOffset5 { return ssz.ErrOffset } - - // Offset (5) 'Attestations' - if o5 = ssz.ReadOffset(buf[208:212]); o5 > size || o4 > o5 { + sszVarOffset7 := ssz.ReadOffset(buf[216:220]) // c.VoluntaryExits + if sszVarOffset7 > size || sszVarOffset7 < sszVarOffset6 { return ssz.ErrOffset } - - // Offset (6) 'Deposits' - if o6 = ssz.ReadOffset(buf[212:216]); o6 > size || o5 > o6 { + sszVarOffset9 := ssz.ReadOffset(buf[320:324]) // c.ExecutionPayload + if sszVarOffset9 > size || sszVarOffset9 < sszVarOffset7 { return ssz.ErrOffset } - - // Offset (7) 'VoluntaryExits' - if o7 = ssz.ReadOffset(buf[216:220]); o7 > size || o6 > o7 { + sszVarOffset10 := ssz.ReadOffset(buf[324:328]) // c.BlsToExecutionChanges + if sszVarOffset10 > size || sszVarOffset10 < sszVarOffset9 { return ssz.ErrOffset } + sszSlice3 := buf[sszVarOffset3:sszVarOffset4] // c.ProposerSlashings + sszSlice4 := buf[sszVarOffset4:sszVarOffset5] // c.AttesterSlashings + sszSlice5 := buf[sszVarOffset5:sszVarOffset6] // c.Attestations + sszSlice6 := buf[sszVarOffset6:sszVarOffset7] // c.Deposits + sszSlice7 := buf[sszVarOffset7:sszVarOffset9] // c.VoluntaryExits + sszSlice9 := buf[sszVarOffset9:sszVarOffset10] // c.ExecutionPayload + sszSlice10 := buf[sszVarOffset10:] // c.BlsToExecutionChanges - // Field (8) 'SyncAggregate' - if b.SyncAggregate == nil { - b.SyncAggregate = new(SyncAggregate) - } - if err = b.SyncAggregate.UnmarshalSSZ(buf[220:320]); err != nil { - return err - } + // Field 0: RandaoReveal + c.RandaoReveal = make([]byte, 0, 96) + c.RandaoReveal = append(c.RandaoReveal, sszSlice0...) - // Offset (9) 'ExecutionPayload' - if o9 = ssz.ReadOffset(buf[320:324]); o9 > size || o7 > o9 { - return ssz.ErrOffset + // Field 1: Eth1Data + c.Eth1Data = new(Eth1Data) + if err = c.Eth1Data.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Eth1Data: %w", err) } - // Offset (10) 'BlsToExecutionChanges' - if o10 = ssz.ReadOffset(buf[324:328]); o10 > size || o9 > o10 { - return ssz.ErrOffset - } + // Field 2: Graffiti + c.Graffiti = make([]byte, 0, 32) + c.Graffiti = append(c.Graffiti, sszSlice2...) - // Field (3) 'ProposerSlashings' + // Field 3: ProposerSlashings { - buf = tail[o3:o4] - num, err := ssz.DivideInt2(len(buf), 416, 16) - if err != nil { - return err - } - b.ProposerSlashings = make([]*ProposerSlashing, num) - for ii := 0; ii < num; ii++ { - if b.ProposerSlashings[ii] == nil { - b.ProposerSlashings[ii] = new(ProposerSlashing) - } - if err = b.ProposerSlashings[ii].UnmarshalSSZ(buf[ii*416 : (ii+1)*416]); err != nil { - return err + if len(sszSlice3)%416 != 0 { + return fmt.Errorf("misaligned bytes: c.ProposerSlashings length is %d, which is not a multiple of 416: %w", len(sszSlice3), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice3) / 416 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.ProposerSlashings has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.ProposerSlashings = make([]*ProposerSlashing, numElem) + for i := 0; i < numElem; i++ { + var tmp *ProposerSlashing + tmp = new(ProposerSlashing) + tmpSlice := sszSlice3[i*416 : (1+i)*416] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("ProposerSlashings: %w", err) } + c.ProposerSlashings[i] = tmp } } - // Field (4) 'AttesterSlashings' + // Field 4: AttesterSlashings { - buf = tail[o4:o5] - num, err := ssz.DecodeDynamicLength(buf, 2) - 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) + // empty lists are zero length, so make sure there is room for an offset + // before attempting to unmarshal it + if len(sszSlice4) > 3 { + startOffset := ssz.ReadOffset(sszSlice4[0:4]) + if startOffset == 0 { + return fmt.Errorf("encountered invalid offset of 0 when decoding c.AttesterSlashings") } - if err = b.AttesterSlashings[indx].UnmarshalSSZ(buf); err != nil { - return err + if startOffset%4 != 0 { + return fmt.Errorf("misaligned list bytes: when decoding c.AttesterSlashings, end-of-list offset is %d, which is not a multiple of 4 (offset size)", startOffset) } - 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([]*Attestation, num) - err = ssz.UnmarshalDynamic(buf, num, func(indx int, buf []byte) (err error) { - if b.Attestations[indx] == nil { - b.Attestations[indx] = new(Attestation) + listLen := startOffset / 4 + if listLen > 2 { + return fmt.Errorf("ssz-max exceeded: c.AttesterSlashings has %d elements, ssz-max is 2: %w", listLen, ssz.ErrListTooBig) } - if err = b.Attestations[indx].UnmarshalSSZ(buf); err != nil { - return err + totalVarBytes := uint64(len(sszSlice4)) + if totalVarBytes < startOffset { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.AttesterSlashings") } - 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([]*Deposit, num) - for ii := 0; ii < num; ii++ { - if b.Deposits[ii] == nil { - b.Deposits[ii] = new(Deposit) + c.AttesterSlashings = make([]*AttesterSlashing, listLen) + var tmpSlice []byte + for i := uint64(0); i < listLen; i++ { + var tmp *AttesterSlashing + tmp = new(AttesterSlashing) + endOffset := totalVarBytes + if i+1 != listLen { + endOffset = ssz.ReadOffset(sszSlice4[(i+1)*4 : (i+2)*4]) + if totalVarBytes < endOffset { + return fmt.Errorf("offset %d points past the end of buffer when decoding c.AttesterSlashings", endOffset) + } + } + if endOffset < startOffset { + return fmt.Errorf("offset %d is not greater than start offset %d when decoding c.AttesterSlashings", endOffset, startOffset) + } + tmpSlice = sszSlice4[startOffset:endOffset] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("AttesterSlashings: %w", err) + } + c.AttesterSlashings[i] = tmp + startOffset = endOffset } - if err = b.Deposits[ii].UnmarshalSSZ(buf[ii*1240 : (ii+1)*1240]); err != nil { - return err + } else { + if len(sszSlice4) > 0 { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.AttesterSlashings") } + c.AttesterSlashings = make([]*AttesterSlashing, 0) } } - // Field (7) 'VoluntaryExits' + // Field 5: Attestations { - buf = tail[o7:o9] - num, err := ssz.DivideInt2(len(buf), 112, 16) - if err != nil { - return err - } - b.VoluntaryExits = make([]*SignedVoluntaryExit, num) - for ii := 0; ii < num; ii++ { - if b.VoluntaryExits[ii] == nil { - b.VoluntaryExits[ii] = new(SignedVoluntaryExit) + // empty lists are zero length, so make sure there is room for an offset + // before attempting to unmarshal it + if len(sszSlice5) > 3 { + startOffset := ssz.ReadOffset(sszSlice5[0:4]) + if startOffset == 0 { + return fmt.Errorf("encountered invalid offset of 0 when decoding c.Attestations") + } + if startOffset%4 != 0 { + return fmt.Errorf("misaligned list bytes: when decoding c.Attestations, end-of-list offset is %d, which is not a multiple of 4 (offset size)", startOffset) + } + listLen := startOffset / 4 + if listLen > 128 { + return fmt.Errorf("ssz-max exceeded: c.Attestations has %d elements, ssz-max is 128: %w", listLen, ssz.ErrListTooBig) + } + totalVarBytes := uint64(len(sszSlice5)) + if totalVarBytes < startOffset { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.Attestations") } - if err = b.VoluntaryExits[ii].UnmarshalSSZ(buf[ii*112 : (ii+1)*112]); err != nil { - return err + c.Attestations = make([]*Attestation, listLen) + var tmpSlice []byte + for i := uint64(0); i < listLen; i++ { + var tmp *Attestation + tmp = new(Attestation) + endOffset := totalVarBytes + if i+1 != listLen { + endOffset = ssz.ReadOffset(sszSlice5[(i+1)*4 : (i+2)*4]) + if totalVarBytes < endOffset { + return fmt.Errorf("offset %d points past the end of buffer when decoding c.Attestations", endOffset) + } + } + if endOffset < startOffset { + return fmt.Errorf("offset %d is not greater than start offset %d when decoding c.Attestations", endOffset, startOffset) + } + tmpSlice = sszSlice5[startOffset:endOffset] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Attestations: %w", err) + } + c.Attestations[i] = tmp + startOffset = endOffset } + } else { + if len(sszSlice5) > 0 { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.Attestations") + } + c.Attestations = make([]*Attestation, 0) } } - // Field (9) 'ExecutionPayload' + // Field 6: Deposits { - buf = tail[o9:o10] - if b.ExecutionPayload == nil { - b.ExecutionPayload = new(v1.ExecutionPayloadCapella) + if len(sszSlice6)%1240 != 0 { + return fmt.Errorf("misaligned bytes: c.Deposits length is %d, which is not a multiple of 1240: %w", len(sszSlice6), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice6) / 1240 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.Deposits has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) } - if err = b.ExecutionPayload.UnmarshalSSZ(buf); err != nil { - return err + c.Deposits = make([]*Deposit, numElem) + for i := 0; i < numElem; i++ { + var tmp *Deposit + tmp = new(Deposit) + tmpSlice := sszSlice6[i*1240 : (1+i)*1240] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Deposits: %w", err) + } + c.Deposits[i] = tmp } } - // Field (10) 'BlsToExecutionChanges' + // Field 7: VoluntaryExits { - buf = tail[o10:] - num, err := ssz.DivideInt2(len(buf), 172, 16) - if err != nil { - return err - } - b.BlsToExecutionChanges = make([]*SignedBLSToExecutionChange, num) - for ii := 0; ii < num; ii++ { - if b.BlsToExecutionChanges[ii] == nil { - b.BlsToExecutionChanges[ii] = new(SignedBLSToExecutionChange) - } - if err = b.BlsToExecutionChanges[ii].UnmarshalSSZ(buf[ii*172 : (ii+1)*172]); err != nil { - return err + if len(sszSlice7)%112 != 0 { + return fmt.Errorf("misaligned bytes: c.VoluntaryExits length is %d, which is not a multiple of 112: %w", len(sszSlice7), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice7) / 112 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.VoluntaryExits has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.VoluntaryExits = make([]*SignedVoluntaryExit, numElem) + for i := 0; i < numElem; i++ { + var tmp *SignedVoluntaryExit + tmp = new(SignedVoluntaryExit) + tmpSlice := sszSlice7[i*112 : (1+i)*112] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("VoluntaryExits: %w", err) } + c.VoluntaryExits[i] = tmp } } - return err -} -// SizeSSZ returns the ssz encoded size in bytes for the BeaconBlockBodyCapella object -func (b *BeaconBlockBodyCapella) SizeSSZ() (size int) { - size = 328 - - // 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 8: SyncAggregate + c.SyncAggregate = new(SyncAggregate) + if err = c.SyncAggregate.UnmarshalSSZ(sszSlice8); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) } - // Field (5) 'Attestations' - for ii := 0; ii < len(b.Attestations); ii++ { - size += 4 - size += b.Attestations[ii].SizeSSZ() + // Field 9: ExecutionPayload + c.ExecutionPayload = new(v1.ExecutionPayloadCapella) + if err = c.ExecutionPayload.UnmarshalSSZ(sszSlice9); err != nil { + return fmt.Errorf("ExecutionPayload: %w", err) } - // 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(v1.ExecutionPayloadCapella) + // Field 10: BlsToExecutionChanges + { + if len(sszSlice10)%172 != 0 { + return fmt.Errorf("misaligned bytes: c.BlsToExecutionChanges length is %d, which is not a multiple of 172: %w", len(sszSlice10), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice10) / 172 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.BlsToExecutionChanges has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.BlsToExecutionChanges = make([]*SignedBLSToExecutionChange, numElem) + for i := 0; i < numElem; i++ { + var tmp *SignedBLSToExecutionChange + tmp = new(SignedBLSToExecutionChange) + tmpSlice := sszSlice10[i*172 : (1+i)*172] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("BlsToExecutionChanges: %w", err) + } + c.BlsToExecutionChanges[i] = tmp + } } - size += b.ExecutionPayload.SizeSSZ() - - // Field (10) 'BlsToExecutionChanges' - size += len(b.BlsToExecutionChanges) * 172 - - return + return err } -// HashTreeRoot ssz hashes the BeaconBlockBodyCapella object -func (b *BeaconBlockBodyCapella) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) +func (c *BeaconBlockBodyCapella) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the BeaconBlockBodyCapella object with a hasher -func (b *BeaconBlockBodyCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *BeaconBlockBodyCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'RandaoReveal' - if size := len(b.RandaoReveal); size != 96 { - err = ssz.ErrBytesLengthFn("--.RandaoReveal", size, 96) - return + // Field 0: RandaoReveal + if len(c.RandaoReveal) != 96 { + return ssz.ErrBytesLength } - hh.PutBytes(b.RandaoReveal) - - // Field (1) 'Eth1Data' - if err = b.Eth1Data.HashTreeRootWith(hh); err != nil { - return + hh.PutBytes(c.RandaoReveal) + // Field 1: Eth1Data + if err := c.Eth1Data.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Eth1Data: %w", err) } - - // Field (2) 'Graffiti' - if size := len(b.Graffiti); size != 32 { - err = ssz.ErrBytesLengthFn("--.Graffiti", size, 32) - return + // Field 2: Graffiti + if len(c.Graffiti) != 32 { + return ssz.ErrBytesLength } - hh.PutBytes(b.Graffiti) - - // Field (3) 'ProposerSlashings' + hh.PutBytes(c.Graffiti) + // Field 3: ProposerSlashings { + if len(c.ProposerSlashings) > 16 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.ProposerSlashings { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ProposerSlashings: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.ProposerSlashings)), 16) } - - // Field (4) 'AttesterSlashings' + // Field 4: AttesterSlashings { + if len(c.AttesterSlashings) > 2 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.AttesterSlashings { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("AttesterSlashings: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 2) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.AttesterSlashings)), 2) } - - // Field (5) 'Attestations' + // Field 5: Attestations { + if len(c.Attestations) > 128 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.Attestations { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Attestations: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 128) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Attestations)), 128) } - - // Field (6) 'Deposits' + // Field 6: Deposits { + if len(c.Deposits) > 16 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.Deposits { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Deposits: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Deposits)), 16) } - - // Field (7) 'VoluntaryExits' + // Field 7: VoluntaryExits { + if len(c.VoluntaryExits) > 16 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.VoluntaryExits { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("VoluntaryExits: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.VoluntaryExits)), 16) } - - // Field (8) 'SyncAggregate' - if err = b.SyncAggregate.HashTreeRootWith(hh); err != nil { - return + // Field 8: SyncAggregate + if err := c.SyncAggregate.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) } - - // Field (9) 'ExecutionPayload' - if err = b.ExecutionPayload.HashTreeRootWith(hh); err != nil { - return + // Field 9: ExecutionPayload + if err := c.ExecutionPayload.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ExecutionPayload: %w", err) } - - // Field (10) 'BlsToExecutionChanges' + // Field 10: BlsToExecutionChanges { + if len(c.BlsToExecutionChanges) > 16 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.BlsToExecutionChanges { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("BlsToExecutionChanges: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.BlsToExecutionChanges)), 16) } - hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the SignedBlindedBeaconBlockCapella object -func (s *SignedBlindedBeaconBlockCapella) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) +func (c *BeaconBlockCapella) SizeSSZ() int { + size := 84 + if c.Body == nil { + c.Body = new(BeaconBlockBodyCapella) + } + size += c.Body.SizeSSZ() + return size } -// MarshalSSZTo ssz marshals the SignedBlindedBeaconBlockCapella object to a target array -func (s *SignedBlindedBeaconBlockCapella) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(100) +func (c *BeaconBlockCapella) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Offset (0) 'Block' - dst = ssz.WriteOffset(dst, offset) - if s.Block == nil { - s.Block = new(BlindedBeaconBlockCapella) +func (c *BeaconBlockCapella) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 84 + + // Field 0: Slot + if dst, err = c.Slot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Slot: %w", err) + } + + // Field 1: ProposerIndex + if dst, err = c.ProposerIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ProposerIndex: %w", err) } - offset += s.Block.SizeSSZ() - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 2: ParentRoot + if len(c.ParentRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, s.Signature...) + dst = append(dst, c.ParentRoot...) - // Field (0) 'Block' - if dst, err = s.Block.MarshalSSZTo(dst); err != nil { - return + // Field 3: StateRoot + if len(c.StateRoot) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.StateRoot...) - return + // Field 4: Body + if c.Body == nil { + c.Body = new(BeaconBlockBodyCapella) + } + dst = ssz.WriteOffset(dst, offset) + offset += c.Body.SizeSSZ() + + // Field 4: Body + if dst, err = c.Body.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Body: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the SignedBlindedBeaconBlockCapella object -func (s *SignedBlindedBeaconBlockCapella) UnmarshalSSZ(buf []byte) error { +func (c *BeaconBlockCapella) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 100 { + if size < 84 { return ssz.ErrSize } - tail := buf - var o0 uint64 + sszSlice0 := buf[0:8] // c.Slot + sszSlice1 := buf[8:16] // c.ProposerIndex + sszSlice2 := buf[16:48] // c.ParentRoot + sszSlice3 := buf[48:80] // c.StateRoot - // Offset (0) 'Block' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { + sszVarOffset4 := ssz.ReadOffset(buf[80:84]) // c.Body + if sszVarOffset4 != 84 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset4 > size { return ssz.ErrOffset } + sszSlice4 := buf[sszVarOffset4:] // c.Body - if o0 != 100 { - return ssz.ErrInvalidVariableOffset + // Field 0: Slot + if err = c.Slot.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Slot: %w", err) } - // Field (1) 'Signature' - if cap(s.Signature) == 0 { - s.Signature = make([]byte, 0, len(buf[4:100])) + // Field 1: ProposerIndex + if err = c.ProposerIndex.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("ProposerIndex: %w", err) } - s.Signature = append(s.Signature, buf[4:100]...) - // Field (0) 'Block' - { - buf = tail[o0:] - if s.Block == nil { - s.Block = new(BlindedBeaconBlockCapella) - } - if err = s.Block.UnmarshalSSZ(buf); err != nil { - return err - } - } - return err -} + // Field 2: ParentRoot + c.ParentRoot = make([]byte, 0, 32) + c.ParentRoot = append(c.ParentRoot, sszSlice2...) -// SizeSSZ returns the ssz encoded size in bytes for the SignedBlindedBeaconBlockCapella object -func (s *SignedBlindedBeaconBlockCapella) SizeSSZ() (size int) { - size = 100 + // Field 3: StateRoot + c.StateRoot = make([]byte, 0, 32) + c.StateRoot = append(c.StateRoot, sszSlice3...) - // Field (0) 'Block' - if s.Block == nil { - s.Block = new(BlindedBeaconBlockCapella) + // Field 4: Body + c.Body = new(BeaconBlockBodyCapella) + if err = c.Body.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("Body: %w", err) } - size += s.Block.SizeSSZ() - - return + return err } -// HashTreeRoot ssz hashes the SignedBlindedBeaconBlockCapella object -func (s *SignedBlindedBeaconBlockCapella) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) +func (c *BeaconBlockCapella) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the SignedBlindedBeaconBlockCapella object with a hasher -func (s *SignedBlindedBeaconBlockCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *BeaconBlockCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Block' - if err = s.Block.HashTreeRootWith(hh); err != nil { - return + // Field 0: Slot + if err := c.Slot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Slot: %w", err) } - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 1: ProposerIndex + if err := c.ProposerIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ProposerIndex: %w", err) + } + // Field 2: ParentRoot + if len(c.ParentRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ParentRoot) + // Field 3: StateRoot + if len(c.StateRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.StateRoot) + // Field 4: Body + if err := c.Body.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Body: %w", err) } - hh.PutBytes(s.Signature) - hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the BlindedBeaconBlockCapella object -func (b *BlindedBeaconBlockCapella) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) +func (c *BeaconStateCapella) SizeSSZ() int { + size := 10253 + size += len(c.HistoricalRoots) * 32 + size += len(c.Eth1DataVotes) * 72 + size += len(c.Validators) * 121 + size += len(c.Balances) * 8 + size += len(c.PreviousEpochParticipation) + size += len(c.CurrentEpochParticipation) + size += len(c.InactivityScores) * 8 + if c.LatestExecutionPayloadHeader == nil { + c.LatestExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderCapella) + } + size += c.LatestExecutionPayloadHeader.SizeSSZ() + size += len(c.HistoricalSummaries) * 64 + return size } -// MarshalSSZTo ssz marshals the BlindedBeaconBlockCapella object to a target array -func (b *BlindedBeaconBlockCapella) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(84) +func (c *BeaconStateCapella) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (0) 'Slot' - dst = ssz.MarshalUint(dst, b.Slot) +func (c *BeaconStateCapella) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 10253 - // Field (1) 'ProposerIndex' - dst = ssz.MarshalUint(dst, b.ProposerIndex) + // Field 0: GenesisTime + dst = binary.LittleEndian.AppendUint64(dst, c.GenesisTime) - // Field (2) 'ParentRoot' - if size := len(b.ParentRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentRoot", size, 32) - return + // Field 1: GenesisValidatorsRoot + if len(c.GenesisValidatorsRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.ParentRoot...) + dst = append(dst, c.GenesisValidatorsRoot...) - // Field (3) 'StateRoot' - if size := len(b.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return + // Field 2: Slot + if dst, err = c.Slot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Slot: %w", err) } - dst = append(dst, b.StateRoot...) - // Offset (4) 'Body' - dst = ssz.WriteOffset(dst, offset) - if b.Body == nil { - b.Body = new(BlindedBeaconBlockBodyCapella) + // Field 3: Fork + if c.Fork == nil { + c.Fork = new(Fork) } - offset += b.Body.SizeSSZ() - - // Field (4) 'Body' - if dst, err = b.Body.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.Fork.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Fork: %w", err) } - return -} - -// UnmarshalSSZ ssz unmarshals the BlindedBeaconBlockCapella object -func (b *BlindedBeaconBlockCapella) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 84 { - return ssz.ErrSize + // Field 4: LatestBlockHeader + if c.LatestBlockHeader == nil { + c.LatestBlockHeader = new(BeaconBlockHeader) } - - tail := buf - var o4 uint64 - - // Field (0) 'Slot' - b.Slot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[0:8]) - - // Field (1) 'ProposerIndex' - b.ProposerIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[8:16]) - - // Field (2) 'ParentRoot' - if cap(b.ParentRoot) == 0 { - b.ParentRoot = make([]byte, 0, len(buf[16:48])) + if dst, err = c.LatestBlockHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("LatestBlockHeader: %w", err) } - 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])) + // Field 5: BlockRoots + if len(c.BlockRoots) != 64 { + return nil, ssz.ErrBytesLength } - b.StateRoot = append(b.StateRoot, buf[48:80]...) - - // Offset (4) 'Body' - if o4 = ssz.ReadOffset(buf[80:84]); o4 > size { - return ssz.ErrOffset + for _, o := range c.BlockRoots { + if len(o) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) } - if o4 != 84 { - return ssz.ErrInvalidVariableOffset + // Field 6: StateRoots + if len(c.StateRoots) != 64 { + return nil, ssz.ErrBytesLength } - - // Field (4) 'Body' - { - buf = tail[o4:] - if b.Body == nil { - b.Body = new(BlindedBeaconBlockBodyCapella) - } - if err = b.Body.UnmarshalSSZ(buf); err != nil { - return err + for _, o := range c.StateRoots { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, o...) } - return err -} -// SizeSSZ returns the ssz encoded size in bytes for the BlindedBeaconBlockCapella object -func (b *BlindedBeaconBlockCapella) SizeSSZ() (size int) { - size = 84 + // Field 7: HistoricalRoots + dst = ssz.WriteOffset(dst, offset) + offset += len(c.HistoricalRoots) * 32 - // Field (4) 'Body' - if b.Body == nil { - b.Body = new(BlindedBeaconBlockBodyCapella) + // Field 8: Eth1Data + if c.Eth1Data == nil { + c.Eth1Data = new(Eth1Data) + } + if dst, err = c.Eth1Data.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Eth1Data: %w", err) } - size += b.Body.SizeSSZ() - - return -} -// HashTreeRoot ssz hashes the BlindedBeaconBlockCapella object -func (b *BlindedBeaconBlockCapella) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) -} + // Field 9: Eth1DataVotes + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Eth1DataVotes) * 72 -// HashTreeRootWith ssz hashes the BlindedBeaconBlockCapella object with a hasher -func (b *BlindedBeaconBlockCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() + // Field 10: Eth1DepositIndex + dst = binary.LittleEndian.AppendUint64(dst, c.Eth1DepositIndex) - // Field (0) 'Slot' - ssz.PutUint(hh, b.Slot) + // Field 11: Validators + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Validators) * 121 - // Field (1) 'ProposerIndex' - ssz.PutUint(hh, b.ProposerIndex) + // Field 12: Balances + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Balances) * 8 - // Field (2) 'ParentRoot' - if size := len(b.ParentRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentRoot", size, 32) - return + // Field 13: RandaoMixes + if len(c.RandaoMixes) != 64 { + return nil, ssz.ErrBytesLength } - hh.PutBytes(b.ParentRoot) - - // Field (3) 'StateRoot' - if size := len(b.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return + for _, o := range c.RandaoMixes { + if len(o) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) } - hh.PutBytes(b.StateRoot) - // Field (4) 'Body' - if err = b.Body.HashTreeRootWith(hh); err != nil { - return + // Field 14: Slashings + if len(c.Slashings) != 64 { + return nil, ssz.ErrBytesLength + } + for _, o := range c.Slashings { + dst = binary.LittleEndian.AppendUint64(dst, o) } - hh.Merkleize(indx) - return -} + // Field 15: PreviousEpochParticipation + dst = ssz.WriteOffset(dst, offset) + offset += len(c.PreviousEpochParticipation) -// MarshalSSZ ssz marshals the BlindedBeaconBlockBodyCapella object -func (b *BlindedBeaconBlockBodyCapella) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} - -// MarshalSSZTo ssz marshals the BlindedBeaconBlockBodyCapella object to a target array -func (b *BlindedBeaconBlockBodyCapella) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(328) + // Field 16: CurrentEpochParticipation + dst = ssz.WriteOffset(dst, offset) + offset += len(c.CurrentEpochParticipation) - // Field (0) 'RandaoReveal' - if size := len(b.RandaoReveal); size != 96 { - err = ssz.ErrBytesLengthFn("--.RandaoReveal", size, 96) - return + // Field 17: JustificationBits + if len([]byte(c.JustificationBits)) != 1 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.RandaoReveal...) + dst = append(dst, []byte(c.JustificationBits)...) - // Field (1) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(Eth1Data) + // Field 18: PreviousJustifiedCheckpoint + if c.PreviousJustifiedCheckpoint == nil { + c.PreviousJustifiedCheckpoint = new(Checkpoint) } - if dst, err = b.Eth1Data.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.PreviousJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("PreviousJustifiedCheckpoint: %w", err) } - // Field (2) 'Graffiti' - if size := len(b.Graffiti); size != 32 { - err = ssz.ErrBytesLengthFn("--.Graffiti", size, 32) - return + // Field 19: CurrentJustifiedCheckpoint + if c.CurrentJustifiedCheckpoint == nil { + c.CurrentJustifiedCheckpoint = new(Checkpoint) } - 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() + if dst, err = c.CurrentJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("CurrentJustifiedCheckpoint: %w", err) } - // Offset (5) 'Attestations' - dst = ssz.WriteOffset(dst, offset) - for ii := 0; ii < len(b.Attestations); ii++ { - offset += 4 - offset += b.Attestations[ii].SizeSSZ() + // Field 20: FinalizedCheckpoint + if c.FinalizedCheckpoint == nil { + c.FinalizedCheckpoint = new(Checkpoint) + } + if dst, err = c.FinalizedCheckpoint.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("FinalizedCheckpoint: %w", err) } - // Offset (6) 'Deposits' + // Field 21: InactivityScores dst = ssz.WriteOffset(dst, offset) - offset += len(b.Deposits) * 1240 + offset += len(c.InactivityScores) * 8 - // Offset (7) 'VoluntaryExits' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.VoluntaryExits) * 112 + // Field 22: CurrentSyncCommittee + if c.CurrentSyncCommittee == nil { + c.CurrentSyncCommittee = new(SyncCommittee) + } + if dst, err = c.CurrentSyncCommittee.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("CurrentSyncCommittee: %w", err) + } - // Field (8) 'SyncAggregate' - if b.SyncAggregate == nil { - b.SyncAggregate = new(SyncAggregate) + // Field 23: NextSyncCommittee + if c.NextSyncCommittee == nil { + c.NextSyncCommittee = new(SyncCommittee) } - if dst, err = b.SyncAggregate.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.NextSyncCommittee.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("NextSyncCommittee: %w", err) } - // Offset (9) 'ExecutionPayloadHeader' + // Field 24: LatestExecutionPayloadHeader + if c.LatestExecutionPayloadHeader == nil { + c.LatestExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderCapella) + } dst = ssz.WriteOffset(dst, offset) - if b.ExecutionPayloadHeader == nil { - b.ExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderCapella) + offset += c.LatestExecutionPayloadHeader.SizeSSZ() + + // Field 25: NextWithdrawalIndex + dst = binary.LittleEndian.AppendUint64(dst, c.NextWithdrawalIndex) + + // Field 26: NextWithdrawalValidatorIndex + if dst, err = c.NextWithdrawalValidatorIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("NextWithdrawalValidatorIndex: %w", err) } - offset += b.ExecutionPayloadHeader.SizeSSZ() - // Offset (10) 'BlsToExecutionChanges' + // Field 27: HistoricalSummaries dst = ssz.WriteOffset(dst, offset) - offset += len(b.BlsToExecutionChanges) * 172 + offset += len(c.HistoricalSummaries) * 64 - // Field (3) 'ProposerSlashings' - if size := len(b.ProposerSlashings); size > 16 { - err = ssz.ErrListTooBigFn("--.ProposerSlashings", size, 16) - return + // Field 7: HistoricalRoots + if len(c.HistoricalRoots) > 16777216 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.ProposerSlashings); ii++ { - if dst, err = b.ProposerSlashings[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.HistoricalRoots { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, o...) } - // Field (4) 'AttesterSlashings' - if size := len(b.AttesterSlashings); size > 2 { - err = ssz.ErrListTooBigFn("--.AttesterSlashings", size, 2) - return + // Field 9: Eth1DataVotes + if len(c.Eth1DataVotes) > 32 { + return nil, ssz.ErrListTooBig } - { - 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 + for _, o := range c.Eth1DataVotes { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Eth1DataVotes: %w", err) } } - // Field (5) 'Attestations' - if size := len(b.Attestations); size > 128 { - err = ssz.ErrListTooBigFn("--.Attestations", size, 128) - return + // Field 11: Validators + if len(c.Validators) > 1099511627776 { + return nil, ssz.ErrListTooBig } - { - offset = 4 * len(b.Attestations) - for ii := 0; ii < len(b.Attestations); ii++ { - dst = ssz.WriteOffset(dst, offset) - offset += b.Attestations[ii].SizeSSZ() + for _, o := range c.Validators { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Validators: %w", err) } } - for ii := 0; ii < len(b.Attestations); ii++ { - if dst, err = b.Attestations[ii].MarshalSSZTo(dst); err != nil { - return - } + + // Field 12: Balances + if len(c.Balances) > 1099511627776 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.Balances { + dst = binary.LittleEndian.AppendUint64(dst, o) } - // Field (6) 'Deposits' - if size := len(b.Deposits); size > 16 { - err = ssz.ErrListTooBigFn("--.Deposits", size, 16) - return + // Field 15: PreviousEpochParticipation + if len(c.PreviousEpochParticipation) > 1099511627776 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.Deposits); ii++ { - if dst, err = b.Deposits[ii].MarshalSSZTo(dst); err != nil { - return - } + dst = append(dst, c.PreviousEpochParticipation...) + + // Field 16: CurrentEpochParticipation + if len(c.CurrentEpochParticipation) > 1099511627776 { + return nil, ssz.ErrListTooBig } + dst = append(dst, c.CurrentEpochParticipation...) - // Field (7) 'VoluntaryExits' - if size := len(b.VoluntaryExits); size > 16 { - err = ssz.ErrListTooBigFn("--.VoluntaryExits", size, 16) - return + // Field 21: InactivityScores + if len(c.InactivityScores) > 1099511627776 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.VoluntaryExits); ii++ { - if dst, err = b.VoluntaryExits[ii].MarshalSSZTo(dst); err != nil { - return - } + for _, o := range c.InactivityScores { + dst = binary.LittleEndian.AppendUint64(dst, o) } - // Field (9) 'ExecutionPayloadHeader' - if dst, err = b.ExecutionPayloadHeader.MarshalSSZTo(dst); err != nil { - return + // Field 24: LatestExecutionPayloadHeader + if dst, err = c.LatestExecutionPayloadHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("LatestExecutionPayloadHeader: %w", err) } - // Field (10) 'BlsToExecutionChanges' - if size := len(b.BlsToExecutionChanges); size > 16 { - err = ssz.ErrListTooBigFn("--.BlsToExecutionChanges", size, 16) - return + // Field 27: HistoricalSummaries + if len(c.HistoricalSummaries) > 16777216 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.BlsToExecutionChanges); ii++ { - if dst, err = b.BlsToExecutionChanges[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.HistoricalSummaries { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("HistoricalSummaries: %w", err) } } - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the BlindedBeaconBlockBodyCapella object -func (b *BlindedBeaconBlockBodyCapella) UnmarshalSSZ(buf []byte) error { +func (c *BeaconStateCapella) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 328 { + if size < 10253 { return ssz.ErrSize } - tail := buf - var o3, o4, o5, o6, o7, o9, o10 uint64 - - // Field (0) 'RandaoReveal' - if cap(b.RandaoReveal) == 0 { - b.RandaoReveal = make([]byte, 0, len(buf[0:96])) + sszSlice0 := buf[0:8] // c.GenesisTime + sszSlice1 := buf[8:40] // c.GenesisValidatorsRoot + sszSlice2 := buf[40:48] // c.Slot + sszSlice3 := buf[48:64] // c.Fork + sszSlice4 := buf[64:176] // c.LatestBlockHeader + sszSlice5 := buf[176:2224] // c.BlockRoots + sszSlice6 := buf[2224:4272] // c.StateRoots + sszSlice8 := buf[4276:4348] // c.Eth1Data + sszSlice10 := buf[4352:4360] // c.Eth1DepositIndex + sszSlice13 := buf[4368:6416] // c.RandaoMixes + sszSlice14 := buf[6416:6928] // c.Slashings + sszSlice17 := buf[6936:6937] // c.JustificationBits + sszSlice18 := buf[6937:6977] // c.PreviousJustifiedCheckpoint + sszSlice19 := buf[6977:7017] // c.CurrentJustifiedCheckpoint + sszSlice20 := buf[7017:7057] // c.FinalizedCheckpoint + sszSlice22 := buf[7061:8645] // c.CurrentSyncCommittee + sszSlice23 := buf[8645:10229] // c.NextSyncCommittee + sszSlice25 := buf[10233:10241] // c.NextWithdrawalIndex + sszSlice26 := buf[10241:10249] // c.NextWithdrawalValidatorIndex + + sszVarOffset7 := ssz.ReadOffset(buf[4272:4276]) // c.HistoricalRoots + if sszVarOffset7 != 10253 { + return ssz.ErrInvalidVariableOffset } - b.RandaoReveal = append(b.RandaoReveal, buf[0:96]...) - - // Field (1) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(Eth1Data) + if sszVarOffset7 > size { + return ssz.ErrOffset } - if err = b.Eth1Data.UnmarshalSSZ(buf[96:168]); err != nil { - return err + sszVarOffset9 := ssz.ReadOffset(buf[4348:4352]) // c.Eth1DataVotes + if sszVarOffset9 > size || sszVarOffset9 < sszVarOffset7 { + return ssz.ErrOffset } - - // Field (2) 'Graffiti' - if cap(b.Graffiti) == 0 { - b.Graffiti = make([]byte, 0, len(buf[168:200])) + sszVarOffset11 := ssz.ReadOffset(buf[4360:4364]) // c.Validators + if sszVarOffset11 > size || sszVarOffset11 < sszVarOffset9 { + return ssz.ErrOffset } - b.Graffiti = append(b.Graffiti, buf[168:200]...) - - // Offset (3) 'ProposerSlashings' - if o3 = ssz.ReadOffset(buf[200:204]); o3 > size { + sszVarOffset12 := ssz.ReadOffset(buf[4364:4368]) // c.Balances + if sszVarOffset12 > size || sszVarOffset12 < sszVarOffset11 { return ssz.ErrOffset } - - if o3 != 328 { - return ssz.ErrInvalidVariableOffset + sszVarOffset15 := ssz.ReadOffset(buf[6928:6932]) // c.PreviousEpochParticipation + if sszVarOffset15 > size || sszVarOffset15 < sszVarOffset12 { + return ssz.ErrOffset } - - // Offset (4) 'AttesterSlashings' - if o4 = ssz.ReadOffset(buf[204:208]); o4 > size || o3 > o4 { + sszVarOffset16 := ssz.ReadOffset(buf[6932:6936]) // c.CurrentEpochParticipation + if sszVarOffset16 > size || sszVarOffset16 < sszVarOffset15 { return ssz.ErrOffset } - - // Offset (5) 'Attestations' - if o5 = ssz.ReadOffset(buf[208:212]); o5 > size || o4 > o5 { + sszVarOffset21 := ssz.ReadOffset(buf[7057:7061]) // c.InactivityScores + if sszVarOffset21 > size || sszVarOffset21 < sszVarOffset16 { return ssz.ErrOffset } - - // Offset (6) 'Deposits' - if o6 = ssz.ReadOffset(buf[212:216]); o6 > size || o5 > o6 { + sszVarOffset24 := ssz.ReadOffset(buf[10229:10233]) // c.LatestExecutionPayloadHeader + if sszVarOffset24 > size || sszVarOffset24 < sszVarOffset21 { return ssz.ErrOffset } - - // Offset (7) 'VoluntaryExits' - if o7 = ssz.ReadOffset(buf[216:220]); o7 > size || o6 > o7 { + sszVarOffset27 := ssz.ReadOffset(buf[10249:10253]) // c.HistoricalSummaries + if sszVarOffset27 > size || sszVarOffset27 < sszVarOffset24 { return ssz.ErrOffset } + sszSlice7 := buf[sszVarOffset7:sszVarOffset9] // c.HistoricalRoots + sszSlice9 := buf[sszVarOffset9:sszVarOffset11] // c.Eth1DataVotes + sszSlice11 := buf[sszVarOffset11:sszVarOffset12] // c.Validators + sszSlice12 := buf[sszVarOffset12:sszVarOffset15] // c.Balances + sszSlice15 := buf[sszVarOffset15:sszVarOffset16] // c.PreviousEpochParticipation + sszSlice16 := buf[sszVarOffset16:sszVarOffset21] // c.CurrentEpochParticipation + sszSlice21 := buf[sszVarOffset21:sszVarOffset24] // c.InactivityScores + sszSlice24 := buf[sszVarOffset24:sszVarOffset27] // c.LatestExecutionPayloadHeader + sszSlice27 := buf[sszVarOffset27:] // c.HistoricalSummaries - // Field (8) 'SyncAggregate' - if b.SyncAggregate == nil { - b.SyncAggregate = new(SyncAggregate) - } - if err = b.SyncAggregate.UnmarshalSSZ(buf[220:320]); err != nil { - return err + // Field 0: GenesisTime + c.GenesisTime = binary.LittleEndian.Uint64(sszSlice0) + + // Field 1: GenesisValidatorsRoot + c.GenesisValidatorsRoot = make([]byte, 0, 32) + c.GenesisValidatorsRoot = append(c.GenesisValidatorsRoot, sszSlice1...) + + // Field 2: Slot + if err = c.Slot.UnmarshalSSZ(sszSlice2); err != nil { + return fmt.Errorf("Slot: %w", err) } - // Offset (9) 'ExecutionPayloadHeader' - if o9 = ssz.ReadOffset(buf[320:324]); o9 > size || o7 > o9 { - return ssz.ErrOffset + // Field 3: Fork + c.Fork = new(Fork) + if err = c.Fork.UnmarshalSSZ(sszSlice3); err != nil { + return fmt.Errorf("Fork: %w", err) } - // Offset (10) 'BlsToExecutionChanges' - if o10 = ssz.ReadOffset(buf[324:328]); o10 > size || o9 > o10 { - return ssz.ErrOffset + // Field 4: LatestBlockHeader + c.LatestBlockHeader = new(BeaconBlockHeader) + if err = c.LatestBlockHeader.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("LatestBlockHeader: %w", err) } - // Field (3) 'ProposerSlashings' + // Field 5: BlockRoots { - buf = tail[o3:o4] - num, err := ssz.DivideInt2(len(buf), 416, 16) - if err != nil { - return err - } - b.ProposerSlashings = make([]*ProposerSlashing, num) - for ii := 0; ii < num; ii++ { - if b.ProposerSlashings[ii] == nil { - b.ProposerSlashings[ii] = new(ProposerSlashing) - } - if err = b.ProposerSlashings[ii].UnmarshalSSZ(buf[ii*416 : (ii+1)*416]); err != nil { - return err - } + c.BlockRoots = make([][]byte, 64) + for i := 0; i < 64; i++ { + var tmp []byte + + tmpSlice := sszSlice5[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.BlockRoots[i] = tmp } } - // Field (4) 'AttesterSlashings' + // Field 6: StateRoots { - buf = tail[o4:o5] - num, err := ssz.DecodeDynamicLength(buf, 2) - 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 + c.StateRoots = make([][]byte, 64) + for i := 0; i < 64; i++ { + var tmp []byte + + tmpSlice := sszSlice6[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.StateRoots[i] = tmp } } - // Field (5) 'Attestations' + // Field 7: HistoricalRoots { - buf = tail[o5:o6] - num, err := ssz.DecodeDynamicLength(buf, 128) - 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 + if len(sszSlice7)%32 != 0 { + return fmt.Errorf("misaligned bytes: c.HistoricalRoots length is %d, which is not a multiple of 32: %w", len(sszSlice7), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice7) / 32 + if numElem > 16777216 { + return fmt.Errorf("ssz-max exceeded: c.HistoricalRoots has %d elements, ssz-max is 16777216: %w", numElem, ssz.ErrListTooBig) } + c.HistoricalRoots = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte + + tmpSlice := sszSlice7[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.HistoricalRoots[i] = tmp + } + } + + // Field 8: Eth1Data + c.Eth1Data = new(Eth1Data) + if err = c.Eth1Data.UnmarshalSSZ(sszSlice8); err != nil { + return fmt.Errorf("Eth1Data: %w", err) } - // Field (6) 'Deposits' + // Field 9: Eth1DataVotes { - buf = tail[o6:o7] - num, err := ssz.DivideInt2(len(buf), 1240, 16) - if err != nil { - return err - } - b.Deposits = make([]*Deposit, num) - for ii := 0; ii < num; ii++ { - if b.Deposits[ii] == nil { - b.Deposits[ii] = new(Deposit) - } - if err = b.Deposits[ii].UnmarshalSSZ(buf[ii*1240 : (ii+1)*1240]); err != nil { - return err + if len(sszSlice9)%72 != 0 { + return fmt.Errorf("misaligned bytes: c.Eth1DataVotes length is %d, which is not a multiple of 72: %w", len(sszSlice9), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice9) / 72 + if numElem > 32 { + return fmt.Errorf("ssz-max exceeded: c.Eth1DataVotes has %d elements, ssz-max is 32: %w", numElem, ssz.ErrListTooBig) + } + c.Eth1DataVotes = make([]*Eth1Data, numElem) + for i := 0; i < numElem; i++ { + var tmp *Eth1Data + tmp = new(Eth1Data) + tmpSlice := sszSlice9[i*72 : (1+i)*72] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Eth1DataVotes: %w", err) } + c.Eth1DataVotes[i] = tmp } } - // Field (7) 'VoluntaryExits' + // Field 10: Eth1DepositIndex + c.Eth1DepositIndex = binary.LittleEndian.Uint64(sszSlice10) + + // Field 11: Validators { - buf = tail[o7:o9] - num, err := ssz.DivideInt2(len(buf), 112, 16) - if err != nil { - return err - } - b.VoluntaryExits = make([]*SignedVoluntaryExit, num) - for ii := 0; ii < num; ii++ { - if b.VoluntaryExits[ii] == nil { - b.VoluntaryExits[ii] = new(SignedVoluntaryExit) - } - if err = b.VoluntaryExits[ii].UnmarshalSSZ(buf[ii*112 : (ii+1)*112]); err != nil { - return err + if len(sszSlice11)%121 != 0 { + return fmt.Errorf("misaligned bytes: c.Validators length is %d, which is not a multiple of 121: %w", len(sszSlice11), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice11) / 121 + if numElem > 1099511627776 { + return fmt.Errorf("ssz-max exceeded: c.Validators has %d elements, ssz-max is 1099511627776: %w", numElem, ssz.ErrListTooBig) + } + c.Validators = make([]*Validator, numElem) + for i := 0; i < numElem; i++ { + var tmp *Validator + tmp = new(Validator) + tmpSlice := sszSlice11[i*121 : (1+i)*121] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Validators: %w", err) } + c.Validators[i] = tmp } } - // Field (9) 'ExecutionPayloadHeader' + // Field 12: Balances { - buf = tail[o9:o10] - if b.ExecutionPayloadHeader == nil { - b.ExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderCapella) + if len(sszSlice12)%8 != 0 { + return fmt.Errorf("misaligned bytes: c.Balances length is %d, which is not a multiple of 8: %w", len(sszSlice12), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice12) / 8 + if numElem > 1099511627776 { + return fmt.Errorf("ssz-max exceeded: c.Balances has %d elements, ssz-max is 1099511627776: %w", numElem, ssz.ErrListTooBig) } - if err = b.ExecutionPayloadHeader.UnmarshalSSZ(buf); err != nil { - return err + c.Balances = make([]uint64, numElem) + for i := 0; i < numElem; i++ { + var tmp uint64 + + tmpSlice := sszSlice12[i*8 : (1+i)*8] + tmp = binary.LittleEndian.Uint64(tmpSlice) + c.Balances[i] = tmp } } - // Field (10) 'BlsToExecutionChanges' + // Field 13: RandaoMixes { - buf = tail[o10:] - num, err := ssz.DivideInt2(len(buf), 172, 16) - if err != nil { - return err - } - b.BlsToExecutionChanges = make([]*SignedBLSToExecutionChange, num) - for ii := 0; ii < num; ii++ { - if b.BlsToExecutionChanges[ii] == nil { - b.BlsToExecutionChanges[ii] = new(SignedBLSToExecutionChange) - } - if err = b.BlsToExecutionChanges[ii].UnmarshalSSZ(buf[ii*172 : (ii+1)*172]); err != nil { - return err - } + c.RandaoMixes = make([][]byte, 64) + for i := 0; i < 64; i++ { + var tmp []byte + + tmpSlice := sszSlice13[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.RandaoMixes[i] = tmp } } - return err -} -// SizeSSZ returns the ssz encoded size in bytes for the BlindedBeaconBlockBodyCapella object -func (b *BlindedBeaconBlockBodyCapella) SizeSSZ() (size int) { - size = 328 + // Field 14: Slashings + { + c.Slashings = make([]uint64, 64) + for i := 0; i < 64; i++ { + var tmp uint64 + + tmpSlice := sszSlice14[i*8 : (1+i)*8] + tmp = binary.LittleEndian.Uint64(tmpSlice) + c.Slashings[i] = tmp + } + } - // Field (3) 'ProposerSlashings' - size += len(b.ProposerSlashings) * 416 + // Field 15: PreviousEpochParticipation + c.PreviousEpochParticipation = append([]byte{}, sszSlice15...) - // Field (4) 'AttesterSlashings' - for ii := 0; ii < len(b.AttesterSlashings); ii++ { - size += 4 - size += b.AttesterSlashings[ii].SizeSSZ() + // Field 16: CurrentEpochParticipation + c.CurrentEpochParticipation = append([]byte{}, sszSlice16...) + + // Field 17: JustificationBits + c.JustificationBits = make([]byte, 0, 1) + c.JustificationBits = append(c.JustificationBits, go_bitfield.Bitvector4(sszSlice17)...) + + // Field 18: PreviousJustifiedCheckpoint + c.PreviousJustifiedCheckpoint = new(Checkpoint) + if err = c.PreviousJustifiedCheckpoint.UnmarshalSSZ(sszSlice18); err != nil { + return fmt.Errorf("PreviousJustifiedCheckpoint: %w", err) } - // Field (5) 'Attestations' - for ii := 0; ii < len(b.Attestations); ii++ { - size += 4 - size += b.Attestations[ii].SizeSSZ() + // Field 19: CurrentJustifiedCheckpoint + c.CurrentJustifiedCheckpoint = new(Checkpoint) + if err = c.CurrentJustifiedCheckpoint.UnmarshalSSZ(sszSlice19); err != nil { + return fmt.Errorf("CurrentJustifiedCheckpoint: %w", err) } - // Field (6) 'Deposits' - size += len(b.Deposits) * 1240 + // Field 20: FinalizedCheckpoint + c.FinalizedCheckpoint = new(Checkpoint) + if err = c.FinalizedCheckpoint.UnmarshalSSZ(sszSlice20); err != nil { + return fmt.Errorf("FinalizedCheckpoint: %w", err) + } - // Field (7) 'VoluntaryExits' - size += len(b.VoluntaryExits) * 112 + // Field 21: InactivityScores + { + if len(sszSlice21)%8 != 0 { + return fmt.Errorf("misaligned bytes: c.InactivityScores length is %d, which is not a multiple of 8: %w", len(sszSlice21), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice21) / 8 + if numElem > 1099511627776 { + return fmt.Errorf("ssz-max exceeded: c.InactivityScores has %d elements, ssz-max is 1099511627776: %w", numElem, ssz.ErrListTooBig) + } + c.InactivityScores = make([]uint64, numElem) + for i := 0; i < numElem; i++ { + var tmp uint64 - // Field (9) 'ExecutionPayloadHeader' - if b.ExecutionPayloadHeader == nil { - b.ExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderCapella) + tmpSlice := sszSlice21[i*8 : (1+i)*8] + tmp = binary.LittleEndian.Uint64(tmpSlice) + c.InactivityScores[i] = tmp + } } - size += b.ExecutionPayloadHeader.SizeSSZ() - // Field (10) 'BlsToExecutionChanges' - size += len(b.BlsToExecutionChanges) * 172 + // Field 22: CurrentSyncCommittee + c.CurrentSyncCommittee = new(SyncCommittee) + if err = c.CurrentSyncCommittee.UnmarshalSSZ(sszSlice22); err != nil { + return fmt.Errorf("CurrentSyncCommittee: %w", err) + } - return -} + // Field 23: NextSyncCommittee + c.NextSyncCommittee = new(SyncCommittee) + if err = c.NextSyncCommittee.UnmarshalSSZ(sszSlice23); err != nil { + return fmt.Errorf("NextSyncCommittee: %w", err) + } -// HashTreeRoot ssz hashes the BlindedBeaconBlockBodyCapella object -func (b *BlindedBeaconBlockBodyCapella) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) -} + // Field 24: LatestExecutionPayloadHeader + c.LatestExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderCapella) + if err = c.LatestExecutionPayloadHeader.UnmarshalSSZ(sszSlice24); err != nil { + return fmt.Errorf("LatestExecutionPayloadHeader: %w", err) + } -// HashTreeRootWith ssz hashes the BlindedBeaconBlockBodyCapella object with a hasher -func (b *BlindedBeaconBlockBodyCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() + // Field 25: NextWithdrawalIndex + c.NextWithdrawalIndex = binary.LittleEndian.Uint64(sszSlice25) - // Field (0) 'RandaoReveal' - if size := len(b.RandaoReveal); size != 96 { - err = ssz.ErrBytesLengthFn("--.RandaoReveal", size, 96) - return + // Field 26: NextWithdrawalValidatorIndex + if err = c.NextWithdrawalValidatorIndex.UnmarshalSSZ(sszSlice26); err != nil { + return fmt.Errorf("NextWithdrawalValidatorIndex: %w", err) } - hh.PutBytes(b.RandaoReveal) - // Field (1) 'Eth1Data' - if err = b.Eth1Data.HashTreeRootWith(hh); err != nil { - return + // Field 27: HistoricalSummaries + { + if len(sszSlice27)%64 != 0 { + return fmt.Errorf("misaligned bytes: c.HistoricalSummaries length is %d, which is not a multiple of 64: %w", len(sszSlice27), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice27) / 64 + if numElem > 16777216 { + return fmt.Errorf("ssz-max exceeded: c.HistoricalSummaries has %d elements, ssz-max is 16777216: %w", numElem, ssz.ErrListTooBig) + } + c.HistoricalSummaries = make([]*HistoricalSummary, numElem) + for i := 0; i < numElem; i++ { + var tmp *HistoricalSummary + tmp = new(HistoricalSummary) + tmpSlice := sszSlice27[i*64 : (1+i)*64] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("HistoricalSummaries: %w", err) + } + c.HistoricalSummaries[i] = tmp + } } + return err +} - // Field (2) 'Graffiti' - if size := len(b.Graffiti); size != 32 { - err = ssz.ErrBytesLengthFn("--.Graffiti", size, 32) - return +func (c *BeaconStateCapella) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - hh.PutBytes(b.Graffiti) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (3) 'ProposerSlashings' +func (c *BeaconStateCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: GenesisTime + hh.PutUint64(c.GenesisTime) + // Field 1: GenesisValidatorsRoot + if len(c.GenesisValidatorsRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.GenesisValidatorsRoot) + // Field 2: Slot + if err := c.Slot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Slot: %w", err) + } + // Field 3: Fork + if err := c.Fork.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Fork: %w", err) + } + // Field 4: LatestBlockHeader + if err := c.LatestBlockHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("LatestBlockHeader: %w", err) + } + // Field 5: BlockRoots { + if len(c.BlockRoots) != 64 { + return ssz.ErrVectorLength + } 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 + for _, o := range c.BlockRoots { + if len(o) != 32 { + return ssz.ErrBytesLength } + hh.Append(o) } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.Merkleize(subIndx) } - - // Field (4) 'AttesterSlashings' + // Field 6: StateRoots { + if len(c.StateRoots) != 64 { + return ssz.ErrVectorLength + } 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 + for _, o := range c.StateRoots { + if len(o) != 32 { + return ssz.ErrBytesLength } + hh.Append(o) } - hh.MerkleizeWithMixin(subIndx, num, 2) + hh.Merkleize(subIndx) } - - // Field (5) 'Attestations' + // Field 7: HistoricalRoots { + if len(c.HistoricalRoots) > 16777216 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.HistoricalRoots { + if len(o) != 32 { + return ssz.ErrBytesLength } + hh.Append(o) } - hh.MerkleizeWithMixin(subIndx, num, 128) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.HistoricalRoots)), 16777216) } - - // Field (6) 'Deposits' + // Field 8: Eth1Data + if err := c.Eth1Data.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Eth1Data: %w", err) + } + // Field 9: Eth1DataVotes { + if len(c.Eth1DataVotes) > 32 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.Eth1DataVotes { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Eth1DataVotes: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Eth1DataVotes)), 32) } - - // Field (7) 'VoluntaryExits' + // Field 10: Eth1DepositIndex + hh.PutUint64(c.Eth1DepositIndex) + // Field 11: Validators { + if len(c.Validators) > 1099511627776 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.Validators { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Validators: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 16) - } - - // Field (8) 'SyncAggregate' - if err = b.SyncAggregate.HashTreeRootWith(hh); err != nil { - return + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Validators)), 1099511627776) } - - // Field (9) 'ExecutionPayloadHeader' - if err = b.ExecutionPayloadHeader.HashTreeRootWith(hh); err != nil { - return + // Field 12: Balances + { + if len(c.Balances) > 1099511627776 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.Balances { + hh.AppendUint64(o) + } + hh.FillUpTo32() + numItems := uint64(len(c.Balances)) + hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(1099511627776, numItems, 8)) } - - // Field (10) 'BlsToExecutionChanges' + // Field 13: RandaoMixes { + if len(c.RandaoMixes) != 64 { + return ssz.ErrVectorLength + } 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 + for _, o := range c.RandaoMixes { + if len(o) != 32 { + return ssz.ErrBytesLength } + hh.Append(o) } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.Merkleize(subIndx) } + // Field 14: Slashings + { + if len(c.Slashings) != 64 { + return ssz.ErrVectorLength + } + subIndx := hh.Index() + for _, o := range c.Slashings { + hh.AppendUint64(o) + } + hh.Merkleize(subIndx) + } + // Field 15: PreviousEpochParticipation - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the SignedBuilderBidCapella object -func (s *SignedBuilderBidCapella) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) -} + { + if len(c.PreviousEpochParticipation) > 1099511627776 { + return ssz.ErrBytesLength + } + subIndx := hh.Index() + hh.AppendBytes32(c.PreviousEpochParticipation) + numItems := uint64(len(c.PreviousEpochParticipation)) + hh.MerkleizeWithMixin(subIndx, numItems, (1099511627776*1+31)/32) + } -// MarshalSSZTo ssz marshals the SignedBuilderBidCapella object to a target array -func (s *SignedBuilderBidCapella) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(100) + // Field 16: CurrentEpochParticipation - // Offset (0) 'Message' - dst = ssz.WriteOffset(dst, offset) - if s.Message == nil { - s.Message = new(BuilderBidCapella) + { + if len(c.CurrentEpochParticipation) > 1099511627776 { + return ssz.ErrBytesLength + } + subIndx := hh.Index() + hh.AppendBytes32(c.CurrentEpochParticipation) + numItems := uint64(len(c.CurrentEpochParticipation)) + hh.MerkleizeWithMixin(subIndx, numItems, (1099511627776*1+31)/32) } - offset += s.Message.SizeSSZ() - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 17: JustificationBits + if len([]byte(c.JustificationBits)) != 1 { + return ssz.ErrBytesLength } - dst = append(dst, s.Signature...) - - // Field (0) 'Message' - if dst, err = s.Message.MarshalSSZTo(dst); err != nil { - return + hh.PutBytes([]byte(c.JustificationBits)) + // Field 18: PreviousJustifiedCheckpoint + if err := c.PreviousJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("PreviousJustifiedCheckpoint: %w", err) } - - return -} - -// UnmarshalSSZ ssz unmarshals the SignedBuilderBidCapella object -func (s *SignedBuilderBidCapella) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 100 { - return ssz.ErrSize + // Field 19: CurrentJustifiedCheckpoint + if err := c.CurrentJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("CurrentJustifiedCheckpoint: %w", err) } - - tail := buf - var o0 uint64 - - // Offset (0) 'Message' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset + // Field 20: FinalizedCheckpoint + if err := c.FinalizedCheckpoint.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("FinalizedCheckpoint: %w", err) } - - if o0 != 100 { - return ssz.ErrInvalidVariableOffset + // Field 21: InactivityScores + { + if len(c.InactivityScores) > 1099511627776 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.InactivityScores { + hh.AppendUint64(o) + } + hh.FillUpTo32() + numItems := uint64(len(c.InactivityScores)) + hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(1099511627776, numItems, 8)) } - - // Field (1) 'Signature' - if cap(s.Signature) == 0 { - s.Signature = make([]byte, 0, len(buf[4:100])) + // Field 22: CurrentSyncCommittee + if err := c.CurrentSyncCommittee.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("CurrentSyncCommittee: %w", err) } - s.Signature = append(s.Signature, buf[4:100]...) - - // Field (0) 'Message' + // Field 23: NextSyncCommittee + if err := c.NextSyncCommittee.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("NextSyncCommittee: %w", err) + } + // Field 24: LatestExecutionPayloadHeader + if err := c.LatestExecutionPayloadHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("LatestExecutionPayloadHeader: %w", err) + } + // Field 25: NextWithdrawalIndex + hh.PutUint64(c.NextWithdrawalIndex) + // Field 26: NextWithdrawalValidatorIndex + if err := c.NextWithdrawalValidatorIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("NextWithdrawalValidatorIndex: %w", err) + } + // Field 27: HistoricalSummaries { - buf = tail[o0:] - if s.Message == nil { - s.Message = new(BuilderBidCapella) + if len(c.HistoricalSummaries) > 16777216 { + return ssz.ErrListTooBig } - if err = s.Message.UnmarshalSSZ(buf); err != nil { - return err + subIndx := hh.Index() + for _, o := range c.HistoricalSummaries { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("HistoricalSummaries: %w", err) + } } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.HistoricalSummaries)), 16777216) } - return err + hh.Merkleize(indx) + return nil } -// SizeSSZ returns the ssz encoded size in bytes for the SignedBuilderBidCapella object -func (s *SignedBuilderBidCapella) SizeSSZ() (size int) { - size = 100 - - // Field (0) 'Message' - if s.Message == nil { - s.Message = new(BuilderBidCapella) +func (c *BlindedBeaconBlockBodyCapella) SizeSSZ() int { + size := 328 + size += len(c.ProposerSlashings) * 416 + for _, o := range c.AttesterSlashings { + size += 4 + size += o.SizeSSZ() } - size += s.Message.SizeSSZ() - - return + for _, o := range c.Attestations { + size += 4 + size += o.SizeSSZ() + } + size += len(c.Deposits) * 1240 + size += len(c.VoluntaryExits) * 112 + if c.ExecutionPayloadHeader == nil { + c.ExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderCapella) + } + size += c.ExecutionPayloadHeader.SizeSSZ() + size += len(c.BlsToExecutionChanges) * 172 + return size } -// HashTreeRoot ssz hashes the SignedBuilderBidCapella object -func (s *SignedBuilderBidCapella) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) +func (c *BlindedBeaconBlockBodyCapella) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// HashTreeRootWith ssz hashes the SignedBuilderBidCapella object with a hasher -func (s *SignedBuilderBidCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() +func (c *BlindedBeaconBlockBodyCapella) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 328 - // Field (0) 'Message' - if err = s.Message.HashTreeRootWith(hh); err != nil { - return + // Field 0: RandaoReveal + if len(c.RandaoReveal) != 96 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.RandaoReveal...) - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 1: Eth1Data + if c.Eth1Data == nil { + c.Eth1Data = new(Eth1Data) + } + if dst, err = c.Eth1Data.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Eth1Data: %w", err) } - hh.PutBytes(s.Signature) - - hh.Merkleize(indx) - return -} -// MarshalSSZ ssz marshals the BuilderBidCapella object -func (b *BuilderBidCapella) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} + // Field 2: Graffiti + if len(c.Graffiti) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.Graffiti...) -// MarshalSSZTo ssz marshals the BuilderBidCapella object to a target array -func (b *BuilderBidCapella) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(84) + // Field 3: ProposerSlashings + dst = ssz.WriteOffset(dst, offset) + offset += len(c.ProposerSlashings) * 416 - // Offset (0) 'Header' + // Field 4: AttesterSlashings dst = ssz.WriteOffset(dst, offset) - if b.Header == nil { - b.Header = new(v1.ExecutionPayloadHeaderCapella) + for _, o := range c.AttesterSlashings { + offset += 4 + offset += o.SizeSSZ() } - offset += b.Header.SizeSSZ() - // Field (1) 'Value' - if size := len(b.Value); size != 32 { - err = ssz.ErrBytesLengthFn("--.Value", size, 32) - return + // Field 5: Attestations + dst = ssz.WriteOffset(dst, offset) + for _, o := range c.Attestations { + offset += 4 + offset += o.SizeSSZ() } - dst = append(dst, b.Value...) - // Field (2) 'Pubkey' - if size := len(b.Pubkey); size != 48 { - err = ssz.ErrBytesLengthFn("--.Pubkey", size, 48) - return - } - dst = append(dst, b.Pubkey...) + // Field 6: Deposits + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Deposits) * 1240 - // Field (0) 'Header' - if dst, err = b.Header.MarshalSSZTo(dst); err != nil { - return - } + // Field 7: VoluntaryExits + dst = ssz.WriteOffset(dst, offset) + offset += len(c.VoluntaryExits) * 112 - return -} + // Field 8: SyncAggregate + if c.SyncAggregate == nil { + c.SyncAggregate = new(SyncAggregate) + } + if dst, err = c.SyncAggregate.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SyncAggregate: %w", err) + } -// UnmarshalSSZ ssz unmarshals the BuilderBidCapella object -func (b *BuilderBidCapella) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 84 { - return ssz.ErrSize + // Field 9: ExecutionPayloadHeader + if c.ExecutionPayloadHeader == nil { + c.ExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderCapella) } + dst = ssz.WriteOffset(dst, offset) + offset += c.ExecutionPayloadHeader.SizeSSZ() - tail := buf - var o0 uint64 + // Field 10: BlsToExecutionChanges + dst = ssz.WriteOffset(dst, offset) + offset += len(c.BlsToExecutionChanges) * 172 - // Offset (0) 'Header' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset + // Field 3: ProposerSlashings + if len(c.ProposerSlashings) > 16 { + return nil, ssz.ErrListTooBig } - - if o0 != 84 { - return ssz.ErrInvalidVariableOffset + for _, o := range c.ProposerSlashings { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ProposerSlashings: %w", err) + } } - // Field (1) 'Value' - if cap(b.Value) == 0 { - b.Value = make([]byte, 0, len(buf[4:36])) + // Field 4: AttesterSlashings + if len(c.AttesterSlashings) > 2 { + return nil, ssz.ErrListTooBig } - b.Value = append(b.Value, buf[4:36]...) - - // Field (2) 'Pubkey' - if cap(b.Pubkey) == 0 { - b.Pubkey = make([]byte, 0, len(buf[36:84])) + { + offset = 4 * len(c.AttesterSlashings) + for _, o := range c.AttesterSlashings { + dst = ssz.WriteOffset(dst, offset) + offset += o.SizeSSZ() + } + } + for _, o := range c.AttesterSlashings { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("AttesterSlashings: %w", err) + } } - b.Pubkey = append(b.Pubkey, buf[36:84]...) - // Field (0) 'Header' + // Field 5: Attestations + if len(c.Attestations) > 128 { + return nil, ssz.ErrListTooBig + } { - buf = tail[o0:] - if b.Header == nil { - b.Header = new(v1.ExecutionPayloadHeaderCapella) + offset = 4 * len(c.Attestations) + for _, o := range c.Attestations { + dst = ssz.WriteOffset(dst, offset) + offset += o.SizeSSZ() } - if err = b.Header.UnmarshalSSZ(buf); err != nil { - return err + } + for _, o := range c.Attestations { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Attestations: %w", err) } } - return err -} -// SizeSSZ returns the ssz encoded size in bytes for the BuilderBidCapella object -func (b *BuilderBidCapella) SizeSSZ() (size int) { - size = 84 - - // Field (0) 'Header' - if b.Header == nil { - b.Header = new(v1.ExecutionPayloadHeaderCapella) + // Field 6: Deposits + if len(c.Deposits) > 16 { + return nil, ssz.ErrListTooBig } - size += b.Header.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the BuilderBidCapella object -func (b *BuilderBidCapella) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) -} - -// HashTreeRootWith ssz hashes the BuilderBidCapella object with a hasher -func (b *BuilderBidCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'Header' - if err = b.Header.HashTreeRootWith(hh); err != nil { - return + for _, o := range c.Deposits { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Deposits: %w", err) + } } - // Field (1) 'Value' - if size := len(b.Value); size != 32 { - err = ssz.ErrBytesLengthFn("--.Value", size, 32) - return + // Field 7: VoluntaryExits + if len(c.VoluntaryExits) > 16 { + return nil, ssz.ErrListTooBig } - hh.PutBytes(b.Value) - - // Field (2) 'Pubkey' - if size := len(b.Pubkey); size != 48 { - err = ssz.ErrBytesLengthFn("--.Pubkey", size, 48) - return + for _, o := range c.VoluntaryExits { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("VoluntaryExits: %w", err) + } } - hh.PutBytes(b.Pubkey) - - hh.Merkleize(indx) - return -} - -// 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' - if size := len(h.BlockSummaryRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockSummaryRoot", size, 32) - return + // Field 9: ExecutionPayloadHeader + if dst, err = c.ExecutionPayloadHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ExecutionPayloadHeader: %w", err) } - dst = append(dst, h.BlockSummaryRoot...) - // Field (1) 'StateSummaryRoot' - if size := len(h.StateSummaryRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateSummaryRoot", size, 32) - return + // Field 10: BlsToExecutionChanges + if len(c.BlsToExecutionChanges) > 16 { + return nil, ssz.ErrListTooBig } - dst = append(dst, h.StateSummaryRoot...) - - return + for _, o := range c.BlsToExecutionChanges { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("BlsToExecutionChanges: %w", err) + } + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the HistoricalSummary object -func (h *HistoricalSummary) UnmarshalSSZ(buf []byte) error { +func (c *BlindedBeaconBlockBodyCapella) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 64 { + if size < 328 { return ssz.ErrSize } - // Field (0) 'BlockSummaryRoot' - if cap(h.BlockSummaryRoot) == 0 { - h.BlockSummaryRoot = make([]byte, 0, len(buf[0:32])) - } - h.BlockSummaryRoot = append(h.BlockSummaryRoot, buf[0:32]...) + sszSlice0 := buf[0:96] // c.RandaoReveal + sszSlice1 := buf[96:168] // c.Eth1Data + sszSlice2 := buf[168:200] // c.Graffiti + sszSlice8 := buf[220:320] // c.SyncAggregate - // Field (1) 'StateSummaryRoot' - if cap(h.StateSummaryRoot) == 0 { - h.StateSummaryRoot = make([]byte, 0, len(buf[32:64])) + sszVarOffset3 := ssz.ReadOffset(buf[200:204]) // c.ProposerSlashings + if sszVarOffset3 != 328 { + return ssz.ErrInvalidVariableOffset } - h.StateSummaryRoot = append(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.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'BlockSummaryRoot' - if size := len(h.BlockSummaryRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockSummaryRoot", size, 32) - return + if sszVarOffset3 > size { + return ssz.ErrOffset } - hh.PutBytes(h.BlockSummaryRoot) - - // Field (1) 'StateSummaryRoot' - if size := len(h.StateSummaryRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateSummaryRoot", size, 32) - return + sszVarOffset4 := ssz.ReadOffset(buf[204:208]) // c.AttesterSlashings + if sszVarOffset4 > size || sszVarOffset4 < sszVarOffset3 { + return ssz.ErrOffset } - hh.PutBytes(h.StateSummaryRoot) - - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the BeaconStateCapella object -func (b *BeaconStateCapella) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} - -// MarshalSSZTo ssz marshals the BeaconStateCapella object to a target array -func (b *BeaconStateCapella) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(10253) - - // Field (0) 'GenesisTime' - dst = ssz.MarshalUint(dst, b.GenesisTime) - - // Field (1) 'GenesisValidatorsRoot' - if size := len(b.GenesisValidatorsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.GenesisValidatorsRoot", size, 32) - return + sszVarOffset5 := ssz.ReadOffset(buf[208:212]) // c.Attestations + if sszVarOffset5 > size || sszVarOffset5 < sszVarOffset4 { + return ssz.ErrOffset } - dst = append(dst, b.GenesisValidatorsRoot...) - - // Field (2) 'Slot' - dst = ssz.MarshalUint(dst, b.Slot) - - // Field (3) 'Fork' - if b.Fork == nil { - b.Fork = new(Fork) + sszVarOffset6 := ssz.ReadOffset(buf[212:216]) // c.Deposits + if sszVarOffset6 > size || sszVarOffset6 < sszVarOffset5 { + return ssz.ErrOffset } - if dst, err = b.Fork.MarshalSSZTo(dst); err != nil { - return + sszVarOffset7 := ssz.ReadOffset(buf[216:220]) // c.VoluntaryExits + if sszVarOffset7 > size || sszVarOffset7 < sszVarOffset6 { + return ssz.ErrOffset } - - // Field (4) 'LatestBlockHeader' - if b.LatestBlockHeader == nil { - b.LatestBlockHeader = new(BeaconBlockHeader) + sszVarOffset9 := ssz.ReadOffset(buf[320:324]) // c.ExecutionPayloadHeader + if sszVarOffset9 > size || sszVarOffset9 < sszVarOffset7 { + return ssz.ErrOffset } - if dst, err = b.LatestBlockHeader.MarshalSSZTo(dst); err != nil { - return + sszVarOffset10 := ssz.ReadOffset(buf[324:328]) // c.BlsToExecutionChanges + if sszVarOffset10 > size || sszVarOffset10 < sszVarOffset9 { + return ssz.ErrOffset } + sszSlice3 := buf[sszVarOffset3:sszVarOffset4] // c.ProposerSlashings + sszSlice4 := buf[sszVarOffset4:sszVarOffset5] // c.AttesterSlashings + sszSlice5 := buf[sszVarOffset5:sszVarOffset6] // c.Attestations + sszSlice6 := buf[sszVarOffset6:sszVarOffset7] // c.Deposits + sszSlice7 := buf[sszVarOffset7:sszVarOffset9] // c.VoluntaryExits + sszSlice9 := buf[sszVarOffset9:sszVarOffset10] // c.ExecutionPayloadHeader + sszSlice10 := buf[sszVarOffset10:] // c.BlsToExecutionChanges + + // Field 0: RandaoReveal + c.RandaoReveal = make([]byte, 0, 96) + c.RandaoReveal = append(c.RandaoReveal, sszSlice0...) - // Field (5) 'BlockRoots' - if size := len(b.BlockRoots); size != 64 { - err = ssz.ErrVectorLengthFn("--.BlockRoots", size, 64) - return + // Field 1: Eth1Data + c.Eth1Data = new(Eth1Data) + if err = c.Eth1Data.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Eth1Data: %w", err) } - for ii := 0; ii < 64; ii++ { - if size := len(b.BlockRoots[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockRoots[ii]", size, 32) - return + + // Field 2: Graffiti + c.Graffiti = make([]byte, 0, 32) + c.Graffiti = append(c.Graffiti, sszSlice2...) + + // Field 3: ProposerSlashings + { + if len(sszSlice3)%416 != 0 { + return fmt.Errorf("misaligned bytes: c.ProposerSlashings length is %d, which is not a multiple of 416: %w", len(sszSlice3), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice3) / 416 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.ProposerSlashings has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.ProposerSlashings = make([]*ProposerSlashing, numElem) + for i := 0; i < numElem; i++ { + var tmp *ProposerSlashing + tmp = new(ProposerSlashing) + tmpSlice := sszSlice3[i*416 : (1+i)*416] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("ProposerSlashings: %w", err) + } + c.ProposerSlashings[i] = tmp } - dst = append(dst, b.BlockRoots[ii]...) } - // Field (6) 'StateRoots' - if size := len(b.StateRoots); size != 64 { - err = ssz.ErrVectorLengthFn("--.StateRoots", size, 64) - return - } - for ii := 0; ii < 64; ii++ { - if size := len(b.StateRoots[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoots[ii]", size, 32) - return + // Field 4: AttesterSlashings + { + // empty lists are zero length, so make sure there is room for an offset + // before attempting to unmarshal it + if len(sszSlice4) > 3 { + startOffset := ssz.ReadOffset(sszSlice4[0:4]) + if startOffset == 0 { + return fmt.Errorf("encountered invalid offset of 0 when decoding c.AttesterSlashings") + } + if startOffset%4 != 0 { + return fmt.Errorf("misaligned list bytes: when decoding c.AttesterSlashings, end-of-list offset is %d, which is not a multiple of 4 (offset size)", startOffset) + } + listLen := startOffset / 4 + if listLen > 2 { + return fmt.Errorf("ssz-max exceeded: c.AttesterSlashings has %d elements, ssz-max is 2: %w", listLen, ssz.ErrListTooBig) + } + totalVarBytes := uint64(len(sszSlice4)) + if totalVarBytes < startOffset { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.AttesterSlashings") + } + c.AttesterSlashings = make([]*AttesterSlashing, listLen) + var tmpSlice []byte + for i := uint64(0); i < listLen; i++ { + var tmp *AttesterSlashing + tmp = new(AttesterSlashing) + endOffset := totalVarBytes + if i+1 != listLen { + endOffset = ssz.ReadOffset(sszSlice4[(i+1)*4 : (i+2)*4]) + if totalVarBytes < endOffset { + return fmt.Errorf("offset %d points past the end of buffer when decoding c.AttesterSlashings", endOffset) + } + } + if endOffset < startOffset { + return fmt.Errorf("offset %d is not greater than start offset %d when decoding c.AttesterSlashings", endOffset, startOffset) + } + tmpSlice = sszSlice4[startOffset:endOffset] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("AttesterSlashings: %w", err) + } + c.AttesterSlashings[i] = tmp + startOffset = endOffset + } + } else { + if len(sszSlice4) > 0 { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.AttesterSlashings") + } + c.AttesterSlashings = make([]*AttesterSlashing, 0) } - 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(Eth1Data) - } - if dst, err = b.Eth1Data.MarshalSSZTo(dst); err != nil { - return + // Field 5: Attestations + { + // empty lists are zero length, so make sure there is room for an offset + // before attempting to unmarshal it + if len(sszSlice5) > 3 { + startOffset := ssz.ReadOffset(sszSlice5[0:4]) + if startOffset == 0 { + return fmt.Errorf("encountered invalid offset of 0 when decoding c.Attestations") + } + if startOffset%4 != 0 { + return fmt.Errorf("misaligned list bytes: when decoding c.Attestations, end-of-list offset is %d, which is not a multiple of 4 (offset size)", startOffset) + } + listLen := startOffset / 4 + if listLen > 128 { + return fmt.Errorf("ssz-max exceeded: c.Attestations has %d elements, ssz-max is 128: %w", listLen, ssz.ErrListTooBig) + } + totalVarBytes := uint64(len(sszSlice5)) + if totalVarBytes < startOffset { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.Attestations") + } + c.Attestations = make([]*Attestation, listLen) + var tmpSlice []byte + for i := uint64(0); i < listLen; i++ { + var tmp *Attestation + tmp = new(Attestation) + endOffset := totalVarBytes + if i+1 != listLen { + endOffset = ssz.ReadOffset(sszSlice5[(i+1)*4 : (i+2)*4]) + if totalVarBytes < endOffset { + return fmt.Errorf("offset %d points past the end of buffer when decoding c.Attestations", endOffset) + } + } + if endOffset < startOffset { + return fmt.Errorf("offset %d is not greater than start offset %d when decoding c.Attestations", endOffset, startOffset) + } + tmpSlice = sszSlice5[startOffset:endOffset] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Attestations: %w", err) + } + c.Attestations[i] = tmp + startOffset = endOffset + } + } else { + if len(sszSlice5) > 0 { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.Attestations") + } + c.Attestations = make([]*Attestation, 0) + } } - // Offset (9) 'Eth1DataVotes' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.Eth1DataVotes) * 72 - - // Field (10) 'Eth1DepositIndex' - dst = ssz.MarshalUint(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 != 64 { - err = ssz.ErrVectorLengthFn("--.RandaoMixes", size, 64) - return - } - for ii := 0; ii < 64; ii++ { - if size := len(b.RandaoMixes[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.RandaoMixes[ii]", size, 32) - return + // Field 6: Deposits + { + if len(sszSlice6)%1240 != 0 { + return fmt.Errorf("misaligned bytes: c.Deposits length is %d, which is not a multiple of 1240: %w", len(sszSlice6), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice6) / 1240 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.Deposits has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.Deposits = make([]*Deposit, numElem) + for i := 0; i < numElem; i++ { + var tmp *Deposit + tmp = new(Deposit) + tmpSlice := sszSlice6[i*1240 : (1+i)*1240] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Deposits: %w", err) + } + c.Deposits[i] = tmp } - dst = append(dst, b.RandaoMixes[ii]...) } - // Field (14) 'Slashings' - if size := len(b.Slashings); size != 64 { - err = ssz.ErrVectorLengthFn("--.Slashings", size, 64) - return - } - for ii := 0; ii < 64; ii++ { - dst = ssz.MarshalUint(dst, b.Slashings[ii]) + // Field 7: VoluntaryExits + { + if len(sszSlice7)%112 != 0 { + return fmt.Errorf("misaligned bytes: c.VoluntaryExits length is %d, which is not a multiple of 112: %w", len(sszSlice7), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice7) / 112 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.VoluntaryExits has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.VoluntaryExits = make([]*SignedVoluntaryExit, numElem) + for i := 0; i < numElem; i++ { + var tmp *SignedVoluntaryExit + tmp = new(SignedVoluntaryExit) + tmpSlice := sszSlice7[i*112 : (1+i)*112] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("VoluntaryExits: %w", err) + } + c.VoluntaryExits[i] = tmp + } } - // 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' - if size := len(b.JustificationBits); size != 1 { - err = ssz.ErrBytesLengthFn("--.JustificationBits", size, 1) - return + // Field 8: SyncAggregate + c.SyncAggregate = new(SyncAggregate) + if err = c.SyncAggregate.UnmarshalSSZ(sszSlice8); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) } - dst = append(dst, b.JustificationBits...) - // Field (18) 'PreviousJustifiedCheckpoint' - if b.PreviousJustifiedCheckpoint == nil { - b.PreviousJustifiedCheckpoint = new(Checkpoint) - } - if dst, err = b.PreviousJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { - return + // Field 9: ExecutionPayloadHeader + c.ExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderCapella) + if err = c.ExecutionPayloadHeader.UnmarshalSSZ(sszSlice9); err != nil { + return fmt.Errorf("ExecutionPayloadHeader: %w", err) } - // Field (19) 'CurrentJustifiedCheckpoint' - if b.CurrentJustifiedCheckpoint == nil { - b.CurrentJustifiedCheckpoint = new(Checkpoint) - } - if dst, err = b.CurrentJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { - return + // Field 10: BlsToExecutionChanges + { + if len(sszSlice10)%172 != 0 { + return fmt.Errorf("misaligned bytes: c.BlsToExecutionChanges length is %d, which is not a multiple of 172: %w", len(sszSlice10), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice10) / 172 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.BlsToExecutionChanges has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.BlsToExecutionChanges = make([]*SignedBLSToExecutionChange, numElem) + for i := 0; i < numElem; i++ { + var tmp *SignedBLSToExecutionChange + tmp = new(SignedBLSToExecutionChange) + tmpSlice := sszSlice10[i*172 : (1+i)*172] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("BlsToExecutionChanges: %w", err) + } + c.BlsToExecutionChanges[i] = tmp + } } + return err +} - // Field (20) 'FinalizedCheckpoint' - if b.FinalizedCheckpoint == nil { - b.FinalizedCheckpoint = new(Checkpoint) - } - if dst, err = b.FinalizedCheckpoint.MarshalSSZTo(dst); err != nil { - return +func (c *BlindedBeaconBlockBodyCapella) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Offset (21) 'InactivityScores' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.InactivityScores) * 8 - - // Field (22) 'CurrentSyncCommittee' - if b.CurrentSyncCommittee == nil { - b.CurrentSyncCommittee = new(SyncCommittee) - } - if dst, err = b.CurrentSyncCommittee.MarshalSSZTo(dst); err != nil { - return +func (c *BlindedBeaconBlockBodyCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: RandaoReveal + if len(c.RandaoReveal) != 96 { + return ssz.ErrBytesLength } - - // Field (23) 'NextSyncCommittee' - if b.NextSyncCommittee == nil { - b.NextSyncCommittee = new(SyncCommittee) + hh.PutBytes(c.RandaoReveal) + // Field 1: Eth1Data + if err := c.Eth1Data.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Eth1Data: %w", err) } - if dst, err = b.NextSyncCommittee.MarshalSSZTo(dst); err != nil { - return + // Field 2: Graffiti + if len(c.Graffiti) != 32 { + return ssz.ErrBytesLength } - - // Offset (24) 'LatestExecutionPayloadHeader' - dst = ssz.WriteOffset(dst, offset) - if b.LatestExecutionPayloadHeader == nil { - b.LatestExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderCapella) + hh.PutBytes(c.Graffiti) + // Field 3: ProposerSlashings + { + if len(c.ProposerSlashings) > 16 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.ProposerSlashings { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ProposerSlashings: %w", err) + } + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.ProposerSlashings)), 16) } - offset += b.LatestExecutionPayloadHeader.SizeSSZ() - - // Field (25) 'NextWithdrawalIndex' - dst = ssz.MarshalUint(dst, b.NextWithdrawalIndex) - - // Field (26) 'NextWithdrawalValidatorIndex' - dst = ssz.MarshalUint(dst, b.NextWithdrawalValidatorIndex) - - // Offset (27) 'HistoricalSummaries' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.HistoricalSummaries) * 64 - - // Field (7) 'HistoricalRoots' - if size := len(b.HistoricalRoots); size > 16777216 { - err = ssz.ErrListTooBigFn("--.HistoricalRoots", size, 16777216) - return + // Field 4: AttesterSlashings + { + if len(c.AttesterSlashings) > 2 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.AttesterSlashings { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("AttesterSlashings: %w", err) + } + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.AttesterSlashings)), 2) } - for ii := 0; ii < len(b.HistoricalRoots); ii++ { - if size := len(b.HistoricalRoots[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.HistoricalRoots[ii]", size, 32) - return + // Field 5: Attestations + { + if len(c.Attestations) > 128 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.Attestations { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Attestations: %w", err) + } } - dst = append(dst, b.HistoricalRoots[ii]...) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Attestations)), 128) } - - // Field (9) 'Eth1DataVotes' - if size := len(b.Eth1DataVotes); size > 32 { - err = ssz.ErrListTooBigFn("--.Eth1DataVotes", size, 32) - return + // Field 6: Deposits + { + if len(c.Deposits) > 16 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.Deposits { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Deposits: %w", err) + } + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Deposits)), 16) } - for ii := 0; ii < len(b.Eth1DataVotes); ii++ { - if dst, err = b.Eth1DataVotes[ii].MarshalSSZTo(dst); err != nil { - return + // Field 7: VoluntaryExits + { + if len(c.VoluntaryExits) > 16 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.VoluntaryExits { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("VoluntaryExits: %w", err) + } } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.VoluntaryExits)), 16) } - - // Field (11) 'Validators' - if size := len(b.Validators); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.Validators", size, 1099511627776) - return + // Field 8: SyncAggregate + if err := c.SyncAggregate.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) } - for ii := 0; ii < len(b.Validators); ii++ { - if dst, err = b.Validators[ii].MarshalSSZTo(dst); err != nil { - return + // Field 9: ExecutionPayloadHeader + if err := c.ExecutionPayloadHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ExecutionPayloadHeader: %w", err) + } + // Field 10: BlsToExecutionChanges + { + if len(c.BlsToExecutionChanges) > 16 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.BlsToExecutionChanges { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("BlsToExecutionChanges: %w", err) + } } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.BlsToExecutionChanges)), 16) } + hh.Merkleize(indx) + return nil +} - // Field (12) 'Balances' - if size := len(b.Balances); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.Balances", size, 1099511627776) - return - } - for ii := 0; ii < len(b.Balances); ii++ { - dst = ssz.MarshalUint(dst, b.Balances[ii]) +func (c *BlindedBeaconBlockCapella) SizeSSZ() int { + size := 84 + if c.Body == nil { + c.Body = new(BlindedBeaconBlockBodyCapella) } + size += c.Body.SizeSSZ() + return size +} - // Field (15) 'PreviousEpochParticipation' - if size := len(b.PreviousEpochParticipation); size > 1099511627776 { - err = ssz.ErrBytesLengthFn("--.PreviousEpochParticipation", size, 1099511627776) - return - } - dst = append(dst, b.PreviousEpochParticipation...) +func (c *BlindedBeaconBlockCapella) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (16) 'CurrentEpochParticipation' - if size := len(b.CurrentEpochParticipation); size > 1099511627776 { - err = ssz.ErrBytesLengthFn("--.CurrentEpochParticipation", size, 1099511627776) - return - } - dst = append(dst, b.CurrentEpochParticipation...) +func (c *BlindedBeaconBlockCapella) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 84 - // Field (21) 'InactivityScores' - if size := len(b.InactivityScores); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.InactivityScores", size, 1099511627776) - return + // Field 0: Slot + if dst, err = c.Slot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Slot: %w", err) } - for ii := 0; ii < len(b.InactivityScores); ii++ { - dst = ssz.MarshalUint(dst, b.InactivityScores[ii]) + + // Field 1: ProposerIndex + if dst, err = c.ProposerIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ProposerIndex: %w", err) } - // Field (24) 'LatestExecutionPayloadHeader' - if dst, err = b.LatestExecutionPayloadHeader.MarshalSSZTo(dst); err != nil { - return + // Field 2: ParentRoot + if len(c.ParentRoot) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.ParentRoot...) - // Field (27) 'HistoricalSummaries' - if size := len(b.HistoricalSummaries); size > 16777216 { - err = ssz.ErrListTooBigFn("--.HistoricalSummaries", size, 16777216) - return + // Field 3: StateRoot + if len(c.StateRoot) != 32 { + return nil, ssz.ErrBytesLength } - for ii := 0; ii < len(b.HistoricalSummaries); ii++ { - if dst, err = b.HistoricalSummaries[ii].MarshalSSZTo(dst); err != nil { - return - } + dst = append(dst, c.StateRoot...) + + // Field 4: Body + if c.Body == nil { + c.Body = new(BlindedBeaconBlockBodyCapella) } + dst = ssz.WriteOffset(dst, offset) + offset += c.Body.SizeSSZ() - return + // Field 4: Body + if dst, err = c.Body.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Body: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the BeaconStateCapella object -func (b *BeaconStateCapella) UnmarshalSSZ(buf []byte) error { +func (c *BlindedBeaconBlockCapella) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 10253 { + if size < 84 { return ssz.ErrSize } - tail := buf - var o7, o9, o11, o12, o15, o16, o21, o24, o27 uint64 - - // Field (0) 'GenesisTime' - b.GenesisTime = ssz.UnmarshallUint[uint64](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.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[40:48]) + sszSlice0 := buf[0:8] // c.Slot + sszSlice1 := buf[8:16] // c.ProposerIndex + sszSlice2 := buf[16:48] // c.ParentRoot + sszSlice3 := buf[48:80] // c.StateRoot - // Field (3) 'Fork' - if b.Fork == nil { - b.Fork = new(Fork) + sszVarOffset4 := ssz.ReadOffset(buf[80:84]) // c.Body + if sszVarOffset4 != 84 { + return ssz.ErrInvalidVariableOffset } - if err = b.Fork.UnmarshalSSZ(buf[48:64]); err != nil { - return err + if sszVarOffset4 > size { + return ssz.ErrOffset } + sszSlice4 := buf[sszVarOffset4:] // c.Body - // Field (4) 'LatestBlockHeader' - if b.LatestBlockHeader == nil { - b.LatestBlockHeader = new(BeaconBlockHeader) - } - if err = b.LatestBlockHeader.UnmarshalSSZ(buf[64:176]); err != nil { - return err + // Field 0: Slot + if err = c.Slot.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Slot: %w", err) } - // Field (5) 'BlockRoots' - b.BlockRoots = make([][]byte, 64) - for ii := 0; ii < 64; ii++ { - if cap(b.BlockRoots[ii]) == 0 { - b.BlockRoots[ii] = make([]byte, 0, len(buf[176:2224][ii*32:(ii+1)*32])) - } - b.BlockRoots[ii] = append(b.BlockRoots[ii], buf[176:2224][ii*32:(ii+1)*32]...) + // Field 1: ProposerIndex + if err = c.ProposerIndex.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("ProposerIndex: %w", err) } - // Field (6) 'StateRoots' - b.StateRoots = make([][]byte, 64) - for ii := 0; ii < 64; ii++ { - if cap(b.StateRoots[ii]) == 0 { - b.StateRoots[ii] = make([]byte, 0, len(buf[2224:4272][ii*32:(ii+1)*32])) - } - b.StateRoots[ii] = append(b.StateRoots[ii], buf[2224:4272][ii*32:(ii+1)*32]...) - } + // Field 2: ParentRoot + c.ParentRoot = make([]byte, 0, 32) + c.ParentRoot = append(c.ParentRoot, sszSlice2...) - // Offset (7) 'HistoricalRoots' - if o7 = ssz.ReadOffset(buf[4272:4276]); o7 > size { - return ssz.ErrOffset + // Field 3: StateRoot + c.StateRoot = make([]byte, 0, 32) + c.StateRoot = append(c.StateRoot, sszSlice3...) + + // Field 4: Body + c.Body = new(BlindedBeaconBlockBodyCapella) + if err = c.Body.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("Body: %w", err) } + return err +} - if o7 != 10253 { - return ssz.ErrInvalidVariableOffset +func (c *BlindedBeaconBlockCapella) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (8) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(Eth1Data) +func (c *BlindedBeaconBlockCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Slot + if err := c.Slot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Slot: %w", err) } - if err = b.Eth1Data.UnmarshalSSZ(buf[4276:4348]); err != nil { - return err + // Field 1: ProposerIndex + if err := c.ProposerIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ProposerIndex: %w", err) } - - // Offset (9) 'Eth1DataVotes' - if o9 = ssz.ReadOffset(buf[4348:4352]); o9 > size || o7 > o9 { - return ssz.ErrOffset + // Field 2: ParentRoot + if len(c.ParentRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ParentRoot) + // Field 3: StateRoot + if len(c.StateRoot) != 32 { + return ssz.ErrBytesLength } + hh.PutBytes(c.StateRoot) + // Field 4: Body + if err := c.Body.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Body: %w", err) + } + hh.Merkleize(indx) + return nil +} - // Field (10) 'Eth1DepositIndex' - b.Eth1DepositIndex = ssz.UnmarshallUint[uint64](buf[4352:4360]) +func (c *BLSToExecutionChange) SizeSSZ() int { + size := 76 - // Offset (11) 'Validators' - if o11 = ssz.ReadOffset(buf[4360:4364]); o11 > size || o9 > o11 { - return ssz.ErrOffset - } + return size +} - // Offset (12) 'Balances' - if o12 = ssz.ReadOffset(buf[4364:4368]); o12 > size || o11 > o12 { - return ssz.ErrOffset - } +func (c *BLSToExecutionChange) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (13) 'RandaoMixes' - b.RandaoMixes = make([][]byte, 64) - for ii := 0; ii < 64; ii++ { - if cap(b.RandaoMixes[ii]) == 0 { - b.RandaoMixes[ii] = make([]byte, 0, len(buf[4368:6416][ii*32:(ii+1)*32])) - } - b.RandaoMixes[ii] = append(b.RandaoMixes[ii], buf[4368:6416][ii*32:(ii+1)*32]...) - } +func (c *BLSToExecutionChange) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (14) 'Slashings' - b.Slashings = ssz.ExtendUint(b.Slashings, 64) - for ii := 0; ii < 64; ii++ { - b.Slashings[ii] = ssz.UnmarshallUint[uint64](buf[6416:6928][ii*8 : (ii+1)*8]) + // Field 0: ValidatorIndex + if dst, err = c.ValidatorIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ValidatorIndex: %w", err) } - // Offset (15) 'PreviousEpochParticipation' - if o15 = ssz.ReadOffset(buf[6928:6932]); o15 > size || o12 > o15 { - return ssz.ErrOffset + // Field 1: FromBlsPubkey + if len(c.FromBlsPubkey) != 48 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.FromBlsPubkey...) - // Offset (16) 'CurrentEpochParticipation' - if o16 = ssz.ReadOffset(buf[6932:6936]); o16 > size || o15 > o16 { - return ssz.ErrOffset + // Field 2: ToExecutionAddress + if len(c.ToExecutionAddress) != 20 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.ToExecutionAddress...) - // Field (17) 'JustificationBits' - if cap(b.JustificationBits) == 0 { - b.JustificationBits = make([]byte, 0, len(buf[6936:6937])) - } - b.JustificationBits = append(b.JustificationBits, buf[6936:6937]...) + return dst, err +} - // Field (18) 'PreviousJustifiedCheckpoint' - if b.PreviousJustifiedCheckpoint == nil { - b.PreviousJustifiedCheckpoint = new(Checkpoint) - } - if err = b.PreviousJustifiedCheckpoint.UnmarshalSSZ(buf[6937:6977]); err != nil { - return err +func (c *BLSToExecutionChange) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 76 { + return ssz.ErrSize } - // Field (19) 'CurrentJustifiedCheckpoint' - if b.CurrentJustifiedCheckpoint == nil { - b.CurrentJustifiedCheckpoint = new(Checkpoint) - } - if err = b.CurrentJustifiedCheckpoint.UnmarshalSSZ(buf[6977:7017]); err != nil { - return err - } + sszSlice0 := buf[0:8] // c.ValidatorIndex + sszSlice1 := buf[8:56] // c.FromBlsPubkey + sszSlice2 := buf[56:76] // c.ToExecutionAddress - // Field (20) 'FinalizedCheckpoint' - if b.FinalizedCheckpoint == nil { - b.FinalizedCheckpoint = new(Checkpoint) - } - if err = b.FinalizedCheckpoint.UnmarshalSSZ(buf[7017:7057]); err != nil { - return err + // Field 0: ValidatorIndex + if err = c.ValidatorIndex.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("ValidatorIndex: %w", err) } - // Offset (21) 'InactivityScores' - if o21 = ssz.ReadOffset(buf[7057:7061]); o21 > size || o16 > o21 { - return ssz.ErrOffset - } + // Field 1: FromBlsPubkey + c.FromBlsPubkey = make([]byte, 0, 48) + c.FromBlsPubkey = append(c.FromBlsPubkey, sszSlice1...) - // Field (22) 'CurrentSyncCommittee' - if b.CurrentSyncCommittee == nil { - b.CurrentSyncCommittee = new(SyncCommittee) - } - if err = b.CurrentSyncCommittee.UnmarshalSSZ(buf[7061:8645]); err != nil { - return err + // Field 2: ToExecutionAddress + c.ToExecutionAddress = make([]byte, 0, 20) + c.ToExecutionAddress = append(c.ToExecutionAddress, sszSlice2...) + return err +} + +func (c *BLSToExecutionChange) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (23) 'NextSyncCommittee' - if b.NextSyncCommittee == nil { - b.NextSyncCommittee = new(SyncCommittee) +func (c *BLSToExecutionChange) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: ValidatorIndex + if err := c.ValidatorIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ValidatorIndex: %w", err) } - if err = b.NextSyncCommittee.UnmarshalSSZ(buf[8645:10229]); err != nil { - return err + // Field 1: FromBlsPubkey + if len(c.FromBlsPubkey) != 48 { + return ssz.ErrBytesLength } + hh.PutBytes(c.FromBlsPubkey) + // Field 2: ToExecutionAddress + if len(c.ToExecutionAddress) != 20 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ToExecutionAddress) + hh.Merkleize(indx) + return nil +} - // Offset (24) 'LatestExecutionPayloadHeader' - if o24 = ssz.ReadOffset(buf[10229:10233]); o24 > size || o21 > o24 { - return ssz.ErrOffset +func (c *BuilderBidCapella) SizeSSZ() int { + size := 84 + if c.Header == nil { + c.Header = new(v1.ExecutionPayloadHeaderCapella) } + size += c.Header.SizeSSZ() + return size +} - // Field (25) 'NextWithdrawalIndex' - b.NextWithdrawalIndex = ssz.UnmarshallUint[uint64](buf[10233:10241]) +func (c *BuilderBidCapella) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (26) 'NextWithdrawalValidatorIndex' - b.NextWithdrawalValidatorIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[10241:10249]) +func (c *BuilderBidCapella) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 84 - // Offset (27) 'HistoricalSummaries' - if o27 = ssz.ReadOffset(buf[10249:10253]); o27 > size || o24 > o27 { - return ssz.ErrOffset + // Field 0: Header + if c.Header == nil { + c.Header = new(v1.ExecutionPayloadHeaderCapella) } + dst = ssz.WriteOffset(dst, offset) + offset += c.Header.SizeSSZ() - // 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 1: Value + if len(c.Value) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.Value...) - // Field (9) 'Eth1DataVotes' - { - buf = tail[o9:o11] - num, err := ssz.DivideInt2(len(buf), 72, 32) - if err != nil { - return err - } - b.Eth1DataVotes = make([]*Eth1Data, num) - for ii := 0; ii < num; ii++ { - if b.Eth1DataVotes[ii] == nil { - b.Eth1DataVotes[ii] = new(Eth1Data) - } - if err = b.Eth1DataVotes[ii].UnmarshalSSZ(buf[ii*72 : (ii+1)*72]); err != nil { - return err - } - } + // Field 2: Pubkey + if len(c.Pubkey) != 48 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.Pubkey...) - // Field (11) 'Validators' - { - buf = tail[o11:o12] - num, err := ssz.DivideInt2(len(buf), 121, 1099511627776) - if err != nil { - return err - } - b.Validators = make([]*Validator, num) - for ii := 0; ii < num; ii++ { - if b.Validators[ii] == nil { - b.Validators[ii] = new(Validator) - } - if err = b.Validators[ii].UnmarshalSSZ(buf[ii*121 : (ii+1)*121]); err != nil { - return err - } - } + // Field 0: Header + if dst, err = c.Header.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Header: %w", err) } + return dst, err +} - // Field (12) 'Balances' - { - buf = tail[o12:o15] - num, err := ssz.DivideInt2(len(buf), 8, 1099511627776) - if err != nil { - return err - } - b.Balances = ssz.ExtendUint(b.Balances, num) - for ii := 0; ii < num; ii++ { - b.Balances[ii] = ssz.UnmarshallUint[uint64](buf[ii*8 : (ii+1)*8]) - } +func (c *BuilderBidCapella) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 84 { + return ssz.ErrSize } - // 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...) - } + sszSlice1 := buf[4:36] // c.Value + sszSlice2 := buf[36:84] // c.Pubkey - // 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...) + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Header + if sszVarOffset0 != 84 { + return ssz.ErrInvalidVariableOffset } - - // Field (21) 'InactivityScores' - { - buf = tail[o21:o24] - num, err := ssz.DivideInt2(len(buf), 8, 1099511627776) - if err != nil { - return err - } - b.InactivityScores = ssz.ExtendUint(b.InactivityScores, num) - for ii := 0; ii < num; ii++ { - b.InactivityScores[ii] = ssz.UnmarshallUint[uint64](buf[ii*8 : (ii+1)*8]) - } + if sszVarOffset0 > size { + return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:] // c.Header - // Field (24) 'LatestExecutionPayloadHeader' - { - buf = tail[o24:o27] - if b.LatestExecutionPayloadHeader == nil { - b.LatestExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderCapella) - } - if err = b.LatestExecutionPayloadHeader.UnmarshalSSZ(buf); err != nil { - return err - } + // Field 0: Header + c.Header = new(v1.ExecutionPayloadHeaderCapella) + if err = c.Header.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Header: %w", err) } - // Field (27) 'HistoricalSummaries' - { - buf = tail[o27:] - num, err := ssz.DivideInt2(len(buf), 64, 16777216) - if err != nil { - return err - } - b.HistoricalSummaries = make([]*HistoricalSummary, num) - for ii := 0; ii < num; ii++ { - if b.HistoricalSummaries[ii] == nil { - b.HistoricalSummaries[ii] = new(HistoricalSummary) - } - if err = b.HistoricalSummaries[ii].UnmarshalSSZ(buf[ii*64 : (ii+1)*64]); err != nil { - return err - } - } - } + // Field 1: Value + c.Value = make([]byte, 0, 32) + c.Value = append(c.Value, sszSlice1...) + + // Field 2: Pubkey + c.Pubkey = make([]byte, 0, 48) + c.Pubkey = append(c.Pubkey, sszSlice2...) return err } -// SizeSSZ returns the ssz encoded size in bytes for the BeaconStateCapella object -func (b *BeaconStateCapella) SizeSSZ() (size int) { - size = 10253 - - // Field (7) 'HistoricalRoots' - size += len(b.HistoricalRoots) * 32 - - // Field (9) 'Eth1DataVotes' - size += len(b.Eth1DataVotes) * 72 +func (c *BuilderBidCapella) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (11) 'Validators' - size += len(b.Validators) * 121 +func (c *BuilderBidCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Header + if err := c.Header.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Header: %w", err) + } + // Field 1: Value + if len(c.Value) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Value) + // Field 2: Pubkey + if len(c.Pubkey) != 48 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Pubkey) + hh.Merkleize(indx) + return nil +} - // Field (12) 'Balances' - size += len(b.Balances) * 8 +func (c *HistoricalSummary) SizeSSZ() int { + size := 64 - // Field (15) 'PreviousEpochParticipation' - size += len(b.PreviousEpochParticipation) + return size +} - // Field (16) 'CurrentEpochParticipation' - size += len(b.CurrentEpochParticipation) +func (c *HistoricalSummary) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (21) 'InactivityScores' - size += len(b.InactivityScores) * 8 +func (c *HistoricalSummary) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (24) 'LatestExecutionPayloadHeader' - if b.LatestExecutionPayloadHeader == nil { - b.LatestExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderCapella) + // Field 0: BlockSummaryRoot + if len(c.BlockSummaryRoot) != 32 { + return nil, ssz.ErrBytesLength } - size += b.LatestExecutionPayloadHeader.SizeSSZ() - - // Field (27) 'HistoricalSummaries' - size += len(b.HistoricalSummaries) * 64 + dst = append(dst, c.BlockSummaryRoot...) - return -} + // Field 1: StateSummaryRoot + if len(c.StateSummaryRoot) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.StateSummaryRoot...) -// HashTreeRoot ssz hashes the BeaconStateCapella object -func (b *BeaconStateCapella) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) + return dst, err } -// HashTreeRootWith ssz hashes the BeaconStateCapella object with a hasher -func (b *BeaconStateCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() +func (c *HistoricalSummary) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 64 { + return ssz.ErrSize + } - // Field (0) 'GenesisTime' - ssz.PutUint(hh, b.GenesisTime) + sszSlice0 := buf[0:32] // c.BlockSummaryRoot + sszSlice1 := buf[32:64] // c.StateSummaryRoot - // Field (1) 'GenesisValidatorsRoot' - if size := len(b.GenesisValidatorsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.GenesisValidatorsRoot", size, 32) - return - } - hh.PutBytes(b.GenesisValidatorsRoot) + // Field 0: BlockSummaryRoot + c.BlockSummaryRoot = make([]byte, 0, 32) + c.BlockSummaryRoot = append(c.BlockSummaryRoot, sszSlice0...) - // Field (2) 'Slot' - ssz.PutUint(hh, b.Slot) + // Field 1: StateSummaryRoot + c.StateSummaryRoot = make([]byte, 0, 32) + c.StateSummaryRoot = append(c.StateSummaryRoot, sszSlice1...) + return err +} - // Field (3) 'Fork' - if err = b.Fork.HashTreeRootWith(hh); err != nil { - return +func (c *HistoricalSummary) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (4) 'LatestBlockHeader' - if err = b.LatestBlockHeader.HashTreeRootWith(hh); err != nil { - return +func (c *HistoricalSummary) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: BlockSummaryRoot + if len(c.BlockSummaryRoot) != 32 { + return ssz.ErrBytesLength } - - // Field (5) 'BlockRoots' - { - if size := len(b.BlockRoots); size != 64 { - err = ssz.ErrVectorLengthFn("--.BlockRoots", size, 64) - return - } - subIndx := hh.Index() - for _, i := range b.BlockRoots { - if len(i) != 32 { - err = ssz.ErrBytesLength - return - } - hh.Append(i) - } - hh.Merkleize(subIndx) + hh.PutBytes(c.BlockSummaryRoot) + // Field 1: StateSummaryRoot + if len(c.StateSummaryRoot) != 32 { + return ssz.ErrBytesLength } + hh.PutBytes(c.StateSummaryRoot) + hh.Merkleize(indx) + return nil +} - // Field (6) 'StateRoots' - { - if size := len(b.StateRoots); size != 64 { - err = ssz.ErrVectorLengthFn("--.StateRoots", size, 64) - return - } - subIndx := hh.Index() - for _, i := range b.StateRoots { - if len(i) != 32 { - err = ssz.ErrBytesLength - return - } - hh.Append(i) - } - hh.Merkleize(subIndx) +func (c *LightClientBootstrapCapella) SizeSSZ() int { + size := 1748 + if c.Header == nil { + c.Header = new(LightClientHeaderCapella) } + size += c.Header.SizeSSZ() + return size +} - // Field (7) 'HistoricalRoots' - { - if size := len(b.HistoricalRoots); size > 16777216 { - err = ssz.ErrListTooBigFn("--.HistoricalRoots", size, 16777216) - return - } - subIndx := hh.Index() - for _, i := range b.HistoricalRoots { - if len(i) != 32 { - err = ssz.ErrBytesLength - return - } - hh.Append(i) - } +func (c *LightClientBootstrapCapella) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - numItems := uint64(len(b.HistoricalRoots)) - hh.MerkleizeWithMixin(subIndx, numItems, 16777216) - } +func (c *LightClientBootstrapCapella) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 1748 - // Field (8) 'Eth1Data' - if err = b.Eth1Data.HashTreeRootWith(hh); err != nil { - return + // Field 0: Header + if c.Header == nil { + c.Header = new(LightClientHeaderCapella) } + dst = ssz.WriteOffset(dst, offset) + offset += c.Header.SizeSSZ() - // Field (9) 'Eth1DataVotes' - { - subIndx := hh.Index() - num := uint64(len(b.Eth1DataVotes)) - if num > 32 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range b.Eth1DataVotes { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } - } - hh.MerkleizeWithMixin(subIndx, num, 32) + // Field 1: CurrentSyncCommittee + if c.CurrentSyncCommittee == nil { + c.CurrentSyncCommittee = new(SyncCommittee) } - - // Field (10) 'Eth1DepositIndex' - ssz.PutUint(hh, 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) + if dst, err = c.CurrentSyncCommittee.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("CurrentSyncCommittee: %w", err) } - // Field (12) 'Balances' - { - if size := len(b.Balances); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.Balances", size, 1099511627776) - return - } - subIndx := hh.Index() - for _, i := range b.Balances { - ssz.AppendUint(hh, i) - } - hh.FillUpTo32() - - numItems := uint64(len(b.Balances)) - hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(1099511627776, numItems, 8)) + // Field 2: CurrentSyncCommitteeBranch + if len(c.CurrentSyncCommitteeBranch) != 5 { + return nil, ssz.ErrBytesLength } - - // Field (13) 'RandaoMixes' - { - if size := len(b.RandaoMixes); size != 64 { - err = ssz.ErrVectorLengthFn("--.RandaoMixes", size, 64) - return + for _, o := range c.CurrentSyncCommitteeBranch { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } - subIndx := hh.Index() - for _, i := range b.RandaoMixes { - if len(i) != 32 { - err = ssz.ErrBytesLength - return - } - hh.Append(i) - } - hh.Merkleize(subIndx) + dst = append(dst, o...) } - // Field (14) 'Slashings' - { - if size := len(b.Slashings); size != 64 { - err = ssz.ErrVectorLengthFn("--.Slashings", size, 64) - return - } - subIndx := hh.Index() - for _, i := range b.Slashings { - ssz.AppendUint(hh, i) - } - hh.Merkleize(subIndx) + // Field 0: Header + if dst, err = c.Header.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Header: %w", err) } + return dst, err +} - // Field (15) 'PreviousEpochParticipation' - { - elemIndx := hh.Index() - byteLen := uint64(len(b.PreviousEpochParticipation)) - if byteLen > 1099511627776 { - err = ssz.ErrIncorrectListSize - return - } - hh.AppendBytes32(b.PreviousEpochParticipation) - hh.MerkleizeWithMixin(elemIndx, byteLen, (1099511627776+31)/32) +func (c *LightClientBootstrapCapella) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 1748 { + return ssz.ErrSize } - // Field (16) 'CurrentEpochParticipation' - { - elemIndx := hh.Index() - byteLen := uint64(len(b.CurrentEpochParticipation)) - if byteLen > 1099511627776 { - err = ssz.ErrIncorrectListSize - return - } - hh.AppendBytes32(b.CurrentEpochParticipation) - hh.MerkleizeWithMixin(elemIndx, byteLen, (1099511627776+31)/32) - } + sszSlice1 := buf[4:1588] // c.CurrentSyncCommittee + sszSlice2 := buf[1588:1748] // c.CurrentSyncCommitteeBranch - // Field (17) 'JustificationBits' - if size := len(b.JustificationBits); size != 1 { - err = ssz.ErrBytesLengthFn("--.JustificationBits", size, 1) - return + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Header + if sszVarOffset0 != 1748 { + return ssz.ErrInvalidVariableOffset } - hh.PutBytes(b.JustificationBits) - - // Field (18) 'PreviousJustifiedCheckpoint' - if err = b.PreviousJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { - return + if sszVarOffset0 > size { + return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:] // c.Header - // Field (19) 'CurrentJustifiedCheckpoint' - if err = b.CurrentJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { - return + // Field 0: Header + c.Header = new(LightClientHeaderCapella) + if err = c.Header.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Header: %w", err) } - // Field (20) 'FinalizedCheckpoint' - if err = b.FinalizedCheckpoint.HashTreeRootWith(hh); err != nil { - return + // Field 1: CurrentSyncCommittee + c.CurrentSyncCommittee = new(SyncCommittee) + if err = c.CurrentSyncCommittee.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("CurrentSyncCommittee: %w", err) } - // Field (21) 'InactivityScores' + // Field 2: CurrentSyncCommitteeBranch { - if size := len(b.InactivityScores); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.InactivityScores", size, 1099511627776) - return - } - subIndx := hh.Index() - for _, i := range b.InactivityScores { - ssz.AppendUint(hh, i) - } - hh.FillUpTo32() + c.CurrentSyncCommitteeBranch = make([][]byte, 5) + for i := 0; i < 5; i++ { + var tmp []byte - numItems := uint64(len(b.InactivityScores)) - hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(1099511627776, numItems, 8)) + tmpSlice := sszSlice2[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.CurrentSyncCommitteeBranch[i] = tmp + } } + return err +} - // Field (22) 'CurrentSyncCommittee' - if err = b.CurrentSyncCommittee.HashTreeRootWith(hh); err != nil { - return +func (c *LightClientBootstrapCapella) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (23) 'NextSyncCommittee' - if err = b.NextSyncCommittee.HashTreeRootWith(hh); err != nil { - return +func (c *LightClientBootstrapCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Header + if err := c.Header.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Header: %w", err) } - - // Field (24) 'LatestExecutionPayloadHeader' - if err = b.LatestExecutionPayloadHeader.HashTreeRootWith(hh); err != nil { - return + // Field 1: CurrentSyncCommittee + if err := c.CurrentSyncCommittee.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("CurrentSyncCommittee: %w", err) } - - // Field (25) 'NextWithdrawalIndex' - ssz.PutUint(hh, b.NextWithdrawalIndex) - - // Field (26) 'NextWithdrawalValidatorIndex' - ssz.PutUint(hh, b.NextWithdrawalValidatorIndex) - - // Field (27) 'HistoricalSummaries' + // Field 2: CurrentSyncCommitteeBranch { + if len(c.CurrentSyncCommitteeBranch) != 5 { + return ssz.ErrVectorLength + } 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 + for _, o := range c.CurrentSyncCommitteeBranch { + if len(o) != 32 { + return ssz.ErrBytesLength } + hh.Append(o) } - hh.MerkleizeWithMixin(subIndx, num, 16777216) + hh.Merkleize(subIndx) } - hh.Merkleize(indx) - return + return nil +} + +func (c *LightClientFinalityUpdateCapella) SizeSSZ() int { + size := 308 + if c.AttestedHeader == nil { + c.AttestedHeader = new(LightClientHeaderCapella) + } + size += c.AttestedHeader.SizeSSZ() + if c.FinalizedHeader == nil { + c.FinalizedHeader = new(LightClientHeaderCapella) + } + size += c.FinalizedHeader.SizeSSZ() + return size } -// MarshalSSZ ssz marshals the LightClientBootstrapCapella object -func (l *LightClientBootstrapCapella) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(l) +func (c *LightClientFinalityUpdateCapella) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the LightClientBootstrapCapella object to a target array -func (l *LightClientBootstrapCapella) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(1748) +func (c *LightClientFinalityUpdateCapella) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 308 - // Offset (0) 'Header' + // Field 0: AttestedHeader + if c.AttestedHeader == nil { + c.AttestedHeader = new(LightClientHeaderCapella) + } dst = ssz.WriteOffset(dst, offset) - if l.Header == nil { - l.Header = new(LightClientHeaderCapella) + offset += c.AttestedHeader.SizeSSZ() + + // Field 1: FinalizedHeader + if c.FinalizedHeader == nil { + c.FinalizedHeader = new(LightClientHeaderCapella) + } + dst = ssz.WriteOffset(dst, offset) + offset += c.FinalizedHeader.SizeSSZ() + + // Field 2: FinalityBranch + if len(c.FinalityBranch) != 6 { + return nil, ssz.ErrBytesLength + } + for _, o := range c.FinalityBranch { + if len(o) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) } - offset += l.Header.SizeSSZ() - // Field (1) 'CurrentSyncCommittee' - if l.CurrentSyncCommittee == nil { - l.CurrentSyncCommittee = new(SyncCommittee) + // Field 3: SyncAggregate + if c.SyncAggregate == nil { + c.SyncAggregate = new(SyncAggregate) } - if dst, err = l.CurrentSyncCommittee.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.SyncAggregate.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SyncAggregate: %w", err) } - // Field (2) 'CurrentSyncCommitteeBranch' - if size := len(l.CurrentSyncCommitteeBranch); size != 5 { - err = ssz.ErrVectorLengthFn("--.CurrentSyncCommitteeBranch", size, 5) - return - } - for ii := 0; ii < 5; ii++ { - if size := len(l.CurrentSyncCommitteeBranch[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.CurrentSyncCommitteeBranch[ii]", size, 32) - return - } - dst = append(dst, l.CurrentSyncCommitteeBranch[ii]...) + // Field 4: SignatureSlot + if dst, err = c.SignatureSlot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SignatureSlot: %w", err) } - // Field (0) 'Header' - if dst, err = l.Header.MarshalSSZTo(dst); err != nil { - return + // Field 0: AttestedHeader + if dst, err = c.AttestedHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("AttestedHeader: %w", err) } - return + // Field 1: FinalizedHeader + if dst, err = c.FinalizedHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("FinalizedHeader: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the LightClientBootstrapCapella object -func (l *LightClientBootstrapCapella) UnmarshalSSZ(buf []byte) error { +func (c *LightClientFinalityUpdateCapella) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 1748 { + if size < 308 { return ssz.ErrSize } - tail := buf - var o0 uint64 + sszSlice2 := buf[8:200] // c.FinalityBranch + sszSlice3 := buf[200:300] // c.SyncAggregate + sszSlice4 := buf[300:308] // c.SignatureSlot - // Offset (0) 'Header' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.AttestedHeader + if sszVarOffset0 != 308 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset0 > size { return ssz.ErrOffset } - - if o0 != 1748 { - return ssz.ErrInvalidVariableOffset + sszVarOffset1 := ssz.ReadOffset(buf[4:8]) // c.FinalizedHeader + if sszVarOffset1 > size || sszVarOffset1 < sszVarOffset0 { + return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:sszVarOffset1] // c.AttestedHeader + sszSlice1 := buf[sszVarOffset1:] // c.FinalizedHeader - // Field (1) 'CurrentSyncCommittee' - if l.CurrentSyncCommittee == nil { - l.CurrentSyncCommittee = new(SyncCommittee) - } - if err = l.CurrentSyncCommittee.UnmarshalSSZ(buf[4:1588]); err != nil { - return err + // Field 0: AttestedHeader + c.AttestedHeader = new(LightClientHeaderCapella) + if err = c.AttestedHeader.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("AttestedHeader: %w", err) } - // Field (2) 'CurrentSyncCommitteeBranch' - l.CurrentSyncCommitteeBranch = make([][]byte, 5) - for ii := 0; ii < 5; ii++ { - if cap(l.CurrentSyncCommitteeBranch[ii]) == 0 { - l.CurrentSyncCommitteeBranch[ii] = make([]byte, 0, len(buf[1588:1748][ii*32:(ii+1)*32])) - } - l.CurrentSyncCommitteeBranch[ii] = append(l.CurrentSyncCommitteeBranch[ii], buf[1588:1748][ii*32:(ii+1)*32]...) + // Field 1: FinalizedHeader + c.FinalizedHeader = new(LightClientHeaderCapella) + if err = c.FinalizedHeader.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("FinalizedHeader: %w", err) } - // Field (0) 'Header' + // Field 2: FinalityBranch { - buf = tail[o0:] - if l.Header == nil { - l.Header = new(LightClientHeaderCapella) - } - if err = l.Header.UnmarshalSSZ(buf); err != nil { - return err + c.FinalityBranch = make([][]byte, 6) + for i := 0; i < 6; i++ { + var tmp []byte + + tmpSlice := sszSlice2[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.FinalityBranch[i] = tmp } } - return err -} -// SizeSSZ returns the ssz encoded size in bytes for the LightClientBootstrapCapella object -func (l *LightClientBootstrapCapella) SizeSSZ() (size int) { - size = 1748 - - // Field (0) 'Header' - if l.Header == nil { - l.Header = new(LightClientHeaderCapella) + // Field 3: SyncAggregate + c.SyncAggregate = new(SyncAggregate) + if err = c.SyncAggregate.UnmarshalSSZ(sszSlice3); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) } - size += l.Header.SizeSSZ() - return + // Field 4: SignatureSlot + if err = c.SignatureSlot.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("SignatureSlot: %w", err) + } + return err } -// HashTreeRoot ssz hashes the LightClientBootstrapCapella object -func (l *LightClientBootstrapCapella) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(l) +func (c *LightClientFinalityUpdateCapella) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the LightClientBootstrapCapella object with a hasher -func (l *LightClientBootstrapCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *LightClientFinalityUpdateCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Header' - if err = l.Header.HashTreeRootWith(hh); err != nil { - return + // Field 0: AttestedHeader + if err := c.AttestedHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("AttestedHeader: %w", err) } - - // Field (1) 'CurrentSyncCommittee' - if err = l.CurrentSyncCommittee.HashTreeRootWith(hh); err != nil { - return + // Field 1: FinalizedHeader + if err := c.FinalizedHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("FinalizedHeader: %w", err) } - - // Field (2) 'CurrentSyncCommitteeBranch' + // Field 2: FinalityBranch { - if size := len(l.CurrentSyncCommitteeBranch); size != 5 { - err = ssz.ErrVectorLengthFn("--.CurrentSyncCommitteeBranch", size, 5) - return + if len(c.FinalityBranch) != 6 { + return ssz.ErrVectorLength } subIndx := hh.Index() - for _, i := range l.CurrentSyncCommitteeBranch { - if len(i) != 32 { - err = ssz.ErrBytesLength - return + for _, o := range c.FinalityBranch { + if len(o) != 32 { + return ssz.ErrBytesLength } - hh.Append(i) + hh.Append(o) } hh.Merkleize(subIndx) } - + // Field 3: SyncAggregate + if err := c.SyncAggregate.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) + } + // Field 4: SignatureSlot + if err := c.SignatureSlot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SignatureSlot: %w", err) + } hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the LightClientUpdateCapella object -func (l *LightClientUpdateCapella) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(l) +func (c *LightClientHeaderCapella) SizeSSZ() int { + size := 244 + if c.Execution == nil { + c.Execution = new(v1.ExecutionPayloadHeaderCapella) + } + size += c.Execution.SizeSSZ() + return size } -// MarshalSSZTo ssz marshals the LightClientUpdateCapella object to a target array -func (l *LightClientUpdateCapella) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(2052) +func (c *LightClientHeaderCapella) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Offset (0) 'AttestedHeader' - dst = ssz.WriteOffset(dst, offset) - if l.AttestedHeader == nil { - l.AttestedHeader = new(LightClientHeaderCapella) - } - offset += l.AttestedHeader.SizeSSZ() +func (c *LightClientHeaderCapella) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 244 - // Field (1) 'NextSyncCommittee' - if l.NextSyncCommittee == nil { - l.NextSyncCommittee = new(SyncCommittee) + // Field 0: Beacon + if c.Beacon == nil { + c.Beacon = new(BeaconBlockHeader) } - if dst, err = l.NextSyncCommittee.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.Beacon.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Beacon: %w", err) } - // Field (2) 'NextSyncCommitteeBranch' - if size := len(l.NextSyncCommitteeBranch); size != 5 { - err = ssz.ErrVectorLengthFn("--.NextSyncCommitteeBranch", size, 5) - return - } - for ii := 0; ii < 5; ii++ { - if size := len(l.NextSyncCommitteeBranch[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.NextSyncCommitteeBranch[ii]", size, 32) - return - } - dst = append(dst, l.NextSyncCommitteeBranch[ii]...) + // Field 1: Execution + if c.Execution == nil { + c.Execution = new(v1.ExecutionPayloadHeaderCapella) } - - // Offset (3) 'FinalizedHeader' dst = ssz.WriteOffset(dst, offset) - if l.FinalizedHeader == nil { - l.FinalizedHeader = new(LightClientHeaderCapella) - } - offset += l.FinalizedHeader.SizeSSZ() + offset += c.Execution.SizeSSZ() - // Field (4) 'FinalityBranch' - if size := len(l.FinalityBranch); size != 6 { - err = ssz.ErrVectorLengthFn("--.FinalityBranch", size, 6) - return + // Field 2: ExecutionBranch + if len(c.ExecutionBranch) != 4 { + return nil, ssz.ErrBytesLength } - for ii := 0; ii < 6; ii++ { - if size := len(l.FinalityBranch[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.FinalityBranch[ii]", size, 32) - return + for _, o := range c.ExecutionBranch { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, l.FinalityBranch[ii]...) - } - - // Field (5) 'SyncAggregate' - if l.SyncAggregate == nil { - l.SyncAggregate = new(SyncAggregate) - } - if dst, err = l.SyncAggregate.MarshalSSZTo(dst); err != nil { - return - } - - // Field (6) 'SignatureSlot' - dst = ssz.MarshalUint(dst, l.SignatureSlot) - - // Field (0) 'AttestedHeader' - if dst, err = l.AttestedHeader.MarshalSSZTo(dst); err != nil { - return + dst = append(dst, o...) } - // Field (3) 'FinalizedHeader' - if dst, err = l.FinalizedHeader.MarshalSSZTo(dst); err != nil { - return + // Field 1: Execution + if dst, err = c.Execution.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Execution: %w", err) } - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the LightClientUpdateCapella object -func (l *LightClientUpdateCapella) UnmarshalSSZ(buf []byte) error { +func (c *LightClientHeaderCapella) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 2052 { + if size < 244 { return ssz.ErrSize } - tail := buf - var o0, o3 uint64 + sszSlice0 := buf[0:112] // c.Beacon + sszSlice2 := buf[116:244] // c.ExecutionBranch - // Offset (0) 'AttestedHeader' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { + sszVarOffset1 := ssz.ReadOffset(buf[112:116]) // c.Execution + if sszVarOffset1 != 244 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset1 > size { return ssz.ErrOffset } + sszSlice1 := buf[sszVarOffset1:] // c.Execution - if o0 != 2052 { - return ssz.ErrInvalidVariableOffset + // Field 0: Beacon + c.Beacon = new(BeaconBlockHeader) + if err = c.Beacon.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Beacon: %w", err) } - // Field (1) 'NextSyncCommittee' - if l.NextSyncCommittee == nil { - l.NextSyncCommittee = new(SyncCommittee) - } - if err = l.NextSyncCommittee.UnmarshalSSZ(buf[4:1588]); err != nil { - return err + // Field 1: Execution + c.Execution = new(v1.ExecutionPayloadHeaderCapella) + if err = c.Execution.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Execution: %w", err) } - // Field (2) 'NextSyncCommitteeBranch' - l.NextSyncCommitteeBranch = make([][]byte, 5) - for ii := 0; ii < 5; ii++ { - if cap(l.NextSyncCommitteeBranch[ii]) == 0 { - l.NextSyncCommitteeBranch[ii] = make([]byte, 0, len(buf[1588:1748][ii*32:(ii+1)*32])) - } - l.NextSyncCommitteeBranch[ii] = append(l.NextSyncCommitteeBranch[ii], buf[1588:1748][ii*32:(ii+1)*32]...) - } + // Field 2: ExecutionBranch + { + c.ExecutionBranch = make([][]byte, 4) + for i := 0; i < 4; i++ { + var tmp []byte - // Offset (3) 'FinalizedHeader' - if o3 = ssz.ReadOffset(buf[1748:1752]); o3 > size || o0 > o3 { - return ssz.ErrOffset + tmpSlice := sszSlice2[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.ExecutionBranch[i] = tmp + } } + return err +} - // Field (4) 'FinalityBranch' - l.FinalityBranch = make([][]byte, 6) - for ii := 0; ii < 6; ii++ { - if cap(l.FinalityBranch[ii]) == 0 { - l.FinalityBranch[ii] = make([]byte, 0, len(buf[1752:1944][ii*32:(ii+1)*32])) - } - l.FinalityBranch[ii] = append(l.FinalityBranch[ii], buf[1752:1944][ii*32:(ii+1)*32]...) +func (c *LightClientHeaderCapella) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (5) 'SyncAggregate' - if l.SyncAggregate == nil { - l.SyncAggregate = new(SyncAggregate) +func (c *LightClientHeaderCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Beacon + if err := c.Beacon.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Beacon: %w", err) } - if err = l.SyncAggregate.UnmarshalSSZ(buf[1944:2044]); err != nil { - return err + // Field 1: Execution + if err := c.Execution.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Execution: %w", err) } - - // Field (6) 'SignatureSlot' - l.SignatureSlot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[2044:2052]) - - // Field (0) 'AttestedHeader' + // Field 2: ExecutionBranch { - buf = tail[o0:o3] - if l.AttestedHeader == nil { - l.AttestedHeader = new(LightClientHeaderCapella) + if len(c.ExecutionBranch) != 4 { + return ssz.ErrVectorLength } - if err = l.AttestedHeader.UnmarshalSSZ(buf); err != nil { - return err + subIndx := hh.Index() + for _, o := range c.ExecutionBranch { + if len(o) != 32 { + return ssz.ErrBytesLength + } + hh.Append(o) } + hh.Merkleize(subIndx) } + hh.Merkleize(indx) + return nil +} - // Field (3) 'FinalizedHeader' - { - buf = tail[o3:] - if l.FinalizedHeader == nil { - l.FinalizedHeader = new(LightClientHeaderCapella) - } - if err = l.FinalizedHeader.UnmarshalSSZ(buf); err != nil { - return err - } +func (c *LightClientOptimisticUpdateCapella) SizeSSZ() int { + size := 112 + if c.AttestedHeader == nil { + c.AttestedHeader = new(LightClientHeaderCapella) } - return err + size += c.AttestedHeader.SizeSSZ() + return size +} + +func (c *LightClientOptimisticUpdateCapella) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// SizeSSZ returns the ssz encoded size in bytes for the LightClientUpdateCapella object -func (l *LightClientUpdateCapella) SizeSSZ() (size int) { - size = 2052 +func (c *LightClientOptimisticUpdateCapella) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 112 - // Field (0) 'AttestedHeader' - if l.AttestedHeader == nil { - l.AttestedHeader = new(LightClientHeaderCapella) + // Field 0: AttestedHeader + if c.AttestedHeader == nil { + c.AttestedHeader = new(LightClientHeaderCapella) } - size += l.AttestedHeader.SizeSSZ() + dst = ssz.WriteOffset(dst, offset) + offset += c.AttestedHeader.SizeSSZ() - // Field (3) 'FinalizedHeader' - if l.FinalizedHeader == nil { - l.FinalizedHeader = new(LightClientHeaderCapella) + // Field 1: SyncAggregate + if c.SyncAggregate == nil { + c.SyncAggregate = new(SyncAggregate) + } + if dst, err = c.SyncAggregate.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SyncAggregate: %w", err) } - size += l.FinalizedHeader.SizeSSZ() - return -} + // Field 2: SignatureSlot + if dst, err = c.SignatureSlot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SignatureSlot: %w", err) + } -// HashTreeRoot ssz hashes the LightClientUpdateCapella object -func (l *LightClientUpdateCapella) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(l) + // Field 0: AttestedHeader + if dst, err = c.AttestedHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("AttestedHeader: %w", err) + } + return dst, err } -// HashTreeRootWith ssz hashes the LightClientUpdateCapella object with a hasher -func (l *LightClientUpdateCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'AttestedHeader' - if err = l.AttestedHeader.HashTreeRootWith(hh); err != nil { - return +func (c *LightClientOptimisticUpdateCapella) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 112 { + return ssz.ErrSize } - // Field (1) 'NextSyncCommittee' - if err = l.NextSyncCommittee.HashTreeRootWith(hh); err != nil { - return - } + sszSlice1 := buf[4:104] // c.SyncAggregate + sszSlice2 := buf[104:112] // c.SignatureSlot - // Field (2) 'NextSyncCommitteeBranch' - { - if size := len(l.NextSyncCommitteeBranch); size != 5 { - err = ssz.ErrVectorLengthFn("--.NextSyncCommitteeBranch", size, 5) - return - } - subIndx := hh.Index() - for _, i := range l.NextSyncCommitteeBranch { - if len(i) != 32 { - err = ssz.ErrBytesLength - return - } - hh.Append(i) - } - hh.Merkleize(subIndx) + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.AttestedHeader + if sszVarOffset0 != 112 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset0 > size { + return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:] // c.AttestedHeader - // Field (3) 'FinalizedHeader' - if err = l.FinalizedHeader.HashTreeRootWith(hh); err != nil { - return + // Field 0: AttestedHeader + c.AttestedHeader = new(LightClientHeaderCapella) + if err = c.AttestedHeader.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("AttestedHeader: %w", err) } - // Field (4) 'FinalityBranch' - { - if size := len(l.FinalityBranch); size != 6 { - err = ssz.ErrVectorLengthFn("--.FinalityBranch", size, 6) - return - } - subIndx := hh.Index() - for _, i := range l.FinalityBranch { - if len(i) != 32 { - err = ssz.ErrBytesLength - return - } - hh.Append(i) - } - hh.Merkleize(subIndx) + // Field 1: SyncAggregate + c.SyncAggregate = new(SyncAggregate) + if err = c.SyncAggregate.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) } - // Field (5) 'SyncAggregate' - if err = l.SyncAggregate.HashTreeRootWith(hh); err != nil { - return + // Field 2: SignatureSlot + if err = c.SignatureSlot.UnmarshalSSZ(sszSlice2); err != nil { + return fmt.Errorf("SignatureSlot: %w", err) } + return err +} - // Field (6) 'SignatureSlot' - ssz.PutUint(hh, l.SignatureSlot) +func (c *LightClientOptimisticUpdateCapella) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} +func (c *LightClientOptimisticUpdateCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: AttestedHeader + if err := c.AttestedHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("AttestedHeader: %w", err) + } + // Field 1: SyncAggregate + if err := c.SyncAggregate.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) + } + // Field 2: SignatureSlot + if err := c.SignatureSlot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SignatureSlot: %w", err) + } hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the LightClientFinalityUpdateCapella object -func (l *LightClientFinalityUpdateCapella) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(l) +func (c *LightClientUpdateCapella) SizeSSZ() int { + size := 2052 + if c.AttestedHeader == nil { + c.AttestedHeader = new(LightClientHeaderCapella) + } + size += c.AttestedHeader.SizeSSZ() + if c.FinalizedHeader == nil { + c.FinalizedHeader = new(LightClientHeaderCapella) + } + size += c.FinalizedHeader.SizeSSZ() + return size } -// MarshalSSZTo ssz marshals the LightClientFinalityUpdateCapella object to a target array -func (l *LightClientFinalityUpdateCapella) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(308) +func (c *LightClientUpdateCapella) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Offset (0) 'AttestedHeader' - dst = ssz.WriteOffset(dst, offset) - if l.AttestedHeader == nil { - l.AttestedHeader = new(LightClientHeaderCapella) - } - offset += l.AttestedHeader.SizeSSZ() +func (c *LightClientUpdateCapella) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 2052 - // Offset (1) 'FinalizedHeader' + // Field 0: AttestedHeader + if c.AttestedHeader == nil { + c.AttestedHeader = new(LightClientHeaderCapella) + } dst = ssz.WriteOffset(dst, offset) - if l.FinalizedHeader == nil { - l.FinalizedHeader = new(LightClientHeaderCapella) + offset += c.AttestedHeader.SizeSSZ() + + // Field 1: NextSyncCommittee + if c.NextSyncCommittee == nil { + c.NextSyncCommittee = new(SyncCommittee) + } + if dst, err = c.NextSyncCommittee.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("NextSyncCommittee: %w", err) } - offset += l.FinalizedHeader.SizeSSZ() - // Field (2) 'FinalityBranch' - if size := len(l.FinalityBranch); size != 6 { - err = ssz.ErrVectorLengthFn("--.FinalityBranch", size, 6) - return + // Field 2: NextSyncCommitteeBranch + if len(c.NextSyncCommitteeBranch) != 5 { + return nil, ssz.ErrBytesLength } - for ii := 0; ii < 6; ii++ { - if size := len(l.FinalityBranch[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.FinalityBranch[ii]", size, 32) - return + for _, o := range c.NextSyncCommitteeBranch { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, l.FinalityBranch[ii]...) + dst = append(dst, o...) } - // Field (3) 'SyncAggregate' - if l.SyncAggregate == nil { - l.SyncAggregate = new(SyncAggregate) + // Field 3: FinalizedHeader + if c.FinalizedHeader == nil { + c.FinalizedHeader = new(LightClientHeaderCapella) } - if dst, err = l.SyncAggregate.MarshalSSZTo(dst); err != nil { - return + dst = ssz.WriteOffset(dst, offset) + offset += c.FinalizedHeader.SizeSSZ() + + // Field 4: FinalityBranch + if len(c.FinalityBranch) != 6 { + return nil, ssz.ErrBytesLength + } + for _, o := range c.FinalityBranch { + if len(o) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) } - // Field (4) 'SignatureSlot' - dst = ssz.MarshalUint(dst, l.SignatureSlot) + // Field 5: SyncAggregate + if c.SyncAggregate == nil { + c.SyncAggregate = new(SyncAggregate) + } + if dst, err = c.SyncAggregate.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SyncAggregate: %w", err) + } - // Field (0) 'AttestedHeader' - if dst, err = l.AttestedHeader.MarshalSSZTo(dst); err != nil { - return + // Field 6: SignatureSlot + if dst, err = c.SignatureSlot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SignatureSlot: %w", err) } - // Field (1) 'FinalizedHeader' - if dst, err = l.FinalizedHeader.MarshalSSZTo(dst); err != nil { - return + // Field 0: AttestedHeader + if dst, err = c.AttestedHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("AttestedHeader: %w", err) } - return + // Field 3: FinalizedHeader + if dst, err = c.FinalizedHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("FinalizedHeader: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the LightClientFinalityUpdateCapella object -func (l *LightClientFinalityUpdateCapella) UnmarshalSSZ(buf []byte) error { +func (c *LightClientUpdateCapella) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 308 { + if size < 2052 { return ssz.ErrSize } - tail := buf - var o0, o1 uint64 - - // Offset (0) 'AttestedHeader' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } + sszSlice1 := buf[4:1588] // c.NextSyncCommittee + sszSlice2 := buf[1588:1748] // c.NextSyncCommitteeBranch + sszSlice4 := buf[1752:1944] // c.FinalityBranch + sszSlice5 := buf[1944:2044] // c.SyncAggregate + sszSlice6 := buf[2044:2052] // c.SignatureSlot - if o0 != 308 { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.AttestedHeader + if sszVarOffset0 != 2052 { return ssz.ErrInvalidVariableOffset } - - // Offset (1) 'FinalizedHeader' - if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 { + if sszVarOffset0 > size { return ssz.ErrOffset } - - // Field (2) 'FinalityBranch' - l.FinalityBranch = make([][]byte, 6) - for ii := 0; ii < 6; ii++ { - if cap(l.FinalityBranch[ii]) == 0 { - l.FinalityBranch[ii] = make([]byte, 0, len(buf[8:200][ii*32:(ii+1)*32])) - } - l.FinalityBranch[ii] = append(l.FinalityBranch[ii], buf[8:200][ii*32:(ii+1)*32]...) + sszVarOffset3 := ssz.ReadOffset(buf[1748:1752]) // c.FinalizedHeader + if sszVarOffset3 > size || sszVarOffset3 < sszVarOffset0 { + return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:sszVarOffset3] // c.AttestedHeader + sszSlice3 := buf[sszVarOffset3:] // c.FinalizedHeader - // Field (3) 'SyncAggregate' - if l.SyncAggregate == nil { - l.SyncAggregate = new(SyncAggregate) - } - if err = l.SyncAggregate.UnmarshalSSZ(buf[200:300]); err != nil { - return err + // Field 0: AttestedHeader + c.AttestedHeader = new(LightClientHeaderCapella) + if err = c.AttestedHeader.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("AttestedHeader: %w", err) } - // Field (4) 'SignatureSlot' - l.SignatureSlot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[300:308]) + // Field 1: NextSyncCommittee + c.NextSyncCommittee = new(SyncCommittee) + if err = c.NextSyncCommittee.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("NextSyncCommittee: %w", err) + } - // Field (0) 'AttestedHeader' + // Field 2: NextSyncCommitteeBranch { - buf = tail[o0:o1] - if l.AttestedHeader == nil { - l.AttestedHeader = new(LightClientHeaderCapella) - } - if err = l.AttestedHeader.UnmarshalSSZ(buf); err != nil { - return err + c.NextSyncCommitteeBranch = make([][]byte, 5) + for i := 0; i < 5; i++ { + var tmp []byte + + tmpSlice := sszSlice2[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.NextSyncCommitteeBranch[i] = tmp } } - // Field (1) 'FinalizedHeader' - { - buf = tail[o1:] - if l.FinalizedHeader == nil { - l.FinalizedHeader = new(LightClientHeaderCapella) - } - if err = l.FinalizedHeader.UnmarshalSSZ(buf); err != nil { - return err - } + // Field 3: FinalizedHeader + c.FinalizedHeader = new(LightClientHeaderCapella) + if err = c.FinalizedHeader.UnmarshalSSZ(sszSlice3); err != nil { + return fmt.Errorf("FinalizedHeader: %w", err) } - return err -} -// SizeSSZ returns the ssz encoded size in bytes for the LightClientFinalityUpdateCapella object -func (l *LightClientFinalityUpdateCapella) SizeSSZ() (size int) { - size = 308 + // Field 4: FinalityBranch + { + c.FinalityBranch = make([][]byte, 6) + for i := 0; i < 6; i++ { + var tmp []byte - // Field (0) 'AttestedHeader' - if l.AttestedHeader == nil { - l.AttestedHeader = new(LightClientHeaderCapella) + tmpSlice := sszSlice4[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.FinalityBranch[i] = tmp + } } - size += l.AttestedHeader.SizeSSZ() - // Field (1) 'FinalizedHeader' - if l.FinalizedHeader == nil { - l.FinalizedHeader = new(LightClientHeaderCapella) + // Field 5: SyncAggregate + c.SyncAggregate = new(SyncAggregate) + if err = c.SyncAggregate.UnmarshalSSZ(sszSlice5); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) } - size += l.FinalizedHeader.SizeSSZ() - return + // Field 6: SignatureSlot + if err = c.SignatureSlot.UnmarshalSSZ(sszSlice6); err != nil { + return fmt.Errorf("SignatureSlot: %w", err) + } + return err } -// HashTreeRoot ssz hashes the LightClientFinalityUpdateCapella object -func (l *LightClientFinalityUpdateCapella) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(l) +func (c *LightClientUpdateCapella) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the LightClientFinalityUpdateCapella object with a hasher -func (l *LightClientFinalityUpdateCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *LightClientUpdateCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'AttestedHeader' - if err = l.AttestedHeader.HashTreeRootWith(hh); err != nil { - return + // Field 0: AttestedHeader + if err := c.AttestedHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("AttestedHeader: %w", err) } - - // Field (1) 'FinalizedHeader' - if err = l.FinalizedHeader.HashTreeRootWith(hh); err != nil { - return + // Field 1: NextSyncCommittee + if err := c.NextSyncCommittee.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("NextSyncCommittee: %w", err) } - - // Field (2) 'FinalityBranch' + // Field 2: NextSyncCommitteeBranch { - if size := len(l.FinalityBranch); size != 6 { - err = ssz.ErrVectorLengthFn("--.FinalityBranch", size, 6) - return + if len(c.NextSyncCommitteeBranch) != 5 { + return ssz.ErrVectorLength } subIndx := hh.Index() - for _, i := range l.FinalityBranch { - if len(i) != 32 { - err = ssz.ErrBytesLength - return + for _, o := range c.NextSyncCommitteeBranch { + if len(o) != 32 { + return ssz.ErrBytesLength } - hh.Append(i) + hh.Append(o) } hh.Merkleize(subIndx) } - - // Field (3) 'SyncAggregate' - if err = l.SyncAggregate.HashTreeRootWith(hh); err != nil { - return + // Field 3: FinalizedHeader + if err := c.FinalizedHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("FinalizedHeader: %w", err) + } + // Field 4: FinalityBranch + { + if len(c.FinalityBranch) != 6 { + return ssz.ErrVectorLength + } + subIndx := hh.Index() + for _, o := range c.FinalityBranch { + if len(o) != 32 { + return ssz.ErrBytesLength + } + hh.Append(o) + } + hh.Merkleize(subIndx) + } + // Field 5: SyncAggregate + if err := c.SyncAggregate.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) + } + // Field 6: SignatureSlot + if err := c.SignatureSlot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SignatureSlot: %w", err) } - - // Field (4) 'SignatureSlot' - ssz.PutUint(hh, l.SignatureSlot) - hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the LightClientOptimisticUpdateCapella object -func (l *LightClientOptimisticUpdateCapella) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(l) +func (c *SignedBeaconBlockCapella) SizeSSZ() int { + size := 100 + if c.Block == nil { + c.Block = new(BeaconBlockCapella) + } + size += c.Block.SizeSSZ() + return size } -// MarshalSSZTo ssz marshals the LightClientOptimisticUpdateCapella object to a target array -func (l *LightClientOptimisticUpdateCapella) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(112) +func (c *SignedBeaconBlockCapella) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Offset (0) 'AttestedHeader' - dst = ssz.WriteOffset(dst, offset) - if l.AttestedHeader == nil { - l.AttestedHeader = new(LightClientHeaderCapella) - } - offset += l.AttestedHeader.SizeSSZ() +func (c *SignedBeaconBlockCapella) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 100 - // Field (1) 'SyncAggregate' - if l.SyncAggregate == nil { - l.SyncAggregate = new(SyncAggregate) + // Field 0: Block + if c.Block == nil { + c.Block = new(BeaconBlockCapella) } - if dst, err = l.SyncAggregate.MarshalSSZTo(dst); err != nil { - return - } - - // Field (2) 'SignatureSlot' - dst = ssz.MarshalUint(dst, l.SignatureSlot) + dst = ssz.WriteOffset(dst, offset) + offset += c.Block.SizeSSZ() - // Field (0) 'AttestedHeader' - if dst, err = l.AttestedHeader.MarshalSSZTo(dst); err != nil { - return + // Field 1: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.Signature...) - return + // Field 0: Block + if dst, err = c.Block.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Block: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the LightClientOptimisticUpdateCapella object -func (l *LightClientOptimisticUpdateCapella) UnmarshalSSZ(buf []byte) error { +func (c *SignedBeaconBlockCapella) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 112 { + if size < 100 { return ssz.ErrSize } - tail := buf - var o0 uint64 + sszSlice1 := buf[4:100] // c.Signature - // Offset (0) 'AttestedHeader' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } - - if o0 != 112 { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Block + if sszVarOffset0 != 100 { return ssz.ErrInvalidVariableOffset } - - // Field (1) 'SyncAggregate' - if l.SyncAggregate == nil { - l.SyncAggregate = new(SyncAggregate) - } - if err = l.SyncAggregate.UnmarshalSSZ(buf[4:104]); err != nil { - return err + if sszVarOffset0 > size { + return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:] // c.Block - // Field (2) 'SignatureSlot' - l.SignatureSlot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[104:112]) - - // Field (0) 'AttestedHeader' - { - buf = tail[o0:] - if l.AttestedHeader == nil { - l.AttestedHeader = new(LightClientHeaderCapella) - } - if err = l.AttestedHeader.UnmarshalSSZ(buf); err != nil { - return err - } + // Field 0: Block + c.Block = new(BeaconBlockCapella) + if err = c.Block.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Block: %w", err) } + + // Field 1: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice1...) return err } -// SizeSSZ returns the ssz encoded size in bytes for the LightClientOptimisticUpdateCapella object -func (l *LightClientOptimisticUpdateCapella) SizeSSZ() (size int) { - size = 112 - - // Field (0) 'AttestedHeader' - if l.AttestedHeader == nil { - l.AttestedHeader = new(LightClientHeaderCapella) +func (c *SignedBeaconBlockCapella) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - size += l.AttestedHeader.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the LightClientOptimisticUpdateCapella object -func (l *LightClientOptimisticUpdateCapella) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(l) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the LightClientOptimisticUpdateCapella object with a hasher -func (l *LightClientOptimisticUpdateCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *SignedBeaconBlockCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'AttestedHeader' - if err = l.AttestedHeader.HashTreeRootWith(hh); err != nil { - return + // Field 0: Block + if err := c.Block.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Block: %w", err) } - - // Field (1) 'SyncAggregate' - if err = l.SyncAggregate.HashTreeRootWith(hh); err != nil { - return + // Field 1: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength } - - // Field (2) 'SignatureSlot' - ssz.PutUint(hh, l.SignatureSlot) - + hh.PutBytes(c.Signature) hh.Merkleize(indx) - return + return nil +} + +func (c *SignedBlindedBeaconBlockCapella) SizeSSZ() int { + size := 100 + if c.Block == nil { + c.Block = new(BlindedBeaconBlockCapella) + } + size += c.Block.SizeSSZ() + return size } -// MarshalSSZ ssz marshals the LightClientHeaderCapella object -func (l *LightClientHeaderCapella) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(l) +func (c *SignedBlindedBeaconBlockCapella) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the LightClientHeaderCapella object to a target array -func (l *LightClientHeaderCapella) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(244) +func (c *SignedBlindedBeaconBlockCapella) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 100 - // Field (0) 'Beacon' - if l.Beacon == nil { - l.Beacon = new(BeaconBlockHeader) - } - if dst, err = l.Beacon.MarshalSSZTo(dst); err != nil { - return + // Field 0: Block + if c.Block == nil { + c.Block = new(BlindedBeaconBlockCapella) } - - // Offset (1) 'Execution' dst = ssz.WriteOffset(dst, offset) - if l.Execution == nil { - l.Execution = new(v1.ExecutionPayloadHeaderCapella) - } - offset += l.Execution.SizeSSZ() + offset += c.Block.SizeSSZ() - // Field (2) 'ExecutionBranch' - if size := len(l.ExecutionBranch); size != 4 { - err = ssz.ErrVectorLengthFn("--.ExecutionBranch", size, 4) - return - } - for ii := 0; ii < 4; ii++ { - if size := len(l.ExecutionBranch[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.ExecutionBranch[ii]", size, 32) - return - } - dst = append(dst, l.ExecutionBranch[ii]...) + // Field 1: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.Signature...) - // Field (1) 'Execution' - if dst, err = l.Execution.MarshalSSZTo(dst); err != nil { - return + // Field 0: Block + if dst, err = c.Block.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Block: %w", err) } - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the LightClientHeaderCapella object -func (l *LightClientHeaderCapella) UnmarshalSSZ(buf []byte) error { +func (c *SignedBlindedBeaconBlockCapella) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 244 { + if size < 100 { return ssz.ErrSize } - tail := buf - var o1 uint64 + sszSlice1 := buf[4:100] // c.Signature - // Field (0) 'Beacon' - if l.Beacon == nil { - l.Beacon = new(BeaconBlockHeader) - } - if err = l.Beacon.UnmarshalSSZ(buf[0:112]); err != nil { - return err + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Block + if sszVarOffset0 != 100 { + return ssz.ErrInvalidVariableOffset } - - // Offset (1) 'Execution' - if o1 = ssz.ReadOffset(buf[112:116]); o1 > size { + if sszVarOffset0 > size { return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:] // c.Block - if o1 != 244 { - return ssz.ErrInvalidVariableOffset - } - - // Field (2) 'ExecutionBranch' - l.ExecutionBranch = make([][]byte, 4) - for ii := 0; ii < 4; ii++ { - if cap(l.ExecutionBranch[ii]) == 0 { - l.ExecutionBranch[ii] = make([]byte, 0, len(buf[116:244][ii*32:(ii+1)*32])) - } - l.ExecutionBranch[ii] = append(l.ExecutionBranch[ii], buf[116:244][ii*32:(ii+1)*32]...) + // Field 0: Block + c.Block = new(BlindedBeaconBlockCapella) + if err = c.Block.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Block: %w", err) } - // Field (1) 'Execution' - { - buf = tail[o1:] - if l.Execution == nil { - l.Execution = new(v1.ExecutionPayloadHeaderCapella) - } - if err = l.Execution.UnmarshalSSZ(buf); err != nil { - return err - } - } + // Field 1: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice1...) return err } -// SizeSSZ returns the ssz encoded size in bytes for the LightClientHeaderCapella object -func (l *LightClientHeaderCapella) SizeSSZ() (size int) { - size = 244 - - // Field (1) 'Execution' - if l.Execution == nil { - l.Execution = new(v1.ExecutionPayloadHeaderCapella) +func (c *SignedBlindedBeaconBlockCapella) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - size += l.Execution.SizeSSZ() - - return + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRoot ssz hashes the LightClientHeaderCapella object -func (l *LightClientHeaderCapella) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(l) -} - -// HashTreeRootWith ssz hashes the LightClientHeaderCapella object with a hasher -func (l *LightClientHeaderCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *SignedBlindedBeaconBlockCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Beacon' - if err = l.Beacon.HashTreeRootWith(hh); err != nil { - return + // Field 0: Block + if err := c.Block.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Block: %w", err) } - - // Field (1) 'Execution' - if err = l.Execution.HashTreeRootWith(hh); err != nil { - return + // Field 1: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength } + hh.PutBytes(c.Signature) + hh.Merkleize(indx) + return nil +} - // Field (2) 'ExecutionBranch' - { - if size := len(l.ExecutionBranch); size != 4 { - err = ssz.ErrVectorLengthFn("--.ExecutionBranch", size, 4) - return - } - subIndx := hh.Index() - for _, i := range l.ExecutionBranch { - if len(i) != 32 { - err = ssz.ErrBytesLength - return - } - hh.Append(i) - } - hh.Merkleize(subIndx) - } +func (c *SignedBLSToExecutionChange) SizeSSZ() int { + size := 172 - hh.Merkleize(indx) - return + return size } -// MarshalSSZ ssz marshals the SignedBLSToExecutionChange object -func (s *SignedBLSToExecutionChange) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) +func (c *SignedBLSToExecutionChange) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the SignedBLSToExecutionChange object to a target array -func (s *SignedBLSToExecutionChange) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *SignedBLSToExecutionChange) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (0) 'Message' - if s.Message == nil { - s.Message = new(BLSToExecutionChange) + // Field 0: Message + if c.Message == nil { + c.Message = new(BLSToExecutionChange) } - if dst, err = s.Message.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.Message.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Message: %w", err) } - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 1: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } - dst = append(dst, s.Signature...) + dst = append(dst, c.Signature...) - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the SignedBLSToExecutionChange object -func (s *SignedBLSToExecutionChange) UnmarshalSSZ(buf []byte) error { +func (c *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 - } + sszSlice0 := buf[0:76] // c.Message + sszSlice1 := buf[76:172] // c.Signature - // Field (1) 'Signature' - if cap(s.Signature) == 0 { - s.Signature = make([]byte, 0, len(buf[76:172])) + // Field 0: Message + c.Message = new(BLSToExecutionChange) + if err = c.Message.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Message: %w", err) } - s.Signature = append(s.Signature, buf[76:172]...) + // Field 1: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice1...) 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) +func (c *SignedBLSToExecutionChange) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the SignedBLSToExecutionChange object with a hasher -func (s *SignedBLSToExecutionChange) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *SignedBLSToExecutionChange) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Message' - if err = s.Message.HashTreeRootWith(hh); err != nil { - return + // Field 0: Message + if err := c.Message.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Message: %w", err) } - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 1: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength } - hh.PutBytes(s.Signature) - + hh.PutBytes(c.Signature) hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the BLSToExecutionChange object -func (b *BLSToExecutionChange) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) +func (c *SignedBuilderBidCapella) SizeSSZ() int { + size := 100 + if c.Message == nil { + c.Message = new(BuilderBidCapella) + } + size += c.Message.SizeSSZ() + return size } -// MarshalSSZTo ssz marshals the BLSToExecutionChange object to a target array -func (b *BLSToExecutionChange) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *SignedBuilderBidCapella) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (0) 'ValidatorIndex' - dst = ssz.MarshalUint(dst, b.ValidatorIndex) +func (c *SignedBuilderBidCapella) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 100 - // Field (1) 'FromBlsPubkey' - if size := len(b.FromBlsPubkey); size != 48 { - err = ssz.ErrBytesLengthFn("--.FromBlsPubkey", size, 48) - return + // Field 0: Message + if c.Message == nil { + c.Message = new(BuilderBidCapella) } - dst = append(dst, b.FromBlsPubkey...) + dst = ssz.WriteOffset(dst, offset) + offset += c.Message.SizeSSZ() - // Field (2) 'ToExecutionAddress' - if size := len(b.ToExecutionAddress); size != 20 { - err = ssz.ErrBytesLengthFn("--.ToExecutionAddress", size, 20) - return + // Field 1: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.ToExecutionAddress...) + dst = append(dst, c.Signature...) - return + // Field 0: Message + if dst, err = c.Message.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Message: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the BLSToExecutionChange object -func (b *BLSToExecutionChange) UnmarshalSSZ(buf []byte) error { +func (c *SignedBuilderBidCapella) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 76 { + if size < 100 { return ssz.ErrSize } - // Field (0) 'ValidatorIndex' - b.ValidatorIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[0:8]) + sszSlice1 := buf[4:100] // c.Signature - // Field (1) 'FromBlsPubkey' - if cap(b.FromBlsPubkey) == 0 { - b.FromBlsPubkey = make([]byte, 0, len(buf[8:56])) + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Message + if sszVarOffset0 != 100 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset0 > size { + return ssz.ErrOffset } - b.FromBlsPubkey = append(b.FromBlsPubkey, buf[8:56]...) + sszSlice0 := buf[sszVarOffset0:] // c.Message - // Field (2) 'ToExecutionAddress' - if cap(b.ToExecutionAddress) == 0 { - b.ToExecutionAddress = make([]byte, 0, len(buf[56:76])) + // Field 0: Message + c.Message = new(BuilderBidCapella) + if err = c.Message.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Message: %w", err) } - b.ToExecutionAddress = append(b.ToExecutionAddress, buf[56:76]...) + // Field 1: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice1...) 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) +func (c *SignedBuilderBidCapella) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the BLSToExecutionChange object with a hasher -func (b *BLSToExecutionChange) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *SignedBuilderBidCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'ValidatorIndex' - ssz.PutUint(hh, b.ValidatorIndex) - - // Field (1) 'FromBlsPubkey' - if size := len(b.FromBlsPubkey); size != 48 { - err = ssz.ErrBytesLengthFn("--.FromBlsPubkey", size, 48) - return + // Field 0: Message + if err := c.Message.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Message: %w", err) } - hh.PutBytes(b.FromBlsPubkey) - - // Field (2) 'ToExecutionAddress' - if size := len(b.ToExecutionAddress); size != 20 { - err = ssz.ErrBytesLengthFn("--.ToExecutionAddress", size, 20) - return + // Field 1: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength } - hh.PutBytes(b.ToExecutionAddress) - + hh.PutBytes(c.Signature) hh.Merkleize(indx) - return + return nil } diff --git a/proto/prysm/v1alpha1/capella.ssz.go b/proto/prysm/v1alpha1/capella.ssz.go index d6743d309709..f9f7c2d27e45 100644 --- a/proto/prysm/v1alpha1/capella.ssz.go +++ b/proto/prysm/v1alpha1/capella.ssz.go @@ -1,3885 +1,3694 @@ //go:build !minimal -// Code generated by fastssz. DO NOT EDIT. package eth import ( - github_com_OffchainLabs_prysm_v7_consensus_types_primitives "github.com/OffchainLabs/prysm/v7/consensus-types/primitives" + binary "encoding/binary" + "fmt" + go_bitfield "github.com/OffchainLabs/go-bitfield" + ssz "github.com/OffchainLabs/methodical-ssz/ssz" v1 "github.com/OffchainLabs/prysm/v7/proto/engine/v1" - ssz "github.com/prysmaticlabs/fastssz" ) -// MarshalSSZ ssz marshals the SignedBeaconBlockCapella object -func (s *SignedBeaconBlockCapella) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) -} - -// MarshalSSZTo ssz marshals the SignedBeaconBlockCapella object to a target array -func (s *SignedBeaconBlockCapella) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(100) - - // Offset (0) 'Block' - dst = ssz.WriteOffset(dst, offset) - if s.Block == nil { - s.Block = new(BeaconBlockCapella) - } - offset += s.Block.SizeSSZ() - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.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 SignedBeaconBlockCapella object -func (s *SignedBeaconBlockCapella) 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(BeaconBlockCapella) - } - if err = s.Block.UnmarshalSSZ(buf); err != nil { - return err - } - } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the SignedBeaconBlockCapella object -func (s *SignedBeaconBlockCapella) SizeSSZ() (size int) { - size = 100 - - // Field (0) 'Block' - if s.Block == nil { - s.Block = new(BeaconBlockCapella) +func (c *BeaconBlockBodyCapella) SizeSSZ() int { + size := 388 + size += len(c.ProposerSlashings) * 416 + for _, o := range c.AttesterSlashings { + size += 4 + size += o.SizeSSZ() } - size += s.Block.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the SignedBeaconBlockCapella object -func (s *SignedBeaconBlockCapella) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) -} - -// HashTreeRootWith ssz hashes the SignedBeaconBlockCapella object with a hasher -func (s *SignedBeaconBlockCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'Block' - if err = s.Block.HashTreeRootWith(hh); err != nil { - return + for _, o := range c.Attestations { + size += 4 + size += o.SizeSSZ() } - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + size += len(c.Deposits) * 1240 + size += len(c.VoluntaryExits) * 112 + if c.ExecutionPayload == nil { + c.ExecutionPayload = new(v1.ExecutionPayloadCapella) } - hh.PutBytes(s.Signature) - - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the BeaconBlockCapella object -func (b *BeaconBlockCapella) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) + size += c.ExecutionPayload.SizeSSZ() + size += len(c.BlsToExecutionChanges) * 172 + return size } -// MarshalSSZTo ssz marshals the BeaconBlockCapella object to a target array -func (b *BeaconBlockCapella) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(84) - - // Field (0) 'Slot' - dst = ssz.MarshalUint(dst, b.Slot) - - // Field (1) 'ProposerIndex' - dst = ssz.MarshalUint(dst, b.ProposerIndex) - - // Field (2) 'ParentRoot' - if size := len(b.ParentRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentRoot", size, 32) - return - } - dst = append(dst, b.ParentRoot...) - - // Field (3) 'StateRoot' - if size := len(b.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return - } - dst = append(dst, b.StateRoot...) - - // Offset (4) 'Body' - dst = ssz.WriteOffset(dst, offset) - if b.Body == nil { - b.Body = new(BeaconBlockBodyCapella) - } - offset += b.Body.SizeSSZ() - - // Field (4) 'Body' - if dst, err = b.Body.MarshalSSZTo(dst); err != nil { - return - } - - return +func (c *BeaconBlockBodyCapella) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// UnmarshalSSZ ssz unmarshals the BeaconBlockCapella object -func (b *BeaconBlockCapella) UnmarshalSSZ(buf []byte) error { +func (c *BeaconBlockBodyCapella) MarshalSSZTo(dst []byte) ([]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.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[0:8]) - - // Field (1) 'ProposerIndex' - b.ProposerIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](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]...) - - // 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(BeaconBlockBodyCapella) - } - if err = b.Body.UnmarshalSSZ(buf); err != nil { - return err - } - } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the BeaconBlockCapella object -func (b *BeaconBlockCapella) SizeSSZ() (size int) { - size = 84 - - // Field (4) 'Body' - if b.Body == nil { - b.Body = new(BeaconBlockBodyCapella) - } - size += b.Body.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the BeaconBlockCapella object -func (b *BeaconBlockCapella) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) -} - -// HashTreeRootWith ssz hashes the BeaconBlockCapella object with a hasher -func (b *BeaconBlockCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'Slot' - ssz.PutUint(hh, b.Slot) - - // Field (1) 'ProposerIndex' - ssz.PutUint(hh, b.ProposerIndex) + offset := 388 - // Field (2) 'ParentRoot' - if size := len(b.ParentRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentRoot", size, 32) - return + // Field 0: RandaoReveal + if len(c.RandaoReveal) != 96 { + return nil, ssz.ErrBytesLength } - hh.PutBytes(b.ParentRoot) + dst = append(dst, c.RandaoReveal...) - // Field (3) 'StateRoot' - if size := len(b.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return + // Field 1: Eth1Data + if c.Eth1Data == nil { + c.Eth1Data = new(Eth1Data) } - hh.PutBytes(b.StateRoot) - - // Field (4) 'Body' - if err = b.Body.HashTreeRootWith(hh); err != nil { - return - } - - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the BeaconBlockBodyCapella object -func (b *BeaconBlockBodyCapella) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} - -// MarshalSSZTo ssz marshals the BeaconBlockBodyCapella object to a target array -func (b *BeaconBlockBodyCapella) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(388) - - // Field (0) 'RandaoReveal' - if size := len(b.RandaoReveal); size != 96 { - err = ssz.ErrBytesLengthFn("--.RandaoReveal", size, 96) - return - } - dst = append(dst, b.RandaoReveal...) - - // Field (1) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(Eth1Data) - } - if dst, err = b.Eth1Data.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.Eth1Data.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Eth1Data: %w", err) } - // Field (2) 'Graffiti' - if size := len(b.Graffiti); size != 32 { - err = ssz.ErrBytesLengthFn("--.Graffiti", size, 32) - return + // Field 2: Graffiti + if len(c.Graffiti) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.Graffiti...) + dst = append(dst, c.Graffiti...) - // Offset (3) 'ProposerSlashings' + // Field 3: ProposerSlashings dst = ssz.WriteOffset(dst, offset) - offset += len(b.ProposerSlashings) * 416 + offset += len(c.ProposerSlashings) * 416 - // Offset (4) 'AttesterSlashings' + // Field 4: AttesterSlashings dst = ssz.WriteOffset(dst, offset) - for ii := 0; ii < len(b.AttesterSlashings); ii++ { + for _, o := range c.AttesterSlashings { offset += 4 - offset += b.AttesterSlashings[ii].SizeSSZ() + offset += o.SizeSSZ() } - // Offset (5) 'Attestations' + // Field 5: Attestations dst = ssz.WriteOffset(dst, offset) - for ii := 0; ii < len(b.Attestations); ii++ { + for _, o := range c.Attestations { offset += 4 - offset += b.Attestations[ii].SizeSSZ() + offset += o.SizeSSZ() } - // Offset (6) 'Deposits' + // Field 6: Deposits dst = ssz.WriteOffset(dst, offset) - offset += len(b.Deposits) * 1240 + offset += len(c.Deposits) * 1240 - // Offset (7) 'VoluntaryExits' + // Field 7: VoluntaryExits dst = ssz.WriteOffset(dst, offset) - offset += len(b.VoluntaryExits) * 112 + offset += len(c.VoluntaryExits) * 112 - // Field (8) 'SyncAggregate' - if b.SyncAggregate == nil { - b.SyncAggregate = new(SyncAggregate) + // Field 8: SyncAggregate + if c.SyncAggregate == nil { + c.SyncAggregate = new(SyncAggregate) } - if dst, err = b.SyncAggregate.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.SyncAggregate.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SyncAggregate: %w", err) } - // Offset (9) 'ExecutionPayload' - dst = ssz.WriteOffset(dst, offset) - if b.ExecutionPayload == nil { - b.ExecutionPayload = new(v1.ExecutionPayloadCapella) + // Field 9: ExecutionPayload + if c.ExecutionPayload == nil { + c.ExecutionPayload = new(v1.ExecutionPayloadCapella) } - offset += b.ExecutionPayload.SizeSSZ() + dst = ssz.WriteOffset(dst, offset) + offset += c.ExecutionPayload.SizeSSZ() - // Offset (10) 'BlsToExecutionChanges' + // Field 10: BlsToExecutionChanges dst = ssz.WriteOffset(dst, offset) - offset += len(b.BlsToExecutionChanges) * 172 + offset += len(c.BlsToExecutionChanges) * 172 - // Field (3) 'ProposerSlashings' - if size := len(b.ProposerSlashings); size > 16 { - err = ssz.ErrListTooBigFn("--.ProposerSlashings", size, 16) - return + // Field 3: ProposerSlashings + if len(c.ProposerSlashings) > 16 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.ProposerSlashings); ii++ { - if dst, err = b.ProposerSlashings[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.ProposerSlashings { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ProposerSlashings: %w", err) } } - // Field (4) 'AttesterSlashings' - if size := len(b.AttesterSlashings); size > 2 { - err = ssz.ErrListTooBigFn("--.AttesterSlashings", size, 2) - return + // Field 4: AttesterSlashings + if len(c.AttesterSlashings) > 2 { + return nil, ssz.ErrListTooBig } { - offset = 4 * len(b.AttesterSlashings) - for ii := 0; ii < len(b.AttesterSlashings); ii++ { + offset = 4 * len(c.AttesterSlashings) + for _, o := range c.AttesterSlashings { dst = ssz.WriteOffset(dst, offset) - offset += b.AttesterSlashings[ii].SizeSSZ() + offset += o.SizeSSZ() } } - for ii := 0; ii < len(b.AttesterSlashings); ii++ { - if dst, err = b.AttesterSlashings[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.AttesterSlashings { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("AttesterSlashings: %w", err) } } - // Field (5) 'Attestations' - if size := len(b.Attestations); size > 128 { - err = ssz.ErrListTooBigFn("--.Attestations", size, 128) - return + // Field 5: Attestations + if len(c.Attestations) > 128 { + return nil, ssz.ErrListTooBig } { - offset = 4 * len(b.Attestations) - for ii := 0; ii < len(b.Attestations); ii++ { + offset = 4 * len(c.Attestations) + for _, o := range c.Attestations { dst = ssz.WriteOffset(dst, offset) - offset += b.Attestations[ii].SizeSSZ() + offset += o.SizeSSZ() } } - for ii := 0; ii < len(b.Attestations); ii++ { - if dst, err = b.Attestations[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.Attestations { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Attestations: %w", err) } } - // Field (6) 'Deposits' - if size := len(b.Deposits); size > 16 { - err = ssz.ErrListTooBigFn("--.Deposits", size, 16) - return + // Field 6: Deposits + if len(c.Deposits) > 16 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.Deposits); ii++ { - if dst, err = b.Deposits[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.Deposits { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Deposits: %w", err) } } - // Field (7) 'VoluntaryExits' - if size := len(b.VoluntaryExits); size > 16 { - err = ssz.ErrListTooBigFn("--.VoluntaryExits", size, 16) - return + // Field 7: VoluntaryExits + if len(c.VoluntaryExits) > 16 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.VoluntaryExits); ii++ { - if dst, err = b.VoluntaryExits[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.VoluntaryExits { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("VoluntaryExits: %w", err) } } - // Field (9) 'ExecutionPayload' - if dst, err = b.ExecutionPayload.MarshalSSZTo(dst); err != nil { - return + // Field 9: ExecutionPayload + if dst, err = c.ExecutionPayload.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ExecutionPayload: %w", err) } - // Field (10) 'BlsToExecutionChanges' - if size := len(b.BlsToExecutionChanges); size > 16 { - err = ssz.ErrListTooBigFn("--.BlsToExecutionChanges", size, 16) - return + // Field 10: BlsToExecutionChanges + if len(c.BlsToExecutionChanges) > 16 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.BlsToExecutionChanges); ii++ { - if dst, err = b.BlsToExecutionChanges[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.BlsToExecutionChanges { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("BlsToExecutionChanges: %w", err) } } - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the BeaconBlockBodyCapella object -func (b *BeaconBlockBodyCapella) UnmarshalSSZ(buf []byte) error { +func (c *BeaconBlockBodyCapella) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size < 388 { return ssz.ErrSize } - tail := buf - var o3, o4, o5, o6, o7, o9, o10 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]...) + sszSlice0 := buf[0:96] // c.RandaoReveal + sszSlice1 := buf[96:168] // c.Eth1Data + sszSlice2 := buf[168:200] // c.Graffiti + sszSlice8 := buf[220:380] // c.SyncAggregate - // Field (1) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(Eth1Data) - } - if err = b.Eth1Data.UnmarshalSSZ(buf[96:168]); err != nil { - return err + sszVarOffset3 := ssz.ReadOffset(buf[200:204]) // c.ProposerSlashings + if sszVarOffset3 != 388 { + return ssz.ErrInvalidVariableOffset } - - // Field (2) 'Graffiti' - if cap(b.Graffiti) == 0 { - b.Graffiti = make([]byte, 0, len(buf[168:200])) + if sszVarOffset3 > size { + return ssz.ErrOffset } - b.Graffiti = append(b.Graffiti, buf[168:200]...) - - // Offset (3) 'ProposerSlashings' - if o3 = ssz.ReadOffset(buf[200:204]); o3 > size { + sszVarOffset4 := ssz.ReadOffset(buf[204:208]) // c.AttesterSlashings + if sszVarOffset4 > size || sszVarOffset4 < sszVarOffset3 { return ssz.ErrOffset } - - if o3 != 388 { - return ssz.ErrInvalidVariableOffset + sszVarOffset5 := ssz.ReadOffset(buf[208:212]) // c.Attestations + if sszVarOffset5 > size || sszVarOffset5 < sszVarOffset4 { + return ssz.ErrOffset } - - // Offset (4) 'AttesterSlashings' - if o4 = ssz.ReadOffset(buf[204:208]); o4 > size || o3 > o4 { + sszVarOffset6 := ssz.ReadOffset(buf[212:216]) // c.Deposits + if sszVarOffset6 > size || sszVarOffset6 < sszVarOffset5 { return ssz.ErrOffset } - - // Offset (5) 'Attestations' - if o5 = ssz.ReadOffset(buf[208:212]); o5 > size || o4 > o5 { + sszVarOffset7 := ssz.ReadOffset(buf[216:220]) // c.VoluntaryExits + if sszVarOffset7 > size || sszVarOffset7 < sszVarOffset6 { return ssz.ErrOffset } - - // Offset (6) 'Deposits' - if o6 = ssz.ReadOffset(buf[212:216]); o6 > size || o5 > o6 { + sszVarOffset9 := ssz.ReadOffset(buf[380:384]) // c.ExecutionPayload + if sszVarOffset9 > size || sszVarOffset9 < sszVarOffset7 { return ssz.ErrOffset } - - // Offset (7) 'VoluntaryExits' - if o7 = ssz.ReadOffset(buf[216:220]); o7 > size || o6 > o7 { + sszVarOffset10 := ssz.ReadOffset(buf[384:388]) // c.BlsToExecutionChanges + if sszVarOffset10 > size || sszVarOffset10 < sszVarOffset9 { return ssz.ErrOffset } + sszSlice3 := buf[sszVarOffset3:sszVarOffset4] // c.ProposerSlashings + sszSlice4 := buf[sszVarOffset4:sszVarOffset5] // c.AttesterSlashings + sszSlice5 := buf[sszVarOffset5:sszVarOffset6] // c.Attestations + sszSlice6 := buf[sszVarOffset6:sszVarOffset7] // c.Deposits + sszSlice7 := buf[sszVarOffset7:sszVarOffset9] // c.VoluntaryExits + sszSlice9 := buf[sszVarOffset9:sszVarOffset10] // c.ExecutionPayload + sszSlice10 := buf[sszVarOffset10:] // c.BlsToExecutionChanges - // Field (8) 'SyncAggregate' - if b.SyncAggregate == nil { - b.SyncAggregate = new(SyncAggregate) - } - if err = b.SyncAggregate.UnmarshalSSZ(buf[220:380]); err != nil { - return err - } + // Field 0: RandaoReveal + c.RandaoReveal = make([]byte, 0, 96) + c.RandaoReveal = append(c.RandaoReveal, sszSlice0...) - // Offset (9) 'ExecutionPayload' - if o9 = ssz.ReadOffset(buf[380:384]); o9 > size || o7 > o9 { - return ssz.ErrOffset + // Field 1: Eth1Data + c.Eth1Data = new(Eth1Data) + if err = c.Eth1Data.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Eth1Data: %w", err) } - // Offset (10) 'BlsToExecutionChanges' - if o10 = ssz.ReadOffset(buf[384:388]); o10 > size || o9 > o10 { - return ssz.ErrOffset - } + // Field 2: Graffiti + c.Graffiti = make([]byte, 0, 32) + c.Graffiti = append(c.Graffiti, sszSlice2...) - // Field (3) 'ProposerSlashings' + // Field 3: ProposerSlashings { - buf = tail[o3:o4] - num, err := ssz.DivideInt2(len(buf), 416, 16) - if err != nil { - return err - } - b.ProposerSlashings = make([]*ProposerSlashing, num) - for ii := 0; ii < num; ii++ { - if b.ProposerSlashings[ii] == nil { - b.ProposerSlashings[ii] = new(ProposerSlashing) - } - if err = b.ProposerSlashings[ii].UnmarshalSSZ(buf[ii*416 : (ii+1)*416]); err != nil { - return err + if len(sszSlice3)%416 != 0 { + return fmt.Errorf("misaligned bytes: c.ProposerSlashings length is %d, which is not a multiple of 416: %w", len(sszSlice3), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice3) / 416 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.ProposerSlashings has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.ProposerSlashings = make([]*ProposerSlashing, numElem) + for i := 0; i < numElem; i++ { + var tmp *ProposerSlashing + tmp = new(ProposerSlashing) + tmpSlice := sszSlice3[i*416 : (1+i)*416] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("ProposerSlashings: %w", err) } + c.ProposerSlashings[i] = tmp } } - // Field (4) 'AttesterSlashings' + // Field 4: AttesterSlashings { - buf = tail[o4:o5] - num, err := ssz.DecodeDynamicLength(buf, 2) - 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) + // empty lists are zero length, so make sure there is room for an offset + // before attempting to unmarshal it + if len(sszSlice4) > 3 { + startOffset := ssz.ReadOffset(sszSlice4[0:4]) + if startOffset == 0 { + return fmt.Errorf("encountered invalid offset of 0 when decoding c.AttesterSlashings") } - if err = b.AttesterSlashings[indx].UnmarshalSSZ(buf); err != nil { - return err + if startOffset%4 != 0 { + return fmt.Errorf("misaligned list bytes: when decoding c.AttesterSlashings, end-of-list offset is %d, which is not a multiple of 4 (offset size)", startOffset) } - 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([]*Attestation, num) - err = ssz.UnmarshalDynamic(buf, num, func(indx int, buf []byte) (err error) { - if b.Attestations[indx] == nil { - b.Attestations[indx] = new(Attestation) + listLen := startOffset / 4 + if listLen > 2 { + return fmt.Errorf("ssz-max exceeded: c.AttesterSlashings has %d elements, ssz-max is 2: %w", listLen, ssz.ErrListTooBig) } - if err = b.Attestations[indx].UnmarshalSSZ(buf); err != nil { - return err + totalVarBytes := uint64(len(sszSlice4)) + if totalVarBytes < startOffset { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.AttesterSlashings") } - 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([]*Deposit, num) - for ii := 0; ii < num; ii++ { - if b.Deposits[ii] == nil { - b.Deposits[ii] = new(Deposit) + c.AttesterSlashings = make([]*AttesterSlashing, listLen) + var tmpSlice []byte + for i := uint64(0); i < listLen; i++ { + var tmp *AttesterSlashing + tmp = new(AttesterSlashing) + endOffset := totalVarBytes + if i+1 != listLen { + endOffset = ssz.ReadOffset(sszSlice4[(i+1)*4 : (i+2)*4]) + if totalVarBytes < endOffset { + return fmt.Errorf("offset %d points past the end of buffer when decoding c.AttesterSlashings", endOffset) + } + } + if endOffset < startOffset { + return fmt.Errorf("offset %d is not greater than start offset %d when decoding c.AttesterSlashings", endOffset, startOffset) + } + tmpSlice = sszSlice4[startOffset:endOffset] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("AttesterSlashings: %w", err) + } + c.AttesterSlashings[i] = tmp + startOffset = endOffset } - if err = b.Deposits[ii].UnmarshalSSZ(buf[ii*1240 : (ii+1)*1240]); err != nil { - return err + } else { + if len(sszSlice4) > 0 { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.AttesterSlashings") } + c.AttesterSlashings = make([]*AttesterSlashing, 0) } } - // Field (7) 'VoluntaryExits' + // Field 5: Attestations { - buf = tail[o7:o9] - num, err := ssz.DivideInt2(len(buf), 112, 16) - if err != nil { - return err - } - b.VoluntaryExits = make([]*SignedVoluntaryExit, num) - for ii := 0; ii < num; ii++ { - if b.VoluntaryExits[ii] == nil { - b.VoluntaryExits[ii] = new(SignedVoluntaryExit) + // empty lists are zero length, so make sure there is room for an offset + // before attempting to unmarshal it + if len(sszSlice5) > 3 { + startOffset := ssz.ReadOffset(sszSlice5[0:4]) + if startOffset == 0 { + return fmt.Errorf("encountered invalid offset of 0 when decoding c.Attestations") + } + if startOffset%4 != 0 { + return fmt.Errorf("misaligned list bytes: when decoding c.Attestations, end-of-list offset is %d, which is not a multiple of 4 (offset size)", startOffset) + } + listLen := startOffset / 4 + if listLen > 128 { + return fmt.Errorf("ssz-max exceeded: c.Attestations has %d elements, ssz-max is 128: %w", listLen, ssz.ErrListTooBig) + } + totalVarBytes := uint64(len(sszSlice5)) + if totalVarBytes < startOffset { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.Attestations") } - if err = b.VoluntaryExits[ii].UnmarshalSSZ(buf[ii*112 : (ii+1)*112]); err != nil { - return err + c.Attestations = make([]*Attestation, listLen) + var tmpSlice []byte + for i := uint64(0); i < listLen; i++ { + var tmp *Attestation + tmp = new(Attestation) + endOffset := totalVarBytes + if i+1 != listLen { + endOffset = ssz.ReadOffset(sszSlice5[(i+1)*4 : (i+2)*4]) + if totalVarBytes < endOffset { + return fmt.Errorf("offset %d points past the end of buffer when decoding c.Attestations", endOffset) + } + } + if endOffset < startOffset { + return fmt.Errorf("offset %d is not greater than start offset %d when decoding c.Attestations", endOffset, startOffset) + } + tmpSlice = sszSlice5[startOffset:endOffset] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Attestations: %w", err) + } + c.Attestations[i] = tmp + startOffset = endOffset } + } else { + if len(sszSlice5) > 0 { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.Attestations") + } + c.Attestations = make([]*Attestation, 0) } } - // Field (9) 'ExecutionPayload' + // Field 6: Deposits { - buf = tail[o9:o10] - if b.ExecutionPayload == nil { - b.ExecutionPayload = new(v1.ExecutionPayloadCapella) + if len(sszSlice6)%1240 != 0 { + return fmt.Errorf("misaligned bytes: c.Deposits length is %d, which is not a multiple of 1240: %w", len(sszSlice6), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice6) / 1240 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.Deposits has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) } - if err = b.ExecutionPayload.UnmarshalSSZ(buf); err != nil { - return err + c.Deposits = make([]*Deposit, numElem) + for i := 0; i < numElem; i++ { + var tmp *Deposit + tmp = new(Deposit) + tmpSlice := sszSlice6[i*1240 : (1+i)*1240] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Deposits: %w", err) + } + c.Deposits[i] = tmp } } - // Field (10) 'BlsToExecutionChanges' + // Field 7: VoluntaryExits { - buf = tail[o10:] - num, err := ssz.DivideInt2(len(buf), 172, 16) - if err != nil { - return err - } - b.BlsToExecutionChanges = make([]*SignedBLSToExecutionChange, num) - for ii := 0; ii < num; ii++ { - if b.BlsToExecutionChanges[ii] == nil { - b.BlsToExecutionChanges[ii] = new(SignedBLSToExecutionChange) - } - if err = b.BlsToExecutionChanges[ii].UnmarshalSSZ(buf[ii*172 : (ii+1)*172]); err != nil { - return err + if len(sszSlice7)%112 != 0 { + return fmt.Errorf("misaligned bytes: c.VoluntaryExits length is %d, which is not a multiple of 112: %w", len(sszSlice7), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice7) / 112 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.VoluntaryExits has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.VoluntaryExits = make([]*SignedVoluntaryExit, numElem) + for i := 0; i < numElem; i++ { + var tmp *SignedVoluntaryExit + tmp = new(SignedVoluntaryExit) + tmpSlice := sszSlice7[i*112 : (1+i)*112] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("VoluntaryExits: %w", err) } + c.VoluntaryExits[i] = tmp } } - return err -} -// SizeSSZ returns the ssz encoded size in bytes for the BeaconBlockBodyCapella object -func (b *BeaconBlockBodyCapella) SizeSSZ() (size int) { - size = 388 - - // 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 8: SyncAggregate + c.SyncAggregate = new(SyncAggregate) + if err = c.SyncAggregate.UnmarshalSSZ(sszSlice8); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) } - // Field (5) 'Attestations' - for ii := 0; ii < len(b.Attestations); ii++ { - size += 4 - size += b.Attestations[ii].SizeSSZ() + // Field 9: ExecutionPayload + c.ExecutionPayload = new(v1.ExecutionPayloadCapella) + if err = c.ExecutionPayload.UnmarshalSSZ(sszSlice9); err != nil { + return fmt.Errorf("ExecutionPayload: %w", err) } - // 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(v1.ExecutionPayloadCapella) + // Field 10: BlsToExecutionChanges + { + if len(sszSlice10)%172 != 0 { + return fmt.Errorf("misaligned bytes: c.BlsToExecutionChanges length is %d, which is not a multiple of 172: %w", len(sszSlice10), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice10) / 172 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.BlsToExecutionChanges has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.BlsToExecutionChanges = make([]*SignedBLSToExecutionChange, numElem) + for i := 0; i < numElem; i++ { + var tmp *SignedBLSToExecutionChange + tmp = new(SignedBLSToExecutionChange) + tmpSlice := sszSlice10[i*172 : (1+i)*172] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("BlsToExecutionChanges: %w", err) + } + c.BlsToExecutionChanges[i] = tmp + } } - size += b.ExecutionPayload.SizeSSZ() - - // Field (10) 'BlsToExecutionChanges' - size += len(b.BlsToExecutionChanges) * 172 - - return + return err } -// HashTreeRoot ssz hashes the BeaconBlockBodyCapella object -func (b *BeaconBlockBodyCapella) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) +func (c *BeaconBlockBodyCapella) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the BeaconBlockBodyCapella object with a hasher -func (b *BeaconBlockBodyCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *BeaconBlockBodyCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'RandaoReveal' - if size := len(b.RandaoReveal); size != 96 { - err = ssz.ErrBytesLengthFn("--.RandaoReveal", size, 96) - return + // Field 0: RandaoReveal + if len(c.RandaoReveal) != 96 { + return ssz.ErrBytesLength } - hh.PutBytes(b.RandaoReveal) - - // Field (1) 'Eth1Data' - if err = b.Eth1Data.HashTreeRootWith(hh); err != nil { - return + hh.PutBytes(c.RandaoReveal) + // Field 1: Eth1Data + if err := c.Eth1Data.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Eth1Data: %w", err) } - - // Field (2) 'Graffiti' - if size := len(b.Graffiti); size != 32 { - err = ssz.ErrBytesLengthFn("--.Graffiti", size, 32) - return + // Field 2: Graffiti + if len(c.Graffiti) != 32 { + return ssz.ErrBytesLength } - hh.PutBytes(b.Graffiti) - - // Field (3) 'ProposerSlashings' + hh.PutBytes(c.Graffiti) + // Field 3: ProposerSlashings { + if len(c.ProposerSlashings) > 16 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.ProposerSlashings { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ProposerSlashings: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.ProposerSlashings)), 16) } - - // Field (4) 'AttesterSlashings' + // Field 4: AttesterSlashings { + if len(c.AttesterSlashings) > 2 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.AttesterSlashings { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("AttesterSlashings: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 2) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.AttesterSlashings)), 2) } - - // Field (5) 'Attestations' + // Field 5: Attestations { + if len(c.Attestations) > 128 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.Attestations { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Attestations: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 128) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Attestations)), 128) } - - // Field (6) 'Deposits' + // Field 6: Deposits { + if len(c.Deposits) > 16 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.Deposits { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Deposits: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Deposits)), 16) } - - // Field (7) 'VoluntaryExits' + // Field 7: VoluntaryExits { + if len(c.VoluntaryExits) > 16 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.VoluntaryExits { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("VoluntaryExits: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.VoluntaryExits)), 16) } - - // Field (8) 'SyncAggregate' - if err = b.SyncAggregate.HashTreeRootWith(hh); err != nil { - return + // Field 8: SyncAggregate + if err := c.SyncAggregate.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) } - - // Field (9) 'ExecutionPayload' - if err = b.ExecutionPayload.HashTreeRootWith(hh); err != nil { - return + // Field 9: ExecutionPayload + if err := c.ExecutionPayload.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ExecutionPayload: %w", err) } - - // Field (10) 'BlsToExecutionChanges' + // Field 10: BlsToExecutionChanges { + if len(c.BlsToExecutionChanges) > 16 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.BlsToExecutionChanges { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("BlsToExecutionChanges: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.BlsToExecutionChanges)), 16) } - hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the SignedBlindedBeaconBlockCapella object -func (s *SignedBlindedBeaconBlockCapella) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) +func (c *BeaconBlockCapella) SizeSSZ() int { + size := 84 + if c.Body == nil { + c.Body = new(BeaconBlockBodyCapella) + } + size += c.Body.SizeSSZ() + return size } -// MarshalSSZTo ssz marshals the SignedBlindedBeaconBlockCapella object to a target array -func (s *SignedBlindedBeaconBlockCapella) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(100) +func (c *BeaconBlockCapella) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Offset (0) 'Block' - dst = ssz.WriteOffset(dst, offset) - if s.Block == nil { - s.Block = new(BlindedBeaconBlockCapella) +func (c *BeaconBlockCapella) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 84 + + // Field 0: Slot + if dst, err = c.Slot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Slot: %w", err) + } + + // Field 1: ProposerIndex + if dst, err = c.ProposerIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ProposerIndex: %w", err) } - offset += s.Block.SizeSSZ() - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 2: ParentRoot + if len(c.ParentRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, s.Signature...) + dst = append(dst, c.ParentRoot...) - // Field (0) 'Block' - if dst, err = s.Block.MarshalSSZTo(dst); err != nil { - return + // Field 3: StateRoot + if len(c.StateRoot) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.StateRoot...) - return + // Field 4: Body + if c.Body == nil { + c.Body = new(BeaconBlockBodyCapella) + } + dst = ssz.WriteOffset(dst, offset) + offset += c.Body.SizeSSZ() + + // Field 4: Body + if dst, err = c.Body.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Body: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the SignedBlindedBeaconBlockCapella object -func (s *SignedBlindedBeaconBlockCapella) UnmarshalSSZ(buf []byte) error { +func (c *BeaconBlockCapella) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 100 { + if size < 84 { return ssz.ErrSize } - tail := buf - var o0 uint64 + sszSlice0 := buf[0:8] // c.Slot + sszSlice1 := buf[8:16] // c.ProposerIndex + sszSlice2 := buf[16:48] // c.ParentRoot + sszSlice3 := buf[48:80] // c.StateRoot - // Offset (0) 'Block' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { + sszVarOffset4 := ssz.ReadOffset(buf[80:84]) // c.Body + if sszVarOffset4 != 84 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset4 > size { return ssz.ErrOffset } + sszSlice4 := buf[sszVarOffset4:] // c.Body - if o0 != 100 { - return ssz.ErrInvalidVariableOffset + // Field 0: Slot + if err = c.Slot.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Slot: %w", err) } - // Field (1) 'Signature' - if cap(s.Signature) == 0 { - s.Signature = make([]byte, 0, len(buf[4:100])) + // Field 1: ProposerIndex + if err = c.ProposerIndex.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("ProposerIndex: %w", err) } - s.Signature = append(s.Signature, buf[4:100]...) - // Field (0) 'Block' - { - buf = tail[o0:] - if s.Block == nil { - s.Block = new(BlindedBeaconBlockCapella) - } - if err = s.Block.UnmarshalSSZ(buf); err != nil { - return err - } - } - return err -} + // Field 2: ParentRoot + c.ParentRoot = make([]byte, 0, 32) + c.ParentRoot = append(c.ParentRoot, sszSlice2...) -// SizeSSZ returns the ssz encoded size in bytes for the SignedBlindedBeaconBlockCapella object -func (s *SignedBlindedBeaconBlockCapella) SizeSSZ() (size int) { - size = 100 + // Field 3: StateRoot + c.StateRoot = make([]byte, 0, 32) + c.StateRoot = append(c.StateRoot, sszSlice3...) - // Field (0) 'Block' - if s.Block == nil { - s.Block = new(BlindedBeaconBlockCapella) + // Field 4: Body + c.Body = new(BeaconBlockBodyCapella) + if err = c.Body.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("Body: %w", err) } - size += s.Block.SizeSSZ() - - return + return err } -// HashTreeRoot ssz hashes the SignedBlindedBeaconBlockCapella object -func (s *SignedBlindedBeaconBlockCapella) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) +func (c *BeaconBlockCapella) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the SignedBlindedBeaconBlockCapella object with a hasher -func (s *SignedBlindedBeaconBlockCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *BeaconBlockCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Block' - if err = s.Block.HashTreeRootWith(hh); err != nil { - return + // Field 0: Slot + if err := c.Slot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Slot: %w", err) } - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 1: ProposerIndex + if err := c.ProposerIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ProposerIndex: %w", err) + } + // Field 2: ParentRoot + if len(c.ParentRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ParentRoot) + // Field 3: StateRoot + if len(c.StateRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.StateRoot) + // Field 4: Body + if err := c.Body.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Body: %w", err) } - hh.PutBytes(s.Signature) - hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the BlindedBeaconBlockCapella object -func (b *BlindedBeaconBlockCapella) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) +func (c *BeaconStateCapella) SizeSSZ() int { + size := 2736653 + size += len(c.HistoricalRoots) * 32 + size += len(c.Eth1DataVotes) * 72 + size += len(c.Validators) * 121 + size += len(c.Balances) * 8 + size += len(c.PreviousEpochParticipation) + size += len(c.CurrentEpochParticipation) + size += len(c.InactivityScores) * 8 + if c.LatestExecutionPayloadHeader == nil { + c.LatestExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderCapella) + } + size += c.LatestExecutionPayloadHeader.SizeSSZ() + size += len(c.HistoricalSummaries) * 64 + return size } -// MarshalSSZTo ssz marshals the BlindedBeaconBlockCapella object to a target array -func (b *BlindedBeaconBlockCapella) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(84) +func (c *BeaconStateCapella) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (0) 'Slot' - dst = ssz.MarshalUint(dst, b.Slot) +func (c *BeaconStateCapella) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 2736653 - // Field (1) 'ProposerIndex' - dst = ssz.MarshalUint(dst, b.ProposerIndex) + // Field 0: GenesisTime + dst = binary.LittleEndian.AppendUint64(dst, c.GenesisTime) - // Field (2) 'ParentRoot' - if size := len(b.ParentRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentRoot", size, 32) - return + // Field 1: GenesisValidatorsRoot + if len(c.GenesisValidatorsRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.ParentRoot...) + dst = append(dst, c.GenesisValidatorsRoot...) - // Field (3) 'StateRoot' - if size := len(b.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return + // Field 2: Slot + if dst, err = c.Slot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Slot: %w", err) } - dst = append(dst, b.StateRoot...) - // Offset (4) 'Body' - dst = ssz.WriteOffset(dst, offset) - if b.Body == nil { - b.Body = new(BlindedBeaconBlockBodyCapella) + // Field 3: Fork + if c.Fork == nil { + c.Fork = new(Fork) } - offset += b.Body.SizeSSZ() - - // Field (4) 'Body' - if dst, err = b.Body.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.Fork.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Fork: %w", err) } - return -} - -// UnmarshalSSZ ssz unmarshals the BlindedBeaconBlockCapella object -func (b *BlindedBeaconBlockCapella) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 84 { - return ssz.ErrSize + // Field 4: LatestBlockHeader + if c.LatestBlockHeader == nil { + c.LatestBlockHeader = new(BeaconBlockHeader) } - - tail := buf - var o4 uint64 - - // Field (0) 'Slot' - b.Slot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[0:8]) - - // Field (1) 'ProposerIndex' - b.ProposerIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[8:16]) - - // Field (2) 'ParentRoot' - if cap(b.ParentRoot) == 0 { - b.ParentRoot = make([]byte, 0, len(buf[16:48])) + if dst, err = c.LatestBlockHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("LatestBlockHeader: %w", err) } - 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])) + // Field 5: BlockRoots + if len(c.BlockRoots) != 8192 { + return nil, ssz.ErrBytesLength } - b.StateRoot = append(b.StateRoot, buf[48:80]...) - - // Offset (4) 'Body' - if o4 = ssz.ReadOffset(buf[80:84]); o4 > size { - return ssz.ErrOffset + for _, o := range c.BlockRoots { + if len(o) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) } - if o4 != 84 { - return ssz.ErrInvalidVariableOffset + // Field 6: StateRoots + if len(c.StateRoots) != 8192 { + return nil, ssz.ErrBytesLength } - - // Field (4) 'Body' - { - buf = tail[o4:] - if b.Body == nil { - b.Body = new(BlindedBeaconBlockBodyCapella) - } - if err = b.Body.UnmarshalSSZ(buf); err != nil { - return err + for _, o := range c.StateRoots { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, o...) } - return err -} -// SizeSSZ returns the ssz encoded size in bytes for the BlindedBeaconBlockCapella object -func (b *BlindedBeaconBlockCapella) SizeSSZ() (size int) { - size = 84 + // Field 7: HistoricalRoots + dst = ssz.WriteOffset(dst, offset) + offset += len(c.HistoricalRoots) * 32 - // Field (4) 'Body' - if b.Body == nil { - b.Body = new(BlindedBeaconBlockBodyCapella) + // Field 8: Eth1Data + if c.Eth1Data == nil { + c.Eth1Data = new(Eth1Data) + } + if dst, err = c.Eth1Data.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Eth1Data: %w", err) } - size += b.Body.SizeSSZ() - - return -} -// HashTreeRoot ssz hashes the BlindedBeaconBlockCapella object -func (b *BlindedBeaconBlockCapella) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) -} + // Field 9: Eth1DataVotes + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Eth1DataVotes) * 72 -// HashTreeRootWith ssz hashes the BlindedBeaconBlockCapella object with a hasher -func (b *BlindedBeaconBlockCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() + // Field 10: Eth1DepositIndex + dst = binary.LittleEndian.AppendUint64(dst, c.Eth1DepositIndex) - // Field (0) 'Slot' - ssz.PutUint(hh, b.Slot) + // Field 11: Validators + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Validators) * 121 - // Field (1) 'ProposerIndex' - ssz.PutUint(hh, b.ProposerIndex) + // Field 12: Balances + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Balances) * 8 - // Field (2) 'ParentRoot' - if size := len(b.ParentRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentRoot", size, 32) - return + // Field 13: RandaoMixes + if len(c.RandaoMixes) != 65536 { + return nil, ssz.ErrBytesLength } - hh.PutBytes(b.ParentRoot) - - // Field (3) 'StateRoot' - if size := len(b.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return + for _, o := range c.RandaoMixes { + if len(o) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) } - hh.PutBytes(b.StateRoot) - // Field (4) 'Body' - if err = b.Body.HashTreeRootWith(hh); err != nil { - return + // Field 14: Slashings + if len(c.Slashings) != 8192 { + return nil, ssz.ErrBytesLength + } + for _, o := range c.Slashings { + dst = binary.LittleEndian.AppendUint64(dst, o) } - hh.Merkleize(indx) - return -} + // Field 15: PreviousEpochParticipation + dst = ssz.WriteOffset(dst, offset) + offset += len(c.PreviousEpochParticipation) -// MarshalSSZ ssz marshals the BlindedBeaconBlockBodyCapella object -func (b *BlindedBeaconBlockBodyCapella) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} - -// MarshalSSZTo ssz marshals the BlindedBeaconBlockBodyCapella object to a target array -func (b *BlindedBeaconBlockBodyCapella) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(388) + // Field 16: CurrentEpochParticipation + dst = ssz.WriteOffset(dst, offset) + offset += len(c.CurrentEpochParticipation) - // Field (0) 'RandaoReveal' - if size := len(b.RandaoReveal); size != 96 { - err = ssz.ErrBytesLengthFn("--.RandaoReveal", size, 96) - return + // Field 17: JustificationBits + if len([]byte(c.JustificationBits)) != 1 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.RandaoReveal...) + dst = append(dst, []byte(c.JustificationBits)...) - // Field (1) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(Eth1Data) + // Field 18: PreviousJustifiedCheckpoint + if c.PreviousJustifiedCheckpoint == nil { + c.PreviousJustifiedCheckpoint = new(Checkpoint) } - if dst, err = b.Eth1Data.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.PreviousJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("PreviousJustifiedCheckpoint: %w", err) } - // Field (2) 'Graffiti' - if size := len(b.Graffiti); size != 32 { - err = ssz.ErrBytesLengthFn("--.Graffiti", size, 32) - return + // Field 19: CurrentJustifiedCheckpoint + if c.CurrentJustifiedCheckpoint == nil { + c.CurrentJustifiedCheckpoint = new(Checkpoint) } - 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() + if dst, err = c.CurrentJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("CurrentJustifiedCheckpoint: %w", err) } - // Offset (5) 'Attestations' - dst = ssz.WriteOffset(dst, offset) - for ii := 0; ii < len(b.Attestations); ii++ { - offset += 4 - offset += b.Attestations[ii].SizeSSZ() + // Field 20: FinalizedCheckpoint + if c.FinalizedCheckpoint == nil { + c.FinalizedCheckpoint = new(Checkpoint) + } + if dst, err = c.FinalizedCheckpoint.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("FinalizedCheckpoint: %w", err) } - // Offset (6) 'Deposits' + // Field 21: InactivityScores dst = ssz.WriteOffset(dst, offset) - offset += len(b.Deposits) * 1240 + offset += len(c.InactivityScores) * 8 - // Offset (7) 'VoluntaryExits' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.VoluntaryExits) * 112 + // Field 22: CurrentSyncCommittee + if c.CurrentSyncCommittee == nil { + c.CurrentSyncCommittee = new(SyncCommittee) + } + if dst, err = c.CurrentSyncCommittee.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("CurrentSyncCommittee: %w", err) + } - // Field (8) 'SyncAggregate' - if b.SyncAggregate == nil { - b.SyncAggregate = new(SyncAggregate) + // Field 23: NextSyncCommittee + if c.NextSyncCommittee == nil { + c.NextSyncCommittee = new(SyncCommittee) } - if dst, err = b.SyncAggregate.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.NextSyncCommittee.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("NextSyncCommittee: %w", err) } - // Offset (9) 'ExecutionPayloadHeader' + // Field 24: LatestExecutionPayloadHeader + if c.LatestExecutionPayloadHeader == nil { + c.LatestExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderCapella) + } dst = ssz.WriteOffset(dst, offset) - if b.ExecutionPayloadHeader == nil { - b.ExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderCapella) + offset += c.LatestExecutionPayloadHeader.SizeSSZ() + + // Field 25: NextWithdrawalIndex + dst = binary.LittleEndian.AppendUint64(dst, c.NextWithdrawalIndex) + + // Field 26: NextWithdrawalValidatorIndex + if dst, err = c.NextWithdrawalValidatorIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("NextWithdrawalValidatorIndex: %w", err) } - offset += b.ExecutionPayloadHeader.SizeSSZ() - // Offset (10) 'BlsToExecutionChanges' + // Field 27: HistoricalSummaries dst = ssz.WriteOffset(dst, offset) - offset += len(b.BlsToExecutionChanges) * 172 + offset += len(c.HistoricalSummaries) * 64 - // Field (3) 'ProposerSlashings' - if size := len(b.ProposerSlashings); size > 16 { - err = ssz.ErrListTooBigFn("--.ProposerSlashings", size, 16) - return + // Field 7: HistoricalRoots + if len(c.HistoricalRoots) > 16777216 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.ProposerSlashings); ii++ { - if dst, err = b.ProposerSlashings[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.HistoricalRoots { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, o...) } - // Field (4) 'AttesterSlashings' - if size := len(b.AttesterSlashings); size > 2 { - err = ssz.ErrListTooBigFn("--.AttesterSlashings", size, 2) - return + // Field 9: Eth1DataVotes + if len(c.Eth1DataVotes) > 2048 { + return nil, ssz.ErrListTooBig } - { - 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 + for _, o := range c.Eth1DataVotes { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Eth1DataVotes: %w", err) } } - // Field (5) 'Attestations' - if size := len(b.Attestations); size > 128 { - err = ssz.ErrListTooBigFn("--.Attestations", size, 128) - return + // Field 11: Validators + if len(c.Validators) > 1099511627776 { + return nil, ssz.ErrListTooBig } - { - offset = 4 * len(b.Attestations) - for ii := 0; ii < len(b.Attestations); ii++ { - dst = ssz.WriteOffset(dst, offset) - offset += b.Attestations[ii].SizeSSZ() + for _, o := range c.Validators { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Validators: %w", err) } } - for ii := 0; ii < len(b.Attestations); ii++ { - if dst, err = b.Attestations[ii].MarshalSSZTo(dst); err != nil { - return - } + + // Field 12: Balances + if len(c.Balances) > 1099511627776 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.Balances { + dst = binary.LittleEndian.AppendUint64(dst, o) } - // Field (6) 'Deposits' - if size := len(b.Deposits); size > 16 { - err = ssz.ErrListTooBigFn("--.Deposits", size, 16) - return + // Field 15: PreviousEpochParticipation + if len(c.PreviousEpochParticipation) > 1099511627776 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.Deposits); ii++ { - if dst, err = b.Deposits[ii].MarshalSSZTo(dst); err != nil { - return - } + dst = append(dst, c.PreviousEpochParticipation...) + + // Field 16: CurrentEpochParticipation + if len(c.CurrentEpochParticipation) > 1099511627776 { + return nil, ssz.ErrListTooBig } + dst = append(dst, c.CurrentEpochParticipation...) - // Field (7) 'VoluntaryExits' - if size := len(b.VoluntaryExits); size > 16 { - err = ssz.ErrListTooBigFn("--.VoluntaryExits", size, 16) - return + // Field 21: InactivityScores + if len(c.InactivityScores) > 1099511627776 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.VoluntaryExits); ii++ { - if dst, err = b.VoluntaryExits[ii].MarshalSSZTo(dst); err != nil { - return - } + for _, o := range c.InactivityScores { + dst = binary.LittleEndian.AppendUint64(dst, o) } - // Field (9) 'ExecutionPayloadHeader' - if dst, err = b.ExecutionPayloadHeader.MarshalSSZTo(dst); err != nil { - return + // Field 24: LatestExecutionPayloadHeader + if dst, err = c.LatestExecutionPayloadHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("LatestExecutionPayloadHeader: %w", err) } - // Field (10) 'BlsToExecutionChanges' - if size := len(b.BlsToExecutionChanges); size > 16 { - err = ssz.ErrListTooBigFn("--.BlsToExecutionChanges", size, 16) - return + // Field 27: HistoricalSummaries + if len(c.HistoricalSummaries) > 16777216 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.BlsToExecutionChanges); ii++ { - if dst, err = b.BlsToExecutionChanges[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.HistoricalSummaries { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("HistoricalSummaries: %w", err) } } - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the BlindedBeaconBlockBodyCapella object -func (b *BlindedBeaconBlockBodyCapella) UnmarshalSSZ(buf []byte) error { +func (c *BeaconStateCapella) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 388 { + if size < 2736653 { return ssz.ErrSize } - tail := buf - var o3, o4, o5, o6, o7, o9, o10 uint64 - - // Field (0) 'RandaoReveal' - if cap(b.RandaoReveal) == 0 { - b.RandaoReveal = make([]byte, 0, len(buf[0:96])) + sszSlice0 := buf[0:8] // c.GenesisTime + sszSlice1 := buf[8:40] // c.GenesisValidatorsRoot + sszSlice2 := buf[40:48] // c.Slot + sszSlice3 := buf[48:64] // c.Fork + sszSlice4 := buf[64:176] // c.LatestBlockHeader + sszSlice5 := buf[176:262320] // c.BlockRoots + sszSlice6 := buf[262320:524464] // c.StateRoots + sszSlice8 := buf[524468:524540] // c.Eth1Data + sszSlice10 := buf[524544:524552] // c.Eth1DepositIndex + sszSlice13 := buf[524560:2621712] // c.RandaoMixes + sszSlice14 := buf[2621712:2687248] // c.Slashings + sszSlice17 := buf[2687256:2687257] // c.JustificationBits + sszSlice18 := buf[2687257:2687297] // c.PreviousJustifiedCheckpoint + sszSlice19 := buf[2687297:2687337] // c.CurrentJustifiedCheckpoint + sszSlice20 := buf[2687337:2687377] // c.FinalizedCheckpoint + sszSlice22 := buf[2687381:2712005] // c.CurrentSyncCommittee + sszSlice23 := buf[2712005:2736629] // c.NextSyncCommittee + sszSlice25 := buf[2736633:2736641] // c.NextWithdrawalIndex + sszSlice26 := buf[2736641:2736649] // c.NextWithdrawalValidatorIndex + + sszVarOffset7 := ssz.ReadOffset(buf[524464:524468]) // c.HistoricalRoots + if sszVarOffset7 != 2736653 { + return ssz.ErrInvalidVariableOffset } - b.RandaoReveal = append(b.RandaoReveal, buf[0:96]...) - - // Field (1) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(Eth1Data) + if sszVarOffset7 > size { + return ssz.ErrOffset } - if err = b.Eth1Data.UnmarshalSSZ(buf[96:168]); err != nil { - return err + sszVarOffset9 := ssz.ReadOffset(buf[524540:524544]) // c.Eth1DataVotes + if sszVarOffset9 > size || sszVarOffset9 < sszVarOffset7 { + return ssz.ErrOffset } - - // Field (2) 'Graffiti' - if cap(b.Graffiti) == 0 { - b.Graffiti = make([]byte, 0, len(buf[168:200])) + sszVarOffset11 := ssz.ReadOffset(buf[524552:524556]) // c.Validators + if sszVarOffset11 > size || sszVarOffset11 < sszVarOffset9 { + return ssz.ErrOffset } - b.Graffiti = append(b.Graffiti, buf[168:200]...) - - // Offset (3) 'ProposerSlashings' - if o3 = ssz.ReadOffset(buf[200:204]); o3 > size { + sszVarOffset12 := ssz.ReadOffset(buf[524556:524560]) // c.Balances + if sszVarOffset12 > size || sszVarOffset12 < sszVarOffset11 { return ssz.ErrOffset } - - if o3 != 388 { - return ssz.ErrInvalidVariableOffset + sszVarOffset15 := ssz.ReadOffset(buf[2687248:2687252]) // c.PreviousEpochParticipation + if sszVarOffset15 > size || sszVarOffset15 < sszVarOffset12 { + return ssz.ErrOffset } - - // Offset (4) 'AttesterSlashings' - if o4 = ssz.ReadOffset(buf[204:208]); o4 > size || o3 > o4 { + sszVarOffset16 := ssz.ReadOffset(buf[2687252:2687256]) // c.CurrentEpochParticipation + if sszVarOffset16 > size || sszVarOffset16 < sszVarOffset15 { return ssz.ErrOffset } - - // Offset (5) 'Attestations' - if o5 = ssz.ReadOffset(buf[208:212]); o5 > size || o4 > o5 { + sszVarOffset21 := ssz.ReadOffset(buf[2687377:2687381]) // c.InactivityScores + if sszVarOffset21 > size || sszVarOffset21 < sszVarOffset16 { return ssz.ErrOffset } - - // Offset (6) 'Deposits' - if o6 = ssz.ReadOffset(buf[212:216]); o6 > size || o5 > o6 { + sszVarOffset24 := ssz.ReadOffset(buf[2736629:2736633]) // c.LatestExecutionPayloadHeader + if sszVarOffset24 > size || sszVarOffset24 < sszVarOffset21 { return ssz.ErrOffset } - - // Offset (7) 'VoluntaryExits' - if o7 = ssz.ReadOffset(buf[216:220]); o7 > size || o6 > o7 { + sszVarOffset27 := ssz.ReadOffset(buf[2736649:2736653]) // c.HistoricalSummaries + if sszVarOffset27 > size || sszVarOffset27 < sszVarOffset24 { return ssz.ErrOffset } + sszSlice7 := buf[sszVarOffset7:sszVarOffset9] // c.HistoricalRoots + sszSlice9 := buf[sszVarOffset9:sszVarOffset11] // c.Eth1DataVotes + sszSlice11 := buf[sszVarOffset11:sszVarOffset12] // c.Validators + sszSlice12 := buf[sszVarOffset12:sszVarOffset15] // c.Balances + sszSlice15 := buf[sszVarOffset15:sszVarOffset16] // c.PreviousEpochParticipation + sszSlice16 := buf[sszVarOffset16:sszVarOffset21] // c.CurrentEpochParticipation + sszSlice21 := buf[sszVarOffset21:sszVarOffset24] // c.InactivityScores + sszSlice24 := buf[sszVarOffset24:sszVarOffset27] // c.LatestExecutionPayloadHeader + sszSlice27 := buf[sszVarOffset27:] // c.HistoricalSummaries - // Field (8) 'SyncAggregate' - if b.SyncAggregate == nil { - b.SyncAggregate = new(SyncAggregate) - } - if err = b.SyncAggregate.UnmarshalSSZ(buf[220:380]); err != nil { - return err + // Field 0: GenesisTime + c.GenesisTime = binary.LittleEndian.Uint64(sszSlice0) + + // Field 1: GenesisValidatorsRoot + c.GenesisValidatorsRoot = make([]byte, 0, 32) + c.GenesisValidatorsRoot = append(c.GenesisValidatorsRoot, sszSlice1...) + + // Field 2: Slot + if err = c.Slot.UnmarshalSSZ(sszSlice2); err != nil { + return fmt.Errorf("Slot: %w", err) } - // Offset (9) 'ExecutionPayloadHeader' - if o9 = ssz.ReadOffset(buf[380:384]); o9 > size || o7 > o9 { - return ssz.ErrOffset + // Field 3: Fork + c.Fork = new(Fork) + if err = c.Fork.UnmarshalSSZ(sszSlice3); err != nil { + return fmt.Errorf("Fork: %w", err) } - // Offset (10) 'BlsToExecutionChanges' - if o10 = ssz.ReadOffset(buf[384:388]); o10 > size || o9 > o10 { - return ssz.ErrOffset + // Field 4: LatestBlockHeader + c.LatestBlockHeader = new(BeaconBlockHeader) + if err = c.LatestBlockHeader.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("LatestBlockHeader: %w", err) } - // Field (3) 'ProposerSlashings' + // Field 5: BlockRoots { - buf = tail[o3:o4] - num, err := ssz.DivideInt2(len(buf), 416, 16) - if err != nil { - return err - } - b.ProposerSlashings = make([]*ProposerSlashing, num) - for ii := 0; ii < num; ii++ { - if b.ProposerSlashings[ii] == nil { - b.ProposerSlashings[ii] = new(ProposerSlashing) - } - if err = b.ProposerSlashings[ii].UnmarshalSSZ(buf[ii*416 : (ii+1)*416]); err != nil { - return err - } + c.BlockRoots = make([][]byte, 8192) + for i := 0; i < 8192; i++ { + var tmp []byte + + tmpSlice := sszSlice5[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.BlockRoots[i] = tmp } } - // Field (4) 'AttesterSlashings' + // Field 6: StateRoots { - buf = tail[o4:o5] - num, err := ssz.DecodeDynamicLength(buf, 2) - 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 + c.StateRoots = make([][]byte, 8192) + for i := 0; i < 8192; i++ { + var tmp []byte + + tmpSlice := sszSlice6[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.StateRoots[i] = tmp } } - // Field (5) 'Attestations' + // Field 7: HistoricalRoots { - buf = tail[o5:o6] - num, err := ssz.DecodeDynamicLength(buf, 128) - 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 + if len(sszSlice7)%32 != 0 { + return fmt.Errorf("misaligned bytes: c.HistoricalRoots length is %d, which is not a multiple of 32: %w", len(sszSlice7), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice7) / 32 + if numElem > 16777216 { + return fmt.Errorf("ssz-max exceeded: c.HistoricalRoots has %d elements, ssz-max is 16777216: %w", numElem, ssz.ErrListTooBig) } + c.HistoricalRoots = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte + + tmpSlice := sszSlice7[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.HistoricalRoots[i] = tmp + } + } + + // Field 8: Eth1Data + c.Eth1Data = new(Eth1Data) + if err = c.Eth1Data.UnmarshalSSZ(sszSlice8); err != nil { + return fmt.Errorf("Eth1Data: %w", err) } - // Field (6) 'Deposits' + // Field 9: Eth1DataVotes { - buf = tail[o6:o7] - num, err := ssz.DivideInt2(len(buf), 1240, 16) - if err != nil { - return err - } - b.Deposits = make([]*Deposit, num) - for ii := 0; ii < num; ii++ { - if b.Deposits[ii] == nil { - b.Deposits[ii] = new(Deposit) - } - if err = b.Deposits[ii].UnmarshalSSZ(buf[ii*1240 : (ii+1)*1240]); err != nil { - return err + if len(sszSlice9)%72 != 0 { + return fmt.Errorf("misaligned bytes: c.Eth1DataVotes length is %d, which is not a multiple of 72: %w", len(sszSlice9), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice9) / 72 + if numElem > 2048 { + return fmt.Errorf("ssz-max exceeded: c.Eth1DataVotes has %d elements, ssz-max is 2048: %w", numElem, ssz.ErrListTooBig) + } + c.Eth1DataVotes = make([]*Eth1Data, numElem) + for i := 0; i < numElem; i++ { + var tmp *Eth1Data + tmp = new(Eth1Data) + tmpSlice := sszSlice9[i*72 : (1+i)*72] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Eth1DataVotes: %w", err) } + c.Eth1DataVotes[i] = tmp } } - // Field (7) 'VoluntaryExits' + // Field 10: Eth1DepositIndex + c.Eth1DepositIndex = binary.LittleEndian.Uint64(sszSlice10) + + // Field 11: Validators { - buf = tail[o7:o9] - num, err := ssz.DivideInt2(len(buf), 112, 16) - if err != nil { - return err - } - b.VoluntaryExits = make([]*SignedVoluntaryExit, num) - for ii := 0; ii < num; ii++ { - if b.VoluntaryExits[ii] == nil { - b.VoluntaryExits[ii] = new(SignedVoluntaryExit) - } - if err = b.VoluntaryExits[ii].UnmarshalSSZ(buf[ii*112 : (ii+1)*112]); err != nil { - return err + if len(sszSlice11)%121 != 0 { + return fmt.Errorf("misaligned bytes: c.Validators length is %d, which is not a multiple of 121: %w", len(sszSlice11), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice11) / 121 + if numElem > 1099511627776 { + return fmt.Errorf("ssz-max exceeded: c.Validators has %d elements, ssz-max is 1099511627776: %w", numElem, ssz.ErrListTooBig) + } + c.Validators = make([]*Validator, numElem) + for i := 0; i < numElem; i++ { + var tmp *Validator + tmp = new(Validator) + tmpSlice := sszSlice11[i*121 : (1+i)*121] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Validators: %w", err) } + c.Validators[i] = tmp } } - // Field (9) 'ExecutionPayloadHeader' + // Field 12: Balances { - buf = tail[o9:o10] - if b.ExecutionPayloadHeader == nil { - b.ExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderCapella) + if len(sszSlice12)%8 != 0 { + return fmt.Errorf("misaligned bytes: c.Balances length is %d, which is not a multiple of 8: %w", len(sszSlice12), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice12) / 8 + if numElem > 1099511627776 { + return fmt.Errorf("ssz-max exceeded: c.Balances has %d elements, ssz-max is 1099511627776: %w", numElem, ssz.ErrListTooBig) } - if err = b.ExecutionPayloadHeader.UnmarshalSSZ(buf); err != nil { - return err + c.Balances = make([]uint64, numElem) + for i := 0; i < numElem; i++ { + var tmp uint64 + + tmpSlice := sszSlice12[i*8 : (1+i)*8] + tmp = binary.LittleEndian.Uint64(tmpSlice) + c.Balances[i] = tmp } } - // Field (10) 'BlsToExecutionChanges' + // Field 13: RandaoMixes { - buf = tail[o10:] - num, err := ssz.DivideInt2(len(buf), 172, 16) - if err != nil { - return err - } - b.BlsToExecutionChanges = make([]*SignedBLSToExecutionChange, num) - for ii := 0; ii < num; ii++ { - if b.BlsToExecutionChanges[ii] == nil { - b.BlsToExecutionChanges[ii] = new(SignedBLSToExecutionChange) - } - if err = b.BlsToExecutionChanges[ii].UnmarshalSSZ(buf[ii*172 : (ii+1)*172]); err != nil { - return err - } + c.RandaoMixes = make([][]byte, 65536) + for i := 0; i < 65536; i++ { + var tmp []byte + + tmpSlice := sszSlice13[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.RandaoMixes[i] = tmp } } - return err -} -// SizeSSZ returns the ssz encoded size in bytes for the BlindedBeaconBlockBodyCapella object -func (b *BlindedBeaconBlockBodyCapella) SizeSSZ() (size int) { - size = 388 + // Field 14: Slashings + { + c.Slashings = make([]uint64, 8192) + for i := 0; i < 8192; i++ { + var tmp uint64 + + tmpSlice := sszSlice14[i*8 : (1+i)*8] + tmp = binary.LittleEndian.Uint64(tmpSlice) + c.Slashings[i] = tmp + } + } - // Field (3) 'ProposerSlashings' - size += len(b.ProposerSlashings) * 416 + // Field 15: PreviousEpochParticipation + c.PreviousEpochParticipation = append([]byte{}, sszSlice15...) - // Field (4) 'AttesterSlashings' - for ii := 0; ii < len(b.AttesterSlashings); ii++ { - size += 4 - size += b.AttesterSlashings[ii].SizeSSZ() + // Field 16: CurrentEpochParticipation + c.CurrentEpochParticipation = append([]byte{}, sszSlice16...) + + // Field 17: JustificationBits + c.JustificationBits = make([]byte, 0, 1) + c.JustificationBits = append(c.JustificationBits, go_bitfield.Bitvector4(sszSlice17)...) + + // Field 18: PreviousJustifiedCheckpoint + c.PreviousJustifiedCheckpoint = new(Checkpoint) + if err = c.PreviousJustifiedCheckpoint.UnmarshalSSZ(sszSlice18); err != nil { + return fmt.Errorf("PreviousJustifiedCheckpoint: %w", err) } - // Field (5) 'Attestations' - for ii := 0; ii < len(b.Attestations); ii++ { - size += 4 - size += b.Attestations[ii].SizeSSZ() + // Field 19: CurrentJustifiedCheckpoint + c.CurrentJustifiedCheckpoint = new(Checkpoint) + if err = c.CurrentJustifiedCheckpoint.UnmarshalSSZ(sszSlice19); err != nil { + return fmt.Errorf("CurrentJustifiedCheckpoint: %w", err) } - // Field (6) 'Deposits' - size += len(b.Deposits) * 1240 + // Field 20: FinalizedCheckpoint + c.FinalizedCheckpoint = new(Checkpoint) + if err = c.FinalizedCheckpoint.UnmarshalSSZ(sszSlice20); err != nil { + return fmt.Errorf("FinalizedCheckpoint: %w", err) + } - // Field (7) 'VoluntaryExits' - size += len(b.VoluntaryExits) * 112 + // Field 21: InactivityScores + { + if len(sszSlice21)%8 != 0 { + return fmt.Errorf("misaligned bytes: c.InactivityScores length is %d, which is not a multiple of 8: %w", len(sszSlice21), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice21) / 8 + if numElem > 1099511627776 { + return fmt.Errorf("ssz-max exceeded: c.InactivityScores has %d elements, ssz-max is 1099511627776: %w", numElem, ssz.ErrListTooBig) + } + c.InactivityScores = make([]uint64, numElem) + for i := 0; i < numElem; i++ { + var tmp uint64 - // Field (9) 'ExecutionPayloadHeader' - if b.ExecutionPayloadHeader == nil { - b.ExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderCapella) + tmpSlice := sszSlice21[i*8 : (1+i)*8] + tmp = binary.LittleEndian.Uint64(tmpSlice) + c.InactivityScores[i] = tmp + } } - size += b.ExecutionPayloadHeader.SizeSSZ() - // Field (10) 'BlsToExecutionChanges' - size += len(b.BlsToExecutionChanges) * 172 + // Field 22: CurrentSyncCommittee + c.CurrentSyncCommittee = new(SyncCommittee) + if err = c.CurrentSyncCommittee.UnmarshalSSZ(sszSlice22); err != nil { + return fmt.Errorf("CurrentSyncCommittee: %w", err) + } - return -} + // Field 23: NextSyncCommittee + c.NextSyncCommittee = new(SyncCommittee) + if err = c.NextSyncCommittee.UnmarshalSSZ(sszSlice23); err != nil { + return fmt.Errorf("NextSyncCommittee: %w", err) + } -// HashTreeRoot ssz hashes the BlindedBeaconBlockBodyCapella object -func (b *BlindedBeaconBlockBodyCapella) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) -} + // Field 24: LatestExecutionPayloadHeader + c.LatestExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderCapella) + if err = c.LatestExecutionPayloadHeader.UnmarshalSSZ(sszSlice24); err != nil { + return fmt.Errorf("LatestExecutionPayloadHeader: %w", err) + } -// HashTreeRootWith ssz hashes the BlindedBeaconBlockBodyCapella object with a hasher -func (b *BlindedBeaconBlockBodyCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() + // Field 25: NextWithdrawalIndex + c.NextWithdrawalIndex = binary.LittleEndian.Uint64(sszSlice25) - // Field (0) 'RandaoReveal' - if size := len(b.RandaoReveal); size != 96 { - err = ssz.ErrBytesLengthFn("--.RandaoReveal", size, 96) - return + // Field 26: NextWithdrawalValidatorIndex + if err = c.NextWithdrawalValidatorIndex.UnmarshalSSZ(sszSlice26); err != nil { + return fmt.Errorf("NextWithdrawalValidatorIndex: %w", err) } - hh.PutBytes(b.RandaoReveal) - // Field (1) 'Eth1Data' - if err = b.Eth1Data.HashTreeRootWith(hh); err != nil { - return + // Field 27: HistoricalSummaries + { + if len(sszSlice27)%64 != 0 { + return fmt.Errorf("misaligned bytes: c.HistoricalSummaries length is %d, which is not a multiple of 64: %w", len(sszSlice27), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice27) / 64 + if numElem > 16777216 { + return fmt.Errorf("ssz-max exceeded: c.HistoricalSummaries has %d elements, ssz-max is 16777216: %w", numElem, ssz.ErrListTooBig) + } + c.HistoricalSummaries = make([]*HistoricalSummary, numElem) + for i := 0; i < numElem; i++ { + var tmp *HistoricalSummary + tmp = new(HistoricalSummary) + tmpSlice := sszSlice27[i*64 : (1+i)*64] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("HistoricalSummaries: %w", err) + } + c.HistoricalSummaries[i] = tmp + } } + return err +} - // Field (2) 'Graffiti' - if size := len(b.Graffiti); size != 32 { - err = ssz.ErrBytesLengthFn("--.Graffiti", size, 32) - return +func (c *BeaconStateCapella) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - hh.PutBytes(b.Graffiti) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (3) 'ProposerSlashings' +func (c *BeaconStateCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: GenesisTime + hh.PutUint64(c.GenesisTime) + // Field 1: GenesisValidatorsRoot + if len(c.GenesisValidatorsRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.GenesisValidatorsRoot) + // Field 2: Slot + if err := c.Slot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Slot: %w", err) + } + // Field 3: Fork + if err := c.Fork.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Fork: %w", err) + } + // Field 4: LatestBlockHeader + if err := c.LatestBlockHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("LatestBlockHeader: %w", err) + } + // Field 5: BlockRoots { + if len(c.BlockRoots) != 8192 { + return ssz.ErrVectorLength + } 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 + for _, o := range c.BlockRoots { + if len(o) != 32 { + return ssz.ErrBytesLength } + hh.Append(o) } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.Merkleize(subIndx) } - - // Field (4) 'AttesterSlashings' + // Field 6: StateRoots { + if len(c.StateRoots) != 8192 { + return ssz.ErrVectorLength + } 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 + for _, o := range c.StateRoots { + if len(o) != 32 { + return ssz.ErrBytesLength } + hh.Append(o) } - hh.MerkleizeWithMixin(subIndx, num, 2) + hh.Merkleize(subIndx) } - - // Field (5) 'Attestations' + // Field 7: HistoricalRoots { + if len(c.HistoricalRoots) > 16777216 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.HistoricalRoots { + if len(o) != 32 { + return ssz.ErrBytesLength } + hh.Append(o) } - hh.MerkleizeWithMixin(subIndx, num, 128) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.HistoricalRoots)), 16777216) } - - // Field (6) 'Deposits' + // Field 8: Eth1Data + if err := c.Eth1Data.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Eth1Data: %w", err) + } + // Field 9: Eth1DataVotes { + if len(c.Eth1DataVotes) > 2048 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.Eth1DataVotes { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Eth1DataVotes: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Eth1DataVotes)), 2048) } - - // Field (7) 'VoluntaryExits' + // Field 10: Eth1DepositIndex + hh.PutUint64(c.Eth1DepositIndex) + // Field 11: Validators { + if len(c.Validators) > 1099511627776 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.Validators { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Validators: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 16) - } - - // Field (8) 'SyncAggregate' - if err = b.SyncAggregate.HashTreeRootWith(hh); err != nil { - return + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Validators)), 1099511627776) } - - // Field (9) 'ExecutionPayloadHeader' - if err = b.ExecutionPayloadHeader.HashTreeRootWith(hh); err != nil { - return + // Field 12: Balances + { + if len(c.Balances) > 1099511627776 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.Balances { + hh.AppendUint64(o) + } + hh.FillUpTo32() + numItems := uint64(len(c.Balances)) + hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(1099511627776, numItems, 8)) } - - // Field (10) 'BlsToExecutionChanges' + // Field 13: RandaoMixes { + if len(c.RandaoMixes) != 65536 { + return ssz.ErrVectorLength + } 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 + for _, o := range c.RandaoMixes { + if len(o) != 32 { + return ssz.ErrBytesLength } + hh.Append(o) } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.Merkleize(subIndx) } + // Field 14: Slashings + { + if len(c.Slashings) != 8192 { + return ssz.ErrVectorLength + } + subIndx := hh.Index() + for _, o := range c.Slashings { + hh.AppendUint64(o) + } + hh.Merkleize(subIndx) + } + // Field 15: PreviousEpochParticipation - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the SignedBuilderBidCapella object -func (s *SignedBuilderBidCapella) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) -} + { + if len(c.PreviousEpochParticipation) > 1099511627776 { + return ssz.ErrBytesLength + } + subIndx := hh.Index() + hh.AppendBytes32(c.PreviousEpochParticipation) + numItems := uint64(len(c.PreviousEpochParticipation)) + hh.MerkleizeWithMixin(subIndx, numItems, (1099511627776*1+31)/32) + } -// MarshalSSZTo ssz marshals the SignedBuilderBidCapella object to a target array -func (s *SignedBuilderBidCapella) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(100) + // Field 16: CurrentEpochParticipation - // Offset (0) 'Message' - dst = ssz.WriteOffset(dst, offset) - if s.Message == nil { - s.Message = new(BuilderBidCapella) + { + if len(c.CurrentEpochParticipation) > 1099511627776 { + return ssz.ErrBytesLength + } + subIndx := hh.Index() + hh.AppendBytes32(c.CurrentEpochParticipation) + numItems := uint64(len(c.CurrentEpochParticipation)) + hh.MerkleizeWithMixin(subIndx, numItems, (1099511627776*1+31)/32) } - offset += s.Message.SizeSSZ() - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 17: JustificationBits + if len([]byte(c.JustificationBits)) != 1 { + return ssz.ErrBytesLength } - dst = append(dst, s.Signature...) - - // Field (0) 'Message' - if dst, err = s.Message.MarshalSSZTo(dst); err != nil { - return + hh.PutBytes([]byte(c.JustificationBits)) + // Field 18: PreviousJustifiedCheckpoint + if err := c.PreviousJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("PreviousJustifiedCheckpoint: %w", err) } - - return -} - -// UnmarshalSSZ ssz unmarshals the SignedBuilderBidCapella object -func (s *SignedBuilderBidCapella) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 100 { - return ssz.ErrSize + // Field 19: CurrentJustifiedCheckpoint + if err := c.CurrentJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("CurrentJustifiedCheckpoint: %w", err) } - - tail := buf - var o0 uint64 - - // Offset (0) 'Message' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset + // Field 20: FinalizedCheckpoint + if err := c.FinalizedCheckpoint.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("FinalizedCheckpoint: %w", err) } - - if o0 != 100 { - return ssz.ErrInvalidVariableOffset + // Field 21: InactivityScores + { + if len(c.InactivityScores) > 1099511627776 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.InactivityScores { + hh.AppendUint64(o) + } + hh.FillUpTo32() + numItems := uint64(len(c.InactivityScores)) + hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(1099511627776, numItems, 8)) } - - // Field (1) 'Signature' - if cap(s.Signature) == 0 { - s.Signature = make([]byte, 0, len(buf[4:100])) + // Field 22: CurrentSyncCommittee + if err := c.CurrentSyncCommittee.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("CurrentSyncCommittee: %w", err) } - s.Signature = append(s.Signature, buf[4:100]...) - - // Field (0) 'Message' + // Field 23: NextSyncCommittee + if err := c.NextSyncCommittee.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("NextSyncCommittee: %w", err) + } + // Field 24: LatestExecutionPayloadHeader + if err := c.LatestExecutionPayloadHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("LatestExecutionPayloadHeader: %w", err) + } + // Field 25: NextWithdrawalIndex + hh.PutUint64(c.NextWithdrawalIndex) + // Field 26: NextWithdrawalValidatorIndex + if err := c.NextWithdrawalValidatorIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("NextWithdrawalValidatorIndex: %w", err) + } + // Field 27: HistoricalSummaries { - buf = tail[o0:] - if s.Message == nil { - s.Message = new(BuilderBidCapella) + if len(c.HistoricalSummaries) > 16777216 { + return ssz.ErrListTooBig } - if err = s.Message.UnmarshalSSZ(buf); err != nil { - return err + subIndx := hh.Index() + for _, o := range c.HistoricalSummaries { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("HistoricalSummaries: %w", err) + } } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.HistoricalSummaries)), 16777216) } - return err + hh.Merkleize(indx) + return nil } -// SizeSSZ returns the ssz encoded size in bytes for the SignedBuilderBidCapella object -func (s *SignedBuilderBidCapella) SizeSSZ() (size int) { - size = 100 - - // Field (0) 'Message' - if s.Message == nil { - s.Message = new(BuilderBidCapella) +func (c *BlindedBeaconBlockBodyCapella) SizeSSZ() int { + size := 388 + size += len(c.ProposerSlashings) * 416 + for _, o := range c.AttesterSlashings { + size += 4 + size += o.SizeSSZ() } - size += s.Message.SizeSSZ() - - return + for _, o := range c.Attestations { + size += 4 + size += o.SizeSSZ() + } + size += len(c.Deposits) * 1240 + size += len(c.VoluntaryExits) * 112 + if c.ExecutionPayloadHeader == nil { + c.ExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderCapella) + } + size += c.ExecutionPayloadHeader.SizeSSZ() + size += len(c.BlsToExecutionChanges) * 172 + return size } -// HashTreeRoot ssz hashes the SignedBuilderBidCapella object -func (s *SignedBuilderBidCapella) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) +func (c *BlindedBeaconBlockBodyCapella) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// HashTreeRootWith ssz hashes the SignedBuilderBidCapella object with a hasher -func (s *SignedBuilderBidCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() +func (c *BlindedBeaconBlockBodyCapella) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 388 - // Field (0) 'Message' - if err = s.Message.HashTreeRootWith(hh); err != nil { - return + // Field 0: RandaoReveal + if len(c.RandaoReveal) != 96 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.RandaoReveal...) - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 1: Eth1Data + if c.Eth1Data == nil { + c.Eth1Data = new(Eth1Data) + } + if dst, err = c.Eth1Data.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Eth1Data: %w", err) } - hh.PutBytes(s.Signature) - - hh.Merkleize(indx) - return -} -// MarshalSSZ ssz marshals the BuilderBidCapella object -func (b *BuilderBidCapella) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} + // Field 2: Graffiti + if len(c.Graffiti) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.Graffiti...) -// MarshalSSZTo ssz marshals the BuilderBidCapella object to a target array -func (b *BuilderBidCapella) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(84) + // Field 3: ProposerSlashings + dst = ssz.WriteOffset(dst, offset) + offset += len(c.ProposerSlashings) * 416 - // Offset (0) 'Header' + // Field 4: AttesterSlashings dst = ssz.WriteOffset(dst, offset) - if b.Header == nil { - b.Header = new(v1.ExecutionPayloadHeaderCapella) + for _, o := range c.AttesterSlashings { + offset += 4 + offset += o.SizeSSZ() } - offset += b.Header.SizeSSZ() - // Field (1) 'Value' - if size := len(b.Value); size != 32 { - err = ssz.ErrBytesLengthFn("--.Value", size, 32) - return + // Field 5: Attestations + dst = ssz.WriteOffset(dst, offset) + for _, o := range c.Attestations { + offset += 4 + offset += o.SizeSSZ() } - dst = append(dst, b.Value...) - // Field (2) 'Pubkey' - if size := len(b.Pubkey); size != 48 { - err = ssz.ErrBytesLengthFn("--.Pubkey", size, 48) - return - } - dst = append(dst, b.Pubkey...) + // Field 6: Deposits + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Deposits) * 1240 - // Field (0) 'Header' - if dst, err = b.Header.MarshalSSZTo(dst); err != nil { - return - } + // Field 7: VoluntaryExits + dst = ssz.WriteOffset(dst, offset) + offset += len(c.VoluntaryExits) * 112 - return -} + // Field 8: SyncAggregate + if c.SyncAggregate == nil { + c.SyncAggregate = new(SyncAggregate) + } + if dst, err = c.SyncAggregate.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SyncAggregate: %w", err) + } -// UnmarshalSSZ ssz unmarshals the BuilderBidCapella object -func (b *BuilderBidCapella) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 84 { - return ssz.ErrSize + // Field 9: ExecutionPayloadHeader + if c.ExecutionPayloadHeader == nil { + c.ExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderCapella) } + dst = ssz.WriteOffset(dst, offset) + offset += c.ExecutionPayloadHeader.SizeSSZ() - tail := buf - var o0 uint64 + // Field 10: BlsToExecutionChanges + dst = ssz.WriteOffset(dst, offset) + offset += len(c.BlsToExecutionChanges) * 172 - // Offset (0) 'Header' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset + // Field 3: ProposerSlashings + if len(c.ProposerSlashings) > 16 { + return nil, ssz.ErrListTooBig } - - if o0 != 84 { - return ssz.ErrInvalidVariableOffset + for _, o := range c.ProposerSlashings { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ProposerSlashings: %w", err) + } } - // Field (1) 'Value' - if cap(b.Value) == 0 { - b.Value = make([]byte, 0, len(buf[4:36])) + // Field 4: AttesterSlashings + if len(c.AttesterSlashings) > 2 { + return nil, ssz.ErrListTooBig } - b.Value = append(b.Value, buf[4:36]...) - - // Field (2) 'Pubkey' - if cap(b.Pubkey) == 0 { - b.Pubkey = make([]byte, 0, len(buf[36:84])) + { + offset = 4 * len(c.AttesterSlashings) + for _, o := range c.AttesterSlashings { + dst = ssz.WriteOffset(dst, offset) + offset += o.SizeSSZ() + } + } + for _, o := range c.AttesterSlashings { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("AttesterSlashings: %w", err) + } } - b.Pubkey = append(b.Pubkey, buf[36:84]...) - // Field (0) 'Header' + // Field 5: Attestations + if len(c.Attestations) > 128 { + return nil, ssz.ErrListTooBig + } { - buf = tail[o0:] - if b.Header == nil { - b.Header = new(v1.ExecutionPayloadHeaderCapella) + offset = 4 * len(c.Attestations) + for _, o := range c.Attestations { + dst = ssz.WriteOffset(dst, offset) + offset += o.SizeSSZ() } - if err = b.Header.UnmarshalSSZ(buf); err != nil { - return err + } + for _, o := range c.Attestations { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Attestations: %w", err) } } - return err -} -// SizeSSZ returns the ssz encoded size in bytes for the BuilderBidCapella object -func (b *BuilderBidCapella) SizeSSZ() (size int) { - size = 84 - - // Field (0) 'Header' - if b.Header == nil { - b.Header = new(v1.ExecutionPayloadHeaderCapella) + // Field 6: Deposits + if len(c.Deposits) > 16 { + return nil, ssz.ErrListTooBig } - size += b.Header.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the BuilderBidCapella object -func (b *BuilderBidCapella) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) -} - -// HashTreeRootWith ssz hashes the BuilderBidCapella object with a hasher -func (b *BuilderBidCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'Header' - if err = b.Header.HashTreeRootWith(hh); err != nil { - return + for _, o := range c.Deposits { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Deposits: %w", err) + } } - // Field (1) 'Value' - if size := len(b.Value); size != 32 { - err = ssz.ErrBytesLengthFn("--.Value", size, 32) - return + // Field 7: VoluntaryExits + if len(c.VoluntaryExits) > 16 { + return nil, ssz.ErrListTooBig } - hh.PutBytes(b.Value) - - // Field (2) 'Pubkey' - if size := len(b.Pubkey); size != 48 { - err = ssz.ErrBytesLengthFn("--.Pubkey", size, 48) - return + for _, o := range c.VoluntaryExits { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("VoluntaryExits: %w", err) + } } - hh.PutBytes(b.Pubkey) - - hh.Merkleize(indx) - return -} - -// 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' - if size := len(h.BlockSummaryRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockSummaryRoot", size, 32) - return + // Field 9: ExecutionPayloadHeader + if dst, err = c.ExecutionPayloadHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ExecutionPayloadHeader: %w", err) } - dst = append(dst, h.BlockSummaryRoot...) - // Field (1) 'StateSummaryRoot' - if size := len(h.StateSummaryRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateSummaryRoot", size, 32) - return + // Field 10: BlsToExecutionChanges + if len(c.BlsToExecutionChanges) > 16 { + return nil, ssz.ErrListTooBig } - dst = append(dst, h.StateSummaryRoot...) - - return + for _, o := range c.BlsToExecutionChanges { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("BlsToExecutionChanges: %w", err) + } + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the HistoricalSummary object -func (h *HistoricalSummary) UnmarshalSSZ(buf []byte) error { +func (c *BlindedBeaconBlockBodyCapella) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 64 { + if size < 388 { return ssz.ErrSize } - // Field (0) 'BlockSummaryRoot' - if cap(h.BlockSummaryRoot) == 0 { - h.BlockSummaryRoot = make([]byte, 0, len(buf[0:32])) - } - h.BlockSummaryRoot = append(h.BlockSummaryRoot, buf[0:32]...) + sszSlice0 := buf[0:96] // c.RandaoReveal + sszSlice1 := buf[96:168] // c.Eth1Data + sszSlice2 := buf[168:200] // c.Graffiti + sszSlice8 := buf[220:380] // c.SyncAggregate - // Field (1) 'StateSummaryRoot' - if cap(h.StateSummaryRoot) == 0 { - h.StateSummaryRoot = make([]byte, 0, len(buf[32:64])) + sszVarOffset3 := ssz.ReadOffset(buf[200:204]) // c.ProposerSlashings + if sszVarOffset3 != 388 { + return ssz.ErrInvalidVariableOffset } - h.StateSummaryRoot = append(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.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'BlockSummaryRoot' - if size := len(h.BlockSummaryRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockSummaryRoot", size, 32) - return + if sszVarOffset3 > size { + return ssz.ErrOffset } - hh.PutBytes(h.BlockSummaryRoot) - - // Field (1) 'StateSummaryRoot' - if size := len(h.StateSummaryRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateSummaryRoot", size, 32) - return + sszVarOffset4 := ssz.ReadOffset(buf[204:208]) // c.AttesterSlashings + if sszVarOffset4 > size || sszVarOffset4 < sszVarOffset3 { + return ssz.ErrOffset } - hh.PutBytes(h.StateSummaryRoot) - - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the BeaconStateCapella object -func (b *BeaconStateCapella) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} - -// MarshalSSZTo ssz marshals the BeaconStateCapella object to a target array -func (b *BeaconStateCapella) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(2736653) - - // Field (0) 'GenesisTime' - dst = ssz.MarshalUint(dst, b.GenesisTime) - - // Field (1) 'GenesisValidatorsRoot' - if size := len(b.GenesisValidatorsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.GenesisValidatorsRoot", size, 32) - return + sszVarOffset5 := ssz.ReadOffset(buf[208:212]) // c.Attestations + if sszVarOffset5 > size || sszVarOffset5 < sszVarOffset4 { + return ssz.ErrOffset } - dst = append(dst, b.GenesisValidatorsRoot...) - - // Field (2) 'Slot' - dst = ssz.MarshalUint(dst, b.Slot) - - // Field (3) 'Fork' - if b.Fork == nil { - b.Fork = new(Fork) + sszVarOffset6 := ssz.ReadOffset(buf[212:216]) // c.Deposits + if sszVarOffset6 > size || sszVarOffset6 < sszVarOffset5 { + return ssz.ErrOffset } - if dst, err = b.Fork.MarshalSSZTo(dst); err != nil { - return + sszVarOffset7 := ssz.ReadOffset(buf[216:220]) // c.VoluntaryExits + if sszVarOffset7 > size || sszVarOffset7 < sszVarOffset6 { + return ssz.ErrOffset } - - // Field (4) 'LatestBlockHeader' - if b.LatestBlockHeader == nil { - b.LatestBlockHeader = new(BeaconBlockHeader) + sszVarOffset9 := ssz.ReadOffset(buf[380:384]) // c.ExecutionPayloadHeader + if sszVarOffset9 > size || sszVarOffset9 < sszVarOffset7 { + return ssz.ErrOffset } - if dst, err = b.LatestBlockHeader.MarshalSSZTo(dst); err != nil { - return + sszVarOffset10 := ssz.ReadOffset(buf[384:388]) // c.BlsToExecutionChanges + if sszVarOffset10 > size || sszVarOffset10 < sszVarOffset9 { + return ssz.ErrOffset } + sszSlice3 := buf[sszVarOffset3:sszVarOffset4] // c.ProposerSlashings + sszSlice4 := buf[sszVarOffset4:sszVarOffset5] // c.AttesterSlashings + sszSlice5 := buf[sszVarOffset5:sszVarOffset6] // c.Attestations + sszSlice6 := buf[sszVarOffset6:sszVarOffset7] // c.Deposits + sszSlice7 := buf[sszVarOffset7:sszVarOffset9] // c.VoluntaryExits + sszSlice9 := buf[sszVarOffset9:sszVarOffset10] // c.ExecutionPayloadHeader + sszSlice10 := buf[sszVarOffset10:] // c.BlsToExecutionChanges + + // Field 0: RandaoReveal + c.RandaoReveal = make([]byte, 0, 96) + c.RandaoReveal = append(c.RandaoReveal, sszSlice0...) - // Field (5) 'BlockRoots' - if size := len(b.BlockRoots); size != 8192 { - err = ssz.ErrVectorLengthFn("--.BlockRoots", size, 8192) - return + // Field 1: Eth1Data + c.Eth1Data = new(Eth1Data) + if err = c.Eth1Data.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Eth1Data: %w", err) } - for ii := 0; ii < 8192; ii++ { - if size := len(b.BlockRoots[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockRoots[ii]", size, 32) - return + + // Field 2: Graffiti + c.Graffiti = make([]byte, 0, 32) + c.Graffiti = append(c.Graffiti, sszSlice2...) + + // Field 3: ProposerSlashings + { + if len(sszSlice3)%416 != 0 { + return fmt.Errorf("misaligned bytes: c.ProposerSlashings length is %d, which is not a multiple of 416: %w", len(sszSlice3), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice3) / 416 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.ProposerSlashings has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.ProposerSlashings = make([]*ProposerSlashing, numElem) + for i := 0; i < numElem; i++ { + var tmp *ProposerSlashing + tmp = new(ProposerSlashing) + tmpSlice := sszSlice3[i*416 : (1+i)*416] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("ProposerSlashings: %w", err) + } + c.ProposerSlashings[i] = tmp } - dst = append(dst, b.BlockRoots[ii]...) } - // Field (6) 'StateRoots' - if size := len(b.StateRoots); size != 8192 { - err = ssz.ErrVectorLengthFn("--.StateRoots", size, 8192) - return - } - for ii := 0; ii < 8192; ii++ { - if size := len(b.StateRoots[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoots[ii]", size, 32) - return + // Field 4: AttesterSlashings + { + // empty lists are zero length, so make sure there is room for an offset + // before attempting to unmarshal it + if len(sszSlice4) > 3 { + startOffset := ssz.ReadOffset(sszSlice4[0:4]) + if startOffset == 0 { + return fmt.Errorf("encountered invalid offset of 0 when decoding c.AttesterSlashings") + } + if startOffset%4 != 0 { + return fmt.Errorf("misaligned list bytes: when decoding c.AttesterSlashings, end-of-list offset is %d, which is not a multiple of 4 (offset size)", startOffset) + } + listLen := startOffset / 4 + if listLen > 2 { + return fmt.Errorf("ssz-max exceeded: c.AttesterSlashings has %d elements, ssz-max is 2: %w", listLen, ssz.ErrListTooBig) + } + totalVarBytes := uint64(len(sszSlice4)) + if totalVarBytes < startOffset { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.AttesterSlashings") + } + c.AttesterSlashings = make([]*AttesterSlashing, listLen) + var tmpSlice []byte + for i := uint64(0); i < listLen; i++ { + var tmp *AttesterSlashing + tmp = new(AttesterSlashing) + endOffset := totalVarBytes + if i+1 != listLen { + endOffset = ssz.ReadOffset(sszSlice4[(i+1)*4 : (i+2)*4]) + if totalVarBytes < endOffset { + return fmt.Errorf("offset %d points past the end of buffer when decoding c.AttesterSlashings", endOffset) + } + } + if endOffset < startOffset { + return fmt.Errorf("offset %d is not greater than start offset %d when decoding c.AttesterSlashings", endOffset, startOffset) + } + tmpSlice = sszSlice4[startOffset:endOffset] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("AttesterSlashings: %w", err) + } + c.AttesterSlashings[i] = tmp + startOffset = endOffset + } + } else { + if len(sszSlice4) > 0 { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.AttesterSlashings") + } + c.AttesterSlashings = make([]*AttesterSlashing, 0) } - 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(Eth1Data) - } - if dst, err = b.Eth1Data.MarshalSSZTo(dst); err != nil { - return + // Field 5: Attestations + { + // empty lists are zero length, so make sure there is room for an offset + // before attempting to unmarshal it + if len(sszSlice5) > 3 { + startOffset := ssz.ReadOffset(sszSlice5[0:4]) + if startOffset == 0 { + return fmt.Errorf("encountered invalid offset of 0 when decoding c.Attestations") + } + if startOffset%4 != 0 { + return fmt.Errorf("misaligned list bytes: when decoding c.Attestations, end-of-list offset is %d, which is not a multiple of 4 (offset size)", startOffset) + } + listLen := startOffset / 4 + if listLen > 128 { + return fmt.Errorf("ssz-max exceeded: c.Attestations has %d elements, ssz-max is 128: %w", listLen, ssz.ErrListTooBig) + } + totalVarBytes := uint64(len(sszSlice5)) + if totalVarBytes < startOffset { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.Attestations") + } + c.Attestations = make([]*Attestation, listLen) + var tmpSlice []byte + for i := uint64(0); i < listLen; i++ { + var tmp *Attestation + tmp = new(Attestation) + endOffset := totalVarBytes + if i+1 != listLen { + endOffset = ssz.ReadOffset(sszSlice5[(i+1)*4 : (i+2)*4]) + if totalVarBytes < endOffset { + return fmt.Errorf("offset %d points past the end of buffer when decoding c.Attestations", endOffset) + } + } + if endOffset < startOffset { + return fmt.Errorf("offset %d is not greater than start offset %d when decoding c.Attestations", endOffset, startOffset) + } + tmpSlice = sszSlice5[startOffset:endOffset] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Attestations: %w", err) + } + c.Attestations[i] = tmp + startOffset = endOffset + } + } else { + if len(sszSlice5) > 0 { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.Attestations") + } + c.Attestations = make([]*Attestation, 0) + } } - // Offset (9) 'Eth1DataVotes' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.Eth1DataVotes) * 72 - - // Field (10) 'Eth1DepositIndex' - dst = ssz.MarshalUint(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("--.RandaoMixes", size, 65536) - return - } - for ii := 0; ii < 65536; ii++ { - if size := len(b.RandaoMixes[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.RandaoMixes[ii]", size, 32) - return + // Field 6: Deposits + { + if len(sszSlice6)%1240 != 0 { + return fmt.Errorf("misaligned bytes: c.Deposits length is %d, which is not a multiple of 1240: %w", len(sszSlice6), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice6) / 1240 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.Deposits has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.Deposits = make([]*Deposit, numElem) + for i := 0; i < numElem; i++ { + var tmp *Deposit + tmp = new(Deposit) + tmpSlice := sszSlice6[i*1240 : (1+i)*1240] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Deposits: %w", err) + } + c.Deposits[i] = tmp } - dst = append(dst, b.RandaoMixes[ii]...) } - // Field (14) 'Slashings' - if size := len(b.Slashings); size != 8192 { - err = ssz.ErrVectorLengthFn("--.Slashings", size, 8192) - return - } - for ii := 0; ii < 8192; ii++ { - dst = ssz.MarshalUint(dst, b.Slashings[ii]) + // Field 7: VoluntaryExits + { + if len(sszSlice7)%112 != 0 { + return fmt.Errorf("misaligned bytes: c.VoluntaryExits length is %d, which is not a multiple of 112: %w", len(sszSlice7), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice7) / 112 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.VoluntaryExits has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.VoluntaryExits = make([]*SignedVoluntaryExit, numElem) + for i := 0; i < numElem; i++ { + var tmp *SignedVoluntaryExit + tmp = new(SignedVoluntaryExit) + tmpSlice := sszSlice7[i*112 : (1+i)*112] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("VoluntaryExits: %w", err) + } + c.VoluntaryExits[i] = tmp + } } - // 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' - if size := len(b.JustificationBits); size != 1 { - err = ssz.ErrBytesLengthFn("--.JustificationBits", size, 1) - return + // Field 8: SyncAggregate + c.SyncAggregate = new(SyncAggregate) + if err = c.SyncAggregate.UnmarshalSSZ(sszSlice8); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) } - dst = append(dst, b.JustificationBits...) - // Field (18) 'PreviousJustifiedCheckpoint' - if b.PreviousJustifiedCheckpoint == nil { - b.PreviousJustifiedCheckpoint = new(Checkpoint) - } - if dst, err = b.PreviousJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { - return + // Field 9: ExecutionPayloadHeader + c.ExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderCapella) + if err = c.ExecutionPayloadHeader.UnmarshalSSZ(sszSlice9); err != nil { + return fmt.Errorf("ExecutionPayloadHeader: %w", err) } - // Field (19) 'CurrentJustifiedCheckpoint' - if b.CurrentJustifiedCheckpoint == nil { - b.CurrentJustifiedCheckpoint = new(Checkpoint) - } - if dst, err = b.CurrentJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { - return + // Field 10: BlsToExecutionChanges + { + if len(sszSlice10)%172 != 0 { + return fmt.Errorf("misaligned bytes: c.BlsToExecutionChanges length is %d, which is not a multiple of 172: %w", len(sszSlice10), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice10) / 172 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.BlsToExecutionChanges has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.BlsToExecutionChanges = make([]*SignedBLSToExecutionChange, numElem) + for i := 0; i < numElem; i++ { + var tmp *SignedBLSToExecutionChange + tmp = new(SignedBLSToExecutionChange) + tmpSlice := sszSlice10[i*172 : (1+i)*172] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("BlsToExecutionChanges: %w", err) + } + c.BlsToExecutionChanges[i] = tmp + } } + return err +} - // Field (20) 'FinalizedCheckpoint' - if b.FinalizedCheckpoint == nil { - b.FinalizedCheckpoint = new(Checkpoint) - } - if dst, err = b.FinalizedCheckpoint.MarshalSSZTo(dst); err != nil { - return +func (c *BlindedBeaconBlockBodyCapella) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Offset (21) 'InactivityScores' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.InactivityScores) * 8 - - // Field (22) 'CurrentSyncCommittee' - if b.CurrentSyncCommittee == nil { - b.CurrentSyncCommittee = new(SyncCommittee) - } - if dst, err = b.CurrentSyncCommittee.MarshalSSZTo(dst); err != nil { - return +func (c *BlindedBeaconBlockBodyCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: RandaoReveal + if len(c.RandaoReveal) != 96 { + return ssz.ErrBytesLength } - - // Field (23) 'NextSyncCommittee' - if b.NextSyncCommittee == nil { - b.NextSyncCommittee = new(SyncCommittee) + hh.PutBytes(c.RandaoReveal) + // Field 1: Eth1Data + if err := c.Eth1Data.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Eth1Data: %w", err) } - if dst, err = b.NextSyncCommittee.MarshalSSZTo(dst); err != nil { - return + // Field 2: Graffiti + if len(c.Graffiti) != 32 { + return ssz.ErrBytesLength } - - // Offset (24) 'LatestExecutionPayloadHeader' - dst = ssz.WriteOffset(dst, offset) - if b.LatestExecutionPayloadHeader == nil { - b.LatestExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderCapella) + hh.PutBytes(c.Graffiti) + // Field 3: ProposerSlashings + { + if len(c.ProposerSlashings) > 16 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.ProposerSlashings { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ProposerSlashings: %w", err) + } + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.ProposerSlashings)), 16) } - offset += b.LatestExecutionPayloadHeader.SizeSSZ() - - // Field (25) 'NextWithdrawalIndex' - dst = ssz.MarshalUint(dst, b.NextWithdrawalIndex) - - // Field (26) 'NextWithdrawalValidatorIndex' - dst = ssz.MarshalUint(dst, b.NextWithdrawalValidatorIndex) - - // Offset (27) 'HistoricalSummaries' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.HistoricalSummaries) * 64 - - // Field (7) 'HistoricalRoots' - if size := len(b.HistoricalRoots); size > 16777216 { - err = ssz.ErrListTooBigFn("--.HistoricalRoots", size, 16777216) - return + // Field 4: AttesterSlashings + { + if len(c.AttesterSlashings) > 2 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.AttesterSlashings { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("AttesterSlashings: %w", err) + } + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.AttesterSlashings)), 2) } - for ii := 0; ii < len(b.HistoricalRoots); ii++ { - if size := len(b.HistoricalRoots[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.HistoricalRoots[ii]", size, 32) - return + // Field 5: Attestations + { + if len(c.Attestations) > 128 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.Attestations { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Attestations: %w", err) + } } - dst = append(dst, b.HistoricalRoots[ii]...) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Attestations)), 128) } - - // Field (9) 'Eth1DataVotes' - if size := len(b.Eth1DataVotes); size > 2048 { - err = ssz.ErrListTooBigFn("--.Eth1DataVotes", size, 2048) - return + // Field 6: Deposits + { + if len(c.Deposits) > 16 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.Deposits { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Deposits: %w", err) + } + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Deposits)), 16) } - for ii := 0; ii < len(b.Eth1DataVotes); ii++ { - if dst, err = b.Eth1DataVotes[ii].MarshalSSZTo(dst); err != nil { - return + // Field 7: VoluntaryExits + { + if len(c.VoluntaryExits) > 16 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.VoluntaryExits { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("VoluntaryExits: %w", err) + } } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.VoluntaryExits)), 16) } - - // Field (11) 'Validators' - if size := len(b.Validators); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.Validators", size, 1099511627776) - return + // Field 8: SyncAggregate + if err := c.SyncAggregate.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) } - for ii := 0; ii < len(b.Validators); ii++ { - if dst, err = b.Validators[ii].MarshalSSZTo(dst); err != nil { - return + // Field 9: ExecutionPayloadHeader + if err := c.ExecutionPayloadHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ExecutionPayloadHeader: %w", err) + } + // Field 10: BlsToExecutionChanges + { + if len(c.BlsToExecutionChanges) > 16 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.BlsToExecutionChanges { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("BlsToExecutionChanges: %w", err) + } } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.BlsToExecutionChanges)), 16) } + hh.Merkleize(indx) + return nil +} - // Field (12) 'Balances' - if size := len(b.Balances); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.Balances", size, 1099511627776) - return - } - for ii := 0; ii < len(b.Balances); ii++ { - dst = ssz.MarshalUint(dst, b.Balances[ii]) +func (c *BlindedBeaconBlockCapella) SizeSSZ() int { + size := 84 + if c.Body == nil { + c.Body = new(BlindedBeaconBlockBodyCapella) } + size += c.Body.SizeSSZ() + return size +} - // Field (15) 'PreviousEpochParticipation' - if size := len(b.PreviousEpochParticipation); size > 1099511627776 { - err = ssz.ErrBytesLengthFn("--.PreviousEpochParticipation", size, 1099511627776) - return - } - dst = append(dst, b.PreviousEpochParticipation...) +func (c *BlindedBeaconBlockCapella) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (16) 'CurrentEpochParticipation' - if size := len(b.CurrentEpochParticipation); size > 1099511627776 { - err = ssz.ErrBytesLengthFn("--.CurrentEpochParticipation", size, 1099511627776) - return - } - dst = append(dst, b.CurrentEpochParticipation...) +func (c *BlindedBeaconBlockCapella) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 84 - // Field (21) 'InactivityScores' - if size := len(b.InactivityScores); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.InactivityScores", size, 1099511627776) - return + // Field 0: Slot + if dst, err = c.Slot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Slot: %w", err) } - for ii := 0; ii < len(b.InactivityScores); ii++ { - dst = ssz.MarshalUint(dst, b.InactivityScores[ii]) + + // Field 1: ProposerIndex + if dst, err = c.ProposerIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ProposerIndex: %w", err) } - // Field (24) 'LatestExecutionPayloadHeader' - if dst, err = b.LatestExecutionPayloadHeader.MarshalSSZTo(dst); err != nil { - return + // Field 2: ParentRoot + if len(c.ParentRoot) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.ParentRoot...) - // Field (27) 'HistoricalSummaries' - if size := len(b.HistoricalSummaries); size > 16777216 { - err = ssz.ErrListTooBigFn("--.HistoricalSummaries", size, 16777216) - return + // Field 3: StateRoot + if len(c.StateRoot) != 32 { + return nil, ssz.ErrBytesLength } - for ii := 0; ii < len(b.HistoricalSummaries); ii++ { - if dst, err = b.HistoricalSummaries[ii].MarshalSSZTo(dst); err != nil { - return - } + dst = append(dst, c.StateRoot...) + + // Field 4: Body + if c.Body == nil { + c.Body = new(BlindedBeaconBlockBodyCapella) } + dst = ssz.WriteOffset(dst, offset) + offset += c.Body.SizeSSZ() - return + // Field 4: Body + if dst, err = c.Body.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Body: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the BeaconStateCapella object -func (b *BeaconStateCapella) UnmarshalSSZ(buf []byte) error { +func (c *BlindedBeaconBlockCapella) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 2736653 { + if size < 84 { return ssz.ErrSize } - tail := buf - var o7, o9, o11, o12, o15, o16, o21, o24, o27 uint64 - - // Field (0) 'GenesisTime' - b.GenesisTime = ssz.UnmarshallUint[uint64](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.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[40:48]) + sszSlice0 := buf[0:8] // c.Slot + sszSlice1 := buf[8:16] // c.ProposerIndex + sszSlice2 := buf[16:48] // c.ParentRoot + sszSlice3 := buf[48:80] // c.StateRoot - // Field (3) 'Fork' - if b.Fork == nil { - b.Fork = new(Fork) + sszVarOffset4 := ssz.ReadOffset(buf[80:84]) // c.Body + if sszVarOffset4 != 84 { + return ssz.ErrInvalidVariableOffset } - if err = b.Fork.UnmarshalSSZ(buf[48:64]); err != nil { - return err + if sszVarOffset4 > size { + return ssz.ErrOffset } + sszSlice4 := buf[sszVarOffset4:] // c.Body - // Field (4) 'LatestBlockHeader' - if b.LatestBlockHeader == nil { - b.LatestBlockHeader = new(BeaconBlockHeader) - } - if err = b.LatestBlockHeader.UnmarshalSSZ(buf[64:176]); err != nil { - return err + // Field 0: Slot + if err = c.Slot.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Slot: %w", err) } - // Field (5) 'BlockRoots' - b.BlockRoots = make([][]byte, 8192) - for ii := 0; ii < 8192; ii++ { - if cap(b.BlockRoots[ii]) == 0 { - b.BlockRoots[ii] = make([]byte, 0, len(buf[176:262320][ii*32:(ii+1)*32])) - } - b.BlockRoots[ii] = append(b.BlockRoots[ii], buf[176:262320][ii*32:(ii+1)*32]...) + // Field 1: ProposerIndex + if err = c.ProposerIndex.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("ProposerIndex: %w", err) } - // Field (6) 'StateRoots' - b.StateRoots = make([][]byte, 8192) - for ii := 0; ii < 8192; ii++ { - if cap(b.StateRoots[ii]) == 0 { - b.StateRoots[ii] = make([]byte, 0, len(buf[262320:524464][ii*32:(ii+1)*32])) - } - b.StateRoots[ii] = append(b.StateRoots[ii], buf[262320:524464][ii*32:(ii+1)*32]...) - } + // Field 2: ParentRoot + c.ParentRoot = make([]byte, 0, 32) + c.ParentRoot = append(c.ParentRoot, sszSlice2...) - // Offset (7) 'HistoricalRoots' - if o7 = ssz.ReadOffset(buf[524464:524468]); o7 > size { - return ssz.ErrOffset + // Field 3: StateRoot + c.StateRoot = make([]byte, 0, 32) + c.StateRoot = append(c.StateRoot, sszSlice3...) + + // Field 4: Body + c.Body = new(BlindedBeaconBlockBodyCapella) + if err = c.Body.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("Body: %w", err) } + return err +} - if o7 != 2736653 { - return ssz.ErrInvalidVariableOffset +func (c *BlindedBeaconBlockCapella) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (8) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(Eth1Data) +func (c *BlindedBeaconBlockCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Slot + if err := c.Slot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Slot: %w", err) } - if err = b.Eth1Data.UnmarshalSSZ(buf[524468:524540]); err != nil { - return err + // Field 1: ProposerIndex + if err := c.ProposerIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ProposerIndex: %w", err) } - - // Offset (9) 'Eth1DataVotes' - if o9 = ssz.ReadOffset(buf[524540:524544]); o9 > size || o7 > o9 { - return ssz.ErrOffset + // Field 2: ParentRoot + if len(c.ParentRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ParentRoot) + // Field 3: StateRoot + if len(c.StateRoot) != 32 { + return ssz.ErrBytesLength } + hh.PutBytes(c.StateRoot) + // Field 4: Body + if err := c.Body.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Body: %w", err) + } + hh.Merkleize(indx) + return nil +} - // Field (10) 'Eth1DepositIndex' - b.Eth1DepositIndex = ssz.UnmarshallUint[uint64](buf[524544:524552]) +func (c *BLSToExecutionChange) SizeSSZ() int { + size := 76 - // Offset (11) 'Validators' - if o11 = ssz.ReadOffset(buf[524552:524556]); o11 > size || o9 > o11 { - return ssz.ErrOffset - } + return size +} - // Offset (12) 'Balances' - if o12 = ssz.ReadOffset(buf[524556:524560]); o12 > size || o11 > o12 { - return ssz.ErrOffset - } +func (c *BLSToExecutionChange) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // 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]...) - } +func (c *BLSToExecutionChange) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (14) 'Slashings' - b.Slashings = ssz.ExtendUint(b.Slashings, 8192) - for ii := 0; ii < 8192; ii++ { - b.Slashings[ii] = ssz.UnmarshallUint[uint64](buf[2621712:2687248][ii*8 : (ii+1)*8]) + // Field 0: ValidatorIndex + if dst, err = c.ValidatorIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ValidatorIndex: %w", err) } - // Offset (15) 'PreviousEpochParticipation' - if o15 = ssz.ReadOffset(buf[2687248:2687252]); o15 > size || o12 > o15 { - return ssz.ErrOffset + // Field 1: FromBlsPubkey + if len(c.FromBlsPubkey) != 48 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.FromBlsPubkey...) - // Offset (16) 'CurrentEpochParticipation' - if o16 = ssz.ReadOffset(buf[2687252:2687256]); o16 > size || o15 > o16 { - return ssz.ErrOffset + // Field 2: ToExecutionAddress + if len(c.ToExecutionAddress) != 20 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.ToExecutionAddress...) - // Field (17) 'JustificationBits' - if cap(b.JustificationBits) == 0 { - b.JustificationBits = make([]byte, 0, len(buf[2687256:2687257])) - } - b.JustificationBits = append(b.JustificationBits, buf[2687256:2687257]...) + return dst, err +} - // Field (18) 'PreviousJustifiedCheckpoint' - if b.PreviousJustifiedCheckpoint == nil { - b.PreviousJustifiedCheckpoint = new(Checkpoint) - } - if err = b.PreviousJustifiedCheckpoint.UnmarshalSSZ(buf[2687257:2687297]); err != nil { - return err +func (c *BLSToExecutionChange) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 76 { + return ssz.ErrSize } - // Field (19) 'CurrentJustifiedCheckpoint' - if b.CurrentJustifiedCheckpoint == nil { - b.CurrentJustifiedCheckpoint = new(Checkpoint) - } - if err = b.CurrentJustifiedCheckpoint.UnmarshalSSZ(buf[2687297:2687337]); err != nil { - return err - } + sszSlice0 := buf[0:8] // c.ValidatorIndex + sszSlice1 := buf[8:56] // c.FromBlsPubkey + sszSlice2 := buf[56:76] // c.ToExecutionAddress - // Field (20) 'FinalizedCheckpoint' - if b.FinalizedCheckpoint == nil { - b.FinalizedCheckpoint = new(Checkpoint) - } - if err = b.FinalizedCheckpoint.UnmarshalSSZ(buf[2687337:2687377]); err != nil { - return err + // Field 0: ValidatorIndex + if err = c.ValidatorIndex.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("ValidatorIndex: %w", err) } - // Offset (21) 'InactivityScores' - if o21 = ssz.ReadOffset(buf[2687377:2687381]); o21 > size || o16 > o21 { - return ssz.ErrOffset - } + // Field 1: FromBlsPubkey + c.FromBlsPubkey = make([]byte, 0, 48) + c.FromBlsPubkey = append(c.FromBlsPubkey, sszSlice1...) - // Field (22) 'CurrentSyncCommittee' - if b.CurrentSyncCommittee == nil { - b.CurrentSyncCommittee = new(SyncCommittee) - } - if err = b.CurrentSyncCommittee.UnmarshalSSZ(buf[2687381:2712005]); err != nil { - return err + // Field 2: ToExecutionAddress + c.ToExecutionAddress = make([]byte, 0, 20) + c.ToExecutionAddress = append(c.ToExecutionAddress, sszSlice2...) + return err +} + +func (c *BLSToExecutionChange) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (23) 'NextSyncCommittee' - if b.NextSyncCommittee == nil { - b.NextSyncCommittee = new(SyncCommittee) +func (c *BLSToExecutionChange) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: ValidatorIndex + if err := c.ValidatorIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ValidatorIndex: %w", err) } - if err = b.NextSyncCommittee.UnmarshalSSZ(buf[2712005:2736629]); err != nil { - return err + // Field 1: FromBlsPubkey + if len(c.FromBlsPubkey) != 48 { + return ssz.ErrBytesLength } + hh.PutBytes(c.FromBlsPubkey) + // Field 2: ToExecutionAddress + if len(c.ToExecutionAddress) != 20 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ToExecutionAddress) + hh.Merkleize(indx) + return nil +} - // Offset (24) 'LatestExecutionPayloadHeader' - if o24 = ssz.ReadOffset(buf[2736629:2736633]); o24 > size || o21 > o24 { - return ssz.ErrOffset +func (c *BuilderBidCapella) SizeSSZ() int { + size := 84 + if c.Header == nil { + c.Header = new(v1.ExecutionPayloadHeaderCapella) } + size += c.Header.SizeSSZ() + return size +} - // Field (25) 'NextWithdrawalIndex' - b.NextWithdrawalIndex = ssz.UnmarshallUint[uint64](buf[2736633:2736641]) +func (c *BuilderBidCapella) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (26) 'NextWithdrawalValidatorIndex' - b.NextWithdrawalValidatorIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[2736641:2736649]) +func (c *BuilderBidCapella) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 84 - // Offset (27) 'HistoricalSummaries' - if o27 = ssz.ReadOffset(buf[2736649:2736653]); o27 > size || o24 > o27 { - return ssz.ErrOffset + // Field 0: Header + if c.Header == nil { + c.Header = new(v1.ExecutionPayloadHeaderCapella) } + dst = ssz.WriteOffset(dst, offset) + offset += c.Header.SizeSSZ() - // 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 1: Value + if len(c.Value) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.Value...) - // Field (9) 'Eth1DataVotes' - { - buf = tail[o9:o11] - num, err := ssz.DivideInt2(len(buf), 72, 2048) - if err != nil { - return err - } - b.Eth1DataVotes = make([]*Eth1Data, num) - for ii := 0; ii < num; ii++ { - if b.Eth1DataVotes[ii] == nil { - b.Eth1DataVotes[ii] = new(Eth1Data) - } - if err = b.Eth1DataVotes[ii].UnmarshalSSZ(buf[ii*72 : (ii+1)*72]); err != nil { - return err - } - } + // Field 2: Pubkey + if len(c.Pubkey) != 48 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.Pubkey...) - // Field (11) 'Validators' - { - buf = tail[o11:o12] - num, err := ssz.DivideInt2(len(buf), 121, 1099511627776) - if err != nil { - return err - } - b.Validators = make([]*Validator, num) - for ii := 0; ii < num; ii++ { - if b.Validators[ii] == nil { - b.Validators[ii] = new(Validator) - } - if err = b.Validators[ii].UnmarshalSSZ(buf[ii*121 : (ii+1)*121]); err != nil { - return err - } - } + // Field 0: Header + if dst, err = c.Header.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Header: %w", err) } + return dst, err +} - // Field (12) 'Balances' - { - buf = tail[o12:o15] - num, err := ssz.DivideInt2(len(buf), 8, 1099511627776) - if err != nil { - return err - } - b.Balances = ssz.ExtendUint(b.Balances, num) - for ii := 0; ii < num; ii++ { - b.Balances[ii] = ssz.UnmarshallUint[uint64](buf[ii*8 : (ii+1)*8]) - } +func (c *BuilderBidCapella) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 84 { + return ssz.ErrSize } - // 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...) - } + sszSlice1 := buf[4:36] // c.Value + sszSlice2 := buf[36:84] // c.Pubkey - // 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...) + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Header + if sszVarOffset0 != 84 { + return ssz.ErrInvalidVariableOffset } - - // Field (21) 'InactivityScores' - { - buf = tail[o21:o24] - num, err := ssz.DivideInt2(len(buf), 8, 1099511627776) - if err != nil { - return err - } - b.InactivityScores = ssz.ExtendUint(b.InactivityScores, num) - for ii := 0; ii < num; ii++ { - b.InactivityScores[ii] = ssz.UnmarshallUint[uint64](buf[ii*8 : (ii+1)*8]) - } + if sszVarOffset0 > size { + return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:] // c.Header - // Field (24) 'LatestExecutionPayloadHeader' - { - buf = tail[o24:o27] - if b.LatestExecutionPayloadHeader == nil { - b.LatestExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderCapella) - } - if err = b.LatestExecutionPayloadHeader.UnmarshalSSZ(buf); err != nil { - return err - } + // Field 0: Header + c.Header = new(v1.ExecutionPayloadHeaderCapella) + if err = c.Header.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Header: %w", err) } - // Field (27) 'HistoricalSummaries' - { - buf = tail[o27:] - num, err := ssz.DivideInt2(len(buf), 64, 16777216) - if err != nil { - return err - } - b.HistoricalSummaries = make([]*HistoricalSummary, num) - for ii := 0; ii < num; ii++ { - if b.HistoricalSummaries[ii] == nil { - b.HistoricalSummaries[ii] = new(HistoricalSummary) - } - if err = b.HistoricalSummaries[ii].UnmarshalSSZ(buf[ii*64 : (ii+1)*64]); err != nil { - return err - } - } - } + // Field 1: Value + c.Value = make([]byte, 0, 32) + c.Value = append(c.Value, sszSlice1...) + + // Field 2: Pubkey + c.Pubkey = make([]byte, 0, 48) + c.Pubkey = append(c.Pubkey, sszSlice2...) return err } -// SizeSSZ returns the ssz encoded size in bytes for the BeaconStateCapella object -func (b *BeaconStateCapella) SizeSSZ() (size int) { - size = 2736653 - - // Field (7) 'HistoricalRoots' - size += len(b.HistoricalRoots) * 32 - - // Field (9) 'Eth1DataVotes' - size += len(b.Eth1DataVotes) * 72 +func (c *BuilderBidCapella) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (11) 'Validators' - size += len(b.Validators) * 121 +func (c *BuilderBidCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Header + if err := c.Header.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Header: %w", err) + } + // Field 1: Value + if len(c.Value) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Value) + // Field 2: Pubkey + if len(c.Pubkey) != 48 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Pubkey) + hh.Merkleize(indx) + return nil +} - // Field (12) 'Balances' - size += len(b.Balances) * 8 +func (c *HistoricalSummary) SizeSSZ() int { + size := 64 - // Field (15) 'PreviousEpochParticipation' - size += len(b.PreviousEpochParticipation) + return size +} - // Field (16) 'CurrentEpochParticipation' - size += len(b.CurrentEpochParticipation) +func (c *HistoricalSummary) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (21) 'InactivityScores' - size += len(b.InactivityScores) * 8 +func (c *HistoricalSummary) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (24) 'LatestExecutionPayloadHeader' - if b.LatestExecutionPayloadHeader == nil { - b.LatestExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderCapella) + // Field 0: BlockSummaryRoot + if len(c.BlockSummaryRoot) != 32 { + return nil, ssz.ErrBytesLength } - size += b.LatestExecutionPayloadHeader.SizeSSZ() - - // Field (27) 'HistoricalSummaries' - size += len(b.HistoricalSummaries) * 64 + dst = append(dst, c.BlockSummaryRoot...) - return -} + // Field 1: StateSummaryRoot + if len(c.StateSummaryRoot) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.StateSummaryRoot...) -// HashTreeRoot ssz hashes the BeaconStateCapella object -func (b *BeaconStateCapella) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) + return dst, err } -// HashTreeRootWith ssz hashes the BeaconStateCapella object with a hasher -func (b *BeaconStateCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() +func (c *HistoricalSummary) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 64 { + return ssz.ErrSize + } - // Field (0) 'GenesisTime' - ssz.PutUint(hh, b.GenesisTime) + sszSlice0 := buf[0:32] // c.BlockSummaryRoot + sszSlice1 := buf[32:64] // c.StateSummaryRoot - // Field (1) 'GenesisValidatorsRoot' - if size := len(b.GenesisValidatorsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.GenesisValidatorsRoot", size, 32) - return - } - hh.PutBytes(b.GenesisValidatorsRoot) + // Field 0: BlockSummaryRoot + c.BlockSummaryRoot = make([]byte, 0, 32) + c.BlockSummaryRoot = append(c.BlockSummaryRoot, sszSlice0...) - // Field (2) 'Slot' - ssz.PutUint(hh, b.Slot) + // Field 1: StateSummaryRoot + c.StateSummaryRoot = make([]byte, 0, 32) + c.StateSummaryRoot = append(c.StateSummaryRoot, sszSlice1...) + return err +} - // Field (3) 'Fork' - if err = b.Fork.HashTreeRootWith(hh); err != nil { - return +func (c *HistoricalSummary) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (4) 'LatestBlockHeader' - if err = b.LatestBlockHeader.HashTreeRootWith(hh); err != nil { - return +func (c *HistoricalSummary) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: BlockSummaryRoot + if len(c.BlockSummaryRoot) != 32 { + return ssz.ErrBytesLength } - - // Field (5) 'BlockRoots' - { - if size := len(b.BlockRoots); size != 8192 { - err = ssz.ErrVectorLengthFn("--.BlockRoots", size, 8192) - return - } - subIndx := hh.Index() - for _, i := range b.BlockRoots { - if len(i) != 32 { - err = ssz.ErrBytesLength - return - } - hh.Append(i) - } - hh.Merkleize(subIndx) + hh.PutBytes(c.BlockSummaryRoot) + // Field 1: StateSummaryRoot + if len(c.StateSummaryRoot) != 32 { + return ssz.ErrBytesLength } + hh.PutBytes(c.StateSummaryRoot) + hh.Merkleize(indx) + return nil +} - // Field (6) 'StateRoots' - { - if size := len(b.StateRoots); size != 8192 { - err = ssz.ErrVectorLengthFn("--.StateRoots", size, 8192) - return - } - subIndx := hh.Index() - for _, i := range b.StateRoots { - if len(i) != 32 { - err = ssz.ErrBytesLength - return - } - hh.Append(i) - } - hh.Merkleize(subIndx) +func (c *LightClientBootstrapCapella) SizeSSZ() int { + size := 24788 + if c.Header == nil { + c.Header = new(LightClientHeaderCapella) } + size += c.Header.SizeSSZ() + return size +} - // Field (7) 'HistoricalRoots' - { - if size := len(b.HistoricalRoots); size > 16777216 { - err = ssz.ErrListTooBigFn("--.HistoricalRoots", size, 16777216) - return - } - subIndx := hh.Index() - for _, i := range b.HistoricalRoots { - if len(i) != 32 { - err = ssz.ErrBytesLength - return - } - hh.Append(i) - } +func (c *LightClientBootstrapCapella) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - numItems := uint64(len(b.HistoricalRoots)) - hh.MerkleizeWithMixin(subIndx, numItems, 16777216) - } +func (c *LightClientBootstrapCapella) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 24788 - // Field (8) 'Eth1Data' - if err = b.Eth1Data.HashTreeRootWith(hh); err != nil { - return + // Field 0: Header + if c.Header == nil { + c.Header = new(LightClientHeaderCapella) } + dst = ssz.WriteOffset(dst, offset) + offset += c.Header.SizeSSZ() - // 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 1: CurrentSyncCommittee + if c.CurrentSyncCommittee == nil { + c.CurrentSyncCommittee = new(SyncCommittee) } - - // Field (10) 'Eth1DepositIndex' - ssz.PutUint(hh, 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) + if dst, err = c.CurrentSyncCommittee.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("CurrentSyncCommittee: %w", err) } - // Field (12) 'Balances' - { - if size := len(b.Balances); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.Balances", size, 1099511627776) - return - } - subIndx := hh.Index() - for _, i := range b.Balances { - ssz.AppendUint(hh, i) - } - hh.FillUpTo32() - - numItems := uint64(len(b.Balances)) - hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(1099511627776, numItems, 8)) + // Field 2: CurrentSyncCommitteeBranch + if len(c.CurrentSyncCommitteeBranch) != 5 { + return nil, ssz.ErrBytesLength } - - // Field (13) 'RandaoMixes' - { - if size := len(b.RandaoMixes); size != 65536 { - err = ssz.ErrVectorLengthFn("--.RandaoMixes", size, 65536) - return + for _, o := range c.CurrentSyncCommitteeBranch { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } - subIndx := hh.Index() - for _, i := range b.RandaoMixes { - if len(i) != 32 { - err = ssz.ErrBytesLength - return - } - hh.Append(i) - } - hh.Merkleize(subIndx) + dst = append(dst, o...) } - // Field (14) 'Slashings' - { - if size := len(b.Slashings); size != 8192 { - err = ssz.ErrVectorLengthFn("--.Slashings", size, 8192) - return - } - subIndx := hh.Index() - for _, i := range b.Slashings { - ssz.AppendUint(hh, i) - } - hh.Merkleize(subIndx) + // Field 0: Header + if dst, err = c.Header.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Header: %w", err) } + return dst, err +} - // Field (15) 'PreviousEpochParticipation' - { - elemIndx := hh.Index() - byteLen := uint64(len(b.PreviousEpochParticipation)) - if byteLen > 1099511627776 { - err = ssz.ErrIncorrectListSize - return - } - hh.AppendBytes32(b.PreviousEpochParticipation) - hh.MerkleizeWithMixin(elemIndx, byteLen, (1099511627776+31)/32) +func (c *LightClientBootstrapCapella) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 24788 { + return ssz.ErrSize } - // Field (16) 'CurrentEpochParticipation' - { - elemIndx := hh.Index() - byteLen := uint64(len(b.CurrentEpochParticipation)) - if byteLen > 1099511627776 { - err = ssz.ErrIncorrectListSize - return - } - hh.AppendBytes32(b.CurrentEpochParticipation) - hh.MerkleizeWithMixin(elemIndx, byteLen, (1099511627776+31)/32) - } + sszSlice1 := buf[4:24628] // c.CurrentSyncCommittee + sszSlice2 := buf[24628:24788] // c.CurrentSyncCommitteeBranch - // Field (17) 'JustificationBits' - if size := len(b.JustificationBits); size != 1 { - err = ssz.ErrBytesLengthFn("--.JustificationBits", size, 1) - return + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Header + if sszVarOffset0 != 24788 { + return ssz.ErrInvalidVariableOffset } - hh.PutBytes(b.JustificationBits) - - // Field (18) 'PreviousJustifiedCheckpoint' - if err = b.PreviousJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { - return + if sszVarOffset0 > size { + return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:] // c.Header - // Field (19) 'CurrentJustifiedCheckpoint' - if err = b.CurrentJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { - return + // Field 0: Header + c.Header = new(LightClientHeaderCapella) + if err = c.Header.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Header: %w", err) } - // Field (20) 'FinalizedCheckpoint' - if err = b.FinalizedCheckpoint.HashTreeRootWith(hh); err != nil { - return + // Field 1: CurrentSyncCommittee + c.CurrentSyncCommittee = new(SyncCommittee) + if err = c.CurrentSyncCommittee.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("CurrentSyncCommittee: %w", err) } - // Field (21) 'InactivityScores' + // Field 2: CurrentSyncCommitteeBranch { - if size := len(b.InactivityScores); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.InactivityScores", size, 1099511627776) - return - } - subIndx := hh.Index() - for _, i := range b.InactivityScores { - ssz.AppendUint(hh, i) - } - hh.FillUpTo32() + c.CurrentSyncCommitteeBranch = make([][]byte, 5) + for i := 0; i < 5; i++ { + var tmp []byte - numItems := uint64(len(b.InactivityScores)) - hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(1099511627776, numItems, 8)) + tmpSlice := sszSlice2[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.CurrentSyncCommitteeBranch[i] = tmp + } } + return err +} - // Field (22) 'CurrentSyncCommittee' - if err = b.CurrentSyncCommittee.HashTreeRootWith(hh); err != nil { - return +func (c *LightClientBootstrapCapella) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (23) 'NextSyncCommittee' - if err = b.NextSyncCommittee.HashTreeRootWith(hh); err != nil { - return +func (c *LightClientBootstrapCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Header + if err := c.Header.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Header: %w", err) } - - // Field (24) 'LatestExecutionPayloadHeader' - if err = b.LatestExecutionPayloadHeader.HashTreeRootWith(hh); err != nil { - return + // Field 1: CurrentSyncCommittee + if err := c.CurrentSyncCommittee.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("CurrentSyncCommittee: %w", err) } - - // Field (25) 'NextWithdrawalIndex' - ssz.PutUint(hh, b.NextWithdrawalIndex) - - // Field (26) 'NextWithdrawalValidatorIndex' - ssz.PutUint(hh, b.NextWithdrawalValidatorIndex) - - // Field (27) 'HistoricalSummaries' + // Field 2: CurrentSyncCommitteeBranch { + if len(c.CurrentSyncCommitteeBranch) != 5 { + return ssz.ErrVectorLength + } 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 + for _, o := range c.CurrentSyncCommitteeBranch { + if len(o) != 32 { + return ssz.ErrBytesLength } + hh.Append(o) } - hh.MerkleizeWithMixin(subIndx, num, 16777216) + hh.Merkleize(subIndx) } - hh.Merkleize(indx) - return + return nil +} + +func (c *LightClientFinalityUpdateCapella) SizeSSZ() int { + size := 368 + if c.AttestedHeader == nil { + c.AttestedHeader = new(LightClientHeaderCapella) + } + size += c.AttestedHeader.SizeSSZ() + if c.FinalizedHeader == nil { + c.FinalizedHeader = new(LightClientHeaderCapella) + } + size += c.FinalizedHeader.SizeSSZ() + return size } -// MarshalSSZ ssz marshals the LightClientBootstrapCapella object -func (l *LightClientBootstrapCapella) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(l) +func (c *LightClientFinalityUpdateCapella) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the LightClientBootstrapCapella object to a target array -func (l *LightClientBootstrapCapella) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(24788) +func (c *LightClientFinalityUpdateCapella) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 368 - // Offset (0) 'Header' + // Field 0: AttestedHeader + if c.AttestedHeader == nil { + c.AttestedHeader = new(LightClientHeaderCapella) + } dst = ssz.WriteOffset(dst, offset) - if l.Header == nil { - l.Header = new(LightClientHeaderCapella) + offset += c.AttestedHeader.SizeSSZ() + + // Field 1: FinalizedHeader + if c.FinalizedHeader == nil { + c.FinalizedHeader = new(LightClientHeaderCapella) + } + dst = ssz.WriteOffset(dst, offset) + offset += c.FinalizedHeader.SizeSSZ() + + // Field 2: FinalityBranch + if len(c.FinalityBranch) != 6 { + return nil, ssz.ErrBytesLength + } + for _, o := range c.FinalityBranch { + if len(o) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) } - offset += l.Header.SizeSSZ() - // Field (1) 'CurrentSyncCommittee' - if l.CurrentSyncCommittee == nil { - l.CurrentSyncCommittee = new(SyncCommittee) + // Field 3: SyncAggregate + if c.SyncAggregate == nil { + c.SyncAggregate = new(SyncAggregate) } - if dst, err = l.CurrentSyncCommittee.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.SyncAggregate.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SyncAggregate: %w", err) } - // Field (2) 'CurrentSyncCommitteeBranch' - if size := len(l.CurrentSyncCommitteeBranch); size != 5 { - err = ssz.ErrVectorLengthFn("--.CurrentSyncCommitteeBranch", size, 5) - return - } - for ii := 0; ii < 5; ii++ { - if size := len(l.CurrentSyncCommitteeBranch[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.CurrentSyncCommitteeBranch[ii]", size, 32) - return - } - dst = append(dst, l.CurrentSyncCommitteeBranch[ii]...) + // Field 4: SignatureSlot + if dst, err = c.SignatureSlot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SignatureSlot: %w", err) } - // Field (0) 'Header' - if dst, err = l.Header.MarshalSSZTo(dst); err != nil { - return + // Field 0: AttestedHeader + if dst, err = c.AttestedHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("AttestedHeader: %w", err) } - return + // Field 1: FinalizedHeader + if dst, err = c.FinalizedHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("FinalizedHeader: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the LightClientBootstrapCapella object -func (l *LightClientBootstrapCapella) UnmarshalSSZ(buf []byte) error { +func (c *LightClientFinalityUpdateCapella) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 24788 { + if size < 368 { return ssz.ErrSize } - tail := buf - var o0 uint64 + sszSlice2 := buf[8:200] // c.FinalityBranch + sszSlice3 := buf[200:360] // c.SyncAggregate + sszSlice4 := buf[360:368] // c.SignatureSlot - // Offset (0) 'Header' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.AttestedHeader + if sszVarOffset0 != 368 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset0 > size { return ssz.ErrOffset } - - if o0 != 24788 { - return ssz.ErrInvalidVariableOffset + sszVarOffset1 := ssz.ReadOffset(buf[4:8]) // c.FinalizedHeader + if sszVarOffset1 > size || sszVarOffset1 < sszVarOffset0 { + return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:sszVarOffset1] // c.AttestedHeader + sszSlice1 := buf[sszVarOffset1:] // c.FinalizedHeader - // Field (1) 'CurrentSyncCommittee' - if l.CurrentSyncCommittee == nil { - l.CurrentSyncCommittee = new(SyncCommittee) - } - if err = l.CurrentSyncCommittee.UnmarshalSSZ(buf[4:24628]); err != nil { - return err + // Field 0: AttestedHeader + c.AttestedHeader = new(LightClientHeaderCapella) + if err = c.AttestedHeader.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("AttestedHeader: %w", err) } - // Field (2) 'CurrentSyncCommitteeBranch' - l.CurrentSyncCommitteeBranch = make([][]byte, 5) - for ii := 0; ii < 5; ii++ { - if cap(l.CurrentSyncCommitteeBranch[ii]) == 0 { - l.CurrentSyncCommitteeBranch[ii] = make([]byte, 0, len(buf[24628:24788][ii*32:(ii+1)*32])) - } - l.CurrentSyncCommitteeBranch[ii] = append(l.CurrentSyncCommitteeBranch[ii], buf[24628:24788][ii*32:(ii+1)*32]...) + // Field 1: FinalizedHeader + c.FinalizedHeader = new(LightClientHeaderCapella) + if err = c.FinalizedHeader.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("FinalizedHeader: %w", err) } - // Field (0) 'Header' + // Field 2: FinalityBranch { - buf = tail[o0:] - if l.Header == nil { - l.Header = new(LightClientHeaderCapella) - } - if err = l.Header.UnmarshalSSZ(buf); err != nil { - return err + c.FinalityBranch = make([][]byte, 6) + for i := 0; i < 6; i++ { + var tmp []byte + + tmpSlice := sszSlice2[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.FinalityBranch[i] = tmp } } - return err -} -// SizeSSZ returns the ssz encoded size in bytes for the LightClientBootstrapCapella object -func (l *LightClientBootstrapCapella) SizeSSZ() (size int) { - size = 24788 - - // Field (0) 'Header' - if l.Header == nil { - l.Header = new(LightClientHeaderCapella) + // Field 3: SyncAggregate + c.SyncAggregate = new(SyncAggregate) + if err = c.SyncAggregate.UnmarshalSSZ(sszSlice3); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) } - size += l.Header.SizeSSZ() - return + // Field 4: SignatureSlot + if err = c.SignatureSlot.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("SignatureSlot: %w", err) + } + return err } -// HashTreeRoot ssz hashes the LightClientBootstrapCapella object -func (l *LightClientBootstrapCapella) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(l) +func (c *LightClientFinalityUpdateCapella) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the LightClientBootstrapCapella object with a hasher -func (l *LightClientBootstrapCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *LightClientFinalityUpdateCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Header' - if err = l.Header.HashTreeRootWith(hh); err != nil { - return + // Field 0: AttestedHeader + if err := c.AttestedHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("AttestedHeader: %w", err) } - - // Field (1) 'CurrentSyncCommittee' - if err = l.CurrentSyncCommittee.HashTreeRootWith(hh); err != nil { - return + // Field 1: FinalizedHeader + if err := c.FinalizedHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("FinalizedHeader: %w", err) } - - // Field (2) 'CurrentSyncCommitteeBranch' + // Field 2: FinalityBranch { - if size := len(l.CurrentSyncCommitteeBranch); size != 5 { - err = ssz.ErrVectorLengthFn("--.CurrentSyncCommitteeBranch", size, 5) - return + if len(c.FinalityBranch) != 6 { + return ssz.ErrVectorLength } subIndx := hh.Index() - for _, i := range l.CurrentSyncCommitteeBranch { - if len(i) != 32 { - err = ssz.ErrBytesLength - return + for _, o := range c.FinalityBranch { + if len(o) != 32 { + return ssz.ErrBytesLength } - hh.Append(i) + hh.Append(o) } hh.Merkleize(subIndx) } - + // Field 3: SyncAggregate + if err := c.SyncAggregate.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) + } + // Field 4: SignatureSlot + if err := c.SignatureSlot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SignatureSlot: %w", err) + } hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the LightClientUpdateCapella object -func (l *LightClientUpdateCapella) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(l) +func (c *LightClientHeaderCapella) SizeSSZ() int { + size := 244 + if c.Execution == nil { + c.Execution = new(v1.ExecutionPayloadHeaderCapella) + } + size += c.Execution.SizeSSZ() + return size } -// MarshalSSZTo ssz marshals the LightClientUpdateCapella object to a target array -func (l *LightClientUpdateCapella) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(25152) +func (c *LightClientHeaderCapella) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Offset (0) 'AttestedHeader' - dst = ssz.WriteOffset(dst, offset) - if l.AttestedHeader == nil { - l.AttestedHeader = new(LightClientHeaderCapella) - } - offset += l.AttestedHeader.SizeSSZ() +func (c *LightClientHeaderCapella) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 244 - // Field (1) 'NextSyncCommittee' - if l.NextSyncCommittee == nil { - l.NextSyncCommittee = new(SyncCommittee) + // Field 0: Beacon + if c.Beacon == nil { + c.Beacon = new(BeaconBlockHeader) } - if dst, err = l.NextSyncCommittee.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.Beacon.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Beacon: %w", err) } - // Field (2) 'NextSyncCommitteeBranch' - if size := len(l.NextSyncCommitteeBranch); size != 5 { - err = ssz.ErrVectorLengthFn("--.NextSyncCommitteeBranch", size, 5) - return - } - for ii := 0; ii < 5; ii++ { - if size := len(l.NextSyncCommitteeBranch[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.NextSyncCommitteeBranch[ii]", size, 32) - return - } - dst = append(dst, l.NextSyncCommitteeBranch[ii]...) + // Field 1: Execution + if c.Execution == nil { + c.Execution = new(v1.ExecutionPayloadHeaderCapella) } - - // Offset (3) 'FinalizedHeader' dst = ssz.WriteOffset(dst, offset) - if l.FinalizedHeader == nil { - l.FinalizedHeader = new(LightClientHeaderCapella) - } - offset += l.FinalizedHeader.SizeSSZ() + offset += c.Execution.SizeSSZ() - // Field (4) 'FinalityBranch' - if size := len(l.FinalityBranch); size != 6 { - err = ssz.ErrVectorLengthFn("--.FinalityBranch", size, 6) - return + // Field 2: ExecutionBranch + if len(c.ExecutionBranch) != 4 { + return nil, ssz.ErrBytesLength } - for ii := 0; ii < 6; ii++ { - if size := len(l.FinalityBranch[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.FinalityBranch[ii]", size, 32) - return + for _, o := range c.ExecutionBranch { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, l.FinalityBranch[ii]...) - } - - // Field (5) 'SyncAggregate' - if l.SyncAggregate == nil { - l.SyncAggregate = new(SyncAggregate) - } - if dst, err = l.SyncAggregate.MarshalSSZTo(dst); err != nil { - return - } - - // Field (6) 'SignatureSlot' - dst = ssz.MarshalUint(dst, l.SignatureSlot) - - // Field (0) 'AttestedHeader' - if dst, err = l.AttestedHeader.MarshalSSZTo(dst); err != nil { - return + dst = append(dst, o...) } - // Field (3) 'FinalizedHeader' - if dst, err = l.FinalizedHeader.MarshalSSZTo(dst); err != nil { - return + // Field 1: Execution + if dst, err = c.Execution.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Execution: %w", err) } - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the LightClientUpdateCapella object -func (l *LightClientUpdateCapella) UnmarshalSSZ(buf []byte) error { +func (c *LightClientHeaderCapella) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 25152 { + if size < 244 { return ssz.ErrSize } - tail := buf - var o0, o3 uint64 + sszSlice0 := buf[0:112] // c.Beacon + sszSlice2 := buf[116:244] // c.ExecutionBranch - // Offset (0) 'AttestedHeader' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { + sszVarOffset1 := ssz.ReadOffset(buf[112:116]) // c.Execution + if sszVarOffset1 != 244 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset1 > size { return ssz.ErrOffset } + sszSlice1 := buf[sszVarOffset1:] // c.Execution - if o0 != 25152 { - return ssz.ErrInvalidVariableOffset + // Field 0: Beacon + c.Beacon = new(BeaconBlockHeader) + if err = c.Beacon.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Beacon: %w", err) } - // Field (1) 'NextSyncCommittee' - if l.NextSyncCommittee == nil { - l.NextSyncCommittee = new(SyncCommittee) - } - if err = l.NextSyncCommittee.UnmarshalSSZ(buf[4:24628]); err != nil { - return err + // Field 1: Execution + c.Execution = new(v1.ExecutionPayloadHeaderCapella) + if err = c.Execution.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Execution: %w", err) } - // Field (2) 'NextSyncCommitteeBranch' - l.NextSyncCommitteeBranch = make([][]byte, 5) - for ii := 0; ii < 5; ii++ { - if cap(l.NextSyncCommitteeBranch[ii]) == 0 { - l.NextSyncCommitteeBranch[ii] = make([]byte, 0, len(buf[24628:24788][ii*32:(ii+1)*32])) - } - l.NextSyncCommitteeBranch[ii] = append(l.NextSyncCommitteeBranch[ii], buf[24628:24788][ii*32:(ii+1)*32]...) - } + // Field 2: ExecutionBranch + { + c.ExecutionBranch = make([][]byte, 4) + for i := 0; i < 4; i++ { + var tmp []byte - // Offset (3) 'FinalizedHeader' - if o3 = ssz.ReadOffset(buf[24788:24792]); o3 > size || o0 > o3 { - return ssz.ErrOffset + tmpSlice := sszSlice2[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.ExecutionBranch[i] = tmp + } } + return err +} - // Field (4) 'FinalityBranch' - l.FinalityBranch = make([][]byte, 6) - for ii := 0; ii < 6; ii++ { - if cap(l.FinalityBranch[ii]) == 0 { - l.FinalityBranch[ii] = make([]byte, 0, len(buf[24792:24984][ii*32:(ii+1)*32])) - } - l.FinalityBranch[ii] = append(l.FinalityBranch[ii], buf[24792:24984][ii*32:(ii+1)*32]...) +func (c *LightClientHeaderCapella) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (5) 'SyncAggregate' - if l.SyncAggregate == nil { - l.SyncAggregate = new(SyncAggregate) +func (c *LightClientHeaderCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Beacon + if err := c.Beacon.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Beacon: %w", err) } - if err = l.SyncAggregate.UnmarshalSSZ(buf[24984:25144]); err != nil { - return err + // Field 1: Execution + if err := c.Execution.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Execution: %w", err) } - - // Field (6) 'SignatureSlot' - l.SignatureSlot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[25144:25152]) - - // Field (0) 'AttestedHeader' + // Field 2: ExecutionBranch { - buf = tail[o0:o3] - if l.AttestedHeader == nil { - l.AttestedHeader = new(LightClientHeaderCapella) + if len(c.ExecutionBranch) != 4 { + return ssz.ErrVectorLength } - if err = l.AttestedHeader.UnmarshalSSZ(buf); err != nil { - return err + subIndx := hh.Index() + for _, o := range c.ExecutionBranch { + if len(o) != 32 { + return ssz.ErrBytesLength + } + hh.Append(o) } + hh.Merkleize(subIndx) } + hh.Merkleize(indx) + return nil +} - // Field (3) 'FinalizedHeader' - { - buf = tail[o3:] - if l.FinalizedHeader == nil { - l.FinalizedHeader = new(LightClientHeaderCapella) - } - if err = l.FinalizedHeader.UnmarshalSSZ(buf); err != nil { - return err - } +func (c *LightClientOptimisticUpdateCapella) SizeSSZ() int { + size := 172 + if c.AttestedHeader == nil { + c.AttestedHeader = new(LightClientHeaderCapella) } - return err + size += c.AttestedHeader.SizeSSZ() + return size +} + +func (c *LightClientOptimisticUpdateCapella) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// SizeSSZ returns the ssz encoded size in bytes for the LightClientUpdateCapella object -func (l *LightClientUpdateCapella) SizeSSZ() (size int) { - size = 25152 +func (c *LightClientOptimisticUpdateCapella) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 172 - // Field (0) 'AttestedHeader' - if l.AttestedHeader == nil { - l.AttestedHeader = new(LightClientHeaderCapella) + // Field 0: AttestedHeader + if c.AttestedHeader == nil { + c.AttestedHeader = new(LightClientHeaderCapella) } - size += l.AttestedHeader.SizeSSZ() + dst = ssz.WriteOffset(dst, offset) + offset += c.AttestedHeader.SizeSSZ() - // Field (3) 'FinalizedHeader' - if l.FinalizedHeader == nil { - l.FinalizedHeader = new(LightClientHeaderCapella) + // Field 1: SyncAggregate + if c.SyncAggregate == nil { + c.SyncAggregate = new(SyncAggregate) + } + if dst, err = c.SyncAggregate.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SyncAggregate: %w", err) } - size += l.FinalizedHeader.SizeSSZ() - return -} + // Field 2: SignatureSlot + if dst, err = c.SignatureSlot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SignatureSlot: %w", err) + } -// HashTreeRoot ssz hashes the LightClientUpdateCapella object -func (l *LightClientUpdateCapella) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(l) + // Field 0: AttestedHeader + if dst, err = c.AttestedHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("AttestedHeader: %w", err) + } + return dst, err } -// HashTreeRootWith ssz hashes the LightClientUpdateCapella object with a hasher -func (l *LightClientUpdateCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'AttestedHeader' - if err = l.AttestedHeader.HashTreeRootWith(hh); err != nil { - return +func (c *LightClientOptimisticUpdateCapella) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 172 { + return ssz.ErrSize } - // Field (1) 'NextSyncCommittee' - if err = l.NextSyncCommittee.HashTreeRootWith(hh); err != nil { - return - } + sszSlice1 := buf[4:164] // c.SyncAggregate + sszSlice2 := buf[164:172] // c.SignatureSlot - // Field (2) 'NextSyncCommitteeBranch' - { - if size := len(l.NextSyncCommitteeBranch); size != 5 { - err = ssz.ErrVectorLengthFn("--.NextSyncCommitteeBranch", size, 5) - return - } - subIndx := hh.Index() - for _, i := range l.NextSyncCommitteeBranch { - if len(i) != 32 { - err = ssz.ErrBytesLength - return - } - hh.Append(i) - } - hh.Merkleize(subIndx) + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.AttestedHeader + if sszVarOffset0 != 172 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset0 > size { + return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:] // c.AttestedHeader - // Field (3) 'FinalizedHeader' - if err = l.FinalizedHeader.HashTreeRootWith(hh); err != nil { - return + // Field 0: AttestedHeader + c.AttestedHeader = new(LightClientHeaderCapella) + if err = c.AttestedHeader.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("AttestedHeader: %w", err) } - // Field (4) 'FinalityBranch' - { - if size := len(l.FinalityBranch); size != 6 { - err = ssz.ErrVectorLengthFn("--.FinalityBranch", size, 6) - return - } - subIndx := hh.Index() - for _, i := range l.FinalityBranch { - if len(i) != 32 { - err = ssz.ErrBytesLength - return - } - hh.Append(i) - } - hh.Merkleize(subIndx) + // Field 1: SyncAggregate + c.SyncAggregate = new(SyncAggregate) + if err = c.SyncAggregate.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) } - // Field (5) 'SyncAggregate' - if err = l.SyncAggregate.HashTreeRootWith(hh); err != nil { - return + // Field 2: SignatureSlot + if err = c.SignatureSlot.UnmarshalSSZ(sszSlice2); err != nil { + return fmt.Errorf("SignatureSlot: %w", err) } + return err +} - // Field (6) 'SignatureSlot' - ssz.PutUint(hh, l.SignatureSlot) +func (c *LightClientOptimisticUpdateCapella) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} +func (c *LightClientOptimisticUpdateCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: AttestedHeader + if err := c.AttestedHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("AttestedHeader: %w", err) + } + // Field 1: SyncAggregate + if err := c.SyncAggregate.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) + } + // Field 2: SignatureSlot + if err := c.SignatureSlot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SignatureSlot: %w", err) + } hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the LightClientFinalityUpdateCapella object -func (l *LightClientFinalityUpdateCapella) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(l) +func (c *LightClientUpdateCapella) SizeSSZ() int { + size := 25152 + if c.AttestedHeader == nil { + c.AttestedHeader = new(LightClientHeaderCapella) + } + size += c.AttestedHeader.SizeSSZ() + if c.FinalizedHeader == nil { + c.FinalizedHeader = new(LightClientHeaderCapella) + } + size += c.FinalizedHeader.SizeSSZ() + return size } -// MarshalSSZTo ssz marshals the LightClientFinalityUpdateCapella object to a target array -func (l *LightClientFinalityUpdateCapella) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(368) +func (c *LightClientUpdateCapella) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Offset (0) 'AttestedHeader' - dst = ssz.WriteOffset(dst, offset) - if l.AttestedHeader == nil { - l.AttestedHeader = new(LightClientHeaderCapella) - } - offset += l.AttestedHeader.SizeSSZ() +func (c *LightClientUpdateCapella) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 25152 - // Offset (1) 'FinalizedHeader' + // Field 0: AttestedHeader + if c.AttestedHeader == nil { + c.AttestedHeader = new(LightClientHeaderCapella) + } dst = ssz.WriteOffset(dst, offset) - if l.FinalizedHeader == nil { - l.FinalizedHeader = new(LightClientHeaderCapella) + offset += c.AttestedHeader.SizeSSZ() + + // Field 1: NextSyncCommittee + if c.NextSyncCommittee == nil { + c.NextSyncCommittee = new(SyncCommittee) + } + if dst, err = c.NextSyncCommittee.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("NextSyncCommittee: %w", err) } - offset += l.FinalizedHeader.SizeSSZ() - // Field (2) 'FinalityBranch' - if size := len(l.FinalityBranch); size != 6 { - err = ssz.ErrVectorLengthFn("--.FinalityBranch", size, 6) - return + // Field 2: NextSyncCommitteeBranch + if len(c.NextSyncCommitteeBranch) != 5 { + return nil, ssz.ErrBytesLength } - for ii := 0; ii < 6; ii++ { - if size := len(l.FinalityBranch[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.FinalityBranch[ii]", size, 32) - return + for _, o := range c.NextSyncCommitteeBranch { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, l.FinalityBranch[ii]...) + dst = append(dst, o...) } - // Field (3) 'SyncAggregate' - if l.SyncAggregate == nil { - l.SyncAggregate = new(SyncAggregate) + // Field 3: FinalizedHeader + if c.FinalizedHeader == nil { + c.FinalizedHeader = new(LightClientHeaderCapella) } - if dst, err = l.SyncAggregate.MarshalSSZTo(dst); err != nil { - return + dst = ssz.WriteOffset(dst, offset) + offset += c.FinalizedHeader.SizeSSZ() + + // Field 4: FinalityBranch + if len(c.FinalityBranch) != 6 { + return nil, ssz.ErrBytesLength + } + for _, o := range c.FinalityBranch { + if len(o) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) } - // Field (4) 'SignatureSlot' - dst = ssz.MarshalUint(dst, l.SignatureSlot) + // Field 5: SyncAggregate + if c.SyncAggregate == nil { + c.SyncAggregate = new(SyncAggregate) + } + if dst, err = c.SyncAggregate.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SyncAggregate: %w", err) + } - // Field (0) 'AttestedHeader' - if dst, err = l.AttestedHeader.MarshalSSZTo(dst); err != nil { - return + // Field 6: SignatureSlot + if dst, err = c.SignatureSlot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SignatureSlot: %w", err) } - // Field (1) 'FinalizedHeader' - if dst, err = l.FinalizedHeader.MarshalSSZTo(dst); err != nil { - return + // Field 0: AttestedHeader + if dst, err = c.AttestedHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("AttestedHeader: %w", err) } - return + // Field 3: FinalizedHeader + if dst, err = c.FinalizedHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("FinalizedHeader: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the LightClientFinalityUpdateCapella object -func (l *LightClientFinalityUpdateCapella) UnmarshalSSZ(buf []byte) error { +func (c *LightClientUpdateCapella) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 368 { + if size < 25152 { return ssz.ErrSize } - tail := buf - var o0, o1 uint64 - - // Offset (0) 'AttestedHeader' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } + sszSlice1 := buf[4:24628] // c.NextSyncCommittee + sszSlice2 := buf[24628:24788] // c.NextSyncCommitteeBranch + sszSlice4 := buf[24792:24984] // c.FinalityBranch + sszSlice5 := buf[24984:25144] // c.SyncAggregate + sszSlice6 := buf[25144:25152] // c.SignatureSlot - if o0 != 368 { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.AttestedHeader + if sszVarOffset0 != 25152 { return ssz.ErrInvalidVariableOffset } - - // Offset (1) 'FinalizedHeader' - if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 { + if sszVarOffset0 > size { return ssz.ErrOffset } - - // Field (2) 'FinalityBranch' - l.FinalityBranch = make([][]byte, 6) - for ii := 0; ii < 6; ii++ { - if cap(l.FinalityBranch[ii]) == 0 { - l.FinalityBranch[ii] = make([]byte, 0, len(buf[8:200][ii*32:(ii+1)*32])) - } - l.FinalityBranch[ii] = append(l.FinalityBranch[ii], buf[8:200][ii*32:(ii+1)*32]...) + sszVarOffset3 := ssz.ReadOffset(buf[24788:24792]) // c.FinalizedHeader + if sszVarOffset3 > size || sszVarOffset3 < sszVarOffset0 { + return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:sszVarOffset3] // c.AttestedHeader + sszSlice3 := buf[sszVarOffset3:] // c.FinalizedHeader - // Field (3) 'SyncAggregate' - if l.SyncAggregate == nil { - l.SyncAggregate = new(SyncAggregate) - } - if err = l.SyncAggregate.UnmarshalSSZ(buf[200:360]); err != nil { - return err + // Field 0: AttestedHeader + c.AttestedHeader = new(LightClientHeaderCapella) + if err = c.AttestedHeader.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("AttestedHeader: %w", err) } - // Field (4) 'SignatureSlot' - l.SignatureSlot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[360:368]) + // Field 1: NextSyncCommittee + c.NextSyncCommittee = new(SyncCommittee) + if err = c.NextSyncCommittee.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("NextSyncCommittee: %w", err) + } - // Field (0) 'AttestedHeader' + // Field 2: NextSyncCommitteeBranch { - buf = tail[o0:o1] - if l.AttestedHeader == nil { - l.AttestedHeader = new(LightClientHeaderCapella) - } - if err = l.AttestedHeader.UnmarshalSSZ(buf); err != nil { - return err + c.NextSyncCommitteeBranch = make([][]byte, 5) + for i := 0; i < 5; i++ { + var tmp []byte + + tmpSlice := sszSlice2[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.NextSyncCommitteeBranch[i] = tmp } } - // Field (1) 'FinalizedHeader' - { - buf = tail[o1:] - if l.FinalizedHeader == nil { - l.FinalizedHeader = new(LightClientHeaderCapella) - } - if err = l.FinalizedHeader.UnmarshalSSZ(buf); err != nil { - return err - } + // Field 3: FinalizedHeader + c.FinalizedHeader = new(LightClientHeaderCapella) + if err = c.FinalizedHeader.UnmarshalSSZ(sszSlice3); err != nil { + return fmt.Errorf("FinalizedHeader: %w", err) } - return err -} -// SizeSSZ returns the ssz encoded size in bytes for the LightClientFinalityUpdateCapella object -func (l *LightClientFinalityUpdateCapella) SizeSSZ() (size int) { - size = 368 + // Field 4: FinalityBranch + { + c.FinalityBranch = make([][]byte, 6) + for i := 0; i < 6; i++ { + var tmp []byte - // Field (0) 'AttestedHeader' - if l.AttestedHeader == nil { - l.AttestedHeader = new(LightClientHeaderCapella) + tmpSlice := sszSlice4[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.FinalityBranch[i] = tmp + } } - size += l.AttestedHeader.SizeSSZ() - // Field (1) 'FinalizedHeader' - if l.FinalizedHeader == nil { - l.FinalizedHeader = new(LightClientHeaderCapella) + // Field 5: SyncAggregate + c.SyncAggregate = new(SyncAggregate) + if err = c.SyncAggregate.UnmarshalSSZ(sszSlice5); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) } - size += l.FinalizedHeader.SizeSSZ() - return + // Field 6: SignatureSlot + if err = c.SignatureSlot.UnmarshalSSZ(sszSlice6); err != nil { + return fmt.Errorf("SignatureSlot: %w", err) + } + return err } -// HashTreeRoot ssz hashes the LightClientFinalityUpdateCapella object -func (l *LightClientFinalityUpdateCapella) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(l) +func (c *LightClientUpdateCapella) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the LightClientFinalityUpdateCapella object with a hasher -func (l *LightClientFinalityUpdateCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *LightClientUpdateCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'AttestedHeader' - if err = l.AttestedHeader.HashTreeRootWith(hh); err != nil { - return + // Field 0: AttestedHeader + if err := c.AttestedHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("AttestedHeader: %w", err) } - - // Field (1) 'FinalizedHeader' - if err = l.FinalizedHeader.HashTreeRootWith(hh); err != nil { - return + // Field 1: NextSyncCommittee + if err := c.NextSyncCommittee.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("NextSyncCommittee: %w", err) } - - // Field (2) 'FinalityBranch' + // Field 2: NextSyncCommitteeBranch { - if size := len(l.FinalityBranch); size != 6 { - err = ssz.ErrVectorLengthFn("--.FinalityBranch", size, 6) - return + if len(c.NextSyncCommitteeBranch) != 5 { + return ssz.ErrVectorLength } subIndx := hh.Index() - for _, i := range l.FinalityBranch { - if len(i) != 32 { - err = ssz.ErrBytesLength - return + for _, o := range c.NextSyncCommitteeBranch { + if len(o) != 32 { + return ssz.ErrBytesLength } - hh.Append(i) + hh.Append(o) } hh.Merkleize(subIndx) } - - // Field (3) 'SyncAggregate' - if err = l.SyncAggregate.HashTreeRootWith(hh); err != nil { - return + // Field 3: FinalizedHeader + if err := c.FinalizedHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("FinalizedHeader: %w", err) + } + // Field 4: FinalityBranch + { + if len(c.FinalityBranch) != 6 { + return ssz.ErrVectorLength + } + subIndx := hh.Index() + for _, o := range c.FinalityBranch { + if len(o) != 32 { + return ssz.ErrBytesLength + } + hh.Append(o) + } + hh.Merkleize(subIndx) + } + // Field 5: SyncAggregate + if err := c.SyncAggregate.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) + } + // Field 6: SignatureSlot + if err := c.SignatureSlot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SignatureSlot: %w", err) } - - // Field (4) 'SignatureSlot' - ssz.PutUint(hh, l.SignatureSlot) - hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the LightClientOptimisticUpdateCapella object -func (l *LightClientOptimisticUpdateCapella) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(l) +func (c *SignedBeaconBlockCapella) SizeSSZ() int { + size := 100 + if c.Block == nil { + c.Block = new(BeaconBlockCapella) + } + size += c.Block.SizeSSZ() + return size } -// MarshalSSZTo ssz marshals the LightClientOptimisticUpdateCapella object to a target array -func (l *LightClientOptimisticUpdateCapella) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(172) +func (c *SignedBeaconBlockCapella) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Offset (0) 'AttestedHeader' - dst = ssz.WriteOffset(dst, offset) - if l.AttestedHeader == nil { - l.AttestedHeader = new(LightClientHeaderCapella) - } - offset += l.AttestedHeader.SizeSSZ() +func (c *SignedBeaconBlockCapella) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 100 - // Field (1) 'SyncAggregate' - if l.SyncAggregate == nil { - l.SyncAggregate = new(SyncAggregate) + // Field 0: Block + if c.Block == nil { + c.Block = new(BeaconBlockCapella) } - if dst, err = l.SyncAggregate.MarshalSSZTo(dst); err != nil { - return - } - - // Field (2) 'SignatureSlot' - dst = ssz.MarshalUint(dst, l.SignatureSlot) + dst = ssz.WriteOffset(dst, offset) + offset += c.Block.SizeSSZ() - // Field (0) 'AttestedHeader' - if dst, err = l.AttestedHeader.MarshalSSZTo(dst); err != nil { - return + // Field 1: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.Signature...) - return + // Field 0: Block + if dst, err = c.Block.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Block: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the LightClientOptimisticUpdateCapella object -func (l *LightClientOptimisticUpdateCapella) UnmarshalSSZ(buf []byte) error { +func (c *SignedBeaconBlockCapella) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 172 { + if size < 100 { return ssz.ErrSize } - tail := buf - var o0 uint64 + sszSlice1 := buf[4:100] // c.Signature - // Offset (0) 'AttestedHeader' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } - - if o0 != 172 { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Block + if sszVarOffset0 != 100 { return ssz.ErrInvalidVariableOffset } - - // Field (1) 'SyncAggregate' - if l.SyncAggregate == nil { - l.SyncAggregate = new(SyncAggregate) - } - if err = l.SyncAggregate.UnmarshalSSZ(buf[4:164]); err != nil { - return err + if sszVarOffset0 > size { + return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:] // c.Block - // Field (2) 'SignatureSlot' - l.SignatureSlot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[164:172]) - - // Field (0) 'AttestedHeader' - { - buf = tail[o0:] - if l.AttestedHeader == nil { - l.AttestedHeader = new(LightClientHeaderCapella) - } - if err = l.AttestedHeader.UnmarshalSSZ(buf); err != nil { - return err - } + // Field 0: Block + c.Block = new(BeaconBlockCapella) + if err = c.Block.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Block: %w", err) } + + // Field 1: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice1...) return err } -// SizeSSZ returns the ssz encoded size in bytes for the LightClientOptimisticUpdateCapella object -func (l *LightClientOptimisticUpdateCapella) SizeSSZ() (size int) { - size = 172 - - // Field (0) 'AttestedHeader' - if l.AttestedHeader == nil { - l.AttestedHeader = new(LightClientHeaderCapella) +func (c *SignedBeaconBlockCapella) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - size += l.AttestedHeader.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the LightClientOptimisticUpdateCapella object -func (l *LightClientOptimisticUpdateCapella) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(l) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the LightClientOptimisticUpdateCapella object with a hasher -func (l *LightClientOptimisticUpdateCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *SignedBeaconBlockCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'AttestedHeader' - if err = l.AttestedHeader.HashTreeRootWith(hh); err != nil { - return + // Field 0: Block + if err := c.Block.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Block: %w", err) } - - // Field (1) 'SyncAggregate' - if err = l.SyncAggregate.HashTreeRootWith(hh); err != nil { - return + // Field 1: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength } - - // Field (2) 'SignatureSlot' - ssz.PutUint(hh, l.SignatureSlot) - + hh.PutBytes(c.Signature) hh.Merkleize(indx) - return + return nil +} + +func (c *SignedBlindedBeaconBlockCapella) SizeSSZ() int { + size := 100 + if c.Block == nil { + c.Block = new(BlindedBeaconBlockCapella) + } + size += c.Block.SizeSSZ() + return size } -// MarshalSSZ ssz marshals the LightClientHeaderCapella object -func (l *LightClientHeaderCapella) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(l) +func (c *SignedBlindedBeaconBlockCapella) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the LightClientHeaderCapella object to a target array -func (l *LightClientHeaderCapella) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(244) +func (c *SignedBlindedBeaconBlockCapella) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 100 - // Field (0) 'Beacon' - if l.Beacon == nil { - l.Beacon = new(BeaconBlockHeader) - } - if dst, err = l.Beacon.MarshalSSZTo(dst); err != nil { - return + // Field 0: Block + if c.Block == nil { + c.Block = new(BlindedBeaconBlockCapella) } - - // Offset (1) 'Execution' dst = ssz.WriteOffset(dst, offset) - if l.Execution == nil { - l.Execution = new(v1.ExecutionPayloadHeaderCapella) - } - offset += l.Execution.SizeSSZ() + offset += c.Block.SizeSSZ() - // Field (2) 'ExecutionBranch' - if size := len(l.ExecutionBranch); size != 4 { - err = ssz.ErrVectorLengthFn("--.ExecutionBranch", size, 4) - return - } - for ii := 0; ii < 4; ii++ { - if size := len(l.ExecutionBranch[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.ExecutionBranch[ii]", size, 32) - return - } - dst = append(dst, l.ExecutionBranch[ii]...) + // Field 1: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.Signature...) - // Field (1) 'Execution' - if dst, err = l.Execution.MarshalSSZTo(dst); err != nil { - return + // Field 0: Block + if dst, err = c.Block.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Block: %w", err) } - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the LightClientHeaderCapella object -func (l *LightClientHeaderCapella) UnmarshalSSZ(buf []byte) error { +func (c *SignedBlindedBeaconBlockCapella) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 244 { + if size < 100 { return ssz.ErrSize } - tail := buf - var o1 uint64 + sszSlice1 := buf[4:100] // c.Signature - // Field (0) 'Beacon' - if l.Beacon == nil { - l.Beacon = new(BeaconBlockHeader) - } - if err = l.Beacon.UnmarshalSSZ(buf[0:112]); err != nil { - return err + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Block + if sszVarOffset0 != 100 { + return ssz.ErrInvalidVariableOffset } - - // Offset (1) 'Execution' - if o1 = ssz.ReadOffset(buf[112:116]); o1 > size { + if sszVarOffset0 > size { return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:] // c.Block - if o1 != 244 { - return ssz.ErrInvalidVariableOffset - } - - // Field (2) 'ExecutionBranch' - l.ExecutionBranch = make([][]byte, 4) - for ii := 0; ii < 4; ii++ { - if cap(l.ExecutionBranch[ii]) == 0 { - l.ExecutionBranch[ii] = make([]byte, 0, len(buf[116:244][ii*32:(ii+1)*32])) - } - l.ExecutionBranch[ii] = append(l.ExecutionBranch[ii], buf[116:244][ii*32:(ii+1)*32]...) + // Field 0: Block + c.Block = new(BlindedBeaconBlockCapella) + if err = c.Block.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Block: %w", err) } - // Field (1) 'Execution' - { - buf = tail[o1:] - if l.Execution == nil { - l.Execution = new(v1.ExecutionPayloadHeaderCapella) - } - if err = l.Execution.UnmarshalSSZ(buf); err != nil { - return err - } - } + // Field 1: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice1...) return err } -// SizeSSZ returns the ssz encoded size in bytes for the LightClientHeaderCapella object -func (l *LightClientHeaderCapella) SizeSSZ() (size int) { - size = 244 - - // Field (1) 'Execution' - if l.Execution == nil { - l.Execution = new(v1.ExecutionPayloadHeaderCapella) +func (c *SignedBlindedBeaconBlockCapella) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - size += l.Execution.SizeSSZ() - - return + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRoot ssz hashes the LightClientHeaderCapella object -func (l *LightClientHeaderCapella) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(l) -} - -// HashTreeRootWith ssz hashes the LightClientHeaderCapella object with a hasher -func (l *LightClientHeaderCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *SignedBlindedBeaconBlockCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Beacon' - if err = l.Beacon.HashTreeRootWith(hh); err != nil { - return + // Field 0: Block + if err := c.Block.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Block: %w", err) } - - // Field (1) 'Execution' - if err = l.Execution.HashTreeRootWith(hh); err != nil { - return + // Field 1: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength } + hh.PutBytes(c.Signature) + hh.Merkleize(indx) + return nil +} - // Field (2) 'ExecutionBranch' - { - if size := len(l.ExecutionBranch); size != 4 { - err = ssz.ErrVectorLengthFn("--.ExecutionBranch", size, 4) - return - } - subIndx := hh.Index() - for _, i := range l.ExecutionBranch { - if len(i) != 32 { - err = ssz.ErrBytesLength - return - } - hh.Append(i) - } - hh.Merkleize(subIndx) - } +func (c *SignedBLSToExecutionChange) SizeSSZ() int { + size := 172 - hh.Merkleize(indx) - return + return size } -// MarshalSSZ ssz marshals the SignedBLSToExecutionChange object -func (s *SignedBLSToExecutionChange) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) +func (c *SignedBLSToExecutionChange) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the SignedBLSToExecutionChange object to a target array -func (s *SignedBLSToExecutionChange) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *SignedBLSToExecutionChange) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (0) 'Message' - if s.Message == nil { - s.Message = new(BLSToExecutionChange) + // Field 0: Message + if c.Message == nil { + c.Message = new(BLSToExecutionChange) } - if dst, err = s.Message.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.Message.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Message: %w", err) } - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 1: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } - dst = append(dst, s.Signature...) + dst = append(dst, c.Signature...) - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the SignedBLSToExecutionChange object -func (s *SignedBLSToExecutionChange) UnmarshalSSZ(buf []byte) error { +func (c *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 - } + sszSlice0 := buf[0:76] // c.Message + sszSlice1 := buf[76:172] // c.Signature - // Field (1) 'Signature' - if cap(s.Signature) == 0 { - s.Signature = make([]byte, 0, len(buf[76:172])) + // Field 0: Message + c.Message = new(BLSToExecutionChange) + if err = c.Message.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Message: %w", err) } - s.Signature = append(s.Signature, buf[76:172]...) + // Field 1: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice1...) 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) +func (c *SignedBLSToExecutionChange) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the SignedBLSToExecutionChange object with a hasher -func (s *SignedBLSToExecutionChange) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *SignedBLSToExecutionChange) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Message' - if err = s.Message.HashTreeRootWith(hh); err != nil { - return + // Field 0: Message + if err := c.Message.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Message: %w", err) } - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 1: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength } - hh.PutBytes(s.Signature) - + hh.PutBytes(c.Signature) hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the BLSToExecutionChange object -func (b *BLSToExecutionChange) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) +func (c *SignedBuilderBidCapella) SizeSSZ() int { + size := 100 + if c.Message == nil { + c.Message = new(BuilderBidCapella) + } + size += c.Message.SizeSSZ() + return size } -// MarshalSSZTo ssz marshals the BLSToExecutionChange object to a target array -func (b *BLSToExecutionChange) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *SignedBuilderBidCapella) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (0) 'ValidatorIndex' - dst = ssz.MarshalUint(dst, b.ValidatorIndex) +func (c *SignedBuilderBidCapella) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 100 - // Field (1) 'FromBlsPubkey' - if size := len(b.FromBlsPubkey); size != 48 { - err = ssz.ErrBytesLengthFn("--.FromBlsPubkey", size, 48) - return + // Field 0: Message + if c.Message == nil { + c.Message = new(BuilderBidCapella) } - dst = append(dst, b.FromBlsPubkey...) + dst = ssz.WriteOffset(dst, offset) + offset += c.Message.SizeSSZ() - // Field (2) 'ToExecutionAddress' - if size := len(b.ToExecutionAddress); size != 20 { - err = ssz.ErrBytesLengthFn("--.ToExecutionAddress", size, 20) - return + // Field 1: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.ToExecutionAddress...) + dst = append(dst, c.Signature...) - return + // Field 0: Message + if dst, err = c.Message.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Message: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the BLSToExecutionChange object -func (b *BLSToExecutionChange) UnmarshalSSZ(buf []byte) error { +func (c *SignedBuilderBidCapella) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 76 { + if size < 100 { return ssz.ErrSize } - // Field (0) 'ValidatorIndex' - b.ValidatorIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[0:8]) + sszSlice1 := buf[4:100] // c.Signature - // Field (1) 'FromBlsPubkey' - if cap(b.FromBlsPubkey) == 0 { - b.FromBlsPubkey = make([]byte, 0, len(buf[8:56])) + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Message + if sszVarOffset0 != 100 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset0 > size { + return ssz.ErrOffset } - b.FromBlsPubkey = append(b.FromBlsPubkey, buf[8:56]...) + sszSlice0 := buf[sszVarOffset0:] // c.Message - // Field (2) 'ToExecutionAddress' - if cap(b.ToExecutionAddress) == 0 { - b.ToExecutionAddress = make([]byte, 0, len(buf[56:76])) + // Field 0: Message + c.Message = new(BuilderBidCapella) + if err = c.Message.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Message: %w", err) } - b.ToExecutionAddress = append(b.ToExecutionAddress, buf[56:76]...) + // Field 1: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice1...) 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) +func (c *SignedBuilderBidCapella) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the BLSToExecutionChange object with a hasher -func (b *BLSToExecutionChange) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *SignedBuilderBidCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'ValidatorIndex' - ssz.PutUint(hh, b.ValidatorIndex) - - // Field (1) 'FromBlsPubkey' - if size := len(b.FromBlsPubkey); size != 48 { - err = ssz.ErrBytesLengthFn("--.FromBlsPubkey", size, 48) - return + // Field 0: Message + if err := c.Message.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Message: %w", err) } - hh.PutBytes(b.FromBlsPubkey) - - // Field (2) 'ToExecutionAddress' - if size := len(b.ToExecutionAddress); size != 20 { - err = ssz.ErrBytesLengthFn("--.ToExecutionAddress", size, 20) - return + // Field 1: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength } - hh.PutBytes(b.ToExecutionAddress) - + hh.PutBytes(c.Signature) hh.Merkleize(indx) - return + return nil } diff --git a/proto/prysm/v1alpha1/capella.yaml b/proto/prysm/v1alpha1/capella.yaml new file mode 100644 index 000000000000..908c6b85f0bf --- /dev/null +++ b/proto/prysm/v1alpha1/capella.yaml @@ -0,0 +1,19 @@ +package: "github.com/OffchainLabs/prysm/v7/proto/prysm/v1alpha1" +types: + - name: "BeaconBlockBodyCapella" + - name: "BeaconBlockCapella" + - name: "BeaconStateCapella" + - name: "BlindedBeaconBlockBodyCapella" + - name: "BlindedBeaconBlockCapella" + - name: "BLSToExecutionChange" + - name: "BuilderBidCapella" + - name: "HistoricalSummary" + - name: "LightClientBootstrapCapella" + - name: "LightClientFinalityUpdateCapella" + - name: "LightClientHeaderCapella" + - name: "LightClientOptimisticUpdateCapella" + - name: "LightClientUpdateCapella" + - name: "SignedBeaconBlockCapella" + - name: "SignedBlindedBeaconBlockCapella" + - name: "SignedBLSToExecutionChange" + - name: "SignedBuilderBidCapella" diff --git a/proto/prysm/v1alpha1/deneb.minimal.ssz.go b/proto/prysm/v1alpha1/deneb.minimal.ssz.go index 0502eca49c4b..d1027177a396 100644 --- a/proto/prysm/v1alpha1/deneb.minimal.ssz.go +++ b/proto/prysm/v1alpha1/deneb.minimal.ssz.go @@ -1,4576 +1,4315 @@ //go:build minimal -// Code generated by fastssz. DO NOT EDIT. package eth import ( - github_com_OffchainLabs_prysm_v7_consensus_types_primitives "github.com/OffchainLabs/prysm/v7/consensus-types/primitives" + binary "encoding/binary" + "fmt" + go_bitfield "github.com/OffchainLabs/go-bitfield" + ssz "github.com/OffchainLabs/methodical-ssz/ssz" v1 "github.com/OffchainLabs/prysm/v7/proto/engine/v1" - ssz "github.com/prysmaticlabs/fastssz" ) -// MarshalSSZ ssz marshals the SignedBeaconBlockContentsDeneb object -func (s *SignedBeaconBlockContentsDeneb) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) +func (c *BeaconBlockBodyDeneb) SizeSSZ() int { + size := 332 + size += len(c.ProposerSlashings) * 416 + for _, o := range c.AttesterSlashings { + size += 4 + size += o.SizeSSZ() + } + for _, o := range c.Attestations { + size += 4 + size += o.SizeSSZ() + } + size += len(c.Deposits) * 1240 + size += len(c.VoluntaryExits) * 112 + if c.ExecutionPayload == nil { + c.ExecutionPayload = new(v1.ExecutionPayloadDeneb) + } + size += c.ExecutionPayload.SizeSSZ() + size += len(c.BlsToExecutionChanges) * 172 + size += len(c.BlobKzgCommitments) * 48 + return size +} + +func (c *BeaconBlockBodyDeneb) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the SignedBeaconBlockContentsDeneb object to a target array -func (s *SignedBeaconBlockContentsDeneb) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(12) +func (c *BeaconBlockBodyDeneb) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 332 + + // Field 0: RandaoReveal + if len(c.RandaoReveal) != 96 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.RandaoReveal...) + + // Field 1: Eth1Data + if c.Eth1Data == nil { + c.Eth1Data = new(Eth1Data) + } + if dst, err = c.Eth1Data.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Eth1Data: %w", err) + } + + // Field 2: Graffiti + if len(c.Graffiti) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.Graffiti...) + + // Field 3: ProposerSlashings + dst = ssz.WriteOffset(dst, offset) + offset += len(c.ProposerSlashings) * 416 + + // Field 4: AttesterSlashings + dst = ssz.WriteOffset(dst, offset) + for _, o := range c.AttesterSlashings { + offset += 4 + offset += o.SizeSSZ() + } + + // Field 5: Attestations + dst = ssz.WriteOffset(dst, offset) + for _, o := range c.Attestations { + offset += 4 + offset += o.SizeSSZ() + } + + // Field 6: Deposits + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Deposits) * 1240 - // Offset (0) 'Block' + // Field 7: VoluntaryExits dst = ssz.WriteOffset(dst, offset) - if s.Block == nil { - s.Block = new(SignedBeaconBlockDeneb) + offset += len(c.VoluntaryExits) * 112 + + // Field 8: SyncAggregate + if c.SyncAggregate == nil { + c.SyncAggregate = new(SyncAggregate) } - offset += s.Block.SizeSSZ() + if dst, err = c.SyncAggregate.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SyncAggregate: %w", err) + } + + // Field 9: ExecutionPayload + if c.ExecutionPayload == nil { + c.ExecutionPayload = new(v1.ExecutionPayloadDeneb) + } + dst = ssz.WriteOffset(dst, offset) + offset += c.ExecutionPayload.SizeSSZ() - // Offset (1) 'KzgProofs' + // Field 10: BlsToExecutionChanges dst = ssz.WriteOffset(dst, offset) - offset += len(s.KzgProofs) * 48 + offset += len(c.BlsToExecutionChanges) * 172 - // Offset (2) 'Blobs' + // Field 11: BlobKzgCommitments dst = ssz.WriteOffset(dst, offset) - offset += len(s.Blobs) * 131072 + offset += len(c.BlobKzgCommitments) * 48 - // Field (0) 'Block' - if dst, err = s.Block.MarshalSSZTo(dst); err != nil { - return + // Field 3: ProposerSlashings + if len(c.ProposerSlashings) > 16 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.ProposerSlashings { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ProposerSlashings: %w", err) + } + } + + // Field 4: AttesterSlashings + if len(c.AttesterSlashings) > 2 { + return nil, ssz.ErrListTooBig + } + { + offset = 4 * len(c.AttesterSlashings) + for _, o := range c.AttesterSlashings { + dst = ssz.WriteOffset(dst, offset) + offset += o.SizeSSZ() + } + } + for _, o := range c.AttesterSlashings { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("AttesterSlashings: %w", err) + } + } + + // Field 5: Attestations + if len(c.Attestations) > 128 { + return nil, ssz.ErrListTooBig + } + { + offset = 4 * len(c.Attestations) + for _, o := range c.Attestations { + dst = ssz.WriteOffset(dst, offset) + offset += o.SizeSSZ() + } + } + for _, o := range c.Attestations { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Attestations: %w", err) + } + } + + // Field 6: Deposits + if len(c.Deposits) > 16 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.Deposits { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Deposits: %w", err) + } } - // Field (1) 'KzgProofs' - if size := len(s.KzgProofs); size > 4096 { - err = ssz.ErrListTooBigFn("--.KzgProofs", size, 4096) - return + // Field 7: VoluntaryExits + if len(c.VoluntaryExits) > 16 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(s.KzgProofs); ii++ { - if size := len(s.KzgProofs[ii]); size != 48 { - err = ssz.ErrBytesLengthFn("--.KzgProofs[ii]", size, 48) - return + for _, o := range c.VoluntaryExits { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("VoluntaryExits: %w", err) } - dst = append(dst, s.KzgProofs[ii]...) } - // Field (2) 'Blobs' - if size := len(s.Blobs); size > 4096 { - err = ssz.ErrListTooBigFn("--.Blobs", size, 4096) - return + // Field 9: ExecutionPayload + if dst, err = c.ExecutionPayload.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ExecutionPayload: %w", err) + } + + // Field 10: BlsToExecutionChanges + if len(c.BlsToExecutionChanges) > 16 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(s.Blobs); ii++ { - if size := len(s.Blobs[ii]); size != 131072 { - err = ssz.ErrBytesLengthFn("--.Blobs[ii]", size, 131072) - return + for _, o := range c.BlsToExecutionChanges { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("BlsToExecutionChanges: %w", err) } - dst = append(dst, s.Blobs[ii]...) } - return + // Field 11: BlobKzgCommitments + if len(c.BlobKzgCommitments) > 4096 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.BlobKzgCommitments { + if len(o) != 48 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the SignedBeaconBlockContentsDeneb object -func (s *SignedBeaconBlockContentsDeneb) UnmarshalSSZ(buf []byte) error { +func (c *BeaconBlockBodyDeneb) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 12 { + if size < 332 { return ssz.ErrSize } - tail := buf - var o0, o1, o2 uint64 + sszSlice0 := buf[0:96] // c.RandaoReveal + sszSlice1 := buf[96:168] // c.Eth1Data + sszSlice2 := buf[168:200] // c.Graffiti + sszSlice8 := buf[220:320] // c.SyncAggregate - // Offset (0) 'Block' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { + sszVarOffset3 := ssz.ReadOffset(buf[200:204]) // c.ProposerSlashings + if sszVarOffset3 != 332 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset3 > size { return ssz.ErrOffset } - - if o0 != 12 { - return ssz.ErrInvalidVariableOffset + sszVarOffset4 := ssz.ReadOffset(buf[204:208]) // c.AttesterSlashings + if sszVarOffset4 > size || sszVarOffset4 < sszVarOffset3 { + return ssz.ErrOffset } - - // Offset (1) 'KzgProofs' - if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 { + sszVarOffset5 := ssz.ReadOffset(buf[208:212]) // c.Attestations + if sszVarOffset5 > size || sszVarOffset5 < sszVarOffset4 { return ssz.ErrOffset } - - // Offset (2) 'Blobs' - if o2 = ssz.ReadOffset(buf[8:12]); o2 > size || o1 > o2 { + sszVarOffset6 := ssz.ReadOffset(buf[212:216]) // c.Deposits + if sszVarOffset6 > size || sszVarOffset6 < sszVarOffset5 { + return ssz.ErrOffset + } + sszVarOffset7 := ssz.ReadOffset(buf[216:220]) // c.VoluntaryExits + if sszVarOffset7 > size || sszVarOffset7 < sszVarOffset6 { + return ssz.ErrOffset + } + sszVarOffset9 := ssz.ReadOffset(buf[320:324]) // c.ExecutionPayload + if sszVarOffset9 > size || sszVarOffset9 < sszVarOffset7 { return ssz.ErrOffset } + sszVarOffset10 := ssz.ReadOffset(buf[324:328]) // c.BlsToExecutionChanges + if sszVarOffset10 > size || sszVarOffset10 < sszVarOffset9 { + return ssz.ErrOffset + } + sszVarOffset11 := ssz.ReadOffset(buf[328:332]) // c.BlobKzgCommitments + if sszVarOffset11 > size || sszVarOffset11 < sszVarOffset10 { + return ssz.ErrOffset + } + sszSlice3 := buf[sszVarOffset3:sszVarOffset4] // c.ProposerSlashings + sszSlice4 := buf[sszVarOffset4:sszVarOffset5] // c.AttesterSlashings + sszSlice5 := buf[sszVarOffset5:sszVarOffset6] // c.Attestations + sszSlice6 := buf[sszVarOffset6:sszVarOffset7] // c.Deposits + sszSlice7 := buf[sszVarOffset7:sszVarOffset9] // c.VoluntaryExits + sszSlice9 := buf[sszVarOffset9:sszVarOffset10] // c.ExecutionPayload + sszSlice10 := buf[sszVarOffset10:sszVarOffset11] // c.BlsToExecutionChanges + sszSlice11 := buf[sszVarOffset11:] // c.BlobKzgCommitments + + // Field 0: RandaoReveal + c.RandaoReveal = make([]byte, 0, 96) + c.RandaoReveal = append(c.RandaoReveal, sszSlice0...) + + // Field 1: Eth1Data + c.Eth1Data = new(Eth1Data) + if err = c.Eth1Data.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Eth1Data: %w", err) + } + + // Field 2: Graffiti + c.Graffiti = make([]byte, 0, 32) + c.Graffiti = append(c.Graffiti, sszSlice2...) - // Field (0) 'Block' + // Field 3: ProposerSlashings { - buf = tail[o0:o1] - if s.Block == nil { - s.Block = new(SignedBeaconBlockDeneb) + if len(sszSlice3)%416 != 0 { + return fmt.Errorf("misaligned bytes: c.ProposerSlashings length is %d, which is not a multiple of 416: %w", len(sszSlice3), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice3) / 416 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.ProposerSlashings has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.ProposerSlashings = make([]*ProposerSlashing, numElem) + for i := 0; i < numElem; i++ { + var tmp *ProposerSlashing + tmp = new(ProposerSlashing) + tmpSlice := sszSlice3[i*416 : (1+i)*416] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("ProposerSlashings: %w", err) + } + c.ProposerSlashings[i] = tmp } - if err = s.Block.UnmarshalSSZ(buf); err != nil { - return err + } + + // Field 4: AttesterSlashings + { + // empty lists are zero length, so make sure there is room for an offset + // before attempting to unmarshal it + if len(sszSlice4) > 3 { + startOffset := ssz.ReadOffset(sszSlice4[0:4]) + if startOffset == 0 { + return fmt.Errorf("encountered invalid offset of 0 when decoding c.AttesterSlashings") + } + if startOffset%4 != 0 { + return fmt.Errorf("misaligned list bytes: when decoding c.AttesterSlashings, end-of-list offset is %d, which is not a multiple of 4 (offset size)", startOffset) + } + listLen := startOffset / 4 + if listLen > 2 { + return fmt.Errorf("ssz-max exceeded: c.AttesterSlashings has %d elements, ssz-max is 2: %w", listLen, ssz.ErrListTooBig) + } + totalVarBytes := uint64(len(sszSlice4)) + if totalVarBytes < startOffset { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.AttesterSlashings") + } + c.AttesterSlashings = make([]*AttesterSlashing, listLen) + var tmpSlice []byte + for i := uint64(0); i < listLen; i++ { + var tmp *AttesterSlashing + tmp = new(AttesterSlashing) + endOffset := totalVarBytes + if i+1 != listLen { + endOffset = ssz.ReadOffset(sszSlice4[(i+1)*4 : (i+2)*4]) + if totalVarBytes < endOffset { + return fmt.Errorf("offset %d points past the end of buffer when decoding c.AttesterSlashings", endOffset) + } + } + if endOffset < startOffset { + return fmt.Errorf("offset %d is not greater than start offset %d when decoding c.AttesterSlashings", endOffset, startOffset) + } + tmpSlice = sszSlice4[startOffset:endOffset] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("AttesterSlashings: %w", err) + } + c.AttesterSlashings[i] = tmp + startOffset = endOffset + } + } else { + if len(sszSlice4) > 0 { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.AttesterSlashings") + } + c.AttesterSlashings = make([]*AttesterSlashing, 0) } } - // Field (1) 'KzgProofs' + // Field 5: Attestations { - buf = tail[o1:o2] - num, err := ssz.DivideInt2(len(buf), 48, 4096) - if err != nil { - return err - } - s.KzgProofs = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(s.KzgProofs[ii]) == 0 { - s.KzgProofs[ii] = make([]byte, 0, len(buf[ii*48:(ii+1)*48])) + // empty lists are zero length, so make sure there is room for an offset + // before attempting to unmarshal it + if len(sszSlice5) > 3 { + startOffset := ssz.ReadOffset(sszSlice5[0:4]) + if startOffset == 0 { + return fmt.Errorf("encountered invalid offset of 0 when decoding c.Attestations") + } + if startOffset%4 != 0 { + return fmt.Errorf("misaligned list bytes: when decoding c.Attestations, end-of-list offset is %d, which is not a multiple of 4 (offset size)", startOffset) + } + listLen := startOffset / 4 + if listLen > 128 { + return fmt.Errorf("ssz-max exceeded: c.Attestations has %d elements, ssz-max is 128: %w", listLen, ssz.ErrListTooBig) } - s.KzgProofs[ii] = append(s.KzgProofs[ii], buf[ii*48:(ii+1)*48]...) + totalVarBytes := uint64(len(sszSlice5)) + if totalVarBytes < startOffset { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.Attestations") + } + c.Attestations = make([]*Attestation, listLen) + var tmpSlice []byte + for i := uint64(0); i < listLen; i++ { + var tmp *Attestation + tmp = new(Attestation) + endOffset := totalVarBytes + if i+1 != listLen { + endOffset = ssz.ReadOffset(sszSlice5[(i+1)*4 : (i+2)*4]) + if totalVarBytes < endOffset { + return fmt.Errorf("offset %d points past the end of buffer when decoding c.Attestations", endOffset) + } + } + if endOffset < startOffset { + return fmt.Errorf("offset %d is not greater than start offset %d when decoding c.Attestations", endOffset, startOffset) + } + tmpSlice = sszSlice5[startOffset:endOffset] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Attestations: %w", err) + } + c.Attestations[i] = tmp + startOffset = endOffset + } + } else { + if len(sszSlice5) > 0 { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.Attestations") + } + c.Attestations = make([]*Attestation, 0) } } - // Field (2) 'Blobs' + // Field 6: Deposits { - buf = tail[o2:] - num, err := ssz.DivideInt2(len(buf), 131072, 4096) - if err != nil { - return err - } - s.Blobs = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(s.Blobs[ii]) == 0 { - s.Blobs[ii] = make([]byte, 0, len(buf[ii*131072:(ii+1)*131072])) + if len(sszSlice6)%1240 != 0 { + return fmt.Errorf("misaligned bytes: c.Deposits length is %d, which is not a multiple of 1240: %w", len(sszSlice6), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice6) / 1240 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.Deposits has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.Deposits = make([]*Deposit, numElem) + for i := 0; i < numElem; i++ { + var tmp *Deposit + tmp = new(Deposit) + tmpSlice := sszSlice6[i*1240 : (1+i)*1240] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Deposits: %w", err) } - s.Blobs[ii] = append(s.Blobs[ii], buf[ii*131072:(ii+1)*131072]...) + c.Deposits[i] = tmp + } + } + + // Field 7: VoluntaryExits + { + if len(sszSlice7)%112 != 0 { + return fmt.Errorf("misaligned bytes: c.VoluntaryExits length is %d, which is not a multiple of 112: %w", len(sszSlice7), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice7) / 112 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.VoluntaryExits has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.VoluntaryExits = make([]*SignedVoluntaryExit, numElem) + for i := 0; i < numElem; i++ { + var tmp *SignedVoluntaryExit + tmp = new(SignedVoluntaryExit) + tmpSlice := sszSlice7[i*112 : (1+i)*112] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("VoluntaryExits: %w", err) + } + c.VoluntaryExits[i] = tmp } } - return err -} -// SizeSSZ returns the ssz encoded size in bytes for the SignedBeaconBlockContentsDeneb object -func (s *SignedBeaconBlockContentsDeneb) SizeSSZ() (size int) { - size = 12 + // Field 8: SyncAggregate + c.SyncAggregate = new(SyncAggregate) + if err = c.SyncAggregate.UnmarshalSSZ(sszSlice8); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) + } - // Field (0) 'Block' - if s.Block == nil { - s.Block = new(SignedBeaconBlockDeneb) + // Field 9: ExecutionPayload + c.ExecutionPayload = new(v1.ExecutionPayloadDeneb) + if err = c.ExecutionPayload.UnmarshalSSZ(sszSlice9); err != nil { + return fmt.Errorf("ExecutionPayload: %w", err) } - size += s.Block.SizeSSZ() - // Field (1) 'KzgProofs' - size += len(s.KzgProofs) * 48 + // Field 10: BlsToExecutionChanges + { + if len(sszSlice10)%172 != 0 { + return fmt.Errorf("misaligned bytes: c.BlsToExecutionChanges length is %d, which is not a multiple of 172: %w", len(sszSlice10), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice10) / 172 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.BlsToExecutionChanges has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.BlsToExecutionChanges = make([]*SignedBLSToExecutionChange, numElem) + for i := 0; i < numElem; i++ { + var tmp *SignedBLSToExecutionChange + tmp = new(SignedBLSToExecutionChange) + tmpSlice := sszSlice10[i*172 : (1+i)*172] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("BlsToExecutionChanges: %w", err) + } + c.BlsToExecutionChanges[i] = tmp + } + } - // Field (2) 'Blobs' - size += len(s.Blobs) * 131072 + // Field 11: BlobKzgCommitments + { + if len(sszSlice11)%48 != 0 { + return fmt.Errorf("misaligned bytes: c.BlobKzgCommitments length is %d, which is not a multiple of 48: %w", len(sszSlice11), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice11) / 48 + if numElem > 4096 { + return fmt.Errorf("ssz-max exceeded: c.BlobKzgCommitments has %d elements, ssz-max is 4096: %w", numElem, ssz.ErrListTooBig) + } + c.BlobKzgCommitments = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte - return + tmpSlice := sszSlice11[i*48 : (1+i)*48] + tmp = make([]byte, 0, 48) + tmp = append(tmp, tmpSlice...) + c.BlobKzgCommitments[i] = tmp + } + } + return err } -// HashTreeRoot ssz hashes the SignedBeaconBlockContentsDeneb object -func (s *SignedBeaconBlockContentsDeneb) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) +func (c *BeaconBlockBodyDeneb) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the SignedBeaconBlockContentsDeneb object with a hasher -func (s *SignedBeaconBlockContentsDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *BeaconBlockBodyDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Block' - if err = s.Block.HashTreeRootWith(hh); err != nil { - return + // Field 0: RandaoReveal + if len(c.RandaoReveal) != 96 { + return ssz.ErrBytesLength } - - // Field (1) 'KzgProofs' + hh.PutBytes(c.RandaoReveal) + // Field 1: Eth1Data + if err := c.Eth1Data.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Eth1Data: %w", err) + } + // Field 2: Graffiti + if len(c.Graffiti) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Graffiti) + // Field 3: ProposerSlashings { - if size := len(s.KzgProofs); size > 4096 { - err = ssz.ErrListTooBigFn("--.KzgProofs", size, 4096) - return + if len(c.ProposerSlashings) > 16 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range s.KzgProofs { - if len(i) != 48 { - err = ssz.ErrBytesLength - return + for _, o := range c.ProposerSlashings { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ProposerSlashings: %w", err) } - hh.PutBytes(i) } - - numItems := uint64(len(s.KzgProofs)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.ProposerSlashings)), 16) } - - // Field (2) 'Blobs' + // Field 4: AttesterSlashings { - if size := len(s.Blobs); size > 4096 { - err = ssz.ErrListTooBigFn("--.Blobs", size, 4096) - return + if len(c.AttesterSlashings) > 2 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range s.Blobs { - if len(i) != 131072 { - err = ssz.ErrBytesLength - return + for _, o := range c.AttesterSlashings { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("AttesterSlashings: %w", err) } - hh.PutBytes(i) } - - numItems := uint64(len(s.Blobs)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) - } - - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the SignedBeaconBlockDeneb object -func (s *SignedBeaconBlockDeneb) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) -} - -// MarshalSSZTo ssz marshals the SignedBeaconBlockDeneb object to a target array -func (s *SignedBeaconBlockDeneb) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(100) - - // Offset (0) 'Block' - dst = ssz.WriteOffset(dst, offset) - if s.Block == nil { - s.Block = new(BeaconBlockDeneb) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.AttesterSlashings)), 2) } - offset += s.Block.SizeSSZ() - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 5: Attestations + { + if len(c.Attestations) > 128 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.Attestations { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Attestations: %w", err) + } + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Attestations)), 128) } - dst = append(dst, s.Signature...) - - // Field (0) 'Block' - if dst, err = s.Block.MarshalSSZTo(dst); err != nil { - return + // Field 6: Deposits + { + if len(c.Deposits) > 16 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.Deposits { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Deposits: %w", err) + } + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Deposits)), 16) } - - return -} - -// UnmarshalSSZ ssz unmarshals the SignedBeaconBlockDeneb object -func (s *SignedBeaconBlockDeneb) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 100 { - return ssz.ErrSize + // Field 7: VoluntaryExits + { + if len(c.VoluntaryExits) > 16 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.VoluntaryExits { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("VoluntaryExits: %w", err) + } + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.VoluntaryExits)), 16) } - - tail := buf - var o0 uint64 - - // Offset (0) 'Block' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset + // Field 8: SyncAggregate + if err := c.SyncAggregate.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) } - - if o0 != 100 { - return ssz.ErrInvalidVariableOffset + // Field 9: ExecutionPayload + if err := c.ExecutionPayload.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ExecutionPayload: %w", err) } - - // Field (1) 'Signature' - if cap(s.Signature) == 0 { - s.Signature = make([]byte, 0, len(buf[4:100])) + // Field 10: BlsToExecutionChanges + { + if len(c.BlsToExecutionChanges) > 16 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.BlsToExecutionChanges { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("BlsToExecutionChanges: %w", err) + } + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.BlsToExecutionChanges)), 16) } - s.Signature = append(s.Signature, buf[4:100]...) - - // Field (0) 'Block' + // Field 11: BlobKzgCommitments { - buf = tail[o0:] - if s.Block == nil { - s.Block = new(BeaconBlockDeneb) + if len(c.BlobKzgCommitments) > 4096 { + return ssz.ErrListTooBig } - if err = s.Block.UnmarshalSSZ(buf); err != nil { - return err + subIndx := hh.Index() + for _, o := range c.BlobKzgCommitments { + if len(o) != 48 { + return ssz.ErrBytesLength + } + hh.PutBytes(o) } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.BlobKzgCommitments)), 4096) } - return err + hh.Merkleize(indx) + return nil } -// SizeSSZ returns the ssz encoded size in bytes for the SignedBeaconBlockDeneb object -func (s *SignedBeaconBlockDeneb) SizeSSZ() (size int) { - size = 100 - - // Field (0) 'Block' - if s.Block == nil { - s.Block = new(BeaconBlockDeneb) +func (c *BeaconBlockContentsDeneb) SizeSSZ() int { + size := 12 + if c.Block == nil { + c.Block = new(BeaconBlockDeneb) } - size += s.Block.SizeSSZ() - - return + size += c.Block.SizeSSZ() + size += len(c.KzgProofs) * 48 + size += len(c.Blobs) * 131072 + return size } -// HashTreeRoot ssz hashes the SignedBeaconBlockDeneb object -func (s *SignedBeaconBlockDeneb) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) +func (c *BeaconBlockContentsDeneb) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// HashTreeRootWith ssz hashes the SignedBeaconBlockDeneb object with a hasher -func (s *SignedBeaconBlockDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'Block' - if err = s.Block.HashTreeRootWith(hh); err != nil { - return - } +func (c *BeaconBlockContentsDeneb) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 12 - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 0: Block + if c.Block == nil { + c.Block = new(BeaconBlockDeneb) } - hh.PutBytes(s.Signature) - - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the BeaconBlockContentsDeneb object -func (b *BeaconBlockContentsDeneb) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} - -// MarshalSSZTo ssz marshals the BeaconBlockContentsDeneb object to a target array -func (b *BeaconBlockContentsDeneb) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(12) - - // Offset (0) 'Block' dst = ssz.WriteOffset(dst, offset) - if b.Block == nil { - b.Block = new(BeaconBlockDeneb) - } - offset += b.Block.SizeSSZ() + offset += c.Block.SizeSSZ() - // Offset (1) 'KzgProofs' + // Field 1: KzgProofs dst = ssz.WriteOffset(dst, offset) - offset += len(b.KzgProofs) * 48 + offset += len(c.KzgProofs) * 48 - // Offset (2) 'Blobs' + // Field 2: Blobs dst = ssz.WriteOffset(dst, offset) - offset += len(b.Blobs) * 131072 + offset += len(c.Blobs) * 131072 - // Field (0) 'Block' - if dst, err = b.Block.MarshalSSZTo(dst); err != nil { - return + // Field 0: Block + if dst, err = c.Block.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Block: %w", err) } - // Field (1) 'KzgProofs' - if size := len(b.KzgProofs); size > 4096 { - err = ssz.ErrListTooBigFn("--.KzgProofs", size, 4096) - return + // Field 1: KzgProofs + if len(c.KzgProofs) > 4096 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.KzgProofs); ii++ { - if size := len(b.KzgProofs[ii]); size != 48 { - err = ssz.ErrBytesLengthFn("--.KzgProofs[ii]", size, 48) - return + for _, o := range c.KzgProofs { + if len(o) != 48 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.KzgProofs[ii]...) + dst = append(dst, o...) } - // Field (2) 'Blobs' - if size := len(b.Blobs); size > 4096 { - err = ssz.ErrListTooBigFn("--.Blobs", size, 4096) - return + // Field 2: Blobs + if len(c.Blobs) > 4096 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.Blobs); ii++ { - if size := len(b.Blobs[ii]); size != 131072 { - err = ssz.ErrBytesLengthFn("--.Blobs[ii]", size, 131072) - return + for _, o := range c.Blobs { + if len(o) != 131072 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.Blobs[ii]...) + dst = append(dst, o...) } - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the BeaconBlockContentsDeneb object -func (b *BeaconBlockContentsDeneb) UnmarshalSSZ(buf []byte) error { +func (c *BeaconBlockContentsDeneb) 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) 'Block' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Block + if sszVarOffset0 != 12 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset0 > size { return ssz.ErrOffset } - - if o0 != 12 { - return ssz.ErrInvalidVariableOffset + sszVarOffset1 := ssz.ReadOffset(buf[4:8]) // c.KzgProofs + if sszVarOffset1 > size || sszVarOffset1 < sszVarOffset0 { + return ssz.ErrOffset } - - // Offset (1) 'KzgProofs' - if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 { + sszVarOffset2 := ssz.ReadOffset(buf[8:12]) // c.Blobs + if sszVarOffset2 > size || sszVarOffset2 < sszVarOffset1 { return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:sszVarOffset1] // c.Block + sszSlice1 := buf[sszVarOffset1:sszVarOffset2] // c.KzgProofs + sszSlice2 := buf[sszVarOffset2:] // c.Blobs - // Offset (2) 'Blobs' - if o2 = ssz.ReadOffset(buf[8:12]); o2 > size || o1 > o2 { - return ssz.ErrOffset + // Field 0: Block + c.Block = new(BeaconBlockDeneb) + if err = c.Block.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Block: %w", err) } - // Field (0) 'Block' + // Field 1: KzgProofs { - buf = tail[o0:o1] - if b.Block == nil { - b.Block = new(BeaconBlockDeneb) + if len(sszSlice1)%48 != 0 { + return fmt.Errorf("misaligned bytes: c.KzgProofs length is %d, which is not a multiple of 48: %w", len(sszSlice1), ssz.ErrIncorrectListSize) } - if err = b.Block.UnmarshalSSZ(buf); err != nil { - return err + numElem := len(sszSlice1) / 48 + if numElem > 4096 { + return fmt.Errorf("ssz-max exceeded: c.KzgProofs has %d elements, ssz-max is 4096: %w", numElem, ssz.ErrListTooBig) } - } + c.KzgProofs = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte - // Field (1) 'KzgProofs' - { - buf = tail[o1:o2] - num, err := ssz.DivideInt2(len(buf), 48, 4096) - if err != nil { - return err - } - b.KzgProofs = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(b.KzgProofs[ii]) == 0 { - b.KzgProofs[ii] = make([]byte, 0, len(buf[ii*48:(ii+1)*48])) - } - b.KzgProofs[ii] = append(b.KzgProofs[ii], buf[ii*48:(ii+1)*48]...) + tmpSlice := sszSlice1[i*48 : (1+i)*48] + tmp = make([]byte, 0, 48) + tmp = append(tmp, tmpSlice...) + c.KzgProofs[i] = tmp } } - // Field (2) 'Blobs' + // Field 2: Blobs { - buf = tail[o2:] - num, err := ssz.DivideInt2(len(buf), 131072, 4096) - if err != nil { - return err - } - b.Blobs = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(b.Blobs[ii]) == 0 { - b.Blobs[ii] = make([]byte, 0, len(buf[ii*131072:(ii+1)*131072])) - } - b.Blobs[ii] = append(b.Blobs[ii], buf[ii*131072:(ii+1)*131072]...) + if len(sszSlice2)%131072 != 0 { + return fmt.Errorf("misaligned bytes: c.Blobs length is %d, which is not a multiple of 131072: %w", len(sszSlice2), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice2) / 131072 + if numElem > 4096 { + return fmt.Errorf("ssz-max exceeded: c.Blobs has %d elements, ssz-max is 4096: %w", numElem, ssz.ErrListTooBig) + } + c.Blobs = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte + + tmpSlice := sszSlice2[i*131072 : (1+i)*131072] + tmp = make([]byte, 0, 131072) + tmp = append(tmp, tmpSlice...) + c.Blobs[i] = tmp } } return err } -// SizeSSZ returns the ssz encoded size in bytes for the BeaconBlockContentsDeneb object -func (b *BeaconBlockContentsDeneb) SizeSSZ() (size int) { - size = 12 - - // Field (0) 'Block' - if b.Block == nil { - b.Block = new(BeaconBlockDeneb) +func (c *BeaconBlockContentsDeneb) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - size += b.Block.SizeSSZ() - - // Field (1) 'KzgProofs' - size += len(b.KzgProofs) * 48 - - // Field (2) 'Blobs' - size += len(b.Blobs) * 131072 - - return + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRoot ssz hashes the BeaconBlockContentsDeneb object -func (b *BeaconBlockContentsDeneb) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) -} - -// HashTreeRootWith ssz hashes the BeaconBlockContentsDeneb object with a hasher -func (b *BeaconBlockContentsDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *BeaconBlockContentsDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Block' - if err = b.Block.HashTreeRootWith(hh); err != nil { - return + // Field 0: Block + if err := c.Block.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Block: %w", err) } - - // Field (1) 'KzgProofs' + // Field 1: KzgProofs { - if size := len(b.KzgProofs); size > 4096 { - err = ssz.ErrListTooBigFn("--.KzgProofs", size, 4096) - return + if len(c.KzgProofs) > 4096 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range b.KzgProofs { - if len(i) != 48 { - err = ssz.ErrBytesLength - return + for _, o := range c.KzgProofs { + if len(o) != 48 { + return ssz.ErrBytesLength } - hh.PutBytes(i) + hh.PutBytes(o) } - - numItems := uint64(len(b.KzgProofs)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.KzgProofs)), 4096) } - - // Field (2) 'Blobs' + // Field 2: Blobs { - if size := len(b.Blobs); size > 4096 { - err = ssz.ErrListTooBigFn("--.Blobs", size, 4096) - return + if len(c.Blobs) > 4096 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range b.Blobs { - if len(i) != 131072 { - err = ssz.ErrBytesLength - return + for _, o := range c.Blobs { + if len(o) != 131072 { + return ssz.ErrBytesLength } - hh.PutBytes(i) + hh.PutBytes(o) } - - numItems := uint64(len(b.Blobs)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Blobs)), 4096) } - hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the BeaconBlockDeneb object -func (b *BeaconBlockDeneb) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) +func (c *BeaconBlockDeneb) SizeSSZ() int { + size := 84 + if c.Body == nil { + c.Body = new(BeaconBlockBodyDeneb) + } + size += c.Body.SizeSSZ() + return size } -// MarshalSSZTo ssz marshals the BeaconBlockDeneb object to a target array -func (b *BeaconBlockDeneb) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(84) +func (c *BeaconBlockDeneb) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (0) 'Slot' - dst = ssz.MarshalUint(dst, b.Slot) +func (c *BeaconBlockDeneb) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 84 - // Field (1) 'ProposerIndex' - dst = ssz.MarshalUint(dst, b.ProposerIndex) + // Field 0: Slot + if dst, err = c.Slot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Slot: %w", err) + } - // Field (2) 'ParentRoot' - if size := len(b.ParentRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentRoot", size, 32) - return + // Field 1: ProposerIndex + if dst, err = c.ProposerIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ProposerIndex: %w", err) } - dst = append(dst, b.ParentRoot...) - // Field (3) 'StateRoot' - if size := len(b.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return + // Field 2: ParentRoot + if len(c.ParentRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.StateRoot...) + dst = append(dst, c.ParentRoot...) - // Offset (4) 'Body' - dst = ssz.WriteOffset(dst, offset) - if b.Body == nil { - b.Body = new(BeaconBlockBodyDeneb) + // Field 3: StateRoot + if len(c.StateRoot) != 32 { + return nil, ssz.ErrBytesLength } - offset += b.Body.SizeSSZ() + dst = append(dst, c.StateRoot...) - // Field (4) 'Body' - if dst, err = b.Body.MarshalSSZTo(dst); err != nil { - return + // Field 4: Body + if c.Body == nil { + c.Body = new(BeaconBlockBodyDeneb) } + dst = ssz.WriteOffset(dst, offset) + offset += c.Body.SizeSSZ() - return + // Field 4: Body + if dst, err = c.Body.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Body: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the BeaconBlockDeneb object -func (b *BeaconBlockDeneb) UnmarshalSSZ(buf []byte) error { +func (c *BeaconBlockDeneb) 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.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[0:8]) + sszSlice0 := buf[0:8] // c.Slot + sszSlice1 := buf[8:16] // c.ProposerIndex + sszSlice2 := buf[16:48] // c.ParentRoot + sszSlice3 := buf[48:80] // c.StateRoot - // Field (1) 'ProposerIndex' - b.ProposerIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[8:16]) - - // Field (2) 'ParentRoot' - if cap(b.ParentRoot) == 0 { - b.ParentRoot = make([]byte, 0, len(buf[16:48])) + sszVarOffset4 := ssz.ReadOffset(buf[80:84]) // c.Body + if sszVarOffset4 != 84 { + return ssz.ErrInvalidVariableOffset } - 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])) + if sszVarOffset4 > size { + return ssz.ErrOffset } - b.StateRoot = append(b.StateRoot, buf[48:80]...) + sszSlice4 := buf[sszVarOffset4:] // c.Body - // Offset (4) 'Body' - if o4 = ssz.ReadOffset(buf[80:84]); o4 > size { - return ssz.ErrOffset + // Field 0: Slot + if err = c.Slot.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Slot: %w", err) } - if o4 != 84 { - return ssz.ErrInvalidVariableOffset + // Field 1: ProposerIndex + if err = c.ProposerIndex.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("ProposerIndex: %w", err) } - // Field (4) 'Body' - { - buf = tail[o4:] - if b.Body == nil { - b.Body = new(BeaconBlockBodyDeneb) - } - if err = b.Body.UnmarshalSSZ(buf); err != nil { - return err - } + // Field 2: ParentRoot + c.ParentRoot = make([]byte, 0, 32) + c.ParentRoot = append(c.ParentRoot, sszSlice2...) + + // Field 3: StateRoot + c.StateRoot = make([]byte, 0, 32) + c.StateRoot = append(c.StateRoot, sszSlice3...) + + // Field 4: Body + c.Body = new(BeaconBlockBodyDeneb) + if err = c.Body.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("Body: %w", err) } return err } -// SizeSSZ returns the ssz encoded size in bytes for the BeaconBlockDeneb object -func (b *BeaconBlockDeneb) SizeSSZ() (size int) { - size = 84 - - // Field (4) 'Body' - if b.Body == nil { - b.Body = new(BeaconBlockBodyDeneb) +func (c *BeaconBlockDeneb) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - size += b.Body.SizeSSZ() + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - return +func (c *BeaconBlockDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Slot + if err := c.Slot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Slot: %w", err) + } + // Field 1: ProposerIndex + if err := c.ProposerIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ProposerIndex: %w", err) + } + // Field 2: ParentRoot + if len(c.ParentRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ParentRoot) + // Field 3: StateRoot + if len(c.StateRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.StateRoot) + // Field 4: Body + if err := c.Body.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Body: %w", err) + } + hh.Merkleize(indx) + return nil } -// HashTreeRoot ssz hashes the BeaconBlockDeneb object -func (b *BeaconBlockDeneb) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) +func (c *BeaconStateDeneb) SizeSSZ() int { + size := 10253 + size += len(c.HistoricalRoots) * 32 + size += len(c.Eth1DataVotes) * 72 + size += len(c.Validators) * 121 + size += len(c.Balances) * 8 + size += len(c.PreviousEpochParticipation) + size += len(c.CurrentEpochParticipation) + size += len(c.InactivityScores) * 8 + if c.LatestExecutionPayloadHeader == nil { + c.LatestExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderDeneb) + } + size += c.LatestExecutionPayloadHeader.SizeSSZ() + size += len(c.HistoricalSummaries) * 64 + return size } -// HashTreeRootWith ssz hashes the BeaconBlockDeneb object with a hasher -func (b *BeaconBlockDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() +func (c *BeaconStateDeneb) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (0) 'Slot' - ssz.PutUint(hh, b.Slot) +func (c *BeaconStateDeneb) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 10253 - // Field (1) 'ProposerIndex' - ssz.PutUint(hh, b.ProposerIndex) + // Field 0: GenesisTime + dst = binary.LittleEndian.AppendUint64(dst, c.GenesisTime) - // Field (2) 'ParentRoot' - if size := len(b.ParentRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentRoot", size, 32) - return + // Field 1: GenesisValidatorsRoot + if len(c.GenesisValidatorsRoot) != 32 { + return nil, ssz.ErrBytesLength } - hh.PutBytes(b.ParentRoot) + dst = append(dst, c.GenesisValidatorsRoot...) - // Field (3) 'StateRoot' - if size := len(b.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return + // Field 2: Slot + if dst, err = c.Slot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Slot: %w", err) } - hh.PutBytes(b.StateRoot) - // Field (4) 'Body' - if err = b.Body.HashTreeRootWith(hh); err != nil { - return + // Field 3: Fork + if c.Fork == nil { + c.Fork = new(Fork) + } + if dst, err = c.Fork.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Fork: %w", err) } - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the BeaconBlockBodyDeneb object -func (b *BeaconBlockBodyDeneb) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} - -// MarshalSSZTo ssz marshals the BeaconBlockBodyDeneb object to a target array -func (b *BeaconBlockBodyDeneb) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(332) - - // Field (0) 'RandaoReveal' - if size := len(b.RandaoReveal); size != 96 { - err = ssz.ErrBytesLengthFn("--.RandaoReveal", size, 96) - return + // Field 4: LatestBlockHeader + if c.LatestBlockHeader == nil { + c.LatestBlockHeader = new(BeaconBlockHeader) + } + if dst, err = c.LatestBlockHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("LatestBlockHeader: %w", err) } - dst = append(dst, b.RandaoReveal...) - // Field (1) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(Eth1Data) + // Field 5: BlockRoots + if len(c.BlockRoots) != 64 { + return nil, ssz.ErrBytesLength } - if dst, err = b.Eth1Data.MarshalSSZTo(dst); err != nil { - return + for _, o := range c.BlockRoots { + if len(o) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) } - // Field (2) 'Graffiti' - if size := len(b.Graffiti); size != 32 { - err = ssz.ErrBytesLengthFn("--.Graffiti", size, 32) - return + // Field 6: StateRoots + if len(c.StateRoots) != 64 { + return nil, ssz.ErrBytesLength + } + for _, o := range c.StateRoots { + if len(o) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) } - dst = append(dst, b.Graffiti...) - // Offset (3) 'ProposerSlashings' + // Field 7: HistoricalRoots dst = ssz.WriteOffset(dst, offset) - offset += len(b.ProposerSlashings) * 416 + offset += len(c.HistoricalRoots) * 32 - // Offset (4) 'AttesterSlashings' - dst = ssz.WriteOffset(dst, offset) - for ii := 0; ii < len(b.AttesterSlashings); ii++ { - offset += 4 - offset += b.AttesterSlashings[ii].SizeSSZ() + // Field 8: Eth1Data + if c.Eth1Data == nil { + c.Eth1Data = new(Eth1Data) + } + if dst, err = c.Eth1Data.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Eth1Data: %w", err) } - // Offset (5) 'Attestations' + // Field 9: Eth1DataVotes dst = ssz.WriteOffset(dst, offset) - for ii := 0; ii < len(b.Attestations); ii++ { - offset += 4 - offset += b.Attestations[ii].SizeSSZ() - } + offset += len(c.Eth1DataVotes) * 72 + + // Field 10: Eth1DepositIndex + dst = binary.LittleEndian.AppendUint64(dst, c.Eth1DepositIndex) - // Offset (6) 'Deposits' + // Field 11: Validators dst = ssz.WriteOffset(dst, offset) - offset += len(b.Deposits) * 1240 + offset += len(c.Validators) * 121 - // Offset (7) 'VoluntaryExits' + // Field 12: Balances dst = ssz.WriteOffset(dst, offset) - offset += len(b.VoluntaryExits) * 112 + offset += len(c.Balances) * 8 - // Field (8) 'SyncAggregate' - if b.SyncAggregate == nil { - b.SyncAggregate = new(SyncAggregate) + // Field 13: RandaoMixes + if len(c.RandaoMixes) != 64 { + return nil, ssz.ErrBytesLength } - if dst, err = b.SyncAggregate.MarshalSSZTo(dst); err != nil { - return + for _, o := range c.RandaoMixes { + if len(o) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) } - // Offset (9) 'ExecutionPayload' - dst = ssz.WriteOffset(dst, offset) - if b.ExecutionPayload == nil { - b.ExecutionPayload = new(v1.ExecutionPayloadDeneb) + // Field 14: Slashings + if len(c.Slashings) != 64 { + return nil, ssz.ErrBytesLength + } + for _, o := range c.Slashings { + dst = binary.LittleEndian.AppendUint64(dst, o) } - offset += b.ExecutionPayload.SizeSSZ() - // Offset (10) 'BlsToExecutionChanges' + // Field 15: PreviousEpochParticipation dst = ssz.WriteOffset(dst, offset) - offset += len(b.BlsToExecutionChanges) * 172 + offset += len(c.PreviousEpochParticipation) - // Offset (11) 'BlobKzgCommitments' + // Field 16: CurrentEpochParticipation dst = ssz.WriteOffset(dst, offset) - offset += len(b.BlobKzgCommitments) * 48 + offset += len(c.CurrentEpochParticipation) - // Field (3) 'ProposerSlashings' - if size := len(b.ProposerSlashings); size > 16 { - err = ssz.ErrListTooBigFn("--.ProposerSlashings", size, 16) - return + // Field 17: JustificationBits + if len([]byte(c.JustificationBits)) != 1 { + return nil, ssz.ErrBytesLength } - for ii := 0; ii < len(b.ProposerSlashings); ii++ { - if dst, err = b.ProposerSlashings[ii].MarshalSSZTo(dst); err != nil { - return - } + dst = append(dst, []byte(c.JustificationBits)...) + + // Field 18: PreviousJustifiedCheckpoint + if c.PreviousJustifiedCheckpoint == nil { + c.PreviousJustifiedCheckpoint = new(Checkpoint) + } + if dst, err = c.PreviousJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("PreviousJustifiedCheckpoint: %w", err) } - // Field (4) 'AttesterSlashings' - if size := len(b.AttesterSlashings); size > 2 { - err = ssz.ErrListTooBigFn("--.AttesterSlashings", size, 2) - return + // Field 19: CurrentJustifiedCheckpoint + if c.CurrentJustifiedCheckpoint == nil { + c.CurrentJustifiedCheckpoint = new(Checkpoint) } - { - offset = 4 * len(b.AttesterSlashings) - for ii := 0; ii < len(b.AttesterSlashings); ii++ { - dst = ssz.WriteOffset(dst, offset) - offset += b.AttesterSlashings[ii].SizeSSZ() - } + if dst, err = c.CurrentJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("CurrentJustifiedCheckpoint: %w", err) } - for ii := 0; ii < len(b.AttesterSlashings); ii++ { - if dst, err = b.AttesterSlashings[ii].MarshalSSZTo(dst); err != nil { - return - } + + // Field 20: FinalizedCheckpoint + if c.FinalizedCheckpoint == nil { + c.FinalizedCheckpoint = new(Checkpoint) + } + if dst, err = c.FinalizedCheckpoint.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("FinalizedCheckpoint: %w", err) } - // Field (5) 'Attestations' - if size := len(b.Attestations); size > 128 { - err = ssz.ErrListTooBigFn("--.Attestations", size, 128) - return + // Field 21: InactivityScores + dst = ssz.WriteOffset(dst, offset) + offset += len(c.InactivityScores) * 8 + + // Field 22: CurrentSyncCommittee + if c.CurrentSyncCommittee == nil { + c.CurrentSyncCommittee = new(SyncCommittee) } - { - offset = 4 * len(b.Attestations) - for ii := 0; ii < len(b.Attestations); ii++ { - dst = ssz.WriteOffset(dst, offset) - offset += b.Attestations[ii].SizeSSZ() - } + if dst, err = c.CurrentSyncCommittee.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("CurrentSyncCommittee: %w", err) } - for ii := 0; ii < len(b.Attestations); ii++ { - if dst, err = b.Attestations[ii].MarshalSSZTo(dst); err != nil { - return - } + + // Field 23: NextSyncCommittee + if c.NextSyncCommittee == nil { + c.NextSyncCommittee = new(SyncCommittee) + } + if dst, err = c.NextSyncCommittee.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("NextSyncCommittee: %w", err) } - // Field (6) 'Deposits' - if size := len(b.Deposits); size > 16 { - err = ssz.ErrListTooBigFn("--.Deposits", size, 16) - return + // Field 24: LatestExecutionPayloadHeader + if c.LatestExecutionPayloadHeader == nil { + c.LatestExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderDeneb) } - for ii := 0; ii < len(b.Deposits); ii++ { - if dst, err = b.Deposits[ii].MarshalSSZTo(dst); err != nil { - return - } + dst = ssz.WriteOffset(dst, offset) + offset += c.LatestExecutionPayloadHeader.SizeSSZ() + + // Field 25: NextWithdrawalIndex + dst = binary.LittleEndian.AppendUint64(dst, c.NextWithdrawalIndex) + + // Field 26: NextWithdrawalValidatorIndex + if dst, err = c.NextWithdrawalValidatorIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("NextWithdrawalValidatorIndex: %w", err) } - // Field (7) 'VoluntaryExits' - if size := len(b.VoluntaryExits); size > 16 { - err = ssz.ErrListTooBigFn("--.VoluntaryExits", size, 16) - return + // Field 27: HistoricalSummaries + dst = ssz.WriteOffset(dst, offset) + offset += len(c.HistoricalSummaries) * 64 + + // Field 7: HistoricalRoots + if len(c.HistoricalRoots) > 16777216 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.VoluntaryExits); ii++ { - if dst, err = b.VoluntaryExits[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.HistoricalRoots { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, o...) } - // Field (9) 'ExecutionPayload' - if dst, err = b.ExecutionPayload.MarshalSSZTo(dst); err != nil { - return + // Field 9: Eth1DataVotes + if len(c.Eth1DataVotes) > 32 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.Eth1DataVotes { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Eth1DataVotes: %w", err) + } } - // Field (10) 'BlsToExecutionChanges' - if size := len(b.BlsToExecutionChanges); size > 16 { - err = ssz.ErrListTooBigFn("--.BlsToExecutionChanges", size, 16) - return + // Field 11: Validators + if len(c.Validators) > 1099511627776 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.BlsToExecutionChanges); ii++ { - if dst, err = b.BlsToExecutionChanges[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.Validators { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Validators: %w", err) } } - // Field (11) 'BlobKzgCommitments' - if size := len(b.BlobKzgCommitments); size > 4096 { - err = ssz.ErrListTooBigFn("--.BlobKzgCommitments", size, 4096) - return + // Field 12: Balances + if len(c.Balances) > 1099511627776 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.BlobKzgCommitments); ii++ { - if size := len(b.BlobKzgCommitments[ii]); size != 48 { - err = ssz.ErrBytesLengthFn("--.BlobKzgCommitments[ii]", size, 48) - return - } - dst = append(dst, b.BlobKzgCommitments[ii]...) + for _, o := range c.Balances { + dst = binary.LittleEndian.AppendUint64(dst, o) } - return -} + // Field 15: PreviousEpochParticipation + if len(c.PreviousEpochParticipation) > 1099511627776 { + return nil, ssz.ErrListTooBig + } + dst = append(dst, c.PreviousEpochParticipation...) -// UnmarshalSSZ ssz unmarshals the BeaconBlockBodyDeneb object -func (b *BeaconBlockBodyDeneb) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 332 { - return ssz.ErrSize + // Field 16: CurrentEpochParticipation + if len(c.CurrentEpochParticipation) > 1099511627776 { + return nil, ssz.ErrListTooBig } + dst = append(dst, c.CurrentEpochParticipation...) - tail := buf - var o3, o4, o5, o6, o7, o9, o10, o11 uint64 + // Field 21: InactivityScores + if len(c.InactivityScores) > 1099511627776 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.InactivityScores { + dst = binary.LittleEndian.AppendUint64(dst, o) + } - // Field (0) 'RandaoReveal' - if cap(b.RandaoReveal) == 0 { - b.RandaoReveal = make([]byte, 0, len(buf[0:96])) + // Field 24: LatestExecutionPayloadHeader + if dst, err = c.LatestExecutionPayloadHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("LatestExecutionPayloadHeader: %w", err) } - b.RandaoReveal = append(b.RandaoReveal, buf[0:96]...) - // Field (1) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(Eth1Data) + // Field 27: HistoricalSummaries + if len(c.HistoricalSummaries) > 16777216 { + return nil, ssz.ErrListTooBig } - if err = b.Eth1Data.UnmarshalSSZ(buf[96:168]); err != nil { - return err + for _, o := range c.HistoricalSummaries { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("HistoricalSummaries: %w", err) + } } + return dst, err +} - // Field (2) 'Graffiti' - if cap(b.Graffiti) == 0 { - b.Graffiti = make([]byte, 0, len(buf[168:200])) +func (c *BeaconStateDeneb) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 10253 { + return ssz.ErrSize } - b.Graffiti = append(b.Graffiti, buf[168:200]...) - // Offset (3) 'ProposerSlashings' - if o3 = ssz.ReadOffset(buf[200:204]); o3 > size { + sszSlice0 := buf[0:8] // c.GenesisTime + sszSlice1 := buf[8:40] // c.GenesisValidatorsRoot + sszSlice2 := buf[40:48] // c.Slot + sszSlice3 := buf[48:64] // c.Fork + sszSlice4 := buf[64:176] // c.LatestBlockHeader + sszSlice5 := buf[176:2224] // c.BlockRoots + sszSlice6 := buf[2224:4272] // c.StateRoots + sszSlice8 := buf[4276:4348] // c.Eth1Data + sszSlice10 := buf[4352:4360] // c.Eth1DepositIndex + sszSlice13 := buf[4368:6416] // c.RandaoMixes + sszSlice14 := buf[6416:6928] // c.Slashings + sszSlice17 := buf[6936:6937] // c.JustificationBits + sszSlice18 := buf[6937:6977] // c.PreviousJustifiedCheckpoint + sszSlice19 := buf[6977:7017] // c.CurrentJustifiedCheckpoint + sszSlice20 := buf[7017:7057] // c.FinalizedCheckpoint + sszSlice22 := buf[7061:8645] // c.CurrentSyncCommittee + sszSlice23 := buf[8645:10229] // c.NextSyncCommittee + sszSlice25 := buf[10233:10241] // c.NextWithdrawalIndex + sszSlice26 := buf[10241:10249] // c.NextWithdrawalValidatorIndex + + sszVarOffset7 := ssz.ReadOffset(buf[4272:4276]) // c.HistoricalRoots + if sszVarOffset7 != 10253 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset7 > size { return ssz.ErrOffset } - - if o3 != 332 { - return ssz.ErrInvalidVariableOffset + sszVarOffset9 := ssz.ReadOffset(buf[4348:4352]) // c.Eth1DataVotes + if sszVarOffset9 > size || sszVarOffset9 < sszVarOffset7 { + return ssz.ErrOffset } - - // Offset (4) 'AttesterSlashings' - if o4 = ssz.ReadOffset(buf[204:208]); o4 > size || o3 > o4 { + sszVarOffset11 := ssz.ReadOffset(buf[4360:4364]) // c.Validators + if sszVarOffset11 > size || sszVarOffset11 < sszVarOffset9 { return ssz.ErrOffset } - - // Offset (5) 'Attestations' - if o5 = ssz.ReadOffset(buf[208:212]); o5 > size || o4 > o5 { + sszVarOffset12 := ssz.ReadOffset(buf[4364:4368]) // c.Balances + if sszVarOffset12 > size || sszVarOffset12 < sszVarOffset11 { return ssz.ErrOffset } - - // Offset (6) 'Deposits' - if o6 = ssz.ReadOffset(buf[212:216]); o6 > size || o5 > o6 { + sszVarOffset15 := ssz.ReadOffset(buf[6928:6932]) // c.PreviousEpochParticipation + if sszVarOffset15 > size || sszVarOffset15 < sszVarOffset12 { return ssz.ErrOffset } - - // Offset (7) 'VoluntaryExits' - if o7 = ssz.ReadOffset(buf[216:220]); o7 > size || o6 > o7 { + sszVarOffset16 := ssz.ReadOffset(buf[6932:6936]) // c.CurrentEpochParticipation + if sszVarOffset16 > size || sszVarOffset16 < sszVarOffset15 { return ssz.ErrOffset } - - // Field (8) 'SyncAggregate' - if b.SyncAggregate == nil { - b.SyncAggregate = new(SyncAggregate) + sszVarOffset21 := ssz.ReadOffset(buf[7057:7061]) // c.InactivityScores + if sszVarOffset21 > size || sszVarOffset21 < sszVarOffset16 { + return ssz.ErrOffset } - if err = b.SyncAggregate.UnmarshalSSZ(buf[220:320]); err != nil { - return err + sszVarOffset24 := ssz.ReadOffset(buf[10229:10233]) // c.LatestExecutionPayloadHeader + if sszVarOffset24 > size || sszVarOffset24 < sszVarOffset21 { + return ssz.ErrOffset } - - // Offset (9) 'ExecutionPayload' - if o9 = ssz.ReadOffset(buf[320:324]); o9 > size || o7 > o9 { + sszVarOffset27 := ssz.ReadOffset(buf[10249:10253]) // c.HistoricalSummaries + if sszVarOffset27 > size || sszVarOffset27 < sszVarOffset24 { return ssz.ErrOffset } + sszSlice7 := buf[sszVarOffset7:sszVarOffset9] // c.HistoricalRoots + sszSlice9 := buf[sszVarOffset9:sszVarOffset11] // c.Eth1DataVotes + sszSlice11 := buf[sszVarOffset11:sszVarOffset12] // c.Validators + sszSlice12 := buf[sszVarOffset12:sszVarOffset15] // c.Balances + sszSlice15 := buf[sszVarOffset15:sszVarOffset16] // c.PreviousEpochParticipation + sszSlice16 := buf[sszVarOffset16:sszVarOffset21] // c.CurrentEpochParticipation + sszSlice21 := buf[sszVarOffset21:sszVarOffset24] // c.InactivityScores + sszSlice24 := buf[sszVarOffset24:sszVarOffset27] // c.LatestExecutionPayloadHeader + sszSlice27 := buf[sszVarOffset27:] // c.HistoricalSummaries - // Offset (10) 'BlsToExecutionChanges' - if o10 = ssz.ReadOffset(buf[324:328]); o10 > size || o9 > o10 { - return ssz.ErrOffset + // Field 0: GenesisTime + c.GenesisTime = binary.LittleEndian.Uint64(sszSlice0) + + // Field 1: GenesisValidatorsRoot + c.GenesisValidatorsRoot = make([]byte, 0, 32) + c.GenesisValidatorsRoot = append(c.GenesisValidatorsRoot, sszSlice1...) + + // Field 2: Slot + if err = c.Slot.UnmarshalSSZ(sszSlice2); err != nil { + return fmt.Errorf("Slot: %w", err) } - // Offset (11) 'BlobKzgCommitments' - if o11 = ssz.ReadOffset(buf[328:332]); o11 > size || o10 > o11 { - return ssz.ErrOffset + // Field 3: Fork + c.Fork = new(Fork) + if err = c.Fork.UnmarshalSSZ(sszSlice3); err != nil { + return fmt.Errorf("Fork: %w", err) } - // Field (3) 'ProposerSlashings' + // Field 4: LatestBlockHeader + c.LatestBlockHeader = new(BeaconBlockHeader) + if err = c.LatestBlockHeader.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("LatestBlockHeader: %w", err) + } + + // Field 5: BlockRoots { - buf = tail[o3:o4] - num, err := ssz.DivideInt2(len(buf), 416, 16) - if err != nil { - return err - } - b.ProposerSlashings = make([]*ProposerSlashing, num) - for ii := 0; ii < num; ii++ { - if b.ProposerSlashings[ii] == nil { - b.ProposerSlashings[ii] = new(ProposerSlashing) - } - if err = b.ProposerSlashings[ii].UnmarshalSSZ(buf[ii*416 : (ii+1)*416]); err != nil { - return err - } + c.BlockRoots = make([][]byte, 64) + for i := 0; i < 64; i++ { + var tmp []byte + + tmpSlice := sszSlice5[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.BlockRoots[i] = tmp } } - // Field (4) 'AttesterSlashings' + // Field 6: StateRoots { - buf = tail[o4:o5] - num, err := ssz.DecodeDynamicLength(buf, 2) - 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 + c.StateRoots = make([][]byte, 64) + for i := 0; i < 64; i++ { + var tmp []byte + + tmpSlice := sszSlice6[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.StateRoots[i] = tmp } } - // Field (5) 'Attestations' + // Field 7: HistoricalRoots { - buf = tail[o5:o6] - num, err := ssz.DecodeDynamicLength(buf, 128) - 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 + if len(sszSlice7)%32 != 0 { + return fmt.Errorf("misaligned bytes: c.HistoricalRoots length is %d, which is not a multiple of 32: %w", len(sszSlice7), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice7) / 32 + if numElem > 16777216 { + return fmt.Errorf("ssz-max exceeded: c.HistoricalRoots has %d elements, ssz-max is 16777216: %w", numElem, ssz.ErrListTooBig) + } + c.HistoricalRoots = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte + + tmpSlice := sszSlice7[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.HistoricalRoots[i] = tmp } } - // Field (6) 'Deposits' + // Field 8: Eth1Data + c.Eth1Data = new(Eth1Data) + if err = c.Eth1Data.UnmarshalSSZ(sszSlice8); err != nil { + return fmt.Errorf("Eth1Data: %w", err) + } + + // Field 9: Eth1DataVotes { - buf = tail[o6:o7] - num, err := ssz.DivideInt2(len(buf), 1240, 16) - if err != nil { - return err - } - b.Deposits = make([]*Deposit, num) - for ii := 0; ii < num; ii++ { - if b.Deposits[ii] == nil { - b.Deposits[ii] = new(Deposit) - } - if err = b.Deposits[ii].UnmarshalSSZ(buf[ii*1240 : (ii+1)*1240]); err != nil { - return err + if len(sszSlice9)%72 != 0 { + return fmt.Errorf("misaligned bytes: c.Eth1DataVotes length is %d, which is not a multiple of 72: %w", len(sszSlice9), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice9) / 72 + if numElem > 32 { + return fmt.Errorf("ssz-max exceeded: c.Eth1DataVotes has %d elements, ssz-max is 32: %w", numElem, ssz.ErrListTooBig) + } + c.Eth1DataVotes = make([]*Eth1Data, numElem) + for i := 0; i < numElem; i++ { + var tmp *Eth1Data + tmp = new(Eth1Data) + tmpSlice := sszSlice9[i*72 : (1+i)*72] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Eth1DataVotes: %w", err) } + c.Eth1DataVotes[i] = tmp } } - // Field (7) 'VoluntaryExits' + // Field 10: Eth1DepositIndex + c.Eth1DepositIndex = binary.LittleEndian.Uint64(sszSlice10) + + // Field 11: Validators { - buf = tail[o7:o9] - num, err := ssz.DivideInt2(len(buf), 112, 16) - if err != nil { - return err - } - b.VoluntaryExits = make([]*SignedVoluntaryExit, num) - for ii := 0; ii < num; ii++ { - if b.VoluntaryExits[ii] == nil { - b.VoluntaryExits[ii] = new(SignedVoluntaryExit) - } - if err = b.VoluntaryExits[ii].UnmarshalSSZ(buf[ii*112 : (ii+1)*112]); err != nil { - return err + if len(sszSlice11)%121 != 0 { + return fmt.Errorf("misaligned bytes: c.Validators length is %d, which is not a multiple of 121: %w", len(sszSlice11), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice11) / 121 + if numElem > 1099511627776 { + return fmt.Errorf("ssz-max exceeded: c.Validators has %d elements, ssz-max is 1099511627776: %w", numElem, ssz.ErrListTooBig) + } + c.Validators = make([]*Validator, numElem) + for i := 0; i < numElem; i++ { + var tmp *Validator + tmp = new(Validator) + tmpSlice := sszSlice11[i*121 : (1+i)*121] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Validators: %w", err) } + c.Validators[i] = tmp } } - // Field (9) 'ExecutionPayload' + // Field 12: Balances { - buf = tail[o9:o10] - if b.ExecutionPayload == nil { - b.ExecutionPayload = new(v1.ExecutionPayloadDeneb) + if len(sszSlice12)%8 != 0 { + return fmt.Errorf("misaligned bytes: c.Balances length is %d, which is not a multiple of 8: %w", len(sszSlice12), ssz.ErrIncorrectListSize) } - if err = b.ExecutionPayload.UnmarshalSSZ(buf); err != nil { - return err + numElem := len(sszSlice12) / 8 + if numElem > 1099511627776 { + return fmt.Errorf("ssz-max exceeded: c.Balances has %d elements, ssz-max is 1099511627776: %w", numElem, ssz.ErrListTooBig) + } + c.Balances = make([]uint64, numElem) + for i := 0; i < numElem; i++ { + var tmp uint64 + + tmpSlice := sszSlice12[i*8 : (1+i)*8] + tmp = binary.LittleEndian.Uint64(tmpSlice) + c.Balances[i] = tmp } } - // Field (10) 'BlsToExecutionChanges' + // Field 13: RandaoMixes { - buf = tail[o10:o11] - num, err := ssz.DivideInt2(len(buf), 172, 16) - if err != nil { - return err - } - b.BlsToExecutionChanges = make([]*SignedBLSToExecutionChange, num) - for ii := 0; ii < num; ii++ { - if b.BlsToExecutionChanges[ii] == nil { - b.BlsToExecutionChanges[ii] = new(SignedBLSToExecutionChange) - } - if err = b.BlsToExecutionChanges[ii].UnmarshalSSZ(buf[ii*172 : (ii+1)*172]); err != nil { - return err - } + c.RandaoMixes = make([][]byte, 64) + for i := 0; i < 64; i++ { + var tmp []byte + + tmpSlice := sszSlice13[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.RandaoMixes[i] = tmp } } - // Field (11) 'BlobKzgCommitments' + // Field 14: Slashings { - buf = tail[o11:] - num, err := ssz.DivideInt2(len(buf), 48, 4096) - if err != nil { - return err - } - b.BlobKzgCommitments = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(b.BlobKzgCommitments[ii]) == 0 { - b.BlobKzgCommitments[ii] = make([]byte, 0, len(buf[ii*48:(ii+1)*48])) - } - b.BlobKzgCommitments[ii] = append(b.BlobKzgCommitments[ii], buf[ii*48:(ii+1)*48]...) + c.Slashings = make([]uint64, 64) + for i := 0; i < 64; i++ { + var tmp uint64 + + tmpSlice := sszSlice14[i*8 : (1+i)*8] + tmp = binary.LittleEndian.Uint64(tmpSlice) + c.Slashings[i] = tmp } } - return err -} -// SizeSSZ returns the ssz encoded size in bytes for the BeaconBlockBodyDeneb object -func (b *BeaconBlockBodyDeneb) SizeSSZ() (size int) { - size = 332 + // Field 15: PreviousEpochParticipation + c.PreviousEpochParticipation = append([]byte{}, sszSlice15...) - // Field (3) 'ProposerSlashings' - size += len(b.ProposerSlashings) * 416 + // Field 16: CurrentEpochParticipation + c.CurrentEpochParticipation = append([]byte{}, sszSlice16...) - // Field (4) 'AttesterSlashings' - for ii := 0; ii < len(b.AttesterSlashings); ii++ { - size += 4 - size += b.AttesterSlashings[ii].SizeSSZ() + // Field 17: JustificationBits + c.JustificationBits = make([]byte, 0, 1) + c.JustificationBits = append(c.JustificationBits, go_bitfield.Bitvector4(sszSlice17)...) + + // Field 18: PreviousJustifiedCheckpoint + c.PreviousJustifiedCheckpoint = new(Checkpoint) + if err = c.PreviousJustifiedCheckpoint.UnmarshalSSZ(sszSlice18); err != nil { + return fmt.Errorf("PreviousJustifiedCheckpoint: %w", err) } - // Field (5) 'Attestations' - for ii := 0; ii < len(b.Attestations); ii++ { - size += 4 - size += b.Attestations[ii].SizeSSZ() + // Field 19: CurrentJustifiedCheckpoint + c.CurrentJustifiedCheckpoint = new(Checkpoint) + if err = c.CurrentJustifiedCheckpoint.UnmarshalSSZ(sszSlice19); err != nil { + return fmt.Errorf("CurrentJustifiedCheckpoint: %w", err) } - // Field (6) 'Deposits' - size += len(b.Deposits) * 1240 + // Field 20: FinalizedCheckpoint + c.FinalizedCheckpoint = new(Checkpoint) + if err = c.FinalizedCheckpoint.UnmarshalSSZ(sszSlice20); err != nil { + return fmt.Errorf("FinalizedCheckpoint: %w", err) + } - // Field (7) 'VoluntaryExits' - size += len(b.VoluntaryExits) * 112 + // Field 21: InactivityScores + { + if len(sszSlice21)%8 != 0 { + return fmt.Errorf("misaligned bytes: c.InactivityScores length is %d, which is not a multiple of 8: %w", len(sszSlice21), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice21) / 8 + if numElem > 1099511627776 { + return fmt.Errorf("ssz-max exceeded: c.InactivityScores has %d elements, ssz-max is 1099511627776: %w", numElem, ssz.ErrListTooBig) + } + c.InactivityScores = make([]uint64, numElem) + for i := 0; i < numElem; i++ { + var tmp uint64 - // Field (9) 'ExecutionPayload' - if b.ExecutionPayload == nil { - b.ExecutionPayload = new(v1.ExecutionPayloadDeneb) + tmpSlice := sszSlice21[i*8 : (1+i)*8] + tmp = binary.LittleEndian.Uint64(tmpSlice) + c.InactivityScores[i] = tmp + } } - size += b.ExecutionPayload.SizeSSZ() - - // Field (10) 'BlsToExecutionChanges' - size += len(b.BlsToExecutionChanges) * 172 - // Field (11) 'BlobKzgCommitments' - size += len(b.BlobKzgCommitments) * 48 + // Field 22: CurrentSyncCommittee + c.CurrentSyncCommittee = new(SyncCommittee) + if err = c.CurrentSyncCommittee.UnmarshalSSZ(sszSlice22); err != nil { + return fmt.Errorf("CurrentSyncCommittee: %w", err) + } - return -} + // Field 23: NextSyncCommittee + c.NextSyncCommittee = new(SyncCommittee) + if err = c.NextSyncCommittee.UnmarshalSSZ(sszSlice23); err != nil { + return fmt.Errorf("NextSyncCommittee: %w", err) + } -// HashTreeRoot ssz hashes the BeaconBlockBodyDeneb object -func (b *BeaconBlockBodyDeneb) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) -} + // Field 24: LatestExecutionPayloadHeader + c.LatestExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderDeneb) + if err = c.LatestExecutionPayloadHeader.UnmarshalSSZ(sszSlice24); err != nil { + return fmt.Errorf("LatestExecutionPayloadHeader: %w", err) + } -// HashTreeRootWith ssz hashes the BeaconBlockBodyDeneb object with a hasher -func (b *BeaconBlockBodyDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() + // Field 25: NextWithdrawalIndex + c.NextWithdrawalIndex = binary.LittleEndian.Uint64(sszSlice25) - // Field (0) 'RandaoReveal' - if size := len(b.RandaoReveal); size != 96 { - err = ssz.ErrBytesLengthFn("--.RandaoReveal", size, 96) - return + // Field 26: NextWithdrawalValidatorIndex + if err = c.NextWithdrawalValidatorIndex.UnmarshalSSZ(sszSlice26); err != nil { + return fmt.Errorf("NextWithdrawalValidatorIndex: %w", err) } - hh.PutBytes(b.RandaoReveal) - // Field (1) 'Eth1Data' - if err = b.Eth1Data.HashTreeRootWith(hh); err != nil { - return + // Field 27: HistoricalSummaries + { + if len(sszSlice27)%64 != 0 { + return fmt.Errorf("misaligned bytes: c.HistoricalSummaries length is %d, which is not a multiple of 64: %w", len(sszSlice27), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice27) / 64 + if numElem > 16777216 { + return fmt.Errorf("ssz-max exceeded: c.HistoricalSummaries has %d elements, ssz-max is 16777216: %w", numElem, ssz.ErrListTooBig) + } + c.HistoricalSummaries = make([]*HistoricalSummary, numElem) + for i := 0; i < numElem; i++ { + var tmp *HistoricalSummary + tmp = new(HistoricalSummary) + tmpSlice := sszSlice27[i*64 : (1+i)*64] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("HistoricalSummaries: %w", err) + } + c.HistoricalSummaries[i] = tmp + } } + return err +} - // Field (2) 'Graffiti' - if size := len(b.Graffiti); size != 32 { - err = ssz.ErrBytesLengthFn("--.Graffiti", size, 32) - return +func (c *BeaconStateDeneb) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - hh.PutBytes(b.Graffiti) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (3) 'ProposerSlashings' +func (c *BeaconStateDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: GenesisTime + hh.PutUint64(c.GenesisTime) + // Field 1: GenesisValidatorsRoot + if len(c.GenesisValidatorsRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.GenesisValidatorsRoot) + // Field 2: Slot + if err := c.Slot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Slot: %w", err) + } + // Field 3: Fork + if err := c.Fork.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Fork: %w", err) + } + // Field 4: LatestBlockHeader + if err := c.LatestBlockHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("LatestBlockHeader: %w", err) + } + // Field 5: BlockRoots { + if len(c.BlockRoots) != 64 { + return ssz.ErrVectorLength + } 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 + for _, o := range c.BlockRoots { + if len(o) != 32 { + return ssz.ErrBytesLength } + hh.Append(o) } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.Merkleize(subIndx) } - - // Field (4) 'AttesterSlashings' + // Field 6: StateRoots { + if len(c.StateRoots) != 64 { + return ssz.ErrVectorLength + } 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 + for _, o := range c.StateRoots { + if len(o) != 32 { + return ssz.ErrBytesLength } + hh.Append(o) } - hh.MerkleizeWithMixin(subIndx, num, 2) + hh.Merkleize(subIndx) } - - // Field (5) 'Attestations' + // Field 7: HistoricalRoots { + if len(c.HistoricalRoots) > 16777216 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.HistoricalRoots { + if len(o) != 32 { + return ssz.ErrBytesLength } + hh.Append(o) } - hh.MerkleizeWithMixin(subIndx, num, 128) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.HistoricalRoots)), 16777216) } - - // Field (6) 'Deposits' + // Field 8: Eth1Data + if err := c.Eth1Data.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Eth1Data: %w", err) + } + // Field 9: Eth1DataVotes { + if len(c.Eth1DataVotes) > 32 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.Eth1DataVotes { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Eth1DataVotes: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Eth1DataVotes)), 32) } - - // Field (7) 'VoluntaryExits' + // Field 10: Eth1DepositIndex + hh.PutUint64(c.Eth1DepositIndex) + // Field 11: Validators { + if len(c.Validators) > 1099511627776 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.Validators { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Validators: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 16) - } - - // Field (8) 'SyncAggregate' - if err = b.SyncAggregate.HashTreeRootWith(hh); err != nil { - return - } - - // Field (9) 'ExecutionPayload' - if err = b.ExecutionPayload.HashTreeRootWith(hh); err != nil { - return + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Validators)), 1099511627776) } - - // Field (10) 'BlsToExecutionChanges' + // Field 12: Balances { + if len(c.Balances) > 1099511627776 { + return ssz.ErrListTooBig + } 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 - } + for _, o := range c.Balances { + hh.AppendUint64(o) } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.FillUpTo32() + numItems := uint64(len(c.Balances)) + hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(1099511627776, numItems, 8)) } - - // Field (11) 'BlobKzgCommitments' + // Field 13: RandaoMixes { - if size := len(b.BlobKzgCommitments); size > 4096 { - err = ssz.ErrListTooBigFn("--.BlobKzgCommitments", size, 4096) - return + if len(c.RandaoMixes) != 64 { + return ssz.ErrVectorLength } subIndx := hh.Index() - for _, i := range b.BlobKzgCommitments { - if len(i) != 48 { - err = ssz.ErrBytesLength - return + for _, o := range c.RandaoMixes { + if len(o) != 32 { + return ssz.ErrBytesLength } - hh.PutBytes(i) + hh.Append(o) } - - numItems := uint64(len(b.BlobKzgCommitments)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) - } - - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the SignedBlindedBeaconBlockDeneb object -func (s *SignedBlindedBeaconBlockDeneb) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) -} - -// MarshalSSZTo ssz marshals the SignedBlindedBeaconBlockDeneb object to a target array -func (s *SignedBlindedBeaconBlockDeneb) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(100) - - // Offset (0) 'Message' - dst = ssz.WriteOffset(dst, offset) - if s.Message == nil { - s.Message = new(BlindedBeaconBlockDeneb) - } - offset += s.Message.SizeSSZ() - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return - } - dst = append(dst, s.Signature...) - - // Field (0) 'Message' - if dst, err = s.Message.MarshalSSZTo(dst); err != nil { - return - } - - return -} - -// UnmarshalSSZ ssz unmarshals the SignedBlindedBeaconBlockDeneb object -func (s *SignedBlindedBeaconBlockDeneb) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 100 { - return ssz.ErrSize - } - - tail := buf - var o0 uint64 - - // Offset (0) 'Message' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } - - if o0 != 100 { - return ssz.ErrInvalidVariableOffset - } - - // Field (1) 'Signature' - if cap(s.Signature) == 0 { - s.Signature = make([]byte, 0, len(buf[4:100])) + hh.Merkleize(subIndx) } - s.Signature = append(s.Signature, buf[4:100]...) - - // Field (0) 'Message' + // Field 14: Slashings { - buf = tail[o0:] - if s.Message == nil { - s.Message = new(BlindedBeaconBlockDeneb) + if len(c.Slashings) != 64 { + return ssz.ErrVectorLength } - if err = s.Message.UnmarshalSSZ(buf); err != nil { - return err + subIndx := hh.Index() + for _, o := range c.Slashings { + hh.AppendUint64(o) } + hh.Merkleize(subIndx) } - return err -} + // Field 15: PreviousEpochParticipation -// SizeSSZ returns the ssz encoded size in bytes for the SignedBlindedBeaconBlockDeneb object -func (s *SignedBlindedBeaconBlockDeneb) SizeSSZ() (size int) { - size = 100 - - // Field (0) 'Message' - if s.Message == nil { - s.Message = new(BlindedBeaconBlockDeneb) + { + if len(c.PreviousEpochParticipation) > 1099511627776 { + return ssz.ErrBytesLength + } + subIndx := hh.Index() + hh.AppendBytes32(c.PreviousEpochParticipation) + numItems := uint64(len(c.PreviousEpochParticipation)) + hh.MerkleizeWithMixin(subIndx, numItems, (1099511627776*1+31)/32) } - size += s.Message.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the SignedBlindedBeaconBlockDeneb object -func (s *SignedBlindedBeaconBlockDeneb) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) -} - -// HashTreeRootWith ssz hashes the SignedBlindedBeaconBlockDeneb object with a hasher -func (s *SignedBlindedBeaconBlockDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - // Field (0) 'Message' - if err = s.Message.HashTreeRootWith(hh); err != nil { - return - } + // Field 16: CurrentEpochParticipation - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + { + if len(c.CurrentEpochParticipation) > 1099511627776 { + return ssz.ErrBytesLength + } + subIndx := hh.Index() + hh.AppendBytes32(c.CurrentEpochParticipation) + numItems := uint64(len(c.CurrentEpochParticipation)) + hh.MerkleizeWithMixin(subIndx, numItems, (1099511627776*1+31)/32) } - hh.PutBytes(s.Signature) - - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the BlindedBeaconBlockDeneb object -func (b *BlindedBeaconBlockDeneb) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} - -// MarshalSSZTo ssz marshals the BlindedBeaconBlockDeneb object to a target array -func (b *BlindedBeaconBlockDeneb) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(84) - - // Field (0) 'Slot' - dst = ssz.MarshalUint(dst, b.Slot) - - // Field (1) 'ProposerIndex' - dst = ssz.MarshalUint(dst, b.ProposerIndex) - // Field (2) 'ParentRoot' - if size := len(b.ParentRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentRoot", size, 32) - return + // Field 17: JustificationBits + if len([]byte(c.JustificationBits)) != 1 { + return ssz.ErrBytesLength } - dst = append(dst, b.ParentRoot...) - - // Field (3) 'StateRoot' - if size := len(b.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return + hh.PutBytes([]byte(c.JustificationBits)) + // Field 18: PreviousJustifiedCheckpoint + if err := c.PreviousJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("PreviousJustifiedCheckpoint: %w", err) } - dst = append(dst, b.StateRoot...) - - // Offset (4) 'Body' - dst = ssz.WriteOffset(dst, offset) - if b.Body == nil { - b.Body = new(BlindedBeaconBlockBodyDeneb) + // Field 19: CurrentJustifiedCheckpoint + if err := c.CurrentJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("CurrentJustifiedCheckpoint: %w", err) } - offset += b.Body.SizeSSZ() - - // Field (4) 'Body' - if dst, err = b.Body.MarshalSSZTo(dst); err != nil { - return + // Field 20: FinalizedCheckpoint + if err := c.FinalizedCheckpoint.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("FinalizedCheckpoint: %w", err) } - - return -} - -// UnmarshalSSZ ssz unmarshals the BlindedBeaconBlockDeneb object -func (b *BlindedBeaconBlockDeneb) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 84 { - return ssz.ErrSize + // Field 21: InactivityScores + { + if len(c.InactivityScores) > 1099511627776 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.InactivityScores { + hh.AppendUint64(o) + } + hh.FillUpTo32() + numItems := uint64(len(c.InactivityScores)) + hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(1099511627776, numItems, 8)) } - - tail := buf - var o4 uint64 - - // Field (0) 'Slot' - b.Slot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[0:8]) - - // Field (1) 'ProposerIndex' - b.ProposerIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[8:16]) - - // Field (2) 'ParentRoot' - if cap(b.ParentRoot) == 0 { - b.ParentRoot = make([]byte, 0, len(buf[16:48])) + // Field 22: CurrentSyncCommittee + if err := c.CurrentSyncCommittee.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("CurrentSyncCommittee: %w", err) } - 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])) + // Field 23: NextSyncCommittee + if err := c.NextSyncCommittee.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("NextSyncCommittee: %w", err) } - b.StateRoot = append(b.StateRoot, buf[48:80]...) - - // Offset (4) 'Body' - if o4 = ssz.ReadOffset(buf[80:84]); o4 > size { - return ssz.ErrOffset + // Field 24: LatestExecutionPayloadHeader + if err := c.LatestExecutionPayloadHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("LatestExecutionPayloadHeader: %w", err) } - - if o4 != 84 { - return ssz.ErrInvalidVariableOffset + // Field 25: NextWithdrawalIndex + hh.PutUint64(c.NextWithdrawalIndex) + // Field 26: NextWithdrawalValidatorIndex + if err := c.NextWithdrawalValidatorIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("NextWithdrawalValidatorIndex: %w", err) } - - // Field (4) 'Body' + // Field 27: HistoricalSummaries { - buf = tail[o4:] - if b.Body == nil { - b.Body = new(BlindedBeaconBlockBodyDeneb) + if len(c.HistoricalSummaries) > 16777216 { + return ssz.ErrListTooBig } - if err = b.Body.UnmarshalSSZ(buf); err != nil { - return err + subIndx := hh.Index() + for _, o := range c.HistoricalSummaries { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("HistoricalSummaries: %w", err) + } } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.HistoricalSummaries)), 16777216) } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the BlindedBeaconBlockDeneb object -func (b *BlindedBeaconBlockDeneb) SizeSSZ() (size int) { - size = 84 - - // Field (4) 'Body' - if b.Body == nil { - b.Body = new(BlindedBeaconBlockBodyDeneb) - } - size += b.Body.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the BlindedBeaconBlockDeneb object -func (b *BlindedBeaconBlockDeneb) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) + hh.Merkleize(indx) + return nil } -// HashTreeRootWith ssz hashes the BlindedBeaconBlockDeneb object with a hasher -func (b *BlindedBeaconBlockDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'Slot' - ssz.PutUint(hh, b.Slot) - - // Field (1) 'ProposerIndex' - ssz.PutUint(hh, b.ProposerIndex) - - // Field (2) 'ParentRoot' - if size := len(b.ParentRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentRoot", size, 32) - return +func (c *BlindedBeaconBlockBodyDeneb) SizeSSZ() int { + size := 332 + size += len(c.ProposerSlashings) * 416 + for _, o := range c.AttesterSlashings { + size += 4 + size += o.SizeSSZ() } - hh.PutBytes(b.ParentRoot) - - // Field (3) 'StateRoot' - if size := len(b.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return + for _, o := range c.Attestations { + size += 4 + size += o.SizeSSZ() } - hh.PutBytes(b.StateRoot) - - // Field (4) 'Body' - if err = b.Body.HashTreeRootWith(hh); err != nil { - return + size += len(c.Deposits) * 1240 + size += len(c.VoluntaryExits) * 112 + if c.ExecutionPayloadHeader == nil { + c.ExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderDeneb) } - - hh.Merkleize(indx) - return + size += c.ExecutionPayloadHeader.SizeSSZ() + size += len(c.BlsToExecutionChanges) * 172 + size += len(c.BlobKzgCommitments) * 48 + return size } -// MarshalSSZ ssz marshals the BlindedBeaconBlockBodyDeneb object -func (b *BlindedBeaconBlockBodyDeneb) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) +func (c *BlindedBeaconBlockBodyDeneb) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the BlindedBeaconBlockBodyDeneb object to a target array -func (b *BlindedBeaconBlockBodyDeneb) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(332) +func (c *BlindedBeaconBlockBodyDeneb) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 332 - // Field (0) 'RandaoReveal' - if size := len(b.RandaoReveal); size != 96 { - err = ssz.ErrBytesLengthFn("--.RandaoReveal", size, 96) - return + // Field 0: RandaoReveal + if len(c.RandaoReveal) != 96 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.RandaoReveal...) + dst = append(dst, c.RandaoReveal...) - // Field (1) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(Eth1Data) + // Field 1: Eth1Data + if c.Eth1Data == nil { + c.Eth1Data = new(Eth1Data) } - if dst, err = b.Eth1Data.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.Eth1Data.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Eth1Data: %w", err) } - // Field (2) 'Graffiti' - if size := len(b.Graffiti); size != 32 { - err = ssz.ErrBytesLengthFn("--.Graffiti", size, 32) - return + // Field 2: Graffiti + if len(c.Graffiti) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.Graffiti...) + dst = append(dst, c.Graffiti...) - // Offset (3) 'ProposerSlashings' + // Field 3: ProposerSlashings dst = ssz.WriteOffset(dst, offset) - offset += len(b.ProposerSlashings) * 416 + offset += len(c.ProposerSlashings) * 416 - // Offset (4) 'AttesterSlashings' + // Field 4: AttesterSlashings dst = ssz.WriteOffset(dst, offset) - for ii := 0; ii < len(b.AttesterSlashings); ii++ { + for _, o := range c.AttesterSlashings { offset += 4 - offset += b.AttesterSlashings[ii].SizeSSZ() + offset += o.SizeSSZ() } - // Offset (5) 'Attestations' + // Field 5: Attestations dst = ssz.WriteOffset(dst, offset) - for ii := 0; ii < len(b.Attestations); ii++ { + for _, o := range c.Attestations { offset += 4 - offset += b.Attestations[ii].SizeSSZ() + offset += o.SizeSSZ() } - // Offset (6) 'Deposits' + // Field 6: Deposits dst = ssz.WriteOffset(dst, offset) - offset += len(b.Deposits) * 1240 + offset += len(c.Deposits) * 1240 - // Offset (7) 'VoluntaryExits' + // Field 7: VoluntaryExits dst = ssz.WriteOffset(dst, offset) - offset += len(b.VoluntaryExits) * 112 + offset += len(c.VoluntaryExits) * 112 - // Field (8) 'SyncAggregate' - if b.SyncAggregate == nil { - b.SyncAggregate = new(SyncAggregate) + // Field 8: SyncAggregate + if c.SyncAggregate == nil { + c.SyncAggregate = new(SyncAggregate) } - if dst, err = b.SyncAggregate.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.SyncAggregate.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SyncAggregate: %w", err) } - // Offset (9) 'ExecutionPayloadHeader' - dst = ssz.WriteOffset(dst, offset) - if b.ExecutionPayloadHeader == nil { - b.ExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderDeneb) + // Field 9: ExecutionPayloadHeader + if c.ExecutionPayloadHeader == nil { + c.ExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderDeneb) } - offset += b.ExecutionPayloadHeader.SizeSSZ() + dst = ssz.WriteOffset(dst, offset) + offset += c.ExecutionPayloadHeader.SizeSSZ() - // Offset (10) 'BlsToExecutionChanges' + // Field 10: BlsToExecutionChanges dst = ssz.WriteOffset(dst, offset) - offset += len(b.BlsToExecutionChanges) * 172 + offset += len(c.BlsToExecutionChanges) * 172 - // Offset (11) 'BlobKzgCommitments' + // Field 11: BlobKzgCommitments dst = ssz.WriteOffset(dst, offset) - offset += len(b.BlobKzgCommitments) * 48 + offset += len(c.BlobKzgCommitments) * 48 - // Field (3) 'ProposerSlashings' - if size := len(b.ProposerSlashings); size > 16 { - err = ssz.ErrListTooBigFn("--.ProposerSlashings", size, 16) - return + // Field 3: ProposerSlashings + if len(c.ProposerSlashings) > 16 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.ProposerSlashings); ii++ { - if dst, err = b.ProposerSlashings[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.ProposerSlashings { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ProposerSlashings: %w", err) } } - // Field (4) 'AttesterSlashings' - if size := len(b.AttesterSlashings); size > 2 { - err = ssz.ErrListTooBigFn("--.AttesterSlashings", size, 2) - return + // Field 4: AttesterSlashings + if len(c.AttesterSlashings) > 2 { + return nil, ssz.ErrListTooBig } { - offset = 4 * len(b.AttesterSlashings) - for ii := 0; ii < len(b.AttesterSlashings); ii++ { + offset = 4 * len(c.AttesterSlashings) + for _, o := range c.AttesterSlashings { dst = ssz.WriteOffset(dst, offset) - offset += b.AttesterSlashings[ii].SizeSSZ() + offset += o.SizeSSZ() } } - for ii := 0; ii < len(b.AttesterSlashings); ii++ { - if dst, err = b.AttesterSlashings[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.AttesterSlashings { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("AttesterSlashings: %w", err) } } - // Field (5) 'Attestations' - if size := len(b.Attestations); size > 128 { - err = ssz.ErrListTooBigFn("--.Attestations", size, 128) - return + // Field 5: Attestations + if len(c.Attestations) > 128 { + return nil, ssz.ErrListTooBig } { - offset = 4 * len(b.Attestations) - for ii := 0; ii < len(b.Attestations); ii++ { + offset = 4 * len(c.Attestations) + for _, o := range c.Attestations { dst = ssz.WriteOffset(dst, offset) - offset += b.Attestations[ii].SizeSSZ() + offset += o.SizeSSZ() } } - for ii := 0; ii < len(b.Attestations); ii++ { - if dst, err = b.Attestations[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.Attestations { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Attestations: %w", err) } } - // Field (6) 'Deposits' - if size := len(b.Deposits); size > 16 { - err = ssz.ErrListTooBigFn("--.Deposits", size, 16) - return + // Field 6: Deposits + if len(c.Deposits) > 16 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.Deposits); ii++ { - if dst, err = b.Deposits[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.Deposits { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Deposits: %w", err) } } - // Field (7) 'VoluntaryExits' - if size := len(b.VoluntaryExits); size > 16 { - err = ssz.ErrListTooBigFn("--.VoluntaryExits", size, 16) - return + // Field 7: VoluntaryExits + if len(c.VoluntaryExits) > 16 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.VoluntaryExits); ii++ { - if dst, err = b.VoluntaryExits[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.VoluntaryExits { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("VoluntaryExits: %w", err) } } - // Field (9) 'ExecutionPayloadHeader' - if dst, err = b.ExecutionPayloadHeader.MarshalSSZTo(dst); err != nil { - return + // Field 9: ExecutionPayloadHeader + if dst, err = c.ExecutionPayloadHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ExecutionPayloadHeader: %w", err) } - // Field (10) 'BlsToExecutionChanges' - if size := len(b.BlsToExecutionChanges); size > 16 { - err = ssz.ErrListTooBigFn("--.BlsToExecutionChanges", size, 16) - return + // Field 10: BlsToExecutionChanges + if len(c.BlsToExecutionChanges) > 16 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.BlsToExecutionChanges); ii++ { - if dst, err = b.BlsToExecutionChanges[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.BlsToExecutionChanges { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("BlsToExecutionChanges: %w", err) } } - // Field (11) 'BlobKzgCommitments' - if size := len(b.BlobKzgCommitments); size > 4096 { - err = ssz.ErrListTooBigFn("--.BlobKzgCommitments", size, 4096) - return + // Field 11: BlobKzgCommitments + if len(c.BlobKzgCommitments) > 4096 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.BlobKzgCommitments); ii++ { - if size := len(b.BlobKzgCommitments[ii]); size != 48 { - err = ssz.ErrBytesLengthFn("--.BlobKzgCommitments[ii]", size, 48) - return + for _, o := range c.BlobKzgCommitments { + if len(o) != 48 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.BlobKzgCommitments[ii]...) + dst = append(dst, o...) } - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the BlindedBeaconBlockBodyDeneb object -func (b *BlindedBeaconBlockBodyDeneb) UnmarshalSSZ(buf []byte) error { +func (c *BlindedBeaconBlockBodyDeneb) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size < 332 { return ssz.ErrSize } - tail := buf - var o3, o4, o5, o6, o7, o9, o10, o11 uint64 + sszSlice0 := buf[0:96] // c.RandaoReveal + sszSlice1 := buf[96:168] // c.Eth1Data + sszSlice2 := buf[168:200] // c.Graffiti + sszSlice8 := buf[220:320] // c.SyncAggregate - // Field (0) 'RandaoReveal' - if cap(b.RandaoReveal) == 0 { - b.RandaoReveal = make([]byte, 0, len(buf[0:96])) + sszVarOffset3 := ssz.ReadOffset(buf[200:204]) // c.ProposerSlashings + if sszVarOffset3 != 332 { + return ssz.ErrInvalidVariableOffset } - b.RandaoReveal = append(b.RandaoReveal, buf[0:96]...) - - // Field (1) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(Eth1Data) + if sszVarOffset3 > size { + return ssz.ErrOffset } - if err = b.Eth1Data.UnmarshalSSZ(buf[96:168]); err != nil { - return err + sszVarOffset4 := ssz.ReadOffset(buf[204:208]) // c.AttesterSlashings + if sszVarOffset4 > size || sszVarOffset4 < sszVarOffset3 { + return ssz.ErrOffset } - - // Field (2) 'Graffiti' - if cap(b.Graffiti) == 0 { - b.Graffiti = make([]byte, 0, len(buf[168:200])) + sszVarOffset5 := ssz.ReadOffset(buf[208:212]) // c.Attestations + if sszVarOffset5 > size || sszVarOffset5 < sszVarOffset4 { + return ssz.ErrOffset } - b.Graffiti = append(b.Graffiti, buf[168:200]...) - - // Offset (3) 'ProposerSlashings' - if o3 = ssz.ReadOffset(buf[200:204]); o3 > size { + sszVarOffset6 := ssz.ReadOffset(buf[212:216]) // c.Deposits + if sszVarOffset6 > size || sszVarOffset6 < sszVarOffset5 { return ssz.ErrOffset } - - if o3 != 332 { - return ssz.ErrInvalidVariableOffset - } - - // Offset (4) 'AttesterSlashings' - if o4 = ssz.ReadOffset(buf[204:208]); o4 > size || o3 > o4 { + sszVarOffset7 := ssz.ReadOffset(buf[216:220]) // c.VoluntaryExits + if sszVarOffset7 > size || sszVarOffset7 < sszVarOffset6 { return ssz.ErrOffset } - - // Offset (5) 'Attestations' - if o5 = ssz.ReadOffset(buf[208:212]); o5 > size || o4 > o5 { + sszVarOffset9 := ssz.ReadOffset(buf[320:324]) // c.ExecutionPayloadHeader + if sszVarOffset9 > size || sszVarOffset9 < sszVarOffset7 { return ssz.ErrOffset } - - // Offset (6) 'Deposits' - if o6 = ssz.ReadOffset(buf[212:216]); o6 > size || o5 > o6 { + sszVarOffset10 := ssz.ReadOffset(buf[324:328]) // c.BlsToExecutionChanges + if sszVarOffset10 > size || sszVarOffset10 < sszVarOffset9 { return ssz.ErrOffset } - - // Offset (7) 'VoluntaryExits' - if o7 = ssz.ReadOffset(buf[216:220]); o7 > size || o6 > o7 { + sszVarOffset11 := ssz.ReadOffset(buf[328:332]) // c.BlobKzgCommitments + if sszVarOffset11 > size || sszVarOffset11 < sszVarOffset10 { return ssz.ErrOffset } + sszSlice3 := buf[sszVarOffset3:sszVarOffset4] // c.ProposerSlashings + sszSlice4 := buf[sszVarOffset4:sszVarOffset5] // c.AttesterSlashings + sszSlice5 := buf[sszVarOffset5:sszVarOffset6] // c.Attestations + sszSlice6 := buf[sszVarOffset6:sszVarOffset7] // c.Deposits + sszSlice7 := buf[sszVarOffset7:sszVarOffset9] // c.VoluntaryExits + sszSlice9 := buf[sszVarOffset9:sszVarOffset10] // c.ExecutionPayloadHeader + sszSlice10 := buf[sszVarOffset10:sszVarOffset11] // c.BlsToExecutionChanges + sszSlice11 := buf[sszVarOffset11:] // c.BlobKzgCommitments - // Field (8) 'SyncAggregate' - if b.SyncAggregate == nil { - b.SyncAggregate = new(SyncAggregate) - } - if err = b.SyncAggregate.UnmarshalSSZ(buf[220:320]); err != nil { - return err - } - - // Offset (9) 'ExecutionPayloadHeader' - if o9 = ssz.ReadOffset(buf[320:324]); o9 > size || o7 > o9 { - return ssz.ErrOffset - } + // Field 0: RandaoReveal + c.RandaoReveal = make([]byte, 0, 96) + c.RandaoReveal = append(c.RandaoReveal, sszSlice0...) - // Offset (10) 'BlsToExecutionChanges' - if o10 = ssz.ReadOffset(buf[324:328]); o10 > size || o9 > o10 { - return ssz.ErrOffset + // Field 1: Eth1Data + c.Eth1Data = new(Eth1Data) + if err = c.Eth1Data.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Eth1Data: %w", err) } - // Offset (11) 'BlobKzgCommitments' - if o11 = ssz.ReadOffset(buf[328:332]); o11 > size || o10 > o11 { - return ssz.ErrOffset - } + // Field 2: Graffiti + c.Graffiti = make([]byte, 0, 32) + c.Graffiti = append(c.Graffiti, sszSlice2...) - // Field (3) 'ProposerSlashings' + // Field 3: ProposerSlashings { - buf = tail[o3:o4] - num, err := ssz.DivideInt2(len(buf), 416, 16) - if err != nil { - return err - } - b.ProposerSlashings = make([]*ProposerSlashing, num) - for ii := 0; ii < num; ii++ { - if b.ProposerSlashings[ii] == nil { - b.ProposerSlashings[ii] = new(ProposerSlashing) - } - if err = b.ProposerSlashings[ii].UnmarshalSSZ(buf[ii*416 : (ii+1)*416]); err != nil { - return err + if len(sszSlice3)%416 != 0 { + return fmt.Errorf("misaligned bytes: c.ProposerSlashings length is %d, which is not a multiple of 416: %w", len(sszSlice3), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice3) / 416 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.ProposerSlashings has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.ProposerSlashings = make([]*ProposerSlashing, numElem) + for i := 0; i < numElem; i++ { + var tmp *ProposerSlashing + tmp = new(ProposerSlashing) + tmpSlice := sszSlice3[i*416 : (1+i)*416] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("ProposerSlashings: %w", err) } + c.ProposerSlashings[i] = tmp } } - // Field (4) 'AttesterSlashings' + // Field 4: AttesterSlashings { - buf = tail[o4:o5] - num, err := ssz.DecodeDynamicLength(buf, 2) - 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) + // empty lists are zero length, so make sure there is room for an offset + // before attempting to unmarshal it + if len(sszSlice4) > 3 { + startOffset := ssz.ReadOffset(sszSlice4[0:4]) + if startOffset == 0 { + return fmt.Errorf("encountered invalid offset of 0 when decoding c.AttesterSlashings") + } + if startOffset%4 != 0 { + return fmt.Errorf("misaligned list bytes: when decoding c.AttesterSlashings, end-of-list offset is %d, which is not a multiple of 4 (offset size)", startOffset) } - if err = b.AttesterSlashings[indx].UnmarshalSSZ(buf); err != nil { - return err + listLen := startOffset / 4 + if listLen > 2 { + return fmt.Errorf("ssz-max exceeded: c.AttesterSlashings has %d elements, ssz-max is 2: %w", listLen, ssz.ErrListTooBig) } - return nil - }) - if err != nil { - return err + totalVarBytes := uint64(len(sszSlice4)) + if totalVarBytes < startOffset { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.AttesterSlashings") + } + c.AttesterSlashings = make([]*AttesterSlashing, listLen) + var tmpSlice []byte + for i := uint64(0); i < listLen; i++ { + var tmp *AttesterSlashing + tmp = new(AttesterSlashing) + endOffset := totalVarBytes + if i+1 != listLen { + endOffset = ssz.ReadOffset(sszSlice4[(i+1)*4 : (i+2)*4]) + if totalVarBytes < endOffset { + return fmt.Errorf("offset %d points past the end of buffer when decoding c.AttesterSlashings", endOffset) + } + } + if endOffset < startOffset { + return fmt.Errorf("offset %d is not greater than start offset %d when decoding c.AttesterSlashings", endOffset, startOffset) + } + tmpSlice = sszSlice4[startOffset:endOffset] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("AttesterSlashings: %w", err) + } + c.AttesterSlashings[i] = tmp + startOffset = endOffset + } + } else { + if len(sszSlice4) > 0 { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.AttesterSlashings") + } + c.AttesterSlashings = make([]*AttesterSlashing, 0) } } - // Field (5) 'Attestations' + // Field 5: Attestations { - buf = tail[o5:o6] - num, err := ssz.DecodeDynamicLength(buf, 128) - 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) + // empty lists are zero length, so make sure there is room for an offset + // before attempting to unmarshal it + if len(sszSlice5) > 3 { + startOffset := ssz.ReadOffset(sszSlice5[0:4]) + if startOffset == 0 { + return fmt.Errorf("encountered invalid offset of 0 when decoding c.Attestations") + } + if startOffset%4 != 0 { + return fmt.Errorf("misaligned list bytes: when decoding c.Attestations, end-of-list offset is %d, which is not a multiple of 4 (offset size)", startOffset) } - if err = b.Attestations[indx].UnmarshalSSZ(buf); err != nil { - return err + listLen := startOffset / 4 + if listLen > 128 { + return fmt.Errorf("ssz-max exceeded: c.Attestations has %d elements, ssz-max is 128: %w", listLen, ssz.ErrListTooBig) } - return nil - }) - if err != nil { - return err + totalVarBytes := uint64(len(sszSlice5)) + if totalVarBytes < startOffset { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.Attestations") + } + c.Attestations = make([]*Attestation, listLen) + var tmpSlice []byte + for i := uint64(0); i < listLen; i++ { + var tmp *Attestation + tmp = new(Attestation) + endOffset := totalVarBytes + if i+1 != listLen { + endOffset = ssz.ReadOffset(sszSlice5[(i+1)*4 : (i+2)*4]) + if totalVarBytes < endOffset { + return fmt.Errorf("offset %d points past the end of buffer when decoding c.Attestations", endOffset) + } + } + if endOffset < startOffset { + return fmt.Errorf("offset %d is not greater than start offset %d when decoding c.Attestations", endOffset, startOffset) + } + tmpSlice = sszSlice5[startOffset:endOffset] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Attestations: %w", err) + } + c.Attestations[i] = tmp + startOffset = endOffset + } + } else { + if len(sszSlice5) > 0 { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.Attestations") + } + c.Attestations = make([]*Attestation, 0) } } - // Field (6) 'Deposits' + // Field 6: Deposits { - buf = tail[o6:o7] - num, err := ssz.DivideInt2(len(buf), 1240, 16) - if err != nil { - return err - } - b.Deposits = make([]*Deposit, num) - for ii := 0; ii < num; ii++ { - if b.Deposits[ii] == nil { - b.Deposits[ii] = new(Deposit) - } - if err = b.Deposits[ii].UnmarshalSSZ(buf[ii*1240 : (ii+1)*1240]); err != nil { - return err + if len(sszSlice6)%1240 != 0 { + return fmt.Errorf("misaligned bytes: c.Deposits length is %d, which is not a multiple of 1240: %w", len(sszSlice6), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice6) / 1240 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.Deposits has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.Deposits = make([]*Deposit, numElem) + for i := 0; i < numElem; i++ { + var tmp *Deposit + tmp = new(Deposit) + tmpSlice := sszSlice6[i*1240 : (1+i)*1240] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Deposits: %w", err) } + c.Deposits[i] = tmp } } - // Field (7) 'VoluntaryExits' + // Field 7: VoluntaryExits { - buf = tail[o7:o9] - num, err := ssz.DivideInt2(len(buf), 112, 16) - if err != nil { - return err - } - b.VoluntaryExits = make([]*SignedVoluntaryExit, num) - for ii := 0; ii < num; ii++ { - if b.VoluntaryExits[ii] == nil { - b.VoluntaryExits[ii] = new(SignedVoluntaryExit) - } - if err = b.VoluntaryExits[ii].UnmarshalSSZ(buf[ii*112 : (ii+1)*112]); err != nil { - return err + if len(sszSlice7)%112 != 0 { + return fmt.Errorf("misaligned bytes: c.VoluntaryExits length is %d, which is not a multiple of 112: %w", len(sszSlice7), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice7) / 112 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.VoluntaryExits has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.VoluntaryExits = make([]*SignedVoluntaryExit, numElem) + for i := 0; i < numElem; i++ { + var tmp *SignedVoluntaryExit + tmp = new(SignedVoluntaryExit) + tmpSlice := sszSlice7[i*112 : (1+i)*112] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("VoluntaryExits: %w", err) } + c.VoluntaryExits[i] = tmp } } - // Field (9) 'ExecutionPayloadHeader' - { - buf = tail[o9:o10] - if b.ExecutionPayloadHeader == nil { - b.ExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderDeneb) - } - if err = b.ExecutionPayloadHeader.UnmarshalSSZ(buf); err != nil { - return err - } + // Field 8: SyncAggregate + c.SyncAggregate = new(SyncAggregate) + if err = c.SyncAggregate.UnmarshalSSZ(sszSlice8); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) } - // Field (10) 'BlsToExecutionChanges' + // Field 9: ExecutionPayloadHeader + c.ExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderDeneb) + if err = c.ExecutionPayloadHeader.UnmarshalSSZ(sszSlice9); err != nil { + return fmt.Errorf("ExecutionPayloadHeader: %w", err) + } + + // Field 10: BlsToExecutionChanges { - buf = tail[o10:o11] - num, err := ssz.DivideInt2(len(buf), 172, 16) - if err != nil { - return err - } - b.BlsToExecutionChanges = make([]*SignedBLSToExecutionChange, num) - for ii := 0; ii < num; ii++ { - if b.BlsToExecutionChanges[ii] == nil { - b.BlsToExecutionChanges[ii] = new(SignedBLSToExecutionChange) - } - if err = b.BlsToExecutionChanges[ii].UnmarshalSSZ(buf[ii*172 : (ii+1)*172]); err != nil { - return err + if len(sszSlice10)%172 != 0 { + return fmt.Errorf("misaligned bytes: c.BlsToExecutionChanges length is %d, which is not a multiple of 172: %w", len(sszSlice10), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice10) / 172 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.BlsToExecutionChanges has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.BlsToExecutionChanges = make([]*SignedBLSToExecutionChange, numElem) + for i := 0; i < numElem; i++ { + var tmp *SignedBLSToExecutionChange + tmp = new(SignedBLSToExecutionChange) + tmpSlice := sszSlice10[i*172 : (1+i)*172] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("BlsToExecutionChanges: %w", err) } + c.BlsToExecutionChanges[i] = tmp } } - // Field (11) 'BlobKzgCommitments' + // Field 11: BlobKzgCommitments { - buf = tail[o11:] - num, err := ssz.DivideInt2(len(buf), 48, 4096) - if err != nil { - return err - } - b.BlobKzgCommitments = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(b.BlobKzgCommitments[ii]) == 0 { - b.BlobKzgCommitments[ii] = make([]byte, 0, len(buf[ii*48:(ii+1)*48])) - } - b.BlobKzgCommitments[ii] = append(b.BlobKzgCommitments[ii], buf[ii*48:(ii+1)*48]...) + if len(sszSlice11)%48 != 0 { + return fmt.Errorf("misaligned bytes: c.BlobKzgCommitments length is %d, which is not a multiple of 48: %w", len(sszSlice11), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice11) / 48 + if numElem > 4096 { + return fmt.Errorf("ssz-max exceeded: c.BlobKzgCommitments has %d elements, ssz-max is 4096: %w", numElem, ssz.ErrListTooBig) + } + c.BlobKzgCommitments = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte + + tmpSlice := sszSlice11[i*48 : (1+i)*48] + tmp = make([]byte, 0, 48) + tmp = append(tmp, tmpSlice...) + c.BlobKzgCommitments[i] = tmp } } return err } -// SizeSSZ returns the ssz encoded size in bytes for the BlindedBeaconBlockBodyDeneb object -func (b *BlindedBeaconBlockBodyDeneb) SizeSSZ() (size int) { - size = 332 - - // 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) 'ExecutionPayloadHeader' - if b.ExecutionPayloadHeader == nil { - b.ExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderDeneb) +func (c *BlindedBeaconBlockBodyDeneb) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - size += b.ExecutionPayloadHeader.SizeSSZ() - - // Field (10) 'BlsToExecutionChanges' - size += len(b.BlsToExecutionChanges) * 172 - - // Field (11) 'BlobKzgCommitments' - size += len(b.BlobKzgCommitments) * 48 - - return + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRoot ssz hashes the BlindedBeaconBlockBodyDeneb object -func (b *BlindedBeaconBlockBodyDeneb) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) -} - -// HashTreeRootWith ssz hashes the BlindedBeaconBlockBodyDeneb object with a hasher -func (b *BlindedBeaconBlockBodyDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *BlindedBeaconBlockBodyDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'RandaoReveal' - if size := len(b.RandaoReveal); size != 96 { - err = ssz.ErrBytesLengthFn("--.RandaoReveal", size, 96) - return + // Field 0: RandaoReveal + if len(c.RandaoReveal) != 96 { + return ssz.ErrBytesLength } - hh.PutBytes(b.RandaoReveal) - - // Field (1) 'Eth1Data' - if err = b.Eth1Data.HashTreeRootWith(hh); err != nil { - return + hh.PutBytes(c.RandaoReveal) + // Field 1: Eth1Data + if err := c.Eth1Data.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Eth1Data: %w", err) } - - // Field (2) 'Graffiti' - if size := len(b.Graffiti); size != 32 { - err = ssz.ErrBytesLengthFn("--.Graffiti", size, 32) - return + // Field 2: Graffiti + if len(c.Graffiti) != 32 { + return ssz.ErrBytesLength } - hh.PutBytes(b.Graffiti) - - // Field (3) 'ProposerSlashings' + hh.PutBytes(c.Graffiti) + // Field 3: ProposerSlashings { + if len(c.ProposerSlashings) > 16 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.ProposerSlashings { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ProposerSlashings: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.ProposerSlashings)), 16) } - - // Field (4) 'AttesterSlashings' + // Field 4: AttesterSlashings { + if len(c.AttesterSlashings) > 2 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.AttesterSlashings { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("AttesterSlashings: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 2) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.AttesterSlashings)), 2) } - - // Field (5) 'Attestations' + // Field 5: Attestations { + if len(c.Attestations) > 128 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.Attestations { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Attestations: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 128) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Attestations)), 128) } - - // Field (6) 'Deposits' + // Field 6: Deposits { + if len(c.Deposits) > 16 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.Deposits { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Deposits: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Deposits)), 16) } - - // Field (7) 'VoluntaryExits' + // Field 7: VoluntaryExits { + if len(c.VoluntaryExits) > 16 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.VoluntaryExits { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("VoluntaryExits: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.VoluntaryExits)), 16) } - - // Field (8) 'SyncAggregate' - if err = b.SyncAggregate.HashTreeRootWith(hh); err != nil { - return + // Field 8: SyncAggregate + if err := c.SyncAggregate.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) } - - // Field (9) 'ExecutionPayloadHeader' - if err = b.ExecutionPayloadHeader.HashTreeRootWith(hh); err != nil { - return + // Field 9: ExecutionPayloadHeader + if err := c.ExecutionPayloadHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ExecutionPayloadHeader: %w", err) } - - // Field (10) 'BlsToExecutionChanges' + // Field 10: BlsToExecutionChanges { + if len(c.BlsToExecutionChanges) > 16 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.BlsToExecutionChanges { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("BlsToExecutionChanges: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.BlsToExecutionChanges)), 16) } - - // Field (11) 'BlobKzgCommitments' + // Field 11: BlobKzgCommitments { - if size := len(b.BlobKzgCommitments); size > 4096 { - err = ssz.ErrListTooBigFn("--.BlobKzgCommitments", size, 4096) - return + if len(c.BlobKzgCommitments) > 4096 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range b.BlobKzgCommitments { - if len(i) != 48 { - err = ssz.ErrBytesLength - return + for _, o := range c.BlobKzgCommitments { + if len(o) != 48 { + return ssz.ErrBytesLength } - hh.PutBytes(i) + hh.PutBytes(o) } - - numItems := uint64(len(b.BlobKzgCommitments)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.BlobKzgCommitments)), 4096) } - hh.Merkleize(indx) - return + return nil +} + +func (c *BlindedBeaconBlockDeneb) SizeSSZ() int { + size := 84 + if c.Body == nil { + c.Body = new(BlindedBeaconBlockBodyDeneb) + } + size += c.Body.SizeSSZ() + return size } -// MarshalSSZ ssz marshals the SignedBuilderBidDeneb object -func (s *SignedBuilderBidDeneb) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) +func (c *BlindedBeaconBlockDeneb) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the SignedBuilderBidDeneb object to a target array -func (s *SignedBuilderBidDeneb) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(100) +func (c *BlindedBeaconBlockDeneb) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 84 - // Offset (0) 'Message' - dst = ssz.WriteOffset(dst, offset) - if s.Message == nil { - s.Message = new(BuilderBidDeneb) + // Field 0: Slot + if dst, err = c.Slot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Slot: %w", err) + } + + // Field 1: ProposerIndex + if dst, err = c.ProposerIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ProposerIndex: %w", err) + } + + // Field 2: ParentRoot + if len(c.ParentRoot) != 32 { + return nil, ssz.ErrBytesLength } - offset += s.Message.SizeSSZ() + dst = append(dst, c.ParentRoot...) - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 3: StateRoot + if len(c.StateRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, s.Signature...) + dst = append(dst, c.StateRoot...) - // Field (0) 'Message' - if dst, err = s.Message.MarshalSSZTo(dst); err != nil { - return + // Field 4: Body + if c.Body == nil { + c.Body = new(BlindedBeaconBlockBodyDeneb) } + dst = ssz.WriteOffset(dst, offset) + offset += c.Body.SizeSSZ() - return + // Field 4: Body + if dst, err = c.Body.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Body: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the SignedBuilderBidDeneb object -func (s *SignedBuilderBidDeneb) UnmarshalSSZ(buf []byte) error { +func (c *BlindedBeaconBlockDeneb) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 100 { + if size < 84 { return ssz.ErrSize } - tail := buf - var o0 uint64 + sszSlice0 := buf[0:8] // c.Slot + sszSlice1 := buf[8:16] // c.ProposerIndex + sszSlice2 := buf[16:48] // c.ParentRoot + sszSlice3 := buf[48:80] // c.StateRoot - // Offset (0) 'Message' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { + sszVarOffset4 := ssz.ReadOffset(buf[80:84]) // c.Body + if sszVarOffset4 != 84 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset4 > size { return ssz.ErrOffset } + sszSlice4 := buf[sszVarOffset4:] // c.Body - if o0 != 100 { - return ssz.ErrInvalidVariableOffset + // Field 0: Slot + if err = c.Slot.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Slot: %w", err) } - // Field (1) 'Signature' - if cap(s.Signature) == 0 { - s.Signature = make([]byte, 0, len(buf[4:100])) + // Field 1: ProposerIndex + if err = c.ProposerIndex.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("ProposerIndex: %w", err) } - s.Signature = append(s.Signature, buf[4:100]...) - // Field (0) 'Message' - { - buf = tail[o0:] - if s.Message == nil { - s.Message = new(BuilderBidDeneb) - } - if err = s.Message.UnmarshalSSZ(buf); err != nil { - return err - } + // Field 2: ParentRoot + c.ParentRoot = make([]byte, 0, 32) + c.ParentRoot = append(c.ParentRoot, sszSlice2...) + + // Field 3: StateRoot + c.StateRoot = make([]byte, 0, 32) + c.StateRoot = append(c.StateRoot, sszSlice3...) + + // Field 4: Body + c.Body = new(BlindedBeaconBlockBodyDeneb) + if err = c.Body.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("Body: %w", err) } return err } -// SizeSSZ returns the ssz encoded size in bytes for the SignedBuilderBidDeneb object -func (s *SignedBuilderBidDeneb) SizeSSZ() (size int) { - size = 100 +func (c *BlindedBeaconBlockDeneb) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (0) 'Message' - if s.Message == nil { - s.Message = new(BuilderBidDeneb) +func (c *BlindedBeaconBlockDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Slot + if err := c.Slot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Slot: %w", err) + } + // Field 1: ProposerIndex + if err := c.ProposerIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ProposerIndex: %w", err) + } + // Field 2: ParentRoot + if len(c.ParentRoot) != 32 { + return ssz.ErrBytesLength } - size += s.Message.SizeSSZ() + hh.PutBytes(c.ParentRoot) + // Field 3: StateRoot + if len(c.StateRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.StateRoot) + // Field 4: Body + if err := c.Body.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Body: %w", err) + } + hh.Merkleize(indx) + return nil +} - return +func (c *BlobIdentifier) SizeSSZ() int { + size := 40 + + return size } -// HashTreeRoot ssz hashes the SignedBuilderBidDeneb object -func (s *SignedBuilderBidDeneb) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) +func (c *BlobIdentifier) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// HashTreeRootWith ssz hashes the SignedBuilderBidDeneb object with a hasher -func (s *SignedBuilderBidDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() +func (c *BlobIdentifier) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + + // Field 0: BlockRoot + if len(c.BlockRoot) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.BlockRoot...) + + // Field 1: Index + dst = binary.LittleEndian.AppendUint64(dst, c.Index) + + return dst, err +} - // Field (0) 'Message' - if err = s.Message.HashTreeRootWith(hh); err != nil { - return +func (c *BlobIdentifier) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 40 { + return ssz.ErrSize } - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + sszSlice0 := buf[0:32] // c.BlockRoot + sszSlice1 := buf[32:40] // c.Index + + // Field 0: BlockRoot + c.BlockRoot = make([]byte, 0, 32) + c.BlockRoot = append(c.BlockRoot, sszSlice0...) + + // Field 1: Index + c.Index = binary.LittleEndian.Uint64(sszSlice1) + return err +} + +func (c *BlobIdentifier) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - hh.PutBytes(s.Signature) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} +func (c *BlobIdentifier) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: BlockRoot + if len(c.BlockRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.BlockRoot) + // Field 1: Index + hh.PutUint64(c.Index) hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the BuilderBidDeneb object -func (b *BuilderBidDeneb) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) +func (c *BlobSidecar) SizeSSZ() int { + size := 131928 + + return size } -// MarshalSSZTo ssz marshals the BuilderBidDeneb object to a target array -func (b *BuilderBidDeneb) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(88) +func (c *BlobSidecar) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Offset (0) 'Header' - dst = ssz.WriteOffset(dst, offset) - if b.Header == nil { - b.Header = new(v1.ExecutionPayloadHeaderDeneb) - } - offset += b.Header.SizeSSZ() +func (c *BlobSidecar) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Offset (1) 'BlobKzgCommitments' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.BlobKzgCommitments) * 48 + // Field 0: Index + dst = binary.LittleEndian.AppendUint64(dst, c.Index) + + // Field 1: Blob + if len(c.Blob) != 131072 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.Blob...) - // Field (2) 'Value' - if size := len(b.Value); size != 32 { - err = ssz.ErrBytesLengthFn("--.Value", size, 32) - return + // Field 2: KzgCommitment + if len(c.KzgCommitment) != 48 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.Value...) + dst = append(dst, c.KzgCommitment...) - // Field (3) 'Pubkey' - if size := len(b.Pubkey); size != 48 { - err = ssz.ErrBytesLengthFn("--.Pubkey", size, 48) - return + // Field 3: KzgProof + if len(c.KzgProof) != 48 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.Pubkey...) + dst = append(dst, c.KzgProof...) - // Field (0) 'Header' - if dst, err = b.Header.MarshalSSZTo(dst); err != nil { - return + // Field 4: SignedBlockHeader + if c.SignedBlockHeader == nil { + c.SignedBlockHeader = new(SignedBeaconBlockHeader) + } + if dst, err = c.SignedBlockHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SignedBlockHeader: %w", err) } - // Field (1) 'BlobKzgCommitments' - if size := len(b.BlobKzgCommitments); size > 4096 { - err = ssz.ErrListTooBigFn("--.BlobKzgCommitments", size, 4096) - return + // Field 5: CommitmentInclusionProof + if len(c.CommitmentInclusionProof) != 17 { + return nil, ssz.ErrBytesLength } - for ii := 0; ii < len(b.BlobKzgCommitments); ii++ { - if size := len(b.BlobKzgCommitments[ii]); size != 48 { - err = ssz.ErrBytesLengthFn("--.BlobKzgCommitments[ii]", size, 48) - return + for _, o := range c.CommitmentInclusionProof { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.BlobKzgCommitments[ii]...) + dst = append(dst, o...) } - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the BuilderBidDeneb object -func (b *BuilderBidDeneb) UnmarshalSSZ(buf []byte) error { +func (c *BlobSidecar) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 88 { + if size != 131928 { return ssz.ErrSize } - tail := buf - var o0, o1 uint64 + sszSlice0 := buf[0:8] // c.Index + sszSlice1 := buf[8:131080] // c.Blob + sszSlice2 := buf[131080:131128] // c.KzgCommitment + sszSlice3 := buf[131128:131176] // c.KzgProof + sszSlice4 := buf[131176:131384] // c.SignedBlockHeader + sszSlice5 := buf[131384:131928] // c.CommitmentInclusionProof - // Offset (0) 'Header' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } + // Field 0: Index + c.Index = binary.LittleEndian.Uint64(sszSlice0) - if o0 != 88 { - return ssz.ErrInvalidVariableOffset - } + // Field 1: Blob + c.Blob = make([]byte, 0, 131072) + c.Blob = append(c.Blob, sszSlice1...) - // Offset (1) 'BlobKzgCommitments' - if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 { - return ssz.ErrOffset - } + // Field 2: KzgCommitment + c.KzgCommitment = make([]byte, 0, 48) + c.KzgCommitment = append(c.KzgCommitment, sszSlice2...) - // Field (2) 'Value' - if cap(b.Value) == 0 { - b.Value = make([]byte, 0, len(buf[8:40])) - } - b.Value = append(b.Value, buf[8:40]...) + // Field 3: KzgProof + c.KzgProof = make([]byte, 0, 48) + c.KzgProof = append(c.KzgProof, sszSlice3...) - // Field (3) 'Pubkey' - if cap(b.Pubkey) == 0 { - b.Pubkey = make([]byte, 0, len(buf[40:88])) + // Field 4: SignedBlockHeader + c.SignedBlockHeader = new(SignedBeaconBlockHeader) + if err = c.SignedBlockHeader.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("SignedBlockHeader: %w", err) } - b.Pubkey = append(b.Pubkey, buf[40:88]...) - // Field (0) 'Header' + // Field 5: CommitmentInclusionProof { - buf = tail[o0:o1] - if b.Header == nil { - b.Header = new(v1.ExecutionPayloadHeaderDeneb) - } - if err = b.Header.UnmarshalSSZ(buf); err != nil { - return err - } - } + c.CommitmentInclusionProof = make([][]byte, 17) + for i := 0; i < 17; i++ { + var tmp []byte - // Field (1) 'BlobKzgCommitments' - { - buf = tail[o1:] - num, err := ssz.DivideInt2(len(buf), 48, 4096) - if err != nil { - return err - } - b.BlobKzgCommitments = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(b.BlobKzgCommitments[ii]) == 0 { - b.BlobKzgCommitments[ii] = make([]byte, 0, len(buf[ii*48:(ii+1)*48])) - } - b.BlobKzgCommitments[ii] = append(b.BlobKzgCommitments[ii], buf[ii*48:(ii+1)*48]...) + tmpSlice := sszSlice5[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.CommitmentInclusionProof[i] = tmp } } return err } -// SizeSSZ returns the ssz encoded size in bytes for the BuilderBidDeneb object -func (b *BuilderBidDeneb) SizeSSZ() (size int) { - size = 88 - - // Field (0) 'Header' - if b.Header == nil { - b.Header = new(v1.ExecutionPayloadHeaderDeneb) +func (c *BlobSidecar) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - size += b.Header.SizeSSZ() - - // Field (1) 'BlobKzgCommitments' - size += len(b.BlobKzgCommitments) * 48 - - return -} - -// HashTreeRoot ssz hashes the BuilderBidDeneb object -func (b *BuilderBidDeneb) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the BuilderBidDeneb object with a hasher -func (b *BuilderBidDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *BlobSidecar) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Header' - if err = b.Header.HashTreeRootWith(hh); err != nil { - return - } - - // Field (1) 'BlobKzgCommitments' + // Field 0: Index + hh.PutUint64(c.Index) + // Field 1: Blob + if len(c.Blob) != 131072 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Blob) + // Field 2: KzgCommitment + if len(c.KzgCommitment) != 48 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.KzgCommitment) + // Field 3: KzgProof + if len(c.KzgProof) != 48 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.KzgProof) + // Field 4: SignedBlockHeader + if err := c.SignedBlockHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SignedBlockHeader: %w", err) + } + // Field 5: CommitmentInclusionProof { - if size := len(b.BlobKzgCommitments); size > 4096 { - err = ssz.ErrListTooBigFn("--.BlobKzgCommitments", size, 4096) - return + if len(c.CommitmentInclusionProof) != 17 { + return ssz.ErrVectorLength } subIndx := hh.Index() - for _, i := range b.BlobKzgCommitments { - if len(i) != 48 { - err = ssz.ErrBytesLength - return + for _, o := range c.CommitmentInclusionProof { + if len(o) != 32 { + return ssz.ErrBytesLength } - hh.PutBytes(i) + hh.Append(o) } - - numItems := uint64(len(b.BlobKzgCommitments)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) - } - - // Field (2) 'Value' - if size := len(b.Value); size != 32 { - err = ssz.ErrBytesLengthFn("--.Value", size, 32) - return - } - hh.PutBytes(b.Value) - - // Field (3) 'Pubkey' - if size := len(b.Pubkey); size != 48 { - err = ssz.ErrBytesLengthFn("--.Pubkey", size, 48) - return + hh.Merkleize(subIndx) } - hh.PutBytes(b.Pubkey) - hh.Merkleize(indx) - return + return nil +} + +func (c *BlobSidecars) SizeSSZ() int { + size := 4 + size += len(c.Sidecars) * 131928 + return size } -// MarshalSSZ ssz marshals the BlobSidecars object -func (b *BlobSidecars) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) +func (c *BlobSidecars) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the BlobSidecars object to a target array -func (b *BlobSidecars) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(4) +func (c *BlobSidecars) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 4 - // Offset (0) 'Sidecars' + // Field 0: Sidecars dst = ssz.WriteOffset(dst, offset) - offset += len(b.Sidecars) * 131928 + offset += len(c.Sidecars) * 131928 - // Field (0) 'Sidecars' - if size := len(b.Sidecars); size > 6 { - err = ssz.ErrListTooBigFn("--.Sidecars", size, 6) - return + // Field 0: Sidecars + if len(c.Sidecars) > 6 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.Sidecars); ii++ { - if dst, err = b.Sidecars[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.Sidecars { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Sidecars: %w", err) } } - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the BlobSidecars object -func (b *BlobSidecars) UnmarshalSSZ(buf []byte) error { +func (c *BlobSidecars) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size < 4 { return ssz.ErrSize } - tail := buf - var o0 uint64 - - // Offset (0) 'Sidecars' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } - - if o0 != 4 { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Sidecars + if sszVarOffset0 != 4 { return ssz.ErrInvalidVariableOffset } + if sszVarOffset0 > size { + return ssz.ErrOffset + } + sszSlice0 := buf[sszVarOffset0:] // c.Sidecars - // Field (0) 'Sidecars' + // Field 0: Sidecars { - buf = tail[o0:] - num, err := ssz.DivideInt2(len(buf), 131928, 6) - if err != nil { - return err - } - b.Sidecars = make([]*BlobSidecar, num) - for ii := 0; ii < num; ii++ { - if b.Sidecars[ii] == nil { - b.Sidecars[ii] = new(BlobSidecar) - } - if err = b.Sidecars[ii].UnmarshalSSZ(buf[ii*131928 : (ii+1)*131928]); err != nil { - return err + if len(sszSlice0)%131928 != 0 { + return fmt.Errorf("misaligned bytes: c.Sidecars length is %d, which is not a multiple of 131928: %w", len(sszSlice0), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice0) / 131928 + if numElem > 6 { + return fmt.Errorf("ssz-max exceeded: c.Sidecars has %d elements, ssz-max is 6: %w", numElem, ssz.ErrListTooBig) + } + c.Sidecars = make([]*BlobSidecar, numElem) + for i := 0; i < numElem; i++ { + var tmp *BlobSidecar + tmp = new(BlobSidecar) + tmpSlice := sszSlice0[i*131928 : (1+i)*131928] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Sidecars: %w", err) } + c.Sidecars[i] = tmp } } return err } -// SizeSSZ returns the ssz encoded size in bytes for the BlobSidecars object -func (b *BlobSidecars) SizeSSZ() (size int) { - size = 4 - - // Field (0) 'Sidecars' - size += len(b.Sidecars) * 131928 - - return -} - -// HashTreeRoot ssz hashes the BlobSidecars object -func (b *BlobSidecars) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) +func (c *BlobSidecars) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the BlobSidecars object with a hasher -func (b *BlobSidecars) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *BlobSidecars) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Sidecars' + // Field 0: Sidecars { + if len(c.Sidecars) > 6 { + return ssz.ErrListTooBig + } subIndx := hh.Index() - num := uint64(len(b.Sidecars)) - if num > 6 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range b.Sidecars { - if err = elem.HashTreeRootWith(hh); err != nil { - return + for _, o := range c.Sidecars { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Sidecars: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 6) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Sidecars)), 6) } - hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the BlobSidecar object -func (b *BlobSidecar) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) +func (c *BuilderBidDeneb) SizeSSZ() int { + size := 88 + if c.Header == nil { + c.Header = new(v1.ExecutionPayloadHeaderDeneb) + } + size += c.Header.SizeSSZ() + size += len(c.BlobKzgCommitments) * 48 + return size } -// MarshalSSZTo ssz marshals the BlobSidecar object to a target array -func (b *BlobSidecar) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *BuilderBidDeneb) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (0) 'Index' - dst = ssz.MarshalUint(dst, b.Index) +func (c *BuilderBidDeneb) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 88 - // Field (1) 'Blob' - if size := len(b.Blob); size != 131072 { - err = ssz.ErrBytesLengthFn("--.Blob", size, 131072) - return + // Field 0: Header + if c.Header == nil { + c.Header = new(v1.ExecutionPayloadHeaderDeneb) } - dst = append(dst, b.Blob...) + dst = ssz.WriteOffset(dst, offset) + offset += c.Header.SizeSSZ() - // Field (2) 'KzgCommitment' - if size := len(b.KzgCommitment); size != 48 { - err = ssz.ErrBytesLengthFn("--.KzgCommitment", size, 48) - return - } - dst = append(dst, b.KzgCommitment...) + // Field 1: BlobKzgCommitments + dst = ssz.WriteOffset(dst, offset) + offset += len(c.BlobKzgCommitments) * 48 - // Field (3) 'KzgProof' - if size := len(b.KzgProof); size != 48 { - err = ssz.ErrBytesLengthFn("--.KzgProof", size, 48) - return + // Field 2: Value + if len(c.Value) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.KzgProof...) + dst = append(dst, c.Value...) - // Field (4) 'SignedBlockHeader' - if b.SignedBlockHeader == nil { - b.SignedBlockHeader = new(SignedBeaconBlockHeader) + // Field 3: Pubkey + if len(c.Pubkey) != 48 { + return nil, ssz.ErrBytesLength } - if dst, err = b.SignedBlockHeader.MarshalSSZTo(dst); err != nil { - return + dst = append(dst, c.Pubkey...) + + // Field 0: Header + if dst, err = c.Header.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Header: %w", err) } - // Field (5) 'CommitmentInclusionProof' - if size := len(b.CommitmentInclusionProof); size != 17 { - err = ssz.ErrVectorLengthFn("--.CommitmentInclusionProof", size, 17) - return + // Field 1: BlobKzgCommitments + if len(c.BlobKzgCommitments) > 4096 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < 17; ii++ { - if size := len(b.CommitmentInclusionProof[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.CommitmentInclusionProof[ii]", size, 32) - return + for _, o := range c.BlobKzgCommitments { + if len(o) != 48 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.CommitmentInclusionProof[ii]...) + dst = append(dst, o...) } - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the BlobSidecar object -func (b *BlobSidecar) UnmarshalSSZ(buf []byte) error { +func (c *BuilderBidDeneb) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 131928 { + if size < 88 { return ssz.ErrSize } - // Field (0) 'Index' - b.Index = ssz.UnmarshallUint[uint64](buf[0:8]) + sszSlice2 := buf[8:40] // c.Value + sszSlice3 := buf[40:88] // c.Pubkey - // Field (1) 'Blob' - if cap(b.Blob) == 0 { - b.Blob = make([]byte, 0, len(buf[8:131080])) + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Header + if sszVarOffset0 != 88 { + return ssz.ErrInvalidVariableOffset } - b.Blob = append(b.Blob, buf[8:131080]...) - - // Field (2) 'KzgCommitment' - if cap(b.KzgCommitment) == 0 { - b.KzgCommitment = make([]byte, 0, len(buf[131080:131128])) + if sszVarOffset0 > size { + return ssz.ErrOffset } - b.KzgCommitment = append(b.KzgCommitment, buf[131080:131128]...) - - // Field (3) 'KzgProof' - if cap(b.KzgProof) == 0 { - b.KzgProof = make([]byte, 0, len(buf[131128:131176])) + sszVarOffset1 := ssz.ReadOffset(buf[4:8]) // c.BlobKzgCommitments + if sszVarOffset1 > size || sszVarOffset1 < sszVarOffset0 { + return ssz.ErrOffset } - b.KzgProof = append(b.KzgProof, buf[131128:131176]...) + sszSlice0 := buf[sszVarOffset0:sszVarOffset1] // c.Header + sszSlice1 := buf[sszVarOffset1:] // c.BlobKzgCommitments - // Field (4) 'SignedBlockHeader' - if b.SignedBlockHeader == nil { - b.SignedBlockHeader = new(SignedBeaconBlockHeader) - } - if err = b.SignedBlockHeader.UnmarshalSSZ(buf[131176:131384]); err != nil { - return err + // Field 0: Header + c.Header = new(v1.ExecutionPayloadHeaderDeneb) + if err = c.Header.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Header: %w", err) } - // Field (5) 'CommitmentInclusionProof' - b.CommitmentInclusionProof = make([][]byte, 17) - for ii := 0; ii < 17; ii++ { - if cap(b.CommitmentInclusionProof[ii]) == 0 { - b.CommitmentInclusionProof[ii] = make([]byte, 0, len(buf[131384:131928][ii*32:(ii+1)*32])) + // Field 1: BlobKzgCommitments + { + if len(sszSlice1)%48 != 0 { + return fmt.Errorf("misaligned bytes: c.BlobKzgCommitments length is %d, which is not a multiple of 48: %w", len(sszSlice1), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice1) / 48 + if numElem > 4096 { + return fmt.Errorf("ssz-max exceeded: c.BlobKzgCommitments has %d elements, ssz-max is 4096: %w", numElem, ssz.ErrListTooBig) + } + c.BlobKzgCommitments = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte + + tmpSlice := sszSlice1[i*48 : (1+i)*48] + tmp = make([]byte, 0, 48) + tmp = append(tmp, tmpSlice...) + c.BlobKzgCommitments[i] = tmp } - b.CommitmentInclusionProof[ii] = append(b.CommitmentInclusionProof[ii], buf[131384:131928][ii*32:(ii+1)*32]...) } - return err -} + // Field 2: Value + c.Value = make([]byte, 0, 32) + c.Value = append(c.Value, sszSlice2...) -// SizeSSZ returns the ssz encoded size in bytes for the BlobSidecar object -func (b *BlobSidecar) SizeSSZ() (size int) { - size = 131928 - return + // Field 3: Pubkey + c.Pubkey = make([]byte, 0, 48) + c.Pubkey = append(c.Pubkey, sszSlice3...) + return err } -// HashTreeRoot ssz hashes the BlobSidecar object -func (b *BlobSidecar) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) +func (c *BuilderBidDeneb) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the BlobSidecar object with a hasher -func (b *BlobSidecar) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *BuilderBidDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Index' - ssz.PutUint(hh, b.Index) - - // Field (1) 'Blob' - if size := len(b.Blob); size != 131072 { - err = ssz.ErrBytesLengthFn("--.Blob", size, 131072) - return - } - hh.PutBytes(b.Blob) - - // Field (2) 'KzgCommitment' - if size := len(b.KzgCommitment); size != 48 { - err = ssz.ErrBytesLengthFn("--.KzgCommitment", size, 48) - return - } - hh.PutBytes(b.KzgCommitment) - - // Field (3) 'KzgProof' - if size := len(b.KzgProof); size != 48 { - err = ssz.ErrBytesLengthFn("--.KzgProof", size, 48) - return - } - hh.PutBytes(b.KzgProof) - - // Field (4) 'SignedBlockHeader' - if err = b.SignedBlockHeader.HashTreeRootWith(hh); err != nil { - return + // Field 0: Header + if err := c.Header.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Header: %w", err) } - - // Field (5) 'CommitmentInclusionProof' + // Field 1: BlobKzgCommitments { - if size := len(b.CommitmentInclusionProof); size != 17 { - err = ssz.ErrVectorLengthFn("--.CommitmentInclusionProof", size, 17) - return + if len(c.BlobKzgCommitments) > 4096 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range b.CommitmentInclusionProof { - if len(i) != 32 { - err = ssz.ErrBytesLength - return + for _, o := range c.BlobKzgCommitments { + if len(o) != 48 { + return ssz.ErrBytesLength } - hh.Append(i) + hh.PutBytes(o) } - hh.Merkleize(subIndx) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.BlobKzgCommitments)), 4096) } - + // Field 2: Value + if len(c.Value) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Value) + // Field 3: Pubkey + if len(c.Pubkey) != 48 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Pubkey) hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the BeaconStateDeneb object -func (b *BeaconStateDeneb) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) +func (c *LightClientHeaderDeneb) SizeSSZ() int { + size := 244 + if c.Execution == nil { + c.Execution = new(v1.ExecutionPayloadHeaderDeneb) + } + size += c.Execution.SizeSSZ() + return size } -// MarshalSSZTo ssz marshals the BeaconStateDeneb object to a target array -func (b *BeaconStateDeneb) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(10253) - - // Field (0) 'GenesisTime' - dst = ssz.MarshalUint(dst, b.GenesisTime) - - // Field (1) 'GenesisValidatorsRoot' - if size := len(b.GenesisValidatorsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.GenesisValidatorsRoot", size, 32) - return - } - dst = append(dst, b.GenesisValidatorsRoot...) +func (c *LightClientHeaderDeneb) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (2) 'Slot' - dst = ssz.MarshalUint(dst, b.Slot) +func (c *LightClientHeaderDeneb) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 244 - // Field (3) 'Fork' - if b.Fork == nil { - b.Fork = new(Fork) + // Field 0: Beacon + if c.Beacon == nil { + c.Beacon = new(BeaconBlockHeader) } - if dst, err = b.Fork.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.Beacon.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Beacon: %w", err) } - // Field (4) 'LatestBlockHeader' - if b.LatestBlockHeader == nil { - b.LatestBlockHeader = new(BeaconBlockHeader) - } - if dst, err = b.LatestBlockHeader.MarshalSSZTo(dst); err != nil { - return + // Field 1: Execution + if c.Execution == nil { + c.Execution = new(v1.ExecutionPayloadHeaderDeneb) } + dst = ssz.WriteOffset(dst, offset) + offset += c.Execution.SizeSSZ() - // Field (5) 'BlockRoots' - if size := len(b.BlockRoots); size != 64 { - err = ssz.ErrVectorLengthFn("--.BlockRoots", size, 64) - return + // Field 2: ExecutionBranch + if len(c.ExecutionBranch) != 4 { + return nil, ssz.ErrBytesLength } - for ii := 0; ii < 64; ii++ { - if size := len(b.BlockRoots[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockRoots[ii]", size, 32) - return + for _, o := range c.ExecutionBranch { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.BlockRoots[ii]...) + dst = append(dst, o...) } - // Field (6) 'StateRoots' - if size := len(b.StateRoots); size != 64 { - err = ssz.ErrVectorLengthFn("--.StateRoots", size, 64) - return - } - for ii := 0; ii < 64; ii++ { - if size := len(b.StateRoots[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoots[ii]", size, 32) - return - } - dst = append(dst, b.StateRoots[ii]...) + // Field 1: Execution + if dst, err = c.Execution.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Execution: %w", err) } + return dst, err +} - // Offset (7) 'HistoricalRoots' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.HistoricalRoots) * 32 - - // Field (8) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(Eth1Data) - } - if dst, err = b.Eth1Data.MarshalSSZTo(dst); err != nil { - return +func (c *LightClientHeaderDeneb) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 244 { + return ssz.ErrSize } - // Offset (9) 'Eth1DataVotes' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.Eth1DataVotes) * 72 - - // Field (10) 'Eth1DepositIndex' - dst = ssz.MarshalUint(dst, b.Eth1DepositIndex) - - // Offset (11) 'Validators' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.Validators) * 121 + sszSlice0 := buf[0:112] // c.Beacon + sszSlice2 := buf[116:244] // c.ExecutionBranch - // Offset (12) 'Balances' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.Balances) * 8 - - // Field (13) 'RandaoMixes' - if size := len(b.RandaoMixes); size != 64 { - err = ssz.ErrVectorLengthFn("--.RandaoMixes", size, 64) - return + sszVarOffset1 := ssz.ReadOffset(buf[112:116]) // c.Execution + if sszVarOffset1 != 244 { + return ssz.ErrInvalidVariableOffset } - for ii := 0; ii < 64; ii++ { - if size := len(b.RandaoMixes[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.RandaoMixes[ii]", size, 32) - return - } - dst = append(dst, b.RandaoMixes[ii]...) + if sszVarOffset1 > size { + return ssz.ErrOffset } + sszSlice1 := buf[sszVarOffset1:] // c.Execution - // Field (14) 'Slashings' - if size := len(b.Slashings); size != 64 { - err = ssz.ErrVectorLengthFn("--.Slashings", size, 64) - return - } - for ii := 0; ii < 64; ii++ { - dst = ssz.MarshalUint(dst, b.Slashings[ii]) + // Field 0: Beacon + c.Beacon = new(BeaconBlockHeader) + if err = c.Beacon.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Beacon: %w", err) } - // 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' - if size := len(b.JustificationBits); size != 1 { - err = ssz.ErrBytesLengthFn("--.JustificationBits", size, 1) - return + // Field 1: Execution + c.Execution = new(v1.ExecutionPayloadHeaderDeneb) + if err = c.Execution.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Execution: %w", err) } - dst = append(dst, b.JustificationBits...) - // Field (18) 'PreviousJustifiedCheckpoint' - if b.PreviousJustifiedCheckpoint == nil { - b.PreviousJustifiedCheckpoint = new(Checkpoint) - } - if dst, err = b.PreviousJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { - return - } + // Field 2: ExecutionBranch + { + c.ExecutionBranch = make([][]byte, 4) + for i := 0; i < 4; i++ { + var tmp []byte - // Field (19) 'CurrentJustifiedCheckpoint' - if b.CurrentJustifiedCheckpoint == nil { - b.CurrentJustifiedCheckpoint = new(Checkpoint) + tmpSlice := sszSlice2[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.ExecutionBranch[i] = tmp + } } - if dst, err = b.CurrentJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { - return + return err +} + +func (c *LightClientHeaderDeneb) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (20) 'FinalizedCheckpoint' - if b.FinalizedCheckpoint == nil { - b.FinalizedCheckpoint = new(Checkpoint) +func (c *LightClientHeaderDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Beacon + if err := c.Beacon.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Beacon: %w", err) } - if dst, err = b.FinalizedCheckpoint.MarshalSSZTo(dst); err != nil { - return + // Field 1: Execution + if err := c.Execution.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Execution: %w", err) } - - // Offset (21) 'InactivityScores' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.InactivityScores) * 8 - - // Field (22) 'CurrentSyncCommittee' - if b.CurrentSyncCommittee == nil { - b.CurrentSyncCommittee = new(SyncCommittee) - } - if dst, err = b.CurrentSyncCommittee.MarshalSSZTo(dst); err != nil { - return - } - - // Field (23) 'NextSyncCommittee' - if b.NextSyncCommittee == nil { - b.NextSyncCommittee = new(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(v1.ExecutionPayloadHeaderDeneb) - } - offset += b.LatestExecutionPayloadHeader.SizeSSZ() - - // Field (25) 'NextWithdrawalIndex' - dst = ssz.MarshalUint(dst, b.NextWithdrawalIndex) - - // Field (26) 'NextWithdrawalValidatorIndex' - dst = ssz.MarshalUint(dst, b.NextWithdrawalValidatorIndex) - - // Offset (27) 'HistoricalSummaries' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.HistoricalSummaries) * 64 - - // Field (7) 'HistoricalRoots' - if size := len(b.HistoricalRoots); size > 16777216 { - err = ssz.ErrListTooBigFn("--.HistoricalRoots", size, 16777216) - return - } - for ii := 0; ii < len(b.HistoricalRoots); ii++ { - if size := len(b.HistoricalRoots[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.HistoricalRoots[ii]", size, 32) - return - } - dst = append(dst, b.HistoricalRoots[ii]...) - } - - // Field (9) 'Eth1DataVotes' - if size := len(b.Eth1DataVotes); size > 32 { - err = ssz.ErrListTooBigFn("--.Eth1DataVotes", size, 32) - 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("--.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("--.Balances", size, 1099511627776) - return - } - for ii := 0; ii < len(b.Balances); ii++ { - dst = ssz.MarshalUint(dst, b.Balances[ii]) - } - - // Field (15) 'PreviousEpochParticipation' - if size := len(b.PreviousEpochParticipation); size > 1099511627776 { - err = ssz.ErrBytesLengthFn("--.PreviousEpochParticipation", size, 1099511627776) - return - } - dst = append(dst, b.PreviousEpochParticipation...) - - // Field (16) 'CurrentEpochParticipation' - if size := len(b.CurrentEpochParticipation); size > 1099511627776 { - err = ssz.ErrBytesLengthFn("--.CurrentEpochParticipation", size, 1099511627776) - return - } - dst = append(dst, b.CurrentEpochParticipation...) - - // Field (21) 'InactivityScores' - if size := len(b.InactivityScores); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.InactivityScores", size, 1099511627776) - return - } - for ii := 0; ii < len(b.InactivityScores); ii++ { - dst = ssz.MarshalUint(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("--.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 BeaconStateDeneb object -func (b *BeaconStateDeneb) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 10253 { - return ssz.ErrSize - } - - tail := buf - var o7, o9, o11, o12, o15, o16, o21, o24, o27 uint64 - - // Field (0) 'GenesisTime' - b.GenesisTime = ssz.UnmarshallUint[uint64](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.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[40:48]) - - // Field (3) 'Fork' - if b.Fork == nil { - b.Fork = new(Fork) - } - if err = b.Fork.UnmarshalSSZ(buf[48:64]); err != nil { - return err - } - - // Field (4) 'LatestBlockHeader' - if b.LatestBlockHeader == nil { - b.LatestBlockHeader = new(BeaconBlockHeader) - } - if err = b.LatestBlockHeader.UnmarshalSSZ(buf[64:176]); err != nil { - return err - } - - // Field (5) 'BlockRoots' - b.BlockRoots = make([][]byte, 64) - for ii := 0; ii < 64; ii++ { - if cap(b.BlockRoots[ii]) == 0 { - b.BlockRoots[ii] = make([]byte, 0, len(buf[176:2224][ii*32:(ii+1)*32])) - } - b.BlockRoots[ii] = append(b.BlockRoots[ii], buf[176:2224][ii*32:(ii+1)*32]...) - } - - // Field (6) 'StateRoots' - b.StateRoots = make([][]byte, 64) - for ii := 0; ii < 64; ii++ { - if cap(b.StateRoots[ii]) == 0 { - b.StateRoots[ii] = make([]byte, 0, len(buf[2224:4272][ii*32:(ii+1)*32])) - } - b.StateRoots[ii] = append(b.StateRoots[ii], buf[2224:4272][ii*32:(ii+1)*32]...) - } - - // Offset (7) 'HistoricalRoots' - if o7 = ssz.ReadOffset(buf[4272:4276]); o7 > size { - return ssz.ErrOffset - } - - if o7 != 10253 { - return ssz.ErrInvalidVariableOffset - } - - // Field (8) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(Eth1Data) - } - if err = b.Eth1Data.UnmarshalSSZ(buf[4276:4348]); err != nil { - return err - } - - // Offset (9) 'Eth1DataVotes' - if o9 = ssz.ReadOffset(buf[4348:4352]); o9 > size || o7 > o9 { - return ssz.ErrOffset - } - - // Field (10) 'Eth1DepositIndex' - b.Eth1DepositIndex = ssz.UnmarshallUint[uint64](buf[4352:4360]) - - // Offset (11) 'Validators' - if o11 = ssz.ReadOffset(buf[4360:4364]); o11 > size || o9 > o11 { - return ssz.ErrOffset - } - - // Offset (12) 'Balances' - if o12 = ssz.ReadOffset(buf[4364:4368]); o12 > size || o11 > o12 { - return ssz.ErrOffset - } - - // Field (13) 'RandaoMixes' - b.RandaoMixes = make([][]byte, 64) - for ii := 0; ii < 64; ii++ { - if cap(b.RandaoMixes[ii]) == 0 { - b.RandaoMixes[ii] = make([]byte, 0, len(buf[4368:6416][ii*32:(ii+1)*32])) - } - b.RandaoMixes[ii] = append(b.RandaoMixes[ii], buf[4368:6416][ii*32:(ii+1)*32]...) - } - - // Field (14) 'Slashings' - b.Slashings = ssz.ExtendUint(b.Slashings, 64) - for ii := 0; ii < 64; ii++ { - b.Slashings[ii] = ssz.UnmarshallUint[uint64](buf[6416:6928][ii*8 : (ii+1)*8]) - } - - // Offset (15) 'PreviousEpochParticipation' - if o15 = ssz.ReadOffset(buf[6928:6932]); o15 > size || o12 > o15 { - return ssz.ErrOffset - } - - // Offset (16) 'CurrentEpochParticipation' - if o16 = ssz.ReadOffset(buf[6932:6936]); o16 > size || o15 > o16 { - return ssz.ErrOffset - } - - // Field (17) 'JustificationBits' - if cap(b.JustificationBits) == 0 { - b.JustificationBits = make([]byte, 0, len(buf[6936:6937])) - } - b.JustificationBits = append(b.JustificationBits, buf[6936:6937]...) - - // Field (18) 'PreviousJustifiedCheckpoint' - if b.PreviousJustifiedCheckpoint == nil { - b.PreviousJustifiedCheckpoint = new(Checkpoint) - } - if err = b.PreviousJustifiedCheckpoint.UnmarshalSSZ(buf[6937:6977]); err != nil { - return err - } - - // Field (19) 'CurrentJustifiedCheckpoint' - if b.CurrentJustifiedCheckpoint == nil { - b.CurrentJustifiedCheckpoint = new(Checkpoint) - } - if err = b.CurrentJustifiedCheckpoint.UnmarshalSSZ(buf[6977:7017]); err != nil { - return err - } - - // Field (20) 'FinalizedCheckpoint' - if b.FinalizedCheckpoint == nil { - b.FinalizedCheckpoint = new(Checkpoint) - } - if err = b.FinalizedCheckpoint.UnmarshalSSZ(buf[7017:7057]); err != nil { - return err - } - - // Offset (21) 'InactivityScores' - if o21 = ssz.ReadOffset(buf[7057:7061]); o21 > size || o16 > o21 { - return ssz.ErrOffset - } - - // Field (22) 'CurrentSyncCommittee' - if b.CurrentSyncCommittee == nil { - b.CurrentSyncCommittee = new(SyncCommittee) - } - if err = b.CurrentSyncCommittee.UnmarshalSSZ(buf[7061:8645]); err != nil { - return err - } - - // Field (23) 'NextSyncCommittee' - if b.NextSyncCommittee == nil { - b.NextSyncCommittee = new(SyncCommittee) - } - if err = b.NextSyncCommittee.UnmarshalSSZ(buf[8645:10229]); err != nil { - return err - } - - // Offset (24) 'LatestExecutionPayloadHeader' - if o24 = ssz.ReadOffset(buf[10229:10233]); o24 > size || o21 > o24 { - return ssz.ErrOffset - } - - // Field (25) 'NextWithdrawalIndex' - b.NextWithdrawalIndex = ssz.UnmarshallUint[uint64](buf[10233:10241]) - - // Field (26) 'NextWithdrawalValidatorIndex' - b.NextWithdrawalValidatorIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[10241:10249]) - - // Offset (27) 'HistoricalSummaries' - if o27 = ssz.ReadOffset(buf[10249:10253]); 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, 32) - if err != nil { - return err - } - b.Eth1DataVotes = make([]*Eth1Data, num) - for ii := 0; ii < num; ii++ { - if b.Eth1DataVotes[ii] == nil { - b.Eth1DataVotes[ii] = new(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([]*Validator, num) - for ii := 0; ii < num; ii++ { - if b.Validators[ii] == nil { - b.Validators[ii] = new(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.ExtendUint(b.Balances, num) - for ii := 0; ii < num; ii++ { - b.Balances[ii] = ssz.UnmarshallUint[uint64](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.ExtendUint(b.InactivityScores, num) - for ii := 0; ii < num; ii++ { - b.InactivityScores[ii] = ssz.UnmarshallUint[uint64](buf[ii*8 : (ii+1)*8]) - } - } - - // Field (24) 'LatestExecutionPayloadHeader' - { - buf = tail[o24:o27] - if b.LatestExecutionPayloadHeader == nil { - b.LatestExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderDeneb) - } - 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([]*HistoricalSummary, num) - for ii := 0; ii < num; ii++ { - if b.HistoricalSummaries[ii] == nil { - b.HistoricalSummaries[ii] = new(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 BeaconStateDeneb object -func (b *BeaconStateDeneb) SizeSSZ() (size int) { - size = 10253 - - // 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(v1.ExecutionPayloadHeaderDeneb) - } - size += b.LatestExecutionPayloadHeader.SizeSSZ() - - // Field (27) 'HistoricalSummaries' - size += len(b.HistoricalSummaries) * 64 - - return -} - -// HashTreeRoot ssz hashes the BeaconStateDeneb object -func (b *BeaconStateDeneb) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) -} - -// HashTreeRootWith ssz hashes the BeaconStateDeneb object with a hasher -func (b *BeaconStateDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'GenesisTime' - ssz.PutUint(hh, b.GenesisTime) - - // Field (1) 'GenesisValidatorsRoot' - if size := len(b.GenesisValidatorsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.GenesisValidatorsRoot", size, 32) - return - } - hh.PutBytes(b.GenesisValidatorsRoot) - - // Field (2) 'Slot' - ssz.PutUint(hh, b.Slot) - - // Field (3) 'Fork' - if err = b.Fork.HashTreeRootWith(hh); err != nil { - return - } - - // Field (4) 'LatestBlockHeader' - if err = b.LatestBlockHeader.HashTreeRootWith(hh); err != nil { - return - } - - // Field (5) 'BlockRoots' - { - if size := len(b.BlockRoots); size != 64 { - err = ssz.ErrVectorLengthFn("--.BlockRoots", size, 64) - return - } - subIndx := hh.Index() - for _, i := range b.BlockRoots { - if len(i) != 32 { - err = ssz.ErrBytesLength - return - } - hh.Append(i) - } - hh.Merkleize(subIndx) - } - - // Field (6) 'StateRoots' - { - if size := len(b.StateRoots); size != 64 { - err = ssz.ErrVectorLengthFn("--.StateRoots", size, 64) - return - } - subIndx := hh.Index() - for _, i := range b.StateRoots { - if len(i) != 32 { - err = ssz.ErrBytesLength - return - } - hh.Append(i) - } - hh.Merkleize(subIndx) - } - - // Field (7) 'HistoricalRoots' - { - if size := len(b.HistoricalRoots); size > 16777216 { - err = ssz.ErrListTooBigFn("--.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 err = b.Eth1Data.HashTreeRootWith(hh); err != nil { - return - } - - // Field (9) 'Eth1DataVotes' + // Field 2: ExecutionBranch { - subIndx := hh.Index() - num := uint64(len(b.Eth1DataVotes)) - if num > 32 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range b.Eth1DataVotes { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } + if len(c.ExecutionBranch) != 4 { + return ssz.ErrVectorLength } - hh.MerkleizeWithMixin(subIndx, num, 32) - } - - // Field (10) 'Eth1DepositIndex' - ssz.PutUint(hh, 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 + for _, o := range c.ExecutionBranch { + if len(o) != 32 { + return ssz.ErrBytesLength } - } - hh.MerkleizeWithMixin(subIndx, num, 1099511627776) - } - - // Field (12) 'Balances' - { - if size := len(b.Balances); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.Balances", size, 1099511627776) - return - } - subIndx := hh.Index() - for _, i := range b.Balances { - ssz.AppendUint(hh, 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 != 64 { - err = ssz.ErrVectorLengthFn("--.RandaoMixes", size, 64) - 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 != 64 { - err = ssz.ErrVectorLengthFn("--.Slashings", size, 64) - return - } - subIndx := hh.Index() - for _, i := range b.Slashings { - ssz.AppendUint(hh, i) + hh.Append(o) } hh.Merkleize(subIndx) } - - // Field (15) 'PreviousEpochParticipation' - { - elemIndx := hh.Index() - byteLen := uint64(len(b.PreviousEpochParticipation)) - if byteLen > 1099511627776 { - err = ssz.ErrIncorrectListSize - return - } - hh.AppendBytes32(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.AppendBytes32(b.CurrentEpochParticipation) - hh.MerkleizeWithMixin(elemIndx, byteLen, (1099511627776+31)/32) - } - - // Field (17) 'JustificationBits' - if size := len(b.JustificationBits); size != 1 { - err = ssz.ErrBytesLengthFn("--.JustificationBits", size, 1) - return - } - hh.PutBytes(b.JustificationBits) - - // Field (18) 'PreviousJustifiedCheckpoint' - if err = b.PreviousJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { - return - } - - // Field (19) 'CurrentJustifiedCheckpoint' - if err = b.CurrentJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { - return - } - - // Field (20) 'FinalizedCheckpoint' - if err = b.FinalizedCheckpoint.HashTreeRootWith(hh); err != nil { - return - } - - // Field (21) 'InactivityScores' - { - if size := len(b.InactivityScores); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.InactivityScores", size, 1099511627776) - return - } - subIndx := hh.Index() - for _, i := range b.InactivityScores { - ssz.AppendUint(hh, i) - } - hh.FillUpTo32() - - numItems := uint64(len(b.InactivityScores)) - hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(1099511627776, numItems, 8)) - } - - // Field (22) 'CurrentSyncCommittee' - if err = b.CurrentSyncCommittee.HashTreeRootWith(hh); err != nil { - return - } - - // Field (23) 'NextSyncCommittee' - if err = b.NextSyncCommittee.HashTreeRootWith(hh); err != nil { - return - } - - // Field (24) 'LatestExecutionPayloadHeader' - if err = b.LatestExecutionPayloadHeader.HashTreeRootWith(hh); err != nil { - return - } - - // Field (25) 'NextWithdrawalIndex' - ssz.PutUint(hh, b.NextWithdrawalIndex) - - // Field (26) 'NextWithdrawalValidatorIndex' - ssz.PutUint(hh, 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 -} - -// MarshalSSZ ssz marshals the BlobIdentifier object -func (b *BlobIdentifier) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} - -// MarshalSSZTo ssz marshals the BlobIdentifier object to a target array -func (b *BlobIdentifier) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - - // Field (0) 'BlockRoot' - if size := len(b.BlockRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockRoot", size, 32) - return - } - dst = append(dst, b.BlockRoot...) - - // Field (1) 'Index' - dst = ssz.MarshalUint(dst, b.Index) - - return + return nil } -// UnmarshalSSZ ssz unmarshals the BlobIdentifier object -func (b *BlobIdentifier) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size != 40 { - return ssz.ErrSize - } - - // Field (0) 'BlockRoot' - if cap(b.BlockRoot) == 0 { - b.BlockRoot = make([]byte, 0, len(buf[0:32])) +func (c *LightClientBootstrapDeneb) SizeSSZ() int { + size := 1748 + if c.Header == nil { + c.Header = new(LightClientHeaderDeneb) } - b.BlockRoot = append(b.BlockRoot, buf[0:32]...) - - // Field (1) 'Index' - b.Index = ssz.UnmarshallUint[uint64](buf[32:40]) - - return err + size += c.Header.SizeSSZ() + return size } -// SizeSSZ returns the ssz encoded size in bytes for the BlobIdentifier object -func (b *BlobIdentifier) SizeSSZ() (size int) { - size = 40 - return +func (c *LightClientBootstrapDeneb) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// HashTreeRoot ssz hashes the BlobIdentifier object -func (b *BlobIdentifier) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) -} - -// HashTreeRootWith ssz hashes the BlobIdentifier object with a hasher -func (b *BlobIdentifier) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() +func (c *LightClientBootstrapDeneb) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 1748 - // Field (0) 'BlockRoot' - if size := len(b.BlockRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockRoot", size, 32) - return + // Field 0: Header + if c.Header == nil { + c.Header = new(LightClientHeaderDeneb) } - hh.PutBytes(b.BlockRoot) - - // Field (1) 'Index' - ssz.PutUint(hh, b.Index) - - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the LightClientBootstrapDeneb object -func (l *LightClientBootstrapDeneb) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(l) -} - -// MarshalSSZTo ssz marshals the LightClientBootstrapDeneb object to a target array -func (l *LightClientBootstrapDeneb) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(1748) - - // Offset (0) 'Header' dst = ssz.WriteOffset(dst, offset) - if l.Header == nil { - l.Header = new(LightClientHeaderDeneb) - } - offset += l.Header.SizeSSZ() + offset += c.Header.SizeSSZ() - // Field (1) 'CurrentSyncCommittee' - if l.CurrentSyncCommittee == nil { - l.CurrentSyncCommittee = new(SyncCommittee) + // Field 1: CurrentSyncCommittee + if c.CurrentSyncCommittee == nil { + c.CurrentSyncCommittee = new(SyncCommittee) } - if dst, err = l.CurrentSyncCommittee.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.CurrentSyncCommittee.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("CurrentSyncCommittee: %w", err) } - // Field (2) 'CurrentSyncCommitteeBranch' - if size := len(l.CurrentSyncCommitteeBranch); size != 5 { - err = ssz.ErrVectorLengthFn("--.CurrentSyncCommitteeBranch", size, 5) - return + // Field 2: CurrentSyncCommitteeBranch + if len(c.CurrentSyncCommitteeBranch) != 5 { + return nil, ssz.ErrBytesLength } - for ii := 0; ii < 5; ii++ { - if size := len(l.CurrentSyncCommitteeBranch[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.CurrentSyncCommitteeBranch[ii]", size, 32) - return + for _, o := range c.CurrentSyncCommitteeBranch { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, l.CurrentSyncCommitteeBranch[ii]...) + dst = append(dst, o...) } - // Field (0) 'Header' - if dst, err = l.Header.MarshalSSZTo(dst); err != nil { - return + // Field 0: Header + if dst, err = c.Header.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Header: %w", err) } - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the LightClientBootstrapDeneb object -func (l *LightClientBootstrapDeneb) UnmarshalSSZ(buf []byte) error { +func (c *LightClientBootstrapDeneb) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size < 1748 { return ssz.ErrSize } - tail := buf - var o0 uint64 + sszSlice1 := buf[4:1588] // c.CurrentSyncCommittee + sszSlice2 := buf[1588:1748] // c.CurrentSyncCommitteeBranch - // Offset (0) 'Header' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } - - if o0 != 1748 { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Header + if sszVarOffset0 != 1748 { return ssz.ErrInvalidVariableOffset } - - // Field (1) 'CurrentSyncCommittee' - if l.CurrentSyncCommittee == nil { - l.CurrentSyncCommittee = new(SyncCommittee) - } - if err = l.CurrentSyncCommittee.UnmarshalSSZ(buf[4:1588]); err != nil { - return err + if sszVarOffset0 > size { + return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:] // c.Header - // Field (2) 'CurrentSyncCommitteeBranch' - l.CurrentSyncCommitteeBranch = make([][]byte, 5) - for ii := 0; ii < 5; ii++ { - if cap(l.CurrentSyncCommitteeBranch[ii]) == 0 { - l.CurrentSyncCommitteeBranch[ii] = make([]byte, 0, len(buf[1588:1748][ii*32:(ii+1)*32])) - } - l.CurrentSyncCommitteeBranch[ii] = append(l.CurrentSyncCommitteeBranch[ii], buf[1588:1748][ii*32:(ii+1)*32]...) + // Field 0: Header + c.Header = new(LightClientHeaderDeneb) + if err = c.Header.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Header: %w", err) } - // Field (0) 'Header' - { - buf = tail[o0:] - if l.Header == nil { - l.Header = new(LightClientHeaderDeneb) - } - if err = l.Header.UnmarshalSSZ(buf); err != nil { - return err - } + // Field 1: CurrentSyncCommittee + c.CurrentSyncCommittee = new(SyncCommittee) + if err = c.CurrentSyncCommittee.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("CurrentSyncCommittee: %w", err) } - return err -} -// SizeSSZ returns the ssz encoded size in bytes for the LightClientBootstrapDeneb object -func (l *LightClientBootstrapDeneb) SizeSSZ() (size int) { - size = 1748 + // Field 2: CurrentSyncCommitteeBranch + { + c.CurrentSyncCommitteeBranch = make([][]byte, 5) + for i := 0; i < 5; i++ { + var tmp []byte - // Field (0) 'Header' - if l.Header == nil { - l.Header = new(LightClientHeaderDeneb) + tmpSlice := sszSlice2[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.CurrentSyncCommitteeBranch[i] = tmp + } } - size += l.Header.SizeSSZ() - - return + return err } -// HashTreeRoot ssz hashes the LightClientBootstrapDeneb object -func (l *LightClientBootstrapDeneb) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(l) +func (c *LightClientBootstrapDeneb) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the LightClientBootstrapDeneb object with a hasher -func (l *LightClientBootstrapDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *LightClientBootstrapDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Header' - if err = l.Header.HashTreeRootWith(hh); err != nil { - return + // Field 0: Header + if err := c.Header.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Header: %w", err) } - - // Field (1) 'CurrentSyncCommittee' - if err = l.CurrentSyncCommittee.HashTreeRootWith(hh); err != nil { - return + // Field 1: CurrentSyncCommittee + if err := c.CurrentSyncCommittee.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("CurrentSyncCommittee: %w", err) } - - // Field (2) 'CurrentSyncCommitteeBranch' + // Field 2: CurrentSyncCommitteeBranch { - if size := len(l.CurrentSyncCommitteeBranch); size != 5 { - err = ssz.ErrVectorLengthFn("--.CurrentSyncCommitteeBranch", size, 5) - return + if len(c.CurrentSyncCommitteeBranch) != 5 { + return ssz.ErrVectorLength } subIndx := hh.Index() - for _, i := range l.CurrentSyncCommitteeBranch { - if len(i) != 32 { - err = ssz.ErrBytesLength - return + for _, o := range c.CurrentSyncCommitteeBranch { + if len(o) != 32 { + return ssz.ErrBytesLength } - hh.Append(i) + hh.Append(o) } hh.Merkleize(subIndx) } - hh.Merkleize(indx) - return + return nil +} + +func (c *LightClientUpdateDeneb) SizeSSZ() int { + size := 2052 + if c.AttestedHeader == nil { + c.AttestedHeader = new(LightClientHeaderDeneb) + } + size += c.AttestedHeader.SizeSSZ() + if c.FinalizedHeader == nil { + c.FinalizedHeader = new(LightClientHeaderDeneb) + } + size += c.FinalizedHeader.SizeSSZ() + return size } -// MarshalSSZ ssz marshals the LightClientUpdateDeneb object -func (l *LightClientUpdateDeneb) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(l) +func (c *LightClientUpdateDeneb) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the LightClientUpdateDeneb object to a target array -func (l *LightClientUpdateDeneb) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(2052) +func (c *LightClientUpdateDeneb) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 2052 - // Offset (0) 'AttestedHeader' - dst = ssz.WriteOffset(dst, offset) - if l.AttestedHeader == nil { - l.AttestedHeader = new(LightClientHeaderDeneb) + // Field 0: AttestedHeader + if c.AttestedHeader == nil { + c.AttestedHeader = new(LightClientHeaderDeneb) } - offset += l.AttestedHeader.SizeSSZ() + dst = ssz.WriteOffset(dst, offset) + offset += c.AttestedHeader.SizeSSZ() - // Field (1) 'NextSyncCommittee' - if l.NextSyncCommittee == nil { - l.NextSyncCommittee = new(SyncCommittee) + // Field 1: NextSyncCommittee + if c.NextSyncCommittee == nil { + c.NextSyncCommittee = new(SyncCommittee) } - if dst, err = l.NextSyncCommittee.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.NextSyncCommittee.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("NextSyncCommittee: %w", err) } - // Field (2) 'NextSyncCommitteeBranch' - if size := len(l.NextSyncCommitteeBranch); size != 5 { - err = ssz.ErrVectorLengthFn("--.NextSyncCommitteeBranch", size, 5) - return + // Field 2: NextSyncCommitteeBranch + if len(c.NextSyncCommitteeBranch) != 5 { + return nil, ssz.ErrBytesLength } - for ii := 0; ii < 5; ii++ { - if size := len(l.NextSyncCommitteeBranch[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.NextSyncCommitteeBranch[ii]", size, 32) - return + for _, o := range c.NextSyncCommitteeBranch { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, l.NextSyncCommitteeBranch[ii]...) + dst = append(dst, o...) } - // Offset (3) 'FinalizedHeader' - dst = ssz.WriteOffset(dst, offset) - if l.FinalizedHeader == nil { - l.FinalizedHeader = new(LightClientHeaderDeneb) + // Field 3: FinalizedHeader + if c.FinalizedHeader == nil { + c.FinalizedHeader = new(LightClientHeaderDeneb) } - offset += l.FinalizedHeader.SizeSSZ() + dst = ssz.WriteOffset(dst, offset) + offset += c.FinalizedHeader.SizeSSZ() - // Field (4) 'FinalityBranch' - if size := len(l.FinalityBranch); size != 6 { - err = ssz.ErrVectorLengthFn("--.FinalityBranch", size, 6) - return + // Field 4: FinalityBranch + if len(c.FinalityBranch) != 6 { + return nil, ssz.ErrBytesLength } - for ii := 0; ii < 6; ii++ { - if size := len(l.FinalityBranch[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.FinalityBranch[ii]", size, 32) - return + for _, o := range c.FinalityBranch { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, l.FinalityBranch[ii]...) + dst = append(dst, o...) } - // Field (5) 'SyncAggregate' - if l.SyncAggregate == nil { - l.SyncAggregate = new(SyncAggregate) + // Field 5: SyncAggregate + if c.SyncAggregate == nil { + c.SyncAggregate = new(SyncAggregate) } - if dst, err = l.SyncAggregate.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.SyncAggregate.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SyncAggregate: %w", err) } - // Field (6) 'SignatureSlot' - dst = ssz.MarshalUint(dst, l.SignatureSlot) - - // Field (0) 'AttestedHeader' - if dst, err = l.AttestedHeader.MarshalSSZTo(dst); err != nil { - return + // Field 6: SignatureSlot + if dst, err = c.SignatureSlot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SignatureSlot: %w", err) } - // Field (3) 'FinalizedHeader' - if dst, err = l.FinalizedHeader.MarshalSSZTo(dst); err != nil { - return + // Field 0: AttestedHeader + if dst, err = c.AttestedHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("AttestedHeader: %w", err) } - return + // Field 3: FinalizedHeader + if dst, err = c.FinalizedHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("FinalizedHeader: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the LightClientUpdateDeneb object -func (l *LightClientUpdateDeneb) UnmarshalSSZ(buf []byte) error { +func (c *LightClientUpdateDeneb) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size < 2052 { return ssz.ErrSize } - tail := buf - var o0, o3 uint64 - - // Offset (0) 'AttestedHeader' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } + sszSlice1 := buf[4:1588] // c.NextSyncCommittee + sszSlice2 := buf[1588:1748] // c.NextSyncCommitteeBranch + sszSlice4 := buf[1752:1944] // c.FinalityBranch + sszSlice5 := buf[1944:2044] // c.SyncAggregate + sszSlice6 := buf[2044:2052] // c.SignatureSlot - if o0 != 2052 { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.AttestedHeader + if sszVarOffset0 != 2052 { return ssz.ErrInvalidVariableOffset } - - // Field (1) 'NextSyncCommittee' - if l.NextSyncCommittee == nil { - l.NextSyncCommittee = new(SyncCommittee) + if sszVarOffset0 > size { + return ssz.ErrOffset } - if err = l.NextSyncCommittee.UnmarshalSSZ(buf[4:1588]); err != nil { - return err + sszVarOffset3 := ssz.ReadOffset(buf[1748:1752]) // c.FinalizedHeader + if sszVarOffset3 > size || sszVarOffset3 < sszVarOffset0 { + return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:sszVarOffset3] // c.AttestedHeader + sszSlice3 := buf[sszVarOffset3:] // c.FinalizedHeader - // Field (2) 'NextSyncCommitteeBranch' - l.NextSyncCommitteeBranch = make([][]byte, 5) - for ii := 0; ii < 5; ii++ { - if cap(l.NextSyncCommitteeBranch[ii]) == 0 { - l.NextSyncCommitteeBranch[ii] = make([]byte, 0, len(buf[1588:1748][ii*32:(ii+1)*32])) - } - l.NextSyncCommitteeBranch[ii] = append(l.NextSyncCommitteeBranch[ii], buf[1588:1748][ii*32:(ii+1)*32]...) + // Field 0: AttestedHeader + c.AttestedHeader = new(LightClientHeaderDeneb) + if err = c.AttestedHeader.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("AttestedHeader: %w", err) } - // Offset (3) 'FinalizedHeader' - if o3 = ssz.ReadOffset(buf[1748:1752]); o3 > size || o0 > o3 { - return ssz.ErrOffset + // Field 1: NextSyncCommittee + c.NextSyncCommittee = new(SyncCommittee) + if err = c.NextSyncCommittee.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("NextSyncCommittee: %w", err) } - // Field (4) 'FinalityBranch' - l.FinalityBranch = make([][]byte, 6) - for ii := 0; ii < 6; ii++ { - if cap(l.FinalityBranch[ii]) == 0 { - l.FinalityBranch[ii] = make([]byte, 0, len(buf[1752:1944][ii*32:(ii+1)*32])) + // Field 2: NextSyncCommitteeBranch + { + c.NextSyncCommitteeBranch = make([][]byte, 5) + for i := 0; i < 5; i++ { + var tmp []byte + + tmpSlice := sszSlice2[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.NextSyncCommitteeBranch[i] = tmp } - l.FinalityBranch[ii] = append(l.FinalityBranch[ii], buf[1752:1944][ii*32:(ii+1)*32]...) } - // Field (5) 'SyncAggregate' - if l.SyncAggregate == nil { - l.SyncAggregate = new(SyncAggregate) - } - if err = l.SyncAggregate.UnmarshalSSZ(buf[1944:2044]); err != nil { - return err + // Field 3: FinalizedHeader + c.FinalizedHeader = new(LightClientHeaderDeneb) + if err = c.FinalizedHeader.UnmarshalSSZ(sszSlice3); err != nil { + return fmt.Errorf("FinalizedHeader: %w", err) } - // Field (6) 'SignatureSlot' - l.SignatureSlot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[2044:2052]) - - // Field (0) 'AttestedHeader' + // Field 4: FinalityBranch { - buf = tail[o0:o3] - if l.AttestedHeader == nil { - l.AttestedHeader = new(LightClientHeaderDeneb) - } - if err = l.AttestedHeader.UnmarshalSSZ(buf); err != nil { - return err - } - } + c.FinalityBranch = make([][]byte, 6) + for i := 0; i < 6; i++ { + var tmp []byte - // Field (3) 'FinalizedHeader' - { - buf = tail[o3:] - if l.FinalizedHeader == nil { - l.FinalizedHeader = new(LightClientHeaderDeneb) - } - if err = l.FinalizedHeader.UnmarshalSSZ(buf); err != nil { - return err + tmpSlice := sszSlice4[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.FinalityBranch[i] = tmp } } - return err -} -// SizeSSZ returns the ssz encoded size in bytes for the LightClientUpdateDeneb object -func (l *LightClientUpdateDeneb) SizeSSZ() (size int) { - size = 2052 - - // Field (0) 'AttestedHeader' - if l.AttestedHeader == nil { - l.AttestedHeader = new(LightClientHeaderDeneb) + // Field 5: SyncAggregate + c.SyncAggregate = new(SyncAggregate) + if err = c.SyncAggregate.UnmarshalSSZ(sszSlice5); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) } - size += l.AttestedHeader.SizeSSZ() - // Field (3) 'FinalizedHeader' - if l.FinalizedHeader == nil { - l.FinalizedHeader = new(LightClientHeaderDeneb) + // Field 6: SignatureSlot + if err = c.SignatureSlot.UnmarshalSSZ(sszSlice6); err != nil { + return fmt.Errorf("SignatureSlot: %w", err) } - size += l.FinalizedHeader.SizeSSZ() - - return + return err } -// HashTreeRoot ssz hashes the LightClientUpdateDeneb object -func (l *LightClientUpdateDeneb) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(l) +func (c *LightClientUpdateDeneb) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the LightClientUpdateDeneb object with a hasher -func (l *LightClientUpdateDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *LightClientUpdateDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'AttestedHeader' - if err = l.AttestedHeader.HashTreeRootWith(hh); err != nil { - return + // Field 0: AttestedHeader + if err := c.AttestedHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("AttestedHeader: %w", err) } - - // Field (1) 'NextSyncCommittee' - if err = l.NextSyncCommittee.HashTreeRootWith(hh); err != nil { - return + // Field 1: NextSyncCommittee + if err := c.NextSyncCommittee.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("NextSyncCommittee: %w", err) } - - // Field (2) 'NextSyncCommitteeBranch' + // Field 2: NextSyncCommitteeBranch { - if size := len(l.NextSyncCommitteeBranch); size != 5 { - err = ssz.ErrVectorLengthFn("--.NextSyncCommitteeBranch", size, 5) - return + if len(c.NextSyncCommitteeBranch) != 5 { + return ssz.ErrVectorLength } subIndx := hh.Index() - for _, i := range l.NextSyncCommitteeBranch { - if len(i) != 32 { - err = ssz.ErrBytesLength - return + for _, o := range c.NextSyncCommitteeBranch { + if len(o) != 32 { + return ssz.ErrBytesLength } - hh.Append(i) + hh.Append(o) } hh.Merkleize(subIndx) } - - // Field (3) 'FinalizedHeader' - if err = l.FinalizedHeader.HashTreeRootWith(hh); err != nil { - return + // Field 3: FinalizedHeader + if err := c.FinalizedHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("FinalizedHeader: %w", err) } - - // Field (4) 'FinalityBranch' + // Field 4: FinalityBranch { - if size := len(l.FinalityBranch); size != 6 { - err = ssz.ErrVectorLengthFn("--.FinalityBranch", size, 6) - return + if len(c.FinalityBranch) != 6 { + return ssz.ErrVectorLength } subIndx := hh.Index() - for _, i := range l.FinalityBranch { - if len(i) != 32 { - err = ssz.ErrBytesLength - return + for _, o := range c.FinalityBranch { + if len(o) != 32 { + return ssz.ErrBytesLength } - hh.Append(i) + hh.Append(o) } hh.Merkleize(subIndx) } - - // Field (5) 'SyncAggregate' - if err = l.SyncAggregate.HashTreeRootWith(hh); err != nil { - return + // Field 5: SyncAggregate + if err := c.SyncAggregate.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) + } + // Field 6: SignatureSlot + if err := c.SignatureSlot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SignatureSlot: %w", err) } - - // Field (6) 'SignatureSlot' - ssz.PutUint(hh, l.SignatureSlot) - hh.Merkleize(indx) - return + return nil +} + +func (c *LightClientFinalityUpdateDeneb) SizeSSZ() int { + size := 308 + if c.AttestedHeader == nil { + c.AttestedHeader = new(LightClientHeaderDeneb) + } + size += c.AttestedHeader.SizeSSZ() + if c.FinalizedHeader == nil { + c.FinalizedHeader = new(LightClientHeaderDeneb) + } + size += c.FinalizedHeader.SizeSSZ() + return size } -// MarshalSSZ ssz marshals the LightClientFinalityUpdateDeneb object -func (l *LightClientFinalityUpdateDeneb) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(l) +func (c *LightClientFinalityUpdateDeneb) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the LightClientFinalityUpdateDeneb object to a target array -func (l *LightClientFinalityUpdateDeneb) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(308) +func (c *LightClientFinalityUpdateDeneb) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 308 - // Offset (0) 'AttestedHeader' - dst = ssz.WriteOffset(dst, offset) - if l.AttestedHeader == nil { - l.AttestedHeader = new(LightClientHeaderDeneb) + // Field 0: AttestedHeader + if c.AttestedHeader == nil { + c.AttestedHeader = new(LightClientHeaderDeneb) } - offset += l.AttestedHeader.SizeSSZ() - - // Offset (1) 'FinalizedHeader' dst = ssz.WriteOffset(dst, offset) - if l.FinalizedHeader == nil { - l.FinalizedHeader = new(LightClientHeaderDeneb) + offset += c.AttestedHeader.SizeSSZ() + + // Field 1: FinalizedHeader + if c.FinalizedHeader == nil { + c.FinalizedHeader = new(LightClientHeaderDeneb) } - offset += l.FinalizedHeader.SizeSSZ() + dst = ssz.WriteOffset(dst, offset) + offset += c.FinalizedHeader.SizeSSZ() - // Field (2) 'FinalityBranch' - if size := len(l.FinalityBranch); size != 6 { - err = ssz.ErrVectorLengthFn("--.FinalityBranch", size, 6) - return + // Field 2: FinalityBranch + if len(c.FinalityBranch) != 6 { + return nil, ssz.ErrBytesLength } - for ii := 0; ii < 6; ii++ { - if size := len(l.FinalityBranch[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.FinalityBranch[ii]", size, 32) - return + for _, o := range c.FinalityBranch { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, l.FinalityBranch[ii]...) + dst = append(dst, o...) } - // Field (3) 'SyncAggregate' - if l.SyncAggregate == nil { - l.SyncAggregate = new(SyncAggregate) + // Field 3: SyncAggregate + if c.SyncAggregate == nil { + c.SyncAggregate = new(SyncAggregate) } - if dst, err = l.SyncAggregate.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.SyncAggregate.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SyncAggregate: %w", err) } - // Field (4) 'SignatureSlot' - dst = ssz.MarshalUint(dst, l.SignatureSlot) - - // Field (0) 'AttestedHeader' - if dst, err = l.AttestedHeader.MarshalSSZTo(dst); err != nil { - return + // Field 4: SignatureSlot + if dst, err = c.SignatureSlot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SignatureSlot: %w", err) } - // Field (1) 'FinalizedHeader' - if dst, err = l.FinalizedHeader.MarshalSSZTo(dst); err != nil { - return + // Field 0: AttestedHeader + if dst, err = c.AttestedHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("AttestedHeader: %w", err) } - return + // Field 1: FinalizedHeader + if dst, err = c.FinalizedHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("FinalizedHeader: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the LightClientFinalityUpdateDeneb object -func (l *LightClientFinalityUpdateDeneb) UnmarshalSSZ(buf []byte) error { +func (c *LightClientFinalityUpdateDeneb) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size < 308 { return ssz.ErrSize } - tail := buf - var o0, o1 uint64 + sszSlice2 := buf[8:200] // c.FinalityBranch + sszSlice3 := buf[200:300] // c.SyncAggregate + sszSlice4 := buf[300:308] // c.SignatureSlot - // Offset (0) 'AttestedHeader' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.AttestedHeader + if sszVarOffset0 != 308 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset0 > size { + return ssz.ErrOffset + } + sszVarOffset1 := ssz.ReadOffset(buf[4:8]) // c.FinalizedHeader + if sszVarOffset1 > size || sszVarOffset1 < sszVarOffset0 { return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:sszVarOffset1] // c.AttestedHeader + sszSlice1 := buf[sszVarOffset1:] // c.FinalizedHeader - if o0 != 308 { - return ssz.ErrInvalidVariableOffset + // Field 0: AttestedHeader + c.AttestedHeader = new(LightClientHeaderDeneb) + if err = c.AttestedHeader.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("AttestedHeader: %w", err) } - // Offset (1) 'FinalizedHeader' - if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 { - return ssz.ErrOffset + // Field 1: FinalizedHeader + c.FinalizedHeader = new(LightClientHeaderDeneb) + if err = c.FinalizedHeader.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("FinalizedHeader: %w", err) } - // Field (2) 'FinalityBranch' - l.FinalityBranch = make([][]byte, 6) - for ii := 0; ii < 6; ii++ { - if cap(l.FinalityBranch[ii]) == 0 { - l.FinalityBranch[ii] = make([]byte, 0, len(buf[8:200][ii*32:(ii+1)*32])) + // Field 2: FinalityBranch + { + c.FinalityBranch = make([][]byte, 6) + for i := 0; i < 6; i++ { + var tmp []byte + + tmpSlice := sszSlice2[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.FinalityBranch[i] = tmp } - l.FinalityBranch[ii] = append(l.FinalityBranch[ii], buf[8:200][ii*32:(ii+1)*32]...) } - // Field (3) 'SyncAggregate' - if l.SyncAggregate == nil { - l.SyncAggregate = new(SyncAggregate) + // Field 3: SyncAggregate + c.SyncAggregate = new(SyncAggregate) + if err = c.SyncAggregate.UnmarshalSSZ(sszSlice3); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) } - if err = l.SyncAggregate.UnmarshalSSZ(buf[200:300]); err != nil { - return err + + // Field 4: SignatureSlot + if err = c.SignatureSlot.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("SignatureSlot: %w", err) } + return err +} - // Field (4) 'SignatureSlot' - l.SignatureSlot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[300:308]) +func (c *LightClientFinalityUpdateDeneb) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (0) 'AttestedHeader' +func (c *LightClientFinalityUpdateDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: AttestedHeader + if err := c.AttestedHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("AttestedHeader: %w", err) + } + // Field 1: FinalizedHeader + if err := c.FinalizedHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("FinalizedHeader: %w", err) + } + // Field 2: FinalityBranch { - buf = tail[o0:o1] - if l.AttestedHeader == nil { - l.AttestedHeader = new(LightClientHeaderDeneb) + if len(c.FinalityBranch) != 6 { + return ssz.ErrVectorLength } - if err = l.AttestedHeader.UnmarshalSSZ(buf); err != nil { - return err + subIndx := hh.Index() + for _, o := range c.FinalityBranch { + if len(o) != 32 { + return ssz.ErrBytesLength + } + hh.Append(o) } + hh.Merkleize(subIndx) + } + // Field 3: SyncAggregate + if err := c.SyncAggregate.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) } + // Field 4: SignatureSlot + if err := c.SignatureSlot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SignatureSlot: %w", err) + } + hh.Merkleize(indx) + return nil +} - // Field (1) 'FinalizedHeader' - { - buf = tail[o1:] - if l.FinalizedHeader == nil { - l.FinalizedHeader = new(LightClientHeaderDeneb) - } - if err = l.FinalizedHeader.UnmarshalSSZ(buf); err != nil { - return err - } +func (c *LightClientOptimisticUpdateDeneb) SizeSSZ() int { + size := 112 + if c.AttestedHeader == nil { + c.AttestedHeader = new(LightClientHeaderDeneb) } - return err + size += c.AttestedHeader.SizeSSZ() + return size +} + +func (c *LightClientOptimisticUpdateDeneb) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// SizeSSZ returns the ssz encoded size in bytes for the LightClientFinalityUpdateDeneb object -func (l *LightClientFinalityUpdateDeneb) SizeSSZ() (size int) { - size = 308 +func (c *LightClientOptimisticUpdateDeneb) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 112 - // Field (0) 'AttestedHeader' - if l.AttestedHeader == nil { - l.AttestedHeader = new(LightClientHeaderDeneb) + // Field 0: AttestedHeader + if c.AttestedHeader == nil { + c.AttestedHeader = new(LightClientHeaderDeneb) } - size += l.AttestedHeader.SizeSSZ() + dst = ssz.WriteOffset(dst, offset) + offset += c.AttestedHeader.SizeSSZ() - // Field (1) 'FinalizedHeader' - if l.FinalizedHeader == nil { - l.FinalizedHeader = new(LightClientHeaderDeneb) + // Field 1: SyncAggregate + if c.SyncAggregate == nil { + c.SyncAggregate = new(SyncAggregate) + } + if dst, err = c.SyncAggregate.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SyncAggregate: %w", err) } - size += l.FinalizedHeader.SizeSSZ() - return -} + // Field 2: SignatureSlot + if dst, err = c.SignatureSlot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SignatureSlot: %w", err) + } -// HashTreeRoot ssz hashes the LightClientFinalityUpdateDeneb object -func (l *LightClientFinalityUpdateDeneb) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(l) + // Field 0: AttestedHeader + if dst, err = c.AttestedHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("AttestedHeader: %w", err) + } + return dst, err } -// HashTreeRootWith ssz hashes the LightClientFinalityUpdateDeneb object with a hasher -func (l *LightClientFinalityUpdateDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() +func (c *LightClientOptimisticUpdateDeneb) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 112 { + return ssz.ErrSize + } + + sszSlice1 := buf[4:104] // c.SyncAggregate + sszSlice2 := buf[104:112] // c.SignatureSlot - // Field (0) 'AttestedHeader' - if err = l.AttestedHeader.HashTreeRootWith(hh); err != nil { - return + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.AttestedHeader + if sszVarOffset0 != 112 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset0 > size { + return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:] // c.AttestedHeader - // Field (1) 'FinalizedHeader' - if err = l.FinalizedHeader.HashTreeRootWith(hh); err != nil { - return + // Field 0: AttestedHeader + c.AttestedHeader = new(LightClientHeaderDeneb) + if err = c.AttestedHeader.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("AttestedHeader: %w", err) } - // Field (2) 'FinalityBranch' - { - if size := len(l.FinalityBranch); size != 6 { - err = ssz.ErrVectorLengthFn("--.FinalityBranch", size, 6) - return - } - subIndx := hh.Index() - for _, i := range l.FinalityBranch { - if len(i) != 32 { - err = ssz.ErrBytesLength - return - } - hh.Append(i) - } - hh.Merkleize(subIndx) + // Field 1: SyncAggregate + c.SyncAggregate = new(SyncAggregate) + if err = c.SyncAggregate.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) } - // Field (3) 'SyncAggregate' - if err = l.SyncAggregate.HashTreeRootWith(hh); err != nil { - return + // Field 2: SignatureSlot + if err = c.SignatureSlot.UnmarshalSSZ(sszSlice2); err != nil { + return fmt.Errorf("SignatureSlot: %w", err) } + return err +} - // Field (4) 'SignatureSlot' - ssz.PutUint(hh, l.SignatureSlot) +func (c *LightClientOptimisticUpdateDeneb) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} +func (c *LightClientOptimisticUpdateDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: AttestedHeader + if err := c.AttestedHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("AttestedHeader: %w", err) + } + // Field 1: SyncAggregate + if err := c.SyncAggregate.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) + } + // Field 2: SignatureSlot + if err := c.SignatureSlot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SignatureSlot: %w", err) + } hh.Merkleize(indx) - return + return nil +} + +func (c *SignedBeaconBlockContentsDeneb) SizeSSZ() int { + size := 12 + if c.Block == nil { + c.Block = new(SignedBeaconBlockDeneb) + } + size += c.Block.SizeSSZ() + size += len(c.KzgProofs) * 48 + size += len(c.Blobs) * 131072 + return size } -// MarshalSSZ ssz marshals the LightClientOptimisticUpdateDeneb object -func (l *LightClientOptimisticUpdateDeneb) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(l) +func (c *SignedBeaconBlockContentsDeneb) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the LightClientOptimisticUpdateDeneb object to a target array -func (l *LightClientOptimisticUpdateDeneb) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(112) +func (c *SignedBeaconBlockContentsDeneb) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 12 + + // Field 0: Block + if c.Block == nil { + c.Block = new(SignedBeaconBlockDeneb) + } + dst = ssz.WriteOffset(dst, offset) + offset += c.Block.SizeSSZ() + + // Field 1: KzgProofs + dst = ssz.WriteOffset(dst, offset) + offset += len(c.KzgProofs) * 48 - // Offset (0) 'AttestedHeader' + // Field 2: Blobs dst = ssz.WriteOffset(dst, offset) - if l.AttestedHeader == nil { - l.AttestedHeader = new(LightClientHeaderDeneb) + offset += len(c.Blobs) * 131072 + + // Field 0: Block + if dst, err = c.Block.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Block: %w", err) } - offset += l.AttestedHeader.SizeSSZ() - // Field (1) 'SyncAggregate' - if l.SyncAggregate == nil { - l.SyncAggregate = new(SyncAggregate) + // Field 1: KzgProofs + if len(c.KzgProofs) > 4096 { + return nil, ssz.ErrListTooBig } - if dst, err = l.SyncAggregate.MarshalSSZTo(dst); err != nil { - return + for _, o := range c.KzgProofs { + if len(o) != 48 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) } - // Field (2) 'SignatureSlot' - dst = ssz.MarshalUint(dst, l.SignatureSlot) - - // Field (0) 'AttestedHeader' - if dst, err = l.AttestedHeader.MarshalSSZTo(dst); err != nil { - return + // Field 2: Blobs + if len(c.Blobs) > 4096 { + return nil, ssz.ErrListTooBig } - - return + for _, o := range c.Blobs { + if len(o) != 131072 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the LightClientOptimisticUpdateDeneb object -func (l *LightClientOptimisticUpdateDeneb) UnmarshalSSZ(buf []byte) error { +func (c *SignedBeaconBlockContentsDeneb) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 112 { + if size < 12 { return ssz.ErrSize } - tail := buf - var o0 uint64 - - // Offset (0) 'AttestedHeader' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Block + if sszVarOffset0 != 12 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset0 > size { return ssz.ErrOffset } - - if o0 != 112 { - return ssz.ErrInvalidVariableOffset + sszVarOffset1 := ssz.ReadOffset(buf[4:8]) // c.KzgProofs + if sszVarOffset1 > size || sszVarOffset1 < sszVarOffset0 { + return ssz.ErrOffset } - - // Field (1) 'SyncAggregate' - if l.SyncAggregate == nil { - l.SyncAggregate = new(SyncAggregate) + sszVarOffset2 := ssz.ReadOffset(buf[8:12]) // c.Blobs + if sszVarOffset2 > size || sszVarOffset2 < sszVarOffset1 { + return ssz.ErrOffset } - if err = l.SyncAggregate.UnmarshalSSZ(buf[4:104]); err != nil { - return err + sszSlice0 := buf[sszVarOffset0:sszVarOffset1] // c.Block + sszSlice1 := buf[sszVarOffset1:sszVarOffset2] // c.KzgProofs + sszSlice2 := buf[sszVarOffset2:] // c.Blobs + + // Field 0: Block + c.Block = new(SignedBeaconBlockDeneb) + if err = c.Block.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Block: %w", err) } - // Field (2) 'SignatureSlot' - l.SignatureSlot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[104:112]) + // Field 1: KzgProofs + { + if len(sszSlice1)%48 != 0 { + return fmt.Errorf("misaligned bytes: c.KzgProofs length is %d, which is not a multiple of 48: %w", len(sszSlice1), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice1) / 48 + if numElem > 4096 { + return fmt.Errorf("ssz-max exceeded: c.KzgProofs has %d elements, ssz-max is 4096: %w", numElem, ssz.ErrListTooBig) + } + c.KzgProofs = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte + + tmpSlice := sszSlice1[i*48 : (1+i)*48] + tmp = make([]byte, 0, 48) + tmp = append(tmp, tmpSlice...) + c.KzgProofs[i] = tmp + } + } - // Field (0) 'AttestedHeader' + // Field 2: Blobs { - buf = tail[o0:] - if l.AttestedHeader == nil { - l.AttestedHeader = new(LightClientHeaderDeneb) + if len(sszSlice2)%131072 != 0 { + return fmt.Errorf("misaligned bytes: c.Blobs length is %d, which is not a multiple of 131072: %w", len(sszSlice2), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice2) / 131072 + if numElem > 4096 { + return fmt.Errorf("ssz-max exceeded: c.Blobs has %d elements, ssz-max is 4096: %w", numElem, ssz.ErrListTooBig) } - if err = l.AttestedHeader.UnmarshalSSZ(buf); err != nil { - return err + c.Blobs = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte + + tmpSlice := sszSlice2[i*131072 : (1+i)*131072] + tmp = make([]byte, 0, 131072) + tmp = append(tmp, tmpSlice...) + c.Blobs[i] = tmp } } return err } -// SizeSSZ returns the ssz encoded size in bytes for the LightClientOptimisticUpdateDeneb object -func (l *LightClientOptimisticUpdateDeneb) SizeSSZ() (size int) { - size = 112 +func (c *SignedBeaconBlockContentsDeneb) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (0) 'AttestedHeader' - if l.AttestedHeader == nil { - l.AttestedHeader = new(LightClientHeaderDeneb) +func (c *SignedBeaconBlockContentsDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Block + if err := c.Block.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Block: %w", err) + } + // Field 1: KzgProofs + { + if len(c.KzgProofs) > 4096 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.KzgProofs { + if len(o) != 48 { + return ssz.ErrBytesLength + } + hh.PutBytes(o) + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.KzgProofs)), 4096) + } + // Field 2: Blobs + { + if len(c.Blobs) > 4096 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.Blobs { + if len(o) != 131072 { + return ssz.ErrBytesLength + } + hh.PutBytes(o) + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Blobs)), 4096) } - size += l.AttestedHeader.SizeSSZ() + hh.Merkleize(indx) + return nil +} - return +func (c *SignedBeaconBlockDeneb) SizeSSZ() int { + size := 100 + if c.Block == nil { + c.Block = new(BeaconBlockDeneb) + } + size += c.Block.SizeSSZ() + return size } -// HashTreeRoot ssz hashes the LightClientOptimisticUpdateDeneb object -func (l *LightClientOptimisticUpdateDeneb) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(l) +func (c *SignedBeaconBlockDeneb) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// HashTreeRootWith ssz hashes the LightClientOptimisticUpdateDeneb object with a hasher -func (l *LightClientOptimisticUpdateDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() +func (c *SignedBeaconBlockDeneb) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 100 - // Field (0) 'AttestedHeader' - if err = l.AttestedHeader.HashTreeRootWith(hh); err != nil { - return + // Field 0: Block + if c.Block == nil { + c.Block = new(BeaconBlockDeneb) } + dst = ssz.WriteOffset(dst, offset) + offset += c.Block.SizeSSZ() - // Field (1) 'SyncAggregate' - if err = l.SyncAggregate.HashTreeRootWith(hh); err != nil { - return + // Field 1: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.Signature...) - // Field (2) 'SignatureSlot' - ssz.PutUint(hh, l.SignatureSlot) - - hh.Merkleize(indx) - return + // Field 0: Block + if dst, err = c.Block.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Block: %w", err) + } + return dst, err } -// MarshalSSZ ssz marshals the LightClientHeaderDeneb object -func (l *LightClientHeaderDeneb) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(l) -} +func (c *SignedBeaconBlockDeneb) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 100 { + return ssz.ErrSize + } -// MarshalSSZTo ssz marshals the LightClientHeaderDeneb object to a target array -func (l *LightClientHeaderDeneb) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(244) + sszSlice1 := buf[4:100] // c.Signature - // Field (0) 'Beacon' - if l.Beacon == nil { - l.Beacon = new(BeaconBlockHeader) + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Block + if sszVarOffset0 != 100 { + return ssz.ErrInvalidVariableOffset } - if dst, err = l.Beacon.MarshalSSZTo(dst); err != nil { - return + if sszVarOffset0 > size { + return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:] // c.Block - // Offset (1) 'Execution' - dst = ssz.WriteOffset(dst, offset) - if l.Execution == nil { - l.Execution = new(v1.ExecutionPayloadHeaderDeneb) + // Field 0: Block + c.Block = new(BeaconBlockDeneb) + if err = c.Block.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Block: %w", err) } - offset += l.Execution.SizeSSZ() - // Field (2) 'ExecutionBranch' - if size := len(l.ExecutionBranch); size != 4 { - err = ssz.ErrVectorLengthFn("--.ExecutionBranch", size, 4) - return + // Field 1: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice1...) + return err +} + +func (c *SignedBeaconBlockDeneb) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - for ii := 0; ii < 4; ii++ { - if size := len(l.ExecutionBranch[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.ExecutionBranch[ii]", size, 32) - return - } - dst = append(dst, l.ExecutionBranch[ii]...) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} + +func (c *SignedBeaconBlockDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Block + if err := c.Block.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Block: %w", err) + } + // Field 1: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Signature) + hh.Merkleize(indx) + return nil +} + +func (c *SignedBlindedBeaconBlockDeneb) SizeSSZ() int { + size := 100 + if c.Message == nil { + c.Message = new(BlindedBeaconBlockDeneb) + } + size += c.Message.SizeSSZ() + return size +} + +func (c *SignedBlindedBeaconBlockDeneb) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} + +func (c *SignedBlindedBeaconBlockDeneb) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 100 + + // Field 0: Message + if c.Message == nil { + c.Message = new(BlindedBeaconBlockDeneb) } + dst = ssz.WriteOffset(dst, offset) + offset += c.Message.SizeSSZ() - // Field (1) 'Execution' - if dst, err = l.Execution.MarshalSSZTo(dst); err != nil { - return + // Field 1: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.Signature...) - return + // Field 0: Message + if dst, err = c.Message.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Message: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the LightClientHeaderDeneb object -func (l *LightClientHeaderDeneb) UnmarshalSSZ(buf []byte) error { +func (c *SignedBlindedBeaconBlockDeneb) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 244 { + if size < 100 { return ssz.ErrSize } - tail := buf - var o1 uint64 + sszSlice1 := buf[4:100] // c.Signature - // Field (0) 'Beacon' - if l.Beacon == nil { - l.Beacon = new(BeaconBlockHeader) + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Message + if sszVarOffset0 != 100 { + return ssz.ErrInvalidVariableOffset } - if err = l.Beacon.UnmarshalSSZ(buf[0:112]); err != nil { - return err + if sszVarOffset0 > size { + return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:] // c.Message - // Offset (1) 'Execution' - if o1 = ssz.ReadOffset(buf[112:116]); o1 > size { - return ssz.ErrOffset + // Field 0: Message + c.Message = new(BlindedBeaconBlockDeneb) + if err = c.Message.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Message: %w", err) } - if o1 != 244 { - return ssz.ErrInvalidVariableOffset + // Field 1: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice1...) + return err +} + +func (c *SignedBlindedBeaconBlockDeneb) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (2) 'ExecutionBranch' - l.ExecutionBranch = make([][]byte, 4) - for ii := 0; ii < 4; ii++ { - if cap(l.ExecutionBranch[ii]) == 0 { - l.ExecutionBranch[ii] = make([]byte, 0, len(buf[116:244][ii*32:(ii+1)*32])) - } - l.ExecutionBranch[ii] = append(l.ExecutionBranch[ii], buf[116:244][ii*32:(ii+1)*32]...) +func (c *SignedBlindedBeaconBlockDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Message + if err := c.Message.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Message: %w", err) + } + // Field 1: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength } + hh.PutBytes(c.Signature) + hh.Merkleize(indx) + return nil +} - // Field (1) 'Execution' - { - buf = tail[o1:] - if l.Execution == nil { - l.Execution = new(v1.ExecutionPayloadHeaderDeneb) - } - if err = l.Execution.UnmarshalSSZ(buf); err != nil { - return err - } +func (c *SignedBuilderBidDeneb) SizeSSZ() int { + size := 100 + if c.Message == nil { + c.Message = new(BuilderBidDeneb) } - return err + size += c.Message.SizeSSZ() + return size +} + +func (c *SignedBuilderBidDeneb) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// SizeSSZ returns the ssz encoded size in bytes for the LightClientHeaderDeneb object -func (l *LightClientHeaderDeneb) SizeSSZ() (size int) { - size = 244 +func (c *SignedBuilderBidDeneb) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 100 - // Field (1) 'Execution' - if l.Execution == nil { - l.Execution = new(v1.ExecutionPayloadHeaderDeneb) + // Field 0: Message + if c.Message == nil { + c.Message = new(BuilderBidDeneb) } - size += l.Execution.SizeSSZ() + dst = ssz.WriteOffset(dst, offset) + offset += c.Message.SizeSSZ() - return -} + // Field 1: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.Signature...) -// HashTreeRoot ssz hashes the LightClientHeaderDeneb object -func (l *LightClientHeaderDeneb) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(l) + // Field 0: Message + if dst, err = c.Message.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Message: %w", err) + } + return dst, err } -// HashTreeRootWith ssz hashes the LightClientHeaderDeneb object with a hasher -func (l *LightClientHeaderDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() +func (c *SignedBuilderBidDeneb) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 100 { + return ssz.ErrSize + } + + sszSlice1 := buf[4:100] // c.Signature - // Field (0) 'Beacon' - if err = l.Beacon.HashTreeRootWith(hh); err != nil { - return + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Message + if sszVarOffset0 != 100 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset0 > size { + return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:] // c.Message - // Field (1) 'Execution' - if err = l.Execution.HashTreeRootWith(hh); err != nil { - return + // Field 0: Message + c.Message = new(BuilderBidDeneb) + if err = c.Message.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Message: %w", err) } - // Field (2) 'ExecutionBranch' - { - if size := len(l.ExecutionBranch); size != 4 { - err = ssz.ErrVectorLengthFn("--.ExecutionBranch", size, 4) - return - } - subIndx := hh.Index() - for _, i := range l.ExecutionBranch { - if len(i) != 32 { - err = ssz.ErrBytesLength - return - } - hh.Append(i) - } - hh.Merkleize(subIndx) + // Field 1: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice1...) + return err +} + +func (c *SignedBuilderBidDeneb) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} +func (c *SignedBuilderBidDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Message + if err := c.Message.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Message: %w", err) + } + // Field 1: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Signature) hh.Merkleize(indx) - return + return nil } diff --git a/proto/prysm/v1alpha1/deneb.ssz.go b/proto/prysm/v1alpha1/deneb.ssz.go index 9ad167849b4a..ef3dbc25ce04 100644 --- a/proto/prysm/v1alpha1/deneb.ssz.go +++ b/proto/prysm/v1alpha1/deneb.ssz.go @@ -1,4576 +1,4315 @@ //go:build !minimal -// Code generated by fastssz. DO NOT EDIT. package eth import ( - github_com_OffchainLabs_prysm_v7_consensus_types_primitives "github.com/OffchainLabs/prysm/v7/consensus-types/primitives" + binary "encoding/binary" + "fmt" + go_bitfield "github.com/OffchainLabs/go-bitfield" + ssz "github.com/OffchainLabs/methodical-ssz/ssz" v1 "github.com/OffchainLabs/prysm/v7/proto/engine/v1" - ssz "github.com/prysmaticlabs/fastssz" ) -// MarshalSSZ ssz marshals the SignedBeaconBlockContentsDeneb object -func (s *SignedBeaconBlockContentsDeneb) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) +func (c *BeaconBlockBodyDeneb) SizeSSZ() int { + size := 392 + size += len(c.ProposerSlashings) * 416 + for _, o := range c.AttesterSlashings { + size += 4 + size += o.SizeSSZ() + } + for _, o := range c.Attestations { + size += 4 + size += o.SizeSSZ() + } + size += len(c.Deposits) * 1240 + size += len(c.VoluntaryExits) * 112 + if c.ExecutionPayload == nil { + c.ExecutionPayload = new(v1.ExecutionPayloadDeneb) + } + size += c.ExecutionPayload.SizeSSZ() + size += len(c.BlsToExecutionChanges) * 172 + size += len(c.BlobKzgCommitments) * 48 + return size +} + +func (c *BeaconBlockBodyDeneb) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the SignedBeaconBlockContentsDeneb object to a target array -func (s *SignedBeaconBlockContentsDeneb) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(12) +func (c *BeaconBlockBodyDeneb) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 392 + + // Field 0: RandaoReveal + if len(c.RandaoReveal) != 96 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.RandaoReveal...) + + // Field 1: Eth1Data + if c.Eth1Data == nil { + c.Eth1Data = new(Eth1Data) + } + if dst, err = c.Eth1Data.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Eth1Data: %w", err) + } + + // Field 2: Graffiti + if len(c.Graffiti) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.Graffiti...) + + // Field 3: ProposerSlashings + dst = ssz.WriteOffset(dst, offset) + offset += len(c.ProposerSlashings) * 416 + + // Field 4: AttesterSlashings + dst = ssz.WriteOffset(dst, offset) + for _, o := range c.AttesterSlashings { + offset += 4 + offset += o.SizeSSZ() + } + + // Field 5: Attestations + dst = ssz.WriteOffset(dst, offset) + for _, o := range c.Attestations { + offset += 4 + offset += o.SizeSSZ() + } + + // Field 6: Deposits + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Deposits) * 1240 - // Offset (0) 'Block' + // Field 7: VoluntaryExits dst = ssz.WriteOffset(dst, offset) - if s.Block == nil { - s.Block = new(SignedBeaconBlockDeneb) + offset += len(c.VoluntaryExits) * 112 + + // Field 8: SyncAggregate + if c.SyncAggregate == nil { + c.SyncAggregate = new(SyncAggregate) } - offset += s.Block.SizeSSZ() + if dst, err = c.SyncAggregate.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SyncAggregate: %w", err) + } + + // Field 9: ExecutionPayload + if c.ExecutionPayload == nil { + c.ExecutionPayload = new(v1.ExecutionPayloadDeneb) + } + dst = ssz.WriteOffset(dst, offset) + offset += c.ExecutionPayload.SizeSSZ() - // Offset (1) 'KzgProofs' + // Field 10: BlsToExecutionChanges dst = ssz.WriteOffset(dst, offset) - offset += len(s.KzgProofs) * 48 + offset += len(c.BlsToExecutionChanges) * 172 - // Offset (2) 'Blobs' + // Field 11: BlobKzgCommitments dst = ssz.WriteOffset(dst, offset) - offset += len(s.Blobs) * 131072 + offset += len(c.BlobKzgCommitments) * 48 - // Field (0) 'Block' - if dst, err = s.Block.MarshalSSZTo(dst); err != nil { - return + // Field 3: ProposerSlashings + if len(c.ProposerSlashings) > 16 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.ProposerSlashings { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ProposerSlashings: %w", err) + } + } + + // Field 4: AttesterSlashings + if len(c.AttesterSlashings) > 2 { + return nil, ssz.ErrListTooBig + } + { + offset = 4 * len(c.AttesterSlashings) + for _, o := range c.AttesterSlashings { + dst = ssz.WriteOffset(dst, offset) + offset += o.SizeSSZ() + } + } + for _, o := range c.AttesterSlashings { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("AttesterSlashings: %w", err) + } + } + + // Field 5: Attestations + if len(c.Attestations) > 128 { + return nil, ssz.ErrListTooBig + } + { + offset = 4 * len(c.Attestations) + for _, o := range c.Attestations { + dst = ssz.WriteOffset(dst, offset) + offset += o.SizeSSZ() + } + } + for _, o := range c.Attestations { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Attestations: %w", err) + } + } + + // Field 6: Deposits + if len(c.Deposits) > 16 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.Deposits { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Deposits: %w", err) + } } - // Field (1) 'KzgProofs' - if size := len(s.KzgProofs); size > 4096 { - err = ssz.ErrListTooBigFn("--.KzgProofs", size, 4096) - return + // Field 7: VoluntaryExits + if len(c.VoluntaryExits) > 16 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(s.KzgProofs); ii++ { - if size := len(s.KzgProofs[ii]); size != 48 { - err = ssz.ErrBytesLengthFn("--.KzgProofs[ii]", size, 48) - return + for _, o := range c.VoluntaryExits { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("VoluntaryExits: %w", err) } - dst = append(dst, s.KzgProofs[ii]...) } - // Field (2) 'Blobs' - if size := len(s.Blobs); size > 4096 { - err = ssz.ErrListTooBigFn("--.Blobs", size, 4096) - return + // Field 9: ExecutionPayload + if dst, err = c.ExecutionPayload.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ExecutionPayload: %w", err) + } + + // Field 10: BlsToExecutionChanges + if len(c.BlsToExecutionChanges) > 16 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(s.Blobs); ii++ { - if size := len(s.Blobs[ii]); size != 131072 { - err = ssz.ErrBytesLengthFn("--.Blobs[ii]", size, 131072) - return + for _, o := range c.BlsToExecutionChanges { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("BlsToExecutionChanges: %w", err) } - dst = append(dst, s.Blobs[ii]...) } - return + // Field 11: BlobKzgCommitments + if len(c.BlobKzgCommitments) > 4096 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.BlobKzgCommitments { + if len(o) != 48 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the SignedBeaconBlockContentsDeneb object -func (s *SignedBeaconBlockContentsDeneb) UnmarshalSSZ(buf []byte) error { +func (c *BeaconBlockBodyDeneb) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 12 { + if size < 392 { return ssz.ErrSize } - tail := buf - var o0, o1, o2 uint64 + sszSlice0 := buf[0:96] // c.RandaoReveal + sszSlice1 := buf[96:168] // c.Eth1Data + sszSlice2 := buf[168:200] // c.Graffiti + sszSlice8 := buf[220:380] // c.SyncAggregate - // Offset (0) 'Block' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { + sszVarOffset3 := ssz.ReadOffset(buf[200:204]) // c.ProposerSlashings + if sszVarOffset3 != 392 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset3 > size { return ssz.ErrOffset } - - if o0 != 12 { - return ssz.ErrInvalidVariableOffset + sszVarOffset4 := ssz.ReadOffset(buf[204:208]) // c.AttesterSlashings + if sszVarOffset4 > size || sszVarOffset4 < sszVarOffset3 { + return ssz.ErrOffset } - - // Offset (1) 'KzgProofs' - if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 { + sszVarOffset5 := ssz.ReadOffset(buf[208:212]) // c.Attestations + if sszVarOffset5 > size || sszVarOffset5 < sszVarOffset4 { return ssz.ErrOffset } - - // Offset (2) 'Blobs' - if o2 = ssz.ReadOffset(buf[8:12]); o2 > size || o1 > o2 { + sszVarOffset6 := ssz.ReadOffset(buf[212:216]) // c.Deposits + if sszVarOffset6 > size || sszVarOffset6 < sszVarOffset5 { + return ssz.ErrOffset + } + sszVarOffset7 := ssz.ReadOffset(buf[216:220]) // c.VoluntaryExits + if sszVarOffset7 > size || sszVarOffset7 < sszVarOffset6 { + return ssz.ErrOffset + } + sszVarOffset9 := ssz.ReadOffset(buf[380:384]) // c.ExecutionPayload + if sszVarOffset9 > size || sszVarOffset9 < sszVarOffset7 { return ssz.ErrOffset } + sszVarOffset10 := ssz.ReadOffset(buf[384:388]) // c.BlsToExecutionChanges + if sszVarOffset10 > size || sszVarOffset10 < sszVarOffset9 { + return ssz.ErrOffset + } + sszVarOffset11 := ssz.ReadOffset(buf[388:392]) // c.BlobKzgCommitments + if sszVarOffset11 > size || sszVarOffset11 < sszVarOffset10 { + return ssz.ErrOffset + } + sszSlice3 := buf[sszVarOffset3:sszVarOffset4] // c.ProposerSlashings + sszSlice4 := buf[sszVarOffset4:sszVarOffset5] // c.AttesterSlashings + sszSlice5 := buf[sszVarOffset5:sszVarOffset6] // c.Attestations + sszSlice6 := buf[sszVarOffset6:sszVarOffset7] // c.Deposits + sszSlice7 := buf[sszVarOffset7:sszVarOffset9] // c.VoluntaryExits + sszSlice9 := buf[sszVarOffset9:sszVarOffset10] // c.ExecutionPayload + sszSlice10 := buf[sszVarOffset10:sszVarOffset11] // c.BlsToExecutionChanges + sszSlice11 := buf[sszVarOffset11:] // c.BlobKzgCommitments + + // Field 0: RandaoReveal + c.RandaoReveal = make([]byte, 0, 96) + c.RandaoReveal = append(c.RandaoReveal, sszSlice0...) + + // Field 1: Eth1Data + c.Eth1Data = new(Eth1Data) + if err = c.Eth1Data.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Eth1Data: %w", err) + } + + // Field 2: Graffiti + c.Graffiti = make([]byte, 0, 32) + c.Graffiti = append(c.Graffiti, sszSlice2...) - // Field (0) 'Block' + // Field 3: ProposerSlashings { - buf = tail[o0:o1] - if s.Block == nil { - s.Block = new(SignedBeaconBlockDeneb) + if len(sszSlice3)%416 != 0 { + return fmt.Errorf("misaligned bytes: c.ProposerSlashings length is %d, which is not a multiple of 416: %w", len(sszSlice3), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice3) / 416 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.ProposerSlashings has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.ProposerSlashings = make([]*ProposerSlashing, numElem) + for i := 0; i < numElem; i++ { + var tmp *ProposerSlashing + tmp = new(ProposerSlashing) + tmpSlice := sszSlice3[i*416 : (1+i)*416] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("ProposerSlashings: %w", err) + } + c.ProposerSlashings[i] = tmp } - if err = s.Block.UnmarshalSSZ(buf); err != nil { - return err + } + + // Field 4: AttesterSlashings + { + // empty lists are zero length, so make sure there is room for an offset + // before attempting to unmarshal it + if len(sszSlice4) > 3 { + startOffset := ssz.ReadOffset(sszSlice4[0:4]) + if startOffset == 0 { + return fmt.Errorf("encountered invalid offset of 0 when decoding c.AttesterSlashings") + } + if startOffset%4 != 0 { + return fmt.Errorf("misaligned list bytes: when decoding c.AttesterSlashings, end-of-list offset is %d, which is not a multiple of 4 (offset size)", startOffset) + } + listLen := startOffset / 4 + if listLen > 2 { + return fmt.Errorf("ssz-max exceeded: c.AttesterSlashings has %d elements, ssz-max is 2: %w", listLen, ssz.ErrListTooBig) + } + totalVarBytes := uint64(len(sszSlice4)) + if totalVarBytes < startOffset { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.AttesterSlashings") + } + c.AttesterSlashings = make([]*AttesterSlashing, listLen) + var tmpSlice []byte + for i := uint64(0); i < listLen; i++ { + var tmp *AttesterSlashing + tmp = new(AttesterSlashing) + endOffset := totalVarBytes + if i+1 != listLen { + endOffset = ssz.ReadOffset(sszSlice4[(i+1)*4 : (i+2)*4]) + if totalVarBytes < endOffset { + return fmt.Errorf("offset %d points past the end of buffer when decoding c.AttesterSlashings", endOffset) + } + } + if endOffset < startOffset { + return fmt.Errorf("offset %d is not greater than start offset %d when decoding c.AttesterSlashings", endOffset, startOffset) + } + tmpSlice = sszSlice4[startOffset:endOffset] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("AttesterSlashings: %w", err) + } + c.AttesterSlashings[i] = tmp + startOffset = endOffset + } + } else { + if len(sszSlice4) > 0 { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.AttesterSlashings") + } + c.AttesterSlashings = make([]*AttesterSlashing, 0) } } - // Field (1) 'KzgProofs' + // Field 5: Attestations { - buf = tail[o1:o2] - num, err := ssz.DivideInt2(len(buf), 48, 4096) - if err != nil { - return err - } - s.KzgProofs = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(s.KzgProofs[ii]) == 0 { - s.KzgProofs[ii] = make([]byte, 0, len(buf[ii*48:(ii+1)*48])) + // empty lists are zero length, so make sure there is room for an offset + // before attempting to unmarshal it + if len(sszSlice5) > 3 { + startOffset := ssz.ReadOffset(sszSlice5[0:4]) + if startOffset == 0 { + return fmt.Errorf("encountered invalid offset of 0 when decoding c.Attestations") + } + if startOffset%4 != 0 { + return fmt.Errorf("misaligned list bytes: when decoding c.Attestations, end-of-list offset is %d, which is not a multiple of 4 (offset size)", startOffset) + } + listLen := startOffset / 4 + if listLen > 128 { + return fmt.Errorf("ssz-max exceeded: c.Attestations has %d elements, ssz-max is 128: %w", listLen, ssz.ErrListTooBig) } - s.KzgProofs[ii] = append(s.KzgProofs[ii], buf[ii*48:(ii+1)*48]...) + totalVarBytes := uint64(len(sszSlice5)) + if totalVarBytes < startOffset { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.Attestations") + } + c.Attestations = make([]*Attestation, listLen) + var tmpSlice []byte + for i := uint64(0); i < listLen; i++ { + var tmp *Attestation + tmp = new(Attestation) + endOffset := totalVarBytes + if i+1 != listLen { + endOffset = ssz.ReadOffset(sszSlice5[(i+1)*4 : (i+2)*4]) + if totalVarBytes < endOffset { + return fmt.Errorf("offset %d points past the end of buffer when decoding c.Attestations", endOffset) + } + } + if endOffset < startOffset { + return fmt.Errorf("offset %d is not greater than start offset %d when decoding c.Attestations", endOffset, startOffset) + } + tmpSlice = sszSlice5[startOffset:endOffset] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Attestations: %w", err) + } + c.Attestations[i] = tmp + startOffset = endOffset + } + } else { + if len(sszSlice5) > 0 { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.Attestations") + } + c.Attestations = make([]*Attestation, 0) } } - // Field (2) 'Blobs' + // Field 6: Deposits { - buf = tail[o2:] - num, err := ssz.DivideInt2(len(buf), 131072, 4096) - if err != nil { - return err - } - s.Blobs = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(s.Blobs[ii]) == 0 { - s.Blobs[ii] = make([]byte, 0, len(buf[ii*131072:(ii+1)*131072])) + if len(sszSlice6)%1240 != 0 { + return fmt.Errorf("misaligned bytes: c.Deposits length is %d, which is not a multiple of 1240: %w", len(sszSlice6), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice6) / 1240 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.Deposits has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.Deposits = make([]*Deposit, numElem) + for i := 0; i < numElem; i++ { + var tmp *Deposit + tmp = new(Deposit) + tmpSlice := sszSlice6[i*1240 : (1+i)*1240] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Deposits: %w", err) } - s.Blobs[ii] = append(s.Blobs[ii], buf[ii*131072:(ii+1)*131072]...) + c.Deposits[i] = tmp + } + } + + // Field 7: VoluntaryExits + { + if len(sszSlice7)%112 != 0 { + return fmt.Errorf("misaligned bytes: c.VoluntaryExits length is %d, which is not a multiple of 112: %w", len(sszSlice7), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice7) / 112 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.VoluntaryExits has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.VoluntaryExits = make([]*SignedVoluntaryExit, numElem) + for i := 0; i < numElem; i++ { + var tmp *SignedVoluntaryExit + tmp = new(SignedVoluntaryExit) + tmpSlice := sszSlice7[i*112 : (1+i)*112] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("VoluntaryExits: %w", err) + } + c.VoluntaryExits[i] = tmp } } - return err -} -// SizeSSZ returns the ssz encoded size in bytes for the SignedBeaconBlockContentsDeneb object -func (s *SignedBeaconBlockContentsDeneb) SizeSSZ() (size int) { - size = 12 + // Field 8: SyncAggregate + c.SyncAggregate = new(SyncAggregate) + if err = c.SyncAggregate.UnmarshalSSZ(sszSlice8); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) + } - // Field (0) 'Block' - if s.Block == nil { - s.Block = new(SignedBeaconBlockDeneb) + // Field 9: ExecutionPayload + c.ExecutionPayload = new(v1.ExecutionPayloadDeneb) + if err = c.ExecutionPayload.UnmarshalSSZ(sszSlice9); err != nil { + return fmt.Errorf("ExecutionPayload: %w", err) } - size += s.Block.SizeSSZ() - // Field (1) 'KzgProofs' - size += len(s.KzgProofs) * 48 + // Field 10: BlsToExecutionChanges + { + if len(sszSlice10)%172 != 0 { + return fmt.Errorf("misaligned bytes: c.BlsToExecutionChanges length is %d, which is not a multiple of 172: %w", len(sszSlice10), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice10) / 172 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.BlsToExecutionChanges has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.BlsToExecutionChanges = make([]*SignedBLSToExecutionChange, numElem) + for i := 0; i < numElem; i++ { + var tmp *SignedBLSToExecutionChange + tmp = new(SignedBLSToExecutionChange) + tmpSlice := sszSlice10[i*172 : (1+i)*172] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("BlsToExecutionChanges: %w", err) + } + c.BlsToExecutionChanges[i] = tmp + } + } - // Field (2) 'Blobs' - size += len(s.Blobs) * 131072 + // Field 11: BlobKzgCommitments + { + if len(sszSlice11)%48 != 0 { + return fmt.Errorf("misaligned bytes: c.BlobKzgCommitments length is %d, which is not a multiple of 48: %w", len(sszSlice11), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice11) / 48 + if numElem > 4096 { + return fmt.Errorf("ssz-max exceeded: c.BlobKzgCommitments has %d elements, ssz-max is 4096: %w", numElem, ssz.ErrListTooBig) + } + c.BlobKzgCommitments = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte - return + tmpSlice := sszSlice11[i*48 : (1+i)*48] + tmp = make([]byte, 0, 48) + tmp = append(tmp, tmpSlice...) + c.BlobKzgCommitments[i] = tmp + } + } + return err } -// HashTreeRoot ssz hashes the SignedBeaconBlockContentsDeneb object -func (s *SignedBeaconBlockContentsDeneb) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) +func (c *BeaconBlockBodyDeneb) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the SignedBeaconBlockContentsDeneb object with a hasher -func (s *SignedBeaconBlockContentsDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *BeaconBlockBodyDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Block' - if err = s.Block.HashTreeRootWith(hh); err != nil { - return + // Field 0: RandaoReveal + if len(c.RandaoReveal) != 96 { + return ssz.ErrBytesLength } - - // Field (1) 'KzgProofs' + hh.PutBytes(c.RandaoReveal) + // Field 1: Eth1Data + if err := c.Eth1Data.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Eth1Data: %w", err) + } + // Field 2: Graffiti + if len(c.Graffiti) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Graffiti) + // Field 3: ProposerSlashings { - if size := len(s.KzgProofs); size > 4096 { - err = ssz.ErrListTooBigFn("--.KzgProofs", size, 4096) - return + if len(c.ProposerSlashings) > 16 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range s.KzgProofs { - if len(i) != 48 { - err = ssz.ErrBytesLength - return + for _, o := range c.ProposerSlashings { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ProposerSlashings: %w", err) } - hh.PutBytes(i) } - - numItems := uint64(len(s.KzgProofs)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.ProposerSlashings)), 16) } - - // Field (2) 'Blobs' + // Field 4: AttesterSlashings { - if size := len(s.Blobs); size > 4096 { - err = ssz.ErrListTooBigFn("--.Blobs", size, 4096) - return + if len(c.AttesterSlashings) > 2 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range s.Blobs { - if len(i) != 131072 { - err = ssz.ErrBytesLength - return + for _, o := range c.AttesterSlashings { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("AttesterSlashings: %w", err) } - hh.PutBytes(i) } - - numItems := uint64(len(s.Blobs)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) - } - - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the SignedBeaconBlockDeneb object -func (s *SignedBeaconBlockDeneb) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) -} - -// MarshalSSZTo ssz marshals the SignedBeaconBlockDeneb object to a target array -func (s *SignedBeaconBlockDeneb) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(100) - - // Offset (0) 'Block' - dst = ssz.WriteOffset(dst, offset) - if s.Block == nil { - s.Block = new(BeaconBlockDeneb) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.AttesterSlashings)), 2) } - offset += s.Block.SizeSSZ() - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 5: Attestations + { + if len(c.Attestations) > 128 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.Attestations { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Attestations: %w", err) + } + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Attestations)), 128) } - dst = append(dst, s.Signature...) - - // Field (0) 'Block' - if dst, err = s.Block.MarshalSSZTo(dst); err != nil { - return + // Field 6: Deposits + { + if len(c.Deposits) > 16 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.Deposits { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Deposits: %w", err) + } + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Deposits)), 16) } - - return -} - -// UnmarshalSSZ ssz unmarshals the SignedBeaconBlockDeneb object -func (s *SignedBeaconBlockDeneb) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 100 { - return ssz.ErrSize + // Field 7: VoluntaryExits + { + if len(c.VoluntaryExits) > 16 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.VoluntaryExits { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("VoluntaryExits: %w", err) + } + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.VoluntaryExits)), 16) } - - tail := buf - var o0 uint64 - - // Offset (0) 'Block' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset + // Field 8: SyncAggregate + if err := c.SyncAggregate.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) } - - if o0 != 100 { - return ssz.ErrInvalidVariableOffset + // Field 9: ExecutionPayload + if err := c.ExecutionPayload.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ExecutionPayload: %w", err) } - - // Field (1) 'Signature' - if cap(s.Signature) == 0 { - s.Signature = make([]byte, 0, len(buf[4:100])) + // Field 10: BlsToExecutionChanges + { + if len(c.BlsToExecutionChanges) > 16 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.BlsToExecutionChanges { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("BlsToExecutionChanges: %w", err) + } + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.BlsToExecutionChanges)), 16) } - s.Signature = append(s.Signature, buf[4:100]...) - - // Field (0) 'Block' + // Field 11: BlobKzgCommitments { - buf = tail[o0:] - if s.Block == nil { - s.Block = new(BeaconBlockDeneb) + if len(c.BlobKzgCommitments) > 4096 { + return ssz.ErrListTooBig } - if err = s.Block.UnmarshalSSZ(buf); err != nil { - return err + subIndx := hh.Index() + for _, o := range c.BlobKzgCommitments { + if len(o) != 48 { + return ssz.ErrBytesLength + } + hh.PutBytes(o) } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.BlobKzgCommitments)), 4096) } - return err + hh.Merkleize(indx) + return nil } -// SizeSSZ returns the ssz encoded size in bytes for the SignedBeaconBlockDeneb object -func (s *SignedBeaconBlockDeneb) SizeSSZ() (size int) { - size = 100 - - // Field (0) 'Block' - if s.Block == nil { - s.Block = new(BeaconBlockDeneb) +func (c *BeaconBlockContentsDeneb) SizeSSZ() int { + size := 12 + if c.Block == nil { + c.Block = new(BeaconBlockDeneb) } - size += s.Block.SizeSSZ() - - return + size += c.Block.SizeSSZ() + size += len(c.KzgProofs) * 48 + size += len(c.Blobs) * 131072 + return size } -// HashTreeRoot ssz hashes the SignedBeaconBlockDeneb object -func (s *SignedBeaconBlockDeneb) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) +func (c *BeaconBlockContentsDeneb) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// HashTreeRootWith ssz hashes the SignedBeaconBlockDeneb object with a hasher -func (s *SignedBeaconBlockDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'Block' - if err = s.Block.HashTreeRootWith(hh); err != nil { - return - } +func (c *BeaconBlockContentsDeneb) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 12 - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 0: Block + if c.Block == nil { + c.Block = new(BeaconBlockDeneb) } - hh.PutBytes(s.Signature) - - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the BeaconBlockContentsDeneb object -func (b *BeaconBlockContentsDeneb) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} - -// MarshalSSZTo ssz marshals the BeaconBlockContentsDeneb object to a target array -func (b *BeaconBlockContentsDeneb) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(12) - - // Offset (0) 'Block' dst = ssz.WriteOffset(dst, offset) - if b.Block == nil { - b.Block = new(BeaconBlockDeneb) - } - offset += b.Block.SizeSSZ() + offset += c.Block.SizeSSZ() - // Offset (1) 'KzgProofs' + // Field 1: KzgProofs dst = ssz.WriteOffset(dst, offset) - offset += len(b.KzgProofs) * 48 + offset += len(c.KzgProofs) * 48 - // Offset (2) 'Blobs' + // Field 2: Blobs dst = ssz.WriteOffset(dst, offset) - offset += len(b.Blobs) * 131072 + offset += len(c.Blobs) * 131072 - // Field (0) 'Block' - if dst, err = b.Block.MarshalSSZTo(dst); err != nil { - return + // Field 0: Block + if dst, err = c.Block.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Block: %w", err) } - // Field (1) 'KzgProofs' - if size := len(b.KzgProofs); size > 4096 { - err = ssz.ErrListTooBigFn("--.KzgProofs", size, 4096) - return + // Field 1: KzgProofs + if len(c.KzgProofs) > 4096 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.KzgProofs); ii++ { - if size := len(b.KzgProofs[ii]); size != 48 { - err = ssz.ErrBytesLengthFn("--.KzgProofs[ii]", size, 48) - return + for _, o := range c.KzgProofs { + if len(o) != 48 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.KzgProofs[ii]...) + dst = append(dst, o...) } - // Field (2) 'Blobs' - if size := len(b.Blobs); size > 4096 { - err = ssz.ErrListTooBigFn("--.Blobs", size, 4096) - return + // Field 2: Blobs + if len(c.Blobs) > 4096 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.Blobs); ii++ { - if size := len(b.Blobs[ii]); size != 131072 { - err = ssz.ErrBytesLengthFn("--.Blobs[ii]", size, 131072) - return + for _, o := range c.Blobs { + if len(o) != 131072 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.Blobs[ii]...) + dst = append(dst, o...) } - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the BeaconBlockContentsDeneb object -func (b *BeaconBlockContentsDeneb) UnmarshalSSZ(buf []byte) error { +func (c *BeaconBlockContentsDeneb) 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) 'Block' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Block + if sszVarOffset0 != 12 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset0 > size { return ssz.ErrOffset } - - if o0 != 12 { - return ssz.ErrInvalidVariableOffset + sszVarOffset1 := ssz.ReadOffset(buf[4:8]) // c.KzgProofs + if sszVarOffset1 > size || sszVarOffset1 < sszVarOffset0 { + return ssz.ErrOffset } - - // Offset (1) 'KzgProofs' - if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 { + sszVarOffset2 := ssz.ReadOffset(buf[8:12]) // c.Blobs + if sszVarOffset2 > size || sszVarOffset2 < sszVarOffset1 { return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:sszVarOffset1] // c.Block + sszSlice1 := buf[sszVarOffset1:sszVarOffset2] // c.KzgProofs + sszSlice2 := buf[sszVarOffset2:] // c.Blobs - // Offset (2) 'Blobs' - if o2 = ssz.ReadOffset(buf[8:12]); o2 > size || o1 > o2 { - return ssz.ErrOffset + // Field 0: Block + c.Block = new(BeaconBlockDeneb) + if err = c.Block.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Block: %w", err) } - // Field (0) 'Block' + // Field 1: KzgProofs { - buf = tail[o0:o1] - if b.Block == nil { - b.Block = new(BeaconBlockDeneb) + if len(sszSlice1)%48 != 0 { + return fmt.Errorf("misaligned bytes: c.KzgProofs length is %d, which is not a multiple of 48: %w", len(sszSlice1), ssz.ErrIncorrectListSize) } - if err = b.Block.UnmarshalSSZ(buf); err != nil { - return err + numElem := len(sszSlice1) / 48 + if numElem > 4096 { + return fmt.Errorf("ssz-max exceeded: c.KzgProofs has %d elements, ssz-max is 4096: %w", numElem, ssz.ErrListTooBig) } - } + c.KzgProofs = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte - // Field (1) 'KzgProofs' - { - buf = tail[o1:o2] - num, err := ssz.DivideInt2(len(buf), 48, 4096) - if err != nil { - return err - } - b.KzgProofs = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(b.KzgProofs[ii]) == 0 { - b.KzgProofs[ii] = make([]byte, 0, len(buf[ii*48:(ii+1)*48])) - } - b.KzgProofs[ii] = append(b.KzgProofs[ii], buf[ii*48:(ii+1)*48]...) + tmpSlice := sszSlice1[i*48 : (1+i)*48] + tmp = make([]byte, 0, 48) + tmp = append(tmp, tmpSlice...) + c.KzgProofs[i] = tmp } } - // Field (2) 'Blobs' + // Field 2: Blobs { - buf = tail[o2:] - num, err := ssz.DivideInt2(len(buf), 131072, 4096) - if err != nil { - return err - } - b.Blobs = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(b.Blobs[ii]) == 0 { - b.Blobs[ii] = make([]byte, 0, len(buf[ii*131072:(ii+1)*131072])) - } - b.Blobs[ii] = append(b.Blobs[ii], buf[ii*131072:(ii+1)*131072]...) + if len(sszSlice2)%131072 != 0 { + return fmt.Errorf("misaligned bytes: c.Blobs length is %d, which is not a multiple of 131072: %w", len(sszSlice2), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice2) / 131072 + if numElem > 4096 { + return fmt.Errorf("ssz-max exceeded: c.Blobs has %d elements, ssz-max is 4096: %w", numElem, ssz.ErrListTooBig) + } + c.Blobs = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte + + tmpSlice := sszSlice2[i*131072 : (1+i)*131072] + tmp = make([]byte, 0, 131072) + tmp = append(tmp, tmpSlice...) + c.Blobs[i] = tmp } } return err } -// SizeSSZ returns the ssz encoded size in bytes for the BeaconBlockContentsDeneb object -func (b *BeaconBlockContentsDeneb) SizeSSZ() (size int) { - size = 12 - - // Field (0) 'Block' - if b.Block == nil { - b.Block = new(BeaconBlockDeneb) +func (c *BeaconBlockContentsDeneb) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - size += b.Block.SizeSSZ() - - // Field (1) 'KzgProofs' - size += len(b.KzgProofs) * 48 - - // Field (2) 'Blobs' - size += len(b.Blobs) * 131072 - - return + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRoot ssz hashes the BeaconBlockContentsDeneb object -func (b *BeaconBlockContentsDeneb) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) -} - -// HashTreeRootWith ssz hashes the BeaconBlockContentsDeneb object with a hasher -func (b *BeaconBlockContentsDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *BeaconBlockContentsDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Block' - if err = b.Block.HashTreeRootWith(hh); err != nil { - return + // Field 0: Block + if err := c.Block.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Block: %w", err) } - - // Field (1) 'KzgProofs' + // Field 1: KzgProofs { - if size := len(b.KzgProofs); size > 4096 { - err = ssz.ErrListTooBigFn("--.KzgProofs", size, 4096) - return + if len(c.KzgProofs) > 4096 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range b.KzgProofs { - if len(i) != 48 { - err = ssz.ErrBytesLength - return + for _, o := range c.KzgProofs { + if len(o) != 48 { + return ssz.ErrBytesLength } - hh.PutBytes(i) + hh.PutBytes(o) } - - numItems := uint64(len(b.KzgProofs)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.KzgProofs)), 4096) } - - // Field (2) 'Blobs' + // Field 2: Blobs { - if size := len(b.Blobs); size > 4096 { - err = ssz.ErrListTooBigFn("--.Blobs", size, 4096) - return + if len(c.Blobs) > 4096 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range b.Blobs { - if len(i) != 131072 { - err = ssz.ErrBytesLength - return + for _, o := range c.Blobs { + if len(o) != 131072 { + return ssz.ErrBytesLength } - hh.PutBytes(i) + hh.PutBytes(o) } - - numItems := uint64(len(b.Blobs)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Blobs)), 4096) } - hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the BeaconBlockDeneb object -func (b *BeaconBlockDeneb) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) +func (c *BeaconBlockDeneb) SizeSSZ() int { + size := 84 + if c.Body == nil { + c.Body = new(BeaconBlockBodyDeneb) + } + size += c.Body.SizeSSZ() + return size } -// MarshalSSZTo ssz marshals the BeaconBlockDeneb object to a target array -func (b *BeaconBlockDeneb) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(84) +func (c *BeaconBlockDeneb) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (0) 'Slot' - dst = ssz.MarshalUint(dst, b.Slot) +func (c *BeaconBlockDeneb) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 84 - // Field (1) 'ProposerIndex' - dst = ssz.MarshalUint(dst, b.ProposerIndex) + // Field 0: Slot + if dst, err = c.Slot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Slot: %w", err) + } - // Field (2) 'ParentRoot' - if size := len(b.ParentRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentRoot", size, 32) - return + // Field 1: ProposerIndex + if dst, err = c.ProposerIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ProposerIndex: %w", err) } - dst = append(dst, b.ParentRoot...) - // Field (3) 'StateRoot' - if size := len(b.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return + // Field 2: ParentRoot + if len(c.ParentRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.StateRoot...) + dst = append(dst, c.ParentRoot...) - // Offset (4) 'Body' - dst = ssz.WriteOffset(dst, offset) - if b.Body == nil { - b.Body = new(BeaconBlockBodyDeneb) + // Field 3: StateRoot + if len(c.StateRoot) != 32 { + return nil, ssz.ErrBytesLength } - offset += b.Body.SizeSSZ() + dst = append(dst, c.StateRoot...) - // Field (4) 'Body' - if dst, err = b.Body.MarshalSSZTo(dst); err != nil { - return + // Field 4: Body + if c.Body == nil { + c.Body = new(BeaconBlockBodyDeneb) } + dst = ssz.WriteOffset(dst, offset) + offset += c.Body.SizeSSZ() - return + // Field 4: Body + if dst, err = c.Body.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Body: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the BeaconBlockDeneb object -func (b *BeaconBlockDeneb) UnmarshalSSZ(buf []byte) error { +func (c *BeaconBlockDeneb) 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.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[0:8]) + sszSlice0 := buf[0:8] // c.Slot + sszSlice1 := buf[8:16] // c.ProposerIndex + sszSlice2 := buf[16:48] // c.ParentRoot + sszSlice3 := buf[48:80] // c.StateRoot - // Field (1) 'ProposerIndex' - b.ProposerIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[8:16]) - - // Field (2) 'ParentRoot' - if cap(b.ParentRoot) == 0 { - b.ParentRoot = make([]byte, 0, len(buf[16:48])) + sszVarOffset4 := ssz.ReadOffset(buf[80:84]) // c.Body + if sszVarOffset4 != 84 { + return ssz.ErrInvalidVariableOffset } - 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])) + if sszVarOffset4 > size { + return ssz.ErrOffset } - b.StateRoot = append(b.StateRoot, buf[48:80]...) + sszSlice4 := buf[sszVarOffset4:] // c.Body - // Offset (4) 'Body' - if o4 = ssz.ReadOffset(buf[80:84]); o4 > size { - return ssz.ErrOffset + // Field 0: Slot + if err = c.Slot.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Slot: %w", err) } - if o4 != 84 { - return ssz.ErrInvalidVariableOffset + // Field 1: ProposerIndex + if err = c.ProposerIndex.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("ProposerIndex: %w", err) } - // Field (4) 'Body' - { - buf = tail[o4:] - if b.Body == nil { - b.Body = new(BeaconBlockBodyDeneb) - } - if err = b.Body.UnmarshalSSZ(buf); err != nil { - return err - } + // Field 2: ParentRoot + c.ParentRoot = make([]byte, 0, 32) + c.ParentRoot = append(c.ParentRoot, sszSlice2...) + + // Field 3: StateRoot + c.StateRoot = make([]byte, 0, 32) + c.StateRoot = append(c.StateRoot, sszSlice3...) + + // Field 4: Body + c.Body = new(BeaconBlockBodyDeneb) + if err = c.Body.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("Body: %w", err) } return err } -// SizeSSZ returns the ssz encoded size in bytes for the BeaconBlockDeneb object -func (b *BeaconBlockDeneb) SizeSSZ() (size int) { - size = 84 - - // Field (4) 'Body' - if b.Body == nil { - b.Body = new(BeaconBlockBodyDeneb) +func (c *BeaconBlockDeneb) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - size += b.Body.SizeSSZ() + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - return +func (c *BeaconBlockDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Slot + if err := c.Slot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Slot: %w", err) + } + // Field 1: ProposerIndex + if err := c.ProposerIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ProposerIndex: %w", err) + } + // Field 2: ParentRoot + if len(c.ParentRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ParentRoot) + // Field 3: StateRoot + if len(c.StateRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.StateRoot) + // Field 4: Body + if err := c.Body.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Body: %w", err) + } + hh.Merkleize(indx) + return nil } -// HashTreeRoot ssz hashes the BeaconBlockDeneb object -func (b *BeaconBlockDeneb) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) +func (c *BeaconStateDeneb) SizeSSZ() int { + size := 2736653 + size += len(c.HistoricalRoots) * 32 + size += len(c.Eth1DataVotes) * 72 + size += len(c.Validators) * 121 + size += len(c.Balances) * 8 + size += len(c.PreviousEpochParticipation) + size += len(c.CurrentEpochParticipation) + size += len(c.InactivityScores) * 8 + if c.LatestExecutionPayloadHeader == nil { + c.LatestExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderDeneb) + } + size += c.LatestExecutionPayloadHeader.SizeSSZ() + size += len(c.HistoricalSummaries) * 64 + return size } -// HashTreeRootWith ssz hashes the BeaconBlockDeneb object with a hasher -func (b *BeaconBlockDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() +func (c *BeaconStateDeneb) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (0) 'Slot' - ssz.PutUint(hh, b.Slot) +func (c *BeaconStateDeneb) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 2736653 - // Field (1) 'ProposerIndex' - ssz.PutUint(hh, b.ProposerIndex) + // Field 0: GenesisTime + dst = binary.LittleEndian.AppendUint64(dst, c.GenesisTime) - // Field (2) 'ParentRoot' - if size := len(b.ParentRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentRoot", size, 32) - return + // Field 1: GenesisValidatorsRoot + if len(c.GenesisValidatorsRoot) != 32 { + return nil, ssz.ErrBytesLength } - hh.PutBytes(b.ParentRoot) + dst = append(dst, c.GenesisValidatorsRoot...) - // Field (3) 'StateRoot' - if size := len(b.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return + // Field 2: Slot + if dst, err = c.Slot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Slot: %w", err) } - hh.PutBytes(b.StateRoot) - // Field (4) 'Body' - if err = b.Body.HashTreeRootWith(hh); err != nil { - return + // Field 3: Fork + if c.Fork == nil { + c.Fork = new(Fork) + } + if dst, err = c.Fork.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Fork: %w", err) } - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the BeaconBlockBodyDeneb object -func (b *BeaconBlockBodyDeneb) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} - -// MarshalSSZTo ssz marshals the BeaconBlockBodyDeneb object to a target array -func (b *BeaconBlockBodyDeneb) 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("--.RandaoReveal", size, 96) - return + // Field 4: LatestBlockHeader + if c.LatestBlockHeader == nil { + c.LatestBlockHeader = new(BeaconBlockHeader) + } + if dst, err = c.LatestBlockHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("LatestBlockHeader: %w", err) } - dst = append(dst, b.RandaoReveal...) - // Field (1) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(Eth1Data) + // Field 5: BlockRoots + if len(c.BlockRoots) != 8192 { + return nil, ssz.ErrBytesLength } - if dst, err = b.Eth1Data.MarshalSSZTo(dst); err != nil { - return + for _, o := range c.BlockRoots { + if len(o) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) } - // Field (2) 'Graffiti' - if size := len(b.Graffiti); size != 32 { - err = ssz.ErrBytesLengthFn("--.Graffiti", size, 32) - return + // Field 6: StateRoots + if len(c.StateRoots) != 8192 { + return nil, ssz.ErrBytesLength + } + for _, o := range c.StateRoots { + if len(o) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) } - dst = append(dst, b.Graffiti...) - // Offset (3) 'ProposerSlashings' + // Field 7: HistoricalRoots dst = ssz.WriteOffset(dst, offset) - offset += len(b.ProposerSlashings) * 416 + offset += len(c.HistoricalRoots) * 32 - // Offset (4) 'AttesterSlashings' - dst = ssz.WriteOffset(dst, offset) - for ii := 0; ii < len(b.AttesterSlashings); ii++ { - offset += 4 - offset += b.AttesterSlashings[ii].SizeSSZ() + // Field 8: Eth1Data + if c.Eth1Data == nil { + c.Eth1Data = new(Eth1Data) + } + if dst, err = c.Eth1Data.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Eth1Data: %w", err) } - // Offset (5) 'Attestations' + // Field 9: Eth1DataVotes dst = ssz.WriteOffset(dst, offset) - for ii := 0; ii < len(b.Attestations); ii++ { - offset += 4 - offset += b.Attestations[ii].SizeSSZ() - } + offset += len(c.Eth1DataVotes) * 72 + + // Field 10: Eth1DepositIndex + dst = binary.LittleEndian.AppendUint64(dst, c.Eth1DepositIndex) - // Offset (6) 'Deposits' + // Field 11: Validators dst = ssz.WriteOffset(dst, offset) - offset += len(b.Deposits) * 1240 + offset += len(c.Validators) * 121 - // Offset (7) 'VoluntaryExits' + // Field 12: Balances dst = ssz.WriteOffset(dst, offset) - offset += len(b.VoluntaryExits) * 112 + offset += len(c.Balances) * 8 - // Field (8) 'SyncAggregate' - if b.SyncAggregate == nil { - b.SyncAggregate = new(SyncAggregate) + // Field 13: RandaoMixes + if len(c.RandaoMixes) != 65536 { + return nil, ssz.ErrBytesLength } - if dst, err = b.SyncAggregate.MarshalSSZTo(dst); err != nil { - return + for _, o := range c.RandaoMixes { + if len(o) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) } - // Offset (9) 'ExecutionPayload' - dst = ssz.WriteOffset(dst, offset) - if b.ExecutionPayload == nil { - b.ExecutionPayload = new(v1.ExecutionPayloadDeneb) + // Field 14: Slashings + if len(c.Slashings) != 8192 { + return nil, ssz.ErrBytesLength + } + for _, o := range c.Slashings { + dst = binary.LittleEndian.AppendUint64(dst, o) } - offset += b.ExecutionPayload.SizeSSZ() - // Offset (10) 'BlsToExecutionChanges' + // Field 15: PreviousEpochParticipation dst = ssz.WriteOffset(dst, offset) - offset += len(b.BlsToExecutionChanges) * 172 + offset += len(c.PreviousEpochParticipation) - // Offset (11) 'BlobKzgCommitments' + // Field 16: CurrentEpochParticipation dst = ssz.WriteOffset(dst, offset) - offset += len(b.BlobKzgCommitments) * 48 + offset += len(c.CurrentEpochParticipation) - // Field (3) 'ProposerSlashings' - if size := len(b.ProposerSlashings); size > 16 { - err = ssz.ErrListTooBigFn("--.ProposerSlashings", size, 16) - return + // Field 17: JustificationBits + if len([]byte(c.JustificationBits)) != 1 { + return nil, ssz.ErrBytesLength } - for ii := 0; ii < len(b.ProposerSlashings); ii++ { - if dst, err = b.ProposerSlashings[ii].MarshalSSZTo(dst); err != nil { - return - } + dst = append(dst, []byte(c.JustificationBits)...) + + // Field 18: PreviousJustifiedCheckpoint + if c.PreviousJustifiedCheckpoint == nil { + c.PreviousJustifiedCheckpoint = new(Checkpoint) + } + if dst, err = c.PreviousJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("PreviousJustifiedCheckpoint: %w", err) } - // Field (4) 'AttesterSlashings' - if size := len(b.AttesterSlashings); size > 2 { - err = ssz.ErrListTooBigFn("--.AttesterSlashings", size, 2) - return + // Field 19: CurrentJustifiedCheckpoint + if c.CurrentJustifiedCheckpoint == nil { + c.CurrentJustifiedCheckpoint = new(Checkpoint) } - { - offset = 4 * len(b.AttesterSlashings) - for ii := 0; ii < len(b.AttesterSlashings); ii++ { - dst = ssz.WriteOffset(dst, offset) - offset += b.AttesterSlashings[ii].SizeSSZ() - } + if dst, err = c.CurrentJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("CurrentJustifiedCheckpoint: %w", err) } - for ii := 0; ii < len(b.AttesterSlashings); ii++ { - if dst, err = b.AttesterSlashings[ii].MarshalSSZTo(dst); err != nil { - return - } + + // Field 20: FinalizedCheckpoint + if c.FinalizedCheckpoint == nil { + c.FinalizedCheckpoint = new(Checkpoint) + } + if dst, err = c.FinalizedCheckpoint.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("FinalizedCheckpoint: %w", err) } - // Field (5) 'Attestations' - if size := len(b.Attestations); size > 128 { - err = ssz.ErrListTooBigFn("--.Attestations", size, 128) - return + // Field 21: InactivityScores + dst = ssz.WriteOffset(dst, offset) + offset += len(c.InactivityScores) * 8 + + // Field 22: CurrentSyncCommittee + if c.CurrentSyncCommittee == nil { + c.CurrentSyncCommittee = new(SyncCommittee) } - { - offset = 4 * len(b.Attestations) - for ii := 0; ii < len(b.Attestations); ii++ { - dst = ssz.WriteOffset(dst, offset) - offset += b.Attestations[ii].SizeSSZ() - } + if dst, err = c.CurrentSyncCommittee.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("CurrentSyncCommittee: %w", err) } - for ii := 0; ii < len(b.Attestations); ii++ { - if dst, err = b.Attestations[ii].MarshalSSZTo(dst); err != nil { - return - } + + // Field 23: NextSyncCommittee + if c.NextSyncCommittee == nil { + c.NextSyncCommittee = new(SyncCommittee) + } + if dst, err = c.NextSyncCommittee.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("NextSyncCommittee: %w", err) } - // Field (6) 'Deposits' - if size := len(b.Deposits); size > 16 { - err = ssz.ErrListTooBigFn("--.Deposits", size, 16) - return + // Field 24: LatestExecutionPayloadHeader + if c.LatestExecutionPayloadHeader == nil { + c.LatestExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderDeneb) } - for ii := 0; ii < len(b.Deposits); ii++ { - if dst, err = b.Deposits[ii].MarshalSSZTo(dst); err != nil { - return - } + dst = ssz.WriteOffset(dst, offset) + offset += c.LatestExecutionPayloadHeader.SizeSSZ() + + // Field 25: NextWithdrawalIndex + dst = binary.LittleEndian.AppendUint64(dst, c.NextWithdrawalIndex) + + // Field 26: NextWithdrawalValidatorIndex + if dst, err = c.NextWithdrawalValidatorIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("NextWithdrawalValidatorIndex: %w", err) } - // Field (7) 'VoluntaryExits' - if size := len(b.VoluntaryExits); size > 16 { - err = ssz.ErrListTooBigFn("--.VoluntaryExits", size, 16) - return + // Field 27: HistoricalSummaries + dst = ssz.WriteOffset(dst, offset) + offset += len(c.HistoricalSummaries) * 64 + + // Field 7: HistoricalRoots + if len(c.HistoricalRoots) > 16777216 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.VoluntaryExits); ii++ { - if dst, err = b.VoluntaryExits[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.HistoricalRoots { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, o...) } - // Field (9) 'ExecutionPayload' - if dst, err = b.ExecutionPayload.MarshalSSZTo(dst); err != nil { - return + // Field 9: Eth1DataVotes + if len(c.Eth1DataVotes) > 2048 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.Eth1DataVotes { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Eth1DataVotes: %w", err) + } } - // Field (10) 'BlsToExecutionChanges' - if size := len(b.BlsToExecutionChanges); size > 16 { - err = ssz.ErrListTooBigFn("--.BlsToExecutionChanges", size, 16) - return + // Field 11: Validators + if len(c.Validators) > 1099511627776 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.BlsToExecutionChanges); ii++ { - if dst, err = b.BlsToExecutionChanges[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.Validators { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Validators: %w", err) } } - // Field (11) 'BlobKzgCommitments' - if size := len(b.BlobKzgCommitments); size > 4096 { - err = ssz.ErrListTooBigFn("--.BlobKzgCommitments", size, 4096) - return + // Field 12: Balances + if len(c.Balances) > 1099511627776 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.BlobKzgCommitments); ii++ { - if size := len(b.BlobKzgCommitments[ii]); size != 48 { - err = ssz.ErrBytesLengthFn("--.BlobKzgCommitments[ii]", size, 48) - return - } - dst = append(dst, b.BlobKzgCommitments[ii]...) + for _, o := range c.Balances { + dst = binary.LittleEndian.AppendUint64(dst, o) } - return -} + // Field 15: PreviousEpochParticipation + if len(c.PreviousEpochParticipation) > 1099511627776 { + return nil, ssz.ErrListTooBig + } + dst = append(dst, c.PreviousEpochParticipation...) -// UnmarshalSSZ ssz unmarshals the BeaconBlockBodyDeneb object -func (b *BeaconBlockBodyDeneb) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 392 { - return ssz.ErrSize + // Field 16: CurrentEpochParticipation + if len(c.CurrentEpochParticipation) > 1099511627776 { + return nil, ssz.ErrListTooBig } + dst = append(dst, c.CurrentEpochParticipation...) - tail := buf - var o3, o4, o5, o6, o7, o9, o10, o11 uint64 + // Field 21: InactivityScores + if len(c.InactivityScores) > 1099511627776 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.InactivityScores { + dst = binary.LittleEndian.AppendUint64(dst, o) + } - // Field (0) 'RandaoReveal' - if cap(b.RandaoReveal) == 0 { - b.RandaoReveal = make([]byte, 0, len(buf[0:96])) + // Field 24: LatestExecutionPayloadHeader + if dst, err = c.LatestExecutionPayloadHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("LatestExecutionPayloadHeader: %w", err) } - b.RandaoReveal = append(b.RandaoReveal, buf[0:96]...) - // Field (1) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(Eth1Data) + // Field 27: HistoricalSummaries + if len(c.HistoricalSummaries) > 16777216 { + return nil, ssz.ErrListTooBig } - if err = b.Eth1Data.UnmarshalSSZ(buf[96:168]); err != nil { - return err + for _, o := range c.HistoricalSummaries { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("HistoricalSummaries: %w", err) + } } + return dst, err +} - // Field (2) 'Graffiti' - if cap(b.Graffiti) == 0 { - b.Graffiti = make([]byte, 0, len(buf[168:200])) +func (c *BeaconStateDeneb) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 2736653 { + return ssz.ErrSize } - b.Graffiti = append(b.Graffiti, buf[168:200]...) - // Offset (3) 'ProposerSlashings' - if o3 = ssz.ReadOffset(buf[200:204]); o3 > size { + sszSlice0 := buf[0:8] // c.GenesisTime + sszSlice1 := buf[8:40] // c.GenesisValidatorsRoot + sszSlice2 := buf[40:48] // c.Slot + sszSlice3 := buf[48:64] // c.Fork + sszSlice4 := buf[64:176] // c.LatestBlockHeader + sszSlice5 := buf[176:262320] // c.BlockRoots + sszSlice6 := buf[262320:524464] // c.StateRoots + sszSlice8 := buf[524468:524540] // c.Eth1Data + sszSlice10 := buf[524544:524552] // c.Eth1DepositIndex + sszSlice13 := buf[524560:2621712] // c.RandaoMixes + sszSlice14 := buf[2621712:2687248] // c.Slashings + sszSlice17 := buf[2687256:2687257] // c.JustificationBits + sszSlice18 := buf[2687257:2687297] // c.PreviousJustifiedCheckpoint + sszSlice19 := buf[2687297:2687337] // c.CurrentJustifiedCheckpoint + sszSlice20 := buf[2687337:2687377] // c.FinalizedCheckpoint + sszSlice22 := buf[2687381:2712005] // c.CurrentSyncCommittee + sszSlice23 := buf[2712005:2736629] // c.NextSyncCommittee + sszSlice25 := buf[2736633:2736641] // c.NextWithdrawalIndex + sszSlice26 := buf[2736641:2736649] // c.NextWithdrawalValidatorIndex + + sszVarOffset7 := ssz.ReadOffset(buf[524464:524468]) // c.HistoricalRoots + if sszVarOffset7 != 2736653 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset7 > size { return ssz.ErrOffset } - - if o3 != 392 { - return ssz.ErrInvalidVariableOffset + sszVarOffset9 := ssz.ReadOffset(buf[524540:524544]) // c.Eth1DataVotes + if sszVarOffset9 > size || sszVarOffset9 < sszVarOffset7 { + return ssz.ErrOffset } - - // Offset (4) 'AttesterSlashings' - if o4 = ssz.ReadOffset(buf[204:208]); o4 > size || o3 > o4 { + sszVarOffset11 := ssz.ReadOffset(buf[524552:524556]) // c.Validators + if sszVarOffset11 > size || sszVarOffset11 < sszVarOffset9 { return ssz.ErrOffset } - - // Offset (5) 'Attestations' - if o5 = ssz.ReadOffset(buf[208:212]); o5 > size || o4 > o5 { + sszVarOffset12 := ssz.ReadOffset(buf[524556:524560]) // c.Balances + if sszVarOffset12 > size || sszVarOffset12 < sszVarOffset11 { return ssz.ErrOffset } - - // Offset (6) 'Deposits' - if o6 = ssz.ReadOffset(buf[212:216]); o6 > size || o5 > o6 { + sszVarOffset15 := ssz.ReadOffset(buf[2687248:2687252]) // c.PreviousEpochParticipation + if sszVarOffset15 > size || sszVarOffset15 < sszVarOffset12 { return ssz.ErrOffset } - - // Offset (7) 'VoluntaryExits' - if o7 = ssz.ReadOffset(buf[216:220]); o7 > size || o6 > o7 { + sszVarOffset16 := ssz.ReadOffset(buf[2687252:2687256]) // c.CurrentEpochParticipation + if sszVarOffset16 > size || sszVarOffset16 < sszVarOffset15 { return ssz.ErrOffset } - - // Field (8) 'SyncAggregate' - if b.SyncAggregate == nil { - b.SyncAggregate = new(SyncAggregate) + sszVarOffset21 := ssz.ReadOffset(buf[2687377:2687381]) // c.InactivityScores + if sszVarOffset21 > size || sszVarOffset21 < sszVarOffset16 { + return ssz.ErrOffset } - if err = b.SyncAggregate.UnmarshalSSZ(buf[220:380]); err != nil { - return err + sszVarOffset24 := ssz.ReadOffset(buf[2736629:2736633]) // c.LatestExecutionPayloadHeader + if sszVarOffset24 > size || sszVarOffset24 < sszVarOffset21 { + return ssz.ErrOffset } - - // Offset (9) 'ExecutionPayload' - if o9 = ssz.ReadOffset(buf[380:384]); o9 > size || o7 > o9 { + sszVarOffset27 := ssz.ReadOffset(buf[2736649:2736653]) // c.HistoricalSummaries + if sszVarOffset27 > size || sszVarOffset27 < sszVarOffset24 { return ssz.ErrOffset } + sszSlice7 := buf[sszVarOffset7:sszVarOffset9] // c.HistoricalRoots + sszSlice9 := buf[sszVarOffset9:sszVarOffset11] // c.Eth1DataVotes + sszSlice11 := buf[sszVarOffset11:sszVarOffset12] // c.Validators + sszSlice12 := buf[sszVarOffset12:sszVarOffset15] // c.Balances + sszSlice15 := buf[sszVarOffset15:sszVarOffset16] // c.PreviousEpochParticipation + sszSlice16 := buf[sszVarOffset16:sszVarOffset21] // c.CurrentEpochParticipation + sszSlice21 := buf[sszVarOffset21:sszVarOffset24] // c.InactivityScores + sszSlice24 := buf[sszVarOffset24:sszVarOffset27] // c.LatestExecutionPayloadHeader + sszSlice27 := buf[sszVarOffset27:] // c.HistoricalSummaries - // Offset (10) 'BlsToExecutionChanges' - if o10 = ssz.ReadOffset(buf[384:388]); o10 > size || o9 > o10 { - return ssz.ErrOffset + // Field 0: GenesisTime + c.GenesisTime = binary.LittleEndian.Uint64(sszSlice0) + + // Field 1: GenesisValidatorsRoot + c.GenesisValidatorsRoot = make([]byte, 0, 32) + c.GenesisValidatorsRoot = append(c.GenesisValidatorsRoot, sszSlice1...) + + // Field 2: Slot + if err = c.Slot.UnmarshalSSZ(sszSlice2); err != nil { + return fmt.Errorf("Slot: %w", err) } - // Offset (11) 'BlobKzgCommitments' - if o11 = ssz.ReadOffset(buf[388:392]); o11 > size || o10 > o11 { - return ssz.ErrOffset + // Field 3: Fork + c.Fork = new(Fork) + if err = c.Fork.UnmarshalSSZ(sszSlice3); err != nil { + return fmt.Errorf("Fork: %w", err) } - // Field (3) 'ProposerSlashings' + // Field 4: LatestBlockHeader + c.LatestBlockHeader = new(BeaconBlockHeader) + if err = c.LatestBlockHeader.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("LatestBlockHeader: %w", err) + } + + // Field 5: BlockRoots { - buf = tail[o3:o4] - num, err := ssz.DivideInt2(len(buf), 416, 16) - if err != nil { - return err - } - b.ProposerSlashings = make([]*ProposerSlashing, num) - for ii := 0; ii < num; ii++ { - if b.ProposerSlashings[ii] == nil { - b.ProposerSlashings[ii] = new(ProposerSlashing) - } - if err = b.ProposerSlashings[ii].UnmarshalSSZ(buf[ii*416 : (ii+1)*416]); err != nil { - return err - } + c.BlockRoots = make([][]byte, 8192) + for i := 0; i < 8192; i++ { + var tmp []byte + + tmpSlice := sszSlice5[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.BlockRoots[i] = tmp } } - // Field (4) 'AttesterSlashings' + // Field 6: StateRoots { - buf = tail[o4:o5] - num, err := ssz.DecodeDynamicLength(buf, 2) - 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 + c.StateRoots = make([][]byte, 8192) + for i := 0; i < 8192; i++ { + var tmp []byte + + tmpSlice := sszSlice6[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.StateRoots[i] = tmp } } - // Field (5) 'Attestations' + // Field 7: HistoricalRoots { - buf = tail[o5:o6] - num, err := ssz.DecodeDynamicLength(buf, 128) - 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 + if len(sszSlice7)%32 != 0 { + return fmt.Errorf("misaligned bytes: c.HistoricalRoots length is %d, which is not a multiple of 32: %w", len(sszSlice7), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice7) / 32 + if numElem > 16777216 { + return fmt.Errorf("ssz-max exceeded: c.HistoricalRoots has %d elements, ssz-max is 16777216: %w", numElem, ssz.ErrListTooBig) + } + c.HistoricalRoots = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte + + tmpSlice := sszSlice7[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.HistoricalRoots[i] = tmp } } - // Field (6) 'Deposits' + // Field 8: Eth1Data + c.Eth1Data = new(Eth1Data) + if err = c.Eth1Data.UnmarshalSSZ(sszSlice8); err != nil { + return fmt.Errorf("Eth1Data: %w", err) + } + + // Field 9: Eth1DataVotes { - buf = tail[o6:o7] - num, err := ssz.DivideInt2(len(buf), 1240, 16) - if err != nil { - return err - } - b.Deposits = make([]*Deposit, num) - for ii := 0; ii < num; ii++ { - if b.Deposits[ii] == nil { - b.Deposits[ii] = new(Deposit) - } - if err = b.Deposits[ii].UnmarshalSSZ(buf[ii*1240 : (ii+1)*1240]); err != nil { - return err + if len(sszSlice9)%72 != 0 { + return fmt.Errorf("misaligned bytes: c.Eth1DataVotes length is %d, which is not a multiple of 72: %w", len(sszSlice9), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice9) / 72 + if numElem > 2048 { + return fmt.Errorf("ssz-max exceeded: c.Eth1DataVotes has %d elements, ssz-max is 2048: %w", numElem, ssz.ErrListTooBig) + } + c.Eth1DataVotes = make([]*Eth1Data, numElem) + for i := 0; i < numElem; i++ { + var tmp *Eth1Data + tmp = new(Eth1Data) + tmpSlice := sszSlice9[i*72 : (1+i)*72] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Eth1DataVotes: %w", err) } + c.Eth1DataVotes[i] = tmp } } - // Field (7) 'VoluntaryExits' + // Field 10: Eth1DepositIndex + c.Eth1DepositIndex = binary.LittleEndian.Uint64(sszSlice10) + + // Field 11: Validators { - buf = tail[o7:o9] - num, err := ssz.DivideInt2(len(buf), 112, 16) - if err != nil { - return err - } - b.VoluntaryExits = make([]*SignedVoluntaryExit, num) - for ii := 0; ii < num; ii++ { - if b.VoluntaryExits[ii] == nil { - b.VoluntaryExits[ii] = new(SignedVoluntaryExit) - } - if err = b.VoluntaryExits[ii].UnmarshalSSZ(buf[ii*112 : (ii+1)*112]); err != nil { - return err + if len(sszSlice11)%121 != 0 { + return fmt.Errorf("misaligned bytes: c.Validators length is %d, which is not a multiple of 121: %w", len(sszSlice11), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice11) / 121 + if numElem > 1099511627776 { + return fmt.Errorf("ssz-max exceeded: c.Validators has %d elements, ssz-max is 1099511627776: %w", numElem, ssz.ErrListTooBig) + } + c.Validators = make([]*Validator, numElem) + for i := 0; i < numElem; i++ { + var tmp *Validator + tmp = new(Validator) + tmpSlice := sszSlice11[i*121 : (1+i)*121] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Validators: %w", err) } + c.Validators[i] = tmp } } - // Field (9) 'ExecutionPayload' + // Field 12: Balances { - buf = tail[o9:o10] - if b.ExecutionPayload == nil { - b.ExecutionPayload = new(v1.ExecutionPayloadDeneb) + if len(sszSlice12)%8 != 0 { + return fmt.Errorf("misaligned bytes: c.Balances length is %d, which is not a multiple of 8: %w", len(sszSlice12), ssz.ErrIncorrectListSize) } - if err = b.ExecutionPayload.UnmarshalSSZ(buf); err != nil { - return err + numElem := len(sszSlice12) / 8 + if numElem > 1099511627776 { + return fmt.Errorf("ssz-max exceeded: c.Balances has %d elements, ssz-max is 1099511627776: %w", numElem, ssz.ErrListTooBig) + } + c.Balances = make([]uint64, numElem) + for i := 0; i < numElem; i++ { + var tmp uint64 + + tmpSlice := sszSlice12[i*8 : (1+i)*8] + tmp = binary.LittleEndian.Uint64(tmpSlice) + c.Balances[i] = tmp } } - // Field (10) 'BlsToExecutionChanges' + // Field 13: RandaoMixes { - buf = tail[o10:o11] - num, err := ssz.DivideInt2(len(buf), 172, 16) - if err != nil { - return err - } - b.BlsToExecutionChanges = make([]*SignedBLSToExecutionChange, num) - for ii := 0; ii < num; ii++ { - if b.BlsToExecutionChanges[ii] == nil { - b.BlsToExecutionChanges[ii] = new(SignedBLSToExecutionChange) - } - if err = b.BlsToExecutionChanges[ii].UnmarshalSSZ(buf[ii*172 : (ii+1)*172]); err != nil { - return err - } + c.RandaoMixes = make([][]byte, 65536) + for i := 0; i < 65536; i++ { + var tmp []byte + + tmpSlice := sszSlice13[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.RandaoMixes[i] = tmp } } - // Field (11) 'BlobKzgCommitments' + // Field 14: Slashings { - buf = tail[o11:] - num, err := ssz.DivideInt2(len(buf), 48, 4096) - if err != nil { - return err - } - b.BlobKzgCommitments = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(b.BlobKzgCommitments[ii]) == 0 { - b.BlobKzgCommitments[ii] = make([]byte, 0, len(buf[ii*48:(ii+1)*48])) - } - b.BlobKzgCommitments[ii] = append(b.BlobKzgCommitments[ii], buf[ii*48:(ii+1)*48]...) + c.Slashings = make([]uint64, 8192) + for i := 0; i < 8192; i++ { + var tmp uint64 + + tmpSlice := sszSlice14[i*8 : (1+i)*8] + tmp = binary.LittleEndian.Uint64(tmpSlice) + c.Slashings[i] = tmp } } - return err -} -// SizeSSZ returns the ssz encoded size in bytes for the BeaconBlockBodyDeneb object -func (b *BeaconBlockBodyDeneb) SizeSSZ() (size int) { - size = 392 + // Field 15: PreviousEpochParticipation + c.PreviousEpochParticipation = append([]byte{}, sszSlice15...) - // Field (3) 'ProposerSlashings' - size += len(b.ProposerSlashings) * 416 + // Field 16: CurrentEpochParticipation + c.CurrentEpochParticipation = append([]byte{}, sszSlice16...) - // Field (4) 'AttesterSlashings' - for ii := 0; ii < len(b.AttesterSlashings); ii++ { - size += 4 - size += b.AttesterSlashings[ii].SizeSSZ() + // Field 17: JustificationBits + c.JustificationBits = make([]byte, 0, 1) + c.JustificationBits = append(c.JustificationBits, go_bitfield.Bitvector4(sszSlice17)...) + + // Field 18: PreviousJustifiedCheckpoint + c.PreviousJustifiedCheckpoint = new(Checkpoint) + if err = c.PreviousJustifiedCheckpoint.UnmarshalSSZ(sszSlice18); err != nil { + return fmt.Errorf("PreviousJustifiedCheckpoint: %w", err) } - // Field (5) 'Attestations' - for ii := 0; ii < len(b.Attestations); ii++ { - size += 4 - size += b.Attestations[ii].SizeSSZ() + // Field 19: CurrentJustifiedCheckpoint + c.CurrentJustifiedCheckpoint = new(Checkpoint) + if err = c.CurrentJustifiedCheckpoint.UnmarshalSSZ(sszSlice19); err != nil { + return fmt.Errorf("CurrentJustifiedCheckpoint: %w", err) } - // Field (6) 'Deposits' - size += len(b.Deposits) * 1240 + // Field 20: FinalizedCheckpoint + c.FinalizedCheckpoint = new(Checkpoint) + if err = c.FinalizedCheckpoint.UnmarshalSSZ(sszSlice20); err != nil { + return fmt.Errorf("FinalizedCheckpoint: %w", err) + } - // Field (7) 'VoluntaryExits' - size += len(b.VoluntaryExits) * 112 + // Field 21: InactivityScores + { + if len(sszSlice21)%8 != 0 { + return fmt.Errorf("misaligned bytes: c.InactivityScores length is %d, which is not a multiple of 8: %w", len(sszSlice21), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice21) / 8 + if numElem > 1099511627776 { + return fmt.Errorf("ssz-max exceeded: c.InactivityScores has %d elements, ssz-max is 1099511627776: %w", numElem, ssz.ErrListTooBig) + } + c.InactivityScores = make([]uint64, numElem) + for i := 0; i < numElem; i++ { + var tmp uint64 - // Field (9) 'ExecutionPayload' - if b.ExecutionPayload == nil { - b.ExecutionPayload = new(v1.ExecutionPayloadDeneb) + tmpSlice := sszSlice21[i*8 : (1+i)*8] + tmp = binary.LittleEndian.Uint64(tmpSlice) + c.InactivityScores[i] = tmp + } } - size += b.ExecutionPayload.SizeSSZ() - - // Field (10) 'BlsToExecutionChanges' - size += len(b.BlsToExecutionChanges) * 172 - // Field (11) 'BlobKzgCommitments' - size += len(b.BlobKzgCommitments) * 48 + // Field 22: CurrentSyncCommittee + c.CurrentSyncCommittee = new(SyncCommittee) + if err = c.CurrentSyncCommittee.UnmarshalSSZ(sszSlice22); err != nil { + return fmt.Errorf("CurrentSyncCommittee: %w", err) + } - return -} + // Field 23: NextSyncCommittee + c.NextSyncCommittee = new(SyncCommittee) + if err = c.NextSyncCommittee.UnmarshalSSZ(sszSlice23); err != nil { + return fmt.Errorf("NextSyncCommittee: %w", err) + } -// HashTreeRoot ssz hashes the BeaconBlockBodyDeneb object -func (b *BeaconBlockBodyDeneb) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) -} + // Field 24: LatestExecutionPayloadHeader + c.LatestExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderDeneb) + if err = c.LatestExecutionPayloadHeader.UnmarshalSSZ(sszSlice24); err != nil { + return fmt.Errorf("LatestExecutionPayloadHeader: %w", err) + } -// HashTreeRootWith ssz hashes the BeaconBlockBodyDeneb object with a hasher -func (b *BeaconBlockBodyDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() + // Field 25: NextWithdrawalIndex + c.NextWithdrawalIndex = binary.LittleEndian.Uint64(sszSlice25) - // Field (0) 'RandaoReveal' - if size := len(b.RandaoReveal); size != 96 { - err = ssz.ErrBytesLengthFn("--.RandaoReveal", size, 96) - return + // Field 26: NextWithdrawalValidatorIndex + if err = c.NextWithdrawalValidatorIndex.UnmarshalSSZ(sszSlice26); err != nil { + return fmt.Errorf("NextWithdrawalValidatorIndex: %w", err) } - hh.PutBytes(b.RandaoReveal) - // Field (1) 'Eth1Data' - if err = b.Eth1Data.HashTreeRootWith(hh); err != nil { - return + // Field 27: HistoricalSummaries + { + if len(sszSlice27)%64 != 0 { + return fmt.Errorf("misaligned bytes: c.HistoricalSummaries length is %d, which is not a multiple of 64: %w", len(sszSlice27), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice27) / 64 + if numElem > 16777216 { + return fmt.Errorf("ssz-max exceeded: c.HistoricalSummaries has %d elements, ssz-max is 16777216: %w", numElem, ssz.ErrListTooBig) + } + c.HistoricalSummaries = make([]*HistoricalSummary, numElem) + for i := 0; i < numElem; i++ { + var tmp *HistoricalSummary + tmp = new(HistoricalSummary) + tmpSlice := sszSlice27[i*64 : (1+i)*64] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("HistoricalSummaries: %w", err) + } + c.HistoricalSummaries[i] = tmp + } } + return err +} - // Field (2) 'Graffiti' - if size := len(b.Graffiti); size != 32 { - err = ssz.ErrBytesLengthFn("--.Graffiti", size, 32) - return +func (c *BeaconStateDeneb) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - hh.PutBytes(b.Graffiti) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (3) 'ProposerSlashings' +func (c *BeaconStateDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: GenesisTime + hh.PutUint64(c.GenesisTime) + // Field 1: GenesisValidatorsRoot + if len(c.GenesisValidatorsRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.GenesisValidatorsRoot) + // Field 2: Slot + if err := c.Slot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Slot: %w", err) + } + // Field 3: Fork + if err := c.Fork.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Fork: %w", err) + } + // Field 4: LatestBlockHeader + if err := c.LatestBlockHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("LatestBlockHeader: %w", err) + } + // Field 5: BlockRoots { + if len(c.BlockRoots) != 8192 { + return ssz.ErrVectorLength + } 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 + for _, o := range c.BlockRoots { + if len(o) != 32 { + return ssz.ErrBytesLength } + hh.Append(o) } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.Merkleize(subIndx) } - - // Field (4) 'AttesterSlashings' + // Field 6: StateRoots { + if len(c.StateRoots) != 8192 { + return ssz.ErrVectorLength + } 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 + for _, o := range c.StateRoots { + if len(o) != 32 { + return ssz.ErrBytesLength } + hh.Append(o) } - hh.MerkleizeWithMixin(subIndx, num, 2) + hh.Merkleize(subIndx) } - - // Field (5) 'Attestations' + // Field 7: HistoricalRoots { + if len(c.HistoricalRoots) > 16777216 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.HistoricalRoots { + if len(o) != 32 { + return ssz.ErrBytesLength } + hh.Append(o) } - hh.MerkleizeWithMixin(subIndx, num, 128) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.HistoricalRoots)), 16777216) } - - // Field (6) 'Deposits' + // Field 8: Eth1Data + if err := c.Eth1Data.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Eth1Data: %w", err) + } + // Field 9: Eth1DataVotes { + if len(c.Eth1DataVotes) > 2048 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.Eth1DataVotes { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Eth1DataVotes: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Eth1DataVotes)), 2048) } - - // Field (7) 'VoluntaryExits' + // Field 10: Eth1DepositIndex + hh.PutUint64(c.Eth1DepositIndex) + // Field 11: Validators { + if len(c.Validators) > 1099511627776 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.Validators { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Validators: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 16) - } - - // Field (8) 'SyncAggregate' - if err = b.SyncAggregate.HashTreeRootWith(hh); err != nil { - return - } - - // Field (9) 'ExecutionPayload' - if err = b.ExecutionPayload.HashTreeRootWith(hh); err != nil { - return + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Validators)), 1099511627776) } - - // Field (10) 'BlsToExecutionChanges' + // Field 12: Balances { + if len(c.Balances) > 1099511627776 { + return ssz.ErrListTooBig + } 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 - } + for _, o := range c.Balances { + hh.AppendUint64(o) } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.FillUpTo32() + numItems := uint64(len(c.Balances)) + hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(1099511627776, numItems, 8)) } - - // Field (11) 'BlobKzgCommitments' + // Field 13: RandaoMixes { - if size := len(b.BlobKzgCommitments); size > 4096 { - err = ssz.ErrListTooBigFn("--.BlobKzgCommitments", size, 4096) - return + if len(c.RandaoMixes) != 65536 { + return ssz.ErrVectorLength } subIndx := hh.Index() - for _, i := range b.BlobKzgCommitments { - if len(i) != 48 { - err = ssz.ErrBytesLength - return + for _, o := range c.RandaoMixes { + if len(o) != 32 { + return ssz.ErrBytesLength } - hh.PutBytes(i) + hh.Append(o) } - - numItems := uint64(len(b.BlobKzgCommitments)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) - } - - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the SignedBlindedBeaconBlockDeneb object -func (s *SignedBlindedBeaconBlockDeneb) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) -} - -// MarshalSSZTo ssz marshals the SignedBlindedBeaconBlockDeneb object to a target array -func (s *SignedBlindedBeaconBlockDeneb) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(100) - - // Offset (0) 'Message' - dst = ssz.WriteOffset(dst, offset) - if s.Message == nil { - s.Message = new(BlindedBeaconBlockDeneb) - } - offset += s.Message.SizeSSZ() - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return - } - dst = append(dst, s.Signature...) - - // Field (0) 'Message' - if dst, err = s.Message.MarshalSSZTo(dst); err != nil { - return - } - - return -} - -// UnmarshalSSZ ssz unmarshals the SignedBlindedBeaconBlockDeneb object -func (s *SignedBlindedBeaconBlockDeneb) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 100 { - return ssz.ErrSize - } - - tail := buf - var o0 uint64 - - // Offset (0) 'Message' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } - - if o0 != 100 { - return ssz.ErrInvalidVariableOffset - } - - // Field (1) 'Signature' - if cap(s.Signature) == 0 { - s.Signature = make([]byte, 0, len(buf[4:100])) + hh.Merkleize(subIndx) } - s.Signature = append(s.Signature, buf[4:100]...) - - // Field (0) 'Message' + // Field 14: Slashings { - buf = tail[o0:] - if s.Message == nil { - s.Message = new(BlindedBeaconBlockDeneb) + if len(c.Slashings) != 8192 { + return ssz.ErrVectorLength } - if err = s.Message.UnmarshalSSZ(buf); err != nil { - return err + subIndx := hh.Index() + for _, o := range c.Slashings { + hh.AppendUint64(o) } + hh.Merkleize(subIndx) } - return err -} + // Field 15: PreviousEpochParticipation -// SizeSSZ returns the ssz encoded size in bytes for the SignedBlindedBeaconBlockDeneb object -func (s *SignedBlindedBeaconBlockDeneb) SizeSSZ() (size int) { - size = 100 - - // Field (0) 'Message' - if s.Message == nil { - s.Message = new(BlindedBeaconBlockDeneb) + { + if len(c.PreviousEpochParticipation) > 1099511627776 { + return ssz.ErrBytesLength + } + subIndx := hh.Index() + hh.AppendBytes32(c.PreviousEpochParticipation) + numItems := uint64(len(c.PreviousEpochParticipation)) + hh.MerkleizeWithMixin(subIndx, numItems, (1099511627776*1+31)/32) } - size += s.Message.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the SignedBlindedBeaconBlockDeneb object -func (s *SignedBlindedBeaconBlockDeneb) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) -} - -// HashTreeRootWith ssz hashes the SignedBlindedBeaconBlockDeneb object with a hasher -func (s *SignedBlindedBeaconBlockDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - // Field (0) 'Message' - if err = s.Message.HashTreeRootWith(hh); err != nil { - return - } + // Field 16: CurrentEpochParticipation - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + { + if len(c.CurrentEpochParticipation) > 1099511627776 { + return ssz.ErrBytesLength + } + subIndx := hh.Index() + hh.AppendBytes32(c.CurrentEpochParticipation) + numItems := uint64(len(c.CurrentEpochParticipation)) + hh.MerkleizeWithMixin(subIndx, numItems, (1099511627776*1+31)/32) } - hh.PutBytes(s.Signature) - - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the BlindedBeaconBlockDeneb object -func (b *BlindedBeaconBlockDeneb) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} - -// MarshalSSZTo ssz marshals the BlindedBeaconBlockDeneb object to a target array -func (b *BlindedBeaconBlockDeneb) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(84) - - // Field (0) 'Slot' - dst = ssz.MarshalUint(dst, b.Slot) - - // Field (1) 'ProposerIndex' - dst = ssz.MarshalUint(dst, b.ProposerIndex) - // Field (2) 'ParentRoot' - if size := len(b.ParentRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentRoot", size, 32) - return + // Field 17: JustificationBits + if len([]byte(c.JustificationBits)) != 1 { + return ssz.ErrBytesLength } - dst = append(dst, b.ParentRoot...) - - // Field (3) 'StateRoot' - if size := len(b.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return + hh.PutBytes([]byte(c.JustificationBits)) + // Field 18: PreviousJustifiedCheckpoint + if err := c.PreviousJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("PreviousJustifiedCheckpoint: %w", err) } - dst = append(dst, b.StateRoot...) - - // Offset (4) 'Body' - dst = ssz.WriteOffset(dst, offset) - if b.Body == nil { - b.Body = new(BlindedBeaconBlockBodyDeneb) + // Field 19: CurrentJustifiedCheckpoint + if err := c.CurrentJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("CurrentJustifiedCheckpoint: %w", err) } - offset += b.Body.SizeSSZ() - - // Field (4) 'Body' - if dst, err = b.Body.MarshalSSZTo(dst); err != nil { - return + // Field 20: FinalizedCheckpoint + if err := c.FinalizedCheckpoint.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("FinalizedCheckpoint: %w", err) } - - return -} - -// UnmarshalSSZ ssz unmarshals the BlindedBeaconBlockDeneb object -func (b *BlindedBeaconBlockDeneb) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 84 { - return ssz.ErrSize + // Field 21: InactivityScores + { + if len(c.InactivityScores) > 1099511627776 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.InactivityScores { + hh.AppendUint64(o) + } + hh.FillUpTo32() + numItems := uint64(len(c.InactivityScores)) + hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(1099511627776, numItems, 8)) } - - tail := buf - var o4 uint64 - - // Field (0) 'Slot' - b.Slot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[0:8]) - - // Field (1) 'ProposerIndex' - b.ProposerIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[8:16]) - - // Field (2) 'ParentRoot' - if cap(b.ParentRoot) == 0 { - b.ParentRoot = make([]byte, 0, len(buf[16:48])) + // Field 22: CurrentSyncCommittee + if err := c.CurrentSyncCommittee.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("CurrentSyncCommittee: %w", err) } - 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])) + // Field 23: NextSyncCommittee + if err := c.NextSyncCommittee.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("NextSyncCommittee: %w", err) } - b.StateRoot = append(b.StateRoot, buf[48:80]...) - - // Offset (4) 'Body' - if o4 = ssz.ReadOffset(buf[80:84]); o4 > size { - return ssz.ErrOffset + // Field 24: LatestExecutionPayloadHeader + if err := c.LatestExecutionPayloadHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("LatestExecutionPayloadHeader: %w", err) } - - if o4 != 84 { - return ssz.ErrInvalidVariableOffset + // Field 25: NextWithdrawalIndex + hh.PutUint64(c.NextWithdrawalIndex) + // Field 26: NextWithdrawalValidatorIndex + if err := c.NextWithdrawalValidatorIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("NextWithdrawalValidatorIndex: %w", err) } - - // Field (4) 'Body' + // Field 27: HistoricalSummaries { - buf = tail[o4:] - if b.Body == nil { - b.Body = new(BlindedBeaconBlockBodyDeneb) + if len(c.HistoricalSummaries) > 16777216 { + return ssz.ErrListTooBig } - if err = b.Body.UnmarshalSSZ(buf); err != nil { - return err + subIndx := hh.Index() + for _, o := range c.HistoricalSummaries { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("HistoricalSummaries: %w", err) + } } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.HistoricalSummaries)), 16777216) } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the BlindedBeaconBlockDeneb object -func (b *BlindedBeaconBlockDeneb) SizeSSZ() (size int) { - size = 84 - - // Field (4) 'Body' - if b.Body == nil { - b.Body = new(BlindedBeaconBlockBodyDeneb) - } - size += b.Body.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the BlindedBeaconBlockDeneb object -func (b *BlindedBeaconBlockDeneb) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) + hh.Merkleize(indx) + return nil } -// HashTreeRootWith ssz hashes the BlindedBeaconBlockDeneb object with a hasher -func (b *BlindedBeaconBlockDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'Slot' - ssz.PutUint(hh, b.Slot) - - // Field (1) 'ProposerIndex' - ssz.PutUint(hh, b.ProposerIndex) - - // Field (2) 'ParentRoot' - if size := len(b.ParentRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentRoot", size, 32) - return +func (c *BlindedBeaconBlockBodyDeneb) SizeSSZ() int { + size := 392 + size += len(c.ProposerSlashings) * 416 + for _, o := range c.AttesterSlashings { + size += 4 + size += o.SizeSSZ() } - hh.PutBytes(b.ParentRoot) - - // Field (3) 'StateRoot' - if size := len(b.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return + for _, o := range c.Attestations { + size += 4 + size += o.SizeSSZ() } - hh.PutBytes(b.StateRoot) - - // Field (4) 'Body' - if err = b.Body.HashTreeRootWith(hh); err != nil { - return + size += len(c.Deposits) * 1240 + size += len(c.VoluntaryExits) * 112 + if c.ExecutionPayloadHeader == nil { + c.ExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderDeneb) } - - hh.Merkleize(indx) - return + size += c.ExecutionPayloadHeader.SizeSSZ() + size += len(c.BlsToExecutionChanges) * 172 + size += len(c.BlobKzgCommitments) * 48 + return size } -// MarshalSSZ ssz marshals the BlindedBeaconBlockBodyDeneb object -func (b *BlindedBeaconBlockBodyDeneb) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) +func (c *BlindedBeaconBlockBodyDeneb) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the BlindedBeaconBlockBodyDeneb object to a target array -func (b *BlindedBeaconBlockBodyDeneb) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(392) +func (c *BlindedBeaconBlockBodyDeneb) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 392 - // Field (0) 'RandaoReveal' - if size := len(b.RandaoReveal); size != 96 { - err = ssz.ErrBytesLengthFn("--.RandaoReveal", size, 96) - return + // Field 0: RandaoReveal + if len(c.RandaoReveal) != 96 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.RandaoReveal...) + dst = append(dst, c.RandaoReveal...) - // Field (1) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(Eth1Data) + // Field 1: Eth1Data + if c.Eth1Data == nil { + c.Eth1Data = new(Eth1Data) } - if dst, err = b.Eth1Data.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.Eth1Data.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Eth1Data: %w", err) } - // Field (2) 'Graffiti' - if size := len(b.Graffiti); size != 32 { - err = ssz.ErrBytesLengthFn("--.Graffiti", size, 32) - return + // Field 2: Graffiti + if len(c.Graffiti) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.Graffiti...) + dst = append(dst, c.Graffiti...) - // Offset (3) 'ProposerSlashings' + // Field 3: ProposerSlashings dst = ssz.WriteOffset(dst, offset) - offset += len(b.ProposerSlashings) * 416 + offset += len(c.ProposerSlashings) * 416 - // Offset (4) 'AttesterSlashings' + // Field 4: AttesterSlashings dst = ssz.WriteOffset(dst, offset) - for ii := 0; ii < len(b.AttesterSlashings); ii++ { + for _, o := range c.AttesterSlashings { offset += 4 - offset += b.AttesterSlashings[ii].SizeSSZ() + offset += o.SizeSSZ() } - // Offset (5) 'Attestations' + // Field 5: Attestations dst = ssz.WriteOffset(dst, offset) - for ii := 0; ii < len(b.Attestations); ii++ { + for _, o := range c.Attestations { offset += 4 - offset += b.Attestations[ii].SizeSSZ() + offset += o.SizeSSZ() } - // Offset (6) 'Deposits' + // Field 6: Deposits dst = ssz.WriteOffset(dst, offset) - offset += len(b.Deposits) * 1240 + offset += len(c.Deposits) * 1240 - // Offset (7) 'VoluntaryExits' + // Field 7: VoluntaryExits dst = ssz.WriteOffset(dst, offset) - offset += len(b.VoluntaryExits) * 112 + offset += len(c.VoluntaryExits) * 112 - // Field (8) 'SyncAggregate' - if b.SyncAggregate == nil { - b.SyncAggregate = new(SyncAggregate) + // Field 8: SyncAggregate + if c.SyncAggregate == nil { + c.SyncAggregate = new(SyncAggregate) } - if dst, err = b.SyncAggregate.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.SyncAggregate.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SyncAggregate: %w", err) } - // Offset (9) 'ExecutionPayloadHeader' - dst = ssz.WriteOffset(dst, offset) - if b.ExecutionPayloadHeader == nil { - b.ExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderDeneb) + // Field 9: ExecutionPayloadHeader + if c.ExecutionPayloadHeader == nil { + c.ExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderDeneb) } - offset += b.ExecutionPayloadHeader.SizeSSZ() + dst = ssz.WriteOffset(dst, offset) + offset += c.ExecutionPayloadHeader.SizeSSZ() - // Offset (10) 'BlsToExecutionChanges' + // Field 10: BlsToExecutionChanges dst = ssz.WriteOffset(dst, offset) - offset += len(b.BlsToExecutionChanges) * 172 + offset += len(c.BlsToExecutionChanges) * 172 - // Offset (11) 'BlobKzgCommitments' + // Field 11: BlobKzgCommitments dst = ssz.WriteOffset(dst, offset) - offset += len(b.BlobKzgCommitments) * 48 + offset += len(c.BlobKzgCommitments) * 48 - // Field (3) 'ProposerSlashings' - if size := len(b.ProposerSlashings); size > 16 { - err = ssz.ErrListTooBigFn("--.ProposerSlashings", size, 16) - return + // Field 3: ProposerSlashings + if len(c.ProposerSlashings) > 16 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.ProposerSlashings); ii++ { - if dst, err = b.ProposerSlashings[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.ProposerSlashings { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ProposerSlashings: %w", err) } } - // Field (4) 'AttesterSlashings' - if size := len(b.AttesterSlashings); size > 2 { - err = ssz.ErrListTooBigFn("--.AttesterSlashings", size, 2) - return + // Field 4: AttesterSlashings + if len(c.AttesterSlashings) > 2 { + return nil, ssz.ErrListTooBig } { - offset = 4 * len(b.AttesterSlashings) - for ii := 0; ii < len(b.AttesterSlashings); ii++ { + offset = 4 * len(c.AttesterSlashings) + for _, o := range c.AttesterSlashings { dst = ssz.WriteOffset(dst, offset) - offset += b.AttesterSlashings[ii].SizeSSZ() + offset += o.SizeSSZ() } } - for ii := 0; ii < len(b.AttesterSlashings); ii++ { - if dst, err = b.AttesterSlashings[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.AttesterSlashings { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("AttesterSlashings: %w", err) } } - // Field (5) 'Attestations' - if size := len(b.Attestations); size > 128 { - err = ssz.ErrListTooBigFn("--.Attestations", size, 128) - return + // Field 5: Attestations + if len(c.Attestations) > 128 { + return nil, ssz.ErrListTooBig } { - offset = 4 * len(b.Attestations) - for ii := 0; ii < len(b.Attestations); ii++ { + offset = 4 * len(c.Attestations) + for _, o := range c.Attestations { dst = ssz.WriteOffset(dst, offset) - offset += b.Attestations[ii].SizeSSZ() + offset += o.SizeSSZ() } } - for ii := 0; ii < len(b.Attestations); ii++ { - if dst, err = b.Attestations[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.Attestations { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Attestations: %w", err) } } - // Field (6) 'Deposits' - if size := len(b.Deposits); size > 16 { - err = ssz.ErrListTooBigFn("--.Deposits", size, 16) - return + // Field 6: Deposits + if len(c.Deposits) > 16 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.Deposits); ii++ { - if dst, err = b.Deposits[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.Deposits { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Deposits: %w", err) } } - // Field (7) 'VoluntaryExits' - if size := len(b.VoluntaryExits); size > 16 { - err = ssz.ErrListTooBigFn("--.VoluntaryExits", size, 16) - return + // Field 7: VoluntaryExits + if len(c.VoluntaryExits) > 16 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.VoluntaryExits); ii++ { - if dst, err = b.VoluntaryExits[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.VoluntaryExits { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("VoluntaryExits: %w", err) } } - // Field (9) 'ExecutionPayloadHeader' - if dst, err = b.ExecutionPayloadHeader.MarshalSSZTo(dst); err != nil { - return + // Field 9: ExecutionPayloadHeader + if dst, err = c.ExecutionPayloadHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ExecutionPayloadHeader: %w", err) } - // Field (10) 'BlsToExecutionChanges' - if size := len(b.BlsToExecutionChanges); size > 16 { - err = ssz.ErrListTooBigFn("--.BlsToExecutionChanges", size, 16) - return + // Field 10: BlsToExecutionChanges + if len(c.BlsToExecutionChanges) > 16 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.BlsToExecutionChanges); ii++ { - if dst, err = b.BlsToExecutionChanges[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.BlsToExecutionChanges { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("BlsToExecutionChanges: %w", err) } } - // Field (11) 'BlobKzgCommitments' - if size := len(b.BlobKzgCommitments); size > 4096 { - err = ssz.ErrListTooBigFn("--.BlobKzgCommitments", size, 4096) - return + // Field 11: BlobKzgCommitments + if len(c.BlobKzgCommitments) > 4096 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.BlobKzgCommitments); ii++ { - if size := len(b.BlobKzgCommitments[ii]); size != 48 { - err = ssz.ErrBytesLengthFn("--.BlobKzgCommitments[ii]", size, 48) - return + for _, o := range c.BlobKzgCommitments { + if len(o) != 48 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.BlobKzgCommitments[ii]...) + dst = append(dst, o...) } - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the BlindedBeaconBlockBodyDeneb object -func (b *BlindedBeaconBlockBodyDeneb) UnmarshalSSZ(buf []byte) error { +func (c *BlindedBeaconBlockBodyDeneb) 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 + sszSlice0 := buf[0:96] // c.RandaoReveal + sszSlice1 := buf[96:168] // c.Eth1Data + sszSlice2 := buf[168:200] // c.Graffiti + sszSlice8 := buf[220:380] // c.SyncAggregate - // Field (0) 'RandaoReveal' - if cap(b.RandaoReveal) == 0 { - b.RandaoReveal = make([]byte, 0, len(buf[0:96])) + sszVarOffset3 := ssz.ReadOffset(buf[200:204]) // c.ProposerSlashings + if sszVarOffset3 != 392 { + return ssz.ErrInvalidVariableOffset } - b.RandaoReveal = append(b.RandaoReveal, buf[0:96]...) - - // Field (1) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(Eth1Data) + if sszVarOffset3 > size { + return ssz.ErrOffset } - if err = b.Eth1Data.UnmarshalSSZ(buf[96:168]); err != nil { - return err + sszVarOffset4 := ssz.ReadOffset(buf[204:208]) // c.AttesterSlashings + if sszVarOffset4 > size || sszVarOffset4 < sszVarOffset3 { + return ssz.ErrOffset } - - // Field (2) 'Graffiti' - if cap(b.Graffiti) == 0 { - b.Graffiti = make([]byte, 0, len(buf[168:200])) + sszVarOffset5 := ssz.ReadOffset(buf[208:212]) // c.Attestations + if sszVarOffset5 > size || sszVarOffset5 < sszVarOffset4 { + return ssz.ErrOffset } - b.Graffiti = append(b.Graffiti, buf[168:200]...) - - // Offset (3) 'ProposerSlashings' - if o3 = ssz.ReadOffset(buf[200:204]); o3 > size { + sszVarOffset6 := ssz.ReadOffset(buf[212:216]) // c.Deposits + if sszVarOffset6 > size || sszVarOffset6 < sszVarOffset5 { return ssz.ErrOffset } - - if o3 != 392 { - return ssz.ErrInvalidVariableOffset - } - - // Offset (4) 'AttesterSlashings' - if o4 = ssz.ReadOffset(buf[204:208]); o4 > size || o3 > o4 { + sszVarOffset7 := ssz.ReadOffset(buf[216:220]) // c.VoluntaryExits + if sszVarOffset7 > size || sszVarOffset7 < sszVarOffset6 { return ssz.ErrOffset } - - // Offset (5) 'Attestations' - if o5 = ssz.ReadOffset(buf[208:212]); o5 > size || o4 > o5 { + sszVarOffset9 := ssz.ReadOffset(buf[380:384]) // c.ExecutionPayloadHeader + if sszVarOffset9 > size || sszVarOffset9 < sszVarOffset7 { return ssz.ErrOffset } - - // Offset (6) 'Deposits' - if o6 = ssz.ReadOffset(buf[212:216]); o6 > size || o5 > o6 { + sszVarOffset10 := ssz.ReadOffset(buf[384:388]) // c.BlsToExecutionChanges + if sszVarOffset10 > size || sszVarOffset10 < sszVarOffset9 { return ssz.ErrOffset } - - // Offset (7) 'VoluntaryExits' - if o7 = ssz.ReadOffset(buf[216:220]); o7 > size || o6 > o7 { + sszVarOffset11 := ssz.ReadOffset(buf[388:392]) // c.BlobKzgCommitments + if sszVarOffset11 > size || sszVarOffset11 < sszVarOffset10 { return ssz.ErrOffset } + sszSlice3 := buf[sszVarOffset3:sszVarOffset4] // c.ProposerSlashings + sszSlice4 := buf[sszVarOffset4:sszVarOffset5] // c.AttesterSlashings + sszSlice5 := buf[sszVarOffset5:sszVarOffset6] // c.Attestations + sszSlice6 := buf[sszVarOffset6:sszVarOffset7] // c.Deposits + sszSlice7 := buf[sszVarOffset7:sszVarOffset9] // c.VoluntaryExits + sszSlice9 := buf[sszVarOffset9:sszVarOffset10] // c.ExecutionPayloadHeader + sszSlice10 := buf[sszVarOffset10:sszVarOffset11] // c.BlsToExecutionChanges + sszSlice11 := buf[sszVarOffset11:] // c.BlobKzgCommitments - // Field (8) 'SyncAggregate' - if b.SyncAggregate == nil { - b.SyncAggregate = new(SyncAggregate) - } - if err = b.SyncAggregate.UnmarshalSSZ(buf[220:380]); err != nil { - return err - } - - // Offset (9) 'ExecutionPayloadHeader' - if o9 = ssz.ReadOffset(buf[380:384]); o9 > size || o7 > o9 { - return ssz.ErrOffset - } + // Field 0: RandaoReveal + c.RandaoReveal = make([]byte, 0, 96) + c.RandaoReveal = append(c.RandaoReveal, sszSlice0...) - // Offset (10) 'BlsToExecutionChanges' - if o10 = ssz.ReadOffset(buf[384:388]); o10 > size || o9 > o10 { - return ssz.ErrOffset + // Field 1: Eth1Data + c.Eth1Data = new(Eth1Data) + if err = c.Eth1Data.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Eth1Data: %w", err) } - // Offset (11) 'BlobKzgCommitments' - if o11 = ssz.ReadOffset(buf[388:392]); o11 > size || o10 > o11 { - return ssz.ErrOffset - } + // Field 2: Graffiti + c.Graffiti = make([]byte, 0, 32) + c.Graffiti = append(c.Graffiti, sszSlice2...) - // Field (3) 'ProposerSlashings' + // Field 3: ProposerSlashings { - buf = tail[o3:o4] - num, err := ssz.DivideInt2(len(buf), 416, 16) - if err != nil { - return err - } - b.ProposerSlashings = make([]*ProposerSlashing, num) - for ii := 0; ii < num; ii++ { - if b.ProposerSlashings[ii] == nil { - b.ProposerSlashings[ii] = new(ProposerSlashing) - } - if err = b.ProposerSlashings[ii].UnmarshalSSZ(buf[ii*416 : (ii+1)*416]); err != nil { - return err + if len(sszSlice3)%416 != 0 { + return fmt.Errorf("misaligned bytes: c.ProposerSlashings length is %d, which is not a multiple of 416: %w", len(sszSlice3), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice3) / 416 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.ProposerSlashings has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.ProposerSlashings = make([]*ProposerSlashing, numElem) + for i := 0; i < numElem; i++ { + var tmp *ProposerSlashing + tmp = new(ProposerSlashing) + tmpSlice := sszSlice3[i*416 : (1+i)*416] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("ProposerSlashings: %w", err) } + c.ProposerSlashings[i] = tmp } } - // Field (4) 'AttesterSlashings' + // Field 4: AttesterSlashings { - buf = tail[o4:o5] - num, err := ssz.DecodeDynamicLength(buf, 2) - 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) + // empty lists are zero length, so make sure there is room for an offset + // before attempting to unmarshal it + if len(sszSlice4) > 3 { + startOffset := ssz.ReadOffset(sszSlice4[0:4]) + if startOffset == 0 { + return fmt.Errorf("encountered invalid offset of 0 when decoding c.AttesterSlashings") + } + if startOffset%4 != 0 { + return fmt.Errorf("misaligned list bytes: when decoding c.AttesterSlashings, end-of-list offset is %d, which is not a multiple of 4 (offset size)", startOffset) } - if err = b.AttesterSlashings[indx].UnmarshalSSZ(buf); err != nil { - return err + listLen := startOffset / 4 + if listLen > 2 { + return fmt.Errorf("ssz-max exceeded: c.AttesterSlashings has %d elements, ssz-max is 2: %w", listLen, ssz.ErrListTooBig) } - return nil - }) - if err != nil { - return err + totalVarBytes := uint64(len(sszSlice4)) + if totalVarBytes < startOffset { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.AttesterSlashings") + } + c.AttesterSlashings = make([]*AttesterSlashing, listLen) + var tmpSlice []byte + for i := uint64(0); i < listLen; i++ { + var tmp *AttesterSlashing + tmp = new(AttesterSlashing) + endOffset := totalVarBytes + if i+1 != listLen { + endOffset = ssz.ReadOffset(sszSlice4[(i+1)*4 : (i+2)*4]) + if totalVarBytes < endOffset { + return fmt.Errorf("offset %d points past the end of buffer when decoding c.AttesterSlashings", endOffset) + } + } + if endOffset < startOffset { + return fmt.Errorf("offset %d is not greater than start offset %d when decoding c.AttesterSlashings", endOffset, startOffset) + } + tmpSlice = sszSlice4[startOffset:endOffset] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("AttesterSlashings: %w", err) + } + c.AttesterSlashings[i] = tmp + startOffset = endOffset + } + } else { + if len(sszSlice4) > 0 { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.AttesterSlashings") + } + c.AttesterSlashings = make([]*AttesterSlashing, 0) } } - // Field (5) 'Attestations' + // Field 5: Attestations { - buf = tail[o5:o6] - num, err := ssz.DecodeDynamicLength(buf, 128) - 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) + // empty lists are zero length, so make sure there is room for an offset + // before attempting to unmarshal it + if len(sszSlice5) > 3 { + startOffset := ssz.ReadOffset(sszSlice5[0:4]) + if startOffset == 0 { + return fmt.Errorf("encountered invalid offset of 0 when decoding c.Attestations") + } + if startOffset%4 != 0 { + return fmt.Errorf("misaligned list bytes: when decoding c.Attestations, end-of-list offset is %d, which is not a multiple of 4 (offset size)", startOffset) } - if err = b.Attestations[indx].UnmarshalSSZ(buf); err != nil { - return err + listLen := startOffset / 4 + if listLen > 128 { + return fmt.Errorf("ssz-max exceeded: c.Attestations has %d elements, ssz-max is 128: %w", listLen, ssz.ErrListTooBig) } - return nil - }) - if err != nil { - return err + totalVarBytes := uint64(len(sszSlice5)) + if totalVarBytes < startOffset { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.Attestations") + } + c.Attestations = make([]*Attestation, listLen) + var tmpSlice []byte + for i := uint64(0); i < listLen; i++ { + var tmp *Attestation + tmp = new(Attestation) + endOffset := totalVarBytes + if i+1 != listLen { + endOffset = ssz.ReadOffset(sszSlice5[(i+1)*4 : (i+2)*4]) + if totalVarBytes < endOffset { + return fmt.Errorf("offset %d points past the end of buffer when decoding c.Attestations", endOffset) + } + } + if endOffset < startOffset { + return fmt.Errorf("offset %d is not greater than start offset %d when decoding c.Attestations", endOffset, startOffset) + } + tmpSlice = sszSlice5[startOffset:endOffset] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Attestations: %w", err) + } + c.Attestations[i] = tmp + startOffset = endOffset + } + } else { + if len(sszSlice5) > 0 { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.Attestations") + } + c.Attestations = make([]*Attestation, 0) } } - // Field (6) 'Deposits' + // Field 6: Deposits { - buf = tail[o6:o7] - num, err := ssz.DivideInt2(len(buf), 1240, 16) - if err != nil { - return err - } - b.Deposits = make([]*Deposit, num) - for ii := 0; ii < num; ii++ { - if b.Deposits[ii] == nil { - b.Deposits[ii] = new(Deposit) - } - if err = b.Deposits[ii].UnmarshalSSZ(buf[ii*1240 : (ii+1)*1240]); err != nil { - return err + if len(sszSlice6)%1240 != 0 { + return fmt.Errorf("misaligned bytes: c.Deposits length is %d, which is not a multiple of 1240: %w", len(sszSlice6), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice6) / 1240 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.Deposits has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.Deposits = make([]*Deposit, numElem) + for i := 0; i < numElem; i++ { + var tmp *Deposit + tmp = new(Deposit) + tmpSlice := sszSlice6[i*1240 : (1+i)*1240] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Deposits: %w", err) } + c.Deposits[i] = tmp } } - // Field (7) 'VoluntaryExits' + // Field 7: VoluntaryExits { - buf = tail[o7:o9] - num, err := ssz.DivideInt2(len(buf), 112, 16) - if err != nil { - return err - } - b.VoluntaryExits = make([]*SignedVoluntaryExit, num) - for ii := 0; ii < num; ii++ { - if b.VoluntaryExits[ii] == nil { - b.VoluntaryExits[ii] = new(SignedVoluntaryExit) - } - if err = b.VoluntaryExits[ii].UnmarshalSSZ(buf[ii*112 : (ii+1)*112]); err != nil { - return err + if len(sszSlice7)%112 != 0 { + return fmt.Errorf("misaligned bytes: c.VoluntaryExits length is %d, which is not a multiple of 112: %w", len(sszSlice7), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice7) / 112 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.VoluntaryExits has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.VoluntaryExits = make([]*SignedVoluntaryExit, numElem) + for i := 0; i < numElem; i++ { + var tmp *SignedVoluntaryExit + tmp = new(SignedVoluntaryExit) + tmpSlice := sszSlice7[i*112 : (1+i)*112] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("VoluntaryExits: %w", err) } + c.VoluntaryExits[i] = tmp } } - // Field (9) 'ExecutionPayloadHeader' - { - buf = tail[o9:o10] - if b.ExecutionPayloadHeader == nil { - b.ExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderDeneb) - } - if err = b.ExecutionPayloadHeader.UnmarshalSSZ(buf); err != nil { - return err - } + // Field 8: SyncAggregate + c.SyncAggregate = new(SyncAggregate) + if err = c.SyncAggregate.UnmarshalSSZ(sszSlice8); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) } - // Field (10) 'BlsToExecutionChanges' + // Field 9: ExecutionPayloadHeader + c.ExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderDeneb) + if err = c.ExecutionPayloadHeader.UnmarshalSSZ(sszSlice9); err != nil { + return fmt.Errorf("ExecutionPayloadHeader: %w", err) + } + + // Field 10: BlsToExecutionChanges { - buf = tail[o10:o11] - num, err := ssz.DivideInt2(len(buf), 172, 16) - if err != nil { - return err - } - b.BlsToExecutionChanges = make([]*SignedBLSToExecutionChange, num) - for ii := 0; ii < num; ii++ { - if b.BlsToExecutionChanges[ii] == nil { - b.BlsToExecutionChanges[ii] = new(SignedBLSToExecutionChange) - } - if err = b.BlsToExecutionChanges[ii].UnmarshalSSZ(buf[ii*172 : (ii+1)*172]); err != nil { - return err + if len(sszSlice10)%172 != 0 { + return fmt.Errorf("misaligned bytes: c.BlsToExecutionChanges length is %d, which is not a multiple of 172: %w", len(sszSlice10), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice10) / 172 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.BlsToExecutionChanges has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.BlsToExecutionChanges = make([]*SignedBLSToExecutionChange, numElem) + for i := 0; i < numElem; i++ { + var tmp *SignedBLSToExecutionChange + tmp = new(SignedBLSToExecutionChange) + tmpSlice := sszSlice10[i*172 : (1+i)*172] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("BlsToExecutionChanges: %w", err) } + c.BlsToExecutionChanges[i] = tmp } } - // Field (11) 'BlobKzgCommitments' + // Field 11: BlobKzgCommitments { - buf = tail[o11:] - num, err := ssz.DivideInt2(len(buf), 48, 4096) - if err != nil { - return err - } - b.BlobKzgCommitments = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(b.BlobKzgCommitments[ii]) == 0 { - b.BlobKzgCommitments[ii] = make([]byte, 0, len(buf[ii*48:(ii+1)*48])) - } - b.BlobKzgCommitments[ii] = append(b.BlobKzgCommitments[ii], buf[ii*48:(ii+1)*48]...) + if len(sszSlice11)%48 != 0 { + return fmt.Errorf("misaligned bytes: c.BlobKzgCommitments length is %d, which is not a multiple of 48: %w", len(sszSlice11), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice11) / 48 + if numElem > 4096 { + return fmt.Errorf("ssz-max exceeded: c.BlobKzgCommitments has %d elements, ssz-max is 4096: %w", numElem, ssz.ErrListTooBig) + } + c.BlobKzgCommitments = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte + + tmpSlice := sszSlice11[i*48 : (1+i)*48] + tmp = make([]byte, 0, 48) + tmp = append(tmp, tmpSlice...) + c.BlobKzgCommitments[i] = tmp } } return err } -// SizeSSZ returns the ssz encoded size in bytes for the BlindedBeaconBlockBodyDeneb object -func (b *BlindedBeaconBlockBodyDeneb) 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) 'ExecutionPayloadHeader' - if b.ExecutionPayloadHeader == nil { - b.ExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderDeneb) +func (c *BlindedBeaconBlockBodyDeneb) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - size += b.ExecutionPayloadHeader.SizeSSZ() - - // Field (10) 'BlsToExecutionChanges' - size += len(b.BlsToExecutionChanges) * 172 - - // Field (11) 'BlobKzgCommitments' - size += len(b.BlobKzgCommitments) * 48 - - return + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRoot ssz hashes the BlindedBeaconBlockBodyDeneb object -func (b *BlindedBeaconBlockBodyDeneb) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) -} - -// HashTreeRootWith ssz hashes the BlindedBeaconBlockBodyDeneb object with a hasher -func (b *BlindedBeaconBlockBodyDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *BlindedBeaconBlockBodyDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'RandaoReveal' - if size := len(b.RandaoReveal); size != 96 { - err = ssz.ErrBytesLengthFn("--.RandaoReveal", size, 96) - return + // Field 0: RandaoReveal + if len(c.RandaoReveal) != 96 { + return ssz.ErrBytesLength } - hh.PutBytes(b.RandaoReveal) - - // Field (1) 'Eth1Data' - if err = b.Eth1Data.HashTreeRootWith(hh); err != nil { - return + hh.PutBytes(c.RandaoReveal) + // Field 1: Eth1Data + if err := c.Eth1Data.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Eth1Data: %w", err) } - - // Field (2) 'Graffiti' - if size := len(b.Graffiti); size != 32 { - err = ssz.ErrBytesLengthFn("--.Graffiti", size, 32) - return + // Field 2: Graffiti + if len(c.Graffiti) != 32 { + return ssz.ErrBytesLength } - hh.PutBytes(b.Graffiti) - - // Field (3) 'ProposerSlashings' + hh.PutBytes(c.Graffiti) + // Field 3: ProposerSlashings { + if len(c.ProposerSlashings) > 16 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.ProposerSlashings { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ProposerSlashings: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.ProposerSlashings)), 16) } - - // Field (4) 'AttesterSlashings' + // Field 4: AttesterSlashings { + if len(c.AttesterSlashings) > 2 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.AttesterSlashings { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("AttesterSlashings: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 2) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.AttesterSlashings)), 2) } - - // Field (5) 'Attestations' + // Field 5: Attestations { + if len(c.Attestations) > 128 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.Attestations { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Attestations: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 128) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Attestations)), 128) } - - // Field (6) 'Deposits' + // Field 6: Deposits { + if len(c.Deposits) > 16 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.Deposits { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Deposits: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Deposits)), 16) } - - // Field (7) 'VoluntaryExits' + // Field 7: VoluntaryExits { + if len(c.VoluntaryExits) > 16 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.VoluntaryExits { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("VoluntaryExits: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.VoluntaryExits)), 16) } - - // Field (8) 'SyncAggregate' - if err = b.SyncAggregate.HashTreeRootWith(hh); err != nil { - return + // Field 8: SyncAggregate + if err := c.SyncAggregate.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) } - - // Field (9) 'ExecutionPayloadHeader' - if err = b.ExecutionPayloadHeader.HashTreeRootWith(hh); err != nil { - return + // Field 9: ExecutionPayloadHeader + if err := c.ExecutionPayloadHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ExecutionPayloadHeader: %w", err) } - - // Field (10) 'BlsToExecutionChanges' + // Field 10: BlsToExecutionChanges { + if len(c.BlsToExecutionChanges) > 16 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.BlsToExecutionChanges { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("BlsToExecutionChanges: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.BlsToExecutionChanges)), 16) } - - // Field (11) 'BlobKzgCommitments' + // Field 11: BlobKzgCommitments { - if size := len(b.BlobKzgCommitments); size > 4096 { - err = ssz.ErrListTooBigFn("--.BlobKzgCommitments", size, 4096) - return + if len(c.BlobKzgCommitments) > 4096 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range b.BlobKzgCommitments { - if len(i) != 48 { - err = ssz.ErrBytesLength - return + for _, o := range c.BlobKzgCommitments { + if len(o) != 48 { + return ssz.ErrBytesLength } - hh.PutBytes(i) + hh.PutBytes(o) } - - numItems := uint64(len(b.BlobKzgCommitments)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.BlobKzgCommitments)), 4096) } - hh.Merkleize(indx) - return + return nil +} + +func (c *BlindedBeaconBlockDeneb) SizeSSZ() int { + size := 84 + if c.Body == nil { + c.Body = new(BlindedBeaconBlockBodyDeneb) + } + size += c.Body.SizeSSZ() + return size } -// MarshalSSZ ssz marshals the SignedBuilderBidDeneb object -func (s *SignedBuilderBidDeneb) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) +func (c *BlindedBeaconBlockDeneb) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the SignedBuilderBidDeneb object to a target array -func (s *SignedBuilderBidDeneb) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(100) +func (c *BlindedBeaconBlockDeneb) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 84 - // Offset (0) 'Message' - dst = ssz.WriteOffset(dst, offset) - if s.Message == nil { - s.Message = new(BuilderBidDeneb) + // Field 0: Slot + if dst, err = c.Slot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Slot: %w", err) + } + + // Field 1: ProposerIndex + if dst, err = c.ProposerIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ProposerIndex: %w", err) + } + + // Field 2: ParentRoot + if len(c.ParentRoot) != 32 { + return nil, ssz.ErrBytesLength } - offset += s.Message.SizeSSZ() + dst = append(dst, c.ParentRoot...) - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 3: StateRoot + if len(c.StateRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, s.Signature...) + dst = append(dst, c.StateRoot...) - // Field (0) 'Message' - if dst, err = s.Message.MarshalSSZTo(dst); err != nil { - return + // Field 4: Body + if c.Body == nil { + c.Body = new(BlindedBeaconBlockBodyDeneb) } + dst = ssz.WriteOffset(dst, offset) + offset += c.Body.SizeSSZ() - return + // Field 4: Body + if dst, err = c.Body.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Body: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the SignedBuilderBidDeneb object -func (s *SignedBuilderBidDeneb) UnmarshalSSZ(buf []byte) error { +func (c *BlindedBeaconBlockDeneb) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 100 { + if size < 84 { return ssz.ErrSize } - tail := buf - var o0 uint64 + sszSlice0 := buf[0:8] // c.Slot + sszSlice1 := buf[8:16] // c.ProposerIndex + sszSlice2 := buf[16:48] // c.ParentRoot + sszSlice3 := buf[48:80] // c.StateRoot - // Offset (0) 'Message' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { + sszVarOffset4 := ssz.ReadOffset(buf[80:84]) // c.Body + if sszVarOffset4 != 84 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset4 > size { return ssz.ErrOffset } + sszSlice4 := buf[sszVarOffset4:] // c.Body - if o0 != 100 { - return ssz.ErrInvalidVariableOffset + // Field 0: Slot + if err = c.Slot.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Slot: %w", err) } - // Field (1) 'Signature' - if cap(s.Signature) == 0 { - s.Signature = make([]byte, 0, len(buf[4:100])) + // Field 1: ProposerIndex + if err = c.ProposerIndex.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("ProposerIndex: %w", err) } - s.Signature = append(s.Signature, buf[4:100]...) - // Field (0) 'Message' - { - buf = tail[o0:] - if s.Message == nil { - s.Message = new(BuilderBidDeneb) - } - if err = s.Message.UnmarshalSSZ(buf); err != nil { - return err - } + // Field 2: ParentRoot + c.ParentRoot = make([]byte, 0, 32) + c.ParentRoot = append(c.ParentRoot, sszSlice2...) + + // Field 3: StateRoot + c.StateRoot = make([]byte, 0, 32) + c.StateRoot = append(c.StateRoot, sszSlice3...) + + // Field 4: Body + c.Body = new(BlindedBeaconBlockBodyDeneb) + if err = c.Body.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("Body: %w", err) } return err } -// SizeSSZ returns the ssz encoded size in bytes for the SignedBuilderBidDeneb object -func (s *SignedBuilderBidDeneb) SizeSSZ() (size int) { - size = 100 +func (c *BlindedBeaconBlockDeneb) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (0) 'Message' - if s.Message == nil { - s.Message = new(BuilderBidDeneb) +func (c *BlindedBeaconBlockDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Slot + if err := c.Slot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Slot: %w", err) + } + // Field 1: ProposerIndex + if err := c.ProposerIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ProposerIndex: %w", err) + } + // Field 2: ParentRoot + if len(c.ParentRoot) != 32 { + return ssz.ErrBytesLength } - size += s.Message.SizeSSZ() + hh.PutBytes(c.ParentRoot) + // Field 3: StateRoot + if len(c.StateRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.StateRoot) + // Field 4: Body + if err := c.Body.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Body: %w", err) + } + hh.Merkleize(indx) + return nil +} - return +func (c *BlobIdentifier) SizeSSZ() int { + size := 40 + + return size } -// HashTreeRoot ssz hashes the SignedBuilderBidDeneb object -func (s *SignedBuilderBidDeneb) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) +func (c *BlobIdentifier) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// HashTreeRootWith ssz hashes the SignedBuilderBidDeneb object with a hasher -func (s *SignedBuilderBidDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() +func (c *BlobIdentifier) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + + // Field 0: BlockRoot + if len(c.BlockRoot) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.BlockRoot...) + + // Field 1: Index + dst = binary.LittleEndian.AppendUint64(dst, c.Index) + + return dst, err +} - // Field (0) 'Message' - if err = s.Message.HashTreeRootWith(hh); err != nil { - return +func (c *BlobIdentifier) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 40 { + return ssz.ErrSize } - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + sszSlice0 := buf[0:32] // c.BlockRoot + sszSlice1 := buf[32:40] // c.Index + + // Field 0: BlockRoot + c.BlockRoot = make([]byte, 0, 32) + c.BlockRoot = append(c.BlockRoot, sszSlice0...) + + // Field 1: Index + c.Index = binary.LittleEndian.Uint64(sszSlice1) + return err +} + +func (c *BlobIdentifier) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - hh.PutBytes(s.Signature) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} +func (c *BlobIdentifier) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: BlockRoot + if len(c.BlockRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.BlockRoot) + // Field 1: Index + hh.PutUint64(c.Index) hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the BuilderBidDeneb object -func (b *BuilderBidDeneb) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) +func (c *BlobSidecar) SizeSSZ() int { + size := 131928 + + return size } -// MarshalSSZTo ssz marshals the BuilderBidDeneb object to a target array -func (b *BuilderBidDeneb) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(88) +func (c *BlobSidecar) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Offset (0) 'Header' - dst = ssz.WriteOffset(dst, offset) - if b.Header == nil { - b.Header = new(v1.ExecutionPayloadHeaderDeneb) - } - offset += b.Header.SizeSSZ() +func (c *BlobSidecar) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Offset (1) 'BlobKzgCommitments' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.BlobKzgCommitments) * 48 + // Field 0: Index + dst = binary.LittleEndian.AppendUint64(dst, c.Index) + + // Field 1: Blob + if len(c.Blob) != 131072 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.Blob...) - // Field (2) 'Value' - if size := len(b.Value); size != 32 { - err = ssz.ErrBytesLengthFn("--.Value", size, 32) - return + // Field 2: KzgCommitment + if len(c.KzgCommitment) != 48 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.Value...) + dst = append(dst, c.KzgCommitment...) - // Field (3) 'Pubkey' - if size := len(b.Pubkey); size != 48 { - err = ssz.ErrBytesLengthFn("--.Pubkey", size, 48) - return + // Field 3: KzgProof + if len(c.KzgProof) != 48 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.Pubkey...) + dst = append(dst, c.KzgProof...) - // Field (0) 'Header' - if dst, err = b.Header.MarshalSSZTo(dst); err != nil { - return + // Field 4: SignedBlockHeader + if c.SignedBlockHeader == nil { + c.SignedBlockHeader = new(SignedBeaconBlockHeader) + } + if dst, err = c.SignedBlockHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SignedBlockHeader: %w", err) } - // Field (1) 'BlobKzgCommitments' - if size := len(b.BlobKzgCommitments); size > 4096 { - err = ssz.ErrListTooBigFn("--.BlobKzgCommitments", size, 4096) - return + // Field 5: CommitmentInclusionProof + if len(c.CommitmentInclusionProof) != 17 { + return nil, ssz.ErrBytesLength } - for ii := 0; ii < len(b.BlobKzgCommitments); ii++ { - if size := len(b.BlobKzgCommitments[ii]); size != 48 { - err = ssz.ErrBytesLengthFn("--.BlobKzgCommitments[ii]", size, 48) - return + for _, o := range c.CommitmentInclusionProof { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.BlobKzgCommitments[ii]...) + dst = append(dst, o...) } - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the BuilderBidDeneb object -func (b *BuilderBidDeneb) UnmarshalSSZ(buf []byte) error { +func (c *BlobSidecar) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 88 { + if size != 131928 { return ssz.ErrSize } - tail := buf - var o0, o1 uint64 + sszSlice0 := buf[0:8] // c.Index + sszSlice1 := buf[8:131080] // c.Blob + sszSlice2 := buf[131080:131128] // c.KzgCommitment + sszSlice3 := buf[131128:131176] // c.KzgProof + sszSlice4 := buf[131176:131384] // c.SignedBlockHeader + sszSlice5 := buf[131384:131928] // c.CommitmentInclusionProof - // Offset (0) 'Header' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } + // Field 0: Index + c.Index = binary.LittleEndian.Uint64(sszSlice0) - if o0 != 88 { - return ssz.ErrInvalidVariableOffset - } + // Field 1: Blob + c.Blob = make([]byte, 0, 131072) + c.Blob = append(c.Blob, sszSlice1...) - // Offset (1) 'BlobKzgCommitments' - if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 { - return ssz.ErrOffset - } + // Field 2: KzgCommitment + c.KzgCommitment = make([]byte, 0, 48) + c.KzgCommitment = append(c.KzgCommitment, sszSlice2...) - // Field (2) 'Value' - if cap(b.Value) == 0 { - b.Value = make([]byte, 0, len(buf[8:40])) - } - b.Value = append(b.Value, buf[8:40]...) + // Field 3: KzgProof + c.KzgProof = make([]byte, 0, 48) + c.KzgProof = append(c.KzgProof, sszSlice3...) - // Field (3) 'Pubkey' - if cap(b.Pubkey) == 0 { - b.Pubkey = make([]byte, 0, len(buf[40:88])) + // Field 4: SignedBlockHeader + c.SignedBlockHeader = new(SignedBeaconBlockHeader) + if err = c.SignedBlockHeader.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("SignedBlockHeader: %w", err) } - b.Pubkey = append(b.Pubkey, buf[40:88]...) - // Field (0) 'Header' + // Field 5: CommitmentInclusionProof { - buf = tail[o0:o1] - if b.Header == nil { - b.Header = new(v1.ExecutionPayloadHeaderDeneb) - } - if err = b.Header.UnmarshalSSZ(buf); err != nil { - return err - } - } + c.CommitmentInclusionProof = make([][]byte, 17) + for i := 0; i < 17; i++ { + var tmp []byte - // Field (1) 'BlobKzgCommitments' - { - buf = tail[o1:] - num, err := ssz.DivideInt2(len(buf), 48, 4096) - if err != nil { - return err - } - b.BlobKzgCommitments = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(b.BlobKzgCommitments[ii]) == 0 { - b.BlobKzgCommitments[ii] = make([]byte, 0, len(buf[ii*48:(ii+1)*48])) - } - b.BlobKzgCommitments[ii] = append(b.BlobKzgCommitments[ii], buf[ii*48:(ii+1)*48]...) + tmpSlice := sszSlice5[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.CommitmentInclusionProof[i] = tmp } } return err } -// SizeSSZ returns the ssz encoded size in bytes for the BuilderBidDeneb object -func (b *BuilderBidDeneb) SizeSSZ() (size int) { - size = 88 - - // Field (0) 'Header' - if b.Header == nil { - b.Header = new(v1.ExecutionPayloadHeaderDeneb) +func (c *BlobSidecar) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - size += b.Header.SizeSSZ() - - // Field (1) 'BlobKzgCommitments' - size += len(b.BlobKzgCommitments) * 48 - - return -} - -// HashTreeRoot ssz hashes the BuilderBidDeneb object -func (b *BuilderBidDeneb) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the BuilderBidDeneb object with a hasher -func (b *BuilderBidDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *BlobSidecar) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Header' - if err = b.Header.HashTreeRootWith(hh); err != nil { - return - } - - // Field (1) 'BlobKzgCommitments' + // Field 0: Index + hh.PutUint64(c.Index) + // Field 1: Blob + if len(c.Blob) != 131072 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Blob) + // Field 2: KzgCommitment + if len(c.KzgCommitment) != 48 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.KzgCommitment) + // Field 3: KzgProof + if len(c.KzgProof) != 48 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.KzgProof) + // Field 4: SignedBlockHeader + if err := c.SignedBlockHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SignedBlockHeader: %w", err) + } + // Field 5: CommitmentInclusionProof { - if size := len(b.BlobKzgCommitments); size > 4096 { - err = ssz.ErrListTooBigFn("--.BlobKzgCommitments", size, 4096) - return + if len(c.CommitmentInclusionProof) != 17 { + return ssz.ErrVectorLength } subIndx := hh.Index() - for _, i := range b.BlobKzgCommitments { - if len(i) != 48 { - err = ssz.ErrBytesLength - return + for _, o := range c.CommitmentInclusionProof { + if len(o) != 32 { + return ssz.ErrBytesLength } - hh.PutBytes(i) + hh.Append(o) } - - numItems := uint64(len(b.BlobKzgCommitments)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) - } - - // Field (2) 'Value' - if size := len(b.Value); size != 32 { - err = ssz.ErrBytesLengthFn("--.Value", size, 32) - return - } - hh.PutBytes(b.Value) - - // Field (3) 'Pubkey' - if size := len(b.Pubkey); size != 48 { - err = ssz.ErrBytesLengthFn("--.Pubkey", size, 48) - return + hh.Merkleize(subIndx) } - hh.PutBytes(b.Pubkey) - hh.Merkleize(indx) - return + return nil +} + +func (c *BlobSidecars) SizeSSZ() int { + size := 4 + size += len(c.Sidecars) * 131928 + return size } -// MarshalSSZ ssz marshals the BlobSidecars object -func (b *BlobSidecars) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) +func (c *BlobSidecars) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the BlobSidecars object to a target array -func (b *BlobSidecars) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(4) +func (c *BlobSidecars) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 4 - // Offset (0) 'Sidecars' + // Field 0: Sidecars dst = ssz.WriteOffset(dst, offset) - offset += len(b.Sidecars) * 131928 + offset += len(c.Sidecars) * 131928 - // Field (0) 'Sidecars' - if size := len(b.Sidecars); size > 6 { - err = ssz.ErrListTooBigFn("--.Sidecars", size, 6) - return + // Field 0: Sidecars + if len(c.Sidecars) > 6 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.Sidecars); ii++ { - if dst, err = b.Sidecars[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.Sidecars { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Sidecars: %w", err) } } - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the BlobSidecars object -func (b *BlobSidecars) UnmarshalSSZ(buf []byte) error { +func (c *BlobSidecars) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size < 4 { return ssz.ErrSize } - tail := buf - var o0 uint64 - - // Offset (0) 'Sidecars' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } - - if o0 != 4 { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Sidecars + if sszVarOffset0 != 4 { return ssz.ErrInvalidVariableOffset } + if sszVarOffset0 > size { + return ssz.ErrOffset + } + sszSlice0 := buf[sszVarOffset0:] // c.Sidecars - // Field (0) 'Sidecars' + // Field 0: Sidecars { - buf = tail[o0:] - num, err := ssz.DivideInt2(len(buf), 131928, 6) - if err != nil { - return err - } - b.Sidecars = make([]*BlobSidecar, num) - for ii := 0; ii < num; ii++ { - if b.Sidecars[ii] == nil { - b.Sidecars[ii] = new(BlobSidecar) - } - if err = b.Sidecars[ii].UnmarshalSSZ(buf[ii*131928 : (ii+1)*131928]); err != nil { - return err + if len(sszSlice0)%131928 != 0 { + return fmt.Errorf("misaligned bytes: c.Sidecars length is %d, which is not a multiple of 131928: %w", len(sszSlice0), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice0) / 131928 + if numElem > 6 { + return fmt.Errorf("ssz-max exceeded: c.Sidecars has %d elements, ssz-max is 6: %w", numElem, ssz.ErrListTooBig) + } + c.Sidecars = make([]*BlobSidecar, numElem) + for i := 0; i < numElem; i++ { + var tmp *BlobSidecar + tmp = new(BlobSidecar) + tmpSlice := sszSlice0[i*131928 : (1+i)*131928] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Sidecars: %w", err) } + c.Sidecars[i] = tmp } } return err } -// SizeSSZ returns the ssz encoded size in bytes for the BlobSidecars object -func (b *BlobSidecars) SizeSSZ() (size int) { - size = 4 - - // Field (0) 'Sidecars' - size += len(b.Sidecars) * 131928 - - return -} - -// HashTreeRoot ssz hashes the BlobSidecars object -func (b *BlobSidecars) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) +func (c *BlobSidecars) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the BlobSidecars object with a hasher -func (b *BlobSidecars) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *BlobSidecars) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Sidecars' + // Field 0: Sidecars { + if len(c.Sidecars) > 6 { + return ssz.ErrListTooBig + } subIndx := hh.Index() - num := uint64(len(b.Sidecars)) - if num > 6 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range b.Sidecars { - if err = elem.HashTreeRootWith(hh); err != nil { - return + for _, o := range c.Sidecars { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Sidecars: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 6) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Sidecars)), 6) } - hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the BlobSidecar object -func (b *BlobSidecar) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) +func (c *BuilderBidDeneb) SizeSSZ() int { + size := 88 + if c.Header == nil { + c.Header = new(v1.ExecutionPayloadHeaderDeneb) + } + size += c.Header.SizeSSZ() + size += len(c.BlobKzgCommitments) * 48 + return size } -// MarshalSSZTo ssz marshals the BlobSidecar object to a target array -func (b *BlobSidecar) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *BuilderBidDeneb) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (0) 'Index' - dst = ssz.MarshalUint(dst, b.Index) +func (c *BuilderBidDeneb) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 88 - // Field (1) 'Blob' - if size := len(b.Blob); size != 131072 { - err = ssz.ErrBytesLengthFn("--.Blob", size, 131072) - return + // Field 0: Header + if c.Header == nil { + c.Header = new(v1.ExecutionPayloadHeaderDeneb) } - dst = append(dst, b.Blob...) + dst = ssz.WriteOffset(dst, offset) + offset += c.Header.SizeSSZ() - // Field (2) 'KzgCommitment' - if size := len(b.KzgCommitment); size != 48 { - err = ssz.ErrBytesLengthFn("--.KzgCommitment", size, 48) - return - } - dst = append(dst, b.KzgCommitment...) + // Field 1: BlobKzgCommitments + dst = ssz.WriteOffset(dst, offset) + offset += len(c.BlobKzgCommitments) * 48 - // Field (3) 'KzgProof' - if size := len(b.KzgProof); size != 48 { - err = ssz.ErrBytesLengthFn("--.KzgProof", size, 48) - return + // Field 2: Value + if len(c.Value) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.KzgProof...) + dst = append(dst, c.Value...) - // Field (4) 'SignedBlockHeader' - if b.SignedBlockHeader == nil { - b.SignedBlockHeader = new(SignedBeaconBlockHeader) + // Field 3: Pubkey + if len(c.Pubkey) != 48 { + return nil, ssz.ErrBytesLength } - if dst, err = b.SignedBlockHeader.MarshalSSZTo(dst); err != nil { - return + dst = append(dst, c.Pubkey...) + + // Field 0: Header + if dst, err = c.Header.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Header: %w", err) } - // Field (5) 'CommitmentInclusionProof' - if size := len(b.CommitmentInclusionProof); size != 17 { - err = ssz.ErrVectorLengthFn("--.CommitmentInclusionProof", size, 17) - return + // Field 1: BlobKzgCommitments + if len(c.BlobKzgCommitments) > 4096 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < 17; ii++ { - if size := len(b.CommitmentInclusionProof[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.CommitmentInclusionProof[ii]", size, 32) - return + for _, o := range c.BlobKzgCommitments { + if len(o) != 48 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.CommitmentInclusionProof[ii]...) + dst = append(dst, o...) } - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the BlobSidecar object -func (b *BlobSidecar) UnmarshalSSZ(buf []byte) error { +func (c *BuilderBidDeneb) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 131928 { + if size < 88 { return ssz.ErrSize } - // Field (0) 'Index' - b.Index = ssz.UnmarshallUint[uint64](buf[0:8]) + sszSlice2 := buf[8:40] // c.Value + sszSlice3 := buf[40:88] // c.Pubkey - // Field (1) 'Blob' - if cap(b.Blob) == 0 { - b.Blob = make([]byte, 0, len(buf[8:131080])) + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Header + if sszVarOffset0 != 88 { + return ssz.ErrInvalidVariableOffset } - b.Blob = append(b.Blob, buf[8:131080]...) - - // Field (2) 'KzgCommitment' - if cap(b.KzgCommitment) == 0 { - b.KzgCommitment = make([]byte, 0, len(buf[131080:131128])) + if sszVarOffset0 > size { + return ssz.ErrOffset } - b.KzgCommitment = append(b.KzgCommitment, buf[131080:131128]...) - - // Field (3) 'KzgProof' - if cap(b.KzgProof) == 0 { - b.KzgProof = make([]byte, 0, len(buf[131128:131176])) + sszVarOffset1 := ssz.ReadOffset(buf[4:8]) // c.BlobKzgCommitments + if sszVarOffset1 > size || sszVarOffset1 < sszVarOffset0 { + return ssz.ErrOffset } - b.KzgProof = append(b.KzgProof, buf[131128:131176]...) + sszSlice0 := buf[sszVarOffset0:sszVarOffset1] // c.Header + sszSlice1 := buf[sszVarOffset1:] // c.BlobKzgCommitments - // Field (4) 'SignedBlockHeader' - if b.SignedBlockHeader == nil { - b.SignedBlockHeader = new(SignedBeaconBlockHeader) - } - if err = b.SignedBlockHeader.UnmarshalSSZ(buf[131176:131384]); err != nil { - return err + // Field 0: Header + c.Header = new(v1.ExecutionPayloadHeaderDeneb) + if err = c.Header.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Header: %w", err) } - // Field (5) 'CommitmentInclusionProof' - b.CommitmentInclusionProof = make([][]byte, 17) - for ii := 0; ii < 17; ii++ { - if cap(b.CommitmentInclusionProof[ii]) == 0 { - b.CommitmentInclusionProof[ii] = make([]byte, 0, len(buf[131384:131928][ii*32:(ii+1)*32])) + // Field 1: BlobKzgCommitments + { + if len(sszSlice1)%48 != 0 { + return fmt.Errorf("misaligned bytes: c.BlobKzgCommitments length is %d, which is not a multiple of 48: %w", len(sszSlice1), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice1) / 48 + if numElem > 4096 { + return fmt.Errorf("ssz-max exceeded: c.BlobKzgCommitments has %d elements, ssz-max is 4096: %w", numElem, ssz.ErrListTooBig) + } + c.BlobKzgCommitments = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte + + tmpSlice := sszSlice1[i*48 : (1+i)*48] + tmp = make([]byte, 0, 48) + tmp = append(tmp, tmpSlice...) + c.BlobKzgCommitments[i] = tmp } - b.CommitmentInclusionProof[ii] = append(b.CommitmentInclusionProof[ii], buf[131384:131928][ii*32:(ii+1)*32]...) } - return err -} + // Field 2: Value + c.Value = make([]byte, 0, 32) + c.Value = append(c.Value, sszSlice2...) -// SizeSSZ returns the ssz encoded size in bytes for the BlobSidecar object -func (b *BlobSidecar) SizeSSZ() (size int) { - size = 131928 - return + // Field 3: Pubkey + c.Pubkey = make([]byte, 0, 48) + c.Pubkey = append(c.Pubkey, sszSlice3...) + return err } -// HashTreeRoot ssz hashes the BlobSidecar object -func (b *BlobSidecar) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) +func (c *BuilderBidDeneb) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the BlobSidecar object with a hasher -func (b *BlobSidecar) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *BuilderBidDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Index' - ssz.PutUint(hh, b.Index) - - // Field (1) 'Blob' - if size := len(b.Blob); size != 131072 { - err = ssz.ErrBytesLengthFn("--.Blob", size, 131072) - return - } - hh.PutBytes(b.Blob) - - // Field (2) 'KzgCommitment' - if size := len(b.KzgCommitment); size != 48 { - err = ssz.ErrBytesLengthFn("--.KzgCommitment", size, 48) - return - } - hh.PutBytes(b.KzgCommitment) - - // Field (3) 'KzgProof' - if size := len(b.KzgProof); size != 48 { - err = ssz.ErrBytesLengthFn("--.KzgProof", size, 48) - return - } - hh.PutBytes(b.KzgProof) - - // Field (4) 'SignedBlockHeader' - if err = b.SignedBlockHeader.HashTreeRootWith(hh); err != nil { - return + // Field 0: Header + if err := c.Header.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Header: %w", err) } - - // Field (5) 'CommitmentInclusionProof' + // Field 1: BlobKzgCommitments { - if size := len(b.CommitmentInclusionProof); size != 17 { - err = ssz.ErrVectorLengthFn("--.CommitmentInclusionProof", size, 17) - return + if len(c.BlobKzgCommitments) > 4096 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range b.CommitmentInclusionProof { - if len(i) != 32 { - err = ssz.ErrBytesLength - return + for _, o := range c.BlobKzgCommitments { + if len(o) != 48 { + return ssz.ErrBytesLength } - hh.Append(i) + hh.PutBytes(o) } - hh.Merkleize(subIndx) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.BlobKzgCommitments)), 4096) } - + // Field 2: Value + if len(c.Value) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Value) + // Field 3: Pubkey + if len(c.Pubkey) != 48 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Pubkey) hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the BeaconStateDeneb object -func (b *BeaconStateDeneb) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) +func (c *LightClientHeaderDeneb) SizeSSZ() int { + size := 244 + if c.Execution == nil { + c.Execution = new(v1.ExecutionPayloadHeaderDeneb) + } + size += c.Execution.SizeSSZ() + return size } -// MarshalSSZTo ssz marshals the BeaconStateDeneb object to a target array -func (b *BeaconStateDeneb) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(2736653) - - // Field (0) 'GenesisTime' - dst = ssz.MarshalUint(dst, b.GenesisTime) - - // Field (1) 'GenesisValidatorsRoot' - if size := len(b.GenesisValidatorsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.GenesisValidatorsRoot", size, 32) - return - } - dst = append(dst, b.GenesisValidatorsRoot...) +func (c *LightClientHeaderDeneb) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (2) 'Slot' - dst = ssz.MarshalUint(dst, b.Slot) +func (c *LightClientHeaderDeneb) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 244 - // Field (3) 'Fork' - if b.Fork == nil { - b.Fork = new(Fork) + // Field 0: Beacon + if c.Beacon == nil { + c.Beacon = new(BeaconBlockHeader) } - if dst, err = b.Fork.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.Beacon.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Beacon: %w", err) } - // Field (4) 'LatestBlockHeader' - if b.LatestBlockHeader == nil { - b.LatestBlockHeader = new(BeaconBlockHeader) - } - if dst, err = b.LatestBlockHeader.MarshalSSZTo(dst); err != nil { - return + // Field 1: Execution + if c.Execution == nil { + c.Execution = new(v1.ExecutionPayloadHeaderDeneb) } + dst = ssz.WriteOffset(dst, offset) + offset += c.Execution.SizeSSZ() - // Field (5) 'BlockRoots' - if size := len(b.BlockRoots); size != 8192 { - err = ssz.ErrVectorLengthFn("--.BlockRoots", size, 8192) - return + // Field 2: ExecutionBranch + if len(c.ExecutionBranch) != 4 { + return nil, ssz.ErrBytesLength } - for ii := 0; ii < 8192; ii++ { - if size := len(b.BlockRoots[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockRoots[ii]", size, 32) - return + for _, o := range c.ExecutionBranch { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.BlockRoots[ii]...) + dst = append(dst, o...) } - // Field (6) 'StateRoots' - if size := len(b.StateRoots); size != 8192 { - err = ssz.ErrVectorLengthFn("--.StateRoots", size, 8192) - return - } - for ii := 0; ii < 8192; ii++ { - if size := len(b.StateRoots[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoots[ii]", size, 32) - return - } - dst = append(dst, b.StateRoots[ii]...) + // Field 1: Execution + if dst, err = c.Execution.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Execution: %w", err) } + return dst, err +} - // Offset (7) 'HistoricalRoots' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.HistoricalRoots) * 32 - - // Field (8) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(Eth1Data) - } - if dst, err = b.Eth1Data.MarshalSSZTo(dst); err != nil { - return +func (c *LightClientHeaderDeneb) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 244 { + return ssz.ErrSize } - // Offset (9) 'Eth1DataVotes' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.Eth1DataVotes) * 72 - - // Field (10) 'Eth1DepositIndex' - dst = ssz.MarshalUint(dst, b.Eth1DepositIndex) - - // Offset (11) 'Validators' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.Validators) * 121 + sszSlice0 := buf[0:112] // c.Beacon + sszSlice2 := buf[116:244] // c.ExecutionBranch - // 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("--.RandaoMixes", size, 65536) - return + sszVarOffset1 := ssz.ReadOffset(buf[112:116]) // c.Execution + if sszVarOffset1 != 244 { + return ssz.ErrInvalidVariableOffset } - for ii := 0; ii < 65536; ii++ { - if size := len(b.RandaoMixes[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.RandaoMixes[ii]", size, 32) - return - } - dst = append(dst, b.RandaoMixes[ii]...) + if sszVarOffset1 > size { + return ssz.ErrOffset } + sszSlice1 := buf[sszVarOffset1:] // c.Execution - // Field (14) 'Slashings' - if size := len(b.Slashings); size != 8192 { - err = ssz.ErrVectorLengthFn("--.Slashings", size, 8192) - return - } - for ii := 0; ii < 8192; ii++ { - dst = ssz.MarshalUint(dst, b.Slashings[ii]) + // Field 0: Beacon + c.Beacon = new(BeaconBlockHeader) + if err = c.Beacon.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Beacon: %w", err) } - // 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' - if size := len(b.JustificationBits); size != 1 { - err = ssz.ErrBytesLengthFn("--.JustificationBits", size, 1) - return + // Field 1: Execution + c.Execution = new(v1.ExecutionPayloadHeaderDeneb) + if err = c.Execution.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Execution: %w", err) } - dst = append(dst, b.JustificationBits...) - // Field (18) 'PreviousJustifiedCheckpoint' - if b.PreviousJustifiedCheckpoint == nil { - b.PreviousJustifiedCheckpoint = new(Checkpoint) - } - if dst, err = b.PreviousJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { - return - } + // Field 2: ExecutionBranch + { + c.ExecutionBranch = make([][]byte, 4) + for i := 0; i < 4; i++ { + var tmp []byte - // Field (19) 'CurrentJustifiedCheckpoint' - if b.CurrentJustifiedCheckpoint == nil { - b.CurrentJustifiedCheckpoint = new(Checkpoint) + tmpSlice := sszSlice2[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.ExecutionBranch[i] = tmp + } } - if dst, err = b.CurrentJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { - return + return err +} + +func (c *LightClientHeaderDeneb) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (20) 'FinalizedCheckpoint' - if b.FinalizedCheckpoint == nil { - b.FinalizedCheckpoint = new(Checkpoint) +func (c *LightClientHeaderDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Beacon + if err := c.Beacon.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Beacon: %w", err) } - if dst, err = b.FinalizedCheckpoint.MarshalSSZTo(dst); err != nil { - return + // Field 1: Execution + if err := c.Execution.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Execution: %w", err) } - - // Offset (21) 'InactivityScores' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.InactivityScores) * 8 - - // Field (22) 'CurrentSyncCommittee' - if b.CurrentSyncCommittee == nil { - b.CurrentSyncCommittee = new(SyncCommittee) - } - if dst, err = b.CurrentSyncCommittee.MarshalSSZTo(dst); err != nil { - return - } - - // Field (23) 'NextSyncCommittee' - if b.NextSyncCommittee == nil { - b.NextSyncCommittee = new(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(v1.ExecutionPayloadHeaderDeneb) - } - offset += b.LatestExecutionPayloadHeader.SizeSSZ() - - // Field (25) 'NextWithdrawalIndex' - dst = ssz.MarshalUint(dst, b.NextWithdrawalIndex) - - // Field (26) 'NextWithdrawalValidatorIndex' - dst = ssz.MarshalUint(dst, b.NextWithdrawalValidatorIndex) - - // Offset (27) 'HistoricalSummaries' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.HistoricalSummaries) * 64 - - // Field (7) 'HistoricalRoots' - if size := len(b.HistoricalRoots); size > 16777216 { - err = ssz.ErrListTooBigFn("--.HistoricalRoots", size, 16777216) - return - } - for ii := 0; ii < len(b.HistoricalRoots); ii++ { - if size := len(b.HistoricalRoots[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.HistoricalRoots[ii]", size, 32) - return - } - dst = append(dst, b.HistoricalRoots[ii]...) - } - - // Field (9) 'Eth1DataVotes' - if size := len(b.Eth1DataVotes); size > 2048 { - err = ssz.ErrListTooBigFn("--.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("--.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("--.Balances", size, 1099511627776) - return - } - for ii := 0; ii < len(b.Balances); ii++ { - dst = ssz.MarshalUint(dst, b.Balances[ii]) - } - - // Field (15) 'PreviousEpochParticipation' - if size := len(b.PreviousEpochParticipation); size > 1099511627776 { - err = ssz.ErrBytesLengthFn("--.PreviousEpochParticipation", size, 1099511627776) - return - } - dst = append(dst, b.PreviousEpochParticipation...) - - // Field (16) 'CurrentEpochParticipation' - if size := len(b.CurrentEpochParticipation); size > 1099511627776 { - err = ssz.ErrBytesLengthFn("--.CurrentEpochParticipation", size, 1099511627776) - return - } - dst = append(dst, b.CurrentEpochParticipation...) - - // Field (21) 'InactivityScores' - if size := len(b.InactivityScores); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.InactivityScores", size, 1099511627776) - return - } - for ii := 0; ii < len(b.InactivityScores); ii++ { - dst = ssz.MarshalUint(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("--.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 BeaconStateDeneb object -func (b *BeaconStateDeneb) 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.UnmarshallUint[uint64](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.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[40:48]) - - // Field (3) 'Fork' - if b.Fork == nil { - b.Fork = new(Fork) - } - if err = b.Fork.UnmarshalSSZ(buf[48:64]); err != nil { - return err - } - - // Field (4) 'LatestBlockHeader' - if b.LatestBlockHeader == nil { - b.LatestBlockHeader = new(BeaconBlockHeader) - } - if err = b.LatestBlockHeader.UnmarshalSSZ(buf[64:176]); err != nil { - return err - } - - // Field (5) 'BlockRoots' - b.BlockRoots = make([][]byte, 8192) - for ii := 0; ii < 8192; ii++ { - if cap(b.BlockRoots[ii]) == 0 { - b.BlockRoots[ii] = make([]byte, 0, len(buf[176:262320][ii*32:(ii+1)*32])) - } - b.BlockRoots[ii] = append(b.BlockRoots[ii], buf[176:262320][ii*32:(ii+1)*32]...) - } - - // Field (6) 'StateRoots' - b.StateRoots = make([][]byte, 8192) - for ii := 0; ii < 8192; ii++ { - if cap(b.StateRoots[ii]) == 0 { - b.StateRoots[ii] = make([]byte, 0, len(buf[262320:524464][ii*32:(ii+1)*32])) - } - b.StateRoots[ii] = append(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(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.UnmarshallUint[uint64](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.ExtendUint(b.Slashings, 8192) - for ii := 0; ii < 8192; ii++ { - b.Slashings[ii] = ssz.UnmarshallUint[uint64](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' - if cap(b.JustificationBits) == 0 { - b.JustificationBits = make([]byte, 0, len(buf[2687256:2687257])) - } - b.JustificationBits = append(b.JustificationBits, buf[2687256:2687257]...) - - // Field (18) 'PreviousJustifiedCheckpoint' - if b.PreviousJustifiedCheckpoint == nil { - b.PreviousJustifiedCheckpoint = new(Checkpoint) - } - if err = b.PreviousJustifiedCheckpoint.UnmarshalSSZ(buf[2687257:2687297]); err != nil { - return err - } - - // Field (19) 'CurrentJustifiedCheckpoint' - if b.CurrentJustifiedCheckpoint == nil { - b.CurrentJustifiedCheckpoint = new(Checkpoint) - } - if err = b.CurrentJustifiedCheckpoint.UnmarshalSSZ(buf[2687297:2687337]); err != nil { - return err - } - - // Field (20) 'FinalizedCheckpoint' - if b.FinalizedCheckpoint == nil { - b.FinalizedCheckpoint = new(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(SyncCommittee) - } - if err = b.CurrentSyncCommittee.UnmarshalSSZ(buf[2687381:2712005]); err != nil { - return err - } - - // Field (23) 'NextSyncCommittee' - if b.NextSyncCommittee == nil { - b.NextSyncCommittee = new(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.UnmarshallUint[uint64](buf[2736633:2736641]) - - // Field (26) 'NextWithdrawalValidatorIndex' - b.NextWithdrawalValidatorIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](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([]*Eth1Data, num) - for ii := 0; ii < num; ii++ { - if b.Eth1DataVotes[ii] == nil { - b.Eth1DataVotes[ii] = new(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([]*Validator, num) - for ii := 0; ii < num; ii++ { - if b.Validators[ii] == nil { - b.Validators[ii] = new(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.ExtendUint(b.Balances, num) - for ii := 0; ii < num; ii++ { - b.Balances[ii] = ssz.UnmarshallUint[uint64](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.ExtendUint(b.InactivityScores, num) - for ii := 0; ii < num; ii++ { - b.InactivityScores[ii] = ssz.UnmarshallUint[uint64](buf[ii*8 : (ii+1)*8]) - } - } - - // Field (24) 'LatestExecutionPayloadHeader' - { - buf = tail[o24:o27] - if b.LatestExecutionPayloadHeader == nil { - b.LatestExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderDeneb) - } - 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([]*HistoricalSummary, num) - for ii := 0; ii < num; ii++ { - if b.HistoricalSummaries[ii] == nil { - b.HistoricalSummaries[ii] = new(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 BeaconStateDeneb object -func (b *BeaconStateDeneb) 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(v1.ExecutionPayloadHeaderDeneb) - } - size += b.LatestExecutionPayloadHeader.SizeSSZ() - - // Field (27) 'HistoricalSummaries' - size += len(b.HistoricalSummaries) * 64 - - return -} - -// HashTreeRoot ssz hashes the BeaconStateDeneb object -func (b *BeaconStateDeneb) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) -} - -// HashTreeRootWith ssz hashes the BeaconStateDeneb object with a hasher -func (b *BeaconStateDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'GenesisTime' - ssz.PutUint(hh, b.GenesisTime) - - // Field (1) 'GenesisValidatorsRoot' - if size := len(b.GenesisValidatorsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.GenesisValidatorsRoot", size, 32) - return - } - hh.PutBytes(b.GenesisValidatorsRoot) - - // Field (2) 'Slot' - ssz.PutUint(hh, b.Slot) - - // Field (3) 'Fork' - if err = b.Fork.HashTreeRootWith(hh); err != nil { - return - } - - // Field (4) 'LatestBlockHeader' - if err = b.LatestBlockHeader.HashTreeRootWith(hh); err != nil { - return - } - - // Field (5) 'BlockRoots' - { - if size := len(b.BlockRoots); size != 8192 { - err = ssz.ErrVectorLengthFn("--.BlockRoots", size, 8192) - return - } - subIndx := hh.Index() - for _, i := range b.BlockRoots { - if len(i) != 32 { - err = ssz.ErrBytesLength - return - } - hh.Append(i) - } - hh.Merkleize(subIndx) - } - - // Field (6) 'StateRoots' - { - if size := len(b.StateRoots); size != 8192 { - err = ssz.ErrVectorLengthFn("--.StateRoots", size, 8192) - return - } - subIndx := hh.Index() - for _, i := range b.StateRoots { - if len(i) != 32 { - err = ssz.ErrBytesLength - return - } - hh.Append(i) - } - hh.Merkleize(subIndx) - } - - // Field (7) 'HistoricalRoots' - { - if size := len(b.HistoricalRoots); size > 16777216 { - err = ssz.ErrListTooBigFn("--.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 err = b.Eth1Data.HashTreeRootWith(hh); err != nil { - return - } - - // Field (9) 'Eth1DataVotes' + // Field 2: ExecutionBranch { - 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 - } + if len(c.ExecutionBranch) != 4 { + return ssz.ErrVectorLength } - hh.MerkleizeWithMixin(subIndx, num, 2048) - } - - // Field (10) 'Eth1DepositIndex' - ssz.PutUint(hh, 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 + for _, o := range c.ExecutionBranch { + if len(o) != 32 { + return ssz.ErrBytesLength } - } - hh.MerkleizeWithMixin(subIndx, num, 1099511627776) - } - - // Field (12) 'Balances' - { - if size := len(b.Balances); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.Balances", size, 1099511627776) - return - } - subIndx := hh.Index() - for _, i := range b.Balances { - ssz.AppendUint(hh, 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("--.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("--.Slashings", size, 8192) - return - } - subIndx := hh.Index() - for _, i := range b.Slashings { - ssz.AppendUint(hh, i) + hh.Append(o) } hh.Merkleize(subIndx) } - - // Field (15) 'PreviousEpochParticipation' - { - elemIndx := hh.Index() - byteLen := uint64(len(b.PreviousEpochParticipation)) - if byteLen > 1099511627776 { - err = ssz.ErrIncorrectListSize - return - } - hh.AppendBytes32(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.AppendBytes32(b.CurrentEpochParticipation) - hh.MerkleizeWithMixin(elemIndx, byteLen, (1099511627776+31)/32) - } - - // Field (17) 'JustificationBits' - if size := len(b.JustificationBits); size != 1 { - err = ssz.ErrBytesLengthFn("--.JustificationBits", size, 1) - return - } - hh.PutBytes(b.JustificationBits) - - // Field (18) 'PreviousJustifiedCheckpoint' - if err = b.PreviousJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { - return - } - - // Field (19) 'CurrentJustifiedCheckpoint' - if err = b.CurrentJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { - return - } - - // Field (20) 'FinalizedCheckpoint' - if err = b.FinalizedCheckpoint.HashTreeRootWith(hh); err != nil { - return - } - - // Field (21) 'InactivityScores' - { - if size := len(b.InactivityScores); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.InactivityScores", size, 1099511627776) - return - } - subIndx := hh.Index() - for _, i := range b.InactivityScores { - ssz.AppendUint(hh, i) - } - hh.FillUpTo32() - - numItems := uint64(len(b.InactivityScores)) - hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(1099511627776, numItems, 8)) - } - - // Field (22) 'CurrentSyncCommittee' - if err = b.CurrentSyncCommittee.HashTreeRootWith(hh); err != nil { - return - } - - // Field (23) 'NextSyncCommittee' - if err = b.NextSyncCommittee.HashTreeRootWith(hh); err != nil { - return - } - - // Field (24) 'LatestExecutionPayloadHeader' - if err = b.LatestExecutionPayloadHeader.HashTreeRootWith(hh); err != nil { - return - } - - // Field (25) 'NextWithdrawalIndex' - ssz.PutUint(hh, b.NextWithdrawalIndex) - - // Field (26) 'NextWithdrawalValidatorIndex' - ssz.PutUint(hh, 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 -} - -// MarshalSSZ ssz marshals the BlobIdentifier object -func (b *BlobIdentifier) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} - -// MarshalSSZTo ssz marshals the BlobIdentifier object to a target array -func (b *BlobIdentifier) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - - // Field (0) 'BlockRoot' - if size := len(b.BlockRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockRoot", size, 32) - return - } - dst = append(dst, b.BlockRoot...) - - // Field (1) 'Index' - dst = ssz.MarshalUint(dst, b.Index) - - return + return nil } -// UnmarshalSSZ ssz unmarshals the BlobIdentifier object -func (b *BlobIdentifier) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size != 40 { - return ssz.ErrSize - } - - // Field (0) 'BlockRoot' - if cap(b.BlockRoot) == 0 { - b.BlockRoot = make([]byte, 0, len(buf[0:32])) +func (c *LightClientBootstrapDeneb) SizeSSZ() int { + size := 24788 + if c.Header == nil { + c.Header = new(LightClientHeaderDeneb) } - b.BlockRoot = append(b.BlockRoot, buf[0:32]...) - - // Field (1) 'Index' - b.Index = ssz.UnmarshallUint[uint64](buf[32:40]) - - return err + size += c.Header.SizeSSZ() + return size } -// SizeSSZ returns the ssz encoded size in bytes for the BlobIdentifier object -func (b *BlobIdentifier) SizeSSZ() (size int) { - size = 40 - return +func (c *LightClientBootstrapDeneb) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// HashTreeRoot ssz hashes the BlobIdentifier object -func (b *BlobIdentifier) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) -} - -// HashTreeRootWith ssz hashes the BlobIdentifier object with a hasher -func (b *BlobIdentifier) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() +func (c *LightClientBootstrapDeneb) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 24788 - // Field (0) 'BlockRoot' - if size := len(b.BlockRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockRoot", size, 32) - return + // Field 0: Header + if c.Header == nil { + c.Header = new(LightClientHeaderDeneb) } - hh.PutBytes(b.BlockRoot) - - // Field (1) 'Index' - ssz.PutUint(hh, b.Index) - - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the LightClientBootstrapDeneb object -func (l *LightClientBootstrapDeneb) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(l) -} - -// MarshalSSZTo ssz marshals the LightClientBootstrapDeneb object to a target array -func (l *LightClientBootstrapDeneb) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(24788) - - // Offset (0) 'Header' dst = ssz.WriteOffset(dst, offset) - if l.Header == nil { - l.Header = new(LightClientHeaderDeneb) - } - offset += l.Header.SizeSSZ() + offset += c.Header.SizeSSZ() - // Field (1) 'CurrentSyncCommittee' - if l.CurrentSyncCommittee == nil { - l.CurrentSyncCommittee = new(SyncCommittee) + // Field 1: CurrentSyncCommittee + if c.CurrentSyncCommittee == nil { + c.CurrentSyncCommittee = new(SyncCommittee) } - if dst, err = l.CurrentSyncCommittee.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.CurrentSyncCommittee.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("CurrentSyncCommittee: %w", err) } - // Field (2) 'CurrentSyncCommitteeBranch' - if size := len(l.CurrentSyncCommitteeBranch); size != 5 { - err = ssz.ErrVectorLengthFn("--.CurrentSyncCommitteeBranch", size, 5) - return + // Field 2: CurrentSyncCommitteeBranch + if len(c.CurrentSyncCommitteeBranch) != 5 { + return nil, ssz.ErrBytesLength } - for ii := 0; ii < 5; ii++ { - if size := len(l.CurrentSyncCommitteeBranch[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.CurrentSyncCommitteeBranch[ii]", size, 32) - return + for _, o := range c.CurrentSyncCommitteeBranch { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, l.CurrentSyncCommitteeBranch[ii]...) + dst = append(dst, o...) } - // Field (0) 'Header' - if dst, err = l.Header.MarshalSSZTo(dst); err != nil { - return + // Field 0: Header + if dst, err = c.Header.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Header: %w", err) } - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the LightClientBootstrapDeneb object -func (l *LightClientBootstrapDeneb) UnmarshalSSZ(buf []byte) error { +func (c *LightClientBootstrapDeneb) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size < 24788 { return ssz.ErrSize } - tail := buf - var o0 uint64 + sszSlice1 := buf[4:24628] // c.CurrentSyncCommittee + sszSlice2 := buf[24628:24788] // c.CurrentSyncCommitteeBranch - // Offset (0) 'Header' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } - - if o0 != 24788 { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Header + if sszVarOffset0 != 24788 { return ssz.ErrInvalidVariableOffset } - - // Field (1) 'CurrentSyncCommittee' - if l.CurrentSyncCommittee == nil { - l.CurrentSyncCommittee = new(SyncCommittee) - } - if err = l.CurrentSyncCommittee.UnmarshalSSZ(buf[4:24628]); err != nil { - return err + if sszVarOffset0 > size { + return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:] // c.Header - // Field (2) 'CurrentSyncCommitteeBranch' - l.CurrentSyncCommitteeBranch = make([][]byte, 5) - for ii := 0; ii < 5; ii++ { - if cap(l.CurrentSyncCommitteeBranch[ii]) == 0 { - l.CurrentSyncCommitteeBranch[ii] = make([]byte, 0, len(buf[24628:24788][ii*32:(ii+1)*32])) - } - l.CurrentSyncCommitteeBranch[ii] = append(l.CurrentSyncCommitteeBranch[ii], buf[24628:24788][ii*32:(ii+1)*32]...) + // Field 0: Header + c.Header = new(LightClientHeaderDeneb) + if err = c.Header.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Header: %w", err) } - // Field (0) 'Header' - { - buf = tail[o0:] - if l.Header == nil { - l.Header = new(LightClientHeaderDeneb) - } - if err = l.Header.UnmarshalSSZ(buf); err != nil { - return err - } + // Field 1: CurrentSyncCommittee + c.CurrentSyncCommittee = new(SyncCommittee) + if err = c.CurrentSyncCommittee.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("CurrentSyncCommittee: %w", err) } - return err -} -// SizeSSZ returns the ssz encoded size in bytes for the LightClientBootstrapDeneb object -func (l *LightClientBootstrapDeneb) SizeSSZ() (size int) { - size = 24788 + // Field 2: CurrentSyncCommitteeBranch + { + c.CurrentSyncCommitteeBranch = make([][]byte, 5) + for i := 0; i < 5; i++ { + var tmp []byte - // Field (0) 'Header' - if l.Header == nil { - l.Header = new(LightClientHeaderDeneb) + tmpSlice := sszSlice2[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.CurrentSyncCommitteeBranch[i] = tmp + } } - size += l.Header.SizeSSZ() - - return + return err } -// HashTreeRoot ssz hashes the LightClientBootstrapDeneb object -func (l *LightClientBootstrapDeneb) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(l) +func (c *LightClientBootstrapDeneb) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the LightClientBootstrapDeneb object with a hasher -func (l *LightClientBootstrapDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *LightClientBootstrapDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Header' - if err = l.Header.HashTreeRootWith(hh); err != nil { - return + // Field 0: Header + if err := c.Header.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Header: %w", err) } - - // Field (1) 'CurrentSyncCommittee' - if err = l.CurrentSyncCommittee.HashTreeRootWith(hh); err != nil { - return + // Field 1: CurrentSyncCommittee + if err := c.CurrentSyncCommittee.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("CurrentSyncCommittee: %w", err) } - - // Field (2) 'CurrentSyncCommitteeBranch' + // Field 2: CurrentSyncCommitteeBranch { - if size := len(l.CurrentSyncCommitteeBranch); size != 5 { - err = ssz.ErrVectorLengthFn("--.CurrentSyncCommitteeBranch", size, 5) - return + if len(c.CurrentSyncCommitteeBranch) != 5 { + return ssz.ErrVectorLength } subIndx := hh.Index() - for _, i := range l.CurrentSyncCommitteeBranch { - if len(i) != 32 { - err = ssz.ErrBytesLength - return + for _, o := range c.CurrentSyncCommitteeBranch { + if len(o) != 32 { + return ssz.ErrBytesLength } - hh.Append(i) + hh.Append(o) } hh.Merkleize(subIndx) } - hh.Merkleize(indx) - return + return nil +} + +func (c *LightClientUpdateDeneb) SizeSSZ() int { + size := 25152 + if c.AttestedHeader == nil { + c.AttestedHeader = new(LightClientHeaderDeneb) + } + size += c.AttestedHeader.SizeSSZ() + if c.FinalizedHeader == nil { + c.FinalizedHeader = new(LightClientHeaderDeneb) + } + size += c.FinalizedHeader.SizeSSZ() + return size } -// MarshalSSZ ssz marshals the LightClientUpdateDeneb object -func (l *LightClientUpdateDeneb) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(l) +func (c *LightClientUpdateDeneb) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the LightClientUpdateDeneb object to a target array -func (l *LightClientUpdateDeneb) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(25152) +func (c *LightClientUpdateDeneb) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 25152 - // Offset (0) 'AttestedHeader' - dst = ssz.WriteOffset(dst, offset) - if l.AttestedHeader == nil { - l.AttestedHeader = new(LightClientHeaderDeneb) + // Field 0: AttestedHeader + if c.AttestedHeader == nil { + c.AttestedHeader = new(LightClientHeaderDeneb) } - offset += l.AttestedHeader.SizeSSZ() + dst = ssz.WriteOffset(dst, offset) + offset += c.AttestedHeader.SizeSSZ() - // Field (1) 'NextSyncCommittee' - if l.NextSyncCommittee == nil { - l.NextSyncCommittee = new(SyncCommittee) + // Field 1: NextSyncCommittee + if c.NextSyncCommittee == nil { + c.NextSyncCommittee = new(SyncCommittee) } - if dst, err = l.NextSyncCommittee.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.NextSyncCommittee.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("NextSyncCommittee: %w", err) } - // Field (2) 'NextSyncCommitteeBranch' - if size := len(l.NextSyncCommitteeBranch); size != 5 { - err = ssz.ErrVectorLengthFn("--.NextSyncCommitteeBranch", size, 5) - return + // Field 2: NextSyncCommitteeBranch + if len(c.NextSyncCommitteeBranch) != 5 { + return nil, ssz.ErrBytesLength } - for ii := 0; ii < 5; ii++ { - if size := len(l.NextSyncCommitteeBranch[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.NextSyncCommitteeBranch[ii]", size, 32) - return + for _, o := range c.NextSyncCommitteeBranch { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, l.NextSyncCommitteeBranch[ii]...) + dst = append(dst, o...) } - // Offset (3) 'FinalizedHeader' - dst = ssz.WriteOffset(dst, offset) - if l.FinalizedHeader == nil { - l.FinalizedHeader = new(LightClientHeaderDeneb) + // Field 3: FinalizedHeader + if c.FinalizedHeader == nil { + c.FinalizedHeader = new(LightClientHeaderDeneb) } - offset += l.FinalizedHeader.SizeSSZ() + dst = ssz.WriteOffset(dst, offset) + offset += c.FinalizedHeader.SizeSSZ() - // Field (4) 'FinalityBranch' - if size := len(l.FinalityBranch); size != 6 { - err = ssz.ErrVectorLengthFn("--.FinalityBranch", size, 6) - return + // Field 4: FinalityBranch + if len(c.FinalityBranch) != 6 { + return nil, ssz.ErrBytesLength } - for ii := 0; ii < 6; ii++ { - if size := len(l.FinalityBranch[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.FinalityBranch[ii]", size, 32) - return + for _, o := range c.FinalityBranch { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, l.FinalityBranch[ii]...) + dst = append(dst, o...) } - // Field (5) 'SyncAggregate' - if l.SyncAggregate == nil { - l.SyncAggregate = new(SyncAggregate) + // Field 5: SyncAggregate + if c.SyncAggregate == nil { + c.SyncAggregate = new(SyncAggregate) } - if dst, err = l.SyncAggregate.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.SyncAggregate.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SyncAggregate: %w", err) } - // Field (6) 'SignatureSlot' - dst = ssz.MarshalUint(dst, l.SignatureSlot) - - // Field (0) 'AttestedHeader' - if dst, err = l.AttestedHeader.MarshalSSZTo(dst); err != nil { - return + // Field 6: SignatureSlot + if dst, err = c.SignatureSlot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SignatureSlot: %w", err) } - // Field (3) 'FinalizedHeader' - if dst, err = l.FinalizedHeader.MarshalSSZTo(dst); err != nil { - return + // Field 0: AttestedHeader + if dst, err = c.AttestedHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("AttestedHeader: %w", err) } - return + // Field 3: FinalizedHeader + if dst, err = c.FinalizedHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("FinalizedHeader: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the LightClientUpdateDeneb object -func (l *LightClientUpdateDeneb) UnmarshalSSZ(buf []byte) error { +func (c *LightClientUpdateDeneb) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size < 25152 { return ssz.ErrSize } - tail := buf - var o0, o3 uint64 - - // Offset (0) 'AttestedHeader' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } + sszSlice1 := buf[4:24628] // c.NextSyncCommittee + sszSlice2 := buf[24628:24788] // c.NextSyncCommitteeBranch + sszSlice4 := buf[24792:24984] // c.FinalityBranch + sszSlice5 := buf[24984:25144] // c.SyncAggregate + sszSlice6 := buf[25144:25152] // c.SignatureSlot - if o0 != 25152 { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.AttestedHeader + if sszVarOffset0 != 25152 { return ssz.ErrInvalidVariableOffset } - - // Field (1) 'NextSyncCommittee' - if l.NextSyncCommittee == nil { - l.NextSyncCommittee = new(SyncCommittee) + if sszVarOffset0 > size { + return ssz.ErrOffset } - if err = l.NextSyncCommittee.UnmarshalSSZ(buf[4:24628]); err != nil { - return err + sszVarOffset3 := ssz.ReadOffset(buf[24788:24792]) // c.FinalizedHeader + if sszVarOffset3 > size || sszVarOffset3 < sszVarOffset0 { + return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:sszVarOffset3] // c.AttestedHeader + sszSlice3 := buf[sszVarOffset3:] // c.FinalizedHeader - // Field (2) 'NextSyncCommitteeBranch' - l.NextSyncCommitteeBranch = make([][]byte, 5) - for ii := 0; ii < 5; ii++ { - if cap(l.NextSyncCommitteeBranch[ii]) == 0 { - l.NextSyncCommitteeBranch[ii] = make([]byte, 0, len(buf[24628:24788][ii*32:(ii+1)*32])) - } - l.NextSyncCommitteeBranch[ii] = append(l.NextSyncCommitteeBranch[ii], buf[24628:24788][ii*32:(ii+1)*32]...) + // Field 0: AttestedHeader + c.AttestedHeader = new(LightClientHeaderDeneb) + if err = c.AttestedHeader.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("AttestedHeader: %w", err) } - // Offset (3) 'FinalizedHeader' - if o3 = ssz.ReadOffset(buf[24788:24792]); o3 > size || o0 > o3 { - return ssz.ErrOffset + // Field 1: NextSyncCommittee + c.NextSyncCommittee = new(SyncCommittee) + if err = c.NextSyncCommittee.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("NextSyncCommittee: %w", err) } - // Field (4) 'FinalityBranch' - l.FinalityBranch = make([][]byte, 6) - for ii := 0; ii < 6; ii++ { - if cap(l.FinalityBranch[ii]) == 0 { - l.FinalityBranch[ii] = make([]byte, 0, len(buf[24792:24984][ii*32:(ii+1)*32])) + // Field 2: NextSyncCommitteeBranch + { + c.NextSyncCommitteeBranch = make([][]byte, 5) + for i := 0; i < 5; i++ { + var tmp []byte + + tmpSlice := sszSlice2[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.NextSyncCommitteeBranch[i] = tmp } - l.FinalityBranch[ii] = append(l.FinalityBranch[ii], buf[24792:24984][ii*32:(ii+1)*32]...) } - // Field (5) 'SyncAggregate' - if l.SyncAggregate == nil { - l.SyncAggregate = new(SyncAggregate) - } - if err = l.SyncAggregate.UnmarshalSSZ(buf[24984:25144]); err != nil { - return err + // Field 3: FinalizedHeader + c.FinalizedHeader = new(LightClientHeaderDeneb) + if err = c.FinalizedHeader.UnmarshalSSZ(sszSlice3); err != nil { + return fmt.Errorf("FinalizedHeader: %w", err) } - // Field (6) 'SignatureSlot' - l.SignatureSlot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[25144:25152]) - - // Field (0) 'AttestedHeader' + // Field 4: FinalityBranch { - buf = tail[o0:o3] - if l.AttestedHeader == nil { - l.AttestedHeader = new(LightClientHeaderDeneb) - } - if err = l.AttestedHeader.UnmarshalSSZ(buf); err != nil { - return err - } - } + c.FinalityBranch = make([][]byte, 6) + for i := 0; i < 6; i++ { + var tmp []byte - // Field (3) 'FinalizedHeader' - { - buf = tail[o3:] - if l.FinalizedHeader == nil { - l.FinalizedHeader = new(LightClientHeaderDeneb) - } - if err = l.FinalizedHeader.UnmarshalSSZ(buf); err != nil { - return err + tmpSlice := sszSlice4[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.FinalityBranch[i] = tmp } } - return err -} -// SizeSSZ returns the ssz encoded size in bytes for the LightClientUpdateDeneb object -func (l *LightClientUpdateDeneb) SizeSSZ() (size int) { - size = 25152 - - // Field (0) 'AttestedHeader' - if l.AttestedHeader == nil { - l.AttestedHeader = new(LightClientHeaderDeneb) + // Field 5: SyncAggregate + c.SyncAggregate = new(SyncAggregate) + if err = c.SyncAggregate.UnmarshalSSZ(sszSlice5); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) } - size += l.AttestedHeader.SizeSSZ() - // Field (3) 'FinalizedHeader' - if l.FinalizedHeader == nil { - l.FinalizedHeader = new(LightClientHeaderDeneb) + // Field 6: SignatureSlot + if err = c.SignatureSlot.UnmarshalSSZ(sszSlice6); err != nil { + return fmt.Errorf("SignatureSlot: %w", err) } - size += l.FinalizedHeader.SizeSSZ() - - return + return err } -// HashTreeRoot ssz hashes the LightClientUpdateDeneb object -func (l *LightClientUpdateDeneb) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(l) +func (c *LightClientUpdateDeneb) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the LightClientUpdateDeneb object with a hasher -func (l *LightClientUpdateDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *LightClientUpdateDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'AttestedHeader' - if err = l.AttestedHeader.HashTreeRootWith(hh); err != nil { - return + // Field 0: AttestedHeader + if err := c.AttestedHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("AttestedHeader: %w", err) } - - // Field (1) 'NextSyncCommittee' - if err = l.NextSyncCommittee.HashTreeRootWith(hh); err != nil { - return + // Field 1: NextSyncCommittee + if err := c.NextSyncCommittee.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("NextSyncCommittee: %w", err) } - - // Field (2) 'NextSyncCommitteeBranch' + // Field 2: NextSyncCommitteeBranch { - if size := len(l.NextSyncCommitteeBranch); size != 5 { - err = ssz.ErrVectorLengthFn("--.NextSyncCommitteeBranch", size, 5) - return + if len(c.NextSyncCommitteeBranch) != 5 { + return ssz.ErrVectorLength } subIndx := hh.Index() - for _, i := range l.NextSyncCommitteeBranch { - if len(i) != 32 { - err = ssz.ErrBytesLength - return + for _, o := range c.NextSyncCommitteeBranch { + if len(o) != 32 { + return ssz.ErrBytesLength } - hh.Append(i) + hh.Append(o) } hh.Merkleize(subIndx) } - - // Field (3) 'FinalizedHeader' - if err = l.FinalizedHeader.HashTreeRootWith(hh); err != nil { - return + // Field 3: FinalizedHeader + if err := c.FinalizedHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("FinalizedHeader: %w", err) } - - // Field (4) 'FinalityBranch' + // Field 4: FinalityBranch { - if size := len(l.FinalityBranch); size != 6 { - err = ssz.ErrVectorLengthFn("--.FinalityBranch", size, 6) - return + if len(c.FinalityBranch) != 6 { + return ssz.ErrVectorLength } subIndx := hh.Index() - for _, i := range l.FinalityBranch { - if len(i) != 32 { - err = ssz.ErrBytesLength - return + for _, o := range c.FinalityBranch { + if len(o) != 32 { + return ssz.ErrBytesLength } - hh.Append(i) + hh.Append(o) } hh.Merkleize(subIndx) } - - // Field (5) 'SyncAggregate' - if err = l.SyncAggregate.HashTreeRootWith(hh); err != nil { - return + // Field 5: SyncAggregate + if err := c.SyncAggregate.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) + } + // Field 6: SignatureSlot + if err := c.SignatureSlot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SignatureSlot: %w", err) } - - // Field (6) 'SignatureSlot' - ssz.PutUint(hh, l.SignatureSlot) - hh.Merkleize(indx) - return + return nil +} + +func (c *LightClientFinalityUpdateDeneb) SizeSSZ() int { + size := 368 + if c.AttestedHeader == nil { + c.AttestedHeader = new(LightClientHeaderDeneb) + } + size += c.AttestedHeader.SizeSSZ() + if c.FinalizedHeader == nil { + c.FinalizedHeader = new(LightClientHeaderDeneb) + } + size += c.FinalizedHeader.SizeSSZ() + return size } -// MarshalSSZ ssz marshals the LightClientFinalityUpdateDeneb object -func (l *LightClientFinalityUpdateDeneb) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(l) +func (c *LightClientFinalityUpdateDeneb) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the LightClientFinalityUpdateDeneb object to a target array -func (l *LightClientFinalityUpdateDeneb) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(368) +func (c *LightClientFinalityUpdateDeneb) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 368 - // Offset (0) 'AttestedHeader' - dst = ssz.WriteOffset(dst, offset) - if l.AttestedHeader == nil { - l.AttestedHeader = new(LightClientHeaderDeneb) + // Field 0: AttestedHeader + if c.AttestedHeader == nil { + c.AttestedHeader = new(LightClientHeaderDeneb) } - offset += l.AttestedHeader.SizeSSZ() - - // Offset (1) 'FinalizedHeader' dst = ssz.WriteOffset(dst, offset) - if l.FinalizedHeader == nil { - l.FinalizedHeader = new(LightClientHeaderDeneb) + offset += c.AttestedHeader.SizeSSZ() + + // Field 1: FinalizedHeader + if c.FinalizedHeader == nil { + c.FinalizedHeader = new(LightClientHeaderDeneb) } - offset += l.FinalizedHeader.SizeSSZ() + dst = ssz.WriteOffset(dst, offset) + offset += c.FinalizedHeader.SizeSSZ() - // Field (2) 'FinalityBranch' - if size := len(l.FinalityBranch); size != 6 { - err = ssz.ErrVectorLengthFn("--.FinalityBranch", size, 6) - return + // Field 2: FinalityBranch + if len(c.FinalityBranch) != 6 { + return nil, ssz.ErrBytesLength } - for ii := 0; ii < 6; ii++ { - if size := len(l.FinalityBranch[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.FinalityBranch[ii]", size, 32) - return + for _, o := range c.FinalityBranch { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, l.FinalityBranch[ii]...) + dst = append(dst, o...) } - // Field (3) 'SyncAggregate' - if l.SyncAggregate == nil { - l.SyncAggregate = new(SyncAggregate) + // Field 3: SyncAggregate + if c.SyncAggregate == nil { + c.SyncAggregate = new(SyncAggregate) } - if dst, err = l.SyncAggregate.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.SyncAggregate.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SyncAggregate: %w", err) } - // Field (4) 'SignatureSlot' - dst = ssz.MarshalUint(dst, l.SignatureSlot) - - // Field (0) 'AttestedHeader' - if dst, err = l.AttestedHeader.MarshalSSZTo(dst); err != nil { - return + // Field 4: SignatureSlot + if dst, err = c.SignatureSlot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SignatureSlot: %w", err) } - // Field (1) 'FinalizedHeader' - if dst, err = l.FinalizedHeader.MarshalSSZTo(dst); err != nil { - return + // Field 0: AttestedHeader + if dst, err = c.AttestedHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("AttestedHeader: %w", err) } - return + // Field 1: FinalizedHeader + if dst, err = c.FinalizedHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("FinalizedHeader: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the LightClientFinalityUpdateDeneb object -func (l *LightClientFinalityUpdateDeneb) UnmarshalSSZ(buf []byte) error { +func (c *LightClientFinalityUpdateDeneb) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size < 368 { return ssz.ErrSize } - tail := buf - var o0, o1 uint64 + sszSlice2 := buf[8:200] // c.FinalityBranch + sszSlice3 := buf[200:360] // c.SyncAggregate + sszSlice4 := buf[360:368] // c.SignatureSlot - // Offset (0) 'AttestedHeader' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.AttestedHeader + if sszVarOffset0 != 368 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset0 > size { + return ssz.ErrOffset + } + sszVarOffset1 := ssz.ReadOffset(buf[4:8]) // c.FinalizedHeader + if sszVarOffset1 > size || sszVarOffset1 < sszVarOffset0 { return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:sszVarOffset1] // c.AttestedHeader + sszSlice1 := buf[sszVarOffset1:] // c.FinalizedHeader - if o0 != 368 { - return ssz.ErrInvalidVariableOffset + // Field 0: AttestedHeader + c.AttestedHeader = new(LightClientHeaderDeneb) + if err = c.AttestedHeader.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("AttestedHeader: %w", err) } - // Offset (1) 'FinalizedHeader' - if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 { - return ssz.ErrOffset + // Field 1: FinalizedHeader + c.FinalizedHeader = new(LightClientHeaderDeneb) + if err = c.FinalizedHeader.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("FinalizedHeader: %w", err) } - // Field (2) 'FinalityBranch' - l.FinalityBranch = make([][]byte, 6) - for ii := 0; ii < 6; ii++ { - if cap(l.FinalityBranch[ii]) == 0 { - l.FinalityBranch[ii] = make([]byte, 0, len(buf[8:200][ii*32:(ii+1)*32])) + // Field 2: FinalityBranch + { + c.FinalityBranch = make([][]byte, 6) + for i := 0; i < 6; i++ { + var tmp []byte + + tmpSlice := sszSlice2[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.FinalityBranch[i] = tmp } - l.FinalityBranch[ii] = append(l.FinalityBranch[ii], buf[8:200][ii*32:(ii+1)*32]...) } - // Field (3) 'SyncAggregate' - if l.SyncAggregate == nil { - l.SyncAggregate = new(SyncAggregate) + // Field 3: SyncAggregate + c.SyncAggregate = new(SyncAggregate) + if err = c.SyncAggregate.UnmarshalSSZ(sszSlice3); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) } - if err = l.SyncAggregate.UnmarshalSSZ(buf[200:360]); err != nil { - return err + + // Field 4: SignatureSlot + if err = c.SignatureSlot.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("SignatureSlot: %w", err) } + return err +} - // Field (4) 'SignatureSlot' - l.SignatureSlot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[360:368]) +func (c *LightClientFinalityUpdateDeneb) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (0) 'AttestedHeader' +func (c *LightClientFinalityUpdateDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: AttestedHeader + if err := c.AttestedHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("AttestedHeader: %w", err) + } + // Field 1: FinalizedHeader + if err := c.FinalizedHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("FinalizedHeader: %w", err) + } + // Field 2: FinalityBranch { - buf = tail[o0:o1] - if l.AttestedHeader == nil { - l.AttestedHeader = new(LightClientHeaderDeneb) + if len(c.FinalityBranch) != 6 { + return ssz.ErrVectorLength } - if err = l.AttestedHeader.UnmarshalSSZ(buf); err != nil { - return err + subIndx := hh.Index() + for _, o := range c.FinalityBranch { + if len(o) != 32 { + return ssz.ErrBytesLength + } + hh.Append(o) } + hh.Merkleize(subIndx) + } + // Field 3: SyncAggregate + if err := c.SyncAggregate.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) } + // Field 4: SignatureSlot + if err := c.SignatureSlot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SignatureSlot: %w", err) + } + hh.Merkleize(indx) + return nil +} - // Field (1) 'FinalizedHeader' - { - buf = tail[o1:] - if l.FinalizedHeader == nil { - l.FinalizedHeader = new(LightClientHeaderDeneb) - } - if err = l.FinalizedHeader.UnmarshalSSZ(buf); err != nil { - return err - } +func (c *LightClientOptimisticUpdateDeneb) SizeSSZ() int { + size := 172 + if c.AttestedHeader == nil { + c.AttestedHeader = new(LightClientHeaderDeneb) } - return err + size += c.AttestedHeader.SizeSSZ() + return size +} + +func (c *LightClientOptimisticUpdateDeneb) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// SizeSSZ returns the ssz encoded size in bytes for the LightClientFinalityUpdateDeneb object -func (l *LightClientFinalityUpdateDeneb) SizeSSZ() (size int) { - size = 368 +func (c *LightClientOptimisticUpdateDeneb) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 172 - // Field (0) 'AttestedHeader' - if l.AttestedHeader == nil { - l.AttestedHeader = new(LightClientHeaderDeneb) + // Field 0: AttestedHeader + if c.AttestedHeader == nil { + c.AttestedHeader = new(LightClientHeaderDeneb) } - size += l.AttestedHeader.SizeSSZ() + dst = ssz.WriteOffset(dst, offset) + offset += c.AttestedHeader.SizeSSZ() - // Field (1) 'FinalizedHeader' - if l.FinalizedHeader == nil { - l.FinalizedHeader = new(LightClientHeaderDeneb) + // Field 1: SyncAggregate + if c.SyncAggregate == nil { + c.SyncAggregate = new(SyncAggregate) + } + if dst, err = c.SyncAggregate.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SyncAggregate: %w", err) } - size += l.FinalizedHeader.SizeSSZ() - return -} + // Field 2: SignatureSlot + if dst, err = c.SignatureSlot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SignatureSlot: %w", err) + } -// HashTreeRoot ssz hashes the LightClientFinalityUpdateDeneb object -func (l *LightClientFinalityUpdateDeneb) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(l) + // Field 0: AttestedHeader + if dst, err = c.AttestedHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("AttestedHeader: %w", err) + } + return dst, err } -// HashTreeRootWith ssz hashes the LightClientFinalityUpdateDeneb object with a hasher -func (l *LightClientFinalityUpdateDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() +func (c *LightClientOptimisticUpdateDeneb) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 172 { + return ssz.ErrSize + } + + sszSlice1 := buf[4:164] // c.SyncAggregate + sszSlice2 := buf[164:172] // c.SignatureSlot - // Field (0) 'AttestedHeader' - if err = l.AttestedHeader.HashTreeRootWith(hh); err != nil { - return + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.AttestedHeader + if sszVarOffset0 != 172 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset0 > size { + return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:] // c.AttestedHeader - // Field (1) 'FinalizedHeader' - if err = l.FinalizedHeader.HashTreeRootWith(hh); err != nil { - return + // Field 0: AttestedHeader + c.AttestedHeader = new(LightClientHeaderDeneb) + if err = c.AttestedHeader.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("AttestedHeader: %w", err) } - // Field (2) 'FinalityBranch' - { - if size := len(l.FinalityBranch); size != 6 { - err = ssz.ErrVectorLengthFn("--.FinalityBranch", size, 6) - return - } - subIndx := hh.Index() - for _, i := range l.FinalityBranch { - if len(i) != 32 { - err = ssz.ErrBytesLength - return - } - hh.Append(i) - } - hh.Merkleize(subIndx) + // Field 1: SyncAggregate + c.SyncAggregate = new(SyncAggregate) + if err = c.SyncAggregate.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) } - // Field (3) 'SyncAggregate' - if err = l.SyncAggregate.HashTreeRootWith(hh); err != nil { - return + // Field 2: SignatureSlot + if err = c.SignatureSlot.UnmarshalSSZ(sszSlice2); err != nil { + return fmt.Errorf("SignatureSlot: %w", err) } + return err +} - // Field (4) 'SignatureSlot' - ssz.PutUint(hh, l.SignatureSlot) +func (c *LightClientOptimisticUpdateDeneb) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} +func (c *LightClientOptimisticUpdateDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: AttestedHeader + if err := c.AttestedHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("AttestedHeader: %w", err) + } + // Field 1: SyncAggregate + if err := c.SyncAggregate.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) + } + // Field 2: SignatureSlot + if err := c.SignatureSlot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SignatureSlot: %w", err) + } hh.Merkleize(indx) - return + return nil +} + +func (c *SignedBeaconBlockContentsDeneb) SizeSSZ() int { + size := 12 + if c.Block == nil { + c.Block = new(SignedBeaconBlockDeneb) + } + size += c.Block.SizeSSZ() + size += len(c.KzgProofs) * 48 + size += len(c.Blobs) * 131072 + return size } -// MarshalSSZ ssz marshals the LightClientOptimisticUpdateDeneb object -func (l *LightClientOptimisticUpdateDeneb) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(l) +func (c *SignedBeaconBlockContentsDeneb) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the LightClientOptimisticUpdateDeneb object to a target array -func (l *LightClientOptimisticUpdateDeneb) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(172) +func (c *SignedBeaconBlockContentsDeneb) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 12 + + // Field 0: Block + if c.Block == nil { + c.Block = new(SignedBeaconBlockDeneb) + } + dst = ssz.WriteOffset(dst, offset) + offset += c.Block.SizeSSZ() + + // Field 1: KzgProofs + dst = ssz.WriteOffset(dst, offset) + offset += len(c.KzgProofs) * 48 - // Offset (0) 'AttestedHeader' + // Field 2: Blobs dst = ssz.WriteOffset(dst, offset) - if l.AttestedHeader == nil { - l.AttestedHeader = new(LightClientHeaderDeneb) + offset += len(c.Blobs) * 131072 + + // Field 0: Block + if dst, err = c.Block.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Block: %w", err) } - offset += l.AttestedHeader.SizeSSZ() - // Field (1) 'SyncAggregate' - if l.SyncAggregate == nil { - l.SyncAggregate = new(SyncAggregate) + // Field 1: KzgProofs + if len(c.KzgProofs) > 4096 { + return nil, ssz.ErrListTooBig } - if dst, err = l.SyncAggregate.MarshalSSZTo(dst); err != nil { - return + for _, o := range c.KzgProofs { + if len(o) != 48 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) } - // Field (2) 'SignatureSlot' - dst = ssz.MarshalUint(dst, l.SignatureSlot) - - // Field (0) 'AttestedHeader' - if dst, err = l.AttestedHeader.MarshalSSZTo(dst); err != nil { - return + // Field 2: Blobs + if len(c.Blobs) > 4096 { + return nil, ssz.ErrListTooBig } - - return + for _, o := range c.Blobs { + if len(o) != 131072 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the LightClientOptimisticUpdateDeneb object -func (l *LightClientOptimisticUpdateDeneb) UnmarshalSSZ(buf []byte) error { +func (c *SignedBeaconBlockContentsDeneb) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 172 { + if size < 12 { return ssz.ErrSize } - tail := buf - var o0 uint64 - - // Offset (0) 'AttestedHeader' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Block + if sszVarOffset0 != 12 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset0 > size { return ssz.ErrOffset } - - if o0 != 172 { - return ssz.ErrInvalidVariableOffset + sszVarOffset1 := ssz.ReadOffset(buf[4:8]) // c.KzgProofs + if sszVarOffset1 > size || sszVarOffset1 < sszVarOffset0 { + return ssz.ErrOffset } - - // Field (1) 'SyncAggregate' - if l.SyncAggregate == nil { - l.SyncAggregate = new(SyncAggregate) + sszVarOffset2 := ssz.ReadOffset(buf[8:12]) // c.Blobs + if sszVarOffset2 > size || sszVarOffset2 < sszVarOffset1 { + return ssz.ErrOffset } - if err = l.SyncAggregate.UnmarshalSSZ(buf[4:164]); err != nil { - return err + sszSlice0 := buf[sszVarOffset0:sszVarOffset1] // c.Block + sszSlice1 := buf[sszVarOffset1:sszVarOffset2] // c.KzgProofs + sszSlice2 := buf[sszVarOffset2:] // c.Blobs + + // Field 0: Block + c.Block = new(SignedBeaconBlockDeneb) + if err = c.Block.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Block: %w", err) } - // Field (2) 'SignatureSlot' - l.SignatureSlot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[164:172]) + // Field 1: KzgProofs + { + if len(sszSlice1)%48 != 0 { + return fmt.Errorf("misaligned bytes: c.KzgProofs length is %d, which is not a multiple of 48: %w", len(sszSlice1), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice1) / 48 + if numElem > 4096 { + return fmt.Errorf("ssz-max exceeded: c.KzgProofs has %d elements, ssz-max is 4096: %w", numElem, ssz.ErrListTooBig) + } + c.KzgProofs = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte + + tmpSlice := sszSlice1[i*48 : (1+i)*48] + tmp = make([]byte, 0, 48) + tmp = append(tmp, tmpSlice...) + c.KzgProofs[i] = tmp + } + } - // Field (0) 'AttestedHeader' + // Field 2: Blobs { - buf = tail[o0:] - if l.AttestedHeader == nil { - l.AttestedHeader = new(LightClientHeaderDeneb) + if len(sszSlice2)%131072 != 0 { + return fmt.Errorf("misaligned bytes: c.Blobs length is %d, which is not a multiple of 131072: %w", len(sszSlice2), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice2) / 131072 + if numElem > 4096 { + return fmt.Errorf("ssz-max exceeded: c.Blobs has %d elements, ssz-max is 4096: %w", numElem, ssz.ErrListTooBig) } - if err = l.AttestedHeader.UnmarshalSSZ(buf); err != nil { - return err + c.Blobs = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte + + tmpSlice := sszSlice2[i*131072 : (1+i)*131072] + tmp = make([]byte, 0, 131072) + tmp = append(tmp, tmpSlice...) + c.Blobs[i] = tmp } } return err } -// SizeSSZ returns the ssz encoded size in bytes for the LightClientOptimisticUpdateDeneb object -func (l *LightClientOptimisticUpdateDeneb) SizeSSZ() (size int) { - size = 172 +func (c *SignedBeaconBlockContentsDeneb) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (0) 'AttestedHeader' - if l.AttestedHeader == nil { - l.AttestedHeader = new(LightClientHeaderDeneb) +func (c *SignedBeaconBlockContentsDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Block + if err := c.Block.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Block: %w", err) + } + // Field 1: KzgProofs + { + if len(c.KzgProofs) > 4096 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.KzgProofs { + if len(o) != 48 { + return ssz.ErrBytesLength + } + hh.PutBytes(o) + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.KzgProofs)), 4096) + } + // Field 2: Blobs + { + if len(c.Blobs) > 4096 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.Blobs { + if len(o) != 131072 { + return ssz.ErrBytesLength + } + hh.PutBytes(o) + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Blobs)), 4096) } - size += l.AttestedHeader.SizeSSZ() + hh.Merkleize(indx) + return nil +} - return +func (c *SignedBeaconBlockDeneb) SizeSSZ() int { + size := 100 + if c.Block == nil { + c.Block = new(BeaconBlockDeneb) + } + size += c.Block.SizeSSZ() + return size } -// HashTreeRoot ssz hashes the LightClientOptimisticUpdateDeneb object -func (l *LightClientOptimisticUpdateDeneb) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(l) +func (c *SignedBeaconBlockDeneb) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// HashTreeRootWith ssz hashes the LightClientOptimisticUpdateDeneb object with a hasher -func (l *LightClientOptimisticUpdateDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() +func (c *SignedBeaconBlockDeneb) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 100 - // Field (0) 'AttestedHeader' - if err = l.AttestedHeader.HashTreeRootWith(hh); err != nil { - return + // Field 0: Block + if c.Block == nil { + c.Block = new(BeaconBlockDeneb) } + dst = ssz.WriteOffset(dst, offset) + offset += c.Block.SizeSSZ() - // Field (1) 'SyncAggregate' - if err = l.SyncAggregate.HashTreeRootWith(hh); err != nil { - return + // Field 1: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.Signature...) - // Field (2) 'SignatureSlot' - ssz.PutUint(hh, l.SignatureSlot) - - hh.Merkleize(indx) - return + // Field 0: Block + if dst, err = c.Block.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Block: %w", err) + } + return dst, err } -// MarshalSSZ ssz marshals the LightClientHeaderDeneb object -func (l *LightClientHeaderDeneb) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(l) -} +func (c *SignedBeaconBlockDeneb) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 100 { + return ssz.ErrSize + } -// MarshalSSZTo ssz marshals the LightClientHeaderDeneb object to a target array -func (l *LightClientHeaderDeneb) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(244) + sszSlice1 := buf[4:100] // c.Signature - // Field (0) 'Beacon' - if l.Beacon == nil { - l.Beacon = new(BeaconBlockHeader) + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Block + if sszVarOffset0 != 100 { + return ssz.ErrInvalidVariableOffset } - if dst, err = l.Beacon.MarshalSSZTo(dst); err != nil { - return + if sszVarOffset0 > size { + return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:] // c.Block - // Offset (1) 'Execution' - dst = ssz.WriteOffset(dst, offset) - if l.Execution == nil { - l.Execution = new(v1.ExecutionPayloadHeaderDeneb) + // Field 0: Block + c.Block = new(BeaconBlockDeneb) + if err = c.Block.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Block: %w", err) } - offset += l.Execution.SizeSSZ() - // Field (2) 'ExecutionBranch' - if size := len(l.ExecutionBranch); size != 4 { - err = ssz.ErrVectorLengthFn("--.ExecutionBranch", size, 4) - return + // Field 1: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice1...) + return err +} + +func (c *SignedBeaconBlockDeneb) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - for ii := 0; ii < 4; ii++ { - if size := len(l.ExecutionBranch[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.ExecutionBranch[ii]", size, 32) - return - } - dst = append(dst, l.ExecutionBranch[ii]...) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} + +func (c *SignedBeaconBlockDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Block + if err := c.Block.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Block: %w", err) + } + // Field 1: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Signature) + hh.Merkleize(indx) + return nil +} + +func (c *SignedBlindedBeaconBlockDeneb) SizeSSZ() int { + size := 100 + if c.Message == nil { + c.Message = new(BlindedBeaconBlockDeneb) + } + size += c.Message.SizeSSZ() + return size +} + +func (c *SignedBlindedBeaconBlockDeneb) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} + +func (c *SignedBlindedBeaconBlockDeneb) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 100 + + // Field 0: Message + if c.Message == nil { + c.Message = new(BlindedBeaconBlockDeneb) } + dst = ssz.WriteOffset(dst, offset) + offset += c.Message.SizeSSZ() - // Field (1) 'Execution' - if dst, err = l.Execution.MarshalSSZTo(dst); err != nil { - return + // Field 1: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.Signature...) - return + // Field 0: Message + if dst, err = c.Message.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Message: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the LightClientHeaderDeneb object -func (l *LightClientHeaderDeneb) UnmarshalSSZ(buf []byte) error { +func (c *SignedBlindedBeaconBlockDeneb) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 244 { + if size < 100 { return ssz.ErrSize } - tail := buf - var o1 uint64 + sszSlice1 := buf[4:100] // c.Signature - // Field (0) 'Beacon' - if l.Beacon == nil { - l.Beacon = new(BeaconBlockHeader) + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Message + if sszVarOffset0 != 100 { + return ssz.ErrInvalidVariableOffset } - if err = l.Beacon.UnmarshalSSZ(buf[0:112]); err != nil { - return err + if sszVarOffset0 > size { + return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:] // c.Message - // Offset (1) 'Execution' - if o1 = ssz.ReadOffset(buf[112:116]); o1 > size { - return ssz.ErrOffset + // Field 0: Message + c.Message = new(BlindedBeaconBlockDeneb) + if err = c.Message.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Message: %w", err) } - if o1 != 244 { - return ssz.ErrInvalidVariableOffset + // Field 1: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice1...) + return err +} + +func (c *SignedBlindedBeaconBlockDeneb) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (2) 'ExecutionBranch' - l.ExecutionBranch = make([][]byte, 4) - for ii := 0; ii < 4; ii++ { - if cap(l.ExecutionBranch[ii]) == 0 { - l.ExecutionBranch[ii] = make([]byte, 0, len(buf[116:244][ii*32:(ii+1)*32])) - } - l.ExecutionBranch[ii] = append(l.ExecutionBranch[ii], buf[116:244][ii*32:(ii+1)*32]...) +func (c *SignedBlindedBeaconBlockDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Message + if err := c.Message.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Message: %w", err) + } + // Field 1: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength } + hh.PutBytes(c.Signature) + hh.Merkleize(indx) + return nil +} - // Field (1) 'Execution' - { - buf = tail[o1:] - if l.Execution == nil { - l.Execution = new(v1.ExecutionPayloadHeaderDeneb) - } - if err = l.Execution.UnmarshalSSZ(buf); err != nil { - return err - } +func (c *SignedBuilderBidDeneb) SizeSSZ() int { + size := 100 + if c.Message == nil { + c.Message = new(BuilderBidDeneb) } - return err + size += c.Message.SizeSSZ() + return size +} + +func (c *SignedBuilderBidDeneb) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// SizeSSZ returns the ssz encoded size in bytes for the LightClientHeaderDeneb object -func (l *LightClientHeaderDeneb) SizeSSZ() (size int) { - size = 244 +func (c *SignedBuilderBidDeneb) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 100 - // Field (1) 'Execution' - if l.Execution == nil { - l.Execution = new(v1.ExecutionPayloadHeaderDeneb) + // Field 0: Message + if c.Message == nil { + c.Message = new(BuilderBidDeneb) } - size += l.Execution.SizeSSZ() + dst = ssz.WriteOffset(dst, offset) + offset += c.Message.SizeSSZ() - return -} + // Field 1: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.Signature...) -// HashTreeRoot ssz hashes the LightClientHeaderDeneb object -func (l *LightClientHeaderDeneb) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(l) + // Field 0: Message + if dst, err = c.Message.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Message: %w", err) + } + return dst, err } -// HashTreeRootWith ssz hashes the LightClientHeaderDeneb object with a hasher -func (l *LightClientHeaderDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() +func (c *SignedBuilderBidDeneb) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 100 { + return ssz.ErrSize + } + + sszSlice1 := buf[4:100] // c.Signature - // Field (0) 'Beacon' - if err = l.Beacon.HashTreeRootWith(hh); err != nil { - return + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Message + if sszVarOffset0 != 100 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset0 > size { + return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:] // c.Message - // Field (1) 'Execution' - if err = l.Execution.HashTreeRootWith(hh); err != nil { - return + // Field 0: Message + c.Message = new(BuilderBidDeneb) + if err = c.Message.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Message: %w", err) } - // Field (2) 'ExecutionBranch' - { - if size := len(l.ExecutionBranch); size != 4 { - err = ssz.ErrVectorLengthFn("--.ExecutionBranch", size, 4) - return - } - subIndx := hh.Index() - for _, i := range l.ExecutionBranch { - if len(i) != 32 { - err = ssz.ErrBytesLength - return - } - hh.Append(i) - } - hh.Merkleize(subIndx) + // Field 1: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice1...) + return err +} + +func (c *SignedBuilderBidDeneb) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} +func (c *SignedBuilderBidDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Message + if err := c.Message.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Message: %w", err) + } + // Field 1: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Signature) hh.Merkleize(indx) - return + return nil } diff --git a/proto/prysm/v1alpha1/deneb.yaml b/proto/prysm/v1alpha1/deneb.yaml new file mode 100644 index 000000000000..3d980c56ed0d --- /dev/null +++ b/proto/prysm/v1alpha1/deneb.yaml @@ -0,0 +1,21 @@ +package: "github.com/OffchainLabs/prysm/v7/proto/prysm/v1alpha1" +types: + - name: "BeaconBlockBodyDeneb" + - name: "BeaconBlockContentsDeneb" + - name: "BeaconBlockDeneb" + - name: "BeaconStateDeneb" + - name: "BlindedBeaconBlockBodyDeneb" + - name: "BlindedBeaconBlockDeneb" + - name: "BlobIdentifier" + - name: "BlobSidecar" + - name: "BlobSidecars" + - name: "BuilderBidDeneb" + - name: "LightClientHeaderDeneb" + - name: "LightClientBootstrapDeneb" + - name: "LightClientUpdateDeneb" + - name: "LightClientFinalityUpdateDeneb" + - name: "LightClientOptimisticUpdateDeneb" + - name: "SignedBeaconBlockContentsDeneb" + - name: "SignedBeaconBlockDeneb" + - name: "SignedBlindedBeaconBlockDeneb" + - name: "SignedBuilderBidDeneb" diff --git a/proto/prysm/v1alpha1/electra.minimal.ssz.go b/proto/prysm/v1alpha1/electra.minimal.ssz.go index fcfd74d47442..2fccb269722c 100644 --- a/proto/prysm/v1alpha1/electra.minimal.ssz.go +++ b/proto/prysm/v1alpha1/electra.minimal.ssz.go @@ -1,5296 +1,5028 @@ //go:build minimal -// Code generated by fastssz. DO NOT EDIT. package eth import ( - github_com_OffchainLabs_prysm_v7_consensus_types_primitives "github.com/OffchainLabs/prysm/v7/consensus-types/primitives" + binary "encoding/binary" + "fmt" + go_bitfield "github.com/OffchainLabs/go-bitfield" + ssz "github.com/OffchainLabs/methodical-ssz/ssz" v1 "github.com/OffchainLabs/prysm/v7/proto/engine/v1" - ssz "github.com/prysmaticlabs/fastssz" ) -// MarshalSSZ ssz marshals the SignedAggregateAttestationAndProofElectra object -func (s *SignedAggregateAttestationAndProofElectra) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) +func (c *AggregateAttestationAndProofElectra) SizeSSZ() int { + size := 108 + if c.Aggregate == nil { + c.Aggregate = new(AttestationElectra) + } + size += c.Aggregate.SizeSSZ() + return size } -// MarshalSSZTo ssz marshals the SignedAggregateAttestationAndProofElectra object to a target array -func (s *SignedAggregateAttestationAndProofElectra) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(100) +func (c *AggregateAttestationAndProofElectra) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Offset (0) 'Message' - dst = ssz.WriteOffset(dst, offset) - if s.Message == nil { - s.Message = new(AggregateAttestationAndProofElectra) +func (c *AggregateAttestationAndProofElectra) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 108 + + // Field 0: AggregatorIndex + if dst, err = c.AggregatorIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("AggregatorIndex: %w", err) } - offset += s.Message.SizeSSZ() - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 1: Aggregate + if c.Aggregate == nil { + c.Aggregate = new(AttestationElectra) } - dst = append(dst, s.Signature...) + dst = ssz.WriteOffset(dst, offset) + offset += c.Aggregate.SizeSSZ() - // Field (0) 'Message' - if dst, err = s.Message.MarshalSSZTo(dst); err != nil { - return + // Field 2: SelectionProof + if len(c.SelectionProof) != 96 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.SelectionProof...) - return + // Field 1: Aggregate + if dst, err = c.Aggregate.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Aggregate: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the SignedAggregateAttestationAndProofElectra object -func (s *SignedAggregateAttestationAndProofElectra) UnmarshalSSZ(buf []byte) error { +func (c *AggregateAttestationAndProofElectra) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 100 { + if size < 108 { return ssz.ErrSize } - tail := buf - var o0 uint64 + sszSlice0 := buf[0:8] // c.AggregatorIndex + sszSlice2 := buf[12:108] // c.SelectionProof - // Offset (0) 'Message' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { + sszVarOffset1 := ssz.ReadOffset(buf[8:12]) // c.Aggregate + if sszVarOffset1 != 108 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset1 > size { return ssz.ErrOffset } + sszSlice1 := buf[sszVarOffset1:] // c.Aggregate - if o0 != 100 { - return ssz.ErrInvalidVariableOffset + // Field 0: AggregatorIndex + if err = c.AggregatorIndex.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("AggregatorIndex: %w", err) } - // Field (1) 'Signature' - if cap(s.Signature) == 0 { - s.Signature = make([]byte, 0, len(buf[4:100])) + // Field 1: Aggregate + c.Aggregate = new(AttestationElectra) + if err = c.Aggregate.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Aggregate: %w", err) } - s.Signature = append(s.Signature, buf[4:100]...) - // Field (0) 'Message' - { - buf = tail[o0:] - if s.Message == nil { - s.Message = new(AggregateAttestationAndProofElectra) - } - if err = s.Message.UnmarshalSSZ(buf); err != nil { - return err - } - } + // Field 2: SelectionProof + c.SelectionProof = make([]byte, 0, 96) + c.SelectionProof = append(c.SelectionProof, sszSlice2...) return err } -// SizeSSZ returns the ssz encoded size in bytes for the SignedAggregateAttestationAndProofElectra object -func (s *SignedAggregateAttestationAndProofElectra) SizeSSZ() (size int) { - size = 100 - - // Field (0) 'Message' - if s.Message == nil { - s.Message = new(AggregateAttestationAndProofElectra) +func (c *AggregateAttestationAndProofElectra) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - size += s.Message.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the SignedAggregateAttestationAndProofElectra object -func (s *SignedAggregateAttestationAndProofElectra) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the SignedAggregateAttestationAndProofElectra object with a hasher -func (s *SignedAggregateAttestationAndProofElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *AggregateAttestationAndProofElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Message' - if err = s.Message.HashTreeRootWith(hh); err != nil { - return + // Field 0: AggregatorIndex + if err := c.AggregatorIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("AggregatorIndex: %w", err) } - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 1: Aggregate + if err := c.Aggregate.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Aggregate: %w", err) } - hh.PutBytes(s.Signature) - + // Field 2: SelectionProof + if len(c.SelectionProof) != 96 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.SelectionProof) hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the AggregateAttestationAndProofElectra object -func (a *AggregateAttestationAndProofElectra) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(a) +func (c *AttestationElectra) SizeSSZ() int { + size := 229 + size += len(c.AggregationBits) + return size } -// MarshalSSZTo ssz marshals the AggregateAttestationAndProofElectra object to a target array -func (a *AggregateAttestationAndProofElectra) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(108) +func (c *AttestationElectra) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (0) 'AggregatorIndex' - dst = ssz.MarshalUint(dst, a.AggregatorIndex) +func (c *AttestationElectra) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 229 - // Offset (1) 'Aggregate' + // Field 0: AggregationBits dst = ssz.WriteOffset(dst, offset) - if a.Aggregate == nil { - a.Aggregate = new(AttestationElectra) + offset += len(c.AggregationBits) + + // Field 1: Data + if c.Data == nil { + c.Data = new(AttestationData) + } + if dst, err = c.Data.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Data: %w", err) } - offset += a.Aggregate.SizeSSZ() - // Field (2) 'SelectionProof' - if size := len(a.SelectionProof); size != 96 { - err = ssz.ErrBytesLengthFn("--.SelectionProof", size, 96) - return + // Field 2: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } - dst = append(dst, a.SelectionProof...) + dst = append(dst, c.Signature...) - // Field (1) 'Aggregate' - if dst, err = a.Aggregate.MarshalSSZTo(dst); err != nil { - return + // Field 3: CommitteeBits + if len([]byte(c.CommitteeBits)) != 1 { + return nil, ssz.ErrBytesLength } + dst = append(dst, []byte(c.CommitteeBits)...) - return + // Field 0: AggregationBits + if len(c.AggregationBits) > 8192 { + return nil, ssz.ErrListTooBig + } + dst = append(dst, c.AggregationBits...) + return dst, err } -// UnmarshalSSZ ssz unmarshals the AggregateAttestationAndProofElectra object -func (a *AggregateAttestationAndProofElectra) UnmarshalSSZ(buf []byte) error { +func (c *AttestationElectra) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 108 { + if size < 229 { return ssz.ErrSize } - tail := buf - var o1 uint64 - - // Field (0) 'AggregatorIndex' - a.AggregatorIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[0:8]) + sszSlice1 := buf[4:132] // c.Data + sszSlice2 := buf[132:228] // c.Signature + sszSlice3 := buf[228:229] // c.CommitteeBits - // Offset (1) 'Aggregate' - if o1 = ssz.ReadOffset(buf[8:12]); o1 > size { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.AggregationBits + if sszVarOffset0 != 229 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset0 > size { return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:] // c.AggregationBits - if o1 != 108 { - return ssz.ErrInvalidVariableOffset + // Field 0: AggregationBits + if err = ssz.ValidateBitlist(sszSlice0, 8192); err != nil { + return fmt.Errorf("AggregationBits: %w", err) } + c.AggregationBits = append([]byte{}, go_bitfield.Bitlist(sszSlice0)...) - // Field (2) 'SelectionProof' - if cap(a.SelectionProof) == 0 { - a.SelectionProof = make([]byte, 0, len(buf[12:108])) + // Field 1: Data + c.Data = new(AttestationData) + if err = c.Data.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Data: %w", err) } - a.SelectionProof = append(a.SelectionProof, buf[12:108]...) - // Field (1) 'Aggregate' - { - buf = tail[o1:] - if a.Aggregate == nil { - a.Aggregate = new(AttestationElectra) - } - if err = a.Aggregate.UnmarshalSSZ(buf); err != nil { - return err - } - } + // Field 2: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice2...) + + // Field 3: CommitteeBits + c.CommitteeBits = make([]byte, 0, 1) + c.CommitteeBits = append(c.CommitteeBits, go_bitfield.Bitvector4(sszSlice3)...) return err } -// SizeSSZ returns the ssz encoded size in bytes for the AggregateAttestationAndProofElectra object -func (a *AggregateAttestationAndProofElectra) SizeSSZ() (size int) { - size = 108 - - // Field (1) 'Aggregate' - if a.Aggregate == nil { - a.Aggregate = new(AttestationElectra) +func (c *AttestationElectra) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - size += a.Aggregate.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the AggregateAttestationAndProofElectra object -func (a *AggregateAttestationAndProofElectra) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(a) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the AggregateAttestationAndProofElectra object with a hasher -func (a *AggregateAttestationAndProofElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *AttestationElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'AggregatorIndex' - ssz.PutUint(hh, a.AggregatorIndex) - - // Field (1) 'Aggregate' - if err = a.Aggregate.HashTreeRootWith(hh); err != nil { - return + // Field 0: AggregationBits + if len(c.AggregationBits) == 0 { + return ssz.ErrEmptyBitlist } - - // Field (2) 'SelectionProof' - if size := len(a.SelectionProof); size != 96 { - err = ssz.ErrBytesLengthFn("--.SelectionProof", size, 96) - return + hh.PutBitlist(c.AggregationBits, 8192) + // Field 1: Data + if err := c.Data.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Data: %w", err) } - hh.PutBytes(a.SelectionProof) - + // Field 2: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Signature) + // Field 3: CommitteeBits + if len([]byte(c.CommitteeBits)) != 1 { + return ssz.ErrBytesLength + } + hh.PutBytes([]byte(c.CommitteeBits)) hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the AttestationElectra object -func (a *AttestationElectra) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(a) +func (c *AttesterSlashingElectra) SizeSSZ() int { + size := 8 + if c.Attestation_1 == nil { + c.Attestation_1 = new(IndexedAttestationElectra) + } + size += c.Attestation_1.SizeSSZ() + if c.Attestation_2 == nil { + c.Attestation_2 = new(IndexedAttestationElectra) + } + size += c.Attestation_2.SizeSSZ() + return size } -// MarshalSSZTo ssz marshals the AttestationElectra object to a target array -func (a *AttestationElectra) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(229) +func (c *AttesterSlashingElectra) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Offset (0) 'AggregationBits' - dst = ssz.WriteOffset(dst, offset) - offset += len(a.AggregationBits) +func (c *AttesterSlashingElectra) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 8 - // Field (1) 'Data' - if a.Data == nil { - a.Data = new(AttestationData) - } - if dst, err = a.Data.MarshalSSZTo(dst); err != nil { - return + // Field 0: Attestation_1 + if c.Attestation_1 == nil { + c.Attestation_1 = new(IndexedAttestationElectra) } + dst = ssz.WriteOffset(dst, offset) + offset += c.Attestation_1.SizeSSZ() - // Field (2) 'Signature' - if size := len(a.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 1: Attestation_2 + if c.Attestation_2 == nil { + c.Attestation_2 = new(IndexedAttestationElectra) } - dst = append(dst, a.Signature...) + dst = ssz.WriteOffset(dst, offset) + offset += c.Attestation_2.SizeSSZ() - // Field (3) 'CommitteeBits' - if size := len(a.CommitteeBits); size != 1 { - err = ssz.ErrBytesLengthFn("--.CommitteeBits", size, 1) - return + // Field 0: Attestation_1 + if dst, err = c.Attestation_1.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Attestation_1: %w", err) } - dst = append(dst, a.CommitteeBits...) - // Field (0) 'AggregationBits' - if size := len(a.AggregationBits); size > 8192 { - err = ssz.ErrBytesLengthFn("--.AggregationBits", size, 8192) - return + // Field 1: Attestation_2 + if dst, err = c.Attestation_2.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Attestation_2: %w", err) } - dst = append(dst, a.AggregationBits...) - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the AttestationElectra object -func (a *AttestationElectra) UnmarshalSSZ(buf []byte) error { +func (c *AttesterSlashingElectra) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 229 { + if size < 8 { 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 != 229 { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Attestation_1 + if sszVarOffset0 != 8 { 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 + if sszVarOffset0 > size { + return ssz.ErrOffset } - - // Field (2) 'Signature' - if cap(a.Signature) == 0 { - a.Signature = make([]byte, 0, len(buf[132:228])) + sszVarOffset1 := ssz.ReadOffset(buf[4:8]) // c.Attestation_2 + if sszVarOffset1 > size || sszVarOffset1 < sszVarOffset0 { + return ssz.ErrOffset } - a.Signature = append(a.Signature, buf[132:228]...) + sszSlice0 := buf[sszVarOffset0:sszVarOffset1] // c.Attestation_1 + sszSlice1 := buf[sszVarOffset1:] // c.Attestation_2 - // Field (3) 'CommitteeBits' - if cap(a.CommitteeBits) == 0 { - a.CommitteeBits = make([]byte, 0, len(buf[228:229])) + // Field 0: Attestation_1 + c.Attestation_1 = new(IndexedAttestationElectra) + if err = c.Attestation_1.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Attestation_1: %w", err) } - a.CommitteeBits = append(a.CommitteeBits, buf[228:229]...) - // Field (0) 'AggregationBits' - { - buf = tail[o0:] - if err = ssz.ValidateBitlist(buf, 8192); err != nil { - return err - } - if cap(a.AggregationBits) == 0 { - a.AggregationBits = make([]byte, 0, len(buf)) - } - a.AggregationBits = append(a.AggregationBits, buf...) + // Field 1: Attestation_2 + c.Attestation_2 = new(IndexedAttestationElectra) + if err = c.Attestation_2.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Attestation_2: %w", err) } return err } -// SizeSSZ returns the ssz encoded size in bytes for the AttestationElectra object -func (a *AttestationElectra) SizeSSZ() (size int) { - size = 229 - - // Field (0) 'AggregationBits' - size += len(a.AggregationBits) - - return -} - -// HashTreeRoot ssz hashes the AttestationElectra object -func (a *AttestationElectra) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(a) +func (c *AttesterSlashingElectra) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the AttestationElectra object with a hasher -func (a *AttestationElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *AttesterSlashingElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'AggregationBits' - if len(a.AggregationBits) == 0 { - err = ssz.ErrEmptyBitlist - return - } - hh.PutBitlist(a.AggregationBits, 8192) - - // Field (1) 'Data' - if err = a.Data.HashTreeRootWith(hh); err != nil { - return - } - - // Field (2) 'Signature' - if size := len(a.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 0: Attestation_1 + if err := c.Attestation_1.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Attestation_1: %w", err) } - hh.PutBytes(a.Signature) - - // Field (3) 'CommitteeBits' - if size := len(a.CommitteeBits); size != 1 { - err = ssz.ErrBytesLengthFn("--.CommitteeBits", size, 1) - return + // Field 1: Attestation_2 + if err := c.Attestation_2.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Attestation_2: %w", err) } - hh.PutBytes(a.CommitteeBits) - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the SingleAttestation object -func (s *SingleAttestation) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) + return nil } -// MarshalSSZTo ssz marshals the SingleAttestation object to a target array -func (s *SingleAttestation) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - - // Field (0) 'CommitteeId' - dst = ssz.MarshalUint(dst, s.CommitteeId) - - // Field (1) 'AttesterIndex' - dst = ssz.MarshalUint(dst, s.AttesterIndex) - - // Field (2) 'Data' - if s.Data == nil { - s.Data = new(AttestationData) +func (c *BeaconBlockBodyElectra) SizeSSZ() int { + size := 336 + size += len(c.ProposerSlashings) * 416 + for _, o := range c.AttesterSlashings { + size += 4 + size += o.SizeSSZ() + } + for _, o := range c.Attestations { + size += 4 + size += o.SizeSSZ() } - if dst, err = s.Data.MarshalSSZTo(dst); err != nil { - return + size += len(c.Deposits) * 1240 + size += len(c.VoluntaryExits) * 112 + if c.ExecutionPayload == nil { + c.ExecutionPayload = new(v1.ExecutionPayloadDeneb) } - - // Field (3) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + size += c.ExecutionPayload.SizeSSZ() + size += len(c.BlsToExecutionChanges) * 172 + size += len(c.BlobKzgCommitments) * 48 + if c.ExecutionRequests == nil { + c.ExecutionRequests = new(v1.ExecutionRequests) } - dst = append(dst, s.Signature...) + size += c.ExecutionRequests.SizeSSZ() + return size +} - return +func (c *BeaconBlockBodyElectra) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// UnmarshalSSZ ssz unmarshals the SingleAttestation object -func (s *SingleAttestation) UnmarshalSSZ(buf []byte) error { +func (c *BeaconBlockBodyElectra) MarshalSSZTo(dst []byte) ([]byte, error) { var err error - size := uint64(len(buf)) - if size != 240 { - return ssz.ErrSize - } - - // Field (0) 'CommitteeId' - s.CommitteeId = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.CommitteeIndex](buf[0:8]) + offset := 336 - // Field (1) 'AttesterIndex' - s.AttesterIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[8:16]) + // Field 0: RandaoReveal + if len(c.RandaoReveal) != 96 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.RandaoReveal...) - // Field (2) 'Data' - if s.Data == nil { - s.Data = new(AttestationData) + // Field 1: Eth1Data + if c.Eth1Data == nil { + c.Eth1Data = new(Eth1Data) } - if err = s.Data.UnmarshalSSZ(buf[16:144]); err != nil { - return err + if dst, err = c.Eth1Data.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Eth1Data: %w", err) } - // Field (3) 'Signature' - if cap(s.Signature) == 0 { - s.Signature = make([]byte, 0, len(buf[144:240])) + // Field 2: Graffiti + if len(c.Graffiti) != 32 { + return nil, ssz.ErrBytesLength } - s.Signature = append(s.Signature, buf[144:240]...) - - return err -} + dst = append(dst, c.Graffiti...) -// SizeSSZ returns the ssz encoded size in bytes for the SingleAttestation object -func (s *SingleAttestation) SizeSSZ() (size int) { - size = 240 - return -} + // Field 3: ProposerSlashings + dst = ssz.WriteOffset(dst, offset) + offset += len(c.ProposerSlashings) * 416 -// HashTreeRoot ssz hashes the SingleAttestation object -func (s *SingleAttestation) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) -} + // Field 4: AttesterSlashings + dst = ssz.WriteOffset(dst, offset) + for _, o := range c.AttesterSlashings { + offset += 4 + offset += o.SizeSSZ() + } -// HashTreeRootWith ssz hashes the SingleAttestation object with a hasher -func (s *SingleAttestation) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() + // Field 5: Attestations + dst = ssz.WriteOffset(dst, offset) + for _, o := range c.Attestations { + offset += 4 + offset += o.SizeSSZ() + } - // Field (0) 'CommitteeId' - ssz.PutUint(hh, s.CommitteeId) + // Field 6: Deposits + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Deposits) * 1240 - // Field (1) 'AttesterIndex' - ssz.PutUint(hh, s.AttesterIndex) + // Field 7: VoluntaryExits + dst = ssz.WriteOffset(dst, offset) + offset += len(c.VoluntaryExits) * 112 - // Field (2) 'Data' - if err = s.Data.HashTreeRootWith(hh); err != nil { - return + // Field 8: SyncAggregate + if c.SyncAggregate == nil { + c.SyncAggregate = new(SyncAggregate) } - - // Field (3) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + if dst, err = c.SyncAggregate.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SyncAggregate: %w", err) } - hh.PutBytes(s.Signature) - hh.Merkleize(indx) - return -} + // Field 9: ExecutionPayload + if c.ExecutionPayload == nil { + c.ExecutionPayload = new(v1.ExecutionPayloadDeneb) + } + dst = ssz.WriteOffset(dst, offset) + offset += c.ExecutionPayload.SizeSSZ() -// MarshalSSZ ssz marshals the BuilderBidElectra object -func (b *BuilderBidElectra) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} + // Field 10: BlsToExecutionChanges + dst = ssz.WriteOffset(dst, offset) + offset += len(c.BlsToExecutionChanges) * 172 -// MarshalSSZTo ssz marshals the BuilderBidElectra object to a target array -func (b *BuilderBidElectra) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(92) + // Field 11: BlobKzgCommitments + dst = ssz.WriteOffset(dst, offset) + offset += len(c.BlobKzgCommitments) * 48 - // Offset (0) 'Header' + // Field 12: ExecutionRequests + if c.ExecutionRequests == nil { + c.ExecutionRequests = new(v1.ExecutionRequests) + } dst = ssz.WriteOffset(dst, offset) - if b.Header == nil { - b.Header = new(v1.ExecutionPayloadHeaderDeneb) + offset += c.ExecutionRequests.SizeSSZ() + + // Field 3: ProposerSlashings + if len(c.ProposerSlashings) > 16 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.ProposerSlashings { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ProposerSlashings: %w", err) + } } - offset += b.Header.SizeSSZ() - // Offset (1) 'BlobKzgCommitments' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.BlobKzgCommitments) * 48 + // Field 4: AttesterSlashings + if len(c.AttesterSlashings) > 1 { + return nil, ssz.ErrListTooBig + } + { + offset = 4 * len(c.AttesterSlashings) + for _, o := range c.AttesterSlashings { + dst = ssz.WriteOffset(dst, offset) + offset += o.SizeSSZ() + } + } + for _, o := range c.AttesterSlashings { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("AttesterSlashings: %w", err) + } + } - // Offset (2) 'ExecutionRequests' - dst = ssz.WriteOffset(dst, offset) - if b.ExecutionRequests == nil { - b.ExecutionRequests = new(v1.ExecutionRequests) + // Field 5: Attestations + if len(c.Attestations) > 8 { + return nil, ssz.ErrListTooBig + } + { + offset = 4 * len(c.Attestations) + for _, o := range c.Attestations { + dst = ssz.WriteOffset(dst, offset) + offset += o.SizeSSZ() + } + } + for _, o := range c.Attestations { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Attestations: %w", err) + } } - offset += b.ExecutionRequests.SizeSSZ() - // Field (3) 'Value' - if size := len(b.Value); size != 32 { - err = ssz.ErrBytesLengthFn("--.Value", size, 32) - return + // Field 6: Deposits + if len(c.Deposits) > 16 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.Deposits { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Deposits: %w", err) + } } - dst = append(dst, b.Value...) - // Field (4) 'Pubkey' - if size := len(b.Pubkey); size != 48 { - err = ssz.ErrBytesLengthFn("--.Pubkey", size, 48) - return + // Field 7: VoluntaryExits + if len(c.VoluntaryExits) > 16 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.VoluntaryExits { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("VoluntaryExits: %w", err) + } } - dst = append(dst, b.Pubkey...) - // Field (0) 'Header' - if dst, err = b.Header.MarshalSSZTo(dst); err != nil { - return + // Field 9: ExecutionPayload + if dst, err = c.ExecutionPayload.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ExecutionPayload: %w", err) } - // Field (1) 'BlobKzgCommitments' - if size := len(b.BlobKzgCommitments); size > 4096 { - err = ssz.ErrListTooBigFn("--.BlobKzgCommitments", size, 4096) - return + // Field 10: BlsToExecutionChanges + if len(c.BlsToExecutionChanges) > 16 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.BlobKzgCommitments); ii++ { - if size := len(b.BlobKzgCommitments[ii]); size != 48 { - err = ssz.ErrBytesLengthFn("--.BlobKzgCommitments[ii]", size, 48) - return + for _, o := range c.BlsToExecutionChanges { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("BlsToExecutionChanges: %w", err) } - dst = append(dst, b.BlobKzgCommitments[ii]...) } - // Field (2) 'ExecutionRequests' - if dst, err = b.ExecutionRequests.MarshalSSZTo(dst); err != nil { - return + // Field 11: BlobKzgCommitments + if len(c.BlobKzgCommitments) > 4096 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.BlobKzgCommitments { + if len(o) != 48 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) } - return + // Field 12: ExecutionRequests + if dst, err = c.ExecutionRequests.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ExecutionRequests: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the BuilderBidElectra object -func (b *BuilderBidElectra) UnmarshalSSZ(buf []byte) error { +func (c *BeaconBlockBodyElectra) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 92 { + if size < 336 { return ssz.ErrSize } - tail := buf - var o0, o1, o2 uint64 + sszSlice0 := buf[0:96] // c.RandaoReveal + sszSlice1 := buf[96:168] // c.Eth1Data + sszSlice2 := buf[168:200] // c.Graffiti + sszSlice8 := buf[220:320] // c.SyncAggregate - // Offset (0) 'Header' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { + sszVarOffset3 := ssz.ReadOffset(buf[200:204]) // c.ProposerSlashings + if sszVarOffset3 != 336 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset3 > size { return ssz.ErrOffset } - - if o0 != 92 { - return ssz.ErrInvalidVariableOffset + sszVarOffset4 := ssz.ReadOffset(buf[204:208]) // c.AttesterSlashings + if sszVarOffset4 > size || sszVarOffset4 < sszVarOffset3 { + return ssz.ErrOffset } - - // Offset (1) 'BlobKzgCommitments' - if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 { + sszVarOffset5 := ssz.ReadOffset(buf[208:212]) // c.Attestations + if sszVarOffset5 > size || sszVarOffset5 < sszVarOffset4 { return ssz.ErrOffset } - - // Offset (2) 'ExecutionRequests' - if o2 = ssz.ReadOffset(buf[8:12]); o2 > size || o1 > o2 { + sszVarOffset6 := ssz.ReadOffset(buf[212:216]) // c.Deposits + if sszVarOffset6 > size || sszVarOffset6 < sszVarOffset5 { return ssz.ErrOffset } - - // Field (3) 'Value' - if cap(b.Value) == 0 { - b.Value = make([]byte, 0, len(buf[12:44])) + sszVarOffset7 := ssz.ReadOffset(buf[216:220]) // c.VoluntaryExits + if sszVarOffset7 > size || sszVarOffset7 < sszVarOffset6 { + return ssz.ErrOffset + } + sszVarOffset9 := ssz.ReadOffset(buf[320:324]) // c.ExecutionPayload + if sszVarOffset9 > size || sszVarOffset9 < sszVarOffset7 { + return ssz.ErrOffset + } + sszVarOffset10 := ssz.ReadOffset(buf[324:328]) // c.BlsToExecutionChanges + if sszVarOffset10 > size || sszVarOffset10 < sszVarOffset9 { + return ssz.ErrOffset + } + sszVarOffset11 := ssz.ReadOffset(buf[328:332]) // c.BlobKzgCommitments + if sszVarOffset11 > size || sszVarOffset11 < sszVarOffset10 { + return ssz.ErrOffset + } + sszVarOffset12 := ssz.ReadOffset(buf[332:336]) // c.ExecutionRequests + if sszVarOffset12 > size || sszVarOffset12 < sszVarOffset11 { + return ssz.ErrOffset } - b.Value = append(b.Value, buf[12:44]...) + sszSlice3 := buf[sszVarOffset3:sszVarOffset4] // c.ProposerSlashings + sszSlice4 := buf[sszVarOffset4:sszVarOffset5] // c.AttesterSlashings + sszSlice5 := buf[sszVarOffset5:sszVarOffset6] // c.Attestations + sszSlice6 := buf[sszVarOffset6:sszVarOffset7] // c.Deposits + sszSlice7 := buf[sszVarOffset7:sszVarOffset9] // c.VoluntaryExits + sszSlice9 := buf[sszVarOffset9:sszVarOffset10] // c.ExecutionPayload + sszSlice10 := buf[sszVarOffset10:sszVarOffset11] // c.BlsToExecutionChanges + sszSlice11 := buf[sszVarOffset11:sszVarOffset12] // c.BlobKzgCommitments + sszSlice12 := buf[sszVarOffset12:] // c.ExecutionRequests + + // Field 0: RandaoReveal + c.RandaoReveal = make([]byte, 0, 96) + c.RandaoReveal = append(c.RandaoReveal, sszSlice0...) - // Field (4) 'Pubkey' - if cap(b.Pubkey) == 0 { - b.Pubkey = make([]byte, 0, len(buf[44:92])) + // Field 1: Eth1Data + c.Eth1Data = new(Eth1Data) + if err = c.Eth1Data.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Eth1Data: %w", err) } - b.Pubkey = append(b.Pubkey, buf[44:92]...) - // Field (0) 'Header' + // Field 2: Graffiti + c.Graffiti = make([]byte, 0, 32) + c.Graffiti = append(c.Graffiti, sszSlice2...) + + // Field 3: ProposerSlashings { - buf = tail[o0:o1] - if b.Header == nil { - b.Header = new(v1.ExecutionPayloadHeaderDeneb) - } - if err = b.Header.UnmarshalSSZ(buf); err != nil { - return err + if len(sszSlice3)%416 != 0 { + return fmt.Errorf("misaligned bytes: c.ProposerSlashings length is %d, which is not a multiple of 416: %w", len(sszSlice3), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice3) / 416 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.ProposerSlashings has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.ProposerSlashings = make([]*ProposerSlashing, numElem) + for i := 0; i < numElem; i++ { + var tmp *ProposerSlashing + tmp = new(ProposerSlashing) + tmpSlice := sszSlice3[i*416 : (1+i)*416] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("ProposerSlashings: %w", err) + } + c.ProposerSlashings[i] = tmp } } - // Field (1) 'BlobKzgCommitments' + // Field 4: AttesterSlashings { - buf = tail[o1:o2] - num, err := ssz.DivideInt2(len(buf), 48, 4096) - if err != nil { - return err - } - b.BlobKzgCommitments = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(b.BlobKzgCommitments[ii]) == 0 { - b.BlobKzgCommitments[ii] = make([]byte, 0, len(buf[ii*48:(ii+1)*48])) + // empty lists are zero length, so make sure there is room for an offset + // before attempting to unmarshal it + if len(sszSlice4) > 3 { + startOffset := ssz.ReadOffset(sszSlice4[0:4]) + if startOffset == 0 { + return fmt.Errorf("encountered invalid offset of 0 when decoding c.AttesterSlashings") + } + if startOffset%4 != 0 { + return fmt.Errorf("misaligned list bytes: when decoding c.AttesterSlashings, end-of-list offset is %d, which is not a multiple of 4 (offset size)", startOffset) + } + listLen := startOffset / 4 + if listLen > 1 { + return fmt.Errorf("ssz-max exceeded: c.AttesterSlashings has %d elements, ssz-max is 1: %w", listLen, ssz.ErrListTooBig) + } + totalVarBytes := uint64(len(sszSlice4)) + if totalVarBytes < startOffset { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.AttesterSlashings") } - b.BlobKzgCommitments[ii] = append(b.BlobKzgCommitments[ii], buf[ii*48:(ii+1)*48]...) + c.AttesterSlashings = make([]*AttesterSlashingElectra, listLen) + var tmpSlice []byte + for i := uint64(0); i < listLen; i++ { + var tmp *AttesterSlashingElectra + tmp = new(AttesterSlashingElectra) + endOffset := totalVarBytes + if i+1 != listLen { + endOffset = ssz.ReadOffset(sszSlice4[(i+1)*4 : (i+2)*4]) + if totalVarBytes < endOffset { + return fmt.Errorf("offset %d points past the end of buffer when decoding c.AttesterSlashings", endOffset) + } + } + if endOffset < startOffset { + return fmt.Errorf("offset %d is not greater than start offset %d when decoding c.AttesterSlashings", endOffset, startOffset) + } + tmpSlice = sszSlice4[startOffset:endOffset] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("AttesterSlashings: %w", err) + } + c.AttesterSlashings[i] = tmp + startOffset = endOffset + } + } else { + if len(sszSlice4) > 0 { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.AttesterSlashings") + } + c.AttesterSlashings = make([]*AttesterSlashingElectra, 0) } } - // Field (2) 'ExecutionRequests' + // Field 5: Attestations { - buf = tail[o2:] - if b.ExecutionRequests == nil { - b.ExecutionRequests = new(v1.ExecutionRequests) - } - if err = b.ExecutionRequests.UnmarshalSSZ(buf); err != nil { - return err + // empty lists are zero length, so make sure there is room for an offset + // before attempting to unmarshal it + if len(sszSlice5) > 3 { + startOffset := ssz.ReadOffset(sszSlice5[0:4]) + if startOffset == 0 { + return fmt.Errorf("encountered invalid offset of 0 when decoding c.Attestations") + } + if startOffset%4 != 0 { + return fmt.Errorf("misaligned list bytes: when decoding c.Attestations, end-of-list offset is %d, which is not a multiple of 4 (offset size)", startOffset) + } + listLen := startOffset / 4 + if listLen > 8 { + return fmt.Errorf("ssz-max exceeded: c.Attestations has %d elements, ssz-max is 8: %w", listLen, ssz.ErrListTooBig) + } + totalVarBytes := uint64(len(sszSlice5)) + if totalVarBytes < startOffset { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.Attestations") + } + c.Attestations = make([]*AttestationElectra, listLen) + var tmpSlice []byte + for i := uint64(0); i < listLen; i++ { + var tmp *AttestationElectra + tmp = new(AttestationElectra) + endOffset := totalVarBytes + if i+1 != listLen { + endOffset = ssz.ReadOffset(sszSlice5[(i+1)*4 : (i+2)*4]) + if totalVarBytes < endOffset { + return fmt.Errorf("offset %d points past the end of buffer when decoding c.Attestations", endOffset) + } + } + if endOffset < startOffset { + return fmt.Errorf("offset %d is not greater than start offset %d when decoding c.Attestations", endOffset, startOffset) + } + tmpSlice = sszSlice5[startOffset:endOffset] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Attestations: %w", err) + } + c.Attestations[i] = tmp + startOffset = endOffset + } + } else { + if len(sszSlice5) > 0 { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.Attestations") + } + c.Attestations = make([]*AttestationElectra, 0) } } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the BuilderBidElectra object -func (b *BuilderBidElectra) SizeSSZ() (size int) { - size = 92 - // Field (0) 'Header' - if b.Header == nil { - b.Header = new(v1.ExecutionPayloadHeaderDeneb) + // Field 6: Deposits + { + if len(sszSlice6)%1240 != 0 { + return fmt.Errorf("misaligned bytes: c.Deposits length is %d, which is not a multiple of 1240: %w", len(sszSlice6), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice6) / 1240 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.Deposits has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.Deposits = make([]*Deposit, numElem) + for i := 0; i < numElem; i++ { + var tmp *Deposit + tmp = new(Deposit) + tmpSlice := sszSlice6[i*1240 : (1+i)*1240] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Deposits: %w", err) + } + c.Deposits[i] = tmp + } } - size += b.Header.SizeSSZ() - - // Field (1) 'BlobKzgCommitments' - size += len(b.BlobKzgCommitments) * 48 - // Field (2) 'ExecutionRequests' - if b.ExecutionRequests == nil { - b.ExecutionRequests = new(v1.ExecutionRequests) + // Field 7: VoluntaryExits + { + if len(sszSlice7)%112 != 0 { + return fmt.Errorf("misaligned bytes: c.VoluntaryExits length is %d, which is not a multiple of 112: %w", len(sszSlice7), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice7) / 112 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.VoluntaryExits has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.VoluntaryExits = make([]*SignedVoluntaryExit, numElem) + for i := 0; i < numElem; i++ { + var tmp *SignedVoluntaryExit + tmp = new(SignedVoluntaryExit) + tmpSlice := sszSlice7[i*112 : (1+i)*112] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("VoluntaryExits: %w", err) + } + c.VoluntaryExits[i] = tmp + } } - size += b.ExecutionRequests.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the BuilderBidElectra object -func (b *BuilderBidElectra) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) -} -// HashTreeRootWith ssz hashes the BuilderBidElectra object with a hasher -func (b *BuilderBidElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() + // Field 8: SyncAggregate + c.SyncAggregate = new(SyncAggregate) + if err = c.SyncAggregate.UnmarshalSSZ(sszSlice8); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) + } - // Field (0) 'Header' - if err = b.Header.HashTreeRootWith(hh); err != nil { - return + // Field 9: ExecutionPayload + c.ExecutionPayload = new(v1.ExecutionPayloadDeneb) + if err = c.ExecutionPayload.UnmarshalSSZ(sszSlice9); err != nil { + return fmt.Errorf("ExecutionPayload: %w", err) } - // Field (1) 'BlobKzgCommitments' + // Field 10: BlsToExecutionChanges { - if size := len(b.BlobKzgCommitments); size > 4096 { - err = ssz.ErrListTooBigFn("--.BlobKzgCommitments", size, 4096) - return - } - subIndx := hh.Index() - for _, i := range b.BlobKzgCommitments { - if len(i) != 48 { - err = ssz.ErrBytesLength - return + if len(sszSlice10)%172 != 0 { + return fmt.Errorf("misaligned bytes: c.BlsToExecutionChanges length is %d, which is not a multiple of 172: %w", len(sszSlice10), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice10) / 172 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.BlsToExecutionChanges has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.BlsToExecutionChanges = make([]*SignedBLSToExecutionChange, numElem) + for i := 0; i < numElem; i++ { + var tmp *SignedBLSToExecutionChange + tmp = new(SignedBLSToExecutionChange) + tmpSlice := sszSlice10[i*172 : (1+i)*172] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("BlsToExecutionChanges: %w", err) } - hh.PutBytes(i) + c.BlsToExecutionChanges[i] = tmp } - - numItems := uint64(len(b.BlobKzgCommitments)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) } - // Field (2) 'ExecutionRequests' - if err = b.ExecutionRequests.HashTreeRootWith(hh); err != nil { - return - } + // Field 11: BlobKzgCommitments + { + if len(sszSlice11)%48 != 0 { + return fmt.Errorf("misaligned bytes: c.BlobKzgCommitments length is %d, which is not a multiple of 48: %w", len(sszSlice11), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice11) / 48 + if numElem > 4096 { + return fmt.Errorf("ssz-max exceeded: c.BlobKzgCommitments has %d elements, ssz-max is 4096: %w", numElem, ssz.ErrListTooBig) + } + c.BlobKzgCommitments = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte - // Field (3) 'Value' - if size := len(b.Value); size != 32 { - err = ssz.ErrBytesLengthFn("--.Value", size, 32) - return + tmpSlice := sszSlice11[i*48 : (1+i)*48] + tmp = make([]byte, 0, 48) + tmp = append(tmp, tmpSlice...) + c.BlobKzgCommitments[i] = tmp + } } - hh.PutBytes(b.Value) - // Field (4) 'Pubkey' - if size := len(b.Pubkey); size != 48 { - err = ssz.ErrBytesLengthFn("--.Pubkey", size, 48) - return + // Field 12: ExecutionRequests + c.ExecutionRequests = new(v1.ExecutionRequests) + if err = c.ExecutionRequests.UnmarshalSSZ(sszSlice12); err != nil { + return fmt.Errorf("ExecutionRequests: %w", err) } - hh.PutBytes(b.Pubkey) - - hh.Merkleize(indx) - return + return err } -// MarshalSSZ ssz marshals the SignedBuilderBidElectra object -func (s *SignedBuilderBidElectra) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) +func (c *BeaconBlockBodyElectra) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// MarshalSSZTo ssz marshals the SignedBuilderBidElectra object to a target array -func (s *SignedBuilderBidElectra) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(100) - - // Offset (0) 'Message' - dst = ssz.WriteOffset(dst, offset) - if s.Message == nil { - s.Message = new(BuilderBidElectra) +func (c *BeaconBlockBodyElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: RandaoReveal + if len(c.RandaoReveal) != 96 { + return ssz.ErrBytesLength } - offset += s.Message.SizeSSZ() - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + hh.PutBytes(c.RandaoReveal) + // Field 1: Eth1Data + if err := c.Eth1Data.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Eth1Data: %w", err) } - dst = append(dst, s.Signature...) - - // Field (0) 'Message' - if dst, err = s.Message.MarshalSSZTo(dst); err != nil { - return + // Field 2: Graffiti + if len(c.Graffiti) != 32 { + return ssz.ErrBytesLength } - - return -} - -// UnmarshalSSZ ssz unmarshals the SignedBuilderBidElectra object -func (s *SignedBuilderBidElectra) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 100 { - return ssz.ErrSize + hh.PutBytes(c.Graffiti) + // Field 3: ProposerSlashings + { + if len(c.ProposerSlashings) > 16 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.ProposerSlashings { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ProposerSlashings: %w", err) + } + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.ProposerSlashings)), 16) } - - tail := buf - var o0 uint64 - - // Offset (0) 'Message' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset + // Field 4: AttesterSlashings + { + if len(c.AttesterSlashings) > 1 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.AttesterSlashings { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("AttesterSlashings: %w", err) + } + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.AttesterSlashings)), 1) } - - if o0 != 100 { - return ssz.ErrInvalidVariableOffset + // Field 5: Attestations + { + if len(c.Attestations) > 8 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.Attestations { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Attestations: %w", err) + } + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Attestations)), 8) } - - // Field (1) 'Signature' - if cap(s.Signature) == 0 { - s.Signature = make([]byte, 0, len(buf[4:100])) + // Field 6: Deposits + { + if len(c.Deposits) > 16 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.Deposits { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Deposits: %w", err) + } + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Deposits)), 16) } - s.Signature = append(s.Signature, buf[4:100]...) - - // Field (0) 'Message' + // Field 7: VoluntaryExits { - buf = tail[o0:] - if s.Message == nil { - s.Message = new(BuilderBidElectra) + if len(c.VoluntaryExits) > 16 { + return ssz.ErrListTooBig } - if err = s.Message.UnmarshalSSZ(buf); err != nil { - return err + subIndx := hh.Index() + for _, o := range c.VoluntaryExits { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("VoluntaryExits: %w", err) + } } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.VoluntaryExits)), 16) } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the SignedBuilderBidElectra object -func (s *SignedBuilderBidElectra) SizeSSZ() (size int) { - size = 100 - - // Field (0) 'Message' - if s.Message == nil { - s.Message = new(BuilderBidElectra) + // Field 8: SyncAggregate + if err := c.SyncAggregate.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) } - size += s.Message.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the SignedBuilderBidElectra object -func (s *SignedBuilderBidElectra) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) -} - -// HashTreeRootWith ssz hashes the SignedBuilderBidElectra object with a hasher -func (s *SignedBuilderBidElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'Message' - if err = s.Message.HashTreeRootWith(hh); err != nil { - return + // Field 9: ExecutionPayload + if err := c.ExecutionPayload.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ExecutionPayload: %w", err) } - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 10: BlsToExecutionChanges + { + if len(c.BlsToExecutionChanges) > 16 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.BlsToExecutionChanges { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("BlsToExecutionChanges: %w", err) + } + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.BlsToExecutionChanges)), 16) + } + // Field 11: BlobKzgCommitments + { + if len(c.BlobKzgCommitments) > 4096 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.BlobKzgCommitments { + if len(o) != 48 { + return ssz.ErrBytesLength + } + hh.PutBytes(o) + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.BlobKzgCommitments)), 4096) + } + // Field 12: ExecutionRequests + if err := c.ExecutionRequests.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ExecutionRequests: %w", err) } - hh.PutBytes(s.Signature) - hh.Merkleize(indx) - return + return nil +} + +func (c *BeaconBlockContentsElectra) SizeSSZ() int { + size := 12 + if c.Block == nil { + c.Block = new(BeaconBlockElectra) + } + size += c.Block.SizeSSZ() + size += len(c.KzgProofs) * 48 + size += len(c.Blobs) * 131072 + return size } -// MarshalSSZ ssz marshals the SignedBeaconBlockContentsElectra object -func (s *SignedBeaconBlockContentsElectra) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) +func (c *BeaconBlockContentsElectra) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the SignedBeaconBlockContentsElectra object to a target array -func (s *SignedBeaconBlockContentsElectra) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(12) +func (c *BeaconBlockContentsElectra) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 12 - // Offset (0) 'Block' - dst = ssz.WriteOffset(dst, offset) - if s.Block == nil { - s.Block = new(SignedBeaconBlockElectra) + // Field 0: Block + if c.Block == nil { + c.Block = new(BeaconBlockElectra) } - offset += s.Block.SizeSSZ() + dst = ssz.WriteOffset(dst, offset) + offset += c.Block.SizeSSZ() - // Offset (1) 'KzgProofs' + // Field 1: KzgProofs dst = ssz.WriteOffset(dst, offset) - offset += len(s.KzgProofs) * 48 + offset += len(c.KzgProofs) * 48 - // Offset (2) 'Blobs' + // Field 2: Blobs dst = ssz.WriteOffset(dst, offset) - offset += len(s.Blobs) * 131072 + offset += len(c.Blobs) * 131072 - // Field (0) 'Block' - if dst, err = s.Block.MarshalSSZTo(dst); err != nil { - return + // Field 0: Block + if dst, err = c.Block.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Block: %w", err) } - // Field (1) 'KzgProofs' - if size := len(s.KzgProofs); size > 4096 { - err = ssz.ErrListTooBigFn("--.KzgProofs", size, 4096) - return + // Field 1: KzgProofs + if len(c.KzgProofs) > 4096 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(s.KzgProofs); ii++ { - if size := len(s.KzgProofs[ii]); size != 48 { - err = ssz.ErrBytesLengthFn("--.KzgProofs[ii]", size, 48) - return + for _, o := range c.KzgProofs { + if len(o) != 48 { + return nil, ssz.ErrBytesLength } - dst = append(dst, s.KzgProofs[ii]...) + dst = append(dst, o...) } - // Field (2) 'Blobs' - if size := len(s.Blobs); size > 4096 { - err = ssz.ErrListTooBigFn("--.Blobs", size, 4096) - return + // Field 2: Blobs + if len(c.Blobs) > 4096 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(s.Blobs); ii++ { - if size := len(s.Blobs[ii]); size != 131072 { - err = ssz.ErrBytesLengthFn("--.Blobs[ii]", size, 131072) - return + for _, o := range c.Blobs { + if len(o) != 131072 { + return nil, ssz.ErrBytesLength } - dst = append(dst, s.Blobs[ii]...) + dst = append(dst, o...) } - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the SignedBeaconBlockContentsElectra object -func (s *SignedBeaconBlockContentsElectra) UnmarshalSSZ(buf []byte) error { +func (c *BeaconBlockContentsElectra) 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) 'Block' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Block + if sszVarOffset0 != 12 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset0 > size { return ssz.ErrOffset } - - if o0 != 12 { - return ssz.ErrInvalidVariableOffset + sszVarOffset1 := ssz.ReadOffset(buf[4:8]) // c.KzgProofs + if sszVarOffset1 > size || sszVarOffset1 < sszVarOffset0 { + return ssz.ErrOffset } - - // Offset (1) 'KzgProofs' - if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 { + sszVarOffset2 := ssz.ReadOffset(buf[8:12]) // c.Blobs + if sszVarOffset2 > size || sszVarOffset2 < sszVarOffset1 { return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:sszVarOffset1] // c.Block + sszSlice1 := buf[sszVarOffset1:sszVarOffset2] // c.KzgProofs + sszSlice2 := buf[sszVarOffset2:] // c.Blobs - // Offset (2) 'Blobs' - if o2 = ssz.ReadOffset(buf[8:12]); o2 > size || o1 > o2 { - return ssz.ErrOffset + // Field 0: Block + c.Block = new(BeaconBlockElectra) + if err = c.Block.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Block: %w", err) } - // Field (0) 'Block' + // Field 1: KzgProofs { - buf = tail[o0:o1] - if s.Block == nil { - s.Block = new(SignedBeaconBlockElectra) + if len(sszSlice1)%48 != 0 { + return fmt.Errorf("misaligned bytes: c.KzgProofs length is %d, which is not a multiple of 48: %w", len(sszSlice1), ssz.ErrIncorrectListSize) } - if err = s.Block.UnmarshalSSZ(buf); err != nil { - return err + numElem := len(sszSlice1) / 48 + if numElem > 4096 { + return fmt.Errorf("ssz-max exceeded: c.KzgProofs has %d elements, ssz-max is 4096: %w", numElem, ssz.ErrListTooBig) } - } + c.KzgProofs = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte - // Field (1) 'KzgProofs' - { - buf = tail[o1:o2] - num, err := ssz.DivideInt2(len(buf), 48, 4096) - if err != nil { - return err - } - s.KzgProofs = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(s.KzgProofs[ii]) == 0 { - s.KzgProofs[ii] = make([]byte, 0, len(buf[ii*48:(ii+1)*48])) - } - s.KzgProofs[ii] = append(s.KzgProofs[ii], buf[ii*48:(ii+1)*48]...) + tmpSlice := sszSlice1[i*48 : (1+i)*48] + tmp = make([]byte, 0, 48) + tmp = append(tmp, tmpSlice...) + c.KzgProofs[i] = tmp } } - // Field (2) 'Blobs' + // Field 2: Blobs { - buf = tail[o2:] - num, err := ssz.DivideInt2(len(buf), 131072, 4096) - if err != nil { - return err - } - s.Blobs = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(s.Blobs[ii]) == 0 { - s.Blobs[ii] = make([]byte, 0, len(buf[ii*131072:(ii+1)*131072])) - } - s.Blobs[ii] = append(s.Blobs[ii], buf[ii*131072:(ii+1)*131072]...) + if len(sszSlice2)%131072 != 0 { + return fmt.Errorf("misaligned bytes: c.Blobs length is %d, which is not a multiple of 131072: %w", len(sszSlice2), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice2) / 131072 + if numElem > 4096 { + return fmt.Errorf("ssz-max exceeded: c.Blobs has %d elements, ssz-max is 4096: %w", numElem, ssz.ErrListTooBig) + } + c.Blobs = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte + + tmpSlice := sszSlice2[i*131072 : (1+i)*131072] + tmp = make([]byte, 0, 131072) + tmp = append(tmp, tmpSlice...) + c.Blobs[i] = tmp } } return err } -// SizeSSZ returns the ssz encoded size in bytes for the SignedBeaconBlockContentsElectra object -func (s *SignedBeaconBlockContentsElectra) SizeSSZ() (size int) { - size = 12 - - // Field (0) 'Block' - if s.Block == nil { - s.Block = new(SignedBeaconBlockElectra) +func (c *BeaconBlockContentsElectra) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - size += s.Block.SizeSSZ() - - // Field (1) 'KzgProofs' - size += len(s.KzgProofs) * 48 - - // Field (2) 'Blobs' - size += len(s.Blobs) * 131072 - - return -} - -// HashTreeRoot ssz hashes the SignedBeaconBlockContentsElectra object -func (s *SignedBeaconBlockContentsElectra) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the SignedBeaconBlockContentsElectra object with a hasher -func (s *SignedBeaconBlockContentsElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *BeaconBlockContentsElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Block' - if err = s.Block.HashTreeRootWith(hh); err != nil { - return + // Field 0: Block + if err := c.Block.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Block: %w", err) } - - // Field (1) 'KzgProofs' + // Field 1: KzgProofs { - if size := len(s.KzgProofs); size > 4096 { - err = ssz.ErrListTooBigFn("--.KzgProofs", size, 4096) - return + if len(c.KzgProofs) > 4096 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range s.KzgProofs { - if len(i) != 48 { - err = ssz.ErrBytesLength - return + for _, o := range c.KzgProofs { + if len(o) != 48 { + return ssz.ErrBytesLength } - hh.PutBytes(i) + hh.PutBytes(o) } - - numItems := uint64(len(s.KzgProofs)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.KzgProofs)), 4096) } - - // Field (2) 'Blobs' + // Field 2: Blobs { - if size := len(s.Blobs); size > 4096 { - err = ssz.ErrListTooBigFn("--.Blobs", size, 4096) - return + if len(c.Blobs) > 4096 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range s.Blobs { - if len(i) != 131072 { - err = ssz.ErrBytesLength - return + for _, o := range c.Blobs { + if len(o) != 131072 { + return ssz.ErrBytesLength } - hh.PutBytes(i) + hh.PutBytes(o) } - - numItems := uint64(len(s.Blobs)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Blobs)), 4096) } - hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the SignedBeaconBlockElectra object -func (s *SignedBeaconBlockElectra) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) +func (c *BeaconBlockElectra) SizeSSZ() int { + size := 84 + if c.Body == nil { + c.Body = new(BeaconBlockBodyElectra) + } + size += c.Body.SizeSSZ() + return size } -// MarshalSSZTo ssz marshals the SignedBeaconBlockElectra object to a target array -func (s *SignedBeaconBlockElectra) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(100) +func (c *BeaconBlockElectra) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Offset (0) 'Block' - dst = ssz.WriteOffset(dst, offset) - if s.Block == nil { - s.Block = new(BeaconBlockElectra) +func (c *BeaconBlockElectra) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 84 + + // Field 0: Slot + if dst, err = c.Slot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Slot: %w", err) + } + + // Field 1: ProposerIndex + if dst, err = c.ProposerIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ProposerIndex: %w", err) } - offset += s.Block.SizeSSZ() - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 2: ParentRoot + if len(c.ParentRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, s.Signature...) + dst = append(dst, c.ParentRoot...) - // Field (0) 'Block' - if dst, err = s.Block.MarshalSSZTo(dst); err != nil { - return + // Field 3: StateRoot + if len(c.StateRoot) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.StateRoot...) - return + // Field 4: Body + if c.Body == nil { + c.Body = new(BeaconBlockBodyElectra) + } + dst = ssz.WriteOffset(dst, offset) + offset += c.Body.SizeSSZ() + + // Field 4: Body + if dst, err = c.Body.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Body: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the SignedBeaconBlockElectra object -func (s *SignedBeaconBlockElectra) UnmarshalSSZ(buf []byte) error { +func (c *BeaconBlockElectra) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 100 { + if size < 84 { return ssz.ErrSize } - tail := buf - var o0 uint64 + sszSlice0 := buf[0:8] // c.Slot + sszSlice1 := buf[8:16] // c.ProposerIndex + sszSlice2 := buf[16:48] // c.ParentRoot + sszSlice3 := buf[48:80] // c.StateRoot - // Offset (0) 'Block' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { + sszVarOffset4 := ssz.ReadOffset(buf[80:84]) // c.Body + if sszVarOffset4 != 84 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset4 > size { return ssz.ErrOffset } + sszSlice4 := buf[sszVarOffset4:] // c.Body - if o0 != 100 { - return ssz.ErrInvalidVariableOffset + // Field 0: Slot + if err = c.Slot.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Slot: %w", err) } - // Field (1) 'Signature' - if cap(s.Signature) == 0 { - s.Signature = make([]byte, 0, len(buf[4:100])) + // Field 1: ProposerIndex + if err = c.ProposerIndex.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("ProposerIndex: %w", err) } - s.Signature = append(s.Signature, buf[4:100]...) - // Field (0) 'Block' - { - buf = tail[o0:] - if s.Block == nil { - s.Block = new(BeaconBlockElectra) - } - if err = s.Block.UnmarshalSSZ(buf); err != nil { - return err - } - } - return err -} + // Field 2: ParentRoot + c.ParentRoot = make([]byte, 0, 32) + c.ParentRoot = append(c.ParentRoot, sszSlice2...) -// SizeSSZ returns the ssz encoded size in bytes for the SignedBeaconBlockElectra object -func (s *SignedBeaconBlockElectra) SizeSSZ() (size int) { - size = 100 + // Field 3: StateRoot + c.StateRoot = make([]byte, 0, 32) + c.StateRoot = append(c.StateRoot, sszSlice3...) - // Field (0) 'Block' - if s.Block == nil { - s.Block = new(BeaconBlockElectra) + // Field 4: Body + c.Body = new(BeaconBlockBodyElectra) + if err = c.Body.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("Body: %w", err) } - size += s.Block.SizeSSZ() - - return + return err } -// HashTreeRoot ssz hashes the SignedBeaconBlockElectra object -func (s *SignedBeaconBlockElectra) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) +func (c *BeaconBlockElectra) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the SignedBeaconBlockElectra object with a hasher -func (s *SignedBeaconBlockElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *BeaconBlockElectra) HashTreeRootWith(hh *ssz.Hasher) (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("--.Signature", size, 96) - return + // Field 0: Slot + if err := c.Slot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Slot: %w", err) } - hh.PutBytes(s.Signature) - - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the BeaconBlockContentsElectra object -func (b *BeaconBlockContentsElectra) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} - -// MarshalSSZTo ssz marshals the BeaconBlockContentsElectra object to a target array -func (b *BeaconBlockContentsElectra) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(12) - - // Offset (0) 'Block' - dst = ssz.WriteOffset(dst, offset) - if b.Block == nil { - b.Block = new(BeaconBlockElectra) + // Field 1: ProposerIndex + if err := c.ProposerIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ProposerIndex: %w", err) } - offset += b.Block.SizeSSZ() - - // Offset (1) 'KzgProofs' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.KzgProofs) * 48 - - // Offset (2) 'Blobs' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.Blobs) * 131072 - - // Field (0) 'Block' - if dst, err = b.Block.MarshalSSZTo(dst); err != nil { - return + // Field 2: ParentRoot + if len(c.ParentRoot) != 32 { + return ssz.ErrBytesLength } - - // Field (1) 'KzgProofs' - if size := len(b.KzgProofs); size > 4096 { - err = ssz.ErrListTooBigFn("--.KzgProofs", size, 4096) - return + hh.PutBytes(c.ParentRoot) + // Field 3: StateRoot + if len(c.StateRoot) != 32 { + return ssz.ErrBytesLength } - for ii := 0; ii < len(b.KzgProofs); ii++ { - if size := len(b.KzgProofs[ii]); size != 48 { - err = ssz.ErrBytesLengthFn("--.KzgProofs[ii]", size, 48) - return - } - dst = append(dst, b.KzgProofs[ii]...) + hh.PutBytes(c.StateRoot) + // Field 4: Body + if err := c.Body.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Body: %w", err) } + hh.Merkleize(indx) + return nil +} - // Field (2) 'Blobs' - if size := len(b.Blobs); size > 4096 { - err = ssz.ErrListTooBigFn("--.Blobs", size, 4096) - return - } - for ii := 0; ii < len(b.Blobs); ii++ { - if size := len(b.Blobs[ii]); size != 131072 { - err = ssz.ErrBytesLengthFn("--.Blobs[ii]", size, 131072) - return - } - dst = append(dst, b.Blobs[ii]...) +func (c *BeaconStateElectra) SizeSSZ() int { + size := 10313 + size += len(c.HistoricalRoots) * 32 + size += len(c.Eth1DataVotes) * 72 + size += len(c.Validators) * 121 + size += len(c.Balances) * 8 + size += len(c.PreviousEpochParticipation) + size += len(c.CurrentEpochParticipation) + size += len(c.InactivityScores) * 8 + if c.LatestExecutionPayloadHeader == nil { + c.LatestExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderDeneb) } + size += c.LatestExecutionPayloadHeader.SizeSSZ() + size += len(c.HistoricalSummaries) * 64 + size += len(c.PendingDeposits) * 192 + size += len(c.PendingPartialWithdrawals) * 24 + size += len(c.PendingConsolidations) * 16 + return size +} - return +func (c *BeaconStateElectra) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// UnmarshalSSZ ssz unmarshals the BeaconBlockContentsElectra object -func (b *BeaconBlockContentsElectra) UnmarshalSSZ(buf []byte) error { +func (c *BeaconStateElectra) MarshalSSZTo(dst []byte) ([]byte, error) { var err error - size := uint64(len(buf)) - if size < 12 { - return ssz.ErrSize - } + offset := 10313 - tail := buf - var o0, o1, o2 uint64 + // Field 0: GenesisTime + dst = binary.LittleEndian.AppendUint64(dst, c.GenesisTime) - // Offset (0) 'Block' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset + // Field 1: GenesisValidatorsRoot + if len(c.GenesisValidatorsRoot) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.GenesisValidatorsRoot...) - if o0 != 12 { - return ssz.ErrInvalidVariableOffset + // Field 2: Slot + if dst, err = c.Slot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Slot: %w", err) } - // Offset (1) 'KzgProofs' - if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 { - return ssz.ErrOffset + // Field 3: Fork + if c.Fork == nil { + c.Fork = new(Fork) } - - // Offset (2) 'Blobs' - if o2 = ssz.ReadOffset(buf[8:12]); o2 > size || o1 > o2 { - return ssz.ErrOffset + if dst, err = c.Fork.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Fork: %w", err) } - // Field (0) 'Block' - { - buf = tail[o0:o1] - if b.Block == nil { - b.Block = new(BeaconBlockElectra) - } - if err = b.Block.UnmarshalSSZ(buf); err != nil { - return err - } + // Field 4: LatestBlockHeader + if c.LatestBlockHeader == nil { + c.LatestBlockHeader = new(BeaconBlockHeader) + } + if dst, err = c.LatestBlockHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("LatestBlockHeader: %w", err) } - // Field (1) 'KzgProofs' - { - buf = tail[o1:o2] - num, err := ssz.DivideInt2(len(buf), 48, 4096) - if err != nil { - return err - } - b.KzgProofs = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(b.KzgProofs[ii]) == 0 { - b.KzgProofs[ii] = make([]byte, 0, len(buf[ii*48:(ii+1)*48])) - } - b.KzgProofs[ii] = append(b.KzgProofs[ii], buf[ii*48:(ii+1)*48]...) + // Field 5: BlockRoots + if len(c.BlockRoots) != 64 { + return nil, ssz.ErrBytesLength + } + for _, o := range c.BlockRoots { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, o...) } - // Field (2) 'Blobs' - { - buf = tail[o2:] - num, err := ssz.DivideInt2(len(buf), 131072, 4096) - if err != nil { - return err - } - b.Blobs = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(b.Blobs[ii]) == 0 { - b.Blobs[ii] = make([]byte, 0, len(buf[ii*131072:(ii+1)*131072])) - } - b.Blobs[ii] = append(b.Blobs[ii], buf[ii*131072:(ii+1)*131072]...) + // Field 6: StateRoots + if len(c.StateRoots) != 64 { + return nil, ssz.ErrBytesLength + } + for _, o := range c.StateRoots { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, o...) } - return err -} -// SizeSSZ returns the ssz encoded size in bytes for the BeaconBlockContentsElectra object -func (b *BeaconBlockContentsElectra) SizeSSZ() (size int) { - size = 12 + // Field 7: HistoricalRoots + dst = ssz.WriteOffset(dst, offset) + offset += len(c.HistoricalRoots) * 32 - // Field (0) 'Block' - if b.Block == nil { - b.Block = new(BeaconBlockElectra) + // Field 8: Eth1Data + if c.Eth1Data == nil { + c.Eth1Data = new(Eth1Data) + } + if dst, err = c.Eth1Data.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Eth1Data: %w", err) } - size += b.Block.SizeSSZ() - - // Field (1) 'KzgProofs' - size += len(b.KzgProofs) * 48 - // Field (2) 'Blobs' - size += len(b.Blobs) * 131072 + // Field 9: Eth1DataVotes + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Eth1DataVotes) * 72 - return -} + // Field 10: Eth1DepositIndex + dst = binary.LittleEndian.AppendUint64(dst, c.Eth1DepositIndex) -// HashTreeRoot ssz hashes the BeaconBlockContentsElectra object -func (b *BeaconBlockContentsElectra) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) -} + // Field 11: Validators + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Validators) * 121 -// HashTreeRootWith ssz hashes the BeaconBlockContentsElectra object with a hasher -func (b *BeaconBlockContentsElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() + // Field 12: Balances + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Balances) * 8 - // Field (0) 'Block' - if err = b.Block.HashTreeRootWith(hh); err != nil { - return + // Field 13: RandaoMixes + if len(c.RandaoMixes) != 64 { + return nil, ssz.ErrBytesLength } - - // Field (1) 'KzgProofs' - { - if size := len(b.KzgProofs); size > 4096 { - err = ssz.ErrListTooBigFn("--.KzgProofs", size, 4096) - return - } - subIndx := hh.Index() - for _, i := range b.KzgProofs { - if len(i) != 48 { - err = ssz.ErrBytesLength - return - } - hh.PutBytes(i) + for _, o := range c.RandaoMixes { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } - - numItems := uint64(len(b.KzgProofs)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) + dst = append(dst, o...) } - // Field (2) 'Blobs' - { - if size := len(b.Blobs); size > 4096 { - err = ssz.ErrListTooBigFn("--.Blobs", size, 4096) - return - } - subIndx := hh.Index() - for _, i := range b.Blobs { - if len(i) != 131072 { - err = ssz.ErrBytesLength - return - } - hh.PutBytes(i) - } - - numItems := uint64(len(b.Blobs)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) + // Field 14: Slashings + if len(c.Slashings) != 64 { + return nil, ssz.ErrBytesLength } - - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the BeaconBlockElectra object -func (b *BeaconBlockElectra) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} - -// MarshalSSZTo ssz marshals the BeaconBlockElectra object to a target array -func (b *BeaconBlockElectra) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(84) - - // Field (0) 'Slot' - dst = ssz.MarshalUint(dst, b.Slot) - - // Field (1) 'ProposerIndex' - dst = ssz.MarshalUint(dst, b.ProposerIndex) - - // Field (2) 'ParentRoot' - if size := len(b.ParentRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentRoot", size, 32) - return + for _, o := range c.Slashings { + dst = binary.LittleEndian.AppendUint64(dst, o) } - dst = append(dst, b.ParentRoot...) - // Field (3) 'StateRoot' - if size := len(b.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return - } - dst = append(dst, b.StateRoot...) + // Field 15: PreviousEpochParticipation + dst = ssz.WriteOffset(dst, offset) + offset += len(c.PreviousEpochParticipation) - // Offset (4) 'Body' + // Field 16: CurrentEpochParticipation dst = ssz.WriteOffset(dst, offset) - if b.Body == nil { - b.Body = new(BeaconBlockBodyElectra) - } - offset += b.Body.SizeSSZ() + offset += len(c.CurrentEpochParticipation) - // Field (4) 'Body' - if dst, err = b.Body.MarshalSSZTo(dst); err != nil { - return + // Field 17: JustificationBits + if len([]byte(c.JustificationBits)) != 1 { + return nil, ssz.ErrBytesLength } + dst = append(dst, []byte(c.JustificationBits)...) - return -} - -// UnmarshalSSZ ssz unmarshals the BeaconBlockElectra object -func (b *BeaconBlockElectra) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 84 { - return ssz.ErrSize + // Field 18: PreviousJustifiedCheckpoint + if c.PreviousJustifiedCheckpoint == nil { + c.PreviousJustifiedCheckpoint = new(Checkpoint) } - - tail := buf - var o4 uint64 - - // Field (0) 'Slot' - b.Slot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[0:8]) - - // Field (1) 'ProposerIndex' - b.ProposerIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[8:16]) - - // Field (2) 'ParentRoot' - if cap(b.ParentRoot) == 0 { - b.ParentRoot = make([]byte, 0, len(buf[16:48])) + if dst, err = c.PreviousJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("PreviousJustifiedCheckpoint: %w", err) } - 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])) + // Field 19: CurrentJustifiedCheckpoint + if c.CurrentJustifiedCheckpoint == nil { + c.CurrentJustifiedCheckpoint = new(Checkpoint) } - b.StateRoot = append(b.StateRoot, buf[48:80]...) - - // Offset (4) 'Body' - if o4 = ssz.ReadOffset(buf[80:84]); o4 > size { - return ssz.ErrOffset + if dst, err = c.CurrentJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("CurrentJustifiedCheckpoint: %w", err) } - if o4 != 84 { - return ssz.ErrInvalidVariableOffset + // Field 20: FinalizedCheckpoint + if c.FinalizedCheckpoint == nil { + c.FinalizedCheckpoint = new(Checkpoint) } - - // Field (4) 'Body' - { - buf = tail[o4:] - if b.Body == nil { - b.Body = new(BeaconBlockBodyElectra) - } - if err = b.Body.UnmarshalSSZ(buf); err != nil { - return err - } + if dst, err = c.FinalizedCheckpoint.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("FinalizedCheckpoint: %w", err) } - return err -} -// SizeSSZ returns the ssz encoded size in bytes for the BeaconBlockElectra object -func (b *BeaconBlockElectra) SizeSSZ() (size int) { - size = 84 + // Field 21: InactivityScores + dst = ssz.WriteOffset(dst, offset) + offset += len(c.InactivityScores) * 8 - // Field (4) 'Body' - if b.Body == nil { - b.Body = new(BeaconBlockBodyElectra) + // Field 22: CurrentSyncCommittee + if c.CurrentSyncCommittee == nil { + c.CurrentSyncCommittee = new(SyncCommittee) } - size += b.Body.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the BeaconBlockElectra object -func (b *BeaconBlockElectra) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) -} - -// HashTreeRootWith ssz hashes the BeaconBlockElectra object with a hasher -func (b *BeaconBlockElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'Slot' - ssz.PutUint(hh, b.Slot) - - // Field (1) 'ProposerIndex' - ssz.PutUint(hh, b.ProposerIndex) - - // Field (2) 'ParentRoot' - if size := len(b.ParentRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentRoot", size, 32) - return + if dst, err = c.CurrentSyncCommittee.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("CurrentSyncCommittee: %w", err) } - hh.PutBytes(b.ParentRoot) - // Field (3) 'StateRoot' - if size := len(b.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return + // Field 23: NextSyncCommittee + if c.NextSyncCommittee == nil { + c.NextSyncCommittee = new(SyncCommittee) } - hh.PutBytes(b.StateRoot) - - // Field (4) 'Body' - if err = b.Body.HashTreeRootWith(hh); err != nil { - return + if dst, err = c.NextSyncCommittee.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("NextSyncCommittee: %w", err) } - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the BeaconBlockBodyElectra object -func (b *BeaconBlockBodyElectra) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} - -// MarshalSSZTo ssz marshals the BeaconBlockBodyElectra object to a target array -func (b *BeaconBlockBodyElectra) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(336) - - // Field (0) 'RandaoReveal' - if size := len(b.RandaoReveal); size != 96 { - err = ssz.ErrBytesLengthFn("--.RandaoReveal", size, 96) - return + // Field 24: LatestExecutionPayloadHeader + if c.LatestExecutionPayloadHeader == nil { + c.LatestExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderDeneb) } - dst = append(dst, b.RandaoReveal...) + dst = ssz.WriteOffset(dst, offset) + offset += c.LatestExecutionPayloadHeader.SizeSSZ() - // Field (1) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(Eth1Data) - } - if dst, err = b.Eth1Data.MarshalSSZTo(dst); err != nil { - return - } + // Field 25: NextWithdrawalIndex + dst = binary.LittleEndian.AppendUint64(dst, c.NextWithdrawalIndex) - // Field (2) 'Graffiti' - if size := len(b.Graffiti); size != 32 { - err = ssz.ErrBytesLengthFn("--.Graffiti", size, 32) - return + // Field 26: NextWithdrawalValidatorIndex + if dst, err = c.NextWithdrawalValidatorIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("NextWithdrawalValidatorIndex: %w", err) } - dst = append(dst, b.Graffiti...) - // Offset (3) 'ProposerSlashings' + // Field 27: HistoricalSummaries dst = ssz.WriteOffset(dst, offset) - offset += len(b.ProposerSlashings) * 416 + offset += len(c.HistoricalSummaries) * 64 - // Offset (4) 'AttesterSlashings' - dst = ssz.WriteOffset(dst, offset) - for ii := 0; ii < len(b.AttesterSlashings); ii++ { - offset += 4 - offset += b.AttesterSlashings[ii].SizeSSZ() - } + // Field 28: DepositRequestsStartIndex + dst = binary.LittleEndian.AppendUint64(dst, c.DepositRequestsStartIndex) - // Offset (5) 'Attestations' - dst = ssz.WriteOffset(dst, offset) - for ii := 0; ii < len(b.Attestations); ii++ { - offset += 4 - offset += b.Attestations[ii].SizeSSZ() + // Field 29: DepositBalanceToConsume + if dst, err = c.DepositBalanceToConsume.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("DepositBalanceToConsume: %w", err) } - // 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 30: ExitBalanceToConsume + if dst, err = c.ExitBalanceToConsume.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ExitBalanceToConsume: %w", err) + } - // Field (8) 'SyncAggregate' - if b.SyncAggregate == nil { - b.SyncAggregate = new(SyncAggregate) + // Field 31: EarliestExitEpoch + if dst, err = c.EarliestExitEpoch.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("EarliestExitEpoch: %w", err) } - if dst, err = b.SyncAggregate.MarshalSSZTo(dst); err != nil { - return + + // Field 32: ConsolidationBalanceToConsume + if dst, err = c.ConsolidationBalanceToConsume.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ConsolidationBalanceToConsume: %w", err) } - // Offset (9) 'ExecutionPayload' - dst = ssz.WriteOffset(dst, offset) - if b.ExecutionPayload == nil { - b.ExecutionPayload = new(v1.ExecutionPayloadDeneb) + // Field 33: EarliestConsolidationEpoch + if dst, err = c.EarliestConsolidationEpoch.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("EarliestConsolidationEpoch: %w", err) } - offset += b.ExecutionPayload.SizeSSZ() - // Offset (10) 'BlsToExecutionChanges' + // Field 34: PendingDeposits dst = ssz.WriteOffset(dst, offset) - offset += len(b.BlsToExecutionChanges) * 172 + offset += len(c.PendingDeposits) * 192 - // Offset (11) 'BlobKzgCommitments' + // Field 35: PendingPartialWithdrawals dst = ssz.WriteOffset(dst, offset) - offset += len(b.BlobKzgCommitments) * 48 + offset += len(c.PendingPartialWithdrawals) * 24 - // Offset (12) 'ExecutionRequests' + // Field 36: PendingConsolidations dst = ssz.WriteOffset(dst, offset) - if b.ExecutionRequests == nil { - b.ExecutionRequests = new(v1.ExecutionRequests) - } - offset += b.ExecutionRequests.SizeSSZ() + offset += len(c.PendingConsolidations) * 16 - // Field (3) 'ProposerSlashings' - if size := len(b.ProposerSlashings); size > 16 { - err = ssz.ErrListTooBigFn("--.ProposerSlashings", size, 16) - return + // Field 7: HistoricalRoots + if len(c.HistoricalRoots) > 16777216 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.ProposerSlashings); ii++ { - if dst, err = b.ProposerSlashings[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.HistoricalRoots { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, o...) } - // Field (4) 'AttesterSlashings' - if size := len(b.AttesterSlashings); size > 1 { - err = ssz.ErrListTooBigFn("--.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() - } + // Field 9: Eth1DataVotes + if len(c.Eth1DataVotes) > 32 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.AttesterSlashings); ii++ { - if dst, err = b.AttesterSlashings[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.Eth1DataVotes { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Eth1DataVotes: %w", err) } } - // Field (5) 'Attestations' - if size := len(b.Attestations); size > 8 { - err = ssz.ErrListTooBigFn("--.Attestations", size, 8) - return + // Field 11: Validators + if len(c.Validators) > 1099511627776 { + return nil, ssz.ErrListTooBig } - { - offset = 4 * len(b.Attestations) - for ii := 0; ii < len(b.Attestations); ii++ { - dst = ssz.WriteOffset(dst, offset) - offset += b.Attestations[ii].SizeSSZ() + for _, o := range c.Validators { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Validators: %w", err) } } - for ii := 0; ii < len(b.Attestations); ii++ { - if dst, err = b.Attestations[ii].MarshalSSZTo(dst); err != nil { - return - } + + // Field 12: Balances + if len(c.Balances) > 1099511627776 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.Balances { + dst = binary.LittleEndian.AppendUint64(dst, o) } - // Field (6) 'Deposits' - if size := len(b.Deposits); size > 16 { - err = ssz.ErrListTooBigFn("--.Deposits", size, 16) - return + // Field 15: PreviousEpochParticipation + if len(c.PreviousEpochParticipation) > 1099511627776 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.Deposits); ii++ { - if dst, err = b.Deposits[ii].MarshalSSZTo(dst); err != nil { - return - } + dst = append(dst, c.PreviousEpochParticipation...) + + // Field 16: CurrentEpochParticipation + if len(c.CurrentEpochParticipation) > 1099511627776 { + return nil, ssz.ErrListTooBig } + dst = append(dst, c.CurrentEpochParticipation...) - // Field (7) 'VoluntaryExits' - if size := len(b.VoluntaryExits); size > 16 { - err = ssz.ErrListTooBigFn("--.VoluntaryExits", size, 16) - return + // Field 21: InactivityScores + if len(c.InactivityScores) > 1099511627776 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.VoluntaryExits); ii++ { - if dst, err = b.VoluntaryExits[ii].MarshalSSZTo(dst); err != nil { - return - } + for _, o := range c.InactivityScores { + dst = binary.LittleEndian.AppendUint64(dst, o) } - // Field (9) 'ExecutionPayload' - if dst, err = b.ExecutionPayload.MarshalSSZTo(dst); err != nil { - return + // Field 24: LatestExecutionPayloadHeader + if dst, err = c.LatestExecutionPayloadHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("LatestExecutionPayloadHeader: %w", err) } - // Field (10) 'BlsToExecutionChanges' - if size := len(b.BlsToExecutionChanges); size > 16 { - err = ssz.ErrListTooBigFn("--.BlsToExecutionChanges", size, 16) - return + // Field 27: HistoricalSummaries + if len(c.HistoricalSummaries) > 16777216 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.BlsToExecutionChanges); ii++ { - if dst, err = b.BlsToExecutionChanges[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.HistoricalSummaries { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("HistoricalSummaries: %w", err) } } - // Field (11) 'BlobKzgCommitments' - if size := len(b.BlobKzgCommitments); size > 4096 { - err = ssz.ErrListTooBigFn("--.BlobKzgCommitments", size, 4096) - return + // Field 34: PendingDeposits + if len(c.PendingDeposits) > 134217728 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.BlobKzgCommitments); ii++ { - if size := len(b.BlobKzgCommitments[ii]); size != 48 { - err = ssz.ErrBytesLengthFn("--.BlobKzgCommitments[ii]", size, 48) - return + for _, o := range c.PendingDeposits { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("PendingDeposits: %w", err) } - dst = append(dst, b.BlobKzgCommitments[ii]...) } - // Field (12) 'ExecutionRequests' - if dst, err = b.ExecutionRequests.MarshalSSZTo(dst); err != nil { - return + // Field 35: PendingPartialWithdrawals + if len(c.PendingPartialWithdrawals) > 64 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.PendingPartialWithdrawals { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("PendingPartialWithdrawals: %w", err) + } } - return + // Field 36: PendingConsolidations + if len(c.PendingConsolidations) > 64 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.PendingConsolidations { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("PendingConsolidations: %w", err) + } + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the BeaconBlockBodyElectra object -func (b *BeaconBlockBodyElectra) UnmarshalSSZ(buf []byte) error { +func (c *BeaconStateElectra) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 336 { + if size < 10313 { 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])) + sszSlice0 := buf[0:8] // c.GenesisTime + sszSlice1 := buf[8:40] // c.GenesisValidatorsRoot + sszSlice2 := buf[40:48] // c.Slot + sszSlice3 := buf[48:64] // c.Fork + sszSlice4 := buf[64:176] // c.LatestBlockHeader + sszSlice5 := buf[176:2224] // c.BlockRoots + sszSlice6 := buf[2224:4272] // c.StateRoots + sszSlice8 := buf[4276:4348] // c.Eth1Data + sszSlice10 := buf[4352:4360] // c.Eth1DepositIndex + sszSlice13 := buf[4368:6416] // c.RandaoMixes + sszSlice14 := buf[6416:6928] // c.Slashings + sszSlice17 := buf[6936:6937] // c.JustificationBits + sszSlice18 := buf[6937:6977] // c.PreviousJustifiedCheckpoint + sszSlice19 := buf[6977:7017] // c.CurrentJustifiedCheckpoint + sszSlice20 := buf[7017:7057] // c.FinalizedCheckpoint + sszSlice22 := buf[7061:8645] // c.CurrentSyncCommittee + sszSlice23 := buf[8645:10229] // c.NextSyncCommittee + sszSlice25 := buf[10233:10241] // c.NextWithdrawalIndex + sszSlice26 := buf[10241:10249] // c.NextWithdrawalValidatorIndex + sszSlice28 := buf[10253:10261] // c.DepositRequestsStartIndex + sszSlice29 := buf[10261:10269] // c.DepositBalanceToConsume + sszSlice30 := buf[10269:10277] // c.ExitBalanceToConsume + sszSlice31 := buf[10277:10285] // c.EarliestExitEpoch + sszSlice32 := buf[10285:10293] // c.ConsolidationBalanceToConsume + sszSlice33 := buf[10293:10301] // c.EarliestConsolidationEpoch + + sszVarOffset7 := ssz.ReadOffset(buf[4272:4276]) // c.HistoricalRoots + if sszVarOffset7 != 10313 { + return ssz.ErrInvalidVariableOffset } - b.RandaoReveal = append(b.RandaoReveal, buf[0:96]...) - - // Field (1) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(Eth1Data) + if sszVarOffset7 > size { + return ssz.ErrOffset } - if err = b.Eth1Data.UnmarshalSSZ(buf[96:168]); err != nil { - return err + sszVarOffset9 := ssz.ReadOffset(buf[4348:4352]) // c.Eth1DataVotes + if sszVarOffset9 > size || sszVarOffset9 < sszVarOffset7 { + return ssz.ErrOffset } - - // Field (2) 'Graffiti' - if cap(b.Graffiti) == 0 { - b.Graffiti = make([]byte, 0, len(buf[168:200])) + sszVarOffset11 := ssz.ReadOffset(buf[4360:4364]) // c.Validators + if sszVarOffset11 > size || sszVarOffset11 < sszVarOffset9 { + return ssz.ErrOffset } - b.Graffiti = append(b.Graffiti, buf[168:200]...) - - // Offset (3) 'ProposerSlashings' - if o3 = ssz.ReadOffset(buf[200:204]); o3 > size { + sszVarOffset12 := ssz.ReadOffset(buf[4364:4368]) // c.Balances + if sszVarOffset12 > size || sszVarOffset12 < sszVarOffset11 { return ssz.ErrOffset } - - if o3 != 336 { - return ssz.ErrInvalidVariableOffset + sszVarOffset15 := ssz.ReadOffset(buf[6928:6932]) // c.PreviousEpochParticipation + if sszVarOffset15 > size || sszVarOffset15 < sszVarOffset12 { + return ssz.ErrOffset } - - // Offset (4) 'AttesterSlashings' - if o4 = ssz.ReadOffset(buf[204:208]); o4 > size || o3 > o4 { + sszVarOffset16 := ssz.ReadOffset(buf[6932:6936]) // c.CurrentEpochParticipation + if sszVarOffset16 > size || sszVarOffset16 < sszVarOffset15 { return ssz.ErrOffset } - - // Offset (5) 'Attestations' - if o5 = ssz.ReadOffset(buf[208:212]); o5 > size || o4 > o5 { + sszVarOffset21 := ssz.ReadOffset(buf[7057:7061]) // c.InactivityScores + if sszVarOffset21 > size || sszVarOffset21 < sszVarOffset16 { return ssz.ErrOffset } - - // Offset (6) 'Deposits' - if o6 = ssz.ReadOffset(buf[212:216]); o6 > size || o5 > o6 { + sszVarOffset24 := ssz.ReadOffset(buf[10229:10233]) // c.LatestExecutionPayloadHeader + if sszVarOffset24 > size || sszVarOffset24 < sszVarOffset21 { return ssz.ErrOffset } - - // Offset (7) 'VoluntaryExits' - if o7 = ssz.ReadOffset(buf[216:220]); o7 > size || o6 > o7 { + sszVarOffset27 := ssz.ReadOffset(buf[10249:10253]) // c.HistoricalSummaries + if sszVarOffset27 > size || sszVarOffset27 < sszVarOffset24 { return ssz.ErrOffset } - - // Field (8) 'SyncAggregate' - if b.SyncAggregate == nil { - b.SyncAggregate = new(SyncAggregate) + sszVarOffset34 := ssz.ReadOffset(buf[10301:10305]) // c.PendingDeposits + if sszVarOffset34 > size || sszVarOffset34 < sszVarOffset27 { + return ssz.ErrOffset } - if err = b.SyncAggregate.UnmarshalSSZ(buf[220:320]); err != nil { - return err + sszVarOffset35 := ssz.ReadOffset(buf[10305:10309]) // c.PendingPartialWithdrawals + if sszVarOffset35 > size || sszVarOffset35 < sszVarOffset34 { + return ssz.ErrOffset } - - // Offset (9) 'ExecutionPayload' - if o9 = ssz.ReadOffset(buf[320:324]); o9 > size || o7 > o9 { + sszVarOffset36 := ssz.ReadOffset(buf[10309:10313]) // c.PendingConsolidations + if sszVarOffset36 > size || sszVarOffset36 < sszVarOffset35 { return ssz.ErrOffset } + sszSlice7 := buf[sszVarOffset7:sszVarOffset9] // c.HistoricalRoots + sszSlice9 := buf[sszVarOffset9:sszVarOffset11] // c.Eth1DataVotes + sszSlice11 := buf[sszVarOffset11:sszVarOffset12] // c.Validators + sszSlice12 := buf[sszVarOffset12:sszVarOffset15] // c.Balances + sszSlice15 := buf[sszVarOffset15:sszVarOffset16] // c.PreviousEpochParticipation + sszSlice16 := buf[sszVarOffset16:sszVarOffset21] // c.CurrentEpochParticipation + sszSlice21 := buf[sszVarOffset21:sszVarOffset24] // c.InactivityScores + sszSlice24 := buf[sszVarOffset24:sszVarOffset27] // c.LatestExecutionPayloadHeader + sszSlice27 := buf[sszVarOffset27:sszVarOffset34] // c.HistoricalSummaries + sszSlice34 := buf[sszVarOffset34:sszVarOffset35] // c.PendingDeposits + sszSlice35 := buf[sszVarOffset35:sszVarOffset36] // c.PendingPartialWithdrawals + sszSlice36 := buf[sszVarOffset36:] // c.PendingConsolidations - // Offset (10) 'BlsToExecutionChanges' - if o10 = ssz.ReadOffset(buf[324:328]); o10 > size || o9 > o10 { - return ssz.ErrOffset + // Field 0: GenesisTime + c.GenesisTime = binary.LittleEndian.Uint64(sszSlice0) + + // Field 1: GenesisValidatorsRoot + c.GenesisValidatorsRoot = make([]byte, 0, 32) + c.GenesisValidatorsRoot = append(c.GenesisValidatorsRoot, sszSlice1...) + + // Field 2: Slot + if err = c.Slot.UnmarshalSSZ(sszSlice2); err != nil { + return fmt.Errorf("Slot: %w", err) } - // Offset (11) 'BlobKzgCommitments' - if o11 = ssz.ReadOffset(buf[328:332]); o11 > size || o10 > o11 { - return ssz.ErrOffset + // Field 3: Fork + c.Fork = new(Fork) + if err = c.Fork.UnmarshalSSZ(sszSlice3); err != nil { + return fmt.Errorf("Fork: %w", err) } - // Offset (12) 'ExecutionRequests' - if o12 = ssz.ReadOffset(buf[332:336]); o12 > size || o11 > o12 { - return ssz.ErrOffset + // Field 4: LatestBlockHeader + c.LatestBlockHeader = new(BeaconBlockHeader) + if err = c.LatestBlockHeader.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("LatestBlockHeader: %w", err) } - // Field (3) 'ProposerSlashings' + // Field 5: BlockRoots { - buf = tail[o3:o4] - num, err := ssz.DivideInt2(len(buf), 416, 16) - if err != nil { - return err - } - b.ProposerSlashings = make([]*ProposerSlashing, num) - for ii := 0; ii < num; ii++ { - if b.ProposerSlashings[ii] == nil { - b.ProposerSlashings[ii] = new(ProposerSlashing) - } - if err = b.ProposerSlashings[ii].UnmarshalSSZ(buf[ii*416 : (ii+1)*416]); err != nil { - return err - } + c.BlockRoots = make([][]byte, 64) + for i := 0; i < 64; i++ { + var tmp []byte + + tmpSlice := sszSlice5[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.BlockRoots[i] = tmp } } - // Field (4) 'AttesterSlashings' + // Field 6: StateRoots { - buf = tail[o4:o5] - num, err := ssz.DecodeDynamicLength(buf, 1) - if err != nil { - return err - } - b.AttesterSlashings = make([]*AttesterSlashingElectra, num) - err = ssz.UnmarshalDynamic(buf, num, func(indx int, buf []byte) (err error) { - if b.AttesterSlashings[indx] == nil { - b.AttesterSlashings[indx] = new(AttesterSlashingElectra) - } - if err = b.AttesterSlashings[indx].UnmarshalSSZ(buf); err != nil { - return err - } - return nil - }) - if err != nil { - return err + c.StateRoots = make([][]byte, 64) + for i := 0; i < 64; i++ { + var tmp []byte + + tmpSlice := sszSlice6[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.StateRoots[i] = tmp } } - // Field (5) 'Attestations' + // Field 7: HistoricalRoots { - buf = tail[o5:o6] - num, err := ssz.DecodeDynamicLength(buf, 8) - if err != nil { - return err - } - b.Attestations = make([]*AttestationElectra, num) - err = ssz.UnmarshalDynamic(buf, num, func(indx int, buf []byte) (err error) { - if b.Attestations[indx] == nil { - b.Attestations[indx] = new(AttestationElectra) - } - if err = b.Attestations[indx].UnmarshalSSZ(buf); err != nil { - return err - } - return nil - }) - if err != nil { - return err + if len(sszSlice7)%32 != 0 { + return fmt.Errorf("misaligned bytes: c.HistoricalRoots length is %d, which is not a multiple of 32: %w", len(sszSlice7), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice7) / 32 + if numElem > 16777216 { + return fmt.Errorf("ssz-max exceeded: c.HistoricalRoots has %d elements, ssz-max is 16777216: %w", numElem, ssz.ErrListTooBig) + } + c.HistoricalRoots = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte + + tmpSlice := sszSlice7[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.HistoricalRoots[i] = tmp } } - // Field (6) 'Deposits' + // Field 8: Eth1Data + c.Eth1Data = new(Eth1Data) + if err = c.Eth1Data.UnmarshalSSZ(sszSlice8); err != nil { + return fmt.Errorf("Eth1Data: %w", err) + } + + // Field 9: Eth1DataVotes { - buf = tail[o6:o7] - num, err := ssz.DivideInt2(len(buf), 1240, 16) - if err != nil { - return err - } - b.Deposits = make([]*Deposit, num) - for ii := 0; ii < num; ii++ { - if b.Deposits[ii] == nil { - b.Deposits[ii] = new(Deposit) - } - if err = b.Deposits[ii].UnmarshalSSZ(buf[ii*1240 : (ii+1)*1240]); err != nil { - return err + if len(sszSlice9)%72 != 0 { + return fmt.Errorf("misaligned bytes: c.Eth1DataVotes length is %d, which is not a multiple of 72: %w", len(sszSlice9), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice9) / 72 + if numElem > 32 { + return fmt.Errorf("ssz-max exceeded: c.Eth1DataVotes has %d elements, ssz-max is 32: %w", numElem, ssz.ErrListTooBig) + } + c.Eth1DataVotes = make([]*Eth1Data, numElem) + for i := 0; i < numElem; i++ { + var tmp *Eth1Data + tmp = new(Eth1Data) + tmpSlice := sszSlice9[i*72 : (1+i)*72] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Eth1DataVotes: %w", err) } + c.Eth1DataVotes[i] = tmp } } - // Field (7) 'VoluntaryExits' + // Field 10: Eth1DepositIndex + c.Eth1DepositIndex = binary.LittleEndian.Uint64(sszSlice10) + + // Field 11: Validators { - buf = tail[o7:o9] - num, err := ssz.DivideInt2(len(buf), 112, 16) - if err != nil { - return err - } - b.VoluntaryExits = make([]*SignedVoluntaryExit, num) - for ii := 0; ii < num; ii++ { - if b.VoluntaryExits[ii] == nil { - b.VoluntaryExits[ii] = new(SignedVoluntaryExit) - } - if err = b.VoluntaryExits[ii].UnmarshalSSZ(buf[ii*112 : (ii+1)*112]); err != nil { - return err + if len(sszSlice11)%121 != 0 { + return fmt.Errorf("misaligned bytes: c.Validators length is %d, which is not a multiple of 121: %w", len(sszSlice11), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice11) / 121 + if numElem > 1099511627776 { + return fmt.Errorf("ssz-max exceeded: c.Validators has %d elements, ssz-max is 1099511627776: %w", numElem, ssz.ErrListTooBig) + } + c.Validators = make([]*Validator, numElem) + for i := 0; i < numElem; i++ { + var tmp *Validator + tmp = new(Validator) + tmpSlice := sszSlice11[i*121 : (1+i)*121] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Validators: %w", err) } + c.Validators[i] = tmp } } - // Field (9) 'ExecutionPayload' + // Field 12: Balances { - buf = tail[o9:o10] - if b.ExecutionPayload == nil { - b.ExecutionPayload = new(v1.ExecutionPayloadDeneb) + if len(sszSlice12)%8 != 0 { + return fmt.Errorf("misaligned bytes: c.Balances length is %d, which is not a multiple of 8: %w", len(sszSlice12), ssz.ErrIncorrectListSize) } - if err = b.ExecutionPayload.UnmarshalSSZ(buf); err != nil { - return err + numElem := len(sszSlice12) / 8 + if numElem > 1099511627776 { + return fmt.Errorf("ssz-max exceeded: c.Balances has %d elements, ssz-max is 1099511627776: %w", numElem, ssz.ErrListTooBig) } - } + c.Balances = make([]uint64, numElem) + for i := 0; i < numElem; i++ { + var tmp uint64 - // Field (10) 'BlsToExecutionChanges' - { - buf = tail[o10:o11] - num, err := ssz.DivideInt2(len(buf), 172, 16) - if err != nil { - return err - } - b.BlsToExecutionChanges = make([]*SignedBLSToExecutionChange, num) - for ii := 0; ii < num; ii++ { - if b.BlsToExecutionChanges[ii] == nil { - b.BlsToExecutionChanges[ii] = new(SignedBLSToExecutionChange) - } - if err = b.BlsToExecutionChanges[ii].UnmarshalSSZ(buf[ii*172 : (ii+1)*172]); err != nil { - return err - } + tmpSlice := sszSlice12[i*8 : (1+i)*8] + tmp = binary.LittleEndian.Uint64(tmpSlice) + c.Balances[i] = tmp } } - // Field (11) 'BlobKzgCommitments' + // Field 13: RandaoMixes { - buf = tail[o11:o12] - num, err := ssz.DivideInt2(len(buf), 48, 4096) - if err != nil { - return err - } - b.BlobKzgCommitments = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(b.BlobKzgCommitments[ii]) == 0 { - b.BlobKzgCommitments[ii] = make([]byte, 0, len(buf[ii*48:(ii+1)*48])) - } - b.BlobKzgCommitments[ii] = append(b.BlobKzgCommitments[ii], buf[ii*48:(ii+1)*48]...) + c.RandaoMixes = make([][]byte, 64) + for i := 0; i < 64; i++ { + var tmp []byte + + tmpSlice := sszSlice13[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.RandaoMixes[i] = tmp } } - // Field (12) 'ExecutionRequests' + // Field 14: Slashings { - buf = tail[o12:] - if b.ExecutionRequests == nil { - b.ExecutionRequests = new(v1.ExecutionRequests) - } - if err = b.ExecutionRequests.UnmarshalSSZ(buf); err != nil { - return err + c.Slashings = make([]uint64, 64) + for i := 0; i < 64; i++ { + var tmp uint64 + + tmpSlice := sszSlice14[i*8 : (1+i)*8] + tmp = binary.LittleEndian.Uint64(tmpSlice) + c.Slashings[i] = tmp } } - return err -} -// SizeSSZ returns the ssz encoded size in bytes for the BeaconBlockBodyElectra object -func (b *BeaconBlockBodyElectra) SizeSSZ() (size int) { - size = 336 + // Field 15: PreviousEpochParticipation + c.PreviousEpochParticipation = append([]byte{}, sszSlice15...) - // Field (3) 'ProposerSlashings' - size += len(b.ProposerSlashings) * 416 + // Field 16: CurrentEpochParticipation + c.CurrentEpochParticipation = append([]byte{}, sszSlice16...) - // Field (4) 'AttesterSlashings' - for ii := 0; ii < len(b.AttesterSlashings); ii++ { - size += 4 - size += b.AttesterSlashings[ii].SizeSSZ() + // Field 17: JustificationBits + c.JustificationBits = make([]byte, 0, 1) + c.JustificationBits = append(c.JustificationBits, go_bitfield.Bitvector4(sszSlice17)...) + + // Field 18: PreviousJustifiedCheckpoint + c.PreviousJustifiedCheckpoint = new(Checkpoint) + if err = c.PreviousJustifiedCheckpoint.UnmarshalSSZ(sszSlice18); err != nil { + return fmt.Errorf("PreviousJustifiedCheckpoint: %w", err) } - // Field (5) 'Attestations' - for ii := 0; ii < len(b.Attestations); ii++ { - size += 4 - size += b.Attestations[ii].SizeSSZ() + // Field 19: CurrentJustifiedCheckpoint + c.CurrentJustifiedCheckpoint = new(Checkpoint) + if err = c.CurrentJustifiedCheckpoint.UnmarshalSSZ(sszSlice19); err != nil { + return fmt.Errorf("CurrentJustifiedCheckpoint: %w", err) + } + + // Field 20: FinalizedCheckpoint + c.FinalizedCheckpoint = new(Checkpoint) + if err = c.FinalizedCheckpoint.UnmarshalSSZ(sszSlice20); err != nil { + return fmt.Errorf("FinalizedCheckpoint: %w", err) + } + + // Field 21: InactivityScores + { + if len(sszSlice21)%8 != 0 { + return fmt.Errorf("misaligned bytes: c.InactivityScores length is %d, which is not a multiple of 8: %w", len(sszSlice21), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice21) / 8 + if numElem > 1099511627776 { + return fmt.Errorf("ssz-max exceeded: c.InactivityScores has %d elements, ssz-max is 1099511627776: %w", numElem, ssz.ErrListTooBig) + } + c.InactivityScores = make([]uint64, numElem) + for i := 0; i < numElem; i++ { + var tmp uint64 + + tmpSlice := sszSlice21[i*8 : (1+i)*8] + tmp = binary.LittleEndian.Uint64(tmpSlice) + c.InactivityScores[i] = tmp + } } - // Field (6) 'Deposits' - size += len(b.Deposits) * 1240 + // Field 22: CurrentSyncCommittee + c.CurrentSyncCommittee = new(SyncCommittee) + if err = c.CurrentSyncCommittee.UnmarshalSSZ(sszSlice22); err != nil { + return fmt.Errorf("CurrentSyncCommittee: %w", err) + } - // Field (7) 'VoluntaryExits' - size += len(b.VoluntaryExits) * 112 + // Field 23: NextSyncCommittee + c.NextSyncCommittee = new(SyncCommittee) + if err = c.NextSyncCommittee.UnmarshalSSZ(sszSlice23); err != nil { + return fmt.Errorf("NextSyncCommittee: %w", err) + } - // Field (9) 'ExecutionPayload' - if b.ExecutionPayload == nil { - b.ExecutionPayload = new(v1.ExecutionPayloadDeneb) + // Field 24: LatestExecutionPayloadHeader + c.LatestExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderDeneb) + if err = c.LatestExecutionPayloadHeader.UnmarshalSSZ(sszSlice24); err != nil { + return fmt.Errorf("LatestExecutionPayloadHeader: %w", err) } - size += b.ExecutionPayload.SizeSSZ() - // Field (10) 'BlsToExecutionChanges' - size += len(b.BlsToExecutionChanges) * 172 + // Field 25: NextWithdrawalIndex + c.NextWithdrawalIndex = binary.LittleEndian.Uint64(sszSlice25) - // Field (11) 'BlobKzgCommitments' - size += len(b.BlobKzgCommitments) * 48 + // Field 26: NextWithdrawalValidatorIndex + if err = c.NextWithdrawalValidatorIndex.UnmarshalSSZ(sszSlice26); err != nil { + return fmt.Errorf("NextWithdrawalValidatorIndex: %w", err) + } - // Field (12) 'ExecutionRequests' - if b.ExecutionRequests == nil { - b.ExecutionRequests = new(v1.ExecutionRequests) + // Field 27: HistoricalSummaries + { + if len(sszSlice27)%64 != 0 { + return fmt.Errorf("misaligned bytes: c.HistoricalSummaries length is %d, which is not a multiple of 64: %w", len(sszSlice27), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice27) / 64 + if numElem > 16777216 { + return fmt.Errorf("ssz-max exceeded: c.HistoricalSummaries has %d elements, ssz-max is 16777216: %w", numElem, ssz.ErrListTooBig) + } + c.HistoricalSummaries = make([]*HistoricalSummary, numElem) + for i := 0; i < numElem; i++ { + var tmp *HistoricalSummary + tmp = new(HistoricalSummary) + tmpSlice := sszSlice27[i*64 : (1+i)*64] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("HistoricalSummaries: %w", err) + } + c.HistoricalSummaries[i] = tmp + } } - size += b.ExecutionRequests.SizeSSZ() - return -} + // Field 28: DepositRequestsStartIndex + c.DepositRequestsStartIndex = binary.LittleEndian.Uint64(sszSlice28) -// HashTreeRoot ssz hashes the BeaconBlockBodyElectra object -func (b *BeaconBlockBodyElectra) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) -} + // Field 29: DepositBalanceToConsume + if err = c.DepositBalanceToConsume.UnmarshalSSZ(sszSlice29); err != nil { + return fmt.Errorf("DepositBalanceToConsume: %w", err) + } -// HashTreeRootWith ssz hashes the BeaconBlockBodyElectra object with a hasher -func (b *BeaconBlockBodyElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() + // Field 30: ExitBalanceToConsume + if err = c.ExitBalanceToConsume.UnmarshalSSZ(sszSlice30); err != nil { + return fmt.Errorf("ExitBalanceToConsume: %w", err) + } - // Field (0) 'RandaoReveal' - if size := len(b.RandaoReveal); size != 96 { - err = ssz.ErrBytesLengthFn("--.RandaoReveal", size, 96) - return + // Field 31: EarliestExitEpoch + if err = c.EarliestExitEpoch.UnmarshalSSZ(sszSlice31); err != nil { + return fmt.Errorf("EarliestExitEpoch: %w", err) } - hh.PutBytes(b.RandaoReveal) - // Field (1) 'Eth1Data' - if err = b.Eth1Data.HashTreeRootWith(hh); err != nil { - return + // Field 32: ConsolidationBalanceToConsume + if err = c.ConsolidationBalanceToConsume.UnmarshalSSZ(sszSlice32); err != nil { + return fmt.Errorf("ConsolidationBalanceToConsume: %w", err) } - // Field (2) 'Graffiti' - if size := len(b.Graffiti); size != 32 { - err = ssz.ErrBytesLengthFn("--.Graffiti", size, 32) - return + // Field 33: EarliestConsolidationEpoch + if err = c.EarliestConsolidationEpoch.UnmarshalSSZ(sszSlice33); err != nil { + return fmt.Errorf("EarliestConsolidationEpoch: %w", err) } - hh.PutBytes(b.Graffiti) - // Field (3) 'ProposerSlashings' + // Field 34: PendingDeposits { - 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 + if len(sszSlice34)%192 != 0 { + return fmt.Errorf("misaligned bytes: c.PendingDeposits length is %d, which is not a multiple of 192: %w", len(sszSlice34), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice34) / 192 + if numElem > 134217728 { + return fmt.Errorf("ssz-max exceeded: c.PendingDeposits has %d elements, ssz-max is 134217728: %w", numElem, ssz.ErrListTooBig) + } + c.PendingDeposits = make([]*PendingDeposit, numElem) + for i := 0; i < numElem; i++ { + var tmp *PendingDeposit + tmp = new(PendingDeposit) + tmpSlice := sszSlice34[i*192 : (1+i)*192] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("PendingDeposits: %w", err) } + c.PendingDeposits[i] = tmp } - hh.MerkleizeWithMixin(subIndx, num, 16) } - // Field (4) 'AttesterSlashings' + // Field 35: PendingPartialWithdrawals { - 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 + if len(sszSlice35)%24 != 0 { + return fmt.Errorf("misaligned bytes: c.PendingPartialWithdrawals length is %d, which is not a multiple of 24: %w", len(sszSlice35), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice35) / 24 + if numElem > 64 { + return fmt.Errorf("ssz-max exceeded: c.PendingPartialWithdrawals has %d elements, ssz-max is 64: %w", numElem, ssz.ErrListTooBig) + } + c.PendingPartialWithdrawals = make([]*PendingPartialWithdrawal, numElem) + for i := 0; i < numElem; i++ { + var tmp *PendingPartialWithdrawal + tmp = new(PendingPartialWithdrawal) + tmpSlice := sszSlice35[i*24 : (1+i)*24] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("PendingPartialWithdrawals: %w", err) } + c.PendingPartialWithdrawals[i] = tmp } - hh.MerkleizeWithMixin(subIndx, num, 1) } - // Field (5) 'Attestations' + // Field 36: PendingConsolidations { - 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 + if len(sszSlice36)%16 != 0 { + return fmt.Errorf("misaligned bytes: c.PendingConsolidations length is %d, which is not a multiple of 16: %w", len(sszSlice36), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice36) / 16 + if numElem > 64 { + return fmt.Errorf("ssz-max exceeded: c.PendingConsolidations has %d elements, ssz-max is 64: %w", numElem, ssz.ErrListTooBig) + } + c.PendingConsolidations = make([]*PendingConsolidation, numElem) + for i := 0; i < numElem; i++ { + var tmp *PendingConsolidation + tmp = new(PendingConsolidation) + tmpSlice := sszSlice36[i*16 : (1+i)*16] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("PendingConsolidations: %w", err) } + c.PendingConsolidations[i] = tmp } - hh.MerkleizeWithMixin(subIndx, num, 8) } + return err +} + +func (c *BeaconStateElectra) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (6) 'Deposits' +func (c *BeaconStateElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: GenesisTime + hh.PutUint64(c.GenesisTime) + // Field 1: GenesisValidatorsRoot + if len(c.GenesisValidatorsRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.GenesisValidatorsRoot) + // Field 2: Slot + if err := c.Slot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Slot: %w", err) + } + // Field 3: Fork + if err := c.Fork.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Fork: %w", err) + } + // Field 4: LatestBlockHeader + if err := c.LatestBlockHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("LatestBlockHeader: %w", err) + } + // Field 5: BlockRoots { + if len(c.BlockRoots) != 64 { + return ssz.ErrVectorLength + } 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 + for _, o := range c.BlockRoots { + if len(o) != 32 { + return ssz.ErrBytesLength } + hh.Append(o) } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.Merkleize(subIndx) } - - // Field (7) 'VoluntaryExits' + // Field 6: StateRoots { + if len(c.StateRoots) != 64 { + return ssz.ErrVectorLength + } 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 + for _, o := range c.StateRoots { + if len(o) != 32 { + return ssz.ErrBytesLength } + hh.Append(o) } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.Merkleize(subIndx) } - - // Field (8) 'SyncAggregate' - if err = b.SyncAggregate.HashTreeRootWith(hh); err != nil { - return + // Field 7: HistoricalRoots + { + if len(c.HistoricalRoots) > 16777216 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.HistoricalRoots { + if len(o) != 32 { + return ssz.ErrBytesLength + } + hh.Append(o) + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.HistoricalRoots)), 16777216) } - - // Field (9) 'ExecutionPayload' - if err = b.ExecutionPayload.HashTreeRootWith(hh); err != nil { - return + // Field 8: Eth1Data + if err := c.Eth1Data.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Eth1Data: %w", err) } - - // Field (10) 'BlsToExecutionChanges' + // Field 9: Eth1DataVotes { + if len(c.Eth1DataVotes) > 32 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.Eth1DataVotes { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Eth1DataVotes: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Eth1DataVotes)), 32) } - - // Field (11) 'BlobKzgCommitments' + // Field 10: Eth1DepositIndex + hh.PutUint64(c.Eth1DepositIndex) + // Field 11: Validators { - if size := len(b.BlobKzgCommitments); size > 4096 { - err = ssz.ErrListTooBigFn("--.BlobKzgCommitments", size, 4096) - return + if len(c.Validators) > 1099511627776 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range b.BlobKzgCommitments { - if len(i) != 48 { - err = ssz.ErrBytesLength - return + for _, o := range c.Validators { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Validators: %w", err) } - hh.PutBytes(i) } - - numItems := uint64(len(b.BlobKzgCommitments)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Validators)), 1099511627776) } - - // Field (12) 'ExecutionRequests' - if err = b.ExecutionRequests.HashTreeRootWith(hh); err != nil { - return + // Field 12: Balances + { + if len(c.Balances) > 1099511627776 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.Balances { + hh.AppendUint64(o) + } + hh.FillUpTo32() + numItems := uint64(len(c.Balances)) + hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(1099511627776, numItems, 8)) } - - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the SignedBlindedBeaconBlockElectra object -func (s *SignedBlindedBeaconBlockElectra) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) -} - -// MarshalSSZTo ssz marshals the SignedBlindedBeaconBlockElectra object to a target array -func (s *SignedBlindedBeaconBlockElectra) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(100) - - // Offset (0) 'Message' - dst = ssz.WriteOffset(dst, offset) - if s.Message == nil { - s.Message = new(BlindedBeaconBlockElectra) + // Field 13: RandaoMixes + { + if len(c.RandaoMixes) != 64 { + return ssz.ErrVectorLength + } + subIndx := hh.Index() + for _, o := range c.RandaoMixes { + if len(o) != 32 { + return ssz.ErrBytesLength + } + hh.Append(o) + } + hh.Merkleize(subIndx) } - offset += s.Message.SizeSSZ() - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 14: Slashings + { + if len(c.Slashings) != 64 { + return ssz.ErrVectorLength + } + subIndx := hh.Index() + for _, o := range c.Slashings { + hh.AppendUint64(o) + } + hh.Merkleize(subIndx) } - dst = append(dst, s.Signature...) + // Field 15: PreviousEpochParticipation - // Field (0) 'Message' - if dst, err = s.Message.MarshalSSZTo(dst); err != nil { - return + { + if len(c.PreviousEpochParticipation) > 1099511627776 { + return ssz.ErrBytesLength + } + subIndx := hh.Index() + hh.AppendBytes32(c.PreviousEpochParticipation) + numItems := uint64(len(c.PreviousEpochParticipation)) + hh.MerkleizeWithMixin(subIndx, numItems, (1099511627776*1+31)/32) } - return -} + // Field 16: CurrentEpochParticipation -// UnmarshalSSZ ssz unmarshals the SignedBlindedBeaconBlockElectra object -func (s *SignedBlindedBeaconBlockElectra) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 100 { - return ssz.ErrSize + { + if len(c.CurrentEpochParticipation) > 1099511627776 { + return ssz.ErrBytesLength + } + subIndx := hh.Index() + hh.AppendBytes32(c.CurrentEpochParticipation) + numItems := uint64(len(c.CurrentEpochParticipation)) + hh.MerkleizeWithMixin(subIndx, numItems, (1099511627776*1+31)/32) } - tail := buf - var o0 uint64 - - // Offset (0) 'Message' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset + // Field 17: JustificationBits + if len([]byte(c.JustificationBits)) != 1 { + return ssz.ErrBytesLength } - - if o0 != 100 { - return ssz.ErrInvalidVariableOffset + hh.PutBytes([]byte(c.JustificationBits)) + // Field 18: PreviousJustifiedCheckpoint + if err := c.PreviousJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("PreviousJustifiedCheckpoint: %w", err) } - - // Field (1) 'Signature' - if cap(s.Signature) == 0 { - s.Signature = make([]byte, 0, len(buf[4:100])) + // Field 19: CurrentJustifiedCheckpoint + if err := c.CurrentJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("CurrentJustifiedCheckpoint: %w", err) } - s.Signature = append(s.Signature, buf[4:100]...) - - // Field (0) 'Message' + // Field 20: FinalizedCheckpoint + if err := c.FinalizedCheckpoint.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("FinalizedCheckpoint: %w", err) + } + // Field 21: InactivityScores { - buf = tail[o0:] - if s.Message == nil { - s.Message = new(BlindedBeaconBlockElectra) + if len(c.InactivityScores) > 1099511627776 { + return ssz.ErrListTooBig } - if err = s.Message.UnmarshalSSZ(buf); err != nil { - return err + subIndx := hh.Index() + for _, o := range c.InactivityScores { + hh.AppendUint64(o) } + hh.FillUpTo32() + numItems := uint64(len(c.InactivityScores)) + hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(1099511627776, numItems, 8)) } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the SignedBlindedBeaconBlockElectra object -func (s *SignedBlindedBeaconBlockElectra) SizeSSZ() (size int) { - size = 100 - - // Field (0) 'Message' - if s.Message == nil { - s.Message = new(BlindedBeaconBlockElectra) + // Field 22: CurrentSyncCommittee + if err := c.CurrentSyncCommittee.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("CurrentSyncCommittee: %w", err) } - size += s.Message.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the SignedBlindedBeaconBlockElectra object -func (s *SignedBlindedBeaconBlockElectra) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) -} - -// HashTreeRootWith ssz hashes the SignedBlindedBeaconBlockElectra object with a hasher -func (s *SignedBlindedBeaconBlockElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'Message' - if err = s.Message.HashTreeRootWith(hh); err != nil { - return + // Field 23: NextSyncCommittee + if err := c.NextSyncCommittee.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("NextSyncCommittee: %w", err) } - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 24: LatestExecutionPayloadHeader + if err := c.LatestExecutionPayloadHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("LatestExecutionPayloadHeader: %w", err) } - hh.PutBytes(s.Signature) - - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the BlindedBeaconBlockElectra object -func (b *BlindedBeaconBlockElectra) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} - -// MarshalSSZTo ssz marshals the BlindedBeaconBlockElectra object to a target array -func (b *BlindedBeaconBlockElectra) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(84) - - // Field (0) 'Slot' - dst = ssz.MarshalUint(dst, b.Slot) - - // Field (1) 'ProposerIndex' - dst = ssz.MarshalUint(dst, b.ProposerIndex) - - // Field (2) 'ParentRoot' - if size := len(b.ParentRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentRoot", size, 32) - return + // Field 25: NextWithdrawalIndex + hh.PutUint64(c.NextWithdrawalIndex) + // Field 26: NextWithdrawalValidatorIndex + if err := c.NextWithdrawalValidatorIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("NextWithdrawalValidatorIndex: %w", err) } - dst = append(dst, b.ParentRoot...) - - // Field (3) 'StateRoot' - if size := len(b.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return + // Field 27: HistoricalSummaries + { + if len(c.HistoricalSummaries) > 16777216 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.HistoricalSummaries { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("HistoricalSummaries: %w", err) + } + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.HistoricalSummaries)), 16777216) } - dst = append(dst, b.StateRoot...) - - // Offset (4) 'Body' - dst = ssz.WriteOffset(dst, offset) - if b.Body == nil { - b.Body = new(BlindedBeaconBlockBodyElectra) + // Field 28: DepositRequestsStartIndex + hh.PutUint64(c.DepositRequestsStartIndex) + // Field 29: DepositBalanceToConsume + if err := c.DepositBalanceToConsume.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("DepositBalanceToConsume: %w", err) } - offset += b.Body.SizeSSZ() - - // Field (4) 'Body' - if dst, err = b.Body.MarshalSSZTo(dst); err != nil { - return + // Field 30: ExitBalanceToConsume + if err := c.ExitBalanceToConsume.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ExitBalanceToConsume: %w", err) } - - return -} - -// UnmarshalSSZ ssz unmarshals the BlindedBeaconBlockElectra object -func (b *BlindedBeaconBlockElectra) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 84 { - return ssz.ErrSize + // Field 31: EarliestExitEpoch + if err := c.EarliestExitEpoch.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("EarliestExitEpoch: %w", err) } - - tail := buf - var o4 uint64 - - // Field (0) 'Slot' - b.Slot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[0:8]) - - // Field (1) 'ProposerIndex' - b.ProposerIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[8:16]) - - // Field (2) 'ParentRoot' - if cap(b.ParentRoot) == 0 { - b.ParentRoot = make([]byte, 0, len(buf[16:48])) + // Field 32: ConsolidationBalanceToConsume + if err := c.ConsolidationBalanceToConsume.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ConsolidationBalanceToConsume: %w", err) } - 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])) + // Field 33: EarliestConsolidationEpoch + if err := c.EarliestConsolidationEpoch.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("EarliestConsolidationEpoch: %w", err) } - b.StateRoot = append(b.StateRoot, buf[48:80]...) - - // Offset (4) 'Body' - if o4 = ssz.ReadOffset(buf[80:84]); o4 > size { - return ssz.ErrOffset + // Field 34: PendingDeposits + { + if len(c.PendingDeposits) > 134217728 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.PendingDeposits { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("PendingDeposits: %w", err) + } + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.PendingDeposits)), 134217728) } - - if o4 != 84 { - return ssz.ErrInvalidVariableOffset + // Field 35: PendingPartialWithdrawals + { + if len(c.PendingPartialWithdrawals) > 64 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.PendingPartialWithdrawals { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("PendingPartialWithdrawals: %w", err) + } + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.PendingPartialWithdrawals)), 64) } - - // Field (4) 'Body' + // Field 36: PendingConsolidations { - buf = tail[o4:] - if b.Body == nil { - b.Body = new(BlindedBeaconBlockBodyElectra) + if len(c.PendingConsolidations) > 64 { + return ssz.ErrListTooBig } - if err = b.Body.UnmarshalSSZ(buf); err != nil { - return err + subIndx := hh.Index() + for _, o := range c.PendingConsolidations { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("PendingConsolidations: %w", err) + } } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.PendingConsolidations)), 64) } - return err + hh.Merkleize(indx) + return nil } -// SizeSSZ returns the ssz encoded size in bytes for the BlindedBeaconBlockElectra object -func (b *BlindedBeaconBlockElectra) SizeSSZ() (size int) { - size = 84 - - // Field (4) 'Body' - if b.Body == nil { - b.Body = new(BlindedBeaconBlockBodyElectra) +func (c *BlindedBeaconBlockBodyElectra) SizeSSZ() int { + size := 336 + size += len(c.ProposerSlashings) * 416 + for _, o := range c.AttesterSlashings { + size += 4 + size += o.SizeSSZ() } - size += b.Body.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the BlindedBeaconBlockElectra object -func (b *BlindedBeaconBlockElectra) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) -} - -// HashTreeRootWith ssz hashes the BlindedBeaconBlockElectra object with a hasher -func (b *BlindedBeaconBlockElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'Slot' - ssz.PutUint(hh, b.Slot) - - // Field (1) 'ProposerIndex' - ssz.PutUint(hh, b.ProposerIndex) - - // Field (2) 'ParentRoot' - if size := len(b.ParentRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentRoot", size, 32) - return + for _, o := range c.Attestations { + size += 4 + size += o.SizeSSZ() } - hh.PutBytes(b.ParentRoot) - - // Field (3) 'StateRoot' - if size := len(b.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return + size += len(c.Deposits) * 1240 + size += len(c.VoluntaryExits) * 112 + if c.ExecutionPayloadHeader == nil { + c.ExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderDeneb) } - hh.PutBytes(b.StateRoot) - - // Field (4) 'Body' - if err = b.Body.HashTreeRootWith(hh); err != nil { - return + size += c.ExecutionPayloadHeader.SizeSSZ() + size += len(c.BlsToExecutionChanges) * 172 + size += len(c.BlobKzgCommitments) * 48 + if c.ExecutionRequests == nil { + c.ExecutionRequests = new(v1.ExecutionRequests) } - - hh.Merkleize(indx) - return + size += c.ExecutionRequests.SizeSSZ() + return size } -// MarshalSSZ ssz marshals the BlindedBeaconBlockBodyElectra object -func (b *BlindedBeaconBlockBodyElectra) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) +func (c *BlindedBeaconBlockBodyElectra) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the BlindedBeaconBlockBodyElectra object to a target array -func (b *BlindedBeaconBlockBodyElectra) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(336) +func (c *BlindedBeaconBlockBodyElectra) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 336 - // Field (0) 'RandaoReveal' - if size := len(b.RandaoReveal); size != 96 { - err = ssz.ErrBytesLengthFn("--.RandaoReveal", size, 96) - return + // Field 0: RandaoReveal + if len(c.RandaoReveal) != 96 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.RandaoReveal...) + dst = append(dst, c.RandaoReveal...) - // Field (1) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(Eth1Data) + // Field 1: Eth1Data + if c.Eth1Data == nil { + c.Eth1Data = new(Eth1Data) } - if dst, err = b.Eth1Data.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.Eth1Data.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Eth1Data: %w", err) } - // Field (2) 'Graffiti' - if size := len(b.Graffiti); size != 32 { - err = ssz.ErrBytesLengthFn("--.Graffiti", size, 32) - return + // Field 2: Graffiti + if len(c.Graffiti) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.Graffiti...) + dst = append(dst, c.Graffiti...) - // Offset (3) 'ProposerSlashings' + // Field 3: ProposerSlashings dst = ssz.WriteOffset(dst, offset) - offset += len(b.ProposerSlashings) * 416 + offset += len(c.ProposerSlashings) * 416 - // Offset (4) 'AttesterSlashings' + // Field 4: AttesterSlashings dst = ssz.WriteOffset(dst, offset) - for ii := 0; ii < len(b.AttesterSlashings); ii++ { + for _, o := range c.AttesterSlashings { offset += 4 - offset += b.AttesterSlashings[ii].SizeSSZ() + offset += o.SizeSSZ() } - // Offset (5) 'Attestations' + // Field 5: Attestations dst = ssz.WriteOffset(dst, offset) - for ii := 0; ii < len(b.Attestations); ii++ { + for _, o := range c.Attestations { offset += 4 - offset += b.Attestations[ii].SizeSSZ() + offset += o.SizeSSZ() } - // Offset (6) 'Deposits' + // Field 6: Deposits dst = ssz.WriteOffset(dst, offset) - offset += len(b.Deposits) * 1240 + offset += len(c.Deposits) * 1240 - // Offset (7) 'VoluntaryExits' + // Field 7: VoluntaryExits dst = ssz.WriteOffset(dst, offset) - offset += len(b.VoluntaryExits) * 112 + offset += len(c.VoluntaryExits) * 112 - // Field (8) 'SyncAggregate' - if b.SyncAggregate == nil { - b.SyncAggregate = new(SyncAggregate) + // Field 8: SyncAggregate + if c.SyncAggregate == nil { + c.SyncAggregate = new(SyncAggregate) } - if dst, err = b.SyncAggregate.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.SyncAggregate.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SyncAggregate: %w", err) } - // Offset (9) 'ExecutionPayloadHeader' - dst = ssz.WriteOffset(dst, offset) - if b.ExecutionPayloadHeader == nil { - b.ExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderDeneb) + // Field 9: ExecutionPayloadHeader + if c.ExecutionPayloadHeader == nil { + c.ExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderDeneb) } - offset += b.ExecutionPayloadHeader.SizeSSZ() - - // Offset (10) 'BlsToExecutionChanges' dst = ssz.WriteOffset(dst, offset) - offset += len(b.BlsToExecutionChanges) * 172 + offset += c.ExecutionPayloadHeader.SizeSSZ() - // Offset (11) 'BlobKzgCommitments' + // Field 10: BlsToExecutionChanges dst = ssz.WriteOffset(dst, offset) - offset += len(b.BlobKzgCommitments) * 48 + offset += len(c.BlsToExecutionChanges) * 172 - // Offset (12) 'ExecutionRequests' + // Field 11: BlobKzgCommitments dst = ssz.WriteOffset(dst, offset) - if b.ExecutionRequests == nil { - b.ExecutionRequests = new(v1.ExecutionRequests) + offset += len(c.BlobKzgCommitments) * 48 + + // Field 12: ExecutionRequests + if c.ExecutionRequests == nil { + c.ExecutionRequests = new(v1.ExecutionRequests) } - offset += b.ExecutionRequests.SizeSSZ() + dst = ssz.WriteOffset(dst, offset) + offset += c.ExecutionRequests.SizeSSZ() - // Field (3) 'ProposerSlashings' - if size := len(b.ProposerSlashings); size > 16 { - err = ssz.ErrListTooBigFn("--.ProposerSlashings", size, 16) - return + // Field 3: ProposerSlashings + if len(c.ProposerSlashings) > 16 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.ProposerSlashings); ii++ { - if dst, err = b.ProposerSlashings[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.ProposerSlashings { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ProposerSlashings: %w", err) } } - // Field (4) 'AttesterSlashings' - if size := len(b.AttesterSlashings); size > 1 { - err = ssz.ErrListTooBigFn("--.AttesterSlashings", size, 1) - return + // Field 4: AttesterSlashings + if len(c.AttesterSlashings) > 1 { + return nil, ssz.ErrListTooBig } { - offset = 4 * len(b.AttesterSlashings) - for ii := 0; ii < len(b.AttesterSlashings); ii++ { + offset = 4 * len(c.AttesterSlashings) + for _, o := range c.AttesterSlashings { dst = ssz.WriteOffset(dst, offset) - offset += b.AttesterSlashings[ii].SizeSSZ() + offset += o.SizeSSZ() } } - for ii := 0; ii < len(b.AttesterSlashings); ii++ { - if dst, err = b.AttesterSlashings[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.AttesterSlashings { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("AttesterSlashings: %w", err) } } - // Field (5) 'Attestations' - if size := len(b.Attestations); size > 8 { - err = ssz.ErrListTooBigFn("--.Attestations", size, 8) - return + // Field 5: Attestations + if len(c.Attestations) > 8 { + return nil, ssz.ErrListTooBig } { - offset = 4 * len(b.Attestations) - for ii := 0; ii < len(b.Attestations); ii++ { + offset = 4 * len(c.Attestations) + for _, o := range c.Attestations { dst = ssz.WriteOffset(dst, offset) - offset += b.Attestations[ii].SizeSSZ() + offset += o.SizeSSZ() } } - for ii := 0; ii < len(b.Attestations); ii++ { - if dst, err = b.Attestations[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.Attestations { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Attestations: %w", err) } } - // Field (6) 'Deposits' - if size := len(b.Deposits); size > 16 { - err = ssz.ErrListTooBigFn("--.Deposits", size, 16) - return + // Field 6: Deposits + if len(c.Deposits) > 16 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.Deposits); ii++ { - if dst, err = b.Deposits[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.Deposits { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Deposits: %w", err) } } - // Field (7) 'VoluntaryExits' - if size := len(b.VoluntaryExits); size > 16 { - err = ssz.ErrListTooBigFn("--.VoluntaryExits", size, 16) - return + // Field 7: VoluntaryExits + if len(c.VoluntaryExits) > 16 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.VoluntaryExits); ii++ { - if dst, err = b.VoluntaryExits[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.VoluntaryExits { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("VoluntaryExits: %w", err) } } - // Field (9) 'ExecutionPayloadHeader' - if dst, err = b.ExecutionPayloadHeader.MarshalSSZTo(dst); err != nil { - return + // Field 9: ExecutionPayloadHeader + if dst, err = c.ExecutionPayloadHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ExecutionPayloadHeader: %w", err) } - // Field (10) 'BlsToExecutionChanges' - if size := len(b.BlsToExecutionChanges); size > 16 { - err = ssz.ErrListTooBigFn("--.BlsToExecutionChanges", size, 16) - return + // Field 10: BlsToExecutionChanges + if len(c.BlsToExecutionChanges) > 16 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.BlsToExecutionChanges); ii++ { - if dst, err = b.BlsToExecutionChanges[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.BlsToExecutionChanges { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("BlsToExecutionChanges: %w", err) } } - // Field (11) 'BlobKzgCommitments' - if size := len(b.BlobKzgCommitments); size > 4096 { - err = ssz.ErrListTooBigFn("--.BlobKzgCommitments", size, 4096) - return + // Field 11: BlobKzgCommitments + if len(c.BlobKzgCommitments) > 4096 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.BlobKzgCommitments); ii++ { - if size := len(b.BlobKzgCommitments[ii]); size != 48 { - err = ssz.ErrBytesLengthFn("--.BlobKzgCommitments[ii]", size, 48) - return + for _, o := range c.BlobKzgCommitments { + if len(o) != 48 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.BlobKzgCommitments[ii]...) + dst = append(dst, o...) } - // Field (12) 'ExecutionRequests' - if dst, err = b.ExecutionRequests.MarshalSSZTo(dst); err != nil { - return + // Field 12: ExecutionRequests + if dst, err = c.ExecutionRequests.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ExecutionRequests: %w", err) } - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the BlindedBeaconBlockBodyElectra object -func (b *BlindedBeaconBlockBodyElectra) UnmarshalSSZ(buf []byte) error { +func (c *BlindedBeaconBlockBodyElectra) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size < 336 { 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(Eth1Data) - } - if err = b.Eth1Data.UnmarshalSSZ(buf[96:168]); err != nil { - return err - } - - // Field (2) 'Graffiti' - if cap(b.Graffiti) == 0 { - b.Graffiti = make([]byte, 0, len(buf[168:200])) - } - b.Graffiti = append(b.Graffiti, buf[168:200]...) - - // Offset (3) 'ProposerSlashings' - if o3 = ssz.ReadOffset(buf[200:204]); o3 > size { - return ssz.ErrOffset - } + sszSlice0 := buf[0:96] // c.RandaoReveal + sszSlice1 := buf[96:168] // c.Eth1Data + sszSlice2 := buf[168:200] // c.Graffiti + sszSlice8 := buf[220:320] // c.SyncAggregate - if o3 != 336 { + sszVarOffset3 := ssz.ReadOffset(buf[200:204]) // c.ProposerSlashings + if sszVarOffset3 != 336 { return ssz.ErrInvalidVariableOffset } - - // Offset (4) 'AttesterSlashings' - if o4 = ssz.ReadOffset(buf[204:208]); o4 > size || o3 > o4 { + if sszVarOffset3 > size { return ssz.ErrOffset } - - // Offset (5) 'Attestations' - if o5 = ssz.ReadOffset(buf[208:212]); o5 > size || o4 > o5 { + sszVarOffset4 := ssz.ReadOffset(buf[204:208]) // c.AttesterSlashings + if sszVarOffset4 > size || sszVarOffset4 < sszVarOffset3 { return ssz.ErrOffset } - - // Offset (6) 'Deposits' - if o6 = ssz.ReadOffset(buf[212:216]); o6 > size || o5 > o6 { + sszVarOffset5 := ssz.ReadOffset(buf[208:212]) // c.Attestations + if sszVarOffset5 > size || sszVarOffset5 < sszVarOffset4 { return ssz.ErrOffset } - - // Offset (7) 'VoluntaryExits' - if o7 = ssz.ReadOffset(buf[216:220]); o7 > size || o6 > o7 { + sszVarOffset6 := ssz.ReadOffset(buf[212:216]) // c.Deposits + if sszVarOffset6 > size || sszVarOffset6 < sszVarOffset5 { return ssz.ErrOffset } - - // Field (8) 'SyncAggregate' - if b.SyncAggregate == nil { - b.SyncAggregate = new(SyncAggregate) + sszVarOffset7 := ssz.ReadOffset(buf[216:220]) // c.VoluntaryExits + if sszVarOffset7 > size || sszVarOffset7 < sszVarOffset6 { + return ssz.ErrOffset } - if err = b.SyncAggregate.UnmarshalSSZ(buf[220:320]); err != nil { - return err + sszVarOffset9 := ssz.ReadOffset(buf[320:324]) // c.ExecutionPayloadHeader + if sszVarOffset9 > size || sszVarOffset9 < sszVarOffset7 { + return ssz.ErrOffset } - - // Offset (9) 'ExecutionPayloadHeader' - if o9 = ssz.ReadOffset(buf[320:324]); o9 > size || o7 > o9 { + sszVarOffset10 := ssz.ReadOffset(buf[324:328]) // c.BlsToExecutionChanges + if sszVarOffset10 > size || sszVarOffset10 < sszVarOffset9 { return ssz.ErrOffset } - - // Offset (10) 'BlsToExecutionChanges' - if o10 = ssz.ReadOffset(buf[324:328]); o10 > size || o9 > o10 { + sszVarOffset11 := ssz.ReadOffset(buf[328:332]) // c.BlobKzgCommitments + if sszVarOffset11 > size || sszVarOffset11 < sszVarOffset10 { return ssz.ErrOffset } - - // Offset (11) 'BlobKzgCommitments' - if o11 = ssz.ReadOffset(buf[328:332]); o11 > size || o10 > o11 { + sszVarOffset12 := ssz.ReadOffset(buf[332:336]) // c.ExecutionRequests + if sszVarOffset12 > size || sszVarOffset12 < sszVarOffset11 { return ssz.ErrOffset } + sszSlice3 := buf[sszVarOffset3:sszVarOffset4] // c.ProposerSlashings + sszSlice4 := buf[sszVarOffset4:sszVarOffset5] // c.AttesterSlashings + sszSlice5 := buf[sszVarOffset5:sszVarOffset6] // c.Attestations + sszSlice6 := buf[sszVarOffset6:sszVarOffset7] // c.Deposits + sszSlice7 := buf[sszVarOffset7:sszVarOffset9] // c.VoluntaryExits + sszSlice9 := buf[sszVarOffset9:sszVarOffset10] // c.ExecutionPayloadHeader + sszSlice10 := buf[sszVarOffset10:sszVarOffset11] // c.BlsToExecutionChanges + sszSlice11 := buf[sszVarOffset11:sszVarOffset12] // c.BlobKzgCommitments + sszSlice12 := buf[sszVarOffset12:] // c.ExecutionRequests - // Offset (12) 'ExecutionRequests' - if o12 = ssz.ReadOffset(buf[332:336]); o12 > size || o11 > o12 { - return ssz.ErrOffset + // Field 0: RandaoReveal + c.RandaoReveal = make([]byte, 0, 96) + c.RandaoReveal = append(c.RandaoReveal, sszSlice0...) + + // Field 1: Eth1Data + c.Eth1Data = new(Eth1Data) + if err = c.Eth1Data.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Eth1Data: %w", err) } - // Field (3) 'ProposerSlashings' + // Field 2: Graffiti + c.Graffiti = make([]byte, 0, 32) + c.Graffiti = append(c.Graffiti, sszSlice2...) + + // Field 3: ProposerSlashings { - buf = tail[o3:o4] - num, err := ssz.DivideInt2(len(buf), 416, 16) - if err != nil { - return err - } - b.ProposerSlashings = make([]*ProposerSlashing, num) - for ii := 0; ii < num; ii++ { - if b.ProposerSlashings[ii] == nil { - b.ProposerSlashings[ii] = new(ProposerSlashing) - } - if err = b.ProposerSlashings[ii].UnmarshalSSZ(buf[ii*416 : (ii+1)*416]); err != nil { - return err + if len(sszSlice3)%416 != 0 { + return fmt.Errorf("misaligned bytes: c.ProposerSlashings length is %d, which is not a multiple of 416: %w", len(sszSlice3), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice3) / 416 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.ProposerSlashings has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.ProposerSlashings = make([]*ProposerSlashing, numElem) + for i := 0; i < numElem; i++ { + var tmp *ProposerSlashing + tmp = new(ProposerSlashing) + tmpSlice := sszSlice3[i*416 : (1+i)*416] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("ProposerSlashings: %w", err) } + c.ProposerSlashings[i] = tmp } } - // Field (4) 'AttesterSlashings' + // Field 4: AttesterSlashings { - buf = tail[o4:o5] - num, err := ssz.DecodeDynamicLength(buf, 1) - if err != nil { - return err - } - b.AttesterSlashings = make([]*AttesterSlashingElectra, num) - err = ssz.UnmarshalDynamic(buf, num, func(indx int, buf []byte) (err error) { - if b.AttesterSlashings[indx] == nil { - b.AttesterSlashings[indx] = new(AttesterSlashingElectra) + // empty lists are zero length, so make sure there is room for an offset + // before attempting to unmarshal it + if len(sszSlice4) > 3 { + startOffset := ssz.ReadOffset(sszSlice4[0:4]) + if startOffset == 0 { + return fmt.Errorf("encountered invalid offset of 0 when decoding c.AttesterSlashings") + } + if startOffset%4 != 0 { + return fmt.Errorf("misaligned list bytes: when decoding c.AttesterSlashings, end-of-list offset is %d, which is not a multiple of 4 (offset size)", startOffset) + } + listLen := startOffset / 4 + if listLen > 1 { + return fmt.Errorf("ssz-max exceeded: c.AttesterSlashings has %d elements, ssz-max is 1: %w", listLen, ssz.ErrListTooBig) + } + totalVarBytes := uint64(len(sszSlice4)) + if totalVarBytes < startOffset { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.AttesterSlashings") + } + c.AttesterSlashings = make([]*AttesterSlashingElectra, listLen) + var tmpSlice []byte + for i := uint64(0); i < listLen; i++ { + var tmp *AttesterSlashingElectra + tmp = new(AttesterSlashingElectra) + endOffset := totalVarBytes + if i+1 != listLen { + endOffset = ssz.ReadOffset(sszSlice4[(i+1)*4 : (i+2)*4]) + if totalVarBytes < endOffset { + return fmt.Errorf("offset %d points past the end of buffer when decoding c.AttesterSlashings", endOffset) + } + } + if endOffset < startOffset { + return fmt.Errorf("offset %d is not greater than start offset %d when decoding c.AttesterSlashings", endOffset, startOffset) + } + tmpSlice = sszSlice4[startOffset:endOffset] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("AttesterSlashings: %w", err) + } + c.AttesterSlashings[i] = tmp + startOffset = endOffset } - if err = b.AttesterSlashings[indx].UnmarshalSSZ(buf); err != nil { - return err + } else { + if len(sszSlice4) > 0 { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.AttesterSlashings") } - return nil - }) - if err != nil { - return err + c.AttesterSlashings = make([]*AttesterSlashingElectra, 0) } } - // Field (5) 'Attestations' + // Field 5: Attestations { - buf = tail[o5:o6] - num, err := ssz.DecodeDynamicLength(buf, 8) - if err != nil { - return err - } - b.Attestations = make([]*AttestationElectra, num) - err = ssz.UnmarshalDynamic(buf, num, func(indx int, buf []byte) (err error) { - if b.Attestations[indx] == nil { - b.Attestations[indx] = new(AttestationElectra) + // empty lists are zero length, so make sure there is room for an offset + // before attempting to unmarshal it + if len(sszSlice5) > 3 { + startOffset := ssz.ReadOffset(sszSlice5[0:4]) + if startOffset == 0 { + return fmt.Errorf("encountered invalid offset of 0 when decoding c.Attestations") } - if err = b.Attestations[indx].UnmarshalSSZ(buf); err != nil { - return err + if startOffset%4 != 0 { + return fmt.Errorf("misaligned list bytes: when decoding c.Attestations, end-of-list offset is %d, which is not a multiple of 4 (offset size)", startOffset) } - return nil - }) - if err != nil { - return err + listLen := startOffset / 4 + if listLen > 8 { + return fmt.Errorf("ssz-max exceeded: c.Attestations has %d elements, ssz-max is 8: %w", listLen, ssz.ErrListTooBig) + } + totalVarBytes := uint64(len(sszSlice5)) + if totalVarBytes < startOffset { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.Attestations") + } + c.Attestations = make([]*AttestationElectra, listLen) + var tmpSlice []byte + for i := uint64(0); i < listLen; i++ { + var tmp *AttestationElectra + tmp = new(AttestationElectra) + endOffset := totalVarBytes + if i+1 != listLen { + endOffset = ssz.ReadOffset(sszSlice5[(i+1)*4 : (i+2)*4]) + if totalVarBytes < endOffset { + return fmt.Errorf("offset %d points past the end of buffer when decoding c.Attestations", endOffset) + } + } + if endOffset < startOffset { + return fmt.Errorf("offset %d is not greater than start offset %d when decoding c.Attestations", endOffset, startOffset) + } + tmpSlice = sszSlice5[startOffset:endOffset] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Attestations: %w", err) + } + c.Attestations[i] = tmp + startOffset = endOffset + } + } else { + if len(sszSlice5) > 0 { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.Attestations") + } + c.Attestations = make([]*AttestationElectra, 0) } } - // Field (6) 'Deposits' + // Field 6: Deposits { - buf = tail[o6:o7] - num, err := ssz.DivideInt2(len(buf), 1240, 16) - if err != nil { - return err - } - b.Deposits = make([]*Deposit, num) - for ii := 0; ii < num; ii++ { - if b.Deposits[ii] == nil { - b.Deposits[ii] = new(Deposit) - } - if err = b.Deposits[ii].UnmarshalSSZ(buf[ii*1240 : (ii+1)*1240]); err != nil { - return err + if len(sszSlice6)%1240 != 0 { + return fmt.Errorf("misaligned bytes: c.Deposits length is %d, which is not a multiple of 1240: %w", len(sszSlice6), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice6) / 1240 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.Deposits has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.Deposits = make([]*Deposit, numElem) + for i := 0; i < numElem; i++ { + var tmp *Deposit + tmp = new(Deposit) + tmpSlice := sszSlice6[i*1240 : (1+i)*1240] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Deposits: %w", err) } + c.Deposits[i] = tmp } } - // Field (7) 'VoluntaryExits' + // Field 7: VoluntaryExits { - buf = tail[o7:o9] - num, err := ssz.DivideInt2(len(buf), 112, 16) - if err != nil { - return err - } - b.VoluntaryExits = make([]*SignedVoluntaryExit, num) - for ii := 0; ii < num; ii++ { - if b.VoluntaryExits[ii] == nil { - b.VoluntaryExits[ii] = new(SignedVoluntaryExit) - } - if err = b.VoluntaryExits[ii].UnmarshalSSZ(buf[ii*112 : (ii+1)*112]); err != nil { - return err + if len(sszSlice7)%112 != 0 { + return fmt.Errorf("misaligned bytes: c.VoluntaryExits length is %d, which is not a multiple of 112: %w", len(sszSlice7), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice7) / 112 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.VoluntaryExits has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.VoluntaryExits = make([]*SignedVoluntaryExit, numElem) + for i := 0; i < numElem; i++ { + var tmp *SignedVoluntaryExit + tmp = new(SignedVoluntaryExit) + tmpSlice := sszSlice7[i*112 : (1+i)*112] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("VoluntaryExits: %w", err) } + c.VoluntaryExits[i] = tmp } } - // Field (9) 'ExecutionPayloadHeader' - { - buf = tail[o9:o10] - if b.ExecutionPayloadHeader == nil { - b.ExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderDeneb) - } - if err = b.ExecutionPayloadHeader.UnmarshalSSZ(buf); err != nil { - return err - } + // Field 8: SyncAggregate + c.SyncAggregate = new(SyncAggregate) + if err = c.SyncAggregate.UnmarshalSSZ(sszSlice8); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) } - // Field (10) 'BlsToExecutionChanges' - { - buf = tail[o10:o11] - num, err := ssz.DivideInt2(len(buf), 172, 16) - if err != nil { - return err - } - b.BlsToExecutionChanges = make([]*SignedBLSToExecutionChange, num) - for ii := 0; ii < num; ii++ { - if b.BlsToExecutionChanges[ii] == nil { - b.BlsToExecutionChanges[ii] = new(SignedBLSToExecutionChange) - } - if err = b.BlsToExecutionChanges[ii].UnmarshalSSZ(buf[ii*172 : (ii+1)*172]); err != nil { - return err - } - } + // Field 9: ExecutionPayloadHeader + c.ExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderDeneb) + if err = c.ExecutionPayloadHeader.UnmarshalSSZ(sszSlice9); err != nil { + return fmt.Errorf("ExecutionPayloadHeader: %w", err) } - // Field (11) 'BlobKzgCommitments' + // Field 10: BlsToExecutionChanges { - buf = tail[o11:o12] - num, err := ssz.DivideInt2(len(buf), 48, 4096) - if err != nil { - return err - } - b.BlobKzgCommitments = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(b.BlobKzgCommitments[ii]) == 0 { - b.BlobKzgCommitments[ii] = make([]byte, 0, len(buf[ii*48:(ii+1)*48])) + if len(sszSlice10)%172 != 0 { + return fmt.Errorf("misaligned bytes: c.BlsToExecutionChanges length is %d, which is not a multiple of 172: %w", len(sszSlice10), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice10) / 172 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.BlsToExecutionChanges has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.BlsToExecutionChanges = make([]*SignedBLSToExecutionChange, numElem) + for i := 0; i < numElem; i++ { + var tmp *SignedBLSToExecutionChange + tmp = new(SignedBLSToExecutionChange) + tmpSlice := sszSlice10[i*172 : (1+i)*172] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("BlsToExecutionChanges: %w", err) } - b.BlobKzgCommitments[ii] = append(b.BlobKzgCommitments[ii], buf[ii*48:(ii+1)*48]...) + c.BlsToExecutionChanges[i] = tmp } } - // Field (12) 'ExecutionRequests' + // Field 11: BlobKzgCommitments { - buf = tail[o12:] - if b.ExecutionRequests == nil { - b.ExecutionRequests = new(v1.ExecutionRequests) + if len(sszSlice11)%48 != 0 { + return fmt.Errorf("misaligned bytes: c.BlobKzgCommitments length is %d, which is not a multiple of 48: %w", len(sszSlice11), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice11) / 48 + if numElem > 4096 { + return fmt.Errorf("ssz-max exceeded: c.BlobKzgCommitments has %d elements, ssz-max is 4096: %w", numElem, ssz.ErrListTooBig) } - if err = b.ExecutionRequests.UnmarshalSSZ(buf); err != nil { - return err + c.BlobKzgCommitments = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte + + tmpSlice := sszSlice11[i*48 : (1+i)*48] + tmp = make([]byte, 0, 48) + tmp = append(tmp, tmpSlice...) + c.BlobKzgCommitments[i] = tmp } } + + // Field 12: ExecutionRequests + c.ExecutionRequests = new(v1.ExecutionRequests) + if err = c.ExecutionRequests.UnmarshalSSZ(sszSlice12); err != nil { + return fmt.Errorf("ExecutionRequests: %w", err) + } return err } -// SizeSSZ returns the ssz encoded size in bytes for the BlindedBeaconBlockBodyElectra object -func (b *BlindedBeaconBlockBodyElectra) SizeSSZ() (size int) { - size = 336 - - // 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() +func (c *BlindedBeaconBlockBodyElectra) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (5) 'Attestations' - for ii := 0; ii < len(b.Attestations); ii++ { - size += 4 - size += b.Attestations[ii].SizeSSZ() +func (c *BlindedBeaconBlockBodyElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: RandaoReveal + if len(c.RandaoReveal) != 96 { + return ssz.ErrBytesLength } - - // Field (6) 'Deposits' - size += len(b.Deposits) * 1240 - - // Field (7) 'VoluntaryExits' - size += len(b.VoluntaryExits) * 112 - - // Field (9) 'ExecutionPayloadHeader' - if b.ExecutionPayloadHeader == nil { - b.ExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderDeneb) - } - size += b.ExecutionPayloadHeader.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(v1.ExecutionRequests) + hh.PutBytes(c.RandaoReveal) + // Field 1: Eth1Data + if err := c.Eth1Data.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Eth1Data: %w", err) } - size += b.ExecutionRequests.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the BlindedBeaconBlockBodyElectra object -func (b *BlindedBeaconBlockBodyElectra) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) -} - -// HashTreeRootWith ssz hashes the BlindedBeaconBlockBodyElectra object with a hasher -func (b *BlindedBeaconBlockBodyElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'RandaoReveal' - if size := len(b.RandaoReveal); size != 96 { - err = ssz.ErrBytesLengthFn("--.RandaoReveal", size, 96) - return - } - hh.PutBytes(b.RandaoReveal) - - // Field (1) 'Eth1Data' - if err = b.Eth1Data.HashTreeRootWith(hh); err != nil { - return + // Field 2: Graffiti + if len(c.Graffiti) != 32 { + return ssz.ErrBytesLength } - - // Field (2) 'Graffiti' - if size := len(b.Graffiti); size != 32 { - err = ssz.ErrBytesLengthFn("--.Graffiti", size, 32) - return - } - hh.PutBytes(b.Graffiti) - - // Field (3) 'ProposerSlashings' + hh.PutBytes(c.Graffiti) + // Field 3: ProposerSlashings { + if len(c.ProposerSlashings) > 16 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.ProposerSlashings { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ProposerSlashings: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.ProposerSlashings)), 16) } - - // Field (4) 'AttesterSlashings' + // Field 4: AttesterSlashings { + if len(c.AttesterSlashings) > 1 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.AttesterSlashings { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("AttesterSlashings: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 1) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.AttesterSlashings)), 1) } - - // Field (5) 'Attestations' + // Field 5: Attestations { + if len(c.Attestations) > 8 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.Attestations { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Attestations: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 8) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Attestations)), 8) } - - // Field (6) 'Deposits' + // Field 6: Deposits { + if len(c.Deposits) > 16 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.Deposits { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Deposits: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Deposits)), 16) } - - // Field (7) 'VoluntaryExits' + // Field 7: VoluntaryExits { + if len(c.VoluntaryExits) > 16 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.VoluntaryExits { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("VoluntaryExits: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.VoluntaryExits)), 16) } - - // Field (8) 'SyncAggregate' - if err = b.SyncAggregate.HashTreeRootWith(hh); err != nil { - return + // Field 8: SyncAggregate + if err := c.SyncAggregate.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) } - - // Field (9) 'ExecutionPayloadHeader' - if err = b.ExecutionPayloadHeader.HashTreeRootWith(hh); err != nil { - return + // Field 9: ExecutionPayloadHeader + if err := c.ExecutionPayloadHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ExecutionPayloadHeader: %w", err) } - - // Field (10) 'BlsToExecutionChanges' + // Field 10: BlsToExecutionChanges { + if len(c.BlsToExecutionChanges) > 16 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.BlsToExecutionChanges { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("BlsToExecutionChanges: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.BlsToExecutionChanges)), 16) } - - // Field (11) 'BlobKzgCommitments' + // Field 11: BlobKzgCommitments { - if size := len(b.BlobKzgCommitments); size > 4096 { - err = ssz.ErrListTooBigFn("--.BlobKzgCommitments", size, 4096) - return + if len(c.BlobKzgCommitments) > 4096 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range b.BlobKzgCommitments { - if len(i) != 48 { - err = ssz.ErrBytesLength - return + for _, o := range c.BlobKzgCommitments { + if len(o) != 48 { + return ssz.ErrBytesLength } - hh.PutBytes(i) + hh.PutBytes(o) } - - numItems := uint64(len(b.BlobKzgCommitments)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.BlobKzgCommitments)), 4096) } - - // Field (12) 'ExecutionRequests' - if err = b.ExecutionRequests.HashTreeRootWith(hh); err != nil { - return + // Field 12: ExecutionRequests + if err := c.ExecutionRequests.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ExecutionRequests: %w", err) } - hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the AttesterSlashingElectra object -func (a *AttesterSlashingElectra) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(a) +func (c *BlindedBeaconBlockElectra) SizeSSZ() int { + size := 84 + if c.Body == nil { + c.Body = new(BlindedBeaconBlockBodyElectra) + } + size += c.Body.SizeSSZ() + return size } -// MarshalSSZTo ssz marshals the AttesterSlashingElectra object to a target array -func (a *AttesterSlashingElectra) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(8) +func (c *BlindedBeaconBlockElectra) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Offset (0) 'Attestation_1' - dst = ssz.WriteOffset(dst, offset) - if a.Attestation_1 == nil { - a.Attestation_1 = new(IndexedAttestationElectra) +func (c *BlindedBeaconBlockElectra) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 84 + + // Field 0: Slot + if dst, err = c.Slot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Slot: %w", err) } - offset += a.Attestation_1.SizeSSZ() - // Offset (1) 'Attestation_2' - dst = ssz.WriteOffset(dst, offset) - if a.Attestation_2 == nil { - a.Attestation_2 = new(IndexedAttestationElectra) + // Field 1: ProposerIndex + if dst, err = c.ProposerIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ProposerIndex: %w", err) } - offset += a.Attestation_2.SizeSSZ() - // Field (0) 'Attestation_1' - if dst, err = a.Attestation_1.MarshalSSZTo(dst); err != nil { - return + // Field 2: ParentRoot + if len(c.ParentRoot) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.ParentRoot...) - // Field (1) 'Attestation_2' - if dst, err = a.Attestation_2.MarshalSSZTo(dst); err != nil { - return + // Field 3: StateRoot + if len(c.StateRoot) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.StateRoot...) + + // Field 4: Body + if c.Body == nil { + c.Body = new(BlindedBeaconBlockBodyElectra) + } + dst = ssz.WriteOffset(dst, offset) + offset += c.Body.SizeSSZ() - return + // Field 4: Body + if dst, err = c.Body.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Body: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the AttesterSlashingElectra object -func (a *AttesterSlashingElectra) UnmarshalSSZ(buf []byte) error { +func (c *BlindedBeaconBlockElectra) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 8 { + if size < 84 { return ssz.ErrSize } - tail := buf - var o0, o1 uint64 + sszSlice0 := buf[0:8] // c.Slot + sszSlice1 := buf[8:16] // c.ProposerIndex + sszSlice2 := buf[16:48] // c.ParentRoot + sszSlice3 := buf[48:80] // c.StateRoot - // Offset (0) 'Attestation_1' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } - - if o0 != 8 { + sszVarOffset4 := ssz.ReadOffset(buf[80:84]) // c.Body + if sszVarOffset4 != 84 { return ssz.ErrInvalidVariableOffset } - - // Offset (1) 'Attestation_2' - if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 { + if sszVarOffset4 > size { return ssz.ErrOffset } + sszSlice4 := buf[sszVarOffset4:] // c.Body - // Field (0) 'Attestation_1' - { - buf = tail[o0:o1] - if a.Attestation_1 == nil { - a.Attestation_1 = new(IndexedAttestationElectra) - } - if err = a.Attestation_1.UnmarshalSSZ(buf); err != nil { - return err - } + // Field 0: Slot + if err = c.Slot.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Slot: %w", err) } - // Field (1) 'Attestation_2' - { - buf = tail[o1:] - if a.Attestation_2 == nil { - a.Attestation_2 = new(IndexedAttestationElectra) - } - if err = a.Attestation_2.UnmarshalSSZ(buf); err != nil { - return err - } + // Field 1: ProposerIndex + if err = c.ProposerIndex.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("ProposerIndex: %w", err) } - return err -} -// SizeSSZ returns the ssz encoded size in bytes for the AttesterSlashingElectra object -func (a *AttesterSlashingElectra) SizeSSZ() (size int) { - size = 8 + // Field 2: ParentRoot + c.ParentRoot = make([]byte, 0, 32) + c.ParentRoot = append(c.ParentRoot, sszSlice2...) - // Field (0) 'Attestation_1' - if a.Attestation_1 == nil { - a.Attestation_1 = new(IndexedAttestationElectra) - } - size += a.Attestation_1.SizeSSZ() + // Field 3: StateRoot + c.StateRoot = make([]byte, 0, 32) + c.StateRoot = append(c.StateRoot, sszSlice3...) - // Field (1) 'Attestation_2' - if a.Attestation_2 == nil { - a.Attestation_2 = new(IndexedAttestationElectra) + // Field 4: Body + c.Body = new(BlindedBeaconBlockBodyElectra) + if err = c.Body.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("Body: %w", err) } - size += a.Attestation_2.SizeSSZ() - - return + return err } -// HashTreeRoot ssz hashes the AttesterSlashingElectra object -func (a *AttesterSlashingElectra) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(a) +func (c *BlindedBeaconBlockElectra) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the AttesterSlashingElectra object with a hasher -func (a *AttesterSlashingElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *BlindedBeaconBlockElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Attestation_1' - if err = a.Attestation_1.HashTreeRootWith(hh); err != nil { - return + // Field 0: Slot + if err := c.Slot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Slot: %w", err) } - - // Field (1) 'Attestation_2' - if err = a.Attestation_2.HashTreeRootWith(hh); err != nil { - return + // Field 1: ProposerIndex + if err := c.ProposerIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ProposerIndex: %w", err) + } + // Field 2: ParentRoot + if len(c.ParentRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ParentRoot) + // Field 3: StateRoot + if len(c.StateRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.StateRoot) + // Field 4: Body + if err := c.Body.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Body: %w", err) } - hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the IndexedAttestationElectra object -func (i *IndexedAttestationElectra) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(i) +func (c *BuilderBidElectra) SizeSSZ() int { + size := 92 + if c.Header == nil { + c.Header = new(v1.ExecutionPayloadHeaderDeneb) + } + size += c.Header.SizeSSZ() + size += len(c.BlobKzgCommitments) * 48 + if c.ExecutionRequests == nil { + c.ExecutionRequests = new(v1.ExecutionRequests) + } + size += c.ExecutionRequests.SizeSSZ() + return size } -// MarshalSSZTo ssz marshals the IndexedAttestationElectra object to a target array -func (i *IndexedAttestationElectra) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(228) +func (c *BuilderBidElectra) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Offset (0) 'AttestingIndices' +func (c *BuilderBidElectra) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 92 + + // Field 0: Header + if c.Header == nil { + c.Header = new(v1.ExecutionPayloadHeaderDeneb) + } + dst = ssz.WriteOffset(dst, offset) + offset += c.Header.SizeSSZ() + + // Field 1: BlobKzgCommitments + dst = ssz.WriteOffset(dst, offset) + offset += len(c.BlobKzgCommitments) * 48 + + // Field 2: ExecutionRequests + if c.ExecutionRequests == nil { + c.ExecutionRequests = new(v1.ExecutionRequests) + } dst = ssz.WriteOffset(dst, offset) - offset += len(i.AttestingIndices) * 8 + offset += c.ExecutionRequests.SizeSSZ() - // Field (1) 'Data' - if i.Data == nil { - i.Data = new(AttestationData) + // Field 3: Value + if len(c.Value) != 32 { + return nil, ssz.ErrBytesLength } - if dst, err = i.Data.MarshalSSZTo(dst); err != nil { - return + dst = append(dst, c.Value...) + + // Field 4: Pubkey + if len(c.Pubkey) != 48 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.Pubkey...) - // Field (2) 'Signature' - if size := len(i.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 0: Header + if dst, err = c.Header.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Header: %w", err) } - dst = append(dst, i.Signature...) - // Field (0) 'AttestingIndices' - if size := len(i.AttestingIndices); size > 8192 { - err = ssz.ErrListTooBigFn("--.AttestingIndices", size, 8192) - return + // Field 1: BlobKzgCommitments + if len(c.BlobKzgCommitments) > 4096 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(i.AttestingIndices); ii++ { - dst = ssz.MarshalUint(dst, i.AttestingIndices[ii]) + for _, o := range c.BlobKzgCommitments { + if len(o) != 48 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) } - return + // Field 2: ExecutionRequests + if dst, err = c.ExecutionRequests.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ExecutionRequests: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the IndexedAttestationElectra object -func (i *IndexedAttestationElectra) UnmarshalSSZ(buf []byte) error { +func (c *BuilderBidElectra) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 228 { + if size < 92 { return ssz.ErrSize } - tail := buf - var o0 uint64 + sszSlice3 := buf[12:44] // c.Value + sszSlice4 := buf[44:92] // c.Pubkey - // Offset (0) 'AttestingIndices' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } - - if o0 != 228 { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Header + if sszVarOffset0 != 92 { return ssz.ErrInvalidVariableOffset } - - // Field (1) 'Data' - if i.Data == nil { - i.Data = new(AttestationData) + if sszVarOffset0 > size { + return ssz.ErrOffset } - if err = i.Data.UnmarshalSSZ(buf[4:132]); err != nil { - return err + sszVarOffset1 := ssz.ReadOffset(buf[4:8]) // c.BlobKzgCommitments + if sszVarOffset1 > size || sszVarOffset1 < sszVarOffset0 { + return ssz.ErrOffset } + sszVarOffset2 := ssz.ReadOffset(buf[8:12]) // c.ExecutionRequests + if sszVarOffset2 > size || sszVarOffset2 < sszVarOffset1 { + return ssz.ErrOffset + } + sszSlice0 := buf[sszVarOffset0:sszVarOffset1] // c.Header + sszSlice1 := buf[sszVarOffset1:sszVarOffset2] // c.BlobKzgCommitments + sszSlice2 := buf[sszVarOffset2:] // c.ExecutionRequests - // Field (2) 'Signature' - if cap(i.Signature) == 0 { - i.Signature = make([]byte, 0, len(buf[132:228])) + // Field 0: Header + c.Header = new(v1.ExecutionPayloadHeaderDeneb) + if err = c.Header.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Header: %w", err) } - i.Signature = append(i.Signature, buf[132:228]...) - // Field (0) 'AttestingIndices' + // Field 1: BlobKzgCommitments { - buf = tail[o0:] - num, err := ssz.DivideInt2(len(buf), 8, 8192) - if err != nil { - return err + if len(sszSlice1)%48 != 0 { + return fmt.Errorf("misaligned bytes: c.BlobKzgCommitments length is %d, which is not a multiple of 48: %w", len(sszSlice1), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice1) / 48 + if numElem > 4096 { + return fmt.Errorf("ssz-max exceeded: c.BlobKzgCommitments has %d elements, ssz-max is 4096: %w", numElem, ssz.ErrListTooBig) } - i.AttestingIndices = ssz.ExtendUint(i.AttestingIndices, num) - for ii := 0; ii < num; ii++ { - i.AttestingIndices[ii] = ssz.UnmarshallUint[uint64](buf[ii*8 : (ii+1)*8]) + c.BlobKzgCommitments = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte + + tmpSlice := sszSlice1[i*48 : (1+i)*48] + tmp = make([]byte, 0, 48) + tmp = append(tmp, tmpSlice...) + c.BlobKzgCommitments[i] = tmp } } - return err -} -// SizeSSZ returns the ssz encoded size in bytes for the IndexedAttestationElectra object -func (i *IndexedAttestationElectra) SizeSSZ() (size int) { - size = 228 + // Field 2: ExecutionRequests + c.ExecutionRequests = new(v1.ExecutionRequests) + if err = c.ExecutionRequests.UnmarshalSSZ(sszSlice2); err != nil { + return fmt.Errorf("ExecutionRequests: %w", err) + } - // Field (0) 'AttestingIndices' - size += len(i.AttestingIndices) * 8 + // Field 3: Value + c.Value = make([]byte, 0, 32) + c.Value = append(c.Value, sszSlice3...) - return + // Field 4: Pubkey + c.Pubkey = make([]byte, 0, 48) + c.Pubkey = append(c.Pubkey, sszSlice4...) + return err } -// HashTreeRoot ssz hashes the IndexedAttestationElectra object -func (i *IndexedAttestationElectra) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(i) +func (c *BuilderBidElectra) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the IndexedAttestationElectra object with a hasher -func (i *IndexedAttestationElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *BuilderBidElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'AttestingIndices' + // Field 0: Header + if err := c.Header.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Header: %w", err) + } + // Field 1: BlobKzgCommitments { - if size := len(i.AttestingIndices); size > 8192 { - err = ssz.ErrListTooBigFn("--.AttestingIndices", size, 8192) - return + if len(c.BlobKzgCommitments) > 4096 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range i.AttestingIndices { - ssz.AppendUint(hh, i) + for _, o := range c.BlobKzgCommitments { + if len(o) != 48 { + return ssz.ErrBytesLength + } + hh.PutBytes(o) } - hh.FillUpTo32() - - numItems := uint64(len(i.AttestingIndices)) - hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(8192, numItems, 8)) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.BlobKzgCommitments)), 4096) } - - // Field (1) 'Data' - if err = i.Data.HashTreeRootWith(hh); err != nil { - return + // Field 2: ExecutionRequests + if err := c.ExecutionRequests.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ExecutionRequests: %w", err) } - - // Field (2) 'Signature' - if size := len(i.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 3: Value + if len(c.Value) != 32 { + return ssz.ErrBytesLength } - hh.PutBytes(i.Signature) - + hh.PutBytes(c.Value) + // Field 4: Pubkey + if len(c.Pubkey) != 48 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Pubkey) hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the BeaconStateElectra object -func (b *BeaconStateElectra) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) +func (c *IndexedAttestationElectra) SizeSSZ() int { + size := 228 + size += len(c.AttestingIndices) * 8 + return size } -// MarshalSSZTo ssz marshals the BeaconStateElectra object to a target array -func (b *BeaconStateElectra) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(10313) - - // Field (0) 'GenesisTime' - dst = ssz.MarshalUint(dst, b.GenesisTime) +func (c *IndexedAttestationElectra) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (1) 'GenesisValidatorsRoot' - if size := len(b.GenesisValidatorsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.GenesisValidatorsRoot", size, 32) - return - } - dst = append(dst, b.GenesisValidatorsRoot...) +func (c *IndexedAttestationElectra) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 228 - // Field (2) 'Slot' - dst = ssz.MarshalUint(dst, b.Slot) + // Field 0: AttestingIndices + dst = ssz.WriteOffset(dst, offset) + offset += len(c.AttestingIndices) * 8 - // Field (3) 'Fork' - if b.Fork == nil { - b.Fork = new(Fork) + // Field 1: Data + if c.Data == nil { + c.Data = new(AttestationData) } - if dst, err = b.Fork.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.Data.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Data: %w", err) } - // Field (4) 'LatestBlockHeader' - if b.LatestBlockHeader == nil { - b.LatestBlockHeader = new(BeaconBlockHeader) - } - if dst, err = b.LatestBlockHeader.MarshalSSZTo(dst); err != nil { - return + // Field 2: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.Signature...) - // Field (5) 'BlockRoots' - if size := len(b.BlockRoots); size != 64 { - err = ssz.ErrVectorLengthFn("--.BlockRoots", size, 64) - return + // Field 0: AttestingIndices + if len(c.AttestingIndices) > 8192 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < 64; ii++ { - if size := len(b.BlockRoots[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockRoots[ii]", size, 32) - return - } - dst = append(dst, b.BlockRoots[ii]...) + for _, o := range c.AttestingIndices { + dst = binary.LittleEndian.AppendUint64(dst, o) } + return dst, err +} - // Field (6) 'StateRoots' - if size := len(b.StateRoots); size != 64 { - err = ssz.ErrVectorLengthFn("--.StateRoots", size, 64) - return - } - for ii := 0; ii < 64; ii++ { - if size := len(b.StateRoots[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoots[ii]", size, 32) - return - } - dst = append(dst, b.StateRoots[ii]...) +func (c *IndexedAttestationElectra) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 228 { + return ssz.ErrSize } - // Offset (7) 'HistoricalRoots' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.HistoricalRoots) * 32 + sszSlice1 := buf[4:132] // c.Data + sszSlice2 := buf[132:228] // c.Signature - // Field (8) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(Eth1Data) + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.AttestingIndices + if sszVarOffset0 != 228 { + return ssz.ErrInvalidVariableOffset } - if dst, err = b.Eth1Data.MarshalSSZTo(dst); err != nil { - return + if sszVarOffset0 > size { + return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:] // c.AttestingIndices - // Offset (9) 'Eth1DataVotes' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.Eth1DataVotes) * 72 - - // Field (10) 'Eth1DepositIndex' - dst = ssz.MarshalUint(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 0: AttestingIndices + { + if len(sszSlice0)%8 != 0 { + return fmt.Errorf("misaligned bytes: c.AttestingIndices length is %d, which is not a multiple of 8: %w", len(sszSlice0), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice0) / 8 + if numElem > 8192 { + return fmt.Errorf("ssz-max exceeded: c.AttestingIndices has %d elements, ssz-max is 8192: %w", numElem, ssz.ErrListTooBig) + } + c.AttestingIndices = make([]uint64, numElem) + for i := 0; i < numElem; i++ { + var tmp uint64 - // Field (13) 'RandaoMixes' - if size := len(b.RandaoMixes); size != 64 { - err = ssz.ErrVectorLengthFn("--.RandaoMixes", size, 64) - return - } - for ii := 0; ii < 64; ii++ { - if size := len(b.RandaoMixes[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.RandaoMixes[ii]", size, 32) - return + tmpSlice := sszSlice0[i*8 : (1+i)*8] + tmp = binary.LittleEndian.Uint64(tmpSlice) + c.AttestingIndices[i] = tmp } - dst = append(dst, b.RandaoMixes[ii]...) } - // Field (14) 'Slashings' - if size := len(b.Slashings); size != 64 { - err = ssz.ErrVectorLengthFn("--.Slashings", size, 64) - return + // Field 1: Data + c.Data = new(AttestationData) + if err = c.Data.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Data: %w", err) } - for ii := 0; ii < 64; ii++ { - dst = ssz.MarshalUint(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 2: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice2...) + return err +} - // Field (17) 'JustificationBits' - if size := len(b.JustificationBits); size != 1 { - err = ssz.ErrBytesLengthFn("--.JustificationBits", size, 1) - return +func (c *IndexedAttestationElectra) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - dst = append(dst, b.JustificationBits...) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (18) 'PreviousJustifiedCheckpoint' - if b.PreviousJustifiedCheckpoint == nil { - b.PreviousJustifiedCheckpoint = new(Checkpoint) - } - if dst, err = b.PreviousJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { - return +func (c *IndexedAttestationElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: AttestingIndices + { + if len(c.AttestingIndices) > 8192 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.AttestingIndices { + hh.AppendUint64(o) + } + hh.FillUpTo32() + numItems := uint64(len(c.AttestingIndices)) + hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(8192, numItems, 8)) } - - // Field (19) 'CurrentJustifiedCheckpoint' - if b.CurrentJustifiedCheckpoint == nil { - b.CurrentJustifiedCheckpoint = new(Checkpoint) + // Field 1: Data + if err := c.Data.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Data: %w", err) } - if dst, err = b.CurrentJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { - return + // Field 2: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength } + hh.PutBytes(c.Signature) + hh.Merkleize(indx) + return nil +} - // Field (20) 'FinalizedCheckpoint' - if b.FinalizedCheckpoint == nil { - b.FinalizedCheckpoint = new(Checkpoint) +func (c *LightClientBootstrapElectra) SizeSSZ() int { + size := 1780 + if c.Header == nil { + c.Header = new(LightClientHeaderDeneb) } - if dst, err = b.FinalizedCheckpoint.MarshalSSZTo(dst); err != nil { - return - } - - // Offset (21) 'InactivityScores' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.InactivityScores) * 8 + size += c.Header.SizeSSZ() + return size +} - // Field (22) 'CurrentSyncCommittee' - if b.CurrentSyncCommittee == nil { - b.CurrentSyncCommittee = new(SyncCommittee) - } - if dst, err = b.CurrentSyncCommittee.MarshalSSZTo(dst); err != nil { - return - } +func (c *LightClientBootstrapElectra) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (23) 'NextSyncCommittee' - if b.NextSyncCommittee == nil { - b.NextSyncCommittee = new(SyncCommittee) - } - if dst, err = b.NextSyncCommittee.MarshalSSZTo(dst); err != nil { - return - } +func (c *LightClientBootstrapElectra) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 1780 - // Offset (24) 'LatestExecutionPayloadHeader' - dst = ssz.WriteOffset(dst, offset) - if b.LatestExecutionPayloadHeader == nil { - b.LatestExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderDeneb) + // Field 0: Header + if c.Header == nil { + c.Header = new(LightClientHeaderDeneb) } - offset += b.LatestExecutionPayloadHeader.SizeSSZ() - - // Field (25) 'NextWithdrawalIndex' - dst = ssz.MarshalUint(dst, b.NextWithdrawalIndex) - - // Field (26) 'NextWithdrawalValidatorIndex' - dst = ssz.MarshalUint(dst, b.NextWithdrawalValidatorIndex) - - // Offset (27) 'HistoricalSummaries' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.HistoricalSummaries) * 64 - - // Field (28) 'DepositRequestsStartIndex' - dst = ssz.MarshalUint(dst, b.DepositRequestsStartIndex) - - // Field (29) 'DepositBalanceToConsume' - dst = ssz.MarshalUint(dst, b.DepositBalanceToConsume) - - // Field (30) 'ExitBalanceToConsume' - dst = ssz.MarshalUint(dst, b.ExitBalanceToConsume) - - // Field (31) 'EarliestExitEpoch' - dst = ssz.MarshalUint(dst, b.EarliestExitEpoch) - - // Field (32) 'ConsolidationBalanceToConsume' - dst = ssz.MarshalUint(dst, b.ConsolidationBalanceToConsume) - - // Field (33) 'EarliestConsolidationEpoch' - dst = ssz.MarshalUint(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 += c.Header.SizeSSZ() - // Offset (36) 'PendingConsolidations' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.PendingConsolidations) * 16 - - // Field (7) 'HistoricalRoots' - if size := len(b.HistoricalRoots); size > 16777216 { - err = ssz.ErrListTooBigFn("--.HistoricalRoots", size, 16777216) - return + // Field 1: CurrentSyncCommittee + if c.CurrentSyncCommittee == nil { + c.CurrentSyncCommittee = new(SyncCommittee) } - for ii := 0; ii < len(b.HistoricalRoots); ii++ { - if size := len(b.HistoricalRoots[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.HistoricalRoots[ii]", size, 32) - return - } - dst = append(dst, b.HistoricalRoots[ii]...) + if dst, err = c.CurrentSyncCommittee.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("CurrentSyncCommittee: %w", err) } - // Field (9) 'Eth1DataVotes' - if size := len(b.Eth1DataVotes); size > 32 { - err = ssz.ErrListTooBigFn("--.Eth1DataVotes", size, 32) - return + // Field 2: CurrentSyncCommitteeBranch + if len(c.CurrentSyncCommitteeBranch) != 6 { + return nil, ssz.ErrBytesLength } - for ii := 0; ii < len(b.Eth1DataVotes); ii++ { - if dst, err = b.Eth1DataVotes[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.CurrentSyncCommitteeBranch { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, o...) } - // Field (11) 'Validators' - if size := len(b.Validators); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.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("--.Balances", size, 1099511627776) - return - } - for ii := 0; ii < len(b.Balances); ii++ { - dst = ssz.MarshalUint(dst, b.Balances[ii]) + // Field 0: Header + if dst, err = c.Header.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Header: %w", err) } + return dst, err +} - // Field (15) 'PreviousEpochParticipation' - if size := len(b.PreviousEpochParticipation); size > 1099511627776 { - err = ssz.ErrBytesLengthFn("--.PreviousEpochParticipation", size, 1099511627776) - return +func (c *LightClientBootstrapElectra) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 1780 { + return ssz.ErrSize } - dst = append(dst, b.PreviousEpochParticipation...) - // Field (16) 'CurrentEpochParticipation' - if size := len(b.CurrentEpochParticipation); size > 1099511627776 { - err = ssz.ErrBytesLengthFn("--.CurrentEpochParticipation", size, 1099511627776) - return - } - dst = append(dst, b.CurrentEpochParticipation...) + sszSlice1 := buf[4:1588] // c.CurrentSyncCommittee + sszSlice2 := buf[1588:1780] // c.CurrentSyncCommitteeBranch - // Field (21) 'InactivityScores' - if size := len(b.InactivityScores); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.InactivityScores", size, 1099511627776) - return + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Header + if sszVarOffset0 != 1780 { + return ssz.ErrInvalidVariableOffset } - for ii := 0; ii < len(b.InactivityScores); ii++ { - dst = ssz.MarshalUint(dst, b.InactivityScores[ii]) + if sszVarOffset0 > size { + return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:] // c.Header - // Field (24) 'LatestExecutionPayloadHeader' - if dst, err = b.LatestExecutionPayloadHeader.MarshalSSZTo(dst); err != nil { - return + // Field 0: Header + c.Header = new(LightClientHeaderDeneb) + if err = c.Header.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Header: %w", err) } - // Field (27) 'HistoricalSummaries' - if size := len(b.HistoricalSummaries); size > 16777216 { - err = ssz.ErrListTooBigFn("--.HistoricalSummaries", size, 16777216) - return + // Field 1: CurrentSyncCommittee + c.CurrentSyncCommittee = new(SyncCommittee) + if err = c.CurrentSyncCommittee.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("CurrentSyncCommittee: %w", err) } - for ii := 0; ii < len(b.HistoricalSummaries); ii++ { - if dst, err = b.HistoricalSummaries[ii].MarshalSSZTo(dst); err != nil { - return + + // Field 2: CurrentSyncCommitteeBranch + { + c.CurrentSyncCommitteeBranch = make([][]byte, 6) + for i := 0; i < 6; i++ { + var tmp []byte + + tmpSlice := sszSlice2[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.CurrentSyncCommitteeBranch[i] = tmp } } + return err +} - // Field (34) 'PendingDeposits' - if size := len(b.PendingDeposits); size > 134217728 { - err = ssz.ErrListTooBigFn("--.PendingDeposits", size, 134217728) - return - } - for ii := 0; ii < len(b.PendingDeposits); ii++ { - if dst, err = b.PendingDeposits[ii].MarshalSSZTo(dst); err != nil { - return - } +func (c *LightClientBootstrapElectra) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (35) 'PendingPartialWithdrawals' - if size := len(b.PendingPartialWithdrawals); size > 64 { - err = ssz.ErrListTooBigFn("--.PendingPartialWithdrawals", size, 64) - return +func (c *LightClientBootstrapElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Header + if err := c.Header.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Header: %w", err) + } + // Field 1: CurrentSyncCommittee + if err := c.CurrentSyncCommittee.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("CurrentSyncCommittee: %w", err) } - for ii := 0; ii < len(b.PendingPartialWithdrawals); ii++ { - if dst, err = b.PendingPartialWithdrawals[ii].MarshalSSZTo(dst); err != nil { - return + // Field 2: CurrentSyncCommitteeBranch + { + if len(c.CurrentSyncCommitteeBranch) != 6 { + return ssz.ErrVectorLength + } + subIndx := hh.Index() + for _, o := range c.CurrentSyncCommitteeBranch { + if len(o) != 32 { + return ssz.ErrBytesLength + } + hh.Append(o) } + hh.Merkleize(subIndx) } + hh.Merkleize(indx) + return nil +} - // Field (36) 'PendingConsolidations' - if size := len(b.PendingConsolidations); size > 64 { - err = ssz.ErrListTooBigFn("--.PendingConsolidations", size, 64) - return +func (c *LightClientUpdateElectra) SizeSSZ() int { + size := 2116 + if c.AttestedHeader == nil { + c.AttestedHeader = new(LightClientHeaderDeneb) } - for ii := 0; ii < len(b.PendingConsolidations); ii++ { - if dst, err = b.PendingConsolidations[ii].MarshalSSZTo(dst); err != nil { - return - } + size += c.AttestedHeader.SizeSSZ() + if c.FinalizedHeader == nil { + c.FinalizedHeader = new(LightClientHeaderDeneb) } + size += c.FinalizedHeader.SizeSSZ() + return size +} - return +func (c *LightClientUpdateElectra) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// UnmarshalSSZ ssz unmarshals the BeaconStateElectra object -func (b *BeaconStateElectra) UnmarshalSSZ(buf []byte) error { +func (c *LightClientUpdateElectra) MarshalSSZTo(dst []byte) ([]byte, error) { var err error - size := uint64(len(buf)) - if size < 10313 { - return ssz.ErrSize - } - - tail := buf - var o7, o9, o11, o12, o15, o16, o21, o24, o27, o34, o35, o36 uint64 + offset := 2116 - // Field (0) 'GenesisTime' - b.GenesisTime = ssz.UnmarshallUint[uint64](buf[0:8]) - - // Field (1) 'GenesisValidatorsRoot' - if cap(b.GenesisValidatorsRoot) == 0 { - b.GenesisValidatorsRoot = make([]byte, 0, len(buf[8:40])) + // Field 0: AttestedHeader + if c.AttestedHeader == nil { + c.AttestedHeader = new(LightClientHeaderDeneb) } - b.GenesisValidatorsRoot = append(b.GenesisValidatorsRoot, buf[8:40]...) - - // Field (2) 'Slot' - b.Slot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[40:48]) + dst = ssz.WriteOffset(dst, offset) + offset += c.AttestedHeader.SizeSSZ() - // Field (3) 'Fork' - if b.Fork == nil { - b.Fork = new(Fork) + // Field 1: NextSyncCommittee + if c.NextSyncCommittee == nil { + c.NextSyncCommittee = new(SyncCommittee) } - if err = b.Fork.UnmarshalSSZ(buf[48:64]); err != nil { - return err + if dst, err = c.NextSyncCommittee.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("NextSyncCommittee: %w", err) } - // Field (4) 'LatestBlockHeader' - if b.LatestBlockHeader == nil { - b.LatestBlockHeader = new(BeaconBlockHeader) + // Field 2: NextSyncCommitteeBranch + if len(c.NextSyncCommitteeBranch) != 6 { + return nil, ssz.ErrBytesLength } - if err = b.LatestBlockHeader.UnmarshalSSZ(buf[64:176]); err != nil { - return err - } - - // Field (5) 'BlockRoots' - b.BlockRoots = make([][]byte, 64) - for ii := 0; ii < 64; ii++ { - if cap(b.BlockRoots[ii]) == 0 { - b.BlockRoots[ii] = make([]byte, 0, len(buf[176:2224][ii*32:(ii+1)*32])) + for _, o := range c.NextSyncCommitteeBranch { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } - b.BlockRoots[ii] = append(b.BlockRoots[ii], buf[176:2224][ii*32:(ii+1)*32]...) + dst = append(dst, o...) } - // Field (6) 'StateRoots' - b.StateRoots = make([][]byte, 64) - for ii := 0; ii < 64; ii++ { - if cap(b.StateRoots[ii]) == 0 { - b.StateRoots[ii] = make([]byte, 0, len(buf[2224:4272][ii*32:(ii+1)*32])) - } - b.StateRoots[ii] = append(b.StateRoots[ii], buf[2224:4272][ii*32:(ii+1)*32]...) + // Field 3: FinalizedHeader + if c.FinalizedHeader == nil { + c.FinalizedHeader = new(LightClientHeaderDeneb) } + dst = ssz.WriteOffset(dst, offset) + offset += c.FinalizedHeader.SizeSSZ() - // Offset (7) 'HistoricalRoots' - if o7 = ssz.ReadOffset(buf[4272:4276]); o7 > size { - return ssz.ErrOffset + // Field 4: FinalityBranch + if len(c.FinalityBranch) != 7 { + return nil, ssz.ErrBytesLength } - - if o7 != 10313 { - return ssz.ErrInvalidVariableOffset + for _, o := range c.FinalityBranch { + if len(o) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) } - // Field (8) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(Eth1Data) + // Field 5: SyncAggregate + if c.SyncAggregate == nil { + c.SyncAggregate = new(SyncAggregate) } - if err = b.Eth1Data.UnmarshalSSZ(buf[4276:4348]); err != nil { - return err + if dst, err = c.SyncAggregate.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SyncAggregate: %w", err) } - // Offset (9) 'Eth1DataVotes' - if o9 = ssz.ReadOffset(buf[4348:4352]); o9 > size || o7 > o9 { - return ssz.ErrOffset + // Field 6: SignatureSlot + if dst, err = c.SignatureSlot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SignatureSlot: %w", err) } - // Field (10) 'Eth1DepositIndex' - b.Eth1DepositIndex = ssz.UnmarshallUint[uint64](buf[4352:4360]) - - // Offset (11) 'Validators' - if o11 = ssz.ReadOffset(buf[4360:4364]); o11 > size || o9 > o11 { - return ssz.ErrOffset + // Field 0: AttestedHeader + if dst, err = c.AttestedHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("AttestedHeader: %w", err) } - // Offset (12) 'Balances' - if o12 = ssz.ReadOffset(buf[4364:4368]); o12 > size || o11 > o12 { - return ssz.ErrOffset + // Field 3: FinalizedHeader + if dst, err = c.FinalizedHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("FinalizedHeader: %w", err) } + return dst, err +} - // Field (13) 'RandaoMixes' - b.RandaoMixes = make([][]byte, 64) - for ii := 0; ii < 64; ii++ { - if cap(b.RandaoMixes[ii]) == 0 { - b.RandaoMixes[ii] = make([]byte, 0, len(buf[4368:6416][ii*32:(ii+1)*32])) - } - b.RandaoMixes[ii] = append(b.RandaoMixes[ii], buf[4368:6416][ii*32:(ii+1)*32]...) +func (c *LightClientUpdateElectra) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 2116 { + return ssz.ErrSize } - // Field (14) 'Slashings' - b.Slashings = ssz.ExtendUint(b.Slashings, 64) - for ii := 0; ii < 64; ii++ { - b.Slashings[ii] = ssz.UnmarshallUint[uint64](buf[6416:6928][ii*8 : (ii+1)*8]) - } + sszSlice1 := buf[4:1588] // c.NextSyncCommittee + sszSlice2 := buf[1588:1780] // c.NextSyncCommitteeBranch + sszSlice4 := buf[1784:2008] // c.FinalityBranch + sszSlice5 := buf[2008:2108] // c.SyncAggregate + sszSlice6 := buf[2108:2116] // c.SignatureSlot - // Offset (15) 'PreviousEpochParticipation' - if o15 = ssz.ReadOffset(buf[6928:6932]); o15 > size || o12 > o15 { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.AttestedHeader + if sszVarOffset0 != 2116 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset0 > size { return ssz.ErrOffset } - - // Offset (16) 'CurrentEpochParticipation' - if o16 = ssz.ReadOffset(buf[6932:6936]); o16 > size || o15 > o16 { + sszVarOffset3 := ssz.ReadOffset(buf[1780:1784]) // c.FinalizedHeader + if sszVarOffset3 > size || sszVarOffset3 < sszVarOffset0 { return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:sszVarOffset3] // c.AttestedHeader + sszSlice3 := buf[sszVarOffset3:] // c.FinalizedHeader - // Field (17) 'JustificationBits' - if cap(b.JustificationBits) == 0 { - b.JustificationBits = make([]byte, 0, len(buf[6936:6937])) + // Field 0: AttestedHeader + c.AttestedHeader = new(LightClientHeaderDeneb) + if err = c.AttestedHeader.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("AttestedHeader: %w", err) } - b.JustificationBits = append(b.JustificationBits, buf[6936:6937]...) - // Field (18) 'PreviousJustifiedCheckpoint' - if b.PreviousJustifiedCheckpoint == nil { - b.PreviousJustifiedCheckpoint = new(Checkpoint) - } - if err = b.PreviousJustifiedCheckpoint.UnmarshalSSZ(buf[6937:6977]); err != nil { - return err + // Field 1: NextSyncCommittee + c.NextSyncCommittee = new(SyncCommittee) + if err = c.NextSyncCommittee.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("NextSyncCommittee: %w", err) } - // Field (19) 'CurrentJustifiedCheckpoint' - if b.CurrentJustifiedCheckpoint == nil { - b.CurrentJustifiedCheckpoint = new(Checkpoint) - } - if err = b.CurrentJustifiedCheckpoint.UnmarshalSSZ(buf[6977:7017]); err != nil { - return err - } + // Field 2: NextSyncCommitteeBranch + { + c.NextSyncCommitteeBranch = make([][]byte, 6) + for i := 0; i < 6; i++ { + var tmp []byte - // Field (20) 'FinalizedCheckpoint' - if b.FinalizedCheckpoint == nil { - b.FinalizedCheckpoint = new(Checkpoint) - } - if err = b.FinalizedCheckpoint.UnmarshalSSZ(buf[7017:7057]); err != nil { - return err + tmpSlice := sszSlice2[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.NextSyncCommitteeBranch[i] = tmp + } } - // Offset (21) 'InactivityScores' - if o21 = ssz.ReadOffset(buf[7057:7061]); o21 > size || o16 > o21 { - return ssz.ErrOffset + // Field 3: FinalizedHeader + c.FinalizedHeader = new(LightClientHeaderDeneb) + if err = c.FinalizedHeader.UnmarshalSSZ(sszSlice3); err != nil { + return fmt.Errorf("FinalizedHeader: %w", err) } - // Field (22) 'CurrentSyncCommittee' - if b.CurrentSyncCommittee == nil { - b.CurrentSyncCommittee = new(SyncCommittee) - } - if err = b.CurrentSyncCommittee.UnmarshalSSZ(buf[7061:8645]); err != nil { - return err - } + // Field 4: FinalityBranch + { + c.FinalityBranch = make([][]byte, 7) + for i := 0; i < 7; i++ { + var tmp []byte - // Field (23) 'NextSyncCommittee' - if b.NextSyncCommittee == nil { - b.NextSyncCommittee = new(SyncCommittee) - } - if err = b.NextSyncCommittee.UnmarshalSSZ(buf[8645:10229]); err != nil { - return err + tmpSlice := sszSlice4[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.FinalityBranch[i] = tmp + } } - // Offset (24) 'LatestExecutionPayloadHeader' - if o24 = ssz.ReadOffset(buf[10229:10233]); o24 > size || o21 > o24 { - return ssz.ErrOffset + // Field 5: SyncAggregate + c.SyncAggregate = new(SyncAggregate) + if err = c.SyncAggregate.UnmarshalSSZ(sszSlice5); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) } - // Field (25) 'NextWithdrawalIndex' - b.NextWithdrawalIndex = ssz.UnmarshallUint[uint64](buf[10233:10241]) - - // Field (26) 'NextWithdrawalValidatorIndex' - b.NextWithdrawalValidatorIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[10241:10249]) - - // Offset (27) 'HistoricalSummaries' - if o27 = ssz.ReadOffset(buf[10249:10253]); o27 > size || o24 > o27 { - return ssz.ErrOffset + // Field 6: SignatureSlot + if err = c.SignatureSlot.UnmarshalSSZ(sszSlice6); err != nil { + return fmt.Errorf("SignatureSlot: %w", err) } + return err +} - // Field (28) 'DepositRequestsStartIndex' - b.DepositRequestsStartIndex = ssz.UnmarshallUint[uint64](buf[10253:10261]) - - // Field (29) 'DepositBalanceToConsume' - b.DepositBalanceToConsume = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Gwei](buf[10261:10269]) - - // Field (30) 'ExitBalanceToConsume' - b.ExitBalanceToConsume = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Gwei](buf[10269:10277]) - - // Field (31) 'EarliestExitEpoch' - b.EarliestExitEpoch = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Epoch](buf[10277:10285]) - - // Field (32) 'ConsolidationBalanceToConsume' - b.ConsolidationBalanceToConsume = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Gwei](buf[10285:10293]) - - // Field (33) 'EarliestConsolidationEpoch' - b.EarliestConsolidationEpoch = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Epoch](buf[10293:10301]) - - // Offset (34) 'PendingDeposits' - if o34 = ssz.ReadOffset(buf[10301:10305]); o34 > size || o27 > o34 { - return ssz.ErrOffset +func (c *LightClientUpdateElectra) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Offset (35) 'PendingPartialWithdrawals' - if o35 = ssz.ReadOffset(buf[10305:10309]); o35 > size || o34 > o35 { - return ssz.ErrOffset +func (c *LightClientUpdateElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: AttestedHeader + if err := c.AttestedHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("AttestedHeader: %w", err) } - - // Offset (36) 'PendingConsolidations' - if o36 = ssz.ReadOffset(buf[10309:10313]); o36 > size || o35 > o36 { - return ssz.ErrOffset + // Field 1: NextSyncCommittee + if err := c.NextSyncCommittee.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("NextSyncCommittee: %w", err) } - - // Field (7) 'HistoricalRoots' + // Field 2: NextSyncCommitteeBranch { - 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]...) + if len(c.NextSyncCommitteeBranch) != 6 { + return ssz.ErrVectorLength } - } - - // Field (9) 'Eth1DataVotes' - { - buf = tail[o9:o11] - num, err := ssz.DivideInt2(len(buf), 72, 32) - if err != nil { - return err - } - b.Eth1DataVotes = make([]*Eth1Data, num) - for ii := 0; ii < num; ii++ { - if b.Eth1DataVotes[ii] == nil { - b.Eth1DataVotes[ii] = new(Eth1Data) - } - if err = b.Eth1DataVotes[ii].UnmarshalSSZ(buf[ii*72 : (ii+1)*72]); err != nil { - return err + subIndx := hh.Index() + for _, o := range c.NextSyncCommitteeBranch { + if len(o) != 32 { + return ssz.ErrBytesLength } + hh.Append(o) } + hh.Merkleize(subIndx) } - - // Field (11) 'Validators' - { - buf = tail[o11:o12] - num, err := ssz.DivideInt2(len(buf), 121, 1099511627776) - if err != nil { - return err - } - b.Validators = make([]*Validator, num) - for ii := 0; ii < num; ii++ { - if b.Validators[ii] == nil { - b.Validators[ii] = new(Validator) - } - if err = b.Validators[ii].UnmarshalSSZ(buf[ii*121 : (ii+1)*121]); err != nil { - return err - } - } + // Field 3: FinalizedHeader + if err := c.FinalizedHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("FinalizedHeader: %w", err) } - - // Field (12) 'Balances' + // Field 4: FinalityBranch { - buf = tail[o12:o15] - num, err := ssz.DivideInt2(len(buf), 8, 1099511627776) - if err != nil { - return err + if len(c.FinalityBranch) != 7 { + return ssz.ErrVectorLength } - b.Balances = ssz.ExtendUint(b.Balances, num) - for ii := 0; ii < num; ii++ { - b.Balances[ii] = ssz.UnmarshallUint[uint64](buf[ii*8 : (ii+1)*8]) + subIndx := hh.Index() + for _, o := range c.FinalityBranch { + if len(o) != 32 { + return ssz.ErrBytesLength + } + hh.Append(o) } + hh.Merkleize(subIndx) } - - // 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 5: SyncAggregate + if err := c.SyncAggregate.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) } - - // 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 6: SignatureSlot + if err := c.SignatureSlot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SignatureSlot: %w", err) } + hh.Merkleize(indx) + return nil +} - // Field (21) 'InactivityScores' - { - buf = tail[o21:o24] - num, err := ssz.DivideInt2(len(buf), 8, 1099511627776) - if err != nil { - return err - } - b.InactivityScores = ssz.ExtendUint(b.InactivityScores, num) - for ii := 0; ii < num; ii++ { - b.InactivityScores[ii] = ssz.UnmarshallUint[uint64](buf[ii*8 : (ii+1)*8]) - } +func (c *LightClientFinalityUpdateElectra) SizeSSZ() int { + size := 340 + if c.AttestedHeader == nil { + c.AttestedHeader = new(LightClientHeaderDeneb) } - - // Field (24) 'LatestExecutionPayloadHeader' - { - buf = tail[o24:o27] - if b.LatestExecutionPayloadHeader == nil { - b.LatestExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderDeneb) - } - if err = b.LatestExecutionPayloadHeader.UnmarshalSSZ(buf); err != nil { - return err - } + size += c.AttestedHeader.SizeSSZ() + if c.FinalizedHeader == nil { + c.FinalizedHeader = new(LightClientHeaderDeneb) } + size += c.FinalizedHeader.SizeSSZ() + return size +} - // Field (27) 'HistoricalSummaries' - { - buf = tail[o27:o34] - num, err := ssz.DivideInt2(len(buf), 64, 16777216) - if err != nil { - return err - } - b.HistoricalSummaries = make([]*HistoricalSummary, num) - for ii := 0; ii < num; ii++ { - if b.HistoricalSummaries[ii] == nil { - b.HistoricalSummaries[ii] = new(HistoricalSummary) - } - if err = b.HistoricalSummaries[ii].UnmarshalSSZ(buf[ii*64 : (ii+1)*64]); err != nil { - return err - } - } - } +func (c *LightClientFinalityUpdateElectra) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (34) 'PendingDeposits' - { - buf = tail[o34:o35] - num, err := ssz.DivideInt2(len(buf), 192, 134217728) - if err != nil { - return err - } - b.PendingDeposits = make([]*PendingDeposit, num) - for ii := 0; ii < num; ii++ { - if b.PendingDeposits[ii] == nil { - b.PendingDeposits[ii] = new(PendingDeposit) - } - if err = b.PendingDeposits[ii].UnmarshalSSZ(buf[ii*192 : (ii+1)*192]); err != nil { - return err - } - } +func (c *LightClientFinalityUpdateElectra) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 340 + + // Field 0: AttestedHeader + if c.AttestedHeader == nil { + c.AttestedHeader = new(LightClientHeaderDeneb) } + dst = ssz.WriteOffset(dst, offset) + offset += c.AttestedHeader.SizeSSZ() - // Field (35) 'PendingPartialWithdrawals' - { - buf = tail[o35:o36] - num, err := ssz.DivideInt2(len(buf), 24, 64) - if err != nil { - return err - } - b.PendingPartialWithdrawals = make([]*PendingPartialWithdrawal, num) - for ii := 0; ii < num; ii++ { - if b.PendingPartialWithdrawals[ii] == nil { - b.PendingPartialWithdrawals[ii] = new(PendingPartialWithdrawal) - } - if err = b.PendingPartialWithdrawals[ii].UnmarshalSSZ(buf[ii*24 : (ii+1)*24]); err != nil { - return err - } - } + // Field 1: FinalizedHeader + if c.FinalizedHeader == nil { + c.FinalizedHeader = new(LightClientHeaderDeneb) } + dst = ssz.WriteOffset(dst, offset) + offset += c.FinalizedHeader.SizeSSZ() - // Field (36) 'PendingConsolidations' - { - buf = tail[o36:] - num, err := ssz.DivideInt2(len(buf), 16, 64) - if err != nil { - return err - } - b.PendingConsolidations = make([]*PendingConsolidation, num) - for ii := 0; ii < num; ii++ { - if b.PendingConsolidations[ii] == nil { - b.PendingConsolidations[ii] = new(PendingConsolidation) - } - if err = b.PendingConsolidations[ii].UnmarshalSSZ(buf[ii*16 : (ii+1)*16]); err != nil { - return err - } + // Field 2: FinalityBranch + if len(c.FinalityBranch) != 7 { + return nil, ssz.ErrBytesLength + } + for _, o := range c.FinalityBranch { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, o...) } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the BeaconStateElectra object -func (b *BeaconStateElectra) SizeSSZ() (size int) { - size = 10313 - - // 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(v1.ExecutionPayloadHeaderDeneb) + // Field 3: SyncAggregate + if c.SyncAggregate == nil { + c.SyncAggregate = new(SyncAggregate) + } + if dst, err = c.SyncAggregate.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SyncAggregate: %w", err) } - 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 + // Field 4: SignatureSlot + if dst, err = c.SignatureSlot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SignatureSlot: %w", err) + } - return -} + // Field 0: AttestedHeader + if dst, err = c.AttestedHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("AttestedHeader: %w", err) + } -// HashTreeRoot ssz hashes the BeaconStateElectra object -func (b *BeaconStateElectra) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) + // Field 1: FinalizedHeader + if dst, err = c.FinalizedHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("FinalizedHeader: %w", err) + } + return dst, err } -// HashTreeRootWith ssz hashes the BeaconStateElectra object with a hasher -func (b *BeaconStateElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'GenesisTime' - ssz.PutUint(hh, b.GenesisTime) - - // Field (1) 'GenesisValidatorsRoot' - if size := len(b.GenesisValidatorsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.GenesisValidatorsRoot", size, 32) - return +func (c *LightClientFinalityUpdateElectra) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 340 { + return ssz.ErrSize } - hh.PutBytes(b.GenesisValidatorsRoot) - // Field (2) 'Slot' - ssz.PutUint(hh, b.Slot) + sszSlice2 := buf[8:232] // c.FinalityBranch + sszSlice3 := buf[232:332] // c.SyncAggregate + sszSlice4 := buf[332:340] // c.SignatureSlot - // Field (3) 'Fork' - if err = b.Fork.HashTreeRootWith(hh); err != nil { - return + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.AttestedHeader + if sszVarOffset0 != 340 { + return ssz.ErrInvalidVariableOffset } - - // Field (4) 'LatestBlockHeader' - if err = b.LatestBlockHeader.HashTreeRootWith(hh); err != nil { - return + if sszVarOffset0 > size { + return ssz.ErrOffset } + sszVarOffset1 := ssz.ReadOffset(buf[4:8]) // c.FinalizedHeader + if sszVarOffset1 > size || sszVarOffset1 < sszVarOffset0 { + return ssz.ErrOffset + } + sszSlice0 := buf[sszVarOffset0:sszVarOffset1] // c.AttestedHeader + sszSlice1 := buf[sszVarOffset1:] // c.FinalizedHeader - // Field (5) 'BlockRoots' - { - if size := len(b.BlockRoots); size != 64 { - err = ssz.ErrVectorLengthFn("--.BlockRoots", size, 64) - return - } - subIndx := hh.Index() - for _, i := range b.BlockRoots { - if len(i) != 32 { - err = ssz.ErrBytesLength - return - } - hh.Append(i) - } - hh.Merkleize(subIndx) + // Field 0: AttestedHeader + c.AttestedHeader = new(LightClientHeaderDeneb) + if err = c.AttestedHeader.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("AttestedHeader: %w", err) } - // Field (6) 'StateRoots' - { - if size := len(b.StateRoots); size != 64 { - err = ssz.ErrVectorLengthFn("--.StateRoots", size, 64) - return - } - subIndx := hh.Index() - for _, i := range b.StateRoots { - if len(i) != 32 { - err = ssz.ErrBytesLength - return - } - hh.Append(i) - } - hh.Merkleize(subIndx) + // Field 1: FinalizedHeader + c.FinalizedHeader = new(LightClientHeaderDeneb) + if err = c.FinalizedHeader.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("FinalizedHeader: %w", err) } - // Field (7) 'HistoricalRoots' + // Field 2: FinalityBranch { - if size := len(b.HistoricalRoots); size > 16777216 { - err = ssz.ErrListTooBigFn("--.HistoricalRoots", size, 16777216) - return - } - subIndx := hh.Index() - for _, i := range b.HistoricalRoots { - if len(i) != 32 { - err = ssz.ErrBytesLength - return - } - hh.Append(i) - } + c.FinalityBranch = make([][]byte, 7) + for i := 0; i < 7; i++ { + var tmp []byte - numItems := uint64(len(b.HistoricalRoots)) - hh.MerkleizeWithMixin(subIndx, numItems, 16777216) + tmpSlice := sszSlice2[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.FinalityBranch[i] = tmp + } } - // Field (8) 'Eth1Data' - if err = b.Eth1Data.HashTreeRootWith(hh); err != nil { - return + // Field 3: SyncAggregate + c.SyncAggregate = new(SyncAggregate) + if err = c.SyncAggregate.UnmarshalSSZ(sszSlice3); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) } - // Field (9) 'Eth1DataVotes' - { - subIndx := hh.Index() - num := uint64(len(b.Eth1DataVotes)) - if num > 32 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range b.Eth1DataVotes { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } - } - hh.MerkleizeWithMixin(subIndx, num, 32) + // Field 4: SignatureSlot + if err = c.SignatureSlot.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("SignatureSlot: %w", err) } + return err +} - // Field (10) 'Eth1DepositIndex' - ssz.PutUint(hh, 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) +func (c *LightClientFinalityUpdateElectra) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (12) 'Balances' - { - if size := len(b.Balances); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.Balances", size, 1099511627776) - return - } - subIndx := hh.Index() - for _, i := range b.Balances { - ssz.AppendUint(hh, i) - } - hh.FillUpTo32() - - numItems := uint64(len(b.Balances)) - hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(1099511627776, numItems, 8)) +func (c *LightClientFinalityUpdateElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: AttestedHeader + if err := c.AttestedHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("AttestedHeader: %w", err) } - - // Field (13) 'RandaoMixes' + // Field 1: FinalizedHeader + if err := c.FinalizedHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("FinalizedHeader: %w", err) + } + // Field 2: FinalityBranch { - if size := len(b.RandaoMixes); size != 64 { - err = ssz.ErrVectorLengthFn("--.RandaoMixes", size, 64) - return + if len(c.FinalityBranch) != 7 { + return ssz.ErrVectorLength } subIndx := hh.Index() - for _, i := range b.RandaoMixes { - if len(i) != 32 { - err = ssz.ErrBytesLength - return + for _, o := range c.FinalityBranch { + if len(o) != 32 { + return ssz.ErrBytesLength } - hh.Append(i) + hh.Append(o) } hh.Merkleize(subIndx) } - - // Field (14) 'Slashings' - { - if size := len(b.Slashings); size != 64 { - err = ssz.ErrVectorLengthFn("--.Slashings", size, 64) - return - } - subIndx := hh.Index() - for _, i := range b.Slashings { - ssz.AppendUint(hh, i) - } - hh.Merkleize(subIndx) + // Field 3: SyncAggregate + if err := c.SyncAggregate.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) } - - // Field (15) 'PreviousEpochParticipation' - { - elemIndx := hh.Index() - byteLen := uint64(len(b.PreviousEpochParticipation)) - if byteLen > 1099511627776 { - err = ssz.ErrIncorrectListSize - return - } - hh.AppendBytes32(b.PreviousEpochParticipation) - hh.MerkleizeWithMixin(elemIndx, byteLen, (1099511627776+31)/32) + // Field 4: SignatureSlot + if err := c.SignatureSlot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SignatureSlot: %w", err) } + hh.Merkleize(indx) + return nil +} - // Field (16) 'CurrentEpochParticipation' - { - elemIndx := hh.Index() - byteLen := uint64(len(b.CurrentEpochParticipation)) - if byteLen > 1099511627776 { - err = ssz.ErrIncorrectListSize - return - } - hh.AppendBytes32(b.CurrentEpochParticipation) - hh.MerkleizeWithMixin(elemIndx, byteLen, (1099511627776+31)/32) - } +func (c *PendingDeposit) SizeSSZ() int { + size := 192 - // Field (17) 'JustificationBits' - if size := len(b.JustificationBits); size != 1 { - err = ssz.ErrBytesLengthFn("--.JustificationBits", size, 1) - return - } - hh.PutBytes(b.JustificationBits) + return size +} - // Field (18) 'PreviousJustifiedCheckpoint' - if err = b.PreviousJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { - return - } +func (c *PendingDeposit) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (19) 'CurrentJustifiedCheckpoint' - if err = b.CurrentJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { - return - } +func (c *PendingDeposit) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (20) 'FinalizedCheckpoint' - if err = b.FinalizedCheckpoint.HashTreeRootWith(hh); err != nil { - return + // Field 0: PublicKey + if len(c.PublicKey) != 48 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.PublicKey...) - // Field (21) 'InactivityScores' - { - if size := len(b.InactivityScores); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.InactivityScores", size, 1099511627776) - return - } - subIndx := hh.Index() - for _, i := range b.InactivityScores { - ssz.AppendUint(hh, i) - } - hh.FillUpTo32() - - numItems := uint64(len(b.InactivityScores)) - hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(1099511627776, numItems, 8)) + // Field 1: WithdrawalCredentials + if len(c.WithdrawalCredentials) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.WithdrawalCredentials...) - // Field (22) 'CurrentSyncCommittee' - if err = b.CurrentSyncCommittee.HashTreeRootWith(hh); err != nil { - return - } + // Field 2: Amount + dst = binary.LittleEndian.AppendUint64(dst, c.Amount) - // Field (23) 'NextSyncCommittee' - if err = b.NextSyncCommittee.HashTreeRootWith(hh); err != nil { - return + // Field 3: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.Signature...) - // Field (24) 'LatestExecutionPayloadHeader' - if err = b.LatestExecutionPayloadHeader.HashTreeRootWith(hh); err != nil { - return + // Field 4: Slot + if dst, err = c.Slot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Slot: %w", err) } - // Field (25) 'NextWithdrawalIndex' - ssz.PutUint(hh, b.NextWithdrawalIndex) - - // Field (26) 'NextWithdrawalValidatorIndex' - ssz.PutUint(hh, b.NextWithdrawalValidatorIndex) + return dst, err +} - // 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) +func (c *PendingDeposit) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 192 { + return ssz.ErrSize } - // Field (28) 'DepositRequestsStartIndex' - ssz.PutUint(hh, b.DepositRequestsStartIndex) + sszSlice0 := buf[0:48] // c.PublicKey + sszSlice1 := buf[48:80] // c.WithdrawalCredentials + sszSlice2 := buf[80:88] // c.Amount + sszSlice3 := buf[88:184] // c.Signature + sszSlice4 := buf[184:192] // c.Slot - // Field (29) 'DepositBalanceToConsume' - ssz.PutUint(hh, b.DepositBalanceToConsume) + // Field 0: PublicKey + c.PublicKey = make([]byte, 0, 48) + c.PublicKey = append(c.PublicKey, sszSlice0...) - // Field (30) 'ExitBalanceToConsume' - ssz.PutUint(hh, b.ExitBalanceToConsume) + // Field 1: WithdrawalCredentials + c.WithdrawalCredentials = make([]byte, 0, 32) + c.WithdrawalCredentials = append(c.WithdrawalCredentials, sszSlice1...) - // Field (31) 'EarliestExitEpoch' - ssz.PutUint(hh, b.EarliestExitEpoch) + // Field 2: Amount + c.Amount = binary.LittleEndian.Uint64(sszSlice2) - // Field (32) 'ConsolidationBalanceToConsume' - ssz.PutUint(hh, b.ConsolidationBalanceToConsume) - - // Field (33) 'EarliestConsolidationEpoch' - ssz.PutUint(hh, 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 3: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice3...) - // Field (35) 'PendingPartialWithdrawals' - { - subIndx := hh.Index() - num := uint64(len(b.PendingPartialWithdrawals)) - if num > 64 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range b.PendingPartialWithdrawals { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } - } - hh.MerkleizeWithMixin(subIndx, num, 64) + // Field 4: Slot + if err = c.Slot.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("Slot: %w", err) } - - // Field (36) 'PendingConsolidations' - { - subIndx := hh.Index() - num := uint64(len(b.PendingConsolidations)) - if num > 64 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range b.PendingConsolidations { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } - } - hh.MerkleizeWithMixin(subIndx, num, 64) + return err +} + +func (c *PendingDeposit) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} +func (c *PendingDeposit) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: PublicKey + if len(c.PublicKey) != 48 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.PublicKey) + // Field 1: WithdrawalCredentials + if len(c.WithdrawalCredentials) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.WithdrawalCredentials) + // Field 2: Amount + hh.PutUint64(c.Amount) + // Field 3: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Signature) + // Field 4: Slot + if err := c.Slot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Slot: %w", err) + } hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the PendingDeposit object -func (p *PendingDeposit) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(p) +func (c *PendingConsolidation) SizeSSZ() int { + size := 16 + + return size } -// MarshalSSZTo ssz marshals the PendingDeposit object to a target array -func (p *PendingDeposit) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *PendingConsolidation) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (0) 'PublicKey' - if size := len(p.PublicKey); size != 48 { - err = ssz.ErrBytesLengthFn("--.PublicKey", size, 48) - return - } - dst = append(dst, p.PublicKey...) +func (c *PendingConsolidation) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (1) 'WithdrawalCredentials' - if size := len(p.WithdrawalCredentials); size != 32 { - err = ssz.ErrBytesLengthFn("--.WithdrawalCredentials", size, 32) - return + // Field 0: SourceIndex + if dst, err = c.SourceIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SourceIndex: %w", err) } - dst = append(dst, p.WithdrawalCredentials...) - - // Field (2) 'Amount' - dst = ssz.MarshalUint(dst, p.Amount) - // Field (3) 'Signature' - if size := len(p.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 1: TargetIndex + if dst, err = c.TargetIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("TargetIndex: %w", err) } - dst = append(dst, p.Signature...) - // Field (4) 'Slot' - dst = ssz.MarshalUint(dst, p.Slot) - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the PendingDeposit object -func (p *PendingDeposit) UnmarshalSSZ(buf []byte) error { +func (c *PendingConsolidation) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 192 { + if size != 16 { return ssz.ErrSize } - // Field (0) 'PublicKey' - if cap(p.PublicKey) == 0 { - p.PublicKey = make([]byte, 0, len(buf[0:48])) - } - p.PublicKey = append(p.PublicKey, buf[0:48]...) + sszSlice0 := buf[0:8] // c.SourceIndex + sszSlice1 := buf[8:16] // c.TargetIndex - // Field (1) 'WithdrawalCredentials' - if cap(p.WithdrawalCredentials) == 0 { - p.WithdrawalCredentials = make([]byte, 0, len(buf[48:80])) + // Field 0: SourceIndex + if err = c.SourceIndex.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("SourceIndex: %w", err) } - p.WithdrawalCredentials = append(p.WithdrawalCredentials, buf[48:80]...) - // Field (2) 'Amount' - p.Amount = ssz.UnmarshallUint[uint64](buf[80:88]) - - // Field (3) 'Signature' - if cap(p.Signature) == 0 { - p.Signature = make([]byte, 0, len(buf[88:184])) + // Field 1: TargetIndex + if err = c.TargetIndex.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("TargetIndex: %w", err) } - p.Signature = append(p.Signature, buf[88:184]...) - - // Field (4) 'Slot' - p.Slot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](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) +func (c *PendingConsolidation) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the PendingDeposit object with a hasher -func (p *PendingDeposit) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *PendingConsolidation) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'PublicKey' - if size := len(p.PublicKey); size != 48 { - err = ssz.ErrBytesLengthFn("--.PublicKey", size, 48) - return - } - hh.PutBytes(p.PublicKey) - - // Field (1) 'WithdrawalCredentials' - if size := len(p.WithdrawalCredentials); size != 32 { - err = ssz.ErrBytesLengthFn("--.WithdrawalCredentials", size, 32) - return + // Field 0: SourceIndex + if err := c.SourceIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SourceIndex: %w", err) } - hh.PutBytes(p.WithdrawalCredentials) - - // Field (2) 'Amount' - ssz.PutUint(hh, p.Amount) - - // Field (3) 'Signature' - if size := len(p.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 1: TargetIndex + if err := c.TargetIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("TargetIndex: %w", err) } - hh.PutBytes(p.Signature) + hh.Merkleize(indx) + return nil +} - // Field (4) 'Slot' - ssz.PutUint(hh, p.Slot) +func (c *PendingPartialWithdrawal) SizeSSZ() int { + size := 24 - hh.Merkleize(indx) - return + return size } -// MarshalSSZ ssz marshals the PendingPartialWithdrawal object -func (p *PendingPartialWithdrawal) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(p) +func (c *PendingPartialWithdrawal) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the PendingPartialWithdrawal object to a target array -func (p *PendingPartialWithdrawal) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *PendingPartialWithdrawal) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (0) 'Index' - dst = ssz.MarshalUint(dst, p.Index) + // Field 0: Index + if dst, err = c.Index.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Index: %w", err) + } - // Field (1) 'Amount' - dst = ssz.MarshalUint(dst, p.Amount) + // Field 1: Amount + dst = binary.LittleEndian.AppendUint64(dst, c.Amount) - // Field (2) 'WithdrawableEpoch' - dst = ssz.MarshalUint(dst, p.WithdrawableEpoch) + // Field 2: WithdrawableEpoch + if dst, err = c.WithdrawableEpoch.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("WithdrawableEpoch: %w", err) + } - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the PendingPartialWithdrawal object -func (p *PendingPartialWithdrawal) UnmarshalSSZ(buf []byte) error { +func (c *PendingPartialWithdrawal) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size != 24 { return ssz.ErrSize } - // Field (0) 'Index' - p.Index = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[0:8]) + sszSlice0 := buf[0:8] // c.Index + sszSlice1 := buf[8:16] // c.Amount + sszSlice2 := buf[16:24] // c.WithdrawableEpoch - // Field (1) 'Amount' - p.Amount = ssz.UnmarshallUint[uint64](buf[8:16]) + // Field 0: Index + if err = c.Index.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Index: %w", err) + } - // Field (2) 'WithdrawableEpoch' - p.WithdrawableEpoch = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Epoch](buf[16:24]) + // Field 1: Amount + c.Amount = binary.LittleEndian.Uint64(sszSlice1) + // Field 2: WithdrawableEpoch + if err = c.WithdrawableEpoch.UnmarshalSSZ(sszSlice2); err != nil { + return fmt.Errorf("WithdrawableEpoch: %w", err) + } 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) +func (c *PendingPartialWithdrawal) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the PendingPartialWithdrawal object with a hasher -func (p *PendingPartialWithdrawal) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *PendingPartialWithdrawal) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Index' - ssz.PutUint(hh, p.Index) - - // Field (1) 'Amount' - ssz.PutUint(hh, p.Amount) - - // Field (2) 'WithdrawableEpoch' - ssz.PutUint(hh, p.WithdrawableEpoch) - + // Field 0: Index + if err := c.Index.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Index: %w", err) + } + // Field 1: Amount + hh.PutUint64(c.Amount) + // Field 2: WithdrawableEpoch + if err := c.WithdrawableEpoch.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("WithdrawableEpoch: %w", err) + } hh.Merkleize(indx) - return + return nil +} + +func (c *SignedAggregateAttestationAndProofElectra) SizeSSZ() int { + size := 100 + if c.Message == nil { + c.Message = new(AggregateAttestationAndProofElectra) + } + size += c.Message.SizeSSZ() + return size } -// MarshalSSZ ssz marshals the PendingConsolidation object -func (p *PendingConsolidation) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(p) +func (c *SignedAggregateAttestationAndProofElectra) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the PendingConsolidation object to a target array -func (p *PendingConsolidation) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *SignedAggregateAttestationAndProofElectra) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 100 - // Field (0) 'SourceIndex' - dst = ssz.MarshalUint(dst, p.SourceIndex) + // Field 0: Message + if c.Message == nil { + c.Message = new(AggregateAttestationAndProofElectra) + } + dst = ssz.WriteOffset(dst, offset) + offset += c.Message.SizeSSZ() - // Field (1) 'TargetIndex' - dst = ssz.MarshalUint(dst, p.TargetIndex) + // Field 1: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.Signature...) - return + // Field 0: Message + if dst, err = c.Message.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Message: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the PendingConsolidation object -func (p *PendingConsolidation) UnmarshalSSZ(buf []byte) error { +func (c *SignedAggregateAttestationAndProofElectra) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 16 { + if size < 100 { return ssz.ErrSize } - // Field (0) 'SourceIndex' - p.SourceIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[0:8]) + sszSlice1 := buf[4:100] // c.Signature + + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Message + if sszVarOffset0 != 100 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset0 > size { + return ssz.ErrOffset + } + sszSlice0 := buf[sszVarOffset0:] // c.Message - // Field (1) 'TargetIndex' - p.TargetIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[8:16]) + // Field 0: Message + c.Message = new(AggregateAttestationAndProofElectra) + if err = c.Message.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Message: %w", err) + } + // Field 1: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice1...) 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) +func (c *SignedAggregateAttestationAndProofElectra) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the PendingConsolidation object with a hasher -func (p *PendingConsolidation) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *SignedAggregateAttestationAndProofElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'SourceIndex' - ssz.PutUint(hh, p.SourceIndex) - - // Field (1) 'TargetIndex' - ssz.PutUint(hh, p.TargetIndex) - + // Field 0: Message + if err := c.Message.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Message: %w", err) + } + // Field 1: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Signature) hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the LightClientBootstrapElectra object -func (l *LightClientBootstrapElectra) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(l) +func (c *SignedBeaconBlockContentsElectra) SizeSSZ() int { + size := 12 + if c.Block == nil { + c.Block = new(SignedBeaconBlockElectra) + } + size += c.Block.SizeSSZ() + size += len(c.KzgProofs) * 48 + size += len(c.Blobs) * 131072 + return size } -// MarshalSSZTo ssz marshals the LightClientBootstrapElectra object to a target array -func (l *LightClientBootstrapElectra) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(1780) +func (c *SignedBeaconBlockContentsElectra) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Offset (0) 'Header' - dst = ssz.WriteOffset(dst, offset) - if l.Header == nil { - l.Header = new(LightClientHeaderDeneb) - } - offset += l.Header.SizeSSZ() +func (c *SignedBeaconBlockContentsElectra) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 12 - // Field (1) 'CurrentSyncCommittee' - if l.CurrentSyncCommittee == nil { - l.CurrentSyncCommittee = new(SyncCommittee) + // Field 0: Block + if c.Block == nil { + c.Block = new(SignedBeaconBlockElectra) } - if dst, err = l.CurrentSyncCommittee.MarshalSSZTo(dst); err != nil { - return + dst = ssz.WriteOffset(dst, offset) + offset += c.Block.SizeSSZ() + + // Field 1: KzgProofs + dst = ssz.WriteOffset(dst, offset) + offset += len(c.KzgProofs) * 48 + + // Field 2: Blobs + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Blobs) * 131072 + + // Field 0: Block + if dst, err = c.Block.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Block: %w", err) } - // Field (2) 'CurrentSyncCommitteeBranch' - if size := len(l.CurrentSyncCommitteeBranch); size != 6 { - err = ssz.ErrVectorLengthFn("--.CurrentSyncCommitteeBranch", size, 6) - return + // Field 1: KzgProofs + if len(c.KzgProofs) > 4096 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < 6; ii++ { - if size := len(l.CurrentSyncCommitteeBranch[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.CurrentSyncCommitteeBranch[ii]", size, 32) - return + for _, o := range c.KzgProofs { + if len(o) != 48 { + return nil, ssz.ErrBytesLength } - dst = append(dst, l.CurrentSyncCommitteeBranch[ii]...) + dst = append(dst, o...) } - // Field (0) 'Header' - if dst, err = l.Header.MarshalSSZTo(dst); err != nil { - return + // Field 2: Blobs + if len(c.Blobs) > 4096 { + return nil, ssz.ErrListTooBig } - - return + for _, o := range c.Blobs { + if len(o) != 131072 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the LightClientBootstrapElectra object -func (l *LightClientBootstrapElectra) UnmarshalSSZ(buf []byte) error { +func (c *SignedBeaconBlockContentsElectra) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 1780 { + if size < 12 { return ssz.ErrSize } - tail := buf - var o0 uint64 - - // Offset (0) 'Header' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Block + if sszVarOffset0 != 12 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset0 > size { return ssz.ErrOffset } - - if o0 != 1780 { - return ssz.ErrInvalidVariableOffset + sszVarOffset1 := ssz.ReadOffset(buf[4:8]) // c.KzgProofs + if sszVarOffset1 > size || sszVarOffset1 < sszVarOffset0 { + return ssz.ErrOffset } - - // Field (1) 'CurrentSyncCommittee' - if l.CurrentSyncCommittee == nil { - l.CurrentSyncCommittee = new(SyncCommittee) + sszVarOffset2 := ssz.ReadOffset(buf[8:12]) // c.Blobs + if sszVarOffset2 > size || sszVarOffset2 < sszVarOffset1 { + return ssz.ErrOffset } - if err = l.CurrentSyncCommittee.UnmarshalSSZ(buf[4:1588]); err != nil { - return err + sszSlice0 := buf[sszVarOffset0:sszVarOffset1] // c.Block + sszSlice1 := buf[sszVarOffset1:sszVarOffset2] // c.KzgProofs + sszSlice2 := buf[sszVarOffset2:] // c.Blobs + + // Field 0: Block + c.Block = new(SignedBeaconBlockElectra) + if err = c.Block.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Block: %w", err) } - // Field (2) 'CurrentSyncCommitteeBranch' - l.CurrentSyncCommitteeBranch = make([][]byte, 6) - for ii := 0; ii < 6; ii++ { - if cap(l.CurrentSyncCommitteeBranch[ii]) == 0 { - l.CurrentSyncCommitteeBranch[ii] = make([]byte, 0, len(buf[1588:1780][ii*32:(ii+1)*32])) + // Field 1: KzgProofs + { + if len(sszSlice1)%48 != 0 { + return fmt.Errorf("misaligned bytes: c.KzgProofs length is %d, which is not a multiple of 48: %w", len(sszSlice1), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice1) / 48 + if numElem > 4096 { + return fmt.Errorf("ssz-max exceeded: c.KzgProofs has %d elements, ssz-max is 4096: %w", numElem, ssz.ErrListTooBig) + } + c.KzgProofs = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte + + tmpSlice := sszSlice1[i*48 : (1+i)*48] + tmp = make([]byte, 0, 48) + tmp = append(tmp, tmpSlice...) + c.KzgProofs[i] = tmp } - l.CurrentSyncCommitteeBranch[ii] = append(l.CurrentSyncCommitteeBranch[ii], buf[1588:1780][ii*32:(ii+1)*32]...) } - // Field (0) 'Header' + // Field 2: Blobs { - buf = tail[o0:] - if l.Header == nil { - l.Header = new(LightClientHeaderDeneb) + if len(sszSlice2)%131072 != 0 { + return fmt.Errorf("misaligned bytes: c.Blobs length is %d, which is not a multiple of 131072: %w", len(sszSlice2), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice2) / 131072 + if numElem > 4096 { + return fmt.Errorf("ssz-max exceeded: c.Blobs has %d elements, ssz-max is 4096: %w", numElem, ssz.ErrListTooBig) } - if err = l.Header.UnmarshalSSZ(buf); err != nil { - return err + c.Blobs = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte + + tmpSlice := sszSlice2[i*131072 : (1+i)*131072] + tmp = make([]byte, 0, 131072) + tmp = append(tmp, tmpSlice...) + c.Blobs[i] = tmp } } return err } -// SizeSSZ returns the ssz encoded size in bytes for the LightClientBootstrapElectra object -func (l *LightClientBootstrapElectra) SizeSSZ() (size int) { - size = 1780 - - // Field (0) 'Header' - if l.Header == nil { - l.Header = new(LightClientHeaderDeneb) +func (c *SignedBeaconBlockContentsElectra) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - size += l.Header.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the LightClientBootstrapElectra object -func (l *LightClientBootstrapElectra) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(l) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the LightClientBootstrapElectra object with a hasher -func (l *LightClientBootstrapElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *SignedBeaconBlockContentsElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Header' - if err = l.Header.HashTreeRootWith(hh); err != nil { - return + // Field 0: Block + if err := c.Block.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Block: %w", err) } - - // Field (1) 'CurrentSyncCommittee' - if err = l.CurrentSyncCommittee.HashTreeRootWith(hh); err != nil { - return + // Field 1: KzgProofs + { + if len(c.KzgProofs) > 4096 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.KzgProofs { + if len(o) != 48 { + return ssz.ErrBytesLength + } + hh.PutBytes(o) + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.KzgProofs)), 4096) } - - // Field (2) 'CurrentSyncCommitteeBranch' + // Field 2: Blobs { - if size := len(l.CurrentSyncCommitteeBranch); size != 6 { - err = ssz.ErrVectorLengthFn("--.CurrentSyncCommitteeBranch", size, 6) - return + if len(c.Blobs) > 4096 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range l.CurrentSyncCommitteeBranch { - if len(i) != 32 { - err = ssz.ErrBytesLength - return + for _, o := range c.Blobs { + if len(o) != 131072 { + return ssz.ErrBytesLength } - hh.Append(i) + hh.PutBytes(o) } - hh.Merkleize(subIndx) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Blobs)), 4096) } - hh.Merkleize(indx) - return + return nil +} + +func (c *SignedBeaconBlockElectra) SizeSSZ() int { + size := 100 + if c.Block == nil { + c.Block = new(BeaconBlockElectra) + } + size += c.Block.SizeSSZ() + return size } -// MarshalSSZ ssz marshals the LightClientUpdateElectra object -func (l *LightClientUpdateElectra) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(l) +func (c *SignedBeaconBlockElectra) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the LightClientUpdateElectra object to a target array -func (l *LightClientUpdateElectra) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(2116) +func (c *SignedBeaconBlockElectra) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 100 - // Offset (0) 'AttestedHeader' + // Field 0: Block + if c.Block == nil { + c.Block = new(BeaconBlockElectra) + } dst = ssz.WriteOffset(dst, offset) - if l.AttestedHeader == nil { - l.AttestedHeader = new(LightClientHeaderDeneb) + offset += c.Block.SizeSSZ() + + // Field 1: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } - offset += l.AttestedHeader.SizeSSZ() + dst = append(dst, c.Signature...) - // Field (1) 'NextSyncCommittee' - if l.NextSyncCommittee == nil { - l.NextSyncCommittee = new(SyncCommittee) + // Field 0: Block + if dst, err = c.Block.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Block: %w", err) } - if dst, err = l.NextSyncCommittee.MarshalSSZTo(dst); err != nil { - return + return dst, err +} + +func (c *SignedBeaconBlockElectra) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 100 { + return ssz.ErrSize } - // Field (2) 'NextSyncCommitteeBranch' - if size := len(l.NextSyncCommitteeBranch); size != 6 { - err = ssz.ErrVectorLengthFn("--.NextSyncCommitteeBranch", size, 6) - return + sszSlice1 := buf[4:100] // c.Signature + + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Block + if sszVarOffset0 != 100 { + return ssz.ErrInvalidVariableOffset } - for ii := 0; ii < 6; ii++ { - if size := len(l.NextSyncCommitteeBranch[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.NextSyncCommitteeBranch[ii]", size, 32) - return - } - dst = append(dst, l.NextSyncCommitteeBranch[ii]...) + if sszVarOffset0 > size { + return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:] // c.Block - // Offset (3) 'FinalizedHeader' - dst = ssz.WriteOffset(dst, offset) - if l.FinalizedHeader == nil { - l.FinalizedHeader = new(LightClientHeaderDeneb) + // Field 0: Block + c.Block = new(BeaconBlockElectra) + if err = c.Block.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Block: %w", err) } - offset += l.FinalizedHeader.SizeSSZ() - // Field (4) 'FinalityBranch' - if size := len(l.FinalityBranch); size != 7 { - err = ssz.ErrVectorLengthFn("--.FinalityBranch", size, 7) - return - } - for ii := 0; ii < 7; ii++ { - if size := len(l.FinalityBranch[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.FinalityBranch[ii]", size, 32) - return - } - dst = append(dst, l.FinalityBranch[ii]...) + // Field 1: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice1...) + return err +} + +func (c *SignedBeaconBlockElectra) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (5) 'SyncAggregate' - if l.SyncAggregate == nil { - l.SyncAggregate = new(SyncAggregate) +func (c *SignedBeaconBlockElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Block + if err := c.Block.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Block: %w", err) + } + // Field 1: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength } - if dst, err = l.SyncAggregate.MarshalSSZTo(dst); err != nil { - return + hh.PutBytes(c.Signature) + hh.Merkleize(indx) + return nil +} + +func (c *SignedBlindedBeaconBlockElectra) SizeSSZ() int { + size := 100 + if c.Message == nil { + c.Message = new(BlindedBeaconBlockElectra) } + size += c.Message.SizeSSZ() + return size +} - // Field (6) 'SignatureSlot' - dst = ssz.MarshalUint(dst, l.SignatureSlot) +func (c *SignedBlindedBeaconBlockElectra) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} + +func (c *SignedBlindedBeaconBlockElectra) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 100 - // Field (0) 'AttestedHeader' - if dst, err = l.AttestedHeader.MarshalSSZTo(dst); err != nil { - return + // Field 0: Message + if c.Message == nil { + c.Message = new(BlindedBeaconBlockElectra) } + dst = ssz.WriteOffset(dst, offset) + offset += c.Message.SizeSSZ() - // Field (3) 'FinalizedHeader' - if dst, err = l.FinalizedHeader.MarshalSSZTo(dst); err != nil { - return + // Field 1: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.Signature...) - return + // Field 0: Message + if dst, err = c.Message.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Message: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the LightClientUpdateElectra object -func (l *LightClientUpdateElectra) UnmarshalSSZ(buf []byte) error { +func (c *SignedBlindedBeaconBlockElectra) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 2116 { + if size < 100 { return ssz.ErrSize } - tail := buf - var o0, o3 uint64 - - // Offset (0) 'AttestedHeader' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } + sszSlice1 := buf[4:100] // c.Signature - if o0 != 2116 { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Message + if sszVarOffset0 != 100 { return ssz.ErrInvalidVariableOffset } - - // Field (1) 'NextSyncCommittee' - if l.NextSyncCommittee == nil { - l.NextSyncCommittee = new(SyncCommittee) - } - if err = l.NextSyncCommittee.UnmarshalSSZ(buf[4:1588]); err != nil { - return err + if sszVarOffset0 > size { + return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:] // c.Message - // Field (2) 'NextSyncCommitteeBranch' - l.NextSyncCommitteeBranch = make([][]byte, 6) - for ii := 0; ii < 6; ii++ { - if cap(l.NextSyncCommitteeBranch[ii]) == 0 { - l.NextSyncCommitteeBranch[ii] = make([]byte, 0, len(buf[1588:1780][ii*32:(ii+1)*32])) - } - l.NextSyncCommitteeBranch[ii] = append(l.NextSyncCommitteeBranch[ii], buf[1588:1780][ii*32:(ii+1)*32]...) + // Field 0: Message + c.Message = new(BlindedBeaconBlockElectra) + if err = c.Message.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Message: %w", err) } - // Offset (3) 'FinalizedHeader' - if o3 = ssz.ReadOffset(buf[1780:1784]); o3 > size || o0 > o3 { - return ssz.ErrOffset - } + // Field 1: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice1...) + return err +} - // Field (4) 'FinalityBranch' - l.FinalityBranch = make([][]byte, 7) - for ii := 0; ii < 7; ii++ { - if cap(l.FinalityBranch[ii]) == 0 { - l.FinalityBranch[ii] = make([]byte, 0, len(buf[1784:2008][ii*32:(ii+1)*32])) - } - l.FinalityBranch[ii] = append(l.FinalityBranch[ii], buf[1784:2008][ii*32:(ii+1)*32]...) +func (c *SignedBlindedBeaconBlockElectra) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (5) 'SyncAggregate' - if l.SyncAggregate == nil { - l.SyncAggregate = new(SyncAggregate) +func (c *SignedBlindedBeaconBlockElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Message + if err := c.Message.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Message: %w", err) } - if err = l.SyncAggregate.UnmarshalSSZ(buf[2008:2108]); err != nil { - return err + // Field 1: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength } + hh.PutBytes(c.Signature) + hh.Merkleize(indx) + return nil +} - // Field (6) 'SignatureSlot' - l.SignatureSlot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[2108:2116]) - - // Field (0) 'AttestedHeader' - { - buf = tail[o0:o3] - if l.AttestedHeader == nil { - l.AttestedHeader = new(LightClientHeaderDeneb) - } - if err = l.AttestedHeader.UnmarshalSSZ(buf); err != nil { - return err - } +func (c *SignedBuilderBidElectra) SizeSSZ() int { + size := 100 + if c.Message == nil { + c.Message = new(BuilderBidElectra) } + size += c.Message.SizeSSZ() + return size +} - // Field (3) 'FinalizedHeader' - { - buf = tail[o3:] - if l.FinalizedHeader == nil { - l.FinalizedHeader = new(LightClientHeaderDeneb) - } - if err = l.FinalizedHeader.UnmarshalSSZ(buf); err != nil { - return err - } - } - return err +func (c *SignedBuilderBidElectra) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// SizeSSZ returns the ssz encoded size in bytes for the LightClientUpdateElectra object -func (l *LightClientUpdateElectra) SizeSSZ() (size int) { - size = 2116 +func (c *SignedBuilderBidElectra) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 100 - // Field (0) 'AttestedHeader' - if l.AttestedHeader == nil { - l.AttestedHeader = new(LightClientHeaderDeneb) + // Field 0: Message + if c.Message == nil { + c.Message = new(BuilderBidElectra) } - size += l.AttestedHeader.SizeSSZ() + dst = ssz.WriteOffset(dst, offset) + offset += c.Message.SizeSSZ() - // Field (3) 'FinalizedHeader' - if l.FinalizedHeader == nil { - l.FinalizedHeader = new(LightClientHeaderDeneb) + // Field 1: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } - size += l.FinalizedHeader.SizeSSZ() + dst = append(dst, c.Signature...) - return + // Field 0: Message + if dst, err = c.Message.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Message: %w", err) + } + return dst, err } -// HashTreeRoot ssz hashes the LightClientUpdateElectra object -func (l *LightClientUpdateElectra) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(l) -} +func (c *SignedBuilderBidElectra) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 100 { + return ssz.ErrSize + } -// HashTreeRootWith ssz hashes the LightClientUpdateElectra object with a hasher -func (l *LightClientUpdateElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() + sszSlice1 := buf[4:100] // c.Signature - // Field (0) 'AttestedHeader' - if err = l.AttestedHeader.HashTreeRootWith(hh); err != nil { - return + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Message + if sszVarOffset0 != 100 { + return ssz.ErrInvalidVariableOffset } - - // Field (1) 'NextSyncCommittee' - if err = l.NextSyncCommittee.HashTreeRootWith(hh); err != nil { - return + if sszVarOffset0 > size { + return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:] // c.Message - // Field (2) 'NextSyncCommitteeBranch' - { - if size := len(l.NextSyncCommitteeBranch); size != 6 { - err = ssz.ErrVectorLengthFn("--.NextSyncCommitteeBranch", size, 6) - return - } - subIndx := hh.Index() - for _, i := range l.NextSyncCommitteeBranch { - if len(i) != 32 { - err = ssz.ErrBytesLength - return - } - hh.Append(i) - } - hh.Merkleize(subIndx) + // Field 0: Message + c.Message = new(BuilderBidElectra) + if err = c.Message.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Message: %w", err) } - // Field (3) 'FinalizedHeader' - if err = l.FinalizedHeader.HashTreeRootWith(hh); err != nil { - return - } + // Field 1: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice1...) + return err +} - // Field (4) 'FinalityBranch' - { - if size := len(l.FinalityBranch); size != 7 { - err = ssz.ErrVectorLengthFn("--.FinalityBranch", size, 7) - return - } - subIndx := hh.Index() - for _, i := range l.FinalityBranch { - if len(i) != 32 { - err = ssz.ErrBytesLength - return - } - hh.Append(i) - } - hh.Merkleize(subIndx) +func (c *SignedBuilderBidElectra) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (5) 'SyncAggregate' - if err = l.SyncAggregate.HashTreeRootWith(hh); err != nil { - return +func (c *SignedBuilderBidElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Message + if err := c.Message.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Message: %w", err) } - - // Field (6) 'SignatureSlot' - ssz.PutUint(hh, l.SignatureSlot) - + // Field 1: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Signature) hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the LightClientFinalityUpdateElectra object -func (l *LightClientFinalityUpdateElectra) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(l) +func (c *SingleAttestation) SizeSSZ() int { + size := 240 + + return size } -// MarshalSSZTo ssz marshals the LightClientFinalityUpdateElectra object to a target array -func (l *LightClientFinalityUpdateElectra) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(340) +func (c *SingleAttestation) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Offset (0) 'AttestedHeader' - dst = ssz.WriteOffset(dst, offset) - if l.AttestedHeader == nil { - l.AttestedHeader = new(LightClientHeaderDeneb) - } - offset += l.AttestedHeader.SizeSSZ() +func (c *SingleAttestation) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Offset (1) 'FinalizedHeader' - dst = ssz.WriteOffset(dst, offset) - if l.FinalizedHeader == nil { - l.FinalizedHeader = new(LightClientHeaderDeneb) + // Field 0: CommitteeId + if dst, err = c.CommitteeId.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("CommitteeId: %w", err) } - offset += l.FinalizedHeader.SizeSSZ() - // Field (2) 'FinalityBranch' - if size := len(l.FinalityBranch); size != 7 { - err = ssz.ErrVectorLengthFn("--.FinalityBranch", size, 7) - return - } - for ii := 0; ii < 7; ii++ { - if size := len(l.FinalityBranch[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.FinalityBranch[ii]", size, 32) - return - } - dst = append(dst, l.FinalityBranch[ii]...) + // Field 1: AttesterIndex + if dst, err = c.AttesterIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("AttesterIndex: %w", err) } - // Field (3) 'SyncAggregate' - if l.SyncAggregate == nil { - l.SyncAggregate = new(SyncAggregate) + // Field 2: Data + if c.Data == nil { + c.Data = new(AttestationData) } - if dst, err = l.SyncAggregate.MarshalSSZTo(dst); err != nil { - return - } - - // Field (4) 'SignatureSlot' - dst = ssz.MarshalUint(dst, l.SignatureSlot) - - // Field (0) 'AttestedHeader' - if dst, err = l.AttestedHeader.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.Data.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Data: %w", err) } - // Field (1) 'FinalizedHeader' - if dst, err = l.FinalizedHeader.MarshalSSZTo(dst); err != nil { - return + // Field 3: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.Signature...) - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the LightClientFinalityUpdateElectra object -func (l *LightClientFinalityUpdateElectra) UnmarshalSSZ(buf []byte) error { +func (c *SingleAttestation) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 340 { + if size != 240 { return ssz.ErrSize } - tail := buf - var o0, o1 uint64 - - // Offset (0) 'AttestedHeader' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } - - if o0 != 340 { - return ssz.ErrInvalidVariableOffset - } - - // Offset (1) 'FinalizedHeader' - if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 { - return ssz.ErrOffset - } + sszSlice0 := buf[0:8] // c.CommitteeId + sszSlice1 := buf[8:16] // c.AttesterIndex + sszSlice2 := buf[16:144] // c.Data + sszSlice3 := buf[144:240] // c.Signature - // Field (2) 'FinalityBranch' - l.FinalityBranch = make([][]byte, 7) - for ii := 0; ii < 7; ii++ { - if cap(l.FinalityBranch[ii]) == 0 { - l.FinalityBranch[ii] = make([]byte, 0, len(buf[8:232][ii*32:(ii+1)*32])) - } - l.FinalityBranch[ii] = append(l.FinalityBranch[ii], buf[8:232][ii*32:(ii+1)*32]...) + // Field 0: CommitteeId + if err = c.CommitteeId.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("CommitteeId: %w", err) } - // Field (3) 'SyncAggregate' - if l.SyncAggregate == nil { - l.SyncAggregate = new(SyncAggregate) - } - if err = l.SyncAggregate.UnmarshalSSZ(buf[232:332]); err != nil { - return err + // Field 1: AttesterIndex + if err = c.AttesterIndex.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("AttesterIndex: %w", err) } - // Field (4) 'SignatureSlot' - l.SignatureSlot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[332:340]) - - // Field (0) 'AttestedHeader' - { - buf = tail[o0:o1] - if l.AttestedHeader == nil { - l.AttestedHeader = new(LightClientHeaderDeneb) - } - if err = l.AttestedHeader.UnmarshalSSZ(buf); err != nil { - return err - } + // Field 2: Data + c.Data = new(AttestationData) + if err = c.Data.UnmarshalSSZ(sszSlice2); err != nil { + return fmt.Errorf("Data: %w", err) } - // Field (1) 'FinalizedHeader' - { - buf = tail[o1:] - if l.FinalizedHeader == nil { - l.FinalizedHeader = new(LightClientHeaderDeneb) - } - if err = l.FinalizedHeader.UnmarshalSSZ(buf); err != nil { - return err - } - } + // Field 3: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice3...) return err } -// SizeSSZ returns the ssz encoded size in bytes for the LightClientFinalityUpdateElectra object -func (l *LightClientFinalityUpdateElectra) SizeSSZ() (size int) { - size = 340 - - // Field (0) 'AttestedHeader' - if l.AttestedHeader == nil { - l.AttestedHeader = new(LightClientHeaderDeneb) - } - size += l.AttestedHeader.SizeSSZ() - - // Field (1) 'FinalizedHeader' - if l.FinalizedHeader == nil { - l.FinalizedHeader = new(LightClientHeaderDeneb) +func (c *SingleAttestation) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - size += l.FinalizedHeader.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the LightClientFinalityUpdateElectra object -func (l *LightClientFinalityUpdateElectra) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(l) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the LightClientFinalityUpdateElectra object with a hasher -func (l *LightClientFinalityUpdateElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *SingleAttestation) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'AttestedHeader' - if err = l.AttestedHeader.HashTreeRootWith(hh); err != nil { - return + // Field 0: CommitteeId + if err := c.CommitteeId.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("CommitteeId: %w", err) } - - // Field (1) 'FinalizedHeader' - if err = l.FinalizedHeader.HashTreeRootWith(hh); err != nil { - return + // Field 1: AttesterIndex + if err := c.AttesterIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("AttesterIndex: %w", err) } - - // Field (2) 'FinalityBranch' - { - if size := len(l.FinalityBranch); size != 7 { - err = ssz.ErrVectorLengthFn("--.FinalityBranch", size, 7) - return - } - subIndx := hh.Index() - for _, i := range l.FinalityBranch { - if len(i) != 32 { - err = ssz.ErrBytesLength - return - } - hh.Append(i) - } - hh.Merkleize(subIndx) + // Field 2: Data + if err := c.Data.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Data: %w", err) } - - // Field (3) 'SyncAggregate' - if err = l.SyncAggregate.HashTreeRootWith(hh); err != nil { - return + // Field 3: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength } - - // Field (4) 'SignatureSlot' - ssz.PutUint(hh, l.SignatureSlot) - + hh.PutBytes(c.Signature) hh.Merkleize(indx) - return + return nil } diff --git a/proto/prysm/v1alpha1/electra.ssz.go b/proto/prysm/v1alpha1/electra.ssz.go index 723e9f76659c..3511d9d91e22 100644 --- a/proto/prysm/v1alpha1/electra.ssz.go +++ b/proto/prysm/v1alpha1/electra.ssz.go @@ -1,5296 +1,5028 @@ //go:build !minimal -// Code generated by fastssz. DO NOT EDIT. package eth import ( - github_com_OffchainLabs_prysm_v7_consensus_types_primitives "github.com/OffchainLabs/prysm/v7/consensus-types/primitives" + binary "encoding/binary" + "fmt" + go_bitfield "github.com/OffchainLabs/go-bitfield" + ssz "github.com/OffchainLabs/methodical-ssz/ssz" v1 "github.com/OffchainLabs/prysm/v7/proto/engine/v1" - ssz "github.com/prysmaticlabs/fastssz" ) -// MarshalSSZ ssz marshals the SignedAggregateAttestationAndProofElectra object -func (s *SignedAggregateAttestationAndProofElectra) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) +func (c *AggregateAttestationAndProofElectra) SizeSSZ() int { + size := 108 + if c.Aggregate == nil { + c.Aggregate = new(AttestationElectra) + } + size += c.Aggregate.SizeSSZ() + return size } -// MarshalSSZTo ssz marshals the SignedAggregateAttestationAndProofElectra object to a target array -func (s *SignedAggregateAttestationAndProofElectra) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(100) +func (c *AggregateAttestationAndProofElectra) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Offset (0) 'Message' - dst = ssz.WriteOffset(dst, offset) - if s.Message == nil { - s.Message = new(AggregateAttestationAndProofElectra) +func (c *AggregateAttestationAndProofElectra) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 108 + + // Field 0: AggregatorIndex + if dst, err = c.AggregatorIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("AggregatorIndex: %w", err) } - offset += s.Message.SizeSSZ() - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 1: Aggregate + if c.Aggregate == nil { + c.Aggregate = new(AttestationElectra) } - dst = append(dst, s.Signature...) + dst = ssz.WriteOffset(dst, offset) + offset += c.Aggregate.SizeSSZ() - // Field (0) 'Message' - if dst, err = s.Message.MarshalSSZTo(dst); err != nil { - return + // Field 2: SelectionProof + if len(c.SelectionProof) != 96 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.SelectionProof...) - return + // Field 1: Aggregate + if dst, err = c.Aggregate.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Aggregate: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the SignedAggregateAttestationAndProofElectra object -func (s *SignedAggregateAttestationAndProofElectra) UnmarshalSSZ(buf []byte) error { +func (c *AggregateAttestationAndProofElectra) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 100 { + if size < 108 { return ssz.ErrSize } - tail := buf - var o0 uint64 + sszSlice0 := buf[0:8] // c.AggregatorIndex + sszSlice2 := buf[12:108] // c.SelectionProof - // Offset (0) 'Message' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { + sszVarOffset1 := ssz.ReadOffset(buf[8:12]) // c.Aggregate + if sszVarOffset1 != 108 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset1 > size { return ssz.ErrOffset } + sszSlice1 := buf[sszVarOffset1:] // c.Aggregate - if o0 != 100 { - return ssz.ErrInvalidVariableOffset + // Field 0: AggregatorIndex + if err = c.AggregatorIndex.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("AggregatorIndex: %w", err) } - // Field (1) 'Signature' - if cap(s.Signature) == 0 { - s.Signature = make([]byte, 0, len(buf[4:100])) + // Field 1: Aggregate + c.Aggregate = new(AttestationElectra) + if err = c.Aggregate.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Aggregate: %w", err) } - s.Signature = append(s.Signature, buf[4:100]...) - // Field (0) 'Message' - { - buf = tail[o0:] - if s.Message == nil { - s.Message = new(AggregateAttestationAndProofElectra) - } - if err = s.Message.UnmarshalSSZ(buf); err != nil { - return err - } - } + // Field 2: SelectionProof + c.SelectionProof = make([]byte, 0, 96) + c.SelectionProof = append(c.SelectionProof, sszSlice2...) return err } -// SizeSSZ returns the ssz encoded size in bytes for the SignedAggregateAttestationAndProofElectra object -func (s *SignedAggregateAttestationAndProofElectra) SizeSSZ() (size int) { - size = 100 - - // Field (0) 'Message' - if s.Message == nil { - s.Message = new(AggregateAttestationAndProofElectra) +func (c *AggregateAttestationAndProofElectra) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - size += s.Message.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the SignedAggregateAttestationAndProofElectra object -func (s *SignedAggregateAttestationAndProofElectra) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the SignedAggregateAttestationAndProofElectra object with a hasher -func (s *SignedAggregateAttestationAndProofElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *AggregateAttestationAndProofElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Message' - if err = s.Message.HashTreeRootWith(hh); err != nil { - return + // Field 0: AggregatorIndex + if err := c.AggregatorIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("AggregatorIndex: %w", err) } - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 1: Aggregate + if err := c.Aggregate.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Aggregate: %w", err) } - hh.PutBytes(s.Signature) - + // Field 2: SelectionProof + if len(c.SelectionProof) != 96 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.SelectionProof) hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the AggregateAttestationAndProofElectra object -func (a *AggregateAttestationAndProofElectra) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(a) +func (c *AttestationElectra) SizeSSZ() int { + size := 236 + size += len(c.AggregationBits) + return size } -// MarshalSSZTo ssz marshals the AggregateAttestationAndProofElectra object to a target array -func (a *AggregateAttestationAndProofElectra) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(108) +func (c *AttestationElectra) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (0) 'AggregatorIndex' - dst = ssz.MarshalUint(dst, a.AggregatorIndex) +func (c *AttestationElectra) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 236 - // Offset (1) 'Aggregate' + // Field 0: AggregationBits dst = ssz.WriteOffset(dst, offset) - if a.Aggregate == nil { - a.Aggregate = new(AttestationElectra) + offset += len(c.AggregationBits) + + // Field 1: Data + if c.Data == nil { + c.Data = new(AttestationData) + } + if dst, err = c.Data.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Data: %w", err) } - offset += a.Aggregate.SizeSSZ() - // Field (2) 'SelectionProof' - if size := len(a.SelectionProof); size != 96 { - err = ssz.ErrBytesLengthFn("--.SelectionProof", size, 96) - return + // Field 2: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } - dst = append(dst, a.SelectionProof...) + dst = append(dst, c.Signature...) - // Field (1) 'Aggregate' - if dst, err = a.Aggregate.MarshalSSZTo(dst); err != nil { - return + // Field 3: CommitteeBits + if len([]byte(c.CommitteeBits)) != 8 { + return nil, ssz.ErrBytesLength } + dst = append(dst, []byte(c.CommitteeBits)...) - return + // Field 0: AggregationBits + if len(c.AggregationBits) > 131072 { + return nil, ssz.ErrListTooBig + } + dst = append(dst, c.AggregationBits...) + return dst, err } -// UnmarshalSSZ ssz unmarshals the AggregateAttestationAndProofElectra object -func (a *AggregateAttestationAndProofElectra) UnmarshalSSZ(buf []byte) error { +func (c *AttestationElectra) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 108 { + if size < 236 { return ssz.ErrSize } - tail := buf - var o1 uint64 - - // Field (0) 'AggregatorIndex' - a.AggregatorIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[0:8]) + sszSlice1 := buf[4:132] // c.Data + sszSlice2 := buf[132:228] // c.Signature + sszSlice3 := buf[228:236] // c.CommitteeBits - // Offset (1) 'Aggregate' - if o1 = ssz.ReadOffset(buf[8:12]); o1 > size { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.AggregationBits + if sszVarOffset0 != 236 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset0 > size { return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:] // c.AggregationBits - if o1 != 108 { - return ssz.ErrInvalidVariableOffset + // Field 0: AggregationBits + if err = ssz.ValidateBitlist(sszSlice0, 131072); err != nil { + return fmt.Errorf("AggregationBits: %w", err) } + c.AggregationBits = append([]byte{}, go_bitfield.Bitlist(sszSlice0)...) - // Field (2) 'SelectionProof' - if cap(a.SelectionProof) == 0 { - a.SelectionProof = make([]byte, 0, len(buf[12:108])) + // Field 1: Data + c.Data = new(AttestationData) + if err = c.Data.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Data: %w", err) } - a.SelectionProof = append(a.SelectionProof, buf[12:108]...) - // Field (1) 'Aggregate' - { - buf = tail[o1:] - if a.Aggregate == nil { - a.Aggregate = new(AttestationElectra) - } - if err = a.Aggregate.UnmarshalSSZ(buf); err != nil { - return err - } - } + // Field 2: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice2...) + + // Field 3: CommitteeBits + c.CommitteeBits = make([]byte, 0, 8) + c.CommitteeBits = append(c.CommitteeBits, go_bitfield.Bitvector64(sszSlice3)...) return err } -// SizeSSZ returns the ssz encoded size in bytes for the AggregateAttestationAndProofElectra object -func (a *AggregateAttestationAndProofElectra) SizeSSZ() (size int) { - size = 108 - - // Field (1) 'Aggregate' - if a.Aggregate == nil { - a.Aggregate = new(AttestationElectra) +func (c *AttestationElectra) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - size += a.Aggregate.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the AggregateAttestationAndProofElectra object -func (a *AggregateAttestationAndProofElectra) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(a) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the AggregateAttestationAndProofElectra object with a hasher -func (a *AggregateAttestationAndProofElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *AttestationElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'AggregatorIndex' - ssz.PutUint(hh, a.AggregatorIndex) - - // Field (1) 'Aggregate' - if err = a.Aggregate.HashTreeRootWith(hh); err != nil { - return + // Field 0: AggregationBits + if len(c.AggregationBits) == 0 { + return ssz.ErrEmptyBitlist } - - // Field (2) 'SelectionProof' - if size := len(a.SelectionProof); size != 96 { - err = ssz.ErrBytesLengthFn("--.SelectionProof", size, 96) - return + hh.PutBitlist(c.AggregationBits, 131072) + // Field 1: Data + if err := c.Data.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Data: %w", err) } - hh.PutBytes(a.SelectionProof) - + // Field 2: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Signature) + // Field 3: CommitteeBits + if len([]byte(c.CommitteeBits)) != 8 { + return ssz.ErrBytesLength + } + hh.PutBytes([]byte(c.CommitteeBits)) hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the AttestationElectra object -func (a *AttestationElectra) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(a) +func (c *AttesterSlashingElectra) SizeSSZ() int { + size := 8 + if c.Attestation_1 == nil { + c.Attestation_1 = new(IndexedAttestationElectra) + } + size += c.Attestation_1.SizeSSZ() + if c.Attestation_2 == nil { + c.Attestation_2 = new(IndexedAttestationElectra) + } + size += c.Attestation_2.SizeSSZ() + return size } -// MarshalSSZTo ssz marshals the AttestationElectra object to a target array -func (a *AttestationElectra) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(236) +func (c *AttesterSlashingElectra) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Offset (0) 'AggregationBits' - dst = ssz.WriteOffset(dst, offset) - offset += len(a.AggregationBits) +func (c *AttesterSlashingElectra) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 8 - // Field (1) 'Data' - if a.Data == nil { - a.Data = new(AttestationData) - } - if dst, err = a.Data.MarshalSSZTo(dst); err != nil { - return + // Field 0: Attestation_1 + if c.Attestation_1 == nil { + c.Attestation_1 = new(IndexedAttestationElectra) } + dst = ssz.WriteOffset(dst, offset) + offset += c.Attestation_1.SizeSSZ() - // Field (2) 'Signature' - if size := len(a.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 1: Attestation_2 + if c.Attestation_2 == nil { + c.Attestation_2 = new(IndexedAttestationElectra) } - dst = append(dst, a.Signature...) + dst = ssz.WriteOffset(dst, offset) + offset += c.Attestation_2.SizeSSZ() - // Field (3) 'CommitteeBits' - if size := len(a.CommitteeBits); size != 8 { - err = ssz.ErrBytesLengthFn("--.CommitteeBits", size, 8) - return + // Field 0: Attestation_1 + if dst, err = c.Attestation_1.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Attestation_1: %w", err) } - dst = append(dst, a.CommitteeBits...) - // Field (0) 'AggregationBits' - if size := len(a.AggregationBits); size > 131072 { - err = ssz.ErrBytesLengthFn("--.AggregationBits", size, 131072) - return + // Field 1: Attestation_2 + if dst, err = c.Attestation_2.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Attestation_2: %w", err) } - dst = append(dst, a.AggregationBits...) - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the AttestationElectra object -func (a *AttestationElectra) UnmarshalSSZ(buf []byte) error { +func (c *AttesterSlashingElectra) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 236 { + if size < 8 { 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 { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Attestation_1 + if sszVarOffset0 != 8 { 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 + if sszVarOffset0 > size { + return ssz.ErrOffset } - - // Field (2) 'Signature' - if cap(a.Signature) == 0 { - a.Signature = make([]byte, 0, len(buf[132:228])) + sszVarOffset1 := ssz.ReadOffset(buf[4:8]) // c.Attestation_2 + if sszVarOffset1 > size || sszVarOffset1 < sszVarOffset0 { + return ssz.ErrOffset } - a.Signature = append(a.Signature, buf[132:228]...) + sszSlice0 := buf[sszVarOffset0:sszVarOffset1] // c.Attestation_1 + sszSlice1 := buf[sszVarOffset1:] // c.Attestation_2 - // Field (3) 'CommitteeBits' - if cap(a.CommitteeBits) == 0 { - a.CommitteeBits = make([]byte, 0, len(buf[228:236])) + // Field 0: Attestation_1 + c.Attestation_1 = new(IndexedAttestationElectra) + if err = c.Attestation_1.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Attestation_1: %w", err) } - 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...) + // Field 1: Attestation_2 + c.Attestation_2 = new(IndexedAttestationElectra) + if err = c.Attestation_2.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Attestation_2: %w", err) } return err } -// SizeSSZ returns the ssz encoded size in bytes for the AttestationElectra object -func (a *AttestationElectra) SizeSSZ() (size int) { - size = 236 - - // Field (0) 'AggregationBits' - size += len(a.AggregationBits) - - return -} - -// HashTreeRoot ssz hashes the AttestationElectra object -func (a *AttestationElectra) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(a) +func (c *AttesterSlashingElectra) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the AttestationElectra object with a hasher -func (a *AttestationElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *AttesterSlashingElectra) HashTreeRootWith(hh *ssz.Hasher) (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 err = a.Data.HashTreeRootWith(hh); err != nil { - return - } - - // Field (2) 'Signature' - if size := len(a.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 0: Attestation_1 + if err := c.Attestation_1.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Attestation_1: %w", err) } - hh.PutBytes(a.Signature) - - // Field (3) 'CommitteeBits' - if size := len(a.CommitteeBits); size != 8 { - err = ssz.ErrBytesLengthFn("--.CommitteeBits", size, 8) - return + // Field 1: Attestation_2 + if err := c.Attestation_2.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Attestation_2: %w", err) } - hh.PutBytes(a.CommitteeBits) - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the SingleAttestation object -func (s *SingleAttestation) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) + return nil } -// MarshalSSZTo ssz marshals the SingleAttestation object to a target array -func (s *SingleAttestation) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - - // Field (0) 'CommitteeId' - dst = ssz.MarshalUint(dst, s.CommitteeId) - - // Field (1) 'AttesterIndex' - dst = ssz.MarshalUint(dst, s.AttesterIndex) - - // Field (2) 'Data' - if s.Data == nil { - s.Data = new(AttestationData) +func (c *BeaconBlockBodyElectra) SizeSSZ() int { + size := 396 + size += len(c.ProposerSlashings) * 416 + for _, o := range c.AttesterSlashings { + size += 4 + size += o.SizeSSZ() + } + for _, o := range c.Attestations { + size += 4 + size += o.SizeSSZ() } - if dst, err = s.Data.MarshalSSZTo(dst); err != nil { - return + size += len(c.Deposits) * 1240 + size += len(c.VoluntaryExits) * 112 + if c.ExecutionPayload == nil { + c.ExecutionPayload = new(v1.ExecutionPayloadDeneb) } - - // Field (3) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + size += c.ExecutionPayload.SizeSSZ() + size += len(c.BlsToExecutionChanges) * 172 + size += len(c.BlobKzgCommitments) * 48 + if c.ExecutionRequests == nil { + c.ExecutionRequests = new(v1.ExecutionRequests) } - dst = append(dst, s.Signature...) + size += c.ExecutionRequests.SizeSSZ() + return size +} - return +func (c *BeaconBlockBodyElectra) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// UnmarshalSSZ ssz unmarshals the SingleAttestation object -func (s *SingleAttestation) UnmarshalSSZ(buf []byte) error { +func (c *BeaconBlockBodyElectra) MarshalSSZTo(dst []byte) ([]byte, error) { var err error - size := uint64(len(buf)) - if size != 240 { - return ssz.ErrSize - } - - // Field (0) 'CommitteeId' - s.CommitteeId = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.CommitteeIndex](buf[0:8]) + offset := 396 - // Field (1) 'AttesterIndex' - s.AttesterIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[8:16]) + // Field 0: RandaoReveal + if len(c.RandaoReveal) != 96 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.RandaoReveal...) - // Field (2) 'Data' - if s.Data == nil { - s.Data = new(AttestationData) + // Field 1: Eth1Data + if c.Eth1Data == nil { + c.Eth1Data = new(Eth1Data) } - if err = s.Data.UnmarshalSSZ(buf[16:144]); err != nil { - return err + if dst, err = c.Eth1Data.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Eth1Data: %w", err) } - // Field (3) 'Signature' - if cap(s.Signature) == 0 { - s.Signature = make([]byte, 0, len(buf[144:240])) + // Field 2: Graffiti + if len(c.Graffiti) != 32 { + return nil, ssz.ErrBytesLength } - s.Signature = append(s.Signature, buf[144:240]...) - - return err -} + dst = append(dst, c.Graffiti...) -// SizeSSZ returns the ssz encoded size in bytes for the SingleAttestation object -func (s *SingleAttestation) SizeSSZ() (size int) { - size = 240 - return -} + // Field 3: ProposerSlashings + dst = ssz.WriteOffset(dst, offset) + offset += len(c.ProposerSlashings) * 416 -// HashTreeRoot ssz hashes the SingleAttestation object -func (s *SingleAttestation) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) -} + // Field 4: AttesterSlashings + dst = ssz.WriteOffset(dst, offset) + for _, o := range c.AttesterSlashings { + offset += 4 + offset += o.SizeSSZ() + } -// HashTreeRootWith ssz hashes the SingleAttestation object with a hasher -func (s *SingleAttestation) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() + // Field 5: Attestations + dst = ssz.WriteOffset(dst, offset) + for _, o := range c.Attestations { + offset += 4 + offset += o.SizeSSZ() + } - // Field (0) 'CommitteeId' - ssz.PutUint(hh, s.CommitteeId) + // Field 6: Deposits + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Deposits) * 1240 - // Field (1) 'AttesterIndex' - ssz.PutUint(hh, s.AttesterIndex) + // Field 7: VoluntaryExits + dst = ssz.WriteOffset(dst, offset) + offset += len(c.VoluntaryExits) * 112 - // Field (2) 'Data' - if err = s.Data.HashTreeRootWith(hh); err != nil { - return + // Field 8: SyncAggregate + if c.SyncAggregate == nil { + c.SyncAggregate = new(SyncAggregate) } - - // Field (3) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + if dst, err = c.SyncAggregate.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SyncAggregate: %w", err) } - hh.PutBytes(s.Signature) - hh.Merkleize(indx) - return -} + // Field 9: ExecutionPayload + if c.ExecutionPayload == nil { + c.ExecutionPayload = new(v1.ExecutionPayloadDeneb) + } + dst = ssz.WriteOffset(dst, offset) + offset += c.ExecutionPayload.SizeSSZ() -// MarshalSSZ ssz marshals the BuilderBidElectra object -func (b *BuilderBidElectra) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} + // Field 10: BlsToExecutionChanges + dst = ssz.WriteOffset(dst, offset) + offset += len(c.BlsToExecutionChanges) * 172 -// MarshalSSZTo ssz marshals the BuilderBidElectra object to a target array -func (b *BuilderBidElectra) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(92) + // Field 11: BlobKzgCommitments + dst = ssz.WriteOffset(dst, offset) + offset += len(c.BlobKzgCommitments) * 48 - // Offset (0) 'Header' + // Field 12: ExecutionRequests + if c.ExecutionRequests == nil { + c.ExecutionRequests = new(v1.ExecutionRequests) + } dst = ssz.WriteOffset(dst, offset) - if b.Header == nil { - b.Header = new(v1.ExecutionPayloadHeaderDeneb) + offset += c.ExecutionRequests.SizeSSZ() + + // Field 3: ProposerSlashings + if len(c.ProposerSlashings) > 16 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.ProposerSlashings { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ProposerSlashings: %w", err) + } } - offset += b.Header.SizeSSZ() - // Offset (1) 'BlobKzgCommitments' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.BlobKzgCommitments) * 48 + // Field 4: AttesterSlashings + if len(c.AttesterSlashings) > 1 { + return nil, ssz.ErrListTooBig + } + { + offset = 4 * len(c.AttesterSlashings) + for _, o := range c.AttesterSlashings { + dst = ssz.WriteOffset(dst, offset) + offset += o.SizeSSZ() + } + } + for _, o := range c.AttesterSlashings { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("AttesterSlashings: %w", err) + } + } - // Offset (2) 'ExecutionRequests' - dst = ssz.WriteOffset(dst, offset) - if b.ExecutionRequests == nil { - b.ExecutionRequests = new(v1.ExecutionRequests) + // Field 5: Attestations + if len(c.Attestations) > 8 { + return nil, ssz.ErrListTooBig + } + { + offset = 4 * len(c.Attestations) + for _, o := range c.Attestations { + dst = ssz.WriteOffset(dst, offset) + offset += o.SizeSSZ() + } + } + for _, o := range c.Attestations { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Attestations: %w", err) + } } - offset += b.ExecutionRequests.SizeSSZ() - // Field (3) 'Value' - if size := len(b.Value); size != 32 { - err = ssz.ErrBytesLengthFn("--.Value", size, 32) - return + // Field 6: Deposits + if len(c.Deposits) > 16 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.Deposits { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Deposits: %w", err) + } } - dst = append(dst, b.Value...) - // Field (4) 'Pubkey' - if size := len(b.Pubkey); size != 48 { - err = ssz.ErrBytesLengthFn("--.Pubkey", size, 48) - return + // Field 7: VoluntaryExits + if len(c.VoluntaryExits) > 16 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.VoluntaryExits { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("VoluntaryExits: %w", err) + } } - dst = append(dst, b.Pubkey...) - // Field (0) 'Header' - if dst, err = b.Header.MarshalSSZTo(dst); err != nil { - return + // Field 9: ExecutionPayload + if dst, err = c.ExecutionPayload.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ExecutionPayload: %w", err) } - // Field (1) 'BlobKzgCommitments' - if size := len(b.BlobKzgCommitments); size > 4096 { - err = ssz.ErrListTooBigFn("--.BlobKzgCommitments", size, 4096) - return + // Field 10: BlsToExecutionChanges + if len(c.BlsToExecutionChanges) > 16 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.BlobKzgCommitments); ii++ { - if size := len(b.BlobKzgCommitments[ii]); size != 48 { - err = ssz.ErrBytesLengthFn("--.BlobKzgCommitments[ii]", size, 48) - return + for _, o := range c.BlsToExecutionChanges { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("BlsToExecutionChanges: %w", err) } - dst = append(dst, b.BlobKzgCommitments[ii]...) } - // Field (2) 'ExecutionRequests' - if dst, err = b.ExecutionRequests.MarshalSSZTo(dst); err != nil { - return + // Field 11: BlobKzgCommitments + if len(c.BlobKzgCommitments) > 4096 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.BlobKzgCommitments { + if len(o) != 48 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) } - return + // Field 12: ExecutionRequests + if dst, err = c.ExecutionRequests.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ExecutionRequests: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the BuilderBidElectra object -func (b *BuilderBidElectra) UnmarshalSSZ(buf []byte) error { +func (c *BeaconBlockBodyElectra) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 92 { + if size < 396 { return ssz.ErrSize } - tail := buf - var o0, o1, o2 uint64 + sszSlice0 := buf[0:96] // c.RandaoReveal + sszSlice1 := buf[96:168] // c.Eth1Data + sszSlice2 := buf[168:200] // c.Graffiti + sszSlice8 := buf[220:380] // c.SyncAggregate - // Offset (0) 'Header' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { + sszVarOffset3 := ssz.ReadOffset(buf[200:204]) // c.ProposerSlashings + if sszVarOffset3 != 396 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset3 > size { return ssz.ErrOffset } - - if o0 != 92 { - return ssz.ErrInvalidVariableOffset + sszVarOffset4 := ssz.ReadOffset(buf[204:208]) // c.AttesterSlashings + if sszVarOffset4 > size || sszVarOffset4 < sszVarOffset3 { + return ssz.ErrOffset } - - // Offset (1) 'BlobKzgCommitments' - if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 { + sszVarOffset5 := ssz.ReadOffset(buf[208:212]) // c.Attestations + if sszVarOffset5 > size || sszVarOffset5 < sszVarOffset4 { return ssz.ErrOffset } - - // Offset (2) 'ExecutionRequests' - if o2 = ssz.ReadOffset(buf[8:12]); o2 > size || o1 > o2 { + sszVarOffset6 := ssz.ReadOffset(buf[212:216]) // c.Deposits + if sszVarOffset6 > size || sszVarOffset6 < sszVarOffset5 { return ssz.ErrOffset } - - // Field (3) 'Value' - if cap(b.Value) == 0 { - b.Value = make([]byte, 0, len(buf[12:44])) + sszVarOffset7 := ssz.ReadOffset(buf[216:220]) // c.VoluntaryExits + if sszVarOffset7 > size || sszVarOffset7 < sszVarOffset6 { + return ssz.ErrOffset + } + sszVarOffset9 := ssz.ReadOffset(buf[380:384]) // c.ExecutionPayload + if sszVarOffset9 > size || sszVarOffset9 < sszVarOffset7 { + return ssz.ErrOffset + } + sszVarOffset10 := ssz.ReadOffset(buf[384:388]) // c.BlsToExecutionChanges + if sszVarOffset10 > size || sszVarOffset10 < sszVarOffset9 { + return ssz.ErrOffset + } + sszVarOffset11 := ssz.ReadOffset(buf[388:392]) // c.BlobKzgCommitments + if sszVarOffset11 > size || sszVarOffset11 < sszVarOffset10 { + return ssz.ErrOffset + } + sszVarOffset12 := ssz.ReadOffset(buf[392:396]) // c.ExecutionRequests + if sszVarOffset12 > size || sszVarOffset12 < sszVarOffset11 { + return ssz.ErrOffset } - b.Value = append(b.Value, buf[12:44]...) + sszSlice3 := buf[sszVarOffset3:sszVarOffset4] // c.ProposerSlashings + sszSlice4 := buf[sszVarOffset4:sszVarOffset5] // c.AttesterSlashings + sszSlice5 := buf[sszVarOffset5:sszVarOffset6] // c.Attestations + sszSlice6 := buf[sszVarOffset6:sszVarOffset7] // c.Deposits + sszSlice7 := buf[sszVarOffset7:sszVarOffset9] // c.VoluntaryExits + sszSlice9 := buf[sszVarOffset9:sszVarOffset10] // c.ExecutionPayload + sszSlice10 := buf[sszVarOffset10:sszVarOffset11] // c.BlsToExecutionChanges + sszSlice11 := buf[sszVarOffset11:sszVarOffset12] // c.BlobKzgCommitments + sszSlice12 := buf[sszVarOffset12:] // c.ExecutionRequests + + // Field 0: RandaoReveal + c.RandaoReveal = make([]byte, 0, 96) + c.RandaoReveal = append(c.RandaoReveal, sszSlice0...) - // Field (4) 'Pubkey' - if cap(b.Pubkey) == 0 { - b.Pubkey = make([]byte, 0, len(buf[44:92])) + // Field 1: Eth1Data + c.Eth1Data = new(Eth1Data) + if err = c.Eth1Data.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Eth1Data: %w", err) } - b.Pubkey = append(b.Pubkey, buf[44:92]...) - // Field (0) 'Header' + // Field 2: Graffiti + c.Graffiti = make([]byte, 0, 32) + c.Graffiti = append(c.Graffiti, sszSlice2...) + + // Field 3: ProposerSlashings { - buf = tail[o0:o1] - if b.Header == nil { - b.Header = new(v1.ExecutionPayloadHeaderDeneb) - } - if err = b.Header.UnmarshalSSZ(buf); err != nil { - return err + if len(sszSlice3)%416 != 0 { + return fmt.Errorf("misaligned bytes: c.ProposerSlashings length is %d, which is not a multiple of 416: %w", len(sszSlice3), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice3) / 416 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.ProposerSlashings has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.ProposerSlashings = make([]*ProposerSlashing, numElem) + for i := 0; i < numElem; i++ { + var tmp *ProposerSlashing + tmp = new(ProposerSlashing) + tmpSlice := sszSlice3[i*416 : (1+i)*416] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("ProposerSlashings: %w", err) + } + c.ProposerSlashings[i] = tmp } } - // Field (1) 'BlobKzgCommitments' + // Field 4: AttesterSlashings { - buf = tail[o1:o2] - num, err := ssz.DivideInt2(len(buf), 48, 4096) - if err != nil { - return err - } - b.BlobKzgCommitments = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(b.BlobKzgCommitments[ii]) == 0 { - b.BlobKzgCommitments[ii] = make([]byte, 0, len(buf[ii*48:(ii+1)*48])) + // empty lists are zero length, so make sure there is room for an offset + // before attempting to unmarshal it + if len(sszSlice4) > 3 { + startOffset := ssz.ReadOffset(sszSlice4[0:4]) + if startOffset == 0 { + return fmt.Errorf("encountered invalid offset of 0 when decoding c.AttesterSlashings") + } + if startOffset%4 != 0 { + return fmt.Errorf("misaligned list bytes: when decoding c.AttesterSlashings, end-of-list offset is %d, which is not a multiple of 4 (offset size)", startOffset) + } + listLen := startOffset / 4 + if listLen > 1 { + return fmt.Errorf("ssz-max exceeded: c.AttesterSlashings has %d elements, ssz-max is 1: %w", listLen, ssz.ErrListTooBig) + } + totalVarBytes := uint64(len(sszSlice4)) + if totalVarBytes < startOffset { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.AttesterSlashings") } - b.BlobKzgCommitments[ii] = append(b.BlobKzgCommitments[ii], buf[ii*48:(ii+1)*48]...) + c.AttesterSlashings = make([]*AttesterSlashingElectra, listLen) + var tmpSlice []byte + for i := uint64(0); i < listLen; i++ { + var tmp *AttesterSlashingElectra + tmp = new(AttesterSlashingElectra) + endOffset := totalVarBytes + if i+1 != listLen { + endOffset = ssz.ReadOffset(sszSlice4[(i+1)*4 : (i+2)*4]) + if totalVarBytes < endOffset { + return fmt.Errorf("offset %d points past the end of buffer when decoding c.AttesterSlashings", endOffset) + } + } + if endOffset < startOffset { + return fmt.Errorf("offset %d is not greater than start offset %d when decoding c.AttesterSlashings", endOffset, startOffset) + } + tmpSlice = sszSlice4[startOffset:endOffset] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("AttesterSlashings: %w", err) + } + c.AttesterSlashings[i] = tmp + startOffset = endOffset + } + } else { + if len(sszSlice4) > 0 { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.AttesterSlashings") + } + c.AttesterSlashings = make([]*AttesterSlashingElectra, 0) } } - // Field (2) 'ExecutionRequests' + // Field 5: Attestations { - buf = tail[o2:] - if b.ExecutionRequests == nil { - b.ExecutionRequests = new(v1.ExecutionRequests) - } - if err = b.ExecutionRequests.UnmarshalSSZ(buf); err != nil { - return err + // empty lists are zero length, so make sure there is room for an offset + // before attempting to unmarshal it + if len(sszSlice5) > 3 { + startOffset := ssz.ReadOffset(sszSlice5[0:4]) + if startOffset == 0 { + return fmt.Errorf("encountered invalid offset of 0 when decoding c.Attestations") + } + if startOffset%4 != 0 { + return fmt.Errorf("misaligned list bytes: when decoding c.Attestations, end-of-list offset is %d, which is not a multiple of 4 (offset size)", startOffset) + } + listLen := startOffset / 4 + if listLen > 8 { + return fmt.Errorf("ssz-max exceeded: c.Attestations has %d elements, ssz-max is 8: %w", listLen, ssz.ErrListTooBig) + } + totalVarBytes := uint64(len(sszSlice5)) + if totalVarBytes < startOffset { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.Attestations") + } + c.Attestations = make([]*AttestationElectra, listLen) + var tmpSlice []byte + for i := uint64(0); i < listLen; i++ { + var tmp *AttestationElectra + tmp = new(AttestationElectra) + endOffset := totalVarBytes + if i+1 != listLen { + endOffset = ssz.ReadOffset(sszSlice5[(i+1)*4 : (i+2)*4]) + if totalVarBytes < endOffset { + return fmt.Errorf("offset %d points past the end of buffer when decoding c.Attestations", endOffset) + } + } + if endOffset < startOffset { + return fmt.Errorf("offset %d is not greater than start offset %d when decoding c.Attestations", endOffset, startOffset) + } + tmpSlice = sszSlice5[startOffset:endOffset] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Attestations: %w", err) + } + c.Attestations[i] = tmp + startOffset = endOffset + } + } else { + if len(sszSlice5) > 0 { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.Attestations") + } + c.Attestations = make([]*AttestationElectra, 0) } } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the BuilderBidElectra object -func (b *BuilderBidElectra) SizeSSZ() (size int) { - size = 92 - // Field (0) 'Header' - if b.Header == nil { - b.Header = new(v1.ExecutionPayloadHeaderDeneb) + // Field 6: Deposits + { + if len(sszSlice6)%1240 != 0 { + return fmt.Errorf("misaligned bytes: c.Deposits length is %d, which is not a multiple of 1240: %w", len(sszSlice6), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice6) / 1240 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.Deposits has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.Deposits = make([]*Deposit, numElem) + for i := 0; i < numElem; i++ { + var tmp *Deposit + tmp = new(Deposit) + tmpSlice := sszSlice6[i*1240 : (1+i)*1240] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Deposits: %w", err) + } + c.Deposits[i] = tmp + } } - size += b.Header.SizeSSZ() - - // Field (1) 'BlobKzgCommitments' - size += len(b.BlobKzgCommitments) * 48 - // Field (2) 'ExecutionRequests' - if b.ExecutionRequests == nil { - b.ExecutionRequests = new(v1.ExecutionRequests) + // Field 7: VoluntaryExits + { + if len(sszSlice7)%112 != 0 { + return fmt.Errorf("misaligned bytes: c.VoluntaryExits length is %d, which is not a multiple of 112: %w", len(sszSlice7), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice7) / 112 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.VoluntaryExits has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.VoluntaryExits = make([]*SignedVoluntaryExit, numElem) + for i := 0; i < numElem; i++ { + var tmp *SignedVoluntaryExit + tmp = new(SignedVoluntaryExit) + tmpSlice := sszSlice7[i*112 : (1+i)*112] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("VoluntaryExits: %w", err) + } + c.VoluntaryExits[i] = tmp + } } - size += b.ExecutionRequests.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the BuilderBidElectra object -func (b *BuilderBidElectra) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) -} -// HashTreeRootWith ssz hashes the BuilderBidElectra object with a hasher -func (b *BuilderBidElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() + // Field 8: SyncAggregate + c.SyncAggregate = new(SyncAggregate) + if err = c.SyncAggregate.UnmarshalSSZ(sszSlice8); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) + } - // Field (0) 'Header' - if err = b.Header.HashTreeRootWith(hh); err != nil { - return + // Field 9: ExecutionPayload + c.ExecutionPayload = new(v1.ExecutionPayloadDeneb) + if err = c.ExecutionPayload.UnmarshalSSZ(sszSlice9); err != nil { + return fmt.Errorf("ExecutionPayload: %w", err) } - // Field (1) 'BlobKzgCommitments' + // Field 10: BlsToExecutionChanges { - if size := len(b.BlobKzgCommitments); size > 4096 { - err = ssz.ErrListTooBigFn("--.BlobKzgCommitments", size, 4096) - return - } - subIndx := hh.Index() - for _, i := range b.BlobKzgCommitments { - if len(i) != 48 { - err = ssz.ErrBytesLength - return + if len(sszSlice10)%172 != 0 { + return fmt.Errorf("misaligned bytes: c.BlsToExecutionChanges length is %d, which is not a multiple of 172: %w", len(sszSlice10), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice10) / 172 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.BlsToExecutionChanges has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.BlsToExecutionChanges = make([]*SignedBLSToExecutionChange, numElem) + for i := 0; i < numElem; i++ { + var tmp *SignedBLSToExecutionChange + tmp = new(SignedBLSToExecutionChange) + tmpSlice := sszSlice10[i*172 : (1+i)*172] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("BlsToExecutionChanges: %w", err) } - hh.PutBytes(i) + c.BlsToExecutionChanges[i] = tmp } - - numItems := uint64(len(b.BlobKzgCommitments)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) } - // Field (2) 'ExecutionRequests' - if err = b.ExecutionRequests.HashTreeRootWith(hh); err != nil { - return - } + // Field 11: BlobKzgCommitments + { + if len(sszSlice11)%48 != 0 { + return fmt.Errorf("misaligned bytes: c.BlobKzgCommitments length is %d, which is not a multiple of 48: %w", len(sszSlice11), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice11) / 48 + if numElem > 4096 { + return fmt.Errorf("ssz-max exceeded: c.BlobKzgCommitments has %d elements, ssz-max is 4096: %w", numElem, ssz.ErrListTooBig) + } + c.BlobKzgCommitments = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte - // Field (3) 'Value' - if size := len(b.Value); size != 32 { - err = ssz.ErrBytesLengthFn("--.Value", size, 32) - return + tmpSlice := sszSlice11[i*48 : (1+i)*48] + tmp = make([]byte, 0, 48) + tmp = append(tmp, tmpSlice...) + c.BlobKzgCommitments[i] = tmp + } } - hh.PutBytes(b.Value) - // Field (4) 'Pubkey' - if size := len(b.Pubkey); size != 48 { - err = ssz.ErrBytesLengthFn("--.Pubkey", size, 48) - return + // Field 12: ExecutionRequests + c.ExecutionRequests = new(v1.ExecutionRequests) + if err = c.ExecutionRequests.UnmarshalSSZ(sszSlice12); err != nil { + return fmt.Errorf("ExecutionRequests: %w", err) } - hh.PutBytes(b.Pubkey) - - hh.Merkleize(indx) - return + return err } -// MarshalSSZ ssz marshals the SignedBuilderBidElectra object -func (s *SignedBuilderBidElectra) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) +func (c *BeaconBlockBodyElectra) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// MarshalSSZTo ssz marshals the SignedBuilderBidElectra object to a target array -func (s *SignedBuilderBidElectra) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(100) - - // Offset (0) 'Message' - dst = ssz.WriteOffset(dst, offset) - if s.Message == nil { - s.Message = new(BuilderBidElectra) +func (c *BeaconBlockBodyElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: RandaoReveal + if len(c.RandaoReveal) != 96 { + return ssz.ErrBytesLength } - offset += s.Message.SizeSSZ() - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + hh.PutBytes(c.RandaoReveal) + // Field 1: Eth1Data + if err := c.Eth1Data.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Eth1Data: %w", err) } - dst = append(dst, s.Signature...) - - // Field (0) 'Message' - if dst, err = s.Message.MarshalSSZTo(dst); err != nil { - return + // Field 2: Graffiti + if len(c.Graffiti) != 32 { + return ssz.ErrBytesLength } - - return -} - -// UnmarshalSSZ ssz unmarshals the SignedBuilderBidElectra object -func (s *SignedBuilderBidElectra) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 100 { - return ssz.ErrSize + hh.PutBytes(c.Graffiti) + // Field 3: ProposerSlashings + { + if len(c.ProposerSlashings) > 16 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.ProposerSlashings { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ProposerSlashings: %w", err) + } + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.ProposerSlashings)), 16) } - - tail := buf - var o0 uint64 - - // Offset (0) 'Message' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset + // Field 4: AttesterSlashings + { + if len(c.AttesterSlashings) > 1 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.AttesterSlashings { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("AttesterSlashings: %w", err) + } + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.AttesterSlashings)), 1) } - - if o0 != 100 { - return ssz.ErrInvalidVariableOffset + // Field 5: Attestations + { + if len(c.Attestations) > 8 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.Attestations { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Attestations: %w", err) + } + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Attestations)), 8) } - - // Field (1) 'Signature' - if cap(s.Signature) == 0 { - s.Signature = make([]byte, 0, len(buf[4:100])) + // Field 6: Deposits + { + if len(c.Deposits) > 16 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.Deposits { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Deposits: %w", err) + } + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Deposits)), 16) } - s.Signature = append(s.Signature, buf[4:100]...) - - // Field (0) 'Message' + // Field 7: VoluntaryExits { - buf = tail[o0:] - if s.Message == nil { - s.Message = new(BuilderBidElectra) + if len(c.VoluntaryExits) > 16 { + return ssz.ErrListTooBig } - if err = s.Message.UnmarshalSSZ(buf); err != nil { - return err + subIndx := hh.Index() + for _, o := range c.VoluntaryExits { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("VoluntaryExits: %w", err) + } } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.VoluntaryExits)), 16) } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the SignedBuilderBidElectra object -func (s *SignedBuilderBidElectra) SizeSSZ() (size int) { - size = 100 - - // Field (0) 'Message' - if s.Message == nil { - s.Message = new(BuilderBidElectra) + // Field 8: SyncAggregate + if err := c.SyncAggregate.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) } - size += s.Message.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the SignedBuilderBidElectra object -func (s *SignedBuilderBidElectra) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) -} - -// HashTreeRootWith ssz hashes the SignedBuilderBidElectra object with a hasher -func (s *SignedBuilderBidElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'Message' - if err = s.Message.HashTreeRootWith(hh); err != nil { - return + // Field 9: ExecutionPayload + if err := c.ExecutionPayload.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ExecutionPayload: %w", err) } - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 10: BlsToExecutionChanges + { + if len(c.BlsToExecutionChanges) > 16 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.BlsToExecutionChanges { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("BlsToExecutionChanges: %w", err) + } + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.BlsToExecutionChanges)), 16) + } + // Field 11: BlobKzgCommitments + { + if len(c.BlobKzgCommitments) > 4096 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.BlobKzgCommitments { + if len(o) != 48 { + return ssz.ErrBytesLength + } + hh.PutBytes(o) + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.BlobKzgCommitments)), 4096) + } + // Field 12: ExecutionRequests + if err := c.ExecutionRequests.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ExecutionRequests: %w", err) } - hh.PutBytes(s.Signature) - hh.Merkleize(indx) - return + return nil +} + +func (c *BeaconBlockContentsElectra) SizeSSZ() int { + size := 12 + if c.Block == nil { + c.Block = new(BeaconBlockElectra) + } + size += c.Block.SizeSSZ() + size += len(c.KzgProofs) * 48 + size += len(c.Blobs) * 131072 + return size } -// MarshalSSZ ssz marshals the SignedBeaconBlockContentsElectra object -func (s *SignedBeaconBlockContentsElectra) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) +func (c *BeaconBlockContentsElectra) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the SignedBeaconBlockContentsElectra object to a target array -func (s *SignedBeaconBlockContentsElectra) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(12) +func (c *BeaconBlockContentsElectra) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 12 - // Offset (0) 'Block' - dst = ssz.WriteOffset(dst, offset) - if s.Block == nil { - s.Block = new(SignedBeaconBlockElectra) + // Field 0: Block + if c.Block == nil { + c.Block = new(BeaconBlockElectra) } - offset += s.Block.SizeSSZ() + dst = ssz.WriteOffset(dst, offset) + offset += c.Block.SizeSSZ() - // Offset (1) 'KzgProofs' + // Field 1: KzgProofs dst = ssz.WriteOffset(dst, offset) - offset += len(s.KzgProofs) * 48 + offset += len(c.KzgProofs) * 48 - // Offset (2) 'Blobs' + // Field 2: Blobs dst = ssz.WriteOffset(dst, offset) - offset += len(s.Blobs) * 131072 + offset += len(c.Blobs) * 131072 - // Field (0) 'Block' - if dst, err = s.Block.MarshalSSZTo(dst); err != nil { - return + // Field 0: Block + if dst, err = c.Block.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Block: %w", err) } - // Field (1) 'KzgProofs' - if size := len(s.KzgProofs); size > 4096 { - err = ssz.ErrListTooBigFn("--.KzgProofs", size, 4096) - return + // Field 1: KzgProofs + if len(c.KzgProofs) > 4096 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(s.KzgProofs); ii++ { - if size := len(s.KzgProofs[ii]); size != 48 { - err = ssz.ErrBytesLengthFn("--.KzgProofs[ii]", size, 48) - return + for _, o := range c.KzgProofs { + if len(o) != 48 { + return nil, ssz.ErrBytesLength } - dst = append(dst, s.KzgProofs[ii]...) + dst = append(dst, o...) } - // Field (2) 'Blobs' - if size := len(s.Blobs); size > 4096 { - err = ssz.ErrListTooBigFn("--.Blobs", size, 4096) - return + // Field 2: Blobs + if len(c.Blobs) > 4096 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(s.Blobs); ii++ { - if size := len(s.Blobs[ii]); size != 131072 { - err = ssz.ErrBytesLengthFn("--.Blobs[ii]", size, 131072) - return + for _, o := range c.Blobs { + if len(o) != 131072 { + return nil, ssz.ErrBytesLength } - dst = append(dst, s.Blobs[ii]...) + dst = append(dst, o...) } - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the SignedBeaconBlockContentsElectra object -func (s *SignedBeaconBlockContentsElectra) UnmarshalSSZ(buf []byte) error { +func (c *BeaconBlockContentsElectra) 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) 'Block' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Block + if sszVarOffset0 != 12 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset0 > size { return ssz.ErrOffset } - - if o0 != 12 { - return ssz.ErrInvalidVariableOffset + sszVarOffset1 := ssz.ReadOffset(buf[4:8]) // c.KzgProofs + if sszVarOffset1 > size || sszVarOffset1 < sszVarOffset0 { + return ssz.ErrOffset } - - // Offset (1) 'KzgProofs' - if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 { + sszVarOffset2 := ssz.ReadOffset(buf[8:12]) // c.Blobs + if sszVarOffset2 > size || sszVarOffset2 < sszVarOffset1 { return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:sszVarOffset1] // c.Block + sszSlice1 := buf[sszVarOffset1:sszVarOffset2] // c.KzgProofs + sszSlice2 := buf[sszVarOffset2:] // c.Blobs - // Offset (2) 'Blobs' - if o2 = ssz.ReadOffset(buf[8:12]); o2 > size || o1 > o2 { - return ssz.ErrOffset + // Field 0: Block + c.Block = new(BeaconBlockElectra) + if err = c.Block.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Block: %w", err) } - // Field (0) 'Block' + // Field 1: KzgProofs { - buf = tail[o0:o1] - if s.Block == nil { - s.Block = new(SignedBeaconBlockElectra) + if len(sszSlice1)%48 != 0 { + return fmt.Errorf("misaligned bytes: c.KzgProofs length is %d, which is not a multiple of 48: %w", len(sszSlice1), ssz.ErrIncorrectListSize) } - if err = s.Block.UnmarshalSSZ(buf); err != nil { - return err + numElem := len(sszSlice1) / 48 + if numElem > 4096 { + return fmt.Errorf("ssz-max exceeded: c.KzgProofs has %d elements, ssz-max is 4096: %w", numElem, ssz.ErrListTooBig) } - } + c.KzgProofs = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte - // Field (1) 'KzgProofs' - { - buf = tail[o1:o2] - num, err := ssz.DivideInt2(len(buf), 48, 4096) - if err != nil { - return err - } - s.KzgProofs = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(s.KzgProofs[ii]) == 0 { - s.KzgProofs[ii] = make([]byte, 0, len(buf[ii*48:(ii+1)*48])) - } - s.KzgProofs[ii] = append(s.KzgProofs[ii], buf[ii*48:(ii+1)*48]...) + tmpSlice := sszSlice1[i*48 : (1+i)*48] + tmp = make([]byte, 0, 48) + tmp = append(tmp, tmpSlice...) + c.KzgProofs[i] = tmp } } - // Field (2) 'Blobs' + // Field 2: Blobs { - buf = tail[o2:] - num, err := ssz.DivideInt2(len(buf), 131072, 4096) - if err != nil { - return err - } - s.Blobs = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(s.Blobs[ii]) == 0 { - s.Blobs[ii] = make([]byte, 0, len(buf[ii*131072:(ii+1)*131072])) - } - s.Blobs[ii] = append(s.Blobs[ii], buf[ii*131072:(ii+1)*131072]...) + if len(sszSlice2)%131072 != 0 { + return fmt.Errorf("misaligned bytes: c.Blobs length is %d, which is not a multiple of 131072: %w", len(sszSlice2), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice2) / 131072 + if numElem > 4096 { + return fmt.Errorf("ssz-max exceeded: c.Blobs has %d elements, ssz-max is 4096: %w", numElem, ssz.ErrListTooBig) + } + c.Blobs = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte + + tmpSlice := sszSlice2[i*131072 : (1+i)*131072] + tmp = make([]byte, 0, 131072) + tmp = append(tmp, tmpSlice...) + c.Blobs[i] = tmp } } return err } -// SizeSSZ returns the ssz encoded size in bytes for the SignedBeaconBlockContentsElectra object -func (s *SignedBeaconBlockContentsElectra) SizeSSZ() (size int) { - size = 12 - - // Field (0) 'Block' - if s.Block == nil { - s.Block = new(SignedBeaconBlockElectra) +func (c *BeaconBlockContentsElectra) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - size += s.Block.SizeSSZ() - - // Field (1) 'KzgProofs' - size += len(s.KzgProofs) * 48 - - // Field (2) 'Blobs' - size += len(s.Blobs) * 131072 - - return -} - -// HashTreeRoot ssz hashes the SignedBeaconBlockContentsElectra object -func (s *SignedBeaconBlockContentsElectra) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the SignedBeaconBlockContentsElectra object with a hasher -func (s *SignedBeaconBlockContentsElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *BeaconBlockContentsElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Block' - if err = s.Block.HashTreeRootWith(hh); err != nil { - return + // Field 0: Block + if err := c.Block.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Block: %w", err) } - - // Field (1) 'KzgProofs' + // Field 1: KzgProofs { - if size := len(s.KzgProofs); size > 4096 { - err = ssz.ErrListTooBigFn("--.KzgProofs", size, 4096) - return + if len(c.KzgProofs) > 4096 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range s.KzgProofs { - if len(i) != 48 { - err = ssz.ErrBytesLength - return + for _, o := range c.KzgProofs { + if len(o) != 48 { + return ssz.ErrBytesLength } - hh.PutBytes(i) + hh.PutBytes(o) } - - numItems := uint64(len(s.KzgProofs)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.KzgProofs)), 4096) } - - // Field (2) 'Blobs' + // Field 2: Blobs { - if size := len(s.Blobs); size > 4096 { - err = ssz.ErrListTooBigFn("--.Blobs", size, 4096) - return + if len(c.Blobs) > 4096 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range s.Blobs { - if len(i) != 131072 { - err = ssz.ErrBytesLength - return + for _, o := range c.Blobs { + if len(o) != 131072 { + return ssz.ErrBytesLength } - hh.PutBytes(i) + hh.PutBytes(o) } - - numItems := uint64(len(s.Blobs)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Blobs)), 4096) } - hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the SignedBeaconBlockElectra object -func (s *SignedBeaconBlockElectra) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) +func (c *BeaconBlockElectra) SizeSSZ() int { + size := 84 + if c.Body == nil { + c.Body = new(BeaconBlockBodyElectra) + } + size += c.Body.SizeSSZ() + return size } -// MarshalSSZTo ssz marshals the SignedBeaconBlockElectra object to a target array -func (s *SignedBeaconBlockElectra) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(100) +func (c *BeaconBlockElectra) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Offset (0) 'Block' - dst = ssz.WriteOffset(dst, offset) - if s.Block == nil { - s.Block = new(BeaconBlockElectra) +func (c *BeaconBlockElectra) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 84 + + // Field 0: Slot + if dst, err = c.Slot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Slot: %w", err) + } + + // Field 1: ProposerIndex + if dst, err = c.ProposerIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ProposerIndex: %w", err) } - offset += s.Block.SizeSSZ() - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 2: ParentRoot + if len(c.ParentRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, s.Signature...) + dst = append(dst, c.ParentRoot...) - // Field (0) 'Block' - if dst, err = s.Block.MarshalSSZTo(dst); err != nil { - return + // Field 3: StateRoot + if len(c.StateRoot) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.StateRoot...) - return + // Field 4: Body + if c.Body == nil { + c.Body = new(BeaconBlockBodyElectra) + } + dst = ssz.WriteOffset(dst, offset) + offset += c.Body.SizeSSZ() + + // Field 4: Body + if dst, err = c.Body.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Body: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the SignedBeaconBlockElectra object -func (s *SignedBeaconBlockElectra) UnmarshalSSZ(buf []byte) error { +func (c *BeaconBlockElectra) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 100 { + if size < 84 { return ssz.ErrSize } - tail := buf - var o0 uint64 + sszSlice0 := buf[0:8] // c.Slot + sszSlice1 := buf[8:16] // c.ProposerIndex + sszSlice2 := buf[16:48] // c.ParentRoot + sszSlice3 := buf[48:80] // c.StateRoot - // Offset (0) 'Block' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { + sszVarOffset4 := ssz.ReadOffset(buf[80:84]) // c.Body + if sszVarOffset4 != 84 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset4 > size { return ssz.ErrOffset } + sszSlice4 := buf[sszVarOffset4:] // c.Body - if o0 != 100 { - return ssz.ErrInvalidVariableOffset + // Field 0: Slot + if err = c.Slot.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Slot: %w", err) } - // Field (1) 'Signature' - if cap(s.Signature) == 0 { - s.Signature = make([]byte, 0, len(buf[4:100])) + // Field 1: ProposerIndex + if err = c.ProposerIndex.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("ProposerIndex: %w", err) } - s.Signature = append(s.Signature, buf[4:100]...) - // Field (0) 'Block' - { - buf = tail[o0:] - if s.Block == nil { - s.Block = new(BeaconBlockElectra) - } - if err = s.Block.UnmarshalSSZ(buf); err != nil { - return err - } - } - return err -} + // Field 2: ParentRoot + c.ParentRoot = make([]byte, 0, 32) + c.ParentRoot = append(c.ParentRoot, sszSlice2...) -// SizeSSZ returns the ssz encoded size in bytes for the SignedBeaconBlockElectra object -func (s *SignedBeaconBlockElectra) SizeSSZ() (size int) { - size = 100 + // Field 3: StateRoot + c.StateRoot = make([]byte, 0, 32) + c.StateRoot = append(c.StateRoot, sszSlice3...) - // Field (0) 'Block' - if s.Block == nil { - s.Block = new(BeaconBlockElectra) + // Field 4: Body + c.Body = new(BeaconBlockBodyElectra) + if err = c.Body.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("Body: %w", err) } - size += s.Block.SizeSSZ() - - return + return err } -// HashTreeRoot ssz hashes the SignedBeaconBlockElectra object -func (s *SignedBeaconBlockElectra) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) +func (c *BeaconBlockElectra) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the SignedBeaconBlockElectra object with a hasher -func (s *SignedBeaconBlockElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *BeaconBlockElectra) HashTreeRootWith(hh *ssz.Hasher) (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("--.Signature", size, 96) - return + // Field 0: Slot + if err := c.Slot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Slot: %w", err) } - hh.PutBytes(s.Signature) - - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the BeaconBlockContentsElectra object -func (b *BeaconBlockContentsElectra) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} - -// MarshalSSZTo ssz marshals the BeaconBlockContentsElectra object to a target array -func (b *BeaconBlockContentsElectra) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(12) - - // Offset (0) 'Block' - dst = ssz.WriteOffset(dst, offset) - if b.Block == nil { - b.Block = new(BeaconBlockElectra) + // Field 1: ProposerIndex + if err := c.ProposerIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ProposerIndex: %w", err) } - offset += b.Block.SizeSSZ() - - // Offset (1) 'KzgProofs' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.KzgProofs) * 48 - - // Offset (2) 'Blobs' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.Blobs) * 131072 - - // Field (0) 'Block' - if dst, err = b.Block.MarshalSSZTo(dst); err != nil { - return + // Field 2: ParentRoot + if len(c.ParentRoot) != 32 { + return ssz.ErrBytesLength } - - // Field (1) 'KzgProofs' - if size := len(b.KzgProofs); size > 4096 { - err = ssz.ErrListTooBigFn("--.KzgProofs", size, 4096) - return + hh.PutBytes(c.ParentRoot) + // Field 3: StateRoot + if len(c.StateRoot) != 32 { + return ssz.ErrBytesLength } - for ii := 0; ii < len(b.KzgProofs); ii++ { - if size := len(b.KzgProofs[ii]); size != 48 { - err = ssz.ErrBytesLengthFn("--.KzgProofs[ii]", size, 48) - return - } - dst = append(dst, b.KzgProofs[ii]...) + hh.PutBytes(c.StateRoot) + // Field 4: Body + if err := c.Body.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Body: %w", err) } + hh.Merkleize(indx) + return nil +} - // Field (2) 'Blobs' - if size := len(b.Blobs); size > 4096 { - err = ssz.ErrListTooBigFn("--.Blobs", size, 4096) - return - } - for ii := 0; ii < len(b.Blobs); ii++ { - if size := len(b.Blobs[ii]); size != 131072 { - err = ssz.ErrBytesLengthFn("--.Blobs[ii]", size, 131072) - return - } - dst = append(dst, b.Blobs[ii]...) +func (c *BeaconStateElectra) SizeSSZ() int { + size := 2736713 + size += len(c.HistoricalRoots) * 32 + size += len(c.Eth1DataVotes) * 72 + size += len(c.Validators) * 121 + size += len(c.Balances) * 8 + size += len(c.PreviousEpochParticipation) + size += len(c.CurrentEpochParticipation) + size += len(c.InactivityScores) * 8 + if c.LatestExecutionPayloadHeader == nil { + c.LatestExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderDeneb) } + size += c.LatestExecutionPayloadHeader.SizeSSZ() + size += len(c.HistoricalSummaries) * 64 + size += len(c.PendingDeposits) * 192 + size += len(c.PendingPartialWithdrawals) * 24 + size += len(c.PendingConsolidations) * 16 + return size +} - return +func (c *BeaconStateElectra) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// UnmarshalSSZ ssz unmarshals the BeaconBlockContentsElectra object -func (b *BeaconBlockContentsElectra) UnmarshalSSZ(buf []byte) error { +func (c *BeaconStateElectra) MarshalSSZTo(dst []byte) ([]byte, error) { var err error - size := uint64(len(buf)) - if size < 12 { - return ssz.ErrSize - } + offset := 2736713 - tail := buf - var o0, o1, o2 uint64 + // Field 0: GenesisTime + dst = binary.LittleEndian.AppendUint64(dst, c.GenesisTime) - // Offset (0) 'Block' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset + // Field 1: GenesisValidatorsRoot + if len(c.GenesisValidatorsRoot) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.GenesisValidatorsRoot...) - if o0 != 12 { - return ssz.ErrInvalidVariableOffset + // Field 2: Slot + if dst, err = c.Slot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Slot: %w", err) } - // Offset (1) 'KzgProofs' - if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 { - return ssz.ErrOffset + // Field 3: Fork + if c.Fork == nil { + c.Fork = new(Fork) } - - // Offset (2) 'Blobs' - if o2 = ssz.ReadOffset(buf[8:12]); o2 > size || o1 > o2 { - return ssz.ErrOffset + if dst, err = c.Fork.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Fork: %w", err) } - // Field (0) 'Block' - { - buf = tail[o0:o1] - if b.Block == nil { - b.Block = new(BeaconBlockElectra) - } - if err = b.Block.UnmarshalSSZ(buf); err != nil { - return err - } + // Field 4: LatestBlockHeader + if c.LatestBlockHeader == nil { + c.LatestBlockHeader = new(BeaconBlockHeader) + } + if dst, err = c.LatestBlockHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("LatestBlockHeader: %w", err) } - // Field (1) 'KzgProofs' - { - buf = tail[o1:o2] - num, err := ssz.DivideInt2(len(buf), 48, 4096) - if err != nil { - return err - } - b.KzgProofs = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(b.KzgProofs[ii]) == 0 { - b.KzgProofs[ii] = make([]byte, 0, len(buf[ii*48:(ii+1)*48])) - } - b.KzgProofs[ii] = append(b.KzgProofs[ii], buf[ii*48:(ii+1)*48]...) + // Field 5: BlockRoots + if len(c.BlockRoots) != 8192 { + return nil, ssz.ErrBytesLength + } + for _, o := range c.BlockRoots { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, o...) } - // Field (2) 'Blobs' - { - buf = tail[o2:] - num, err := ssz.DivideInt2(len(buf), 131072, 4096) - if err != nil { - return err - } - b.Blobs = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(b.Blobs[ii]) == 0 { - b.Blobs[ii] = make([]byte, 0, len(buf[ii*131072:(ii+1)*131072])) - } - b.Blobs[ii] = append(b.Blobs[ii], buf[ii*131072:(ii+1)*131072]...) + // Field 6: StateRoots + if len(c.StateRoots) != 8192 { + return nil, ssz.ErrBytesLength + } + for _, o := range c.StateRoots { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, o...) } - return err -} -// SizeSSZ returns the ssz encoded size in bytes for the BeaconBlockContentsElectra object -func (b *BeaconBlockContentsElectra) SizeSSZ() (size int) { - size = 12 + // Field 7: HistoricalRoots + dst = ssz.WriteOffset(dst, offset) + offset += len(c.HistoricalRoots) * 32 - // Field (0) 'Block' - if b.Block == nil { - b.Block = new(BeaconBlockElectra) + // Field 8: Eth1Data + if c.Eth1Data == nil { + c.Eth1Data = new(Eth1Data) + } + if dst, err = c.Eth1Data.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Eth1Data: %w", err) } - size += b.Block.SizeSSZ() - - // Field (1) 'KzgProofs' - size += len(b.KzgProofs) * 48 - // Field (2) 'Blobs' - size += len(b.Blobs) * 131072 + // Field 9: Eth1DataVotes + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Eth1DataVotes) * 72 - return -} + // Field 10: Eth1DepositIndex + dst = binary.LittleEndian.AppendUint64(dst, c.Eth1DepositIndex) -// HashTreeRoot ssz hashes the BeaconBlockContentsElectra object -func (b *BeaconBlockContentsElectra) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) -} + // Field 11: Validators + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Validators) * 121 -// HashTreeRootWith ssz hashes the BeaconBlockContentsElectra object with a hasher -func (b *BeaconBlockContentsElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() + // Field 12: Balances + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Balances) * 8 - // Field (0) 'Block' - if err = b.Block.HashTreeRootWith(hh); err != nil { - return + // Field 13: RandaoMixes + if len(c.RandaoMixes) != 65536 { + return nil, ssz.ErrBytesLength } - - // Field (1) 'KzgProofs' - { - if size := len(b.KzgProofs); size > 4096 { - err = ssz.ErrListTooBigFn("--.KzgProofs", size, 4096) - return - } - subIndx := hh.Index() - for _, i := range b.KzgProofs { - if len(i) != 48 { - err = ssz.ErrBytesLength - return - } - hh.PutBytes(i) + for _, o := range c.RandaoMixes { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } - - numItems := uint64(len(b.KzgProofs)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) + dst = append(dst, o...) } - // Field (2) 'Blobs' - { - if size := len(b.Blobs); size > 4096 { - err = ssz.ErrListTooBigFn("--.Blobs", size, 4096) - return - } - subIndx := hh.Index() - for _, i := range b.Blobs { - if len(i) != 131072 { - err = ssz.ErrBytesLength - return - } - hh.PutBytes(i) - } - - numItems := uint64(len(b.Blobs)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) + // Field 14: Slashings + if len(c.Slashings) != 8192 { + return nil, ssz.ErrBytesLength } - - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the BeaconBlockElectra object -func (b *BeaconBlockElectra) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} - -// MarshalSSZTo ssz marshals the BeaconBlockElectra object to a target array -func (b *BeaconBlockElectra) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(84) - - // Field (0) 'Slot' - dst = ssz.MarshalUint(dst, b.Slot) - - // Field (1) 'ProposerIndex' - dst = ssz.MarshalUint(dst, b.ProposerIndex) - - // Field (2) 'ParentRoot' - if size := len(b.ParentRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentRoot", size, 32) - return + for _, o := range c.Slashings { + dst = binary.LittleEndian.AppendUint64(dst, o) } - dst = append(dst, b.ParentRoot...) - // Field (3) 'StateRoot' - if size := len(b.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return - } - dst = append(dst, b.StateRoot...) + // Field 15: PreviousEpochParticipation + dst = ssz.WriteOffset(dst, offset) + offset += len(c.PreviousEpochParticipation) - // Offset (4) 'Body' + // Field 16: CurrentEpochParticipation dst = ssz.WriteOffset(dst, offset) - if b.Body == nil { - b.Body = new(BeaconBlockBodyElectra) - } - offset += b.Body.SizeSSZ() + offset += len(c.CurrentEpochParticipation) - // Field (4) 'Body' - if dst, err = b.Body.MarshalSSZTo(dst); err != nil { - return + // Field 17: JustificationBits + if len([]byte(c.JustificationBits)) != 1 { + return nil, ssz.ErrBytesLength } + dst = append(dst, []byte(c.JustificationBits)...) - return -} - -// UnmarshalSSZ ssz unmarshals the BeaconBlockElectra object -func (b *BeaconBlockElectra) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 84 { - return ssz.ErrSize + // Field 18: PreviousJustifiedCheckpoint + if c.PreviousJustifiedCheckpoint == nil { + c.PreviousJustifiedCheckpoint = new(Checkpoint) } - - tail := buf - var o4 uint64 - - // Field (0) 'Slot' - b.Slot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[0:8]) - - // Field (1) 'ProposerIndex' - b.ProposerIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[8:16]) - - // Field (2) 'ParentRoot' - if cap(b.ParentRoot) == 0 { - b.ParentRoot = make([]byte, 0, len(buf[16:48])) + if dst, err = c.PreviousJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("PreviousJustifiedCheckpoint: %w", err) } - 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])) + // Field 19: CurrentJustifiedCheckpoint + if c.CurrentJustifiedCheckpoint == nil { + c.CurrentJustifiedCheckpoint = new(Checkpoint) } - b.StateRoot = append(b.StateRoot, buf[48:80]...) - - // Offset (4) 'Body' - if o4 = ssz.ReadOffset(buf[80:84]); o4 > size { - return ssz.ErrOffset + if dst, err = c.CurrentJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("CurrentJustifiedCheckpoint: %w", err) } - if o4 != 84 { - return ssz.ErrInvalidVariableOffset + // Field 20: FinalizedCheckpoint + if c.FinalizedCheckpoint == nil { + c.FinalizedCheckpoint = new(Checkpoint) } - - // Field (4) 'Body' - { - buf = tail[o4:] - if b.Body == nil { - b.Body = new(BeaconBlockBodyElectra) - } - if err = b.Body.UnmarshalSSZ(buf); err != nil { - return err - } + if dst, err = c.FinalizedCheckpoint.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("FinalizedCheckpoint: %w", err) } - return err -} -// SizeSSZ returns the ssz encoded size in bytes for the BeaconBlockElectra object -func (b *BeaconBlockElectra) SizeSSZ() (size int) { - size = 84 + // Field 21: InactivityScores + dst = ssz.WriteOffset(dst, offset) + offset += len(c.InactivityScores) * 8 - // Field (4) 'Body' - if b.Body == nil { - b.Body = new(BeaconBlockBodyElectra) + // Field 22: CurrentSyncCommittee + if c.CurrentSyncCommittee == nil { + c.CurrentSyncCommittee = new(SyncCommittee) } - size += b.Body.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the BeaconBlockElectra object -func (b *BeaconBlockElectra) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) -} - -// HashTreeRootWith ssz hashes the BeaconBlockElectra object with a hasher -func (b *BeaconBlockElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'Slot' - ssz.PutUint(hh, b.Slot) - - // Field (1) 'ProposerIndex' - ssz.PutUint(hh, b.ProposerIndex) - - // Field (2) 'ParentRoot' - if size := len(b.ParentRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentRoot", size, 32) - return + if dst, err = c.CurrentSyncCommittee.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("CurrentSyncCommittee: %w", err) } - hh.PutBytes(b.ParentRoot) - // Field (3) 'StateRoot' - if size := len(b.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return + // Field 23: NextSyncCommittee + if c.NextSyncCommittee == nil { + c.NextSyncCommittee = new(SyncCommittee) } - hh.PutBytes(b.StateRoot) - - // Field (4) 'Body' - if err = b.Body.HashTreeRootWith(hh); err != nil { - return + if dst, err = c.NextSyncCommittee.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("NextSyncCommittee: %w", err) } - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the BeaconBlockBodyElectra object -func (b *BeaconBlockBodyElectra) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} - -// MarshalSSZTo ssz marshals the BeaconBlockBodyElectra object to a target array -func (b *BeaconBlockBodyElectra) 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("--.RandaoReveal", size, 96) - return + // Field 24: LatestExecutionPayloadHeader + if c.LatestExecutionPayloadHeader == nil { + c.LatestExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderDeneb) } - dst = append(dst, b.RandaoReveal...) + dst = ssz.WriteOffset(dst, offset) + offset += c.LatestExecutionPayloadHeader.SizeSSZ() - // Field (1) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(Eth1Data) - } - if dst, err = b.Eth1Data.MarshalSSZTo(dst); err != nil { - return - } + // Field 25: NextWithdrawalIndex + dst = binary.LittleEndian.AppendUint64(dst, c.NextWithdrawalIndex) - // Field (2) 'Graffiti' - if size := len(b.Graffiti); size != 32 { - err = ssz.ErrBytesLengthFn("--.Graffiti", size, 32) - return + // Field 26: NextWithdrawalValidatorIndex + if dst, err = c.NextWithdrawalValidatorIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("NextWithdrawalValidatorIndex: %w", err) } - dst = append(dst, b.Graffiti...) - // Offset (3) 'ProposerSlashings' + // Field 27: HistoricalSummaries dst = ssz.WriteOffset(dst, offset) - offset += len(b.ProposerSlashings) * 416 + offset += len(c.HistoricalSummaries) * 64 - // Offset (4) 'AttesterSlashings' - dst = ssz.WriteOffset(dst, offset) - for ii := 0; ii < len(b.AttesterSlashings); ii++ { - offset += 4 - offset += b.AttesterSlashings[ii].SizeSSZ() - } + // Field 28: DepositRequestsStartIndex + dst = binary.LittleEndian.AppendUint64(dst, c.DepositRequestsStartIndex) - // Offset (5) 'Attestations' - dst = ssz.WriteOffset(dst, offset) - for ii := 0; ii < len(b.Attestations); ii++ { - offset += 4 - offset += b.Attestations[ii].SizeSSZ() + // Field 29: DepositBalanceToConsume + if dst, err = c.DepositBalanceToConsume.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("DepositBalanceToConsume: %w", err) } - // 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 30: ExitBalanceToConsume + if dst, err = c.ExitBalanceToConsume.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ExitBalanceToConsume: %w", err) + } - // Field (8) 'SyncAggregate' - if b.SyncAggregate == nil { - b.SyncAggregate = new(SyncAggregate) + // Field 31: EarliestExitEpoch + if dst, err = c.EarliestExitEpoch.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("EarliestExitEpoch: %w", err) } - if dst, err = b.SyncAggregate.MarshalSSZTo(dst); err != nil { - return + + // Field 32: ConsolidationBalanceToConsume + if dst, err = c.ConsolidationBalanceToConsume.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ConsolidationBalanceToConsume: %w", err) } - // Offset (9) 'ExecutionPayload' - dst = ssz.WriteOffset(dst, offset) - if b.ExecutionPayload == nil { - b.ExecutionPayload = new(v1.ExecutionPayloadDeneb) + // Field 33: EarliestConsolidationEpoch + if dst, err = c.EarliestConsolidationEpoch.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("EarliestConsolidationEpoch: %w", err) } - offset += b.ExecutionPayload.SizeSSZ() - // Offset (10) 'BlsToExecutionChanges' + // Field 34: PendingDeposits dst = ssz.WriteOffset(dst, offset) - offset += len(b.BlsToExecutionChanges) * 172 + offset += len(c.PendingDeposits) * 192 - // Offset (11) 'BlobKzgCommitments' + // Field 35: PendingPartialWithdrawals dst = ssz.WriteOffset(dst, offset) - offset += len(b.BlobKzgCommitments) * 48 + offset += len(c.PendingPartialWithdrawals) * 24 - // Offset (12) 'ExecutionRequests' + // Field 36: PendingConsolidations dst = ssz.WriteOffset(dst, offset) - if b.ExecutionRequests == nil { - b.ExecutionRequests = new(v1.ExecutionRequests) - } - offset += b.ExecutionRequests.SizeSSZ() + offset += len(c.PendingConsolidations) * 16 - // Field (3) 'ProposerSlashings' - if size := len(b.ProposerSlashings); size > 16 { - err = ssz.ErrListTooBigFn("--.ProposerSlashings", size, 16) - return + // Field 7: HistoricalRoots + if len(c.HistoricalRoots) > 16777216 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.ProposerSlashings); ii++ { - if dst, err = b.ProposerSlashings[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.HistoricalRoots { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, o...) } - // Field (4) 'AttesterSlashings' - if size := len(b.AttesterSlashings); size > 1 { - err = ssz.ErrListTooBigFn("--.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() - } + // Field 9: Eth1DataVotes + if len(c.Eth1DataVotes) > 2048 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.AttesterSlashings); ii++ { - if dst, err = b.AttesterSlashings[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.Eth1DataVotes { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Eth1DataVotes: %w", err) } } - // Field (5) 'Attestations' - if size := len(b.Attestations); size > 8 { - err = ssz.ErrListTooBigFn("--.Attestations", size, 8) - return + // Field 11: Validators + if len(c.Validators) > 1099511627776 { + return nil, ssz.ErrListTooBig } - { - offset = 4 * len(b.Attestations) - for ii := 0; ii < len(b.Attestations); ii++ { - dst = ssz.WriteOffset(dst, offset) - offset += b.Attestations[ii].SizeSSZ() + for _, o := range c.Validators { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Validators: %w", err) } } - for ii := 0; ii < len(b.Attestations); ii++ { - if dst, err = b.Attestations[ii].MarshalSSZTo(dst); err != nil { - return - } + + // Field 12: Balances + if len(c.Balances) > 1099511627776 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.Balances { + dst = binary.LittleEndian.AppendUint64(dst, o) } - // Field (6) 'Deposits' - if size := len(b.Deposits); size > 16 { - err = ssz.ErrListTooBigFn("--.Deposits", size, 16) - return + // Field 15: PreviousEpochParticipation + if len(c.PreviousEpochParticipation) > 1099511627776 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.Deposits); ii++ { - if dst, err = b.Deposits[ii].MarshalSSZTo(dst); err != nil { - return - } + dst = append(dst, c.PreviousEpochParticipation...) + + // Field 16: CurrentEpochParticipation + if len(c.CurrentEpochParticipation) > 1099511627776 { + return nil, ssz.ErrListTooBig } + dst = append(dst, c.CurrentEpochParticipation...) - // Field (7) 'VoluntaryExits' - if size := len(b.VoluntaryExits); size > 16 { - err = ssz.ErrListTooBigFn("--.VoluntaryExits", size, 16) - return + // Field 21: InactivityScores + if len(c.InactivityScores) > 1099511627776 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.VoluntaryExits); ii++ { - if dst, err = b.VoluntaryExits[ii].MarshalSSZTo(dst); err != nil { - return - } + for _, o := range c.InactivityScores { + dst = binary.LittleEndian.AppendUint64(dst, o) } - // Field (9) 'ExecutionPayload' - if dst, err = b.ExecutionPayload.MarshalSSZTo(dst); err != nil { - return + // Field 24: LatestExecutionPayloadHeader + if dst, err = c.LatestExecutionPayloadHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("LatestExecutionPayloadHeader: %w", err) } - // Field (10) 'BlsToExecutionChanges' - if size := len(b.BlsToExecutionChanges); size > 16 { - err = ssz.ErrListTooBigFn("--.BlsToExecutionChanges", size, 16) - return + // Field 27: HistoricalSummaries + if len(c.HistoricalSummaries) > 16777216 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.BlsToExecutionChanges); ii++ { - if dst, err = b.BlsToExecutionChanges[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.HistoricalSummaries { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("HistoricalSummaries: %w", err) } } - // Field (11) 'BlobKzgCommitments' - if size := len(b.BlobKzgCommitments); size > 4096 { - err = ssz.ErrListTooBigFn("--.BlobKzgCommitments", size, 4096) - return + // Field 34: PendingDeposits + if len(c.PendingDeposits) > 134217728 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.BlobKzgCommitments); ii++ { - if size := len(b.BlobKzgCommitments[ii]); size != 48 { - err = ssz.ErrBytesLengthFn("--.BlobKzgCommitments[ii]", size, 48) - return + for _, o := range c.PendingDeposits { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("PendingDeposits: %w", err) } - dst = append(dst, b.BlobKzgCommitments[ii]...) } - // Field (12) 'ExecutionRequests' - if dst, err = b.ExecutionRequests.MarshalSSZTo(dst); err != nil { - return + // Field 35: PendingPartialWithdrawals + if len(c.PendingPartialWithdrawals) > 134217728 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.PendingPartialWithdrawals { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("PendingPartialWithdrawals: %w", err) + } } - return + // Field 36: PendingConsolidations + if len(c.PendingConsolidations) > 262144 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.PendingConsolidations { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("PendingConsolidations: %w", err) + } + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the BeaconBlockBodyElectra object -func (b *BeaconBlockBodyElectra) UnmarshalSSZ(buf []byte) error { +func (c *BeaconStateElectra) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 396 { + if size < 2736713 { 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])) + sszSlice0 := buf[0:8] // c.GenesisTime + sszSlice1 := buf[8:40] // c.GenesisValidatorsRoot + sszSlice2 := buf[40:48] // c.Slot + sszSlice3 := buf[48:64] // c.Fork + sszSlice4 := buf[64:176] // c.LatestBlockHeader + sszSlice5 := buf[176:262320] // c.BlockRoots + sszSlice6 := buf[262320:524464] // c.StateRoots + sszSlice8 := buf[524468:524540] // c.Eth1Data + sszSlice10 := buf[524544:524552] // c.Eth1DepositIndex + sszSlice13 := buf[524560:2621712] // c.RandaoMixes + sszSlice14 := buf[2621712:2687248] // c.Slashings + sszSlice17 := buf[2687256:2687257] // c.JustificationBits + sszSlice18 := buf[2687257:2687297] // c.PreviousJustifiedCheckpoint + sszSlice19 := buf[2687297:2687337] // c.CurrentJustifiedCheckpoint + sszSlice20 := buf[2687337:2687377] // c.FinalizedCheckpoint + sszSlice22 := buf[2687381:2712005] // c.CurrentSyncCommittee + sszSlice23 := buf[2712005:2736629] // c.NextSyncCommittee + sszSlice25 := buf[2736633:2736641] // c.NextWithdrawalIndex + sszSlice26 := buf[2736641:2736649] // c.NextWithdrawalValidatorIndex + sszSlice28 := buf[2736653:2736661] // c.DepositRequestsStartIndex + sszSlice29 := buf[2736661:2736669] // c.DepositBalanceToConsume + sszSlice30 := buf[2736669:2736677] // c.ExitBalanceToConsume + sszSlice31 := buf[2736677:2736685] // c.EarliestExitEpoch + sszSlice32 := buf[2736685:2736693] // c.ConsolidationBalanceToConsume + sszSlice33 := buf[2736693:2736701] // c.EarliestConsolidationEpoch + + sszVarOffset7 := ssz.ReadOffset(buf[524464:524468]) // c.HistoricalRoots + if sszVarOffset7 != 2736713 { + return ssz.ErrInvalidVariableOffset } - b.RandaoReveal = append(b.RandaoReveal, buf[0:96]...) - - // Field (1) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(Eth1Data) + if sszVarOffset7 > size { + return ssz.ErrOffset } - if err = b.Eth1Data.UnmarshalSSZ(buf[96:168]); err != nil { - return err + sszVarOffset9 := ssz.ReadOffset(buf[524540:524544]) // c.Eth1DataVotes + if sszVarOffset9 > size || sszVarOffset9 < sszVarOffset7 { + return ssz.ErrOffset } - - // Field (2) 'Graffiti' - if cap(b.Graffiti) == 0 { - b.Graffiti = make([]byte, 0, len(buf[168:200])) + sszVarOffset11 := ssz.ReadOffset(buf[524552:524556]) // c.Validators + if sszVarOffset11 > size || sszVarOffset11 < sszVarOffset9 { + return ssz.ErrOffset } - b.Graffiti = append(b.Graffiti, buf[168:200]...) - - // Offset (3) 'ProposerSlashings' - if o3 = ssz.ReadOffset(buf[200:204]); o3 > size { + sszVarOffset12 := ssz.ReadOffset(buf[524556:524560]) // c.Balances + if sszVarOffset12 > size || sszVarOffset12 < sszVarOffset11 { return ssz.ErrOffset } - - if o3 != 396 { - return ssz.ErrInvalidVariableOffset + sszVarOffset15 := ssz.ReadOffset(buf[2687248:2687252]) // c.PreviousEpochParticipation + if sszVarOffset15 > size || sszVarOffset15 < sszVarOffset12 { + return ssz.ErrOffset } - - // Offset (4) 'AttesterSlashings' - if o4 = ssz.ReadOffset(buf[204:208]); o4 > size || o3 > o4 { + sszVarOffset16 := ssz.ReadOffset(buf[2687252:2687256]) // c.CurrentEpochParticipation + if sszVarOffset16 > size || sszVarOffset16 < sszVarOffset15 { return ssz.ErrOffset } - - // Offset (5) 'Attestations' - if o5 = ssz.ReadOffset(buf[208:212]); o5 > size || o4 > o5 { + sszVarOffset21 := ssz.ReadOffset(buf[2687377:2687381]) // c.InactivityScores + if sszVarOffset21 > size || sszVarOffset21 < sszVarOffset16 { return ssz.ErrOffset } - - // Offset (6) 'Deposits' - if o6 = ssz.ReadOffset(buf[212:216]); o6 > size || o5 > o6 { + sszVarOffset24 := ssz.ReadOffset(buf[2736629:2736633]) // c.LatestExecutionPayloadHeader + if sszVarOffset24 > size || sszVarOffset24 < sszVarOffset21 { return ssz.ErrOffset } - - // Offset (7) 'VoluntaryExits' - if o7 = ssz.ReadOffset(buf[216:220]); o7 > size || o6 > o7 { + sszVarOffset27 := ssz.ReadOffset(buf[2736649:2736653]) // c.HistoricalSummaries + if sszVarOffset27 > size || sszVarOffset27 < sszVarOffset24 { return ssz.ErrOffset } - - // Field (8) 'SyncAggregate' - if b.SyncAggregate == nil { - b.SyncAggregate = new(SyncAggregate) + sszVarOffset34 := ssz.ReadOffset(buf[2736701:2736705]) // c.PendingDeposits + if sszVarOffset34 > size || sszVarOffset34 < sszVarOffset27 { + return ssz.ErrOffset } - if err = b.SyncAggregate.UnmarshalSSZ(buf[220:380]); err != nil { - return err + sszVarOffset35 := ssz.ReadOffset(buf[2736705:2736709]) // c.PendingPartialWithdrawals + if sszVarOffset35 > size || sszVarOffset35 < sszVarOffset34 { + return ssz.ErrOffset } - - // Offset (9) 'ExecutionPayload' - if o9 = ssz.ReadOffset(buf[380:384]); o9 > size || o7 > o9 { + sszVarOffset36 := ssz.ReadOffset(buf[2736709:2736713]) // c.PendingConsolidations + if sszVarOffset36 > size || sszVarOffset36 < sszVarOffset35 { return ssz.ErrOffset } + sszSlice7 := buf[sszVarOffset7:sszVarOffset9] // c.HistoricalRoots + sszSlice9 := buf[sszVarOffset9:sszVarOffset11] // c.Eth1DataVotes + sszSlice11 := buf[sszVarOffset11:sszVarOffset12] // c.Validators + sszSlice12 := buf[sszVarOffset12:sszVarOffset15] // c.Balances + sszSlice15 := buf[sszVarOffset15:sszVarOffset16] // c.PreviousEpochParticipation + sszSlice16 := buf[sszVarOffset16:sszVarOffset21] // c.CurrentEpochParticipation + sszSlice21 := buf[sszVarOffset21:sszVarOffset24] // c.InactivityScores + sszSlice24 := buf[sszVarOffset24:sszVarOffset27] // c.LatestExecutionPayloadHeader + sszSlice27 := buf[sszVarOffset27:sszVarOffset34] // c.HistoricalSummaries + sszSlice34 := buf[sszVarOffset34:sszVarOffset35] // c.PendingDeposits + sszSlice35 := buf[sszVarOffset35:sszVarOffset36] // c.PendingPartialWithdrawals + sszSlice36 := buf[sszVarOffset36:] // c.PendingConsolidations - // Offset (10) 'BlsToExecutionChanges' - if o10 = ssz.ReadOffset(buf[384:388]); o10 > size || o9 > o10 { - return ssz.ErrOffset + // Field 0: GenesisTime + c.GenesisTime = binary.LittleEndian.Uint64(sszSlice0) + + // Field 1: GenesisValidatorsRoot + c.GenesisValidatorsRoot = make([]byte, 0, 32) + c.GenesisValidatorsRoot = append(c.GenesisValidatorsRoot, sszSlice1...) + + // Field 2: Slot + if err = c.Slot.UnmarshalSSZ(sszSlice2); err != nil { + return fmt.Errorf("Slot: %w", err) } - // Offset (11) 'BlobKzgCommitments' - if o11 = ssz.ReadOffset(buf[388:392]); o11 > size || o10 > o11 { - return ssz.ErrOffset + // Field 3: Fork + c.Fork = new(Fork) + if err = c.Fork.UnmarshalSSZ(sszSlice3); err != nil { + return fmt.Errorf("Fork: %w", err) } - // Offset (12) 'ExecutionRequests' - if o12 = ssz.ReadOffset(buf[392:396]); o12 > size || o11 > o12 { - return ssz.ErrOffset + // Field 4: LatestBlockHeader + c.LatestBlockHeader = new(BeaconBlockHeader) + if err = c.LatestBlockHeader.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("LatestBlockHeader: %w", err) } - // Field (3) 'ProposerSlashings' + // Field 5: BlockRoots { - buf = tail[o3:o4] - num, err := ssz.DivideInt2(len(buf), 416, 16) - if err != nil { - return err - } - b.ProposerSlashings = make([]*ProposerSlashing, num) - for ii := 0; ii < num; ii++ { - if b.ProposerSlashings[ii] == nil { - b.ProposerSlashings[ii] = new(ProposerSlashing) - } - if err = b.ProposerSlashings[ii].UnmarshalSSZ(buf[ii*416 : (ii+1)*416]); err != nil { - return err - } + c.BlockRoots = make([][]byte, 8192) + for i := 0; i < 8192; i++ { + var tmp []byte + + tmpSlice := sszSlice5[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.BlockRoots[i] = tmp } } - // Field (4) 'AttesterSlashings' + // Field 6: StateRoots { - buf = tail[o4:o5] - num, err := ssz.DecodeDynamicLength(buf, 1) - if err != nil { - return err - } - b.AttesterSlashings = make([]*AttesterSlashingElectra, num) - err = ssz.UnmarshalDynamic(buf, num, func(indx int, buf []byte) (err error) { - if b.AttesterSlashings[indx] == nil { - b.AttesterSlashings[indx] = new(AttesterSlashingElectra) - } - if err = b.AttesterSlashings[indx].UnmarshalSSZ(buf); err != nil { - return err - } - return nil - }) - if err != nil { - return err + c.StateRoots = make([][]byte, 8192) + for i := 0; i < 8192; i++ { + var tmp []byte + + tmpSlice := sszSlice6[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.StateRoots[i] = tmp } } - // Field (5) 'Attestations' + // Field 7: HistoricalRoots { - buf = tail[o5:o6] - num, err := ssz.DecodeDynamicLength(buf, 8) - if err != nil { - return err - } - b.Attestations = make([]*AttestationElectra, num) - err = ssz.UnmarshalDynamic(buf, num, func(indx int, buf []byte) (err error) { - if b.Attestations[indx] == nil { - b.Attestations[indx] = new(AttestationElectra) - } - if err = b.Attestations[indx].UnmarshalSSZ(buf); err != nil { - return err - } - return nil - }) - if err != nil { - return err + if len(sszSlice7)%32 != 0 { + return fmt.Errorf("misaligned bytes: c.HistoricalRoots length is %d, which is not a multiple of 32: %w", len(sszSlice7), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice7) / 32 + if numElem > 16777216 { + return fmt.Errorf("ssz-max exceeded: c.HistoricalRoots has %d elements, ssz-max is 16777216: %w", numElem, ssz.ErrListTooBig) + } + c.HistoricalRoots = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte + + tmpSlice := sszSlice7[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.HistoricalRoots[i] = tmp } } - // Field (6) 'Deposits' + // Field 8: Eth1Data + c.Eth1Data = new(Eth1Data) + if err = c.Eth1Data.UnmarshalSSZ(sszSlice8); err != nil { + return fmt.Errorf("Eth1Data: %w", err) + } + + // Field 9: Eth1DataVotes { - buf = tail[o6:o7] - num, err := ssz.DivideInt2(len(buf), 1240, 16) - if err != nil { - return err - } - b.Deposits = make([]*Deposit, num) - for ii := 0; ii < num; ii++ { - if b.Deposits[ii] == nil { - b.Deposits[ii] = new(Deposit) - } - if err = b.Deposits[ii].UnmarshalSSZ(buf[ii*1240 : (ii+1)*1240]); err != nil { - return err + if len(sszSlice9)%72 != 0 { + return fmt.Errorf("misaligned bytes: c.Eth1DataVotes length is %d, which is not a multiple of 72: %w", len(sszSlice9), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice9) / 72 + if numElem > 2048 { + return fmt.Errorf("ssz-max exceeded: c.Eth1DataVotes has %d elements, ssz-max is 2048: %w", numElem, ssz.ErrListTooBig) + } + c.Eth1DataVotes = make([]*Eth1Data, numElem) + for i := 0; i < numElem; i++ { + var tmp *Eth1Data + tmp = new(Eth1Data) + tmpSlice := sszSlice9[i*72 : (1+i)*72] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Eth1DataVotes: %w", err) } + c.Eth1DataVotes[i] = tmp } } - // Field (7) 'VoluntaryExits' + // Field 10: Eth1DepositIndex + c.Eth1DepositIndex = binary.LittleEndian.Uint64(sszSlice10) + + // Field 11: Validators { - buf = tail[o7:o9] - num, err := ssz.DivideInt2(len(buf), 112, 16) - if err != nil { - return err - } - b.VoluntaryExits = make([]*SignedVoluntaryExit, num) - for ii := 0; ii < num; ii++ { - if b.VoluntaryExits[ii] == nil { - b.VoluntaryExits[ii] = new(SignedVoluntaryExit) - } - if err = b.VoluntaryExits[ii].UnmarshalSSZ(buf[ii*112 : (ii+1)*112]); err != nil { - return err + if len(sszSlice11)%121 != 0 { + return fmt.Errorf("misaligned bytes: c.Validators length is %d, which is not a multiple of 121: %w", len(sszSlice11), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice11) / 121 + if numElem > 1099511627776 { + return fmt.Errorf("ssz-max exceeded: c.Validators has %d elements, ssz-max is 1099511627776: %w", numElem, ssz.ErrListTooBig) + } + c.Validators = make([]*Validator, numElem) + for i := 0; i < numElem; i++ { + var tmp *Validator + tmp = new(Validator) + tmpSlice := sszSlice11[i*121 : (1+i)*121] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Validators: %w", err) } + c.Validators[i] = tmp } } - // Field (9) 'ExecutionPayload' + // Field 12: Balances { - buf = tail[o9:o10] - if b.ExecutionPayload == nil { - b.ExecutionPayload = new(v1.ExecutionPayloadDeneb) + if len(sszSlice12)%8 != 0 { + return fmt.Errorf("misaligned bytes: c.Balances length is %d, which is not a multiple of 8: %w", len(sszSlice12), ssz.ErrIncorrectListSize) } - if err = b.ExecutionPayload.UnmarshalSSZ(buf); err != nil { - return err + numElem := len(sszSlice12) / 8 + if numElem > 1099511627776 { + return fmt.Errorf("ssz-max exceeded: c.Balances has %d elements, ssz-max is 1099511627776: %w", numElem, ssz.ErrListTooBig) } - } + c.Balances = make([]uint64, numElem) + for i := 0; i < numElem; i++ { + var tmp uint64 - // Field (10) 'BlsToExecutionChanges' - { - buf = tail[o10:o11] - num, err := ssz.DivideInt2(len(buf), 172, 16) - if err != nil { - return err - } - b.BlsToExecutionChanges = make([]*SignedBLSToExecutionChange, num) - for ii := 0; ii < num; ii++ { - if b.BlsToExecutionChanges[ii] == nil { - b.BlsToExecutionChanges[ii] = new(SignedBLSToExecutionChange) - } - if err = b.BlsToExecutionChanges[ii].UnmarshalSSZ(buf[ii*172 : (ii+1)*172]); err != nil { - return err - } + tmpSlice := sszSlice12[i*8 : (1+i)*8] + tmp = binary.LittleEndian.Uint64(tmpSlice) + c.Balances[i] = tmp } } - // Field (11) 'BlobKzgCommitments' + // Field 13: RandaoMixes { - buf = tail[o11:o12] - num, err := ssz.DivideInt2(len(buf), 48, 4096) - if err != nil { - return err - } - b.BlobKzgCommitments = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(b.BlobKzgCommitments[ii]) == 0 { - b.BlobKzgCommitments[ii] = make([]byte, 0, len(buf[ii*48:(ii+1)*48])) - } - b.BlobKzgCommitments[ii] = append(b.BlobKzgCommitments[ii], buf[ii*48:(ii+1)*48]...) + c.RandaoMixes = make([][]byte, 65536) + for i := 0; i < 65536; i++ { + var tmp []byte + + tmpSlice := sszSlice13[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.RandaoMixes[i] = tmp } } - // Field (12) 'ExecutionRequests' + // Field 14: Slashings { - buf = tail[o12:] - if b.ExecutionRequests == nil { - b.ExecutionRequests = new(v1.ExecutionRequests) - } - if err = b.ExecutionRequests.UnmarshalSSZ(buf); err != nil { - return err + c.Slashings = make([]uint64, 8192) + for i := 0; i < 8192; i++ { + var tmp uint64 + + tmpSlice := sszSlice14[i*8 : (1+i)*8] + tmp = binary.LittleEndian.Uint64(tmpSlice) + c.Slashings[i] = tmp } } - return err -} -// SizeSSZ returns the ssz encoded size in bytes for the BeaconBlockBodyElectra object -func (b *BeaconBlockBodyElectra) SizeSSZ() (size int) { - size = 396 + // Field 15: PreviousEpochParticipation + c.PreviousEpochParticipation = append([]byte{}, sszSlice15...) - // Field (3) 'ProposerSlashings' - size += len(b.ProposerSlashings) * 416 + // Field 16: CurrentEpochParticipation + c.CurrentEpochParticipation = append([]byte{}, sszSlice16...) - // Field (4) 'AttesterSlashings' - for ii := 0; ii < len(b.AttesterSlashings); ii++ { - size += 4 - size += b.AttesterSlashings[ii].SizeSSZ() + // Field 17: JustificationBits + c.JustificationBits = make([]byte, 0, 1) + c.JustificationBits = append(c.JustificationBits, go_bitfield.Bitvector4(sszSlice17)...) + + // Field 18: PreviousJustifiedCheckpoint + c.PreviousJustifiedCheckpoint = new(Checkpoint) + if err = c.PreviousJustifiedCheckpoint.UnmarshalSSZ(sszSlice18); err != nil { + return fmt.Errorf("PreviousJustifiedCheckpoint: %w", err) } - // Field (5) 'Attestations' - for ii := 0; ii < len(b.Attestations); ii++ { - size += 4 - size += b.Attestations[ii].SizeSSZ() + // Field 19: CurrentJustifiedCheckpoint + c.CurrentJustifiedCheckpoint = new(Checkpoint) + if err = c.CurrentJustifiedCheckpoint.UnmarshalSSZ(sszSlice19); err != nil { + return fmt.Errorf("CurrentJustifiedCheckpoint: %w", err) + } + + // Field 20: FinalizedCheckpoint + c.FinalizedCheckpoint = new(Checkpoint) + if err = c.FinalizedCheckpoint.UnmarshalSSZ(sszSlice20); err != nil { + return fmt.Errorf("FinalizedCheckpoint: %w", err) + } + + // Field 21: InactivityScores + { + if len(sszSlice21)%8 != 0 { + return fmt.Errorf("misaligned bytes: c.InactivityScores length is %d, which is not a multiple of 8: %w", len(sszSlice21), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice21) / 8 + if numElem > 1099511627776 { + return fmt.Errorf("ssz-max exceeded: c.InactivityScores has %d elements, ssz-max is 1099511627776: %w", numElem, ssz.ErrListTooBig) + } + c.InactivityScores = make([]uint64, numElem) + for i := 0; i < numElem; i++ { + var tmp uint64 + + tmpSlice := sszSlice21[i*8 : (1+i)*8] + tmp = binary.LittleEndian.Uint64(tmpSlice) + c.InactivityScores[i] = tmp + } } - // Field (6) 'Deposits' - size += len(b.Deposits) * 1240 + // Field 22: CurrentSyncCommittee + c.CurrentSyncCommittee = new(SyncCommittee) + if err = c.CurrentSyncCommittee.UnmarshalSSZ(sszSlice22); err != nil { + return fmt.Errorf("CurrentSyncCommittee: %w", err) + } - // Field (7) 'VoluntaryExits' - size += len(b.VoluntaryExits) * 112 + // Field 23: NextSyncCommittee + c.NextSyncCommittee = new(SyncCommittee) + if err = c.NextSyncCommittee.UnmarshalSSZ(sszSlice23); err != nil { + return fmt.Errorf("NextSyncCommittee: %w", err) + } - // Field (9) 'ExecutionPayload' - if b.ExecutionPayload == nil { - b.ExecutionPayload = new(v1.ExecutionPayloadDeneb) + // Field 24: LatestExecutionPayloadHeader + c.LatestExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderDeneb) + if err = c.LatestExecutionPayloadHeader.UnmarshalSSZ(sszSlice24); err != nil { + return fmt.Errorf("LatestExecutionPayloadHeader: %w", err) } - size += b.ExecutionPayload.SizeSSZ() - // Field (10) 'BlsToExecutionChanges' - size += len(b.BlsToExecutionChanges) * 172 + // Field 25: NextWithdrawalIndex + c.NextWithdrawalIndex = binary.LittleEndian.Uint64(sszSlice25) - // Field (11) 'BlobKzgCommitments' - size += len(b.BlobKzgCommitments) * 48 + // Field 26: NextWithdrawalValidatorIndex + if err = c.NextWithdrawalValidatorIndex.UnmarshalSSZ(sszSlice26); err != nil { + return fmt.Errorf("NextWithdrawalValidatorIndex: %w", err) + } - // Field (12) 'ExecutionRequests' - if b.ExecutionRequests == nil { - b.ExecutionRequests = new(v1.ExecutionRequests) + // Field 27: HistoricalSummaries + { + if len(sszSlice27)%64 != 0 { + return fmt.Errorf("misaligned bytes: c.HistoricalSummaries length is %d, which is not a multiple of 64: %w", len(sszSlice27), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice27) / 64 + if numElem > 16777216 { + return fmt.Errorf("ssz-max exceeded: c.HistoricalSummaries has %d elements, ssz-max is 16777216: %w", numElem, ssz.ErrListTooBig) + } + c.HistoricalSummaries = make([]*HistoricalSummary, numElem) + for i := 0; i < numElem; i++ { + var tmp *HistoricalSummary + tmp = new(HistoricalSummary) + tmpSlice := sszSlice27[i*64 : (1+i)*64] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("HistoricalSummaries: %w", err) + } + c.HistoricalSummaries[i] = tmp + } } - size += b.ExecutionRequests.SizeSSZ() - return -} + // Field 28: DepositRequestsStartIndex + c.DepositRequestsStartIndex = binary.LittleEndian.Uint64(sszSlice28) -// HashTreeRoot ssz hashes the BeaconBlockBodyElectra object -func (b *BeaconBlockBodyElectra) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) -} + // Field 29: DepositBalanceToConsume + if err = c.DepositBalanceToConsume.UnmarshalSSZ(sszSlice29); err != nil { + return fmt.Errorf("DepositBalanceToConsume: %w", err) + } -// HashTreeRootWith ssz hashes the BeaconBlockBodyElectra object with a hasher -func (b *BeaconBlockBodyElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() + // Field 30: ExitBalanceToConsume + if err = c.ExitBalanceToConsume.UnmarshalSSZ(sszSlice30); err != nil { + return fmt.Errorf("ExitBalanceToConsume: %w", err) + } - // Field (0) 'RandaoReveal' - if size := len(b.RandaoReveal); size != 96 { - err = ssz.ErrBytesLengthFn("--.RandaoReveal", size, 96) - return + // Field 31: EarliestExitEpoch + if err = c.EarliestExitEpoch.UnmarshalSSZ(sszSlice31); err != nil { + return fmt.Errorf("EarliestExitEpoch: %w", err) } - hh.PutBytes(b.RandaoReveal) - // Field (1) 'Eth1Data' - if err = b.Eth1Data.HashTreeRootWith(hh); err != nil { - return + // Field 32: ConsolidationBalanceToConsume + if err = c.ConsolidationBalanceToConsume.UnmarshalSSZ(sszSlice32); err != nil { + return fmt.Errorf("ConsolidationBalanceToConsume: %w", err) } - // Field (2) 'Graffiti' - if size := len(b.Graffiti); size != 32 { - err = ssz.ErrBytesLengthFn("--.Graffiti", size, 32) - return + // Field 33: EarliestConsolidationEpoch + if err = c.EarliestConsolidationEpoch.UnmarshalSSZ(sszSlice33); err != nil { + return fmt.Errorf("EarliestConsolidationEpoch: %w", err) } - hh.PutBytes(b.Graffiti) - // Field (3) 'ProposerSlashings' + // Field 34: PendingDeposits { - 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 + if len(sszSlice34)%192 != 0 { + return fmt.Errorf("misaligned bytes: c.PendingDeposits length is %d, which is not a multiple of 192: %w", len(sszSlice34), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice34) / 192 + if numElem > 134217728 { + return fmt.Errorf("ssz-max exceeded: c.PendingDeposits has %d elements, ssz-max is 134217728: %w", numElem, ssz.ErrListTooBig) + } + c.PendingDeposits = make([]*PendingDeposit, numElem) + for i := 0; i < numElem; i++ { + var tmp *PendingDeposit + tmp = new(PendingDeposit) + tmpSlice := sszSlice34[i*192 : (1+i)*192] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("PendingDeposits: %w", err) } + c.PendingDeposits[i] = tmp } - hh.MerkleizeWithMixin(subIndx, num, 16) } - // Field (4) 'AttesterSlashings' + // Field 35: PendingPartialWithdrawals { - 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 + if len(sszSlice35)%24 != 0 { + return fmt.Errorf("misaligned bytes: c.PendingPartialWithdrawals length is %d, which is not a multiple of 24: %w", len(sszSlice35), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice35) / 24 + if numElem > 134217728 { + return fmt.Errorf("ssz-max exceeded: c.PendingPartialWithdrawals has %d elements, ssz-max is 134217728: %w", numElem, ssz.ErrListTooBig) + } + c.PendingPartialWithdrawals = make([]*PendingPartialWithdrawal, numElem) + for i := 0; i < numElem; i++ { + var tmp *PendingPartialWithdrawal + tmp = new(PendingPartialWithdrawal) + tmpSlice := sszSlice35[i*24 : (1+i)*24] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("PendingPartialWithdrawals: %w", err) } + c.PendingPartialWithdrawals[i] = tmp } - hh.MerkleizeWithMixin(subIndx, num, 1) } - // Field (5) 'Attestations' + // Field 36: PendingConsolidations { - 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 + if len(sszSlice36)%16 != 0 { + return fmt.Errorf("misaligned bytes: c.PendingConsolidations length is %d, which is not a multiple of 16: %w", len(sszSlice36), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice36) / 16 + if numElem > 262144 { + return fmt.Errorf("ssz-max exceeded: c.PendingConsolidations has %d elements, ssz-max is 262144: %w", numElem, ssz.ErrListTooBig) + } + c.PendingConsolidations = make([]*PendingConsolidation, numElem) + for i := 0; i < numElem; i++ { + var tmp *PendingConsolidation + tmp = new(PendingConsolidation) + tmpSlice := sszSlice36[i*16 : (1+i)*16] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("PendingConsolidations: %w", err) } + c.PendingConsolidations[i] = tmp } - hh.MerkleizeWithMixin(subIndx, num, 8) } + return err +} + +func (c *BeaconStateElectra) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (6) 'Deposits' +func (c *BeaconStateElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: GenesisTime + hh.PutUint64(c.GenesisTime) + // Field 1: GenesisValidatorsRoot + if len(c.GenesisValidatorsRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.GenesisValidatorsRoot) + // Field 2: Slot + if err := c.Slot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Slot: %w", err) + } + // Field 3: Fork + if err := c.Fork.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Fork: %w", err) + } + // Field 4: LatestBlockHeader + if err := c.LatestBlockHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("LatestBlockHeader: %w", err) + } + // Field 5: BlockRoots { + if len(c.BlockRoots) != 8192 { + return ssz.ErrVectorLength + } 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 + for _, o := range c.BlockRoots { + if len(o) != 32 { + return ssz.ErrBytesLength } + hh.Append(o) } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.Merkleize(subIndx) } - - // Field (7) 'VoluntaryExits' + // Field 6: StateRoots { + if len(c.StateRoots) != 8192 { + return ssz.ErrVectorLength + } 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 + for _, o := range c.StateRoots { + if len(o) != 32 { + return ssz.ErrBytesLength } + hh.Append(o) } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.Merkleize(subIndx) } - - // Field (8) 'SyncAggregate' - if err = b.SyncAggregate.HashTreeRootWith(hh); err != nil { - return + // Field 7: HistoricalRoots + { + if len(c.HistoricalRoots) > 16777216 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.HistoricalRoots { + if len(o) != 32 { + return ssz.ErrBytesLength + } + hh.Append(o) + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.HistoricalRoots)), 16777216) } - - // Field (9) 'ExecutionPayload' - if err = b.ExecutionPayload.HashTreeRootWith(hh); err != nil { - return + // Field 8: Eth1Data + if err := c.Eth1Data.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Eth1Data: %w", err) } - - // Field (10) 'BlsToExecutionChanges' + // Field 9: Eth1DataVotes { + if len(c.Eth1DataVotes) > 2048 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.Eth1DataVotes { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Eth1DataVotes: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Eth1DataVotes)), 2048) } - - // Field (11) 'BlobKzgCommitments' + // Field 10: Eth1DepositIndex + hh.PutUint64(c.Eth1DepositIndex) + // Field 11: Validators { - if size := len(b.BlobKzgCommitments); size > 4096 { - err = ssz.ErrListTooBigFn("--.BlobKzgCommitments", size, 4096) - return + if len(c.Validators) > 1099511627776 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range b.BlobKzgCommitments { - if len(i) != 48 { - err = ssz.ErrBytesLength - return + for _, o := range c.Validators { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Validators: %w", err) } - hh.PutBytes(i) } - - numItems := uint64(len(b.BlobKzgCommitments)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Validators)), 1099511627776) } - - // Field (12) 'ExecutionRequests' - if err = b.ExecutionRequests.HashTreeRootWith(hh); err != nil { - return + // Field 12: Balances + { + if len(c.Balances) > 1099511627776 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.Balances { + hh.AppendUint64(o) + } + hh.FillUpTo32() + numItems := uint64(len(c.Balances)) + hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(1099511627776, numItems, 8)) } - - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the SignedBlindedBeaconBlockElectra object -func (s *SignedBlindedBeaconBlockElectra) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) -} - -// MarshalSSZTo ssz marshals the SignedBlindedBeaconBlockElectra object to a target array -func (s *SignedBlindedBeaconBlockElectra) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(100) - - // Offset (0) 'Message' - dst = ssz.WriteOffset(dst, offset) - if s.Message == nil { - s.Message = new(BlindedBeaconBlockElectra) + // Field 13: RandaoMixes + { + if len(c.RandaoMixes) != 65536 { + return ssz.ErrVectorLength + } + subIndx := hh.Index() + for _, o := range c.RandaoMixes { + if len(o) != 32 { + return ssz.ErrBytesLength + } + hh.Append(o) + } + hh.Merkleize(subIndx) } - offset += s.Message.SizeSSZ() - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 14: Slashings + { + if len(c.Slashings) != 8192 { + return ssz.ErrVectorLength + } + subIndx := hh.Index() + for _, o := range c.Slashings { + hh.AppendUint64(o) + } + hh.Merkleize(subIndx) } - dst = append(dst, s.Signature...) + // Field 15: PreviousEpochParticipation - // Field (0) 'Message' - if dst, err = s.Message.MarshalSSZTo(dst); err != nil { - return + { + if len(c.PreviousEpochParticipation) > 1099511627776 { + return ssz.ErrBytesLength + } + subIndx := hh.Index() + hh.AppendBytes32(c.PreviousEpochParticipation) + numItems := uint64(len(c.PreviousEpochParticipation)) + hh.MerkleizeWithMixin(subIndx, numItems, (1099511627776*1+31)/32) } - return -} + // Field 16: CurrentEpochParticipation -// UnmarshalSSZ ssz unmarshals the SignedBlindedBeaconBlockElectra object -func (s *SignedBlindedBeaconBlockElectra) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 100 { - return ssz.ErrSize + { + if len(c.CurrentEpochParticipation) > 1099511627776 { + return ssz.ErrBytesLength + } + subIndx := hh.Index() + hh.AppendBytes32(c.CurrentEpochParticipation) + numItems := uint64(len(c.CurrentEpochParticipation)) + hh.MerkleizeWithMixin(subIndx, numItems, (1099511627776*1+31)/32) } - tail := buf - var o0 uint64 - - // Offset (0) 'Message' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset + // Field 17: JustificationBits + if len([]byte(c.JustificationBits)) != 1 { + return ssz.ErrBytesLength } - - if o0 != 100 { - return ssz.ErrInvalidVariableOffset + hh.PutBytes([]byte(c.JustificationBits)) + // Field 18: PreviousJustifiedCheckpoint + if err := c.PreviousJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("PreviousJustifiedCheckpoint: %w", err) } - - // Field (1) 'Signature' - if cap(s.Signature) == 0 { - s.Signature = make([]byte, 0, len(buf[4:100])) + // Field 19: CurrentJustifiedCheckpoint + if err := c.CurrentJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("CurrentJustifiedCheckpoint: %w", err) } - s.Signature = append(s.Signature, buf[4:100]...) - - // Field (0) 'Message' + // Field 20: FinalizedCheckpoint + if err := c.FinalizedCheckpoint.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("FinalizedCheckpoint: %w", err) + } + // Field 21: InactivityScores { - buf = tail[o0:] - if s.Message == nil { - s.Message = new(BlindedBeaconBlockElectra) + if len(c.InactivityScores) > 1099511627776 { + return ssz.ErrListTooBig } - if err = s.Message.UnmarshalSSZ(buf); err != nil { - return err + subIndx := hh.Index() + for _, o := range c.InactivityScores { + hh.AppendUint64(o) } + hh.FillUpTo32() + numItems := uint64(len(c.InactivityScores)) + hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(1099511627776, numItems, 8)) } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the SignedBlindedBeaconBlockElectra object -func (s *SignedBlindedBeaconBlockElectra) SizeSSZ() (size int) { - size = 100 - - // Field (0) 'Message' - if s.Message == nil { - s.Message = new(BlindedBeaconBlockElectra) + // Field 22: CurrentSyncCommittee + if err := c.CurrentSyncCommittee.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("CurrentSyncCommittee: %w", err) } - size += s.Message.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the SignedBlindedBeaconBlockElectra object -func (s *SignedBlindedBeaconBlockElectra) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) -} - -// HashTreeRootWith ssz hashes the SignedBlindedBeaconBlockElectra object with a hasher -func (s *SignedBlindedBeaconBlockElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'Message' - if err = s.Message.HashTreeRootWith(hh); err != nil { - return + // Field 23: NextSyncCommittee + if err := c.NextSyncCommittee.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("NextSyncCommittee: %w", err) } - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 24: LatestExecutionPayloadHeader + if err := c.LatestExecutionPayloadHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("LatestExecutionPayloadHeader: %w", err) } - hh.PutBytes(s.Signature) - - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the BlindedBeaconBlockElectra object -func (b *BlindedBeaconBlockElectra) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} - -// MarshalSSZTo ssz marshals the BlindedBeaconBlockElectra object to a target array -func (b *BlindedBeaconBlockElectra) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(84) - - // Field (0) 'Slot' - dst = ssz.MarshalUint(dst, b.Slot) - - // Field (1) 'ProposerIndex' - dst = ssz.MarshalUint(dst, b.ProposerIndex) - - // Field (2) 'ParentRoot' - if size := len(b.ParentRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentRoot", size, 32) - return + // Field 25: NextWithdrawalIndex + hh.PutUint64(c.NextWithdrawalIndex) + // Field 26: NextWithdrawalValidatorIndex + if err := c.NextWithdrawalValidatorIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("NextWithdrawalValidatorIndex: %w", err) } - dst = append(dst, b.ParentRoot...) - - // Field (3) 'StateRoot' - if size := len(b.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return + // Field 27: HistoricalSummaries + { + if len(c.HistoricalSummaries) > 16777216 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.HistoricalSummaries { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("HistoricalSummaries: %w", err) + } + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.HistoricalSummaries)), 16777216) } - dst = append(dst, b.StateRoot...) - - // Offset (4) 'Body' - dst = ssz.WriteOffset(dst, offset) - if b.Body == nil { - b.Body = new(BlindedBeaconBlockBodyElectra) + // Field 28: DepositRequestsStartIndex + hh.PutUint64(c.DepositRequestsStartIndex) + // Field 29: DepositBalanceToConsume + if err := c.DepositBalanceToConsume.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("DepositBalanceToConsume: %w", err) } - offset += b.Body.SizeSSZ() - - // Field (4) 'Body' - if dst, err = b.Body.MarshalSSZTo(dst); err != nil { - return + // Field 30: ExitBalanceToConsume + if err := c.ExitBalanceToConsume.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ExitBalanceToConsume: %w", err) } - - return -} - -// UnmarshalSSZ ssz unmarshals the BlindedBeaconBlockElectra object -func (b *BlindedBeaconBlockElectra) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 84 { - return ssz.ErrSize + // Field 31: EarliestExitEpoch + if err := c.EarliestExitEpoch.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("EarliestExitEpoch: %w", err) } - - tail := buf - var o4 uint64 - - // Field (0) 'Slot' - b.Slot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[0:8]) - - // Field (1) 'ProposerIndex' - b.ProposerIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[8:16]) - - // Field (2) 'ParentRoot' - if cap(b.ParentRoot) == 0 { - b.ParentRoot = make([]byte, 0, len(buf[16:48])) + // Field 32: ConsolidationBalanceToConsume + if err := c.ConsolidationBalanceToConsume.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ConsolidationBalanceToConsume: %w", err) } - 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])) + // Field 33: EarliestConsolidationEpoch + if err := c.EarliestConsolidationEpoch.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("EarliestConsolidationEpoch: %w", err) } - b.StateRoot = append(b.StateRoot, buf[48:80]...) - - // Offset (4) 'Body' - if o4 = ssz.ReadOffset(buf[80:84]); o4 > size { - return ssz.ErrOffset + // Field 34: PendingDeposits + { + if len(c.PendingDeposits) > 134217728 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.PendingDeposits { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("PendingDeposits: %w", err) + } + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.PendingDeposits)), 134217728) } - - if o4 != 84 { - return ssz.ErrInvalidVariableOffset + // Field 35: PendingPartialWithdrawals + { + if len(c.PendingPartialWithdrawals) > 134217728 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.PendingPartialWithdrawals { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("PendingPartialWithdrawals: %w", err) + } + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.PendingPartialWithdrawals)), 134217728) } - - // Field (4) 'Body' + // Field 36: PendingConsolidations { - buf = tail[o4:] - if b.Body == nil { - b.Body = new(BlindedBeaconBlockBodyElectra) + if len(c.PendingConsolidations) > 262144 { + return ssz.ErrListTooBig } - if err = b.Body.UnmarshalSSZ(buf); err != nil { - return err + subIndx := hh.Index() + for _, o := range c.PendingConsolidations { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("PendingConsolidations: %w", err) + } } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.PendingConsolidations)), 262144) } - return err + hh.Merkleize(indx) + return nil } -// SizeSSZ returns the ssz encoded size in bytes for the BlindedBeaconBlockElectra object -func (b *BlindedBeaconBlockElectra) SizeSSZ() (size int) { - size = 84 - - // Field (4) 'Body' - if b.Body == nil { - b.Body = new(BlindedBeaconBlockBodyElectra) +func (c *BlindedBeaconBlockBodyElectra) SizeSSZ() int { + size := 396 + size += len(c.ProposerSlashings) * 416 + for _, o := range c.AttesterSlashings { + size += 4 + size += o.SizeSSZ() } - size += b.Body.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the BlindedBeaconBlockElectra object -func (b *BlindedBeaconBlockElectra) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) -} - -// HashTreeRootWith ssz hashes the BlindedBeaconBlockElectra object with a hasher -func (b *BlindedBeaconBlockElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'Slot' - ssz.PutUint(hh, b.Slot) - - // Field (1) 'ProposerIndex' - ssz.PutUint(hh, b.ProposerIndex) - - // Field (2) 'ParentRoot' - if size := len(b.ParentRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentRoot", size, 32) - return + for _, o := range c.Attestations { + size += 4 + size += o.SizeSSZ() } - hh.PutBytes(b.ParentRoot) - - // Field (3) 'StateRoot' - if size := len(b.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return + size += len(c.Deposits) * 1240 + size += len(c.VoluntaryExits) * 112 + if c.ExecutionPayloadHeader == nil { + c.ExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderDeneb) } - hh.PutBytes(b.StateRoot) - - // Field (4) 'Body' - if err = b.Body.HashTreeRootWith(hh); err != nil { - return + size += c.ExecutionPayloadHeader.SizeSSZ() + size += len(c.BlsToExecutionChanges) * 172 + size += len(c.BlobKzgCommitments) * 48 + if c.ExecutionRequests == nil { + c.ExecutionRequests = new(v1.ExecutionRequests) } - - hh.Merkleize(indx) - return + size += c.ExecutionRequests.SizeSSZ() + return size } -// MarshalSSZ ssz marshals the BlindedBeaconBlockBodyElectra object -func (b *BlindedBeaconBlockBodyElectra) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) +func (c *BlindedBeaconBlockBodyElectra) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the BlindedBeaconBlockBodyElectra object to a target array -func (b *BlindedBeaconBlockBodyElectra) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(396) +func (c *BlindedBeaconBlockBodyElectra) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 396 - // Field (0) 'RandaoReveal' - if size := len(b.RandaoReveal); size != 96 { - err = ssz.ErrBytesLengthFn("--.RandaoReveal", size, 96) - return + // Field 0: RandaoReveal + if len(c.RandaoReveal) != 96 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.RandaoReveal...) + dst = append(dst, c.RandaoReveal...) - // Field (1) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(Eth1Data) + // Field 1: Eth1Data + if c.Eth1Data == nil { + c.Eth1Data = new(Eth1Data) } - if dst, err = b.Eth1Data.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.Eth1Data.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Eth1Data: %w", err) } - // Field (2) 'Graffiti' - if size := len(b.Graffiti); size != 32 { - err = ssz.ErrBytesLengthFn("--.Graffiti", size, 32) - return + // Field 2: Graffiti + if len(c.Graffiti) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.Graffiti...) + dst = append(dst, c.Graffiti...) - // Offset (3) 'ProposerSlashings' + // Field 3: ProposerSlashings dst = ssz.WriteOffset(dst, offset) - offset += len(b.ProposerSlashings) * 416 + offset += len(c.ProposerSlashings) * 416 - // Offset (4) 'AttesterSlashings' + // Field 4: AttesterSlashings dst = ssz.WriteOffset(dst, offset) - for ii := 0; ii < len(b.AttesterSlashings); ii++ { + for _, o := range c.AttesterSlashings { offset += 4 - offset += b.AttesterSlashings[ii].SizeSSZ() + offset += o.SizeSSZ() } - // Offset (5) 'Attestations' + // Field 5: Attestations dst = ssz.WriteOffset(dst, offset) - for ii := 0; ii < len(b.Attestations); ii++ { + for _, o := range c.Attestations { offset += 4 - offset += b.Attestations[ii].SizeSSZ() + offset += o.SizeSSZ() } - // Offset (6) 'Deposits' + // Field 6: Deposits dst = ssz.WriteOffset(dst, offset) - offset += len(b.Deposits) * 1240 + offset += len(c.Deposits) * 1240 - // Offset (7) 'VoluntaryExits' + // Field 7: VoluntaryExits dst = ssz.WriteOffset(dst, offset) - offset += len(b.VoluntaryExits) * 112 + offset += len(c.VoluntaryExits) * 112 - // Field (8) 'SyncAggregate' - if b.SyncAggregate == nil { - b.SyncAggregate = new(SyncAggregate) + // Field 8: SyncAggregate + if c.SyncAggregate == nil { + c.SyncAggregate = new(SyncAggregate) } - if dst, err = b.SyncAggregate.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.SyncAggregate.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SyncAggregate: %w", err) } - // Offset (9) 'ExecutionPayloadHeader' - dst = ssz.WriteOffset(dst, offset) - if b.ExecutionPayloadHeader == nil { - b.ExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderDeneb) + // Field 9: ExecutionPayloadHeader + if c.ExecutionPayloadHeader == nil { + c.ExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderDeneb) } - offset += b.ExecutionPayloadHeader.SizeSSZ() - - // Offset (10) 'BlsToExecutionChanges' dst = ssz.WriteOffset(dst, offset) - offset += len(b.BlsToExecutionChanges) * 172 + offset += c.ExecutionPayloadHeader.SizeSSZ() - // Offset (11) 'BlobKzgCommitments' + // Field 10: BlsToExecutionChanges dst = ssz.WriteOffset(dst, offset) - offset += len(b.BlobKzgCommitments) * 48 + offset += len(c.BlsToExecutionChanges) * 172 - // Offset (12) 'ExecutionRequests' + // Field 11: BlobKzgCommitments dst = ssz.WriteOffset(dst, offset) - if b.ExecutionRequests == nil { - b.ExecutionRequests = new(v1.ExecutionRequests) + offset += len(c.BlobKzgCommitments) * 48 + + // Field 12: ExecutionRequests + if c.ExecutionRequests == nil { + c.ExecutionRequests = new(v1.ExecutionRequests) } - offset += b.ExecutionRequests.SizeSSZ() + dst = ssz.WriteOffset(dst, offset) + offset += c.ExecutionRequests.SizeSSZ() - // Field (3) 'ProposerSlashings' - if size := len(b.ProposerSlashings); size > 16 { - err = ssz.ErrListTooBigFn("--.ProposerSlashings", size, 16) - return + // Field 3: ProposerSlashings + if len(c.ProposerSlashings) > 16 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.ProposerSlashings); ii++ { - if dst, err = b.ProposerSlashings[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.ProposerSlashings { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ProposerSlashings: %w", err) } } - // Field (4) 'AttesterSlashings' - if size := len(b.AttesterSlashings); size > 1 { - err = ssz.ErrListTooBigFn("--.AttesterSlashings", size, 1) - return + // Field 4: AttesterSlashings + if len(c.AttesterSlashings) > 1 { + return nil, ssz.ErrListTooBig } { - offset = 4 * len(b.AttesterSlashings) - for ii := 0; ii < len(b.AttesterSlashings); ii++ { + offset = 4 * len(c.AttesterSlashings) + for _, o := range c.AttesterSlashings { dst = ssz.WriteOffset(dst, offset) - offset += b.AttesterSlashings[ii].SizeSSZ() + offset += o.SizeSSZ() } } - for ii := 0; ii < len(b.AttesterSlashings); ii++ { - if dst, err = b.AttesterSlashings[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.AttesterSlashings { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("AttesterSlashings: %w", err) } } - // Field (5) 'Attestations' - if size := len(b.Attestations); size > 8 { - err = ssz.ErrListTooBigFn("--.Attestations", size, 8) - return + // Field 5: Attestations + if len(c.Attestations) > 8 { + return nil, ssz.ErrListTooBig } { - offset = 4 * len(b.Attestations) - for ii := 0; ii < len(b.Attestations); ii++ { + offset = 4 * len(c.Attestations) + for _, o := range c.Attestations { dst = ssz.WriteOffset(dst, offset) - offset += b.Attestations[ii].SizeSSZ() + offset += o.SizeSSZ() } } - for ii := 0; ii < len(b.Attestations); ii++ { - if dst, err = b.Attestations[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.Attestations { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Attestations: %w", err) } } - // Field (6) 'Deposits' - if size := len(b.Deposits); size > 16 { - err = ssz.ErrListTooBigFn("--.Deposits", size, 16) - return + // Field 6: Deposits + if len(c.Deposits) > 16 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.Deposits); ii++ { - if dst, err = b.Deposits[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.Deposits { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Deposits: %w", err) } } - // Field (7) 'VoluntaryExits' - if size := len(b.VoluntaryExits); size > 16 { - err = ssz.ErrListTooBigFn("--.VoluntaryExits", size, 16) - return + // Field 7: VoluntaryExits + if len(c.VoluntaryExits) > 16 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.VoluntaryExits); ii++ { - if dst, err = b.VoluntaryExits[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.VoluntaryExits { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("VoluntaryExits: %w", err) } } - // Field (9) 'ExecutionPayloadHeader' - if dst, err = b.ExecutionPayloadHeader.MarshalSSZTo(dst); err != nil { - return + // Field 9: ExecutionPayloadHeader + if dst, err = c.ExecutionPayloadHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ExecutionPayloadHeader: %w", err) } - // Field (10) 'BlsToExecutionChanges' - if size := len(b.BlsToExecutionChanges); size > 16 { - err = ssz.ErrListTooBigFn("--.BlsToExecutionChanges", size, 16) - return + // Field 10: BlsToExecutionChanges + if len(c.BlsToExecutionChanges) > 16 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.BlsToExecutionChanges); ii++ { - if dst, err = b.BlsToExecutionChanges[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.BlsToExecutionChanges { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("BlsToExecutionChanges: %w", err) } } - // Field (11) 'BlobKzgCommitments' - if size := len(b.BlobKzgCommitments); size > 4096 { - err = ssz.ErrListTooBigFn("--.BlobKzgCommitments", size, 4096) - return + // Field 11: BlobKzgCommitments + if len(c.BlobKzgCommitments) > 4096 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.BlobKzgCommitments); ii++ { - if size := len(b.BlobKzgCommitments[ii]); size != 48 { - err = ssz.ErrBytesLengthFn("--.BlobKzgCommitments[ii]", size, 48) - return + for _, o := range c.BlobKzgCommitments { + if len(o) != 48 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.BlobKzgCommitments[ii]...) + dst = append(dst, o...) } - // Field (12) 'ExecutionRequests' - if dst, err = b.ExecutionRequests.MarshalSSZTo(dst); err != nil { - return + // Field 12: ExecutionRequests + if dst, err = c.ExecutionRequests.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ExecutionRequests: %w", err) } - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the BlindedBeaconBlockBodyElectra object -func (b *BlindedBeaconBlockBodyElectra) UnmarshalSSZ(buf []byte) error { +func (c *BlindedBeaconBlockBodyElectra) 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(Eth1Data) - } - if err = b.Eth1Data.UnmarshalSSZ(buf[96:168]); err != nil { - return err - } - - // Field (2) 'Graffiti' - if cap(b.Graffiti) == 0 { - b.Graffiti = make([]byte, 0, len(buf[168:200])) - } - b.Graffiti = append(b.Graffiti, buf[168:200]...) - - // Offset (3) 'ProposerSlashings' - if o3 = ssz.ReadOffset(buf[200:204]); o3 > size { - return ssz.ErrOffset - } + sszSlice0 := buf[0:96] // c.RandaoReveal + sszSlice1 := buf[96:168] // c.Eth1Data + sszSlice2 := buf[168:200] // c.Graffiti + sszSlice8 := buf[220:380] // c.SyncAggregate - if o3 != 396 { + sszVarOffset3 := ssz.ReadOffset(buf[200:204]) // c.ProposerSlashings + if sszVarOffset3 != 396 { return ssz.ErrInvalidVariableOffset } - - // Offset (4) 'AttesterSlashings' - if o4 = ssz.ReadOffset(buf[204:208]); o4 > size || o3 > o4 { + if sszVarOffset3 > size { return ssz.ErrOffset } - - // Offset (5) 'Attestations' - if o5 = ssz.ReadOffset(buf[208:212]); o5 > size || o4 > o5 { + sszVarOffset4 := ssz.ReadOffset(buf[204:208]) // c.AttesterSlashings + if sszVarOffset4 > size || sszVarOffset4 < sszVarOffset3 { return ssz.ErrOffset } - - // Offset (6) 'Deposits' - if o6 = ssz.ReadOffset(buf[212:216]); o6 > size || o5 > o6 { + sszVarOffset5 := ssz.ReadOffset(buf[208:212]) // c.Attestations + if sszVarOffset5 > size || sszVarOffset5 < sszVarOffset4 { return ssz.ErrOffset } - - // Offset (7) 'VoluntaryExits' - if o7 = ssz.ReadOffset(buf[216:220]); o7 > size || o6 > o7 { + sszVarOffset6 := ssz.ReadOffset(buf[212:216]) // c.Deposits + if sszVarOffset6 > size || sszVarOffset6 < sszVarOffset5 { return ssz.ErrOffset } - - // Field (8) 'SyncAggregate' - if b.SyncAggregate == nil { - b.SyncAggregate = new(SyncAggregate) + sszVarOffset7 := ssz.ReadOffset(buf[216:220]) // c.VoluntaryExits + if sszVarOffset7 > size || sszVarOffset7 < sszVarOffset6 { + return ssz.ErrOffset } - if err = b.SyncAggregate.UnmarshalSSZ(buf[220:380]); err != nil { - return err + sszVarOffset9 := ssz.ReadOffset(buf[380:384]) // c.ExecutionPayloadHeader + if sszVarOffset9 > size || sszVarOffset9 < sszVarOffset7 { + return ssz.ErrOffset } - - // Offset (9) 'ExecutionPayloadHeader' - if o9 = ssz.ReadOffset(buf[380:384]); o9 > size || o7 > o9 { + sszVarOffset10 := ssz.ReadOffset(buf[384:388]) // c.BlsToExecutionChanges + if sszVarOffset10 > size || sszVarOffset10 < sszVarOffset9 { return ssz.ErrOffset } - - // Offset (10) 'BlsToExecutionChanges' - if o10 = ssz.ReadOffset(buf[384:388]); o10 > size || o9 > o10 { + sszVarOffset11 := ssz.ReadOffset(buf[388:392]) // c.BlobKzgCommitments + if sszVarOffset11 > size || sszVarOffset11 < sszVarOffset10 { return ssz.ErrOffset } - - // Offset (11) 'BlobKzgCommitments' - if o11 = ssz.ReadOffset(buf[388:392]); o11 > size || o10 > o11 { + sszVarOffset12 := ssz.ReadOffset(buf[392:396]) // c.ExecutionRequests + if sszVarOffset12 > size || sszVarOffset12 < sszVarOffset11 { return ssz.ErrOffset } + sszSlice3 := buf[sszVarOffset3:sszVarOffset4] // c.ProposerSlashings + sszSlice4 := buf[sszVarOffset4:sszVarOffset5] // c.AttesterSlashings + sszSlice5 := buf[sszVarOffset5:sszVarOffset6] // c.Attestations + sszSlice6 := buf[sszVarOffset6:sszVarOffset7] // c.Deposits + sszSlice7 := buf[sszVarOffset7:sszVarOffset9] // c.VoluntaryExits + sszSlice9 := buf[sszVarOffset9:sszVarOffset10] // c.ExecutionPayloadHeader + sszSlice10 := buf[sszVarOffset10:sszVarOffset11] // c.BlsToExecutionChanges + sszSlice11 := buf[sszVarOffset11:sszVarOffset12] // c.BlobKzgCommitments + sszSlice12 := buf[sszVarOffset12:] // c.ExecutionRequests - // Offset (12) 'ExecutionRequests' - if o12 = ssz.ReadOffset(buf[392:396]); o12 > size || o11 > o12 { - return ssz.ErrOffset + // Field 0: RandaoReveal + c.RandaoReveal = make([]byte, 0, 96) + c.RandaoReveal = append(c.RandaoReveal, sszSlice0...) + + // Field 1: Eth1Data + c.Eth1Data = new(Eth1Data) + if err = c.Eth1Data.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Eth1Data: %w", err) } - // Field (3) 'ProposerSlashings' + // Field 2: Graffiti + c.Graffiti = make([]byte, 0, 32) + c.Graffiti = append(c.Graffiti, sszSlice2...) + + // Field 3: ProposerSlashings { - buf = tail[o3:o4] - num, err := ssz.DivideInt2(len(buf), 416, 16) - if err != nil { - return err - } - b.ProposerSlashings = make([]*ProposerSlashing, num) - for ii := 0; ii < num; ii++ { - if b.ProposerSlashings[ii] == nil { - b.ProposerSlashings[ii] = new(ProposerSlashing) - } - if err = b.ProposerSlashings[ii].UnmarshalSSZ(buf[ii*416 : (ii+1)*416]); err != nil { - return err + if len(sszSlice3)%416 != 0 { + return fmt.Errorf("misaligned bytes: c.ProposerSlashings length is %d, which is not a multiple of 416: %w", len(sszSlice3), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice3) / 416 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.ProposerSlashings has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.ProposerSlashings = make([]*ProposerSlashing, numElem) + for i := 0; i < numElem; i++ { + var tmp *ProposerSlashing + tmp = new(ProposerSlashing) + tmpSlice := sszSlice3[i*416 : (1+i)*416] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("ProposerSlashings: %w", err) } + c.ProposerSlashings[i] = tmp } } - // Field (4) 'AttesterSlashings' + // Field 4: AttesterSlashings { - buf = tail[o4:o5] - num, err := ssz.DecodeDynamicLength(buf, 1) - if err != nil { - return err - } - b.AttesterSlashings = make([]*AttesterSlashingElectra, num) - err = ssz.UnmarshalDynamic(buf, num, func(indx int, buf []byte) (err error) { - if b.AttesterSlashings[indx] == nil { - b.AttesterSlashings[indx] = new(AttesterSlashingElectra) + // empty lists are zero length, so make sure there is room for an offset + // before attempting to unmarshal it + if len(sszSlice4) > 3 { + startOffset := ssz.ReadOffset(sszSlice4[0:4]) + if startOffset == 0 { + return fmt.Errorf("encountered invalid offset of 0 when decoding c.AttesterSlashings") + } + if startOffset%4 != 0 { + return fmt.Errorf("misaligned list bytes: when decoding c.AttesterSlashings, end-of-list offset is %d, which is not a multiple of 4 (offset size)", startOffset) + } + listLen := startOffset / 4 + if listLen > 1 { + return fmt.Errorf("ssz-max exceeded: c.AttesterSlashings has %d elements, ssz-max is 1: %w", listLen, ssz.ErrListTooBig) + } + totalVarBytes := uint64(len(sszSlice4)) + if totalVarBytes < startOffset { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.AttesterSlashings") + } + c.AttesterSlashings = make([]*AttesterSlashingElectra, listLen) + var tmpSlice []byte + for i := uint64(0); i < listLen; i++ { + var tmp *AttesterSlashingElectra + tmp = new(AttesterSlashingElectra) + endOffset := totalVarBytes + if i+1 != listLen { + endOffset = ssz.ReadOffset(sszSlice4[(i+1)*4 : (i+2)*4]) + if totalVarBytes < endOffset { + return fmt.Errorf("offset %d points past the end of buffer when decoding c.AttesterSlashings", endOffset) + } + } + if endOffset < startOffset { + return fmt.Errorf("offset %d is not greater than start offset %d when decoding c.AttesterSlashings", endOffset, startOffset) + } + tmpSlice = sszSlice4[startOffset:endOffset] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("AttesterSlashings: %w", err) + } + c.AttesterSlashings[i] = tmp + startOffset = endOffset } - if err = b.AttesterSlashings[indx].UnmarshalSSZ(buf); err != nil { - return err + } else { + if len(sszSlice4) > 0 { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.AttesterSlashings") } - return nil - }) - if err != nil { - return err + c.AttesterSlashings = make([]*AttesterSlashingElectra, 0) } } - // Field (5) 'Attestations' + // Field 5: Attestations { - buf = tail[o5:o6] - num, err := ssz.DecodeDynamicLength(buf, 8) - if err != nil { - return err - } - b.Attestations = make([]*AttestationElectra, num) - err = ssz.UnmarshalDynamic(buf, num, func(indx int, buf []byte) (err error) { - if b.Attestations[indx] == nil { - b.Attestations[indx] = new(AttestationElectra) + // empty lists are zero length, so make sure there is room for an offset + // before attempting to unmarshal it + if len(sszSlice5) > 3 { + startOffset := ssz.ReadOffset(sszSlice5[0:4]) + if startOffset == 0 { + return fmt.Errorf("encountered invalid offset of 0 when decoding c.Attestations") } - if err = b.Attestations[indx].UnmarshalSSZ(buf); err != nil { - return err + if startOffset%4 != 0 { + return fmt.Errorf("misaligned list bytes: when decoding c.Attestations, end-of-list offset is %d, which is not a multiple of 4 (offset size)", startOffset) } - return nil - }) - if err != nil { - return err + listLen := startOffset / 4 + if listLen > 8 { + return fmt.Errorf("ssz-max exceeded: c.Attestations has %d elements, ssz-max is 8: %w", listLen, ssz.ErrListTooBig) + } + totalVarBytes := uint64(len(sszSlice5)) + if totalVarBytes < startOffset { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.Attestations") + } + c.Attestations = make([]*AttestationElectra, listLen) + var tmpSlice []byte + for i := uint64(0); i < listLen; i++ { + var tmp *AttestationElectra + tmp = new(AttestationElectra) + endOffset := totalVarBytes + if i+1 != listLen { + endOffset = ssz.ReadOffset(sszSlice5[(i+1)*4 : (i+2)*4]) + if totalVarBytes < endOffset { + return fmt.Errorf("offset %d points past the end of buffer when decoding c.Attestations", endOffset) + } + } + if endOffset < startOffset { + return fmt.Errorf("offset %d is not greater than start offset %d when decoding c.Attestations", endOffset, startOffset) + } + tmpSlice = sszSlice5[startOffset:endOffset] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Attestations: %w", err) + } + c.Attestations[i] = tmp + startOffset = endOffset + } + } else { + if len(sszSlice5) > 0 { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.Attestations") + } + c.Attestations = make([]*AttestationElectra, 0) } } - // Field (6) 'Deposits' + // Field 6: Deposits { - buf = tail[o6:o7] - num, err := ssz.DivideInt2(len(buf), 1240, 16) - if err != nil { - return err - } - b.Deposits = make([]*Deposit, num) - for ii := 0; ii < num; ii++ { - if b.Deposits[ii] == nil { - b.Deposits[ii] = new(Deposit) - } - if err = b.Deposits[ii].UnmarshalSSZ(buf[ii*1240 : (ii+1)*1240]); err != nil { - return err + if len(sszSlice6)%1240 != 0 { + return fmt.Errorf("misaligned bytes: c.Deposits length is %d, which is not a multiple of 1240: %w", len(sszSlice6), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice6) / 1240 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.Deposits has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.Deposits = make([]*Deposit, numElem) + for i := 0; i < numElem; i++ { + var tmp *Deposit + tmp = new(Deposit) + tmpSlice := sszSlice6[i*1240 : (1+i)*1240] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Deposits: %w", err) } + c.Deposits[i] = tmp } } - // Field (7) 'VoluntaryExits' + // Field 7: VoluntaryExits { - buf = tail[o7:o9] - num, err := ssz.DivideInt2(len(buf), 112, 16) - if err != nil { - return err - } - b.VoluntaryExits = make([]*SignedVoluntaryExit, num) - for ii := 0; ii < num; ii++ { - if b.VoluntaryExits[ii] == nil { - b.VoluntaryExits[ii] = new(SignedVoluntaryExit) - } - if err = b.VoluntaryExits[ii].UnmarshalSSZ(buf[ii*112 : (ii+1)*112]); err != nil { - return err + if len(sszSlice7)%112 != 0 { + return fmt.Errorf("misaligned bytes: c.VoluntaryExits length is %d, which is not a multiple of 112: %w", len(sszSlice7), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice7) / 112 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.VoluntaryExits has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.VoluntaryExits = make([]*SignedVoluntaryExit, numElem) + for i := 0; i < numElem; i++ { + var tmp *SignedVoluntaryExit + tmp = new(SignedVoluntaryExit) + tmpSlice := sszSlice7[i*112 : (1+i)*112] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("VoluntaryExits: %w", err) } + c.VoluntaryExits[i] = tmp } } - // Field (9) 'ExecutionPayloadHeader' - { - buf = tail[o9:o10] - if b.ExecutionPayloadHeader == nil { - b.ExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderDeneb) - } - if err = b.ExecutionPayloadHeader.UnmarshalSSZ(buf); err != nil { - return err - } + // Field 8: SyncAggregate + c.SyncAggregate = new(SyncAggregate) + if err = c.SyncAggregate.UnmarshalSSZ(sszSlice8); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) } - // Field (10) 'BlsToExecutionChanges' - { - buf = tail[o10:o11] - num, err := ssz.DivideInt2(len(buf), 172, 16) - if err != nil { - return err - } - b.BlsToExecutionChanges = make([]*SignedBLSToExecutionChange, num) - for ii := 0; ii < num; ii++ { - if b.BlsToExecutionChanges[ii] == nil { - b.BlsToExecutionChanges[ii] = new(SignedBLSToExecutionChange) - } - if err = b.BlsToExecutionChanges[ii].UnmarshalSSZ(buf[ii*172 : (ii+1)*172]); err != nil { - return err - } - } + // Field 9: ExecutionPayloadHeader + c.ExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderDeneb) + if err = c.ExecutionPayloadHeader.UnmarshalSSZ(sszSlice9); err != nil { + return fmt.Errorf("ExecutionPayloadHeader: %w", err) } - // Field (11) 'BlobKzgCommitments' + // Field 10: BlsToExecutionChanges { - buf = tail[o11:o12] - num, err := ssz.DivideInt2(len(buf), 48, 4096) - if err != nil { - return err - } - b.BlobKzgCommitments = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(b.BlobKzgCommitments[ii]) == 0 { - b.BlobKzgCommitments[ii] = make([]byte, 0, len(buf[ii*48:(ii+1)*48])) + if len(sszSlice10)%172 != 0 { + return fmt.Errorf("misaligned bytes: c.BlsToExecutionChanges length is %d, which is not a multiple of 172: %w", len(sszSlice10), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice10) / 172 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.BlsToExecutionChanges has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.BlsToExecutionChanges = make([]*SignedBLSToExecutionChange, numElem) + for i := 0; i < numElem; i++ { + var tmp *SignedBLSToExecutionChange + tmp = new(SignedBLSToExecutionChange) + tmpSlice := sszSlice10[i*172 : (1+i)*172] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("BlsToExecutionChanges: %w", err) } - b.BlobKzgCommitments[ii] = append(b.BlobKzgCommitments[ii], buf[ii*48:(ii+1)*48]...) + c.BlsToExecutionChanges[i] = tmp } } - // Field (12) 'ExecutionRequests' + // Field 11: BlobKzgCommitments { - buf = tail[o12:] - if b.ExecutionRequests == nil { - b.ExecutionRequests = new(v1.ExecutionRequests) + if len(sszSlice11)%48 != 0 { + return fmt.Errorf("misaligned bytes: c.BlobKzgCommitments length is %d, which is not a multiple of 48: %w", len(sszSlice11), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice11) / 48 + if numElem > 4096 { + return fmt.Errorf("ssz-max exceeded: c.BlobKzgCommitments has %d elements, ssz-max is 4096: %w", numElem, ssz.ErrListTooBig) } - if err = b.ExecutionRequests.UnmarshalSSZ(buf); err != nil { - return err + c.BlobKzgCommitments = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte + + tmpSlice := sszSlice11[i*48 : (1+i)*48] + tmp = make([]byte, 0, 48) + tmp = append(tmp, tmpSlice...) + c.BlobKzgCommitments[i] = tmp } } + + // Field 12: ExecutionRequests + c.ExecutionRequests = new(v1.ExecutionRequests) + if err = c.ExecutionRequests.UnmarshalSSZ(sszSlice12); err != nil { + return fmt.Errorf("ExecutionRequests: %w", err) + } return err } -// SizeSSZ returns the ssz encoded size in bytes for the BlindedBeaconBlockBodyElectra object -func (b *BlindedBeaconBlockBodyElectra) 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() +func (c *BlindedBeaconBlockBodyElectra) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (5) 'Attestations' - for ii := 0; ii < len(b.Attestations); ii++ { - size += 4 - size += b.Attestations[ii].SizeSSZ() +func (c *BlindedBeaconBlockBodyElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: RandaoReveal + if len(c.RandaoReveal) != 96 { + return ssz.ErrBytesLength } - - // Field (6) 'Deposits' - size += len(b.Deposits) * 1240 - - // Field (7) 'VoluntaryExits' - size += len(b.VoluntaryExits) * 112 - - // Field (9) 'ExecutionPayloadHeader' - if b.ExecutionPayloadHeader == nil { - b.ExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderDeneb) - } - size += b.ExecutionPayloadHeader.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(v1.ExecutionRequests) + hh.PutBytes(c.RandaoReveal) + // Field 1: Eth1Data + if err := c.Eth1Data.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Eth1Data: %w", err) } - size += b.ExecutionRequests.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the BlindedBeaconBlockBodyElectra object -func (b *BlindedBeaconBlockBodyElectra) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) -} - -// HashTreeRootWith ssz hashes the BlindedBeaconBlockBodyElectra object with a hasher -func (b *BlindedBeaconBlockBodyElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'RandaoReveal' - if size := len(b.RandaoReveal); size != 96 { - err = ssz.ErrBytesLengthFn("--.RandaoReveal", size, 96) - return - } - hh.PutBytes(b.RandaoReveal) - - // Field (1) 'Eth1Data' - if err = b.Eth1Data.HashTreeRootWith(hh); err != nil { - return + // Field 2: Graffiti + if len(c.Graffiti) != 32 { + return ssz.ErrBytesLength } - - // Field (2) 'Graffiti' - if size := len(b.Graffiti); size != 32 { - err = ssz.ErrBytesLengthFn("--.Graffiti", size, 32) - return - } - hh.PutBytes(b.Graffiti) - - // Field (3) 'ProposerSlashings' + hh.PutBytes(c.Graffiti) + // Field 3: ProposerSlashings { + if len(c.ProposerSlashings) > 16 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.ProposerSlashings { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ProposerSlashings: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.ProposerSlashings)), 16) } - - // Field (4) 'AttesterSlashings' + // Field 4: AttesterSlashings { + if len(c.AttesterSlashings) > 1 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.AttesterSlashings { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("AttesterSlashings: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 1) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.AttesterSlashings)), 1) } - - // Field (5) 'Attestations' + // Field 5: Attestations { + if len(c.Attestations) > 8 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.Attestations { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Attestations: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 8) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Attestations)), 8) } - - // Field (6) 'Deposits' + // Field 6: Deposits { + if len(c.Deposits) > 16 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.Deposits { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Deposits: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Deposits)), 16) } - - // Field (7) 'VoluntaryExits' + // Field 7: VoluntaryExits { + if len(c.VoluntaryExits) > 16 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.VoluntaryExits { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("VoluntaryExits: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.VoluntaryExits)), 16) } - - // Field (8) 'SyncAggregate' - if err = b.SyncAggregate.HashTreeRootWith(hh); err != nil { - return + // Field 8: SyncAggregate + if err := c.SyncAggregate.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) } - - // Field (9) 'ExecutionPayloadHeader' - if err = b.ExecutionPayloadHeader.HashTreeRootWith(hh); err != nil { - return + // Field 9: ExecutionPayloadHeader + if err := c.ExecutionPayloadHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ExecutionPayloadHeader: %w", err) } - - // Field (10) 'BlsToExecutionChanges' + // Field 10: BlsToExecutionChanges { + if len(c.BlsToExecutionChanges) > 16 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.BlsToExecutionChanges { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("BlsToExecutionChanges: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.BlsToExecutionChanges)), 16) } - - // Field (11) 'BlobKzgCommitments' + // Field 11: BlobKzgCommitments { - if size := len(b.BlobKzgCommitments); size > 4096 { - err = ssz.ErrListTooBigFn("--.BlobKzgCommitments", size, 4096) - return + if len(c.BlobKzgCommitments) > 4096 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range b.BlobKzgCommitments { - if len(i) != 48 { - err = ssz.ErrBytesLength - return + for _, o := range c.BlobKzgCommitments { + if len(o) != 48 { + return ssz.ErrBytesLength } - hh.PutBytes(i) + hh.PutBytes(o) } - - numItems := uint64(len(b.BlobKzgCommitments)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.BlobKzgCommitments)), 4096) } - - // Field (12) 'ExecutionRequests' - if err = b.ExecutionRequests.HashTreeRootWith(hh); err != nil { - return + // Field 12: ExecutionRequests + if err := c.ExecutionRequests.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ExecutionRequests: %w", err) } - hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the AttesterSlashingElectra object -func (a *AttesterSlashingElectra) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(a) +func (c *BlindedBeaconBlockElectra) SizeSSZ() int { + size := 84 + if c.Body == nil { + c.Body = new(BlindedBeaconBlockBodyElectra) + } + size += c.Body.SizeSSZ() + return size } -// MarshalSSZTo ssz marshals the AttesterSlashingElectra object to a target array -func (a *AttesterSlashingElectra) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(8) +func (c *BlindedBeaconBlockElectra) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Offset (0) 'Attestation_1' - dst = ssz.WriteOffset(dst, offset) - if a.Attestation_1 == nil { - a.Attestation_1 = new(IndexedAttestationElectra) +func (c *BlindedBeaconBlockElectra) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 84 + + // Field 0: Slot + if dst, err = c.Slot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Slot: %w", err) } - offset += a.Attestation_1.SizeSSZ() - // Offset (1) 'Attestation_2' - dst = ssz.WriteOffset(dst, offset) - if a.Attestation_2 == nil { - a.Attestation_2 = new(IndexedAttestationElectra) + // Field 1: ProposerIndex + if dst, err = c.ProposerIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ProposerIndex: %w", err) } - offset += a.Attestation_2.SizeSSZ() - // Field (0) 'Attestation_1' - if dst, err = a.Attestation_1.MarshalSSZTo(dst); err != nil { - return + // Field 2: ParentRoot + if len(c.ParentRoot) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.ParentRoot...) - // Field (1) 'Attestation_2' - if dst, err = a.Attestation_2.MarshalSSZTo(dst); err != nil { - return + // Field 3: StateRoot + if len(c.StateRoot) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.StateRoot...) + + // Field 4: Body + if c.Body == nil { + c.Body = new(BlindedBeaconBlockBodyElectra) + } + dst = ssz.WriteOffset(dst, offset) + offset += c.Body.SizeSSZ() - return + // Field 4: Body + if dst, err = c.Body.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Body: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the AttesterSlashingElectra object -func (a *AttesterSlashingElectra) UnmarshalSSZ(buf []byte) error { +func (c *BlindedBeaconBlockElectra) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 8 { + if size < 84 { return ssz.ErrSize } - tail := buf - var o0, o1 uint64 + sszSlice0 := buf[0:8] // c.Slot + sszSlice1 := buf[8:16] // c.ProposerIndex + sszSlice2 := buf[16:48] // c.ParentRoot + sszSlice3 := buf[48:80] // c.StateRoot - // Offset (0) 'Attestation_1' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } - - if o0 != 8 { + sszVarOffset4 := ssz.ReadOffset(buf[80:84]) // c.Body + if sszVarOffset4 != 84 { return ssz.ErrInvalidVariableOffset } - - // Offset (1) 'Attestation_2' - if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 { + if sszVarOffset4 > size { return ssz.ErrOffset } + sszSlice4 := buf[sszVarOffset4:] // c.Body - // Field (0) 'Attestation_1' - { - buf = tail[o0:o1] - if a.Attestation_1 == nil { - a.Attestation_1 = new(IndexedAttestationElectra) - } - if err = a.Attestation_1.UnmarshalSSZ(buf); err != nil { - return err - } + // Field 0: Slot + if err = c.Slot.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Slot: %w", err) } - // Field (1) 'Attestation_2' - { - buf = tail[o1:] - if a.Attestation_2 == nil { - a.Attestation_2 = new(IndexedAttestationElectra) - } - if err = a.Attestation_2.UnmarshalSSZ(buf); err != nil { - return err - } + // Field 1: ProposerIndex + if err = c.ProposerIndex.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("ProposerIndex: %w", err) } - return err -} -// SizeSSZ returns the ssz encoded size in bytes for the AttesterSlashingElectra object -func (a *AttesterSlashingElectra) SizeSSZ() (size int) { - size = 8 + // Field 2: ParentRoot + c.ParentRoot = make([]byte, 0, 32) + c.ParentRoot = append(c.ParentRoot, sszSlice2...) - // Field (0) 'Attestation_1' - if a.Attestation_1 == nil { - a.Attestation_1 = new(IndexedAttestationElectra) - } - size += a.Attestation_1.SizeSSZ() + // Field 3: StateRoot + c.StateRoot = make([]byte, 0, 32) + c.StateRoot = append(c.StateRoot, sszSlice3...) - // Field (1) 'Attestation_2' - if a.Attestation_2 == nil { - a.Attestation_2 = new(IndexedAttestationElectra) + // Field 4: Body + c.Body = new(BlindedBeaconBlockBodyElectra) + if err = c.Body.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("Body: %w", err) } - size += a.Attestation_2.SizeSSZ() - - return + return err } -// HashTreeRoot ssz hashes the AttesterSlashingElectra object -func (a *AttesterSlashingElectra) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(a) +func (c *BlindedBeaconBlockElectra) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the AttesterSlashingElectra object with a hasher -func (a *AttesterSlashingElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *BlindedBeaconBlockElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Attestation_1' - if err = a.Attestation_1.HashTreeRootWith(hh); err != nil { - return + // Field 0: Slot + if err := c.Slot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Slot: %w", err) } - - // Field (1) 'Attestation_2' - if err = a.Attestation_2.HashTreeRootWith(hh); err != nil { - return + // Field 1: ProposerIndex + if err := c.ProposerIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ProposerIndex: %w", err) + } + // Field 2: ParentRoot + if len(c.ParentRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ParentRoot) + // Field 3: StateRoot + if len(c.StateRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.StateRoot) + // Field 4: Body + if err := c.Body.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Body: %w", err) } - hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the IndexedAttestationElectra object -func (i *IndexedAttestationElectra) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(i) +func (c *BuilderBidElectra) SizeSSZ() int { + size := 92 + if c.Header == nil { + c.Header = new(v1.ExecutionPayloadHeaderDeneb) + } + size += c.Header.SizeSSZ() + size += len(c.BlobKzgCommitments) * 48 + if c.ExecutionRequests == nil { + c.ExecutionRequests = new(v1.ExecutionRequests) + } + size += c.ExecutionRequests.SizeSSZ() + return size } -// MarshalSSZTo ssz marshals the IndexedAttestationElectra object to a target array -func (i *IndexedAttestationElectra) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(228) +func (c *BuilderBidElectra) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Offset (0) 'AttestingIndices' +func (c *BuilderBidElectra) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 92 + + // Field 0: Header + if c.Header == nil { + c.Header = new(v1.ExecutionPayloadHeaderDeneb) + } + dst = ssz.WriteOffset(dst, offset) + offset += c.Header.SizeSSZ() + + // Field 1: BlobKzgCommitments + dst = ssz.WriteOffset(dst, offset) + offset += len(c.BlobKzgCommitments) * 48 + + // Field 2: ExecutionRequests + if c.ExecutionRequests == nil { + c.ExecutionRequests = new(v1.ExecutionRequests) + } dst = ssz.WriteOffset(dst, offset) - offset += len(i.AttestingIndices) * 8 + offset += c.ExecutionRequests.SizeSSZ() - // Field (1) 'Data' - if i.Data == nil { - i.Data = new(AttestationData) + // Field 3: Value + if len(c.Value) != 32 { + return nil, ssz.ErrBytesLength } - if dst, err = i.Data.MarshalSSZTo(dst); err != nil { - return + dst = append(dst, c.Value...) + + // Field 4: Pubkey + if len(c.Pubkey) != 48 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.Pubkey...) - // Field (2) 'Signature' - if size := len(i.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 0: Header + if dst, err = c.Header.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Header: %w", err) } - dst = append(dst, i.Signature...) - // Field (0) 'AttestingIndices' - if size := len(i.AttestingIndices); size > 131072 { - err = ssz.ErrListTooBigFn("--.AttestingIndices", size, 131072) - return + // Field 1: BlobKzgCommitments + if len(c.BlobKzgCommitments) > 4096 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(i.AttestingIndices); ii++ { - dst = ssz.MarshalUint(dst, i.AttestingIndices[ii]) + for _, o := range c.BlobKzgCommitments { + if len(o) != 48 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) } - return + // Field 2: ExecutionRequests + if dst, err = c.ExecutionRequests.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ExecutionRequests: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the IndexedAttestationElectra object -func (i *IndexedAttestationElectra) UnmarshalSSZ(buf []byte) error { +func (c *BuilderBidElectra) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 228 { + if size < 92 { return ssz.ErrSize } - tail := buf - var o0 uint64 + sszSlice3 := buf[12:44] // c.Value + sszSlice4 := buf[44:92] // c.Pubkey - // Offset (0) 'AttestingIndices' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } - - if o0 != 228 { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Header + if sszVarOffset0 != 92 { return ssz.ErrInvalidVariableOffset } - - // Field (1) 'Data' - if i.Data == nil { - i.Data = new(AttestationData) + if sszVarOffset0 > size { + return ssz.ErrOffset } - if err = i.Data.UnmarshalSSZ(buf[4:132]); err != nil { - return err + sszVarOffset1 := ssz.ReadOffset(buf[4:8]) // c.BlobKzgCommitments + if sszVarOffset1 > size || sszVarOffset1 < sszVarOffset0 { + return ssz.ErrOffset } + sszVarOffset2 := ssz.ReadOffset(buf[8:12]) // c.ExecutionRequests + if sszVarOffset2 > size || sszVarOffset2 < sszVarOffset1 { + return ssz.ErrOffset + } + sszSlice0 := buf[sszVarOffset0:sszVarOffset1] // c.Header + sszSlice1 := buf[sszVarOffset1:sszVarOffset2] // c.BlobKzgCommitments + sszSlice2 := buf[sszVarOffset2:] // c.ExecutionRequests - // Field (2) 'Signature' - if cap(i.Signature) == 0 { - i.Signature = make([]byte, 0, len(buf[132:228])) + // Field 0: Header + c.Header = new(v1.ExecutionPayloadHeaderDeneb) + if err = c.Header.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Header: %w", err) } - i.Signature = append(i.Signature, buf[132:228]...) - // Field (0) 'AttestingIndices' + // Field 1: BlobKzgCommitments { - buf = tail[o0:] - num, err := ssz.DivideInt2(len(buf), 8, 131072) - if err != nil { - return err + if len(sszSlice1)%48 != 0 { + return fmt.Errorf("misaligned bytes: c.BlobKzgCommitments length is %d, which is not a multiple of 48: %w", len(sszSlice1), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice1) / 48 + if numElem > 4096 { + return fmt.Errorf("ssz-max exceeded: c.BlobKzgCommitments has %d elements, ssz-max is 4096: %w", numElem, ssz.ErrListTooBig) } - i.AttestingIndices = ssz.ExtendUint(i.AttestingIndices, num) - for ii := 0; ii < num; ii++ { - i.AttestingIndices[ii] = ssz.UnmarshallUint[uint64](buf[ii*8 : (ii+1)*8]) + c.BlobKzgCommitments = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte + + tmpSlice := sszSlice1[i*48 : (1+i)*48] + tmp = make([]byte, 0, 48) + tmp = append(tmp, tmpSlice...) + c.BlobKzgCommitments[i] = tmp } } - return err -} -// SizeSSZ returns the ssz encoded size in bytes for the IndexedAttestationElectra object -func (i *IndexedAttestationElectra) SizeSSZ() (size int) { - size = 228 + // Field 2: ExecutionRequests + c.ExecutionRequests = new(v1.ExecutionRequests) + if err = c.ExecutionRequests.UnmarshalSSZ(sszSlice2); err != nil { + return fmt.Errorf("ExecutionRequests: %w", err) + } - // Field (0) 'AttestingIndices' - size += len(i.AttestingIndices) * 8 + // Field 3: Value + c.Value = make([]byte, 0, 32) + c.Value = append(c.Value, sszSlice3...) - return + // Field 4: Pubkey + c.Pubkey = make([]byte, 0, 48) + c.Pubkey = append(c.Pubkey, sszSlice4...) + return err } -// HashTreeRoot ssz hashes the IndexedAttestationElectra object -func (i *IndexedAttestationElectra) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(i) +func (c *BuilderBidElectra) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the IndexedAttestationElectra object with a hasher -func (i *IndexedAttestationElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *BuilderBidElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'AttestingIndices' + // Field 0: Header + if err := c.Header.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Header: %w", err) + } + // Field 1: BlobKzgCommitments { - if size := len(i.AttestingIndices); size > 131072 { - err = ssz.ErrListTooBigFn("--.AttestingIndices", size, 131072) - return + if len(c.BlobKzgCommitments) > 4096 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range i.AttestingIndices { - ssz.AppendUint(hh, i) + for _, o := range c.BlobKzgCommitments { + if len(o) != 48 { + return ssz.ErrBytesLength + } + hh.PutBytes(o) } - hh.FillUpTo32() - - numItems := uint64(len(i.AttestingIndices)) - hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(131072, numItems, 8)) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.BlobKzgCommitments)), 4096) } - - // Field (1) 'Data' - if err = i.Data.HashTreeRootWith(hh); err != nil { - return + // Field 2: ExecutionRequests + if err := c.ExecutionRequests.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ExecutionRequests: %w", err) } - - // Field (2) 'Signature' - if size := len(i.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 3: Value + if len(c.Value) != 32 { + return ssz.ErrBytesLength } - hh.PutBytes(i.Signature) - + hh.PutBytes(c.Value) + // Field 4: Pubkey + if len(c.Pubkey) != 48 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Pubkey) hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the BeaconStateElectra object -func (b *BeaconStateElectra) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) +func (c *IndexedAttestationElectra) SizeSSZ() int { + size := 228 + size += len(c.AttestingIndices) * 8 + return size } -// MarshalSSZTo ssz marshals the BeaconStateElectra object to a target array -func (b *BeaconStateElectra) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(2736713) - - // Field (0) 'GenesisTime' - dst = ssz.MarshalUint(dst, b.GenesisTime) +func (c *IndexedAttestationElectra) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (1) 'GenesisValidatorsRoot' - if size := len(b.GenesisValidatorsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.GenesisValidatorsRoot", size, 32) - return - } - dst = append(dst, b.GenesisValidatorsRoot...) +func (c *IndexedAttestationElectra) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 228 - // Field (2) 'Slot' - dst = ssz.MarshalUint(dst, b.Slot) + // Field 0: AttestingIndices + dst = ssz.WriteOffset(dst, offset) + offset += len(c.AttestingIndices) * 8 - // Field (3) 'Fork' - if b.Fork == nil { - b.Fork = new(Fork) + // Field 1: Data + if c.Data == nil { + c.Data = new(AttestationData) } - if dst, err = b.Fork.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.Data.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Data: %w", err) } - // Field (4) 'LatestBlockHeader' - if b.LatestBlockHeader == nil { - b.LatestBlockHeader = new(BeaconBlockHeader) - } - if dst, err = b.LatestBlockHeader.MarshalSSZTo(dst); err != nil { - return + // Field 2: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.Signature...) - // Field (5) 'BlockRoots' - if size := len(b.BlockRoots); size != 8192 { - err = ssz.ErrVectorLengthFn("--.BlockRoots", size, 8192) - return + // Field 0: AttestingIndices + if len(c.AttestingIndices) > 131072 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < 8192; ii++ { - if size := len(b.BlockRoots[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockRoots[ii]", size, 32) - return - } - dst = append(dst, b.BlockRoots[ii]...) + for _, o := range c.AttestingIndices { + dst = binary.LittleEndian.AppendUint64(dst, o) } + return dst, err +} - // Field (6) 'StateRoots' - if size := len(b.StateRoots); size != 8192 { - err = ssz.ErrVectorLengthFn("--.StateRoots", size, 8192) - return - } - for ii := 0; ii < 8192; ii++ { - if size := len(b.StateRoots[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoots[ii]", size, 32) - return - } - dst = append(dst, b.StateRoots[ii]...) +func (c *IndexedAttestationElectra) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 228 { + return ssz.ErrSize } - // Offset (7) 'HistoricalRoots' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.HistoricalRoots) * 32 + sszSlice1 := buf[4:132] // c.Data + sszSlice2 := buf[132:228] // c.Signature - // Field (8) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(Eth1Data) + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.AttestingIndices + if sszVarOffset0 != 228 { + return ssz.ErrInvalidVariableOffset } - if dst, err = b.Eth1Data.MarshalSSZTo(dst); err != nil { - return + if sszVarOffset0 > size { + return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:] // c.AttestingIndices - // Offset (9) 'Eth1DataVotes' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.Eth1DataVotes) * 72 - - // Field (10) 'Eth1DepositIndex' - dst = ssz.MarshalUint(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 0: AttestingIndices + { + if len(sszSlice0)%8 != 0 { + return fmt.Errorf("misaligned bytes: c.AttestingIndices length is %d, which is not a multiple of 8: %w", len(sszSlice0), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice0) / 8 + if numElem > 131072 { + return fmt.Errorf("ssz-max exceeded: c.AttestingIndices has %d elements, ssz-max is 131072: %w", numElem, ssz.ErrListTooBig) + } + c.AttestingIndices = make([]uint64, numElem) + for i := 0; i < numElem; i++ { + var tmp uint64 - // Field (13) 'RandaoMixes' - if size := len(b.RandaoMixes); size != 65536 { - err = ssz.ErrVectorLengthFn("--.RandaoMixes", size, 65536) - return - } - for ii := 0; ii < 65536; ii++ { - if size := len(b.RandaoMixes[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.RandaoMixes[ii]", size, 32) - return + tmpSlice := sszSlice0[i*8 : (1+i)*8] + tmp = binary.LittleEndian.Uint64(tmpSlice) + c.AttestingIndices[i] = tmp } - dst = append(dst, b.RandaoMixes[ii]...) } - // Field (14) 'Slashings' - if size := len(b.Slashings); size != 8192 { - err = ssz.ErrVectorLengthFn("--.Slashings", size, 8192) - return + // Field 1: Data + c.Data = new(AttestationData) + if err = c.Data.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Data: %w", err) } - for ii := 0; ii < 8192; ii++ { - dst = ssz.MarshalUint(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 2: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice2...) + return err +} - // Field (17) 'JustificationBits' - if size := len(b.JustificationBits); size != 1 { - err = ssz.ErrBytesLengthFn("--.JustificationBits", size, 1) - return +func (c *IndexedAttestationElectra) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - dst = append(dst, b.JustificationBits...) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (18) 'PreviousJustifiedCheckpoint' - if b.PreviousJustifiedCheckpoint == nil { - b.PreviousJustifiedCheckpoint = new(Checkpoint) - } - if dst, err = b.PreviousJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { - return +func (c *IndexedAttestationElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: AttestingIndices + { + if len(c.AttestingIndices) > 131072 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.AttestingIndices { + hh.AppendUint64(o) + } + hh.FillUpTo32() + numItems := uint64(len(c.AttestingIndices)) + hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(131072, numItems, 8)) } - - // Field (19) 'CurrentJustifiedCheckpoint' - if b.CurrentJustifiedCheckpoint == nil { - b.CurrentJustifiedCheckpoint = new(Checkpoint) + // Field 1: Data + if err := c.Data.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Data: %w", err) } - if dst, err = b.CurrentJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { - return + // Field 2: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength } + hh.PutBytes(c.Signature) + hh.Merkleize(indx) + return nil +} - // Field (20) 'FinalizedCheckpoint' - if b.FinalizedCheckpoint == nil { - b.FinalizedCheckpoint = new(Checkpoint) +func (c *LightClientBootstrapElectra) SizeSSZ() int { + size := 24820 + if c.Header == nil { + c.Header = new(LightClientHeaderDeneb) } - if dst, err = b.FinalizedCheckpoint.MarshalSSZTo(dst); err != nil { - return - } - - // Offset (21) 'InactivityScores' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.InactivityScores) * 8 + size += c.Header.SizeSSZ() + return size +} - // Field (22) 'CurrentSyncCommittee' - if b.CurrentSyncCommittee == nil { - b.CurrentSyncCommittee = new(SyncCommittee) - } - if dst, err = b.CurrentSyncCommittee.MarshalSSZTo(dst); err != nil { - return - } +func (c *LightClientBootstrapElectra) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (23) 'NextSyncCommittee' - if b.NextSyncCommittee == nil { - b.NextSyncCommittee = new(SyncCommittee) - } - if dst, err = b.NextSyncCommittee.MarshalSSZTo(dst); err != nil { - return - } +func (c *LightClientBootstrapElectra) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 24820 - // Offset (24) 'LatestExecutionPayloadHeader' - dst = ssz.WriteOffset(dst, offset) - if b.LatestExecutionPayloadHeader == nil { - b.LatestExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderDeneb) + // Field 0: Header + if c.Header == nil { + c.Header = new(LightClientHeaderDeneb) } - offset += b.LatestExecutionPayloadHeader.SizeSSZ() - - // Field (25) 'NextWithdrawalIndex' - dst = ssz.MarshalUint(dst, b.NextWithdrawalIndex) - - // Field (26) 'NextWithdrawalValidatorIndex' - dst = ssz.MarshalUint(dst, b.NextWithdrawalValidatorIndex) - - // Offset (27) 'HistoricalSummaries' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.HistoricalSummaries) * 64 - - // Field (28) 'DepositRequestsStartIndex' - dst = ssz.MarshalUint(dst, b.DepositRequestsStartIndex) - - // Field (29) 'DepositBalanceToConsume' - dst = ssz.MarshalUint(dst, b.DepositBalanceToConsume) - - // Field (30) 'ExitBalanceToConsume' - dst = ssz.MarshalUint(dst, b.ExitBalanceToConsume) - - // Field (31) 'EarliestExitEpoch' - dst = ssz.MarshalUint(dst, b.EarliestExitEpoch) - - // Field (32) 'ConsolidationBalanceToConsume' - dst = ssz.MarshalUint(dst, b.ConsolidationBalanceToConsume) - - // Field (33) 'EarliestConsolidationEpoch' - dst = ssz.MarshalUint(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 += c.Header.SizeSSZ() - // Offset (36) 'PendingConsolidations' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.PendingConsolidations) * 16 - - // Field (7) 'HistoricalRoots' - if size := len(b.HistoricalRoots); size > 16777216 { - err = ssz.ErrListTooBigFn("--.HistoricalRoots", size, 16777216) - return + // Field 1: CurrentSyncCommittee + if c.CurrentSyncCommittee == nil { + c.CurrentSyncCommittee = new(SyncCommittee) } - for ii := 0; ii < len(b.HistoricalRoots); ii++ { - if size := len(b.HistoricalRoots[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.HistoricalRoots[ii]", size, 32) - return - } - dst = append(dst, b.HistoricalRoots[ii]...) + if dst, err = c.CurrentSyncCommittee.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("CurrentSyncCommittee: %w", err) } - // Field (9) 'Eth1DataVotes' - if size := len(b.Eth1DataVotes); size > 2048 { - err = ssz.ErrListTooBigFn("--.Eth1DataVotes", size, 2048) - return + // Field 2: CurrentSyncCommitteeBranch + if len(c.CurrentSyncCommitteeBranch) != 6 { + return nil, ssz.ErrBytesLength } - for ii := 0; ii < len(b.Eth1DataVotes); ii++ { - if dst, err = b.Eth1DataVotes[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.CurrentSyncCommitteeBranch { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, o...) } - // Field (11) 'Validators' - if size := len(b.Validators); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.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("--.Balances", size, 1099511627776) - return - } - for ii := 0; ii < len(b.Balances); ii++ { - dst = ssz.MarshalUint(dst, b.Balances[ii]) + // Field 0: Header + if dst, err = c.Header.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Header: %w", err) } + return dst, err +} - // Field (15) 'PreviousEpochParticipation' - if size := len(b.PreviousEpochParticipation); size > 1099511627776 { - err = ssz.ErrBytesLengthFn("--.PreviousEpochParticipation", size, 1099511627776) - return +func (c *LightClientBootstrapElectra) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 24820 { + return ssz.ErrSize } - dst = append(dst, b.PreviousEpochParticipation...) - // Field (16) 'CurrentEpochParticipation' - if size := len(b.CurrentEpochParticipation); size > 1099511627776 { - err = ssz.ErrBytesLengthFn("--.CurrentEpochParticipation", size, 1099511627776) - return - } - dst = append(dst, b.CurrentEpochParticipation...) + sszSlice1 := buf[4:24628] // c.CurrentSyncCommittee + sszSlice2 := buf[24628:24820] // c.CurrentSyncCommitteeBranch - // Field (21) 'InactivityScores' - if size := len(b.InactivityScores); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.InactivityScores", size, 1099511627776) - return + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Header + if sszVarOffset0 != 24820 { + return ssz.ErrInvalidVariableOffset } - for ii := 0; ii < len(b.InactivityScores); ii++ { - dst = ssz.MarshalUint(dst, b.InactivityScores[ii]) + if sszVarOffset0 > size { + return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:] // c.Header - // Field (24) 'LatestExecutionPayloadHeader' - if dst, err = b.LatestExecutionPayloadHeader.MarshalSSZTo(dst); err != nil { - return + // Field 0: Header + c.Header = new(LightClientHeaderDeneb) + if err = c.Header.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Header: %w", err) } - // Field (27) 'HistoricalSummaries' - if size := len(b.HistoricalSummaries); size > 16777216 { - err = ssz.ErrListTooBigFn("--.HistoricalSummaries", size, 16777216) - return + // Field 1: CurrentSyncCommittee + c.CurrentSyncCommittee = new(SyncCommittee) + if err = c.CurrentSyncCommittee.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("CurrentSyncCommittee: %w", err) } - for ii := 0; ii < len(b.HistoricalSummaries); ii++ { - if dst, err = b.HistoricalSummaries[ii].MarshalSSZTo(dst); err != nil { - return + + // Field 2: CurrentSyncCommitteeBranch + { + c.CurrentSyncCommitteeBranch = make([][]byte, 6) + for i := 0; i < 6; i++ { + var tmp []byte + + tmpSlice := sszSlice2[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.CurrentSyncCommitteeBranch[i] = tmp } } + return err +} - // Field (34) 'PendingDeposits' - if size := len(b.PendingDeposits); size > 134217728 { - err = ssz.ErrListTooBigFn("--.PendingDeposits", size, 134217728) - return - } - for ii := 0; ii < len(b.PendingDeposits); ii++ { - if dst, err = b.PendingDeposits[ii].MarshalSSZTo(dst); err != nil { - return - } +func (c *LightClientBootstrapElectra) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (35) 'PendingPartialWithdrawals' - if size := len(b.PendingPartialWithdrawals); size > 134217728 { - err = ssz.ErrListTooBigFn("--.PendingPartialWithdrawals", size, 134217728) - return +func (c *LightClientBootstrapElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Header + if err := c.Header.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Header: %w", err) + } + // Field 1: CurrentSyncCommittee + if err := c.CurrentSyncCommittee.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("CurrentSyncCommittee: %w", err) } - for ii := 0; ii < len(b.PendingPartialWithdrawals); ii++ { - if dst, err = b.PendingPartialWithdrawals[ii].MarshalSSZTo(dst); err != nil { - return + // Field 2: CurrentSyncCommitteeBranch + { + if len(c.CurrentSyncCommitteeBranch) != 6 { + return ssz.ErrVectorLength + } + subIndx := hh.Index() + for _, o := range c.CurrentSyncCommitteeBranch { + if len(o) != 32 { + return ssz.ErrBytesLength + } + hh.Append(o) } + hh.Merkleize(subIndx) } + hh.Merkleize(indx) + return nil +} - // Field (36) 'PendingConsolidations' - if size := len(b.PendingConsolidations); size > 262144 { - err = ssz.ErrListTooBigFn("--.PendingConsolidations", size, 262144) - return +func (c *LightClientUpdateElectra) SizeSSZ() int { + size := 25216 + if c.AttestedHeader == nil { + c.AttestedHeader = new(LightClientHeaderDeneb) } - for ii := 0; ii < len(b.PendingConsolidations); ii++ { - if dst, err = b.PendingConsolidations[ii].MarshalSSZTo(dst); err != nil { - return - } + size += c.AttestedHeader.SizeSSZ() + if c.FinalizedHeader == nil { + c.FinalizedHeader = new(LightClientHeaderDeneb) } + size += c.FinalizedHeader.SizeSSZ() + return size +} - return +func (c *LightClientUpdateElectra) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// UnmarshalSSZ ssz unmarshals the BeaconStateElectra object -func (b *BeaconStateElectra) UnmarshalSSZ(buf []byte) error { +func (c *LightClientUpdateElectra) MarshalSSZTo(dst []byte) ([]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 + offset := 25216 - // Field (0) 'GenesisTime' - b.GenesisTime = ssz.UnmarshallUint[uint64](buf[0:8]) - - // Field (1) 'GenesisValidatorsRoot' - if cap(b.GenesisValidatorsRoot) == 0 { - b.GenesisValidatorsRoot = make([]byte, 0, len(buf[8:40])) + // Field 0: AttestedHeader + if c.AttestedHeader == nil { + c.AttestedHeader = new(LightClientHeaderDeneb) } - b.GenesisValidatorsRoot = append(b.GenesisValidatorsRoot, buf[8:40]...) - - // Field (2) 'Slot' - b.Slot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[40:48]) + dst = ssz.WriteOffset(dst, offset) + offset += c.AttestedHeader.SizeSSZ() - // Field (3) 'Fork' - if b.Fork == nil { - b.Fork = new(Fork) + // Field 1: NextSyncCommittee + if c.NextSyncCommittee == nil { + c.NextSyncCommittee = new(SyncCommittee) } - if err = b.Fork.UnmarshalSSZ(buf[48:64]); err != nil { - return err + if dst, err = c.NextSyncCommittee.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("NextSyncCommittee: %w", err) } - // Field (4) 'LatestBlockHeader' - if b.LatestBlockHeader == nil { - b.LatestBlockHeader = new(BeaconBlockHeader) + // Field 2: NextSyncCommitteeBranch + if len(c.NextSyncCommitteeBranch) != 6 { + return nil, ssz.ErrBytesLength } - if err = b.LatestBlockHeader.UnmarshalSSZ(buf[64:176]); err != nil { - return err - } - - // Field (5) 'BlockRoots' - b.BlockRoots = make([][]byte, 8192) - for ii := 0; ii < 8192; ii++ { - if cap(b.BlockRoots[ii]) == 0 { - b.BlockRoots[ii] = make([]byte, 0, len(buf[176:262320][ii*32:(ii+1)*32])) + for _, o := range c.NextSyncCommitteeBranch { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } - b.BlockRoots[ii] = append(b.BlockRoots[ii], buf[176:262320][ii*32:(ii+1)*32]...) + dst = append(dst, o...) } - // Field (6) 'StateRoots' - b.StateRoots = make([][]byte, 8192) - for ii := 0; ii < 8192; ii++ { - if cap(b.StateRoots[ii]) == 0 { - b.StateRoots[ii] = make([]byte, 0, len(buf[262320:524464][ii*32:(ii+1)*32])) - } - b.StateRoots[ii] = append(b.StateRoots[ii], buf[262320:524464][ii*32:(ii+1)*32]...) + // Field 3: FinalizedHeader + if c.FinalizedHeader == nil { + c.FinalizedHeader = new(LightClientHeaderDeneb) } + dst = ssz.WriteOffset(dst, offset) + offset += c.FinalizedHeader.SizeSSZ() - // Offset (7) 'HistoricalRoots' - if o7 = ssz.ReadOffset(buf[524464:524468]); o7 > size { - return ssz.ErrOffset + // Field 4: FinalityBranch + if len(c.FinalityBranch) != 7 { + return nil, ssz.ErrBytesLength } - - if o7 != 2736713 { - return ssz.ErrInvalidVariableOffset + for _, o := range c.FinalityBranch { + if len(o) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) } - // Field (8) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(Eth1Data) + // Field 5: SyncAggregate + if c.SyncAggregate == nil { + c.SyncAggregate = new(SyncAggregate) } - if err = b.Eth1Data.UnmarshalSSZ(buf[524468:524540]); err != nil { - return err + if dst, err = c.SyncAggregate.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SyncAggregate: %w", err) } - // Offset (9) 'Eth1DataVotes' - if o9 = ssz.ReadOffset(buf[524540:524544]); o9 > size || o7 > o9 { - return ssz.ErrOffset + // Field 6: SignatureSlot + if dst, err = c.SignatureSlot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SignatureSlot: %w", err) } - // Field (10) 'Eth1DepositIndex' - b.Eth1DepositIndex = ssz.UnmarshallUint[uint64](buf[524544:524552]) - - // Offset (11) 'Validators' - if o11 = ssz.ReadOffset(buf[524552:524556]); o11 > size || o9 > o11 { - return ssz.ErrOffset + // Field 0: AttestedHeader + if dst, err = c.AttestedHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("AttestedHeader: %w", err) } - // Offset (12) 'Balances' - if o12 = ssz.ReadOffset(buf[524556:524560]); o12 > size || o11 > o12 { - return ssz.ErrOffset + // Field 3: FinalizedHeader + if dst, err = c.FinalizedHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("FinalizedHeader: %w", err) } + return dst, err +} - // 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]...) +func (c *LightClientUpdateElectra) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 25216 { + return ssz.ErrSize } - // Field (14) 'Slashings' - b.Slashings = ssz.ExtendUint(b.Slashings, 8192) - for ii := 0; ii < 8192; ii++ { - b.Slashings[ii] = ssz.UnmarshallUint[uint64](buf[2621712:2687248][ii*8 : (ii+1)*8]) - } + sszSlice1 := buf[4:24628] // c.NextSyncCommittee + sszSlice2 := buf[24628:24820] // c.NextSyncCommitteeBranch + sszSlice4 := buf[24824:25048] // c.FinalityBranch + sszSlice5 := buf[25048:25208] // c.SyncAggregate + sszSlice6 := buf[25208:25216] // c.SignatureSlot - // Offset (15) 'PreviousEpochParticipation' - if o15 = ssz.ReadOffset(buf[2687248:2687252]); o15 > size || o12 > o15 { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.AttestedHeader + if sszVarOffset0 != 25216 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset0 > size { return ssz.ErrOffset } - - // Offset (16) 'CurrentEpochParticipation' - if o16 = ssz.ReadOffset(buf[2687252:2687256]); o16 > size || o15 > o16 { + sszVarOffset3 := ssz.ReadOffset(buf[24820:24824]) // c.FinalizedHeader + if sszVarOffset3 > size || sszVarOffset3 < sszVarOffset0 { return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:sszVarOffset3] // c.AttestedHeader + sszSlice3 := buf[sszVarOffset3:] // c.FinalizedHeader - // Field (17) 'JustificationBits' - if cap(b.JustificationBits) == 0 { - b.JustificationBits = make([]byte, 0, len(buf[2687256:2687257])) + // Field 0: AttestedHeader + c.AttestedHeader = new(LightClientHeaderDeneb) + if err = c.AttestedHeader.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("AttestedHeader: %w", err) } - b.JustificationBits = append(b.JustificationBits, buf[2687256:2687257]...) - // Field (18) 'PreviousJustifiedCheckpoint' - if b.PreviousJustifiedCheckpoint == nil { - b.PreviousJustifiedCheckpoint = new(Checkpoint) - } - if err = b.PreviousJustifiedCheckpoint.UnmarshalSSZ(buf[2687257:2687297]); err != nil { - return err + // Field 1: NextSyncCommittee + c.NextSyncCommittee = new(SyncCommittee) + if err = c.NextSyncCommittee.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("NextSyncCommittee: %w", err) } - // Field (19) 'CurrentJustifiedCheckpoint' - if b.CurrentJustifiedCheckpoint == nil { - b.CurrentJustifiedCheckpoint = new(Checkpoint) - } - if err = b.CurrentJustifiedCheckpoint.UnmarshalSSZ(buf[2687297:2687337]); err != nil { - return err - } + // Field 2: NextSyncCommitteeBranch + { + c.NextSyncCommitteeBranch = make([][]byte, 6) + for i := 0; i < 6; i++ { + var tmp []byte - // Field (20) 'FinalizedCheckpoint' - if b.FinalizedCheckpoint == nil { - b.FinalizedCheckpoint = new(Checkpoint) - } - if err = b.FinalizedCheckpoint.UnmarshalSSZ(buf[2687337:2687377]); err != nil { - return err + tmpSlice := sszSlice2[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.NextSyncCommitteeBranch[i] = tmp + } } - // Offset (21) 'InactivityScores' - if o21 = ssz.ReadOffset(buf[2687377:2687381]); o21 > size || o16 > o21 { - return ssz.ErrOffset + // Field 3: FinalizedHeader + c.FinalizedHeader = new(LightClientHeaderDeneb) + if err = c.FinalizedHeader.UnmarshalSSZ(sszSlice3); err != nil { + return fmt.Errorf("FinalizedHeader: %w", err) } - // Field (22) 'CurrentSyncCommittee' - if b.CurrentSyncCommittee == nil { - b.CurrentSyncCommittee = new(SyncCommittee) - } - if err = b.CurrentSyncCommittee.UnmarshalSSZ(buf[2687381:2712005]); err != nil { - return err - } + // Field 4: FinalityBranch + { + c.FinalityBranch = make([][]byte, 7) + for i := 0; i < 7; i++ { + var tmp []byte - // Field (23) 'NextSyncCommittee' - if b.NextSyncCommittee == nil { - b.NextSyncCommittee = new(SyncCommittee) - } - if err = b.NextSyncCommittee.UnmarshalSSZ(buf[2712005:2736629]); err != nil { - return err + tmpSlice := sszSlice4[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.FinalityBranch[i] = tmp + } } - // Offset (24) 'LatestExecutionPayloadHeader' - if o24 = ssz.ReadOffset(buf[2736629:2736633]); o24 > size || o21 > o24 { - return ssz.ErrOffset + // Field 5: SyncAggregate + c.SyncAggregate = new(SyncAggregate) + if err = c.SyncAggregate.UnmarshalSSZ(sszSlice5); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) } - // Field (25) 'NextWithdrawalIndex' - b.NextWithdrawalIndex = ssz.UnmarshallUint[uint64](buf[2736633:2736641]) - - // Field (26) 'NextWithdrawalValidatorIndex' - b.NextWithdrawalValidatorIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[2736641:2736649]) - - // Offset (27) 'HistoricalSummaries' - if o27 = ssz.ReadOffset(buf[2736649:2736653]); o27 > size || o24 > o27 { - return ssz.ErrOffset + // Field 6: SignatureSlot + if err = c.SignatureSlot.UnmarshalSSZ(sszSlice6); err != nil { + return fmt.Errorf("SignatureSlot: %w", err) } + return err +} - // Field (28) 'DepositRequestsStartIndex' - b.DepositRequestsStartIndex = ssz.UnmarshallUint[uint64](buf[2736653:2736661]) - - // Field (29) 'DepositBalanceToConsume' - b.DepositBalanceToConsume = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Gwei](buf[2736661:2736669]) - - // Field (30) 'ExitBalanceToConsume' - b.ExitBalanceToConsume = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Gwei](buf[2736669:2736677]) - - // Field (31) 'EarliestExitEpoch' - b.EarliestExitEpoch = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Epoch](buf[2736677:2736685]) - - // Field (32) 'ConsolidationBalanceToConsume' - b.ConsolidationBalanceToConsume = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Gwei](buf[2736685:2736693]) - - // Field (33) 'EarliestConsolidationEpoch' - b.EarliestConsolidationEpoch = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Epoch](buf[2736693:2736701]) - - // Offset (34) 'PendingDeposits' - if o34 = ssz.ReadOffset(buf[2736701:2736705]); o34 > size || o27 > o34 { - return ssz.ErrOffset +func (c *LightClientUpdateElectra) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Offset (35) 'PendingPartialWithdrawals' - if o35 = ssz.ReadOffset(buf[2736705:2736709]); o35 > size || o34 > o35 { - return ssz.ErrOffset +func (c *LightClientUpdateElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: AttestedHeader + if err := c.AttestedHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("AttestedHeader: %w", err) } - - // Offset (36) 'PendingConsolidations' - if o36 = ssz.ReadOffset(buf[2736709:2736713]); o36 > size || o35 > o36 { - return ssz.ErrOffset + // Field 1: NextSyncCommittee + if err := c.NextSyncCommittee.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("NextSyncCommittee: %w", err) } - - // Field (7) 'HistoricalRoots' + // Field 2: NextSyncCommitteeBranch { - 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]...) + if len(c.NextSyncCommitteeBranch) != 6 { + return ssz.ErrVectorLength } - } - - // Field (9) 'Eth1DataVotes' - { - buf = tail[o9:o11] - num, err := ssz.DivideInt2(len(buf), 72, 2048) - if err != nil { - return err - } - b.Eth1DataVotes = make([]*Eth1Data, num) - for ii := 0; ii < num; ii++ { - if b.Eth1DataVotes[ii] == nil { - b.Eth1DataVotes[ii] = new(Eth1Data) - } - if err = b.Eth1DataVotes[ii].UnmarshalSSZ(buf[ii*72 : (ii+1)*72]); err != nil { - return err + subIndx := hh.Index() + for _, o := range c.NextSyncCommitteeBranch { + if len(o) != 32 { + return ssz.ErrBytesLength } + hh.Append(o) } + hh.Merkleize(subIndx) } - - // Field (11) 'Validators' - { - buf = tail[o11:o12] - num, err := ssz.DivideInt2(len(buf), 121, 1099511627776) - if err != nil { - return err - } - b.Validators = make([]*Validator, num) - for ii := 0; ii < num; ii++ { - if b.Validators[ii] == nil { - b.Validators[ii] = new(Validator) - } - if err = b.Validators[ii].UnmarshalSSZ(buf[ii*121 : (ii+1)*121]); err != nil { - return err - } - } + // Field 3: FinalizedHeader + if err := c.FinalizedHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("FinalizedHeader: %w", err) } - - // Field (12) 'Balances' + // Field 4: FinalityBranch { - buf = tail[o12:o15] - num, err := ssz.DivideInt2(len(buf), 8, 1099511627776) - if err != nil { - return err + if len(c.FinalityBranch) != 7 { + return ssz.ErrVectorLength } - b.Balances = ssz.ExtendUint(b.Balances, num) - for ii := 0; ii < num; ii++ { - b.Balances[ii] = ssz.UnmarshallUint[uint64](buf[ii*8 : (ii+1)*8]) + subIndx := hh.Index() + for _, o := range c.FinalityBranch { + if len(o) != 32 { + return ssz.ErrBytesLength + } + hh.Append(o) } + hh.Merkleize(subIndx) } - - // 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 5: SyncAggregate + if err := c.SyncAggregate.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) } - - // 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 6: SignatureSlot + if err := c.SignatureSlot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SignatureSlot: %w", err) } + hh.Merkleize(indx) + return nil +} - // Field (21) 'InactivityScores' - { - buf = tail[o21:o24] - num, err := ssz.DivideInt2(len(buf), 8, 1099511627776) - if err != nil { - return err - } - b.InactivityScores = ssz.ExtendUint(b.InactivityScores, num) - for ii := 0; ii < num; ii++ { - b.InactivityScores[ii] = ssz.UnmarshallUint[uint64](buf[ii*8 : (ii+1)*8]) - } +func (c *LightClientFinalityUpdateElectra) SizeSSZ() int { + size := 400 + if c.AttestedHeader == nil { + c.AttestedHeader = new(LightClientHeaderDeneb) } - - // Field (24) 'LatestExecutionPayloadHeader' - { - buf = tail[o24:o27] - if b.LatestExecutionPayloadHeader == nil { - b.LatestExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderDeneb) - } - if err = b.LatestExecutionPayloadHeader.UnmarshalSSZ(buf); err != nil { - return err - } + size += c.AttestedHeader.SizeSSZ() + if c.FinalizedHeader == nil { + c.FinalizedHeader = new(LightClientHeaderDeneb) } + size += c.FinalizedHeader.SizeSSZ() + return size +} - // Field (27) 'HistoricalSummaries' - { - buf = tail[o27:o34] - num, err := ssz.DivideInt2(len(buf), 64, 16777216) - if err != nil { - return err - } - b.HistoricalSummaries = make([]*HistoricalSummary, num) - for ii := 0; ii < num; ii++ { - if b.HistoricalSummaries[ii] == nil { - b.HistoricalSummaries[ii] = new(HistoricalSummary) - } - if err = b.HistoricalSummaries[ii].UnmarshalSSZ(buf[ii*64 : (ii+1)*64]); err != nil { - return err - } - } - } +func (c *LightClientFinalityUpdateElectra) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (34) 'PendingDeposits' - { - buf = tail[o34:o35] - num, err := ssz.DivideInt2(len(buf), 192, 134217728) - if err != nil { - return err - } - b.PendingDeposits = make([]*PendingDeposit, num) - for ii := 0; ii < num; ii++ { - if b.PendingDeposits[ii] == nil { - b.PendingDeposits[ii] = new(PendingDeposit) - } - if err = b.PendingDeposits[ii].UnmarshalSSZ(buf[ii*192 : (ii+1)*192]); err != nil { - return err - } - } +func (c *LightClientFinalityUpdateElectra) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 400 + + // Field 0: AttestedHeader + if c.AttestedHeader == nil { + c.AttestedHeader = new(LightClientHeaderDeneb) } + dst = ssz.WriteOffset(dst, offset) + offset += c.AttestedHeader.SizeSSZ() - // Field (35) 'PendingPartialWithdrawals' - { - buf = tail[o35:o36] - num, err := ssz.DivideInt2(len(buf), 24, 134217728) - if err != nil { - return err - } - b.PendingPartialWithdrawals = make([]*PendingPartialWithdrawal, num) - for ii := 0; ii < num; ii++ { - if b.PendingPartialWithdrawals[ii] == nil { - b.PendingPartialWithdrawals[ii] = new(PendingPartialWithdrawal) - } - if err = b.PendingPartialWithdrawals[ii].UnmarshalSSZ(buf[ii*24 : (ii+1)*24]); err != nil { - return err - } - } + // Field 1: FinalizedHeader + if c.FinalizedHeader == nil { + c.FinalizedHeader = new(LightClientHeaderDeneb) } + dst = ssz.WriteOffset(dst, offset) + offset += c.FinalizedHeader.SizeSSZ() - // Field (36) 'PendingConsolidations' - { - buf = tail[o36:] - num, err := ssz.DivideInt2(len(buf), 16, 262144) - if err != nil { - return err - } - b.PendingConsolidations = make([]*PendingConsolidation, num) - for ii := 0; ii < num; ii++ { - if b.PendingConsolidations[ii] == nil { - b.PendingConsolidations[ii] = new(PendingConsolidation) - } - if err = b.PendingConsolidations[ii].UnmarshalSSZ(buf[ii*16 : (ii+1)*16]); err != nil { - return err - } + // Field 2: FinalityBranch + if len(c.FinalityBranch) != 7 { + return nil, ssz.ErrBytesLength + } + for _, o := range c.FinalityBranch { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, o...) } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the BeaconStateElectra object -func (b *BeaconStateElectra) 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(v1.ExecutionPayloadHeaderDeneb) + // Field 3: SyncAggregate + if c.SyncAggregate == nil { + c.SyncAggregate = new(SyncAggregate) + } + if dst, err = c.SyncAggregate.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SyncAggregate: %w", err) } - 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 + // Field 4: SignatureSlot + if dst, err = c.SignatureSlot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SignatureSlot: %w", err) + } - return -} + // Field 0: AttestedHeader + if dst, err = c.AttestedHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("AttestedHeader: %w", err) + } -// HashTreeRoot ssz hashes the BeaconStateElectra object -func (b *BeaconStateElectra) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) + // Field 1: FinalizedHeader + if dst, err = c.FinalizedHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("FinalizedHeader: %w", err) + } + return dst, err } -// HashTreeRootWith ssz hashes the BeaconStateElectra object with a hasher -func (b *BeaconStateElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'GenesisTime' - ssz.PutUint(hh, b.GenesisTime) - - // Field (1) 'GenesisValidatorsRoot' - if size := len(b.GenesisValidatorsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.GenesisValidatorsRoot", size, 32) - return +func (c *LightClientFinalityUpdateElectra) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 400 { + return ssz.ErrSize } - hh.PutBytes(b.GenesisValidatorsRoot) - // Field (2) 'Slot' - ssz.PutUint(hh, b.Slot) + sszSlice2 := buf[8:232] // c.FinalityBranch + sszSlice3 := buf[232:392] // c.SyncAggregate + sszSlice4 := buf[392:400] // c.SignatureSlot - // Field (3) 'Fork' - if err = b.Fork.HashTreeRootWith(hh); err != nil { - return + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.AttestedHeader + if sszVarOffset0 != 400 { + return ssz.ErrInvalidVariableOffset } - - // Field (4) 'LatestBlockHeader' - if err = b.LatestBlockHeader.HashTreeRootWith(hh); err != nil { - return + if sszVarOffset0 > size { + return ssz.ErrOffset } + sszVarOffset1 := ssz.ReadOffset(buf[4:8]) // c.FinalizedHeader + if sszVarOffset1 > size || sszVarOffset1 < sszVarOffset0 { + return ssz.ErrOffset + } + sszSlice0 := buf[sszVarOffset0:sszVarOffset1] // c.AttestedHeader + sszSlice1 := buf[sszVarOffset1:] // c.FinalizedHeader - // Field (5) 'BlockRoots' - { - if size := len(b.BlockRoots); size != 8192 { - err = ssz.ErrVectorLengthFn("--.BlockRoots", size, 8192) - return - } - subIndx := hh.Index() - for _, i := range b.BlockRoots { - if len(i) != 32 { - err = ssz.ErrBytesLength - return - } - hh.Append(i) - } - hh.Merkleize(subIndx) + // Field 0: AttestedHeader + c.AttestedHeader = new(LightClientHeaderDeneb) + if err = c.AttestedHeader.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("AttestedHeader: %w", err) } - // Field (6) 'StateRoots' - { - if size := len(b.StateRoots); size != 8192 { - err = ssz.ErrVectorLengthFn("--.StateRoots", size, 8192) - return - } - subIndx := hh.Index() - for _, i := range b.StateRoots { - if len(i) != 32 { - err = ssz.ErrBytesLength - return - } - hh.Append(i) - } - hh.Merkleize(subIndx) + // Field 1: FinalizedHeader + c.FinalizedHeader = new(LightClientHeaderDeneb) + if err = c.FinalizedHeader.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("FinalizedHeader: %w", err) } - // Field (7) 'HistoricalRoots' + // Field 2: FinalityBranch { - if size := len(b.HistoricalRoots); size > 16777216 { - err = ssz.ErrListTooBigFn("--.HistoricalRoots", size, 16777216) - return - } - subIndx := hh.Index() - for _, i := range b.HistoricalRoots { - if len(i) != 32 { - err = ssz.ErrBytesLength - return - } - hh.Append(i) - } + c.FinalityBranch = make([][]byte, 7) + for i := 0; i < 7; i++ { + var tmp []byte - numItems := uint64(len(b.HistoricalRoots)) - hh.MerkleizeWithMixin(subIndx, numItems, 16777216) + tmpSlice := sszSlice2[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.FinalityBranch[i] = tmp + } } - // Field (8) 'Eth1Data' - if err = b.Eth1Data.HashTreeRootWith(hh); err != nil { - return + // Field 3: SyncAggregate + c.SyncAggregate = new(SyncAggregate) + if err = c.SyncAggregate.UnmarshalSSZ(sszSlice3); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) } - // 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 4: SignatureSlot + if err = c.SignatureSlot.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("SignatureSlot: %w", err) } + return err +} - // Field (10) 'Eth1DepositIndex' - ssz.PutUint(hh, 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) +func (c *LightClientFinalityUpdateElectra) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (12) 'Balances' - { - if size := len(b.Balances); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.Balances", size, 1099511627776) - return - } - subIndx := hh.Index() - for _, i := range b.Balances { - ssz.AppendUint(hh, i) - } - hh.FillUpTo32() - - numItems := uint64(len(b.Balances)) - hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(1099511627776, numItems, 8)) +func (c *LightClientFinalityUpdateElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: AttestedHeader + if err := c.AttestedHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("AttestedHeader: %w", err) } - - // Field (13) 'RandaoMixes' + // Field 1: FinalizedHeader + if err := c.FinalizedHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("FinalizedHeader: %w", err) + } + // Field 2: FinalityBranch { - if size := len(b.RandaoMixes); size != 65536 { - err = ssz.ErrVectorLengthFn("--.RandaoMixes", size, 65536) - return + if len(c.FinalityBranch) != 7 { + return ssz.ErrVectorLength } subIndx := hh.Index() - for _, i := range b.RandaoMixes { - if len(i) != 32 { - err = ssz.ErrBytesLength - return + for _, o := range c.FinalityBranch { + if len(o) != 32 { + return ssz.ErrBytesLength } - hh.Append(i) + hh.Append(o) } hh.Merkleize(subIndx) } - - // Field (14) 'Slashings' - { - if size := len(b.Slashings); size != 8192 { - err = ssz.ErrVectorLengthFn("--.Slashings", size, 8192) - return - } - subIndx := hh.Index() - for _, i := range b.Slashings { - ssz.AppendUint(hh, i) - } - hh.Merkleize(subIndx) + // Field 3: SyncAggregate + if err := c.SyncAggregate.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) } - - // Field (15) 'PreviousEpochParticipation' - { - elemIndx := hh.Index() - byteLen := uint64(len(b.PreviousEpochParticipation)) - if byteLen > 1099511627776 { - err = ssz.ErrIncorrectListSize - return - } - hh.AppendBytes32(b.PreviousEpochParticipation) - hh.MerkleizeWithMixin(elemIndx, byteLen, (1099511627776+31)/32) + // Field 4: SignatureSlot + if err := c.SignatureSlot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SignatureSlot: %w", err) } + hh.Merkleize(indx) + return nil +} - // Field (16) 'CurrentEpochParticipation' - { - elemIndx := hh.Index() - byteLen := uint64(len(b.CurrentEpochParticipation)) - if byteLen > 1099511627776 { - err = ssz.ErrIncorrectListSize - return - } - hh.AppendBytes32(b.CurrentEpochParticipation) - hh.MerkleizeWithMixin(elemIndx, byteLen, (1099511627776+31)/32) - } +func (c *PendingDeposit) SizeSSZ() int { + size := 192 - // Field (17) 'JustificationBits' - if size := len(b.JustificationBits); size != 1 { - err = ssz.ErrBytesLengthFn("--.JustificationBits", size, 1) - return - } - hh.PutBytes(b.JustificationBits) + return size +} - // Field (18) 'PreviousJustifiedCheckpoint' - if err = b.PreviousJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { - return - } +func (c *PendingDeposit) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (19) 'CurrentJustifiedCheckpoint' - if err = b.CurrentJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { - return - } +func (c *PendingDeposit) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (20) 'FinalizedCheckpoint' - if err = b.FinalizedCheckpoint.HashTreeRootWith(hh); err != nil { - return + // Field 0: PublicKey + if len(c.PublicKey) != 48 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.PublicKey...) - // Field (21) 'InactivityScores' - { - if size := len(b.InactivityScores); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.InactivityScores", size, 1099511627776) - return - } - subIndx := hh.Index() - for _, i := range b.InactivityScores { - ssz.AppendUint(hh, i) - } - hh.FillUpTo32() - - numItems := uint64(len(b.InactivityScores)) - hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(1099511627776, numItems, 8)) + // Field 1: WithdrawalCredentials + if len(c.WithdrawalCredentials) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.WithdrawalCredentials...) - // Field (22) 'CurrentSyncCommittee' - if err = b.CurrentSyncCommittee.HashTreeRootWith(hh); err != nil { - return - } + // Field 2: Amount + dst = binary.LittleEndian.AppendUint64(dst, c.Amount) - // Field (23) 'NextSyncCommittee' - if err = b.NextSyncCommittee.HashTreeRootWith(hh); err != nil { - return + // Field 3: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.Signature...) - // Field (24) 'LatestExecutionPayloadHeader' - if err = b.LatestExecutionPayloadHeader.HashTreeRootWith(hh); err != nil { - return + // Field 4: Slot + if dst, err = c.Slot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Slot: %w", err) } - // Field (25) 'NextWithdrawalIndex' - ssz.PutUint(hh, b.NextWithdrawalIndex) - - // Field (26) 'NextWithdrawalValidatorIndex' - ssz.PutUint(hh, b.NextWithdrawalValidatorIndex) + return dst, err +} - // 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) +func (c *PendingDeposit) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 192 { + return ssz.ErrSize } - // Field (28) 'DepositRequestsStartIndex' - ssz.PutUint(hh, b.DepositRequestsStartIndex) + sszSlice0 := buf[0:48] // c.PublicKey + sszSlice1 := buf[48:80] // c.WithdrawalCredentials + sszSlice2 := buf[80:88] // c.Amount + sszSlice3 := buf[88:184] // c.Signature + sszSlice4 := buf[184:192] // c.Slot - // Field (29) 'DepositBalanceToConsume' - ssz.PutUint(hh, b.DepositBalanceToConsume) + // Field 0: PublicKey + c.PublicKey = make([]byte, 0, 48) + c.PublicKey = append(c.PublicKey, sszSlice0...) - // Field (30) 'ExitBalanceToConsume' - ssz.PutUint(hh, b.ExitBalanceToConsume) + // Field 1: WithdrawalCredentials + c.WithdrawalCredentials = make([]byte, 0, 32) + c.WithdrawalCredentials = append(c.WithdrawalCredentials, sszSlice1...) - // Field (31) 'EarliestExitEpoch' - ssz.PutUint(hh, b.EarliestExitEpoch) + // Field 2: Amount + c.Amount = binary.LittleEndian.Uint64(sszSlice2) - // Field (32) 'ConsolidationBalanceToConsume' - ssz.PutUint(hh, b.ConsolidationBalanceToConsume) - - // Field (33) 'EarliestConsolidationEpoch' - ssz.PutUint(hh, 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 3: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice3...) - // 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 4: Slot + if err = c.Slot.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("Slot: %w", err) } - - // 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) + return err +} + +func (c *PendingDeposit) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} +func (c *PendingDeposit) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: PublicKey + if len(c.PublicKey) != 48 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.PublicKey) + // Field 1: WithdrawalCredentials + if len(c.WithdrawalCredentials) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.WithdrawalCredentials) + // Field 2: Amount + hh.PutUint64(c.Amount) + // Field 3: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Signature) + // Field 4: Slot + if err := c.Slot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Slot: %w", err) + } hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the PendingDeposit object -func (p *PendingDeposit) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(p) +func (c *PendingConsolidation) SizeSSZ() int { + size := 16 + + return size } -// MarshalSSZTo ssz marshals the PendingDeposit object to a target array -func (p *PendingDeposit) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *PendingConsolidation) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (0) 'PublicKey' - if size := len(p.PublicKey); size != 48 { - err = ssz.ErrBytesLengthFn("--.PublicKey", size, 48) - return - } - dst = append(dst, p.PublicKey...) +func (c *PendingConsolidation) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (1) 'WithdrawalCredentials' - if size := len(p.WithdrawalCredentials); size != 32 { - err = ssz.ErrBytesLengthFn("--.WithdrawalCredentials", size, 32) - return + // Field 0: SourceIndex + if dst, err = c.SourceIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SourceIndex: %w", err) } - dst = append(dst, p.WithdrawalCredentials...) - - // Field (2) 'Amount' - dst = ssz.MarshalUint(dst, p.Amount) - // Field (3) 'Signature' - if size := len(p.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 1: TargetIndex + if dst, err = c.TargetIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("TargetIndex: %w", err) } - dst = append(dst, p.Signature...) - // Field (4) 'Slot' - dst = ssz.MarshalUint(dst, p.Slot) - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the PendingDeposit object -func (p *PendingDeposit) UnmarshalSSZ(buf []byte) error { +func (c *PendingConsolidation) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 192 { + if size != 16 { return ssz.ErrSize } - // Field (0) 'PublicKey' - if cap(p.PublicKey) == 0 { - p.PublicKey = make([]byte, 0, len(buf[0:48])) - } - p.PublicKey = append(p.PublicKey, buf[0:48]...) + sszSlice0 := buf[0:8] // c.SourceIndex + sszSlice1 := buf[8:16] // c.TargetIndex - // Field (1) 'WithdrawalCredentials' - if cap(p.WithdrawalCredentials) == 0 { - p.WithdrawalCredentials = make([]byte, 0, len(buf[48:80])) + // Field 0: SourceIndex + if err = c.SourceIndex.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("SourceIndex: %w", err) } - p.WithdrawalCredentials = append(p.WithdrawalCredentials, buf[48:80]...) - // Field (2) 'Amount' - p.Amount = ssz.UnmarshallUint[uint64](buf[80:88]) - - // Field (3) 'Signature' - if cap(p.Signature) == 0 { - p.Signature = make([]byte, 0, len(buf[88:184])) + // Field 1: TargetIndex + if err = c.TargetIndex.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("TargetIndex: %w", err) } - p.Signature = append(p.Signature, buf[88:184]...) - - // Field (4) 'Slot' - p.Slot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](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) +func (c *PendingConsolidation) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the PendingDeposit object with a hasher -func (p *PendingDeposit) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *PendingConsolidation) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'PublicKey' - if size := len(p.PublicKey); size != 48 { - err = ssz.ErrBytesLengthFn("--.PublicKey", size, 48) - return - } - hh.PutBytes(p.PublicKey) - - // Field (1) 'WithdrawalCredentials' - if size := len(p.WithdrawalCredentials); size != 32 { - err = ssz.ErrBytesLengthFn("--.WithdrawalCredentials", size, 32) - return + // Field 0: SourceIndex + if err := c.SourceIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SourceIndex: %w", err) } - hh.PutBytes(p.WithdrawalCredentials) - - // Field (2) 'Amount' - ssz.PutUint(hh, p.Amount) - - // Field (3) 'Signature' - if size := len(p.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 1: TargetIndex + if err := c.TargetIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("TargetIndex: %w", err) } - hh.PutBytes(p.Signature) + hh.Merkleize(indx) + return nil +} - // Field (4) 'Slot' - ssz.PutUint(hh, p.Slot) +func (c *PendingPartialWithdrawal) SizeSSZ() int { + size := 24 - hh.Merkleize(indx) - return + return size } -// MarshalSSZ ssz marshals the PendingPartialWithdrawal object -func (p *PendingPartialWithdrawal) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(p) +func (c *PendingPartialWithdrawal) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the PendingPartialWithdrawal object to a target array -func (p *PendingPartialWithdrawal) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *PendingPartialWithdrawal) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (0) 'Index' - dst = ssz.MarshalUint(dst, p.Index) + // Field 0: Index + if dst, err = c.Index.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Index: %w", err) + } - // Field (1) 'Amount' - dst = ssz.MarshalUint(dst, p.Amount) + // Field 1: Amount + dst = binary.LittleEndian.AppendUint64(dst, c.Amount) - // Field (2) 'WithdrawableEpoch' - dst = ssz.MarshalUint(dst, p.WithdrawableEpoch) + // Field 2: WithdrawableEpoch + if dst, err = c.WithdrawableEpoch.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("WithdrawableEpoch: %w", err) + } - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the PendingPartialWithdrawal object -func (p *PendingPartialWithdrawal) UnmarshalSSZ(buf []byte) error { +func (c *PendingPartialWithdrawal) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size != 24 { return ssz.ErrSize } - // Field (0) 'Index' - p.Index = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[0:8]) + sszSlice0 := buf[0:8] // c.Index + sszSlice1 := buf[8:16] // c.Amount + sszSlice2 := buf[16:24] // c.WithdrawableEpoch - // Field (1) 'Amount' - p.Amount = ssz.UnmarshallUint[uint64](buf[8:16]) + // Field 0: Index + if err = c.Index.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Index: %w", err) + } - // Field (2) 'WithdrawableEpoch' - p.WithdrawableEpoch = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Epoch](buf[16:24]) + // Field 1: Amount + c.Amount = binary.LittleEndian.Uint64(sszSlice1) + // Field 2: WithdrawableEpoch + if err = c.WithdrawableEpoch.UnmarshalSSZ(sszSlice2); err != nil { + return fmt.Errorf("WithdrawableEpoch: %w", err) + } 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) +func (c *PendingPartialWithdrawal) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the PendingPartialWithdrawal object with a hasher -func (p *PendingPartialWithdrawal) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *PendingPartialWithdrawal) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Index' - ssz.PutUint(hh, p.Index) - - // Field (1) 'Amount' - ssz.PutUint(hh, p.Amount) - - // Field (2) 'WithdrawableEpoch' - ssz.PutUint(hh, p.WithdrawableEpoch) - + // Field 0: Index + if err := c.Index.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Index: %w", err) + } + // Field 1: Amount + hh.PutUint64(c.Amount) + // Field 2: WithdrawableEpoch + if err := c.WithdrawableEpoch.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("WithdrawableEpoch: %w", err) + } hh.Merkleize(indx) - return + return nil +} + +func (c *SignedAggregateAttestationAndProofElectra) SizeSSZ() int { + size := 100 + if c.Message == nil { + c.Message = new(AggregateAttestationAndProofElectra) + } + size += c.Message.SizeSSZ() + return size } -// MarshalSSZ ssz marshals the PendingConsolidation object -func (p *PendingConsolidation) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(p) +func (c *SignedAggregateAttestationAndProofElectra) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the PendingConsolidation object to a target array -func (p *PendingConsolidation) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *SignedAggregateAttestationAndProofElectra) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 100 - // Field (0) 'SourceIndex' - dst = ssz.MarshalUint(dst, p.SourceIndex) + // Field 0: Message + if c.Message == nil { + c.Message = new(AggregateAttestationAndProofElectra) + } + dst = ssz.WriteOffset(dst, offset) + offset += c.Message.SizeSSZ() - // Field (1) 'TargetIndex' - dst = ssz.MarshalUint(dst, p.TargetIndex) + // Field 1: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.Signature...) - return + // Field 0: Message + if dst, err = c.Message.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Message: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the PendingConsolidation object -func (p *PendingConsolidation) UnmarshalSSZ(buf []byte) error { +func (c *SignedAggregateAttestationAndProofElectra) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 16 { + if size < 100 { return ssz.ErrSize } - // Field (0) 'SourceIndex' - p.SourceIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[0:8]) + sszSlice1 := buf[4:100] // c.Signature + + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Message + if sszVarOffset0 != 100 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset0 > size { + return ssz.ErrOffset + } + sszSlice0 := buf[sszVarOffset0:] // c.Message - // Field (1) 'TargetIndex' - p.TargetIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[8:16]) + // Field 0: Message + c.Message = new(AggregateAttestationAndProofElectra) + if err = c.Message.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Message: %w", err) + } + // Field 1: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice1...) 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) +func (c *SignedAggregateAttestationAndProofElectra) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the PendingConsolidation object with a hasher -func (p *PendingConsolidation) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *SignedAggregateAttestationAndProofElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'SourceIndex' - ssz.PutUint(hh, p.SourceIndex) - - // Field (1) 'TargetIndex' - ssz.PutUint(hh, p.TargetIndex) - + // Field 0: Message + if err := c.Message.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Message: %w", err) + } + // Field 1: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Signature) hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the LightClientBootstrapElectra object -func (l *LightClientBootstrapElectra) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(l) +func (c *SignedBeaconBlockContentsElectra) SizeSSZ() int { + size := 12 + if c.Block == nil { + c.Block = new(SignedBeaconBlockElectra) + } + size += c.Block.SizeSSZ() + size += len(c.KzgProofs) * 48 + size += len(c.Blobs) * 131072 + return size } -// MarshalSSZTo ssz marshals the LightClientBootstrapElectra object to a target array -func (l *LightClientBootstrapElectra) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(24820) +func (c *SignedBeaconBlockContentsElectra) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Offset (0) 'Header' - dst = ssz.WriteOffset(dst, offset) - if l.Header == nil { - l.Header = new(LightClientHeaderDeneb) - } - offset += l.Header.SizeSSZ() +func (c *SignedBeaconBlockContentsElectra) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 12 - // Field (1) 'CurrentSyncCommittee' - if l.CurrentSyncCommittee == nil { - l.CurrentSyncCommittee = new(SyncCommittee) + // Field 0: Block + if c.Block == nil { + c.Block = new(SignedBeaconBlockElectra) } - if dst, err = l.CurrentSyncCommittee.MarshalSSZTo(dst); err != nil { - return + dst = ssz.WriteOffset(dst, offset) + offset += c.Block.SizeSSZ() + + // Field 1: KzgProofs + dst = ssz.WriteOffset(dst, offset) + offset += len(c.KzgProofs) * 48 + + // Field 2: Blobs + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Blobs) * 131072 + + // Field 0: Block + if dst, err = c.Block.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Block: %w", err) } - // Field (2) 'CurrentSyncCommitteeBranch' - if size := len(l.CurrentSyncCommitteeBranch); size != 6 { - err = ssz.ErrVectorLengthFn("--.CurrentSyncCommitteeBranch", size, 6) - return + // Field 1: KzgProofs + if len(c.KzgProofs) > 4096 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < 6; ii++ { - if size := len(l.CurrentSyncCommitteeBranch[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.CurrentSyncCommitteeBranch[ii]", size, 32) - return + for _, o := range c.KzgProofs { + if len(o) != 48 { + return nil, ssz.ErrBytesLength } - dst = append(dst, l.CurrentSyncCommitteeBranch[ii]...) + dst = append(dst, o...) } - // Field (0) 'Header' - if dst, err = l.Header.MarshalSSZTo(dst); err != nil { - return + // Field 2: Blobs + if len(c.Blobs) > 4096 { + return nil, ssz.ErrListTooBig } - - return + for _, o := range c.Blobs { + if len(o) != 131072 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the LightClientBootstrapElectra object -func (l *LightClientBootstrapElectra) UnmarshalSSZ(buf []byte) error { +func (c *SignedBeaconBlockContentsElectra) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 24820 { + if size < 12 { return ssz.ErrSize } - tail := buf - var o0 uint64 - - // Offset (0) 'Header' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Block + if sszVarOffset0 != 12 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset0 > size { return ssz.ErrOffset } - - if o0 != 24820 { - return ssz.ErrInvalidVariableOffset + sszVarOffset1 := ssz.ReadOffset(buf[4:8]) // c.KzgProofs + if sszVarOffset1 > size || sszVarOffset1 < sszVarOffset0 { + return ssz.ErrOffset } - - // Field (1) 'CurrentSyncCommittee' - if l.CurrentSyncCommittee == nil { - l.CurrentSyncCommittee = new(SyncCommittee) + sszVarOffset2 := ssz.ReadOffset(buf[8:12]) // c.Blobs + if sszVarOffset2 > size || sszVarOffset2 < sszVarOffset1 { + return ssz.ErrOffset } - if err = l.CurrentSyncCommittee.UnmarshalSSZ(buf[4:24628]); err != nil { - return err + sszSlice0 := buf[sszVarOffset0:sszVarOffset1] // c.Block + sszSlice1 := buf[sszVarOffset1:sszVarOffset2] // c.KzgProofs + sszSlice2 := buf[sszVarOffset2:] // c.Blobs + + // Field 0: Block + c.Block = new(SignedBeaconBlockElectra) + if err = c.Block.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Block: %w", err) } - // Field (2) 'CurrentSyncCommitteeBranch' - l.CurrentSyncCommitteeBranch = make([][]byte, 6) - for ii := 0; ii < 6; ii++ { - if cap(l.CurrentSyncCommitteeBranch[ii]) == 0 { - l.CurrentSyncCommitteeBranch[ii] = make([]byte, 0, len(buf[24628:24820][ii*32:(ii+1)*32])) + // Field 1: KzgProofs + { + if len(sszSlice1)%48 != 0 { + return fmt.Errorf("misaligned bytes: c.KzgProofs length is %d, which is not a multiple of 48: %w", len(sszSlice1), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice1) / 48 + if numElem > 4096 { + return fmt.Errorf("ssz-max exceeded: c.KzgProofs has %d elements, ssz-max is 4096: %w", numElem, ssz.ErrListTooBig) + } + c.KzgProofs = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte + + tmpSlice := sszSlice1[i*48 : (1+i)*48] + tmp = make([]byte, 0, 48) + tmp = append(tmp, tmpSlice...) + c.KzgProofs[i] = tmp } - l.CurrentSyncCommitteeBranch[ii] = append(l.CurrentSyncCommitteeBranch[ii], buf[24628:24820][ii*32:(ii+1)*32]...) } - // Field (0) 'Header' + // Field 2: Blobs { - buf = tail[o0:] - if l.Header == nil { - l.Header = new(LightClientHeaderDeneb) + if len(sszSlice2)%131072 != 0 { + return fmt.Errorf("misaligned bytes: c.Blobs length is %d, which is not a multiple of 131072: %w", len(sszSlice2), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice2) / 131072 + if numElem > 4096 { + return fmt.Errorf("ssz-max exceeded: c.Blobs has %d elements, ssz-max is 4096: %w", numElem, ssz.ErrListTooBig) } - if err = l.Header.UnmarshalSSZ(buf); err != nil { - return err + c.Blobs = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte + + tmpSlice := sszSlice2[i*131072 : (1+i)*131072] + tmp = make([]byte, 0, 131072) + tmp = append(tmp, tmpSlice...) + c.Blobs[i] = tmp } } return err } -// SizeSSZ returns the ssz encoded size in bytes for the LightClientBootstrapElectra object -func (l *LightClientBootstrapElectra) SizeSSZ() (size int) { - size = 24820 - - // Field (0) 'Header' - if l.Header == nil { - l.Header = new(LightClientHeaderDeneb) +func (c *SignedBeaconBlockContentsElectra) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - size += l.Header.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the LightClientBootstrapElectra object -func (l *LightClientBootstrapElectra) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(l) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the LightClientBootstrapElectra object with a hasher -func (l *LightClientBootstrapElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *SignedBeaconBlockContentsElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Header' - if err = l.Header.HashTreeRootWith(hh); err != nil { - return + // Field 0: Block + if err := c.Block.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Block: %w", err) } - - // Field (1) 'CurrentSyncCommittee' - if err = l.CurrentSyncCommittee.HashTreeRootWith(hh); err != nil { - return + // Field 1: KzgProofs + { + if len(c.KzgProofs) > 4096 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.KzgProofs { + if len(o) != 48 { + return ssz.ErrBytesLength + } + hh.PutBytes(o) + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.KzgProofs)), 4096) } - - // Field (2) 'CurrentSyncCommitteeBranch' + // Field 2: Blobs { - if size := len(l.CurrentSyncCommitteeBranch); size != 6 { - err = ssz.ErrVectorLengthFn("--.CurrentSyncCommitteeBranch", size, 6) - return + if len(c.Blobs) > 4096 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range l.CurrentSyncCommitteeBranch { - if len(i) != 32 { - err = ssz.ErrBytesLength - return + for _, o := range c.Blobs { + if len(o) != 131072 { + return ssz.ErrBytesLength } - hh.Append(i) + hh.PutBytes(o) } - hh.Merkleize(subIndx) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Blobs)), 4096) } - hh.Merkleize(indx) - return + return nil +} + +func (c *SignedBeaconBlockElectra) SizeSSZ() int { + size := 100 + if c.Block == nil { + c.Block = new(BeaconBlockElectra) + } + size += c.Block.SizeSSZ() + return size } -// MarshalSSZ ssz marshals the LightClientUpdateElectra object -func (l *LightClientUpdateElectra) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(l) +func (c *SignedBeaconBlockElectra) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the LightClientUpdateElectra object to a target array -func (l *LightClientUpdateElectra) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(25216) +func (c *SignedBeaconBlockElectra) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 100 - // Offset (0) 'AttestedHeader' + // Field 0: Block + if c.Block == nil { + c.Block = new(BeaconBlockElectra) + } dst = ssz.WriteOffset(dst, offset) - if l.AttestedHeader == nil { - l.AttestedHeader = new(LightClientHeaderDeneb) + offset += c.Block.SizeSSZ() + + // Field 1: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } - offset += l.AttestedHeader.SizeSSZ() + dst = append(dst, c.Signature...) - // Field (1) 'NextSyncCommittee' - if l.NextSyncCommittee == nil { - l.NextSyncCommittee = new(SyncCommittee) + // Field 0: Block + if dst, err = c.Block.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Block: %w", err) } - if dst, err = l.NextSyncCommittee.MarshalSSZTo(dst); err != nil { - return + return dst, err +} + +func (c *SignedBeaconBlockElectra) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 100 { + return ssz.ErrSize } - // Field (2) 'NextSyncCommitteeBranch' - if size := len(l.NextSyncCommitteeBranch); size != 6 { - err = ssz.ErrVectorLengthFn("--.NextSyncCommitteeBranch", size, 6) - return + sszSlice1 := buf[4:100] // c.Signature + + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Block + if sszVarOffset0 != 100 { + return ssz.ErrInvalidVariableOffset } - for ii := 0; ii < 6; ii++ { - if size := len(l.NextSyncCommitteeBranch[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.NextSyncCommitteeBranch[ii]", size, 32) - return - } - dst = append(dst, l.NextSyncCommitteeBranch[ii]...) + if sszVarOffset0 > size { + return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:] // c.Block - // Offset (3) 'FinalizedHeader' - dst = ssz.WriteOffset(dst, offset) - if l.FinalizedHeader == nil { - l.FinalizedHeader = new(LightClientHeaderDeneb) + // Field 0: Block + c.Block = new(BeaconBlockElectra) + if err = c.Block.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Block: %w", err) } - offset += l.FinalizedHeader.SizeSSZ() - // Field (4) 'FinalityBranch' - if size := len(l.FinalityBranch); size != 7 { - err = ssz.ErrVectorLengthFn("--.FinalityBranch", size, 7) - return - } - for ii := 0; ii < 7; ii++ { - if size := len(l.FinalityBranch[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.FinalityBranch[ii]", size, 32) - return - } - dst = append(dst, l.FinalityBranch[ii]...) + // Field 1: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice1...) + return err +} + +func (c *SignedBeaconBlockElectra) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (5) 'SyncAggregate' - if l.SyncAggregate == nil { - l.SyncAggregate = new(SyncAggregate) +func (c *SignedBeaconBlockElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Block + if err := c.Block.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Block: %w", err) + } + // Field 1: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength } - if dst, err = l.SyncAggregate.MarshalSSZTo(dst); err != nil { - return + hh.PutBytes(c.Signature) + hh.Merkleize(indx) + return nil +} + +func (c *SignedBlindedBeaconBlockElectra) SizeSSZ() int { + size := 100 + if c.Message == nil { + c.Message = new(BlindedBeaconBlockElectra) } + size += c.Message.SizeSSZ() + return size +} - // Field (6) 'SignatureSlot' - dst = ssz.MarshalUint(dst, l.SignatureSlot) +func (c *SignedBlindedBeaconBlockElectra) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} + +func (c *SignedBlindedBeaconBlockElectra) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 100 - // Field (0) 'AttestedHeader' - if dst, err = l.AttestedHeader.MarshalSSZTo(dst); err != nil { - return + // Field 0: Message + if c.Message == nil { + c.Message = new(BlindedBeaconBlockElectra) } + dst = ssz.WriteOffset(dst, offset) + offset += c.Message.SizeSSZ() - // Field (3) 'FinalizedHeader' - if dst, err = l.FinalizedHeader.MarshalSSZTo(dst); err != nil { - return + // Field 1: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.Signature...) - return + // Field 0: Message + if dst, err = c.Message.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Message: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the LightClientUpdateElectra object -func (l *LightClientUpdateElectra) UnmarshalSSZ(buf []byte) error { +func (c *SignedBlindedBeaconBlockElectra) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 25216 { + if size < 100 { return ssz.ErrSize } - tail := buf - var o0, o3 uint64 - - // Offset (0) 'AttestedHeader' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } + sszSlice1 := buf[4:100] // c.Signature - if o0 != 25216 { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Message + if sszVarOffset0 != 100 { return ssz.ErrInvalidVariableOffset } - - // Field (1) 'NextSyncCommittee' - if l.NextSyncCommittee == nil { - l.NextSyncCommittee = new(SyncCommittee) - } - if err = l.NextSyncCommittee.UnmarshalSSZ(buf[4:24628]); err != nil { - return err + if sszVarOffset0 > size { + return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:] // c.Message - // Field (2) 'NextSyncCommitteeBranch' - l.NextSyncCommitteeBranch = make([][]byte, 6) - for ii := 0; ii < 6; ii++ { - if cap(l.NextSyncCommitteeBranch[ii]) == 0 { - l.NextSyncCommitteeBranch[ii] = make([]byte, 0, len(buf[24628:24820][ii*32:(ii+1)*32])) - } - l.NextSyncCommitteeBranch[ii] = append(l.NextSyncCommitteeBranch[ii], buf[24628:24820][ii*32:(ii+1)*32]...) + // Field 0: Message + c.Message = new(BlindedBeaconBlockElectra) + if err = c.Message.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Message: %w", err) } - // Offset (3) 'FinalizedHeader' - if o3 = ssz.ReadOffset(buf[24820:24824]); o3 > size || o0 > o3 { - return ssz.ErrOffset - } + // Field 1: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice1...) + return err +} - // Field (4) 'FinalityBranch' - l.FinalityBranch = make([][]byte, 7) - for ii := 0; ii < 7; ii++ { - if cap(l.FinalityBranch[ii]) == 0 { - l.FinalityBranch[ii] = make([]byte, 0, len(buf[24824:25048][ii*32:(ii+1)*32])) - } - l.FinalityBranch[ii] = append(l.FinalityBranch[ii], buf[24824:25048][ii*32:(ii+1)*32]...) +func (c *SignedBlindedBeaconBlockElectra) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (5) 'SyncAggregate' - if l.SyncAggregate == nil { - l.SyncAggregate = new(SyncAggregate) +func (c *SignedBlindedBeaconBlockElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Message + if err := c.Message.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Message: %w", err) } - if err = l.SyncAggregate.UnmarshalSSZ(buf[25048:25208]); err != nil { - return err + // Field 1: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength } + hh.PutBytes(c.Signature) + hh.Merkleize(indx) + return nil +} - // Field (6) 'SignatureSlot' - l.SignatureSlot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[25208:25216]) - - // Field (0) 'AttestedHeader' - { - buf = tail[o0:o3] - if l.AttestedHeader == nil { - l.AttestedHeader = new(LightClientHeaderDeneb) - } - if err = l.AttestedHeader.UnmarshalSSZ(buf); err != nil { - return err - } +func (c *SignedBuilderBidElectra) SizeSSZ() int { + size := 100 + if c.Message == nil { + c.Message = new(BuilderBidElectra) } + size += c.Message.SizeSSZ() + return size +} - // Field (3) 'FinalizedHeader' - { - buf = tail[o3:] - if l.FinalizedHeader == nil { - l.FinalizedHeader = new(LightClientHeaderDeneb) - } - if err = l.FinalizedHeader.UnmarshalSSZ(buf); err != nil { - return err - } - } - return err +func (c *SignedBuilderBidElectra) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// SizeSSZ returns the ssz encoded size in bytes for the LightClientUpdateElectra object -func (l *LightClientUpdateElectra) SizeSSZ() (size int) { - size = 25216 +func (c *SignedBuilderBidElectra) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 100 - // Field (0) 'AttestedHeader' - if l.AttestedHeader == nil { - l.AttestedHeader = new(LightClientHeaderDeneb) + // Field 0: Message + if c.Message == nil { + c.Message = new(BuilderBidElectra) } - size += l.AttestedHeader.SizeSSZ() + dst = ssz.WriteOffset(dst, offset) + offset += c.Message.SizeSSZ() - // Field (3) 'FinalizedHeader' - if l.FinalizedHeader == nil { - l.FinalizedHeader = new(LightClientHeaderDeneb) + // Field 1: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } - size += l.FinalizedHeader.SizeSSZ() + dst = append(dst, c.Signature...) - return + // Field 0: Message + if dst, err = c.Message.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Message: %w", err) + } + return dst, err } -// HashTreeRoot ssz hashes the LightClientUpdateElectra object -func (l *LightClientUpdateElectra) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(l) -} +func (c *SignedBuilderBidElectra) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 100 { + return ssz.ErrSize + } -// HashTreeRootWith ssz hashes the LightClientUpdateElectra object with a hasher -func (l *LightClientUpdateElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() + sszSlice1 := buf[4:100] // c.Signature - // Field (0) 'AttestedHeader' - if err = l.AttestedHeader.HashTreeRootWith(hh); err != nil { - return + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Message + if sszVarOffset0 != 100 { + return ssz.ErrInvalidVariableOffset } - - // Field (1) 'NextSyncCommittee' - if err = l.NextSyncCommittee.HashTreeRootWith(hh); err != nil { - return + if sszVarOffset0 > size { + return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:] // c.Message - // Field (2) 'NextSyncCommitteeBranch' - { - if size := len(l.NextSyncCommitteeBranch); size != 6 { - err = ssz.ErrVectorLengthFn("--.NextSyncCommitteeBranch", size, 6) - return - } - subIndx := hh.Index() - for _, i := range l.NextSyncCommitteeBranch { - if len(i) != 32 { - err = ssz.ErrBytesLength - return - } - hh.Append(i) - } - hh.Merkleize(subIndx) + // Field 0: Message + c.Message = new(BuilderBidElectra) + if err = c.Message.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Message: %w", err) } - // Field (3) 'FinalizedHeader' - if err = l.FinalizedHeader.HashTreeRootWith(hh); err != nil { - return - } + // Field 1: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice1...) + return err +} - // Field (4) 'FinalityBranch' - { - if size := len(l.FinalityBranch); size != 7 { - err = ssz.ErrVectorLengthFn("--.FinalityBranch", size, 7) - return - } - subIndx := hh.Index() - for _, i := range l.FinalityBranch { - if len(i) != 32 { - err = ssz.ErrBytesLength - return - } - hh.Append(i) - } - hh.Merkleize(subIndx) +func (c *SignedBuilderBidElectra) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (5) 'SyncAggregate' - if err = l.SyncAggregate.HashTreeRootWith(hh); err != nil { - return +func (c *SignedBuilderBidElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Message + if err := c.Message.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Message: %w", err) } - - // Field (6) 'SignatureSlot' - ssz.PutUint(hh, l.SignatureSlot) - + // Field 1: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Signature) hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the LightClientFinalityUpdateElectra object -func (l *LightClientFinalityUpdateElectra) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(l) +func (c *SingleAttestation) SizeSSZ() int { + size := 240 + + return size } -// MarshalSSZTo ssz marshals the LightClientFinalityUpdateElectra object to a target array -func (l *LightClientFinalityUpdateElectra) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(400) +func (c *SingleAttestation) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Offset (0) 'AttestedHeader' - dst = ssz.WriteOffset(dst, offset) - if l.AttestedHeader == nil { - l.AttestedHeader = new(LightClientHeaderDeneb) - } - offset += l.AttestedHeader.SizeSSZ() +func (c *SingleAttestation) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Offset (1) 'FinalizedHeader' - dst = ssz.WriteOffset(dst, offset) - if l.FinalizedHeader == nil { - l.FinalizedHeader = new(LightClientHeaderDeneb) + // Field 0: CommitteeId + if dst, err = c.CommitteeId.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("CommitteeId: %w", err) } - offset += l.FinalizedHeader.SizeSSZ() - // Field (2) 'FinalityBranch' - if size := len(l.FinalityBranch); size != 7 { - err = ssz.ErrVectorLengthFn("--.FinalityBranch", size, 7) - return - } - for ii := 0; ii < 7; ii++ { - if size := len(l.FinalityBranch[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.FinalityBranch[ii]", size, 32) - return - } - dst = append(dst, l.FinalityBranch[ii]...) + // Field 1: AttesterIndex + if dst, err = c.AttesterIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("AttesterIndex: %w", err) } - // Field (3) 'SyncAggregate' - if l.SyncAggregate == nil { - l.SyncAggregate = new(SyncAggregate) + // Field 2: Data + if c.Data == nil { + c.Data = new(AttestationData) } - if dst, err = l.SyncAggregate.MarshalSSZTo(dst); err != nil { - return - } - - // Field (4) 'SignatureSlot' - dst = ssz.MarshalUint(dst, l.SignatureSlot) - - // Field (0) 'AttestedHeader' - if dst, err = l.AttestedHeader.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.Data.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Data: %w", err) } - // Field (1) 'FinalizedHeader' - if dst, err = l.FinalizedHeader.MarshalSSZTo(dst); err != nil { - return + // Field 3: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.Signature...) - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the LightClientFinalityUpdateElectra object -func (l *LightClientFinalityUpdateElectra) UnmarshalSSZ(buf []byte) error { +func (c *SingleAttestation) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 400 { + if size != 240 { return ssz.ErrSize } - tail := buf - var o0, o1 uint64 - - // Offset (0) 'AttestedHeader' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } - - if o0 != 400 { - return ssz.ErrInvalidVariableOffset - } - - // Offset (1) 'FinalizedHeader' - if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 { - return ssz.ErrOffset - } + sszSlice0 := buf[0:8] // c.CommitteeId + sszSlice1 := buf[8:16] // c.AttesterIndex + sszSlice2 := buf[16:144] // c.Data + sszSlice3 := buf[144:240] // c.Signature - // Field (2) 'FinalityBranch' - l.FinalityBranch = make([][]byte, 7) - for ii := 0; ii < 7; ii++ { - if cap(l.FinalityBranch[ii]) == 0 { - l.FinalityBranch[ii] = make([]byte, 0, len(buf[8:232][ii*32:(ii+1)*32])) - } - l.FinalityBranch[ii] = append(l.FinalityBranch[ii], buf[8:232][ii*32:(ii+1)*32]...) + // Field 0: CommitteeId + if err = c.CommitteeId.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("CommitteeId: %w", err) } - // Field (3) 'SyncAggregate' - if l.SyncAggregate == nil { - l.SyncAggregate = new(SyncAggregate) - } - if err = l.SyncAggregate.UnmarshalSSZ(buf[232:392]); err != nil { - return err + // Field 1: AttesterIndex + if err = c.AttesterIndex.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("AttesterIndex: %w", err) } - // Field (4) 'SignatureSlot' - l.SignatureSlot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[392:400]) - - // Field (0) 'AttestedHeader' - { - buf = tail[o0:o1] - if l.AttestedHeader == nil { - l.AttestedHeader = new(LightClientHeaderDeneb) - } - if err = l.AttestedHeader.UnmarshalSSZ(buf); err != nil { - return err - } + // Field 2: Data + c.Data = new(AttestationData) + if err = c.Data.UnmarshalSSZ(sszSlice2); err != nil { + return fmt.Errorf("Data: %w", err) } - // Field (1) 'FinalizedHeader' - { - buf = tail[o1:] - if l.FinalizedHeader == nil { - l.FinalizedHeader = new(LightClientHeaderDeneb) - } - if err = l.FinalizedHeader.UnmarshalSSZ(buf); err != nil { - return err - } - } + // Field 3: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice3...) return err } -// SizeSSZ returns the ssz encoded size in bytes for the LightClientFinalityUpdateElectra object -func (l *LightClientFinalityUpdateElectra) SizeSSZ() (size int) { - size = 400 - - // Field (0) 'AttestedHeader' - if l.AttestedHeader == nil { - l.AttestedHeader = new(LightClientHeaderDeneb) - } - size += l.AttestedHeader.SizeSSZ() - - // Field (1) 'FinalizedHeader' - if l.FinalizedHeader == nil { - l.FinalizedHeader = new(LightClientHeaderDeneb) +func (c *SingleAttestation) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - size += l.FinalizedHeader.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the LightClientFinalityUpdateElectra object -func (l *LightClientFinalityUpdateElectra) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(l) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the LightClientFinalityUpdateElectra object with a hasher -func (l *LightClientFinalityUpdateElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *SingleAttestation) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'AttestedHeader' - if err = l.AttestedHeader.HashTreeRootWith(hh); err != nil { - return + // Field 0: CommitteeId + if err := c.CommitteeId.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("CommitteeId: %w", err) } - - // Field (1) 'FinalizedHeader' - if err = l.FinalizedHeader.HashTreeRootWith(hh); err != nil { - return + // Field 1: AttesterIndex + if err := c.AttesterIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("AttesterIndex: %w", err) } - - // Field (2) 'FinalityBranch' - { - if size := len(l.FinalityBranch); size != 7 { - err = ssz.ErrVectorLengthFn("--.FinalityBranch", size, 7) - return - } - subIndx := hh.Index() - for _, i := range l.FinalityBranch { - if len(i) != 32 { - err = ssz.ErrBytesLength - return - } - hh.Append(i) - } - hh.Merkleize(subIndx) + // Field 2: Data + if err := c.Data.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Data: %w", err) } - - // Field (3) 'SyncAggregate' - if err = l.SyncAggregate.HashTreeRootWith(hh); err != nil { - return + // Field 3: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength } - - // Field (4) 'SignatureSlot' - ssz.PutUint(hh, l.SignatureSlot) - + hh.PutBytes(c.Signature) hh.Merkleize(indx) - return + return nil } diff --git a/proto/prysm/v1alpha1/electra.yaml b/proto/prysm/v1alpha1/electra.yaml new file mode 100644 index 000000000000..2d9c1cce9a67 --- /dev/null +++ b/proto/prysm/v1alpha1/electra.yaml @@ -0,0 +1,29 @@ +package: "github.com/OffchainLabs/prysm/v7/proto/prysm/v1alpha1" +types: + - name: "AggregateAttestationAndProofElectra" + - name: "AttestationElectra" + - name: "AttesterSlashingElectra" + - name: "BeaconBlockBodyElectra" + - name: "BeaconBlockContentsElectra" + - name: "BeaconBlockElectra" + - name: "BeaconStateElectra" + - name: "BlindedBeaconBlockBodyElectra" + - name: "BlindedBeaconBlockElectra" + - name: "BuilderBidElectra" + - name: "IndexedAttestationElectra" + - name: "LightClientBootstrapElectra" + - name: "LightClientUpdateElectra" + - name: "LightClientFinalityUpdateElectra" + - name: "PendingDeposit" + - name: "PendingConsolidation" + - name: "PendingPartialWithdrawal" + - name: "SignedAggregateAttestationAndProofElectra" + - name: "SignedBeaconBlockContentsElectra" + - name: "SignedBeaconBlockElectra" + - name: "SignedBlindedBeaconBlockElectra" + - name: "SignedBuilderBidElectra" + - name: "SingleAttestation" + + #- name: "LightClientHeaderElectra" + #- name: "PendingDeposits" + #- name: "SignedConsolidation" diff --git a/proto/prysm/v1alpha1/fulu.minimal.ssz.go b/proto/prysm/v1alpha1/fulu.minimal.ssz.go index 3fd23a1fc9ba..746a8c7f6526 100644 --- a/proto/prysm/v1alpha1/fulu.minimal.ssz.go +++ b/proto/prysm/v1alpha1/fulu.minimal.ssz.go @@ -1,3076 +1,2911 @@ //go:build minimal -// Code generated by fastssz. DO NOT EDIT. package eth import ( - github_com_OffchainLabs_prysm_v7_consensus_types_primitives "github.com/OffchainLabs/prysm/v7/consensus-types/primitives" + binary "encoding/binary" + "fmt" + go_bitfield "github.com/OffchainLabs/go-bitfield" + ssz "github.com/OffchainLabs/methodical-ssz/ssz" + primitives "github.com/OffchainLabs/prysm/v7/consensus-types/primitives" v1 "github.com/OffchainLabs/prysm/v7/proto/engine/v1" - ssz "github.com/prysmaticlabs/fastssz" ) -// MarshalSSZ ssz marshals the SignedBeaconBlockContentsFulu object -func (s *SignedBeaconBlockContentsFulu) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) +func (c *BeaconBlockContentsFulu) SizeSSZ() int { + size := 12 + if c.Block == nil { + c.Block = new(BeaconBlockElectra) + } + size += c.Block.SizeSSZ() + size += len(c.KzgProofs) * 48 + size += len(c.Blobs) * 131072 + return size } -// MarshalSSZTo ssz marshals the SignedBeaconBlockContentsFulu object to a target array -func (s *SignedBeaconBlockContentsFulu) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(12) +func (c *BeaconBlockContentsFulu) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Offset (0) 'Block' - dst = ssz.WriteOffset(dst, offset) - if s.Block == nil { - s.Block = new(SignedBeaconBlockFulu) +func (c *BeaconBlockContentsFulu) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 12 + + // Field 0: Block + if c.Block == nil { + c.Block = new(BeaconBlockElectra) } - offset += s.Block.SizeSSZ() + dst = ssz.WriteOffset(dst, offset) + offset += c.Block.SizeSSZ() - // Offset (1) 'KzgProofs' + // Field 1: KzgProofs dst = ssz.WriteOffset(dst, offset) - offset += len(s.KzgProofs) * 48 + offset += len(c.KzgProofs) * 48 - // Offset (2) 'Blobs' + // Field 2: Blobs dst = ssz.WriteOffset(dst, offset) - offset += len(s.Blobs) * 131072 + offset += len(c.Blobs) * 131072 - // Field (0) 'Block' - if dst, err = s.Block.MarshalSSZTo(dst); err != nil { - return + // Field 0: Block + if dst, err = c.Block.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Block: %w", err) } - // Field (1) 'KzgProofs' - if size := len(s.KzgProofs); size > 33554432 { - err = ssz.ErrListTooBigFn("--.KzgProofs", size, 33554432) - return + // Field 1: KzgProofs + if len(c.KzgProofs) > 33554432 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(s.KzgProofs); ii++ { - if size := len(s.KzgProofs[ii]); size != 48 { - err = ssz.ErrBytesLengthFn("--.KzgProofs[ii]", size, 48) - return + for _, o := range c.KzgProofs { + if len(o) != 48 { + return nil, ssz.ErrBytesLength } - dst = append(dst, s.KzgProofs[ii]...) + dst = append(dst, o...) } - // Field (2) 'Blobs' - if size := len(s.Blobs); size > 4096 { - err = ssz.ErrListTooBigFn("--.Blobs", size, 4096) - return + // Field 2: Blobs + if len(c.Blobs) > 4096 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(s.Blobs); ii++ { - if size := len(s.Blobs[ii]); size != 131072 { - err = ssz.ErrBytesLengthFn("--.Blobs[ii]", size, 131072) - return + for _, o := range c.Blobs { + if len(o) != 131072 { + return nil, ssz.ErrBytesLength } - dst = append(dst, s.Blobs[ii]...) + dst = append(dst, o...) } - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the SignedBeaconBlockContentsFulu object -func (s *SignedBeaconBlockContentsFulu) UnmarshalSSZ(buf []byte) error { +func (c *BeaconBlockContentsFulu) 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) 'Block' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } - - if o0 != 12 { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Block + if sszVarOffset0 != 12 { return ssz.ErrInvalidVariableOffset } - - // Offset (1) 'KzgProofs' - if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 { + if sszVarOffset0 > size { return ssz.ErrOffset } - - // Offset (2) 'Blobs' - if o2 = ssz.ReadOffset(buf[8:12]); o2 > size || o1 > o2 { + sszVarOffset1 := ssz.ReadOffset(buf[4:8]) // c.KzgProofs + if sszVarOffset1 > size || sszVarOffset1 < sszVarOffset0 { return ssz.ErrOffset } - - // Field (0) 'Block' - { - buf = tail[o0:o1] - if s.Block == nil { - s.Block = new(SignedBeaconBlockFulu) - } - if err = s.Block.UnmarshalSSZ(buf); err != nil { - return err - } - } - - // Field (1) 'KzgProofs' - { - buf = tail[o1:o2] - num, err := ssz.DivideInt2(len(buf), 48, 33554432) - if err != nil { - return err - } - s.KzgProofs = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(s.KzgProofs[ii]) == 0 { - s.KzgProofs[ii] = make([]byte, 0, len(buf[ii*48:(ii+1)*48])) - } - s.KzgProofs[ii] = append(s.KzgProofs[ii], buf[ii*48:(ii+1)*48]...) - } - } - - // Field (2) 'Blobs' - { - buf = tail[o2:] - num, err := ssz.DivideInt2(len(buf), 131072, 4096) - if err != nil { - return err - } - s.Blobs = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(s.Blobs[ii]) == 0 { - s.Blobs[ii] = make([]byte, 0, len(buf[ii*131072:(ii+1)*131072])) - } - s.Blobs[ii] = append(s.Blobs[ii], buf[ii*131072:(ii+1)*131072]...) - } - } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the SignedBeaconBlockContentsFulu object -func (s *SignedBeaconBlockContentsFulu) SizeSSZ() (size int) { - size = 12 - - // Field (0) 'Block' - if s.Block == nil { - s.Block = new(SignedBeaconBlockFulu) - } - size += s.Block.SizeSSZ() - - // Field (1) 'KzgProofs' - size += len(s.KzgProofs) * 48 - - // Field (2) 'Blobs' - size += len(s.Blobs) * 131072 - - return -} - -// HashTreeRoot ssz hashes the SignedBeaconBlockContentsFulu object -func (s *SignedBeaconBlockContentsFulu) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) -} - -// HashTreeRootWith ssz hashes the SignedBeaconBlockContentsFulu object with a hasher -func (s *SignedBeaconBlockContentsFulu) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'Block' - if err = s.Block.HashTreeRootWith(hh); err != nil { - return - } - - // Field (1) 'KzgProofs' - { - if size := len(s.KzgProofs); size > 33554432 { - err = ssz.ErrListTooBigFn("--.KzgProofs", size, 33554432) - return - } - subIndx := hh.Index() - for _, i := range s.KzgProofs { - if len(i) != 48 { - err = ssz.ErrBytesLength - return - } - hh.PutBytes(i) - } - - numItems := uint64(len(s.KzgProofs)) - hh.MerkleizeWithMixin(subIndx, numItems, 33554432) - } - - // Field (2) 'Blobs' - { - if size := len(s.Blobs); size > 4096 { - err = ssz.ErrListTooBigFn("--.Blobs", size, 4096) - return - } - subIndx := hh.Index() - for _, i := range s.Blobs { - if len(i) != 131072 { - err = ssz.ErrBytesLength - return - } - hh.PutBytes(i) - } - - numItems := uint64(len(s.Blobs)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) - } - - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the SignedBeaconBlockFulu object -func (s *SignedBeaconBlockFulu) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) -} - -// MarshalSSZTo ssz marshals the SignedBeaconBlockFulu object to a target array -func (s *SignedBeaconBlockFulu) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(100) - - // Offset (0) 'Block' - dst = ssz.WriteOffset(dst, offset) - if s.Block == nil { - s.Block = new(BeaconBlockElectra) - } - offset += s.Block.SizeSSZ() - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.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 SignedBeaconBlockFulu object -func (s *SignedBeaconBlockFulu) 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 { + sszVarOffset2 := ssz.ReadOffset(buf[8:12]) // c.Blobs + if sszVarOffset2 > size || sszVarOffset2 < sszVarOffset1 { return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:sszVarOffset1] // c.Block + sszSlice1 := buf[sszVarOffset1:sszVarOffset2] // c.KzgProofs + sszSlice2 := buf[sszVarOffset2:] // c.Blobs - if o0 != 100 { - return ssz.ErrInvalidVariableOffset - } - - // Field (1) 'Signature' - if cap(s.Signature) == 0 { - s.Signature = make([]byte, 0, len(buf[4:100])) + // Field 0: Block + c.Block = new(BeaconBlockElectra) + if err = c.Block.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Block: %w", err) } - s.Signature = append(s.Signature, buf[4:100]...) - // Field (0) 'Block' + // Field 1: KzgProofs { - buf = tail[o0:] - if s.Block == nil { - s.Block = new(BeaconBlockElectra) + if len(sszSlice1)%48 != 0 { + return fmt.Errorf("misaligned bytes: c.KzgProofs length is %d, which is not a multiple of 48: %w", len(sszSlice1), ssz.ErrIncorrectListSize) } - if err = s.Block.UnmarshalSSZ(buf); err != nil { - return err + numElem := len(sszSlice1) / 48 + if numElem > 33554432 { + return fmt.Errorf("ssz-max exceeded: c.KzgProofs has %d elements, ssz-max is 33554432: %w", numElem, ssz.ErrListTooBig) } - } - return err -} + c.KzgProofs = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte -// SizeSSZ returns the ssz encoded size in bytes for the SignedBeaconBlockFulu object -func (s *SignedBeaconBlockFulu) SizeSSZ() (size int) { - size = 100 - - // Field (0) 'Block' - if s.Block == nil { - s.Block = new(BeaconBlockElectra) - } - size += s.Block.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the SignedBeaconBlockFulu object -func (s *SignedBeaconBlockFulu) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) -} - -// HashTreeRootWith ssz hashes the SignedBeaconBlockFulu object with a hasher -func (s *SignedBeaconBlockFulu) HashTreeRootWith(hh *ssz.Hasher) (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("--.Signature", size, 96) - return - } - hh.PutBytes(s.Signature) - - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the BeaconBlockContentsFulu object -func (b *BeaconBlockContentsFulu) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} - -// MarshalSSZTo ssz marshals the BeaconBlockContentsFulu object to a target array -func (b *BeaconBlockContentsFulu) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(12) - - // Offset (0) 'Block' - dst = ssz.WriteOffset(dst, offset) - if b.Block == nil { - b.Block = new(BeaconBlockElectra) - } - offset += b.Block.SizeSSZ() - - // Offset (1) 'KzgProofs' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.KzgProofs) * 48 - - // Offset (2) 'Blobs' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.Blobs) * 131072 - - // Field (0) 'Block' - if dst, err = b.Block.MarshalSSZTo(dst); err != nil { - return - } - - // Field (1) 'KzgProofs' - if size := len(b.KzgProofs); size > 33554432 { - err = ssz.ErrListTooBigFn("--.KzgProofs", size, 33554432) - return - } - for ii := 0; ii < len(b.KzgProofs); ii++ { - if size := len(b.KzgProofs[ii]); size != 48 { - err = ssz.ErrBytesLengthFn("--.KzgProofs[ii]", size, 48) - return + tmpSlice := sszSlice1[i*48 : (1+i)*48] + tmp = make([]byte, 0, 48) + tmp = append(tmp, tmpSlice...) + c.KzgProofs[i] = tmp } - dst = append(dst, b.KzgProofs[ii]...) - } - - // Field (2) 'Blobs' - if size := len(b.Blobs); size > 4096 { - err = ssz.ErrListTooBigFn("--.Blobs", size, 4096) - return - } - for ii := 0; ii < len(b.Blobs); ii++ { - if size := len(b.Blobs[ii]); size != 131072 { - err = ssz.ErrBytesLengthFn("--.Blobs[ii]", size, 131072) - return - } - dst = append(dst, b.Blobs[ii]...) - } - - return -} - -// UnmarshalSSZ ssz unmarshals the BeaconBlockContentsFulu object -func (b *BeaconBlockContentsFulu) 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) 'Block' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } - - if o0 != 12 { - return ssz.ErrInvalidVariableOffset - } - - // Offset (1) 'KzgProofs' - if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 { - return ssz.ErrOffset - } - - // Offset (2) 'Blobs' - if o2 = ssz.ReadOffset(buf[8:12]); o2 > size || o1 > o2 { - return ssz.ErrOffset - } - - // Field (0) 'Block' + // Field 2: Blobs { - buf = tail[o0:o1] - if b.Block == nil { - b.Block = new(BeaconBlockElectra) - } - if err = b.Block.UnmarshalSSZ(buf); err != nil { - return err + if len(sszSlice2)%131072 != 0 { + return fmt.Errorf("misaligned bytes: c.Blobs length is %d, which is not a multiple of 131072: %w", len(sszSlice2), ssz.ErrIncorrectListSize) } - } - - // Field (1) 'KzgProofs' - { - buf = tail[o1:o2] - num, err := ssz.DivideInt2(len(buf), 48, 33554432) - if err != nil { - return err - } - b.KzgProofs = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(b.KzgProofs[ii]) == 0 { - b.KzgProofs[ii] = make([]byte, 0, len(buf[ii*48:(ii+1)*48])) - } - b.KzgProofs[ii] = append(b.KzgProofs[ii], buf[ii*48:(ii+1)*48]...) + numElem := len(sszSlice2) / 131072 + if numElem > 4096 { + return fmt.Errorf("ssz-max exceeded: c.Blobs has %d elements, ssz-max is 4096: %w", numElem, ssz.ErrListTooBig) } - } + c.Blobs = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte - // Field (2) 'Blobs' - { - buf = tail[o2:] - num, err := ssz.DivideInt2(len(buf), 131072, 4096) - if err != nil { - return err - } - b.Blobs = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(b.Blobs[ii]) == 0 { - b.Blobs[ii] = make([]byte, 0, len(buf[ii*131072:(ii+1)*131072])) - } - b.Blobs[ii] = append(b.Blobs[ii], buf[ii*131072:(ii+1)*131072]...) + tmpSlice := sszSlice2[i*131072 : (1+i)*131072] + tmp = make([]byte, 0, 131072) + tmp = append(tmp, tmpSlice...) + c.Blobs[i] = tmp } } return err } -// SizeSSZ returns the ssz encoded size in bytes for the BeaconBlockContentsFulu object -func (b *BeaconBlockContentsFulu) SizeSSZ() (size int) { - size = 12 - - // Field (0) 'Block' - if b.Block == nil { - b.Block = new(BeaconBlockElectra) +func (c *BeaconBlockContentsFulu) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - size += b.Block.SizeSSZ() - - // Field (1) 'KzgProofs' - size += len(b.KzgProofs) * 48 - - // Field (2) 'Blobs' - size += len(b.Blobs) * 131072 - - return + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRoot ssz hashes the BeaconBlockContentsFulu object -func (b *BeaconBlockContentsFulu) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) -} - -// HashTreeRootWith ssz hashes the BeaconBlockContentsFulu object with a hasher -func (b *BeaconBlockContentsFulu) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *BeaconBlockContentsFulu) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Block' - if err = b.Block.HashTreeRootWith(hh); err != nil { - return + // Field 0: Block + if err := c.Block.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Block: %w", err) } - - // Field (1) 'KzgProofs' + // Field 1: KzgProofs { - if size := len(b.KzgProofs); size > 33554432 { - err = ssz.ErrListTooBigFn("--.KzgProofs", size, 33554432) - return + if len(c.KzgProofs) > 33554432 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range b.KzgProofs { - if len(i) != 48 { - err = ssz.ErrBytesLength - return + for _, o := range c.KzgProofs { + if len(o) != 48 { + return ssz.ErrBytesLength } - hh.PutBytes(i) + hh.PutBytes(o) } - - numItems := uint64(len(b.KzgProofs)) - hh.MerkleizeWithMixin(subIndx, numItems, 33554432) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.KzgProofs)), 33554432) } - - // Field (2) 'Blobs' + // Field 2: Blobs { - if size := len(b.Blobs); size > 4096 { - err = ssz.ErrListTooBigFn("--.Blobs", size, 4096) - return + if len(c.Blobs) > 4096 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range b.Blobs { - if len(i) != 131072 { - err = ssz.ErrBytesLength - return + for _, o := range c.Blobs { + if len(o) != 131072 { + return ssz.ErrBytesLength } - hh.PutBytes(i) + hh.PutBytes(o) } - - numItems := uint64(len(b.Blobs)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Blobs)), 4096) } - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the SignedBlindedBeaconBlockFulu object -func (s *SignedBlindedBeaconBlockFulu) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) -} - -// MarshalSSZTo ssz marshals the SignedBlindedBeaconBlockFulu object to a target array -func (s *SignedBlindedBeaconBlockFulu) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(100) - - // Offset (0) 'Message' - dst = ssz.WriteOffset(dst, offset) - if s.Message == nil { - s.Message = new(BlindedBeaconBlockFulu) - } - offset += s.Message.SizeSSZ() - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return - } - dst = append(dst, s.Signature...) - - // Field (0) 'Message' - if dst, err = s.Message.MarshalSSZTo(dst); err != nil { - return - } - - return -} - -// UnmarshalSSZ ssz unmarshals the SignedBlindedBeaconBlockFulu object -func (s *SignedBlindedBeaconBlockFulu) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 100 { - return ssz.ErrSize - } - - tail := buf - var o0 uint64 - - // Offset (0) 'Message' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } - - if o0 != 100 { - return ssz.ErrInvalidVariableOffset - } - - // Field (1) 'Signature' - if cap(s.Signature) == 0 { - s.Signature = make([]byte, 0, len(buf[4:100])) - } - s.Signature = append(s.Signature, buf[4:100]...) - - // Field (0) 'Message' - { - buf = tail[o0:] - if s.Message == nil { - s.Message = new(BlindedBeaconBlockFulu) - } - if err = s.Message.UnmarshalSSZ(buf); err != nil { - return err - } - } - return err + return nil } -// SizeSSZ returns the ssz encoded size in bytes for the SignedBlindedBeaconBlockFulu object -func (s *SignedBlindedBeaconBlockFulu) SizeSSZ() (size int) { - size = 100 - - // Field (0) 'Message' - if s.Message == nil { - s.Message = new(BlindedBeaconBlockFulu) +func (c *BeaconStateFulu) SizeSSZ() int { + size := 10441 + size += len(c.HistoricalRoots) * 32 + size += len(c.Eth1DataVotes) * 72 + size += len(c.Validators) * 121 + size += len(c.Balances) * 8 + size += len(c.PreviousEpochParticipation) + size += len(c.CurrentEpochParticipation) + size += len(c.InactivityScores) * 8 + if c.LatestExecutionPayloadHeader == nil { + c.LatestExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderDeneb) } - size += s.Message.SizeSSZ() - - return + size += c.LatestExecutionPayloadHeader.SizeSSZ() + size += len(c.HistoricalSummaries) * 64 + size += len(c.PendingDeposits) * 192 + size += len(c.PendingPartialWithdrawals) * 24 + size += len(c.PendingConsolidations) * 16 + return size } -// HashTreeRoot ssz hashes the SignedBlindedBeaconBlockFulu object -func (s *SignedBlindedBeaconBlockFulu) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) +func (c *BeaconStateFulu) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// HashTreeRootWith ssz hashes the SignedBlindedBeaconBlockFulu object with a hasher -func (s *SignedBlindedBeaconBlockFulu) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'Message' - if err = s.Message.HashTreeRootWith(hh); err != nil { - return - } - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return - } - hh.PutBytes(s.Signature) - - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the BlindedBeaconBlockFulu object -func (b *BlindedBeaconBlockFulu) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} - -// MarshalSSZTo ssz marshals the BlindedBeaconBlockFulu object to a target array -func (b *BlindedBeaconBlockFulu) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(84) - - // Field (0) 'Slot' - dst = ssz.MarshalUint(dst, b.Slot) - - // Field (1) 'ProposerIndex' - dst = ssz.MarshalUint(dst, b.ProposerIndex) - - // Field (2) 'ParentRoot' - if size := len(b.ParentRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentRoot", size, 32) - return - } - dst = append(dst, b.ParentRoot...) - - // Field (3) 'StateRoot' - if size := len(b.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return - } - dst = append(dst, b.StateRoot...) - - // Offset (4) 'Body' - dst = ssz.WriteOffset(dst, offset) - if b.Body == nil { - b.Body = new(BlindedBeaconBlockBodyElectra) - } - offset += b.Body.SizeSSZ() - - // Field (4) 'Body' - if dst, err = b.Body.MarshalSSZTo(dst); err != nil { - return - } - - return -} - -// UnmarshalSSZ ssz unmarshals the BlindedBeaconBlockFulu object -func (b *BlindedBeaconBlockFulu) UnmarshalSSZ(buf []byte) error { +func (c *BeaconStateFulu) MarshalSSZTo(dst []byte) ([]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.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[0:8]) - - // Field (1) 'ProposerIndex' - b.ProposerIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[8:16]) + offset := 10441 - // 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 0: GenesisTime + dst = binary.LittleEndian.AppendUint64(dst, c.GenesisTime) - // Offset (4) 'Body' - if o4 = ssz.ReadOffset(buf[80:84]); o4 > size { - return ssz.ErrOffset + // Field 1: GenesisValidatorsRoot + if len(c.GenesisValidatorsRoot) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.GenesisValidatorsRoot...) - if o4 != 84 { - return ssz.ErrInvalidVariableOffset + // Field 2: Slot + if dst, err = c.Slot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Slot: %w", err) } - // Field (4) 'Body' - { - buf = tail[o4:] - if b.Body == nil { - b.Body = new(BlindedBeaconBlockBodyElectra) - } - if err = b.Body.UnmarshalSSZ(buf); err != nil { - return err - } - } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the BlindedBeaconBlockFulu object -func (b *BlindedBeaconBlockFulu) SizeSSZ() (size int) { - size = 84 - - // Field (4) 'Body' - if b.Body == nil { - b.Body = new(BlindedBeaconBlockBodyElectra) - } - size += b.Body.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the BlindedBeaconBlockFulu object -func (b *BlindedBeaconBlockFulu) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) -} - -// HashTreeRootWith ssz hashes the BlindedBeaconBlockFulu object with a hasher -func (b *BlindedBeaconBlockFulu) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'Slot' - ssz.PutUint(hh, b.Slot) - - // Field (1) 'ProposerIndex' - ssz.PutUint(hh, b.ProposerIndex) - - // Field (2) 'ParentRoot' - if size := len(b.ParentRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentRoot", size, 32) - return - } - hh.PutBytes(b.ParentRoot) - - // Field (3) 'StateRoot' - if size := len(b.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return - } - hh.PutBytes(b.StateRoot) - - // Field (4) 'Body' - if err = b.Body.HashTreeRootWith(hh); err != nil { - return - } - - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the BeaconStateFulu object -func (b *BeaconStateFulu) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} - -// MarshalSSZTo ssz marshals the BeaconStateFulu object to a target array -func (b *BeaconStateFulu) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(10441) - - // Field (0) 'GenesisTime' - dst = ssz.MarshalUint(dst, b.GenesisTime) - - // Field (1) 'GenesisValidatorsRoot' - if size := len(b.GenesisValidatorsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.GenesisValidatorsRoot", size, 32) - return - } - dst = append(dst, b.GenesisValidatorsRoot...) - - // Field (2) 'Slot' - dst = ssz.MarshalUint(dst, b.Slot) - - // Field (3) 'Fork' - if b.Fork == nil { - b.Fork = new(Fork) + // Field 3: Fork + if c.Fork == nil { + c.Fork = new(Fork) } - if dst, err = b.Fork.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.Fork.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Fork: %w", err) } - // Field (4) 'LatestBlockHeader' - if b.LatestBlockHeader == nil { - b.LatestBlockHeader = new(BeaconBlockHeader) + // Field 4: LatestBlockHeader + if c.LatestBlockHeader == nil { + c.LatestBlockHeader = new(BeaconBlockHeader) } - if dst, err = b.LatestBlockHeader.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.LatestBlockHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("LatestBlockHeader: %w", err) } - // Field (5) 'BlockRoots' - if size := len(b.BlockRoots); size != 64 { - err = ssz.ErrVectorLengthFn("--.BlockRoots", size, 64) - return + // Field 5: BlockRoots + if len(c.BlockRoots) != 64 { + return nil, ssz.ErrBytesLength } - for ii := 0; ii < 64; ii++ { - if size := len(b.BlockRoots[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockRoots[ii]", size, 32) - return + for _, o := range c.BlockRoots { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.BlockRoots[ii]...) + dst = append(dst, o...) } - // Field (6) 'StateRoots' - if size := len(b.StateRoots); size != 64 { - err = ssz.ErrVectorLengthFn("--.StateRoots", size, 64) - return + // Field 6: StateRoots + if len(c.StateRoots) != 64 { + return nil, ssz.ErrBytesLength } - for ii := 0; ii < 64; ii++ { - if size := len(b.StateRoots[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoots[ii]", size, 32) - return + for _, o := range c.StateRoots { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.StateRoots[ii]...) + dst = append(dst, o...) } - // Offset (7) 'HistoricalRoots' + // Field 7: HistoricalRoots dst = ssz.WriteOffset(dst, offset) - offset += len(b.HistoricalRoots) * 32 + offset += len(c.HistoricalRoots) * 32 - // Field (8) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(Eth1Data) + // Field 8: Eth1Data + if c.Eth1Data == nil { + c.Eth1Data = new(Eth1Data) } - if dst, err = b.Eth1Data.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.Eth1Data.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Eth1Data: %w", err) } - // Offset (9) 'Eth1DataVotes' + // Field 9: Eth1DataVotes dst = ssz.WriteOffset(dst, offset) - offset += len(b.Eth1DataVotes) * 72 + offset += len(c.Eth1DataVotes) * 72 - // Field (10) 'Eth1DepositIndex' - dst = ssz.MarshalUint(dst, b.Eth1DepositIndex) + // Field 10: Eth1DepositIndex + dst = binary.LittleEndian.AppendUint64(dst, c.Eth1DepositIndex) - // Offset (11) 'Validators' + // Field 11: Validators dst = ssz.WriteOffset(dst, offset) - offset += len(b.Validators) * 121 + offset += len(c.Validators) * 121 - // Offset (12) 'Balances' + // Field 12: Balances dst = ssz.WriteOffset(dst, offset) - offset += len(b.Balances) * 8 + offset += len(c.Balances) * 8 - // Field (13) 'RandaoMixes' - if size := len(b.RandaoMixes); size != 64 { - err = ssz.ErrVectorLengthFn("--.RandaoMixes", size, 64) - return + // Field 13: RandaoMixes + if len(c.RandaoMixes) != 64 { + return nil, ssz.ErrBytesLength } - for ii := 0; ii < 64; ii++ { - if size := len(b.RandaoMixes[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.RandaoMixes[ii]", size, 32) - return + for _, o := range c.RandaoMixes { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.RandaoMixes[ii]...) + dst = append(dst, o...) } - // Field (14) 'Slashings' - if size := len(b.Slashings); size != 64 { - err = ssz.ErrVectorLengthFn("--.Slashings", size, 64) - return + // Field 14: Slashings + if len(c.Slashings) != 64 { + return nil, ssz.ErrBytesLength } - for ii := 0; ii < 64; ii++ { - dst = ssz.MarshalUint(dst, b.Slashings[ii]) + for _, o := range c.Slashings { + dst = binary.LittleEndian.AppendUint64(dst, o) } - // Offset (15) 'PreviousEpochParticipation' + // Field 15: PreviousEpochParticipation dst = ssz.WriteOffset(dst, offset) - offset += len(b.PreviousEpochParticipation) + offset += len(c.PreviousEpochParticipation) - // Offset (16) 'CurrentEpochParticipation' + // Field 16: CurrentEpochParticipation dst = ssz.WriteOffset(dst, offset) - offset += len(b.CurrentEpochParticipation) + offset += len(c.CurrentEpochParticipation) - // Field (17) 'JustificationBits' - if size := len(b.JustificationBits); size != 1 { - err = ssz.ErrBytesLengthFn("--.JustificationBits", size, 1) - return + // Field 17: JustificationBits + if len([]byte(c.JustificationBits)) != 1 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.JustificationBits...) + dst = append(dst, []byte(c.JustificationBits)...) - // Field (18) 'PreviousJustifiedCheckpoint' - if b.PreviousJustifiedCheckpoint == nil { - b.PreviousJustifiedCheckpoint = new(Checkpoint) + // Field 18: PreviousJustifiedCheckpoint + if c.PreviousJustifiedCheckpoint == nil { + c.PreviousJustifiedCheckpoint = new(Checkpoint) } - if dst, err = b.PreviousJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.PreviousJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("PreviousJustifiedCheckpoint: %w", err) } - // Field (19) 'CurrentJustifiedCheckpoint' - if b.CurrentJustifiedCheckpoint == nil { - b.CurrentJustifiedCheckpoint = new(Checkpoint) + // Field 19: CurrentJustifiedCheckpoint + if c.CurrentJustifiedCheckpoint == nil { + c.CurrentJustifiedCheckpoint = new(Checkpoint) } - if dst, err = b.CurrentJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.CurrentJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("CurrentJustifiedCheckpoint: %w", err) } - // Field (20) 'FinalizedCheckpoint' - if b.FinalizedCheckpoint == nil { - b.FinalizedCheckpoint = new(Checkpoint) + // Field 20: FinalizedCheckpoint + if c.FinalizedCheckpoint == nil { + c.FinalizedCheckpoint = new(Checkpoint) } - if dst, err = b.FinalizedCheckpoint.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.FinalizedCheckpoint.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("FinalizedCheckpoint: %w", err) } - // Offset (21) 'InactivityScores' + // Field 21: InactivityScores dst = ssz.WriteOffset(dst, offset) - offset += len(b.InactivityScores) * 8 + offset += len(c.InactivityScores) * 8 - // Field (22) 'CurrentSyncCommittee' - if b.CurrentSyncCommittee == nil { - b.CurrentSyncCommittee = new(SyncCommittee) + // Field 22: CurrentSyncCommittee + if c.CurrentSyncCommittee == nil { + c.CurrentSyncCommittee = new(SyncCommittee) } - if dst, err = b.CurrentSyncCommittee.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.CurrentSyncCommittee.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("CurrentSyncCommittee: %w", err) } - // Field (23) 'NextSyncCommittee' - if b.NextSyncCommittee == nil { - b.NextSyncCommittee = new(SyncCommittee) + // Field 23: NextSyncCommittee + if c.NextSyncCommittee == nil { + c.NextSyncCommittee = new(SyncCommittee) } - if dst, err = b.NextSyncCommittee.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.NextSyncCommittee.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("NextSyncCommittee: %w", err) } - // Offset (24) 'LatestExecutionPayloadHeader' - dst = ssz.WriteOffset(dst, offset) - if b.LatestExecutionPayloadHeader == nil { - b.LatestExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderDeneb) + // Field 24: LatestExecutionPayloadHeader + if c.LatestExecutionPayloadHeader == nil { + c.LatestExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderDeneb) } - offset += b.LatestExecutionPayloadHeader.SizeSSZ() + dst = ssz.WriteOffset(dst, offset) + offset += c.LatestExecutionPayloadHeader.SizeSSZ() - // Field (25) 'NextWithdrawalIndex' - dst = ssz.MarshalUint(dst, b.NextWithdrawalIndex) + // Field 25: NextWithdrawalIndex + dst = binary.LittleEndian.AppendUint64(dst, c.NextWithdrawalIndex) - // Field (26) 'NextWithdrawalValidatorIndex' - dst = ssz.MarshalUint(dst, b.NextWithdrawalValidatorIndex) + // Field 26: NextWithdrawalValidatorIndex + if dst, err = c.NextWithdrawalValidatorIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("NextWithdrawalValidatorIndex: %w", err) + } - // Offset (27) 'HistoricalSummaries' + // Field 27: HistoricalSummaries dst = ssz.WriteOffset(dst, offset) - offset += len(b.HistoricalSummaries) * 64 + offset += len(c.HistoricalSummaries) * 64 - // Field (28) 'DepositRequestsStartIndex' - dst = ssz.MarshalUint(dst, b.DepositRequestsStartIndex) + // Field 28: DepositRequestsStartIndex + dst = binary.LittleEndian.AppendUint64(dst, c.DepositRequestsStartIndex) - // Field (29) 'DepositBalanceToConsume' - dst = ssz.MarshalUint(dst, b.DepositBalanceToConsume) + // Field 29: DepositBalanceToConsume + if dst, err = c.DepositBalanceToConsume.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("DepositBalanceToConsume: %w", err) + } - // Field (30) 'ExitBalanceToConsume' - dst = ssz.MarshalUint(dst, b.ExitBalanceToConsume) + // Field 30: ExitBalanceToConsume + if dst, err = c.ExitBalanceToConsume.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ExitBalanceToConsume: %w", err) + } - // Field (31) 'EarliestExitEpoch' - dst = ssz.MarshalUint(dst, b.EarliestExitEpoch) + // Field 31: EarliestExitEpoch + if dst, err = c.EarliestExitEpoch.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("EarliestExitEpoch: %w", err) + } - // Field (32) 'ConsolidationBalanceToConsume' - dst = ssz.MarshalUint(dst, b.ConsolidationBalanceToConsume) + // Field 32: ConsolidationBalanceToConsume + if dst, err = c.ConsolidationBalanceToConsume.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ConsolidationBalanceToConsume: %w", err) + } - // Field (33) 'EarliestConsolidationEpoch' - dst = ssz.MarshalUint(dst, b.EarliestConsolidationEpoch) + // Field 33: EarliestConsolidationEpoch + if dst, err = c.EarliestConsolidationEpoch.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("EarliestConsolidationEpoch: %w", err) + } - // Offset (34) 'PendingDeposits' + // Field 34: PendingDeposits dst = ssz.WriteOffset(dst, offset) - offset += len(b.PendingDeposits) * 192 + offset += len(c.PendingDeposits) * 192 - // Offset (35) 'PendingPartialWithdrawals' + // Field 35: PendingPartialWithdrawals dst = ssz.WriteOffset(dst, offset) - offset += len(b.PendingPartialWithdrawals) * 24 + offset += len(c.PendingPartialWithdrawals) * 24 - // Offset (36) 'PendingConsolidations' + // Field 36: PendingConsolidations dst = ssz.WriteOffset(dst, offset) - offset += len(b.PendingConsolidations) * 16 + offset += len(c.PendingConsolidations) * 16 - // Field (37) 'ProposerLookahead' - if size := len(b.ProposerLookahead); size != 16 { - err = ssz.ErrVectorLengthFn("--.ProposerLookahead", size, 16) - return + // Field 37: ProposerLookahead + if len(c.ProposerLookahead) != 16 { + return nil, ssz.ErrBytesLength } - for ii := 0; ii < 16; ii++ { - dst = ssz.MarshalUint(dst, b.ProposerLookahead[ii]) + for _, o := range c.ProposerLookahead { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ProposerLookahead: %w", err) + } } - // Field (7) 'HistoricalRoots' - if size := len(b.HistoricalRoots); size > 16777216 { - err = ssz.ErrListTooBigFn("--.HistoricalRoots", size, 16777216) - return + // Field 7: HistoricalRoots + if len(c.HistoricalRoots) > 16777216 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.HistoricalRoots); ii++ { - if size := len(b.HistoricalRoots[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.HistoricalRoots[ii]", size, 32) - return + for _, o := range c.HistoricalRoots { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.HistoricalRoots[ii]...) + dst = append(dst, o...) } - // Field (9) 'Eth1DataVotes' - if size := len(b.Eth1DataVotes); size > 32 { - err = ssz.ErrListTooBigFn("--.Eth1DataVotes", size, 32) - return + // Field 9: Eth1DataVotes + if len(c.Eth1DataVotes) > 32 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.Eth1DataVotes); ii++ { - if dst, err = b.Eth1DataVotes[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.Eth1DataVotes { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Eth1DataVotes: %w", err) } } - // Field (11) 'Validators' - if size := len(b.Validators); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.Validators", size, 1099511627776) - return + // Field 11: Validators + if len(c.Validators) > 1099511627776 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.Validators); ii++ { - if dst, err = b.Validators[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.Validators { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Validators: %w", err) } } - // Field (12) 'Balances' - if size := len(b.Balances); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.Balances", size, 1099511627776) - return + // Field 12: Balances + if len(c.Balances) > 1099511627776 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.Balances); ii++ { - dst = ssz.MarshalUint(dst, b.Balances[ii]) + for _, o := range c.Balances { + dst = binary.LittleEndian.AppendUint64(dst, o) } - // Field (15) 'PreviousEpochParticipation' - if size := len(b.PreviousEpochParticipation); size > 1099511627776 { - err = ssz.ErrBytesLengthFn("--.PreviousEpochParticipation", size, 1099511627776) - return + // Field 15: PreviousEpochParticipation + if len(c.PreviousEpochParticipation) > 1099511627776 { + return nil, ssz.ErrListTooBig } - dst = append(dst, b.PreviousEpochParticipation...) + dst = append(dst, c.PreviousEpochParticipation...) - // Field (16) 'CurrentEpochParticipation' - if size := len(b.CurrentEpochParticipation); size > 1099511627776 { - err = ssz.ErrBytesLengthFn("--.CurrentEpochParticipation", size, 1099511627776) - return + // Field 16: CurrentEpochParticipation + if len(c.CurrentEpochParticipation) > 1099511627776 { + return nil, ssz.ErrListTooBig } - dst = append(dst, b.CurrentEpochParticipation...) + dst = append(dst, c.CurrentEpochParticipation...) - // Field (21) 'InactivityScores' - if size := len(b.InactivityScores); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.InactivityScores", size, 1099511627776) - return + // Field 21: InactivityScores + if len(c.InactivityScores) > 1099511627776 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.InactivityScores); ii++ { - dst = ssz.MarshalUint(dst, b.InactivityScores[ii]) + for _, o := range c.InactivityScores { + dst = binary.LittleEndian.AppendUint64(dst, o) } - // Field (24) 'LatestExecutionPayloadHeader' - if dst, err = b.LatestExecutionPayloadHeader.MarshalSSZTo(dst); err != nil { - return + // Field 24: LatestExecutionPayloadHeader + if dst, err = c.LatestExecutionPayloadHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("LatestExecutionPayloadHeader: %w", err) } - // Field (27) 'HistoricalSummaries' - if size := len(b.HistoricalSummaries); size > 16777216 { - err = ssz.ErrListTooBigFn("--.HistoricalSummaries", size, 16777216) - return + // Field 27: HistoricalSummaries + if len(c.HistoricalSummaries) > 16777216 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.HistoricalSummaries); ii++ { - if dst, err = b.HistoricalSummaries[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.HistoricalSummaries { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("HistoricalSummaries: %w", err) } } - // Field (34) 'PendingDeposits' - if size := len(b.PendingDeposits); size > 134217728 { - err = ssz.ErrListTooBigFn("--.PendingDeposits", size, 134217728) - return + // Field 34: PendingDeposits + if len(c.PendingDeposits) > 134217728 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.PendingDeposits); ii++ { - if dst, err = b.PendingDeposits[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.PendingDeposits { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("PendingDeposits: %w", err) } } - // Field (35) 'PendingPartialWithdrawals' - if size := len(b.PendingPartialWithdrawals); size > 64 { - err = ssz.ErrListTooBigFn("--.PendingPartialWithdrawals", size, 64) - return + // Field 35: PendingPartialWithdrawals + if len(c.PendingPartialWithdrawals) > 64 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.PendingPartialWithdrawals); ii++ { - if dst, err = b.PendingPartialWithdrawals[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.PendingPartialWithdrawals { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("PendingPartialWithdrawals: %w", err) } } - // Field (36) 'PendingConsolidations' - if size := len(b.PendingConsolidations); size > 64 { - err = ssz.ErrListTooBigFn("--.PendingConsolidations", size, 64) - return + // Field 36: PendingConsolidations + if len(c.PendingConsolidations) > 64 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.PendingConsolidations); ii++ { - if dst, err = b.PendingConsolidations[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.PendingConsolidations { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("PendingConsolidations: %w", err) } } - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the BeaconStateFulu object -func (b *BeaconStateFulu) UnmarshalSSZ(buf []byte) error { +func (c *BeaconStateFulu) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size < 10441 { 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.UnmarshallUint[uint64](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.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[40:48]) - - // Field (3) 'Fork' - if b.Fork == nil { - b.Fork = new(Fork) + sszSlice0 := buf[0:8] // c.GenesisTime + sszSlice1 := buf[8:40] // c.GenesisValidatorsRoot + sszSlice2 := buf[40:48] // c.Slot + sszSlice3 := buf[48:64] // c.Fork + sszSlice4 := buf[64:176] // c.LatestBlockHeader + sszSlice5 := buf[176:2224] // c.BlockRoots + sszSlice6 := buf[2224:4272] // c.StateRoots + sszSlice8 := buf[4276:4348] // c.Eth1Data + sszSlice10 := buf[4352:4360] // c.Eth1DepositIndex + sszSlice13 := buf[4368:6416] // c.RandaoMixes + sszSlice14 := buf[6416:6928] // c.Slashings + sszSlice17 := buf[6936:6937] // c.JustificationBits + sszSlice18 := buf[6937:6977] // c.PreviousJustifiedCheckpoint + sszSlice19 := buf[6977:7017] // c.CurrentJustifiedCheckpoint + sszSlice20 := buf[7017:7057] // c.FinalizedCheckpoint + sszSlice22 := buf[7061:8645] // c.CurrentSyncCommittee + sszSlice23 := buf[8645:10229] // c.NextSyncCommittee + sszSlice25 := buf[10233:10241] // c.NextWithdrawalIndex + sszSlice26 := buf[10241:10249] // c.NextWithdrawalValidatorIndex + sszSlice28 := buf[10253:10261] // c.DepositRequestsStartIndex + sszSlice29 := buf[10261:10269] // c.DepositBalanceToConsume + sszSlice30 := buf[10269:10277] // c.ExitBalanceToConsume + sszSlice31 := buf[10277:10285] // c.EarliestExitEpoch + sszSlice32 := buf[10285:10293] // c.ConsolidationBalanceToConsume + sszSlice33 := buf[10293:10301] // c.EarliestConsolidationEpoch + sszSlice37 := buf[10313:10441] // c.ProposerLookahead + + sszVarOffset7 := ssz.ReadOffset(buf[4272:4276]) // c.HistoricalRoots + if sszVarOffset7 != 10441 { + return ssz.ErrInvalidVariableOffset } - if err = b.Fork.UnmarshalSSZ(buf[48:64]); err != nil { - return err + if sszVarOffset7 > size { + return ssz.ErrOffset } - - // Field (4) 'LatestBlockHeader' - if b.LatestBlockHeader == nil { - b.LatestBlockHeader = new(BeaconBlockHeader) + sszVarOffset9 := ssz.ReadOffset(buf[4348:4352]) // c.Eth1DataVotes + if sszVarOffset9 > size || sszVarOffset9 < sszVarOffset7 { + return ssz.ErrOffset } - if err = b.LatestBlockHeader.UnmarshalSSZ(buf[64:176]); err != nil { - return err + sszVarOffset11 := ssz.ReadOffset(buf[4360:4364]) // c.Validators + if sszVarOffset11 > size || sszVarOffset11 < sszVarOffset9 { + return ssz.ErrOffset } - - // Field (5) 'BlockRoots' - b.BlockRoots = make([][]byte, 64) - for ii := 0; ii < 64; ii++ { - if cap(b.BlockRoots[ii]) == 0 { - b.BlockRoots[ii] = make([]byte, 0, len(buf[176:2224][ii*32:(ii+1)*32])) - } - b.BlockRoots[ii] = append(b.BlockRoots[ii], buf[176:2224][ii*32:(ii+1)*32]...) + sszVarOffset12 := ssz.ReadOffset(buf[4364:4368]) // c.Balances + if sszVarOffset12 > size || sszVarOffset12 < sszVarOffset11 { + return ssz.ErrOffset } - - // Field (6) 'StateRoots' - b.StateRoots = make([][]byte, 64) - for ii := 0; ii < 64; ii++ { - if cap(b.StateRoots[ii]) == 0 { - b.StateRoots[ii] = make([]byte, 0, len(buf[2224:4272][ii*32:(ii+1)*32])) - } - b.StateRoots[ii] = append(b.StateRoots[ii], buf[2224:4272][ii*32:(ii+1)*32]...) + sszVarOffset15 := ssz.ReadOffset(buf[6928:6932]) // c.PreviousEpochParticipation + if sszVarOffset15 > size || sszVarOffset15 < sszVarOffset12 { + return ssz.ErrOffset } - - // Offset (7) 'HistoricalRoots' - if o7 = ssz.ReadOffset(buf[4272:4276]); o7 > size { + sszVarOffset16 := ssz.ReadOffset(buf[6932:6936]) // c.CurrentEpochParticipation + if sszVarOffset16 > size || sszVarOffset16 < sszVarOffset15 { return ssz.ErrOffset } - - if o7 != 10441 { - return ssz.ErrInvalidVariableOffset + sszVarOffset21 := ssz.ReadOffset(buf[7057:7061]) // c.InactivityScores + if sszVarOffset21 > size || sszVarOffset21 < sszVarOffset16 { + return ssz.ErrOffset } - - // Field (8) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(Eth1Data) + sszVarOffset24 := ssz.ReadOffset(buf[10229:10233]) // c.LatestExecutionPayloadHeader + if sszVarOffset24 > size || sszVarOffset24 < sszVarOffset21 { + return ssz.ErrOffset } - if err = b.Eth1Data.UnmarshalSSZ(buf[4276:4348]); err != nil { - return err + sszVarOffset27 := ssz.ReadOffset(buf[10249:10253]) // c.HistoricalSummaries + if sszVarOffset27 > size || sszVarOffset27 < sszVarOffset24 { + return ssz.ErrOffset } - - // Offset (9) 'Eth1DataVotes' - if o9 = ssz.ReadOffset(buf[4348:4352]); o9 > size || o7 > o9 { + sszVarOffset34 := ssz.ReadOffset(buf[10301:10305]) // c.PendingDeposits + if sszVarOffset34 > size || sszVarOffset34 < sszVarOffset27 { return ssz.ErrOffset } - - // Field (10) 'Eth1DepositIndex' - b.Eth1DepositIndex = ssz.UnmarshallUint[uint64](buf[4352:4360]) - - // Offset (11) 'Validators' - if o11 = ssz.ReadOffset(buf[4360:4364]); o11 > size || o9 > o11 { + sszVarOffset35 := ssz.ReadOffset(buf[10305:10309]) // c.PendingPartialWithdrawals + if sszVarOffset35 > size || sszVarOffset35 < sszVarOffset34 { return ssz.ErrOffset } - - // Offset (12) 'Balances' - if o12 = ssz.ReadOffset(buf[4364:4368]); o12 > size || o11 > o12 { + sszVarOffset36 := ssz.ReadOffset(buf[10309:10313]) // c.PendingConsolidations + if sszVarOffset36 > size || sszVarOffset36 < sszVarOffset35 { return ssz.ErrOffset } + sszSlice7 := buf[sszVarOffset7:sszVarOffset9] // c.HistoricalRoots + sszSlice9 := buf[sszVarOffset9:sszVarOffset11] // c.Eth1DataVotes + sszSlice11 := buf[sszVarOffset11:sszVarOffset12] // c.Validators + sszSlice12 := buf[sszVarOffset12:sszVarOffset15] // c.Balances + sszSlice15 := buf[sszVarOffset15:sszVarOffset16] // c.PreviousEpochParticipation + sszSlice16 := buf[sszVarOffset16:sszVarOffset21] // c.CurrentEpochParticipation + sszSlice21 := buf[sszVarOffset21:sszVarOffset24] // c.InactivityScores + sszSlice24 := buf[sszVarOffset24:sszVarOffset27] // c.LatestExecutionPayloadHeader + sszSlice27 := buf[sszVarOffset27:sszVarOffset34] // c.HistoricalSummaries + sszSlice34 := buf[sszVarOffset34:sszVarOffset35] // c.PendingDeposits + sszSlice35 := buf[sszVarOffset35:sszVarOffset36] // c.PendingPartialWithdrawals + sszSlice36 := buf[sszVarOffset36:] // c.PendingConsolidations - // Field (13) 'RandaoMixes' - b.RandaoMixes = make([][]byte, 64) - for ii := 0; ii < 64; ii++ { - if cap(b.RandaoMixes[ii]) == 0 { - b.RandaoMixes[ii] = make([]byte, 0, len(buf[4368:6416][ii*32:(ii+1)*32])) - } - b.RandaoMixes[ii] = append(b.RandaoMixes[ii], buf[4368:6416][ii*32:(ii+1)*32]...) - } + // Field 0: GenesisTime + c.GenesisTime = binary.LittleEndian.Uint64(sszSlice0) - // Field (14) 'Slashings' - b.Slashings = ssz.ExtendUint(b.Slashings, 64) - for ii := 0; ii < 64; ii++ { - b.Slashings[ii] = ssz.UnmarshallUint[uint64](buf[6416:6928][ii*8 : (ii+1)*8]) - } + // Field 1: GenesisValidatorsRoot + c.GenesisValidatorsRoot = make([]byte, 0, 32) + c.GenesisValidatorsRoot = append(c.GenesisValidatorsRoot, sszSlice1...) - // Offset (15) 'PreviousEpochParticipation' - if o15 = ssz.ReadOffset(buf[6928:6932]); o15 > size || o12 > o15 { - return ssz.ErrOffset + // Field 2: Slot + if err = c.Slot.UnmarshalSSZ(sszSlice2); err != nil { + return fmt.Errorf("Slot: %w", err) } - // Offset (16) 'CurrentEpochParticipation' - if o16 = ssz.ReadOffset(buf[6932:6936]); o16 > size || o15 > o16 { - return ssz.ErrOffset + // Field 3: Fork + c.Fork = new(Fork) + if err = c.Fork.UnmarshalSSZ(sszSlice3); err != nil { + return fmt.Errorf("Fork: %w", err) } - // Field (17) 'JustificationBits' - if cap(b.JustificationBits) == 0 { - b.JustificationBits = make([]byte, 0, len(buf[6936:6937])) + // Field 4: LatestBlockHeader + c.LatestBlockHeader = new(BeaconBlockHeader) + if err = c.LatestBlockHeader.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("LatestBlockHeader: %w", err) } - b.JustificationBits = append(b.JustificationBits, buf[6936:6937]...) - // Field (18) 'PreviousJustifiedCheckpoint' - if b.PreviousJustifiedCheckpoint == nil { - b.PreviousJustifiedCheckpoint = new(Checkpoint) - } - if err = b.PreviousJustifiedCheckpoint.UnmarshalSSZ(buf[6937:6977]); err != nil { - return err - } + // Field 5: BlockRoots + { + c.BlockRoots = make([][]byte, 64) + for i := 0; i < 64; i++ { + var tmp []byte - // Field (19) 'CurrentJustifiedCheckpoint' - if b.CurrentJustifiedCheckpoint == nil { - b.CurrentJustifiedCheckpoint = new(Checkpoint) - } - if err = b.CurrentJustifiedCheckpoint.UnmarshalSSZ(buf[6977:7017]); err != nil { - return err + tmpSlice := sszSlice5[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.BlockRoots[i] = tmp + } } - // Field (20) 'FinalizedCheckpoint' - if b.FinalizedCheckpoint == nil { - b.FinalizedCheckpoint = new(Checkpoint) - } - if err = b.FinalizedCheckpoint.UnmarshalSSZ(buf[7017:7057]); err != nil { - return err - } + // Field 6: StateRoots + { + c.StateRoots = make([][]byte, 64) + for i := 0; i < 64; i++ { + var tmp []byte - // Offset (21) 'InactivityScores' - if o21 = ssz.ReadOffset(buf[7057:7061]); o21 > size || o16 > o21 { - return ssz.ErrOffset + tmpSlice := sszSlice6[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.StateRoots[i] = tmp + } } - // Field (22) 'CurrentSyncCommittee' - if b.CurrentSyncCommittee == nil { - b.CurrentSyncCommittee = new(SyncCommittee) - } - if err = b.CurrentSyncCommittee.UnmarshalSSZ(buf[7061:8645]); err != nil { - return err + // Field 7: HistoricalRoots + { + if len(sszSlice7)%32 != 0 { + return fmt.Errorf("misaligned bytes: c.HistoricalRoots length is %d, which is not a multiple of 32: %w", len(sszSlice7), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice7) / 32 + if numElem > 16777216 { + return fmt.Errorf("ssz-max exceeded: c.HistoricalRoots has %d elements, ssz-max is 16777216: %w", numElem, ssz.ErrListTooBig) + } + c.HistoricalRoots = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte + + tmpSlice := sszSlice7[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.HistoricalRoots[i] = tmp + } } - // Field (23) 'NextSyncCommittee' - if b.NextSyncCommittee == nil { - b.NextSyncCommittee = new(SyncCommittee) + // Field 8: Eth1Data + c.Eth1Data = new(Eth1Data) + if err = c.Eth1Data.UnmarshalSSZ(sszSlice8); err != nil { + return fmt.Errorf("Eth1Data: %w", err) } - if err = b.NextSyncCommittee.UnmarshalSSZ(buf[8645:10229]); err != nil { - return err + + // Field 9: Eth1DataVotes + { + if len(sszSlice9)%72 != 0 { + return fmt.Errorf("misaligned bytes: c.Eth1DataVotes length is %d, which is not a multiple of 72: %w", len(sszSlice9), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice9) / 72 + if numElem > 32 { + return fmt.Errorf("ssz-max exceeded: c.Eth1DataVotes has %d elements, ssz-max is 32: %w", numElem, ssz.ErrListTooBig) + } + c.Eth1DataVotes = make([]*Eth1Data, numElem) + for i := 0; i < numElem; i++ { + var tmp *Eth1Data + tmp = new(Eth1Data) + tmpSlice := sszSlice9[i*72 : (1+i)*72] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Eth1DataVotes: %w", err) + } + c.Eth1DataVotes[i] = tmp + } } - // Offset (24) 'LatestExecutionPayloadHeader' - if o24 = ssz.ReadOffset(buf[10229:10233]); o24 > size || o21 > o24 { - return ssz.ErrOffset + // Field 10: Eth1DepositIndex + c.Eth1DepositIndex = binary.LittleEndian.Uint64(sszSlice10) + + // Field 11: Validators + { + if len(sszSlice11)%121 != 0 { + return fmt.Errorf("misaligned bytes: c.Validators length is %d, which is not a multiple of 121: %w", len(sszSlice11), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice11) / 121 + if numElem > 1099511627776 { + return fmt.Errorf("ssz-max exceeded: c.Validators has %d elements, ssz-max is 1099511627776: %w", numElem, ssz.ErrListTooBig) + } + c.Validators = make([]*Validator, numElem) + for i := 0; i < numElem; i++ { + var tmp *Validator + tmp = new(Validator) + tmpSlice := sszSlice11[i*121 : (1+i)*121] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Validators: %w", err) + } + c.Validators[i] = tmp + } } - // Field (25) 'NextWithdrawalIndex' - b.NextWithdrawalIndex = ssz.UnmarshallUint[uint64](buf[10233:10241]) + // Field 12: Balances + { + if len(sszSlice12)%8 != 0 { + return fmt.Errorf("misaligned bytes: c.Balances length is %d, which is not a multiple of 8: %w", len(sszSlice12), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice12) / 8 + if numElem > 1099511627776 { + return fmt.Errorf("ssz-max exceeded: c.Balances has %d elements, ssz-max is 1099511627776: %w", numElem, ssz.ErrListTooBig) + } + c.Balances = make([]uint64, numElem) + for i := 0; i < numElem; i++ { + var tmp uint64 - // Field (26) 'NextWithdrawalValidatorIndex' - b.NextWithdrawalValidatorIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[10241:10249]) + tmpSlice := sszSlice12[i*8 : (1+i)*8] + tmp = binary.LittleEndian.Uint64(tmpSlice) + c.Balances[i] = tmp + } + } - // Offset (27) 'HistoricalSummaries' - if o27 = ssz.ReadOffset(buf[10249:10253]); o27 > size || o24 > o27 { - return ssz.ErrOffset + // Field 13: RandaoMixes + { + c.RandaoMixes = make([][]byte, 64) + for i := 0; i < 64; i++ { + var tmp []byte + + tmpSlice := sszSlice13[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.RandaoMixes[i] = tmp + } } - // Field (28) 'DepositRequestsStartIndex' - b.DepositRequestsStartIndex = ssz.UnmarshallUint[uint64](buf[10253:10261]) + // Field 14: Slashings + { + c.Slashings = make([]uint64, 64) + for i := 0; i < 64; i++ { + var tmp uint64 + + tmpSlice := sszSlice14[i*8 : (1+i)*8] + tmp = binary.LittleEndian.Uint64(tmpSlice) + c.Slashings[i] = tmp + } + } - // Field (29) 'DepositBalanceToConsume' - b.DepositBalanceToConsume = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Gwei](buf[10261:10269]) + // Field 15: PreviousEpochParticipation + c.PreviousEpochParticipation = append([]byte{}, sszSlice15...) - // Field (30) 'ExitBalanceToConsume' - b.ExitBalanceToConsume = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Gwei](buf[10269:10277]) + // Field 16: CurrentEpochParticipation + c.CurrentEpochParticipation = append([]byte{}, sszSlice16...) - // Field (31) 'EarliestExitEpoch' - b.EarliestExitEpoch = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Epoch](buf[10277:10285]) + // Field 17: JustificationBits + c.JustificationBits = make([]byte, 0, 1) + c.JustificationBits = append(c.JustificationBits, go_bitfield.Bitvector4(sszSlice17)...) - // Field (32) 'ConsolidationBalanceToConsume' - b.ConsolidationBalanceToConsume = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Gwei](buf[10285:10293]) + // Field 18: PreviousJustifiedCheckpoint + c.PreviousJustifiedCheckpoint = new(Checkpoint) + if err = c.PreviousJustifiedCheckpoint.UnmarshalSSZ(sszSlice18); err != nil { + return fmt.Errorf("PreviousJustifiedCheckpoint: %w", err) + } - // Field (33) 'EarliestConsolidationEpoch' - b.EarliestConsolidationEpoch = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Epoch](buf[10293:10301]) + // Field 19: CurrentJustifiedCheckpoint + c.CurrentJustifiedCheckpoint = new(Checkpoint) + if err = c.CurrentJustifiedCheckpoint.UnmarshalSSZ(sszSlice19); err != nil { + return fmt.Errorf("CurrentJustifiedCheckpoint: %w", err) + } - // Offset (34) 'PendingDeposits' - if o34 = ssz.ReadOffset(buf[10301:10305]); o34 > size || o27 > o34 { - return ssz.ErrOffset + // Field 20: FinalizedCheckpoint + c.FinalizedCheckpoint = new(Checkpoint) + if err = c.FinalizedCheckpoint.UnmarshalSSZ(sszSlice20); err != nil { + return fmt.Errorf("FinalizedCheckpoint: %w", err) } - // Offset (35) 'PendingPartialWithdrawals' - if o35 = ssz.ReadOffset(buf[10305:10309]); o35 > size || o34 > o35 { - return ssz.ErrOffset + // Field 21: InactivityScores + { + if len(sszSlice21)%8 != 0 { + return fmt.Errorf("misaligned bytes: c.InactivityScores length is %d, which is not a multiple of 8: %w", len(sszSlice21), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice21) / 8 + if numElem > 1099511627776 { + return fmt.Errorf("ssz-max exceeded: c.InactivityScores has %d elements, ssz-max is 1099511627776: %w", numElem, ssz.ErrListTooBig) + } + c.InactivityScores = make([]uint64, numElem) + for i := 0; i < numElem; i++ { + var tmp uint64 + + tmpSlice := sszSlice21[i*8 : (1+i)*8] + tmp = binary.LittleEndian.Uint64(tmpSlice) + c.InactivityScores[i] = tmp + } } - // Offset (36) 'PendingConsolidations' - if o36 = ssz.ReadOffset(buf[10309:10313]); o36 > size || o35 > o36 { - return ssz.ErrOffset + // Field 22: CurrentSyncCommittee + c.CurrentSyncCommittee = new(SyncCommittee) + if err = c.CurrentSyncCommittee.UnmarshalSSZ(sszSlice22); err != nil { + return fmt.Errorf("CurrentSyncCommittee: %w", err) } - // Field (37) 'ProposerLookahead' - b.ProposerLookahead = ssz.ExtendUint(b.ProposerLookahead, 16) - for ii := 0; ii < 16; ii++ { - b.ProposerLookahead[ii] = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[10313:10441][ii*8 : (ii+1)*8]) + // Field 23: NextSyncCommittee + c.NextSyncCommittee = new(SyncCommittee) + if err = c.NextSyncCommittee.UnmarshalSSZ(sszSlice23); err != nil { + return fmt.Errorf("NextSyncCommittee: %w", err) } - // 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 24: LatestExecutionPayloadHeader + c.LatestExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderDeneb) + if err = c.LatestExecutionPayloadHeader.UnmarshalSSZ(sszSlice24); err != nil { + return fmt.Errorf("LatestExecutionPayloadHeader: %w", err) } - // Field (9) 'Eth1DataVotes' - { - buf = tail[o9:o11] - num, err := ssz.DivideInt2(len(buf), 72, 32) - if err != nil { - return err - } - b.Eth1DataVotes = make([]*Eth1Data, num) - for ii := 0; ii < num; ii++ { - if b.Eth1DataVotes[ii] == nil { - b.Eth1DataVotes[ii] = new(Eth1Data) - } - if err = b.Eth1DataVotes[ii].UnmarshalSSZ(buf[ii*72 : (ii+1)*72]); err != nil { - return err - } - } + // Field 25: NextWithdrawalIndex + c.NextWithdrawalIndex = binary.LittleEndian.Uint64(sszSlice25) + + // Field 26: NextWithdrawalValidatorIndex + if err = c.NextWithdrawalValidatorIndex.UnmarshalSSZ(sszSlice26); err != nil { + return fmt.Errorf("NextWithdrawalValidatorIndex: %w", err) } - // Field (11) 'Validators' + // Field 27: HistoricalSummaries { - buf = tail[o11:o12] - num, err := ssz.DivideInt2(len(buf), 121, 1099511627776) - if err != nil { - return err - } - b.Validators = make([]*Validator, num) - for ii := 0; ii < num; ii++ { - if b.Validators[ii] == nil { - b.Validators[ii] = new(Validator) - } - if err = b.Validators[ii].UnmarshalSSZ(buf[ii*121 : (ii+1)*121]); err != nil { - return err + if len(sszSlice27)%64 != 0 { + return fmt.Errorf("misaligned bytes: c.HistoricalSummaries length is %d, which is not a multiple of 64: %w", len(sszSlice27), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice27) / 64 + if numElem > 16777216 { + return fmt.Errorf("ssz-max exceeded: c.HistoricalSummaries has %d elements, ssz-max is 16777216: %w", numElem, ssz.ErrListTooBig) + } + c.HistoricalSummaries = make([]*HistoricalSummary, numElem) + for i := 0; i < numElem; i++ { + var tmp *HistoricalSummary + tmp = new(HistoricalSummary) + tmpSlice := sszSlice27[i*64 : (1+i)*64] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("HistoricalSummaries: %w", err) } + c.HistoricalSummaries[i] = tmp } } - // Field (12) 'Balances' - { - buf = tail[o12:o15] - num, err := ssz.DivideInt2(len(buf), 8, 1099511627776) - if err != nil { - return err - } - b.Balances = ssz.ExtendUint(b.Balances, num) - for ii := 0; ii < num; ii++ { - b.Balances[ii] = ssz.UnmarshallUint[uint64](buf[ii*8 : (ii+1)*8]) - } + // Field 28: DepositRequestsStartIndex + c.DepositRequestsStartIndex = binary.LittleEndian.Uint64(sszSlice28) + + // Field 29: DepositBalanceToConsume + if err = c.DepositBalanceToConsume.UnmarshalSSZ(sszSlice29); err != nil { + return fmt.Errorf("DepositBalanceToConsume: %w", err) } - // 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 30: ExitBalanceToConsume + if err = c.ExitBalanceToConsume.UnmarshalSSZ(sszSlice30); err != nil { + return fmt.Errorf("ExitBalanceToConsume: %w", err) } - // 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 31: EarliestExitEpoch + if err = c.EarliestExitEpoch.UnmarshalSSZ(sszSlice31); err != nil { + return fmt.Errorf("EarliestExitEpoch: %w", err) } - // Field (21) 'InactivityScores' - { - buf = tail[o21:o24] - num, err := ssz.DivideInt2(len(buf), 8, 1099511627776) - if err != nil { - return err - } - b.InactivityScores = ssz.ExtendUint(b.InactivityScores, num) - for ii := 0; ii < num; ii++ { - b.InactivityScores[ii] = ssz.UnmarshallUint[uint64](buf[ii*8 : (ii+1)*8]) - } + // Field 32: ConsolidationBalanceToConsume + if err = c.ConsolidationBalanceToConsume.UnmarshalSSZ(sszSlice32); err != nil { + return fmt.Errorf("ConsolidationBalanceToConsume: %w", err) } - // Field (24) 'LatestExecutionPayloadHeader' - { - buf = tail[o24:o27] - if b.LatestExecutionPayloadHeader == nil { - b.LatestExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderDeneb) - } - if err = b.LatestExecutionPayloadHeader.UnmarshalSSZ(buf); err != nil { - return err - } + // Field 33: EarliestConsolidationEpoch + if err = c.EarliestConsolidationEpoch.UnmarshalSSZ(sszSlice33); err != nil { + return fmt.Errorf("EarliestConsolidationEpoch: %w", err) } - // Field (27) 'HistoricalSummaries' + // Field 34: PendingDeposits { - buf = tail[o27:o34] - num, err := ssz.DivideInt2(len(buf), 64, 16777216) - if err != nil { - return err - } - b.HistoricalSummaries = make([]*HistoricalSummary, num) - for ii := 0; ii < num; ii++ { - if b.HistoricalSummaries[ii] == nil { - b.HistoricalSummaries[ii] = new(HistoricalSummary) - } - if err = b.HistoricalSummaries[ii].UnmarshalSSZ(buf[ii*64 : (ii+1)*64]); err != nil { - return err + if len(sszSlice34)%192 != 0 { + return fmt.Errorf("misaligned bytes: c.PendingDeposits length is %d, which is not a multiple of 192: %w", len(sszSlice34), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice34) / 192 + if numElem > 134217728 { + return fmt.Errorf("ssz-max exceeded: c.PendingDeposits has %d elements, ssz-max is 134217728: %w", numElem, ssz.ErrListTooBig) + } + c.PendingDeposits = make([]*PendingDeposit, numElem) + for i := 0; i < numElem; i++ { + var tmp *PendingDeposit + tmp = new(PendingDeposit) + tmpSlice := sszSlice34[i*192 : (1+i)*192] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("PendingDeposits: %w", err) } + c.PendingDeposits[i] = tmp } } - // Field (34) 'PendingDeposits' + // Field 35: PendingPartialWithdrawals { - buf = tail[o34:o35] - num, err := ssz.DivideInt2(len(buf), 192, 134217728) - if err != nil { - return err - } - b.PendingDeposits = make([]*PendingDeposit, num) - for ii := 0; ii < num; ii++ { - if b.PendingDeposits[ii] == nil { - b.PendingDeposits[ii] = new(PendingDeposit) - } - if err = b.PendingDeposits[ii].UnmarshalSSZ(buf[ii*192 : (ii+1)*192]); err != nil { - return err + if len(sszSlice35)%24 != 0 { + return fmt.Errorf("misaligned bytes: c.PendingPartialWithdrawals length is %d, which is not a multiple of 24: %w", len(sszSlice35), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice35) / 24 + if numElem > 64 { + return fmt.Errorf("ssz-max exceeded: c.PendingPartialWithdrawals has %d elements, ssz-max is 64: %w", numElem, ssz.ErrListTooBig) + } + c.PendingPartialWithdrawals = make([]*PendingPartialWithdrawal, numElem) + for i := 0; i < numElem; i++ { + var tmp *PendingPartialWithdrawal + tmp = new(PendingPartialWithdrawal) + tmpSlice := sszSlice35[i*24 : (1+i)*24] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("PendingPartialWithdrawals: %w", err) } + c.PendingPartialWithdrawals[i] = tmp } } - // Field (35) 'PendingPartialWithdrawals' + // Field 36: PendingConsolidations { - buf = tail[o35:o36] - num, err := ssz.DivideInt2(len(buf), 24, 64) - if err != nil { - return err - } - b.PendingPartialWithdrawals = make([]*PendingPartialWithdrawal, num) - for ii := 0; ii < num; ii++ { - if b.PendingPartialWithdrawals[ii] == nil { - b.PendingPartialWithdrawals[ii] = new(PendingPartialWithdrawal) - } - if err = b.PendingPartialWithdrawals[ii].UnmarshalSSZ(buf[ii*24 : (ii+1)*24]); err != nil { - return err + if len(sszSlice36)%16 != 0 { + return fmt.Errorf("misaligned bytes: c.PendingConsolidations length is %d, which is not a multiple of 16: %w", len(sszSlice36), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice36) / 16 + if numElem > 64 { + return fmt.Errorf("ssz-max exceeded: c.PendingConsolidations has %d elements, ssz-max is 64: %w", numElem, ssz.ErrListTooBig) + } + c.PendingConsolidations = make([]*PendingConsolidation, numElem) + for i := 0; i < numElem; i++ { + var tmp *PendingConsolidation + tmp = new(PendingConsolidation) + tmpSlice := sszSlice36[i*16 : (1+i)*16] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("PendingConsolidations: %w", err) } + c.PendingConsolidations[i] = tmp } } - // Field (36) 'PendingConsolidations' + // Field 37: ProposerLookahead { - buf = tail[o36:] - num, err := ssz.DivideInt2(len(buf), 16, 64) - if err != nil { - return err - } - b.PendingConsolidations = make([]*PendingConsolidation, num) - for ii := 0; ii < num; ii++ { - if b.PendingConsolidations[ii] == nil { - b.PendingConsolidations[ii] = new(PendingConsolidation) - } - if err = b.PendingConsolidations[ii].UnmarshalSSZ(buf[ii*16 : (ii+1)*16]); err != nil { - return err + c.ProposerLookahead = make([]primitives.ValidatorIndex, 16) + for i := 0; i < 16; i++ { + var tmp primitives.ValidatorIndex + + tmpSlice := sszSlice37[i*8 : (1+i)*8] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("ProposerLookahead: %w", err) } + c.ProposerLookahead[i] = tmp } } return err } -// SizeSSZ returns the ssz encoded size in bytes for the BeaconStateFulu object -func (b *BeaconStateFulu) SizeSSZ() (size int) { - size = 10441 - - // 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(v1.ExecutionPayloadHeaderDeneb) +func (c *BeaconStateFulu) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - 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 BeaconStateFulu object -func (b *BeaconStateFulu) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the BeaconStateFulu object with a hasher -func (b *BeaconStateFulu) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *BeaconStateFulu) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'GenesisTime' - ssz.PutUint(hh, b.GenesisTime) - - // Field (1) 'GenesisValidatorsRoot' - if size := len(b.GenesisValidatorsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.GenesisValidatorsRoot", size, 32) - return - } - hh.PutBytes(b.GenesisValidatorsRoot) - - // Field (2) 'Slot' - ssz.PutUint(hh, b.Slot) - - // Field (3) 'Fork' - if err = b.Fork.HashTreeRootWith(hh); err != nil { - return - } - - // Field (4) 'LatestBlockHeader' - if err = b.LatestBlockHeader.HashTreeRootWith(hh); err != nil { - return - } - - // Field (5) 'BlockRoots' + // Field 0: GenesisTime + hh.PutUint64(c.GenesisTime) + // Field 1: GenesisValidatorsRoot + if len(c.GenesisValidatorsRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.GenesisValidatorsRoot) + // Field 2: Slot + if err := c.Slot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Slot: %w", err) + } + // Field 3: Fork + if err := c.Fork.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Fork: %w", err) + } + // Field 4: LatestBlockHeader + if err := c.LatestBlockHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("LatestBlockHeader: %w", err) + } + // Field 5: BlockRoots { - if size := len(b.BlockRoots); size != 64 { - err = ssz.ErrVectorLengthFn("--.BlockRoots", size, 64) - return + if len(c.BlockRoots) != 64 { + return ssz.ErrVectorLength } subIndx := hh.Index() - for _, i := range b.BlockRoots { - if len(i) != 32 { - err = ssz.ErrBytesLength - return + for _, o := range c.BlockRoots { + if len(o) != 32 { + return ssz.ErrBytesLength } - hh.Append(i) + hh.Append(o) } hh.Merkleize(subIndx) } - - // Field (6) 'StateRoots' + // Field 6: StateRoots { - if size := len(b.StateRoots); size != 64 { - err = ssz.ErrVectorLengthFn("--.StateRoots", size, 64) - return + if len(c.StateRoots) != 64 { + return ssz.ErrVectorLength } subIndx := hh.Index() - for _, i := range b.StateRoots { - if len(i) != 32 { - err = ssz.ErrBytesLength - return + for _, o := range c.StateRoots { + if len(o) != 32 { + return ssz.ErrBytesLength } - hh.Append(i) + hh.Append(o) } hh.Merkleize(subIndx) } - - // Field (7) 'HistoricalRoots' + // Field 7: HistoricalRoots { - if size := len(b.HistoricalRoots); size > 16777216 { - err = ssz.ErrListTooBigFn("--.HistoricalRoots", size, 16777216) - return + if len(c.HistoricalRoots) > 16777216 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range b.HistoricalRoots { - if len(i) != 32 { - err = ssz.ErrBytesLength - return + for _, o := range c.HistoricalRoots { + if len(o) != 32 { + return ssz.ErrBytesLength } - hh.Append(i) + hh.Append(o) } - - numItems := uint64(len(b.HistoricalRoots)) - hh.MerkleizeWithMixin(subIndx, numItems, 16777216) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.HistoricalRoots)), 16777216) } - - // Field (8) 'Eth1Data' - if err = b.Eth1Data.HashTreeRootWith(hh); err != nil { - return + // Field 8: Eth1Data + if err := c.Eth1Data.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Eth1Data: %w", err) } - - // Field (9) 'Eth1DataVotes' + // Field 9: Eth1DataVotes { + if len(c.Eth1DataVotes) > 32 { + return ssz.ErrListTooBig + } subIndx := hh.Index() - num := uint64(len(b.Eth1DataVotes)) - if num > 32 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range b.Eth1DataVotes { - if err = elem.HashTreeRootWith(hh); err != nil { - return + for _, o := range c.Eth1DataVotes { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Eth1DataVotes: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 32) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Eth1DataVotes)), 32) } - - // Field (10) 'Eth1DepositIndex' - ssz.PutUint(hh, b.Eth1DepositIndex) - - // Field (11) 'Validators' + // Field 10: Eth1DepositIndex + hh.PutUint64(c.Eth1DepositIndex) + // Field 11: Validators { + if len(c.Validators) > 1099511627776 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.Validators { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Validators: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 1099511627776) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Validators)), 1099511627776) } - - // Field (12) 'Balances' + // Field 12: Balances { - if size := len(b.Balances); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.Balances", size, 1099511627776) - return + if len(c.Balances) > 1099511627776 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range b.Balances { - ssz.AppendUint(hh, i) + for _, o := range c.Balances { + hh.AppendUint64(o) } hh.FillUpTo32() - - numItems := uint64(len(b.Balances)) + numItems := uint64(len(c.Balances)) hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(1099511627776, numItems, 8)) } - - // Field (13) 'RandaoMixes' + // Field 13: RandaoMixes { - if size := len(b.RandaoMixes); size != 64 { - err = ssz.ErrVectorLengthFn("--.RandaoMixes", size, 64) - return + if len(c.RandaoMixes) != 64 { + return ssz.ErrVectorLength } subIndx := hh.Index() - for _, i := range b.RandaoMixes { - if len(i) != 32 { - err = ssz.ErrBytesLength - return + for _, o := range c.RandaoMixes { + if len(o) != 32 { + return ssz.ErrBytesLength } - hh.Append(i) + hh.Append(o) } hh.Merkleize(subIndx) } - - // Field (14) 'Slashings' + // Field 14: Slashings { - if size := len(b.Slashings); size != 64 { - err = ssz.ErrVectorLengthFn("--.Slashings", size, 64) - return + if len(c.Slashings) != 64 { + return ssz.ErrVectorLength } subIndx := hh.Index() - for _, i := range b.Slashings { - ssz.AppendUint(hh, i) + for _, o := range c.Slashings { + hh.AppendUint64(o) } hh.Merkleize(subIndx) } + // Field 15: PreviousEpochParticipation - // Field (15) 'PreviousEpochParticipation' { - elemIndx := hh.Index() - byteLen := uint64(len(b.PreviousEpochParticipation)) - if byteLen > 1099511627776 { - err = ssz.ErrIncorrectListSize - return + if len(c.PreviousEpochParticipation) > 1099511627776 { + return ssz.ErrBytesLength } - hh.AppendBytes32(b.PreviousEpochParticipation) - hh.MerkleizeWithMixin(elemIndx, byteLen, (1099511627776+31)/32) + subIndx := hh.Index() + hh.AppendBytes32(c.PreviousEpochParticipation) + numItems := uint64(len(c.PreviousEpochParticipation)) + hh.MerkleizeWithMixin(subIndx, numItems, (1099511627776*1+31)/32) } - // Field (16) 'CurrentEpochParticipation' + // Field 16: CurrentEpochParticipation + { - elemIndx := hh.Index() - byteLen := uint64(len(b.CurrentEpochParticipation)) - if byteLen > 1099511627776 { - err = ssz.ErrIncorrectListSize - return + if len(c.CurrentEpochParticipation) > 1099511627776 { + return ssz.ErrBytesLength } - hh.AppendBytes32(b.CurrentEpochParticipation) - hh.MerkleizeWithMixin(elemIndx, byteLen, (1099511627776+31)/32) + subIndx := hh.Index() + hh.AppendBytes32(c.CurrentEpochParticipation) + numItems := uint64(len(c.CurrentEpochParticipation)) + hh.MerkleizeWithMixin(subIndx, numItems, (1099511627776*1+31)/32) } - // Field (17) 'JustificationBits' - if size := len(b.JustificationBits); size != 1 { - err = ssz.ErrBytesLengthFn("--.JustificationBits", size, 1) - return + // Field 17: JustificationBits + if len([]byte(c.JustificationBits)) != 1 { + return ssz.ErrBytesLength } - hh.PutBytes(b.JustificationBits) - - // Field (18) 'PreviousJustifiedCheckpoint' - if err = b.PreviousJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { - return + hh.PutBytes([]byte(c.JustificationBits)) + // Field 18: PreviousJustifiedCheckpoint + if err := c.PreviousJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("PreviousJustifiedCheckpoint: %w", err) } - - // Field (19) 'CurrentJustifiedCheckpoint' - if err = b.CurrentJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { - return + // Field 19: CurrentJustifiedCheckpoint + if err := c.CurrentJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("CurrentJustifiedCheckpoint: %w", err) } - - // Field (20) 'FinalizedCheckpoint' - if err = b.FinalizedCheckpoint.HashTreeRootWith(hh); err != nil { - return + // Field 20: FinalizedCheckpoint + if err := c.FinalizedCheckpoint.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("FinalizedCheckpoint: %w", err) } - - // Field (21) 'InactivityScores' + // Field 21: InactivityScores { - if size := len(b.InactivityScores); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.InactivityScores", size, 1099511627776) - return + if len(c.InactivityScores) > 1099511627776 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range b.InactivityScores { - ssz.AppendUint(hh, i) + for _, o := range c.InactivityScores { + hh.AppendUint64(o) } hh.FillUpTo32() - - numItems := uint64(len(b.InactivityScores)) + numItems := uint64(len(c.InactivityScores)) hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(1099511627776, numItems, 8)) } - - // Field (22) 'CurrentSyncCommittee' - if err = b.CurrentSyncCommittee.HashTreeRootWith(hh); err != nil { - return + // Field 22: CurrentSyncCommittee + if err := c.CurrentSyncCommittee.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("CurrentSyncCommittee: %w", err) } - - // Field (23) 'NextSyncCommittee' - if err = b.NextSyncCommittee.HashTreeRootWith(hh); err != nil { - return + // Field 23: NextSyncCommittee + if err := c.NextSyncCommittee.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("NextSyncCommittee: %w", err) } - - // Field (24) 'LatestExecutionPayloadHeader' - if err = b.LatestExecutionPayloadHeader.HashTreeRootWith(hh); err != nil { - return + // Field 24: LatestExecutionPayloadHeader + if err := c.LatestExecutionPayloadHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("LatestExecutionPayloadHeader: %w", err) } - - // Field (25) 'NextWithdrawalIndex' - ssz.PutUint(hh, b.NextWithdrawalIndex) - - // Field (26) 'NextWithdrawalValidatorIndex' - ssz.PutUint(hh, b.NextWithdrawalValidatorIndex) - - // Field (27) 'HistoricalSummaries' + // Field 25: NextWithdrawalIndex + hh.PutUint64(c.NextWithdrawalIndex) + // Field 26: NextWithdrawalValidatorIndex + if err := c.NextWithdrawalValidatorIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("NextWithdrawalValidatorIndex: %w", err) + } + // Field 27: HistoricalSummaries { + if len(c.HistoricalSummaries) > 16777216 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.HistoricalSummaries { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("HistoricalSummaries: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 16777216) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.HistoricalSummaries)), 16777216) } - - // Field (28) 'DepositRequestsStartIndex' - ssz.PutUint(hh, b.DepositRequestsStartIndex) - - // Field (29) 'DepositBalanceToConsume' - ssz.PutUint(hh, b.DepositBalanceToConsume) - - // Field (30) 'ExitBalanceToConsume' - ssz.PutUint(hh, b.ExitBalanceToConsume) - - // Field (31) 'EarliestExitEpoch' - ssz.PutUint(hh, b.EarliestExitEpoch) - - // Field (32) 'ConsolidationBalanceToConsume' - ssz.PutUint(hh, b.ConsolidationBalanceToConsume) - - // Field (33) 'EarliestConsolidationEpoch' - ssz.PutUint(hh, b.EarliestConsolidationEpoch) - - // Field (34) 'PendingDeposits' + // Field 28: DepositRequestsStartIndex + hh.PutUint64(c.DepositRequestsStartIndex) + // Field 29: DepositBalanceToConsume + if err := c.DepositBalanceToConsume.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("DepositBalanceToConsume: %w", err) + } + // Field 30: ExitBalanceToConsume + if err := c.ExitBalanceToConsume.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ExitBalanceToConsume: %w", err) + } + // Field 31: EarliestExitEpoch + if err := c.EarliestExitEpoch.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("EarliestExitEpoch: %w", err) + } + // Field 32: ConsolidationBalanceToConsume + if err := c.ConsolidationBalanceToConsume.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ConsolidationBalanceToConsume: %w", err) + } + // Field 33: EarliestConsolidationEpoch + if err := c.EarliestConsolidationEpoch.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("EarliestConsolidationEpoch: %w", err) + } + // Field 34: PendingDeposits { + if len(c.PendingDeposits) > 134217728 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.PendingDeposits { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("PendingDeposits: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 134217728) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.PendingDeposits)), 134217728) } - - // Field (35) 'PendingPartialWithdrawals' + // Field 35: PendingPartialWithdrawals { + if len(c.PendingPartialWithdrawals) > 64 { + return ssz.ErrListTooBig + } subIndx := hh.Index() - num := uint64(len(b.PendingPartialWithdrawals)) - if num > 64 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range b.PendingPartialWithdrawals { - if err = elem.HashTreeRootWith(hh); err != nil { - return + for _, o := range c.PendingPartialWithdrawals { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("PendingPartialWithdrawals: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 64) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.PendingPartialWithdrawals)), 64) } - - // Field (36) 'PendingConsolidations' + // Field 36: PendingConsolidations { + if len(c.PendingConsolidations) > 64 { + return ssz.ErrListTooBig + } subIndx := hh.Index() - num := uint64(len(b.PendingConsolidations)) - if num > 64 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range b.PendingConsolidations { - if err = elem.HashTreeRootWith(hh); err != nil { - return + for _, o := range c.PendingConsolidations { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("PendingConsolidations: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 64) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.PendingConsolidations)), 64) } - - // Field (37) 'ProposerLookahead' + // Field 37: ProposerLookahead { - if size := len(b.ProposerLookahead); size != 16 { - err = ssz.ErrVectorLengthFn("--.ProposerLookahead", size, 16) - return + if len(c.ProposerLookahead) != 16 { + return ssz.ErrVectorLength } subIndx := hh.Index() - for _, i := range b.ProposerLookahead { - ssz.AppendUint(hh, i) + for _, o := range c.ProposerLookahead { + hh.AppendUint64(uint64(o)) } hh.Merkleize(subIndx) } + hh.Merkleize(indx) + return nil +} + +func (c *BlindedBeaconBlockFulu) SizeSSZ() int { + size := 84 + if c.Body == nil { + c.Body = new(BlindedBeaconBlockBodyElectra) + } + size += c.Body.SizeSSZ() + return size +} + +func (c *BlindedBeaconBlockFulu) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} + +func (c *BlindedBeaconBlockFulu) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 84 + + // Field 0: Slot + if dst, err = c.Slot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Slot: %w", err) + } + + // Field 1: ProposerIndex + if dst, err = c.ProposerIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ProposerIndex: %w", err) + } + + // Field 2: ParentRoot + if len(c.ParentRoot) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.ParentRoot...) + + // Field 3: StateRoot + if len(c.StateRoot) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.StateRoot...) + + // Field 4: Body + if c.Body == nil { + c.Body = new(BlindedBeaconBlockBodyElectra) + } + dst = ssz.WriteOffset(dst, offset) + offset += c.Body.SizeSSZ() + + // Field 4: Body + if dst, err = c.Body.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Body: %w", err) + } + return dst, err +} + +func (c *BlindedBeaconBlockFulu) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 84 { + return ssz.ErrSize + } + + sszSlice0 := buf[0:8] // c.Slot + sszSlice1 := buf[8:16] // c.ProposerIndex + sszSlice2 := buf[16:48] // c.ParentRoot + sszSlice3 := buf[48:80] // c.StateRoot + + sszVarOffset4 := ssz.ReadOffset(buf[80:84]) // c.Body + if sszVarOffset4 != 84 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset4 > size { + return ssz.ErrOffset + } + sszSlice4 := buf[sszVarOffset4:] // c.Body + + // Field 0: Slot + if err = c.Slot.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Slot: %w", err) + } + + // Field 1: ProposerIndex + if err = c.ProposerIndex.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("ProposerIndex: %w", err) + } + + // Field 2: ParentRoot + c.ParentRoot = make([]byte, 0, 32) + c.ParentRoot = append(c.ParentRoot, sszSlice2...) + + // Field 3: StateRoot + c.StateRoot = make([]byte, 0, 32) + c.StateRoot = append(c.StateRoot, sszSlice3...) + + // Field 4: Body + c.Body = new(BlindedBeaconBlockBodyElectra) + if err = c.Body.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("Body: %w", err) + } + return err +} + +func (c *BlindedBeaconBlockFulu) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} +func (c *BlindedBeaconBlockFulu) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Slot + if err := c.Slot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Slot: %w", err) + } + // Field 1: ProposerIndex + if err := c.ProposerIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ProposerIndex: %w", err) + } + // Field 2: ParentRoot + if len(c.ParentRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ParentRoot) + // Field 3: StateRoot + if len(c.StateRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.StateRoot) + // Field 4: Body + if err := c.Body.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Body: %w", err) + } hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the DataColumnSidecar object -func (d *DataColumnSidecar) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(d) +func (c *DataColumnSidecar) SizeSSZ() int { + size := 356 + size += len(c.Column) * 2048 + size += len(c.KzgCommitments) * 48 + size += len(c.KzgProofs) * 48 + return size } -// MarshalSSZTo ssz marshals the DataColumnSidecar object to a target array -func (d *DataColumnSidecar) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(356) +func (c *DataColumnSidecar) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} + +func (c *DataColumnSidecar) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 356 - // Field (0) 'Index' - dst = ssz.MarshalUint(dst, d.Index) + // Field 0: Index + dst = binary.LittleEndian.AppendUint64(dst, c.Index) - // Offset (1) 'Column' + // Field 1: Column dst = ssz.WriteOffset(dst, offset) - offset += len(d.Column) * 2048 + offset += len(c.Column) * 2048 - // Offset (2) 'KzgCommitments' + // Field 2: KzgCommitments dst = ssz.WriteOffset(dst, offset) - offset += len(d.KzgCommitments) * 48 + offset += len(c.KzgCommitments) * 48 - // Offset (3) 'KzgProofs' + // Field 3: KzgProofs dst = ssz.WriteOffset(dst, offset) - offset += len(d.KzgProofs) * 48 + offset += len(c.KzgProofs) * 48 - // Field (4) 'SignedBlockHeader' - if d.SignedBlockHeader == nil { - d.SignedBlockHeader = new(SignedBeaconBlockHeader) + // Field 4: SignedBlockHeader + if c.SignedBlockHeader == nil { + c.SignedBlockHeader = new(SignedBeaconBlockHeader) } - if dst, err = d.SignedBlockHeader.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.SignedBlockHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SignedBlockHeader: %w", err) } - // Field (5) 'KzgCommitmentsInclusionProof' - if size := len(d.KzgCommitmentsInclusionProof); size != 4 { - err = ssz.ErrVectorLengthFn("--.KzgCommitmentsInclusionProof", size, 4) - return + // Field 5: KzgCommitmentsInclusionProof + if len(c.KzgCommitmentsInclusionProof) != 4 { + return nil, ssz.ErrBytesLength } - for ii := 0; ii < 4; ii++ { - if size := len(d.KzgCommitmentsInclusionProof[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.KzgCommitmentsInclusionProof[ii]", size, 32) - return + for _, o := range c.KzgCommitmentsInclusionProof { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, d.KzgCommitmentsInclusionProof[ii]...) + dst = append(dst, o...) } - // Field (1) 'Column' - if size := len(d.Column); size > 4096 { - err = ssz.ErrListTooBigFn("--.Column", size, 4096) - return + // Field 1: Column + if len(c.Column) > 4096 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(d.Column); ii++ { - if size := len(d.Column[ii]); size != 2048 { - err = ssz.ErrBytesLengthFn("--.Column[ii]", size, 2048) - return + for _, o := range c.Column { + if len(o) != 2048 { + return nil, ssz.ErrBytesLength } - dst = append(dst, d.Column[ii]...) + dst = append(dst, o...) } - // Field (2) 'KzgCommitments' - if size := len(d.KzgCommitments); size > 4096 { - err = ssz.ErrListTooBigFn("--.KzgCommitments", size, 4096) - return + // Field 2: KzgCommitments + if len(c.KzgCommitments) > 4096 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(d.KzgCommitments); ii++ { - if size := len(d.KzgCommitments[ii]); size != 48 { - err = ssz.ErrBytesLengthFn("--.KzgCommitments[ii]", size, 48) - return + for _, o := range c.KzgCommitments { + if len(o) != 48 { + return nil, ssz.ErrBytesLength } - dst = append(dst, d.KzgCommitments[ii]...) + dst = append(dst, o...) } - // Field (3) 'KzgProofs' - if size := len(d.KzgProofs); size > 4096 { - err = ssz.ErrListTooBigFn("--.KzgProofs", size, 4096) - return + // Field 3: KzgProofs + if len(c.KzgProofs) > 4096 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(d.KzgProofs); ii++ { - if size := len(d.KzgProofs[ii]); size != 48 { - err = ssz.ErrBytesLengthFn("--.KzgProofs[ii]", size, 48) - return + for _, o := range c.KzgProofs { + if len(o) != 48 { + return nil, ssz.ErrBytesLength } - dst = append(dst, d.KzgProofs[ii]...) + dst = append(dst, o...) } - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the DataColumnSidecar object -func (d *DataColumnSidecar) UnmarshalSSZ(buf []byte) error { +func (c *DataColumnSidecar) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size < 356 { return ssz.ErrSize } - tail := buf - var o1, o2, o3 uint64 - - // Field (0) 'Index' - d.Index = ssz.UnmarshallUint[uint64](buf[0:8]) - - // Offset (1) 'Column' - if o1 = ssz.ReadOffset(buf[8:12]); o1 > size { - return ssz.ErrOffset - } + sszSlice0 := buf[0:8] // c.Index + sszSlice4 := buf[20:228] // c.SignedBlockHeader + sszSlice5 := buf[228:356] // c.KzgCommitmentsInclusionProof - if o1 != 356 { + sszVarOffset1 := ssz.ReadOffset(buf[8:12]) // c.Column + if sszVarOffset1 != 356 { return ssz.ErrInvalidVariableOffset } - - // Offset (2) 'KzgCommitments' - if o2 = ssz.ReadOffset(buf[12:16]); o2 > size || o1 > o2 { + if sszVarOffset1 > size { return ssz.ErrOffset } - - // Offset (3) 'KzgProofs' - if o3 = ssz.ReadOffset(buf[16:20]); o3 > size || o2 > o3 { + sszVarOffset2 := ssz.ReadOffset(buf[12:16]) // c.KzgCommitments + if sszVarOffset2 > size || sszVarOffset2 < sszVarOffset1 { return ssz.ErrOffset } - - // Field (4) 'SignedBlockHeader' - if d.SignedBlockHeader == nil { - d.SignedBlockHeader = new(SignedBeaconBlockHeader) - } - if err = d.SignedBlockHeader.UnmarshalSSZ(buf[20:228]); err != nil { - return err + sszVarOffset3 := ssz.ReadOffset(buf[16:20]) // c.KzgProofs + if sszVarOffset3 > size || sszVarOffset3 < sszVarOffset2 { + return ssz.ErrOffset } + sszSlice1 := buf[sszVarOffset1:sszVarOffset2] // c.Column + sszSlice2 := buf[sszVarOffset2:sszVarOffset3] // c.KzgCommitments + sszSlice3 := buf[sszVarOffset3:] // c.KzgProofs - // Field (5) 'KzgCommitmentsInclusionProof' - d.KzgCommitmentsInclusionProof = make([][]byte, 4) - for ii := 0; ii < 4; ii++ { - if cap(d.KzgCommitmentsInclusionProof[ii]) == 0 { - d.KzgCommitmentsInclusionProof[ii] = make([]byte, 0, len(buf[228:356][ii*32:(ii+1)*32])) - } - d.KzgCommitmentsInclusionProof[ii] = append(d.KzgCommitmentsInclusionProof[ii], buf[228:356][ii*32:(ii+1)*32]...) - } + // Field 0: Index + c.Index = binary.LittleEndian.Uint64(sszSlice0) - // Field (1) 'Column' + // Field 1: Column { - buf = tail[o1:o2] - num, err := ssz.DivideInt2(len(buf), 2048, 4096) - if err != nil { - return err - } - d.Column = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(d.Column[ii]) == 0 { - d.Column[ii] = make([]byte, 0, len(buf[ii*2048:(ii+1)*2048])) - } - d.Column[ii] = append(d.Column[ii], buf[ii*2048:(ii+1)*2048]...) + if len(sszSlice1)%2048 != 0 { + return fmt.Errorf("misaligned bytes: c.Column length is %d, which is not a multiple of 2048: %w", len(sszSlice1), ssz.ErrIncorrectListSize) } - } + numElem := len(sszSlice1) / 2048 + if numElem > 4096 { + return fmt.Errorf("ssz-max exceeded: c.Column has %d elements, ssz-max is 4096: %w", numElem, ssz.ErrListTooBig) + } + c.Column = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte - // Field (2) 'KzgCommitments' - { - buf = tail[o2:o3] - num, err := ssz.DivideInt2(len(buf), 48, 4096) - if err != nil { - return err - } - d.KzgCommitments = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(d.KzgCommitments[ii]) == 0 { - d.KzgCommitments[ii] = make([]byte, 0, len(buf[ii*48:(ii+1)*48])) - } - d.KzgCommitments[ii] = append(d.KzgCommitments[ii], buf[ii*48:(ii+1)*48]...) + tmpSlice := sszSlice1[i*2048 : (1+i)*2048] + tmp = make([]byte, 0, 2048) + tmp = append(tmp, tmpSlice...) + c.Column[i] = tmp } } - // Field (3) 'KzgProofs' + // Field 2: KzgCommitments { - buf = tail[o3:] - num, err := ssz.DivideInt2(len(buf), 48, 4096) - if err != nil { - return err - } - d.KzgProofs = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(d.KzgProofs[ii]) == 0 { - d.KzgProofs[ii] = make([]byte, 0, len(buf[ii*48:(ii+1)*48])) - } - d.KzgProofs[ii] = append(d.KzgProofs[ii], buf[ii*48:(ii+1)*48]...) + if len(sszSlice2)%48 != 0 { + return fmt.Errorf("misaligned bytes: c.KzgCommitments length is %d, which is not a multiple of 48: %w", len(sszSlice2), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice2) / 48 + if numElem > 4096 { + return fmt.Errorf("ssz-max exceeded: c.KzgCommitments has %d elements, ssz-max is 4096: %w", numElem, ssz.ErrListTooBig) + } + c.KzgCommitments = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte + + tmpSlice := sszSlice2[i*48 : (1+i)*48] + tmp = make([]byte, 0, 48) + tmp = append(tmp, tmpSlice...) + c.KzgCommitments[i] = tmp } } - return err -} -// SizeSSZ returns the ssz encoded size in bytes for the DataColumnSidecar object -func (d *DataColumnSidecar) SizeSSZ() (size int) { - size = 356 + // Field 3: KzgProofs + { + if len(sszSlice3)%48 != 0 { + return fmt.Errorf("misaligned bytes: c.KzgProofs length is %d, which is not a multiple of 48: %w", len(sszSlice3), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice3) / 48 + if numElem > 4096 { + return fmt.Errorf("ssz-max exceeded: c.KzgProofs has %d elements, ssz-max is 4096: %w", numElem, ssz.ErrListTooBig) + } + c.KzgProofs = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte - // Field (1) 'Column' - size += len(d.Column) * 2048 + tmpSlice := sszSlice3[i*48 : (1+i)*48] + tmp = make([]byte, 0, 48) + tmp = append(tmp, tmpSlice...) + c.KzgProofs[i] = tmp + } + } - // Field (2) 'KzgCommitments' - size += len(d.KzgCommitments) * 48 + // Field 4: SignedBlockHeader + c.SignedBlockHeader = new(SignedBeaconBlockHeader) + if err = c.SignedBlockHeader.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("SignedBlockHeader: %w", err) + } - // Field (3) 'KzgProofs' - size += len(d.KzgProofs) * 48 + // Field 5: KzgCommitmentsInclusionProof + { + c.KzgCommitmentsInclusionProof = make([][]byte, 4) + for i := 0; i < 4; i++ { + var tmp []byte - return + tmpSlice := sszSlice5[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.KzgCommitmentsInclusionProof[i] = tmp + } + } + return err } -// HashTreeRoot ssz hashes the DataColumnSidecar object -func (d *DataColumnSidecar) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(d) +func (c *DataColumnSidecar) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the DataColumnSidecar object with a hasher -func (d *DataColumnSidecar) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *DataColumnSidecar) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Index' - ssz.PutUint(hh, d.Index) - - // Field (1) 'Column' + // Field 0: Index + hh.PutUint64(c.Index) + // Field 1: Column { - if size := len(d.Column); size > 4096 { - err = ssz.ErrListTooBigFn("--.Column", size, 4096) - return + if len(c.Column) > 4096 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range d.Column { - if len(i) != 2048 { - err = ssz.ErrBytesLength - return + for _, o := range c.Column { + if len(o) != 2048 { + return ssz.ErrBytesLength } - hh.PutBytes(i) + hh.PutBytes(o) } - - numItems := uint64(len(d.Column)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Column)), 4096) } - - // Field (2) 'KzgCommitments' + // Field 2: KzgCommitments { - if size := len(d.KzgCommitments); size > 4096 { - err = ssz.ErrListTooBigFn("--.KzgCommitments", size, 4096) - return + if len(c.KzgCommitments) > 4096 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range d.KzgCommitments { - if len(i) != 48 { - err = ssz.ErrBytesLength - return + for _, o := range c.KzgCommitments { + if len(o) != 48 { + return ssz.ErrBytesLength } - hh.PutBytes(i) + hh.PutBytes(o) } - - numItems := uint64(len(d.KzgCommitments)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.KzgCommitments)), 4096) } - - // Field (3) 'KzgProofs' + // Field 3: KzgProofs { - if size := len(d.KzgProofs); size > 4096 { - err = ssz.ErrListTooBigFn("--.KzgProofs", size, 4096) - return + if len(c.KzgProofs) > 4096 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range d.KzgProofs { - if len(i) != 48 { - err = ssz.ErrBytesLength - return + for _, o := range c.KzgProofs { + if len(o) != 48 { + return ssz.ErrBytesLength } - hh.PutBytes(i) + hh.PutBytes(o) } - - numItems := uint64(len(d.KzgProofs)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.KzgProofs)), 4096) } - - // Field (4) 'SignedBlockHeader' - if err = d.SignedBlockHeader.HashTreeRootWith(hh); err != nil { - return + // Field 4: SignedBlockHeader + if err := c.SignedBlockHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SignedBlockHeader: %w", err) } - - // Field (5) 'KzgCommitmentsInclusionProof' + // Field 5: KzgCommitmentsInclusionProof { - if size := len(d.KzgCommitmentsInclusionProof); size != 4 { - err = ssz.ErrVectorLengthFn("--.KzgCommitmentsInclusionProof", size, 4) - return + if len(c.KzgCommitmentsInclusionProof) != 4 { + return ssz.ErrVectorLength } subIndx := hh.Index() - for _, i := range d.KzgCommitmentsInclusionProof { - if len(i) != 32 { - err = ssz.ErrBytesLength - return + for _, o := range c.KzgCommitmentsInclusionProof { + if len(o) != 32 { + return ssz.ErrBytesLength } - hh.Append(i) + hh.Append(o) } hh.Merkleize(subIndx) } + hh.Merkleize(indx) + return nil +} + +func (c *DataColumnsByRootIdentifier) SizeSSZ() int { + size := 36 + size += len(c.Columns) * 8 + return size +} + +func (c *DataColumnsByRootIdentifier) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} + +func (c *DataColumnsByRootIdentifier) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 36 + + // Field 0: BlockRoot + if len(c.BlockRoot) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.BlockRoot...) + + // Field 1: Columns + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Columns) * 8 + + // Field 1: Columns + if len(c.Columns) > 128 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.Columns { + dst = binary.LittleEndian.AppendUint64(dst, o) + } + return dst, err +} + +func (c *DataColumnsByRootIdentifier) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 36 { + return ssz.ErrSize + } + + sszSlice0 := buf[0:32] // c.BlockRoot + + sszVarOffset1 := ssz.ReadOffset(buf[32:36]) // c.Columns + if sszVarOffset1 != 36 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset1 > size { + return ssz.ErrOffset + } + sszSlice1 := buf[sszVarOffset1:] // c.Columns + + // Field 0: BlockRoot + c.BlockRoot = make([]byte, 0, 32) + c.BlockRoot = append(c.BlockRoot, sszSlice0...) + + // Field 1: Columns + { + if len(sszSlice1)%8 != 0 { + return fmt.Errorf("misaligned bytes: c.Columns length is %d, which is not a multiple of 8: %w", len(sszSlice1), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice1) / 8 + if numElem > 128 { + return fmt.Errorf("ssz-max exceeded: c.Columns has %d elements, ssz-max is 128: %w", numElem, ssz.ErrListTooBig) + } + c.Columns = make([]uint64, numElem) + for i := 0; i < numElem; i++ { + var tmp uint64 + + tmpSlice := sszSlice1[i*8 : (1+i)*8] + tmp = binary.LittleEndian.Uint64(tmpSlice) + c.Columns[i] = tmp + } + } + return err +} + +func (c *DataColumnsByRootIdentifier) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} +func (c *DataColumnsByRootIdentifier) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: BlockRoot + if len(c.BlockRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.BlockRoot) + // Field 1: Columns + { + if len(c.Columns) > 128 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.Columns { + hh.AppendUint64(o) + } + hh.FillUpTo32() + numItems := uint64(len(c.Columns)) + hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(128, numItems, 8)) + } hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the DataColumnsByRootIdentifier object -func (d *DataColumnsByRootIdentifier) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(d) +func (c *PartialDataColumnHeader) SizeSSZ() int { + size := 340 + size += len(c.KzgCommitments) * 48 + return size } -// MarshalSSZTo ssz marshals the DataColumnsByRootIdentifier object to a target array -func (d *DataColumnsByRootIdentifier) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(36) +func (c *PartialDataColumnHeader) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (0) 'BlockRoot' - if size := len(d.BlockRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockRoot", size, 32) - return - } - dst = append(dst, d.BlockRoot...) +func (c *PartialDataColumnHeader) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 340 - // Offset (1) 'Columns' + // Field 0: KzgCommitments dst = ssz.WriteOffset(dst, offset) - offset += len(d.Columns) * 8 + offset += len(c.KzgCommitments) * 48 + + // Field 1: SignedBlockHeader + if c.SignedBlockHeader == nil { + c.SignedBlockHeader = new(SignedBeaconBlockHeader) + } + if dst, err = c.SignedBlockHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SignedBlockHeader: %w", err) + } - // Field (1) 'Columns' - if size := len(d.Columns); size > 128 { - err = ssz.ErrListTooBigFn("--.Columns", size, 128) - return + // Field 2: KzgCommitmentsInclusionProof + if len(c.KzgCommitmentsInclusionProof) != 4 { + return nil, ssz.ErrBytesLength } - for ii := 0; ii < len(d.Columns); ii++ { - dst = ssz.MarshalUint(dst, d.Columns[ii]) + for _, o := range c.KzgCommitmentsInclusionProof { + if len(o) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) } - return + // Field 0: KzgCommitments + if len(c.KzgCommitments) > 4096 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.KzgCommitments { + if len(o) != 48 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the DataColumnsByRootIdentifier object -func (d *DataColumnsByRootIdentifier) UnmarshalSSZ(buf []byte) error { +func (c *PartialDataColumnHeader) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 36 { + if size < 340 { return ssz.ErrSize } - tail := buf - var o1 uint64 + sszSlice1 := buf[4:212] // c.SignedBlockHeader + sszSlice2 := buf[212:340] // c.KzgCommitmentsInclusionProof - // Field (0) 'BlockRoot' - if cap(d.BlockRoot) == 0 { - d.BlockRoot = make([]byte, 0, len(buf[0:32])) + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.KzgCommitments + if sszVarOffset0 != 340 { + return ssz.ErrInvalidVariableOffset } - d.BlockRoot = append(d.BlockRoot, buf[0:32]...) - - // Offset (1) 'Columns' - if o1 = ssz.ReadOffset(buf[32:36]); o1 > size { + if sszVarOffset0 > size { return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:] // c.KzgCommitments - if o1 != 36 { - return ssz.ErrInvalidVariableOffset - } - - // Field (1) 'Columns' + // Field 0: KzgCommitments { - buf = tail[o1:] - num, err := ssz.DivideInt2(len(buf), 8, 128) - if err != nil { - return err + if len(sszSlice0)%48 != 0 { + return fmt.Errorf("misaligned bytes: c.KzgCommitments length is %d, which is not a multiple of 48: %w", len(sszSlice0), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice0) / 48 + if numElem > 4096 { + return fmt.Errorf("ssz-max exceeded: c.KzgCommitments has %d elements, ssz-max is 4096: %w", numElem, ssz.ErrListTooBig) } - d.Columns = ssz.ExtendUint(d.Columns, num) - for ii := 0; ii < num; ii++ { - d.Columns[ii] = ssz.UnmarshallUint[uint64](buf[ii*8 : (ii+1)*8]) + c.KzgCommitments = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte + + tmpSlice := sszSlice0[i*48 : (1+i)*48] + tmp = make([]byte, 0, 48) + tmp = append(tmp, tmpSlice...) + c.KzgCommitments[i] = tmp } } - return err -} -// SizeSSZ returns the ssz encoded size in bytes for the DataColumnsByRootIdentifier object -func (d *DataColumnsByRootIdentifier) SizeSSZ() (size int) { - size = 36 + // Field 1: SignedBlockHeader + c.SignedBlockHeader = new(SignedBeaconBlockHeader) + if err = c.SignedBlockHeader.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("SignedBlockHeader: %w", err) + } - // Field (1) 'Columns' - size += len(d.Columns) * 8 + // Field 2: KzgCommitmentsInclusionProof + { + c.KzgCommitmentsInclusionProof = make([][]byte, 4) + for i := 0; i < 4; i++ { + var tmp []byte - return + tmpSlice := sszSlice2[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.KzgCommitmentsInclusionProof[i] = tmp + } + } + return err } -// HashTreeRoot ssz hashes the DataColumnsByRootIdentifier object -func (d *DataColumnsByRootIdentifier) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(d) +func (c *PartialDataColumnHeader) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the DataColumnsByRootIdentifier object with a hasher -func (d *DataColumnsByRootIdentifier) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *PartialDataColumnHeader) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'BlockRoot' - if size := len(d.BlockRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockRoot", size, 32) - return + // Field 0: KzgCommitments + { + if len(c.KzgCommitments) > 4096 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.KzgCommitments { + if len(o) != 48 { + return ssz.ErrBytesLength + } + hh.PutBytes(o) + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.KzgCommitments)), 4096) } - hh.PutBytes(d.BlockRoot) - - // Field (1) 'Columns' + // Field 1: SignedBlockHeader + if err := c.SignedBlockHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SignedBlockHeader: %w", err) + } + // Field 2: KzgCommitmentsInclusionProof { - if size := len(d.Columns); size > 128 { - err = ssz.ErrListTooBigFn("--.Columns", size, 128) - return + if len(c.KzgCommitmentsInclusionProof) != 4 { + return ssz.ErrVectorLength } subIndx := hh.Index() - for _, i := range d.Columns { - ssz.AppendUint(hh, i) + for _, o := range c.KzgCommitmentsInclusionProof { + if len(o) != 32 { + return ssz.ErrBytesLength + } + hh.Append(o) } - hh.FillUpTo32() - - numItems := uint64(len(d.Columns)) - hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(128, numItems, 8)) + hh.Merkleize(subIndx) } - hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the StatusV2 object -func (s *StatusV2) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) +func (c *PartialDataColumnPartsMetadata) SizeSSZ() int { + size := 8 + size += len(c.Available) + size += len(c.Requests) + return size } -// MarshalSSZTo ssz marshals the StatusV2 object to a target array -func (s *StatusV2) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *PartialDataColumnPartsMetadata) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (0) 'ForkDigest' - if size := len(s.ForkDigest); size != 4 { - err = ssz.ErrBytesLengthFn("--.ForkDigest", size, 4) - return - } - dst = append(dst, s.ForkDigest...) +func (c *PartialDataColumnPartsMetadata) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 8 - // Field (1) 'FinalizedRoot' - if size := len(s.FinalizedRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.FinalizedRoot", size, 32) - return - } - dst = append(dst, s.FinalizedRoot...) + // Field 0: Available + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Available) - // Field (2) 'FinalizedEpoch' - dst = ssz.MarshalUint(dst, s.FinalizedEpoch) + // Field 1: Requests + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Requests) - // Field (3) 'HeadRoot' - if size := len(s.HeadRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.HeadRoot", size, 32) - return + // Field 0: Available + if len(c.Available) > 4096 { + return nil, ssz.ErrListTooBig } - dst = append(dst, s.HeadRoot...) - - // Field (4) 'HeadSlot' - dst = ssz.MarshalUint(dst, s.HeadSlot) + dst = append(dst, c.Available...) - // Field (5) 'EarliestAvailableSlot' - dst = ssz.MarshalUint(dst, s.EarliestAvailableSlot) - - return + // Field 1: Requests + if len(c.Requests) > 4096 { + return nil, ssz.ErrListTooBig + } + dst = append(dst, c.Requests...) + return dst, err } -// UnmarshalSSZ ssz unmarshals the StatusV2 object -func (s *StatusV2) UnmarshalSSZ(buf []byte) error { +func (c *PartialDataColumnPartsMetadata) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 92 { + if size < 8 { return ssz.ErrSize } - // Field (0) 'ForkDigest' - if cap(s.ForkDigest) == 0 { - s.ForkDigest = make([]byte, 0, len(buf[0:4])) + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Available + if sszVarOffset0 != 8 { + return ssz.ErrInvalidVariableOffset } - s.ForkDigest = append(s.ForkDigest, buf[0:4]...) - - // Field (1) 'FinalizedRoot' - if cap(s.FinalizedRoot) == 0 { - s.FinalizedRoot = make([]byte, 0, len(buf[4:36])) + if sszVarOffset0 > size { + return ssz.ErrOffset } - s.FinalizedRoot = append(s.FinalizedRoot, buf[4:36]...) - - // Field (2) 'FinalizedEpoch' - s.FinalizedEpoch = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Epoch](buf[36:44]) - - // Field (3) 'HeadRoot' - if cap(s.HeadRoot) == 0 { - s.HeadRoot = make([]byte, 0, len(buf[44:76])) + sszVarOffset1 := ssz.ReadOffset(buf[4:8]) // c.Requests + if sszVarOffset1 > size || sszVarOffset1 < sszVarOffset0 { + return ssz.ErrOffset } - s.HeadRoot = append(s.HeadRoot, buf[44:76]...) + sszSlice0 := buf[sszVarOffset0:sszVarOffset1] // c.Available + sszSlice1 := buf[sszVarOffset1:] // c.Requests - // Field (4) 'HeadSlot' - s.HeadSlot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[76:84]) - - // Field (5) 'EarliestAvailableSlot' - s.EarliestAvailableSlot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[84:92]) + // Field 0: Available + if err = ssz.ValidateBitlist(sszSlice0, 4096); err != nil { + return fmt.Errorf("Available: %w", err) + } + c.Available = append([]byte{}, go_bitfield.Bitlist(sszSlice0)...) + // Field 1: Requests + if err = ssz.ValidateBitlist(sszSlice1, 4096); err != nil { + return fmt.Errorf("Requests: %w", err) + } + c.Requests = append([]byte{}, go_bitfield.Bitlist(sszSlice1)...) return err } -// SizeSSZ returns the ssz encoded size in bytes for the StatusV2 object -func (s *StatusV2) SizeSSZ() (size int) { - size = 92 - return -} - -// HashTreeRoot ssz hashes the StatusV2 object -func (s *StatusV2) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) +func (c *PartialDataColumnPartsMetadata) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the StatusV2 object with a hasher -func (s *StatusV2) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *PartialDataColumnPartsMetadata) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'ForkDigest' - if size := len(s.ForkDigest); size != 4 { - err = ssz.ErrBytesLengthFn("--.ForkDigest", size, 4) - return + // Field 0: Available + if len(c.Available) == 0 { + return ssz.ErrEmptyBitlist } - hh.PutBytes(s.ForkDigest) - - // Field (1) 'FinalizedRoot' - if size := len(s.FinalizedRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.FinalizedRoot", size, 32) - return + hh.PutBitlist(c.Available, 4096) + // Field 1: Requests + if len(c.Requests) == 0 { + return ssz.ErrEmptyBitlist } - hh.PutBytes(s.FinalizedRoot) - - // Field (2) 'FinalizedEpoch' - ssz.PutUint(hh, s.FinalizedEpoch) + hh.PutBitlist(c.Requests, 4096) + hh.Merkleize(indx) + return nil +} - // Field (3) 'HeadRoot' - if size := len(s.HeadRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.HeadRoot", size, 32) - return +func (c *PartialDataColumnSidecar) SizeSSZ() int { + size := 16 + size += len(c.CellsPresentBitmap) + size += len(c.PartialColumn) * 2048 + size += len(c.KzgProofs) * 48 + for _, o := range c.Header { + size += 4 + size += o.SizeSSZ() } - hh.PutBytes(s.HeadRoot) - - // Field (4) 'HeadSlot' - ssz.PutUint(hh, s.HeadSlot) - - // Field (5) 'EarliestAvailableSlot' - ssz.PutUint(hh, s.EarliestAvailableSlot) - - hh.Merkleize(indx) - return + return size } -// MarshalSSZ ssz marshals the PartialDataColumnSidecar object -func (p *PartialDataColumnSidecar) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(p) +func (c *PartialDataColumnSidecar) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the PartialDataColumnSidecar object to a target array -func (p *PartialDataColumnSidecar) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(16) +func (c *PartialDataColumnSidecar) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 16 - // Offset (0) 'CellsPresentBitmap' + // Field 0: CellsPresentBitmap dst = ssz.WriteOffset(dst, offset) - offset += len(p.CellsPresentBitmap) + offset += len(c.CellsPresentBitmap) - // Offset (1) 'PartialColumn' + // Field 1: PartialColumn dst = ssz.WriteOffset(dst, offset) - offset += len(p.PartialColumn) * 2048 + offset += len(c.PartialColumn) * 2048 - // Offset (2) 'KzgProofs' + // Field 2: KzgProofs dst = ssz.WriteOffset(dst, offset) - offset += len(p.KzgProofs) * 48 + offset += len(c.KzgProofs) * 48 - // Offset (3) 'Header' + // Field 3: Header dst = ssz.WriteOffset(dst, offset) - for ii := 0; ii < len(p.Header); ii++ { + for _, o := range c.Header { offset += 4 - offset += p.Header[ii].SizeSSZ() + offset += o.SizeSSZ() } - // Field (0) 'CellsPresentBitmap' - if size := len(p.CellsPresentBitmap); size > 4096 { - err = ssz.ErrBytesLengthFn("--.CellsPresentBitmap", size, 4096) - return + // Field 0: CellsPresentBitmap + if len(c.CellsPresentBitmap) > 4096 { + return nil, ssz.ErrListTooBig } - dst = append(dst, p.CellsPresentBitmap...) + dst = append(dst, c.CellsPresentBitmap...) - // Field (1) 'PartialColumn' - if size := len(p.PartialColumn); size > 4096 { - err = ssz.ErrListTooBigFn("--.PartialColumn", size, 4096) - return + // Field 1: PartialColumn + if len(c.PartialColumn) > 4096 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(p.PartialColumn); ii++ { - if size := len(p.PartialColumn[ii]); size != 2048 { - err = ssz.ErrBytesLengthFn("--.PartialColumn[ii]", size, 2048) - return + for _, o := range c.PartialColumn { + if len(o) != 2048 { + return nil, ssz.ErrBytesLength } - dst = append(dst, p.PartialColumn[ii]...) + dst = append(dst, o...) } - // Field (2) 'KzgProofs' - if size := len(p.KzgProofs); size > 4096 { - err = ssz.ErrListTooBigFn("--.KzgProofs", size, 4096) - return + // Field 2: KzgProofs + if len(c.KzgProofs) > 4096 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(p.KzgProofs); ii++ { - if size := len(p.KzgProofs[ii]); size != 48 { - err = ssz.ErrBytesLengthFn("--.KzgProofs[ii]", size, 48) - return + for _, o := range c.KzgProofs { + if len(o) != 48 { + return nil, ssz.ErrBytesLength } - dst = append(dst, p.KzgProofs[ii]...) + dst = append(dst, o...) } - // Field (3) 'Header' - if size := len(p.Header); size > 1 { - err = ssz.ErrListTooBigFn("--.Header", size, 1) - return + // Field 3: Header + if len(c.Header) > 1 { + return nil, ssz.ErrListTooBig } { - offset = 4 * len(p.Header) - for ii := 0; ii < len(p.Header); ii++ { + offset = 4 * len(c.Header) + for _, o := range c.Header { dst = ssz.WriteOffset(dst, offset) - offset += p.Header[ii].SizeSSZ() + offset += o.SizeSSZ() } } - for ii := 0; ii < len(p.Header); ii++ { - if dst, err = p.Header[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.Header { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Header: %w", err) } } - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the PartialDataColumnSidecar object -func (p *PartialDataColumnSidecar) UnmarshalSSZ(buf []byte) error { +func (c *PartialDataColumnSidecar) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size < 16 { return ssz.ErrSize } - tail := buf - var o0, o1, o2, o3 uint64 - - // Offset (0) 'CellsPresentBitmap' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.CellsPresentBitmap + if sszVarOffset0 != 16 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset0 > size { return ssz.ErrOffset } - - if o0 != 16 { - return ssz.ErrInvalidVariableOffset + sszVarOffset1 := ssz.ReadOffset(buf[4:8]) // c.PartialColumn + if sszVarOffset1 > size || sszVarOffset1 < sszVarOffset0 { + return ssz.ErrOffset } - - // Offset (1) 'PartialColumn' - if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 { + sszVarOffset2 := ssz.ReadOffset(buf[8:12]) // c.KzgProofs + if sszVarOffset2 > size || sszVarOffset2 < sszVarOffset1 { return ssz.ErrOffset } - - // Offset (2) 'KzgProofs' - if o2 = ssz.ReadOffset(buf[8:12]); o2 > size || o1 > o2 { + sszVarOffset3 := ssz.ReadOffset(buf[12:16]) // c.Header + if sszVarOffset3 > size || sszVarOffset3 < sszVarOffset2 { return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:sszVarOffset1] // c.CellsPresentBitmap + sszSlice1 := buf[sszVarOffset1:sszVarOffset2] // c.PartialColumn + sszSlice2 := buf[sszVarOffset2:sszVarOffset3] // c.KzgProofs + sszSlice3 := buf[sszVarOffset3:] // c.Header - // Offset (3) 'Header' - if o3 = ssz.ReadOffset(buf[12:16]); o3 > size || o2 > o3 { - return ssz.ErrOffset + // Field 0: CellsPresentBitmap + if err = ssz.ValidateBitlist(sszSlice0, 4096); err != nil { + return fmt.Errorf("CellsPresentBitmap: %w", err) } + c.CellsPresentBitmap = append([]byte{}, go_bitfield.Bitlist(sszSlice0)...) - // Field (0) 'CellsPresentBitmap' + // Field 1: PartialColumn { - buf = tail[o0:o1] - if err = ssz.ValidateBitlist(buf, 4096); err != nil { - return err + if len(sszSlice1)%2048 != 0 { + return fmt.Errorf("misaligned bytes: c.PartialColumn length is %d, which is not a multiple of 2048: %w", len(sszSlice1), ssz.ErrIncorrectListSize) } - if cap(p.CellsPresentBitmap) == 0 { - p.CellsPresentBitmap = make([]byte, 0, len(buf)) + numElem := len(sszSlice1) / 2048 + if numElem > 4096 { + return fmt.Errorf("ssz-max exceeded: c.PartialColumn has %d elements, ssz-max is 4096: %w", numElem, ssz.ErrListTooBig) } - p.CellsPresentBitmap = append(p.CellsPresentBitmap, buf...) - } + c.PartialColumn = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte - // Field (1) 'PartialColumn' - { - buf = tail[o1:o2] - num, err := ssz.DivideInt2(len(buf), 2048, 4096) - if err != nil { - return err - } - p.PartialColumn = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(p.PartialColumn[ii]) == 0 { - p.PartialColumn[ii] = make([]byte, 0, len(buf[ii*2048:(ii+1)*2048])) - } - p.PartialColumn[ii] = append(p.PartialColumn[ii], buf[ii*2048:(ii+1)*2048]...) + tmpSlice := sszSlice1[i*2048 : (1+i)*2048] + tmp = make([]byte, 0, 2048) + tmp = append(tmp, tmpSlice...) + c.PartialColumn[i] = tmp } } - // Field (2) 'KzgProofs' + // Field 2: KzgProofs { - buf = tail[o2:o3] - num, err := ssz.DivideInt2(len(buf), 48, 4096) - if err != nil { - return err - } - p.KzgProofs = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(p.KzgProofs[ii]) == 0 { - p.KzgProofs[ii] = make([]byte, 0, len(buf[ii*48:(ii+1)*48])) - } - p.KzgProofs[ii] = append(p.KzgProofs[ii], buf[ii*48:(ii+1)*48]...) + if len(sszSlice2)%48 != 0 { + return fmt.Errorf("misaligned bytes: c.KzgProofs length is %d, which is not a multiple of 48: %w", len(sszSlice2), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice2) / 48 + if numElem > 4096 { + return fmt.Errorf("ssz-max exceeded: c.KzgProofs has %d elements, ssz-max is 4096: %w", numElem, ssz.ErrListTooBig) + } + c.KzgProofs = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte + + tmpSlice := sszSlice2[i*48 : (1+i)*48] + tmp = make([]byte, 0, 48) + tmp = append(tmp, tmpSlice...) + c.KzgProofs[i] = tmp } } - // Field (3) 'Header' + // Field 3: Header { - buf = tail[o3:] - num, err := ssz.DecodeDynamicLength(buf, 1) - if err != nil { - return err - } - p.Header = make([]*PartialDataColumnHeader, num) - err = ssz.UnmarshalDynamic(buf, num, func(indx int, buf []byte) (err error) { - if p.Header[indx] == nil { - p.Header[indx] = new(PartialDataColumnHeader) + // empty lists are zero length, so make sure there is room for an offset + // before attempting to unmarshal it + if len(sszSlice3) > 3 { + startOffset := ssz.ReadOffset(sszSlice3[0:4]) + if startOffset == 0 { + return fmt.Errorf("encountered invalid offset of 0 when decoding c.Header") + } + if startOffset%4 != 0 { + return fmt.Errorf("misaligned list bytes: when decoding c.Header, end-of-list offset is %d, which is not a multiple of 4 (offset size)", startOffset) + } + listLen := startOffset / 4 + if listLen > 1 { + return fmt.Errorf("ssz-max exceeded: c.Header has %d elements, ssz-max is 1: %w", listLen, ssz.ErrListTooBig) + } + totalVarBytes := uint64(len(sszSlice3)) + if totalVarBytes < startOffset { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.Header") + } + c.Header = make([]*PartialDataColumnHeader, listLen) + var tmpSlice []byte + for i := uint64(0); i < listLen; i++ { + var tmp *PartialDataColumnHeader + tmp = new(PartialDataColumnHeader) + endOffset := totalVarBytes + if i+1 != listLen { + endOffset = ssz.ReadOffset(sszSlice3[(i+1)*4 : (i+2)*4]) + if totalVarBytes < endOffset { + return fmt.Errorf("offset %d points past the end of buffer when decoding c.Header", endOffset) + } + } + if endOffset < startOffset { + return fmt.Errorf("offset %d is not greater than start offset %d when decoding c.Header", endOffset, startOffset) + } + tmpSlice = sszSlice3[startOffset:endOffset] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Header: %w", err) + } + c.Header[i] = tmp + startOffset = endOffset } - if err = p.Header[indx].UnmarshalSSZ(buf); err != nil { - return err + } else { + if len(sszSlice3) > 0 { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.Header") } - return nil - }) - if err != nil { - return err + c.Header = make([]*PartialDataColumnHeader, 0) } } return err } -// SizeSSZ returns the ssz encoded size in bytes for the PartialDataColumnSidecar object -func (p *PartialDataColumnSidecar) SizeSSZ() (size int) { - size = 16 - - // Field (0) 'CellsPresentBitmap' - size += len(p.CellsPresentBitmap) - - // Field (1) 'PartialColumn' - size += len(p.PartialColumn) * 2048 - - // Field (2) 'KzgProofs' - size += len(p.KzgProofs) * 48 - - // Field (3) 'Header' - for ii := 0; ii < len(p.Header); ii++ { - size += 4 - size += p.Header[ii].SizeSSZ() +func (c *PartialDataColumnSidecar) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - - return -} - -// HashTreeRoot ssz hashes the PartialDataColumnSidecar object -func (p *PartialDataColumnSidecar) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(p) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the PartialDataColumnSidecar object with a hasher -func (p *PartialDataColumnSidecar) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *PartialDataColumnSidecar) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'CellsPresentBitmap' - if len(p.CellsPresentBitmap) == 0 { - err = ssz.ErrEmptyBitlist - return + // Field 0: CellsPresentBitmap + if len(c.CellsPresentBitmap) == 0 { + return ssz.ErrEmptyBitlist } - hh.PutBitlist(p.CellsPresentBitmap, 4096) - - // Field (1) 'PartialColumn' + hh.PutBitlist(c.CellsPresentBitmap, 4096) + // Field 1: PartialColumn { - if size := len(p.PartialColumn); size > 4096 { - err = ssz.ErrListTooBigFn("--.PartialColumn", size, 4096) - return + if len(c.PartialColumn) > 4096 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range p.PartialColumn { - if len(i) != 2048 { - err = ssz.ErrBytesLength - return + for _, o := range c.PartialColumn { + if len(o) != 2048 { + return ssz.ErrBytesLength } - hh.PutBytes(i) + hh.PutBytes(o) } - - numItems := uint64(len(p.PartialColumn)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.PartialColumn)), 4096) } - - // Field (2) 'KzgProofs' + // Field 2: KzgProofs { - if size := len(p.KzgProofs); size > 4096 { - err = ssz.ErrListTooBigFn("--.KzgProofs", size, 4096) - return + if len(c.KzgProofs) > 4096 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range p.KzgProofs { - if len(i) != 48 { - err = ssz.ErrBytesLength - return + for _, o := range c.KzgProofs { + if len(o) != 48 { + return ssz.ErrBytesLength } - hh.PutBytes(i) + hh.PutBytes(o) } - - numItems := uint64(len(p.KzgProofs)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.KzgProofs)), 4096) } - - // Field (3) 'Header' + // Field 3: Header { + if len(c.Header) > 1 { + return ssz.ErrListTooBig + } subIndx := hh.Index() - num := uint64(len(p.Header)) - if num > 1 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range p.Header { - if err = elem.HashTreeRootWith(hh); err != nil { - return + for _, o := range c.Header { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Header: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 1) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Header)), 1) } - hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the PartialDataColumnHeader object -func (p *PartialDataColumnHeader) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(p) +func (c *SignedBeaconBlockContentsFulu) SizeSSZ() int { + size := 12 + if c.Block == nil { + c.Block = new(SignedBeaconBlockFulu) + } + size += c.Block.SizeSSZ() + size += len(c.KzgProofs) * 48 + size += len(c.Blobs) * 131072 + return size } -// MarshalSSZTo ssz marshals the PartialDataColumnHeader object to a target array -func (p *PartialDataColumnHeader) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(340) +func (c *SignedBeaconBlockContentsFulu) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Offset (0) 'KzgCommitments' - dst = ssz.WriteOffset(dst, offset) - offset += len(p.KzgCommitments) * 48 +func (c *SignedBeaconBlockContentsFulu) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 12 - // Field (1) 'SignedBlockHeader' - if p.SignedBlockHeader == nil { - p.SignedBlockHeader = new(SignedBeaconBlockHeader) + // Field 0: Block + if c.Block == nil { + c.Block = new(SignedBeaconBlockFulu) } - if dst, err = p.SignedBlockHeader.MarshalSSZTo(dst); err != nil { - return + dst = ssz.WriteOffset(dst, offset) + offset += c.Block.SizeSSZ() + + // Field 1: KzgProofs + dst = ssz.WriteOffset(dst, offset) + offset += len(c.KzgProofs) * 48 + + // Field 2: Blobs + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Blobs) * 131072 + + // Field 0: Block + if dst, err = c.Block.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Block: %w", err) } - // Field (2) 'KzgCommitmentsInclusionProof' - if size := len(p.KzgCommitmentsInclusionProof); size != 4 { - err = ssz.ErrVectorLengthFn("--.KzgCommitmentsInclusionProof", size, 4) - return + // Field 1: KzgProofs + if len(c.KzgProofs) > 33554432 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < 4; ii++ { - if size := len(p.KzgCommitmentsInclusionProof[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.KzgCommitmentsInclusionProof[ii]", size, 32) - return + for _, o := range c.KzgProofs { + if len(o) != 48 { + return nil, ssz.ErrBytesLength } - dst = append(dst, p.KzgCommitmentsInclusionProof[ii]...) + dst = append(dst, o...) } - // Field (0) 'KzgCommitments' - if size := len(p.KzgCommitments); size > 4096 { - err = ssz.ErrListTooBigFn("--.KzgCommitments", size, 4096) - return + // Field 2: Blobs + if len(c.Blobs) > 4096 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(p.KzgCommitments); ii++ { - if size := len(p.KzgCommitments[ii]); size != 48 { - err = ssz.ErrBytesLengthFn("--.KzgCommitments[ii]", size, 48) - return + for _, o := range c.Blobs { + if len(o) != 131072 { + return nil, ssz.ErrBytesLength } - dst = append(dst, p.KzgCommitments[ii]...) + dst = append(dst, o...) } - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the PartialDataColumnHeader object -func (p *PartialDataColumnHeader) UnmarshalSSZ(buf []byte) error { +func (c *SignedBeaconBlockContentsFulu) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 340 { + if size < 12 { return ssz.ErrSize } - tail := buf - var o0 uint64 - - // Offset (0) 'KzgCommitments' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Block + if sszVarOffset0 != 12 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset0 > size { return ssz.ErrOffset } - - if o0 != 340 { - return ssz.ErrInvalidVariableOffset + sszVarOffset1 := ssz.ReadOffset(buf[4:8]) // c.KzgProofs + if sszVarOffset1 > size || sszVarOffset1 < sszVarOffset0 { + return ssz.ErrOffset } - - // Field (1) 'SignedBlockHeader' - if p.SignedBlockHeader == nil { - p.SignedBlockHeader = new(SignedBeaconBlockHeader) + sszVarOffset2 := ssz.ReadOffset(buf[8:12]) // c.Blobs + if sszVarOffset2 > size || sszVarOffset2 < sszVarOffset1 { + return ssz.ErrOffset } - if err = p.SignedBlockHeader.UnmarshalSSZ(buf[4:212]); err != nil { - return err + sszSlice0 := buf[sszVarOffset0:sszVarOffset1] // c.Block + sszSlice1 := buf[sszVarOffset1:sszVarOffset2] // c.KzgProofs + sszSlice2 := buf[sszVarOffset2:] // c.Blobs + + // Field 0: Block + c.Block = new(SignedBeaconBlockFulu) + if err = c.Block.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Block: %w", err) } - // Field (2) 'KzgCommitmentsInclusionProof' - p.KzgCommitmentsInclusionProof = make([][]byte, 4) - for ii := 0; ii < 4; ii++ { - if cap(p.KzgCommitmentsInclusionProof[ii]) == 0 { - p.KzgCommitmentsInclusionProof[ii] = make([]byte, 0, len(buf[212:340][ii*32:(ii+1)*32])) + // Field 1: KzgProofs + { + if len(sszSlice1)%48 != 0 { + return fmt.Errorf("misaligned bytes: c.KzgProofs length is %d, which is not a multiple of 48: %w", len(sszSlice1), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice1) / 48 + if numElem > 33554432 { + return fmt.Errorf("ssz-max exceeded: c.KzgProofs has %d elements, ssz-max is 33554432: %w", numElem, ssz.ErrListTooBig) + } + c.KzgProofs = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte + + tmpSlice := sszSlice1[i*48 : (1+i)*48] + tmp = make([]byte, 0, 48) + tmp = append(tmp, tmpSlice...) + c.KzgProofs[i] = tmp } - p.KzgCommitmentsInclusionProof[ii] = append(p.KzgCommitmentsInclusionProof[ii], buf[212:340][ii*32:(ii+1)*32]...) } - // Field (0) 'KzgCommitments' + // Field 2: Blobs { - buf = tail[o0:] - num, err := ssz.DivideInt2(len(buf), 48, 4096) - if err != nil { - return err - } - p.KzgCommitments = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(p.KzgCommitments[ii]) == 0 { - p.KzgCommitments[ii] = make([]byte, 0, len(buf[ii*48:(ii+1)*48])) - } - p.KzgCommitments[ii] = append(p.KzgCommitments[ii], buf[ii*48:(ii+1)*48]...) + if len(sszSlice2)%131072 != 0 { + return fmt.Errorf("misaligned bytes: c.Blobs length is %d, which is not a multiple of 131072: %w", len(sszSlice2), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice2) / 131072 + if numElem > 4096 { + return fmt.Errorf("ssz-max exceeded: c.Blobs has %d elements, ssz-max is 4096: %w", numElem, ssz.ErrListTooBig) + } + c.Blobs = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte + + tmpSlice := sszSlice2[i*131072 : (1+i)*131072] + tmp = make([]byte, 0, 131072) + tmp = append(tmp, tmpSlice...) + c.Blobs[i] = tmp } } return err } -// SizeSSZ returns the ssz encoded size in bytes for the PartialDataColumnHeader object -func (p *PartialDataColumnHeader) SizeSSZ() (size int) { - size = 340 - - // Field (0) 'KzgCommitments' - size += len(p.KzgCommitments) * 48 - - return -} - -// HashTreeRoot ssz hashes the PartialDataColumnHeader object -func (p *PartialDataColumnHeader) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(p) +func (c *SignedBeaconBlockContentsFulu) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the PartialDataColumnHeader object with a hasher -func (p *PartialDataColumnHeader) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *SignedBeaconBlockContentsFulu) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'KzgCommitments' + // Field 0: Block + if err := c.Block.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Block: %w", err) + } + // Field 1: KzgProofs { - if size := len(p.KzgCommitments); size > 4096 { - err = ssz.ErrListTooBigFn("--.KzgCommitments", size, 4096) - return + if len(c.KzgProofs) > 33554432 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range p.KzgCommitments { - if len(i) != 48 { - err = ssz.ErrBytesLength - return + for _, o := range c.KzgProofs { + if len(o) != 48 { + return ssz.ErrBytesLength } - hh.PutBytes(i) + hh.PutBytes(o) } - - numItems := uint64(len(p.KzgCommitments)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) - } - - // Field (1) 'SignedBlockHeader' - if err = p.SignedBlockHeader.HashTreeRootWith(hh); err != nil { - return + hh.MerkleizeWithMixin(subIndx, uint64(len(c.KzgProofs)), 33554432) } - - // Field (2) 'KzgCommitmentsInclusionProof' + // Field 2: Blobs { - if size := len(p.KzgCommitmentsInclusionProof); size != 4 { - err = ssz.ErrVectorLengthFn("--.KzgCommitmentsInclusionProof", size, 4) - return + if len(c.Blobs) > 4096 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range p.KzgCommitmentsInclusionProof { - if len(i) != 32 { - err = ssz.ErrBytesLength - return + for _, o := range c.Blobs { + if len(o) != 131072 { + return ssz.ErrBytesLength } - hh.Append(i) + hh.PutBytes(o) } - hh.Merkleize(subIndx) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Blobs)), 4096) } - hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the PartialDataColumnPartsMetadata object -func (p *PartialDataColumnPartsMetadata) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(p) +func (c *SignedBeaconBlockFulu) SizeSSZ() int { + size := 100 + if c.Block == nil { + c.Block = new(BeaconBlockElectra) + } + size += c.Block.SizeSSZ() + return size } -// MarshalSSZTo ssz marshals the PartialDataColumnPartsMetadata object to a target array -func (p *PartialDataColumnPartsMetadata) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(8) +func (c *SignedBeaconBlockFulu) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Offset (0) 'Available' - dst = ssz.WriteOffset(dst, offset) - offset += len(p.Available) +func (c *SignedBeaconBlockFulu) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 100 - // Offset (1) 'Requests' + // Field 0: Block + if c.Block == nil { + c.Block = new(BeaconBlockElectra) + } dst = ssz.WriteOffset(dst, offset) - offset += len(p.Requests) + offset += c.Block.SizeSSZ() - // Field (0) 'Available' - if size := len(p.Available); size > 4096 { - err = ssz.ErrBytesLengthFn("--.Available", size, 4096) - return + // Field 1: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } - dst = append(dst, p.Available...) + dst = append(dst, c.Signature...) - // Field (1) 'Requests' - if size := len(p.Requests); size > 4096 { - err = ssz.ErrBytesLengthFn("--.Requests", size, 4096) - return + // Field 0: Block + if dst, err = c.Block.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Block: %w", err) } - dst = append(dst, p.Requests...) - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the PartialDataColumnPartsMetadata object -func (p *PartialDataColumnPartsMetadata) UnmarshalSSZ(buf []byte) error { +func (c *SignedBeaconBlockFulu) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 8 { + if size < 100 { return ssz.ErrSize } - tail := buf - var o0, o1 uint64 + sszSlice1 := buf[4:100] // c.Signature - // Offset (0) 'Available' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Block + if sszVarOffset0 != 100 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset0 > size { return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:] // c.Block - if o0 != 8 { - return ssz.ErrInvalidVariableOffset + // Field 0: Block + c.Block = new(BeaconBlockElectra) + if err = c.Block.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Block: %w", err) } - // Offset (1) 'Requests' - if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 { - return ssz.ErrOffset + // Field 1: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice1...) + return err +} + +func (c *SignedBeaconBlockFulu) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (0) 'Available' - { - buf = tail[o0:o1] - if err = ssz.ValidateBitlist(buf, 4096); err != nil { - return err - } - if cap(p.Available) == 0 { - p.Available = make([]byte, 0, len(buf)) - } - p.Available = append(p.Available, buf...) +func (c *SignedBeaconBlockFulu) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Block + if err := c.Block.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Block: %w", err) + } + // Field 1: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength } + hh.PutBytes(c.Signature) + hh.Merkleize(indx) + return nil +} - // Field (1) 'Requests' - { - buf = tail[o1:] - if err = ssz.ValidateBitlist(buf, 4096); err != nil { - return err - } - if cap(p.Requests) == 0 { - p.Requests = make([]byte, 0, len(buf)) - } - p.Requests = append(p.Requests, buf...) +func (c *SignedBlindedBeaconBlockFulu) SizeSSZ() int { + size := 100 + if c.Message == nil { + c.Message = new(BlindedBeaconBlockFulu) } - return err + size += c.Message.SizeSSZ() + return size +} + +func (c *SignedBlindedBeaconBlockFulu) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} + +func (c *SignedBlindedBeaconBlockFulu) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 100 + + // Field 0: Message + if c.Message == nil { + c.Message = new(BlindedBeaconBlockFulu) + } + dst = ssz.WriteOffset(dst, offset) + offset += c.Message.SizeSSZ() + + // Field 1: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.Signature...) + + // Field 0: Message + if dst, err = c.Message.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Message: %w", err) + } + return dst, err } -// SizeSSZ returns the ssz encoded size in bytes for the PartialDataColumnPartsMetadata object -func (p *PartialDataColumnPartsMetadata) SizeSSZ() (size int) { - size = 8 +func (c *SignedBlindedBeaconBlockFulu) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 100 { + return ssz.ErrSize + } + + sszSlice1 := buf[4:100] // c.Signature - // Field (0) 'Available' - size += len(p.Available) + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Message + if sszVarOffset0 != 100 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset0 > size { + return ssz.ErrOffset + } + sszSlice0 := buf[sszVarOffset0:] // c.Message - // Field (1) 'Requests' - size += len(p.Requests) + // Field 0: Message + c.Message = new(BlindedBeaconBlockFulu) + if err = c.Message.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Message: %w", err) + } - return + // Field 1: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice1...) + return err } -// HashTreeRoot ssz hashes the PartialDataColumnPartsMetadata object -func (p *PartialDataColumnPartsMetadata) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(p) +func (c *SignedBlindedBeaconBlockFulu) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the PartialDataColumnPartsMetadata object with a hasher -func (p *PartialDataColumnPartsMetadata) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *SignedBlindedBeaconBlockFulu) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() + // Field 0: Message + if err := c.Message.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Message: %w", err) + } + // Field 1: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Signature) + hh.Merkleize(indx) + return nil +} + +func (c *StatusV2) SizeSSZ() int { + size := 92 + + return size +} + +func (c *StatusV2) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} + +func (c *StatusV2) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + + // Field 0: ForkDigest + if len(c.ForkDigest) != 4 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.ForkDigest...) + + // Field 1: FinalizedRoot + if len(c.FinalizedRoot) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.FinalizedRoot...) + + // Field 2: FinalizedEpoch + if dst, err = c.FinalizedEpoch.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("FinalizedEpoch: %w", err) + } - // Field (0) 'Available' - if len(p.Available) == 0 { - err = ssz.ErrEmptyBitlist - return + // Field 3: HeadRoot + if len(c.HeadRoot) != 32 { + return nil, ssz.ErrBytesLength } - hh.PutBitlist(p.Available, 4096) + dst = append(dst, c.HeadRoot...) - // Field (1) 'Requests' - if len(p.Requests) == 0 { - err = ssz.ErrEmptyBitlist - return + // Field 4: HeadSlot + if dst, err = c.HeadSlot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("HeadSlot: %w", err) } - hh.PutBitlist(p.Requests, 4096) + // Field 5: EarliestAvailableSlot + if dst, err = c.EarliestAvailableSlot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("EarliestAvailableSlot: %w", err) + } + + return dst, err +} + +func (c *StatusV2) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 92 { + return ssz.ErrSize + } + + sszSlice0 := buf[0:4] // c.ForkDigest + sszSlice1 := buf[4:36] // c.FinalizedRoot + sszSlice2 := buf[36:44] // c.FinalizedEpoch + sszSlice3 := buf[44:76] // c.HeadRoot + sszSlice4 := buf[76:84] // c.HeadSlot + sszSlice5 := buf[84:92] // c.EarliestAvailableSlot + + // Field 0: ForkDigest + c.ForkDigest = make([]byte, 0, 4) + c.ForkDigest = append(c.ForkDigest, sszSlice0...) + + // Field 1: FinalizedRoot + c.FinalizedRoot = make([]byte, 0, 32) + c.FinalizedRoot = append(c.FinalizedRoot, sszSlice1...) + + // Field 2: FinalizedEpoch + if err = c.FinalizedEpoch.UnmarshalSSZ(sszSlice2); err != nil { + return fmt.Errorf("FinalizedEpoch: %w", err) + } + + // Field 3: HeadRoot + c.HeadRoot = make([]byte, 0, 32) + c.HeadRoot = append(c.HeadRoot, sszSlice3...) + + // Field 4: HeadSlot + if err = c.HeadSlot.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("HeadSlot: %w", err) + } + + // Field 5: EarliestAvailableSlot + if err = c.EarliestAvailableSlot.UnmarshalSSZ(sszSlice5); err != nil { + return fmt.Errorf("EarliestAvailableSlot: %w", err) + } + return err +} + +func (c *StatusV2) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} + +func (c *StatusV2) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: ForkDigest + if len(c.ForkDigest) != 4 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ForkDigest) + // Field 1: FinalizedRoot + if len(c.FinalizedRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.FinalizedRoot) + // Field 2: FinalizedEpoch + if err := c.FinalizedEpoch.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("FinalizedEpoch: %w", err) + } + // Field 3: HeadRoot + if len(c.HeadRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.HeadRoot) + // Field 4: HeadSlot + if err := c.HeadSlot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("HeadSlot: %w", err) + } + // Field 5: EarliestAvailableSlot + if err := c.EarliestAvailableSlot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("EarliestAvailableSlot: %w", err) + } hh.Merkleize(indx) - return + return nil } diff --git a/proto/prysm/v1alpha1/fulu.ssz.go b/proto/prysm/v1alpha1/fulu.ssz.go index 38cd4596140e..aa61b360852d 100644 --- a/proto/prysm/v1alpha1/fulu.ssz.go +++ b/proto/prysm/v1alpha1/fulu.ssz.go @@ -1,3076 +1,2911 @@ //go:build !minimal -// Code generated by fastssz. DO NOT EDIT. package eth import ( - github_com_OffchainLabs_prysm_v7_consensus_types_primitives "github.com/OffchainLabs/prysm/v7/consensus-types/primitives" + binary "encoding/binary" + "fmt" + go_bitfield "github.com/OffchainLabs/go-bitfield" + ssz "github.com/OffchainLabs/methodical-ssz/ssz" + primitives "github.com/OffchainLabs/prysm/v7/consensus-types/primitives" v1 "github.com/OffchainLabs/prysm/v7/proto/engine/v1" - ssz "github.com/prysmaticlabs/fastssz" ) -// MarshalSSZ ssz marshals the SignedBeaconBlockContentsFulu object -func (s *SignedBeaconBlockContentsFulu) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) +func (c *BeaconBlockContentsFulu) SizeSSZ() int { + size := 12 + if c.Block == nil { + c.Block = new(BeaconBlockElectra) + } + size += c.Block.SizeSSZ() + size += len(c.KzgProofs) * 48 + size += len(c.Blobs) * 131072 + return size } -// MarshalSSZTo ssz marshals the SignedBeaconBlockContentsFulu object to a target array -func (s *SignedBeaconBlockContentsFulu) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(12) +func (c *BeaconBlockContentsFulu) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Offset (0) 'Block' - dst = ssz.WriteOffset(dst, offset) - if s.Block == nil { - s.Block = new(SignedBeaconBlockFulu) +func (c *BeaconBlockContentsFulu) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 12 + + // Field 0: Block + if c.Block == nil { + c.Block = new(BeaconBlockElectra) } - offset += s.Block.SizeSSZ() + dst = ssz.WriteOffset(dst, offset) + offset += c.Block.SizeSSZ() - // Offset (1) 'KzgProofs' + // Field 1: KzgProofs dst = ssz.WriteOffset(dst, offset) - offset += len(s.KzgProofs) * 48 + offset += len(c.KzgProofs) * 48 - // Offset (2) 'Blobs' + // Field 2: Blobs dst = ssz.WriteOffset(dst, offset) - offset += len(s.Blobs) * 131072 + offset += len(c.Blobs) * 131072 - // Field (0) 'Block' - if dst, err = s.Block.MarshalSSZTo(dst); err != nil { - return + // Field 0: Block + if dst, err = c.Block.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Block: %w", err) } - // Field (1) 'KzgProofs' - if size := len(s.KzgProofs); size > 33554432 { - err = ssz.ErrListTooBigFn("--.KzgProofs", size, 33554432) - return + // Field 1: KzgProofs + if len(c.KzgProofs) > 33554432 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(s.KzgProofs); ii++ { - if size := len(s.KzgProofs[ii]); size != 48 { - err = ssz.ErrBytesLengthFn("--.KzgProofs[ii]", size, 48) - return + for _, o := range c.KzgProofs { + if len(o) != 48 { + return nil, ssz.ErrBytesLength } - dst = append(dst, s.KzgProofs[ii]...) + dst = append(dst, o...) } - // Field (2) 'Blobs' - if size := len(s.Blobs); size > 4096 { - err = ssz.ErrListTooBigFn("--.Blobs", size, 4096) - return + // Field 2: Blobs + if len(c.Blobs) > 4096 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(s.Blobs); ii++ { - if size := len(s.Blobs[ii]); size != 131072 { - err = ssz.ErrBytesLengthFn("--.Blobs[ii]", size, 131072) - return + for _, o := range c.Blobs { + if len(o) != 131072 { + return nil, ssz.ErrBytesLength } - dst = append(dst, s.Blobs[ii]...) + dst = append(dst, o...) } - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the SignedBeaconBlockContentsFulu object -func (s *SignedBeaconBlockContentsFulu) UnmarshalSSZ(buf []byte) error { +func (c *BeaconBlockContentsFulu) 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) 'Block' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } - - if o0 != 12 { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Block + if sszVarOffset0 != 12 { return ssz.ErrInvalidVariableOffset } - - // Offset (1) 'KzgProofs' - if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 { + if sszVarOffset0 > size { return ssz.ErrOffset } - - // Offset (2) 'Blobs' - if o2 = ssz.ReadOffset(buf[8:12]); o2 > size || o1 > o2 { + sszVarOffset1 := ssz.ReadOffset(buf[4:8]) // c.KzgProofs + if sszVarOffset1 > size || sszVarOffset1 < sszVarOffset0 { return ssz.ErrOffset } - - // Field (0) 'Block' - { - buf = tail[o0:o1] - if s.Block == nil { - s.Block = new(SignedBeaconBlockFulu) - } - if err = s.Block.UnmarshalSSZ(buf); err != nil { - return err - } - } - - // Field (1) 'KzgProofs' - { - buf = tail[o1:o2] - num, err := ssz.DivideInt2(len(buf), 48, 33554432) - if err != nil { - return err - } - s.KzgProofs = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(s.KzgProofs[ii]) == 0 { - s.KzgProofs[ii] = make([]byte, 0, len(buf[ii*48:(ii+1)*48])) - } - s.KzgProofs[ii] = append(s.KzgProofs[ii], buf[ii*48:(ii+1)*48]...) - } - } - - // Field (2) 'Blobs' - { - buf = tail[o2:] - num, err := ssz.DivideInt2(len(buf), 131072, 4096) - if err != nil { - return err - } - s.Blobs = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(s.Blobs[ii]) == 0 { - s.Blobs[ii] = make([]byte, 0, len(buf[ii*131072:(ii+1)*131072])) - } - s.Blobs[ii] = append(s.Blobs[ii], buf[ii*131072:(ii+1)*131072]...) - } - } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the SignedBeaconBlockContentsFulu object -func (s *SignedBeaconBlockContentsFulu) SizeSSZ() (size int) { - size = 12 - - // Field (0) 'Block' - if s.Block == nil { - s.Block = new(SignedBeaconBlockFulu) - } - size += s.Block.SizeSSZ() - - // Field (1) 'KzgProofs' - size += len(s.KzgProofs) * 48 - - // Field (2) 'Blobs' - size += len(s.Blobs) * 131072 - - return -} - -// HashTreeRoot ssz hashes the SignedBeaconBlockContentsFulu object -func (s *SignedBeaconBlockContentsFulu) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) -} - -// HashTreeRootWith ssz hashes the SignedBeaconBlockContentsFulu object with a hasher -func (s *SignedBeaconBlockContentsFulu) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'Block' - if err = s.Block.HashTreeRootWith(hh); err != nil { - return - } - - // Field (1) 'KzgProofs' - { - if size := len(s.KzgProofs); size > 33554432 { - err = ssz.ErrListTooBigFn("--.KzgProofs", size, 33554432) - return - } - subIndx := hh.Index() - for _, i := range s.KzgProofs { - if len(i) != 48 { - err = ssz.ErrBytesLength - return - } - hh.PutBytes(i) - } - - numItems := uint64(len(s.KzgProofs)) - hh.MerkleizeWithMixin(subIndx, numItems, 33554432) - } - - // Field (2) 'Blobs' - { - if size := len(s.Blobs); size > 4096 { - err = ssz.ErrListTooBigFn("--.Blobs", size, 4096) - return - } - subIndx := hh.Index() - for _, i := range s.Blobs { - if len(i) != 131072 { - err = ssz.ErrBytesLength - return - } - hh.PutBytes(i) - } - - numItems := uint64(len(s.Blobs)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) - } - - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the SignedBeaconBlockFulu object -func (s *SignedBeaconBlockFulu) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) -} - -// MarshalSSZTo ssz marshals the SignedBeaconBlockFulu object to a target array -func (s *SignedBeaconBlockFulu) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(100) - - // Offset (0) 'Block' - dst = ssz.WriteOffset(dst, offset) - if s.Block == nil { - s.Block = new(BeaconBlockElectra) - } - offset += s.Block.SizeSSZ() - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.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 SignedBeaconBlockFulu object -func (s *SignedBeaconBlockFulu) 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 { + sszVarOffset2 := ssz.ReadOffset(buf[8:12]) // c.Blobs + if sszVarOffset2 > size || sszVarOffset2 < sszVarOffset1 { return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:sszVarOffset1] // c.Block + sszSlice1 := buf[sszVarOffset1:sszVarOffset2] // c.KzgProofs + sszSlice2 := buf[sszVarOffset2:] // c.Blobs - if o0 != 100 { - return ssz.ErrInvalidVariableOffset - } - - // Field (1) 'Signature' - if cap(s.Signature) == 0 { - s.Signature = make([]byte, 0, len(buf[4:100])) + // Field 0: Block + c.Block = new(BeaconBlockElectra) + if err = c.Block.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Block: %w", err) } - s.Signature = append(s.Signature, buf[4:100]...) - // Field (0) 'Block' + // Field 1: KzgProofs { - buf = tail[o0:] - if s.Block == nil { - s.Block = new(BeaconBlockElectra) + if len(sszSlice1)%48 != 0 { + return fmt.Errorf("misaligned bytes: c.KzgProofs length is %d, which is not a multiple of 48: %w", len(sszSlice1), ssz.ErrIncorrectListSize) } - if err = s.Block.UnmarshalSSZ(buf); err != nil { - return err + numElem := len(sszSlice1) / 48 + if numElem > 33554432 { + return fmt.Errorf("ssz-max exceeded: c.KzgProofs has %d elements, ssz-max is 33554432: %w", numElem, ssz.ErrListTooBig) } - } - return err -} + c.KzgProofs = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte -// SizeSSZ returns the ssz encoded size in bytes for the SignedBeaconBlockFulu object -func (s *SignedBeaconBlockFulu) SizeSSZ() (size int) { - size = 100 - - // Field (0) 'Block' - if s.Block == nil { - s.Block = new(BeaconBlockElectra) - } - size += s.Block.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the SignedBeaconBlockFulu object -func (s *SignedBeaconBlockFulu) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) -} - -// HashTreeRootWith ssz hashes the SignedBeaconBlockFulu object with a hasher -func (s *SignedBeaconBlockFulu) HashTreeRootWith(hh *ssz.Hasher) (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("--.Signature", size, 96) - return - } - hh.PutBytes(s.Signature) - - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the BeaconBlockContentsFulu object -func (b *BeaconBlockContentsFulu) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} - -// MarshalSSZTo ssz marshals the BeaconBlockContentsFulu object to a target array -func (b *BeaconBlockContentsFulu) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(12) - - // Offset (0) 'Block' - dst = ssz.WriteOffset(dst, offset) - if b.Block == nil { - b.Block = new(BeaconBlockElectra) - } - offset += b.Block.SizeSSZ() - - // Offset (1) 'KzgProofs' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.KzgProofs) * 48 - - // Offset (2) 'Blobs' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.Blobs) * 131072 - - // Field (0) 'Block' - if dst, err = b.Block.MarshalSSZTo(dst); err != nil { - return - } - - // Field (1) 'KzgProofs' - if size := len(b.KzgProofs); size > 33554432 { - err = ssz.ErrListTooBigFn("--.KzgProofs", size, 33554432) - return - } - for ii := 0; ii < len(b.KzgProofs); ii++ { - if size := len(b.KzgProofs[ii]); size != 48 { - err = ssz.ErrBytesLengthFn("--.KzgProofs[ii]", size, 48) - return + tmpSlice := sszSlice1[i*48 : (1+i)*48] + tmp = make([]byte, 0, 48) + tmp = append(tmp, tmpSlice...) + c.KzgProofs[i] = tmp } - dst = append(dst, b.KzgProofs[ii]...) - } - - // Field (2) 'Blobs' - if size := len(b.Blobs); size > 4096 { - err = ssz.ErrListTooBigFn("--.Blobs", size, 4096) - return - } - for ii := 0; ii < len(b.Blobs); ii++ { - if size := len(b.Blobs[ii]); size != 131072 { - err = ssz.ErrBytesLengthFn("--.Blobs[ii]", size, 131072) - return - } - dst = append(dst, b.Blobs[ii]...) - } - - return -} - -// UnmarshalSSZ ssz unmarshals the BeaconBlockContentsFulu object -func (b *BeaconBlockContentsFulu) 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) 'Block' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } - - if o0 != 12 { - return ssz.ErrInvalidVariableOffset - } - - // Offset (1) 'KzgProofs' - if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 { - return ssz.ErrOffset - } - - // Offset (2) 'Blobs' - if o2 = ssz.ReadOffset(buf[8:12]); o2 > size || o1 > o2 { - return ssz.ErrOffset - } - - // Field (0) 'Block' + // Field 2: Blobs { - buf = tail[o0:o1] - if b.Block == nil { - b.Block = new(BeaconBlockElectra) - } - if err = b.Block.UnmarshalSSZ(buf); err != nil { - return err + if len(sszSlice2)%131072 != 0 { + return fmt.Errorf("misaligned bytes: c.Blobs length is %d, which is not a multiple of 131072: %w", len(sszSlice2), ssz.ErrIncorrectListSize) } - } - - // Field (1) 'KzgProofs' - { - buf = tail[o1:o2] - num, err := ssz.DivideInt2(len(buf), 48, 33554432) - if err != nil { - return err - } - b.KzgProofs = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(b.KzgProofs[ii]) == 0 { - b.KzgProofs[ii] = make([]byte, 0, len(buf[ii*48:(ii+1)*48])) - } - b.KzgProofs[ii] = append(b.KzgProofs[ii], buf[ii*48:(ii+1)*48]...) + numElem := len(sszSlice2) / 131072 + if numElem > 4096 { + return fmt.Errorf("ssz-max exceeded: c.Blobs has %d elements, ssz-max is 4096: %w", numElem, ssz.ErrListTooBig) } - } + c.Blobs = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte - // Field (2) 'Blobs' - { - buf = tail[o2:] - num, err := ssz.DivideInt2(len(buf), 131072, 4096) - if err != nil { - return err - } - b.Blobs = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(b.Blobs[ii]) == 0 { - b.Blobs[ii] = make([]byte, 0, len(buf[ii*131072:(ii+1)*131072])) - } - b.Blobs[ii] = append(b.Blobs[ii], buf[ii*131072:(ii+1)*131072]...) + tmpSlice := sszSlice2[i*131072 : (1+i)*131072] + tmp = make([]byte, 0, 131072) + tmp = append(tmp, tmpSlice...) + c.Blobs[i] = tmp } } return err } -// SizeSSZ returns the ssz encoded size in bytes for the BeaconBlockContentsFulu object -func (b *BeaconBlockContentsFulu) SizeSSZ() (size int) { - size = 12 - - // Field (0) 'Block' - if b.Block == nil { - b.Block = new(BeaconBlockElectra) +func (c *BeaconBlockContentsFulu) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - size += b.Block.SizeSSZ() - - // Field (1) 'KzgProofs' - size += len(b.KzgProofs) * 48 - - // Field (2) 'Blobs' - size += len(b.Blobs) * 131072 - - return + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRoot ssz hashes the BeaconBlockContentsFulu object -func (b *BeaconBlockContentsFulu) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) -} - -// HashTreeRootWith ssz hashes the BeaconBlockContentsFulu object with a hasher -func (b *BeaconBlockContentsFulu) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *BeaconBlockContentsFulu) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Block' - if err = b.Block.HashTreeRootWith(hh); err != nil { - return + // Field 0: Block + if err := c.Block.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Block: %w", err) } - - // Field (1) 'KzgProofs' + // Field 1: KzgProofs { - if size := len(b.KzgProofs); size > 33554432 { - err = ssz.ErrListTooBigFn("--.KzgProofs", size, 33554432) - return + if len(c.KzgProofs) > 33554432 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range b.KzgProofs { - if len(i) != 48 { - err = ssz.ErrBytesLength - return + for _, o := range c.KzgProofs { + if len(o) != 48 { + return ssz.ErrBytesLength } - hh.PutBytes(i) + hh.PutBytes(o) } - - numItems := uint64(len(b.KzgProofs)) - hh.MerkleizeWithMixin(subIndx, numItems, 33554432) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.KzgProofs)), 33554432) } - - // Field (2) 'Blobs' + // Field 2: Blobs { - if size := len(b.Blobs); size > 4096 { - err = ssz.ErrListTooBigFn("--.Blobs", size, 4096) - return + if len(c.Blobs) > 4096 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range b.Blobs { - if len(i) != 131072 { - err = ssz.ErrBytesLength - return + for _, o := range c.Blobs { + if len(o) != 131072 { + return ssz.ErrBytesLength } - hh.PutBytes(i) + hh.PutBytes(o) } - - numItems := uint64(len(b.Blobs)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Blobs)), 4096) } - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the SignedBlindedBeaconBlockFulu object -func (s *SignedBlindedBeaconBlockFulu) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) -} - -// MarshalSSZTo ssz marshals the SignedBlindedBeaconBlockFulu object to a target array -func (s *SignedBlindedBeaconBlockFulu) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(100) - - // Offset (0) 'Message' - dst = ssz.WriteOffset(dst, offset) - if s.Message == nil { - s.Message = new(BlindedBeaconBlockFulu) - } - offset += s.Message.SizeSSZ() - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return - } - dst = append(dst, s.Signature...) - - // Field (0) 'Message' - if dst, err = s.Message.MarshalSSZTo(dst); err != nil { - return - } - - return -} - -// UnmarshalSSZ ssz unmarshals the SignedBlindedBeaconBlockFulu object -func (s *SignedBlindedBeaconBlockFulu) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 100 { - return ssz.ErrSize - } - - tail := buf - var o0 uint64 - - // Offset (0) 'Message' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } - - if o0 != 100 { - return ssz.ErrInvalidVariableOffset - } - - // Field (1) 'Signature' - if cap(s.Signature) == 0 { - s.Signature = make([]byte, 0, len(buf[4:100])) - } - s.Signature = append(s.Signature, buf[4:100]...) - - // Field (0) 'Message' - { - buf = tail[o0:] - if s.Message == nil { - s.Message = new(BlindedBeaconBlockFulu) - } - if err = s.Message.UnmarshalSSZ(buf); err != nil { - return err - } - } - return err + return nil } -// SizeSSZ returns the ssz encoded size in bytes for the SignedBlindedBeaconBlockFulu object -func (s *SignedBlindedBeaconBlockFulu) SizeSSZ() (size int) { - size = 100 - - // Field (0) 'Message' - if s.Message == nil { - s.Message = new(BlindedBeaconBlockFulu) +func (c *BeaconStateFulu) SizeSSZ() int { + size := 2737225 + size += len(c.HistoricalRoots) * 32 + size += len(c.Eth1DataVotes) * 72 + size += len(c.Validators) * 121 + size += len(c.Balances) * 8 + size += len(c.PreviousEpochParticipation) + size += len(c.CurrentEpochParticipation) + size += len(c.InactivityScores) * 8 + if c.LatestExecutionPayloadHeader == nil { + c.LatestExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderDeneb) } - size += s.Message.SizeSSZ() - - return + size += c.LatestExecutionPayloadHeader.SizeSSZ() + size += len(c.HistoricalSummaries) * 64 + size += len(c.PendingDeposits) * 192 + size += len(c.PendingPartialWithdrawals) * 24 + size += len(c.PendingConsolidations) * 16 + return size } -// HashTreeRoot ssz hashes the SignedBlindedBeaconBlockFulu object -func (s *SignedBlindedBeaconBlockFulu) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) +func (c *BeaconStateFulu) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// HashTreeRootWith ssz hashes the SignedBlindedBeaconBlockFulu object with a hasher -func (s *SignedBlindedBeaconBlockFulu) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'Message' - if err = s.Message.HashTreeRootWith(hh); err != nil { - return - } - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return - } - hh.PutBytes(s.Signature) - - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the BlindedBeaconBlockFulu object -func (b *BlindedBeaconBlockFulu) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} - -// MarshalSSZTo ssz marshals the BlindedBeaconBlockFulu object to a target array -func (b *BlindedBeaconBlockFulu) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(84) - - // Field (0) 'Slot' - dst = ssz.MarshalUint(dst, b.Slot) - - // Field (1) 'ProposerIndex' - dst = ssz.MarshalUint(dst, b.ProposerIndex) - - // Field (2) 'ParentRoot' - if size := len(b.ParentRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentRoot", size, 32) - return - } - dst = append(dst, b.ParentRoot...) - - // Field (3) 'StateRoot' - if size := len(b.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return - } - dst = append(dst, b.StateRoot...) - - // Offset (4) 'Body' - dst = ssz.WriteOffset(dst, offset) - if b.Body == nil { - b.Body = new(BlindedBeaconBlockBodyElectra) - } - offset += b.Body.SizeSSZ() - - // Field (4) 'Body' - if dst, err = b.Body.MarshalSSZTo(dst); err != nil { - return - } - - return -} - -// UnmarshalSSZ ssz unmarshals the BlindedBeaconBlockFulu object -func (b *BlindedBeaconBlockFulu) UnmarshalSSZ(buf []byte) error { +func (c *BeaconStateFulu) MarshalSSZTo(dst []byte) ([]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.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[0:8]) - - // Field (1) 'ProposerIndex' - b.ProposerIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[8:16]) + offset := 2737225 - // 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 0: GenesisTime + dst = binary.LittleEndian.AppendUint64(dst, c.GenesisTime) - // Offset (4) 'Body' - if o4 = ssz.ReadOffset(buf[80:84]); o4 > size { - return ssz.ErrOffset + // Field 1: GenesisValidatorsRoot + if len(c.GenesisValidatorsRoot) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.GenesisValidatorsRoot...) - if o4 != 84 { - return ssz.ErrInvalidVariableOffset + // Field 2: Slot + if dst, err = c.Slot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Slot: %w", err) } - // Field (4) 'Body' - { - buf = tail[o4:] - if b.Body == nil { - b.Body = new(BlindedBeaconBlockBodyElectra) - } - if err = b.Body.UnmarshalSSZ(buf); err != nil { - return err - } - } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the BlindedBeaconBlockFulu object -func (b *BlindedBeaconBlockFulu) SizeSSZ() (size int) { - size = 84 - - // Field (4) 'Body' - if b.Body == nil { - b.Body = new(BlindedBeaconBlockBodyElectra) - } - size += b.Body.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the BlindedBeaconBlockFulu object -func (b *BlindedBeaconBlockFulu) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) -} - -// HashTreeRootWith ssz hashes the BlindedBeaconBlockFulu object with a hasher -func (b *BlindedBeaconBlockFulu) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'Slot' - ssz.PutUint(hh, b.Slot) - - // Field (1) 'ProposerIndex' - ssz.PutUint(hh, b.ProposerIndex) - - // Field (2) 'ParentRoot' - if size := len(b.ParentRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentRoot", size, 32) - return - } - hh.PutBytes(b.ParentRoot) - - // Field (3) 'StateRoot' - if size := len(b.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return - } - hh.PutBytes(b.StateRoot) - - // Field (4) 'Body' - if err = b.Body.HashTreeRootWith(hh); err != nil { - return - } - - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the BeaconStateFulu object -func (b *BeaconStateFulu) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} - -// MarshalSSZTo ssz marshals the BeaconStateFulu object to a target array -func (b *BeaconStateFulu) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(2737225) - - // Field (0) 'GenesisTime' - dst = ssz.MarshalUint(dst, b.GenesisTime) - - // Field (1) 'GenesisValidatorsRoot' - if size := len(b.GenesisValidatorsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.GenesisValidatorsRoot", size, 32) - return - } - dst = append(dst, b.GenesisValidatorsRoot...) - - // Field (2) 'Slot' - dst = ssz.MarshalUint(dst, b.Slot) - - // Field (3) 'Fork' - if b.Fork == nil { - b.Fork = new(Fork) + // Field 3: Fork + if c.Fork == nil { + c.Fork = new(Fork) } - if dst, err = b.Fork.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.Fork.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Fork: %w", err) } - // Field (4) 'LatestBlockHeader' - if b.LatestBlockHeader == nil { - b.LatestBlockHeader = new(BeaconBlockHeader) + // Field 4: LatestBlockHeader + if c.LatestBlockHeader == nil { + c.LatestBlockHeader = new(BeaconBlockHeader) } - if dst, err = b.LatestBlockHeader.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.LatestBlockHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("LatestBlockHeader: %w", err) } - // Field (5) 'BlockRoots' - if size := len(b.BlockRoots); size != 8192 { - err = ssz.ErrVectorLengthFn("--.BlockRoots", size, 8192) - return + // Field 5: BlockRoots + if len(c.BlockRoots) != 8192 { + return nil, ssz.ErrBytesLength } - for ii := 0; ii < 8192; ii++ { - if size := len(b.BlockRoots[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockRoots[ii]", size, 32) - return + for _, o := range c.BlockRoots { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.BlockRoots[ii]...) + dst = append(dst, o...) } - // Field (6) 'StateRoots' - if size := len(b.StateRoots); size != 8192 { - err = ssz.ErrVectorLengthFn("--.StateRoots", size, 8192) - return + // Field 6: StateRoots + if len(c.StateRoots) != 8192 { + return nil, ssz.ErrBytesLength } - for ii := 0; ii < 8192; ii++ { - if size := len(b.StateRoots[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoots[ii]", size, 32) - return + for _, o := range c.StateRoots { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.StateRoots[ii]...) + dst = append(dst, o...) } - // Offset (7) 'HistoricalRoots' + // Field 7: HistoricalRoots dst = ssz.WriteOffset(dst, offset) - offset += len(b.HistoricalRoots) * 32 + offset += len(c.HistoricalRoots) * 32 - // Field (8) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(Eth1Data) + // Field 8: Eth1Data + if c.Eth1Data == nil { + c.Eth1Data = new(Eth1Data) } - if dst, err = b.Eth1Data.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.Eth1Data.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Eth1Data: %w", err) } - // Offset (9) 'Eth1DataVotes' + // Field 9: Eth1DataVotes dst = ssz.WriteOffset(dst, offset) - offset += len(b.Eth1DataVotes) * 72 + offset += len(c.Eth1DataVotes) * 72 - // Field (10) 'Eth1DepositIndex' - dst = ssz.MarshalUint(dst, b.Eth1DepositIndex) + // Field 10: Eth1DepositIndex + dst = binary.LittleEndian.AppendUint64(dst, c.Eth1DepositIndex) - // Offset (11) 'Validators' + // Field 11: Validators dst = ssz.WriteOffset(dst, offset) - offset += len(b.Validators) * 121 + offset += len(c.Validators) * 121 - // Offset (12) 'Balances' + // Field 12: Balances dst = ssz.WriteOffset(dst, offset) - offset += len(b.Balances) * 8 + offset += len(c.Balances) * 8 - // Field (13) 'RandaoMixes' - if size := len(b.RandaoMixes); size != 65536 { - err = ssz.ErrVectorLengthFn("--.RandaoMixes", size, 65536) - return + // Field 13: RandaoMixes + if len(c.RandaoMixes) != 65536 { + return nil, ssz.ErrBytesLength } - for ii := 0; ii < 65536; ii++ { - if size := len(b.RandaoMixes[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.RandaoMixes[ii]", size, 32) - return + for _, o := range c.RandaoMixes { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.RandaoMixes[ii]...) + dst = append(dst, o...) } - // Field (14) 'Slashings' - if size := len(b.Slashings); size != 8192 { - err = ssz.ErrVectorLengthFn("--.Slashings", size, 8192) - return + // Field 14: Slashings + if len(c.Slashings) != 8192 { + return nil, ssz.ErrBytesLength } - for ii := 0; ii < 8192; ii++ { - dst = ssz.MarshalUint(dst, b.Slashings[ii]) + for _, o := range c.Slashings { + dst = binary.LittleEndian.AppendUint64(dst, o) } - // Offset (15) 'PreviousEpochParticipation' + // Field 15: PreviousEpochParticipation dst = ssz.WriteOffset(dst, offset) - offset += len(b.PreviousEpochParticipation) + offset += len(c.PreviousEpochParticipation) - // Offset (16) 'CurrentEpochParticipation' + // Field 16: CurrentEpochParticipation dst = ssz.WriteOffset(dst, offset) - offset += len(b.CurrentEpochParticipation) + offset += len(c.CurrentEpochParticipation) - // Field (17) 'JustificationBits' - if size := len(b.JustificationBits); size != 1 { - err = ssz.ErrBytesLengthFn("--.JustificationBits", size, 1) - return + // Field 17: JustificationBits + if len([]byte(c.JustificationBits)) != 1 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.JustificationBits...) + dst = append(dst, []byte(c.JustificationBits)...) - // Field (18) 'PreviousJustifiedCheckpoint' - if b.PreviousJustifiedCheckpoint == nil { - b.PreviousJustifiedCheckpoint = new(Checkpoint) + // Field 18: PreviousJustifiedCheckpoint + if c.PreviousJustifiedCheckpoint == nil { + c.PreviousJustifiedCheckpoint = new(Checkpoint) } - if dst, err = b.PreviousJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.PreviousJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("PreviousJustifiedCheckpoint: %w", err) } - // Field (19) 'CurrentJustifiedCheckpoint' - if b.CurrentJustifiedCheckpoint == nil { - b.CurrentJustifiedCheckpoint = new(Checkpoint) + // Field 19: CurrentJustifiedCheckpoint + if c.CurrentJustifiedCheckpoint == nil { + c.CurrentJustifiedCheckpoint = new(Checkpoint) } - if dst, err = b.CurrentJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.CurrentJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("CurrentJustifiedCheckpoint: %w", err) } - // Field (20) 'FinalizedCheckpoint' - if b.FinalizedCheckpoint == nil { - b.FinalizedCheckpoint = new(Checkpoint) + // Field 20: FinalizedCheckpoint + if c.FinalizedCheckpoint == nil { + c.FinalizedCheckpoint = new(Checkpoint) } - if dst, err = b.FinalizedCheckpoint.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.FinalizedCheckpoint.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("FinalizedCheckpoint: %w", err) } - // Offset (21) 'InactivityScores' + // Field 21: InactivityScores dst = ssz.WriteOffset(dst, offset) - offset += len(b.InactivityScores) * 8 + offset += len(c.InactivityScores) * 8 - // Field (22) 'CurrentSyncCommittee' - if b.CurrentSyncCommittee == nil { - b.CurrentSyncCommittee = new(SyncCommittee) + // Field 22: CurrentSyncCommittee + if c.CurrentSyncCommittee == nil { + c.CurrentSyncCommittee = new(SyncCommittee) } - if dst, err = b.CurrentSyncCommittee.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.CurrentSyncCommittee.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("CurrentSyncCommittee: %w", err) } - // Field (23) 'NextSyncCommittee' - if b.NextSyncCommittee == nil { - b.NextSyncCommittee = new(SyncCommittee) + // Field 23: NextSyncCommittee + if c.NextSyncCommittee == nil { + c.NextSyncCommittee = new(SyncCommittee) } - if dst, err = b.NextSyncCommittee.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.NextSyncCommittee.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("NextSyncCommittee: %w", err) } - // Offset (24) 'LatestExecutionPayloadHeader' - dst = ssz.WriteOffset(dst, offset) - if b.LatestExecutionPayloadHeader == nil { - b.LatestExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderDeneb) + // Field 24: LatestExecutionPayloadHeader + if c.LatestExecutionPayloadHeader == nil { + c.LatestExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderDeneb) } - offset += b.LatestExecutionPayloadHeader.SizeSSZ() + dst = ssz.WriteOffset(dst, offset) + offset += c.LatestExecutionPayloadHeader.SizeSSZ() - // Field (25) 'NextWithdrawalIndex' - dst = ssz.MarshalUint(dst, b.NextWithdrawalIndex) + // Field 25: NextWithdrawalIndex + dst = binary.LittleEndian.AppendUint64(dst, c.NextWithdrawalIndex) - // Field (26) 'NextWithdrawalValidatorIndex' - dst = ssz.MarshalUint(dst, b.NextWithdrawalValidatorIndex) + // Field 26: NextWithdrawalValidatorIndex + if dst, err = c.NextWithdrawalValidatorIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("NextWithdrawalValidatorIndex: %w", err) + } - // Offset (27) 'HistoricalSummaries' + // Field 27: HistoricalSummaries dst = ssz.WriteOffset(dst, offset) - offset += len(b.HistoricalSummaries) * 64 + offset += len(c.HistoricalSummaries) * 64 - // Field (28) 'DepositRequestsStartIndex' - dst = ssz.MarshalUint(dst, b.DepositRequestsStartIndex) + // Field 28: DepositRequestsStartIndex + dst = binary.LittleEndian.AppendUint64(dst, c.DepositRequestsStartIndex) - // Field (29) 'DepositBalanceToConsume' - dst = ssz.MarshalUint(dst, b.DepositBalanceToConsume) + // Field 29: DepositBalanceToConsume + if dst, err = c.DepositBalanceToConsume.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("DepositBalanceToConsume: %w", err) + } - // Field (30) 'ExitBalanceToConsume' - dst = ssz.MarshalUint(dst, b.ExitBalanceToConsume) + // Field 30: ExitBalanceToConsume + if dst, err = c.ExitBalanceToConsume.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ExitBalanceToConsume: %w", err) + } - // Field (31) 'EarliestExitEpoch' - dst = ssz.MarshalUint(dst, b.EarliestExitEpoch) + // Field 31: EarliestExitEpoch + if dst, err = c.EarliestExitEpoch.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("EarliestExitEpoch: %w", err) + } - // Field (32) 'ConsolidationBalanceToConsume' - dst = ssz.MarshalUint(dst, b.ConsolidationBalanceToConsume) + // Field 32: ConsolidationBalanceToConsume + if dst, err = c.ConsolidationBalanceToConsume.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ConsolidationBalanceToConsume: %w", err) + } - // Field (33) 'EarliestConsolidationEpoch' - dst = ssz.MarshalUint(dst, b.EarliestConsolidationEpoch) + // Field 33: EarliestConsolidationEpoch + if dst, err = c.EarliestConsolidationEpoch.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("EarliestConsolidationEpoch: %w", err) + } - // Offset (34) 'PendingDeposits' + // Field 34: PendingDeposits dst = ssz.WriteOffset(dst, offset) - offset += len(b.PendingDeposits) * 192 + offset += len(c.PendingDeposits) * 192 - // Offset (35) 'PendingPartialWithdrawals' + // Field 35: PendingPartialWithdrawals dst = ssz.WriteOffset(dst, offset) - offset += len(b.PendingPartialWithdrawals) * 24 + offset += len(c.PendingPartialWithdrawals) * 24 - // Offset (36) 'PendingConsolidations' + // Field 36: PendingConsolidations dst = ssz.WriteOffset(dst, offset) - offset += len(b.PendingConsolidations) * 16 + offset += len(c.PendingConsolidations) * 16 - // Field (37) 'ProposerLookahead' - if size := len(b.ProposerLookahead); size != 64 { - err = ssz.ErrVectorLengthFn("--.ProposerLookahead", size, 64) - return + // Field 37: ProposerLookahead + if len(c.ProposerLookahead) != 64 { + return nil, ssz.ErrBytesLength } - for ii := 0; ii < 64; ii++ { - dst = ssz.MarshalUint(dst, b.ProposerLookahead[ii]) + for _, o := range c.ProposerLookahead { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ProposerLookahead: %w", err) + } } - // Field (7) 'HistoricalRoots' - if size := len(b.HistoricalRoots); size > 16777216 { - err = ssz.ErrListTooBigFn("--.HistoricalRoots", size, 16777216) - return + // Field 7: HistoricalRoots + if len(c.HistoricalRoots) > 16777216 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.HistoricalRoots); ii++ { - if size := len(b.HistoricalRoots[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.HistoricalRoots[ii]", size, 32) - return + for _, o := range c.HistoricalRoots { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.HistoricalRoots[ii]...) + dst = append(dst, o...) } - // Field (9) 'Eth1DataVotes' - if size := len(b.Eth1DataVotes); size > 2048 { - err = ssz.ErrListTooBigFn("--.Eth1DataVotes", size, 2048) - return + // Field 9: Eth1DataVotes + if len(c.Eth1DataVotes) > 2048 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.Eth1DataVotes); ii++ { - if dst, err = b.Eth1DataVotes[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.Eth1DataVotes { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Eth1DataVotes: %w", err) } } - // Field (11) 'Validators' - if size := len(b.Validators); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.Validators", size, 1099511627776) - return + // Field 11: Validators + if len(c.Validators) > 1099511627776 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.Validators); ii++ { - if dst, err = b.Validators[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.Validators { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Validators: %w", err) } } - // Field (12) 'Balances' - if size := len(b.Balances); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.Balances", size, 1099511627776) - return + // Field 12: Balances + if len(c.Balances) > 1099511627776 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.Balances); ii++ { - dst = ssz.MarshalUint(dst, b.Balances[ii]) + for _, o := range c.Balances { + dst = binary.LittleEndian.AppendUint64(dst, o) } - // Field (15) 'PreviousEpochParticipation' - if size := len(b.PreviousEpochParticipation); size > 1099511627776 { - err = ssz.ErrBytesLengthFn("--.PreviousEpochParticipation", size, 1099511627776) - return + // Field 15: PreviousEpochParticipation + if len(c.PreviousEpochParticipation) > 1099511627776 { + return nil, ssz.ErrListTooBig } - dst = append(dst, b.PreviousEpochParticipation...) + dst = append(dst, c.PreviousEpochParticipation...) - // Field (16) 'CurrentEpochParticipation' - if size := len(b.CurrentEpochParticipation); size > 1099511627776 { - err = ssz.ErrBytesLengthFn("--.CurrentEpochParticipation", size, 1099511627776) - return + // Field 16: CurrentEpochParticipation + if len(c.CurrentEpochParticipation) > 1099511627776 { + return nil, ssz.ErrListTooBig } - dst = append(dst, b.CurrentEpochParticipation...) + dst = append(dst, c.CurrentEpochParticipation...) - // Field (21) 'InactivityScores' - if size := len(b.InactivityScores); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.InactivityScores", size, 1099511627776) - return + // Field 21: InactivityScores + if len(c.InactivityScores) > 1099511627776 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.InactivityScores); ii++ { - dst = ssz.MarshalUint(dst, b.InactivityScores[ii]) + for _, o := range c.InactivityScores { + dst = binary.LittleEndian.AppendUint64(dst, o) } - // Field (24) 'LatestExecutionPayloadHeader' - if dst, err = b.LatestExecutionPayloadHeader.MarshalSSZTo(dst); err != nil { - return + // Field 24: LatestExecutionPayloadHeader + if dst, err = c.LatestExecutionPayloadHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("LatestExecutionPayloadHeader: %w", err) } - // Field (27) 'HistoricalSummaries' - if size := len(b.HistoricalSummaries); size > 16777216 { - err = ssz.ErrListTooBigFn("--.HistoricalSummaries", size, 16777216) - return + // Field 27: HistoricalSummaries + if len(c.HistoricalSummaries) > 16777216 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.HistoricalSummaries); ii++ { - if dst, err = b.HistoricalSummaries[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.HistoricalSummaries { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("HistoricalSummaries: %w", err) } } - // Field (34) 'PendingDeposits' - if size := len(b.PendingDeposits); size > 134217728 { - err = ssz.ErrListTooBigFn("--.PendingDeposits", size, 134217728) - return + // Field 34: PendingDeposits + if len(c.PendingDeposits) > 134217728 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.PendingDeposits); ii++ { - if dst, err = b.PendingDeposits[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.PendingDeposits { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("PendingDeposits: %w", err) } } - // Field (35) 'PendingPartialWithdrawals' - if size := len(b.PendingPartialWithdrawals); size > 134217728 { - err = ssz.ErrListTooBigFn("--.PendingPartialWithdrawals", size, 134217728) - return + // Field 35: PendingPartialWithdrawals + if len(c.PendingPartialWithdrawals) > 134217728 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.PendingPartialWithdrawals); ii++ { - if dst, err = b.PendingPartialWithdrawals[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.PendingPartialWithdrawals { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("PendingPartialWithdrawals: %w", err) } } - // Field (36) 'PendingConsolidations' - if size := len(b.PendingConsolidations); size > 262144 { - err = ssz.ErrListTooBigFn("--.PendingConsolidations", size, 262144) - return + // Field 36: PendingConsolidations + if len(c.PendingConsolidations) > 262144 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.PendingConsolidations); ii++ { - if dst, err = b.PendingConsolidations[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.PendingConsolidations { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("PendingConsolidations: %w", err) } } - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the BeaconStateFulu object -func (b *BeaconStateFulu) UnmarshalSSZ(buf []byte) error { +func (c *BeaconStateFulu) 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.UnmarshallUint[uint64](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.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[40:48]) - - // Field (3) 'Fork' - if b.Fork == nil { - b.Fork = new(Fork) + sszSlice0 := buf[0:8] // c.GenesisTime + sszSlice1 := buf[8:40] // c.GenesisValidatorsRoot + sszSlice2 := buf[40:48] // c.Slot + sszSlice3 := buf[48:64] // c.Fork + sszSlice4 := buf[64:176] // c.LatestBlockHeader + sszSlice5 := buf[176:262320] // c.BlockRoots + sszSlice6 := buf[262320:524464] // c.StateRoots + sszSlice8 := buf[524468:524540] // c.Eth1Data + sszSlice10 := buf[524544:524552] // c.Eth1DepositIndex + sszSlice13 := buf[524560:2621712] // c.RandaoMixes + sszSlice14 := buf[2621712:2687248] // c.Slashings + sszSlice17 := buf[2687256:2687257] // c.JustificationBits + sszSlice18 := buf[2687257:2687297] // c.PreviousJustifiedCheckpoint + sszSlice19 := buf[2687297:2687337] // c.CurrentJustifiedCheckpoint + sszSlice20 := buf[2687337:2687377] // c.FinalizedCheckpoint + sszSlice22 := buf[2687381:2712005] // c.CurrentSyncCommittee + sszSlice23 := buf[2712005:2736629] // c.NextSyncCommittee + sszSlice25 := buf[2736633:2736641] // c.NextWithdrawalIndex + sszSlice26 := buf[2736641:2736649] // c.NextWithdrawalValidatorIndex + sszSlice28 := buf[2736653:2736661] // c.DepositRequestsStartIndex + sszSlice29 := buf[2736661:2736669] // c.DepositBalanceToConsume + sszSlice30 := buf[2736669:2736677] // c.ExitBalanceToConsume + sszSlice31 := buf[2736677:2736685] // c.EarliestExitEpoch + sszSlice32 := buf[2736685:2736693] // c.ConsolidationBalanceToConsume + sszSlice33 := buf[2736693:2736701] // c.EarliestConsolidationEpoch + sszSlice37 := buf[2736713:2737225] // c.ProposerLookahead + + sszVarOffset7 := ssz.ReadOffset(buf[524464:524468]) // c.HistoricalRoots + if sszVarOffset7 != 2737225 { + return ssz.ErrInvalidVariableOffset } - if err = b.Fork.UnmarshalSSZ(buf[48:64]); err != nil { - return err + if sszVarOffset7 > size { + return ssz.ErrOffset } - - // Field (4) 'LatestBlockHeader' - if b.LatestBlockHeader == nil { - b.LatestBlockHeader = new(BeaconBlockHeader) + sszVarOffset9 := ssz.ReadOffset(buf[524540:524544]) // c.Eth1DataVotes + if sszVarOffset9 > size || sszVarOffset9 < sszVarOffset7 { + return ssz.ErrOffset } - if err = b.LatestBlockHeader.UnmarshalSSZ(buf[64:176]); err != nil { - return err + sszVarOffset11 := ssz.ReadOffset(buf[524552:524556]) // c.Validators + if sszVarOffset11 > size || sszVarOffset11 < sszVarOffset9 { + return ssz.ErrOffset } - - // Field (5) 'BlockRoots' - b.BlockRoots = make([][]byte, 8192) - for ii := 0; ii < 8192; ii++ { - if cap(b.BlockRoots[ii]) == 0 { - b.BlockRoots[ii] = make([]byte, 0, len(buf[176:262320][ii*32:(ii+1)*32])) - } - b.BlockRoots[ii] = append(b.BlockRoots[ii], buf[176:262320][ii*32:(ii+1)*32]...) + sszVarOffset12 := ssz.ReadOffset(buf[524556:524560]) // c.Balances + if sszVarOffset12 > size || sszVarOffset12 < sszVarOffset11 { + return ssz.ErrOffset } - - // Field (6) 'StateRoots' - b.StateRoots = make([][]byte, 8192) - for ii := 0; ii < 8192; ii++ { - if cap(b.StateRoots[ii]) == 0 { - b.StateRoots[ii] = make([]byte, 0, len(buf[262320:524464][ii*32:(ii+1)*32])) - } - b.StateRoots[ii] = append(b.StateRoots[ii], buf[262320:524464][ii*32:(ii+1)*32]...) + sszVarOffset15 := ssz.ReadOffset(buf[2687248:2687252]) // c.PreviousEpochParticipation + if sszVarOffset15 > size || sszVarOffset15 < sszVarOffset12 { + return ssz.ErrOffset } - - // Offset (7) 'HistoricalRoots' - if o7 = ssz.ReadOffset(buf[524464:524468]); o7 > size { + sszVarOffset16 := ssz.ReadOffset(buf[2687252:2687256]) // c.CurrentEpochParticipation + if sszVarOffset16 > size || sszVarOffset16 < sszVarOffset15 { return ssz.ErrOffset } - - if o7 != 2737225 { - return ssz.ErrInvalidVariableOffset + sszVarOffset21 := ssz.ReadOffset(buf[2687377:2687381]) // c.InactivityScores + if sszVarOffset21 > size || sszVarOffset21 < sszVarOffset16 { + return ssz.ErrOffset } - - // Field (8) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(Eth1Data) + sszVarOffset24 := ssz.ReadOffset(buf[2736629:2736633]) // c.LatestExecutionPayloadHeader + if sszVarOffset24 > size || sszVarOffset24 < sszVarOffset21 { + return ssz.ErrOffset } - if err = b.Eth1Data.UnmarshalSSZ(buf[524468:524540]); err != nil { - return err + sszVarOffset27 := ssz.ReadOffset(buf[2736649:2736653]) // c.HistoricalSummaries + if sszVarOffset27 > size || sszVarOffset27 < sszVarOffset24 { + return ssz.ErrOffset } - - // Offset (9) 'Eth1DataVotes' - if o9 = ssz.ReadOffset(buf[524540:524544]); o9 > size || o7 > o9 { + sszVarOffset34 := ssz.ReadOffset(buf[2736701:2736705]) // c.PendingDeposits + if sszVarOffset34 > size || sszVarOffset34 < sszVarOffset27 { return ssz.ErrOffset } - - // Field (10) 'Eth1DepositIndex' - b.Eth1DepositIndex = ssz.UnmarshallUint[uint64](buf[524544:524552]) - - // Offset (11) 'Validators' - if o11 = ssz.ReadOffset(buf[524552:524556]); o11 > size || o9 > o11 { + sszVarOffset35 := ssz.ReadOffset(buf[2736705:2736709]) // c.PendingPartialWithdrawals + if sszVarOffset35 > size || sszVarOffset35 < sszVarOffset34 { return ssz.ErrOffset } - - // Offset (12) 'Balances' - if o12 = ssz.ReadOffset(buf[524556:524560]); o12 > size || o11 > o12 { + sszVarOffset36 := ssz.ReadOffset(buf[2736709:2736713]) // c.PendingConsolidations + if sszVarOffset36 > size || sszVarOffset36 < sszVarOffset35 { return ssz.ErrOffset } + sszSlice7 := buf[sszVarOffset7:sszVarOffset9] // c.HistoricalRoots + sszSlice9 := buf[sszVarOffset9:sszVarOffset11] // c.Eth1DataVotes + sszSlice11 := buf[sszVarOffset11:sszVarOffset12] // c.Validators + sszSlice12 := buf[sszVarOffset12:sszVarOffset15] // c.Balances + sszSlice15 := buf[sszVarOffset15:sszVarOffset16] // c.PreviousEpochParticipation + sszSlice16 := buf[sszVarOffset16:sszVarOffset21] // c.CurrentEpochParticipation + sszSlice21 := buf[sszVarOffset21:sszVarOffset24] // c.InactivityScores + sszSlice24 := buf[sszVarOffset24:sszVarOffset27] // c.LatestExecutionPayloadHeader + sszSlice27 := buf[sszVarOffset27:sszVarOffset34] // c.HistoricalSummaries + sszSlice34 := buf[sszVarOffset34:sszVarOffset35] // c.PendingDeposits + sszSlice35 := buf[sszVarOffset35:sszVarOffset36] // c.PendingPartialWithdrawals + sszSlice36 := buf[sszVarOffset36:] // c.PendingConsolidations - // 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 0: GenesisTime + c.GenesisTime = binary.LittleEndian.Uint64(sszSlice0) - // Field (14) 'Slashings' - b.Slashings = ssz.ExtendUint(b.Slashings, 8192) - for ii := 0; ii < 8192; ii++ { - b.Slashings[ii] = ssz.UnmarshallUint[uint64](buf[2621712:2687248][ii*8 : (ii+1)*8]) - } + // Field 1: GenesisValidatorsRoot + c.GenesisValidatorsRoot = make([]byte, 0, 32) + c.GenesisValidatorsRoot = append(c.GenesisValidatorsRoot, sszSlice1...) - // Offset (15) 'PreviousEpochParticipation' - if o15 = ssz.ReadOffset(buf[2687248:2687252]); o15 > size || o12 > o15 { - return ssz.ErrOffset + // Field 2: Slot + if err = c.Slot.UnmarshalSSZ(sszSlice2); err != nil { + return fmt.Errorf("Slot: %w", err) } - // Offset (16) 'CurrentEpochParticipation' - if o16 = ssz.ReadOffset(buf[2687252:2687256]); o16 > size || o15 > o16 { - return ssz.ErrOffset + // Field 3: Fork + c.Fork = new(Fork) + if err = c.Fork.UnmarshalSSZ(sszSlice3); err != nil { + return fmt.Errorf("Fork: %w", err) } - // Field (17) 'JustificationBits' - if cap(b.JustificationBits) == 0 { - b.JustificationBits = make([]byte, 0, len(buf[2687256:2687257])) + // Field 4: LatestBlockHeader + c.LatestBlockHeader = new(BeaconBlockHeader) + if err = c.LatestBlockHeader.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("LatestBlockHeader: %w", err) } - b.JustificationBits = append(b.JustificationBits, buf[2687256:2687257]...) - // Field (18) 'PreviousJustifiedCheckpoint' - if b.PreviousJustifiedCheckpoint == nil { - b.PreviousJustifiedCheckpoint = new(Checkpoint) - } - if err = b.PreviousJustifiedCheckpoint.UnmarshalSSZ(buf[2687257:2687297]); err != nil { - return err - } + // Field 5: BlockRoots + { + c.BlockRoots = make([][]byte, 8192) + for i := 0; i < 8192; i++ { + var tmp []byte - // Field (19) 'CurrentJustifiedCheckpoint' - if b.CurrentJustifiedCheckpoint == nil { - b.CurrentJustifiedCheckpoint = new(Checkpoint) - } - if err = b.CurrentJustifiedCheckpoint.UnmarshalSSZ(buf[2687297:2687337]); err != nil { - return err + tmpSlice := sszSlice5[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.BlockRoots[i] = tmp + } } - // Field (20) 'FinalizedCheckpoint' - if b.FinalizedCheckpoint == nil { - b.FinalizedCheckpoint = new(Checkpoint) - } - if err = b.FinalizedCheckpoint.UnmarshalSSZ(buf[2687337:2687377]); err != nil { - return err - } + // Field 6: StateRoots + { + c.StateRoots = make([][]byte, 8192) + for i := 0; i < 8192; i++ { + var tmp []byte - // Offset (21) 'InactivityScores' - if o21 = ssz.ReadOffset(buf[2687377:2687381]); o21 > size || o16 > o21 { - return ssz.ErrOffset + tmpSlice := sszSlice6[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.StateRoots[i] = tmp + } } - // Field (22) 'CurrentSyncCommittee' - if b.CurrentSyncCommittee == nil { - b.CurrentSyncCommittee = new(SyncCommittee) - } - if err = b.CurrentSyncCommittee.UnmarshalSSZ(buf[2687381:2712005]); err != nil { - return err + // Field 7: HistoricalRoots + { + if len(sszSlice7)%32 != 0 { + return fmt.Errorf("misaligned bytes: c.HistoricalRoots length is %d, which is not a multiple of 32: %w", len(sszSlice7), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice7) / 32 + if numElem > 16777216 { + return fmt.Errorf("ssz-max exceeded: c.HistoricalRoots has %d elements, ssz-max is 16777216: %w", numElem, ssz.ErrListTooBig) + } + c.HistoricalRoots = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte + + tmpSlice := sszSlice7[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.HistoricalRoots[i] = tmp + } } - // Field (23) 'NextSyncCommittee' - if b.NextSyncCommittee == nil { - b.NextSyncCommittee = new(SyncCommittee) + // Field 8: Eth1Data + c.Eth1Data = new(Eth1Data) + if err = c.Eth1Data.UnmarshalSSZ(sszSlice8); err != nil { + return fmt.Errorf("Eth1Data: %w", err) } - if err = b.NextSyncCommittee.UnmarshalSSZ(buf[2712005:2736629]); err != nil { - return err + + // Field 9: Eth1DataVotes + { + if len(sszSlice9)%72 != 0 { + return fmt.Errorf("misaligned bytes: c.Eth1DataVotes length is %d, which is not a multiple of 72: %w", len(sszSlice9), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice9) / 72 + if numElem > 2048 { + return fmt.Errorf("ssz-max exceeded: c.Eth1DataVotes has %d elements, ssz-max is 2048: %w", numElem, ssz.ErrListTooBig) + } + c.Eth1DataVotes = make([]*Eth1Data, numElem) + for i := 0; i < numElem; i++ { + var tmp *Eth1Data + tmp = new(Eth1Data) + tmpSlice := sszSlice9[i*72 : (1+i)*72] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Eth1DataVotes: %w", err) + } + c.Eth1DataVotes[i] = tmp + } } - // Offset (24) 'LatestExecutionPayloadHeader' - if o24 = ssz.ReadOffset(buf[2736629:2736633]); o24 > size || o21 > o24 { - return ssz.ErrOffset + // Field 10: Eth1DepositIndex + c.Eth1DepositIndex = binary.LittleEndian.Uint64(sszSlice10) + + // Field 11: Validators + { + if len(sszSlice11)%121 != 0 { + return fmt.Errorf("misaligned bytes: c.Validators length is %d, which is not a multiple of 121: %w", len(sszSlice11), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice11) / 121 + if numElem > 1099511627776 { + return fmt.Errorf("ssz-max exceeded: c.Validators has %d elements, ssz-max is 1099511627776: %w", numElem, ssz.ErrListTooBig) + } + c.Validators = make([]*Validator, numElem) + for i := 0; i < numElem; i++ { + var tmp *Validator + tmp = new(Validator) + tmpSlice := sszSlice11[i*121 : (1+i)*121] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Validators: %w", err) + } + c.Validators[i] = tmp + } } - // Field (25) 'NextWithdrawalIndex' - b.NextWithdrawalIndex = ssz.UnmarshallUint[uint64](buf[2736633:2736641]) + // Field 12: Balances + { + if len(sszSlice12)%8 != 0 { + return fmt.Errorf("misaligned bytes: c.Balances length is %d, which is not a multiple of 8: %w", len(sszSlice12), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice12) / 8 + if numElem > 1099511627776 { + return fmt.Errorf("ssz-max exceeded: c.Balances has %d elements, ssz-max is 1099511627776: %w", numElem, ssz.ErrListTooBig) + } + c.Balances = make([]uint64, numElem) + for i := 0; i < numElem; i++ { + var tmp uint64 - // Field (26) 'NextWithdrawalValidatorIndex' - b.NextWithdrawalValidatorIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[2736641:2736649]) + tmpSlice := sszSlice12[i*8 : (1+i)*8] + tmp = binary.LittleEndian.Uint64(tmpSlice) + c.Balances[i] = tmp + } + } - // Offset (27) 'HistoricalSummaries' - if o27 = ssz.ReadOffset(buf[2736649:2736653]); o27 > size || o24 > o27 { - return ssz.ErrOffset + // Field 13: RandaoMixes + { + c.RandaoMixes = make([][]byte, 65536) + for i := 0; i < 65536; i++ { + var tmp []byte + + tmpSlice := sszSlice13[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.RandaoMixes[i] = tmp + } } - // Field (28) 'DepositRequestsStartIndex' - b.DepositRequestsStartIndex = ssz.UnmarshallUint[uint64](buf[2736653:2736661]) + // Field 14: Slashings + { + c.Slashings = make([]uint64, 8192) + for i := 0; i < 8192; i++ { + var tmp uint64 + + tmpSlice := sszSlice14[i*8 : (1+i)*8] + tmp = binary.LittleEndian.Uint64(tmpSlice) + c.Slashings[i] = tmp + } + } - // Field (29) 'DepositBalanceToConsume' - b.DepositBalanceToConsume = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Gwei](buf[2736661:2736669]) + // Field 15: PreviousEpochParticipation + c.PreviousEpochParticipation = append([]byte{}, sszSlice15...) - // Field (30) 'ExitBalanceToConsume' - b.ExitBalanceToConsume = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Gwei](buf[2736669:2736677]) + // Field 16: CurrentEpochParticipation + c.CurrentEpochParticipation = append([]byte{}, sszSlice16...) - // Field (31) 'EarliestExitEpoch' - b.EarliestExitEpoch = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Epoch](buf[2736677:2736685]) + // Field 17: JustificationBits + c.JustificationBits = make([]byte, 0, 1) + c.JustificationBits = append(c.JustificationBits, go_bitfield.Bitvector4(sszSlice17)...) - // Field (32) 'ConsolidationBalanceToConsume' - b.ConsolidationBalanceToConsume = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Gwei](buf[2736685:2736693]) + // Field 18: PreviousJustifiedCheckpoint + c.PreviousJustifiedCheckpoint = new(Checkpoint) + if err = c.PreviousJustifiedCheckpoint.UnmarshalSSZ(sszSlice18); err != nil { + return fmt.Errorf("PreviousJustifiedCheckpoint: %w", err) + } - // Field (33) 'EarliestConsolidationEpoch' - b.EarliestConsolidationEpoch = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Epoch](buf[2736693:2736701]) + // Field 19: CurrentJustifiedCheckpoint + c.CurrentJustifiedCheckpoint = new(Checkpoint) + if err = c.CurrentJustifiedCheckpoint.UnmarshalSSZ(sszSlice19); err != nil { + return fmt.Errorf("CurrentJustifiedCheckpoint: %w", err) + } - // Offset (34) 'PendingDeposits' - if o34 = ssz.ReadOffset(buf[2736701:2736705]); o34 > size || o27 > o34 { - return ssz.ErrOffset + // Field 20: FinalizedCheckpoint + c.FinalizedCheckpoint = new(Checkpoint) + if err = c.FinalizedCheckpoint.UnmarshalSSZ(sszSlice20); err != nil { + return fmt.Errorf("FinalizedCheckpoint: %w", err) } - // Offset (35) 'PendingPartialWithdrawals' - if o35 = ssz.ReadOffset(buf[2736705:2736709]); o35 > size || o34 > o35 { - return ssz.ErrOffset + // Field 21: InactivityScores + { + if len(sszSlice21)%8 != 0 { + return fmt.Errorf("misaligned bytes: c.InactivityScores length is %d, which is not a multiple of 8: %w", len(sszSlice21), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice21) / 8 + if numElem > 1099511627776 { + return fmt.Errorf("ssz-max exceeded: c.InactivityScores has %d elements, ssz-max is 1099511627776: %w", numElem, ssz.ErrListTooBig) + } + c.InactivityScores = make([]uint64, numElem) + for i := 0; i < numElem; i++ { + var tmp uint64 + + tmpSlice := sszSlice21[i*8 : (1+i)*8] + tmp = binary.LittleEndian.Uint64(tmpSlice) + c.InactivityScores[i] = tmp + } } - // Offset (36) 'PendingConsolidations' - if o36 = ssz.ReadOffset(buf[2736709:2736713]); o36 > size || o35 > o36 { - return ssz.ErrOffset + // Field 22: CurrentSyncCommittee + c.CurrentSyncCommittee = new(SyncCommittee) + if err = c.CurrentSyncCommittee.UnmarshalSSZ(sszSlice22); err != nil { + return fmt.Errorf("CurrentSyncCommittee: %w", err) } - // Field (37) 'ProposerLookahead' - b.ProposerLookahead = ssz.ExtendUint(b.ProposerLookahead, 64) - for ii := 0; ii < 64; ii++ { - b.ProposerLookahead[ii] = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[2736713:2737225][ii*8 : (ii+1)*8]) + // Field 23: NextSyncCommittee + c.NextSyncCommittee = new(SyncCommittee) + if err = c.NextSyncCommittee.UnmarshalSSZ(sszSlice23); err != nil { + return fmt.Errorf("NextSyncCommittee: %w", err) } - // 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 24: LatestExecutionPayloadHeader + c.LatestExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderDeneb) + if err = c.LatestExecutionPayloadHeader.UnmarshalSSZ(sszSlice24); err != nil { + return fmt.Errorf("LatestExecutionPayloadHeader: %w", err) } - // Field (9) 'Eth1DataVotes' - { - buf = tail[o9:o11] - num, err := ssz.DivideInt2(len(buf), 72, 2048) - if err != nil { - return err - } - b.Eth1DataVotes = make([]*Eth1Data, num) - for ii := 0; ii < num; ii++ { - if b.Eth1DataVotes[ii] == nil { - b.Eth1DataVotes[ii] = new(Eth1Data) - } - if err = b.Eth1DataVotes[ii].UnmarshalSSZ(buf[ii*72 : (ii+1)*72]); err != nil { - return err - } - } + // Field 25: NextWithdrawalIndex + c.NextWithdrawalIndex = binary.LittleEndian.Uint64(sszSlice25) + + // Field 26: NextWithdrawalValidatorIndex + if err = c.NextWithdrawalValidatorIndex.UnmarshalSSZ(sszSlice26); err != nil { + return fmt.Errorf("NextWithdrawalValidatorIndex: %w", err) } - // Field (11) 'Validators' + // Field 27: HistoricalSummaries { - buf = tail[o11:o12] - num, err := ssz.DivideInt2(len(buf), 121, 1099511627776) - if err != nil { - return err - } - b.Validators = make([]*Validator, num) - for ii := 0; ii < num; ii++ { - if b.Validators[ii] == nil { - b.Validators[ii] = new(Validator) - } - if err = b.Validators[ii].UnmarshalSSZ(buf[ii*121 : (ii+1)*121]); err != nil { - return err + if len(sszSlice27)%64 != 0 { + return fmt.Errorf("misaligned bytes: c.HistoricalSummaries length is %d, which is not a multiple of 64: %w", len(sszSlice27), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice27) / 64 + if numElem > 16777216 { + return fmt.Errorf("ssz-max exceeded: c.HistoricalSummaries has %d elements, ssz-max is 16777216: %w", numElem, ssz.ErrListTooBig) + } + c.HistoricalSummaries = make([]*HistoricalSummary, numElem) + for i := 0; i < numElem; i++ { + var tmp *HistoricalSummary + tmp = new(HistoricalSummary) + tmpSlice := sszSlice27[i*64 : (1+i)*64] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("HistoricalSummaries: %w", err) } + c.HistoricalSummaries[i] = tmp } } - // Field (12) 'Balances' - { - buf = tail[o12:o15] - num, err := ssz.DivideInt2(len(buf), 8, 1099511627776) - if err != nil { - return err - } - b.Balances = ssz.ExtendUint(b.Balances, num) - for ii := 0; ii < num; ii++ { - b.Balances[ii] = ssz.UnmarshallUint[uint64](buf[ii*8 : (ii+1)*8]) - } + // Field 28: DepositRequestsStartIndex + c.DepositRequestsStartIndex = binary.LittleEndian.Uint64(sszSlice28) + + // Field 29: DepositBalanceToConsume + if err = c.DepositBalanceToConsume.UnmarshalSSZ(sszSlice29); err != nil { + return fmt.Errorf("DepositBalanceToConsume: %w", err) } - // 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 30: ExitBalanceToConsume + if err = c.ExitBalanceToConsume.UnmarshalSSZ(sszSlice30); err != nil { + return fmt.Errorf("ExitBalanceToConsume: %w", err) } - // 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 31: EarliestExitEpoch + if err = c.EarliestExitEpoch.UnmarshalSSZ(sszSlice31); err != nil { + return fmt.Errorf("EarliestExitEpoch: %w", err) } - // Field (21) 'InactivityScores' - { - buf = tail[o21:o24] - num, err := ssz.DivideInt2(len(buf), 8, 1099511627776) - if err != nil { - return err - } - b.InactivityScores = ssz.ExtendUint(b.InactivityScores, num) - for ii := 0; ii < num; ii++ { - b.InactivityScores[ii] = ssz.UnmarshallUint[uint64](buf[ii*8 : (ii+1)*8]) - } + // Field 32: ConsolidationBalanceToConsume + if err = c.ConsolidationBalanceToConsume.UnmarshalSSZ(sszSlice32); err != nil { + return fmt.Errorf("ConsolidationBalanceToConsume: %w", err) } - // Field (24) 'LatestExecutionPayloadHeader' - { - buf = tail[o24:o27] - if b.LatestExecutionPayloadHeader == nil { - b.LatestExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderDeneb) - } - if err = b.LatestExecutionPayloadHeader.UnmarshalSSZ(buf); err != nil { - return err - } + // Field 33: EarliestConsolidationEpoch + if err = c.EarliestConsolidationEpoch.UnmarshalSSZ(sszSlice33); err != nil { + return fmt.Errorf("EarliestConsolidationEpoch: %w", err) } - // Field (27) 'HistoricalSummaries' + // Field 34: PendingDeposits { - buf = tail[o27:o34] - num, err := ssz.DivideInt2(len(buf), 64, 16777216) - if err != nil { - return err - } - b.HistoricalSummaries = make([]*HistoricalSummary, num) - for ii := 0; ii < num; ii++ { - if b.HistoricalSummaries[ii] == nil { - b.HistoricalSummaries[ii] = new(HistoricalSummary) - } - if err = b.HistoricalSummaries[ii].UnmarshalSSZ(buf[ii*64 : (ii+1)*64]); err != nil { - return err + if len(sszSlice34)%192 != 0 { + return fmt.Errorf("misaligned bytes: c.PendingDeposits length is %d, which is not a multiple of 192: %w", len(sszSlice34), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice34) / 192 + if numElem > 134217728 { + return fmt.Errorf("ssz-max exceeded: c.PendingDeposits has %d elements, ssz-max is 134217728: %w", numElem, ssz.ErrListTooBig) + } + c.PendingDeposits = make([]*PendingDeposit, numElem) + for i := 0; i < numElem; i++ { + var tmp *PendingDeposit + tmp = new(PendingDeposit) + tmpSlice := sszSlice34[i*192 : (1+i)*192] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("PendingDeposits: %w", err) } + c.PendingDeposits[i] = tmp } } - // Field (34) 'PendingDeposits' + // Field 35: PendingPartialWithdrawals { - buf = tail[o34:o35] - num, err := ssz.DivideInt2(len(buf), 192, 134217728) - if err != nil { - return err - } - b.PendingDeposits = make([]*PendingDeposit, num) - for ii := 0; ii < num; ii++ { - if b.PendingDeposits[ii] == nil { - b.PendingDeposits[ii] = new(PendingDeposit) - } - if err = b.PendingDeposits[ii].UnmarshalSSZ(buf[ii*192 : (ii+1)*192]); err != nil { - return err + if len(sszSlice35)%24 != 0 { + return fmt.Errorf("misaligned bytes: c.PendingPartialWithdrawals length is %d, which is not a multiple of 24: %w", len(sszSlice35), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice35) / 24 + if numElem > 134217728 { + return fmt.Errorf("ssz-max exceeded: c.PendingPartialWithdrawals has %d elements, ssz-max is 134217728: %w", numElem, ssz.ErrListTooBig) + } + c.PendingPartialWithdrawals = make([]*PendingPartialWithdrawal, numElem) + for i := 0; i < numElem; i++ { + var tmp *PendingPartialWithdrawal + tmp = new(PendingPartialWithdrawal) + tmpSlice := sszSlice35[i*24 : (1+i)*24] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("PendingPartialWithdrawals: %w", err) } + c.PendingPartialWithdrawals[i] = tmp } } - // Field (35) 'PendingPartialWithdrawals' + // Field 36: PendingConsolidations { - buf = tail[o35:o36] - num, err := ssz.DivideInt2(len(buf), 24, 134217728) - if err != nil { - return err - } - b.PendingPartialWithdrawals = make([]*PendingPartialWithdrawal, num) - for ii := 0; ii < num; ii++ { - if b.PendingPartialWithdrawals[ii] == nil { - b.PendingPartialWithdrawals[ii] = new(PendingPartialWithdrawal) - } - if err = b.PendingPartialWithdrawals[ii].UnmarshalSSZ(buf[ii*24 : (ii+1)*24]); err != nil { - return err + if len(sszSlice36)%16 != 0 { + return fmt.Errorf("misaligned bytes: c.PendingConsolidations length is %d, which is not a multiple of 16: %w", len(sszSlice36), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice36) / 16 + if numElem > 262144 { + return fmt.Errorf("ssz-max exceeded: c.PendingConsolidations has %d elements, ssz-max is 262144: %w", numElem, ssz.ErrListTooBig) + } + c.PendingConsolidations = make([]*PendingConsolidation, numElem) + for i := 0; i < numElem; i++ { + var tmp *PendingConsolidation + tmp = new(PendingConsolidation) + tmpSlice := sszSlice36[i*16 : (1+i)*16] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("PendingConsolidations: %w", err) } + c.PendingConsolidations[i] = tmp } } - // Field (36) 'PendingConsolidations' + // Field 37: ProposerLookahead { - buf = tail[o36:] - num, err := ssz.DivideInt2(len(buf), 16, 262144) - if err != nil { - return err - } - b.PendingConsolidations = make([]*PendingConsolidation, num) - for ii := 0; ii < num; ii++ { - if b.PendingConsolidations[ii] == nil { - b.PendingConsolidations[ii] = new(PendingConsolidation) - } - if err = b.PendingConsolidations[ii].UnmarshalSSZ(buf[ii*16 : (ii+1)*16]); err != nil { - return err + c.ProposerLookahead = make([]primitives.ValidatorIndex, 64) + for i := 0; i < 64; i++ { + var tmp primitives.ValidatorIndex + + tmpSlice := sszSlice37[i*8 : (1+i)*8] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("ProposerLookahead: %w", err) } + c.ProposerLookahead[i] = tmp } } return err } -// SizeSSZ returns the ssz encoded size in bytes for the BeaconStateFulu object -func (b *BeaconStateFulu) 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(v1.ExecutionPayloadHeaderDeneb) +func (c *BeaconStateFulu) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - 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 BeaconStateFulu object -func (b *BeaconStateFulu) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the BeaconStateFulu object with a hasher -func (b *BeaconStateFulu) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *BeaconStateFulu) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'GenesisTime' - ssz.PutUint(hh, b.GenesisTime) - - // Field (1) 'GenesisValidatorsRoot' - if size := len(b.GenesisValidatorsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.GenesisValidatorsRoot", size, 32) - return - } - hh.PutBytes(b.GenesisValidatorsRoot) - - // Field (2) 'Slot' - ssz.PutUint(hh, b.Slot) - - // Field (3) 'Fork' - if err = b.Fork.HashTreeRootWith(hh); err != nil { - return - } - - // Field (4) 'LatestBlockHeader' - if err = b.LatestBlockHeader.HashTreeRootWith(hh); err != nil { - return - } - - // Field (5) 'BlockRoots' + // Field 0: GenesisTime + hh.PutUint64(c.GenesisTime) + // Field 1: GenesisValidatorsRoot + if len(c.GenesisValidatorsRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.GenesisValidatorsRoot) + // Field 2: Slot + if err := c.Slot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Slot: %w", err) + } + // Field 3: Fork + if err := c.Fork.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Fork: %w", err) + } + // Field 4: LatestBlockHeader + if err := c.LatestBlockHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("LatestBlockHeader: %w", err) + } + // Field 5: BlockRoots { - if size := len(b.BlockRoots); size != 8192 { - err = ssz.ErrVectorLengthFn("--.BlockRoots", size, 8192) - return + if len(c.BlockRoots) != 8192 { + return ssz.ErrVectorLength } subIndx := hh.Index() - for _, i := range b.BlockRoots { - if len(i) != 32 { - err = ssz.ErrBytesLength - return + for _, o := range c.BlockRoots { + if len(o) != 32 { + return ssz.ErrBytesLength } - hh.Append(i) + hh.Append(o) } hh.Merkleize(subIndx) } - - // Field (6) 'StateRoots' + // Field 6: StateRoots { - if size := len(b.StateRoots); size != 8192 { - err = ssz.ErrVectorLengthFn("--.StateRoots", size, 8192) - return + if len(c.StateRoots) != 8192 { + return ssz.ErrVectorLength } subIndx := hh.Index() - for _, i := range b.StateRoots { - if len(i) != 32 { - err = ssz.ErrBytesLength - return + for _, o := range c.StateRoots { + if len(o) != 32 { + return ssz.ErrBytesLength } - hh.Append(i) + hh.Append(o) } hh.Merkleize(subIndx) } - - // Field (7) 'HistoricalRoots' + // Field 7: HistoricalRoots { - if size := len(b.HistoricalRoots); size > 16777216 { - err = ssz.ErrListTooBigFn("--.HistoricalRoots", size, 16777216) - return + if len(c.HistoricalRoots) > 16777216 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range b.HistoricalRoots { - if len(i) != 32 { - err = ssz.ErrBytesLength - return + for _, o := range c.HistoricalRoots { + if len(o) != 32 { + return ssz.ErrBytesLength } - hh.Append(i) + hh.Append(o) } - - numItems := uint64(len(b.HistoricalRoots)) - hh.MerkleizeWithMixin(subIndx, numItems, 16777216) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.HistoricalRoots)), 16777216) } - - // Field (8) 'Eth1Data' - if err = b.Eth1Data.HashTreeRootWith(hh); err != nil { - return + // Field 8: Eth1Data + if err := c.Eth1Data.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Eth1Data: %w", err) } - - // Field (9) 'Eth1DataVotes' + // Field 9: Eth1DataVotes { + if len(c.Eth1DataVotes) > 2048 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.Eth1DataVotes { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Eth1DataVotes: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 2048) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Eth1DataVotes)), 2048) } - - // Field (10) 'Eth1DepositIndex' - ssz.PutUint(hh, b.Eth1DepositIndex) - - // Field (11) 'Validators' + // Field 10: Eth1DepositIndex + hh.PutUint64(c.Eth1DepositIndex) + // Field 11: Validators { + if len(c.Validators) > 1099511627776 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.Validators { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Validators: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 1099511627776) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Validators)), 1099511627776) } - - // Field (12) 'Balances' + // Field 12: Balances { - if size := len(b.Balances); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.Balances", size, 1099511627776) - return + if len(c.Balances) > 1099511627776 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range b.Balances { - ssz.AppendUint(hh, i) + for _, o := range c.Balances { + hh.AppendUint64(o) } hh.FillUpTo32() - - numItems := uint64(len(b.Balances)) + numItems := uint64(len(c.Balances)) hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(1099511627776, numItems, 8)) } - - // Field (13) 'RandaoMixes' + // Field 13: RandaoMixes { - if size := len(b.RandaoMixes); size != 65536 { - err = ssz.ErrVectorLengthFn("--.RandaoMixes", size, 65536) - return + if len(c.RandaoMixes) != 65536 { + return ssz.ErrVectorLength } subIndx := hh.Index() - for _, i := range b.RandaoMixes { - if len(i) != 32 { - err = ssz.ErrBytesLength - return + for _, o := range c.RandaoMixes { + if len(o) != 32 { + return ssz.ErrBytesLength } - hh.Append(i) + hh.Append(o) } hh.Merkleize(subIndx) } - - // Field (14) 'Slashings' + // Field 14: Slashings { - if size := len(b.Slashings); size != 8192 { - err = ssz.ErrVectorLengthFn("--.Slashings", size, 8192) - return + if len(c.Slashings) != 8192 { + return ssz.ErrVectorLength } subIndx := hh.Index() - for _, i := range b.Slashings { - ssz.AppendUint(hh, i) + for _, o := range c.Slashings { + hh.AppendUint64(o) } hh.Merkleize(subIndx) } + // Field 15: PreviousEpochParticipation - // Field (15) 'PreviousEpochParticipation' { - elemIndx := hh.Index() - byteLen := uint64(len(b.PreviousEpochParticipation)) - if byteLen > 1099511627776 { - err = ssz.ErrIncorrectListSize - return + if len(c.PreviousEpochParticipation) > 1099511627776 { + return ssz.ErrBytesLength } - hh.AppendBytes32(b.PreviousEpochParticipation) - hh.MerkleizeWithMixin(elemIndx, byteLen, (1099511627776+31)/32) + subIndx := hh.Index() + hh.AppendBytes32(c.PreviousEpochParticipation) + numItems := uint64(len(c.PreviousEpochParticipation)) + hh.MerkleizeWithMixin(subIndx, numItems, (1099511627776*1+31)/32) } - // Field (16) 'CurrentEpochParticipation' + // Field 16: CurrentEpochParticipation + { - elemIndx := hh.Index() - byteLen := uint64(len(b.CurrentEpochParticipation)) - if byteLen > 1099511627776 { - err = ssz.ErrIncorrectListSize - return + if len(c.CurrentEpochParticipation) > 1099511627776 { + return ssz.ErrBytesLength } - hh.AppendBytes32(b.CurrentEpochParticipation) - hh.MerkleizeWithMixin(elemIndx, byteLen, (1099511627776+31)/32) + subIndx := hh.Index() + hh.AppendBytes32(c.CurrentEpochParticipation) + numItems := uint64(len(c.CurrentEpochParticipation)) + hh.MerkleizeWithMixin(subIndx, numItems, (1099511627776*1+31)/32) } - // Field (17) 'JustificationBits' - if size := len(b.JustificationBits); size != 1 { - err = ssz.ErrBytesLengthFn("--.JustificationBits", size, 1) - return + // Field 17: JustificationBits + if len([]byte(c.JustificationBits)) != 1 { + return ssz.ErrBytesLength } - hh.PutBytes(b.JustificationBits) - - // Field (18) 'PreviousJustifiedCheckpoint' - if err = b.PreviousJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { - return + hh.PutBytes([]byte(c.JustificationBits)) + // Field 18: PreviousJustifiedCheckpoint + if err := c.PreviousJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("PreviousJustifiedCheckpoint: %w", err) } - - // Field (19) 'CurrentJustifiedCheckpoint' - if err = b.CurrentJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { - return + // Field 19: CurrentJustifiedCheckpoint + if err := c.CurrentJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("CurrentJustifiedCheckpoint: %w", err) } - - // Field (20) 'FinalizedCheckpoint' - if err = b.FinalizedCheckpoint.HashTreeRootWith(hh); err != nil { - return + // Field 20: FinalizedCheckpoint + if err := c.FinalizedCheckpoint.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("FinalizedCheckpoint: %w", err) } - - // Field (21) 'InactivityScores' + // Field 21: InactivityScores { - if size := len(b.InactivityScores); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.InactivityScores", size, 1099511627776) - return + if len(c.InactivityScores) > 1099511627776 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range b.InactivityScores { - ssz.AppendUint(hh, i) + for _, o := range c.InactivityScores { + hh.AppendUint64(o) } hh.FillUpTo32() - - numItems := uint64(len(b.InactivityScores)) + numItems := uint64(len(c.InactivityScores)) hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(1099511627776, numItems, 8)) } - - // Field (22) 'CurrentSyncCommittee' - if err = b.CurrentSyncCommittee.HashTreeRootWith(hh); err != nil { - return + // Field 22: CurrentSyncCommittee + if err := c.CurrentSyncCommittee.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("CurrentSyncCommittee: %w", err) } - - // Field (23) 'NextSyncCommittee' - if err = b.NextSyncCommittee.HashTreeRootWith(hh); err != nil { - return + // Field 23: NextSyncCommittee + if err := c.NextSyncCommittee.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("NextSyncCommittee: %w", err) } - - // Field (24) 'LatestExecutionPayloadHeader' - if err = b.LatestExecutionPayloadHeader.HashTreeRootWith(hh); err != nil { - return + // Field 24: LatestExecutionPayloadHeader + if err := c.LatestExecutionPayloadHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("LatestExecutionPayloadHeader: %w", err) } - - // Field (25) 'NextWithdrawalIndex' - ssz.PutUint(hh, b.NextWithdrawalIndex) - - // Field (26) 'NextWithdrawalValidatorIndex' - ssz.PutUint(hh, b.NextWithdrawalValidatorIndex) - - // Field (27) 'HistoricalSummaries' + // Field 25: NextWithdrawalIndex + hh.PutUint64(c.NextWithdrawalIndex) + // Field 26: NextWithdrawalValidatorIndex + if err := c.NextWithdrawalValidatorIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("NextWithdrawalValidatorIndex: %w", err) + } + // Field 27: HistoricalSummaries { + if len(c.HistoricalSummaries) > 16777216 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.HistoricalSummaries { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("HistoricalSummaries: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 16777216) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.HistoricalSummaries)), 16777216) } - - // Field (28) 'DepositRequestsStartIndex' - ssz.PutUint(hh, b.DepositRequestsStartIndex) - - // Field (29) 'DepositBalanceToConsume' - ssz.PutUint(hh, b.DepositBalanceToConsume) - - // Field (30) 'ExitBalanceToConsume' - ssz.PutUint(hh, b.ExitBalanceToConsume) - - // Field (31) 'EarliestExitEpoch' - ssz.PutUint(hh, b.EarliestExitEpoch) - - // Field (32) 'ConsolidationBalanceToConsume' - ssz.PutUint(hh, b.ConsolidationBalanceToConsume) - - // Field (33) 'EarliestConsolidationEpoch' - ssz.PutUint(hh, b.EarliestConsolidationEpoch) - - // Field (34) 'PendingDeposits' + // Field 28: DepositRequestsStartIndex + hh.PutUint64(c.DepositRequestsStartIndex) + // Field 29: DepositBalanceToConsume + if err := c.DepositBalanceToConsume.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("DepositBalanceToConsume: %w", err) + } + // Field 30: ExitBalanceToConsume + if err := c.ExitBalanceToConsume.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ExitBalanceToConsume: %w", err) + } + // Field 31: EarliestExitEpoch + if err := c.EarliestExitEpoch.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("EarliestExitEpoch: %w", err) + } + // Field 32: ConsolidationBalanceToConsume + if err := c.ConsolidationBalanceToConsume.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ConsolidationBalanceToConsume: %w", err) + } + // Field 33: EarliestConsolidationEpoch + if err := c.EarliestConsolidationEpoch.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("EarliestConsolidationEpoch: %w", err) + } + // Field 34: PendingDeposits { + if len(c.PendingDeposits) > 134217728 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.PendingDeposits { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("PendingDeposits: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 134217728) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.PendingDeposits)), 134217728) } - - // Field (35) 'PendingPartialWithdrawals' + // Field 35: PendingPartialWithdrawals { + if len(c.PendingPartialWithdrawals) > 134217728 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.PendingPartialWithdrawals { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("PendingPartialWithdrawals: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 134217728) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.PendingPartialWithdrawals)), 134217728) } - - // Field (36) 'PendingConsolidations' + // Field 36: PendingConsolidations { + if len(c.PendingConsolidations) > 262144 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.PendingConsolidations { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("PendingConsolidations: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 262144) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.PendingConsolidations)), 262144) } - - // Field (37) 'ProposerLookahead' + // Field 37: ProposerLookahead { - if size := len(b.ProposerLookahead); size != 64 { - err = ssz.ErrVectorLengthFn("--.ProposerLookahead", size, 64) - return + if len(c.ProposerLookahead) != 64 { + return ssz.ErrVectorLength } subIndx := hh.Index() - for _, i := range b.ProposerLookahead { - ssz.AppendUint(hh, i) + for _, o := range c.ProposerLookahead { + hh.AppendUint64(uint64(o)) } hh.Merkleize(subIndx) } + hh.Merkleize(indx) + return nil +} + +func (c *BlindedBeaconBlockFulu) SizeSSZ() int { + size := 84 + if c.Body == nil { + c.Body = new(BlindedBeaconBlockBodyElectra) + } + size += c.Body.SizeSSZ() + return size +} + +func (c *BlindedBeaconBlockFulu) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} + +func (c *BlindedBeaconBlockFulu) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 84 + + // Field 0: Slot + if dst, err = c.Slot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Slot: %w", err) + } + + // Field 1: ProposerIndex + if dst, err = c.ProposerIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ProposerIndex: %w", err) + } + + // Field 2: ParentRoot + if len(c.ParentRoot) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.ParentRoot...) + + // Field 3: StateRoot + if len(c.StateRoot) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.StateRoot...) + + // Field 4: Body + if c.Body == nil { + c.Body = new(BlindedBeaconBlockBodyElectra) + } + dst = ssz.WriteOffset(dst, offset) + offset += c.Body.SizeSSZ() + + // Field 4: Body + if dst, err = c.Body.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Body: %w", err) + } + return dst, err +} + +func (c *BlindedBeaconBlockFulu) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 84 { + return ssz.ErrSize + } + + sszSlice0 := buf[0:8] // c.Slot + sszSlice1 := buf[8:16] // c.ProposerIndex + sszSlice2 := buf[16:48] // c.ParentRoot + sszSlice3 := buf[48:80] // c.StateRoot + + sszVarOffset4 := ssz.ReadOffset(buf[80:84]) // c.Body + if sszVarOffset4 != 84 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset4 > size { + return ssz.ErrOffset + } + sszSlice4 := buf[sszVarOffset4:] // c.Body + + // Field 0: Slot + if err = c.Slot.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Slot: %w", err) + } + + // Field 1: ProposerIndex + if err = c.ProposerIndex.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("ProposerIndex: %w", err) + } + + // Field 2: ParentRoot + c.ParentRoot = make([]byte, 0, 32) + c.ParentRoot = append(c.ParentRoot, sszSlice2...) + + // Field 3: StateRoot + c.StateRoot = make([]byte, 0, 32) + c.StateRoot = append(c.StateRoot, sszSlice3...) + + // Field 4: Body + c.Body = new(BlindedBeaconBlockBodyElectra) + if err = c.Body.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("Body: %w", err) + } + return err +} + +func (c *BlindedBeaconBlockFulu) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} +func (c *BlindedBeaconBlockFulu) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Slot + if err := c.Slot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Slot: %w", err) + } + // Field 1: ProposerIndex + if err := c.ProposerIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ProposerIndex: %w", err) + } + // Field 2: ParentRoot + if len(c.ParentRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ParentRoot) + // Field 3: StateRoot + if len(c.StateRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.StateRoot) + // Field 4: Body + if err := c.Body.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Body: %w", err) + } hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the DataColumnSidecar object -func (d *DataColumnSidecar) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(d) +func (c *DataColumnSidecar) SizeSSZ() int { + size := 356 + size += len(c.Column) * 2048 + size += len(c.KzgCommitments) * 48 + size += len(c.KzgProofs) * 48 + return size } -// MarshalSSZTo ssz marshals the DataColumnSidecar object to a target array -func (d *DataColumnSidecar) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(356) +func (c *DataColumnSidecar) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} + +func (c *DataColumnSidecar) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 356 - // Field (0) 'Index' - dst = ssz.MarshalUint(dst, d.Index) + // Field 0: Index + dst = binary.LittleEndian.AppendUint64(dst, c.Index) - // Offset (1) 'Column' + // Field 1: Column dst = ssz.WriteOffset(dst, offset) - offset += len(d.Column) * 2048 + offset += len(c.Column) * 2048 - // Offset (2) 'KzgCommitments' + // Field 2: KzgCommitments dst = ssz.WriteOffset(dst, offset) - offset += len(d.KzgCommitments) * 48 + offset += len(c.KzgCommitments) * 48 - // Offset (3) 'KzgProofs' + // Field 3: KzgProofs dst = ssz.WriteOffset(dst, offset) - offset += len(d.KzgProofs) * 48 + offset += len(c.KzgProofs) * 48 - // Field (4) 'SignedBlockHeader' - if d.SignedBlockHeader == nil { - d.SignedBlockHeader = new(SignedBeaconBlockHeader) + // Field 4: SignedBlockHeader + if c.SignedBlockHeader == nil { + c.SignedBlockHeader = new(SignedBeaconBlockHeader) } - if dst, err = d.SignedBlockHeader.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.SignedBlockHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SignedBlockHeader: %w", err) } - // Field (5) 'KzgCommitmentsInclusionProof' - if size := len(d.KzgCommitmentsInclusionProof); size != 4 { - err = ssz.ErrVectorLengthFn("--.KzgCommitmentsInclusionProof", size, 4) - return + // Field 5: KzgCommitmentsInclusionProof + if len(c.KzgCommitmentsInclusionProof) != 4 { + return nil, ssz.ErrBytesLength } - for ii := 0; ii < 4; ii++ { - if size := len(d.KzgCommitmentsInclusionProof[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.KzgCommitmentsInclusionProof[ii]", size, 32) - return + for _, o := range c.KzgCommitmentsInclusionProof { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, d.KzgCommitmentsInclusionProof[ii]...) + dst = append(dst, o...) } - // Field (1) 'Column' - if size := len(d.Column); size > 4096 { - err = ssz.ErrListTooBigFn("--.Column", size, 4096) - return + // Field 1: Column + if len(c.Column) > 4096 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(d.Column); ii++ { - if size := len(d.Column[ii]); size != 2048 { - err = ssz.ErrBytesLengthFn("--.Column[ii]", size, 2048) - return + for _, o := range c.Column { + if len(o) != 2048 { + return nil, ssz.ErrBytesLength } - dst = append(dst, d.Column[ii]...) + dst = append(dst, o...) } - // Field (2) 'KzgCommitments' - if size := len(d.KzgCommitments); size > 4096 { - err = ssz.ErrListTooBigFn("--.KzgCommitments", size, 4096) - return + // Field 2: KzgCommitments + if len(c.KzgCommitments) > 4096 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(d.KzgCommitments); ii++ { - if size := len(d.KzgCommitments[ii]); size != 48 { - err = ssz.ErrBytesLengthFn("--.KzgCommitments[ii]", size, 48) - return + for _, o := range c.KzgCommitments { + if len(o) != 48 { + return nil, ssz.ErrBytesLength } - dst = append(dst, d.KzgCommitments[ii]...) + dst = append(dst, o...) } - // Field (3) 'KzgProofs' - if size := len(d.KzgProofs); size > 4096 { - err = ssz.ErrListTooBigFn("--.KzgProofs", size, 4096) - return + // Field 3: KzgProofs + if len(c.KzgProofs) > 4096 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(d.KzgProofs); ii++ { - if size := len(d.KzgProofs[ii]); size != 48 { - err = ssz.ErrBytesLengthFn("--.KzgProofs[ii]", size, 48) - return + for _, o := range c.KzgProofs { + if len(o) != 48 { + return nil, ssz.ErrBytesLength } - dst = append(dst, d.KzgProofs[ii]...) + dst = append(dst, o...) } - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the DataColumnSidecar object -func (d *DataColumnSidecar) UnmarshalSSZ(buf []byte) error { +func (c *DataColumnSidecar) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size < 356 { return ssz.ErrSize } - tail := buf - var o1, o2, o3 uint64 - - // Field (0) 'Index' - d.Index = ssz.UnmarshallUint[uint64](buf[0:8]) - - // Offset (1) 'Column' - if o1 = ssz.ReadOffset(buf[8:12]); o1 > size { - return ssz.ErrOffset - } + sszSlice0 := buf[0:8] // c.Index + sszSlice4 := buf[20:228] // c.SignedBlockHeader + sszSlice5 := buf[228:356] // c.KzgCommitmentsInclusionProof - if o1 != 356 { + sszVarOffset1 := ssz.ReadOffset(buf[8:12]) // c.Column + if sszVarOffset1 != 356 { return ssz.ErrInvalidVariableOffset } - - // Offset (2) 'KzgCommitments' - if o2 = ssz.ReadOffset(buf[12:16]); o2 > size || o1 > o2 { + if sszVarOffset1 > size { return ssz.ErrOffset } - - // Offset (3) 'KzgProofs' - if o3 = ssz.ReadOffset(buf[16:20]); o3 > size || o2 > o3 { + sszVarOffset2 := ssz.ReadOffset(buf[12:16]) // c.KzgCommitments + if sszVarOffset2 > size || sszVarOffset2 < sszVarOffset1 { return ssz.ErrOffset } - - // Field (4) 'SignedBlockHeader' - if d.SignedBlockHeader == nil { - d.SignedBlockHeader = new(SignedBeaconBlockHeader) - } - if err = d.SignedBlockHeader.UnmarshalSSZ(buf[20:228]); err != nil { - return err + sszVarOffset3 := ssz.ReadOffset(buf[16:20]) // c.KzgProofs + if sszVarOffset3 > size || sszVarOffset3 < sszVarOffset2 { + return ssz.ErrOffset } + sszSlice1 := buf[sszVarOffset1:sszVarOffset2] // c.Column + sszSlice2 := buf[sszVarOffset2:sszVarOffset3] // c.KzgCommitments + sszSlice3 := buf[sszVarOffset3:] // c.KzgProofs - // Field (5) 'KzgCommitmentsInclusionProof' - d.KzgCommitmentsInclusionProof = make([][]byte, 4) - for ii := 0; ii < 4; ii++ { - if cap(d.KzgCommitmentsInclusionProof[ii]) == 0 { - d.KzgCommitmentsInclusionProof[ii] = make([]byte, 0, len(buf[228:356][ii*32:(ii+1)*32])) - } - d.KzgCommitmentsInclusionProof[ii] = append(d.KzgCommitmentsInclusionProof[ii], buf[228:356][ii*32:(ii+1)*32]...) - } + // Field 0: Index + c.Index = binary.LittleEndian.Uint64(sszSlice0) - // Field (1) 'Column' + // Field 1: Column { - buf = tail[o1:o2] - num, err := ssz.DivideInt2(len(buf), 2048, 4096) - if err != nil { - return err - } - d.Column = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(d.Column[ii]) == 0 { - d.Column[ii] = make([]byte, 0, len(buf[ii*2048:(ii+1)*2048])) - } - d.Column[ii] = append(d.Column[ii], buf[ii*2048:(ii+1)*2048]...) + if len(sszSlice1)%2048 != 0 { + return fmt.Errorf("misaligned bytes: c.Column length is %d, which is not a multiple of 2048: %w", len(sszSlice1), ssz.ErrIncorrectListSize) } - } + numElem := len(sszSlice1) / 2048 + if numElem > 4096 { + return fmt.Errorf("ssz-max exceeded: c.Column has %d elements, ssz-max is 4096: %w", numElem, ssz.ErrListTooBig) + } + c.Column = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte - // Field (2) 'KzgCommitments' - { - buf = tail[o2:o3] - num, err := ssz.DivideInt2(len(buf), 48, 4096) - if err != nil { - return err - } - d.KzgCommitments = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(d.KzgCommitments[ii]) == 0 { - d.KzgCommitments[ii] = make([]byte, 0, len(buf[ii*48:(ii+1)*48])) - } - d.KzgCommitments[ii] = append(d.KzgCommitments[ii], buf[ii*48:(ii+1)*48]...) + tmpSlice := sszSlice1[i*2048 : (1+i)*2048] + tmp = make([]byte, 0, 2048) + tmp = append(tmp, tmpSlice...) + c.Column[i] = tmp } } - // Field (3) 'KzgProofs' + // Field 2: KzgCommitments { - buf = tail[o3:] - num, err := ssz.DivideInt2(len(buf), 48, 4096) - if err != nil { - return err - } - d.KzgProofs = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(d.KzgProofs[ii]) == 0 { - d.KzgProofs[ii] = make([]byte, 0, len(buf[ii*48:(ii+1)*48])) - } - d.KzgProofs[ii] = append(d.KzgProofs[ii], buf[ii*48:(ii+1)*48]...) + if len(sszSlice2)%48 != 0 { + return fmt.Errorf("misaligned bytes: c.KzgCommitments length is %d, which is not a multiple of 48: %w", len(sszSlice2), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice2) / 48 + if numElem > 4096 { + return fmt.Errorf("ssz-max exceeded: c.KzgCommitments has %d elements, ssz-max is 4096: %w", numElem, ssz.ErrListTooBig) + } + c.KzgCommitments = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte + + tmpSlice := sszSlice2[i*48 : (1+i)*48] + tmp = make([]byte, 0, 48) + tmp = append(tmp, tmpSlice...) + c.KzgCommitments[i] = tmp } } - return err -} -// SizeSSZ returns the ssz encoded size in bytes for the DataColumnSidecar object -func (d *DataColumnSidecar) SizeSSZ() (size int) { - size = 356 + // Field 3: KzgProofs + { + if len(sszSlice3)%48 != 0 { + return fmt.Errorf("misaligned bytes: c.KzgProofs length is %d, which is not a multiple of 48: %w", len(sszSlice3), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice3) / 48 + if numElem > 4096 { + return fmt.Errorf("ssz-max exceeded: c.KzgProofs has %d elements, ssz-max is 4096: %w", numElem, ssz.ErrListTooBig) + } + c.KzgProofs = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte - // Field (1) 'Column' - size += len(d.Column) * 2048 + tmpSlice := sszSlice3[i*48 : (1+i)*48] + tmp = make([]byte, 0, 48) + tmp = append(tmp, tmpSlice...) + c.KzgProofs[i] = tmp + } + } - // Field (2) 'KzgCommitments' - size += len(d.KzgCommitments) * 48 + // Field 4: SignedBlockHeader + c.SignedBlockHeader = new(SignedBeaconBlockHeader) + if err = c.SignedBlockHeader.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("SignedBlockHeader: %w", err) + } - // Field (3) 'KzgProofs' - size += len(d.KzgProofs) * 48 + // Field 5: KzgCommitmentsInclusionProof + { + c.KzgCommitmentsInclusionProof = make([][]byte, 4) + for i := 0; i < 4; i++ { + var tmp []byte - return + tmpSlice := sszSlice5[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.KzgCommitmentsInclusionProof[i] = tmp + } + } + return err } -// HashTreeRoot ssz hashes the DataColumnSidecar object -func (d *DataColumnSidecar) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(d) +func (c *DataColumnSidecar) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the DataColumnSidecar object with a hasher -func (d *DataColumnSidecar) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *DataColumnSidecar) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Index' - ssz.PutUint(hh, d.Index) - - // Field (1) 'Column' + // Field 0: Index + hh.PutUint64(c.Index) + // Field 1: Column { - if size := len(d.Column); size > 4096 { - err = ssz.ErrListTooBigFn("--.Column", size, 4096) - return + if len(c.Column) > 4096 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range d.Column { - if len(i) != 2048 { - err = ssz.ErrBytesLength - return + for _, o := range c.Column { + if len(o) != 2048 { + return ssz.ErrBytesLength } - hh.PutBytes(i) + hh.PutBytes(o) } - - numItems := uint64(len(d.Column)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Column)), 4096) } - - // Field (2) 'KzgCommitments' + // Field 2: KzgCommitments { - if size := len(d.KzgCommitments); size > 4096 { - err = ssz.ErrListTooBigFn("--.KzgCommitments", size, 4096) - return + if len(c.KzgCommitments) > 4096 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range d.KzgCommitments { - if len(i) != 48 { - err = ssz.ErrBytesLength - return + for _, o := range c.KzgCommitments { + if len(o) != 48 { + return ssz.ErrBytesLength } - hh.PutBytes(i) + hh.PutBytes(o) } - - numItems := uint64(len(d.KzgCommitments)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.KzgCommitments)), 4096) } - - // Field (3) 'KzgProofs' + // Field 3: KzgProofs { - if size := len(d.KzgProofs); size > 4096 { - err = ssz.ErrListTooBigFn("--.KzgProofs", size, 4096) - return + if len(c.KzgProofs) > 4096 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range d.KzgProofs { - if len(i) != 48 { - err = ssz.ErrBytesLength - return + for _, o := range c.KzgProofs { + if len(o) != 48 { + return ssz.ErrBytesLength } - hh.PutBytes(i) + hh.PutBytes(o) } - - numItems := uint64(len(d.KzgProofs)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.KzgProofs)), 4096) } - - // Field (4) 'SignedBlockHeader' - if err = d.SignedBlockHeader.HashTreeRootWith(hh); err != nil { - return + // Field 4: SignedBlockHeader + if err := c.SignedBlockHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SignedBlockHeader: %w", err) } - - // Field (5) 'KzgCommitmentsInclusionProof' + // Field 5: KzgCommitmentsInclusionProof { - if size := len(d.KzgCommitmentsInclusionProof); size != 4 { - err = ssz.ErrVectorLengthFn("--.KzgCommitmentsInclusionProof", size, 4) - return + if len(c.KzgCommitmentsInclusionProof) != 4 { + return ssz.ErrVectorLength } subIndx := hh.Index() - for _, i := range d.KzgCommitmentsInclusionProof { - if len(i) != 32 { - err = ssz.ErrBytesLength - return + for _, o := range c.KzgCommitmentsInclusionProof { + if len(o) != 32 { + return ssz.ErrBytesLength } - hh.Append(i) + hh.Append(o) } hh.Merkleize(subIndx) } + hh.Merkleize(indx) + return nil +} + +func (c *DataColumnsByRootIdentifier) SizeSSZ() int { + size := 36 + size += len(c.Columns) * 8 + return size +} + +func (c *DataColumnsByRootIdentifier) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} + +func (c *DataColumnsByRootIdentifier) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 36 + + // Field 0: BlockRoot + if len(c.BlockRoot) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.BlockRoot...) + + // Field 1: Columns + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Columns) * 8 + + // Field 1: Columns + if len(c.Columns) > 128 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.Columns { + dst = binary.LittleEndian.AppendUint64(dst, o) + } + return dst, err +} + +func (c *DataColumnsByRootIdentifier) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 36 { + return ssz.ErrSize + } + + sszSlice0 := buf[0:32] // c.BlockRoot + + sszVarOffset1 := ssz.ReadOffset(buf[32:36]) // c.Columns + if sszVarOffset1 != 36 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset1 > size { + return ssz.ErrOffset + } + sszSlice1 := buf[sszVarOffset1:] // c.Columns + + // Field 0: BlockRoot + c.BlockRoot = make([]byte, 0, 32) + c.BlockRoot = append(c.BlockRoot, sszSlice0...) + + // Field 1: Columns + { + if len(sszSlice1)%8 != 0 { + return fmt.Errorf("misaligned bytes: c.Columns length is %d, which is not a multiple of 8: %w", len(sszSlice1), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice1) / 8 + if numElem > 128 { + return fmt.Errorf("ssz-max exceeded: c.Columns has %d elements, ssz-max is 128: %w", numElem, ssz.ErrListTooBig) + } + c.Columns = make([]uint64, numElem) + for i := 0; i < numElem; i++ { + var tmp uint64 + + tmpSlice := sszSlice1[i*8 : (1+i)*8] + tmp = binary.LittleEndian.Uint64(tmpSlice) + c.Columns[i] = tmp + } + } + return err +} + +func (c *DataColumnsByRootIdentifier) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} +func (c *DataColumnsByRootIdentifier) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: BlockRoot + if len(c.BlockRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.BlockRoot) + // Field 1: Columns + { + if len(c.Columns) > 128 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.Columns { + hh.AppendUint64(o) + } + hh.FillUpTo32() + numItems := uint64(len(c.Columns)) + hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(128, numItems, 8)) + } hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the DataColumnsByRootIdentifier object -func (d *DataColumnsByRootIdentifier) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(d) +func (c *PartialDataColumnHeader) SizeSSZ() int { + size := 340 + size += len(c.KzgCommitments) * 48 + return size } -// MarshalSSZTo ssz marshals the DataColumnsByRootIdentifier object to a target array -func (d *DataColumnsByRootIdentifier) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(36) +func (c *PartialDataColumnHeader) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (0) 'BlockRoot' - if size := len(d.BlockRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockRoot", size, 32) - return - } - dst = append(dst, d.BlockRoot...) +func (c *PartialDataColumnHeader) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 340 - // Offset (1) 'Columns' + // Field 0: KzgCommitments dst = ssz.WriteOffset(dst, offset) - offset += len(d.Columns) * 8 + offset += len(c.KzgCommitments) * 48 + + // Field 1: SignedBlockHeader + if c.SignedBlockHeader == nil { + c.SignedBlockHeader = new(SignedBeaconBlockHeader) + } + if dst, err = c.SignedBlockHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SignedBlockHeader: %w", err) + } - // Field (1) 'Columns' - if size := len(d.Columns); size > 128 { - err = ssz.ErrListTooBigFn("--.Columns", size, 128) - return + // Field 2: KzgCommitmentsInclusionProof + if len(c.KzgCommitmentsInclusionProof) != 4 { + return nil, ssz.ErrBytesLength } - for ii := 0; ii < len(d.Columns); ii++ { - dst = ssz.MarshalUint(dst, d.Columns[ii]) + for _, o := range c.KzgCommitmentsInclusionProof { + if len(o) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) } - return + // Field 0: KzgCommitments + if len(c.KzgCommitments) > 4096 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.KzgCommitments { + if len(o) != 48 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the DataColumnsByRootIdentifier object -func (d *DataColumnsByRootIdentifier) UnmarshalSSZ(buf []byte) error { +func (c *PartialDataColumnHeader) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 36 { + if size < 340 { return ssz.ErrSize } - tail := buf - var o1 uint64 + sszSlice1 := buf[4:212] // c.SignedBlockHeader + sszSlice2 := buf[212:340] // c.KzgCommitmentsInclusionProof - // Field (0) 'BlockRoot' - if cap(d.BlockRoot) == 0 { - d.BlockRoot = make([]byte, 0, len(buf[0:32])) + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.KzgCommitments + if sszVarOffset0 != 340 { + return ssz.ErrInvalidVariableOffset } - d.BlockRoot = append(d.BlockRoot, buf[0:32]...) - - // Offset (1) 'Columns' - if o1 = ssz.ReadOffset(buf[32:36]); o1 > size { + if sszVarOffset0 > size { return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:] // c.KzgCommitments - if o1 != 36 { - return ssz.ErrInvalidVariableOffset - } - - // Field (1) 'Columns' + // Field 0: KzgCommitments { - buf = tail[o1:] - num, err := ssz.DivideInt2(len(buf), 8, 128) - if err != nil { - return err + if len(sszSlice0)%48 != 0 { + return fmt.Errorf("misaligned bytes: c.KzgCommitments length is %d, which is not a multiple of 48: %w", len(sszSlice0), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice0) / 48 + if numElem > 4096 { + return fmt.Errorf("ssz-max exceeded: c.KzgCommitments has %d elements, ssz-max is 4096: %w", numElem, ssz.ErrListTooBig) } - d.Columns = ssz.ExtendUint(d.Columns, num) - for ii := 0; ii < num; ii++ { - d.Columns[ii] = ssz.UnmarshallUint[uint64](buf[ii*8 : (ii+1)*8]) + c.KzgCommitments = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte + + tmpSlice := sszSlice0[i*48 : (1+i)*48] + tmp = make([]byte, 0, 48) + tmp = append(tmp, tmpSlice...) + c.KzgCommitments[i] = tmp } } - return err -} -// SizeSSZ returns the ssz encoded size in bytes for the DataColumnsByRootIdentifier object -func (d *DataColumnsByRootIdentifier) SizeSSZ() (size int) { - size = 36 + // Field 1: SignedBlockHeader + c.SignedBlockHeader = new(SignedBeaconBlockHeader) + if err = c.SignedBlockHeader.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("SignedBlockHeader: %w", err) + } - // Field (1) 'Columns' - size += len(d.Columns) * 8 + // Field 2: KzgCommitmentsInclusionProof + { + c.KzgCommitmentsInclusionProof = make([][]byte, 4) + for i := 0; i < 4; i++ { + var tmp []byte - return + tmpSlice := sszSlice2[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.KzgCommitmentsInclusionProof[i] = tmp + } + } + return err } -// HashTreeRoot ssz hashes the DataColumnsByRootIdentifier object -func (d *DataColumnsByRootIdentifier) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(d) +func (c *PartialDataColumnHeader) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the DataColumnsByRootIdentifier object with a hasher -func (d *DataColumnsByRootIdentifier) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *PartialDataColumnHeader) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'BlockRoot' - if size := len(d.BlockRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockRoot", size, 32) - return + // Field 0: KzgCommitments + { + if len(c.KzgCommitments) > 4096 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.KzgCommitments { + if len(o) != 48 { + return ssz.ErrBytesLength + } + hh.PutBytes(o) + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.KzgCommitments)), 4096) } - hh.PutBytes(d.BlockRoot) - - // Field (1) 'Columns' + // Field 1: SignedBlockHeader + if err := c.SignedBlockHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SignedBlockHeader: %w", err) + } + // Field 2: KzgCommitmentsInclusionProof { - if size := len(d.Columns); size > 128 { - err = ssz.ErrListTooBigFn("--.Columns", size, 128) - return + if len(c.KzgCommitmentsInclusionProof) != 4 { + return ssz.ErrVectorLength } subIndx := hh.Index() - for _, i := range d.Columns { - ssz.AppendUint(hh, i) + for _, o := range c.KzgCommitmentsInclusionProof { + if len(o) != 32 { + return ssz.ErrBytesLength + } + hh.Append(o) } - hh.FillUpTo32() - - numItems := uint64(len(d.Columns)) - hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(128, numItems, 8)) + hh.Merkleize(subIndx) } - hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the StatusV2 object -func (s *StatusV2) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) +func (c *PartialDataColumnPartsMetadata) SizeSSZ() int { + size := 8 + size += len(c.Available) + size += len(c.Requests) + return size } -// MarshalSSZTo ssz marshals the StatusV2 object to a target array -func (s *StatusV2) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *PartialDataColumnPartsMetadata) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (0) 'ForkDigest' - if size := len(s.ForkDigest); size != 4 { - err = ssz.ErrBytesLengthFn("--.ForkDigest", size, 4) - return - } - dst = append(dst, s.ForkDigest...) +func (c *PartialDataColumnPartsMetadata) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 8 - // Field (1) 'FinalizedRoot' - if size := len(s.FinalizedRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.FinalizedRoot", size, 32) - return - } - dst = append(dst, s.FinalizedRoot...) + // Field 0: Available + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Available) - // Field (2) 'FinalizedEpoch' - dst = ssz.MarshalUint(dst, s.FinalizedEpoch) + // Field 1: Requests + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Requests) - // Field (3) 'HeadRoot' - if size := len(s.HeadRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.HeadRoot", size, 32) - return + // Field 0: Available + if len(c.Available) > 4096 { + return nil, ssz.ErrListTooBig } - dst = append(dst, s.HeadRoot...) - - // Field (4) 'HeadSlot' - dst = ssz.MarshalUint(dst, s.HeadSlot) + dst = append(dst, c.Available...) - // Field (5) 'EarliestAvailableSlot' - dst = ssz.MarshalUint(dst, s.EarliestAvailableSlot) - - return + // Field 1: Requests + if len(c.Requests) > 4096 { + return nil, ssz.ErrListTooBig + } + dst = append(dst, c.Requests...) + return dst, err } -// UnmarshalSSZ ssz unmarshals the StatusV2 object -func (s *StatusV2) UnmarshalSSZ(buf []byte) error { +func (c *PartialDataColumnPartsMetadata) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 92 { + if size < 8 { return ssz.ErrSize } - // Field (0) 'ForkDigest' - if cap(s.ForkDigest) == 0 { - s.ForkDigest = make([]byte, 0, len(buf[0:4])) + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Available + if sszVarOffset0 != 8 { + return ssz.ErrInvalidVariableOffset } - s.ForkDigest = append(s.ForkDigest, buf[0:4]...) - - // Field (1) 'FinalizedRoot' - if cap(s.FinalizedRoot) == 0 { - s.FinalizedRoot = make([]byte, 0, len(buf[4:36])) + if sszVarOffset0 > size { + return ssz.ErrOffset } - s.FinalizedRoot = append(s.FinalizedRoot, buf[4:36]...) - - // Field (2) 'FinalizedEpoch' - s.FinalizedEpoch = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Epoch](buf[36:44]) - - // Field (3) 'HeadRoot' - if cap(s.HeadRoot) == 0 { - s.HeadRoot = make([]byte, 0, len(buf[44:76])) + sszVarOffset1 := ssz.ReadOffset(buf[4:8]) // c.Requests + if sszVarOffset1 > size || sszVarOffset1 < sszVarOffset0 { + return ssz.ErrOffset } - s.HeadRoot = append(s.HeadRoot, buf[44:76]...) + sszSlice0 := buf[sszVarOffset0:sszVarOffset1] // c.Available + sszSlice1 := buf[sszVarOffset1:] // c.Requests - // Field (4) 'HeadSlot' - s.HeadSlot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[76:84]) - - // Field (5) 'EarliestAvailableSlot' - s.EarliestAvailableSlot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[84:92]) + // Field 0: Available + if err = ssz.ValidateBitlist(sszSlice0, 4096); err != nil { + return fmt.Errorf("Available: %w", err) + } + c.Available = append([]byte{}, go_bitfield.Bitlist(sszSlice0)...) + // Field 1: Requests + if err = ssz.ValidateBitlist(sszSlice1, 4096); err != nil { + return fmt.Errorf("Requests: %w", err) + } + c.Requests = append([]byte{}, go_bitfield.Bitlist(sszSlice1)...) return err } -// SizeSSZ returns the ssz encoded size in bytes for the StatusV2 object -func (s *StatusV2) SizeSSZ() (size int) { - size = 92 - return -} - -// HashTreeRoot ssz hashes the StatusV2 object -func (s *StatusV2) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) +func (c *PartialDataColumnPartsMetadata) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the StatusV2 object with a hasher -func (s *StatusV2) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *PartialDataColumnPartsMetadata) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'ForkDigest' - if size := len(s.ForkDigest); size != 4 { - err = ssz.ErrBytesLengthFn("--.ForkDigest", size, 4) - return + // Field 0: Available + if len(c.Available) == 0 { + return ssz.ErrEmptyBitlist } - hh.PutBytes(s.ForkDigest) - - // Field (1) 'FinalizedRoot' - if size := len(s.FinalizedRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.FinalizedRoot", size, 32) - return + hh.PutBitlist(c.Available, 4096) + // Field 1: Requests + if len(c.Requests) == 0 { + return ssz.ErrEmptyBitlist } - hh.PutBytes(s.FinalizedRoot) - - // Field (2) 'FinalizedEpoch' - ssz.PutUint(hh, s.FinalizedEpoch) + hh.PutBitlist(c.Requests, 4096) + hh.Merkleize(indx) + return nil +} - // Field (3) 'HeadRoot' - if size := len(s.HeadRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.HeadRoot", size, 32) - return +func (c *PartialDataColumnSidecar) SizeSSZ() int { + size := 16 + size += len(c.CellsPresentBitmap) + size += len(c.PartialColumn) * 2048 + size += len(c.KzgProofs) * 48 + for _, o := range c.Header { + size += 4 + size += o.SizeSSZ() } - hh.PutBytes(s.HeadRoot) - - // Field (4) 'HeadSlot' - ssz.PutUint(hh, s.HeadSlot) - - // Field (5) 'EarliestAvailableSlot' - ssz.PutUint(hh, s.EarliestAvailableSlot) - - hh.Merkleize(indx) - return + return size } -// MarshalSSZ ssz marshals the PartialDataColumnSidecar object -func (p *PartialDataColumnSidecar) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(p) +func (c *PartialDataColumnSidecar) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the PartialDataColumnSidecar object to a target array -func (p *PartialDataColumnSidecar) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(16) +func (c *PartialDataColumnSidecar) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 16 - // Offset (0) 'CellsPresentBitmap' + // Field 0: CellsPresentBitmap dst = ssz.WriteOffset(dst, offset) - offset += len(p.CellsPresentBitmap) + offset += len(c.CellsPresentBitmap) - // Offset (1) 'PartialColumn' + // Field 1: PartialColumn dst = ssz.WriteOffset(dst, offset) - offset += len(p.PartialColumn) * 2048 + offset += len(c.PartialColumn) * 2048 - // Offset (2) 'KzgProofs' + // Field 2: KzgProofs dst = ssz.WriteOffset(dst, offset) - offset += len(p.KzgProofs) * 48 + offset += len(c.KzgProofs) * 48 - // Offset (3) 'Header' + // Field 3: Header dst = ssz.WriteOffset(dst, offset) - for ii := 0; ii < len(p.Header); ii++ { + for _, o := range c.Header { offset += 4 - offset += p.Header[ii].SizeSSZ() + offset += o.SizeSSZ() } - // Field (0) 'CellsPresentBitmap' - if size := len(p.CellsPresentBitmap); size > 4096 { - err = ssz.ErrBytesLengthFn("--.CellsPresentBitmap", size, 4096) - return + // Field 0: CellsPresentBitmap + if len(c.CellsPresentBitmap) > 4096 { + return nil, ssz.ErrListTooBig } - dst = append(dst, p.CellsPresentBitmap...) + dst = append(dst, c.CellsPresentBitmap...) - // Field (1) 'PartialColumn' - if size := len(p.PartialColumn); size > 4096 { - err = ssz.ErrListTooBigFn("--.PartialColumn", size, 4096) - return + // Field 1: PartialColumn + if len(c.PartialColumn) > 4096 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(p.PartialColumn); ii++ { - if size := len(p.PartialColumn[ii]); size != 2048 { - err = ssz.ErrBytesLengthFn("--.PartialColumn[ii]", size, 2048) - return + for _, o := range c.PartialColumn { + if len(o) != 2048 { + return nil, ssz.ErrBytesLength } - dst = append(dst, p.PartialColumn[ii]...) + dst = append(dst, o...) } - // Field (2) 'KzgProofs' - if size := len(p.KzgProofs); size > 4096 { - err = ssz.ErrListTooBigFn("--.KzgProofs", size, 4096) - return + // Field 2: KzgProofs + if len(c.KzgProofs) > 4096 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(p.KzgProofs); ii++ { - if size := len(p.KzgProofs[ii]); size != 48 { - err = ssz.ErrBytesLengthFn("--.KzgProofs[ii]", size, 48) - return + for _, o := range c.KzgProofs { + if len(o) != 48 { + return nil, ssz.ErrBytesLength } - dst = append(dst, p.KzgProofs[ii]...) + dst = append(dst, o...) } - // Field (3) 'Header' - if size := len(p.Header); size > 1 { - err = ssz.ErrListTooBigFn("--.Header", size, 1) - return + // Field 3: Header + if len(c.Header) > 1 { + return nil, ssz.ErrListTooBig } { - offset = 4 * len(p.Header) - for ii := 0; ii < len(p.Header); ii++ { + offset = 4 * len(c.Header) + for _, o := range c.Header { dst = ssz.WriteOffset(dst, offset) - offset += p.Header[ii].SizeSSZ() + offset += o.SizeSSZ() } } - for ii := 0; ii < len(p.Header); ii++ { - if dst, err = p.Header[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.Header { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Header: %w", err) } } - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the PartialDataColumnSidecar object -func (p *PartialDataColumnSidecar) UnmarshalSSZ(buf []byte) error { +func (c *PartialDataColumnSidecar) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size < 16 { return ssz.ErrSize } - tail := buf - var o0, o1, o2, o3 uint64 - - // Offset (0) 'CellsPresentBitmap' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.CellsPresentBitmap + if sszVarOffset0 != 16 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset0 > size { return ssz.ErrOffset } - - if o0 != 16 { - return ssz.ErrInvalidVariableOffset + sszVarOffset1 := ssz.ReadOffset(buf[4:8]) // c.PartialColumn + if sszVarOffset1 > size || sszVarOffset1 < sszVarOffset0 { + return ssz.ErrOffset } - - // Offset (1) 'PartialColumn' - if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 { + sszVarOffset2 := ssz.ReadOffset(buf[8:12]) // c.KzgProofs + if sszVarOffset2 > size || sszVarOffset2 < sszVarOffset1 { return ssz.ErrOffset } - - // Offset (2) 'KzgProofs' - if o2 = ssz.ReadOffset(buf[8:12]); o2 > size || o1 > o2 { + sszVarOffset3 := ssz.ReadOffset(buf[12:16]) // c.Header + if sszVarOffset3 > size || sszVarOffset3 < sszVarOffset2 { return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:sszVarOffset1] // c.CellsPresentBitmap + sszSlice1 := buf[sszVarOffset1:sszVarOffset2] // c.PartialColumn + sszSlice2 := buf[sszVarOffset2:sszVarOffset3] // c.KzgProofs + sszSlice3 := buf[sszVarOffset3:] // c.Header - // Offset (3) 'Header' - if o3 = ssz.ReadOffset(buf[12:16]); o3 > size || o2 > o3 { - return ssz.ErrOffset + // Field 0: CellsPresentBitmap + if err = ssz.ValidateBitlist(sszSlice0, 4096); err != nil { + return fmt.Errorf("CellsPresentBitmap: %w", err) } + c.CellsPresentBitmap = append([]byte{}, go_bitfield.Bitlist(sszSlice0)...) - // Field (0) 'CellsPresentBitmap' + // Field 1: PartialColumn { - buf = tail[o0:o1] - if err = ssz.ValidateBitlist(buf, 4096); err != nil { - return err + if len(sszSlice1)%2048 != 0 { + return fmt.Errorf("misaligned bytes: c.PartialColumn length is %d, which is not a multiple of 2048: %w", len(sszSlice1), ssz.ErrIncorrectListSize) } - if cap(p.CellsPresentBitmap) == 0 { - p.CellsPresentBitmap = make([]byte, 0, len(buf)) + numElem := len(sszSlice1) / 2048 + if numElem > 4096 { + return fmt.Errorf("ssz-max exceeded: c.PartialColumn has %d elements, ssz-max is 4096: %w", numElem, ssz.ErrListTooBig) } - p.CellsPresentBitmap = append(p.CellsPresentBitmap, buf...) - } + c.PartialColumn = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte - // Field (1) 'PartialColumn' - { - buf = tail[o1:o2] - num, err := ssz.DivideInt2(len(buf), 2048, 4096) - if err != nil { - return err - } - p.PartialColumn = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(p.PartialColumn[ii]) == 0 { - p.PartialColumn[ii] = make([]byte, 0, len(buf[ii*2048:(ii+1)*2048])) - } - p.PartialColumn[ii] = append(p.PartialColumn[ii], buf[ii*2048:(ii+1)*2048]...) + tmpSlice := sszSlice1[i*2048 : (1+i)*2048] + tmp = make([]byte, 0, 2048) + tmp = append(tmp, tmpSlice...) + c.PartialColumn[i] = tmp } } - // Field (2) 'KzgProofs' + // Field 2: KzgProofs { - buf = tail[o2:o3] - num, err := ssz.DivideInt2(len(buf), 48, 4096) - if err != nil { - return err - } - p.KzgProofs = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(p.KzgProofs[ii]) == 0 { - p.KzgProofs[ii] = make([]byte, 0, len(buf[ii*48:(ii+1)*48])) - } - p.KzgProofs[ii] = append(p.KzgProofs[ii], buf[ii*48:(ii+1)*48]...) + if len(sszSlice2)%48 != 0 { + return fmt.Errorf("misaligned bytes: c.KzgProofs length is %d, which is not a multiple of 48: %w", len(sszSlice2), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice2) / 48 + if numElem > 4096 { + return fmt.Errorf("ssz-max exceeded: c.KzgProofs has %d elements, ssz-max is 4096: %w", numElem, ssz.ErrListTooBig) + } + c.KzgProofs = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte + + tmpSlice := sszSlice2[i*48 : (1+i)*48] + tmp = make([]byte, 0, 48) + tmp = append(tmp, tmpSlice...) + c.KzgProofs[i] = tmp } } - // Field (3) 'Header' + // Field 3: Header { - buf = tail[o3:] - num, err := ssz.DecodeDynamicLength(buf, 1) - if err != nil { - return err - } - p.Header = make([]*PartialDataColumnHeader, num) - err = ssz.UnmarshalDynamic(buf, num, func(indx int, buf []byte) (err error) { - if p.Header[indx] == nil { - p.Header[indx] = new(PartialDataColumnHeader) + // empty lists are zero length, so make sure there is room for an offset + // before attempting to unmarshal it + if len(sszSlice3) > 3 { + startOffset := ssz.ReadOffset(sszSlice3[0:4]) + if startOffset == 0 { + return fmt.Errorf("encountered invalid offset of 0 when decoding c.Header") + } + if startOffset%4 != 0 { + return fmt.Errorf("misaligned list bytes: when decoding c.Header, end-of-list offset is %d, which is not a multiple of 4 (offset size)", startOffset) + } + listLen := startOffset / 4 + if listLen > 1 { + return fmt.Errorf("ssz-max exceeded: c.Header has %d elements, ssz-max is 1: %w", listLen, ssz.ErrListTooBig) + } + totalVarBytes := uint64(len(sszSlice3)) + if totalVarBytes < startOffset { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.Header") + } + c.Header = make([]*PartialDataColumnHeader, listLen) + var tmpSlice []byte + for i := uint64(0); i < listLen; i++ { + var tmp *PartialDataColumnHeader + tmp = new(PartialDataColumnHeader) + endOffset := totalVarBytes + if i+1 != listLen { + endOffset = ssz.ReadOffset(sszSlice3[(i+1)*4 : (i+2)*4]) + if totalVarBytes < endOffset { + return fmt.Errorf("offset %d points past the end of buffer when decoding c.Header", endOffset) + } + } + if endOffset < startOffset { + return fmt.Errorf("offset %d is not greater than start offset %d when decoding c.Header", endOffset, startOffset) + } + tmpSlice = sszSlice3[startOffset:endOffset] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Header: %w", err) + } + c.Header[i] = tmp + startOffset = endOffset } - if err = p.Header[indx].UnmarshalSSZ(buf); err != nil { - return err + } else { + if len(sszSlice3) > 0 { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.Header") } - return nil - }) - if err != nil { - return err + c.Header = make([]*PartialDataColumnHeader, 0) } } return err } -// SizeSSZ returns the ssz encoded size in bytes for the PartialDataColumnSidecar object -func (p *PartialDataColumnSidecar) SizeSSZ() (size int) { - size = 16 - - // Field (0) 'CellsPresentBitmap' - size += len(p.CellsPresentBitmap) - - // Field (1) 'PartialColumn' - size += len(p.PartialColumn) * 2048 - - // Field (2) 'KzgProofs' - size += len(p.KzgProofs) * 48 - - // Field (3) 'Header' - for ii := 0; ii < len(p.Header); ii++ { - size += 4 - size += p.Header[ii].SizeSSZ() +func (c *PartialDataColumnSidecar) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - - return -} - -// HashTreeRoot ssz hashes the PartialDataColumnSidecar object -func (p *PartialDataColumnSidecar) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(p) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the PartialDataColumnSidecar object with a hasher -func (p *PartialDataColumnSidecar) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *PartialDataColumnSidecar) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'CellsPresentBitmap' - if len(p.CellsPresentBitmap) == 0 { - err = ssz.ErrEmptyBitlist - return + // Field 0: CellsPresentBitmap + if len(c.CellsPresentBitmap) == 0 { + return ssz.ErrEmptyBitlist } - hh.PutBitlist(p.CellsPresentBitmap, 4096) - - // Field (1) 'PartialColumn' + hh.PutBitlist(c.CellsPresentBitmap, 4096) + // Field 1: PartialColumn { - if size := len(p.PartialColumn); size > 4096 { - err = ssz.ErrListTooBigFn("--.PartialColumn", size, 4096) - return + if len(c.PartialColumn) > 4096 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range p.PartialColumn { - if len(i) != 2048 { - err = ssz.ErrBytesLength - return + for _, o := range c.PartialColumn { + if len(o) != 2048 { + return ssz.ErrBytesLength } - hh.PutBytes(i) + hh.PutBytes(o) } - - numItems := uint64(len(p.PartialColumn)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.PartialColumn)), 4096) } - - // Field (2) 'KzgProofs' + // Field 2: KzgProofs { - if size := len(p.KzgProofs); size > 4096 { - err = ssz.ErrListTooBigFn("--.KzgProofs", size, 4096) - return + if len(c.KzgProofs) > 4096 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range p.KzgProofs { - if len(i) != 48 { - err = ssz.ErrBytesLength - return + for _, o := range c.KzgProofs { + if len(o) != 48 { + return ssz.ErrBytesLength } - hh.PutBytes(i) + hh.PutBytes(o) } - - numItems := uint64(len(p.KzgProofs)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.KzgProofs)), 4096) } - - // Field (3) 'Header' + // Field 3: Header { + if len(c.Header) > 1 { + return ssz.ErrListTooBig + } subIndx := hh.Index() - num := uint64(len(p.Header)) - if num > 1 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range p.Header { - if err = elem.HashTreeRootWith(hh); err != nil { - return + for _, o := range c.Header { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Header: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 1) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Header)), 1) } - hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the PartialDataColumnHeader object -func (p *PartialDataColumnHeader) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(p) +func (c *SignedBeaconBlockContentsFulu) SizeSSZ() int { + size := 12 + if c.Block == nil { + c.Block = new(SignedBeaconBlockFulu) + } + size += c.Block.SizeSSZ() + size += len(c.KzgProofs) * 48 + size += len(c.Blobs) * 131072 + return size } -// MarshalSSZTo ssz marshals the PartialDataColumnHeader object to a target array -func (p *PartialDataColumnHeader) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(340) +func (c *SignedBeaconBlockContentsFulu) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Offset (0) 'KzgCommitments' - dst = ssz.WriteOffset(dst, offset) - offset += len(p.KzgCommitments) * 48 +func (c *SignedBeaconBlockContentsFulu) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 12 - // Field (1) 'SignedBlockHeader' - if p.SignedBlockHeader == nil { - p.SignedBlockHeader = new(SignedBeaconBlockHeader) + // Field 0: Block + if c.Block == nil { + c.Block = new(SignedBeaconBlockFulu) } - if dst, err = p.SignedBlockHeader.MarshalSSZTo(dst); err != nil { - return + dst = ssz.WriteOffset(dst, offset) + offset += c.Block.SizeSSZ() + + // Field 1: KzgProofs + dst = ssz.WriteOffset(dst, offset) + offset += len(c.KzgProofs) * 48 + + // Field 2: Blobs + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Blobs) * 131072 + + // Field 0: Block + if dst, err = c.Block.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Block: %w", err) } - // Field (2) 'KzgCommitmentsInclusionProof' - if size := len(p.KzgCommitmentsInclusionProof); size != 4 { - err = ssz.ErrVectorLengthFn("--.KzgCommitmentsInclusionProof", size, 4) - return + // Field 1: KzgProofs + if len(c.KzgProofs) > 33554432 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < 4; ii++ { - if size := len(p.KzgCommitmentsInclusionProof[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.KzgCommitmentsInclusionProof[ii]", size, 32) - return + for _, o := range c.KzgProofs { + if len(o) != 48 { + return nil, ssz.ErrBytesLength } - dst = append(dst, p.KzgCommitmentsInclusionProof[ii]...) + dst = append(dst, o...) } - // Field (0) 'KzgCommitments' - if size := len(p.KzgCommitments); size > 4096 { - err = ssz.ErrListTooBigFn("--.KzgCommitments", size, 4096) - return + // Field 2: Blobs + if len(c.Blobs) > 4096 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(p.KzgCommitments); ii++ { - if size := len(p.KzgCommitments[ii]); size != 48 { - err = ssz.ErrBytesLengthFn("--.KzgCommitments[ii]", size, 48) - return + for _, o := range c.Blobs { + if len(o) != 131072 { + return nil, ssz.ErrBytesLength } - dst = append(dst, p.KzgCommitments[ii]...) + dst = append(dst, o...) } - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the PartialDataColumnHeader object -func (p *PartialDataColumnHeader) UnmarshalSSZ(buf []byte) error { +func (c *SignedBeaconBlockContentsFulu) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 340 { + if size < 12 { return ssz.ErrSize } - tail := buf - var o0 uint64 - - // Offset (0) 'KzgCommitments' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Block + if sszVarOffset0 != 12 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset0 > size { return ssz.ErrOffset } - - if o0 != 340 { - return ssz.ErrInvalidVariableOffset + sszVarOffset1 := ssz.ReadOffset(buf[4:8]) // c.KzgProofs + if sszVarOffset1 > size || sszVarOffset1 < sszVarOffset0 { + return ssz.ErrOffset } - - // Field (1) 'SignedBlockHeader' - if p.SignedBlockHeader == nil { - p.SignedBlockHeader = new(SignedBeaconBlockHeader) + sszVarOffset2 := ssz.ReadOffset(buf[8:12]) // c.Blobs + if sszVarOffset2 > size || sszVarOffset2 < sszVarOffset1 { + return ssz.ErrOffset } - if err = p.SignedBlockHeader.UnmarshalSSZ(buf[4:212]); err != nil { - return err + sszSlice0 := buf[sszVarOffset0:sszVarOffset1] // c.Block + sszSlice1 := buf[sszVarOffset1:sszVarOffset2] // c.KzgProofs + sszSlice2 := buf[sszVarOffset2:] // c.Blobs + + // Field 0: Block + c.Block = new(SignedBeaconBlockFulu) + if err = c.Block.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Block: %w", err) } - // Field (2) 'KzgCommitmentsInclusionProof' - p.KzgCommitmentsInclusionProof = make([][]byte, 4) - for ii := 0; ii < 4; ii++ { - if cap(p.KzgCommitmentsInclusionProof[ii]) == 0 { - p.KzgCommitmentsInclusionProof[ii] = make([]byte, 0, len(buf[212:340][ii*32:(ii+1)*32])) + // Field 1: KzgProofs + { + if len(sszSlice1)%48 != 0 { + return fmt.Errorf("misaligned bytes: c.KzgProofs length is %d, which is not a multiple of 48: %w", len(sszSlice1), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice1) / 48 + if numElem > 33554432 { + return fmt.Errorf("ssz-max exceeded: c.KzgProofs has %d elements, ssz-max is 33554432: %w", numElem, ssz.ErrListTooBig) + } + c.KzgProofs = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte + + tmpSlice := sszSlice1[i*48 : (1+i)*48] + tmp = make([]byte, 0, 48) + tmp = append(tmp, tmpSlice...) + c.KzgProofs[i] = tmp } - p.KzgCommitmentsInclusionProof[ii] = append(p.KzgCommitmentsInclusionProof[ii], buf[212:340][ii*32:(ii+1)*32]...) } - // Field (0) 'KzgCommitments' + // Field 2: Blobs { - buf = tail[o0:] - num, err := ssz.DivideInt2(len(buf), 48, 4096) - if err != nil { - return err - } - p.KzgCommitments = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(p.KzgCommitments[ii]) == 0 { - p.KzgCommitments[ii] = make([]byte, 0, len(buf[ii*48:(ii+1)*48])) - } - p.KzgCommitments[ii] = append(p.KzgCommitments[ii], buf[ii*48:(ii+1)*48]...) + if len(sszSlice2)%131072 != 0 { + return fmt.Errorf("misaligned bytes: c.Blobs length is %d, which is not a multiple of 131072: %w", len(sszSlice2), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice2) / 131072 + if numElem > 4096 { + return fmt.Errorf("ssz-max exceeded: c.Blobs has %d elements, ssz-max is 4096: %w", numElem, ssz.ErrListTooBig) + } + c.Blobs = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte + + tmpSlice := sszSlice2[i*131072 : (1+i)*131072] + tmp = make([]byte, 0, 131072) + tmp = append(tmp, tmpSlice...) + c.Blobs[i] = tmp } } return err } -// SizeSSZ returns the ssz encoded size in bytes for the PartialDataColumnHeader object -func (p *PartialDataColumnHeader) SizeSSZ() (size int) { - size = 340 - - // Field (0) 'KzgCommitments' - size += len(p.KzgCommitments) * 48 - - return -} - -// HashTreeRoot ssz hashes the PartialDataColumnHeader object -func (p *PartialDataColumnHeader) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(p) +func (c *SignedBeaconBlockContentsFulu) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the PartialDataColumnHeader object with a hasher -func (p *PartialDataColumnHeader) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *SignedBeaconBlockContentsFulu) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'KzgCommitments' + // Field 0: Block + if err := c.Block.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Block: %w", err) + } + // Field 1: KzgProofs { - if size := len(p.KzgCommitments); size > 4096 { - err = ssz.ErrListTooBigFn("--.KzgCommitments", size, 4096) - return + if len(c.KzgProofs) > 33554432 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range p.KzgCommitments { - if len(i) != 48 { - err = ssz.ErrBytesLength - return + for _, o := range c.KzgProofs { + if len(o) != 48 { + return ssz.ErrBytesLength } - hh.PutBytes(i) + hh.PutBytes(o) } - - numItems := uint64(len(p.KzgCommitments)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) - } - - // Field (1) 'SignedBlockHeader' - if err = p.SignedBlockHeader.HashTreeRootWith(hh); err != nil { - return + hh.MerkleizeWithMixin(subIndx, uint64(len(c.KzgProofs)), 33554432) } - - // Field (2) 'KzgCommitmentsInclusionProof' + // Field 2: Blobs { - if size := len(p.KzgCommitmentsInclusionProof); size != 4 { - err = ssz.ErrVectorLengthFn("--.KzgCommitmentsInclusionProof", size, 4) - return + if len(c.Blobs) > 4096 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range p.KzgCommitmentsInclusionProof { - if len(i) != 32 { - err = ssz.ErrBytesLength - return + for _, o := range c.Blobs { + if len(o) != 131072 { + return ssz.ErrBytesLength } - hh.Append(i) + hh.PutBytes(o) } - hh.Merkleize(subIndx) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Blobs)), 4096) } - hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the PartialDataColumnPartsMetadata object -func (p *PartialDataColumnPartsMetadata) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(p) +func (c *SignedBeaconBlockFulu) SizeSSZ() int { + size := 100 + if c.Block == nil { + c.Block = new(BeaconBlockElectra) + } + size += c.Block.SizeSSZ() + return size } -// MarshalSSZTo ssz marshals the PartialDataColumnPartsMetadata object to a target array -func (p *PartialDataColumnPartsMetadata) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(8) +func (c *SignedBeaconBlockFulu) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Offset (0) 'Available' - dst = ssz.WriteOffset(dst, offset) - offset += len(p.Available) +func (c *SignedBeaconBlockFulu) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 100 - // Offset (1) 'Requests' + // Field 0: Block + if c.Block == nil { + c.Block = new(BeaconBlockElectra) + } dst = ssz.WriteOffset(dst, offset) - offset += len(p.Requests) + offset += c.Block.SizeSSZ() - // Field (0) 'Available' - if size := len(p.Available); size > 4096 { - err = ssz.ErrBytesLengthFn("--.Available", size, 4096) - return + // Field 1: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } - dst = append(dst, p.Available...) + dst = append(dst, c.Signature...) - // Field (1) 'Requests' - if size := len(p.Requests); size > 4096 { - err = ssz.ErrBytesLengthFn("--.Requests", size, 4096) - return + // Field 0: Block + if dst, err = c.Block.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Block: %w", err) } - dst = append(dst, p.Requests...) - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the PartialDataColumnPartsMetadata object -func (p *PartialDataColumnPartsMetadata) UnmarshalSSZ(buf []byte) error { +func (c *SignedBeaconBlockFulu) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 8 { + if size < 100 { return ssz.ErrSize } - tail := buf - var o0, o1 uint64 + sszSlice1 := buf[4:100] // c.Signature - // Offset (0) 'Available' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Block + if sszVarOffset0 != 100 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset0 > size { return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:] // c.Block - if o0 != 8 { - return ssz.ErrInvalidVariableOffset + // Field 0: Block + c.Block = new(BeaconBlockElectra) + if err = c.Block.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Block: %w", err) } - // Offset (1) 'Requests' - if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 { - return ssz.ErrOffset + // Field 1: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice1...) + return err +} + +func (c *SignedBeaconBlockFulu) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (0) 'Available' - { - buf = tail[o0:o1] - if err = ssz.ValidateBitlist(buf, 4096); err != nil { - return err - } - if cap(p.Available) == 0 { - p.Available = make([]byte, 0, len(buf)) - } - p.Available = append(p.Available, buf...) +func (c *SignedBeaconBlockFulu) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Block + if err := c.Block.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Block: %w", err) + } + // Field 1: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength } + hh.PutBytes(c.Signature) + hh.Merkleize(indx) + return nil +} - // Field (1) 'Requests' - { - buf = tail[o1:] - if err = ssz.ValidateBitlist(buf, 4096); err != nil { - return err - } - if cap(p.Requests) == 0 { - p.Requests = make([]byte, 0, len(buf)) - } - p.Requests = append(p.Requests, buf...) +func (c *SignedBlindedBeaconBlockFulu) SizeSSZ() int { + size := 100 + if c.Message == nil { + c.Message = new(BlindedBeaconBlockFulu) } - return err + size += c.Message.SizeSSZ() + return size +} + +func (c *SignedBlindedBeaconBlockFulu) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} + +func (c *SignedBlindedBeaconBlockFulu) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 100 + + // Field 0: Message + if c.Message == nil { + c.Message = new(BlindedBeaconBlockFulu) + } + dst = ssz.WriteOffset(dst, offset) + offset += c.Message.SizeSSZ() + + // Field 1: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.Signature...) + + // Field 0: Message + if dst, err = c.Message.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Message: %w", err) + } + return dst, err } -// SizeSSZ returns the ssz encoded size in bytes for the PartialDataColumnPartsMetadata object -func (p *PartialDataColumnPartsMetadata) SizeSSZ() (size int) { - size = 8 +func (c *SignedBlindedBeaconBlockFulu) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 100 { + return ssz.ErrSize + } + + sszSlice1 := buf[4:100] // c.Signature - // Field (0) 'Available' - size += len(p.Available) + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Message + if sszVarOffset0 != 100 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset0 > size { + return ssz.ErrOffset + } + sszSlice0 := buf[sszVarOffset0:] // c.Message - // Field (1) 'Requests' - size += len(p.Requests) + // Field 0: Message + c.Message = new(BlindedBeaconBlockFulu) + if err = c.Message.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Message: %w", err) + } - return + // Field 1: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice1...) + return err } -// HashTreeRoot ssz hashes the PartialDataColumnPartsMetadata object -func (p *PartialDataColumnPartsMetadata) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(p) +func (c *SignedBlindedBeaconBlockFulu) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the PartialDataColumnPartsMetadata object with a hasher -func (p *PartialDataColumnPartsMetadata) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *SignedBlindedBeaconBlockFulu) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() + // Field 0: Message + if err := c.Message.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Message: %w", err) + } + // Field 1: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Signature) + hh.Merkleize(indx) + return nil +} + +func (c *StatusV2) SizeSSZ() int { + size := 92 + + return size +} + +func (c *StatusV2) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} + +func (c *StatusV2) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + + // Field 0: ForkDigest + if len(c.ForkDigest) != 4 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.ForkDigest...) + + // Field 1: FinalizedRoot + if len(c.FinalizedRoot) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.FinalizedRoot...) + + // Field 2: FinalizedEpoch + if dst, err = c.FinalizedEpoch.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("FinalizedEpoch: %w", err) + } - // Field (0) 'Available' - if len(p.Available) == 0 { - err = ssz.ErrEmptyBitlist - return + // Field 3: HeadRoot + if len(c.HeadRoot) != 32 { + return nil, ssz.ErrBytesLength } - hh.PutBitlist(p.Available, 4096) + dst = append(dst, c.HeadRoot...) - // Field (1) 'Requests' - if len(p.Requests) == 0 { - err = ssz.ErrEmptyBitlist - return + // Field 4: HeadSlot + if dst, err = c.HeadSlot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("HeadSlot: %w", err) } - hh.PutBitlist(p.Requests, 4096) + // Field 5: EarliestAvailableSlot + if dst, err = c.EarliestAvailableSlot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("EarliestAvailableSlot: %w", err) + } + + return dst, err +} + +func (c *StatusV2) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 92 { + return ssz.ErrSize + } + + sszSlice0 := buf[0:4] // c.ForkDigest + sszSlice1 := buf[4:36] // c.FinalizedRoot + sszSlice2 := buf[36:44] // c.FinalizedEpoch + sszSlice3 := buf[44:76] // c.HeadRoot + sszSlice4 := buf[76:84] // c.HeadSlot + sszSlice5 := buf[84:92] // c.EarliestAvailableSlot + + // Field 0: ForkDigest + c.ForkDigest = make([]byte, 0, 4) + c.ForkDigest = append(c.ForkDigest, sszSlice0...) + + // Field 1: FinalizedRoot + c.FinalizedRoot = make([]byte, 0, 32) + c.FinalizedRoot = append(c.FinalizedRoot, sszSlice1...) + + // Field 2: FinalizedEpoch + if err = c.FinalizedEpoch.UnmarshalSSZ(sszSlice2); err != nil { + return fmt.Errorf("FinalizedEpoch: %w", err) + } + + // Field 3: HeadRoot + c.HeadRoot = make([]byte, 0, 32) + c.HeadRoot = append(c.HeadRoot, sszSlice3...) + + // Field 4: HeadSlot + if err = c.HeadSlot.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("HeadSlot: %w", err) + } + + // Field 5: EarliestAvailableSlot + if err = c.EarliestAvailableSlot.UnmarshalSSZ(sszSlice5); err != nil { + return fmt.Errorf("EarliestAvailableSlot: %w", err) + } + return err +} + +func (c *StatusV2) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} + +func (c *StatusV2) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: ForkDigest + if len(c.ForkDigest) != 4 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ForkDigest) + // Field 1: FinalizedRoot + if len(c.FinalizedRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.FinalizedRoot) + // Field 2: FinalizedEpoch + if err := c.FinalizedEpoch.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("FinalizedEpoch: %w", err) + } + // Field 3: HeadRoot + if len(c.HeadRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.HeadRoot) + // Field 4: HeadSlot + if err := c.HeadSlot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("HeadSlot: %w", err) + } + // Field 5: EarliestAvailableSlot + if err := c.EarliestAvailableSlot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("EarliestAvailableSlot: %w", err) + } hh.Merkleize(indx) - return + return nil } diff --git a/proto/prysm/v1alpha1/fulu.yaml b/proto/prysm/v1alpha1/fulu.yaml new file mode 100644 index 000000000000..fff18493910d --- /dev/null +++ b/proto/prysm/v1alpha1/fulu.yaml @@ -0,0 +1,14 @@ +package: "github.com/OffchainLabs/prysm/v7/proto/prysm/v1alpha1" +types: + - name: "BeaconBlockContentsFulu" + - name: "BeaconStateFulu" + - name: "BlindedBeaconBlockFulu" + - name: "DataColumnSidecar" + - name: "DataColumnsByRootIdentifier" + - name: "PartialDataColumnHeader" + - name: "PartialDataColumnPartsMetadata" + - name: "PartialDataColumnSidecar" + - name: "SignedBeaconBlockContentsFulu" + - name: "SignedBeaconBlockFulu" + - name: "SignedBlindedBeaconBlockFulu" + - name: "StatusV2" diff --git a/proto/prysm/v1alpha1/gloas.minimal.ssz.go b/proto/prysm/v1alpha1/gloas.minimal.ssz.go index a4727052eaa4..5fab1f5af70d 100644 --- a/proto/prysm/v1alpha1/gloas.minimal.ssz.go +++ b/proto/prysm/v1alpha1/gloas.minimal.ssz.go @@ -1,5470 +1,5589 @@ //go:build minimal -// Code generated by fastssz. DO NOT EDIT. package eth import ( - github_com_OffchainLabs_prysm_v7_consensus_types_primitives "github.com/OffchainLabs/prysm/v7/consensus-types/primitives" + binary "encoding/binary" + "fmt" + go_bitfield "github.com/OffchainLabs/go-bitfield" + ssz "github.com/OffchainLabs/methodical-ssz/ssz" + primitives "github.com/OffchainLabs/prysm/v7/consensus-types/primitives" v1 "github.com/OffchainLabs/prysm/v7/proto/engine/v1" - ssz "github.com/prysmaticlabs/fastssz" ) -// MarshalSSZ ssz marshals the AttestationGloas object -func (a *AttestationGloas) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(a) +func (c *AttestationGloas) SizeSSZ() int { + size := 229 + size += len(c.AggregationBits) + return size } -// MarshalSSZTo ssz marshals the AttestationGloas object to a target array -func (a *AttestationGloas) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(229) +func (c *AttestationGloas) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} + +func (c *AttestationGloas) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 229 - // Offset (0) 'AggregationBits' + // Field 0: AggregationBits dst = ssz.WriteOffset(dst, offset) - offset += len(a.AggregationBits) + offset += len(c.AggregationBits) - // Field (1) 'Data' - if a.Data == nil { - a.Data = new(AttestationData) + // Field 1: Data + if c.Data == nil { + c.Data = new(AttestationData) } - if dst, err = a.Data.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.Data.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Data: %w", err) } - // Field (2) 'Signature' - if size := len(a.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 2: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } - dst = append(dst, a.Signature...) + dst = append(dst, c.Signature...) - // Field (3) 'CommitteeBits' - if size := len(a.CommitteeBits); size != 1 { - err = ssz.ErrBytesLengthFn("--.CommitteeBits", size, 1) - return + // Field 3: CommitteeBits + if len([]byte(c.CommitteeBits)) != 1 { + return nil, ssz.ErrBytesLength } - dst = append(dst, a.CommitteeBits...) + dst = append(dst, []byte(c.CommitteeBits)...) - // Field (0) 'AggregationBits' - if size := len(a.AggregationBits); size > 8192 { - err = ssz.ErrBytesLengthFn("--.AggregationBits", size, 8192) - return + // Field 0: AggregationBits + if len(c.AggregationBits) > 8192 { + return nil, ssz.ErrListTooBig } - dst = append(dst, a.AggregationBits...) - - return + dst = append(dst, c.AggregationBits...) + return dst, err } -// UnmarshalSSZ ssz unmarshals the AttestationGloas object -func (a *AttestationGloas) UnmarshalSSZ(buf []byte) error { +func (c *AttestationGloas) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size < 229 { return ssz.ErrSize } - tail := buf - var o0 uint64 + sszSlice1 := buf[4:132] // c.Data + sszSlice2 := buf[132:228] // c.Signature + sszSlice3 := buf[228:229] // c.CommitteeBits - // Offset (0) 'AggregationBits' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } - - if o0 != 229 { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.AggregationBits + if sszVarOffset0 != 229 { 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' - if cap(a.Signature) == 0 { - a.Signature = make([]byte, 0, len(buf[132:228])) + if sszVarOffset0 > size { + return ssz.ErrOffset } - a.Signature = append(a.Signature, buf[132:228]...) + sszSlice0 := buf[sszVarOffset0:] // c.AggregationBits - // Field (3) 'CommitteeBits' - if cap(a.CommitteeBits) == 0 { - a.CommitteeBits = make([]byte, 0, len(buf[228:229])) + // Field 0: AggregationBits + if err = ssz.ValidateBitlist(sszSlice0, 8192); err != nil { + return fmt.Errorf("AggregationBits: %w", err) } - a.CommitteeBits = append(a.CommitteeBits, buf[228:229]...) + c.AggregationBits = append([]byte{}, go_bitfield.Bitlist(sszSlice0)...) - // Field (0) 'AggregationBits' - { - buf = tail[o0:] - if err = ssz.ValidateBitlist(buf, 8192); err != nil { - return err - } - if cap(a.AggregationBits) == 0 { - a.AggregationBits = make([]byte, 0, len(buf)) - } - a.AggregationBits = append(a.AggregationBits, buf...) + // Field 1: Data + c.Data = new(AttestationData) + if err = c.Data.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Data: %w", err) } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the AttestationGloas object -func (a *AttestationGloas) SizeSSZ() (size int) { - size = 229 - // Field (0) 'AggregationBits' - size += len(a.AggregationBits) + // Field 2: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice2...) - return + // Field 3: CommitteeBits + c.CommitteeBits = make([]byte, 0, 1) + c.CommitteeBits = append(c.CommitteeBits, go_bitfield.Bitvector4(sszSlice3)...) + return err } -// HashTreeRoot ssz hashes the AttestationGloas object -func (a *AttestationGloas) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(a) +func (c *AttestationGloas) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the AttestationGloas object with a hasher -func (a *AttestationGloas) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *AttestationGloas) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'AggregationBits' - if len(a.AggregationBits) == 0 { - err = ssz.ErrEmptyBitlist - return + // Field 0: AggregationBits + if len(c.AggregationBits) == 0 { + return ssz.ErrEmptyBitlist } - hh.PutBitlist(a.AggregationBits, 8192) - - // Field (1) 'Data' - if err = a.Data.HashTreeRootWith(hh); err != nil { - return + hh.PutBitlist(c.AggregationBits, 8192) + // Field 1: Data + if err := c.Data.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Data: %w", err) } - - // Field (2) 'Signature' - if size := len(a.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 2: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength } - hh.PutBytes(a.Signature) - - // Field (3) 'CommitteeBits' - if size := len(a.CommitteeBits); size != 1 { - err = ssz.ErrBytesLengthFn("--.CommitteeBits", size, 1) - return + hh.PutBytes(c.Signature) + // Field 3: CommitteeBits + if len([]byte(c.CommitteeBits)) != 1 { + return ssz.ErrBytesLength } - hh.PutBytes(a.CommitteeBits) - + hh.PutBytes([]byte(c.CommitteeBits)) hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the SignedAggregateAttestationAndProofGloas object -func (s *SignedAggregateAttestationAndProofGloas) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) +func (c *AggregateAttestationAndProofGloas) SizeSSZ() int { + size := 108 + if c.Aggregate == nil { + c.Aggregate = new(AttestationGloas) + } + size += c.Aggregate.SizeSSZ() + return size } -// MarshalSSZTo ssz marshals the SignedAggregateAttestationAndProofGloas object to a target array -func (s *SignedAggregateAttestationAndProofGloas) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(100) +func (c *AggregateAttestationAndProofGloas) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Offset (0) 'Message' - dst = ssz.WriteOffset(dst, offset) - if s.Message == nil { - s.Message = new(AggregateAttestationAndProofGloas) +func (c *AggregateAttestationAndProofGloas) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 108 + + // Field 0: AggregatorIndex + if dst, err = c.AggregatorIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("AggregatorIndex: %w", err) } - offset += s.Message.SizeSSZ() - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 1: Aggregate + if c.Aggregate == nil { + c.Aggregate = new(AttestationGloas) } - dst = append(dst, s.Signature...) + dst = ssz.WriteOffset(dst, offset) + offset += c.Aggregate.SizeSSZ() - // Field (0) 'Message' - if dst, err = s.Message.MarshalSSZTo(dst); err != nil { - return + // Field 2: SelectionProof + if len(c.SelectionProof) != 96 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.SelectionProof...) - return + // Field 1: Aggregate + if dst, err = c.Aggregate.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Aggregate: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the SignedAggregateAttestationAndProofGloas object -func (s *SignedAggregateAttestationAndProofGloas) UnmarshalSSZ(buf []byte) error { +func (c *AggregateAttestationAndProofGloas) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 100 { + if size < 108 { return ssz.ErrSize } - tail := buf - var o0 uint64 + sszSlice0 := buf[0:8] // c.AggregatorIndex + sszSlice2 := buf[12:108] // c.SelectionProof - // Offset (0) 'Message' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { + sszVarOffset1 := ssz.ReadOffset(buf[8:12]) // c.Aggregate + if sszVarOffset1 != 108 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset1 > size { return ssz.ErrOffset } + sszSlice1 := buf[sszVarOffset1:] // c.Aggregate - if o0 != 100 { - return ssz.ErrInvalidVariableOffset + // Field 0: AggregatorIndex + if err = c.AggregatorIndex.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("AggregatorIndex: %w", err) } - // Field (1) 'Signature' - if cap(s.Signature) == 0 { - s.Signature = make([]byte, 0, len(buf[4:100])) + // Field 1: Aggregate + c.Aggregate = new(AttestationGloas) + if err = c.Aggregate.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Aggregate: %w", err) } - s.Signature = append(s.Signature, buf[4:100]...) - // Field (0) 'Message' - { - buf = tail[o0:] - if s.Message == nil { - s.Message = new(AggregateAttestationAndProofGloas) - } - if err = s.Message.UnmarshalSSZ(buf); err != nil { - return err - } - } + // Field 2: SelectionProof + c.SelectionProof = make([]byte, 0, 96) + c.SelectionProof = append(c.SelectionProof, sszSlice2...) return err } -// SizeSSZ returns the ssz encoded size in bytes for the SignedAggregateAttestationAndProofGloas object -func (s *SignedAggregateAttestationAndProofGloas) SizeSSZ() (size int) { - size = 100 - - // Field (0) 'Message' - if s.Message == nil { - s.Message = new(AggregateAttestationAndProofGloas) +func (c *AggregateAttestationAndProofGloas) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - size += s.Message.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the SignedAggregateAttestationAndProofGloas object -func (s *SignedAggregateAttestationAndProofGloas) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the SignedAggregateAttestationAndProofGloas object with a hasher -func (s *SignedAggregateAttestationAndProofGloas) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *AggregateAttestationAndProofGloas) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Message' - if err = s.Message.HashTreeRootWith(hh); err != nil { - return + // Field 0: AggregatorIndex + if err := c.AggregatorIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("AggregatorIndex: %w", err) } - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 1: Aggregate + if err := c.Aggregate.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Aggregate: %w", err) } - hh.PutBytes(s.Signature) - + // Field 2: SelectionProof + if len(c.SelectionProof) != 96 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.SelectionProof) hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the AggregateAttestationAndProofGloas object -func (a *AggregateAttestationAndProofGloas) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(a) +func (c *SignedAggregateAttestationAndProofGloas) SizeSSZ() int { + size := 100 + if c.Message == nil { + c.Message = new(AggregateAttestationAndProofGloas) + } + size += c.Message.SizeSSZ() + return size } -// MarshalSSZTo ssz marshals the AggregateAttestationAndProofGloas object to a target array -func (a *AggregateAttestationAndProofGloas) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(108) +func (c *SignedAggregateAttestationAndProofGloas) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (0) 'AggregatorIndex' - dst = ssz.MarshalUint(dst, a.AggregatorIndex) +func (c *SignedAggregateAttestationAndProofGloas) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 100 - // Offset (1) 'Aggregate' - dst = ssz.WriteOffset(dst, offset) - if a.Aggregate == nil { - a.Aggregate = new(AttestationGloas) + // Field 0: Message + if c.Message == nil { + c.Message = new(AggregateAttestationAndProofGloas) } - offset += a.Aggregate.SizeSSZ() + dst = ssz.WriteOffset(dst, offset) + offset += c.Message.SizeSSZ() - // Field (2) 'SelectionProof' - if size := len(a.SelectionProof); size != 96 { - err = ssz.ErrBytesLengthFn("--.SelectionProof", size, 96) - return + // Field 1: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } - dst = append(dst, a.SelectionProof...) + dst = append(dst, c.Signature...) - // Field (1) 'Aggregate' - if dst, err = a.Aggregate.MarshalSSZTo(dst); err != nil { - return + // Field 0: Message + if dst, err = c.Message.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Message: %w", err) } - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the AggregateAttestationAndProofGloas object -func (a *AggregateAttestationAndProofGloas) UnmarshalSSZ(buf []byte) error { +func (c *SignedAggregateAttestationAndProofGloas) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 108 { + if size < 100 { return ssz.ErrSize } - tail := buf - var o1 uint64 - - // Field (0) 'AggregatorIndex' - a.AggregatorIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[0:8]) - - // Offset (1) 'Aggregate' - if o1 = ssz.ReadOffset(buf[8:12]); o1 > size { - return ssz.ErrOffset - } + sszSlice1 := buf[4:100] // c.Signature - if o1 != 108 { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Message + if sszVarOffset0 != 100 { return ssz.ErrInvalidVariableOffset } - - // Field (2) 'SelectionProof' - if cap(a.SelectionProof) == 0 { - a.SelectionProof = make([]byte, 0, len(buf[12:108])) + if sszVarOffset0 > size { + return ssz.ErrOffset } - a.SelectionProof = append(a.SelectionProof, buf[12:108]...) + sszSlice0 := buf[sszVarOffset0:] // c.Message - // Field (1) 'Aggregate' - { - buf = tail[o1:] - if a.Aggregate == nil { - a.Aggregate = new(AttestationGloas) - } - if err = a.Aggregate.UnmarshalSSZ(buf); err != nil { - return err - } + // Field 0: Message + c.Message = new(AggregateAttestationAndProofGloas) + if err = c.Message.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Message: %w", err) } + + // Field 1: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice1...) return err } -// SizeSSZ returns the ssz encoded size in bytes for the AggregateAttestationAndProofGloas object -func (a *AggregateAttestationAndProofGloas) SizeSSZ() (size int) { - size = 108 - - // Field (1) 'Aggregate' - if a.Aggregate == nil { - a.Aggregate = new(AttestationGloas) +func (c *SignedAggregateAttestationAndProofGloas) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - size += a.Aggregate.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the AggregateAttestationAndProofGloas object -func (a *AggregateAttestationAndProofGloas) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(a) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the AggregateAttestationAndProofGloas object with a hasher -func (a *AggregateAttestationAndProofGloas) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *SignedAggregateAttestationAndProofGloas) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'AggregatorIndex' - ssz.PutUint(hh, a.AggregatorIndex) - - // Field (1) 'Aggregate' - if err = a.Aggregate.HashTreeRootWith(hh); err != nil { - return + // Field 0: Message + if err := c.Message.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Message: %w", err) } - - // Field (2) 'SelectionProof' - if size := len(a.SelectionProof); size != 96 { - err = ssz.ErrBytesLengthFn("--.SelectionProof", size, 96) - return + // Field 1: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength } - hh.PutBytes(a.SelectionProof) - + hh.PutBytes(c.Signature) hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the AttesterSlashingGloas object -func (a *AttesterSlashingGloas) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(a) +func (c *AttesterSlashingGloas) SizeSSZ() int { + size := 8 + if c.Attestation_1 == nil { + c.Attestation_1 = new(IndexedAttestationGloas) + } + size += c.Attestation_1.SizeSSZ() + if c.Attestation_2 == nil { + c.Attestation_2 = new(IndexedAttestationGloas) + } + size += c.Attestation_2.SizeSSZ() + return size } -// MarshalSSZTo ssz marshals the AttesterSlashingGloas object to a target array -func (a *AttesterSlashingGloas) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(8) +func (c *AttesterSlashingGloas) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Offset (0) 'Attestation_1' - dst = ssz.WriteOffset(dst, offset) - if a.Attestation_1 == nil { - a.Attestation_1 = new(IndexedAttestationGloas) - } - offset += a.Attestation_1.SizeSSZ() +func (c *AttesterSlashingGloas) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 8 - // Offset (1) 'Attestation_2' - dst = ssz.WriteOffset(dst, offset) - if a.Attestation_2 == nil { - a.Attestation_2 = new(IndexedAttestationGloas) + // Field 0: Attestation_1 + if c.Attestation_1 == nil { + c.Attestation_1 = new(IndexedAttestationGloas) } - offset += a.Attestation_2.SizeSSZ() + dst = ssz.WriteOffset(dst, offset) + offset += c.Attestation_1.SizeSSZ() - // Field (0) 'Attestation_1' - if dst, err = a.Attestation_1.MarshalSSZTo(dst); err != nil { - return + // Field 1: Attestation_2 + if c.Attestation_2 == nil { + c.Attestation_2 = new(IndexedAttestationGloas) } + dst = ssz.WriteOffset(dst, offset) + offset += c.Attestation_2.SizeSSZ() - // Field (1) 'Attestation_2' - if dst, err = a.Attestation_2.MarshalSSZTo(dst); err != nil { - return + // Field 0: Attestation_1 + if dst, err = c.Attestation_1.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Attestation_1: %w", err) } - return + // Field 1: Attestation_2 + if dst, err = c.Attestation_2.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Attestation_2: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the AttesterSlashingGloas object -func (a *AttesterSlashingGloas) UnmarshalSSZ(buf []byte) error { +func (c *AttesterSlashingGloas) 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) 'Attestation_1' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } - - if o0 != 8 { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Attestation_1 + if sszVarOffset0 != 8 { return ssz.ErrInvalidVariableOffset } - - // Offset (1) 'Attestation_2' - if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 { + if sszVarOffset0 > size { + return ssz.ErrOffset + } + sszVarOffset1 := ssz.ReadOffset(buf[4:8]) // c.Attestation_2 + if sszVarOffset1 > size || sszVarOffset1 < sszVarOffset0 { return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:sszVarOffset1] // c.Attestation_1 + sszSlice1 := buf[sszVarOffset1:] // c.Attestation_2 - // Field (0) 'Attestation_1' - { - buf = tail[o0:o1] - if a.Attestation_1 == nil { - a.Attestation_1 = new(IndexedAttestationGloas) - } - if err = a.Attestation_1.UnmarshalSSZ(buf); err != nil { - return err - } + // Field 0: Attestation_1 + c.Attestation_1 = new(IndexedAttestationGloas) + if err = c.Attestation_1.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Attestation_1: %w", err) } - // Field (1) 'Attestation_2' - { - buf = tail[o1:] - if a.Attestation_2 == nil { - a.Attestation_2 = new(IndexedAttestationGloas) - } - if err = a.Attestation_2.UnmarshalSSZ(buf); err != nil { - return err - } + // Field 1: Attestation_2 + c.Attestation_2 = new(IndexedAttestationGloas) + if err = c.Attestation_2.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Attestation_2: %w", err) } return err } -// SizeSSZ returns the ssz encoded size in bytes for the AttesterSlashingGloas object -func (a *AttesterSlashingGloas) SizeSSZ() (size int) { - size = 8 - - // Field (0) 'Attestation_1' - if a.Attestation_1 == nil { - a.Attestation_1 = new(IndexedAttestationGloas) - } - size += a.Attestation_1.SizeSSZ() - - // Field (1) 'Attestation_2' - if a.Attestation_2 == nil { - a.Attestation_2 = new(IndexedAttestationGloas) +func (c *AttesterSlashingGloas) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - size += a.Attestation_2.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the AttesterSlashingGloas object -func (a *AttesterSlashingGloas) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(a) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the AttesterSlashingGloas object with a hasher -func (a *AttesterSlashingGloas) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *AttesterSlashingGloas) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Attestation_1' - if err = a.Attestation_1.HashTreeRootWith(hh); err != nil { - return + // Field 0: Attestation_1 + if err := c.Attestation_1.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Attestation_1: %w", err) } - - // Field (1) 'Attestation_2' - if err = a.Attestation_2.HashTreeRootWith(hh); err != nil { - return + // Field 1: Attestation_2 + if err := c.Attestation_2.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Attestation_2: %w", err) } - hh.Merkleize(indx) - return + return nil +} + +func (c *BeaconBlockBodyGloas) SizeSSZ() int { + size := 336 + size += len(c.ProposerSlashings) * 416 + for _, o := range c.AttesterSlashings { + size += 4 + size += o.SizeSSZ() + } + for _, o := range c.Attestations { + size += 4 + size += o.SizeSSZ() + } + size += len(c.Deposits) * 1240 + size += len(c.VoluntaryExits) * 112 + size += len(c.BlsToExecutionChanges) * 172 + if c.SignedExecutionPayloadBid == nil { + c.SignedExecutionPayloadBid = new(SignedExecutionPayloadBid) + } + size += c.SignedExecutionPayloadBid.SizeSSZ() + size += len(c.PayloadAttestations) * 140 + if c.ParentExecutionRequests == nil { + c.ParentExecutionRequests = new(v1.ExecutionRequestsGloas) + } + size += c.ParentExecutionRequests.SizeSSZ() + return size } -// MarshalSSZ ssz marshals the IndexedAttestationGloas object -func (i *IndexedAttestationGloas) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(i) +func (c *BeaconBlockBodyGloas) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the IndexedAttestationGloas object to a target array -func (i *IndexedAttestationGloas) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(228) +func (c *BeaconBlockBodyGloas) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 336 - // Offset (0) 'AttestingIndices' - dst = ssz.WriteOffset(dst, offset) - offset += len(i.AttestingIndices) * 8 + // Field 0: RandaoReveal + if len(c.RandaoReveal) != 96 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.RandaoReveal...) - // Field (1) 'Data' - if i.Data == nil { - i.Data = new(AttestationData) + // Field 1: Eth1Data + if c.Eth1Data == nil { + c.Eth1Data = new(Eth1Data) } - if dst, err = i.Data.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.Eth1Data.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Eth1Data: %w", err) } - // Field (2) 'Signature' - if size := len(i.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 2: Graffiti + if len(c.Graffiti) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, i.Signature...) + dst = append(dst, c.Graffiti...) + + // Field 3: ProposerSlashings + dst = ssz.WriteOffset(dst, offset) + offset += len(c.ProposerSlashings) * 416 - // Field (0) 'AttestingIndices' - if size := len(i.AttestingIndices); size > 8192 { - err = ssz.ErrListTooBigFn("--.AttestingIndices", size, 8192) - return + // Field 4: AttesterSlashings + dst = ssz.WriteOffset(dst, offset) + for _, o := range c.AttesterSlashings { + offset += 4 + offset += o.SizeSSZ() } - for ii := 0; ii < len(i.AttestingIndices); ii++ { - dst = ssz.MarshalUint(dst, i.AttestingIndices[ii]) + + // Field 5: Attestations + dst = ssz.WriteOffset(dst, offset) + for _, o := range c.Attestations { + offset += 4 + offset += o.SizeSSZ() } - return -} + // Field 6: Deposits + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Deposits) * 1240 -// UnmarshalSSZ ssz unmarshals the IndexedAttestationGloas object -func (i *IndexedAttestationGloas) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 228 { - return ssz.ErrSize + // Field 7: VoluntaryExits + dst = ssz.WriteOffset(dst, offset) + offset += len(c.VoluntaryExits) * 112 + + // Field 8: SyncAggregate + if c.SyncAggregate == nil { + c.SyncAggregate = new(SyncAggregate) + } + if dst, err = c.SyncAggregate.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SyncAggregate: %w", err) } - tail := buf - var o0 uint64 + // Field 9: BlsToExecutionChanges + dst = ssz.WriteOffset(dst, offset) + offset += len(c.BlsToExecutionChanges) * 172 - // Offset (0) 'AttestingIndices' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset + // Field 10: SignedExecutionPayloadBid + if c.SignedExecutionPayloadBid == nil { + c.SignedExecutionPayloadBid = new(SignedExecutionPayloadBid) } + dst = ssz.WriteOffset(dst, offset) + offset += c.SignedExecutionPayloadBid.SizeSSZ() - if o0 != 228 { - return ssz.ErrInvalidVariableOffset + // Field 11: PayloadAttestations + dst = ssz.WriteOffset(dst, offset) + offset += len(c.PayloadAttestations) * 140 + + // Field 12: ParentExecutionRequests + if c.ParentExecutionRequests == nil { + c.ParentExecutionRequests = new(v1.ExecutionRequestsGloas) } + dst = ssz.WriteOffset(dst, offset) + offset += c.ParentExecutionRequests.SizeSSZ() - // Field (1) 'Data' - if i.Data == nil { - i.Data = new(AttestationData) + // Field 3: ProposerSlashings + if len(c.ProposerSlashings) > 16 { + return nil, ssz.ErrListTooBig } - if err = i.Data.UnmarshalSSZ(buf[4:132]); err != nil { - return err + for _, o := range c.ProposerSlashings { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ProposerSlashings: %w", err) + } } - // Field (2) 'Signature' - if cap(i.Signature) == 0 { - i.Signature = make([]byte, 0, len(buf[132:228])) + // Field 4: AttesterSlashings + if len(c.AttesterSlashings) > 1 { + return nil, ssz.ErrListTooBig } - i.Signature = append(i.Signature, buf[132:228]...) - - // Field (0) 'AttestingIndices' { - buf = tail[o0:] - num, err := ssz.DivideInt2(len(buf), 8, 8192) - if err != nil { - return err + offset = 4 * len(c.AttesterSlashings) + for _, o := range c.AttesterSlashings { + dst = ssz.WriteOffset(dst, offset) + offset += o.SizeSSZ() } - i.AttestingIndices = ssz.ExtendUint(i.AttestingIndices, num) - for ii := 0; ii < num; ii++ { - i.AttestingIndices[ii] = ssz.UnmarshallUint[uint64](buf[ii*8 : (ii+1)*8]) + } + for _, o := range c.AttesterSlashings { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("AttesterSlashings: %w", err) } } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the IndexedAttestationGloas object -func (i *IndexedAttestationGloas) SizeSSZ() (size int) { - size = 228 - - // Field (0) 'AttestingIndices' - size += len(i.AttestingIndices) * 8 - - return -} - -// HashTreeRoot ssz hashes the IndexedAttestationGloas object -func (i *IndexedAttestationGloas) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(i) -} - -// HashTreeRootWith ssz hashes the IndexedAttestationGloas object with a hasher -func (i *IndexedAttestationGloas) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - // Field (0) 'AttestingIndices' + // Field 5: Attestations + if len(c.Attestations) > 8 { + return nil, ssz.ErrListTooBig + } { - if size := len(i.AttestingIndices); size > 8192 { - err = ssz.ErrListTooBigFn("--.AttestingIndices", size, 8192) - return - } - subIndx := hh.Index() - for _, i := range i.AttestingIndices { - ssz.AppendUint(hh, i) + offset = 4 * len(c.Attestations) + for _, o := range c.Attestations { + dst = ssz.WriteOffset(dst, offset) + offset += o.SizeSSZ() } - hh.FillUpTo32() - - numItems := uint64(len(i.AttestingIndices)) - hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(8192, numItems, 8)) } - - // Field (1) 'Data' - if err = i.Data.HashTreeRootWith(hh); err != nil { - return + for _, o := range c.Attestations { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Attestations: %w", err) + } } - // Field (2) 'Signature' - if size := len(i.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 6: Deposits + if len(c.Deposits) > 16 { + return nil, ssz.ErrListTooBig } - hh.PutBytes(i.Signature) - - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the ExecutionPayloadBid object -func (e *ExecutionPayloadBid) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(e) -} - -// MarshalSSZTo ssz marshals the ExecutionPayloadBid object to a target array -func (e *ExecutionPayloadBid) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(224) - - // Field (0) 'ParentBlockHash' - if size := len(e.ParentBlockHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentBlockHash", size, 32) - return + for _, o := range c.Deposits { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Deposits: %w", err) + } } - dst = append(dst, e.ParentBlockHash...) - // Field (1) 'ParentBlockRoot' - if size := len(e.ParentBlockRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentBlockRoot", size, 32) - return + // Field 7: VoluntaryExits + if len(c.VoluntaryExits) > 16 { + return nil, ssz.ErrListTooBig } - dst = append(dst, e.ParentBlockRoot...) - - // Field (2) 'BlockHash' - if size := len(e.BlockHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockHash", size, 32) - return + for _, o := range c.VoluntaryExits { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("VoluntaryExits: %w", err) + } } - dst = append(dst, e.BlockHash...) - // Field (3) 'PrevRandao' - if size := len(e.PrevRandao); size != 32 { - err = ssz.ErrBytesLengthFn("--.PrevRandao", size, 32) - return + // Field 9: BlsToExecutionChanges + if len(c.BlsToExecutionChanges) > 16 { + return nil, ssz.ErrListTooBig } - dst = append(dst, e.PrevRandao...) - - // Field (4) 'FeeRecipient' - if size := len(e.FeeRecipient); size != 20 { - err = ssz.ErrBytesLengthFn("--.FeeRecipient", size, 20) - return + for _, o := range c.BlsToExecutionChanges { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("BlsToExecutionChanges: %w", err) + } } - dst = append(dst, e.FeeRecipient...) - // Field (5) 'GasLimit' - dst = ssz.MarshalUint(dst, e.GasLimit) - - // Field (6) 'BuilderIndex' - dst = ssz.MarshalUint(dst, e.BuilderIndex) - - // Field (7) 'Slot' - dst = ssz.MarshalUint(dst, e.Slot) - - // Field (8) 'Value' - dst = ssz.MarshalUint(dst, e.Value) - - // Field (9) 'ExecutionPayment' - dst = ssz.MarshalUint(dst, e.ExecutionPayment) - - // Offset (10) 'BlobKzgCommitments' - dst = ssz.WriteOffset(dst, offset) - offset += len(e.BlobKzgCommitments) * 48 - - // Field (11) 'ExecutionRequestsRoot' - if size := len(e.ExecutionRequestsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ExecutionRequestsRoot", size, 32) - return + // Field 10: SignedExecutionPayloadBid + if dst, err = c.SignedExecutionPayloadBid.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SignedExecutionPayloadBid: %w", err) } - dst = append(dst, e.ExecutionRequestsRoot...) - // Field (10) 'BlobKzgCommitments' - if size := len(e.BlobKzgCommitments); size > 4096 { - err = ssz.ErrListTooBigFn("--.BlobKzgCommitments", size, 4096) - return + // Field 11: PayloadAttestations + if len(c.PayloadAttestations) > 4 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(e.BlobKzgCommitments); ii++ { - if size := len(e.BlobKzgCommitments[ii]); size != 48 { - err = ssz.ErrBytesLengthFn("--.BlobKzgCommitments[ii]", size, 48) - return + for _, o := range c.PayloadAttestations { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("PayloadAttestations: %w", err) } - dst = append(dst, e.BlobKzgCommitments[ii]...) } - return + // Field 12: ParentExecutionRequests + if dst, err = c.ParentExecutionRequests.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ParentExecutionRequests: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the ExecutionPayloadBid object -func (e *ExecutionPayloadBid) UnmarshalSSZ(buf []byte) error { +func (c *BeaconBlockBodyGloas) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 224 { + if size < 336 { return ssz.ErrSize } - tail := buf - var o10 uint64 + sszSlice0 := buf[0:96] // c.RandaoReveal + sszSlice1 := buf[96:168] // c.Eth1Data + sszSlice2 := buf[168:200] // c.Graffiti + sszSlice8 := buf[220:320] // c.SyncAggregate - // Field (0) 'ParentBlockHash' - if cap(e.ParentBlockHash) == 0 { - e.ParentBlockHash = make([]byte, 0, len(buf[0:32])) + sszVarOffset3 := ssz.ReadOffset(buf[200:204]) // c.ProposerSlashings + if sszVarOffset3 != 336 { + return ssz.ErrInvalidVariableOffset } - e.ParentBlockHash = append(e.ParentBlockHash, buf[0:32]...) - - // Field (1) 'ParentBlockRoot' - if cap(e.ParentBlockRoot) == 0 { - e.ParentBlockRoot = make([]byte, 0, len(buf[32:64])) + if sszVarOffset3 > size { + return ssz.ErrOffset } - e.ParentBlockRoot = append(e.ParentBlockRoot, buf[32:64]...) - - // Field (2) 'BlockHash' - if cap(e.BlockHash) == 0 { - e.BlockHash = make([]byte, 0, len(buf[64:96])) + sszVarOffset4 := ssz.ReadOffset(buf[204:208]) // c.AttesterSlashings + if sszVarOffset4 > size || sszVarOffset4 < sszVarOffset3 { + return ssz.ErrOffset } - e.BlockHash = append(e.BlockHash, buf[64:96]...) - - // Field (3) 'PrevRandao' - if cap(e.PrevRandao) == 0 { - e.PrevRandao = make([]byte, 0, len(buf[96:128])) + sszVarOffset5 := ssz.ReadOffset(buf[208:212]) // c.Attestations + if sszVarOffset5 > size || sszVarOffset5 < sszVarOffset4 { + return ssz.ErrOffset } - e.PrevRandao = append(e.PrevRandao, buf[96:128]...) - - // Field (4) 'FeeRecipient' - if cap(e.FeeRecipient) == 0 { - e.FeeRecipient = make([]byte, 0, len(buf[128:148])) + sszVarOffset6 := ssz.ReadOffset(buf[212:216]) // c.Deposits + if sszVarOffset6 > size || sszVarOffset6 < sszVarOffset5 { + return ssz.ErrOffset } - e.FeeRecipient = append(e.FeeRecipient, buf[128:148]...) - - // Field (5) 'GasLimit' - e.GasLimit = ssz.UnmarshallUint[uint64](buf[148:156]) - - // Field (6) 'BuilderIndex' - e.BuilderIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.BuilderIndex](buf[156:164]) - - // Field (7) 'Slot' - e.Slot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[164:172]) - - // Field (8) 'Value' - e.Value = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Gwei](buf[172:180]) - - // Field (9) 'ExecutionPayment' - e.ExecutionPayment = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Gwei](buf[180:188]) - - // Offset (10) 'BlobKzgCommitments' - if o10 = ssz.ReadOffset(buf[188:192]); o10 > size { + sszVarOffset7 := ssz.ReadOffset(buf[216:220]) // c.VoluntaryExits + if sszVarOffset7 > size || sszVarOffset7 < sszVarOffset6 { return ssz.ErrOffset } - - if o10 != 224 { - return ssz.ErrInvalidVariableOffset + sszVarOffset9 := ssz.ReadOffset(buf[320:324]) // c.BlsToExecutionChanges + if sszVarOffset9 > size || sszVarOffset9 < sszVarOffset7 { + return ssz.ErrOffset + } + sszVarOffset10 := ssz.ReadOffset(buf[324:328]) // c.SignedExecutionPayloadBid + if sszVarOffset10 > size || sszVarOffset10 < sszVarOffset9 { + return ssz.ErrOffset + } + sszVarOffset11 := ssz.ReadOffset(buf[328:332]) // c.PayloadAttestations + if sszVarOffset11 > size || sszVarOffset11 < sszVarOffset10 { + return ssz.ErrOffset } + sszVarOffset12 := ssz.ReadOffset(buf[332:336]) // c.ParentExecutionRequests + if sszVarOffset12 > size || sszVarOffset12 < sszVarOffset11 { + return ssz.ErrOffset + } + sszSlice3 := buf[sszVarOffset3:sszVarOffset4] // c.ProposerSlashings + sszSlice4 := buf[sszVarOffset4:sszVarOffset5] // c.AttesterSlashings + sszSlice5 := buf[sszVarOffset5:sszVarOffset6] // c.Attestations + sszSlice6 := buf[sszVarOffset6:sszVarOffset7] // c.Deposits + sszSlice7 := buf[sszVarOffset7:sszVarOffset9] // c.VoluntaryExits + sszSlice9 := buf[sszVarOffset9:sszVarOffset10] // c.BlsToExecutionChanges + sszSlice10 := buf[sszVarOffset10:sszVarOffset11] // c.SignedExecutionPayloadBid + sszSlice11 := buf[sszVarOffset11:sszVarOffset12] // c.PayloadAttestations + sszSlice12 := buf[sszVarOffset12:] // c.ParentExecutionRequests - // Field (11) 'ExecutionRequestsRoot' - if cap(e.ExecutionRequestsRoot) == 0 { - e.ExecutionRequestsRoot = make([]byte, 0, len(buf[192:224])) + // Field 0: RandaoReveal + c.RandaoReveal = make([]byte, 0, 96) + c.RandaoReveal = append(c.RandaoReveal, sszSlice0...) + + // Field 1: Eth1Data + c.Eth1Data = new(Eth1Data) + if err = c.Eth1Data.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Eth1Data: %w", err) } - e.ExecutionRequestsRoot = append(e.ExecutionRequestsRoot, buf[192:224]...) - // Field (10) 'BlobKzgCommitments' + // Field 2: Graffiti + c.Graffiti = make([]byte, 0, 32) + c.Graffiti = append(c.Graffiti, sszSlice2...) + + // Field 3: ProposerSlashings { - buf = tail[o10:] - num, err := ssz.DivideInt2(len(buf), 48, 4096) - if err != nil { - return err - } - e.BlobKzgCommitments = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(e.BlobKzgCommitments[ii]) == 0 { - e.BlobKzgCommitments[ii] = make([]byte, 0, len(buf[ii*48:(ii+1)*48])) + if len(sszSlice3)%416 != 0 { + return fmt.Errorf("misaligned bytes: c.ProposerSlashings length is %d, which is not a multiple of 416: %w", len(sszSlice3), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice3) / 416 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.ProposerSlashings has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.ProposerSlashings = make([]*ProposerSlashing, numElem) + for i := 0; i < numElem; i++ { + var tmp *ProposerSlashing + tmp = new(ProposerSlashing) + tmpSlice := sszSlice3[i*416 : (1+i)*416] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("ProposerSlashings: %w", err) } - e.BlobKzgCommitments[ii] = append(e.BlobKzgCommitments[ii], buf[ii*48:(ii+1)*48]...) + c.ProposerSlashings[i] = tmp } } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the ExecutionPayloadBid object -func (e *ExecutionPayloadBid) SizeSSZ() (size int) { - size = 224 - - // Field (10) 'BlobKzgCommitments' - size += len(e.BlobKzgCommitments) * 48 - return -} - -// HashTreeRoot ssz hashes the ExecutionPayloadBid object -func (e *ExecutionPayloadBid) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(e) -} - -// HashTreeRootWith ssz hashes the ExecutionPayloadBid object with a hasher -func (e *ExecutionPayloadBid) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'ParentBlockHash' - if size := len(e.ParentBlockHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentBlockHash", size, 32) - return + // Field 4: AttesterSlashings + { + // empty lists are zero length, so make sure there is room for an offset + // before attempting to unmarshal it + if len(sszSlice4) > 3 { + startOffset := ssz.ReadOffset(sszSlice4[0:4]) + if startOffset == 0 { + return fmt.Errorf("encountered invalid offset of 0 when decoding c.AttesterSlashings") + } + if startOffset%4 != 0 { + return fmt.Errorf("misaligned list bytes: when decoding c.AttesterSlashings, end-of-list offset is %d, which is not a multiple of 4 (offset size)", startOffset) + } + listLen := startOffset / 4 + if listLen > 1 { + return fmt.Errorf("ssz-max exceeded: c.AttesterSlashings has %d elements, ssz-max is 1: %w", listLen, ssz.ErrListTooBig) + } + totalVarBytes := uint64(len(sszSlice4)) + if totalVarBytes < startOffset { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.AttesterSlashings") + } + c.AttesterSlashings = make([]*AttesterSlashingGloas, listLen) + var tmpSlice []byte + for i := uint64(0); i < listLen; i++ { + var tmp *AttesterSlashingGloas + tmp = new(AttesterSlashingGloas) + endOffset := totalVarBytes + if i+1 != listLen { + endOffset = ssz.ReadOffset(sszSlice4[(i+1)*4 : (i+2)*4]) + if totalVarBytes < endOffset { + return fmt.Errorf("offset %d points past the end of buffer when decoding c.AttesterSlashings", endOffset) + } + } + if endOffset < startOffset { + return fmt.Errorf("offset %d is not greater than start offset %d when decoding c.AttesterSlashings", endOffset, startOffset) + } + tmpSlice = sszSlice4[startOffset:endOffset] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("AttesterSlashings: %w", err) + } + c.AttesterSlashings[i] = tmp + startOffset = endOffset + } + } else { + if len(sszSlice4) > 0 { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.AttesterSlashings") + } + c.AttesterSlashings = make([]*AttesterSlashingGloas, 0) + } } - hh.PutBytes(e.ParentBlockHash) - // Field (1) 'ParentBlockRoot' - if size := len(e.ParentBlockRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentBlockRoot", size, 32) - return + // Field 5: Attestations + { + // empty lists are zero length, so make sure there is room for an offset + // before attempting to unmarshal it + if len(sszSlice5) > 3 { + startOffset := ssz.ReadOffset(sszSlice5[0:4]) + if startOffset == 0 { + return fmt.Errorf("encountered invalid offset of 0 when decoding c.Attestations") + } + if startOffset%4 != 0 { + return fmt.Errorf("misaligned list bytes: when decoding c.Attestations, end-of-list offset is %d, which is not a multiple of 4 (offset size)", startOffset) + } + listLen := startOffset / 4 + if listLen > 8 { + return fmt.Errorf("ssz-max exceeded: c.Attestations has %d elements, ssz-max is 8: %w", listLen, ssz.ErrListTooBig) + } + totalVarBytes := uint64(len(sszSlice5)) + if totalVarBytes < startOffset { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.Attestations") + } + c.Attestations = make([]*AttestationGloas, listLen) + var tmpSlice []byte + for i := uint64(0); i < listLen; i++ { + var tmp *AttestationGloas + tmp = new(AttestationGloas) + endOffset := totalVarBytes + if i+1 != listLen { + endOffset = ssz.ReadOffset(sszSlice5[(i+1)*4 : (i+2)*4]) + if totalVarBytes < endOffset { + return fmt.Errorf("offset %d points past the end of buffer when decoding c.Attestations", endOffset) + } + } + if endOffset < startOffset { + return fmt.Errorf("offset %d is not greater than start offset %d when decoding c.Attestations", endOffset, startOffset) + } + tmpSlice = sszSlice5[startOffset:endOffset] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Attestations: %w", err) + } + c.Attestations[i] = tmp + startOffset = endOffset + } + } else { + if len(sszSlice5) > 0 { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.Attestations") + } + c.Attestations = make([]*AttestationGloas, 0) + } } - hh.PutBytes(e.ParentBlockRoot) - // Field (2) 'BlockHash' - if size := len(e.BlockHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockHash", size, 32) - return + // Field 6: Deposits + { + if len(sszSlice6)%1240 != 0 { + return fmt.Errorf("misaligned bytes: c.Deposits length is %d, which is not a multiple of 1240: %w", len(sszSlice6), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice6) / 1240 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.Deposits has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.Deposits = make([]*Deposit, numElem) + for i := 0; i < numElem; i++ { + var tmp *Deposit + tmp = new(Deposit) + tmpSlice := sszSlice6[i*1240 : (1+i)*1240] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Deposits: %w", err) + } + c.Deposits[i] = tmp + } } - hh.PutBytes(e.BlockHash) - // Field (3) 'PrevRandao' - if size := len(e.PrevRandao); size != 32 { - err = ssz.ErrBytesLengthFn("--.PrevRandao", size, 32) - return + // Field 7: VoluntaryExits + { + if len(sszSlice7)%112 != 0 { + return fmt.Errorf("misaligned bytes: c.VoluntaryExits length is %d, which is not a multiple of 112: %w", len(sszSlice7), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice7) / 112 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.VoluntaryExits has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.VoluntaryExits = make([]*SignedVoluntaryExit, numElem) + for i := 0; i < numElem; i++ { + var tmp *SignedVoluntaryExit + tmp = new(SignedVoluntaryExit) + tmpSlice := sszSlice7[i*112 : (1+i)*112] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("VoluntaryExits: %w", err) + } + c.VoluntaryExits[i] = tmp + } } - hh.PutBytes(e.PrevRandao) - // Field (4) 'FeeRecipient' - if size := len(e.FeeRecipient); size != 20 { - err = ssz.ErrBytesLengthFn("--.FeeRecipient", size, 20) - return + // Field 8: SyncAggregate + c.SyncAggregate = new(SyncAggregate) + if err = c.SyncAggregate.UnmarshalSSZ(sszSlice8); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) } - hh.PutBytes(e.FeeRecipient) - - // Field (5) 'GasLimit' - ssz.PutUint(hh, e.GasLimit) - - // Field (6) 'BuilderIndex' - ssz.PutUint(hh, e.BuilderIndex) - - // Field (7) 'Slot' - ssz.PutUint(hh, e.Slot) - - // Field (8) 'Value' - ssz.PutUint(hh, e.Value) - // Field (9) 'ExecutionPayment' - ssz.PutUint(hh, e.ExecutionPayment) - - // Field (10) 'BlobKzgCommitments' + // Field 9: BlsToExecutionChanges { - if size := len(e.BlobKzgCommitments); size > 4096 { - err = ssz.ErrListTooBigFn("--.BlobKzgCommitments", size, 4096) - return - } - subIndx := hh.Index() - for _, i := range e.BlobKzgCommitments { - if len(i) != 48 { - err = ssz.ErrBytesLength - return + if len(sszSlice9)%172 != 0 { + return fmt.Errorf("misaligned bytes: c.BlsToExecutionChanges length is %d, which is not a multiple of 172: %w", len(sszSlice9), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice9) / 172 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.BlsToExecutionChanges has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.BlsToExecutionChanges = make([]*SignedBLSToExecutionChange, numElem) + for i := 0; i < numElem; i++ { + var tmp *SignedBLSToExecutionChange + tmp = new(SignedBLSToExecutionChange) + tmpSlice := sszSlice9[i*172 : (1+i)*172] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("BlsToExecutionChanges: %w", err) } - hh.PutBytes(i) + c.BlsToExecutionChanges[i] = tmp } + } - numItems := uint64(len(e.BlobKzgCommitments)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) + // Field 10: SignedExecutionPayloadBid + c.SignedExecutionPayloadBid = new(SignedExecutionPayloadBid) + if err = c.SignedExecutionPayloadBid.UnmarshalSSZ(sszSlice10); err != nil { + return fmt.Errorf("SignedExecutionPayloadBid: %w", err) } - // Field (11) 'ExecutionRequestsRoot' - if size := len(e.ExecutionRequestsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ExecutionRequestsRoot", size, 32) - return + // Field 11: PayloadAttestations + { + if len(sszSlice11)%140 != 0 { + return fmt.Errorf("misaligned bytes: c.PayloadAttestations length is %d, which is not a multiple of 140: %w", len(sszSlice11), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice11) / 140 + if numElem > 4 { + return fmt.Errorf("ssz-max exceeded: c.PayloadAttestations has %d elements, ssz-max is 4: %w", numElem, ssz.ErrListTooBig) + } + c.PayloadAttestations = make([]*PayloadAttestation, numElem) + for i := 0; i < numElem; i++ { + var tmp *PayloadAttestation + tmp = new(PayloadAttestation) + tmpSlice := sszSlice11[i*140 : (1+i)*140] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("PayloadAttestations: %w", err) + } + c.PayloadAttestations[i] = tmp + } } - hh.PutBytes(e.ExecutionRequestsRoot) - hh.Merkleize(indx) - return + // Field 12: ParentExecutionRequests + c.ParentExecutionRequests = new(v1.ExecutionRequestsGloas) + if err = c.ParentExecutionRequests.UnmarshalSSZ(sszSlice12); err != nil { + return fmt.Errorf("ParentExecutionRequests: %w", err) + } + return err } -// MarshalSSZ ssz marshals the SignedExecutionPayloadBid object -func (s *SignedExecutionPayloadBid) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) +func (c *BeaconBlockBodyGloas) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// MarshalSSZTo ssz marshals the SignedExecutionPayloadBid object to a target array -func (s *SignedExecutionPayloadBid) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(100) - - // Offset (0) 'Message' - dst = ssz.WriteOffset(dst, offset) - if s.Message == nil { - s.Message = new(ExecutionPayloadBid) +func (c *BeaconBlockBodyGloas) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: RandaoReveal + if len(c.RandaoReveal) != 96 { + return ssz.ErrBytesLength } - offset += s.Message.SizeSSZ() - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + hh.PutBytes(c.RandaoReveal) + // Field 1: Eth1Data + if err := c.Eth1Data.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Eth1Data: %w", err) } - dst = append(dst, s.Signature...) - - // Field (0) 'Message' - if dst, err = s.Message.MarshalSSZTo(dst); err != nil { - return + // Field 2: Graffiti + if len(c.Graffiti) != 32 { + return ssz.ErrBytesLength } - - return -} - -// UnmarshalSSZ ssz unmarshals the SignedExecutionPayloadBid object -func (s *SignedExecutionPayloadBid) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 100 { - return ssz.ErrSize + hh.PutBytes(c.Graffiti) + // Field 3: ProposerSlashings + { + if len(c.ProposerSlashings) > 16 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.ProposerSlashings { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ProposerSlashings: %w", err) + } + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.ProposerSlashings)), 16) } - - tail := buf - var o0 uint64 - - // Offset (0) 'Message' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset + // Field 4: AttesterSlashings + { + if len(c.AttesterSlashings) > 1 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.AttesterSlashings { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("AttesterSlashings: %w", err) + } + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.AttesterSlashings)), 1) } - - if o0 != 100 { - return ssz.ErrInvalidVariableOffset + // Field 5: Attestations + { + if len(c.Attestations) > 8 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.Attestations { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Attestations: %w", err) + } + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Attestations)), 8) } - - // Field (1) 'Signature' - if cap(s.Signature) == 0 { - s.Signature = make([]byte, 0, len(buf[4:100])) + // Field 6: Deposits + { + if len(c.Deposits) > 16 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.Deposits { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Deposits: %w", err) + } + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Deposits)), 16) } - s.Signature = append(s.Signature, buf[4:100]...) - - // Field (0) 'Message' + // Field 7: VoluntaryExits { - buf = tail[o0:] - if s.Message == nil { - s.Message = new(ExecutionPayloadBid) + if len(c.VoluntaryExits) > 16 { + return ssz.ErrListTooBig } - if err = s.Message.UnmarshalSSZ(buf); err != nil { - return err + subIndx := hh.Index() + for _, o := range c.VoluntaryExits { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("VoluntaryExits: %w", err) + } } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.VoluntaryExits)), 16) } - return err + // Field 8: SyncAggregate + if err := c.SyncAggregate.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) + } + // Field 9: BlsToExecutionChanges + { + if len(c.BlsToExecutionChanges) > 16 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.BlsToExecutionChanges { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("BlsToExecutionChanges: %w", err) + } + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.BlsToExecutionChanges)), 16) + } + // Field 10: SignedExecutionPayloadBid + if err := c.SignedExecutionPayloadBid.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SignedExecutionPayloadBid: %w", err) + } + // Field 11: PayloadAttestations + { + if len(c.PayloadAttestations) > 4 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.PayloadAttestations { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("PayloadAttestations: %w", err) + } + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.PayloadAttestations)), 4) + } + // Field 12: ParentExecutionRequests + if err := c.ParentExecutionRequests.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ParentExecutionRequests: %w", err) + } + hh.Merkleize(indx) + return nil } -// SizeSSZ returns the ssz encoded size in bytes for the SignedExecutionPayloadBid object -func (s *SignedExecutionPayloadBid) SizeSSZ() (size int) { - size = 100 - - // Field (0) 'Message' - if s.Message == nil { - s.Message = new(ExecutionPayloadBid) +func (c *BeaconBlockContentsGloas) SizeSSZ() int { + size := 16 + if c.Block == nil { + c.Block = new(BeaconBlockGloas) } - size += s.Message.SizeSSZ() - - return + size += c.Block.SizeSSZ() + if c.ExecutionPayloadEnvelope == nil { + c.ExecutionPayloadEnvelope = new(ExecutionPayloadEnvelope) + } + size += c.ExecutionPayloadEnvelope.SizeSSZ() + size += len(c.KzgProofs) * 48 + size += len(c.Blobs) * 131072 + return size } -// HashTreeRoot ssz hashes the SignedExecutionPayloadBid object -func (s *SignedExecutionPayloadBid) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) +func (c *BeaconBlockContentsGloas) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// HashTreeRootWith ssz hashes the SignedExecutionPayloadBid object with a hasher -func (s *SignedExecutionPayloadBid) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() +func (c *BeaconBlockContentsGloas) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 16 - // Field (0) 'Message' - if err = s.Message.HashTreeRootWith(hh); err != nil { - return + // Field 0: Block + if c.Block == nil { + c.Block = new(BeaconBlockGloas) } + dst = ssz.WriteOffset(dst, offset) + offset += c.Block.SizeSSZ() - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 1: ExecutionPayloadEnvelope + if c.ExecutionPayloadEnvelope == nil { + c.ExecutionPayloadEnvelope = new(ExecutionPayloadEnvelope) } - hh.PutBytes(s.Signature) - - hh.Merkleize(indx) - return -} + dst = ssz.WriteOffset(dst, offset) + offset += c.ExecutionPayloadEnvelope.SizeSSZ() -// MarshalSSZ ssz marshals the ProposerPreferences object -func (p *ProposerPreferences) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(p) -} + // Field 2: KzgProofs + dst = ssz.WriteOffset(dst, offset) + offset += len(c.KzgProofs) * 48 -// MarshalSSZTo ssz marshals the ProposerPreferences object to a target array -func (p *ProposerPreferences) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf + // Field 3: Blobs + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Blobs) * 131072 - // Field (0) 'DependentRoot' - if size := len(p.DependentRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.DependentRoot", size, 32) - return + // Field 0: Block + if dst, err = c.Block.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Block: %w", err) } - dst = append(dst, p.DependentRoot...) - - // Field (1) 'ProposalSlot' - dst = ssz.MarshalUint(dst, p.ProposalSlot) - - // Field (2) 'ValidatorIndex' - dst = ssz.MarshalUint(dst, p.ValidatorIndex) - // Field (3) 'FeeRecipient' - if size := len(p.FeeRecipient); size != 20 { - err = ssz.ErrBytesLengthFn("--.FeeRecipient", size, 20) - return + // Field 1: ExecutionPayloadEnvelope + if dst, err = c.ExecutionPayloadEnvelope.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ExecutionPayloadEnvelope: %w", err) } - dst = append(dst, p.FeeRecipient...) - // Field (4) 'TargetGasLimit' - dst = ssz.MarshalUint(dst, p.TargetGasLimit) + // Field 2: KzgProofs + if len(c.KzgProofs) > 33554432 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.KzgProofs { + if len(o) != 48 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) + } - return + // Field 3: Blobs + if len(c.Blobs) > 4096 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.Blobs { + if len(o) != 131072 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the ProposerPreferences object -func (p *ProposerPreferences) UnmarshalSSZ(buf []byte) error { +func (c *BeaconBlockContentsGloas) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 76 { + if size < 16 { return ssz.ErrSize } - // Field (0) 'DependentRoot' - if cap(p.DependentRoot) == 0 { - p.DependentRoot = make([]byte, 0, len(buf[0:32])) + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Block + if sszVarOffset0 != 16 { + return ssz.ErrInvalidVariableOffset } - p.DependentRoot = append(p.DependentRoot, buf[0:32]...) - - // Field (1) 'ProposalSlot' - p.ProposalSlot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[32:40]) - - // Field (2) 'ValidatorIndex' - p.ValidatorIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[40:48]) - - // Field (3) 'FeeRecipient' - if cap(p.FeeRecipient) == 0 { - p.FeeRecipient = make([]byte, 0, len(buf[48:68])) + if sszVarOffset0 > size { + return ssz.ErrOffset } - p.FeeRecipient = append(p.FeeRecipient, buf[48:68]...) - - // Field (4) 'TargetGasLimit' - p.TargetGasLimit = ssz.UnmarshallUint[uint64](buf[68:76]) - - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the ProposerPreferences object -func (p *ProposerPreferences) SizeSSZ() (size int) { - size = 76 - return -} - -// HashTreeRoot ssz hashes the ProposerPreferences object -func (p *ProposerPreferences) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(p) -} - -// HashTreeRootWith ssz hashes the ProposerPreferences object with a hasher -func (p *ProposerPreferences) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'DependentRoot' - if size := len(p.DependentRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.DependentRoot", size, 32) - return + sszVarOffset1 := ssz.ReadOffset(buf[4:8]) // c.ExecutionPayloadEnvelope + if sszVarOffset1 > size || sszVarOffset1 < sszVarOffset0 { + return ssz.ErrOffset } - hh.PutBytes(p.DependentRoot) - - // Field (1) 'ProposalSlot' - ssz.PutUint(hh, p.ProposalSlot) - - // Field (2) 'ValidatorIndex' - ssz.PutUint(hh, p.ValidatorIndex) + sszVarOffset2 := ssz.ReadOffset(buf[8:12]) // c.KzgProofs + if sszVarOffset2 > size || sszVarOffset2 < sszVarOffset1 { + return ssz.ErrOffset + } + sszVarOffset3 := ssz.ReadOffset(buf[12:16]) // c.Blobs + if sszVarOffset3 > size || sszVarOffset3 < sszVarOffset2 { + return ssz.ErrOffset + } + sszSlice0 := buf[sszVarOffset0:sszVarOffset1] // c.Block + sszSlice1 := buf[sszVarOffset1:sszVarOffset2] // c.ExecutionPayloadEnvelope + sszSlice2 := buf[sszVarOffset2:sszVarOffset3] // c.KzgProofs + sszSlice3 := buf[sszVarOffset3:] // c.Blobs - // Field (3) 'FeeRecipient' - if size := len(p.FeeRecipient); size != 20 { - err = ssz.ErrBytesLengthFn("--.FeeRecipient", size, 20) - return + // Field 0: Block + c.Block = new(BeaconBlockGloas) + if err = c.Block.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Block: %w", err) } - hh.PutBytes(p.FeeRecipient) - // Field (4) 'TargetGasLimit' - ssz.PutUint(hh, p.TargetGasLimit) + // Field 1: ExecutionPayloadEnvelope + c.ExecutionPayloadEnvelope = new(ExecutionPayloadEnvelope) + if err = c.ExecutionPayloadEnvelope.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("ExecutionPayloadEnvelope: %w", err) + } - hh.Merkleize(indx) - return -} + // Field 2: KzgProofs + { + if len(sszSlice2)%48 != 0 { + return fmt.Errorf("misaligned bytes: c.KzgProofs length is %d, which is not a multiple of 48: %w", len(sszSlice2), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice2) / 48 + if numElem > 33554432 { + return fmt.Errorf("ssz-max exceeded: c.KzgProofs has %d elements, ssz-max is 33554432: %w", numElem, ssz.ErrListTooBig) + } + c.KzgProofs = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte -// MarshalSSZ ssz marshals the SignedProposerPreferences object -func (s *SignedProposerPreferences) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) -} + tmpSlice := sszSlice2[i*48 : (1+i)*48] + tmp = make([]byte, 0, 48) + tmp = append(tmp, tmpSlice...) + c.KzgProofs[i] = tmp + } + } -// MarshalSSZTo ssz marshals the SignedProposerPreferences object to a target array -func (s *SignedProposerPreferences) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf + // Field 3: Blobs + { + if len(sszSlice3)%131072 != 0 { + return fmt.Errorf("misaligned bytes: c.Blobs length is %d, which is not a multiple of 131072: %w", len(sszSlice3), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice3) / 131072 + if numElem > 4096 { + return fmt.Errorf("ssz-max exceeded: c.Blobs has %d elements, ssz-max is 4096: %w", numElem, ssz.ErrListTooBig) + } + c.Blobs = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte - // Field (0) 'Message' - if s.Message == nil { - s.Message = new(ProposerPreferences) - } - if dst, err = s.Message.MarshalSSZTo(dst); err != nil { - return + tmpSlice := sszSlice3[i*131072 : (1+i)*131072] + tmp = make([]byte, 0, 131072) + tmp = append(tmp, tmpSlice...) + c.Blobs[i] = tmp + } } + return err +} - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return +func (c *BeaconBlockContentsGloas) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - dst = append(dst, s.Signature...) - - return + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// UnmarshalSSZ ssz unmarshals the SignedProposerPreferences object -func (s *SignedProposerPreferences) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size != 172 { - return ssz.ErrSize +func (c *BeaconBlockContentsGloas) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Block + if err := c.Block.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Block: %w", err) } - - // Field (0) 'Message' - if s.Message == nil { - s.Message = new(ProposerPreferences) + // Field 1: ExecutionPayloadEnvelope + if err := c.ExecutionPayloadEnvelope.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ExecutionPayloadEnvelope: %w", err) } - if err = s.Message.UnmarshalSSZ(buf[0:76]); err != nil { - return err + // Field 2: KzgProofs + { + if len(c.KzgProofs) > 33554432 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.KzgProofs { + if len(o) != 48 { + return ssz.ErrBytesLength + } + hh.PutBytes(o) + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.KzgProofs)), 33554432) } - - // Field (1) 'Signature' - if cap(s.Signature) == 0 { - s.Signature = make([]byte, 0, len(buf[76:172])) + // Field 3: Blobs + { + if len(c.Blobs) > 4096 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.Blobs { + if len(o) != 131072 { + return ssz.ErrBytesLength + } + hh.PutBytes(o) + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Blobs)), 4096) } - s.Signature = append(s.Signature, buf[76:172]...) - - return err + hh.Merkleize(indx) + return nil } -// SizeSSZ returns the ssz encoded size in bytes for the SignedProposerPreferences object -func (s *SignedProposerPreferences) SizeSSZ() (size int) { - size = 172 - return +func (c *BeaconBlockGloas) SizeSSZ() int { + size := 84 + if c.Body == nil { + c.Body = new(BeaconBlockBodyGloas) + } + size += c.Body.SizeSSZ() + return size } -// HashTreeRoot ssz hashes the SignedProposerPreferences object -func (s *SignedProposerPreferences) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) +func (c *BeaconBlockGloas) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// HashTreeRootWith ssz hashes the SignedProposerPreferences object with a hasher -func (s *SignedProposerPreferences) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() +func (c *BeaconBlockGloas) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 84 - // Field (0) 'Message' - if err = s.Message.HashTreeRootWith(hh); err != nil { - return + // Field 0: Slot + if dst, err = c.Slot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Slot: %w", err) } - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 1: ProposerIndex + if dst, err = c.ProposerIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ProposerIndex: %w", err) } - hh.PutBytes(s.Signature) - - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the PayloadAttestationData object -func (p *PayloadAttestationData) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(p) -} -// MarshalSSZTo ssz marshals the PayloadAttestationData object to a target array -func (p *PayloadAttestationData) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - - // Field (0) 'BeaconBlockRoot' - if size := len(p.BeaconBlockRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.BeaconBlockRoot", size, 32) - return + // Field 2: ParentRoot + if len(c.ParentRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, p.BeaconBlockRoot...) - - // Field (1) 'Slot' - dst = ssz.MarshalUint(dst, p.Slot) + dst = append(dst, c.ParentRoot...) - // Field (2) 'PayloadPresent' - dst = ssz.MarshalBool(dst, p.PayloadPresent) + // Field 3: StateRoot + if len(c.StateRoot) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.StateRoot...) - // Field (3) 'BlobDataAvailable' - dst = ssz.MarshalBool(dst, p.BlobDataAvailable) + // Field 4: Body + if c.Body == nil { + c.Body = new(BeaconBlockBodyGloas) + } + dst = ssz.WriteOffset(dst, offset) + offset += c.Body.SizeSSZ() - return + // Field 4: Body + if dst, err = c.Body.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Body: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the PayloadAttestationData object -func (p *PayloadAttestationData) UnmarshalSSZ(buf []byte) error { +func (c *BeaconBlockGloas) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 42 { + if size < 84 { return ssz.ErrSize } - // Field (0) 'BeaconBlockRoot' - if cap(p.BeaconBlockRoot) == 0 { - p.BeaconBlockRoot = make([]byte, 0, len(buf[0:32])) - } - p.BeaconBlockRoot = append(p.BeaconBlockRoot, buf[0:32]...) + sszSlice0 := buf[0:8] // c.Slot + sszSlice1 := buf[8:16] // c.ProposerIndex + sszSlice2 := buf[16:48] // c.ParentRoot + sszSlice3 := buf[48:80] // c.StateRoot - // Field (1) 'Slot' - p.Slot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[32:40]) + sszVarOffset4 := ssz.ReadOffset(buf[80:84]) // c.Body + if sszVarOffset4 != 84 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset4 > size { + return ssz.ErrOffset + } + sszSlice4 := buf[sszVarOffset4:] // c.Body - // Field (2) 'PayloadPresent' - p.PayloadPresent, err = ssz.DecodeBool(buf[40:41]) - if err != nil { - return err + // Field 0: Slot + if err = c.Slot.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Slot: %w", err) } - // Field (3) 'BlobDataAvailable' - p.BlobDataAvailable, err = ssz.DecodeBool(buf[41:42]) - if err != nil { - return err + // Field 1: ProposerIndex + if err = c.ProposerIndex.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("ProposerIndex: %w", err) } - return err -} + // Field 2: ParentRoot + c.ParentRoot = make([]byte, 0, 32) + c.ParentRoot = append(c.ParentRoot, sszSlice2...) + + // Field 3: StateRoot + c.StateRoot = make([]byte, 0, 32) + c.StateRoot = append(c.StateRoot, sszSlice3...) -// SizeSSZ returns the ssz encoded size in bytes for the PayloadAttestationData object -func (p *PayloadAttestationData) SizeSSZ() (size int) { - size = 42 - return + // Field 4: Body + c.Body = new(BeaconBlockBodyGloas) + if err = c.Body.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("Body: %w", err) + } + return err } -// HashTreeRoot ssz hashes the PayloadAttestationData object -func (p *PayloadAttestationData) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(p) +func (c *BeaconBlockGloas) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the PayloadAttestationData object with a hasher -func (p *PayloadAttestationData) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *BeaconBlockGloas) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'BeaconBlockRoot' - if size := len(p.BeaconBlockRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.BeaconBlockRoot", size, 32) - return + // Field 0: Slot + if err := c.Slot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Slot: %w", err) + } + // Field 1: ProposerIndex + if err := c.ProposerIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ProposerIndex: %w", err) + } + // Field 2: ParentRoot + if len(c.ParentRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ParentRoot) + // Field 3: StateRoot + if len(c.StateRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.StateRoot) + // Field 4: Body + if err := c.Body.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Body: %w", err) } - hh.PutBytes(p.BeaconBlockRoot) - - // Field (1) 'Slot' - ssz.PutUint(hh, p.Slot) - - // Field (2) 'PayloadPresent' - hh.PutBool(p.PayloadPresent) - - // Field (3) 'BlobDataAvailable' - hh.PutBool(p.BlobDataAvailable) - hh.Merkleize(indx) - return -} + return nil +} + +func (c *BeaconStateGloas) SizeSSZ() int { + size := 14405 + size += len(c.HistoricalRoots) * 32 + size += len(c.Eth1DataVotes) * 72 + size += len(c.Validators) * 121 + size += len(c.Balances) * 8 + size += len(c.PreviousEpochParticipation) + size += len(c.CurrentEpochParticipation) + size += len(c.InactivityScores) * 8 + size += len(c.HistoricalSummaries) * 64 + size += len(c.PendingDeposits) * 192 + size += len(c.PendingPartialWithdrawals) * 24 + size += len(c.PendingConsolidations) * 16 + size += len(c.Builders) * 93 + size += len(c.BuilderPendingWithdrawals) * 36 + if c.LatestExecutionPayloadBid == nil { + c.LatestExecutionPayloadBid = new(ExecutionPayloadBid) + } + size += c.LatestExecutionPayloadBid.SizeSSZ() + size += len(c.PayloadExpectedWithdrawals) * 44 + return size +} + +func (c *BeaconStateGloas) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} + +func (c *BeaconStateGloas) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 14405 -// MarshalSSZ ssz marshals the PayloadAttestation object -func (p *PayloadAttestation) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(p) -} + // Field 0: GenesisTime + dst = binary.LittleEndian.AppendUint64(dst, c.GenesisTime) -// MarshalSSZTo ssz marshals the PayloadAttestation object to a target array -func (p *PayloadAttestation) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf + // Field 1: GenesisValidatorsRoot + if len(c.GenesisValidatorsRoot) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.GenesisValidatorsRoot...) - // Field (0) 'AggregationBits' - if size := len(p.AggregationBits); size != 2 { - err = ssz.ErrBytesLengthFn("--.AggregationBits", size, 2) - return + // Field 2: Slot + if dst, err = c.Slot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Slot: %w", err) } - dst = append(dst, p.AggregationBits...) - // Field (1) 'Data' - if p.Data == nil { - p.Data = new(PayloadAttestationData) + // Field 3: Fork + if c.Fork == nil { + c.Fork = new(Fork) } - if dst, err = p.Data.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.Fork.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Fork: %w", err) } - // Field (2) 'Signature' - if size := len(p.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 4: LatestBlockHeader + if c.LatestBlockHeader == nil { + c.LatestBlockHeader = new(BeaconBlockHeader) } - dst = append(dst, p.Signature...) - - return -} - -// UnmarshalSSZ ssz unmarshals the PayloadAttestation object -func (p *PayloadAttestation) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size != 140 { - return ssz.ErrSize + if dst, err = c.LatestBlockHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("LatestBlockHeader: %w", err) } - // Field (0) 'AggregationBits' - if cap(p.AggregationBits) == 0 { - p.AggregationBits = make([]byte, 0, len(buf[0:2])) + // Field 5: BlockRoots + if len(c.BlockRoots) != 64 { + return nil, ssz.ErrBytesLength + } + for _, o := range c.BlockRoots { + if len(o) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) } - p.AggregationBits = append(p.AggregationBits, buf[0:2]...) - // Field (1) 'Data' - if p.Data == nil { - p.Data = new(PayloadAttestationData) + // Field 6: StateRoots + if len(c.StateRoots) != 64 { + return nil, ssz.ErrBytesLength } - if err = p.Data.UnmarshalSSZ(buf[2:44]); err != nil { - return err + for _, o := range c.StateRoots { + if len(o) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) } - // Field (2) 'Signature' - if cap(p.Signature) == 0 { - p.Signature = make([]byte, 0, len(buf[44:140])) + // Field 7: HistoricalRoots + dst = ssz.WriteOffset(dst, offset) + offset += len(c.HistoricalRoots) * 32 + + // Field 8: Eth1Data + if c.Eth1Data == nil { + c.Eth1Data = new(Eth1Data) + } + if dst, err = c.Eth1Data.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Eth1Data: %w", err) } - p.Signature = append(p.Signature, buf[44:140]...) - return err -} + // Field 9: Eth1DataVotes + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Eth1DataVotes) * 72 -// SizeSSZ returns the ssz encoded size in bytes for the PayloadAttestation object -func (p *PayloadAttestation) SizeSSZ() (size int) { - size = 140 - return -} + // Field 10: Eth1DepositIndex + dst = binary.LittleEndian.AppendUint64(dst, c.Eth1DepositIndex) -// HashTreeRoot ssz hashes the PayloadAttestation object -func (p *PayloadAttestation) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(p) -} + // Field 11: Validators + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Validators) * 121 -// HashTreeRootWith ssz hashes the PayloadAttestation object with a hasher -func (p *PayloadAttestation) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() + // Field 12: Balances + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Balances) * 8 - // Field (0) 'AggregationBits' - if size := len(p.AggregationBits); size != 2 { - err = ssz.ErrBytesLengthFn("--.AggregationBits", size, 2) - return + // Field 13: RandaoMixes + if len(c.RandaoMixes) != 64 { + return nil, ssz.ErrBytesLength } - hh.PutBytes(p.AggregationBits) - - // Field (1) 'Data' - if err = p.Data.HashTreeRootWith(hh); err != nil { - return + for _, o := range c.RandaoMixes { + if len(o) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) } - // Field (2) 'Signature' - if size := len(p.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 14: Slashings + if len(c.Slashings) != 64 { + return nil, ssz.ErrBytesLength + } + for _, o := range c.Slashings { + dst = binary.LittleEndian.AppendUint64(dst, o) } - hh.PutBytes(p.Signature) - hh.Merkleize(indx) - return -} + // Field 15: PreviousEpochParticipation + dst = ssz.WriteOffset(dst, offset) + offset += len(c.PreviousEpochParticipation) -// MarshalSSZ ssz marshals the PayloadAttestationMessage object -func (p *PayloadAttestationMessage) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(p) -} + // Field 16: CurrentEpochParticipation + dst = ssz.WriteOffset(dst, offset) + offset += len(c.CurrentEpochParticipation) -// MarshalSSZTo ssz marshals the PayloadAttestationMessage object to a target array -func (p *PayloadAttestationMessage) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf + // Field 17: JustificationBits + if len([]byte(c.JustificationBits)) != 1 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, []byte(c.JustificationBits)...) - // Field (0) 'ValidatorIndex' - dst = ssz.MarshalUint(dst, p.ValidatorIndex) + // Field 18: PreviousJustifiedCheckpoint + if c.PreviousJustifiedCheckpoint == nil { + c.PreviousJustifiedCheckpoint = new(Checkpoint) + } + if dst, err = c.PreviousJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("PreviousJustifiedCheckpoint: %w", err) + } - // Field (1) 'Data' - if p.Data == nil { - p.Data = new(PayloadAttestationData) + // Field 19: CurrentJustifiedCheckpoint + if c.CurrentJustifiedCheckpoint == nil { + c.CurrentJustifiedCheckpoint = new(Checkpoint) } - if dst, err = p.Data.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.CurrentJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("CurrentJustifiedCheckpoint: %w", err) } - // Field (2) 'Signature' - if size := len(p.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 20: FinalizedCheckpoint + if c.FinalizedCheckpoint == nil { + c.FinalizedCheckpoint = new(Checkpoint) + } + if dst, err = c.FinalizedCheckpoint.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("FinalizedCheckpoint: %w", err) } - dst = append(dst, p.Signature...) - return -} + // Field 21: InactivityScores + dst = ssz.WriteOffset(dst, offset) + offset += len(c.InactivityScores) * 8 -// UnmarshalSSZ ssz unmarshals the PayloadAttestationMessage object -func (p *PayloadAttestationMessage) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size != 146 { - return ssz.ErrSize + // Field 22: CurrentSyncCommittee + if c.CurrentSyncCommittee == nil { + c.CurrentSyncCommittee = new(SyncCommittee) + } + if dst, err = c.CurrentSyncCommittee.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("CurrentSyncCommittee: %w", err) } - // Field (0) 'ValidatorIndex' - p.ValidatorIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[0:8]) - - // Field (1) 'Data' - if p.Data == nil { - p.Data = new(PayloadAttestationData) + // Field 23: NextSyncCommittee + if c.NextSyncCommittee == nil { + c.NextSyncCommittee = new(SyncCommittee) } - if err = p.Data.UnmarshalSSZ(buf[8:50]); err != nil { - return err + if dst, err = c.NextSyncCommittee.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("NextSyncCommittee: %w", err) } - // Field (2) 'Signature' - if cap(p.Signature) == 0 { - p.Signature = make([]byte, 0, len(buf[50:146])) + // Field 24: LatestBlockHash + if len(c.LatestBlockHash) != 32 { + return nil, ssz.ErrBytesLength } - p.Signature = append(p.Signature, buf[50:146]...) + dst = append(dst, c.LatestBlockHash...) - return err -} + // Field 25: NextWithdrawalIndex + dst = binary.LittleEndian.AppendUint64(dst, c.NextWithdrawalIndex) -// SizeSSZ returns the ssz encoded size in bytes for the PayloadAttestationMessage object -func (p *PayloadAttestationMessage) SizeSSZ() (size int) { - size = 146 - return -} + // Field 26: NextWithdrawalValidatorIndex + if dst, err = c.NextWithdrawalValidatorIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("NextWithdrawalValidatorIndex: %w", err) + } -// HashTreeRoot ssz hashes the PayloadAttestationMessage object -func (p *PayloadAttestationMessage) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(p) -} + // Field 27: HistoricalSummaries + dst = ssz.WriteOffset(dst, offset) + offset += len(c.HistoricalSummaries) * 64 -// HashTreeRootWith ssz hashes the PayloadAttestationMessage object with a hasher -func (p *PayloadAttestationMessage) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() + // Field 28: DepositRequestsStartIndex + dst = binary.LittleEndian.AppendUint64(dst, c.DepositRequestsStartIndex) - // Field (0) 'ValidatorIndex' - ssz.PutUint(hh, p.ValidatorIndex) + // Field 29: DepositBalanceToConsume + if dst, err = c.DepositBalanceToConsume.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("DepositBalanceToConsume: %w", err) + } - // Field (1) 'Data' - if err = p.Data.HashTreeRootWith(hh); err != nil { - return + // Field 30: ExitBalanceToConsume + if dst, err = c.ExitBalanceToConsume.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ExitBalanceToConsume: %w", err) } - // Field (2) 'Signature' - if size := len(p.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 31: EarliestExitEpoch + if dst, err = c.EarliestExitEpoch.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("EarliestExitEpoch: %w", err) } - hh.PutBytes(p.Signature) - hh.Merkleize(indx) - return -} + // Field 32: ConsolidationBalanceToConsume + if dst, err = c.ConsolidationBalanceToConsume.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ConsolidationBalanceToConsume: %w", err) + } -// MarshalSSZ ssz marshals the BeaconBlockGloas object -func (b *BeaconBlockGloas) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} + // Field 33: EarliestConsolidationEpoch + if dst, err = c.EarliestConsolidationEpoch.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("EarliestConsolidationEpoch: %w", err) + } -// MarshalSSZTo ssz marshals the BeaconBlockGloas object to a target array -func (b *BeaconBlockGloas) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(84) + // Field 34: PendingDeposits + dst = ssz.WriteOffset(dst, offset) + offset += len(c.PendingDeposits) * 192 - // Field (0) 'Slot' - dst = ssz.MarshalUint(dst, b.Slot) + // Field 35: PendingPartialWithdrawals + dst = ssz.WriteOffset(dst, offset) + offset += len(c.PendingPartialWithdrawals) * 24 - // Field (1) 'ProposerIndex' - dst = ssz.MarshalUint(dst, b.ProposerIndex) + // Field 36: PendingConsolidations + dst = ssz.WriteOffset(dst, offset) + offset += len(c.PendingConsolidations) * 16 - // Field (2) 'ParentRoot' - if size := len(b.ParentRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentRoot", size, 32) - return + // Field 37: ProposerLookahead + if len(c.ProposerLookahead) != 16 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.ParentRoot...) - - // Field (3) 'StateRoot' - if size := len(b.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return + for _, o := range c.ProposerLookahead { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ProposerLookahead: %w", err) + } } - dst = append(dst, b.StateRoot...) - // Offset (4) 'Body' + // Field 38: Builders dst = ssz.WriteOffset(dst, offset) - if b.Body == nil { - b.Body = new(BeaconBlockBodyGloas) - } - offset += b.Body.SizeSSZ() + offset += len(c.Builders) * 93 - // Field (4) 'Body' - if dst, err = b.Body.MarshalSSZTo(dst); err != nil { - return + // Field 39: NextWithdrawalBuilderIndex + if dst, err = c.NextWithdrawalBuilderIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("NextWithdrawalBuilderIndex: %w", err) } - return -} + // Field 40: ExecutionPayloadAvailability + if len(c.ExecutionPayloadAvailability) != 8 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.ExecutionPayloadAvailability...) -// UnmarshalSSZ ssz unmarshals the BeaconBlockGloas object -func (b *BeaconBlockGloas) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 84 { - return ssz.ErrSize + // Field 41: BuilderPendingPayments + if len(c.BuilderPendingPayments) != 16 { + return nil, ssz.ErrBytesLength + } + for _, o := range c.BuilderPendingPayments { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("BuilderPendingPayments: %w", err) + } } - tail := buf - var o4 uint64 + // Field 42: BuilderPendingWithdrawals + dst = ssz.WriteOffset(dst, offset) + offset += len(c.BuilderPendingWithdrawals) * 36 - // Field (0) 'Slot' - b.Slot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[0:8]) + // Field 43: LatestExecutionPayloadBid + if c.LatestExecutionPayloadBid == nil { + c.LatestExecutionPayloadBid = new(ExecutionPayloadBid) + } + dst = ssz.WriteOffset(dst, offset) + offset += c.LatestExecutionPayloadBid.SizeSSZ() - // Field (1) 'ProposerIndex' - b.ProposerIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[8:16]) + // Field 44: PayloadExpectedWithdrawals + dst = ssz.WriteOffset(dst, offset) + offset += len(c.PayloadExpectedWithdrawals) * 44 - // Field (2) 'ParentRoot' - if cap(b.ParentRoot) == 0 { - b.ParentRoot = make([]byte, 0, len(buf[16:48])) + // Field 45: PtcWindow + if len(c.PtcWindow) != 24 { + return nil, ssz.ErrBytesLength } - 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]...) - - // 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(BeaconBlockBodyGloas) + for _, o := range c.PtcWindow { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("PtcWindow: %w", err) } - if err = b.Body.UnmarshalSSZ(buf); err != nil { - return err - } - } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the BeaconBlockGloas object -func (b *BeaconBlockGloas) SizeSSZ() (size int) { - size = 84 - - // Field (4) 'Body' - if b.Body == nil { - b.Body = new(BeaconBlockBodyGloas) } - size += b.Body.SizeSSZ() - return -} - -// HashTreeRoot ssz hashes the BeaconBlockGloas object -func (b *BeaconBlockGloas) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) -} - -// HashTreeRootWith ssz hashes the BeaconBlockGloas object with a hasher -func (b *BeaconBlockGloas) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'Slot' - ssz.PutUint(hh, b.Slot) - - // Field (1) 'ProposerIndex' - ssz.PutUint(hh, b.ProposerIndex) - - // Field (2) 'ParentRoot' - if size := len(b.ParentRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentRoot", size, 32) - return + // Field 7: HistoricalRoots + if len(c.HistoricalRoots) > 16777216 { + return nil, ssz.ErrListTooBig } - hh.PutBytes(b.ParentRoot) - - // Field (3) 'StateRoot' - if size := len(b.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return + for _, o := range c.HistoricalRoots { + if len(o) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) } - hh.PutBytes(b.StateRoot) - // Field (4) 'Body' - if err = b.Body.HashTreeRootWith(hh); err != nil { - return + // Field 9: Eth1DataVotes + if len(c.Eth1DataVotes) > 32 { + return nil, ssz.ErrListTooBig } - - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the BeaconBlockBodyGloas object -func (b *BeaconBlockBodyGloas) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} - -// MarshalSSZTo ssz marshals the BeaconBlockBodyGloas object to a target array -func (b *BeaconBlockBodyGloas) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(336) - - // Field (0) 'RandaoReveal' - if size := len(b.RandaoReveal); size != 96 { - err = ssz.ErrBytesLengthFn("--.RandaoReveal", size, 96) - return + for _, o := range c.Eth1DataVotes { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Eth1DataVotes: %w", err) + } } - dst = append(dst, b.RandaoReveal...) - // Field (1) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(Eth1Data) + // Field 11: Validators + if len(c.Validators) > 1099511627776 { + return nil, ssz.ErrListTooBig } - if dst, err = b.Eth1Data.MarshalSSZTo(dst); err != nil { - return + for _, o := range c.Validators { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Validators: %w", err) + } } - // Field (2) 'Graffiti' - if size := len(b.Graffiti); size != 32 { - err = ssz.ErrBytesLengthFn("--.Graffiti", size, 32) - return + // Field 12: Balances + if len(c.Balances) > 1099511627776 { + return nil, ssz.ErrListTooBig } - 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() + for _, o := range c.Balances { + dst = binary.LittleEndian.AppendUint64(dst, o) } - // Offset (5) 'Attestations' - dst = ssz.WriteOffset(dst, offset) - for ii := 0; ii < len(b.Attestations); ii++ { - offset += 4 - offset += b.Attestations[ii].SizeSSZ() + // Field 15: PreviousEpochParticipation + if len(c.PreviousEpochParticipation) > 1099511627776 { + return nil, ssz.ErrListTooBig } + dst = append(dst, c.PreviousEpochParticipation...) - // 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(SyncAggregate) + // Field 16: CurrentEpochParticipation + if len(c.CurrentEpochParticipation) > 1099511627776 { + return nil, ssz.ErrListTooBig } - if dst, err = b.SyncAggregate.MarshalSSZTo(dst); err != nil { - return - } - - // Offset (9) 'BlsToExecutionChanges' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.BlsToExecutionChanges) * 172 + dst = append(dst, c.CurrentEpochParticipation...) - // Offset (10) 'SignedExecutionPayloadBid' - dst = ssz.WriteOffset(dst, offset) - if b.SignedExecutionPayloadBid == nil { - b.SignedExecutionPayloadBid = new(SignedExecutionPayloadBid) + // Field 21: InactivityScores + if len(c.InactivityScores) > 1099511627776 { + return nil, ssz.ErrListTooBig } - offset += b.SignedExecutionPayloadBid.SizeSSZ() - - // Offset (11) 'PayloadAttestations' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.PayloadAttestations) * 140 - - // Offset (12) 'ParentExecutionRequests' - dst = ssz.WriteOffset(dst, offset) - if b.ParentExecutionRequests == nil { - b.ParentExecutionRequests = new(v1.ExecutionRequestsGloas) + for _, o := range c.InactivityScores { + dst = binary.LittleEndian.AppendUint64(dst, o) } - offset += b.ParentExecutionRequests.SizeSSZ() - // Field (3) 'ProposerSlashings' - if size := len(b.ProposerSlashings); size > 16 { - err = ssz.ErrListTooBigFn("--.ProposerSlashings", size, 16) - return + // Field 27: HistoricalSummaries + if len(c.HistoricalSummaries) > 16777216 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.ProposerSlashings); ii++ { - if dst, err = b.ProposerSlashings[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.HistoricalSummaries { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("HistoricalSummaries: %w", err) } } - // Field (4) 'AttesterSlashings' - if size := len(b.AttesterSlashings); size > 1 { - err = ssz.ErrListTooBigFn("--.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() - } + // Field 34: PendingDeposits + if len(c.PendingDeposits) > 134217728 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.AttesterSlashings); ii++ { - if dst, err = b.AttesterSlashings[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.PendingDeposits { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("PendingDeposits: %w", err) } } - // Field (5) 'Attestations' - if size := len(b.Attestations); size > 8 { - err = ssz.ErrListTooBigFn("--.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() - } + // Field 35: PendingPartialWithdrawals + if len(c.PendingPartialWithdrawals) > 64 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.Attestations); ii++ { - if dst, err = b.Attestations[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.PendingPartialWithdrawals { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("PendingPartialWithdrawals: %w", err) } } - // Field (6) 'Deposits' - if size := len(b.Deposits); size > 16 { - err = ssz.ErrListTooBigFn("--.Deposits", size, 16) - return + // Field 36: PendingConsolidations + if len(c.PendingConsolidations) > 64 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.Deposits); ii++ { - if dst, err = b.Deposits[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.PendingConsolidations { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("PendingConsolidations: %w", err) } } - // Field (7) 'VoluntaryExits' - if size := len(b.VoluntaryExits); size > 16 { - err = ssz.ErrListTooBigFn("--.VoluntaryExits", size, 16) - return + // Field 38: Builders + if len(c.Builders) > 1099511627776 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.VoluntaryExits); ii++ { - if dst, err = b.VoluntaryExits[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.Builders { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Builders: %w", err) } } - // Field (9) 'BlsToExecutionChanges' - if size := len(b.BlsToExecutionChanges); size > 16 { - err = ssz.ErrListTooBigFn("--.BlsToExecutionChanges", size, 16) - return + // Field 42: BuilderPendingWithdrawals + if len(c.BuilderPendingWithdrawals) > 1048576 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.BlsToExecutionChanges); ii++ { - if dst, err = b.BlsToExecutionChanges[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.BuilderPendingWithdrawals { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("BuilderPendingWithdrawals: %w", err) } } - // Field (10) 'SignedExecutionPayloadBid' - if dst, err = b.SignedExecutionPayloadBid.MarshalSSZTo(dst); err != nil { - return + // Field 43: LatestExecutionPayloadBid + if dst, err = c.LatestExecutionPayloadBid.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("LatestExecutionPayloadBid: %w", err) } - // Field (11) 'PayloadAttestations' - if size := len(b.PayloadAttestations); size > 4 { - err = ssz.ErrListTooBigFn("--.PayloadAttestations", size, 4) - return + // Field 44: PayloadExpectedWithdrawals + if len(c.PayloadExpectedWithdrawals) > 4 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.PayloadAttestations); ii++ { - if dst, err = b.PayloadAttestations[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.PayloadExpectedWithdrawals { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("PayloadExpectedWithdrawals: %w", err) } } - - // Field (12) 'ParentExecutionRequests' - if dst, err = b.ParentExecutionRequests.MarshalSSZTo(dst); err != nil { - return - } - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the BeaconBlockBodyGloas object -func (b *BeaconBlockBodyGloas) UnmarshalSSZ(buf []byte) error { +func (c *BeaconStateGloas) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 336 { + if size < 14405 { 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])) + sszSlice0 := buf[0:8] // c.GenesisTime + sszSlice1 := buf[8:40] // c.GenesisValidatorsRoot + sszSlice2 := buf[40:48] // c.Slot + sszSlice3 := buf[48:64] // c.Fork + sszSlice4 := buf[64:176] // c.LatestBlockHeader + sszSlice5 := buf[176:2224] // c.BlockRoots + sszSlice6 := buf[2224:4272] // c.StateRoots + sszSlice8 := buf[4276:4348] // c.Eth1Data + sszSlice10 := buf[4352:4360] // c.Eth1DepositIndex + sszSlice13 := buf[4368:6416] // c.RandaoMixes + sszSlice14 := buf[6416:6928] // c.Slashings + sszSlice17 := buf[6936:6937] // c.JustificationBits + sszSlice18 := buf[6937:6977] // c.PreviousJustifiedCheckpoint + sszSlice19 := buf[6977:7017] // c.CurrentJustifiedCheckpoint + sszSlice20 := buf[7017:7057] // c.FinalizedCheckpoint + sszSlice22 := buf[7061:8645] // c.CurrentSyncCommittee + sszSlice23 := buf[8645:10229] // c.NextSyncCommittee + sszSlice24 := buf[10229:10261] // c.LatestBlockHash + sszSlice25 := buf[10261:10269] // c.NextWithdrawalIndex + sszSlice26 := buf[10269:10277] // c.NextWithdrawalValidatorIndex + sszSlice28 := buf[10281:10289] // c.DepositRequestsStartIndex + sszSlice29 := buf[10289:10297] // c.DepositBalanceToConsume + sszSlice30 := buf[10297:10305] // c.ExitBalanceToConsume + sszSlice31 := buf[10305:10313] // c.EarliestExitEpoch + sszSlice32 := buf[10313:10321] // c.ConsolidationBalanceToConsume + sszSlice33 := buf[10321:10329] // c.EarliestConsolidationEpoch + sszSlice37 := buf[10341:10469] // c.ProposerLookahead + sszSlice39 := buf[10473:10481] // c.NextWithdrawalBuilderIndex + sszSlice40 := buf[10481:10489] // c.ExecutionPayloadAvailability + sszSlice41 := buf[10489:11321] // c.BuilderPendingPayments + sszSlice45 := buf[11333:14405] // c.PtcWindow + + sszVarOffset7 := ssz.ReadOffset(buf[4272:4276]) // c.HistoricalRoots + if sszVarOffset7 != 14405 { + return ssz.ErrInvalidVariableOffset } - b.RandaoReveal = append(b.RandaoReveal, buf[0:96]...) - - // Field (1) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(Eth1Data) + if sszVarOffset7 > size { + return ssz.ErrOffset } - if err = b.Eth1Data.UnmarshalSSZ(buf[96:168]); err != nil { - return err + sszVarOffset9 := ssz.ReadOffset(buf[4348:4352]) // c.Eth1DataVotes + if sszVarOffset9 > size || sszVarOffset9 < sszVarOffset7 { + return ssz.ErrOffset } - - // Field (2) 'Graffiti' - if cap(b.Graffiti) == 0 { - b.Graffiti = make([]byte, 0, len(buf[168:200])) + sszVarOffset11 := ssz.ReadOffset(buf[4360:4364]) // c.Validators + if sszVarOffset11 > size || sszVarOffset11 < sszVarOffset9 { + return ssz.ErrOffset } - b.Graffiti = append(b.Graffiti, buf[168:200]...) - - // Offset (3) 'ProposerSlashings' - if o3 = ssz.ReadOffset(buf[200:204]); o3 > size { + sszVarOffset12 := ssz.ReadOffset(buf[4364:4368]) // c.Balances + if sszVarOffset12 > size || sszVarOffset12 < sszVarOffset11 { return ssz.ErrOffset } - - if o3 != 336 { - return ssz.ErrInvalidVariableOffset + sszVarOffset15 := ssz.ReadOffset(buf[6928:6932]) // c.PreviousEpochParticipation + if sszVarOffset15 > size || sszVarOffset15 < sszVarOffset12 { + return ssz.ErrOffset } - - // Offset (4) 'AttesterSlashings' - if o4 = ssz.ReadOffset(buf[204:208]); o4 > size || o3 > o4 { + sszVarOffset16 := ssz.ReadOffset(buf[6932:6936]) // c.CurrentEpochParticipation + if sszVarOffset16 > size || sszVarOffset16 < sszVarOffset15 { return ssz.ErrOffset } - - // Offset (5) 'Attestations' - if o5 = ssz.ReadOffset(buf[208:212]); o5 > size || o4 > o5 { + sszVarOffset21 := ssz.ReadOffset(buf[7057:7061]) // c.InactivityScores + if sszVarOffset21 > size || sszVarOffset21 < sszVarOffset16 { return ssz.ErrOffset } - - // Offset (6) 'Deposits' - if o6 = ssz.ReadOffset(buf[212:216]); o6 > size || o5 > o6 { + sszVarOffset27 := ssz.ReadOffset(buf[10277:10281]) // c.HistoricalSummaries + if sszVarOffset27 > size || sszVarOffset27 < sszVarOffset21 { return ssz.ErrOffset } - - // Offset (7) 'VoluntaryExits' - if o7 = ssz.ReadOffset(buf[216:220]); o7 > size || o6 > o7 { + sszVarOffset34 := ssz.ReadOffset(buf[10329:10333]) // c.PendingDeposits + if sszVarOffset34 > size || sszVarOffset34 < sszVarOffset27 { return ssz.ErrOffset } - - // Field (8) 'SyncAggregate' - if b.SyncAggregate == nil { - b.SyncAggregate = new(SyncAggregate) + sszVarOffset35 := ssz.ReadOffset(buf[10333:10337]) // c.PendingPartialWithdrawals + if sszVarOffset35 > size || sszVarOffset35 < sszVarOffset34 { + return ssz.ErrOffset } - if err = b.SyncAggregate.UnmarshalSSZ(buf[220:320]); err != nil { - return err + sszVarOffset36 := ssz.ReadOffset(buf[10337:10341]) // c.PendingConsolidations + if sszVarOffset36 > size || sszVarOffset36 < sszVarOffset35 { + return ssz.ErrOffset } - - // Offset (9) 'BlsToExecutionChanges' - if o9 = ssz.ReadOffset(buf[320:324]); o9 > size || o7 > o9 { + sszVarOffset38 := ssz.ReadOffset(buf[10469:10473]) // c.Builders + if sszVarOffset38 > size || sszVarOffset38 < sszVarOffset36 { return ssz.ErrOffset } - - // Offset (10) 'SignedExecutionPayloadBid' - if o10 = ssz.ReadOffset(buf[324:328]); o10 > size || o9 > o10 { + sszVarOffset42 := ssz.ReadOffset(buf[11321:11325]) // c.BuilderPendingWithdrawals + if sszVarOffset42 > size || sszVarOffset42 < sszVarOffset38 { return ssz.ErrOffset } - - // Offset (11) 'PayloadAttestations' - if o11 = ssz.ReadOffset(buf[328:332]); o11 > size || o10 > o11 { + sszVarOffset43 := ssz.ReadOffset(buf[11325:11329]) // c.LatestExecutionPayloadBid + if sszVarOffset43 > size || sszVarOffset43 < sszVarOffset42 { return ssz.ErrOffset } - - // Offset (12) 'ParentExecutionRequests' - if o12 = ssz.ReadOffset(buf[332:336]); o12 > size || o11 > o12 { + sszVarOffset44 := ssz.ReadOffset(buf[11329:11333]) // c.PayloadExpectedWithdrawals + if sszVarOffset44 > size || sszVarOffset44 < sszVarOffset43 { return ssz.ErrOffset } + sszSlice7 := buf[sszVarOffset7:sszVarOffset9] // c.HistoricalRoots + sszSlice9 := buf[sszVarOffset9:sszVarOffset11] // c.Eth1DataVotes + sszSlice11 := buf[sszVarOffset11:sszVarOffset12] // c.Validators + sszSlice12 := buf[sszVarOffset12:sszVarOffset15] // c.Balances + sszSlice15 := buf[sszVarOffset15:sszVarOffset16] // c.PreviousEpochParticipation + sszSlice16 := buf[sszVarOffset16:sszVarOffset21] // c.CurrentEpochParticipation + sszSlice21 := buf[sszVarOffset21:sszVarOffset27] // c.InactivityScores + sszSlice27 := buf[sszVarOffset27:sszVarOffset34] // c.HistoricalSummaries + sszSlice34 := buf[sszVarOffset34:sszVarOffset35] // c.PendingDeposits + sszSlice35 := buf[sszVarOffset35:sszVarOffset36] // c.PendingPartialWithdrawals + sszSlice36 := buf[sszVarOffset36:sszVarOffset38] // c.PendingConsolidations + sszSlice38 := buf[sszVarOffset38:sszVarOffset42] // c.Builders + sszSlice42 := buf[sszVarOffset42:sszVarOffset43] // c.BuilderPendingWithdrawals + sszSlice43 := buf[sszVarOffset43:sszVarOffset44] // c.LatestExecutionPayloadBid + sszSlice44 := buf[sszVarOffset44:] // c.PayloadExpectedWithdrawals - // Field (3) 'ProposerSlashings' - { - buf = tail[o3:o4] - num, err := ssz.DivideInt2(len(buf), 416, 16) - if err != nil { - return err - } - b.ProposerSlashings = make([]*ProposerSlashing, num) - for ii := 0; ii < num; ii++ { - if b.ProposerSlashings[ii] == nil { - b.ProposerSlashings[ii] = new(ProposerSlashing) - } - if err = b.ProposerSlashings[ii].UnmarshalSSZ(buf[ii*416 : (ii+1)*416]); err != nil { - return err - } - } + // Field 0: GenesisTime + c.GenesisTime = binary.LittleEndian.Uint64(sszSlice0) + + // Field 1: GenesisValidatorsRoot + c.GenesisValidatorsRoot = make([]byte, 0, 32) + c.GenesisValidatorsRoot = append(c.GenesisValidatorsRoot, sszSlice1...) + + // Field 2: Slot + if err = c.Slot.UnmarshalSSZ(sszSlice2); err != nil { + return fmt.Errorf("Slot: %w", err) + } + + // Field 3: Fork + c.Fork = new(Fork) + if err = c.Fork.UnmarshalSSZ(sszSlice3); err != nil { + return fmt.Errorf("Fork: %w", err) + } + + // Field 4: LatestBlockHeader + c.LatestBlockHeader = new(BeaconBlockHeader) + if err = c.LatestBlockHeader.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("LatestBlockHeader: %w", err) } - // Field (4) 'AttesterSlashings' + // Field 5: BlockRoots { - buf = tail[o4:o5] - num, err := ssz.DecodeDynamicLength(buf, 1) - if err != nil { - return err - } - b.AttesterSlashings = make([]*AttesterSlashingGloas, num) - err = ssz.UnmarshalDynamic(buf, num, func(indx int, buf []byte) (err error) { - if b.AttesterSlashings[indx] == nil { - b.AttesterSlashings[indx] = new(AttesterSlashingGloas) - } - if err = b.AttesterSlashings[indx].UnmarshalSSZ(buf); err != nil { - return err - } - return nil - }) - if err != nil { - return err + c.BlockRoots = make([][]byte, 64) + for i := 0; i < 64; i++ { + var tmp []byte + + tmpSlice := sszSlice5[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.BlockRoots[i] = tmp } } - // Field (5) 'Attestations' + // Field 6: StateRoots { - buf = tail[o5:o6] - num, err := ssz.DecodeDynamicLength(buf, 8) - if err != nil { - return err - } - b.Attestations = make([]*AttestationGloas, num) - err = ssz.UnmarshalDynamic(buf, num, func(indx int, buf []byte) (err error) { - if b.Attestations[indx] == nil { - b.Attestations[indx] = new(AttestationGloas) - } - if err = b.Attestations[indx].UnmarshalSSZ(buf); err != nil { - return err - } - return nil - }) - if err != nil { - return err + c.StateRoots = make([][]byte, 64) + for i := 0; i < 64; i++ { + var tmp []byte + + tmpSlice := sszSlice6[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.StateRoots[i] = tmp } } - // Field (6) 'Deposits' + // Field 7: HistoricalRoots { - buf = tail[o6:o7] - num, err := ssz.DivideInt2(len(buf), 1240, 16) - if err != nil { - return err - } - b.Deposits = make([]*Deposit, num) - for ii := 0; ii < num; ii++ { - if b.Deposits[ii] == nil { - b.Deposits[ii] = new(Deposit) - } - if err = b.Deposits[ii].UnmarshalSSZ(buf[ii*1240 : (ii+1)*1240]); err != nil { - return err - } + if len(sszSlice7)%32 != 0 { + return fmt.Errorf("misaligned bytes: c.HistoricalRoots length is %d, which is not a multiple of 32: %w", len(sszSlice7), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice7) / 32 + if numElem > 16777216 { + return fmt.Errorf("ssz-max exceeded: c.HistoricalRoots has %d elements, ssz-max is 16777216: %w", numElem, ssz.ErrListTooBig) } + c.HistoricalRoots = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte + + tmpSlice := sszSlice7[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.HistoricalRoots[i] = tmp + } + } + + // Field 8: Eth1Data + c.Eth1Data = new(Eth1Data) + if err = c.Eth1Data.UnmarshalSSZ(sszSlice8); err != nil { + return fmt.Errorf("Eth1Data: %w", err) } - // Field (7) 'VoluntaryExits' + // Field 9: Eth1DataVotes { - buf = tail[o7:o9] - num, err := ssz.DivideInt2(len(buf), 112, 16) - if err != nil { - return err - } - b.VoluntaryExits = make([]*SignedVoluntaryExit, num) - for ii := 0; ii < num; ii++ { - if b.VoluntaryExits[ii] == nil { - b.VoluntaryExits[ii] = new(SignedVoluntaryExit) - } - if err = b.VoluntaryExits[ii].UnmarshalSSZ(buf[ii*112 : (ii+1)*112]); err != nil { - return err + if len(sszSlice9)%72 != 0 { + return fmt.Errorf("misaligned bytes: c.Eth1DataVotes length is %d, which is not a multiple of 72: %w", len(sszSlice9), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice9) / 72 + if numElem > 32 { + return fmt.Errorf("ssz-max exceeded: c.Eth1DataVotes has %d elements, ssz-max is 32: %w", numElem, ssz.ErrListTooBig) + } + c.Eth1DataVotes = make([]*Eth1Data, numElem) + for i := 0; i < numElem; i++ { + var tmp *Eth1Data + tmp = new(Eth1Data) + tmpSlice := sszSlice9[i*72 : (1+i)*72] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Eth1DataVotes: %w", err) } + c.Eth1DataVotes[i] = tmp } } - // Field (9) 'BlsToExecutionChanges' + // Field 10: Eth1DepositIndex + c.Eth1DepositIndex = binary.LittleEndian.Uint64(sszSlice10) + + // Field 11: Validators { - buf = tail[o9:o10] - num, err := ssz.DivideInt2(len(buf), 172, 16) - if err != nil { - return err - } - b.BlsToExecutionChanges = make([]*SignedBLSToExecutionChange, num) - for ii := 0; ii < num; ii++ { - if b.BlsToExecutionChanges[ii] == nil { - b.BlsToExecutionChanges[ii] = new(SignedBLSToExecutionChange) - } - if err = b.BlsToExecutionChanges[ii].UnmarshalSSZ(buf[ii*172 : (ii+1)*172]); err != nil { - return err + if len(sszSlice11)%121 != 0 { + return fmt.Errorf("misaligned bytes: c.Validators length is %d, which is not a multiple of 121: %w", len(sszSlice11), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice11) / 121 + if numElem > 1099511627776 { + return fmt.Errorf("ssz-max exceeded: c.Validators has %d elements, ssz-max is 1099511627776: %w", numElem, ssz.ErrListTooBig) + } + c.Validators = make([]*Validator, numElem) + for i := 0; i < numElem; i++ { + var tmp *Validator + tmp = new(Validator) + tmpSlice := sszSlice11[i*121 : (1+i)*121] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Validators: %w", err) } + c.Validators[i] = tmp } } - // Field (10) 'SignedExecutionPayloadBid' + // Field 12: Balances { - buf = tail[o10:o11] - if b.SignedExecutionPayloadBid == nil { - b.SignedExecutionPayloadBid = new(SignedExecutionPayloadBid) + if len(sszSlice12)%8 != 0 { + return fmt.Errorf("misaligned bytes: c.Balances length is %d, which is not a multiple of 8: %w", len(sszSlice12), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice12) / 8 + if numElem > 1099511627776 { + return fmt.Errorf("ssz-max exceeded: c.Balances has %d elements, ssz-max is 1099511627776: %w", numElem, ssz.ErrListTooBig) } - if err = b.SignedExecutionPayloadBid.UnmarshalSSZ(buf); err != nil { - return err + c.Balances = make([]uint64, numElem) + for i := 0; i < numElem; i++ { + var tmp uint64 + + tmpSlice := sszSlice12[i*8 : (1+i)*8] + tmp = binary.LittleEndian.Uint64(tmpSlice) + c.Balances[i] = tmp } } - // Field (11) 'PayloadAttestations' + // Field 13: RandaoMixes { - buf = tail[o11:o12] - num, err := ssz.DivideInt2(len(buf), 140, 4) - if err != nil { - return err - } - b.PayloadAttestations = make([]*PayloadAttestation, num) - for ii := 0; ii < num; ii++ { - if b.PayloadAttestations[ii] == nil { - b.PayloadAttestations[ii] = new(PayloadAttestation) - } - if err = b.PayloadAttestations[ii].UnmarshalSSZ(buf[ii*140 : (ii+1)*140]); err != nil { - return err - } + c.RandaoMixes = make([][]byte, 64) + for i := 0; i < 64; i++ { + var tmp []byte + + tmpSlice := sszSlice13[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.RandaoMixes[i] = tmp } } - // Field (12) 'ParentExecutionRequests' + // Field 14: Slashings { - buf = tail[o12:] - if b.ParentExecutionRequests == nil { - b.ParentExecutionRequests = new(v1.ExecutionRequestsGloas) - } - if err = b.ParentExecutionRequests.UnmarshalSSZ(buf); err != nil { - return err + c.Slashings = make([]uint64, 64) + for i := 0; i < 64; i++ { + var tmp uint64 + + tmpSlice := sszSlice14[i*8 : (1+i)*8] + tmp = binary.LittleEndian.Uint64(tmpSlice) + c.Slashings[i] = tmp } } - return err -} -// SizeSSZ returns the ssz encoded size in bytes for the BeaconBlockBodyGloas object -func (b *BeaconBlockBodyGloas) SizeSSZ() (size int) { - size = 336 + // Field 15: PreviousEpochParticipation + c.PreviousEpochParticipation = append([]byte{}, sszSlice15...) - // Field (3) 'ProposerSlashings' - size += len(b.ProposerSlashings) * 416 + // Field 16: CurrentEpochParticipation + c.CurrentEpochParticipation = append([]byte{}, sszSlice16...) - // Field (4) 'AttesterSlashings' - for ii := 0; ii < len(b.AttesterSlashings); ii++ { - size += 4 - size += b.AttesterSlashings[ii].SizeSSZ() + // Field 17: JustificationBits + c.JustificationBits = make([]byte, 0, 1) + c.JustificationBits = append(c.JustificationBits, go_bitfield.Bitvector4(sszSlice17)...) + + // Field 18: PreviousJustifiedCheckpoint + c.PreviousJustifiedCheckpoint = new(Checkpoint) + if err = c.PreviousJustifiedCheckpoint.UnmarshalSSZ(sszSlice18); err != nil { + return fmt.Errorf("PreviousJustifiedCheckpoint: %w", err) } - // Field (5) 'Attestations' - for ii := 0; ii < len(b.Attestations); ii++ { - size += 4 - size += b.Attestations[ii].SizeSSZ() + // Field 19: CurrentJustifiedCheckpoint + c.CurrentJustifiedCheckpoint = new(Checkpoint) + if err = c.CurrentJustifiedCheckpoint.UnmarshalSSZ(sszSlice19); err != nil { + return fmt.Errorf("CurrentJustifiedCheckpoint: %w", err) + } + + // Field 20: FinalizedCheckpoint + c.FinalizedCheckpoint = new(Checkpoint) + if err = c.FinalizedCheckpoint.UnmarshalSSZ(sszSlice20); err != nil { + return fmt.Errorf("FinalizedCheckpoint: %w", err) } - // Field (6) 'Deposits' - size += len(b.Deposits) * 1240 + // Field 21: InactivityScores + { + if len(sszSlice21)%8 != 0 { + return fmt.Errorf("misaligned bytes: c.InactivityScores length is %d, which is not a multiple of 8: %w", len(sszSlice21), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice21) / 8 + if numElem > 1099511627776 { + return fmt.Errorf("ssz-max exceeded: c.InactivityScores has %d elements, ssz-max is 1099511627776: %w", numElem, ssz.ErrListTooBig) + } + c.InactivityScores = make([]uint64, numElem) + for i := 0; i < numElem; i++ { + var tmp uint64 - // Field (7) 'VoluntaryExits' - size += len(b.VoluntaryExits) * 112 + tmpSlice := sszSlice21[i*8 : (1+i)*8] + tmp = binary.LittleEndian.Uint64(tmpSlice) + c.InactivityScores[i] = tmp + } + } - // Field (9) 'BlsToExecutionChanges' - size += len(b.BlsToExecutionChanges) * 172 + // Field 22: CurrentSyncCommittee + c.CurrentSyncCommittee = new(SyncCommittee) + if err = c.CurrentSyncCommittee.UnmarshalSSZ(sszSlice22); err != nil { + return fmt.Errorf("CurrentSyncCommittee: %w", err) + } - // Field (10) 'SignedExecutionPayloadBid' - if b.SignedExecutionPayloadBid == nil { - b.SignedExecutionPayloadBid = new(SignedExecutionPayloadBid) + // Field 23: NextSyncCommittee + c.NextSyncCommittee = new(SyncCommittee) + if err = c.NextSyncCommittee.UnmarshalSSZ(sszSlice23); err != nil { + return fmt.Errorf("NextSyncCommittee: %w", err) } - size += b.SignedExecutionPayloadBid.SizeSSZ() - // Field (11) 'PayloadAttestations' - size += len(b.PayloadAttestations) * 140 + // Field 24: LatestBlockHash + c.LatestBlockHash = make([]byte, 0, 32) + c.LatestBlockHash = append(c.LatestBlockHash, sszSlice24...) + + // Field 25: NextWithdrawalIndex + c.NextWithdrawalIndex = binary.LittleEndian.Uint64(sszSlice25) - // Field (12) 'ParentExecutionRequests' - if b.ParentExecutionRequests == nil { - b.ParentExecutionRequests = new(v1.ExecutionRequestsGloas) + // Field 26: NextWithdrawalValidatorIndex + if err = c.NextWithdrawalValidatorIndex.UnmarshalSSZ(sszSlice26); err != nil { + return fmt.Errorf("NextWithdrawalValidatorIndex: %w", err) } - size += b.ParentExecutionRequests.SizeSSZ() - return -} + // Field 27: HistoricalSummaries + { + if len(sszSlice27)%64 != 0 { + return fmt.Errorf("misaligned bytes: c.HistoricalSummaries length is %d, which is not a multiple of 64: %w", len(sszSlice27), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice27) / 64 + if numElem > 16777216 { + return fmt.Errorf("ssz-max exceeded: c.HistoricalSummaries has %d elements, ssz-max is 16777216: %w", numElem, ssz.ErrListTooBig) + } + c.HistoricalSummaries = make([]*HistoricalSummary, numElem) + for i := 0; i < numElem; i++ { + var tmp *HistoricalSummary + tmp = new(HistoricalSummary) + tmpSlice := sszSlice27[i*64 : (1+i)*64] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("HistoricalSummaries: %w", err) + } + c.HistoricalSummaries[i] = tmp + } + } -// HashTreeRoot ssz hashes the BeaconBlockBodyGloas object -func (b *BeaconBlockBodyGloas) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) -} + // Field 28: DepositRequestsStartIndex + c.DepositRequestsStartIndex = binary.LittleEndian.Uint64(sszSlice28) -// HashTreeRootWith ssz hashes the BeaconBlockBodyGloas object with a hasher -func (b *BeaconBlockBodyGloas) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() + // Field 29: DepositBalanceToConsume + if err = c.DepositBalanceToConsume.UnmarshalSSZ(sszSlice29); err != nil { + return fmt.Errorf("DepositBalanceToConsume: %w", err) + } - // Field (0) 'RandaoReveal' - if size := len(b.RandaoReveal); size != 96 { - err = ssz.ErrBytesLengthFn("--.RandaoReveal", size, 96) - return + // Field 30: ExitBalanceToConsume + if err = c.ExitBalanceToConsume.UnmarshalSSZ(sszSlice30); err != nil { + return fmt.Errorf("ExitBalanceToConsume: %w", err) } - hh.PutBytes(b.RandaoReveal) - // Field (1) 'Eth1Data' - if err = b.Eth1Data.HashTreeRootWith(hh); err != nil { - return + // Field 31: EarliestExitEpoch + if err = c.EarliestExitEpoch.UnmarshalSSZ(sszSlice31); err != nil { + return fmt.Errorf("EarliestExitEpoch: %w", err) } - // Field (2) 'Graffiti' - if size := len(b.Graffiti); size != 32 { - err = ssz.ErrBytesLengthFn("--.Graffiti", size, 32) - return + // Field 32: ConsolidationBalanceToConsume + if err = c.ConsolidationBalanceToConsume.UnmarshalSSZ(sszSlice32); err != nil { + return fmt.Errorf("ConsolidationBalanceToConsume: %w", err) } - hh.PutBytes(b.Graffiti) - // Field (3) 'ProposerSlashings' + // Field 33: EarliestConsolidationEpoch + if err = c.EarliestConsolidationEpoch.UnmarshalSSZ(sszSlice33); err != nil { + return fmt.Errorf("EarliestConsolidationEpoch: %w", err) + } + + // Field 34: PendingDeposits { - 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 + if len(sszSlice34)%192 != 0 { + return fmt.Errorf("misaligned bytes: c.PendingDeposits length is %d, which is not a multiple of 192: %w", len(sszSlice34), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice34) / 192 + if numElem > 134217728 { + return fmt.Errorf("ssz-max exceeded: c.PendingDeposits has %d elements, ssz-max is 134217728: %w", numElem, ssz.ErrListTooBig) + } + c.PendingDeposits = make([]*PendingDeposit, numElem) + for i := 0; i < numElem; i++ { + var tmp *PendingDeposit + tmp = new(PendingDeposit) + tmpSlice := sszSlice34[i*192 : (1+i)*192] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("PendingDeposits: %w", err) } + c.PendingDeposits[i] = tmp } - hh.MerkleizeWithMixin(subIndx, num, 16) } - // Field (4) 'AttesterSlashings' + // Field 35: PendingPartialWithdrawals { - 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 + if len(sszSlice35)%24 != 0 { + return fmt.Errorf("misaligned bytes: c.PendingPartialWithdrawals length is %d, which is not a multiple of 24: %w", len(sszSlice35), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice35) / 24 + if numElem > 64 { + return fmt.Errorf("ssz-max exceeded: c.PendingPartialWithdrawals has %d elements, ssz-max is 64: %w", numElem, ssz.ErrListTooBig) + } + c.PendingPartialWithdrawals = make([]*PendingPartialWithdrawal, numElem) + for i := 0; i < numElem; i++ { + var tmp *PendingPartialWithdrawal + tmp = new(PendingPartialWithdrawal) + tmpSlice := sszSlice35[i*24 : (1+i)*24] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("PendingPartialWithdrawals: %w", err) } + c.PendingPartialWithdrawals[i] = tmp } - hh.MerkleizeWithMixin(subIndx, num, 1) } - // Field (5) 'Attestations' + // Field 36: PendingConsolidations { - 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 + if len(sszSlice36)%16 != 0 { + return fmt.Errorf("misaligned bytes: c.PendingConsolidations length is %d, which is not a multiple of 16: %w", len(sszSlice36), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice36) / 16 + if numElem > 64 { + return fmt.Errorf("ssz-max exceeded: c.PendingConsolidations has %d elements, ssz-max is 64: %w", numElem, ssz.ErrListTooBig) + } + c.PendingConsolidations = make([]*PendingConsolidation, numElem) + for i := 0; i < numElem; i++ { + var tmp *PendingConsolidation + tmp = new(PendingConsolidation) + tmpSlice := sszSlice36[i*16 : (1+i)*16] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("PendingConsolidations: %w", err) } + c.PendingConsolidations[i] = tmp } - hh.MerkleizeWithMixin(subIndx, num, 8) } - // Field (6) 'Deposits' + // Field 37: ProposerLookahead { - 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 + c.ProposerLookahead = make([]primitives.ValidatorIndex, 16) + for i := 0; i < 16; i++ { + var tmp primitives.ValidatorIndex + + tmpSlice := sszSlice37[i*8 : (1+i)*8] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("ProposerLookahead: %w", err) } + c.ProposerLookahead[i] = tmp } - hh.MerkleizeWithMixin(subIndx, num, 16) } - // Field (7) 'VoluntaryExits' + // Field 38: Builders { - 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 + if len(sszSlice38)%93 != 0 { + return fmt.Errorf("misaligned bytes: c.Builders length is %d, which is not a multiple of 93: %w", len(sszSlice38), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice38) / 93 + if numElem > 1099511627776 { + return fmt.Errorf("ssz-max exceeded: c.Builders has %d elements, ssz-max is 1099511627776: %w", numElem, ssz.ErrListTooBig) + } + c.Builders = make([]*Builder, numElem) + for i := 0; i < numElem; i++ { + var tmp *Builder + tmp = new(Builder) + tmpSlice := sszSlice38[i*93 : (1+i)*93] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Builders: %w", err) } + c.Builders[i] = tmp } - hh.MerkleizeWithMixin(subIndx, num, 16) } - // Field (8) 'SyncAggregate' - if err = b.SyncAggregate.HashTreeRootWith(hh); err != nil { - return + // Field 39: NextWithdrawalBuilderIndex + if err = c.NextWithdrawalBuilderIndex.UnmarshalSSZ(sszSlice39); err != nil { + return fmt.Errorf("NextWithdrawalBuilderIndex: %w", err) } - // Field (9) 'BlsToExecutionChanges' + // Field 40: ExecutionPayloadAvailability + c.ExecutionPayloadAvailability = make([]byte, 0, 8) + c.ExecutionPayloadAvailability = append(c.ExecutionPayloadAvailability, sszSlice40...) + + // Field 41: BuilderPendingPayments { - 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 + c.BuilderPendingPayments = make([]*BuilderPendingPayment, 16) + for i := 0; i < 16; i++ { + var tmp *BuilderPendingPayment + tmp = new(BuilderPendingPayment) + tmpSlice := sszSlice41[i*52 : (1+i)*52] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("BuilderPendingPayments: %w", err) } + c.BuilderPendingPayments[i] = tmp } - hh.MerkleizeWithMixin(subIndx, num, 16) - } - - // Field (10) 'SignedExecutionPayloadBid' - if err = b.SignedExecutionPayloadBid.HashTreeRootWith(hh); err != nil { - return } - // Field (11) 'PayloadAttestations' + // Field 42: BuilderPendingWithdrawals { - subIndx := hh.Index() - num := uint64(len(b.PayloadAttestations)) - if num > 4 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range b.PayloadAttestations { - if err = elem.HashTreeRootWith(hh); err != nil { - return + if len(sszSlice42)%36 != 0 { + return fmt.Errorf("misaligned bytes: c.BuilderPendingWithdrawals length is %d, which is not a multiple of 36: %w", len(sszSlice42), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice42) / 36 + if numElem > 1048576 { + return fmt.Errorf("ssz-max exceeded: c.BuilderPendingWithdrawals has %d elements, ssz-max is 1048576: %w", numElem, ssz.ErrListTooBig) + } + c.BuilderPendingWithdrawals = make([]*BuilderPendingWithdrawal, numElem) + for i := 0; i < numElem; i++ { + var tmp *BuilderPendingWithdrawal + tmp = new(BuilderPendingWithdrawal) + tmpSlice := sszSlice42[i*36 : (1+i)*36] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("BuilderPendingWithdrawals: %w", err) } + c.BuilderPendingWithdrawals[i] = tmp } - hh.MerkleizeWithMixin(subIndx, num, 4) - } - - // Field (12) 'ParentExecutionRequests' - if err = b.ParentExecutionRequests.HashTreeRootWith(hh); err != nil { - return - } - - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the SignedBeaconBlockGloas object -func (s *SignedBeaconBlockGloas) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) -} - -// MarshalSSZTo ssz marshals the SignedBeaconBlockGloas object to a target array -func (s *SignedBeaconBlockGloas) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(100) - - // Offset (0) 'Block' - dst = ssz.WriteOffset(dst, offset) - if s.Block == nil { - s.Block = new(BeaconBlockGloas) - } - offset += s.Block.SizeSSZ() - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.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 SignedBeaconBlockGloas object -func (s *SignedBeaconBlockGloas) 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 43: LatestExecutionPayloadBid + c.LatestExecutionPayloadBid = new(ExecutionPayloadBid) + if err = c.LatestExecutionPayloadBid.UnmarshalSSZ(sszSlice43); err != nil { + return fmt.Errorf("LatestExecutionPayloadBid: %w", err) } - // Field (1) 'Signature' - if cap(s.Signature) == 0 { - s.Signature = make([]byte, 0, len(buf[4:100])) + // Field 44: PayloadExpectedWithdrawals + { + if len(sszSlice44)%44 != 0 { + return fmt.Errorf("misaligned bytes: c.PayloadExpectedWithdrawals length is %d, which is not a multiple of 44: %w", len(sszSlice44), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice44) / 44 + if numElem > 4 { + return fmt.Errorf("ssz-max exceeded: c.PayloadExpectedWithdrawals has %d elements, ssz-max is 4: %w", numElem, ssz.ErrListTooBig) + } + c.PayloadExpectedWithdrawals = make([]*v1.Withdrawal, numElem) + for i := 0; i < numElem; i++ { + var tmp *v1.Withdrawal + tmp = new(v1.Withdrawal) + tmpSlice := sszSlice44[i*44 : (1+i)*44] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("PayloadExpectedWithdrawals: %w", err) + } + c.PayloadExpectedWithdrawals[i] = tmp + } } - s.Signature = append(s.Signature, buf[4:100]...) - // Field (0) 'Block' + // Field 45: PtcWindow { - buf = tail[o0:] - if s.Block == nil { - s.Block = new(BeaconBlockGloas) - } - if err = s.Block.UnmarshalSSZ(buf); err != nil { - return err + c.PtcWindow = make([]*PTCs, 24) + for i := 0; i < 24; i++ { + var tmp *PTCs + tmp = new(PTCs) + tmpSlice := sszSlice45[i*128 : (1+i)*128] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("PtcWindow: %w", err) + } + c.PtcWindow[i] = tmp } } return err } -// SizeSSZ returns the ssz encoded size in bytes for the SignedBeaconBlockGloas object -func (s *SignedBeaconBlockGloas) SizeSSZ() (size int) { - size = 100 - - // Field (0) 'Block' - if s.Block == nil { - s.Block = new(BeaconBlockGloas) +func (c *BeaconStateGloas) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - size += s.Block.SizeSSZ() - - return + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRoot ssz hashes the SignedBeaconBlockGloas object -func (s *SignedBeaconBlockGloas) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) -} - -// HashTreeRootWith ssz hashes the SignedBeaconBlockGloas object with a hasher -func (s *SignedBeaconBlockGloas) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *BeaconStateGloas) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Block' - if err = s.Block.HashTreeRootWith(hh); err != nil { - return + // Field 0: GenesisTime + hh.PutUint64(c.GenesisTime) + // Field 1: GenesisValidatorsRoot + if len(c.GenesisValidatorsRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.GenesisValidatorsRoot) + // Field 2: Slot + if err := c.Slot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Slot: %w", err) + } + // Field 3: Fork + if err := c.Fork.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Fork: %w", err) + } + // Field 4: LatestBlockHeader + if err := c.LatestBlockHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("LatestBlockHeader: %w", err) + } + // Field 5: BlockRoots + { + if len(c.BlockRoots) != 64 { + return ssz.ErrVectorLength + } + subIndx := hh.Index() + for _, o := range c.BlockRoots { + if len(o) != 32 { + return ssz.ErrBytesLength + } + hh.Append(o) + } + hh.Merkleize(subIndx) } - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 6: StateRoots + { + if len(c.StateRoots) != 64 { + return ssz.ErrVectorLength + } + subIndx := hh.Index() + for _, o := range c.StateRoots { + if len(o) != 32 { + return ssz.ErrBytesLength + } + hh.Append(o) + } + hh.Merkleize(subIndx) } - hh.PutBytes(s.Signature) - - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the BeaconStateGloas object -func (b *BeaconStateGloas) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} - -// MarshalSSZTo ssz marshals the BeaconStateGloas object to a target array -func (b *BeaconStateGloas) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(14405) - - // Field (0) 'GenesisTime' - dst = ssz.MarshalUint(dst, b.GenesisTime) - - // Field (1) 'GenesisValidatorsRoot' - if size := len(b.GenesisValidatorsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.GenesisValidatorsRoot", size, 32) - return + // Field 7: HistoricalRoots + { + if len(c.HistoricalRoots) > 16777216 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.HistoricalRoots { + if len(o) != 32 { + return ssz.ErrBytesLength + } + hh.Append(o) + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.HistoricalRoots)), 16777216) } - dst = append(dst, b.GenesisValidatorsRoot...) - - // Field (2) 'Slot' - dst = ssz.MarshalUint(dst, b.Slot) - - // Field (3) 'Fork' - if b.Fork == nil { - b.Fork = new(Fork) + // Field 8: Eth1Data + if err := c.Eth1Data.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Eth1Data: %w", err) } - if dst, err = b.Fork.MarshalSSZTo(dst); err != nil { - return + // Field 9: Eth1DataVotes + { + if len(c.Eth1DataVotes) > 32 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.Eth1DataVotes { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Eth1DataVotes: %w", err) + } + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Eth1DataVotes)), 32) } - - // Field (4) 'LatestBlockHeader' - if b.LatestBlockHeader == nil { - b.LatestBlockHeader = new(BeaconBlockHeader) + // Field 10: Eth1DepositIndex + hh.PutUint64(c.Eth1DepositIndex) + // Field 11: Validators + { + if len(c.Validators) > 1099511627776 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.Validators { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Validators: %w", err) + } + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Validators)), 1099511627776) } - if dst, err = b.LatestBlockHeader.MarshalSSZTo(dst); err != nil { - return + // Field 12: Balances + { + if len(c.Balances) > 1099511627776 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.Balances { + hh.AppendUint64(o) + } + hh.FillUpTo32() + numItems := uint64(len(c.Balances)) + hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(1099511627776, numItems, 8)) } - - // Field (5) 'BlockRoots' - if size := len(b.BlockRoots); size != 64 { - err = ssz.ErrVectorLengthFn("--.BlockRoots", size, 64) - return + // Field 13: RandaoMixes + { + if len(c.RandaoMixes) != 64 { + return ssz.ErrVectorLength + } + subIndx := hh.Index() + for _, o := range c.RandaoMixes { + if len(o) != 32 { + return ssz.ErrBytesLength + } + hh.Append(o) + } + hh.Merkleize(subIndx) } - for ii := 0; ii < 64; ii++ { - if size := len(b.BlockRoots[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockRoots[ii]", size, 32) - return + // Field 14: Slashings + { + if len(c.Slashings) != 64 { + return ssz.ErrVectorLength } - dst = append(dst, b.BlockRoots[ii]...) + subIndx := hh.Index() + for _, o := range c.Slashings { + hh.AppendUint64(o) + } + hh.Merkleize(subIndx) } + // Field 15: PreviousEpochParticipation - // Field (6) 'StateRoots' - if size := len(b.StateRoots); size != 64 { - err = ssz.ErrVectorLengthFn("--.StateRoots", size, 64) - return - } - for ii := 0; ii < 64; ii++ { - if size := len(b.StateRoots[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoots[ii]", size, 32) - return + { + if len(c.PreviousEpochParticipation) > 1099511627776 { + return ssz.ErrBytesLength } - dst = append(dst, b.StateRoots[ii]...) + subIndx := hh.Index() + hh.AppendBytes32(c.PreviousEpochParticipation) + numItems := uint64(len(c.PreviousEpochParticipation)) + hh.MerkleizeWithMixin(subIndx, numItems, (1099511627776*1+31)/32) } - // Offset (7) 'HistoricalRoots' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.HistoricalRoots) * 32 + // Field 16: CurrentEpochParticipation - // Field (8) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(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.MarshalUint(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 != 64 { - err = ssz.ErrVectorLengthFn("--.RandaoMixes", size, 64) - return - } - for ii := 0; ii < 64; ii++ { - if size := len(b.RandaoMixes[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.RandaoMixes[ii]", size, 32) - return + { + if len(c.CurrentEpochParticipation) > 1099511627776 { + return ssz.ErrBytesLength } - dst = append(dst, b.RandaoMixes[ii]...) + subIndx := hh.Index() + hh.AppendBytes32(c.CurrentEpochParticipation) + numItems := uint64(len(c.CurrentEpochParticipation)) + hh.MerkleizeWithMixin(subIndx, numItems, (1099511627776*1+31)/32) } - // Field (14) 'Slashings' - if size := len(b.Slashings); size != 64 { - err = ssz.ErrVectorLengthFn("--.Slashings", size, 64) - return + // Field 17: JustificationBits + if len([]byte(c.JustificationBits)) != 1 { + return ssz.ErrBytesLength } - for ii := 0; ii < 64; ii++ { - dst = ssz.MarshalUint(dst, b.Slashings[ii]) + hh.PutBytes([]byte(c.JustificationBits)) + // Field 18: PreviousJustifiedCheckpoint + if err := c.PreviousJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("PreviousJustifiedCheckpoint: %w", err) } - - // 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' - if size := len(b.JustificationBits); size != 1 { - err = ssz.ErrBytesLengthFn("--.JustificationBits", size, 1) - return + // Field 19: CurrentJustifiedCheckpoint + if err := c.CurrentJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("CurrentJustifiedCheckpoint: %w", err) } - dst = append(dst, b.JustificationBits...) - - // Field (18) 'PreviousJustifiedCheckpoint' - if b.PreviousJustifiedCheckpoint == nil { - b.PreviousJustifiedCheckpoint = new(Checkpoint) + // Field 20: FinalizedCheckpoint + if err := c.FinalizedCheckpoint.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("FinalizedCheckpoint: %w", err) } - if dst, err = b.PreviousJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { - return + // Field 21: InactivityScores + { + if len(c.InactivityScores) > 1099511627776 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.InactivityScores { + hh.AppendUint64(o) + } + hh.FillUpTo32() + numItems := uint64(len(c.InactivityScores)) + hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(1099511627776, numItems, 8)) } - - // Field (19) 'CurrentJustifiedCheckpoint' - if b.CurrentJustifiedCheckpoint == nil { - b.CurrentJustifiedCheckpoint = new(Checkpoint) + // Field 22: CurrentSyncCommittee + if err := c.CurrentSyncCommittee.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("CurrentSyncCommittee: %w", err) } - if dst, err = b.CurrentJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { - return + // Field 23: NextSyncCommittee + if err := c.NextSyncCommittee.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("NextSyncCommittee: %w", err) } - - // Field (20) 'FinalizedCheckpoint' - if b.FinalizedCheckpoint == nil { - b.FinalizedCheckpoint = new(Checkpoint) + // Field 24: LatestBlockHash + if len(c.LatestBlockHash) != 32 { + return ssz.ErrBytesLength } - if dst, err = b.FinalizedCheckpoint.MarshalSSZTo(dst); err != nil { - return + hh.PutBytes(c.LatestBlockHash) + // Field 25: NextWithdrawalIndex + hh.PutUint64(c.NextWithdrawalIndex) + // Field 26: NextWithdrawalValidatorIndex + if err := c.NextWithdrawalValidatorIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("NextWithdrawalValidatorIndex: %w", err) } - - // Offset (21) 'InactivityScores' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.InactivityScores) * 8 - - // Field (22) 'CurrentSyncCommittee' - if b.CurrentSyncCommittee == nil { - b.CurrentSyncCommittee = new(SyncCommittee) + // Field 27: HistoricalSummaries + { + if len(c.HistoricalSummaries) > 16777216 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.HistoricalSummaries { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("HistoricalSummaries: %w", err) + } + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.HistoricalSummaries)), 16777216) } - if dst, err = b.CurrentSyncCommittee.MarshalSSZTo(dst); err != nil { - return + // Field 28: DepositRequestsStartIndex + hh.PutUint64(c.DepositRequestsStartIndex) + // Field 29: DepositBalanceToConsume + if err := c.DepositBalanceToConsume.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("DepositBalanceToConsume: %w", err) } - - // Field (23) 'NextSyncCommittee' - if b.NextSyncCommittee == nil { - b.NextSyncCommittee = new(SyncCommittee) + // Field 30: ExitBalanceToConsume + if err := c.ExitBalanceToConsume.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ExitBalanceToConsume: %w", err) } - if dst, err = b.NextSyncCommittee.MarshalSSZTo(dst); err != nil { - return + // Field 31: EarliestExitEpoch + if err := c.EarliestExitEpoch.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("EarliestExitEpoch: %w", err) } - - // Field (24) 'LatestBlockHash' - if size := len(b.LatestBlockHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.LatestBlockHash", size, 32) - return + // Field 32: ConsolidationBalanceToConsume + if err := c.ConsolidationBalanceToConsume.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ConsolidationBalanceToConsume: %w", err) } - dst = append(dst, b.LatestBlockHash...) - - // Field (25) 'NextWithdrawalIndex' - dst = ssz.MarshalUint(dst, b.NextWithdrawalIndex) - - // Field (26) 'NextWithdrawalValidatorIndex' - dst = ssz.MarshalUint(dst, b.NextWithdrawalValidatorIndex) - - // Offset (27) 'HistoricalSummaries' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.HistoricalSummaries) * 64 - - // Field (28) 'DepositRequestsStartIndex' - dst = ssz.MarshalUint(dst, b.DepositRequestsStartIndex) - - // Field (29) 'DepositBalanceToConsume' - dst = ssz.MarshalUint(dst, b.DepositBalanceToConsume) - - // Field (30) 'ExitBalanceToConsume' - dst = ssz.MarshalUint(dst, b.ExitBalanceToConsume) - - // Field (31) 'EarliestExitEpoch' - dst = ssz.MarshalUint(dst, b.EarliestExitEpoch) - - // Field (32) 'ConsolidationBalanceToConsume' - dst = ssz.MarshalUint(dst, b.ConsolidationBalanceToConsume) - - // Field (33) 'EarliestConsolidationEpoch' - dst = ssz.MarshalUint(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) - offset += len(b.PendingConsolidations) * 16 - - // Field (37) 'ProposerLookahead' - if size := len(b.ProposerLookahead); size != 16 { - err = ssz.ErrVectorLengthFn("--.ProposerLookahead", size, 16) - return + // Field 33: EarliestConsolidationEpoch + if err := c.EarliestConsolidationEpoch.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("EarliestConsolidationEpoch: %w", err) } - for ii := 0; ii < 16; ii++ { - dst = ssz.MarshalUint(dst, b.ProposerLookahead[ii]) + // Field 34: PendingDeposits + { + if len(c.PendingDeposits) > 134217728 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.PendingDeposits { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("PendingDeposits: %w", err) + } + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.PendingDeposits)), 134217728) } - - // Offset (38) 'Builders' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.Builders) * 93 - - // Field (39) 'NextWithdrawalBuilderIndex' - dst = ssz.MarshalUint(dst, b.NextWithdrawalBuilderIndex) - - // Field (40) 'ExecutionPayloadAvailability' - if size := len(b.ExecutionPayloadAvailability); size != 8 { - err = ssz.ErrBytesLengthFn("--.ExecutionPayloadAvailability", size, 8) - return + // Field 35: PendingPartialWithdrawals + { + if len(c.PendingPartialWithdrawals) > 64 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.PendingPartialWithdrawals { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("PendingPartialWithdrawals: %w", err) + } + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.PendingPartialWithdrawals)), 64) } - dst = append(dst, b.ExecutionPayloadAvailability...) - - // Field (41) 'BuilderPendingPayments' - if size := len(b.BuilderPendingPayments); size != 16 { - err = ssz.ErrVectorLengthFn("--.BuilderPendingPayments", size, 16) - return + // Field 36: PendingConsolidations + { + if len(c.PendingConsolidations) > 64 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.PendingConsolidations { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("PendingConsolidations: %w", err) + } + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.PendingConsolidations)), 64) } - for ii := 0; ii < 16; ii++ { - if dst, err = b.BuilderPendingPayments[ii].MarshalSSZTo(dst); err != nil { - return + // Field 37: ProposerLookahead + { + if len(c.ProposerLookahead) != 16 { + return ssz.ErrVectorLength + } + subIndx := hh.Index() + for _, o := range c.ProposerLookahead { + hh.AppendUint64(uint64(o)) } + hh.Merkleize(subIndx) } - - // Offset (42) 'BuilderPendingWithdrawals' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.BuilderPendingWithdrawals) * 36 - - // Offset (43) 'LatestExecutionPayloadBid' - dst = ssz.WriteOffset(dst, offset) - if b.LatestExecutionPayloadBid == nil { - b.LatestExecutionPayloadBid = new(ExecutionPayloadBid) + // Field 38: Builders + { + if len(c.Builders) > 1099511627776 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.Builders { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Builders: %w", err) + } + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Builders)), 1099511627776) } - offset += b.LatestExecutionPayloadBid.SizeSSZ() - - // Offset (44) 'PayloadExpectedWithdrawals' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.PayloadExpectedWithdrawals) * 44 - - // Field (45) 'PtcWindow' - if size := len(b.PtcWindow); size != 24 { - err = ssz.ErrVectorLengthFn("--.PtcWindow", size, 24) - return + // Field 39: NextWithdrawalBuilderIndex + if err := c.NextWithdrawalBuilderIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("NextWithdrawalBuilderIndex: %w", err) } - for ii := 0; ii < 24; ii++ { - if dst, err = b.PtcWindow[ii].MarshalSSZTo(dst); err != nil { - return - } + // Field 40: ExecutionPayloadAvailability + if len(c.ExecutionPayloadAvailability) != 8 { + return ssz.ErrBytesLength } - - // Field (7) 'HistoricalRoots' - if size := len(b.HistoricalRoots); size > 16777216 { - err = ssz.ErrListTooBigFn("--.HistoricalRoots", size, 16777216) - return + hh.PutBytes(c.ExecutionPayloadAvailability) + // Field 41: BuilderPendingPayments + { + if len(c.BuilderPendingPayments) != 16 { + return ssz.ErrVectorLength + } + subIndx := hh.Index() + for _, o := range c.BuilderPendingPayments { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("BuilderPendingPayments: %w", err) + } + } + hh.Merkleize(subIndx) } - for ii := 0; ii < len(b.HistoricalRoots); ii++ { - if size := len(b.HistoricalRoots[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.HistoricalRoots[ii]", size, 32) - return + // Field 42: BuilderPendingWithdrawals + { + if len(c.BuilderPendingWithdrawals) > 1048576 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.BuilderPendingWithdrawals { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("BuilderPendingWithdrawals: %w", err) + } } - dst = append(dst, b.HistoricalRoots[ii]...) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.BuilderPendingWithdrawals)), 1048576) } - - // Field (9) 'Eth1DataVotes' - if size := len(b.Eth1DataVotes); size > 32 { - err = ssz.ErrListTooBigFn("--.Eth1DataVotes", size, 32) - return + // Field 43: LatestExecutionPayloadBid + if err := c.LatestExecutionPayloadBid.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("LatestExecutionPayloadBid: %w", err) } - for ii := 0; ii < len(b.Eth1DataVotes); ii++ { - if dst, err = b.Eth1DataVotes[ii].MarshalSSZTo(dst); err != nil { - return + // Field 44: PayloadExpectedWithdrawals + { + if len(c.PayloadExpectedWithdrawals) > 4 { + return ssz.ErrListTooBig } + subIndx := hh.Index() + for _, o := range c.PayloadExpectedWithdrawals { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("PayloadExpectedWithdrawals: %w", err) + } + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.PayloadExpectedWithdrawals)), 4) } - - // Field (11) 'Validators' - if size := len(b.Validators); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.Validators", size, 1099511627776) - return - } - for ii := 0; ii < len(b.Validators); ii++ { - if dst, err = b.Validators[ii].MarshalSSZTo(dst); err != nil { - return + // Field 45: PtcWindow + { + if len(c.PtcWindow) != 24 { + return ssz.ErrVectorLength + } + subIndx := hh.Index() + for _, o := range c.PtcWindow { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("PtcWindow: %w", err) + } } + hh.Merkleize(subIndx) } + hh.Merkleize(indx) + return nil +} - // Field (12) 'Balances' - if size := len(b.Balances); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.Balances", size, 1099511627776) - return - } - for ii := 0; ii < len(b.Balances); ii++ { - dst = ssz.MarshalUint(dst, b.Balances[ii]) +func (c *BlindedExecutionPayloadEnvelope) SizeSSZ() int { + size := 148 + if c.ExecutionRequests == nil { + c.ExecutionRequests = new(v1.ExecutionRequestsGloas) } + size += c.ExecutionRequests.SizeSSZ() + return size +} - // Field (15) 'PreviousEpochParticipation' - if size := len(b.PreviousEpochParticipation); size > 1099511627776 { - err = ssz.ErrBytesLengthFn("--.PreviousEpochParticipation", size, 1099511627776) - return - } - dst = append(dst, b.PreviousEpochParticipation...) +func (c *BlindedExecutionPayloadEnvelope) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (16) 'CurrentEpochParticipation' - if size := len(b.CurrentEpochParticipation); size > 1099511627776 { - err = ssz.ErrBytesLengthFn("--.CurrentEpochParticipation", size, 1099511627776) - return - } - dst = append(dst, b.CurrentEpochParticipation...) +func (c *BlindedExecutionPayloadEnvelope) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 148 - // Field (21) 'InactivityScores' - if size := len(b.InactivityScores); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.InactivityScores", size, 1099511627776) - return - } - for ii := 0; ii < len(b.InactivityScores); ii++ { - dst = ssz.MarshalUint(dst, b.InactivityScores[ii]) + // Field 0: BlockHash + if len(c.BlockHash) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.BlockHash...) - // Field (27) 'HistoricalSummaries' - if size := len(b.HistoricalSummaries); size > 16777216 { - err = ssz.ErrListTooBigFn("--.HistoricalSummaries", size, 16777216) - return - } - for ii := 0; ii < len(b.HistoricalSummaries); ii++ { - if dst, err = b.HistoricalSummaries[ii].MarshalSSZTo(dst); err != nil { - return - } + // Field 1: ExecutionRequests + if c.ExecutionRequests == nil { + c.ExecutionRequests = new(v1.ExecutionRequestsGloas) } + dst = ssz.WriteOffset(dst, offset) + offset += c.ExecutionRequests.SizeSSZ() - // Field (34) 'PendingDeposits' - if size := len(b.PendingDeposits); size > 134217728 { - err = ssz.ErrListTooBigFn("--.PendingDeposits", size, 134217728) - return - } - for ii := 0; ii < len(b.PendingDeposits); ii++ { - if dst, err = b.PendingDeposits[ii].MarshalSSZTo(dst); err != nil { - return - } + // Field 2: BuilderIndex + if dst, err = c.BuilderIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("BuilderIndex: %w", err) } - // Field (35) 'PendingPartialWithdrawals' - if size := len(b.PendingPartialWithdrawals); size > 64 { - err = ssz.ErrListTooBigFn("--.PendingPartialWithdrawals", size, 64) - return + // Field 3: BeaconBlockRoot + if len(c.BeaconBlockRoot) != 32 { + return nil, ssz.ErrBytesLength } - for ii := 0; ii < len(b.PendingPartialWithdrawals); ii++ { - if dst, err = b.PendingPartialWithdrawals[ii].MarshalSSZTo(dst); err != nil { - return - } + dst = append(dst, c.BeaconBlockRoot...) + + // Field 4: Slot + if dst, err = c.Slot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Slot: %w", err) } - // Field (36) 'PendingConsolidations' - if size := len(b.PendingConsolidations); size > 64 { - err = ssz.ErrListTooBigFn("--.PendingConsolidations", size, 64) - return + // Field 5: ParentBlockHash + if len(c.ParentBlockHash) != 32 { + return nil, ssz.ErrBytesLength } - for ii := 0; ii < len(b.PendingConsolidations); ii++ { - if dst, err = b.PendingConsolidations[ii].MarshalSSZTo(dst); err != nil { - return - } + dst = append(dst, c.ParentBlockHash...) + + // Field 6: ParentBeaconBlockRoot + if len(c.ParentBeaconBlockRoot) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.ParentBeaconBlockRoot...) - // Field (38) 'Builders' - if size := len(b.Builders); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.Builders", size, 1099511627776) - return + // Field 1: ExecutionRequests + if dst, err = c.ExecutionRequests.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ExecutionRequests: %w", err) } - for ii := 0; ii < len(b.Builders); ii++ { - if dst, err = b.Builders[ii].MarshalSSZTo(dst); err != nil { - return - } + return dst, err +} + +func (c *BlindedExecutionPayloadEnvelope) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 148 { + return ssz.ErrSize } - // Field (42) 'BuilderPendingWithdrawals' - if size := len(b.BuilderPendingWithdrawals); size > 1048576 { - err = ssz.ErrListTooBigFn("--.BuilderPendingWithdrawals", size, 1048576) - return + sszSlice0 := buf[0:32] // c.BlockHash + sszSlice2 := buf[36:44] // c.BuilderIndex + sszSlice3 := buf[44:76] // c.BeaconBlockRoot + sszSlice4 := buf[76:84] // c.Slot + sszSlice5 := buf[84:116] // c.ParentBlockHash + sszSlice6 := buf[116:148] // c.ParentBeaconBlockRoot + + sszVarOffset1 := ssz.ReadOffset(buf[32:36]) // c.ExecutionRequests + if sszVarOffset1 != 148 { + return ssz.ErrInvalidVariableOffset } - for ii := 0; ii < len(b.BuilderPendingWithdrawals); ii++ { - if dst, err = b.BuilderPendingWithdrawals[ii].MarshalSSZTo(dst); err != nil { - return - } + if sszVarOffset1 > size { + return ssz.ErrOffset } + sszSlice1 := buf[sszVarOffset1:] // c.ExecutionRequests - // Field (43) 'LatestExecutionPayloadBid' - if dst, err = b.LatestExecutionPayloadBid.MarshalSSZTo(dst); err != nil { - return + // Field 0: BlockHash + c.BlockHash = make([]byte, 0, 32) + c.BlockHash = append(c.BlockHash, sszSlice0...) + + // Field 1: ExecutionRequests + c.ExecutionRequests = new(v1.ExecutionRequestsGloas) + if err = c.ExecutionRequests.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("ExecutionRequests: %w", err) } - // Field (44) 'PayloadExpectedWithdrawals' - if size := len(b.PayloadExpectedWithdrawals); size > 4 { - err = ssz.ErrListTooBigFn("--.PayloadExpectedWithdrawals", size, 4) - return + // Field 2: BuilderIndex + if err = c.BuilderIndex.UnmarshalSSZ(sszSlice2); err != nil { + return fmt.Errorf("BuilderIndex: %w", err) } - for ii := 0; ii < len(b.PayloadExpectedWithdrawals); ii++ { - if dst, err = b.PayloadExpectedWithdrawals[ii].MarshalSSZTo(dst); err != nil { - return - } + + // Field 3: BeaconBlockRoot + c.BeaconBlockRoot = make([]byte, 0, 32) + c.BeaconBlockRoot = append(c.BeaconBlockRoot, sszSlice3...) + + // Field 4: Slot + if err = c.Slot.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("Slot: %w", err) } - return + // Field 5: ParentBlockHash + c.ParentBlockHash = make([]byte, 0, 32) + c.ParentBlockHash = append(c.ParentBlockHash, sszSlice5...) + + // Field 6: ParentBeaconBlockRoot + c.ParentBeaconBlockRoot = make([]byte, 0, 32) + c.ParentBeaconBlockRoot = append(c.ParentBeaconBlockRoot, sszSlice6...) + return err } -// UnmarshalSSZ ssz unmarshals the BeaconStateGloas object -func (b *BeaconStateGloas) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 14405 { - return ssz.ErrSize +func (c *BlindedExecutionPayloadEnvelope) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - tail := buf - var o7, o9, o11, o12, o15, o16, o21, o27, o34, o35, o36, o38, o42, o43, o44 uint64 +func (c *BlindedExecutionPayloadEnvelope) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: BlockHash + if len(c.BlockHash) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.BlockHash) + // Field 1: ExecutionRequests + if err := c.ExecutionRequests.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ExecutionRequests: %w", err) + } + // Field 2: BuilderIndex + if err := c.BuilderIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("BuilderIndex: %w", err) + } + // Field 3: BeaconBlockRoot + if len(c.BeaconBlockRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.BeaconBlockRoot) + // Field 4: Slot + if err := c.Slot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Slot: %w", err) + } + // Field 5: ParentBlockHash + if len(c.ParentBlockHash) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ParentBlockHash) + // Field 6: ParentBeaconBlockRoot + if len(c.ParentBeaconBlockRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ParentBeaconBlockRoot) + hh.Merkleize(indx) + return nil +} - // Field (0) 'GenesisTime' - b.GenesisTime = ssz.UnmarshallUint[uint64](buf[0:8]) +func (c *Builder) SizeSSZ() int { + size := 93 - // 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]...) + return size +} - // Field (2) 'Slot' - b.Slot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[40:48]) +func (c *Builder) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (3) 'Fork' - if b.Fork == nil { - b.Fork = new(Fork) - } - if err = b.Fork.UnmarshalSSZ(buf[48:64]); err != nil { - return err - } +func (c *Builder) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (4) 'LatestBlockHeader' - if b.LatestBlockHeader == nil { - b.LatestBlockHeader = new(BeaconBlockHeader) - } - if err = b.LatestBlockHeader.UnmarshalSSZ(buf[64:176]); err != nil { - return err + // Field 0: Pubkey + if len(c.Pubkey) != 48 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.Pubkey...) - // Field (5) 'BlockRoots' - b.BlockRoots = make([][]byte, 64) - for ii := 0; ii < 64; ii++ { - if cap(b.BlockRoots[ii]) == 0 { - b.BlockRoots[ii] = make([]byte, 0, len(buf[176:2224][ii*32:(ii+1)*32])) - } - b.BlockRoots[ii] = append(b.BlockRoots[ii], buf[176:2224][ii*32:(ii+1)*32]...) + // Field 1: Version + if len(c.Version) != 1 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.Version...) - // Field (6) 'StateRoots' - b.StateRoots = make([][]byte, 64) - for ii := 0; ii < 64; ii++ { - if cap(b.StateRoots[ii]) == 0 { - b.StateRoots[ii] = make([]byte, 0, len(buf[2224:4272][ii*32:(ii+1)*32])) - } - b.StateRoots[ii] = append(b.StateRoots[ii], buf[2224:4272][ii*32:(ii+1)*32]...) + // Field 2: ExecutionAddress + if len(c.ExecutionAddress) != 20 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.ExecutionAddress...) - // Offset (7) 'HistoricalRoots' - if o7 = ssz.ReadOffset(buf[4272:4276]); o7 > size { - return ssz.ErrOffset + // Field 3: Balance + if dst, err = c.Balance.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Balance: %w", err) } - if o7 != 14405 { - return ssz.ErrInvalidVariableOffset + // Field 4: DepositEpoch + if dst, err = c.DepositEpoch.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("DepositEpoch: %w", err) } - // Field (8) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(Eth1Data) - } - if err = b.Eth1Data.UnmarshalSSZ(buf[4276:4348]); err != nil { - return err + // Field 5: WithdrawableEpoch + if dst, err = c.WithdrawableEpoch.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("WithdrawableEpoch: %w", err) } - // Offset (9) 'Eth1DataVotes' - if o9 = ssz.ReadOffset(buf[4348:4352]); o9 > size || o7 > o9 { - return ssz.ErrOffset + return dst, err +} + +func (c *Builder) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 93 { + return ssz.ErrSize } - // Field (10) 'Eth1DepositIndex' - b.Eth1DepositIndex = ssz.UnmarshallUint[uint64](buf[4352:4360]) + sszSlice0 := buf[0:48] // c.Pubkey + sszSlice1 := buf[48:49] // c.Version + sszSlice2 := buf[49:69] // c.ExecutionAddress + sszSlice3 := buf[69:77] // c.Balance + sszSlice4 := buf[77:85] // c.DepositEpoch + sszSlice5 := buf[85:93] // c.WithdrawableEpoch - // Offset (11) 'Validators' - if o11 = ssz.ReadOffset(buf[4360:4364]); o11 > size || o9 > o11 { - return ssz.ErrOffset - } + // Field 0: Pubkey + c.Pubkey = make([]byte, 0, 48) + c.Pubkey = append(c.Pubkey, sszSlice0...) - // Offset (12) 'Balances' - if o12 = ssz.ReadOffset(buf[4364:4368]); o12 > size || o11 > o12 { - return ssz.ErrOffset - } + // Field 1: Version + c.Version = make([]byte, 0, 1) + c.Version = append(c.Version, sszSlice1...) - // Field (13) 'RandaoMixes' - b.RandaoMixes = make([][]byte, 64) - for ii := 0; ii < 64; ii++ { - if cap(b.RandaoMixes[ii]) == 0 { - b.RandaoMixes[ii] = make([]byte, 0, len(buf[4368:6416][ii*32:(ii+1)*32])) - } - b.RandaoMixes[ii] = append(b.RandaoMixes[ii], buf[4368:6416][ii*32:(ii+1)*32]...) - } + // Field 2: ExecutionAddress + c.ExecutionAddress = make([]byte, 0, 20) + c.ExecutionAddress = append(c.ExecutionAddress, sszSlice2...) - // Field (14) 'Slashings' - b.Slashings = ssz.ExtendUint(b.Slashings, 64) - for ii := 0; ii < 64; ii++ { - b.Slashings[ii] = ssz.UnmarshallUint[uint64](buf[6416:6928][ii*8 : (ii+1)*8]) + // Field 3: Balance + if err = c.Balance.UnmarshalSSZ(sszSlice3); err != nil { + return fmt.Errorf("Balance: %w", err) } - // Offset (15) 'PreviousEpochParticipation' - if o15 = ssz.ReadOffset(buf[6928:6932]); o15 > size || o12 > o15 { - return ssz.ErrOffset + // Field 4: DepositEpoch + if err = c.DepositEpoch.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("DepositEpoch: %w", err) } - // Offset (16) 'CurrentEpochParticipation' - if o16 = ssz.ReadOffset(buf[6932:6936]); o16 > size || o15 > o16 { - return ssz.ErrOffset + // Field 5: WithdrawableEpoch + if err = c.WithdrawableEpoch.UnmarshalSSZ(sszSlice5); err != nil { + return fmt.Errorf("WithdrawableEpoch: %w", err) } + return err +} - // Field (17) 'JustificationBits' - if cap(b.JustificationBits) == 0 { - b.JustificationBits = make([]byte, 0, len(buf[6936:6937])) +func (c *Builder) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - b.JustificationBits = append(b.JustificationBits, buf[6936:6937]...) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (18) 'PreviousJustifiedCheckpoint' - if b.PreviousJustifiedCheckpoint == nil { - b.PreviousJustifiedCheckpoint = new(Checkpoint) +func (c *Builder) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Pubkey + if len(c.Pubkey) != 48 { + return ssz.ErrBytesLength } - if err = b.PreviousJustifiedCheckpoint.UnmarshalSSZ(buf[6937:6977]); err != nil { - return err + hh.PutBytes(c.Pubkey) + // Field 1: Version + if len(c.Version) != 1 { + return ssz.ErrBytesLength } - - // Field (19) 'CurrentJustifiedCheckpoint' - if b.CurrentJustifiedCheckpoint == nil { - b.CurrentJustifiedCheckpoint = new(Checkpoint) + hh.PutBytes(c.Version) + // Field 2: ExecutionAddress + if len(c.ExecutionAddress) != 20 { + return ssz.ErrBytesLength } - if err = b.CurrentJustifiedCheckpoint.UnmarshalSSZ(buf[6977:7017]); err != nil { - return err + hh.PutBytes(c.ExecutionAddress) + // Field 3: Balance + if err := c.Balance.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Balance: %w", err) } - - // Field (20) 'FinalizedCheckpoint' - if b.FinalizedCheckpoint == nil { - b.FinalizedCheckpoint = new(Checkpoint) + // Field 4: DepositEpoch + if err := c.DepositEpoch.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("DepositEpoch: %w", err) } - if err = b.FinalizedCheckpoint.UnmarshalSSZ(buf[7017:7057]); err != nil { - return err + // Field 5: WithdrawableEpoch + if err := c.WithdrawableEpoch.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("WithdrawableEpoch: %w", err) } + hh.Merkleize(indx) + return nil +} - // Offset (21) 'InactivityScores' - if o21 = ssz.ReadOffset(buf[7057:7061]); o21 > size || o16 > o21 { - return ssz.ErrOffset - } +func (c *BuilderPendingPayment) SizeSSZ() int { + size := 52 - // Field (22) 'CurrentSyncCommittee' - if b.CurrentSyncCommittee == nil { - b.CurrentSyncCommittee = new(SyncCommittee) - } - if err = b.CurrentSyncCommittee.UnmarshalSSZ(buf[7061:8645]); err != nil { - return err + return size +} + +func (c *BuilderPendingPayment) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} + +func (c *BuilderPendingPayment) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + + // Field 0: Weight + if dst, err = c.Weight.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Weight: %w", err) } - // Field (23) 'NextSyncCommittee' - if b.NextSyncCommittee == nil { - b.NextSyncCommittee = new(SyncCommittee) + // Field 1: Withdrawal + if c.Withdrawal == nil { + c.Withdrawal = new(BuilderPendingWithdrawal) } - if err = b.NextSyncCommittee.UnmarshalSSZ(buf[8645:10229]); err != nil { - return err + if dst, err = c.Withdrawal.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Withdrawal: %w", err) } - // Field (24) 'LatestBlockHash' - if cap(b.LatestBlockHash) == 0 { - b.LatestBlockHash = make([]byte, 0, len(buf[10229:10261])) + // Field 2: ProposerIndex + if dst, err = c.ProposerIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ProposerIndex: %w", err) } - b.LatestBlockHash = append(b.LatestBlockHash, buf[10229:10261]...) - // Field (25) 'NextWithdrawalIndex' - b.NextWithdrawalIndex = ssz.UnmarshallUint[uint64](buf[10261:10269]) + return dst, err +} + +func (c *BuilderPendingPayment) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 52 { + return ssz.ErrSize + } - // Field (26) 'NextWithdrawalValidatorIndex' - b.NextWithdrawalValidatorIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[10269:10277]) + sszSlice0 := buf[0:8] // c.Weight + sszSlice1 := buf[8:44] // c.Withdrawal + sszSlice2 := buf[44:52] // c.ProposerIndex - // Offset (27) 'HistoricalSummaries' - if o27 = ssz.ReadOffset(buf[10277:10281]); o27 > size || o21 > o27 { - return ssz.ErrOffset + // Field 0: Weight + if err = c.Weight.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Weight: %w", err) } - // Field (28) 'DepositRequestsStartIndex' - b.DepositRequestsStartIndex = ssz.UnmarshallUint[uint64](buf[10281:10289]) + // Field 1: Withdrawal + c.Withdrawal = new(BuilderPendingWithdrawal) + if err = c.Withdrawal.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Withdrawal: %w", err) + } - // Field (29) 'DepositBalanceToConsume' - b.DepositBalanceToConsume = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Gwei](buf[10289:10297]) + // Field 2: ProposerIndex + if err = c.ProposerIndex.UnmarshalSSZ(sszSlice2); err != nil { + return fmt.Errorf("ProposerIndex: %w", err) + } + return err +} - // Field (30) 'ExitBalanceToConsume' - b.ExitBalanceToConsume = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Gwei](buf[10297:10305]) +func (c *BuilderPendingPayment) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (31) 'EarliestExitEpoch' - b.EarliestExitEpoch = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Epoch](buf[10305:10313]) +func (c *BuilderPendingPayment) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Weight + if err := c.Weight.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Weight: %w", err) + } + // Field 1: Withdrawal + if err := c.Withdrawal.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Withdrawal: %w", err) + } + // Field 2: ProposerIndex + if err := c.ProposerIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ProposerIndex: %w", err) + } + hh.Merkleize(indx) + return nil +} - // Field (32) 'ConsolidationBalanceToConsume' - b.ConsolidationBalanceToConsume = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Gwei](buf[10313:10321]) +func (c *BuilderPendingWithdrawal) SizeSSZ() int { + size := 36 - // Field (33) 'EarliestConsolidationEpoch' - b.EarliestConsolidationEpoch = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Epoch](buf[10321:10329]) + return size +} - // Offset (34) 'PendingDeposits' - if o34 = ssz.ReadOffset(buf[10329:10333]); o34 > size || o27 > o34 { - return ssz.ErrOffset - } +func (c *BuilderPendingWithdrawal) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Offset (35) 'PendingPartialWithdrawals' - if o35 = ssz.ReadOffset(buf[10333:10337]); o35 > size || o34 > o35 { - return ssz.ErrOffset - } +func (c *BuilderPendingWithdrawal) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Offset (36) 'PendingConsolidations' - if o36 = ssz.ReadOffset(buf[10337:10341]); o36 > size || o35 > o36 { - return ssz.ErrOffset + // Field 0: FeeRecipient + if len(c.FeeRecipient) != 20 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.FeeRecipient...) - // Field (37) 'ProposerLookahead' - b.ProposerLookahead = ssz.ExtendUint(b.ProposerLookahead, 16) - for ii := 0; ii < 16; ii++ { - b.ProposerLookahead[ii] = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[10341:10469][ii*8 : (ii+1)*8]) + // Field 1: Amount + if dst, err = c.Amount.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Amount: %w", err) } - // Offset (38) 'Builders' - if o38 = ssz.ReadOffset(buf[10469:10473]); o38 > size || o36 > o38 { - return ssz.ErrOffset + // Field 2: BuilderIndex + if dst, err = c.BuilderIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("BuilderIndex: %w", err) } - // Field (39) 'NextWithdrawalBuilderIndex' - b.NextWithdrawalBuilderIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.BuilderIndex](buf[10473:10481]) + return dst, err +} - // Field (40) 'ExecutionPayloadAvailability' - if cap(b.ExecutionPayloadAvailability) == 0 { - b.ExecutionPayloadAvailability = make([]byte, 0, len(buf[10481:10489])) +func (c *BuilderPendingWithdrawal) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 36 { + return ssz.ErrSize } - b.ExecutionPayloadAvailability = append(b.ExecutionPayloadAvailability, buf[10481:10489]...) - // Field (41) 'BuilderPendingPayments' - b.BuilderPendingPayments = make([]*BuilderPendingPayment, 16) - for ii := 0; ii < 16; ii++ { - if b.BuilderPendingPayments[ii] == nil { - b.BuilderPendingPayments[ii] = new(BuilderPendingPayment) - } - if err = b.BuilderPendingPayments[ii].UnmarshalSSZ(buf[10489:11321][ii*52 : (ii+1)*52]); err != nil { - return err - } - } + sszSlice0 := buf[0:20] // c.FeeRecipient + sszSlice1 := buf[20:28] // c.Amount + sszSlice2 := buf[28:36] // c.BuilderIndex - // Offset (42) 'BuilderPendingWithdrawals' - if o42 = ssz.ReadOffset(buf[11321:11325]); o42 > size || o38 > o42 { - return ssz.ErrOffset - } + // Field 0: FeeRecipient + c.FeeRecipient = make([]byte, 0, 20) + c.FeeRecipient = append(c.FeeRecipient, sszSlice0...) - // Offset (43) 'LatestExecutionPayloadBid' - if o43 = ssz.ReadOffset(buf[11325:11329]); o43 > size || o42 > o43 { - return ssz.ErrOffset + // Field 1: Amount + if err = c.Amount.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Amount: %w", err) } - // Offset (44) 'PayloadExpectedWithdrawals' - if o44 = ssz.ReadOffset(buf[11329:11333]); o44 > size || o43 > o44 { - return ssz.ErrOffset + // Field 2: BuilderIndex + if err = c.BuilderIndex.UnmarshalSSZ(sszSlice2); err != nil { + return fmt.Errorf("BuilderIndex: %w", err) } + return err +} - // Field (45) 'PtcWindow' - b.PtcWindow = make([]*PTCs, 24) - for ii := 0; ii < 24; ii++ { - if b.PtcWindow[ii] == nil { - b.PtcWindow[ii] = new(PTCs) - } - if err = b.PtcWindow[ii].UnmarshalSSZ(buf[11333:14405][ii*128 : (ii+1)*128]); err != nil { - return err - } +func (c *BuilderPendingWithdrawal) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // 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]...) - } +func (c *BuilderPendingWithdrawal) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: FeeRecipient + if len(c.FeeRecipient) != 20 { + return ssz.ErrBytesLength } - - // Field (9) 'Eth1DataVotes' - { - buf = tail[o9:o11] - num, err := ssz.DivideInt2(len(buf), 72, 32) - if err != nil { - return err - } - b.Eth1DataVotes = make([]*Eth1Data, num) - for ii := 0; ii < num; ii++ { - if b.Eth1DataVotes[ii] == nil { - b.Eth1DataVotes[ii] = new(Eth1Data) - } - if err = b.Eth1DataVotes[ii].UnmarshalSSZ(buf[ii*72 : (ii+1)*72]); err != nil { - return err - } - } + hh.PutBytes(c.FeeRecipient) + // Field 1: Amount + if err := c.Amount.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Amount: %w", err) } - - // Field (11) 'Validators' - { - buf = tail[o11:o12] - num, err := ssz.DivideInt2(len(buf), 121, 1099511627776) - if err != nil { - return err - } - b.Validators = make([]*Validator, num) - for ii := 0; ii < num; ii++ { - if b.Validators[ii] == nil { - b.Validators[ii] = new(Validator) - } - if err = b.Validators[ii].UnmarshalSSZ(buf[ii*121 : (ii+1)*121]); err != nil { - return err - } - } + // Field 2: BuilderIndex + if err := c.BuilderIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("BuilderIndex: %w", err) } + hh.Merkleize(indx) + return nil +} - // Field (12) 'Balances' - { - buf = tail[o12:o15] - num, err := ssz.DivideInt2(len(buf), 8, 1099511627776) - if err != nil { - return err - } - b.Balances = ssz.ExtendUint(b.Balances, num) - for ii := 0; ii < num; ii++ { - b.Balances[ii] = ssz.UnmarshallUint[uint64](buf[ii*8 : (ii+1)*8]) - } +func (c *BuilderPreferencesRequestV1) SizeSSZ() int { + size := 12 + if c.Auth == nil { + c.Auth = new(SignedRequestAuthV1) } + size += c.Auth.SizeSSZ() + return size +} - // 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...) - } +func (c *BuilderPreferencesRequestV1) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // 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...) - } +func (c *BuilderPreferencesRequestV1) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 12 - // Field (21) 'InactivityScores' - { - buf = tail[o21:o27] - num, err := ssz.DivideInt2(len(buf), 8, 1099511627776) - if err != nil { - return err - } - b.InactivityScores = ssz.ExtendUint(b.InactivityScores, num) - for ii := 0; ii < num; ii++ { - b.InactivityScores[ii] = ssz.UnmarshallUint[uint64](buf[ii*8 : (ii+1)*8]) - } + // Field 0: Preferences + if c.Preferences == nil { + c.Preferences = new(BuilderPreferencesV1) } - - // Field (27) 'HistoricalSummaries' - { - buf = tail[o27:o34] - num, err := ssz.DivideInt2(len(buf), 64, 16777216) - if err != nil { - return err - } - b.HistoricalSummaries = make([]*HistoricalSummary, num) - for ii := 0; ii < num; ii++ { - if b.HistoricalSummaries[ii] == nil { - b.HistoricalSummaries[ii] = new(HistoricalSummary) - } - if err = b.HistoricalSummaries[ii].UnmarshalSSZ(buf[ii*64 : (ii+1)*64]); err != nil { - return err - } - } + if dst, err = c.Preferences.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Preferences: %w", err) } - // Field (34) 'PendingDeposits' - { - buf = tail[o34:o35] - num, err := ssz.DivideInt2(len(buf), 192, 134217728) - if err != nil { - return err - } - b.PendingDeposits = make([]*PendingDeposit, num) - for ii := 0; ii < num; ii++ { - if b.PendingDeposits[ii] == nil { - b.PendingDeposits[ii] = new(PendingDeposit) - } - if err = b.PendingDeposits[ii].UnmarshalSSZ(buf[ii*192 : (ii+1)*192]); err != nil { - return err - } - } + // Field 1: Auth + if c.Auth == nil { + c.Auth = new(SignedRequestAuthV1) } + dst = ssz.WriteOffset(dst, offset) + offset += c.Auth.SizeSSZ() - // Field (35) 'PendingPartialWithdrawals' - { - buf = tail[o35:o36] - num, err := ssz.DivideInt2(len(buf), 24, 64) - if err != nil { - return err - } - b.PendingPartialWithdrawals = make([]*PendingPartialWithdrawal, num) - for ii := 0; ii < num; ii++ { - if b.PendingPartialWithdrawals[ii] == nil { - b.PendingPartialWithdrawals[ii] = new(PendingPartialWithdrawal) - } - if err = b.PendingPartialWithdrawals[ii].UnmarshalSSZ(buf[ii*24 : (ii+1)*24]); err != nil { - return err - } - } + // Field 1: Auth + if dst, err = c.Auth.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Auth: %w", err) } + return dst, err +} - // Field (36) 'PendingConsolidations' - { - buf = tail[o36:o38] - num, err := ssz.DivideInt2(len(buf), 16, 64) - if err != nil { - return err - } - b.PendingConsolidations = make([]*PendingConsolidation, num) - for ii := 0; ii < num; ii++ { - if b.PendingConsolidations[ii] == nil { - b.PendingConsolidations[ii] = new(PendingConsolidation) - } - if err = b.PendingConsolidations[ii].UnmarshalSSZ(buf[ii*16 : (ii+1)*16]); err != nil { - return err - } - } +func (c *BuilderPreferencesRequestV1) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 12 { + return ssz.ErrSize } - // Field (38) 'Builders' - { - buf = tail[o38:o42] - num, err := ssz.DivideInt2(len(buf), 93, 1099511627776) - if err != nil { - return err - } - b.Builders = make([]*Builder, num) - for ii := 0; ii < num; ii++ { - if b.Builders[ii] == nil { - b.Builders[ii] = new(Builder) - } - if err = b.Builders[ii].UnmarshalSSZ(buf[ii*93 : (ii+1)*93]); err != nil { - return err - } - } - } + sszSlice0 := buf[0:8] // c.Preferences - // Field (42) 'BuilderPendingWithdrawals' - { - buf = tail[o42:o43] - num, err := ssz.DivideInt2(len(buf), 36, 1048576) - if err != nil { - return err - } - b.BuilderPendingWithdrawals = make([]*BuilderPendingWithdrawal, num) - for ii := 0; ii < num; ii++ { - if b.BuilderPendingWithdrawals[ii] == nil { - b.BuilderPendingWithdrawals[ii] = new(BuilderPendingWithdrawal) - } - if err = b.BuilderPendingWithdrawals[ii].UnmarshalSSZ(buf[ii*36 : (ii+1)*36]); err != nil { - return err - } - } + sszVarOffset1 := ssz.ReadOffset(buf[8:12]) // c.Auth + if sszVarOffset1 != 12 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset1 > size { + return ssz.ErrOffset } + sszSlice1 := buf[sszVarOffset1:] // c.Auth - // Field (43) 'LatestExecutionPayloadBid' - { - buf = tail[o43:o44] - if b.LatestExecutionPayloadBid == nil { - b.LatestExecutionPayloadBid = new(ExecutionPayloadBid) - } - if err = b.LatestExecutionPayloadBid.UnmarshalSSZ(buf); err != nil { - return err - } + // Field 0: Preferences + c.Preferences = new(BuilderPreferencesV1) + if err = c.Preferences.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Preferences: %w", err) } - // Field (44) 'PayloadExpectedWithdrawals' - { - buf = tail[o44:] - num, err := ssz.DivideInt2(len(buf), 44, 4) - if err != nil { - return err - } - b.PayloadExpectedWithdrawals = make([]*v1.Withdrawal, num) - for ii := 0; ii < num; ii++ { - if b.PayloadExpectedWithdrawals[ii] == nil { - b.PayloadExpectedWithdrawals[ii] = new(v1.Withdrawal) - } - if err = b.PayloadExpectedWithdrawals[ii].UnmarshalSSZ(buf[ii*44 : (ii+1)*44]); err != nil { - return err - } - } + // Field 1: Auth + c.Auth = new(SignedRequestAuthV1) + if err = c.Auth.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Auth: %w", err) } return err } -// SizeSSZ returns the ssz encoded size in bytes for the BeaconStateGloas object -func (b *BeaconStateGloas) SizeSSZ() (size int) { - size = 14405 - - // Field (7) 'HistoricalRoots' - size += len(b.HistoricalRoots) * 32 - - // Field (9) 'Eth1DataVotes' - size += len(b.Eth1DataVotes) * 72 - - // Field (11) 'Validators' - size += len(b.Validators) * 121 +func (c *BuilderPreferencesRequestV1) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (12) 'Balances' - size += len(b.Balances) * 8 +func (c *BuilderPreferencesRequestV1) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Preferences + if err := c.Preferences.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Preferences: %w", err) + } + // Field 1: Auth + if err := c.Auth.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Auth: %w", err) + } + hh.Merkleize(indx) + return nil +} - // Field (15) 'PreviousEpochParticipation' - size += len(b.PreviousEpochParticipation) +func (c *BuilderPreferencesV1) SizeSSZ() int { + size := 8 - // Field (16) 'CurrentEpochParticipation' - size += len(b.CurrentEpochParticipation) + return size +} - // Field (21) 'InactivityScores' - size += len(b.InactivityScores) * 8 +func (c *BuilderPreferencesV1) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (27) 'HistoricalSummaries' - size += len(b.HistoricalSummaries) * 64 +func (c *BuilderPreferencesV1) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (34) 'PendingDeposits' - size += len(b.PendingDeposits) * 192 + // Field 0: MaxExecutionPayment + if dst, err = c.MaxExecutionPayment.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("MaxExecutionPayment: %w", err) + } - // Field (35) 'PendingPartialWithdrawals' - size += len(b.PendingPartialWithdrawals) * 24 + return dst, err +} - // Field (36) 'PendingConsolidations' - size += len(b.PendingConsolidations) * 16 +func (c *BuilderPreferencesV1) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 8 { + return ssz.ErrSize + } - // Field (38) 'Builders' - size += len(b.Builders) * 93 + sszSlice0 := buf[0:8] // c.MaxExecutionPayment - // Field (42) 'BuilderPendingWithdrawals' - size += len(b.BuilderPendingWithdrawals) * 36 + // Field 0: MaxExecutionPayment + if err = c.MaxExecutionPayment.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("MaxExecutionPayment: %w", err) + } + return err +} - // Field (43) 'LatestExecutionPayloadBid' - if b.LatestExecutionPayloadBid == nil { - b.LatestExecutionPayloadBid = new(ExecutionPayloadBid) +func (c *BuilderPreferencesV1) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - size += b.LatestExecutionPayloadBid.SizeSSZ() + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (44) 'PayloadExpectedWithdrawals' - size += len(b.PayloadExpectedWithdrawals) * 44 +func (c *BuilderPreferencesV1) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: MaxExecutionPayment + if err := c.MaxExecutionPayment.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("MaxExecutionPayment: %w", err) + } + hh.Merkleize(indx) + return nil +} - return +func (c *DataColumnSidecarGloas) SizeSSZ() int { + size := 56 + size += len(c.Column) * 2048 + size += len(c.KzgProofs) * 48 + return size } -// HashTreeRoot ssz hashes the BeaconStateGloas object -func (b *BeaconStateGloas) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) +func (c *DataColumnSidecarGloas) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// HashTreeRootWith ssz hashes the BeaconStateGloas object with a hasher -func (b *BeaconStateGloas) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() +func (c *DataColumnSidecarGloas) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 56 - // Field (0) 'GenesisTime' - ssz.PutUint(hh, b.GenesisTime) + // Field 0: Index + dst = binary.LittleEndian.AppendUint64(dst, c.Index) - // Field (1) 'GenesisValidatorsRoot' - if size := len(b.GenesisValidatorsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.GenesisValidatorsRoot", size, 32) - return - } - hh.PutBytes(b.GenesisValidatorsRoot) + // Field 1: Column + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Column) * 2048 - // Field (2) 'Slot' - ssz.PutUint(hh, b.Slot) + // Field 2: KzgProofs + dst = ssz.WriteOffset(dst, offset) + offset += len(c.KzgProofs) * 48 - // Field (3) 'Fork' - if err = b.Fork.HashTreeRootWith(hh); err != nil { - return + // Field 3: Slot + if dst, err = c.Slot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Slot: %w", err) } - // Field (4) 'LatestBlockHeader' - if err = b.LatestBlockHeader.HashTreeRootWith(hh); err != nil { - return + // Field 4: BeaconBlockRoot + if len(c.BeaconBlockRoot) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.BeaconBlockRoot...) - // Field (5) 'BlockRoots' - { - if size := len(b.BlockRoots); size != 64 { - err = ssz.ErrVectorLengthFn("--.BlockRoots", size, 64) - return - } - subIndx := hh.Index() - for _, i := range b.BlockRoots { - if len(i) != 32 { - err = ssz.ErrBytesLength - return - } - hh.Append(i) - } - hh.Merkleize(subIndx) + // Field 1: Column + if len(c.Column) > 4096 { + return nil, ssz.ErrListTooBig } - - // Field (6) 'StateRoots' - { - if size := len(b.StateRoots); size != 64 { - err = ssz.ErrVectorLengthFn("--.StateRoots", size, 64) - return - } - subIndx := hh.Index() - for _, i := range b.StateRoots { - if len(i) != 32 { - err = ssz.ErrBytesLength - return - } - hh.Append(i) + for _, o := range c.Column { + if len(o) != 2048 { + return nil, ssz.ErrBytesLength } - hh.Merkleize(subIndx) + dst = append(dst, o...) } - // Field (7) 'HistoricalRoots' - { - if size := len(b.HistoricalRoots); size > 16777216 { - err = ssz.ErrListTooBigFn("--.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 2: KzgProofs + if len(c.KzgProofs) > 4096 { + return nil, ssz.ErrListTooBig } - - // Field (8) 'Eth1Data' - if err = b.Eth1Data.HashTreeRootWith(hh); err != nil { - return - } - - // Field (9) 'Eth1DataVotes' - { - subIndx := hh.Index() - num := uint64(len(b.Eth1DataVotes)) - if num > 32 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range b.Eth1DataVotes { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } + for _, o := range c.KzgProofs { + if len(o) != 48 { + return nil, ssz.ErrBytesLength } - hh.MerkleizeWithMixin(subIndx, num, 32) + dst = append(dst, o...) } + return dst, err +} - // Field (10) 'Eth1DepositIndex' - ssz.PutUint(hh, 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) +func (c *DataColumnSidecarGloas) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 56 { + return ssz.ErrSize } - // Field (12) 'Balances' - { - if size := len(b.Balances); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.Balances", size, 1099511627776) - return - } - subIndx := hh.Index() - for _, i := range b.Balances { - ssz.AppendUint(hh, i) - } - hh.FillUpTo32() + sszSlice0 := buf[0:8] // c.Index + sszSlice3 := buf[16:24] // c.Slot + sszSlice4 := buf[24:56] // c.BeaconBlockRoot - numItems := uint64(len(b.Balances)) - hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(1099511627776, numItems, 8)) + sszVarOffset1 := ssz.ReadOffset(buf[8:12]) // c.Column + if sszVarOffset1 != 56 { + return ssz.ErrInvalidVariableOffset } - - // Field (13) 'RandaoMixes' - { - if size := len(b.RandaoMixes); size != 64 { - err = ssz.ErrVectorLengthFn("--.RandaoMixes", size, 64) - return - } - subIndx := hh.Index() - for _, i := range b.RandaoMixes { - if len(i) != 32 { - err = ssz.ErrBytesLength - return - } - hh.Append(i) - } - hh.Merkleize(subIndx) + if sszVarOffset1 > size { + return ssz.ErrOffset } + sszVarOffset2 := ssz.ReadOffset(buf[12:16]) // c.KzgProofs + if sszVarOffset2 > size || sszVarOffset2 < sszVarOffset1 { + return ssz.ErrOffset + } + sszSlice1 := buf[sszVarOffset1:sszVarOffset2] // c.Column + sszSlice2 := buf[sszVarOffset2:] // c.KzgProofs - // Field (14) 'Slashings' + // Field 0: Index + c.Index = binary.LittleEndian.Uint64(sszSlice0) + + // Field 1: Column { - if size := len(b.Slashings); size != 64 { - err = ssz.ErrVectorLengthFn("--.Slashings", size, 64) - return + if len(sszSlice1)%2048 != 0 { + return fmt.Errorf("misaligned bytes: c.Column length is %d, which is not a multiple of 2048: %w", len(sszSlice1), ssz.ErrIncorrectListSize) } - subIndx := hh.Index() - for _, i := range b.Slashings { - ssz.AppendUint(hh, i) + numElem := len(sszSlice1) / 2048 + if numElem > 4096 { + return fmt.Errorf("ssz-max exceeded: c.Column has %d elements, ssz-max is 4096: %w", numElem, ssz.ErrListTooBig) } - hh.Merkleize(subIndx) - } + c.Column = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte - // Field (15) 'PreviousEpochParticipation' - { - elemIndx := hh.Index() - byteLen := uint64(len(b.PreviousEpochParticipation)) - if byteLen > 1099511627776 { - err = ssz.ErrIncorrectListSize - return + tmpSlice := sszSlice1[i*2048 : (1+i)*2048] + tmp = make([]byte, 0, 2048) + tmp = append(tmp, tmpSlice...) + c.Column[i] = tmp } - hh.AppendBytes32(b.PreviousEpochParticipation) - hh.MerkleizeWithMixin(elemIndx, byteLen, (1099511627776+31)/32) } - // Field (16) 'CurrentEpochParticipation' + // Field 2: KzgProofs { - elemIndx := hh.Index() - byteLen := uint64(len(b.CurrentEpochParticipation)) - if byteLen > 1099511627776 { - err = ssz.ErrIncorrectListSize - return + if len(sszSlice2)%48 != 0 { + return fmt.Errorf("misaligned bytes: c.KzgProofs length is %d, which is not a multiple of 48: %w", len(sszSlice2), ssz.ErrIncorrectListSize) } - hh.AppendBytes32(b.CurrentEpochParticipation) - hh.MerkleizeWithMixin(elemIndx, byteLen, (1099511627776+31)/32) - } + numElem := len(sszSlice2) / 48 + if numElem > 4096 { + return fmt.Errorf("ssz-max exceeded: c.KzgProofs has %d elements, ssz-max is 4096: %w", numElem, ssz.ErrListTooBig) + } + c.KzgProofs = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte - // Field (17) 'JustificationBits' - if size := len(b.JustificationBits); size != 1 { - err = ssz.ErrBytesLengthFn("--.JustificationBits", size, 1) - return + tmpSlice := sszSlice2[i*48 : (1+i)*48] + tmp = make([]byte, 0, 48) + tmp = append(tmp, tmpSlice...) + c.KzgProofs[i] = tmp + } } - hh.PutBytes(b.JustificationBits) - // Field (18) 'PreviousJustifiedCheckpoint' - if err = b.PreviousJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { - return + // Field 3: Slot + if err = c.Slot.UnmarshalSSZ(sszSlice3); err != nil { + return fmt.Errorf("Slot: %w", err) } - // Field (19) 'CurrentJustifiedCheckpoint' - if err = b.CurrentJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { - return - } + // Field 4: BeaconBlockRoot + c.BeaconBlockRoot = make([]byte, 0, 32) + c.BeaconBlockRoot = append(c.BeaconBlockRoot, sszSlice4...) + return err +} - // Field (20) 'FinalizedCheckpoint' - if err = b.FinalizedCheckpoint.HashTreeRootWith(hh); err != nil { - return +func (c *DataColumnSidecarGloas) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (21) 'InactivityScores' +func (c *DataColumnSidecarGloas) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Index + hh.PutUint64(c.Index) + // Field 1: Column { - if size := len(b.InactivityScores); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.InactivityScores", size, 1099511627776) - return + if len(c.Column) > 4096 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range b.InactivityScores { - ssz.AppendUint(hh, i) + for _, o := range c.Column { + if len(o) != 2048 { + return ssz.ErrBytesLength + } + hh.PutBytes(o) } - hh.FillUpTo32() - - numItems := uint64(len(b.InactivityScores)) - hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(1099511627776, numItems, 8)) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Column)), 4096) } - - // Field (22) 'CurrentSyncCommittee' - if err = b.CurrentSyncCommittee.HashTreeRootWith(hh); err != nil { - return - } - - // Field (23) 'NextSyncCommittee' - if err = b.NextSyncCommittee.HashTreeRootWith(hh); err != nil { - return - } - - // Field (24) 'LatestBlockHash' - if size := len(b.LatestBlockHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.LatestBlockHash", size, 32) - return - } - hh.PutBytes(b.LatestBlockHash) - - // Field (25) 'NextWithdrawalIndex' - ssz.PutUint(hh, b.NextWithdrawalIndex) - - // Field (26) 'NextWithdrawalValidatorIndex' - ssz.PutUint(hh, b.NextWithdrawalValidatorIndex) - - // Field (27) 'HistoricalSummaries' + // Field 2: KzgProofs { + if len(c.KzgProofs) > 4096 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.KzgProofs { + if len(o) != 48 { + return ssz.ErrBytesLength } + hh.PutBytes(o) } - hh.MerkleizeWithMixin(subIndx, num, 16777216) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.KzgProofs)), 4096) } + // Field 3: Slot + if err := c.Slot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Slot: %w", err) + } + // Field 4: BeaconBlockRoot + if len(c.BeaconBlockRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.BeaconBlockRoot) + hh.Merkleize(indx) + return nil +} - // Field (28) 'DepositRequestsStartIndex' - ssz.PutUint(hh, b.DepositRequestsStartIndex) - - // Field (29) 'DepositBalanceToConsume' - ssz.PutUint(hh, b.DepositBalanceToConsume) - - // Field (30) 'ExitBalanceToConsume' - ssz.PutUint(hh, b.ExitBalanceToConsume) - - // Field (31) 'EarliestExitEpoch' - ssz.PutUint(hh, b.EarliestExitEpoch) +func (c *ExecutionPayloadBid) SizeSSZ() int { + size := 224 + size += len(c.BlobKzgCommitments) * 48 + return size +} - // Field (32) 'ConsolidationBalanceToConsume' - ssz.PutUint(hh, b.ConsolidationBalanceToConsume) +func (c *ExecutionPayloadBid) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (33) 'EarliestConsolidationEpoch' - ssz.PutUint(hh, b.EarliestConsolidationEpoch) +func (c *ExecutionPayloadBid) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 224 - // 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 0: ParentBlockHash + if len(c.ParentBlockHash) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.ParentBlockHash...) - // Field (35) 'PendingPartialWithdrawals' - { - subIndx := hh.Index() - num := uint64(len(b.PendingPartialWithdrawals)) - if num > 64 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range b.PendingPartialWithdrawals { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } - } - hh.MerkleizeWithMixin(subIndx, num, 64) + // Field 1: ParentBlockRoot + if len(c.ParentBlockRoot) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.ParentBlockRoot...) - // Field (36) 'PendingConsolidations' - { - subIndx := hh.Index() - num := uint64(len(b.PendingConsolidations)) - if num > 64 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range b.PendingConsolidations { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } - } - hh.MerkleizeWithMixin(subIndx, num, 64) + // Field 2: BlockHash + if len(c.BlockHash) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.BlockHash...) - // Field (37) 'ProposerLookahead' - { - if size := len(b.ProposerLookahead); size != 16 { - err = ssz.ErrVectorLengthFn("--.ProposerLookahead", size, 16) - return - } - subIndx := hh.Index() - for _, i := range b.ProposerLookahead { - ssz.AppendUint(hh, i) - } - hh.Merkleize(subIndx) + // Field 3: PrevRandao + if len(c.PrevRandao) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.PrevRandao...) - // Field (38) 'Builders' - { - subIndx := hh.Index() - num := uint64(len(b.Builders)) - if num > 1099511627776 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range b.Builders { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } - } - hh.MerkleizeWithMixin(subIndx, num, 1099511627776) + // Field 4: FeeRecipient + if len(c.FeeRecipient) != 20 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.FeeRecipient...) - // Field (39) 'NextWithdrawalBuilderIndex' - ssz.PutUint(hh, b.NextWithdrawalBuilderIndex) + // Field 5: GasLimit + dst = binary.LittleEndian.AppendUint64(dst, c.GasLimit) - // Field (40) 'ExecutionPayloadAvailability' - if size := len(b.ExecutionPayloadAvailability); size != 8 { - err = ssz.ErrBytesLengthFn("--.ExecutionPayloadAvailability", size, 8) - return + // Field 6: BuilderIndex + if dst, err = c.BuilderIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("BuilderIndex: %w", err) } - hh.PutBytes(b.ExecutionPayloadAvailability) - // Field (41) 'BuilderPendingPayments' - { - subIndx := hh.Index() - for _, elem := range b.BuilderPendingPayments { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } - } - hh.Merkleize(subIndx) + // Field 7: Slot + if dst, err = c.Slot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Slot: %w", err) } - // Field (42) 'BuilderPendingWithdrawals' - { - subIndx := hh.Index() - num := uint64(len(b.BuilderPendingWithdrawals)) - if num > 1048576 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range b.BuilderPendingWithdrawals { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } - } - hh.MerkleizeWithMixin(subIndx, num, 1048576) + // Field 8: Value + if dst, err = c.Value.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Value: %w", err) } - // Field (43) 'LatestExecutionPayloadBid' - if err = b.LatestExecutionPayloadBid.HashTreeRootWith(hh); err != nil { - return + // Field 9: ExecutionPayment + if dst, err = c.ExecutionPayment.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ExecutionPayment: %w", err) } - // Field (44) 'PayloadExpectedWithdrawals' - { - subIndx := hh.Index() - num := uint64(len(b.PayloadExpectedWithdrawals)) - if num > 4 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range b.PayloadExpectedWithdrawals { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } - } - hh.MerkleizeWithMixin(subIndx, num, 4) + // Field 10: BlobKzgCommitments + dst = ssz.WriteOffset(dst, offset) + offset += len(c.BlobKzgCommitments) * 48 + + // Field 11: ExecutionRequestsRoot + if len(c.ExecutionRequestsRoot) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.ExecutionRequestsRoot...) - // Field (45) 'PtcWindow' - { - subIndx := hh.Index() - for _, elem := range b.PtcWindow { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } + // Field 10: BlobKzgCommitments + if len(c.BlobKzgCommitments) > 4096 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.BlobKzgCommitments { + if len(o) != 48 { + return nil, ssz.ErrBytesLength } - hh.Merkleize(subIndx) + dst = append(dst, o...) + } + return dst, err +} + +func (c *ExecutionPayloadBid) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 224 { + return ssz.ErrSize + } + + sszSlice0 := buf[0:32] // c.ParentBlockHash + sszSlice1 := buf[32:64] // c.ParentBlockRoot + sszSlice2 := buf[64:96] // c.BlockHash + sszSlice3 := buf[96:128] // c.PrevRandao + sszSlice4 := buf[128:148] // c.FeeRecipient + sszSlice5 := buf[148:156] // c.GasLimit + sszSlice6 := buf[156:164] // c.BuilderIndex + sszSlice7 := buf[164:172] // c.Slot + sszSlice8 := buf[172:180] // c.Value + sszSlice9 := buf[180:188] // c.ExecutionPayment + sszSlice11 := buf[192:224] // c.ExecutionRequestsRoot + + sszVarOffset10 := ssz.ReadOffset(buf[188:192]) // c.BlobKzgCommitments + if sszVarOffset10 != 224 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset10 > size { + return ssz.ErrOffset } + sszSlice10 := buf[sszVarOffset10:] // c.BlobKzgCommitments - hh.Merkleize(indx) - return -} + // Field 0: ParentBlockHash + c.ParentBlockHash = make([]byte, 0, 32) + c.ParentBlockHash = append(c.ParentBlockHash, sszSlice0...) -// MarshalSSZ ssz marshals the PTCs object -func (p *PTCs) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(p) -} + // Field 1: ParentBlockRoot + c.ParentBlockRoot = make([]byte, 0, 32) + c.ParentBlockRoot = append(c.ParentBlockRoot, sszSlice1...) + + // Field 2: BlockHash + c.BlockHash = make([]byte, 0, 32) + c.BlockHash = append(c.BlockHash, sszSlice2...) -// MarshalSSZTo ssz marshals the PTCs object to a target array -func (p *PTCs) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf + // Field 3: PrevRandao + c.PrevRandao = make([]byte, 0, 32) + c.PrevRandao = append(c.PrevRandao, sszSlice3...) - // Field (0) 'ValidatorIndices' - if size := len(p.ValidatorIndices); size != 16 { - err = ssz.ErrVectorLengthFn("--.ValidatorIndices", size, 16) - return + // Field 4: FeeRecipient + c.FeeRecipient = make([]byte, 0, 20) + c.FeeRecipient = append(c.FeeRecipient, sszSlice4...) + + // Field 5: GasLimit + c.GasLimit = binary.LittleEndian.Uint64(sszSlice5) + + // Field 6: BuilderIndex + if err = c.BuilderIndex.UnmarshalSSZ(sszSlice6); err != nil { + return fmt.Errorf("BuilderIndex: %w", err) } - for ii := 0; ii < 16; ii++ { - dst = ssz.MarshalUint(dst, p.ValidatorIndices[ii]) + + // Field 7: Slot + if err = c.Slot.UnmarshalSSZ(sszSlice7); err != nil { + return fmt.Errorf("Slot: %w", err) } - return -} + // Field 8: Value + if err = c.Value.UnmarshalSSZ(sszSlice8); err != nil { + return fmt.Errorf("Value: %w", err) + } -// UnmarshalSSZ ssz unmarshals the PTCs object -func (p *PTCs) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size != 128 { - return ssz.ErrSize + // Field 9: ExecutionPayment + if err = c.ExecutionPayment.UnmarshalSSZ(sszSlice9); err != nil { + return fmt.Errorf("ExecutionPayment: %w", err) } - // Field (0) 'ValidatorIndices' - p.ValidatorIndices = ssz.ExtendUint(p.ValidatorIndices, 16) - for ii := 0; ii < 16; ii++ { - p.ValidatorIndices[ii] = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[0:128][ii*8 : (ii+1)*8]) + // Field 10: BlobKzgCommitments + { + if len(sszSlice10)%48 != 0 { + return fmt.Errorf("misaligned bytes: c.BlobKzgCommitments length is %d, which is not a multiple of 48: %w", len(sszSlice10), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice10) / 48 + if numElem > 4096 { + return fmt.Errorf("ssz-max exceeded: c.BlobKzgCommitments has %d elements, ssz-max is 4096: %w", numElem, ssz.ErrListTooBig) + } + c.BlobKzgCommitments = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte + + tmpSlice := sszSlice10[i*48 : (1+i)*48] + tmp = make([]byte, 0, 48) + tmp = append(tmp, tmpSlice...) + c.BlobKzgCommitments[i] = tmp + } } + // Field 11: ExecutionRequestsRoot + c.ExecutionRequestsRoot = make([]byte, 0, 32) + c.ExecutionRequestsRoot = append(c.ExecutionRequestsRoot, sszSlice11...) return err } -// SizeSSZ returns the ssz encoded size in bytes for the PTCs object -func (p *PTCs) SizeSSZ() (size int) { - size = 128 - return -} - -// HashTreeRoot ssz hashes the PTCs object -func (p *PTCs) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(p) +func (c *ExecutionPayloadBid) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the PTCs object with a hasher -func (p *PTCs) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *ExecutionPayloadBid) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'ValidatorIndices' + // Field 0: ParentBlockHash + if len(c.ParentBlockHash) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ParentBlockHash) + // Field 1: ParentBlockRoot + if len(c.ParentBlockRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ParentBlockRoot) + // Field 2: BlockHash + if len(c.BlockHash) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.BlockHash) + // Field 3: PrevRandao + if len(c.PrevRandao) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.PrevRandao) + // Field 4: FeeRecipient + if len(c.FeeRecipient) != 20 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.FeeRecipient) + // Field 5: GasLimit + hh.PutUint64(c.GasLimit) + // Field 6: BuilderIndex + if err := c.BuilderIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("BuilderIndex: %w", err) + } + // Field 7: Slot + if err := c.Slot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Slot: %w", err) + } + // Field 8: Value + if err := c.Value.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Value: %w", err) + } + // Field 9: ExecutionPayment + if err := c.ExecutionPayment.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ExecutionPayment: %w", err) + } + // Field 10: BlobKzgCommitments { - if size := len(p.ValidatorIndices); size != 16 { - err = ssz.ErrVectorLengthFn("--.ValidatorIndices", size, 16) - return + if len(c.BlobKzgCommitments) > 4096 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range p.ValidatorIndices { - ssz.AppendUint(hh, i) + for _, o := range c.BlobKzgCommitments { + if len(o) != 48 { + return ssz.ErrBytesLength + } + hh.PutBytes(o) } - hh.Merkleize(subIndx) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.BlobKzgCommitments)), 4096) } - + // Field 11: ExecutionRequestsRoot + if len(c.ExecutionRequestsRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ExecutionRequestsRoot) hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the BeaconBlockContentsGloas object -func (b *BeaconBlockContentsGloas) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) +func (c *ExecutionPayloadEnvelope) SizeSSZ() int { + size := 80 + if c.Payload == nil { + c.Payload = new(v1.ExecutionPayloadGloas) + } + size += c.Payload.SizeSSZ() + if c.ExecutionRequests == nil { + c.ExecutionRequests = new(v1.ExecutionRequestsGloas) + } + size += c.ExecutionRequests.SizeSSZ() + return size } -// MarshalSSZTo ssz marshals the BeaconBlockContentsGloas object to a target array -func (b *BeaconBlockContentsGloas) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(16) +func (c *ExecutionPayloadEnvelope) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Offset (0) 'Block' - dst = ssz.WriteOffset(dst, offset) - if b.Block == nil { - b.Block = new(BeaconBlockGloas) - } - offset += b.Block.SizeSSZ() +func (c *ExecutionPayloadEnvelope) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 80 - // Offset (1) 'ExecutionPayloadEnvelope' - dst = ssz.WriteOffset(dst, offset) - if b.ExecutionPayloadEnvelope == nil { - b.ExecutionPayloadEnvelope = new(ExecutionPayloadEnvelope) + // Field 0: Payload + if c.Payload == nil { + c.Payload = new(v1.ExecutionPayloadGloas) } - offset += b.ExecutionPayloadEnvelope.SizeSSZ() - - // Offset (2) 'KzgProofs' dst = ssz.WriteOffset(dst, offset) - offset += len(b.KzgProofs) * 48 + offset += c.Payload.SizeSSZ() - // Offset (3) 'Blobs' + // Field 1: ExecutionRequests + if c.ExecutionRequests == nil { + c.ExecutionRequests = new(v1.ExecutionRequestsGloas) + } dst = ssz.WriteOffset(dst, offset) - offset += len(b.Blobs) * 131072 + offset += c.ExecutionRequests.SizeSSZ() - // Field (0) 'Block' - if dst, err = b.Block.MarshalSSZTo(dst); err != nil { - return + // Field 2: BuilderIndex + if dst, err = c.BuilderIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("BuilderIndex: %w", err) } - // Field (1) 'ExecutionPayloadEnvelope' - if dst, err = b.ExecutionPayloadEnvelope.MarshalSSZTo(dst); err != nil { - return + // Field 3: BeaconBlockRoot + if len(c.BeaconBlockRoot) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.BeaconBlockRoot...) - // Field (2) 'KzgProofs' - if size := len(b.KzgProofs); size > 33554432 { - err = ssz.ErrListTooBigFn("--.KzgProofs", size, 33554432) - return - } - for ii := 0; ii < len(b.KzgProofs); ii++ { - if size := len(b.KzgProofs[ii]); size != 48 { - err = ssz.ErrBytesLengthFn("--.KzgProofs[ii]", size, 48) - return - } - dst = append(dst, b.KzgProofs[ii]...) + // Field 4: ParentBeaconBlockRoot + if len(c.ParentBeaconBlockRoot) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.ParentBeaconBlockRoot...) - // Field (3) 'Blobs' - if size := len(b.Blobs); size > 4096 { - err = ssz.ErrListTooBigFn("--.Blobs", size, 4096) - return - } - for ii := 0; ii < len(b.Blobs); ii++ { - if size := len(b.Blobs[ii]); size != 131072 { - err = ssz.ErrBytesLengthFn("--.Blobs[ii]", size, 131072) - return - } - dst = append(dst, b.Blobs[ii]...) + // Field 0: Payload + if dst, err = c.Payload.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Payload: %w", err) } - return + // Field 1: ExecutionRequests + if dst, err = c.ExecutionRequests.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ExecutionRequests: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the BeaconBlockContentsGloas object -func (b *BeaconBlockContentsGloas) UnmarshalSSZ(buf []byte) error { +func (c *ExecutionPayloadEnvelope) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 16 { + if size < 80 { return ssz.ErrSize } - tail := buf - var o0, o1, o2, o3 uint64 - - // Offset (0) 'Block' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } + sszSlice2 := buf[8:16] // c.BuilderIndex + sszSlice3 := buf[16:48] // c.BeaconBlockRoot + sszSlice4 := buf[48:80] // c.ParentBeaconBlockRoot - if o0 != 16 { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Payload + if sszVarOffset0 != 80 { return ssz.ErrInvalidVariableOffset } - - // Offset (1) 'ExecutionPayloadEnvelope' - if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 { + if sszVarOffset0 > size { return ssz.ErrOffset } - - // Offset (2) 'KzgProofs' - if o2 = ssz.ReadOffset(buf[8:12]); o2 > size || o1 > o2 { + sszVarOffset1 := ssz.ReadOffset(buf[4:8]) // c.ExecutionRequests + if sszVarOffset1 > size || sszVarOffset1 < sszVarOffset0 { return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:sszVarOffset1] // c.Payload + sszSlice1 := buf[sszVarOffset1:] // c.ExecutionRequests - // Offset (3) 'Blobs' - if o3 = ssz.ReadOffset(buf[12:16]); o3 > size || o2 > o3 { - return ssz.ErrOffset + // Field 0: Payload + c.Payload = new(v1.ExecutionPayloadGloas) + if err = c.Payload.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Payload: %w", err) } - // Field (0) 'Block' - { - buf = tail[o0:o1] - if b.Block == nil { - b.Block = new(BeaconBlockGloas) - } - if err = b.Block.UnmarshalSSZ(buf); err != nil { - return err - } + // Field 1: ExecutionRequests + c.ExecutionRequests = new(v1.ExecutionRequestsGloas) + if err = c.ExecutionRequests.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("ExecutionRequests: %w", err) } - // Field (1) 'ExecutionPayloadEnvelope' - { - buf = tail[o1:o2] - if b.ExecutionPayloadEnvelope == nil { - b.ExecutionPayloadEnvelope = new(ExecutionPayloadEnvelope) - } - if err = b.ExecutionPayloadEnvelope.UnmarshalSSZ(buf); err != nil { - return err - } + // Field 2: BuilderIndex + if err = c.BuilderIndex.UnmarshalSSZ(sszSlice2); err != nil { + return fmt.Errorf("BuilderIndex: %w", err) } - // Field (2) 'KzgProofs' - { - buf = tail[o2:o3] - num, err := ssz.DivideInt2(len(buf), 48, 33554432) - if err != nil { - return err - } - b.KzgProofs = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(b.KzgProofs[ii]) == 0 { - b.KzgProofs[ii] = make([]byte, 0, len(buf[ii*48:(ii+1)*48])) - } - b.KzgProofs[ii] = append(b.KzgProofs[ii], buf[ii*48:(ii+1)*48]...) - } - } + // Field 3: BeaconBlockRoot + c.BeaconBlockRoot = make([]byte, 0, 32) + c.BeaconBlockRoot = append(c.BeaconBlockRoot, sszSlice3...) - // Field (3) 'Blobs' - { - buf = tail[o3:] - num, err := ssz.DivideInt2(len(buf), 131072, 4096) - if err != nil { - return err - } - b.Blobs = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(b.Blobs[ii]) == 0 { - b.Blobs[ii] = make([]byte, 0, len(buf[ii*131072:(ii+1)*131072])) - } - b.Blobs[ii] = append(b.Blobs[ii], buf[ii*131072:(ii+1)*131072]...) - } - } + // Field 4: ParentBeaconBlockRoot + c.ParentBeaconBlockRoot = make([]byte, 0, 32) + c.ParentBeaconBlockRoot = append(c.ParentBeaconBlockRoot, sszSlice4...) return err } -// SizeSSZ returns the ssz encoded size in bytes for the BeaconBlockContentsGloas object -func (b *BeaconBlockContentsGloas) SizeSSZ() (size int) { - size = 16 - - // Field (0) 'Block' - if b.Block == nil { - b.Block = new(BeaconBlockGloas) +func (c *ExecutionPayloadEnvelope) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - size += b.Block.SizeSSZ() + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (1) 'ExecutionPayloadEnvelope' - if b.ExecutionPayloadEnvelope == nil { - b.ExecutionPayloadEnvelope = new(ExecutionPayloadEnvelope) +func (c *ExecutionPayloadEnvelope) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Payload + if err := c.Payload.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Payload: %w", err) } - size += b.ExecutionPayloadEnvelope.SizeSSZ() - - // Field (2) 'KzgProofs' - size += len(b.KzgProofs) * 48 - - // Field (3) 'Blobs' - size += len(b.Blobs) * 131072 + // Field 1: ExecutionRequests + if err := c.ExecutionRequests.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ExecutionRequests: %w", err) + } + // Field 2: BuilderIndex + if err := c.BuilderIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("BuilderIndex: %w", err) + } + // Field 3: BeaconBlockRoot + if len(c.BeaconBlockRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.BeaconBlockRoot) + // Field 4: ParentBeaconBlockRoot + if len(c.ParentBeaconBlockRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ParentBeaconBlockRoot) + hh.Merkleize(indx) + return nil +} - return +func (c *IndexedAttestationGloas) SizeSSZ() int { + size := 228 + size += len(c.AttestingIndices) * 8 + return size } -// HashTreeRoot ssz hashes the BeaconBlockContentsGloas object -func (b *BeaconBlockContentsGloas) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) +func (c *IndexedAttestationGloas) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// HashTreeRootWith ssz hashes the BeaconBlockContentsGloas object with a hasher -func (b *BeaconBlockContentsGloas) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() +func (c *IndexedAttestationGloas) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 228 + + // Field 0: AttestingIndices + dst = ssz.WriteOffset(dst, offset) + offset += len(c.AttestingIndices) * 8 + + // Field 1: Data + if c.Data == nil { + c.Data = new(AttestationData) + } + if dst, err = c.Data.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Data: %w", err) + } + + // Field 2: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.Signature...) + + // Field 0: AttestingIndices + if len(c.AttestingIndices) > 8192 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.AttestingIndices { + dst = binary.LittleEndian.AppendUint64(dst, o) + } + return dst, err +} - // Field (0) 'Block' - if err = b.Block.HashTreeRootWith(hh); err != nil { - return +func (c *IndexedAttestationGloas) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 228 { + return ssz.ErrSize } - // Field (1) 'ExecutionPayloadEnvelope' - if err = b.ExecutionPayloadEnvelope.HashTreeRootWith(hh); err != nil { - return + sszSlice1 := buf[4:132] // c.Data + sszSlice2 := buf[132:228] // c.Signature + + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.AttestingIndices + if sszVarOffset0 != 228 { + return ssz.ErrInvalidVariableOffset } + if sszVarOffset0 > size { + return ssz.ErrOffset + } + sszSlice0 := buf[sszVarOffset0:] // c.AttestingIndices - // Field (2) 'KzgProofs' + // Field 0: AttestingIndices { - if size := len(b.KzgProofs); size > 33554432 { - err = ssz.ErrListTooBigFn("--.KzgProofs", size, 33554432) - return + if len(sszSlice0)%8 != 0 { + return fmt.Errorf("misaligned bytes: c.AttestingIndices length is %d, which is not a multiple of 8: %w", len(sszSlice0), ssz.ErrIncorrectListSize) } - subIndx := hh.Index() - for _, i := range b.KzgProofs { - if len(i) != 48 { - err = ssz.ErrBytesLength - return - } - hh.PutBytes(i) + numElem := len(sszSlice0) / 8 + if numElem > 8192 { + return fmt.Errorf("ssz-max exceeded: c.AttestingIndices has %d elements, ssz-max is 8192: %w", numElem, ssz.ErrListTooBig) } + c.AttestingIndices = make([]uint64, numElem) + for i := 0; i < numElem; i++ { + var tmp uint64 + + tmpSlice := sszSlice0[i*8 : (1+i)*8] + tmp = binary.LittleEndian.Uint64(tmpSlice) + c.AttestingIndices[i] = tmp + } + } + + // Field 1: Data + c.Data = new(AttestationData) + if err = c.Data.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Data: %w", err) + } + + // Field 2: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice2...) + return err +} - numItems := uint64(len(b.KzgProofs)) - hh.MerkleizeWithMixin(subIndx, numItems, 33554432) +func (c *IndexedAttestationGloas) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (3) 'Blobs' +func (c *IndexedAttestationGloas) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: AttestingIndices { - if size := len(b.Blobs); size > 4096 { - err = ssz.ErrListTooBigFn("--.Blobs", size, 4096) - return + if len(c.AttestingIndices) > 8192 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range b.Blobs { - if len(i) != 131072 { - err = ssz.ErrBytesLength - return - } - hh.PutBytes(i) + for _, o := range c.AttestingIndices { + hh.AppendUint64(o) } - - numItems := uint64(len(b.Blobs)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) + hh.FillUpTo32() + numItems := uint64(len(c.AttestingIndices)) + hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(8192, numItems, 8)) } - + // Field 1: Data + if err := c.Data.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Data: %w", err) + } + // Field 2: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Signature) hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the SignedExecutionPayloadEnvelopeContents object -func (s *SignedExecutionPayloadEnvelopeContents) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) + return nil } -// MarshalSSZTo ssz marshals the SignedExecutionPayloadEnvelopeContents object to a target array -func (s *SignedExecutionPayloadEnvelopeContents) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(12) +func (c *PayloadAttestation) SizeSSZ() int { + size := 140 - // Offset (0) 'SignedExecutionPayloadEnvelope' - dst = ssz.WriteOffset(dst, offset) - if s.SignedExecutionPayloadEnvelope == nil { - s.SignedExecutionPayloadEnvelope = new(SignedExecutionPayloadEnvelope) - } - offset += s.SignedExecutionPayloadEnvelope.SizeSSZ() + return size +} - // Offset (1) 'KzgProofs' - dst = ssz.WriteOffset(dst, offset) - offset += len(s.KzgProofs) * 48 +func (c *PayloadAttestation) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Offset (2) 'Blobs' - dst = ssz.WriteOffset(dst, offset) - offset += len(s.Blobs) * 131072 +func (c *PayloadAttestation) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (0) 'SignedExecutionPayloadEnvelope' - if dst, err = s.SignedExecutionPayloadEnvelope.MarshalSSZTo(dst); err != nil { - return + // Field 0: AggregationBits + if len([]byte(c.AggregationBits)) != 2 { + return nil, ssz.ErrBytesLength } + dst = append(dst, []byte(c.AggregationBits)...) - // Field (1) 'KzgProofs' - if size := len(s.KzgProofs); size > 33554432 { - err = ssz.ErrListTooBigFn("--.KzgProofs", size, 33554432) - return + // Field 1: Data + if c.Data == nil { + c.Data = new(PayloadAttestationData) } - for ii := 0; ii < len(s.KzgProofs); ii++ { - if size := len(s.KzgProofs[ii]); size != 48 { - err = ssz.ErrBytesLengthFn("--.KzgProofs[ii]", size, 48) - return - } - dst = append(dst, s.KzgProofs[ii]...) + if dst, err = c.Data.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Data: %w", err) } - // Field (2) 'Blobs' - if size := len(s.Blobs); size > 4096 { - err = ssz.ErrListTooBigFn("--.Blobs", size, 4096) - return - } - for ii := 0; ii < len(s.Blobs); ii++ { - if size := len(s.Blobs[ii]); size != 131072 { - err = ssz.ErrBytesLengthFn("--.Blobs[ii]", size, 131072) - return - } - dst = append(dst, s.Blobs[ii]...) + // Field 2: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.Signature...) - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the SignedExecutionPayloadEnvelopeContents object -func (s *SignedExecutionPayloadEnvelopeContents) UnmarshalSSZ(buf []byte) error { +func (c *PayloadAttestation) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 12 { + if size != 140 { return ssz.ErrSize } - tail := buf - var o0, o1, o2 uint64 + sszSlice0 := buf[0:2] // c.AggregationBits + sszSlice1 := buf[2:44] // c.Data + sszSlice2 := buf[44:140] // c.Signature - // Offset (0) 'SignedExecutionPayloadEnvelope' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } + // Field 0: AggregationBits + c.AggregationBits = make([]byte, 0, 2) + c.AggregationBits = append(c.AggregationBits, go_bitfield.Bitvector16(sszSlice0)...) - if o0 != 12 { - return ssz.ErrInvalidVariableOffset + // Field 1: Data + c.Data = new(PayloadAttestationData) + if err = c.Data.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Data: %w", err) } - // Offset (1) 'KzgProofs' - if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 { - return ssz.ErrOffset - } + // Field 2: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice2...) + return err +} - // Offset (2) 'Blobs' - if o2 = ssz.ReadOffset(buf[8:12]); o2 > size || o1 > o2 { - return ssz.ErrOffset +func (c *PayloadAttestation) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (0) 'SignedExecutionPayloadEnvelope' - { - buf = tail[o0:o1] - if s.SignedExecutionPayloadEnvelope == nil { - s.SignedExecutionPayloadEnvelope = new(SignedExecutionPayloadEnvelope) - } - if err = s.SignedExecutionPayloadEnvelope.UnmarshalSSZ(buf); err != nil { - return err - } +func (c *PayloadAttestation) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: AggregationBits + if len([]byte(c.AggregationBits)) != 2 { + return ssz.ErrBytesLength } - - // Field (1) 'KzgProofs' - { - buf = tail[o1:o2] - num, err := ssz.DivideInt2(len(buf), 48, 33554432) - if err != nil { - return err - } - s.KzgProofs = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(s.KzgProofs[ii]) == 0 { - s.KzgProofs[ii] = make([]byte, 0, len(buf[ii*48:(ii+1)*48])) - } - s.KzgProofs[ii] = append(s.KzgProofs[ii], buf[ii*48:(ii+1)*48]...) - } + hh.PutBytes([]byte(c.AggregationBits)) + // Field 1: Data + if err := c.Data.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Data: %w", err) } - - // Field (2) 'Blobs' - { - buf = tail[o2:] - num, err := ssz.DivideInt2(len(buf), 131072, 4096) - if err != nil { - return err - } - s.Blobs = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(s.Blobs[ii]) == 0 { - s.Blobs[ii] = make([]byte, 0, len(buf[ii*131072:(ii+1)*131072])) - } - s.Blobs[ii] = append(s.Blobs[ii], buf[ii*131072:(ii+1)*131072]...) - } + // Field 2: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength } - return err + hh.PutBytes(c.Signature) + hh.Merkleize(indx) + return nil +} + +func (c *PayloadAttestationData) SizeSSZ() int { + size := 42 + + return size +} + +func (c *PayloadAttestationData) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// SizeSSZ returns the ssz encoded size in bytes for the SignedExecutionPayloadEnvelopeContents object -func (s *SignedExecutionPayloadEnvelopeContents) SizeSSZ() (size int) { - size = 12 +func (c *PayloadAttestationData) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + + // Field 0: BeaconBlockRoot + if len(c.BeaconBlockRoot) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.BeaconBlockRoot...) - // Field (0) 'SignedExecutionPayloadEnvelope' - if s.SignedExecutionPayloadEnvelope == nil { - s.SignedExecutionPayloadEnvelope = new(SignedExecutionPayloadEnvelope) + // Field 1: Slot + if dst, err = c.Slot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Slot: %w", err) } - size += s.SignedExecutionPayloadEnvelope.SizeSSZ() - // Field (1) 'KzgProofs' - size += len(s.KzgProofs) * 48 + // Field 2: PayloadPresent + if c.PayloadPresent { + dst = append(dst, 1) + } else { + dst = append(dst, 0) + } - // Field (2) 'Blobs' - size += len(s.Blobs) * 131072 + // Field 3: BlobDataAvailable + if c.BlobDataAvailable { + dst = append(dst, 1) + } else { + dst = append(dst, 0) + } - return + return dst, err } -// HashTreeRoot ssz hashes the SignedExecutionPayloadEnvelopeContents object -func (s *SignedExecutionPayloadEnvelopeContents) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) -} +func (c *PayloadAttestationData) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 42 { + return ssz.ErrSize + } -// HashTreeRootWith ssz hashes the SignedExecutionPayloadEnvelopeContents object with a hasher -func (s *SignedExecutionPayloadEnvelopeContents) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() + sszSlice0 := buf[0:32] // c.BeaconBlockRoot + sszSlice1 := buf[32:40] // c.Slot + sszSlice2 := buf[40:41] // c.PayloadPresent + sszSlice3 := buf[41:42] // c.BlobDataAvailable - // Field (0) 'SignedExecutionPayloadEnvelope' - if err = s.SignedExecutionPayloadEnvelope.HashTreeRootWith(hh); err != nil { - return - } + // Field 0: BeaconBlockRoot + c.BeaconBlockRoot = make([]byte, 0, 32) + c.BeaconBlockRoot = append(c.BeaconBlockRoot, sszSlice0...) - // Field (1) 'KzgProofs' - { - if size := len(s.KzgProofs); size > 33554432 { - err = ssz.ErrListTooBigFn("--.KzgProofs", size, 33554432) - return - } - subIndx := hh.Index() - for _, i := range s.KzgProofs { - if len(i) != 48 { - err = ssz.ErrBytesLength - return - } - hh.PutBytes(i) - } + // Field 1: Slot + if err = c.Slot.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Slot: %w", err) + } - numItems := uint64(len(s.KzgProofs)) - hh.MerkleizeWithMixin(subIndx, numItems, 33554432) + // Field 2: PayloadPresent + if sszSlice2[0] > 1 { + return ssz.ErrInvalidSerialization + } + if sszSlice2[0] == 1 { + c.PayloadPresent = true + } else { + c.PayloadPresent = false } - // Field (2) 'Blobs' - { - if size := len(s.Blobs); size > 4096 { - err = ssz.ErrListTooBigFn("--.Blobs", size, 4096) - return - } - subIndx := hh.Index() - for _, i := range s.Blobs { - if len(i) != 131072 { - err = ssz.ErrBytesLength - return - } - hh.PutBytes(i) - } + // Field 3: BlobDataAvailable + if sszSlice3[0] > 1 { + return ssz.ErrInvalidSerialization + } + if sszSlice3[0] == 1 { + c.BlobDataAvailable = true + } else { + c.BlobDataAvailable = false + } + return err +} - numItems := uint64(len(s.Blobs)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) +func (c *PayloadAttestationData) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} +func (c *PayloadAttestationData) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: BeaconBlockRoot + if len(c.BeaconBlockRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.BeaconBlockRoot) + // Field 1: Slot + if err := c.Slot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Slot: %w", err) + } + // Field 2: PayloadPresent + hh.PutBool(c.PayloadPresent) + // Field 3: BlobDataAvailable + hh.PutBool(c.BlobDataAvailable) hh.Merkleize(indx) - return + return nil +} + +func (c *PayloadAttestationMessage) SizeSSZ() int { + size := 146 + + return size } -// MarshalSSZ ssz marshals the BuilderPendingPayment object -func (b *BuilderPendingPayment) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) +func (c *PayloadAttestationMessage) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the BuilderPendingPayment object to a target array -func (b *BuilderPendingPayment) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *PayloadAttestationMessage) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (0) 'Weight' - dst = ssz.MarshalUint(dst, b.Weight) + // Field 0: ValidatorIndex + if dst, err = c.ValidatorIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ValidatorIndex: %w", err) + } - // Field (1) 'Withdrawal' - if b.Withdrawal == nil { - b.Withdrawal = new(BuilderPendingWithdrawal) + // Field 1: Data + if c.Data == nil { + c.Data = new(PayloadAttestationData) } - if dst, err = b.Withdrawal.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.Data.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Data: %w", err) } - // Field (2) 'ProposerIndex' - dst = ssz.MarshalUint(dst, b.ProposerIndex) + // Field 2: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.Signature...) - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the BuilderPendingPayment object -func (b *BuilderPendingPayment) UnmarshalSSZ(buf []byte) error { +func (c *PayloadAttestationMessage) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 52 { + if size != 146 { return ssz.ErrSize } - // Field (0) 'Weight' - b.Weight = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Gwei](buf[0:8]) + sszSlice0 := buf[0:8] // c.ValidatorIndex + sszSlice1 := buf[8:50] // c.Data + sszSlice2 := buf[50:146] // c.Signature - // Field (1) 'Withdrawal' - if b.Withdrawal == nil { - b.Withdrawal = new(BuilderPendingWithdrawal) - } - if err = b.Withdrawal.UnmarshalSSZ(buf[8:44]); err != nil { - return err + // Field 0: ValidatorIndex + if err = c.ValidatorIndex.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("ValidatorIndex: %w", err) } - // Field (2) 'ProposerIndex' - b.ProposerIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[44:52]) + // Field 1: Data + c.Data = new(PayloadAttestationData) + if err = c.Data.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Data: %w", err) + } + // Field 2: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice2...) return err } -// SizeSSZ returns the ssz encoded size in bytes for the BuilderPendingPayment object -func (b *BuilderPendingPayment) SizeSSZ() (size int) { - size = 52 - return -} - -// HashTreeRoot ssz hashes the BuilderPendingPayment object -func (b *BuilderPendingPayment) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) +func (c *PayloadAttestationMessage) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the BuilderPendingPayment object with a hasher -func (b *BuilderPendingPayment) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *PayloadAttestationMessage) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Weight' - ssz.PutUint(hh, b.Weight) - - // Field (1) 'Withdrawal' - if err = b.Withdrawal.HashTreeRootWith(hh); err != nil { - return + // Field 0: ValidatorIndex + if err := c.ValidatorIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ValidatorIndex: %w", err) + } + // Field 1: Data + if err := c.Data.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Data: %w", err) } + // Field 2: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Signature) + hh.Merkleize(indx) + return nil +} - // Field (2) 'ProposerIndex' - ssz.PutUint(hh, b.ProposerIndex) +func (c *ProposerPreferences) SizeSSZ() int { + size := 76 - hh.Merkleize(indx) - return + return size } -// MarshalSSZ ssz marshals the BuilderPendingWithdrawal object -func (b *BuilderPendingWithdrawal) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) +func (c *ProposerPreferences) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the BuilderPendingWithdrawal object to a target array -func (b *BuilderPendingWithdrawal) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *ProposerPreferences) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + + // Field 0: DependentRoot + if len(c.DependentRoot) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.DependentRoot...) + + // Field 1: ProposalSlot + if dst, err = c.ProposalSlot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ProposalSlot: %w", err) + } - // Field (0) 'FeeRecipient' - if size := len(b.FeeRecipient); size != 20 { - err = ssz.ErrBytesLengthFn("--.FeeRecipient", size, 20) - return + // Field 2: ValidatorIndex + if dst, err = c.ValidatorIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ValidatorIndex: %w", err) } - dst = append(dst, b.FeeRecipient...) - // Field (1) 'Amount' - dst = ssz.MarshalUint(dst, b.Amount) + // Field 3: FeeRecipient + if len(c.FeeRecipient) != 20 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.FeeRecipient...) - // Field (2) 'BuilderIndex' - dst = ssz.MarshalUint(dst, b.BuilderIndex) + // Field 4: TargetGasLimit + dst = binary.LittleEndian.AppendUint64(dst, c.TargetGasLimit) - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the BuilderPendingWithdrawal object -func (b *BuilderPendingWithdrawal) UnmarshalSSZ(buf []byte) error { +func (c *ProposerPreferences) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 36 { + if size != 76 { return ssz.ErrSize } - // Field (0) 'FeeRecipient' - if cap(b.FeeRecipient) == 0 { - b.FeeRecipient = make([]byte, 0, len(buf[0:20])) + sszSlice0 := buf[0:32] // c.DependentRoot + sszSlice1 := buf[32:40] // c.ProposalSlot + sszSlice2 := buf[40:48] // c.ValidatorIndex + sszSlice3 := buf[48:68] // c.FeeRecipient + sszSlice4 := buf[68:76] // c.TargetGasLimit + + // Field 0: DependentRoot + c.DependentRoot = make([]byte, 0, 32) + c.DependentRoot = append(c.DependentRoot, sszSlice0...) + + // Field 1: ProposalSlot + if err = c.ProposalSlot.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("ProposalSlot: %w", err) } - b.FeeRecipient = append(b.FeeRecipient, buf[0:20]...) - // Field (1) 'Amount' - b.Amount = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Gwei](buf[20:28]) + // Field 2: ValidatorIndex + if err = c.ValidatorIndex.UnmarshalSSZ(sszSlice2); err != nil { + return fmt.Errorf("ValidatorIndex: %w", err) + } - // Field (2) 'BuilderIndex' - b.BuilderIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.BuilderIndex](buf[28:36]) + // Field 3: FeeRecipient + c.FeeRecipient = make([]byte, 0, 20) + c.FeeRecipient = append(c.FeeRecipient, sszSlice3...) + // Field 4: TargetGasLimit + c.TargetGasLimit = binary.LittleEndian.Uint64(sszSlice4) return err } -// SizeSSZ returns the ssz encoded size in bytes for the BuilderPendingWithdrawal object -func (b *BuilderPendingWithdrawal) SizeSSZ() (size int) { - size = 36 - return +func (c *ProposerPreferences) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} + +func (c *ProposerPreferences) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: DependentRoot + if len(c.DependentRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.DependentRoot) + // Field 1: ProposalSlot + if err := c.ProposalSlot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ProposalSlot: %w", err) + } + // Field 2: ValidatorIndex + if err := c.ValidatorIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ValidatorIndex: %w", err) + } + // Field 3: FeeRecipient + if len(c.FeeRecipient) != 20 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.FeeRecipient) + // Field 4: TargetGasLimit + hh.PutUint64(c.TargetGasLimit) + hh.Merkleize(indx) + return nil } -// HashTreeRoot ssz hashes the BuilderPendingWithdrawal object -func (b *BuilderPendingWithdrawal) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) +func (c *PTCs) SizeSSZ() int { + size := 128 + + return size } -// HashTreeRootWith ssz hashes the BuilderPendingWithdrawal object with a hasher -func (b *BuilderPendingWithdrawal) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() +func (c *PTCs) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} + +func (c *PTCs) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + + // Field 0: ValidatorIndices + if len(c.ValidatorIndices) != 16 { + return nil, ssz.ErrBytesLength + } + for _, o := range c.ValidatorIndices { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ValidatorIndices: %w", err) + } + } + + return dst, err +} - // Field (0) 'FeeRecipient' - if size := len(b.FeeRecipient); size != 20 { - err = ssz.ErrBytesLengthFn("--.FeeRecipient", size, 20) - return +func (c *PTCs) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 128 { + return ssz.ErrSize } - hh.PutBytes(b.FeeRecipient) - // Field (1) 'Amount' - ssz.PutUint(hh, b.Amount) + sszSlice0 := buf[0:128] // c.ValidatorIndices + + // Field 0: ValidatorIndices + { + c.ValidatorIndices = make([]primitives.ValidatorIndex, 16) + for i := 0; i < 16; i++ { + var tmp primitives.ValidatorIndex + + tmpSlice := sszSlice0[i*8 : (1+i)*8] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("ValidatorIndices: %w", err) + } + c.ValidatorIndices[i] = tmp + } + } + return err +} - // Field (2) 'BuilderIndex' - ssz.PutUint(hh, b.BuilderIndex) +func (c *PTCs) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} +func (c *PTCs) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: ValidatorIndices + { + if len(c.ValidatorIndices) != 16 { + return ssz.ErrVectorLength + } + subIndx := hh.Index() + for _, o := range c.ValidatorIndices { + hh.AppendUint64(uint64(o)) + } + hh.Merkleize(subIndx) + } hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the DataColumnSidecarGloas object -func (d *DataColumnSidecarGloas) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(d) +func (c *RequestAuthV1) SizeSSZ() int { + size := 12 + size += len(c.Data) + return size } -// MarshalSSZTo ssz marshals the DataColumnSidecarGloas object to a target array -func (d *DataColumnSidecarGloas) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(56) - - // Field (0) 'Index' - dst = ssz.MarshalUint(dst, d.Index) +func (c *RequestAuthV1) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Offset (1) 'Column' - dst = ssz.WriteOffset(dst, offset) - offset += len(d.Column) * 2048 +func (c *RequestAuthV1) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 12 - // Offset (2) 'KzgProofs' + // Field 0: Data dst = ssz.WriteOffset(dst, offset) - offset += len(d.KzgProofs) * 48 - - // Field (3) 'Slot' - dst = ssz.MarshalUint(dst, d.Slot) - - // Field (4) 'BeaconBlockRoot' - if size := len(d.BeaconBlockRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.BeaconBlockRoot", size, 32) - return - } - dst = append(dst, d.BeaconBlockRoot...) + offset += len(c.Data) - // Field (1) 'Column' - if size := len(d.Column); size > 4096 { - err = ssz.ErrListTooBigFn("--.Column", size, 4096) - return - } - for ii := 0; ii < len(d.Column); ii++ { - if size := len(d.Column[ii]); size != 2048 { - err = ssz.ErrBytesLengthFn("--.Column[ii]", size, 2048) - return - } - dst = append(dst, d.Column[ii]...) + // Field 1: Slot + if dst, err = c.Slot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Slot: %w", err) } - // Field (2) 'KzgProofs' - if size := len(d.KzgProofs); size > 4096 { - err = ssz.ErrListTooBigFn("--.KzgProofs", size, 4096) - return - } - for ii := 0; ii < len(d.KzgProofs); ii++ { - if size := len(d.KzgProofs[ii]); size != 48 { - err = ssz.ErrBytesLengthFn("--.KzgProofs[ii]", size, 48) - return - } - dst = append(dst, d.KzgProofs[ii]...) + // Field 0: Data + if len(c.Data) > 4096 { + return nil, ssz.ErrListTooBig } - - return + dst = append(dst, c.Data...) + return dst, err } -// UnmarshalSSZ ssz unmarshals the DataColumnSidecarGloas object -func (d *DataColumnSidecarGloas) UnmarshalSSZ(buf []byte) error { +func (c *RequestAuthV1) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 56 { + if size < 12 { return ssz.ErrSize } - tail := buf - var o1, o2 uint64 + sszSlice1 := buf[4:12] // c.Slot - // Field (0) 'Index' - d.Index = ssz.UnmarshallUint[uint64](buf[0:8]) - - // Offset (1) 'Column' - if o1 = ssz.ReadOffset(buf[8:12]); o1 > size { - return ssz.ErrOffset - } - - if o1 != 56 { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Data + if sszVarOffset0 != 12 { return ssz.ErrInvalidVariableOffset } - - // Offset (2) 'KzgProofs' - if o2 = ssz.ReadOffset(buf[12:16]); o2 > size || o1 > o2 { + if sszVarOffset0 > size { return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:] // c.Data - // Field (3) 'Slot' - d.Slot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[16:24]) + // Field 0: Data + c.Data = append([]byte{}, sszSlice0...) - // Field (4) 'BeaconBlockRoot' - if cap(d.BeaconBlockRoot) == 0 { - d.BeaconBlockRoot = make([]byte, 0, len(buf[24:56])) + // Field 1: Slot + if err = c.Slot.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Slot: %w", err) } - d.BeaconBlockRoot = append(d.BeaconBlockRoot, buf[24:56]...) + return err +} - // Field (1) 'Column' - { - buf = tail[o1:o2] - num, err := ssz.DivideInt2(len(buf), 2048, 4096) - if err != nil { - return err - } - d.Column = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(d.Column[ii]) == 0 { - d.Column[ii] = make([]byte, 0, len(buf[ii*2048:(ii+1)*2048])) - } - d.Column[ii] = append(d.Column[ii], buf[ii*2048:(ii+1)*2048]...) - } +func (c *RequestAuthV1) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} + +func (c *RequestAuthV1) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Data - // Field (2) 'KzgProofs' { - buf = tail[o2:] - num, err := ssz.DivideInt2(len(buf), 48, 4096) - if err != nil { - return err - } - d.KzgProofs = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(d.KzgProofs[ii]) == 0 { - d.KzgProofs[ii] = make([]byte, 0, len(buf[ii*48:(ii+1)*48])) - } - d.KzgProofs[ii] = append(d.KzgProofs[ii], buf[ii*48:(ii+1)*48]...) + if len(c.Data) > 4096 { + return ssz.ErrBytesLength } + subIndx := hh.Index() + hh.AppendBytes32(c.Data) + numItems := uint64(len(c.Data)) + hh.MerkleizeWithMixin(subIndx, numItems, (4096*1+31)/32) } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the DataColumnSidecarGloas object -func (d *DataColumnSidecarGloas) SizeSSZ() (size int) { - size = 56 - - // Field (1) 'Column' - size += len(d.Column) * 2048 - // Field (2) 'KzgProofs' - size += len(d.KzgProofs) * 48 - - return + // Field 1: Slot + if err := c.Slot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Slot: %w", err) + } + hh.Merkleize(indx) + return nil } -// HashTreeRoot ssz hashes the DataColumnSidecarGloas object -func (d *DataColumnSidecarGloas) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(d) +func (c *SignedBeaconBlockGloas) SizeSSZ() int { + size := 100 + if c.Block == nil { + c.Block = new(BeaconBlockGloas) + } + size += c.Block.SizeSSZ() + return size } -// HashTreeRootWith ssz hashes the DataColumnSidecarGloas object with a hasher -func (d *DataColumnSidecarGloas) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() +func (c *SignedBeaconBlockGloas) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (0) 'Index' - ssz.PutUint(hh, d.Index) +func (c *SignedBeaconBlockGloas) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 100 - // Field (1) 'Column' - { - if size := len(d.Column); size > 4096 { - err = ssz.ErrListTooBigFn("--.Column", size, 4096) - return - } - subIndx := hh.Index() - for _, i := range d.Column { - if len(i) != 2048 { - err = ssz.ErrBytesLength - return - } - hh.PutBytes(i) - } + // Field 0: Block + if c.Block == nil { + c.Block = new(BeaconBlockGloas) + } + dst = ssz.WriteOffset(dst, offset) + offset += c.Block.SizeSSZ() - numItems := uint64(len(d.Column)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) + // Field 1: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.Signature...) - // Field (2) 'KzgProofs' - { - if size := len(d.KzgProofs); size > 4096 { - err = ssz.ErrListTooBigFn("--.KzgProofs", size, 4096) - return - } - subIndx := hh.Index() - for _, i := range d.KzgProofs { - if len(i) != 48 { - err = ssz.ErrBytesLength - return - } - hh.PutBytes(i) - } + // Field 0: Block + if dst, err = c.Block.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Block: %w", err) + } + return dst, err +} - numItems := uint64(len(d.KzgProofs)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) +func (c *SignedBeaconBlockGloas) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 100 { + return ssz.ErrSize } - // Field (3) 'Slot' - ssz.PutUint(hh, d.Slot) + sszSlice1 := buf[4:100] // c.Signature + + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Block + if sszVarOffset0 != 100 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset0 > size { + return ssz.ErrOffset + } + sszSlice0 := buf[sszVarOffset0:] // c.Block - // Field (4) 'BeaconBlockRoot' - if size := len(d.BeaconBlockRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.BeaconBlockRoot", size, 32) - return + // Field 0: Block + c.Block = new(BeaconBlockGloas) + if err = c.Block.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Block: %w", err) } - hh.PutBytes(d.BeaconBlockRoot) - hh.Merkleize(indx) - return + // Field 1: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice1...) + return err } -// MarshalSSZ ssz marshals the ExecutionPayloadEnvelope object -func (e *ExecutionPayloadEnvelope) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(e) +func (c *SignedBeaconBlockGloas) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// MarshalSSZTo ssz marshals the ExecutionPayloadEnvelope object to a target array -func (e *ExecutionPayloadEnvelope) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(80) - - // Offset (0) 'Payload' - dst = ssz.WriteOffset(dst, offset) - if e.Payload == nil { - e.Payload = new(v1.ExecutionPayloadGloas) +func (c *SignedBeaconBlockGloas) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Block + if err := c.Block.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Block: %w", err) } - offset += e.Payload.SizeSSZ() + // Field 1: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Signature) + hh.Merkleize(indx) + return nil +} - // Offset (1) 'ExecutionRequests' - dst = ssz.WriteOffset(dst, offset) - if e.ExecutionRequests == nil { - e.ExecutionRequests = new(v1.ExecutionRequestsGloas) +func (c *SignedBlindedExecutionPayloadEnvelope) SizeSSZ() int { + size := 100 + if c.Message == nil { + c.Message = new(BlindedExecutionPayloadEnvelope) } - offset += e.ExecutionRequests.SizeSSZ() + size += c.Message.SizeSSZ() + return size +} - // Field (2) 'BuilderIndex' - dst = ssz.MarshalUint(dst, e.BuilderIndex) +func (c *SignedBlindedExecutionPayloadEnvelope) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (3) 'BeaconBlockRoot' - if size := len(e.BeaconBlockRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.BeaconBlockRoot", size, 32) - return - } - dst = append(dst, e.BeaconBlockRoot...) +func (c *SignedBlindedExecutionPayloadEnvelope) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 100 - // Field (4) 'ParentBeaconBlockRoot' - if size := len(e.ParentBeaconBlockRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentBeaconBlockRoot", size, 32) - return + // Field 0: Message + if c.Message == nil { + c.Message = new(BlindedExecutionPayloadEnvelope) } - dst = append(dst, e.ParentBeaconBlockRoot...) + dst = ssz.WriteOffset(dst, offset) + offset += c.Message.SizeSSZ() - // Field (0) 'Payload' - if dst, err = e.Payload.MarshalSSZTo(dst); err != nil { - return + // Field 1: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.Signature...) - // Field (1) 'ExecutionRequests' - if dst, err = e.ExecutionRequests.MarshalSSZTo(dst); err != nil { - return + // Field 0: Message + if dst, err = c.Message.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Message: %w", err) } - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the ExecutionPayloadEnvelope object -func (e *ExecutionPayloadEnvelope) UnmarshalSSZ(buf []byte) error { +func (c *SignedBlindedExecutionPayloadEnvelope) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 80 { + if size < 100 { return ssz.ErrSize } - tail := buf - var o0, o1 uint64 + sszSlice1 := buf[4:100] // c.Signature - // Offset (0) 'Payload' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } - - if o0 != 80 { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Message + if sszVarOffset0 != 100 { return ssz.ErrInvalidVariableOffset } - - // Offset (1) 'ExecutionRequests' - if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 { + if sszVarOffset0 > size { return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:] // c.Message - // Field (2) 'BuilderIndex' - e.BuilderIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.BuilderIndex](buf[8:16]) - - // Field (3) 'BeaconBlockRoot' - if cap(e.BeaconBlockRoot) == 0 { - e.BeaconBlockRoot = make([]byte, 0, len(buf[16:48])) + // Field 0: Message + c.Message = new(BlindedExecutionPayloadEnvelope) + if err = c.Message.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Message: %w", err) } - e.BeaconBlockRoot = append(e.BeaconBlockRoot, buf[16:48]...) - // Field (4) 'ParentBeaconBlockRoot' - if cap(e.ParentBeaconBlockRoot) == 0 { - e.ParentBeaconBlockRoot = make([]byte, 0, len(buf[48:80])) + // Field 1: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice1...) + return err +} + +func (c *SignedBlindedExecutionPayloadEnvelope) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - e.ParentBeaconBlockRoot = append(e.ParentBeaconBlockRoot, buf[48:80]...) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (0) 'Payload' - { - buf = tail[o0:o1] - if e.Payload == nil { - e.Payload = new(v1.ExecutionPayloadGloas) - } - if err = e.Payload.UnmarshalSSZ(buf); err != nil { - return err - } +func (c *SignedBlindedExecutionPayloadEnvelope) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Message + if err := c.Message.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Message: %w", err) + } + // Field 1: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength } + hh.PutBytes(c.Signature) + hh.Merkleize(indx) + return nil +} - // Field (1) 'ExecutionRequests' - { - buf = tail[o1:] - if e.ExecutionRequests == nil { - e.ExecutionRequests = new(v1.ExecutionRequestsGloas) - } - if err = e.ExecutionRequests.UnmarshalSSZ(buf); err != nil { - return err - } +func (c *SignedExecutionPayloadBid) SizeSSZ() int { + size := 100 + if c.Message == nil { + c.Message = new(ExecutionPayloadBid) } - return err + size += c.Message.SizeSSZ() + return size } -// SizeSSZ returns the ssz encoded size in bytes for the ExecutionPayloadEnvelope object -func (e *ExecutionPayloadEnvelope) SizeSSZ() (size int) { - size = 80 +func (c *SignedExecutionPayloadBid) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} + +func (c *SignedExecutionPayloadBid) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 100 - // Field (0) 'Payload' - if e.Payload == nil { - e.Payload = new(v1.ExecutionPayloadGloas) + // Field 0: Message + if c.Message == nil { + c.Message = new(ExecutionPayloadBid) } - size += e.Payload.SizeSSZ() + dst = ssz.WriteOffset(dst, offset) + offset += c.Message.SizeSSZ() - // Field (1) 'ExecutionRequests' - if e.ExecutionRequests == nil { - e.ExecutionRequests = new(v1.ExecutionRequestsGloas) + // Field 1: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } - size += e.ExecutionRequests.SizeSSZ() + dst = append(dst, c.Signature...) - return + // Field 0: Message + if dst, err = c.Message.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Message: %w", err) + } + return dst, err } -// HashTreeRoot ssz hashes the ExecutionPayloadEnvelope object -func (e *ExecutionPayloadEnvelope) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(e) -} +func (c *SignedExecutionPayloadBid) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 100 { + return ssz.ErrSize + } -// HashTreeRootWith ssz hashes the ExecutionPayloadEnvelope object with a hasher -func (e *ExecutionPayloadEnvelope) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() + sszSlice1 := buf[4:100] // c.Signature - // Field (0) 'Payload' - if err = e.Payload.HashTreeRootWith(hh); err != nil { - return + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Message + if sszVarOffset0 != 100 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset0 > size { + return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:] // c.Message - // Field (1) 'ExecutionRequests' - if err = e.ExecutionRequests.HashTreeRootWith(hh); err != nil { - return + // Field 0: Message + c.Message = new(ExecutionPayloadBid) + if err = c.Message.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Message: %w", err) } - // Field (2) 'BuilderIndex' - ssz.PutUint(hh, e.BuilderIndex) + // Field 1: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice1...) + return err +} - // Field (3) 'BeaconBlockRoot' - if size := len(e.BeaconBlockRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.BeaconBlockRoot", size, 32) - return +func (c *SignedExecutionPayloadBid) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - hh.PutBytes(e.BeaconBlockRoot) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (4) 'ParentBeaconBlockRoot' - if size := len(e.ParentBeaconBlockRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentBeaconBlockRoot", size, 32) - return +func (c *SignedExecutionPayloadBid) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Message + if err := c.Message.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Message: %w", err) } - hh.PutBytes(e.ParentBeaconBlockRoot) - + // Field 1: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Signature) hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the SignedExecutionPayloadEnvelope object -func (s *SignedExecutionPayloadEnvelope) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) +func (c *SignedExecutionPayloadEnvelope) SizeSSZ() int { + size := 100 + if c.Message == nil { + c.Message = new(ExecutionPayloadEnvelope) + } + size += c.Message.SizeSSZ() + return size } -// MarshalSSZTo ssz marshals the SignedExecutionPayloadEnvelope object to a target array -func (s *SignedExecutionPayloadEnvelope) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(100) +func (c *SignedExecutionPayloadEnvelope) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Offset (0) 'Message' - dst = ssz.WriteOffset(dst, offset) - if s.Message == nil { - s.Message = new(ExecutionPayloadEnvelope) - } - offset += s.Message.SizeSSZ() +func (c *SignedExecutionPayloadEnvelope) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 100 - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 0: Message + if c.Message == nil { + c.Message = new(ExecutionPayloadEnvelope) } - dst = append(dst, s.Signature...) + dst = ssz.WriteOffset(dst, offset) + offset += c.Message.SizeSSZ() - // Field (0) 'Message' - if dst, err = s.Message.MarshalSSZTo(dst); err != nil { - return + // Field 1: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.Signature...) - return + // Field 0: Message + if dst, err = c.Message.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Message: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the SignedExecutionPayloadEnvelope object -func (s *SignedExecutionPayloadEnvelope) UnmarshalSSZ(buf []byte) error { +func (c *SignedExecutionPayloadEnvelope) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size < 100 { return ssz.ErrSize } - tail := buf - var o0 uint64 + sszSlice1 := buf[4:100] // c.Signature - // Offset (0) 'Message' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } - - if o0 != 100 { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Message + if sszVarOffset0 != 100 { return ssz.ErrInvalidVariableOffset } - - // Field (1) 'Signature' - if cap(s.Signature) == 0 { - s.Signature = make([]byte, 0, len(buf[4:100])) + if sszVarOffset0 > size { + return ssz.ErrOffset } - s.Signature = append(s.Signature, buf[4:100]...) + sszSlice0 := buf[sszVarOffset0:] // c.Message - // Field (0) 'Message' - { - buf = tail[o0:] - if s.Message == nil { - s.Message = new(ExecutionPayloadEnvelope) - } - if err = s.Message.UnmarshalSSZ(buf); err != nil { - return err - } + // Field 0: Message + c.Message = new(ExecutionPayloadEnvelope) + if err = c.Message.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Message: %w", err) } + + // Field 1: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice1...) return err } -// SizeSSZ returns the ssz encoded size in bytes for the SignedExecutionPayloadEnvelope object -func (s *SignedExecutionPayloadEnvelope) SizeSSZ() (size int) { - size = 100 - - // Field (0) 'Message' - if s.Message == nil { - s.Message = new(ExecutionPayloadEnvelope) +func (c *SignedExecutionPayloadEnvelope) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - size += s.Message.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the SignedExecutionPayloadEnvelope object -func (s *SignedExecutionPayloadEnvelope) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the SignedExecutionPayloadEnvelope object with a hasher -func (s *SignedExecutionPayloadEnvelope) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *SignedExecutionPayloadEnvelope) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Message' - if err = s.Message.HashTreeRootWith(hh); err != nil { - return + // Field 0: Message + if err := c.Message.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Message: %w", err) } - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 1: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength } - hh.PutBytes(s.Signature) - + hh.PutBytes(c.Signature) hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the BlindedExecutionPayloadEnvelope object -func (b *BlindedExecutionPayloadEnvelope) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) +func (c *SignedExecutionPayloadEnvelopeContents) SizeSSZ() int { + size := 12 + if c.SignedExecutionPayloadEnvelope == nil { + c.SignedExecutionPayloadEnvelope = new(SignedExecutionPayloadEnvelope) + } + size += c.SignedExecutionPayloadEnvelope.SizeSSZ() + size += len(c.KzgProofs) * 48 + size += len(c.Blobs) * 131072 + return size +} + +func (c *SignedExecutionPayloadEnvelopeContents) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the BlindedExecutionPayloadEnvelope object to a target array -func (b *BlindedExecutionPayloadEnvelope) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(148) +func (c *SignedExecutionPayloadEnvelopeContents) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 12 - // Field (0) 'BlockHash' - if size := len(b.BlockHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockHash", size, 32) - return + // Field 0: SignedExecutionPayloadEnvelope + if c.SignedExecutionPayloadEnvelope == nil { + c.SignedExecutionPayloadEnvelope = new(SignedExecutionPayloadEnvelope) } - dst = append(dst, b.BlockHash...) + dst = ssz.WriteOffset(dst, offset) + offset += c.SignedExecutionPayloadEnvelope.SizeSSZ() - // Offset (1) 'ExecutionRequests' + // Field 1: KzgProofs dst = ssz.WriteOffset(dst, offset) - if b.ExecutionRequests == nil { - b.ExecutionRequests = new(v1.ExecutionRequestsGloas) - } - offset += b.ExecutionRequests.SizeSSZ() + offset += len(c.KzgProofs) * 48 - // Field (2) 'BuilderIndex' - dst = ssz.MarshalUint(dst, b.BuilderIndex) + // Field 2: Blobs + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Blobs) * 131072 - // Field (3) 'BeaconBlockRoot' - if size := len(b.BeaconBlockRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.BeaconBlockRoot", size, 32) - return + // Field 0: SignedExecutionPayloadEnvelope + if dst, err = c.SignedExecutionPayloadEnvelope.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SignedExecutionPayloadEnvelope: %w", err) } - dst = append(dst, b.BeaconBlockRoot...) - - // Field (4) 'Slot' - dst = ssz.MarshalUint(dst, b.Slot) - // Field (5) 'ParentBlockHash' - if size := len(b.ParentBlockHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentBlockHash", size, 32) - return + // Field 1: KzgProofs + if len(c.KzgProofs) > 33554432 { + return nil, ssz.ErrListTooBig } - dst = append(dst, b.ParentBlockHash...) - - // Field (6) 'ParentBeaconBlockRoot' - if size := len(b.ParentBeaconBlockRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentBeaconBlockRoot", size, 32) - return + for _, o := range c.KzgProofs { + if len(o) != 48 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) } - dst = append(dst, b.ParentBeaconBlockRoot...) - // Field (1) 'ExecutionRequests' - if dst, err = b.ExecutionRequests.MarshalSSZTo(dst); err != nil { - return + // Field 2: Blobs + if len(c.Blobs) > 4096 { + return nil, ssz.ErrListTooBig } - - return + for _, o := range c.Blobs { + if len(o) != 131072 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the BlindedExecutionPayloadEnvelope object -func (b *BlindedExecutionPayloadEnvelope) UnmarshalSSZ(buf []byte) error { +func (c *SignedExecutionPayloadEnvelopeContents) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 148 { + if size < 12 { return ssz.ErrSize } - tail := buf - var o1 uint64 - - // Field (0) 'BlockHash' - if cap(b.BlockHash) == 0 { - b.BlockHash = make([]byte, 0, len(buf[0:32])) + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.SignedExecutionPayloadEnvelope + if sszVarOffset0 != 12 { + return ssz.ErrInvalidVariableOffset } - b.BlockHash = append(b.BlockHash, buf[0:32]...) - - // Offset (1) 'ExecutionRequests' - if o1 = ssz.ReadOffset(buf[32:36]); o1 > size { + if sszVarOffset0 > size { return ssz.ErrOffset } - - if o1 != 148 { - return ssz.ErrInvalidVariableOffset + sszVarOffset1 := ssz.ReadOffset(buf[4:8]) // c.KzgProofs + if sszVarOffset1 > size || sszVarOffset1 < sszVarOffset0 { + return ssz.ErrOffset } - - // Field (2) 'BuilderIndex' - b.BuilderIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.BuilderIndex](buf[36:44]) - - // Field (3) 'BeaconBlockRoot' - if cap(b.BeaconBlockRoot) == 0 { - b.BeaconBlockRoot = make([]byte, 0, len(buf[44:76])) + sszVarOffset2 := ssz.ReadOffset(buf[8:12]) // c.Blobs + if sszVarOffset2 > size || sszVarOffset2 < sszVarOffset1 { + return ssz.ErrOffset } - b.BeaconBlockRoot = append(b.BeaconBlockRoot, buf[44:76]...) + sszSlice0 := buf[sszVarOffset0:sszVarOffset1] // c.SignedExecutionPayloadEnvelope + sszSlice1 := buf[sszVarOffset1:sszVarOffset2] // c.KzgProofs + sszSlice2 := buf[sszVarOffset2:] // c.Blobs - // Field (4) 'Slot' - b.Slot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[76:84]) - - // Field (5) 'ParentBlockHash' - if cap(b.ParentBlockHash) == 0 { - b.ParentBlockHash = make([]byte, 0, len(buf[84:116])) + // Field 0: SignedExecutionPayloadEnvelope + c.SignedExecutionPayloadEnvelope = new(SignedExecutionPayloadEnvelope) + if err = c.SignedExecutionPayloadEnvelope.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("SignedExecutionPayloadEnvelope: %w", err) } - b.ParentBlockHash = append(b.ParentBlockHash, buf[84:116]...) - // Field (6) 'ParentBeaconBlockRoot' - if cap(b.ParentBeaconBlockRoot) == 0 { - b.ParentBeaconBlockRoot = make([]byte, 0, len(buf[116:148])) + // Field 1: KzgProofs + { + if len(sszSlice1)%48 != 0 { + return fmt.Errorf("misaligned bytes: c.KzgProofs length is %d, which is not a multiple of 48: %w", len(sszSlice1), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice1) / 48 + if numElem > 33554432 { + return fmt.Errorf("ssz-max exceeded: c.KzgProofs has %d elements, ssz-max is 33554432: %w", numElem, ssz.ErrListTooBig) + } + c.KzgProofs = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte + + tmpSlice := sszSlice1[i*48 : (1+i)*48] + tmp = make([]byte, 0, 48) + tmp = append(tmp, tmpSlice...) + c.KzgProofs[i] = tmp + } } - b.ParentBeaconBlockRoot = append(b.ParentBeaconBlockRoot, buf[116:148]...) - // Field (1) 'ExecutionRequests' + // Field 2: Blobs { - buf = tail[o1:] - if b.ExecutionRequests == nil { - b.ExecutionRequests = new(v1.ExecutionRequestsGloas) + if len(sszSlice2)%131072 != 0 { + return fmt.Errorf("misaligned bytes: c.Blobs length is %d, which is not a multiple of 131072: %w", len(sszSlice2), ssz.ErrIncorrectListSize) } - if err = b.ExecutionRequests.UnmarshalSSZ(buf); err != nil { - return err + numElem := len(sszSlice2) / 131072 + if numElem > 4096 { + return fmt.Errorf("ssz-max exceeded: c.Blobs has %d elements, ssz-max is 4096: %w", numElem, ssz.ErrListTooBig) + } + c.Blobs = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte + + tmpSlice := sszSlice2[i*131072 : (1+i)*131072] + tmp = make([]byte, 0, 131072) + tmp = append(tmp, tmpSlice...) + c.Blobs[i] = tmp } } return err } -// SizeSSZ returns the ssz encoded size in bytes for the BlindedExecutionPayloadEnvelope object -func (b *BlindedExecutionPayloadEnvelope) SizeSSZ() (size int) { - size = 148 - - // Field (1) 'ExecutionRequests' - if b.ExecutionRequests == nil { - b.ExecutionRequests = new(v1.ExecutionRequestsGloas) +func (c *SignedExecutionPayloadEnvelopeContents) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - size += b.ExecutionRequests.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the BlindedExecutionPayloadEnvelope object -func (b *BlindedExecutionPayloadEnvelope) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the BlindedExecutionPayloadEnvelope object with a hasher -func (b *BlindedExecutionPayloadEnvelope) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *SignedExecutionPayloadEnvelopeContents) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'BlockHash' - if size := len(b.BlockHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockHash", size, 32) - return - } - hh.PutBytes(b.BlockHash) - - // Field (1) 'ExecutionRequests' - if err = b.ExecutionRequests.HashTreeRootWith(hh); err != nil { - return + // Field 0: SignedExecutionPayloadEnvelope + if err := c.SignedExecutionPayloadEnvelope.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SignedExecutionPayloadEnvelope: %w", err) } - - // Field (2) 'BuilderIndex' - ssz.PutUint(hh, b.BuilderIndex) - - // Field (3) 'BeaconBlockRoot' - if size := len(b.BeaconBlockRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.BeaconBlockRoot", size, 32) - return + // Field 1: KzgProofs + { + if len(c.KzgProofs) > 33554432 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.KzgProofs { + if len(o) != 48 { + return ssz.ErrBytesLength + } + hh.PutBytes(o) + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.KzgProofs)), 33554432) } - hh.PutBytes(b.BeaconBlockRoot) - - // Field (4) 'Slot' - ssz.PutUint(hh, b.Slot) - - // Field (5) 'ParentBlockHash' - if size := len(b.ParentBlockHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentBlockHash", size, 32) - return + // Field 2: Blobs + { + if len(c.Blobs) > 4096 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.Blobs { + if len(o) != 131072 { + return ssz.ErrBytesLength + } + hh.PutBytes(o) + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Blobs)), 4096) } - hh.PutBytes(b.ParentBlockHash) + hh.Merkleize(indx) + return nil +} - // Field (6) 'ParentBeaconBlockRoot' - if size := len(b.ParentBeaconBlockRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentBeaconBlockRoot", size, 32) - return - } - hh.PutBytes(b.ParentBeaconBlockRoot) +func (c *SignedProposerPreferences) SizeSSZ() int { + size := 172 - hh.Merkleize(indx) - return + return size } -// MarshalSSZ ssz marshals the SignedBlindedExecutionPayloadEnvelope object -func (s *SignedBlindedExecutionPayloadEnvelope) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) +func (c *SignedProposerPreferences) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the SignedBlindedExecutionPayloadEnvelope object to a target array -func (s *SignedBlindedExecutionPayloadEnvelope) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(100) +func (c *SignedProposerPreferences) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Offset (0) 'Message' - dst = ssz.WriteOffset(dst, offset) - if s.Message == nil { - s.Message = new(BlindedExecutionPayloadEnvelope) + // Field 0: Message + if c.Message == nil { + c.Message = new(ProposerPreferences) } - offset += s.Message.SizeSSZ() - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + if dst, err = c.Message.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Message: %w", err) } - dst = append(dst, s.Signature...) - // Field (0) 'Message' - if dst, err = s.Message.MarshalSSZTo(dst); err != nil { - return + // Field 1: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.Signature...) - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the SignedBlindedExecutionPayloadEnvelope object -func (s *SignedBlindedExecutionPayloadEnvelope) UnmarshalSSZ(buf []byte) error { +func (c *SignedProposerPreferences) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 100 { + if size != 172 { return ssz.ErrSize } - tail := buf - var o0 uint64 - - // Offset (0) 'Message' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } - - if o0 != 100 { - return ssz.ErrInvalidVariableOffset - } + sszSlice0 := buf[0:76] // c.Message + sszSlice1 := buf[76:172] // c.Signature - // Field (1) 'Signature' - if cap(s.Signature) == 0 { - s.Signature = make([]byte, 0, len(buf[4:100])) + // Field 0: Message + c.Message = new(ProposerPreferences) + if err = c.Message.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Message: %w", err) } - s.Signature = append(s.Signature, buf[4:100]...) - // Field (0) 'Message' - { - buf = tail[o0:] - if s.Message == nil { - s.Message = new(BlindedExecutionPayloadEnvelope) - } - if err = s.Message.UnmarshalSSZ(buf); err != nil { - return err - } - } + // Field 1: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice1...) return err } -// SizeSSZ returns the ssz encoded size in bytes for the SignedBlindedExecutionPayloadEnvelope object -func (s *SignedBlindedExecutionPayloadEnvelope) SizeSSZ() (size int) { - size = 100 - - // Field (0) 'Message' - if s.Message == nil { - s.Message = new(BlindedExecutionPayloadEnvelope) +func (c *SignedProposerPreferences) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - size += s.Message.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the SignedBlindedExecutionPayloadEnvelope object -func (s *SignedBlindedExecutionPayloadEnvelope) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the SignedBlindedExecutionPayloadEnvelope object with a hasher -func (s *SignedBlindedExecutionPayloadEnvelope) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *SignedProposerPreferences) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Message' - if err = s.Message.HashTreeRootWith(hh); err != nil { - return + // Field 0: Message + if err := c.Message.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Message: %w", err) } - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 1: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength } - hh.PutBytes(s.Signature) - + hh.PutBytes(c.Signature) hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the Builder object -func (b *Builder) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) +func (c *SignedRequestAuthV1) SizeSSZ() int { + size := 100 + if c.Message == nil { + c.Message = new(RequestAuthV1) + } + size += c.Message.SizeSSZ() + return size } -// MarshalSSZTo ssz marshals the Builder object to a target array -func (b *Builder) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *SignedRequestAuthV1) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (0) 'Pubkey' - if size := len(b.Pubkey); size != 48 { - err = ssz.ErrBytesLengthFn("--.Pubkey", size, 48) - return - } - dst = append(dst, b.Pubkey...) +func (c *SignedRequestAuthV1) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 100 - // Field (1) 'Version' - if size := len(b.Version); size != 1 { - err = ssz.ErrBytesLengthFn("--.Version", size, 1) - return + // Field 0: Message + if c.Message == nil { + c.Message = new(RequestAuthV1) } - dst = append(dst, b.Version...) + dst = ssz.WriteOffset(dst, offset) + offset += c.Message.SizeSSZ() - // Field (2) 'ExecutionAddress' - if size := len(b.ExecutionAddress); size != 20 { - err = ssz.ErrBytesLengthFn("--.ExecutionAddress", size, 20) - return + // Field 1: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.ExecutionAddress...) + dst = append(dst, c.Signature...) - // Field (3) 'Balance' - dst = ssz.MarshalUint(dst, b.Balance) - - // Field (4) 'DepositEpoch' - dst = ssz.MarshalUint(dst, b.DepositEpoch) - - // Field (5) 'WithdrawableEpoch' - dst = ssz.MarshalUint(dst, b.WithdrawableEpoch) - - return + // Field 0: Message + if dst, err = c.Message.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Message: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the Builder object -func (b *Builder) UnmarshalSSZ(buf []byte) error { +func (c *SignedRequestAuthV1) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 93 { + if size < 100 { return ssz.ErrSize } - // Field (0) 'Pubkey' - if cap(b.Pubkey) == 0 { - b.Pubkey = make([]byte, 0, len(buf[0:48])) - } - b.Pubkey = append(b.Pubkey, buf[0:48]...) + sszSlice1 := buf[4:100] // c.Signature - // Field (1) 'Version' - if cap(b.Version) == 0 { - b.Version = make([]byte, 0, len(buf[48:49])) + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Message + if sszVarOffset0 != 100 { + return ssz.ErrInvalidVariableOffset } - b.Version = append(b.Version, buf[48:49]...) - - // Field (2) 'ExecutionAddress' - if cap(b.ExecutionAddress) == 0 { - b.ExecutionAddress = make([]byte, 0, len(buf[49:69])) + if sszVarOffset0 > size { + return ssz.ErrOffset } - b.ExecutionAddress = append(b.ExecutionAddress, buf[49:69]...) - - // Field (3) 'Balance' - b.Balance = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Gwei](buf[69:77]) - - // Field (4) 'DepositEpoch' - b.DepositEpoch = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Epoch](buf[77:85]) + sszSlice0 := buf[sszVarOffset0:] // c.Message - // Field (5) 'WithdrawableEpoch' - b.WithdrawableEpoch = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Epoch](buf[85:93]) + // Field 0: Message + c.Message = new(RequestAuthV1) + if err = c.Message.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Message: %w", err) + } + // Field 1: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice1...) return err } -// SizeSSZ returns the ssz encoded size in bytes for the Builder object -func (b *Builder) SizeSSZ() (size int) { - size = 93 - return -} - -// HashTreeRoot ssz hashes the Builder object -func (b *Builder) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) +func (c *SignedRequestAuthV1) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the Builder object with a hasher -func (b *Builder) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *SignedRequestAuthV1) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Pubkey' - if size := len(b.Pubkey); size != 48 { - err = ssz.ErrBytesLengthFn("--.Pubkey", size, 48) - return - } - hh.PutBytes(b.Pubkey) - - // Field (1) 'Version' - if size := len(b.Version); size != 1 { - err = ssz.ErrBytesLengthFn("--.Version", size, 1) - return + // Field 0: Message + if err := c.Message.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Message: %w", err) } - hh.PutBytes(b.Version) - - // Field (2) 'ExecutionAddress' - if size := len(b.ExecutionAddress); size != 20 { - err = ssz.ErrBytesLengthFn("--.ExecutionAddress", size, 20) - return + // Field 1: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength } - hh.PutBytes(b.ExecutionAddress) - - // Field (3) 'Balance' - ssz.PutUint(hh, b.Balance) - - // Field (4) 'DepositEpoch' - ssz.PutUint(hh, b.DepositEpoch) - - // Field (5) 'WithdrawableEpoch' - ssz.PutUint(hh, b.WithdrawableEpoch) - + hh.PutBytes(c.Signature) hh.Merkleize(indx) - return + return nil } diff --git a/proto/prysm/v1alpha1/gloas.ssz.go b/proto/prysm/v1alpha1/gloas.ssz.go index b60bc34eb3d8..9eeba105bb1b 100644 --- a/proto/prysm/v1alpha1/gloas.ssz.go +++ b/proto/prysm/v1alpha1/gloas.ssz.go @@ -1,5470 +1,5589 @@ //go:build !minimal -// Code generated by fastssz. DO NOT EDIT. package eth import ( - github_com_OffchainLabs_prysm_v7_consensus_types_primitives "github.com/OffchainLabs/prysm/v7/consensus-types/primitives" + binary "encoding/binary" + "fmt" + go_bitfield "github.com/OffchainLabs/go-bitfield" + ssz "github.com/OffchainLabs/methodical-ssz/ssz" + primitives "github.com/OffchainLabs/prysm/v7/consensus-types/primitives" v1 "github.com/OffchainLabs/prysm/v7/proto/engine/v1" - ssz "github.com/prysmaticlabs/fastssz" ) -// MarshalSSZ ssz marshals the AttestationGloas object -func (a *AttestationGloas) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(a) +func (c *AttestationGloas) SizeSSZ() int { + size := 236 + size += len(c.AggregationBits) + return size } -// MarshalSSZTo ssz marshals the AttestationGloas object to a target array -func (a *AttestationGloas) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(236) +func (c *AttestationGloas) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} + +func (c *AttestationGloas) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 236 - // Offset (0) 'AggregationBits' + // Field 0: AggregationBits dst = ssz.WriteOffset(dst, offset) - offset += len(a.AggregationBits) + offset += len(c.AggregationBits) - // Field (1) 'Data' - if a.Data == nil { - a.Data = new(AttestationData) + // Field 1: Data + if c.Data == nil { + c.Data = new(AttestationData) } - if dst, err = a.Data.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.Data.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Data: %w", err) } - // Field (2) 'Signature' - if size := len(a.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 2: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } - dst = append(dst, a.Signature...) + dst = append(dst, c.Signature...) - // Field (3) 'CommitteeBits' - if size := len(a.CommitteeBits); size != 8 { - err = ssz.ErrBytesLengthFn("--.CommitteeBits", size, 8) - return + // Field 3: CommitteeBits + if len([]byte(c.CommitteeBits)) != 8 { + return nil, ssz.ErrBytesLength } - dst = append(dst, a.CommitteeBits...) + dst = append(dst, []byte(c.CommitteeBits)...) - // Field (0) 'AggregationBits' - if size := len(a.AggregationBits); size > 131072 { - err = ssz.ErrBytesLengthFn("--.AggregationBits", size, 131072) - return + // Field 0: AggregationBits + if len(c.AggregationBits) > 131072 { + return nil, ssz.ErrListTooBig } - dst = append(dst, a.AggregationBits...) - - return + dst = append(dst, c.AggregationBits...) + return dst, err } -// UnmarshalSSZ ssz unmarshals the AttestationGloas object -func (a *AttestationGloas) UnmarshalSSZ(buf []byte) error { +func (c *AttestationGloas) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size < 236 { return ssz.ErrSize } - tail := buf - var o0 uint64 + sszSlice1 := buf[4:132] // c.Data + sszSlice2 := buf[132:228] // c.Signature + sszSlice3 := buf[228:236] // c.CommitteeBits - // Offset (0) 'AggregationBits' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } - - if o0 != 236 { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.AggregationBits + if sszVarOffset0 != 236 { 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' - if cap(a.Signature) == 0 { - a.Signature = make([]byte, 0, len(buf[132:228])) + if sszVarOffset0 > size { + return ssz.ErrOffset } - a.Signature = append(a.Signature, buf[132:228]...) + sszSlice0 := buf[sszVarOffset0:] // c.AggregationBits - // Field (3) 'CommitteeBits' - if cap(a.CommitteeBits) == 0 { - a.CommitteeBits = make([]byte, 0, len(buf[228:236])) + // Field 0: AggregationBits + if err = ssz.ValidateBitlist(sszSlice0, 131072); err != nil { + return fmt.Errorf("AggregationBits: %w", err) } - a.CommitteeBits = append(a.CommitteeBits, buf[228:236]...) + c.AggregationBits = append([]byte{}, go_bitfield.Bitlist(sszSlice0)...) - // 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...) + // Field 1: Data + c.Data = new(AttestationData) + if err = c.Data.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Data: %w", err) } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the AttestationGloas object -func (a *AttestationGloas) SizeSSZ() (size int) { - size = 236 - // Field (0) 'AggregationBits' - size += len(a.AggregationBits) + // Field 2: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice2...) - return + // Field 3: CommitteeBits + c.CommitteeBits = make([]byte, 0, 8) + c.CommitteeBits = append(c.CommitteeBits, go_bitfield.Bitvector64(sszSlice3)...) + return err } -// HashTreeRoot ssz hashes the AttestationGloas object -func (a *AttestationGloas) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(a) +func (c *AttestationGloas) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the AttestationGloas object with a hasher -func (a *AttestationGloas) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *AttestationGloas) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'AggregationBits' - if len(a.AggregationBits) == 0 { - err = ssz.ErrEmptyBitlist - return + // Field 0: AggregationBits + if len(c.AggregationBits) == 0 { + return ssz.ErrEmptyBitlist } - hh.PutBitlist(a.AggregationBits, 131072) - - // Field (1) 'Data' - if err = a.Data.HashTreeRootWith(hh); err != nil { - return + hh.PutBitlist(c.AggregationBits, 131072) + // Field 1: Data + if err := c.Data.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Data: %w", err) } - - // Field (2) 'Signature' - if size := len(a.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 2: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength } - hh.PutBytes(a.Signature) - - // Field (3) 'CommitteeBits' - if size := len(a.CommitteeBits); size != 8 { - err = ssz.ErrBytesLengthFn("--.CommitteeBits", size, 8) - return + hh.PutBytes(c.Signature) + // Field 3: CommitteeBits + if len([]byte(c.CommitteeBits)) != 8 { + return ssz.ErrBytesLength } - hh.PutBytes(a.CommitteeBits) - + hh.PutBytes([]byte(c.CommitteeBits)) hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the SignedAggregateAttestationAndProofGloas object -func (s *SignedAggregateAttestationAndProofGloas) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) +func (c *AggregateAttestationAndProofGloas) SizeSSZ() int { + size := 108 + if c.Aggregate == nil { + c.Aggregate = new(AttestationGloas) + } + size += c.Aggregate.SizeSSZ() + return size } -// MarshalSSZTo ssz marshals the SignedAggregateAttestationAndProofGloas object to a target array -func (s *SignedAggregateAttestationAndProofGloas) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(100) +func (c *AggregateAttestationAndProofGloas) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Offset (0) 'Message' - dst = ssz.WriteOffset(dst, offset) - if s.Message == nil { - s.Message = new(AggregateAttestationAndProofGloas) +func (c *AggregateAttestationAndProofGloas) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 108 + + // Field 0: AggregatorIndex + if dst, err = c.AggregatorIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("AggregatorIndex: %w", err) } - offset += s.Message.SizeSSZ() - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 1: Aggregate + if c.Aggregate == nil { + c.Aggregate = new(AttestationGloas) } - dst = append(dst, s.Signature...) + dst = ssz.WriteOffset(dst, offset) + offset += c.Aggregate.SizeSSZ() - // Field (0) 'Message' - if dst, err = s.Message.MarshalSSZTo(dst); err != nil { - return + // Field 2: SelectionProof + if len(c.SelectionProof) != 96 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.SelectionProof...) - return + // Field 1: Aggregate + if dst, err = c.Aggregate.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Aggregate: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the SignedAggregateAttestationAndProofGloas object -func (s *SignedAggregateAttestationAndProofGloas) UnmarshalSSZ(buf []byte) error { +func (c *AggregateAttestationAndProofGloas) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 100 { + if size < 108 { return ssz.ErrSize } - tail := buf - var o0 uint64 + sszSlice0 := buf[0:8] // c.AggregatorIndex + sszSlice2 := buf[12:108] // c.SelectionProof - // Offset (0) 'Message' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { + sszVarOffset1 := ssz.ReadOffset(buf[8:12]) // c.Aggregate + if sszVarOffset1 != 108 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset1 > size { return ssz.ErrOffset } + sszSlice1 := buf[sszVarOffset1:] // c.Aggregate - if o0 != 100 { - return ssz.ErrInvalidVariableOffset + // Field 0: AggregatorIndex + if err = c.AggregatorIndex.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("AggregatorIndex: %w", err) } - // Field (1) 'Signature' - if cap(s.Signature) == 0 { - s.Signature = make([]byte, 0, len(buf[4:100])) + // Field 1: Aggregate + c.Aggregate = new(AttestationGloas) + if err = c.Aggregate.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Aggregate: %w", err) } - s.Signature = append(s.Signature, buf[4:100]...) - // Field (0) 'Message' - { - buf = tail[o0:] - if s.Message == nil { - s.Message = new(AggregateAttestationAndProofGloas) - } - if err = s.Message.UnmarshalSSZ(buf); err != nil { - return err - } - } + // Field 2: SelectionProof + c.SelectionProof = make([]byte, 0, 96) + c.SelectionProof = append(c.SelectionProof, sszSlice2...) return err } -// SizeSSZ returns the ssz encoded size in bytes for the SignedAggregateAttestationAndProofGloas object -func (s *SignedAggregateAttestationAndProofGloas) SizeSSZ() (size int) { - size = 100 - - // Field (0) 'Message' - if s.Message == nil { - s.Message = new(AggregateAttestationAndProofGloas) +func (c *AggregateAttestationAndProofGloas) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - size += s.Message.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the SignedAggregateAttestationAndProofGloas object -func (s *SignedAggregateAttestationAndProofGloas) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the SignedAggregateAttestationAndProofGloas object with a hasher -func (s *SignedAggregateAttestationAndProofGloas) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *AggregateAttestationAndProofGloas) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Message' - if err = s.Message.HashTreeRootWith(hh); err != nil { - return + // Field 0: AggregatorIndex + if err := c.AggregatorIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("AggregatorIndex: %w", err) } - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 1: Aggregate + if err := c.Aggregate.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Aggregate: %w", err) } - hh.PutBytes(s.Signature) - + // Field 2: SelectionProof + if len(c.SelectionProof) != 96 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.SelectionProof) hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the AggregateAttestationAndProofGloas object -func (a *AggregateAttestationAndProofGloas) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(a) +func (c *SignedAggregateAttestationAndProofGloas) SizeSSZ() int { + size := 100 + if c.Message == nil { + c.Message = new(AggregateAttestationAndProofGloas) + } + size += c.Message.SizeSSZ() + return size } -// MarshalSSZTo ssz marshals the AggregateAttestationAndProofGloas object to a target array -func (a *AggregateAttestationAndProofGloas) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(108) +func (c *SignedAggregateAttestationAndProofGloas) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (0) 'AggregatorIndex' - dst = ssz.MarshalUint(dst, a.AggregatorIndex) +func (c *SignedAggregateAttestationAndProofGloas) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 100 - // Offset (1) 'Aggregate' - dst = ssz.WriteOffset(dst, offset) - if a.Aggregate == nil { - a.Aggregate = new(AttestationGloas) + // Field 0: Message + if c.Message == nil { + c.Message = new(AggregateAttestationAndProofGloas) } - offset += a.Aggregate.SizeSSZ() + dst = ssz.WriteOffset(dst, offset) + offset += c.Message.SizeSSZ() - // Field (2) 'SelectionProof' - if size := len(a.SelectionProof); size != 96 { - err = ssz.ErrBytesLengthFn("--.SelectionProof", size, 96) - return + // Field 1: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } - dst = append(dst, a.SelectionProof...) + dst = append(dst, c.Signature...) - // Field (1) 'Aggregate' - if dst, err = a.Aggregate.MarshalSSZTo(dst); err != nil { - return + // Field 0: Message + if dst, err = c.Message.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Message: %w", err) } - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the AggregateAttestationAndProofGloas object -func (a *AggregateAttestationAndProofGloas) UnmarshalSSZ(buf []byte) error { +func (c *SignedAggregateAttestationAndProofGloas) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 108 { + if size < 100 { return ssz.ErrSize } - tail := buf - var o1 uint64 - - // Field (0) 'AggregatorIndex' - a.AggregatorIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[0:8]) - - // Offset (1) 'Aggregate' - if o1 = ssz.ReadOffset(buf[8:12]); o1 > size { - return ssz.ErrOffset - } + sszSlice1 := buf[4:100] // c.Signature - if o1 != 108 { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Message + if sszVarOffset0 != 100 { return ssz.ErrInvalidVariableOffset } - - // Field (2) 'SelectionProof' - if cap(a.SelectionProof) == 0 { - a.SelectionProof = make([]byte, 0, len(buf[12:108])) + if sszVarOffset0 > size { + return ssz.ErrOffset } - a.SelectionProof = append(a.SelectionProof, buf[12:108]...) + sszSlice0 := buf[sszVarOffset0:] // c.Message - // Field (1) 'Aggregate' - { - buf = tail[o1:] - if a.Aggregate == nil { - a.Aggregate = new(AttestationGloas) - } - if err = a.Aggregate.UnmarshalSSZ(buf); err != nil { - return err - } + // Field 0: Message + c.Message = new(AggregateAttestationAndProofGloas) + if err = c.Message.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Message: %w", err) } + + // Field 1: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice1...) return err } -// SizeSSZ returns the ssz encoded size in bytes for the AggregateAttestationAndProofGloas object -func (a *AggregateAttestationAndProofGloas) SizeSSZ() (size int) { - size = 108 - - // Field (1) 'Aggregate' - if a.Aggregate == nil { - a.Aggregate = new(AttestationGloas) +func (c *SignedAggregateAttestationAndProofGloas) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - size += a.Aggregate.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the AggregateAttestationAndProofGloas object -func (a *AggregateAttestationAndProofGloas) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(a) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the AggregateAttestationAndProofGloas object with a hasher -func (a *AggregateAttestationAndProofGloas) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *SignedAggregateAttestationAndProofGloas) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'AggregatorIndex' - ssz.PutUint(hh, a.AggregatorIndex) - - // Field (1) 'Aggregate' - if err = a.Aggregate.HashTreeRootWith(hh); err != nil { - return + // Field 0: Message + if err := c.Message.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Message: %w", err) } - - // Field (2) 'SelectionProof' - if size := len(a.SelectionProof); size != 96 { - err = ssz.ErrBytesLengthFn("--.SelectionProof", size, 96) - return + // Field 1: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength } - hh.PutBytes(a.SelectionProof) - + hh.PutBytes(c.Signature) hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the AttesterSlashingGloas object -func (a *AttesterSlashingGloas) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(a) +func (c *AttesterSlashingGloas) SizeSSZ() int { + size := 8 + if c.Attestation_1 == nil { + c.Attestation_1 = new(IndexedAttestationGloas) + } + size += c.Attestation_1.SizeSSZ() + if c.Attestation_2 == nil { + c.Attestation_2 = new(IndexedAttestationGloas) + } + size += c.Attestation_2.SizeSSZ() + return size } -// MarshalSSZTo ssz marshals the AttesterSlashingGloas object to a target array -func (a *AttesterSlashingGloas) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(8) +func (c *AttesterSlashingGloas) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Offset (0) 'Attestation_1' - dst = ssz.WriteOffset(dst, offset) - if a.Attestation_1 == nil { - a.Attestation_1 = new(IndexedAttestationGloas) - } - offset += a.Attestation_1.SizeSSZ() +func (c *AttesterSlashingGloas) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 8 - // Offset (1) 'Attestation_2' - dst = ssz.WriteOffset(dst, offset) - if a.Attestation_2 == nil { - a.Attestation_2 = new(IndexedAttestationGloas) + // Field 0: Attestation_1 + if c.Attestation_1 == nil { + c.Attestation_1 = new(IndexedAttestationGloas) } - offset += a.Attestation_2.SizeSSZ() + dst = ssz.WriteOffset(dst, offset) + offset += c.Attestation_1.SizeSSZ() - // Field (0) 'Attestation_1' - if dst, err = a.Attestation_1.MarshalSSZTo(dst); err != nil { - return + // Field 1: Attestation_2 + if c.Attestation_2 == nil { + c.Attestation_2 = new(IndexedAttestationGloas) } + dst = ssz.WriteOffset(dst, offset) + offset += c.Attestation_2.SizeSSZ() - // Field (1) 'Attestation_2' - if dst, err = a.Attestation_2.MarshalSSZTo(dst); err != nil { - return + // Field 0: Attestation_1 + if dst, err = c.Attestation_1.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Attestation_1: %w", err) } - return + // Field 1: Attestation_2 + if dst, err = c.Attestation_2.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Attestation_2: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the AttesterSlashingGloas object -func (a *AttesterSlashingGloas) UnmarshalSSZ(buf []byte) error { +func (c *AttesterSlashingGloas) 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) 'Attestation_1' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } - - if o0 != 8 { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Attestation_1 + if sszVarOffset0 != 8 { return ssz.ErrInvalidVariableOffset } - - // Offset (1) 'Attestation_2' - if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 { + if sszVarOffset0 > size { + return ssz.ErrOffset + } + sszVarOffset1 := ssz.ReadOffset(buf[4:8]) // c.Attestation_2 + if sszVarOffset1 > size || sszVarOffset1 < sszVarOffset0 { return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:sszVarOffset1] // c.Attestation_1 + sszSlice1 := buf[sszVarOffset1:] // c.Attestation_2 - // Field (0) 'Attestation_1' - { - buf = tail[o0:o1] - if a.Attestation_1 == nil { - a.Attestation_1 = new(IndexedAttestationGloas) - } - if err = a.Attestation_1.UnmarshalSSZ(buf); err != nil { - return err - } + // Field 0: Attestation_1 + c.Attestation_1 = new(IndexedAttestationGloas) + if err = c.Attestation_1.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Attestation_1: %w", err) } - // Field (1) 'Attestation_2' - { - buf = tail[o1:] - if a.Attestation_2 == nil { - a.Attestation_2 = new(IndexedAttestationGloas) - } - if err = a.Attestation_2.UnmarshalSSZ(buf); err != nil { - return err - } + // Field 1: Attestation_2 + c.Attestation_2 = new(IndexedAttestationGloas) + if err = c.Attestation_2.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Attestation_2: %w", err) } return err } -// SizeSSZ returns the ssz encoded size in bytes for the AttesterSlashingGloas object -func (a *AttesterSlashingGloas) SizeSSZ() (size int) { - size = 8 - - // Field (0) 'Attestation_1' - if a.Attestation_1 == nil { - a.Attestation_1 = new(IndexedAttestationGloas) - } - size += a.Attestation_1.SizeSSZ() - - // Field (1) 'Attestation_2' - if a.Attestation_2 == nil { - a.Attestation_2 = new(IndexedAttestationGloas) +func (c *AttesterSlashingGloas) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - size += a.Attestation_2.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the AttesterSlashingGloas object -func (a *AttesterSlashingGloas) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(a) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the AttesterSlashingGloas object with a hasher -func (a *AttesterSlashingGloas) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *AttesterSlashingGloas) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Attestation_1' - if err = a.Attestation_1.HashTreeRootWith(hh); err != nil { - return + // Field 0: Attestation_1 + if err := c.Attestation_1.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Attestation_1: %w", err) } - - // Field (1) 'Attestation_2' - if err = a.Attestation_2.HashTreeRootWith(hh); err != nil { - return + // Field 1: Attestation_2 + if err := c.Attestation_2.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Attestation_2: %w", err) } - hh.Merkleize(indx) - return + return nil +} + +func (c *BeaconBlockBodyGloas) SizeSSZ() int { + size := 396 + size += len(c.ProposerSlashings) * 416 + for _, o := range c.AttesterSlashings { + size += 4 + size += o.SizeSSZ() + } + for _, o := range c.Attestations { + size += 4 + size += o.SizeSSZ() + } + size += len(c.Deposits) * 1240 + size += len(c.VoluntaryExits) * 112 + size += len(c.BlsToExecutionChanges) * 172 + if c.SignedExecutionPayloadBid == nil { + c.SignedExecutionPayloadBid = new(SignedExecutionPayloadBid) + } + size += c.SignedExecutionPayloadBid.SizeSSZ() + size += len(c.PayloadAttestations) * 202 + if c.ParentExecutionRequests == nil { + c.ParentExecutionRequests = new(v1.ExecutionRequestsGloas) + } + size += c.ParentExecutionRequests.SizeSSZ() + return size } -// MarshalSSZ ssz marshals the IndexedAttestationGloas object -func (i *IndexedAttestationGloas) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(i) +func (c *BeaconBlockBodyGloas) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the IndexedAttestationGloas object to a target array -func (i *IndexedAttestationGloas) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(228) +func (c *BeaconBlockBodyGloas) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 396 - // Offset (0) 'AttestingIndices' - dst = ssz.WriteOffset(dst, offset) - offset += len(i.AttestingIndices) * 8 + // Field 0: RandaoReveal + if len(c.RandaoReveal) != 96 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.RandaoReveal...) - // Field (1) 'Data' - if i.Data == nil { - i.Data = new(AttestationData) + // Field 1: Eth1Data + if c.Eth1Data == nil { + c.Eth1Data = new(Eth1Data) } - if dst, err = i.Data.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.Eth1Data.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Eth1Data: %w", err) } - // Field (2) 'Signature' - if size := len(i.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 2: Graffiti + if len(c.Graffiti) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, i.Signature...) + dst = append(dst, c.Graffiti...) + + // Field 3: ProposerSlashings + dst = ssz.WriteOffset(dst, offset) + offset += len(c.ProposerSlashings) * 416 - // Field (0) 'AttestingIndices' - if size := len(i.AttestingIndices); size > 131072 { - err = ssz.ErrListTooBigFn("--.AttestingIndices", size, 131072) - return + // Field 4: AttesterSlashings + dst = ssz.WriteOffset(dst, offset) + for _, o := range c.AttesterSlashings { + offset += 4 + offset += o.SizeSSZ() } - for ii := 0; ii < len(i.AttestingIndices); ii++ { - dst = ssz.MarshalUint(dst, i.AttestingIndices[ii]) + + // Field 5: Attestations + dst = ssz.WriteOffset(dst, offset) + for _, o := range c.Attestations { + offset += 4 + offset += o.SizeSSZ() } - return -} + // Field 6: Deposits + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Deposits) * 1240 -// UnmarshalSSZ ssz unmarshals the IndexedAttestationGloas object -func (i *IndexedAttestationGloas) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 228 { - return ssz.ErrSize + // Field 7: VoluntaryExits + dst = ssz.WriteOffset(dst, offset) + offset += len(c.VoluntaryExits) * 112 + + // Field 8: SyncAggregate + if c.SyncAggregate == nil { + c.SyncAggregate = new(SyncAggregate) + } + if dst, err = c.SyncAggregate.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SyncAggregate: %w", err) } - tail := buf - var o0 uint64 + // Field 9: BlsToExecutionChanges + dst = ssz.WriteOffset(dst, offset) + offset += len(c.BlsToExecutionChanges) * 172 - // Offset (0) 'AttestingIndices' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset + // Field 10: SignedExecutionPayloadBid + if c.SignedExecutionPayloadBid == nil { + c.SignedExecutionPayloadBid = new(SignedExecutionPayloadBid) } + dst = ssz.WriteOffset(dst, offset) + offset += c.SignedExecutionPayloadBid.SizeSSZ() - if o0 != 228 { - return ssz.ErrInvalidVariableOffset + // Field 11: PayloadAttestations + dst = ssz.WriteOffset(dst, offset) + offset += len(c.PayloadAttestations) * 202 + + // Field 12: ParentExecutionRequests + if c.ParentExecutionRequests == nil { + c.ParentExecutionRequests = new(v1.ExecutionRequestsGloas) } + dst = ssz.WriteOffset(dst, offset) + offset += c.ParentExecutionRequests.SizeSSZ() - // Field (1) 'Data' - if i.Data == nil { - i.Data = new(AttestationData) + // Field 3: ProposerSlashings + if len(c.ProposerSlashings) > 16 { + return nil, ssz.ErrListTooBig } - if err = i.Data.UnmarshalSSZ(buf[4:132]); err != nil { - return err + for _, o := range c.ProposerSlashings { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ProposerSlashings: %w", err) + } } - // Field (2) 'Signature' - if cap(i.Signature) == 0 { - i.Signature = make([]byte, 0, len(buf[132:228])) + // Field 4: AttesterSlashings + if len(c.AttesterSlashings) > 1 { + return nil, ssz.ErrListTooBig } - 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 + offset = 4 * len(c.AttesterSlashings) + for _, o := range c.AttesterSlashings { + dst = ssz.WriteOffset(dst, offset) + offset += o.SizeSSZ() } - i.AttestingIndices = ssz.ExtendUint(i.AttestingIndices, num) - for ii := 0; ii < num; ii++ { - i.AttestingIndices[ii] = ssz.UnmarshallUint[uint64](buf[ii*8 : (ii+1)*8]) + } + for _, o := range c.AttesterSlashings { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("AttesterSlashings: %w", err) } } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the IndexedAttestationGloas object -func (i *IndexedAttestationGloas) SizeSSZ() (size int) { - size = 228 - - // Field (0) 'AttestingIndices' - size += len(i.AttestingIndices) * 8 - - return -} - -// HashTreeRoot ssz hashes the IndexedAttestationGloas object -func (i *IndexedAttestationGloas) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(i) -} - -// HashTreeRootWith ssz hashes the IndexedAttestationGloas object with a hasher -func (i *IndexedAttestationGloas) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - // Field (0) 'AttestingIndices' + // Field 5: Attestations + if len(c.Attestations) > 8 { + return nil, ssz.ErrListTooBig + } { - if size := len(i.AttestingIndices); size > 131072 { - err = ssz.ErrListTooBigFn("--.AttestingIndices", size, 131072) - return - } - subIndx := hh.Index() - for _, i := range i.AttestingIndices { - ssz.AppendUint(hh, i) + offset = 4 * len(c.Attestations) + for _, o := range c.Attestations { + dst = ssz.WriteOffset(dst, offset) + offset += o.SizeSSZ() } - hh.FillUpTo32() - - numItems := uint64(len(i.AttestingIndices)) - hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(131072, numItems, 8)) } - - // Field (1) 'Data' - if err = i.Data.HashTreeRootWith(hh); err != nil { - return + for _, o := range c.Attestations { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Attestations: %w", err) + } } - // Field (2) 'Signature' - if size := len(i.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 6: Deposits + if len(c.Deposits) > 16 { + return nil, ssz.ErrListTooBig } - hh.PutBytes(i.Signature) - - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the ExecutionPayloadBid object -func (e *ExecutionPayloadBid) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(e) -} - -// MarshalSSZTo ssz marshals the ExecutionPayloadBid object to a target array -func (e *ExecutionPayloadBid) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(224) - - // Field (0) 'ParentBlockHash' - if size := len(e.ParentBlockHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentBlockHash", size, 32) - return + for _, o := range c.Deposits { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Deposits: %w", err) + } } - dst = append(dst, e.ParentBlockHash...) - // Field (1) 'ParentBlockRoot' - if size := len(e.ParentBlockRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentBlockRoot", size, 32) - return + // Field 7: VoluntaryExits + if len(c.VoluntaryExits) > 16 { + return nil, ssz.ErrListTooBig } - dst = append(dst, e.ParentBlockRoot...) - - // Field (2) 'BlockHash' - if size := len(e.BlockHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockHash", size, 32) - return + for _, o := range c.VoluntaryExits { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("VoluntaryExits: %w", err) + } } - dst = append(dst, e.BlockHash...) - // Field (3) 'PrevRandao' - if size := len(e.PrevRandao); size != 32 { - err = ssz.ErrBytesLengthFn("--.PrevRandao", size, 32) - return + // Field 9: BlsToExecutionChanges + if len(c.BlsToExecutionChanges) > 16 { + return nil, ssz.ErrListTooBig } - dst = append(dst, e.PrevRandao...) - - // Field (4) 'FeeRecipient' - if size := len(e.FeeRecipient); size != 20 { - err = ssz.ErrBytesLengthFn("--.FeeRecipient", size, 20) - return + for _, o := range c.BlsToExecutionChanges { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("BlsToExecutionChanges: %w", err) + } } - dst = append(dst, e.FeeRecipient...) - // Field (5) 'GasLimit' - dst = ssz.MarshalUint(dst, e.GasLimit) - - // Field (6) 'BuilderIndex' - dst = ssz.MarshalUint(dst, e.BuilderIndex) - - // Field (7) 'Slot' - dst = ssz.MarshalUint(dst, e.Slot) - - // Field (8) 'Value' - dst = ssz.MarshalUint(dst, e.Value) - - // Field (9) 'ExecutionPayment' - dst = ssz.MarshalUint(dst, e.ExecutionPayment) - - // Offset (10) 'BlobKzgCommitments' - dst = ssz.WriteOffset(dst, offset) - offset += len(e.BlobKzgCommitments) * 48 - - // Field (11) 'ExecutionRequestsRoot' - if size := len(e.ExecutionRequestsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ExecutionRequestsRoot", size, 32) - return + // Field 10: SignedExecutionPayloadBid + if dst, err = c.SignedExecutionPayloadBid.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SignedExecutionPayloadBid: %w", err) } - dst = append(dst, e.ExecutionRequestsRoot...) - // Field (10) 'BlobKzgCommitments' - if size := len(e.BlobKzgCommitments); size > 4096 { - err = ssz.ErrListTooBigFn("--.BlobKzgCommitments", size, 4096) - return + // Field 11: PayloadAttestations + if len(c.PayloadAttestations) > 4 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(e.BlobKzgCommitments); ii++ { - if size := len(e.BlobKzgCommitments[ii]); size != 48 { - err = ssz.ErrBytesLengthFn("--.BlobKzgCommitments[ii]", size, 48) - return + for _, o := range c.PayloadAttestations { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("PayloadAttestations: %w", err) } - dst = append(dst, e.BlobKzgCommitments[ii]...) } - return + // Field 12: ParentExecutionRequests + if dst, err = c.ParentExecutionRequests.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ParentExecutionRequests: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the ExecutionPayloadBid object -func (e *ExecutionPayloadBid) UnmarshalSSZ(buf []byte) error { +func (c *BeaconBlockBodyGloas) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 224 { + if size < 396 { return ssz.ErrSize } - tail := buf - var o10 uint64 + sszSlice0 := buf[0:96] // c.RandaoReveal + sszSlice1 := buf[96:168] // c.Eth1Data + sszSlice2 := buf[168:200] // c.Graffiti + sszSlice8 := buf[220:380] // c.SyncAggregate - // Field (0) 'ParentBlockHash' - if cap(e.ParentBlockHash) == 0 { - e.ParentBlockHash = make([]byte, 0, len(buf[0:32])) + sszVarOffset3 := ssz.ReadOffset(buf[200:204]) // c.ProposerSlashings + if sszVarOffset3 != 396 { + return ssz.ErrInvalidVariableOffset } - e.ParentBlockHash = append(e.ParentBlockHash, buf[0:32]...) - - // Field (1) 'ParentBlockRoot' - if cap(e.ParentBlockRoot) == 0 { - e.ParentBlockRoot = make([]byte, 0, len(buf[32:64])) + if sszVarOffset3 > size { + return ssz.ErrOffset } - e.ParentBlockRoot = append(e.ParentBlockRoot, buf[32:64]...) - - // Field (2) 'BlockHash' - if cap(e.BlockHash) == 0 { - e.BlockHash = make([]byte, 0, len(buf[64:96])) + sszVarOffset4 := ssz.ReadOffset(buf[204:208]) // c.AttesterSlashings + if sszVarOffset4 > size || sszVarOffset4 < sszVarOffset3 { + return ssz.ErrOffset } - e.BlockHash = append(e.BlockHash, buf[64:96]...) - - // Field (3) 'PrevRandao' - if cap(e.PrevRandao) == 0 { - e.PrevRandao = make([]byte, 0, len(buf[96:128])) + sszVarOffset5 := ssz.ReadOffset(buf[208:212]) // c.Attestations + if sszVarOffset5 > size || sszVarOffset5 < sszVarOffset4 { + return ssz.ErrOffset } - e.PrevRandao = append(e.PrevRandao, buf[96:128]...) - - // Field (4) 'FeeRecipient' - if cap(e.FeeRecipient) == 0 { - e.FeeRecipient = make([]byte, 0, len(buf[128:148])) + sszVarOffset6 := ssz.ReadOffset(buf[212:216]) // c.Deposits + if sszVarOffset6 > size || sszVarOffset6 < sszVarOffset5 { + return ssz.ErrOffset } - e.FeeRecipient = append(e.FeeRecipient, buf[128:148]...) - - // Field (5) 'GasLimit' - e.GasLimit = ssz.UnmarshallUint[uint64](buf[148:156]) - - // Field (6) 'BuilderIndex' - e.BuilderIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.BuilderIndex](buf[156:164]) - - // Field (7) 'Slot' - e.Slot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[164:172]) - - // Field (8) 'Value' - e.Value = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Gwei](buf[172:180]) - - // Field (9) 'ExecutionPayment' - e.ExecutionPayment = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Gwei](buf[180:188]) - - // Offset (10) 'BlobKzgCommitments' - if o10 = ssz.ReadOffset(buf[188:192]); o10 > size { + sszVarOffset7 := ssz.ReadOffset(buf[216:220]) // c.VoluntaryExits + if sszVarOffset7 > size || sszVarOffset7 < sszVarOffset6 { return ssz.ErrOffset } - - if o10 != 224 { - return ssz.ErrInvalidVariableOffset + sszVarOffset9 := ssz.ReadOffset(buf[380:384]) // c.BlsToExecutionChanges + if sszVarOffset9 > size || sszVarOffset9 < sszVarOffset7 { + return ssz.ErrOffset + } + sszVarOffset10 := ssz.ReadOffset(buf[384:388]) // c.SignedExecutionPayloadBid + if sszVarOffset10 > size || sszVarOffset10 < sszVarOffset9 { + return ssz.ErrOffset + } + sszVarOffset11 := ssz.ReadOffset(buf[388:392]) // c.PayloadAttestations + if sszVarOffset11 > size || sszVarOffset11 < sszVarOffset10 { + return ssz.ErrOffset } + sszVarOffset12 := ssz.ReadOffset(buf[392:396]) // c.ParentExecutionRequests + if sszVarOffset12 > size || sszVarOffset12 < sszVarOffset11 { + return ssz.ErrOffset + } + sszSlice3 := buf[sszVarOffset3:sszVarOffset4] // c.ProposerSlashings + sszSlice4 := buf[sszVarOffset4:sszVarOffset5] // c.AttesterSlashings + sszSlice5 := buf[sszVarOffset5:sszVarOffset6] // c.Attestations + sszSlice6 := buf[sszVarOffset6:sszVarOffset7] // c.Deposits + sszSlice7 := buf[sszVarOffset7:sszVarOffset9] // c.VoluntaryExits + sszSlice9 := buf[sszVarOffset9:sszVarOffset10] // c.BlsToExecutionChanges + sszSlice10 := buf[sszVarOffset10:sszVarOffset11] // c.SignedExecutionPayloadBid + sszSlice11 := buf[sszVarOffset11:sszVarOffset12] // c.PayloadAttestations + sszSlice12 := buf[sszVarOffset12:] // c.ParentExecutionRequests - // Field (11) 'ExecutionRequestsRoot' - if cap(e.ExecutionRequestsRoot) == 0 { - e.ExecutionRequestsRoot = make([]byte, 0, len(buf[192:224])) + // Field 0: RandaoReveal + c.RandaoReveal = make([]byte, 0, 96) + c.RandaoReveal = append(c.RandaoReveal, sszSlice0...) + + // Field 1: Eth1Data + c.Eth1Data = new(Eth1Data) + if err = c.Eth1Data.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Eth1Data: %w", err) } - e.ExecutionRequestsRoot = append(e.ExecutionRequestsRoot, buf[192:224]...) - // Field (10) 'BlobKzgCommitments' + // Field 2: Graffiti + c.Graffiti = make([]byte, 0, 32) + c.Graffiti = append(c.Graffiti, sszSlice2...) + + // Field 3: ProposerSlashings { - buf = tail[o10:] - num, err := ssz.DivideInt2(len(buf), 48, 4096) - if err != nil { - return err - } - e.BlobKzgCommitments = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(e.BlobKzgCommitments[ii]) == 0 { - e.BlobKzgCommitments[ii] = make([]byte, 0, len(buf[ii*48:(ii+1)*48])) + if len(sszSlice3)%416 != 0 { + return fmt.Errorf("misaligned bytes: c.ProposerSlashings length is %d, which is not a multiple of 416: %w", len(sszSlice3), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice3) / 416 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.ProposerSlashings has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.ProposerSlashings = make([]*ProposerSlashing, numElem) + for i := 0; i < numElem; i++ { + var tmp *ProposerSlashing + tmp = new(ProposerSlashing) + tmpSlice := sszSlice3[i*416 : (1+i)*416] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("ProposerSlashings: %w", err) } - e.BlobKzgCommitments[ii] = append(e.BlobKzgCommitments[ii], buf[ii*48:(ii+1)*48]...) + c.ProposerSlashings[i] = tmp } } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the ExecutionPayloadBid object -func (e *ExecutionPayloadBid) SizeSSZ() (size int) { - size = 224 - - // Field (10) 'BlobKzgCommitments' - size += len(e.BlobKzgCommitments) * 48 - return -} - -// HashTreeRoot ssz hashes the ExecutionPayloadBid object -func (e *ExecutionPayloadBid) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(e) -} - -// HashTreeRootWith ssz hashes the ExecutionPayloadBid object with a hasher -func (e *ExecutionPayloadBid) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'ParentBlockHash' - if size := len(e.ParentBlockHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentBlockHash", size, 32) - return + // Field 4: AttesterSlashings + { + // empty lists are zero length, so make sure there is room for an offset + // before attempting to unmarshal it + if len(sszSlice4) > 3 { + startOffset := ssz.ReadOffset(sszSlice4[0:4]) + if startOffset == 0 { + return fmt.Errorf("encountered invalid offset of 0 when decoding c.AttesterSlashings") + } + if startOffset%4 != 0 { + return fmt.Errorf("misaligned list bytes: when decoding c.AttesterSlashings, end-of-list offset is %d, which is not a multiple of 4 (offset size)", startOffset) + } + listLen := startOffset / 4 + if listLen > 1 { + return fmt.Errorf("ssz-max exceeded: c.AttesterSlashings has %d elements, ssz-max is 1: %w", listLen, ssz.ErrListTooBig) + } + totalVarBytes := uint64(len(sszSlice4)) + if totalVarBytes < startOffset { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.AttesterSlashings") + } + c.AttesterSlashings = make([]*AttesterSlashingGloas, listLen) + var tmpSlice []byte + for i := uint64(0); i < listLen; i++ { + var tmp *AttesterSlashingGloas + tmp = new(AttesterSlashingGloas) + endOffset := totalVarBytes + if i+1 != listLen { + endOffset = ssz.ReadOffset(sszSlice4[(i+1)*4 : (i+2)*4]) + if totalVarBytes < endOffset { + return fmt.Errorf("offset %d points past the end of buffer when decoding c.AttesterSlashings", endOffset) + } + } + if endOffset < startOffset { + return fmt.Errorf("offset %d is not greater than start offset %d when decoding c.AttesterSlashings", endOffset, startOffset) + } + tmpSlice = sszSlice4[startOffset:endOffset] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("AttesterSlashings: %w", err) + } + c.AttesterSlashings[i] = tmp + startOffset = endOffset + } + } else { + if len(sszSlice4) > 0 { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.AttesterSlashings") + } + c.AttesterSlashings = make([]*AttesterSlashingGloas, 0) + } } - hh.PutBytes(e.ParentBlockHash) - // Field (1) 'ParentBlockRoot' - if size := len(e.ParentBlockRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentBlockRoot", size, 32) - return + // Field 5: Attestations + { + // empty lists are zero length, so make sure there is room for an offset + // before attempting to unmarshal it + if len(sszSlice5) > 3 { + startOffset := ssz.ReadOffset(sszSlice5[0:4]) + if startOffset == 0 { + return fmt.Errorf("encountered invalid offset of 0 when decoding c.Attestations") + } + if startOffset%4 != 0 { + return fmt.Errorf("misaligned list bytes: when decoding c.Attestations, end-of-list offset is %d, which is not a multiple of 4 (offset size)", startOffset) + } + listLen := startOffset / 4 + if listLen > 8 { + return fmt.Errorf("ssz-max exceeded: c.Attestations has %d elements, ssz-max is 8: %w", listLen, ssz.ErrListTooBig) + } + totalVarBytes := uint64(len(sszSlice5)) + if totalVarBytes < startOffset { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.Attestations") + } + c.Attestations = make([]*AttestationGloas, listLen) + var tmpSlice []byte + for i := uint64(0); i < listLen; i++ { + var tmp *AttestationGloas + tmp = new(AttestationGloas) + endOffset := totalVarBytes + if i+1 != listLen { + endOffset = ssz.ReadOffset(sszSlice5[(i+1)*4 : (i+2)*4]) + if totalVarBytes < endOffset { + return fmt.Errorf("offset %d points past the end of buffer when decoding c.Attestations", endOffset) + } + } + if endOffset < startOffset { + return fmt.Errorf("offset %d is not greater than start offset %d when decoding c.Attestations", endOffset, startOffset) + } + tmpSlice = sszSlice5[startOffset:endOffset] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Attestations: %w", err) + } + c.Attestations[i] = tmp + startOffset = endOffset + } + } else { + if len(sszSlice5) > 0 { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.Attestations") + } + c.Attestations = make([]*AttestationGloas, 0) + } } - hh.PutBytes(e.ParentBlockRoot) - // Field (2) 'BlockHash' - if size := len(e.BlockHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockHash", size, 32) - return + // Field 6: Deposits + { + if len(sszSlice6)%1240 != 0 { + return fmt.Errorf("misaligned bytes: c.Deposits length is %d, which is not a multiple of 1240: %w", len(sszSlice6), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice6) / 1240 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.Deposits has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.Deposits = make([]*Deposit, numElem) + for i := 0; i < numElem; i++ { + var tmp *Deposit + tmp = new(Deposit) + tmpSlice := sszSlice6[i*1240 : (1+i)*1240] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Deposits: %w", err) + } + c.Deposits[i] = tmp + } } - hh.PutBytes(e.BlockHash) - // Field (3) 'PrevRandao' - if size := len(e.PrevRandao); size != 32 { - err = ssz.ErrBytesLengthFn("--.PrevRandao", size, 32) - return + // Field 7: VoluntaryExits + { + if len(sszSlice7)%112 != 0 { + return fmt.Errorf("misaligned bytes: c.VoluntaryExits length is %d, which is not a multiple of 112: %w", len(sszSlice7), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice7) / 112 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.VoluntaryExits has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.VoluntaryExits = make([]*SignedVoluntaryExit, numElem) + for i := 0; i < numElem; i++ { + var tmp *SignedVoluntaryExit + tmp = new(SignedVoluntaryExit) + tmpSlice := sszSlice7[i*112 : (1+i)*112] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("VoluntaryExits: %w", err) + } + c.VoluntaryExits[i] = tmp + } } - hh.PutBytes(e.PrevRandao) - // Field (4) 'FeeRecipient' - if size := len(e.FeeRecipient); size != 20 { - err = ssz.ErrBytesLengthFn("--.FeeRecipient", size, 20) - return + // Field 8: SyncAggregate + c.SyncAggregate = new(SyncAggregate) + if err = c.SyncAggregate.UnmarshalSSZ(sszSlice8); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) } - hh.PutBytes(e.FeeRecipient) - - // Field (5) 'GasLimit' - ssz.PutUint(hh, e.GasLimit) - - // Field (6) 'BuilderIndex' - ssz.PutUint(hh, e.BuilderIndex) - - // Field (7) 'Slot' - ssz.PutUint(hh, e.Slot) - - // Field (8) 'Value' - ssz.PutUint(hh, e.Value) - // Field (9) 'ExecutionPayment' - ssz.PutUint(hh, e.ExecutionPayment) - - // Field (10) 'BlobKzgCommitments' + // Field 9: BlsToExecutionChanges { - if size := len(e.BlobKzgCommitments); size > 4096 { - err = ssz.ErrListTooBigFn("--.BlobKzgCommitments", size, 4096) - return - } - subIndx := hh.Index() - for _, i := range e.BlobKzgCommitments { - if len(i) != 48 { - err = ssz.ErrBytesLength - return + if len(sszSlice9)%172 != 0 { + return fmt.Errorf("misaligned bytes: c.BlsToExecutionChanges length is %d, which is not a multiple of 172: %w", len(sszSlice9), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice9) / 172 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.BlsToExecutionChanges has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.BlsToExecutionChanges = make([]*SignedBLSToExecutionChange, numElem) + for i := 0; i < numElem; i++ { + var tmp *SignedBLSToExecutionChange + tmp = new(SignedBLSToExecutionChange) + tmpSlice := sszSlice9[i*172 : (1+i)*172] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("BlsToExecutionChanges: %w", err) } - hh.PutBytes(i) + c.BlsToExecutionChanges[i] = tmp } + } - numItems := uint64(len(e.BlobKzgCommitments)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) + // Field 10: SignedExecutionPayloadBid + c.SignedExecutionPayloadBid = new(SignedExecutionPayloadBid) + if err = c.SignedExecutionPayloadBid.UnmarshalSSZ(sszSlice10); err != nil { + return fmt.Errorf("SignedExecutionPayloadBid: %w", err) } - // Field (11) 'ExecutionRequestsRoot' - if size := len(e.ExecutionRequestsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ExecutionRequestsRoot", size, 32) - return + // Field 11: PayloadAttestations + { + if len(sszSlice11)%202 != 0 { + return fmt.Errorf("misaligned bytes: c.PayloadAttestations length is %d, which is not a multiple of 202: %w", len(sszSlice11), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice11) / 202 + if numElem > 4 { + return fmt.Errorf("ssz-max exceeded: c.PayloadAttestations has %d elements, ssz-max is 4: %w", numElem, ssz.ErrListTooBig) + } + c.PayloadAttestations = make([]*PayloadAttestation, numElem) + for i := 0; i < numElem; i++ { + var tmp *PayloadAttestation + tmp = new(PayloadAttestation) + tmpSlice := sszSlice11[i*202 : (1+i)*202] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("PayloadAttestations: %w", err) + } + c.PayloadAttestations[i] = tmp + } } - hh.PutBytes(e.ExecutionRequestsRoot) - hh.Merkleize(indx) - return + // Field 12: ParentExecutionRequests + c.ParentExecutionRequests = new(v1.ExecutionRequestsGloas) + if err = c.ParentExecutionRequests.UnmarshalSSZ(sszSlice12); err != nil { + return fmt.Errorf("ParentExecutionRequests: %w", err) + } + return err } -// MarshalSSZ ssz marshals the SignedExecutionPayloadBid object -func (s *SignedExecutionPayloadBid) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) +func (c *BeaconBlockBodyGloas) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// MarshalSSZTo ssz marshals the SignedExecutionPayloadBid object to a target array -func (s *SignedExecutionPayloadBid) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(100) - - // Offset (0) 'Message' - dst = ssz.WriteOffset(dst, offset) - if s.Message == nil { - s.Message = new(ExecutionPayloadBid) +func (c *BeaconBlockBodyGloas) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: RandaoReveal + if len(c.RandaoReveal) != 96 { + return ssz.ErrBytesLength } - offset += s.Message.SizeSSZ() - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + hh.PutBytes(c.RandaoReveal) + // Field 1: Eth1Data + if err := c.Eth1Data.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Eth1Data: %w", err) } - dst = append(dst, s.Signature...) - - // Field (0) 'Message' - if dst, err = s.Message.MarshalSSZTo(dst); err != nil { - return + // Field 2: Graffiti + if len(c.Graffiti) != 32 { + return ssz.ErrBytesLength } - - return -} - -// UnmarshalSSZ ssz unmarshals the SignedExecutionPayloadBid object -func (s *SignedExecutionPayloadBid) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 100 { - return ssz.ErrSize + hh.PutBytes(c.Graffiti) + // Field 3: ProposerSlashings + { + if len(c.ProposerSlashings) > 16 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.ProposerSlashings { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ProposerSlashings: %w", err) + } + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.ProposerSlashings)), 16) } - - tail := buf - var o0 uint64 - - // Offset (0) 'Message' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset + // Field 4: AttesterSlashings + { + if len(c.AttesterSlashings) > 1 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.AttesterSlashings { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("AttesterSlashings: %w", err) + } + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.AttesterSlashings)), 1) } - - if o0 != 100 { - return ssz.ErrInvalidVariableOffset + // Field 5: Attestations + { + if len(c.Attestations) > 8 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.Attestations { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Attestations: %w", err) + } + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Attestations)), 8) } - - // Field (1) 'Signature' - if cap(s.Signature) == 0 { - s.Signature = make([]byte, 0, len(buf[4:100])) + // Field 6: Deposits + { + if len(c.Deposits) > 16 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.Deposits { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Deposits: %w", err) + } + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Deposits)), 16) } - s.Signature = append(s.Signature, buf[4:100]...) - - // Field (0) 'Message' + // Field 7: VoluntaryExits { - buf = tail[o0:] - if s.Message == nil { - s.Message = new(ExecutionPayloadBid) + if len(c.VoluntaryExits) > 16 { + return ssz.ErrListTooBig } - if err = s.Message.UnmarshalSSZ(buf); err != nil { - return err + subIndx := hh.Index() + for _, o := range c.VoluntaryExits { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("VoluntaryExits: %w", err) + } } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.VoluntaryExits)), 16) } - return err + // Field 8: SyncAggregate + if err := c.SyncAggregate.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SyncAggregate: %w", err) + } + // Field 9: BlsToExecutionChanges + { + if len(c.BlsToExecutionChanges) > 16 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.BlsToExecutionChanges { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("BlsToExecutionChanges: %w", err) + } + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.BlsToExecutionChanges)), 16) + } + // Field 10: SignedExecutionPayloadBid + if err := c.SignedExecutionPayloadBid.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SignedExecutionPayloadBid: %w", err) + } + // Field 11: PayloadAttestations + { + if len(c.PayloadAttestations) > 4 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.PayloadAttestations { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("PayloadAttestations: %w", err) + } + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.PayloadAttestations)), 4) + } + // Field 12: ParentExecutionRequests + if err := c.ParentExecutionRequests.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ParentExecutionRequests: %w", err) + } + hh.Merkleize(indx) + return nil } -// SizeSSZ returns the ssz encoded size in bytes for the SignedExecutionPayloadBid object -func (s *SignedExecutionPayloadBid) SizeSSZ() (size int) { - size = 100 - - // Field (0) 'Message' - if s.Message == nil { - s.Message = new(ExecutionPayloadBid) +func (c *BeaconBlockContentsGloas) SizeSSZ() int { + size := 16 + if c.Block == nil { + c.Block = new(BeaconBlockGloas) } - size += s.Message.SizeSSZ() - - return + size += c.Block.SizeSSZ() + if c.ExecutionPayloadEnvelope == nil { + c.ExecutionPayloadEnvelope = new(ExecutionPayloadEnvelope) + } + size += c.ExecutionPayloadEnvelope.SizeSSZ() + size += len(c.KzgProofs) * 48 + size += len(c.Blobs) * 131072 + return size } -// HashTreeRoot ssz hashes the SignedExecutionPayloadBid object -func (s *SignedExecutionPayloadBid) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) +func (c *BeaconBlockContentsGloas) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// HashTreeRootWith ssz hashes the SignedExecutionPayloadBid object with a hasher -func (s *SignedExecutionPayloadBid) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() +func (c *BeaconBlockContentsGloas) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 16 - // Field (0) 'Message' - if err = s.Message.HashTreeRootWith(hh); err != nil { - return + // Field 0: Block + if c.Block == nil { + c.Block = new(BeaconBlockGloas) } + dst = ssz.WriteOffset(dst, offset) + offset += c.Block.SizeSSZ() - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 1: ExecutionPayloadEnvelope + if c.ExecutionPayloadEnvelope == nil { + c.ExecutionPayloadEnvelope = new(ExecutionPayloadEnvelope) } - hh.PutBytes(s.Signature) - - hh.Merkleize(indx) - return -} + dst = ssz.WriteOffset(dst, offset) + offset += c.ExecutionPayloadEnvelope.SizeSSZ() -// MarshalSSZ ssz marshals the ProposerPreferences object -func (p *ProposerPreferences) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(p) -} + // Field 2: KzgProofs + dst = ssz.WriteOffset(dst, offset) + offset += len(c.KzgProofs) * 48 -// MarshalSSZTo ssz marshals the ProposerPreferences object to a target array -func (p *ProposerPreferences) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf + // Field 3: Blobs + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Blobs) * 131072 - // Field (0) 'DependentRoot' - if size := len(p.DependentRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.DependentRoot", size, 32) - return + // Field 0: Block + if dst, err = c.Block.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Block: %w", err) } - dst = append(dst, p.DependentRoot...) - - // Field (1) 'ProposalSlot' - dst = ssz.MarshalUint(dst, p.ProposalSlot) - - // Field (2) 'ValidatorIndex' - dst = ssz.MarshalUint(dst, p.ValidatorIndex) - // Field (3) 'FeeRecipient' - if size := len(p.FeeRecipient); size != 20 { - err = ssz.ErrBytesLengthFn("--.FeeRecipient", size, 20) - return + // Field 1: ExecutionPayloadEnvelope + if dst, err = c.ExecutionPayloadEnvelope.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ExecutionPayloadEnvelope: %w", err) } - dst = append(dst, p.FeeRecipient...) - // Field (4) 'TargetGasLimit' - dst = ssz.MarshalUint(dst, p.TargetGasLimit) + // Field 2: KzgProofs + if len(c.KzgProofs) > 33554432 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.KzgProofs { + if len(o) != 48 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) + } - return + // Field 3: Blobs + if len(c.Blobs) > 4096 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.Blobs { + if len(o) != 131072 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the ProposerPreferences object -func (p *ProposerPreferences) UnmarshalSSZ(buf []byte) error { +func (c *BeaconBlockContentsGloas) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 76 { + if size < 16 { return ssz.ErrSize } - // Field (0) 'DependentRoot' - if cap(p.DependentRoot) == 0 { - p.DependentRoot = make([]byte, 0, len(buf[0:32])) + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Block + if sszVarOffset0 != 16 { + return ssz.ErrInvalidVariableOffset } - p.DependentRoot = append(p.DependentRoot, buf[0:32]...) - - // Field (1) 'ProposalSlot' - p.ProposalSlot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[32:40]) - - // Field (2) 'ValidatorIndex' - p.ValidatorIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[40:48]) - - // Field (3) 'FeeRecipient' - if cap(p.FeeRecipient) == 0 { - p.FeeRecipient = make([]byte, 0, len(buf[48:68])) + if sszVarOffset0 > size { + return ssz.ErrOffset } - p.FeeRecipient = append(p.FeeRecipient, buf[48:68]...) - - // Field (4) 'TargetGasLimit' - p.TargetGasLimit = ssz.UnmarshallUint[uint64](buf[68:76]) - - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the ProposerPreferences object -func (p *ProposerPreferences) SizeSSZ() (size int) { - size = 76 - return -} - -// HashTreeRoot ssz hashes the ProposerPreferences object -func (p *ProposerPreferences) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(p) -} - -// HashTreeRootWith ssz hashes the ProposerPreferences object with a hasher -func (p *ProposerPreferences) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'DependentRoot' - if size := len(p.DependentRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.DependentRoot", size, 32) - return + sszVarOffset1 := ssz.ReadOffset(buf[4:8]) // c.ExecutionPayloadEnvelope + if sszVarOffset1 > size || sszVarOffset1 < sszVarOffset0 { + return ssz.ErrOffset } - hh.PutBytes(p.DependentRoot) - - // Field (1) 'ProposalSlot' - ssz.PutUint(hh, p.ProposalSlot) - - // Field (2) 'ValidatorIndex' - ssz.PutUint(hh, p.ValidatorIndex) + sszVarOffset2 := ssz.ReadOffset(buf[8:12]) // c.KzgProofs + if sszVarOffset2 > size || sszVarOffset2 < sszVarOffset1 { + return ssz.ErrOffset + } + sszVarOffset3 := ssz.ReadOffset(buf[12:16]) // c.Blobs + if sszVarOffset3 > size || sszVarOffset3 < sszVarOffset2 { + return ssz.ErrOffset + } + sszSlice0 := buf[sszVarOffset0:sszVarOffset1] // c.Block + sszSlice1 := buf[sszVarOffset1:sszVarOffset2] // c.ExecutionPayloadEnvelope + sszSlice2 := buf[sszVarOffset2:sszVarOffset3] // c.KzgProofs + sszSlice3 := buf[sszVarOffset3:] // c.Blobs - // Field (3) 'FeeRecipient' - if size := len(p.FeeRecipient); size != 20 { - err = ssz.ErrBytesLengthFn("--.FeeRecipient", size, 20) - return + // Field 0: Block + c.Block = new(BeaconBlockGloas) + if err = c.Block.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Block: %w", err) } - hh.PutBytes(p.FeeRecipient) - // Field (4) 'TargetGasLimit' - ssz.PutUint(hh, p.TargetGasLimit) + // Field 1: ExecutionPayloadEnvelope + c.ExecutionPayloadEnvelope = new(ExecutionPayloadEnvelope) + if err = c.ExecutionPayloadEnvelope.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("ExecutionPayloadEnvelope: %w", err) + } - hh.Merkleize(indx) - return -} + // Field 2: KzgProofs + { + if len(sszSlice2)%48 != 0 { + return fmt.Errorf("misaligned bytes: c.KzgProofs length is %d, which is not a multiple of 48: %w", len(sszSlice2), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice2) / 48 + if numElem > 33554432 { + return fmt.Errorf("ssz-max exceeded: c.KzgProofs has %d elements, ssz-max is 33554432: %w", numElem, ssz.ErrListTooBig) + } + c.KzgProofs = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte -// MarshalSSZ ssz marshals the SignedProposerPreferences object -func (s *SignedProposerPreferences) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) -} + tmpSlice := sszSlice2[i*48 : (1+i)*48] + tmp = make([]byte, 0, 48) + tmp = append(tmp, tmpSlice...) + c.KzgProofs[i] = tmp + } + } -// MarshalSSZTo ssz marshals the SignedProposerPreferences object to a target array -func (s *SignedProposerPreferences) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf + // Field 3: Blobs + { + if len(sszSlice3)%131072 != 0 { + return fmt.Errorf("misaligned bytes: c.Blobs length is %d, which is not a multiple of 131072: %w", len(sszSlice3), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice3) / 131072 + if numElem > 4096 { + return fmt.Errorf("ssz-max exceeded: c.Blobs has %d elements, ssz-max is 4096: %w", numElem, ssz.ErrListTooBig) + } + c.Blobs = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte - // Field (0) 'Message' - if s.Message == nil { - s.Message = new(ProposerPreferences) - } - if dst, err = s.Message.MarshalSSZTo(dst); err != nil { - return + tmpSlice := sszSlice3[i*131072 : (1+i)*131072] + tmp = make([]byte, 0, 131072) + tmp = append(tmp, tmpSlice...) + c.Blobs[i] = tmp + } } + return err +} - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return +func (c *BeaconBlockContentsGloas) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - dst = append(dst, s.Signature...) - - return + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// UnmarshalSSZ ssz unmarshals the SignedProposerPreferences object -func (s *SignedProposerPreferences) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size != 172 { - return ssz.ErrSize +func (c *BeaconBlockContentsGloas) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Block + if err := c.Block.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Block: %w", err) } - - // Field (0) 'Message' - if s.Message == nil { - s.Message = new(ProposerPreferences) + // Field 1: ExecutionPayloadEnvelope + if err := c.ExecutionPayloadEnvelope.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ExecutionPayloadEnvelope: %w", err) } - if err = s.Message.UnmarshalSSZ(buf[0:76]); err != nil { - return err + // Field 2: KzgProofs + { + if len(c.KzgProofs) > 33554432 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.KzgProofs { + if len(o) != 48 { + return ssz.ErrBytesLength + } + hh.PutBytes(o) + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.KzgProofs)), 33554432) } - - // Field (1) 'Signature' - if cap(s.Signature) == 0 { - s.Signature = make([]byte, 0, len(buf[76:172])) + // Field 3: Blobs + { + if len(c.Blobs) > 4096 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.Blobs { + if len(o) != 131072 { + return ssz.ErrBytesLength + } + hh.PutBytes(o) + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Blobs)), 4096) } - s.Signature = append(s.Signature, buf[76:172]...) - - return err + hh.Merkleize(indx) + return nil } -// SizeSSZ returns the ssz encoded size in bytes for the SignedProposerPreferences object -func (s *SignedProposerPreferences) SizeSSZ() (size int) { - size = 172 - return +func (c *BeaconBlockGloas) SizeSSZ() int { + size := 84 + if c.Body == nil { + c.Body = new(BeaconBlockBodyGloas) + } + size += c.Body.SizeSSZ() + return size } -// HashTreeRoot ssz hashes the SignedProposerPreferences object -func (s *SignedProposerPreferences) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) +func (c *BeaconBlockGloas) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// HashTreeRootWith ssz hashes the SignedProposerPreferences object with a hasher -func (s *SignedProposerPreferences) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() +func (c *BeaconBlockGloas) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 84 - // Field (0) 'Message' - if err = s.Message.HashTreeRootWith(hh); err != nil { - return + // Field 0: Slot + if dst, err = c.Slot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Slot: %w", err) } - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 1: ProposerIndex + if dst, err = c.ProposerIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ProposerIndex: %w", err) } - hh.PutBytes(s.Signature) - - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the PayloadAttestationData object -func (p *PayloadAttestationData) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(p) -} -// MarshalSSZTo ssz marshals the PayloadAttestationData object to a target array -func (p *PayloadAttestationData) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - - // Field (0) 'BeaconBlockRoot' - if size := len(p.BeaconBlockRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.BeaconBlockRoot", size, 32) - return + // Field 2: ParentRoot + if len(c.ParentRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, p.BeaconBlockRoot...) - - // Field (1) 'Slot' - dst = ssz.MarshalUint(dst, p.Slot) + dst = append(dst, c.ParentRoot...) - // Field (2) 'PayloadPresent' - dst = ssz.MarshalBool(dst, p.PayloadPresent) + // Field 3: StateRoot + if len(c.StateRoot) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.StateRoot...) - // Field (3) 'BlobDataAvailable' - dst = ssz.MarshalBool(dst, p.BlobDataAvailable) + // Field 4: Body + if c.Body == nil { + c.Body = new(BeaconBlockBodyGloas) + } + dst = ssz.WriteOffset(dst, offset) + offset += c.Body.SizeSSZ() - return + // Field 4: Body + if dst, err = c.Body.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Body: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the PayloadAttestationData object -func (p *PayloadAttestationData) UnmarshalSSZ(buf []byte) error { +func (c *BeaconBlockGloas) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 42 { + if size < 84 { return ssz.ErrSize } - // Field (0) 'BeaconBlockRoot' - if cap(p.BeaconBlockRoot) == 0 { - p.BeaconBlockRoot = make([]byte, 0, len(buf[0:32])) - } - p.BeaconBlockRoot = append(p.BeaconBlockRoot, buf[0:32]...) + sszSlice0 := buf[0:8] // c.Slot + sszSlice1 := buf[8:16] // c.ProposerIndex + sszSlice2 := buf[16:48] // c.ParentRoot + sszSlice3 := buf[48:80] // c.StateRoot - // Field (1) 'Slot' - p.Slot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[32:40]) + sszVarOffset4 := ssz.ReadOffset(buf[80:84]) // c.Body + if sszVarOffset4 != 84 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset4 > size { + return ssz.ErrOffset + } + sszSlice4 := buf[sszVarOffset4:] // c.Body - // Field (2) 'PayloadPresent' - p.PayloadPresent, err = ssz.DecodeBool(buf[40:41]) - if err != nil { - return err + // Field 0: Slot + if err = c.Slot.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Slot: %w", err) } - // Field (3) 'BlobDataAvailable' - p.BlobDataAvailable, err = ssz.DecodeBool(buf[41:42]) - if err != nil { - return err + // Field 1: ProposerIndex + if err = c.ProposerIndex.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("ProposerIndex: %w", err) } - return err -} + // Field 2: ParentRoot + c.ParentRoot = make([]byte, 0, 32) + c.ParentRoot = append(c.ParentRoot, sszSlice2...) + + // Field 3: StateRoot + c.StateRoot = make([]byte, 0, 32) + c.StateRoot = append(c.StateRoot, sszSlice3...) -// SizeSSZ returns the ssz encoded size in bytes for the PayloadAttestationData object -func (p *PayloadAttestationData) SizeSSZ() (size int) { - size = 42 - return + // Field 4: Body + c.Body = new(BeaconBlockBodyGloas) + if err = c.Body.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("Body: %w", err) + } + return err } -// HashTreeRoot ssz hashes the PayloadAttestationData object -func (p *PayloadAttestationData) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(p) +func (c *BeaconBlockGloas) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the PayloadAttestationData object with a hasher -func (p *PayloadAttestationData) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *BeaconBlockGloas) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'BeaconBlockRoot' - if size := len(p.BeaconBlockRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.BeaconBlockRoot", size, 32) - return + // Field 0: Slot + if err := c.Slot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Slot: %w", err) + } + // Field 1: ProposerIndex + if err := c.ProposerIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ProposerIndex: %w", err) + } + // Field 2: ParentRoot + if len(c.ParentRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ParentRoot) + // Field 3: StateRoot + if len(c.StateRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.StateRoot) + // Field 4: Body + if err := c.Body.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Body: %w", err) } - hh.PutBytes(p.BeaconBlockRoot) - - // Field (1) 'Slot' - ssz.PutUint(hh, p.Slot) - - // Field (2) 'PayloadPresent' - hh.PutBool(p.PayloadPresent) - - // Field (3) 'BlobDataAvailable' - hh.PutBool(p.BlobDataAvailable) - hh.Merkleize(indx) - return -} + return nil +} + +func (c *BeaconStateGloas) SizeSSZ() int { + size := 3134845 + size += len(c.HistoricalRoots) * 32 + size += len(c.Eth1DataVotes) * 72 + size += len(c.Validators) * 121 + size += len(c.Balances) * 8 + size += len(c.PreviousEpochParticipation) + size += len(c.CurrentEpochParticipation) + size += len(c.InactivityScores) * 8 + size += len(c.HistoricalSummaries) * 64 + size += len(c.PendingDeposits) * 192 + size += len(c.PendingPartialWithdrawals) * 24 + size += len(c.PendingConsolidations) * 16 + size += len(c.Builders) * 93 + size += len(c.BuilderPendingWithdrawals) * 36 + if c.LatestExecutionPayloadBid == nil { + c.LatestExecutionPayloadBid = new(ExecutionPayloadBid) + } + size += c.LatestExecutionPayloadBid.SizeSSZ() + size += len(c.PayloadExpectedWithdrawals) * 44 + return size +} + +func (c *BeaconStateGloas) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} + +func (c *BeaconStateGloas) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 3134845 -// MarshalSSZ ssz marshals the PayloadAttestation object -func (p *PayloadAttestation) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(p) -} + // Field 0: GenesisTime + dst = binary.LittleEndian.AppendUint64(dst, c.GenesisTime) -// MarshalSSZTo ssz marshals the PayloadAttestation object to a target array -func (p *PayloadAttestation) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf + // Field 1: GenesisValidatorsRoot + if len(c.GenesisValidatorsRoot) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.GenesisValidatorsRoot...) - // Field (0) 'AggregationBits' - if size := len(p.AggregationBits); size != 64 { - err = ssz.ErrBytesLengthFn("--.AggregationBits", size, 64) - return + // Field 2: Slot + if dst, err = c.Slot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Slot: %w", err) } - dst = append(dst, p.AggregationBits...) - // Field (1) 'Data' - if p.Data == nil { - p.Data = new(PayloadAttestationData) + // Field 3: Fork + if c.Fork == nil { + c.Fork = new(Fork) } - if dst, err = p.Data.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.Fork.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Fork: %w", err) } - // Field (2) 'Signature' - if size := len(p.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 4: LatestBlockHeader + if c.LatestBlockHeader == nil { + c.LatestBlockHeader = new(BeaconBlockHeader) } - dst = append(dst, p.Signature...) - - return -} - -// UnmarshalSSZ ssz unmarshals the PayloadAttestation object -func (p *PayloadAttestation) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size != 202 { - return ssz.ErrSize + if dst, err = c.LatestBlockHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("LatestBlockHeader: %w", err) } - // Field (0) 'AggregationBits' - if cap(p.AggregationBits) == 0 { - p.AggregationBits = make([]byte, 0, len(buf[0:64])) + // Field 5: BlockRoots + if len(c.BlockRoots) != 8192 { + return nil, ssz.ErrBytesLength + } + for _, o := range c.BlockRoots { + if len(o) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) } - p.AggregationBits = append(p.AggregationBits, buf[0:64]...) - // Field (1) 'Data' - if p.Data == nil { - p.Data = new(PayloadAttestationData) + // Field 6: StateRoots + if len(c.StateRoots) != 8192 { + return nil, ssz.ErrBytesLength } - if err = p.Data.UnmarshalSSZ(buf[64:106]); err != nil { - return err + for _, o := range c.StateRoots { + if len(o) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) } - // Field (2) 'Signature' - if cap(p.Signature) == 0 { - p.Signature = make([]byte, 0, len(buf[106:202])) + // Field 7: HistoricalRoots + dst = ssz.WriteOffset(dst, offset) + offset += len(c.HistoricalRoots) * 32 + + // Field 8: Eth1Data + if c.Eth1Data == nil { + c.Eth1Data = new(Eth1Data) + } + if dst, err = c.Eth1Data.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Eth1Data: %w", err) } - p.Signature = append(p.Signature, buf[106:202]...) - return err -} + // Field 9: Eth1DataVotes + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Eth1DataVotes) * 72 -// SizeSSZ returns the ssz encoded size in bytes for the PayloadAttestation object -func (p *PayloadAttestation) SizeSSZ() (size int) { - size = 202 - return -} + // Field 10: Eth1DepositIndex + dst = binary.LittleEndian.AppendUint64(dst, c.Eth1DepositIndex) -// HashTreeRoot ssz hashes the PayloadAttestation object -func (p *PayloadAttestation) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(p) -} + // Field 11: Validators + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Validators) * 121 -// HashTreeRootWith ssz hashes the PayloadAttestation object with a hasher -func (p *PayloadAttestation) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() + // Field 12: Balances + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Balances) * 8 - // Field (0) 'AggregationBits' - if size := len(p.AggregationBits); size != 64 { - err = ssz.ErrBytesLengthFn("--.AggregationBits", size, 64) - return + // Field 13: RandaoMixes + if len(c.RandaoMixes) != 65536 { + return nil, ssz.ErrBytesLength } - hh.PutBytes(p.AggregationBits) - - // Field (1) 'Data' - if err = p.Data.HashTreeRootWith(hh); err != nil { - return + for _, o := range c.RandaoMixes { + if len(o) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) } - // Field (2) 'Signature' - if size := len(p.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 14: Slashings + if len(c.Slashings) != 8192 { + return nil, ssz.ErrBytesLength + } + for _, o := range c.Slashings { + dst = binary.LittleEndian.AppendUint64(dst, o) } - hh.PutBytes(p.Signature) - hh.Merkleize(indx) - return -} + // Field 15: PreviousEpochParticipation + dst = ssz.WriteOffset(dst, offset) + offset += len(c.PreviousEpochParticipation) -// MarshalSSZ ssz marshals the PayloadAttestationMessage object -func (p *PayloadAttestationMessage) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(p) -} + // Field 16: CurrentEpochParticipation + dst = ssz.WriteOffset(dst, offset) + offset += len(c.CurrentEpochParticipation) -// MarshalSSZTo ssz marshals the PayloadAttestationMessage object to a target array -func (p *PayloadAttestationMessage) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf + // Field 17: JustificationBits + if len([]byte(c.JustificationBits)) != 1 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, []byte(c.JustificationBits)...) - // Field (0) 'ValidatorIndex' - dst = ssz.MarshalUint(dst, p.ValidatorIndex) + // Field 18: PreviousJustifiedCheckpoint + if c.PreviousJustifiedCheckpoint == nil { + c.PreviousJustifiedCheckpoint = new(Checkpoint) + } + if dst, err = c.PreviousJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("PreviousJustifiedCheckpoint: %w", err) + } - // Field (1) 'Data' - if p.Data == nil { - p.Data = new(PayloadAttestationData) + // Field 19: CurrentJustifiedCheckpoint + if c.CurrentJustifiedCheckpoint == nil { + c.CurrentJustifiedCheckpoint = new(Checkpoint) } - if dst, err = p.Data.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.CurrentJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("CurrentJustifiedCheckpoint: %w", err) } - // Field (2) 'Signature' - if size := len(p.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 20: FinalizedCheckpoint + if c.FinalizedCheckpoint == nil { + c.FinalizedCheckpoint = new(Checkpoint) + } + if dst, err = c.FinalizedCheckpoint.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("FinalizedCheckpoint: %w", err) } - dst = append(dst, p.Signature...) - return -} + // Field 21: InactivityScores + dst = ssz.WriteOffset(dst, offset) + offset += len(c.InactivityScores) * 8 -// UnmarshalSSZ ssz unmarshals the PayloadAttestationMessage object -func (p *PayloadAttestationMessage) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size != 146 { - return ssz.ErrSize + // Field 22: CurrentSyncCommittee + if c.CurrentSyncCommittee == nil { + c.CurrentSyncCommittee = new(SyncCommittee) + } + if dst, err = c.CurrentSyncCommittee.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("CurrentSyncCommittee: %w", err) } - // Field (0) 'ValidatorIndex' - p.ValidatorIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[0:8]) - - // Field (1) 'Data' - if p.Data == nil { - p.Data = new(PayloadAttestationData) + // Field 23: NextSyncCommittee + if c.NextSyncCommittee == nil { + c.NextSyncCommittee = new(SyncCommittee) } - if err = p.Data.UnmarshalSSZ(buf[8:50]); err != nil { - return err + if dst, err = c.NextSyncCommittee.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("NextSyncCommittee: %w", err) } - // Field (2) 'Signature' - if cap(p.Signature) == 0 { - p.Signature = make([]byte, 0, len(buf[50:146])) + // Field 24: LatestBlockHash + if len(c.LatestBlockHash) != 32 { + return nil, ssz.ErrBytesLength } - p.Signature = append(p.Signature, buf[50:146]...) + dst = append(dst, c.LatestBlockHash...) - return err -} + // Field 25: NextWithdrawalIndex + dst = binary.LittleEndian.AppendUint64(dst, c.NextWithdrawalIndex) -// SizeSSZ returns the ssz encoded size in bytes for the PayloadAttestationMessage object -func (p *PayloadAttestationMessage) SizeSSZ() (size int) { - size = 146 - return -} + // Field 26: NextWithdrawalValidatorIndex + if dst, err = c.NextWithdrawalValidatorIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("NextWithdrawalValidatorIndex: %w", err) + } -// HashTreeRoot ssz hashes the PayloadAttestationMessage object -func (p *PayloadAttestationMessage) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(p) -} + // Field 27: HistoricalSummaries + dst = ssz.WriteOffset(dst, offset) + offset += len(c.HistoricalSummaries) * 64 -// HashTreeRootWith ssz hashes the PayloadAttestationMessage object with a hasher -func (p *PayloadAttestationMessage) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() + // Field 28: DepositRequestsStartIndex + dst = binary.LittleEndian.AppendUint64(dst, c.DepositRequestsStartIndex) - // Field (0) 'ValidatorIndex' - ssz.PutUint(hh, p.ValidatorIndex) + // Field 29: DepositBalanceToConsume + if dst, err = c.DepositBalanceToConsume.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("DepositBalanceToConsume: %w", err) + } - // Field (1) 'Data' - if err = p.Data.HashTreeRootWith(hh); err != nil { - return + // Field 30: ExitBalanceToConsume + if dst, err = c.ExitBalanceToConsume.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ExitBalanceToConsume: %w", err) } - // Field (2) 'Signature' - if size := len(p.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 31: EarliestExitEpoch + if dst, err = c.EarliestExitEpoch.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("EarliestExitEpoch: %w", err) } - hh.PutBytes(p.Signature) - hh.Merkleize(indx) - return -} + // Field 32: ConsolidationBalanceToConsume + if dst, err = c.ConsolidationBalanceToConsume.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ConsolidationBalanceToConsume: %w", err) + } -// MarshalSSZ ssz marshals the BeaconBlockGloas object -func (b *BeaconBlockGloas) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} + // Field 33: EarliestConsolidationEpoch + if dst, err = c.EarliestConsolidationEpoch.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("EarliestConsolidationEpoch: %w", err) + } -// MarshalSSZTo ssz marshals the BeaconBlockGloas object to a target array -func (b *BeaconBlockGloas) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(84) + // Field 34: PendingDeposits + dst = ssz.WriteOffset(dst, offset) + offset += len(c.PendingDeposits) * 192 - // Field (0) 'Slot' - dst = ssz.MarshalUint(dst, b.Slot) + // Field 35: PendingPartialWithdrawals + dst = ssz.WriteOffset(dst, offset) + offset += len(c.PendingPartialWithdrawals) * 24 - // Field (1) 'ProposerIndex' - dst = ssz.MarshalUint(dst, b.ProposerIndex) + // Field 36: PendingConsolidations + dst = ssz.WriteOffset(dst, offset) + offset += len(c.PendingConsolidations) * 16 - // Field (2) 'ParentRoot' - if size := len(b.ParentRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentRoot", size, 32) - return + // Field 37: ProposerLookahead + if len(c.ProposerLookahead) != 64 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.ParentRoot...) - - // Field (3) 'StateRoot' - if size := len(b.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return + for _, o := range c.ProposerLookahead { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ProposerLookahead: %w", err) + } } - dst = append(dst, b.StateRoot...) - // Offset (4) 'Body' + // Field 38: Builders dst = ssz.WriteOffset(dst, offset) - if b.Body == nil { - b.Body = new(BeaconBlockBodyGloas) - } - offset += b.Body.SizeSSZ() + offset += len(c.Builders) * 93 - // Field (4) 'Body' - if dst, err = b.Body.MarshalSSZTo(dst); err != nil { - return + // Field 39: NextWithdrawalBuilderIndex + if dst, err = c.NextWithdrawalBuilderIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("NextWithdrawalBuilderIndex: %w", err) } - return -} + // Field 40: ExecutionPayloadAvailability + if len(c.ExecutionPayloadAvailability) != 1024 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.ExecutionPayloadAvailability...) -// UnmarshalSSZ ssz unmarshals the BeaconBlockGloas object -func (b *BeaconBlockGloas) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 84 { - return ssz.ErrSize + // Field 41: BuilderPendingPayments + if len(c.BuilderPendingPayments) != 64 { + return nil, ssz.ErrBytesLength + } + for _, o := range c.BuilderPendingPayments { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("BuilderPendingPayments: %w", err) + } } - tail := buf - var o4 uint64 + // Field 42: BuilderPendingWithdrawals + dst = ssz.WriteOffset(dst, offset) + offset += len(c.BuilderPendingWithdrawals) * 36 - // Field (0) 'Slot' - b.Slot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[0:8]) + // Field 43: LatestExecutionPayloadBid + if c.LatestExecutionPayloadBid == nil { + c.LatestExecutionPayloadBid = new(ExecutionPayloadBid) + } + dst = ssz.WriteOffset(dst, offset) + offset += c.LatestExecutionPayloadBid.SizeSSZ() - // Field (1) 'ProposerIndex' - b.ProposerIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[8:16]) + // Field 44: PayloadExpectedWithdrawals + dst = ssz.WriteOffset(dst, offset) + offset += len(c.PayloadExpectedWithdrawals) * 44 - // Field (2) 'ParentRoot' - if cap(b.ParentRoot) == 0 { - b.ParentRoot = make([]byte, 0, len(buf[16:48])) + // Field 45: PtcWindow + if len(c.PtcWindow) != 96 { + return nil, ssz.ErrBytesLength } - 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]...) - - // 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(BeaconBlockBodyGloas) + for _, o := range c.PtcWindow { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("PtcWindow: %w", err) } - if err = b.Body.UnmarshalSSZ(buf); err != nil { - return err - } - } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the BeaconBlockGloas object -func (b *BeaconBlockGloas) SizeSSZ() (size int) { - size = 84 - - // Field (4) 'Body' - if b.Body == nil { - b.Body = new(BeaconBlockBodyGloas) } - size += b.Body.SizeSSZ() - return -} - -// HashTreeRoot ssz hashes the BeaconBlockGloas object -func (b *BeaconBlockGloas) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) -} - -// HashTreeRootWith ssz hashes the BeaconBlockGloas object with a hasher -func (b *BeaconBlockGloas) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'Slot' - ssz.PutUint(hh, b.Slot) - - // Field (1) 'ProposerIndex' - ssz.PutUint(hh, b.ProposerIndex) - - // Field (2) 'ParentRoot' - if size := len(b.ParentRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentRoot", size, 32) - return + // Field 7: HistoricalRoots + if len(c.HistoricalRoots) > 16777216 { + return nil, ssz.ErrListTooBig } - hh.PutBytes(b.ParentRoot) - - // Field (3) 'StateRoot' - if size := len(b.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return + for _, o := range c.HistoricalRoots { + if len(o) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) } - hh.PutBytes(b.StateRoot) - // Field (4) 'Body' - if err = b.Body.HashTreeRootWith(hh); err != nil { - return + // Field 9: Eth1DataVotes + if len(c.Eth1DataVotes) > 2048 { + return nil, ssz.ErrListTooBig } - - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the BeaconBlockBodyGloas object -func (b *BeaconBlockBodyGloas) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} - -// MarshalSSZTo ssz marshals the BeaconBlockBodyGloas object to a target array -func (b *BeaconBlockBodyGloas) 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("--.RandaoReveal", size, 96) - return + for _, o := range c.Eth1DataVotes { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Eth1DataVotes: %w", err) + } } - dst = append(dst, b.RandaoReveal...) - // Field (1) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(Eth1Data) + // Field 11: Validators + if len(c.Validators) > 1099511627776 { + return nil, ssz.ErrListTooBig } - if dst, err = b.Eth1Data.MarshalSSZTo(dst); err != nil { - return + for _, o := range c.Validators { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Validators: %w", err) + } } - // Field (2) 'Graffiti' - if size := len(b.Graffiti); size != 32 { - err = ssz.ErrBytesLengthFn("--.Graffiti", size, 32) - return + // Field 12: Balances + if len(c.Balances) > 1099511627776 { + return nil, ssz.ErrListTooBig } - 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() + for _, o := range c.Balances { + dst = binary.LittleEndian.AppendUint64(dst, o) } - // Offset (5) 'Attestations' - dst = ssz.WriteOffset(dst, offset) - for ii := 0; ii < len(b.Attestations); ii++ { - offset += 4 - offset += b.Attestations[ii].SizeSSZ() + // Field 15: PreviousEpochParticipation + if len(c.PreviousEpochParticipation) > 1099511627776 { + return nil, ssz.ErrListTooBig } + dst = append(dst, c.PreviousEpochParticipation...) - // 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(SyncAggregate) + // Field 16: CurrentEpochParticipation + if len(c.CurrentEpochParticipation) > 1099511627776 { + return nil, ssz.ErrListTooBig } - if dst, err = b.SyncAggregate.MarshalSSZTo(dst); err != nil { - return - } - - // Offset (9) 'BlsToExecutionChanges' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.BlsToExecutionChanges) * 172 + dst = append(dst, c.CurrentEpochParticipation...) - // Offset (10) 'SignedExecutionPayloadBid' - dst = ssz.WriteOffset(dst, offset) - if b.SignedExecutionPayloadBid == nil { - b.SignedExecutionPayloadBid = new(SignedExecutionPayloadBid) + // Field 21: InactivityScores + if len(c.InactivityScores) > 1099511627776 { + return nil, ssz.ErrListTooBig } - offset += b.SignedExecutionPayloadBid.SizeSSZ() - - // Offset (11) 'PayloadAttestations' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.PayloadAttestations) * 202 - - // Offset (12) 'ParentExecutionRequests' - dst = ssz.WriteOffset(dst, offset) - if b.ParentExecutionRequests == nil { - b.ParentExecutionRequests = new(v1.ExecutionRequestsGloas) + for _, o := range c.InactivityScores { + dst = binary.LittleEndian.AppendUint64(dst, o) } - offset += b.ParentExecutionRequests.SizeSSZ() - // Field (3) 'ProposerSlashings' - if size := len(b.ProposerSlashings); size > 16 { - err = ssz.ErrListTooBigFn("--.ProposerSlashings", size, 16) - return + // Field 27: HistoricalSummaries + if len(c.HistoricalSummaries) > 16777216 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.ProposerSlashings); ii++ { - if dst, err = b.ProposerSlashings[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.HistoricalSummaries { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("HistoricalSummaries: %w", err) } } - // Field (4) 'AttesterSlashings' - if size := len(b.AttesterSlashings); size > 1 { - err = ssz.ErrListTooBigFn("--.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() - } + // Field 34: PendingDeposits + if len(c.PendingDeposits) > 134217728 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.AttesterSlashings); ii++ { - if dst, err = b.AttesterSlashings[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.PendingDeposits { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("PendingDeposits: %w", err) } } - // Field (5) 'Attestations' - if size := len(b.Attestations); size > 8 { - err = ssz.ErrListTooBigFn("--.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() - } + // Field 35: PendingPartialWithdrawals + if len(c.PendingPartialWithdrawals) > 134217728 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.Attestations); ii++ { - if dst, err = b.Attestations[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.PendingPartialWithdrawals { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("PendingPartialWithdrawals: %w", err) } } - // Field (6) 'Deposits' - if size := len(b.Deposits); size > 16 { - err = ssz.ErrListTooBigFn("--.Deposits", size, 16) - return + // Field 36: PendingConsolidations + if len(c.PendingConsolidations) > 262144 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.Deposits); ii++ { - if dst, err = b.Deposits[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.PendingConsolidations { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("PendingConsolidations: %w", err) } } - // Field (7) 'VoluntaryExits' - if size := len(b.VoluntaryExits); size > 16 { - err = ssz.ErrListTooBigFn("--.VoluntaryExits", size, 16) - return + // Field 38: Builders + if len(c.Builders) > 1099511627776 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.VoluntaryExits); ii++ { - if dst, err = b.VoluntaryExits[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.Builders { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Builders: %w", err) } } - // Field (9) 'BlsToExecutionChanges' - if size := len(b.BlsToExecutionChanges); size > 16 { - err = ssz.ErrListTooBigFn("--.BlsToExecutionChanges", size, 16) - return + // Field 42: BuilderPendingWithdrawals + if len(c.BuilderPendingWithdrawals) > 1048576 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.BlsToExecutionChanges); ii++ { - if dst, err = b.BlsToExecutionChanges[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.BuilderPendingWithdrawals { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("BuilderPendingWithdrawals: %w", err) } } - // Field (10) 'SignedExecutionPayloadBid' - if dst, err = b.SignedExecutionPayloadBid.MarshalSSZTo(dst); err != nil { - return + // Field 43: LatestExecutionPayloadBid + if dst, err = c.LatestExecutionPayloadBid.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("LatestExecutionPayloadBid: %w", err) } - // Field (11) 'PayloadAttestations' - if size := len(b.PayloadAttestations); size > 4 { - err = ssz.ErrListTooBigFn("--.PayloadAttestations", size, 4) - return + // Field 44: PayloadExpectedWithdrawals + if len(c.PayloadExpectedWithdrawals) > 16 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.PayloadAttestations); ii++ { - if dst, err = b.PayloadAttestations[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.PayloadExpectedWithdrawals { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("PayloadExpectedWithdrawals: %w", err) } } - - // Field (12) 'ParentExecutionRequests' - if dst, err = b.ParentExecutionRequests.MarshalSSZTo(dst); err != nil { - return - } - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the BeaconBlockBodyGloas object -func (b *BeaconBlockBodyGloas) UnmarshalSSZ(buf []byte) error { +func (c *BeaconStateGloas) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 396 { + if size < 3134845 { 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])) + sszSlice0 := buf[0:8] // c.GenesisTime + sszSlice1 := buf[8:40] // c.GenesisValidatorsRoot + sszSlice2 := buf[40:48] // c.Slot + sszSlice3 := buf[48:64] // c.Fork + sszSlice4 := buf[64:176] // c.LatestBlockHeader + sszSlice5 := buf[176:262320] // c.BlockRoots + sszSlice6 := buf[262320:524464] // c.StateRoots + sszSlice8 := buf[524468:524540] // c.Eth1Data + sszSlice10 := buf[524544:524552] // c.Eth1DepositIndex + sszSlice13 := buf[524560:2621712] // c.RandaoMixes + sszSlice14 := buf[2621712:2687248] // c.Slashings + sszSlice17 := buf[2687256:2687257] // c.JustificationBits + sszSlice18 := buf[2687257:2687297] // c.PreviousJustifiedCheckpoint + sszSlice19 := buf[2687297:2687337] // c.CurrentJustifiedCheckpoint + sszSlice20 := buf[2687337:2687377] // c.FinalizedCheckpoint + sszSlice22 := buf[2687381:2712005] // c.CurrentSyncCommittee + sszSlice23 := buf[2712005:2736629] // c.NextSyncCommittee + sszSlice24 := buf[2736629:2736661] // c.LatestBlockHash + sszSlice25 := buf[2736661:2736669] // c.NextWithdrawalIndex + sszSlice26 := buf[2736669:2736677] // c.NextWithdrawalValidatorIndex + sszSlice28 := buf[2736681:2736689] // c.DepositRequestsStartIndex + sszSlice29 := buf[2736689:2736697] // c.DepositBalanceToConsume + sszSlice30 := buf[2736697:2736705] // c.ExitBalanceToConsume + sszSlice31 := buf[2736705:2736713] // c.EarliestExitEpoch + sszSlice32 := buf[2736713:2736721] // c.ConsolidationBalanceToConsume + sszSlice33 := buf[2736721:2736729] // c.EarliestConsolidationEpoch + sszSlice37 := buf[2736741:2737253] // c.ProposerLookahead + sszSlice39 := buf[2737257:2737265] // c.NextWithdrawalBuilderIndex + sszSlice40 := buf[2737265:2738289] // c.ExecutionPayloadAvailability + sszSlice41 := buf[2738289:2741617] // c.BuilderPendingPayments + sszSlice45 := buf[2741629:3134845] // c.PtcWindow + + sszVarOffset7 := ssz.ReadOffset(buf[524464:524468]) // c.HistoricalRoots + if sszVarOffset7 != 3134845 { + return ssz.ErrInvalidVariableOffset } - b.RandaoReveal = append(b.RandaoReveal, buf[0:96]...) - - // Field (1) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(Eth1Data) + if sszVarOffset7 > size { + return ssz.ErrOffset } - if err = b.Eth1Data.UnmarshalSSZ(buf[96:168]); err != nil { - return err + sszVarOffset9 := ssz.ReadOffset(buf[524540:524544]) // c.Eth1DataVotes + if sszVarOffset9 > size || sszVarOffset9 < sszVarOffset7 { + return ssz.ErrOffset } - - // Field (2) 'Graffiti' - if cap(b.Graffiti) == 0 { - b.Graffiti = make([]byte, 0, len(buf[168:200])) + sszVarOffset11 := ssz.ReadOffset(buf[524552:524556]) // c.Validators + if sszVarOffset11 > size || sszVarOffset11 < sszVarOffset9 { + return ssz.ErrOffset } - b.Graffiti = append(b.Graffiti, buf[168:200]...) - - // Offset (3) 'ProposerSlashings' - if o3 = ssz.ReadOffset(buf[200:204]); o3 > size { + sszVarOffset12 := ssz.ReadOffset(buf[524556:524560]) // c.Balances + if sszVarOffset12 > size || sszVarOffset12 < sszVarOffset11 { return ssz.ErrOffset } - - if o3 != 396 { - return ssz.ErrInvalidVariableOffset + sszVarOffset15 := ssz.ReadOffset(buf[2687248:2687252]) // c.PreviousEpochParticipation + if sszVarOffset15 > size || sszVarOffset15 < sszVarOffset12 { + return ssz.ErrOffset } - - // Offset (4) 'AttesterSlashings' - if o4 = ssz.ReadOffset(buf[204:208]); o4 > size || o3 > o4 { + sszVarOffset16 := ssz.ReadOffset(buf[2687252:2687256]) // c.CurrentEpochParticipation + if sszVarOffset16 > size || sszVarOffset16 < sszVarOffset15 { return ssz.ErrOffset } - - // Offset (5) 'Attestations' - if o5 = ssz.ReadOffset(buf[208:212]); o5 > size || o4 > o5 { + sszVarOffset21 := ssz.ReadOffset(buf[2687377:2687381]) // c.InactivityScores + if sszVarOffset21 > size || sszVarOffset21 < sszVarOffset16 { return ssz.ErrOffset } - - // Offset (6) 'Deposits' - if o6 = ssz.ReadOffset(buf[212:216]); o6 > size || o5 > o6 { + sszVarOffset27 := ssz.ReadOffset(buf[2736677:2736681]) // c.HistoricalSummaries + if sszVarOffset27 > size || sszVarOffset27 < sszVarOffset21 { return ssz.ErrOffset } - - // Offset (7) 'VoluntaryExits' - if o7 = ssz.ReadOffset(buf[216:220]); o7 > size || o6 > o7 { + sszVarOffset34 := ssz.ReadOffset(buf[2736729:2736733]) // c.PendingDeposits + if sszVarOffset34 > size || sszVarOffset34 < sszVarOffset27 { return ssz.ErrOffset } - - // Field (8) 'SyncAggregate' - if b.SyncAggregate == nil { - b.SyncAggregate = new(SyncAggregate) + sszVarOffset35 := ssz.ReadOffset(buf[2736733:2736737]) // c.PendingPartialWithdrawals + if sszVarOffset35 > size || sszVarOffset35 < sszVarOffset34 { + return ssz.ErrOffset } - if err = b.SyncAggregate.UnmarshalSSZ(buf[220:380]); err != nil { - return err + sszVarOffset36 := ssz.ReadOffset(buf[2736737:2736741]) // c.PendingConsolidations + if sszVarOffset36 > size || sszVarOffset36 < sszVarOffset35 { + return ssz.ErrOffset } - - // Offset (9) 'BlsToExecutionChanges' - if o9 = ssz.ReadOffset(buf[380:384]); o9 > size || o7 > o9 { + sszVarOffset38 := ssz.ReadOffset(buf[2737253:2737257]) // c.Builders + if sszVarOffset38 > size || sszVarOffset38 < sszVarOffset36 { return ssz.ErrOffset } - - // Offset (10) 'SignedExecutionPayloadBid' - if o10 = ssz.ReadOffset(buf[384:388]); o10 > size || o9 > o10 { + sszVarOffset42 := ssz.ReadOffset(buf[2741617:2741621]) // c.BuilderPendingWithdrawals + if sszVarOffset42 > size || sszVarOffset42 < sszVarOffset38 { return ssz.ErrOffset } - - // Offset (11) 'PayloadAttestations' - if o11 = ssz.ReadOffset(buf[388:392]); o11 > size || o10 > o11 { + sszVarOffset43 := ssz.ReadOffset(buf[2741621:2741625]) // c.LatestExecutionPayloadBid + if sszVarOffset43 > size || sszVarOffset43 < sszVarOffset42 { return ssz.ErrOffset } - - // Offset (12) 'ParentExecutionRequests' - if o12 = ssz.ReadOffset(buf[392:396]); o12 > size || o11 > o12 { + sszVarOffset44 := ssz.ReadOffset(buf[2741625:2741629]) // c.PayloadExpectedWithdrawals + if sszVarOffset44 > size || sszVarOffset44 < sszVarOffset43 { return ssz.ErrOffset } + sszSlice7 := buf[sszVarOffset7:sszVarOffset9] // c.HistoricalRoots + sszSlice9 := buf[sszVarOffset9:sszVarOffset11] // c.Eth1DataVotes + sszSlice11 := buf[sszVarOffset11:sszVarOffset12] // c.Validators + sszSlice12 := buf[sszVarOffset12:sszVarOffset15] // c.Balances + sszSlice15 := buf[sszVarOffset15:sszVarOffset16] // c.PreviousEpochParticipation + sszSlice16 := buf[sszVarOffset16:sszVarOffset21] // c.CurrentEpochParticipation + sszSlice21 := buf[sszVarOffset21:sszVarOffset27] // c.InactivityScores + sszSlice27 := buf[sszVarOffset27:sszVarOffset34] // c.HistoricalSummaries + sszSlice34 := buf[sszVarOffset34:sszVarOffset35] // c.PendingDeposits + sszSlice35 := buf[sszVarOffset35:sszVarOffset36] // c.PendingPartialWithdrawals + sszSlice36 := buf[sszVarOffset36:sszVarOffset38] // c.PendingConsolidations + sszSlice38 := buf[sszVarOffset38:sszVarOffset42] // c.Builders + sszSlice42 := buf[sszVarOffset42:sszVarOffset43] // c.BuilderPendingWithdrawals + sszSlice43 := buf[sszVarOffset43:sszVarOffset44] // c.LatestExecutionPayloadBid + sszSlice44 := buf[sszVarOffset44:] // c.PayloadExpectedWithdrawals - // Field (3) 'ProposerSlashings' - { - buf = tail[o3:o4] - num, err := ssz.DivideInt2(len(buf), 416, 16) - if err != nil { - return err - } - b.ProposerSlashings = make([]*ProposerSlashing, num) - for ii := 0; ii < num; ii++ { - if b.ProposerSlashings[ii] == nil { - b.ProposerSlashings[ii] = new(ProposerSlashing) - } - if err = b.ProposerSlashings[ii].UnmarshalSSZ(buf[ii*416 : (ii+1)*416]); err != nil { - return err - } - } + // Field 0: GenesisTime + c.GenesisTime = binary.LittleEndian.Uint64(sszSlice0) + + // Field 1: GenesisValidatorsRoot + c.GenesisValidatorsRoot = make([]byte, 0, 32) + c.GenesisValidatorsRoot = append(c.GenesisValidatorsRoot, sszSlice1...) + + // Field 2: Slot + if err = c.Slot.UnmarshalSSZ(sszSlice2); err != nil { + return fmt.Errorf("Slot: %w", err) + } + + // Field 3: Fork + c.Fork = new(Fork) + if err = c.Fork.UnmarshalSSZ(sszSlice3); err != nil { + return fmt.Errorf("Fork: %w", err) + } + + // Field 4: LatestBlockHeader + c.LatestBlockHeader = new(BeaconBlockHeader) + if err = c.LatestBlockHeader.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("LatestBlockHeader: %w", err) } - // Field (4) 'AttesterSlashings' + // Field 5: BlockRoots { - buf = tail[o4:o5] - num, err := ssz.DecodeDynamicLength(buf, 1) - if err != nil { - return err - } - b.AttesterSlashings = make([]*AttesterSlashingGloas, num) - err = ssz.UnmarshalDynamic(buf, num, func(indx int, buf []byte) (err error) { - if b.AttesterSlashings[indx] == nil { - b.AttesterSlashings[indx] = new(AttesterSlashingGloas) - } - if err = b.AttesterSlashings[indx].UnmarshalSSZ(buf); err != nil { - return err - } - return nil - }) - if err != nil { - return err + c.BlockRoots = make([][]byte, 8192) + for i := 0; i < 8192; i++ { + var tmp []byte + + tmpSlice := sszSlice5[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.BlockRoots[i] = tmp } } - // Field (5) 'Attestations' + // Field 6: StateRoots { - buf = tail[o5:o6] - num, err := ssz.DecodeDynamicLength(buf, 8) - if err != nil { - return err - } - b.Attestations = make([]*AttestationGloas, num) - err = ssz.UnmarshalDynamic(buf, num, func(indx int, buf []byte) (err error) { - if b.Attestations[indx] == nil { - b.Attestations[indx] = new(AttestationGloas) - } - if err = b.Attestations[indx].UnmarshalSSZ(buf); err != nil { - return err - } - return nil - }) - if err != nil { - return err + c.StateRoots = make([][]byte, 8192) + for i := 0; i < 8192; i++ { + var tmp []byte + + tmpSlice := sszSlice6[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.StateRoots[i] = tmp } } - // Field (6) 'Deposits' + // Field 7: HistoricalRoots { - buf = tail[o6:o7] - num, err := ssz.DivideInt2(len(buf), 1240, 16) - if err != nil { - return err - } - b.Deposits = make([]*Deposit, num) - for ii := 0; ii < num; ii++ { - if b.Deposits[ii] == nil { - b.Deposits[ii] = new(Deposit) - } - if err = b.Deposits[ii].UnmarshalSSZ(buf[ii*1240 : (ii+1)*1240]); err != nil { - return err - } + if len(sszSlice7)%32 != 0 { + return fmt.Errorf("misaligned bytes: c.HistoricalRoots length is %d, which is not a multiple of 32: %w", len(sszSlice7), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice7) / 32 + if numElem > 16777216 { + return fmt.Errorf("ssz-max exceeded: c.HistoricalRoots has %d elements, ssz-max is 16777216: %w", numElem, ssz.ErrListTooBig) } + c.HistoricalRoots = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte + + tmpSlice := sszSlice7[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.HistoricalRoots[i] = tmp + } + } + + // Field 8: Eth1Data + c.Eth1Data = new(Eth1Data) + if err = c.Eth1Data.UnmarshalSSZ(sszSlice8); err != nil { + return fmt.Errorf("Eth1Data: %w", err) } - // Field (7) 'VoluntaryExits' + // Field 9: Eth1DataVotes { - buf = tail[o7:o9] - num, err := ssz.DivideInt2(len(buf), 112, 16) - if err != nil { - return err - } - b.VoluntaryExits = make([]*SignedVoluntaryExit, num) - for ii := 0; ii < num; ii++ { - if b.VoluntaryExits[ii] == nil { - b.VoluntaryExits[ii] = new(SignedVoluntaryExit) - } - if err = b.VoluntaryExits[ii].UnmarshalSSZ(buf[ii*112 : (ii+1)*112]); err != nil { - return err + if len(sszSlice9)%72 != 0 { + return fmt.Errorf("misaligned bytes: c.Eth1DataVotes length is %d, which is not a multiple of 72: %w", len(sszSlice9), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice9) / 72 + if numElem > 2048 { + return fmt.Errorf("ssz-max exceeded: c.Eth1DataVotes has %d elements, ssz-max is 2048: %w", numElem, ssz.ErrListTooBig) + } + c.Eth1DataVotes = make([]*Eth1Data, numElem) + for i := 0; i < numElem; i++ { + var tmp *Eth1Data + tmp = new(Eth1Data) + tmpSlice := sszSlice9[i*72 : (1+i)*72] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Eth1DataVotes: %w", err) } + c.Eth1DataVotes[i] = tmp } } - // Field (9) 'BlsToExecutionChanges' + // Field 10: Eth1DepositIndex + c.Eth1DepositIndex = binary.LittleEndian.Uint64(sszSlice10) + + // Field 11: Validators { - buf = tail[o9:o10] - num, err := ssz.DivideInt2(len(buf), 172, 16) - if err != nil { - return err - } - b.BlsToExecutionChanges = make([]*SignedBLSToExecutionChange, num) - for ii := 0; ii < num; ii++ { - if b.BlsToExecutionChanges[ii] == nil { - b.BlsToExecutionChanges[ii] = new(SignedBLSToExecutionChange) - } - if err = b.BlsToExecutionChanges[ii].UnmarshalSSZ(buf[ii*172 : (ii+1)*172]); err != nil { - return err + if len(sszSlice11)%121 != 0 { + return fmt.Errorf("misaligned bytes: c.Validators length is %d, which is not a multiple of 121: %w", len(sszSlice11), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice11) / 121 + if numElem > 1099511627776 { + return fmt.Errorf("ssz-max exceeded: c.Validators has %d elements, ssz-max is 1099511627776: %w", numElem, ssz.ErrListTooBig) + } + c.Validators = make([]*Validator, numElem) + for i := 0; i < numElem; i++ { + var tmp *Validator + tmp = new(Validator) + tmpSlice := sszSlice11[i*121 : (1+i)*121] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Validators: %w", err) } + c.Validators[i] = tmp } } - // Field (10) 'SignedExecutionPayloadBid' + // Field 12: Balances { - buf = tail[o10:o11] - if b.SignedExecutionPayloadBid == nil { - b.SignedExecutionPayloadBid = new(SignedExecutionPayloadBid) + if len(sszSlice12)%8 != 0 { + return fmt.Errorf("misaligned bytes: c.Balances length is %d, which is not a multiple of 8: %w", len(sszSlice12), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice12) / 8 + if numElem > 1099511627776 { + return fmt.Errorf("ssz-max exceeded: c.Balances has %d elements, ssz-max is 1099511627776: %w", numElem, ssz.ErrListTooBig) } - if err = b.SignedExecutionPayloadBid.UnmarshalSSZ(buf); err != nil { - return err + c.Balances = make([]uint64, numElem) + for i := 0; i < numElem; i++ { + var tmp uint64 + + tmpSlice := sszSlice12[i*8 : (1+i)*8] + tmp = binary.LittleEndian.Uint64(tmpSlice) + c.Balances[i] = tmp } } - // Field (11) 'PayloadAttestations' + // Field 13: RandaoMixes { - buf = tail[o11:o12] - num, err := ssz.DivideInt2(len(buf), 202, 4) - if err != nil { - return err - } - b.PayloadAttestations = make([]*PayloadAttestation, num) - for ii := 0; ii < num; ii++ { - if b.PayloadAttestations[ii] == nil { - b.PayloadAttestations[ii] = new(PayloadAttestation) - } - if err = b.PayloadAttestations[ii].UnmarshalSSZ(buf[ii*202 : (ii+1)*202]); err != nil { - return err - } + c.RandaoMixes = make([][]byte, 65536) + for i := 0; i < 65536; i++ { + var tmp []byte + + tmpSlice := sszSlice13[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.RandaoMixes[i] = tmp } } - // Field (12) 'ParentExecutionRequests' + // Field 14: Slashings { - buf = tail[o12:] - if b.ParentExecutionRequests == nil { - b.ParentExecutionRequests = new(v1.ExecutionRequestsGloas) - } - if err = b.ParentExecutionRequests.UnmarshalSSZ(buf); err != nil { - return err + c.Slashings = make([]uint64, 8192) + for i := 0; i < 8192; i++ { + var tmp uint64 + + tmpSlice := sszSlice14[i*8 : (1+i)*8] + tmp = binary.LittleEndian.Uint64(tmpSlice) + c.Slashings[i] = tmp } } - return err -} -// SizeSSZ returns the ssz encoded size in bytes for the BeaconBlockBodyGloas object -func (b *BeaconBlockBodyGloas) SizeSSZ() (size int) { - size = 396 + // Field 15: PreviousEpochParticipation + c.PreviousEpochParticipation = append([]byte{}, sszSlice15...) - // Field (3) 'ProposerSlashings' - size += len(b.ProposerSlashings) * 416 + // Field 16: CurrentEpochParticipation + c.CurrentEpochParticipation = append([]byte{}, sszSlice16...) - // Field (4) 'AttesterSlashings' - for ii := 0; ii < len(b.AttesterSlashings); ii++ { - size += 4 - size += b.AttesterSlashings[ii].SizeSSZ() + // Field 17: JustificationBits + c.JustificationBits = make([]byte, 0, 1) + c.JustificationBits = append(c.JustificationBits, go_bitfield.Bitvector4(sszSlice17)...) + + // Field 18: PreviousJustifiedCheckpoint + c.PreviousJustifiedCheckpoint = new(Checkpoint) + if err = c.PreviousJustifiedCheckpoint.UnmarshalSSZ(sszSlice18); err != nil { + return fmt.Errorf("PreviousJustifiedCheckpoint: %w", err) } - // Field (5) 'Attestations' - for ii := 0; ii < len(b.Attestations); ii++ { - size += 4 - size += b.Attestations[ii].SizeSSZ() + // Field 19: CurrentJustifiedCheckpoint + c.CurrentJustifiedCheckpoint = new(Checkpoint) + if err = c.CurrentJustifiedCheckpoint.UnmarshalSSZ(sszSlice19); err != nil { + return fmt.Errorf("CurrentJustifiedCheckpoint: %w", err) + } + + // Field 20: FinalizedCheckpoint + c.FinalizedCheckpoint = new(Checkpoint) + if err = c.FinalizedCheckpoint.UnmarshalSSZ(sszSlice20); err != nil { + return fmt.Errorf("FinalizedCheckpoint: %w", err) } - // Field (6) 'Deposits' - size += len(b.Deposits) * 1240 + // Field 21: InactivityScores + { + if len(sszSlice21)%8 != 0 { + return fmt.Errorf("misaligned bytes: c.InactivityScores length is %d, which is not a multiple of 8: %w", len(sszSlice21), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice21) / 8 + if numElem > 1099511627776 { + return fmt.Errorf("ssz-max exceeded: c.InactivityScores has %d elements, ssz-max is 1099511627776: %w", numElem, ssz.ErrListTooBig) + } + c.InactivityScores = make([]uint64, numElem) + for i := 0; i < numElem; i++ { + var tmp uint64 - // Field (7) 'VoluntaryExits' - size += len(b.VoluntaryExits) * 112 + tmpSlice := sszSlice21[i*8 : (1+i)*8] + tmp = binary.LittleEndian.Uint64(tmpSlice) + c.InactivityScores[i] = tmp + } + } - // Field (9) 'BlsToExecutionChanges' - size += len(b.BlsToExecutionChanges) * 172 + // Field 22: CurrentSyncCommittee + c.CurrentSyncCommittee = new(SyncCommittee) + if err = c.CurrentSyncCommittee.UnmarshalSSZ(sszSlice22); err != nil { + return fmt.Errorf("CurrentSyncCommittee: %w", err) + } - // Field (10) 'SignedExecutionPayloadBid' - if b.SignedExecutionPayloadBid == nil { - b.SignedExecutionPayloadBid = new(SignedExecutionPayloadBid) + // Field 23: NextSyncCommittee + c.NextSyncCommittee = new(SyncCommittee) + if err = c.NextSyncCommittee.UnmarshalSSZ(sszSlice23); err != nil { + return fmt.Errorf("NextSyncCommittee: %w", err) } - size += b.SignedExecutionPayloadBid.SizeSSZ() - // Field (11) 'PayloadAttestations' - size += len(b.PayloadAttestations) * 202 + // Field 24: LatestBlockHash + c.LatestBlockHash = make([]byte, 0, 32) + c.LatestBlockHash = append(c.LatestBlockHash, sszSlice24...) + + // Field 25: NextWithdrawalIndex + c.NextWithdrawalIndex = binary.LittleEndian.Uint64(sszSlice25) - // Field (12) 'ParentExecutionRequests' - if b.ParentExecutionRequests == nil { - b.ParentExecutionRequests = new(v1.ExecutionRequestsGloas) + // Field 26: NextWithdrawalValidatorIndex + if err = c.NextWithdrawalValidatorIndex.UnmarshalSSZ(sszSlice26); err != nil { + return fmt.Errorf("NextWithdrawalValidatorIndex: %w", err) } - size += b.ParentExecutionRequests.SizeSSZ() - return -} + // Field 27: HistoricalSummaries + { + if len(sszSlice27)%64 != 0 { + return fmt.Errorf("misaligned bytes: c.HistoricalSummaries length is %d, which is not a multiple of 64: %w", len(sszSlice27), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice27) / 64 + if numElem > 16777216 { + return fmt.Errorf("ssz-max exceeded: c.HistoricalSummaries has %d elements, ssz-max is 16777216: %w", numElem, ssz.ErrListTooBig) + } + c.HistoricalSummaries = make([]*HistoricalSummary, numElem) + for i := 0; i < numElem; i++ { + var tmp *HistoricalSummary + tmp = new(HistoricalSummary) + tmpSlice := sszSlice27[i*64 : (1+i)*64] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("HistoricalSummaries: %w", err) + } + c.HistoricalSummaries[i] = tmp + } + } -// HashTreeRoot ssz hashes the BeaconBlockBodyGloas object -func (b *BeaconBlockBodyGloas) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) -} + // Field 28: DepositRequestsStartIndex + c.DepositRequestsStartIndex = binary.LittleEndian.Uint64(sszSlice28) -// HashTreeRootWith ssz hashes the BeaconBlockBodyGloas object with a hasher -func (b *BeaconBlockBodyGloas) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() + // Field 29: DepositBalanceToConsume + if err = c.DepositBalanceToConsume.UnmarshalSSZ(sszSlice29); err != nil { + return fmt.Errorf("DepositBalanceToConsume: %w", err) + } - // Field (0) 'RandaoReveal' - if size := len(b.RandaoReveal); size != 96 { - err = ssz.ErrBytesLengthFn("--.RandaoReveal", size, 96) - return + // Field 30: ExitBalanceToConsume + if err = c.ExitBalanceToConsume.UnmarshalSSZ(sszSlice30); err != nil { + return fmt.Errorf("ExitBalanceToConsume: %w", err) } - hh.PutBytes(b.RandaoReveal) - // Field (1) 'Eth1Data' - if err = b.Eth1Data.HashTreeRootWith(hh); err != nil { - return + // Field 31: EarliestExitEpoch + if err = c.EarliestExitEpoch.UnmarshalSSZ(sszSlice31); err != nil { + return fmt.Errorf("EarliestExitEpoch: %w", err) } - // Field (2) 'Graffiti' - if size := len(b.Graffiti); size != 32 { - err = ssz.ErrBytesLengthFn("--.Graffiti", size, 32) - return + // Field 32: ConsolidationBalanceToConsume + if err = c.ConsolidationBalanceToConsume.UnmarshalSSZ(sszSlice32); err != nil { + return fmt.Errorf("ConsolidationBalanceToConsume: %w", err) } - hh.PutBytes(b.Graffiti) - // Field (3) 'ProposerSlashings' + // Field 33: EarliestConsolidationEpoch + if err = c.EarliestConsolidationEpoch.UnmarshalSSZ(sszSlice33); err != nil { + return fmt.Errorf("EarliestConsolidationEpoch: %w", err) + } + + // Field 34: PendingDeposits { - 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 + if len(sszSlice34)%192 != 0 { + return fmt.Errorf("misaligned bytes: c.PendingDeposits length is %d, which is not a multiple of 192: %w", len(sszSlice34), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice34) / 192 + if numElem > 134217728 { + return fmt.Errorf("ssz-max exceeded: c.PendingDeposits has %d elements, ssz-max is 134217728: %w", numElem, ssz.ErrListTooBig) + } + c.PendingDeposits = make([]*PendingDeposit, numElem) + for i := 0; i < numElem; i++ { + var tmp *PendingDeposit + tmp = new(PendingDeposit) + tmpSlice := sszSlice34[i*192 : (1+i)*192] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("PendingDeposits: %w", err) } + c.PendingDeposits[i] = tmp } - hh.MerkleizeWithMixin(subIndx, num, 16) } - // Field (4) 'AttesterSlashings' + // Field 35: PendingPartialWithdrawals { - 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 + if len(sszSlice35)%24 != 0 { + return fmt.Errorf("misaligned bytes: c.PendingPartialWithdrawals length is %d, which is not a multiple of 24: %w", len(sszSlice35), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice35) / 24 + if numElem > 134217728 { + return fmt.Errorf("ssz-max exceeded: c.PendingPartialWithdrawals has %d elements, ssz-max is 134217728: %w", numElem, ssz.ErrListTooBig) + } + c.PendingPartialWithdrawals = make([]*PendingPartialWithdrawal, numElem) + for i := 0; i < numElem; i++ { + var tmp *PendingPartialWithdrawal + tmp = new(PendingPartialWithdrawal) + tmpSlice := sszSlice35[i*24 : (1+i)*24] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("PendingPartialWithdrawals: %w", err) } + c.PendingPartialWithdrawals[i] = tmp } - hh.MerkleizeWithMixin(subIndx, num, 1) } - // Field (5) 'Attestations' + // Field 36: PendingConsolidations { - 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 + if len(sszSlice36)%16 != 0 { + return fmt.Errorf("misaligned bytes: c.PendingConsolidations length is %d, which is not a multiple of 16: %w", len(sszSlice36), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice36) / 16 + if numElem > 262144 { + return fmt.Errorf("ssz-max exceeded: c.PendingConsolidations has %d elements, ssz-max is 262144: %w", numElem, ssz.ErrListTooBig) + } + c.PendingConsolidations = make([]*PendingConsolidation, numElem) + for i := 0; i < numElem; i++ { + var tmp *PendingConsolidation + tmp = new(PendingConsolidation) + tmpSlice := sszSlice36[i*16 : (1+i)*16] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("PendingConsolidations: %w", err) } + c.PendingConsolidations[i] = tmp } - hh.MerkleizeWithMixin(subIndx, num, 8) } - // Field (6) 'Deposits' + // Field 37: ProposerLookahead { - 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 + c.ProposerLookahead = make([]primitives.ValidatorIndex, 64) + for i := 0; i < 64; i++ { + var tmp primitives.ValidatorIndex + + tmpSlice := sszSlice37[i*8 : (1+i)*8] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("ProposerLookahead: %w", err) } + c.ProposerLookahead[i] = tmp } - hh.MerkleizeWithMixin(subIndx, num, 16) } - // Field (7) 'VoluntaryExits' + // Field 38: Builders { - 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 + if len(sszSlice38)%93 != 0 { + return fmt.Errorf("misaligned bytes: c.Builders length is %d, which is not a multiple of 93: %w", len(sszSlice38), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice38) / 93 + if numElem > 1099511627776 { + return fmt.Errorf("ssz-max exceeded: c.Builders has %d elements, ssz-max is 1099511627776: %w", numElem, ssz.ErrListTooBig) + } + c.Builders = make([]*Builder, numElem) + for i := 0; i < numElem; i++ { + var tmp *Builder + tmp = new(Builder) + tmpSlice := sszSlice38[i*93 : (1+i)*93] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Builders: %w", err) } + c.Builders[i] = tmp } - hh.MerkleizeWithMixin(subIndx, num, 16) } - // Field (8) 'SyncAggregate' - if err = b.SyncAggregate.HashTreeRootWith(hh); err != nil { - return + // Field 39: NextWithdrawalBuilderIndex + if err = c.NextWithdrawalBuilderIndex.UnmarshalSSZ(sszSlice39); err != nil { + return fmt.Errorf("NextWithdrawalBuilderIndex: %w", err) } - // Field (9) 'BlsToExecutionChanges' + // Field 40: ExecutionPayloadAvailability + c.ExecutionPayloadAvailability = make([]byte, 0, 1024) + c.ExecutionPayloadAvailability = append(c.ExecutionPayloadAvailability, sszSlice40...) + + // Field 41: BuilderPendingPayments { - 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 + c.BuilderPendingPayments = make([]*BuilderPendingPayment, 64) + for i := 0; i < 64; i++ { + var tmp *BuilderPendingPayment + tmp = new(BuilderPendingPayment) + tmpSlice := sszSlice41[i*52 : (1+i)*52] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("BuilderPendingPayments: %w", err) } + c.BuilderPendingPayments[i] = tmp } - hh.MerkleizeWithMixin(subIndx, num, 16) - } - - // Field (10) 'SignedExecutionPayloadBid' - if err = b.SignedExecutionPayloadBid.HashTreeRootWith(hh); err != nil { - return } - // Field (11) 'PayloadAttestations' + // Field 42: BuilderPendingWithdrawals { - subIndx := hh.Index() - num := uint64(len(b.PayloadAttestations)) - if num > 4 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range b.PayloadAttestations { - if err = elem.HashTreeRootWith(hh); err != nil { - return + if len(sszSlice42)%36 != 0 { + return fmt.Errorf("misaligned bytes: c.BuilderPendingWithdrawals length is %d, which is not a multiple of 36: %w", len(sszSlice42), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice42) / 36 + if numElem > 1048576 { + return fmt.Errorf("ssz-max exceeded: c.BuilderPendingWithdrawals has %d elements, ssz-max is 1048576: %w", numElem, ssz.ErrListTooBig) + } + c.BuilderPendingWithdrawals = make([]*BuilderPendingWithdrawal, numElem) + for i := 0; i < numElem; i++ { + var tmp *BuilderPendingWithdrawal + tmp = new(BuilderPendingWithdrawal) + tmpSlice := sszSlice42[i*36 : (1+i)*36] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("BuilderPendingWithdrawals: %w", err) } + c.BuilderPendingWithdrawals[i] = tmp } - hh.MerkleizeWithMixin(subIndx, num, 4) - } - - // Field (12) 'ParentExecutionRequests' - if err = b.ParentExecutionRequests.HashTreeRootWith(hh); err != nil { - return - } - - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the SignedBeaconBlockGloas object -func (s *SignedBeaconBlockGloas) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) -} - -// MarshalSSZTo ssz marshals the SignedBeaconBlockGloas object to a target array -func (s *SignedBeaconBlockGloas) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(100) - - // Offset (0) 'Block' - dst = ssz.WriteOffset(dst, offset) - if s.Block == nil { - s.Block = new(BeaconBlockGloas) - } - offset += s.Block.SizeSSZ() - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.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 SignedBeaconBlockGloas object -func (s *SignedBeaconBlockGloas) 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 43: LatestExecutionPayloadBid + c.LatestExecutionPayloadBid = new(ExecutionPayloadBid) + if err = c.LatestExecutionPayloadBid.UnmarshalSSZ(sszSlice43); err != nil { + return fmt.Errorf("LatestExecutionPayloadBid: %w", err) } - // Field (1) 'Signature' - if cap(s.Signature) == 0 { - s.Signature = make([]byte, 0, len(buf[4:100])) + // Field 44: PayloadExpectedWithdrawals + { + if len(sszSlice44)%44 != 0 { + return fmt.Errorf("misaligned bytes: c.PayloadExpectedWithdrawals length is %d, which is not a multiple of 44: %w", len(sszSlice44), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice44) / 44 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.PayloadExpectedWithdrawals has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.PayloadExpectedWithdrawals = make([]*v1.Withdrawal, numElem) + for i := 0; i < numElem; i++ { + var tmp *v1.Withdrawal + tmp = new(v1.Withdrawal) + tmpSlice := sszSlice44[i*44 : (1+i)*44] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("PayloadExpectedWithdrawals: %w", err) + } + c.PayloadExpectedWithdrawals[i] = tmp + } } - s.Signature = append(s.Signature, buf[4:100]...) - // Field (0) 'Block' + // Field 45: PtcWindow { - buf = tail[o0:] - if s.Block == nil { - s.Block = new(BeaconBlockGloas) - } - if err = s.Block.UnmarshalSSZ(buf); err != nil { - return err + c.PtcWindow = make([]*PTCs, 96) + for i := 0; i < 96; i++ { + var tmp *PTCs + tmp = new(PTCs) + tmpSlice := sszSlice45[i*4096 : (1+i)*4096] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("PtcWindow: %w", err) + } + c.PtcWindow[i] = tmp } } return err } -// SizeSSZ returns the ssz encoded size in bytes for the SignedBeaconBlockGloas object -func (s *SignedBeaconBlockGloas) SizeSSZ() (size int) { - size = 100 - - // Field (0) 'Block' - if s.Block == nil { - s.Block = new(BeaconBlockGloas) +func (c *BeaconStateGloas) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - size += s.Block.SizeSSZ() - - return + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRoot ssz hashes the SignedBeaconBlockGloas object -func (s *SignedBeaconBlockGloas) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) -} - -// HashTreeRootWith ssz hashes the SignedBeaconBlockGloas object with a hasher -func (s *SignedBeaconBlockGloas) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *BeaconStateGloas) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Block' - if err = s.Block.HashTreeRootWith(hh); err != nil { - return + // Field 0: GenesisTime + hh.PutUint64(c.GenesisTime) + // Field 1: GenesisValidatorsRoot + if len(c.GenesisValidatorsRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.GenesisValidatorsRoot) + // Field 2: Slot + if err := c.Slot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Slot: %w", err) + } + // Field 3: Fork + if err := c.Fork.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Fork: %w", err) + } + // Field 4: LatestBlockHeader + if err := c.LatestBlockHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("LatestBlockHeader: %w", err) + } + // Field 5: BlockRoots + { + if len(c.BlockRoots) != 8192 { + return ssz.ErrVectorLength + } + subIndx := hh.Index() + for _, o := range c.BlockRoots { + if len(o) != 32 { + return ssz.ErrBytesLength + } + hh.Append(o) + } + hh.Merkleize(subIndx) } - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 6: StateRoots + { + if len(c.StateRoots) != 8192 { + return ssz.ErrVectorLength + } + subIndx := hh.Index() + for _, o := range c.StateRoots { + if len(o) != 32 { + return ssz.ErrBytesLength + } + hh.Append(o) + } + hh.Merkleize(subIndx) } - hh.PutBytes(s.Signature) - - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the BeaconStateGloas object -func (b *BeaconStateGloas) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} - -// MarshalSSZTo ssz marshals the BeaconStateGloas object to a target array -func (b *BeaconStateGloas) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(3134845) - - // Field (0) 'GenesisTime' - dst = ssz.MarshalUint(dst, b.GenesisTime) - - // Field (1) 'GenesisValidatorsRoot' - if size := len(b.GenesisValidatorsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.GenesisValidatorsRoot", size, 32) - return + // Field 7: HistoricalRoots + { + if len(c.HistoricalRoots) > 16777216 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.HistoricalRoots { + if len(o) != 32 { + return ssz.ErrBytesLength + } + hh.Append(o) + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.HistoricalRoots)), 16777216) } - dst = append(dst, b.GenesisValidatorsRoot...) - - // Field (2) 'Slot' - dst = ssz.MarshalUint(dst, b.Slot) - - // Field (3) 'Fork' - if b.Fork == nil { - b.Fork = new(Fork) + // Field 8: Eth1Data + if err := c.Eth1Data.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Eth1Data: %w", err) } - if dst, err = b.Fork.MarshalSSZTo(dst); err != nil { - return + // Field 9: Eth1DataVotes + { + if len(c.Eth1DataVotes) > 2048 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.Eth1DataVotes { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Eth1DataVotes: %w", err) + } + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Eth1DataVotes)), 2048) } - - // Field (4) 'LatestBlockHeader' - if b.LatestBlockHeader == nil { - b.LatestBlockHeader = new(BeaconBlockHeader) + // Field 10: Eth1DepositIndex + hh.PutUint64(c.Eth1DepositIndex) + // Field 11: Validators + { + if len(c.Validators) > 1099511627776 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.Validators { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Validators: %w", err) + } + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Validators)), 1099511627776) } - if dst, err = b.LatestBlockHeader.MarshalSSZTo(dst); err != nil { - return + // Field 12: Balances + { + if len(c.Balances) > 1099511627776 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.Balances { + hh.AppendUint64(o) + } + hh.FillUpTo32() + numItems := uint64(len(c.Balances)) + hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(1099511627776, numItems, 8)) } - - // Field (5) 'BlockRoots' - if size := len(b.BlockRoots); size != 8192 { - err = ssz.ErrVectorLengthFn("--.BlockRoots", size, 8192) - return + // Field 13: RandaoMixes + { + if len(c.RandaoMixes) != 65536 { + return ssz.ErrVectorLength + } + subIndx := hh.Index() + for _, o := range c.RandaoMixes { + if len(o) != 32 { + return ssz.ErrBytesLength + } + hh.Append(o) + } + hh.Merkleize(subIndx) } - for ii := 0; ii < 8192; ii++ { - if size := len(b.BlockRoots[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockRoots[ii]", size, 32) - return + // Field 14: Slashings + { + if len(c.Slashings) != 8192 { + return ssz.ErrVectorLength } - dst = append(dst, b.BlockRoots[ii]...) + subIndx := hh.Index() + for _, o := range c.Slashings { + hh.AppendUint64(o) + } + hh.Merkleize(subIndx) } + // Field 15: PreviousEpochParticipation - // Field (6) 'StateRoots' - if size := len(b.StateRoots); size != 8192 { - err = ssz.ErrVectorLengthFn("--.StateRoots", size, 8192) - return - } - for ii := 0; ii < 8192; ii++ { - if size := len(b.StateRoots[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoots[ii]", size, 32) - return + { + if len(c.PreviousEpochParticipation) > 1099511627776 { + return ssz.ErrBytesLength } - dst = append(dst, b.StateRoots[ii]...) + subIndx := hh.Index() + hh.AppendBytes32(c.PreviousEpochParticipation) + numItems := uint64(len(c.PreviousEpochParticipation)) + hh.MerkleizeWithMixin(subIndx, numItems, (1099511627776*1+31)/32) } - // Offset (7) 'HistoricalRoots' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.HistoricalRoots) * 32 + // Field 16: CurrentEpochParticipation - // Field (8) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(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.MarshalUint(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("--.RandaoMixes", size, 65536) - return - } - for ii := 0; ii < 65536; ii++ { - if size := len(b.RandaoMixes[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.RandaoMixes[ii]", size, 32) - return + { + if len(c.CurrentEpochParticipation) > 1099511627776 { + return ssz.ErrBytesLength } - dst = append(dst, b.RandaoMixes[ii]...) + subIndx := hh.Index() + hh.AppendBytes32(c.CurrentEpochParticipation) + numItems := uint64(len(c.CurrentEpochParticipation)) + hh.MerkleizeWithMixin(subIndx, numItems, (1099511627776*1+31)/32) } - // Field (14) 'Slashings' - if size := len(b.Slashings); size != 8192 { - err = ssz.ErrVectorLengthFn("--.Slashings", size, 8192) - return + // Field 17: JustificationBits + if len([]byte(c.JustificationBits)) != 1 { + return ssz.ErrBytesLength } - for ii := 0; ii < 8192; ii++ { - dst = ssz.MarshalUint(dst, b.Slashings[ii]) + hh.PutBytes([]byte(c.JustificationBits)) + // Field 18: PreviousJustifiedCheckpoint + if err := c.PreviousJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("PreviousJustifiedCheckpoint: %w", err) } - - // 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' - if size := len(b.JustificationBits); size != 1 { - err = ssz.ErrBytesLengthFn("--.JustificationBits", size, 1) - return + // Field 19: CurrentJustifiedCheckpoint + if err := c.CurrentJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("CurrentJustifiedCheckpoint: %w", err) } - dst = append(dst, b.JustificationBits...) - - // Field (18) 'PreviousJustifiedCheckpoint' - if b.PreviousJustifiedCheckpoint == nil { - b.PreviousJustifiedCheckpoint = new(Checkpoint) + // Field 20: FinalizedCheckpoint + if err := c.FinalizedCheckpoint.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("FinalizedCheckpoint: %w", err) } - if dst, err = b.PreviousJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { - return + // Field 21: InactivityScores + { + if len(c.InactivityScores) > 1099511627776 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.InactivityScores { + hh.AppendUint64(o) + } + hh.FillUpTo32() + numItems := uint64(len(c.InactivityScores)) + hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(1099511627776, numItems, 8)) } - - // Field (19) 'CurrentJustifiedCheckpoint' - if b.CurrentJustifiedCheckpoint == nil { - b.CurrentJustifiedCheckpoint = new(Checkpoint) + // Field 22: CurrentSyncCommittee + if err := c.CurrentSyncCommittee.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("CurrentSyncCommittee: %w", err) } - if dst, err = b.CurrentJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { - return + // Field 23: NextSyncCommittee + if err := c.NextSyncCommittee.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("NextSyncCommittee: %w", err) } - - // Field (20) 'FinalizedCheckpoint' - if b.FinalizedCheckpoint == nil { - b.FinalizedCheckpoint = new(Checkpoint) + // Field 24: LatestBlockHash + if len(c.LatestBlockHash) != 32 { + return ssz.ErrBytesLength } - if dst, err = b.FinalizedCheckpoint.MarshalSSZTo(dst); err != nil { - return + hh.PutBytes(c.LatestBlockHash) + // Field 25: NextWithdrawalIndex + hh.PutUint64(c.NextWithdrawalIndex) + // Field 26: NextWithdrawalValidatorIndex + if err := c.NextWithdrawalValidatorIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("NextWithdrawalValidatorIndex: %w", err) } - - // Offset (21) 'InactivityScores' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.InactivityScores) * 8 - - // Field (22) 'CurrentSyncCommittee' - if b.CurrentSyncCommittee == nil { - b.CurrentSyncCommittee = new(SyncCommittee) + // Field 27: HistoricalSummaries + { + if len(c.HistoricalSummaries) > 16777216 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.HistoricalSummaries { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("HistoricalSummaries: %w", err) + } + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.HistoricalSummaries)), 16777216) } - if dst, err = b.CurrentSyncCommittee.MarshalSSZTo(dst); err != nil { - return + // Field 28: DepositRequestsStartIndex + hh.PutUint64(c.DepositRequestsStartIndex) + // Field 29: DepositBalanceToConsume + if err := c.DepositBalanceToConsume.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("DepositBalanceToConsume: %w", err) } - - // Field (23) 'NextSyncCommittee' - if b.NextSyncCommittee == nil { - b.NextSyncCommittee = new(SyncCommittee) + // Field 30: ExitBalanceToConsume + if err := c.ExitBalanceToConsume.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ExitBalanceToConsume: %w", err) } - if dst, err = b.NextSyncCommittee.MarshalSSZTo(dst); err != nil { - return + // Field 31: EarliestExitEpoch + if err := c.EarliestExitEpoch.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("EarliestExitEpoch: %w", err) } - - // Field (24) 'LatestBlockHash' - if size := len(b.LatestBlockHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.LatestBlockHash", size, 32) - return + // Field 32: ConsolidationBalanceToConsume + if err := c.ConsolidationBalanceToConsume.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ConsolidationBalanceToConsume: %w", err) } - dst = append(dst, b.LatestBlockHash...) - - // Field (25) 'NextWithdrawalIndex' - dst = ssz.MarshalUint(dst, b.NextWithdrawalIndex) - - // Field (26) 'NextWithdrawalValidatorIndex' - dst = ssz.MarshalUint(dst, b.NextWithdrawalValidatorIndex) - - // Offset (27) 'HistoricalSummaries' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.HistoricalSummaries) * 64 - - // Field (28) 'DepositRequestsStartIndex' - dst = ssz.MarshalUint(dst, b.DepositRequestsStartIndex) - - // Field (29) 'DepositBalanceToConsume' - dst = ssz.MarshalUint(dst, b.DepositBalanceToConsume) - - // Field (30) 'ExitBalanceToConsume' - dst = ssz.MarshalUint(dst, b.ExitBalanceToConsume) - - // Field (31) 'EarliestExitEpoch' - dst = ssz.MarshalUint(dst, b.EarliestExitEpoch) - - // Field (32) 'ConsolidationBalanceToConsume' - dst = ssz.MarshalUint(dst, b.ConsolidationBalanceToConsume) - - // Field (33) 'EarliestConsolidationEpoch' - dst = ssz.MarshalUint(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) - offset += len(b.PendingConsolidations) * 16 - - // Field (37) 'ProposerLookahead' - if size := len(b.ProposerLookahead); size != 64 { - err = ssz.ErrVectorLengthFn("--.ProposerLookahead", size, 64) - return + // Field 33: EarliestConsolidationEpoch + if err := c.EarliestConsolidationEpoch.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("EarliestConsolidationEpoch: %w", err) } - for ii := 0; ii < 64; ii++ { - dst = ssz.MarshalUint(dst, b.ProposerLookahead[ii]) + // Field 34: PendingDeposits + { + if len(c.PendingDeposits) > 134217728 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.PendingDeposits { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("PendingDeposits: %w", err) + } + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.PendingDeposits)), 134217728) } - - // Offset (38) 'Builders' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.Builders) * 93 - - // Field (39) 'NextWithdrawalBuilderIndex' - dst = ssz.MarshalUint(dst, b.NextWithdrawalBuilderIndex) - - // Field (40) 'ExecutionPayloadAvailability' - if size := len(b.ExecutionPayloadAvailability); size != 1024 { - err = ssz.ErrBytesLengthFn("--.ExecutionPayloadAvailability", size, 1024) - return + // Field 35: PendingPartialWithdrawals + { + if len(c.PendingPartialWithdrawals) > 134217728 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.PendingPartialWithdrawals { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("PendingPartialWithdrawals: %w", err) + } + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.PendingPartialWithdrawals)), 134217728) } - dst = append(dst, b.ExecutionPayloadAvailability...) - - // Field (41) 'BuilderPendingPayments' - if size := len(b.BuilderPendingPayments); size != 64 { - err = ssz.ErrVectorLengthFn("--.BuilderPendingPayments", size, 64) - return + // Field 36: PendingConsolidations + { + if len(c.PendingConsolidations) > 262144 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.PendingConsolidations { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("PendingConsolidations: %w", err) + } + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.PendingConsolidations)), 262144) } - for ii := 0; ii < 64; ii++ { - if dst, err = b.BuilderPendingPayments[ii].MarshalSSZTo(dst); err != nil { - return + // Field 37: ProposerLookahead + { + if len(c.ProposerLookahead) != 64 { + return ssz.ErrVectorLength + } + subIndx := hh.Index() + for _, o := range c.ProposerLookahead { + hh.AppendUint64(uint64(o)) } + hh.Merkleize(subIndx) } - - // Offset (42) 'BuilderPendingWithdrawals' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.BuilderPendingWithdrawals) * 36 - - // Offset (43) 'LatestExecutionPayloadBid' - dst = ssz.WriteOffset(dst, offset) - if b.LatestExecutionPayloadBid == nil { - b.LatestExecutionPayloadBid = new(ExecutionPayloadBid) + // Field 38: Builders + { + if len(c.Builders) > 1099511627776 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.Builders { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Builders: %w", err) + } + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Builders)), 1099511627776) } - offset += b.LatestExecutionPayloadBid.SizeSSZ() - - // Offset (44) 'PayloadExpectedWithdrawals' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.PayloadExpectedWithdrawals) * 44 - - // Field (45) 'PtcWindow' - if size := len(b.PtcWindow); size != 96 { - err = ssz.ErrVectorLengthFn("--.PtcWindow", size, 96) - return + // Field 39: NextWithdrawalBuilderIndex + if err := c.NextWithdrawalBuilderIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("NextWithdrawalBuilderIndex: %w", err) } - for ii := 0; ii < 96; ii++ { - if dst, err = b.PtcWindow[ii].MarshalSSZTo(dst); err != nil { - return - } + // Field 40: ExecutionPayloadAvailability + if len(c.ExecutionPayloadAvailability) != 1024 { + return ssz.ErrBytesLength } - - // Field (7) 'HistoricalRoots' - if size := len(b.HistoricalRoots); size > 16777216 { - err = ssz.ErrListTooBigFn("--.HistoricalRoots", size, 16777216) - return + hh.PutBytes(c.ExecutionPayloadAvailability) + // Field 41: BuilderPendingPayments + { + if len(c.BuilderPendingPayments) != 64 { + return ssz.ErrVectorLength + } + subIndx := hh.Index() + for _, o := range c.BuilderPendingPayments { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("BuilderPendingPayments: %w", err) + } + } + hh.Merkleize(subIndx) } - for ii := 0; ii < len(b.HistoricalRoots); ii++ { - if size := len(b.HistoricalRoots[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.HistoricalRoots[ii]", size, 32) - return + // Field 42: BuilderPendingWithdrawals + { + if len(c.BuilderPendingWithdrawals) > 1048576 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.BuilderPendingWithdrawals { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("BuilderPendingWithdrawals: %w", err) + } } - dst = append(dst, b.HistoricalRoots[ii]...) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.BuilderPendingWithdrawals)), 1048576) } - - // Field (9) 'Eth1DataVotes' - if size := len(b.Eth1DataVotes); size > 2048 { - err = ssz.ErrListTooBigFn("--.Eth1DataVotes", size, 2048) - return + // Field 43: LatestExecutionPayloadBid + if err := c.LatestExecutionPayloadBid.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("LatestExecutionPayloadBid: %w", err) } - for ii := 0; ii < len(b.Eth1DataVotes); ii++ { - if dst, err = b.Eth1DataVotes[ii].MarshalSSZTo(dst); err != nil { - return + // Field 44: PayloadExpectedWithdrawals + { + if len(c.PayloadExpectedWithdrawals) > 16 { + return ssz.ErrListTooBig } + subIndx := hh.Index() + for _, o := range c.PayloadExpectedWithdrawals { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("PayloadExpectedWithdrawals: %w", err) + } + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.PayloadExpectedWithdrawals)), 16) } - - // Field (11) 'Validators' - if size := len(b.Validators); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.Validators", size, 1099511627776) - return - } - for ii := 0; ii < len(b.Validators); ii++ { - if dst, err = b.Validators[ii].MarshalSSZTo(dst); err != nil { - return + // Field 45: PtcWindow + { + if len(c.PtcWindow) != 96 { + return ssz.ErrVectorLength + } + subIndx := hh.Index() + for _, o := range c.PtcWindow { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("PtcWindow: %w", err) + } } + hh.Merkleize(subIndx) } + hh.Merkleize(indx) + return nil +} - // Field (12) 'Balances' - if size := len(b.Balances); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.Balances", size, 1099511627776) - return - } - for ii := 0; ii < len(b.Balances); ii++ { - dst = ssz.MarshalUint(dst, b.Balances[ii]) +func (c *BlindedExecutionPayloadEnvelope) SizeSSZ() int { + size := 148 + if c.ExecutionRequests == nil { + c.ExecutionRequests = new(v1.ExecutionRequestsGloas) } + size += c.ExecutionRequests.SizeSSZ() + return size +} - // Field (15) 'PreviousEpochParticipation' - if size := len(b.PreviousEpochParticipation); size > 1099511627776 { - err = ssz.ErrBytesLengthFn("--.PreviousEpochParticipation", size, 1099511627776) - return - } - dst = append(dst, b.PreviousEpochParticipation...) +func (c *BlindedExecutionPayloadEnvelope) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (16) 'CurrentEpochParticipation' - if size := len(b.CurrentEpochParticipation); size > 1099511627776 { - err = ssz.ErrBytesLengthFn("--.CurrentEpochParticipation", size, 1099511627776) - return - } - dst = append(dst, b.CurrentEpochParticipation...) +func (c *BlindedExecutionPayloadEnvelope) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 148 - // Field (21) 'InactivityScores' - if size := len(b.InactivityScores); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.InactivityScores", size, 1099511627776) - return - } - for ii := 0; ii < len(b.InactivityScores); ii++ { - dst = ssz.MarshalUint(dst, b.InactivityScores[ii]) + // Field 0: BlockHash + if len(c.BlockHash) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.BlockHash...) - // Field (27) 'HistoricalSummaries' - if size := len(b.HistoricalSummaries); size > 16777216 { - err = ssz.ErrListTooBigFn("--.HistoricalSummaries", size, 16777216) - return - } - for ii := 0; ii < len(b.HistoricalSummaries); ii++ { - if dst, err = b.HistoricalSummaries[ii].MarshalSSZTo(dst); err != nil { - return - } + // Field 1: ExecutionRequests + if c.ExecutionRequests == nil { + c.ExecutionRequests = new(v1.ExecutionRequestsGloas) } + dst = ssz.WriteOffset(dst, offset) + offset += c.ExecutionRequests.SizeSSZ() - // Field (34) 'PendingDeposits' - if size := len(b.PendingDeposits); size > 134217728 { - err = ssz.ErrListTooBigFn("--.PendingDeposits", size, 134217728) - return - } - for ii := 0; ii < len(b.PendingDeposits); ii++ { - if dst, err = b.PendingDeposits[ii].MarshalSSZTo(dst); err != nil { - return - } + // Field 2: BuilderIndex + if dst, err = c.BuilderIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("BuilderIndex: %w", err) } - // Field (35) 'PendingPartialWithdrawals' - if size := len(b.PendingPartialWithdrawals); size > 134217728 { - err = ssz.ErrListTooBigFn("--.PendingPartialWithdrawals", size, 134217728) - return + // Field 3: BeaconBlockRoot + if len(c.BeaconBlockRoot) != 32 { + return nil, ssz.ErrBytesLength } - for ii := 0; ii < len(b.PendingPartialWithdrawals); ii++ { - if dst, err = b.PendingPartialWithdrawals[ii].MarshalSSZTo(dst); err != nil { - return - } + dst = append(dst, c.BeaconBlockRoot...) + + // Field 4: Slot + if dst, err = c.Slot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Slot: %w", err) } - // Field (36) 'PendingConsolidations' - if size := len(b.PendingConsolidations); size > 262144 { - err = ssz.ErrListTooBigFn("--.PendingConsolidations", size, 262144) - return + // Field 5: ParentBlockHash + if len(c.ParentBlockHash) != 32 { + return nil, ssz.ErrBytesLength } - for ii := 0; ii < len(b.PendingConsolidations); ii++ { - if dst, err = b.PendingConsolidations[ii].MarshalSSZTo(dst); err != nil { - return - } + dst = append(dst, c.ParentBlockHash...) + + // Field 6: ParentBeaconBlockRoot + if len(c.ParentBeaconBlockRoot) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.ParentBeaconBlockRoot...) - // Field (38) 'Builders' - if size := len(b.Builders); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.Builders", size, 1099511627776) - return + // Field 1: ExecutionRequests + if dst, err = c.ExecutionRequests.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ExecutionRequests: %w", err) } - for ii := 0; ii < len(b.Builders); ii++ { - if dst, err = b.Builders[ii].MarshalSSZTo(dst); err != nil { - return - } + return dst, err +} + +func (c *BlindedExecutionPayloadEnvelope) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 148 { + return ssz.ErrSize } - // Field (42) 'BuilderPendingWithdrawals' - if size := len(b.BuilderPendingWithdrawals); size > 1048576 { - err = ssz.ErrListTooBigFn("--.BuilderPendingWithdrawals", size, 1048576) - return + sszSlice0 := buf[0:32] // c.BlockHash + sszSlice2 := buf[36:44] // c.BuilderIndex + sszSlice3 := buf[44:76] // c.BeaconBlockRoot + sszSlice4 := buf[76:84] // c.Slot + sszSlice5 := buf[84:116] // c.ParentBlockHash + sszSlice6 := buf[116:148] // c.ParentBeaconBlockRoot + + sszVarOffset1 := ssz.ReadOffset(buf[32:36]) // c.ExecutionRequests + if sszVarOffset1 != 148 { + return ssz.ErrInvalidVariableOffset } - for ii := 0; ii < len(b.BuilderPendingWithdrawals); ii++ { - if dst, err = b.BuilderPendingWithdrawals[ii].MarshalSSZTo(dst); err != nil { - return - } + if sszVarOffset1 > size { + return ssz.ErrOffset } + sszSlice1 := buf[sszVarOffset1:] // c.ExecutionRequests - // Field (43) 'LatestExecutionPayloadBid' - if dst, err = b.LatestExecutionPayloadBid.MarshalSSZTo(dst); err != nil { - return + // Field 0: BlockHash + c.BlockHash = make([]byte, 0, 32) + c.BlockHash = append(c.BlockHash, sszSlice0...) + + // Field 1: ExecutionRequests + c.ExecutionRequests = new(v1.ExecutionRequestsGloas) + if err = c.ExecutionRequests.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("ExecutionRequests: %w", err) } - // Field (44) 'PayloadExpectedWithdrawals' - if size := len(b.PayloadExpectedWithdrawals); size > 16 { - err = ssz.ErrListTooBigFn("--.PayloadExpectedWithdrawals", size, 16) - return + // Field 2: BuilderIndex + if err = c.BuilderIndex.UnmarshalSSZ(sszSlice2); err != nil { + return fmt.Errorf("BuilderIndex: %w", err) } - for ii := 0; ii < len(b.PayloadExpectedWithdrawals); ii++ { - if dst, err = b.PayloadExpectedWithdrawals[ii].MarshalSSZTo(dst); err != nil { - return - } + + // Field 3: BeaconBlockRoot + c.BeaconBlockRoot = make([]byte, 0, 32) + c.BeaconBlockRoot = append(c.BeaconBlockRoot, sszSlice3...) + + // Field 4: Slot + if err = c.Slot.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("Slot: %w", err) } - return + // Field 5: ParentBlockHash + c.ParentBlockHash = make([]byte, 0, 32) + c.ParentBlockHash = append(c.ParentBlockHash, sszSlice5...) + + // Field 6: ParentBeaconBlockRoot + c.ParentBeaconBlockRoot = make([]byte, 0, 32) + c.ParentBeaconBlockRoot = append(c.ParentBeaconBlockRoot, sszSlice6...) + return err } -// UnmarshalSSZ ssz unmarshals the BeaconStateGloas object -func (b *BeaconStateGloas) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 3134845 { - return ssz.ErrSize +func (c *BlindedExecutionPayloadEnvelope) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - tail := buf - var o7, o9, o11, o12, o15, o16, o21, o27, o34, o35, o36, o38, o42, o43, o44 uint64 +func (c *BlindedExecutionPayloadEnvelope) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: BlockHash + if len(c.BlockHash) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.BlockHash) + // Field 1: ExecutionRequests + if err := c.ExecutionRequests.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ExecutionRequests: %w", err) + } + // Field 2: BuilderIndex + if err := c.BuilderIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("BuilderIndex: %w", err) + } + // Field 3: BeaconBlockRoot + if len(c.BeaconBlockRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.BeaconBlockRoot) + // Field 4: Slot + if err := c.Slot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Slot: %w", err) + } + // Field 5: ParentBlockHash + if len(c.ParentBlockHash) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ParentBlockHash) + // Field 6: ParentBeaconBlockRoot + if len(c.ParentBeaconBlockRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ParentBeaconBlockRoot) + hh.Merkleize(indx) + return nil +} - // Field (0) 'GenesisTime' - b.GenesisTime = ssz.UnmarshallUint[uint64](buf[0:8]) +func (c *Builder) SizeSSZ() int { + size := 93 - // 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]...) + return size +} - // Field (2) 'Slot' - b.Slot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[40:48]) +func (c *Builder) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (3) 'Fork' - if b.Fork == nil { - b.Fork = new(Fork) - } - if err = b.Fork.UnmarshalSSZ(buf[48:64]); err != nil { - return err - } +func (c *Builder) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (4) 'LatestBlockHeader' - if b.LatestBlockHeader == nil { - b.LatestBlockHeader = new(BeaconBlockHeader) - } - if err = b.LatestBlockHeader.UnmarshalSSZ(buf[64:176]); err != nil { - return err + // Field 0: Pubkey + if len(c.Pubkey) != 48 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.Pubkey...) - // Field (5) 'BlockRoots' - b.BlockRoots = make([][]byte, 8192) - for ii := 0; ii < 8192; ii++ { - if cap(b.BlockRoots[ii]) == 0 { - b.BlockRoots[ii] = make([]byte, 0, len(buf[176:262320][ii*32:(ii+1)*32])) - } - b.BlockRoots[ii] = append(b.BlockRoots[ii], buf[176:262320][ii*32:(ii+1)*32]...) + // Field 1: Version + if len(c.Version) != 1 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.Version...) - // Field (6) 'StateRoots' - b.StateRoots = make([][]byte, 8192) - for ii := 0; ii < 8192; ii++ { - if cap(b.StateRoots[ii]) == 0 { - b.StateRoots[ii] = make([]byte, 0, len(buf[262320:524464][ii*32:(ii+1)*32])) - } - b.StateRoots[ii] = append(b.StateRoots[ii], buf[262320:524464][ii*32:(ii+1)*32]...) + // Field 2: ExecutionAddress + if len(c.ExecutionAddress) != 20 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.ExecutionAddress...) - // Offset (7) 'HistoricalRoots' - if o7 = ssz.ReadOffset(buf[524464:524468]); o7 > size { - return ssz.ErrOffset + // Field 3: Balance + if dst, err = c.Balance.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Balance: %w", err) } - if o7 != 3134845 { - return ssz.ErrInvalidVariableOffset + // Field 4: DepositEpoch + if dst, err = c.DepositEpoch.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("DepositEpoch: %w", err) } - // Field (8) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(Eth1Data) - } - if err = b.Eth1Data.UnmarshalSSZ(buf[524468:524540]); err != nil { - return err + // Field 5: WithdrawableEpoch + if dst, err = c.WithdrawableEpoch.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("WithdrawableEpoch: %w", err) } - // Offset (9) 'Eth1DataVotes' - if o9 = ssz.ReadOffset(buf[524540:524544]); o9 > size || o7 > o9 { - return ssz.ErrOffset + return dst, err +} + +func (c *Builder) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 93 { + return ssz.ErrSize } - // Field (10) 'Eth1DepositIndex' - b.Eth1DepositIndex = ssz.UnmarshallUint[uint64](buf[524544:524552]) + sszSlice0 := buf[0:48] // c.Pubkey + sszSlice1 := buf[48:49] // c.Version + sszSlice2 := buf[49:69] // c.ExecutionAddress + sszSlice3 := buf[69:77] // c.Balance + sszSlice4 := buf[77:85] // c.DepositEpoch + sszSlice5 := buf[85:93] // c.WithdrawableEpoch - // Offset (11) 'Validators' - if o11 = ssz.ReadOffset(buf[524552:524556]); o11 > size || o9 > o11 { - return ssz.ErrOffset - } + // Field 0: Pubkey + c.Pubkey = make([]byte, 0, 48) + c.Pubkey = append(c.Pubkey, sszSlice0...) - // Offset (12) 'Balances' - if o12 = ssz.ReadOffset(buf[524556:524560]); o12 > size || o11 > o12 { - return ssz.ErrOffset - } + // Field 1: Version + c.Version = make([]byte, 0, 1) + c.Version = append(c.Version, sszSlice1...) - // 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 2: ExecutionAddress + c.ExecutionAddress = make([]byte, 0, 20) + c.ExecutionAddress = append(c.ExecutionAddress, sszSlice2...) - // Field (14) 'Slashings' - b.Slashings = ssz.ExtendUint(b.Slashings, 8192) - for ii := 0; ii < 8192; ii++ { - b.Slashings[ii] = ssz.UnmarshallUint[uint64](buf[2621712:2687248][ii*8 : (ii+1)*8]) + // Field 3: Balance + if err = c.Balance.UnmarshalSSZ(sszSlice3); err != nil { + return fmt.Errorf("Balance: %w", err) } - // Offset (15) 'PreviousEpochParticipation' - if o15 = ssz.ReadOffset(buf[2687248:2687252]); o15 > size || o12 > o15 { - return ssz.ErrOffset + // Field 4: DepositEpoch + if err = c.DepositEpoch.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("DepositEpoch: %w", err) } - // Offset (16) 'CurrentEpochParticipation' - if o16 = ssz.ReadOffset(buf[2687252:2687256]); o16 > size || o15 > o16 { - return ssz.ErrOffset + // Field 5: WithdrawableEpoch + if err = c.WithdrawableEpoch.UnmarshalSSZ(sszSlice5); err != nil { + return fmt.Errorf("WithdrawableEpoch: %w", err) } + return err +} - // Field (17) 'JustificationBits' - if cap(b.JustificationBits) == 0 { - b.JustificationBits = make([]byte, 0, len(buf[2687256:2687257])) +func (c *Builder) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - b.JustificationBits = append(b.JustificationBits, buf[2687256:2687257]...) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (18) 'PreviousJustifiedCheckpoint' - if b.PreviousJustifiedCheckpoint == nil { - b.PreviousJustifiedCheckpoint = new(Checkpoint) +func (c *Builder) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Pubkey + if len(c.Pubkey) != 48 { + return ssz.ErrBytesLength } - if err = b.PreviousJustifiedCheckpoint.UnmarshalSSZ(buf[2687257:2687297]); err != nil { - return err + hh.PutBytes(c.Pubkey) + // Field 1: Version + if len(c.Version) != 1 { + return ssz.ErrBytesLength } - - // Field (19) 'CurrentJustifiedCheckpoint' - if b.CurrentJustifiedCheckpoint == nil { - b.CurrentJustifiedCheckpoint = new(Checkpoint) + hh.PutBytes(c.Version) + // Field 2: ExecutionAddress + if len(c.ExecutionAddress) != 20 { + return ssz.ErrBytesLength } - if err = b.CurrentJustifiedCheckpoint.UnmarshalSSZ(buf[2687297:2687337]); err != nil { - return err + hh.PutBytes(c.ExecutionAddress) + // Field 3: Balance + if err := c.Balance.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Balance: %w", err) } - - // Field (20) 'FinalizedCheckpoint' - if b.FinalizedCheckpoint == nil { - b.FinalizedCheckpoint = new(Checkpoint) + // Field 4: DepositEpoch + if err := c.DepositEpoch.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("DepositEpoch: %w", err) } - if err = b.FinalizedCheckpoint.UnmarshalSSZ(buf[2687337:2687377]); err != nil { - return err + // Field 5: WithdrawableEpoch + if err := c.WithdrawableEpoch.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("WithdrawableEpoch: %w", err) } + hh.Merkleize(indx) + return nil +} - // Offset (21) 'InactivityScores' - if o21 = ssz.ReadOffset(buf[2687377:2687381]); o21 > size || o16 > o21 { - return ssz.ErrOffset - } +func (c *BuilderPendingPayment) SizeSSZ() int { + size := 52 - // Field (22) 'CurrentSyncCommittee' - if b.CurrentSyncCommittee == nil { - b.CurrentSyncCommittee = new(SyncCommittee) - } - if err = b.CurrentSyncCommittee.UnmarshalSSZ(buf[2687381:2712005]); err != nil { - return err + return size +} + +func (c *BuilderPendingPayment) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} + +func (c *BuilderPendingPayment) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + + // Field 0: Weight + if dst, err = c.Weight.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Weight: %w", err) } - // Field (23) 'NextSyncCommittee' - if b.NextSyncCommittee == nil { - b.NextSyncCommittee = new(SyncCommittee) + // Field 1: Withdrawal + if c.Withdrawal == nil { + c.Withdrawal = new(BuilderPendingWithdrawal) } - if err = b.NextSyncCommittee.UnmarshalSSZ(buf[2712005:2736629]); err != nil { - return err + if dst, err = c.Withdrawal.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Withdrawal: %w", err) } - // Field (24) 'LatestBlockHash' - if cap(b.LatestBlockHash) == 0 { - b.LatestBlockHash = make([]byte, 0, len(buf[2736629:2736661])) + // Field 2: ProposerIndex + if dst, err = c.ProposerIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ProposerIndex: %w", err) } - b.LatestBlockHash = append(b.LatestBlockHash, buf[2736629:2736661]...) - // Field (25) 'NextWithdrawalIndex' - b.NextWithdrawalIndex = ssz.UnmarshallUint[uint64](buf[2736661:2736669]) + return dst, err +} + +func (c *BuilderPendingPayment) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 52 { + return ssz.ErrSize + } - // Field (26) 'NextWithdrawalValidatorIndex' - b.NextWithdrawalValidatorIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[2736669:2736677]) + sszSlice0 := buf[0:8] // c.Weight + sszSlice1 := buf[8:44] // c.Withdrawal + sszSlice2 := buf[44:52] // c.ProposerIndex - // Offset (27) 'HistoricalSummaries' - if o27 = ssz.ReadOffset(buf[2736677:2736681]); o27 > size || o21 > o27 { - return ssz.ErrOffset + // Field 0: Weight + if err = c.Weight.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Weight: %w", err) } - // Field (28) 'DepositRequestsStartIndex' - b.DepositRequestsStartIndex = ssz.UnmarshallUint[uint64](buf[2736681:2736689]) + // Field 1: Withdrawal + c.Withdrawal = new(BuilderPendingWithdrawal) + if err = c.Withdrawal.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Withdrawal: %w", err) + } - // Field (29) 'DepositBalanceToConsume' - b.DepositBalanceToConsume = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Gwei](buf[2736689:2736697]) + // Field 2: ProposerIndex + if err = c.ProposerIndex.UnmarshalSSZ(sszSlice2); err != nil { + return fmt.Errorf("ProposerIndex: %w", err) + } + return err +} - // Field (30) 'ExitBalanceToConsume' - b.ExitBalanceToConsume = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Gwei](buf[2736697:2736705]) +func (c *BuilderPendingPayment) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (31) 'EarliestExitEpoch' - b.EarliestExitEpoch = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Epoch](buf[2736705:2736713]) +func (c *BuilderPendingPayment) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Weight + if err := c.Weight.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Weight: %w", err) + } + // Field 1: Withdrawal + if err := c.Withdrawal.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Withdrawal: %w", err) + } + // Field 2: ProposerIndex + if err := c.ProposerIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ProposerIndex: %w", err) + } + hh.Merkleize(indx) + return nil +} - // Field (32) 'ConsolidationBalanceToConsume' - b.ConsolidationBalanceToConsume = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Gwei](buf[2736713:2736721]) +func (c *BuilderPendingWithdrawal) SizeSSZ() int { + size := 36 - // Field (33) 'EarliestConsolidationEpoch' - b.EarliestConsolidationEpoch = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Epoch](buf[2736721:2736729]) + return size +} - // Offset (34) 'PendingDeposits' - if o34 = ssz.ReadOffset(buf[2736729:2736733]); o34 > size || o27 > o34 { - return ssz.ErrOffset - } +func (c *BuilderPendingWithdrawal) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Offset (35) 'PendingPartialWithdrawals' - if o35 = ssz.ReadOffset(buf[2736733:2736737]); o35 > size || o34 > o35 { - return ssz.ErrOffset - } +func (c *BuilderPendingWithdrawal) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Offset (36) 'PendingConsolidations' - if o36 = ssz.ReadOffset(buf[2736737:2736741]); o36 > size || o35 > o36 { - return ssz.ErrOffset + // Field 0: FeeRecipient + if len(c.FeeRecipient) != 20 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.FeeRecipient...) - // Field (37) 'ProposerLookahead' - b.ProposerLookahead = ssz.ExtendUint(b.ProposerLookahead, 64) - for ii := 0; ii < 64; ii++ { - b.ProposerLookahead[ii] = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[2736741:2737253][ii*8 : (ii+1)*8]) + // Field 1: Amount + if dst, err = c.Amount.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Amount: %w", err) } - // Offset (38) 'Builders' - if o38 = ssz.ReadOffset(buf[2737253:2737257]); o38 > size || o36 > o38 { - return ssz.ErrOffset + // Field 2: BuilderIndex + if dst, err = c.BuilderIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("BuilderIndex: %w", err) } - // Field (39) 'NextWithdrawalBuilderIndex' - b.NextWithdrawalBuilderIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.BuilderIndex](buf[2737257:2737265]) + return dst, err +} - // Field (40) 'ExecutionPayloadAvailability' - if cap(b.ExecutionPayloadAvailability) == 0 { - b.ExecutionPayloadAvailability = make([]byte, 0, len(buf[2737265:2738289])) +func (c *BuilderPendingWithdrawal) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 36 { + return ssz.ErrSize } - b.ExecutionPayloadAvailability = append(b.ExecutionPayloadAvailability, buf[2737265:2738289]...) - // Field (41) 'BuilderPendingPayments' - b.BuilderPendingPayments = make([]*BuilderPendingPayment, 64) - for ii := 0; ii < 64; ii++ { - if b.BuilderPendingPayments[ii] == nil { - b.BuilderPendingPayments[ii] = new(BuilderPendingPayment) - } - if err = b.BuilderPendingPayments[ii].UnmarshalSSZ(buf[2738289:2741617][ii*52 : (ii+1)*52]); err != nil { - return err - } - } + sszSlice0 := buf[0:20] // c.FeeRecipient + sszSlice1 := buf[20:28] // c.Amount + sszSlice2 := buf[28:36] // c.BuilderIndex - // Offset (42) 'BuilderPendingWithdrawals' - if o42 = ssz.ReadOffset(buf[2741617:2741621]); o42 > size || o38 > o42 { - return ssz.ErrOffset - } + // Field 0: FeeRecipient + c.FeeRecipient = make([]byte, 0, 20) + c.FeeRecipient = append(c.FeeRecipient, sszSlice0...) - // Offset (43) 'LatestExecutionPayloadBid' - if o43 = ssz.ReadOffset(buf[2741621:2741625]); o43 > size || o42 > o43 { - return ssz.ErrOffset + // Field 1: Amount + if err = c.Amount.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Amount: %w", err) } - // Offset (44) 'PayloadExpectedWithdrawals' - if o44 = ssz.ReadOffset(buf[2741625:2741629]); o44 > size || o43 > o44 { - return ssz.ErrOffset + // Field 2: BuilderIndex + if err = c.BuilderIndex.UnmarshalSSZ(sszSlice2); err != nil { + return fmt.Errorf("BuilderIndex: %w", err) } + return err +} - // Field (45) 'PtcWindow' - b.PtcWindow = make([]*PTCs, 96) - for ii := 0; ii < 96; ii++ { - if b.PtcWindow[ii] == nil { - b.PtcWindow[ii] = new(PTCs) - } - if err = b.PtcWindow[ii].UnmarshalSSZ(buf[2741629:3134845][ii*4096 : (ii+1)*4096]); err != nil { - return err - } +func (c *BuilderPendingWithdrawal) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // 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]...) - } +func (c *BuilderPendingWithdrawal) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: FeeRecipient + if len(c.FeeRecipient) != 20 { + return ssz.ErrBytesLength } - - // Field (9) 'Eth1DataVotes' - { - buf = tail[o9:o11] - num, err := ssz.DivideInt2(len(buf), 72, 2048) - if err != nil { - return err - } - b.Eth1DataVotes = make([]*Eth1Data, num) - for ii := 0; ii < num; ii++ { - if b.Eth1DataVotes[ii] == nil { - b.Eth1DataVotes[ii] = new(Eth1Data) - } - if err = b.Eth1DataVotes[ii].UnmarshalSSZ(buf[ii*72 : (ii+1)*72]); err != nil { - return err - } - } + hh.PutBytes(c.FeeRecipient) + // Field 1: Amount + if err := c.Amount.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Amount: %w", err) } - - // Field (11) 'Validators' - { - buf = tail[o11:o12] - num, err := ssz.DivideInt2(len(buf), 121, 1099511627776) - if err != nil { - return err - } - b.Validators = make([]*Validator, num) - for ii := 0; ii < num; ii++ { - if b.Validators[ii] == nil { - b.Validators[ii] = new(Validator) - } - if err = b.Validators[ii].UnmarshalSSZ(buf[ii*121 : (ii+1)*121]); err != nil { - return err - } - } + // Field 2: BuilderIndex + if err := c.BuilderIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("BuilderIndex: %w", err) } + hh.Merkleize(indx) + return nil +} - // Field (12) 'Balances' - { - buf = tail[o12:o15] - num, err := ssz.DivideInt2(len(buf), 8, 1099511627776) - if err != nil { - return err - } - b.Balances = ssz.ExtendUint(b.Balances, num) - for ii := 0; ii < num; ii++ { - b.Balances[ii] = ssz.UnmarshallUint[uint64](buf[ii*8 : (ii+1)*8]) - } +func (c *BuilderPreferencesRequestV1) SizeSSZ() int { + size := 12 + if c.Auth == nil { + c.Auth = new(SignedRequestAuthV1) } + size += c.Auth.SizeSSZ() + return size +} - // 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...) - } +func (c *BuilderPreferencesRequestV1) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // 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...) - } +func (c *BuilderPreferencesRequestV1) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 12 - // Field (21) 'InactivityScores' - { - buf = tail[o21:o27] - num, err := ssz.DivideInt2(len(buf), 8, 1099511627776) - if err != nil { - return err - } - b.InactivityScores = ssz.ExtendUint(b.InactivityScores, num) - for ii := 0; ii < num; ii++ { - b.InactivityScores[ii] = ssz.UnmarshallUint[uint64](buf[ii*8 : (ii+1)*8]) - } + // Field 0: Preferences + if c.Preferences == nil { + c.Preferences = new(BuilderPreferencesV1) } - - // Field (27) 'HistoricalSummaries' - { - buf = tail[o27:o34] - num, err := ssz.DivideInt2(len(buf), 64, 16777216) - if err != nil { - return err - } - b.HistoricalSummaries = make([]*HistoricalSummary, num) - for ii := 0; ii < num; ii++ { - if b.HistoricalSummaries[ii] == nil { - b.HistoricalSummaries[ii] = new(HistoricalSummary) - } - if err = b.HistoricalSummaries[ii].UnmarshalSSZ(buf[ii*64 : (ii+1)*64]); err != nil { - return err - } - } + if dst, err = c.Preferences.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Preferences: %w", err) } - // Field (34) 'PendingDeposits' - { - buf = tail[o34:o35] - num, err := ssz.DivideInt2(len(buf), 192, 134217728) - if err != nil { - return err - } - b.PendingDeposits = make([]*PendingDeposit, num) - for ii := 0; ii < num; ii++ { - if b.PendingDeposits[ii] == nil { - b.PendingDeposits[ii] = new(PendingDeposit) - } - if err = b.PendingDeposits[ii].UnmarshalSSZ(buf[ii*192 : (ii+1)*192]); err != nil { - return err - } - } + // Field 1: Auth + if c.Auth == nil { + c.Auth = new(SignedRequestAuthV1) } + dst = ssz.WriteOffset(dst, offset) + offset += c.Auth.SizeSSZ() - // Field (35) 'PendingPartialWithdrawals' - { - buf = tail[o35:o36] - num, err := ssz.DivideInt2(len(buf), 24, 134217728) - if err != nil { - return err - } - b.PendingPartialWithdrawals = make([]*PendingPartialWithdrawal, num) - for ii := 0; ii < num; ii++ { - if b.PendingPartialWithdrawals[ii] == nil { - b.PendingPartialWithdrawals[ii] = new(PendingPartialWithdrawal) - } - if err = b.PendingPartialWithdrawals[ii].UnmarshalSSZ(buf[ii*24 : (ii+1)*24]); err != nil { - return err - } - } + // Field 1: Auth + if dst, err = c.Auth.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Auth: %w", err) } + return dst, err +} - // Field (36) 'PendingConsolidations' - { - buf = tail[o36:o38] - num, err := ssz.DivideInt2(len(buf), 16, 262144) - if err != nil { - return err - } - b.PendingConsolidations = make([]*PendingConsolidation, num) - for ii := 0; ii < num; ii++ { - if b.PendingConsolidations[ii] == nil { - b.PendingConsolidations[ii] = new(PendingConsolidation) - } - if err = b.PendingConsolidations[ii].UnmarshalSSZ(buf[ii*16 : (ii+1)*16]); err != nil { - return err - } - } +func (c *BuilderPreferencesRequestV1) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 12 { + return ssz.ErrSize } - // Field (38) 'Builders' - { - buf = tail[o38:o42] - num, err := ssz.DivideInt2(len(buf), 93, 1099511627776) - if err != nil { - return err - } - b.Builders = make([]*Builder, num) - for ii := 0; ii < num; ii++ { - if b.Builders[ii] == nil { - b.Builders[ii] = new(Builder) - } - if err = b.Builders[ii].UnmarshalSSZ(buf[ii*93 : (ii+1)*93]); err != nil { - return err - } - } - } + sszSlice0 := buf[0:8] // c.Preferences - // Field (42) 'BuilderPendingWithdrawals' - { - buf = tail[o42:o43] - num, err := ssz.DivideInt2(len(buf), 36, 1048576) - if err != nil { - return err - } - b.BuilderPendingWithdrawals = make([]*BuilderPendingWithdrawal, num) - for ii := 0; ii < num; ii++ { - if b.BuilderPendingWithdrawals[ii] == nil { - b.BuilderPendingWithdrawals[ii] = new(BuilderPendingWithdrawal) - } - if err = b.BuilderPendingWithdrawals[ii].UnmarshalSSZ(buf[ii*36 : (ii+1)*36]); err != nil { - return err - } - } + sszVarOffset1 := ssz.ReadOffset(buf[8:12]) // c.Auth + if sszVarOffset1 != 12 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset1 > size { + return ssz.ErrOffset } + sszSlice1 := buf[sszVarOffset1:] // c.Auth - // Field (43) 'LatestExecutionPayloadBid' - { - buf = tail[o43:o44] - if b.LatestExecutionPayloadBid == nil { - b.LatestExecutionPayloadBid = new(ExecutionPayloadBid) - } - if err = b.LatestExecutionPayloadBid.UnmarshalSSZ(buf); err != nil { - return err - } + // Field 0: Preferences + c.Preferences = new(BuilderPreferencesV1) + if err = c.Preferences.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Preferences: %w", err) } - // Field (44) 'PayloadExpectedWithdrawals' - { - buf = tail[o44:] - num, err := ssz.DivideInt2(len(buf), 44, 16) - if err != nil { - return err - } - b.PayloadExpectedWithdrawals = make([]*v1.Withdrawal, num) - for ii := 0; ii < num; ii++ { - if b.PayloadExpectedWithdrawals[ii] == nil { - b.PayloadExpectedWithdrawals[ii] = new(v1.Withdrawal) - } - if err = b.PayloadExpectedWithdrawals[ii].UnmarshalSSZ(buf[ii*44 : (ii+1)*44]); err != nil { - return err - } - } + // Field 1: Auth + c.Auth = new(SignedRequestAuthV1) + if err = c.Auth.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Auth: %w", err) } return err } -// SizeSSZ returns the ssz encoded size in bytes for the BeaconStateGloas object -func (b *BeaconStateGloas) SizeSSZ() (size int) { - size = 3134845 - - // Field (7) 'HistoricalRoots' - size += len(b.HistoricalRoots) * 32 - - // Field (9) 'Eth1DataVotes' - size += len(b.Eth1DataVotes) * 72 - - // Field (11) 'Validators' - size += len(b.Validators) * 121 +func (c *BuilderPreferencesRequestV1) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (12) 'Balances' - size += len(b.Balances) * 8 +func (c *BuilderPreferencesRequestV1) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Preferences + if err := c.Preferences.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Preferences: %w", err) + } + // Field 1: Auth + if err := c.Auth.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Auth: %w", err) + } + hh.Merkleize(indx) + return nil +} - // Field (15) 'PreviousEpochParticipation' - size += len(b.PreviousEpochParticipation) +func (c *BuilderPreferencesV1) SizeSSZ() int { + size := 8 - // Field (16) 'CurrentEpochParticipation' - size += len(b.CurrentEpochParticipation) + return size +} - // Field (21) 'InactivityScores' - size += len(b.InactivityScores) * 8 +func (c *BuilderPreferencesV1) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (27) 'HistoricalSummaries' - size += len(b.HistoricalSummaries) * 64 +func (c *BuilderPreferencesV1) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (34) 'PendingDeposits' - size += len(b.PendingDeposits) * 192 + // Field 0: MaxExecutionPayment + if dst, err = c.MaxExecutionPayment.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("MaxExecutionPayment: %w", err) + } - // Field (35) 'PendingPartialWithdrawals' - size += len(b.PendingPartialWithdrawals) * 24 + return dst, err +} - // Field (36) 'PendingConsolidations' - size += len(b.PendingConsolidations) * 16 +func (c *BuilderPreferencesV1) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 8 { + return ssz.ErrSize + } - // Field (38) 'Builders' - size += len(b.Builders) * 93 + sszSlice0 := buf[0:8] // c.MaxExecutionPayment - // Field (42) 'BuilderPendingWithdrawals' - size += len(b.BuilderPendingWithdrawals) * 36 + // Field 0: MaxExecutionPayment + if err = c.MaxExecutionPayment.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("MaxExecutionPayment: %w", err) + } + return err +} - // Field (43) 'LatestExecutionPayloadBid' - if b.LatestExecutionPayloadBid == nil { - b.LatestExecutionPayloadBid = new(ExecutionPayloadBid) +func (c *BuilderPreferencesV1) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - size += b.LatestExecutionPayloadBid.SizeSSZ() + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (44) 'PayloadExpectedWithdrawals' - size += len(b.PayloadExpectedWithdrawals) * 44 +func (c *BuilderPreferencesV1) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: MaxExecutionPayment + if err := c.MaxExecutionPayment.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("MaxExecutionPayment: %w", err) + } + hh.Merkleize(indx) + return nil +} - return +func (c *DataColumnSidecarGloas) SizeSSZ() int { + size := 56 + size += len(c.Column) * 2048 + size += len(c.KzgProofs) * 48 + return size } -// HashTreeRoot ssz hashes the BeaconStateGloas object -func (b *BeaconStateGloas) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) +func (c *DataColumnSidecarGloas) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// HashTreeRootWith ssz hashes the BeaconStateGloas object with a hasher -func (b *BeaconStateGloas) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() +func (c *DataColumnSidecarGloas) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 56 - // Field (0) 'GenesisTime' - ssz.PutUint(hh, b.GenesisTime) + // Field 0: Index + dst = binary.LittleEndian.AppendUint64(dst, c.Index) - // Field (1) 'GenesisValidatorsRoot' - if size := len(b.GenesisValidatorsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.GenesisValidatorsRoot", size, 32) - return - } - hh.PutBytes(b.GenesisValidatorsRoot) + // Field 1: Column + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Column) * 2048 - // Field (2) 'Slot' - ssz.PutUint(hh, b.Slot) + // Field 2: KzgProofs + dst = ssz.WriteOffset(dst, offset) + offset += len(c.KzgProofs) * 48 - // Field (3) 'Fork' - if err = b.Fork.HashTreeRootWith(hh); err != nil { - return + // Field 3: Slot + if dst, err = c.Slot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Slot: %w", err) } - // Field (4) 'LatestBlockHeader' - if err = b.LatestBlockHeader.HashTreeRootWith(hh); err != nil { - return + // Field 4: BeaconBlockRoot + if len(c.BeaconBlockRoot) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.BeaconBlockRoot...) - // Field (5) 'BlockRoots' - { - if size := len(b.BlockRoots); size != 8192 { - err = ssz.ErrVectorLengthFn("--.BlockRoots", size, 8192) - return - } - subIndx := hh.Index() - for _, i := range b.BlockRoots { - if len(i) != 32 { - err = ssz.ErrBytesLength - return - } - hh.Append(i) - } - hh.Merkleize(subIndx) + // Field 1: Column + if len(c.Column) > 4096 { + return nil, ssz.ErrListTooBig } - - // Field (6) 'StateRoots' - { - if size := len(b.StateRoots); size != 8192 { - err = ssz.ErrVectorLengthFn("--.StateRoots", size, 8192) - return - } - subIndx := hh.Index() - for _, i := range b.StateRoots { - if len(i) != 32 { - err = ssz.ErrBytesLength - return - } - hh.Append(i) + for _, o := range c.Column { + if len(o) != 2048 { + return nil, ssz.ErrBytesLength } - hh.Merkleize(subIndx) + dst = append(dst, o...) } - // Field (7) 'HistoricalRoots' - { - if size := len(b.HistoricalRoots); size > 16777216 { - err = ssz.ErrListTooBigFn("--.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 2: KzgProofs + if len(c.KzgProofs) > 4096 { + return nil, ssz.ErrListTooBig } - - // Field (8) '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 - } + for _, o := range c.KzgProofs { + if len(o) != 48 { + return nil, ssz.ErrBytesLength } - hh.MerkleizeWithMixin(subIndx, num, 2048) + dst = append(dst, o...) } + return dst, err +} - // Field (10) 'Eth1DepositIndex' - ssz.PutUint(hh, 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) +func (c *DataColumnSidecarGloas) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 56 { + return ssz.ErrSize } - // Field (12) 'Balances' - { - if size := len(b.Balances); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.Balances", size, 1099511627776) - return - } - subIndx := hh.Index() - for _, i := range b.Balances { - ssz.AppendUint(hh, i) - } - hh.FillUpTo32() + sszSlice0 := buf[0:8] // c.Index + sszSlice3 := buf[16:24] // c.Slot + sszSlice4 := buf[24:56] // c.BeaconBlockRoot - numItems := uint64(len(b.Balances)) - hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(1099511627776, numItems, 8)) + sszVarOffset1 := ssz.ReadOffset(buf[8:12]) // c.Column + if sszVarOffset1 != 56 { + return ssz.ErrInvalidVariableOffset } - - // Field (13) 'RandaoMixes' - { - if size := len(b.RandaoMixes); size != 65536 { - err = ssz.ErrVectorLengthFn("--.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) + if sszVarOffset1 > size { + return ssz.ErrOffset } + sszVarOffset2 := ssz.ReadOffset(buf[12:16]) // c.KzgProofs + if sszVarOffset2 > size || sszVarOffset2 < sszVarOffset1 { + return ssz.ErrOffset + } + sszSlice1 := buf[sszVarOffset1:sszVarOffset2] // c.Column + sszSlice2 := buf[sszVarOffset2:] // c.KzgProofs - // Field (14) 'Slashings' + // Field 0: Index + c.Index = binary.LittleEndian.Uint64(sszSlice0) + + // Field 1: Column { - if size := len(b.Slashings); size != 8192 { - err = ssz.ErrVectorLengthFn("--.Slashings", size, 8192) - return + if len(sszSlice1)%2048 != 0 { + return fmt.Errorf("misaligned bytes: c.Column length is %d, which is not a multiple of 2048: %w", len(sszSlice1), ssz.ErrIncorrectListSize) } - subIndx := hh.Index() - for _, i := range b.Slashings { - ssz.AppendUint(hh, i) + numElem := len(sszSlice1) / 2048 + if numElem > 4096 { + return fmt.Errorf("ssz-max exceeded: c.Column has %d elements, ssz-max is 4096: %w", numElem, ssz.ErrListTooBig) } - hh.Merkleize(subIndx) - } + c.Column = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte - // Field (15) 'PreviousEpochParticipation' - { - elemIndx := hh.Index() - byteLen := uint64(len(b.PreviousEpochParticipation)) - if byteLen > 1099511627776 { - err = ssz.ErrIncorrectListSize - return + tmpSlice := sszSlice1[i*2048 : (1+i)*2048] + tmp = make([]byte, 0, 2048) + tmp = append(tmp, tmpSlice...) + c.Column[i] = tmp } - hh.AppendBytes32(b.PreviousEpochParticipation) - hh.MerkleizeWithMixin(elemIndx, byteLen, (1099511627776+31)/32) } - // Field (16) 'CurrentEpochParticipation' + // Field 2: KzgProofs { - elemIndx := hh.Index() - byteLen := uint64(len(b.CurrentEpochParticipation)) - if byteLen > 1099511627776 { - err = ssz.ErrIncorrectListSize - return + if len(sszSlice2)%48 != 0 { + return fmt.Errorf("misaligned bytes: c.KzgProofs length is %d, which is not a multiple of 48: %w", len(sszSlice2), ssz.ErrIncorrectListSize) } - hh.AppendBytes32(b.CurrentEpochParticipation) - hh.MerkleizeWithMixin(elemIndx, byteLen, (1099511627776+31)/32) - } + numElem := len(sszSlice2) / 48 + if numElem > 4096 { + return fmt.Errorf("ssz-max exceeded: c.KzgProofs has %d elements, ssz-max is 4096: %w", numElem, ssz.ErrListTooBig) + } + c.KzgProofs = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte - // Field (17) 'JustificationBits' - if size := len(b.JustificationBits); size != 1 { - err = ssz.ErrBytesLengthFn("--.JustificationBits", size, 1) - return + tmpSlice := sszSlice2[i*48 : (1+i)*48] + tmp = make([]byte, 0, 48) + tmp = append(tmp, tmpSlice...) + c.KzgProofs[i] = tmp + } } - hh.PutBytes(b.JustificationBits) - // Field (18) 'PreviousJustifiedCheckpoint' - if err = b.PreviousJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { - return + // Field 3: Slot + if err = c.Slot.UnmarshalSSZ(sszSlice3); err != nil { + return fmt.Errorf("Slot: %w", err) } - // Field (19) 'CurrentJustifiedCheckpoint' - if err = b.CurrentJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { - return - } + // Field 4: BeaconBlockRoot + c.BeaconBlockRoot = make([]byte, 0, 32) + c.BeaconBlockRoot = append(c.BeaconBlockRoot, sszSlice4...) + return err +} - // Field (20) 'FinalizedCheckpoint' - if err = b.FinalizedCheckpoint.HashTreeRootWith(hh); err != nil { - return +func (c *DataColumnSidecarGloas) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (21) 'InactivityScores' +func (c *DataColumnSidecarGloas) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Index + hh.PutUint64(c.Index) + // Field 1: Column { - if size := len(b.InactivityScores); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.InactivityScores", size, 1099511627776) - return + if len(c.Column) > 4096 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range b.InactivityScores { - ssz.AppendUint(hh, i) + for _, o := range c.Column { + if len(o) != 2048 { + return ssz.ErrBytesLength + } + hh.PutBytes(o) } - hh.FillUpTo32() - - numItems := uint64(len(b.InactivityScores)) - hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(1099511627776, numItems, 8)) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Column)), 4096) } - - // Field (22) 'CurrentSyncCommittee' - if err = b.CurrentSyncCommittee.HashTreeRootWith(hh); err != nil { - return - } - - // Field (23) 'NextSyncCommittee' - if err = b.NextSyncCommittee.HashTreeRootWith(hh); err != nil { - return - } - - // Field (24) 'LatestBlockHash' - if size := len(b.LatestBlockHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.LatestBlockHash", size, 32) - return - } - hh.PutBytes(b.LatestBlockHash) - - // Field (25) 'NextWithdrawalIndex' - ssz.PutUint(hh, b.NextWithdrawalIndex) - - // Field (26) 'NextWithdrawalValidatorIndex' - ssz.PutUint(hh, b.NextWithdrawalValidatorIndex) - - // Field (27) 'HistoricalSummaries' + // Field 2: KzgProofs { + if len(c.KzgProofs) > 4096 { + return ssz.ErrListTooBig + } 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 + for _, o := range c.KzgProofs { + if len(o) != 48 { + return ssz.ErrBytesLength } + hh.PutBytes(o) } - hh.MerkleizeWithMixin(subIndx, num, 16777216) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.KzgProofs)), 4096) } + // Field 3: Slot + if err := c.Slot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Slot: %w", err) + } + // Field 4: BeaconBlockRoot + if len(c.BeaconBlockRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.BeaconBlockRoot) + hh.Merkleize(indx) + return nil +} - // Field (28) 'DepositRequestsStartIndex' - ssz.PutUint(hh, b.DepositRequestsStartIndex) - - // Field (29) 'DepositBalanceToConsume' - ssz.PutUint(hh, b.DepositBalanceToConsume) - - // Field (30) 'ExitBalanceToConsume' - ssz.PutUint(hh, b.ExitBalanceToConsume) - - // Field (31) 'EarliestExitEpoch' - ssz.PutUint(hh, b.EarliestExitEpoch) +func (c *ExecutionPayloadBid) SizeSSZ() int { + size := 224 + size += len(c.BlobKzgCommitments) * 48 + return size +} - // Field (32) 'ConsolidationBalanceToConsume' - ssz.PutUint(hh, b.ConsolidationBalanceToConsume) +func (c *ExecutionPayloadBid) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (33) 'EarliestConsolidationEpoch' - ssz.PutUint(hh, b.EarliestConsolidationEpoch) +func (c *ExecutionPayloadBid) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 224 - // 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 0: ParentBlockHash + if len(c.ParentBlockHash) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.ParentBlockHash...) - // 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 1: ParentBlockRoot + if len(c.ParentBlockRoot) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.ParentBlockRoot...) - // 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 2: BlockHash + if len(c.BlockHash) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.BlockHash...) - // Field (37) 'ProposerLookahead' - { - if size := len(b.ProposerLookahead); size != 64 { - err = ssz.ErrVectorLengthFn("--.ProposerLookahead", size, 64) - return - } - subIndx := hh.Index() - for _, i := range b.ProposerLookahead { - ssz.AppendUint(hh, i) - } - hh.Merkleize(subIndx) + // Field 3: PrevRandao + if len(c.PrevRandao) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.PrevRandao...) - // Field (38) 'Builders' - { - subIndx := hh.Index() - num := uint64(len(b.Builders)) - if num > 1099511627776 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range b.Builders { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } - } - hh.MerkleizeWithMixin(subIndx, num, 1099511627776) + // Field 4: FeeRecipient + if len(c.FeeRecipient) != 20 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.FeeRecipient...) - // Field (39) 'NextWithdrawalBuilderIndex' - ssz.PutUint(hh, b.NextWithdrawalBuilderIndex) + // Field 5: GasLimit + dst = binary.LittleEndian.AppendUint64(dst, c.GasLimit) - // Field (40) 'ExecutionPayloadAvailability' - if size := len(b.ExecutionPayloadAvailability); size != 1024 { - err = ssz.ErrBytesLengthFn("--.ExecutionPayloadAvailability", size, 1024) - return + // Field 6: BuilderIndex + if dst, err = c.BuilderIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("BuilderIndex: %w", err) } - hh.PutBytes(b.ExecutionPayloadAvailability) - // Field (41) 'BuilderPendingPayments' - { - subIndx := hh.Index() - for _, elem := range b.BuilderPendingPayments { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } - } - hh.Merkleize(subIndx) + // Field 7: Slot + if dst, err = c.Slot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Slot: %w", err) } - // Field (42) 'BuilderPendingWithdrawals' - { - subIndx := hh.Index() - num := uint64(len(b.BuilderPendingWithdrawals)) - if num > 1048576 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range b.BuilderPendingWithdrawals { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } - } - hh.MerkleizeWithMixin(subIndx, num, 1048576) + // Field 8: Value + if dst, err = c.Value.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Value: %w", err) } - // Field (43) 'LatestExecutionPayloadBid' - if err = b.LatestExecutionPayloadBid.HashTreeRootWith(hh); err != nil { - return + // Field 9: ExecutionPayment + if dst, err = c.ExecutionPayment.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ExecutionPayment: %w", err) } - // Field (44) 'PayloadExpectedWithdrawals' - { - subIndx := hh.Index() - num := uint64(len(b.PayloadExpectedWithdrawals)) - if num > 16 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range b.PayloadExpectedWithdrawals { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } - } - hh.MerkleizeWithMixin(subIndx, num, 16) + // Field 10: BlobKzgCommitments + dst = ssz.WriteOffset(dst, offset) + offset += len(c.BlobKzgCommitments) * 48 + + // Field 11: ExecutionRequestsRoot + if len(c.ExecutionRequestsRoot) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.ExecutionRequestsRoot...) - // Field (45) 'PtcWindow' - { - subIndx := hh.Index() - for _, elem := range b.PtcWindow { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } + // Field 10: BlobKzgCommitments + if len(c.BlobKzgCommitments) > 4096 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.BlobKzgCommitments { + if len(o) != 48 { + return nil, ssz.ErrBytesLength } - hh.Merkleize(subIndx) + dst = append(dst, o...) + } + return dst, err +} + +func (c *ExecutionPayloadBid) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 224 { + return ssz.ErrSize + } + + sszSlice0 := buf[0:32] // c.ParentBlockHash + sszSlice1 := buf[32:64] // c.ParentBlockRoot + sszSlice2 := buf[64:96] // c.BlockHash + sszSlice3 := buf[96:128] // c.PrevRandao + sszSlice4 := buf[128:148] // c.FeeRecipient + sszSlice5 := buf[148:156] // c.GasLimit + sszSlice6 := buf[156:164] // c.BuilderIndex + sszSlice7 := buf[164:172] // c.Slot + sszSlice8 := buf[172:180] // c.Value + sszSlice9 := buf[180:188] // c.ExecutionPayment + sszSlice11 := buf[192:224] // c.ExecutionRequestsRoot + + sszVarOffset10 := ssz.ReadOffset(buf[188:192]) // c.BlobKzgCommitments + if sszVarOffset10 != 224 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset10 > size { + return ssz.ErrOffset } + sszSlice10 := buf[sszVarOffset10:] // c.BlobKzgCommitments - hh.Merkleize(indx) - return -} + // Field 0: ParentBlockHash + c.ParentBlockHash = make([]byte, 0, 32) + c.ParentBlockHash = append(c.ParentBlockHash, sszSlice0...) -// MarshalSSZ ssz marshals the PTCs object -func (p *PTCs) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(p) -} + // Field 1: ParentBlockRoot + c.ParentBlockRoot = make([]byte, 0, 32) + c.ParentBlockRoot = append(c.ParentBlockRoot, sszSlice1...) + + // Field 2: BlockHash + c.BlockHash = make([]byte, 0, 32) + c.BlockHash = append(c.BlockHash, sszSlice2...) -// MarshalSSZTo ssz marshals the PTCs object to a target array -func (p *PTCs) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf + // Field 3: PrevRandao + c.PrevRandao = make([]byte, 0, 32) + c.PrevRandao = append(c.PrevRandao, sszSlice3...) - // Field (0) 'ValidatorIndices' - if size := len(p.ValidatorIndices); size != 512 { - err = ssz.ErrVectorLengthFn("--.ValidatorIndices", size, 512) - return + // Field 4: FeeRecipient + c.FeeRecipient = make([]byte, 0, 20) + c.FeeRecipient = append(c.FeeRecipient, sszSlice4...) + + // Field 5: GasLimit + c.GasLimit = binary.LittleEndian.Uint64(sszSlice5) + + // Field 6: BuilderIndex + if err = c.BuilderIndex.UnmarshalSSZ(sszSlice6); err != nil { + return fmt.Errorf("BuilderIndex: %w", err) } - for ii := 0; ii < 512; ii++ { - dst = ssz.MarshalUint(dst, p.ValidatorIndices[ii]) + + // Field 7: Slot + if err = c.Slot.UnmarshalSSZ(sszSlice7); err != nil { + return fmt.Errorf("Slot: %w", err) } - return -} + // Field 8: Value + if err = c.Value.UnmarshalSSZ(sszSlice8); err != nil { + return fmt.Errorf("Value: %w", err) + } -// UnmarshalSSZ ssz unmarshals the PTCs object -func (p *PTCs) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size != 4096 { - return ssz.ErrSize + // Field 9: ExecutionPayment + if err = c.ExecutionPayment.UnmarshalSSZ(sszSlice9); err != nil { + return fmt.Errorf("ExecutionPayment: %w", err) } - // Field (0) 'ValidatorIndices' - p.ValidatorIndices = ssz.ExtendUint(p.ValidatorIndices, 512) - for ii := 0; ii < 512; ii++ { - p.ValidatorIndices[ii] = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[0:4096][ii*8 : (ii+1)*8]) + // Field 10: BlobKzgCommitments + { + if len(sszSlice10)%48 != 0 { + return fmt.Errorf("misaligned bytes: c.BlobKzgCommitments length is %d, which is not a multiple of 48: %w", len(sszSlice10), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice10) / 48 + if numElem > 4096 { + return fmt.Errorf("ssz-max exceeded: c.BlobKzgCommitments has %d elements, ssz-max is 4096: %w", numElem, ssz.ErrListTooBig) + } + c.BlobKzgCommitments = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte + + tmpSlice := sszSlice10[i*48 : (1+i)*48] + tmp = make([]byte, 0, 48) + tmp = append(tmp, tmpSlice...) + c.BlobKzgCommitments[i] = tmp + } } + // Field 11: ExecutionRequestsRoot + c.ExecutionRequestsRoot = make([]byte, 0, 32) + c.ExecutionRequestsRoot = append(c.ExecutionRequestsRoot, sszSlice11...) return err } -// SizeSSZ returns the ssz encoded size in bytes for the PTCs object -func (p *PTCs) SizeSSZ() (size int) { - size = 4096 - return -} - -// HashTreeRoot ssz hashes the PTCs object -func (p *PTCs) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(p) +func (c *ExecutionPayloadBid) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the PTCs object with a hasher -func (p *PTCs) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *ExecutionPayloadBid) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'ValidatorIndices' + // Field 0: ParentBlockHash + if len(c.ParentBlockHash) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ParentBlockHash) + // Field 1: ParentBlockRoot + if len(c.ParentBlockRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ParentBlockRoot) + // Field 2: BlockHash + if len(c.BlockHash) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.BlockHash) + // Field 3: PrevRandao + if len(c.PrevRandao) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.PrevRandao) + // Field 4: FeeRecipient + if len(c.FeeRecipient) != 20 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.FeeRecipient) + // Field 5: GasLimit + hh.PutUint64(c.GasLimit) + // Field 6: BuilderIndex + if err := c.BuilderIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("BuilderIndex: %w", err) + } + // Field 7: Slot + if err := c.Slot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Slot: %w", err) + } + // Field 8: Value + if err := c.Value.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Value: %w", err) + } + // Field 9: ExecutionPayment + if err := c.ExecutionPayment.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ExecutionPayment: %w", err) + } + // Field 10: BlobKzgCommitments { - if size := len(p.ValidatorIndices); size != 512 { - err = ssz.ErrVectorLengthFn("--.ValidatorIndices", size, 512) - return + if len(c.BlobKzgCommitments) > 4096 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range p.ValidatorIndices { - ssz.AppendUint(hh, i) + for _, o := range c.BlobKzgCommitments { + if len(o) != 48 { + return ssz.ErrBytesLength + } + hh.PutBytes(o) } - hh.Merkleize(subIndx) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.BlobKzgCommitments)), 4096) } - + // Field 11: ExecutionRequestsRoot + if len(c.ExecutionRequestsRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ExecutionRequestsRoot) hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the BeaconBlockContentsGloas object -func (b *BeaconBlockContentsGloas) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) +func (c *ExecutionPayloadEnvelope) SizeSSZ() int { + size := 80 + if c.Payload == nil { + c.Payload = new(v1.ExecutionPayloadGloas) + } + size += c.Payload.SizeSSZ() + if c.ExecutionRequests == nil { + c.ExecutionRequests = new(v1.ExecutionRequestsGloas) + } + size += c.ExecutionRequests.SizeSSZ() + return size } -// MarshalSSZTo ssz marshals the BeaconBlockContentsGloas object to a target array -func (b *BeaconBlockContentsGloas) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(16) +func (c *ExecutionPayloadEnvelope) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Offset (0) 'Block' - dst = ssz.WriteOffset(dst, offset) - if b.Block == nil { - b.Block = new(BeaconBlockGloas) - } - offset += b.Block.SizeSSZ() +func (c *ExecutionPayloadEnvelope) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 80 - // Offset (1) 'ExecutionPayloadEnvelope' - dst = ssz.WriteOffset(dst, offset) - if b.ExecutionPayloadEnvelope == nil { - b.ExecutionPayloadEnvelope = new(ExecutionPayloadEnvelope) + // Field 0: Payload + if c.Payload == nil { + c.Payload = new(v1.ExecutionPayloadGloas) } - offset += b.ExecutionPayloadEnvelope.SizeSSZ() - - // Offset (2) 'KzgProofs' dst = ssz.WriteOffset(dst, offset) - offset += len(b.KzgProofs) * 48 + offset += c.Payload.SizeSSZ() - // Offset (3) 'Blobs' + // Field 1: ExecutionRequests + if c.ExecutionRequests == nil { + c.ExecutionRequests = new(v1.ExecutionRequestsGloas) + } dst = ssz.WriteOffset(dst, offset) - offset += len(b.Blobs) * 131072 + offset += c.ExecutionRequests.SizeSSZ() - // Field (0) 'Block' - if dst, err = b.Block.MarshalSSZTo(dst); err != nil { - return + // Field 2: BuilderIndex + if dst, err = c.BuilderIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("BuilderIndex: %w", err) } - // Field (1) 'ExecutionPayloadEnvelope' - if dst, err = b.ExecutionPayloadEnvelope.MarshalSSZTo(dst); err != nil { - return + // Field 3: BeaconBlockRoot + if len(c.BeaconBlockRoot) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.BeaconBlockRoot...) - // Field (2) 'KzgProofs' - if size := len(b.KzgProofs); size > 33554432 { - err = ssz.ErrListTooBigFn("--.KzgProofs", size, 33554432) - return - } - for ii := 0; ii < len(b.KzgProofs); ii++ { - if size := len(b.KzgProofs[ii]); size != 48 { - err = ssz.ErrBytesLengthFn("--.KzgProofs[ii]", size, 48) - return - } - dst = append(dst, b.KzgProofs[ii]...) + // Field 4: ParentBeaconBlockRoot + if len(c.ParentBeaconBlockRoot) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.ParentBeaconBlockRoot...) - // Field (3) 'Blobs' - if size := len(b.Blobs); size > 4096 { - err = ssz.ErrListTooBigFn("--.Blobs", size, 4096) - return - } - for ii := 0; ii < len(b.Blobs); ii++ { - if size := len(b.Blobs[ii]); size != 131072 { - err = ssz.ErrBytesLengthFn("--.Blobs[ii]", size, 131072) - return - } - dst = append(dst, b.Blobs[ii]...) + // Field 0: Payload + if dst, err = c.Payload.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Payload: %w", err) } - return + // Field 1: ExecutionRequests + if dst, err = c.ExecutionRequests.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ExecutionRequests: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the BeaconBlockContentsGloas object -func (b *BeaconBlockContentsGloas) UnmarshalSSZ(buf []byte) error { +func (c *ExecutionPayloadEnvelope) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 16 { + if size < 80 { return ssz.ErrSize } - tail := buf - var o0, o1, o2, o3 uint64 - - // Offset (0) 'Block' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } + sszSlice2 := buf[8:16] // c.BuilderIndex + sszSlice3 := buf[16:48] // c.BeaconBlockRoot + sszSlice4 := buf[48:80] // c.ParentBeaconBlockRoot - if o0 != 16 { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Payload + if sszVarOffset0 != 80 { return ssz.ErrInvalidVariableOffset } - - // Offset (1) 'ExecutionPayloadEnvelope' - if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 { + if sszVarOffset0 > size { return ssz.ErrOffset } - - // Offset (2) 'KzgProofs' - if o2 = ssz.ReadOffset(buf[8:12]); o2 > size || o1 > o2 { + sszVarOffset1 := ssz.ReadOffset(buf[4:8]) // c.ExecutionRequests + if sszVarOffset1 > size || sszVarOffset1 < sszVarOffset0 { return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:sszVarOffset1] // c.Payload + sszSlice1 := buf[sszVarOffset1:] // c.ExecutionRequests - // Offset (3) 'Blobs' - if o3 = ssz.ReadOffset(buf[12:16]); o3 > size || o2 > o3 { - return ssz.ErrOffset + // Field 0: Payload + c.Payload = new(v1.ExecutionPayloadGloas) + if err = c.Payload.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Payload: %w", err) } - // Field (0) 'Block' - { - buf = tail[o0:o1] - if b.Block == nil { - b.Block = new(BeaconBlockGloas) - } - if err = b.Block.UnmarshalSSZ(buf); err != nil { - return err - } + // Field 1: ExecutionRequests + c.ExecutionRequests = new(v1.ExecutionRequestsGloas) + if err = c.ExecutionRequests.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("ExecutionRequests: %w", err) } - // Field (1) 'ExecutionPayloadEnvelope' - { - buf = tail[o1:o2] - if b.ExecutionPayloadEnvelope == nil { - b.ExecutionPayloadEnvelope = new(ExecutionPayloadEnvelope) - } - if err = b.ExecutionPayloadEnvelope.UnmarshalSSZ(buf); err != nil { - return err - } + // Field 2: BuilderIndex + if err = c.BuilderIndex.UnmarshalSSZ(sszSlice2); err != nil { + return fmt.Errorf("BuilderIndex: %w", err) } - // Field (2) 'KzgProofs' - { - buf = tail[o2:o3] - num, err := ssz.DivideInt2(len(buf), 48, 33554432) - if err != nil { - return err - } - b.KzgProofs = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(b.KzgProofs[ii]) == 0 { - b.KzgProofs[ii] = make([]byte, 0, len(buf[ii*48:(ii+1)*48])) - } - b.KzgProofs[ii] = append(b.KzgProofs[ii], buf[ii*48:(ii+1)*48]...) - } - } + // Field 3: BeaconBlockRoot + c.BeaconBlockRoot = make([]byte, 0, 32) + c.BeaconBlockRoot = append(c.BeaconBlockRoot, sszSlice3...) - // Field (3) 'Blobs' - { - buf = tail[o3:] - num, err := ssz.DivideInt2(len(buf), 131072, 4096) - if err != nil { - return err - } - b.Blobs = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(b.Blobs[ii]) == 0 { - b.Blobs[ii] = make([]byte, 0, len(buf[ii*131072:(ii+1)*131072])) - } - b.Blobs[ii] = append(b.Blobs[ii], buf[ii*131072:(ii+1)*131072]...) - } - } + // Field 4: ParentBeaconBlockRoot + c.ParentBeaconBlockRoot = make([]byte, 0, 32) + c.ParentBeaconBlockRoot = append(c.ParentBeaconBlockRoot, sszSlice4...) return err } -// SizeSSZ returns the ssz encoded size in bytes for the BeaconBlockContentsGloas object -func (b *BeaconBlockContentsGloas) SizeSSZ() (size int) { - size = 16 - - // Field (0) 'Block' - if b.Block == nil { - b.Block = new(BeaconBlockGloas) +func (c *ExecutionPayloadEnvelope) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - size += b.Block.SizeSSZ() + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (1) 'ExecutionPayloadEnvelope' - if b.ExecutionPayloadEnvelope == nil { - b.ExecutionPayloadEnvelope = new(ExecutionPayloadEnvelope) +func (c *ExecutionPayloadEnvelope) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Payload + if err := c.Payload.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Payload: %w", err) } - size += b.ExecutionPayloadEnvelope.SizeSSZ() - - // Field (2) 'KzgProofs' - size += len(b.KzgProofs) * 48 - - // Field (3) 'Blobs' - size += len(b.Blobs) * 131072 + // Field 1: ExecutionRequests + if err := c.ExecutionRequests.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ExecutionRequests: %w", err) + } + // Field 2: BuilderIndex + if err := c.BuilderIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("BuilderIndex: %w", err) + } + // Field 3: BeaconBlockRoot + if len(c.BeaconBlockRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.BeaconBlockRoot) + // Field 4: ParentBeaconBlockRoot + if len(c.ParentBeaconBlockRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ParentBeaconBlockRoot) + hh.Merkleize(indx) + return nil +} - return +func (c *IndexedAttestationGloas) SizeSSZ() int { + size := 228 + size += len(c.AttestingIndices) * 8 + return size } -// HashTreeRoot ssz hashes the BeaconBlockContentsGloas object -func (b *BeaconBlockContentsGloas) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) +func (c *IndexedAttestationGloas) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// HashTreeRootWith ssz hashes the BeaconBlockContentsGloas object with a hasher -func (b *BeaconBlockContentsGloas) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() +func (c *IndexedAttestationGloas) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 228 + + // Field 0: AttestingIndices + dst = ssz.WriteOffset(dst, offset) + offset += len(c.AttestingIndices) * 8 + + // Field 1: Data + if c.Data == nil { + c.Data = new(AttestationData) + } + if dst, err = c.Data.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Data: %w", err) + } + + // Field 2: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.Signature...) + + // Field 0: AttestingIndices + if len(c.AttestingIndices) > 131072 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.AttestingIndices { + dst = binary.LittleEndian.AppendUint64(dst, o) + } + return dst, err +} - // Field (0) 'Block' - if err = b.Block.HashTreeRootWith(hh); err != nil { - return +func (c *IndexedAttestationGloas) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 228 { + return ssz.ErrSize } - // Field (1) 'ExecutionPayloadEnvelope' - if err = b.ExecutionPayloadEnvelope.HashTreeRootWith(hh); err != nil { - return + sszSlice1 := buf[4:132] // c.Data + sszSlice2 := buf[132:228] // c.Signature + + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.AttestingIndices + if sszVarOffset0 != 228 { + return ssz.ErrInvalidVariableOffset } + if sszVarOffset0 > size { + return ssz.ErrOffset + } + sszSlice0 := buf[sszVarOffset0:] // c.AttestingIndices - // Field (2) 'KzgProofs' + // Field 0: AttestingIndices { - if size := len(b.KzgProofs); size > 33554432 { - err = ssz.ErrListTooBigFn("--.KzgProofs", size, 33554432) - return + if len(sszSlice0)%8 != 0 { + return fmt.Errorf("misaligned bytes: c.AttestingIndices length is %d, which is not a multiple of 8: %w", len(sszSlice0), ssz.ErrIncorrectListSize) } - subIndx := hh.Index() - for _, i := range b.KzgProofs { - if len(i) != 48 { - err = ssz.ErrBytesLength - return - } - hh.PutBytes(i) + numElem := len(sszSlice0) / 8 + if numElem > 131072 { + return fmt.Errorf("ssz-max exceeded: c.AttestingIndices has %d elements, ssz-max is 131072: %w", numElem, ssz.ErrListTooBig) } + c.AttestingIndices = make([]uint64, numElem) + for i := 0; i < numElem; i++ { + var tmp uint64 + + tmpSlice := sszSlice0[i*8 : (1+i)*8] + tmp = binary.LittleEndian.Uint64(tmpSlice) + c.AttestingIndices[i] = tmp + } + } + + // Field 1: Data + c.Data = new(AttestationData) + if err = c.Data.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Data: %w", err) + } + + // Field 2: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice2...) + return err +} - numItems := uint64(len(b.KzgProofs)) - hh.MerkleizeWithMixin(subIndx, numItems, 33554432) +func (c *IndexedAttestationGloas) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (3) 'Blobs' +func (c *IndexedAttestationGloas) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: AttestingIndices { - if size := len(b.Blobs); size > 4096 { - err = ssz.ErrListTooBigFn("--.Blobs", size, 4096) - return + if len(c.AttestingIndices) > 131072 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range b.Blobs { - if len(i) != 131072 { - err = ssz.ErrBytesLength - return - } - hh.PutBytes(i) + for _, o := range c.AttestingIndices { + hh.AppendUint64(o) } - - numItems := uint64(len(b.Blobs)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) + hh.FillUpTo32() + numItems := uint64(len(c.AttestingIndices)) + hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(131072, numItems, 8)) } - + // Field 1: Data + if err := c.Data.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Data: %w", err) + } + // Field 2: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Signature) hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the SignedExecutionPayloadEnvelopeContents object -func (s *SignedExecutionPayloadEnvelopeContents) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) + return nil } -// MarshalSSZTo ssz marshals the SignedExecutionPayloadEnvelopeContents object to a target array -func (s *SignedExecutionPayloadEnvelopeContents) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(12) +func (c *PayloadAttestation) SizeSSZ() int { + size := 202 - // Offset (0) 'SignedExecutionPayloadEnvelope' - dst = ssz.WriteOffset(dst, offset) - if s.SignedExecutionPayloadEnvelope == nil { - s.SignedExecutionPayloadEnvelope = new(SignedExecutionPayloadEnvelope) - } - offset += s.SignedExecutionPayloadEnvelope.SizeSSZ() + return size +} - // Offset (1) 'KzgProofs' - dst = ssz.WriteOffset(dst, offset) - offset += len(s.KzgProofs) * 48 +func (c *PayloadAttestation) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Offset (2) 'Blobs' - dst = ssz.WriteOffset(dst, offset) - offset += len(s.Blobs) * 131072 +func (c *PayloadAttestation) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (0) 'SignedExecutionPayloadEnvelope' - if dst, err = s.SignedExecutionPayloadEnvelope.MarshalSSZTo(dst); err != nil { - return + // Field 0: AggregationBits + if len([]byte(c.AggregationBits)) != 64 { + return nil, ssz.ErrBytesLength } + dst = append(dst, []byte(c.AggregationBits)...) - // Field (1) 'KzgProofs' - if size := len(s.KzgProofs); size > 33554432 { - err = ssz.ErrListTooBigFn("--.KzgProofs", size, 33554432) - return + // Field 1: Data + if c.Data == nil { + c.Data = new(PayloadAttestationData) } - for ii := 0; ii < len(s.KzgProofs); ii++ { - if size := len(s.KzgProofs[ii]); size != 48 { - err = ssz.ErrBytesLengthFn("--.KzgProofs[ii]", size, 48) - return - } - dst = append(dst, s.KzgProofs[ii]...) + if dst, err = c.Data.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Data: %w", err) } - // Field (2) 'Blobs' - if size := len(s.Blobs); size > 4096 { - err = ssz.ErrListTooBigFn("--.Blobs", size, 4096) - return - } - for ii := 0; ii < len(s.Blobs); ii++ { - if size := len(s.Blobs[ii]); size != 131072 { - err = ssz.ErrBytesLengthFn("--.Blobs[ii]", size, 131072) - return - } - dst = append(dst, s.Blobs[ii]...) + // Field 2: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.Signature...) - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the SignedExecutionPayloadEnvelopeContents object -func (s *SignedExecutionPayloadEnvelopeContents) UnmarshalSSZ(buf []byte) error { +func (c *PayloadAttestation) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 12 { + if size != 202 { return ssz.ErrSize } - tail := buf - var o0, o1, o2 uint64 + sszSlice0 := buf[0:64] // c.AggregationBits + sszSlice1 := buf[64:106] // c.Data + sszSlice2 := buf[106:202] // c.Signature - // Offset (0) 'SignedExecutionPayloadEnvelope' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } + // Field 0: AggregationBits + c.AggregationBits = make([]byte, 0, 64) + c.AggregationBits = append(c.AggregationBits, go_bitfield.Bitvector512(sszSlice0)...) - if o0 != 12 { - return ssz.ErrInvalidVariableOffset + // Field 1: Data + c.Data = new(PayloadAttestationData) + if err = c.Data.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Data: %w", err) } - // Offset (1) 'KzgProofs' - if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 { - return ssz.ErrOffset - } + // Field 2: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice2...) + return err +} - // Offset (2) 'Blobs' - if o2 = ssz.ReadOffset(buf[8:12]); o2 > size || o1 > o2 { - return ssz.ErrOffset +func (c *PayloadAttestation) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (0) 'SignedExecutionPayloadEnvelope' - { - buf = tail[o0:o1] - if s.SignedExecutionPayloadEnvelope == nil { - s.SignedExecutionPayloadEnvelope = new(SignedExecutionPayloadEnvelope) - } - if err = s.SignedExecutionPayloadEnvelope.UnmarshalSSZ(buf); err != nil { - return err - } +func (c *PayloadAttestation) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: AggregationBits + if len([]byte(c.AggregationBits)) != 64 { + return ssz.ErrBytesLength } - - // Field (1) 'KzgProofs' - { - buf = tail[o1:o2] - num, err := ssz.DivideInt2(len(buf), 48, 33554432) - if err != nil { - return err - } - s.KzgProofs = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(s.KzgProofs[ii]) == 0 { - s.KzgProofs[ii] = make([]byte, 0, len(buf[ii*48:(ii+1)*48])) - } - s.KzgProofs[ii] = append(s.KzgProofs[ii], buf[ii*48:(ii+1)*48]...) - } + hh.PutBytes([]byte(c.AggregationBits)) + // Field 1: Data + if err := c.Data.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Data: %w", err) } - - // Field (2) 'Blobs' - { - buf = tail[o2:] - num, err := ssz.DivideInt2(len(buf), 131072, 4096) - if err != nil { - return err - } - s.Blobs = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(s.Blobs[ii]) == 0 { - s.Blobs[ii] = make([]byte, 0, len(buf[ii*131072:(ii+1)*131072])) - } - s.Blobs[ii] = append(s.Blobs[ii], buf[ii*131072:(ii+1)*131072]...) - } + // Field 2: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength } - return err + hh.PutBytes(c.Signature) + hh.Merkleize(indx) + return nil +} + +func (c *PayloadAttestationData) SizeSSZ() int { + size := 42 + + return size +} + +func (c *PayloadAttestationData) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// SizeSSZ returns the ssz encoded size in bytes for the SignedExecutionPayloadEnvelopeContents object -func (s *SignedExecutionPayloadEnvelopeContents) SizeSSZ() (size int) { - size = 12 +func (c *PayloadAttestationData) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + + // Field 0: BeaconBlockRoot + if len(c.BeaconBlockRoot) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.BeaconBlockRoot...) - // Field (0) 'SignedExecutionPayloadEnvelope' - if s.SignedExecutionPayloadEnvelope == nil { - s.SignedExecutionPayloadEnvelope = new(SignedExecutionPayloadEnvelope) + // Field 1: Slot + if dst, err = c.Slot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Slot: %w", err) } - size += s.SignedExecutionPayloadEnvelope.SizeSSZ() - // Field (1) 'KzgProofs' - size += len(s.KzgProofs) * 48 + // Field 2: PayloadPresent + if c.PayloadPresent { + dst = append(dst, 1) + } else { + dst = append(dst, 0) + } - // Field (2) 'Blobs' - size += len(s.Blobs) * 131072 + // Field 3: BlobDataAvailable + if c.BlobDataAvailable { + dst = append(dst, 1) + } else { + dst = append(dst, 0) + } - return + return dst, err } -// HashTreeRoot ssz hashes the SignedExecutionPayloadEnvelopeContents object -func (s *SignedExecutionPayloadEnvelopeContents) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) -} +func (c *PayloadAttestationData) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 42 { + return ssz.ErrSize + } -// HashTreeRootWith ssz hashes the SignedExecutionPayloadEnvelopeContents object with a hasher -func (s *SignedExecutionPayloadEnvelopeContents) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() + sszSlice0 := buf[0:32] // c.BeaconBlockRoot + sszSlice1 := buf[32:40] // c.Slot + sszSlice2 := buf[40:41] // c.PayloadPresent + sszSlice3 := buf[41:42] // c.BlobDataAvailable - // Field (0) 'SignedExecutionPayloadEnvelope' - if err = s.SignedExecutionPayloadEnvelope.HashTreeRootWith(hh); err != nil { - return - } + // Field 0: BeaconBlockRoot + c.BeaconBlockRoot = make([]byte, 0, 32) + c.BeaconBlockRoot = append(c.BeaconBlockRoot, sszSlice0...) - // Field (1) 'KzgProofs' - { - if size := len(s.KzgProofs); size > 33554432 { - err = ssz.ErrListTooBigFn("--.KzgProofs", size, 33554432) - return - } - subIndx := hh.Index() - for _, i := range s.KzgProofs { - if len(i) != 48 { - err = ssz.ErrBytesLength - return - } - hh.PutBytes(i) - } + // Field 1: Slot + if err = c.Slot.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Slot: %w", err) + } - numItems := uint64(len(s.KzgProofs)) - hh.MerkleizeWithMixin(subIndx, numItems, 33554432) + // Field 2: PayloadPresent + if sszSlice2[0] > 1 { + return ssz.ErrInvalidSerialization + } + if sszSlice2[0] == 1 { + c.PayloadPresent = true + } else { + c.PayloadPresent = false } - // Field (2) 'Blobs' - { - if size := len(s.Blobs); size > 4096 { - err = ssz.ErrListTooBigFn("--.Blobs", size, 4096) - return - } - subIndx := hh.Index() - for _, i := range s.Blobs { - if len(i) != 131072 { - err = ssz.ErrBytesLength - return - } - hh.PutBytes(i) - } + // Field 3: BlobDataAvailable + if sszSlice3[0] > 1 { + return ssz.ErrInvalidSerialization + } + if sszSlice3[0] == 1 { + c.BlobDataAvailable = true + } else { + c.BlobDataAvailable = false + } + return err +} - numItems := uint64(len(s.Blobs)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) +func (c *PayloadAttestationData) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} +func (c *PayloadAttestationData) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: BeaconBlockRoot + if len(c.BeaconBlockRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.BeaconBlockRoot) + // Field 1: Slot + if err := c.Slot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Slot: %w", err) + } + // Field 2: PayloadPresent + hh.PutBool(c.PayloadPresent) + // Field 3: BlobDataAvailable + hh.PutBool(c.BlobDataAvailable) hh.Merkleize(indx) - return + return nil +} + +func (c *PayloadAttestationMessage) SizeSSZ() int { + size := 146 + + return size } -// MarshalSSZ ssz marshals the BuilderPendingPayment object -func (b *BuilderPendingPayment) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) +func (c *PayloadAttestationMessage) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the BuilderPendingPayment object to a target array -func (b *BuilderPendingPayment) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *PayloadAttestationMessage) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (0) 'Weight' - dst = ssz.MarshalUint(dst, b.Weight) + // Field 0: ValidatorIndex + if dst, err = c.ValidatorIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ValidatorIndex: %w", err) + } - // Field (1) 'Withdrawal' - if b.Withdrawal == nil { - b.Withdrawal = new(BuilderPendingWithdrawal) + // Field 1: Data + if c.Data == nil { + c.Data = new(PayloadAttestationData) } - if dst, err = b.Withdrawal.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.Data.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Data: %w", err) } - // Field (2) 'ProposerIndex' - dst = ssz.MarshalUint(dst, b.ProposerIndex) + // Field 2: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.Signature...) - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the BuilderPendingPayment object -func (b *BuilderPendingPayment) UnmarshalSSZ(buf []byte) error { +func (c *PayloadAttestationMessage) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 52 { + if size != 146 { return ssz.ErrSize } - // Field (0) 'Weight' - b.Weight = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Gwei](buf[0:8]) + sszSlice0 := buf[0:8] // c.ValidatorIndex + sszSlice1 := buf[8:50] // c.Data + sszSlice2 := buf[50:146] // c.Signature - // Field (1) 'Withdrawal' - if b.Withdrawal == nil { - b.Withdrawal = new(BuilderPendingWithdrawal) - } - if err = b.Withdrawal.UnmarshalSSZ(buf[8:44]); err != nil { - return err + // Field 0: ValidatorIndex + if err = c.ValidatorIndex.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("ValidatorIndex: %w", err) } - // Field (2) 'ProposerIndex' - b.ProposerIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[44:52]) + // Field 1: Data + c.Data = new(PayloadAttestationData) + if err = c.Data.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Data: %w", err) + } + // Field 2: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice2...) return err } -// SizeSSZ returns the ssz encoded size in bytes for the BuilderPendingPayment object -func (b *BuilderPendingPayment) SizeSSZ() (size int) { - size = 52 - return -} - -// HashTreeRoot ssz hashes the BuilderPendingPayment object -func (b *BuilderPendingPayment) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) +func (c *PayloadAttestationMessage) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the BuilderPendingPayment object with a hasher -func (b *BuilderPendingPayment) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *PayloadAttestationMessage) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Weight' - ssz.PutUint(hh, b.Weight) - - // Field (1) 'Withdrawal' - if err = b.Withdrawal.HashTreeRootWith(hh); err != nil { - return + // Field 0: ValidatorIndex + if err := c.ValidatorIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ValidatorIndex: %w", err) + } + // Field 1: Data + if err := c.Data.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Data: %w", err) } + // Field 2: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Signature) + hh.Merkleize(indx) + return nil +} - // Field (2) 'ProposerIndex' - ssz.PutUint(hh, b.ProposerIndex) +func (c *ProposerPreferences) SizeSSZ() int { + size := 76 - hh.Merkleize(indx) - return + return size } -// MarshalSSZ ssz marshals the BuilderPendingWithdrawal object -func (b *BuilderPendingWithdrawal) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) +func (c *ProposerPreferences) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the BuilderPendingWithdrawal object to a target array -func (b *BuilderPendingWithdrawal) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *ProposerPreferences) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + + // Field 0: DependentRoot + if len(c.DependentRoot) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.DependentRoot...) + + // Field 1: ProposalSlot + if dst, err = c.ProposalSlot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ProposalSlot: %w", err) + } - // Field (0) 'FeeRecipient' - if size := len(b.FeeRecipient); size != 20 { - err = ssz.ErrBytesLengthFn("--.FeeRecipient", size, 20) - return + // Field 2: ValidatorIndex + if dst, err = c.ValidatorIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ValidatorIndex: %w", err) } - dst = append(dst, b.FeeRecipient...) - // Field (1) 'Amount' - dst = ssz.MarshalUint(dst, b.Amount) + // Field 3: FeeRecipient + if len(c.FeeRecipient) != 20 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.FeeRecipient...) - // Field (2) 'BuilderIndex' - dst = ssz.MarshalUint(dst, b.BuilderIndex) + // Field 4: TargetGasLimit + dst = binary.LittleEndian.AppendUint64(dst, c.TargetGasLimit) - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the BuilderPendingWithdrawal object -func (b *BuilderPendingWithdrawal) UnmarshalSSZ(buf []byte) error { +func (c *ProposerPreferences) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 36 { + if size != 76 { return ssz.ErrSize } - // Field (0) 'FeeRecipient' - if cap(b.FeeRecipient) == 0 { - b.FeeRecipient = make([]byte, 0, len(buf[0:20])) + sszSlice0 := buf[0:32] // c.DependentRoot + sszSlice1 := buf[32:40] // c.ProposalSlot + sszSlice2 := buf[40:48] // c.ValidatorIndex + sszSlice3 := buf[48:68] // c.FeeRecipient + sszSlice4 := buf[68:76] // c.TargetGasLimit + + // Field 0: DependentRoot + c.DependentRoot = make([]byte, 0, 32) + c.DependentRoot = append(c.DependentRoot, sszSlice0...) + + // Field 1: ProposalSlot + if err = c.ProposalSlot.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("ProposalSlot: %w", err) } - b.FeeRecipient = append(b.FeeRecipient, buf[0:20]...) - // Field (1) 'Amount' - b.Amount = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Gwei](buf[20:28]) + // Field 2: ValidatorIndex + if err = c.ValidatorIndex.UnmarshalSSZ(sszSlice2); err != nil { + return fmt.Errorf("ValidatorIndex: %w", err) + } - // Field (2) 'BuilderIndex' - b.BuilderIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.BuilderIndex](buf[28:36]) + // Field 3: FeeRecipient + c.FeeRecipient = make([]byte, 0, 20) + c.FeeRecipient = append(c.FeeRecipient, sszSlice3...) + // Field 4: TargetGasLimit + c.TargetGasLimit = binary.LittleEndian.Uint64(sszSlice4) return err } -// SizeSSZ returns the ssz encoded size in bytes for the BuilderPendingWithdrawal object -func (b *BuilderPendingWithdrawal) SizeSSZ() (size int) { - size = 36 - return +func (c *ProposerPreferences) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} + +func (c *ProposerPreferences) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: DependentRoot + if len(c.DependentRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.DependentRoot) + // Field 1: ProposalSlot + if err := c.ProposalSlot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ProposalSlot: %w", err) + } + // Field 2: ValidatorIndex + if err := c.ValidatorIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ValidatorIndex: %w", err) + } + // Field 3: FeeRecipient + if len(c.FeeRecipient) != 20 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.FeeRecipient) + // Field 4: TargetGasLimit + hh.PutUint64(c.TargetGasLimit) + hh.Merkleize(indx) + return nil } -// HashTreeRoot ssz hashes the BuilderPendingWithdrawal object -func (b *BuilderPendingWithdrawal) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) +func (c *PTCs) SizeSSZ() int { + size := 4096 + + return size } -// HashTreeRootWith ssz hashes the BuilderPendingWithdrawal object with a hasher -func (b *BuilderPendingWithdrawal) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() +func (c *PTCs) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} + +func (c *PTCs) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + + // Field 0: ValidatorIndices + if len(c.ValidatorIndices) != 512 { + return nil, ssz.ErrBytesLength + } + for _, o := range c.ValidatorIndices { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ValidatorIndices: %w", err) + } + } + + return dst, err +} - // Field (0) 'FeeRecipient' - if size := len(b.FeeRecipient); size != 20 { - err = ssz.ErrBytesLengthFn("--.FeeRecipient", size, 20) - return +func (c *PTCs) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 4096 { + return ssz.ErrSize } - hh.PutBytes(b.FeeRecipient) - // Field (1) 'Amount' - ssz.PutUint(hh, b.Amount) + sszSlice0 := buf[0:4096] // c.ValidatorIndices + + // Field 0: ValidatorIndices + { + c.ValidatorIndices = make([]primitives.ValidatorIndex, 512) + for i := 0; i < 512; i++ { + var tmp primitives.ValidatorIndex + + tmpSlice := sszSlice0[i*8 : (1+i)*8] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("ValidatorIndices: %w", err) + } + c.ValidatorIndices[i] = tmp + } + } + return err +} - // Field (2) 'BuilderIndex' - ssz.PutUint(hh, b.BuilderIndex) +func (c *PTCs) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} +func (c *PTCs) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: ValidatorIndices + { + if len(c.ValidatorIndices) != 512 { + return ssz.ErrVectorLength + } + subIndx := hh.Index() + for _, o := range c.ValidatorIndices { + hh.AppendUint64(uint64(o)) + } + hh.Merkleize(subIndx) + } hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the DataColumnSidecarGloas object -func (d *DataColumnSidecarGloas) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(d) +func (c *RequestAuthV1) SizeSSZ() int { + size := 12 + size += len(c.Data) + return size } -// MarshalSSZTo ssz marshals the DataColumnSidecarGloas object to a target array -func (d *DataColumnSidecarGloas) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(56) - - // Field (0) 'Index' - dst = ssz.MarshalUint(dst, d.Index) +func (c *RequestAuthV1) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Offset (1) 'Column' - dst = ssz.WriteOffset(dst, offset) - offset += len(d.Column) * 2048 +func (c *RequestAuthV1) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 12 - // Offset (2) 'KzgProofs' + // Field 0: Data dst = ssz.WriteOffset(dst, offset) - offset += len(d.KzgProofs) * 48 - - // Field (3) 'Slot' - dst = ssz.MarshalUint(dst, d.Slot) - - // Field (4) 'BeaconBlockRoot' - if size := len(d.BeaconBlockRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.BeaconBlockRoot", size, 32) - return - } - dst = append(dst, d.BeaconBlockRoot...) + offset += len(c.Data) - // Field (1) 'Column' - if size := len(d.Column); size > 4096 { - err = ssz.ErrListTooBigFn("--.Column", size, 4096) - return - } - for ii := 0; ii < len(d.Column); ii++ { - if size := len(d.Column[ii]); size != 2048 { - err = ssz.ErrBytesLengthFn("--.Column[ii]", size, 2048) - return - } - dst = append(dst, d.Column[ii]...) + // Field 1: Slot + if dst, err = c.Slot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Slot: %w", err) } - // Field (2) 'KzgProofs' - if size := len(d.KzgProofs); size > 4096 { - err = ssz.ErrListTooBigFn("--.KzgProofs", size, 4096) - return - } - for ii := 0; ii < len(d.KzgProofs); ii++ { - if size := len(d.KzgProofs[ii]); size != 48 { - err = ssz.ErrBytesLengthFn("--.KzgProofs[ii]", size, 48) - return - } - dst = append(dst, d.KzgProofs[ii]...) + // Field 0: Data + if len(c.Data) > 4096 { + return nil, ssz.ErrListTooBig } - - return + dst = append(dst, c.Data...) + return dst, err } -// UnmarshalSSZ ssz unmarshals the DataColumnSidecarGloas object -func (d *DataColumnSidecarGloas) UnmarshalSSZ(buf []byte) error { +func (c *RequestAuthV1) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 56 { + if size < 12 { return ssz.ErrSize } - tail := buf - var o1, o2 uint64 + sszSlice1 := buf[4:12] // c.Slot - // Field (0) 'Index' - d.Index = ssz.UnmarshallUint[uint64](buf[0:8]) - - // Offset (1) 'Column' - if o1 = ssz.ReadOffset(buf[8:12]); o1 > size { - return ssz.ErrOffset - } - - if o1 != 56 { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Data + if sszVarOffset0 != 12 { return ssz.ErrInvalidVariableOffset } - - // Offset (2) 'KzgProofs' - if o2 = ssz.ReadOffset(buf[12:16]); o2 > size || o1 > o2 { + if sszVarOffset0 > size { return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:] // c.Data - // Field (3) 'Slot' - d.Slot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[16:24]) + // Field 0: Data + c.Data = append([]byte{}, sszSlice0...) - // Field (4) 'BeaconBlockRoot' - if cap(d.BeaconBlockRoot) == 0 { - d.BeaconBlockRoot = make([]byte, 0, len(buf[24:56])) + // Field 1: Slot + if err = c.Slot.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Slot: %w", err) } - d.BeaconBlockRoot = append(d.BeaconBlockRoot, buf[24:56]...) + return err +} - // Field (1) 'Column' - { - buf = tail[o1:o2] - num, err := ssz.DivideInt2(len(buf), 2048, 4096) - if err != nil { - return err - } - d.Column = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(d.Column[ii]) == 0 { - d.Column[ii] = make([]byte, 0, len(buf[ii*2048:(ii+1)*2048])) - } - d.Column[ii] = append(d.Column[ii], buf[ii*2048:(ii+1)*2048]...) - } +func (c *RequestAuthV1) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} + +func (c *RequestAuthV1) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Data - // Field (2) 'KzgProofs' { - buf = tail[o2:] - num, err := ssz.DivideInt2(len(buf), 48, 4096) - if err != nil { - return err - } - d.KzgProofs = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(d.KzgProofs[ii]) == 0 { - d.KzgProofs[ii] = make([]byte, 0, len(buf[ii*48:(ii+1)*48])) - } - d.KzgProofs[ii] = append(d.KzgProofs[ii], buf[ii*48:(ii+1)*48]...) + if len(c.Data) > 4096 { + return ssz.ErrBytesLength } + subIndx := hh.Index() + hh.AppendBytes32(c.Data) + numItems := uint64(len(c.Data)) + hh.MerkleizeWithMixin(subIndx, numItems, (4096*1+31)/32) } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the DataColumnSidecarGloas object -func (d *DataColumnSidecarGloas) SizeSSZ() (size int) { - size = 56 - - // Field (1) 'Column' - size += len(d.Column) * 2048 - // Field (2) 'KzgProofs' - size += len(d.KzgProofs) * 48 - - return + // Field 1: Slot + if err := c.Slot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Slot: %w", err) + } + hh.Merkleize(indx) + return nil } -// HashTreeRoot ssz hashes the DataColumnSidecarGloas object -func (d *DataColumnSidecarGloas) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(d) +func (c *SignedBeaconBlockGloas) SizeSSZ() int { + size := 100 + if c.Block == nil { + c.Block = new(BeaconBlockGloas) + } + size += c.Block.SizeSSZ() + return size } -// HashTreeRootWith ssz hashes the DataColumnSidecarGloas object with a hasher -func (d *DataColumnSidecarGloas) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() +func (c *SignedBeaconBlockGloas) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (0) 'Index' - ssz.PutUint(hh, d.Index) +func (c *SignedBeaconBlockGloas) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 100 - // Field (1) 'Column' - { - if size := len(d.Column); size > 4096 { - err = ssz.ErrListTooBigFn("--.Column", size, 4096) - return - } - subIndx := hh.Index() - for _, i := range d.Column { - if len(i) != 2048 { - err = ssz.ErrBytesLength - return - } - hh.PutBytes(i) - } + // Field 0: Block + if c.Block == nil { + c.Block = new(BeaconBlockGloas) + } + dst = ssz.WriteOffset(dst, offset) + offset += c.Block.SizeSSZ() - numItems := uint64(len(d.Column)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) + // Field 1: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.Signature...) - // Field (2) 'KzgProofs' - { - if size := len(d.KzgProofs); size > 4096 { - err = ssz.ErrListTooBigFn("--.KzgProofs", size, 4096) - return - } - subIndx := hh.Index() - for _, i := range d.KzgProofs { - if len(i) != 48 { - err = ssz.ErrBytesLength - return - } - hh.PutBytes(i) - } + // Field 0: Block + if dst, err = c.Block.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Block: %w", err) + } + return dst, err +} - numItems := uint64(len(d.KzgProofs)) - hh.MerkleizeWithMixin(subIndx, numItems, 4096) +func (c *SignedBeaconBlockGloas) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 100 { + return ssz.ErrSize } - // Field (3) 'Slot' - ssz.PutUint(hh, d.Slot) + sszSlice1 := buf[4:100] // c.Signature + + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Block + if sszVarOffset0 != 100 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset0 > size { + return ssz.ErrOffset + } + sszSlice0 := buf[sszVarOffset0:] // c.Block - // Field (4) 'BeaconBlockRoot' - if size := len(d.BeaconBlockRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.BeaconBlockRoot", size, 32) - return + // Field 0: Block + c.Block = new(BeaconBlockGloas) + if err = c.Block.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Block: %w", err) } - hh.PutBytes(d.BeaconBlockRoot) - hh.Merkleize(indx) - return + // Field 1: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice1...) + return err } -// MarshalSSZ ssz marshals the ExecutionPayloadEnvelope object -func (e *ExecutionPayloadEnvelope) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(e) +func (c *SignedBeaconBlockGloas) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// MarshalSSZTo ssz marshals the ExecutionPayloadEnvelope object to a target array -func (e *ExecutionPayloadEnvelope) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(80) - - // Offset (0) 'Payload' - dst = ssz.WriteOffset(dst, offset) - if e.Payload == nil { - e.Payload = new(v1.ExecutionPayloadGloas) +func (c *SignedBeaconBlockGloas) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Block + if err := c.Block.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Block: %w", err) } - offset += e.Payload.SizeSSZ() + // Field 1: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Signature) + hh.Merkleize(indx) + return nil +} - // Offset (1) 'ExecutionRequests' - dst = ssz.WriteOffset(dst, offset) - if e.ExecutionRequests == nil { - e.ExecutionRequests = new(v1.ExecutionRequestsGloas) +func (c *SignedBlindedExecutionPayloadEnvelope) SizeSSZ() int { + size := 100 + if c.Message == nil { + c.Message = new(BlindedExecutionPayloadEnvelope) } - offset += e.ExecutionRequests.SizeSSZ() + size += c.Message.SizeSSZ() + return size +} - // Field (2) 'BuilderIndex' - dst = ssz.MarshalUint(dst, e.BuilderIndex) +func (c *SignedBlindedExecutionPayloadEnvelope) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (3) 'BeaconBlockRoot' - if size := len(e.BeaconBlockRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.BeaconBlockRoot", size, 32) - return - } - dst = append(dst, e.BeaconBlockRoot...) +func (c *SignedBlindedExecutionPayloadEnvelope) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 100 - // Field (4) 'ParentBeaconBlockRoot' - if size := len(e.ParentBeaconBlockRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentBeaconBlockRoot", size, 32) - return + // Field 0: Message + if c.Message == nil { + c.Message = new(BlindedExecutionPayloadEnvelope) } - dst = append(dst, e.ParentBeaconBlockRoot...) + dst = ssz.WriteOffset(dst, offset) + offset += c.Message.SizeSSZ() - // Field (0) 'Payload' - if dst, err = e.Payload.MarshalSSZTo(dst); err != nil { - return + // Field 1: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.Signature...) - // Field (1) 'ExecutionRequests' - if dst, err = e.ExecutionRequests.MarshalSSZTo(dst); err != nil { - return + // Field 0: Message + if dst, err = c.Message.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Message: %w", err) } - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the ExecutionPayloadEnvelope object -func (e *ExecutionPayloadEnvelope) UnmarshalSSZ(buf []byte) error { +func (c *SignedBlindedExecutionPayloadEnvelope) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 80 { + if size < 100 { return ssz.ErrSize } - tail := buf - var o0, o1 uint64 + sszSlice1 := buf[4:100] // c.Signature - // Offset (0) 'Payload' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } - - if o0 != 80 { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Message + if sszVarOffset0 != 100 { return ssz.ErrInvalidVariableOffset } - - // Offset (1) 'ExecutionRequests' - if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 { + if sszVarOffset0 > size { return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:] // c.Message - // Field (2) 'BuilderIndex' - e.BuilderIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.BuilderIndex](buf[8:16]) - - // Field (3) 'BeaconBlockRoot' - if cap(e.BeaconBlockRoot) == 0 { - e.BeaconBlockRoot = make([]byte, 0, len(buf[16:48])) + // Field 0: Message + c.Message = new(BlindedExecutionPayloadEnvelope) + if err = c.Message.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Message: %w", err) } - e.BeaconBlockRoot = append(e.BeaconBlockRoot, buf[16:48]...) - // Field (4) 'ParentBeaconBlockRoot' - if cap(e.ParentBeaconBlockRoot) == 0 { - e.ParentBeaconBlockRoot = make([]byte, 0, len(buf[48:80])) + // Field 1: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice1...) + return err +} + +func (c *SignedBlindedExecutionPayloadEnvelope) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - e.ParentBeaconBlockRoot = append(e.ParentBeaconBlockRoot, buf[48:80]...) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (0) 'Payload' - { - buf = tail[o0:o1] - if e.Payload == nil { - e.Payload = new(v1.ExecutionPayloadGloas) - } - if err = e.Payload.UnmarshalSSZ(buf); err != nil { - return err - } +func (c *SignedBlindedExecutionPayloadEnvelope) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Message + if err := c.Message.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Message: %w", err) + } + // Field 1: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength } + hh.PutBytes(c.Signature) + hh.Merkleize(indx) + return nil +} - // Field (1) 'ExecutionRequests' - { - buf = tail[o1:] - if e.ExecutionRequests == nil { - e.ExecutionRequests = new(v1.ExecutionRequestsGloas) - } - if err = e.ExecutionRequests.UnmarshalSSZ(buf); err != nil { - return err - } +func (c *SignedExecutionPayloadBid) SizeSSZ() int { + size := 100 + if c.Message == nil { + c.Message = new(ExecutionPayloadBid) } - return err + size += c.Message.SizeSSZ() + return size } -// SizeSSZ returns the ssz encoded size in bytes for the ExecutionPayloadEnvelope object -func (e *ExecutionPayloadEnvelope) SizeSSZ() (size int) { - size = 80 +func (c *SignedExecutionPayloadBid) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} + +func (c *SignedExecutionPayloadBid) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 100 - // Field (0) 'Payload' - if e.Payload == nil { - e.Payload = new(v1.ExecutionPayloadGloas) + // Field 0: Message + if c.Message == nil { + c.Message = new(ExecutionPayloadBid) } - size += e.Payload.SizeSSZ() + dst = ssz.WriteOffset(dst, offset) + offset += c.Message.SizeSSZ() - // Field (1) 'ExecutionRequests' - if e.ExecutionRequests == nil { - e.ExecutionRequests = new(v1.ExecutionRequestsGloas) + // Field 1: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } - size += e.ExecutionRequests.SizeSSZ() + dst = append(dst, c.Signature...) - return + // Field 0: Message + if dst, err = c.Message.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Message: %w", err) + } + return dst, err } -// HashTreeRoot ssz hashes the ExecutionPayloadEnvelope object -func (e *ExecutionPayloadEnvelope) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(e) -} +func (c *SignedExecutionPayloadBid) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 100 { + return ssz.ErrSize + } -// HashTreeRootWith ssz hashes the ExecutionPayloadEnvelope object with a hasher -func (e *ExecutionPayloadEnvelope) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() + sszSlice1 := buf[4:100] // c.Signature - // Field (0) 'Payload' - if err = e.Payload.HashTreeRootWith(hh); err != nil { - return + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Message + if sszVarOffset0 != 100 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset0 > size { + return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:] // c.Message - // Field (1) 'ExecutionRequests' - if err = e.ExecutionRequests.HashTreeRootWith(hh); err != nil { - return + // Field 0: Message + c.Message = new(ExecutionPayloadBid) + if err = c.Message.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Message: %w", err) } - // Field (2) 'BuilderIndex' - ssz.PutUint(hh, e.BuilderIndex) + // Field 1: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice1...) + return err +} - // Field (3) 'BeaconBlockRoot' - if size := len(e.BeaconBlockRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.BeaconBlockRoot", size, 32) - return +func (c *SignedExecutionPayloadBid) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - hh.PutBytes(e.BeaconBlockRoot) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (4) 'ParentBeaconBlockRoot' - if size := len(e.ParentBeaconBlockRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentBeaconBlockRoot", size, 32) - return +func (c *SignedExecutionPayloadBid) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Message + if err := c.Message.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Message: %w", err) } - hh.PutBytes(e.ParentBeaconBlockRoot) - + // Field 1: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Signature) hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the SignedExecutionPayloadEnvelope object -func (s *SignedExecutionPayloadEnvelope) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) +func (c *SignedExecutionPayloadEnvelope) SizeSSZ() int { + size := 100 + if c.Message == nil { + c.Message = new(ExecutionPayloadEnvelope) + } + size += c.Message.SizeSSZ() + return size } -// MarshalSSZTo ssz marshals the SignedExecutionPayloadEnvelope object to a target array -func (s *SignedExecutionPayloadEnvelope) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(100) +func (c *SignedExecutionPayloadEnvelope) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Offset (0) 'Message' - dst = ssz.WriteOffset(dst, offset) - if s.Message == nil { - s.Message = new(ExecutionPayloadEnvelope) - } - offset += s.Message.SizeSSZ() +func (c *SignedExecutionPayloadEnvelope) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 100 - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 0: Message + if c.Message == nil { + c.Message = new(ExecutionPayloadEnvelope) } - dst = append(dst, s.Signature...) + dst = ssz.WriteOffset(dst, offset) + offset += c.Message.SizeSSZ() - // Field (0) 'Message' - if dst, err = s.Message.MarshalSSZTo(dst); err != nil { - return + // Field 1: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.Signature...) - return + // Field 0: Message + if dst, err = c.Message.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Message: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the SignedExecutionPayloadEnvelope object -func (s *SignedExecutionPayloadEnvelope) UnmarshalSSZ(buf []byte) error { +func (c *SignedExecutionPayloadEnvelope) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size < 100 { return ssz.ErrSize } - tail := buf - var o0 uint64 + sszSlice1 := buf[4:100] // c.Signature - // Offset (0) 'Message' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } - - if o0 != 100 { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Message + if sszVarOffset0 != 100 { return ssz.ErrInvalidVariableOffset } - - // Field (1) 'Signature' - if cap(s.Signature) == 0 { - s.Signature = make([]byte, 0, len(buf[4:100])) + if sszVarOffset0 > size { + return ssz.ErrOffset } - s.Signature = append(s.Signature, buf[4:100]...) + sszSlice0 := buf[sszVarOffset0:] // c.Message - // Field (0) 'Message' - { - buf = tail[o0:] - if s.Message == nil { - s.Message = new(ExecutionPayloadEnvelope) - } - if err = s.Message.UnmarshalSSZ(buf); err != nil { - return err - } + // Field 0: Message + c.Message = new(ExecutionPayloadEnvelope) + if err = c.Message.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Message: %w", err) } + + // Field 1: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice1...) return err } -// SizeSSZ returns the ssz encoded size in bytes for the SignedExecutionPayloadEnvelope object -func (s *SignedExecutionPayloadEnvelope) SizeSSZ() (size int) { - size = 100 - - // Field (0) 'Message' - if s.Message == nil { - s.Message = new(ExecutionPayloadEnvelope) +func (c *SignedExecutionPayloadEnvelope) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - size += s.Message.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the SignedExecutionPayloadEnvelope object -func (s *SignedExecutionPayloadEnvelope) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the SignedExecutionPayloadEnvelope object with a hasher -func (s *SignedExecutionPayloadEnvelope) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *SignedExecutionPayloadEnvelope) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Message' - if err = s.Message.HashTreeRootWith(hh); err != nil { - return + // Field 0: Message + if err := c.Message.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Message: %w", err) } - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 1: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength } - hh.PutBytes(s.Signature) - + hh.PutBytes(c.Signature) hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the BlindedExecutionPayloadEnvelope object -func (b *BlindedExecutionPayloadEnvelope) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) +func (c *SignedExecutionPayloadEnvelopeContents) SizeSSZ() int { + size := 12 + if c.SignedExecutionPayloadEnvelope == nil { + c.SignedExecutionPayloadEnvelope = new(SignedExecutionPayloadEnvelope) + } + size += c.SignedExecutionPayloadEnvelope.SizeSSZ() + size += len(c.KzgProofs) * 48 + size += len(c.Blobs) * 131072 + return size +} + +func (c *SignedExecutionPayloadEnvelopeContents) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the BlindedExecutionPayloadEnvelope object to a target array -func (b *BlindedExecutionPayloadEnvelope) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(148) +func (c *SignedExecutionPayloadEnvelopeContents) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 12 - // Field (0) 'BlockHash' - if size := len(b.BlockHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockHash", size, 32) - return + // Field 0: SignedExecutionPayloadEnvelope + if c.SignedExecutionPayloadEnvelope == nil { + c.SignedExecutionPayloadEnvelope = new(SignedExecutionPayloadEnvelope) } - dst = append(dst, b.BlockHash...) + dst = ssz.WriteOffset(dst, offset) + offset += c.SignedExecutionPayloadEnvelope.SizeSSZ() - // Offset (1) 'ExecutionRequests' + // Field 1: KzgProofs dst = ssz.WriteOffset(dst, offset) - if b.ExecutionRequests == nil { - b.ExecutionRequests = new(v1.ExecutionRequestsGloas) - } - offset += b.ExecutionRequests.SizeSSZ() + offset += len(c.KzgProofs) * 48 - // Field (2) 'BuilderIndex' - dst = ssz.MarshalUint(dst, b.BuilderIndex) + // Field 2: Blobs + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Blobs) * 131072 - // Field (3) 'BeaconBlockRoot' - if size := len(b.BeaconBlockRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.BeaconBlockRoot", size, 32) - return + // Field 0: SignedExecutionPayloadEnvelope + if dst, err = c.SignedExecutionPayloadEnvelope.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("SignedExecutionPayloadEnvelope: %w", err) } - dst = append(dst, b.BeaconBlockRoot...) - - // Field (4) 'Slot' - dst = ssz.MarshalUint(dst, b.Slot) - // Field (5) 'ParentBlockHash' - if size := len(b.ParentBlockHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentBlockHash", size, 32) - return + // Field 1: KzgProofs + if len(c.KzgProofs) > 33554432 { + return nil, ssz.ErrListTooBig } - dst = append(dst, b.ParentBlockHash...) - - // Field (6) 'ParentBeaconBlockRoot' - if size := len(b.ParentBeaconBlockRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentBeaconBlockRoot", size, 32) - return + for _, o := range c.KzgProofs { + if len(o) != 48 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) } - dst = append(dst, b.ParentBeaconBlockRoot...) - // Field (1) 'ExecutionRequests' - if dst, err = b.ExecutionRequests.MarshalSSZTo(dst); err != nil { - return + // Field 2: Blobs + if len(c.Blobs) > 4096 { + return nil, ssz.ErrListTooBig } - - return + for _, o := range c.Blobs { + if len(o) != 131072 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the BlindedExecutionPayloadEnvelope object -func (b *BlindedExecutionPayloadEnvelope) UnmarshalSSZ(buf []byte) error { +func (c *SignedExecutionPayloadEnvelopeContents) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 148 { + if size < 12 { return ssz.ErrSize } - tail := buf - var o1 uint64 - - // Field (0) 'BlockHash' - if cap(b.BlockHash) == 0 { - b.BlockHash = make([]byte, 0, len(buf[0:32])) + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.SignedExecutionPayloadEnvelope + if sszVarOffset0 != 12 { + return ssz.ErrInvalidVariableOffset } - b.BlockHash = append(b.BlockHash, buf[0:32]...) - - // Offset (1) 'ExecutionRequests' - if o1 = ssz.ReadOffset(buf[32:36]); o1 > size { + if sszVarOffset0 > size { return ssz.ErrOffset } - - if o1 != 148 { - return ssz.ErrInvalidVariableOffset + sszVarOffset1 := ssz.ReadOffset(buf[4:8]) // c.KzgProofs + if sszVarOffset1 > size || sszVarOffset1 < sszVarOffset0 { + return ssz.ErrOffset } - - // Field (2) 'BuilderIndex' - b.BuilderIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.BuilderIndex](buf[36:44]) - - // Field (3) 'BeaconBlockRoot' - if cap(b.BeaconBlockRoot) == 0 { - b.BeaconBlockRoot = make([]byte, 0, len(buf[44:76])) + sszVarOffset2 := ssz.ReadOffset(buf[8:12]) // c.Blobs + if sszVarOffset2 > size || sszVarOffset2 < sszVarOffset1 { + return ssz.ErrOffset } - b.BeaconBlockRoot = append(b.BeaconBlockRoot, buf[44:76]...) + sszSlice0 := buf[sszVarOffset0:sszVarOffset1] // c.SignedExecutionPayloadEnvelope + sszSlice1 := buf[sszVarOffset1:sszVarOffset2] // c.KzgProofs + sszSlice2 := buf[sszVarOffset2:] // c.Blobs - // Field (4) 'Slot' - b.Slot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[76:84]) - - // Field (5) 'ParentBlockHash' - if cap(b.ParentBlockHash) == 0 { - b.ParentBlockHash = make([]byte, 0, len(buf[84:116])) + // Field 0: SignedExecutionPayloadEnvelope + c.SignedExecutionPayloadEnvelope = new(SignedExecutionPayloadEnvelope) + if err = c.SignedExecutionPayloadEnvelope.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("SignedExecutionPayloadEnvelope: %w", err) } - b.ParentBlockHash = append(b.ParentBlockHash, buf[84:116]...) - // Field (6) 'ParentBeaconBlockRoot' - if cap(b.ParentBeaconBlockRoot) == 0 { - b.ParentBeaconBlockRoot = make([]byte, 0, len(buf[116:148])) + // Field 1: KzgProofs + { + if len(sszSlice1)%48 != 0 { + return fmt.Errorf("misaligned bytes: c.KzgProofs length is %d, which is not a multiple of 48: %w", len(sszSlice1), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice1) / 48 + if numElem > 33554432 { + return fmt.Errorf("ssz-max exceeded: c.KzgProofs has %d elements, ssz-max is 33554432: %w", numElem, ssz.ErrListTooBig) + } + c.KzgProofs = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte + + tmpSlice := sszSlice1[i*48 : (1+i)*48] + tmp = make([]byte, 0, 48) + tmp = append(tmp, tmpSlice...) + c.KzgProofs[i] = tmp + } } - b.ParentBeaconBlockRoot = append(b.ParentBeaconBlockRoot, buf[116:148]...) - // Field (1) 'ExecutionRequests' + // Field 2: Blobs { - buf = tail[o1:] - if b.ExecutionRequests == nil { - b.ExecutionRequests = new(v1.ExecutionRequestsGloas) + if len(sszSlice2)%131072 != 0 { + return fmt.Errorf("misaligned bytes: c.Blobs length is %d, which is not a multiple of 131072: %w", len(sszSlice2), ssz.ErrIncorrectListSize) } - if err = b.ExecutionRequests.UnmarshalSSZ(buf); err != nil { - return err + numElem := len(sszSlice2) / 131072 + if numElem > 4096 { + return fmt.Errorf("ssz-max exceeded: c.Blobs has %d elements, ssz-max is 4096: %w", numElem, ssz.ErrListTooBig) + } + c.Blobs = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte + + tmpSlice := sszSlice2[i*131072 : (1+i)*131072] + tmp = make([]byte, 0, 131072) + tmp = append(tmp, tmpSlice...) + c.Blobs[i] = tmp } } return err } -// SizeSSZ returns the ssz encoded size in bytes for the BlindedExecutionPayloadEnvelope object -func (b *BlindedExecutionPayloadEnvelope) SizeSSZ() (size int) { - size = 148 - - // Field (1) 'ExecutionRequests' - if b.ExecutionRequests == nil { - b.ExecutionRequests = new(v1.ExecutionRequestsGloas) +func (c *SignedExecutionPayloadEnvelopeContents) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - size += b.ExecutionRequests.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the BlindedExecutionPayloadEnvelope object -func (b *BlindedExecutionPayloadEnvelope) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the BlindedExecutionPayloadEnvelope object with a hasher -func (b *BlindedExecutionPayloadEnvelope) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *SignedExecutionPayloadEnvelopeContents) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'BlockHash' - if size := len(b.BlockHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockHash", size, 32) - return - } - hh.PutBytes(b.BlockHash) - - // Field (1) 'ExecutionRequests' - if err = b.ExecutionRequests.HashTreeRootWith(hh); err != nil { - return + // Field 0: SignedExecutionPayloadEnvelope + if err := c.SignedExecutionPayloadEnvelope.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("SignedExecutionPayloadEnvelope: %w", err) } - - // Field (2) 'BuilderIndex' - ssz.PutUint(hh, b.BuilderIndex) - - // Field (3) 'BeaconBlockRoot' - if size := len(b.BeaconBlockRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.BeaconBlockRoot", size, 32) - return + // Field 1: KzgProofs + { + if len(c.KzgProofs) > 33554432 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.KzgProofs { + if len(o) != 48 { + return ssz.ErrBytesLength + } + hh.PutBytes(o) + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.KzgProofs)), 33554432) } - hh.PutBytes(b.BeaconBlockRoot) - - // Field (4) 'Slot' - ssz.PutUint(hh, b.Slot) - - // Field (5) 'ParentBlockHash' - if size := len(b.ParentBlockHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentBlockHash", size, 32) - return + // Field 2: Blobs + { + if len(c.Blobs) > 4096 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.Blobs { + if len(o) != 131072 { + return ssz.ErrBytesLength + } + hh.PutBytes(o) + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Blobs)), 4096) } - hh.PutBytes(b.ParentBlockHash) + hh.Merkleize(indx) + return nil +} - // Field (6) 'ParentBeaconBlockRoot' - if size := len(b.ParentBeaconBlockRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentBeaconBlockRoot", size, 32) - return - } - hh.PutBytes(b.ParentBeaconBlockRoot) +func (c *SignedProposerPreferences) SizeSSZ() int { + size := 172 - hh.Merkleize(indx) - return + return size } -// MarshalSSZ ssz marshals the SignedBlindedExecutionPayloadEnvelope object -func (s *SignedBlindedExecutionPayloadEnvelope) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) +func (c *SignedProposerPreferences) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the SignedBlindedExecutionPayloadEnvelope object to a target array -func (s *SignedBlindedExecutionPayloadEnvelope) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(100) +func (c *SignedProposerPreferences) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Offset (0) 'Message' - dst = ssz.WriteOffset(dst, offset) - if s.Message == nil { - s.Message = new(BlindedExecutionPayloadEnvelope) + // Field 0: Message + if c.Message == nil { + c.Message = new(ProposerPreferences) } - offset += s.Message.SizeSSZ() - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + if dst, err = c.Message.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Message: %w", err) } - dst = append(dst, s.Signature...) - // Field (0) 'Message' - if dst, err = s.Message.MarshalSSZTo(dst); err != nil { - return + // Field 1: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.Signature...) - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the SignedBlindedExecutionPayloadEnvelope object -func (s *SignedBlindedExecutionPayloadEnvelope) UnmarshalSSZ(buf []byte) error { +func (c *SignedProposerPreferences) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 100 { + if size != 172 { return ssz.ErrSize } - tail := buf - var o0 uint64 - - // Offset (0) 'Message' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } - - if o0 != 100 { - return ssz.ErrInvalidVariableOffset - } + sszSlice0 := buf[0:76] // c.Message + sszSlice1 := buf[76:172] // c.Signature - // Field (1) 'Signature' - if cap(s.Signature) == 0 { - s.Signature = make([]byte, 0, len(buf[4:100])) + // Field 0: Message + c.Message = new(ProposerPreferences) + if err = c.Message.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Message: %w", err) } - s.Signature = append(s.Signature, buf[4:100]...) - // Field (0) 'Message' - { - buf = tail[o0:] - if s.Message == nil { - s.Message = new(BlindedExecutionPayloadEnvelope) - } - if err = s.Message.UnmarshalSSZ(buf); err != nil { - return err - } - } + // Field 1: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice1...) return err } -// SizeSSZ returns the ssz encoded size in bytes for the SignedBlindedExecutionPayloadEnvelope object -func (s *SignedBlindedExecutionPayloadEnvelope) SizeSSZ() (size int) { - size = 100 - - // Field (0) 'Message' - if s.Message == nil { - s.Message = new(BlindedExecutionPayloadEnvelope) +func (c *SignedProposerPreferences) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - size += s.Message.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the SignedBlindedExecutionPayloadEnvelope object -func (s *SignedBlindedExecutionPayloadEnvelope) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the SignedBlindedExecutionPayloadEnvelope object with a hasher -func (s *SignedBlindedExecutionPayloadEnvelope) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *SignedProposerPreferences) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Message' - if err = s.Message.HashTreeRootWith(hh); err != nil { - return + // Field 0: Message + if err := c.Message.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Message: %w", err) } - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 1: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength } - hh.PutBytes(s.Signature) - + hh.PutBytes(c.Signature) hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the Builder object -func (b *Builder) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) +func (c *SignedRequestAuthV1) SizeSSZ() int { + size := 100 + if c.Message == nil { + c.Message = new(RequestAuthV1) + } + size += c.Message.SizeSSZ() + return size } -// MarshalSSZTo ssz marshals the Builder object to a target array -func (b *Builder) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *SignedRequestAuthV1) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (0) 'Pubkey' - if size := len(b.Pubkey); size != 48 { - err = ssz.ErrBytesLengthFn("--.Pubkey", size, 48) - return - } - dst = append(dst, b.Pubkey...) +func (c *SignedRequestAuthV1) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 100 - // Field (1) 'Version' - if size := len(b.Version); size != 1 { - err = ssz.ErrBytesLengthFn("--.Version", size, 1) - return + // Field 0: Message + if c.Message == nil { + c.Message = new(RequestAuthV1) } - dst = append(dst, b.Version...) + dst = ssz.WriteOffset(dst, offset) + offset += c.Message.SizeSSZ() - // Field (2) 'ExecutionAddress' - if size := len(b.ExecutionAddress); size != 20 { - err = ssz.ErrBytesLengthFn("--.ExecutionAddress", size, 20) - return + // Field 1: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.ExecutionAddress...) + dst = append(dst, c.Signature...) - // Field (3) 'Balance' - dst = ssz.MarshalUint(dst, b.Balance) - - // Field (4) 'DepositEpoch' - dst = ssz.MarshalUint(dst, b.DepositEpoch) - - // Field (5) 'WithdrawableEpoch' - dst = ssz.MarshalUint(dst, b.WithdrawableEpoch) - - return + // Field 0: Message + if dst, err = c.Message.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Message: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the Builder object -func (b *Builder) UnmarshalSSZ(buf []byte) error { +func (c *SignedRequestAuthV1) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 93 { + if size < 100 { return ssz.ErrSize } - // Field (0) 'Pubkey' - if cap(b.Pubkey) == 0 { - b.Pubkey = make([]byte, 0, len(buf[0:48])) - } - b.Pubkey = append(b.Pubkey, buf[0:48]...) + sszSlice1 := buf[4:100] // c.Signature - // Field (1) 'Version' - if cap(b.Version) == 0 { - b.Version = make([]byte, 0, len(buf[48:49])) + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Message + if sszVarOffset0 != 100 { + return ssz.ErrInvalidVariableOffset } - b.Version = append(b.Version, buf[48:49]...) - - // Field (2) 'ExecutionAddress' - if cap(b.ExecutionAddress) == 0 { - b.ExecutionAddress = make([]byte, 0, len(buf[49:69])) + if sszVarOffset0 > size { + return ssz.ErrOffset } - b.ExecutionAddress = append(b.ExecutionAddress, buf[49:69]...) - - // Field (3) 'Balance' - b.Balance = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Gwei](buf[69:77]) - - // Field (4) 'DepositEpoch' - b.DepositEpoch = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Epoch](buf[77:85]) + sszSlice0 := buf[sszVarOffset0:] // c.Message - // Field (5) 'WithdrawableEpoch' - b.WithdrawableEpoch = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Epoch](buf[85:93]) + // Field 0: Message + c.Message = new(RequestAuthV1) + if err = c.Message.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Message: %w", err) + } + // Field 1: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice1...) return err } -// SizeSSZ returns the ssz encoded size in bytes for the Builder object -func (b *Builder) SizeSSZ() (size int) { - size = 93 - return -} - -// HashTreeRoot ssz hashes the Builder object -func (b *Builder) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) +func (c *SignedRequestAuthV1) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the Builder object with a hasher -func (b *Builder) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *SignedRequestAuthV1) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Pubkey' - if size := len(b.Pubkey); size != 48 { - err = ssz.ErrBytesLengthFn("--.Pubkey", size, 48) - return - } - hh.PutBytes(b.Pubkey) - - // Field (1) 'Version' - if size := len(b.Version); size != 1 { - err = ssz.ErrBytesLengthFn("--.Version", size, 1) - return + // Field 0: Message + if err := c.Message.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Message: %w", err) } - hh.PutBytes(b.Version) - - // Field (2) 'ExecutionAddress' - if size := len(b.ExecutionAddress); size != 20 { - err = ssz.ErrBytesLengthFn("--.ExecutionAddress", size, 20) - return + // Field 1: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength } - hh.PutBytes(b.ExecutionAddress) - - // Field (3) 'Balance' - ssz.PutUint(hh, b.Balance) - - // Field (4) 'DepositEpoch' - ssz.PutUint(hh, b.DepositEpoch) - - // Field (5) 'WithdrawableEpoch' - ssz.PutUint(hh, b.WithdrawableEpoch) - + hh.PutBytes(c.Signature) hh.Merkleize(indx) - return + return nil } diff --git a/proto/prysm/v1alpha1/gloas.yaml b/proto/prysm/v1alpha1/gloas.yaml new file mode 100644 index 000000000000..d96107eb343c --- /dev/null +++ b/proto/prysm/v1alpha1/gloas.yaml @@ -0,0 +1,33 @@ +package: "github.com/OffchainLabs/prysm/v7/proto/prysm/v1alpha1" +types: + - name: "AttestationGloas" + - name: "AggregateAttestationAndProofGloas" + - name: "SignedAggregateAttestationAndProofGloas" + - name: "AttesterSlashingGloas" + - name: "BeaconBlockBodyGloas" + - name: "BeaconBlockContentsGloas" + - name: "BeaconBlockGloas" + - name: "BeaconStateGloas" + - name: "BlindedExecutionPayloadEnvelope" + - name: "Builder" + - name: "BuilderPendingPayment" + - name: "BuilderPendingWithdrawal" + - name: "BuilderPreferencesRequestV1" + - name: "BuilderPreferencesV1" + - name: "DataColumnSidecarGloas" + - name: "ExecutionPayloadBid" + - name: "ExecutionPayloadEnvelope" + - name: "IndexedAttestationGloas" + - name: "PayloadAttestation" + - name: "PayloadAttestationData" + - name: "PayloadAttestationMessage" + - name: "ProposerPreferences" + - name: "PTCs" + - name: "RequestAuthV1" + - name: "SignedBeaconBlockGloas" + - name: "SignedBlindedExecutionPayloadEnvelope" + - name: "SignedExecutionPayloadBid" + - name: "SignedExecutionPayloadEnvelope" + - name: "SignedExecutionPayloadEnvelopeContents" + - name: "SignedProposerPreferences" + - name: "SignedRequestAuthV1" diff --git a/proto/prysm/v1alpha1/gloas_builder_api.ssz.go b/proto/prysm/v1alpha1/gloas_builder_api.ssz.go deleted file mode 100644 index 78618ca2612a..000000000000 --- a/proto/prysm/v1alpha1/gloas_builder_api.ssz.go +++ /dev/null @@ -1,379 +0,0 @@ -// Code generated by fastssz. DO NOT EDIT. -package eth - -import ( - github_com_OffchainLabs_prysm_v7_consensus_types_primitives "github.com/OffchainLabs/prysm/v7/consensus-types/primitives" - ssz "github.com/prysmaticlabs/fastssz" -) - -// MarshalSSZ ssz marshals the RequestAuthV1 object -func (r *RequestAuthV1) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(r) -} - -// MarshalSSZTo ssz marshals the RequestAuthV1 object to a target array -func (r *RequestAuthV1) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(12) - - // Offset (0) 'Data' - dst = ssz.WriteOffset(dst, offset) - offset += len(r.Data) - - // Field (1) 'Slot' - dst = ssz.MarshalUint(dst, r.Slot) - - // Field (0) 'Data' - if size := len(r.Data); size > 4096 { - err = ssz.ErrBytesLengthFn("--.Data", size, 4096) - return - } - dst = append(dst, r.Data...) - - return -} - -// UnmarshalSSZ ssz unmarshals the RequestAuthV1 object -func (r *RequestAuthV1) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 12 { - return ssz.ErrSize - } - - tail := buf - var o0 uint64 - - // Offset (0) 'Data' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } - - if o0 != 12 { - return ssz.ErrInvalidVariableOffset - } - - // Field (1) 'Slot' - r.Slot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[4:12]) - - // Field (0) 'Data' - { - buf = tail[o0:] - if len(buf) > 4096 { - return ssz.ErrBytesLength - } - if cap(r.Data) == 0 { - r.Data = make([]byte, 0, len(buf)) - } - r.Data = append(r.Data, buf...) - } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the RequestAuthV1 object -func (r *RequestAuthV1) SizeSSZ() (size int) { - size = 12 - - // Field (0) 'Data' - size += len(r.Data) - - return -} - -// HashTreeRoot ssz hashes the RequestAuthV1 object -func (r *RequestAuthV1) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(r) -} - -// HashTreeRootWith ssz hashes the RequestAuthV1 object with a hasher -func (r *RequestAuthV1) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'Data' - { - elemIndx := hh.Index() - byteLen := uint64(len(r.Data)) - if byteLen > 4096 { - err = ssz.ErrIncorrectListSize - return - } - hh.AppendBytes32(r.Data) - hh.MerkleizeWithMixin(elemIndx, byteLen, (4096+31)/32) - } - - // Field (1) 'Slot' - ssz.PutUint(hh, r.Slot) - - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the SignedRequestAuthV1 object -func (s *SignedRequestAuthV1) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) -} - -// MarshalSSZTo ssz marshals the SignedRequestAuthV1 object to a target array -func (s *SignedRequestAuthV1) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(100) - - // Offset (0) 'Message' - dst = ssz.WriteOffset(dst, offset) - if s.Message == nil { - s.Message = new(RequestAuthV1) - } - offset += s.Message.SizeSSZ() - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return - } - dst = append(dst, s.Signature...) - - // Field (0) 'Message' - if dst, err = s.Message.MarshalSSZTo(dst); err != nil { - return - } - - return -} - -// UnmarshalSSZ ssz unmarshals the SignedRequestAuthV1 object -func (s *SignedRequestAuthV1) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 100 { - return ssz.ErrSize - } - - tail := buf - var o0 uint64 - - // Offset (0) 'Message' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } - - if o0 != 100 { - return ssz.ErrInvalidVariableOffset - } - - // Field (1) 'Signature' - if cap(s.Signature) == 0 { - s.Signature = make([]byte, 0, len(buf[4:100])) - } - s.Signature = append(s.Signature, buf[4:100]...) - - // Field (0) 'Message' - { - buf = tail[o0:] - if s.Message == nil { - s.Message = new(RequestAuthV1) - } - if err = s.Message.UnmarshalSSZ(buf); err != nil { - return err - } - } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the SignedRequestAuthV1 object -func (s *SignedRequestAuthV1) SizeSSZ() (size int) { - size = 100 - - // Field (0) 'Message' - if s.Message == nil { - s.Message = new(RequestAuthV1) - } - size += s.Message.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the SignedRequestAuthV1 object -func (s *SignedRequestAuthV1) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) -} - -// HashTreeRootWith ssz hashes the SignedRequestAuthV1 object with a hasher -func (s *SignedRequestAuthV1) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'Message' - if err = s.Message.HashTreeRootWith(hh); err != nil { - return - } - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return - } - hh.PutBytes(s.Signature) - - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the BuilderPreferencesV1 object -func (b *BuilderPreferencesV1) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} - -// MarshalSSZTo ssz marshals the BuilderPreferencesV1 object to a target array -func (b *BuilderPreferencesV1) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - - // Field (0) 'MaxExecutionPayment' - dst = ssz.MarshalUint(dst, b.MaxExecutionPayment) - - return -} - -// UnmarshalSSZ ssz unmarshals the BuilderPreferencesV1 object -func (b *BuilderPreferencesV1) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size != 8 { - return ssz.ErrSize - } - - // Field (0) 'MaxExecutionPayment' - b.MaxExecutionPayment = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Gwei](buf[0:8]) - - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the BuilderPreferencesV1 object -func (b *BuilderPreferencesV1) SizeSSZ() (size int) { - size = 8 - return -} - -// HashTreeRoot ssz hashes the BuilderPreferencesV1 object -func (b *BuilderPreferencesV1) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) -} - -// HashTreeRootWith ssz hashes the BuilderPreferencesV1 object with a hasher -func (b *BuilderPreferencesV1) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'MaxExecutionPayment' - ssz.PutUint(hh, b.MaxExecutionPayment) - - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the BuilderPreferencesRequestV1 object -func (b *BuilderPreferencesRequestV1) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} - -// MarshalSSZTo ssz marshals the BuilderPreferencesRequestV1 object to a target array -func (b *BuilderPreferencesRequestV1) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(12) - - // Field (0) 'Preferences' - if b.Preferences == nil { - b.Preferences = new(BuilderPreferencesV1) - } - if dst, err = b.Preferences.MarshalSSZTo(dst); err != nil { - return - } - - // Offset (1) 'Auth' - dst = ssz.WriteOffset(dst, offset) - if b.Auth == nil { - b.Auth = new(SignedRequestAuthV1) - } - offset += b.Auth.SizeSSZ() - - // Field (1) 'Auth' - if dst, err = b.Auth.MarshalSSZTo(dst); err != nil { - return - } - - return -} - -// UnmarshalSSZ ssz unmarshals the BuilderPreferencesRequestV1 object -func (b *BuilderPreferencesRequestV1) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 12 { - return ssz.ErrSize - } - - tail := buf - var o1 uint64 - - // Field (0) 'Preferences' - if b.Preferences == nil { - b.Preferences = new(BuilderPreferencesV1) - } - if err = b.Preferences.UnmarshalSSZ(buf[0:8]); err != nil { - return err - } - - // Offset (1) 'Auth' - if o1 = ssz.ReadOffset(buf[8:12]); o1 > size { - return ssz.ErrOffset - } - - if o1 != 12 { - return ssz.ErrInvalidVariableOffset - } - - // Field (1) 'Auth' - { - buf = tail[o1:] - if b.Auth == nil { - b.Auth = new(SignedRequestAuthV1) - } - if err = b.Auth.UnmarshalSSZ(buf); err != nil { - return err - } - } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the BuilderPreferencesRequestV1 object -func (b *BuilderPreferencesRequestV1) SizeSSZ() (size int) { - size = 12 - - // Field (1) 'Auth' - if b.Auth == nil { - b.Auth = new(SignedRequestAuthV1) - } - size += b.Auth.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the BuilderPreferencesRequestV1 object -func (b *BuilderPreferencesRequestV1) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) -} - -// HashTreeRootWith ssz hashes the BuilderPreferencesRequestV1 object with a hasher -func (b *BuilderPreferencesRequestV1) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'Preferences' - if err = b.Preferences.HashTreeRootWith(hh); err != nil { - return - } - - // Field (1) 'Auth' - if err = b.Auth.HashTreeRootWith(hh); err != nil { - return - } - - hh.Merkleize(indx) - return -} diff --git a/proto/prysm/v1alpha1/metadata/BUILD.bazel b/proto/prysm/v1alpha1/metadata/BUILD.bazel index 81c3480e0748..77ca73c25179 100644 --- a/proto/prysm/v1alpha1/metadata/BUILD.bazel +++ b/proto/prysm/v1alpha1/metadata/BUILD.bazel @@ -7,7 +7,7 @@ go_library( visibility = ["//visibility:public"], deps = [ "//proto/prysm/v1alpha1:go_default_library", - "@com_github_prysmaticlabs_fastssz//:go_default_library", + "@com_github_offchainlabs_methodical_ssz//ssz:go_default_library", "@com_github_prysmaticlabs_go_bitfield//:go_default_library", ], ) diff --git a/proto/prysm/v1alpha1/metadata/metadata_interfaces.go b/proto/prysm/v1alpha1/metadata/metadata_interfaces.go index d2a04e5cf0cc..e399b23a4a64 100644 --- a/proto/prysm/v1alpha1/metadata/metadata_interfaces.go +++ b/proto/prysm/v1alpha1/metadata/metadata_interfaces.go @@ -2,8 +2,8 @@ package metadata import ( "github.com/OffchainLabs/go-bitfield" + "github.com/OffchainLabs/methodical-ssz/ssz" pb "github.com/OffchainLabs/prysm/v7/proto/prysm/v1alpha1" - ssz "github.com/prysmaticlabs/fastssz" ) // Metadata returns the interface of a p2p metadata type. diff --git a/proto/prysm/v1alpha1/non-core.minimal.ssz.go b/proto/prysm/v1alpha1/non-core.minimal.ssz.go new file mode 100644 index 000000000000..4e64d69e14d5 --- /dev/null +++ b/proto/prysm/v1alpha1/non-core.minimal.ssz.go @@ -0,0 +1,1212 @@ +//go:build minimal + +package eth + +import ( + binary "encoding/binary" + "fmt" + go_bitfield "github.com/OffchainLabs/go-bitfield" + ssz "github.com/OffchainLabs/methodical-ssz/ssz" + v1 "github.com/OffchainLabs/prysm/v7/proto/engine/v1" +) + +func (c *BeaconBlocksByRangeRequest) SizeSSZ() int { + size := 24 + + return size +} + +func (c *BeaconBlocksByRangeRequest) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} + +func (c *BeaconBlocksByRangeRequest) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + + // Field 0: StartSlot + if dst, err = c.StartSlot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("StartSlot: %w", err) + } + + // Field 1: Count + dst = binary.LittleEndian.AppendUint64(dst, c.Count) + + // Field 2: Step + dst = binary.LittleEndian.AppendUint64(dst, c.Step) + + return dst, err +} + +func (c *BeaconBlocksByRangeRequest) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 24 { + return ssz.ErrSize + } + + sszSlice0 := buf[0:8] // c.StartSlot + sszSlice1 := buf[8:16] // c.Count + sszSlice2 := buf[16:24] // c.Step + + // Field 0: StartSlot + if err = c.StartSlot.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("StartSlot: %w", err) + } + + // Field 1: Count + c.Count = binary.LittleEndian.Uint64(sszSlice1) + + // Field 2: Step + c.Step = binary.LittleEndian.Uint64(sszSlice2) + return err +} + +func (c *BeaconBlocksByRangeRequest) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} + +func (c *BeaconBlocksByRangeRequest) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: StartSlot + if err := c.StartSlot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("StartSlot: %w", err) + } + // Field 1: Count + hh.PutUint64(c.Count) + // Field 2: Step + hh.PutUint64(c.Step) + hh.Merkleize(indx) + return nil +} + +func (c *BlobSidecarsByRangeRequest) SizeSSZ() int { + size := 16 + + return size +} + +func (c *BlobSidecarsByRangeRequest) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} + +func (c *BlobSidecarsByRangeRequest) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + + // Field 0: StartSlot + if dst, err = c.StartSlot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("StartSlot: %w", err) + } + + // Field 1: Count + dst = binary.LittleEndian.AppendUint64(dst, c.Count) + + return dst, err +} + +func (c *BlobSidecarsByRangeRequest) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 16 { + return ssz.ErrSize + } + + sszSlice0 := buf[0:8] // c.StartSlot + sszSlice1 := buf[8:16] // c.Count + + // Field 0: StartSlot + if err = c.StartSlot.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("StartSlot: %w", err) + } + + // Field 1: Count + c.Count = binary.LittleEndian.Uint64(sszSlice1) + return err +} + +func (c *BlobSidecarsByRangeRequest) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} + +func (c *BlobSidecarsByRangeRequest) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: StartSlot + if err := c.StartSlot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("StartSlot: %w", err) + } + // Field 1: Count + hh.PutUint64(c.Count) + hh.Merkleize(indx) + return nil +} + +func (c *BuilderBid) SizeSSZ() int { + size := 84 + if c.Header == nil { + c.Header = new(v1.ExecutionPayloadHeader) + } + size += c.Header.SizeSSZ() + return size +} + +func (c *BuilderBid) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} + +func (c *BuilderBid) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 84 + + // Field 0: Header + if c.Header == nil { + c.Header = new(v1.ExecutionPayloadHeader) + } + dst = ssz.WriteOffset(dst, offset) + offset += c.Header.SizeSSZ() + + // Field 1: Value + if len(c.Value) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.Value...) + + // Field 2: Pubkey + if len(c.Pubkey) != 48 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.Pubkey...) + + // Field 0: Header + if dst, err = c.Header.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Header: %w", err) + } + return dst, err +} + +func (c *BuilderBid) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 84 { + return ssz.ErrSize + } + + sszSlice1 := buf[4:36] // c.Value + sszSlice2 := buf[36:84] // c.Pubkey + + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Header + if sszVarOffset0 != 84 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset0 > size { + return ssz.ErrOffset + } + sszSlice0 := buf[sszVarOffset0:] // c.Header + + // Field 0: Header + c.Header = new(v1.ExecutionPayloadHeader) + if err = c.Header.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Header: %w", err) + } + + // Field 1: Value + c.Value = make([]byte, 0, 32) + c.Value = append(c.Value, sszSlice1...) + + // Field 2: Pubkey + c.Pubkey = make([]byte, 0, 48) + c.Pubkey = append(c.Pubkey, sszSlice2...) + return err +} + +func (c *BuilderBid) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} + +func (c *BuilderBid) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Header + if err := c.Header.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Header: %w", err) + } + // Field 1: Value + if len(c.Value) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Value) + // Field 2: Pubkey + if len(c.Pubkey) != 48 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Pubkey) + hh.Merkleize(indx) + return nil +} + +func (c *DataColumnSidecarsByRangeRequest) SizeSSZ() int { + size := 20 + size += len(c.Columns) * 8 + return size +} + +func (c *DataColumnSidecarsByRangeRequest) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} + +func (c *DataColumnSidecarsByRangeRequest) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 20 + + // Field 0: StartSlot + if dst, err = c.StartSlot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("StartSlot: %w", err) + } + + // Field 1: Count + dst = binary.LittleEndian.AppendUint64(dst, c.Count) + + // Field 2: Columns + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Columns) * 8 + + // Field 2: Columns + if len(c.Columns) > 128 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.Columns { + dst = binary.LittleEndian.AppendUint64(dst, o) + } + return dst, err +} + +func (c *DataColumnSidecarsByRangeRequest) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 20 { + return ssz.ErrSize + } + + sszSlice0 := buf[0:8] // c.StartSlot + sszSlice1 := buf[8:16] // c.Count + + sszVarOffset2 := ssz.ReadOffset(buf[16:20]) // c.Columns + if sszVarOffset2 != 20 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset2 > size { + return ssz.ErrOffset + } + sszSlice2 := buf[sszVarOffset2:] // c.Columns + + // Field 0: StartSlot + if err = c.StartSlot.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("StartSlot: %w", err) + } + + // Field 1: Count + c.Count = binary.LittleEndian.Uint64(sszSlice1) + + // Field 2: Columns + { + if len(sszSlice2)%8 != 0 { + return fmt.Errorf("misaligned bytes: c.Columns length is %d, which is not a multiple of 8: %w", len(sszSlice2), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice2) / 8 + if numElem > 128 { + return fmt.Errorf("ssz-max exceeded: c.Columns has %d elements, ssz-max is 128: %w", numElem, ssz.ErrListTooBig) + } + c.Columns = make([]uint64, numElem) + for i := 0; i < numElem; i++ { + var tmp uint64 + + tmpSlice := sszSlice2[i*8 : (1+i)*8] + tmp = binary.LittleEndian.Uint64(tmpSlice) + c.Columns[i] = tmp + } + } + return err +} + +func (c *DataColumnSidecarsByRangeRequest) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} + +func (c *DataColumnSidecarsByRangeRequest) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: StartSlot + if err := c.StartSlot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("StartSlot: %w", err) + } + // Field 1: Count + hh.PutUint64(c.Count) + // Field 2: Columns + { + if len(c.Columns) > 128 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.Columns { + hh.AppendUint64(o) + } + hh.FillUpTo32() + numItems := uint64(len(c.Columns)) + hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(128, numItems, 8)) + } + hh.Merkleize(indx) + return nil +} + +func (c *DepositSnapshot) SizeSSZ() int { + size := 84 + size += len(c.Finalized) * 32 + return size +} + +func (c *DepositSnapshot) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} + +func (c *DepositSnapshot) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 84 + + // Field 0: Finalized + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Finalized) * 32 + + // Field 1: DepositRoot + if len(c.DepositRoot) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.DepositRoot...) + + // Field 2: DepositCount + dst = binary.LittleEndian.AppendUint64(dst, c.DepositCount) + + // Field 3: ExecutionHash + if len(c.ExecutionHash) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.ExecutionHash...) + + // Field 4: ExecutionDepth + dst = binary.LittleEndian.AppendUint64(dst, c.ExecutionDepth) + + // Field 0: Finalized + if len(c.Finalized) > 32 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.Finalized { + if len(o) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) + } + return dst, err +} + +func (c *DepositSnapshot) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 84 { + return ssz.ErrSize + } + + sszSlice1 := buf[4:36] // c.DepositRoot + sszSlice2 := buf[36:44] // c.DepositCount + sszSlice3 := buf[44:76] // c.ExecutionHash + sszSlice4 := buf[76:84] // c.ExecutionDepth + + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Finalized + if sszVarOffset0 != 84 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset0 > size { + return ssz.ErrOffset + } + sszSlice0 := buf[sszVarOffset0:] // c.Finalized + + // Field 0: Finalized + { + if len(sszSlice0)%32 != 0 { + return fmt.Errorf("misaligned bytes: c.Finalized length is %d, which is not a multiple of 32: %w", len(sszSlice0), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice0) / 32 + if numElem > 32 { + return fmt.Errorf("ssz-max exceeded: c.Finalized has %d elements, ssz-max is 32: %w", numElem, ssz.ErrListTooBig) + } + c.Finalized = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte + + tmpSlice := sszSlice0[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.Finalized[i] = tmp + } + } + + // Field 1: DepositRoot + c.DepositRoot = make([]byte, 0, 32) + c.DepositRoot = append(c.DepositRoot, sszSlice1...) + + // Field 2: DepositCount + c.DepositCount = binary.LittleEndian.Uint64(sszSlice2) + + // Field 3: ExecutionHash + c.ExecutionHash = make([]byte, 0, 32) + c.ExecutionHash = append(c.ExecutionHash, sszSlice3...) + + // Field 4: ExecutionDepth + c.ExecutionDepth = binary.LittleEndian.Uint64(sszSlice4) + return err +} + +func (c *DepositSnapshot) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} + +func (c *DepositSnapshot) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Finalized + { + if len(c.Finalized) > 32 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.Finalized { + if len(o) != 32 { + return ssz.ErrBytesLength + } + hh.Append(o) + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Finalized)), 32) + } + // Field 1: DepositRoot + if len(c.DepositRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.DepositRoot) + // Field 2: DepositCount + hh.PutUint64(c.DepositCount) + // Field 3: ExecutionHash + if len(c.ExecutionHash) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ExecutionHash) + // Field 4: ExecutionDepth + hh.PutUint64(c.ExecutionDepth) + hh.Merkleize(indx) + return nil +} + +func (c *ExecutionPayloadEnvelopesByRangeRequest) SizeSSZ() int { + size := 16 + + return size +} + +func (c *ExecutionPayloadEnvelopesByRangeRequest) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} + +func (c *ExecutionPayloadEnvelopesByRangeRequest) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + + // Field 0: StartSlot + if dst, err = c.StartSlot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("StartSlot: %w", err) + } + + // Field 1: Count + dst = binary.LittleEndian.AppendUint64(dst, c.Count) + + return dst, err +} + +func (c *ExecutionPayloadEnvelopesByRangeRequest) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 16 { + return ssz.ErrSize + } + + sszSlice0 := buf[0:8] // c.StartSlot + sszSlice1 := buf[8:16] // c.Count + + // Field 0: StartSlot + if err = c.StartSlot.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("StartSlot: %w", err) + } + + // Field 1: Count + c.Count = binary.LittleEndian.Uint64(sszSlice1) + return err +} + +func (c *ExecutionPayloadEnvelopesByRangeRequest) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} + +func (c *ExecutionPayloadEnvelopesByRangeRequest) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: StartSlot + if err := c.StartSlot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("StartSlot: %w", err) + } + // Field 1: Count + hh.PutUint64(c.Count) + hh.Merkleize(indx) + return nil +} + +func (c *MetaDataV0) SizeSSZ() int { + size := 16 + + return size +} + +func (c *MetaDataV0) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} + +func (c *MetaDataV0) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + + // Field 0: SeqNumber + dst = binary.LittleEndian.AppendUint64(dst, c.SeqNumber) + + // Field 1: Attnets + if len([]byte(c.Attnets)) != 8 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, []byte(c.Attnets)...) + + return dst, err +} + +func (c *MetaDataV0) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 16 { + return ssz.ErrSize + } + + sszSlice0 := buf[0:8] // c.SeqNumber + sszSlice1 := buf[8:16] // c.Attnets + + // Field 0: SeqNumber + c.SeqNumber = binary.LittleEndian.Uint64(sszSlice0) + + // Field 1: Attnets + c.Attnets = make([]byte, 0, 8) + c.Attnets = append(c.Attnets, go_bitfield.Bitvector64(sszSlice1)...) + return err +} + +func (c *MetaDataV0) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} + +func (c *MetaDataV0) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: SeqNumber + hh.PutUint64(c.SeqNumber) + // Field 1: Attnets + if len([]byte(c.Attnets)) != 8 { + return ssz.ErrBytesLength + } + hh.PutBytes([]byte(c.Attnets)) + hh.Merkleize(indx) + return nil +} + +func (c *MetaDataV1) SizeSSZ() int { + size := 17 + + return size +} + +func (c *MetaDataV1) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} + +func (c *MetaDataV1) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + + // Field 0: SeqNumber + dst = binary.LittleEndian.AppendUint64(dst, c.SeqNumber) + + // Field 1: Attnets + if len([]byte(c.Attnets)) != 8 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, []byte(c.Attnets)...) + + // Field 2: Syncnets + if len([]byte(c.Syncnets)) != 1 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, []byte(c.Syncnets)...) + + return dst, err +} + +func (c *MetaDataV1) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 17 { + return ssz.ErrSize + } + + sszSlice0 := buf[0:8] // c.SeqNumber + sszSlice1 := buf[8:16] // c.Attnets + sszSlice2 := buf[16:17] // c.Syncnets + + // Field 0: SeqNumber + c.SeqNumber = binary.LittleEndian.Uint64(sszSlice0) + + // Field 1: Attnets + c.Attnets = make([]byte, 0, 8) + c.Attnets = append(c.Attnets, go_bitfield.Bitvector64(sszSlice1)...) + + // Field 2: Syncnets + c.Syncnets = make([]byte, 0, 1) + c.Syncnets = append(c.Syncnets, go_bitfield.Bitvector4(sszSlice2)...) + return err +} + +func (c *MetaDataV1) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} + +func (c *MetaDataV1) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: SeqNumber + hh.PutUint64(c.SeqNumber) + // Field 1: Attnets + if len([]byte(c.Attnets)) != 8 { + return ssz.ErrBytesLength + } + hh.PutBytes([]byte(c.Attnets)) + // Field 2: Syncnets + if len([]byte(c.Syncnets)) != 1 { + return ssz.ErrBytesLength + } + hh.PutBytes([]byte(c.Syncnets)) + hh.Merkleize(indx) + return nil +} + +func (c *MetaDataV2) SizeSSZ() int { + size := 25 + + return size +} + +func (c *MetaDataV2) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} + +func (c *MetaDataV2) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + + // Field 0: SeqNumber + dst = binary.LittleEndian.AppendUint64(dst, c.SeqNumber) + + // Field 1: Attnets + if len([]byte(c.Attnets)) != 8 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, []byte(c.Attnets)...) + + // Field 2: Syncnets + if len([]byte(c.Syncnets)) != 1 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, []byte(c.Syncnets)...) + + // Field 3: CustodyGroupCount + dst = binary.LittleEndian.AppendUint64(dst, c.CustodyGroupCount) + + return dst, err +} + +func (c *MetaDataV2) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 25 { + return ssz.ErrSize + } + + sszSlice0 := buf[0:8] // c.SeqNumber + sszSlice1 := buf[8:16] // c.Attnets + sszSlice2 := buf[16:17] // c.Syncnets + sszSlice3 := buf[17:25] // c.CustodyGroupCount + + // Field 0: SeqNumber + c.SeqNumber = binary.LittleEndian.Uint64(sszSlice0) + + // Field 1: Attnets + c.Attnets = make([]byte, 0, 8) + c.Attnets = append(c.Attnets, go_bitfield.Bitvector64(sszSlice1)...) + + // Field 2: Syncnets + c.Syncnets = make([]byte, 0, 1) + c.Syncnets = append(c.Syncnets, go_bitfield.Bitvector4(sszSlice2)...) + + // Field 3: CustodyGroupCount + c.CustodyGroupCount = binary.LittleEndian.Uint64(sszSlice3) + return err +} + +func (c *MetaDataV2) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} + +func (c *MetaDataV2) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: SeqNumber + hh.PutUint64(c.SeqNumber) + // Field 1: Attnets + if len([]byte(c.Attnets)) != 8 { + return ssz.ErrBytesLength + } + hh.PutBytes([]byte(c.Attnets)) + // Field 2: Syncnets + if len([]byte(c.Syncnets)) != 1 { + return ssz.ErrBytesLength + } + hh.PutBytes([]byte(c.Syncnets)) + // Field 3: CustodyGroupCount + hh.PutUint64(c.CustodyGroupCount) + hh.Merkleize(indx) + return nil +} + +func (c *SignedBuilderBid) SizeSSZ() int { + size := 100 + if c.Message == nil { + c.Message = new(BuilderBid) + } + size += c.Message.SizeSSZ() + return size +} + +func (c *SignedBuilderBid) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} + +func (c *SignedBuilderBid) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 100 + + // Field 0: Message + if c.Message == nil { + c.Message = new(BuilderBid) + } + dst = ssz.WriteOffset(dst, offset) + offset += c.Message.SizeSSZ() + + // Field 1: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.Signature...) + + // Field 0: Message + if dst, err = c.Message.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Message: %w", err) + } + return dst, err +} + +func (c *SignedBuilderBid) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 100 { + return ssz.ErrSize + } + + sszSlice1 := buf[4:100] // c.Signature + + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Message + if sszVarOffset0 != 100 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset0 > size { + return ssz.ErrOffset + } + sszSlice0 := buf[sszVarOffset0:] // c.Message + + // Field 0: Message + c.Message = new(BuilderBid) + if err = c.Message.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Message: %w", err) + } + + // Field 1: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice1...) + return err +} + +func (c *SignedBuilderBid) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} + +func (c *SignedBuilderBid) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Message + if err := c.Message.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Message: %w", err) + } + // Field 1: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Signature) + hh.Merkleize(indx) + return nil +} + +func (c *SignedValidatorRegistrationV1) SizeSSZ() int { + size := 180 + + return size +} + +func (c *SignedValidatorRegistrationV1) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} + +func (c *SignedValidatorRegistrationV1) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + + // Field 0: Message + if c.Message == nil { + c.Message = new(ValidatorRegistrationV1) + } + if dst, err = c.Message.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Message: %w", err) + } + + // Field 1: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.Signature...) + + return dst, err +} + +func (c *SignedValidatorRegistrationV1) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 180 { + return ssz.ErrSize + } + + sszSlice0 := buf[0:84] // c.Message + sszSlice1 := buf[84:180] // c.Signature + + // Field 0: Message + c.Message = new(ValidatorRegistrationV1) + if err = c.Message.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Message: %w", err) + } + + // Field 1: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice1...) + return err +} + +func (c *SignedValidatorRegistrationV1) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} + +func (c *SignedValidatorRegistrationV1) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Message + if err := c.Message.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Message: %w", err) + } + // Field 1: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Signature) + hh.Merkleize(indx) + return nil +} + +func (c *ValidatorRegistrationV1) SizeSSZ() int { + size := 84 + + return size +} + +func (c *ValidatorRegistrationV1) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} + +func (c *ValidatorRegistrationV1) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + + // Field 0: FeeRecipient + if len(c.FeeRecipient) != 20 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.FeeRecipient...) + + // Field 1: GasLimit + dst = binary.LittleEndian.AppendUint64(dst, c.GasLimit) + + // Field 2: Timestamp + dst = binary.LittleEndian.AppendUint64(dst, c.Timestamp) + + // Field 3: Pubkey + if len(c.Pubkey) != 48 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.Pubkey...) + + return dst, err +} + +func (c *ValidatorRegistrationV1) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 84 { + return ssz.ErrSize + } + + sszSlice0 := buf[0:20] // c.FeeRecipient + sszSlice1 := buf[20:28] // c.GasLimit + sszSlice2 := buf[28:36] // c.Timestamp + sszSlice3 := buf[36:84] // c.Pubkey + + // Field 0: FeeRecipient + c.FeeRecipient = make([]byte, 0, 20) + c.FeeRecipient = append(c.FeeRecipient, sszSlice0...) + + // Field 1: GasLimit + c.GasLimit = binary.LittleEndian.Uint64(sszSlice1) + + // Field 2: Timestamp + c.Timestamp = binary.LittleEndian.Uint64(sszSlice2) + + // Field 3: Pubkey + c.Pubkey = make([]byte, 0, 48) + c.Pubkey = append(c.Pubkey, sszSlice3...) + return err +} + +func (c *ValidatorRegistrationV1) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} + +func (c *ValidatorRegistrationV1) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: FeeRecipient + if len(c.FeeRecipient) != 20 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.FeeRecipient) + // Field 1: GasLimit + hh.PutUint64(c.GasLimit) + // Field 2: Timestamp + hh.PutUint64(c.Timestamp) + // Field 3: Pubkey + if len(c.Pubkey) != 48 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Pubkey) + hh.Merkleize(indx) + return nil +} + +func (c *ValidatorIdentity) SizeSSZ() int { + size := 64 + + return size +} + +func (c *ValidatorIdentity) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} + +func (c *ValidatorIdentity) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + + // Field 0: Index + if dst, err = c.Index.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Index: %w", err) + } + + // Field 1: Pubkey + if len(c.Pubkey) != 48 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.Pubkey...) + + // Field 2: ActivationEpoch + if dst, err = c.ActivationEpoch.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ActivationEpoch: %w", err) + } + + return dst, err +} + +func (c *ValidatorIdentity) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 64 { + return ssz.ErrSize + } + + sszSlice0 := buf[0:8] // c.Index + sszSlice1 := buf[8:56] // c.Pubkey + sszSlice2 := buf[56:64] // c.ActivationEpoch + + // Field 0: Index + if err = c.Index.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Index: %w", err) + } + + // Field 1: Pubkey + c.Pubkey = make([]byte, 0, 48) + c.Pubkey = append(c.Pubkey, sszSlice1...) + + // Field 2: ActivationEpoch + if err = c.ActivationEpoch.UnmarshalSSZ(sszSlice2); err != nil { + return fmt.Errorf("ActivationEpoch: %w", err) + } + return err +} + +func (c *ValidatorIdentity) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} + +func (c *ValidatorIdentity) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Index + if err := c.Index.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Index: %w", err) + } + // Field 1: Pubkey + if len(c.Pubkey) != 48 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Pubkey) + // Field 2: ActivationEpoch + if err := c.ActivationEpoch.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ActivationEpoch: %w", err) + } + hh.Merkleize(indx) + return nil +} diff --git a/proto/prysm/v1alpha1/non-core.ssz.go b/proto/prysm/v1alpha1/non-core.ssz.go index 42cc4d375783..ea888f6036f5 100644 --- a/proto/prysm/v1alpha1/non-core.ssz.go +++ b/proto/prysm/v1alpha1/non-core.ssz.go @@ -1,1166 +1,1212 @@ -// Code generated by fastssz. DO NOT EDIT. +//go:build !minimal + package eth import ( - github_com_OffchainLabs_prysm_v7_consensus_types_primitives "github.com/OffchainLabs/prysm/v7/consensus-types/primitives" + binary "encoding/binary" + "fmt" + go_bitfield "github.com/OffchainLabs/go-bitfield" + ssz "github.com/OffchainLabs/methodical-ssz/ssz" v1 "github.com/OffchainLabs/prysm/v7/proto/engine/v1" - ssz "github.com/prysmaticlabs/fastssz" ) -// MarshalSSZ ssz marshals the SignedValidatorRegistrationV1 object -func (s *SignedValidatorRegistrationV1) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) +func (c *BeaconBlocksByRangeRequest) SizeSSZ() int { + size := 24 + + return size } -// MarshalSSZTo ssz marshals the SignedValidatorRegistrationV1 object to a target array -func (s *SignedValidatorRegistrationV1) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *BeaconBlocksByRangeRequest) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (0) 'Message' - if s.Message == nil { - s.Message = new(ValidatorRegistrationV1) - } - if dst, err = s.Message.MarshalSSZTo(dst); err != nil { - return - } +func (c *BeaconBlocksByRangeRequest) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 0: StartSlot + if dst, err = c.StartSlot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("StartSlot: %w", err) } - dst = append(dst, s.Signature...) - return + // Field 1: Count + dst = binary.LittleEndian.AppendUint64(dst, c.Count) + + // Field 2: Step + dst = binary.LittleEndian.AppendUint64(dst, c.Step) + + return dst, err } -// UnmarshalSSZ ssz unmarshals the SignedValidatorRegistrationV1 object -func (s *SignedValidatorRegistrationV1) UnmarshalSSZ(buf []byte) error { +func (c *BeaconBlocksByRangeRequest) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 180 { + if size != 24 { return ssz.ErrSize } - // Field (0) 'Message' - if s.Message == nil { - s.Message = new(ValidatorRegistrationV1) - } - if err = s.Message.UnmarshalSSZ(buf[0:84]); err != nil { - return err - } + sszSlice0 := buf[0:8] // c.StartSlot + sszSlice1 := buf[8:16] // c.Count + sszSlice2 := buf[16:24] // c.Step - // Field (1) 'Signature' - if cap(s.Signature) == 0 { - s.Signature = make([]byte, 0, len(buf[84:180])) + // Field 0: StartSlot + if err = c.StartSlot.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("StartSlot: %w", err) } - s.Signature = append(s.Signature, buf[84:180]...) - return err -} + // Field 1: Count + c.Count = binary.LittleEndian.Uint64(sszSlice1) -// SizeSSZ returns the ssz encoded size in bytes for the SignedValidatorRegistrationV1 object -func (s *SignedValidatorRegistrationV1) SizeSSZ() (size int) { - size = 180 - return + // Field 2: Step + c.Step = binary.LittleEndian.Uint64(sszSlice2) + return err } -// HashTreeRoot ssz hashes the SignedValidatorRegistrationV1 object -func (s *SignedValidatorRegistrationV1) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) +func (c *BeaconBlocksByRangeRequest) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the SignedValidatorRegistrationV1 object with a hasher -func (s *SignedValidatorRegistrationV1) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *BeaconBlocksByRangeRequest) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() + // Field 0: StartSlot + if err := c.StartSlot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("StartSlot: %w", err) + } + // Field 1: Count + hh.PutUint64(c.Count) + // Field 2: Step + hh.PutUint64(c.Step) + hh.Merkleize(indx) + return nil +} - // Field (0) 'Message' - if err = s.Message.HashTreeRootWith(hh); err != nil { - return - } - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return - } - hh.PutBytes(s.Signature) +func (c *BlobSidecarsByRangeRequest) SizeSSZ() int { + size := 16 - hh.Merkleize(indx) - return + return size } -// MarshalSSZ ssz marshals the ValidatorRegistrationV1 object -func (v *ValidatorRegistrationV1) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(v) +func (c *BlobSidecarsByRangeRequest) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the ValidatorRegistrationV1 object to a target array -func (v *ValidatorRegistrationV1) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *BlobSidecarsByRangeRequest) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (0) 'FeeRecipient' - if size := len(v.FeeRecipient); size != 20 { - err = ssz.ErrBytesLengthFn("--.FeeRecipient", size, 20) - return + // Field 0: StartSlot + if dst, err = c.StartSlot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("StartSlot: %w", err) } - dst = append(dst, v.FeeRecipient...) - - // Field (1) 'GasLimit' - dst = ssz.MarshalUint(dst, v.GasLimit) - // Field (2) 'Timestamp' - dst = ssz.MarshalUint(dst, v.Timestamp) + // Field 1: Count + dst = binary.LittleEndian.AppendUint64(dst, c.Count) - // Field (3) 'Pubkey' - if size := len(v.Pubkey); size != 48 { - err = ssz.ErrBytesLengthFn("--.Pubkey", size, 48) - return - } - dst = append(dst, v.Pubkey...) - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the ValidatorRegistrationV1 object -func (v *ValidatorRegistrationV1) UnmarshalSSZ(buf []byte) error { +func (c *BlobSidecarsByRangeRequest) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 84 { + if size != 16 { return ssz.ErrSize } - // Field (0) 'FeeRecipient' - if cap(v.FeeRecipient) == 0 { - v.FeeRecipient = make([]byte, 0, len(buf[0:20])) + sszSlice0 := buf[0:8] // c.StartSlot + sszSlice1 := buf[8:16] // c.Count + + // Field 0: StartSlot + if err = c.StartSlot.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("StartSlot: %w", err) } - v.FeeRecipient = append(v.FeeRecipient, buf[0:20]...) - // Field (1) 'GasLimit' - v.GasLimit = ssz.UnmarshallUint[uint64](buf[20:28]) + // Field 1: Count + c.Count = binary.LittleEndian.Uint64(sszSlice1) + return err +} - // Field (2) 'Timestamp' - v.Timestamp = ssz.UnmarshallUint[uint64](buf[28:36]) +func (c *BlobSidecarsByRangeRequest) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (3) 'Pubkey' - if cap(v.Pubkey) == 0 { - v.Pubkey = make([]byte, 0, len(buf[36:84])) +func (c *BlobSidecarsByRangeRequest) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: StartSlot + if err := c.StartSlot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("StartSlot: %w", err) } - v.Pubkey = append(v.Pubkey, buf[36:84]...) + // Field 1: Count + hh.PutUint64(c.Count) + hh.Merkleize(indx) + return nil +} - return err +func (c *BuilderBid) SizeSSZ() int { + size := 84 + if c.Header == nil { + c.Header = new(v1.ExecutionPayloadHeader) + } + size += c.Header.SizeSSZ() + return size } -// SizeSSZ returns the ssz encoded size in bytes for the ValidatorRegistrationV1 object -func (v *ValidatorRegistrationV1) SizeSSZ() (size int) { - size = 84 - return +func (c *BuilderBid) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// HashTreeRoot ssz hashes the ValidatorRegistrationV1 object -func (v *ValidatorRegistrationV1) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(v) +func (c *BuilderBid) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 84 + + // Field 0: Header + if c.Header == nil { + c.Header = new(v1.ExecutionPayloadHeader) + } + dst = ssz.WriteOffset(dst, offset) + offset += c.Header.SizeSSZ() + + // Field 1: Value + if len(c.Value) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.Value...) + + // Field 2: Pubkey + if len(c.Pubkey) != 48 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.Pubkey...) + + // Field 0: Header + if dst, err = c.Header.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Header: %w", err) + } + return dst, err } -// HashTreeRootWith ssz hashes the ValidatorRegistrationV1 object with a hasher -func (v *ValidatorRegistrationV1) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() +func (c *BuilderBid) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 84 { + return ssz.ErrSize + } + + sszSlice1 := buf[4:36] // c.Value + sszSlice2 := buf[36:84] // c.Pubkey - // Field (0) 'FeeRecipient' - if size := len(v.FeeRecipient); size != 20 { - err = ssz.ErrBytesLengthFn("--.FeeRecipient", size, 20) - return + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Header + if sszVarOffset0 != 84 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset0 > size { + return ssz.ErrOffset + } + sszSlice0 := buf[sszVarOffset0:] // c.Header + + // Field 0: Header + c.Header = new(v1.ExecutionPayloadHeader) + if err = c.Header.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Header: %w", err) } - hh.PutBytes(v.FeeRecipient) - // Field (1) 'GasLimit' - ssz.PutUint(hh, v.GasLimit) + // Field 1: Value + c.Value = make([]byte, 0, 32) + c.Value = append(c.Value, sszSlice1...) - // Field (2) 'Timestamp' - ssz.PutUint(hh, v.Timestamp) + // Field 2: Pubkey + c.Pubkey = make([]byte, 0, 48) + c.Pubkey = append(c.Pubkey, sszSlice2...) + return err +} - // Field (3) 'Pubkey' - if size := len(v.Pubkey); size != 48 { - err = ssz.ErrBytesLengthFn("--.Pubkey", size, 48) - return +func (c *BuilderBid) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - hh.PutBytes(v.Pubkey) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} +func (c *BuilderBid) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Header + if err := c.Header.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Header: %w", err) + } + // Field 1: Value + if len(c.Value) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Value) + // Field 2: Pubkey + if len(c.Pubkey) != 48 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Pubkey) hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the SignedBuilderBid object -func (s *SignedBuilderBid) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) +func (c *DataColumnSidecarsByRangeRequest) SizeSSZ() int { + size := 20 + size += len(c.Columns) * 8 + return size } -// MarshalSSZTo ssz marshals the SignedBuilderBid object to a target array -func (s *SignedBuilderBid) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(100) +func (c *DataColumnSidecarsByRangeRequest) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Offset (0) 'Message' - dst = ssz.WriteOffset(dst, offset) - if s.Message == nil { - s.Message = new(BuilderBid) - } - offset += s.Message.SizeSSZ() +func (c *DataColumnSidecarsByRangeRequest) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 20 - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 0: StartSlot + if dst, err = c.StartSlot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("StartSlot: %w", err) } - dst = append(dst, s.Signature...) - // Field (0) 'Message' - if dst, err = s.Message.MarshalSSZTo(dst); err != nil { - return - } + // Field 1: Count + dst = binary.LittleEndian.AppendUint64(dst, c.Count) + + // Field 2: Columns + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Columns) * 8 - return + // Field 2: Columns + if len(c.Columns) > 128 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.Columns { + dst = binary.LittleEndian.AppendUint64(dst, o) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the SignedBuilderBid object -func (s *SignedBuilderBid) UnmarshalSSZ(buf []byte) error { +func (c *DataColumnSidecarsByRangeRequest) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 100 { + if size < 20 { return ssz.ErrSize } - tail := buf - var o0 uint64 + sszSlice0 := buf[0:8] // c.StartSlot + sszSlice1 := buf[8:16] // c.Count - // Offset (0) 'Message' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { + sszVarOffset2 := ssz.ReadOffset(buf[16:20]) // c.Columns + if sszVarOffset2 != 20 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset2 > size { return ssz.ErrOffset } + sszSlice2 := buf[sszVarOffset2:] // c.Columns - if o0 != 100 { - return ssz.ErrInvalidVariableOffset + // Field 0: StartSlot + if err = c.StartSlot.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("StartSlot: %w", err) } - // 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 1: Count + c.Count = binary.LittleEndian.Uint64(sszSlice1) - // Field (0) 'Message' + // Field 2: Columns { - buf = tail[o0:] - if s.Message == nil { - s.Message = new(BuilderBid) + if len(sszSlice2)%8 != 0 { + return fmt.Errorf("misaligned bytes: c.Columns length is %d, which is not a multiple of 8: %w", len(sszSlice2), ssz.ErrIncorrectListSize) } - if err = s.Message.UnmarshalSSZ(buf); err != nil { - return err + numElem := len(sszSlice2) / 8 + if numElem > 128 { + return fmt.Errorf("ssz-max exceeded: c.Columns has %d elements, ssz-max is 128: %w", numElem, ssz.ErrListTooBig) + } + c.Columns = make([]uint64, numElem) + for i := 0; i < numElem; i++ { + var tmp uint64 + + tmpSlice := sszSlice2[i*8 : (1+i)*8] + tmp = binary.LittleEndian.Uint64(tmpSlice) + c.Columns[i] = tmp } } return err } -// SizeSSZ returns the ssz encoded size in bytes for the SignedBuilderBid object -func (s *SignedBuilderBid) SizeSSZ() (size int) { - size = 100 - - // Field (0) 'Message' - if s.Message == nil { - s.Message = new(BuilderBid) +func (c *DataColumnSidecarsByRangeRequest) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - size += s.Message.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the SignedBuilderBid object -func (s *SignedBuilderBid) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the SignedBuilderBid object with a hasher -func (s *SignedBuilderBid) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *DataColumnSidecarsByRangeRequest) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Message' - if err = s.Message.HashTreeRootWith(hh); err != nil { - return + // Field 0: StartSlot + if err := c.StartSlot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("StartSlot: %w", err) } - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 1: Count + hh.PutUint64(c.Count) + // Field 2: Columns + { + if len(c.Columns) > 128 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.Columns { + hh.AppendUint64(o) + } + hh.FillUpTo32() + numItems := uint64(len(c.Columns)) + hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(128, numItems, 8)) } - hh.PutBytes(s.Signature) - hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the BuilderBid object -func (b *BuilderBid) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) +func (c *DepositSnapshot) SizeSSZ() int { + size := 84 + size += len(c.Finalized) * 32 + return size } -// MarshalSSZTo ssz marshals the BuilderBid object to a target array -func (b *BuilderBid) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(84) +func (c *DepositSnapshot) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Offset (0) 'Header' +func (c *DepositSnapshot) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 84 + + // Field 0: Finalized dst = ssz.WriteOffset(dst, offset) - if b.Header == nil { - b.Header = new(v1.ExecutionPayloadHeader) - } - offset += b.Header.SizeSSZ() + offset += len(c.Finalized) * 32 - // Field (1) 'Value' - if size := len(b.Value); size != 32 { - err = ssz.ErrBytesLengthFn("--.Value", size, 32) - return + // Field 1: DepositRoot + if len(c.DepositRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.Value...) + dst = append(dst, c.DepositRoot...) - // Field (2) 'Pubkey' - if size := len(b.Pubkey); size != 48 { - err = ssz.ErrBytesLengthFn("--.Pubkey", size, 48) - return - } - dst = append(dst, b.Pubkey...) + // Field 2: DepositCount + dst = binary.LittleEndian.AppendUint64(dst, c.DepositCount) - // Field (0) 'Header' - if dst, err = b.Header.MarshalSSZTo(dst); err != nil { - return + // Field 3: ExecutionHash + if len(c.ExecutionHash) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.ExecutionHash...) + + // Field 4: ExecutionDepth + dst = binary.LittleEndian.AppendUint64(dst, c.ExecutionDepth) - return + // Field 0: Finalized + if len(c.Finalized) > 32 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.Finalized { + if len(o) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the BuilderBid object -func (b *BuilderBid) UnmarshalSSZ(buf []byte) error { +func (c *DepositSnapshot) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size < 84 { return ssz.ErrSize } - tail := buf - var o0 uint64 + sszSlice1 := buf[4:36] // c.DepositRoot + sszSlice2 := buf[36:44] // c.DepositCount + sszSlice3 := buf[44:76] // c.ExecutionHash + sszSlice4 := buf[76:84] // c.ExecutionDepth - // Offset (0) 'Header' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } - - if o0 != 84 { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Finalized + if sszVarOffset0 != 84 { return ssz.ErrInvalidVariableOffset } - - // Field (1) 'Value' - if cap(b.Value) == 0 { - b.Value = make([]byte, 0, len(buf[4:36])) - } - b.Value = append(b.Value, buf[4:36]...) - - // Field (2) 'Pubkey' - if cap(b.Pubkey) == 0 { - b.Pubkey = make([]byte, 0, len(buf[36:84])) + if sszVarOffset0 > size { + return ssz.ErrOffset } - b.Pubkey = append(b.Pubkey, buf[36:84]...) + sszSlice0 := buf[sszVarOffset0:] // c.Finalized - // Field (0) 'Header' + // Field 0: Finalized { - buf = tail[o0:] - if b.Header == nil { - b.Header = new(v1.ExecutionPayloadHeader) + if len(sszSlice0)%32 != 0 { + return fmt.Errorf("misaligned bytes: c.Finalized length is %d, which is not a multiple of 32: %w", len(sszSlice0), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice0) / 32 + if numElem > 32 { + return fmt.Errorf("ssz-max exceeded: c.Finalized has %d elements, ssz-max is 32: %w", numElem, ssz.ErrListTooBig) } - if err = b.Header.UnmarshalSSZ(buf); err != nil { - return err + c.Finalized = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte + + tmpSlice := sszSlice0[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.Finalized[i] = tmp } } - return err -} -// SizeSSZ returns the ssz encoded size in bytes for the BuilderBid object -func (b *BuilderBid) SizeSSZ() (size int) { - size = 84 + // Field 1: DepositRoot + c.DepositRoot = make([]byte, 0, 32) + c.DepositRoot = append(c.DepositRoot, sszSlice1...) - // Field (0) 'Header' - if b.Header == nil { - b.Header = new(v1.ExecutionPayloadHeader) - } - size += b.Header.SizeSSZ() + // Field 2: DepositCount + c.DepositCount = binary.LittleEndian.Uint64(sszSlice2) - return -} + // Field 3: ExecutionHash + c.ExecutionHash = make([]byte, 0, 32) + c.ExecutionHash = append(c.ExecutionHash, sszSlice3...) -// HashTreeRoot ssz hashes the BuilderBid object -func (b *BuilderBid) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) + // Field 4: ExecutionDepth + c.ExecutionDepth = binary.LittleEndian.Uint64(sszSlice4) + return err } -// HashTreeRootWith ssz hashes the BuilderBid object with a hasher -func (b *BuilderBid) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'Header' - if err = b.Header.HashTreeRootWith(hh); err != nil { - return +func (c *DepositSnapshot) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (1) 'Value' - if size := len(b.Value); size != 32 { - err = ssz.ErrBytesLengthFn("--.Value", size, 32) - return - } - hh.PutBytes(b.Value) - - // Field (2) 'Pubkey' - if size := len(b.Pubkey); size != 48 { - err = ssz.ErrBytesLengthFn("--.Pubkey", size, 48) - return - } - hh.PutBytes(b.Pubkey) - +func (c *DepositSnapshot) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Finalized + { + if len(c.Finalized) > 32 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.Finalized { + if len(o) != 32 { + return ssz.ErrBytesLength + } + hh.Append(o) + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Finalized)), 32) + } + // Field 1: DepositRoot + if len(c.DepositRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.DepositRoot) + // Field 2: DepositCount + hh.PutUint64(c.DepositCount) + // Field 3: ExecutionHash + if len(c.ExecutionHash) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ExecutionHash) + // Field 4: ExecutionDepth + hh.PutUint64(c.ExecutionDepth) hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the BeaconBlocksByRangeRequest object -func (b *BeaconBlocksByRangeRequest) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) +func (c *ExecutionPayloadEnvelopesByRangeRequest) SizeSSZ() int { + size := 16 + + return size } -// MarshalSSZTo ssz marshals the BeaconBlocksByRangeRequest object to a target array -func (b *BeaconBlocksByRangeRequest) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *ExecutionPayloadEnvelopesByRangeRequest) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (0) 'StartSlot' - dst = ssz.MarshalUint(dst, b.StartSlot) +func (c *ExecutionPayloadEnvelopesByRangeRequest) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (1) 'Count' - dst = ssz.MarshalUint(dst, b.Count) + // Field 0: StartSlot + if dst, err = c.StartSlot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("StartSlot: %w", err) + } - // Field (2) 'Step' - dst = ssz.MarshalUint(dst, b.Step) + // Field 1: Count + dst = binary.LittleEndian.AppendUint64(dst, c.Count) - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the BeaconBlocksByRangeRequest object -func (b *BeaconBlocksByRangeRequest) UnmarshalSSZ(buf []byte) error { +func (c *ExecutionPayloadEnvelopesByRangeRequest) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 24 { + if size != 16 { return ssz.ErrSize } - // Field (0) 'StartSlot' - b.StartSlot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[0:8]) + sszSlice0 := buf[0:8] // c.StartSlot + sszSlice1 := buf[8:16] // c.Count - // Field (1) 'Count' - b.Count = ssz.UnmarshallUint[uint64](buf[8:16]) - - // Field (2) 'Step' - b.Step = ssz.UnmarshallUint[uint64](buf[16:24]) + // Field 0: StartSlot + if err = c.StartSlot.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("StartSlot: %w", err) + } + // Field 1: Count + c.Count = binary.LittleEndian.Uint64(sszSlice1) return err } -// SizeSSZ returns the ssz encoded size in bytes for the BeaconBlocksByRangeRequest object -func (b *BeaconBlocksByRangeRequest) SizeSSZ() (size int) { - size = 24 - return -} - -// HashTreeRoot ssz hashes the BeaconBlocksByRangeRequest object -func (b *BeaconBlocksByRangeRequest) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) +func (c *ExecutionPayloadEnvelopesByRangeRequest) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the BeaconBlocksByRangeRequest object with a hasher -func (b *BeaconBlocksByRangeRequest) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *ExecutionPayloadEnvelopesByRangeRequest) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() + // Field 0: StartSlot + if err := c.StartSlot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("StartSlot: %w", err) + } + // Field 1: Count + hh.PutUint64(c.Count) + hh.Merkleize(indx) + return nil +} - // Field (0) 'StartSlot' - ssz.PutUint(hh, b.StartSlot) - - // Field (1) 'Count' - ssz.PutUint(hh, b.Count) - - // Field (2) 'Step' - ssz.PutUint(hh, b.Step) +func (c *MetaDataV0) SizeSSZ() int { + size := 16 - hh.Merkleize(indx) - return + return size } -// MarshalSSZ ssz marshals the MetaDataV0 object -func (m *MetaDataV0) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(m) +func (c *MetaDataV0) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the MetaDataV0 object to a target array -func (m *MetaDataV0) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *MetaDataV0) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (0) 'SeqNumber' - dst = ssz.MarshalUint(dst, m.SeqNumber) + // Field 0: SeqNumber + dst = binary.LittleEndian.AppendUint64(dst, c.SeqNumber) - // Field (1) 'Attnets' - if size := len(m.Attnets); size != 8 { - err = ssz.ErrBytesLengthFn("--.Attnets", size, 8) - return + // Field 1: Attnets + if len([]byte(c.Attnets)) != 8 { + return nil, ssz.ErrBytesLength } - dst = append(dst, m.Attnets...) + dst = append(dst, []byte(c.Attnets)...) - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the MetaDataV0 object -func (m *MetaDataV0) UnmarshalSSZ(buf []byte) error { +func (c *MetaDataV0) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size != 16 { return ssz.ErrSize } - // Field (0) 'SeqNumber' - m.SeqNumber = ssz.UnmarshallUint[uint64](buf[0:8]) + sszSlice0 := buf[0:8] // c.SeqNumber + sszSlice1 := buf[8:16] // c.Attnets - // Field (1) 'Attnets' - if cap(m.Attnets) == 0 { - m.Attnets = make([]byte, 0, len(buf[8:16])) - } - m.Attnets = append(m.Attnets, buf[8:16]...) + // Field 0: SeqNumber + c.SeqNumber = binary.LittleEndian.Uint64(sszSlice0) + // Field 1: Attnets + c.Attnets = make([]byte, 0, 8) + c.Attnets = append(c.Attnets, go_bitfield.Bitvector64(sszSlice1)...) return err } -// SizeSSZ returns the ssz encoded size in bytes for the MetaDataV0 object -func (m *MetaDataV0) SizeSSZ() (size int) { - size = 16 - return -} - -// HashTreeRoot ssz hashes the MetaDataV0 object -func (m *MetaDataV0) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(m) +func (c *MetaDataV0) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the MetaDataV0 object with a hasher -func (m *MetaDataV0) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *MetaDataV0) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'SeqNumber' - ssz.PutUint(hh, m.SeqNumber) - - // Field (1) 'Attnets' - if size := len(m.Attnets); size != 8 { - err = ssz.ErrBytesLengthFn("--.Attnets", size, 8) - return + // Field 0: SeqNumber + hh.PutUint64(c.SeqNumber) + // Field 1: Attnets + if len([]byte(c.Attnets)) != 8 { + return ssz.ErrBytesLength } - hh.PutBytes(m.Attnets) - + hh.PutBytes([]byte(c.Attnets)) hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the MetaDataV1 object -func (m *MetaDataV1) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(m) +func (c *MetaDataV1) SizeSSZ() int { + size := 17 + + return size } -// MarshalSSZTo ssz marshals the MetaDataV1 object to a target array -func (m *MetaDataV1) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *MetaDataV1) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (0) 'SeqNumber' - dst = ssz.MarshalUint(dst, m.SeqNumber) +func (c *MetaDataV1) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + + // Field 0: SeqNumber + dst = binary.LittleEndian.AppendUint64(dst, c.SeqNumber) - // Field (1) 'Attnets' - if size := len(m.Attnets); size != 8 { - err = ssz.ErrBytesLengthFn("--.Attnets", size, 8) - return + // Field 1: Attnets + if len([]byte(c.Attnets)) != 8 { + return nil, ssz.ErrBytesLength } - dst = append(dst, m.Attnets...) + dst = append(dst, []byte(c.Attnets)...) - // Field (2) 'Syncnets' - if size := len(m.Syncnets); size != 1 { - err = ssz.ErrBytesLengthFn("--.Syncnets", size, 1) - return + // Field 2: Syncnets + if len([]byte(c.Syncnets)) != 1 { + return nil, ssz.ErrBytesLength } - dst = append(dst, m.Syncnets...) + dst = append(dst, []byte(c.Syncnets)...) - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the MetaDataV1 object -func (m *MetaDataV1) UnmarshalSSZ(buf []byte) error { +func (c *MetaDataV1) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size != 17 { return ssz.ErrSize } - // Field (0) 'SeqNumber' - m.SeqNumber = ssz.UnmarshallUint[uint64](buf[0:8]) + sszSlice0 := buf[0:8] // c.SeqNumber + sszSlice1 := buf[8:16] // c.Attnets + sszSlice2 := buf[16:17] // c.Syncnets - // Field (1) 'Attnets' - if cap(m.Attnets) == 0 { - m.Attnets = make([]byte, 0, len(buf[8:16])) - } - m.Attnets = append(m.Attnets, buf[8:16]...) + // Field 0: SeqNumber + c.SeqNumber = binary.LittleEndian.Uint64(sszSlice0) - // Field (2) 'Syncnets' - if cap(m.Syncnets) == 0 { - m.Syncnets = make([]byte, 0, len(buf[16:17])) - } - m.Syncnets = append(m.Syncnets, buf[16:17]...) + // Field 1: Attnets + c.Attnets = make([]byte, 0, 8) + c.Attnets = append(c.Attnets, go_bitfield.Bitvector64(sszSlice1)...) + // Field 2: Syncnets + c.Syncnets = make([]byte, 0, 1) + c.Syncnets = append(c.Syncnets, go_bitfield.Bitvector4(sszSlice2)...) return err } -// SizeSSZ returns the ssz encoded size in bytes for the MetaDataV1 object -func (m *MetaDataV1) SizeSSZ() (size int) { - size = 17 - return -} - -// HashTreeRoot ssz hashes the MetaDataV1 object -func (m *MetaDataV1) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(m) +func (c *MetaDataV1) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the MetaDataV1 object with a hasher -func (m *MetaDataV1) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *MetaDataV1) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() + // Field 0: SeqNumber + hh.PutUint64(c.SeqNumber) + // Field 1: Attnets + if len([]byte(c.Attnets)) != 8 { + return ssz.ErrBytesLength + } + hh.PutBytes([]byte(c.Attnets)) + // Field 2: Syncnets + if len([]byte(c.Syncnets)) != 1 { + return ssz.ErrBytesLength + } + hh.PutBytes([]byte(c.Syncnets)) + hh.Merkleize(indx) + return nil +} - // Field (0) 'SeqNumber' - ssz.PutUint(hh, m.SeqNumber) - - // Field (1) 'Attnets' - if size := len(m.Attnets); size != 8 { - err = ssz.ErrBytesLengthFn("--.Attnets", size, 8) - return - } - hh.PutBytes(m.Attnets) - - // Field (2) 'Syncnets' - if size := len(m.Syncnets); size != 1 { - err = ssz.ErrBytesLengthFn("--.Syncnets", size, 1) - return - } - hh.PutBytes(m.Syncnets) +func (c *MetaDataV2) SizeSSZ() int { + size := 25 - hh.Merkleize(indx) - return + return size } -// MarshalSSZ ssz marshals the MetaDataV2 object -func (m *MetaDataV2) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(m) +func (c *MetaDataV2) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the MetaDataV2 object to a target array -func (m *MetaDataV2) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *MetaDataV2) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (0) 'SeqNumber' - dst = ssz.MarshalUint(dst, m.SeqNumber) + // Field 0: SeqNumber + dst = binary.LittleEndian.AppendUint64(dst, c.SeqNumber) - // Field (1) 'Attnets' - if size := len(m.Attnets); size != 8 { - err = ssz.ErrBytesLengthFn("--.Attnets", size, 8) - return + // Field 1: Attnets + if len([]byte(c.Attnets)) != 8 { + return nil, ssz.ErrBytesLength } - dst = append(dst, m.Attnets...) + dst = append(dst, []byte(c.Attnets)...) - // Field (2) 'Syncnets' - if size := len(m.Syncnets); size != 1 { - err = ssz.ErrBytesLengthFn("--.Syncnets", size, 1) - return + // Field 2: Syncnets + if len([]byte(c.Syncnets)) != 1 { + return nil, ssz.ErrBytesLength } - dst = append(dst, m.Syncnets...) + dst = append(dst, []byte(c.Syncnets)...) - // Field (3) 'CustodyGroupCount' - dst = ssz.MarshalUint(dst, m.CustodyGroupCount) + // Field 3: CustodyGroupCount + dst = binary.LittleEndian.AppendUint64(dst, c.CustodyGroupCount) - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the MetaDataV2 object -func (m *MetaDataV2) UnmarshalSSZ(buf []byte) error { +func (c *MetaDataV2) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size != 25 { return ssz.ErrSize } - // Field (0) 'SeqNumber' - m.SeqNumber = ssz.UnmarshallUint[uint64](buf[0:8]) + sszSlice0 := buf[0:8] // c.SeqNumber + sszSlice1 := buf[8:16] // c.Attnets + sszSlice2 := buf[16:17] // c.Syncnets + sszSlice3 := buf[17:25] // c.CustodyGroupCount - // Field (1) 'Attnets' - if cap(m.Attnets) == 0 { - m.Attnets = make([]byte, 0, len(buf[8:16])) - } - m.Attnets = append(m.Attnets, buf[8:16]...) + // Field 0: SeqNumber + c.SeqNumber = binary.LittleEndian.Uint64(sszSlice0) - // Field (2) 'Syncnets' - if cap(m.Syncnets) == 0 { - m.Syncnets = make([]byte, 0, len(buf[16:17])) - } - m.Syncnets = append(m.Syncnets, buf[16:17]...) + // Field 1: Attnets + c.Attnets = make([]byte, 0, 8) + c.Attnets = append(c.Attnets, go_bitfield.Bitvector64(sszSlice1)...) - // Field (3) 'CustodyGroupCount' - m.CustodyGroupCount = ssz.UnmarshallUint[uint64](buf[17:25]) + // Field 2: Syncnets + c.Syncnets = make([]byte, 0, 1) + c.Syncnets = append(c.Syncnets, go_bitfield.Bitvector4(sszSlice2)...) + // Field 3: CustodyGroupCount + c.CustodyGroupCount = binary.LittleEndian.Uint64(sszSlice3) return err } -// SizeSSZ returns the ssz encoded size in bytes for the MetaDataV2 object -func (m *MetaDataV2) SizeSSZ() (size int) { - size = 25 - return -} - -// HashTreeRoot ssz hashes the MetaDataV2 object -func (m *MetaDataV2) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(m) +func (c *MetaDataV2) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the MetaDataV2 object with a hasher -func (m *MetaDataV2) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *MetaDataV2) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() + // Field 0: SeqNumber + hh.PutUint64(c.SeqNumber) + // Field 1: Attnets + if len([]byte(c.Attnets)) != 8 { + return ssz.ErrBytesLength + } + hh.PutBytes([]byte(c.Attnets)) + // Field 2: Syncnets + if len([]byte(c.Syncnets)) != 1 { + return ssz.ErrBytesLength + } + hh.PutBytes([]byte(c.Syncnets)) + // Field 3: CustodyGroupCount + hh.PutUint64(c.CustodyGroupCount) + hh.Merkleize(indx) + return nil +} - // Field (0) 'SeqNumber' - ssz.PutUint(hh, m.SeqNumber) - - // Field (1) 'Attnets' - if size := len(m.Attnets); size != 8 { - err = ssz.ErrBytesLengthFn("--.Attnets", size, 8) - return - } - hh.PutBytes(m.Attnets) - - // Field (2) 'Syncnets' - if size := len(m.Syncnets); size != 1 { - err = ssz.ErrBytesLengthFn("--.Syncnets", size, 1) - return +func (c *SignedBuilderBid) SizeSSZ() int { + size := 100 + if c.Message == nil { + c.Message = new(BuilderBid) } - hh.PutBytes(m.Syncnets) - - // Field (3) 'CustodyGroupCount' - ssz.PutUint(hh, m.CustodyGroupCount) - - hh.Merkleize(indx) - return + size += c.Message.SizeSSZ() + return size } -// MarshalSSZ ssz marshals the BlobSidecarsByRangeRequest object -func (b *BlobSidecarsByRangeRequest) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) +func (c *SignedBuilderBid) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the BlobSidecarsByRangeRequest object to a target array -func (b *BlobSidecarsByRangeRequest) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *SignedBuilderBid) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 100 - // Field (0) 'StartSlot' - dst = ssz.MarshalUint(dst, b.StartSlot) + // Field 0: Message + if c.Message == nil { + c.Message = new(BuilderBid) + } + dst = ssz.WriteOffset(dst, offset) + offset += c.Message.SizeSSZ() - // Field (1) 'Count' - dst = ssz.MarshalUint(dst, b.Count) + // Field 1: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.Signature...) - return + // Field 0: Message + if dst, err = c.Message.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Message: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the BlobSidecarsByRangeRequest object -func (b *BlobSidecarsByRangeRequest) UnmarshalSSZ(buf []byte) error { +func (c *SignedBuilderBid) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 16 { + if size < 100 { return ssz.ErrSize } - // Field (0) 'StartSlot' - b.StartSlot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[0:8]) + sszSlice1 := buf[4:100] // c.Signature - // Field (1) 'Count' - b.Count = ssz.UnmarshallUint[uint64](buf[8:16]) + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Message + if sszVarOffset0 != 100 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset0 > size { + return ssz.ErrOffset + } + sszSlice0 := buf[sszVarOffset0:] // c.Message - return err -} + // Field 0: Message + c.Message = new(BuilderBid) + if err = c.Message.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Message: %w", err) + } -// SizeSSZ returns the ssz encoded size in bytes for the BlobSidecarsByRangeRequest object -func (b *BlobSidecarsByRangeRequest) SizeSSZ() (size int) { - size = 16 - return + // Field 1: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice1...) + return err } -// HashTreeRoot ssz hashes the BlobSidecarsByRangeRequest object -func (b *BlobSidecarsByRangeRequest) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) +func (c *SignedBuilderBid) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the BlobSidecarsByRangeRequest object with a hasher -func (b *BlobSidecarsByRangeRequest) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *SignedBuilderBid) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'StartSlot' - ssz.PutUint(hh, b.StartSlot) - - // Field (1) 'Count' - ssz.PutUint(hh, b.Count) - + // Field 0: Message + if err := c.Message.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Message: %w", err) + } + // Field 1: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Signature) hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the DataColumnSidecarsByRangeRequest object -func (d *DataColumnSidecarsByRangeRequest) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(d) -} +func (c *SignedValidatorRegistrationV1) SizeSSZ() int { + size := 180 -// MarshalSSZTo ssz marshals the DataColumnSidecarsByRangeRequest object to a target array -func (d *DataColumnSidecarsByRangeRequest) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(20) - - // Field (0) 'StartSlot' - dst = ssz.MarshalUint(dst, d.StartSlot) + return size +} - // Field (1) 'Count' - dst = ssz.MarshalUint(dst, d.Count) +func (c *SignedValidatorRegistrationV1) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Offset (2) 'Columns' - dst = ssz.WriteOffset(dst, offset) - offset += len(d.Columns) * 8 +func (c *SignedValidatorRegistrationV1) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (2) 'Columns' - if size := len(d.Columns); size > 128 { - err = ssz.ErrListTooBigFn("--.Columns", size, 128) - return + // Field 0: Message + if c.Message == nil { + c.Message = new(ValidatorRegistrationV1) + } + if dst, err = c.Message.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Message: %w", err) } - for ii := 0; ii < len(d.Columns); ii++ { - dst = ssz.MarshalUint(dst, d.Columns[ii]) + + // Field 1: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.Signature...) - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the DataColumnSidecarsByRangeRequest object -func (d *DataColumnSidecarsByRangeRequest) UnmarshalSSZ(buf []byte) error { +func (c *SignedValidatorRegistrationV1) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 20 { + if size != 180 { return ssz.ErrSize } - tail := buf - var o2 uint64 + sszSlice0 := buf[0:84] // c.Message + sszSlice1 := buf[84:180] // c.Signature - // Field (0) 'StartSlot' - d.StartSlot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[0:8]) + // Field 0: Message + c.Message = new(ValidatorRegistrationV1) + if err = c.Message.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Message: %w", err) + } - // Field (1) 'Count' - d.Count = ssz.UnmarshallUint[uint64](buf[8:16]) + // Field 1: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice1...) + return err +} - // Offset (2) 'Columns' - if o2 = ssz.ReadOffset(buf[16:20]); o2 > size { - return ssz.ErrOffset +func (c *SignedValidatorRegistrationV1) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - if o2 != 20 { - return ssz.ErrInvalidVariableOffset +func (c *SignedValidatorRegistrationV1) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Message + if err := c.Message.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Message: %w", err) } - - // Field (2) 'Columns' - { - buf = tail[o2:] - num, err := ssz.DivideInt2(len(buf), 8, 128) - if err != nil { - return err - } - d.Columns = ssz.ExtendUint(d.Columns, num) - for ii := 0; ii < num; ii++ { - d.Columns[ii] = ssz.UnmarshallUint[uint64](buf[ii*8 : (ii+1)*8]) - } + // Field 1: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength } - return err + hh.PutBytes(c.Signature) + hh.Merkleize(indx) + return nil } -// SizeSSZ returns the ssz encoded size in bytes for the DataColumnSidecarsByRangeRequest object -func (d *DataColumnSidecarsByRangeRequest) SizeSSZ() (size int) { - size = 20 - - // Field (2) 'Columns' - size += len(d.Columns) * 8 +func (c *ValidatorRegistrationV1) SizeSSZ() int { + size := 84 - return + return size } -// HashTreeRoot ssz hashes the DataColumnSidecarsByRangeRequest object -func (d *DataColumnSidecarsByRangeRequest) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(d) +func (c *ValidatorRegistrationV1) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// HashTreeRootWith ssz hashes the DataColumnSidecarsByRangeRequest object with a hasher -func (d *DataColumnSidecarsByRangeRequest) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'StartSlot' - ssz.PutUint(hh, d.StartSlot) - - // Field (1) 'Count' - ssz.PutUint(hh, d.Count) - - // Field (2) 'Columns' - { - if size := len(d.Columns); size > 128 { - err = ssz.ErrListTooBigFn("--.Columns", size, 128) - return - } - subIndx := hh.Index() - for _, i := range d.Columns { - ssz.AppendUint(hh, i) - } - hh.FillUpTo32() +func (c *ValidatorRegistrationV1) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - numItems := uint64(len(d.Columns)) - hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(128, numItems, 8)) + // Field 0: FeeRecipient + if len(c.FeeRecipient) != 20 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.FeeRecipient...) - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the ExecutionPayloadEnvelopesByRangeRequest object -func (e *ExecutionPayloadEnvelopesByRangeRequest) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(e) -} - -// MarshalSSZTo ssz marshals the ExecutionPayloadEnvelopesByRangeRequest object to a target array -func (e *ExecutionPayloadEnvelopesByRangeRequest) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf + // Field 1: GasLimit + dst = binary.LittleEndian.AppendUint64(dst, c.GasLimit) - // Field (0) 'StartSlot' - dst = ssz.MarshalUint(dst, e.StartSlot) + // Field 2: Timestamp + dst = binary.LittleEndian.AppendUint64(dst, c.Timestamp) - // Field (1) 'Count' - dst = ssz.MarshalUint(dst, e.Count) + // Field 3: Pubkey + if len(c.Pubkey) != 48 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.Pubkey...) - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the ExecutionPayloadEnvelopesByRangeRequest object -func (e *ExecutionPayloadEnvelopesByRangeRequest) UnmarshalSSZ(buf []byte) error { +func (c *ValidatorRegistrationV1) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 16 { + if size != 84 { return ssz.ErrSize } - // Field (0) 'StartSlot' - e.StartSlot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[0:8]) + sszSlice0 := buf[0:20] // c.FeeRecipient + sszSlice1 := buf[20:28] // c.GasLimit + sszSlice2 := buf[28:36] // c.Timestamp + sszSlice3 := buf[36:84] // c.Pubkey - // Field (1) 'Count' - e.Count = ssz.UnmarshallUint[uint64](buf[8:16]) + // Field 0: FeeRecipient + c.FeeRecipient = make([]byte, 0, 20) + c.FeeRecipient = append(c.FeeRecipient, sszSlice0...) - return err -} + // Field 1: GasLimit + c.GasLimit = binary.LittleEndian.Uint64(sszSlice1) + + // Field 2: Timestamp + c.Timestamp = binary.LittleEndian.Uint64(sszSlice2) -// SizeSSZ returns the ssz encoded size in bytes for the ExecutionPayloadEnvelopesByRangeRequest object -func (e *ExecutionPayloadEnvelopesByRangeRequest) SizeSSZ() (size int) { - size = 16 - return + // Field 3: Pubkey + c.Pubkey = make([]byte, 0, 48) + c.Pubkey = append(c.Pubkey, sszSlice3...) + return err } -// HashTreeRoot ssz hashes the ExecutionPayloadEnvelopesByRangeRequest object -func (e *ExecutionPayloadEnvelopesByRangeRequest) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(e) +func (c *ValidatorRegistrationV1) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the ExecutionPayloadEnvelopesByRangeRequest object with a hasher -func (e *ExecutionPayloadEnvelopesByRangeRequest) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *ValidatorRegistrationV1) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'StartSlot' - ssz.PutUint(hh, e.StartSlot) - - // Field (1) 'Count' - ssz.PutUint(hh, e.Count) - + // Field 0: FeeRecipient + if len(c.FeeRecipient) != 20 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.FeeRecipient) + // Field 1: GasLimit + hh.PutUint64(c.GasLimit) + // Field 2: Timestamp + hh.PutUint64(c.Timestamp) + // Field 3: Pubkey + if len(c.Pubkey) != 48 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Pubkey) hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the DepositSnapshot object -func (d *DepositSnapshot) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(d) +func (c *ValidatorIdentity) SizeSSZ() int { + size := 64 + + return size } -// MarshalSSZTo ssz marshals the DepositSnapshot object to a target array -func (d *DepositSnapshot) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(84) +func (c *ValidatorIdentity) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Offset (0) 'Finalized' - dst = ssz.WriteOffset(dst, offset) - offset += len(d.Finalized) * 32 +func (c *ValidatorIdentity) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (1) 'DepositRoot' - if size := len(d.DepositRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.DepositRoot", size, 32) - return + // Field 0: Index + if dst, err = c.Index.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Index: %w", err) } - dst = append(dst, d.DepositRoot...) - - // Field (2) 'DepositCount' - dst = ssz.MarshalUint(dst, d.DepositCount) - // Field (3) 'ExecutionHash' - if size := len(d.ExecutionHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.ExecutionHash", size, 32) - return + // Field 1: Pubkey + if len(c.Pubkey) != 48 { + return nil, ssz.ErrBytesLength } - dst = append(dst, d.ExecutionHash...) + dst = append(dst, c.Pubkey...) - // Field (4) 'ExecutionDepth' - dst = ssz.MarshalUint(dst, d.ExecutionDepth) - - // Field (0) 'Finalized' - if size := len(d.Finalized); size > 32 { - err = ssz.ErrListTooBigFn("--.Finalized", size, 32) - return - } - for ii := 0; ii < len(d.Finalized); ii++ { - if size := len(d.Finalized[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.Finalized[ii]", size, 32) - return - } - dst = append(dst, d.Finalized[ii]...) + // Field 2: ActivationEpoch + if dst, err = c.ActivationEpoch.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ActivationEpoch: %w", err) } - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the DepositSnapshot object -func (d *DepositSnapshot) UnmarshalSSZ(buf []byte) error { +func (c *ValidatorIdentity) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 84 { + if size != 64 { return ssz.ErrSize } - tail := buf - var o0 uint64 + sszSlice0 := buf[0:8] // c.Index + sszSlice1 := buf[8:56] // c.Pubkey + sszSlice2 := buf[56:64] // c.ActivationEpoch - // Offset (0) 'Finalized' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset + // Field 0: Index + if err = c.Index.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Index: %w", err) } - if o0 != 84 { - return ssz.ErrInvalidVariableOffset - } + // Field 1: Pubkey + c.Pubkey = make([]byte, 0, 48) + c.Pubkey = append(c.Pubkey, sszSlice1...) - // Field (1) 'DepositRoot' - if cap(d.DepositRoot) == 0 { - d.DepositRoot = make([]byte, 0, len(buf[4:36])) - } - d.DepositRoot = append(d.DepositRoot, buf[4:36]...) - - // Field (2) 'DepositCount' - d.DepositCount = ssz.UnmarshallUint[uint64](buf[36:44]) - - // Field (3) 'ExecutionHash' - if cap(d.ExecutionHash) == 0 { - d.ExecutionHash = make([]byte, 0, len(buf[44:76])) - } - d.ExecutionHash = append(d.ExecutionHash, buf[44:76]...) - - // Field (4) 'ExecutionDepth' - d.ExecutionDepth = ssz.UnmarshallUint[uint64](buf[76:84]) - - // Field (0) 'Finalized' - { - buf = tail[o0:] - num, err := ssz.DivideInt2(len(buf), 32, 32) - if err != nil { - return err - } - d.Finalized = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(d.Finalized[ii]) == 0 { - d.Finalized[ii] = make([]byte, 0, len(buf[ii*32:(ii+1)*32])) - } - d.Finalized[ii] = append(d.Finalized[ii], buf[ii*32:(ii+1)*32]...) - } + // Field 2: ActivationEpoch + if err = c.ActivationEpoch.UnmarshalSSZ(sszSlice2); err != nil { + return fmt.Errorf("ActivationEpoch: %w", err) } return err } -// SizeSSZ returns the ssz encoded size in bytes for the DepositSnapshot object -func (d *DepositSnapshot) SizeSSZ() (size int) { - size = 84 - - // Field (0) 'Finalized' - size += len(d.Finalized) * 32 - - return -} - -// HashTreeRoot ssz hashes the DepositSnapshot object -func (d *DepositSnapshot) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(d) +func (c *ValidatorIdentity) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the DepositSnapshot object with a hasher -func (d *DepositSnapshot) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *ValidatorIdentity) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Finalized' - { - if size := len(d.Finalized); size > 32 { - err = ssz.ErrListTooBigFn("--.Finalized", size, 32) - return - } - subIndx := hh.Index() - for _, i := range d.Finalized { - if len(i) != 32 { - err = ssz.ErrBytesLength - return - } - hh.Append(i) - } - - numItems := uint64(len(d.Finalized)) - hh.MerkleizeWithMixin(subIndx, numItems, 32) + // Field 0: Index + if err := c.Index.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Index: %w", err) } - - // Field (1) 'DepositRoot' - if size := len(d.DepositRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.DepositRoot", size, 32) - return + // Field 1: Pubkey + if len(c.Pubkey) != 48 { + return ssz.ErrBytesLength } - hh.PutBytes(d.DepositRoot) - - // Field (2) 'DepositCount' - ssz.PutUint(hh, d.DepositCount) - - // Field (3) 'ExecutionHash' - if size := len(d.ExecutionHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.ExecutionHash", size, 32) - return + hh.PutBytes(c.Pubkey) + // Field 2: ActivationEpoch + if err := c.ActivationEpoch.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ActivationEpoch: %w", err) } - hh.PutBytes(d.ExecutionHash) - - // Field (4) 'ExecutionDepth' - ssz.PutUint(hh, d.ExecutionDepth) - hh.Merkleize(indx) - return + return nil } diff --git a/proto/prysm/v1alpha1/non-core.yaml b/proto/prysm/v1alpha1/non-core.yaml new file mode 100644 index 000000000000..b0dca616d55d --- /dev/null +++ b/proto/prysm/v1alpha1/non-core.yaml @@ -0,0 +1,15 @@ +package: "github.com/OffchainLabs/prysm/v7/proto/prysm/v1alpha1" +types: + - name: "BeaconBlocksByRangeRequest" + - name: "BlobSidecarsByRangeRequest" + - name: "BuilderBid" + - name: "DataColumnSidecarsByRangeRequest" + - name: "DepositSnapshot" + - name: "ExecutionPayloadEnvelopesByRangeRequest" + - name: "MetaDataV0" + - name: "MetaDataV1" + - name: "MetaDataV2" + - name: "SignedBuilderBid" + - name: "SignedValidatorRegistrationV1" + - name: "ValidatorRegistrationV1" + - name: "ValidatorIdentity" diff --git a/proto/prysm/v1alpha1/phase0.minimal.ssz.go b/proto/prysm/v1alpha1/phase0.minimal.ssz.go index 98f83ed75a04..b6c832519768 100644 --- a/proto/prysm/v1alpha1/phase0.minimal.ssz.go +++ b/proto/prysm/v1alpha1/phase0.minimal.ssz.go @@ -1,4192 +1,4066 @@ //go:build minimal -// Code generated by fastssz. DO NOT EDIT. package eth import ( - github_com_OffchainLabs_prysm_v7_consensus_types_primitives "github.com/OffchainLabs/prysm/v7/consensus-types/primitives" - ssz "github.com/prysmaticlabs/fastssz" + binary "encoding/binary" + "fmt" + go_bitfield "github.com/OffchainLabs/go-bitfield" + ssz "github.com/OffchainLabs/methodical-ssz/ssz" ) -// MarshalSSZ ssz marshals the SignedAggregateAttestationAndProof object -func (s *SignedAggregateAttestationAndProof) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) -} - -// MarshalSSZTo ssz marshals the SignedAggregateAttestationAndProof object to a target array -func (s *SignedAggregateAttestationAndProof) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(100) - - // Offset (0) 'Message' - dst = ssz.WriteOffset(dst, offset) - if s.Message == nil { - s.Message = new(AggregateAttestationAndProof) - } - offset += s.Message.SizeSSZ() - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return - } - dst = append(dst, s.Signature...) - - // Field (0) 'Message' - if dst, err = s.Message.MarshalSSZTo(dst); err != nil { - return - } - - return -} - -// UnmarshalSSZ ssz unmarshals the SignedAggregateAttestationAndProof object -func (s *SignedAggregateAttestationAndProof) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 100 { - return ssz.ErrSize - } - - tail := buf - var o0 uint64 - - // Offset (0) 'Message' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } - - if o0 != 100 { - return ssz.ErrInvalidVariableOffset - } - - // Field (1) 'Signature' - if cap(s.Signature) == 0 { - s.Signature = make([]byte, 0, len(buf[4:100])) - } - s.Signature = append(s.Signature, buf[4:100]...) - - // Field (0) 'Message' - { - buf = tail[o0:] - if s.Message == nil { - s.Message = new(AggregateAttestationAndProof) - } - if err = s.Message.UnmarshalSSZ(buf); err != nil { - return err - } - } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the SignedAggregateAttestationAndProof object -func (s *SignedAggregateAttestationAndProof) SizeSSZ() (size int) { - size = 100 - - // Field (0) 'Message' - if s.Message == nil { - s.Message = new(AggregateAttestationAndProof) +func (c *AggregateAttestationAndProof) SizeSSZ() int { + size := 108 + if c.Aggregate == nil { + c.Aggregate = new(Attestation) } - size += s.Message.SizeSSZ() - - return + size += c.Aggregate.SizeSSZ() + return size } -// HashTreeRoot ssz hashes the SignedAggregateAttestationAndProof object -func (s *SignedAggregateAttestationAndProof) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) +func (c *AggregateAttestationAndProof) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// HashTreeRootWith ssz hashes the SignedAggregateAttestationAndProof object with a hasher -func (s *SignedAggregateAttestationAndProof) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() +func (c *AggregateAttestationAndProof) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 108 - // Field (0) 'Message' - if err = s.Message.HashTreeRootWith(hh); err != nil { - return + // Field 0: AggregatorIndex + if dst, err = c.AggregatorIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("AggregatorIndex: %w", err) } - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 1: Aggregate + if c.Aggregate == nil { + c.Aggregate = new(Attestation) } - hh.PutBytes(s.Signature) - - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the AggregateAttestationAndProof object -func (a *AggregateAttestationAndProof) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(a) -} - -// MarshalSSZTo ssz marshals the AggregateAttestationAndProof object to a target array -func (a *AggregateAttestationAndProof) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(108) - - // Field (0) 'AggregatorIndex' - dst = ssz.MarshalUint(dst, a.AggregatorIndex) - - // Offset (1) 'Aggregate' dst = ssz.WriteOffset(dst, offset) - if a.Aggregate == nil { - a.Aggregate = new(Attestation) - } - offset += a.Aggregate.SizeSSZ() + offset += c.Aggregate.SizeSSZ() - // Field (2) 'SelectionProof' - if size := len(a.SelectionProof); size != 96 { - err = ssz.ErrBytesLengthFn("--.SelectionProof", size, 96) - return + // Field 2: SelectionProof + if len(c.SelectionProof) != 96 { + return nil, ssz.ErrBytesLength } - dst = append(dst, a.SelectionProof...) + dst = append(dst, c.SelectionProof...) - // Field (1) 'Aggregate' - if dst, err = a.Aggregate.MarshalSSZTo(dst); err != nil { - return + // Field 1: Aggregate + if dst, err = c.Aggregate.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Aggregate: %w", err) } - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the AggregateAttestationAndProof object -func (a *AggregateAttestationAndProof) UnmarshalSSZ(buf []byte) error { +func (c *AggregateAttestationAndProof) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size < 108 { return ssz.ErrSize } - tail := buf - var o1 uint64 + sszSlice0 := buf[0:8] // c.AggregatorIndex + sszSlice2 := buf[12:108] // c.SelectionProof - // Field (0) 'AggregatorIndex' - a.AggregatorIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[0:8]) - - // Offset (1) 'Aggregate' - if o1 = ssz.ReadOffset(buf[8:12]); o1 > size { + sszVarOffset1 := ssz.ReadOffset(buf[8:12]) // c.Aggregate + if sszVarOffset1 != 108 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset1 > size { return ssz.ErrOffset } + sszSlice1 := buf[sszVarOffset1:] // c.Aggregate - if o1 != 108 { - return ssz.ErrInvalidVariableOffset + // Field 0: AggregatorIndex + if err = c.AggregatorIndex.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("AggregatorIndex: %w", err) } - // Field (2) 'SelectionProof' - if cap(a.SelectionProof) == 0 { - a.SelectionProof = make([]byte, 0, len(buf[12:108])) + // Field 1: Aggregate + c.Aggregate = new(Attestation) + if err = c.Aggregate.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Aggregate: %w", err) } - a.SelectionProof = append(a.SelectionProof, buf[12:108]...) - // Field (1) 'Aggregate' - { - buf = tail[o1:] - if a.Aggregate == nil { - a.Aggregate = new(Attestation) - } - if err = a.Aggregate.UnmarshalSSZ(buf); err != nil { - return err - } - } + // Field 2: SelectionProof + c.SelectionProof = make([]byte, 0, 96) + c.SelectionProof = append(c.SelectionProof, sszSlice2...) return err } -// SizeSSZ returns the ssz encoded size in bytes for the AggregateAttestationAndProof object -func (a *AggregateAttestationAndProof) SizeSSZ() (size int) { - size = 108 - - // Field (1) 'Aggregate' - if a.Aggregate == nil { - a.Aggregate = new(Attestation) +func (c *AggregateAttestationAndProof) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - size += a.Aggregate.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the AggregateAttestationAndProof object -func (a *AggregateAttestationAndProof) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(a) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the AggregateAttestationAndProof object with a hasher -func (a *AggregateAttestationAndProof) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *AggregateAttestationAndProof) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'AggregatorIndex' - ssz.PutUint(hh, a.AggregatorIndex) - - // Field (1) 'Aggregate' - if err = a.Aggregate.HashTreeRootWith(hh); err != nil { - return + // Field 0: AggregatorIndex + if err := c.AggregatorIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("AggregatorIndex: %w", err) } - - // Field (2) 'SelectionProof' - if size := len(a.SelectionProof); size != 96 { - err = ssz.ErrBytesLengthFn("--.SelectionProof", size, 96) - return + // Field 1: Aggregate + if err := c.Aggregate.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Aggregate: %w", err) } - hh.PutBytes(a.SelectionProof) - + // Field 2: SelectionProof + if len(c.SelectionProof) != 96 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.SelectionProof) hh.Merkleize(indx) - return + return nil +} + +func (c *Attestation) SizeSSZ() int { + size := 228 + size += len(c.AggregationBits) + return size } -// MarshalSSZ ssz marshals the Attestation object -func (a *Attestation) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(a) +func (c *Attestation) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// 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) +func (c *Attestation) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 228 - // Offset (0) 'AggregationBits' + // Field 0: AggregationBits dst = ssz.WriteOffset(dst, offset) - offset += len(a.AggregationBits) + offset += len(c.AggregationBits) - // Field (1) 'Data' - if a.Data == nil { - a.Data = new(AttestationData) + // Field 1: Data + if c.Data == nil { + c.Data = new(AttestationData) } - if dst, err = a.Data.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.Data.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Data: %w", err) } - // Field (2) 'Signature' - if size := len(a.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 2: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } - dst = append(dst, a.Signature...) + dst = append(dst, c.Signature...) - // Field (0) 'AggregationBits' - if size := len(a.AggregationBits); size > 2048 { - err = ssz.ErrBytesLengthFn("--.AggregationBits", size, 2048) - return + // Field 0: AggregationBits + if len(c.AggregationBits) > 2048 { + return nil, ssz.ErrListTooBig } - dst = append(dst, a.AggregationBits...) - - return + dst = append(dst, c.AggregationBits...) + return dst, err } -// UnmarshalSSZ ssz unmarshals the Attestation object -func (a *Attestation) UnmarshalSSZ(buf []byte) error { +func (c *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 - } + sszSlice1 := buf[4:132] // c.Data + sszSlice2 := buf[132:228] // c.Signature - if o0 != 228 { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.AggregationBits + if sszVarOffset0 != 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 + if sszVarOffset0 > size { + return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:] // c.AggregationBits - // Field (2) 'Signature' - if cap(a.Signature) == 0 { - a.Signature = make([]byte, 0, len(buf[132:228])) + // Field 0: AggregationBits + if err = ssz.ValidateBitlist(sszSlice0, 2048); err != nil { + return fmt.Errorf("AggregationBits: %w", err) } - a.Signature = append(a.Signature, buf[132:228]...) + c.AggregationBits = append([]byte{}, go_bitfield.Bitlist(sszSlice0)...) - // 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...) + // Field 1: Data + c.Data = new(AttestationData) + if err = c.Data.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Data: %w", err) } - 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 + // Field 2: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice2...) + return err } -// HashTreeRoot ssz hashes the Attestation object -func (a *Attestation) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(a) +func (c *Attestation) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the Attestation object with a hasher -func (a *Attestation) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *Attestation) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'AggregationBits' - if len(a.AggregationBits) == 0 { - err = ssz.ErrEmptyBitlist - return + // Field 0: AggregationBits + if len(c.AggregationBits) == 0 { + return ssz.ErrEmptyBitlist } - hh.PutBitlist(a.AggregationBits, 2048) - - // Field (1) 'Data' - if err = a.Data.HashTreeRootWith(hh); err != nil { - return + hh.PutBitlist(c.AggregationBits, 2048) + // Field 1: Data + if err := c.Data.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Data: %w", err) } - - // Field (2) 'Signature' - if size := len(a.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 2: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength } - hh.PutBytes(a.Signature) - + hh.PutBytes(c.Signature) hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the AttestationData object -func (a *AttestationData) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(a) +func (c *AttestationData) SizeSSZ() int { + size := 128 + + return size +} + +func (c *AttestationData) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the AttestationData object to a target array -func (a *AttestationData) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *AttestationData) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (0) 'Slot' - dst = ssz.MarshalUint(dst, a.Slot) + // Field 0: Slot + if dst, err = c.Slot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Slot: %w", err) + } - // Field (1) 'CommitteeIndex' - dst = ssz.MarshalUint(dst, a.CommitteeIndex) + // Field 1: CommitteeIndex + if dst, err = c.CommitteeIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("CommitteeIndex: %w", err) + } - // Field (2) 'BeaconBlockRoot' - if size := len(a.BeaconBlockRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.BeaconBlockRoot", size, 32) - return + // Field 2: BeaconBlockRoot + if len(c.BeaconBlockRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, a.BeaconBlockRoot...) + dst = append(dst, c.BeaconBlockRoot...) - // Field (3) 'Source' - if a.Source == nil { - a.Source = new(Checkpoint) + // Field 3: Source + if c.Source == nil { + c.Source = new(Checkpoint) } - if dst, err = a.Source.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.Source.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Source: %w", err) } - // Field (4) 'Target' - if a.Target == nil { - a.Target = new(Checkpoint) + // Field 4: Target + if c.Target == nil { + c.Target = new(Checkpoint) } - if dst, err = a.Target.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.Target.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Target: %w", err) } - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the AttestationData object -func (a *AttestationData) UnmarshalSSZ(buf []byte) error { +func (c *AttestationData) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size != 128 { return ssz.ErrSize } - // Field (0) 'Slot' - a.Slot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[0:8]) + sszSlice0 := buf[0:8] // c.Slot + sszSlice1 := buf[8:16] // c.CommitteeIndex + sszSlice2 := buf[16:48] // c.BeaconBlockRoot + sszSlice3 := buf[48:88] // c.Source + sszSlice4 := buf[88:128] // c.Target - // Field (1) 'CommitteeIndex' - a.CommitteeIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.CommitteeIndex](buf[8:16]) - - // Field (2) 'BeaconBlockRoot' - if cap(a.BeaconBlockRoot) == 0 { - a.BeaconBlockRoot = make([]byte, 0, len(buf[16:48])) + // Field 0: Slot + if err = c.Slot.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Slot: %w", err) } - a.BeaconBlockRoot = append(a.BeaconBlockRoot, 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 1: CommitteeIndex + if err = c.CommitteeIndex.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("CommitteeIndex: %w", err) } - // Field (4) 'Target' - if a.Target == nil { - a.Target = new(Checkpoint) - } - if err = a.Target.UnmarshalSSZ(buf[88:128]); err != nil { - return err + // Field 2: BeaconBlockRoot + c.BeaconBlockRoot = make([]byte, 0, 32) + c.BeaconBlockRoot = append(c.BeaconBlockRoot, sszSlice2...) + + // Field 3: Source + c.Source = new(Checkpoint) + if err = c.Source.UnmarshalSSZ(sszSlice3); err != nil { + return fmt.Errorf("Source: %w", err) } + // Field 4: Target + c.Target = new(Checkpoint) + if err = c.Target.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("Target: %w", 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) +func (c *AttestationData) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the AttestationData object with a hasher -func (a *AttestationData) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *AttestationData) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Slot' - ssz.PutUint(hh, a.Slot) - - // Field (1) 'CommitteeIndex' - ssz.PutUint(hh, a.CommitteeIndex) - - // Field (2) 'BeaconBlockRoot' - if size := len(a.BeaconBlockRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.BeaconBlockRoot", size, 32) - return + // Field 0: Slot + if err := c.Slot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Slot: %w", err) } - hh.PutBytes(a.BeaconBlockRoot) - - // Field (3) 'Source' - if err = a.Source.HashTreeRootWith(hh); err != nil { - return + // Field 1: CommitteeIndex + if err := c.CommitteeIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("CommitteeIndex: %w", err) } - - // Field (4) 'Target' - if err = a.Target.HashTreeRootWith(hh); err != nil { - return + // Field 2: BeaconBlockRoot + if len(c.BeaconBlockRoot) != 32 { + return ssz.ErrBytesLength } - - hh.Merkleize(indx) - return -} - -// 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.MarshalUint(dst, c.Epoch) - - // Field (1) 'Root' - if size := len(c.Root); size != 32 { - err = ssz.ErrBytesLengthFn("--.Root", size, 32) - return + hh.PutBytes(c.BeaconBlockRoot) + // Field 3: Source + if err := c.Source.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Source: %w", err) } - dst = append(dst, c.Root...) - - return + // Field 4: Target + if err := c.Target.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Target: %w", err) + } + hh.Merkleize(indx) + return nil } -// 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 +func (c *AttesterSlashing) SizeSSZ() int { + size := 8 + if c.Attestation_1 == nil { + c.Attestation_1 = new(IndexedAttestation) } - - // Field (0) 'Epoch' - c.Epoch = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Epoch](buf[0:8]) - - // Field (1) 'Root' - if cap(c.Root) == 0 { - c.Root = make([]byte, 0, len(buf[8:40])) + size += c.Attestation_1.SizeSSZ() + if c.Attestation_2 == nil { + c.Attestation_2 = new(IndexedAttestation) } - 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 + size += c.Attestation_2.SizeSSZ() + return size } -// HashTreeRoot ssz hashes the Checkpoint object -func (c *Checkpoint) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(c) +func (c *AttesterSlashing) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// HashTreeRootWith ssz hashes the Checkpoint object with a hasher -func (c *Checkpoint) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'Epoch' - ssz.PutUint(hh, c.Epoch) +func (c *AttesterSlashing) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 8 - // Field (1) 'Root' - if size := len(c.Root); size != 32 { - err = ssz.ErrBytesLengthFn("--.Root", size, 32) - return + // Field 0: Attestation_1 + if c.Attestation_1 == nil { + c.Attestation_1 = new(IndexedAttestation) } - hh.PutBytes(c.Root) - - hh.Merkleize(indx) - return -} - -// 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) - if s.Block == nil { - s.Block = new(BeaconBlock) - } - offset += s.Block.SizeSSZ() + offset += c.Attestation_1.SizeSSZ() - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 1: Attestation_2 + if c.Attestation_2 == nil { + c.Attestation_2 = new(IndexedAttestation) } - dst = append(dst, s.Signature...) + dst = ssz.WriteOffset(dst, offset) + offset += c.Attestation_2.SizeSSZ() - // Field (0) 'Block' - if dst, err = s.Block.MarshalSSZTo(dst); err != nil { - return + // Field 0: Attestation_1 + if dst, err = c.Attestation_1.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Attestation_1: %w", err) } - return + // Field 1: Attestation_2 + if dst, err = c.Attestation_2.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Attestation_2: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the SignedBeaconBlock object -func (s *SignedBeaconBlock) UnmarshalSSZ(buf []byte) error { +func (c *AttesterSlashing) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 100 { + if size < 8 { return ssz.ErrSize } - tail := buf - var o0 uint64 - - // Offset (0) 'Block' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Attestation_1 + if sszVarOffset0 != 8 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset0 > size { return ssz.ErrOffset } - - if o0 != 100 { - return ssz.ErrInvalidVariableOffset + sszVarOffset1 := ssz.ReadOffset(buf[4:8]) // c.Attestation_2 + if sszVarOffset1 > size || sszVarOffset1 < sszVarOffset0 { + return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:sszVarOffset1] // c.Attestation_1 + sszSlice1 := buf[sszVarOffset1:] // c.Attestation_2 - // Field (1) 'Signature' - if cap(s.Signature) == 0 { - s.Signature = make([]byte, 0, len(buf[4:100])) + // Field 0: Attestation_1 + c.Attestation_1 = new(IndexedAttestation) + if err = c.Attestation_1.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Attestation_1: %w", err) } - 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 - } + // Field 1: Attestation_2 + c.Attestation_2 = new(IndexedAttestation) + if err = c.Attestation_2.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Attestation_2: %w", 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) +func (c *AttesterSlashing) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - size += s.Block.SizeSSZ() - - return + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// 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.Hasher) (err error) { +func (c *AttesterSlashing) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Block' - if err = s.Block.HashTreeRootWith(hh); err != nil { - return + // Field 0: Attestation_1 + if err := c.Attestation_1.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Attestation_1: %w", err) } - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 1: Attestation_2 + if err := c.Attestation_2.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Attestation_2: %w", err) } - hh.PutBytes(s.Signature) - hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the BeaconBlock object -func (b *BeaconBlock) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) +func (c *BeaconBlock) SizeSSZ() int { + size := 84 + if c.Body == nil { + c.Body = new(BeaconBlockBody) + } + size += c.Body.SizeSSZ() + return size } -// 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) +func (c *BeaconBlock) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (0) 'Slot' - dst = ssz.MarshalUint(dst, b.Slot) +func (c *BeaconBlock) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 84 - // Field (1) 'ProposerIndex' - dst = ssz.MarshalUint(dst, b.ProposerIndex) + // Field 0: Slot + if dst, err = c.Slot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Slot: %w", err) + } - // Field (2) 'ParentRoot' - if size := len(b.ParentRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentRoot", size, 32) - return + // Field 1: ProposerIndex + if dst, err = c.ProposerIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ProposerIndex: %w", err) } - dst = append(dst, b.ParentRoot...) - // Field (3) 'StateRoot' - if size := len(b.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return + // Field 2: ParentRoot + if len(c.ParentRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.StateRoot...) + dst = append(dst, c.ParentRoot...) - // Offset (4) 'Body' - dst = ssz.WriteOffset(dst, offset) - if b.Body == nil { - b.Body = new(BeaconBlockBody) + // Field 3: StateRoot + if len(c.StateRoot) != 32 { + return nil, ssz.ErrBytesLength } - offset += b.Body.SizeSSZ() + dst = append(dst, c.StateRoot...) - // Field (4) 'Body' - if dst, err = b.Body.MarshalSSZTo(dst); err != nil { - return + // Field 4: Body + if c.Body == nil { + c.Body = new(BeaconBlockBody) } + dst = ssz.WriteOffset(dst, offset) + offset += c.Body.SizeSSZ() - return + // Field 4: Body + if dst, err = c.Body.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Body: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the BeaconBlock object -func (b *BeaconBlock) UnmarshalSSZ(buf []byte) error { +func (c *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.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[0:8]) - - // Field (1) 'ProposerIndex' - b.ProposerIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](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]...) + sszSlice0 := buf[0:8] // c.Slot + sszSlice1 := buf[8:16] // c.ProposerIndex + sszSlice2 := buf[16:48] // c.ParentRoot + sszSlice3 := buf[48:80] // c.StateRoot - // Field (3) 'StateRoot' - if cap(b.StateRoot) == 0 { - b.StateRoot = make([]byte, 0, len(buf[48:80])) + sszVarOffset4 := ssz.ReadOffset(buf[80:84]) // c.Body + if sszVarOffset4 != 84 { + return ssz.ErrInvalidVariableOffset } - b.StateRoot = append(b.StateRoot, buf[48:80]...) - - // Offset (4) 'Body' - if o4 = ssz.ReadOffset(buf[80:84]); o4 > size { + if sszVarOffset4 > size { return ssz.ErrOffset } + sszSlice4 := buf[sszVarOffset4:] // c.Body - if o4 != 84 { - return ssz.ErrInvalidVariableOffset + // Field 0: Slot + if err = c.Slot.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Slot: %w", err) } - // Field (4) 'Body' - { - buf = tail[o4:] - if b.Body == nil { - b.Body = new(BeaconBlockBody) - } - if err = b.Body.UnmarshalSSZ(buf); err != nil { - return err - } + // Field 1: ProposerIndex + if err = c.ProposerIndex.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("ProposerIndex: %w", err) } - return err -} -// SizeSSZ returns the ssz encoded size in bytes for the BeaconBlock object -func (b *BeaconBlock) SizeSSZ() (size int) { - size = 84 + // Field 2: ParentRoot + c.ParentRoot = make([]byte, 0, 32) + c.ParentRoot = append(c.ParentRoot, sszSlice2...) - // Field (4) 'Body' - if b.Body == nil { - b.Body = new(BeaconBlockBody) - } - size += b.Body.SizeSSZ() + // Field 3: StateRoot + c.StateRoot = make([]byte, 0, 32) + c.StateRoot = append(c.StateRoot, sszSlice3...) - return + // Field 4: Body + c.Body = new(BeaconBlockBody) + if err = c.Body.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("Body: %w", err) + } + return err } -// HashTreeRoot ssz hashes the BeaconBlock object -func (b *BeaconBlock) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) +func (c *BeaconBlock) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the BeaconBlock object with a hasher -func (b *BeaconBlock) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *BeaconBlock) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Slot' - ssz.PutUint(hh, b.Slot) - - // Field (1) 'ProposerIndex' - ssz.PutUint(hh, b.ProposerIndex) - - // Field (2) 'ParentRoot' - if size := len(b.ParentRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentRoot", size, 32) - return + // Field 0: Slot + if err := c.Slot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Slot: %w", err) } - hh.PutBytes(b.ParentRoot) - - // Field (3) 'StateRoot' - if size := len(b.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return + // Field 1: ProposerIndex + if err := c.ProposerIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ProposerIndex: %w", err) } - hh.PutBytes(b.StateRoot) - - // Field (4) 'Body' - if err = b.Body.HashTreeRootWith(hh); err != nil { - return + // Field 2: ParentRoot + if len(c.ParentRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ParentRoot) + // Field 3: StateRoot + if len(c.StateRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.StateRoot) + // Field 4: Body + if err := c.Body.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Body: %w", err) } - hh.Merkleize(indx) - return + return nil +} + +func (c *BeaconBlockBody) SizeSSZ() int { + size := 220 + size += len(c.ProposerSlashings) * 416 + for _, o := range c.AttesterSlashings { + size += 4 + size += o.SizeSSZ() + } + for _, o := range c.Attestations { + size += 4 + size += o.SizeSSZ() + } + size += len(c.Deposits) * 1240 + size += len(c.VoluntaryExits) * 112 + return size } -// MarshalSSZ ssz marshals the BeaconBlockBody object -func (b *BeaconBlockBody) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) +func (c *BeaconBlockBody) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the BeaconBlockBody object to a target array -func (b *BeaconBlockBody) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(220) +func (c *BeaconBlockBody) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 220 - // Field (0) 'RandaoReveal' - if size := len(b.RandaoReveal); size != 96 { - err = ssz.ErrBytesLengthFn("--.RandaoReveal", size, 96) - return + // Field 0: RandaoReveal + if len(c.RandaoReveal) != 96 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.RandaoReveal...) + dst = append(dst, c.RandaoReveal...) - // Field (1) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(Eth1Data) + // Field 1: Eth1Data + if c.Eth1Data == nil { + c.Eth1Data = new(Eth1Data) } - if dst, err = b.Eth1Data.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.Eth1Data.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Eth1Data: %w", err) } - // Field (2) 'Graffiti' - if size := len(b.Graffiti); size != 32 { - err = ssz.ErrBytesLengthFn("--.Graffiti", size, 32) - return + // Field 2: Graffiti + if len(c.Graffiti) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.Graffiti...) + dst = append(dst, c.Graffiti...) - // Offset (3) 'ProposerSlashings' + // Field 3: ProposerSlashings dst = ssz.WriteOffset(dst, offset) - offset += len(b.ProposerSlashings) * 416 + offset += len(c.ProposerSlashings) * 416 - // Offset (4) 'AttesterSlashings' + // Field 4: AttesterSlashings dst = ssz.WriteOffset(dst, offset) - for ii := 0; ii < len(b.AttesterSlashings); ii++ { + for _, o := range c.AttesterSlashings { offset += 4 - offset += b.AttesterSlashings[ii].SizeSSZ() + offset += o.SizeSSZ() } - // Offset (5) 'Attestations' + // Field 5: Attestations dst = ssz.WriteOffset(dst, offset) - for ii := 0; ii < len(b.Attestations); ii++ { + for _, o := range c.Attestations { offset += 4 - offset += b.Attestations[ii].SizeSSZ() + offset += o.SizeSSZ() } - // Offset (6) 'Deposits' + // Field 6: Deposits dst = ssz.WriteOffset(dst, offset) - offset += len(b.Deposits) * 1240 + offset += len(c.Deposits) * 1240 - // Offset (7) 'VoluntaryExits' + // Field 7: VoluntaryExits dst = ssz.WriteOffset(dst, offset) - offset += len(b.VoluntaryExits) * 112 + offset += len(c.VoluntaryExits) * 112 - // Field (3) 'ProposerSlashings' - if size := len(b.ProposerSlashings); size > 16 { - err = ssz.ErrListTooBigFn("--.ProposerSlashings", size, 16) - return + // Field 3: ProposerSlashings + if len(c.ProposerSlashings) > 16 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.ProposerSlashings); ii++ { - if dst, err = b.ProposerSlashings[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.ProposerSlashings { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ProposerSlashings: %w", err) } } - // Field (4) 'AttesterSlashings' - if size := len(b.AttesterSlashings); size > 2 { - err = ssz.ErrListTooBigFn("--.AttesterSlashings", size, 2) - return + // Field 4: AttesterSlashings + if len(c.AttesterSlashings) > 2 { + return nil, ssz.ErrListTooBig } { - offset = 4 * len(b.AttesterSlashings) - for ii := 0; ii < len(b.AttesterSlashings); ii++ { + offset = 4 * len(c.AttesterSlashings) + for _, o := range c.AttesterSlashings { dst = ssz.WriteOffset(dst, offset) - offset += b.AttesterSlashings[ii].SizeSSZ() + offset += o.SizeSSZ() } } - for ii := 0; ii < len(b.AttesterSlashings); ii++ { - if dst, err = b.AttesterSlashings[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.AttesterSlashings { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("AttesterSlashings: %w", err) } } - // Field (5) 'Attestations' - if size := len(b.Attestations); size > 128 { - err = ssz.ErrListTooBigFn("--.Attestations", size, 128) - return + // Field 5: Attestations + if len(c.Attestations) > 128 { + return nil, ssz.ErrListTooBig } { - offset = 4 * len(b.Attestations) - for ii := 0; ii < len(b.Attestations); ii++ { + offset = 4 * len(c.Attestations) + for _, o := range c.Attestations { dst = ssz.WriteOffset(dst, offset) - offset += b.Attestations[ii].SizeSSZ() + offset += o.SizeSSZ() } } - for ii := 0; ii < len(b.Attestations); ii++ { - if dst, err = b.Attestations[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.Attestations { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Attestations: %w", err) } } - // Field (6) 'Deposits' - if size := len(b.Deposits); size > 16 { - err = ssz.ErrListTooBigFn("--.Deposits", size, 16) - return + // Field 6: Deposits + if len(c.Deposits) > 16 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.Deposits); ii++ { - if dst, err = b.Deposits[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.Deposits { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Deposits: %w", err) } } - // Field (7) 'VoluntaryExits' - if size := len(b.VoluntaryExits); size > 16 { - err = ssz.ErrListTooBigFn("--.VoluntaryExits", size, 16) - return + // Field 7: VoluntaryExits + if len(c.VoluntaryExits) > 16 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.VoluntaryExits); ii++ { - if dst, err = b.VoluntaryExits[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.VoluntaryExits { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("VoluntaryExits: %w", err) } } - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the BeaconBlockBody object -func (b *BeaconBlockBody) UnmarshalSSZ(buf []byte) error { +func (c *BeaconBlockBody) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size < 220 { return ssz.ErrSize } - tail := buf - var o3, o4, o5, o6, o7 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(Eth1Data) - } - if err = b.Eth1Data.UnmarshalSSZ(buf[96:168]); err != nil { - return err - } + sszSlice0 := buf[0:96] // c.RandaoReveal + sszSlice1 := buf[96:168] // c.Eth1Data + sszSlice2 := buf[168:200] // c.Graffiti - // Field (2) 'Graffiti' - if cap(b.Graffiti) == 0 { - b.Graffiti = make([]byte, 0, len(buf[168:200])) + sszVarOffset3 := ssz.ReadOffset(buf[200:204]) // c.ProposerSlashings + if sszVarOffset3 != 220 { + return ssz.ErrInvalidVariableOffset } - b.Graffiti = append(b.Graffiti, buf[168:200]...) - - // Offset (3) 'ProposerSlashings' - if o3 = ssz.ReadOffset(buf[200:204]); o3 > size { + if sszVarOffset3 > size { return ssz.ErrOffset } - - if o3 != 220 { - return ssz.ErrInvalidVariableOffset + sszVarOffset4 := ssz.ReadOffset(buf[204:208]) // c.AttesterSlashings + if sszVarOffset4 > size || sszVarOffset4 < sszVarOffset3 { + return ssz.ErrOffset } - - // Offset (4) 'AttesterSlashings' - if o4 = ssz.ReadOffset(buf[204:208]); o4 > size || o3 > o4 { + sszVarOffset5 := ssz.ReadOffset(buf[208:212]) // c.Attestations + if sszVarOffset5 > size || sszVarOffset5 < sszVarOffset4 { return ssz.ErrOffset } - - // Offset (5) 'Attestations' - if o5 = ssz.ReadOffset(buf[208:212]); o5 > size || o4 > o5 { + sszVarOffset6 := ssz.ReadOffset(buf[212:216]) // c.Deposits + if sszVarOffset6 > size || sszVarOffset6 < sszVarOffset5 { return ssz.ErrOffset } - - // Offset (6) 'Deposits' - if o6 = ssz.ReadOffset(buf[212:216]); o6 > size || o5 > o6 { + sszVarOffset7 := ssz.ReadOffset(buf[216:220]) // c.VoluntaryExits + if sszVarOffset7 > size || sszVarOffset7 < sszVarOffset6 { return ssz.ErrOffset } + sszSlice3 := buf[sszVarOffset3:sszVarOffset4] // c.ProposerSlashings + sszSlice4 := buf[sszVarOffset4:sszVarOffset5] // c.AttesterSlashings + sszSlice5 := buf[sszVarOffset5:sszVarOffset6] // c.Attestations + sszSlice6 := buf[sszVarOffset6:sszVarOffset7] // c.Deposits + sszSlice7 := buf[sszVarOffset7:] // c.VoluntaryExits - // Offset (7) 'VoluntaryExits' - if o7 = ssz.ReadOffset(buf[216:220]); o7 > size || o6 > o7 { - return ssz.ErrOffset + // Field 0: RandaoReveal + c.RandaoReveal = make([]byte, 0, 96) + c.RandaoReveal = append(c.RandaoReveal, sszSlice0...) + + // Field 1: Eth1Data + c.Eth1Data = new(Eth1Data) + if err = c.Eth1Data.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Eth1Data: %w", err) } - // Field (3) 'ProposerSlashings' + // Field 2: Graffiti + c.Graffiti = make([]byte, 0, 32) + c.Graffiti = append(c.Graffiti, sszSlice2...) + + // Field 3: ProposerSlashings { - buf = tail[o3:o4] - num, err := ssz.DivideInt2(len(buf), 416, 16) - if err != nil { - return err - } - b.ProposerSlashings = make([]*ProposerSlashing, num) - for ii := 0; ii < num; ii++ { - if b.ProposerSlashings[ii] == nil { - b.ProposerSlashings[ii] = new(ProposerSlashing) - } - if err = b.ProposerSlashings[ii].UnmarshalSSZ(buf[ii*416 : (ii+1)*416]); err != nil { - return err + if len(sszSlice3)%416 != 0 { + return fmt.Errorf("misaligned bytes: c.ProposerSlashings length is %d, which is not a multiple of 416: %w", len(sszSlice3), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice3) / 416 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.ProposerSlashings has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.ProposerSlashings = make([]*ProposerSlashing, numElem) + for i := 0; i < numElem; i++ { + var tmp *ProposerSlashing + tmp = new(ProposerSlashing) + tmpSlice := sszSlice3[i*416 : (1+i)*416] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("ProposerSlashings: %w", err) } + c.ProposerSlashings[i] = tmp } } - // Field (4) 'AttesterSlashings' + // Field 4: AttesterSlashings { - buf = tail[o4:o5] - num, err := ssz.DecodeDynamicLength(buf, 2) - 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) + // empty lists are zero length, so make sure there is room for an offset + // before attempting to unmarshal it + if len(sszSlice4) > 3 { + startOffset := ssz.ReadOffset(sszSlice4[0:4]) + if startOffset == 0 { + return fmt.Errorf("encountered invalid offset of 0 when decoding c.AttesterSlashings") + } + if startOffset%4 != 0 { + return fmt.Errorf("misaligned list bytes: when decoding c.AttesterSlashings, end-of-list offset is %d, which is not a multiple of 4 (offset size)", startOffset) } - if err = b.AttesterSlashings[indx].UnmarshalSSZ(buf); err != nil { - return err + listLen := startOffset / 4 + if listLen > 2 { + return fmt.Errorf("ssz-max exceeded: c.AttesterSlashings has %d elements, ssz-max is 2: %w", listLen, ssz.ErrListTooBig) } - return nil - }) - if err != nil { - return err + totalVarBytes := uint64(len(sszSlice4)) + if totalVarBytes < startOffset { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.AttesterSlashings") + } + c.AttesterSlashings = make([]*AttesterSlashing, listLen) + var tmpSlice []byte + for i := uint64(0); i < listLen; i++ { + var tmp *AttesterSlashing + tmp = new(AttesterSlashing) + endOffset := totalVarBytes + if i+1 != listLen { + endOffset = ssz.ReadOffset(sszSlice4[(i+1)*4 : (i+2)*4]) + if totalVarBytes < endOffset { + return fmt.Errorf("offset %d points past the end of buffer when decoding c.AttesterSlashings", endOffset) + } + } + if endOffset < startOffset { + return fmt.Errorf("offset %d is not greater than start offset %d when decoding c.AttesterSlashings", endOffset, startOffset) + } + tmpSlice = sszSlice4[startOffset:endOffset] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("AttesterSlashings: %w", err) + } + c.AttesterSlashings[i] = tmp + startOffset = endOffset + } + } else { + if len(sszSlice4) > 0 { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.AttesterSlashings") + } + c.AttesterSlashings = make([]*AttesterSlashing, 0) } } - // Field (5) 'Attestations' + // Field 5: Attestations { - buf = tail[o5:o6] - num, err := ssz.DecodeDynamicLength(buf, 128) - 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) + // empty lists are zero length, so make sure there is room for an offset + // before attempting to unmarshal it + if len(sszSlice5) > 3 { + startOffset := ssz.ReadOffset(sszSlice5[0:4]) + if startOffset == 0 { + return fmt.Errorf("encountered invalid offset of 0 when decoding c.Attestations") + } + if startOffset%4 != 0 { + return fmt.Errorf("misaligned list bytes: when decoding c.Attestations, end-of-list offset is %d, which is not a multiple of 4 (offset size)", startOffset) + } + listLen := startOffset / 4 + if listLen > 128 { + return fmt.Errorf("ssz-max exceeded: c.Attestations has %d elements, ssz-max is 128: %w", listLen, ssz.ErrListTooBig) + } + totalVarBytes := uint64(len(sszSlice5)) + if totalVarBytes < startOffset { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.Attestations") + } + c.Attestations = make([]*Attestation, listLen) + var tmpSlice []byte + for i := uint64(0); i < listLen; i++ { + var tmp *Attestation + tmp = new(Attestation) + endOffset := totalVarBytes + if i+1 != listLen { + endOffset = ssz.ReadOffset(sszSlice5[(i+1)*4 : (i+2)*4]) + if totalVarBytes < endOffset { + return fmt.Errorf("offset %d points past the end of buffer when decoding c.Attestations", endOffset) + } + } + if endOffset < startOffset { + return fmt.Errorf("offset %d is not greater than start offset %d when decoding c.Attestations", endOffset, startOffset) + } + tmpSlice = sszSlice5[startOffset:endOffset] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Attestations: %w", err) + } + c.Attestations[i] = tmp + startOffset = endOffset } - if err = b.Attestations[indx].UnmarshalSSZ(buf); err != nil { - return err + } else { + if len(sszSlice5) > 0 { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.Attestations") } - return nil - }) - if err != nil { - return err + c.Attestations = make([]*Attestation, 0) } } - // Field (6) 'Deposits' + // Field 6: Deposits { - buf = tail[o6:o7] - num, err := ssz.DivideInt2(len(buf), 1240, 16) - if err != nil { - return err - } - b.Deposits = make([]*Deposit, num) - for ii := 0; ii < num; ii++ { - if b.Deposits[ii] == nil { - b.Deposits[ii] = new(Deposit) - } - if err = b.Deposits[ii].UnmarshalSSZ(buf[ii*1240 : (ii+1)*1240]); err != nil { - return err + if len(sszSlice6)%1240 != 0 { + return fmt.Errorf("misaligned bytes: c.Deposits length is %d, which is not a multiple of 1240: %w", len(sszSlice6), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice6) / 1240 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.Deposits has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.Deposits = make([]*Deposit, numElem) + for i := 0; i < numElem; i++ { + var tmp *Deposit + tmp = new(Deposit) + tmpSlice := sszSlice6[i*1240 : (1+i)*1240] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Deposits: %w", err) } + c.Deposits[i] = tmp } } - // Field (7) 'VoluntaryExits' + // Field 7: VoluntaryExits { - buf = tail[o7:] - num, err := ssz.DivideInt2(len(buf), 112, 16) - if err != nil { - return err - } - b.VoluntaryExits = make([]*SignedVoluntaryExit, num) - for ii := 0; ii < num; ii++ { - if b.VoluntaryExits[ii] == nil { - b.VoluntaryExits[ii] = new(SignedVoluntaryExit) - } - if err = b.VoluntaryExits[ii].UnmarshalSSZ(buf[ii*112 : (ii+1)*112]); err != nil { - return err + if len(sszSlice7)%112 != 0 { + return fmt.Errorf("misaligned bytes: c.VoluntaryExits length is %d, which is not a multiple of 112: %w", len(sszSlice7), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice7) / 112 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.VoluntaryExits has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.VoluntaryExits = make([]*SignedVoluntaryExit, numElem) + for i := 0; i < numElem; i++ { + var tmp *SignedVoluntaryExit + tmp = new(SignedVoluntaryExit) + tmpSlice := sszSlice7[i*112 : (1+i)*112] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("VoluntaryExits: %w", err) } + c.VoluntaryExits[i] = tmp } } return err } -// SizeSSZ returns the ssz encoded size in bytes for the BeaconBlockBody object -func (b *BeaconBlockBody) SizeSSZ() (size int) { - size = 220 - - // 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() +func (c *BeaconBlockBody) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - - // Field (6) 'Deposits' - size += len(b.Deposits) * 1240 - - // Field (7) 'VoluntaryExits' - size += len(b.VoluntaryExits) * 112 - - return -} - -// HashTreeRoot ssz hashes the BeaconBlockBody object -func (b *BeaconBlockBody) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the BeaconBlockBody object with a hasher -func (b *BeaconBlockBody) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *BeaconBlockBody) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'RandaoReveal' - if size := len(b.RandaoReveal); size != 96 { - err = ssz.ErrBytesLengthFn("--.RandaoReveal", size, 96) - return + // Field 0: RandaoReveal + if len(c.RandaoReveal) != 96 { + return ssz.ErrBytesLength } - hh.PutBytes(b.RandaoReveal) - - // Field (1) 'Eth1Data' - if err = b.Eth1Data.HashTreeRootWith(hh); err != nil { - return + hh.PutBytes(c.RandaoReveal) + // Field 1: Eth1Data + if err := c.Eth1Data.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Eth1Data: %w", err) } - - // Field (2) 'Graffiti' - if size := len(b.Graffiti); size != 32 { - err = ssz.ErrBytesLengthFn("--.Graffiti", size, 32) - return + // Field 2: Graffiti + if len(c.Graffiti) != 32 { + return ssz.ErrBytesLength } - hh.PutBytes(b.Graffiti) - - // Field (3) 'ProposerSlashings' + hh.PutBytes(c.Graffiti) + // Field 3: ProposerSlashings { - subIndx := hh.Index() - num := uint64(len(b.ProposerSlashings)) - if num > 16 { - err = ssz.ErrIncorrectListSize - return + if len(c.ProposerSlashings) > 16 { + return ssz.ErrListTooBig } - for _, elem := range b.ProposerSlashings { - if err = elem.HashTreeRootWith(hh); err != nil { - return + subIndx := hh.Index() + for _, o := range c.ProposerSlashings { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ProposerSlashings: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.ProposerSlashings)), 16) } - - // Field (4) 'AttesterSlashings' + // Field 4: AttesterSlashings { - subIndx := hh.Index() - num := uint64(len(b.AttesterSlashings)) - if num > 2 { - err = ssz.ErrIncorrectListSize - return + if len(c.AttesterSlashings) > 2 { + return ssz.ErrListTooBig } - for _, elem := range b.AttesterSlashings { - if err = elem.HashTreeRootWith(hh); err != nil { - return + subIndx := hh.Index() + for _, o := range c.AttesterSlashings { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("AttesterSlashings: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 2) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.AttesterSlashings)), 2) } - - // Field (5) 'Attestations' + // Field 5: Attestations { - subIndx := hh.Index() - num := uint64(len(b.Attestations)) - if num > 128 { - err = ssz.ErrIncorrectListSize - return + if len(c.Attestations) > 128 { + return ssz.ErrListTooBig } - for _, elem := range b.Attestations { - if err = elem.HashTreeRootWith(hh); err != nil { - return + subIndx := hh.Index() + for _, o := range c.Attestations { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Attestations: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 128) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Attestations)), 128) } - - // Field (6) 'Deposits' + // Field 6: Deposits { - subIndx := hh.Index() - num := uint64(len(b.Deposits)) - if num > 16 { - err = ssz.ErrIncorrectListSize - return + if len(c.Deposits) > 16 { + return ssz.ErrListTooBig } - for _, elem := range b.Deposits { - if err = elem.HashTreeRootWith(hh); err != nil { - return + subIndx := hh.Index() + for _, o := range c.Deposits { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Deposits: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Deposits)), 16) } - - // Field (7) 'VoluntaryExits' + // Field 7: VoluntaryExits { - subIndx := hh.Index() - num := uint64(len(b.VoluntaryExits)) - if num > 16 { - err = ssz.ErrIncorrectListSize - return + if len(c.VoluntaryExits) > 16 { + return ssz.ErrListTooBig } - for _, elem := range b.VoluntaryExits { - if err = elem.HashTreeRootWith(hh); err != nil { - return + subIndx := hh.Index() + for _, o := range c.VoluntaryExits { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("VoluntaryExits: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.VoluntaryExits)), 16) } - hh.Merkleize(indx) - return + return nil +} + +func (c *BeaconBlockHeader) SizeSSZ() int { + size := 112 + + return size } -// MarshalSSZ ssz marshals the AttesterSlashing object -func (a *AttesterSlashing) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(a) +func (c *BeaconBlockHeader) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// 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) +func (c *BeaconBlockHeader) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Offset (0) 'Attestation_1' - dst = ssz.WriteOffset(dst, offset) - if a.Attestation_1 == nil { - a.Attestation_1 = new(IndexedAttestation) + // Field 0: Slot + if dst, err = c.Slot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Slot: %w", err) } - offset += a.Attestation_1.SizeSSZ() - // Offset (1) 'Attestation_2' - dst = ssz.WriteOffset(dst, offset) - if a.Attestation_2 == nil { - a.Attestation_2 = new(IndexedAttestation) + // Field 1: ProposerIndex + if dst, err = c.ProposerIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ProposerIndex: %w", err) } - offset += a.Attestation_2.SizeSSZ() - // Field (0) 'Attestation_1' - if dst, err = a.Attestation_1.MarshalSSZTo(dst); err != nil { - return + // Field 2: ParentRoot + if len(c.ParentRoot) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.ParentRoot...) - // Field (1) 'Attestation_2' - if dst, err = a.Attestation_2.MarshalSSZTo(dst); err != nil { - return + // Field 3: StateRoot + if len(c.StateRoot) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.StateRoot...) - return + // Field 4: BodyRoot + if len(c.BodyRoot) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.BodyRoot...) + + return dst, err } -// UnmarshalSSZ ssz unmarshals the AttesterSlashing object -func (a *AttesterSlashing) UnmarshalSSZ(buf []byte) error { +func (c *BeaconBlockHeader) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 8 { + if size != 112 { return ssz.ErrSize } - tail := buf - var o0, o1 uint64 + sszSlice0 := buf[0:8] // c.Slot + sszSlice1 := buf[8:16] // c.ProposerIndex + sszSlice2 := buf[16:48] // c.ParentRoot + sszSlice3 := buf[48:80] // c.StateRoot + sszSlice4 := buf[80:112] // c.BodyRoot - // Offset (0) 'Attestation_1' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset + // Field 0: Slot + if err = c.Slot.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Slot: %w", err) } - if o0 != 8 { - return ssz.ErrInvalidVariableOffset + // Field 1: ProposerIndex + if err = c.ProposerIndex.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("ProposerIndex: %w", err) } - // Offset (1) 'Attestation_2' - if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 { - return ssz.ErrOffset - } + // Field 2: ParentRoot + c.ParentRoot = make([]byte, 0, 32) + c.ParentRoot = append(c.ParentRoot, sszSlice2...) - // Field (0) 'Attestation_1' - { - buf = tail[o0:o1] - if a.Attestation_1 == nil { - a.Attestation_1 = new(IndexedAttestation) - } - if err = a.Attestation_1.UnmarshalSSZ(buf); err != nil { - return err - } - } + // Field 3: StateRoot + c.StateRoot = make([]byte, 0, 32) + c.StateRoot = append(c.StateRoot, sszSlice3...) - // Field (1) 'Attestation_2' - { - buf = tail[o1:] - if a.Attestation_2 == nil { - a.Attestation_2 = new(IndexedAttestation) - } - if err = a.Attestation_2.UnmarshalSSZ(buf); err != nil { - return err - } - } + // Field 4: BodyRoot + c.BodyRoot = make([]byte, 0, 32) + c.BodyRoot = append(c.BodyRoot, sszSlice4...) return err } -// SizeSSZ returns the ssz encoded size in bytes for the AttesterSlashing object -func (a *AttesterSlashing) SizeSSZ() (size int) { - size = 8 - - // Field (0) 'Attestation_1' - if a.Attestation_1 == nil { - a.Attestation_1 = new(IndexedAttestation) - } - size += a.Attestation_1.SizeSSZ() - - // Field (1) 'Attestation_2' - if a.Attestation_2 == nil { - a.Attestation_2 = new(IndexedAttestation) +func (c *BeaconBlockHeader) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - size += a.Attestation_2.SizeSSZ() - - return + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// 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.Hasher) (err error) { +func (c *BeaconBlockHeader) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Attestation_1' - if err = a.Attestation_1.HashTreeRootWith(hh); err != nil { - return + // Field 0: Slot + if err := c.Slot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Slot: %w", err) } - - // Field (1) 'Attestation_2' - if err = a.Attestation_2.HashTreeRootWith(hh); err != nil { - return + // Field 1: ProposerIndex + if err := c.ProposerIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ProposerIndex: %w", err) } - - hh.Merkleize(indx) - return -} - -// 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) - offset += len(i.AttestingIndices) * 8 - - // Field (1) 'Data' - if i.Data == nil { - i.Data = new(AttestationData) + // Field 2: ParentRoot + if len(c.ParentRoot) != 32 { + return ssz.ErrBytesLength } - if dst, err = i.Data.MarshalSSZTo(dst); err != nil { - return + hh.PutBytes(c.ParentRoot) + // Field 3: StateRoot + if len(c.StateRoot) != 32 { + return ssz.ErrBytesLength } - - // Field (2) 'Signature' - if size := len(i.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + hh.PutBytes(c.StateRoot) + // Field 4: BodyRoot + if len(c.BodyRoot) != 32 { + return ssz.ErrBytesLength } - dst = append(dst, i.Signature...) + hh.PutBytes(c.BodyRoot) + hh.Merkleize(indx) + return nil +} - // Field (0) 'AttestingIndices' - if size := len(i.AttestingIndices); size > 2048 { - err = ssz.ErrListTooBigFn("--.AttestingIndices", size, 2048) - return +func (c *BeaconState) SizeSSZ() int { + size := 7057 + size += len(c.HistoricalRoots) * 32 + size += len(c.Eth1DataVotes) * 72 + size += len(c.Validators) * 121 + size += len(c.Balances) * 8 + for _, o := range c.PreviousEpochAttestations { + size += 4 + size += o.SizeSSZ() } - for ii := 0; ii < len(i.AttestingIndices); ii++ { - dst = ssz.MarshalUint(dst, i.AttestingIndices[ii]) + for _, o := range c.CurrentEpochAttestations { + size += 4 + size += o.SizeSSZ() } + return size +} - return +func (c *BeaconState) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// UnmarshalSSZ ssz unmarshals the IndexedAttestation object -func (i *IndexedAttestation) UnmarshalSSZ(buf []byte) error { +func (c *BeaconState) MarshalSSZTo(dst []byte) ([]byte, error) { var err error - size := uint64(len(buf)) - if size < 228 { - return ssz.ErrSize - } + offset := 7057 - tail := buf - var o0 uint64 + // Field 0: GenesisTime + dst = binary.LittleEndian.AppendUint64(dst, c.GenesisTime) - // Offset (0) 'AttestingIndices' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset + // Field 1: GenesisValidatorsRoot + if len(c.GenesisValidatorsRoot) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.GenesisValidatorsRoot...) - if o0 != 228 { - return ssz.ErrInvalidVariableOffset + // Field 2: Slot + if dst, err = c.Slot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Slot: %w", err) } - // Field (1) 'Data' - if i.Data == nil { - i.Data = new(AttestationData) + // Field 3: Fork + if c.Fork == nil { + c.Fork = new(Fork) } - if err = i.Data.UnmarshalSSZ(buf[4:132]); err != nil { - return err + if dst, err = c.Fork.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Fork: %w", err) } - // Field (2) 'Signature' - if cap(i.Signature) == 0 { - i.Signature = make([]byte, 0, len(buf[132:228])) + // Field 4: LatestBlockHeader + if c.LatestBlockHeader == nil { + c.LatestBlockHeader = new(BeaconBlockHeader) + } + if dst, err = c.LatestBlockHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("LatestBlockHeader: %w", err) } - i.Signature = append(i.Signature, buf[132:228]...) - // Field (0) 'AttestingIndices' - { - buf = tail[o0:] - num, err := ssz.DivideInt2(len(buf), 8, 2048) - if err != nil { - return err - } - i.AttestingIndices = ssz.ExtendUint(i.AttestingIndices, num) - for ii := 0; ii < num; ii++ { - i.AttestingIndices[ii] = ssz.UnmarshallUint[uint64](buf[ii*8 : (ii+1)*8]) + // Field 5: BlockRoots + if len(c.BlockRoots) != 64 { + return nil, ssz.ErrBytesLength + } + for _, o := range c.BlockRoots { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, o...) } - 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.Hasher) (err error) { - indx := hh.Index() - // Field (0) 'AttestingIndices' - { - if size := len(i.AttestingIndices); size > 2048 { - err = ssz.ErrListTooBigFn("--.AttestingIndices", size, 2048) - return - } - subIndx := hh.Index() - for _, i := range i.AttestingIndices { - ssz.AppendUint(hh, i) + // Field 6: StateRoots + if len(c.StateRoots) != 64 { + return nil, ssz.ErrBytesLength + } + for _, o := range c.StateRoots { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } - hh.FillUpTo32() - - numItems := uint64(len(i.AttestingIndices)) - hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(2048, numItems, 8)) + dst = append(dst, o...) } - // Field (1) 'Data' - if err = i.Data.HashTreeRootWith(hh); err != nil { - return - } + // Field 7: HistoricalRoots + dst = ssz.WriteOffset(dst, offset) + offset += len(c.HistoricalRoots) * 32 - // Field (2) 'Signature' - if size := len(i.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 8: Eth1Data + if c.Eth1Data == nil { + c.Eth1Data = new(Eth1Data) + } + if dst, err = c.Eth1Data.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Eth1Data: %w", err) } - hh.PutBytes(i.Signature) - - hh.Merkleize(indx) - return -} -// MarshalSSZ ssz marshals the BeaconBlockHeader object -func (b *BeaconBlockHeader) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} + // Field 9: Eth1DataVotes + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Eth1DataVotes) * 72 -// MarshalSSZTo ssz marshals the BeaconBlockHeader object to a target array -func (b *BeaconBlockHeader) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf + // Field 10: Eth1DepositIndex + dst = binary.LittleEndian.AppendUint64(dst, c.Eth1DepositIndex) - // Field (0) 'Slot' - dst = ssz.MarshalUint(dst, b.Slot) + // Field 11: Validators + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Validators) * 121 - // Field (1) 'ProposerIndex' - dst = ssz.MarshalUint(dst, b.ProposerIndex) + // Field 12: Balances + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Balances) * 8 - // Field (2) 'ParentRoot' - if size := len(b.ParentRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentRoot", size, 32) - return + // Field 13: RandaoMixes + if len(c.RandaoMixes) != 64 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.ParentRoot...) - - // Field (3) 'StateRoot' - if size := len(b.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return + for _, o := range c.RandaoMixes { + if len(o) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) } - dst = append(dst, b.StateRoot...) - // Field (4) 'BodyRoot' - if size := len(b.BodyRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.BodyRoot", size, 32) - return + // Field 14: Slashings + if len(c.Slashings) != 64 { + return nil, ssz.ErrBytesLength } - 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 + for _, o := range c.Slashings { + dst = binary.LittleEndian.AppendUint64(dst, o) } - // Field (0) 'Slot' - b.Slot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[0:8]) - - // Field (1) 'ProposerIndex' - b.ProposerIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[8:16]) - - // Field (2) 'ParentRoot' - if cap(b.ParentRoot) == 0 { - b.ParentRoot = make([]byte, 0, len(buf[16:48])) + // Field 15: PreviousEpochAttestations + dst = ssz.WriteOffset(dst, offset) + for _, o := range c.PreviousEpochAttestations { + offset += 4 + offset += o.SizeSSZ() } - 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])) + // Field 16: CurrentEpochAttestations + dst = ssz.WriteOffset(dst, offset) + for _, o := range c.CurrentEpochAttestations { + offset += 4 + offset += o.SizeSSZ() } - 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])) + // Field 17: JustificationBits + if len([]byte(c.JustificationBits)) != 1 { + return nil, ssz.ErrBytesLength } - 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 -} + dst = append(dst, []byte(c.JustificationBits)...) -// 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.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'Slot' - ssz.PutUint(hh, b.Slot) - - // Field (1) 'ProposerIndex' - ssz.PutUint(hh, b.ProposerIndex) - - // Field (2) 'ParentRoot' - if size := len(b.ParentRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentRoot", size, 32) - return + // Field 18: PreviousJustifiedCheckpoint + if c.PreviousJustifiedCheckpoint == nil { + c.PreviousJustifiedCheckpoint = new(Checkpoint) + } + if dst, err = c.PreviousJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("PreviousJustifiedCheckpoint: %w", err) } - hh.PutBytes(b.ParentRoot) - // Field (3) 'StateRoot' - if size := len(b.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return + // Field 19: CurrentJustifiedCheckpoint + if c.CurrentJustifiedCheckpoint == nil { + c.CurrentJustifiedCheckpoint = new(Checkpoint) + } + if dst, err = c.CurrentJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("CurrentJustifiedCheckpoint: %w", err) } - hh.PutBytes(b.StateRoot) - // Field (4) 'BodyRoot' - if size := len(b.BodyRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.BodyRoot", size, 32) - return + // Field 20: FinalizedCheckpoint + if c.FinalizedCheckpoint == nil { + c.FinalizedCheckpoint = new(Checkpoint) + } + if dst, err = c.FinalizedCheckpoint.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("FinalizedCheckpoint: %w", err) } - hh.PutBytes(b.BodyRoot) - hh.Merkleize(indx) - return -} + // Field 7: HistoricalRoots + if len(c.HistoricalRoots) > 16777216 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.HistoricalRoots { + if len(o) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) + } -// MarshalSSZ ssz marshals the SignedBeaconBlockHeader object -func (s *SignedBeaconBlockHeader) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) -} + // Field 9: Eth1DataVotes + if len(c.Eth1DataVotes) > 32 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.Eth1DataVotes { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Eth1DataVotes: %w", err) + } + } -// MarshalSSZTo ssz marshals the SignedBeaconBlockHeader object to a target array -func (s *SignedBeaconBlockHeader) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf + // Field 11: Validators + if len(c.Validators) > 1099511627776 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.Validators { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Validators: %w", err) + } + } - // Field (0) 'Header' - if s.Header == nil { - s.Header = new(BeaconBlockHeader) + // Field 12: Balances + if len(c.Balances) > 1099511627776 { + return nil, ssz.ErrListTooBig } - if dst, err = s.Header.MarshalSSZTo(dst); err != nil { - return + for _, o := range c.Balances { + dst = binary.LittleEndian.AppendUint64(dst, o) } - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 15: PreviousEpochAttestations + if len(c.PreviousEpochAttestations) > 1024 { + return nil, ssz.ErrListTooBig + } + { + offset = 4 * len(c.PreviousEpochAttestations) + for _, o := range c.PreviousEpochAttestations { + dst = ssz.WriteOffset(dst, offset) + offset += o.SizeSSZ() + } + } + for _, o := range c.PreviousEpochAttestations { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("PreviousEpochAttestations: %w", err) + } } - dst = append(dst, s.Signature...) - return + // Field 16: CurrentEpochAttestations + if len(c.CurrentEpochAttestations) > 1024 { + return nil, ssz.ErrListTooBig + } + { + offset = 4 * len(c.CurrentEpochAttestations) + for _, o := range c.CurrentEpochAttestations { + dst = ssz.WriteOffset(dst, offset) + offset += o.SizeSSZ() + } + } + for _, o := range c.CurrentEpochAttestations { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("CurrentEpochAttestations: %w", err) + } + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the SignedBeaconBlockHeader object -func (s *SignedBeaconBlockHeader) UnmarshalSSZ(buf []byte) error { +func (c *BeaconState) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 208 { + if size < 7057 { return ssz.ErrSize } - // Field (0) 'Header' - if s.Header == nil { - s.Header = new(BeaconBlockHeader) + sszSlice0 := buf[0:8] // c.GenesisTime + sszSlice1 := buf[8:40] // c.GenesisValidatorsRoot + sszSlice2 := buf[40:48] // c.Slot + sszSlice3 := buf[48:64] // c.Fork + sszSlice4 := buf[64:176] // c.LatestBlockHeader + sszSlice5 := buf[176:2224] // c.BlockRoots + sszSlice6 := buf[2224:4272] // c.StateRoots + sszSlice8 := buf[4276:4348] // c.Eth1Data + sszSlice10 := buf[4352:4360] // c.Eth1DepositIndex + sszSlice13 := buf[4368:6416] // c.RandaoMixes + sszSlice14 := buf[6416:6928] // c.Slashings + sszSlice17 := buf[6936:6937] // c.JustificationBits + sszSlice18 := buf[6937:6977] // c.PreviousJustifiedCheckpoint + sszSlice19 := buf[6977:7017] // c.CurrentJustifiedCheckpoint + sszSlice20 := buf[7017:7057] // c.FinalizedCheckpoint + + sszVarOffset7 := ssz.ReadOffset(buf[4272:4276]) // c.HistoricalRoots + if sszVarOffset7 != 7057 { + return ssz.ErrInvalidVariableOffset } - if err = s.Header.UnmarshalSSZ(buf[0:112]); err != nil { - return err + if sszVarOffset7 > size { + return ssz.ErrOffset } - - // Field (1) 'Signature' - if cap(s.Signature) == 0 { - s.Signature = make([]byte, 0, len(buf[112:208])) + sszVarOffset9 := ssz.ReadOffset(buf[4348:4352]) // c.Eth1DataVotes + if sszVarOffset9 > size || sszVarOffset9 < sszVarOffset7 { + return ssz.ErrOffset } - 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 -} + sszVarOffset11 := ssz.ReadOffset(buf[4360:4364]) // c.Validators + if sszVarOffset11 > size || sszVarOffset11 < sszVarOffset9 { + return ssz.ErrOffset + } + sszVarOffset12 := ssz.ReadOffset(buf[4364:4368]) // c.Balances + if sszVarOffset12 > size || sszVarOffset12 < sszVarOffset11 { + return ssz.ErrOffset + } + sszVarOffset15 := ssz.ReadOffset(buf[6928:6932]) // c.PreviousEpochAttestations + if sszVarOffset15 > size || sszVarOffset15 < sszVarOffset12 { + return ssz.ErrOffset + } + sszVarOffset16 := ssz.ReadOffset(buf[6932:6936]) // c.CurrentEpochAttestations + if sszVarOffset16 > size || sszVarOffset16 < sszVarOffset15 { + return ssz.ErrOffset + } + sszSlice7 := buf[sszVarOffset7:sszVarOffset9] // c.HistoricalRoots + sszSlice9 := buf[sszVarOffset9:sszVarOffset11] // c.Eth1DataVotes + sszSlice11 := buf[sszVarOffset11:sszVarOffset12] // c.Validators + sszSlice12 := buf[sszVarOffset12:sszVarOffset15] // c.Balances + sszSlice15 := buf[sszVarOffset15:sszVarOffset16] // c.PreviousEpochAttestations + sszSlice16 := buf[sszVarOffset16:] // c.CurrentEpochAttestations -// HashTreeRoot ssz hashes the SignedBeaconBlockHeader object -func (s *SignedBeaconBlockHeader) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) -} + // Field 0: GenesisTime + c.GenesisTime = binary.LittleEndian.Uint64(sszSlice0) -// HashTreeRootWith ssz hashes the SignedBeaconBlockHeader object with a hasher -func (s *SignedBeaconBlockHeader) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() + // Field 1: GenesisValidatorsRoot + c.GenesisValidatorsRoot = make([]byte, 0, 32) + c.GenesisValidatorsRoot = append(c.GenesisValidatorsRoot, sszSlice1...) - // Field (0) 'Header' - if err = s.Header.HashTreeRootWith(hh); err != nil { - return + // Field 2: Slot + if err = c.Slot.UnmarshalSSZ(sszSlice2); err != nil { + return fmt.Errorf("Slot: %w", err) } - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 3: Fork + c.Fork = new(Fork) + if err = c.Fork.UnmarshalSSZ(sszSlice3); err != nil { + return fmt.Errorf("Fork: %w", err) } - hh.PutBytes(s.Signature) - - hh.Merkleize(indx) - return -} -// MarshalSSZ ssz marshals the Eth1Data object -func (e *Eth1Data) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(e) -} + // Field 4: LatestBlockHeader + c.LatestBlockHeader = new(BeaconBlockHeader) + if err = c.LatestBlockHeader.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("LatestBlockHeader: %w", err) + } -// MarshalSSZTo ssz marshals the Eth1Data object to a target array -func (e *Eth1Data) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf + // Field 5: BlockRoots + { + c.BlockRoots = make([][]byte, 64) + for i := 0; i < 64; i++ { + var tmp []byte - // Field (0) 'DepositRoot' - if size := len(e.DepositRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.DepositRoot", size, 32) - return + tmpSlice := sszSlice5[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.BlockRoots[i] = tmp + } } - dst = append(dst, e.DepositRoot...) - // Field (1) 'DepositCount' - dst = ssz.MarshalUint(dst, e.DepositCount) + // Field 6: StateRoots + { + c.StateRoots = make([][]byte, 64) + for i := 0; i < 64; i++ { + var tmp []byte - // Field (2) 'BlockHash' - if size := len(e.BlockHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockHash", size, 32) - return + tmpSlice := sszSlice6[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.StateRoots[i] = tmp + } } - dst = append(dst, e.BlockHash...) - return -} + // Field 7: HistoricalRoots + { + if len(sszSlice7)%32 != 0 { + return fmt.Errorf("misaligned bytes: c.HistoricalRoots length is %d, which is not a multiple of 32: %w", len(sszSlice7), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice7) / 32 + if numElem > 16777216 { + return fmt.Errorf("ssz-max exceeded: c.HistoricalRoots has %d elements, ssz-max is 16777216: %w", numElem, ssz.ErrListTooBig) + } + c.HistoricalRoots = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte -// 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 + tmpSlice := sszSlice7[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.HistoricalRoots[i] = tmp + } } - // Field (0) 'DepositRoot' - if cap(e.DepositRoot) == 0 { - e.DepositRoot = make([]byte, 0, len(buf[0:32])) + // Field 8: Eth1Data + c.Eth1Data = new(Eth1Data) + if err = c.Eth1Data.UnmarshalSSZ(sszSlice8); err != nil { + return fmt.Errorf("Eth1Data: %w", err) } - e.DepositRoot = append(e.DepositRoot, buf[0:32]...) - - // Field (1) 'DepositCount' - e.DepositCount = ssz.UnmarshallUint[uint64](buf[32:40]) - // Field (2) 'BlockHash' - if cap(e.BlockHash) == 0 { - e.BlockHash = make([]byte, 0, len(buf[40:72])) + // Field 9: Eth1DataVotes + { + if len(sszSlice9)%72 != 0 { + return fmt.Errorf("misaligned bytes: c.Eth1DataVotes length is %d, which is not a multiple of 72: %w", len(sszSlice9), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice9) / 72 + if numElem > 32 { + return fmt.Errorf("ssz-max exceeded: c.Eth1DataVotes has %d elements, ssz-max is 32: %w", numElem, ssz.ErrListTooBig) + } + c.Eth1DataVotes = make([]*Eth1Data, numElem) + for i := 0; i < numElem; i++ { + var tmp *Eth1Data + tmp = new(Eth1Data) + tmpSlice := sszSlice9[i*72 : (1+i)*72] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Eth1DataVotes: %w", err) + } + c.Eth1DataVotes[i] = tmp + } } - 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.Hasher) (err error) { - indx := hh.Index() + // Field 10: Eth1DepositIndex + c.Eth1DepositIndex = binary.LittleEndian.Uint64(sszSlice10) - // Field (0) 'DepositRoot' - if size := len(e.DepositRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.DepositRoot", size, 32) - return + // Field 11: Validators + { + if len(sszSlice11)%121 != 0 { + return fmt.Errorf("misaligned bytes: c.Validators length is %d, which is not a multiple of 121: %w", len(sszSlice11), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice11) / 121 + if numElem > 1099511627776 { + return fmt.Errorf("ssz-max exceeded: c.Validators has %d elements, ssz-max is 1099511627776: %w", numElem, ssz.ErrListTooBig) + } + c.Validators = make([]*Validator, numElem) + for i := 0; i < numElem; i++ { + var tmp *Validator + tmp = new(Validator) + tmpSlice := sszSlice11[i*121 : (1+i)*121] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Validators: %w", err) + } + c.Validators[i] = tmp + } } - hh.PutBytes(e.DepositRoot) - // Field (1) 'DepositCount' - ssz.PutUint(hh, e.DepositCount) + // Field 12: Balances + { + if len(sszSlice12)%8 != 0 { + return fmt.Errorf("misaligned bytes: c.Balances length is %d, which is not a multiple of 8: %w", len(sszSlice12), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice12) / 8 + if numElem > 1099511627776 { + return fmt.Errorf("ssz-max exceeded: c.Balances has %d elements, ssz-max is 1099511627776: %w", numElem, ssz.ErrListTooBig) + } + c.Balances = make([]uint64, numElem) + for i := 0; i < numElem; i++ { + var tmp uint64 - // Field (2) 'BlockHash' - if size := len(e.BlockHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockHash", size, 32) - return + tmpSlice := sszSlice12[i*8 : (1+i)*8] + tmp = binary.LittleEndian.Uint64(tmpSlice) + c.Balances[i] = tmp + } } - hh.PutBytes(e.BlockHash) - hh.Merkleize(indx) - return -} + // Field 13: RandaoMixes + { + c.RandaoMixes = make([][]byte, 64) + for i := 0; i < 64; i++ { + var tmp []byte -// MarshalSSZ ssz marshals the ProposerSlashing object -func (p *ProposerSlashing) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(p) -} + tmpSlice := sszSlice13[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.RandaoMixes[i] = tmp + } + } -// MarshalSSZTo ssz marshals the ProposerSlashing object to a target array -func (p *ProposerSlashing) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf + // Field 14: Slashings + { + c.Slashings = make([]uint64, 64) + for i := 0; i < 64; i++ { + var tmp uint64 - // Field (0) 'Header_1' - if p.Header_1 == nil { - p.Header_1 = new(SignedBeaconBlockHeader) - } - if dst, err = p.Header_1.MarshalSSZTo(dst); err != nil { - return + tmpSlice := sszSlice14[i*8 : (1+i)*8] + tmp = binary.LittleEndian.Uint64(tmpSlice) + c.Slashings[i] = tmp + } } - // Field (1) 'Header_2' - if p.Header_2 == nil { - p.Header_2 = new(SignedBeaconBlockHeader) + // Field 15: PreviousEpochAttestations + { + // empty lists are zero length, so make sure there is room for an offset + // before attempting to unmarshal it + if len(sszSlice15) > 3 { + startOffset := ssz.ReadOffset(sszSlice15[0:4]) + if startOffset == 0 { + return fmt.Errorf("encountered invalid offset of 0 when decoding c.PreviousEpochAttestations") + } + if startOffset%4 != 0 { + return fmt.Errorf("misaligned list bytes: when decoding c.PreviousEpochAttestations, end-of-list offset is %d, which is not a multiple of 4 (offset size)", startOffset) + } + listLen := startOffset / 4 + if listLen > 1024 { + return fmt.Errorf("ssz-max exceeded: c.PreviousEpochAttestations has %d elements, ssz-max is 1024: %w", listLen, ssz.ErrListTooBig) + } + totalVarBytes := uint64(len(sszSlice15)) + if totalVarBytes < startOffset { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.PreviousEpochAttestations") + } + c.PreviousEpochAttestations = make([]*PendingAttestation, listLen) + var tmpSlice []byte + for i := uint64(0); i < listLen; i++ { + var tmp *PendingAttestation + tmp = new(PendingAttestation) + endOffset := totalVarBytes + if i+1 != listLen { + endOffset = ssz.ReadOffset(sszSlice15[(i+1)*4 : (i+2)*4]) + if totalVarBytes < endOffset { + return fmt.Errorf("offset %d points past the end of buffer when decoding c.PreviousEpochAttestations", endOffset) + } + } + if endOffset < startOffset { + return fmt.Errorf("offset %d is not greater than start offset %d when decoding c.PreviousEpochAttestations", endOffset, startOffset) + } + tmpSlice = sszSlice15[startOffset:endOffset] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("PreviousEpochAttestations: %w", err) + } + c.PreviousEpochAttestations[i] = tmp + startOffset = endOffset + } + } else { + if len(sszSlice15) > 0 { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.PreviousEpochAttestations") + } + c.PreviousEpochAttestations = make([]*PendingAttestation, 0) + } } - if dst, err = p.Header_2.MarshalSSZTo(dst); err != nil { - return + + // Field 16: CurrentEpochAttestations + { + // empty lists are zero length, so make sure there is room for an offset + // before attempting to unmarshal it + if len(sszSlice16) > 3 { + startOffset := ssz.ReadOffset(sszSlice16[0:4]) + if startOffset == 0 { + return fmt.Errorf("encountered invalid offset of 0 when decoding c.CurrentEpochAttestations") + } + if startOffset%4 != 0 { + return fmt.Errorf("misaligned list bytes: when decoding c.CurrentEpochAttestations, end-of-list offset is %d, which is not a multiple of 4 (offset size)", startOffset) + } + listLen := startOffset / 4 + if listLen > 1024 { + return fmt.Errorf("ssz-max exceeded: c.CurrentEpochAttestations has %d elements, ssz-max is 1024: %w", listLen, ssz.ErrListTooBig) + } + totalVarBytes := uint64(len(sszSlice16)) + if totalVarBytes < startOffset { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.CurrentEpochAttestations") + } + c.CurrentEpochAttestations = make([]*PendingAttestation, listLen) + var tmpSlice []byte + for i := uint64(0); i < listLen; i++ { + var tmp *PendingAttestation + tmp = new(PendingAttestation) + endOffset := totalVarBytes + if i+1 != listLen { + endOffset = ssz.ReadOffset(sszSlice16[(i+1)*4 : (i+2)*4]) + if totalVarBytes < endOffset { + return fmt.Errorf("offset %d points past the end of buffer when decoding c.CurrentEpochAttestations", endOffset) + } + } + if endOffset < startOffset { + return fmt.Errorf("offset %d is not greater than start offset %d when decoding c.CurrentEpochAttestations", endOffset, startOffset) + } + tmpSlice = sszSlice16[startOffset:endOffset] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("CurrentEpochAttestations: %w", err) + } + c.CurrentEpochAttestations[i] = tmp + startOffset = endOffset + } + } else { + if len(sszSlice16) > 0 { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.CurrentEpochAttestations") + } + c.CurrentEpochAttestations = make([]*PendingAttestation, 0) + } } - return -} + // Field 17: JustificationBits + c.JustificationBits = make([]byte, 0, 1) + c.JustificationBits = append(c.JustificationBits, go_bitfield.Bitvector4(sszSlice17)...) -// 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 18: PreviousJustifiedCheckpoint + c.PreviousJustifiedCheckpoint = new(Checkpoint) + if err = c.PreviousJustifiedCheckpoint.UnmarshalSSZ(sszSlice18); err != nil { + return fmt.Errorf("PreviousJustifiedCheckpoint: %w", err) } - // Field (0) 'Header_1' - if p.Header_1 == nil { - p.Header_1 = new(SignedBeaconBlockHeader) - } - if err = p.Header_1.UnmarshalSSZ(buf[0:208]); err != nil { - return err + // Field 19: CurrentJustifiedCheckpoint + c.CurrentJustifiedCheckpoint = new(Checkpoint) + if err = c.CurrentJustifiedCheckpoint.UnmarshalSSZ(sszSlice19); err != nil { + return fmt.Errorf("CurrentJustifiedCheckpoint: %w", err) } - // Field (1) 'Header_2' - if p.Header_2 == nil { - p.Header_2 = new(SignedBeaconBlockHeader) + // Field 20: FinalizedCheckpoint + c.FinalizedCheckpoint = new(Checkpoint) + if err = c.FinalizedCheckpoint.UnmarshalSSZ(sszSlice20); err != nil { + return fmt.Errorf("FinalizedCheckpoint: %w", err) } - if err = p.Header_2.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) +func (c *BeaconState) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the ProposerSlashing object with a hasher -func (p *ProposerSlashing) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *BeaconState) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Header_1' - if err = p.Header_1.HashTreeRootWith(hh); err != nil { - return + // Field 0: GenesisTime + hh.PutUint64(c.GenesisTime) + // Field 1: GenesisValidatorsRoot + if len(c.GenesisValidatorsRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.GenesisValidatorsRoot) + // Field 2: Slot + if err := c.Slot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Slot: %w", err) + } + // Field 3: Fork + if err := c.Fork.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Fork: %w", err) + } + // Field 4: LatestBlockHeader + if err := c.LatestBlockHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("LatestBlockHeader: %w", err) + } + // Field 5: BlockRoots + { + if len(c.BlockRoots) != 64 { + return ssz.ErrVectorLength + } + subIndx := hh.Index() + for _, o := range c.BlockRoots { + if len(o) != 32 { + return ssz.ErrBytesLength + } + hh.Append(o) + } + hh.Merkleize(subIndx) } - - // Field (1) 'Header_2' - if err = p.Header_2.HashTreeRootWith(hh); err != nil { - return + // Field 6: StateRoots + { + if len(c.StateRoots) != 64 { + return ssz.ErrVectorLength + } + subIndx := hh.Index() + for _, o := range c.StateRoots { + if len(o) != 32 { + return ssz.ErrBytesLength + } + hh.Append(o) + } + hh.Merkleize(subIndx) } - - hh.Merkleize(indx) - return -} - -// 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("--.Proof", size, 33) - return - } - for ii := 0; ii < 33; ii++ { - if size := len(d.Proof[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.Proof[ii]", size, 32) - return + // Field 7: HistoricalRoots + { + if len(c.HistoricalRoots) > 16777216 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.HistoricalRoots { + if len(o) != 32 { + return ssz.ErrBytesLength + } + hh.Append(o) } - dst = append(dst, d.Proof[ii]...) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.HistoricalRoots)), 16777216) } - - // Field (1) 'Data' - if d.Data == nil { - d.Data = new(Deposit_Data) + // Field 8: Eth1Data + if err := c.Eth1Data.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Eth1Data: %w", err) } - if dst, err = d.Data.MarshalSSZTo(dst); err != nil { - return + // Field 9: Eth1DataVotes + { + if len(c.Eth1DataVotes) > 32 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.Eth1DataVotes { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Eth1DataVotes: %w", err) + } + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Eth1DataVotes)), 32) } - - 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 10: Eth1DepositIndex + hh.PutUint64(c.Eth1DepositIndex) + // Field 11: Validators + { + if len(c.Validators) > 1099511627776 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.Validators { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Validators: %w", err) + } + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Validators)), 1099511627776) } - - // 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])) + // Field 12: Balances + { + if len(c.Balances) > 1099511627776 { + return ssz.ErrListTooBig } - d.Proof[ii] = append(d.Proof[ii], buf[0:1056][ii*32:(ii+1)*32]...) + subIndx := hh.Index() + for _, o := range c.Balances { + hh.AppendUint64(o) + } + hh.FillUpTo32() + numItems := uint64(len(c.Balances)) + hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(1099511627776, numItems, 8)) } - - // Field (1) 'Data' - if d.Data == nil { - d.Data = new(Deposit_Data) + // Field 13: RandaoMixes + { + if len(c.RandaoMixes) != 64 { + return ssz.ErrVectorLength + } + subIndx := hh.Index() + for _, o := range c.RandaoMixes { + if len(o) != 32 { + return ssz.ErrBytesLength + } + hh.Append(o) + } + hh.Merkleize(subIndx) } - if err = d.Data.UnmarshalSSZ(buf[1056:1240]); err != nil { - return err + // Field 14: Slashings + { + if len(c.Slashings) != 64 { + return ssz.ErrVectorLength + } + subIndx := hh.Index() + for _, o := range c.Slashings { + hh.AppendUint64(o) + } + hh.Merkleize(subIndx) } - - 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.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'Proof' + // Field 15: PreviousEpochAttestations { - if size := len(d.Proof); size != 33 { - err = ssz.ErrVectorLengthFn("--.Proof", size, 33) - return + if len(c.PreviousEpochAttestations) > 1024 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range d.Proof { - if len(i) != 32 { - err = ssz.ErrBytesLength - return + for _, o := range c.PreviousEpochAttestations { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("PreviousEpochAttestations: %w", err) } - hh.Append(i) } - hh.Merkleize(subIndx) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.PreviousEpochAttestations)), 1024) } - - // Field (1) 'Data' - if err = d.Data.HashTreeRootWith(hh); err != nil { - return + // Field 16: CurrentEpochAttestations + { + if len(c.CurrentEpochAttestations) > 1024 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.CurrentEpochAttestations { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("CurrentEpochAttestations: %w", err) + } + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.CurrentEpochAttestations)), 1024) + } + // Field 17: JustificationBits + if len([]byte(c.JustificationBits)) != 1 { + return ssz.ErrBytesLength + } + hh.PutBytes([]byte(c.JustificationBits)) + // Field 18: PreviousJustifiedCheckpoint + if err := c.PreviousJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("PreviousJustifiedCheckpoint: %w", err) + } + // Field 19: CurrentJustifiedCheckpoint + if err := c.CurrentJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("CurrentJustifiedCheckpoint: %w", err) + } + // Field 20: FinalizedCheckpoint + if err := c.FinalizedCheckpoint.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("FinalizedCheckpoint: %w", err) } - hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the SignedVoluntaryExit object -func (s *SignedVoluntaryExit) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) +func (c *Checkpoint) SizeSSZ() int { + size := 40 + + return size } -// MarshalSSZTo ssz marshals the SignedVoluntaryExit object to a target array -func (s *SignedVoluntaryExit) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *Checkpoint) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (0) 'Exit' - if s.Exit == nil { - s.Exit = new(VoluntaryExit) - } - if dst, err = s.Exit.MarshalSSZTo(dst); err != nil { - return +func (c *Checkpoint) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + + // Field 0: Epoch + if dst, err = c.Epoch.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Epoch: %w", err) } - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 1: Root + if len(c.Root) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, s.Signature...) + dst = append(dst, c.Root...) - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the SignedVoluntaryExit object -func (s *SignedVoluntaryExit) UnmarshalSSZ(buf []byte) error { +func (c *Checkpoint) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 112 { + if size != 40 { 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 - } + sszSlice0 := buf[0:8] // c.Epoch + sszSlice1 := buf[8:40] // c.Root - // Field (1) 'Signature' - if cap(s.Signature) == 0 { - s.Signature = make([]byte, 0, len(buf[16:112])) + // Field 0: Epoch + if err = c.Epoch.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Epoch: %w", err) } - s.Signature = append(s.Signature, buf[16:112]...) + // Field 1: Root + c.Root = make([]byte, 0, 32) + c.Root = append(c.Root, sszSlice1...) 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) +func (c *Checkpoint) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the SignedVoluntaryExit object with a hasher -func (s *SignedVoluntaryExit) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *Checkpoint) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Exit' - if err = s.Exit.HashTreeRootWith(hh); err != nil { - return + // Field 0: Epoch + if err := c.Epoch.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Epoch: %w", err) } - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 1: Root + if len(c.Root) != 32 { + return ssz.ErrBytesLength } - hh.PutBytes(s.Signature) - + hh.PutBytes(c.Root) hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the VoluntaryExit object -func (v *VoluntaryExit) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(v) +func (c *Deposit) SizeSSZ() int { + size := 1240 + + return size } -// MarshalSSZTo ssz marshals the VoluntaryExit object to a target array -func (v *VoluntaryExit) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *Deposit) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (0) 'Epoch' - dst = ssz.MarshalUint(dst, v.Epoch) +func (c *Deposit) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (1) 'ValidatorIndex' - dst = ssz.MarshalUint(dst, v.ValidatorIndex) + // Field 0: Proof + if len(c.Proof) != 33 { + return nil, ssz.ErrBytesLength + } + for _, o := range c.Proof { + if len(o) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) + } + + // Field 1: Data + if c.Data == nil { + c.Data = new(Deposit_Data) + } + if dst, err = c.Data.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Data: %w", err) + } - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the VoluntaryExit object -func (v *VoluntaryExit) UnmarshalSSZ(buf []byte) error { +func (c *Deposit) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 16 { + if size != 1240 { return ssz.ErrSize } - // Field (0) 'Epoch' - v.Epoch = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Epoch](buf[0:8]) + sszSlice0 := buf[0:1056] // c.Proof + sszSlice1 := buf[1056:1240] // c.Data - // Field (1) 'ValidatorIndex' - v.ValidatorIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[8:16]) + // Field 0: Proof + { + c.Proof = make([][]byte, 33) + for i := 0; i < 33; i++ { + var tmp []byte - return err -} + tmpSlice := sszSlice0[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.Proof[i] = tmp + } + } -// SizeSSZ returns the ssz encoded size in bytes for the VoluntaryExit object -func (v *VoluntaryExit) SizeSSZ() (size int) { - size = 16 - return + // Field 1: Data + c.Data = new(Deposit_Data) + if err = c.Data.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Data: %w", err) + } + return err } -// HashTreeRoot ssz hashes the VoluntaryExit object -func (v *VoluntaryExit) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(v) +func (c *Deposit) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the VoluntaryExit object with a hasher -func (v *VoluntaryExit) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *Deposit) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() + // Field 0: Proof + { + if len(c.Proof) != 33 { + return ssz.ErrVectorLength + } + subIndx := hh.Index() + for _, o := range c.Proof { + if len(o) != 32 { + return ssz.ErrBytesLength + } + hh.Append(o) + } + hh.Merkleize(subIndx) + } + // Field 1: Data + if err := c.Data.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Data: %w", err) + } + hh.Merkleize(indx) + return nil +} - // Field (0) 'Epoch' - ssz.PutUint(hh, v.Epoch) - - // Field (1) 'ValidatorIndex' - ssz.PutUint(hh, v.ValidatorIndex) +func (c *Deposit_Data) SizeSSZ() int { + size := 184 - hh.Merkleize(indx) - return + return size } -// MarshalSSZ ssz marshals the Fork object -func (f *Fork) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(f) +func (c *Deposit_Data) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the Fork object to a target array -func (f *Fork) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *Deposit_Data) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (0) 'PreviousVersion' - if size := len(f.PreviousVersion); size != 4 { - err = ssz.ErrBytesLengthFn("--.PreviousVersion", size, 4) - return + // Field 0: PublicKey + if len(c.PublicKey) != 48 { + return nil, ssz.ErrBytesLength } - dst = append(dst, f.PreviousVersion...) + dst = append(dst, c.PublicKey...) - // Field (1) 'CurrentVersion' - if size := len(f.CurrentVersion); size != 4 { - err = ssz.ErrBytesLengthFn("--.CurrentVersion", size, 4) - return + // Field 1: WithdrawalCredentials + if len(c.WithdrawalCredentials) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, f.CurrentVersion...) + dst = append(dst, c.WithdrawalCredentials...) - // Field (2) 'Epoch' - dst = ssz.MarshalUint(dst, f.Epoch) + // Field 2: Amount + dst = binary.LittleEndian.AppendUint64(dst, c.Amount) - return + // Field 3: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.Signature...) + + return dst, err } -// UnmarshalSSZ ssz unmarshals the Fork object -func (f *Fork) UnmarshalSSZ(buf []byte) error { +func (c *Deposit_Data) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 16 { + if size != 184 { 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]...) + sszSlice0 := buf[0:48] // c.PublicKey + sszSlice1 := buf[48:80] // c.WithdrawalCredentials + sszSlice2 := buf[80:88] // c.Amount + sszSlice3 := buf[88:184] // c.Signature - // 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 0: PublicKey + c.PublicKey = make([]byte, 0, 48) + c.PublicKey = append(c.PublicKey, sszSlice0...) - // Field (2) 'Epoch' - f.Epoch = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Epoch](buf[8:16]) + // Field 1: WithdrawalCredentials + c.WithdrawalCredentials = make([]byte, 0, 32) + c.WithdrawalCredentials = append(c.WithdrawalCredentials, sszSlice1...) - return err -} + // Field 2: Amount + c.Amount = binary.LittleEndian.Uint64(sszSlice2) -// SizeSSZ returns the ssz encoded size in bytes for the Fork object -func (f *Fork) SizeSSZ() (size int) { - size = 16 - return + // Field 3: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice3...) + return err } -// HashTreeRoot ssz hashes the Fork object -func (f *Fork) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(f) +func (c *Deposit_Data) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the Fork object with a hasher -func (f *Fork) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *Deposit_Data) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() + // Field 0: PublicKey + if len(c.PublicKey) != 48 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.PublicKey) + // Field 1: WithdrawalCredentials + if len(c.WithdrawalCredentials) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.WithdrawalCredentials) + // Field 2: Amount + hh.PutUint64(c.Amount) + // Field 3: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Signature) + hh.Merkleize(indx) + return nil +} - // Field (0) 'PreviousVersion' - if size := len(f.PreviousVersion); size != 4 { - err = ssz.ErrBytesLengthFn("--.PreviousVersion", size, 4) - return - } - hh.PutBytes(f.PreviousVersion) - - // Field (1) 'CurrentVersion' - if size := len(f.CurrentVersion); size != 4 { - err = ssz.ErrBytesLengthFn("--.CurrentVersion", size, 4) - return - } - hh.PutBytes(f.CurrentVersion) - - // Field (2) 'Epoch' - ssz.PutUint(hh, f.Epoch) +func (c *DepositMessage) SizeSSZ() int { + size := 88 - hh.Merkleize(indx) - return + return size } -// MarshalSSZ ssz marshals the Validator object -func (v *Validator) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(v) +func (c *DepositMessage) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the Validator object to a target array -func (v *Validator) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *DepositMessage) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (0) 'PublicKey' - if size := len(v.PublicKey); size != 48 { - err = ssz.ErrBytesLengthFn("--.PublicKey", size, 48) - return + // Field 0: PublicKey + if len(c.PublicKey) != 48 { + return nil, ssz.ErrBytesLength } - dst = append(dst, v.PublicKey...) + dst = append(dst, c.PublicKey...) - // Field (1) 'WithdrawalCredentials' - if size := len(v.WithdrawalCredentials); size != 32 { - err = ssz.ErrBytesLengthFn("--.WithdrawalCredentials", size, 32) - return + // Field 1: WithdrawalCredentials + if len(c.WithdrawalCredentials) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, v.WithdrawalCredentials...) - - // Field (2) 'EffectiveBalance' - dst = ssz.MarshalUint(dst, v.EffectiveBalance) - - // Field (3) 'Slashed' - dst = ssz.MarshalBool(dst, v.Slashed) + dst = append(dst, c.WithdrawalCredentials...) - // Field (4) 'ActivationEligibilityEpoch' - dst = ssz.MarshalUint(dst, v.ActivationEligibilityEpoch) + // Field 2: Amount + dst = binary.LittleEndian.AppendUint64(dst, c.Amount) - // Field (5) 'ActivationEpoch' - dst = ssz.MarshalUint(dst, v.ActivationEpoch) - - // Field (6) 'ExitEpoch' - dst = ssz.MarshalUint(dst, v.ExitEpoch) - - // Field (7) 'WithdrawableEpoch' - dst = ssz.MarshalUint(dst, v.WithdrawableEpoch) - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the Validator object -func (v *Validator) UnmarshalSSZ(buf []byte) error { +func (c *DepositMessage) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 121 { + if size != 88 { return ssz.ErrSize } - // Field (0) 'PublicKey' - if cap(v.PublicKey) == 0 { - v.PublicKey = make([]byte, 0, len(buf[0:48])) - } - v.PublicKey = append(v.PublicKey, buf[0:48]...) + sszSlice0 := buf[0:48] // c.PublicKey + sszSlice1 := buf[48:80] // c.WithdrawalCredentials + sszSlice2 := buf[80:88] // c.Amount - // 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 0: PublicKey + c.PublicKey = make([]byte, 0, 48) + c.PublicKey = append(c.PublicKey, sszSlice0...) - // Field (2) 'EffectiveBalance' - v.EffectiveBalance = ssz.UnmarshallUint[uint64](buf[80:88]) - - // Field (3) 'Slashed' - v.Slashed, err = ssz.DecodeBool(buf[88:89]) - if err != nil { - return err - } - - // Field (4) 'ActivationEligibilityEpoch' - v.ActivationEligibilityEpoch = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Epoch](buf[89:97]) - - // Field (5) 'ActivationEpoch' - v.ActivationEpoch = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Epoch](buf[97:105]) - - // Field (6) 'ExitEpoch' - v.ExitEpoch = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Epoch](buf[105:113]) - - // Field (7) 'WithdrawableEpoch' - v.WithdrawableEpoch = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Epoch](buf[113:121]) + // Field 1: WithdrawalCredentials + c.WithdrawalCredentials = make([]byte, 0, 32) + c.WithdrawalCredentials = append(c.WithdrawalCredentials, sszSlice1...) + // Field 2: Amount + c.Amount = binary.LittleEndian.Uint64(sszSlice2) 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) +func (c *DepositMessage) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the Validator object with a hasher -func (v *Validator) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *DepositMessage) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() + // Field 0: PublicKey + if len(c.PublicKey) != 48 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.PublicKey) + // Field 1: WithdrawalCredentials + if len(c.WithdrawalCredentials) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.WithdrawalCredentials) + // Field 2: Amount + hh.PutUint64(c.Amount) + hh.Merkleize(indx) + return nil +} - // Field (0) 'PublicKey' - if size := len(v.PublicKey); size != 48 { - err = ssz.ErrBytesLengthFn("--.PublicKey", size, 48) - return - } - hh.PutBytes(v.PublicKey) - - // Field (1) 'WithdrawalCredentials' - if size := len(v.WithdrawalCredentials); size != 32 { - err = ssz.ErrBytesLengthFn("--.WithdrawalCredentials", size, 32) - return - } - hh.PutBytes(v.WithdrawalCredentials) - - // Field (2) 'EffectiveBalance' - ssz.PutUint(hh, v.EffectiveBalance) - - // Field (3) 'Slashed' - hh.PutBool(v.Slashed) - - // Field (4) 'ActivationEligibilityEpoch' - ssz.PutUint(hh, v.ActivationEligibilityEpoch) - - // Field (5) 'ActivationEpoch' - ssz.PutUint(hh, v.ActivationEpoch) - - // Field (6) 'ExitEpoch' - ssz.PutUint(hh, v.ExitEpoch) - - // Field (7) 'WithdrawableEpoch' - ssz.PutUint(hh, v.WithdrawableEpoch) +func (c *ENRForkID) SizeSSZ() int { + size := 16 - hh.Merkleize(indx) - return + return size } -// MarshalSSZ ssz marshals the Deposit_Data object -func (d *Deposit_Data) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(d) +func (c *ENRForkID) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the Deposit_Data object to a target array -func (d *Deposit_Data) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *ENRForkID) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (0) 'PublicKey' - if size := len(d.PublicKey); size != 48 { - err = ssz.ErrBytesLengthFn("--.PublicKey", size, 48) - return + // Field 0: CurrentForkDigest + if len(c.CurrentForkDigest) != 4 { + return nil, ssz.ErrBytesLength } - dst = append(dst, d.PublicKey...) + dst = append(dst, c.CurrentForkDigest...) - // Field (1) 'WithdrawalCredentials' - if size := len(d.WithdrawalCredentials); size != 32 { - err = ssz.ErrBytesLengthFn("--.WithdrawalCredentials", size, 32) - return + // Field 1: NextForkVersion + if len(c.NextForkVersion) != 4 { + return nil, ssz.ErrBytesLength } - dst = append(dst, d.WithdrawalCredentials...) + dst = append(dst, c.NextForkVersion...) - // Field (2) 'Amount' - dst = ssz.MarshalUint(dst, d.Amount) - - // Field (3) 'Signature' - if size := len(d.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 2: NextForkEpoch + if dst, err = c.NextForkEpoch.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("NextForkEpoch: %w", err) } - dst = append(dst, d.Signature...) - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the Deposit_Data object -func (d *Deposit_Data) UnmarshalSSZ(buf []byte) error { +func (c *ENRForkID) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 184 { + if size != 16 { 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]...) + sszSlice0 := buf[0:4] // c.CurrentForkDigest + sszSlice1 := buf[4:8] // c.NextForkVersion + sszSlice2 := buf[8:16] // c.NextForkEpoch - // 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 0: CurrentForkDigest + c.CurrentForkDigest = make([]byte, 0, 4) + c.CurrentForkDigest = append(c.CurrentForkDigest, sszSlice0...) - // Field (2) 'Amount' - d.Amount = ssz.UnmarshallUint[uint64](buf[80:88]) + // Field 1: NextForkVersion + c.NextForkVersion = make([]byte, 0, 4) + c.NextForkVersion = append(c.NextForkVersion, sszSlice1...) - // Field (3) 'Signature' - if cap(d.Signature) == 0 { - d.Signature = make([]byte, 0, len(buf[88:184])) + // Field 2: NextForkEpoch + if err = c.NextForkEpoch.UnmarshalSSZ(sszSlice2); err != nil { + return fmt.Errorf("NextForkEpoch: %w", err) } - d.Signature = append(d.Signature, buf[88:184]...) - return err } -// SizeSSZ returns the ssz encoded size in bytes for the Deposit_Data object -func (d *Deposit_Data) SizeSSZ() (size int) { - size = 184 - return -} - -// HashTreeRoot ssz hashes the Deposit_Data object -func (d *Deposit_Data) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(d) +func (c *ENRForkID) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the Deposit_Data object with a hasher -func (d *Deposit_Data) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *ENRForkID) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'PublicKey' - if size := len(d.PublicKey); size != 48 { - err = ssz.ErrBytesLengthFn("--.PublicKey", size, 48) - return + // Field 0: CurrentForkDigest + if len(c.CurrentForkDigest) != 4 { + return ssz.ErrBytesLength } - hh.PutBytes(d.PublicKey) - - // Field (1) 'WithdrawalCredentials' - if size := len(d.WithdrawalCredentials); size != 32 { - err = ssz.ErrBytesLengthFn("--.WithdrawalCredentials", size, 32) - return + hh.PutBytes(c.CurrentForkDigest) + // Field 1: NextForkVersion + if len(c.NextForkVersion) != 4 { + return ssz.ErrBytesLength } - hh.PutBytes(d.WithdrawalCredentials) - - // Field (2) 'Amount' - ssz.PutUint(hh, d.Amount) - - // Field (3) 'Signature' - if size := len(d.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + hh.PutBytes(c.NextForkVersion) + // Field 2: NextForkEpoch + if err := c.NextForkEpoch.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("NextForkEpoch: %w", err) } - hh.PutBytes(d.Signature) - hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the BeaconState object -func (b *BeaconState) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) +func (c *Eth1Data) SizeSSZ() int { + size := 72 + + return size } -// MarshalSSZTo ssz marshals the BeaconState object to a target array -func (b *BeaconState) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(7057) +func (c *Eth1Data) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (0) 'GenesisTime' - dst = ssz.MarshalUint(dst, b.GenesisTime) +func (c *Eth1Data) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (1) 'GenesisValidatorsRoot' - if size := len(b.GenesisValidatorsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.GenesisValidatorsRoot", size, 32) - return + // Field 0: DepositRoot + if len(c.DepositRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.GenesisValidatorsRoot...) + dst = append(dst, c.DepositRoot...) - // Field (2) 'Slot' - dst = ssz.MarshalUint(dst, b.Slot) + // Field 1: DepositCount + dst = binary.LittleEndian.AppendUint64(dst, c.DepositCount) - // Field (3) 'Fork' - if b.Fork == nil { - b.Fork = new(Fork) - } - if dst, err = b.Fork.MarshalSSZTo(dst); err != nil { - return + // Field 2: BlockHash + if len(c.BlockHash) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.BlockHash...) - // Field (4) 'LatestBlockHeader' - if b.LatestBlockHeader == nil { - b.LatestBlockHeader = new(BeaconBlockHeader) - } - if dst, err = b.LatestBlockHeader.MarshalSSZTo(dst); err != nil { - return - } + return dst, err +} - // Field (5) 'BlockRoots' - if size := len(b.BlockRoots); size != 64 { - err = ssz.ErrVectorLengthFn("--.BlockRoots", size, 64) - return - } - for ii := 0; ii < 64; ii++ { - if size := len(b.BlockRoots[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockRoots[ii]", size, 32) - return - } - dst = append(dst, b.BlockRoots[ii]...) +func (c *Eth1Data) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 72 { + return ssz.ErrSize } - // Field (6) 'StateRoots' - if size := len(b.StateRoots); size != 64 { - err = ssz.ErrVectorLengthFn("--.StateRoots", size, 64) - return - } - for ii := 0; ii < 64; ii++ { - if size := len(b.StateRoots[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoots[ii]", size, 32) - return - } - dst = append(dst, b.StateRoots[ii]...) - } + sszSlice0 := buf[0:32] // c.DepositRoot + sszSlice1 := buf[32:40] // c.DepositCount + sszSlice2 := buf[40:72] // c.BlockHash - // Offset (7) 'HistoricalRoots' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.HistoricalRoots) * 32 + // Field 0: DepositRoot + c.DepositRoot = make([]byte, 0, 32) + c.DepositRoot = append(c.DepositRoot, sszSlice0...) - // Field (8) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(Eth1Data) - } - if dst, err = b.Eth1Data.MarshalSSZTo(dst); err != nil { - return - } + // Field 1: DepositCount + c.DepositCount = binary.LittleEndian.Uint64(sszSlice1) - // Offset (9) 'Eth1DataVotes' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.Eth1DataVotes) * 72 + // Field 2: BlockHash + c.BlockHash = make([]byte, 0, 32) + c.BlockHash = append(c.BlockHash, sszSlice2...) + return err +} - // Field (10) 'Eth1DepositIndex' - dst = ssz.MarshalUint(dst, b.Eth1DepositIndex) +func (c *Eth1Data) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Offset (11) 'Validators' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.Validators) * 121 +func (c *Eth1Data) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: DepositRoot + if len(c.DepositRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.DepositRoot) + // Field 1: DepositCount + hh.PutUint64(c.DepositCount) + // Field 2: BlockHash + if len(c.BlockHash) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.BlockHash) + hh.Merkleize(indx) + return nil +} - // Offset (12) 'Balances' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.Balances) * 8 +func (c *Fork) SizeSSZ() int { + size := 16 - // Field (13) 'RandaoMixes' - if size := len(b.RandaoMixes); size != 64 { - err = ssz.ErrVectorLengthFn("--.RandaoMixes", size, 64) - return - } - for ii := 0; ii < 64; ii++ { - if size := len(b.RandaoMixes[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.RandaoMixes[ii]", size, 32) - return - } - dst = append(dst, b.RandaoMixes[ii]...) - } + return size +} - // Field (14) 'Slashings' - if size := len(b.Slashings); size != 64 { - err = ssz.ErrVectorLengthFn("--.Slashings", size, 64) - return - } - for ii := 0; ii < 64; ii++ { - dst = ssz.MarshalUint(dst, b.Slashings[ii]) - } +func (c *Fork) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Offset (15) 'PreviousEpochAttestations' - dst = ssz.WriteOffset(dst, offset) - for ii := 0; ii < len(b.PreviousEpochAttestations); ii++ { - offset += 4 - offset += b.PreviousEpochAttestations[ii].SizeSSZ() - } +func (c *Fork) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Offset (16) 'CurrentEpochAttestations' - dst = ssz.WriteOffset(dst, offset) - for ii := 0; ii < len(b.CurrentEpochAttestations); ii++ { - offset += 4 - offset += b.CurrentEpochAttestations[ii].SizeSSZ() + // Field 0: PreviousVersion + if len(c.PreviousVersion) != 4 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.PreviousVersion...) - // Field (17) 'JustificationBits' - if size := len(b.JustificationBits); size != 1 { - err = ssz.ErrBytesLengthFn("--.JustificationBits", size, 1) - return + // Field 1: CurrentVersion + if len(c.CurrentVersion) != 4 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.JustificationBits...) + dst = append(dst, c.CurrentVersion...) - // Field (18) 'PreviousJustifiedCheckpoint' - if b.PreviousJustifiedCheckpoint == nil { - b.PreviousJustifiedCheckpoint = new(Checkpoint) - } - if dst, err = b.PreviousJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { - return + // Field 2: Epoch + if dst, err = c.Epoch.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Epoch: %w", err) } - // Field (19) 'CurrentJustifiedCheckpoint' - if b.CurrentJustifiedCheckpoint == nil { - b.CurrentJustifiedCheckpoint = new(Checkpoint) - } - if dst, err = b.CurrentJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { - return - } + return dst, err +} - // Field (20) 'FinalizedCheckpoint' - if b.FinalizedCheckpoint == nil { - b.FinalizedCheckpoint = new(Checkpoint) - } - if dst, err = b.FinalizedCheckpoint.MarshalSSZTo(dst); err != nil { - return +func (c *Fork) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 16 { + return ssz.ErrSize } - // Field (7) 'HistoricalRoots' - if size := len(b.HistoricalRoots); size > 16777216 { - err = ssz.ErrListTooBigFn("--.HistoricalRoots", size, 16777216) - return - } - for ii := 0; ii < len(b.HistoricalRoots); ii++ { - if size := len(b.HistoricalRoots[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.HistoricalRoots[ii]", size, 32) - return - } - dst = append(dst, b.HistoricalRoots[ii]...) - } + sszSlice0 := buf[0:4] // c.PreviousVersion + sszSlice1 := buf[4:8] // c.CurrentVersion + sszSlice2 := buf[8:16] // c.Epoch - // Field (9) 'Eth1DataVotes' - if size := len(b.Eth1DataVotes); size > 32 { - err = ssz.ErrListTooBigFn("--.Eth1DataVotes", size, 32) - return - } - for ii := 0; ii < len(b.Eth1DataVotes); ii++ { - if dst, err = b.Eth1DataVotes[ii].MarshalSSZTo(dst); err != nil { - return - } - } + // Field 0: PreviousVersion + c.PreviousVersion = make([]byte, 0, 4) + c.PreviousVersion = append(c.PreviousVersion, sszSlice0...) - // Field (11) 'Validators' - if size := len(b.Validators); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.Validators", size, 1099511627776) - return - } - for ii := 0; ii < len(b.Validators); ii++ { - if dst, err = b.Validators[ii].MarshalSSZTo(dst); err != nil { - return - } - } + // Field 1: CurrentVersion + c.CurrentVersion = make([]byte, 0, 4) + c.CurrentVersion = append(c.CurrentVersion, sszSlice1...) - // Field (12) 'Balances' - if size := len(b.Balances); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.Balances", size, 1099511627776) - return - } - for ii := 0; ii < len(b.Balances); ii++ { - dst = ssz.MarshalUint(dst, b.Balances[ii]) + // Field 2: Epoch + if err = c.Epoch.UnmarshalSSZ(sszSlice2); err != nil { + return fmt.Errorf("Epoch: %w", err) } + return err +} - // Field (15) 'PreviousEpochAttestations' - if size := len(b.PreviousEpochAttestations); size > 1024 { - err = ssz.ErrListTooBigFn("--.PreviousEpochAttestations", size, 1024) - return - } - { - offset = 4 * len(b.PreviousEpochAttestations) - for ii := 0; ii < len(b.PreviousEpochAttestations); ii++ { - dst = ssz.WriteOffset(dst, offset) - offset += b.PreviousEpochAttestations[ii].SizeSSZ() - } - } - for ii := 0; ii < len(b.PreviousEpochAttestations); ii++ { - if dst, err = b.PreviousEpochAttestations[ii].MarshalSSZTo(dst); err != nil { - return - } +func (c *Fork) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (16) 'CurrentEpochAttestations' - if size := len(b.CurrentEpochAttestations); size > 1024 { - err = ssz.ErrListTooBigFn("--.CurrentEpochAttestations", size, 1024) - return +func (c *Fork) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: PreviousVersion + if len(c.PreviousVersion) != 4 { + return ssz.ErrBytesLength } - { - offset = 4 * len(b.CurrentEpochAttestations) - for ii := 0; ii < len(b.CurrentEpochAttestations); ii++ { - dst = ssz.WriteOffset(dst, offset) - offset += b.CurrentEpochAttestations[ii].SizeSSZ() - } + hh.PutBytes(c.PreviousVersion) + // Field 1: CurrentVersion + if len(c.CurrentVersion) != 4 { + return ssz.ErrBytesLength } - for ii := 0; ii < len(b.CurrentEpochAttestations); ii++ { - if dst, err = b.CurrentEpochAttestations[ii].MarshalSSZTo(dst); err != nil { - return - } + hh.PutBytes(c.CurrentVersion) + // Field 2: Epoch + if err := c.Epoch.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Epoch: %w", err) } - - return + hh.Merkleize(indx) + return nil } -// UnmarshalSSZ ssz unmarshals the BeaconState object -func (b *BeaconState) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 7057 { - return ssz.ErrSize - } - - tail := buf - var o7, o9, o11, o12, o15, o16 uint64 - - // Field (0) 'GenesisTime' - b.GenesisTime = ssz.UnmarshallUint[uint64](buf[0:8]) +func (c *ForkData) SizeSSZ() int { + size := 36 - // 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.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[40:48]) + return size +} - // Field (3) 'Fork' - if b.Fork == nil { - b.Fork = new(Fork) - } - if err = b.Fork.UnmarshalSSZ(buf[48:64]); err != nil { - return err - } +func (c *ForkData) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (4) 'LatestBlockHeader' - if b.LatestBlockHeader == nil { - b.LatestBlockHeader = new(BeaconBlockHeader) - } - if err = b.LatestBlockHeader.UnmarshalSSZ(buf[64:176]); err != nil { - return err - } +func (c *ForkData) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (5) 'BlockRoots' - b.BlockRoots = make([][]byte, 64) - for ii := 0; ii < 64; ii++ { - if cap(b.BlockRoots[ii]) == 0 { - b.BlockRoots[ii] = make([]byte, 0, len(buf[176:2224][ii*32:(ii+1)*32])) - } - b.BlockRoots[ii] = append(b.BlockRoots[ii], buf[176:2224][ii*32:(ii+1)*32]...) + // Field 0: CurrentVersion + if len(c.CurrentVersion) != 4 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.CurrentVersion...) - // Field (6) 'StateRoots' - b.StateRoots = make([][]byte, 64) - for ii := 0; ii < 64; ii++ { - if cap(b.StateRoots[ii]) == 0 { - b.StateRoots[ii] = make([]byte, 0, len(buf[2224:4272][ii*32:(ii+1)*32])) - } - b.StateRoots[ii] = append(b.StateRoots[ii], buf[2224:4272][ii*32:(ii+1)*32]...) + // Field 1: GenesisValidatorsRoot + if len(c.GenesisValidatorsRoot) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.GenesisValidatorsRoot...) - // Offset (7) 'HistoricalRoots' - if o7 = ssz.ReadOffset(buf[4272:4276]); o7 > size { - return ssz.ErrOffset - } + return dst, err +} - if o7 != 7057 { - return ssz.ErrInvalidVariableOffset +func (c *ForkData) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 36 { + return ssz.ErrSize } - // Field (8) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(Eth1Data) - } - if err = b.Eth1Data.UnmarshalSSZ(buf[4276:4348]); err != nil { - return err - } + sszSlice0 := buf[0:4] // c.CurrentVersion + sszSlice1 := buf[4:36] // c.GenesisValidatorsRoot - // Offset (9) 'Eth1DataVotes' - if o9 = ssz.ReadOffset(buf[4348:4352]); o9 > size || o7 > o9 { - return ssz.ErrOffset - } + // Field 0: CurrentVersion + c.CurrentVersion = make([]byte, 0, 4) + c.CurrentVersion = append(c.CurrentVersion, sszSlice0...) - // Field (10) 'Eth1DepositIndex' - b.Eth1DepositIndex = ssz.UnmarshallUint[uint64](buf[4352:4360]) + // Field 1: GenesisValidatorsRoot + c.GenesisValidatorsRoot = make([]byte, 0, 32) + c.GenesisValidatorsRoot = append(c.GenesisValidatorsRoot, sszSlice1...) + return err +} - // Offset (11) 'Validators' - if o11 = ssz.ReadOffset(buf[4360:4364]); o11 > size || o9 > o11 { - return ssz.ErrOffset +func (c *ForkData) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Offset (12) 'Balances' - if o12 = ssz.ReadOffset(buf[4364:4368]); o12 > size || o11 > o12 { - return ssz.ErrOffset +func (c *ForkData) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: CurrentVersion + if len(c.CurrentVersion) != 4 { + return ssz.ErrBytesLength } - - // Field (13) 'RandaoMixes' - b.RandaoMixes = make([][]byte, 64) - for ii := 0; ii < 64; ii++ { - if cap(b.RandaoMixes[ii]) == 0 { - b.RandaoMixes[ii] = make([]byte, 0, len(buf[4368:6416][ii*32:(ii+1)*32])) - } - b.RandaoMixes[ii] = append(b.RandaoMixes[ii], buf[4368:6416][ii*32:(ii+1)*32]...) + hh.PutBytes(c.CurrentVersion) + // Field 1: GenesisValidatorsRoot + if len(c.GenesisValidatorsRoot) != 32 { + return ssz.ErrBytesLength } + hh.PutBytes(c.GenesisValidatorsRoot) + hh.Merkleize(indx) + return nil +} - // Field (14) 'Slashings' - b.Slashings = ssz.ExtendUint(b.Slashings, 64) - for ii := 0; ii < 64; ii++ { - b.Slashings[ii] = ssz.UnmarshallUint[uint64](buf[6416:6928][ii*8 : (ii+1)*8]) - } +func (c *HistoricalBatch) SizeSSZ() int { + size := 4096 - // Offset (15) 'PreviousEpochAttestations' - if o15 = ssz.ReadOffset(buf[6928:6932]); o15 > size || o12 > o15 { - return ssz.ErrOffset - } + return size +} - // Offset (16) 'CurrentEpochAttestations' - if o16 = ssz.ReadOffset(buf[6932:6936]); o16 > size || o15 > o16 { - return ssz.ErrOffset - } +func (c *HistoricalBatch) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (17) 'JustificationBits' - if cap(b.JustificationBits) == 0 { - b.JustificationBits = make([]byte, 0, len(buf[6936:6937])) - } - b.JustificationBits = append(b.JustificationBits, buf[6936:6937]...) +func (c *HistoricalBatch) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (18) 'PreviousJustifiedCheckpoint' - if b.PreviousJustifiedCheckpoint == nil { - b.PreviousJustifiedCheckpoint = new(Checkpoint) + // Field 0: BlockRoots + if len(c.BlockRoots) != 64 { + return nil, ssz.ErrBytesLength } - if err = b.PreviousJustifiedCheckpoint.UnmarshalSSZ(buf[6937:6977]); err != nil { - return err + for _, o := range c.BlockRoots { + if len(o) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) } - // Field (19) 'CurrentJustifiedCheckpoint' - if b.CurrentJustifiedCheckpoint == nil { - b.CurrentJustifiedCheckpoint = new(Checkpoint) + // Field 1: StateRoots + if len(c.StateRoots) != 64 { + return nil, ssz.ErrBytesLength } - if err = b.CurrentJustifiedCheckpoint.UnmarshalSSZ(buf[6977:7017]); err != nil { - return err + for _, o := range c.StateRoots { + if len(o) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) } - // Field (20) 'FinalizedCheckpoint' - if b.FinalizedCheckpoint == nil { - b.FinalizedCheckpoint = new(Checkpoint) - } - if err = b.FinalizedCheckpoint.UnmarshalSSZ(buf[7017:7057]); err != nil { - return err - } + return dst, err +} - // 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]...) - } +func (c *HistoricalBatch) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 4096 { + return ssz.ErrSize } - // Field (9) 'Eth1DataVotes' - { - buf = tail[o9:o11] - num, err := ssz.DivideInt2(len(buf), 72, 32) - if err != nil { - return err - } - b.Eth1DataVotes = make([]*Eth1Data, num) - for ii := 0; ii < num; ii++ { - if b.Eth1DataVotes[ii] == nil { - b.Eth1DataVotes[ii] = new(Eth1Data) - } - if err = b.Eth1DataVotes[ii].UnmarshalSSZ(buf[ii*72 : (ii+1)*72]); err != nil { - return err - } - } - } + sszSlice0 := buf[0:2048] // c.BlockRoots + sszSlice1 := buf[2048:4096] // c.StateRoots - // Field (11) 'Validators' + // Field 0: BlockRoots { - buf = tail[o11:o12] - num, err := ssz.DivideInt2(len(buf), 121, 1099511627776) - if err != nil { - return err - } - b.Validators = make([]*Validator, num) - for ii := 0; ii < num; ii++ { - if b.Validators[ii] == nil { - b.Validators[ii] = new(Validator) - } - if err = b.Validators[ii].UnmarshalSSZ(buf[ii*121 : (ii+1)*121]); err != nil { - return err - } - } - } + c.BlockRoots = make([][]byte, 64) + for i := 0; i < 64; i++ { + var tmp []byte - // Field (12) 'Balances' - { - buf = tail[o12:o15] - num, err := ssz.DivideInt2(len(buf), 8, 1099511627776) - if err != nil { - return err - } - b.Balances = ssz.ExtendUint(b.Balances, num) - for ii := 0; ii < num; ii++ { - b.Balances[ii] = ssz.UnmarshallUint[uint64](buf[ii*8 : (ii+1)*8]) + tmpSlice := sszSlice0[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.BlockRoots[i] = tmp } } - // Field (15) 'PreviousEpochAttestations' + // Field 1: StateRoots { - buf = tail[o15:o16] - num, err := ssz.DecodeDynamicLength(buf, 1024) - if err != nil { - return err - } - b.PreviousEpochAttestations = make([]*PendingAttestation, num) - err = ssz.UnmarshalDynamic(buf, num, func(indx int, buf []byte) (err error) { - if b.PreviousEpochAttestations[indx] == nil { - b.PreviousEpochAttestations[indx] = new(PendingAttestation) - } - if err = b.PreviousEpochAttestations[indx].UnmarshalSSZ(buf); err != nil { - return err - } - return nil - }) - if err != nil { - return err - } - } + c.StateRoots = make([][]byte, 64) + for i := 0; i < 64; i++ { + var tmp []byte - // Field (16) 'CurrentEpochAttestations' - { - buf = tail[o16:] - num, err := ssz.DecodeDynamicLength(buf, 1024) - if err != nil { - return err - } - b.CurrentEpochAttestations = make([]*PendingAttestation, num) - err = ssz.UnmarshalDynamic(buf, num, func(indx int, buf []byte) (err error) { - if b.CurrentEpochAttestations[indx] == nil { - b.CurrentEpochAttestations[indx] = new(PendingAttestation) - } - if err = b.CurrentEpochAttestations[indx].UnmarshalSSZ(buf); err != nil { - return err - } - return nil - }) - if err != nil { - return err + tmpSlice := sszSlice1[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.StateRoots[i] = tmp } } return err } -// SizeSSZ returns the ssz encoded size in bytes for the BeaconState object -func (b *BeaconState) SizeSSZ() (size int) { - size = 7057 - - // 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) 'PreviousEpochAttestations' - for ii := 0; ii < len(b.PreviousEpochAttestations); ii++ { - size += 4 - size += b.PreviousEpochAttestations[ii].SizeSSZ() +func (c *HistoricalBatch) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - - // Field (16) 'CurrentEpochAttestations' - for ii := 0; ii < len(b.CurrentEpochAttestations); ii++ { - size += 4 - size += b.CurrentEpochAttestations[ii].SizeSSZ() - } - - return + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// 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.Hasher) (err error) { +func (c *HistoricalBatch) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'GenesisTime' - ssz.PutUint(hh, b.GenesisTime) - - // Field (1) 'GenesisValidatorsRoot' - if size := len(b.GenesisValidatorsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.GenesisValidatorsRoot", size, 32) - return - } - hh.PutBytes(b.GenesisValidatorsRoot) - - // Field (2) 'Slot' - ssz.PutUint(hh, b.Slot) - - // Field (3) 'Fork' - if err = b.Fork.HashTreeRootWith(hh); err != nil { - return - } - - // Field (4) 'LatestBlockHeader' - if err = b.LatestBlockHeader.HashTreeRootWith(hh); err != nil { - return - } - - // Field (5) 'BlockRoots' + // Field 0: BlockRoots { - if size := len(b.BlockRoots); size != 64 { - err = ssz.ErrVectorLengthFn("--.BlockRoots", size, 64) - return + if len(c.BlockRoots) != 64 { + return ssz.ErrVectorLength } subIndx := hh.Index() - for _, i := range b.BlockRoots { - if len(i) != 32 { - err = ssz.ErrBytesLength - return + for _, o := range c.BlockRoots { + if len(o) != 32 { + return ssz.ErrBytesLength } - hh.Append(i) + hh.Append(o) } hh.Merkleize(subIndx) } - - // Field (6) 'StateRoots' + // Field 1: StateRoots { - if size := len(b.StateRoots); size != 64 { - err = ssz.ErrVectorLengthFn("--.StateRoots", size, 64) - return + if len(c.StateRoots) != 64 { + return ssz.ErrVectorLength } subIndx := hh.Index() - for _, i := range b.StateRoots { - if len(i) != 32 { - err = ssz.ErrBytesLength - return + for _, o := range c.StateRoots { + if len(o) != 32 { + return ssz.ErrBytesLength } - hh.Append(i) + hh.Append(o) } hh.Merkleize(subIndx) } + hh.Merkleize(indx) + return nil +} - // Field (7) 'HistoricalRoots' - { - if size := len(b.HistoricalRoots); size > 16777216 { - err = ssz.ErrListTooBigFn("--.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) - } +func (c *IndexedAttestation) SizeSSZ() int { + size := 228 + size += len(c.AttestingIndices) * 8 + return size +} - // Field (8) 'Eth1Data' - if err = b.Eth1Data.HashTreeRootWith(hh); err != nil { - return - } +func (c *IndexedAttestation) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (9) 'Eth1DataVotes' - { - subIndx := hh.Index() - num := uint64(len(b.Eth1DataVotes)) - if num > 32 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range b.Eth1DataVotes { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } - } - hh.MerkleizeWithMixin(subIndx, num, 32) - } +func (c *IndexedAttestation) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 228 - // Field (10) 'Eth1DepositIndex' - ssz.PutUint(hh, b.Eth1DepositIndex) + // Field 0: AttestingIndices + dst = ssz.WriteOffset(dst, offset) + offset += len(c.AttestingIndices) * 8 - // 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 1: Data + if c.Data == nil { + c.Data = new(AttestationData) + } + if dst, err = c.Data.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Data: %w", err) } - // Field (12) 'Balances' - { - if size := len(b.Balances); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.Balances", size, 1099511627776) - return - } - subIndx := hh.Index() - for _, i := range b.Balances { - ssz.AppendUint(hh, i) - } - hh.FillUpTo32() + // Field 2: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.Signature...) - numItems := uint64(len(b.Balances)) - hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(1099511627776, numItems, 8)) + // Field 0: AttestingIndices + if len(c.AttestingIndices) > 2048 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.AttestingIndices { + dst = binary.LittleEndian.AppendUint64(dst, o) } + return dst, err +} - // Field (13) 'RandaoMixes' - { - if size := len(b.RandaoMixes); size != 64 { - err = ssz.ErrVectorLengthFn("--.RandaoMixes", size, 64) - return - } - subIndx := hh.Index() - for _, i := range b.RandaoMixes { - if len(i) != 32 { - err = ssz.ErrBytesLength - return - } - hh.Append(i) - } - hh.Merkleize(subIndx) +func (c *IndexedAttestation) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 228 { + return ssz.ErrSize } - // Field (14) 'Slashings' - { - if size := len(b.Slashings); size != 64 { - err = ssz.ErrVectorLengthFn("--.Slashings", size, 64) - return - } - subIndx := hh.Index() - for _, i := range b.Slashings { - ssz.AppendUint(hh, i) - } - hh.Merkleize(subIndx) + sszSlice1 := buf[4:132] // c.Data + sszSlice2 := buf[132:228] // c.Signature + + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.AttestingIndices + if sszVarOffset0 != 228 { + return ssz.ErrInvalidVariableOffset } + if sszVarOffset0 > size { + return ssz.ErrOffset + } + sszSlice0 := buf[sszVarOffset0:] // c.AttestingIndices - // Field (15) 'PreviousEpochAttestations' + // Field 0: AttestingIndices { - subIndx := hh.Index() - num := uint64(len(b.PreviousEpochAttestations)) - if num > 1024 { - err = ssz.ErrIncorrectListSize - return + if len(sszSlice0)%8 != 0 { + return fmt.Errorf("misaligned bytes: c.AttestingIndices length is %d, which is not a multiple of 8: %w", len(sszSlice0), ssz.ErrIncorrectListSize) } - for _, elem := range b.PreviousEpochAttestations { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } + numElem := len(sszSlice0) / 8 + if numElem > 2048 { + return fmt.Errorf("ssz-max exceeded: c.AttestingIndices has %d elements, ssz-max is 2048: %w", numElem, ssz.ErrListTooBig) } - hh.MerkleizeWithMixin(subIndx, num, 1024) - } + c.AttestingIndices = make([]uint64, numElem) + for i := 0; i < numElem; i++ { + var tmp uint64 - // Field (16) 'CurrentEpochAttestations' - { - subIndx := hh.Index() - num := uint64(len(b.CurrentEpochAttestations)) - if num > 1024 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range b.CurrentEpochAttestations { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } + tmpSlice := sszSlice0[i*8 : (1+i)*8] + tmp = binary.LittleEndian.Uint64(tmpSlice) + c.AttestingIndices[i] = tmp } - hh.MerkleizeWithMixin(subIndx, num, 1024) } - // Field (17) 'JustificationBits' - if size := len(b.JustificationBits); size != 1 { - err = ssz.ErrBytesLengthFn("--.JustificationBits", size, 1) - return + // Field 1: Data + c.Data = new(AttestationData) + if err = c.Data.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Data: %w", err) } - hh.PutBytes(b.JustificationBits) - // Field (18) 'PreviousJustifiedCheckpoint' - if err = b.PreviousJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { - return - } + // Field 2: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice2...) + return err +} - // Field (19) 'CurrentJustifiedCheckpoint' - if err = b.CurrentJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { - return +func (c *IndexedAttestation) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (20) 'FinalizedCheckpoint' - if err = b.FinalizedCheckpoint.HashTreeRootWith(hh); err != nil { - return +func (c *IndexedAttestation) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: AttestingIndices + { + if len(c.AttestingIndices) > 2048 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.AttestingIndices { + hh.AppendUint64(o) + } + hh.FillUpTo32() + numItems := uint64(len(c.AttestingIndices)) + hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(2048, numItems, 8)) } - + // Field 1: Data + if err := c.Data.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Data: %w", err) + } + // Field 2: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Signature) hh.Merkleize(indx) - return + return nil +} + +func (c *PendingAttestation) SizeSSZ() int { + size := 148 + size += len(c.AggregationBits) + return size } -// MarshalSSZ ssz marshals the PendingAttestation object -func (p *PendingAttestation) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(p) +func (c *PendingAttestation) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the PendingAttestation object to a target array -func (p *PendingAttestation) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(148) +func (c *PendingAttestation) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 148 - // Offset (0) 'AggregationBits' + // Field 0: AggregationBits dst = ssz.WriteOffset(dst, offset) - offset += len(p.AggregationBits) + offset += len(c.AggregationBits) - // Field (1) 'Data' - if p.Data == nil { - p.Data = new(AttestationData) + // Field 1: Data + if c.Data == nil { + c.Data = new(AttestationData) } - if dst, err = p.Data.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.Data.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Data: %w", err) } - // Field (2) 'InclusionDelay' - dst = ssz.MarshalUint(dst, p.InclusionDelay) - - // Field (3) 'ProposerIndex' - dst = ssz.MarshalUint(dst, p.ProposerIndex) + // Field 2: InclusionDelay + if dst, err = c.InclusionDelay.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("InclusionDelay: %w", err) + } - // Field (0) 'AggregationBits' - if size := len(p.AggregationBits); size > 2048 { - err = ssz.ErrBytesLengthFn("--.AggregationBits", size, 2048) - return + // Field 3: ProposerIndex + if dst, err = c.ProposerIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ProposerIndex: %w", err) } - dst = append(dst, p.AggregationBits...) - return + // Field 0: AggregationBits + if len(c.AggregationBits) > 2048 { + return nil, ssz.ErrListTooBig + } + dst = append(dst, c.AggregationBits...) + return dst, err } -// UnmarshalSSZ ssz unmarshals the PendingAttestation object -func (p *PendingAttestation) UnmarshalSSZ(buf []byte) error { +func (c *PendingAttestation) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size < 148 { return ssz.ErrSize } - tail := buf - var o0 uint64 + sszSlice1 := buf[4:132] // c.Data + sszSlice2 := buf[132:140] // c.InclusionDelay + sszSlice3 := buf[140:148] // c.ProposerIndex - // Offset (0) 'AggregationBits' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.AggregationBits + if sszVarOffset0 != 148 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset0 > size { return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:] // c.AggregationBits - if o0 != 148 { - return ssz.ErrInvalidVariableOffset + // Field 0: AggregationBits + if err = ssz.ValidateBitlist(sszSlice0, 2048); err != nil { + return fmt.Errorf("AggregationBits: %w", err) } + c.AggregationBits = append([]byte{}, go_bitfield.Bitlist(sszSlice0)...) - // Field (1) 'Data' - if p.Data == nil { - p.Data = new(AttestationData) - } - if err = p.Data.UnmarshalSSZ(buf[4:132]); err != nil { - return err + // Field 1: Data + c.Data = new(AttestationData) + if err = c.Data.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Data: %w", err) } - // Field (2) 'InclusionDelay' - p.InclusionDelay = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[132:140]) - - // Field (3) 'ProposerIndex' - p.ProposerIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[140:148]) + // Field 2: InclusionDelay + if err = c.InclusionDelay.UnmarshalSSZ(sszSlice2); err != nil { + return fmt.Errorf("InclusionDelay: %w", err) + } - // Field (0) 'AggregationBits' - { - buf = tail[o0:] - if err = ssz.ValidateBitlist(buf, 2048); err != nil { - return err - } - if cap(p.AggregationBits) == 0 { - p.AggregationBits = make([]byte, 0, len(buf)) - } - p.AggregationBits = append(p.AggregationBits, buf...) + // Field 3: ProposerIndex + if err = c.ProposerIndex.UnmarshalSSZ(sszSlice3); err != nil { + return fmt.Errorf("ProposerIndex: %w", err) } return err } -// SizeSSZ returns the ssz encoded size in bytes for the PendingAttestation object -func (p *PendingAttestation) SizeSSZ() (size int) { - size = 148 +func (c *PendingAttestation) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} + +func (c *PendingAttestation) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: AggregationBits + if len(c.AggregationBits) == 0 { + return ssz.ErrEmptyBitlist + } + hh.PutBitlist(c.AggregationBits, 2048) + // Field 1: Data + if err := c.Data.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Data: %w", err) + } + // Field 2: InclusionDelay + if err := c.InclusionDelay.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("InclusionDelay: %w", err) + } + // Field 3: ProposerIndex + if err := c.ProposerIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ProposerIndex: %w", err) + } + hh.Merkleize(indx) + return nil +} - // Field (0) 'AggregationBits' - size += len(p.AggregationBits) +func (c *PowBlock) SizeSSZ() int { + size := 96 - return + return size } -// HashTreeRoot ssz hashes the PendingAttestation object -func (p *PendingAttestation) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(p) +func (c *PowBlock) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// HashTreeRootWith ssz hashes the PendingAttestation object with a hasher -func (p *PendingAttestation) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() +func (c *PowBlock) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + + // Field 0: BlockHash + if len(c.BlockHash) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.BlockHash...) + + // Field 1: ParentHash + if len(c.ParentHash) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.ParentHash...) - // Field (0) 'AggregationBits' - if len(p.AggregationBits) == 0 { - err = ssz.ErrEmptyBitlist - return + // Field 2: TotalDifficulty + if len(c.TotalDifficulty) != 32 { + return nil, ssz.ErrBytesLength } - hh.PutBitlist(p.AggregationBits, 2048) + dst = append(dst, c.TotalDifficulty...) + + return dst, err +} - // Field (1) 'Data' - if err = p.Data.HashTreeRootWith(hh); err != nil { - return +func (c *PowBlock) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 96 { + return ssz.ErrSize } - // Field (2) 'InclusionDelay' - ssz.PutUint(hh, p.InclusionDelay) + sszSlice0 := buf[0:32] // c.BlockHash + sszSlice1 := buf[32:64] // c.ParentHash + sszSlice2 := buf[64:96] // c.TotalDifficulty + + // Field 0: BlockHash + c.BlockHash = make([]byte, 0, 32) + c.BlockHash = append(c.BlockHash, sszSlice0...) + + // Field 1: ParentHash + c.ParentHash = make([]byte, 0, 32) + c.ParentHash = append(c.ParentHash, sszSlice1...) + + // Field 2: TotalDifficulty + c.TotalDifficulty = make([]byte, 0, 32) + c.TotalDifficulty = append(c.TotalDifficulty, sszSlice2...) + return err +} - // Field (3) 'ProposerIndex' - ssz.PutUint(hh, p.ProposerIndex) +func (c *PowBlock) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} +func (c *PowBlock) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: BlockHash + if len(c.BlockHash) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.BlockHash) + // Field 1: ParentHash + if len(c.ParentHash) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ParentHash) + // Field 2: TotalDifficulty + if len(c.TotalDifficulty) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.TotalDifficulty) hh.Merkleize(indx) - return + return nil +} + +func (c *ProposerSlashing) SizeSSZ() int { + size := 416 + + return size } -// MarshalSSZ ssz marshals the HistoricalBatch object -func (h *HistoricalBatch) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(h) +func (c *ProposerSlashing) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the HistoricalBatch object to a target array -func (h *HistoricalBatch) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *ProposerSlashing) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (0) 'BlockRoots' - if size := len(h.BlockRoots); size != 64 { - err = ssz.ErrVectorLengthFn("--.BlockRoots", size, 64) - return + // Field 0: Header_1 + if c.Header_1 == nil { + c.Header_1 = new(SignedBeaconBlockHeader) } - for ii := 0; ii < 64; ii++ { - if size := len(h.BlockRoots[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockRoots[ii]", size, 32) - return - } - dst = append(dst, h.BlockRoots[ii]...) + if dst, err = c.Header_1.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Header_1: %w", err) } - // Field (1) 'StateRoots' - if size := len(h.StateRoots); size != 64 { - err = ssz.ErrVectorLengthFn("--.StateRoots", size, 64) - return + // Field 1: Header_2 + if c.Header_2 == nil { + c.Header_2 = new(SignedBeaconBlockHeader) } - for ii := 0; ii < 64; ii++ { - if size := len(h.StateRoots[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoots[ii]", size, 32) - return - } - dst = append(dst, h.StateRoots[ii]...) + if dst, err = c.Header_2.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Header_2: %w", err) } - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the HistoricalBatch object -func (h *HistoricalBatch) UnmarshalSSZ(buf []byte) error { +func (c *ProposerSlashing) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 4096 { + if size != 416 { return ssz.ErrSize } - // Field (0) 'BlockRoots' - h.BlockRoots = make([][]byte, 64) - for ii := 0; ii < 64; ii++ { - if cap(h.BlockRoots[ii]) == 0 { - h.BlockRoots[ii] = make([]byte, 0, len(buf[0:2048][ii*32:(ii+1)*32])) - } - h.BlockRoots[ii] = append(h.BlockRoots[ii], buf[0:2048][ii*32:(ii+1)*32]...) - } + sszSlice0 := buf[0:208] // c.Header_1 + sszSlice1 := buf[208:416] // c.Header_2 - // Field (1) 'StateRoots' - h.StateRoots = make([][]byte, 64) - for ii := 0; ii < 64; ii++ { - if cap(h.StateRoots[ii]) == 0 { - h.StateRoots[ii] = make([]byte, 0, len(buf[2048:4096][ii*32:(ii+1)*32])) - } - h.StateRoots[ii] = append(h.StateRoots[ii], buf[2048:4096][ii*32:(ii+1)*32]...) + // Field 0: Header_1 + c.Header_1 = new(SignedBeaconBlockHeader) + if err = c.Header_1.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Header_1: %w", err) } + // Field 1: Header_2 + c.Header_2 = new(SignedBeaconBlockHeader) + if err = c.Header_2.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Header_2: %w", err) + } return err } -// SizeSSZ returns the ssz encoded size in bytes for the HistoricalBatch object -func (h *HistoricalBatch) SizeSSZ() (size int) { - size = 4096 - return -} - -// HashTreeRoot ssz hashes the HistoricalBatch object -func (h *HistoricalBatch) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(h) +func (c *ProposerSlashing) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the HistoricalBatch object with a hasher -func (h *HistoricalBatch) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *ProposerSlashing) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'BlockRoots' - { - if size := len(h.BlockRoots); size != 64 { - err = ssz.ErrVectorLengthFn("--.BlockRoots", size, 64) - return - } - subIndx := hh.Index() - for _, i := range h.BlockRoots { - if len(i) != 32 { - err = ssz.ErrBytesLength - return - } - hh.Append(i) - } - hh.Merkleize(subIndx) + // Field 0: Header_1 + if err := c.Header_1.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Header_1: %w", err) } - - // Field (1) 'StateRoots' - { - if size := len(h.StateRoots); size != 64 { - err = ssz.ErrVectorLengthFn("--.StateRoots", size, 64) - return - } - subIndx := hh.Index() - for _, i := range h.StateRoots { - if len(i) != 32 { - err = ssz.ErrBytesLength - return - } - hh.Append(i) - } - hh.Merkleize(subIndx) + // Field 1: Header_2 + if err := c.Header_2.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Header_2: %w", err) } - hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the SigningData object -func (s *SigningData) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) +func (c *SignedAggregateAttestationAndProof) SizeSSZ() int { + size := 100 + if c.Message == nil { + c.Message = new(AggregateAttestationAndProof) + } + size += c.Message.SizeSSZ() + return size +} + +func (c *SignedAggregateAttestationAndProof) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the SigningData object to a target array -func (s *SigningData) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *SignedAggregateAttestationAndProof) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 100 - // Field (0) 'ObjectRoot' - if size := len(s.ObjectRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ObjectRoot", size, 32) - return + // Field 0: Message + if c.Message == nil { + c.Message = new(AggregateAttestationAndProof) } - dst = append(dst, s.ObjectRoot...) + dst = ssz.WriteOffset(dst, offset) + offset += c.Message.SizeSSZ() - // Field (1) 'Domain' - if size := len(s.Domain); size != 32 { - err = ssz.ErrBytesLengthFn("--.Domain", size, 32) - return + // Field 1: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } - dst = append(dst, s.Domain...) + dst = append(dst, c.Signature...) - return + // Field 0: Message + if dst, err = c.Message.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Message: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the SigningData object -func (s *SigningData) UnmarshalSSZ(buf []byte) error { +func (c *SignedAggregateAttestationAndProof) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 64 { + if size < 100 { return ssz.ErrSize } - // Field (0) 'ObjectRoot' - if cap(s.ObjectRoot) == 0 { - s.ObjectRoot = make([]byte, 0, len(buf[0:32])) + sszSlice1 := buf[4:100] // c.Signature + + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Message + if sszVarOffset0 != 100 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset0 > size { + return ssz.ErrOffset } - s.ObjectRoot = append(s.ObjectRoot, buf[0:32]...) + sszSlice0 := buf[sszVarOffset0:] // c.Message - // Field (1) 'Domain' - if cap(s.Domain) == 0 { - s.Domain = make([]byte, 0, len(buf[32:64])) + // Field 0: Message + c.Message = new(AggregateAttestationAndProof) + if err = c.Message.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Message: %w", err) } - s.Domain = append(s.Domain, buf[32:64]...) + // Field 1: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice1...) return err } -// SizeSSZ returns the ssz encoded size in bytes for the SigningData object -func (s *SigningData) SizeSSZ() (size int) { - size = 64 - return -} - -// HashTreeRoot ssz hashes the SigningData object -func (s *SigningData) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) +func (c *SignedAggregateAttestationAndProof) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the SigningData object with a hasher -func (s *SigningData) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *SignedAggregateAttestationAndProof) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'ObjectRoot' - if size := len(s.ObjectRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ObjectRoot", size, 32) - return + // Field 0: Message + if err := c.Message.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Message: %w", err) } - hh.PutBytes(s.ObjectRoot) - - // Field (1) 'Domain' - if size := len(s.Domain); size != 32 { - err = ssz.ErrBytesLengthFn("--.Domain", size, 32) - return + // Field 1: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength } - hh.PutBytes(s.Domain) - + hh.PutBytes(c.Signature) hh.Merkleize(indx) - return + return nil +} + +func (c *SignedBeaconBlock) SizeSSZ() int { + size := 100 + if c.Block == nil { + c.Block = new(BeaconBlock) + } + size += c.Block.SizeSSZ() + return size } -// MarshalSSZ ssz marshals the ForkData object -func (f *ForkData) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(f) +func (c *SignedBeaconBlock) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the ForkData object to a target array -func (f *ForkData) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *SignedBeaconBlock) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 100 - // Field (0) 'CurrentVersion' - if size := len(f.CurrentVersion); size != 4 { - err = ssz.ErrBytesLengthFn("--.CurrentVersion", size, 4) - return + // Field 0: Block + if c.Block == nil { + c.Block = new(BeaconBlock) } - dst = append(dst, f.CurrentVersion...) + dst = ssz.WriteOffset(dst, offset) + offset += c.Block.SizeSSZ() - // Field (1) 'GenesisValidatorsRoot' - if size := len(f.GenesisValidatorsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.GenesisValidatorsRoot", size, 32) - return + // Field 1: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } - dst = append(dst, f.GenesisValidatorsRoot...) + dst = append(dst, c.Signature...) - return + // Field 0: Block + if dst, err = c.Block.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Block: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the ForkData object -func (f *ForkData) UnmarshalSSZ(buf []byte) error { +func (c *SignedBeaconBlock) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 36 { + if size < 100 { return ssz.ErrSize } - // Field (0) 'CurrentVersion' - if cap(f.CurrentVersion) == 0 { - f.CurrentVersion = make([]byte, 0, len(buf[0:4])) + sszSlice1 := buf[4:100] // c.Signature + + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Block + if sszVarOffset0 != 100 { + return ssz.ErrInvalidVariableOffset } - f.CurrentVersion = append(f.CurrentVersion, buf[0:4]...) + if sszVarOffset0 > size { + return ssz.ErrOffset + } + sszSlice0 := buf[sszVarOffset0:] // c.Block - // Field (1) 'GenesisValidatorsRoot' - if cap(f.GenesisValidatorsRoot) == 0 { - f.GenesisValidatorsRoot = make([]byte, 0, len(buf[4:36])) + // Field 0: Block + c.Block = new(BeaconBlock) + if err = c.Block.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Block: %w", err) } - f.GenesisValidatorsRoot = append(f.GenesisValidatorsRoot, buf[4:36]...) + // Field 1: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice1...) return err } -// SizeSSZ returns the ssz encoded size in bytes for the ForkData object -func (f *ForkData) SizeSSZ() (size int) { - size = 36 - return -} - -// HashTreeRoot ssz hashes the ForkData object -func (f *ForkData) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(f) +func (c *SignedBeaconBlock) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the ForkData object with a hasher -func (f *ForkData) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *SignedBeaconBlock) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'CurrentVersion' - if size := len(f.CurrentVersion); size != 4 { - err = ssz.ErrBytesLengthFn("--.CurrentVersion", size, 4) - return + // Field 0: Block + if err := c.Block.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Block: %w", err) } - hh.PutBytes(f.CurrentVersion) - - // Field (1) 'GenesisValidatorsRoot' - if size := len(f.GenesisValidatorsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.GenesisValidatorsRoot", size, 32) - return + // Field 1: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength } - hh.PutBytes(f.GenesisValidatorsRoot) - + hh.PutBytes(c.Signature) hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the DepositMessage object -func (d *DepositMessage) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(d) +func (c *SignedBeaconBlockHeader) SizeSSZ() int { + size := 208 + + return size } -// MarshalSSZTo ssz marshals the DepositMessage object to a target array -func (d *DepositMessage) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *SignedBeaconBlockHeader) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (0) 'PublicKey' - if size := len(d.PublicKey); size != 48 { - err = ssz.ErrBytesLengthFn("--.PublicKey", size, 48) - return - } - dst = append(dst, d.PublicKey...) +func (c *SignedBeaconBlockHeader) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (1) 'WithdrawalCredentials' - if size := len(d.WithdrawalCredentials); size != 32 { - err = ssz.ErrBytesLengthFn("--.WithdrawalCredentials", size, 32) - return + // Field 0: Header + if c.Header == nil { + c.Header = new(BeaconBlockHeader) + } + if dst, err = c.Header.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Header: %w", err) } - dst = append(dst, d.WithdrawalCredentials...) - // Field (2) 'Amount' - dst = ssz.MarshalUint(dst, d.Amount) + // Field 1: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.Signature...) - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the DepositMessage object -func (d *DepositMessage) UnmarshalSSZ(buf []byte) error { +func (c *SignedBeaconBlockHeader) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 88 { + if size != 208 { 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]...) + sszSlice0 := buf[0:112] // c.Header + sszSlice1 := buf[112:208] // c.Signature - // Field (1) 'WithdrawalCredentials' - if cap(d.WithdrawalCredentials) == 0 { - d.WithdrawalCredentials = make([]byte, 0, len(buf[48:80])) + // Field 0: Header + c.Header = new(BeaconBlockHeader) + if err = c.Header.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Header: %w", err) } - d.WithdrawalCredentials = append(d.WithdrawalCredentials, buf[48:80]...) - - // Field (2) 'Amount' - d.Amount = ssz.UnmarshallUint[uint64](buf[80:88]) + // Field 1: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice1...) return err } -// SizeSSZ returns the ssz encoded size in bytes for the DepositMessage object -func (d *DepositMessage) SizeSSZ() (size int) { - size = 88 - return -} - -// HashTreeRoot ssz hashes the DepositMessage object -func (d *DepositMessage) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(d) +func (c *SignedBeaconBlockHeader) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the DepositMessage object with a hasher -func (d *DepositMessage) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *SignedBeaconBlockHeader) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'PublicKey' - if size := len(d.PublicKey); size != 48 { - err = ssz.ErrBytesLengthFn("--.PublicKey", size, 48) - return + // Field 0: Header + if err := c.Header.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Header: %w", err) } - hh.PutBytes(d.PublicKey) - - // Field (1) 'WithdrawalCredentials' - if size := len(d.WithdrawalCredentials); size != 32 { - err = ssz.ErrBytesLengthFn("--.WithdrawalCredentials", size, 32) - return + // Field 1: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength } - hh.PutBytes(d.WithdrawalCredentials) + hh.PutBytes(c.Signature) + hh.Merkleize(indx) + return nil +} - // Field (2) 'Amount' - ssz.PutUint(hh, d.Amount) +func (c *SignedVoluntaryExit) SizeSSZ() int { + size := 112 - hh.Merkleize(indx) - return + return size } -// MarshalSSZ ssz marshals the PowBlock object -func (p *PowBlock) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(p) +func (c *SignedVoluntaryExit) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the PowBlock object to a target array -func (p *PowBlock) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *SignedVoluntaryExit) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (0) 'BlockHash' - if size := len(p.BlockHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockHash", size, 32) - return + // Field 0: Exit + if c.Exit == nil { + c.Exit = new(VoluntaryExit) } - dst = append(dst, p.BlockHash...) - - // Field (1) 'ParentHash' - if size := len(p.ParentHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentHash", size, 32) - return + if dst, err = c.Exit.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Exit: %w", err) } - dst = append(dst, p.ParentHash...) - // Field (2) 'TotalDifficulty' - if size := len(p.TotalDifficulty); size != 32 { - err = ssz.ErrBytesLengthFn("--.TotalDifficulty", size, 32) - return + // Field 1: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } - dst = append(dst, p.TotalDifficulty...) + dst = append(dst, c.Signature...) - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the PowBlock object -func (p *PowBlock) UnmarshalSSZ(buf []byte) error { +func (c *SignedVoluntaryExit) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 96 { + if size != 112 { return ssz.ErrSize } - // Field (0) 'BlockHash' - if cap(p.BlockHash) == 0 { - p.BlockHash = make([]byte, 0, len(buf[0:32])) - } - p.BlockHash = append(p.BlockHash, buf[0:32]...) + sszSlice0 := buf[0:16] // c.Exit + sszSlice1 := buf[16:112] // c.Signature - // Field (1) 'ParentHash' - if cap(p.ParentHash) == 0 { - p.ParentHash = make([]byte, 0, len(buf[32:64])) + // Field 0: Exit + c.Exit = new(VoluntaryExit) + if err = c.Exit.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Exit: %w", err) } - p.ParentHash = append(p.ParentHash, buf[32:64]...) - // Field (2) 'TotalDifficulty' - if cap(p.TotalDifficulty) == 0 { - p.TotalDifficulty = make([]byte, 0, len(buf[64:96])) + // Field 1: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice1...) + return err +} + +func (c *SignedVoluntaryExit) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - p.TotalDifficulty = append(p.TotalDifficulty, buf[64:96]...) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - return err +func (c *SignedVoluntaryExit) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Exit + if err := c.Exit.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Exit: %w", err) + } + // Field 1: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Signature) + hh.Merkleize(indx) + return nil } -// SizeSSZ returns the ssz encoded size in bytes for the PowBlock object -func (p *PowBlock) SizeSSZ() (size int) { - size = 96 - return +func (c *SigningData) SizeSSZ() int { + size := 64 + + return size } -// HashTreeRoot ssz hashes the PowBlock object -func (p *PowBlock) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(p) +func (c *SigningData) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// HashTreeRootWith ssz hashes the PowBlock object with a hasher -func (p *PowBlock) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() +func (c *SigningData) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + + // Field 0: ObjectRoot + if len(c.ObjectRoot) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.ObjectRoot...) - // Field (0) 'BlockHash' - if size := len(p.BlockHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockHash", size, 32) - return + // Field 1: Domain + if len(c.Domain) != 32 { + return nil, ssz.ErrBytesLength } - hh.PutBytes(p.BlockHash) + dst = append(dst, c.Domain...) + + return dst, err +} - // Field (1) 'ParentHash' - if size := len(p.ParentHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentHash", size, 32) - return +func (c *SigningData) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 64 { + return ssz.ErrSize } - hh.PutBytes(p.ParentHash) - // Field (2) 'TotalDifficulty' - if size := len(p.TotalDifficulty); size != 32 { - err = ssz.ErrBytesLengthFn("--.TotalDifficulty", size, 32) - return + sszSlice0 := buf[0:32] // c.ObjectRoot + sszSlice1 := buf[32:64] // c.Domain + + // Field 0: ObjectRoot + c.ObjectRoot = make([]byte, 0, 32) + c.ObjectRoot = append(c.ObjectRoot, sszSlice0...) + + // Field 1: Domain + c.Domain = make([]byte, 0, 32) + c.Domain = append(c.Domain, sszSlice1...) + return err +} + +func (c *SigningData) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - hh.PutBytes(p.TotalDifficulty) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} +func (c *SigningData) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: ObjectRoot + if len(c.ObjectRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ObjectRoot) + // Field 1: Domain + if len(c.Domain) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Domain) hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the Status object -func (s *Status) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) +func (c *Status) SizeSSZ() int { + size := 84 + + return size +} + +func (c *Status) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the Status object to a target array -func (s *Status) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *Status) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (0) 'ForkDigest' - if size := len(s.ForkDigest); size != 4 { - err = ssz.ErrBytesLengthFn("--.ForkDigest", size, 4) - return + // Field 0: ForkDigest + if len(c.ForkDigest) != 4 { + return nil, ssz.ErrBytesLength } - dst = append(dst, s.ForkDigest...) + dst = append(dst, c.ForkDigest...) - // Field (1) 'FinalizedRoot' - if size := len(s.FinalizedRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.FinalizedRoot", size, 32) - return + // Field 1: FinalizedRoot + if len(c.FinalizedRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, s.FinalizedRoot...) + dst = append(dst, c.FinalizedRoot...) - // Field (2) 'FinalizedEpoch' - dst = ssz.MarshalUint(dst, s.FinalizedEpoch) + // Field 2: FinalizedEpoch + if dst, err = c.FinalizedEpoch.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("FinalizedEpoch: %w", err) + } - // Field (3) 'HeadRoot' - if size := len(s.HeadRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.HeadRoot", size, 32) - return + // Field 3: HeadRoot + if len(c.HeadRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, s.HeadRoot...) + dst = append(dst, c.HeadRoot...) - // Field (4) 'HeadSlot' - dst = ssz.MarshalUint(dst, s.HeadSlot) + // Field 4: HeadSlot + if dst, err = c.HeadSlot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("HeadSlot: %w", err) + } - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the Status object -func (s *Status) UnmarshalSSZ(buf []byte) error { +func (c *Status) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size != 84 { return ssz.ErrSize } - // Field (0) 'ForkDigest' - if cap(s.ForkDigest) == 0 { - s.ForkDigest = make([]byte, 0, len(buf[0:4])) - } - s.ForkDigest = append(s.ForkDigest, buf[0:4]...) + sszSlice0 := buf[0:4] // c.ForkDigest + sszSlice1 := buf[4:36] // c.FinalizedRoot + sszSlice2 := buf[36:44] // c.FinalizedEpoch + sszSlice3 := buf[44:76] // c.HeadRoot + sszSlice4 := buf[76:84] // c.HeadSlot - // Field (1) 'FinalizedRoot' - if cap(s.FinalizedRoot) == 0 { - s.FinalizedRoot = make([]byte, 0, len(buf[4:36])) - } - s.FinalizedRoot = append(s.FinalizedRoot, buf[4:36]...) + // Field 0: ForkDigest + c.ForkDigest = make([]byte, 0, 4) + c.ForkDigest = append(c.ForkDigest, sszSlice0...) - // Field (2) 'FinalizedEpoch' - s.FinalizedEpoch = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Epoch](buf[36:44]) + // Field 1: FinalizedRoot + c.FinalizedRoot = make([]byte, 0, 32) + c.FinalizedRoot = append(c.FinalizedRoot, sszSlice1...) - // Field (3) 'HeadRoot' - if cap(s.HeadRoot) == 0 { - s.HeadRoot = make([]byte, 0, len(buf[44:76])) + // Field 2: FinalizedEpoch + if err = c.FinalizedEpoch.UnmarshalSSZ(sszSlice2); err != nil { + return fmt.Errorf("FinalizedEpoch: %w", err) } - s.HeadRoot = append(s.HeadRoot, buf[44:76]...) - // Field (4) 'HeadSlot' - s.HeadSlot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[76:84]) + // Field 3: HeadRoot + c.HeadRoot = make([]byte, 0, 32) + c.HeadRoot = append(c.HeadRoot, sszSlice3...) + // Field 4: HeadSlot + if err = c.HeadSlot.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("HeadSlot: %w", err) + } return err } -// SizeSSZ returns the ssz encoded size in bytes for the Status object -func (s *Status) SizeSSZ() (size int) { - size = 84 - return +func (c *Status) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRoot ssz hashes the Status object -func (s *Status) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) +func (c *Status) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: ForkDigest + if len(c.ForkDigest) != 4 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ForkDigest) + // Field 1: FinalizedRoot + if len(c.FinalizedRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.FinalizedRoot) + // Field 2: FinalizedEpoch + if err := c.FinalizedEpoch.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("FinalizedEpoch: %w", err) + } + // Field 3: HeadRoot + if len(c.HeadRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.HeadRoot) + // Field 4: HeadSlot + if err := c.HeadSlot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("HeadSlot: %w", err) + } + hh.Merkleize(indx) + return nil } -// HashTreeRootWith ssz hashes the Status object with a hasher -func (s *Status) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() +func (c *Validator) SizeSSZ() int { + size := 121 - // Field (0) 'ForkDigest' - if size := len(s.ForkDigest); size != 4 { - err = ssz.ErrBytesLengthFn("--.ForkDigest", size, 4) - return - } - hh.PutBytes(s.ForkDigest) + return size +} - // Field (1) 'FinalizedRoot' - if size := len(s.FinalizedRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.FinalizedRoot", size, 32) - return - } - hh.PutBytes(s.FinalizedRoot) +func (c *Validator) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (2) 'FinalizedEpoch' - ssz.PutUint(hh, s.FinalizedEpoch) +func (c *Validator) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (3) 'HeadRoot' - if size := len(s.HeadRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.HeadRoot", size, 32) - return + // Field 0: PublicKey + if len(c.PublicKey) != 48 { + return nil, ssz.ErrBytesLength } - hh.PutBytes(s.HeadRoot) + dst = append(dst, c.PublicKey...) - // Field (4) 'HeadSlot' - ssz.PutUint(hh, s.HeadSlot) + // Field 1: WithdrawalCredentials + if len(c.WithdrawalCredentials) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.WithdrawalCredentials...) - hh.Merkleize(indx) - return -} + // Field 2: EffectiveBalance + dst = binary.LittleEndian.AppendUint64(dst, c.EffectiveBalance) -// MarshalSSZ ssz marshals the ENRForkID object -func (e *ENRForkID) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(e) -} + // Field 3: Slashed + if c.Slashed { + dst = append(dst, 1) + } else { + dst = append(dst, 0) + } -// MarshalSSZTo ssz marshals the ENRForkID object to a target array -func (e *ENRForkID) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf + // Field 4: ActivationEligibilityEpoch + if dst, err = c.ActivationEligibilityEpoch.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ActivationEligibilityEpoch: %w", err) + } - // Field (0) 'CurrentForkDigest' - if size := len(e.CurrentForkDigest); size != 4 { - err = ssz.ErrBytesLengthFn("--.CurrentForkDigest", size, 4) - return + // Field 5: ActivationEpoch + if dst, err = c.ActivationEpoch.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ActivationEpoch: %w", err) } - dst = append(dst, e.CurrentForkDigest...) - // Field (1) 'NextForkVersion' - if size := len(e.NextForkVersion); size != 4 { - err = ssz.ErrBytesLengthFn("--.NextForkVersion", size, 4) - return + // Field 6: ExitEpoch + if dst, err = c.ExitEpoch.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ExitEpoch: %w", err) } - dst = append(dst, e.NextForkVersion...) - // Field (2) 'NextForkEpoch' - dst = ssz.MarshalUint(dst, e.NextForkEpoch) + // Field 7: WithdrawableEpoch + if dst, err = c.WithdrawableEpoch.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("WithdrawableEpoch: %w", err) + } - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the ENRForkID object -func (e *ENRForkID) UnmarshalSSZ(buf []byte) error { +func (c *Validator) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 16 { + if size != 121 { return ssz.ErrSize } - // Field (0) 'CurrentForkDigest' - if cap(e.CurrentForkDigest) == 0 { - e.CurrentForkDigest = make([]byte, 0, len(buf[0:4])) - } - e.CurrentForkDigest = append(e.CurrentForkDigest, buf[0:4]...) + sszSlice0 := buf[0:48] // c.PublicKey + sszSlice1 := buf[48:80] // c.WithdrawalCredentials + sszSlice2 := buf[80:88] // c.EffectiveBalance + sszSlice3 := buf[88:89] // c.Slashed + sszSlice4 := buf[89:97] // c.ActivationEligibilityEpoch + sszSlice5 := buf[97:105] // c.ActivationEpoch + sszSlice6 := buf[105:113] // c.ExitEpoch + sszSlice7 := buf[113:121] // c.WithdrawableEpoch - // Field (1) 'NextForkVersion' - if cap(e.NextForkVersion) == 0 { - e.NextForkVersion = make([]byte, 0, len(buf[4:8])) - } - e.NextForkVersion = append(e.NextForkVersion, buf[4:8]...) + // Field 0: PublicKey + c.PublicKey = make([]byte, 0, 48) + c.PublicKey = append(c.PublicKey, sszSlice0...) - // Field (2) 'NextForkEpoch' - e.NextForkEpoch = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Epoch](buf[8:16]) + // Field 1: WithdrawalCredentials + c.WithdrawalCredentials = make([]byte, 0, 32) + c.WithdrawalCredentials = append(c.WithdrawalCredentials, sszSlice1...) - return err -} + // Field 2: EffectiveBalance + c.EffectiveBalance = binary.LittleEndian.Uint64(sszSlice2) -// SizeSSZ returns the ssz encoded size in bytes for the ENRForkID object -func (e *ENRForkID) SizeSSZ() (size int) { - size = 16 - return -} + // Field 3: Slashed + if sszSlice3[0] > 1 { + return ssz.ErrInvalidSerialization + } + if sszSlice3[0] == 1 { + c.Slashed = true + } else { + c.Slashed = false + } -// HashTreeRoot ssz hashes the ENRForkID object -func (e *ENRForkID) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(e) -} + // Field 4: ActivationEligibilityEpoch + if err = c.ActivationEligibilityEpoch.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("ActivationEligibilityEpoch: %w", err) + } -// HashTreeRootWith ssz hashes the ENRForkID object with a hasher -func (e *ENRForkID) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() + // Field 5: ActivationEpoch + if err = c.ActivationEpoch.UnmarshalSSZ(sszSlice5); err != nil { + return fmt.Errorf("ActivationEpoch: %w", err) + } - // Field (0) 'CurrentForkDigest' - if size := len(e.CurrentForkDigest); size != 4 { - err = ssz.ErrBytesLengthFn("--.CurrentForkDigest", size, 4) - return + // Field 6: ExitEpoch + if err = c.ExitEpoch.UnmarshalSSZ(sszSlice6); err != nil { + return fmt.Errorf("ExitEpoch: %w", err) } - hh.PutBytes(e.CurrentForkDigest) - // Field (1) 'NextForkVersion' - if size := len(e.NextForkVersion); size != 4 { - err = ssz.ErrBytesLengthFn("--.NextForkVersion", size, 4) - return + // Field 7: WithdrawableEpoch + if err = c.WithdrawableEpoch.UnmarshalSSZ(sszSlice7); err != nil { + return fmt.Errorf("WithdrawableEpoch: %w", err) } - hh.PutBytes(e.NextForkVersion) + return err +} - // Field (2) 'NextForkEpoch' - ssz.PutUint(hh, e.NextForkEpoch) +func (c *Validator) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} +func (c *Validator) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: PublicKey + if len(c.PublicKey) != 48 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.PublicKey) + // Field 1: WithdrawalCredentials + if len(c.WithdrawalCredentials) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.WithdrawalCredentials) + // Field 2: EffectiveBalance + hh.PutUint64(c.EffectiveBalance) + // Field 3: Slashed + hh.PutBool(c.Slashed) + // Field 4: ActivationEligibilityEpoch + if err := c.ActivationEligibilityEpoch.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ActivationEligibilityEpoch: %w", err) + } + // Field 5: ActivationEpoch + if err := c.ActivationEpoch.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ActivationEpoch: %w", err) + } + // Field 6: ExitEpoch + if err := c.ExitEpoch.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ExitEpoch: %w", err) + } + // Field 7: WithdrawableEpoch + if err := c.WithdrawableEpoch.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("WithdrawableEpoch: %w", err) + } hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the ValidatorIdentity object -func (v *ValidatorIdentity) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(v) +func (c *ValidatorBalance) SizeSSZ() int { + size := 16 + + return size } -// MarshalSSZTo ssz marshals the ValidatorIdentity object to a target array -func (v *ValidatorIdentity) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *ValidatorBalance) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (0) 'Index' - dst = ssz.MarshalUint(dst, v.Index) +func (c *ValidatorBalance) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (1) 'Pubkey' - if size := len(v.Pubkey); size != 48 { - err = ssz.ErrBytesLengthFn("--.Pubkey", size, 48) - return + // Field 0: Index + if dst, err = c.Index.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Index: %w", err) } - dst = append(dst, v.Pubkey...) - // Field (2) 'ActivationEpoch' - dst = ssz.MarshalUint(dst, v.ActivationEpoch) + // Field 1: Balance + dst = binary.LittleEndian.AppendUint64(dst, c.Balance) - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the ValidatorIdentity object -func (v *ValidatorIdentity) UnmarshalSSZ(buf []byte) error { +func (c *ValidatorBalance) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 64 { + if size != 16 { return ssz.ErrSize } - // Field (0) 'Index' - v.Index = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[0:8]) + sszSlice0 := buf[0:8] // c.Index + sszSlice1 := buf[8:16] // c.Balance - // Field (1) 'Pubkey' - if cap(v.Pubkey) == 0 { - v.Pubkey = make([]byte, 0, len(buf[8:56])) + // Field 0: Index + if err = c.Index.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Index: %w", err) } - v.Pubkey = append(v.Pubkey, buf[8:56]...) - - // Field (2) 'ActivationEpoch' - v.ActivationEpoch = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Epoch](buf[56:64]) + // Field 1: Balance + c.Balance = binary.LittleEndian.Uint64(sszSlice1) return err } -// SizeSSZ returns the ssz encoded size in bytes for the ValidatorIdentity object -func (v *ValidatorIdentity) SizeSSZ() (size int) { - size = 64 - return -} - -// HashTreeRoot ssz hashes the ValidatorIdentity object -func (v *ValidatorIdentity) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(v) +func (c *ValidatorBalance) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the ValidatorIdentity object with a hasher -func (v *ValidatorIdentity) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *ValidatorBalance) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Index' - ssz.PutUint(hh, v.Index) - - // Field (1) 'Pubkey' - if size := len(v.Pubkey); size != 48 { - err = ssz.ErrBytesLengthFn("--.Pubkey", size, 48) - return + // Field 0: Index + if err := c.Index.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Index: %w", err) } - hh.PutBytes(v.Pubkey) + // Field 1: Balance + hh.PutUint64(c.Balance) + hh.Merkleize(indx) + return nil +} - // Field (2) 'ActivationEpoch' - ssz.PutUint(hh, v.ActivationEpoch) +func (c *VoluntaryExit) SizeSSZ() int { + size := 16 - hh.Merkleize(indx) - return + return size } -// MarshalSSZ ssz marshals the ValidatorBalance object -func (v *ValidatorBalance) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(v) +func (c *VoluntaryExit) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the ValidatorBalance object to a target array -func (v *ValidatorBalance) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *VoluntaryExit) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (0) 'Index' - dst = ssz.MarshalUint(dst, v.Index) + // Field 0: Epoch + if dst, err = c.Epoch.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Epoch: %w", err) + } - // Field (1) 'Balance' - dst = ssz.MarshalUint(dst, v.Balance) + // Field 1: ValidatorIndex + if dst, err = c.ValidatorIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ValidatorIndex: %w", err) + } - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the ValidatorBalance object -func (v *ValidatorBalance) UnmarshalSSZ(buf []byte) error { +func (c *VoluntaryExit) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size != 16 { return ssz.ErrSize } - // Field (0) 'Index' - v.Index = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[0:8]) + sszSlice0 := buf[0:8] // c.Epoch + sszSlice1 := buf[8:16] // c.ValidatorIndex - // Field (1) 'Balance' - v.Balance = ssz.UnmarshallUint[uint64](buf[8:16]) + // Field 0: Epoch + if err = c.Epoch.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Epoch: %w", err) + } + // Field 1: ValidatorIndex + if err = c.ValidatorIndex.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("ValidatorIndex: %w", err) + } return err } -// SizeSSZ returns the ssz encoded size in bytes for the ValidatorBalance object -func (v *ValidatorBalance) SizeSSZ() (size int) { - size = 16 - return -} - -// HashTreeRoot ssz hashes the ValidatorBalance object -func (v *ValidatorBalance) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(v) +func (c *VoluntaryExit) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the ValidatorBalance object with a hasher -func (v *ValidatorBalance) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *VoluntaryExit) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Index' - ssz.PutUint(hh, v.Index) - - // Field (1) 'Balance' - ssz.PutUint(hh, v.Balance) - + // Field 0: Epoch + if err := c.Epoch.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Epoch: %w", err) + } + // Field 1: ValidatorIndex + if err := c.ValidatorIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ValidatorIndex: %w", err) + } hh.Merkleize(indx) - return + return nil } diff --git a/proto/prysm/v1alpha1/phase0.ssz.go b/proto/prysm/v1alpha1/phase0.ssz.go index 3bd775c6d8fa..7ed2fcec7e95 100644 --- a/proto/prysm/v1alpha1/phase0.ssz.go +++ b/proto/prysm/v1alpha1/phase0.ssz.go @@ -1,4192 +1,4066 @@ //go:build !minimal -// Code generated by fastssz. DO NOT EDIT. package eth import ( - github_com_OffchainLabs_prysm_v7_consensus_types_primitives "github.com/OffchainLabs/prysm/v7/consensus-types/primitives" - ssz "github.com/prysmaticlabs/fastssz" + binary "encoding/binary" + "fmt" + go_bitfield "github.com/OffchainLabs/go-bitfield" + ssz "github.com/OffchainLabs/methodical-ssz/ssz" ) -// MarshalSSZ ssz marshals the SignedAggregateAttestationAndProof object -func (s *SignedAggregateAttestationAndProof) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) -} - -// MarshalSSZTo ssz marshals the SignedAggregateAttestationAndProof object to a target array -func (s *SignedAggregateAttestationAndProof) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(100) - - // Offset (0) 'Message' - dst = ssz.WriteOffset(dst, offset) - if s.Message == nil { - s.Message = new(AggregateAttestationAndProof) - } - offset += s.Message.SizeSSZ() - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return - } - dst = append(dst, s.Signature...) - - // Field (0) 'Message' - if dst, err = s.Message.MarshalSSZTo(dst); err != nil { - return - } - - return -} - -// UnmarshalSSZ ssz unmarshals the SignedAggregateAttestationAndProof object -func (s *SignedAggregateAttestationAndProof) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 100 { - return ssz.ErrSize - } - - tail := buf - var o0 uint64 - - // Offset (0) 'Message' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } - - if o0 != 100 { - return ssz.ErrInvalidVariableOffset - } - - // Field (1) 'Signature' - if cap(s.Signature) == 0 { - s.Signature = make([]byte, 0, len(buf[4:100])) - } - s.Signature = append(s.Signature, buf[4:100]...) - - // Field (0) 'Message' - { - buf = tail[o0:] - if s.Message == nil { - s.Message = new(AggregateAttestationAndProof) - } - if err = s.Message.UnmarshalSSZ(buf); err != nil { - return err - } - } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the SignedAggregateAttestationAndProof object -func (s *SignedAggregateAttestationAndProof) SizeSSZ() (size int) { - size = 100 - - // Field (0) 'Message' - if s.Message == nil { - s.Message = new(AggregateAttestationAndProof) +func (c *AggregateAttestationAndProof) SizeSSZ() int { + size := 108 + if c.Aggregate == nil { + c.Aggregate = new(Attestation) } - size += s.Message.SizeSSZ() - - return + size += c.Aggregate.SizeSSZ() + return size } -// HashTreeRoot ssz hashes the SignedAggregateAttestationAndProof object -func (s *SignedAggregateAttestationAndProof) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) +func (c *AggregateAttestationAndProof) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// HashTreeRootWith ssz hashes the SignedAggregateAttestationAndProof object with a hasher -func (s *SignedAggregateAttestationAndProof) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() +func (c *AggregateAttestationAndProof) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 108 - // Field (0) 'Message' - if err = s.Message.HashTreeRootWith(hh); err != nil { - return + // Field 0: AggregatorIndex + if dst, err = c.AggregatorIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("AggregatorIndex: %w", err) } - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 1: Aggregate + if c.Aggregate == nil { + c.Aggregate = new(Attestation) } - hh.PutBytes(s.Signature) - - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the AggregateAttestationAndProof object -func (a *AggregateAttestationAndProof) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(a) -} - -// MarshalSSZTo ssz marshals the AggregateAttestationAndProof object to a target array -func (a *AggregateAttestationAndProof) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(108) - - // Field (0) 'AggregatorIndex' - dst = ssz.MarshalUint(dst, a.AggregatorIndex) - - // Offset (1) 'Aggregate' dst = ssz.WriteOffset(dst, offset) - if a.Aggregate == nil { - a.Aggregate = new(Attestation) - } - offset += a.Aggregate.SizeSSZ() + offset += c.Aggregate.SizeSSZ() - // Field (2) 'SelectionProof' - if size := len(a.SelectionProof); size != 96 { - err = ssz.ErrBytesLengthFn("--.SelectionProof", size, 96) - return + // Field 2: SelectionProof + if len(c.SelectionProof) != 96 { + return nil, ssz.ErrBytesLength } - dst = append(dst, a.SelectionProof...) + dst = append(dst, c.SelectionProof...) - // Field (1) 'Aggregate' - if dst, err = a.Aggregate.MarshalSSZTo(dst); err != nil { - return + // Field 1: Aggregate + if dst, err = c.Aggregate.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Aggregate: %w", err) } - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the AggregateAttestationAndProof object -func (a *AggregateAttestationAndProof) UnmarshalSSZ(buf []byte) error { +func (c *AggregateAttestationAndProof) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size < 108 { return ssz.ErrSize } - tail := buf - var o1 uint64 + sszSlice0 := buf[0:8] // c.AggregatorIndex + sszSlice2 := buf[12:108] // c.SelectionProof - // Field (0) 'AggregatorIndex' - a.AggregatorIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[0:8]) - - // Offset (1) 'Aggregate' - if o1 = ssz.ReadOffset(buf[8:12]); o1 > size { + sszVarOffset1 := ssz.ReadOffset(buf[8:12]) // c.Aggregate + if sszVarOffset1 != 108 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset1 > size { return ssz.ErrOffset } + sszSlice1 := buf[sszVarOffset1:] // c.Aggregate - if o1 != 108 { - return ssz.ErrInvalidVariableOffset + // Field 0: AggregatorIndex + if err = c.AggregatorIndex.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("AggregatorIndex: %w", err) } - // Field (2) 'SelectionProof' - if cap(a.SelectionProof) == 0 { - a.SelectionProof = make([]byte, 0, len(buf[12:108])) + // Field 1: Aggregate + c.Aggregate = new(Attestation) + if err = c.Aggregate.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Aggregate: %w", err) } - a.SelectionProof = append(a.SelectionProof, buf[12:108]...) - // Field (1) 'Aggregate' - { - buf = tail[o1:] - if a.Aggregate == nil { - a.Aggregate = new(Attestation) - } - if err = a.Aggregate.UnmarshalSSZ(buf); err != nil { - return err - } - } + // Field 2: SelectionProof + c.SelectionProof = make([]byte, 0, 96) + c.SelectionProof = append(c.SelectionProof, sszSlice2...) return err } -// SizeSSZ returns the ssz encoded size in bytes for the AggregateAttestationAndProof object -func (a *AggregateAttestationAndProof) SizeSSZ() (size int) { - size = 108 - - // Field (1) 'Aggregate' - if a.Aggregate == nil { - a.Aggregate = new(Attestation) +func (c *AggregateAttestationAndProof) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - size += a.Aggregate.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the AggregateAttestationAndProof object -func (a *AggregateAttestationAndProof) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(a) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the AggregateAttestationAndProof object with a hasher -func (a *AggregateAttestationAndProof) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *AggregateAttestationAndProof) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'AggregatorIndex' - ssz.PutUint(hh, a.AggregatorIndex) - - // Field (1) 'Aggregate' - if err = a.Aggregate.HashTreeRootWith(hh); err != nil { - return + // Field 0: AggregatorIndex + if err := c.AggregatorIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("AggregatorIndex: %w", err) } - - // Field (2) 'SelectionProof' - if size := len(a.SelectionProof); size != 96 { - err = ssz.ErrBytesLengthFn("--.SelectionProof", size, 96) - return + // Field 1: Aggregate + if err := c.Aggregate.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Aggregate: %w", err) } - hh.PutBytes(a.SelectionProof) - + // Field 2: SelectionProof + if len(c.SelectionProof) != 96 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.SelectionProof) hh.Merkleize(indx) - return + return nil +} + +func (c *Attestation) SizeSSZ() int { + size := 228 + size += len(c.AggregationBits) + return size } -// MarshalSSZ ssz marshals the Attestation object -func (a *Attestation) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(a) +func (c *Attestation) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// 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) +func (c *Attestation) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 228 - // Offset (0) 'AggregationBits' + // Field 0: AggregationBits dst = ssz.WriteOffset(dst, offset) - offset += len(a.AggregationBits) + offset += len(c.AggregationBits) - // Field (1) 'Data' - if a.Data == nil { - a.Data = new(AttestationData) + // Field 1: Data + if c.Data == nil { + c.Data = new(AttestationData) } - if dst, err = a.Data.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.Data.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Data: %w", err) } - // Field (2) 'Signature' - if size := len(a.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 2: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } - dst = append(dst, a.Signature...) + dst = append(dst, c.Signature...) - // Field (0) 'AggregationBits' - if size := len(a.AggregationBits); size > 2048 { - err = ssz.ErrBytesLengthFn("--.AggregationBits", size, 2048) - return + // Field 0: AggregationBits + if len(c.AggregationBits) > 2048 { + return nil, ssz.ErrListTooBig } - dst = append(dst, a.AggregationBits...) - - return + dst = append(dst, c.AggregationBits...) + return dst, err } -// UnmarshalSSZ ssz unmarshals the Attestation object -func (a *Attestation) UnmarshalSSZ(buf []byte) error { +func (c *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 - } + sszSlice1 := buf[4:132] // c.Data + sszSlice2 := buf[132:228] // c.Signature - if o0 != 228 { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.AggregationBits + if sszVarOffset0 != 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 + if sszVarOffset0 > size { + return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:] // c.AggregationBits - // Field (2) 'Signature' - if cap(a.Signature) == 0 { - a.Signature = make([]byte, 0, len(buf[132:228])) + // Field 0: AggregationBits + if err = ssz.ValidateBitlist(sszSlice0, 2048); err != nil { + return fmt.Errorf("AggregationBits: %w", err) } - a.Signature = append(a.Signature, buf[132:228]...) + c.AggregationBits = append([]byte{}, go_bitfield.Bitlist(sszSlice0)...) - // 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...) + // Field 1: Data + c.Data = new(AttestationData) + if err = c.Data.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Data: %w", err) } - 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 + // Field 2: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice2...) + return err } -// HashTreeRoot ssz hashes the Attestation object -func (a *Attestation) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(a) +func (c *Attestation) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the Attestation object with a hasher -func (a *Attestation) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *Attestation) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'AggregationBits' - if len(a.AggregationBits) == 0 { - err = ssz.ErrEmptyBitlist - return + // Field 0: AggregationBits + if len(c.AggregationBits) == 0 { + return ssz.ErrEmptyBitlist } - hh.PutBitlist(a.AggregationBits, 2048) - - // Field (1) 'Data' - if err = a.Data.HashTreeRootWith(hh); err != nil { - return + hh.PutBitlist(c.AggregationBits, 2048) + // Field 1: Data + if err := c.Data.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Data: %w", err) } - - // Field (2) 'Signature' - if size := len(a.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 2: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength } - hh.PutBytes(a.Signature) - + hh.PutBytes(c.Signature) hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the AttestationData object -func (a *AttestationData) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(a) +func (c *AttestationData) SizeSSZ() int { + size := 128 + + return size +} + +func (c *AttestationData) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the AttestationData object to a target array -func (a *AttestationData) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *AttestationData) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (0) 'Slot' - dst = ssz.MarshalUint(dst, a.Slot) + // Field 0: Slot + if dst, err = c.Slot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Slot: %w", err) + } - // Field (1) 'CommitteeIndex' - dst = ssz.MarshalUint(dst, a.CommitteeIndex) + // Field 1: CommitteeIndex + if dst, err = c.CommitteeIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("CommitteeIndex: %w", err) + } - // Field (2) 'BeaconBlockRoot' - if size := len(a.BeaconBlockRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.BeaconBlockRoot", size, 32) - return + // Field 2: BeaconBlockRoot + if len(c.BeaconBlockRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, a.BeaconBlockRoot...) + dst = append(dst, c.BeaconBlockRoot...) - // Field (3) 'Source' - if a.Source == nil { - a.Source = new(Checkpoint) + // Field 3: Source + if c.Source == nil { + c.Source = new(Checkpoint) } - if dst, err = a.Source.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.Source.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Source: %w", err) } - // Field (4) 'Target' - if a.Target == nil { - a.Target = new(Checkpoint) + // Field 4: Target + if c.Target == nil { + c.Target = new(Checkpoint) } - if dst, err = a.Target.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.Target.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Target: %w", err) } - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the AttestationData object -func (a *AttestationData) UnmarshalSSZ(buf []byte) error { +func (c *AttestationData) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size != 128 { return ssz.ErrSize } - // Field (0) 'Slot' - a.Slot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[0:8]) + sszSlice0 := buf[0:8] // c.Slot + sszSlice1 := buf[8:16] // c.CommitteeIndex + sszSlice2 := buf[16:48] // c.BeaconBlockRoot + sszSlice3 := buf[48:88] // c.Source + sszSlice4 := buf[88:128] // c.Target - // Field (1) 'CommitteeIndex' - a.CommitteeIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.CommitteeIndex](buf[8:16]) - - // Field (2) 'BeaconBlockRoot' - if cap(a.BeaconBlockRoot) == 0 { - a.BeaconBlockRoot = make([]byte, 0, len(buf[16:48])) + // Field 0: Slot + if err = c.Slot.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Slot: %w", err) } - a.BeaconBlockRoot = append(a.BeaconBlockRoot, 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 1: CommitteeIndex + if err = c.CommitteeIndex.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("CommitteeIndex: %w", err) } - // Field (4) 'Target' - if a.Target == nil { - a.Target = new(Checkpoint) - } - if err = a.Target.UnmarshalSSZ(buf[88:128]); err != nil { - return err + // Field 2: BeaconBlockRoot + c.BeaconBlockRoot = make([]byte, 0, 32) + c.BeaconBlockRoot = append(c.BeaconBlockRoot, sszSlice2...) + + // Field 3: Source + c.Source = new(Checkpoint) + if err = c.Source.UnmarshalSSZ(sszSlice3); err != nil { + return fmt.Errorf("Source: %w", err) } + // Field 4: Target + c.Target = new(Checkpoint) + if err = c.Target.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("Target: %w", 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) +func (c *AttestationData) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the AttestationData object with a hasher -func (a *AttestationData) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *AttestationData) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Slot' - ssz.PutUint(hh, a.Slot) - - // Field (1) 'CommitteeIndex' - ssz.PutUint(hh, a.CommitteeIndex) - - // Field (2) 'BeaconBlockRoot' - if size := len(a.BeaconBlockRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.BeaconBlockRoot", size, 32) - return + // Field 0: Slot + if err := c.Slot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Slot: %w", err) } - hh.PutBytes(a.BeaconBlockRoot) - - // Field (3) 'Source' - if err = a.Source.HashTreeRootWith(hh); err != nil { - return + // Field 1: CommitteeIndex + if err := c.CommitteeIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("CommitteeIndex: %w", err) } - - // Field (4) 'Target' - if err = a.Target.HashTreeRootWith(hh); err != nil { - return + // Field 2: BeaconBlockRoot + if len(c.BeaconBlockRoot) != 32 { + return ssz.ErrBytesLength } - - hh.Merkleize(indx) - return -} - -// 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.MarshalUint(dst, c.Epoch) - - // Field (1) 'Root' - if size := len(c.Root); size != 32 { - err = ssz.ErrBytesLengthFn("--.Root", size, 32) - return + hh.PutBytes(c.BeaconBlockRoot) + // Field 3: Source + if err := c.Source.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Source: %w", err) } - dst = append(dst, c.Root...) - - return + // Field 4: Target + if err := c.Target.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Target: %w", err) + } + hh.Merkleize(indx) + return nil } -// 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 +func (c *AttesterSlashing) SizeSSZ() int { + size := 8 + if c.Attestation_1 == nil { + c.Attestation_1 = new(IndexedAttestation) } - - // Field (0) 'Epoch' - c.Epoch = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Epoch](buf[0:8]) - - // Field (1) 'Root' - if cap(c.Root) == 0 { - c.Root = make([]byte, 0, len(buf[8:40])) + size += c.Attestation_1.SizeSSZ() + if c.Attestation_2 == nil { + c.Attestation_2 = new(IndexedAttestation) } - 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 + size += c.Attestation_2.SizeSSZ() + return size } -// HashTreeRoot ssz hashes the Checkpoint object -func (c *Checkpoint) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(c) +func (c *AttesterSlashing) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// HashTreeRootWith ssz hashes the Checkpoint object with a hasher -func (c *Checkpoint) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'Epoch' - ssz.PutUint(hh, c.Epoch) +func (c *AttesterSlashing) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 8 - // Field (1) 'Root' - if size := len(c.Root); size != 32 { - err = ssz.ErrBytesLengthFn("--.Root", size, 32) - return + // Field 0: Attestation_1 + if c.Attestation_1 == nil { + c.Attestation_1 = new(IndexedAttestation) } - hh.PutBytes(c.Root) - - hh.Merkleize(indx) - return -} - -// 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) - if s.Block == nil { - s.Block = new(BeaconBlock) - } - offset += s.Block.SizeSSZ() + offset += c.Attestation_1.SizeSSZ() - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 1: Attestation_2 + if c.Attestation_2 == nil { + c.Attestation_2 = new(IndexedAttestation) } - dst = append(dst, s.Signature...) + dst = ssz.WriteOffset(dst, offset) + offset += c.Attestation_2.SizeSSZ() - // Field (0) 'Block' - if dst, err = s.Block.MarshalSSZTo(dst); err != nil { - return + // Field 0: Attestation_1 + if dst, err = c.Attestation_1.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Attestation_1: %w", err) } - return + // Field 1: Attestation_2 + if dst, err = c.Attestation_2.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Attestation_2: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the SignedBeaconBlock object -func (s *SignedBeaconBlock) UnmarshalSSZ(buf []byte) error { +func (c *AttesterSlashing) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 100 { + if size < 8 { return ssz.ErrSize } - tail := buf - var o0 uint64 - - // Offset (0) 'Block' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Attestation_1 + if sszVarOffset0 != 8 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset0 > size { return ssz.ErrOffset } - - if o0 != 100 { - return ssz.ErrInvalidVariableOffset + sszVarOffset1 := ssz.ReadOffset(buf[4:8]) // c.Attestation_2 + if sszVarOffset1 > size || sszVarOffset1 < sszVarOffset0 { + return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:sszVarOffset1] // c.Attestation_1 + sszSlice1 := buf[sszVarOffset1:] // c.Attestation_2 - // Field (1) 'Signature' - if cap(s.Signature) == 0 { - s.Signature = make([]byte, 0, len(buf[4:100])) + // Field 0: Attestation_1 + c.Attestation_1 = new(IndexedAttestation) + if err = c.Attestation_1.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Attestation_1: %w", err) } - 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 - } + // Field 1: Attestation_2 + c.Attestation_2 = new(IndexedAttestation) + if err = c.Attestation_2.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Attestation_2: %w", 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) +func (c *AttesterSlashing) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - size += s.Block.SizeSSZ() - - return + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// 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.Hasher) (err error) { +func (c *AttesterSlashing) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Block' - if err = s.Block.HashTreeRootWith(hh); err != nil { - return + // Field 0: Attestation_1 + if err := c.Attestation_1.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Attestation_1: %w", err) } - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 1: Attestation_2 + if err := c.Attestation_2.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Attestation_2: %w", err) } - hh.PutBytes(s.Signature) - hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the BeaconBlock object -func (b *BeaconBlock) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) +func (c *BeaconBlock) SizeSSZ() int { + size := 84 + if c.Body == nil { + c.Body = new(BeaconBlockBody) + } + size += c.Body.SizeSSZ() + return size } -// 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) +func (c *BeaconBlock) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (0) 'Slot' - dst = ssz.MarshalUint(dst, b.Slot) +func (c *BeaconBlock) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 84 - // Field (1) 'ProposerIndex' - dst = ssz.MarshalUint(dst, b.ProposerIndex) + // Field 0: Slot + if dst, err = c.Slot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Slot: %w", err) + } - // Field (2) 'ParentRoot' - if size := len(b.ParentRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentRoot", size, 32) - return + // Field 1: ProposerIndex + if dst, err = c.ProposerIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ProposerIndex: %w", err) } - dst = append(dst, b.ParentRoot...) - // Field (3) 'StateRoot' - if size := len(b.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return + // Field 2: ParentRoot + if len(c.ParentRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.StateRoot...) + dst = append(dst, c.ParentRoot...) - // Offset (4) 'Body' - dst = ssz.WriteOffset(dst, offset) - if b.Body == nil { - b.Body = new(BeaconBlockBody) + // Field 3: StateRoot + if len(c.StateRoot) != 32 { + return nil, ssz.ErrBytesLength } - offset += b.Body.SizeSSZ() + dst = append(dst, c.StateRoot...) - // Field (4) 'Body' - if dst, err = b.Body.MarshalSSZTo(dst); err != nil { - return + // Field 4: Body + if c.Body == nil { + c.Body = new(BeaconBlockBody) } + dst = ssz.WriteOffset(dst, offset) + offset += c.Body.SizeSSZ() - return + // Field 4: Body + if dst, err = c.Body.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Body: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the BeaconBlock object -func (b *BeaconBlock) UnmarshalSSZ(buf []byte) error { +func (c *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.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[0:8]) - - // Field (1) 'ProposerIndex' - b.ProposerIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](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]...) + sszSlice0 := buf[0:8] // c.Slot + sszSlice1 := buf[8:16] // c.ProposerIndex + sszSlice2 := buf[16:48] // c.ParentRoot + sszSlice3 := buf[48:80] // c.StateRoot - // Field (3) 'StateRoot' - if cap(b.StateRoot) == 0 { - b.StateRoot = make([]byte, 0, len(buf[48:80])) + sszVarOffset4 := ssz.ReadOffset(buf[80:84]) // c.Body + if sszVarOffset4 != 84 { + return ssz.ErrInvalidVariableOffset } - b.StateRoot = append(b.StateRoot, buf[48:80]...) - - // Offset (4) 'Body' - if o4 = ssz.ReadOffset(buf[80:84]); o4 > size { + if sszVarOffset4 > size { return ssz.ErrOffset } + sszSlice4 := buf[sszVarOffset4:] // c.Body - if o4 != 84 { - return ssz.ErrInvalidVariableOffset + // Field 0: Slot + if err = c.Slot.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Slot: %w", err) } - // Field (4) 'Body' - { - buf = tail[o4:] - if b.Body == nil { - b.Body = new(BeaconBlockBody) - } - if err = b.Body.UnmarshalSSZ(buf); err != nil { - return err - } + // Field 1: ProposerIndex + if err = c.ProposerIndex.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("ProposerIndex: %w", err) } - return err -} -// SizeSSZ returns the ssz encoded size in bytes for the BeaconBlock object -func (b *BeaconBlock) SizeSSZ() (size int) { - size = 84 + // Field 2: ParentRoot + c.ParentRoot = make([]byte, 0, 32) + c.ParentRoot = append(c.ParentRoot, sszSlice2...) - // Field (4) 'Body' - if b.Body == nil { - b.Body = new(BeaconBlockBody) - } - size += b.Body.SizeSSZ() + // Field 3: StateRoot + c.StateRoot = make([]byte, 0, 32) + c.StateRoot = append(c.StateRoot, sszSlice3...) - return + // Field 4: Body + c.Body = new(BeaconBlockBody) + if err = c.Body.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("Body: %w", err) + } + return err } -// HashTreeRoot ssz hashes the BeaconBlock object -func (b *BeaconBlock) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) +func (c *BeaconBlock) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the BeaconBlock object with a hasher -func (b *BeaconBlock) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *BeaconBlock) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Slot' - ssz.PutUint(hh, b.Slot) - - // Field (1) 'ProposerIndex' - ssz.PutUint(hh, b.ProposerIndex) - - // Field (2) 'ParentRoot' - if size := len(b.ParentRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentRoot", size, 32) - return + // Field 0: Slot + if err := c.Slot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Slot: %w", err) } - hh.PutBytes(b.ParentRoot) - - // Field (3) 'StateRoot' - if size := len(b.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return + // Field 1: ProposerIndex + if err := c.ProposerIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ProposerIndex: %w", err) } - hh.PutBytes(b.StateRoot) - - // Field (4) 'Body' - if err = b.Body.HashTreeRootWith(hh); err != nil { - return + // Field 2: ParentRoot + if len(c.ParentRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ParentRoot) + // Field 3: StateRoot + if len(c.StateRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.StateRoot) + // Field 4: Body + if err := c.Body.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Body: %w", err) } - hh.Merkleize(indx) - return + return nil +} + +func (c *BeaconBlockBody) SizeSSZ() int { + size := 220 + size += len(c.ProposerSlashings) * 416 + for _, o := range c.AttesterSlashings { + size += 4 + size += o.SizeSSZ() + } + for _, o := range c.Attestations { + size += 4 + size += o.SizeSSZ() + } + size += len(c.Deposits) * 1240 + size += len(c.VoluntaryExits) * 112 + return size } -// MarshalSSZ ssz marshals the BeaconBlockBody object -func (b *BeaconBlockBody) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) +func (c *BeaconBlockBody) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the BeaconBlockBody object to a target array -func (b *BeaconBlockBody) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(220) +func (c *BeaconBlockBody) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 220 - // Field (0) 'RandaoReveal' - if size := len(b.RandaoReveal); size != 96 { - err = ssz.ErrBytesLengthFn("--.RandaoReveal", size, 96) - return + // Field 0: RandaoReveal + if len(c.RandaoReveal) != 96 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.RandaoReveal...) + dst = append(dst, c.RandaoReveal...) - // Field (1) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(Eth1Data) + // Field 1: Eth1Data + if c.Eth1Data == nil { + c.Eth1Data = new(Eth1Data) } - if dst, err = b.Eth1Data.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.Eth1Data.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Eth1Data: %w", err) } - // Field (2) 'Graffiti' - if size := len(b.Graffiti); size != 32 { - err = ssz.ErrBytesLengthFn("--.Graffiti", size, 32) - return + // Field 2: Graffiti + if len(c.Graffiti) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.Graffiti...) + dst = append(dst, c.Graffiti...) - // Offset (3) 'ProposerSlashings' + // Field 3: ProposerSlashings dst = ssz.WriteOffset(dst, offset) - offset += len(b.ProposerSlashings) * 416 + offset += len(c.ProposerSlashings) * 416 - // Offset (4) 'AttesterSlashings' + // Field 4: AttesterSlashings dst = ssz.WriteOffset(dst, offset) - for ii := 0; ii < len(b.AttesterSlashings); ii++ { + for _, o := range c.AttesterSlashings { offset += 4 - offset += b.AttesterSlashings[ii].SizeSSZ() + offset += o.SizeSSZ() } - // Offset (5) 'Attestations' + // Field 5: Attestations dst = ssz.WriteOffset(dst, offset) - for ii := 0; ii < len(b.Attestations); ii++ { + for _, o := range c.Attestations { offset += 4 - offset += b.Attestations[ii].SizeSSZ() + offset += o.SizeSSZ() } - // Offset (6) 'Deposits' + // Field 6: Deposits dst = ssz.WriteOffset(dst, offset) - offset += len(b.Deposits) * 1240 + offset += len(c.Deposits) * 1240 - // Offset (7) 'VoluntaryExits' + // Field 7: VoluntaryExits dst = ssz.WriteOffset(dst, offset) - offset += len(b.VoluntaryExits) * 112 + offset += len(c.VoluntaryExits) * 112 - // Field (3) 'ProposerSlashings' - if size := len(b.ProposerSlashings); size > 16 { - err = ssz.ErrListTooBigFn("--.ProposerSlashings", size, 16) - return + // Field 3: ProposerSlashings + if len(c.ProposerSlashings) > 16 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.ProposerSlashings); ii++ { - if dst, err = b.ProposerSlashings[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.ProposerSlashings { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ProposerSlashings: %w", err) } } - // Field (4) 'AttesterSlashings' - if size := len(b.AttesterSlashings); size > 2 { - err = ssz.ErrListTooBigFn("--.AttesterSlashings", size, 2) - return + // Field 4: AttesterSlashings + if len(c.AttesterSlashings) > 2 { + return nil, ssz.ErrListTooBig } { - offset = 4 * len(b.AttesterSlashings) - for ii := 0; ii < len(b.AttesterSlashings); ii++ { + offset = 4 * len(c.AttesterSlashings) + for _, o := range c.AttesterSlashings { dst = ssz.WriteOffset(dst, offset) - offset += b.AttesterSlashings[ii].SizeSSZ() + offset += o.SizeSSZ() } } - for ii := 0; ii < len(b.AttesterSlashings); ii++ { - if dst, err = b.AttesterSlashings[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.AttesterSlashings { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("AttesterSlashings: %w", err) } } - // Field (5) 'Attestations' - if size := len(b.Attestations); size > 128 { - err = ssz.ErrListTooBigFn("--.Attestations", size, 128) - return + // Field 5: Attestations + if len(c.Attestations) > 128 { + return nil, ssz.ErrListTooBig } { - offset = 4 * len(b.Attestations) - for ii := 0; ii < len(b.Attestations); ii++ { + offset = 4 * len(c.Attestations) + for _, o := range c.Attestations { dst = ssz.WriteOffset(dst, offset) - offset += b.Attestations[ii].SizeSSZ() + offset += o.SizeSSZ() } } - for ii := 0; ii < len(b.Attestations); ii++ { - if dst, err = b.Attestations[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.Attestations { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Attestations: %w", err) } } - // Field (6) 'Deposits' - if size := len(b.Deposits); size > 16 { - err = ssz.ErrListTooBigFn("--.Deposits", size, 16) - return + // Field 6: Deposits + if len(c.Deposits) > 16 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.Deposits); ii++ { - if dst, err = b.Deposits[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.Deposits { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Deposits: %w", err) } } - // Field (7) 'VoluntaryExits' - if size := len(b.VoluntaryExits); size > 16 { - err = ssz.ErrListTooBigFn("--.VoluntaryExits", size, 16) - return + // Field 7: VoluntaryExits + if len(c.VoluntaryExits) > 16 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(b.VoluntaryExits); ii++ { - if dst, err = b.VoluntaryExits[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.VoluntaryExits { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("VoluntaryExits: %w", err) } } - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the BeaconBlockBody object -func (b *BeaconBlockBody) UnmarshalSSZ(buf []byte) error { +func (c *BeaconBlockBody) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size < 220 { return ssz.ErrSize } - tail := buf - var o3, o4, o5, o6, o7 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(Eth1Data) - } - if err = b.Eth1Data.UnmarshalSSZ(buf[96:168]); err != nil { - return err - } + sszSlice0 := buf[0:96] // c.RandaoReveal + sszSlice1 := buf[96:168] // c.Eth1Data + sszSlice2 := buf[168:200] // c.Graffiti - // Field (2) 'Graffiti' - if cap(b.Graffiti) == 0 { - b.Graffiti = make([]byte, 0, len(buf[168:200])) + sszVarOffset3 := ssz.ReadOffset(buf[200:204]) // c.ProposerSlashings + if sszVarOffset3 != 220 { + return ssz.ErrInvalidVariableOffset } - b.Graffiti = append(b.Graffiti, buf[168:200]...) - - // Offset (3) 'ProposerSlashings' - if o3 = ssz.ReadOffset(buf[200:204]); o3 > size { + if sszVarOffset3 > size { return ssz.ErrOffset } - - if o3 != 220 { - return ssz.ErrInvalidVariableOffset + sszVarOffset4 := ssz.ReadOffset(buf[204:208]) // c.AttesterSlashings + if sszVarOffset4 > size || sszVarOffset4 < sszVarOffset3 { + return ssz.ErrOffset } - - // Offset (4) 'AttesterSlashings' - if o4 = ssz.ReadOffset(buf[204:208]); o4 > size || o3 > o4 { + sszVarOffset5 := ssz.ReadOffset(buf[208:212]) // c.Attestations + if sszVarOffset5 > size || sszVarOffset5 < sszVarOffset4 { return ssz.ErrOffset } - - // Offset (5) 'Attestations' - if o5 = ssz.ReadOffset(buf[208:212]); o5 > size || o4 > o5 { + sszVarOffset6 := ssz.ReadOffset(buf[212:216]) // c.Deposits + if sszVarOffset6 > size || sszVarOffset6 < sszVarOffset5 { return ssz.ErrOffset } - - // Offset (6) 'Deposits' - if o6 = ssz.ReadOffset(buf[212:216]); o6 > size || o5 > o6 { + sszVarOffset7 := ssz.ReadOffset(buf[216:220]) // c.VoluntaryExits + if sszVarOffset7 > size || sszVarOffset7 < sszVarOffset6 { return ssz.ErrOffset } + sszSlice3 := buf[sszVarOffset3:sszVarOffset4] // c.ProposerSlashings + sszSlice4 := buf[sszVarOffset4:sszVarOffset5] // c.AttesterSlashings + sszSlice5 := buf[sszVarOffset5:sszVarOffset6] // c.Attestations + sszSlice6 := buf[sszVarOffset6:sszVarOffset7] // c.Deposits + sszSlice7 := buf[sszVarOffset7:] // c.VoluntaryExits - // Offset (7) 'VoluntaryExits' - if o7 = ssz.ReadOffset(buf[216:220]); o7 > size || o6 > o7 { - return ssz.ErrOffset + // Field 0: RandaoReveal + c.RandaoReveal = make([]byte, 0, 96) + c.RandaoReveal = append(c.RandaoReveal, sszSlice0...) + + // Field 1: Eth1Data + c.Eth1Data = new(Eth1Data) + if err = c.Eth1Data.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Eth1Data: %w", err) } - // Field (3) 'ProposerSlashings' + // Field 2: Graffiti + c.Graffiti = make([]byte, 0, 32) + c.Graffiti = append(c.Graffiti, sszSlice2...) + + // Field 3: ProposerSlashings { - buf = tail[o3:o4] - num, err := ssz.DivideInt2(len(buf), 416, 16) - if err != nil { - return err - } - b.ProposerSlashings = make([]*ProposerSlashing, num) - for ii := 0; ii < num; ii++ { - if b.ProposerSlashings[ii] == nil { - b.ProposerSlashings[ii] = new(ProposerSlashing) - } - if err = b.ProposerSlashings[ii].UnmarshalSSZ(buf[ii*416 : (ii+1)*416]); err != nil { - return err + if len(sszSlice3)%416 != 0 { + return fmt.Errorf("misaligned bytes: c.ProposerSlashings length is %d, which is not a multiple of 416: %w", len(sszSlice3), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice3) / 416 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.ProposerSlashings has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.ProposerSlashings = make([]*ProposerSlashing, numElem) + for i := 0; i < numElem; i++ { + var tmp *ProposerSlashing + tmp = new(ProposerSlashing) + tmpSlice := sszSlice3[i*416 : (1+i)*416] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("ProposerSlashings: %w", err) } + c.ProposerSlashings[i] = tmp } } - // Field (4) 'AttesterSlashings' + // Field 4: AttesterSlashings { - buf = tail[o4:o5] - num, err := ssz.DecodeDynamicLength(buf, 2) - 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) + // empty lists are zero length, so make sure there is room for an offset + // before attempting to unmarshal it + if len(sszSlice4) > 3 { + startOffset := ssz.ReadOffset(sszSlice4[0:4]) + if startOffset == 0 { + return fmt.Errorf("encountered invalid offset of 0 when decoding c.AttesterSlashings") + } + if startOffset%4 != 0 { + return fmt.Errorf("misaligned list bytes: when decoding c.AttesterSlashings, end-of-list offset is %d, which is not a multiple of 4 (offset size)", startOffset) } - if err = b.AttesterSlashings[indx].UnmarshalSSZ(buf); err != nil { - return err + listLen := startOffset / 4 + if listLen > 2 { + return fmt.Errorf("ssz-max exceeded: c.AttesterSlashings has %d elements, ssz-max is 2: %w", listLen, ssz.ErrListTooBig) } - return nil - }) - if err != nil { - return err + totalVarBytes := uint64(len(sszSlice4)) + if totalVarBytes < startOffset { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.AttesterSlashings") + } + c.AttesterSlashings = make([]*AttesterSlashing, listLen) + var tmpSlice []byte + for i := uint64(0); i < listLen; i++ { + var tmp *AttesterSlashing + tmp = new(AttesterSlashing) + endOffset := totalVarBytes + if i+1 != listLen { + endOffset = ssz.ReadOffset(sszSlice4[(i+1)*4 : (i+2)*4]) + if totalVarBytes < endOffset { + return fmt.Errorf("offset %d points past the end of buffer when decoding c.AttesterSlashings", endOffset) + } + } + if endOffset < startOffset { + return fmt.Errorf("offset %d is not greater than start offset %d when decoding c.AttesterSlashings", endOffset, startOffset) + } + tmpSlice = sszSlice4[startOffset:endOffset] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("AttesterSlashings: %w", err) + } + c.AttesterSlashings[i] = tmp + startOffset = endOffset + } + } else { + if len(sszSlice4) > 0 { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.AttesterSlashings") + } + c.AttesterSlashings = make([]*AttesterSlashing, 0) } } - // Field (5) 'Attestations' + // Field 5: Attestations { - buf = tail[o5:o6] - num, err := ssz.DecodeDynamicLength(buf, 128) - 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) + // empty lists are zero length, so make sure there is room for an offset + // before attempting to unmarshal it + if len(sszSlice5) > 3 { + startOffset := ssz.ReadOffset(sszSlice5[0:4]) + if startOffset == 0 { + return fmt.Errorf("encountered invalid offset of 0 when decoding c.Attestations") + } + if startOffset%4 != 0 { + return fmt.Errorf("misaligned list bytes: when decoding c.Attestations, end-of-list offset is %d, which is not a multiple of 4 (offset size)", startOffset) + } + listLen := startOffset / 4 + if listLen > 128 { + return fmt.Errorf("ssz-max exceeded: c.Attestations has %d elements, ssz-max is 128: %w", listLen, ssz.ErrListTooBig) + } + totalVarBytes := uint64(len(sszSlice5)) + if totalVarBytes < startOffset { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.Attestations") + } + c.Attestations = make([]*Attestation, listLen) + var tmpSlice []byte + for i := uint64(0); i < listLen; i++ { + var tmp *Attestation + tmp = new(Attestation) + endOffset := totalVarBytes + if i+1 != listLen { + endOffset = ssz.ReadOffset(sszSlice5[(i+1)*4 : (i+2)*4]) + if totalVarBytes < endOffset { + return fmt.Errorf("offset %d points past the end of buffer when decoding c.Attestations", endOffset) + } + } + if endOffset < startOffset { + return fmt.Errorf("offset %d is not greater than start offset %d when decoding c.Attestations", endOffset, startOffset) + } + tmpSlice = sszSlice5[startOffset:endOffset] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Attestations: %w", err) + } + c.Attestations[i] = tmp + startOffset = endOffset } - if err = b.Attestations[indx].UnmarshalSSZ(buf); err != nil { - return err + } else { + if len(sszSlice5) > 0 { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.Attestations") } - return nil - }) - if err != nil { - return err + c.Attestations = make([]*Attestation, 0) } } - // Field (6) 'Deposits' + // Field 6: Deposits { - buf = tail[o6:o7] - num, err := ssz.DivideInt2(len(buf), 1240, 16) - if err != nil { - return err - } - b.Deposits = make([]*Deposit, num) - for ii := 0; ii < num; ii++ { - if b.Deposits[ii] == nil { - b.Deposits[ii] = new(Deposit) - } - if err = b.Deposits[ii].UnmarshalSSZ(buf[ii*1240 : (ii+1)*1240]); err != nil { - return err + if len(sszSlice6)%1240 != 0 { + return fmt.Errorf("misaligned bytes: c.Deposits length is %d, which is not a multiple of 1240: %w", len(sszSlice6), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice6) / 1240 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.Deposits has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.Deposits = make([]*Deposit, numElem) + for i := 0; i < numElem; i++ { + var tmp *Deposit + tmp = new(Deposit) + tmpSlice := sszSlice6[i*1240 : (1+i)*1240] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Deposits: %w", err) } + c.Deposits[i] = tmp } } - // Field (7) 'VoluntaryExits' + // Field 7: VoluntaryExits { - buf = tail[o7:] - num, err := ssz.DivideInt2(len(buf), 112, 16) - if err != nil { - return err - } - b.VoluntaryExits = make([]*SignedVoluntaryExit, num) - for ii := 0; ii < num; ii++ { - if b.VoluntaryExits[ii] == nil { - b.VoluntaryExits[ii] = new(SignedVoluntaryExit) - } - if err = b.VoluntaryExits[ii].UnmarshalSSZ(buf[ii*112 : (ii+1)*112]); err != nil { - return err + if len(sszSlice7)%112 != 0 { + return fmt.Errorf("misaligned bytes: c.VoluntaryExits length is %d, which is not a multiple of 112: %w", len(sszSlice7), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice7) / 112 + if numElem > 16 { + return fmt.Errorf("ssz-max exceeded: c.VoluntaryExits has %d elements, ssz-max is 16: %w", numElem, ssz.ErrListTooBig) + } + c.VoluntaryExits = make([]*SignedVoluntaryExit, numElem) + for i := 0; i < numElem; i++ { + var tmp *SignedVoluntaryExit + tmp = new(SignedVoluntaryExit) + tmpSlice := sszSlice7[i*112 : (1+i)*112] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("VoluntaryExits: %w", err) } + c.VoluntaryExits[i] = tmp } } return err } -// SizeSSZ returns the ssz encoded size in bytes for the BeaconBlockBody object -func (b *BeaconBlockBody) SizeSSZ() (size int) { - size = 220 - - // 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() +func (c *BeaconBlockBody) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - - // Field (6) 'Deposits' - size += len(b.Deposits) * 1240 - - // Field (7) 'VoluntaryExits' - size += len(b.VoluntaryExits) * 112 - - return -} - -// HashTreeRoot ssz hashes the BeaconBlockBody object -func (b *BeaconBlockBody) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(b) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the BeaconBlockBody object with a hasher -func (b *BeaconBlockBody) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *BeaconBlockBody) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'RandaoReveal' - if size := len(b.RandaoReveal); size != 96 { - err = ssz.ErrBytesLengthFn("--.RandaoReveal", size, 96) - return + // Field 0: RandaoReveal + if len(c.RandaoReveal) != 96 { + return ssz.ErrBytesLength } - hh.PutBytes(b.RandaoReveal) - - // Field (1) 'Eth1Data' - if err = b.Eth1Data.HashTreeRootWith(hh); err != nil { - return + hh.PutBytes(c.RandaoReveal) + // Field 1: Eth1Data + if err := c.Eth1Data.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Eth1Data: %w", err) } - - // Field (2) 'Graffiti' - if size := len(b.Graffiti); size != 32 { - err = ssz.ErrBytesLengthFn("--.Graffiti", size, 32) - return + // Field 2: Graffiti + if len(c.Graffiti) != 32 { + return ssz.ErrBytesLength } - hh.PutBytes(b.Graffiti) - - // Field (3) 'ProposerSlashings' + hh.PutBytes(c.Graffiti) + // Field 3: ProposerSlashings { - subIndx := hh.Index() - num := uint64(len(b.ProposerSlashings)) - if num > 16 { - err = ssz.ErrIncorrectListSize - return + if len(c.ProposerSlashings) > 16 { + return ssz.ErrListTooBig } - for _, elem := range b.ProposerSlashings { - if err = elem.HashTreeRootWith(hh); err != nil { - return + subIndx := hh.Index() + for _, o := range c.ProposerSlashings { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ProposerSlashings: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.ProposerSlashings)), 16) } - - // Field (4) 'AttesterSlashings' + // Field 4: AttesterSlashings { - subIndx := hh.Index() - num := uint64(len(b.AttesterSlashings)) - if num > 2 { - err = ssz.ErrIncorrectListSize - return + if len(c.AttesterSlashings) > 2 { + return ssz.ErrListTooBig } - for _, elem := range b.AttesterSlashings { - if err = elem.HashTreeRootWith(hh); err != nil { - return + subIndx := hh.Index() + for _, o := range c.AttesterSlashings { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("AttesterSlashings: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 2) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.AttesterSlashings)), 2) } - - // Field (5) 'Attestations' + // Field 5: Attestations { - subIndx := hh.Index() - num := uint64(len(b.Attestations)) - if num > 128 { - err = ssz.ErrIncorrectListSize - return + if len(c.Attestations) > 128 { + return ssz.ErrListTooBig } - for _, elem := range b.Attestations { - if err = elem.HashTreeRootWith(hh); err != nil { - return + subIndx := hh.Index() + for _, o := range c.Attestations { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Attestations: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 128) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Attestations)), 128) } - - // Field (6) 'Deposits' + // Field 6: Deposits { - subIndx := hh.Index() - num := uint64(len(b.Deposits)) - if num > 16 { - err = ssz.ErrIncorrectListSize - return + if len(c.Deposits) > 16 { + return ssz.ErrListTooBig } - for _, elem := range b.Deposits { - if err = elem.HashTreeRootWith(hh); err != nil { - return + subIndx := hh.Index() + for _, o := range c.Deposits { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Deposits: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Deposits)), 16) } - - // Field (7) 'VoluntaryExits' + // Field 7: VoluntaryExits { - subIndx := hh.Index() - num := uint64(len(b.VoluntaryExits)) - if num > 16 { - err = ssz.ErrIncorrectListSize - return + if len(c.VoluntaryExits) > 16 { + return ssz.ErrListTooBig } - for _, elem := range b.VoluntaryExits { - if err = elem.HashTreeRootWith(hh); err != nil { - return + subIndx := hh.Index() + for _, o := range c.VoluntaryExits { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("VoluntaryExits: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 16) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.VoluntaryExits)), 16) } - hh.Merkleize(indx) - return + return nil +} + +func (c *BeaconBlockHeader) SizeSSZ() int { + size := 112 + + return size } -// MarshalSSZ ssz marshals the AttesterSlashing object -func (a *AttesterSlashing) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(a) +func (c *BeaconBlockHeader) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// 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) +func (c *BeaconBlockHeader) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Offset (0) 'Attestation_1' - dst = ssz.WriteOffset(dst, offset) - if a.Attestation_1 == nil { - a.Attestation_1 = new(IndexedAttestation) + // Field 0: Slot + if dst, err = c.Slot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Slot: %w", err) } - offset += a.Attestation_1.SizeSSZ() - // Offset (1) 'Attestation_2' - dst = ssz.WriteOffset(dst, offset) - if a.Attestation_2 == nil { - a.Attestation_2 = new(IndexedAttestation) + // Field 1: ProposerIndex + if dst, err = c.ProposerIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ProposerIndex: %w", err) } - offset += a.Attestation_2.SizeSSZ() - // Field (0) 'Attestation_1' - if dst, err = a.Attestation_1.MarshalSSZTo(dst); err != nil { - return + // Field 2: ParentRoot + if len(c.ParentRoot) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.ParentRoot...) - // Field (1) 'Attestation_2' - if dst, err = a.Attestation_2.MarshalSSZTo(dst); err != nil { - return + // Field 3: StateRoot + if len(c.StateRoot) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.StateRoot...) - return + // Field 4: BodyRoot + if len(c.BodyRoot) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.BodyRoot...) + + return dst, err } -// UnmarshalSSZ ssz unmarshals the AttesterSlashing object -func (a *AttesterSlashing) UnmarshalSSZ(buf []byte) error { +func (c *BeaconBlockHeader) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 8 { + if size != 112 { return ssz.ErrSize } - tail := buf - var o0, o1 uint64 + sszSlice0 := buf[0:8] // c.Slot + sszSlice1 := buf[8:16] // c.ProposerIndex + sszSlice2 := buf[16:48] // c.ParentRoot + sszSlice3 := buf[48:80] // c.StateRoot + sszSlice4 := buf[80:112] // c.BodyRoot - // Offset (0) 'Attestation_1' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset + // Field 0: Slot + if err = c.Slot.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Slot: %w", err) } - if o0 != 8 { - return ssz.ErrInvalidVariableOffset + // Field 1: ProposerIndex + if err = c.ProposerIndex.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("ProposerIndex: %w", err) } - // Offset (1) 'Attestation_2' - if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 { - return ssz.ErrOffset - } + // Field 2: ParentRoot + c.ParentRoot = make([]byte, 0, 32) + c.ParentRoot = append(c.ParentRoot, sszSlice2...) - // Field (0) 'Attestation_1' - { - buf = tail[o0:o1] - if a.Attestation_1 == nil { - a.Attestation_1 = new(IndexedAttestation) - } - if err = a.Attestation_1.UnmarshalSSZ(buf); err != nil { - return err - } - } + // Field 3: StateRoot + c.StateRoot = make([]byte, 0, 32) + c.StateRoot = append(c.StateRoot, sszSlice3...) - // Field (1) 'Attestation_2' - { - buf = tail[o1:] - if a.Attestation_2 == nil { - a.Attestation_2 = new(IndexedAttestation) - } - if err = a.Attestation_2.UnmarshalSSZ(buf); err != nil { - return err - } - } + // Field 4: BodyRoot + c.BodyRoot = make([]byte, 0, 32) + c.BodyRoot = append(c.BodyRoot, sszSlice4...) return err } -// SizeSSZ returns the ssz encoded size in bytes for the AttesterSlashing object -func (a *AttesterSlashing) SizeSSZ() (size int) { - size = 8 - - // Field (0) 'Attestation_1' - if a.Attestation_1 == nil { - a.Attestation_1 = new(IndexedAttestation) - } - size += a.Attestation_1.SizeSSZ() - - // Field (1) 'Attestation_2' - if a.Attestation_2 == nil { - a.Attestation_2 = new(IndexedAttestation) +func (c *BeaconBlockHeader) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - size += a.Attestation_2.SizeSSZ() - - return + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// 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.Hasher) (err error) { +func (c *BeaconBlockHeader) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Attestation_1' - if err = a.Attestation_1.HashTreeRootWith(hh); err != nil { - return + // Field 0: Slot + if err := c.Slot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Slot: %w", err) } - - // Field (1) 'Attestation_2' - if err = a.Attestation_2.HashTreeRootWith(hh); err != nil { - return + // Field 1: ProposerIndex + if err := c.ProposerIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ProposerIndex: %w", err) } - - hh.Merkleize(indx) - return -} - -// 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) - offset += len(i.AttestingIndices) * 8 - - // Field (1) 'Data' - if i.Data == nil { - i.Data = new(AttestationData) + // Field 2: ParentRoot + if len(c.ParentRoot) != 32 { + return ssz.ErrBytesLength } - if dst, err = i.Data.MarshalSSZTo(dst); err != nil { - return + hh.PutBytes(c.ParentRoot) + // Field 3: StateRoot + if len(c.StateRoot) != 32 { + return ssz.ErrBytesLength } - - // Field (2) 'Signature' - if size := len(i.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + hh.PutBytes(c.StateRoot) + // Field 4: BodyRoot + if len(c.BodyRoot) != 32 { + return ssz.ErrBytesLength } - dst = append(dst, i.Signature...) + hh.PutBytes(c.BodyRoot) + hh.Merkleize(indx) + return nil +} - // Field (0) 'AttestingIndices' - if size := len(i.AttestingIndices); size > 2048 { - err = ssz.ErrListTooBigFn("--.AttestingIndices", size, 2048) - return +func (c *BeaconState) SizeSSZ() int { + size := 2687377 + size += len(c.HistoricalRoots) * 32 + size += len(c.Eth1DataVotes) * 72 + size += len(c.Validators) * 121 + size += len(c.Balances) * 8 + for _, o := range c.PreviousEpochAttestations { + size += 4 + size += o.SizeSSZ() } - for ii := 0; ii < len(i.AttestingIndices); ii++ { - dst = ssz.MarshalUint(dst, i.AttestingIndices[ii]) + for _, o := range c.CurrentEpochAttestations { + size += 4 + size += o.SizeSSZ() } + return size +} - return +func (c *BeaconState) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// UnmarshalSSZ ssz unmarshals the IndexedAttestation object -func (i *IndexedAttestation) UnmarshalSSZ(buf []byte) error { +func (c *BeaconState) MarshalSSZTo(dst []byte) ([]byte, error) { var err error - size := uint64(len(buf)) - if size < 228 { - return ssz.ErrSize - } + offset := 2687377 - tail := buf - var o0 uint64 + // Field 0: GenesisTime + dst = binary.LittleEndian.AppendUint64(dst, c.GenesisTime) - // Offset (0) 'AttestingIndices' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset + // Field 1: GenesisValidatorsRoot + if len(c.GenesisValidatorsRoot) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.GenesisValidatorsRoot...) - if o0 != 228 { - return ssz.ErrInvalidVariableOffset + // Field 2: Slot + if dst, err = c.Slot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Slot: %w", err) } - // Field (1) 'Data' - if i.Data == nil { - i.Data = new(AttestationData) + // Field 3: Fork + if c.Fork == nil { + c.Fork = new(Fork) } - if err = i.Data.UnmarshalSSZ(buf[4:132]); err != nil { - return err + if dst, err = c.Fork.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Fork: %w", err) } - // Field (2) 'Signature' - if cap(i.Signature) == 0 { - i.Signature = make([]byte, 0, len(buf[132:228])) + // Field 4: LatestBlockHeader + if c.LatestBlockHeader == nil { + c.LatestBlockHeader = new(BeaconBlockHeader) + } + if dst, err = c.LatestBlockHeader.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("LatestBlockHeader: %w", err) } - i.Signature = append(i.Signature, buf[132:228]...) - // Field (0) 'AttestingIndices' - { - buf = tail[o0:] - num, err := ssz.DivideInt2(len(buf), 8, 2048) - if err != nil { - return err - } - i.AttestingIndices = ssz.ExtendUint(i.AttestingIndices, num) - for ii := 0; ii < num; ii++ { - i.AttestingIndices[ii] = ssz.UnmarshallUint[uint64](buf[ii*8 : (ii+1)*8]) + // Field 5: BlockRoots + if len(c.BlockRoots) != 8192 { + return nil, ssz.ErrBytesLength + } + for _, o := range c.BlockRoots { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, o...) } - 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.Hasher) (err error) { - indx := hh.Index() - // Field (0) 'AttestingIndices' - { - if size := len(i.AttestingIndices); size > 2048 { - err = ssz.ErrListTooBigFn("--.AttestingIndices", size, 2048) - return - } - subIndx := hh.Index() - for _, i := range i.AttestingIndices { - ssz.AppendUint(hh, i) + // Field 6: StateRoots + if len(c.StateRoots) != 8192 { + return nil, ssz.ErrBytesLength + } + for _, o := range c.StateRoots { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } - hh.FillUpTo32() - - numItems := uint64(len(i.AttestingIndices)) - hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(2048, numItems, 8)) + dst = append(dst, o...) } - // Field (1) 'Data' - if err = i.Data.HashTreeRootWith(hh); err != nil { - return - } + // Field 7: HistoricalRoots + dst = ssz.WriteOffset(dst, offset) + offset += len(c.HistoricalRoots) * 32 - // Field (2) 'Signature' - if size := len(i.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 8: Eth1Data + if c.Eth1Data == nil { + c.Eth1Data = new(Eth1Data) + } + if dst, err = c.Eth1Data.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Eth1Data: %w", err) } - hh.PutBytes(i.Signature) - - hh.Merkleize(indx) - return -} -// MarshalSSZ ssz marshals the BeaconBlockHeader object -func (b *BeaconBlockHeader) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) -} + // Field 9: Eth1DataVotes + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Eth1DataVotes) * 72 -// MarshalSSZTo ssz marshals the BeaconBlockHeader object to a target array -func (b *BeaconBlockHeader) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf + // Field 10: Eth1DepositIndex + dst = binary.LittleEndian.AppendUint64(dst, c.Eth1DepositIndex) - // Field (0) 'Slot' - dst = ssz.MarshalUint(dst, b.Slot) + // Field 11: Validators + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Validators) * 121 - // Field (1) 'ProposerIndex' - dst = ssz.MarshalUint(dst, b.ProposerIndex) + // Field 12: Balances + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Balances) * 8 - // Field (2) 'ParentRoot' - if size := len(b.ParentRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentRoot", size, 32) - return + // Field 13: RandaoMixes + if len(c.RandaoMixes) != 65536 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.ParentRoot...) - - // Field (3) 'StateRoot' - if size := len(b.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return + for _, o := range c.RandaoMixes { + if len(o) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) } - dst = append(dst, b.StateRoot...) - // Field (4) 'BodyRoot' - if size := len(b.BodyRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.BodyRoot", size, 32) - return + // Field 14: Slashings + if len(c.Slashings) != 8192 { + return nil, ssz.ErrBytesLength } - 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 + for _, o := range c.Slashings { + dst = binary.LittleEndian.AppendUint64(dst, o) } - // Field (0) 'Slot' - b.Slot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[0:8]) - - // Field (1) 'ProposerIndex' - b.ProposerIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[8:16]) - - // Field (2) 'ParentRoot' - if cap(b.ParentRoot) == 0 { - b.ParentRoot = make([]byte, 0, len(buf[16:48])) + // Field 15: PreviousEpochAttestations + dst = ssz.WriteOffset(dst, offset) + for _, o := range c.PreviousEpochAttestations { + offset += 4 + offset += o.SizeSSZ() } - 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])) + // Field 16: CurrentEpochAttestations + dst = ssz.WriteOffset(dst, offset) + for _, o := range c.CurrentEpochAttestations { + offset += 4 + offset += o.SizeSSZ() } - 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])) + // Field 17: JustificationBits + if len([]byte(c.JustificationBits)) != 1 { + return nil, ssz.ErrBytesLength } - 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 -} + dst = append(dst, []byte(c.JustificationBits)...) -// 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.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'Slot' - ssz.PutUint(hh, b.Slot) - - // Field (1) 'ProposerIndex' - ssz.PutUint(hh, b.ProposerIndex) - - // Field (2) 'ParentRoot' - if size := len(b.ParentRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentRoot", size, 32) - return + // Field 18: PreviousJustifiedCheckpoint + if c.PreviousJustifiedCheckpoint == nil { + c.PreviousJustifiedCheckpoint = new(Checkpoint) + } + if dst, err = c.PreviousJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("PreviousJustifiedCheckpoint: %w", err) } - hh.PutBytes(b.ParentRoot) - // Field (3) 'StateRoot' - if size := len(b.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return + // Field 19: CurrentJustifiedCheckpoint + if c.CurrentJustifiedCheckpoint == nil { + c.CurrentJustifiedCheckpoint = new(Checkpoint) + } + if dst, err = c.CurrentJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("CurrentJustifiedCheckpoint: %w", err) } - hh.PutBytes(b.StateRoot) - // Field (4) 'BodyRoot' - if size := len(b.BodyRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.BodyRoot", size, 32) - return + // Field 20: FinalizedCheckpoint + if c.FinalizedCheckpoint == nil { + c.FinalizedCheckpoint = new(Checkpoint) + } + if dst, err = c.FinalizedCheckpoint.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("FinalizedCheckpoint: %w", err) } - hh.PutBytes(b.BodyRoot) - hh.Merkleize(indx) - return -} + // Field 7: HistoricalRoots + if len(c.HistoricalRoots) > 16777216 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.HistoricalRoots { + if len(o) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) + } -// MarshalSSZ ssz marshals the SignedBeaconBlockHeader object -func (s *SignedBeaconBlockHeader) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) -} + // Field 9: Eth1DataVotes + if len(c.Eth1DataVotes) > 2048 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.Eth1DataVotes { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Eth1DataVotes: %w", err) + } + } -// MarshalSSZTo ssz marshals the SignedBeaconBlockHeader object to a target array -func (s *SignedBeaconBlockHeader) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf + // Field 11: Validators + if len(c.Validators) > 1099511627776 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.Validators { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Validators: %w", err) + } + } - // Field (0) 'Header' - if s.Header == nil { - s.Header = new(BeaconBlockHeader) + // Field 12: Balances + if len(c.Balances) > 1099511627776 { + return nil, ssz.ErrListTooBig } - if dst, err = s.Header.MarshalSSZTo(dst); err != nil { - return + for _, o := range c.Balances { + dst = binary.LittleEndian.AppendUint64(dst, o) } - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 15: PreviousEpochAttestations + if len(c.PreviousEpochAttestations) > 4096 { + return nil, ssz.ErrListTooBig + } + { + offset = 4 * len(c.PreviousEpochAttestations) + for _, o := range c.PreviousEpochAttestations { + dst = ssz.WriteOffset(dst, offset) + offset += o.SizeSSZ() + } + } + for _, o := range c.PreviousEpochAttestations { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("PreviousEpochAttestations: %w", err) + } } - dst = append(dst, s.Signature...) - return + // Field 16: CurrentEpochAttestations + if len(c.CurrentEpochAttestations) > 4096 { + return nil, ssz.ErrListTooBig + } + { + offset = 4 * len(c.CurrentEpochAttestations) + for _, o := range c.CurrentEpochAttestations { + dst = ssz.WriteOffset(dst, offset) + offset += o.SizeSSZ() + } + } + for _, o := range c.CurrentEpochAttestations { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("CurrentEpochAttestations: %w", err) + } + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the SignedBeaconBlockHeader object -func (s *SignedBeaconBlockHeader) UnmarshalSSZ(buf []byte) error { +func (c *BeaconState) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 208 { + if size < 2687377 { return ssz.ErrSize } - // Field (0) 'Header' - if s.Header == nil { - s.Header = new(BeaconBlockHeader) + sszSlice0 := buf[0:8] // c.GenesisTime + sszSlice1 := buf[8:40] // c.GenesisValidatorsRoot + sszSlice2 := buf[40:48] // c.Slot + sszSlice3 := buf[48:64] // c.Fork + sszSlice4 := buf[64:176] // c.LatestBlockHeader + sszSlice5 := buf[176:262320] // c.BlockRoots + sszSlice6 := buf[262320:524464] // c.StateRoots + sszSlice8 := buf[524468:524540] // c.Eth1Data + sszSlice10 := buf[524544:524552] // c.Eth1DepositIndex + sszSlice13 := buf[524560:2621712] // c.RandaoMixes + sszSlice14 := buf[2621712:2687248] // c.Slashings + sszSlice17 := buf[2687256:2687257] // c.JustificationBits + sszSlice18 := buf[2687257:2687297] // c.PreviousJustifiedCheckpoint + sszSlice19 := buf[2687297:2687337] // c.CurrentJustifiedCheckpoint + sszSlice20 := buf[2687337:2687377] // c.FinalizedCheckpoint + + sszVarOffset7 := ssz.ReadOffset(buf[524464:524468]) // c.HistoricalRoots + if sszVarOffset7 != 2687377 { + return ssz.ErrInvalidVariableOffset } - if err = s.Header.UnmarshalSSZ(buf[0:112]); err != nil { - return err + if sszVarOffset7 > size { + return ssz.ErrOffset } - - // Field (1) 'Signature' - if cap(s.Signature) == 0 { - s.Signature = make([]byte, 0, len(buf[112:208])) + sszVarOffset9 := ssz.ReadOffset(buf[524540:524544]) // c.Eth1DataVotes + if sszVarOffset9 > size || sszVarOffset9 < sszVarOffset7 { + return ssz.ErrOffset } - 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 -} + sszVarOffset11 := ssz.ReadOffset(buf[524552:524556]) // c.Validators + if sszVarOffset11 > size || sszVarOffset11 < sszVarOffset9 { + return ssz.ErrOffset + } + sszVarOffset12 := ssz.ReadOffset(buf[524556:524560]) // c.Balances + if sszVarOffset12 > size || sszVarOffset12 < sszVarOffset11 { + return ssz.ErrOffset + } + sszVarOffset15 := ssz.ReadOffset(buf[2687248:2687252]) // c.PreviousEpochAttestations + if sszVarOffset15 > size || sszVarOffset15 < sszVarOffset12 { + return ssz.ErrOffset + } + sszVarOffset16 := ssz.ReadOffset(buf[2687252:2687256]) // c.CurrentEpochAttestations + if sszVarOffset16 > size || sszVarOffset16 < sszVarOffset15 { + return ssz.ErrOffset + } + sszSlice7 := buf[sszVarOffset7:sszVarOffset9] // c.HistoricalRoots + sszSlice9 := buf[sszVarOffset9:sszVarOffset11] // c.Eth1DataVotes + sszSlice11 := buf[sszVarOffset11:sszVarOffset12] // c.Validators + sszSlice12 := buf[sszVarOffset12:sszVarOffset15] // c.Balances + sszSlice15 := buf[sszVarOffset15:sszVarOffset16] // c.PreviousEpochAttestations + sszSlice16 := buf[sszVarOffset16:] // c.CurrentEpochAttestations -// HashTreeRoot ssz hashes the SignedBeaconBlockHeader object -func (s *SignedBeaconBlockHeader) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) -} + // Field 0: GenesisTime + c.GenesisTime = binary.LittleEndian.Uint64(sszSlice0) -// HashTreeRootWith ssz hashes the SignedBeaconBlockHeader object with a hasher -func (s *SignedBeaconBlockHeader) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() + // Field 1: GenesisValidatorsRoot + c.GenesisValidatorsRoot = make([]byte, 0, 32) + c.GenesisValidatorsRoot = append(c.GenesisValidatorsRoot, sszSlice1...) - // Field (0) 'Header' - if err = s.Header.HashTreeRootWith(hh); err != nil { - return + // Field 2: Slot + if err = c.Slot.UnmarshalSSZ(sszSlice2); err != nil { + return fmt.Errorf("Slot: %w", err) } - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 3: Fork + c.Fork = new(Fork) + if err = c.Fork.UnmarshalSSZ(sszSlice3); err != nil { + return fmt.Errorf("Fork: %w", err) } - hh.PutBytes(s.Signature) - - hh.Merkleize(indx) - return -} -// MarshalSSZ ssz marshals the Eth1Data object -func (e *Eth1Data) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(e) -} + // Field 4: LatestBlockHeader + c.LatestBlockHeader = new(BeaconBlockHeader) + if err = c.LatestBlockHeader.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("LatestBlockHeader: %w", err) + } -// MarshalSSZTo ssz marshals the Eth1Data object to a target array -func (e *Eth1Data) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf + // Field 5: BlockRoots + { + c.BlockRoots = make([][]byte, 8192) + for i := 0; i < 8192; i++ { + var tmp []byte - // Field (0) 'DepositRoot' - if size := len(e.DepositRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.DepositRoot", size, 32) - return + tmpSlice := sszSlice5[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.BlockRoots[i] = tmp + } } - dst = append(dst, e.DepositRoot...) - // Field (1) 'DepositCount' - dst = ssz.MarshalUint(dst, e.DepositCount) + // Field 6: StateRoots + { + c.StateRoots = make([][]byte, 8192) + for i := 0; i < 8192; i++ { + var tmp []byte - // Field (2) 'BlockHash' - if size := len(e.BlockHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockHash", size, 32) - return + tmpSlice := sszSlice6[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.StateRoots[i] = tmp + } } - dst = append(dst, e.BlockHash...) - return -} + // Field 7: HistoricalRoots + { + if len(sszSlice7)%32 != 0 { + return fmt.Errorf("misaligned bytes: c.HistoricalRoots length is %d, which is not a multiple of 32: %w", len(sszSlice7), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice7) / 32 + if numElem > 16777216 { + return fmt.Errorf("ssz-max exceeded: c.HistoricalRoots has %d elements, ssz-max is 16777216: %w", numElem, ssz.ErrListTooBig) + } + c.HistoricalRoots = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte -// 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 + tmpSlice := sszSlice7[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.HistoricalRoots[i] = tmp + } } - // Field (0) 'DepositRoot' - if cap(e.DepositRoot) == 0 { - e.DepositRoot = make([]byte, 0, len(buf[0:32])) + // Field 8: Eth1Data + c.Eth1Data = new(Eth1Data) + if err = c.Eth1Data.UnmarshalSSZ(sszSlice8); err != nil { + return fmt.Errorf("Eth1Data: %w", err) } - e.DepositRoot = append(e.DepositRoot, buf[0:32]...) - - // Field (1) 'DepositCount' - e.DepositCount = ssz.UnmarshallUint[uint64](buf[32:40]) - // Field (2) 'BlockHash' - if cap(e.BlockHash) == 0 { - e.BlockHash = make([]byte, 0, len(buf[40:72])) + // Field 9: Eth1DataVotes + { + if len(sszSlice9)%72 != 0 { + return fmt.Errorf("misaligned bytes: c.Eth1DataVotes length is %d, which is not a multiple of 72: %w", len(sszSlice9), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice9) / 72 + if numElem > 2048 { + return fmt.Errorf("ssz-max exceeded: c.Eth1DataVotes has %d elements, ssz-max is 2048: %w", numElem, ssz.ErrListTooBig) + } + c.Eth1DataVotes = make([]*Eth1Data, numElem) + for i := 0; i < numElem; i++ { + var tmp *Eth1Data + tmp = new(Eth1Data) + tmpSlice := sszSlice9[i*72 : (1+i)*72] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Eth1DataVotes: %w", err) + } + c.Eth1DataVotes[i] = tmp + } } - 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.Hasher) (err error) { - indx := hh.Index() + // Field 10: Eth1DepositIndex + c.Eth1DepositIndex = binary.LittleEndian.Uint64(sszSlice10) - // Field (0) 'DepositRoot' - if size := len(e.DepositRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.DepositRoot", size, 32) - return + // Field 11: Validators + { + if len(sszSlice11)%121 != 0 { + return fmt.Errorf("misaligned bytes: c.Validators length is %d, which is not a multiple of 121: %w", len(sszSlice11), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice11) / 121 + if numElem > 1099511627776 { + return fmt.Errorf("ssz-max exceeded: c.Validators has %d elements, ssz-max is 1099511627776: %w", numElem, ssz.ErrListTooBig) + } + c.Validators = make([]*Validator, numElem) + for i := 0; i < numElem; i++ { + var tmp *Validator + tmp = new(Validator) + tmpSlice := sszSlice11[i*121 : (1+i)*121] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("Validators: %w", err) + } + c.Validators[i] = tmp + } } - hh.PutBytes(e.DepositRoot) - // Field (1) 'DepositCount' - ssz.PutUint(hh, e.DepositCount) + // Field 12: Balances + { + if len(sszSlice12)%8 != 0 { + return fmt.Errorf("misaligned bytes: c.Balances length is %d, which is not a multiple of 8: %w", len(sszSlice12), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice12) / 8 + if numElem > 1099511627776 { + return fmt.Errorf("ssz-max exceeded: c.Balances has %d elements, ssz-max is 1099511627776: %w", numElem, ssz.ErrListTooBig) + } + c.Balances = make([]uint64, numElem) + for i := 0; i < numElem; i++ { + var tmp uint64 - // Field (2) 'BlockHash' - if size := len(e.BlockHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockHash", size, 32) - return + tmpSlice := sszSlice12[i*8 : (1+i)*8] + tmp = binary.LittleEndian.Uint64(tmpSlice) + c.Balances[i] = tmp + } } - hh.PutBytes(e.BlockHash) - hh.Merkleize(indx) - return -} + // Field 13: RandaoMixes + { + c.RandaoMixes = make([][]byte, 65536) + for i := 0; i < 65536; i++ { + var tmp []byte -// MarshalSSZ ssz marshals the ProposerSlashing object -func (p *ProposerSlashing) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(p) -} + tmpSlice := sszSlice13[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.RandaoMixes[i] = tmp + } + } -// MarshalSSZTo ssz marshals the ProposerSlashing object to a target array -func (p *ProposerSlashing) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf + // Field 14: Slashings + { + c.Slashings = make([]uint64, 8192) + for i := 0; i < 8192; i++ { + var tmp uint64 - // Field (0) 'Header_1' - if p.Header_1 == nil { - p.Header_1 = new(SignedBeaconBlockHeader) - } - if dst, err = p.Header_1.MarshalSSZTo(dst); err != nil { - return + tmpSlice := sszSlice14[i*8 : (1+i)*8] + tmp = binary.LittleEndian.Uint64(tmpSlice) + c.Slashings[i] = tmp + } } - // Field (1) 'Header_2' - if p.Header_2 == nil { - p.Header_2 = new(SignedBeaconBlockHeader) + // Field 15: PreviousEpochAttestations + { + // empty lists are zero length, so make sure there is room for an offset + // before attempting to unmarshal it + if len(sszSlice15) > 3 { + startOffset := ssz.ReadOffset(sszSlice15[0:4]) + if startOffset == 0 { + return fmt.Errorf("encountered invalid offset of 0 when decoding c.PreviousEpochAttestations") + } + if startOffset%4 != 0 { + return fmt.Errorf("misaligned list bytes: when decoding c.PreviousEpochAttestations, end-of-list offset is %d, which is not a multiple of 4 (offset size)", startOffset) + } + listLen := startOffset / 4 + if listLen > 4096 { + return fmt.Errorf("ssz-max exceeded: c.PreviousEpochAttestations has %d elements, ssz-max is 4096: %w", listLen, ssz.ErrListTooBig) + } + totalVarBytes := uint64(len(sszSlice15)) + if totalVarBytes < startOffset { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.PreviousEpochAttestations") + } + c.PreviousEpochAttestations = make([]*PendingAttestation, listLen) + var tmpSlice []byte + for i := uint64(0); i < listLen; i++ { + var tmp *PendingAttestation + tmp = new(PendingAttestation) + endOffset := totalVarBytes + if i+1 != listLen { + endOffset = ssz.ReadOffset(sszSlice15[(i+1)*4 : (i+2)*4]) + if totalVarBytes < endOffset { + return fmt.Errorf("offset %d points past the end of buffer when decoding c.PreviousEpochAttestations", endOffset) + } + } + if endOffset < startOffset { + return fmt.Errorf("offset %d is not greater than start offset %d when decoding c.PreviousEpochAttestations", endOffset, startOffset) + } + tmpSlice = sszSlice15[startOffset:endOffset] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("PreviousEpochAttestations: %w", err) + } + c.PreviousEpochAttestations[i] = tmp + startOffset = endOffset + } + } else { + if len(sszSlice15) > 0 { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.PreviousEpochAttestations") + } + c.PreviousEpochAttestations = make([]*PendingAttestation, 0) + } } - if dst, err = p.Header_2.MarshalSSZTo(dst); err != nil { - return + + // Field 16: CurrentEpochAttestations + { + // empty lists are zero length, so make sure there is room for an offset + // before attempting to unmarshal it + if len(sszSlice16) > 3 { + startOffset := ssz.ReadOffset(sszSlice16[0:4]) + if startOffset == 0 { + return fmt.Errorf("encountered invalid offset of 0 when decoding c.CurrentEpochAttestations") + } + if startOffset%4 != 0 { + return fmt.Errorf("misaligned list bytes: when decoding c.CurrentEpochAttestations, end-of-list offset is %d, which is not a multiple of 4 (offset size)", startOffset) + } + listLen := startOffset / 4 + if listLen > 4096 { + return fmt.Errorf("ssz-max exceeded: c.CurrentEpochAttestations has %d elements, ssz-max is 4096: %w", listLen, ssz.ErrListTooBig) + } + totalVarBytes := uint64(len(sszSlice16)) + if totalVarBytes < startOffset { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.CurrentEpochAttestations") + } + c.CurrentEpochAttestations = make([]*PendingAttestation, listLen) + var tmpSlice []byte + for i := uint64(0); i < listLen; i++ { + var tmp *PendingAttestation + tmp = new(PendingAttestation) + endOffset := totalVarBytes + if i+1 != listLen { + endOffset = ssz.ReadOffset(sszSlice16[(i+1)*4 : (i+2)*4]) + if totalVarBytes < endOffset { + return fmt.Errorf("offset %d points past the end of buffer when decoding c.CurrentEpochAttestations", endOffset) + } + } + if endOffset < startOffset { + return fmt.Errorf("offset %d is not greater than start offset %d when decoding c.CurrentEpochAttestations", endOffset, startOffset) + } + tmpSlice = sszSlice16[startOffset:endOffset] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("CurrentEpochAttestations: %w", err) + } + c.CurrentEpochAttestations[i] = tmp + startOffset = endOffset + } + } else { + if len(sszSlice16) > 0 { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.CurrentEpochAttestations") + } + c.CurrentEpochAttestations = make([]*PendingAttestation, 0) + } } - return -} + // Field 17: JustificationBits + c.JustificationBits = make([]byte, 0, 1) + c.JustificationBits = append(c.JustificationBits, go_bitfield.Bitvector4(sszSlice17)...) -// 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 18: PreviousJustifiedCheckpoint + c.PreviousJustifiedCheckpoint = new(Checkpoint) + if err = c.PreviousJustifiedCheckpoint.UnmarshalSSZ(sszSlice18); err != nil { + return fmt.Errorf("PreviousJustifiedCheckpoint: %w", err) } - // Field (0) 'Header_1' - if p.Header_1 == nil { - p.Header_1 = new(SignedBeaconBlockHeader) - } - if err = p.Header_1.UnmarshalSSZ(buf[0:208]); err != nil { - return err + // Field 19: CurrentJustifiedCheckpoint + c.CurrentJustifiedCheckpoint = new(Checkpoint) + if err = c.CurrentJustifiedCheckpoint.UnmarshalSSZ(sszSlice19); err != nil { + return fmt.Errorf("CurrentJustifiedCheckpoint: %w", err) } - // Field (1) 'Header_2' - if p.Header_2 == nil { - p.Header_2 = new(SignedBeaconBlockHeader) + // Field 20: FinalizedCheckpoint + c.FinalizedCheckpoint = new(Checkpoint) + if err = c.FinalizedCheckpoint.UnmarshalSSZ(sszSlice20); err != nil { + return fmt.Errorf("FinalizedCheckpoint: %w", err) } - if err = p.Header_2.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) +func (c *BeaconState) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the ProposerSlashing object with a hasher -func (p *ProposerSlashing) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *BeaconState) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Header_1' - if err = p.Header_1.HashTreeRootWith(hh); err != nil { - return + // Field 0: GenesisTime + hh.PutUint64(c.GenesisTime) + // Field 1: GenesisValidatorsRoot + if len(c.GenesisValidatorsRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.GenesisValidatorsRoot) + // Field 2: Slot + if err := c.Slot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Slot: %w", err) + } + // Field 3: Fork + if err := c.Fork.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Fork: %w", err) + } + // Field 4: LatestBlockHeader + if err := c.LatestBlockHeader.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("LatestBlockHeader: %w", err) + } + // Field 5: BlockRoots + { + if len(c.BlockRoots) != 8192 { + return ssz.ErrVectorLength + } + subIndx := hh.Index() + for _, o := range c.BlockRoots { + if len(o) != 32 { + return ssz.ErrBytesLength + } + hh.Append(o) + } + hh.Merkleize(subIndx) } - - // Field (1) 'Header_2' - if err = p.Header_2.HashTreeRootWith(hh); err != nil { - return + // Field 6: StateRoots + { + if len(c.StateRoots) != 8192 { + return ssz.ErrVectorLength + } + subIndx := hh.Index() + for _, o := range c.StateRoots { + if len(o) != 32 { + return ssz.ErrBytesLength + } + hh.Append(o) + } + hh.Merkleize(subIndx) } - - hh.Merkleize(indx) - return -} - -// 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("--.Proof", size, 33) - return - } - for ii := 0; ii < 33; ii++ { - if size := len(d.Proof[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.Proof[ii]", size, 32) - return + // Field 7: HistoricalRoots + { + if len(c.HistoricalRoots) > 16777216 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.HistoricalRoots { + if len(o) != 32 { + return ssz.ErrBytesLength + } + hh.Append(o) } - dst = append(dst, d.Proof[ii]...) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.HistoricalRoots)), 16777216) } - - // Field (1) 'Data' - if d.Data == nil { - d.Data = new(Deposit_Data) + // Field 8: Eth1Data + if err := c.Eth1Data.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Eth1Data: %w", err) } - if dst, err = d.Data.MarshalSSZTo(dst); err != nil { - return + // Field 9: Eth1DataVotes + { + if len(c.Eth1DataVotes) > 2048 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.Eth1DataVotes { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Eth1DataVotes: %w", err) + } + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Eth1DataVotes)), 2048) } - - 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 10: Eth1DepositIndex + hh.PutUint64(c.Eth1DepositIndex) + // Field 11: Validators + { + if len(c.Validators) > 1099511627776 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.Validators { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Validators: %w", err) + } + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Validators)), 1099511627776) } - - // 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])) + // Field 12: Balances + { + if len(c.Balances) > 1099511627776 { + return ssz.ErrListTooBig } - d.Proof[ii] = append(d.Proof[ii], buf[0:1056][ii*32:(ii+1)*32]...) + subIndx := hh.Index() + for _, o := range c.Balances { + hh.AppendUint64(o) + } + hh.FillUpTo32() + numItems := uint64(len(c.Balances)) + hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(1099511627776, numItems, 8)) } - - // Field (1) 'Data' - if d.Data == nil { - d.Data = new(Deposit_Data) + // Field 13: RandaoMixes + { + if len(c.RandaoMixes) != 65536 { + return ssz.ErrVectorLength + } + subIndx := hh.Index() + for _, o := range c.RandaoMixes { + if len(o) != 32 { + return ssz.ErrBytesLength + } + hh.Append(o) + } + hh.Merkleize(subIndx) } - if err = d.Data.UnmarshalSSZ(buf[1056:1240]); err != nil { - return err + // Field 14: Slashings + { + if len(c.Slashings) != 8192 { + return ssz.ErrVectorLength + } + subIndx := hh.Index() + for _, o := range c.Slashings { + hh.AppendUint64(o) + } + hh.Merkleize(subIndx) } - - 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.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'Proof' + // Field 15: PreviousEpochAttestations { - if size := len(d.Proof); size != 33 { - err = ssz.ErrVectorLengthFn("--.Proof", size, 33) - return + if len(c.PreviousEpochAttestations) > 4096 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range d.Proof { - if len(i) != 32 { - err = ssz.ErrBytesLength - return + for _, o := range c.PreviousEpochAttestations { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("PreviousEpochAttestations: %w", err) } - hh.Append(i) } - hh.Merkleize(subIndx) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.PreviousEpochAttestations)), 4096) } - - // Field (1) 'Data' - if err = d.Data.HashTreeRootWith(hh); err != nil { - return + // Field 16: CurrentEpochAttestations + { + if len(c.CurrentEpochAttestations) > 4096 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.CurrentEpochAttestations { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("CurrentEpochAttestations: %w", err) + } + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.CurrentEpochAttestations)), 4096) + } + // Field 17: JustificationBits + if len([]byte(c.JustificationBits)) != 1 { + return ssz.ErrBytesLength + } + hh.PutBytes([]byte(c.JustificationBits)) + // Field 18: PreviousJustifiedCheckpoint + if err := c.PreviousJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("PreviousJustifiedCheckpoint: %w", err) + } + // Field 19: CurrentJustifiedCheckpoint + if err := c.CurrentJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("CurrentJustifiedCheckpoint: %w", err) + } + // Field 20: FinalizedCheckpoint + if err := c.FinalizedCheckpoint.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("FinalizedCheckpoint: %w", err) } - hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the SignedVoluntaryExit object -func (s *SignedVoluntaryExit) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) +func (c *Checkpoint) SizeSSZ() int { + size := 40 + + return size } -// MarshalSSZTo ssz marshals the SignedVoluntaryExit object to a target array -func (s *SignedVoluntaryExit) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *Checkpoint) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (0) 'Exit' - if s.Exit == nil { - s.Exit = new(VoluntaryExit) - } - if dst, err = s.Exit.MarshalSSZTo(dst); err != nil { - return +func (c *Checkpoint) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + + // Field 0: Epoch + if dst, err = c.Epoch.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Epoch: %w", err) } - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 1: Root + if len(c.Root) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, s.Signature...) + dst = append(dst, c.Root...) - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the SignedVoluntaryExit object -func (s *SignedVoluntaryExit) UnmarshalSSZ(buf []byte) error { +func (c *Checkpoint) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 112 { + if size != 40 { 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 - } + sszSlice0 := buf[0:8] // c.Epoch + sszSlice1 := buf[8:40] // c.Root - // Field (1) 'Signature' - if cap(s.Signature) == 0 { - s.Signature = make([]byte, 0, len(buf[16:112])) + // Field 0: Epoch + if err = c.Epoch.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Epoch: %w", err) } - s.Signature = append(s.Signature, buf[16:112]...) + // Field 1: Root + c.Root = make([]byte, 0, 32) + c.Root = append(c.Root, sszSlice1...) 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) +func (c *Checkpoint) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the SignedVoluntaryExit object with a hasher -func (s *SignedVoluntaryExit) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *Checkpoint) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Exit' - if err = s.Exit.HashTreeRootWith(hh); err != nil { - return + // Field 0: Epoch + if err := c.Epoch.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Epoch: %w", err) } - - // Field (1) 'Signature' - if size := len(s.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 1: Root + if len(c.Root) != 32 { + return ssz.ErrBytesLength } - hh.PutBytes(s.Signature) - + hh.PutBytes(c.Root) hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the VoluntaryExit object -func (v *VoluntaryExit) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(v) +func (c *Deposit) SizeSSZ() int { + size := 1240 + + return size } -// MarshalSSZTo ssz marshals the VoluntaryExit object to a target array -func (v *VoluntaryExit) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *Deposit) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (0) 'Epoch' - dst = ssz.MarshalUint(dst, v.Epoch) +func (c *Deposit) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (1) 'ValidatorIndex' - dst = ssz.MarshalUint(dst, v.ValidatorIndex) + // Field 0: Proof + if len(c.Proof) != 33 { + return nil, ssz.ErrBytesLength + } + for _, o := range c.Proof { + if len(o) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) + } + + // Field 1: Data + if c.Data == nil { + c.Data = new(Deposit_Data) + } + if dst, err = c.Data.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Data: %w", err) + } - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the VoluntaryExit object -func (v *VoluntaryExit) UnmarshalSSZ(buf []byte) error { +func (c *Deposit) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 16 { + if size != 1240 { return ssz.ErrSize } - // Field (0) 'Epoch' - v.Epoch = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Epoch](buf[0:8]) + sszSlice0 := buf[0:1056] // c.Proof + sszSlice1 := buf[1056:1240] // c.Data - // Field (1) 'ValidatorIndex' - v.ValidatorIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[8:16]) + // Field 0: Proof + { + c.Proof = make([][]byte, 33) + for i := 0; i < 33; i++ { + var tmp []byte - return err -} + tmpSlice := sszSlice0[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.Proof[i] = tmp + } + } -// SizeSSZ returns the ssz encoded size in bytes for the VoluntaryExit object -func (v *VoluntaryExit) SizeSSZ() (size int) { - size = 16 - return + // Field 1: Data + c.Data = new(Deposit_Data) + if err = c.Data.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Data: %w", err) + } + return err } -// HashTreeRoot ssz hashes the VoluntaryExit object -func (v *VoluntaryExit) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(v) +func (c *Deposit) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the VoluntaryExit object with a hasher -func (v *VoluntaryExit) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *Deposit) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() + // Field 0: Proof + { + if len(c.Proof) != 33 { + return ssz.ErrVectorLength + } + subIndx := hh.Index() + for _, o := range c.Proof { + if len(o) != 32 { + return ssz.ErrBytesLength + } + hh.Append(o) + } + hh.Merkleize(subIndx) + } + // Field 1: Data + if err := c.Data.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Data: %w", err) + } + hh.Merkleize(indx) + return nil +} - // Field (0) 'Epoch' - ssz.PutUint(hh, v.Epoch) - - // Field (1) 'ValidatorIndex' - ssz.PutUint(hh, v.ValidatorIndex) +func (c *Deposit_Data) SizeSSZ() int { + size := 184 - hh.Merkleize(indx) - return + return size } -// MarshalSSZ ssz marshals the Fork object -func (f *Fork) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(f) +func (c *Deposit_Data) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the Fork object to a target array -func (f *Fork) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *Deposit_Data) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (0) 'PreviousVersion' - if size := len(f.PreviousVersion); size != 4 { - err = ssz.ErrBytesLengthFn("--.PreviousVersion", size, 4) - return + // Field 0: PublicKey + if len(c.PublicKey) != 48 { + return nil, ssz.ErrBytesLength } - dst = append(dst, f.PreviousVersion...) + dst = append(dst, c.PublicKey...) - // Field (1) 'CurrentVersion' - if size := len(f.CurrentVersion); size != 4 { - err = ssz.ErrBytesLengthFn("--.CurrentVersion", size, 4) - return + // Field 1: WithdrawalCredentials + if len(c.WithdrawalCredentials) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, f.CurrentVersion...) + dst = append(dst, c.WithdrawalCredentials...) - // Field (2) 'Epoch' - dst = ssz.MarshalUint(dst, f.Epoch) + // Field 2: Amount + dst = binary.LittleEndian.AppendUint64(dst, c.Amount) - return + // Field 3: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.Signature...) + + return dst, err } -// UnmarshalSSZ ssz unmarshals the Fork object -func (f *Fork) UnmarshalSSZ(buf []byte) error { +func (c *Deposit_Data) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 16 { + if size != 184 { 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]...) + sszSlice0 := buf[0:48] // c.PublicKey + sszSlice1 := buf[48:80] // c.WithdrawalCredentials + sszSlice2 := buf[80:88] // c.Amount + sszSlice3 := buf[88:184] // c.Signature - // 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 0: PublicKey + c.PublicKey = make([]byte, 0, 48) + c.PublicKey = append(c.PublicKey, sszSlice0...) - // Field (2) 'Epoch' - f.Epoch = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Epoch](buf[8:16]) + // Field 1: WithdrawalCredentials + c.WithdrawalCredentials = make([]byte, 0, 32) + c.WithdrawalCredentials = append(c.WithdrawalCredentials, sszSlice1...) - return err -} + // Field 2: Amount + c.Amount = binary.LittleEndian.Uint64(sszSlice2) -// SizeSSZ returns the ssz encoded size in bytes for the Fork object -func (f *Fork) SizeSSZ() (size int) { - size = 16 - return + // Field 3: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice3...) + return err } -// HashTreeRoot ssz hashes the Fork object -func (f *Fork) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(f) +func (c *Deposit_Data) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the Fork object with a hasher -func (f *Fork) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *Deposit_Data) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() + // Field 0: PublicKey + if len(c.PublicKey) != 48 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.PublicKey) + // Field 1: WithdrawalCredentials + if len(c.WithdrawalCredentials) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.WithdrawalCredentials) + // Field 2: Amount + hh.PutUint64(c.Amount) + // Field 3: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Signature) + hh.Merkleize(indx) + return nil +} - // Field (0) 'PreviousVersion' - if size := len(f.PreviousVersion); size != 4 { - err = ssz.ErrBytesLengthFn("--.PreviousVersion", size, 4) - return - } - hh.PutBytes(f.PreviousVersion) - - // Field (1) 'CurrentVersion' - if size := len(f.CurrentVersion); size != 4 { - err = ssz.ErrBytesLengthFn("--.CurrentVersion", size, 4) - return - } - hh.PutBytes(f.CurrentVersion) - - // Field (2) 'Epoch' - ssz.PutUint(hh, f.Epoch) +func (c *DepositMessage) SizeSSZ() int { + size := 88 - hh.Merkleize(indx) - return + return size } -// MarshalSSZ ssz marshals the Validator object -func (v *Validator) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(v) +func (c *DepositMessage) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the Validator object to a target array -func (v *Validator) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *DepositMessage) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (0) 'PublicKey' - if size := len(v.PublicKey); size != 48 { - err = ssz.ErrBytesLengthFn("--.PublicKey", size, 48) - return + // Field 0: PublicKey + if len(c.PublicKey) != 48 { + return nil, ssz.ErrBytesLength } - dst = append(dst, v.PublicKey...) + dst = append(dst, c.PublicKey...) - // Field (1) 'WithdrawalCredentials' - if size := len(v.WithdrawalCredentials); size != 32 { - err = ssz.ErrBytesLengthFn("--.WithdrawalCredentials", size, 32) - return + // Field 1: WithdrawalCredentials + if len(c.WithdrawalCredentials) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, v.WithdrawalCredentials...) - - // Field (2) 'EffectiveBalance' - dst = ssz.MarshalUint(dst, v.EffectiveBalance) - - // Field (3) 'Slashed' - dst = ssz.MarshalBool(dst, v.Slashed) + dst = append(dst, c.WithdrawalCredentials...) - // Field (4) 'ActivationEligibilityEpoch' - dst = ssz.MarshalUint(dst, v.ActivationEligibilityEpoch) + // Field 2: Amount + dst = binary.LittleEndian.AppendUint64(dst, c.Amount) - // Field (5) 'ActivationEpoch' - dst = ssz.MarshalUint(dst, v.ActivationEpoch) - - // Field (6) 'ExitEpoch' - dst = ssz.MarshalUint(dst, v.ExitEpoch) - - // Field (7) 'WithdrawableEpoch' - dst = ssz.MarshalUint(dst, v.WithdrawableEpoch) - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the Validator object -func (v *Validator) UnmarshalSSZ(buf []byte) error { +func (c *DepositMessage) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 121 { + if size != 88 { return ssz.ErrSize } - // Field (0) 'PublicKey' - if cap(v.PublicKey) == 0 { - v.PublicKey = make([]byte, 0, len(buf[0:48])) - } - v.PublicKey = append(v.PublicKey, buf[0:48]...) + sszSlice0 := buf[0:48] // c.PublicKey + sszSlice1 := buf[48:80] // c.WithdrawalCredentials + sszSlice2 := buf[80:88] // c.Amount - // 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 0: PublicKey + c.PublicKey = make([]byte, 0, 48) + c.PublicKey = append(c.PublicKey, sszSlice0...) - // Field (2) 'EffectiveBalance' - v.EffectiveBalance = ssz.UnmarshallUint[uint64](buf[80:88]) - - // Field (3) 'Slashed' - v.Slashed, err = ssz.DecodeBool(buf[88:89]) - if err != nil { - return err - } - - // Field (4) 'ActivationEligibilityEpoch' - v.ActivationEligibilityEpoch = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Epoch](buf[89:97]) - - // Field (5) 'ActivationEpoch' - v.ActivationEpoch = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Epoch](buf[97:105]) - - // Field (6) 'ExitEpoch' - v.ExitEpoch = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Epoch](buf[105:113]) - - // Field (7) 'WithdrawableEpoch' - v.WithdrawableEpoch = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Epoch](buf[113:121]) + // Field 1: WithdrawalCredentials + c.WithdrawalCredentials = make([]byte, 0, 32) + c.WithdrawalCredentials = append(c.WithdrawalCredentials, sszSlice1...) + // Field 2: Amount + c.Amount = binary.LittleEndian.Uint64(sszSlice2) 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) +func (c *DepositMessage) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the Validator object with a hasher -func (v *Validator) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *DepositMessage) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() + // Field 0: PublicKey + if len(c.PublicKey) != 48 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.PublicKey) + // Field 1: WithdrawalCredentials + if len(c.WithdrawalCredentials) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.WithdrawalCredentials) + // Field 2: Amount + hh.PutUint64(c.Amount) + hh.Merkleize(indx) + return nil +} - // Field (0) 'PublicKey' - if size := len(v.PublicKey); size != 48 { - err = ssz.ErrBytesLengthFn("--.PublicKey", size, 48) - return - } - hh.PutBytes(v.PublicKey) - - // Field (1) 'WithdrawalCredentials' - if size := len(v.WithdrawalCredentials); size != 32 { - err = ssz.ErrBytesLengthFn("--.WithdrawalCredentials", size, 32) - return - } - hh.PutBytes(v.WithdrawalCredentials) - - // Field (2) 'EffectiveBalance' - ssz.PutUint(hh, v.EffectiveBalance) - - // Field (3) 'Slashed' - hh.PutBool(v.Slashed) - - // Field (4) 'ActivationEligibilityEpoch' - ssz.PutUint(hh, v.ActivationEligibilityEpoch) - - // Field (5) 'ActivationEpoch' - ssz.PutUint(hh, v.ActivationEpoch) - - // Field (6) 'ExitEpoch' - ssz.PutUint(hh, v.ExitEpoch) - - // Field (7) 'WithdrawableEpoch' - ssz.PutUint(hh, v.WithdrawableEpoch) +func (c *ENRForkID) SizeSSZ() int { + size := 16 - hh.Merkleize(indx) - return + return size } -// MarshalSSZ ssz marshals the Deposit_Data object -func (d *Deposit_Data) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(d) +func (c *ENRForkID) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the Deposit_Data object to a target array -func (d *Deposit_Data) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *ENRForkID) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (0) 'PublicKey' - if size := len(d.PublicKey); size != 48 { - err = ssz.ErrBytesLengthFn("--.PublicKey", size, 48) - return + // Field 0: CurrentForkDigest + if len(c.CurrentForkDigest) != 4 { + return nil, ssz.ErrBytesLength } - dst = append(dst, d.PublicKey...) + dst = append(dst, c.CurrentForkDigest...) - // Field (1) 'WithdrawalCredentials' - if size := len(d.WithdrawalCredentials); size != 32 { - err = ssz.ErrBytesLengthFn("--.WithdrawalCredentials", size, 32) - return + // Field 1: NextForkVersion + if len(c.NextForkVersion) != 4 { + return nil, ssz.ErrBytesLength } - dst = append(dst, d.WithdrawalCredentials...) + dst = append(dst, c.NextForkVersion...) - // Field (2) 'Amount' - dst = ssz.MarshalUint(dst, d.Amount) - - // Field (3) 'Signature' - if size := len(d.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + // Field 2: NextForkEpoch + if dst, err = c.NextForkEpoch.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("NextForkEpoch: %w", err) } - dst = append(dst, d.Signature...) - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the Deposit_Data object -func (d *Deposit_Data) UnmarshalSSZ(buf []byte) error { +func (c *ENRForkID) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 184 { + if size != 16 { 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]...) + sszSlice0 := buf[0:4] // c.CurrentForkDigest + sszSlice1 := buf[4:8] // c.NextForkVersion + sszSlice2 := buf[8:16] // c.NextForkEpoch - // 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 0: CurrentForkDigest + c.CurrentForkDigest = make([]byte, 0, 4) + c.CurrentForkDigest = append(c.CurrentForkDigest, sszSlice0...) - // Field (2) 'Amount' - d.Amount = ssz.UnmarshallUint[uint64](buf[80:88]) + // Field 1: NextForkVersion + c.NextForkVersion = make([]byte, 0, 4) + c.NextForkVersion = append(c.NextForkVersion, sszSlice1...) - // Field (3) 'Signature' - if cap(d.Signature) == 0 { - d.Signature = make([]byte, 0, len(buf[88:184])) + // Field 2: NextForkEpoch + if err = c.NextForkEpoch.UnmarshalSSZ(sszSlice2); err != nil { + return fmt.Errorf("NextForkEpoch: %w", err) } - d.Signature = append(d.Signature, buf[88:184]...) - return err } -// SizeSSZ returns the ssz encoded size in bytes for the Deposit_Data object -func (d *Deposit_Data) SizeSSZ() (size int) { - size = 184 - return -} - -// HashTreeRoot ssz hashes the Deposit_Data object -func (d *Deposit_Data) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(d) +func (c *ENRForkID) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the Deposit_Data object with a hasher -func (d *Deposit_Data) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *ENRForkID) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'PublicKey' - if size := len(d.PublicKey); size != 48 { - err = ssz.ErrBytesLengthFn("--.PublicKey", size, 48) - return + // Field 0: CurrentForkDigest + if len(c.CurrentForkDigest) != 4 { + return ssz.ErrBytesLength } - hh.PutBytes(d.PublicKey) - - // Field (1) 'WithdrawalCredentials' - if size := len(d.WithdrawalCredentials); size != 32 { - err = ssz.ErrBytesLengthFn("--.WithdrawalCredentials", size, 32) - return + hh.PutBytes(c.CurrentForkDigest) + // Field 1: NextForkVersion + if len(c.NextForkVersion) != 4 { + return ssz.ErrBytesLength } - hh.PutBytes(d.WithdrawalCredentials) - - // Field (2) 'Amount' - ssz.PutUint(hh, d.Amount) - - // Field (3) 'Signature' - if size := len(d.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return + hh.PutBytes(c.NextForkVersion) + // Field 2: NextForkEpoch + if err := c.NextForkEpoch.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("NextForkEpoch: %w", err) } - hh.PutBytes(d.Signature) - hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the BeaconState object -func (b *BeaconState) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(b) +func (c *Eth1Data) SizeSSZ() int { + size := 72 + + return size } -// MarshalSSZTo ssz marshals the BeaconState object to a target array -func (b *BeaconState) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(2687377) +func (c *Eth1Data) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (0) 'GenesisTime' - dst = ssz.MarshalUint(dst, b.GenesisTime) +func (c *Eth1Data) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (1) 'GenesisValidatorsRoot' - if size := len(b.GenesisValidatorsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.GenesisValidatorsRoot", size, 32) - return + // Field 0: DepositRoot + if len(c.DepositRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.GenesisValidatorsRoot...) + dst = append(dst, c.DepositRoot...) - // Field (2) 'Slot' - dst = ssz.MarshalUint(dst, b.Slot) + // Field 1: DepositCount + dst = binary.LittleEndian.AppendUint64(dst, c.DepositCount) - // Field (3) 'Fork' - if b.Fork == nil { - b.Fork = new(Fork) - } - if dst, err = b.Fork.MarshalSSZTo(dst); err != nil { - return + // Field 2: BlockHash + if len(c.BlockHash) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.BlockHash...) - // Field (4) 'LatestBlockHeader' - if b.LatestBlockHeader == nil { - b.LatestBlockHeader = new(BeaconBlockHeader) - } - if dst, err = b.LatestBlockHeader.MarshalSSZTo(dst); err != nil { - return - } + return dst, err +} - // Field (5) 'BlockRoots' - if size := len(b.BlockRoots); size != 8192 { - err = ssz.ErrVectorLengthFn("--.BlockRoots", size, 8192) - return - } - for ii := 0; ii < 8192; ii++ { - if size := len(b.BlockRoots[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockRoots[ii]", size, 32) - return - } - dst = append(dst, b.BlockRoots[ii]...) +func (c *Eth1Data) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 72 { + return ssz.ErrSize } - // Field (6) 'StateRoots' - if size := len(b.StateRoots); size != 8192 { - err = ssz.ErrVectorLengthFn("--.StateRoots", size, 8192) - return - } - for ii := 0; ii < 8192; ii++ { - if size := len(b.StateRoots[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoots[ii]", size, 32) - return - } - dst = append(dst, b.StateRoots[ii]...) - } + sszSlice0 := buf[0:32] // c.DepositRoot + sszSlice1 := buf[32:40] // c.DepositCount + sszSlice2 := buf[40:72] // c.BlockHash - // Offset (7) 'HistoricalRoots' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.HistoricalRoots) * 32 + // Field 0: DepositRoot + c.DepositRoot = make([]byte, 0, 32) + c.DepositRoot = append(c.DepositRoot, sszSlice0...) - // Field (8) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(Eth1Data) - } - if dst, err = b.Eth1Data.MarshalSSZTo(dst); err != nil { - return - } + // Field 1: DepositCount + c.DepositCount = binary.LittleEndian.Uint64(sszSlice1) - // Offset (9) 'Eth1DataVotes' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.Eth1DataVotes) * 72 + // Field 2: BlockHash + c.BlockHash = make([]byte, 0, 32) + c.BlockHash = append(c.BlockHash, sszSlice2...) + return err +} - // Field (10) 'Eth1DepositIndex' - dst = ssz.MarshalUint(dst, b.Eth1DepositIndex) +func (c *Eth1Data) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Offset (11) 'Validators' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.Validators) * 121 +func (c *Eth1Data) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: DepositRoot + if len(c.DepositRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.DepositRoot) + // Field 1: DepositCount + hh.PutUint64(c.DepositCount) + // Field 2: BlockHash + if len(c.BlockHash) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.BlockHash) + hh.Merkleize(indx) + return nil +} - // Offset (12) 'Balances' - dst = ssz.WriteOffset(dst, offset) - offset += len(b.Balances) * 8 +func (c *Fork) SizeSSZ() int { + size := 16 - // Field (13) 'RandaoMixes' - if size := len(b.RandaoMixes); size != 65536 { - err = ssz.ErrVectorLengthFn("--.RandaoMixes", size, 65536) - return - } - for ii := 0; ii < 65536; ii++ { - if size := len(b.RandaoMixes[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.RandaoMixes[ii]", size, 32) - return - } - dst = append(dst, b.RandaoMixes[ii]...) - } + return size +} - // Field (14) 'Slashings' - if size := len(b.Slashings); size != 8192 { - err = ssz.ErrVectorLengthFn("--.Slashings", size, 8192) - return - } - for ii := 0; ii < 8192; ii++ { - dst = ssz.MarshalUint(dst, b.Slashings[ii]) - } +func (c *Fork) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Offset (15) 'PreviousEpochAttestations' - dst = ssz.WriteOffset(dst, offset) - for ii := 0; ii < len(b.PreviousEpochAttestations); ii++ { - offset += 4 - offset += b.PreviousEpochAttestations[ii].SizeSSZ() - } +func (c *Fork) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Offset (16) 'CurrentEpochAttestations' - dst = ssz.WriteOffset(dst, offset) - for ii := 0; ii < len(b.CurrentEpochAttestations); ii++ { - offset += 4 - offset += b.CurrentEpochAttestations[ii].SizeSSZ() + // Field 0: PreviousVersion + if len(c.PreviousVersion) != 4 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.PreviousVersion...) - // Field (17) 'JustificationBits' - if size := len(b.JustificationBits); size != 1 { - err = ssz.ErrBytesLengthFn("--.JustificationBits", size, 1) - return + // Field 1: CurrentVersion + if len(c.CurrentVersion) != 4 { + return nil, ssz.ErrBytesLength } - dst = append(dst, b.JustificationBits...) + dst = append(dst, c.CurrentVersion...) - // Field (18) 'PreviousJustifiedCheckpoint' - if b.PreviousJustifiedCheckpoint == nil { - b.PreviousJustifiedCheckpoint = new(Checkpoint) - } - if dst, err = b.PreviousJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { - return + // Field 2: Epoch + if dst, err = c.Epoch.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Epoch: %w", err) } - // Field (19) 'CurrentJustifiedCheckpoint' - if b.CurrentJustifiedCheckpoint == nil { - b.CurrentJustifiedCheckpoint = new(Checkpoint) - } - if dst, err = b.CurrentJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { - return - } + return dst, err +} - // Field (20) 'FinalizedCheckpoint' - if b.FinalizedCheckpoint == nil { - b.FinalizedCheckpoint = new(Checkpoint) - } - if dst, err = b.FinalizedCheckpoint.MarshalSSZTo(dst); err != nil { - return +func (c *Fork) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 16 { + return ssz.ErrSize } - // Field (7) 'HistoricalRoots' - if size := len(b.HistoricalRoots); size > 16777216 { - err = ssz.ErrListTooBigFn("--.HistoricalRoots", size, 16777216) - return - } - for ii := 0; ii < len(b.HistoricalRoots); ii++ { - if size := len(b.HistoricalRoots[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.HistoricalRoots[ii]", size, 32) - return - } - dst = append(dst, b.HistoricalRoots[ii]...) - } + sszSlice0 := buf[0:4] // c.PreviousVersion + sszSlice1 := buf[4:8] // c.CurrentVersion + sszSlice2 := buf[8:16] // c.Epoch - // Field (9) 'Eth1DataVotes' - if size := len(b.Eth1DataVotes); size > 2048 { - err = ssz.ErrListTooBigFn("--.Eth1DataVotes", size, 2048) - return - } - for ii := 0; ii < len(b.Eth1DataVotes); ii++ { - if dst, err = b.Eth1DataVotes[ii].MarshalSSZTo(dst); err != nil { - return - } - } + // Field 0: PreviousVersion + c.PreviousVersion = make([]byte, 0, 4) + c.PreviousVersion = append(c.PreviousVersion, sszSlice0...) - // Field (11) 'Validators' - if size := len(b.Validators); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.Validators", size, 1099511627776) - return - } - for ii := 0; ii < len(b.Validators); ii++ { - if dst, err = b.Validators[ii].MarshalSSZTo(dst); err != nil { - return - } - } + // Field 1: CurrentVersion + c.CurrentVersion = make([]byte, 0, 4) + c.CurrentVersion = append(c.CurrentVersion, sszSlice1...) - // Field (12) 'Balances' - if size := len(b.Balances); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.Balances", size, 1099511627776) - return - } - for ii := 0; ii < len(b.Balances); ii++ { - dst = ssz.MarshalUint(dst, b.Balances[ii]) + // Field 2: Epoch + if err = c.Epoch.UnmarshalSSZ(sszSlice2); err != nil { + return fmt.Errorf("Epoch: %w", err) } + return err +} - // Field (15) 'PreviousEpochAttestations' - if size := len(b.PreviousEpochAttestations); size > 4096 { - err = ssz.ErrListTooBigFn("--.PreviousEpochAttestations", size, 4096) - return - } - { - offset = 4 * len(b.PreviousEpochAttestations) - for ii := 0; ii < len(b.PreviousEpochAttestations); ii++ { - dst = ssz.WriteOffset(dst, offset) - offset += b.PreviousEpochAttestations[ii].SizeSSZ() - } - } - for ii := 0; ii < len(b.PreviousEpochAttestations); ii++ { - if dst, err = b.PreviousEpochAttestations[ii].MarshalSSZTo(dst); err != nil { - return - } +func (c *Fork) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (16) 'CurrentEpochAttestations' - if size := len(b.CurrentEpochAttestations); size > 4096 { - err = ssz.ErrListTooBigFn("--.CurrentEpochAttestations", size, 4096) - return +func (c *Fork) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: PreviousVersion + if len(c.PreviousVersion) != 4 { + return ssz.ErrBytesLength } - { - offset = 4 * len(b.CurrentEpochAttestations) - for ii := 0; ii < len(b.CurrentEpochAttestations); ii++ { - dst = ssz.WriteOffset(dst, offset) - offset += b.CurrentEpochAttestations[ii].SizeSSZ() - } + hh.PutBytes(c.PreviousVersion) + // Field 1: CurrentVersion + if len(c.CurrentVersion) != 4 { + return ssz.ErrBytesLength } - for ii := 0; ii < len(b.CurrentEpochAttestations); ii++ { - if dst, err = b.CurrentEpochAttestations[ii].MarshalSSZTo(dst); err != nil { - return - } + hh.PutBytes(c.CurrentVersion) + // Field 2: Epoch + if err := c.Epoch.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Epoch: %w", err) } - - return + hh.Merkleize(indx) + return nil } -// UnmarshalSSZ ssz unmarshals the BeaconState object -func (b *BeaconState) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 2687377 { - return ssz.ErrSize - } - - tail := buf - var o7, o9, o11, o12, o15, o16 uint64 - - // Field (0) 'GenesisTime' - b.GenesisTime = ssz.UnmarshallUint[uint64](buf[0:8]) +func (c *ForkData) SizeSSZ() int { + size := 36 - // 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.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[40:48]) + return size +} - // Field (3) 'Fork' - if b.Fork == nil { - b.Fork = new(Fork) - } - if err = b.Fork.UnmarshalSSZ(buf[48:64]); err != nil { - return err - } +func (c *ForkData) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (4) 'LatestBlockHeader' - if b.LatestBlockHeader == nil { - b.LatestBlockHeader = new(BeaconBlockHeader) - } - if err = b.LatestBlockHeader.UnmarshalSSZ(buf[64:176]); err != nil { - return err - } +func (c *ForkData) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (5) 'BlockRoots' - b.BlockRoots = make([][]byte, 8192) - for ii := 0; ii < 8192; ii++ { - if cap(b.BlockRoots[ii]) == 0 { - b.BlockRoots[ii] = make([]byte, 0, len(buf[176:262320][ii*32:(ii+1)*32])) - } - b.BlockRoots[ii] = append(b.BlockRoots[ii], buf[176:262320][ii*32:(ii+1)*32]...) + // Field 0: CurrentVersion + if len(c.CurrentVersion) != 4 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.CurrentVersion...) - // Field (6) 'StateRoots' - b.StateRoots = make([][]byte, 8192) - for ii := 0; ii < 8192; ii++ { - if cap(b.StateRoots[ii]) == 0 { - b.StateRoots[ii] = make([]byte, 0, len(buf[262320:524464][ii*32:(ii+1)*32])) - } - b.StateRoots[ii] = append(b.StateRoots[ii], buf[262320:524464][ii*32:(ii+1)*32]...) + // Field 1: GenesisValidatorsRoot + if len(c.GenesisValidatorsRoot) != 32 { + return nil, ssz.ErrBytesLength } + dst = append(dst, c.GenesisValidatorsRoot...) - // Offset (7) 'HistoricalRoots' - if o7 = ssz.ReadOffset(buf[524464:524468]); o7 > size { - return ssz.ErrOffset - } + return dst, err +} - if o7 != 2687377 { - return ssz.ErrInvalidVariableOffset +func (c *ForkData) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 36 { + return ssz.ErrSize } - // Field (8) 'Eth1Data' - if b.Eth1Data == nil { - b.Eth1Data = new(Eth1Data) - } - if err = b.Eth1Data.UnmarshalSSZ(buf[524468:524540]); err != nil { - return err - } + sszSlice0 := buf[0:4] // c.CurrentVersion + sszSlice1 := buf[4:36] // c.GenesisValidatorsRoot - // Offset (9) 'Eth1DataVotes' - if o9 = ssz.ReadOffset(buf[524540:524544]); o9 > size || o7 > o9 { - return ssz.ErrOffset - } + // Field 0: CurrentVersion + c.CurrentVersion = make([]byte, 0, 4) + c.CurrentVersion = append(c.CurrentVersion, sszSlice0...) - // Field (10) 'Eth1DepositIndex' - b.Eth1DepositIndex = ssz.UnmarshallUint[uint64](buf[524544:524552]) + // Field 1: GenesisValidatorsRoot + c.GenesisValidatorsRoot = make([]byte, 0, 32) + c.GenesisValidatorsRoot = append(c.GenesisValidatorsRoot, sszSlice1...) + return err +} - // Offset (11) 'Validators' - if o11 = ssz.ReadOffset(buf[524552:524556]); o11 > size || o9 > o11 { - return ssz.ErrOffset +func (c *ForkData) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Offset (12) 'Balances' - if o12 = ssz.ReadOffset(buf[524556:524560]); o12 > size || o11 > o12 { - return ssz.ErrOffset +func (c *ForkData) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: CurrentVersion + if len(c.CurrentVersion) != 4 { + return ssz.ErrBytesLength } - - // 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]...) + hh.PutBytes(c.CurrentVersion) + // Field 1: GenesisValidatorsRoot + if len(c.GenesisValidatorsRoot) != 32 { + return ssz.ErrBytesLength } + hh.PutBytes(c.GenesisValidatorsRoot) + hh.Merkleize(indx) + return nil +} - // Field (14) 'Slashings' - b.Slashings = ssz.ExtendUint(b.Slashings, 8192) - for ii := 0; ii < 8192; ii++ { - b.Slashings[ii] = ssz.UnmarshallUint[uint64](buf[2621712:2687248][ii*8 : (ii+1)*8]) - } +func (c *HistoricalBatch) SizeSSZ() int { + size := 524288 - // Offset (15) 'PreviousEpochAttestations' - if o15 = ssz.ReadOffset(buf[2687248:2687252]); o15 > size || o12 > o15 { - return ssz.ErrOffset - } + return size +} - // Offset (16) 'CurrentEpochAttestations' - if o16 = ssz.ReadOffset(buf[2687252:2687256]); o16 > size || o15 > o16 { - return ssz.ErrOffset - } +func (c *HistoricalBatch) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (17) 'JustificationBits' - if cap(b.JustificationBits) == 0 { - b.JustificationBits = make([]byte, 0, len(buf[2687256:2687257])) - } - b.JustificationBits = append(b.JustificationBits, buf[2687256:2687257]...) +func (c *HistoricalBatch) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (18) 'PreviousJustifiedCheckpoint' - if b.PreviousJustifiedCheckpoint == nil { - b.PreviousJustifiedCheckpoint = new(Checkpoint) + // Field 0: BlockRoots + if len(c.BlockRoots) != 8192 { + return nil, ssz.ErrBytesLength } - if err = b.PreviousJustifiedCheckpoint.UnmarshalSSZ(buf[2687257:2687297]); err != nil { - return err + for _, o := range c.BlockRoots { + if len(o) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) } - // Field (19) 'CurrentJustifiedCheckpoint' - if b.CurrentJustifiedCheckpoint == nil { - b.CurrentJustifiedCheckpoint = new(Checkpoint) + // Field 1: StateRoots + if len(c.StateRoots) != 8192 { + return nil, ssz.ErrBytesLength } - if err = b.CurrentJustifiedCheckpoint.UnmarshalSSZ(buf[2687297:2687337]); err != nil { - return err + for _, o := range c.StateRoots { + if len(o) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) } - // Field (20) 'FinalizedCheckpoint' - if b.FinalizedCheckpoint == nil { - b.FinalizedCheckpoint = new(Checkpoint) - } - if err = b.FinalizedCheckpoint.UnmarshalSSZ(buf[2687337:2687377]); err != nil { - return err - } + return dst, err +} - // 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]...) - } +func (c *HistoricalBatch) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 524288 { + return ssz.ErrSize } - // Field (9) 'Eth1DataVotes' - { - buf = tail[o9:o11] - num, err := ssz.DivideInt2(len(buf), 72, 2048) - if err != nil { - return err - } - b.Eth1DataVotes = make([]*Eth1Data, num) - for ii := 0; ii < num; ii++ { - if b.Eth1DataVotes[ii] == nil { - b.Eth1DataVotes[ii] = new(Eth1Data) - } - if err = b.Eth1DataVotes[ii].UnmarshalSSZ(buf[ii*72 : (ii+1)*72]); err != nil { - return err - } - } - } + sszSlice0 := buf[0:262144] // c.BlockRoots + sszSlice1 := buf[262144:524288] // c.StateRoots - // Field (11) 'Validators' + // Field 0: BlockRoots { - buf = tail[o11:o12] - num, err := ssz.DivideInt2(len(buf), 121, 1099511627776) - if err != nil { - return err - } - b.Validators = make([]*Validator, num) - for ii := 0; ii < num; ii++ { - if b.Validators[ii] == nil { - b.Validators[ii] = new(Validator) - } - if err = b.Validators[ii].UnmarshalSSZ(buf[ii*121 : (ii+1)*121]); err != nil { - return err - } - } - } + c.BlockRoots = make([][]byte, 8192) + for i := 0; i < 8192; i++ { + var tmp []byte - // Field (12) 'Balances' - { - buf = tail[o12:o15] - num, err := ssz.DivideInt2(len(buf), 8, 1099511627776) - if err != nil { - return err - } - b.Balances = ssz.ExtendUint(b.Balances, num) - for ii := 0; ii < num; ii++ { - b.Balances[ii] = ssz.UnmarshallUint[uint64](buf[ii*8 : (ii+1)*8]) + tmpSlice := sszSlice0[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.BlockRoots[i] = tmp } } - // Field (15) 'PreviousEpochAttestations' + // Field 1: StateRoots { - buf = tail[o15:o16] - num, err := ssz.DecodeDynamicLength(buf, 4096) - if err != nil { - return err - } - b.PreviousEpochAttestations = make([]*PendingAttestation, num) - err = ssz.UnmarshalDynamic(buf, num, func(indx int, buf []byte) (err error) { - if b.PreviousEpochAttestations[indx] == nil { - b.PreviousEpochAttestations[indx] = new(PendingAttestation) - } - if err = b.PreviousEpochAttestations[indx].UnmarshalSSZ(buf); err != nil { - return err - } - return nil - }) - if err != nil { - return err - } - } + c.StateRoots = make([][]byte, 8192) + for i := 0; i < 8192; i++ { + var tmp []byte - // Field (16) 'CurrentEpochAttestations' - { - buf = tail[o16:] - num, err := ssz.DecodeDynamicLength(buf, 4096) - if err != nil { - return err - } - b.CurrentEpochAttestations = make([]*PendingAttestation, num) - err = ssz.UnmarshalDynamic(buf, num, func(indx int, buf []byte) (err error) { - if b.CurrentEpochAttestations[indx] == nil { - b.CurrentEpochAttestations[indx] = new(PendingAttestation) - } - if err = b.CurrentEpochAttestations[indx].UnmarshalSSZ(buf); err != nil { - return err - } - return nil - }) - if err != nil { - return err + tmpSlice := sszSlice1[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.StateRoots[i] = tmp } } return err } -// SizeSSZ returns the ssz encoded size in bytes for the BeaconState object -func (b *BeaconState) SizeSSZ() (size int) { - size = 2687377 - - // 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) 'PreviousEpochAttestations' - for ii := 0; ii < len(b.PreviousEpochAttestations); ii++ { - size += 4 - size += b.PreviousEpochAttestations[ii].SizeSSZ() +func (c *HistoricalBatch) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - - // Field (16) 'CurrentEpochAttestations' - for ii := 0; ii < len(b.CurrentEpochAttestations); ii++ { - size += 4 - size += b.CurrentEpochAttestations[ii].SizeSSZ() - } - - return + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// 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.Hasher) (err error) { +func (c *HistoricalBatch) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'GenesisTime' - ssz.PutUint(hh, b.GenesisTime) - - // Field (1) 'GenesisValidatorsRoot' - if size := len(b.GenesisValidatorsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.GenesisValidatorsRoot", size, 32) - return - } - hh.PutBytes(b.GenesisValidatorsRoot) - - // Field (2) 'Slot' - ssz.PutUint(hh, b.Slot) - - // Field (3) 'Fork' - if err = b.Fork.HashTreeRootWith(hh); err != nil { - return - } - - // Field (4) 'LatestBlockHeader' - if err = b.LatestBlockHeader.HashTreeRootWith(hh); err != nil { - return - } - - // Field (5) 'BlockRoots' + // Field 0: BlockRoots { - if size := len(b.BlockRoots); size != 8192 { - err = ssz.ErrVectorLengthFn("--.BlockRoots", size, 8192) - return + if len(c.BlockRoots) != 8192 { + return ssz.ErrVectorLength } subIndx := hh.Index() - for _, i := range b.BlockRoots { - if len(i) != 32 { - err = ssz.ErrBytesLength - return + for _, o := range c.BlockRoots { + if len(o) != 32 { + return ssz.ErrBytesLength } - hh.Append(i) + hh.Append(o) } hh.Merkleize(subIndx) } - - // Field (6) 'StateRoots' + // Field 1: StateRoots { - if size := len(b.StateRoots); size != 8192 { - err = ssz.ErrVectorLengthFn("--.StateRoots", size, 8192) - return + if len(c.StateRoots) != 8192 { + return ssz.ErrVectorLength } subIndx := hh.Index() - for _, i := range b.StateRoots { - if len(i) != 32 { - err = ssz.ErrBytesLength - return + for _, o := range c.StateRoots { + if len(o) != 32 { + return ssz.ErrBytesLength } - hh.Append(i) + hh.Append(o) } hh.Merkleize(subIndx) } + hh.Merkleize(indx) + return nil +} - // Field (7) 'HistoricalRoots' - { - if size := len(b.HistoricalRoots); size > 16777216 { - err = ssz.ErrListTooBigFn("--.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) - } +func (c *IndexedAttestation) SizeSSZ() int { + size := 228 + size += len(c.AttestingIndices) * 8 + return size +} - // Field (8) 'Eth1Data' - if err = b.Eth1Data.HashTreeRootWith(hh); err != nil { - return - } +func (c *IndexedAttestation) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // 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) - } +func (c *IndexedAttestation) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 228 - // Field (10) 'Eth1DepositIndex' - ssz.PutUint(hh, b.Eth1DepositIndex) + // Field 0: AttestingIndices + dst = ssz.WriteOffset(dst, offset) + offset += len(c.AttestingIndices) * 8 - // 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 1: Data + if c.Data == nil { + c.Data = new(AttestationData) + } + if dst, err = c.Data.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Data: %w", err) } - // Field (12) 'Balances' - { - if size := len(b.Balances); size > 1099511627776 { - err = ssz.ErrListTooBigFn("--.Balances", size, 1099511627776) - return - } - subIndx := hh.Index() - for _, i := range b.Balances { - ssz.AppendUint(hh, i) - } - hh.FillUpTo32() + // Field 2: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.Signature...) - numItems := uint64(len(b.Balances)) - hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(1099511627776, numItems, 8)) + // Field 0: AttestingIndices + if len(c.AttestingIndices) > 2048 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.AttestingIndices { + dst = binary.LittleEndian.AppendUint64(dst, o) } + return dst, err +} - // Field (13) 'RandaoMixes' - { - if size := len(b.RandaoMixes); size != 65536 { - err = ssz.ErrVectorLengthFn("--.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) +func (c *IndexedAttestation) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 228 { + return ssz.ErrSize } - // Field (14) 'Slashings' - { - if size := len(b.Slashings); size != 8192 { - err = ssz.ErrVectorLengthFn("--.Slashings", size, 8192) - return - } - subIndx := hh.Index() - for _, i := range b.Slashings { - ssz.AppendUint(hh, i) - } - hh.Merkleize(subIndx) + sszSlice1 := buf[4:132] // c.Data + sszSlice2 := buf[132:228] // c.Signature + + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.AttestingIndices + if sszVarOffset0 != 228 { + return ssz.ErrInvalidVariableOffset } + if sszVarOffset0 > size { + return ssz.ErrOffset + } + sszSlice0 := buf[sszVarOffset0:] // c.AttestingIndices - // Field (15) 'PreviousEpochAttestations' + // Field 0: AttestingIndices { - subIndx := hh.Index() - num := uint64(len(b.PreviousEpochAttestations)) - if num > 4096 { - err = ssz.ErrIncorrectListSize - return + if len(sszSlice0)%8 != 0 { + return fmt.Errorf("misaligned bytes: c.AttestingIndices length is %d, which is not a multiple of 8: %w", len(sszSlice0), ssz.ErrIncorrectListSize) } - for _, elem := range b.PreviousEpochAttestations { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } + numElem := len(sszSlice0) / 8 + if numElem > 2048 { + return fmt.Errorf("ssz-max exceeded: c.AttestingIndices has %d elements, ssz-max is 2048: %w", numElem, ssz.ErrListTooBig) } - hh.MerkleizeWithMixin(subIndx, num, 4096) - } + c.AttestingIndices = make([]uint64, numElem) + for i := 0; i < numElem; i++ { + var tmp uint64 - // Field (16) 'CurrentEpochAttestations' - { - subIndx := hh.Index() - num := uint64(len(b.CurrentEpochAttestations)) - if num > 4096 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range b.CurrentEpochAttestations { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } + tmpSlice := sszSlice0[i*8 : (1+i)*8] + tmp = binary.LittleEndian.Uint64(tmpSlice) + c.AttestingIndices[i] = tmp } - hh.MerkleizeWithMixin(subIndx, num, 4096) } - // Field (17) 'JustificationBits' - if size := len(b.JustificationBits); size != 1 { - err = ssz.ErrBytesLengthFn("--.JustificationBits", size, 1) - return + // Field 1: Data + c.Data = new(AttestationData) + if err = c.Data.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Data: %w", err) } - hh.PutBytes(b.JustificationBits) - // Field (18) 'PreviousJustifiedCheckpoint' - if err = b.PreviousJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { - return - } + // Field 2: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice2...) + return err +} - // Field (19) 'CurrentJustifiedCheckpoint' - if err = b.CurrentJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { - return +func (c *IndexedAttestation) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - // Field (20) 'FinalizedCheckpoint' - if err = b.FinalizedCheckpoint.HashTreeRootWith(hh); err != nil { - return +func (c *IndexedAttestation) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: AttestingIndices + { + if len(c.AttestingIndices) > 2048 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.AttestingIndices { + hh.AppendUint64(o) + } + hh.FillUpTo32() + numItems := uint64(len(c.AttestingIndices)) + hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(2048, numItems, 8)) } - + // Field 1: Data + if err := c.Data.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Data: %w", err) + } + // Field 2: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Signature) hh.Merkleize(indx) - return + return nil +} + +func (c *PendingAttestation) SizeSSZ() int { + size := 148 + size += len(c.AggregationBits) + return size } -// MarshalSSZ ssz marshals the PendingAttestation object -func (p *PendingAttestation) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(p) +func (c *PendingAttestation) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the PendingAttestation object to a target array -func (p *PendingAttestation) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(148) +func (c *PendingAttestation) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 148 - // Offset (0) 'AggregationBits' + // Field 0: AggregationBits dst = ssz.WriteOffset(dst, offset) - offset += len(p.AggregationBits) + offset += len(c.AggregationBits) - // Field (1) 'Data' - if p.Data == nil { - p.Data = new(AttestationData) + // Field 1: Data + if c.Data == nil { + c.Data = new(AttestationData) } - if dst, err = p.Data.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.Data.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Data: %w", err) } - // Field (2) 'InclusionDelay' - dst = ssz.MarshalUint(dst, p.InclusionDelay) - - // Field (3) 'ProposerIndex' - dst = ssz.MarshalUint(dst, p.ProposerIndex) + // Field 2: InclusionDelay + if dst, err = c.InclusionDelay.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("InclusionDelay: %w", err) + } - // Field (0) 'AggregationBits' - if size := len(p.AggregationBits); size > 2048 { - err = ssz.ErrBytesLengthFn("--.AggregationBits", size, 2048) - return + // Field 3: ProposerIndex + if dst, err = c.ProposerIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ProposerIndex: %w", err) } - dst = append(dst, p.AggregationBits...) - return + // Field 0: AggregationBits + if len(c.AggregationBits) > 2048 { + return nil, ssz.ErrListTooBig + } + dst = append(dst, c.AggregationBits...) + return dst, err } -// UnmarshalSSZ ssz unmarshals the PendingAttestation object -func (p *PendingAttestation) UnmarshalSSZ(buf []byte) error { +func (c *PendingAttestation) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size < 148 { return ssz.ErrSize } - tail := buf - var o0 uint64 + sszSlice1 := buf[4:132] // c.Data + sszSlice2 := buf[132:140] // c.InclusionDelay + sszSlice3 := buf[140:148] // c.ProposerIndex - // Offset (0) 'AggregationBits' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.AggregationBits + if sszVarOffset0 != 148 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset0 > size { return ssz.ErrOffset } + sszSlice0 := buf[sszVarOffset0:] // c.AggregationBits - if o0 != 148 { - return ssz.ErrInvalidVariableOffset + // Field 0: AggregationBits + if err = ssz.ValidateBitlist(sszSlice0, 2048); err != nil { + return fmt.Errorf("AggregationBits: %w", err) } + c.AggregationBits = append([]byte{}, go_bitfield.Bitlist(sszSlice0)...) - // Field (1) 'Data' - if p.Data == nil { - p.Data = new(AttestationData) - } - if err = p.Data.UnmarshalSSZ(buf[4:132]); err != nil { - return err + // Field 1: Data + c.Data = new(AttestationData) + if err = c.Data.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Data: %w", err) } - // Field (2) 'InclusionDelay' - p.InclusionDelay = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[132:140]) - - // Field (3) 'ProposerIndex' - p.ProposerIndex = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[140:148]) + // Field 2: InclusionDelay + if err = c.InclusionDelay.UnmarshalSSZ(sszSlice2); err != nil { + return fmt.Errorf("InclusionDelay: %w", err) + } - // Field (0) 'AggregationBits' - { - buf = tail[o0:] - if err = ssz.ValidateBitlist(buf, 2048); err != nil { - return err - } - if cap(p.AggregationBits) == 0 { - p.AggregationBits = make([]byte, 0, len(buf)) - } - p.AggregationBits = append(p.AggregationBits, buf...) + // Field 3: ProposerIndex + if err = c.ProposerIndex.UnmarshalSSZ(sszSlice3); err != nil { + return fmt.Errorf("ProposerIndex: %w", err) } return err } -// SizeSSZ returns the ssz encoded size in bytes for the PendingAttestation object -func (p *PendingAttestation) SizeSSZ() (size int) { - size = 148 +func (c *PendingAttestation) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} + +func (c *PendingAttestation) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: AggregationBits + if len(c.AggregationBits) == 0 { + return ssz.ErrEmptyBitlist + } + hh.PutBitlist(c.AggregationBits, 2048) + // Field 1: Data + if err := c.Data.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Data: %w", err) + } + // Field 2: InclusionDelay + if err := c.InclusionDelay.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("InclusionDelay: %w", err) + } + // Field 3: ProposerIndex + if err := c.ProposerIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ProposerIndex: %w", err) + } + hh.Merkleize(indx) + return nil +} - // Field (0) 'AggregationBits' - size += len(p.AggregationBits) +func (c *PowBlock) SizeSSZ() int { + size := 96 - return + return size } -// HashTreeRoot ssz hashes the PendingAttestation object -func (p *PendingAttestation) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(p) +func (c *PowBlock) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// HashTreeRootWith ssz hashes the PendingAttestation object with a hasher -func (p *PendingAttestation) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() +func (c *PowBlock) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + + // Field 0: BlockHash + if len(c.BlockHash) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.BlockHash...) + + // Field 1: ParentHash + if len(c.ParentHash) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.ParentHash...) - // Field (0) 'AggregationBits' - if len(p.AggregationBits) == 0 { - err = ssz.ErrEmptyBitlist - return + // Field 2: TotalDifficulty + if len(c.TotalDifficulty) != 32 { + return nil, ssz.ErrBytesLength } - hh.PutBitlist(p.AggregationBits, 2048) + dst = append(dst, c.TotalDifficulty...) + + return dst, err +} - // Field (1) 'Data' - if err = p.Data.HashTreeRootWith(hh); err != nil { - return +func (c *PowBlock) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 96 { + return ssz.ErrSize } - // Field (2) 'InclusionDelay' - ssz.PutUint(hh, p.InclusionDelay) + sszSlice0 := buf[0:32] // c.BlockHash + sszSlice1 := buf[32:64] // c.ParentHash + sszSlice2 := buf[64:96] // c.TotalDifficulty + + // Field 0: BlockHash + c.BlockHash = make([]byte, 0, 32) + c.BlockHash = append(c.BlockHash, sszSlice0...) + + // Field 1: ParentHash + c.ParentHash = make([]byte, 0, 32) + c.ParentHash = append(c.ParentHash, sszSlice1...) + + // Field 2: TotalDifficulty + c.TotalDifficulty = make([]byte, 0, 32) + c.TotalDifficulty = append(c.TotalDifficulty, sszSlice2...) + return err +} - // Field (3) 'ProposerIndex' - ssz.PutUint(hh, p.ProposerIndex) +func (c *PowBlock) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} +func (c *PowBlock) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: BlockHash + if len(c.BlockHash) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.BlockHash) + // Field 1: ParentHash + if len(c.ParentHash) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ParentHash) + // Field 2: TotalDifficulty + if len(c.TotalDifficulty) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.TotalDifficulty) hh.Merkleize(indx) - return + return nil +} + +func (c *ProposerSlashing) SizeSSZ() int { + size := 416 + + return size } -// MarshalSSZ ssz marshals the HistoricalBatch object -func (h *HistoricalBatch) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(h) +func (c *ProposerSlashing) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the HistoricalBatch object to a target array -func (h *HistoricalBatch) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *ProposerSlashing) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (0) 'BlockRoots' - if size := len(h.BlockRoots); size != 8192 { - err = ssz.ErrVectorLengthFn("--.BlockRoots", size, 8192) - return + // Field 0: Header_1 + if c.Header_1 == nil { + c.Header_1 = new(SignedBeaconBlockHeader) } - for ii := 0; ii < 8192; ii++ { - if size := len(h.BlockRoots[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockRoots[ii]", size, 32) - return - } - dst = append(dst, h.BlockRoots[ii]...) + if dst, err = c.Header_1.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Header_1: %w", err) } - // Field (1) 'StateRoots' - if size := len(h.StateRoots); size != 8192 { - err = ssz.ErrVectorLengthFn("--.StateRoots", size, 8192) - return + // Field 1: Header_2 + if c.Header_2 == nil { + c.Header_2 = new(SignedBeaconBlockHeader) } - for ii := 0; ii < 8192; ii++ { - if size := len(h.StateRoots[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoots[ii]", size, 32) - return - } - dst = append(dst, h.StateRoots[ii]...) + if dst, err = c.Header_2.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Header_2: %w", err) } - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the HistoricalBatch object -func (h *HistoricalBatch) UnmarshalSSZ(buf []byte) error { +func (c *ProposerSlashing) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 524288 { + if size != 416 { return ssz.ErrSize } - // Field (0) 'BlockRoots' - h.BlockRoots = make([][]byte, 8192) - for ii := 0; ii < 8192; ii++ { - if cap(h.BlockRoots[ii]) == 0 { - h.BlockRoots[ii] = make([]byte, 0, len(buf[0:262144][ii*32:(ii+1)*32])) - } - h.BlockRoots[ii] = append(h.BlockRoots[ii], buf[0:262144][ii*32:(ii+1)*32]...) - } + sszSlice0 := buf[0:208] // c.Header_1 + sszSlice1 := buf[208:416] // c.Header_2 - // Field (1) 'StateRoots' - h.StateRoots = make([][]byte, 8192) - for ii := 0; ii < 8192; ii++ { - if cap(h.StateRoots[ii]) == 0 { - h.StateRoots[ii] = make([]byte, 0, len(buf[262144:524288][ii*32:(ii+1)*32])) - } - h.StateRoots[ii] = append(h.StateRoots[ii], buf[262144:524288][ii*32:(ii+1)*32]...) + // Field 0: Header_1 + c.Header_1 = new(SignedBeaconBlockHeader) + if err = c.Header_1.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Header_1: %w", err) } + // Field 1: Header_2 + c.Header_2 = new(SignedBeaconBlockHeader) + if err = c.Header_2.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Header_2: %w", err) + } return err } -// SizeSSZ returns the ssz encoded size in bytes for the HistoricalBatch object -func (h *HistoricalBatch) SizeSSZ() (size int) { - size = 524288 - return -} - -// HashTreeRoot ssz hashes the HistoricalBatch object -func (h *HistoricalBatch) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(h) +func (c *ProposerSlashing) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the HistoricalBatch object with a hasher -func (h *HistoricalBatch) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *ProposerSlashing) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'BlockRoots' - { - if size := len(h.BlockRoots); size != 8192 { - err = ssz.ErrVectorLengthFn("--.BlockRoots", size, 8192) - return - } - subIndx := hh.Index() - for _, i := range h.BlockRoots { - if len(i) != 32 { - err = ssz.ErrBytesLength - return - } - hh.Append(i) - } - hh.Merkleize(subIndx) + // Field 0: Header_1 + if err := c.Header_1.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Header_1: %w", err) } - - // Field (1) 'StateRoots' - { - if size := len(h.StateRoots); size != 8192 { - err = ssz.ErrVectorLengthFn("--.StateRoots", size, 8192) - return - } - subIndx := hh.Index() - for _, i := range h.StateRoots { - if len(i) != 32 { - err = ssz.ErrBytesLength - return - } - hh.Append(i) - } - hh.Merkleize(subIndx) + // Field 1: Header_2 + if err := c.Header_2.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Header_2: %w", err) } - hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the SigningData object -func (s *SigningData) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) +func (c *SignedAggregateAttestationAndProof) SizeSSZ() int { + size := 100 + if c.Message == nil { + c.Message = new(AggregateAttestationAndProof) + } + size += c.Message.SizeSSZ() + return size +} + +func (c *SignedAggregateAttestationAndProof) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the SigningData object to a target array -func (s *SigningData) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *SignedAggregateAttestationAndProof) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 100 - // Field (0) 'ObjectRoot' - if size := len(s.ObjectRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ObjectRoot", size, 32) - return + // Field 0: Message + if c.Message == nil { + c.Message = new(AggregateAttestationAndProof) } - dst = append(dst, s.ObjectRoot...) + dst = ssz.WriteOffset(dst, offset) + offset += c.Message.SizeSSZ() - // Field (1) 'Domain' - if size := len(s.Domain); size != 32 { - err = ssz.ErrBytesLengthFn("--.Domain", size, 32) - return + // Field 1: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } - dst = append(dst, s.Domain...) + dst = append(dst, c.Signature...) - return + // Field 0: Message + if dst, err = c.Message.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Message: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the SigningData object -func (s *SigningData) UnmarshalSSZ(buf []byte) error { +func (c *SignedAggregateAttestationAndProof) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 64 { + if size < 100 { return ssz.ErrSize } - // Field (0) 'ObjectRoot' - if cap(s.ObjectRoot) == 0 { - s.ObjectRoot = make([]byte, 0, len(buf[0:32])) + sszSlice1 := buf[4:100] // c.Signature + + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Message + if sszVarOffset0 != 100 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset0 > size { + return ssz.ErrOffset } - s.ObjectRoot = append(s.ObjectRoot, buf[0:32]...) + sszSlice0 := buf[sszVarOffset0:] // c.Message - // Field (1) 'Domain' - if cap(s.Domain) == 0 { - s.Domain = make([]byte, 0, len(buf[32:64])) + // Field 0: Message + c.Message = new(AggregateAttestationAndProof) + if err = c.Message.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Message: %w", err) } - s.Domain = append(s.Domain, buf[32:64]...) + // Field 1: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice1...) return err } -// SizeSSZ returns the ssz encoded size in bytes for the SigningData object -func (s *SigningData) SizeSSZ() (size int) { - size = 64 - return -} - -// HashTreeRoot ssz hashes the SigningData object -func (s *SigningData) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) +func (c *SignedAggregateAttestationAndProof) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the SigningData object with a hasher -func (s *SigningData) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *SignedAggregateAttestationAndProof) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'ObjectRoot' - if size := len(s.ObjectRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ObjectRoot", size, 32) - return + // Field 0: Message + if err := c.Message.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Message: %w", err) } - hh.PutBytes(s.ObjectRoot) - - // Field (1) 'Domain' - if size := len(s.Domain); size != 32 { - err = ssz.ErrBytesLengthFn("--.Domain", size, 32) - return + // Field 1: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength } - hh.PutBytes(s.Domain) - + hh.PutBytes(c.Signature) hh.Merkleize(indx) - return + return nil +} + +func (c *SignedBeaconBlock) SizeSSZ() int { + size := 100 + if c.Block == nil { + c.Block = new(BeaconBlock) + } + size += c.Block.SizeSSZ() + return size } -// MarshalSSZ ssz marshals the ForkData object -func (f *ForkData) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(f) +func (c *SignedBeaconBlock) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the ForkData object to a target array -func (f *ForkData) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *SignedBeaconBlock) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 100 - // Field (0) 'CurrentVersion' - if size := len(f.CurrentVersion); size != 4 { - err = ssz.ErrBytesLengthFn("--.CurrentVersion", size, 4) - return + // Field 0: Block + if c.Block == nil { + c.Block = new(BeaconBlock) } - dst = append(dst, f.CurrentVersion...) + dst = ssz.WriteOffset(dst, offset) + offset += c.Block.SizeSSZ() - // Field (1) 'GenesisValidatorsRoot' - if size := len(f.GenesisValidatorsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.GenesisValidatorsRoot", size, 32) - return + // Field 1: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } - dst = append(dst, f.GenesisValidatorsRoot...) + dst = append(dst, c.Signature...) - return + // Field 0: Block + if dst, err = c.Block.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Block: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the ForkData object -func (f *ForkData) UnmarshalSSZ(buf []byte) error { +func (c *SignedBeaconBlock) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 36 { + if size < 100 { return ssz.ErrSize } - // Field (0) 'CurrentVersion' - if cap(f.CurrentVersion) == 0 { - f.CurrentVersion = make([]byte, 0, len(buf[0:4])) + sszSlice1 := buf[4:100] // c.Signature + + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Block + if sszVarOffset0 != 100 { + return ssz.ErrInvalidVariableOffset } - f.CurrentVersion = append(f.CurrentVersion, buf[0:4]...) + if sszVarOffset0 > size { + return ssz.ErrOffset + } + sszSlice0 := buf[sszVarOffset0:] // c.Block - // Field (1) 'GenesisValidatorsRoot' - if cap(f.GenesisValidatorsRoot) == 0 { - f.GenesisValidatorsRoot = make([]byte, 0, len(buf[4:36])) + // Field 0: Block + c.Block = new(BeaconBlock) + if err = c.Block.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Block: %w", err) } - f.GenesisValidatorsRoot = append(f.GenesisValidatorsRoot, buf[4:36]...) + // Field 1: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice1...) return err } -// SizeSSZ returns the ssz encoded size in bytes for the ForkData object -func (f *ForkData) SizeSSZ() (size int) { - size = 36 - return -} - -// HashTreeRoot ssz hashes the ForkData object -func (f *ForkData) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(f) +func (c *SignedBeaconBlock) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the ForkData object with a hasher -func (f *ForkData) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *SignedBeaconBlock) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'CurrentVersion' - if size := len(f.CurrentVersion); size != 4 { - err = ssz.ErrBytesLengthFn("--.CurrentVersion", size, 4) - return + // Field 0: Block + if err := c.Block.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Block: %w", err) } - hh.PutBytes(f.CurrentVersion) - - // Field (1) 'GenesisValidatorsRoot' - if size := len(f.GenesisValidatorsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.GenesisValidatorsRoot", size, 32) - return + // Field 1: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength } - hh.PutBytes(f.GenesisValidatorsRoot) - + hh.PutBytes(c.Signature) hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the DepositMessage object -func (d *DepositMessage) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(d) +func (c *SignedBeaconBlockHeader) SizeSSZ() int { + size := 208 + + return size } -// MarshalSSZTo ssz marshals the DepositMessage object to a target array -func (d *DepositMessage) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *SignedBeaconBlockHeader) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (0) 'PublicKey' - if size := len(d.PublicKey); size != 48 { - err = ssz.ErrBytesLengthFn("--.PublicKey", size, 48) - return - } - dst = append(dst, d.PublicKey...) +func (c *SignedBeaconBlockHeader) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (1) 'WithdrawalCredentials' - if size := len(d.WithdrawalCredentials); size != 32 { - err = ssz.ErrBytesLengthFn("--.WithdrawalCredentials", size, 32) - return + // Field 0: Header + if c.Header == nil { + c.Header = new(BeaconBlockHeader) + } + if dst, err = c.Header.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Header: %w", err) } - dst = append(dst, d.WithdrawalCredentials...) - // Field (2) 'Amount' - dst = ssz.MarshalUint(dst, d.Amount) + // Field 1: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.Signature...) - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the DepositMessage object -func (d *DepositMessage) UnmarshalSSZ(buf []byte) error { +func (c *SignedBeaconBlockHeader) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 88 { + if size != 208 { 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]...) + sszSlice0 := buf[0:112] // c.Header + sszSlice1 := buf[112:208] // c.Signature - // Field (1) 'WithdrawalCredentials' - if cap(d.WithdrawalCredentials) == 0 { - d.WithdrawalCredentials = make([]byte, 0, len(buf[48:80])) + // Field 0: Header + c.Header = new(BeaconBlockHeader) + if err = c.Header.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Header: %w", err) } - d.WithdrawalCredentials = append(d.WithdrawalCredentials, buf[48:80]...) - - // Field (2) 'Amount' - d.Amount = ssz.UnmarshallUint[uint64](buf[80:88]) + // Field 1: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice1...) return err } -// SizeSSZ returns the ssz encoded size in bytes for the DepositMessage object -func (d *DepositMessage) SizeSSZ() (size int) { - size = 88 - return -} - -// HashTreeRoot ssz hashes the DepositMessage object -func (d *DepositMessage) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(d) +func (c *SignedBeaconBlockHeader) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the DepositMessage object with a hasher -func (d *DepositMessage) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *SignedBeaconBlockHeader) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'PublicKey' - if size := len(d.PublicKey); size != 48 { - err = ssz.ErrBytesLengthFn("--.PublicKey", size, 48) - return + // Field 0: Header + if err := c.Header.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Header: %w", err) } - hh.PutBytes(d.PublicKey) - - // Field (1) 'WithdrawalCredentials' - if size := len(d.WithdrawalCredentials); size != 32 { - err = ssz.ErrBytesLengthFn("--.WithdrawalCredentials", size, 32) - return + // Field 1: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength } - hh.PutBytes(d.WithdrawalCredentials) + hh.PutBytes(c.Signature) + hh.Merkleize(indx) + return nil +} - // Field (2) 'Amount' - ssz.PutUint(hh, d.Amount) +func (c *SignedVoluntaryExit) SizeSSZ() int { + size := 112 - hh.Merkleize(indx) - return + return size } -// MarshalSSZ ssz marshals the PowBlock object -func (p *PowBlock) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(p) +func (c *SignedVoluntaryExit) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the PowBlock object to a target array -func (p *PowBlock) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *SignedVoluntaryExit) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (0) 'BlockHash' - if size := len(p.BlockHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockHash", size, 32) - return + // Field 0: Exit + if c.Exit == nil { + c.Exit = new(VoluntaryExit) } - dst = append(dst, p.BlockHash...) - - // Field (1) 'ParentHash' - if size := len(p.ParentHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentHash", size, 32) - return + if dst, err = c.Exit.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Exit: %w", err) } - dst = append(dst, p.ParentHash...) - // Field (2) 'TotalDifficulty' - if size := len(p.TotalDifficulty); size != 32 { - err = ssz.ErrBytesLengthFn("--.TotalDifficulty", size, 32) - return + // Field 1: Signature + if len(c.Signature) != 96 { + return nil, ssz.ErrBytesLength } - dst = append(dst, p.TotalDifficulty...) + dst = append(dst, c.Signature...) - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the PowBlock object -func (p *PowBlock) UnmarshalSSZ(buf []byte) error { +func (c *SignedVoluntaryExit) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 96 { + if size != 112 { return ssz.ErrSize } - // Field (0) 'BlockHash' - if cap(p.BlockHash) == 0 { - p.BlockHash = make([]byte, 0, len(buf[0:32])) - } - p.BlockHash = append(p.BlockHash, buf[0:32]...) + sszSlice0 := buf[0:16] // c.Exit + sszSlice1 := buf[16:112] // c.Signature - // Field (1) 'ParentHash' - if cap(p.ParentHash) == 0 { - p.ParentHash = make([]byte, 0, len(buf[32:64])) + // Field 0: Exit + c.Exit = new(VoluntaryExit) + if err = c.Exit.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Exit: %w", err) } - p.ParentHash = append(p.ParentHash, buf[32:64]...) - // Field (2) 'TotalDifficulty' - if cap(p.TotalDifficulty) == 0 { - p.TotalDifficulty = make([]byte, 0, len(buf[64:96])) + // Field 1: Signature + c.Signature = make([]byte, 0, 96) + c.Signature = append(c.Signature, sszSlice1...) + return err +} + +func (c *SignedVoluntaryExit) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - p.TotalDifficulty = append(p.TotalDifficulty, buf[64:96]...) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} - return err +func (c *SignedVoluntaryExit) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Exit + if err := c.Exit.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Exit: %w", err) + } + // Field 1: Signature + if len(c.Signature) != 96 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Signature) + hh.Merkleize(indx) + return nil } -// SizeSSZ returns the ssz encoded size in bytes for the PowBlock object -func (p *PowBlock) SizeSSZ() (size int) { - size = 96 - return +func (c *SigningData) SizeSSZ() int { + size := 64 + + return size } -// HashTreeRoot ssz hashes the PowBlock object -func (p *PowBlock) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(p) +func (c *SigningData) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// HashTreeRootWith ssz hashes the PowBlock object with a hasher -func (p *PowBlock) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() +func (c *SigningData) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + + // Field 0: ObjectRoot + if len(c.ObjectRoot) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.ObjectRoot...) - // Field (0) 'BlockHash' - if size := len(p.BlockHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockHash", size, 32) - return + // Field 1: Domain + if len(c.Domain) != 32 { + return nil, ssz.ErrBytesLength } - hh.PutBytes(p.BlockHash) + dst = append(dst, c.Domain...) + + return dst, err +} - // Field (1) 'ParentHash' - if size := len(p.ParentHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentHash", size, 32) - return +func (c *SigningData) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 64 { + return ssz.ErrSize } - hh.PutBytes(p.ParentHash) - // Field (2) 'TotalDifficulty' - if size := len(p.TotalDifficulty); size != 32 { - err = ssz.ErrBytesLengthFn("--.TotalDifficulty", size, 32) - return + sszSlice0 := buf[0:32] // c.ObjectRoot + sszSlice1 := buf[32:64] // c.Domain + + // Field 0: ObjectRoot + c.ObjectRoot = make([]byte, 0, 32) + c.ObjectRoot = append(c.ObjectRoot, sszSlice0...) + + // Field 1: Domain + c.Domain = make([]byte, 0, 32) + c.Domain = append(c.Domain, sszSlice1...) + return err +} + +func (c *SigningData) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - hh.PutBytes(p.TotalDifficulty) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} +func (c *SigningData) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: ObjectRoot + if len(c.ObjectRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ObjectRoot) + // Field 1: Domain + if len(c.Domain) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Domain) hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the Status object -func (s *Status) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) +func (c *Status) SizeSSZ() int { + size := 84 + + return size +} + +func (c *Status) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the Status object to a target array -func (s *Status) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *Status) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (0) 'ForkDigest' - if size := len(s.ForkDigest); size != 4 { - err = ssz.ErrBytesLengthFn("--.ForkDigest", size, 4) - return + // Field 0: ForkDigest + if len(c.ForkDigest) != 4 { + return nil, ssz.ErrBytesLength } - dst = append(dst, s.ForkDigest...) + dst = append(dst, c.ForkDigest...) - // Field (1) 'FinalizedRoot' - if size := len(s.FinalizedRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.FinalizedRoot", size, 32) - return + // Field 1: FinalizedRoot + if len(c.FinalizedRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, s.FinalizedRoot...) + dst = append(dst, c.FinalizedRoot...) - // Field (2) 'FinalizedEpoch' - dst = ssz.MarshalUint(dst, s.FinalizedEpoch) + // Field 2: FinalizedEpoch + if dst, err = c.FinalizedEpoch.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("FinalizedEpoch: %w", err) + } - // Field (3) 'HeadRoot' - if size := len(s.HeadRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.HeadRoot", size, 32) - return + // Field 3: HeadRoot + if len(c.HeadRoot) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, s.HeadRoot...) + dst = append(dst, c.HeadRoot...) - // Field (4) 'HeadSlot' - dst = ssz.MarshalUint(dst, s.HeadSlot) + // Field 4: HeadSlot + if dst, err = c.HeadSlot.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("HeadSlot: %w", err) + } - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the Status object -func (s *Status) UnmarshalSSZ(buf []byte) error { +func (c *Status) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size != 84 { return ssz.ErrSize } - // Field (0) 'ForkDigest' - if cap(s.ForkDigest) == 0 { - s.ForkDigest = make([]byte, 0, len(buf[0:4])) - } - s.ForkDigest = append(s.ForkDigest, buf[0:4]...) + sszSlice0 := buf[0:4] // c.ForkDigest + sszSlice1 := buf[4:36] // c.FinalizedRoot + sszSlice2 := buf[36:44] // c.FinalizedEpoch + sszSlice3 := buf[44:76] // c.HeadRoot + sszSlice4 := buf[76:84] // c.HeadSlot - // Field (1) 'FinalizedRoot' - if cap(s.FinalizedRoot) == 0 { - s.FinalizedRoot = make([]byte, 0, len(buf[4:36])) - } - s.FinalizedRoot = append(s.FinalizedRoot, buf[4:36]...) + // Field 0: ForkDigest + c.ForkDigest = make([]byte, 0, 4) + c.ForkDigest = append(c.ForkDigest, sszSlice0...) - // Field (2) 'FinalizedEpoch' - s.FinalizedEpoch = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Epoch](buf[36:44]) + // Field 1: FinalizedRoot + c.FinalizedRoot = make([]byte, 0, 32) + c.FinalizedRoot = append(c.FinalizedRoot, sszSlice1...) - // Field (3) 'HeadRoot' - if cap(s.HeadRoot) == 0 { - s.HeadRoot = make([]byte, 0, len(buf[44:76])) + // Field 2: FinalizedEpoch + if err = c.FinalizedEpoch.UnmarshalSSZ(sszSlice2); err != nil { + return fmt.Errorf("FinalizedEpoch: %w", err) } - s.HeadRoot = append(s.HeadRoot, buf[44:76]...) - // Field (4) 'HeadSlot' - s.HeadSlot = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Slot](buf[76:84]) + // Field 3: HeadRoot + c.HeadRoot = make([]byte, 0, 32) + c.HeadRoot = append(c.HeadRoot, sszSlice3...) + // Field 4: HeadSlot + if err = c.HeadSlot.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("HeadSlot: %w", err) + } return err } -// SizeSSZ returns the ssz encoded size in bytes for the Status object -func (s *Status) SizeSSZ() (size int) { - size = 84 - return +func (c *Status) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRoot ssz hashes the Status object -func (s *Status) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) +func (c *Status) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: ForkDigest + if len(c.ForkDigest) != 4 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.ForkDigest) + // Field 1: FinalizedRoot + if len(c.FinalizedRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.FinalizedRoot) + // Field 2: FinalizedEpoch + if err := c.FinalizedEpoch.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("FinalizedEpoch: %w", err) + } + // Field 3: HeadRoot + if len(c.HeadRoot) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.HeadRoot) + // Field 4: HeadSlot + if err := c.HeadSlot.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("HeadSlot: %w", err) + } + hh.Merkleize(indx) + return nil } -// HashTreeRootWith ssz hashes the Status object with a hasher -func (s *Status) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() +func (c *Validator) SizeSSZ() int { + size := 121 - // Field (0) 'ForkDigest' - if size := len(s.ForkDigest); size != 4 { - err = ssz.ErrBytesLengthFn("--.ForkDigest", size, 4) - return - } - hh.PutBytes(s.ForkDigest) + return size +} - // Field (1) 'FinalizedRoot' - if size := len(s.FinalizedRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.FinalizedRoot", size, 32) - return - } - hh.PutBytes(s.FinalizedRoot) +func (c *Validator) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (2) 'FinalizedEpoch' - ssz.PutUint(hh, s.FinalizedEpoch) +func (c *Validator) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (3) 'HeadRoot' - if size := len(s.HeadRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.HeadRoot", size, 32) - return + // Field 0: PublicKey + if len(c.PublicKey) != 48 { + return nil, ssz.ErrBytesLength } - hh.PutBytes(s.HeadRoot) + dst = append(dst, c.PublicKey...) - // Field (4) 'HeadSlot' - ssz.PutUint(hh, s.HeadSlot) + // Field 1: WithdrawalCredentials + if len(c.WithdrawalCredentials) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.WithdrawalCredentials...) - hh.Merkleize(indx) - return -} + // Field 2: EffectiveBalance + dst = binary.LittleEndian.AppendUint64(dst, c.EffectiveBalance) -// MarshalSSZ ssz marshals the ENRForkID object -func (e *ENRForkID) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(e) -} + // Field 3: Slashed + if c.Slashed { + dst = append(dst, 1) + } else { + dst = append(dst, 0) + } -// MarshalSSZTo ssz marshals the ENRForkID object to a target array -func (e *ENRForkID) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf + // Field 4: ActivationEligibilityEpoch + if dst, err = c.ActivationEligibilityEpoch.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ActivationEligibilityEpoch: %w", err) + } - // Field (0) 'CurrentForkDigest' - if size := len(e.CurrentForkDigest); size != 4 { - err = ssz.ErrBytesLengthFn("--.CurrentForkDigest", size, 4) - return + // Field 5: ActivationEpoch + if dst, err = c.ActivationEpoch.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ActivationEpoch: %w", err) } - dst = append(dst, e.CurrentForkDigest...) - // Field (1) 'NextForkVersion' - if size := len(e.NextForkVersion); size != 4 { - err = ssz.ErrBytesLengthFn("--.NextForkVersion", size, 4) - return + // Field 6: ExitEpoch + if dst, err = c.ExitEpoch.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ExitEpoch: %w", err) } - dst = append(dst, e.NextForkVersion...) - // Field (2) 'NextForkEpoch' - dst = ssz.MarshalUint(dst, e.NextForkEpoch) + // Field 7: WithdrawableEpoch + if dst, err = c.WithdrawableEpoch.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("WithdrawableEpoch: %w", err) + } - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the ENRForkID object -func (e *ENRForkID) UnmarshalSSZ(buf []byte) error { +func (c *Validator) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 16 { + if size != 121 { return ssz.ErrSize } - // Field (0) 'CurrentForkDigest' - if cap(e.CurrentForkDigest) == 0 { - e.CurrentForkDigest = make([]byte, 0, len(buf[0:4])) - } - e.CurrentForkDigest = append(e.CurrentForkDigest, buf[0:4]...) + sszSlice0 := buf[0:48] // c.PublicKey + sszSlice1 := buf[48:80] // c.WithdrawalCredentials + sszSlice2 := buf[80:88] // c.EffectiveBalance + sszSlice3 := buf[88:89] // c.Slashed + sszSlice4 := buf[89:97] // c.ActivationEligibilityEpoch + sszSlice5 := buf[97:105] // c.ActivationEpoch + sszSlice6 := buf[105:113] // c.ExitEpoch + sszSlice7 := buf[113:121] // c.WithdrawableEpoch - // Field (1) 'NextForkVersion' - if cap(e.NextForkVersion) == 0 { - e.NextForkVersion = make([]byte, 0, len(buf[4:8])) - } - e.NextForkVersion = append(e.NextForkVersion, buf[4:8]...) + // Field 0: PublicKey + c.PublicKey = make([]byte, 0, 48) + c.PublicKey = append(c.PublicKey, sszSlice0...) - // Field (2) 'NextForkEpoch' - e.NextForkEpoch = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Epoch](buf[8:16]) + // Field 1: WithdrawalCredentials + c.WithdrawalCredentials = make([]byte, 0, 32) + c.WithdrawalCredentials = append(c.WithdrawalCredentials, sszSlice1...) - return err -} + // Field 2: EffectiveBalance + c.EffectiveBalance = binary.LittleEndian.Uint64(sszSlice2) -// SizeSSZ returns the ssz encoded size in bytes for the ENRForkID object -func (e *ENRForkID) SizeSSZ() (size int) { - size = 16 - return -} + // Field 3: Slashed + if sszSlice3[0] > 1 { + return ssz.ErrInvalidSerialization + } + if sszSlice3[0] == 1 { + c.Slashed = true + } else { + c.Slashed = false + } -// HashTreeRoot ssz hashes the ENRForkID object -func (e *ENRForkID) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(e) -} + // Field 4: ActivationEligibilityEpoch + if err = c.ActivationEligibilityEpoch.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("ActivationEligibilityEpoch: %w", err) + } -// HashTreeRootWith ssz hashes the ENRForkID object with a hasher -func (e *ENRForkID) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() + // Field 5: ActivationEpoch + if err = c.ActivationEpoch.UnmarshalSSZ(sszSlice5); err != nil { + return fmt.Errorf("ActivationEpoch: %w", err) + } - // Field (0) 'CurrentForkDigest' - if size := len(e.CurrentForkDigest); size != 4 { - err = ssz.ErrBytesLengthFn("--.CurrentForkDigest", size, 4) - return + // Field 6: ExitEpoch + if err = c.ExitEpoch.UnmarshalSSZ(sszSlice6); err != nil { + return fmt.Errorf("ExitEpoch: %w", err) } - hh.PutBytes(e.CurrentForkDigest) - // Field (1) 'NextForkVersion' - if size := len(e.NextForkVersion); size != 4 { - err = ssz.ErrBytesLengthFn("--.NextForkVersion", size, 4) - return + // Field 7: WithdrawableEpoch + if err = c.WithdrawableEpoch.UnmarshalSSZ(sszSlice7); err != nil { + return fmt.Errorf("WithdrawableEpoch: %w", err) } - hh.PutBytes(e.NextForkVersion) + return err +} - // Field (2) 'NextForkEpoch' - ssz.PutUint(hh, e.NextForkEpoch) +func (c *Validator) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} +func (c *Validator) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: PublicKey + if len(c.PublicKey) != 48 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.PublicKey) + // Field 1: WithdrawalCredentials + if len(c.WithdrawalCredentials) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.WithdrawalCredentials) + // Field 2: EffectiveBalance + hh.PutUint64(c.EffectiveBalance) + // Field 3: Slashed + hh.PutBool(c.Slashed) + // Field 4: ActivationEligibilityEpoch + if err := c.ActivationEligibilityEpoch.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ActivationEligibilityEpoch: %w", err) + } + // Field 5: ActivationEpoch + if err := c.ActivationEpoch.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ActivationEpoch: %w", err) + } + // Field 6: ExitEpoch + if err := c.ExitEpoch.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ExitEpoch: %w", err) + } + // Field 7: WithdrawableEpoch + if err := c.WithdrawableEpoch.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("WithdrawableEpoch: %w", err) + } hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the ValidatorIdentity object -func (v *ValidatorIdentity) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(v) +func (c *ValidatorBalance) SizeSSZ() int { + size := 16 + + return size } -// MarshalSSZTo ssz marshals the ValidatorIdentity object to a target array -func (v *ValidatorIdentity) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *ValidatorBalance) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (0) 'Index' - dst = ssz.MarshalUint(dst, v.Index) +func (c *ValidatorBalance) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (1) 'Pubkey' - if size := len(v.Pubkey); size != 48 { - err = ssz.ErrBytesLengthFn("--.Pubkey", size, 48) - return + // Field 0: Index + if dst, err = c.Index.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Index: %w", err) } - dst = append(dst, v.Pubkey...) - // Field (2) 'ActivationEpoch' - dst = ssz.MarshalUint(dst, v.ActivationEpoch) + // Field 1: Balance + dst = binary.LittleEndian.AppendUint64(dst, c.Balance) - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the ValidatorIdentity object -func (v *ValidatorIdentity) UnmarshalSSZ(buf []byte) error { +func (c *ValidatorBalance) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size != 64 { + if size != 16 { return ssz.ErrSize } - // Field (0) 'Index' - v.Index = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[0:8]) + sszSlice0 := buf[0:8] // c.Index + sszSlice1 := buf[8:16] // c.Balance - // Field (1) 'Pubkey' - if cap(v.Pubkey) == 0 { - v.Pubkey = make([]byte, 0, len(buf[8:56])) + // Field 0: Index + if err = c.Index.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Index: %w", err) } - v.Pubkey = append(v.Pubkey, buf[8:56]...) - - // Field (2) 'ActivationEpoch' - v.ActivationEpoch = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.Epoch](buf[56:64]) + // Field 1: Balance + c.Balance = binary.LittleEndian.Uint64(sszSlice1) return err } -// SizeSSZ returns the ssz encoded size in bytes for the ValidatorIdentity object -func (v *ValidatorIdentity) SizeSSZ() (size int) { - size = 64 - return -} - -// HashTreeRoot ssz hashes the ValidatorIdentity object -func (v *ValidatorIdentity) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(v) +func (c *ValidatorBalance) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the ValidatorIdentity object with a hasher -func (v *ValidatorIdentity) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *ValidatorBalance) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Index' - ssz.PutUint(hh, v.Index) - - // Field (1) 'Pubkey' - if size := len(v.Pubkey); size != 48 { - err = ssz.ErrBytesLengthFn("--.Pubkey", size, 48) - return + // Field 0: Index + if err := c.Index.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Index: %w", err) } - hh.PutBytes(v.Pubkey) + // Field 1: Balance + hh.PutUint64(c.Balance) + hh.Merkleize(indx) + return nil +} - // Field (2) 'ActivationEpoch' - ssz.PutUint(hh, v.ActivationEpoch) +func (c *VoluntaryExit) SizeSSZ() int { + size := 16 - hh.Merkleize(indx) - return + return size } -// MarshalSSZ ssz marshals the ValidatorBalance object -func (v *ValidatorBalance) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(v) +func (c *VoluntaryExit) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the ValidatorBalance object to a target array -func (v *ValidatorBalance) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *VoluntaryExit) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (0) 'Index' - dst = ssz.MarshalUint(dst, v.Index) + // Field 0: Epoch + if dst, err = c.Epoch.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Epoch: %w", err) + } - // Field (1) 'Balance' - dst = ssz.MarshalUint(dst, v.Balance) + // Field 1: ValidatorIndex + if dst, err = c.ValidatorIndex.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("ValidatorIndex: %w", err) + } - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the ValidatorBalance object -func (v *ValidatorBalance) UnmarshalSSZ(buf []byte) error { +func (c *VoluntaryExit) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size != 16 { return ssz.ErrSize } - // Field (0) 'Index' - v.Index = ssz.UnmarshallUint[github_com_OffchainLabs_prysm_v7_consensus_types_primitives.ValidatorIndex](buf[0:8]) + sszSlice0 := buf[0:8] // c.Epoch + sszSlice1 := buf[8:16] // c.ValidatorIndex - // Field (1) 'Balance' - v.Balance = ssz.UnmarshallUint[uint64](buf[8:16]) + // Field 0: Epoch + if err = c.Epoch.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Epoch: %w", err) + } + // Field 1: ValidatorIndex + if err = c.ValidatorIndex.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("ValidatorIndex: %w", err) + } return err } -// SizeSSZ returns the ssz encoded size in bytes for the ValidatorBalance object -func (v *ValidatorBalance) SizeSSZ() (size int) { - size = 16 - return -} - -// HashTreeRoot ssz hashes the ValidatorBalance object -func (v *ValidatorBalance) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(v) +func (c *VoluntaryExit) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the ValidatorBalance object with a hasher -func (v *ValidatorBalance) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *VoluntaryExit) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Index' - ssz.PutUint(hh, v.Index) - - // Field (1) 'Balance' - ssz.PutUint(hh, v.Balance) - + // Field 0: Epoch + if err := c.Epoch.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Epoch: %w", err) + } + // Field 1: ValidatorIndex + if err := c.ValidatorIndex.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("ValidatorIndex: %w", err) + } hh.Merkleize(indx) - return + return nil } diff --git a/proto/prysm/v1alpha1/phase0.yaml b/proto/prysm/v1alpha1/phase0.yaml new file mode 100644 index 000000000000..bdf60fbf8d30 --- /dev/null +++ b/proto/prysm/v1alpha1/phase0.yaml @@ -0,0 +1,32 @@ +package: "github.com/OffchainLabs/prysm/v7/proto/prysm/v1alpha1" +types: + - name: "AggregateAttestationAndProof" + - name: "Attestation" + - name: "AttestationData" + - name: "AttesterSlashing" + - name: "BeaconBlock" + - name: "BeaconBlockBody" + - name: "BeaconBlockHeader" + - name: "BeaconState" + - name: "Checkpoint" + - name: "Deposit" + - name: "Deposit_Data" + - name: "DepositMessage" + - name: "ENRForkID" + - name: "Eth1Data" + - name: "Fork" + - name: "ForkData" + - name: "HistoricalBatch" + - name: "IndexedAttestation" + - name: "PendingAttestation" + - name: "PowBlock" + - name: "ProposerSlashing" + - name: "SignedAggregateAttestationAndProof" + - name: "SignedBeaconBlock" + - name: "SignedBeaconBlockHeader" + - name: "SignedVoluntaryExit" + - name: "SigningData" + - name: "Status" + - name: "Validator" + - name: "ValidatorBalance" + - name: "VoluntaryExit" diff --git a/proto/ssz_query/BUILD.bazel b/proto/ssz_query/BUILD.bazel index deb168b5e81e..1f6fce46155e 100644 --- a/proto/ssz_query/BUILD.bazel +++ b/proto/ssz_query/BUILD.bazel @@ -1,7 +1,7 @@ load("@rules_proto//proto:defs.bzl", "proto_library") load("@io_bazel_rules_go//go:def.bzl", "go_library") load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") -load("//tools:ssz.bzl", "SSZ_DEPS", "ssz_gen_marshal") +load("//tools:methodical.bzl", "ssz_methodical") # gazelle:ignore @@ -30,28 +30,26 @@ go_proto_library( ], ) -# SSZ generation for proto messages -ssz_gen_marshal( - name = "ssz_generated", +# SSZ generation for proto messages (methodical) +ssz_methodical( + name = "methodical_ssz_query", + config_file = "response.yaml", out = "response.ssz.go", - go_proto = ":go_proto", - objs = [ - "SSZQueryProof", - "SSZQueryResponse", - "SSZQueryResponseWithProof", - ], + override_package_name = "ssz_query", + deps = [":go_proto"], ) go_library( name = "go_default_library", srcs = [ - ":ssz_generated", # keep + ":methodical_ssz_query", # keep ], embed = [":go_proto"], importpath = "github.com/OffchainLabs/prysm/v7/proto/ssz_query", visibility = ["//visibility:public"], - deps = SSZ_DEPS + [ + deps = [ "//proto/eth/ext:go_default_library", "@com_github_golang_protobuf//proto:go_default_library", + "@com_github_offchainlabs_methodical_ssz//ssz:go_default_library", ], ) diff --git a/proto/ssz_query/response.minimal.ssz.go b/proto/ssz_query/response.minimal.ssz.go new file mode 100644 index 000000000000..685b43e5067a --- /dev/null +++ b/proto/ssz_query/response.minimal.ssz.go @@ -0,0 +1,355 @@ +//go:build minimal + +package ssz_query + +import ( + binary "encoding/binary" + "fmt" + ssz "github.com/OffchainLabs/methodical-ssz/ssz" +) + +func (c *SSZQueryProof) SizeSSZ() int { + size := 44 + size += len(c.Proofs) * 32 + return size +} + +func (c *SSZQueryProof) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} + +func (c *SSZQueryProof) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 44 + + // Field 0: Leaf + if len(c.Leaf) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.Leaf...) + + // Field 1: Gindex + dst = binary.LittleEndian.AppendUint64(dst, c.Gindex) + + // Field 2: Proofs + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Proofs) * 32 + + // Field 2: Proofs + if len(c.Proofs) > 64 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.Proofs { + if len(o) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) + } + return dst, err +} + +func (c *SSZQueryProof) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 44 { + return ssz.ErrSize + } + + sszSlice0 := buf[0:32] // c.Leaf + sszSlice1 := buf[32:40] // c.Gindex + + sszVarOffset2 := ssz.ReadOffset(buf[40:44]) // c.Proofs + if sszVarOffset2 != 44 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset2 > size { + return ssz.ErrOffset + } + sszSlice2 := buf[sszVarOffset2:] // c.Proofs + + // Field 0: Leaf + c.Leaf = make([]byte, 0, 32) + c.Leaf = append(c.Leaf, sszSlice0...) + + // Field 1: Gindex + c.Gindex = binary.LittleEndian.Uint64(sszSlice1) + + // Field 2: Proofs + { + if len(sszSlice2)%32 != 0 { + return fmt.Errorf("misaligned bytes: c.Proofs length is %d, which is not a multiple of 32: %w", len(sszSlice2), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice2) / 32 + if numElem > 64 { + return fmt.Errorf("ssz-max exceeded: c.Proofs has %d elements, ssz-max is 64: %w", numElem, ssz.ErrListTooBig) + } + c.Proofs = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte + + tmpSlice := sszSlice2[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.Proofs[i] = tmp + } + } + return err +} + +func (c *SSZQueryProof) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} + +func (c *SSZQueryProof) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Leaf + if len(c.Leaf) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Leaf) + // Field 1: Gindex + hh.PutUint64(c.Gindex) + // Field 2: Proofs + { + if len(c.Proofs) > 64 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.Proofs { + if len(o) != 32 { + return ssz.ErrBytesLength + } + hh.Append(o) + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Proofs)), 64) + } + hh.Merkleize(indx) + return nil +} + +func (c *SSZQueryResponse) SizeSSZ() int { + size := 36 + size += len(c.Result) + return size +} + +func (c *SSZQueryResponse) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} + +func (c *SSZQueryResponse) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 36 + + // Field 0: Root + if len(c.Root) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.Root...) + + // Field 1: Result + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Result) + + // Field 1: Result + if len(c.Result) > 1073741824 { + return nil, ssz.ErrListTooBig + } + dst = append(dst, c.Result...) + return dst, err +} + +func (c *SSZQueryResponse) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 36 { + return ssz.ErrSize + } + + sszSlice0 := buf[0:32] // c.Root + + sszVarOffset1 := ssz.ReadOffset(buf[32:36]) // c.Result + if sszVarOffset1 != 36 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset1 > size { + return ssz.ErrOffset + } + sszSlice1 := buf[sszVarOffset1:] // c.Result + + // Field 0: Root + c.Root = make([]byte, 0, 32) + c.Root = append(c.Root, sszSlice0...) + + // Field 1: Result + c.Result = append([]byte{}, sszSlice1...) + return err +} + +func (c *SSZQueryResponse) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} + +func (c *SSZQueryResponse) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Root + if len(c.Root) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Root) + // Field 1: Result + + { + if len(c.Result) > 1073741824 { + return ssz.ErrBytesLength + } + subIndx := hh.Index() + hh.AppendBytes32(c.Result) + numItems := uint64(len(c.Result)) + hh.MerkleizeWithMixin(subIndx, numItems, (1073741824*1+31)/32) + } + + hh.Merkleize(indx) + return nil +} + +func (c *SSZQueryResponseWithProof) SizeSSZ() int { + size := 40 + size += len(c.Result) + if c.Proof == nil { + c.Proof = new(SSZQueryProof) + } + size += c.Proof.SizeSSZ() + return size +} + +func (c *SSZQueryResponseWithProof) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} + +func (c *SSZQueryResponseWithProof) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 40 + + // Field 0: Root + if len(c.Root) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.Root...) + + // Field 1: Result + dst = ssz.WriteOffset(dst, offset) + offset += len(c.Result) + + // Field 2: Proof + if c.Proof == nil { + c.Proof = new(SSZQueryProof) + } + dst = ssz.WriteOffset(dst, offset) + offset += c.Proof.SizeSSZ() + + // Field 1: Result + if len(c.Result) > 1073741824 { + return nil, ssz.ErrListTooBig + } + dst = append(dst, c.Result...) + + // Field 2: Proof + if dst, err = c.Proof.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Proof: %w", err) + } + return dst, err +} + +func (c *SSZQueryResponseWithProof) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 40 { + return ssz.ErrSize + } + + sszSlice0 := buf[0:32] // c.Root + + sszVarOffset1 := ssz.ReadOffset(buf[32:36]) // c.Result + if sszVarOffset1 != 40 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset1 > size { + return ssz.ErrOffset + } + sszVarOffset2 := ssz.ReadOffset(buf[36:40]) // c.Proof + if sszVarOffset2 > size || sszVarOffset2 < sszVarOffset1 { + return ssz.ErrOffset + } + sszSlice1 := buf[sszVarOffset1:sszVarOffset2] // c.Result + sszSlice2 := buf[sszVarOffset2:] // c.Proof + + // Field 0: Root + c.Root = make([]byte, 0, 32) + c.Root = append(c.Root, sszSlice0...) + + // Field 1: Result + c.Result = append([]byte{}, sszSlice1...) + + // Field 2: Proof + c.Proof = new(SSZQueryProof) + if err = c.Proof.UnmarshalSSZ(sszSlice2); err != nil { + return fmt.Errorf("Proof: %w", err) + } + return err +} + +func (c *SSZQueryResponseWithProof) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} + +func (c *SSZQueryResponseWithProof) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Root + if len(c.Root) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Root) + // Field 1: Result + + { + if len(c.Result) > 1073741824 { + return ssz.ErrBytesLength + } + subIndx := hh.Index() + hh.AppendBytes32(c.Result) + numItems := uint64(len(c.Result)) + hh.MerkleizeWithMixin(subIndx, numItems, (1073741824*1+31)/32) + } + + // Field 2: Proof + if err := c.Proof.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Proof: %w", err) + } + hh.Merkleize(indx) + return nil +} diff --git a/proto/ssz_query/response.ssz.go b/proto/ssz_query/response.ssz.go index 8248c09d4813..f941e8911b59 100644 --- a/proto/ssz_query/response.ssz.go +++ b/proto/ssz_query/response.ssz.go @@ -1,410 +1,355 @@ -// Code generated by fastssz. DO NOT EDIT. +//go:build !minimal + package ssz_query import ( - ssz "github.com/prysmaticlabs/fastssz" + binary "encoding/binary" + "fmt" + ssz "github.com/OffchainLabs/methodical-ssz/ssz" ) -// MarshalSSZ ssz marshals the SSZQueryProof object -func (s *SSZQueryProof) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) +func (c *SSZQueryProof) SizeSSZ() int { + size := 44 + size += len(c.Proofs) * 32 + return size } -// MarshalSSZTo ssz marshals the SSZQueryProof object to a target array -func (s *SSZQueryProof) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(44) +func (c *SSZQueryProof) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (0) 'Leaf' - if size := len(s.Leaf); size != 32 { - err = ssz.ErrBytesLengthFn("--.Leaf", size, 32) - return +func (c *SSZQueryProof) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 44 + + // Field 0: Leaf + if len(c.Leaf) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, s.Leaf...) + dst = append(dst, c.Leaf...) - // Field (1) 'Gindex' - dst = ssz.MarshalUint(dst, s.Gindex) + // Field 1: Gindex + dst = binary.LittleEndian.AppendUint64(dst, c.Gindex) - // Offset (2) 'Proofs' + // Field 2: Proofs dst = ssz.WriteOffset(dst, offset) - offset += len(s.Proofs) * 32 + offset += len(c.Proofs) * 32 - // Field (2) 'Proofs' - if size := len(s.Proofs); size > 64 { - err = ssz.ErrListTooBigFn("--.Proofs", size, 64) - return + // Field 2: Proofs + if len(c.Proofs) > 64 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(s.Proofs); ii++ { - if size := len(s.Proofs[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.Proofs[ii]", size, 32) - return + for _, o := range c.Proofs { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, s.Proofs[ii]...) + dst = append(dst, o...) } - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the SSZQueryProof object -func (s *SSZQueryProof) UnmarshalSSZ(buf []byte) error { +func (c *SSZQueryProof) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size < 44 { return ssz.ErrSize } - tail := buf - var o2 uint64 + sszSlice0 := buf[0:32] // c.Leaf + sszSlice1 := buf[32:40] // c.Gindex - // Field (0) 'Leaf' - if cap(s.Leaf) == 0 { - s.Leaf = make([]byte, 0, len(buf[0:32])) + sszVarOffset2 := ssz.ReadOffset(buf[40:44]) // c.Proofs + if sszVarOffset2 != 44 { + return ssz.ErrInvalidVariableOffset } - s.Leaf = append(s.Leaf, buf[0:32]...) - - // Field (1) 'Gindex' - s.Gindex = ssz.UnmarshallUint[uint64](buf[32:40]) - - // Offset (2) 'Proofs' - if o2 = ssz.ReadOffset(buf[40:44]); o2 > size { + if sszVarOffset2 > size { return ssz.ErrOffset } + sszSlice2 := buf[sszVarOffset2:] // c.Proofs - if o2 != 44 { - return ssz.ErrInvalidVariableOffset - } + // Field 0: Leaf + c.Leaf = make([]byte, 0, 32) + c.Leaf = append(c.Leaf, sszSlice0...) - // Field (2) 'Proofs' + // Field 1: Gindex + c.Gindex = binary.LittleEndian.Uint64(sszSlice1) + + // Field 2: Proofs { - buf = tail[o2:] - num, err := ssz.DivideInt2(len(buf), 32, 64) - if err != nil { - return err + if len(sszSlice2)%32 != 0 { + return fmt.Errorf("misaligned bytes: c.Proofs length is %d, which is not a multiple of 32: %w", len(sszSlice2), ssz.ErrIncorrectListSize) } - s.Proofs = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(s.Proofs[ii]) == 0 { - s.Proofs[ii] = make([]byte, 0, len(buf[ii*32:(ii+1)*32])) - } - s.Proofs[ii] = append(s.Proofs[ii], buf[ii*32:(ii+1)*32]...) + numElem := len(sszSlice2) / 32 + if numElem > 64 { + return fmt.Errorf("ssz-max exceeded: c.Proofs has %d elements, ssz-max is 64: %w", numElem, ssz.ErrListTooBig) + } + c.Proofs = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte + + tmpSlice := sszSlice2[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.Proofs[i] = tmp } } return err } -// SizeSSZ returns the ssz encoded size in bytes for the SSZQueryProof object -func (s *SSZQueryProof) SizeSSZ() (size int) { - size = 44 - - // Field (2) 'Proofs' - size += len(s.Proofs) * 32 - - return -} - -// HashTreeRoot ssz hashes the SSZQueryProof object -func (s *SSZQueryProof) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) +func (c *SSZQueryProof) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the SSZQueryProof object with a hasher -func (s *SSZQueryProof) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *SSZQueryProof) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Leaf' - if size := len(s.Leaf); size != 32 { - err = ssz.ErrBytesLengthFn("--.Leaf", size, 32) - return - } - hh.PutBytes(s.Leaf) - - // Field (1) 'Gindex' - ssz.PutUint(hh, s.Gindex) - - // Field (2) 'Proofs' + // Field 0: Leaf + if len(c.Leaf) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Leaf) + // Field 1: Gindex + hh.PutUint64(c.Gindex) + // Field 2: Proofs { - if size := len(s.Proofs); size > 64 { - err = ssz.ErrListTooBigFn("--.Proofs", size, 64) - return + if len(c.Proofs) > 64 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range s.Proofs { - if len(i) != 32 { - err = ssz.ErrBytesLength - return + for _, o := range c.Proofs { + if len(o) != 32 { + return ssz.ErrBytesLength } - hh.Append(i) + hh.Append(o) } - - numItems := uint64(len(s.Proofs)) - hh.MerkleizeWithMixin(subIndx, numItems, 64) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.Proofs)), 64) } - hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the SSZQueryResponse object -func (s *SSZQueryResponse) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) +func (c *SSZQueryResponse) SizeSSZ() int { + size := 36 + size += len(c.Result) + return size } -// MarshalSSZTo ssz marshals the SSZQueryResponse object to a target array -func (s *SSZQueryResponse) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(36) +func (c *SSZQueryResponse) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} + +func (c *SSZQueryResponse) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 36 - // Field (0) 'Root' - if size := len(s.Root); size != 32 { - err = ssz.ErrBytesLengthFn("--.Root", size, 32) - return + // Field 0: Root + if len(c.Root) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, s.Root...) + dst = append(dst, c.Root...) - // Offset (1) 'Result' + // Field 1: Result dst = ssz.WriteOffset(dst, offset) - offset += len(s.Result) + offset += len(c.Result) - // Field (1) 'Result' - if size := len(s.Result); size > 1073741824 { - err = ssz.ErrBytesLengthFn("--.Result", size, 1073741824) - return + // Field 1: Result + if len(c.Result) > 1073741824 { + return nil, ssz.ErrListTooBig } - dst = append(dst, s.Result...) - - return + dst = append(dst, c.Result...) + return dst, err } -// UnmarshalSSZ ssz unmarshals the SSZQueryResponse object -func (s *SSZQueryResponse) UnmarshalSSZ(buf []byte) error { +func (c *SSZQueryResponse) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size < 36 { return ssz.ErrSize } - tail := buf - var o1 uint64 + sszSlice0 := buf[0:32] // c.Root - // Field (0) 'Root' - if cap(s.Root) == 0 { - s.Root = make([]byte, 0, len(buf[0:32])) + sszVarOffset1 := ssz.ReadOffset(buf[32:36]) // c.Result + if sszVarOffset1 != 36 { + return ssz.ErrInvalidVariableOffset } - s.Root = append(s.Root, buf[0:32]...) - - // Offset (1) 'Result' - if o1 = ssz.ReadOffset(buf[32:36]); o1 > size { + if sszVarOffset1 > size { return ssz.ErrOffset } + sszSlice1 := buf[sszVarOffset1:] // c.Result - if o1 != 36 { - return ssz.ErrInvalidVariableOffset - } + // Field 0: Root + c.Root = make([]byte, 0, 32) + c.Root = append(c.Root, sszSlice0...) - // Field (1) 'Result' - { - buf = tail[o1:] - if len(buf) > 1073741824 { - return ssz.ErrBytesLength - } - if cap(s.Result) == 0 { - s.Result = make([]byte, 0, len(buf)) - } - s.Result = append(s.Result, buf...) - } + // Field 1: Result + c.Result = append([]byte{}, sszSlice1...) return err } -// SizeSSZ returns the ssz encoded size in bytes for the SSZQueryResponse object -func (s *SSZQueryResponse) SizeSSZ() (size int) { - size = 36 - - // Field (1) 'Result' - size += len(s.Result) - - return -} - -// HashTreeRoot ssz hashes the SSZQueryResponse object -func (s *SSZQueryResponse) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) +func (c *SSZQueryResponse) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the SSZQueryResponse object with a hasher -func (s *SSZQueryResponse) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *SSZQueryResponse) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Root' - if size := len(s.Root); size != 32 { - err = ssz.ErrBytesLengthFn("--.Root", size, 32) - return + // Field 0: Root + if len(c.Root) != 32 { + return ssz.ErrBytesLength } - hh.PutBytes(s.Root) + hh.PutBytes(c.Root) + // Field 1: Result - // Field (1) 'Result' { - elemIndx := hh.Index() - byteLen := uint64(len(s.Result)) - if byteLen > 1073741824 { - err = ssz.ErrIncorrectListSize - return + if len(c.Result) > 1073741824 { + return ssz.ErrBytesLength } - hh.AppendBytes32(s.Result) - hh.MerkleizeWithMixin(elemIndx, byteLen, (1073741824+31)/32) + subIndx := hh.Index() + hh.AppendBytes32(c.Result) + numItems := uint64(len(c.Result)) + hh.MerkleizeWithMixin(subIndx, numItems, (1073741824*1+31)/32) } hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the SSZQueryResponseWithProof object -func (s *SSZQueryResponseWithProof) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(s) +func (c *SSZQueryResponseWithProof) SizeSSZ() int { + size := 40 + size += len(c.Result) + if c.Proof == nil { + c.Proof = new(SSZQueryProof) + } + size += c.Proof.SizeSSZ() + return size } -// MarshalSSZTo ssz marshals the SSZQueryResponseWithProof object to a target array -func (s *SSZQueryResponseWithProof) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(40) +func (c *SSZQueryResponseWithProof) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (0) 'Root' - if size := len(s.Root); size != 32 { - err = ssz.ErrBytesLengthFn("--.Root", size, 32) - return +func (c *SSZQueryResponseWithProof) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 40 + + // Field 0: Root + if len(c.Root) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, s.Root...) + dst = append(dst, c.Root...) - // Offset (1) 'Result' + // Field 1: Result dst = ssz.WriteOffset(dst, offset) - offset += len(s.Result) + offset += len(c.Result) - // Offset (2) 'Proof' - dst = ssz.WriteOffset(dst, offset) - if s.Proof == nil { - s.Proof = new(SSZQueryProof) + // Field 2: Proof + if c.Proof == nil { + c.Proof = new(SSZQueryProof) } - offset += s.Proof.SizeSSZ() + dst = ssz.WriteOffset(dst, offset) + offset += c.Proof.SizeSSZ() - // Field (1) 'Result' - if size := len(s.Result); size > 1073741824 { - err = ssz.ErrBytesLengthFn("--.Result", size, 1073741824) - return + // Field 1: Result + if len(c.Result) > 1073741824 { + return nil, ssz.ErrListTooBig } - dst = append(dst, s.Result...) + dst = append(dst, c.Result...) - // Field (2) 'Proof' - if dst, err = s.Proof.MarshalSSZTo(dst); err != nil { - return + // Field 2: Proof + if dst, err = c.Proof.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Proof: %w", err) } - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the SSZQueryResponseWithProof object -func (s *SSZQueryResponseWithProof) UnmarshalSSZ(buf []byte) error { +func (c *SSZQueryResponseWithProof) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size < 40 { return ssz.ErrSize } - tail := buf - var o1, o2 uint64 + sszSlice0 := buf[0:32] // c.Root - // Field (0) 'Root' - if cap(s.Root) == 0 { - s.Root = make([]byte, 0, len(buf[0:32])) + sszVarOffset1 := ssz.ReadOffset(buf[32:36]) // c.Result + if sszVarOffset1 != 40 { + return ssz.ErrInvalidVariableOffset } - s.Root = append(s.Root, buf[0:32]...) - - // Offset (1) 'Result' - if o1 = ssz.ReadOffset(buf[32:36]); o1 > size { + if sszVarOffset1 > size { return ssz.ErrOffset } - - if o1 != 40 { - return ssz.ErrInvalidVariableOffset - } - - // Offset (2) 'Proof' - if o2 = ssz.ReadOffset(buf[36:40]); o2 > size || o1 > o2 { + sszVarOffset2 := ssz.ReadOffset(buf[36:40]) // c.Proof + if sszVarOffset2 > size || sszVarOffset2 < sszVarOffset1 { return ssz.ErrOffset } + sszSlice1 := buf[sszVarOffset1:sszVarOffset2] // c.Result + sszSlice2 := buf[sszVarOffset2:] // c.Proof - // Field (1) 'Result' - { - buf = tail[o1:o2] - if len(buf) > 1073741824 { - return ssz.ErrBytesLength - } - if cap(s.Result) == 0 { - s.Result = make([]byte, 0, len(buf)) - } - s.Result = append(s.Result, buf...) - } + // Field 0: Root + c.Root = make([]byte, 0, 32) + c.Root = append(c.Root, sszSlice0...) - // Field (2) 'Proof' - { - buf = tail[o2:] - if s.Proof == nil { - s.Proof = new(SSZQueryProof) - } - if err = s.Proof.UnmarshalSSZ(buf); err != nil { - return err - } + // Field 1: Result + c.Result = append([]byte{}, sszSlice1...) + + // Field 2: Proof + c.Proof = new(SSZQueryProof) + if err = c.Proof.UnmarshalSSZ(sszSlice2); err != nil { + return fmt.Errorf("Proof: %w", err) } return err } -// SizeSSZ returns the ssz encoded size in bytes for the SSZQueryResponseWithProof object -func (s *SSZQueryResponseWithProof) SizeSSZ() (size int) { - size = 40 - - // Field (1) 'Result' - size += len(s.Result) - - // Field (2) 'Proof' - if s.Proof == nil { - s.Proof = new(SSZQueryProof) +func (c *SSZQueryResponseWithProof) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - size += s.Proof.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the SSZQueryResponseWithProof object -func (s *SSZQueryResponseWithProof) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(s) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the SSZQueryResponseWithProof object with a hasher -func (s *SSZQueryResponseWithProof) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *SSZQueryResponseWithProof) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Root' - if size := len(s.Root); size != 32 { - err = ssz.ErrBytesLengthFn("--.Root", size, 32) - return + // Field 0: Root + if len(c.Root) != 32 { + return ssz.ErrBytesLength } - hh.PutBytes(s.Root) + hh.PutBytes(c.Root) + // Field 1: Result - // Field (1) 'Result' { - elemIndx := hh.Index() - byteLen := uint64(len(s.Result)) - if byteLen > 1073741824 { - err = ssz.ErrIncorrectListSize - return + if len(c.Result) > 1073741824 { + return ssz.ErrBytesLength } - hh.AppendBytes32(s.Result) - hh.MerkleizeWithMixin(elemIndx, byteLen, (1073741824+31)/32) + subIndx := hh.Index() + hh.AppendBytes32(c.Result) + numItems := uint64(len(c.Result)) + hh.MerkleizeWithMixin(subIndx, numItems, (1073741824*1+31)/32) } - // Field (2) 'Proof' - if err = s.Proof.HashTreeRootWith(hh); err != nil { - return + // Field 2: Proof + if err := c.Proof.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Proof: %w", err) } - hh.Merkleize(indx) - return + return nil } diff --git a/proto/ssz_query/response.yaml b/proto/ssz_query/response.yaml new file mode 100644 index 000000000000..5eb8b9883223 --- /dev/null +++ b/proto/ssz_query/response.yaml @@ -0,0 +1,5 @@ +package: "github.com/OffchainLabs/prysm/v7/proto/ssz_query" +types: + - name: "SSZQueryProof" + - name: "SSZQueryResponse" + - name: "SSZQueryResponseWithProof" diff --git a/proto/ssz_query/testing/BUILD.bazel b/proto/ssz_query/testing/BUILD.bazel index 610857a34d4f..06f941e98ab3 100644 --- a/proto/ssz_query/testing/BUILD.bazel +++ b/proto/ssz_query/testing/BUILD.bazel @@ -2,7 +2,7 @@ load("@rules_proto//proto:defs.bzl", "proto_library") load("@io_bazel_rules_go//go:def.bzl", "go_library") load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") load("//proto:ssz_proto_library.bzl", "ssz_proto_files") -load("//tools:ssz.bzl", "SSZ_DEPS", "ssz_gen_marshal") +load("//tools:methodical.bzl", "ssz_methodical") # gazelle:ignore @@ -32,29 +32,27 @@ go_proto_library( ], ) -# SSZ generation for test proto messages -ssz_gen_marshal( - name = "ssz_generated", +# SSZ generation for test proto messages (methodical) +ssz_methodical( + name = "methodical_test_containers", + config_file = "test_containers.yaml", out = "test_containers.ssz.go", - go_proto = ":go_proto", - objs = [ - "FixedTestContainer", - "FixedNestedContainer", - "VariableTestContainer", - ], + override_package_name = "testing", + deps = [":go_proto"], ) go_library( name = "go_default_library", srcs = [ - ":ssz_generated", # keep + ":methodical_test_containers", # keep ], embed = [":go_proto"], importpath = "github.com/OffchainLabs/prysm/v7/proto/ssz_query/testing", visibility = ["//visibility:public"], - deps = SSZ_DEPS + [ + deps = [ "//proto/eth/ext:go_default_library", "@com_github_golang_protobuf//proto:go_default_library", + "@com_github_offchainlabs_methodical_ssz//ssz:go_default_library", "@com_github_prysmaticlabs_go_bitfield//:go_default_library", ], ) diff --git a/proto/ssz_query/testing/test_containers.minimal.ssz.go b/proto/ssz_query/testing/test_containers.minimal.ssz.go new file mode 100644 index 000000000000..109495ad2468 --- /dev/null +++ b/proto/ssz_query/testing/test_containers.minimal.ssz.go @@ -0,0 +1,1127 @@ +//go:build minimal + +package testing + +import ( + binary "encoding/binary" + "fmt" + go_bitfield "github.com/OffchainLabs/go-bitfield" + ssz "github.com/OffchainLabs/methodical-ssz/ssz" +) + +func (c *FixedNestedContainer) SizeSSZ() int { + size := 40 + + return size +} + +func (c *FixedNestedContainer) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} + +func (c *FixedNestedContainer) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + + // Field 0: Value1 + dst = binary.LittleEndian.AppendUint64(dst, c.Value1) + + // Field 1: Value2 + if len(c.Value2) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.Value2...) + + return dst, err +} + +func (c *FixedNestedContainer) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 40 { + return ssz.ErrSize + } + + sszSlice0 := buf[0:8] // c.Value1 + sszSlice1 := buf[8:40] // c.Value2 + + // Field 0: Value1 + c.Value1 = binary.LittleEndian.Uint64(sszSlice0) + + // Field 1: Value2 + c.Value2 = make([]byte, 0, 32) + c.Value2 = append(c.Value2, sszSlice1...) + return err +} + +func (c *FixedNestedContainer) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} + +func (c *FixedNestedContainer) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Value1 + hh.PutUint64(c.Value1) + // Field 1: Value2 + if len(c.Value2) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.Value2) + hh.Merkleize(indx) + return nil +} + +func (c *FixedTestContainer) SizeSSZ() int { + size := 565 + + return size +} + +func (c *FixedTestContainer) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} + +func (c *FixedTestContainer) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + + // Field 0: FieldUint32 + dst = binary.LittleEndian.AppendUint32(dst, c.FieldUint32) + + // Field 1: FieldUint64 + dst = binary.LittleEndian.AppendUint64(dst, c.FieldUint64) + + // Field 2: FieldBool + if c.FieldBool { + dst = append(dst, 1) + } else { + dst = append(dst, 0) + } + + // Field 3: FieldBytes32 + if len(c.FieldBytes32) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.FieldBytes32...) + + // Field 4: Nested + if c.Nested == nil { + c.Nested = new(FixedNestedContainer) + } + if dst, err = c.Nested.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Nested: %w", err) + } + + // Field 5: VectorField + if len(c.VectorField) != 24 { + return nil, ssz.ErrBytesLength + } + for _, o := range c.VectorField { + dst = binary.LittleEndian.AppendUint64(dst, o) + } + + // Field 6: TwoDimensionBytesField + if len(c.TwoDimensionBytesField) != 5 { + return nil, ssz.ErrBytesLength + } + for _, o := range c.TwoDimensionBytesField { + if len(o) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) + } + + // Field 7: Bitvector64Field + if len([]byte(c.Bitvector64Field)) != 8 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, []byte(c.Bitvector64Field)...) + + // Field 8: Bitvector512Field + if len([]byte(c.Bitvector512Field)) != 64 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, []byte(c.Bitvector512Field)...) + + // Field 9: TrailingField + if len(c.TrailingField) != 56 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.TrailingField...) + + return dst, err +} + +func (c *FixedTestContainer) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 565 { + return ssz.ErrSize + } + + sszSlice0 := buf[0:4] // c.FieldUint32 + sszSlice1 := buf[4:12] // c.FieldUint64 + sszSlice2 := buf[12:13] // c.FieldBool + sszSlice3 := buf[13:45] // c.FieldBytes32 + sszSlice4 := buf[45:85] // c.Nested + sszSlice5 := buf[85:277] // c.VectorField + sszSlice6 := buf[277:437] // c.TwoDimensionBytesField + sszSlice7 := buf[437:445] // c.Bitvector64Field + sszSlice8 := buf[445:509] // c.Bitvector512Field + sszSlice9 := buf[509:565] // c.TrailingField + + // Field 0: FieldUint32 + c.FieldUint32 = binary.LittleEndian.Uint32(sszSlice0) + + // Field 1: FieldUint64 + c.FieldUint64 = binary.LittleEndian.Uint64(sszSlice1) + + // Field 2: FieldBool + if sszSlice2[0] > 1 { + return ssz.ErrInvalidSerialization + } + if sszSlice2[0] == 1 { + c.FieldBool = true + } else { + c.FieldBool = false + } + + // Field 3: FieldBytes32 + c.FieldBytes32 = make([]byte, 0, 32) + c.FieldBytes32 = append(c.FieldBytes32, sszSlice3...) + + // Field 4: Nested + c.Nested = new(FixedNestedContainer) + if err = c.Nested.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("Nested: %w", err) + } + + // Field 5: VectorField + { + c.VectorField = make([]uint64, 24) + for i := 0; i < 24; i++ { + var tmp uint64 + + tmpSlice := sszSlice5[i*8 : (1+i)*8] + tmp = binary.LittleEndian.Uint64(tmpSlice) + c.VectorField[i] = tmp + } + } + + // Field 6: TwoDimensionBytesField + { + c.TwoDimensionBytesField = make([][]byte, 5) + for i := 0; i < 5; i++ { + var tmp []byte + + tmpSlice := sszSlice6[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.TwoDimensionBytesField[i] = tmp + } + } + + // Field 7: Bitvector64Field + c.Bitvector64Field = make([]byte, 0, 8) + c.Bitvector64Field = append(c.Bitvector64Field, go_bitfield.Bitvector64(sszSlice7)...) + + // Field 8: Bitvector512Field + c.Bitvector512Field = make([]byte, 0, 64) + c.Bitvector512Field = append(c.Bitvector512Field, go_bitfield.Bitvector512(sszSlice8)...) + + // Field 9: TrailingField + c.TrailingField = make([]byte, 0, 56) + c.TrailingField = append(c.TrailingField, sszSlice9...) + return err +} + +func (c *FixedTestContainer) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} + +func (c *FixedTestContainer) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: FieldUint32 + hh.PutUint32(c.FieldUint32) + // Field 1: FieldUint64 + hh.PutUint64(c.FieldUint64) + // Field 2: FieldBool + hh.PutBool(c.FieldBool) + // Field 3: FieldBytes32 + if len(c.FieldBytes32) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.FieldBytes32) + // Field 4: Nested + if err := c.Nested.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Nested: %w", err) + } + // Field 5: VectorField + { + if len(c.VectorField) != 24 { + return ssz.ErrVectorLength + } + subIndx := hh.Index() + for _, o := range c.VectorField { + hh.AppendUint64(o) + } + hh.Merkleize(subIndx) + } + // Field 6: TwoDimensionBytesField + { + if len(c.TwoDimensionBytesField) != 5 { + return ssz.ErrVectorLength + } + subIndx := hh.Index() + for _, o := range c.TwoDimensionBytesField { + if len(o) != 32 { + return ssz.ErrBytesLength + } + hh.Append(o) + } + hh.Merkleize(subIndx) + } + // Field 7: Bitvector64Field + if len([]byte(c.Bitvector64Field)) != 8 { + return ssz.ErrBytesLength + } + hh.PutBytes([]byte(c.Bitvector64Field)) + // Field 8: Bitvector512Field + if len([]byte(c.Bitvector512Field)) != 64 { + return ssz.ErrBytesLength + } + hh.PutBytes([]byte(c.Bitvector512Field)) + // Field 9: TrailingField + if len(c.TrailingField) != 56 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.TrailingField) + hh.Merkleize(indx) + return nil +} + +func (c *VariableNestedContainer) SizeSSZ() int { + size := 16 + size += len(c.FieldListUint64) * 8 + for _, o := range c.NestedListField { + size += 4 + size += len(o) + } + return size +} + +func (c *VariableNestedContainer) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} + +func (c *VariableNestedContainer) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 16 + + // Field 0: Value1 + dst = binary.LittleEndian.AppendUint64(dst, c.Value1) + + // Field 1: FieldListUint64 + dst = ssz.WriteOffset(dst, offset) + offset += len(c.FieldListUint64) * 8 + + // Field 2: NestedListField + dst = ssz.WriteOffset(dst, offset) + for _, o := range c.NestedListField { + offset += 4 + offset += len(o) + } + + // Field 1: FieldListUint64 + if len(c.FieldListUint64) > 100 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.FieldListUint64 { + dst = binary.LittleEndian.AppendUint64(dst, o) + } + + // Field 2: NestedListField + if len(c.NestedListField) > 100 { + return nil, ssz.ErrListTooBig + } + { + offset = 4 * len(c.NestedListField) + for _, o := range c.NestedListField { + dst = ssz.WriteOffset(dst, offset) + offset += len(o) + } + } + for _, o := range c.NestedListField { + if len(o) > 50 { + return nil, ssz.ErrListTooBig + } + dst = append(dst, o...) + } + return dst, err +} + +func (c *VariableNestedContainer) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 16 { + return ssz.ErrSize + } + + sszSlice0 := buf[0:8] // c.Value1 + + sszVarOffset1 := ssz.ReadOffset(buf[8:12]) // c.FieldListUint64 + if sszVarOffset1 != 16 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset1 > size { + return ssz.ErrOffset + } + sszVarOffset2 := ssz.ReadOffset(buf[12:16]) // c.NestedListField + if sszVarOffset2 > size || sszVarOffset2 < sszVarOffset1 { + return ssz.ErrOffset + } + sszSlice1 := buf[sszVarOffset1:sszVarOffset2] // c.FieldListUint64 + sszSlice2 := buf[sszVarOffset2:] // c.NestedListField + + // Field 0: Value1 + c.Value1 = binary.LittleEndian.Uint64(sszSlice0) + + // Field 1: FieldListUint64 + { + if len(sszSlice1)%8 != 0 { + return fmt.Errorf("misaligned bytes: c.FieldListUint64 length is %d, which is not a multiple of 8: %w", len(sszSlice1), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice1) / 8 + if numElem > 100 { + return fmt.Errorf("ssz-max exceeded: c.FieldListUint64 has %d elements, ssz-max is 100: %w", numElem, ssz.ErrListTooBig) + } + c.FieldListUint64 = make([]uint64, numElem) + for i := 0; i < numElem; i++ { + var tmp uint64 + + tmpSlice := sszSlice1[i*8 : (1+i)*8] + tmp = binary.LittleEndian.Uint64(tmpSlice) + c.FieldListUint64[i] = tmp + } + } + + // Field 2: NestedListField + { + // empty lists are zero length, so make sure there is room for an offset + // before attempting to unmarshal it + if len(sszSlice2) > 3 { + startOffset := ssz.ReadOffset(sszSlice2[0:4]) + if startOffset == 0 { + return fmt.Errorf("encountered invalid offset of 0 when decoding c.NestedListField") + } + if startOffset%4 != 0 { + return fmt.Errorf("misaligned list bytes: when decoding c.NestedListField, end-of-list offset is %d, which is not a multiple of 4 (offset size)", startOffset) + } + listLen := startOffset / 4 + if listLen > 100 { + return fmt.Errorf("ssz-max exceeded: c.NestedListField has %d elements, ssz-max is 100: %w", listLen, ssz.ErrListTooBig) + } + totalVarBytes := uint64(len(sszSlice2)) + if totalVarBytes < startOffset { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.NestedListField") + } + c.NestedListField = make([][]byte, listLen) + var tmpSlice []byte + for i := uint64(0); i < listLen; i++ { + var tmp []byte + + endOffset := totalVarBytes + if i+1 != listLen { + endOffset = ssz.ReadOffset(sszSlice2[(i+1)*4 : (i+2)*4]) + if totalVarBytes < endOffset { + return fmt.Errorf("offset %d points past the end of buffer when decoding c.NestedListField", endOffset) + } + } + if endOffset < startOffset { + return fmt.Errorf("offset %d is not greater than start offset %d when decoding c.NestedListField", endOffset, startOffset) + } + tmpSlice = sszSlice2[startOffset:endOffset] + tmp = append([]byte{}, tmpSlice...) + c.NestedListField[i] = tmp + startOffset = endOffset + } + } else { + if len(sszSlice2) > 0 { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.NestedListField") + } + c.NestedListField = make([][]byte, 0) + } + } + return err +} + +func (c *VariableNestedContainer) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} + +func (c *VariableNestedContainer) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Value1 + hh.PutUint64(c.Value1) + // Field 1: FieldListUint64 + { + if len(c.FieldListUint64) > 100 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.FieldListUint64 { + hh.AppendUint64(o) + } + hh.FillUpTo32() + numItems := uint64(len(c.FieldListUint64)) + hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(100, numItems, 8)) + } + // Field 2: NestedListField + { + if len(c.NestedListField) > 100 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.NestedListField { + + { + if len(o) > 50 { + return ssz.ErrBytesLength + } + subIndx := hh.Index() + hh.AppendBytes32(o) + numItems := uint64(len(o)) + hh.MerkleizeWithMixin(subIndx, numItems, (50*1+31)/32) + } + + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.NestedListField)), 100) + } + hh.Merkleize(indx) + return nil +} + +func (c *VariableOuterContainer) SizeSSZ() int { + size := 8 + if c.Inner_1 == nil { + c.Inner_1 = new(VariableNestedContainer) + } + size += c.Inner_1.SizeSSZ() + if c.Inner_2 == nil { + c.Inner_2 = new(VariableNestedContainer) + } + size += c.Inner_2.SizeSSZ() + return size +} + +func (c *VariableOuterContainer) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} + +func (c *VariableOuterContainer) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 8 + + // Field 0: Inner_1 + if c.Inner_1 == nil { + c.Inner_1 = new(VariableNestedContainer) + } + dst = ssz.WriteOffset(dst, offset) + offset += c.Inner_1.SizeSSZ() + + // Field 1: Inner_2 + if c.Inner_2 == nil { + c.Inner_2 = new(VariableNestedContainer) + } + dst = ssz.WriteOffset(dst, offset) + offset += c.Inner_2.SizeSSZ() + + // Field 0: Inner_1 + if dst, err = c.Inner_1.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Inner_1: %w", err) + } + + // Field 1: Inner_2 + if dst, err = c.Inner_2.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Inner_2: %w", err) + } + return dst, err +} + +func (c *VariableOuterContainer) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 8 { + return ssz.ErrSize + } + + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Inner_1 + if sszVarOffset0 != 8 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset0 > size { + return ssz.ErrOffset + } + sszVarOffset1 := ssz.ReadOffset(buf[4:8]) // c.Inner_2 + if sszVarOffset1 > size || sszVarOffset1 < sszVarOffset0 { + return ssz.ErrOffset + } + sszSlice0 := buf[sszVarOffset0:sszVarOffset1] // c.Inner_1 + sszSlice1 := buf[sszVarOffset1:] // c.Inner_2 + + // Field 0: Inner_1 + c.Inner_1 = new(VariableNestedContainer) + if err = c.Inner_1.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Inner_1: %w", err) + } + + // Field 1: Inner_2 + c.Inner_2 = new(VariableNestedContainer) + if err = c.Inner_2.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Inner_2: %w", err) + } + return err +} + +func (c *VariableOuterContainer) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} + +func (c *VariableOuterContainer) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: Inner_1 + if err := c.Inner_1.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Inner_1: %w", err) + } + // Field 1: Inner_2 + if err := c.Inner_2.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Inner_2: %w", err) + } + hh.Merkleize(indx) + return nil +} + +func (c *VariableTestContainer) SizeSSZ() int { + size := 116 + size += len(c.FieldListUint64) * 8 + size += len(c.FieldListContainer) * 40 + size += len(c.FieldListBytes32) * 32 + if c.Nested == nil { + c.Nested = new(VariableNestedContainer) + } + size += c.Nested.SizeSSZ() + for _, o := range c.VariableContainerList { + size += 4 + size += o.SizeSSZ() + } + size += len(c.BitlistField) + for _, o := range c.NestedListField { + size += 4 + size += len(o) + } + return size +} + +func (c *VariableTestContainer) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} + +func (c *VariableTestContainer) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 116 + + // Field 0: LeadingField + if len(c.LeadingField) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.LeadingField...) + + // Field 1: FieldListUint64 + dst = ssz.WriteOffset(dst, offset) + offset += len(c.FieldListUint64) * 8 + + // Field 2: FieldListContainer + dst = ssz.WriteOffset(dst, offset) + offset += len(c.FieldListContainer) * 40 + + // Field 3: FieldListBytes32 + dst = ssz.WriteOffset(dst, offset) + offset += len(c.FieldListBytes32) * 32 + + // Field 4: Nested + if c.Nested == nil { + c.Nested = new(VariableNestedContainer) + } + dst = ssz.WriteOffset(dst, offset) + offset += c.Nested.SizeSSZ() + + // Field 5: VariableContainerList + dst = ssz.WriteOffset(dst, offset) + for _, o := range c.VariableContainerList { + offset += 4 + offset += o.SizeSSZ() + } + + // Field 6: BitlistField + dst = ssz.WriteOffset(dst, offset) + offset += len(c.BitlistField) + + // Field 7: NestedListField + dst = ssz.WriteOffset(dst, offset) + for _, o := range c.NestedListField { + offset += 4 + offset += len(o) + } + + // Field 8: TrailingField + if len(c.TrailingField) != 56 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, c.TrailingField...) + + // Field 1: FieldListUint64 + if len(c.FieldListUint64) > 2048 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.FieldListUint64 { + dst = binary.LittleEndian.AppendUint64(dst, o) + } + + // Field 2: FieldListContainer + if len(c.FieldListContainer) > 128 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.FieldListContainer { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("FieldListContainer: %w", err) + } + } + + // Field 3: FieldListBytes32 + if len(c.FieldListBytes32) > 100 { + return nil, ssz.ErrListTooBig + } + for _, o := range c.FieldListBytes32 { + if len(o) != 32 { + return nil, ssz.ErrBytesLength + } + dst = append(dst, o...) + } + + // Field 4: Nested + if dst, err = c.Nested.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Nested: %w", err) + } + + // Field 5: VariableContainerList + if len(c.VariableContainerList) > 10 { + return nil, ssz.ErrListTooBig + } + { + offset = 4 * len(c.VariableContainerList) + for _, o := range c.VariableContainerList { + dst = ssz.WriteOffset(dst, offset) + offset += o.SizeSSZ() + } + } + for _, o := range c.VariableContainerList { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("VariableContainerList: %w", err) + } + } + + // Field 6: BitlistField + if len(c.BitlistField) > 2048 { + return nil, ssz.ErrListTooBig + } + dst = append(dst, c.BitlistField...) + + // Field 7: NestedListField + if len(c.NestedListField) > 100 { + return nil, ssz.ErrListTooBig + } + { + offset = 4 * len(c.NestedListField) + for _, o := range c.NestedListField { + dst = ssz.WriteOffset(dst, offset) + offset += len(o) + } + } + for _, o := range c.NestedListField { + if len(o) > 50 { + return nil, ssz.ErrListTooBig + } + dst = append(dst, o...) + } + return dst, err +} + +func (c *VariableTestContainer) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 116 { + return ssz.ErrSize + } + + sszSlice0 := buf[0:32] // c.LeadingField + sszSlice8 := buf[60:116] // c.TrailingField + + sszVarOffset1 := ssz.ReadOffset(buf[32:36]) // c.FieldListUint64 + if sszVarOffset1 != 116 { + return ssz.ErrInvalidVariableOffset + } + if sszVarOffset1 > size { + return ssz.ErrOffset + } + sszVarOffset2 := ssz.ReadOffset(buf[36:40]) // c.FieldListContainer + if sszVarOffset2 > size || sszVarOffset2 < sszVarOffset1 { + return ssz.ErrOffset + } + sszVarOffset3 := ssz.ReadOffset(buf[40:44]) // c.FieldListBytes32 + if sszVarOffset3 > size || sszVarOffset3 < sszVarOffset2 { + return ssz.ErrOffset + } + sszVarOffset4 := ssz.ReadOffset(buf[44:48]) // c.Nested + if sszVarOffset4 > size || sszVarOffset4 < sszVarOffset3 { + return ssz.ErrOffset + } + sszVarOffset5 := ssz.ReadOffset(buf[48:52]) // c.VariableContainerList + if sszVarOffset5 > size || sszVarOffset5 < sszVarOffset4 { + return ssz.ErrOffset + } + sszVarOffset6 := ssz.ReadOffset(buf[52:56]) // c.BitlistField + if sszVarOffset6 > size || sszVarOffset6 < sszVarOffset5 { + return ssz.ErrOffset + } + sszVarOffset7 := ssz.ReadOffset(buf[56:60]) // c.NestedListField + if sszVarOffset7 > size || sszVarOffset7 < sszVarOffset6 { + return ssz.ErrOffset + } + sszSlice1 := buf[sszVarOffset1:sszVarOffset2] // c.FieldListUint64 + sszSlice2 := buf[sszVarOffset2:sszVarOffset3] // c.FieldListContainer + sszSlice3 := buf[sszVarOffset3:sszVarOffset4] // c.FieldListBytes32 + sszSlice4 := buf[sszVarOffset4:sszVarOffset5] // c.Nested + sszSlice5 := buf[sszVarOffset5:sszVarOffset6] // c.VariableContainerList + sszSlice6 := buf[sszVarOffset6:sszVarOffset7] // c.BitlistField + sszSlice7 := buf[sszVarOffset7:] // c.NestedListField + + // Field 0: LeadingField + c.LeadingField = make([]byte, 0, 32) + c.LeadingField = append(c.LeadingField, sszSlice0...) + + // Field 1: FieldListUint64 + { + if len(sszSlice1)%8 != 0 { + return fmt.Errorf("misaligned bytes: c.FieldListUint64 length is %d, which is not a multiple of 8: %w", len(sszSlice1), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice1) / 8 + if numElem > 2048 { + return fmt.Errorf("ssz-max exceeded: c.FieldListUint64 has %d elements, ssz-max is 2048: %w", numElem, ssz.ErrListTooBig) + } + c.FieldListUint64 = make([]uint64, numElem) + for i := 0; i < numElem; i++ { + var tmp uint64 + + tmpSlice := sszSlice1[i*8 : (1+i)*8] + tmp = binary.LittleEndian.Uint64(tmpSlice) + c.FieldListUint64[i] = tmp + } + } + + // Field 2: FieldListContainer + { + if len(sszSlice2)%40 != 0 { + return fmt.Errorf("misaligned bytes: c.FieldListContainer length is %d, which is not a multiple of 40: %w", len(sszSlice2), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice2) / 40 + if numElem > 128 { + return fmt.Errorf("ssz-max exceeded: c.FieldListContainer has %d elements, ssz-max is 128: %w", numElem, ssz.ErrListTooBig) + } + c.FieldListContainer = make([]*FixedNestedContainer, numElem) + for i := 0; i < numElem; i++ { + var tmp *FixedNestedContainer + tmp = new(FixedNestedContainer) + tmpSlice := sszSlice2[i*40 : (1+i)*40] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("FieldListContainer: %w", err) + } + c.FieldListContainer[i] = tmp + } + } + + // Field 3: FieldListBytes32 + { + if len(sszSlice3)%32 != 0 { + return fmt.Errorf("misaligned bytes: c.FieldListBytes32 length is %d, which is not a multiple of 32: %w", len(sszSlice3), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice3) / 32 + if numElem > 100 { + return fmt.Errorf("ssz-max exceeded: c.FieldListBytes32 has %d elements, ssz-max is 100: %w", numElem, ssz.ErrListTooBig) + } + c.FieldListBytes32 = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte + + tmpSlice := sszSlice3[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.FieldListBytes32[i] = tmp + } + } + + // Field 4: Nested + c.Nested = new(VariableNestedContainer) + if err = c.Nested.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("Nested: %w", err) + } + + // Field 5: VariableContainerList + { + // empty lists are zero length, so make sure there is room for an offset + // before attempting to unmarshal it + if len(sszSlice5) > 3 { + startOffset := ssz.ReadOffset(sszSlice5[0:4]) + if startOffset == 0 { + return fmt.Errorf("encountered invalid offset of 0 when decoding c.VariableContainerList") + } + if startOffset%4 != 0 { + return fmt.Errorf("misaligned list bytes: when decoding c.VariableContainerList, end-of-list offset is %d, which is not a multiple of 4 (offset size)", startOffset) + } + listLen := startOffset / 4 + if listLen > 10 { + return fmt.Errorf("ssz-max exceeded: c.VariableContainerList has %d elements, ssz-max is 10: %w", listLen, ssz.ErrListTooBig) + } + totalVarBytes := uint64(len(sszSlice5)) + if totalVarBytes < startOffset { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.VariableContainerList") + } + c.VariableContainerList = make([]*VariableOuterContainer, listLen) + var tmpSlice []byte + for i := uint64(0); i < listLen; i++ { + var tmp *VariableOuterContainer + tmp = new(VariableOuterContainer) + endOffset := totalVarBytes + if i+1 != listLen { + endOffset = ssz.ReadOffset(sszSlice5[(i+1)*4 : (i+2)*4]) + if totalVarBytes < endOffset { + return fmt.Errorf("offset %d points past the end of buffer when decoding c.VariableContainerList", endOffset) + } + } + if endOffset < startOffset { + return fmt.Errorf("offset %d is not greater than start offset %d when decoding c.VariableContainerList", endOffset, startOffset) + } + tmpSlice = sszSlice5[startOffset:endOffset] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("VariableContainerList: %w", err) + } + c.VariableContainerList[i] = tmp + startOffset = endOffset + } + } else { + if len(sszSlice5) > 0 { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.VariableContainerList") + } + c.VariableContainerList = make([]*VariableOuterContainer, 0) + } + } + + // Field 6: BitlistField + if err = ssz.ValidateBitlist(sszSlice6, 2048); err != nil { + return fmt.Errorf("BitlistField: %w", err) + } + c.BitlistField = append([]byte{}, go_bitfield.Bitlist(sszSlice6)...) + + // Field 7: NestedListField + { + // empty lists are zero length, so make sure there is room for an offset + // before attempting to unmarshal it + if len(sszSlice7) > 3 { + startOffset := ssz.ReadOffset(sszSlice7[0:4]) + if startOffset == 0 { + return fmt.Errorf("encountered invalid offset of 0 when decoding c.NestedListField") + } + if startOffset%4 != 0 { + return fmt.Errorf("misaligned list bytes: when decoding c.NestedListField, end-of-list offset is %d, which is not a multiple of 4 (offset size)", startOffset) + } + listLen := startOffset / 4 + if listLen > 100 { + return fmt.Errorf("ssz-max exceeded: c.NestedListField has %d elements, ssz-max is 100: %w", listLen, ssz.ErrListTooBig) + } + totalVarBytes := uint64(len(sszSlice7)) + if totalVarBytes < startOffset { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.NestedListField") + } + c.NestedListField = make([][]byte, listLen) + var tmpSlice []byte + for i := uint64(0); i < listLen; i++ { + var tmp []byte + + endOffset := totalVarBytes + if i+1 != listLen { + endOffset = ssz.ReadOffset(sszSlice7[(i+1)*4 : (i+2)*4]) + if totalVarBytes < endOffset { + return fmt.Errorf("offset %d points past the end of buffer when decoding c.NestedListField", endOffset) + } + } + if endOffset < startOffset { + return fmt.Errorf("offset %d is not greater than start offset %d when decoding c.NestedListField", endOffset, startOffset) + } + tmpSlice = sszSlice7[startOffset:endOffset] + tmp = append([]byte{}, tmpSlice...) + c.NestedListField[i] = tmp + startOffset = endOffset + } + } else { + if len(sszSlice7) > 0 { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.NestedListField") + } + c.NestedListField = make([][]byte, 0) + } + } + + // Field 8: TrailingField + c.TrailingField = make([]byte, 0, 56) + c.TrailingField = append(c.TrailingField, sszSlice8...) + return err +} + +func (c *VariableTestContainer) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err +} + +func (c *VariableTestContainer) HashTreeRootWith(hh *ssz.Hasher) (err error) { + indx := hh.Index() + // Field 0: LeadingField + if len(c.LeadingField) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.LeadingField) + // Field 1: FieldListUint64 + { + if len(c.FieldListUint64) > 2048 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.FieldListUint64 { + hh.AppendUint64(o) + } + hh.FillUpTo32() + numItems := uint64(len(c.FieldListUint64)) + hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(2048, numItems, 8)) + } + // Field 2: FieldListContainer + { + if len(c.FieldListContainer) > 128 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.FieldListContainer { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("FieldListContainer: %w", err) + } + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.FieldListContainer)), 128) + } + // Field 3: FieldListBytes32 + { + if len(c.FieldListBytes32) > 100 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.FieldListBytes32 { + if len(o) != 32 { + return ssz.ErrBytesLength + } + hh.Append(o) + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.FieldListBytes32)), 100) + } + // Field 4: Nested + if err := c.Nested.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Nested: %w", err) + } + // Field 5: VariableContainerList + { + if len(c.VariableContainerList) > 10 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.VariableContainerList { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("VariableContainerList: %w", err) + } + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.VariableContainerList)), 10) + } + // Field 6: BitlistField + if len(c.BitlistField) == 0 { + return ssz.ErrEmptyBitlist + } + hh.PutBitlist(c.BitlistField, 2048) + // Field 7: NestedListField + { + if len(c.NestedListField) > 100 { + return ssz.ErrListTooBig + } + subIndx := hh.Index() + for _, o := range c.NestedListField { + + { + if len(o) > 50 { + return ssz.ErrBytesLength + } + subIndx := hh.Index() + hh.AppendBytes32(o) + numItems := uint64(len(o)) + hh.MerkleizeWithMixin(subIndx, numItems, (50*1+31)/32) + } + + } + hh.MerkleizeWithMixin(subIndx, uint64(len(c.NestedListField)), 100) + } + // Field 8: TrailingField + if len(c.TrailingField) != 56 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.TrailingField) + hh.Merkleize(indx) + return nil +} diff --git a/proto/ssz_query/testing/test_containers.ssz.go b/proto/ssz_query/testing/test_containers.ssz.go index 5b3c568adf39..9bbd33b6f862 100644 --- a/proto/ssz_query/testing/test_containers.ssz.go +++ b/proto/ssz_query/testing/test_containers.ssz.go @@ -1,1130 +1,1127 @@ -// Code generated by fastssz. DO NOT EDIT. +//go:build !minimal + package testing import ( - ssz "github.com/prysmaticlabs/fastssz" + binary "encoding/binary" + "fmt" + go_bitfield "github.com/OffchainLabs/go-bitfield" + ssz "github.com/OffchainLabs/methodical-ssz/ssz" ) -// MarshalSSZ ssz marshals the FixedNestedContainer object -func (f *FixedNestedContainer) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(f) +func (c *FixedNestedContainer) SizeSSZ() int { + size := 40 + + return size } -// MarshalSSZTo ssz marshals the FixedNestedContainer object to a target array -func (f *FixedNestedContainer) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *FixedNestedContainer) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (0) 'Value1' - dst = ssz.MarshalUint(dst, f.Value1) +func (c *FixedNestedContainer) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (1) 'Value2' - if size := len(f.Value2); size != 32 { - err = ssz.ErrBytesLengthFn("--.Value2", size, 32) - return + // Field 0: Value1 + dst = binary.LittleEndian.AppendUint64(dst, c.Value1) + + // Field 1: Value2 + if len(c.Value2) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, f.Value2...) + dst = append(dst, c.Value2...) - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the FixedNestedContainer object -func (f *FixedNestedContainer) UnmarshalSSZ(buf []byte) error { +func (c *FixedNestedContainer) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size != 40 { return ssz.ErrSize } - // Field (0) 'Value1' - f.Value1 = ssz.UnmarshallUint[uint64](buf[0:8]) + sszSlice0 := buf[0:8] // c.Value1 + sszSlice1 := buf[8:40] // c.Value2 - // Field (1) 'Value2' - if cap(f.Value2) == 0 { - f.Value2 = make([]byte, 0, len(buf[8:40])) - } - f.Value2 = append(f.Value2, buf[8:40]...) + // Field 0: Value1 + c.Value1 = binary.LittleEndian.Uint64(sszSlice0) + // Field 1: Value2 + c.Value2 = make([]byte, 0, 32) + c.Value2 = append(c.Value2, sszSlice1...) return err } -// SizeSSZ returns the ssz encoded size in bytes for the FixedNestedContainer object -func (f *FixedNestedContainer) SizeSSZ() (size int) { - size = 40 - return -} - -// HashTreeRoot ssz hashes the FixedNestedContainer object -func (f *FixedNestedContainer) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(f) +func (c *FixedNestedContainer) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the FixedNestedContainer object with a hasher -func (f *FixedNestedContainer) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *FixedNestedContainer) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Value1' - ssz.PutUint(hh, f.Value1) - - // Field (1) 'Value2' - if size := len(f.Value2); size != 32 { - err = ssz.ErrBytesLengthFn("--.Value2", size, 32) - return + // Field 0: Value1 + hh.PutUint64(c.Value1) + // Field 1: Value2 + if len(c.Value2) != 32 { + return ssz.ErrBytesLength } - hh.PutBytes(f.Value2) - + hh.PutBytes(c.Value2) hh.Merkleize(indx) - return + return nil +} + +func (c *FixedTestContainer) SizeSSZ() int { + size := 565 + + return size } -// MarshalSSZ ssz marshals the FixedTestContainer object -func (f *FixedTestContainer) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(f) +func (c *FixedTestContainer) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the FixedTestContainer object to a target array -func (f *FixedTestContainer) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf +func (c *FixedTestContainer) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error - // Field (0) 'FieldUint32' - dst = ssz.MarshalUint(dst, f.FieldUint32) + // Field 0: FieldUint32 + dst = binary.LittleEndian.AppendUint32(dst, c.FieldUint32) - // Field (1) 'FieldUint64' - dst = ssz.MarshalUint(dst, f.FieldUint64) + // Field 1: FieldUint64 + dst = binary.LittleEndian.AppendUint64(dst, c.FieldUint64) - // Field (2) 'FieldBool' - dst = ssz.MarshalBool(dst, f.FieldBool) + // Field 2: FieldBool + if c.FieldBool { + dst = append(dst, 1) + } else { + dst = append(dst, 0) + } - // Field (3) 'FieldBytes32' - if size := len(f.FieldBytes32); size != 32 { - err = ssz.ErrBytesLengthFn("--.FieldBytes32", size, 32) - return + // Field 3: FieldBytes32 + if len(c.FieldBytes32) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, f.FieldBytes32...) + dst = append(dst, c.FieldBytes32...) - // Field (4) 'Nested' - if f.Nested == nil { - f.Nested = new(FixedNestedContainer) + // Field 4: Nested + if c.Nested == nil { + c.Nested = new(FixedNestedContainer) } - if dst, err = f.Nested.MarshalSSZTo(dst); err != nil { - return + if dst, err = c.Nested.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Nested: %w", err) } - // Field (5) 'VectorField' - if size := len(f.VectorField); size != 24 { - err = ssz.ErrVectorLengthFn("--.VectorField", size, 24) - return + // Field 5: VectorField + if len(c.VectorField) != 24 { + return nil, ssz.ErrBytesLength } - for ii := 0; ii < 24; ii++ { - dst = ssz.MarshalUint(dst, f.VectorField[ii]) + for _, o := range c.VectorField { + dst = binary.LittleEndian.AppendUint64(dst, o) } - // Field (6) 'TwoDimensionBytesField' - if size := len(f.TwoDimensionBytesField); size != 5 { - err = ssz.ErrVectorLengthFn("--.TwoDimensionBytesField", size, 5) - return + // Field 6: TwoDimensionBytesField + if len(c.TwoDimensionBytesField) != 5 { + return nil, ssz.ErrBytesLength } - for ii := 0; ii < 5; ii++ { - if size := len(f.TwoDimensionBytesField[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.TwoDimensionBytesField[ii]", size, 32) - return + for _, o := range c.TwoDimensionBytesField { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, f.TwoDimensionBytesField[ii]...) + dst = append(dst, o...) } - // Field (7) 'Bitvector64Field' - if size := len(f.Bitvector64Field); size != 8 { - err = ssz.ErrBytesLengthFn("--.Bitvector64Field", size, 8) - return + // Field 7: Bitvector64Field + if len([]byte(c.Bitvector64Field)) != 8 { + return nil, ssz.ErrBytesLength } - dst = append(dst, f.Bitvector64Field...) + dst = append(dst, []byte(c.Bitvector64Field)...) - // Field (8) 'Bitvector512Field' - if size := len(f.Bitvector512Field); size != 64 { - err = ssz.ErrBytesLengthFn("--.Bitvector512Field", size, 64) - return + // Field 8: Bitvector512Field + if len([]byte(c.Bitvector512Field)) != 64 { + return nil, ssz.ErrBytesLength } - dst = append(dst, f.Bitvector512Field...) + dst = append(dst, []byte(c.Bitvector512Field)...) - // Field (9) 'TrailingField' - if size := len(f.TrailingField); size != 56 { - err = ssz.ErrBytesLengthFn("--.TrailingField", size, 56) - return + // Field 9: TrailingField + if len(c.TrailingField) != 56 { + return nil, ssz.ErrBytesLength } - dst = append(dst, f.TrailingField...) + dst = append(dst, c.TrailingField...) - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the FixedTestContainer object -func (f *FixedTestContainer) UnmarshalSSZ(buf []byte) error { +func (c *FixedTestContainer) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size != 565 { return ssz.ErrSize } - // Field (0) 'FieldUint32' - f.FieldUint32 = ssz.UnmarshallUint[uint32](buf[0:4]) + sszSlice0 := buf[0:4] // c.FieldUint32 + sszSlice1 := buf[4:12] // c.FieldUint64 + sszSlice2 := buf[12:13] // c.FieldBool + sszSlice3 := buf[13:45] // c.FieldBytes32 + sszSlice4 := buf[45:85] // c.Nested + sszSlice5 := buf[85:277] // c.VectorField + sszSlice6 := buf[277:437] // c.TwoDimensionBytesField + sszSlice7 := buf[437:445] // c.Bitvector64Field + sszSlice8 := buf[445:509] // c.Bitvector512Field + sszSlice9 := buf[509:565] // c.TrailingField - // Field (1) 'FieldUint64' - f.FieldUint64 = ssz.UnmarshallUint[uint64](buf[4:12]) + // Field 0: FieldUint32 + c.FieldUint32 = binary.LittleEndian.Uint32(sszSlice0) - // Field (2) 'FieldBool' - f.FieldBool, err = ssz.DecodeBool(buf[12:13]) - if err != nil { - return err - } - - // Field (3) 'FieldBytes32' - if cap(f.FieldBytes32) == 0 { - f.FieldBytes32 = make([]byte, 0, len(buf[13:45])) - } - f.FieldBytes32 = append(f.FieldBytes32, buf[13:45]...) + // Field 1: FieldUint64 + c.FieldUint64 = binary.LittleEndian.Uint64(sszSlice1) - // Field (4) 'Nested' - if f.Nested == nil { - f.Nested = new(FixedNestedContainer) + // Field 2: FieldBool + if sszSlice2[0] > 1 { + return ssz.ErrInvalidSerialization } - if err = f.Nested.UnmarshalSSZ(buf[45:85]); err != nil { - return err + if sszSlice2[0] == 1 { + c.FieldBool = true + } else { + c.FieldBool = false } - // Field (5) 'VectorField' - f.VectorField = ssz.ExtendUint(f.VectorField, 24) - for ii := 0; ii < 24; ii++ { - f.VectorField[ii] = ssz.UnmarshallUint[uint64](buf[85:277][ii*8 : (ii+1)*8]) + // Field 3: FieldBytes32 + c.FieldBytes32 = make([]byte, 0, 32) + c.FieldBytes32 = append(c.FieldBytes32, sszSlice3...) + + // Field 4: Nested + c.Nested = new(FixedNestedContainer) + if err = c.Nested.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("Nested: %w", err) } - // Field (6) 'TwoDimensionBytesField' - f.TwoDimensionBytesField = make([][]byte, 5) - for ii := 0; ii < 5; ii++ { - if cap(f.TwoDimensionBytesField[ii]) == 0 { - f.TwoDimensionBytesField[ii] = make([]byte, 0, len(buf[277:437][ii*32:(ii+1)*32])) + // Field 5: VectorField + { + c.VectorField = make([]uint64, 24) + for i := 0; i < 24; i++ { + var tmp uint64 + + tmpSlice := sszSlice5[i*8 : (1+i)*8] + tmp = binary.LittleEndian.Uint64(tmpSlice) + c.VectorField[i] = tmp } - f.TwoDimensionBytesField[ii] = append(f.TwoDimensionBytesField[ii], buf[277:437][ii*32:(ii+1)*32]...) } - // Field (7) 'Bitvector64Field' - if cap(f.Bitvector64Field) == 0 { - f.Bitvector64Field = make([]byte, 0, len(buf[437:445])) + // Field 6: TwoDimensionBytesField + { + c.TwoDimensionBytesField = make([][]byte, 5) + for i := 0; i < 5; i++ { + var tmp []byte + + tmpSlice := sszSlice6[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.TwoDimensionBytesField[i] = tmp + } } - f.Bitvector64Field = append(f.Bitvector64Field, buf[437:445]...) - // Field (8) 'Bitvector512Field' - if cap(f.Bitvector512Field) == 0 { - f.Bitvector512Field = make([]byte, 0, len(buf[445:509])) - } - f.Bitvector512Field = append(f.Bitvector512Field, buf[445:509]...) + // Field 7: Bitvector64Field + c.Bitvector64Field = make([]byte, 0, 8) + c.Bitvector64Field = append(c.Bitvector64Field, go_bitfield.Bitvector64(sszSlice7)...) - // Field (9) 'TrailingField' - if cap(f.TrailingField) == 0 { - f.TrailingField = make([]byte, 0, len(buf[509:565])) - } - f.TrailingField = append(f.TrailingField, buf[509:565]...) + // Field 8: Bitvector512Field + c.Bitvector512Field = make([]byte, 0, 64) + c.Bitvector512Field = append(c.Bitvector512Field, go_bitfield.Bitvector512(sszSlice8)...) + // Field 9: TrailingField + c.TrailingField = make([]byte, 0, 56) + c.TrailingField = append(c.TrailingField, sszSlice9...) return err } -// SizeSSZ returns the ssz encoded size in bytes for the FixedTestContainer object -func (f *FixedTestContainer) SizeSSZ() (size int) { - size = 565 - return -} - -// HashTreeRoot ssz hashes the FixedTestContainer object -func (f *FixedTestContainer) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(f) +func (c *FixedTestContainer) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err + } + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the FixedTestContainer object with a hasher -func (f *FixedTestContainer) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *FixedTestContainer) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'FieldUint32' - ssz.PutUint(hh, f.FieldUint32) - - // Field (1) 'FieldUint64' - ssz.PutUint(hh, f.FieldUint64) - - // Field (2) 'FieldBool' - hh.PutBool(f.FieldBool) - - // Field (3) 'FieldBytes32' - if size := len(f.FieldBytes32); size != 32 { - err = ssz.ErrBytesLengthFn("--.FieldBytes32", size, 32) - return - } - hh.PutBytes(f.FieldBytes32) - - // Field (4) 'Nested' - if err = f.Nested.HashTreeRootWith(hh); err != nil { - return - } - - // Field (5) 'VectorField' + // Field 0: FieldUint32 + hh.PutUint32(c.FieldUint32) + // Field 1: FieldUint64 + hh.PutUint64(c.FieldUint64) + // Field 2: FieldBool + hh.PutBool(c.FieldBool) + // Field 3: FieldBytes32 + if len(c.FieldBytes32) != 32 { + return ssz.ErrBytesLength + } + hh.PutBytes(c.FieldBytes32) + // Field 4: Nested + if err := c.Nested.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Nested: %w", err) + } + // Field 5: VectorField { - if size := len(f.VectorField); size != 24 { - err = ssz.ErrVectorLengthFn("--.VectorField", size, 24) - return + if len(c.VectorField) != 24 { + return ssz.ErrVectorLength } subIndx := hh.Index() - for _, i := range f.VectorField { - ssz.AppendUint(hh, i) + for _, o := range c.VectorField { + hh.AppendUint64(o) } hh.Merkleize(subIndx) } - - // Field (6) 'TwoDimensionBytesField' + // Field 6: TwoDimensionBytesField { - if size := len(f.TwoDimensionBytesField); size != 5 { - err = ssz.ErrVectorLengthFn("--.TwoDimensionBytesField", size, 5) - return + if len(c.TwoDimensionBytesField) != 5 { + return ssz.ErrVectorLength } subIndx := hh.Index() - for _, i := range f.TwoDimensionBytesField { - if len(i) != 32 { - err = ssz.ErrBytesLength - return + for _, o := range c.TwoDimensionBytesField { + if len(o) != 32 { + return ssz.ErrBytesLength } - hh.Append(i) + hh.Append(o) } hh.Merkleize(subIndx) } - - // Field (7) 'Bitvector64Field' - if size := len(f.Bitvector64Field); size != 8 { - err = ssz.ErrBytesLengthFn("--.Bitvector64Field", size, 8) - return + // Field 7: Bitvector64Field + if len([]byte(c.Bitvector64Field)) != 8 { + return ssz.ErrBytesLength } - hh.PutBytes(f.Bitvector64Field) - - // Field (8) 'Bitvector512Field' - if size := len(f.Bitvector512Field); size != 64 { - err = ssz.ErrBytesLengthFn("--.Bitvector512Field", size, 64) - return + hh.PutBytes([]byte(c.Bitvector64Field)) + // Field 8: Bitvector512Field + if len([]byte(c.Bitvector512Field)) != 64 { + return ssz.ErrBytesLength } - hh.PutBytes(f.Bitvector512Field) - - // Field (9) 'TrailingField' - if size := len(f.TrailingField); size != 56 { - err = ssz.ErrBytesLengthFn("--.TrailingField", size, 56) - return + hh.PutBytes([]byte(c.Bitvector512Field)) + // Field 9: TrailingField + if len(c.TrailingField) != 56 { + return ssz.ErrBytesLength } - hh.PutBytes(f.TrailingField) - + hh.PutBytes(c.TrailingField) hh.Merkleize(indx) - return + return nil +} + +func (c *VariableNestedContainer) SizeSSZ() int { + size := 16 + size += len(c.FieldListUint64) * 8 + for _, o := range c.NestedListField { + size += 4 + size += len(o) + } + return size } -// MarshalSSZ ssz marshals the VariableNestedContainer object -func (v *VariableNestedContainer) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(v) +func (c *VariableNestedContainer) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) } -// MarshalSSZTo ssz marshals the VariableNestedContainer object to a target array -func (v *VariableNestedContainer) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(16) +func (c *VariableNestedContainer) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 16 - // Field (0) 'Value1' - dst = ssz.MarshalUint(dst, v.Value1) + // Field 0: Value1 + dst = binary.LittleEndian.AppendUint64(dst, c.Value1) - // Offset (1) 'FieldListUint64' + // Field 1: FieldListUint64 dst = ssz.WriteOffset(dst, offset) - offset += len(v.FieldListUint64) * 8 + offset += len(c.FieldListUint64) * 8 - // Offset (2) 'NestedListField' + // Field 2: NestedListField dst = ssz.WriteOffset(dst, offset) - for ii := 0; ii < len(v.NestedListField); ii++ { + for _, o := range c.NestedListField { offset += 4 - offset += len(v.NestedListField[ii]) + offset += len(o) } - // Field (1) 'FieldListUint64' - if size := len(v.FieldListUint64); size > 100 { - err = ssz.ErrListTooBigFn("--.FieldListUint64", size, 100) - return + // Field 1: FieldListUint64 + if len(c.FieldListUint64) > 100 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(v.FieldListUint64); ii++ { - dst = ssz.MarshalUint(dst, v.FieldListUint64[ii]) + for _, o := range c.FieldListUint64 { + dst = binary.LittleEndian.AppendUint64(dst, o) } - // Field (2) 'NestedListField' - if size := len(v.NestedListField); size > 100 { - err = ssz.ErrListTooBigFn("--.NestedListField", size, 100) - return + // Field 2: NestedListField + if len(c.NestedListField) > 100 { + return nil, ssz.ErrListTooBig } { - offset = 4 * len(v.NestedListField) - for ii := 0; ii < len(v.NestedListField); ii++ { + offset = 4 * len(c.NestedListField) + for _, o := range c.NestedListField { dst = ssz.WriteOffset(dst, offset) - offset += len(v.NestedListField[ii]) + offset += len(o) } } - for ii := 0; ii < len(v.NestedListField); ii++ { - if size := len(v.NestedListField[ii]); size > 50 { - err = ssz.ErrBytesLengthFn("--.NestedListField[ii]", size, 50) - return + for _, o := range c.NestedListField { + if len(o) > 50 { + return nil, ssz.ErrListTooBig } - dst = append(dst, v.NestedListField[ii]...) + dst = append(dst, o...) } - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the VariableNestedContainer object -func (v *VariableNestedContainer) UnmarshalSSZ(buf []byte) error { +func (c *VariableNestedContainer) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size < 16 { return ssz.ErrSize } - tail := buf - var o1, o2 uint64 - - // Field (0) 'Value1' - v.Value1 = ssz.UnmarshallUint[uint64](buf[0:8]) + sszSlice0 := buf[0:8] // c.Value1 - // Offset (1) 'FieldListUint64' - if o1 = ssz.ReadOffset(buf[8:12]); o1 > size { - return ssz.ErrOffset - } - - if o1 != 16 { + sszVarOffset1 := ssz.ReadOffset(buf[8:12]) // c.FieldListUint64 + if sszVarOffset1 != 16 { return ssz.ErrInvalidVariableOffset } - - // Offset (2) 'NestedListField' - if o2 = ssz.ReadOffset(buf[12:16]); o2 > size || o1 > o2 { + if sszVarOffset1 > size { return ssz.ErrOffset } + sszVarOffset2 := ssz.ReadOffset(buf[12:16]) // c.NestedListField + if sszVarOffset2 > size || sszVarOffset2 < sszVarOffset1 { + return ssz.ErrOffset + } + sszSlice1 := buf[sszVarOffset1:sszVarOffset2] // c.FieldListUint64 + sszSlice2 := buf[sszVarOffset2:] // c.NestedListField + + // Field 0: Value1 + c.Value1 = binary.LittleEndian.Uint64(sszSlice0) - // Field (1) 'FieldListUint64' + // Field 1: FieldListUint64 { - buf = tail[o1:o2] - num, err := ssz.DivideInt2(len(buf), 8, 100) - if err != nil { - return err + if len(sszSlice1)%8 != 0 { + return fmt.Errorf("misaligned bytes: c.FieldListUint64 length is %d, which is not a multiple of 8: %w", len(sszSlice1), ssz.ErrIncorrectListSize) } - v.FieldListUint64 = ssz.ExtendUint(v.FieldListUint64, num) - for ii := 0; ii < num; ii++ { - v.FieldListUint64[ii] = ssz.UnmarshallUint[uint64](buf[ii*8 : (ii+1)*8]) + numElem := len(sszSlice1) / 8 + if numElem > 100 { + return fmt.Errorf("ssz-max exceeded: c.FieldListUint64 has %d elements, ssz-max is 100: %w", numElem, ssz.ErrListTooBig) + } + c.FieldListUint64 = make([]uint64, numElem) + for i := 0; i < numElem; i++ { + var tmp uint64 + + tmpSlice := sszSlice1[i*8 : (1+i)*8] + tmp = binary.LittleEndian.Uint64(tmpSlice) + c.FieldListUint64[i] = tmp } } - // Field (2) 'NestedListField' + // Field 2: NestedListField { - buf = tail[o2:] - num, err := ssz.DecodeDynamicLength(buf, 100) - if err != nil { - return err - } - v.NestedListField = make([][]byte, num) - err = ssz.UnmarshalDynamic(buf, num, func(indx int, buf []byte) (err error) { - if len(buf) > 50 { - return ssz.ErrBytesLength + // empty lists are zero length, so make sure there is room for an offset + // before attempting to unmarshal it + if len(sszSlice2) > 3 { + startOffset := ssz.ReadOffset(sszSlice2[0:4]) + if startOffset == 0 { + return fmt.Errorf("encountered invalid offset of 0 when decoding c.NestedListField") + } + if startOffset%4 != 0 { + return fmt.Errorf("misaligned list bytes: when decoding c.NestedListField, end-of-list offset is %d, which is not a multiple of 4 (offset size)", startOffset) + } + listLen := startOffset / 4 + if listLen > 100 { + return fmt.Errorf("ssz-max exceeded: c.NestedListField has %d elements, ssz-max is 100: %w", listLen, ssz.ErrListTooBig) } - if cap(v.NestedListField[indx]) == 0 { - v.NestedListField[indx] = make([]byte, 0, len(buf)) + totalVarBytes := uint64(len(sszSlice2)) + if totalVarBytes < startOffset { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.NestedListField") } - v.NestedListField[indx] = append(v.NestedListField[indx], buf...) - return nil - }) - if err != nil { - return err + c.NestedListField = make([][]byte, listLen) + var tmpSlice []byte + for i := uint64(0); i < listLen; i++ { + var tmp []byte + + endOffset := totalVarBytes + if i+1 != listLen { + endOffset = ssz.ReadOffset(sszSlice2[(i+1)*4 : (i+2)*4]) + if totalVarBytes < endOffset { + return fmt.Errorf("offset %d points past the end of buffer when decoding c.NestedListField", endOffset) + } + } + if endOffset < startOffset { + return fmt.Errorf("offset %d is not greater than start offset %d when decoding c.NestedListField", endOffset, startOffset) + } + tmpSlice = sszSlice2[startOffset:endOffset] + tmp = append([]byte{}, tmpSlice...) + c.NestedListField[i] = tmp + startOffset = endOffset + } + } else { + if len(sszSlice2) > 0 { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.NestedListField") + } + c.NestedListField = make([][]byte, 0) } } return err } -// SizeSSZ returns the ssz encoded size in bytes for the VariableNestedContainer object -func (v *VariableNestedContainer) SizeSSZ() (size int) { - size = 16 - - // Field (1) 'FieldListUint64' - size += len(v.FieldListUint64) * 8 - - // Field (2) 'NestedListField' - for ii := 0; ii < len(v.NestedListField); ii++ { - size += 4 - size += len(v.NestedListField[ii]) +func (c *VariableNestedContainer) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - - return -} - -// HashTreeRoot ssz hashes the VariableNestedContainer object -func (v *VariableNestedContainer) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(v) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the VariableNestedContainer object with a hasher -func (v *VariableNestedContainer) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *VariableNestedContainer) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Value1' - ssz.PutUint(hh, v.Value1) - - // Field (1) 'FieldListUint64' + // Field 0: Value1 + hh.PutUint64(c.Value1) + // Field 1: FieldListUint64 { - if size := len(v.FieldListUint64); size > 100 { - err = ssz.ErrListTooBigFn("--.FieldListUint64", size, 100) - return + if len(c.FieldListUint64) > 100 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range v.FieldListUint64 { - ssz.AppendUint(hh, i) + for _, o := range c.FieldListUint64 { + hh.AppendUint64(o) } hh.FillUpTo32() - - numItems := uint64(len(v.FieldListUint64)) + numItems := uint64(len(c.FieldListUint64)) hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(100, numItems, 8)) } - - // Field (2) 'NestedListField' + // Field 2: NestedListField { - subIndx := hh.Index() - num := uint64(len(v.NestedListField)) - if num > 100 { - err = ssz.ErrIncorrectListSize - return + if len(c.NestedListField) > 100 { + return ssz.ErrListTooBig } - for _, elem := range v.NestedListField { + subIndx := hh.Index() + for _, o := range c.NestedListField { + { - elemIndx := hh.Index() - byteLen := uint64(len(elem)) - if byteLen > 50 { - err = ssz.ErrIncorrectListSize - return + if len(o) > 50 { + return ssz.ErrBytesLength } - hh.AppendBytes32(elem) - hh.MerkleizeWithMixin(elemIndx, byteLen, (50+31)/32) + subIndx := hh.Index() + hh.AppendBytes32(o) + numItems := uint64(len(o)) + hh.MerkleizeWithMixin(subIndx, numItems, (50*1+31)/32) } + } - hh.MerkleizeWithMixin(subIndx, num, 100) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.NestedListField)), 100) } - hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the VariableOuterContainer object -func (v *VariableOuterContainer) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(v) +func (c *VariableOuterContainer) SizeSSZ() int { + size := 8 + if c.Inner_1 == nil { + c.Inner_1 = new(VariableNestedContainer) + } + size += c.Inner_1.SizeSSZ() + if c.Inner_2 == nil { + c.Inner_2 = new(VariableNestedContainer) + } + size += c.Inner_2.SizeSSZ() + return size } -// MarshalSSZTo ssz marshals the VariableOuterContainer object to a target array -func (v *VariableOuterContainer) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(8) +func (c *VariableOuterContainer) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Offset (0) 'Inner_1' - dst = ssz.WriteOffset(dst, offset) - if v.Inner_1 == nil { - v.Inner_1 = new(VariableNestedContainer) - } - offset += v.Inner_1.SizeSSZ() +func (c *VariableOuterContainer) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 8 - // Offset (1) 'Inner_2' - dst = ssz.WriteOffset(dst, offset) - if v.Inner_2 == nil { - v.Inner_2 = new(VariableNestedContainer) + // Field 0: Inner_1 + if c.Inner_1 == nil { + c.Inner_1 = new(VariableNestedContainer) } - offset += v.Inner_2.SizeSSZ() + dst = ssz.WriteOffset(dst, offset) + offset += c.Inner_1.SizeSSZ() - // Field (0) 'Inner_1' - if dst, err = v.Inner_1.MarshalSSZTo(dst); err != nil { - return + // Field 1: Inner_2 + if c.Inner_2 == nil { + c.Inner_2 = new(VariableNestedContainer) } + dst = ssz.WriteOffset(dst, offset) + offset += c.Inner_2.SizeSSZ() - // Field (1) 'Inner_2' - if dst, err = v.Inner_2.MarshalSSZTo(dst); err != nil { - return + // Field 0: Inner_1 + if dst, err = c.Inner_1.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Inner_1: %w", err) } - return + // Field 1: Inner_2 + if dst, err = c.Inner_2.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Inner_2: %w", err) + } + return dst, err } -// UnmarshalSSZ ssz unmarshals the VariableOuterContainer object -func (v *VariableOuterContainer) UnmarshalSSZ(buf []byte) error { +func (c *VariableOuterContainer) 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) 'Inner_1' - if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { - return ssz.ErrOffset - } - - if o0 != 8 { + sszVarOffset0 := ssz.ReadOffset(buf[0:4]) // c.Inner_1 + if sszVarOffset0 != 8 { return ssz.ErrInvalidVariableOffset } - - // Offset (1) 'Inner_2' - if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 { + if sszVarOffset0 > size { return ssz.ErrOffset } + sszVarOffset1 := ssz.ReadOffset(buf[4:8]) // c.Inner_2 + if sszVarOffset1 > size || sszVarOffset1 < sszVarOffset0 { + return ssz.ErrOffset + } + sszSlice0 := buf[sszVarOffset0:sszVarOffset1] // c.Inner_1 + sszSlice1 := buf[sszVarOffset1:] // c.Inner_2 - // Field (0) 'Inner_1' - { - buf = tail[o0:o1] - if v.Inner_1 == nil { - v.Inner_1 = new(VariableNestedContainer) - } - if err = v.Inner_1.UnmarshalSSZ(buf); err != nil { - return err - } + // Field 0: Inner_1 + c.Inner_1 = new(VariableNestedContainer) + if err = c.Inner_1.UnmarshalSSZ(sszSlice0); err != nil { + return fmt.Errorf("Inner_1: %w", err) } - // Field (1) 'Inner_2' - { - buf = tail[o1:] - if v.Inner_2 == nil { - v.Inner_2 = new(VariableNestedContainer) - } - if err = v.Inner_2.UnmarshalSSZ(buf); err != nil { - return err - } + // Field 1: Inner_2 + c.Inner_2 = new(VariableNestedContainer) + if err = c.Inner_2.UnmarshalSSZ(sszSlice1); err != nil { + return fmt.Errorf("Inner_2: %w", err) } return err } -// SizeSSZ returns the ssz encoded size in bytes for the VariableOuterContainer object -func (v *VariableOuterContainer) SizeSSZ() (size int) { - size = 8 - - // Field (0) 'Inner_1' - if v.Inner_1 == nil { - v.Inner_1 = new(VariableNestedContainer) +func (c *VariableOuterContainer) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - size += v.Inner_1.SizeSSZ() - - // Field (1) 'Inner_2' - if v.Inner_2 == nil { - v.Inner_2 = new(VariableNestedContainer) - } - size += v.Inner_2.SizeSSZ() - - return -} - -// HashTreeRoot ssz hashes the VariableOuterContainer object -func (v *VariableOuterContainer) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(v) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the VariableOuterContainer object with a hasher -func (v *VariableOuterContainer) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *VariableOuterContainer) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'Inner_1' - if err = v.Inner_1.HashTreeRootWith(hh); err != nil { - return + // Field 0: Inner_1 + if err := c.Inner_1.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Inner_1: %w", err) } - - // Field (1) 'Inner_2' - if err = v.Inner_2.HashTreeRootWith(hh); err != nil { - return + // Field 1: Inner_2 + if err := c.Inner_2.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Inner_2: %w", err) } - hh.Merkleize(indx) - return + return nil } -// MarshalSSZ ssz marshals the VariableTestContainer object -func (v *VariableTestContainer) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(v) +func (c *VariableTestContainer) SizeSSZ() int { + size := 116 + size += len(c.FieldListUint64) * 8 + size += len(c.FieldListContainer) * 40 + size += len(c.FieldListBytes32) * 32 + if c.Nested == nil { + c.Nested = new(VariableNestedContainer) + } + size += c.Nested.SizeSSZ() + for _, o := range c.VariableContainerList { + size += 4 + size += o.SizeSSZ() + } + size += len(c.BitlistField) + for _, o := range c.NestedListField { + size += 4 + size += len(o) + } + return size } -// MarshalSSZTo ssz marshals the VariableTestContainer object to a target array -func (v *VariableTestContainer) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(116) +func (c *VariableTestContainer) MarshalSSZ() ([]byte, error) { + buf := make([]byte, c.SizeSSZ()) + return c.MarshalSSZTo(buf[:0]) +} - // Field (0) 'LeadingField' - if size := len(v.LeadingField); size != 32 { - err = ssz.ErrBytesLengthFn("--.LeadingField", size, 32) - return +func (c *VariableTestContainer) MarshalSSZTo(dst []byte) ([]byte, error) { + var err error + offset := 116 + + // Field 0: LeadingField + if len(c.LeadingField) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, v.LeadingField...) + dst = append(dst, c.LeadingField...) - // Offset (1) 'FieldListUint64' + // Field 1: FieldListUint64 dst = ssz.WriteOffset(dst, offset) - offset += len(v.FieldListUint64) * 8 + offset += len(c.FieldListUint64) * 8 - // Offset (2) 'FieldListContainer' + // Field 2: FieldListContainer dst = ssz.WriteOffset(dst, offset) - offset += len(v.FieldListContainer) * 40 + offset += len(c.FieldListContainer) * 40 - // Offset (3) 'FieldListBytes32' + // Field 3: FieldListBytes32 dst = ssz.WriteOffset(dst, offset) - offset += len(v.FieldListBytes32) * 32 + offset += len(c.FieldListBytes32) * 32 - // Offset (4) 'Nested' - dst = ssz.WriteOffset(dst, offset) - if v.Nested == nil { - v.Nested = new(VariableNestedContainer) + // Field 4: Nested + if c.Nested == nil { + c.Nested = new(VariableNestedContainer) } - offset += v.Nested.SizeSSZ() + dst = ssz.WriteOffset(dst, offset) + offset += c.Nested.SizeSSZ() - // Offset (5) 'VariableContainerList' + // Field 5: VariableContainerList dst = ssz.WriteOffset(dst, offset) - for ii := 0; ii < len(v.VariableContainerList); ii++ { + for _, o := range c.VariableContainerList { offset += 4 - offset += v.VariableContainerList[ii].SizeSSZ() + offset += o.SizeSSZ() } - // Offset (6) 'BitlistField' + // Field 6: BitlistField dst = ssz.WriteOffset(dst, offset) - offset += len(v.BitlistField) + offset += len(c.BitlistField) - // Offset (7) 'NestedListField' + // Field 7: NestedListField dst = ssz.WriteOffset(dst, offset) - for ii := 0; ii < len(v.NestedListField); ii++ { + for _, o := range c.NestedListField { offset += 4 - offset += len(v.NestedListField[ii]) + offset += len(o) } - // Field (8) 'TrailingField' - if size := len(v.TrailingField); size != 56 { - err = ssz.ErrBytesLengthFn("--.TrailingField", size, 56) - return + // Field 8: TrailingField + if len(c.TrailingField) != 56 { + return nil, ssz.ErrBytesLength } - dst = append(dst, v.TrailingField...) + dst = append(dst, c.TrailingField...) - // Field (1) 'FieldListUint64' - if size := len(v.FieldListUint64); size > 2048 { - err = ssz.ErrListTooBigFn("--.FieldListUint64", size, 2048) - return + // Field 1: FieldListUint64 + if len(c.FieldListUint64) > 2048 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(v.FieldListUint64); ii++ { - dst = ssz.MarshalUint(dst, v.FieldListUint64[ii]) + for _, o := range c.FieldListUint64 { + dst = binary.LittleEndian.AppendUint64(dst, o) } - // Field (2) 'FieldListContainer' - if size := len(v.FieldListContainer); size > 128 { - err = ssz.ErrListTooBigFn("--.FieldListContainer", size, 128) - return + // Field 2: FieldListContainer + if len(c.FieldListContainer) > 128 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(v.FieldListContainer); ii++ { - if dst, err = v.FieldListContainer[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.FieldListContainer { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("FieldListContainer: %w", err) } } - // Field (3) 'FieldListBytes32' - if size := len(v.FieldListBytes32); size > 100 { - err = ssz.ErrListTooBigFn("--.FieldListBytes32", size, 100) - return + // Field 3: FieldListBytes32 + if len(c.FieldListBytes32) > 100 { + return nil, ssz.ErrListTooBig } - for ii := 0; ii < len(v.FieldListBytes32); ii++ { - if size := len(v.FieldListBytes32[ii]); size != 32 { - err = ssz.ErrBytesLengthFn("--.FieldListBytes32[ii]", size, 32) - return + for _, o := range c.FieldListBytes32 { + if len(o) != 32 { + return nil, ssz.ErrBytesLength } - dst = append(dst, v.FieldListBytes32[ii]...) + dst = append(dst, o...) } - // Field (4) 'Nested' - if dst, err = v.Nested.MarshalSSZTo(dst); err != nil { - return + // Field 4: Nested + if dst, err = c.Nested.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("Nested: %w", err) } - // Field (5) 'VariableContainerList' - if size := len(v.VariableContainerList); size > 10 { - err = ssz.ErrListTooBigFn("--.VariableContainerList", size, 10) - return + // Field 5: VariableContainerList + if len(c.VariableContainerList) > 10 { + return nil, ssz.ErrListTooBig } { - offset = 4 * len(v.VariableContainerList) - for ii := 0; ii < len(v.VariableContainerList); ii++ { + offset = 4 * len(c.VariableContainerList) + for _, o := range c.VariableContainerList { dst = ssz.WriteOffset(dst, offset) - offset += v.VariableContainerList[ii].SizeSSZ() + offset += o.SizeSSZ() } } - for ii := 0; ii < len(v.VariableContainerList); ii++ { - if dst, err = v.VariableContainerList[ii].MarshalSSZTo(dst); err != nil { - return + for _, o := range c.VariableContainerList { + if dst, err = o.MarshalSSZTo(dst); err != nil { + return nil, fmt.Errorf("VariableContainerList: %w", err) } } - // Field (6) 'BitlistField' - if size := len(v.BitlistField); size > 2048 { - err = ssz.ErrBytesLengthFn("--.BitlistField", size, 2048) - return + // Field 6: BitlistField + if len(c.BitlistField) > 2048 { + return nil, ssz.ErrListTooBig } - dst = append(dst, v.BitlistField...) + dst = append(dst, c.BitlistField...) - // Field (7) 'NestedListField' - if size := len(v.NestedListField); size > 100 { - err = ssz.ErrListTooBigFn("--.NestedListField", size, 100) - return + // Field 7: NestedListField + if len(c.NestedListField) > 100 { + return nil, ssz.ErrListTooBig } { - offset = 4 * len(v.NestedListField) - for ii := 0; ii < len(v.NestedListField); ii++ { + offset = 4 * len(c.NestedListField) + for _, o := range c.NestedListField { dst = ssz.WriteOffset(dst, offset) - offset += len(v.NestedListField[ii]) + offset += len(o) } } - for ii := 0; ii < len(v.NestedListField); ii++ { - if size := len(v.NestedListField[ii]); size > 50 { - err = ssz.ErrBytesLengthFn("--.NestedListField[ii]", size, 50) - return + for _, o := range c.NestedListField { + if len(o) > 50 { + return nil, ssz.ErrListTooBig } - dst = append(dst, v.NestedListField[ii]...) + dst = append(dst, o...) } - - return + return dst, err } -// UnmarshalSSZ ssz unmarshals the VariableTestContainer object -func (v *VariableTestContainer) UnmarshalSSZ(buf []byte) error { +func (c *VariableTestContainer) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size < 116 { return ssz.ErrSize } - tail := buf - var o1, o2, o3, o4, o5, o6, o7 uint64 + sszSlice0 := buf[0:32] // c.LeadingField + sszSlice8 := buf[60:116] // c.TrailingField - // Field (0) 'LeadingField' - if cap(v.LeadingField) == 0 { - v.LeadingField = make([]byte, 0, len(buf[0:32])) + sszVarOffset1 := ssz.ReadOffset(buf[32:36]) // c.FieldListUint64 + if sszVarOffset1 != 116 { + return ssz.ErrInvalidVariableOffset } - v.LeadingField = append(v.LeadingField, buf[0:32]...) - - // Offset (1) 'FieldListUint64' - if o1 = ssz.ReadOffset(buf[32:36]); o1 > size { + if sszVarOffset1 > size { return ssz.ErrOffset } - - if o1 != 116 { - return ssz.ErrInvalidVariableOffset - } - - // Offset (2) 'FieldListContainer' - if o2 = ssz.ReadOffset(buf[36:40]); o2 > size || o1 > o2 { + sszVarOffset2 := ssz.ReadOffset(buf[36:40]) // c.FieldListContainer + if sszVarOffset2 > size || sszVarOffset2 < sszVarOffset1 { return ssz.ErrOffset } - - // Offset (3) 'FieldListBytes32' - if o3 = ssz.ReadOffset(buf[40:44]); o3 > size || o2 > o3 { + sszVarOffset3 := ssz.ReadOffset(buf[40:44]) // c.FieldListBytes32 + if sszVarOffset3 > size || sszVarOffset3 < sszVarOffset2 { return ssz.ErrOffset } - - // Offset (4) 'Nested' - if o4 = ssz.ReadOffset(buf[44:48]); o4 > size || o3 > o4 { + sszVarOffset4 := ssz.ReadOffset(buf[44:48]) // c.Nested + if sszVarOffset4 > size || sszVarOffset4 < sszVarOffset3 { return ssz.ErrOffset } - - // Offset (5) 'VariableContainerList' - if o5 = ssz.ReadOffset(buf[48:52]); o5 > size || o4 > o5 { + sszVarOffset5 := ssz.ReadOffset(buf[48:52]) // c.VariableContainerList + if sszVarOffset5 > size || sszVarOffset5 < sszVarOffset4 { return ssz.ErrOffset } - - // Offset (6) 'BitlistField' - if o6 = ssz.ReadOffset(buf[52:56]); o6 > size || o5 > o6 { + sszVarOffset6 := ssz.ReadOffset(buf[52:56]) // c.BitlistField + if sszVarOffset6 > size || sszVarOffset6 < sszVarOffset5 { return ssz.ErrOffset } - - // Offset (7) 'NestedListField' - if o7 = ssz.ReadOffset(buf[56:60]); o7 > size || o6 > o7 { + sszVarOffset7 := ssz.ReadOffset(buf[56:60]) // c.NestedListField + if sszVarOffset7 > size || sszVarOffset7 < sszVarOffset6 { return ssz.ErrOffset } + sszSlice1 := buf[sszVarOffset1:sszVarOffset2] // c.FieldListUint64 + sszSlice2 := buf[sszVarOffset2:sszVarOffset3] // c.FieldListContainer + sszSlice3 := buf[sszVarOffset3:sszVarOffset4] // c.FieldListBytes32 + sszSlice4 := buf[sszVarOffset4:sszVarOffset5] // c.Nested + sszSlice5 := buf[sszVarOffset5:sszVarOffset6] // c.VariableContainerList + sszSlice6 := buf[sszVarOffset6:sszVarOffset7] // c.BitlistField + sszSlice7 := buf[sszVarOffset7:] // c.NestedListField - // Field (8) 'TrailingField' - if cap(v.TrailingField) == 0 { - v.TrailingField = make([]byte, 0, len(buf[60:116])) - } - v.TrailingField = append(v.TrailingField, buf[60:116]...) + // Field 0: LeadingField + c.LeadingField = make([]byte, 0, 32) + c.LeadingField = append(c.LeadingField, sszSlice0...) - // Field (1) 'FieldListUint64' + // Field 1: FieldListUint64 { - buf = tail[o1:o2] - num, err := ssz.DivideInt2(len(buf), 8, 2048) - if err != nil { - return err + if len(sszSlice1)%8 != 0 { + return fmt.Errorf("misaligned bytes: c.FieldListUint64 length is %d, which is not a multiple of 8: %w", len(sszSlice1), ssz.ErrIncorrectListSize) } - v.FieldListUint64 = ssz.ExtendUint(v.FieldListUint64, num) - for ii := 0; ii < num; ii++ { - v.FieldListUint64[ii] = ssz.UnmarshallUint[uint64](buf[ii*8 : (ii+1)*8]) + numElem := len(sszSlice1) / 8 + if numElem > 2048 { + return fmt.Errorf("ssz-max exceeded: c.FieldListUint64 has %d elements, ssz-max is 2048: %w", numElem, ssz.ErrListTooBig) } - } + c.FieldListUint64 = make([]uint64, numElem) + for i := 0; i < numElem; i++ { + var tmp uint64 - // Field (2) 'FieldListContainer' - { - buf = tail[o2:o3] - num, err := ssz.DivideInt2(len(buf), 40, 128) - if err != nil { - return err - } - v.FieldListContainer = make([]*FixedNestedContainer, num) - for ii := 0; ii < num; ii++ { - if v.FieldListContainer[ii] == nil { - v.FieldListContainer[ii] = new(FixedNestedContainer) - } - if err = v.FieldListContainer[ii].UnmarshalSSZ(buf[ii*40 : (ii+1)*40]); err != nil { - return err - } + tmpSlice := sszSlice1[i*8 : (1+i)*8] + tmp = binary.LittleEndian.Uint64(tmpSlice) + c.FieldListUint64[i] = tmp } } - // Field (3) 'FieldListBytes32' + // Field 2: FieldListContainer { - buf = tail[o3:o4] - num, err := ssz.DivideInt2(len(buf), 32, 100) - if err != nil { - return err + if len(sszSlice2)%40 != 0 { + return fmt.Errorf("misaligned bytes: c.FieldListContainer length is %d, which is not a multiple of 40: %w", len(sszSlice2), ssz.ErrIncorrectListSize) } - v.FieldListBytes32 = make([][]byte, num) - for ii := 0; ii < num; ii++ { - if cap(v.FieldListBytes32[ii]) == 0 { - v.FieldListBytes32[ii] = make([]byte, 0, len(buf[ii*32:(ii+1)*32])) + numElem := len(sszSlice2) / 40 + if numElem > 128 { + return fmt.Errorf("ssz-max exceeded: c.FieldListContainer has %d elements, ssz-max is 128: %w", numElem, ssz.ErrListTooBig) + } + c.FieldListContainer = make([]*FixedNestedContainer, numElem) + for i := 0; i < numElem; i++ { + var tmp *FixedNestedContainer + tmp = new(FixedNestedContainer) + tmpSlice := sszSlice2[i*40 : (1+i)*40] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("FieldListContainer: %w", err) } - v.FieldListBytes32[ii] = append(v.FieldListBytes32[ii], buf[ii*32:(ii+1)*32]...) + c.FieldListContainer[i] = tmp } } - // Field (4) 'Nested' + // Field 3: FieldListBytes32 { - buf = tail[o4:o5] - if v.Nested == nil { - v.Nested = new(VariableNestedContainer) + if len(sszSlice3)%32 != 0 { + return fmt.Errorf("misaligned bytes: c.FieldListBytes32 length is %d, which is not a multiple of 32: %w", len(sszSlice3), ssz.ErrIncorrectListSize) + } + numElem := len(sszSlice3) / 32 + if numElem > 100 { + return fmt.Errorf("ssz-max exceeded: c.FieldListBytes32 has %d elements, ssz-max is 100: %w", numElem, ssz.ErrListTooBig) } - if err = v.Nested.UnmarshalSSZ(buf); err != nil { - return err + c.FieldListBytes32 = make([][]byte, numElem) + for i := 0; i < numElem; i++ { + var tmp []byte + + tmpSlice := sszSlice3[i*32 : (1+i)*32] + tmp = make([]byte, 0, 32) + tmp = append(tmp, tmpSlice...) + c.FieldListBytes32[i] = tmp } } - // Field (5) 'VariableContainerList' + // Field 4: Nested + c.Nested = new(VariableNestedContainer) + if err = c.Nested.UnmarshalSSZ(sszSlice4); err != nil { + return fmt.Errorf("Nested: %w", err) + } + + // Field 5: VariableContainerList { - buf = tail[o5:o6] - num, err := ssz.DecodeDynamicLength(buf, 10) - if err != nil { - return err - } - v.VariableContainerList = make([]*VariableOuterContainer, num) - err = ssz.UnmarshalDynamic(buf, num, func(indx int, buf []byte) (err error) { - if v.VariableContainerList[indx] == nil { - v.VariableContainerList[indx] = new(VariableOuterContainer) + // empty lists are zero length, so make sure there is room for an offset + // before attempting to unmarshal it + if len(sszSlice5) > 3 { + startOffset := ssz.ReadOffset(sszSlice5[0:4]) + if startOffset == 0 { + return fmt.Errorf("encountered invalid offset of 0 when decoding c.VariableContainerList") + } + if startOffset%4 != 0 { + return fmt.Errorf("misaligned list bytes: when decoding c.VariableContainerList, end-of-list offset is %d, which is not a multiple of 4 (offset size)", startOffset) } - if err = v.VariableContainerList[indx].UnmarshalSSZ(buf); err != nil { - return err + listLen := startOffset / 4 + if listLen > 10 { + return fmt.Errorf("ssz-max exceeded: c.VariableContainerList has %d elements, ssz-max is 10: %w", listLen, ssz.ErrListTooBig) } - return nil - }) - if err != nil { - return err + totalVarBytes := uint64(len(sszSlice5)) + if totalVarBytes < startOffset { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.VariableContainerList") + } + c.VariableContainerList = make([]*VariableOuterContainer, listLen) + var tmpSlice []byte + for i := uint64(0); i < listLen; i++ { + var tmp *VariableOuterContainer + tmp = new(VariableOuterContainer) + endOffset := totalVarBytes + if i+1 != listLen { + endOffset = ssz.ReadOffset(sszSlice5[(i+1)*4 : (i+2)*4]) + if totalVarBytes < endOffset { + return fmt.Errorf("offset %d points past the end of buffer when decoding c.VariableContainerList", endOffset) + } + } + if endOffset < startOffset { + return fmt.Errorf("offset %d is not greater than start offset %d when decoding c.VariableContainerList", endOffset, startOffset) + } + tmpSlice = sszSlice5[startOffset:endOffset] + if err = tmp.UnmarshalSSZ(tmpSlice); err != nil { + return fmt.Errorf("VariableContainerList: %w", err) + } + c.VariableContainerList[i] = tmp + startOffset = endOffset + } + } else { + if len(sszSlice5) > 0 { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.VariableContainerList") + } + c.VariableContainerList = make([]*VariableOuterContainer, 0) } } - // Field (6) 'BitlistField' - { - buf = tail[o6:o7] - if err = ssz.ValidateBitlist(buf, 2048); err != nil { - return err - } - if cap(v.BitlistField) == 0 { - v.BitlistField = make([]byte, 0, len(buf)) - } - v.BitlistField = append(v.BitlistField, buf...) + // Field 6: BitlistField + if err = ssz.ValidateBitlist(sszSlice6, 2048); err != nil { + return fmt.Errorf("BitlistField: %w", err) } + c.BitlistField = append([]byte{}, go_bitfield.Bitlist(sszSlice6)...) - // Field (7) 'NestedListField' + // Field 7: NestedListField { - buf = tail[o7:] - num, err := ssz.DecodeDynamicLength(buf, 100) - if err != nil { - return err - } - v.NestedListField = make([][]byte, num) - err = ssz.UnmarshalDynamic(buf, num, func(indx int, buf []byte) (err error) { - if len(buf) > 50 { - return ssz.ErrBytesLength + // empty lists are zero length, so make sure there is room for an offset + // before attempting to unmarshal it + if len(sszSlice7) > 3 { + startOffset := ssz.ReadOffset(sszSlice7[0:4]) + if startOffset == 0 { + return fmt.Errorf("encountered invalid offset of 0 when decoding c.NestedListField") + } + if startOffset%4 != 0 { + return fmt.Errorf("misaligned list bytes: when decoding c.NestedListField, end-of-list offset is %d, which is not a multiple of 4 (offset size)", startOffset) + } + listLen := startOffset / 4 + if listLen > 100 { + return fmt.Errorf("ssz-max exceeded: c.NestedListField has %d elements, ssz-max is 100: %w", listLen, ssz.ErrListTooBig) } - if cap(v.NestedListField[indx]) == 0 { - v.NestedListField[indx] = make([]byte, 0, len(buf)) + totalVarBytes := uint64(len(sszSlice7)) + if totalVarBytes < startOffset { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.NestedListField") + } + c.NestedListField = make([][]byte, listLen) + var tmpSlice []byte + for i := uint64(0); i < listLen; i++ { + var tmp []byte + + endOffset := totalVarBytes + if i+1 != listLen { + endOffset = ssz.ReadOffset(sszSlice7[(i+1)*4 : (i+2)*4]) + if totalVarBytes < endOffset { + return fmt.Errorf("offset %d points past the end of buffer when decoding c.NestedListField", endOffset) + } + } + if endOffset < startOffset { + return fmt.Errorf("offset %d is not greater than start offset %d when decoding c.NestedListField", endOffset, startOffset) + } + tmpSlice = sszSlice7[startOffset:endOffset] + tmp = append([]byte{}, tmpSlice...) + c.NestedListField[i] = tmp + startOffset = endOffset } - v.NestedListField[indx] = append(v.NestedListField[indx], buf...) - return nil - }) - if err != nil { - return err + } else { + if len(sszSlice7) > 0 { + return fmt.Errorf("list bytes too short to contain an offset when decoding c.NestedListField") + } + c.NestedListField = make([][]byte, 0) } } + + // Field 8: TrailingField + c.TrailingField = make([]byte, 0, 56) + c.TrailingField = append(c.TrailingField, sszSlice8...) return err } -// SizeSSZ returns the ssz encoded size in bytes for the VariableTestContainer object -func (v *VariableTestContainer) SizeSSZ() (size int) { - size = 116 - - // Field (1) 'FieldListUint64' - size += len(v.FieldListUint64) * 8 - - // Field (2) 'FieldListContainer' - size += len(v.FieldListContainer) * 40 - - // Field (3) 'FieldListBytes32' - size += len(v.FieldListBytes32) * 32 - - // Field (4) 'Nested' - if v.Nested == nil { - v.Nested = new(VariableNestedContainer) - } - size += v.Nested.SizeSSZ() - - // Field (5) 'VariableContainerList' - for ii := 0; ii < len(v.VariableContainerList); ii++ { - size += 4 - size += v.VariableContainerList[ii].SizeSSZ() - } - - // Field (6) 'BitlistField' - size += len(v.BitlistField) - - // Field (7) 'NestedListField' - for ii := 0; ii < len(v.NestedListField); ii++ { - size += 4 - size += len(v.NestedListField[ii]) +func (c *VariableTestContainer) HashTreeRoot() ([32]byte, error) { + hh := ssz.DefaultHasherPool.Get() + if err := c.HashTreeRootWith(hh); err != nil { + ssz.DefaultHasherPool.Put(hh) + return [32]byte{}, err } - - return -} - -// HashTreeRoot ssz hashes the VariableTestContainer object -func (v *VariableTestContainer) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(v) + root, err := hh.HashRoot() + ssz.DefaultHasherPool.Put(hh) + return root, err } -// HashTreeRootWith ssz hashes the VariableTestContainer object with a hasher -func (v *VariableTestContainer) HashTreeRootWith(hh *ssz.Hasher) (err error) { +func (c *VariableTestContainer) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() - - // Field (0) 'LeadingField' - if size := len(v.LeadingField); size != 32 { - err = ssz.ErrBytesLengthFn("--.LeadingField", size, 32) - return + // Field 0: LeadingField + if len(c.LeadingField) != 32 { + return ssz.ErrBytesLength } - hh.PutBytes(v.LeadingField) - - // Field (1) 'FieldListUint64' + hh.PutBytes(c.LeadingField) + // Field 1: FieldListUint64 { - if size := len(v.FieldListUint64); size > 2048 { - err = ssz.ErrListTooBigFn("--.FieldListUint64", size, 2048) - return + if len(c.FieldListUint64) > 2048 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range v.FieldListUint64 { - ssz.AppendUint(hh, i) + for _, o := range c.FieldListUint64 { + hh.AppendUint64(o) } hh.FillUpTo32() - - numItems := uint64(len(v.FieldListUint64)) + numItems := uint64(len(c.FieldListUint64)) hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(2048, numItems, 8)) } - - // Field (2) 'FieldListContainer' + // Field 2: FieldListContainer { - subIndx := hh.Index() - num := uint64(len(v.FieldListContainer)) - if num > 128 { - err = ssz.ErrIncorrectListSize - return + if len(c.FieldListContainer) > 128 { + return ssz.ErrListTooBig } - for _, elem := range v.FieldListContainer { - if err = elem.HashTreeRootWith(hh); err != nil { - return + subIndx := hh.Index() + for _, o := range c.FieldListContainer { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("FieldListContainer: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 128) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.FieldListContainer)), 128) } - - // Field (3) 'FieldListBytes32' + // Field 3: FieldListBytes32 { - if size := len(v.FieldListBytes32); size > 100 { - err = ssz.ErrListTooBigFn("--.FieldListBytes32", size, 100) - return + if len(c.FieldListBytes32) > 100 { + return ssz.ErrListTooBig } subIndx := hh.Index() - for _, i := range v.FieldListBytes32 { - if len(i) != 32 { - err = ssz.ErrBytesLength - return + for _, o := range c.FieldListBytes32 { + if len(o) != 32 { + return ssz.ErrBytesLength } - hh.Append(i) + hh.Append(o) } - - numItems := uint64(len(v.FieldListBytes32)) - hh.MerkleizeWithMixin(subIndx, numItems, 100) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.FieldListBytes32)), 100) } - - // Field (4) 'Nested' - if err = v.Nested.HashTreeRootWith(hh); err != nil { - return + // Field 4: Nested + if err := c.Nested.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("Nested: %w", err) } - - // Field (5) 'VariableContainerList' + // Field 5: VariableContainerList { - subIndx := hh.Index() - num := uint64(len(v.VariableContainerList)) - if num > 10 { - err = ssz.ErrIncorrectListSize - return + if len(c.VariableContainerList) > 10 { + return ssz.ErrListTooBig } - for _, elem := range v.VariableContainerList { - if err = elem.HashTreeRootWith(hh); err != nil { - return + subIndx := hh.Index() + for _, o := range c.VariableContainerList { + if err := o.HashTreeRootWith(hh); err != nil { + return fmt.Errorf("VariableContainerList: %w", err) } } - hh.MerkleizeWithMixin(subIndx, num, 10) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.VariableContainerList)), 10) } - - // Field (6) 'BitlistField' - if len(v.BitlistField) == 0 { - err = ssz.ErrEmptyBitlist - return + // Field 6: BitlistField + if len(c.BitlistField) == 0 { + return ssz.ErrEmptyBitlist } - hh.PutBitlist(v.BitlistField, 2048) - - // Field (7) 'NestedListField' + hh.PutBitlist(c.BitlistField, 2048) + // Field 7: NestedListField { - subIndx := hh.Index() - num := uint64(len(v.NestedListField)) - if num > 100 { - err = ssz.ErrIncorrectListSize - return + if len(c.NestedListField) > 100 { + return ssz.ErrListTooBig } - for _, elem := range v.NestedListField { + subIndx := hh.Index() + for _, o := range c.NestedListField { + { - elemIndx := hh.Index() - byteLen := uint64(len(elem)) - if byteLen > 50 { - err = ssz.ErrIncorrectListSize - return + if len(o) > 50 { + return ssz.ErrBytesLength } - hh.AppendBytes32(elem) - hh.MerkleizeWithMixin(elemIndx, byteLen, (50+31)/32) + subIndx := hh.Index() + hh.AppendBytes32(o) + numItems := uint64(len(o)) + hh.MerkleizeWithMixin(subIndx, numItems, (50*1+31)/32) } + } - hh.MerkleizeWithMixin(subIndx, num, 100) + hh.MerkleizeWithMixin(subIndx, uint64(len(c.NestedListField)), 100) } - - // Field (8) 'TrailingField' - if size := len(v.TrailingField); size != 56 { - err = ssz.ErrBytesLengthFn("--.TrailingField", size, 56) - return + // Field 8: TrailingField + if len(c.TrailingField) != 56 { + return ssz.ErrBytesLength } - hh.PutBytes(v.TrailingField) - + hh.PutBytes(c.TrailingField) hh.Merkleize(indx) - return + return nil } diff --git a/proto/ssz_query/testing/test_containers.yaml b/proto/ssz_query/testing/test_containers.yaml new file mode 100644 index 000000000000..5e4ea3993de0 --- /dev/null +++ b/proto/ssz_query/testing/test_containers.yaml @@ -0,0 +1,7 @@ +package: "github.com/OffchainLabs/prysm/v7/proto/ssz_query/testing" +types: + - name: "FixedNestedContainer" + - name: "FixedTestContainer" + - name: "VariableNestedContainer" + - name: "VariableOuterContainer" + - name: "VariableTestContainer" diff --git a/proto/testing/BUILD.bazel b/proto/testing/BUILD.bazel index b3fac4b73f19..d61cdc08f41f 100644 --- a/proto/testing/BUILD.bazel +++ b/proto/testing/BUILD.bazel @@ -61,7 +61,6 @@ go_test( "//testing/util:go_default_library", "@com_github_ghodss_yaml//:go_default_library", "@com_github_golang_snappy//:go_default_library", - "@com_github_prysmaticlabs_fastssz//:go_default_library", "@io_bazel_rules_go//go/tools/bazel:go_default_library", ], ) diff --git a/testing/spectest/shared/altair/ssz_static/BUILD.bazel b/testing/spectest/shared/altair/ssz_static/BUILD.bazel index 50dd40e32c64..34d5e8e0333e 100644 --- a/testing/spectest/shared/altair/ssz_static/BUILD.bazel +++ b/testing/spectest/shared/altair/ssz_static/BUILD.bazel @@ -11,6 +11,6 @@ go_library( "//proto/prysm/v1alpha1:go_default_library", "//testing/require:go_default_library", "//testing/spectest/shared/common/ssz_static:go_default_library", - "@com_github_prysmaticlabs_fastssz//:go_default_library", + "@com_github_offchainlabs_methodical_ssz//ssz:go_default_library", ], ) diff --git a/testing/spectest/shared/altair/ssz_static/ssz_static.go b/testing/spectest/shared/altair/ssz_static/ssz_static.go index ca04b5c1401f..51c817779234 100644 --- a/testing/spectest/shared/altair/ssz_static/ssz_static.go +++ b/testing/spectest/shared/altair/ssz_static/ssz_static.go @@ -5,11 +5,12 @@ import ( "errors" "testing" + "github.com/OffchainLabs/methodical-ssz/ssz" + state_native "github.com/OffchainLabs/prysm/v7/beacon-chain/state/state-native" ethpb "github.com/OffchainLabs/prysm/v7/proto/prysm/v1alpha1" "github.com/OffchainLabs/prysm/v7/testing/require" common "github.com/OffchainLabs/prysm/v7/testing/spectest/shared/common/ssz_static" - fssz "github.com/prysmaticlabs/fastssz" ) // RunSSZStaticTests executes "ssz_static" tests. @@ -116,10 +117,10 @@ func unmarshalledSSZ(t *testing.T, serializedBytes []byte, folderName string) (a return nil, errors.New("type not found") } var err error - if o, ok := obj.(fssz.Unmarshaler); ok { + if o, ok := obj.(ssz.Unmarshaler); ok { err = o.UnmarshalSSZ(serializedBytes) } else { - err = errors.New("could not unmarshal object, not a fastssz compatible object") + err = errors.New("could not unmarshal object, does not implement Unmarshaler interface") } return obj, err } diff --git a/testing/spectest/shared/bellatrix/ssz_static/BUILD.bazel b/testing/spectest/shared/bellatrix/ssz_static/BUILD.bazel index 7204379bb0cb..d1fda7e5caa5 100644 --- a/testing/spectest/shared/bellatrix/ssz_static/BUILD.bazel +++ b/testing/spectest/shared/bellatrix/ssz_static/BUILD.bazel @@ -12,6 +12,6 @@ go_library( "//proto/prysm/v1alpha1:go_default_library", "//testing/require:go_default_library", "//testing/spectest/shared/common/ssz_static:go_default_library", - "@com_github_prysmaticlabs_fastssz//:go_default_library", + "@com_github_offchainlabs_methodical_ssz//ssz:go_default_library", ], ) diff --git a/testing/spectest/shared/bellatrix/ssz_static/ssz_static.go b/testing/spectest/shared/bellatrix/ssz_static/ssz_static.go index 6c959c35ef04..8fd1259b1b34 100644 --- a/testing/spectest/shared/bellatrix/ssz_static/ssz_static.go +++ b/testing/spectest/shared/bellatrix/ssz_static/ssz_static.go @@ -5,12 +5,13 @@ import ( "errors" "testing" + "github.com/OffchainLabs/methodical-ssz/ssz" + state_native "github.com/OffchainLabs/prysm/v7/beacon-chain/state/state-native" enginev1 "github.com/OffchainLabs/prysm/v7/proto/engine/v1" ethpb "github.com/OffchainLabs/prysm/v7/proto/prysm/v1alpha1" "github.com/OffchainLabs/prysm/v7/testing/require" common "github.com/OffchainLabs/prysm/v7/testing/spectest/shared/common/ssz_static" - fssz "github.com/prysmaticlabs/fastssz" ) // RunSSZStaticTests executes "ssz_static" tests. @@ -123,10 +124,10 @@ func unmarshalledSSZ(t *testing.T, serializedBytes []byte, folderName string) (a return nil, errors.New("type not found") } var err error - if o, ok := obj.(fssz.Unmarshaler); ok { + if o, ok := obj.(ssz.Unmarshaler); ok { err = o.UnmarshalSSZ(serializedBytes) } else { - err = errors.New("could not unmarshal object, not a fastssz compatible object") + err = errors.New("could not unmarshal object, does not implement Unmarshaler interface") } return obj, err } diff --git a/testing/spectest/shared/capella/ssz_static/BUILD.bazel b/testing/spectest/shared/capella/ssz_static/BUILD.bazel index 95e75f781515..c41ec434795b 100644 --- a/testing/spectest/shared/capella/ssz_static/BUILD.bazel +++ b/testing/spectest/shared/capella/ssz_static/BUILD.bazel @@ -12,6 +12,6 @@ go_library( "//proto/prysm/v1alpha1:go_default_library", "//testing/require:go_default_library", "//testing/spectest/shared/common/ssz_static:go_default_library", - "@com_github_prysmaticlabs_fastssz//:go_default_library", + "@com_github_offchainlabs_methodical_ssz//ssz:go_default_library", ], ) diff --git a/testing/spectest/shared/capella/ssz_static/ssz_static.go b/testing/spectest/shared/capella/ssz_static/ssz_static.go index cba6f4ab509a..8375ee278f07 100644 --- a/testing/spectest/shared/capella/ssz_static/ssz_static.go +++ b/testing/spectest/shared/capella/ssz_static/ssz_static.go @@ -5,12 +5,13 @@ import ( "errors" "testing" + "github.com/OffchainLabs/methodical-ssz/ssz" + state_native "github.com/OffchainLabs/prysm/v7/beacon-chain/state/state-native" enginev1 "github.com/OffchainLabs/prysm/v7/proto/engine/v1" ethpb "github.com/OffchainLabs/prysm/v7/proto/prysm/v1alpha1" "github.com/OffchainLabs/prysm/v7/testing/require" common "github.com/OffchainLabs/prysm/v7/testing/spectest/shared/common/ssz_static" - fssz "github.com/prysmaticlabs/fastssz" ) // RunSSZStaticTests executes "ssz_static" tests. @@ -131,10 +132,10 @@ func unmarshalledSSZ(t *testing.T, serializedBytes []byte, folderName string) (a return nil, errors.New("type not found") } var err error - if o, ok := obj.(fssz.Unmarshaler); ok { + if o, ok := obj.(ssz.Unmarshaler); ok { err = o.UnmarshalSSZ(serializedBytes) } else { - err = errors.New("could not unmarshal object, not a fastssz compatible object") + err = errors.New("could not unmarshal object, does not implement Unmarshaler interface") } return obj, err } diff --git a/testing/spectest/shared/common/merkle_proof/BUILD.bazel b/testing/spectest/shared/common/merkle_proof/BUILD.bazel index bbe7f88ae470..dd9f2c660f1c 100644 --- a/testing/spectest/shared/common/merkle_proof/BUILD.bazel +++ b/testing/spectest/shared/common/merkle_proof/BUILD.bazel @@ -16,6 +16,6 @@ go_library( "//testing/spectest/utils:go_default_library", "//testing/util:go_default_library", "@com_github_golang_snappy//:go_default_library", - "@com_github_prysmaticlabs_fastssz//:go_default_library", + "@com_github_offchainlabs_methodical_ssz//ssz:go_default_library", ], ) diff --git a/testing/spectest/shared/common/merkle_proof/single_merkle_proof.go b/testing/spectest/shared/common/merkle_proof/single_merkle_proof.go index 2af2760bb7a3..8a20b8ca3b78 100644 --- a/testing/spectest/shared/common/merkle_proof/single_merkle_proof.go +++ b/testing/spectest/shared/common/merkle_proof/single_merkle_proof.go @@ -6,6 +6,9 @@ import ( "path" "testing" + "github.com/OffchainLabs/methodical-ssz/ssz" + "github.com/golang/snappy" + "github.com/OffchainLabs/prysm/v7/build/bazel" "github.com/OffchainLabs/prysm/v7/config/params" consensus_blocks "github.com/OffchainLabs/prysm/v7/consensus-types/blocks" @@ -14,8 +17,6 @@ import ( "github.com/OffchainLabs/prysm/v7/testing/spectest/shared/common/ssz_static" "github.com/OffchainLabs/prysm/v7/testing/spectest/utils" "github.com/OffchainLabs/prysm/v7/testing/util" - "github.com/golang/snappy" - fssz "github.com/prysmaticlabs/fastssz" ) // SingleMerkleProof is the format used to read spectest Merkle Proof test data. @@ -57,7 +58,7 @@ func runSingleMerkleProofTests(t *testing.T, config, forkOrPhase string, unmarsh require.NoError(t, err, "Failed to decompress") object, err := unmarshaller(t, serializedSSZ, folder.Name()) require.NoError(t, err, "Could not unmarshall serialized SSZ") - sszObj, ok := object.(fssz.HashRoot) + sszObj, ok := object.(ssz.HashRoot) require.Equal(t, true, ok) root, err := sszObj.HashTreeRoot() require.NoError(t, err) diff --git a/testing/spectest/shared/common/ssz_static/BUILD.bazel b/testing/spectest/shared/common/ssz_static/BUILD.bazel index ffeeecf5cf82..da37d4044f80 100644 --- a/testing/spectest/shared/common/ssz_static/BUILD.bazel +++ b/testing/spectest/shared/common/ssz_static/BUILD.bazel @@ -10,11 +10,12 @@ go_library( importpath = "github.com/OffchainLabs/prysm/v7/testing/spectest/shared/common/ssz_static", visibility = ["//testing/spectest:__subpackages__"], deps = [ + "//encoding/bytesutil:go_default_library", "//testing/require:go_default_library", "//testing/spectest/utils:go_default_library", "//testing/util:go_default_library", "@com_github_golang_snappy//:go_default_library", - "@com_github_prysmaticlabs_fastssz//:go_default_library", + "@com_github_offchainlabs_methodical_ssz//ssz:go_default_library", ], ) @@ -27,7 +28,7 @@ go_test( "//beacon-chain/state/state-native:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//testing/require:go_default_library", + "@com_github_offchainlabs_methodical_ssz//ssz:go_default_library", "@com_github_pkg_errors//:go_default_library", - "@com_github_prysmaticlabs_fastssz//:go_default_library", ], ) diff --git a/testing/spectest/shared/common/ssz_static/ssz_static.go b/testing/spectest/shared/common/ssz_static/ssz_static.go index 74954a3fb871..dd4360897390 100644 --- a/testing/spectest/shared/common/ssz_static/ssz_static.go +++ b/testing/spectest/shared/common/ssz_static/ssz_static.go @@ -6,11 +6,13 @@ import ( "path" "testing" + "github.com/OffchainLabs/methodical-ssz/ssz" + "github.com/golang/snappy" + + "github.com/OffchainLabs/prysm/v7/encoding/bytesutil" "github.com/OffchainLabs/prysm/v7/testing/require" "github.com/OffchainLabs/prysm/v7/testing/spectest/utils" "github.com/OffchainLabs/prysm/v7/testing/util" - "github.com/golang/snappy" - fssz "github.com/prysmaticlabs/fastssz" ) // RunSSZStaticTests executes "ssz_static" tests for the given fork of phase using the provided @@ -54,10 +56,10 @@ func RunSSZStaticTests(t *testing.T, config, forkOrPhase string, unmarshaller Un rootsYaml := &SSZRoots{} require.NoError(t, utils.UnmarshalYaml(rootsYamlFile, rootsYaml), "Failed to Unmarshal") - // All types support fastssz generated code, but may also include a custom HTR method. + // All types support generated code, but may also include a custom HTR method. var htrs []HTR htrs = append(htrs, func(s any) ([32]byte, error) { - sszObj, ok := s.(fssz.HashRoot) + sszObj, ok := s.(ssz.HashRoot) if !ok { return [32]byte{}, errors.New("could not get hash root, not compatible object") } @@ -75,8 +77,8 @@ func RunSSZStaticTests(t *testing.T, config, forkOrPhase string, unmarshaller Un for i, htr := range htrs { var testName string - if i == 0 { // First HTR test is fastssz generated code. - testName = "fastssz" + if i == 0 { // First HTR test is generated code. + testName = "generated" } else { testName = "custom" } @@ -85,17 +87,18 @@ func RunSSZStaticTests(t *testing.T, config, forkOrPhase string, unmarshaller Un require.NoError(t, err) rootBytes, err := hex.DecodeString(rootsYaml.Root[2:]) require.NoError(t, err) - require.DeepEqual(t, rootBytes, root[:], "Did not receive expected hash tree root") + expected := bytesutil.ToBytes32(rootBytes) + require.Equal(t, expected, root, "Did not receive expected hash tree root") if rootsYaml.SigningRoot == "" { return } var signingRoot [32]byte - if v, ok := object.(fssz.HashRoot); ok { + if v, ok := object.(ssz.HashRoot); ok { signingRoot, err = v.HashTreeRoot() } else { - t.Fatal("object does not meet fssz.HashRoot") + t.Fatal("object does not meet ssz.HashRoot") } require.NoError(t, err) diff --git a/testing/spectest/shared/common/ssz_static/ssz_static_example_test.go b/testing/spectest/shared/common/ssz_static/ssz_static_example_test.go index 4ae469f96198..745b4f810fb1 100644 --- a/testing/spectest/shared/common/ssz_static/ssz_static_example_test.go +++ b/testing/spectest/shared/common/ssz_static/ssz_static_example_test.go @@ -5,12 +5,13 @@ import ( "fmt" "testing" + "github.com/OffchainLabs/methodical-ssz/ssz" + "github.com/pkg/errors" + state_native "github.com/OffchainLabs/prysm/v7/beacon-chain/state/state-native" ethpb "github.com/OffchainLabs/prysm/v7/proto/prysm/v1alpha1" "github.com/OffchainLabs/prysm/v7/testing/require" common "github.com/OffchainLabs/prysm/v7/testing/spectest/shared/common/ssz_static" - "github.com/pkg/errors" - fssz "github.com/prysmaticlabs/fastssz" ) func ExampleRunSSZStaticTests() { @@ -33,10 +34,10 @@ func ExampleRunSSZStaticTests() { return nil, fmt.Errorf("unsupported type: %s", objectName) } var err error - if o, ok := obj.(fssz.Unmarshaler); ok { + if o, ok := obj.(ssz.Unmarshaler); ok { err = o.UnmarshalSSZ(serializedBytes) } else { - err = errors.New("could not unmarshal object, not a fastssz compatible object") + err = errors.New("could not unmarshal object, does not implement Unmarshaler interface") } return obj, err } @@ -60,7 +61,7 @@ func ExampleRunSSZStaticTests() { var t *testing.T // common.RunSSZStaticTests will run all of the tests found in the spec test folder with the // given config and forkOrPhase. It will then use the unmarshaller to hydrate the types and - // ensure that fastssz generated methods match the expected results. It will also test custom + // ensure that generated methods match the expected results. It will also test custom // HTR methods if provided. common.RunSSZStaticTests(t, "mainnet", // Network configuration diff --git a/testing/spectest/shared/deneb/ssz_static/BUILD.bazel b/testing/spectest/shared/deneb/ssz_static/BUILD.bazel index 1af7f9a5241e..92b77f41f572 100644 --- a/testing/spectest/shared/deneb/ssz_static/BUILD.bazel +++ b/testing/spectest/shared/deneb/ssz_static/BUILD.bazel @@ -12,6 +12,6 @@ go_library( "//proto/prysm/v1alpha1:go_default_library", "//testing/require:go_default_library", "//testing/spectest/shared/common/ssz_static:go_default_library", - "@com_github_prysmaticlabs_fastssz//:go_default_library", + "@com_github_offchainlabs_methodical_ssz//ssz:go_default_library", ], ) diff --git a/testing/spectest/shared/deneb/ssz_static/ssz_static.go b/testing/spectest/shared/deneb/ssz_static/ssz_static.go index d26f7526b922..affe27121400 100644 --- a/testing/spectest/shared/deneb/ssz_static/ssz_static.go +++ b/testing/spectest/shared/deneb/ssz_static/ssz_static.go @@ -5,12 +5,13 @@ import ( "errors" "testing" + "github.com/OffchainLabs/methodical-ssz/ssz" + state_native "github.com/OffchainLabs/prysm/v7/beacon-chain/state/state-native" enginev1 "github.com/OffchainLabs/prysm/v7/proto/engine/v1" ethpb "github.com/OffchainLabs/prysm/v7/proto/prysm/v1alpha1" "github.com/OffchainLabs/prysm/v7/testing/require" common "github.com/OffchainLabs/prysm/v7/testing/spectest/shared/common/ssz_static" - fssz "github.com/prysmaticlabs/fastssz" ) // RunSSZStaticTests executes "ssz_static" tests. @@ -137,10 +138,10 @@ func UnmarshalledSSZ(t *testing.T, serializedBytes []byte, folderName string) (a return nil, errors.New("type not found") } var err error - if o, ok := obj.(fssz.Unmarshaler); ok { + if o, ok := obj.(ssz.Unmarshaler); ok { err = o.UnmarshalSSZ(serializedBytes) } else { - err = errors.New("could not unmarshal object, not a fastssz compatible object") + err = errors.New("could not unmarshal object, does not implement Unmarshaler interface") } return obj, err } diff --git a/testing/spectest/shared/electra/ssz_static/BUILD.bazel b/testing/spectest/shared/electra/ssz_static/BUILD.bazel index b73104c509dc..dc78d2478d0d 100644 --- a/testing/spectest/shared/electra/ssz_static/BUILD.bazel +++ b/testing/spectest/shared/electra/ssz_static/BUILD.bazel @@ -12,6 +12,6 @@ go_library( "//proto/prysm/v1alpha1:go_default_library", "//testing/require:go_default_library", "//testing/spectest/shared/common/ssz_static:go_default_library", - "@com_github_prysmaticlabs_fastssz//:go_default_library", + "@com_github_offchainlabs_methodical_ssz//ssz:go_default_library", ], ) diff --git a/testing/spectest/shared/electra/ssz_static/ssz_static.go b/testing/spectest/shared/electra/ssz_static/ssz_static.go index 565eb095eca5..1bb952e75b9e 100644 --- a/testing/spectest/shared/electra/ssz_static/ssz_static.go +++ b/testing/spectest/shared/electra/ssz_static/ssz_static.go @@ -5,12 +5,13 @@ import ( "errors" "testing" + "github.com/OffchainLabs/methodical-ssz/ssz" + state_native "github.com/OffchainLabs/prysm/v7/beacon-chain/state/state-native" enginev1 "github.com/OffchainLabs/prysm/v7/proto/engine/v1" ethpb "github.com/OffchainLabs/prysm/v7/proto/prysm/v1alpha1" "github.com/OffchainLabs/prysm/v7/testing/require" common "github.com/OffchainLabs/prysm/v7/testing/spectest/shared/common/ssz_static" - fssz "github.com/prysmaticlabs/fastssz" ) // RunSSZStaticTests executes "ssz_static" tests. @@ -153,10 +154,10 @@ func UnmarshalledSSZ(t *testing.T, serializedBytes []byte, folderName string) (a return nil, errors.New("type not found") } var err error - if o, ok := obj.(fssz.Unmarshaler); ok { + if o, ok := obj.(ssz.Unmarshaler); ok { err = o.UnmarshalSSZ(serializedBytes) } else { - err = errors.New("could not unmarshal object, not a fastssz compatible object") + err = errors.New("could not unmarshal object, does not implement Unmarshaler interface") } return obj, err } diff --git a/testing/spectest/shared/fulu/ssz_static/BUILD.bazel b/testing/spectest/shared/fulu/ssz_static/BUILD.bazel index 24918c3bf70d..472727d5a5e9 100644 --- a/testing/spectest/shared/fulu/ssz_static/BUILD.bazel +++ b/testing/spectest/shared/fulu/ssz_static/BUILD.bazel @@ -12,6 +12,6 @@ go_library( "//proto/prysm/v1alpha1:go_default_library", "//testing/require:go_default_library", "//testing/spectest/shared/common/ssz_static:go_default_library", - "@com_github_prysmaticlabs_fastssz//:go_default_library", + "@com_github_offchainlabs_methodical_ssz//ssz:go_default_library", ], ) diff --git a/testing/spectest/shared/fulu/ssz_static/ssz_static.go b/testing/spectest/shared/fulu/ssz_static/ssz_static.go index 8d3529ce2380..b01777aa4d28 100644 --- a/testing/spectest/shared/fulu/ssz_static/ssz_static.go +++ b/testing/spectest/shared/fulu/ssz_static/ssz_static.go @@ -5,12 +5,12 @@ import ( "errors" "testing" + "github.com/OffchainLabs/methodical-ssz/ssz" state_native "github.com/OffchainLabs/prysm/v7/beacon-chain/state/state-native" enginev1 "github.com/OffchainLabs/prysm/v7/proto/engine/v1" ethpb "github.com/OffchainLabs/prysm/v7/proto/prysm/v1alpha1" "github.com/OffchainLabs/prysm/v7/testing/require" common "github.com/OffchainLabs/prysm/v7/testing/spectest/shared/common/ssz_static" - fssz "github.com/prysmaticlabs/fastssz" ) // RunSSZStaticTests executes "ssz_static" tests. @@ -161,7 +161,7 @@ func UnmarshalledSSZ(t *testing.T, serializedBytes []byte, folderName string) (a return nil, errors.New("type not found") } var err error - if o, ok := obj.(fssz.Unmarshaler); ok { + if o, ok := obj.(ssz.Unmarshaler); ok { err = o.UnmarshalSSZ(serializedBytes) } else { err = errors.New("could not unmarshal object, not a fastssz compatible object") diff --git a/testing/spectest/shared/gloas/ssz_static/BUILD.bazel b/testing/spectest/shared/gloas/ssz_static/BUILD.bazel index 3c5936068bf3..6ea520c0fa94 100644 --- a/testing/spectest/shared/gloas/ssz_static/BUILD.bazel +++ b/testing/spectest/shared/gloas/ssz_static/BUILD.bazel @@ -8,10 +8,11 @@ go_library( visibility = ["//testing/spectest:__subpackages__"], deps = [ "//beacon-chain/state/state-native:go_default_library", + "//config/features:go_default_library", "//proto/engine/v1:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//testing/require:go_default_library", "//testing/spectest/shared/common/ssz_static:go_default_library", - "@com_github_prysmaticlabs_fastssz//:go_default_library", + "@com_github_offchainlabs_methodical_ssz//ssz:go_default_library", ], ) diff --git a/testing/spectest/shared/gloas/ssz_static/ssz_static.go b/testing/spectest/shared/gloas/ssz_static/ssz_static.go index 447732f30ac7..a50ad202f327 100644 --- a/testing/spectest/shared/gloas/ssz_static/ssz_static.go +++ b/testing/spectest/shared/gloas/ssz_static/ssz_static.go @@ -3,19 +3,34 @@ package ssz_static import ( "context" "errors" + "os" "testing" state_native "github.com/OffchainLabs/prysm/v7/beacon-chain/state/state-native" // enginev1 "github.com/OffchainLabs/prysm/v7/proto/engine/v1" + ssz "github.com/OffchainLabs/methodical-ssz/ssz" + "github.com/OffchainLabs/prysm/v7/config/features" enginev1 "github.com/OffchainLabs/prysm/v7/proto/engine/v1" ethpb "github.com/OffchainLabs/prysm/v7/proto/prysm/v1alpha1" "github.com/OffchainLabs/prysm/v7/testing/require" common "github.com/OffchainLabs/prysm/v7/testing/spectest/shared/common/ssz_static" - fssz "github.com/prysmaticlabs/fastssz" ) // RunSSZStaticTests executes "ssz_static" tests. +// +// The native-state (`custom`) HashTreeRoot uses progressive merkleization only +// when features.EnableProgressiveSSZ is set (and version >= Gloas). That runtime +// flag is independent of the --//tools:disable_progressive_merkleization codegen +// flag, so when running gloas against progressive fixtures set PROGRESSIVE_SSZ=1 +// to align the native-state root with the generated one. Leave it unset for the +// non-progressive fixture set. func RunSSZStaticTests(t *testing.T, config string) { + if os.Getenv("PROGRESSIVE_SSZ") != "" { + cfg := *features.Get() // nil-safe; copy so other flags are preserved + cfg.EnableProgressiveSSZ = true + reset := features.InitWithReset(&cfg) + defer reset() + } common.RunSSZStaticTests(t, config, "gloas", unmarshalledSSZ, customHtr) } @@ -86,7 +101,7 @@ func unmarshalledSSZ(t *testing.T, serializedBytes []byte, folderName string) (a case "AttestationData": obj = ðpb.AttestationData{} case "AttesterSlashing": - obj = ðpb.AttesterSlashingElectra{} + obj = ðpb.AttesterSlashingGloas{} case "AggregateAndProof": obj = ðpb.AggregateAttestationAndProofGloas{} case "BeaconBlockHeader": @@ -110,7 +125,7 @@ func unmarshalledSSZ(t *testing.T, serializedBytes []byte, folderName string) (a case "HistoricalBatch": obj = ðpb.HistoricalBatch{} case "IndexedAttestation": - obj = ðpb.IndexedAttestationElectra{} + obj = ðpb.IndexedAttestationGloas{} case "PendingAttestation": obj = ðpb.PendingAttestation{} case "ProposerSlashing": @@ -190,7 +205,7 @@ func unmarshalledSSZ(t *testing.T, serializedBytes []byte, folderName string) (a } var err error - if o, ok := obj.(fssz.Unmarshaler); ok { + if o, ok := obj.(ssz.Unmarshaler); ok { err = o.UnmarshalSSZ(serializedBytes) } else { err = errors.New("could not unmarshal object, not a fastssz compatible object") diff --git a/testing/spectest/shared/phase0/ssz_static/BUILD.bazel b/testing/spectest/shared/phase0/ssz_static/BUILD.bazel index 7c2211e2d509..4486ce37ecf7 100644 --- a/testing/spectest/shared/phase0/ssz_static/BUILD.bazel +++ b/testing/spectest/shared/phase0/ssz_static/BUILD.bazel @@ -11,6 +11,6 @@ go_library( "//proto/prysm/v1alpha1:go_default_library", "//testing/require:go_default_library", "//testing/spectest/shared/common/ssz_static:go_default_library", - "@com_github_prysmaticlabs_fastssz//:go_default_library", + "@com_github_offchainlabs_methodical_ssz//ssz:go_default_library", ], ) diff --git a/testing/spectest/shared/phase0/ssz_static/ssz_static.go b/testing/spectest/shared/phase0/ssz_static/ssz_static.go index 5aac42732468..41fc34c3ecd8 100644 --- a/testing/spectest/shared/phase0/ssz_static/ssz_static.go +++ b/testing/spectest/shared/phase0/ssz_static/ssz_static.go @@ -5,11 +5,12 @@ import ( "errors" "testing" + "github.com/OffchainLabs/methodical-ssz/ssz" + state_native "github.com/OffchainLabs/prysm/v7/beacon-chain/state/state-native" ethpb "github.com/OffchainLabs/prysm/v7/proto/prysm/v1alpha1" "github.com/OffchainLabs/prysm/v7/testing/require" common "github.com/OffchainLabs/prysm/v7/testing/spectest/shared/common/ssz_static" - fssz "github.com/prysmaticlabs/fastssz" ) // RunSSZStaticTests executes "ssz_static" tests. @@ -92,10 +93,10 @@ func unmarshalledSSZ(t *testing.T, serializedBytes []byte, objectName string) (a return nil, errors.New("type not found") } var err error - if o, ok := obj.(fssz.Unmarshaler); ok { + if o, ok := obj.(ssz.Unmarshaler); ok { err = o.UnmarshalSSZ(serializedBytes) } else { - err = errors.New("could not unmarshal object, not a fastssz compatible object") + err = errors.New("could not unmarshal object, does not implement Unmarshaler interface") } return obj, err } diff --git a/tools/BUILD.bazel b/tools/BUILD.bazel index 36425f5ca60b..57eb91d839f0 100644 --- a/tools/BUILD.bazel +++ b/tools/BUILD.bazel @@ -1,6 +1,18 @@ +load("@bazel_skylib//rules:common_settings.bzl", "bool_flag") load("@rules_distroless//distroless:defs.bzl", "passwd") load("@rules_pkg//pkg:pkg.bzl", "pkg_tar") +# Build-wide toggle for SSZ progressive merkleization. When set, every +# ssz_methodical() codegen action passes --disable-progressive, so containers +# merkleize as standard SSZ containers and progressive collections downgrade to +# their bounded forms. Read by the ssz_methodical rule in //tools:methodical.bzl. +# Usage: bazel build --//tools:disable_progressive_merkleization //... +bool_flag( + name = "disable_progressive_merkleization", + build_setting_default = False, + visibility = ["//visibility:public"], +) + passwd( name = "passwd", passwds = [ diff --git a/tools/genception/BUILD.bazel b/tools/genception/BUILD.bazel new file mode 100644 index 000000000000..e5079cccfcf2 --- /dev/null +++ b/tools/genception/BUILD.bazel @@ -0,0 +1,5 @@ +alias( + name = "methodicalgen", + actual = "@com_github_offchainlabs_methodical_ssz//cmd/ssz:ssz", + visibility = ["//visibility:public"], +) diff --git a/tools/methodical.bzl b/tools/methodical.bzl new file mode 100644 index 000000000000..d7ddc924e542 --- /dev/null +++ b/tools/methodical.bzl @@ -0,0 +1,217 @@ +load("@bazel_skylib//rules:common_settings.bzl", "BuildSettingInfo") +load("@io_bazel_rules_go//go:def.bzl", "GoLibrary", "GoSource", "go_context", "new_go_info") +load("@io_bazel_rules_go//go/tools/gopackagesdriver:aspect.bzl", "GoPkgInfo", "go_pkg_info_aspect") + +_METHODICAL_TOOL = Label("//tools/genception:methodicalgen") +_GENCEPTION_TOOL = Label("//tools/genception/cmd:cmd") +_SSZ_RUNTIME = Label("@com_github_offchainlabs_methodical_ssz//ssz:go_default_library") + +def _ssz_methodical_impl(ctx): + go_ctx = go_context(ctx) + all_json_files = {} + stdlib = "" + inputs = [ctx.file.config_file] + ssz_lib = ctx.attr.ssz_lib[GoLibrary] + generated_srcs = getattr(ssz_lib, "srcs", []) + ssz_sources = new_go_info( + go_ctx, + ctx.attr, + name = ssz_lib.name, + importpath = ssz_lib.importpath, + coverage_instrumented = ctx.coverage_instrumented(), + generated_srcs = generated_srcs, + pathtype = ssz_lib.pathtype, + verify_resolver_deps = True, + ) + inputs += ssz_sources.srcs + for dep in ctx.attr.deps + [ctx.attr.ssz_lib]: + pkginfo = dep[OutputGroupInfo] + if hasattr(pkginfo, "go_generated_srcs"): + inputs += pkginfo.go_generated_srcs.to_list() + + # collect all the paths to json files dict keys for uniqueness + json_files = pkginfo.go_pkg_driver_json_file.to_list() + inputs += json_files + if len(json_files) > 0: + for jf in json_files: + # presumably path is full path from exec root + all_json_files[jf.path] = "" + inputs += pkginfo.go_pkg_driver_srcs.to_list() + inputs += pkginfo.go_pkg_driver_export_file.to_list() + + # we just ned to get the stdlib once + if stdlib == "": + std_ds = pkginfo.go_pkg_driver_stdlib_json_file.to_list() + if len(std_ds) > 0: + stdlib = std_ds[0].path + inputs += std_ds + + # concat the stdlib with all the other json file paths and write to disk + json_out = [stdlib] + all_json_files.keys() + all_pkg_list = ctx.actions.declare_file("methodical-pkg-list.json") + ctx.actions.write(all_pkg_list, content = json.encode(json_out)) + out_base = ctx.outputs.out.root.path + + # The //proto:network build setting (mainnet|minimal) -- the same flag the + # ssz_proto_files select() keys on -- determines which .pb.go sizes the + # go_proto dep was built with, and therefore which //go:build constraint + # methodical must stamp so the output matches the mainnet/minimal pair that + # //build/gen writes. methodical emits no header on its own; both codegen + # paths drive it through --go-build-constraint. + go_build_constraint = "!minimal" + if ctx.attr._network[BuildSettingInfo].value == "minimal": + go_build_constraint = "minimal" + + args = [ + "gen", + "--config=" + ctx.file.config_file.path, + "--output=" + ctx.outputs.out.path, + "--go-build-constraint=" + go_build_constraint, + ] + if ctx.attr.override_package_name != "": + args.append("--override-package-name=" + ctx.attr.override_package_name) + if ctx.attr._disable_progressive[BuildSettingInfo].value: + args.append("--disable-progressive") + + codegen_bins = [ctx.file.genception, ctx.file.methodical_tool] + ctx.actions.run_shell( + env = { + "PACKAGE_JSON_INVENTORY": all_pkg_list.path, + "PACKAGES_BASE": out_base, + "GOCACHE": "./.gocache", + "GOPACKAGESDRIVER": ctx.file.genception.path, + "GOPACKAGESDRIVER_LOG_PATH": out_base + "/gopackagesdriver.log", + }, + inputs = [all_pkg_list] + inputs + codegen_bins, + outputs = [ctx.outputs.out], + command = """ + {cmd} {args} + """.format( + out_base = out_base, + json_list = all_pkg_list.path, + cmd = "$(pwd)/" + ctx.file.methodical_tool.path, + args = " ".join(args), + out = ctx.outputs.out.path, + ), + ) + +ssz_methodical = rule( + implementation = _ssz_methodical_impl, + attrs = { + "config_file": attr.label( + doc = "path to yaml config file for methodical --config flag ", + mandatory = True, + allow_single_file = True, + ), + "out": attr.output( + doc = "The new Go file to emit the generated mocks into", + ), + "override_package_name": attr.string( + doc = "Override the name of the package the generated file is in (eg 'eth' for proto/prysm/v1alpha1)", + mandatory = False, + ), + # Build-wide progressive-merkleization toggle. Defaults to the + # //tools:disable_progressive_merkleization bool_flag so a single + # `--//tools:disable_progressive_merkleization` flips every + # ssz_methodical target to --disable-progressive with no per-call edits. + "_disable_progressive": attr.label( + default = "//tools:disable_progressive_merkleization", + ), + # The //proto:network string_flag (mainnet|minimal) that ssz_proto_files + # selects on. Read here to pick the //go:build constraint methodical + # stamps, so --//proto:network=minimal yields a `//go:build minimal` + # file matching //build/gen's minimal twin, with no per-call edits. + "_network": attr.label( + default = "//proto:network", + ), + "deps": attr.label_list(aspects = [go_pkg_info_aspect]), + # provides access to the go toolchain via go_context(), enabling package driver indexing. + "_go_context_data": attr.label( + default = "@io_bazel_rules_go//:go_context_data", + ), + "methodical_tool": attr.label( + doc = "The methodical tool (binary) to run", + default = _METHODICAL_TOOL, + allow_single_file = True, + executable = True, + cfg = "exec", + mandatory = False, + ), + "genception": attr.label( + doc = "gopackagesdriver tool for package discovery inside bazel sandbox", + default = _GENCEPTION_TOOL, + allow_single_file = True, + executable = True, + cfg = "exec", + mandatory = False, + ), + # injects ssz library into the generation enviroment for indexing by the package driver. + "ssz_lib": attr.label(providers = [GoLibrary], default = _SSZ_RUNTIME, aspects = [go_pkg_info_aspect]), + }, + toolchains = ["@io_bazel_rules_go//go:toolchain"], +) + +def _ssz_gen_spectest_impl(ctx): + # gen-spectest does no package loading or code generation: it only + # interpolates names from the yaml config and copies fixtures out of a + # consensus-spec-tests release tarball. So, unlike ssz_methodical (the + # `gen` subcommand), it needs none of the gopackagesdriver / go_pkg_info + # apparatus -- just the config, the tarball, and the methodical binary. + out_dir = ctx.actions.declare_directory(ctx.attr.out_dir) + tool = ctx.file.methodical_tool + + args = [ + "gen-spectest", + # The tool reads the archive via a file:// URI; resolve it to an + # absolute path under the exec root at action time. + "--release-uri=file://$(pwd)/" + ctx.file.release_tarball.path, + "--config=" + ctx.file.config_file.path, + "--output=" + out_dir.path, + ] + if ctx.attr.package_name != "": + args.append("--package-name=" + ctx.attr.package_name) + + ctx.actions.run_shell( + inputs = [ctx.file.config_file, ctx.file.release_tarball], + tools = [tool], + outputs = [out_dir], + command = "$(pwd)/{tool} {args}".format( + tool = tool.path, + args = " ".join(args), + ), + mnemonic = "SszGenSpectest", + progress_message = "Generating ssz spectests from %s" % ctx.file.config_file.short_path, + ) + return [DefaultInfo(files = depset([out_dir]))] + +ssz_gen_spectest = rule( + implementation = _ssz_gen_spectest_impl, + attrs = { + "config_file": attr.label( + doc = "path to the spectest yaml config (same format as the standalone spectest command)", + mandatory = True, + allow_single_file = True, + ), + "release_tarball": attr.label( + doc = "consensus-spec-tests release tarball, e.g. @consensus_spec_tests//:mainnet.tar.gz", + mandatory = True, + allow_single_file = True, + ), + "out_dir": attr.string( + doc = "name of the generated tree-artifact directory (holds methodical_test.go and testdata/)", + mandatory = True, + ), + "package_name": attr.string( + doc = "package name for the generated test file (default: 'spectest', set by the tool)", + mandatory = False, + ), + "methodical_tool": attr.label( + doc = "The methodical tool (binary) to run", + default = _METHODICAL_TOOL, + allow_single_file = True, + executable = True, + cfg = "exec", + mandatory = False, + ), + }, +) diff --git a/tools/pcli/BUILD.bazel b/tools/pcli/BUILD.bazel index 18f2924575fc..7edc54ee9a11 100644 --- a/tools/pcli/BUILD.bazel +++ b/tools/pcli/BUILD.bazel @@ -20,8 +20,8 @@ go_library( "//runtime/logging/logrus-prefixed-formatter:go_default_library", "//runtime/version:go_default_library", "@com_github_kr_pretty//:go_default_library", + "@com_github_offchainlabs_methodical_ssz//ssz:go_default_library", "@com_github_pkg_errors//:go_default_library", - "@com_github_prysmaticlabs_fastssz//:go_default_library", "@com_github_sirupsen_logrus//:go_default_library", "@com_github_urfave_cli_v2//:go_default_library", "@in_gopkg_d4l3k_messagediff_v1//:go_default_library", diff --git a/tools/pcli/main.go b/tools/pcli/main.go index 4df6e00c2071..982dd9e0db58 100644 --- a/tools/pcli/main.go +++ b/tools/pcli/main.go @@ -10,6 +10,13 @@ import ( "strings" "time" + "github.com/OffchainLabs/methodical-ssz/ssz" + "github.com/kr/pretty" + "github.com/pkg/errors" + log "github.com/sirupsen/logrus" + "github.com/urfave/cli/v2" + "gopkg.in/d4l3k/messagediff.v1" + "github.com/OffchainLabs/prysm/v7/beacon-chain/core/epoch/precompute" "github.com/OffchainLabs/prysm/v7/beacon-chain/core/transition" "github.com/OffchainLabs/prysm/v7/beacon-chain/state" @@ -21,12 +28,6 @@ import ( ethpb "github.com/OffchainLabs/prysm/v7/proto/prysm/v1alpha1" prefixed "github.com/OffchainLabs/prysm/v7/runtime/logging/logrus-prefixed-formatter" "github.com/OffchainLabs/prysm/v7/runtime/version" - "github.com/kr/pretty" - "github.com/pkg/errors" - fssz "github.com/prysmaticlabs/fastssz" - log "github.com/sirupsen/logrus" - "github.com/urfave/cli/v2" - "gopkg.in/d4l3k/messagediff.v1" ) var blockPath string @@ -65,7 +66,7 @@ var prettyCommand = &cli.Command{ }, }, Action: func(c *cli.Context) error { - var data fssz.Unmarshaler + var data ssz.Unmarshaler switch sszType { case "block": data = ðpb.BeaconBlock{} @@ -323,7 +324,7 @@ func main() { } // dataFetcher fetches and unmarshals data from file to provided data structure. -func dataFetcher(fPath string, data fssz.Unmarshaler) error { +func dataFetcher(fPath string, data ssz.Unmarshaler) error { rawFile, err := os.ReadFile(fPath) // #nosec G304 if err != nil { return err @@ -359,7 +360,7 @@ func detectBlock(fPath string) (interfaces.SignedBeaconBlock, error) { return vu.UnmarshalBeaconBlock(rawFile) } -func prettyPrint(sszPath string, data fssz.Unmarshaler) { +func prettyPrint(sszPath string, data ssz.Unmarshaler) { if err := dataFetcher(sszPath, data); err != nil { log.Fatal(err) } diff --git a/tools/ssz.bzl b/tools/ssz.bzl deleted file mode 100644 index bf15ca519d4e..000000000000 --- a/tools/ssz.bzl +++ /dev/null @@ -1,110 +0,0 @@ -""" -A rule that uses the generated pb.go files from a go_proto_library target to generate SSZ marshal -and unmarshal functions as pointer receivers on the specified objects. To use this rule, provide a -go_proto_library target and specify the structs to generate methods in the "objs" field. Lastly, -include your new target as a source for the go_library that embeds the go_proto_library. -Example: -go_proto_library( - name = "example_go_proto", - ... -) -ssz_gen_marshal( - name = "ssz_generated_sources", - go_proto = ":example_go_proto", - objs = [ # omit this field to generate for all structs in the package. - "AddressBook", - "Person", - ], -) -go_library( - name = "go_default_library", - srcs = [":ssz_generated_sources"], - embed = [":example_go_proto"], - deps = SSZ_DEPS, -) -""" - -load( - "@io_bazel_rules_go//go:def.bzl", - "GoLibrary", - "GoSource", -) - -def _ssz_go_proto_library_impl(ctx): - if ctx.var.get("ssz"): - fail("--define=ssz= is no longer supported, please use --//proto:network=") - - if ctx.attr.go_proto != None: - go_proto = ctx.attr.go_proto - input_files = go_proto[OutputGroupInfo].go_generated_srcs.to_list() - package_path = input_files[0].dirname - elif hasattr(ctx.attr, "srcs") and len(ctx.attr.srcs) > 0: - package_path = ctx.attr.srcs[0].files.to_list()[0].dirname - input_files = ctx.attr.srcs[0].files.to_list() - else: - fail("Must have go_proto or srcs") - - # Run the tool. - output = ctx.outputs.out - args = [ - "--output=%s" % output.path, - "--path=%s" % package_path, - ] - if hasattr(ctx.attr, "includes") and len(ctx.attr.includes) > 0: - incs = [] - for include in ctx.attr.includes: - incs.append(include[GoSource].srcs[0].dirname) - input_files += include[GoSource].srcs - args.append("--include=%s" % ",".join(incs)) - - if len(ctx.attr.objs) > 0: - args.append("--objs=%s" % ",".join(ctx.attr.objs)) - - if len(ctx.attr.exclude_objs) > 0: - args.append("--exclude-objs=%s" % ",".join(ctx.attr.exclude_objs)) - - # golang.org/x/tools requires the go binary to be available in the PATH. - # Follows the same pattern as https://github.com/bazel-contrib/rules_go/pull/4173 - sdk = ctx.toolchains["@io_bazel_rules_go//go:toolchain"].sdk - goroot = sdk.root_file.dirname - env = { - "PATH": "PATH={goroot}/bin:$PATH".format(goroot = goroot), - "GOROOT": goroot, - } - ctx.actions.run_shell( - outputs = [output], - command = """ - export GOROOT=$(pwd)/{goroot} && - export PATH=$GOROOT/bin:$PATH && - {cmd} {args}""".format( - goroot = goroot, - cmd = ctx.executable.sszgen.path, - args = " ".join(args), - ), - tools = [ - ctx.executable.sszgen, - sdk.go, - ], - mnemonic = "SszGen", - inputs = input_files, - ) - -ssz_gen_marshal = rule( - implementation = _ssz_go_proto_library_impl, - attrs = { - "srcs": attr.label_list(allow_files = True), - "go_proto": attr.label(providers = [GoLibrary]), - "sszgen": attr.label( - default = Label("@com_github_prysmaticlabs_fastssz//sszgen:sszgen"), - executable = True, - cfg = "exec", - ), - "objs": attr.string_list(), - "exclude_objs": attr.string_list(), - "includes": attr.label_list(providers = [GoLibrary]), - "out": attr.output(), - }, - toolchains = ["@io_bazel_rules_go//go:toolchain"], -) - -SSZ_DEPS = ["@com_github_prysmaticlabs_fastssz//:go_default_library"]