From 5ebc50fa0d3d068dd56a798408bfc7e647baf882 Mon Sep 17 00:00:00 2001 From: pk910 Date: Wed, 13 May 2026 00:20:12 +0200 Subject: [PATCH 1/2] generate & use streaming interfaces for BeaconState --- api/v1/bellatrix/blindedbeaconblock_ssz.go | 2 +- .../bellatrix/blindedbeaconblockbody_ssz.go | 2 +- .../bellatrix/signedblindedbeaconblock_ssz.go | 2 +- api/v1/capella/blindedbeaconblock_ssz.go | 2 +- api/v1/capella/blindedbeaconblockbody_ssz.go | 2 +- .../capella/signedblindedbeaconblock_ssz.go | 2 +- api/versionedblindedbeaconblock_ssz.go | 2 +- api/versionedsignedblindedbeaconblock_ssz.go | 2 +- http/beaconstate.go | 83 +- http/http.go | 122 +- http/service.go | 34 + spec/all/beaconstate.go | 49 + spec/all/beaconstate_ssz.go | 15481 ++++++++++++++-- spec/all/generate.yaml | 1 + spec/altair/beaconstate_ssz.go | 922 +- spec/altair/generate.yaml | 1 + spec/bellatrix/beaconblock_ssz.go | 2 +- spec/bellatrix/beaconblockbody_ssz.go | 2 +- spec/bellatrix/beaconstate_ssz.go | 977 +- spec/bellatrix/executionpayload_ssz.go | 8 +- spec/bellatrix/executionpayloadheader_ssz.go | 10 +- spec/bellatrix/generate.yaml | 1 + spec/bellatrix/signedbeaconblock_ssz.go | 2 +- spec/capella/beaconblock_ssz.go | 2 +- spec/capella/beaconblockbody_ssz.go | 2 +- spec/capella/beaconstate_ssz.go | 1072 +- spec/capella/executionpayload_ssz.go | 10 +- spec/capella/executionpayloadheader_ssz.go | 10 +- spec/capella/generate.yaml | 1 + spec/capella/signedbeaconblock_ssz.go | 2 +- spec/deneb/beaconstate_ssz.go | 1072 +- spec/deneb/generate.yaml | 1 + spec/electra/beaconstate_ssz.go | 1381 +- spec/electra/generate.yaml | 1 + spec/fulu/beaconstate_ssz.go | 1410 +- spec/fulu/generate.yaml | 1 + spec/gloas/beaconstate_ssz.go | 2504 ++- spec/gloas/generate.yaml | 1 + spec/heze/beaconstate_ssz.go | 2712 ++- spec/heze/generate.yaml | 1 + 40 files changed, 25049 insertions(+), 2845 deletions(-) diff --git a/api/v1/bellatrix/blindedbeaconblock_ssz.go b/api/v1/bellatrix/blindedbeaconblock_ssz.go index 0d8d79ca..d7736a5e 100644 --- a/api/v1/bellatrix/blindedbeaconblock_ssz.go +++ b/api/v1/bellatrix/blindedbeaconblock_ssz.go @@ -1,5 +1,5 @@ // Code generated by dynamic-ssz. DO NOT EDIT. -// Hash: 4e07721dc17ecc8c904da40da11a282b73769a6fab0a1c01f08e51a18d8716db +// Hash: 1fa9bed6502b2ffe506a08eaaa496f1109ce91e0966e86fd91272c3e19137ba5 // Version: v1.3.1 (https://github.com/pk910/dynamic-ssz) package bellatrix diff --git a/api/v1/bellatrix/blindedbeaconblockbody_ssz.go b/api/v1/bellatrix/blindedbeaconblockbody_ssz.go index 9f4238cb..f5cd12b6 100644 --- a/api/v1/bellatrix/blindedbeaconblockbody_ssz.go +++ b/api/v1/bellatrix/blindedbeaconblockbody_ssz.go @@ -1,5 +1,5 @@ // Code generated by dynamic-ssz. DO NOT EDIT. -// Hash: 1b8492e1bb706c87c5b5ca6d4ad5fee81dfcafc4f88e2f999dca0446977cebdd +// Hash: 36c271163269b445f6c6e3708694ac62a44c042f116a61204b843eaff5d23da9 // Version: v1.3.1 (https://github.com/pk910/dynamic-ssz) package bellatrix diff --git a/api/v1/bellatrix/signedblindedbeaconblock_ssz.go b/api/v1/bellatrix/signedblindedbeaconblock_ssz.go index c0a33867..bda28646 100644 --- a/api/v1/bellatrix/signedblindedbeaconblock_ssz.go +++ b/api/v1/bellatrix/signedblindedbeaconblock_ssz.go @@ -1,5 +1,5 @@ // Code generated by dynamic-ssz. DO NOT EDIT. -// Hash: f02189c7c0e4e47cb3353c76cde7fc880fb5243e86accb323ba66af34f4caf0e +// Hash: 028972e3b29ae708d802bace9ced01bff1602a0905b598c2b0046272fca97059 // Version: v1.3.1 (https://github.com/pk910/dynamic-ssz) package bellatrix diff --git a/api/v1/capella/blindedbeaconblock_ssz.go b/api/v1/capella/blindedbeaconblock_ssz.go index fafe47f4..3d841271 100644 --- a/api/v1/capella/blindedbeaconblock_ssz.go +++ b/api/v1/capella/blindedbeaconblock_ssz.go @@ -1,5 +1,5 @@ // Code generated by dynamic-ssz. DO NOT EDIT. -// Hash: 37f24353820f6fcea76d5a7142fa19b4948bbb343342dc031e83c42fdab79408 +// Hash: 57d5b6a7562e222bcd9ccfc2f7fcf41816dcb2f2567b25c14f8764dcfd1c96b7 // Version: v1.3.1 (https://github.com/pk910/dynamic-ssz) package capella diff --git a/api/v1/capella/blindedbeaconblockbody_ssz.go b/api/v1/capella/blindedbeaconblockbody_ssz.go index cfdc98f3..94e7ac5a 100644 --- a/api/v1/capella/blindedbeaconblockbody_ssz.go +++ b/api/v1/capella/blindedbeaconblockbody_ssz.go @@ -1,5 +1,5 @@ // Code generated by dynamic-ssz. DO NOT EDIT. -// Hash: bd38e229c4edde658c8d714c0aada5ad4a3f9d1e5ff6b11231e0e7cfe5c1a2e7 +// Hash: 3b35804fd0c57fc3b867187dddc849dfcf0165171fb8a2d3d83e19af04d5dce7 // Version: v1.3.1 (https://github.com/pk910/dynamic-ssz) package capella diff --git a/api/v1/capella/signedblindedbeaconblock_ssz.go b/api/v1/capella/signedblindedbeaconblock_ssz.go index e493c818..1875430c 100644 --- a/api/v1/capella/signedblindedbeaconblock_ssz.go +++ b/api/v1/capella/signedblindedbeaconblock_ssz.go @@ -1,5 +1,5 @@ // Code generated by dynamic-ssz. DO NOT EDIT. -// Hash: 0a259d24bb4066a2bf9016030e9e54cfd7eb1f222ff3ef7028fa9f3e67272ad7 +// Hash: e0eeaa72aa00d0b1601c5ff072ae212a5a2dcaa2a9c4fddd0a0f5c388154a0a3 // Version: v1.3.1 (https://github.com/pk910/dynamic-ssz) package capella diff --git a/api/versionedblindedbeaconblock_ssz.go b/api/versionedblindedbeaconblock_ssz.go index 2a5a93f7..87e3b6c9 100644 --- a/api/versionedblindedbeaconblock_ssz.go +++ b/api/versionedblindedbeaconblock_ssz.go @@ -1,5 +1,5 @@ // Code generated by dynamic-ssz. DO NOT EDIT. -// Hash: 35bdb60b5b6157e70d9e19955ba6308bce83263d0556f59d1f0682ef8d8cd230 +// Hash: 980f9c646054adc8c284c853ac47aa1a4065bb095adc67493041dc5d33074e74 // Version: v1.3.1 (https://github.com/pk910/dynamic-ssz) package api diff --git a/api/versionedsignedblindedbeaconblock_ssz.go b/api/versionedsignedblindedbeaconblock_ssz.go index 79f1bda2..6f2db659 100644 --- a/api/versionedsignedblindedbeaconblock_ssz.go +++ b/api/versionedsignedblindedbeaconblock_ssz.go @@ -1,5 +1,5 @@ // Code generated by dynamic-ssz. DO NOT EDIT. -// Hash: 9cbc7789a4c2c2872a073a078549978372dcae68d91e0b29e34fc79a7182c5ac +// Hash: 3951940e16f568896dab337063709d0a90541c46f1df43fd5f8ea2121ac9bfef // Version: v1.3.1 (https://github.com/pk910/dynamic-ssz) package api diff --git a/http/beaconstate.go b/http/beaconstate.go index f2db9bd6..af542850 100644 --- a/http/beaconstate.go +++ b/http/beaconstate.go @@ -32,12 +32,12 @@ import ( "github.com/ethpandaops/go-eth2-client/spec/gloas" "github.com/ethpandaops/go-eth2-client/spec/heze" "github.com/ethpandaops/go-eth2-client/spec/phase0" - dynssz "github.com/pk910/dynamic-ssz" ) // BeaconState fetches a beacon state given a state ID and decodes it directly -// into the per-fork view stored on a *spec.VersionedBeaconState. No -// intermediate copy. +// into the per-fork view stored on a *spec.VersionedBeaconState. SSZ +// responses are streamed straight from the wire into the SSZ decoder so the +// (potentially multi-GB) payload is never held in memory in full. func (s *Service) BeaconState(ctx context.Context, opts *api.BeaconStateOpts, ) ( @@ -48,6 +48,7 @@ func (s *Service) BeaconState(ctx context.Context, if err != nil { return nil, err } + defer httpResponse.Close() switch httpResponse.contentType { case ContentTypeSSZ: @@ -62,7 +63,8 @@ func (s *Service) BeaconState(ctx context.Context, // AgnosticBeaconState fetches a beacon state and decodes it directly into a // fork-agnostic *all.BeaconState. The Version is set from the consensus // version header before unmarshaling so the union type's view-aware codec -// dispatches into the correct fork's schema. No intermediate copy. +// dispatches into the correct fork's schema. SSZ responses are streamed +// from the wire into the SSZ decoder; no intermediate copy. func (s *Service) AgnosticBeaconState(ctx context.Context, opts *api.BeaconStateOpts, ) ( @@ -73,8 +75,10 @@ func (s *Service) AgnosticBeaconState(ctx context.Context, if err != nil { return nil, err } + defer httpResponse.Close() state := &all.BeaconState{Version: httpResponse.consensusVersion} + metadata := metadataFromHeaders(httpResponse.headers) switch httpResponse.contentType { case ContentTypeSSZ: @@ -83,25 +87,30 @@ func (s *Service) AgnosticBeaconState(ctx context.Context, return nil, err } - if err := state.UnmarshalSSZDyn(ds, httpResponse.body); err != nil { + if err := ds.UnmarshalSSZReader(state, httpResponse.bodyReader, int(httpResponse.bodySize)); err != nil { return nil, errors.Join(fmt.Errorf("failed to decode %s beacon state", httpResponse.consensusVersion), err) } case ContentTypeJSON: - if err := state.UnmarshalJSON(httpResponse.body); err != nil { + decoded, jsonMetadata, err := decodeJSONResponse(bytes.NewReader(httpResponse.body), state) + if err != nil { return nil, errors.Join(fmt.Errorf("failed to decode %s beacon state", httpResponse.consensusVersion), err) } + state = decoded + metadata = jsonMetadata default: return nil, fmt.Errorf("unhandled content type %v", httpResponse.contentType) } return &api.Response[*all.BeaconState]{ Data: state, - Metadata: metadataFromHeaders(httpResponse.headers), + Metadata: metadata, }, nil } // fetchBeaconState performs the GET request shared by BeaconState and -// AgnosticBeaconState: validates opts and hits the endpoint. +// AgnosticBeaconState: validates opts and hits the endpoint. The response is +// fetched via getStream so SSZ payloads are not buffered into memory; the +// caller is responsible for invoking httpResponse.Close. func (s *Service) fetchBeaconState(ctx context.Context, opts *api.BeaconStateOpts, ) (*httpResponse, error) { @@ -119,7 +128,7 @@ func (s *Service) fetchBeaconState(ctx context.Context, endpoint := fmt.Sprintf("/eth/v2/debug/beacon/states/%s", opts.State) - return s.get(ctx, endpoint, "", &opts.Common, true) + return s.getStream(ctx, endpoint, "", &opts.Common, true) } func (s *Service) beaconStateFromSSZ(ctx context.Context, res *httpResponse) (*api.Response[*spec.VersionedBeaconState], error) { @@ -135,38 +144,42 @@ func (s *Service) beaconStateFromSSZ(ctx context.Context, res *httpResponse) (*a return nil, err } + size := int(res.bodySize) + + var target any switch res.consensusVersion { case spec.DataVersionPhase0: response.Data.Phase0 = &phase0.BeaconState{} - err = dynSSZ.UnmarshalSSZ(response.Data.Phase0, res.body) + target = response.Data.Phase0 case spec.DataVersionAltair: response.Data.Altair = &altair.BeaconState{} - err = dynSSZ.UnmarshalSSZ(response.Data.Altair, res.body) + target = response.Data.Altair case spec.DataVersionBellatrix: response.Data.Bellatrix = &bellatrix.BeaconState{} - err = dynSSZ.UnmarshalSSZ(response.Data.Bellatrix, res.body) + target = response.Data.Bellatrix case spec.DataVersionCapella: response.Data.Capella = &capella.BeaconState{} - err = dynSSZ.UnmarshalSSZ(response.Data.Capella, res.body) + target = response.Data.Capella case spec.DataVersionDeneb: response.Data.Deneb = &deneb.BeaconState{} - err = dynSSZ.UnmarshalSSZ(response.Data.Deneb, res.body) + target = response.Data.Deneb case spec.DataVersionElectra: response.Data.Electra = &electra.BeaconState{} - err = dynSSZ.UnmarshalSSZ(response.Data.Electra, res.body) + target = response.Data.Electra case spec.DataVersionFulu: response.Data.Fulu = &fulu.BeaconState{} - err = dynSSZ.UnmarshalSSZ(response.Data.Fulu, res.body) + target = response.Data.Fulu case spec.DataVersionGloas: response.Data.Gloas = &gloas.BeaconState{} - err = dynSSZ.UnmarshalSSZ(response.Data.Gloas, res.body) + target = response.Data.Gloas case spec.DataVersionHeze: response.Data.Heze = &heze.BeaconState{} - err = dynSSZ.UnmarshalSSZ(response.Data.Heze, res.body) + target = response.Data.Heze default: return nil, fmt.Errorf("unhandled state version %s", res.consensusVersion) } + err = dynSSZ.UnmarshalSSZReader(target, res.bodyReader, size) if err != nil { return nil, errors.Join(fmt.Errorf("failed to decode %s beacon state", res.consensusVersion), err) } @@ -174,40 +187,6 @@ func (s *Service) beaconStateFromSSZ(ctx context.Context, res *httpResponse) (*a return response, nil } -// dynSSZForRequest returns the cached dynssz instance for the current spec -// snapshot, fetching the spec lazily on the first call (and rebuilding the -// instance when clearStaticValues invalidates the cache). The instance's -// internal type cache is reused across calls, which is the whole point of -// caching it here rather than newing one up per request. -func (s *Service) dynSSZForRequest(ctx context.Context) (*dynssz.DynSsz, error) { - if !s.customSpecSupport { - return dynssz.GetGlobalDynSsz(), nil - } - - s.specMutex.RLock() - cached := s.dynSSZ - s.specMutex.RUnlock() - - if cached != nil { - return cached, nil - } - - // Trigger Spec() which fetches+caches both the spec map and the dynssz - // instance built from it. - if _, err := s.Spec(ctx, &api.SpecOpts{}); err != nil { - return nil, errors.Join(errors.New("failed to request specs"), err) - } - - s.specMutex.RLock() - defer s.specMutex.RUnlock() - - if s.dynSSZ != nil { - return s.dynSSZ, nil - } - - return dynssz.GetGlobalDynSsz(), nil -} - func (*Service) beaconStateFromJSON(res *httpResponse) (*api.Response[*spec.VersionedBeaconState], error) { response := &api.Response[*spec.VersionedBeaconState]{ Data: &spec.VersionedBeaconState{ diff --git a/http/http.go b/http/http.go index 86b259d8..4b9367b2 100644 --- a/http/http.go +++ b/http/http.go @@ -225,9 +225,31 @@ type httpResponse struct { headers map[string]string consensusVersion spec.DataVersion body []byte + + // bodyReader is set by getStream for 2xx SSZ responses so the caller can + // decode directly from the wire without a full in-memory copy. When set, + // body is empty and the caller MUST call Close() to release the + // underlying connection. + bodyReader io.ReadCloser + // bodySize is the Content-Length of the streaming body, or -1 when the + // server did not advertise one (e.g. chunked transfer). + bodySize int64 +} + +// Close releases the streaming body if one is held. Safe to call when no +// stream is held (no-op). +func (r *httpResponse) Close() error { + if r == nil || r.bodyReader == nil { + return nil + } + err := r.bodyReader.Close() + r.bodyReader = nil + + return err } -// get sends an HTTP get request and returns the response. +// get sends an HTTP get request and returns the response with the body fully +// buffered into memory. // //nolint:revive func (s *Service) get(ctx context.Context, @@ -238,6 +260,41 @@ func (s *Service) get(ctx context.Context, ) ( *httpResponse, error, +) { + return s.getInternal(ctx, endpoint, query, opts, supportsSSZ, false) +} + +// getStream is like get, but for 2xx SSZ responses it leaves the body open +// as res.bodyReader so the caller can decode straight from the wire. The +// caller MUST call res.Close() to release the connection. For non-SSZ or +// non-2xx responses the body is fully buffered into res.body, exactly like +// get; res.bodyReader is then nil and Close() is a no-op. +func (s *Service) getStream(ctx context.Context, + endpoint string, + query string, + opts *api.CommonOpts, + supportsSSZ bool, +) ( + *httpResponse, + error, +) { + return s.getInternal(ctx, endpoint, query, opts, supportsSSZ, true) +} + +// getInternal implements get and getStream. When stream is true and the +// response is a 2xx SSZ payload, the response body is handed back via +// res.bodyReader without being read into memory. +// +//nolint:revive +func (s *Service) getInternal(ctx context.Context, + endpoint string, + query string, + opts *api.CommonOpts, + supportsSSZ bool, + stream bool, +) ( + *httpResponse, + error, ) { ctx, span := otel.Tracer("attestantio.go-eth2-client.http").Start(ctx, "get") defer span.End() @@ -295,7 +352,6 @@ func (s *Service) get(ctx context.Context, return nil, errors.Join(errors.New("failed to call GET endpoint"), err) } - defer resp.Body.Close() log = log.With().Int("status_code", resp.StatusCode).Logger() @@ -304,6 +360,51 @@ func (s *Service) get(ctx context.Context, } populateHeaders(res, resp) + if resp.StatusCode == http.StatusNoContent { + // Nothing returned. This is not considered an error. + _ = resp.Body.Close() + span.AddEvent("Received empty response") + log.Trace().Msg("Endpoint returned no content") + s.monitorGetComplete(ctx, callURL.Path, "succeeded") + + return res, nil + } + + if err := populateContentType(res, resp); err != nil { + // For now, assume that unknown type is JSON. + log.Debug().Err(err).Msg("Failed to obtain content type; assuming JSON") + + res.contentType = ContentTypeJSON + } + + statusFamily := statusCodeFamily(resp.StatusCode) + + // Streaming path: 2xx SSZ responses are handed to the caller as an open + // reader so the SSZ decoder can read directly off the wire. Everything + // else (non-2xx, JSON, etc.) is buffered below, matching the original + // behavior so callers that don't care about streaming see no change. + if stream && statusFamily == 2 && res.contentType == ContentTypeSSZ { + if err := populateConsensusVersion(res, resp); err != nil { + _ = resp.Body.Close() + + return nil, errors.Join(errors.New("failed to parse consensus version"), err) + } + + res.bodyReader = resp.Body + res.bodySize = resp.ContentLength + + span.AddEvent("Received response", trace.WithAttributes( + attribute.Int64("size", resp.ContentLength), + attribute.String("content-type", res.contentType.String()), + )) + + s.monitorGetComplete(ctx, callURL.Path, "succeeded") + + return res, nil + } + + defer resp.Body.Close() + // Although it would be more efficient to keep the body as a Reader, that would // require the calling function to be aware that it needs to close the body // once it is done with it. To avoid that complexity, we read here and store the @@ -325,28 +426,11 @@ func (s *Service) get(ctx context.Context, return nil, errors.Join(errors.New("failed to read GET response"), err) } - if resp.StatusCode == http.StatusNoContent { - // Nothing returned. This is not considered an error. - span.AddEvent("Received empty response") - log.Trace().Msg("Endpoint returned no content") - s.monitorGetComplete(ctx, callURL.Path, "succeeded") - - return res, nil - } - - if err := populateContentType(res, resp); err != nil { - // For now, assume that unknown type is JSON. - log.Debug().Err(err).Msg("Failed to obtain content type; assuming JSON") - - res.contentType = ContentTypeJSON - } - span.AddEvent("Received response", trace.WithAttributes( attribute.Int("size", len(res.body)), attribute.String("content-type", res.contentType.String()), )) - statusFamily := statusCodeFamily(resp.StatusCode) if statusFamily != 2 { s.logBadStatus(ctx, "GET", res, log) diff --git a/http/service.go b/http/service.go index 22ab6247..3699c519 100644 --- a/http/service.go +++ b/http/service.go @@ -444,3 +444,37 @@ func parseAddress(address string) (*url.URL, *url.URL, error) { return base, &baseAddress, nil } + +// dynSSZForRequest returns the cached dynssz instance for the current spec +// snapshot, fetching the spec lazily on the first call (and rebuilding the +// instance when clearStaticValues invalidates the cache). The instance's +// internal type cache is reused across calls, which is the whole point of +// caching it here rather than newing one up per request. +func (s *Service) dynSSZForRequest(ctx context.Context) (*dynssz.DynSsz, error) { + if !s.customSpecSupport { + return dynssz.GetGlobalDynSsz(), nil + } + + s.specMutex.RLock() + cached := s.dynSSZ + s.specMutex.RUnlock() + + if cached != nil { + return cached, nil + } + + // Trigger Spec() which fetches+caches both the spec map and the dynssz + // instance built from it. + if _, err := s.Spec(ctx, &api.SpecOpts{}); err != nil { + return nil, errors.Join(errors.New("failed to request specs"), err) + } + + s.specMutex.RLock() + defer s.specMutex.RUnlock() + + if s.dynSSZ != nil { + return s.dynSSZ, nil + } + + return dynssz.GetGlobalDynSsz(), nil +} diff --git a/spec/all/beaconstate.go b/spec/all/beaconstate.go index eda43819..fb9b67f1 100644 --- a/spec/all/beaconstate.go +++ b/spec/all/beaconstate.go @@ -133,6 +133,26 @@ func (b *BeaconState) MarshalSSZDyn(ds sszutils.DynamicSpecs, buf []byte) ([]byt return fn(ds, buf) } +// MarshalSSZEncoder is the streaming counterpart of MarshalSSZDyn: it lets +// dynssz dispatch through the DynamicEncoder interface and route writes to +// the per-fork view's generated encoder without buffering the full payload. +func (b *BeaconState) MarshalSSZEncoder(ds sszutils.DynamicSpecs, enc sszutils.Encoder) error { + view, err := b.viewType() + if err != nil { + return err + } + m, ok := any(b).(sszutils.DynamicViewEncoder) + if !ok { + return errors.New("BeaconState: generated SSZ code missing") + } + fn := m.MarshalSSZEncoderView(view) + if fn == nil { + return fmt.Errorf("BeaconState: no view encoder for version %d", b.Version) + } + + return fn(ds, enc) +} + // SizeSSZDyn returns the SSZ size of the state for the active Version. func (b *BeaconState) SizeSSZDyn(ds sszutils.DynamicSpecs) int { view, err := b.viewType() @@ -175,6 +195,35 @@ func (b *BeaconState) UnmarshalSSZDyn(ds sszutils.DynamicSpecs, buf []byte) erro return nil } +// UnmarshalSSZDecoder is the streaming counterpart of UnmarshalSSZDyn: it +// lets dynssz dispatch through the DynamicDecoder interface so the +// (potentially multi-GB) state payload can be read directly off the wire, +// while the view-aware decoder picks the correct fork's schema from +// b.Version. populateVersion runs at the end so children allocated during +// decode have Version seeded, matching the buffered path. +func (b *BeaconState) UnmarshalSSZDecoder(ds sszutils.DynamicSpecs, dec sszutils.Decoder) error { + view, err := b.viewType() + if err != nil { + return err + } + d, ok := any(b).(sszutils.DynamicViewDecoder) + if !ok { + return errors.New("BeaconState: generated SSZ code missing") + } + fn := d.UnmarshalSSZDecoderView(view) + if fn == nil { + return fmt.Errorf("BeaconState: no view decoder for version %d", b.Version) + } + + if err := fn(ds, dec); err != nil { + return err + } + + b.populateVersion(b.Version) + + return nil +} + // populateVersion sets Version and propagates it to any nested versionable // children allocated by the SSZ unmarshal. func (b *BeaconState) populateVersion(v version.DataVersion) { diff --git a/spec/all/beaconstate_ssz.go b/spec/all/beaconstate_ssz.go index d9186519..b828d9b7 100644 --- a/spec/all/beaconstate_ssz.go +++ b/spec/all/beaconstate_ssz.go @@ -1,5 +1,5 @@ // Code generated by dynamic-ssz. DO NOT EDIT. -// Hash: 3e3847c3da47d09def45854ee3b4a380293b6b7a1150497b801f3dd3823bd97e +// Hash: 50b34232d41b42903a460677b81dfe1c8a8f979227520a76aabf87ddb7cdbdd0 // Version: v1.3.1 (https://github.com/pk910/dynamic-ssz) package all @@ -3684,30 +3684,9847 @@ func (t *BeaconState) marshalSSZView_BeaconState_7(ds sszutils.DynamicSpecs, buf return dst, nil } +func (t *BeaconState) MarshalSSZEncoderView(view any) func(ds sszutils.DynamicSpecs, enc sszutils.Encoder) error { + switch view.(type) { + case *phase0.BeaconState: + return t.marshalSSZEncoderView_BeaconState + case *altair.BeaconState: + return t.marshalSSZEncoderView_BeaconState_0 + case *bellatrix.BeaconState: + return t.marshalSSZEncoderView_BeaconState_1 + case *capella.BeaconState: + return t.marshalSSZEncoderView_BeaconState_2 + case *deneb.BeaconState: + return t.marshalSSZEncoderView_BeaconState_3 + case *electra.BeaconState: + return t.marshalSSZEncoderView_BeaconState_4 + case *fulu.BeaconState: + return t.marshalSSZEncoderView_BeaconState_5 + case *gloas.BeaconState: + return t.marshalSSZEncoderView_BeaconState_6 + case *heze.BeaconState: + return t.marshalSSZEncoderView_BeaconState_7 + } + return nil +} +func (t *BeaconState) marshalSSZEncoderView_BeaconState(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + type encoderCtx struct { + ds sszutils.DynamicSpecs + exprs [7]uint64 + sizeFn1 func(ctx *encoderCtx, t []phase0.Root) (size int) + sizeFn2 func(ctx *encoderCtx, t []*phase0.ETH1Data) (size int) + sizeFn3 func(ctx *encoderCtx, t []*phase0.Validator) (size int) + sizeFn4 func(ctx *encoderCtx, t []phase0.Gwei) (size int) + sizeFn5 func(ctx *encoderCtx, t []*phase0.PendingAttestation) (size int) + sizeFn6 func(ctx *encoderCtx, t []*phase0.PendingAttestation) (size int) + sizeFn7 func(ctx *encoderCtx, t *phase0.PendingAttestation) (size int) + sizeFn8 func(ctx *encoderCtx, t *phase0.PendingAttestation) (size int) + } + ctx := &encoderCtx{ds: ds} + canSeek := enc.Seekable() + ctx.exprs[0], err = sszutils.ResolveSpecValueWithDefault(ds, "SLOTS_PER_HISTORICAL_ROOT", 8192) + if err != nil { + return err + } + ctx.exprs[1], err = sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_HISTORICAL_VECTOR", 65536) + if err != nil { + return err + } + ctx.exprs[2], err = sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_SLASHINGS_VECTOR", 8192) + if err != nil { + return err + } + ctx.exprs[3], err = sszutils.ResolveSpecValueWithDefault(ds, "HISTORICAL_ROOTS_LIMIT", 16777216) + if err != nil { + return err + } + ctx.exprs[4], err = sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_ETH1_VOTING_PERIOD*SLOTS_PER_EPOCH", 2048) + if err != nil { + return err + } + ctx.exprs[5], err = sszutils.ResolveSpecValueWithDefault(ds, "VALIDATOR_REGISTRY_LIMIT", 1099511627776) + if err != nil { + return err + } + ctx.exprs[6], err = sszutils.ResolveSpecValueWithDefault(ds, "MAX_ATTESTATIONS*SLOTS_PER_EPOCH", 4096) + if err != nil { + return err + } + // size for []phase0.Root + ctx.sizeFn1 = func(ctx *encoderCtx, t []phase0.Root) (size int) { + size += len(t) * 32 + return size + } + // size for []*phase0.ETH1Data + ctx.sizeFn2 = func(ctx *encoderCtx, t []*phase0.ETH1Data) (size int) { + size += len(t) * 72 + return size + } + // size for []*phase0.Validator + ctx.sizeFn3 = func(ctx *encoderCtx, t []*phase0.Validator) (size int) { + size += len(t) * 121 + return size + } + // size for []phase0.Gwei + ctx.sizeFn4 = func(ctx *encoderCtx, t []phase0.Gwei) (size int) { + size += len(t) * 8 + return size + } + // size for []*phase0.PendingAttestation + ctx.sizeFn5 = func(ctx *encoderCtx, t []*phase0.PendingAttestation) (size int) { + vlen := len(t) + size += vlen * 4 // Offsets + for i1 := range vlen { + size += ctx.sizeFn7(ctx, t[i1]) + } + return size + } + // size for []*phase0.PendingAttestation + ctx.sizeFn6 = func(ctx *encoderCtx, t []*phase0.PendingAttestation) (size int) { + vlen := len(t) + size += vlen * 4 // Offsets + for i1 := range vlen { + size += ctx.sizeFn8(ctx, t[i1]) + } + return size + } + // size for *phase0.PendingAttestation + ctx.sizeFn7 = func(ctx *encoderCtx, t *phase0.PendingAttestation) (size int) { + size += t.SizeSSZ() + return size + } + // size for *phase0.PendingAttestation + ctx.sizeFn8 = func(ctx *encoderCtx, t *phase0.PendingAttestation) (size int) { + size += t.SizeSSZ() + return size + } + size1 := 32 * int(ctx.exprs[0]) + size2 := 32 * int(ctx.exprs[1]) + size3 := 8 * int(ctx.exprs[2]) + if t == nil { + t = new(BeaconState) + } + dstlen := enc.GetPosition() + dynoff := uint32(size1 + size1 + size2 + size3 + 401) + { // Field #0 'GenesisTime' + enc.EncodeUint64(t.GenesisTime) + } + { // Field #1 'GenesisValidatorsRoot' + enc.EncodeBytes(t.GenesisValidatorsRoot[:32]) + } + { // Field #2 'Slot' + enc.EncodeUint64(uint64(t.Slot)) + } + { // Field #3 'Fork' + t := t.Fork + if t == nil { + t = new(phase0.Fork) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "Fork") + } else { + enc.SetBuffer(buf) + } + } + { // Field #4 'LatestBlockHeader' + t := t.LatestBlockHeader + if t == nil { + t = new(phase0.BeaconBlockHeader) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") + } else { + enc.SetBuffer(buf) + } + } + { // Field #5 'BlockRoots' + t := t.BlockRoots + vlen := len(t) + if vlen > int(ctx.exprs[0]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[0])), "BlockRoots") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:32]) + } + if vlen < int(ctx.exprs[0]) { + enc.EncodeZeroPadding((int(ctx.exprs[0]) - vlen) * 32) + } + } + { // Field #6 'StateRoots' + t := t.StateRoots + vlen := len(t) + if vlen > int(ctx.exprs[0]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[0])), "StateRoots") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:32]) + } + if vlen < int(ctx.exprs[0]) { + enc.EncodeZeroPadding((int(ctx.exprs[0]) - vlen) * 32) + } + } + // Offset #7 'HistoricalRoots' + offset7 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn1(ctx, t.HistoricalRoots)) + } + { // Field #8 'ETH1Data' + t := t.ETH1Data + if t == nil { + t = new(phase0.ETH1Data) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "ETH1Data") + } else { + enc.SetBuffer(buf) + } + } + // Offset #9 'ETH1DataVotes' + offset9 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn2(ctx, t.ETH1DataVotes)) + } + { // Field #10 'ETH1DepositIndex' + enc.EncodeUint64(t.ETH1DepositIndex) + } + // Offset #11 'Validators' + offset11 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn3(ctx, t.Validators)) + } + // Offset #12 'Balances' + offset12 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn4(ctx, t.Balances)) + } + { // Field #13 'RANDAOMixes' + t := t.RANDAOMixes + vlen := len(t) + if vlen > int(ctx.exprs[1]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[1])), "RANDAOMixes") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:32]) + } + if vlen < int(ctx.exprs[1]) { + enc.EncodeZeroPadding((int(ctx.exprs[1]) - vlen) * 32) + } + } + { // Field #14 'Slashings' + t := t.Slashings + vlen := len(t) + if vlen > int(ctx.exprs[2]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[2])), "Slashings") + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + if vlen < int(ctx.exprs[2]) { + enc.EncodeZeroPadding((int(ctx.exprs[2]) - vlen) * 8) + } + } + // Offset #15 'PreviousEpochAttestations' + offset15 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn5(ctx, t.PreviousEpochAttestations)) + } + // Offset #16 'CurrentEpochAttestations' + offset16 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn6(ctx, t.CurrentEpochAttestations)) + } + { // Field #17 'JustificationBits' + vlen := len(t.JustificationBits) + if vlen > 1 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 1), "JustificationBits") + } + enc.EncodeBytes(t.JustificationBits[:vlen]) + if vlen < 1 { + enc.EncodeZeroPadding((1 - vlen) * 1) + } + } + { // Field #18 'PreviousJustifiedCheckpoint' + t := t.PreviousJustifiedCheckpoint + if t == nil { + t = new(phase0.Checkpoint) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } else { + enc.SetBuffer(buf) + } + } + { // Field #19 'CurrentJustifiedCheckpoint' + t := t.CurrentJustifiedCheckpoint + if t == nil { + t = new(phase0.Checkpoint) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } else { + enc.SetBuffer(buf) + } + } + { // Field #20 'FinalizedCheckpoint' + t := t.FinalizedCheckpoint + if t == nil { + t = new(phase0.Checkpoint) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") + } else { + enc.SetBuffer(buf) + } + } + { // Dynamic Field #7 'HistoricalRoots' + if canSeek { + enc.EncodeOffsetAt(offset7, uint32(enc.GetPosition()-dstlen)) + } + t := t.HistoricalRoots + vlen := len(t) + if vlen > int(ctx.exprs[3]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[3])), "HistoricalRoots") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:32]) + } + } + { // Dynamic Field #9 'ETH1DataVotes' + if canSeek { + enc.EncodeOffsetAt(offset9, uint32(enc.GetPosition()-dstlen)) + } + t := t.ETH1DataVotes + vlen := len(t) + if vlen > int(ctx.exprs[4]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[4])), "ETH1DataVotes") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(phase0.ETH1Data) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "ETH1DataVotes[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #11 'Validators' + if canSeek { + enc.EncodeOffsetAt(offset11, uint32(enc.GetPosition()-dstlen)) + } + t := t.Validators + vlen := len(t) + if vlen > int(ctx.exprs[5]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[5])), "Validators") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(phase0.Validator) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #12 'Balances' + if canSeek { + enc.EncodeOffsetAt(offset12, uint32(enc.GetPosition()-dstlen)) + } + t := t.Balances + vlen := len(t) + if vlen > int(ctx.exprs[5]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[5])), "Balances") + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + } + { // Dynamic Field #15 'PreviousEpochAttestations' + if canSeek { + enc.EncodeOffsetAt(offset15, uint32(enc.GetPosition()-dstlen)) + } + t := t.PreviousEpochAttestations + vlen := len(t) + if vlen > int(ctx.exprs[6]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[6])), "PreviousEpochAttestations") + } + dstlen := enc.GetPosition() + if canSeek { + enc.EncodeZeroPadding(vlen * 4) + } else if vlen > 0 { + offset := vlen * 4 + enc.EncodeOffset(uint32(offset)) + for i := range vlen-1 { + offset += ctx.sizeFn7(ctx, t[i]) + enc.EncodeOffset(uint32(offset)) + } + } + for idx1 := range vlen { + if canSeek { + enc.EncodeOffsetAt(dstlen+(idx1*4), uint32(enc.GetPosition()-dstlen)) + } + t := t[idx1] + if t == nil { + t = new(phase0.PendingAttestation) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "PreviousEpochAttestations[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #16 'CurrentEpochAttestations' + if canSeek { + enc.EncodeOffsetAt(offset16, uint32(enc.GetPosition()-dstlen)) + } + t := t.CurrentEpochAttestations + vlen := len(t) + if vlen > int(ctx.exprs[6]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[6])), "CurrentEpochAttestations") + } + dstlen := enc.GetPosition() + if canSeek { + enc.EncodeZeroPadding(vlen * 4) + } else if vlen > 0 { + offset := vlen * 4 + enc.EncodeOffset(uint32(offset)) + for i := range vlen-1 { + offset += ctx.sizeFn8(ctx, t[i]) + enc.EncodeOffset(uint32(offset)) + } + } + for idx1 := range vlen { + if canSeek { + enc.EncodeOffsetAt(dstlen+(idx1*4), uint32(enc.GetPosition()-dstlen)) + } + t := t[idx1] + if t == nil { + t = new(phase0.PendingAttestation) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "CurrentEpochAttestations[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + return nil +} + +func (t *BeaconState) marshalSSZEncoderView_BeaconState_0(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + type encoderCtx struct { + ds sszutils.DynamicSpecs + exprs [7]uint64 + sizeFn1 func(ctx *encoderCtx, t []phase0.Root) (size int) + sizeFn2 func(ctx *encoderCtx, t []*phase0.ETH1Data) (size int) + sizeFn3 func(ctx *encoderCtx, t []*phase0.Validator) (size int) + sizeFn4 func(ctx *encoderCtx, t []phase0.Gwei) (size int) + sizeFn5 func(ctx *encoderCtx, t []altair.ParticipationFlags) (size int) + sizeFn6 func(ctx *encoderCtx, t []altair.ParticipationFlags) (size int) + sizeFn7 func(ctx *encoderCtx, t []uint64) (size int) + } + ctx := &encoderCtx{ds: ds} + canSeek := enc.Seekable() + ctx.exprs[0], err = sszutils.ResolveSpecValueWithDefault(ds, "SLOTS_PER_HISTORICAL_ROOT", 8192) + if err != nil { + return err + } + ctx.exprs[1], err = sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_HISTORICAL_VECTOR", 65536) + if err != nil { + return err + } + ctx.exprs[2], err = sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_SLASHINGS_VECTOR", 8192) + if err != nil { + return err + } + ctx.exprs[3], err = sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE", 512) + if err != nil { + return err + } + ctx.exprs[4], err = sszutils.ResolveSpecValueWithDefault(ds, "HISTORICAL_ROOTS_LIMIT", 16777216) + if err != nil { + return err + } + ctx.exprs[5], err = sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_ETH1_VOTING_PERIOD*SLOTS_PER_EPOCH", 2048) + if err != nil { + return err + } + ctx.exprs[6], err = sszutils.ResolveSpecValueWithDefault(ds, "VALIDATOR_REGISTRY_LIMIT", 1099511627776) + if err != nil { + return err + } + // size for []phase0.Root + ctx.sizeFn1 = func(ctx *encoderCtx, t []phase0.Root) (size int) { + size += len(t) * 32 + return size + } + // size for []*phase0.ETH1Data + ctx.sizeFn2 = func(ctx *encoderCtx, t []*phase0.ETH1Data) (size int) { + size += len(t) * 72 + return size + } + // size for []*phase0.Validator + ctx.sizeFn3 = func(ctx *encoderCtx, t []*phase0.Validator) (size int) { + size += len(t) * 121 + return size + } + // size for []phase0.Gwei + ctx.sizeFn4 = func(ctx *encoderCtx, t []phase0.Gwei) (size int) { + size += len(t) * 8 + return size + } + // size for []altair.ParticipationFlags + ctx.sizeFn5 = func(ctx *encoderCtx, t []altair.ParticipationFlags) (size int) { + size += len(t) + return size + } + // size for []altair.ParticipationFlags + ctx.sizeFn6 = func(ctx *encoderCtx, t []altair.ParticipationFlags) (size int) { + size += len(t) + return size + } + // size for []uint64 + ctx.sizeFn7 = func(ctx *encoderCtx, t []uint64) (size int) { + size += len(t) * 8 + return size + } + size1 := 32 * int(ctx.exprs[0]) + size2 := 32 * int(ctx.exprs[1]) + size3 := 8 * int(ctx.exprs[2]) + size5 := 48 * int(ctx.exprs[3]) + size4 := size5 + 48 // size expression for '*SyncCommittee' + if t == nil { + t = new(BeaconState) + } + dstlen := enc.GetPosition() + dynoff := uint32(size1 + size1 + size2 + size3 + size4 + size4 + 405) + { // Field #0 'GenesisTime' + enc.EncodeUint64(t.GenesisTime) + } + { // Field #1 'GenesisValidatorsRoot' + enc.EncodeBytes(t.GenesisValidatorsRoot[:32]) + } + { // Field #2 'Slot' + enc.EncodeUint64(uint64(t.Slot)) + } + { // Field #3 'Fork' + t := t.Fork + if t == nil { + t = new(phase0.Fork) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "Fork") + } else { + enc.SetBuffer(buf) + } + } + { // Field #4 'LatestBlockHeader' + t := t.LatestBlockHeader + if t == nil { + t = new(phase0.BeaconBlockHeader) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") + } else { + enc.SetBuffer(buf) + } + } + { // Field #5 'BlockRoots' + t := t.BlockRoots + vlen := len(t) + if vlen > int(ctx.exprs[0]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[0])), "BlockRoots") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:32]) + } + if vlen < int(ctx.exprs[0]) { + enc.EncodeZeroPadding((int(ctx.exprs[0]) - vlen) * 32) + } + } + { // Field #6 'StateRoots' + t := t.StateRoots + vlen := len(t) + if vlen > int(ctx.exprs[0]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[0])), "StateRoots") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:32]) + } + if vlen < int(ctx.exprs[0]) { + enc.EncodeZeroPadding((int(ctx.exprs[0]) - vlen) * 32) + } + } + // Offset #7 'HistoricalRoots' + offset7 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn1(ctx, t.HistoricalRoots)) + } + { // Field #8 'ETH1Data' + t := t.ETH1Data + if t == nil { + t = new(phase0.ETH1Data) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "ETH1Data") + } else { + enc.SetBuffer(buf) + } + } + // Offset #9 'ETH1DataVotes' + offset9 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn2(ctx, t.ETH1DataVotes)) + } + { // Field #10 'ETH1DepositIndex' + enc.EncodeUint64(t.ETH1DepositIndex) + } + // Offset #11 'Validators' + offset11 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn3(ctx, t.Validators)) + } + // Offset #12 'Balances' + offset12 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn4(ctx, t.Balances)) + } + { // Field #13 'RANDAOMixes' + t := t.RANDAOMixes + vlen := len(t) + if vlen > int(ctx.exprs[1]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[1])), "RANDAOMixes") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:32]) + } + if vlen < int(ctx.exprs[1]) { + enc.EncodeZeroPadding((int(ctx.exprs[1]) - vlen) * 32) + } + } + { // Field #14 'Slashings' + t := t.Slashings + vlen := len(t) + if vlen > int(ctx.exprs[2]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[2])), "Slashings") + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + if vlen < int(ctx.exprs[2]) { + enc.EncodeZeroPadding((int(ctx.exprs[2]) - vlen) * 8) + } + } + // Offset #15 'PreviousEpochParticipation' + offset15 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn5(ctx, t.PreviousEpochParticipation)) + } + // Offset #16 'CurrentEpochParticipation' + offset16 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn6(ctx, t.CurrentEpochParticipation)) + } + { // Field #17 'JustificationBits' + vlen := len(t.JustificationBits) + if vlen > 1 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 1), "JustificationBits") + } + enc.EncodeBytes(t.JustificationBits[:vlen]) + if vlen < 1 { + enc.EncodeZeroPadding((1 - vlen) * 1) + } + } + { // Field #18 'PreviousJustifiedCheckpoint' + t := t.PreviousJustifiedCheckpoint + if t == nil { + t = new(phase0.Checkpoint) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } else { + enc.SetBuffer(buf) + } + } + { // Field #19 'CurrentJustifiedCheckpoint' + t := t.CurrentJustifiedCheckpoint + if t == nil { + t = new(phase0.Checkpoint) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } else { + enc.SetBuffer(buf) + } + } + { // Field #20 'FinalizedCheckpoint' + t := t.FinalizedCheckpoint + if t == nil { + t = new(phase0.Checkpoint) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") + } else { + enc.SetBuffer(buf) + } + } + // Offset #21 'InactivityScores' + offset21 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn7(ctx, t.InactivityScores)) + } + { // Field #22 'CurrentSyncCommittee' + t := t.CurrentSyncCommittee + if t == nil { + t = new(altair.SyncCommittee) + } + { // Field #0 'Pubkeys' + t := t.Pubkeys + vlen := len(t) + if vlen > int(ctx.exprs[3]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[3])), "CurrentSyncCommittee.Pubkeys") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:48]) + } + if vlen < int(ctx.exprs[3]) { + enc.EncodeZeroPadding((int(ctx.exprs[3]) - vlen) * 48) + } + } + { // Field #1 'AggregatePubkey' + enc.EncodeBytes(t.AggregatePubkey[:48]) + } + } + { // Field #23 'NextSyncCommittee' + t := t.NextSyncCommittee + if t == nil { + t = new(altair.SyncCommittee) + } + { // Field #0 'Pubkeys' + t := t.Pubkeys + vlen := len(t) + if vlen > int(ctx.exprs[3]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[3])), "NextSyncCommittee.Pubkeys") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:48]) + } + if vlen < int(ctx.exprs[3]) { + enc.EncodeZeroPadding((int(ctx.exprs[3]) - vlen) * 48) + } + } + { // Field #1 'AggregatePubkey' + enc.EncodeBytes(t.AggregatePubkey[:48]) + } + } + { // Dynamic Field #7 'HistoricalRoots' + if canSeek { + enc.EncodeOffsetAt(offset7, uint32(enc.GetPosition()-dstlen)) + } + t := t.HistoricalRoots + vlen := len(t) + if vlen > int(ctx.exprs[4]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[4])), "HistoricalRoots") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:32]) + } + } + { // Dynamic Field #9 'ETH1DataVotes' + if canSeek { + enc.EncodeOffsetAt(offset9, uint32(enc.GetPosition()-dstlen)) + } + t := t.ETH1DataVotes + vlen := len(t) + if vlen > int(ctx.exprs[5]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[5])), "ETH1DataVotes") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(phase0.ETH1Data) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "ETH1DataVotes[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #11 'Validators' + if canSeek { + enc.EncodeOffsetAt(offset11, uint32(enc.GetPosition()-dstlen)) + } + t := t.Validators + vlen := len(t) + if vlen > int(ctx.exprs[6]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[6])), "Validators") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(phase0.Validator) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #12 'Balances' + if canSeek { + enc.EncodeOffsetAt(offset12, uint32(enc.GetPosition()-dstlen)) + } + t := t.Balances + vlen := len(t) + if vlen > int(ctx.exprs[6]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[6])), "Balances") + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + } + { // Dynamic Field #15 'PreviousEpochParticipation' + if canSeek { + enc.EncodeOffsetAt(offset15, uint32(enc.GetPosition()-dstlen)) + } + t := t.PreviousEpochParticipation + vlen := len(t) + if vlen > int(ctx.exprs[6]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[6])), "PreviousEpochParticipation") + } + for idx1 := range vlen { + enc.EncodeUint8(byte(t[idx1])) + } + } + { // Dynamic Field #16 'CurrentEpochParticipation' + if canSeek { + enc.EncodeOffsetAt(offset16, uint32(enc.GetPosition()-dstlen)) + } + t := t.CurrentEpochParticipation + vlen := len(t) + if vlen > int(ctx.exprs[6]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[6])), "CurrentEpochParticipation") + } + for idx1 := range vlen { + enc.EncodeUint8(byte(t[idx1])) + } + } + { // Dynamic Field #21 'InactivityScores' + if canSeek { + enc.EncodeOffsetAt(offset21, uint32(enc.GetPosition()-dstlen)) + } + t := t.InactivityScores + vlen := len(t) + if vlen > int(ctx.exprs[6]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[6])), "InactivityScores") + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + } + return nil +} + +func (t *BeaconState) marshalSSZEncoderView_BeaconState_1(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + type encoderCtx struct { + ds sszutils.DynamicSpecs + exprs [7]uint64 + sizeFn1 func(ctx *encoderCtx, t []phase0.Root) (size int) + sizeFn2 func(ctx *encoderCtx, t []*phase0.ETH1Data) (size int) + sizeFn3 func(ctx *encoderCtx, t []*phase0.Validator) (size int) + sizeFn4 func(ctx *encoderCtx, t []phase0.Gwei) (size int) + sizeFn5 func(ctx *encoderCtx, t []altair.ParticipationFlags) (size int) + sizeFn6 func(ctx *encoderCtx, t []altair.ParticipationFlags) (size int) + sizeFn7 func(ctx *encoderCtx, t []uint64) (size int) + sizeFn8 func(ctx *encoderCtx, t *ExecutionPayloadHeader) (size int) + } + ctx := &encoderCtx{ds: ds} + canSeek := enc.Seekable() + ctx.exprs[0], err = sszutils.ResolveSpecValueWithDefault(ds, "SLOTS_PER_HISTORICAL_ROOT", 8192) + if err != nil { + return err + } + ctx.exprs[1], err = sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_HISTORICAL_VECTOR", 65536) + if err != nil { + return err + } + ctx.exprs[2], err = sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_SLASHINGS_VECTOR", 8192) + if err != nil { + return err + } + ctx.exprs[3], err = sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE", 512) + if err != nil { + return err + } + ctx.exprs[4], err = sszutils.ResolveSpecValueWithDefault(ds, "HISTORICAL_ROOTS_LIMIT", 16777216) + if err != nil { + return err + } + ctx.exprs[5], err = sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_ETH1_VOTING_PERIOD*SLOTS_PER_EPOCH", 2048) + if err != nil { + return err + } + ctx.exprs[6], err = sszutils.ResolveSpecValueWithDefault(ds, "VALIDATOR_REGISTRY_LIMIT", 1099511627776) + if err != nil { + return err + } + // size for []phase0.Root + ctx.sizeFn1 = func(ctx *encoderCtx, t []phase0.Root) (size int) { + size += len(t) * 32 + return size + } + // size for []*phase0.ETH1Data + ctx.sizeFn2 = func(ctx *encoderCtx, t []*phase0.ETH1Data) (size int) { + size += len(t) * 72 + return size + } + // size for []*phase0.Validator + ctx.sizeFn3 = func(ctx *encoderCtx, t []*phase0.Validator) (size int) { + size += len(t) * 121 + return size + } + // size for []phase0.Gwei + ctx.sizeFn4 = func(ctx *encoderCtx, t []phase0.Gwei) (size int) { + size += len(t) * 8 + return size + } + // size for []altair.ParticipationFlags + ctx.sizeFn5 = func(ctx *encoderCtx, t []altair.ParticipationFlags) (size int) { + size += len(t) + return size + } + // size for []altair.ParticipationFlags + ctx.sizeFn6 = func(ctx *encoderCtx, t []altair.ParticipationFlags) (size int) { + size += len(t) + return size + } + // size for []uint64 + ctx.sizeFn7 = func(ctx *encoderCtx, t []uint64) (size int) { + size += len(t) * 8 + return size + } + // size for *ExecutionPayloadHeader + ctx.sizeFn8 = func(ctx *encoderCtx, t *ExecutionPayloadHeader) (size int) { + if viewFn := t.SizeSSZDynView((*bellatrix.ExecutionPayloadHeader)(nil)); viewFn != nil { + size += viewFn(ds) + } + return size + } + size1 := 32 * int(ctx.exprs[0]) + size2 := 32 * int(ctx.exprs[1]) + size3 := 8 * int(ctx.exprs[2]) + size5 := 48 * int(ctx.exprs[3]) + size4 := size5 + 48 // size expression for '*SyncCommittee' + if t == nil { + t = new(BeaconState) + } + dstlen := enc.GetPosition() + dynoff := uint32(size1 + size1 + size2 + size3 + size4 + size4 + 409) + { // Field #0 'GenesisTime' + enc.EncodeUint64(t.GenesisTime) + } + { // Field #1 'GenesisValidatorsRoot' + enc.EncodeBytes(t.GenesisValidatorsRoot[:32]) + } + { // Field #2 'Slot' + enc.EncodeUint64(uint64(t.Slot)) + } + { // Field #3 'Fork' + t := t.Fork + if t == nil { + t = new(phase0.Fork) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "Fork") + } else { + enc.SetBuffer(buf) + } + } + { // Field #4 'LatestBlockHeader' + t := t.LatestBlockHeader + if t == nil { + t = new(phase0.BeaconBlockHeader) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") + } else { + enc.SetBuffer(buf) + } + } + { // Field #5 'BlockRoots' + t := t.BlockRoots + vlen := len(t) + if vlen > int(ctx.exprs[0]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[0])), "BlockRoots") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:32]) + } + if vlen < int(ctx.exprs[0]) { + enc.EncodeZeroPadding((int(ctx.exprs[0]) - vlen) * 32) + } + } + { // Field #6 'StateRoots' + t := t.StateRoots + vlen := len(t) + if vlen > int(ctx.exprs[0]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[0])), "StateRoots") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:32]) + } + if vlen < int(ctx.exprs[0]) { + enc.EncodeZeroPadding((int(ctx.exprs[0]) - vlen) * 32) + } + } + // Offset #7 'HistoricalRoots' + offset7 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn1(ctx, t.HistoricalRoots)) + } + { // Field #8 'ETH1Data' + t := t.ETH1Data + if t == nil { + t = new(phase0.ETH1Data) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "ETH1Data") + } else { + enc.SetBuffer(buf) + } + } + // Offset #9 'ETH1DataVotes' + offset9 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn2(ctx, t.ETH1DataVotes)) + } + { // Field #10 'ETH1DepositIndex' + enc.EncodeUint64(t.ETH1DepositIndex) + } + // Offset #11 'Validators' + offset11 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn3(ctx, t.Validators)) + } + // Offset #12 'Balances' + offset12 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn4(ctx, t.Balances)) + } + { // Field #13 'RANDAOMixes' + t := t.RANDAOMixes + vlen := len(t) + if vlen > int(ctx.exprs[1]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[1])), "RANDAOMixes") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:32]) + } + if vlen < int(ctx.exprs[1]) { + enc.EncodeZeroPadding((int(ctx.exprs[1]) - vlen) * 32) + } + } + { // Field #14 'Slashings' + t := t.Slashings + vlen := len(t) + if vlen > int(ctx.exprs[2]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[2])), "Slashings") + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + if vlen < int(ctx.exprs[2]) { + enc.EncodeZeroPadding((int(ctx.exprs[2]) - vlen) * 8) + } + } + // Offset #15 'PreviousEpochParticipation' + offset15 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn5(ctx, t.PreviousEpochParticipation)) + } + // Offset #16 'CurrentEpochParticipation' + offset16 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn6(ctx, t.CurrentEpochParticipation)) + } + { // Field #17 'JustificationBits' + vlen := len(t.JustificationBits) + if vlen > 1 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 1), "JustificationBits") + } + enc.EncodeBytes(t.JustificationBits[:vlen]) + if vlen < 1 { + enc.EncodeZeroPadding((1 - vlen) * 1) + } + } + { // Field #18 'PreviousJustifiedCheckpoint' + t := t.PreviousJustifiedCheckpoint + if t == nil { + t = new(phase0.Checkpoint) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } else { + enc.SetBuffer(buf) + } + } + { // Field #19 'CurrentJustifiedCheckpoint' + t := t.CurrentJustifiedCheckpoint + if t == nil { + t = new(phase0.Checkpoint) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } else { + enc.SetBuffer(buf) + } + } + { // Field #20 'FinalizedCheckpoint' + t := t.FinalizedCheckpoint + if t == nil { + t = new(phase0.Checkpoint) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") + } else { + enc.SetBuffer(buf) + } + } + // Offset #21 'InactivityScores' + offset21 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn7(ctx, t.InactivityScores)) + } + { // Field #22 'CurrentSyncCommittee' + t := t.CurrentSyncCommittee + if t == nil { + t = new(altair.SyncCommittee) + } + { // Field #0 'Pubkeys' + t := t.Pubkeys + vlen := len(t) + if vlen > int(ctx.exprs[3]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[3])), "CurrentSyncCommittee.Pubkeys") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:48]) + } + if vlen < int(ctx.exprs[3]) { + enc.EncodeZeroPadding((int(ctx.exprs[3]) - vlen) * 48) + } + } + { // Field #1 'AggregatePubkey' + enc.EncodeBytes(t.AggregatePubkey[:48]) + } + } + { // Field #23 'NextSyncCommittee' + t := t.NextSyncCommittee + if t == nil { + t = new(altair.SyncCommittee) + } + { // Field #0 'Pubkeys' + t := t.Pubkeys + vlen := len(t) + if vlen > int(ctx.exprs[3]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[3])), "NextSyncCommittee.Pubkeys") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:48]) + } + if vlen < int(ctx.exprs[3]) { + enc.EncodeZeroPadding((int(ctx.exprs[3]) - vlen) * 48) + } + } + { // Field #1 'AggregatePubkey' + enc.EncodeBytes(t.AggregatePubkey[:48]) + } + } + // Offset #24 'LatestExecutionPayloadHeader' + offset24 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn8(ctx, t.LatestExecutionPayloadHeader)) + } + { // Dynamic Field #7 'HistoricalRoots' + if canSeek { + enc.EncodeOffsetAt(offset7, uint32(enc.GetPosition()-dstlen)) + } + t := t.HistoricalRoots + vlen := len(t) + if vlen > int(ctx.exprs[4]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[4])), "HistoricalRoots") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:32]) + } + } + { // Dynamic Field #9 'ETH1DataVotes' + if canSeek { + enc.EncodeOffsetAt(offset9, uint32(enc.GetPosition()-dstlen)) + } + t := t.ETH1DataVotes + vlen := len(t) + if vlen > int(ctx.exprs[5]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[5])), "ETH1DataVotes") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(phase0.ETH1Data) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "ETH1DataVotes[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #11 'Validators' + if canSeek { + enc.EncodeOffsetAt(offset11, uint32(enc.GetPosition()-dstlen)) + } + t := t.Validators + vlen := len(t) + if vlen > int(ctx.exprs[6]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[6])), "Validators") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(phase0.Validator) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #12 'Balances' + if canSeek { + enc.EncodeOffsetAt(offset12, uint32(enc.GetPosition()-dstlen)) + } + t := t.Balances + vlen := len(t) + if vlen > int(ctx.exprs[6]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[6])), "Balances") + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + } + { // Dynamic Field #15 'PreviousEpochParticipation' + if canSeek { + enc.EncodeOffsetAt(offset15, uint32(enc.GetPosition()-dstlen)) + } + t := t.PreviousEpochParticipation + vlen := len(t) + if vlen > int(ctx.exprs[6]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[6])), "PreviousEpochParticipation") + } + for idx1 := range vlen { + enc.EncodeUint8(byte(t[idx1])) + } + } + { // Dynamic Field #16 'CurrentEpochParticipation' + if canSeek { + enc.EncodeOffsetAt(offset16, uint32(enc.GetPosition()-dstlen)) + } + t := t.CurrentEpochParticipation + vlen := len(t) + if vlen > int(ctx.exprs[6]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[6])), "CurrentEpochParticipation") + } + for idx1 := range vlen { + enc.EncodeUint8(byte(t[idx1])) + } + } + { // Dynamic Field #21 'InactivityScores' + if canSeek { + enc.EncodeOffsetAt(offset21, uint32(enc.GetPosition()-dstlen)) + } + t := t.InactivityScores + vlen := len(t) + if vlen > int(ctx.exprs[6]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[6])), "InactivityScores") + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + } + { // Dynamic Field #24 'LatestExecutionPayloadHeader' + if canSeek { + enc.EncodeOffsetAt(offset24, uint32(enc.GetPosition()-dstlen)) + } + t := t.LatestExecutionPayloadHeader + if t == nil { + t = new(ExecutionPayloadHeader) + } + if viewFn := t.MarshalSSZDynView((*bellatrix.ExecutionPayloadHeader)(nil)); viewFn != nil { + if buf, err := viewFn(ds, enc.GetBuffer()); err != nil { + return err + } else { + enc.SetBuffer(buf) + } + } else { + return sszutils.ErrNotImplemented + } + } + return nil +} + +func (t *BeaconState) marshalSSZEncoderView_BeaconState_2(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + type encoderCtx struct { + ds sszutils.DynamicSpecs + exprs [7]uint64 + sizeFn1 func(ctx *encoderCtx, t []phase0.Root) (size int) + sizeFn2 func(ctx *encoderCtx, t []*phase0.ETH1Data) (size int) + sizeFn3 func(ctx *encoderCtx, t []*phase0.Validator) (size int) + sizeFn4 func(ctx *encoderCtx, t []phase0.Gwei) (size int) + sizeFn5 func(ctx *encoderCtx, t []altair.ParticipationFlags) (size int) + sizeFn6 func(ctx *encoderCtx, t []altair.ParticipationFlags) (size int) + sizeFn7 func(ctx *encoderCtx, t []uint64) (size int) + sizeFn8 func(ctx *encoderCtx, t *ExecutionPayloadHeader) (size int) + sizeFn9 func(ctx *encoderCtx, t []*capella.HistoricalSummary) (size int) + } + ctx := &encoderCtx{ds: ds} + canSeek := enc.Seekable() + ctx.exprs[0], err = sszutils.ResolveSpecValueWithDefault(ds, "SLOTS_PER_HISTORICAL_ROOT", 8192) + if err != nil { + return err + } + ctx.exprs[1], err = sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_HISTORICAL_VECTOR", 65536) + if err != nil { + return err + } + ctx.exprs[2], err = sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_SLASHINGS_VECTOR", 8192) + if err != nil { + return err + } + ctx.exprs[3], err = sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE", 512) + if err != nil { + return err + } + ctx.exprs[4], err = sszutils.ResolveSpecValueWithDefault(ds, "HISTORICAL_ROOTS_LIMIT", 16777216) + if err != nil { + return err + } + ctx.exprs[5], err = sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_ETH1_VOTING_PERIOD*SLOTS_PER_EPOCH", 2048) + if err != nil { + return err + } + ctx.exprs[6], err = sszutils.ResolveSpecValueWithDefault(ds, "VALIDATOR_REGISTRY_LIMIT", 1099511627776) + if err != nil { + return err + } + // size for []phase0.Root + ctx.sizeFn1 = func(ctx *encoderCtx, t []phase0.Root) (size int) { + size += len(t) * 32 + return size + } + // size for []*phase0.ETH1Data + ctx.sizeFn2 = func(ctx *encoderCtx, t []*phase0.ETH1Data) (size int) { + size += len(t) * 72 + return size + } + // size for []*phase0.Validator + ctx.sizeFn3 = func(ctx *encoderCtx, t []*phase0.Validator) (size int) { + size += len(t) * 121 + return size + } + // size for []phase0.Gwei + ctx.sizeFn4 = func(ctx *encoderCtx, t []phase0.Gwei) (size int) { + size += len(t) * 8 + return size + } + // size for []altair.ParticipationFlags + ctx.sizeFn5 = func(ctx *encoderCtx, t []altair.ParticipationFlags) (size int) { + size += len(t) + return size + } + // size for []altair.ParticipationFlags + ctx.sizeFn6 = func(ctx *encoderCtx, t []altair.ParticipationFlags) (size int) { + size += len(t) + return size + } + // size for []uint64 + ctx.sizeFn7 = func(ctx *encoderCtx, t []uint64) (size int) { + size += len(t) * 8 + return size + } + // size for *ExecutionPayloadHeader + ctx.sizeFn8 = func(ctx *encoderCtx, t *ExecutionPayloadHeader) (size int) { + if viewFn := t.SizeSSZDynView((*capella.ExecutionPayloadHeader)(nil)); viewFn != nil { + size += viewFn(ds) + } + return size + } + // size for []*capella.HistoricalSummary + ctx.sizeFn9 = func(ctx *encoderCtx, t []*capella.HistoricalSummary) (size int) { + size += len(t) * 64 + return size + } + size1 := 32 * int(ctx.exprs[0]) + size2 := 32 * int(ctx.exprs[1]) + size3 := 8 * int(ctx.exprs[2]) + size5 := 48 * int(ctx.exprs[3]) + size4 := size5 + 48 // size expression for '*SyncCommittee' + if t == nil { + t = new(BeaconState) + } + dstlen := enc.GetPosition() + dynoff := uint32(size1 + size1 + size2 + size3 + size4 + size4 + 429) + { // Field #0 'GenesisTime' + enc.EncodeUint64(t.GenesisTime) + } + { // Field #1 'GenesisValidatorsRoot' + enc.EncodeBytes(t.GenesisValidatorsRoot[:32]) + } + { // Field #2 'Slot' + enc.EncodeUint64(uint64(t.Slot)) + } + { // Field #3 'Fork' + t := t.Fork + if t == nil { + t = new(phase0.Fork) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "Fork") + } else { + enc.SetBuffer(buf) + } + } + { // Field #4 'LatestBlockHeader' + t := t.LatestBlockHeader + if t == nil { + t = new(phase0.BeaconBlockHeader) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") + } else { + enc.SetBuffer(buf) + } + } + { // Field #5 'BlockRoots' + t := t.BlockRoots + vlen := len(t) + if vlen > int(ctx.exprs[0]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[0])), "BlockRoots") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:32]) + } + if vlen < int(ctx.exprs[0]) { + enc.EncodeZeroPadding((int(ctx.exprs[0]) - vlen) * 32) + } + } + { // Field #6 'StateRoots' + t := t.StateRoots + vlen := len(t) + if vlen > int(ctx.exprs[0]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[0])), "StateRoots") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:32]) + } + if vlen < int(ctx.exprs[0]) { + enc.EncodeZeroPadding((int(ctx.exprs[0]) - vlen) * 32) + } + } + // Offset #7 'HistoricalRoots' + offset7 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn1(ctx, t.HistoricalRoots)) + } + { // Field #8 'ETH1Data' + t := t.ETH1Data + if t == nil { + t = new(phase0.ETH1Data) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "ETH1Data") + } else { + enc.SetBuffer(buf) + } + } + // Offset #9 'ETH1DataVotes' + offset9 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn2(ctx, t.ETH1DataVotes)) + } + { // Field #10 'ETH1DepositIndex' + enc.EncodeUint64(t.ETH1DepositIndex) + } + // Offset #11 'Validators' + offset11 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn3(ctx, t.Validators)) + } + // Offset #12 'Balances' + offset12 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn4(ctx, t.Balances)) + } + { // Field #13 'RANDAOMixes' + t := t.RANDAOMixes + vlen := len(t) + if vlen > int(ctx.exprs[1]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[1])), "RANDAOMixes") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:32]) + } + if vlen < int(ctx.exprs[1]) { + enc.EncodeZeroPadding((int(ctx.exprs[1]) - vlen) * 32) + } + } + { // Field #14 'Slashings' + t := t.Slashings + vlen := len(t) + if vlen > int(ctx.exprs[2]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[2])), "Slashings") + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + if vlen < int(ctx.exprs[2]) { + enc.EncodeZeroPadding((int(ctx.exprs[2]) - vlen) * 8) + } + } + // Offset #15 'PreviousEpochParticipation' + offset15 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn5(ctx, t.PreviousEpochParticipation)) + } + // Offset #16 'CurrentEpochParticipation' + offset16 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn6(ctx, t.CurrentEpochParticipation)) + } + { // Field #17 'JustificationBits' + vlen := len(t.JustificationBits) + if vlen > 1 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 1), "JustificationBits") + } + enc.EncodeBytes(t.JustificationBits[:vlen]) + if vlen < 1 { + enc.EncodeZeroPadding((1 - vlen) * 1) + } + } + { // Field #18 'PreviousJustifiedCheckpoint' + t := t.PreviousJustifiedCheckpoint + if t == nil { + t = new(phase0.Checkpoint) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } else { + enc.SetBuffer(buf) + } + } + { // Field #19 'CurrentJustifiedCheckpoint' + t := t.CurrentJustifiedCheckpoint + if t == nil { + t = new(phase0.Checkpoint) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } else { + enc.SetBuffer(buf) + } + } + { // Field #20 'FinalizedCheckpoint' + t := t.FinalizedCheckpoint + if t == nil { + t = new(phase0.Checkpoint) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") + } else { + enc.SetBuffer(buf) + } + } + // Offset #21 'InactivityScores' + offset21 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn7(ctx, t.InactivityScores)) + } + { // Field #22 'CurrentSyncCommittee' + t := t.CurrentSyncCommittee + if t == nil { + t = new(altair.SyncCommittee) + } + { // Field #0 'Pubkeys' + t := t.Pubkeys + vlen := len(t) + if vlen > int(ctx.exprs[3]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[3])), "CurrentSyncCommittee.Pubkeys") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:48]) + } + if vlen < int(ctx.exprs[3]) { + enc.EncodeZeroPadding((int(ctx.exprs[3]) - vlen) * 48) + } + } + { // Field #1 'AggregatePubkey' + enc.EncodeBytes(t.AggregatePubkey[:48]) + } + } + { // Field #23 'NextSyncCommittee' + t := t.NextSyncCommittee + if t == nil { + t = new(altair.SyncCommittee) + } + { // Field #0 'Pubkeys' + t := t.Pubkeys + vlen := len(t) + if vlen > int(ctx.exprs[3]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[3])), "NextSyncCommittee.Pubkeys") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:48]) + } + if vlen < int(ctx.exprs[3]) { + enc.EncodeZeroPadding((int(ctx.exprs[3]) - vlen) * 48) + } + } + { // Field #1 'AggregatePubkey' + enc.EncodeBytes(t.AggregatePubkey[:48]) + } + } + // Offset #24 'LatestExecutionPayloadHeader' + offset24 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn8(ctx, t.LatestExecutionPayloadHeader)) + } + { // Field #25 'NextWithdrawalIndex' + enc.EncodeUint64(uint64(t.NextWithdrawalIndex)) + } + { // Field #26 'NextWithdrawalValidatorIndex' + enc.EncodeUint64(uint64(t.NextWithdrawalValidatorIndex)) + } + // Offset #27 'HistoricalSummaries' + offset27 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn9(ctx, t.HistoricalSummaries)) + } + { // Dynamic Field #7 'HistoricalRoots' + if canSeek { + enc.EncodeOffsetAt(offset7, uint32(enc.GetPosition()-dstlen)) + } + t := t.HistoricalRoots + vlen := len(t) + if vlen > int(ctx.exprs[4]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[4])), "HistoricalRoots") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:32]) + } + } + { // Dynamic Field #9 'ETH1DataVotes' + if canSeek { + enc.EncodeOffsetAt(offset9, uint32(enc.GetPosition()-dstlen)) + } + t := t.ETH1DataVotes + vlen := len(t) + if vlen > int(ctx.exprs[5]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[5])), "ETH1DataVotes") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(phase0.ETH1Data) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "ETH1DataVotes[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #11 'Validators' + if canSeek { + enc.EncodeOffsetAt(offset11, uint32(enc.GetPosition()-dstlen)) + } + t := t.Validators + vlen := len(t) + if vlen > int(ctx.exprs[6]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[6])), "Validators") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(phase0.Validator) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #12 'Balances' + if canSeek { + enc.EncodeOffsetAt(offset12, uint32(enc.GetPosition()-dstlen)) + } + t := t.Balances + vlen := len(t) + if vlen > int(ctx.exprs[6]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[6])), "Balances") + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + } + { // Dynamic Field #15 'PreviousEpochParticipation' + if canSeek { + enc.EncodeOffsetAt(offset15, uint32(enc.GetPosition()-dstlen)) + } + t := t.PreviousEpochParticipation + vlen := len(t) + if vlen > int(ctx.exprs[6]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[6])), "PreviousEpochParticipation") + } + for idx1 := range vlen { + enc.EncodeUint8(byte(t[idx1])) + } + } + { // Dynamic Field #16 'CurrentEpochParticipation' + if canSeek { + enc.EncodeOffsetAt(offset16, uint32(enc.GetPosition()-dstlen)) + } + t := t.CurrentEpochParticipation + vlen := len(t) + if vlen > int(ctx.exprs[6]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[6])), "CurrentEpochParticipation") + } + for idx1 := range vlen { + enc.EncodeUint8(byte(t[idx1])) + } + } + { // Dynamic Field #21 'InactivityScores' + if canSeek { + enc.EncodeOffsetAt(offset21, uint32(enc.GetPosition()-dstlen)) + } + t := t.InactivityScores + vlen := len(t) + if vlen > int(ctx.exprs[6]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[6])), "InactivityScores") + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + } + { // Dynamic Field #24 'LatestExecutionPayloadHeader' + if canSeek { + enc.EncodeOffsetAt(offset24, uint32(enc.GetPosition()-dstlen)) + } + t := t.LatestExecutionPayloadHeader + if t == nil { + t = new(ExecutionPayloadHeader) + } + if viewFn := t.MarshalSSZDynView((*capella.ExecutionPayloadHeader)(nil)); viewFn != nil { + if buf, err := viewFn(ds, enc.GetBuffer()); err != nil { + return err + } else { + enc.SetBuffer(buf) + } + } else { + return sszutils.ErrNotImplemented + } + } + { // Dynamic Field #27 'HistoricalSummaries' + if canSeek { + enc.EncodeOffsetAt(offset27, uint32(enc.GetPosition()-dstlen)) + } + t := t.HistoricalSummaries + vlen := len(t) + if vlen > int(ctx.exprs[4]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[4])), "HistoricalSummaries") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(capella.HistoricalSummary) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "HistoricalSummaries[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + return nil +} + +func (t *BeaconState) marshalSSZEncoderView_BeaconState_3(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + type encoderCtx struct { + ds sszutils.DynamicSpecs + exprs [7]uint64 + sizeFn1 func(ctx *encoderCtx, t []phase0.Root) (size int) + sizeFn2 func(ctx *encoderCtx, t []*phase0.ETH1Data) (size int) + sizeFn3 func(ctx *encoderCtx, t []*phase0.Validator) (size int) + sizeFn4 func(ctx *encoderCtx, t []phase0.Gwei) (size int) + sizeFn5 func(ctx *encoderCtx, t []altair.ParticipationFlags) (size int) + sizeFn6 func(ctx *encoderCtx, t []altair.ParticipationFlags) (size int) + sizeFn7 func(ctx *encoderCtx, t []uint64) (size int) + sizeFn8 func(ctx *encoderCtx, t *ExecutionPayloadHeader) (size int) + sizeFn9 func(ctx *encoderCtx, t []*capella.HistoricalSummary) (size int) + } + ctx := &encoderCtx{ds: ds} + canSeek := enc.Seekable() + ctx.exprs[0], err = sszutils.ResolveSpecValueWithDefault(ds, "SLOTS_PER_HISTORICAL_ROOT", 8192) + if err != nil { + return err + } + ctx.exprs[1], err = sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_HISTORICAL_VECTOR", 65536) + if err != nil { + return err + } + ctx.exprs[2], err = sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_SLASHINGS_VECTOR", 8192) + if err != nil { + return err + } + ctx.exprs[3], err = sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE", 512) + if err != nil { + return err + } + ctx.exprs[4], err = sszutils.ResolveSpecValueWithDefault(ds, "HISTORICAL_ROOTS_LIMIT", 16777216) + if err != nil { + return err + } + ctx.exprs[5], err = sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_ETH1_VOTING_PERIOD*SLOTS_PER_EPOCH", 2048) + if err != nil { + return err + } + ctx.exprs[6], err = sszutils.ResolveSpecValueWithDefault(ds, "VALIDATOR_REGISTRY_LIMIT", 1099511627776) + if err != nil { + return err + } + // size for []phase0.Root + ctx.sizeFn1 = func(ctx *encoderCtx, t []phase0.Root) (size int) { + size += len(t) * 32 + return size + } + // size for []*phase0.ETH1Data + ctx.sizeFn2 = func(ctx *encoderCtx, t []*phase0.ETH1Data) (size int) { + size += len(t) * 72 + return size + } + // size for []*phase0.Validator + ctx.sizeFn3 = func(ctx *encoderCtx, t []*phase0.Validator) (size int) { + size += len(t) * 121 + return size + } + // size for []phase0.Gwei + ctx.sizeFn4 = func(ctx *encoderCtx, t []phase0.Gwei) (size int) { + size += len(t) * 8 + return size + } + // size for []altair.ParticipationFlags + ctx.sizeFn5 = func(ctx *encoderCtx, t []altair.ParticipationFlags) (size int) { + size += len(t) + return size + } + // size for []altair.ParticipationFlags + ctx.sizeFn6 = func(ctx *encoderCtx, t []altair.ParticipationFlags) (size int) { + size += len(t) + return size + } + // size for []uint64 + ctx.sizeFn7 = func(ctx *encoderCtx, t []uint64) (size int) { + size += len(t) * 8 + return size + } + // size for *ExecutionPayloadHeader + ctx.sizeFn8 = func(ctx *encoderCtx, t *ExecutionPayloadHeader) (size int) { + if viewFn := t.SizeSSZDynView((*deneb.ExecutionPayloadHeader)(nil)); viewFn != nil { + size += viewFn(ds) + } + return size + } + // size for []*capella.HistoricalSummary + ctx.sizeFn9 = func(ctx *encoderCtx, t []*capella.HistoricalSummary) (size int) { + size += len(t) * 64 + return size + } + size1 := 32 * int(ctx.exprs[0]) + size2 := 32 * int(ctx.exprs[1]) + size3 := 8 * int(ctx.exprs[2]) + size5 := 48 * int(ctx.exprs[3]) + size4 := size5 + 48 // size expression for '*SyncCommittee' + if t == nil { + t = new(BeaconState) + } + dstlen := enc.GetPosition() + dynoff := uint32(size1 + size1 + size2 + size3 + size4 + size4 + 429) + { // Field #0 'GenesisTime' + enc.EncodeUint64(t.GenesisTime) + } + { // Field #1 'GenesisValidatorsRoot' + enc.EncodeBytes(t.GenesisValidatorsRoot[:32]) + } + { // Field #2 'Slot' + enc.EncodeUint64(uint64(t.Slot)) + } + { // Field #3 'Fork' + t := t.Fork + if t == nil { + t = new(phase0.Fork) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "Fork") + } else { + enc.SetBuffer(buf) + } + } + { // Field #4 'LatestBlockHeader' + t := t.LatestBlockHeader + if t == nil { + t = new(phase0.BeaconBlockHeader) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") + } else { + enc.SetBuffer(buf) + } + } + { // Field #5 'BlockRoots' + t := t.BlockRoots + vlen := len(t) + if vlen > int(ctx.exprs[0]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[0])), "BlockRoots") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:32]) + } + if vlen < int(ctx.exprs[0]) { + enc.EncodeZeroPadding((int(ctx.exprs[0]) - vlen) * 32) + } + } + { // Field #6 'StateRoots' + t := t.StateRoots + vlen := len(t) + if vlen > int(ctx.exprs[0]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[0])), "StateRoots") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:32]) + } + if vlen < int(ctx.exprs[0]) { + enc.EncodeZeroPadding((int(ctx.exprs[0]) - vlen) * 32) + } + } + // Offset #7 'HistoricalRoots' + offset7 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn1(ctx, t.HistoricalRoots)) + } + { // Field #8 'ETH1Data' + t := t.ETH1Data + if t == nil { + t = new(phase0.ETH1Data) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "ETH1Data") + } else { + enc.SetBuffer(buf) + } + } + // Offset #9 'ETH1DataVotes' + offset9 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn2(ctx, t.ETH1DataVotes)) + } + { // Field #10 'ETH1DepositIndex' + enc.EncodeUint64(t.ETH1DepositIndex) + } + // Offset #11 'Validators' + offset11 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn3(ctx, t.Validators)) + } + // Offset #12 'Balances' + offset12 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn4(ctx, t.Balances)) + } + { // Field #13 'RANDAOMixes' + t := t.RANDAOMixes + vlen := len(t) + if vlen > int(ctx.exprs[1]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[1])), "RANDAOMixes") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:32]) + } + if vlen < int(ctx.exprs[1]) { + enc.EncodeZeroPadding((int(ctx.exprs[1]) - vlen) * 32) + } + } + { // Field #14 'Slashings' + t := t.Slashings + vlen := len(t) + if vlen > int(ctx.exprs[2]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[2])), "Slashings") + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + if vlen < int(ctx.exprs[2]) { + enc.EncodeZeroPadding((int(ctx.exprs[2]) - vlen) * 8) + } + } + // Offset #15 'PreviousEpochParticipation' + offset15 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn5(ctx, t.PreviousEpochParticipation)) + } + // Offset #16 'CurrentEpochParticipation' + offset16 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn6(ctx, t.CurrentEpochParticipation)) + } + { // Field #17 'JustificationBits' + vlen := len(t.JustificationBits) + if vlen > 1 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 1), "JustificationBits") + } + enc.EncodeBytes(t.JustificationBits[:vlen]) + if vlen < 1 { + enc.EncodeZeroPadding((1 - vlen) * 1) + } + } + { // Field #18 'PreviousJustifiedCheckpoint' + t := t.PreviousJustifiedCheckpoint + if t == nil { + t = new(phase0.Checkpoint) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } else { + enc.SetBuffer(buf) + } + } + { // Field #19 'CurrentJustifiedCheckpoint' + t := t.CurrentJustifiedCheckpoint + if t == nil { + t = new(phase0.Checkpoint) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } else { + enc.SetBuffer(buf) + } + } + { // Field #20 'FinalizedCheckpoint' + t := t.FinalizedCheckpoint + if t == nil { + t = new(phase0.Checkpoint) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") + } else { + enc.SetBuffer(buf) + } + } + // Offset #21 'InactivityScores' + offset21 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn7(ctx, t.InactivityScores)) + } + { // Field #22 'CurrentSyncCommittee' + t := t.CurrentSyncCommittee + if t == nil { + t = new(altair.SyncCommittee) + } + { // Field #0 'Pubkeys' + t := t.Pubkeys + vlen := len(t) + if vlen > int(ctx.exprs[3]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[3])), "CurrentSyncCommittee.Pubkeys") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:48]) + } + if vlen < int(ctx.exprs[3]) { + enc.EncodeZeroPadding((int(ctx.exprs[3]) - vlen) * 48) + } + } + { // Field #1 'AggregatePubkey' + enc.EncodeBytes(t.AggregatePubkey[:48]) + } + } + { // Field #23 'NextSyncCommittee' + t := t.NextSyncCommittee + if t == nil { + t = new(altair.SyncCommittee) + } + { // Field #0 'Pubkeys' + t := t.Pubkeys + vlen := len(t) + if vlen > int(ctx.exprs[3]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[3])), "NextSyncCommittee.Pubkeys") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:48]) + } + if vlen < int(ctx.exprs[3]) { + enc.EncodeZeroPadding((int(ctx.exprs[3]) - vlen) * 48) + } + } + { // Field #1 'AggregatePubkey' + enc.EncodeBytes(t.AggregatePubkey[:48]) + } + } + // Offset #24 'LatestExecutionPayloadHeader' + offset24 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn8(ctx, t.LatestExecutionPayloadHeader)) + } + { // Field #25 'NextWithdrawalIndex' + enc.EncodeUint64(uint64(t.NextWithdrawalIndex)) + } + { // Field #26 'NextWithdrawalValidatorIndex' + enc.EncodeUint64(uint64(t.NextWithdrawalValidatorIndex)) + } + // Offset #27 'HistoricalSummaries' + offset27 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn9(ctx, t.HistoricalSummaries)) + } + { // Dynamic Field #7 'HistoricalRoots' + if canSeek { + enc.EncodeOffsetAt(offset7, uint32(enc.GetPosition()-dstlen)) + } + t := t.HistoricalRoots + vlen := len(t) + if vlen > int(ctx.exprs[4]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[4])), "HistoricalRoots") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:32]) + } + } + { // Dynamic Field #9 'ETH1DataVotes' + if canSeek { + enc.EncodeOffsetAt(offset9, uint32(enc.GetPosition()-dstlen)) + } + t := t.ETH1DataVotes + vlen := len(t) + if vlen > int(ctx.exprs[5]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[5])), "ETH1DataVotes") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(phase0.ETH1Data) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "ETH1DataVotes[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #11 'Validators' + if canSeek { + enc.EncodeOffsetAt(offset11, uint32(enc.GetPosition()-dstlen)) + } + t := t.Validators + vlen := len(t) + if vlen > int(ctx.exprs[6]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[6])), "Validators") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(phase0.Validator) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #12 'Balances' + if canSeek { + enc.EncodeOffsetAt(offset12, uint32(enc.GetPosition()-dstlen)) + } + t := t.Balances + vlen := len(t) + if vlen > int(ctx.exprs[6]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[6])), "Balances") + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + } + { // Dynamic Field #15 'PreviousEpochParticipation' + if canSeek { + enc.EncodeOffsetAt(offset15, uint32(enc.GetPosition()-dstlen)) + } + t := t.PreviousEpochParticipation + vlen := len(t) + if vlen > int(ctx.exprs[6]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[6])), "PreviousEpochParticipation") + } + for idx1 := range vlen { + enc.EncodeUint8(byte(t[idx1])) + } + } + { // Dynamic Field #16 'CurrentEpochParticipation' + if canSeek { + enc.EncodeOffsetAt(offset16, uint32(enc.GetPosition()-dstlen)) + } + t := t.CurrentEpochParticipation + vlen := len(t) + if vlen > int(ctx.exprs[6]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[6])), "CurrentEpochParticipation") + } + for idx1 := range vlen { + enc.EncodeUint8(byte(t[idx1])) + } + } + { // Dynamic Field #21 'InactivityScores' + if canSeek { + enc.EncodeOffsetAt(offset21, uint32(enc.GetPosition()-dstlen)) + } + t := t.InactivityScores + vlen := len(t) + if vlen > int(ctx.exprs[6]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[6])), "InactivityScores") + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + } + { // Dynamic Field #24 'LatestExecutionPayloadHeader' + if canSeek { + enc.EncodeOffsetAt(offset24, uint32(enc.GetPosition()-dstlen)) + } + t := t.LatestExecutionPayloadHeader + if t == nil { + t = new(ExecutionPayloadHeader) + } + if viewFn := t.MarshalSSZDynView((*deneb.ExecutionPayloadHeader)(nil)); viewFn != nil { + if buf, err := viewFn(ds, enc.GetBuffer()); err != nil { + return err + } else { + enc.SetBuffer(buf) + } + } else { + return sszutils.ErrNotImplemented + } + } + { // Dynamic Field #27 'HistoricalSummaries' + if canSeek { + enc.EncodeOffsetAt(offset27, uint32(enc.GetPosition()-dstlen)) + } + t := t.HistoricalSummaries + vlen := len(t) + if vlen > int(ctx.exprs[4]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[4])), "HistoricalSummaries") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(capella.HistoricalSummary) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "HistoricalSummaries[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + return nil +} + +func (t *BeaconState) marshalSSZEncoderView_BeaconState_4(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + type encoderCtx struct { + ds sszutils.DynamicSpecs + exprs [10]uint64 + sizeFn1 func(ctx *encoderCtx, t []phase0.Root) (size int) + sizeFn10 func(ctx *encoderCtx, t []*electra.PendingDeposit) (size int) + sizeFn11 func(ctx *encoderCtx, t []*electra.PendingPartialWithdrawal) (size int) + sizeFn12 func(ctx *encoderCtx, t []*electra.PendingConsolidation) (size int) + sizeFn2 func(ctx *encoderCtx, t []*phase0.ETH1Data) (size int) + sizeFn3 func(ctx *encoderCtx, t []*phase0.Validator) (size int) + sizeFn4 func(ctx *encoderCtx, t []phase0.Gwei) (size int) + sizeFn5 func(ctx *encoderCtx, t []altair.ParticipationFlags) (size int) + sizeFn6 func(ctx *encoderCtx, t []altair.ParticipationFlags) (size int) + sizeFn7 func(ctx *encoderCtx, t []uint64) (size int) + sizeFn8 func(ctx *encoderCtx, t *ExecutionPayloadHeader) (size int) + sizeFn9 func(ctx *encoderCtx, t []*capella.HistoricalSummary) (size int) + } + ctx := &encoderCtx{ds: ds} + canSeek := enc.Seekable() + ctx.exprs[0], err = sszutils.ResolveSpecValueWithDefault(ds, "SLOTS_PER_HISTORICAL_ROOT", 8192) + if err != nil { + return err + } + ctx.exprs[1], err = sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_HISTORICAL_VECTOR", 65536) + if err != nil { + return err + } + ctx.exprs[2], err = sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_SLASHINGS_VECTOR", 8192) + if err != nil { + return err + } + ctx.exprs[3], err = sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE", 512) + if err != nil { + return err + } + ctx.exprs[4], err = sszutils.ResolveSpecValueWithDefault(ds, "HISTORICAL_ROOTS_LIMIT", 16777216) + if err != nil { + return err + } + ctx.exprs[5], err = sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_ETH1_VOTING_PERIOD*SLOTS_PER_EPOCH", 2048) + if err != nil { + return err + } + ctx.exprs[6], err = sszutils.ResolveSpecValueWithDefault(ds, "VALIDATOR_REGISTRY_LIMIT", 1099511627776) + if err != nil { + return err + } + ctx.exprs[7], err = sszutils.ResolveSpecValueWithDefault(ds, "PENDING_DEPOSITS_LIMIT", 134217728) + if err != nil { + return err + } + ctx.exprs[8], err = sszutils.ResolveSpecValueWithDefault(ds, "PENDING_PARTIAL_WITHDRAWALS_LIMIT", 134217728) + if err != nil { + return err + } + ctx.exprs[9], err = sszutils.ResolveSpecValueWithDefault(ds, "PENDING_CONSOLIDATIONS_LIMIT", 262144) + if err != nil { + return err + } + // size for []phase0.Root + ctx.sizeFn1 = func(ctx *encoderCtx, t []phase0.Root) (size int) { + size += len(t) * 32 + return size + } + // size for []*phase0.ETH1Data + ctx.sizeFn2 = func(ctx *encoderCtx, t []*phase0.ETH1Data) (size int) { + size += len(t) * 72 + return size + } + // size for []*phase0.Validator + ctx.sizeFn3 = func(ctx *encoderCtx, t []*phase0.Validator) (size int) { + size += len(t) * 121 + return size + } + // size for []phase0.Gwei + ctx.sizeFn4 = func(ctx *encoderCtx, t []phase0.Gwei) (size int) { + size += len(t) * 8 + return size + } + // size for []altair.ParticipationFlags + ctx.sizeFn5 = func(ctx *encoderCtx, t []altair.ParticipationFlags) (size int) { + size += len(t) + return size + } + // size for []altair.ParticipationFlags + ctx.sizeFn6 = func(ctx *encoderCtx, t []altair.ParticipationFlags) (size int) { + size += len(t) + return size + } + // size for []uint64 + ctx.sizeFn7 = func(ctx *encoderCtx, t []uint64) (size int) { + size += len(t) * 8 + return size + } + // size for *ExecutionPayloadHeader + ctx.sizeFn8 = func(ctx *encoderCtx, t *ExecutionPayloadHeader) (size int) { + if viewFn := t.SizeSSZDynView((*deneb.ExecutionPayloadHeader)(nil)); viewFn != nil { + size += viewFn(ds) + } + return size + } + // size for []*capella.HistoricalSummary + ctx.sizeFn9 = func(ctx *encoderCtx, t []*capella.HistoricalSummary) (size int) { + size += len(t) * 64 + return size + } + // size for []*electra.PendingDeposit + ctx.sizeFn10 = func(ctx *encoderCtx, t []*electra.PendingDeposit) (size int) { + size += len(t) * 192 + return size + } + // size for []*electra.PendingPartialWithdrawal + ctx.sizeFn11 = func(ctx *encoderCtx, t []*electra.PendingPartialWithdrawal) (size int) { + size += len(t) * 24 + return size + } + // size for []*electra.PendingConsolidation + ctx.sizeFn12 = func(ctx *encoderCtx, t []*electra.PendingConsolidation) (size int) { + size += len(t) * 16 + return size + } + size1 := 32 * int(ctx.exprs[0]) + size2 := 32 * int(ctx.exprs[1]) + size3 := 8 * int(ctx.exprs[2]) + size5 := 48 * int(ctx.exprs[3]) + size4 := size5 + 48 // size expression for '*SyncCommittee' + if t == nil { + t = new(BeaconState) + } + dstlen := enc.GetPosition() + dynoff := uint32(size1 + size1 + size2 + size3 + size4 + size4 + 489) + { // Field #0 'GenesisTime' + enc.EncodeUint64(t.GenesisTime) + } + { // Field #1 'GenesisValidatorsRoot' + enc.EncodeBytes(t.GenesisValidatorsRoot[:32]) + } + { // Field #2 'Slot' + enc.EncodeUint64(uint64(t.Slot)) + } + { // Field #3 'Fork' + t := t.Fork + if t == nil { + t = new(phase0.Fork) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "Fork") + } else { + enc.SetBuffer(buf) + } + } + { // Field #4 'LatestBlockHeader' + t := t.LatestBlockHeader + if t == nil { + t = new(phase0.BeaconBlockHeader) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") + } else { + enc.SetBuffer(buf) + } + } + { // Field #5 'BlockRoots' + t := t.BlockRoots + vlen := len(t) + if vlen > int(ctx.exprs[0]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[0])), "BlockRoots") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:32]) + } + if vlen < int(ctx.exprs[0]) { + enc.EncodeZeroPadding((int(ctx.exprs[0]) - vlen) * 32) + } + } + { // Field #6 'StateRoots' + t := t.StateRoots + vlen := len(t) + if vlen > int(ctx.exprs[0]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[0])), "StateRoots") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:32]) + } + if vlen < int(ctx.exprs[0]) { + enc.EncodeZeroPadding((int(ctx.exprs[0]) - vlen) * 32) + } + } + // Offset #7 'HistoricalRoots' + offset7 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn1(ctx, t.HistoricalRoots)) + } + { // Field #8 'ETH1Data' + t := t.ETH1Data + if t == nil { + t = new(phase0.ETH1Data) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "ETH1Data") + } else { + enc.SetBuffer(buf) + } + } + // Offset #9 'ETH1DataVotes' + offset9 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn2(ctx, t.ETH1DataVotes)) + } + { // Field #10 'ETH1DepositIndex' + enc.EncodeUint64(t.ETH1DepositIndex) + } + // Offset #11 'Validators' + offset11 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn3(ctx, t.Validators)) + } + // Offset #12 'Balances' + offset12 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn4(ctx, t.Balances)) + } + { // Field #13 'RANDAOMixes' + t := t.RANDAOMixes + vlen := len(t) + if vlen > int(ctx.exprs[1]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[1])), "RANDAOMixes") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:32]) + } + if vlen < int(ctx.exprs[1]) { + enc.EncodeZeroPadding((int(ctx.exprs[1]) - vlen) * 32) + } + } + { // Field #14 'Slashings' + t := t.Slashings + vlen := len(t) + if vlen > int(ctx.exprs[2]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[2])), "Slashings") + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + if vlen < int(ctx.exprs[2]) { + enc.EncodeZeroPadding((int(ctx.exprs[2]) - vlen) * 8) + } + } + // Offset #15 'PreviousEpochParticipation' + offset15 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn5(ctx, t.PreviousEpochParticipation)) + } + // Offset #16 'CurrentEpochParticipation' + offset16 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn6(ctx, t.CurrentEpochParticipation)) + } + { // Field #17 'JustificationBits' + vlen := len(t.JustificationBits) + if vlen > 1 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 1), "JustificationBits") + } + enc.EncodeBytes(t.JustificationBits[:vlen]) + if vlen < 1 { + enc.EncodeZeroPadding((1 - vlen) * 1) + } + } + { // Field #18 'PreviousJustifiedCheckpoint' + t := t.PreviousJustifiedCheckpoint + if t == nil { + t = new(phase0.Checkpoint) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } else { + enc.SetBuffer(buf) + } + } + { // Field #19 'CurrentJustifiedCheckpoint' + t := t.CurrentJustifiedCheckpoint + if t == nil { + t = new(phase0.Checkpoint) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } else { + enc.SetBuffer(buf) + } + } + { // Field #20 'FinalizedCheckpoint' + t := t.FinalizedCheckpoint + if t == nil { + t = new(phase0.Checkpoint) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") + } else { + enc.SetBuffer(buf) + } + } + // Offset #21 'InactivityScores' + offset21 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn7(ctx, t.InactivityScores)) + } + { // Field #22 'CurrentSyncCommittee' + t := t.CurrentSyncCommittee + if t == nil { + t = new(altair.SyncCommittee) + } + { // Field #0 'Pubkeys' + t := t.Pubkeys + vlen := len(t) + if vlen > int(ctx.exprs[3]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[3])), "CurrentSyncCommittee.Pubkeys") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:48]) + } + if vlen < int(ctx.exprs[3]) { + enc.EncodeZeroPadding((int(ctx.exprs[3]) - vlen) * 48) + } + } + { // Field #1 'AggregatePubkey' + enc.EncodeBytes(t.AggregatePubkey[:48]) + } + } + { // Field #23 'NextSyncCommittee' + t := t.NextSyncCommittee + if t == nil { + t = new(altair.SyncCommittee) + } + { // Field #0 'Pubkeys' + t := t.Pubkeys + vlen := len(t) + if vlen > int(ctx.exprs[3]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[3])), "NextSyncCommittee.Pubkeys") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:48]) + } + if vlen < int(ctx.exprs[3]) { + enc.EncodeZeroPadding((int(ctx.exprs[3]) - vlen) * 48) + } + } + { // Field #1 'AggregatePubkey' + enc.EncodeBytes(t.AggregatePubkey[:48]) + } + } + // Offset #24 'LatestExecutionPayloadHeader' + offset24 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn8(ctx, t.LatestExecutionPayloadHeader)) + } + { // Field #25 'NextWithdrawalIndex' + enc.EncodeUint64(uint64(t.NextWithdrawalIndex)) + } + { // Field #26 'NextWithdrawalValidatorIndex' + enc.EncodeUint64(uint64(t.NextWithdrawalValidatorIndex)) + } + // Offset #27 'HistoricalSummaries' + offset27 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn9(ctx, t.HistoricalSummaries)) + } + { // Field #28 'DepositRequestsStartIndex' + enc.EncodeUint64(t.DepositRequestsStartIndex) + } + { // Field #29 'DepositBalanceToConsume' + enc.EncodeUint64(uint64(t.DepositBalanceToConsume)) + } + { // Field #30 'ExitBalanceToConsume' + enc.EncodeUint64(uint64(t.ExitBalanceToConsume)) + } + { // Field #31 'EarliestExitEpoch' + enc.EncodeUint64(uint64(t.EarliestExitEpoch)) + } + { // Field #32 'ConsolidationBalanceToConsume' + enc.EncodeUint64(uint64(t.ConsolidationBalanceToConsume)) + } + { // Field #33 'EarliestConsolidationEpoch' + enc.EncodeUint64(uint64(t.EarliestConsolidationEpoch)) + } + // Offset #34 'PendingDeposits' + offset34 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn10(ctx, t.PendingDeposits)) + } + // Offset #35 'PendingPartialWithdrawals' + offset35 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn11(ctx, t.PendingPartialWithdrawals)) + } + // Offset #36 'PendingConsolidations' + offset36 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn12(ctx, t.PendingConsolidations)) + } + { // Dynamic Field #7 'HistoricalRoots' + if canSeek { + enc.EncodeOffsetAt(offset7, uint32(enc.GetPosition()-dstlen)) + } + t := t.HistoricalRoots + vlen := len(t) + if vlen > int(ctx.exprs[4]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[4])), "HistoricalRoots") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:32]) + } + } + { // Dynamic Field #9 'ETH1DataVotes' + if canSeek { + enc.EncodeOffsetAt(offset9, uint32(enc.GetPosition()-dstlen)) + } + t := t.ETH1DataVotes + vlen := len(t) + if vlen > int(ctx.exprs[5]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[5])), "ETH1DataVotes") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(phase0.ETH1Data) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "ETH1DataVotes[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #11 'Validators' + if canSeek { + enc.EncodeOffsetAt(offset11, uint32(enc.GetPosition()-dstlen)) + } + t := t.Validators + vlen := len(t) + if vlen > int(ctx.exprs[6]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[6])), "Validators") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(phase0.Validator) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #12 'Balances' + if canSeek { + enc.EncodeOffsetAt(offset12, uint32(enc.GetPosition()-dstlen)) + } + t := t.Balances + vlen := len(t) + if vlen > int(ctx.exprs[6]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[6])), "Balances") + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + } + { // Dynamic Field #15 'PreviousEpochParticipation' + if canSeek { + enc.EncodeOffsetAt(offset15, uint32(enc.GetPosition()-dstlen)) + } + t := t.PreviousEpochParticipation + vlen := len(t) + if vlen > int(ctx.exprs[6]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[6])), "PreviousEpochParticipation") + } + for idx1 := range vlen { + enc.EncodeUint8(byte(t[idx1])) + } + } + { // Dynamic Field #16 'CurrentEpochParticipation' + if canSeek { + enc.EncodeOffsetAt(offset16, uint32(enc.GetPosition()-dstlen)) + } + t := t.CurrentEpochParticipation + vlen := len(t) + if vlen > int(ctx.exprs[6]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[6])), "CurrentEpochParticipation") + } + for idx1 := range vlen { + enc.EncodeUint8(byte(t[idx1])) + } + } + { // Dynamic Field #21 'InactivityScores' + if canSeek { + enc.EncodeOffsetAt(offset21, uint32(enc.GetPosition()-dstlen)) + } + t := t.InactivityScores + vlen := len(t) + if vlen > int(ctx.exprs[6]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[6])), "InactivityScores") + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + } + { // Dynamic Field #24 'LatestExecutionPayloadHeader' + if canSeek { + enc.EncodeOffsetAt(offset24, uint32(enc.GetPosition()-dstlen)) + } + t := t.LatestExecutionPayloadHeader + if t == nil { + t = new(ExecutionPayloadHeader) + } + if viewFn := t.MarshalSSZDynView((*deneb.ExecutionPayloadHeader)(nil)); viewFn != nil { + if buf, err := viewFn(ds, enc.GetBuffer()); err != nil { + return err + } else { + enc.SetBuffer(buf) + } + } else { + return sszutils.ErrNotImplemented + } + } + { // Dynamic Field #27 'HistoricalSummaries' + if canSeek { + enc.EncodeOffsetAt(offset27, uint32(enc.GetPosition()-dstlen)) + } + t := t.HistoricalSummaries + vlen := len(t) + if vlen > int(ctx.exprs[4]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[4])), "HistoricalSummaries") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(capella.HistoricalSummary) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "HistoricalSummaries[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #34 'PendingDeposits' + if canSeek { + enc.EncodeOffsetAt(offset34, uint32(enc.GetPosition()-dstlen)) + } + t := t.PendingDeposits + vlen := len(t) + if vlen > int(ctx.exprs[7]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[7])), "PendingDeposits") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(electra.PendingDeposit) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "PendingDeposits[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #35 'PendingPartialWithdrawals' + if canSeek { + enc.EncodeOffsetAt(offset35, uint32(enc.GetPosition()-dstlen)) + } + t := t.PendingPartialWithdrawals + vlen := len(t) + if vlen > int(ctx.exprs[8]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[8])), "PendingPartialWithdrawals") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(electra.PendingPartialWithdrawal) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "PendingPartialWithdrawals[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #36 'PendingConsolidations' + if canSeek { + enc.EncodeOffsetAt(offset36, uint32(enc.GetPosition()-dstlen)) + } + t := t.PendingConsolidations + vlen := len(t) + if vlen > int(ctx.exprs[9]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[9])), "PendingConsolidations") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(electra.PendingConsolidation) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "PendingConsolidations[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + return nil +} + +func (t *BeaconState) marshalSSZEncoderView_BeaconState_5(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + type encoderCtx struct { + ds sszutils.DynamicSpecs + exprs [11]uint64 + sizeFn1 func(ctx *encoderCtx, t []phase0.Root) (size int) + sizeFn10 func(ctx *encoderCtx, t []*electra.PendingDeposit) (size int) + sizeFn11 func(ctx *encoderCtx, t []*electra.PendingPartialWithdrawal) (size int) + sizeFn12 func(ctx *encoderCtx, t []*electra.PendingConsolidation) (size int) + sizeFn2 func(ctx *encoderCtx, t []*phase0.ETH1Data) (size int) + sizeFn3 func(ctx *encoderCtx, t []*phase0.Validator) (size int) + sizeFn4 func(ctx *encoderCtx, t []phase0.Gwei) (size int) + sizeFn5 func(ctx *encoderCtx, t []altair.ParticipationFlags) (size int) + sizeFn6 func(ctx *encoderCtx, t []altair.ParticipationFlags) (size int) + sizeFn7 func(ctx *encoderCtx, t []uint64) (size int) + sizeFn8 func(ctx *encoderCtx, t *ExecutionPayloadHeader) (size int) + sizeFn9 func(ctx *encoderCtx, t []*capella.HistoricalSummary) (size int) + } + ctx := &encoderCtx{ds: ds} + canSeek := enc.Seekable() + ctx.exprs[0], err = sszutils.ResolveSpecValueWithDefault(ds, "SLOTS_PER_HISTORICAL_ROOT", 8192) + if err != nil { + return err + } + ctx.exprs[1], err = sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_HISTORICAL_VECTOR", 65536) + if err != nil { + return err + } + ctx.exprs[2], err = sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_SLASHINGS_VECTOR", 8192) + if err != nil { + return err + } + ctx.exprs[3], err = sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE", 512) + if err != nil { + return err + } + ctx.exprs[4], err = sszutils.ResolveSpecValueWithDefault(ds, "(MIN_SEED_LOOKAHEAD+1)*SLOTS_PER_EPOCH", 64) + if err != nil { + return err + } + ctx.exprs[5], err = sszutils.ResolveSpecValueWithDefault(ds, "HISTORICAL_ROOTS_LIMIT", 16777216) + if err != nil { + return err + } + ctx.exprs[6], err = sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_ETH1_VOTING_PERIOD*SLOTS_PER_EPOCH", 2048) + if err != nil { + return err + } + ctx.exprs[7], err = sszutils.ResolveSpecValueWithDefault(ds, "VALIDATOR_REGISTRY_LIMIT", 1099511627776) + if err != nil { + return err + } + ctx.exprs[8], err = sszutils.ResolveSpecValueWithDefault(ds, "PENDING_DEPOSITS_LIMIT", 134217728) + if err != nil { + return err + } + ctx.exprs[9], err = sszutils.ResolveSpecValueWithDefault(ds, "PENDING_PARTIAL_WITHDRAWALS_LIMIT", 134217728) + if err != nil { + return err + } + ctx.exprs[10], err = sszutils.ResolveSpecValueWithDefault(ds, "PENDING_CONSOLIDATIONS_LIMIT", 262144) + if err != nil { + return err + } + // size for []phase0.Root + ctx.sizeFn1 = func(ctx *encoderCtx, t []phase0.Root) (size int) { + size += len(t) * 32 + return size + } + // size for []*phase0.ETH1Data + ctx.sizeFn2 = func(ctx *encoderCtx, t []*phase0.ETH1Data) (size int) { + size += len(t) * 72 + return size + } + // size for []*phase0.Validator + ctx.sizeFn3 = func(ctx *encoderCtx, t []*phase0.Validator) (size int) { + size += len(t) * 121 + return size + } + // size for []phase0.Gwei + ctx.sizeFn4 = func(ctx *encoderCtx, t []phase0.Gwei) (size int) { + size += len(t) * 8 + return size + } + // size for []altair.ParticipationFlags + ctx.sizeFn5 = func(ctx *encoderCtx, t []altair.ParticipationFlags) (size int) { + size += len(t) + return size + } + // size for []altair.ParticipationFlags + ctx.sizeFn6 = func(ctx *encoderCtx, t []altair.ParticipationFlags) (size int) { + size += len(t) + return size + } + // size for []uint64 + ctx.sizeFn7 = func(ctx *encoderCtx, t []uint64) (size int) { + size += len(t) * 8 + return size + } + // size for *ExecutionPayloadHeader + ctx.sizeFn8 = func(ctx *encoderCtx, t *ExecutionPayloadHeader) (size int) { + if viewFn := t.SizeSSZDynView((*deneb.ExecutionPayloadHeader)(nil)); viewFn != nil { + size += viewFn(ds) + } + return size + } + // size for []*capella.HistoricalSummary + ctx.sizeFn9 = func(ctx *encoderCtx, t []*capella.HistoricalSummary) (size int) { + size += len(t) * 64 + return size + } + // size for []*electra.PendingDeposit + ctx.sizeFn10 = func(ctx *encoderCtx, t []*electra.PendingDeposit) (size int) { + size += len(t) * 192 + return size + } + // size for []*electra.PendingPartialWithdrawal + ctx.sizeFn11 = func(ctx *encoderCtx, t []*electra.PendingPartialWithdrawal) (size int) { + size += len(t) * 24 + return size + } + // size for []*electra.PendingConsolidation + ctx.sizeFn12 = func(ctx *encoderCtx, t []*electra.PendingConsolidation) (size int) { + size += len(t) * 16 + return size + } + size1 := 32 * int(ctx.exprs[0]) + size2 := 32 * int(ctx.exprs[1]) + size3 := 8 * int(ctx.exprs[2]) + size5 := 48 * int(ctx.exprs[3]) + size4 := size5 + 48 // size expression for '*SyncCommittee' + size6 := 8 * int(ctx.exprs[4]) + if t == nil { + t = new(BeaconState) + } + dstlen := enc.GetPosition() + dynoff := uint32(size1 + size1 + size2 + size3 + size4 + size4 + size6 + 489) + { // Field #0 'GenesisTime' + enc.EncodeUint64(t.GenesisTime) + } + { // Field #1 'GenesisValidatorsRoot' + enc.EncodeBytes(t.GenesisValidatorsRoot[:32]) + } + { // Field #2 'Slot' + enc.EncodeUint64(uint64(t.Slot)) + } + { // Field #3 'Fork' + t := t.Fork + if t == nil { + t = new(phase0.Fork) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "Fork") + } else { + enc.SetBuffer(buf) + } + } + { // Field #4 'LatestBlockHeader' + t := t.LatestBlockHeader + if t == nil { + t = new(phase0.BeaconBlockHeader) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") + } else { + enc.SetBuffer(buf) + } + } + { // Field #5 'BlockRoots' + t := t.BlockRoots + vlen := len(t) + if vlen > int(ctx.exprs[0]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[0])), "BlockRoots") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:32]) + } + if vlen < int(ctx.exprs[0]) { + enc.EncodeZeroPadding((int(ctx.exprs[0]) - vlen) * 32) + } + } + { // Field #6 'StateRoots' + t := t.StateRoots + vlen := len(t) + if vlen > int(ctx.exprs[0]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[0])), "StateRoots") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:32]) + } + if vlen < int(ctx.exprs[0]) { + enc.EncodeZeroPadding((int(ctx.exprs[0]) - vlen) * 32) + } + } + // Offset #7 'HistoricalRoots' + offset7 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn1(ctx, t.HistoricalRoots)) + } + { // Field #8 'ETH1Data' + t := t.ETH1Data + if t == nil { + t = new(phase0.ETH1Data) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "ETH1Data") + } else { + enc.SetBuffer(buf) + } + } + // Offset #9 'ETH1DataVotes' + offset9 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn2(ctx, t.ETH1DataVotes)) + } + { // Field #10 'ETH1DepositIndex' + enc.EncodeUint64(t.ETH1DepositIndex) + } + // Offset #11 'Validators' + offset11 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn3(ctx, t.Validators)) + } + // Offset #12 'Balances' + offset12 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn4(ctx, t.Balances)) + } + { // Field #13 'RANDAOMixes' + t := t.RANDAOMixes + vlen := len(t) + if vlen > int(ctx.exprs[1]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[1])), "RANDAOMixes") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:32]) + } + if vlen < int(ctx.exprs[1]) { + enc.EncodeZeroPadding((int(ctx.exprs[1]) - vlen) * 32) + } + } + { // Field #14 'Slashings' + t := t.Slashings + vlen := len(t) + if vlen > int(ctx.exprs[2]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[2])), "Slashings") + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + if vlen < int(ctx.exprs[2]) { + enc.EncodeZeroPadding((int(ctx.exprs[2]) - vlen) * 8) + } + } + // Offset #15 'PreviousEpochParticipation' + offset15 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn5(ctx, t.PreviousEpochParticipation)) + } + // Offset #16 'CurrentEpochParticipation' + offset16 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn6(ctx, t.CurrentEpochParticipation)) + } + { // Field #17 'JustificationBits' + vlen := len(t.JustificationBits) + if vlen > 1 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 1), "JustificationBits") + } + enc.EncodeBytes(t.JustificationBits[:vlen]) + if vlen < 1 { + enc.EncodeZeroPadding((1 - vlen) * 1) + } + } + { // Field #18 'PreviousJustifiedCheckpoint' + t := t.PreviousJustifiedCheckpoint + if t == nil { + t = new(phase0.Checkpoint) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } else { + enc.SetBuffer(buf) + } + } + { // Field #19 'CurrentJustifiedCheckpoint' + t := t.CurrentJustifiedCheckpoint + if t == nil { + t = new(phase0.Checkpoint) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } else { + enc.SetBuffer(buf) + } + } + { // Field #20 'FinalizedCheckpoint' + t := t.FinalizedCheckpoint + if t == nil { + t = new(phase0.Checkpoint) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") + } else { + enc.SetBuffer(buf) + } + } + // Offset #21 'InactivityScores' + offset21 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn7(ctx, t.InactivityScores)) + } + { // Field #22 'CurrentSyncCommittee' + t := t.CurrentSyncCommittee + if t == nil { + t = new(altair.SyncCommittee) + } + { // Field #0 'Pubkeys' + t := t.Pubkeys + vlen := len(t) + if vlen > int(ctx.exprs[3]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[3])), "CurrentSyncCommittee.Pubkeys") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:48]) + } + if vlen < int(ctx.exprs[3]) { + enc.EncodeZeroPadding((int(ctx.exprs[3]) - vlen) * 48) + } + } + { // Field #1 'AggregatePubkey' + enc.EncodeBytes(t.AggregatePubkey[:48]) + } + } + { // Field #23 'NextSyncCommittee' + t := t.NextSyncCommittee + if t == nil { + t = new(altair.SyncCommittee) + } + { // Field #0 'Pubkeys' + t := t.Pubkeys + vlen := len(t) + if vlen > int(ctx.exprs[3]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[3])), "NextSyncCommittee.Pubkeys") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:48]) + } + if vlen < int(ctx.exprs[3]) { + enc.EncodeZeroPadding((int(ctx.exprs[3]) - vlen) * 48) + } + } + { // Field #1 'AggregatePubkey' + enc.EncodeBytes(t.AggregatePubkey[:48]) + } + } + // Offset #24 'LatestExecutionPayloadHeader' + offset24 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn8(ctx, t.LatestExecutionPayloadHeader)) + } + { // Field #25 'NextWithdrawalIndex' + enc.EncodeUint64(uint64(t.NextWithdrawalIndex)) + } + { // Field #26 'NextWithdrawalValidatorIndex' + enc.EncodeUint64(uint64(t.NextWithdrawalValidatorIndex)) + } + // Offset #27 'HistoricalSummaries' + offset27 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn9(ctx, t.HistoricalSummaries)) + } + { // Field #28 'DepositRequestsStartIndex' + enc.EncodeUint64(t.DepositRequestsStartIndex) + } + { // Field #29 'DepositBalanceToConsume' + enc.EncodeUint64(uint64(t.DepositBalanceToConsume)) + } + { // Field #30 'ExitBalanceToConsume' + enc.EncodeUint64(uint64(t.ExitBalanceToConsume)) + } + { // Field #31 'EarliestExitEpoch' + enc.EncodeUint64(uint64(t.EarliestExitEpoch)) + } + { // Field #32 'ConsolidationBalanceToConsume' + enc.EncodeUint64(uint64(t.ConsolidationBalanceToConsume)) + } + { // Field #33 'EarliestConsolidationEpoch' + enc.EncodeUint64(uint64(t.EarliestConsolidationEpoch)) + } + // Offset #34 'PendingDeposits' + offset34 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn10(ctx, t.PendingDeposits)) + } + // Offset #35 'PendingPartialWithdrawals' + offset35 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn11(ctx, t.PendingPartialWithdrawals)) + } + // Offset #36 'PendingConsolidations' + offset36 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn12(ctx, t.PendingConsolidations)) + } + { // Field #37 'ProposerLookahead' + t := t.ProposerLookahead + vlen := len(t) + if vlen > int(ctx.exprs[4]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[4])), "ProposerLookahead") + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + if vlen < int(ctx.exprs[4]) { + enc.EncodeZeroPadding((int(ctx.exprs[4]) - vlen) * 8) + } + } + { // Dynamic Field #7 'HistoricalRoots' + if canSeek { + enc.EncodeOffsetAt(offset7, uint32(enc.GetPosition()-dstlen)) + } + t := t.HistoricalRoots + vlen := len(t) + if vlen > int(ctx.exprs[5]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[5])), "HistoricalRoots") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:32]) + } + } + { // Dynamic Field #9 'ETH1DataVotes' + if canSeek { + enc.EncodeOffsetAt(offset9, uint32(enc.GetPosition()-dstlen)) + } + t := t.ETH1DataVotes + vlen := len(t) + if vlen > int(ctx.exprs[6]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[6])), "ETH1DataVotes") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(phase0.ETH1Data) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "ETH1DataVotes[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #11 'Validators' + if canSeek { + enc.EncodeOffsetAt(offset11, uint32(enc.GetPosition()-dstlen)) + } + t := t.Validators + vlen := len(t) + if vlen > int(ctx.exprs[7]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[7])), "Validators") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(phase0.Validator) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #12 'Balances' + if canSeek { + enc.EncodeOffsetAt(offset12, uint32(enc.GetPosition()-dstlen)) + } + t := t.Balances + vlen := len(t) + if vlen > int(ctx.exprs[7]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[7])), "Balances") + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + } + { // Dynamic Field #15 'PreviousEpochParticipation' + if canSeek { + enc.EncodeOffsetAt(offset15, uint32(enc.GetPosition()-dstlen)) + } + t := t.PreviousEpochParticipation + vlen := len(t) + if vlen > int(ctx.exprs[7]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[7])), "PreviousEpochParticipation") + } + for idx1 := range vlen { + enc.EncodeUint8(byte(t[idx1])) + } + } + { // Dynamic Field #16 'CurrentEpochParticipation' + if canSeek { + enc.EncodeOffsetAt(offset16, uint32(enc.GetPosition()-dstlen)) + } + t := t.CurrentEpochParticipation + vlen := len(t) + if vlen > int(ctx.exprs[7]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[7])), "CurrentEpochParticipation") + } + for idx1 := range vlen { + enc.EncodeUint8(byte(t[idx1])) + } + } + { // Dynamic Field #21 'InactivityScores' + if canSeek { + enc.EncodeOffsetAt(offset21, uint32(enc.GetPosition()-dstlen)) + } + t := t.InactivityScores + vlen := len(t) + if vlen > int(ctx.exprs[7]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[7])), "InactivityScores") + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + } + { // Dynamic Field #24 'LatestExecutionPayloadHeader' + if canSeek { + enc.EncodeOffsetAt(offset24, uint32(enc.GetPosition()-dstlen)) + } + t := t.LatestExecutionPayloadHeader + if t == nil { + t = new(ExecutionPayloadHeader) + } + if viewFn := t.MarshalSSZDynView((*deneb.ExecutionPayloadHeader)(nil)); viewFn != nil { + if buf, err := viewFn(ds, enc.GetBuffer()); err != nil { + return err + } else { + enc.SetBuffer(buf) + } + } else { + return sszutils.ErrNotImplemented + } + } + { // Dynamic Field #27 'HistoricalSummaries' + if canSeek { + enc.EncodeOffsetAt(offset27, uint32(enc.GetPosition()-dstlen)) + } + t := t.HistoricalSummaries + vlen := len(t) + if vlen > int(ctx.exprs[5]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[5])), "HistoricalSummaries") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(capella.HistoricalSummary) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "HistoricalSummaries[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #34 'PendingDeposits' + if canSeek { + enc.EncodeOffsetAt(offset34, uint32(enc.GetPosition()-dstlen)) + } + t := t.PendingDeposits + vlen := len(t) + if vlen > int(ctx.exprs[8]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[8])), "PendingDeposits") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(electra.PendingDeposit) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "PendingDeposits[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #35 'PendingPartialWithdrawals' + if canSeek { + enc.EncodeOffsetAt(offset35, uint32(enc.GetPosition()-dstlen)) + } + t := t.PendingPartialWithdrawals + vlen := len(t) + if vlen > int(ctx.exprs[9]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[9])), "PendingPartialWithdrawals") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(electra.PendingPartialWithdrawal) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "PendingPartialWithdrawals[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #36 'PendingConsolidations' + if canSeek { + enc.EncodeOffsetAt(offset36, uint32(enc.GetPosition()-dstlen)) + } + t := t.PendingConsolidations + vlen := len(t) + if vlen > int(ctx.exprs[10]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[10])), "PendingConsolidations") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(electra.PendingConsolidation) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "PendingConsolidations[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + return nil +} + +func (t *BeaconState) marshalSSZEncoderView_BeaconState_6(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + type encoderCtx struct { + ds sszutils.DynamicSpecs + exprs [16]uint64 + sizeFn1 func(ctx *encoderCtx, t []phase0.Root) (size int) + sizeFn10 func(ctx *encoderCtx, t []*electra.PendingPartialWithdrawal) (size int) + sizeFn11 func(ctx *encoderCtx, t []*electra.PendingConsolidation) (size int) + sizeFn12 func(ctx *encoderCtx, t []*gloas.Builder) (size int) + sizeFn13 func(ctx *encoderCtx, t []*gloas.BuilderPendingWithdrawal) (size int) + sizeFn14 func(ctx *encoderCtx, t *ExecutionPayloadBid) (size int) + sizeFn15 func(ctx *encoderCtx, t []*capella.Withdrawal) (size int) + sizeFn2 func(ctx *encoderCtx, t []*phase0.ETH1Data) (size int) + sizeFn3 func(ctx *encoderCtx, t []*phase0.Validator) (size int) + sizeFn4 func(ctx *encoderCtx, t []phase0.Gwei) (size int) + sizeFn5 func(ctx *encoderCtx, t []altair.ParticipationFlags) (size int) + sizeFn6 func(ctx *encoderCtx, t []altair.ParticipationFlags) (size int) + sizeFn7 func(ctx *encoderCtx, t []uint64) (size int) + sizeFn8 func(ctx *encoderCtx, t []*capella.HistoricalSummary) (size int) + sizeFn9 func(ctx *encoderCtx, t []*electra.PendingDeposit) (size int) + } + ctx := &encoderCtx{ds: ds} + canSeek := enc.Seekable() + ctx.exprs[0], err = sszutils.ResolveSpecValueWithDefault(ds, "SLOTS_PER_HISTORICAL_ROOT", 8192) + if err != nil { + return err + } + ctx.exprs[1], err = sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_HISTORICAL_VECTOR", 65536) + if err != nil { + return err + } + ctx.exprs[2], err = sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_SLASHINGS_VECTOR", 8192) + if err != nil { + return err + } + ctx.exprs[3], err = sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE", 512) + if err != nil { + return err + } + ctx.exprs[4], err = sszutils.ResolveSpecValueWithDefault(ds, "(MIN_SEED_LOOKAHEAD+1)*SLOTS_PER_EPOCH", 64) + if err != nil { + return err + } + ctx.exprs[5], err = sszutils.ResolveSpecValueWithDefault(ds, "SLOTS_PER_HISTORICAL_ROOT/8", 1024) + if err != nil { + return err + } + ctx.exprs[6], err = sszutils.ResolveSpecValueWithDefault(ds, "SLOTS_PER_EPOCH*2", 64) + if err != nil { + return err + } + ctx.exprs[7], err = sszutils.ResolveSpecValueWithDefault(ds, "PTC_SIZE", 512) + if err != nil { + return err + } + ctx.exprs[8], err = sszutils.ResolveSpecValueWithDefault(ds, "(2+MIN_SEED_LOOKAHEAD)*SLOTS_PER_EPOCH", 96) + if err != nil { + return err + } + ctx.exprs[9], err = sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_ETH1_VOTING_PERIOD*SLOTS_PER_EPOCH", 2048) + if err != nil { + return err + } + ctx.exprs[10], err = sszutils.ResolveSpecValueWithDefault(ds, "PENDING_DEPOSITS_LIMIT", 134217728) + if err != nil { + return err + } + ctx.exprs[11], err = sszutils.ResolveSpecValueWithDefault(ds, "PENDING_PARTIAL_WITHDRAWALS_LIMIT", 134217728) + if err != nil { + return err + } + ctx.exprs[12], err = sszutils.ResolveSpecValueWithDefault(ds, "PENDING_CONSOLIDATIONS_LIMIT", 262144) + if err != nil { + return err + } + ctx.exprs[13], err = sszutils.ResolveSpecValueWithDefault(ds, "BUILDER_REGISTRY_LIMIT", 1099511627776) + if err != nil { + return err + } + ctx.exprs[14], err = sszutils.ResolveSpecValueWithDefault(ds, "BUILDER_PENDING_WITHDRAWALS_LIMIT", 1048576) + if err != nil { + return err + } + ctx.exprs[15], err = sszutils.ResolveSpecValueWithDefault(ds, "MAX_WITHDRAWALS_PER_PAYLOAD", 16) + if err != nil { + return err + } + // size for []phase0.Root + ctx.sizeFn1 = func(ctx *encoderCtx, t []phase0.Root) (size int) { + size += len(t) * 32 + return size + } + // size for []*phase0.ETH1Data + ctx.sizeFn2 = func(ctx *encoderCtx, t []*phase0.ETH1Data) (size int) { + size += len(t) * 72 + return size + } + // size for []*phase0.Validator + ctx.sizeFn3 = func(ctx *encoderCtx, t []*phase0.Validator) (size int) { + size += len(t) * 121 + return size + } + // size for []phase0.Gwei + ctx.sizeFn4 = func(ctx *encoderCtx, t []phase0.Gwei) (size int) { + size += len(t) * 8 + return size + } + // size for []altair.ParticipationFlags + ctx.sizeFn5 = func(ctx *encoderCtx, t []altair.ParticipationFlags) (size int) { + size += len(t) + return size + } + // size for []altair.ParticipationFlags + ctx.sizeFn6 = func(ctx *encoderCtx, t []altair.ParticipationFlags) (size int) { + size += len(t) + return size + } + // size for []uint64 + ctx.sizeFn7 = func(ctx *encoderCtx, t []uint64) (size int) { + size += len(t) * 8 + return size + } + // size for []*capella.HistoricalSummary + ctx.sizeFn8 = func(ctx *encoderCtx, t []*capella.HistoricalSummary) (size int) { + size += len(t) * 64 + return size + } + // size for []*electra.PendingDeposit + ctx.sizeFn9 = func(ctx *encoderCtx, t []*electra.PendingDeposit) (size int) { + size += len(t) * 192 + return size + } + // size for []*electra.PendingPartialWithdrawal + ctx.sizeFn10 = func(ctx *encoderCtx, t []*electra.PendingPartialWithdrawal) (size int) { + size += len(t) * 24 + return size + } + // size for []*electra.PendingConsolidation + ctx.sizeFn11 = func(ctx *encoderCtx, t []*electra.PendingConsolidation) (size int) { + size += len(t) * 16 + return size + } + // size for []*gloas.Builder + ctx.sizeFn12 = func(ctx *encoderCtx, t []*gloas.Builder) (size int) { + size += len(t) * 93 + return size + } + // size for []*gloas.BuilderPendingWithdrawal + ctx.sizeFn13 = func(ctx *encoderCtx, t []*gloas.BuilderPendingWithdrawal) (size int) { + size += len(t) * 36 + return size + } + // size for *ExecutionPayloadBid + ctx.sizeFn14 = func(ctx *encoderCtx, t *ExecutionPayloadBid) (size int) { + if viewFn := t.SizeSSZDynView((*gloas.ExecutionPayloadBid)(nil)); viewFn != nil { + size += viewFn(ds) + } + return size + } + // size for []*capella.Withdrawal + ctx.sizeFn15 = func(ctx *encoderCtx, t []*capella.Withdrawal) (size int) { + size += len(t) * 44 + return size + } + size1 := 32 * int(ctx.exprs[0]) + size2 := 32 * int(ctx.exprs[1]) + size3 := 8 * int(ctx.exprs[2]) + size5 := 48 * int(ctx.exprs[3]) + size4 := size5 + 48 // size expression for '*SyncCommittee' + size6 := 8 * int(ctx.exprs[4]) + size7 := 1 * int(ctx.exprs[5]) + size8 := 44 * int(ctx.exprs[6]) + size10 := 8 * int(ctx.exprs[7]) + size9 := size10 * int(ctx.exprs[8]) + if t == nil { + t = new(BeaconState) + } + dstlen := enc.GetPosition() + dynoff := uint32(size1 + size1 + size2 + size3 + size4 + size4 + size6 + size7 + size8 + size9 + 541) + { // Field #0 'GenesisTime' + enc.EncodeUint64(t.GenesisTime) + } + { // Field #1 'GenesisValidatorsRoot' + enc.EncodeBytes(t.GenesisValidatorsRoot[:32]) + } + { // Field #2 'Slot' + enc.EncodeUint64(uint64(t.Slot)) + } + { // Field #3 'Fork' + t := t.Fork + if t == nil { + t = new(phase0.Fork) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "Fork") + } else { + enc.SetBuffer(buf) + } + } + { // Field #4 'LatestBlockHeader' + t := t.LatestBlockHeader + if t == nil { + t = new(phase0.BeaconBlockHeader) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") + } else { + enc.SetBuffer(buf) + } + } + { // Field #5 'BlockRoots' + t := t.BlockRoots + vlen := len(t) + if vlen > int(ctx.exprs[0]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[0])), "BlockRoots") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:32]) + } + if vlen < int(ctx.exprs[0]) { + enc.EncodeZeroPadding((int(ctx.exprs[0]) - vlen) * 32) + } + } + { // Field #6 'StateRoots' + t := t.StateRoots + vlen := len(t) + if vlen > int(ctx.exprs[0]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[0])), "StateRoots") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:32]) + } + if vlen < int(ctx.exprs[0]) { + enc.EncodeZeroPadding((int(ctx.exprs[0]) - vlen) * 32) + } + } + // Offset #7 'HistoricalRoots' + offset7 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn1(ctx, t.HistoricalRoots)) + } + { // Field #8 'ETH1Data' + t := t.ETH1Data + if t == nil { + t = new(phase0.ETH1Data) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "ETH1Data") + } else { + enc.SetBuffer(buf) + } + } + // Offset #9 'ETH1DataVotes' + offset9 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn2(ctx, t.ETH1DataVotes)) + } + { // Field #10 'ETH1DepositIndex' + enc.EncodeUint64(t.ETH1DepositIndex) + } + // Offset #11 'Validators' + offset11 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn3(ctx, t.Validators)) + } + // Offset #12 'Balances' + offset12 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn4(ctx, t.Balances)) + } + { // Field #13 'RANDAOMixes' + t := t.RANDAOMixes + vlen := len(t) + if vlen > int(ctx.exprs[1]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[1])), "RANDAOMixes") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:32]) + } + if vlen < int(ctx.exprs[1]) { + enc.EncodeZeroPadding((int(ctx.exprs[1]) - vlen) * 32) + } + } + { // Field #14 'Slashings' + t := t.Slashings + vlen := len(t) + if vlen > int(ctx.exprs[2]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[2])), "Slashings") + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + if vlen < int(ctx.exprs[2]) { + enc.EncodeZeroPadding((int(ctx.exprs[2]) - vlen) * 8) + } + } + // Offset #15 'PreviousEpochParticipation' + offset15 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn5(ctx, t.PreviousEpochParticipation)) + } + // Offset #16 'CurrentEpochParticipation' + offset16 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn6(ctx, t.CurrentEpochParticipation)) + } + { // Field #17 'JustificationBits' + vlen := len(t.JustificationBits) + if vlen > 1 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 1), "JustificationBits") + } + enc.EncodeBytes(t.JustificationBits[:vlen]) + if vlen < 1 { + enc.EncodeZeroPadding((1 - vlen) * 1) + } + } + { // Field #18 'PreviousJustifiedCheckpoint' + t := t.PreviousJustifiedCheckpoint + if t == nil { + t = new(phase0.Checkpoint) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } else { + enc.SetBuffer(buf) + } + } + { // Field #19 'CurrentJustifiedCheckpoint' + t := t.CurrentJustifiedCheckpoint + if t == nil { + t = new(phase0.Checkpoint) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } else { + enc.SetBuffer(buf) + } + } + { // Field #20 'FinalizedCheckpoint' + t := t.FinalizedCheckpoint + if t == nil { + t = new(phase0.Checkpoint) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") + } else { + enc.SetBuffer(buf) + } + } + // Offset #21 'InactivityScores' + offset21 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn7(ctx, t.InactivityScores)) + } + { // Field #22 'CurrentSyncCommittee' + t := t.CurrentSyncCommittee + if t == nil { + t = new(altair.SyncCommittee) + } + { // Field #0 'Pubkeys' + t := t.Pubkeys + vlen := len(t) + if vlen > int(ctx.exprs[3]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[3])), "CurrentSyncCommittee.Pubkeys") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:48]) + } + if vlen < int(ctx.exprs[3]) { + enc.EncodeZeroPadding((int(ctx.exprs[3]) - vlen) * 48) + } + } + { // Field #1 'AggregatePubkey' + enc.EncodeBytes(t.AggregatePubkey[:48]) + } + } + { // Field #23 'NextSyncCommittee' + t := t.NextSyncCommittee + if t == nil { + t = new(altair.SyncCommittee) + } + { // Field #0 'Pubkeys' + t := t.Pubkeys + vlen := len(t) + if vlen > int(ctx.exprs[3]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[3])), "NextSyncCommittee.Pubkeys") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:48]) + } + if vlen < int(ctx.exprs[3]) { + enc.EncodeZeroPadding((int(ctx.exprs[3]) - vlen) * 48) + } + } + { // Field #1 'AggregatePubkey' + enc.EncodeBytes(t.AggregatePubkey[:48]) + } + } + { // Field #24 'LatestBlockHash' + enc.EncodeBytes(t.LatestBlockHash[:32]) + } + { // Field #25 'NextWithdrawalIndex' + enc.EncodeUint64(uint64(t.NextWithdrawalIndex)) + } + { // Field #26 'NextWithdrawalValidatorIndex' + enc.EncodeUint64(uint64(t.NextWithdrawalValidatorIndex)) + } + // Offset #27 'HistoricalSummaries' + offset27 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn8(ctx, t.HistoricalSummaries)) + } + { // Field #28 'DepositRequestsStartIndex' + enc.EncodeUint64(t.DepositRequestsStartIndex) + } + { // Field #29 'DepositBalanceToConsume' + enc.EncodeUint64(uint64(t.DepositBalanceToConsume)) + } + { // Field #30 'ExitBalanceToConsume' + enc.EncodeUint64(uint64(t.ExitBalanceToConsume)) + } + { // Field #31 'EarliestExitEpoch' + enc.EncodeUint64(uint64(t.EarliestExitEpoch)) + } + { // Field #32 'ConsolidationBalanceToConsume' + enc.EncodeUint64(uint64(t.ConsolidationBalanceToConsume)) + } + { // Field #33 'EarliestConsolidationEpoch' + enc.EncodeUint64(uint64(t.EarliestConsolidationEpoch)) + } + // Offset #34 'PendingDeposits' + offset34 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn9(ctx, t.PendingDeposits)) + } + // Offset #35 'PendingPartialWithdrawals' + offset35 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn10(ctx, t.PendingPartialWithdrawals)) + } + // Offset #36 'PendingConsolidations' + offset36 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn11(ctx, t.PendingConsolidations)) + } + { // Field #37 'ProposerLookahead' + t := t.ProposerLookahead + vlen := len(t) + if vlen > int(ctx.exprs[4]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[4])), "ProposerLookahead") + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + if vlen < int(ctx.exprs[4]) { + enc.EncodeZeroPadding((int(ctx.exprs[4]) - vlen) * 8) + } + } + // Offset #38 'Builders' + offset38 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn12(ctx, t.Builders)) + } + { // Field #39 'NextWithdrawalBuilderIndex' + enc.EncodeUint64(uint64(t.NextWithdrawalBuilderIndex)) + } + { // Field #40 'ExecutionPayloadAvailability' + vlen := len(t.ExecutionPayloadAvailability) + if vlen > int(ctx.exprs[5]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[5])), "ExecutionPayloadAvailability") + } + enc.EncodeBytes(t.ExecutionPayloadAvailability[:vlen]) + if vlen < int(ctx.exprs[5]) { + enc.EncodeZeroPadding((int(ctx.exprs[5]) - vlen) * 1) + } + } + { // Field #41 'BuilderPendingPayments' + t := t.BuilderPendingPayments + vlen := len(t) + if vlen > int(ctx.exprs[6]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[6])), "BuilderPendingPayments") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(gloas.BuilderPendingPayment) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "BuilderPendingPayments[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + if vlen < int(ctx.exprs[6]) { + enc.EncodeZeroPadding((int(ctx.exprs[6]) - vlen) * 44) + } + } + // Offset #42 'BuilderPendingWithdrawals' + offset42 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn13(ctx, t.BuilderPendingWithdrawals)) + } + // Offset #43 'LatestExecutionPayloadBid' + offset43 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn14(ctx, t.LatestExecutionPayloadBid)) + } + // Offset #44 'PayloadExpectedWithdrawals' + offset44 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn15(ctx, t.PayloadExpectedWithdrawals)) + } + { // Field #45 'PTCWindow' + t := t.PTCWindow + vlen := len(t) + if vlen > int(ctx.exprs[8]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[8])), "PTCWindow") + } + for idx1 := range vlen { + t := t[idx1] + vlen := len(t) + if vlen > int(ctx.exprs[7]) { + return sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[7])), "PTCWindow[%d]", idx1) + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + if vlen < int(ctx.exprs[7]) { + enc.EncodeZeroPadding((int(ctx.exprs[7]) - vlen) * 8) + } + } + if vlen < int(ctx.exprs[8]) { + enc.EncodeZeroPadding((int(ctx.exprs[8]) - vlen) * 4096) + } + } + { // Dynamic Field #7 'HistoricalRoots' + if canSeek { + enc.EncodeOffsetAt(offset7, uint32(enc.GetPosition()-dstlen)) + } + t := t.HistoricalRoots + vlen := len(t) + if vlen > 16777216 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16777216), "HistoricalRoots") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:32]) + } + } + { // Dynamic Field #9 'ETH1DataVotes' + if canSeek { + enc.EncodeOffsetAt(offset9, uint32(enc.GetPosition()-dstlen)) + } + t := t.ETH1DataVotes + vlen := len(t) + if vlen > int(ctx.exprs[9]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[9])), "ETH1DataVotes") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(phase0.ETH1Data) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "ETH1DataVotes[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #11 'Validators' + if canSeek { + enc.EncodeOffsetAt(offset11, uint32(enc.GetPosition()-dstlen)) + } + t := t.Validators + vlen := len(t) + if vlen > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1099511627776), "Validators") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(phase0.Validator) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #12 'Balances' + if canSeek { + enc.EncodeOffsetAt(offset12, uint32(enc.GetPosition()-dstlen)) + } + t := t.Balances + vlen := len(t) + if vlen > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1099511627776), "Balances") + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + } + { // Dynamic Field #15 'PreviousEpochParticipation' + if canSeek { + enc.EncodeOffsetAt(offset15, uint32(enc.GetPosition()-dstlen)) + } + t := t.PreviousEpochParticipation + vlen := len(t) + if vlen > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1099511627776), "PreviousEpochParticipation") + } + for idx1 := range vlen { + enc.EncodeUint8(byte(t[idx1])) + } + } + { // Dynamic Field #16 'CurrentEpochParticipation' + if canSeek { + enc.EncodeOffsetAt(offset16, uint32(enc.GetPosition()-dstlen)) + } + t := t.CurrentEpochParticipation + vlen := len(t) + if vlen > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1099511627776), "CurrentEpochParticipation") + } + for idx1 := range vlen { + enc.EncodeUint8(byte(t[idx1])) + } + } + { // Dynamic Field #21 'InactivityScores' + if canSeek { + enc.EncodeOffsetAt(offset21, uint32(enc.GetPosition()-dstlen)) + } + t := t.InactivityScores + vlen := len(t) + if vlen > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1099511627776), "InactivityScores") + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + } + { // Dynamic Field #27 'HistoricalSummaries' + if canSeek { + enc.EncodeOffsetAt(offset27, uint32(enc.GetPosition()-dstlen)) + } + t := t.HistoricalSummaries + vlen := len(t) + if vlen > 16777216 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16777216), "HistoricalSummaries") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(capella.HistoricalSummary) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "HistoricalSummaries[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #34 'PendingDeposits' + if canSeek { + enc.EncodeOffsetAt(offset34, uint32(enc.GetPosition()-dstlen)) + } + t := t.PendingDeposits + vlen := len(t) + if vlen > int(ctx.exprs[10]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[10])), "PendingDeposits") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(electra.PendingDeposit) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "PendingDeposits[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #35 'PendingPartialWithdrawals' + if canSeek { + enc.EncodeOffsetAt(offset35, uint32(enc.GetPosition()-dstlen)) + } + t := t.PendingPartialWithdrawals + vlen := len(t) + if vlen > int(ctx.exprs[11]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[11])), "PendingPartialWithdrawals") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(electra.PendingPartialWithdrawal) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "PendingPartialWithdrawals[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #36 'PendingConsolidations' + if canSeek { + enc.EncodeOffsetAt(offset36, uint32(enc.GetPosition()-dstlen)) + } + t := t.PendingConsolidations + vlen := len(t) + if vlen > int(ctx.exprs[12]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[12])), "PendingConsolidations") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(electra.PendingConsolidation) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "PendingConsolidations[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #38 'Builders' + if canSeek { + enc.EncodeOffsetAt(offset38, uint32(enc.GetPosition()-dstlen)) + } + t := t.Builders + vlen := len(t) + if vlen > int(ctx.exprs[13]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[13])), "Builders") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(gloas.Builder) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "Builders[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #42 'BuilderPendingWithdrawals' + if canSeek { + enc.EncodeOffsetAt(offset42, uint32(enc.GetPosition()-dstlen)) + } + t := t.BuilderPendingWithdrawals + vlen := len(t) + if vlen > int(ctx.exprs[14]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[14])), "BuilderPendingWithdrawals") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(gloas.BuilderPendingWithdrawal) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "BuilderPendingWithdrawals[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #43 'LatestExecutionPayloadBid' + if canSeek { + enc.EncodeOffsetAt(offset43, uint32(enc.GetPosition()-dstlen)) + } + t := t.LatestExecutionPayloadBid + if t == nil { + t = new(ExecutionPayloadBid) + } + if viewFn := t.MarshalSSZDynView((*gloas.ExecutionPayloadBid)(nil)); viewFn != nil { + if buf, err := viewFn(ds, enc.GetBuffer()); err != nil { + return err + } else { + enc.SetBuffer(buf) + } + } else { + return sszutils.ErrNotImplemented + } + } + { // Dynamic Field #44 'PayloadExpectedWithdrawals' + if canSeek { + enc.EncodeOffsetAt(offset44, uint32(enc.GetPosition()-dstlen)) + } + t := t.PayloadExpectedWithdrawals + vlen := len(t) + if vlen > int(ctx.exprs[15]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[15])), "PayloadExpectedWithdrawals") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(capella.Withdrawal) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "PayloadExpectedWithdrawals[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + return nil +} + +func (t *BeaconState) marshalSSZEncoderView_BeaconState_7(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + type encoderCtx struct { + ds sszutils.DynamicSpecs + exprs [16]uint64 + sizeFn1 func(ctx *encoderCtx, t []phase0.Root) (size int) + sizeFn10 func(ctx *encoderCtx, t []*electra.PendingPartialWithdrawal) (size int) + sizeFn11 func(ctx *encoderCtx, t []*electra.PendingConsolidation) (size int) + sizeFn12 func(ctx *encoderCtx, t []*gloas.Builder) (size int) + sizeFn13 func(ctx *encoderCtx, t []*gloas.BuilderPendingWithdrawal) (size int) + sizeFn14 func(ctx *encoderCtx, t *ExecutionPayloadBid) (size int) + sizeFn15 func(ctx *encoderCtx, t []*capella.Withdrawal) (size int) + sizeFn2 func(ctx *encoderCtx, t []*phase0.ETH1Data) (size int) + sizeFn3 func(ctx *encoderCtx, t []*phase0.Validator) (size int) + sizeFn4 func(ctx *encoderCtx, t []phase0.Gwei) (size int) + sizeFn5 func(ctx *encoderCtx, t []altair.ParticipationFlags) (size int) + sizeFn6 func(ctx *encoderCtx, t []altair.ParticipationFlags) (size int) + sizeFn7 func(ctx *encoderCtx, t []uint64) (size int) + sizeFn8 func(ctx *encoderCtx, t []*capella.HistoricalSummary) (size int) + sizeFn9 func(ctx *encoderCtx, t []*electra.PendingDeposit) (size int) + } + ctx := &encoderCtx{ds: ds} + canSeek := enc.Seekable() + ctx.exprs[0], err = sszutils.ResolveSpecValueWithDefault(ds, "SLOTS_PER_HISTORICAL_ROOT", 8192) + if err != nil { + return err + } + ctx.exprs[1], err = sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_HISTORICAL_VECTOR", 65536) + if err != nil { + return err + } + ctx.exprs[2], err = sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_SLASHINGS_VECTOR", 8192) + if err != nil { + return err + } + ctx.exprs[3], err = sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE", 512) + if err != nil { + return err + } + ctx.exprs[4], err = sszutils.ResolveSpecValueWithDefault(ds, "(MIN_SEED_LOOKAHEAD+1)*SLOTS_PER_EPOCH", 64) + if err != nil { + return err + } + ctx.exprs[5], err = sszutils.ResolveSpecValueWithDefault(ds, "SLOTS_PER_HISTORICAL_ROOT/8", 1024) + if err != nil { + return err + } + ctx.exprs[6], err = sszutils.ResolveSpecValueWithDefault(ds, "SLOTS_PER_EPOCH*2", 64) + if err != nil { + return err + } + ctx.exprs[7], err = sszutils.ResolveSpecValueWithDefault(ds, "PTC_SIZE", 512) + if err != nil { + return err + } + ctx.exprs[8], err = sszutils.ResolveSpecValueWithDefault(ds, "(2+MIN_SEED_LOOKAHEAD)*SLOTS_PER_EPOCH", 96) + if err != nil { + return err + } + ctx.exprs[9], err = sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_ETH1_VOTING_PERIOD*SLOTS_PER_EPOCH", 2048) + if err != nil { + return err + } + ctx.exprs[10], err = sszutils.ResolveSpecValueWithDefault(ds, "PENDING_DEPOSITS_LIMIT", 134217728) + if err != nil { + return err + } + ctx.exprs[11], err = sszutils.ResolveSpecValueWithDefault(ds, "PENDING_PARTIAL_WITHDRAWALS_LIMIT", 134217728) + if err != nil { + return err + } + ctx.exprs[12], err = sszutils.ResolveSpecValueWithDefault(ds, "PENDING_CONSOLIDATIONS_LIMIT", 262144) + if err != nil { + return err + } + ctx.exprs[13], err = sszutils.ResolveSpecValueWithDefault(ds, "BUILDER_REGISTRY_LIMIT", 1099511627776) + if err != nil { + return err + } + ctx.exprs[14], err = sszutils.ResolveSpecValueWithDefault(ds, "BUILDER_PENDING_WITHDRAWALS_LIMIT", 1048576) + if err != nil { + return err + } + ctx.exprs[15], err = sszutils.ResolveSpecValueWithDefault(ds, "MAX_WITHDRAWALS_PER_PAYLOAD", 16) + if err != nil { + return err + } + // size for []phase0.Root + ctx.sizeFn1 = func(ctx *encoderCtx, t []phase0.Root) (size int) { + size += len(t) * 32 + return size + } + // size for []*phase0.ETH1Data + ctx.sizeFn2 = func(ctx *encoderCtx, t []*phase0.ETH1Data) (size int) { + size += len(t) * 72 + return size + } + // size for []*phase0.Validator + ctx.sizeFn3 = func(ctx *encoderCtx, t []*phase0.Validator) (size int) { + size += len(t) * 121 + return size + } + // size for []phase0.Gwei + ctx.sizeFn4 = func(ctx *encoderCtx, t []phase0.Gwei) (size int) { + size += len(t) * 8 + return size + } + // size for []altair.ParticipationFlags + ctx.sizeFn5 = func(ctx *encoderCtx, t []altair.ParticipationFlags) (size int) { + size += len(t) + return size + } + // size for []altair.ParticipationFlags + ctx.sizeFn6 = func(ctx *encoderCtx, t []altair.ParticipationFlags) (size int) { + size += len(t) + return size + } + // size for []uint64 + ctx.sizeFn7 = func(ctx *encoderCtx, t []uint64) (size int) { + size += len(t) * 8 + return size + } + // size for []*capella.HistoricalSummary + ctx.sizeFn8 = func(ctx *encoderCtx, t []*capella.HistoricalSummary) (size int) { + size += len(t) * 64 + return size + } + // size for []*electra.PendingDeposit + ctx.sizeFn9 = func(ctx *encoderCtx, t []*electra.PendingDeposit) (size int) { + size += len(t) * 192 + return size + } + // size for []*electra.PendingPartialWithdrawal + ctx.sizeFn10 = func(ctx *encoderCtx, t []*electra.PendingPartialWithdrawal) (size int) { + size += len(t) * 24 + return size + } + // size for []*electra.PendingConsolidation + ctx.sizeFn11 = func(ctx *encoderCtx, t []*electra.PendingConsolidation) (size int) { + size += len(t) * 16 + return size + } + // size for []*gloas.Builder + ctx.sizeFn12 = func(ctx *encoderCtx, t []*gloas.Builder) (size int) { + size += len(t) * 93 + return size + } + // size for []*gloas.BuilderPendingWithdrawal + ctx.sizeFn13 = func(ctx *encoderCtx, t []*gloas.BuilderPendingWithdrawal) (size int) { + size += len(t) * 36 + return size + } + // size for *ExecutionPayloadBid + ctx.sizeFn14 = func(ctx *encoderCtx, t *ExecutionPayloadBid) (size int) { + if viewFn := t.SizeSSZDynView((*heze.ExecutionPayloadBid)(nil)); viewFn != nil { + size += viewFn(ds) + } + return size + } + // size for []*capella.Withdrawal + ctx.sizeFn15 = func(ctx *encoderCtx, t []*capella.Withdrawal) (size int) { + size += len(t) * 44 + return size + } + size1 := 32 * int(ctx.exprs[0]) + size2 := 32 * int(ctx.exprs[1]) + size3 := 8 * int(ctx.exprs[2]) + size5 := 48 * int(ctx.exprs[3]) + size4 := size5 + 48 // size expression for '*SyncCommittee' + size6 := 8 * int(ctx.exprs[4]) + size7 := 1 * int(ctx.exprs[5]) + size8 := 44 * int(ctx.exprs[6]) + size10 := 8 * int(ctx.exprs[7]) + size9 := size10 * int(ctx.exprs[8]) + if t == nil { + t = new(BeaconState) + } + dstlen := enc.GetPosition() + dynoff := uint32(size1 + size1 + size2 + size3 + size4 + size4 + size6 + size7 + size8 + size9 + 541) + { // Field #0 'GenesisTime' + enc.EncodeUint64(t.GenesisTime) + } + { // Field #1 'GenesisValidatorsRoot' + enc.EncodeBytes(t.GenesisValidatorsRoot[:32]) + } + { // Field #2 'Slot' + enc.EncodeUint64(uint64(t.Slot)) + } + { // Field #3 'Fork' + t := t.Fork + if t == nil { + t = new(phase0.Fork) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "Fork") + } else { + enc.SetBuffer(buf) + } + } + { // Field #4 'LatestBlockHeader' + t := t.LatestBlockHeader + if t == nil { + t = new(phase0.BeaconBlockHeader) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") + } else { + enc.SetBuffer(buf) + } + } + { // Field #5 'BlockRoots' + t := t.BlockRoots + vlen := len(t) + if vlen > int(ctx.exprs[0]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[0])), "BlockRoots") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:32]) + } + if vlen < int(ctx.exprs[0]) { + enc.EncodeZeroPadding((int(ctx.exprs[0]) - vlen) * 32) + } + } + { // Field #6 'StateRoots' + t := t.StateRoots + vlen := len(t) + if vlen > int(ctx.exprs[0]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[0])), "StateRoots") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:32]) + } + if vlen < int(ctx.exprs[0]) { + enc.EncodeZeroPadding((int(ctx.exprs[0]) - vlen) * 32) + } + } + // Offset #7 'HistoricalRoots' + offset7 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn1(ctx, t.HistoricalRoots)) + } + { // Field #8 'ETH1Data' + t := t.ETH1Data + if t == nil { + t = new(phase0.ETH1Data) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "ETH1Data") + } else { + enc.SetBuffer(buf) + } + } + // Offset #9 'ETH1DataVotes' + offset9 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn2(ctx, t.ETH1DataVotes)) + } + { // Field #10 'ETH1DepositIndex' + enc.EncodeUint64(t.ETH1DepositIndex) + } + // Offset #11 'Validators' + offset11 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn3(ctx, t.Validators)) + } + // Offset #12 'Balances' + offset12 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn4(ctx, t.Balances)) + } + { // Field #13 'RANDAOMixes' + t := t.RANDAOMixes + vlen := len(t) + if vlen > int(ctx.exprs[1]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[1])), "RANDAOMixes") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:32]) + } + if vlen < int(ctx.exprs[1]) { + enc.EncodeZeroPadding((int(ctx.exprs[1]) - vlen) * 32) + } + } + { // Field #14 'Slashings' + t := t.Slashings + vlen := len(t) + if vlen > int(ctx.exprs[2]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[2])), "Slashings") + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + if vlen < int(ctx.exprs[2]) { + enc.EncodeZeroPadding((int(ctx.exprs[2]) - vlen) * 8) + } + } + // Offset #15 'PreviousEpochParticipation' + offset15 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn5(ctx, t.PreviousEpochParticipation)) + } + // Offset #16 'CurrentEpochParticipation' + offset16 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn6(ctx, t.CurrentEpochParticipation)) + } + { // Field #17 'JustificationBits' + vlen := len(t.JustificationBits) + if vlen > 1 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 1), "JustificationBits") + } + enc.EncodeBytes(t.JustificationBits[:vlen]) + if vlen < 1 { + enc.EncodeZeroPadding((1 - vlen) * 1) + } + } + { // Field #18 'PreviousJustifiedCheckpoint' + t := t.PreviousJustifiedCheckpoint + if t == nil { + t = new(phase0.Checkpoint) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } else { + enc.SetBuffer(buf) + } + } + { // Field #19 'CurrentJustifiedCheckpoint' + t := t.CurrentJustifiedCheckpoint + if t == nil { + t = new(phase0.Checkpoint) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } else { + enc.SetBuffer(buf) + } + } + { // Field #20 'FinalizedCheckpoint' + t := t.FinalizedCheckpoint + if t == nil { + t = new(phase0.Checkpoint) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") + } else { + enc.SetBuffer(buf) + } + } + // Offset #21 'InactivityScores' + offset21 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn7(ctx, t.InactivityScores)) + } + { // Field #22 'CurrentSyncCommittee' + t := t.CurrentSyncCommittee + if t == nil { + t = new(altair.SyncCommittee) + } + { // Field #0 'Pubkeys' + t := t.Pubkeys + vlen := len(t) + if vlen > int(ctx.exprs[3]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[3])), "CurrentSyncCommittee.Pubkeys") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:48]) + } + if vlen < int(ctx.exprs[3]) { + enc.EncodeZeroPadding((int(ctx.exprs[3]) - vlen) * 48) + } + } + { // Field #1 'AggregatePubkey' + enc.EncodeBytes(t.AggregatePubkey[:48]) + } + } + { // Field #23 'NextSyncCommittee' + t := t.NextSyncCommittee + if t == nil { + t = new(altair.SyncCommittee) + } + { // Field #0 'Pubkeys' + t := t.Pubkeys + vlen := len(t) + if vlen > int(ctx.exprs[3]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[3])), "NextSyncCommittee.Pubkeys") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:48]) + } + if vlen < int(ctx.exprs[3]) { + enc.EncodeZeroPadding((int(ctx.exprs[3]) - vlen) * 48) + } + } + { // Field #1 'AggregatePubkey' + enc.EncodeBytes(t.AggregatePubkey[:48]) + } + } + { // Field #24 'LatestBlockHash' + enc.EncodeBytes(t.LatestBlockHash[:32]) + } + { // Field #25 'NextWithdrawalIndex' + enc.EncodeUint64(uint64(t.NextWithdrawalIndex)) + } + { // Field #26 'NextWithdrawalValidatorIndex' + enc.EncodeUint64(uint64(t.NextWithdrawalValidatorIndex)) + } + // Offset #27 'HistoricalSummaries' + offset27 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn8(ctx, t.HistoricalSummaries)) + } + { // Field #28 'DepositRequestsStartIndex' + enc.EncodeUint64(t.DepositRequestsStartIndex) + } + { // Field #29 'DepositBalanceToConsume' + enc.EncodeUint64(uint64(t.DepositBalanceToConsume)) + } + { // Field #30 'ExitBalanceToConsume' + enc.EncodeUint64(uint64(t.ExitBalanceToConsume)) + } + { // Field #31 'EarliestExitEpoch' + enc.EncodeUint64(uint64(t.EarliestExitEpoch)) + } + { // Field #32 'ConsolidationBalanceToConsume' + enc.EncodeUint64(uint64(t.ConsolidationBalanceToConsume)) + } + { // Field #33 'EarliestConsolidationEpoch' + enc.EncodeUint64(uint64(t.EarliestConsolidationEpoch)) + } + // Offset #34 'PendingDeposits' + offset34 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn9(ctx, t.PendingDeposits)) + } + // Offset #35 'PendingPartialWithdrawals' + offset35 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn10(ctx, t.PendingPartialWithdrawals)) + } + // Offset #36 'PendingConsolidations' + offset36 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn11(ctx, t.PendingConsolidations)) + } + { // Field #37 'ProposerLookahead' + t := t.ProposerLookahead + vlen := len(t) + if vlen > int(ctx.exprs[4]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[4])), "ProposerLookahead") + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + if vlen < int(ctx.exprs[4]) { + enc.EncodeZeroPadding((int(ctx.exprs[4]) - vlen) * 8) + } + } + // Offset #38 'Builders' + offset38 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn12(ctx, t.Builders)) + } + { // Field #39 'NextWithdrawalBuilderIndex' + enc.EncodeUint64(uint64(t.NextWithdrawalBuilderIndex)) + } + { // Field #40 'ExecutionPayloadAvailability' + vlen := len(t.ExecutionPayloadAvailability) + if vlen > int(ctx.exprs[5]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[5])), "ExecutionPayloadAvailability") + } + enc.EncodeBytes(t.ExecutionPayloadAvailability[:vlen]) + if vlen < int(ctx.exprs[5]) { + enc.EncodeZeroPadding((int(ctx.exprs[5]) - vlen) * 1) + } + } + { // Field #41 'BuilderPendingPayments' + t := t.BuilderPendingPayments + vlen := len(t) + if vlen > int(ctx.exprs[6]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[6])), "BuilderPendingPayments") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(gloas.BuilderPendingPayment) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "BuilderPendingPayments[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + if vlen < int(ctx.exprs[6]) { + enc.EncodeZeroPadding((int(ctx.exprs[6]) - vlen) * 44) + } + } + // Offset #42 'BuilderPendingWithdrawals' + offset42 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn13(ctx, t.BuilderPendingWithdrawals)) + } + // Offset #43 'LatestExecutionPayloadBid' + offset43 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn14(ctx, t.LatestExecutionPayloadBid)) + } + // Offset #44 'PayloadExpectedWithdrawals' + offset44 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn15(ctx, t.PayloadExpectedWithdrawals)) + } + { // Field #45 'PTCWindow' + t := t.PTCWindow + vlen := len(t) + if vlen > int(ctx.exprs[8]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[8])), "PTCWindow") + } + for idx1 := range vlen { + t := t[idx1] + vlen := len(t) + if vlen > int(ctx.exprs[7]) { + return sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[7])), "PTCWindow[%d]", idx1) + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + if vlen < int(ctx.exprs[7]) { + enc.EncodeZeroPadding((int(ctx.exprs[7]) - vlen) * 8) + } + } + if vlen < int(ctx.exprs[8]) { + enc.EncodeZeroPadding((int(ctx.exprs[8]) - vlen) * 4096) + } + } + { // Dynamic Field #7 'HistoricalRoots' + if canSeek { + enc.EncodeOffsetAt(offset7, uint32(enc.GetPosition()-dstlen)) + } + t := t.HistoricalRoots + vlen := len(t) + if vlen > 16777216 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16777216), "HistoricalRoots") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:32]) + } + } + { // Dynamic Field #9 'ETH1DataVotes' + if canSeek { + enc.EncodeOffsetAt(offset9, uint32(enc.GetPosition()-dstlen)) + } + t := t.ETH1DataVotes + vlen := len(t) + if vlen > int(ctx.exprs[9]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[9])), "ETH1DataVotes") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(phase0.ETH1Data) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "ETH1DataVotes[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #11 'Validators' + if canSeek { + enc.EncodeOffsetAt(offset11, uint32(enc.GetPosition()-dstlen)) + } + t := t.Validators + vlen := len(t) + if vlen > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1099511627776), "Validators") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(phase0.Validator) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #12 'Balances' + if canSeek { + enc.EncodeOffsetAt(offset12, uint32(enc.GetPosition()-dstlen)) + } + t := t.Balances + vlen := len(t) + if vlen > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1099511627776), "Balances") + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + } + { // Dynamic Field #15 'PreviousEpochParticipation' + if canSeek { + enc.EncodeOffsetAt(offset15, uint32(enc.GetPosition()-dstlen)) + } + t := t.PreviousEpochParticipation + vlen := len(t) + if vlen > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1099511627776), "PreviousEpochParticipation") + } + for idx1 := range vlen { + enc.EncodeUint8(byte(t[idx1])) + } + } + { // Dynamic Field #16 'CurrentEpochParticipation' + if canSeek { + enc.EncodeOffsetAt(offset16, uint32(enc.GetPosition()-dstlen)) + } + t := t.CurrentEpochParticipation + vlen := len(t) + if vlen > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1099511627776), "CurrentEpochParticipation") + } + for idx1 := range vlen { + enc.EncodeUint8(byte(t[idx1])) + } + } + { // Dynamic Field #21 'InactivityScores' + if canSeek { + enc.EncodeOffsetAt(offset21, uint32(enc.GetPosition()-dstlen)) + } + t := t.InactivityScores + vlen := len(t) + if vlen > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1099511627776), "InactivityScores") + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + } + { // Dynamic Field #27 'HistoricalSummaries' + if canSeek { + enc.EncodeOffsetAt(offset27, uint32(enc.GetPosition()-dstlen)) + } + t := t.HistoricalSummaries + vlen := len(t) + if vlen > 16777216 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16777216), "HistoricalSummaries") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(capella.HistoricalSummary) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "HistoricalSummaries[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #34 'PendingDeposits' + if canSeek { + enc.EncodeOffsetAt(offset34, uint32(enc.GetPosition()-dstlen)) + } + t := t.PendingDeposits + vlen := len(t) + if vlen > int(ctx.exprs[10]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[10])), "PendingDeposits") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(electra.PendingDeposit) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "PendingDeposits[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #35 'PendingPartialWithdrawals' + if canSeek { + enc.EncodeOffsetAt(offset35, uint32(enc.GetPosition()-dstlen)) + } + t := t.PendingPartialWithdrawals + vlen := len(t) + if vlen > int(ctx.exprs[11]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[11])), "PendingPartialWithdrawals") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(electra.PendingPartialWithdrawal) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "PendingPartialWithdrawals[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #36 'PendingConsolidations' + if canSeek { + enc.EncodeOffsetAt(offset36, uint32(enc.GetPosition()-dstlen)) + } + t := t.PendingConsolidations + vlen := len(t) + if vlen > int(ctx.exprs[12]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[12])), "PendingConsolidations") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(electra.PendingConsolidation) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "PendingConsolidations[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #38 'Builders' + if canSeek { + enc.EncodeOffsetAt(offset38, uint32(enc.GetPosition()-dstlen)) + } + t := t.Builders + vlen := len(t) + if vlen > int(ctx.exprs[13]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[13])), "Builders") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(gloas.Builder) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "Builders[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #42 'BuilderPendingWithdrawals' + if canSeek { + enc.EncodeOffsetAt(offset42, uint32(enc.GetPosition()-dstlen)) + } + t := t.BuilderPendingWithdrawals + vlen := len(t) + if vlen > int(ctx.exprs[14]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[14])), "BuilderPendingWithdrawals") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(gloas.BuilderPendingWithdrawal) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "BuilderPendingWithdrawals[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #43 'LatestExecutionPayloadBid' + if canSeek { + enc.EncodeOffsetAt(offset43, uint32(enc.GetPosition()-dstlen)) + } + t := t.LatestExecutionPayloadBid + if t == nil { + t = new(ExecutionPayloadBid) + } + if viewFn := t.MarshalSSZDynView((*heze.ExecutionPayloadBid)(nil)); viewFn != nil { + if buf, err := viewFn(ds, enc.GetBuffer()); err != nil { + return err + } else { + enc.SetBuffer(buf) + } + } else { + return sszutils.ErrNotImplemented + } + } + { // Dynamic Field #44 'PayloadExpectedWithdrawals' + if canSeek { + enc.EncodeOffsetAt(offset44, uint32(enc.GetPosition()-dstlen)) + } + t := t.PayloadExpectedWithdrawals + vlen := len(t) + if vlen > int(ctx.exprs[15]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[15])), "PayloadExpectedWithdrawals") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(capella.Withdrawal) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "PayloadExpectedWithdrawals[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + return nil +} + func (t *BeaconState) UnmarshalSSZDynView(view any) func(ds sszutils.DynamicSpecs, buf []byte) error { switch view.(type) { case *phase0.BeaconState: - return t.unmarshalSSZView_BeaconState + return t.unmarshalSSZView_BeaconState + case *altair.BeaconState: + return t.unmarshalSSZView_BeaconState_0 + case *bellatrix.BeaconState: + return t.unmarshalSSZView_BeaconState_1 + case *capella.BeaconState: + return t.unmarshalSSZView_BeaconState_2 + case *deneb.BeaconState: + return t.unmarshalSSZView_BeaconState_3 + case *electra.BeaconState: + return t.unmarshalSSZView_BeaconState_4 + case *fulu.BeaconState: + return t.unmarshalSSZView_BeaconState_5 + case *gloas.BeaconState: + return t.unmarshalSSZView_BeaconState_6 + case *heze.BeaconState: + return t.unmarshalSSZView_BeaconState_7 + } + return nil +} +func (t *BeaconState) unmarshalSSZView_BeaconState(ds sszutils.DynamicSpecs, buf []byte) (err error) { + expr0, err := sszutils.ResolveSpecValueWithDefault(ds, "SLOTS_PER_HISTORICAL_ROOT", 8192) + if err != nil { + return err + } + expr1, err := sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_HISTORICAL_VECTOR", 65536) + if err != nil { + return err + } + expr2, err := sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_SLASHINGS_VECTOR", 8192) + if err != nil { + return err + } + expr3, err := sszutils.ResolveSpecValueWithDefault(ds, "HISTORICAL_ROOTS_LIMIT", 16777216) + if err != nil { + return err + } + expr4, err := sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_ETH1_VOTING_PERIOD*SLOTS_PER_EPOCH", 2048) + if err != nil { + return err + } + expr5, err := sszutils.ResolveSpecValueWithDefault(ds, "VALIDATOR_REGISTRY_LIMIT", 1099511627776) + if err != nil { + return err + } + expr6, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_ATTESTATIONS*SLOTS_PER_EPOCH", 4096) + if err != nil { + return err + } + size1 := 32 * int(expr0) + size2 := 32 * int(expr1) + size3 := 8 * int(expr2) + exproffset := 0 + totalSize := size1+size1+size2+size3+401 + buflen := len(buf) + if buflen < totalSize { + return sszutils.ErrFixedFieldsEOFFn(buflen, totalSize) + } + { // Field #0 'GenesisTime' (static) + buf := buf[0:8] + t.GenesisTime = binary.LittleEndian.Uint64(buf) + } + { // Field #1 'GenesisValidatorsRoot' (static) + buf := buf[8:40] + copy(t.GenesisValidatorsRoot[:], buf) + } + { // Field #2 'Slot' (static) + buf := buf[40:48] + t.Slot = phase0.Slot(binary.LittleEndian.Uint64(buf)) + } + { // Field #3 'Fork' (static) + buf := buf[48:64] + if t.Fork == nil { + t.Fork = new(phase0.Fork) + } + if err = t.Fork.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "Fork") + } + } + { // Field #4 'LatestBlockHeader' (static) + buf := buf[64:176] + if t.LatestBlockHeader == nil { + t.LatestBlockHeader = new(phase0.BeaconBlockHeader) + } + if err = t.LatestBlockHeader.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") + } + } + { // Field #5 'BlockRoots' (static) + buf := buf[176 : size1+176] + exproffset += int(size1) + val1 := t.BlockRoots + val1 = sszutils.ExpandSlice(val1, int(expr0)) + for idx1 := range int(expr0) { + buf := buf[32*idx1 : 32*(idx1+1)] + copy(val1[idx1][:], buf) + } + t.BlockRoots = val1 + } + { // Field #6 'StateRoots' (static) + buf := buf[exproffset+176 : exproffset+size1+176] + exproffset += int(size1) + val2 := t.StateRoots + val2 = sszutils.ExpandSlice(val2, int(expr0)) + for idx1 := range int(expr0) { + buf := buf[32*idx1 : 32*(idx1+1)] + copy(val2[idx1][:], buf) + } + t.StateRoots = val2 + } + // Field #7 'HistoricalRoots' (offset) + offset7 := int(binary.LittleEndian.Uint32(buf[exproffset+176 : exproffset+180])) + if offset7 != totalSize { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset7, totalSize), "HistoricalRoots:o") + } + { // Field #8 'ETH1Data' (static) + buf := buf[exproffset+180 : exproffset+252] + if t.ETH1Data == nil { + t.ETH1Data = new(phase0.ETH1Data) + } + if err = t.ETH1Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "ETH1Data") + } + } + // Field #9 'ETH1DataVotes' (offset) + offset9 := int(binary.LittleEndian.Uint32(buf[exproffset+252 : exproffset+256])) + if offset9 < offset7 || offset9 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset9, offset7, buflen), "ETH1DataVotes:o") + } + { // Field #10 'ETH1DepositIndex' (static) + buf := buf[exproffset+256 : exproffset+264] + t.ETH1DepositIndex = binary.LittleEndian.Uint64(buf) + } + // Field #11 'Validators' (offset) + offset11 := int(binary.LittleEndian.Uint32(buf[exproffset+264 : exproffset+268])) + if offset11 < offset9 || offset11 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset11, offset9, buflen), "Validators:o") + } + // Field #12 'Balances' (offset) + offset12 := int(binary.LittleEndian.Uint32(buf[exproffset+268 : exproffset+272])) + if offset12 < offset11 || offset12 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset12, offset11, buflen), "Balances:o") + } + { // Field #13 'RANDAOMixes' (static) + buf := buf[exproffset+272 : exproffset+size2+272] + exproffset += int(size2) + val3 := t.RANDAOMixes + val3 = sszutils.ExpandSlice(val3, int(expr1)) + for idx1 := range int(expr1) { + buf := buf[32*idx1 : 32*(idx1+1)] + copy(val3[idx1][:], buf) + } + t.RANDAOMixes = val3 + } + { // Field #14 'Slashings' (static) + buf := buf[exproffset+272 : exproffset+size3+272] + exproffset += int(size3) + val4 := t.Slashings + val4 = sszutils.ExpandSlice(val4, int(expr2)) + sszutils.UnmarshalUint64Slice(val4[:int(expr2)], buf) + t.Slashings = val4 + } + // Field #15 'PreviousEpochAttestations' (offset) + offset15 := int(binary.LittleEndian.Uint32(buf[exproffset+272 : exproffset+276])) + if offset15 < offset12 || offset15 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset15, offset12, buflen), "PreviousEpochAttestations:o") + } + // Field #16 'CurrentEpochAttestations' (offset) + offset16 := int(binary.LittleEndian.Uint32(buf[exproffset+276 : exproffset+280])) + if offset16 < offset15 || offset16 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset16, offset15, buflen), "CurrentEpochAttestations:o") + } + { // Field #17 'JustificationBits' (static) + buf := buf[exproffset+280 : exproffset+281] + t.JustificationBits = sszutils.ExpandSlice(t.JustificationBits, 1) + copy(t.JustificationBits[:], buf) + } + { // Field #18 'PreviousJustifiedCheckpoint' (static) + buf := buf[exproffset+281 : exproffset+321] + if t.PreviousJustifiedCheckpoint == nil { + t.PreviousJustifiedCheckpoint = new(phase0.Checkpoint) + } + if err = t.PreviousJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } + } + { // Field #19 'CurrentJustifiedCheckpoint' (static) + buf := buf[exproffset+321 : exproffset+361] + if t.CurrentJustifiedCheckpoint == nil { + t.CurrentJustifiedCheckpoint = new(phase0.Checkpoint) + } + if err = t.CurrentJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } + } + { // Field #20 'FinalizedCheckpoint' (static) + buf := buf[exproffset+361 : exproffset+401] + if t.FinalizedCheckpoint == nil { + t.FinalizedCheckpoint = new(phase0.Checkpoint) + } + if err = t.FinalizedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") + } + } + { // Field #7 'HistoricalRoots' (dynamic) + buf := buf[offset7:offset9] + val5 := t.HistoricalRoots + itemCount := len(buf) / 32 + if len(buf)%32 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 32), "HistoricalRoots") + } + if itemCount > int(expr3) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr3)), "HistoricalRoots") + } + val5 = sszutils.ExpandSlice(val5, itemCount) + for idx1 := range itemCount { + buf := buf[32*idx1 : 32*(idx1+1)] + copy(val5[idx1][:], buf) + } + t.HistoricalRoots = val5 + } + { // Field #9 'ETH1DataVotes' (dynamic) + buf := buf[offset9:offset11] + val6 := t.ETH1DataVotes + itemCount := len(buf) / 72 + if len(buf)%72 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 72), "ETH1DataVotes") + } + if itemCount > int(expr4) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr4)), "ETH1DataVotes") + } + val6 = sszutils.ExpandSlice(val6, itemCount) + for idx1 := range itemCount { + if val6[idx1] == nil { + val6[idx1] = new(phase0.ETH1Data) + } + buf := buf[72*idx1 : 72*(idx1+1)] + if err = val6[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "ETH1DataVotes[%d]", idx1) + } + } + t.ETH1DataVotes = val6 + } + { // Field #11 'Validators' (dynamic) + buf := buf[offset11:offset12] + val7 := t.Validators + itemCount := len(buf) / 121 + if len(buf)%121 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 121), "Validators") + } + if itemCount > int(expr5) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr5)), "Validators") + } + val7 = sszutils.ExpandSlice(val7, itemCount) + for idx1 := range itemCount { + if val7[idx1] == nil { + val7[idx1] = new(phase0.Validator) + } + buf := buf[121*idx1 : 121*(idx1+1)] + if err = val7[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } + } + t.Validators = val7 + } + { // Field #12 'Balances' (dynamic) + buf := buf[offset12:offset15] + val8 := t.Balances + itemCount := len(buf) / 8 + if len(buf)%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 8), "Balances") + } + if itemCount > int(expr5) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr5)), "Balances") + } + val8 = sszutils.ExpandSlice(val8, itemCount) + sszutils.UnmarshalUint64Slice(val8, buf) + t.Balances = val8 + } + { // Field #15 'PreviousEpochAttestations' (dynamic) + buf := buf[offset15:offset16] + val9 := t.PreviousEpochAttestations + startOffset := int(0) + if len(buf) != 0 { + if len(buf) < 4 { + return sszutils.ErrorWithPath(sszutils.ErrListOffsetsEOFFn(len(buf), 4), "PreviousEpochAttestations") + } + startOffset = int(binary.LittleEndian.Uint32(buf[0:4])) + } + itemCount := startOffset / 4 + if startOffset%4 != 0 || len(buf) < startOffset { + return sszutils.ErrorWithPath(sszutils.ErrInvalidListStartOffsetFn(startOffset, len(buf)), "PreviousEpochAttestations") + } + if itemCount > int(expr6) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "PreviousEpochAttestations") + } + val9 = sszutils.ExpandSlice(val9, itemCount) + for idx1 := range itemCount { + var endOffset int + if idx1 < itemCount-1 { + endOffset = int(binary.LittleEndian.Uint32(buf[(idx1+1)*4 : (idx1+2)*4])) + } else { + endOffset = len(buf) + } + if endOffset < startOffset || endOffset > len(buf) { + return sszutils.ErrorWithPathf(sszutils.ErrElementOffsetOutOfRangeFn(endOffset, startOffset, len(buf)), "PreviousEpochAttestations[%d]", idx1) + } + buf := buf[startOffset:endOffset] + startOffset = endOffset + val10 := val9[idx1] + if val10 == nil { + val10 = new(phase0.PendingAttestation) + } + if err = val10.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "PreviousEpochAttestations[%d]", idx1) + } + val9[idx1] = val10 + } + t.PreviousEpochAttestations = val9 + } + { // Field #16 'CurrentEpochAttestations' (dynamic) + buf := buf[offset16:] + val11 := t.CurrentEpochAttestations + startOffset := int(0) + if len(buf) != 0 { + if len(buf) < 4 { + return sszutils.ErrorWithPath(sszutils.ErrListOffsetsEOFFn(len(buf), 4), "CurrentEpochAttestations") + } + startOffset = int(binary.LittleEndian.Uint32(buf[0:4])) + } + itemCount := startOffset / 4 + if startOffset%4 != 0 || len(buf) < startOffset { + return sszutils.ErrorWithPath(sszutils.ErrInvalidListStartOffsetFn(startOffset, len(buf)), "CurrentEpochAttestations") + } + if itemCount > int(expr6) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "CurrentEpochAttestations") + } + val11 = sszutils.ExpandSlice(val11, itemCount) + for idx1 := range itemCount { + var endOffset int + if idx1 < itemCount-1 { + endOffset = int(binary.LittleEndian.Uint32(buf[(idx1+1)*4 : (idx1+2)*4])) + } else { + endOffset = len(buf) + } + if endOffset < startOffset || endOffset > len(buf) { + return sszutils.ErrorWithPathf(sszutils.ErrElementOffsetOutOfRangeFn(endOffset, startOffset, len(buf)), "CurrentEpochAttestations[%d]", idx1) + } + buf := buf[startOffset:endOffset] + startOffset = endOffset + val12 := val11[idx1] + if val12 == nil { + val12 = new(phase0.PendingAttestation) + } + if err = val12.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "CurrentEpochAttestations[%d]", idx1) + } + val11[idx1] = val12 + } + t.CurrentEpochAttestations = val11 + } + return nil +} + +func (t *BeaconState) unmarshalSSZView_BeaconState_0(ds sszutils.DynamicSpecs, buf []byte) (err error) { + expr0, err := sszutils.ResolveSpecValueWithDefault(ds, "SLOTS_PER_HISTORICAL_ROOT", 8192) + if err != nil { + return err + } + expr1, err := sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_HISTORICAL_VECTOR", 65536) + if err != nil { + return err + } + expr2, err := sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_SLASHINGS_VECTOR", 8192) + if err != nil { + return err + } + expr3, err := sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE", 512) + if err != nil { + return err + } + expr4, err := sszutils.ResolveSpecValueWithDefault(ds, "HISTORICAL_ROOTS_LIMIT", 16777216) + if err != nil { + return err + } + expr5, err := sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_ETH1_VOTING_PERIOD*SLOTS_PER_EPOCH", 2048) + if err != nil { + return err + } + expr6, err := sszutils.ResolveSpecValueWithDefault(ds, "VALIDATOR_REGISTRY_LIMIT", 1099511627776) + if err != nil { + return err + } + size1 := 32 * int(expr0) + size2 := 32 * int(expr1) + size3 := 8 * int(expr2) + size5 := 48 * int(expr3) + size4 := size5 + 48 // size expression for '*SyncCommittee' + exproffset := 0 + totalSize := size1+size1+size2+size3+size4+size4+405 + buflen := len(buf) + if buflen < totalSize { + return sszutils.ErrFixedFieldsEOFFn(buflen, totalSize) + } + { // Field #0 'GenesisTime' (static) + buf := buf[0:8] + t.GenesisTime = binary.LittleEndian.Uint64(buf) + } + { // Field #1 'GenesisValidatorsRoot' (static) + buf := buf[8:40] + copy(t.GenesisValidatorsRoot[:], buf) + } + { // Field #2 'Slot' (static) + buf := buf[40:48] + t.Slot = phase0.Slot(binary.LittleEndian.Uint64(buf)) + } + { // Field #3 'Fork' (static) + buf := buf[48:64] + if t.Fork == nil { + t.Fork = new(phase0.Fork) + } + if err = t.Fork.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "Fork") + } + } + { // Field #4 'LatestBlockHeader' (static) + buf := buf[64:176] + if t.LatestBlockHeader == nil { + t.LatestBlockHeader = new(phase0.BeaconBlockHeader) + } + if err = t.LatestBlockHeader.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") + } + } + { // Field #5 'BlockRoots' (static) + buf := buf[176 : size1+176] + exproffset += int(size1) + val1 := t.BlockRoots + val1 = sszutils.ExpandSlice(val1, int(expr0)) + for idx1 := range int(expr0) { + buf := buf[32*idx1 : 32*(idx1+1)] + copy(val1[idx1][:], buf) + } + t.BlockRoots = val1 + } + { // Field #6 'StateRoots' (static) + buf := buf[exproffset+176 : exproffset+size1+176] + exproffset += int(size1) + val2 := t.StateRoots + val2 = sszutils.ExpandSlice(val2, int(expr0)) + for idx1 := range int(expr0) { + buf := buf[32*idx1 : 32*(idx1+1)] + copy(val2[idx1][:], buf) + } + t.StateRoots = val2 + } + // Field #7 'HistoricalRoots' (offset) + offset7 := int(binary.LittleEndian.Uint32(buf[exproffset+176 : exproffset+180])) + if offset7 != totalSize { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset7, totalSize), "HistoricalRoots:o") + } + { // Field #8 'ETH1Data' (static) + buf := buf[exproffset+180 : exproffset+252] + if t.ETH1Data == nil { + t.ETH1Data = new(phase0.ETH1Data) + } + if err = t.ETH1Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "ETH1Data") + } + } + // Field #9 'ETH1DataVotes' (offset) + offset9 := int(binary.LittleEndian.Uint32(buf[exproffset+252 : exproffset+256])) + if offset9 < offset7 || offset9 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset9, offset7, buflen), "ETH1DataVotes:o") + } + { // Field #10 'ETH1DepositIndex' (static) + buf := buf[exproffset+256 : exproffset+264] + t.ETH1DepositIndex = binary.LittleEndian.Uint64(buf) + } + // Field #11 'Validators' (offset) + offset11 := int(binary.LittleEndian.Uint32(buf[exproffset+264 : exproffset+268])) + if offset11 < offset9 || offset11 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset11, offset9, buflen), "Validators:o") + } + // Field #12 'Balances' (offset) + offset12 := int(binary.LittleEndian.Uint32(buf[exproffset+268 : exproffset+272])) + if offset12 < offset11 || offset12 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset12, offset11, buflen), "Balances:o") + } + { // Field #13 'RANDAOMixes' (static) + buf := buf[exproffset+272 : exproffset+size2+272] + exproffset += int(size2) + val3 := t.RANDAOMixes + val3 = sszutils.ExpandSlice(val3, int(expr1)) + for idx1 := range int(expr1) { + buf := buf[32*idx1 : 32*(idx1+1)] + copy(val3[idx1][:], buf) + } + t.RANDAOMixes = val3 + } + { // Field #14 'Slashings' (static) + buf := buf[exproffset+272 : exproffset+size3+272] + exproffset += int(size3) + val4 := t.Slashings + val4 = sszutils.ExpandSlice(val4, int(expr2)) + sszutils.UnmarshalUint64Slice(val4[:int(expr2)], buf) + t.Slashings = val4 + } + // Field #15 'PreviousEpochParticipation' (offset) + offset15 := int(binary.LittleEndian.Uint32(buf[exproffset+272 : exproffset+276])) + if offset15 < offset12 || offset15 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset15, offset12, buflen), "PreviousEpochParticipation:o") + } + // Field #16 'CurrentEpochParticipation' (offset) + offset16 := int(binary.LittleEndian.Uint32(buf[exproffset+276 : exproffset+280])) + if offset16 < offset15 || offset16 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset16, offset15, buflen), "CurrentEpochParticipation:o") + } + { // Field #17 'JustificationBits' (static) + buf := buf[exproffset+280 : exproffset+281] + t.JustificationBits = sszutils.ExpandSlice(t.JustificationBits, 1) + copy(t.JustificationBits[:], buf) + } + { // Field #18 'PreviousJustifiedCheckpoint' (static) + buf := buf[exproffset+281 : exproffset+321] + if t.PreviousJustifiedCheckpoint == nil { + t.PreviousJustifiedCheckpoint = new(phase0.Checkpoint) + } + if err = t.PreviousJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } + } + { // Field #19 'CurrentJustifiedCheckpoint' (static) + buf := buf[exproffset+321 : exproffset+361] + if t.CurrentJustifiedCheckpoint == nil { + t.CurrentJustifiedCheckpoint = new(phase0.Checkpoint) + } + if err = t.CurrentJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } + } + { // Field #20 'FinalizedCheckpoint' (static) + buf := buf[exproffset+361 : exproffset+401] + if t.FinalizedCheckpoint == nil { + t.FinalizedCheckpoint = new(phase0.Checkpoint) + } + if err = t.FinalizedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") + } + } + // Field #21 'InactivityScores' (offset) + offset21 := int(binary.LittleEndian.Uint32(buf[exproffset+401 : exproffset+405])) + if offset21 < offset16 || offset21 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset21, offset16, buflen), "InactivityScores:o") + } + { // Field #22 'CurrentSyncCommittee' (static) + buf := buf[exproffset+405 : exproffset+size4+405] + exproffset += int(size4) + val5 := t.CurrentSyncCommittee + if val5 == nil { + val5 = new(altair.SyncCommittee) + } + exproffset := 0 + totalSize := size5+48 + buflen := len(buf) + if buflen < totalSize { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, totalSize), "CurrentSyncCommittee") + } + { // Field #0 'Pubkeys' (static) + buf := buf[0 : size5+0] + exproffset += int(size5) + val6 := val5.Pubkeys + val6 = sszutils.ExpandSlice(val6, int(expr3)) + for idx1 := range int(expr3) { + buf := buf[48*idx1 : 48*(idx1+1)] + copy(val6[idx1][:], buf) + } + val5.Pubkeys = val6 + } + { // Field #1 'AggregatePubkey' (static) + buf := buf[exproffset+0 : exproffset+48] + copy(val5.AggregatePubkey[:], buf) + } + t.CurrentSyncCommittee = val5 + } + { // Field #23 'NextSyncCommittee' (static) + buf := buf[exproffset+405 : exproffset+size4+405] + exproffset += int(size4) + val7 := t.NextSyncCommittee + if val7 == nil { + val7 = new(altair.SyncCommittee) + } + exproffset := 0 + totalSize := size5+48 + buflen := len(buf) + if buflen < totalSize { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, totalSize), "NextSyncCommittee") + } + { // Field #0 'Pubkeys' (static) + buf := buf[0 : size5+0] + exproffset += int(size5) + val8 := val7.Pubkeys + val8 = sszutils.ExpandSlice(val8, int(expr3)) + for idx1 := range int(expr3) { + buf := buf[48*idx1 : 48*(idx1+1)] + copy(val8[idx1][:], buf) + } + val7.Pubkeys = val8 + } + { // Field #1 'AggregatePubkey' (static) + buf := buf[exproffset+0 : exproffset+48] + copy(val7.AggregatePubkey[:], buf) + } + t.NextSyncCommittee = val7 + } + { // Field #7 'HistoricalRoots' (dynamic) + buf := buf[offset7:offset9] + val9 := t.HistoricalRoots + itemCount := len(buf) / 32 + if len(buf)%32 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 32), "HistoricalRoots") + } + if itemCount > int(expr4) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr4)), "HistoricalRoots") + } + val9 = sszutils.ExpandSlice(val9, itemCount) + for idx1 := range itemCount { + buf := buf[32*idx1 : 32*(idx1+1)] + copy(val9[idx1][:], buf) + } + t.HistoricalRoots = val9 + } + { // Field #9 'ETH1DataVotes' (dynamic) + buf := buf[offset9:offset11] + val10 := t.ETH1DataVotes + itemCount := len(buf) / 72 + if len(buf)%72 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 72), "ETH1DataVotes") + } + if itemCount > int(expr5) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr5)), "ETH1DataVotes") + } + val10 = sszutils.ExpandSlice(val10, itemCount) + for idx1 := range itemCount { + if val10[idx1] == nil { + val10[idx1] = new(phase0.ETH1Data) + } + buf := buf[72*idx1 : 72*(idx1+1)] + if err = val10[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "ETH1DataVotes[%d]", idx1) + } + } + t.ETH1DataVotes = val10 + } + { // Field #11 'Validators' (dynamic) + buf := buf[offset11:offset12] + val11 := t.Validators + itemCount := len(buf) / 121 + if len(buf)%121 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 121), "Validators") + } + if itemCount > int(expr6) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "Validators") + } + val11 = sszutils.ExpandSlice(val11, itemCount) + for idx1 := range itemCount { + if val11[idx1] == nil { + val11[idx1] = new(phase0.Validator) + } + buf := buf[121*idx1 : 121*(idx1+1)] + if err = val11[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } + } + t.Validators = val11 + } + { // Field #12 'Balances' (dynamic) + buf := buf[offset12:offset15] + val12 := t.Balances + itemCount := len(buf) / 8 + if len(buf)%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 8), "Balances") + } + if itemCount > int(expr6) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "Balances") + } + val12 = sszutils.ExpandSlice(val12, itemCount) + sszutils.UnmarshalUint64Slice(val12, buf) + t.Balances = val12 + } + { // Field #15 'PreviousEpochParticipation' (dynamic) + buf := buf[offset15:offset16] + val13 := t.PreviousEpochParticipation + itemCount := len(buf) + if itemCount > int(expr6) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "PreviousEpochParticipation") + } + val13 = sszutils.ExpandSlice(val13, itemCount) + for idx1 := range itemCount { + buf := buf[1*idx1 : 1*(idx1+1)] + val13[idx1] = altair.ParticipationFlags(buf[0]) + } + t.PreviousEpochParticipation = val13 + } + { // Field #16 'CurrentEpochParticipation' (dynamic) + buf := buf[offset16:offset21] + val14 := t.CurrentEpochParticipation + itemCount := len(buf) + if itemCount > int(expr6) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "CurrentEpochParticipation") + } + val14 = sszutils.ExpandSlice(val14, itemCount) + for idx1 := range itemCount { + buf := buf[1*idx1 : 1*(idx1+1)] + val14[idx1] = altair.ParticipationFlags(buf[0]) + } + t.CurrentEpochParticipation = val14 + } + { // Field #21 'InactivityScores' (dynamic) + buf := buf[offset21:] + val15 := t.InactivityScores + itemCount := len(buf) / 8 + if len(buf)%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 8), "InactivityScores") + } + if itemCount > int(expr6) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "InactivityScores") + } + val15 = sszutils.ExpandSlice(val15, itemCount) + sszutils.UnmarshalUint64Slice(val15, buf) + t.InactivityScores = val15 + } + return nil +} + +func (t *BeaconState) unmarshalSSZView_BeaconState_1(ds sszutils.DynamicSpecs, buf []byte) (err error) { + expr0, err := sszutils.ResolveSpecValueWithDefault(ds, "SLOTS_PER_HISTORICAL_ROOT", 8192) + if err != nil { + return err + } + expr1, err := sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_HISTORICAL_VECTOR", 65536) + if err != nil { + return err + } + expr2, err := sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_SLASHINGS_VECTOR", 8192) + if err != nil { + return err + } + expr3, err := sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE", 512) + if err != nil { + return err + } + expr4, err := sszutils.ResolveSpecValueWithDefault(ds, "HISTORICAL_ROOTS_LIMIT", 16777216) + if err != nil { + return err + } + expr5, err := sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_ETH1_VOTING_PERIOD*SLOTS_PER_EPOCH", 2048) + if err != nil { + return err + } + expr6, err := sszutils.ResolveSpecValueWithDefault(ds, "VALIDATOR_REGISTRY_LIMIT", 1099511627776) + if err != nil { + return err + } + size1 := 32 * int(expr0) + size2 := 32 * int(expr1) + size3 := 8 * int(expr2) + size5 := 48 * int(expr3) + size4 := size5 + 48 // size expression for '*SyncCommittee' + exproffset := 0 + totalSize := size1+size1+size2+size3+size4+size4+409 + buflen := len(buf) + if buflen < totalSize { + return sszutils.ErrFixedFieldsEOFFn(buflen, totalSize) + } + { // Field #0 'GenesisTime' (static) + buf := buf[0:8] + t.GenesisTime = binary.LittleEndian.Uint64(buf) + } + { // Field #1 'GenesisValidatorsRoot' (static) + buf := buf[8:40] + copy(t.GenesisValidatorsRoot[:], buf) + } + { // Field #2 'Slot' (static) + buf := buf[40:48] + t.Slot = phase0.Slot(binary.LittleEndian.Uint64(buf)) + } + { // Field #3 'Fork' (static) + buf := buf[48:64] + if t.Fork == nil { + t.Fork = new(phase0.Fork) + } + if err = t.Fork.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "Fork") + } + } + { // Field #4 'LatestBlockHeader' (static) + buf := buf[64:176] + if t.LatestBlockHeader == nil { + t.LatestBlockHeader = new(phase0.BeaconBlockHeader) + } + if err = t.LatestBlockHeader.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") + } + } + { // Field #5 'BlockRoots' (static) + buf := buf[176 : size1+176] + exproffset += int(size1) + val1 := t.BlockRoots + val1 = sszutils.ExpandSlice(val1, int(expr0)) + for idx1 := range int(expr0) { + buf := buf[32*idx1 : 32*(idx1+1)] + copy(val1[idx1][:], buf) + } + t.BlockRoots = val1 + } + { // Field #6 'StateRoots' (static) + buf := buf[exproffset+176 : exproffset+size1+176] + exproffset += int(size1) + val2 := t.StateRoots + val2 = sszutils.ExpandSlice(val2, int(expr0)) + for idx1 := range int(expr0) { + buf := buf[32*idx1 : 32*(idx1+1)] + copy(val2[idx1][:], buf) + } + t.StateRoots = val2 + } + // Field #7 'HistoricalRoots' (offset) + offset7 := int(binary.LittleEndian.Uint32(buf[exproffset+176 : exproffset+180])) + if offset7 != totalSize { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset7, totalSize), "HistoricalRoots:o") + } + { // Field #8 'ETH1Data' (static) + buf := buf[exproffset+180 : exproffset+252] + if t.ETH1Data == nil { + t.ETH1Data = new(phase0.ETH1Data) + } + if err = t.ETH1Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "ETH1Data") + } + } + // Field #9 'ETH1DataVotes' (offset) + offset9 := int(binary.LittleEndian.Uint32(buf[exproffset+252 : exproffset+256])) + if offset9 < offset7 || offset9 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset9, offset7, buflen), "ETH1DataVotes:o") + } + { // Field #10 'ETH1DepositIndex' (static) + buf := buf[exproffset+256 : exproffset+264] + t.ETH1DepositIndex = binary.LittleEndian.Uint64(buf) + } + // Field #11 'Validators' (offset) + offset11 := int(binary.LittleEndian.Uint32(buf[exproffset+264 : exproffset+268])) + if offset11 < offset9 || offset11 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset11, offset9, buflen), "Validators:o") + } + // Field #12 'Balances' (offset) + offset12 := int(binary.LittleEndian.Uint32(buf[exproffset+268 : exproffset+272])) + if offset12 < offset11 || offset12 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset12, offset11, buflen), "Balances:o") + } + { // Field #13 'RANDAOMixes' (static) + buf := buf[exproffset+272 : exproffset+size2+272] + exproffset += int(size2) + val3 := t.RANDAOMixes + val3 = sszutils.ExpandSlice(val3, int(expr1)) + for idx1 := range int(expr1) { + buf := buf[32*idx1 : 32*(idx1+1)] + copy(val3[idx1][:], buf) + } + t.RANDAOMixes = val3 + } + { // Field #14 'Slashings' (static) + buf := buf[exproffset+272 : exproffset+size3+272] + exproffset += int(size3) + val4 := t.Slashings + val4 = sszutils.ExpandSlice(val4, int(expr2)) + sszutils.UnmarshalUint64Slice(val4[:int(expr2)], buf) + t.Slashings = val4 + } + // Field #15 'PreviousEpochParticipation' (offset) + offset15 := int(binary.LittleEndian.Uint32(buf[exproffset+272 : exproffset+276])) + if offset15 < offset12 || offset15 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset15, offset12, buflen), "PreviousEpochParticipation:o") + } + // Field #16 'CurrentEpochParticipation' (offset) + offset16 := int(binary.LittleEndian.Uint32(buf[exproffset+276 : exproffset+280])) + if offset16 < offset15 || offset16 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset16, offset15, buflen), "CurrentEpochParticipation:o") + } + { // Field #17 'JustificationBits' (static) + buf := buf[exproffset+280 : exproffset+281] + t.JustificationBits = sszutils.ExpandSlice(t.JustificationBits, 1) + copy(t.JustificationBits[:], buf) + } + { // Field #18 'PreviousJustifiedCheckpoint' (static) + buf := buf[exproffset+281 : exproffset+321] + if t.PreviousJustifiedCheckpoint == nil { + t.PreviousJustifiedCheckpoint = new(phase0.Checkpoint) + } + if err = t.PreviousJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } + } + { // Field #19 'CurrentJustifiedCheckpoint' (static) + buf := buf[exproffset+321 : exproffset+361] + if t.CurrentJustifiedCheckpoint == nil { + t.CurrentJustifiedCheckpoint = new(phase0.Checkpoint) + } + if err = t.CurrentJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } + } + { // Field #20 'FinalizedCheckpoint' (static) + buf := buf[exproffset+361 : exproffset+401] + if t.FinalizedCheckpoint == nil { + t.FinalizedCheckpoint = new(phase0.Checkpoint) + } + if err = t.FinalizedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") + } + } + // Field #21 'InactivityScores' (offset) + offset21 := int(binary.LittleEndian.Uint32(buf[exproffset+401 : exproffset+405])) + if offset21 < offset16 || offset21 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset21, offset16, buflen), "InactivityScores:o") + } + { // Field #22 'CurrentSyncCommittee' (static) + buf := buf[exproffset+405 : exproffset+size4+405] + exproffset += int(size4) + val5 := t.CurrentSyncCommittee + if val5 == nil { + val5 = new(altair.SyncCommittee) + } + exproffset := 0 + totalSize := size5+48 + buflen := len(buf) + if buflen < totalSize { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, totalSize), "CurrentSyncCommittee") + } + { // Field #0 'Pubkeys' (static) + buf := buf[0 : size5+0] + exproffset += int(size5) + val6 := val5.Pubkeys + val6 = sszutils.ExpandSlice(val6, int(expr3)) + for idx1 := range int(expr3) { + buf := buf[48*idx1 : 48*(idx1+1)] + copy(val6[idx1][:], buf) + } + val5.Pubkeys = val6 + } + { // Field #1 'AggregatePubkey' (static) + buf := buf[exproffset+0 : exproffset+48] + copy(val5.AggregatePubkey[:], buf) + } + t.CurrentSyncCommittee = val5 + } + { // Field #23 'NextSyncCommittee' (static) + buf := buf[exproffset+405 : exproffset+size4+405] + exproffset += int(size4) + val7 := t.NextSyncCommittee + if val7 == nil { + val7 = new(altair.SyncCommittee) + } + exproffset := 0 + totalSize := size5+48 + buflen := len(buf) + if buflen < totalSize { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, totalSize), "NextSyncCommittee") + } + { // Field #0 'Pubkeys' (static) + buf := buf[0 : size5+0] + exproffset += int(size5) + val8 := val7.Pubkeys + val8 = sszutils.ExpandSlice(val8, int(expr3)) + for idx1 := range int(expr3) { + buf := buf[48*idx1 : 48*(idx1+1)] + copy(val8[idx1][:], buf) + } + val7.Pubkeys = val8 + } + { // Field #1 'AggregatePubkey' (static) + buf := buf[exproffset+0 : exproffset+48] + copy(val7.AggregatePubkey[:], buf) + } + t.NextSyncCommittee = val7 + } + // Field #24 'LatestExecutionPayloadHeader' (offset) + offset24 := int(binary.LittleEndian.Uint32(buf[exproffset+405 : exproffset+409])) + if offset24 < offset21 || offset24 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset24, offset21, buflen), "LatestExecutionPayloadHeader:o") + } + { // Field #7 'HistoricalRoots' (dynamic) + buf := buf[offset7:offset9] + val9 := t.HistoricalRoots + itemCount := len(buf) / 32 + if len(buf)%32 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 32), "HistoricalRoots") + } + if itemCount > int(expr4) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr4)), "HistoricalRoots") + } + val9 = sszutils.ExpandSlice(val9, itemCount) + for idx1 := range itemCount { + buf := buf[32*idx1 : 32*(idx1+1)] + copy(val9[idx1][:], buf) + } + t.HistoricalRoots = val9 + } + { // Field #9 'ETH1DataVotes' (dynamic) + buf := buf[offset9:offset11] + val10 := t.ETH1DataVotes + itemCount := len(buf) / 72 + if len(buf)%72 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 72), "ETH1DataVotes") + } + if itemCount > int(expr5) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr5)), "ETH1DataVotes") + } + val10 = sszutils.ExpandSlice(val10, itemCount) + for idx1 := range itemCount { + if val10[idx1] == nil { + val10[idx1] = new(phase0.ETH1Data) + } + buf := buf[72*idx1 : 72*(idx1+1)] + if err = val10[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "ETH1DataVotes[%d]", idx1) + } + } + t.ETH1DataVotes = val10 + } + { // Field #11 'Validators' (dynamic) + buf := buf[offset11:offset12] + val11 := t.Validators + itemCount := len(buf) / 121 + if len(buf)%121 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 121), "Validators") + } + if itemCount > int(expr6) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "Validators") + } + val11 = sszutils.ExpandSlice(val11, itemCount) + for idx1 := range itemCount { + if val11[idx1] == nil { + val11[idx1] = new(phase0.Validator) + } + buf := buf[121*idx1 : 121*(idx1+1)] + if err = val11[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } + } + t.Validators = val11 + } + { // Field #12 'Balances' (dynamic) + buf := buf[offset12:offset15] + val12 := t.Balances + itemCount := len(buf) / 8 + if len(buf)%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 8), "Balances") + } + if itemCount > int(expr6) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "Balances") + } + val12 = sszutils.ExpandSlice(val12, itemCount) + sszutils.UnmarshalUint64Slice(val12, buf) + t.Balances = val12 + } + { // Field #15 'PreviousEpochParticipation' (dynamic) + buf := buf[offset15:offset16] + val13 := t.PreviousEpochParticipation + itemCount := len(buf) + if itemCount > int(expr6) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "PreviousEpochParticipation") + } + val13 = sszutils.ExpandSlice(val13, itemCount) + for idx1 := range itemCount { + buf := buf[1*idx1 : 1*(idx1+1)] + val13[idx1] = altair.ParticipationFlags(buf[0]) + } + t.PreviousEpochParticipation = val13 + } + { // Field #16 'CurrentEpochParticipation' (dynamic) + buf := buf[offset16:offset21] + val14 := t.CurrentEpochParticipation + itemCount := len(buf) + if itemCount > int(expr6) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "CurrentEpochParticipation") + } + val14 = sszutils.ExpandSlice(val14, itemCount) + for idx1 := range itemCount { + buf := buf[1*idx1 : 1*(idx1+1)] + val14[idx1] = altair.ParticipationFlags(buf[0]) + } + t.CurrentEpochParticipation = val14 + } + { // Field #21 'InactivityScores' (dynamic) + buf := buf[offset21:offset24] + val15 := t.InactivityScores + itemCount := len(buf) / 8 + if len(buf)%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 8), "InactivityScores") + } + if itemCount > int(expr6) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "InactivityScores") + } + val15 = sszutils.ExpandSlice(val15, itemCount) + sszutils.UnmarshalUint64Slice(val15, buf) + t.InactivityScores = val15 + } + { // Field #24 'LatestExecutionPayloadHeader' (dynamic) + buf := buf[offset24:] + if t.LatestExecutionPayloadHeader == nil { + t.LatestExecutionPayloadHeader = new(ExecutionPayloadHeader) + } + if viewFn := t.LatestExecutionPayloadHeader.UnmarshalSSZDynView((*bellatrix.ExecutionPayloadHeader)(nil)); viewFn != nil { + if err = viewFn(ds, buf); err != nil { + return err + } + } else { + return sszutils.ErrNotImplemented + } + } + return nil +} + +func (t *BeaconState) unmarshalSSZView_BeaconState_2(ds sszutils.DynamicSpecs, buf []byte) (err error) { + expr0, err := sszutils.ResolveSpecValueWithDefault(ds, "SLOTS_PER_HISTORICAL_ROOT", 8192) + if err != nil { + return err + } + expr1, err := sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_HISTORICAL_VECTOR", 65536) + if err != nil { + return err + } + expr2, err := sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_SLASHINGS_VECTOR", 8192) + if err != nil { + return err + } + expr3, err := sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE", 512) + if err != nil { + return err + } + expr4, err := sszutils.ResolveSpecValueWithDefault(ds, "HISTORICAL_ROOTS_LIMIT", 16777216) + if err != nil { + return err + } + expr5, err := sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_ETH1_VOTING_PERIOD*SLOTS_PER_EPOCH", 2048) + if err != nil { + return err + } + expr6, err := sszutils.ResolveSpecValueWithDefault(ds, "VALIDATOR_REGISTRY_LIMIT", 1099511627776) + if err != nil { + return err + } + size1 := 32 * int(expr0) + size2 := 32 * int(expr1) + size3 := 8 * int(expr2) + size5 := 48 * int(expr3) + size4 := size5 + 48 // size expression for '*SyncCommittee' + exproffset := 0 + totalSize := size1+size1+size2+size3+size4+size4+429 + buflen := len(buf) + if buflen < totalSize { + return sszutils.ErrFixedFieldsEOFFn(buflen, totalSize) + } + { // Field #0 'GenesisTime' (static) + buf := buf[0:8] + t.GenesisTime = binary.LittleEndian.Uint64(buf) + } + { // Field #1 'GenesisValidatorsRoot' (static) + buf := buf[8:40] + copy(t.GenesisValidatorsRoot[:], buf) + } + { // Field #2 'Slot' (static) + buf := buf[40:48] + t.Slot = phase0.Slot(binary.LittleEndian.Uint64(buf)) + } + { // Field #3 'Fork' (static) + buf := buf[48:64] + if t.Fork == nil { + t.Fork = new(phase0.Fork) + } + if err = t.Fork.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "Fork") + } + } + { // Field #4 'LatestBlockHeader' (static) + buf := buf[64:176] + if t.LatestBlockHeader == nil { + t.LatestBlockHeader = new(phase0.BeaconBlockHeader) + } + if err = t.LatestBlockHeader.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") + } + } + { // Field #5 'BlockRoots' (static) + buf := buf[176 : size1+176] + exproffset += int(size1) + val1 := t.BlockRoots + val1 = sszutils.ExpandSlice(val1, int(expr0)) + for idx1 := range int(expr0) { + buf := buf[32*idx1 : 32*(idx1+1)] + copy(val1[idx1][:], buf) + } + t.BlockRoots = val1 + } + { // Field #6 'StateRoots' (static) + buf := buf[exproffset+176 : exproffset+size1+176] + exproffset += int(size1) + val2 := t.StateRoots + val2 = sszutils.ExpandSlice(val2, int(expr0)) + for idx1 := range int(expr0) { + buf := buf[32*idx1 : 32*(idx1+1)] + copy(val2[idx1][:], buf) + } + t.StateRoots = val2 + } + // Field #7 'HistoricalRoots' (offset) + offset7 := int(binary.LittleEndian.Uint32(buf[exproffset+176 : exproffset+180])) + if offset7 != totalSize { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset7, totalSize), "HistoricalRoots:o") + } + { // Field #8 'ETH1Data' (static) + buf := buf[exproffset+180 : exproffset+252] + if t.ETH1Data == nil { + t.ETH1Data = new(phase0.ETH1Data) + } + if err = t.ETH1Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "ETH1Data") + } + } + // Field #9 'ETH1DataVotes' (offset) + offset9 := int(binary.LittleEndian.Uint32(buf[exproffset+252 : exproffset+256])) + if offset9 < offset7 || offset9 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset9, offset7, buflen), "ETH1DataVotes:o") + } + { // Field #10 'ETH1DepositIndex' (static) + buf := buf[exproffset+256 : exproffset+264] + t.ETH1DepositIndex = binary.LittleEndian.Uint64(buf) + } + // Field #11 'Validators' (offset) + offset11 := int(binary.LittleEndian.Uint32(buf[exproffset+264 : exproffset+268])) + if offset11 < offset9 || offset11 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset11, offset9, buflen), "Validators:o") + } + // Field #12 'Balances' (offset) + offset12 := int(binary.LittleEndian.Uint32(buf[exproffset+268 : exproffset+272])) + if offset12 < offset11 || offset12 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset12, offset11, buflen), "Balances:o") + } + { // Field #13 'RANDAOMixes' (static) + buf := buf[exproffset+272 : exproffset+size2+272] + exproffset += int(size2) + val3 := t.RANDAOMixes + val3 = sszutils.ExpandSlice(val3, int(expr1)) + for idx1 := range int(expr1) { + buf := buf[32*idx1 : 32*(idx1+1)] + copy(val3[idx1][:], buf) + } + t.RANDAOMixes = val3 + } + { // Field #14 'Slashings' (static) + buf := buf[exproffset+272 : exproffset+size3+272] + exproffset += int(size3) + val4 := t.Slashings + val4 = sszutils.ExpandSlice(val4, int(expr2)) + sszutils.UnmarshalUint64Slice(val4[:int(expr2)], buf) + t.Slashings = val4 + } + // Field #15 'PreviousEpochParticipation' (offset) + offset15 := int(binary.LittleEndian.Uint32(buf[exproffset+272 : exproffset+276])) + if offset15 < offset12 || offset15 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset15, offset12, buflen), "PreviousEpochParticipation:o") + } + // Field #16 'CurrentEpochParticipation' (offset) + offset16 := int(binary.LittleEndian.Uint32(buf[exproffset+276 : exproffset+280])) + if offset16 < offset15 || offset16 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset16, offset15, buflen), "CurrentEpochParticipation:o") + } + { // Field #17 'JustificationBits' (static) + buf := buf[exproffset+280 : exproffset+281] + t.JustificationBits = sszutils.ExpandSlice(t.JustificationBits, 1) + copy(t.JustificationBits[:], buf) + } + { // Field #18 'PreviousJustifiedCheckpoint' (static) + buf := buf[exproffset+281 : exproffset+321] + if t.PreviousJustifiedCheckpoint == nil { + t.PreviousJustifiedCheckpoint = new(phase0.Checkpoint) + } + if err = t.PreviousJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } + } + { // Field #19 'CurrentJustifiedCheckpoint' (static) + buf := buf[exproffset+321 : exproffset+361] + if t.CurrentJustifiedCheckpoint == nil { + t.CurrentJustifiedCheckpoint = new(phase0.Checkpoint) + } + if err = t.CurrentJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } + } + { // Field #20 'FinalizedCheckpoint' (static) + buf := buf[exproffset+361 : exproffset+401] + if t.FinalizedCheckpoint == nil { + t.FinalizedCheckpoint = new(phase0.Checkpoint) + } + if err = t.FinalizedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") + } + } + // Field #21 'InactivityScores' (offset) + offset21 := int(binary.LittleEndian.Uint32(buf[exproffset+401 : exproffset+405])) + if offset21 < offset16 || offset21 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset21, offset16, buflen), "InactivityScores:o") + } + { // Field #22 'CurrentSyncCommittee' (static) + buf := buf[exproffset+405 : exproffset+size4+405] + exproffset += int(size4) + val5 := t.CurrentSyncCommittee + if val5 == nil { + val5 = new(altair.SyncCommittee) + } + exproffset := 0 + totalSize := size5+48 + buflen := len(buf) + if buflen < totalSize { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, totalSize), "CurrentSyncCommittee") + } + { // Field #0 'Pubkeys' (static) + buf := buf[0 : size5+0] + exproffset += int(size5) + val6 := val5.Pubkeys + val6 = sszutils.ExpandSlice(val6, int(expr3)) + for idx1 := range int(expr3) { + buf := buf[48*idx1 : 48*(idx1+1)] + copy(val6[idx1][:], buf) + } + val5.Pubkeys = val6 + } + { // Field #1 'AggregatePubkey' (static) + buf := buf[exproffset+0 : exproffset+48] + copy(val5.AggregatePubkey[:], buf) + } + t.CurrentSyncCommittee = val5 + } + { // Field #23 'NextSyncCommittee' (static) + buf := buf[exproffset+405 : exproffset+size4+405] + exproffset += int(size4) + val7 := t.NextSyncCommittee + if val7 == nil { + val7 = new(altair.SyncCommittee) + } + exproffset := 0 + totalSize := size5+48 + buflen := len(buf) + if buflen < totalSize { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, totalSize), "NextSyncCommittee") + } + { // Field #0 'Pubkeys' (static) + buf := buf[0 : size5+0] + exproffset += int(size5) + val8 := val7.Pubkeys + val8 = sszutils.ExpandSlice(val8, int(expr3)) + for idx1 := range int(expr3) { + buf := buf[48*idx1 : 48*(idx1+1)] + copy(val8[idx1][:], buf) + } + val7.Pubkeys = val8 + } + { // Field #1 'AggregatePubkey' (static) + buf := buf[exproffset+0 : exproffset+48] + copy(val7.AggregatePubkey[:], buf) + } + t.NextSyncCommittee = val7 + } + // Field #24 'LatestExecutionPayloadHeader' (offset) + offset24 := int(binary.LittleEndian.Uint32(buf[exproffset+405 : exproffset+409])) + if offset24 < offset21 || offset24 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset24, offset21, buflen), "LatestExecutionPayloadHeader:o") + } + { // Field #25 'NextWithdrawalIndex' (static) + buf := buf[exproffset+409 : exproffset+417] + t.NextWithdrawalIndex = capella.WithdrawalIndex(binary.LittleEndian.Uint64(buf)) + } + { // Field #26 'NextWithdrawalValidatorIndex' (static) + buf := buf[exproffset+417 : exproffset+425] + t.NextWithdrawalValidatorIndex = phase0.ValidatorIndex(binary.LittleEndian.Uint64(buf)) + } + // Field #27 'HistoricalSummaries' (offset) + offset27 := int(binary.LittleEndian.Uint32(buf[exproffset+425 : exproffset+429])) + if offset27 < offset24 || offset27 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset27, offset24, buflen), "HistoricalSummaries:o") + } + { // Field #7 'HistoricalRoots' (dynamic) + buf := buf[offset7:offset9] + val9 := t.HistoricalRoots + itemCount := len(buf) / 32 + if len(buf)%32 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 32), "HistoricalRoots") + } + if itemCount > int(expr4) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr4)), "HistoricalRoots") + } + val9 = sszutils.ExpandSlice(val9, itemCount) + for idx1 := range itemCount { + buf := buf[32*idx1 : 32*(idx1+1)] + copy(val9[idx1][:], buf) + } + t.HistoricalRoots = val9 + } + { // Field #9 'ETH1DataVotes' (dynamic) + buf := buf[offset9:offset11] + val10 := t.ETH1DataVotes + itemCount := len(buf) / 72 + if len(buf)%72 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 72), "ETH1DataVotes") + } + if itemCount > int(expr5) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr5)), "ETH1DataVotes") + } + val10 = sszutils.ExpandSlice(val10, itemCount) + for idx1 := range itemCount { + if val10[idx1] == nil { + val10[idx1] = new(phase0.ETH1Data) + } + buf := buf[72*idx1 : 72*(idx1+1)] + if err = val10[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "ETH1DataVotes[%d]", idx1) + } + } + t.ETH1DataVotes = val10 + } + { // Field #11 'Validators' (dynamic) + buf := buf[offset11:offset12] + val11 := t.Validators + itemCount := len(buf) / 121 + if len(buf)%121 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 121), "Validators") + } + if itemCount > int(expr6) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "Validators") + } + val11 = sszutils.ExpandSlice(val11, itemCount) + for idx1 := range itemCount { + if val11[idx1] == nil { + val11[idx1] = new(phase0.Validator) + } + buf := buf[121*idx1 : 121*(idx1+1)] + if err = val11[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } + } + t.Validators = val11 + } + { // Field #12 'Balances' (dynamic) + buf := buf[offset12:offset15] + val12 := t.Balances + itemCount := len(buf) / 8 + if len(buf)%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 8), "Balances") + } + if itemCount > int(expr6) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "Balances") + } + val12 = sszutils.ExpandSlice(val12, itemCount) + sszutils.UnmarshalUint64Slice(val12, buf) + t.Balances = val12 + } + { // Field #15 'PreviousEpochParticipation' (dynamic) + buf := buf[offset15:offset16] + val13 := t.PreviousEpochParticipation + itemCount := len(buf) + if itemCount > int(expr6) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "PreviousEpochParticipation") + } + val13 = sszutils.ExpandSlice(val13, itemCount) + for idx1 := range itemCount { + buf := buf[1*idx1 : 1*(idx1+1)] + val13[idx1] = altair.ParticipationFlags(buf[0]) + } + t.PreviousEpochParticipation = val13 + } + { // Field #16 'CurrentEpochParticipation' (dynamic) + buf := buf[offset16:offset21] + val14 := t.CurrentEpochParticipation + itemCount := len(buf) + if itemCount > int(expr6) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "CurrentEpochParticipation") + } + val14 = sszutils.ExpandSlice(val14, itemCount) + for idx1 := range itemCount { + buf := buf[1*idx1 : 1*(idx1+1)] + val14[idx1] = altair.ParticipationFlags(buf[0]) + } + t.CurrentEpochParticipation = val14 + } + { // Field #21 'InactivityScores' (dynamic) + buf := buf[offset21:offset24] + val15 := t.InactivityScores + itemCount := len(buf) / 8 + if len(buf)%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 8), "InactivityScores") + } + if itemCount > int(expr6) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "InactivityScores") + } + val15 = sszutils.ExpandSlice(val15, itemCount) + sszutils.UnmarshalUint64Slice(val15, buf) + t.InactivityScores = val15 + } + { // Field #24 'LatestExecutionPayloadHeader' (dynamic) + buf := buf[offset24:offset27] + if t.LatestExecutionPayloadHeader == nil { + t.LatestExecutionPayloadHeader = new(ExecutionPayloadHeader) + } + if viewFn := t.LatestExecutionPayloadHeader.UnmarshalSSZDynView((*capella.ExecutionPayloadHeader)(nil)); viewFn != nil { + if err = viewFn(ds, buf); err != nil { + return err + } + } else { + return sszutils.ErrNotImplemented + } + } + { // Field #27 'HistoricalSummaries' (dynamic) + buf := buf[offset27:] + val16 := t.HistoricalSummaries + itemCount := len(buf) / 64 + if len(buf)%64 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 64), "HistoricalSummaries") + } + if itemCount > int(expr4) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr4)), "HistoricalSummaries") + } + val16 = sszutils.ExpandSlice(val16, itemCount) + for idx1 := range itemCount { + if val16[idx1] == nil { + val16[idx1] = new(capella.HistoricalSummary) + } + buf := buf[64*idx1 : 64*(idx1+1)] + if err = val16[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "HistoricalSummaries[%d]", idx1) + } + } + t.HistoricalSummaries = val16 + } + return nil +} + +func (t *BeaconState) unmarshalSSZView_BeaconState_3(ds sszutils.DynamicSpecs, buf []byte) (err error) { + expr0, err := sszutils.ResolveSpecValueWithDefault(ds, "SLOTS_PER_HISTORICAL_ROOT", 8192) + if err != nil { + return err + } + expr1, err := sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_HISTORICAL_VECTOR", 65536) + if err != nil { + return err + } + expr2, err := sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_SLASHINGS_VECTOR", 8192) + if err != nil { + return err + } + expr3, err := sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE", 512) + if err != nil { + return err + } + expr4, err := sszutils.ResolveSpecValueWithDefault(ds, "HISTORICAL_ROOTS_LIMIT", 16777216) + if err != nil { + return err + } + expr5, err := sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_ETH1_VOTING_PERIOD*SLOTS_PER_EPOCH", 2048) + if err != nil { + return err + } + expr6, err := sszutils.ResolveSpecValueWithDefault(ds, "VALIDATOR_REGISTRY_LIMIT", 1099511627776) + if err != nil { + return err + } + size1 := 32 * int(expr0) + size2 := 32 * int(expr1) + size3 := 8 * int(expr2) + size5 := 48 * int(expr3) + size4 := size5 + 48 // size expression for '*SyncCommittee' + exproffset := 0 + totalSize := size1+size1+size2+size3+size4+size4+429 + buflen := len(buf) + if buflen < totalSize { + return sszutils.ErrFixedFieldsEOFFn(buflen, totalSize) + } + { // Field #0 'GenesisTime' (static) + buf := buf[0:8] + t.GenesisTime = binary.LittleEndian.Uint64(buf) + } + { // Field #1 'GenesisValidatorsRoot' (static) + buf := buf[8:40] + copy(t.GenesisValidatorsRoot[:], buf) + } + { // Field #2 'Slot' (static) + buf := buf[40:48] + t.Slot = phase0.Slot(binary.LittleEndian.Uint64(buf)) + } + { // Field #3 'Fork' (static) + buf := buf[48:64] + if t.Fork == nil { + t.Fork = new(phase0.Fork) + } + if err = t.Fork.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "Fork") + } + } + { // Field #4 'LatestBlockHeader' (static) + buf := buf[64:176] + if t.LatestBlockHeader == nil { + t.LatestBlockHeader = new(phase0.BeaconBlockHeader) + } + if err = t.LatestBlockHeader.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") + } + } + { // Field #5 'BlockRoots' (static) + buf := buf[176 : size1+176] + exproffset += int(size1) + val1 := t.BlockRoots + val1 = sszutils.ExpandSlice(val1, int(expr0)) + for idx1 := range int(expr0) { + buf := buf[32*idx1 : 32*(idx1+1)] + copy(val1[idx1][:], buf) + } + t.BlockRoots = val1 + } + { // Field #6 'StateRoots' (static) + buf := buf[exproffset+176 : exproffset+size1+176] + exproffset += int(size1) + val2 := t.StateRoots + val2 = sszutils.ExpandSlice(val2, int(expr0)) + for idx1 := range int(expr0) { + buf := buf[32*idx1 : 32*(idx1+1)] + copy(val2[idx1][:], buf) + } + t.StateRoots = val2 + } + // Field #7 'HistoricalRoots' (offset) + offset7 := int(binary.LittleEndian.Uint32(buf[exproffset+176 : exproffset+180])) + if offset7 != totalSize { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset7, totalSize), "HistoricalRoots:o") + } + { // Field #8 'ETH1Data' (static) + buf := buf[exproffset+180 : exproffset+252] + if t.ETH1Data == nil { + t.ETH1Data = new(phase0.ETH1Data) + } + if err = t.ETH1Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "ETH1Data") + } + } + // Field #9 'ETH1DataVotes' (offset) + offset9 := int(binary.LittleEndian.Uint32(buf[exproffset+252 : exproffset+256])) + if offset9 < offset7 || offset9 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset9, offset7, buflen), "ETH1DataVotes:o") + } + { // Field #10 'ETH1DepositIndex' (static) + buf := buf[exproffset+256 : exproffset+264] + t.ETH1DepositIndex = binary.LittleEndian.Uint64(buf) + } + // Field #11 'Validators' (offset) + offset11 := int(binary.LittleEndian.Uint32(buf[exproffset+264 : exproffset+268])) + if offset11 < offset9 || offset11 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset11, offset9, buflen), "Validators:o") + } + // Field #12 'Balances' (offset) + offset12 := int(binary.LittleEndian.Uint32(buf[exproffset+268 : exproffset+272])) + if offset12 < offset11 || offset12 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset12, offset11, buflen), "Balances:o") + } + { // Field #13 'RANDAOMixes' (static) + buf := buf[exproffset+272 : exproffset+size2+272] + exproffset += int(size2) + val3 := t.RANDAOMixes + val3 = sszutils.ExpandSlice(val3, int(expr1)) + for idx1 := range int(expr1) { + buf := buf[32*idx1 : 32*(idx1+1)] + copy(val3[idx1][:], buf) + } + t.RANDAOMixes = val3 + } + { // Field #14 'Slashings' (static) + buf := buf[exproffset+272 : exproffset+size3+272] + exproffset += int(size3) + val4 := t.Slashings + val4 = sszutils.ExpandSlice(val4, int(expr2)) + sszutils.UnmarshalUint64Slice(val4[:int(expr2)], buf) + t.Slashings = val4 + } + // Field #15 'PreviousEpochParticipation' (offset) + offset15 := int(binary.LittleEndian.Uint32(buf[exproffset+272 : exproffset+276])) + if offset15 < offset12 || offset15 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset15, offset12, buflen), "PreviousEpochParticipation:o") + } + // Field #16 'CurrentEpochParticipation' (offset) + offset16 := int(binary.LittleEndian.Uint32(buf[exproffset+276 : exproffset+280])) + if offset16 < offset15 || offset16 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset16, offset15, buflen), "CurrentEpochParticipation:o") + } + { // Field #17 'JustificationBits' (static) + buf := buf[exproffset+280 : exproffset+281] + t.JustificationBits = sszutils.ExpandSlice(t.JustificationBits, 1) + copy(t.JustificationBits[:], buf) + } + { // Field #18 'PreviousJustifiedCheckpoint' (static) + buf := buf[exproffset+281 : exproffset+321] + if t.PreviousJustifiedCheckpoint == nil { + t.PreviousJustifiedCheckpoint = new(phase0.Checkpoint) + } + if err = t.PreviousJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } + } + { // Field #19 'CurrentJustifiedCheckpoint' (static) + buf := buf[exproffset+321 : exproffset+361] + if t.CurrentJustifiedCheckpoint == nil { + t.CurrentJustifiedCheckpoint = new(phase0.Checkpoint) + } + if err = t.CurrentJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } + } + { // Field #20 'FinalizedCheckpoint' (static) + buf := buf[exproffset+361 : exproffset+401] + if t.FinalizedCheckpoint == nil { + t.FinalizedCheckpoint = new(phase0.Checkpoint) + } + if err = t.FinalizedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") + } + } + // Field #21 'InactivityScores' (offset) + offset21 := int(binary.LittleEndian.Uint32(buf[exproffset+401 : exproffset+405])) + if offset21 < offset16 || offset21 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset21, offset16, buflen), "InactivityScores:o") + } + { // Field #22 'CurrentSyncCommittee' (static) + buf := buf[exproffset+405 : exproffset+size4+405] + exproffset += int(size4) + val5 := t.CurrentSyncCommittee + if val5 == nil { + val5 = new(altair.SyncCommittee) + } + exproffset := 0 + totalSize := size5+48 + buflen := len(buf) + if buflen < totalSize { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, totalSize), "CurrentSyncCommittee") + } + { // Field #0 'Pubkeys' (static) + buf := buf[0 : size5+0] + exproffset += int(size5) + val6 := val5.Pubkeys + val6 = sszutils.ExpandSlice(val6, int(expr3)) + for idx1 := range int(expr3) { + buf := buf[48*idx1 : 48*(idx1+1)] + copy(val6[idx1][:], buf) + } + val5.Pubkeys = val6 + } + { // Field #1 'AggregatePubkey' (static) + buf := buf[exproffset+0 : exproffset+48] + copy(val5.AggregatePubkey[:], buf) + } + t.CurrentSyncCommittee = val5 + } + { // Field #23 'NextSyncCommittee' (static) + buf := buf[exproffset+405 : exproffset+size4+405] + exproffset += int(size4) + val7 := t.NextSyncCommittee + if val7 == nil { + val7 = new(altair.SyncCommittee) + } + exproffset := 0 + totalSize := size5+48 + buflen := len(buf) + if buflen < totalSize { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, totalSize), "NextSyncCommittee") + } + { // Field #0 'Pubkeys' (static) + buf := buf[0 : size5+0] + exproffset += int(size5) + val8 := val7.Pubkeys + val8 = sszutils.ExpandSlice(val8, int(expr3)) + for idx1 := range int(expr3) { + buf := buf[48*idx1 : 48*(idx1+1)] + copy(val8[idx1][:], buf) + } + val7.Pubkeys = val8 + } + { // Field #1 'AggregatePubkey' (static) + buf := buf[exproffset+0 : exproffset+48] + copy(val7.AggregatePubkey[:], buf) + } + t.NextSyncCommittee = val7 + } + // Field #24 'LatestExecutionPayloadHeader' (offset) + offset24 := int(binary.LittleEndian.Uint32(buf[exproffset+405 : exproffset+409])) + if offset24 < offset21 || offset24 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset24, offset21, buflen), "LatestExecutionPayloadHeader:o") + } + { // Field #25 'NextWithdrawalIndex' (static) + buf := buf[exproffset+409 : exproffset+417] + t.NextWithdrawalIndex = capella.WithdrawalIndex(binary.LittleEndian.Uint64(buf)) + } + { // Field #26 'NextWithdrawalValidatorIndex' (static) + buf := buf[exproffset+417 : exproffset+425] + t.NextWithdrawalValidatorIndex = phase0.ValidatorIndex(binary.LittleEndian.Uint64(buf)) + } + // Field #27 'HistoricalSummaries' (offset) + offset27 := int(binary.LittleEndian.Uint32(buf[exproffset+425 : exproffset+429])) + if offset27 < offset24 || offset27 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset27, offset24, buflen), "HistoricalSummaries:o") + } + { // Field #7 'HistoricalRoots' (dynamic) + buf := buf[offset7:offset9] + val9 := t.HistoricalRoots + itemCount := len(buf) / 32 + if len(buf)%32 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 32), "HistoricalRoots") + } + if itemCount > int(expr4) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr4)), "HistoricalRoots") + } + val9 = sszutils.ExpandSlice(val9, itemCount) + for idx1 := range itemCount { + buf := buf[32*idx1 : 32*(idx1+1)] + copy(val9[idx1][:], buf) + } + t.HistoricalRoots = val9 + } + { // Field #9 'ETH1DataVotes' (dynamic) + buf := buf[offset9:offset11] + val10 := t.ETH1DataVotes + itemCount := len(buf) / 72 + if len(buf)%72 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 72), "ETH1DataVotes") + } + if itemCount > int(expr5) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr5)), "ETH1DataVotes") + } + val10 = sszutils.ExpandSlice(val10, itemCount) + for idx1 := range itemCount { + if val10[idx1] == nil { + val10[idx1] = new(phase0.ETH1Data) + } + buf := buf[72*idx1 : 72*(idx1+1)] + if err = val10[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "ETH1DataVotes[%d]", idx1) + } + } + t.ETH1DataVotes = val10 + } + { // Field #11 'Validators' (dynamic) + buf := buf[offset11:offset12] + val11 := t.Validators + itemCount := len(buf) / 121 + if len(buf)%121 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 121), "Validators") + } + if itemCount > int(expr6) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "Validators") + } + val11 = sszutils.ExpandSlice(val11, itemCount) + for idx1 := range itemCount { + if val11[idx1] == nil { + val11[idx1] = new(phase0.Validator) + } + buf := buf[121*idx1 : 121*(idx1+1)] + if err = val11[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } + } + t.Validators = val11 + } + { // Field #12 'Balances' (dynamic) + buf := buf[offset12:offset15] + val12 := t.Balances + itemCount := len(buf) / 8 + if len(buf)%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 8), "Balances") + } + if itemCount > int(expr6) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "Balances") + } + val12 = sszutils.ExpandSlice(val12, itemCount) + sszutils.UnmarshalUint64Slice(val12, buf) + t.Balances = val12 + } + { // Field #15 'PreviousEpochParticipation' (dynamic) + buf := buf[offset15:offset16] + val13 := t.PreviousEpochParticipation + itemCount := len(buf) + if itemCount > int(expr6) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "PreviousEpochParticipation") + } + val13 = sszutils.ExpandSlice(val13, itemCount) + for idx1 := range itemCount { + buf := buf[1*idx1 : 1*(idx1+1)] + val13[idx1] = altair.ParticipationFlags(buf[0]) + } + t.PreviousEpochParticipation = val13 + } + { // Field #16 'CurrentEpochParticipation' (dynamic) + buf := buf[offset16:offset21] + val14 := t.CurrentEpochParticipation + itemCount := len(buf) + if itemCount > int(expr6) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "CurrentEpochParticipation") + } + val14 = sszutils.ExpandSlice(val14, itemCount) + for idx1 := range itemCount { + buf := buf[1*idx1 : 1*(idx1+1)] + val14[idx1] = altair.ParticipationFlags(buf[0]) + } + t.CurrentEpochParticipation = val14 + } + { // Field #21 'InactivityScores' (dynamic) + buf := buf[offset21:offset24] + val15 := t.InactivityScores + itemCount := len(buf) / 8 + if len(buf)%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 8), "InactivityScores") + } + if itemCount > int(expr6) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "InactivityScores") + } + val15 = sszutils.ExpandSlice(val15, itemCount) + sszutils.UnmarshalUint64Slice(val15, buf) + t.InactivityScores = val15 + } + { // Field #24 'LatestExecutionPayloadHeader' (dynamic) + buf := buf[offset24:offset27] + if t.LatestExecutionPayloadHeader == nil { + t.LatestExecutionPayloadHeader = new(ExecutionPayloadHeader) + } + if viewFn := t.LatestExecutionPayloadHeader.UnmarshalSSZDynView((*deneb.ExecutionPayloadHeader)(nil)); viewFn != nil { + if err = viewFn(ds, buf); err != nil { + return err + } + } else { + return sszutils.ErrNotImplemented + } + } + { // Field #27 'HistoricalSummaries' (dynamic) + buf := buf[offset27:] + val16 := t.HistoricalSummaries + itemCount := len(buf) / 64 + if len(buf)%64 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 64), "HistoricalSummaries") + } + if itemCount > int(expr4) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr4)), "HistoricalSummaries") + } + val16 = sszutils.ExpandSlice(val16, itemCount) + for idx1 := range itemCount { + if val16[idx1] == nil { + val16[idx1] = new(capella.HistoricalSummary) + } + buf := buf[64*idx1 : 64*(idx1+1)] + if err = val16[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "HistoricalSummaries[%d]", idx1) + } + } + t.HistoricalSummaries = val16 + } + return nil +} + +func (t *BeaconState) unmarshalSSZView_BeaconState_4(ds sszutils.DynamicSpecs, buf []byte) (err error) { + expr0, err := sszutils.ResolveSpecValueWithDefault(ds, "SLOTS_PER_HISTORICAL_ROOT", 8192) + if err != nil { + return err + } + expr1, err := sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_HISTORICAL_VECTOR", 65536) + if err != nil { + return err + } + expr2, err := sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_SLASHINGS_VECTOR", 8192) + if err != nil { + return err + } + expr3, err := sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE", 512) + if err != nil { + return err + } + expr4, err := sszutils.ResolveSpecValueWithDefault(ds, "HISTORICAL_ROOTS_LIMIT", 16777216) + if err != nil { + return err + } + expr5, err := sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_ETH1_VOTING_PERIOD*SLOTS_PER_EPOCH", 2048) + if err != nil { + return err + } + expr6, err := sszutils.ResolveSpecValueWithDefault(ds, "VALIDATOR_REGISTRY_LIMIT", 1099511627776) + if err != nil { + return err + } + expr7, err := sszutils.ResolveSpecValueWithDefault(ds, "PENDING_DEPOSITS_LIMIT", 134217728) + if err != nil { + return err + } + expr8, err := sszutils.ResolveSpecValueWithDefault(ds, "PENDING_PARTIAL_WITHDRAWALS_LIMIT", 134217728) + if err != nil { + return err + } + expr9, err := sszutils.ResolveSpecValueWithDefault(ds, "PENDING_CONSOLIDATIONS_LIMIT", 262144) + if err != nil { + return err + } + size1 := 32 * int(expr0) + size2 := 32 * int(expr1) + size3 := 8 * int(expr2) + size5 := 48 * int(expr3) + size4 := size5 + 48 // size expression for '*SyncCommittee' + exproffset := 0 + totalSize := size1+size1+size2+size3+size4+size4+489 + buflen := len(buf) + if buflen < totalSize { + return sszutils.ErrFixedFieldsEOFFn(buflen, totalSize) + } + { // Field #0 'GenesisTime' (static) + buf := buf[0:8] + t.GenesisTime = binary.LittleEndian.Uint64(buf) + } + { // Field #1 'GenesisValidatorsRoot' (static) + buf := buf[8:40] + copy(t.GenesisValidatorsRoot[:], buf) + } + { // Field #2 'Slot' (static) + buf := buf[40:48] + t.Slot = phase0.Slot(binary.LittleEndian.Uint64(buf)) + } + { // Field #3 'Fork' (static) + buf := buf[48:64] + if t.Fork == nil { + t.Fork = new(phase0.Fork) + } + if err = t.Fork.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "Fork") + } + } + { // Field #4 'LatestBlockHeader' (static) + buf := buf[64:176] + if t.LatestBlockHeader == nil { + t.LatestBlockHeader = new(phase0.BeaconBlockHeader) + } + if err = t.LatestBlockHeader.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") + } + } + { // Field #5 'BlockRoots' (static) + buf := buf[176 : size1+176] + exproffset += int(size1) + val1 := t.BlockRoots + val1 = sszutils.ExpandSlice(val1, int(expr0)) + for idx1 := range int(expr0) { + buf := buf[32*idx1 : 32*(idx1+1)] + copy(val1[idx1][:], buf) + } + t.BlockRoots = val1 + } + { // Field #6 'StateRoots' (static) + buf := buf[exproffset+176 : exproffset+size1+176] + exproffset += int(size1) + val2 := t.StateRoots + val2 = sszutils.ExpandSlice(val2, int(expr0)) + for idx1 := range int(expr0) { + buf := buf[32*idx1 : 32*(idx1+1)] + copy(val2[idx1][:], buf) + } + t.StateRoots = val2 + } + // Field #7 'HistoricalRoots' (offset) + offset7 := int(binary.LittleEndian.Uint32(buf[exproffset+176 : exproffset+180])) + if offset7 != totalSize { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset7, totalSize), "HistoricalRoots:o") + } + { // Field #8 'ETH1Data' (static) + buf := buf[exproffset+180 : exproffset+252] + if t.ETH1Data == nil { + t.ETH1Data = new(phase0.ETH1Data) + } + if err = t.ETH1Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "ETH1Data") + } + } + // Field #9 'ETH1DataVotes' (offset) + offset9 := int(binary.LittleEndian.Uint32(buf[exproffset+252 : exproffset+256])) + if offset9 < offset7 || offset9 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset9, offset7, buflen), "ETH1DataVotes:o") + } + { // Field #10 'ETH1DepositIndex' (static) + buf := buf[exproffset+256 : exproffset+264] + t.ETH1DepositIndex = binary.LittleEndian.Uint64(buf) + } + // Field #11 'Validators' (offset) + offset11 := int(binary.LittleEndian.Uint32(buf[exproffset+264 : exproffset+268])) + if offset11 < offset9 || offset11 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset11, offset9, buflen), "Validators:o") + } + // Field #12 'Balances' (offset) + offset12 := int(binary.LittleEndian.Uint32(buf[exproffset+268 : exproffset+272])) + if offset12 < offset11 || offset12 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset12, offset11, buflen), "Balances:o") + } + { // Field #13 'RANDAOMixes' (static) + buf := buf[exproffset+272 : exproffset+size2+272] + exproffset += int(size2) + val3 := t.RANDAOMixes + val3 = sszutils.ExpandSlice(val3, int(expr1)) + for idx1 := range int(expr1) { + buf := buf[32*idx1 : 32*(idx1+1)] + copy(val3[idx1][:], buf) + } + t.RANDAOMixes = val3 + } + { // Field #14 'Slashings' (static) + buf := buf[exproffset+272 : exproffset+size3+272] + exproffset += int(size3) + val4 := t.Slashings + val4 = sszutils.ExpandSlice(val4, int(expr2)) + sszutils.UnmarshalUint64Slice(val4[:int(expr2)], buf) + t.Slashings = val4 + } + // Field #15 'PreviousEpochParticipation' (offset) + offset15 := int(binary.LittleEndian.Uint32(buf[exproffset+272 : exproffset+276])) + if offset15 < offset12 || offset15 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset15, offset12, buflen), "PreviousEpochParticipation:o") + } + // Field #16 'CurrentEpochParticipation' (offset) + offset16 := int(binary.LittleEndian.Uint32(buf[exproffset+276 : exproffset+280])) + if offset16 < offset15 || offset16 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset16, offset15, buflen), "CurrentEpochParticipation:o") + } + { // Field #17 'JustificationBits' (static) + buf := buf[exproffset+280 : exproffset+281] + t.JustificationBits = sszutils.ExpandSlice(t.JustificationBits, 1) + copy(t.JustificationBits[:], buf) + } + { // Field #18 'PreviousJustifiedCheckpoint' (static) + buf := buf[exproffset+281 : exproffset+321] + if t.PreviousJustifiedCheckpoint == nil { + t.PreviousJustifiedCheckpoint = new(phase0.Checkpoint) + } + if err = t.PreviousJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } + } + { // Field #19 'CurrentJustifiedCheckpoint' (static) + buf := buf[exproffset+321 : exproffset+361] + if t.CurrentJustifiedCheckpoint == nil { + t.CurrentJustifiedCheckpoint = new(phase0.Checkpoint) + } + if err = t.CurrentJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } + } + { // Field #20 'FinalizedCheckpoint' (static) + buf := buf[exproffset+361 : exproffset+401] + if t.FinalizedCheckpoint == nil { + t.FinalizedCheckpoint = new(phase0.Checkpoint) + } + if err = t.FinalizedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") + } + } + // Field #21 'InactivityScores' (offset) + offset21 := int(binary.LittleEndian.Uint32(buf[exproffset+401 : exproffset+405])) + if offset21 < offset16 || offset21 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset21, offset16, buflen), "InactivityScores:o") + } + { // Field #22 'CurrentSyncCommittee' (static) + buf := buf[exproffset+405 : exproffset+size4+405] + exproffset += int(size4) + val5 := t.CurrentSyncCommittee + if val5 == nil { + val5 = new(altair.SyncCommittee) + } + exproffset := 0 + totalSize := size5+48 + buflen := len(buf) + if buflen < totalSize { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, totalSize), "CurrentSyncCommittee") + } + { // Field #0 'Pubkeys' (static) + buf := buf[0 : size5+0] + exproffset += int(size5) + val6 := val5.Pubkeys + val6 = sszutils.ExpandSlice(val6, int(expr3)) + for idx1 := range int(expr3) { + buf := buf[48*idx1 : 48*(idx1+1)] + copy(val6[idx1][:], buf) + } + val5.Pubkeys = val6 + } + { // Field #1 'AggregatePubkey' (static) + buf := buf[exproffset+0 : exproffset+48] + copy(val5.AggregatePubkey[:], buf) + } + t.CurrentSyncCommittee = val5 + } + { // Field #23 'NextSyncCommittee' (static) + buf := buf[exproffset+405 : exproffset+size4+405] + exproffset += int(size4) + val7 := t.NextSyncCommittee + if val7 == nil { + val7 = new(altair.SyncCommittee) + } + exproffset := 0 + totalSize := size5+48 + buflen := len(buf) + if buflen < totalSize { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, totalSize), "NextSyncCommittee") + } + { // Field #0 'Pubkeys' (static) + buf := buf[0 : size5+0] + exproffset += int(size5) + val8 := val7.Pubkeys + val8 = sszutils.ExpandSlice(val8, int(expr3)) + for idx1 := range int(expr3) { + buf := buf[48*idx1 : 48*(idx1+1)] + copy(val8[idx1][:], buf) + } + val7.Pubkeys = val8 + } + { // Field #1 'AggregatePubkey' (static) + buf := buf[exproffset+0 : exproffset+48] + copy(val7.AggregatePubkey[:], buf) + } + t.NextSyncCommittee = val7 + } + // Field #24 'LatestExecutionPayloadHeader' (offset) + offset24 := int(binary.LittleEndian.Uint32(buf[exproffset+405 : exproffset+409])) + if offset24 < offset21 || offset24 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset24, offset21, buflen), "LatestExecutionPayloadHeader:o") + } + { // Field #25 'NextWithdrawalIndex' (static) + buf := buf[exproffset+409 : exproffset+417] + t.NextWithdrawalIndex = capella.WithdrawalIndex(binary.LittleEndian.Uint64(buf)) + } + { // Field #26 'NextWithdrawalValidatorIndex' (static) + buf := buf[exproffset+417 : exproffset+425] + t.NextWithdrawalValidatorIndex = phase0.ValidatorIndex(binary.LittleEndian.Uint64(buf)) + } + // Field #27 'HistoricalSummaries' (offset) + offset27 := int(binary.LittleEndian.Uint32(buf[exproffset+425 : exproffset+429])) + if offset27 < offset24 || offset27 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset27, offset24, buflen), "HistoricalSummaries:o") + } + { // Field #28 'DepositRequestsStartIndex' (static) + buf := buf[exproffset+429 : exproffset+437] + t.DepositRequestsStartIndex = binary.LittleEndian.Uint64(buf) + } + { // Field #29 'DepositBalanceToConsume' (static) + buf := buf[exproffset+437 : exproffset+445] + t.DepositBalanceToConsume = phase0.Gwei(binary.LittleEndian.Uint64(buf)) + } + { // Field #30 'ExitBalanceToConsume' (static) + buf := buf[exproffset+445 : exproffset+453] + t.ExitBalanceToConsume = phase0.Gwei(binary.LittleEndian.Uint64(buf)) + } + { // Field #31 'EarliestExitEpoch' (static) + buf := buf[exproffset+453 : exproffset+461] + t.EarliestExitEpoch = phase0.Epoch(binary.LittleEndian.Uint64(buf)) + } + { // Field #32 'ConsolidationBalanceToConsume' (static) + buf := buf[exproffset+461 : exproffset+469] + t.ConsolidationBalanceToConsume = phase0.Gwei(binary.LittleEndian.Uint64(buf)) + } + { // Field #33 'EarliestConsolidationEpoch' (static) + buf := buf[exproffset+469 : exproffset+477] + t.EarliestConsolidationEpoch = phase0.Epoch(binary.LittleEndian.Uint64(buf)) + } + // Field #34 'PendingDeposits' (offset) + offset34 := int(binary.LittleEndian.Uint32(buf[exproffset+477 : exproffset+481])) + if offset34 < offset27 || offset34 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset34, offset27, buflen), "PendingDeposits:o") + } + // Field #35 'PendingPartialWithdrawals' (offset) + offset35 := int(binary.LittleEndian.Uint32(buf[exproffset+481 : exproffset+485])) + if offset35 < offset34 || offset35 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset35, offset34, buflen), "PendingPartialWithdrawals:o") + } + // Field #36 'PendingConsolidations' (offset) + offset36 := int(binary.LittleEndian.Uint32(buf[exproffset+485 : exproffset+489])) + if offset36 < offset35 || offset36 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset36, offset35, buflen), "PendingConsolidations:o") + } + { // Field #7 'HistoricalRoots' (dynamic) + buf := buf[offset7:offset9] + val9 := t.HistoricalRoots + itemCount := len(buf) / 32 + if len(buf)%32 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 32), "HistoricalRoots") + } + if itemCount > int(expr4) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr4)), "HistoricalRoots") + } + val9 = sszutils.ExpandSlice(val9, itemCount) + for idx1 := range itemCount { + buf := buf[32*idx1 : 32*(idx1+1)] + copy(val9[idx1][:], buf) + } + t.HistoricalRoots = val9 + } + { // Field #9 'ETH1DataVotes' (dynamic) + buf := buf[offset9:offset11] + val10 := t.ETH1DataVotes + itemCount := len(buf) / 72 + if len(buf)%72 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 72), "ETH1DataVotes") + } + if itemCount > int(expr5) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr5)), "ETH1DataVotes") + } + val10 = sszutils.ExpandSlice(val10, itemCount) + for idx1 := range itemCount { + if val10[idx1] == nil { + val10[idx1] = new(phase0.ETH1Data) + } + buf := buf[72*idx1 : 72*(idx1+1)] + if err = val10[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "ETH1DataVotes[%d]", idx1) + } + } + t.ETH1DataVotes = val10 + } + { // Field #11 'Validators' (dynamic) + buf := buf[offset11:offset12] + val11 := t.Validators + itemCount := len(buf) / 121 + if len(buf)%121 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 121), "Validators") + } + if itemCount > int(expr6) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "Validators") + } + val11 = sszutils.ExpandSlice(val11, itemCount) + for idx1 := range itemCount { + if val11[idx1] == nil { + val11[idx1] = new(phase0.Validator) + } + buf := buf[121*idx1 : 121*(idx1+1)] + if err = val11[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } + } + t.Validators = val11 + } + { // Field #12 'Balances' (dynamic) + buf := buf[offset12:offset15] + val12 := t.Balances + itemCount := len(buf) / 8 + if len(buf)%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 8), "Balances") + } + if itemCount > int(expr6) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "Balances") + } + val12 = sszutils.ExpandSlice(val12, itemCount) + sszutils.UnmarshalUint64Slice(val12, buf) + t.Balances = val12 + } + { // Field #15 'PreviousEpochParticipation' (dynamic) + buf := buf[offset15:offset16] + val13 := t.PreviousEpochParticipation + itemCount := len(buf) + if itemCount > int(expr6) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "PreviousEpochParticipation") + } + val13 = sszutils.ExpandSlice(val13, itemCount) + for idx1 := range itemCount { + buf := buf[1*idx1 : 1*(idx1+1)] + val13[idx1] = altair.ParticipationFlags(buf[0]) + } + t.PreviousEpochParticipation = val13 + } + { // Field #16 'CurrentEpochParticipation' (dynamic) + buf := buf[offset16:offset21] + val14 := t.CurrentEpochParticipation + itemCount := len(buf) + if itemCount > int(expr6) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "CurrentEpochParticipation") + } + val14 = sszutils.ExpandSlice(val14, itemCount) + for idx1 := range itemCount { + buf := buf[1*idx1 : 1*(idx1+1)] + val14[idx1] = altair.ParticipationFlags(buf[0]) + } + t.CurrentEpochParticipation = val14 + } + { // Field #21 'InactivityScores' (dynamic) + buf := buf[offset21:offset24] + val15 := t.InactivityScores + itemCount := len(buf) / 8 + if len(buf)%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 8), "InactivityScores") + } + if itemCount > int(expr6) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "InactivityScores") + } + val15 = sszutils.ExpandSlice(val15, itemCount) + sszutils.UnmarshalUint64Slice(val15, buf) + t.InactivityScores = val15 + } + { // Field #24 'LatestExecutionPayloadHeader' (dynamic) + buf := buf[offset24:offset27] + if t.LatestExecutionPayloadHeader == nil { + t.LatestExecutionPayloadHeader = new(ExecutionPayloadHeader) + } + if viewFn := t.LatestExecutionPayloadHeader.UnmarshalSSZDynView((*deneb.ExecutionPayloadHeader)(nil)); viewFn != nil { + if err = viewFn(ds, buf); err != nil { + return err + } + } else { + return sszutils.ErrNotImplemented + } + } + { // Field #27 'HistoricalSummaries' (dynamic) + buf := buf[offset27:offset34] + val16 := t.HistoricalSummaries + itemCount := len(buf) / 64 + if len(buf)%64 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 64), "HistoricalSummaries") + } + if itemCount > int(expr4) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr4)), "HistoricalSummaries") + } + val16 = sszutils.ExpandSlice(val16, itemCount) + for idx1 := range itemCount { + if val16[idx1] == nil { + val16[idx1] = new(capella.HistoricalSummary) + } + buf := buf[64*idx1 : 64*(idx1+1)] + if err = val16[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "HistoricalSummaries[%d]", idx1) + } + } + t.HistoricalSummaries = val16 + } + { // Field #34 'PendingDeposits' (dynamic) + buf := buf[offset34:offset35] + val17 := t.PendingDeposits + itemCount := len(buf) / 192 + if len(buf)%192 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 192), "PendingDeposits") + } + if itemCount > int(expr7) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr7)), "PendingDeposits") + } + val17 = sszutils.ExpandSlice(val17, itemCount) + for idx1 := range itemCount { + if val17[idx1] == nil { + val17[idx1] = new(electra.PendingDeposit) + } + buf := buf[192*idx1 : 192*(idx1+1)] + if err = val17[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "PendingDeposits[%d]", idx1) + } + } + t.PendingDeposits = val17 + } + { // Field #35 'PendingPartialWithdrawals' (dynamic) + buf := buf[offset35:offset36] + val18 := t.PendingPartialWithdrawals + itemCount := len(buf) / 24 + if len(buf)%24 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 24), "PendingPartialWithdrawals") + } + if itemCount > int(expr8) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr8)), "PendingPartialWithdrawals") + } + val18 = sszutils.ExpandSlice(val18, itemCount) + for idx1 := range itemCount { + if val18[idx1] == nil { + val18[idx1] = new(electra.PendingPartialWithdrawal) + } + buf := buf[24*idx1 : 24*(idx1+1)] + if err = val18[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "PendingPartialWithdrawals[%d]", idx1) + } + } + t.PendingPartialWithdrawals = val18 + } + { // Field #36 'PendingConsolidations' (dynamic) + buf := buf[offset36:] + val19 := t.PendingConsolidations + itemCount := len(buf) / 16 + if len(buf)%16 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 16), "PendingConsolidations") + } + if itemCount > int(expr9) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr9)), "PendingConsolidations") + } + val19 = sszutils.ExpandSlice(val19, itemCount) + for idx1 := range itemCount { + if val19[idx1] == nil { + val19[idx1] = new(electra.PendingConsolidation) + } + buf := buf[16*idx1 : 16*(idx1+1)] + if err = val19[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "PendingConsolidations[%d]", idx1) + } + } + t.PendingConsolidations = val19 + } + return nil +} + +func (t *BeaconState) unmarshalSSZView_BeaconState_5(ds sszutils.DynamicSpecs, buf []byte) (err error) { + expr0, err := sszutils.ResolveSpecValueWithDefault(ds, "SLOTS_PER_HISTORICAL_ROOT", 8192) + if err != nil { + return err + } + expr1, err := sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_HISTORICAL_VECTOR", 65536) + if err != nil { + return err + } + expr2, err := sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_SLASHINGS_VECTOR", 8192) + if err != nil { + return err + } + expr3, err := sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE", 512) + if err != nil { + return err + } + expr4, err := sszutils.ResolveSpecValueWithDefault(ds, "(MIN_SEED_LOOKAHEAD+1)*SLOTS_PER_EPOCH", 64) + if err != nil { + return err + } + expr5, err := sszutils.ResolveSpecValueWithDefault(ds, "HISTORICAL_ROOTS_LIMIT", 16777216) + if err != nil { + return err + } + expr6, err := sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_ETH1_VOTING_PERIOD*SLOTS_PER_EPOCH", 2048) + if err != nil { + return err + } + expr7, err := sszutils.ResolveSpecValueWithDefault(ds, "VALIDATOR_REGISTRY_LIMIT", 1099511627776) + if err != nil { + return err + } + expr8, err := sszutils.ResolveSpecValueWithDefault(ds, "PENDING_DEPOSITS_LIMIT", 134217728) + if err != nil { + return err + } + expr9, err := sszutils.ResolveSpecValueWithDefault(ds, "PENDING_PARTIAL_WITHDRAWALS_LIMIT", 134217728) + if err != nil { + return err + } + expr10, err := sszutils.ResolveSpecValueWithDefault(ds, "PENDING_CONSOLIDATIONS_LIMIT", 262144) + if err != nil { + return err + } + size1 := 32 * int(expr0) + size2 := 32 * int(expr1) + size3 := 8 * int(expr2) + size5 := 48 * int(expr3) + size4 := size5 + 48 // size expression for '*SyncCommittee' + size6 := 8 * int(expr4) + exproffset := 0 + totalSize := size1+size1+size2+size3+size4+size4+size6+489 + buflen := len(buf) + if buflen < totalSize { + return sszutils.ErrFixedFieldsEOFFn(buflen, totalSize) + } + { // Field #0 'GenesisTime' (static) + buf := buf[0:8] + t.GenesisTime = binary.LittleEndian.Uint64(buf) + } + { // Field #1 'GenesisValidatorsRoot' (static) + buf := buf[8:40] + copy(t.GenesisValidatorsRoot[:], buf) + } + { // Field #2 'Slot' (static) + buf := buf[40:48] + t.Slot = phase0.Slot(binary.LittleEndian.Uint64(buf)) + } + { // Field #3 'Fork' (static) + buf := buf[48:64] + if t.Fork == nil { + t.Fork = new(phase0.Fork) + } + if err = t.Fork.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "Fork") + } + } + { // Field #4 'LatestBlockHeader' (static) + buf := buf[64:176] + if t.LatestBlockHeader == nil { + t.LatestBlockHeader = new(phase0.BeaconBlockHeader) + } + if err = t.LatestBlockHeader.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") + } + } + { // Field #5 'BlockRoots' (static) + buf := buf[176 : size1+176] + exproffset += int(size1) + val1 := t.BlockRoots + val1 = sszutils.ExpandSlice(val1, int(expr0)) + for idx1 := range int(expr0) { + buf := buf[32*idx1 : 32*(idx1+1)] + copy(val1[idx1][:], buf) + } + t.BlockRoots = val1 + } + { // Field #6 'StateRoots' (static) + buf := buf[exproffset+176 : exproffset+size1+176] + exproffset += int(size1) + val2 := t.StateRoots + val2 = sszutils.ExpandSlice(val2, int(expr0)) + for idx1 := range int(expr0) { + buf := buf[32*idx1 : 32*(idx1+1)] + copy(val2[idx1][:], buf) + } + t.StateRoots = val2 + } + // Field #7 'HistoricalRoots' (offset) + offset7 := int(binary.LittleEndian.Uint32(buf[exproffset+176 : exproffset+180])) + if offset7 != totalSize { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset7, totalSize), "HistoricalRoots:o") + } + { // Field #8 'ETH1Data' (static) + buf := buf[exproffset+180 : exproffset+252] + if t.ETH1Data == nil { + t.ETH1Data = new(phase0.ETH1Data) + } + if err = t.ETH1Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "ETH1Data") + } + } + // Field #9 'ETH1DataVotes' (offset) + offset9 := int(binary.LittleEndian.Uint32(buf[exproffset+252 : exproffset+256])) + if offset9 < offset7 || offset9 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset9, offset7, buflen), "ETH1DataVotes:o") + } + { // Field #10 'ETH1DepositIndex' (static) + buf := buf[exproffset+256 : exproffset+264] + t.ETH1DepositIndex = binary.LittleEndian.Uint64(buf) + } + // Field #11 'Validators' (offset) + offset11 := int(binary.LittleEndian.Uint32(buf[exproffset+264 : exproffset+268])) + if offset11 < offset9 || offset11 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset11, offset9, buflen), "Validators:o") + } + // Field #12 'Balances' (offset) + offset12 := int(binary.LittleEndian.Uint32(buf[exproffset+268 : exproffset+272])) + if offset12 < offset11 || offset12 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset12, offset11, buflen), "Balances:o") + } + { // Field #13 'RANDAOMixes' (static) + buf := buf[exproffset+272 : exproffset+size2+272] + exproffset += int(size2) + val3 := t.RANDAOMixes + val3 = sszutils.ExpandSlice(val3, int(expr1)) + for idx1 := range int(expr1) { + buf := buf[32*idx1 : 32*(idx1+1)] + copy(val3[idx1][:], buf) + } + t.RANDAOMixes = val3 + } + { // Field #14 'Slashings' (static) + buf := buf[exproffset+272 : exproffset+size3+272] + exproffset += int(size3) + val4 := t.Slashings + val4 = sszutils.ExpandSlice(val4, int(expr2)) + sszutils.UnmarshalUint64Slice(val4[:int(expr2)], buf) + t.Slashings = val4 + } + // Field #15 'PreviousEpochParticipation' (offset) + offset15 := int(binary.LittleEndian.Uint32(buf[exproffset+272 : exproffset+276])) + if offset15 < offset12 || offset15 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset15, offset12, buflen), "PreviousEpochParticipation:o") + } + // Field #16 'CurrentEpochParticipation' (offset) + offset16 := int(binary.LittleEndian.Uint32(buf[exproffset+276 : exproffset+280])) + if offset16 < offset15 || offset16 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset16, offset15, buflen), "CurrentEpochParticipation:o") + } + { // Field #17 'JustificationBits' (static) + buf := buf[exproffset+280 : exproffset+281] + t.JustificationBits = sszutils.ExpandSlice(t.JustificationBits, 1) + copy(t.JustificationBits[:], buf) + } + { // Field #18 'PreviousJustifiedCheckpoint' (static) + buf := buf[exproffset+281 : exproffset+321] + if t.PreviousJustifiedCheckpoint == nil { + t.PreviousJustifiedCheckpoint = new(phase0.Checkpoint) + } + if err = t.PreviousJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } + } + { // Field #19 'CurrentJustifiedCheckpoint' (static) + buf := buf[exproffset+321 : exproffset+361] + if t.CurrentJustifiedCheckpoint == nil { + t.CurrentJustifiedCheckpoint = new(phase0.Checkpoint) + } + if err = t.CurrentJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } + } + { // Field #20 'FinalizedCheckpoint' (static) + buf := buf[exproffset+361 : exproffset+401] + if t.FinalizedCheckpoint == nil { + t.FinalizedCheckpoint = new(phase0.Checkpoint) + } + if err = t.FinalizedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") + } + } + // Field #21 'InactivityScores' (offset) + offset21 := int(binary.LittleEndian.Uint32(buf[exproffset+401 : exproffset+405])) + if offset21 < offset16 || offset21 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset21, offset16, buflen), "InactivityScores:o") + } + { // Field #22 'CurrentSyncCommittee' (static) + buf := buf[exproffset+405 : exproffset+size4+405] + exproffset += int(size4) + val5 := t.CurrentSyncCommittee + if val5 == nil { + val5 = new(altair.SyncCommittee) + } + exproffset := 0 + totalSize := size5+48 + buflen := len(buf) + if buflen < totalSize { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, totalSize), "CurrentSyncCommittee") + } + { // Field #0 'Pubkeys' (static) + buf := buf[0 : size5+0] + exproffset += int(size5) + val6 := val5.Pubkeys + val6 = sszutils.ExpandSlice(val6, int(expr3)) + for idx1 := range int(expr3) { + buf := buf[48*idx1 : 48*(idx1+1)] + copy(val6[idx1][:], buf) + } + val5.Pubkeys = val6 + } + { // Field #1 'AggregatePubkey' (static) + buf := buf[exproffset+0 : exproffset+48] + copy(val5.AggregatePubkey[:], buf) + } + t.CurrentSyncCommittee = val5 + } + { // Field #23 'NextSyncCommittee' (static) + buf := buf[exproffset+405 : exproffset+size4+405] + exproffset += int(size4) + val7 := t.NextSyncCommittee + if val7 == nil { + val7 = new(altair.SyncCommittee) + } + exproffset := 0 + totalSize := size5+48 + buflen := len(buf) + if buflen < totalSize { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, totalSize), "NextSyncCommittee") + } + { // Field #0 'Pubkeys' (static) + buf := buf[0 : size5+0] + exproffset += int(size5) + val8 := val7.Pubkeys + val8 = sszutils.ExpandSlice(val8, int(expr3)) + for idx1 := range int(expr3) { + buf := buf[48*idx1 : 48*(idx1+1)] + copy(val8[idx1][:], buf) + } + val7.Pubkeys = val8 + } + { // Field #1 'AggregatePubkey' (static) + buf := buf[exproffset+0 : exproffset+48] + copy(val7.AggregatePubkey[:], buf) + } + t.NextSyncCommittee = val7 + } + // Field #24 'LatestExecutionPayloadHeader' (offset) + offset24 := int(binary.LittleEndian.Uint32(buf[exproffset+405 : exproffset+409])) + if offset24 < offset21 || offset24 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset24, offset21, buflen), "LatestExecutionPayloadHeader:o") + } + { // Field #25 'NextWithdrawalIndex' (static) + buf := buf[exproffset+409 : exproffset+417] + t.NextWithdrawalIndex = capella.WithdrawalIndex(binary.LittleEndian.Uint64(buf)) + } + { // Field #26 'NextWithdrawalValidatorIndex' (static) + buf := buf[exproffset+417 : exproffset+425] + t.NextWithdrawalValidatorIndex = phase0.ValidatorIndex(binary.LittleEndian.Uint64(buf)) + } + // Field #27 'HistoricalSummaries' (offset) + offset27 := int(binary.LittleEndian.Uint32(buf[exproffset+425 : exproffset+429])) + if offset27 < offset24 || offset27 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset27, offset24, buflen), "HistoricalSummaries:o") + } + { // Field #28 'DepositRequestsStartIndex' (static) + buf := buf[exproffset+429 : exproffset+437] + t.DepositRequestsStartIndex = binary.LittleEndian.Uint64(buf) + } + { // Field #29 'DepositBalanceToConsume' (static) + buf := buf[exproffset+437 : exproffset+445] + t.DepositBalanceToConsume = phase0.Gwei(binary.LittleEndian.Uint64(buf)) + } + { // Field #30 'ExitBalanceToConsume' (static) + buf := buf[exproffset+445 : exproffset+453] + t.ExitBalanceToConsume = phase0.Gwei(binary.LittleEndian.Uint64(buf)) + } + { // Field #31 'EarliestExitEpoch' (static) + buf := buf[exproffset+453 : exproffset+461] + t.EarliestExitEpoch = phase0.Epoch(binary.LittleEndian.Uint64(buf)) + } + { // Field #32 'ConsolidationBalanceToConsume' (static) + buf := buf[exproffset+461 : exproffset+469] + t.ConsolidationBalanceToConsume = phase0.Gwei(binary.LittleEndian.Uint64(buf)) + } + { // Field #33 'EarliestConsolidationEpoch' (static) + buf := buf[exproffset+469 : exproffset+477] + t.EarliestConsolidationEpoch = phase0.Epoch(binary.LittleEndian.Uint64(buf)) + } + // Field #34 'PendingDeposits' (offset) + offset34 := int(binary.LittleEndian.Uint32(buf[exproffset+477 : exproffset+481])) + if offset34 < offset27 || offset34 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset34, offset27, buflen), "PendingDeposits:o") + } + // Field #35 'PendingPartialWithdrawals' (offset) + offset35 := int(binary.LittleEndian.Uint32(buf[exproffset+481 : exproffset+485])) + if offset35 < offset34 || offset35 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset35, offset34, buflen), "PendingPartialWithdrawals:o") + } + // Field #36 'PendingConsolidations' (offset) + offset36 := int(binary.LittleEndian.Uint32(buf[exproffset+485 : exproffset+489])) + if offset36 < offset35 || offset36 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset36, offset35, buflen), "PendingConsolidations:o") + } + { // Field #37 'ProposerLookahead' (static) + buf := buf[exproffset+489 : exproffset+size6+489] + exproffset += int(size6) + val9 := t.ProposerLookahead + val9 = sszutils.ExpandSlice(val9, int(expr4)) + sszutils.UnmarshalUint64Slice(val9[:int(expr4)], buf) + t.ProposerLookahead = val9 + } + { // Field #7 'HistoricalRoots' (dynamic) + buf := buf[offset7:offset9] + val10 := t.HistoricalRoots + itemCount := len(buf) / 32 + if len(buf)%32 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 32), "HistoricalRoots") + } + if itemCount > int(expr5) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr5)), "HistoricalRoots") + } + val10 = sszutils.ExpandSlice(val10, itemCount) + for idx1 := range itemCount { + buf := buf[32*idx1 : 32*(idx1+1)] + copy(val10[idx1][:], buf) + } + t.HistoricalRoots = val10 + } + { // Field #9 'ETH1DataVotes' (dynamic) + buf := buf[offset9:offset11] + val11 := t.ETH1DataVotes + itemCount := len(buf) / 72 + if len(buf)%72 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 72), "ETH1DataVotes") + } + if itemCount > int(expr6) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "ETH1DataVotes") + } + val11 = sszutils.ExpandSlice(val11, itemCount) + for idx1 := range itemCount { + if val11[idx1] == nil { + val11[idx1] = new(phase0.ETH1Data) + } + buf := buf[72*idx1 : 72*(idx1+1)] + if err = val11[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "ETH1DataVotes[%d]", idx1) + } + } + t.ETH1DataVotes = val11 + } + { // Field #11 'Validators' (dynamic) + buf := buf[offset11:offset12] + val12 := t.Validators + itemCount := len(buf) / 121 + if len(buf)%121 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 121), "Validators") + } + if itemCount > int(expr7) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr7)), "Validators") + } + val12 = sszutils.ExpandSlice(val12, itemCount) + for idx1 := range itemCount { + if val12[idx1] == nil { + val12[idx1] = new(phase0.Validator) + } + buf := buf[121*idx1 : 121*(idx1+1)] + if err = val12[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } + } + t.Validators = val12 + } + { // Field #12 'Balances' (dynamic) + buf := buf[offset12:offset15] + val13 := t.Balances + itemCount := len(buf) / 8 + if len(buf)%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 8), "Balances") + } + if itemCount > int(expr7) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr7)), "Balances") + } + val13 = sszutils.ExpandSlice(val13, itemCount) + sszutils.UnmarshalUint64Slice(val13, buf) + t.Balances = val13 + } + { // Field #15 'PreviousEpochParticipation' (dynamic) + buf := buf[offset15:offset16] + val14 := t.PreviousEpochParticipation + itemCount := len(buf) + if itemCount > int(expr7) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr7)), "PreviousEpochParticipation") + } + val14 = sszutils.ExpandSlice(val14, itemCount) + for idx1 := range itemCount { + buf := buf[1*idx1 : 1*(idx1+1)] + val14[idx1] = altair.ParticipationFlags(buf[0]) + } + t.PreviousEpochParticipation = val14 + } + { // Field #16 'CurrentEpochParticipation' (dynamic) + buf := buf[offset16:offset21] + val15 := t.CurrentEpochParticipation + itemCount := len(buf) + if itemCount > int(expr7) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr7)), "CurrentEpochParticipation") + } + val15 = sszutils.ExpandSlice(val15, itemCount) + for idx1 := range itemCount { + buf := buf[1*idx1 : 1*(idx1+1)] + val15[idx1] = altair.ParticipationFlags(buf[0]) + } + t.CurrentEpochParticipation = val15 + } + { // Field #21 'InactivityScores' (dynamic) + buf := buf[offset21:offset24] + val16 := t.InactivityScores + itemCount := len(buf) / 8 + if len(buf)%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 8), "InactivityScores") + } + if itemCount > int(expr7) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr7)), "InactivityScores") + } + val16 = sszutils.ExpandSlice(val16, itemCount) + sszutils.UnmarshalUint64Slice(val16, buf) + t.InactivityScores = val16 + } + { // Field #24 'LatestExecutionPayloadHeader' (dynamic) + buf := buf[offset24:offset27] + if t.LatestExecutionPayloadHeader == nil { + t.LatestExecutionPayloadHeader = new(ExecutionPayloadHeader) + } + if viewFn := t.LatestExecutionPayloadHeader.UnmarshalSSZDynView((*deneb.ExecutionPayloadHeader)(nil)); viewFn != nil { + if err = viewFn(ds, buf); err != nil { + return err + } + } else { + return sszutils.ErrNotImplemented + } + } + { // Field #27 'HistoricalSummaries' (dynamic) + buf := buf[offset27:offset34] + val17 := t.HistoricalSummaries + itemCount := len(buf) / 64 + if len(buf)%64 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 64), "HistoricalSummaries") + } + if itemCount > int(expr5) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr5)), "HistoricalSummaries") + } + val17 = sszutils.ExpandSlice(val17, itemCount) + for idx1 := range itemCount { + if val17[idx1] == nil { + val17[idx1] = new(capella.HistoricalSummary) + } + buf := buf[64*idx1 : 64*(idx1+1)] + if err = val17[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "HistoricalSummaries[%d]", idx1) + } + } + t.HistoricalSummaries = val17 + } + { // Field #34 'PendingDeposits' (dynamic) + buf := buf[offset34:offset35] + val18 := t.PendingDeposits + itemCount := len(buf) / 192 + if len(buf)%192 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 192), "PendingDeposits") + } + if itemCount > int(expr8) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr8)), "PendingDeposits") + } + val18 = sszutils.ExpandSlice(val18, itemCount) + for idx1 := range itemCount { + if val18[idx1] == nil { + val18[idx1] = new(electra.PendingDeposit) + } + buf := buf[192*idx1 : 192*(idx1+1)] + if err = val18[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "PendingDeposits[%d]", idx1) + } + } + t.PendingDeposits = val18 + } + { // Field #35 'PendingPartialWithdrawals' (dynamic) + buf := buf[offset35:offset36] + val19 := t.PendingPartialWithdrawals + itemCount := len(buf) / 24 + if len(buf)%24 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 24), "PendingPartialWithdrawals") + } + if itemCount > int(expr9) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr9)), "PendingPartialWithdrawals") + } + val19 = sszutils.ExpandSlice(val19, itemCount) + for idx1 := range itemCount { + if val19[idx1] == nil { + val19[idx1] = new(electra.PendingPartialWithdrawal) + } + buf := buf[24*idx1 : 24*(idx1+1)] + if err = val19[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "PendingPartialWithdrawals[%d]", idx1) + } + } + t.PendingPartialWithdrawals = val19 + } + { // Field #36 'PendingConsolidations' (dynamic) + buf := buf[offset36:] + val20 := t.PendingConsolidations + itemCount := len(buf) / 16 + if len(buf)%16 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 16), "PendingConsolidations") + } + if itemCount > int(expr10) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr10)), "PendingConsolidations") + } + val20 = sszutils.ExpandSlice(val20, itemCount) + for idx1 := range itemCount { + if val20[idx1] == nil { + val20[idx1] = new(electra.PendingConsolidation) + } + buf := buf[16*idx1 : 16*(idx1+1)] + if err = val20[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "PendingConsolidations[%d]", idx1) + } + } + t.PendingConsolidations = val20 + } + return nil +} + +func (t *BeaconState) unmarshalSSZView_BeaconState_6(ds sszutils.DynamicSpecs, buf []byte) (err error) { + expr0, err := sszutils.ResolveSpecValueWithDefault(ds, "SLOTS_PER_HISTORICAL_ROOT", 8192) + if err != nil { + return err + } + expr1, err := sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_HISTORICAL_VECTOR", 65536) + if err != nil { + return err + } + expr2, err := sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_SLASHINGS_VECTOR", 8192) + if err != nil { + return err + } + expr3, err := sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE", 512) + if err != nil { + return err + } + expr4, err := sszutils.ResolveSpecValueWithDefault(ds, "(MIN_SEED_LOOKAHEAD+1)*SLOTS_PER_EPOCH", 64) + if err != nil { + return err + } + expr5, err := sszutils.ResolveSpecValueWithDefault(ds, "SLOTS_PER_HISTORICAL_ROOT/8", 1024) + if err != nil { + return err + } + expr6, err := sszutils.ResolveSpecValueWithDefault(ds, "SLOTS_PER_EPOCH*2", 64) + if err != nil { + return err + } + expr7, err := sszutils.ResolveSpecValueWithDefault(ds, "PTC_SIZE", 512) + if err != nil { + return err + } + expr8, err := sszutils.ResolveSpecValueWithDefault(ds, "(2+MIN_SEED_LOOKAHEAD)*SLOTS_PER_EPOCH", 96) + if err != nil { + return err + } + expr9, err := sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_ETH1_VOTING_PERIOD*SLOTS_PER_EPOCH", 2048) + if err != nil { + return err + } + expr10, err := sszutils.ResolveSpecValueWithDefault(ds, "PENDING_DEPOSITS_LIMIT", 134217728) + if err != nil { + return err + } + expr11, err := sszutils.ResolveSpecValueWithDefault(ds, "PENDING_PARTIAL_WITHDRAWALS_LIMIT", 134217728) + if err != nil { + return err + } + expr12, err := sszutils.ResolveSpecValueWithDefault(ds, "PENDING_CONSOLIDATIONS_LIMIT", 262144) + if err != nil { + return err + } + expr13, err := sszutils.ResolveSpecValueWithDefault(ds, "BUILDER_REGISTRY_LIMIT", 1099511627776) + if err != nil { + return err + } + expr14, err := sszutils.ResolveSpecValueWithDefault(ds, "BUILDER_PENDING_WITHDRAWALS_LIMIT", 1048576) + if err != nil { + return err + } + expr15, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_WITHDRAWALS_PER_PAYLOAD", 16) + if err != nil { + return err + } + size1 := 32 * int(expr0) + size2 := 32 * int(expr1) + size3 := 8 * int(expr2) + size5 := 48 * int(expr3) + size4 := size5 + 48 // size expression for '*SyncCommittee' + size6 := 8 * int(expr4) + size7 := 1 * int(expr5) + size8 := 44 * int(expr6) + size10 := 8 * int(expr7) + size9 := size10 * int(expr8) + exproffset := 0 + totalSize := size1+size1+size2+size3+size4+size4+size6+size7+size8+size9+541 + buflen := len(buf) + if buflen < totalSize { + return sszutils.ErrFixedFieldsEOFFn(buflen, totalSize) + } + { // Field #0 'GenesisTime' (static) + buf := buf[0:8] + t.GenesisTime = binary.LittleEndian.Uint64(buf) + } + { // Field #1 'GenesisValidatorsRoot' (static) + buf := buf[8:40] + copy(t.GenesisValidatorsRoot[:], buf) + } + { // Field #2 'Slot' (static) + buf := buf[40:48] + t.Slot = phase0.Slot(binary.LittleEndian.Uint64(buf)) + } + { // Field #3 'Fork' (static) + buf := buf[48:64] + if t.Fork == nil { + t.Fork = new(phase0.Fork) + } + if err = t.Fork.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "Fork") + } + } + { // Field #4 'LatestBlockHeader' (static) + buf := buf[64:176] + if t.LatestBlockHeader == nil { + t.LatestBlockHeader = new(phase0.BeaconBlockHeader) + } + if err = t.LatestBlockHeader.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") + } + } + { // Field #5 'BlockRoots' (static) + buf := buf[176 : size1+176] + exproffset += int(size1) + val1 := t.BlockRoots + val1 = sszutils.ExpandSlice(val1, int(expr0)) + for idx1 := range int(expr0) { + buf := buf[32*idx1 : 32*(idx1+1)] + copy(val1[idx1][:], buf) + } + t.BlockRoots = val1 + } + { // Field #6 'StateRoots' (static) + buf := buf[exproffset+176 : exproffset+size1+176] + exproffset += int(size1) + val2 := t.StateRoots + val2 = sszutils.ExpandSlice(val2, int(expr0)) + for idx1 := range int(expr0) { + buf := buf[32*idx1 : 32*(idx1+1)] + copy(val2[idx1][:], buf) + } + t.StateRoots = val2 + } + // Field #7 'HistoricalRoots' (offset) + offset7 := int(binary.LittleEndian.Uint32(buf[exproffset+176 : exproffset+180])) + if offset7 != totalSize { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset7, totalSize), "HistoricalRoots:o") + } + { // Field #8 'ETH1Data' (static) + buf := buf[exproffset+180 : exproffset+252] + if t.ETH1Data == nil { + t.ETH1Data = new(phase0.ETH1Data) + } + if err = t.ETH1Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "ETH1Data") + } + } + // Field #9 'ETH1DataVotes' (offset) + offset9 := int(binary.LittleEndian.Uint32(buf[exproffset+252 : exproffset+256])) + if offset9 < offset7 || offset9 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset9, offset7, buflen), "ETH1DataVotes:o") + } + { // Field #10 'ETH1DepositIndex' (static) + buf := buf[exproffset+256 : exproffset+264] + t.ETH1DepositIndex = binary.LittleEndian.Uint64(buf) + } + // Field #11 'Validators' (offset) + offset11 := int(binary.LittleEndian.Uint32(buf[exproffset+264 : exproffset+268])) + if offset11 < offset9 || offset11 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset11, offset9, buflen), "Validators:o") + } + // Field #12 'Balances' (offset) + offset12 := int(binary.LittleEndian.Uint32(buf[exproffset+268 : exproffset+272])) + if offset12 < offset11 || offset12 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset12, offset11, buflen), "Balances:o") + } + { // Field #13 'RANDAOMixes' (static) + buf := buf[exproffset+272 : exproffset+size2+272] + exproffset += int(size2) + val3 := t.RANDAOMixes + val3 = sszutils.ExpandSlice(val3, int(expr1)) + for idx1 := range int(expr1) { + buf := buf[32*idx1 : 32*(idx1+1)] + copy(val3[idx1][:], buf) + } + t.RANDAOMixes = val3 + } + { // Field #14 'Slashings' (static) + buf := buf[exproffset+272 : exproffset+size3+272] + exproffset += int(size3) + val4 := t.Slashings + val4 = sszutils.ExpandSlice(val4, int(expr2)) + sszutils.UnmarshalUint64Slice(val4[:int(expr2)], buf) + t.Slashings = val4 + } + // Field #15 'PreviousEpochParticipation' (offset) + offset15 := int(binary.LittleEndian.Uint32(buf[exproffset+272 : exproffset+276])) + if offset15 < offset12 || offset15 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset15, offset12, buflen), "PreviousEpochParticipation:o") + } + // Field #16 'CurrentEpochParticipation' (offset) + offset16 := int(binary.LittleEndian.Uint32(buf[exproffset+276 : exproffset+280])) + if offset16 < offset15 || offset16 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset16, offset15, buflen), "CurrentEpochParticipation:o") + } + { // Field #17 'JustificationBits' (static) + buf := buf[exproffset+280 : exproffset+281] + t.JustificationBits = sszutils.ExpandSlice(t.JustificationBits, 1) + copy(t.JustificationBits[:], buf) + } + { // Field #18 'PreviousJustifiedCheckpoint' (static) + buf := buf[exproffset+281 : exproffset+321] + if t.PreviousJustifiedCheckpoint == nil { + t.PreviousJustifiedCheckpoint = new(phase0.Checkpoint) + } + if err = t.PreviousJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } + } + { // Field #19 'CurrentJustifiedCheckpoint' (static) + buf := buf[exproffset+321 : exproffset+361] + if t.CurrentJustifiedCheckpoint == nil { + t.CurrentJustifiedCheckpoint = new(phase0.Checkpoint) + } + if err = t.CurrentJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } + } + { // Field #20 'FinalizedCheckpoint' (static) + buf := buf[exproffset+361 : exproffset+401] + if t.FinalizedCheckpoint == nil { + t.FinalizedCheckpoint = new(phase0.Checkpoint) + } + if err = t.FinalizedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") + } + } + // Field #21 'InactivityScores' (offset) + offset21 := int(binary.LittleEndian.Uint32(buf[exproffset+401 : exproffset+405])) + if offset21 < offset16 || offset21 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset21, offset16, buflen), "InactivityScores:o") + } + { // Field #22 'CurrentSyncCommittee' (static) + buf := buf[exproffset+405 : exproffset+size4+405] + exproffset += int(size4) + val5 := t.CurrentSyncCommittee + if val5 == nil { + val5 = new(altair.SyncCommittee) + } + exproffset := 0 + totalSize := size5+48 + buflen := len(buf) + if buflen < totalSize { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, totalSize), "CurrentSyncCommittee") + } + { // Field #0 'Pubkeys' (static) + buf := buf[0 : size5+0] + exproffset += int(size5) + val6 := val5.Pubkeys + val6 = sszutils.ExpandSlice(val6, int(expr3)) + for idx1 := range int(expr3) { + buf := buf[48*idx1 : 48*(idx1+1)] + copy(val6[idx1][:], buf) + } + val5.Pubkeys = val6 + } + { // Field #1 'AggregatePubkey' (static) + buf := buf[exproffset+0 : exproffset+48] + copy(val5.AggregatePubkey[:], buf) + } + t.CurrentSyncCommittee = val5 + } + { // Field #23 'NextSyncCommittee' (static) + buf := buf[exproffset+405 : exproffset+size4+405] + exproffset += int(size4) + val7 := t.NextSyncCommittee + if val7 == nil { + val7 = new(altair.SyncCommittee) + } + exproffset := 0 + totalSize := size5+48 + buflen := len(buf) + if buflen < totalSize { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, totalSize), "NextSyncCommittee") + } + { // Field #0 'Pubkeys' (static) + buf := buf[0 : size5+0] + exproffset += int(size5) + val8 := val7.Pubkeys + val8 = sszutils.ExpandSlice(val8, int(expr3)) + for idx1 := range int(expr3) { + buf := buf[48*idx1 : 48*(idx1+1)] + copy(val8[idx1][:], buf) + } + val7.Pubkeys = val8 + } + { // Field #1 'AggregatePubkey' (static) + buf := buf[exproffset+0 : exproffset+48] + copy(val7.AggregatePubkey[:], buf) + } + t.NextSyncCommittee = val7 + } + { // Field #24 'LatestBlockHash' (static) + buf := buf[exproffset+405 : exproffset+437] + copy(t.LatestBlockHash[:], buf) + } + { // Field #25 'NextWithdrawalIndex' (static) + buf := buf[exproffset+437 : exproffset+445] + t.NextWithdrawalIndex = capella.WithdrawalIndex(binary.LittleEndian.Uint64(buf)) + } + { // Field #26 'NextWithdrawalValidatorIndex' (static) + buf := buf[exproffset+445 : exproffset+453] + t.NextWithdrawalValidatorIndex = phase0.ValidatorIndex(binary.LittleEndian.Uint64(buf)) + } + // Field #27 'HistoricalSummaries' (offset) + offset27 := int(binary.LittleEndian.Uint32(buf[exproffset+453 : exproffset+457])) + if offset27 < offset21 || offset27 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset27, offset21, buflen), "HistoricalSummaries:o") + } + { // Field #28 'DepositRequestsStartIndex' (static) + buf := buf[exproffset+457 : exproffset+465] + t.DepositRequestsStartIndex = binary.LittleEndian.Uint64(buf) + } + { // Field #29 'DepositBalanceToConsume' (static) + buf := buf[exproffset+465 : exproffset+473] + t.DepositBalanceToConsume = phase0.Gwei(binary.LittleEndian.Uint64(buf)) + } + { // Field #30 'ExitBalanceToConsume' (static) + buf := buf[exproffset+473 : exproffset+481] + t.ExitBalanceToConsume = phase0.Gwei(binary.LittleEndian.Uint64(buf)) + } + { // Field #31 'EarliestExitEpoch' (static) + buf := buf[exproffset+481 : exproffset+489] + t.EarliestExitEpoch = phase0.Epoch(binary.LittleEndian.Uint64(buf)) + } + { // Field #32 'ConsolidationBalanceToConsume' (static) + buf := buf[exproffset+489 : exproffset+497] + t.ConsolidationBalanceToConsume = phase0.Gwei(binary.LittleEndian.Uint64(buf)) + } + { // Field #33 'EarliestConsolidationEpoch' (static) + buf := buf[exproffset+497 : exproffset+505] + t.EarliestConsolidationEpoch = phase0.Epoch(binary.LittleEndian.Uint64(buf)) + } + // Field #34 'PendingDeposits' (offset) + offset34 := int(binary.LittleEndian.Uint32(buf[exproffset+505 : exproffset+509])) + if offset34 < offset27 || offset34 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset34, offset27, buflen), "PendingDeposits:o") + } + // Field #35 'PendingPartialWithdrawals' (offset) + offset35 := int(binary.LittleEndian.Uint32(buf[exproffset+509 : exproffset+513])) + if offset35 < offset34 || offset35 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset35, offset34, buflen), "PendingPartialWithdrawals:o") + } + // Field #36 'PendingConsolidations' (offset) + offset36 := int(binary.LittleEndian.Uint32(buf[exproffset+513 : exproffset+517])) + if offset36 < offset35 || offset36 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset36, offset35, buflen), "PendingConsolidations:o") + } + { // Field #37 'ProposerLookahead' (static) + buf := buf[exproffset+517 : exproffset+size6+517] + exproffset += int(size6) + val9 := t.ProposerLookahead + val9 = sszutils.ExpandSlice(val9, int(expr4)) + sszutils.UnmarshalUint64Slice(val9[:int(expr4)], buf) + t.ProposerLookahead = val9 + } + // Field #38 'Builders' (offset) + offset38 := int(binary.LittleEndian.Uint32(buf[exproffset+517 : exproffset+521])) + if offset38 < offset36 || offset38 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset38, offset36, buflen), "Builders:o") + } + { // Field #39 'NextWithdrawalBuilderIndex' (static) + buf := buf[exproffset+521 : exproffset+529] + t.NextWithdrawalBuilderIndex = gloas.BuilderIndex(binary.LittleEndian.Uint64(buf)) + } + { // Field #40 'ExecutionPayloadAvailability' (static) + buf := buf[exproffset+529 : exproffset+size7+529] + exproffset += int(size7) + t.ExecutionPayloadAvailability = sszutils.ExpandSlice(t.ExecutionPayloadAvailability, int(expr5)) + copy(t.ExecutionPayloadAvailability[:], buf) + } + { // Field #41 'BuilderPendingPayments' (static) + buf := buf[exproffset+529 : exproffset+size8+529] + exproffset += int(size8) + val10 := t.BuilderPendingPayments + val10 = sszutils.ExpandSlice(val10, int(expr6)) + for idx1 := range int(expr6) { + if val10[idx1] == nil { + val10[idx1] = new(gloas.BuilderPendingPayment) + } + buf := buf[44*idx1 : 44*(idx1+1)] + if err = val10[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "BuilderPendingPayments[%d]", idx1) + } + } + t.BuilderPendingPayments = val10 + } + // Field #42 'BuilderPendingWithdrawals' (offset) + offset42 := int(binary.LittleEndian.Uint32(buf[exproffset+529 : exproffset+533])) + if offset42 < offset38 || offset42 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset42, offset38, buflen), "BuilderPendingWithdrawals:o") + } + // Field #43 'LatestExecutionPayloadBid' (offset) + offset43 := int(binary.LittleEndian.Uint32(buf[exproffset+533 : exproffset+537])) + if offset43 < offset42 || offset43 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset43, offset42, buflen), "LatestExecutionPayloadBid:o") + } + // Field #44 'PayloadExpectedWithdrawals' (offset) + offset44 := int(binary.LittleEndian.Uint32(buf[exproffset+537 : exproffset+541])) + if offset44 < offset43 || offset44 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset44, offset43, buflen), "PayloadExpectedWithdrawals:o") + } + { // Field #45 'PTCWindow' (static) + buf := buf[exproffset+541 : exproffset+size9+541] + exproffset += int(size9) + val11 := t.PTCWindow + val11 = sszutils.ExpandSlice(val11, int(expr8)) + for idx1 := range int(expr8) { + val12 := val11[idx1] + buf := buf[size10*idx1 : size10*(idx1+1)] + val12 = sszutils.ExpandSlice(val12, int(expr7)) + sszutils.UnmarshalUint64Slice(val12[:int(expr7)], buf) + val11[idx1] = val12 + } + t.PTCWindow = val11 + } + { // Field #7 'HistoricalRoots' (dynamic) + buf := buf[offset7:offset9] + val13 := t.HistoricalRoots + itemCount := len(buf) / 32 + if len(buf)%32 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 32), "HistoricalRoots") + } + if itemCount > 16777216 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 16777216), "HistoricalRoots") + } + val13 = sszutils.ExpandSlice(val13, itemCount) + for idx1 := range itemCount { + buf := buf[32*idx1 : 32*(idx1+1)] + copy(val13[idx1][:], buf) + } + t.HistoricalRoots = val13 + } + { // Field #9 'ETH1DataVotes' (dynamic) + buf := buf[offset9:offset11] + val14 := t.ETH1DataVotes + itemCount := len(buf) / 72 + if len(buf)%72 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 72), "ETH1DataVotes") + } + if itemCount > int(expr9) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr9)), "ETH1DataVotes") + } + val14 = sszutils.ExpandSlice(val14, itemCount) + for idx1 := range itemCount { + if val14[idx1] == nil { + val14[idx1] = new(phase0.ETH1Data) + } + buf := buf[72*idx1 : 72*(idx1+1)] + if err = val14[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "ETH1DataVotes[%d]", idx1) + } + } + t.ETH1DataVotes = val14 + } + { // Field #11 'Validators' (dynamic) + buf := buf[offset11:offset12] + val15 := t.Validators + itemCount := len(buf) / 121 + if len(buf)%121 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 121), "Validators") + } + if itemCount > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1099511627776), "Validators") + } + val15 = sszutils.ExpandSlice(val15, itemCount) + for idx1 := range itemCount { + if val15[idx1] == nil { + val15[idx1] = new(phase0.Validator) + } + buf := buf[121*idx1 : 121*(idx1+1)] + if err = val15[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } + } + t.Validators = val15 + } + { // Field #12 'Balances' (dynamic) + buf := buf[offset12:offset15] + val16 := t.Balances + itemCount := len(buf) / 8 + if len(buf)%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 8), "Balances") + } + if itemCount > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1099511627776), "Balances") + } + val16 = sszutils.ExpandSlice(val16, itemCount) + sszutils.UnmarshalUint64Slice(val16, buf) + t.Balances = val16 + } + { // Field #15 'PreviousEpochParticipation' (dynamic) + buf := buf[offset15:offset16] + val17 := t.PreviousEpochParticipation + itemCount := len(buf) + if itemCount > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1099511627776), "PreviousEpochParticipation") + } + val17 = sszutils.ExpandSlice(val17, itemCount) + for idx1 := range itemCount { + buf := buf[1*idx1 : 1*(idx1+1)] + val17[idx1] = altair.ParticipationFlags(buf[0]) + } + t.PreviousEpochParticipation = val17 + } + { // Field #16 'CurrentEpochParticipation' (dynamic) + buf := buf[offset16:offset21] + val18 := t.CurrentEpochParticipation + itemCount := len(buf) + if itemCount > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1099511627776), "CurrentEpochParticipation") + } + val18 = sszutils.ExpandSlice(val18, itemCount) + for idx1 := range itemCount { + buf := buf[1*idx1 : 1*(idx1+1)] + val18[idx1] = altair.ParticipationFlags(buf[0]) + } + t.CurrentEpochParticipation = val18 + } + { // Field #21 'InactivityScores' (dynamic) + buf := buf[offset21:offset27] + val19 := t.InactivityScores + itemCount := len(buf) / 8 + if len(buf)%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 8), "InactivityScores") + } + if itemCount > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1099511627776), "InactivityScores") + } + val19 = sszutils.ExpandSlice(val19, itemCount) + sszutils.UnmarshalUint64Slice(val19, buf) + t.InactivityScores = val19 + } + { // Field #27 'HistoricalSummaries' (dynamic) + buf := buf[offset27:offset34] + val20 := t.HistoricalSummaries + itemCount := len(buf) / 64 + if len(buf)%64 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 64), "HistoricalSummaries") + } + if itemCount > 16777216 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 16777216), "HistoricalSummaries") + } + val20 = sszutils.ExpandSlice(val20, itemCount) + for idx1 := range itemCount { + if val20[idx1] == nil { + val20[idx1] = new(capella.HistoricalSummary) + } + buf := buf[64*idx1 : 64*(idx1+1)] + if err = val20[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "HistoricalSummaries[%d]", idx1) + } + } + t.HistoricalSummaries = val20 + } + { // Field #34 'PendingDeposits' (dynamic) + buf := buf[offset34:offset35] + val21 := t.PendingDeposits + itemCount := len(buf) / 192 + if len(buf)%192 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 192), "PendingDeposits") + } + if itemCount > int(expr10) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr10)), "PendingDeposits") + } + val21 = sszutils.ExpandSlice(val21, itemCount) + for idx1 := range itemCount { + if val21[idx1] == nil { + val21[idx1] = new(electra.PendingDeposit) + } + buf := buf[192*idx1 : 192*(idx1+1)] + if err = val21[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "PendingDeposits[%d]", idx1) + } + } + t.PendingDeposits = val21 + } + { // Field #35 'PendingPartialWithdrawals' (dynamic) + buf := buf[offset35:offset36] + val22 := t.PendingPartialWithdrawals + itemCount := len(buf) / 24 + if len(buf)%24 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 24), "PendingPartialWithdrawals") + } + if itemCount > int(expr11) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr11)), "PendingPartialWithdrawals") + } + val22 = sszutils.ExpandSlice(val22, itemCount) + for idx1 := range itemCount { + if val22[idx1] == nil { + val22[idx1] = new(electra.PendingPartialWithdrawal) + } + buf := buf[24*idx1 : 24*(idx1+1)] + if err = val22[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "PendingPartialWithdrawals[%d]", idx1) + } + } + t.PendingPartialWithdrawals = val22 + } + { // Field #36 'PendingConsolidations' (dynamic) + buf := buf[offset36:offset38] + val23 := t.PendingConsolidations + itemCount := len(buf) / 16 + if len(buf)%16 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 16), "PendingConsolidations") + } + if itemCount > int(expr12) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr12)), "PendingConsolidations") + } + val23 = sszutils.ExpandSlice(val23, itemCount) + for idx1 := range itemCount { + if val23[idx1] == nil { + val23[idx1] = new(electra.PendingConsolidation) + } + buf := buf[16*idx1 : 16*(idx1+1)] + if err = val23[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "PendingConsolidations[%d]", idx1) + } + } + t.PendingConsolidations = val23 + } + { // Field #38 'Builders' (dynamic) + buf := buf[offset38:offset42] + val24 := t.Builders + itemCount := len(buf) / 93 + if len(buf)%93 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 93), "Builders") + } + if itemCount > int(expr13) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr13)), "Builders") + } + val24 = sszutils.ExpandSlice(val24, itemCount) + for idx1 := range itemCount { + if val24[idx1] == nil { + val24[idx1] = new(gloas.Builder) + } + buf := buf[93*idx1 : 93*(idx1+1)] + if err = val24[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Builders[%d]", idx1) + } + } + t.Builders = val24 + } + { // Field #42 'BuilderPendingWithdrawals' (dynamic) + buf := buf[offset42:offset43] + val25 := t.BuilderPendingWithdrawals + itemCount := len(buf) / 36 + if len(buf)%36 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 36), "BuilderPendingWithdrawals") + } + if itemCount > int(expr14) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr14)), "BuilderPendingWithdrawals") + } + val25 = sszutils.ExpandSlice(val25, itemCount) + for idx1 := range itemCount { + if val25[idx1] == nil { + val25[idx1] = new(gloas.BuilderPendingWithdrawal) + } + buf := buf[36*idx1 : 36*(idx1+1)] + if err = val25[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "BuilderPendingWithdrawals[%d]", idx1) + } + } + t.BuilderPendingWithdrawals = val25 + } + { // Field #43 'LatestExecutionPayloadBid' (dynamic) + buf := buf[offset43:offset44] + if t.LatestExecutionPayloadBid == nil { + t.LatestExecutionPayloadBid = new(ExecutionPayloadBid) + } + if viewFn := t.LatestExecutionPayloadBid.UnmarshalSSZDynView((*gloas.ExecutionPayloadBid)(nil)); viewFn != nil { + if err = viewFn(ds, buf); err != nil { + return err + } + } else { + return sszutils.ErrNotImplemented + } + } + { // Field #44 'PayloadExpectedWithdrawals' (dynamic) + buf := buf[offset44:] + val26 := t.PayloadExpectedWithdrawals + itemCount := len(buf) / 44 + if len(buf)%44 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 44), "PayloadExpectedWithdrawals") + } + if itemCount > int(expr15) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr15)), "PayloadExpectedWithdrawals") + } + val26 = sszutils.ExpandSlice(val26, itemCount) + for idx1 := range itemCount { + if val26[idx1] == nil { + val26[idx1] = new(capella.Withdrawal) + } + buf := buf[44*idx1 : 44*(idx1+1)] + if err = val26[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "PayloadExpectedWithdrawals[%d]", idx1) + } + } + t.PayloadExpectedWithdrawals = val26 + } + return nil +} + +func (t *BeaconState) unmarshalSSZView_BeaconState_7(ds sszutils.DynamicSpecs, buf []byte) (err error) { + expr0, err := sszutils.ResolveSpecValueWithDefault(ds, "SLOTS_PER_HISTORICAL_ROOT", 8192) + if err != nil { + return err + } + expr1, err := sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_HISTORICAL_VECTOR", 65536) + if err != nil { + return err + } + expr2, err := sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_SLASHINGS_VECTOR", 8192) + if err != nil { + return err + } + expr3, err := sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE", 512) + if err != nil { + return err + } + expr4, err := sszutils.ResolveSpecValueWithDefault(ds, "(MIN_SEED_LOOKAHEAD+1)*SLOTS_PER_EPOCH", 64) + if err != nil { + return err + } + expr5, err := sszutils.ResolveSpecValueWithDefault(ds, "SLOTS_PER_HISTORICAL_ROOT/8", 1024) + if err != nil { + return err + } + expr6, err := sszutils.ResolveSpecValueWithDefault(ds, "SLOTS_PER_EPOCH*2", 64) + if err != nil { + return err + } + expr7, err := sszutils.ResolveSpecValueWithDefault(ds, "PTC_SIZE", 512) + if err != nil { + return err + } + expr8, err := sszutils.ResolveSpecValueWithDefault(ds, "(2+MIN_SEED_LOOKAHEAD)*SLOTS_PER_EPOCH", 96) + if err != nil { + return err + } + expr9, err := sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_ETH1_VOTING_PERIOD*SLOTS_PER_EPOCH", 2048) + if err != nil { + return err + } + expr10, err := sszutils.ResolveSpecValueWithDefault(ds, "PENDING_DEPOSITS_LIMIT", 134217728) + if err != nil { + return err + } + expr11, err := sszutils.ResolveSpecValueWithDefault(ds, "PENDING_PARTIAL_WITHDRAWALS_LIMIT", 134217728) + if err != nil { + return err + } + expr12, err := sszutils.ResolveSpecValueWithDefault(ds, "PENDING_CONSOLIDATIONS_LIMIT", 262144) + if err != nil { + return err + } + expr13, err := sszutils.ResolveSpecValueWithDefault(ds, "BUILDER_REGISTRY_LIMIT", 1099511627776) + if err != nil { + return err + } + expr14, err := sszutils.ResolveSpecValueWithDefault(ds, "BUILDER_PENDING_WITHDRAWALS_LIMIT", 1048576) + if err != nil { + return err + } + expr15, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_WITHDRAWALS_PER_PAYLOAD", 16) + if err != nil { + return err + } + size1 := 32 * int(expr0) + size2 := 32 * int(expr1) + size3 := 8 * int(expr2) + size5 := 48 * int(expr3) + size4 := size5 + 48 // size expression for '*SyncCommittee' + size6 := 8 * int(expr4) + size7 := 1 * int(expr5) + size8 := 44 * int(expr6) + size10 := 8 * int(expr7) + size9 := size10 * int(expr8) + exproffset := 0 + totalSize := size1+size1+size2+size3+size4+size4+size6+size7+size8+size9+541 + buflen := len(buf) + if buflen < totalSize { + return sszutils.ErrFixedFieldsEOFFn(buflen, totalSize) + } + { // Field #0 'GenesisTime' (static) + buf := buf[0:8] + t.GenesisTime = binary.LittleEndian.Uint64(buf) + } + { // Field #1 'GenesisValidatorsRoot' (static) + buf := buf[8:40] + copy(t.GenesisValidatorsRoot[:], buf) + } + { // Field #2 'Slot' (static) + buf := buf[40:48] + t.Slot = phase0.Slot(binary.LittleEndian.Uint64(buf)) + } + { // Field #3 'Fork' (static) + buf := buf[48:64] + if t.Fork == nil { + t.Fork = new(phase0.Fork) + } + if err = t.Fork.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "Fork") + } + } + { // Field #4 'LatestBlockHeader' (static) + buf := buf[64:176] + if t.LatestBlockHeader == nil { + t.LatestBlockHeader = new(phase0.BeaconBlockHeader) + } + if err = t.LatestBlockHeader.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") + } + } + { // Field #5 'BlockRoots' (static) + buf := buf[176 : size1+176] + exproffset += int(size1) + val1 := t.BlockRoots + val1 = sszutils.ExpandSlice(val1, int(expr0)) + for idx1 := range int(expr0) { + buf := buf[32*idx1 : 32*(idx1+1)] + copy(val1[idx1][:], buf) + } + t.BlockRoots = val1 + } + { // Field #6 'StateRoots' (static) + buf := buf[exproffset+176 : exproffset+size1+176] + exproffset += int(size1) + val2 := t.StateRoots + val2 = sszutils.ExpandSlice(val2, int(expr0)) + for idx1 := range int(expr0) { + buf := buf[32*idx1 : 32*(idx1+1)] + copy(val2[idx1][:], buf) + } + t.StateRoots = val2 + } + // Field #7 'HistoricalRoots' (offset) + offset7 := int(binary.LittleEndian.Uint32(buf[exproffset+176 : exproffset+180])) + if offset7 != totalSize { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset7, totalSize), "HistoricalRoots:o") + } + { // Field #8 'ETH1Data' (static) + buf := buf[exproffset+180 : exproffset+252] + if t.ETH1Data == nil { + t.ETH1Data = new(phase0.ETH1Data) + } + if err = t.ETH1Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "ETH1Data") + } + } + // Field #9 'ETH1DataVotes' (offset) + offset9 := int(binary.LittleEndian.Uint32(buf[exproffset+252 : exproffset+256])) + if offset9 < offset7 || offset9 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset9, offset7, buflen), "ETH1DataVotes:o") + } + { // Field #10 'ETH1DepositIndex' (static) + buf := buf[exproffset+256 : exproffset+264] + t.ETH1DepositIndex = binary.LittleEndian.Uint64(buf) + } + // Field #11 'Validators' (offset) + offset11 := int(binary.LittleEndian.Uint32(buf[exproffset+264 : exproffset+268])) + if offset11 < offset9 || offset11 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset11, offset9, buflen), "Validators:o") + } + // Field #12 'Balances' (offset) + offset12 := int(binary.LittleEndian.Uint32(buf[exproffset+268 : exproffset+272])) + if offset12 < offset11 || offset12 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset12, offset11, buflen), "Balances:o") + } + { // Field #13 'RANDAOMixes' (static) + buf := buf[exproffset+272 : exproffset+size2+272] + exproffset += int(size2) + val3 := t.RANDAOMixes + val3 = sszutils.ExpandSlice(val3, int(expr1)) + for idx1 := range int(expr1) { + buf := buf[32*idx1 : 32*(idx1+1)] + copy(val3[idx1][:], buf) + } + t.RANDAOMixes = val3 + } + { // Field #14 'Slashings' (static) + buf := buf[exproffset+272 : exproffset+size3+272] + exproffset += int(size3) + val4 := t.Slashings + val4 = sszutils.ExpandSlice(val4, int(expr2)) + sszutils.UnmarshalUint64Slice(val4[:int(expr2)], buf) + t.Slashings = val4 + } + // Field #15 'PreviousEpochParticipation' (offset) + offset15 := int(binary.LittleEndian.Uint32(buf[exproffset+272 : exproffset+276])) + if offset15 < offset12 || offset15 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset15, offset12, buflen), "PreviousEpochParticipation:o") + } + // Field #16 'CurrentEpochParticipation' (offset) + offset16 := int(binary.LittleEndian.Uint32(buf[exproffset+276 : exproffset+280])) + if offset16 < offset15 || offset16 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset16, offset15, buflen), "CurrentEpochParticipation:o") + } + { // Field #17 'JustificationBits' (static) + buf := buf[exproffset+280 : exproffset+281] + t.JustificationBits = sszutils.ExpandSlice(t.JustificationBits, 1) + copy(t.JustificationBits[:], buf) + } + { // Field #18 'PreviousJustifiedCheckpoint' (static) + buf := buf[exproffset+281 : exproffset+321] + if t.PreviousJustifiedCheckpoint == nil { + t.PreviousJustifiedCheckpoint = new(phase0.Checkpoint) + } + if err = t.PreviousJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } + } + { // Field #19 'CurrentJustifiedCheckpoint' (static) + buf := buf[exproffset+321 : exproffset+361] + if t.CurrentJustifiedCheckpoint == nil { + t.CurrentJustifiedCheckpoint = new(phase0.Checkpoint) + } + if err = t.CurrentJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } + } + { // Field #20 'FinalizedCheckpoint' (static) + buf := buf[exproffset+361 : exproffset+401] + if t.FinalizedCheckpoint == nil { + t.FinalizedCheckpoint = new(phase0.Checkpoint) + } + if err = t.FinalizedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") + } + } + // Field #21 'InactivityScores' (offset) + offset21 := int(binary.LittleEndian.Uint32(buf[exproffset+401 : exproffset+405])) + if offset21 < offset16 || offset21 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset21, offset16, buflen), "InactivityScores:o") + } + { // Field #22 'CurrentSyncCommittee' (static) + buf := buf[exproffset+405 : exproffset+size4+405] + exproffset += int(size4) + val5 := t.CurrentSyncCommittee + if val5 == nil { + val5 = new(altair.SyncCommittee) + } + exproffset := 0 + totalSize := size5+48 + buflen := len(buf) + if buflen < totalSize { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, totalSize), "CurrentSyncCommittee") + } + { // Field #0 'Pubkeys' (static) + buf := buf[0 : size5+0] + exproffset += int(size5) + val6 := val5.Pubkeys + val6 = sszutils.ExpandSlice(val6, int(expr3)) + for idx1 := range int(expr3) { + buf := buf[48*idx1 : 48*(idx1+1)] + copy(val6[idx1][:], buf) + } + val5.Pubkeys = val6 + } + { // Field #1 'AggregatePubkey' (static) + buf := buf[exproffset+0 : exproffset+48] + copy(val5.AggregatePubkey[:], buf) + } + t.CurrentSyncCommittee = val5 + } + { // Field #23 'NextSyncCommittee' (static) + buf := buf[exproffset+405 : exproffset+size4+405] + exproffset += int(size4) + val7 := t.NextSyncCommittee + if val7 == nil { + val7 = new(altair.SyncCommittee) + } + exproffset := 0 + totalSize := size5+48 + buflen := len(buf) + if buflen < totalSize { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, totalSize), "NextSyncCommittee") + } + { // Field #0 'Pubkeys' (static) + buf := buf[0 : size5+0] + exproffset += int(size5) + val8 := val7.Pubkeys + val8 = sszutils.ExpandSlice(val8, int(expr3)) + for idx1 := range int(expr3) { + buf := buf[48*idx1 : 48*(idx1+1)] + copy(val8[idx1][:], buf) + } + val7.Pubkeys = val8 + } + { // Field #1 'AggregatePubkey' (static) + buf := buf[exproffset+0 : exproffset+48] + copy(val7.AggregatePubkey[:], buf) + } + t.NextSyncCommittee = val7 + } + { // Field #24 'LatestBlockHash' (static) + buf := buf[exproffset+405 : exproffset+437] + copy(t.LatestBlockHash[:], buf) + } + { // Field #25 'NextWithdrawalIndex' (static) + buf := buf[exproffset+437 : exproffset+445] + t.NextWithdrawalIndex = capella.WithdrawalIndex(binary.LittleEndian.Uint64(buf)) + } + { // Field #26 'NextWithdrawalValidatorIndex' (static) + buf := buf[exproffset+445 : exproffset+453] + t.NextWithdrawalValidatorIndex = phase0.ValidatorIndex(binary.LittleEndian.Uint64(buf)) + } + // Field #27 'HistoricalSummaries' (offset) + offset27 := int(binary.LittleEndian.Uint32(buf[exproffset+453 : exproffset+457])) + if offset27 < offset21 || offset27 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset27, offset21, buflen), "HistoricalSummaries:o") + } + { // Field #28 'DepositRequestsStartIndex' (static) + buf := buf[exproffset+457 : exproffset+465] + t.DepositRequestsStartIndex = binary.LittleEndian.Uint64(buf) + } + { // Field #29 'DepositBalanceToConsume' (static) + buf := buf[exproffset+465 : exproffset+473] + t.DepositBalanceToConsume = phase0.Gwei(binary.LittleEndian.Uint64(buf)) + } + { // Field #30 'ExitBalanceToConsume' (static) + buf := buf[exproffset+473 : exproffset+481] + t.ExitBalanceToConsume = phase0.Gwei(binary.LittleEndian.Uint64(buf)) + } + { // Field #31 'EarliestExitEpoch' (static) + buf := buf[exproffset+481 : exproffset+489] + t.EarliestExitEpoch = phase0.Epoch(binary.LittleEndian.Uint64(buf)) + } + { // Field #32 'ConsolidationBalanceToConsume' (static) + buf := buf[exproffset+489 : exproffset+497] + t.ConsolidationBalanceToConsume = phase0.Gwei(binary.LittleEndian.Uint64(buf)) + } + { // Field #33 'EarliestConsolidationEpoch' (static) + buf := buf[exproffset+497 : exproffset+505] + t.EarliestConsolidationEpoch = phase0.Epoch(binary.LittleEndian.Uint64(buf)) + } + // Field #34 'PendingDeposits' (offset) + offset34 := int(binary.LittleEndian.Uint32(buf[exproffset+505 : exproffset+509])) + if offset34 < offset27 || offset34 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset34, offset27, buflen), "PendingDeposits:o") + } + // Field #35 'PendingPartialWithdrawals' (offset) + offset35 := int(binary.LittleEndian.Uint32(buf[exproffset+509 : exproffset+513])) + if offset35 < offset34 || offset35 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset35, offset34, buflen), "PendingPartialWithdrawals:o") + } + // Field #36 'PendingConsolidations' (offset) + offset36 := int(binary.LittleEndian.Uint32(buf[exproffset+513 : exproffset+517])) + if offset36 < offset35 || offset36 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset36, offset35, buflen), "PendingConsolidations:o") + } + { // Field #37 'ProposerLookahead' (static) + buf := buf[exproffset+517 : exproffset+size6+517] + exproffset += int(size6) + val9 := t.ProposerLookahead + val9 = sszutils.ExpandSlice(val9, int(expr4)) + sszutils.UnmarshalUint64Slice(val9[:int(expr4)], buf) + t.ProposerLookahead = val9 + } + // Field #38 'Builders' (offset) + offset38 := int(binary.LittleEndian.Uint32(buf[exproffset+517 : exproffset+521])) + if offset38 < offset36 || offset38 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset38, offset36, buflen), "Builders:o") + } + { // Field #39 'NextWithdrawalBuilderIndex' (static) + buf := buf[exproffset+521 : exproffset+529] + t.NextWithdrawalBuilderIndex = gloas.BuilderIndex(binary.LittleEndian.Uint64(buf)) + } + { // Field #40 'ExecutionPayloadAvailability' (static) + buf := buf[exproffset+529 : exproffset+size7+529] + exproffset += int(size7) + t.ExecutionPayloadAvailability = sszutils.ExpandSlice(t.ExecutionPayloadAvailability, int(expr5)) + copy(t.ExecutionPayloadAvailability[:], buf) + } + { // Field #41 'BuilderPendingPayments' (static) + buf := buf[exproffset+529 : exproffset+size8+529] + exproffset += int(size8) + val10 := t.BuilderPendingPayments + val10 = sszutils.ExpandSlice(val10, int(expr6)) + for idx1 := range int(expr6) { + if val10[idx1] == nil { + val10[idx1] = new(gloas.BuilderPendingPayment) + } + buf := buf[44*idx1 : 44*(idx1+1)] + if err = val10[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "BuilderPendingPayments[%d]", idx1) + } + } + t.BuilderPendingPayments = val10 + } + // Field #42 'BuilderPendingWithdrawals' (offset) + offset42 := int(binary.LittleEndian.Uint32(buf[exproffset+529 : exproffset+533])) + if offset42 < offset38 || offset42 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset42, offset38, buflen), "BuilderPendingWithdrawals:o") + } + // Field #43 'LatestExecutionPayloadBid' (offset) + offset43 := int(binary.LittleEndian.Uint32(buf[exproffset+533 : exproffset+537])) + if offset43 < offset42 || offset43 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset43, offset42, buflen), "LatestExecutionPayloadBid:o") + } + // Field #44 'PayloadExpectedWithdrawals' (offset) + offset44 := int(binary.LittleEndian.Uint32(buf[exproffset+537 : exproffset+541])) + if offset44 < offset43 || offset44 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset44, offset43, buflen), "PayloadExpectedWithdrawals:o") + } + { // Field #45 'PTCWindow' (static) + buf := buf[exproffset+541 : exproffset+size9+541] + exproffset += int(size9) + val11 := t.PTCWindow + val11 = sszutils.ExpandSlice(val11, int(expr8)) + for idx1 := range int(expr8) { + val12 := val11[idx1] + buf := buf[size10*idx1 : size10*(idx1+1)] + val12 = sszutils.ExpandSlice(val12, int(expr7)) + sszutils.UnmarshalUint64Slice(val12[:int(expr7)], buf) + val11[idx1] = val12 + } + t.PTCWindow = val11 + } + { // Field #7 'HistoricalRoots' (dynamic) + buf := buf[offset7:offset9] + val13 := t.HistoricalRoots + itemCount := len(buf) / 32 + if len(buf)%32 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 32), "HistoricalRoots") + } + if itemCount > 16777216 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 16777216), "HistoricalRoots") + } + val13 = sszutils.ExpandSlice(val13, itemCount) + for idx1 := range itemCount { + buf := buf[32*idx1 : 32*(idx1+1)] + copy(val13[idx1][:], buf) + } + t.HistoricalRoots = val13 + } + { // Field #9 'ETH1DataVotes' (dynamic) + buf := buf[offset9:offset11] + val14 := t.ETH1DataVotes + itemCount := len(buf) / 72 + if len(buf)%72 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 72), "ETH1DataVotes") + } + if itemCount > int(expr9) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr9)), "ETH1DataVotes") + } + val14 = sszutils.ExpandSlice(val14, itemCount) + for idx1 := range itemCount { + if val14[idx1] == nil { + val14[idx1] = new(phase0.ETH1Data) + } + buf := buf[72*idx1 : 72*(idx1+1)] + if err = val14[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "ETH1DataVotes[%d]", idx1) + } + } + t.ETH1DataVotes = val14 + } + { // Field #11 'Validators' (dynamic) + buf := buf[offset11:offset12] + val15 := t.Validators + itemCount := len(buf) / 121 + if len(buf)%121 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 121), "Validators") + } + if itemCount > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1099511627776), "Validators") + } + val15 = sszutils.ExpandSlice(val15, itemCount) + for idx1 := range itemCount { + if val15[idx1] == nil { + val15[idx1] = new(phase0.Validator) + } + buf := buf[121*idx1 : 121*(idx1+1)] + if err = val15[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } + } + t.Validators = val15 + } + { // Field #12 'Balances' (dynamic) + buf := buf[offset12:offset15] + val16 := t.Balances + itemCount := len(buf) / 8 + if len(buf)%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 8), "Balances") + } + if itemCount > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1099511627776), "Balances") + } + val16 = sszutils.ExpandSlice(val16, itemCount) + sszutils.UnmarshalUint64Slice(val16, buf) + t.Balances = val16 + } + { // Field #15 'PreviousEpochParticipation' (dynamic) + buf := buf[offset15:offset16] + val17 := t.PreviousEpochParticipation + itemCount := len(buf) + if itemCount > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1099511627776), "PreviousEpochParticipation") + } + val17 = sszutils.ExpandSlice(val17, itemCount) + for idx1 := range itemCount { + buf := buf[1*idx1 : 1*(idx1+1)] + val17[idx1] = altair.ParticipationFlags(buf[0]) + } + t.PreviousEpochParticipation = val17 + } + { // Field #16 'CurrentEpochParticipation' (dynamic) + buf := buf[offset16:offset21] + val18 := t.CurrentEpochParticipation + itemCount := len(buf) + if itemCount > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1099511627776), "CurrentEpochParticipation") + } + val18 = sszutils.ExpandSlice(val18, itemCount) + for idx1 := range itemCount { + buf := buf[1*idx1 : 1*(idx1+1)] + val18[idx1] = altair.ParticipationFlags(buf[0]) + } + t.CurrentEpochParticipation = val18 + } + { // Field #21 'InactivityScores' (dynamic) + buf := buf[offset21:offset27] + val19 := t.InactivityScores + itemCount := len(buf) / 8 + if len(buf)%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 8), "InactivityScores") + } + if itemCount > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1099511627776), "InactivityScores") + } + val19 = sszutils.ExpandSlice(val19, itemCount) + sszutils.UnmarshalUint64Slice(val19, buf) + t.InactivityScores = val19 + } + { // Field #27 'HistoricalSummaries' (dynamic) + buf := buf[offset27:offset34] + val20 := t.HistoricalSummaries + itemCount := len(buf) / 64 + if len(buf)%64 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 64), "HistoricalSummaries") + } + if itemCount > 16777216 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 16777216), "HistoricalSummaries") + } + val20 = sszutils.ExpandSlice(val20, itemCount) + for idx1 := range itemCount { + if val20[idx1] == nil { + val20[idx1] = new(capella.HistoricalSummary) + } + buf := buf[64*idx1 : 64*(idx1+1)] + if err = val20[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "HistoricalSummaries[%d]", idx1) + } + } + t.HistoricalSummaries = val20 + } + { // Field #34 'PendingDeposits' (dynamic) + buf := buf[offset34:offset35] + val21 := t.PendingDeposits + itemCount := len(buf) / 192 + if len(buf)%192 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 192), "PendingDeposits") + } + if itemCount > int(expr10) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr10)), "PendingDeposits") + } + val21 = sszutils.ExpandSlice(val21, itemCount) + for idx1 := range itemCount { + if val21[idx1] == nil { + val21[idx1] = new(electra.PendingDeposit) + } + buf := buf[192*idx1 : 192*(idx1+1)] + if err = val21[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "PendingDeposits[%d]", idx1) + } + } + t.PendingDeposits = val21 + } + { // Field #35 'PendingPartialWithdrawals' (dynamic) + buf := buf[offset35:offset36] + val22 := t.PendingPartialWithdrawals + itemCount := len(buf) / 24 + if len(buf)%24 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 24), "PendingPartialWithdrawals") + } + if itemCount > int(expr11) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr11)), "PendingPartialWithdrawals") + } + val22 = sszutils.ExpandSlice(val22, itemCount) + for idx1 := range itemCount { + if val22[idx1] == nil { + val22[idx1] = new(electra.PendingPartialWithdrawal) + } + buf := buf[24*idx1 : 24*(idx1+1)] + if err = val22[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "PendingPartialWithdrawals[%d]", idx1) + } + } + t.PendingPartialWithdrawals = val22 + } + { // Field #36 'PendingConsolidations' (dynamic) + buf := buf[offset36:offset38] + val23 := t.PendingConsolidations + itemCount := len(buf) / 16 + if len(buf)%16 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 16), "PendingConsolidations") + } + if itemCount > int(expr12) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr12)), "PendingConsolidations") + } + val23 = sszutils.ExpandSlice(val23, itemCount) + for idx1 := range itemCount { + if val23[idx1] == nil { + val23[idx1] = new(electra.PendingConsolidation) + } + buf := buf[16*idx1 : 16*(idx1+1)] + if err = val23[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "PendingConsolidations[%d]", idx1) + } + } + t.PendingConsolidations = val23 + } + { // Field #38 'Builders' (dynamic) + buf := buf[offset38:offset42] + val24 := t.Builders + itemCount := len(buf) / 93 + if len(buf)%93 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 93), "Builders") + } + if itemCount > int(expr13) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr13)), "Builders") + } + val24 = sszutils.ExpandSlice(val24, itemCount) + for idx1 := range itemCount { + if val24[idx1] == nil { + val24[idx1] = new(gloas.Builder) + } + buf := buf[93*idx1 : 93*(idx1+1)] + if err = val24[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Builders[%d]", idx1) + } + } + t.Builders = val24 + } + { // Field #42 'BuilderPendingWithdrawals' (dynamic) + buf := buf[offset42:offset43] + val25 := t.BuilderPendingWithdrawals + itemCount := len(buf) / 36 + if len(buf)%36 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 36), "BuilderPendingWithdrawals") + } + if itemCount > int(expr14) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr14)), "BuilderPendingWithdrawals") + } + val25 = sszutils.ExpandSlice(val25, itemCount) + for idx1 := range itemCount { + if val25[idx1] == nil { + val25[idx1] = new(gloas.BuilderPendingWithdrawal) + } + buf := buf[36*idx1 : 36*(idx1+1)] + if err = val25[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "BuilderPendingWithdrawals[%d]", idx1) + } + } + t.BuilderPendingWithdrawals = val25 + } + { // Field #43 'LatestExecutionPayloadBid' (dynamic) + buf := buf[offset43:offset44] + if t.LatestExecutionPayloadBid == nil { + t.LatestExecutionPayloadBid = new(ExecutionPayloadBid) + } + if viewFn := t.LatestExecutionPayloadBid.UnmarshalSSZDynView((*heze.ExecutionPayloadBid)(nil)); viewFn != nil { + if err = viewFn(ds, buf); err != nil { + return err + } + } else { + return sszutils.ErrNotImplemented + } + } + { // Field #44 'PayloadExpectedWithdrawals' (dynamic) + buf := buf[offset44:] + val26 := t.PayloadExpectedWithdrawals + itemCount := len(buf) / 44 + if len(buf)%44 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 44), "PayloadExpectedWithdrawals") + } + if itemCount > int(expr15) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr15)), "PayloadExpectedWithdrawals") + } + val26 = sszutils.ExpandSlice(val26, itemCount) + for idx1 := range itemCount { + if val26[idx1] == nil { + val26[idx1] = new(capella.Withdrawal) + } + buf := buf[44*idx1 : 44*(idx1+1)] + if err = val26[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "PayloadExpectedWithdrawals[%d]", idx1) + } + } + t.PayloadExpectedWithdrawals = val26 + } + return nil +} + +func (t *BeaconState) UnmarshalSSZDecoderView(view any) func(ds sszutils.DynamicSpecs, dec sszutils.Decoder) error { + switch view.(type) { + case *phase0.BeaconState: + return t.unmarshalSSZDecoderView_BeaconState case *altair.BeaconState: - return t.unmarshalSSZView_BeaconState_0 + return t.unmarshalSSZDecoderView_BeaconState_0 case *bellatrix.BeaconState: - return t.unmarshalSSZView_BeaconState_1 + return t.unmarshalSSZDecoderView_BeaconState_1 case *capella.BeaconState: - return t.unmarshalSSZView_BeaconState_2 + return t.unmarshalSSZDecoderView_BeaconState_2 case *deneb.BeaconState: - return t.unmarshalSSZView_BeaconState_3 + return t.unmarshalSSZDecoderView_BeaconState_3 case *electra.BeaconState: - return t.unmarshalSSZView_BeaconState_4 + return t.unmarshalSSZDecoderView_BeaconState_4 case *fulu.BeaconState: - return t.unmarshalSSZView_BeaconState_5 + return t.unmarshalSSZDecoderView_BeaconState_5 case *gloas.BeaconState: - return t.unmarshalSSZView_BeaconState_6 + return t.unmarshalSSZDecoderView_BeaconState_6 case *heze.BeaconState: - return t.unmarshalSSZView_BeaconState_7 + return t.unmarshalSSZDecoderView_BeaconState_7 } return nil } -func (t *BeaconState) unmarshalSSZView_BeaconState(ds sszutils.DynamicSpecs, buf []byte) (err error) { +func (t *BeaconState) unmarshalSSZDecoderView_BeaconState(ds sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { expr0, err := sszutils.ResolveSpecValueWithDefault(ds, "SLOTS_PER_HISTORICAL_ROOT", 8192) if err != nil { return err @@ -3739,319 +13556,468 @@ func (t *BeaconState) unmarshalSSZView_BeaconState(ds sszutils.DynamicSpecs, buf size1 := 32 * int(expr0) size2 := 32 * int(expr1) size3 := 8 * int(expr2) - exproffset := 0 + canSeek := dec.Seekable() + offsetSlices := [1][]uint32{ + sszutils.GetOffsetSlice(0), + } + defer func() { + sszutils.PutOffsetSlice(offsetSlices[0]) + }() totalSize := size1+size1+size2+size3+401 - buflen := len(buf) - if buflen < totalSize { - return sszutils.ErrFixedFieldsEOFFn(buflen, totalSize) + maxOffset := uint32(dec.GetLength()) + startPos0 := dec.GetPosition() + if maxOffset < uint32(totalSize) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(totalSize)) + } + // Field #0 'GenesisTime' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "GenesisTime") + } else { + t.GenesisTime = val + } + // Field #1 'GenesisValidatorsRoot' (static) + if _, err = dec.DecodeBytes(t.GenesisValidatorsRoot[:32]); err != nil { + return err } - { // Field #0 'GenesisTime' (static) - buf := buf[0:8] - t.GenesisTime = binary.LittleEndian.Uint64(buf) + // Field #2 'Slot' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "Slot") + } else { + t.Slot = phase0.Slot(val) } - { // Field #1 'GenesisValidatorsRoot' (static) - buf := buf[8:40] - copy(t.GenesisValidatorsRoot[:], buf) + // Field #3 'Fork' (static) + if t.Fork == nil { + t.Fork = new(phase0.Fork) } - { // Field #2 'Slot' (static) - buf := buf[40:48] - t.Slot = phase0.Slot(binary.LittleEndian.Uint64(buf)) + if buf, err := dec.DecodeBytesBuf(16); err != nil { + return sszutils.ErrorWithPath(err, "Fork") + } else if err = t.Fork.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "Fork") } - { // Field #3 'Fork' (static) - buf := buf[48:64] - if t.Fork == nil { - t.Fork = new(phase0.Fork) - } - if err = t.Fork.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "Fork") - } + // Field #4 'LatestBlockHeader' (static) + if t.LatestBlockHeader == nil { + t.LatestBlockHeader = new(phase0.BeaconBlockHeader) } - { // Field #4 'LatestBlockHeader' (static) - buf := buf[64:176] - if t.LatestBlockHeader == nil { - t.LatestBlockHeader = new(phase0.BeaconBlockHeader) - } - if err = t.LatestBlockHeader.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "LatestBlockHeader") - } + if buf, err := dec.DecodeBytesBuf(112); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") + } else if err = t.LatestBlockHeader.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") } { // Field #5 'BlockRoots' (static) - buf := buf[176 : size1+176] - exproffset += int(size1) val1 := t.BlockRoots val1 = sszutils.ExpandSlice(val1, int(expr0)) + startPos1 := dec.GetPosition() for idx1 := range int(expr0) { - buf := buf[32*idx1 : 32*(idx1+1)] - copy(val1[idx1][:], buf) + if _, err = dec.DecodeBytes(val1[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos1+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos1+int(32*(idx1+1))), "BlockRoots[%d]", idx1) + } } t.BlockRoots = val1 } { // Field #6 'StateRoots' (static) - buf := buf[exproffset+176 : exproffset+size1+176] - exproffset += int(size1) val2 := t.StateRoots val2 = sszutils.ExpandSlice(val2, int(expr0)) + startPos2 := dec.GetPosition() for idx1 := range int(expr0) { - buf := buf[32*idx1 : 32*(idx1+1)] - copy(val2[idx1][:], buf) + if _, err = dec.DecodeBytes(val2[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos2+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos2+int(32*(idx1+1))), "StateRoots[%d]", idx1) + } } t.StateRoots = val2 } // Field #7 'HistoricalRoots' (offset) - offset7 := int(binary.LittleEndian.Uint32(buf[exproffset+176 : exproffset+180])) - if offset7 != totalSize { - return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset7, totalSize), "HistoricalRoots:o") + offset7, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "HistoricalRoots") } - { // Field #8 'ETH1Data' (static) - buf := buf[exproffset+180 : exproffset+252] - if t.ETH1Data == nil { - t.ETH1Data = new(phase0.ETH1Data) - } - if err = t.ETH1Data.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "ETH1Data") - } + if offset7 != uint32(totalSize) { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset7, totalSize), "HistoricalRoots") + } + // Field #8 'ETH1Data' (static) + if t.ETH1Data == nil { + t.ETH1Data = new(phase0.ETH1Data) + } + if buf, err := dec.DecodeBytesBuf(72); err != nil { + return sszutils.ErrorWithPath(err, "ETH1Data") + } else if err = t.ETH1Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "ETH1Data") } // Field #9 'ETH1DataVotes' (offset) - offset9 := int(binary.LittleEndian.Uint32(buf[exproffset+252 : exproffset+256])) - if offset9 < offset7 || offset9 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset9, offset7, buflen), "ETH1DataVotes:o") + offset9, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "ETH1DataVotes") } - { // Field #10 'ETH1DepositIndex' (static) - buf := buf[exproffset+256 : exproffset+264] - t.ETH1DepositIndex = binary.LittleEndian.Uint64(buf) + if offset9 < offset7 || offset9 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset9, offset7, maxOffset), "ETH1DataVotes") + } + // Field #10 'ETH1DepositIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "ETH1DepositIndex") + } else { + t.ETH1DepositIndex = val } // Field #11 'Validators' (offset) - offset11 := int(binary.LittleEndian.Uint32(buf[exproffset+264 : exproffset+268])) - if offset11 < offset9 || offset11 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset11, offset9, buflen), "Validators:o") + offset11, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Validators") + } + if offset11 < offset9 || offset11 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset11, offset9, maxOffset), "Validators") } // Field #12 'Balances' (offset) - offset12 := int(binary.LittleEndian.Uint32(buf[exproffset+268 : exproffset+272])) - if offset12 < offset11 || offset12 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset12, offset11, buflen), "Balances:o") + offset12, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Balances") + } + if offset12 < offset11 || offset12 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset12, offset11, maxOffset), "Balances") } { // Field #13 'RANDAOMixes' (static) - buf := buf[exproffset+272 : exproffset+size2+272] - exproffset += int(size2) val3 := t.RANDAOMixes val3 = sszutils.ExpandSlice(val3, int(expr1)) + startPos3 := dec.GetPosition() for idx1 := range int(expr1) { - buf := buf[32*idx1 : 32*(idx1+1)] - copy(val3[idx1][:], buf) + if _, err = dec.DecodeBytes(val3[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos3+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos3+int(32*(idx1+1))), "RANDAOMixes[%d]", idx1) + } } t.RANDAOMixes = val3 } { // Field #14 'Slashings' (static) - buf := buf[exproffset+272 : exproffset+size3+272] - exproffset += int(size3) val4 := t.Slashings val4 = sszutils.ExpandSlice(val4, int(expr2)) - sszutils.UnmarshalUint64Slice(val4[:int(expr2)], buf) + if err = sszutils.DecodeUint64Slice(dec, val4[:int(expr2)]); err != nil { + return sszutils.ErrorWithPath(err, "Slashings") + } t.Slashings = val4 } // Field #15 'PreviousEpochAttestations' (offset) - offset15 := int(binary.LittleEndian.Uint32(buf[exproffset+272 : exproffset+276])) - if offset15 < offset12 || offset15 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset15, offset12, buflen), "PreviousEpochAttestations:o") + offset15, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "PreviousEpochAttestations") + } + if offset15 < offset12 || offset15 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset15, offset12, maxOffset), "PreviousEpochAttestations") } // Field #16 'CurrentEpochAttestations' (offset) - offset16 := int(binary.LittleEndian.Uint32(buf[exproffset+276 : exproffset+280])) - if offset16 < offset15 || offset16 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset16, offset15, buflen), "CurrentEpochAttestations:o") + offset16, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "CurrentEpochAttestations") } - { // Field #17 'JustificationBits' (static) - buf := buf[exproffset+280 : exproffset+281] - t.JustificationBits = sszutils.ExpandSlice(t.JustificationBits, 1) - copy(t.JustificationBits[:], buf) + if offset16 < offset15 || offset16 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset16, offset15, maxOffset), "CurrentEpochAttestations") } - { // Field #18 'PreviousJustifiedCheckpoint' (static) - buf := buf[exproffset+281 : exproffset+321] - if t.PreviousJustifiedCheckpoint == nil { - t.PreviousJustifiedCheckpoint = new(phase0.Checkpoint) - } - if err = t.PreviousJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") - } + // Field #17 'JustificationBits' (static) + t.JustificationBits = sszutils.ExpandSlice(t.JustificationBits, 1) + if _, err = dec.DecodeBytes(t.JustificationBits[:1]); err != nil { + return err } - { // Field #19 'CurrentJustifiedCheckpoint' (static) - buf := buf[exproffset+321 : exproffset+361] - if t.CurrentJustifiedCheckpoint == nil { - t.CurrentJustifiedCheckpoint = new(phase0.Checkpoint) - } - if err = t.CurrentJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") - } + // Field #18 'PreviousJustifiedCheckpoint' (static) + if t.PreviousJustifiedCheckpoint == nil { + t.PreviousJustifiedCheckpoint = new(phase0.Checkpoint) } - { // Field #20 'FinalizedCheckpoint' (static) - buf := buf[exproffset+361 : exproffset+401] - if t.FinalizedCheckpoint == nil { - t.FinalizedCheckpoint = new(phase0.Checkpoint) - } - if err = t.FinalizedCheckpoint.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") - } + if buf, err := dec.DecodeBytesBuf(40); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } else if err = t.PreviousJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } + // Field #19 'CurrentJustifiedCheckpoint' (static) + if t.CurrentJustifiedCheckpoint == nil { + t.CurrentJustifiedCheckpoint = new(phase0.Checkpoint) + } + if buf, err := dec.DecodeBytesBuf(40); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } else if err = t.CurrentJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } + // Field #20 'FinalizedCheckpoint' (static) + if t.FinalizedCheckpoint == nil { + t.FinalizedCheckpoint = new(phase0.Checkpoint) + } + if buf, err := dec.DecodeBytesBuf(40); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") + } else if err = t.FinalizedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") } { // Field #7 'HistoricalRoots' (dynamic) - buf := buf[offset7:offset9] + if dec.GetPosition() != startPos0+int(offset7) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset7)), "HistoricalRoots") + } + dec.PushLimit(int(offset9 - offset7)) val5 := t.HistoricalRoots - itemCount := len(buf) / 32 - if len(buf)%32 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 32), "HistoricalRoots") + sszLen := dec.GetLength() + itemCount := sszLen / 32 + if sszLen%32 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 32), "HistoricalRoots") } if itemCount > int(expr3) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr3)), "HistoricalRoots") } val5 = sszutils.ExpandSlice(val5, itemCount) + startPos4 := dec.GetPosition() for idx1 := range itemCount { - buf := buf[32*idx1 : 32*(idx1+1)] - copy(val5[idx1][:], buf) + if _, err = dec.DecodeBytes(val5[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos4+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos4+int(32*(idx1+1))), "HistoricalRoots[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "HistoricalRoots") } t.HistoricalRoots = val5 } { // Field #9 'ETH1DataVotes' (dynamic) - buf := buf[offset9:offset11] + if dec.GetPosition() != startPos0+int(offset9) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset9)), "ETH1DataVotes") + } + dec.PushLimit(int(offset11 - offset9)) val6 := t.ETH1DataVotes - itemCount := len(buf) / 72 - if len(buf)%72 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 72), "ETH1DataVotes") + sszLen := dec.GetLength() + itemCount := sszLen / 72 + if sszLen%72 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 72), "ETH1DataVotes") } if itemCount > int(expr4) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr4)), "ETH1DataVotes") } val6 = sszutils.ExpandSlice(val6, itemCount) + startPos5 := dec.GetPosition() for idx1 := range itemCount { if val6[idx1] == nil { val6[idx1] = new(phase0.ETH1Data) } - buf := buf[72*idx1 : 72*(idx1+1)] - if err = val6[idx1].UnmarshalSSZ(buf); err != nil { + if buf, err := dec.DecodeBytesBuf(72); err != nil { return sszutils.ErrorWithPathf(err, "ETH1DataVotes[%d]", idx1) + } else if err = val6[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "ETH1DataVotes[%d]", idx1) + } + if dec.GetPosition() != startPos5+int(72*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos5+int(72*(idx1+1))), "ETH1DataVotes[%d]", idx1) } } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "ETH1DataVotes") + } t.ETH1DataVotes = val6 } { // Field #11 'Validators' (dynamic) - buf := buf[offset11:offset12] + if dec.GetPosition() != startPos0+int(offset11) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset11)), "Validators") + } + dec.PushLimit(int(offset12 - offset11)) val7 := t.Validators - itemCount := len(buf) / 121 - if len(buf)%121 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 121), "Validators") + sszLen := dec.GetLength() + itemCount := sszLen / 121 + if sszLen%121 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 121), "Validators") } if itemCount > int(expr5) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr5)), "Validators") } val7 = sszutils.ExpandSlice(val7, itemCount) + startPos6 := dec.GetPosition() for idx1 := range itemCount { if val7[idx1] == nil { val7[idx1] = new(phase0.Validator) } - buf := buf[121*idx1 : 121*(idx1+1)] - if err = val7[idx1].UnmarshalSSZ(buf); err != nil { + if buf, err := dec.DecodeBytesBuf(121); err != nil { return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } else if err = val7[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } + if dec.GetPosition() != startPos6+int(121*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos6+int(121*(idx1+1))), "Validators[%d]", idx1) } } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Validators") + } t.Validators = val7 } { // Field #12 'Balances' (dynamic) - buf := buf[offset12:offset15] + if dec.GetPosition() != startPos0+int(offset12) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset12)), "Balances") + } + dec.PushLimit(int(offset15 - offset12)) val8 := t.Balances - itemCount := len(buf) / 8 - if len(buf)%8 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 8), "Balances") + sszLen := dec.GetLength() + itemCount := sszLen / 8 + if sszLen%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 8), "Balances") } if itemCount > int(expr5) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr5)), "Balances") } val8 = sszutils.ExpandSlice(val8, itemCount) - sszutils.UnmarshalUint64Slice(val8, buf) + if err = sszutils.DecodeUint64Slice(dec, val8); err != nil { + return sszutils.ErrorWithPath(err, "Balances") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Balances") + } t.Balances = val8 } { // Field #15 'PreviousEpochAttestations' (dynamic) - buf := buf[offset15:offset16] + if dec.GetPosition() != startPos0+int(offset15) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset15)), "PreviousEpochAttestations") + } + dec.PushLimit(int(offset16 - offset15)) val9 := t.PreviousEpochAttestations - startOffset := int(0) - if len(buf) != 0 { - if len(buf) < 4 { - return sszutils.ErrorWithPath(sszutils.ErrListOffsetsEOFFn(len(buf), 4), "PreviousEpochAttestations") + startOffset := uint32(0) + startPos7 := dec.GetPosition() + sszLen := uint32(dec.GetLength()) + if sszLen > 0 { + startOffset, err = dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "PreviousEpochAttestations") + } + } + itemCount := int(startOffset / 4) + var offsets []uint32 + if canSeek { + dec.SkipBytes((itemCount - 1) * 4) + } else if itemCount > 1 { + offsetSlices[0] = sszutils.ExpandSlice(offsetSlices[0], itemCount-1) + offsets = offsetSlices[0] + for idx1 := range itemCount-1 { + offset, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPathf(err, "PreviousEpochAttestations[%d:o]", idx1) + } + offsets[idx1] = offset } - startOffset = int(binary.LittleEndian.Uint32(buf[0:4])) } - itemCount := startOffset / 4 - if startOffset%4 != 0 || len(buf) < startOffset { - return sszutils.ErrorWithPath(sszutils.ErrInvalidListStartOffsetFn(startOffset, len(buf)), "PreviousEpochAttestations") + if startOffset%4 != 0 || uint32(sszLen) < startOffset { + return sszutils.ErrorWithPath(sszutils.ErrInvalidListStartOffsetFn(startOffset, sszLen), "PreviousEpochAttestations") } if itemCount > int(expr6) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "PreviousEpochAttestations") } val9 = sszutils.ExpandSlice(val9, itemCount) for idx1 := range itemCount { - var endOffset int + var endOffset uint32 if idx1 < itemCount-1 { - endOffset = int(binary.LittleEndian.Uint32(buf[(idx1+1)*4 : (idx1+2)*4])) + if canSeek { + endOffset = dec.DecodeOffsetAt(startPos7 + int((idx1+1)*4)) + } else { + endOffset = offsets[idx1] + } } else { - endOffset = len(buf) + endOffset = uint32(sszLen) } - if endOffset < startOffset || endOffset > len(buf) { - return sszutils.ErrorWithPathf(sszutils.ErrElementOffsetOutOfRangeFn(endOffset, startOffset, len(buf)), "PreviousEpochAttestations[%d]", idx1) + if endOffset < startOffset || endOffset > uint32(sszLen) { + return sszutils.ErrorWithPathf(sszutils.ErrElementOffsetOutOfRangeFn(endOffset, startOffset, sszLen), "PreviousEpochAttestations[%d]", idx1) } - buf := buf[startOffset:endOffset] + itemSize := endOffset - startOffset + dec.PushLimit(int(itemSize)) startOffset = endOffset val10 := val9[idx1] if val10 == nil { val10 = new(phase0.PendingAttestation) } - if err = val10.UnmarshalSSZ(buf); err != nil { + if buf, err := dec.DecodeBytesBuf(dec.GetLength()); err != nil { return sszutils.ErrorWithPathf(err, "PreviousEpochAttestations[%d]", idx1) + } else if err = val10.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "PreviousEpochAttestations[%d]", idx1) + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPathf(sszutils.ErrTrailingDataFn(diff), "PreviousEpochAttestations[%d]", idx1) } val9[idx1] = val10 } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "PreviousEpochAttestations") + } t.PreviousEpochAttestations = val9 } { // Field #16 'CurrentEpochAttestations' (dynamic) - buf := buf[offset16:] + if dec.GetPosition() != startPos0+int(offset16) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset16)), "CurrentEpochAttestations") + } + dec.PushLimit(int(maxOffset - offset16)) val11 := t.CurrentEpochAttestations - startOffset := int(0) - if len(buf) != 0 { - if len(buf) < 4 { - return sszutils.ErrorWithPath(sszutils.ErrListOffsetsEOFFn(len(buf), 4), "CurrentEpochAttestations") + startOffset := uint32(0) + startPos8 := dec.GetPosition() + sszLen := uint32(dec.GetLength()) + if sszLen > 0 { + startOffset, err = dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "CurrentEpochAttestations") + } + } + itemCount := int(startOffset / 4) + var offsets []uint32 + if canSeek { + dec.SkipBytes((itemCount - 1) * 4) + } else if itemCount > 1 { + offsetSlices[0] = sszutils.ExpandSlice(offsetSlices[0], itemCount-1) + offsets = offsetSlices[0] + for idx1 := range itemCount-1 { + offset, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPathf(err, "CurrentEpochAttestations[%d:o]", idx1) + } + offsets[idx1] = offset } - startOffset = int(binary.LittleEndian.Uint32(buf[0:4])) } - itemCount := startOffset / 4 - if startOffset%4 != 0 || len(buf) < startOffset { - return sszutils.ErrorWithPath(sszutils.ErrInvalidListStartOffsetFn(startOffset, len(buf)), "CurrentEpochAttestations") + if startOffset%4 != 0 || uint32(sszLen) < startOffset { + return sszutils.ErrorWithPath(sszutils.ErrInvalidListStartOffsetFn(startOffset, sszLen), "CurrentEpochAttestations") } if itemCount > int(expr6) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "CurrentEpochAttestations") } val11 = sszutils.ExpandSlice(val11, itemCount) for idx1 := range itemCount { - var endOffset int + var endOffset uint32 if idx1 < itemCount-1 { - endOffset = int(binary.LittleEndian.Uint32(buf[(idx1+1)*4 : (idx1+2)*4])) + if canSeek { + endOffset = dec.DecodeOffsetAt(startPos8 + int((idx1+1)*4)) + } else { + endOffset = offsets[idx1] + } } else { - endOffset = len(buf) + endOffset = uint32(sszLen) } - if endOffset < startOffset || endOffset > len(buf) { - return sszutils.ErrorWithPathf(sszutils.ErrElementOffsetOutOfRangeFn(endOffset, startOffset, len(buf)), "CurrentEpochAttestations[%d]", idx1) + if endOffset < startOffset || endOffset > uint32(sszLen) { + return sszutils.ErrorWithPathf(sszutils.ErrElementOffsetOutOfRangeFn(endOffset, startOffset, sszLen), "CurrentEpochAttestations[%d]", idx1) } - buf := buf[startOffset:endOffset] + itemSize := endOffset - startOffset + dec.PushLimit(int(itemSize)) startOffset = endOffset val12 := val11[idx1] if val12 == nil { val12 = new(phase0.PendingAttestation) } - if err = val12.UnmarshalSSZ(buf); err != nil { + if buf, err := dec.DecodeBytesBuf(dec.GetLength()); err != nil { return sszutils.ErrorWithPathf(err, "CurrentEpochAttestations[%d]", idx1) + } else if err = val12.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "CurrentEpochAttestations[%d]", idx1) + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPathf(sszutils.ErrTrailingDataFn(diff), "CurrentEpochAttestations[%d]", idx1) } val11[idx1] = val12 } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "CurrentEpochAttestations") + } t.CurrentEpochAttestations = val11 } return nil } -func (t *BeaconState) unmarshalSSZView_BeaconState_0(ds sszutils.DynamicSpecs, buf []byte) (err error) { +func (t *BeaconState) unmarshalSSZDecoderView_BeaconState_0(ds sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { expr0, err := sszutils.ResolveSpecValueWithDefault(ds, "SLOTS_PER_HISTORICAL_ROOT", 8192) if err != nil { return err @@ -4085,344 +14051,460 @@ func (t *BeaconState) unmarshalSSZView_BeaconState_0(ds sszutils.DynamicSpecs, b size3 := 8 * int(expr2) size5 := 48 * int(expr3) size4 := size5 + 48 // size expression for '*SyncCommittee' - exproffset := 0 totalSize := size1+size1+size2+size3+size4+size4+405 - buflen := len(buf) - if buflen < totalSize { - return sszutils.ErrFixedFieldsEOFFn(buflen, totalSize) + maxOffset := uint32(dec.GetLength()) + startPos0 := dec.GetPosition() + if maxOffset < uint32(totalSize) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(totalSize)) + } + // Field #0 'GenesisTime' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "GenesisTime") + } else { + t.GenesisTime = val + } + // Field #1 'GenesisValidatorsRoot' (static) + if _, err = dec.DecodeBytes(t.GenesisValidatorsRoot[:32]); err != nil { + return err } - { // Field #0 'GenesisTime' (static) - buf := buf[0:8] - t.GenesisTime = binary.LittleEndian.Uint64(buf) + // Field #2 'Slot' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "Slot") + } else { + t.Slot = phase0.Slot(val) } - { // Field #1 'GenesisValidatorsRoot' (static) - buf := buf[8:40] - copy(t.GenesisValidatorsRoot[:], buf) + // Field #3 'Fork' (static) + if t.Fork == nil { + t.Fork = new(phase0.Fork) } - { // Field #2 'Slot' (static) - buf := buf[40:48] - t.Slot = phase0.Slot(binary.LittleEndian.Uint64(buf)) + if buf, err := dec.DecodeBytesBuf(16); err != nil { + return sszutils.ErrorWithPath(err, "Fork") + } else if err = t.Fork.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "Fork") } - { // Field #3 'Fork' (static) - buf := buf[48:64] - if t.Fork == nil { - t.Fork = new(phase0.Fork) - } - if err = t.Fork.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "Fork") - } + // Field #4 'LatestBlockHeader' (static) + if t.LatestBlockHeader == nil { + t.LatestBlockHeader = new(phase0.BeaconBlockHeader) } - { // Field #4 'LatestBlockHeader' (static) - buf := buf[64:176] - if t.LatestBlockHeader == nil { - t.LatestBlockHeader = new(phase0.BeaconBlockHeader) - } - if err = t.LatestBlockHeader.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "LatestBlockHeader") - } + if buf, err := dec.DecodeBytesBuf(112); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") + } else if err = t.LatestBlockHeader.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") } { // Field #5 'BlockRoots' (static) - buf := buf[176 : size1+176] - exproffset += int(size1) val1 := t.BlockRoots val1 = sszutils.ExpandSlice(val1, int(expr0)) + startPos1 := dec.GetPosition() for idx1 := range int(expr0) { - buf := buf[32*idx1 : 32*(idx1+1)] - copy(val1[idx1][:], buf) + if _, err = dec.DecodeBytes(val1[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos1+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos1+int(32*(idx1+1))), "BlockRoots[%d]", idx1) + } } t.BlockRoots = val1 } { // Field #6 'StateRoots' (static) - buf := buf[exproffset+176 : exproffset+size1+176] - exproffset += int(size1) val2 := t.StateRoots val2 = sszutils.ExpandSlice(val2, int(expr0)) + startPos2 := dec.GetPosition() for idx1 := range int(expr0) { - buf := buf[32*idx1 : 32*(idx1+1)] - copy(val2[idx1][:], buf) + if _, err = dec.DecodeBytes(val2[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos2+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos2+int(32*(idx1+1))), "StateRoots[%d]", idx1) + } } t.StateRoots = val2 } // Field #7 'HistoricalRoots' (offset) - offset7 := int(binary.LittleEndian.Uint32(buf[exproffset+176 : exproffset+180])) - if offset7 != totalSize { - return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset7, totalSize), "HistoricalRoots:o") + offset7, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "HistoricalRoots") } - { // Field #8 'ETH1Data' (static) - buf := buf[exproffset+180 : exproffset+252] - if t.ETH1Data == nil { - t.ETH1Data = new(phase0.ETH1Data) - } - if err = t.ETH1Data.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "ETH1Data") - } + if offset7 != uint32(totalSize) { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset7, totalSize), "HistoricalRoots") + } + // Field #8 'ETH1Data' (static) + if t.ETH1Data == nil { + t.ETH1Data = new(phase0.ETH1Data) + } + if buf, err := dec.DecodeBytesBuf(72); err != nil { + return sszutils.ErrorWithPath(err, "ETH1Data") + } else if err = t.ETH1Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "ETH1Data") } // Field #9 'ETH1DataVotes' (offset) - offset9 := int(binary.LittleEndian.Uint32(buf[exproffset+252 : exproffset+256])) - if offset9 < offset7 || offset9 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset9, offset7, buflen), "ETH1DataVotes:o") + offset9, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "ETH1DataVotes") } - { // Field #10 'ETH1DepositIndex' (static) - buf := buf[exproffset+256 : exproffset+264] - t.ETH1DepositIndex = binary.LittleEndian.Uint64(buf) + if offset9 < offset7 || offset9 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset9, offset7, maxOffset), "ETH1DataVotes") + } + // Field #10 'ETH1DepositIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "ETH1DepositIndex") + } else { + t.ETH1DepositIndex = val } // Field #11 'Validators' (offset) - offset11 := int(binary.LittleEndian.Uint32(buf[exproffset+264 : exproffset+268])) - if offset11 < offset9 || offset11 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset11, offset9, buflen), "Validators:o") + offset11, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Validators") + } + if offset11 < offset9 || offset11 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset11, offset9, maxOffset), "Validators") } // Field #12 'Balances' (offset) - offset12 := int(binary.LittleEndian.Uint32(buf[exproffset+268 : exproffset+272])) - if offset12 < offset11 || offset12 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset12, offset11, buflen), "Balances:o") + offset12, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Balances") + } + if offset12 < offset11 || offset12 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset12, offset11, maxOffset), "Balances") } { // Field #13 'RANDAOMixes' (static) - buf := buf[exproffset+272 : exproffset+size2+272] - exproffset += int(size2) val3 := t.RANDAOMixes val3 = sszutils.ExpandSlice(val3, int(expr1)) + startPos3 := dec.GetPosition() for idx1 := range int(expr1) { - buf := buf[32*idx1 : 32*(idx1+1)] - copy(val3[idx1][:], buf) + if _, err = dec.DecodeBytes(val3[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos3+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos3+int(32*(idx1+1))), "RANDAOMixes[%d]", idx1) + } } t.RANDAOMixes = val3 } { // Field #14 'Slashings' (static) - buf := buf[exproffset+272 : exproffset+size3+272] - exproffset += int(size3) val4 := t.Slashings val4 = sszutils.ExpandSlice(val4, int(expr2)) - sszutils.UnmarshalUint64Slice(val4[:int(expr2)], buf) + if err = sszutils.DecodeUint64Slice(dec, val4[:int(expr2)]); err != nil { + return sszutils.ErrorWithPath(err, "Slashings") + } t.Slashings = val4 } // Field #15 'PreviousEpochParticipation' (offset) - offset15 := int(binary.LittleEndian.Uint32(buf[exproffset+272 : exproffset+276])) - if offset15 < offset12 || offset15 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset15, offset12, buflen), "PreviousEpochParticipation:o") + offset15, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "PreviousEpochParticipation") + } + if offset15 < offset12 || offset15 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset15, offset12, maxOffset), "PreviousEpochParticipation") } // Field #16 'CurrentEpochParticipation' (offset) - offset16 := int(binary.LittleEndian.Uint32(buf[exproffset+276 : exproffset+280])) - if offset16 < offset15 || offset16 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset16, offset15, buflen), "CurrentEpochParticipation:o") + offset16, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "CurrentEpochParticipation") } - { // Field #17 'JustificationBits' (static) - buf := buf[exproffset+280 : exproffset+281] - t.JustificationBits = sszutils.ExpandSlice(t.JustificationBits, 1) - copy(t.JustificationBits[:], buf) + if offset16 < offset15 || offset16 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset16, offset15, maxOffset), "CurrentEpochParticipation") } - { // Field #18 'PreviousJustifiedCheckpoint' (static) - buf := buf[exproffset+281 : exproffset+321] - if t.PreviousJustifiedCheckpoint == nil { - t.PreviousJustifiedCheckpoint = new(phase0.Checkpoint) - } - if err = t.PreviousJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") - } + // Field #17 'JustificationBits' (static) + t.JustificationBits = sszutils.ExpandSlice(t.JustificationBits, 1) + if _, err = dec.DecodeBytes(t.JustificationBits[:1]); err != nil { + return err } - { // Field #19 'CurrentJustifiedCheckpoint' (static) - buf := buf[exproffset+321 : exproffset+361] - if t.CurrentJustifiedCheckpoint == nil { - t.CurrentJustifiedCheckpoint = new(phase0.Checkpoint) - } - if err = t.CurrentJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") - } + // Field #18 'PreviousJustifiedCheckpoint' (static) + if t.PreviousJustifiedCheckpoint == nil { + t.PreviousJustifiedCheckpoint = new(phase0.Checkpoint) } - { // Field #20 'FinalizedCheckpoint' (static) - buf := buf[exproffset+361 : exproffset+401] - if t.FinalizedCheckpoint == nil { - t.FinalizedCheckpoint = new(phase0.Checkpoint) - } - if err = t.FinalizedCheckpoint.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") - } + if buf, err := dec.DecodeBytesBuf(40); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } else if err = t.PreviousJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } + // Field #19 'CurrentJustifiedCheckpoint' (static) + if t.CurrentJustifiedCheckpoint == nil { + t.CurrentJustifiedCheckpoint = new(phase0.Checkpoint) + } + if buf, err := dec.DecodeBytesBuf(40); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } else if err = t.CurrentJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } + // Field #20 'FinalizedCheckpoint' (static) + if t.FinalizedCheckpoint == nil { + t.FinalizedCheckpoint = new(phase0.Checkpoint) + } + if buf, err := dec.DecodeBytesBuf(40); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") + } else if err = t.FinalizedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") } // Field #21 'InactivityScores' (offset) - offset21 := int(binary.LittleEndian.Uint32(buf[exproffset+401 : exproffset+405])) - if offset21 < offset16 || offset21 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset21, offset16, buflen), "InactivityScores:o") + offset21, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "InactivityScores") + } + if offset21 < offset16 || offset21 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset21, offset16, maxOffset), "InactivityScores") } { // Field #22 'CurrentSyncCommittee' (static) - buf := buf[exproffset+405 : exproffset+size4+405] - exproffset += int(size4) val5 := t.CurrentSyncCommittee if val5 == nil { val5 = new(altair.SyncCommittee) } - exproffset := 0 totalSize := size5+48 - buflen := len(buf) - if buflen < totalSize { - return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, totalSize), "CurrentSyncCommittee") + maxOffset := uint32(dec.GetLength()) + if maxOffset < uint32(totalSize) { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(totalSize)), "CurrentSyncCommittee") } { // Field #0 'Pubkeys' (static) - buf := buf[0 : size5+0] - exproffset += int(size5) val6 := val5.Pubkeys val6 = sszutils.ExpandSlice(val6, int(expr3)) + startPos4 := dec.GetPosition() for idx1 := range int(expr3) { - buf := buf[48*idx1 : 48*(idx1+1)] - copy(val6[idx1][:], buf) + if _, err = dec.DecodeBytes(val6[idx1][:48]); err != nil { + return err + } + if dec.GetPosition() != startPos4+int(48*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos4+int(48*(idx1+1))), "CurrentSyncCommittee.Pubkeys[%d]", idx1) + } } val5.Pubkeys = val6 } - { // Field #1 'AggregatePubkey' (static) - buf := buf[exproffset+0 : exproffset+48] - copy(val5.AggregatePubkey[:], buf) + // Field #1 'AggregatePubkey' (static) + if _, err = dec.DecodeBytes(val5.AggregatePubkey[:48]); err != nil { + return err } t.CurrentSyncCommittee = val5 } { // Field #23 'NextSyncCommittee' (static) - buf := buf[exproffset+405 : exproffset+size4+405] - exproffset += int(size4) val7 := t.NextSyncCommittee if val7 == nil { val7 = new(altair.SyncCommittee) } - exproffset := 0 totalSize := size5+48 - buflen := len(buf) - if buflen < totalSize { - return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, totalSize), "NextSyncCommittee") + maxOffset := uint32(dec.GetLength()) + if maxOffset < uint32(totalSize) { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(totalSize)), "NextSyncCommittee") } { // Field #0 'Pubkeys' (static) - buf := buf[0 : size5+0] - exproffset += int(size5) val8 := val7.Pubkeys val8 = sszutils.ExpandSlice(val8, int(expr3)) + startPos5 := dec.GetPosition() for idx1 := range int(expr3) { - buf := buf[48*idx1 : 48*(idx1+1)] - copy(val8[idx1][:], buf) + if _, err = dec.DecodeBytes(val8[idx1][:48]); err != nil { + return err + } + if dec.GetPosition() != startPos5+int(48*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos5+int(48*(idx1+1))), "NextSyncCommittee.Pubkeys[%d]", idx1) + } } val7.Pubkeys = val8 } - { // Field #1 'AggregatePubkey' (static) - buf := buf[exproffset+0 : exproffset+48] - copy(val7.AggregatePubkey[:], buf) + // Field #1 'AggregatePubkey' (static) + if _, err = dec.DecodeBytes(val7.AggregatePubkey[:48]); err != nil { + return err } t.NextSyncCommittee = val7 } { // Field #7 'HistoricalRoots' (dynamic) - buf := buf[offset7:offset9] + if dec.GetPosition() != startPos0+int(offset7) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset7)), "HistoricalRoots") + } + dec.PushLimit(int(offset9 - offset7)) val9 := t.HistoricalRoots - itemCount := len(buf) / 32 - if len(buf)%32 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 32), "HistoricalRoots") + sszLen := dec.GetLength() + itemCount := sszLen / 32 + if sszLen%32 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 32), "HistoricalRoots") } if itemCount > int(expr4) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr4)), "HistoricalRoots") } val9 = sszutils.ExpandSlice(val9, itemCount) + startPos6 := dec.GetPosition() for idx1 := range itemCount { - buf := buf[32*idx1 : 32*(idx1+1)] - copy(val9[idx1][:], buf) + if _, err = dec.DecodeBytes(val9[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos6+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos6+int(32*(idx1+1))), "HistoricalRoots[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "HistoricalRoots") } t.HistoricalRoots = val9 } { // Field #9 'ETH1DataVotes' (dynamic) - buf := buf[offset9:offset11] + if dec.GetPosition() != startPos0+int(offset9) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset9)), "ETH1DataVotes") + } + dec.PushLimit(int(offset11 - offset9)) val10 := t.ETH1DataVotes - itemCount := len(buf) / 72 - if len(buf)%72 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 72), "ETH1DataVotes") + sszLen := dec.GetLength() + itemCount := sszLen / 72 + if sszLen%72 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 72), "ETH1DataVotes") } if itemCount > int(expr5) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr5)), "ETH1DataVotes") } val10 = sszutils.ExpandSlice(val10, itemCount) + startPos7 := dec.GetPosition() for idx1 := range itemCount { if val10[idx1] == nil { val10[idx1] = new(phase0.ETH1Data) } - buf := buf[72*idx1 : 72*(idx1+1)] - if err = val10[idx1].UnmarshalSSZ(buf); err != nil { + if buf, err := dec.DecodeBytesBuf(72); err != nil { return sszutils.ErrorWithPathf(err, "ETH1DataVotes[%d]", idx1) + } else if err = val10[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "ETH1DataVotes[%d]", idx1) + } + if dec.GetPosition() != startPos7+int(72*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos7+int(72*(idx1+1))), "ETH1DataVotes[%d]", idx1) } } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "ETH1DataVotes") + } t.ETH1DataVotes = val10 } { // Field #11 'Validators' (dynamic) - buf := buf[offset11:offset12] + if dec.GetPosition() != startPos0+int(offset11) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset11)), "Validators") + } + dec.PushLimit(int(offset12 - offset11)) val11 := t.Validators - itemCount := len(buf) / 121 - if len(buf)%121 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 121), "Validators") + sszLen := dec.GetLength() + itemCount := sszLen / 121 + if sszLen%121 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 121), "Validators") } if itemCount > int(expr6) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "Validators") } val11 = sszutils.ExpandSlice(val11, itemCount) + startPos8 := dec.GetPosition() for idx1 := range itemCount { if val11[idx1] == nil { val11[idx1] = new(phase0.Validator) } - buf := buf[121*idx1 : 121*(idx1+1)] - if err = val11[idx1].UnmarshalSSZ(buf); err != nil { + if buf, err := dec.DecodeBytesBuf(121); err != nil { return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } else if err = val11[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } + if dec.GetPosition() != startPos8+int(121*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos8+int(121*(idx1+1))), "Validators[%d]", idx1) } } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Validators") + } t.Validators = val11 } { // Field #12 'Balances' (dynamic) - buf := buf[offset12:offset15] + if dec.GetPosition() != startPos0+int(offset12) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset12)), "Balances") + } + dec.PushLimit(int(offset15 - offset12)) val12 := t.Balances - itemCount := len(buf) / 8 - if len(buf)%8 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 8), "Balances") + sszLen := dec.GetLength() + itemCount := sszLen / 8 + if sszLen%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 8), "Balances") } if itemCount > int(expr6) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "Balances") } val12 = sszutils.ExpandSlice(val12, itemCount) - sszutils.UnmarshalUint64Slice(val12, buf) + if err = sszutils.DecodeUint64Slice(dec, val12); err != nil { + return sszutils.ErrorWithPath(err, "Balances") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Balances") + } t.Balances = val12 } { // Field #15 'PreviousEpochParticipation' (dynamic) - buf := buf[offset15:offset16] + if dec.GetPosition() != startPos0+int(offset15) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset15)), "PreviousEpochParticipation") + } + dec.PushLimit(int(offset16 - offset15)) val13 := t.PreviousEpochParticipation - itemCount := len(buf) + itemCount := dec.GetLength() if itemCount > int(expr6) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "PreviousEpochParticipation") } val13 = sszutils.ExpandSlice(val13, itemCount) + startPos9 := dec.GetPosition() for idx1 := range itemCount { - buf := buf[1*idx1 : 1*(idx1+1)] - val13[idx1] = altair.ParticipationFlags(buf[0]) + if val, err := dec.DecodeUint8(); err != nil { + return sszutils.ErrorWithPathf(err, "PreviousEpochParticipation[%d]", idx1) + } else { + val13[idx1] = altair.ParticipationFlags(val) + } + if dec.GetPosition() != startPos9+int(1*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos9+int(1*(idx1+1))), "PreviousEpochParticipation[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "PreviousEpochParticipation") } t.PreviousEpochParticipation = val13 } { // Field #16 'CurrentEpochParticipation' (dynamic) - buf := buf[offset16:offset21] + if dec.GetPosition() != startPos0+int(offset16) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset16)), "CurrentEpochParticipation") + } + dec.PushLimit(int(offset21 - offset16)) val14 := t.CurrentEpochParticipation - itemCount := len(buf) + itemCount := dec.GetLength() if itemCount > int(expr6) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "CurrentEpochParticipation") } val14 = sszutils.ExpandSlice(val14, itemCount) + startPos10 := dec.GetPosition() for idx1 := range itemCount { - buf := buf[1*idx1 : 1*(idx1+1)] - val14[idx1] = altair.ParticipationFlags(buf[0]) + if val, err := dec.DecodeUint8(); err != nil { + return sszutils.ErrorWithPathf(err, "CurrentEpochParticipation[%d]", idx1) + } else { + val14[idx1] = altair.ParticipationFlags(val) + } + if dec.GetPosition() != startPos10+int(1*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos10+int(1*(idx1+1))), "CurrentEpochParticipation[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "CurrentEpochParticipation") } t.CurrentEpochParticipation = val14 } { // Field #21 'InactivityScores' (dynamic) - buf := buf[offset21:] + if dec.GetPosition() != startPos0+int(offset21) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset21)), "InactivityScores") + } + dec.PushLimit(int(maxOffset - offset21)) val15 := t.InactivityScores - itemCount := len(buf) / 8 - if len(buf)%8 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 8), "InactivityScores") + sszLen := dec.GetLength() + itemCount := sszLen / 8 + if sszLen%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 8), "InactivityScores") } if itemCount > int(expr6) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "InactivityScores") } val15 = sszutils.ExpandSlice(val15, itemCount) - sszutils.UnmarshalUint64Slice(val15, buf) + if err = sszutils.DecodeUint64Slice(dec, val15); err != nil { + return sszutils.ErrorWithPath(err, "InactivityScores") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "InactivityScores") + } t.InactivityScores = val15 } return nil } -func (t *BeaconState) unmarshalSSZView_BeaconState_1(ds sszutils.DynamicSpecs, buf []byte) (err error) { +func (t *BeaconState) unmarshalSSZDecoderView_BeaconState_1(ds sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { expr0, err := sszutils.ResolveSpecValueWithDefault(ds, "SLOTS_PER_HISTORICAL_ROOT", 8192) if err != nil { return err @@ -4456,362 +14538,491 @@ func (t *BeaconState) unmarshalSSZView_BeaconState_1(ds sszutils.DynamicSpecs, b size3 := 8 * int(expr2) size5 := 48 * int(expr3) size4 := size5 + 48 // size expression for '*SyncCommittee' - exproffset := 0 totalSize := size1+size1+size2+size3+size4+size4+409 - buflen := len(buf) - if buflen < totalSize { - return sszutils.ErrFixedFieldsEOFFn(buflen, totalSize) + maxOffset := uint32(dec.GetLength()) + startPos0 := dec.GetPosition() + if maxOffset < uint32(totalSize) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(totalSize)) + } + // Field #0 'GenesisTime' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "GenesisTime") + } else { + t.GenesisTime = val + } + // Field #1 'GenesisValidatorsRoot' (static) + if _, err = dec.DecodeBytes(t.GenesisValidatorsRoot[:32]); err != nil { + return err } - { // Field #0 'GenesisTime' (static) - buf := buf[0:8] - t.GenesisTime = binary.LittleEndian.Uint64(buf) + // Field #2 'Slot' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "Slot") + } else { + t.Slot = phase0.Slot(val) } - { // Field #1 'GenesisValidatorsRoot' (static) - buf := buf[8:40] - copy(t.GenesisValidatorsRoot[:], buf) + // Field #3 'Fork' (static) + if t.Fork == nil { + t.Fork = new(phase0.Fork) } - { // Field #2 'Slot' (static) - buf := buf[40:48] - t.Slot = phase0.Slot(binary.LittleEndian.Uint64(buf)) + if buf, err := dec.DecodeBytesBuf(16); err != nil { + return sszutils.ErrorWithPath(err, "Fork") + } else if err = t.Fork.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "Fork") } - { // Field #3 'Fork' (static) - buf := buf[48:64] - if t.Fork == nil { - t.Fork = new(phase0.Fork) - } - if err = t.Fork.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "Fork") - } + // Field #4 'LatestBlockHeader' (static) + if t.LatestBlockHeader == nil { + t.LatestBlockHeader = new(phase0.BeaconBlockHeader) } - { // Field #4 'LatestBlockHeader' (static) - buf := buf[64:176] - if t.LatestBlockHeader == nil { - t.LatestBlockHeader = new(phase0.BeaconBlockHeader) - } - if err = t.LatestBlockHeader.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "LatestBlockHeader") - } + if buf, err := dec.DecodeBytesBuf(112); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") + } else if err = t.LatestBlockHeader.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") } { // Field #5 'BlockRoots' (static) - buf := buf[176 : size1+176] - exproffset += int(size1) val1 := t.BlockRoots val1 = sszutils.ExpandSlice(val1, int(expr0)) + startPos1 := dec.GetPosition() for idx1 := range int(expr0) { - buf := buf[32*idx1 : 32*(idx1+1)] - copy(val1[idx1][:], buf) + if _, err = dec.DecodeBytes(val1[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos1+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos1+int(32*(idx1+1))), "BlockRoots[%d]", idx1) + } } t.BlockRoots = val1 } { // Field #6 'StateRoots' (static) - buf := buf[exproffset+176 : exproffset+size1+176] - exproffset += int(size1) val2 := t.StateRoots val2 = sszutils.ExpandSlice(val2, int(expr0)) + startPos2 := dec.GetPosition() for idx1 := range int(expr0) { - buf := buf[32*idx1 : 32*(idx1+1)] - copy(val2[idx1][:], buf) + if _, err = dec.DecodeBytes(val2[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos2+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos2+int(32*(idx1+1))), "StateRoots[%d]", idx1) + } } t.StateRoots = val2 } // Field #7 'HistoricalRoots' (offset) - offset7 := int(binary.LittleEndian.Uint32(buf[exproffset+176 : exproffset+180])) - if offset7 != totalSize { - return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset7, totalSize), "HistoricalRoots:o") + offset7, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "HistoricalRoots") } - { // Field #8 'ETH1Data' (static) - buf := buf[exproffset+180 : exproffset+252] - if t.ETH1Data == nil { - t.ETH1Data = new(phase0.ETH1Data) - } - if err = t.ETH1Data.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "ETH1Data") - } + if offset7 != uint32(totalSize) { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset7, totalSize), "HistoricalRoots") } - // Field #9 'ETH1DataVotes' (offset) - offset9 := int(binary.LittleEndian.Uint32(buf[exproffset+252 : exproffset+256])) - if offset9 < offset7 || offset9 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset9, offset7, buflen), "ETH1DataVotes:o") + // Field #8 'ETH1Data' (static) + if t.ETH1Data == nil { + t.ETH1Data = new(phase0.ETH1Data) + } + if buf, err := dec.DecodeBytesBuf(72); err != nil { + return sszutils.ErrorWithPath(err, "ETH1Data") + } else if err = t.ETH1Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "ETH1Data") + } + // Field #9 'ETH1DataVotes' (offset) + offset9, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "ETH1DataVotes") } - { // Field #10 'ETH1DepositIndex' (static) - buf := buf[exproffset+256 : exproffset+264] - t.ETH1DepositIndex = binary.LittleEndian.Uint64(buf) + if offset9 < offset7 || offset9 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset9, offset7, maxOffset), "ETH1DataVotes") + } + // Field #10 'ETH1DepositIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "ETH1DepositIndex") + } else { + t.ETH1DepositIndex = val } // Field #11 'Validators' (offset) - offset11 := int(binary.LittleEndian.Uint32(buf[exproffset+264 : exproffset+268])) - if offset11 < offset9 || offset11 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset11, offset9, buflen), "Validators:o") + offset11, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Validators") + } + if offset11 < offset9 || offset11 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset11, offset9, maxOffset), "Validators") } // Field #12 'Balances' (offset) - offset12 := int(binary.LittleEndian.Uint32(buf[exproffset+268 : exproffset+272])) - if offset12 < offset11 || offset12 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset12, offset11, buflen), "Balances:o") + offset12, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Balances") + } + if offset12 < offset11 || offset12 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset12, offset11, maxOffset), "Balances") } { // Field #13 'RANDAOMixes' (static) - buf := buf[exproffset+272 : exproffset+size2+272] - exproffset += int(size2) val3 := t.RANDAOMixes val3 = sszutils.ExpandSlice(val3, int(expr1)) + startPos3 := dec.GetPosition() for idx1 := range int(expr1) { - buf := buf[32*idx1 : 32*(idx1+1)] - copy(val3[idx1][:], buf) + if _, err = dec.DecodeBytes(val3[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos3+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos3+int(32*(idx1+1))), "RANDAOMixes[%d]", idx1) + } } t.RANDAOMixes = val3 } { // Field #14 'Slashings' (static) - buf := buf[exproffset+272 : exproffset+size3+272] - exproffset += int(size3) val4 := t.Slashings val4 = sszutils.ExpandSlice(val4, int(expr2)) - sszutils.UnmarshalUint64Slice(val4[:int(expr2)], buf) + if err = sszutils.DecodeUint64Slice(dec, val4[:int(expr2)]); err != nil { + return sszutils.ErrorWithPath(err, "Slashings") + } t.Slashings = val4 } // Field #15 'PreviousEpochParticipation' (offset) - offset15 := int(binary.LittleEndian.Uint32(buf[exproffset+272 : exproffset+276])) - if offset15 < offset12 || offset15 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset15, offset12, buflen), "PreviousEpochParticipation:o") + offset15, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "PreviousEpochParticipation") + } + if offset15 < offset12 || offset15 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset15, offset12, maxOffset), "PreviousEpochParticipation") } // Field #16 'CurrentEpochParticipation' (offset) - offset16 := int(binary.LittleEndian.Uint32(buf[exproffset+276 : exproffset+280])) - if offset16 < offset15 || offset16 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset16, offset15, buflen), "CurrentEpochParticipation:o") + offset16, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "CurrentEpochParticipation") } - { // Field #17 'JustificationBits' (static) - buf := buf[exproffset+280 : exproffset+281] - t.JustificationBits = sszutils.ExpandSlice(t.JustificationBits, 1) - copy(t.JustificationBits[:], buf) + if offset16 < offset15 || offset16 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset16, offset15, maxOffset), "CurrentEpochParticipation") } - { // Field #18 'PreviousJustifiedCheckpoint' (static) - buf := buf[exproffset+281 : exproffset+321] - if t.PreviousJustifiedCheckpoint == nil { - t.PreviousJustifiedCheckpoint = new(phase0.Checkpoint) - } - if err = t.PreviousJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") - } + // Field #17 'JustificationBits' (static) + t.JustificationBits = sszutils.ExpandSlice(t.JustificationBits, 1) + if _, err = dec.DecodeBytes(t.JustificationBits[:1]); err != nil { + return err } - { // Field #19 'CurrentJustifiedCheckpoint' (static) - buf := buf[exproffset+321 : exproffset+361] - if t.CurrentJustifiedCheckpoint == nil { - t.CurrentJustifiedCheckpoint = new(phase0.Checkpoint) - } - if err = t.CurrentJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") - } + // Field #18 'PreviousJustifiedCheckpoint' (static) + if t.PreviousJustifiedCheckpoint == nil { + t.PreviousJustifiedCheckpoint = new(phase0.Checkpoint) } - { // Field #20 'FinalizedCheckpoint' (static) - buf := buf[exproffset+361 : exproffset+401] - if t.FinalizedCheckpoint == nil { - t.FinalizedCheckpoint = new(phase0.Checkpoint) - } - if err = t.FinalizedCheckpoint.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") - } + if buf, err := dec.DecodeBytesBuf(40); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } else if err = t.PreviousJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } + // Field #19 'CurrentJustifiedCheckpoint' (static) + if t.CurrentJustifiedCheckpoint == nil { + t.CurrentJustifiedCheckpoint = new(phase0.Checkpoint) + } + if buf, err := dec.DecodeBytesBuf(40); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } else if err = t.CurrentJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } + // Field #20 'FinalizedCheckpoint' (static) + if t.FinalizedCheckpoint == nil { + t.FinalizedCheckpoint = new(phase0.Checkpoint) + } + if buf, err := dec.DecodeBytesBuf(40); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") + } else if err = t.FinalizedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") } // Field #21 'InactivityScores' (offset) - offset21 := int(binary.LittleEndian.Uint32(buf[exproffset+401 : exproffset+405])) - if offset21 < offset16 || offset21 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset21, offset16, buflen), "InactivityScores:o") + offset21, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "InactivityScores") + } + if offset21 < offset16 || offset21 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset21, offset16, maxOffset), "InactivityScores") } { // Field #22 'CurrentSyncCommittee' (static) - buf := buf[exproffset+405 : exproffset+size4+405] - exproffset += int(size4) val5 := t.CurrentSyncCommittee if val5 == nil { val5 = new(altair.SyncCommittee) } - exproffset := 0 totalSize := size5+48 - buflen := len(buf) - if buflen < totalSize { - return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, totalSize), "CurrentSyncCommittee") + maxOffset := uint32(dec.GetLength()) + if maxOffset < uint32(totalSize) { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(totalSize)), "CurrentSyncCommittee") } { // Field #0 'Pubkeys' (static) - buf := buf[0 : size5+0] - exproffset += int(size5) val6 := val5.Pubkeys val6 = sszutils.ExpandSlice(val6, int(expr3)) + startPos4 := dec.GetPosition() for idx1 := range int(expr3) { - buf := buf[48*idx1 : 48*(idx1+1)] - copy(val6[idx1][:], buf) + if _, err = dec.DecodeBytes(val6[idx1][:48]); err != nil { + return err + } + if dec.GetPosition() != startPos4+int(48*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos4+int(48*(idx1+1))), "CurrentSyncCommittee.Pubkeys[%d]", idx1) + } } val5.Pubkeys = val6 } - { // Field #1 'AggregatePubkey' (static) - buf := buf[exproffset+0 : exproffset+48] - copy(val5.AggregatePubkey[:], buf) + // Field #1 'AggregatePubkey' (static) + if _, err = dec.DecodeBytes(val5.AggregatePubkey[:48]); err != nil { + return err } t.CurrentSyncCommittee = val5 } { // Field #23 'NextSyncCommittee' (static) - buf := buf[exproffset+405 : exproffset+size4+405] - exproffset += int(size4) val7 := t.NextSyncCommittee if val7 == nil { val7 = new(altair.SyncCommittee) } - exproffset := 0 totalSize := size5+48 - buflen := len(buf) - if buflen < totalSize { - return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, totalSize), "NextSyncCommittee") + maxOffset := uint32(dec.GetLength()) + if maxOffset < uint32(totalSize) { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(totalSize)), "NextSyncCommittee") } { // Field #0 'Pubkeys' (static) - buf := buf[0 : size5+0] - exproffset += int(size5) val8 := val7.Pubkeys val8 = sszutils.ExpandSlice(val8, int(expr3)) + startPos5 := dec.GetPosition() for idx1 := range int(expr3) { - buf := buf[48*idx1 : 48*(idx1+1)] - copy(val8[idx1][:], buf) + if _, err = dec.DecodeBytes(val8[idx1][:48]); err != nil { + return err + } + if dec.GetPosition() != startPos5+int(48*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos5+int(48*(idx1+1))), "NextSyncCommittee.Pubkeys[%d]", idx1) + } } val7.Pubkeys = val8 } - { // Field #1 'AggregatePubkey' (static) - buf := buf[exproffset+0 : exproffset+48] - copy(val7.AggregatePubkey[:], buf) + // Field #1 'AggregatePubkey' (static) + if _, err = dec.DecodeBytes(val7.AggregatePubkey[:48]); err != nil { + return err } t.NextSyncCommittee = val7 } // Field #24 'LatestExecutionPayloadHeader' (offset) - offset24 := int(binary.LittleEndian.Uint32(buf[exproffset+405 : exproffset+409])) - if offset24 < offset21 || offset24 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset24, offset21, buflen), "LatestExecutionPayloadHeader:o") + offset24, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "LatestExecutionPayloadHeader") + } + if offset24 < offset21 || offset24 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset24, offset21, maxOffset), "LatestExecutionPayloadHeader") } { // Field #7 'HistoricalRoots' (dynamic) - buf := buf[offset7:offset9] + if dec.GetPosition() != startPos0+int(offset7) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset7)), "HistoricalRoots") + } + dec.PushLimit(int(offset9 - offset7)) val9 := t.HistoricalRoots - itemCount := len(buf) / 32 - if len(buf)%32 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 32), "HistoricalRoots") + sszLen := dec.GetLength() + itemCount := sszLen / 32 + if sszLen%32 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 32), "HistoricalRoots") } if itemCount > int(expr4) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr4)), "HistoricalRoots") } val9 = sszutils.ExpandSlice(val9, itemCount) + startPos6 := dec.GetPosition() for idx1 := range itemCount { - buf := buf[32*idx1 : 32*(idx1+1)] - copy(val9[idx1][:], buf) + if _, err = dec.DecodeBytes(val9[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos6+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos6+int(32*(idx1+1))), "HistoricalRoots[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "HistoricalRoots") } t.HistoricalRoots = val9 } { // Field #9 'ETH1DataVotes' (dynamic) - buf := buf[offset9:offset11] + if dec.GetPosition() != startPos0+int(offset9) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset9)), "ETH1DataVotes") + } + dec.PushLimit(int(offset11 - offset9)) val10 := t.ETH1DataVotes - itemCount := len(buf) / 72 - if len(buf)%72 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 72), "ETH1DataVotes") + sszLen := dec.GetLength() + itemCount := sszLen / 72 + if sszLen%72 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 72), "ETH1DataVotes") } if itemCount > int(expr5) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr5)), "ETH1DataVotes") } val10 = sszutils.ExpandSlice(val10, itemCount) + startPos7 := dec.GetPosition() for idx1 := range itemCount { if val10[idx1] == nil { val10[idx1] = new(phase0.ETH1Data) } - buf := buf[72*idx1 : 72*(idx1+1)] - if err = val10[idx1].UnmarshalSSZ(buf); err != nil { + if buf, err := dec.DecodeBytesBuf(72); err != nil { + return sszutils.ErrorWithPathf(err, "ETH1DataVotes[%d]", idx1) + } else if err = val10[idx1].UnmarshalSSZ(buf); err != nil { return sszutils.ErrorWithPathf(err, "ETH1DataVotes[%d]", idx1) } + if dec.GetPosition() != startPos7+int(72*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos7+int(72*(idx1+1))), "ETH1DataVotes[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "ETH1DataVotes") } t.ETH1DataVotes = val10 } { // Field #11 'Validators' (dynamic) - buf := buf[offset11:offset12] + if dec.GetPosition() != startPos0+int(offset11) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset11)), "Validators") + } + dec.PushLimit(int(offset12 - offset11)) val11 := t.Validators - itemCount := len(buf) / 121 - if len(buf)%121 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 121), "Validators") + sszLen := dec.GetLength() + itemCount := sszLen / 121 + if sszLen%121 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 121), "Validators") } if itemCount > int(expr6) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "Validators") } val11 = sszutils.ExpandSlice(val11, itemCount) + startPos8 := dec.GetPosition() for idx1 := range itemCount { if val11[idx1] == nil { val11[idx1] = new(phase0.Validator) } - buf := buf[121*idx1 : 121*(idx1+1)] - if err = val11[idx1].UnmarshalSSZ(buf); err != nil { + if buf, err := dec.DecodeBytesBuf(121); err != nil { + return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } else if err = val11[idx1].UnmarshalSSZ(buf); err != nil { return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) } + if dec.GetPosition() != startPos8+int(121*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos8+int(121*(idx1+1))), "Validators[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Validators") } t.Validators = val11 } { // Field #12 'Balances' (dynamic) - buf := buf[offset12:offset15] + if dec.GetPosition() != startPos0+int(offset12) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset12)), "Balances") + } + dec.PushLimit(int(offset15 - offset12)) val12 := t.Balances - itemCount := len(buf) / 8 - if len(buf)%8 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 8), "Balances") + sszLen := dec.GetLength() + itemCount := sszLen / 8 + if sszLen%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 8), "Balances") } if itemCount > int(expr6) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "Balances") } val12 = sszutils.ExpandSlice(val12, itemCount) - sszutils.UnmarshalUint64Slice(val12, buf) + if err = sszutils.DecodeUint64Slice(dec, val12); err != nil { + return sszutils.ErrorWithPath(err, "Balances") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Balances") + } t.Balances = val12 } { // Field #15 'PreviousEpochParticipation' (dynamic) - buf := buf[offset15:offset16] + if dec.GetPosition() != startPos0+int(offset15) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset15)), "PreviousEpochParticipation") + } + dec.PushLimit(int(offset16 - offset15)) val13 := t.PreviousEpochParticipation - itemCount := len(buf) + itemCount := dec.GetLength() if itemCount > int(expr6) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "PreviousEpochParticipation") } val13 = sszutils.ExpandSlice(val13, itemCount) + startPos9 := dec.GetPosition() for idx1 := range itemCount { - buf := buf[1*idx1 : 1*(idx1+1)] - val13[idx1] = altair.ParticipationFlags(buf[0]) + if val, err := dec.DecodeUint8(); err != nil { + return sszutils.ErrorWithPathf(err, "PreviousEpochParticipation[%d]", idx1) + } else { + val13[idx1] = altair.ParticipationFlags(val) + } + if dec.GetPosition() != startPos9+int(1*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos9+int(1*(idx1+1))), "PreviousEpochParticipation[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "PreviousEpochParticipation") } t.PreviousEpochParticipation = val13 } { // Field #16 'CurrentEpochParticipation' (dynamic) - buf := buf[offset16:offset21] + if dec.GetPosition() != startPos0+int(offset16) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset16)), "CurrentEpochParticipation") + } + dec.PushLimit(int(offset21 - offset16)) val14 := t.CurrentEpochParticipation - itemCount := len(buf) + itemCount := dec.GetLength() if itemCount > int(expr6) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "CurrentEpochParticipation") } val14 = sszutils.ExpandSlice(val14, itemCount) + startPos10 := dec.GetPosition() for idx1 := range itemCount { - buf := buf[1*idx1 : 1*(idx1+1)] - val14[idx1] = altair.ParticipationFlags(buf[0]) + if val, err := dec.DecodeUint8(); err != nil { + return sszutils.ErrorWithPathf(err, "CurrentEpochParticipation[%d]", idx1) + } else { + val14[idx1] = altair.ParticipationFlags(val) + } + if dec.GetPosition() != startPos10+int(1*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos10+int(1*(idx1+1))), "CurrentEpochParticipation[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "CurrentEpochParticipation") } t.CurrentEpochParticipation = val14 } { // Field #21 'InactivityScores' (dynamic) - buf := buf[offset21:offset24] + if dec.GetPosition() != startPos0+int(offset21) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset21)), "InactivityScores") + } + dec.PushLimit(int(offset24 - offset21)) val15 := t.InactivityScores - itemCount := len(buf) / 8 - if len(buf)%8 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 8), "InactivityScores") + sszLen := dec.GetLength() + itemCount := sszLen / 8 + if sszLen%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 8), "InactivityScores") } if itemCount > int(expr6) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "InactivityScores") } val15 = sszutils.ExpandSlice(val15, itemCount) - sszutils.UnmarshalUint64Slice(val15, buf) + if err = sszutils.DecodeUint64Slice(dec, val15); err != nil { + return sszutils.ErrorWithPath(err, "InactivityScores") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "InactivityScores") + } t.InactivityScores = val15 } { // Field #24 'LatestExecutionPayloadHeader' (dynamic) - buf := buf[offset24:] - if t.LatestExecutionPayloadHeader == nil { - t.LatestExecutionPayloadHeader = new(ExecutionPayloadHeader) + if dec.GetPosition() != startPos0+int(offset24) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset24)), "LatestExecutionPayloadHeader") } - if viewFn := t.LatestExecutionPayloadHeader.UnmarshalSSZDynView((*bellatrix.ExecutionPayloadHeader)(nil)); viewFn != nil { + dec.PushLimit(int(maxOffset - offset24)) + val16 := t.LatestExecutionPayloadHeader + if val16 == nil { + val16 = new(ExecutionPayloadHeader) + } + if buf, err := dec.DecodeBytesBuf(dec.GetLength()); err != nil { + return err + } else if viewFn := val16.UnmarshalSSZDynView((*bellatrix.ExecutionPayloadHeader)(nil)); viewFn != nil { if err = viewFn(ds, buf); err != nil { return err } } else { return sszutils.ErrNotImplemented } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "LatestExecutionPayloadHeader") + } + t.LatestExecutionPayloadHeader = val16 } return nil } -func (t *BeaconState) unmarshalSSZView_BeaconState_2(ds sszutils.DynamicSpecs, buf []byte) (err error) { +func (t *BeaconState) unmarshalSSZDecoderView_BeaconState_2(ds sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { expr0, err := sszutils.ResolveSpecValueWithDefault(ds, "SLOTS_PER_HISTORICAL_ROOT", 8192) if err != nil { return err @@ -4845,397 +15056,545 @@ func (t *BeaconState) unmarshalSSZView_BeaconState_2(ds sszutils.DynamicSpecs, b size3 := 8 * int(expr2) size5 := 48 * int(expr3) size4 := size5 + 48 // size expression for '*SyncCommittee' - exproffset := 0 totalSize := size1+size1+size2+size3+size4+size4+429 - buflen := len(buf) - if buflen < totalSize { - return sszutils.ErrFixedFieldsEOFFn(buflen, totalSize) + maxOffset := uint32(dec.GetLength()) + startPos0 := dec.GetPosition() + if maxOffset < uint32(totalSize) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(totalSize)) + } + // Field #0 'GenesisTime' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "GenesisTime") + } else { + t.GenesisTime = val + } + // Field #1 'GenesisValidatorsRoot' (static) + if _, err = dec.DecodeBytes(t.GenesisValidatorsRoot[:32]); err != nil { + return err } - { // Field #0 'GenesisTime' (static) - buf := buf[0:8] - t.GenesisTime = binary.LittleEndian.Uint64(buf) + // Field #2 'Slot' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "Slot") + } else { + t.Slot = phase0.Slot(val) } - { // Field #1 'GenesisValidatorsRoot' (static) - buf := buf[8:40] - copy(t.GenesisValidatorsRoot[:], buf) + // Field #3 'Fork' (static) + if t.Fork == nil { + t.Fork = new(phase0.Fork) } - { // Field #2 'Slot' (static) - buf := buf[40:48] - t.Slot = phase0.Slot(binary.LittleEndian.Uint64(buf)) + if buf, err := dec.DecodeBytesBuf(16); err != nil { + return sszutils.ErrorWithPath(err, "Fork") + } else if err = t.Fork.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "Fork") } - { // Field #3 'Fork' (static) - buf := buf[48:64] - if t.Fork == nil { - t.Fork = new(phase0.Fork) - } - if err = t.Fork.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "Fork") - } + // Field #4 'LatestBlockHeader' (static) + if t.LatestBlockHeader == nil { + t.LatestBlockHeader = new(phase0.BeaconBlockHeader) } - { // Field #4 'LatestBlockHeader' (static) - buf := buf[64:176] - if t.LatestBlockHeader == nil { - t.LatestBlockHeader = new(phase0.BeaconBlockHeader) - } - if err = t.LatestBlockHeader.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "LatestBlockHeader") - } + if buf, err := dec.DecodeBytesBuf(112); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") + } else if err = t.LatestBlockHeader.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") } { // Field #5 'BlockRoots' (static) - buf := buf[176 : size1+176] - exproffset += int(size1) val1 := t.BlockRoots val1 = sszutils.ExpandSlice(val1, int(expr0)) + startPos1 := dec.GetPosition() for idx1 := range int(expr0) { - buf := buf[32*idx1 : 32*(idx1+1)] - copy(val1[idx1][:], buf) + if _, err = dec.DecodeBytes(val1[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos1+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos1+int(32*(idx1+1))), "BlockRoots[%d]", idx1) + } } t.BlockRoots = val1 } { // Field #6 'StateRoots' (static) - buf := buf[exproffset+176 : exproffset+size1+176] - exproffset += int(size1) val2 := t.StateRoots val2 = sszutils.ExpandSlice(val2, int(expr0)) + startPos2 := dec.GetPosition() for idx1 := range int(expr0) { - buf := buf[32*idx1 : 32*(idx1+1)] - copy(val2[idx1][:], buf) + if _, err = dec.DecodeBytes(val2[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos2+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos2+int(32*(idx1+1))), "StateRoots[%d]", idx1) + } } t.StateRoots = val2 } // Field #7 'HistoricalRoots' (offset) - offset7 := int(binary.LittleEndian.Uint32(buf[exproffset+176 : exproffset+180])) - if offset7 != totalSize { - return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset7, totalSize), "HistoricalRoots:o") + offset7, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "HistoricalRoots") } - { // Field #8 'ETH1Data' (static) - buf := buf[exproffset+180 : exproffset+252] - if t.ETH1Data == nil { - t.ETH1Data = new(phase0.ETH1Data) - } - if err = t.ETH1Data.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "ETH1Data") - } + if offset7 != uint32(totalSize) { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset7, totalSize), "HistoricalRoots") + } + // Field #8 'ETH1Data' (static) + if t.ETH1Data == nil { + t.ETH1Data = new(phase0.ETH1Data) + } + if buf, err := dec.DecodeBytesBuf(72); err != nil { + return sszutils.ErrorWithPath(err, "ETH1Data") + } else if err = t.ETH1Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "ETH1Data") } // Field #9 'ETH1DataVotes' (offset) - offset9 := int(binary.LittleEndian.Uint32(buf[exproffset+252 : exproffset+256])) - if offset9 < offset7 || offset9 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset9, offset7, buflen), "ETH1DataVotes:o") + offset9, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "ETH1DataVotes") } - { // Field #10 'ETH1DepositIndex' (static) - buf := buf[exproffset+256 : exproffset+264] - t.ETH1DepositIndex = binary.LittleEndian.Uint64(buf) + if offset9 < offset7 || offset9 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset9, offset7, maxOffset), "ETH1DataVotes") + } + // Field #10 'ETH1DepositIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "ETH1DepositIndex") + } else { + t.ETH1DepositIndex = val } // Field #11 'Validators' (offset) - offset11 := int(binary.LittleEndian.Uint32(buf[exproffset+264 : exproffset+268])) - if offset11 < offset9 || offset11 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset11, offset9, buflen), "Validators:o") + offset11, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Validators") + } + if offset11 < offset9 || offset11 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset11, offset9, maxOffset), "Validators") } // Field #12 'Balances' (offset) - offset12 := int(binary.LittleEndian.Uint32(buf[exproffset+268 : exproffset+272])) - if offset12 < offset11 || offset12 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset12, offset11, buflen), "Balances:o") + offset12, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Balances") + } + if offset12 < offset11 || offset12 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset12, offset11, maxOffset), "Balances") } { // Field #13 'RANDAOMixes' (static) - buf := buf[exproffset+272 : exproffset+size2+272] - exproffset += int(size2) val3 := t.RANDAOMixes val3 = sszutils.ExpandSlice(val3, int(expr1)) + startPos3 := dec.GetPosition() for idx1 := range int(expr1) { - buf := buf[32*idx1 : 32*(idx1+1)] - copy(val3[idx1][:], buf) + if _, err = dec.DecodeBytes(val3[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos3+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos3+int(32*(idx1+1))), "RANDAOMixes[%d]", idx1) + } } t.RANDAOMixes = val3 } { // Field #14 'Slashings' (static) - buf := buf[exproffset+272 : exproffset+size3+272] - exproffset += int(size3) val4 := t.Slashings val4 = sszutils.ExpandSlice(val4, int(expr2)) - sszutils.UnmarshalUint64Slice(val4[:int(expr2)], buf) + if err = sszutils.DecodeUint64Slice(dec, val4[:int(expr2)]); err != nil { + return sszutils.ErrorWithPath(err, "Slashings") + } t.Slashings = val4 } // Field #15 'PreviousEpochParticipation' (offset) - offset15 := int(binary.LittleEndian.Uint32(buf[exproffset+272 : exproffset+276])) - if offset15 < offset12 || offset15 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset15, offset12, buflen), "PreviousEpochParticipation:o") + offset15, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "PreviousEpochParticipation") + } + if offset15 < offset12 || offset15 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset15, offset12, maxOffset), "PreviousEpochParticipation") } // Field #16 'CurrentEpochParticipation' (offset) - offset16 := int(binary.LittleEndian.Uint32(buf[exproffset+276 : exproffset+280])) - if offset16 < offset15 || offset16 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset16, offset15, buflen), "CurrentEpochParticipation:o") + offset16, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "CurrentEpochParticipation") } - { // Field #17 'JustificationBits' (static) - buf := buf[exproffset+280 : exproffset+281] - t.JustificationBits = sszutils.ExpandSlice(t.JustificationBits, 1) - copy(t.JustificationBits[:], buf) + if offset16 < offset15 || offset16 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset16, offset15, maxOffset), "CurrentEpochParticipation") } - { // Field #18 'PreviousJustifiedCheckpoint' (static) - buf := buf[exproffset+281 : exproffset+321] - if t.PreviousJustifiedCheckpoint == nil { - t.PreviousJustifiedCheckpoint = new(phase0.Checkpoint) - } - if err = t.PreviousJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") - } + // Field #17 'JustificationBits' (static) + t.JustificationBits = sszutils.ExpandSlice(t.JustificationBits, 1) + if _, err = dec.DecodeBytes(t.JustificationBits[:1]); err != nil { + return err } - { // Field #19 'CurrentJustifiedCheckpoint' (static) - buf := buf[exproffset+321 : exproffset+361] - if t.CurrentJustifiedCheckpoint == nil { - t.CurrentJustifiedCheckpoint = new(phase0.Checkpoint) - } - if err = t.CurrentJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") - } + // Field #18 'PreviousJustifiedCheckpoint' (static) + if t.PreviousJustifiedCheckpoint == nil { + t.PreviousJustifiedCheckpoint = new(phase0.Checkpoint) } - { // Field #20 'FinalizedCheckpoint' (static) - buf := buf[exproffset+361 : exproffset+401] - if t.FinalizedCheckpoint == nil { - t.FinalizedCheckpoint = new(phase0.Checkpoint) - } - if err = t.FinalizedCheckpoint.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") - } + if buf, err := dec.DecodeBytesBuf(40); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } else if err = t.PreviousJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } + // Field #19 'CurrentJustifiedCheckpoint' (static) + if t.CurrentJustifiedCheckpoint == nil { + t.CurrentJustifiedCheckpoint = new(phase0.Checkpoint) + } + if buf, err := dec.DecodeBytesBuf(40); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } else if err = t.CurrentJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } + // Field #20 'FinalizedCheckpoint' (static) + if t.FinalizedCheckpoint == nil { + t.FinalizedCheckpoint = new(phase0.Checkpoint) + } + if buf, err := dec.DecodeBytesBuf(40); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") + } else if err = t.FinalizedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") } // Field #21 'InactivityScores' (offset) - offset21 := int(binary.LittleEndian.Uint32(buf[exproffset+401 : exproffset+405])) - if offset21 < offset16 || offset21 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset21, offset16, buflen), "InactivityScores:o") + offset21, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "InactivityScores") + } + if offset21 < offset16 || offset21 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset21, offset16, maxOffset), "InactivityScores") } { // Field #22 'CurrentSyncCommittee' (static) - buf := buf[exproffset+405 : exproffset+size4+405] - exproffset += int(size4) val5 := t.CurrentSyncCommittee if val5 == nil { val5 = new(altair.SyncCommittee) } - exproffset := 0 totalSize := size5+48 - buflen := len(buf) - if buflen < totalSize { - return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, totalSize), "CurrentSyncCommittee") + maxOffset := uint32(dec.GetLength()) + if maxOffset < uint32(totalSize) { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(totalSize)), "CurrentSyncCommittee") } { // Field #0 'Pubkeys' (static) - buf := buf[0 : size5+0] - exproffset += int(size5) val6 := val5.Pubkeys val6 = sszutils.ExpandSlice(val6, int(expr3)) + startPos4 := dec.GetPosition() for idx1 := range int(expr3) { - buf := buf[48*idx1 : 48*(idx1+1)] - copy(val6[idx1][:], buf) + if _, err = dec.DecodeBytes(val6[idx1][:48]); err != nil { + return err + } + if dec.GetPosition() != startPos4+int(48*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos4+int(48*(idx1+1))), "CurrentSyncCommittee.Pubkeys[%d]", idx1) + } } val5.Pubkeys = val6 } - { // Field #1 'AggregatePubkey' (static) - buf := buf[exproffset+0 : exproffset+48] - copy(val5.AggregatePubkey[:], buf) + // Field #1 'AggregatePubkey' (static) + if _, err = dec.DecodeBytes(val5.AggregatePubkey[:48]); err != nil { + return err } t.CurrentSyncCommittee = val5 } { // Field #23 'NextSyncCommittee' (static) - buf := buf[exproffset+405 : exproffset+size4+405] - exproffset += int(size4) val7 := t.NextSyncCommittee if val7 == nil { val7 = new(altair.SyncCommittee) } - exproffset := 0 totalSize := size5+48 - buflen := len(buf) - if buflen < totalSize { - return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, totalSize), "NextSyncCommittee") + maxOffset := uint32(dec.GetLength()) + if maxOffset < uint32(totalSize) { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(totalSize)), "NextSyncCommittee") } { // Field #0 'Pubkeys' (static) - buf := buf[0 : size5+0] - exproffset += int(size5) val8 := val7.Pubkeys val8 = sszutils.ExpandSlice(val8, int(expr3)) + startPos5 := dec.GetPosition() for idx1 := range int(expr3) { - buf := buf[48*idx1 : 48*(idx1+1)] - copy(val8[idx1][:], buf) + if _, err = dec.DecodeBytes(val8[idx1][:48]); err != nil { + return err + } + if dec.GetPosition() != startPos5+int(48*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos5+int(48*(idx1+1))), "NextSyncCommittee.Pubkeys[%d]", idx1) + } } val7.Pubkeys = val8 } - { // Field #1 'AggregatePubkey' (static) - buf := buf[exproffset+0 : exproffset+48] - copy(val7.AggregatePubkey[:], buf) + // Field #1 'AggregatePubkey' (static) + if _, err = dec.DecodeBytes(val7.AggregatePubkey[:48]); err != nil { + return err } t.NextSyncCommittee = val7 } // Field #24 'LatestExecutionPayloadHeader' (offset) - offset24 := int(binary.LittleEndian.Uint32(buf[exproffset+405 : exproffset+409])) - if offset24 < offset21 || offset24 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset24, offset21, buflen), "LatestExecutionPayloadHeader:o") + offset24, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "LatestExecutionPayloadHeader") } - { // Field #25 'NextWithdrawalIndex' (static) - buf := buf[exproffset+409 : exproffset+417] - t.NextWithdrawalIndex = capella.WithdrawalIndex(binary.LittleEndian.Uint64(buf)) + if offset24 < offset21 || offset24 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset24, offset21, maxOffset), "LatestExecutionPayloadHeader") } - { // Field #26 'NextWithdrawalValidatorIndex' (static) - buf := buf[exproffset+417 : exproffset+425] - t.NextWithdrawalValidatorIndex = phase0.ValidatorIndex(binary.LittleEndian.Uint64(buf)) + // Field #25 'NextWithdrawalIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "NextWithdrawalIndex") + } else { + t.NextWithdrawalIndex = capella.WithdrawalIndex(val) + } + // Field #26 'NextWithdrawalValidatorIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "NextWithdrawalValidatorIndex") + } else { + t.NextWithdrawalValidatorIndex = phase0.ValidatorIndex(val) } // Field #27 'HistoricalSummaries' (offset) - offset27 := int(binary.LittleEndian.Uint32(buf[exproffset+425 : exproffset+429])) - if offset27 < offset24 || offset27 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset27, offset24, buflen), "HistoricalSummaries:o") + offset27, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "HistoricalSummaries") + } + if offset27 < offset24 || offset27 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset27, offset24, maxOffset), "HistoricalSummaries") } { // Field #7 'HistoricalRoots' (dynamic) - buf := buf[offset7:offset9] + if dec.GetPosition() != startPos0+int(offset7) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset7)), "HistoricalRoots") + } + dec.PushLimit(int(offset9 - offset7)) val9 := t.HistoricalRoots - itemCount := len(buf) / 32 - if len(buf)%32 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 32), "HistoricalRoots") + sszLen := dec.GetLength() + itemCount := sszLen / 32 + if sszLen%32 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 32), "HistoricalRoots") } if itemCount > int(expr4) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr4)), "HistoricalRoots") } val9 = sszutils.ExpandSlice(val9, itemCount) + startPos6 := dec.GetPosition() for idx1 := range itemCount { - buf := buf[32*idx1 : 32*(idx1+1)] - copy(val9[idx1][:], buf) + if _, err = dec.DecodeBytes(val9[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos6+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos6+int(32*(idx1+1))), "HistoricalRoots[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "HistoricalRoots") } t.HistoricalRoots = val9 } { // Field #9 'ETH1DataVotes' (dynamic) - buf := buf[offset9:offset11] + if dec.GetPosition() != startPos0+int(offset9) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset9)), "ETH1DataVotes") + } + dec.PushLimit(int(offset11 - offset9)) val10 := t.ETH1DataVotes - itemCount := len(buf) / 72 - if len(buf)%72 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 72), "ETH1DataVotes") + sszLen := dec.GetLength() + itemCount := sszLen / 72 + if sszLen%72 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 72), "ETH1DataVotes") } if itemCount > int(expr5) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr5)), "ETH1DataVotes") } val10 = sszutils.ExpandSlice(val10, itemCount) + startPos7 := dec.GetPosition() for idx1 := range itemCount { if val10[idx1] == nil { val10[idx1] = new(phase0.ETH1Data) } - buf := buf[72*idx1 : 72*(idx1+1)] - if err = val10[idx1].UnmarshalSSZ(buf); err != nil { + if buf, err := dec.DecodeBytesBuf(72); err != nil { + return sszutils.ErrorWithPathf(err, "ETH1DataVotes[%d]", idx1) + } else if err = val10[idx1].UnmarshalSSZ(buf); err != nil { return sszutils.ErrorWithPathf(err, "ETH1DataVotes[%d]", idx1) } + if dec.GetPosition() != startPos7+int(72*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos7+int(72*(idx1+1))), "ETH1DataVotes[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "ETH1DataVotes") } t.ETH1DataVotes = val10 } { // Field #11 'Validators' (dynamic) - buf := buf[offset11:offset12] + if dec.GetPosition() != startPos0+int(offset11) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset11)), "Validators") + } + dec.PushLimit(int(offset12 - offset11)) val11 := t.Validators - itemCount := len(buf) / 121 - if len(buf)%121 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 121), "Validators") + sszLen := dec.GetLength() + itemCount := sszLen / 121 + if sszLen%121 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 121), "Validators") } if itemCount > int(expr6) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "Validators") } val11 = sszutils.ExpandSlice(val11, itemCount) + startPos8 := dec.GetPosition() for idx1 := range itemCount { if val11[idx1] == nil { val11[idx1] = new(phase0.Validator) } - buf := buf[121*idx1 : 121*(idx1+1)] - if err = val11[idx1].UnmarshalSSZ(buf); err != nil { + if buf, err := dec.DecodeBytesBuf(121); err != nil { + return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } else if err = val11[idx1].UnmarshalSSZ(buf); err != nil { return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) } + if dec.GetPosition() != startPos8+int(121*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos8+int(121*(idx1+1))), "Validators[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Validators") } t.Validators = val11 } { // Field #12 'Balances' (dynamic) - buf := buf[offset12:offset15] + if dec.GetPosition() != startPos0+int(offset12) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset12)), "Balances") + } + dec.PushLimit(int(offset15 - offset12)) val12 := t.Balances - itemCount := len(buf) / 8 - if len(buf)%8 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 8), "Balances") + sszLen := dec.GetLength() + itemCount := sszLen / 8 + if sszLen%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 8), "Balances") } if itemCount > int(expr6) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "Balances") } val12 = sszutils.ExpandSlice(val12, itemCount) - sszutils.UnmarshalUint64Slice(val12, buf) + if err = sszutils.DecodeUint64Slice(dec, val12); err != nil { + return sszutils.ErrorWithPath(err, "Balances") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Balances") + } t.Balances = val12 } { // Field #15 'PreviousEpochParticipation' (dynamic) - buf := buf[offset15:offset16] + if dec.GetPosition() != startPos0+int(offset15) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset15)), "PreviousEpochParticipation") + } + dec.PushLimit(int(offset16 - offset15)) val13 := t.PreviousEpochParticipation - itemCount := len(buf) + itemCount := dec.GetLength() if itemCount > int(expr6) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "PreviousEpochParticipation") } val13 = sszutils.ExpandSlice(val13, itemCount) + startPos9 := dec.GetPosition() for idx1 := range itemCount { - buf := buf[1*idx1 : 1*(idx1+1)] - val13[idx1] = altair.ParticipationFlags(buf[0]) + if val, err := dec.DecodeUint8(); err != nil { + return sszutils.ErrorWithPathf(err, "PreviousEpochParticipation[%d]", idx1) + } else { + val13[idx1] = altair.ParticipationFlags(val) + } + if dec.GetPosition() != startPos9+int(1*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos9+int(1*(idx1+1))), "PreviousEpochParticipation[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "PreviousEpochParticipation") } t.PreviousEpochParticipation = val13 } { // Field #16 'CurrentEpochParticipation' (dynamic) - buf := buf[offset16:offset21] + if dec.GetPosition() != startPos0+int(offset16) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset16)), "CurrentEpochParticipation") + } + dec.PushLimit(int(offset21 - offset16)) val14 := t.CurrentEpochParticipation - itemCount := len(buf) + itemCount := dec.GetLength() if itemCount > int(expr6) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "CurrentEpochParticipation") } val14 = sszutils.ExpandSlice(val14, itemCount) + startPos10 := dec.GetPosition() for idx1 := range itemCount { - buf := buf[1*idx1 : 1*(idx1+1)] - val14[idx1] = altair.ParticipationFlags(buf[0]) + if val, err := dec.DecodeUint8(); err != nil { + return sszutils.ErrorWithPathf(err, "CurrentEpochParticipation[%d]", idx1) + } else { + val14[idx1] = altair.ParticipationFlags(val) + } + if dec.GetPosition() != startPos10+int(1*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos10+int(1*(idx1+1))), "CurrentEpochParticipation[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "CurrentEpochParticipation") } t.CurrentEpochParticipation = val14 } { // Field #21 'InactivityScores' (dynamic) - buf := buf[offset21:offset24] + if dec.GetPosition() != startPos0+int(offset21) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset21)), "InactivityScores") + } + dec.PushLimit(int(offset24 - offset21)) val15 := t.InactivityScores - itemCount := len(buf) / 8 - if len(buf)%8 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 8), "InactivityScores") + sszLen := dec.GetLength() + itemCount := sszLen / 8 + if sszLen%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 8), "InactivityScores") } if itemCount > int(expr6) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "InactivityScores") } val15 = sszutils.ExpandSlice(val15, itemCount) - sszutils.UnmarshalUint64Slice(val15, buf) + if err = sszutils.DecodeUint64Slice(dec, val15); err != nil { + return sszutils.ErrorWithPath(err, "InactivityScores") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "InactivityScores") + } t.InactivityScores = val15 } { // Field #24 'LatestExecutionPayloadHeader' (dynamic) - buf := buf[offset24:offset27] - if t.LatestExecutionPayloadHeader == nil { - t.LatestExecutionPayloadHeader = new(ExecutionPayloadHeader) + if dec.GetPosition() != startPos0+int(offset24) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset24)), "LatestExecutionPayloadHeader") } - if viewFn := t.LatestExecutionPayloadHeader.UnmarshalSSZDynView((*capella.ExecutionPayloadHeader)(nil)); viewFn != nil { + dec.PushLimit(int(offset27 - offset24)) + val16 := t.LatestExecutionPayloadHeader + if val16 == nil { + val16 = new(ExecutionPayloadHeader) + } + if buf, err := dec.DecodeBytesBuf(dec.GetLength()); err != nil { + return err + } else if viewFn := val16.UnmarshalSSZDynView((*capella.ExecutionPayloadHeader)(nil)); viewFn != nil { if err = viewFn(ds, buf); err != nil { return err } } else { return sszutils.ErrNotImplemented } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "LatestExecutionPayloadHeader") + } + t.LatestExecutionPayloadHeader = val16 } { // Field #27 'HistoricalSummaries' (dynamic) - buf := buf[offset27:] - val16 := t.HistoricalSummaries - itemCount := len(buf) / 64 - if len(buf)%64 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 64), "HistoricalSummaries") + if dec.GetPosition() != startPos0+int(offset27) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset27)), "HistoricalSummaries") + } + dec.PushLimit(int(maxOffset - offset27)) + val17 := t.HistoricalSummaries + sszLen := dec.GetLength() + itemCount := sszLen / 64 + if sszLen%64 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 64), "HistoricalSummaries") } if itemCount > int(expr4) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr4)), "HistoricalSummaries") } - val16 = sszutils.ExpandSlice(val16, itemCount) + val17 = sszutils.ExpandSlice(val17, itemCount) + startPos11 := dec.GetPosition() for idx1 := range itemCount { - if val16[idx1] == nil { - val16[idx1] = new(capella.HistoricalSummary) + if val17[idx1] == nil { + val17[idx1] = new(capella.HistoricalSummary) } - buf := buf[64*idx1 : 64*(idx1+1)] - if err = val16[idx1].UnmarshalSSZ(buf); err != nil { + if buf, err := dec.DecodeBytesBuf(64); err != nil { + return sszutils.ErrorWithPathf(err, "HistoricalSummaries[%d]", idx1) + } else if err = val17[idx1].UnmarshalSSZ(buf); err != nil { return sszutils.ErrorWithPathf(err, "HistoricalSummaries[%d]", idx1) } + if dec.GetPosition() != startPos11+int(64*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos11+int(64*(idx1+1))), "HistoricalSummaries[%d]", idx1) + } } - t.HistoricalSummaries = val16 + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "HistoricalSummaries") + } + t.HistoricalSummaries = val17 } return nil } -func (t *BeaconState) unmarshalSSZView_BeaconState_3(ds sszutils.DynamicSpecs, buf []byte) (err error) { +func (t *BeaconState) unmarshalSSZDecoderView_BeaconState_3(ds sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { expr0, err := sszutils.ResolveSpecValueWithDefault(ds, "SLOTS_PER_HISTORICAL_ROOT", 8192) if err != nil { return err @@ -5269,397 +15628,545 @@ func (t *BeaconState) unmarshalSSZView_BeaconState_3(ds sszutils.DynamicSpecs, b size3 := 8 * int(expr2) size5 := 48 * int(expr3) size4 := size5 + 48 // size expression for '*SyncCommittee' - exproffset := 0 totalSize := size1+size1+size2+size3+size4+size4+429 - buflen := len(buf) - if buflen < totalSize { - return sszutils.ErrFixedFieldsEOFFn(buflen, totalSize) + maxOffset := uint32(dec.GetLength()) + startPos0 := dec.GetPosition() + if maxOffset < uint32(totalSize) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(totalSize)) + } + // Field #0 'GenesisTime' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "GenesisTime") + } else { + t.GenesisTime = val + } + // Field #1 'GenesisValidatorsRoot' (static) + if _, err = dec.DecodeBytes(t.GenesisValidatorsRoot[:32]); err != nil { + return err } - { // Field #0 'GenesisTime' (static) - buf := buf[0:8] - t.GenesisTime = binary.LittleEndian.Uint64(buf) + // Field #2 'Slot' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "Slot") + } else { + t.Slot = phase0.Slot(val) } - { // Field #1 'GenesisValidatorsRoot' (static) - buf := buf[8:40] - copy(t.GenesisValidatorsRoot[:], buf) + // Field #3 'Fork' (static) + if t.Fork == nil { + t.Fork = new(phase0.Fork) } - { // Field #2 'Slot' (static) - buf := buf[40:48] - t.Slot = phase0.Slot(binary.LittleEndian.Uint64(buf)) + if buf, err := dec.DecodeBytesBuf(16); err != nil { + return sszutils.ErrorWithPath(err, "Fork") + } else if err = t.Fork.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "Fork") } - { // Field #3 'Fork' (static) - buf := buf[48:64] - if t.Fork == nil { - t.Fork = new(phase0.Fork) - } - if err = t.Fork.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "Fork") - } + // Field #4 'LatestBlockHeader' (static) + if t.LatestBlockHeader == nil { + t.LatestBlockHeader = new(phase0.BeaconBlockHeader) } - { // Field #4 'LatestBlockHeader' (static) - buf := buf[64:176] - if t.LatestBlockHeader == nil { - t.LatestBlockHeader = new(phase0.BeaconBlockHeader) - } - if err = t.LatestBlockHeader.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "LatestBlockHeader") - } + if buf, err := dec.DecodeBytesBuf(112); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") + } else if err = t.LatestBlockHeader.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") } { // Field #5 'BlockRoots' (static) - buf := buf[176 : size1+176] - exproffset += int(size1) val1 := t.BlockRoots val1 = sszutils.ExpandSlice(val1, int(expr0)) + startPos1 := dec.GetPosition() for idx1 := range int(expr0) { - buf := buf[32*idx1 : 32*(idx1+1)] - copy(val1[idx1][:], buf) + if _, err = dec.DecodeBytes(val1[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos1+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos1+int(32*(idx1+1))), "BlockRoots[%d]", idx1) + } } t.BlockRoots = val1 } { // Field #6 'StateRoots' (static) - buf := buf[exproffset+176 : exproffset+size1+176] - exproffset += int(size1) val2 := t.StateRoots val2 = sszutils.ExpandSlice(val2, int(expr0)) + startPos2 := dec.GetPosition() for idx1 := range int(expr0) { - buf := buf[32*idx1 : 32*(idx1+1)] - copy(val2[idx1][:], buf) - } - t.StateRoots = val2 - } - // Field #7 'HistoricalRoots' (offset) - offset7 := int(binary.LittleEndian.Uint32(buf[exproffset+176 : exproffset+180])) - if offset7 != totalSize { - return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset7, totalSize), "HistoricalRoots:o") - } - { // Field #8 'ETH1Data' (static) - buf := buf[exproffset+180 : exproffset+252] - if t.ETH1Data == nil { - t.ETH1Data = new(phase0.ETH1Data) - } - if err = t.ETH1Data.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "ETH1Data") + if _, err = dec.DecodeBytes(val2[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos2+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos2+int(32*(idx1+1))), "StateRoots[%d]", idx1) + } } + t.StateRoots = val2 + } + // Field #7 'HistoricalRoots' (offset) + offset7, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "HistoricalRoots") + } + if offset7 != uint32(totalSize) { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset7, totalSize), "HistoricalRoots") + } + // Field #8 'ETH1Data' (static) + if t.ETH1Data == nil { + t.ETH1Data = new(phase0.ETH1Data) + } + if buf, err := dec.DecodeBytesBuf(72); err != nil { + return sszutils.ErrorWithPath(err, "ETH1Data") + } else if err = t.ETH1Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "ETH1Data") } // Field #9 'ETH1DataVotes' (offset) - offset9 := int(binary.LittleEndian.Uint32(buf[exproffset+252 : exproffset+256])) - if offset9 < offset7 || offset9 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset9, offset7, buflen), "ETH1DataVotes:o") + offset9, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "ETH1DataVotes") } - { // Field #10 'ETH1DepositIndex' (static) - buf := buf[exproffset+256 : exproffset+264] - t.ETH1DepositIndex = binary.LittleEndian.Uint64(buf) + if offset9 < offset7 || offset9 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset9, offset7, maxOffset), "ETH1DataVotes") + } + // Field #10 'ETH1DepositIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "ETH1DepositIndex") + } else { + t.ETH1DepositIndex = val } // Field #11 'Validators' (offset) - offset11 := int(binary.LittleEndian.Uint32(buf[exproffset+264 : exproffset+268])) - if offset11 < offset9 || offset11 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset11, offset9, buflen), "Validators:o") + offset11, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Validators") + } + if offset11 < offset9 || offset11 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset11, offset9, maxOffset), "Validators") } // Field #12 'Balances' (offset) - offset12 := int(binary.LittleEndian.Uint32(buf[exproffset+268 : exproffset+272])) - if offset12 < offset11 || offset12 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset12, offset11, buflen), "Balances:o") + offset12, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Balances") + } + if offset12 < offset11 || offset12 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset12, offset11, maxOffset), "Balances") } { // Field #13 'RANDAOMixes' (static) - buf := buf[exproffset+272 : exproffset+size2+272] - exproffset += int(size2) val3 := t.RANDAOMixes val3 = sszutils.ExpandSlice(val3, int(expr1)) + startPos3 := dec.GetPosition() for idx1 := range int(expr1) { - buf := buf[32*idx1 : 32*(idx1+1)] - copy(val3[idx1][:], buf) + if _, err = dec.DecodeBytes(val3[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos3+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos3+int(32*(idx1+1))), "RANDAOMixes[%d]", idx1) + } } t.RANDAOMixes = val3 } { // Field #14 'Slashings' (static) - buf := buf[exproffset+272 : exproffset+size3+272] - exproffset += int(size3) val4 := t.Slashings val4 = sszutils.ExpandSlice(val4, int(expr2)) - sszutils.UnmarshalUint64Slice(val4[:int(expr2)], buf) + if err = sszutils.DecodeUint64Slice(dec, val4[:int(expr2)]); err != nil { + return sszutils.ErrorWithPath(err, "Slashings") + } t.Slashings = val4 } // Field #15 'PreviousEpochParticipation' (offset) - offset15 := int(binary.LittleEndian.Uint32(buf[exproffset+272 : exproffset+276])) - if offset15 < offset12 || offset15 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset15, offset12, buflen), "PreviousEpochParticipation:o") + offset15, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "PreviousEpochParticipation") + } + if offset15 < offset12 || offset15 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset15, offset12, maxOffset), "PreviousEpochParticipation") } // Field #16 'CurrentEpochParticipation' (offset) - offset16 := int(binary.LittleEndian.Uint32(buf[exproffset+276 : exproffset+280])) - if offset16 < offset15 || offset16 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset16, offset15, buflen), "CurrentEpochParticipation:o") + offset16, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "CurrentEpochParticipation") } - { // Field #17 'JustificationBits' (static) - buf := buf[exproffset+280 : exproffset+281] - t.JustificationBits = sszutils.ExpandSlice(t.JustificationBits, 1) - copy(t.JustificationBits[:], buf) + if offset16 < offset15 || offset16 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset16, offset15, maxOffset), "CurrentEpochParticipation") } - { // Field #18 'PreviousJustifiedCheckpoint' (static) - buf := buf[exproffset+281 : exproffset+321] - if t.PreviousJustifiedCheckpoint == nil { - t.PreviousJustifiedCheckpoint = new(phase0.Checkpoint) - } - if err = t.PreviousJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") - } + // Field #17 'JustificationBits' (static) + t.JustificationBits = sszutils.ExpandSlice(t.JustificationBits, 1) + if _, err = dec.DecodeBytes(t.JustificationBits[:1]); err != nil { + return err } - { // Field #19 'CurrentJustifiedCheckpoint' (static) - buf := buf[exproffset+321 : exproffset+361] - if t.CurrentJustifiedCheckpoint == nil { - t.CurrentJustifiedCheckpoint = new(phase0.Checkpoint) - } - if err = t.CurrentJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") - } + // Field #18 'PreviousJustifiedCheckpoint' (static) + if t.PreviousJustifiedCheckpoint == nil { + t.PreviousJustifiedCheckpoint = new(phase0.Checkpoint) } - { // Field #20 'FinalizedCheckpoint' (static) - buf := buf[exproffset+361 : exproffset+401] - if t.FinalizedCheckpoint == nil { - t.FinalizedCheckpoint = new(phase0.Checkpoint) - } - if err = t.FinalizedCheckpoint.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") - } + if buf, err := dec.DecodeBytesBuf(40); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } else if err = t.PreviousJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } + // Field #19 'CurrentJustifiedCheckpoint' (static) + if t.CurrentJustifiedCheckpoint == nil { + t.CurrentJustifiedCheckpoint = new(phase0.Checkpoint) + } + if buf, err := dec.DecodeBytesBuf(40); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } else if err = t.CurrentJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } + // Field #20 'FinalizedCheckpoint' (static) + if t.FinalizedCheckpoint == nil { + t.FinalizedCheckpoint = new(phase0.Checkpoint) + } + if buf, err := dec.DecodeBytesBuf(40); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") + } else if err = t.FinalizedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") } // Field #21 'InactivityScores' (offset) - offset21 := int(binary.LittleEndian.Uint32(buf[exproffset+401 : exproffset+405])) - if offset21 < offset16 || offset21 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset21, offset16, buflen), "InactivityScores:o") + offset21, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "InactivityScores") + } + if offset21 < offset16 || offset21 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset21, offset16, maxOffset), "InactivityScores") } { // Field #22 'CurrentSyncCommittee' (static) - buf := buf[exproffset+405 : exproffset+size4+405] - exproffset += int(size4) val5 := t.CurrentSyncCommittee if val5 == nil { val5 = new(altair.SyncCommittee) } - exproffset := 0 totalSize := size5+48 - buflen := len(buf) - if buflen < totalSize { - return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, totalSize), "CurrentSyncCommittee") + maxOffset := uint32(dec.GetLength()) + if maxOffset < uint32(totalSize) { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(totalSize)), "CurrentSyncCommittee") } { // Field #0 'Pubkeys' (static) - buf := buf[0 : size5+0] - exproffset += int(size5) val6 := val5.Pubkeys val6 = sszutils.ExpandSlice(val6, int(expr3)) + startPos4 := dec.GetPosition() for idx1 := range int(expr3) { - buf := buf[48*idx1 : 48*(idx1+1)] - copy(val6[idx1][:], buf) + if _, err = dec.DecodeBytes(val6[idx1][:48]); err != nil { + return err + } + if dec.GetPosition() != startPos4+int(48*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos4+int(48*(idx1+1))), "CurrentSyncCommittee.Pubkeys[%d]", idx1) + } } val5.Pubkeys = val6 } - { // Field #1 'AggregatePubkey' (static) - buf := buf[exproffset+0 : exproffset+48] - copy(val5.AggregatePubkey[:], buf) + // Field #1 'AggregatePubkey' (static) + if _, err = dec.DecodeBytes(val5.AggregatePubkey[:48]); err != nil { + return err } t.CurrentSyncCommittee = val5 } { // Field #23 'NextSyncCommittee' (static) - buf := buf[exproffset+405 : exproffset+size4+405] - exproffset += int(size4) val7 := t.NextSyncCommittee if val7 == nil { val7 = new(altair.SyncCommittee) } - exproffset := 0 totalSize := size5+48 - buflen := len(buf) - if buflen < totalSize { - return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, totalSize), "NextSyncCommittee") + maxOffset := uint32(dec.GetLength()) + if maxOffset < uint32(totalSize) { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(totalSize)), "NextSyncCommittee") } { // Field #0 'Pubkeys' (static) - buf := buf[0 : size5+0] - exproffset += int(size5) val8 := val7.Pubkeys val8 = sszutils.ExpandSlice(val8, int(expr3)) + startPos5 := dec.GetPosition() for idx1 := range int(expr3) { - buf := buf[48*idx1 : 48*(idx1+1)] - copy(val8[idx1][:], buf) + if _, err = dec.DecodeBytes(val8[idx1][:48]); err != nil { + return err + } + if dec.GetPosition() != startPos5+int(48*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos5+int(48*(idx1+1))), "NextSyncCommittee.Pubkeys[%d]", idx1) + } } val7.Pubkeys = val8 } - { // Field #1 'AggregatePubkey' (static) - buf := buf[exproffset+0 : exproffset+48] - copy(val7.AggregatePubkey[:], buf) + // Field #1 'AggregatePubkey' (static) + if _, err = dec.DecodeBytes(val7.AggregatePubkey[:48]); err != nil { + return err } t.NextSyncCommittee = val7 } // Field #24 'LatestExecutionPayloadHeader' (offset) - offset24 := int(binary.LittleEndian.Uint32(buf[exproffset+405 : exproffset+409])) - if offset24 < offset21 || offset24 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset24, offset21, buflen), "LatestExecutionPayloadHeader:o") + offset24, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "LatestExecutionPayloadHeader") } - { // Field #25 'NextWithdrawalIndex' (static) - buf := buf[exproffset+409 : exproffset+417] - t.NextWithdrawalIndex = capella.WithdrawalIndex(binary.LittleEndian.Uint64(buf)) + if offset24 < offset21 || offset24 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset24, offset21, maxOffset), "LatestExecutionPayloadHeader") } - { // Field #26 'NextWithdrawalValidatorIndex' (static) - buf := buf[exproffset+417 : exproffset+425] - t.NextWithdrawalValidatorIndex = phase0.ValidatorIndex(binary.LittleEndian.Uint64(buf)) + // Field #25 'NextWithdrawalIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "NextWithdrawalIndex") + } else { + t.NextWithdrawalIndex = capella.WithdrawalIndex(val) + } + // Field #26 'NextWithdrawalValidatorIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "NextWithdrawalValidatorIndex") + } else { + t.NextWithdrawalValidatorIndex = phase0.ValidatorIndex(val) } // Field #27 'HistoricalSummaries' (offset) - offset27 := int(binary.LittleEndian.Uint32(buf[exproffset+425 : exproffset+429])) - if offset27 < offset24 || offset27 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset27, offset24, buflen), "HistoricalSummaries:o") + offset27, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "HistoricalSummaries") + } + if offset27 < offset24 || offset27 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset27, offset24, maxOffset), "HistoricalSummaries") } { // Field #7 'HistoricalRoots' (dynamic) - buf := buf[offset7:offset9] + if dec.GetPosition() != startPos0+int(offset7) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset7)), "HistoricalRoots") + } + dec.PushLimit(int(offset9 - offset7)) val9 := t.HistoricalRoots - itemCount := len(buf) / 32 - if len(buf)%32 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 32), "HistoricalRoots") + sszLen := dec.GetLength() + itemCount := sszLen / 32 + if sszLen%32 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 32), "HistoricalRoots") } if itemCount > int(expr4) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr4)), "HistoricalRoots") } val9 = sszutils.ExpandSlice(val9, itemCount) + startPos6 := dec.GetPosition() for idx1 := range itemCount { - buf := buf[32*idx1 : 32*(idx1+1)] - copy(val9[idx1][:], buf) + if _, err = dec.DecodeBytes(val9[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos6+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos6+int(32*(idx1+1))), "HistoricalRoots[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "HistoricalRoots") } t.HistoricalRoots = val9 } { // Field #9 'ETH1DataVotes' (dynamic) - buf := buf[offset9:offset11] + if dec.GetPosition() != startPos0+int(offset9) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset9)), "ETH1DataVotes") + } + dec.PushLimit(int(offset11 - offset9)) val10 := t.ETH1DataVotes - itemCount := len(buf) / 72 - if len(buf)%72 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 72), "ETH1DataVotes") + sszLen := dec.GetLength() + itemCount := sszLen / 72 + if sszLen%72 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 72), "ETH1DataVotes") } if itemCount > int(expr5) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr5)), "ETH1DataVotes") } val10 = sszutils.ExpandSlice(val10, itemCount) + startPos7 := dec.GetPosition() for idx1 := range itemCount { if val10[idx1] == nil { val10[idx1] = new(phase0.ETH1Data) } - buf := buf[72*idx1 : 72*(idx1+1)] - if err = val10[idx1].UnmarshalSSZ(buf); err != nil { + if buf, err := dec.DecodeBytesBuf(72); err != nil { + return sszutils.ErrorWithPathf(err, "ETH1DataVotes[%d]", idx1) + } else if err = val10[idx1].UnmarshalSSZ(buf); err != nil { return sszutils.ErrorWithPathf(err, "ETH1DataVotes[%d]", idx1) } + if dec.GetPosition() != startPos7+int(72*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos7+int(72*(idx1+1))), "ETH1DataVotes[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "ETH1DataVotes") } t.ETH1DataVotes = val10 } { // Field #11 'Validators' (dynamic) - buf := buf[offset11:offset12] + if dec.GetPosition() != startPos0+int(offset11) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset11)), "Validators") + } + dec.PushLimit(int(offset12 - offset11)) val11 := t.Validators - itemCount := len(buf) / 121 - if len(buf)%121 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 121), "Validators") + sszLen := dec.GetLength() + itemCount := sszLen / 121 + if sszLen%121 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 121), "Validators") } if itemCount > int(expr6) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "Validators") } val11 = sszutils.ExpandSlice(val11, itemCount) + startPos8 := dec.GetPosition() for idx1 := range itemCount { if val11[idx1] == nil { val11[idx1] = new(phase0.Validator) } - buf := buf[121*idx1 : 121*(idx1+1)] - if err = val11[idx1].UnmarshalSSZ(buf); err != nil { + if buf, err := dec.DecodeBytesBuf(121); err != nil { + return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } else if err = val11[idx1].UnmarshalSSZ(buf); err != nil { return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) } + if dec.GetPosition() != startPos8+int(121*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos8+int(121*(idx1+1))), "Validators[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Validators") } t.Validators = val11 } { // Field #12 'Balances' (dynamic) - buf := buf[offset12:offset15] + if dec.GetPosition() != startPos0+int(offset12) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset12)), "Balances") + } + dec.PushLimit(int(offset15 - offset12)) val12 := t.Balances - itemCount := len(buf) / 8 - if len(buf)%8 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 8), "Balances") + sszLen := dec.GetLength() + itemCount := sszLen / 8 + if sszLen%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 8), "Balances") } if itemCount > int(expr6) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "Balances") } val12 = sszutils.ExpandSlice(val12, itemCount) - sszutils.UnmarshalUint64Slice(val12, buf) + if err = sszutils.DecodeUint64Slice(dec, val12); err != nil { + return sszutils.ErrorWithPath(err, "Balances") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Balances") + } t.Balances = val12 } { // Field #15 'PreviousEpochParticipation' (dynamic) - buf := buf[offset15:offset16] + if dec.GetPosition() != startPos0+int(offset15) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset15)), "PreviousEpochParticipation") + } + dec.PushLimit(int(offset16 - offset15)) val13 := t.PreviousEpochParticipation - itemCount := len(buf) + itemCount := dec.GetLength() if itemCount > int(expr6) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "PreviousEpochParticipation") } val13 = sszutils.ExpandSlice(val13, itemCount) + startPos9 := dec.GetPosition() for idx1 := range itemCount { - buf := buf[1*idx1 : 1*(idx1+1)] - val13[idx1] = altair.ParticipationFlags(buf[0]) + if val, err := dec.DecodeUint8(); err != nil { + return sszutils.ErrorWithPathf(err, "PreviousEpochParticipation[%d]", idx1) + } else { + val13[idx1] = altair.ParticipationFlags(val) + } + if dec.GetPosition() != startPos9+int(1*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos9+int(1*(idx1+1))), "PreviousEpochParticipation[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "PreviousEpochParticipation") } t.PreviousEpochParticipation = val13 } { // Field #16 'CurrentEpochParticipation' (dynamic) - buf := buf[offset16:offset21] + if dec.GetPosition() != startPos0+int(offset16) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset16)), "CurrentEpochParticipation") + } + dec.PushLimit(int(offset21 - offset16)) val14 := t.CurrentEpochParticipation - itemCount := len(buf) + itemCount := dec.GetLength() if itemCount > int(expr6) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "CurrentEpochParticipation") } val14 = sszutils.ExpandSlice(val14, itemCount) + startPos10 := dec.GetPosition() for idx1 := range itemCount { - buf := buf[1*idx1 : 1*(idx1+1)] - val14[idx1] = altair.ParticipationFlags(buf[0]) + if val, err := dec.DecodeUint8(); err != nil { + return sszutils.ErrorWithPathf(err, "CurrentEpochParticipation[%d]", idx1) + } else { + val14[idx1] = altair.ParticipationFlags(val) + } + if dec.GetPosition() != startPos10+int(1*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos10+int(1*(idx1+1))), "CurrentEpochParticipation[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "CurrentEpochParticipation") } t.CurrentEpochParticipation = val14 } { // Field #21 'InactivityScores' (dynamic) - buf := buf[offset21:offset24] + if dec.GetPosition() != startPos0+int(offset21) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset21)), "InactivityScores") + } + dec.PushLimit(int(offset24 - offset21)) val15 := t.InactivityScores - itemCount := len(buf) / 8 - if len(buf)%8 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 8), "InactivityScores") + sszLen := dec.GetLength() + itemCount := sszLen / 8 + if sszLen%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 8), "InactivityScores") } if itemCount > int(expr6) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "InactivityScores") } val15 = sszutils.ExpandSlice(val15, itemCount) - sszutils.UnmarshalUint64Slice(val15, buf) + if err = sszutils.DecodeUint64Slice(dec, val15); err != nil { + return sszutils.ErrorWithPath(err, "InactivityScores") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "InactivityScores") + } t.InactivityScores = val15 } { // Field #24 'LatestExecutionPayloadHeader' (dynamic) - buf := buf[offset24:offset27] - if t.LatestExecutionPayloadHeader == nil { - t.LatestExecutionPayloadHeader = new(ExecutionPayloadHeader) + if dec.GetPosition() != startPos0+int(offset24) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset24)), "LatestExecutionPayloadHeader") } - if viewFn := t.LatestExecutionPayloadHeader.UnmarshalSSZDynView((*deneb.ExecutionPayloadHeader)(nil)); viewFn != nil { + dec.PushLimit(int(offset27 - offset24)) + val16 := t.LatestExecutionPayloadHeader + if val16 == nil { + val16 = new(ExecutionPayloadHeader) + } + if buf, err := dec.DecodeBytesBuf(dec.GetLength()); err != nil { + return err + } else if viewFn := val16.UnmarshalSSZDynView((*deneb.ExecutionPayloadHeader)(nil)); viewFn != nil { if err = viewFn(ds, buf); err != nil { return err } } else { return sszutils.ErrNotImplemented } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "LatestExecutionPayloadHeader") + } + t.LatestExecutionPayloadHeader = val16 } { // Field #27 'HistoricalSummaries' (dynamic) - buf := buf[offset27:] - val16 := t.HistoricalSummaries - itemCount := len(buf) / 64 - if len(buf)%64 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 64), "HistoricalSummaries") + if dec.GetPosition() != startPos0+int(offset27) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset27)), "HistoricalSummaries") + } + dec.PushLimit(int(maxOffset - offset27)) + val17 := t.HistoricalSummaries + sszLen := dec.GetLength() + itemCount := sszLen / 64 + if sszLen%64 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 64), "HistoricalSummaries") } if itemCount > int(expr4) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr4)), "HistoricalSummaries") } - val16 = sszutils.ExpandSlice(val16, itemCount) + val17 = sszutils.ExpandSlice(val17, itemCount) + startPos11 := dec.GetPosition() for idx1 := range itemCount { - if val16[idx1] == nil { - val16[idx1] = new(capella.HistoricalSummary) + if val17[idx1] == nil { + val17[idx1] = new(capella.HistoricalSummary) } - buf := buf[64*idx1 : 64*(idx1+1)] - if err = val16[idx1].UnmarshalSSZ(buf); err != nil { + if buf, err := dec.DecodeBytesBuf(64); err != nil { + return sszutils.ErrorWithPathf(err, "HistoricalSummaries[%d]", idx1) + } else if err = val17[idx1].UnmarshalSSZ(buf); err != nil { return sszutils.ErrorWithPathf(err, "HistoricalSummaries[%d]", idx1) } + if dec.GetPosition() != startPos11+int(64*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos11+int(64*(idx1+1))), "HistoricalSummaries[%d]", idx1) + } } - t.HistoricalSummaries = val16 + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "HistoricalSummaries") + } + t.HistoricalSummaries = val17 } return nil } -func (t *BeaconState) unmarshalSSZView_BeaconState_4(ds sszutils.DynamicSpecs, buf []byte) (err error) { +func (t *BeaconState) unmarshalSSZDecoderView_BeaconState_4(ds sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { expr0, err := sszutils.ResolveSpecValueWithDefault(ds, "SLOTS_PER_HISTORICAL_ROOT", 8192) if err != nil { return err @@ -5705,502 +16212,707 @@ func (t *BeaconState) unmarshalSSZView_BeaconState_4(ds sszutils.DynamicSpecs, b size3 := 8 * int(expr2) size5 := 48 * int(expr3) size4 := size5 + 48 // size expression for '*SyncCommittee' - exproffset := 0 - totalSize := size1+size1+size2+size3+size4+size4+489 - buflen := len(buf) - if buflen < totalSize { - return sszutils.ErrFixedFieldsEOFFn(buflen, totalSize) - } - { // Field #0 'GenesisTime' (static) - buf := buf[0:8] - t.GenesisTime = binary.LittleEndian.Uint64(buf) - } - { // Field #1 'GenesisValidatorsRoot' (static) - buf := buf[8:40] - copy(t.GenesisValidatorsRoot[:], buf) - } - { // Field #2 'Slot' (static) - buf := buf[40:48] - t.Slot = phase0.Slot(binary.LittleEndian.Uint64(buf)) - } - { // Field #3 'Fork' (static) - buf := buf[48:64] - if t.Fork == nil { - t.Fork = new(phase0.Fork) - } - if err = t.Fork.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "Fork") - } - } - { // Field #4 'LatestBlockHeader' (static) - buf := buf[64:176] - if t.LatestBlockHeader == nil { - t.LatestBlockHeader = new(phase0.BeaconBlockHeader) - } - if err = t.LatestBlockHeader.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "LatestBlockHeader") - } + totalSize := size1+size1+size2+size3+size4+size4+489 + maxOffset := uint32(dec.GetLength()) + startPos0 := dec.GetPosition() + if maxOffset < uint32(totalSize) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(totalSize)) + } + // Field #0 'GenesisTime' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "GenesisTime") + } else { + t.GenesisTime = val + } + // Field #1 'GenesisValidatorsRoot' (static) + if _, err = dec.DecodeBytes(t.GenesisValidatorsRoot[:32]); err != nil { + return err + } + // Field #2 'Slot' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "Slot") + } else { + t.Slot = phase0.Slot(val) + } + // Field #3 'Fork' (static) + if t.Fork == nil { + t.Fork = new(phase0.Fork) + } + if buf, err := dec.DecodeBytesBuf(16); err != nil { + return sszutils.ErrorWithPath(err, "Fork") + } else if err = t.Fork.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "Fork") + } + // Field #4 'LatestBlockHeader' (static) + if t.LatestBlockHeader == nil { + t.LatestBlockHeader = new(phase0.BeaconBlockHeader) + } + if buf, err := dec.DecodeBytesBuf(112); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") + } else if err = t.LatestBlockHeader.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") } { // Field #5 'BlockRoots' (static) - buf := buf[176 : size1+176] - exproffset += int(size1) val1 := t.BlockRoots val1 = sszutils.ExpandSlice(val1, int(expr0)) + startPos1 := dec.GetPosition() for idx1 := range int(expr0) { - buf := buf[32*idx1 : 32*(idx1+1)] - copy(val1[idx1][:], buf) + if _, err = dec.DecodeBytes(val1[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos1+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos1+int(32*(idx1+1))), "BlockRoots[%d]", idx1) + } } t.BlockRoots = val1 } { // Field #6 'StateRoots' (static) - buf := buf[exproffset+176 : exproffset+size1+176] - exproffset += int(size1) val2 := t.StateRoots val2 = sszutils.ExpandSlice(val2, int(expr0)) + startPos2 := dec.GetPosition() for idx1 := range int(expr0) { - buf := buf[32*idx1 : 32*(idx1+1)] - copy(val2[idx1][:], buf) + if _, err = dec.DecodeBytes(val2[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos2+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos2+int(32*(idx1+1))), "StateRoots[%d]", idx1) + } } t.StateRoots = val2 } // Field #7 'HistoricalRoots' (offset) - offset7 := int(binary.LittleEndian.Uint32(buf[exproffset+176 : exproffset+180])) - if offset7 != totalSize { - return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset7, totalSize), "HistoricalRoots:o") + offset7, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "HistoricalRoots") } - { // Field #8 'ETH1Data' (static) - buf := buf[exproffset+180 : exproffset+252] - if t.ETH1Data == nil { - t.ETH1Data = new(phase0.ETH1Data) - } - if err = t.ETH1Data.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "ETH1Data") - } + if offset7 != uint32(totalSize) { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset7, totalSize), "HistoricalRoots") + } + // Field #8 'ETH1Data' (static) + if t.ETH1Data == nil { + t.ETH1Data = new(phase0.ETH1Data) + } + if buf, err := dec.DecodeBytesBuf(72); err != nil { + return sszutils.ErrorWithPath(err, "ETH1Data") + } else if err = t.ETH1Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "ETH1Data") } // Field #9 'ETH1DataVotes' (offset) - offset9 := int(binary.LittleEndian.Uint32(buf[exproffset+252 : exproffset+256])) - if offset9 < offset7 || offset9 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset9, offset7, buflen), "ETH1DataVotes:o") + offset9, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "ETH1DataVotes") } - { // Field #10 'ETH1DepositIndex' (static) - buf := buf[exproffset+256 : exproffset+264] - t.ETH1DepositIndex = binary.LittleEndian.Uint64(buf) + if offset9 < offset7 || offset9 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset9, offset7, maxOffset), "ETH1DataVotes") + } + // Field #10 'ETH1DepositIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "ETH1DepositIndex") + } else { + t.ETH1DepositIndex = val } // Field #11 'Validators' (offset) - offset11 := int(binary.LittleEndian.Uint32(buf[exproffset+264 : exproffset+268])) - if offset11 < offset9 || offset11 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset11, offset9, buflen), "Validators:o") + offset11, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Validators") + } + if offset11 < offset9 || offset11 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset11, offset9, maxOffset), "Validators") } // Field #12 'Balances' (offset) - offset12 := int(binary.LittleEndian.Uint32(buf[exproffset+268 : exproffset+272])) - if offset12 < offset11 || offset12 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset12, offset11, buflen), "Balances:o") + offset12, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Balances") + } + if offset12 < offset11 || offset12 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset12, offset11, maxOffset), "Balances") } { // Field #13 'RANDAOMixes' (static) - buf := buf[exproffset+272 : exproffset+size2+272] - exproffset += int(size2) val3 := t.RANDAOMixes val3 = sszutils.ExpandSlice(val3, int(expr1)) + startPos3 := dec.GetPosition() for idx1 := range int(expr1) { - buf := buf[32*idx1 : 32*(idx1+1)] - copy(val3[idx1][:], buf) + if _, err = dec.DecodeBytes(val3[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos3+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos3+int(32*(idx1+1))), "RANDAOMixes[%d]", idx1) + } } t.RANDAOMixes = val3 } { // Field #14 'Slashings' (static) - buf := buf[exproffset+272 : exproffset+size3+272] - exproffset += int(size3) val4 := t.Slashings val4 = sszutils.ExpandSlice(val4, int(expr2)) - sszutils.UnmarshalUint64Slice(val4[:int(expr2)], buf) + if err = sszutils.DecodeUint64Slice(dec, val4[:int(expr2)]); err != nil { + return sszutils.ErrorWithPath(err, "Slashings") + } t.Slashings = val4 } // Field #15 'PreviousEpochParticipation' (offset) - offset15 := int(binary.LittleEndian.Uint32(buf[exproffset+272 : exproffset+276])) - if offset15 < offset12 || offset15 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset15, offset12, buflen), "PreviousEpochParticipation:o") + offset15, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "PreviousEpochParticipation") + } + if offset15 < offset12 || offset15 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset15, offset12, maxOffset), "PreviousEpochParticipation") } // Field #16 'CurrentEpochParticipation' (offset) - offset16 := int(binary.LittleEndian.Uint32(buf[exproffset+276 : exproffset+280])) - if offset16 < offset15 || offset16 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset16, offset15, buflen), "CurrentEpochParticipation:o") + offset16, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "CurrentEpochParticipation") } - { // Field #17 'JustificationBits' (static) - buf := buf[exproffset+280 : exproffset+281] - t.JustificationBits = sszutils.ExpandSlice(t.JustificationBits, 1) - copy(t.JustificationBits[:], buf) + if offset16 < offset15 || offset16 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset16, offset15, maxOffset), "CurrentEpochParticipation") } - { // Field #18 'PreviousJustifiedCheckpoint' (static) - buf := buf[exproffset+281 : exproffset+321] - if t.PreviousJustifiedCheckpoint == nil { - t.PreviousJustifiedCheckpoint = new(phase0.Checkpoint) - } - if err = t.PreviousJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") - } + // Field #17 'JustificationBits' (static) + t.JustificationBits = sszutils.ExpandSlice(t.JustificationBits, 1) + if _, err = dec.DecodeBytes(t.JustificationBits[:1]); err != nil { + return err } - { // Field #19 'CurrentJustifiedCheckpoint' (static) - buf := buf[exproffset+321 : exproffset+361] - if t.CurrentJustifiedCheckpoint == nil { - t.CurrentJustifiedCheckpoint = new(phase0.Checkpoint) - } - if err = t.CurrentJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") - } + // Field #18 'PreviousJustifiedCheckpoint' (static) + if t.PreviousJustifiedCheckpoint == nil { + t.PreviousJustifiedCheckpoint = new(phase0.Checkpoint) } - { // Field #20 'FinalizedCheckpoint' (static) - buf := buf[exproffset+361 : exproffset+401] - if t.FinalizedCheckpoint == nil { - t.FinalizedCheckpoint = new(phase0.Checkpoint) - } - if err = t.FinalizedCheckpoint.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") - } + if buf, err := dec.DecodeBytesBuf(40); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } else if err = t.PreviousJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } + // Field #19 'CurrentJustifiedCheckpoint' (static) + if t.CurrentJustifiedCheckpoint == nil { + t.CurrentJustifiedCheckpoint = new(phase0.Checkpoint) + } + if buf, err := dec.DecodeBytesBuf(40); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } else if err = t.CurrentJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } + // Field #20 'FinalizedCheckpoint' (static) + if t.FinalizedCheckpoint == nil { + t.FinalizedCheckpoint = new(phase0.Checkpoint) + } + if buf, err := dec.DecodeBytesBuf(40); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") + } else if err = t.FinalizedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") } // Field #21 'InactivityScores' (offset) - offset21 := int(binary.LittleEndian.Uint32(buf[exproffset+401 : exproffset+405])) - if offset21 < offset16 || offset21 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset21, offset16, buflen), "InactivityScores:o") + offset21, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "InactivityScores") + } + if offset21 < offset16 || offset21 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset21, offset16, maxOffset), "InactivityScores") } { // Field #22 'CurrentSyncCommittee' (static) - buf := buf[exproffset+405 : exproffset+size4+405] - exproffset += int(size4) val5 := t.CurrentSyncCommittee if val5 == nil { val5 = new(altair.SyncCommittee) } - exproffset := 0 totalSize := size5+48 - buflen := len(buf) - if buflen < totalSize { - return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, totalSize), "CurrentSyncCommittee") + maxOffset := uint32(dec.GetLength()) + if maxOffset < uint32(totalSize) { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(totalSize)), "CurrentSyncCommittee") } { // Field #0 'Pubkeys' (static) - buf := buf[0 : size5+0] - exproffset += int(size5) val6 := val5.Pubkeys val6 = sszutils.ExpandSlice(val6, int(expr3)) + startPos4 := dec.GetPosition() for idx1 := range int(expr3) { - buf := buf[48*idx1 : 48*(idx1+1)] - copy(val6[idx1][:], buf) + if _, err = dec.DecodeBytes(val6[idx1][:48]); err != nil { + return err + } + if dec.GetPosition() != startPos4+int(48*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos4+int(48*(idx1+1))), "CurrentSyncCommittee.Pubkeys[%d]", idx1) + } } val5.Pubkeys = val6 } - { // Field #1 'AggregatePubkey' (static) - buf := buf[exproffset+0 : exproffset+48] - copy(val5.AggregatePubkey[:], buf) + // Field #1 'AggregatePubkey' (static) + if _, err = dec.DecodeBytes(val5.AggregatePubkey[:48]); err != nil { + return err } t.CurrentSyncCommittee = val5 } { // Field #23 'NextSyncCommittee' (static) - buf := buf[exproffset+405 : exproffset+size4+405] - exproffset += int(size4) val7 := t.NextSyncCommittee if val7 == nil { val7 = new(altair.SyncCommittee) } - exproffset := 0 totalSize := size5+48 - buflen := len(buf) - if buflen < totalSize { - return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, totalSize), "NextSyncCommittee") + maxOffset := uint32(dec.GetLength()) + if maxOffset < uint32(totalSize) { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(totalSize)), "NextSyncCommittee") } { // Field #0 'Pubkeys' (static) - buf := buf[0 : size5+0] - exproffset += int(size5) val8 := val7.Pubkeys val8 = sszutils.ExpandSlice(val8, int(expr3)) + startPos5 := dec.GetPosition() for idx1 := range int(expr3) { - buf := buf[48*idx1 : 48*(idx1+1)] - copy(val8[idx1][:], buf) + if _, err = dec.DecodeBytes(val8[idx1][:48]); err != nil { + return err + } + if dec.GetPosition() != startPos5+int(48*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos5+int(48*(idx1+1))), "NextSyncCommittee.Pubkeys[%d]", idx1) + } } val7.Pubkeys = val8 } - { // Field #1 'AggregatePubkey' (static) - buf := buf[exproffset+0 : exproffset+48] - copy(val7.AggregatePubkey[:], buf) + // Field #1 'AggregatePubkey' (static) + if _, err = dec.DecodeBytes(val7.AggregatePubkey[:48]); err != nil { + return err } t.NextSyncCommittee = val7 } // Field #24 'LatestExecutionPayloadHeader' (offset) - offset24 := int(binary.LittleEndian.Uint32(buf[exproffset+405 : exproffset+409])) - if offset24 < offset21 || offset24 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset24, offset21, buflen), "LatestExecutionPayloadHeader:o") - } - { // Field #25 'NextWithdrawalIndex' (static) - buf := buf[exproffset+409 : exproffset+417] - t.NextWithdrawalIndex = capella.WithdrawalIndex(binary.LittleEndian.Uint64(buf)) - } - { // Field #26 'NextWithdrawalValidatorIndex' (static) - buf := buf[exproffset+417 : exproffset+425] - t.NextWithdrawalValidatorIndex = phase0.ValidatorIndex(binary.LittleEndian.Uint64(buf)) - } - // Field #27 'HistoricalSummaries' (offset) - offset27 := int(binary.LittleEndian.Uint32(buf[exproffset+425 : exproffset+429])) - if offset27 < offset24 || offset27 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset27, offset24, buflen), "HistoricalSummaries:o") - } - { // Field #28 'DepositRequestsStartIndex' (static) - buf := buf[exproffset+429 : exproffset+437] - t.DepositRequestsStartIndex = binary.LittleEndian.Uint64(buf) - } - { // Field #29 'DepositBalanceToConsume' (static) - buf := buf[exproffset+437 : exproffset+445] - t.DepositBalanceToConsume = phase0.Gwei(binary.LittleEndian.Uint64(buf)) + offset24, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "LatestExecutionPayloadHeader") } - { // Field #30 'ExitBalanceToConsume' (static) - buf := buf[exproffset+445 : exproffset+453] - t.ExitBalanceToConsume = phase0.Gwei(binary.LittleEndian.Uint64(buf)) + if offset24 < offset21 || offset24 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset24, offset21, maxOffset), "LatestExecutionPayloadHeader") } - { // Field #31 'EarliestExitEpoch' (static) - buf := buf[exproffset+453 : exproffset+461] - t.EarliestExitEpoch = phase0.Epoch(binary.LittleEndian.Uint64(buf)) + // Field #25 'NextWithdrawalIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "NextWithdrawalIndex") + } else { + t.NextWithdrawalIndex = capella.WithdrawalIndex(val) } - { // Field #32 'ConsolidationBalanceToConsume' (static) - buf := buf[exproffset+461 : exproffset+469] - t.ConsolidationBalanceToConsume = phase0.Gwei(binary.LittleEndian.Uint64(buf)) + // Field #26 'NextWithdrawalValidatorIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "NextWithdrawalValidatorIndex") + } else { + t.NextWithdrawalValidatorIndex = phase0.ValidatorIndex(val) } - { // Field #33 'EarliestConsolidationEpoch' (static) - buf := buf[exproffset+469 : exproffset+477] - t.EarliestConsolidationEpoch = phase0.Epoch(binary.LittleEndian.Uint64(buf)) + // Field #27 'HistoricalSummaries' (offset) + offset27, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "HistoricalSummaries") + } + if offset27 < offset24 || offset27 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset27, offset24, maxOffset), "HistoricalSummaries") + } + // Field #28 'DepositRequestsStartIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "DepositRequestsStartIndex") + } else { + t.DepositRequestsStartIndex = val + } + // Field #29 'DepositBalanceToConsume' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "DepositBalanceToConsume") + } else { + t.DepositBalanceToConsume = phase0.Gwei(val) + } + // Field #30 'ExitBalanceToConsume' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "ExitBalanceToConsume") + } else { + t.ExitBalanceToConsume = phase0.Gwei(val) + } + // Field #31 'EarliestExitEpoch' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "EarliestExitEpoch") + } else { + t.EarliestExitEpoch = phase0.Epoch(val) + } + // Field #32 'ConsolidationBalanceToConsume' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "ConsolidationBalanceToConsume") + } else { + t.ConsolidationBalanceToConsume = phase0.Gwei(val) + } + // Field #33 'EarliestConsolidationEpoch' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "EarliestConsolidationEpoch") + } else { + t.EarliestConsolidationEpoch = phase0.Epoch(val) } // Field #34 'PendingDeposits' (offset) - offset34 := int(binary.LittleEndian.Uint32(buf[exproffset+477 : exproffset+481])) - if offset34 < offset27 || offset34 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset34, offset27, buflen), "PendingDeposits:o") + offset34, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "PendingDeposits") + } + if offset34 < offset27 || offset34 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset34, offset27, maxOffset), "PendingDeposits") } // Field #35 'PendingPartialWithdrawals' (offset) - offset35 := int(binary.LittleEndian.Uint32(buf[exproffset+481 : exproffset+485])) - if offset35 < offset34 || offset35 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset35, offset34, buflen), "PendingPartialWithdrawals:o") + offset35, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "PendingPartialWithdrawals") + } + if offset35 < offset34 || offset35 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset35, offset34, maxOffset), "PendingPartialWithdrawals") } // Field #36 'PendingConsolidations' (offset) - offset36 := int(binary.LittleEndian.Uint32(buf[exproffset+485 : exproffset+489])) - if offset36 < offset35 || offset36 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset36, offset35, buflen), "PendingConsolidations:o") + offset36, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "PendingConsolidations") + } + if offset36 < offset35 || offset36 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset36, offset35, maxOffset), "PendingConsolidations") } { // Field #7 'HistoricalRoots' (dynamic) - buf := buf[offset7:offset9] + if dec.GetPosition() != startPos0+int(offset7) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset7)), "HistoricalRoots") + } + dec.PushLimit(int(offset9 - offset7)) val9 := t.HistoricalRoots - itemCount := len(buf) / 32 - if len(buf)%32 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 32), "HistoricalRoots") + sszLen := dec.GetLength() + itemCount := sszLen / 32 + if sszLen%32 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 32), "HistoricalRoots") } if itemCount > int(expr4) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr4)), "HistoricalRoots") } val9 = sszutils.ExpandSlice(val9, itemCount) + startPos6 := dec.GetPosition() for idx1 := range itemCount { - buf := buf[32*idx1 : 32*(idx1+1)] - copy(val9[idx1][:], buf) + if _, err = dec.DecodeBytes(val9[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos6+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos6+int(32*(idx1+1))), "HistoricalRoots[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "HistoricalRoots") } t.HistoricalRoots = val9 } { // Field #9 'ETH1DataVotes' (dynamic) - buf := buf[offset9:offset11] + if dec.GetPosition() != startPos0+int(offset9) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset9)), "ETH1DataVotes") + } + dec.PushLimit(int(offset11 - offset9)) val10 := t.ETH1DataVotes - itemCount := len(buf) / 72 - if len(buf)%72 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 72), "ETH1DataVotes") + sszLen := dec.GetLength() + itemCount := sszLen / 72 + if sszLen%72 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 72), "ETH1DataVotes") } if itemCount > int(expr5) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr5)), "ETH1DataVotes") } val10 = sszutils.ExpandSlice(val10, itemCount) + startPos7 := dec.GetPosition() for idx1 := range itemCount { if val10[idx1] == nil { val10[idx1] = new(phase0.ETH1Data) } - buf := buf[72*idx1 : 72*(idx1+1)] - if err = val10[idx1].UnmarshalSSZ(buf); err != nil { + if buf, err := dec.DecodeBytesBuf(72); err != nil { return sszutils.ErrorWithPathf(err, "ETH1DataVotes[%d]", idx1) + } else if err = val10[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "ETH1DataVotes[%d]", idx1) + } + if dec.GetPosition() != startPos7+int(72*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos7+int(72*(idx1+1))), "ETH1DataVotes[%d]", idx1) } } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "ETH1DataVotes") + } t.ETH1DataVotes = val10 } { // Field #11 'Validators' (dynamic) - buf := buf[offset11:offset12] + if dec.GetPosition() != startPos0+int(offset11) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset11)), "Validators") + } + dec.PushLimit(int(offset12 - offset11)) val11 := t.Validators - itemCount := len(buf) / 121 - if len(buf)%121 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 121), "Validators") + sszLen := dec.GetLength() + itemCount := sszLen / 121 + if sszLen%121 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 121), "Validators") } if itemCount > int(expr6) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "Validators") } val11 = sszutils.ExpandSlice(val11, itemCount) + startPos8 := dec.GetPosition() for idx1 := range itemCount { if val11[idx1] == nil { val11[idx1] = new(phase0.Validator) } - buf := buf[121*idx1 : 121*(idx1+1)] - if err = val11[idx1].UnmarshalSSZ(buf); err != nil { + if buf, err := dec.DecodeBytesBuf(121); err != nil { return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } else if err = val11[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } + if dec.GetPosition() != startPos8+int(121*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos8+int(121*(idx1+1))), "Validators[%d]", idx1) } } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Validators") + } t.Validators = val11 } { // Field #12 'Balances' (dynamic) - buf := buf[offset12:offset15] + if dec.GetPosition() != startPos0+int(offset12) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset12)), "Balances") + } + dec.PushLimit(int(offset15 - offset12)) val12 := t.Balances - itemCount := len(buf) / 8 - if len(buf)%8 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 8), "Balances") + sszLen := dec.GetLength() + itemCount := sszLen / 8 + if sszLen%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 8), "Balances") } if itemCount > int(expr6) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "Balances") } val12 = sszutils.ExpandSlice(val12, itemCount) - sszutils.UnmarshalUint64Slice(val12, buf) + if err = sszutils.DecodeUint64Slice(dec, val12); err != nil { + return sszutils.ErrorWithPath(err, "Balances") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Balances") + } t.Balances = val12 } { // Field #15 'PreviousEpochParticipation' (dynamic) - buf := buf[offset15:offset16] + if dec.GetPosition() != startPos0+int(offset15) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset15)), "PreviousEpochParticipation") + } + dec.PushLimit(int(offset16 - offset15)) val13 := t.PreviousEpochParticipation - itemCount := len(buf) + itemCount := dec.GetLength() if itemCount > int(expr6) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "PreviousEpochParticipation") } val13 = sszutils.ExpandSlice(val13, itemCount) + startPos9 := dec.GetPosition() for idx1 := range itemCount { - buf := buf[1*idx1 : 1*(idx1+1)] - val13[idx1] = altair.ParticipationFlags(buf[0]) + if val, err := dec.DecodeUint8(); err != nil { + return sszutils.ErrorWithPathf(err, "PreviousEpochParticipation[%d]", idx1) + } else { + val13[idx1] = altair.ParticipationFlags(val) + } + if dec.GetPosition() != startPos9+int(1*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos9+int(1*(idx1+1))), "PreviousEpochParticipation[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "PreviousEpochParticipation") } t.PreviousEpochParticipation = val13 } { // Field #16 'CurrentEpochParticipation' (dynamic) - buf := buf[offset16:offset21] + if dec.GetPosition() != startPos0+int(offset16) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset16)), "CurrentEpochParticipation") + } + dec.PushLimit(int(offset21 - offset16)) val14 := t.CurrentEpochParticipation - itemCount := len(buf) + itemCount := dec.GetLength() if itemCount > int(expr6) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "CurrentEpochParticipation") } val14 = sszutils.ExpandSlice(val14, itemCount) + startPos10 := dec.GetPosition() for idx1 := range itemCount { - buf := buf[1*idx1 : 1*(idx1+1)] - val14[idx1] = altair.ParticipationFlags(buf[0]) + if val, err := dec.DecodeUint8(); err != nil { + return sszutils.ErrorWithPathf(err, "CurrentEpochParticipation[%d]", idx1) + } else { + val14[idx1] = altair.ParticipationFlags(val) + } + if dec.GetPosition() != startPos10+int(1*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos10+int(1*(idx1+1))), "CurrentEpochParticipation[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "CurrentEpochParticipation") } t.CurrentEpochParticipation = val14 } { // Field #21 'InactivityScores' (dynamic) - buf := buf[offset21:offset24] + if dec.GetPosition() != startPos0+int(offset21) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset21)), "InactivityScores") + } + dec.PushLimit(int(offset24 - offset21)) val15 := t.InactivityScores - itemCount := len(buf) / 8 - if len(buf)%8 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 8), "InactivityScores") + sszLen := dec.GetLength() + itemCount := sszLen / 8 + if sszLen%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 8), "InactivityScores") } if itemCount > int(expr6) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "InactivityScores") } val15 = sszutils.ExpandSlice(val15, itemCount) - sszutils.UnmarshalUint64Slice(val15, buf) + if err = sszutils.DecodeUint64Slice(dec, val15); err != nil { + return sszutils.ErrorWithPath(err, "InactivityScores") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "InactivityScores") + } t.InactivityScores = val15 } { // Field #24 'LatestExecutionPayloadHeader' (dynamic) - buf := buf[offset24:offset27] - if t.LatestExecutionPayloadHeader == nil { - t.LatestExecutionPayloadHeader = new(ExecutionPayloadHeader) + if dec.GetPosition() != startPos0+int(offset24) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset24)), "LatestExecutionPayloadHeader") } - if viewFn := t.LatestExecutionPayloadHeader.UnmarshalSSZDynView((*deneb.ExecutionPayloadHeader)(nil)); viewFn != nil { + dec.PushLimit(int(offset27 - offset24)) + val16 := t.LatestExecutionPayloadHeader + if val16 == nil { + val16 = new(ExecutionPayloadHeader) + } + if buf, err := dec.DecodeBytesBuf(dec.GetLength()); err != nil { + return err + } else if viewFn := val16.UnmarshalSSZDynView((*deneb.ExecutionPayloadHeader)(nil)); viewFn != nil { if err = viewFn(ds, buf); err != nil { return err } } else { return sszutils.ErrNotImplemented } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "LatestExecutionPayloadHeader") + } + t.LatestExecutionPayloadHeader = val16 } { // Field #27 'HistoricalSummaries' (dynamic) - buf := buf[offset27:offset34] - val16 := t.HistoricalSummaries - itemCount := len(buf) / 64 - if len(buf)%64 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 64), "HistoricalSummaries") + if dec.GetPosition() != startPos0+int(offset27) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset27)), "HistoricalSummaries") + } + dec.PushLimit(int(offset34 - offset27)) + val17 := t.HistoricalSummaries + sszLen := dec.GetLength() + itemCount := sszLen / 64 + if sszLen%64 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 64), "HistoricalSummaries") } if itemCount > int(expr4) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr4)), "HistoricalSummaries") } - val16 = sszutils.ExpandSlice(val16, itemCount) + val17 = sszutils.ExpandSlice(val17, itemCount) + startPos11 := dec.GetPosition() for idx1 := range itemCount { - if val16[idx1] == nil { - val16[idx1] = new(capella.HistoricalSummary) + if val17[idx1] == nil { + val17[idx1] = new(capella.HistoricalSummary) } - buf := buf[64*idx1 : 64*(idx1+1)] - if err = val16[idx1].UnmarshalSSZ(buf); err != nil { + if buf, err := dec.DecodeBytesBuf(64); err != nil { return sszutils.ErrorWithPathf(err, "HistoricalSummaries[%d]", idx1) + } else if err = val17[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "HistoricalSummaries[%d]", idx1) + } + if dec.GetPosition() != startPos11+int(64*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos11+int(64*(idx1+1))), "HistoricalSummaries[%d]", idx1) } } - t.HistoricalSummaries = val16 + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "HistoricalSummaries") + } + t.HistoricalSummaries = val17 } { // Field #34 'PendingDeposits' (dynamic) - buf := buf[offset34:offset35] - val17 := t.PendingDeposits - itemCount := len(buf) / 192 - if len(buf)%192 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 192), "PendingDeposits") + if dec.GetPosition() != startPos0+int(offset34) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset34)), "PendingDeposits") + } + dec.PushLimit(int(offset35 - offset34)) + val18 := t.PendingDeposits + sszLen := dec.GetLength() + itemCount := sszLen / 192 + if sszLen%192 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 192), "PendingDeposits") } if itemCount > int(expr7) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr7)), "PendingDeposits") } - val17 = sszutils.ExpandSlice(val17, itemCount) + val18 = sszutils.ExpandSlice(val18, itemCount) + startPos12 := dec.GetPosition() for idx1 := range itemCount { - if val17[idx1] == nil { - val17[idx1] = new(electra.PendingDeposit) + if val18[idx1] == nil { + val18[idx1] = new(electra.PendingDeposit) } - buf := buf[192*idx1 : 192*(idx1+1)] - if err = val17[idx1].UnmarshalSSZ(buf); err != nil { + if buf, err := dec.DecodeBytesBuf(192); err != nil { return sszutils.ErrorWithPathf(err, "PendingDeposits[%d]", idx1) + } else if err = val18[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "PendingDeposits[%d]", idx1) + } + if dec.GetPosition() != startPos12+int(192*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos12+int(192*(idx1+1))), "PendingDeposits[%d]", idx1) } } - t.PendingDeposits = val17 + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "PendingDeposits") + } + t.PendingDeposits = val18 } { // Field #35 'PendingPartialWithdrawals' (dynamic) - buf := buf[offset35:offset36] - val18 := t.PendingPartialWithdrawals - itemCount := len(buf) / 24 - if len(buf)%24 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 24), "PendingPartialWithdrawals") + if dec.GetPosition() != startPos0+int(offset35) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset35)), "PendingPartialWithdrawals") + } + dec.PushLimit(int(offset36 - offset35)) + val19 := t.PendingPartialWithdrawals + sszLen := dec.GetLength() + itemCount := sszLen / 24 + if sszLen%24 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 24), "PendingPartialWithdrawals") } if itemCount > int(expr8) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr8)), "PendingPartialWithdrawals") } - val18 = sszutils.ExpandSlice(val18, itemCount) + val19 = sszutils.ExpandSlice(val19, itemCount) + startPos13 := dec.GetPosition() for idx1 := range itemCount { - if val18[idx1] == nil { - val18[idx1] = new(electra.PendingPartialWithdrawal) + if val19[idx1] == nil { + val19[idx1] = new(electra.PendingPartialWithdrawal) } - buf := buf[24*idx1 : 24*(idx1+1)] - if err = val18[idx1].UnmarshalSSZ(buf); err != nil { + if buf, err := dec.DecodeBytesBuf(24); err != nil { return sszutils.ErrorWithPathf(err, "PendingPartialWithdrawals[%d]", idx1) + } else if err = val19[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "PendingPartialWithdrawals[%d]", idx1) + } + if dec.GetPosition() != startPos13+int(24*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos13+int(24*(idx1+1))), "PendingPartialWithdrawals[%d]", idx1) } } - t.PendingPartialWithdrawals = val18 + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "PendingPartialWithdrawals") + } + t.PendingPartialWithdrawals = val19 } { // Field #36 'PendingConsolidations' (dynamic) - buf := buf[offset36:] - val19 := t.PendingConsolidations - itemCount := len(buf) / 16 - if len(buf)%16 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 16), "PendingConsolidations") + if dec.GetPosition() != startPos0+int(offset36) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset36)), "PendingConsolidations") + } + dec.PushLimit(int(maxOffset - offset36)) + val20 := t.PendingConsolidations + sszLen := dec.GetLength() + itemCount := sszLen / 16 + if sszLen%16 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 16), "PendingConsolidations") } if itemCount > int(expr9) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr9)), "PendingConsolidations") } - val19 = sszutils.ExpandSlice(val19, itemCount) + val20 = sszutils.ExpandSlice(val20, itemCount) + startPos14 := dec.GetPosition() for idx1 := range itemCount { - if val19[idx1] == nil { - val19[idx1] = new(electra.PendingConsolidation) + if val20[idx1] == nil { + val20[idx1] = new(electra.PendingConsolidation) } - buf := buf[16*idx1 : 16*(idx1+1)] - if err = val19[idx1].UnmarshalSSZ(buf); err != nil { + if buf, err := dec.DecodeBytesBuf(16); err != nil { return sszutils.ErrorWithPathf(err, "PendingConsolidations[%d]", idx1) + } else if err = val20[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "PendingConsolidations[%d]", idx1) + } + if dec.GetPosition() != startPos14+int(16*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos14+int(16*(idx1+1))), "PendingConsolidations[%d]", idx1) } } - t.PendingConsolidations = val19 + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "PendingConsolidations") + } + t.PendingConsolidations = val20 } return nil } -func (t *BeaconState) unmarshalSSZView_BeaconState_5(ds sszutils.DynamicSpecs, buf []byte) (err error) { +func (t *BeaconState) unmarshalSSZDecoderView_BeaconState_5(ds sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { expr0, err := sszutils.ResolveSpecValueWithDefault(ds, "SLOTS_PER_HISTORICAL_ROOT", 8192) if err != nil { return err @@ -6251,510 +16963,715 @@ func (t *BeaconState) unmarshalSSZView_BeaconState_5(ds sszutils.DynamicSpecs, b size5 := 48 * int(expr3) size4 := size5 + 48 // size expression for '*SyncCommittee' size6 := 8 * int(expr4) - exproffset := 0 totalSize := size1+size1+size2+size3+size4+size4+size6+489 - buflen := len(buf) - if buflen < totalSize { - return sszutils.ErrFixedFieldsEOFFn(buflen, totalSize) + maxOffset := uint32(dec.GetLength()) + startPos0 := dec.GetPosition() + if maxOffset < uint32(totalSize) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(totalSize)) + } + // Field #0 'GenesisTime' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "GenesisTime") + } else { + t.GenesisTime = val + } + // Field #1 'GenesisValidatorsRoot' (static) + if _, err = dec.DecodeBytes(t.GenesisValidatorsRoot[:32]); err != nil { + return err } - { // Field #0 'GenesisTime' (static) - buf := buf[0:8] - t.GenesisTime = binary.LittleEndian.Uint64(buf) + // Field #2 'Slot' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "Slot") + } else { + t.Slot = phase0.Slot(val) } - { // Field #1 'GenesisValidatorsRoot' (static) - buf := buf[8:40] - copy(t.GenesisValidatorsRoot[:], buf) + // Field #3 'Fork' (static) + if t.Fork == nil { + t.Fork = new(phase0.Fork) } - { // Field #2 'Slot' (static) - buf := buf[40:48] - t.Slot = phase0.Slot(binary.LittleEndian.Uint64(buf)) + if buf, err := dec.DecodeBytesBuf(16); err != nil { + return sszutils.ErrorWithPath(err, "Fork") + } else if err = t.Fork.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "Fork") } - { // Field #3 'Fork' (static) - buf := buf[48:64] - if t.Fork == nil { - t.Fork = new(phase0.Fork) - } - if err = t.Fork.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "Fork") - } + // Field #4 'LatestBlockHeader' (static) + if t.LatestBlockHeader == nil { + t.LatestBlockHeader = new(phase0.BeaconBlockHeader) } - { // Field #4 'LatestBlockHeader' (static) - buf := buf[64:176] - if t.LatestBlockHeader == nil { - t.LatestBlockHeader = new(phase0.BeaconBlockHeader) - } - if err = t.LatestBlockHeader.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "LatestBlockHeader") - } + if buf, err := dec.DecodeBytesBuf(112); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") + } else if err = t.LatestBlockHeader.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") } { // Field #5 'BlockRoots' (static) - buf := buf[176 : size1+176] - exproffset += int(size1) val1 := t.BlockRoots val1 = sszutils.ExpandSlice(val1, int(expr0)) + startPos1 := dec.GetPosition() for idx1 := range int(expr0) { - buf := buf[32*idx1 : 32*(idx1+1)] - copy(val1[idx1][:], buf) + if _, err = dec.DecodeBytes(val1[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos1+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos1+int(32*(idx1+1))), "BlockRoots[%d]", idx1) + } } t.BlockRoots = val1 } { // Field #6 'StateRoots' (static) - buf := buf[exproffset+176 : exproffset+size1+176] - exproffset += int(size1) val2 := t.StateRoots val2 = sszutils.ExpandSlice(val2, int(expr0)) + startPos2 := dec.GetPosition() for idx1 := range int(expr0) { - buf := buf[32*idx1 : 32*(idx1+1)] - copy(val2[idx1][:], buf) + if _, err = dec.DecodeBytes(val2[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos2+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos2+int(32*(idx1+1))), "StateRoots[%d]", idx1) + } } t.StateRoots = val2 } // Field #7 'HistoricalRoots' (offset) - offset7 := int(binary.LittleEndian.Uint32(buf[exproffset+176 : exproffset+180])) - if offset7 != totalSize { - return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset7, totalSize), "HistoricalRoots:o") + offset7, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "HistoricalRoots") } - { // Field #8 'ETH1Data' (static) - buf := buf[exproffset+180 : exproffset+252] - if t.ETH1Data == nil { - t.ETH1Data = new(phase0.ETH1Data) - } - if err = t.ETH1Data.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "ETH1Data") - } + if offset7 != uint32(totalSize) { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset7, totalSize), "HistoricalRoots") + } + // Field #8 'ETH1Data' (static) + if t.ETH1Data == nil { + t.ETH1Data = new(phase0.ETH1Data) + } + if buf, err := dec.DecodeBytesBuf(72); err != nil { + return sszutils.ErrorWithPath(err, "ETH1Data") + } else if err = t.ETH1Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "ETH1Data") } // Field #9 'ETH1DataVotes' (offset) - offset9 := int(binary.LittleEndian.Uint32(buf[exproffset+252 : exproffset+256])) - if offset9 < offset7 || offset9 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset9, offset7, buflen), "ETH1DataVotes:o") + offset9, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "ETH1DataVotes") } - { // Field #10 'ETH1DepositIndex' (static) - buf := buf[exproffset+256 : exproffset+264] - t.ETH1DepositIndex = binary.LittleEndian.Uint64(buf) + if offset9 < offset7 || offset9 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset9, offset7, maxOffset), "ETH1DataVotes") + } + // Field #10 'ETH1DepositIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "ETH1DepositIndex") + } else { + t.ETH1DepositIndex = val } // Field #11 'Validators' (offset) - offset11 := int(binary.LittleEndian.Uint32(buf[exproffset+264 : exproffset+268])) - if offset11 < offset9 || offset11 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset11, offset9, buflen), "Validators:o") + offset11, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Validators") + } + if offset11 < offset9 || offset11 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset11, offset9, maxOffset), "Validators") } // Field #12 'Balances' (offset) - offset12 := int(binary.LittleEndian.Uint32(buf[exproffset+268 : exproffset+272])) - if offset12 < offset11 || offset12 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset12, offset11, buflen), "Balances:o") + offset12, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Balances") + } + if offset12 < offset11 || offset12 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset12, offset11, maxOffset), "Balances") } { // Field #13 'RANDAOMixes' (static) - buf := buf[exproffset+272 : exproffset+size2+272] - exproffset += int(size2) val3 := t.RANDAOMixes val3 = sszutils.ExpandSlice(val3, int(expr1)) + startPos3 := dec.GetPosition() for idx1 := range int(expr1) { - buf := buf[32*idx1 : 32*(idx1+1)] - copy(val3[idx1][:], buf) + if _, err = dec.DecodeBytes(val3[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos3+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos3+int(32*(idx1+1))), "RANDAOMixes[%d]", idx1) + } } t.RANDAOMixes = val3 } { // Field #14 'Slashings' (static) - buf := buf[exproffset+272 : exproffset+size3+272] - exproffset += int(size3) val4 := t.Slashings val4 = sszutils.ExpandSlice(val4, int(expr2)) - sszutils.UnmarshalUint64Slice(val4[:int(expr2)], buf) + if err = sszutils.DecodeUint64Slice(dec, val4[:int(expr2)]); err != nil { + return sszutils.ErrorWithPath(err, "Slashings") + } t.Slashings = val4 } // Field #15 'PreviousEpochParticipation' (offset) - offset15 := int(binary.LittleEndian.Uint32(buf[exproffset+272 : exproffset+276])) - if offset15 < offset12 || offset15 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset15, offset12, buflen), "PreviousEpochParticipation:o") + offset15, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "PreviousEpochParticipation") + } + if offset15 < offset12 || offset15 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset15, offset12, maxOffset), "PreviousEpochParticipation") } // Field #16 'CurrentEpochParticipation' (offset) - offset16 := int(binary.LittleEndian.Uint32(buf[exproffset+276 : exproffset+280])) - if offset16 < offset15 || offset16 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset16, offset15, buflen), "CurrentEpochParticipation:o") + offset16, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "CurrentEpochParticipation") } - { // Field #17 'JustificationBits' (static) - buf := buf[exproffset+280 : exproffset+281] - t.JustificationBits = sszutils.ExpandSlice(t.JustificationBits, 1) - copy(t.JustificationBits[:], buf) + if offset16 < offset15 || offset16 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset16, offset15, maxOffset), "CurrentEpochParticipation") } - { // Field #18 'PreviousJustifiedCheckpoint' (static) - buf := buf[exproffset+281 : exproffset+321] - if t.PreviousJustifiedCheckpoint == nil { - t.PreviousJustifiedCheckpoint = new(phase0.Checkpoint) - } - if err = t.PreviousJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") - } + // Field #17 'JustificationBits' (static) + t.JustificationBits = sszutils.ExpandSlice(t.JustificationBits, 1) + if _, err = dec.DecodeBytes(t.JustificationBits[:1]); err != nil { + return err } - { // Field #19 'CurrentJustifiedCheckpoint' (static) - buf := buf[exproffset+321 : exproffset+361] - if t.CurrentJustifiedCheckpoint == nil { - t.CurrentJustifiedCheckpoint = new(phase0.Checkpoint) - } - if err = t.CurrentJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") - } + // Field #18 'PreviousJustifiedCheckpoint' (static) + if t.PreviousJustifiedCheckpoint == nil { + t.PreviousJustifiedCheckpoint = new(phase0.Checkpoint) } - { // Field #20 'FinalizedCheckpoint' (static) - buf := buf[exproffset+361 : exproffset+401] - if t.FinalizedCheckpoint == nil { - t.FinalizedCheckpoint = new(phase0.Checkpoint) - } - if err = t.FinalizedCheckpoint.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") - } + if buf, err := dec.DecodeBytesBuf(40); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } else if err = t.PreviousJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } + // Field #19 'CurrentJustifiedCheckpoint' (static) + if t.CurrentJustifiedCheckpoint == nil { + t.CurrentJustifiedCheckpoint = new(phase0.Checkpoint) + } + if buf, err := dec.DecodeBytesBuf(40); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } else if err = t.CurrentJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } + // Field #20 'FinalizedCheckpoint' (static) + if t.FinalizedCheckpoint == nil { + t.FinalizedCheckpoint = new(phase0.Checkpoint) + } + if buf, err := dec.DecodeBytesBuf(40); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") + } else if err = t.FinalizedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") } // Field #21 'InactivityScores' (offset) - offset21 := int(binary.LittleEndian.Uint32(buf[exproffset+401 : exproffset+405])) - if offset21 < offset16 || offset21 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset21, offset16, buflen), "InactivityScores:o") + offset21, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "InactivityScores") + } + if offset21 < offset16 || offset21 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset21, offset16, maxOffset), "InactivityScores") } { // Field #22 'CurrentSyncCommittee' (static) - buf := buf[exproffset+405 : exproffset+size4+405] - exproffset += int(size4) val5 := t.CurrentSyncCommittee if val5 == nil { val5 = new(altair.SyncCommittee) } - exproffset := 0 totalSize := size5+48 - buflen := len(buf) - if buflen < totalSize { - return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, totalSize), "CurrentSyncCommittee") + maxOffset := uint32(dec.GetLength()) + if maxOffset < uint32(totalSize) { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(totalSize)), "CurrentSyncCommittee") } { // Field #0 'Pubkeys' (static) - buf := buf[0 : size5+0] - exproffset += int(size5) val6 := val5.Pubkeys val6 = sszutils.ExpandSlice(val6, int(expr3)) + startPos4 := dec.GetPosition() for idx1 := range int(expr3) { - buf := buf[48*idx1 : 48*(idx1+1)] - copy(val6[idx1][:], buf) + if _, err = dec.DecodeBytes(val6[idx1][:48]); err != nil { + return err + } + if dec.GetPosition() != startPos4+int(48*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos4+int(48*(idx1+1))), "CurrentSyncCommittee.Pubkeys[%d]", idx1) + } } val5.Pubkeys = val6 } - { // Field #1 'AggregatePubkey' (static) - buf := buf[exproffset+0 : exproffset+48] - copy(val5.AggregatePubkey[:], buf) + // Field #1 'AggregatePubkey' (static) + if _, err = dec.DecodeBytes(val5.AggregatePubkey[:48]); err != nil { + return err } t.CurrentSyncCommittee = val5 } { // Field #23 'NextSyncCommittee' (static) - buf := buf[exproffset+405 : exproffset+size4+405] - exproffset += int(size4) val7 := t.NextSyncCommittee if val7 == nil { val7 = new(altair.SyncCommittee) } - exproffset := 0 totalSize := size5+48 - buflen := len(buf) - if buflen < totalSize { - return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, totalSize), "NextSyncCommittee") + maxOffset := uint32(dec.GetLength()) + if maxOffset < uint32(totalSize) { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(totalSize)), "NextSyncCommittee") } { // Field #0 'Pubkeys' (static) - buf := buf[0 : size5+0] - exproffset += int(size5) val8 := val7.Pubkeys val8 = sszutils.ExpandSlice(val8, int(expr3)) + startPos5 := dec.GetPosition() for idx1 := range int(expr3) { - buf := buf[48*idx1 : 48*(idx1+1)] - copy(val8[idx1][:], buf) + if _, err = dec.DecodeBytes(val8[idx1][:48]); err != nil { + return err + } + if dec.GetPosition() != startPos5+int(48*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos5+int(48*(idx1+1))), "NextSyncCommittee.Pubkeys[%d]", idx1) + } } - val7.Pubkeys = val8 - } - { // Field #1 'AggregatePubkey' (static) - buf := buf[exproffset+0 : exproffset+48] - copy(val7.AggregatePubkey[:], buf) + val7.Pubkeys = val8 + } + // Field #1 'AggregatePubkey' (static) + if _, err = dec.DecodeBytes(val7.AggregatePubkey[:48]); err != nil { + return err } t.NextSyncCommittee = val7 } // Field #24 'LatestExecutionPayloadHeader' (offset) - offset24 := int(binary.LittleEndian.Uint32(buf[exproffset+405 : exproffset+409])) - if offset24 < offset21 || offset24 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset24, offset21, buflen), "LatestExecutionPayloadHeader:o") - } - { // Field #25 'NextWithdrawalIndex' (static) - buf := buf[exproffset+409 : exproffset+417] - t.NextWithdrawalIndex = capella.WithdrawalIndex(binary.LittleEndian.Uint64(buf)) - } - { // Field #26 'NextWithdrawalValidatorIndex' (static) - buf := buf[exproffset+417 : exproffset+425] - t.NextWithdrawalValidatorIndex = phase0.ValidatorIndex(binary.LittleEndian.Uint64(buf)) - } - // Field #27 'HistoricalSummaries' (offset) - offset27 := int(binary.LittleEndian.Uint32(buf[exproffset+425 : exproffset+429])) - if offset27 < offset24 || offset27 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset27, offset24, buflen), "HistoricalSummaries:o") - } - { // Field #28 'DepositRequestsStartIndex' (static) - buf := buf[exproffset+429 : exproffset+437] - t.DepositRequestsStartIndex = binary.LittleEndian.Uint64(buf) - } - { // Field #29 'DepositBalanceToConsume' (static) - buf := buf[exproffset+437 : exproffset+445] - t.DepositBalanceToConsume = phase0.Gwei(binary.LittleEndian.Uint64(buf)) + offset24, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "LatestExecutionPayloadHeader") } - { // Field #30 'ExitBalanceToConsume' (static) - buf := buf[exproffset+445 : exproffset+453] - t.ExitBalanceToConsume = phase0.Gwei(binary.LittleEndian.Uint64(buf)) + if offset24 < offset21 || offset24 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset24, offset21, maxOffset), "LatestExecutionPayloadHeader") } - { // Field #31 'EarliestExitEpoch' (static) - buf := buf[exproffset+453 : exproffset+461] - t.EarliestExitEpoch = phase0.Epoch(binary.LittleEndian.Uint64(buf)) + // Field #25 'NextWithdrawalIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "NextWithdrawalIndex") + } else { + t.NextWithdrawalIndex = capella.WithdrawalIndex(val) } - { // Field #32 'ConsolidationBalanceToConsume' (static) - buf := buf[exproffset+461 : exproffset+469] - t.ConsolidationBalanceToConsume = phase0.Gwei(binary.LittleEndian.Uint64(buf)) + // Field #26 'NextWithdrawalValidatorIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "NextWithdrawalValidatorIndex") + } else { + t.NextWithdrawalValidatorIndex = phase0.ValidatorIndex(val) } - { // Field #33 'EarliestConsolidationEpoch' (static) - buf := buf[exproffset+469 : exproffset+477] - t.EarliestConsolidationEpoch = phase0.Epoch(binary.LittleEndian.Uint64(buf)) + // Field #27 'HistoricalSummaries' (offset) + offset27, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "HistoricalSummaries") + } + if offset27 < offset24 || offset27 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset27, offset24, maxOffset), "HistoricalSummaries") + } + // Field #28 'DepositRequestsStartIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "DepositRequestsStartIndex") + } else { + t.DepositRequestsStartIndex = val + } + // Field #29 'DepositBalanceToConsume' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "DepositBalanceToConsume") + } else { + t.DepositBalanceToConsume = phase0.Gwei(val) + } + // Field #30 'ExitBalanceToConsume' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "ExitBalanceToConsume") + } else { + t.ExitBalanceToConsume = phase0.Gwei(val) + } + // Field #31 'EarliestExitEpoch' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "EarliestExitEpoch") + } else { + t.EarliestExitEpoch = phase0.Epoch(val) + } + // Field #32 'ConsolidationBalanceToConsume' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "ConsolidationBalanceToConsume") + } else { + t.ConsolidationBalanceToConsume = phase0.Gwei(val) + } + // Field #33 'EarliestConsolidationEpoch' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "EarliestConsolidationEpoch") + } else { + t.EarliestConsolidationEpoch = phase0.Epoch(val) } // Field #34 'PendingDeposits' (offset) - offset34 := int(binary.LittleEndian.Uint32(buf[exproffset+477 : exproffset+481])) - if offset34 < offset27 || offset34 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset34, offset27, buflen), "PendingDeposits:o") + offset34, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "PendingDeposits") + } + if offset34 < offset27 || offset34 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset34, offset27, maxOffset), "PendingDeposits") } // Field #35 'PendingPartialWithdrawals' (offset) - offset35 := int(binary.LittleEndian.Uint32(buf[exproffset+481 : exproffset+485])) - if offset35 < offset34 || offset35 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset35, offset34, buflen), "PendingPartialWithdrawals:o") + offset35, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "PendingPartialWithdrawals") + } + if offset35 < offset34 || offset35 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset35, offset34, maxOffset), "PendingPartialWithdrawals") } // Field #36 'PendingConsolidations' (offset) - offset36 := int(binary.LittleEndian.Uint32(buf[exproffset+485 : exproffset+489])) - if offset36 < offset35 || offset36 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset36, offset35, buflen), "PendingConsolidations:o") + offset36, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "PendingConsolidations") + } + if offset36 < offset35 || offset36 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset36, offset35, maxOffset), "PendingConsolidations") } { // Field #37 'ProposerLookahead' (static) - buf := buf[exproffset+489 : exproffset+size6+489] - exproffset += int(size6) val9 := t.ProposerLookahead val9 = sszutils.ExpandSlice(val9, int(expr4)) - sszutils.UnmarshalUint64Slice(val9[:int(expr4)], buf) + if err = sszutils.DecodeUint64Slice(dec, val9[:int(expr4)]); err != nil { + return sszutils.ErrorWithPath(err, "ProposerLookahead") + } t.ProposerLookahead = val9 } { // Field #7 'HistoricalRoots' (dynamic) - buf := buf[offset7:offset9] + if dec.GetPosition() != startPos0+int(offset7) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset7)), "HistoricalRoots") + } + dec.PushLimit(int(offset9 - offset7)) val10 := t.HistoricalRoots - itemCount := len(buf) / 32 - if len(buf)%32 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 32), "HistoricalRoots") + sszLen := dec.GetLength() + itemCount := sszLen / 32 + if sszLen%32 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 32), "HistoricalRoots") } if itemCount > int(expr5) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr5)), "HistoricalRoots") } val10 = sszutils.ExpandSlice(val10, itemCount) + startPos6 := dec.GetPosition() for idx1 := range itemCount { - buf := buf[32*idx1 : 32*(idx1+1)] - copy(val10[idx1][:], buf) + if _, err = dec.DecodeBytes(val10[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos6+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos6+int(32*(idx1+1))), "HistoricalRoots[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "HistoricalRoots") } t.HistoricalRoots = val10 } { // Field #9 'ETH1DataVotes' (dynamic) - buf := buf[offset9:offset11] + if dec.GetPosition() != startPos0+int(offset9) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset9)), "ETH1DataVotes") + } + dec.PushLimit(int(offset11 - offset9)) val11 := t.ETH1DataVotes - itemCount := len(buf) / 72 - if len(buf)%72 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 72), "ETH1DataVotes") + sszLen := dec.GetLength() + itemCount := sszLen / 72 + if sszLen%72 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 72), "ETH1DataVotes") } if itemCount > int(expr6) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "ETH1DataVotes") } val11 = sszutils.ExpandSlice(val11, itemCount) + startPos7 := dec.GetPosition() for idx1 := range itemCount { if val11[idx1] == nil { val11[idx1] = new(phase0.ETH1Data) } - buf := buf[72*idx1 : 72*(idx1+1)] - if err = val11[idx1].UnmarshalSSZ(buf); err != nil { + if buf, err := dec.DecodeBytesBuf(72); err != nil { + return sszutils.ErrorWithPathf(err, "ETH1DataVotes[%d]", idx1) + } else if err = val11[idx1].UnmarshalSSZ(buf); err != nil { return sszutils.ErrorWithPathf(err, "ETH1DataVotes[%d]", idx1) } + if dec.GetPosition() != startPos7+int(72*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos7+int(72*(idx1+1))), "ETH1DataVotes[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "ETH1DataVotes") } t.ETH1DataVotes = val11 } { // Field #11 'Validators' (dynamic) - buf := buf[offset11:offset12] + if dec.GetPosition() != startPos0+int(offset11) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset11)), "Validators") + } + dec.PushLimit(int(offset12 - offset11)) val12 := t.Validators - itemCount := len(buf) / 121 - if len(buf)%121 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 121), "Validators") + sszLen := dec.GetLength() + itemCount := sszLen / 121 + if sszLen%121 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 121), "Validators") } if itemCount > int(expr7) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr7)), "Validators") } val12 = sszutils.ExpandSlice(val12, itemCount) + startPos8 := dec.GetPosition() for idx1 := range itemCount { if val12[idx1] == nil { val12[idx1] = new(phase0.Validator) } - buf := buf[121*idx1 : 121*(idx1+1)] - if err = val12[idx1].UnmarshalSSZ(buf); err != nil { + if buf, err := dec.DecodeBytesBuf(121); err != nil { + return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } else if err = val12[idx1].UnmarshalSSZ(buf); err != nil { return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) } + if dec.GetPosition() != startPos8+int(121*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos8+int(121*(idx1+1))), "Validators[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Validators") } t.Validators = val12 } { // Field #12 'Balances' (dynamic) - buf := buf[offset12:offset15] + if dec.GetPosition() != startPos0+int(offset12) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset12)), "Balances") + } + dec.PushLimit(int(offset15 - offset12)) val13 := t.Balances - itemCount := len(buf) / 8 - if len(buf)%8 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 8), "Balances") + sszLen := dec.GetLength() + itemCount := sszLen / 8 + if sszLen%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 8), "Balances") } if itemCount > int(expr7) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr7)), "Balances") } val13 = sszutils.ExpandSlice(val13, itemCount) - sszutils.UnmarshalUint64Slice(val13, buf) + if err = sszutils.DecodeUint64Slice(dec, val13); err != nil { + return sszutils.ErrorWithPath(err, "Balances") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Balances") + } t.Balances = val13 } { // Field #15 'PreviousEpochParticipation' (dynamic) - buf := buf[offset15:offset16] + if dec.GetPosition() != startPos0+int(offset15) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset15)), "PreviousEpochParticipation") + } + dec.PushLimit(int(offset16 - offset15)) val14 := t.PreviousEpochParticipation - itemCount := len(buf) + itemCount := dec.GetLength() if itemCount > int(expr7) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr7)), "PreviousEpochParticipation") } val14 = sszutils.ExpandSlice(val14, itemCount) + startPos9 := dec.GetPosition() for idx1 := range itemCount { - buf := buf[1*idx1 : 1*(idx1+1)] - val14[idx1] = altair.ParticipationFlags(buf[0]) + if val, err := dec.DecodeUint8(); err != nil { + return sszutils.ErrorWithPathf(err, "PreviousEpochParticipation[%d]", idx1) + } else { + val14[idx1] = altair.ParticipationFlags(val) + } + if dec.GetPosition() != startPos9+int(1*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos9+int(1*(idx1+1))), "PreviousEpochParticipation[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "PreviousEpochParticipation") } t.PreviousEpochParticipation = val14 } { // Field #16 'CurrentEpochParticipation' (dynamic) - buf := buf[offset16:offset21] + if dec.GetPosition() != startPos0+int(offset16) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset16)), "CurrentEpochParticipation") + } + dec.PushLimit(int(offset21 - offset16)) val15 := t.CurrentEpochParticipation - itemCount := len(buf) + itemCount := dec.GetLength() if itemCount > int(expr7) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr7)), "CurrentEpochParticipation") } val15 = sszutils.ExpandSlice(val15, itemCount) + startPos10 := dec.GetPosition() for idx1 := range itemCount { - buf := buf[1*idx1 : 1*(idx1+1)] - val15[idx1] = altair.ParticipationFlags(buf[0]) + if val, err := dec.DecodeUint8(); err != nil { + return sszutils.ErrorWithPathf(err, "CurrentEpochParticipation[%d]", idx1) + } else { + val15[idx1] = altair.ParticipationFlags(val) + } + if dec.GetPosition() != startPos10+int(1*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos10+int(1*(idx1+1))), "CurrentEpochParticipation[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "CurrentEpochParticipation") } t.CurrentEpochParticipation = val15 } { // Field #21 'InactivityScores' (dynamic) - buf := buf[offset21:offset24] + if dec.GetPosition() != startPos0+int(offset21) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset21)), "InactivityScores") + } + dec.PushLimit(int(offset24 - offset21)) val16 := t.InactivityScores - itemCount := len(buf) / 8 - if len(buf)%8 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 8), "InactivityScores") + sszLen := dec.GetLength() + itemCount := sszLen / 8 + if sszLen%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 8), "InactivityScores") } if itemCount > int(expr7) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr7)), "InactivityScores") } val16 = sszutils.ExpandSlice(val16, itemCount) - sszutils.UnmarshalUint64Slice(val16, buf) + if err = sszutils.DecodeUint64Slice(dec, val16); err != nil { + return sszutils.ErrorWithPath(err, "InactivityScores") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "InactivityScores") + } t.InactivityScores = val16 } { // Field #24 'LatestExecutionPayloadHeader' (dynamic) - buf := buf[offset24:offset27] - if t.LatestExecutionPayloadHeader == nil { - t.LatestExecutionPayloadHeader = new(ExecutionPayloadHeader) + if dec.GetPosition() != startPos0+int(offset24) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset24)), "LatestExecutionPayloadHeader") } - if viewFn := t.LatestExecutionPayloadHeader.UnmarshalSSZDynView((*deneb.ExecutionPayloadHeader)(nil)); viewFn != nil { + dec.PushLimit(int(offset27 - offset24)) + val17 := t.LatestExecutionPayloadHeader + if val17 == nil { + val17 = new(ExecutionPayloadHeader) + } + if buf, err := dec.DecodeBytesBuf(dec.GetLength()); err != nil { + return err + } else if viewFn := val17.UnmarshalSSZDynView((*deneb.ExecutionPayloadHeader)(nil)); viewFn != nil { if err = viewFn(ds, buf); err != nil { return err } } else { return sszutils.ErrNotImplemented } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "LatestExecutionPayloadHeader") + } + t.LatestExecutionPayloadHeader = val17 } { // Field #27 'HistoricalSummaries' (dynamic) - buf := buf[offset27:offset34] - val17 := t.HistoricalSummaries - itemCount := len(buf) / 64 - if len(buf)%64 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 64), "HistoricalSummaries") + if dec.GetPosition() != startPos0+int(offset27) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset27)), "HistoricalSummaries") + } + dec.PushLimit(int(offset34 - offset27)) + val18 := t.HistoricalSummaries + sszLen := dec.GetLength() + itemCount := sszLen / 64 + if sszLen%64 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 64), "HistoricalSummaries") } if itemCount > int(expr5) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr5)), "HistoricalSummaries") } - val17 = sszutils.ExpandSlice(val17, itemCount) + val18 = sszutils.ExpandSlice(val18, itemCount) + startPos11 := dec.GetPosition() for idx1 := range itemCount { - if val17[idx1] == nil { - val17[idx1] = new(capella.HistoricalSummary) + if val18[idx1] == nil { + val18[idx1] = new(capella.HistoricalSummary) } - buf := buf[64*idx1 : 64*(idx1+1)] - if err = val17[idx1].UnmarshalSSZ(buf); err != nil { + if buf, err := dec.DecodeBytesBuf(64); err != nil { + return sszutils.ErrorWithPathf(err, "HistoricalSummaries[%d]", idx1) + } else if err = val18[idx1].UnmarshalSSZ(buf); err != nil { return sszutils.ErrorWithPathf(err, "HistoricalSummaries[%d]", idx1) } + if dec.GetPosition() != startPos11+int(64*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos11+int(64*(idx1+1))), "HistoricalSummaries[%d]", idx1) + } } - t.HistoricalSummaries = val17 + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "HistoricalSummaries") + } + t.HistoricalSummaries = val18 } { // Field #34 'PendingDeposits' (dynamic) - buf := buf[offset34:offset35] - val18 := t.PendingDeposits - itemCount := len(buf) / 192 - if len(buf)%192 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 192), "PendingDeposits") + if dec.GetPosition() != startPos0+int(offset34) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset34)), "PendingDeposits") + } + dec.PushLimit(int(offset35 - offset34)) + val19 := t.PendingDeposits + sszLen := dec.GetLength() + itemCount := sszLen / 192 + if sszLen%192 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 192), "PendingDeposits") } if itemCount > int(expr8) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr8)), "PendingDeposits") } - val18 = sszutils.ExpandSlice(val18, itemCount) + val19 = sszutils.ExpandSlice(val19, itemCount) + startPos12 := dec.GetPosition() for idx1 := range itemCount { - if val18[idx1] == nil { - val18[idx1] = new(electra.PendingDeposit) + if val19[idx1] == nil { + val19[idx1] = new(electra.PendingDeposit) } - buf := buf[192*idx1 : 192*(idx1+1)] - if err = val18[idx1].UnmarshalSSZ(buf); err != nil { + if buf, err := dec.DecodeBytesBuf(192); err != nil { return sszutils.ErrorWithPathf(err, "PendingDeposits[%d]", idx1) + } else if err = val19[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "PendingDeposits[%d]", idx1) + } + if dec.GetPosition() != startPos12+int(192*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos12+int(192*(idx1+1))), "PendingDeposits[%d]", idx1) } } - t.PendingDeposits = val18 + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "PendingDeposits") + } + t.PendingDeposits = val19 } { // Field #35 'PendingPartialWithdrawals' (dynamic) - buf := buf[offset35:offset36] - val19 := t.PendingPartialWithdrawals - itemCount := len(buf) / 24 - if len(buf)%24 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 24), "PendingPartialWithdrawals") + if dec.GetPosition() != startPos0+int(offset35) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset35)), "PendingPartialWithdrawals") + } + dec.PushLimit(int(offset36 - offset35)) + val20 := t.PendingPartialWithdrawals + sszLen := dec.GetLength() + itemCount := sszLen / 24 + if sszLen%24 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 24), "PendingPartialWithdrawals") } if itemCount > int(expr9) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr9)), "PendingPartialWithdrawals") } - val19 = sszutils.ExpandSlice(val19, itemCount) + val20 = sszutils.ExpandSlice(val20, itemCount) + startPos13 := dec.GetPosition() for idx1 := range itemCount { - if val19[idx1] == nil { - val19[idx1] = new(electra.PendingPartialWithdrawal) + if val20[idx1] == nil { + val20[idx1] = new(electra.PendingPartialWithdrawal) } - buf := buf[24*idx1 : 24*(idx1+1)] - if err = val19[idx1].UnmarshalSSZ(buf); err != nil { + if buf, err := dec.DecodeBytesBuf(24); err != nil { + return sszutils.ErrorWithPathf(err, "PendingPartialWithdrawals[%d]", idx1) + } else if err = val20[idx1].UnmarshalSSZ(buf); err != nil { return sszutils.ErrorWithPathf(err, "PendingPartialWithdrawals[%d]", idx1) } + if dec.GetPosition() != startPos13+int(24*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos13+int(24*(idx1+1))), "PendingPartialWithdrawals[%d]", idx1) + } } - t.PendingPartialWithdrawals = val19 + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "PendingPartialWithdrawals") + } + t.PendingPartialWithdrawals = val20 } { // Field #36 'PendingConsolidations' (dynamic) - buf := buf[offset36:] - val20 := t.PendingConsolidations - itemCount := len(buf) / 16 - if len(buf)%16 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 16), "PendingConsolidations") + if dec.GetPosition() != startPos0+int(offset36) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset36)), "PendingConsolidations") + } + dec.PushLimit(int(maxOffset - offset36)) + val21 := t.PendingConsolidations + sszLen := dec.GetLength() + itemCount := sszLen / 16 + if sszLen%16 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 16), "PendingConsolidations") } if itemCount > int(expr10) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr10)), "PendingConsolidations") } - val20 = sszutils.ExpandSlice(val20, itemCount) + val21 = sszutils.ExpandSlice(val21, itemCount) + startPos14 := dec.GetPosition() for idx1 := range itemCount { - if val20[idx1] == nil { - val20[idx1] = new(electra.PendingConsolidation) + if val21[idx1] == nil { + val21[idx1] = new(electra.PendingConsolidation) } - buf := buf[16*idx1 : 16*(idx1+1)] - if err = val20[idx1].UnmarshalSSZ(buf); err != nil { + if buf, err := dec.DecodeBytesBuf(16); err != nil { return sszutils.ErrorWithPathf(err, "PendingConsolidations[%d]", idx1) + } else if err = val21[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "PendingConsolidations[%d]", idx1) + } + if dec.GetPosition() != startPos14+int(16*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos14+int(16*(idx1+1))), "PendingConsolidations[%d]", idx1) } } - t.PendingConsolidations = val20 + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "PendingConsolidations") + } + t.PendingConsolidations = val21 } return nil } -func (t *BeaconState) unmarshalSSZView_BeaconState_6(ds sszutils.DynamicSpecs, buf []byte) (err error) { +func (t *BeaconState) unmarshalSSZDecoderView_BeaconState_6(ds sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { expr0, err := sszutils.ResolveSpecValueWithDefault(ds, "SLOTS_PER_HISTORICAL_ROOT", 8192) if err != nil { return err @@ -6829,635 +17746,892 @@ func (t *BeaconState) unmarshalSSZView_BeaconState_6(ds sszutils.DynamicSpecs, b size8 := 44 * int(expr6) size10 := 8 * int(expr7) size9 := size10 * int(expr8) - exproffset := 0 totalSize := size1+size1+size2+size3+size4+size4+size6+size7+size8+size9+541 - buflen := len(buf) - if buflen < totalSize { - return sszutils.ErrFixedFieldsEOFFn(buflen, totalSize) + maxOffset := uint32(dec.GetLength()) + startPos0 := dec.GetPosition() + if maxOffset < uint32(totalSize) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(totalSize)) + } + // Field #0 'GenesisTime' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "GenesisTime") + } else { + t.GenesisTime = val + } + // Field #1 'GenesisValidatorsRoot' (static) + if _, err = dec.DecodeBytes(t.GenesisValidatorsRoot[:32]); err != nil { + return err } - { // Field #0 'GenesisTime' (static) - buf := buf[0:8] - t.GenesisTime = binary.LittleEndian.Uint64(buf) + // Field #2 'Slot' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "Slot") + } else { + t.Slot = phase0.Slot(val) } - { // Field #1 'GenesisValidatorsRoot' (static) - buf := buf[8:40] - copy(t.GenesisValidatorsRoot[:], buf) + // Field #3 'Fork' (static) + if t.Fork == nil { + t.Fork = new(phase0.Fork) } - { // Field #2 'Slot' (static) - buf := buf[40:48] - t.Slot = phase0.Slot(binary.LittleEndian.Uint64(buf)) + if buf, err := dec.DecodeBytesBuf(16); err != nil { + return sszutils.ErrorWithPath(err, "Fork") + } else if err = t.Fork.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "Fork") } - { // Field #3 'Fork' (static) - buf := buf[48:64] - if t.Fork == nil { - t.Fork = new(phase0.Fork) - } - if err = t.Fork.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "Fork") - } + // Field #4 'LatestBlockHeader' (static) + if t.LatestBlockHeader == nil { + t.LatestBlockHeader = new(phase0.BeaconBlockHeader) } - { // Field #4 'LatestBlockHeader' (static) - buf := buf[64:176] - if t.LatestBlockHeader == nil { - t.LatestBlockHeader = new(phase0.BeaconBlockHeader) - } - if err = t.LatestBlockHeader.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "LatestBlockHeader") - } + if buf, err := dec.DecodeBytesBuf(112); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") + } else if err = t.LatestBlockHeader.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") } { // Field #5 'BlockRoots' (static) - buf := buf[176 : size1+176] - exproffset += int(size1) val1 := t.BlockRoots val1 = sszutils.ExpandSlice(val1, int(expr0)) + startPos1 := dec.GetPosition() for idx1 := range int(expr0) { - buf := buf[32*idx1 : 32*(idx1+1)] - copy(val1[idx1][:], buf) + if _, err = dec.DecodeBytes(val1[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos1+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos1+int(32*(idx1+1))), "BlockRoots[%d]", idx1) + } } t.BlockRoots = val1 } { // Field #6 'StateRoots' (static) - buf := buf[exproffset+176 : exproffset+size1+176] - exproffset += int(size1) val2 := t.StateRoots val2 = sszutils.ExpandSlice(val2, int(expr0)) - for idx1 := range int(expr0) { - buf := buf[32*idx1 : 32*(idx1+1)] - copy(val2[idx1][:], buf) - } - t.StateRoots = val2 - } - // Field #7 'HistoricalRoots' (offset) - offset7 := int(binary.LittleEndian.Uint32(buf[exproffset+176 : exproffset+180])) - if offset7 != totalSize { - return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset7, totalSize), "HistoricalRoots:o") - } - { // Field #8 'ETH1Data' (static) - buf := buf[exproffset+180 : exproffset+252] - if t.ETH1Data == nil { - t.ETH1Data = new(phase0.ETH1Data) - } - if err = t.ETH1Data.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "ETH1Data") + startPos2 := dec.GetPosition() + for idx1 := range int(expr0) { + if _, err = dec.DecodeBytes(val2[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos2+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos2+int(32*(idx1+1))), "StateRoots[%d]", idx1) + } } + t.StateRoots = val2 + } + // Field #7 'HistoricalRoots' (offset) + offset7, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "HistoricalRoots") + } + if offset7 != uint32(totalSize) { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset7, totalSize), "HistoricalRoots") + } + // Field #8 'ETH1Data' (static) + if t.ETH1Data == nil { + t.ETH1Data = new(phase0.ETH1Data) + } + if buf, err := dec.DecodeBytesBuf(72); err != nil { + return sszutils.ErrorWithPath(err, "ETH1Data") + } else if err = t.ETH1Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "ETH1Data") } // Field #9 'ETH1DataVotes' (offset) - offset9 := int(binary.LittleEndian.Uint32(buf[exproffset+252 : exproffset+256])) - if offset9 < offset7 || offset9 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset9, offset7, buflen), "ETH1DataVotes:o") + offset9, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "ETH1DataVotes") } - { // Field #10 'ETH1DepositIndex' (static) - buf := buf[exproffset+256 : exproffset+264] - t.ETH1DepositIndex = binary.LittleEndian.Uint64(buf) + if offset9 < offset7 || offset9 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset9, offset7, maxOffset), "ETH1DataVotes") + } + // Field #10 'ETH1DepositIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "ETH1DepositIndex") + } else { + t.ETH1DepositIndex = val } // Field #11 'Validators' (offset) - offset11 := int(binary.LittleEndian.Uint32(buf[exproffset+264 : exproffset+268])) - if offset11 < offset9 || offset11 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset11, offset9, buflen), "Validators:o") + offset11, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Validators") + } + if offset11 < offset9 || offset11 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset11, offset9, maxOffset), "Validators") } // Field #12 'Balances' (offset) - offset12 := int(binary.LittleEndian.Uint32(buf[exproffset+268 : exproffset+272])) - if offset12 < offset11 || offset12 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset12, offset11, buflen), "Balances:o") + offset12, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Balances") + } + if offset12 < offset11 || offset12 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset12, offset11, maxOffset), "Balances") } { // Field #13 'RANDAOMixes' (static) - buf := buf[exproffset+272 : exproffset+size2+272] - exproffset += int(size2) val3 := t.RANDAOMixes val3 = sszutils.ExpandSlice(val3, int(expr1)) + startPos3 := dec.GetPosition() for idx1 := range int(expr1) { - buf := buf[32*idx1 : 32*(idx1+1)] - copy(val3[idx1][:], buf) + if _, err = dec.DecodeBytes(val3[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos3+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos3+int(32*(idx1+1))), "RANDAOMixes[%d]", idx1) + } } t.RANDAOMixes = val3 } { // Field #14 'Slashings' (static) - buf := buf[exproffset+272 : exproffset+size3+272] - exproffset += int(size3) val4 := t.Slashings val4 = sszutils.ExpandSlice(val4, int(expr2)) - sszutils.UnmarshalUint64Slice(val4[:int(expr2)], buf) + if err = sszutils.DecodeUint64Slice(dec, val4[:int(expr2)]); err != nil { + return sszutils.ErrorWithPath(err, "Slashings") + } t.Slashings = val4 } // Field #15 'PreviousEpochParticipation' (offset) - offset15 := int(binary.LittleEndian.Uint32(buf[exproffset+272 : exproffset+276])) - if offset15 < offset12 || offset15 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset15, offset12, buflen), "PreviousEpochParticipation:o") + offset15, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "PreviousEpochParticipation") + } + if offset15 < offset12 || offset15 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset15, offset12, maxOffset), "PreviousEpochParticipation") } // Field #16 'CurrentEpochParticipation' (offset) - offset16 := int(binary.LittleEndian.Uint32(buf[exproffset+276 : exproffset+280])) - if offset16 < offset15 || offset16 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset16, offset15, buflen), "CurrentEpochParticipation:o") + offset16, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "CurrentEpochParticipation") } - { // Field #17 'JustificationBits' (static) - buf := buf[exproffset+280 : exproffset+281] - t.JustificationBits = sszutils.ExpandSlice(t.JustificationBits, 1) - copy(t.JustificationBits[:], buf) + if offset16 < offset15 || offset16 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset16, offset15, maxOffset), "CurrentEpochParticipation") } - { // Field #18 'PreviousJustifiedCheckpoint' (static) - buf := buf[exproffset+281 : exproffset+321] - if t.PreviousJustifiedCheckpoint == nil { - t.PreviousJustifiedCheckpoint = new(phase0.Checkpoint) - } - if err = t.PreviousJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") - } + // Field #17 'JustificationBits' (static) + t.JustificationBits = sszutils.ExpandSlice(t.JustificationBits, 1) + if _, err = dec.DecodeBytes(t.JustificationBits[:1]); err != nil { + return err } - { // Field #19 'CurrentJustifiedCheckpoint' (static) - buf := buf[exproffset+321 : exproffset+361] - if t.CurrentJustifiedCheckpoint == nil { - t.CurrentJustifiedCheckpoint = new(phase0.Checkpoint) - } - if err = t.CurrentJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") - } + // Field #18 'PreviousJustifiedCheckpoint' (static) + if t.PreviousJustifiedCheckpoint == nil { + t.PreviousJustifiedCheckpoint = new(phase0.Checkpoint) } - { // Field #20 'FinalizedCheckpoint' (static) - buf := buf[exproffset+361 : exproffset+401] - if t.FinalizedCheckpoint == nil { - t.FinalizedCheckpoint = new(phase0.Checkpoint) - } - if err = t.FinalizedCheckpoint.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") - } + if buf, err := dec.DecodeBytesBuf(40); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } else if err = t.PreviousJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } + // Field #19 'CurrentJustifiedCheckpoint' (static) + if t.CurrentJustifiedCheckpoint == nil { + t.CurrentJustifiedCheckpoint = new(phase0.Checkpoint) + } + if buf, err := dec.DecodeBytesBuf(40); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } else if err = t.CurrentJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } + // Field #20 'FinalizedCheckpoint' (static) + if t.FinalizedCheckpoint == nil { + t.FinalizedCheckpoint = new(phase0.Checkpoint) + } + if buf, err := dec.DecodeBytesBuf(40); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") + } else if err = t.FinalizedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") } // Field #21 'InactivityScores' (offset) - offset21 := int(binary.LittleEndian.Uint32(buf[exproffset+401 : exproffset+405])) - if offset21 < offset16 || offset21 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset21, offset16, buflen), "InactivityScores:o") + offset21, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "InactivityScores") + } + if offset21 < offset16 || offset21 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset21, offset16, maxOffset), "InactivityScores") } { // Field #22 'CurrentSyncCommittee' (static) - buf := buf[exproffset+405 : exproffset+size4+405] - exproffset += int(size4) val5 := t.CurrentSyncCommittee if val5 == nil { val5 = new(altair.SyncCommittee) } - exproffset := 0 totalSize := size5+48 - buflen := len(buf) - if buflen < totalSize { - return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, totalSize), "CurrentSyncCommittee") + maxOffset := uint32(dec.GetLength()) + if maxOffset < uint32(totalSize) { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(totalSize)), "CurrentSyncCommittee") } { // Field #0 'Pubkeys' (static) - buf := buf[0 : size5+0] - exproffset += int(size5) val6 := val5.Pubkeys val6 = sszutils.ExpandSlice(val6, int(expr3)) + startPos4 := dec.GetPosition() for idx1 := range int(expr3) { - buf := buf[48*idx1 : 48*(idx1+1)] - copy(val6[idx1][:], buf) + if _, err = dec.DecodeBytes(val6[idx1][:48]); err != nil { + return err + } + if dec.GetPosition() != startPos4+int(48*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos4+int(48*(idx1+1))), "CurrentSyncCommittee.Pubkeys[%d]", idx1) + } } val5.Pubkeys = val6 } - { // Field #1 'AggregatePubkey' (static) - buf := buf[exproffset+0 : exproffset+48] - copy(val5.AggregatePubkey[:], buf) + // Field #1 'AggregatePubkey' (static) + if _, err = dec.DecodeBytes(val5.AggregatePubkey[:48]); err != nil { + return err } t.CurrentSyncCommittee = val5 } { // Field #23 'NextSyncCommittee' (static) - buf := buf[exproffset+405 : exproffset+size4+405] - exproffset += int(size4) val7 := t.NextSyncCommittee if val7 == nil { val7 = new(altair.SyncCommittee) } - exproffset := 0 totalSize := size5+48 - buflen := len(buf) - if buflen < totalSize { - return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, totalSize), "NextSyncCommittee") + maxOffset := uint32(dec.GetLength()) + if maxOffset < uint32(totalSize) { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(totalSize)), "NextSyncCommittee") } { // Field #0 'Pubkeys' (static) - buf := buf[0 : size5+0] - exproffset += int(size5) val8 := val7.Pubkeys val8 = sszutils.ExpandSlice(val8, int(expr3)) + startPos5 := dec.GetPosition() for idx1 := range int(expr3) { - buf := buf[48*idx1 : 48*(idx1+1)] - copy(val8[idx1][:], buf) + if _, err = dec.DecodeBytes(val8[idx1][:48]); err != nil { + return err + } + if dec.GetPosition() != startPos5+int(48*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos5+int(48*(idx1+1))), "NextSyncCommittee.Pubkeys[%d]", idx1) + } } val7.Pubkeys = val8 } - { // Field #1 'AggregatePubkey' (static) - buf := buf[exproffset+0 : exproffset+48] - copy(val7.AggregatePubkey[:], buf) + // Field #1 'AggregatePubkey' (static) + if _, err = dec.DecodeBytes(val7.AggregatePubkey[:48]); err != nil { + return err } t.NextSyncCommittee = val7 } - { // Field #24 'LatestBlockHash' (static) - buf := buf[exproffset+405 : exproffset+437] - copy(t.LatestBlockHash[:], buf) + // Field #24 'LatestBlockHash' (static) + if _, err = dec.DecodeBytes(t.LatestBlockHash[:32]); err != nil { + return err } - { // Field #25 'NextWithdrawalIndex' (static) - buf := buf[exproffset+437 : exproffset+445] - t.NextWithdrawalIndex = capella.WithdrawalIndex(binary.LittleEndian.Uint64(buf)) + // Field #25 'NextWithdrawalIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "NextWithdrawalIndex") + } else { + t.NextWithdrawalIndex = capella.WithdrawalIndex(val) } - { // Field #26 'NextWithdrawalValidatorIndex' (static) - buf := buf[exproffset+445 : exproffset+453] - t.NextWithdrawalValidatorIndex = phase0.ValidatorIndex(binary.LittleEndian.Uint64(buf)) + // Field #26 'NextWithdrawalValidatorIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "NextWithdrawalValidatorIndex") + } else { + t.NextWithdrawalValidatorIndex = phase0.ValidatorIndex(val) } // Field #27 'HistoricalSummaries' (offset) - offset27 := int(binary.LittleEndian.Uint32(buf[exproffset+453 : exproffset+457])) - if offset27 < offset21 || offset27 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset27, offset21, buflen), "HistoricalSummaries:o") - } - { // Field #28 'DepositRequestsStartIndex' (static) - buf := buf[exproffset+457 : exproffset+465] - t.DepositRequestsStartIndex = binary.LittleEndian.Uint64(buf) - } - { // Field #29 'DepositBalanceToConsume' (static) - buf := buf[exproffset+465 : exproffset+473] - t.DepositBalanceToConsume = phase0.Gwei(binary.LittleEndian.Uint64(buf)) - } - { // Field #30 'ExitBalanceToConsume' (static) - buf := buf[exproffset+473 : exproffset+481] - t.ExitBalanceToConsume = phase0.Gwei(binary.LittleEndian.Uint64(buf)) - } - { // Field #31 'EarliestExitEpoch' (static) - buf := buf[exproffset+481 : exproffset+489] - t.EarliestExitEpoch = phase0.Epoch(binary.LittleEndian.Uint64(buf)) - } - { // Field #32 'ConsolidationBalanceToConsume' (static) - buf := buf[exproffset+489 : exproffset+497] - t.ConsolidationBalanceToConsume = phase0.Gwei(binary.LittleEndian.Uint64(buf)) - } - { // Field #33 'EarliestConsolidationEpoch' (static) - buf := buf[exproffset+497 : exproffset+505] - t.EarliestConsolidationEpoch = phase0.Epoch(binary.LittleEndian.Uint64(buf)) + offset27, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "HistoricalSummaries") + } + if offset27 < offset21 || offset27 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset27, offset21, maxOffset), "HistoricalSummaries") + } + // Field #28 'DepositRequestsStartIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "DepositRequestsStartIndex") + } else { + t.DepositRequestsStartIndex = val + } + // Field #29 'DepositBalanceToConsume' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "DepositBalanceToConsume") + } else { + t.DepositBalanceToConsume = phase0.Gwei(val) + } + // Field #30 'ExitBalanceToConsume' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "ExitBalanceToConsume") + } else { + t.ExitBalanceToConsume = phase0.Gwei(val) + } + // Field #31 'EarliestExitEpoch' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "EarliestExitEpoch") + } else { + t.EarliestExitEpoch = phase0.Epoch(val) + } + // Field #32 'ConsolidationBalanceToConsume' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "ConsolidationBalanceToConsume") + } else { + t.ConsolidationBalanceToConsume = phase0.Gwei(val) + } + // Field #33 'EarliestConsolidationEpoch' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "EarliestConsolidationEpoch") + } else { + t.EarliestConsolidationEpoch = phase0.Epoch(val) } // Field #34 'PendingDeposits' (offset) - offset34 := int(binary.LittleEndian.Uint32(buf[exproffset+505 : exproffset+509])) - if offset34 < offset27 || offset34 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset34, offset27, buflen), "PendingDeposits:o") + offset34, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "PendingDeposits") + } + if offset34 < offset27 || offset34 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset34, offset27, maxOffset), "PendingDeposits") } // Field #35 'PendingPartialWithdrawals' (offset) - offset35 := int(binary.LittleEndian.Uint32(buf[exproffset+509 : exproffset+513])) - if offset35 < offset34 || offset35 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset35, offset34, buflen), "PendingPartialWithdrawals:o") + offset35, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "PendingPartialWithdrawals") + } + if offset35 < offset34 || offset35 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset35, offset34, maxOffset), "PendingPartialWithdrawals") } // Field #36 'PendingConsolidations' (offset) - offset36 := int(binary.LittleEndian.Uint32(buf[exproffset+513 : exproffset+517])) - if offset36 < offset35 || offset36 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset36, offset35, buflen), "PendingConsolidations:o") + offset36, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "PendingConsolidations") + } + if offset36 < offset35 || offset36 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset36, offset35, maxOffset), "PendingConsolidations") } { // Field #37 'ProposerLookahead' (static) - buf := buf[exproffset+517 : exproffset+size6+517] - exproffset += int(size6) val9 := t.ProposerLookahead val9 = sszutils.ExpandSlice(val9, int(expr4)) - sszutils.UnmarshalUint64Slice(val9[:int(expr4)], buf) + if err = sszutils.DecodeUint64Slice(dec, val9[:int(expr4)]); err != nil { + return sszutils.ErrorWithPath(err, "ProposerLookahead") + } t.ProposerLookahead = val9 } // Field #38 'Builders' (offset) - offset38 := int(binary.LittleEndian.Uint32(buf[exproffset+517 : exproffset+521])) - if offset38 < offset36 || offset38 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset38, offset36, buflen), "Builders:o") + offset38, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Builders") } - { // Field #39 'NextWithdrawalBuilderIndex' (static) - buf := buf[exproffset+521 : exproffset+529] - t.NextWithdrawalBuilderIndex = gloas.BuilderIndex(binary.LittleEndian.Uint64(buf)) + if offset38 < offset36 || offset38 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset38, offset36, maxOffset), "Builders") } - { // Field #40 'ExecutionPayloadAvailability' (static) - buf := buf[exproffset+529 : exproffset+size7+529] - exproffset += int(size7) - t.ExecutionPayloadAvailability = sszutils.ExpandSlice(t.ExecutionPayloadAvailability, int(expr5)) - copy(t.ExecutionPayloadAvailability[:], buf) + // Field #39 'NextWithdrawalBuilderIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "NextWithdrawalBuilderIndex") + } else { + t.NextWithdrawalBuilderIndex = gloas.BuilderIndex(val) + } + // Field #40 'ExecutionPayloadAvailability' (static) + t.ExecutionPayloadAvailability = sszutils.ExpandSlice(t.ExecutionPayloadAvailability, int(expr5)) + if _, err = dec.DecodeBytes(t.ExecutionPayloadAvailability[:int(expr5)]); err != nil { + return err } { // Field #41 'BuilderPendingPayments' (static) - buf := buf[exproffset+529 : exproffset+size8+529] - exproffset += int(size8) val10 := t.BuilderPendingPayments val10 = sszutils.ExpandSlice(val10, int(expr6)) + startPos6 := dec.GetPosition() for idx1 := range int(expr6) { if val10[idx1] == nil { val10[idx1] = new(gloas.BuilderPendingPayment) } - buf := buf[44*idx1 : 44*(idx1+1)] - if err = val10[idx1].UnmarshalSSZ(buf); err != nil { + if buf, err := dec.DecodeBytesBuf(44); err != nil { + return sszutils.ErrorWithPathf(err, "BuilderPendingPayments[%d]", idx1) + } else if err = val10[idx1].UnmarshalSSZ(buf); err != nil { return sszutils.ErrorWithPathf(err, "BuilderPendingPayments[%d]", idx1) } + if dec.GetPosition() != startPos6+int(44*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos6+int(44*(idx1+1))), "BuilderPendingPayments[%d]", idx1) + } } t.BuilderPendingPayments = val10 } // Field #42 'BuilderPendingWithdrawals' (offset) - offset42 := int(binary.LittleEndian.Uint32(buf[exproffset+529 : exproffset+533])) - if offset42 < offset38 || offset42 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset42, offset38, buflen), "BuilderPendingWithdrawals:o") + offset42, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "BuilderPendingWithdrawals") + } + if offset42 < offset38 || offset42 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset42, offset38, maxOffset), "BuilderPendingWithdrawals") } // Field #43 'LatestExecutionPayloadBid' (offset) - offset43 := int(binary.LittleEndian.Uint32(buf[exproffset+533 : exproffset+537])) - if offset43 < offset42 || offset43 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset43, offset42, buflen), "LatestExecutionPayloadBid:o") + offset43, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "LatestExecutionPayloadBid") + } + if offset43 < offset42 || offset43 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset43, offset42, maxOffset), "LatestExecutionPayloadBid") } // Field #44 'PayloadExpectedWithdrawals' (offset) - offset44 := int(binary.LittleEndian.Uint32(buf[exproffset+537 : exproffset+541])) - if offset44 < offset43 || offset44 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset44, offset43, buflen), "PayloadExpectedWithdrawals:o") + offset44, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "PayloadExpectedWithdrawals") + } + if offset44 < offset43 || offset44 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset44, offset43, maxOffset), "PayloadExpectedWithdrawals") } { // Field #45 'PTCWindow' (static) - buf := buf[exproffset+541 : exproffset+size9+541] - exproffset += int(size9) val11 := t.PTCWindow val11 = sszutils.ExpandSlice(val11, int(expr8)) + startPos7 := dec.GetPosition() for idx1 := range int(expr8) { val12 := val11[idx1] - buf := buf[size10*idx1 : size10*(idx1+1)] val12 = sszutils.ExpandSlice(val12, int(expr7)) - sszutils.UnmarshalUint64Slice(val12[:int(expr7)], buf) + if err = sszutils.DecodeUint64Slice(dec, val12[:int(expr7)]); err != nil { + return sszutils.ErrorWithPathf(err, "PTCWindow[%d]", idx1) + } + if dec.GetPosition() != startPos7+int(size10*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos7+int(size10*(idx1+1))), "PTCWindow[%d]", idx1) + } val11[idx1] = val12 } t.PTCWindow = val11 } { // Field #7 'HistoricalRoots' (dynamic) - buf := buf[offset7:offset9] + if dec.GetPosition() != startPos0+int(offset7) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset7)), "HistoricalRoots") + } + dec.PushLimit(int(offset9 - offset7)) val13 := t.HistoricalRoots - itemCount := len(buf) / 32 - if len(buf)%32 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 32), "HistoricalRoots") + sszLen := dec.GetLength() + itemCount := sszLen / 32 + if sszLen%32 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 32), "HistoricalRoots") } if itemCount > 16777216 { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 16777216), "HistoricalRoots") } val13 = sszutils.ExpandSlice(val13, itemCount) + startPos8 := dec.GetPosition() for idx1 := range itemCount { - buf := buf[32*idx1 : 32*(idx1+1)] - copy(val13[idx1][:], buf) + if _, err = dec.DecodeBytes(val13[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos8+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos8+int(32*(idx1+1))), "HistoricalRoots[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "HistoricalRoots") } t.HistoricalRoots = val13 } { // Field #9 'ETH1DataVotes' (dynamic) - buf := buf[offset9:offset11] + if dec.GetPosition() != startPos0+int(offset9) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset9)), "ETH1DataVotes") + } + dec.PushLimit(int(offset11 - offset9)) val14 := t.ETH1DataVotes - itemCount := len(buf) / 72 - if len(buf)%72 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 72), "ETH1DataVotes") + sszLen := dec.GetLength() + itemCount := sszLen / 72 + if sszLen%72 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 72), "ETH1DataVotes") } if itemCount > int(expr9) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr9)), "ETH1DataVotes") } val14 = sszutils.ExpandSlice(val14, itemCount) + startPos9 := dec.GetPosition() for idx1 := range itemCount { if val14[idx1] == nil { val14[idx1] = new(phase0.ETH1Data) } - buf := buf[72*idx1 : 72*(idx1+1)] - if err = val14[idx1].UnmarshalSSZ(buf); err != nil { + if buf, err := dec.DecodeBytesBuf(72); err != nil { return sszutils.ErrorWithPathf(err, "ETH1DataVotes[%d]", idx1) + } else if err = val14[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "ETH1DataVotes[%d]", idx1) + } + if dec.GetPosition() != startPos9+int(72*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos9+int(72*(idx1+1))), "ETH1DataVotes[%d]", idx1) } } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "ETH1DataVotes") + } t.ETH1DataVotes = val14 } { // Field #11 'Validators' (dynamic) - buf := buf[offset11:offset12] + if dec.GetPosition() != startPos0+int(offset11) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset11)), "Validators") + } + dec.PushLimit(int(offset12 - offset11)) val15 := t.Validators - itemCount := len(buf) / 121 - if len(buf)%121 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 121), "Validators") + sszLen := dec.GetLength() + itemCount := sszLen / 121 + if sszLen%121 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 121), "Validators") } if itemCount > 1099511627776 { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1099511627776), "Validators") } val15 = sszutils.ExpandSlice(val15, itemCount) + startPos10 := dec.GetPosition() for idx1 := range itemCount { if val15[idx1] == nil { val15[idx1] = new(phase0.Validator) } - buf := buf[121*idx1 : 121*(idx1+1)] - if err = val15[idx1].UnmarshalSSZ(buf); err != nil { + if buf, err := dec.DecodeBytesBuf(121); err != nil { return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } else if err = val15[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } + if dec.GetPosition() != startPos10+int(121*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos10+int(121*(idx1+1))), "Validators[%d]", idx1) } } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Validators") + } t.Validators = val15 } { // Field #12 'Balances' (dynamic) - buf := buf[offset12:offset15] + if dec.GetPosition() != startPos0+int(offset12) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset12)), "Balances") + } + dec.PushLimit(int(offset15 - offset12)) val16 := t.Balances - itemCount := len(buf) / 8 - if len(buf)%8 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 8), "Balances") + sszLen := dec.GetLength() + itemCount := sszLen / 8 + if sszLen%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 8), "Balances") } if itemCount > 1099511627776 { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1099511627776), "Balances") } val16 = sszutils.ExpandSlice(val16, itemCount) - sszutils.UnmarshalUint64Slice(val16, buf) + if err = sszutils.DecodeUint64Slice(dec, val16); err != nil { + return sszutils.ErrorWithPath(err, "Balances") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Balances") + } t.Balances = val16 } { // Field #15 'PreviousEpochParticipation' (dynamic) - buf := buf[offset15:offset16] + if dec.GetPosition() != startPos0+int(offset15) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset15)), "PreviousEpochParticipation") + } + dec.PushLimit(int(offset16 - offset15)) val17 := t.PreviousEpochParticipation - itemCount := len(buf) + itemCount := dec.GetLength() if itemCount > 1099511627776 { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1099511627776), "PreviousEpochParticipation") } val17 = sszutils.ExpandSlice(val17, itemCount) + startPos11 := dec.GetPosition() for idx1 := range itemCount { - buf := buf[1*idx1 : 1*(idx1+1)] - val17[idx1] = altair.ParticipationFlags(buf[0]) + if val, err := dec.DecodeUint8(); err != nil { + return sszutils.ErrorWithPathf(err, "PreviousEpochParticipation[%d]", idx1) + } else { + val17[idx1] = altair.ParticipationFlags(val) + } + if dec.GetPosition() != startPos11+int(1*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos11+int(1*(idx1+1))), "PreviousEpochParticipation[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "PreviousEpochParticipation") } t.PreviousEpochParticipation = val17 } { // Field #16 'CurrentEpochParticipation' (dynamic) - buf := buf[offset16:offset21] + if dec.GetPosition() != startPos0+int(offset16) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset16)), "CurrentEpochParticipation") + } + dec.PushLimit(int(offset21 - offset16)) val18 := t.CurrentEpochParticipation - itemCount := len(buf) + itemCount := dec.GetLength() if itemCount > 1099511627776 { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1099511627776), "CurrentEpochParticipation") } val18 = sszutils.ExpandSlice(val18, itemCount) + startPos12 := dec.GetPosition() for idx1 := range itemCount { - buf := buf[1*idx1 : 1*(idx1+1)] - val18[idx1] = altair.ParticipationFlags(buf[0]) + if val, err := dec.DecodeUint8(); err != nil { + return sszutils.ErrorWithPathf(err, "CurrentEpochParticipation[%d]", idx1) + } else { + val18[idx1] = altair.ParticipationFlags(val) + } + if dec.GetPosition() != startPos12+int(1*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos12+int(1*(idx1+1))), "CurrentEpochParticipation[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "CurrentEpochParticipation") } t.CurrentEpochParticipation = val18 } { // Field #21 'InactivityScores' (dynamic) - buf := buf[offset21:offset27] + if dec.GetPosition() != startPos0+int(offset21) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset21)), "InactivityScores") + } + dec.PushLimit(int(offset27 - offset21)) val19 := t.InactivityScores - itemCount := len(buf) / 8 - if len(buf)%8 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 8), "InactivityScores") + sszLen := dec.GetLength() + itemCount := sszLen / 8 + if sszLen%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 8), "InactivityScores") } if itemCount > 1099511627776 { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1099511627776), "InactivityScores") } val19 = sszutils.ExpandSlice(val19, itemCount) - sszutils.UnmarshalUint64Slice(val19, buf) + if err = sszutils.DecodeUint64Slice(dec, val19); err != nil { + return sszutils.ErrorWithPath(err, "InactivityScores") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "InactivityScores") + } t.InactivityScores = val19 } { // Field #27 'HistoricalSummaries' (dynamic) - buf := buf[offset27:offset34] + if dec.GetPosition() != startPos0+int(offset27) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset27)), "HistoricalSummaries") + } + dec.PushLimit(int(offset34 - offset27)) val20 := t.HistoricalSummaries - itemCount := len(buf) / 64 - if len(buf)%64 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 64), "HistoricalSummaries") + sszLen := dec.GetLength() + itemCount := sszLen / 64 + if sszLen%64 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 64), "HistoricalSummaries") } if itemCount > 16777216 { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 16777216), "HistoricalSummaries") } val20 = sszutils.ExpandSlice(val20, itemCount) + startPos13 := dec.GetPosition() for idx1 := range itemCount { if val20[idx1] == nil { val20[idx1] = new(capella.HistoricalSummary) } - buf := buf[64*idx1 : 64*(idx1+1)] - if err = val20[idx1].UnmarshalSSZ(buf); err != nil { + if buf, err := dec.DecodeBytesBuf(64); err != nil { return sszutils.ErrorWithPathf(err, "HistoricalSummaries[%d]", idx1) + } else if err = val20[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "HistoricalSummaries[%d]", idx1) + } + if dec.GetPosition() != startPos13+int(64*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos13+int(64*(idx1+1))), "HistoricalSummaries[%d]", idx1) } } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "HistoricalSummaries") + } t.HistoricalSummaries = val20 } { // Field #34 'PendingDeposits' (dynamic) - buf := buf[offset34:offset35] + if dec.GetPosition() != startPos0+int(offset34) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset34)), "PendingDeposits") + } + dec.PushLimit(int(offset35 - offset34)) val21 := t.PendingDeposits - itemCount := len(buf) / 192 - if len(buf)%192 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 192), "PendingDeposits") + sszLen := dec.GetLength() + itemCount := sszLen / 192 + if sszLen%192 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 192), "PendingDeposits") } if itemCount > int(expr10) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr10)), "PendingDeposits") } val21 = sszutils.ExpandSlice(val21, itemCount) + startPos14 := dec.GetPosition() for idx1 := range itemCount { if val21[idx1] == nil { val21[idx1] = new(electra.PendingDeposit) } - buf := buf[192*idx1 : 192*(idx1+1)] - if err = val21[idx1].UnmarshalSSZ(buf); err != nil { + if buf, err := dec.DecodeBytesBuf(192); err != nil { return sszutils.ErrorWithPathf(err, "PendingDeposits[%d]", idx1) + } else if err = val21[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "PendingDeposits[%d]", idx1) + } + if dec.GetPosition() != startPos14+int(192*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos14+int(192*(idx1+1))), "PendingDeposits[%d]", idx1) } } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "PendingDeposits") + } t.PendingDeposits = val21 } { // Field #35 'PendingPartialWithdrawals' (dynamic) - buf := buf[offset35:offset36] + if dec.GetPosition() != startPos0+int(offset35) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset35)), "PendingPartialWithdrawals") + } + dec.PushLimit(int(offset36 - offset35)) val22 := t.PendingPartialWithdrawals - itemCount := len(buf) / 24 - if len(buf)%24 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 24), "PendingPartialWithdrawals") + sszLen := dec.GetLength() + itemCount := sszLen / 24 + if sszLen%24 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 24), "PendingPartialWithdrawals") } if itemCount > int(expr11) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr11)), "PendingPartialWithdrawals") } val22 = sszutils.ExpandSlice(val22, itemCount) + startPos15 := dec.GetPosition() for idx1 := range itemCount { if val22[idx1] == nil { val22[idx1] = new(electra.PendingPartialWithdrawal) } - buf := buf[24*idx1 : 24*(idx1+1)] - if err = val22[idx1].UnmarshalSSZ(buf); err != nil { + if buf, err := dec.DecodeBytesBuf(24); err != nil { return sszutils.ErrorWithPathf(err, "PendingPartialWithdrawals[%d]", idx1) + } else if err = val22[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "PendingPartialWithdrawals[%d]", idx1) + } + if dec.GetPosition() != startPos15+int(24*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos15+int(24*(idx1+1))), "PendingPartialWithdrawals[%d]", idx1) } } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "PendingPartialWithdrawals") + } t.PendingPartialWithdrawals = val22 } { // Field #36 'PendingConsolidations' (dynamic) - buf := buf[offset36:offset38] + if dec.GetPosition() != startPos0+int(offset36) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset36)), "PendingConsolidations") + } + dec.PushLimit(int(offset38 - offset36)) val23 := t.PendingConsolidations - itemCount := len(buf) / 16 - if len(buf)%16 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 16), "PendingConsolidations") + sszLen := dec.GetLength() + itemCount := sszLen / 16 + if sszLen%16 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 16), "PendingConsolidations") } if itemCount > int(expr12) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr12)), "PendingConsolidations") } val23 = sszutils.ExpandSlice(val23, itemCount) + startPos16 := dec.GetPosition() for idx1 := range itemCount { if val23[idx1] == nil { val23[idx1] = new(electra.PendingConsolidation) } - buf := buf[16*idx1 : 16*(idx1+1)] - if err = val23[idx1].UnmarshalSSZ(buf); err != nil { + if buf, err := dec.DecodeBytesBuf(16); err != nil { return sszutils.ErrorWithPathf(err, "PendingConsolidations[%d]", idx1) + } else if err = val23[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "PendingConsolidations[%d]", idx1) + } + if dec.GetPosition() != startPos16+int(16*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos16+int(16*(idx1+1))), "PendingConsolidations[%d]", idx1) } } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "PendingConsolidations") + } t.PendingConsolidations = val23 } { // Field #38 'Builders' (dynamic) - buf := buf[offset38:offset42] + if dec.GetPosition() != startPos0+int(offset38) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset38)), "Builders") + } + dec.PushLimit(int(offset42 - offset38)) val24 := t.Builders - itemCount := len(buf) / 93 - if len(buf)%93 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 93), "Builders") + sszLen := dec.GetLength() + itemCount := sszLen / 93 + if sszLen%93 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 93), "Builders") } if itemCount > int(expr13) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr13)), "Builders") } val24 = sszutils.ExpandSlice(val24, itemCount) + startPos17 := dec.GetPosition() for idx1 := range itemCount { if val24[idx1] == nil { val24[idx1] = new(gloas.Builder) } - buf := buf[93*idx1 : 93*(idx1+1)] - if err = val24[idx1].UnmarshalSSZ(buf); err != nil { + if buf, err := dec.DecodeBytesBuf(93); err != nil { return sszutils.ErrorWithPathf(err, "Builders[%d]", idx1) + } else if err = val24[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Builders[%d]", idx1) + } + if dec.GetPosition() != startPos17+int(93*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos17+int(93*(idx1+1))), "Builders[%d]", idx1) } } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Builders") + } t.Builders = val24 } { // Field #42 'BuilderPendingWithdrawals' (dynamic) - buf := buf[offset42:offset43] + if dec.GetPosition() != startPos0+int(offset42) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset42)), "BuilderPendingWithdrawals") + } + dec.PushLimit(int(offset43 - offset42)) val25 := t.BuilderPendingWithdrawals - itemCount := len(buf) / 36 - if len(buf)%36 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 36), "BuilderPendingWithdrawals") + sszLen := dec.GetLength() + itemCount := sszLen / 36 + if sszLen%36 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 36), "BuilderPendingWithdrawals") } if itemCount > int(expr14) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr14)), "BuilderPendingWithdrawals") } val25 = sszutils.ExpandSlice(val25, itemCount) + startPos18 := dec.GetPosition() for idx1 := range itemCount { if val25[idx1] == nil { val25[idx1] = new(gloas.BuilderPendingWithdrawal) } - buf := buf[36*idx1 : 36*(idx1+1)] - if err = val25[idx1].UnmarshalSSZ(buf); err != nil { + if buf, err := dec.DecodeBytesBuf(36); err != nil { return sszutils.ErrorWithPathf(err, "BuilderPendingWithdrawals[%d]", idx1) + } else if err = val25[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "BuilderPendingWithdrawals[%d]", idx1) + } + if dec.GetPosition() != startPos18+int(36*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos18+int(36*(idx1+1))), "BuilderPendingWithdrawals[%d]", idx1) } } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "BuilderPendingWithdrawals") + } t.BuilderPendingWithdrawals = val25 } { // Field #43 'LatestExecutionPayloadBid' (dynamic) - buf := buf[offset43:offset44] - if t.LatestExecutionPayloadBid == nil { - t.LatestExecutionPayloadBid = new(ExecutionPayloadBid) + if dec.GetPosition() != startPos0+int(offset43) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset43)), "LatestExecutionPayloadBid") } - if viewFn := t.LatestExecutionPayloadBid.UnmarshalSSZDynView((*gloas.ExecutionPayloadBid)(nil)); viewFn != nil { + dec.PushLimit(int(offset44 - offset43)) + val26 := t.LatestExecutionPayloadBid + if val26 == nil { + val26 = new(ExecutionPayloadBid) + } + if buf, err := dec.DecodeBytesBuf(dec.GetLength()); err != nil { + return err + } else if viewFn := val26.UnmarshalSSZDynView((*gloas.ExecutionPayloadBid)(nil)); viewFn != nil { if err = viewFn(ds, buf); err != nil { return err } } else { return sszutils.ErrNotImplemented } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "LatestExecutionPayloadBid") + } + t.LatestExecutionPayloadBid = val26 } { // Field #44 'PayloadExpectedWithdrawals' (dynamic) - buf := buf[offset44:] - val26 := t.PayloadExpectedWithdrawals - itemCount := len(buf) / 44 - if len(buf)%44 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 44), "PayloadExpectedWithdrawals") + if dec.GetPosition() != startPos0+int(offset44) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset44)), "PayloadExpectedWithdrawals") + } + dec.PushLimit(int(maxOffset - offset44)) + val27 := t.PayloadExpectedWithdrawals + sszLen := dec.GetLength() + itemCount := sszLen / 44 + if sszLen%44 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 44), "PayloadExpectedWithdrawals") } if itemCount > int(expr15) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr15)), "PayloadExpectedWithdrawals") } - val26 = sszutils.ExpandSlice(val26, itemCount) + val27 = sszutils.ExpandSlice(val27, itemCount) + startPos19 := dec.GetPosition() for idx1 := range itemCount { - if val26[idx1] == nil { - val26[idx1] = new(capella.Withdrawal) + if val27[idx1] == nil { + val27[idx1] = new(capella.Withdrawal) } - buf := buf[44*idx1 : 44*(idx1+1)] - if err = val26[idx1].UnmarshalSSZ(buf); err != nil { + if buf, err := dec.DecodeBytesBuf(44); err != nil { return sszutils.ErrorWithPathf(err, "PayloadExpectedWithdrawals[%d]", idx1) + } else if err = val27[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "PayloadExpectedWithdrawals[%d]", idx1) + } + if dec.GetPosition() != startPos19+int(44*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos19+int(44*(idx1+1))), "PayloadExpectedWithdrawals[%d]", idx1) } } - t.PayloadExpectedWithdrawals = val26 + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "PayloadExpectedWithdrawals") + } + t.PayloadExpectedWithdrawals = val27 } return nil } -func (t *BeaconState) unmarshalSSZView_BeaconState_7(ds sszutils.DynamicSpecs, buf []byte) (err error) { +func (t *BeaconState) unmarshalSSZDecoderView_BeaconState_7(ds sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { expr0, err := sszutils.ResolveSpecValueWithDefault(ds, "SLOTS_PER_HISTORICAL_ROOT", 8192) if err != nil { return err @@ -7532,630 +18706,887 @@ func (t *BeaconState) unmarshalSSZView_BeaconState_7(ds sszutils.DynamicSpecs, b size8 := 44 * int(expr6) size10 := 8 * int(expr7) size9 := size10 * int(expr8) - exproffset := 0 totalSize := size1+size1+size2+size3+size4+size4+size6+size7+size8+size9+541 - buflen := len(buf) - if buflen < totalSize { - return sszutils.ErrFixedFieldsEOFFn(buflen, totalSize) + maxOffset := uint32(dec.GetLength()) + startPos0 := dec.GetPosition() + if maxOffset < uint32(totalSize) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(totalSize)) + } + // Field #0 'GenesisTime' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "GenesisTime") + } else { + t.GenesisTime = val + } + // Field #1 'GenesisValidatorsRoot' (static) + if _, err = dec.DecodeBytes(t.GenesisValidatorsRoot[:32]); err != nil { + return err } - { // Field #0 'GenesisTime' (static) - buf := buf[0:8] - t.GenesisTime = binary.LittleEndian.Uint64(buf) + // Field #2 'Slot' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "Slot") + } else { + t.Slot = phase0.Slot(val) } - { // Field #1 'GenesisValidatorsRoot' (static) - buf := buf[8:40] - copy(t.GenesisValidatorsRoot[:], buf) + // Field #3 'Fork' (static) + if t.Fork == nil { + t.Fork = new(phase0.Fork) } - { // Field #2 'Slot' (static) - buf := buf[40:48] - t.Slot = phase0.Slot(binary.LittleEndian.Uint64(buf)) + if buf, err := dec.DecodeBytesBuf(16); err != nil { + return sszutils.ErrorWithPath(err, "Fork") + } else if err = t.Fork.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "Fork") } - { // Field #3 'Fork' (static) - buf := buf[48:64] - if t.Fork == nil { - t.Fork = new(phase0.Fork) - } - if err = t.Fork.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "Fork") - } + // Field #4 'LatestBlockHeader' (static) + if t.LatestBlockHeader == nil { + t.LatestBlockHeader = new(phase0.BeaconBlockHeader) } - { // Field #4 'LatestBlockHeader' (static) - buf := buf[64:176] - if t.LatestBlockHeader == nil { - t.LatestBlockHeader = new(phase0.BeaconBlockHeader) - } - if err = t.LatestBlockHeader.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "LatestBlockHeader") - } + if buf, err := dec.DecodeBytesBuf(112); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") + } else if err = t.LatestBlockHeader.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") } { // Field #5 'BlockRoots' (static) - buf := buf[176 : size1+176] - exproffset += int(size1) val1 := t.BlockRoots val1 = sszutils.ExpandSlice(val1, int(expr0)) + startPos1 := dec.GetPosition() for idx1 := range int(expr0) { - buf := buf[32*idx1 : 32*(idx1+1)] - copy(val1[idx1][:], buf) + if _, err = dec.DecodeBytes(val1[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos1+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos1+int(32*(idx1+1))), "BlockRoots[%d]", idx1) + } } t.BlockRoots = val1 } { // Field #6 'StateRoots' (static) - buf := buf[exproffset+176 : exproffset+size1+176] - exproffset += int(size1) val2 := t.StateRoots val2 = sszutils.ExpandSlice(val2, int(expr0)) + startPos2 := dec.GetPosition() for idx1 := range int(expr0) { - buf := buf[32*idx1 : 32*(idx1+1)] - copy(val2[idx1][:], buf) + if _, err = dec.DecodeBytes(val2[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos2+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos2+int(32*(idx1+1))), "StateRoots[%d]", idx1) + } } t.StateRoots = val2 } // Field #7 'HistoricalRoots' (offset) - offset7 := int(binary.LittleEndian.Uint32(buf[exproffset+176 : exproffset+180])) - if offset7 != totalSize { - return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset7, totalSize), "HistoricalRoots:o") + offset7, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "HistoricalRoots") } - { // Field #8 'ETH1Data' (static) - buf := buf[exproffset+180 : exproffset+252] - if t.ETH1Data == nil { - t.ETH1Data = new(phase0.ETH1Data) - } - if err = t.ETH1Data.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "ETH1Data") - } + if offset7 != uint32(totalSize) { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset7, totalSize), "HistoricalRoots") + } + // Field #8 'ETH1Data' (static) + if t.ETH1Data == nil { + t.ETH1Data = new(phase0.ETH1Data) + } + if buf, err := dec.DecodeBytesBuf(72); err != nil { + return sszutils.ErrorWithPath(err, "ETH1Data") + } else if err = t.ETH1Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "ETH1Data") } // Field #9 'ETH1DataVotes' (offset) - offset9 := int(binary.LittleEndian.Uint32(buf[exproffset+252 : exproffset+256])) - if offset9 < offset7 || offset9 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset9, offset7, buflen), "ETH1DataVotes:o") + offset9, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "ETH1DataVotes") } - { // Field #10 'ETH1DepositIndex' (static) - buf := buf[exproffset+256 : exproffset+264] - t.ETH1DepositIndex = binary.LittleEndian.Uint64(buf) + if offset9 < offset7 || offset9 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset9, offset7, maxOffset), "ETH1DataVotes") + } + // Field #10 'ETH1DepositIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "ETH1DepositIndex") + } else { + t.ETH1DepositIndex = val } // Field #11 'Validators' (offset) - offset11 := int(binary.LittleEndian.Uint32(buf[exproffset+264 : exproffset+268])) - if offset11 < offset9 || offset11 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset11, offset9, buflen), "Validators:o") + offset11, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Validators") + } + if offset11 < offset9 || offset11 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset11, offset9, maxOffset), "Validators") } // Field #12 'Balances' (offset) - offset12 := int(binary.LittleEndian.Uint32(buf[exproffset+268 : exproffset+272])) - if offset12 < offset11 || offset12 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset12, offset11, buflen), "Balances:o") + offset12, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Balances") + } + if offset12 < offset11 || offset12 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset12, offset11, maxOffset), "Balances") } { // Field #13 'RANDAOMixes' (static) - buf := buf[exproffset+272 : exproffset+size2+272] - exproffset += int(size2) val3 := t.RANDAOMixes val3 = sszutils.ExpandSlice(val3, int(expr1)) + startPos3 := dec.GetPosition() for idx1 := range int(expr1) { - buf := buf[32*idx1 : 32*(idx1+1)] - copy(val3[idx1][:], buf) + if _, err = dec.DecodeBytes(val3[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos3+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos3+int(32*(idx1+1))), "RANDAOMixes[%d]", idx1) + } } t.RANDAOMixes = val3 } { // Field #14 'Slashings' (static) - buf := buf[exproffset+272 : exproffset+size3+272] - exproffset += int(size3) val4 := t.Slashings val4 = sszutils.ExpandSlice(val4, int(expr2)) - sszutils.UnmarshalUint64Slice(val4[:int(expr2)], buf) + if err = sszutils.DecodeUint64Slice(dec, val4[:int(expr2)]); err != nil { + return sszutils.ErrorWithPath(err, "Slashings") + } t.Slashings = val4 } // Field #15 'PreviousEpochParticipation' (offset) - offset15 := int(binary.LittleEndian.Uint32(buf[exproffset+272 : exproffset+276])) - if offset15 < offset12 || offset15 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset15, offset12, buflen), "PreviousEpochParticipation:o") + offset15, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "PreviousEpochParticipation") + } + if offset15 < offset12 || offset15 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset15, offset12, maxOffset), "PreviousEpochParticipation") } // Field #16 'CurrentEpochParticipation' (offset) - offset16 := int(binary.LittleEndian.Uint32(buf[exproffset+276 : exproffset+280])) - if offset16 < offset15 || offset16 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset16, offset15, buflen), "CurrentEpochParticipation:o") + offset16, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "CurrentEpochParticipation") } - { // Field #17 'JustificationBits' (static) - buf := buf[exproffset+280 : exproffset+281] - t.JustificationBits = sszutils.ExpandSlice(t.JustificationBits, 1) - copy(t.JustificationBits[:], buf) + if offset16 < offset15 || offset16 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset16, offset15, maxOffset), "CurrentEpochParticipation") } - { // Field #18 'PreviousJustifiedCheckpoint' (static) - buf := buf[exproffset+281 : exproffset+321] - if t.PreviousJustifiedCheckpoint == nil { - t.PreviousJustifiedCheckpoint = new(phase0.Checkpoint) - } - if err = t.PreviousJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") - } + // Field #17 'JustificationBits' (static) + t.JustificationBits = sszutils.ExpandSlice(t.JustificationBits, 1) + if _, err = dec.DecodeBytes(t.JustificationBits[:1]); err != nil { + return err } - { // Field #19 'CurrentJustifiedCheckpoint' (static) - buf := buf[exproffset+321 : exproffset+361] - if t.CurrentJustifiedCheckpoint == nil { - t.CurrentJustifiedCheckpoint = new(phase0.Checkpoint) - } - if err = t.CurrentJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") - } + // Field #18 'PreviousJustifiedCheckpoint' (static) + if t.PreviousJustifiedCheckpoint == nil { + t.PreviousJustifiedCheckpoint = new(phase0.Checkpoint) } - { // Field #20 'FinalizedCheckpoint' (static) - buf := buf[exproffset+361 : exproffset+401] - if t.FinalizedCheckpoint == nil { - t.FinalizedCheckpoint = new(phase0.Checkpoint) - } - if err = t.FinalizedCheckpoint.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") - } + if buf, err := dec.DecodeBytesBuf(40); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } else if err = t.PreviousJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } + // Field #19 'CurrentJustifiedCheckpoint' (static) + if t.CurrentJustifiedCheckpoint == nil { + t.CurrentJustifiedCheckpoint = new(phase0.Checkpoint) + } + if buf, err := dec.DecodeBytesBuf(40); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } else if err = t.CurrentJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } + // Field #20 'FinalizedCheckpoint' (static) + if t.FinalizedCheckpoint == nil { + t.FinalizedCheckpoint = new(phase0.Checkpoint) + } + if buf, err := dec.DecodeBytesBuf(40); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") + } else if err = t.FinalizedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") } // Field #21 'InactivityScores' (offset) - offset21 := int(binary.LittleEndian.Uint32(buf[exproffset+401 : exproffset+405])) - if offset21 < offset16 || offset21 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset21, offset16, buflen), "InactivityScores:o") + offset21, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "InactivityScores") + } + if offset21 < offset16 || offset21 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset21, offset16, maxOffset), "InactivityScores") } { // Field #22 'CurrentSyncCommittee' (static) - buf := buf[exproffset+405 : exproffset+size4+405] - exproffset += int(size4) val5 := t.CurrentSyncCommittee if val5 == nil { val5 = new(altair.SyncCommittee) } - exproffset := 0 totalSize := size5+48 - buflen := len(buf) - if buflen < totalSize { - return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, totalSize), "CurrentSyncCommittee") + maxOffset := uint32(dec.GetLength()) + if maxOffset < uint32(totalSize) { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(totalSize)), "CurrentSyncCommittee") } { // Field #0 'Pubkeys' (static) - buf := buf[0 : size5+0] - exproffset += int(size5) val6 := val5.Pubkeys val6 = sszutils.ExpandSlice(val6, int(expr3)) + startPos4 := dec.GetPosition() for idx1 := range int(expr3) { - buf := buf[48*idx1 : 48*(idx1+1)] - copy(val6[idx1][:], buf) + if _, err = dec.DecodeBytes(val6[idx1][:48]); err != nil { + return err + } + if dec.GetPosition() != startPos4+int(48*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos4+int(48*(idx1+1))), "CurrentSyncCommittee.Pubkeys[%d]", idx1) + } } val5.Pubkeys = val6 } - { // Field #1 'AggregatePubkey' (static) - buf := buf[exproffset+0 : exproffset+48] - copy(val5.AggregatePubkey[:], buf) + // Field #1 'AggregatePubkey' (static) + if _, err = dec.DecodeBytes(val5.AggregatePubkey[:48]); err != nil { + return err } t.CurrentSyncCommittee = val5 } { // Field #23 'NextSyncCommittee' (static) - buf := buf[exproffset+405 : exproffset+size4+405] - exproffset += int(size4) val7 := t.NextSyncCommittee if val7 == nil { val7 = new(altair.SyncCommittee) } - exproffset := 0 totalSize := size5+48 - buflen := len(buf) - if buflen < totalSize { - return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, totalSize), "NextSyncCommittee") + maxOffset := uint32(dec.GetLength()) + if maxOffset < uint32(totalSize) { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(totalSize)), "NextSyncCommittee") } { // Field #0 'Pubkeys' (static) - buf := buf[0 : size5+0] - exproffset += int(size5) val8 := val7.Pubkeys val8 = sszutils.ExpandSlice(val8, int(expr3)) + startPos5 := dec.GetPosition() for idx1 := range int(expr3) { - buf := buf[48*idx1 : 48*(idx1+1)] - copy(val8[idx1][:], buf) + if _, err = dec.DecodeBytes(val8[idx1][:48]); err != nil { + return err + } + if dec.GetPosition() != startPos5+int(48*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos5+int(48*(idx1+1))), "NextSyncCommittee.Pubkeys[%d]", idx1) + } } val7.Pubkeys = val8 } - { // Field #1 'AggregatePubkey' (static) - buf := buf[exproffset+0 : exproffset+48] - copy(val7.AggregatePubkey[:], buf) + // Field #1 'AggregatePubkey' (static) + if _, err = dec.DecodeBytes(val7.AggregatePubkey[:48]); err != nil { + return err } t.NextSyncCommittee = val7 } - { // Field #24 'LatestBlockHash' (static) - buf := buf[exproffset+405 : exproffset+437] - copy(t.LatestBlockHash[:], buf) + // Field #24 'LatestBlockHash' (static) + if _, err = dec.DecodeBytes(t.LatestBlockHash[:32]); err != nil { + return err } - { // Field #25 'NextWithdrawalIndex' (static) - buf := buf[exproffset+437 : exproffset+445] - t.NextWithdrawalIndex = capella.WithdrawalIndex(binary.LittleEndian.Uint64(buf)) + // Field #25 'NextWithdrawalIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "NextWithdrawalIndex") + } else { + t.NextWithdrawalIndex = capella.WithdrawalIndex(val) } - { // Field #26 'NextWithdrawalValidatorIndex' (static) - buf := buf[exproffset+445 : exproffset+453] - t.NextWithdrawalValidatorIndex = phase0.ValidatorIndex(binary.LittleEndian.Uint64(buf)) + // Field #26 'NextWithdrawalValidatorIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "NextWithdrawalValidatorIndex") + } else { + t.NextWithdrawalValidatorIndex = phase0.ValidatorIndex(val) } // Field #27 'HistoricalSummaries' (offset) - offset27 := int(binary.LittleEndian.Uint32(buf[exproffset+453 : exproffset+457])) - if offset27 < offset21 || offset27 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset27, offset21, buflen), "HistoricalSummaries:o") - } - { // Field #28 'DepositRequestsStartIndex' (static) - buf := buf[exproffset+457 : exproffset+465] - t.DepositRequestsStartIndex = binary.LittleEndian.Uint64(buf) - } - { // Field #29 'DepositBalanceToConsume' (static) - buf := buf[exproffset+465 : exproffset+473] - t.DepositBalanceToConsume = phase0.Gwei(binary.LittleEndian.Uint64(buf)) - } - { // Field #30 'ExitBalanceToConsume' (static) - buf := buf[exproffset+473 : exproffset+481] - t.ExitBalanceToConsume = phase0.Gwei(binary.LittleEndian.Uint64(buf)) - } - { // Field #31 'EarliestExitEpoch' (static) - buf := buf[exproffset+481 : exproffset+489] - t.EarliestExitEpoch = phase0.Epoch(binary.LittleEndian.Uint64(buf)) - } - { // Field #32 'ConsolidationBalanceToConsume' (static) - buf := buf[exproffset+489 : exproffset+497] - t.ConsolidationBalanceToConsume = phase0.Gwei(binary.LittleEndian.Uint64(buf)) - } - { // Field #33 'EarliestConsolidationEpoch' (static) - buf := buf[exproffset+497 : exproffset+505] - t.EarliestConsolidationEpoch = phase0.Epoch(binary.LittleEndian.Uint64(buf)) + offset27, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "HistoricalSummaries") + } + if offset27 < offset21 || offset27 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset27, offset21, maxOffset), "HistoricalSummaries") + } + // Field #28 'DepositRequestsStartIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "DepositRequestsStartIndex") + } else { + t.DepositRequestsStartIndex = val + } + // Field #29 'DepositBalanceToConsume' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "DepositBalanceToConsume") + } else { + t.DepositBalanceToConsume = phase0.Gwei(val) + } + // Field #30 'ExitBalanceToConsume' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "ExitBalanceToConsume") + } else { + t.ExitBalanceToConsume = phase0.Gwei(val) + } + // Field #31 'EarliestExitEpoch' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "EarliestExitEpoch") + } else { + t.EarliestExitEpoch = phase0.Epoch(val) + } + // Field #32 'ConsolidationBalanceToConsume' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "ConsolidationBalanceToConsume") + } else { + t.ConsolidationBalanceToConsume = phase0.Gwei(val) + } + // Field #33 'EarliestConsolidationEpoch' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "EarliestConsolidationEpoch") + } else { + t.EarliestConsolidationEpoch = phase0.Epoch(val) } // Field #34 'PendingDeposits' (offset) - offset34 := int(binary.LittleEndian.Uint32(buf[exproffset+505 : exproffset+509])) - if offset34 < offset27 || offset34 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset34, offset27, buflen), "PendingDeposits:o") + offset34, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "PendingDeposits") + } + if offset34 < offset27 || offset34 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset34, offset27, maxOffset), "PendingDeposits") } // Field #35 'PendingPartialWithdrawals' (offset) - offset35 := int(binary.LittleEndian.Uint32(buf[exproffset+509 : exproffset+513])) - if offset35 < offset34 || offset35 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset35, offset34, buflen), "PendingPartialWithdrawals:o") + offset35, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "PendingPartialWithdrawals") + } + if offset35 < offset34 || offset35 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset35, offset34, maxOffset), "PendingPartialWithdrawals") } // Field #36 'PendingConsolidations' (offset) - offset36 := int(binary.LittleEndian.Uint32(buf[exproffset+513 : exproffset+517])) - if offset36 < offset35 || offset36 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset36, offset35, buflen), "PendingConsolidations:o") + offset36, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "PendingConsolidations") + } + if offset36 < offset35 || offset36 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset36, offset35, maxOffset), "PendingConsolidations") } { // Field #37 'ProposerLookahead' (static) - buf := buf[exproffset+517 : exproffset+size6+517] - exproffset += int(size6) val9 := t.ProposerLookahead val9 = sszutils.ExpandSlice(val9, int(expr4)) - sszutils.UnmarshalUint64Slice(val9[:int(expr4)], buf) + if err = sszutils.DecodeUint64Slice(dec, val9[:int(expr4)]); err != nil { + return sszutils.ErrorWithPath(err, "ProposerLookahead") + } t.ProposerLookahead = val9 } // Field #38 'Builders' (offset) - offset38 := int(binary.LittleEndian.Uint32(buf[exproffset+517 : exproffset+521])) - if offset38 < offset36 || offset38 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset38, offset36, buflen), "Builders:o") + offset38, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Builders") } - { // Field #39 'NextWithdrawalBuilderIndex' (static) - buf := buf[exproffset+521 : exproffset+529] - t.NextWithdrawalBuilderIndex = gloas.BuilderIndex(binary.LittleEndian.Uint64(buf)) + if offset38 < offset36 || offset38 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset38, offset36, maxOffset), "Builders") } - { // Field #40 'ExecutionPayloadAvailability' (static) - buf := buf[exproffset+529 : exproffset+size7+529] - exproffset += int(size7) - t.ExecutionPayloadAvailability = sszutils.ExpandSlice(t.ExecutionPayloadAvailability, int(expr5)) - copy(t.ExecutionPayloadAvailability[:], buf) + // Field #39 'NextWithdrawalBuilderIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "NextWithdrawalBuilderIndex") + } else { + t.NextWithdrawalBuilderIndex = gloas.BuilderIndex(val) + } + // Field #40 'ExecutionPayloadAvailability' (static) + t.ExecutionPayloadAvailability = sszutils.ExpandSlice(t.ExecutionPayloadAvailability, int(expr5)) + if _, err = dec.DecodeBytes(t.ExecutionPayloadAvailability[:int(expr5)]); err != nil { + return err } { // Field #41 'BuilderPendingPayments' (static) - buf := buf[exproffset+529 : exproffset+size8+529] - exproffset += int(size8) val10 := t.BuilderPendingPayments val10 = sszutils.ExpandSlice(val10, int(expr6)) + startPos6 := dec.GetPosition() for idx1 := range int(expr6) { if val10[idx1] == nil { val10[idx1] = new(gloas.BuilderPendingPayment) } - buf := buf[44*idx1 : 44*(idx1+1)] - if err = val10[idx1].UnmarshalSSZ(buf); err != nil { + if buf, err := dec.DecodeBytesBuf(44); err != nil { + return sszutils.ErrorWithPathf(err, "BuilderPendingPayments[%d]", idx1) + } else if err = val10[idx1].UnmarshalSSZ(buf); err != nil { return sszutils.ErrorWithPathf(err, "BuilderPendingPayments[%d]", idx1) } + if dec.GetPosition() != startPos6+int(44*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos6+int(44*(idx1+1))), "BuilderPendingPayments[%d]", idx1) + } } t.BuilderPendingPayments = val10 } // Field #42 'BuilderPendingWithdrawals' (offset) - offset42 := int(binary.LittleEndian.Uint32(buf[exproffset+529 : exproffset+533])) - if offset42 < offset38 || offset42 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset42, offset38, buflen), "BuilderPendingWithdrawals:o") + offset42, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "BuilderPendingWithdrawals") + } + if offset42 < offset38 || offset42 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset42, offset38, maxOffset), "BuilderPendingWithdrawals") } // Field #43 'LatestExecutionPayloadBid' (offset) - offset43 := int(binary.LittleEndian.Uint32(buf[exproffset+533 : exproffset+537])) - if offset43 < offset42 || offset43 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset43, offset42, buflen), "LatestExecutionPayloadBid:o") + offset43, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "LatestExecutionPayloadBid") + } + if offset43 < offset42 || offset43 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset43, offset42, maxOffset), "LatestExecutionPayloadBid") } // Field #44 'PayloadExpectedWithdrawals' (offset) - offset44 := int(binary.LittleEndian.Uint32(buf[exproffset+537 : exproffset+541])) - if offset44 < offset43 || offset44 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset44, offset43, buflen), "PayloadExpectedWithdrawals:o") + offset44, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "PayloadExpectedWithdrawals") + } + if offset44 < offset43 || offset44 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset44, offset43, maxOffset), "PayloadExpectedWithdrawals") } { // Field #45 'PTCWindow' (static) - buf := buf[exproffset+541 : exproffset+size9+541] - exproffset += int(size9) val11 := t.PTCWindow val11 = sszutils.ExpandSlice(val11, int(expr8)) + startPos7 := dec.GetPosition() for idx1 := range int(expr8) { val12 := val11[idx1] - buf := buf[size10*idx1 : size10*(idx1+1)] val12 = sszutils.ExpandSlice(val12, int(expr7)) - sszutils.UnmarshalUint64Slice(val12[:int(expr7)], buf) + if err = sszutils.DecodeUint64Slice(dec, val12[:int(expr7)]); err != nil { + return sszutils.ErrorWithPathf(err, "PTCWindow[%d]", idx1) + } + if dec.GetPosition() != startPos7+int(size10*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos7+int(size10*(idx1+1))), "PTCWindow[%d]", idx1) + } val11[idx1] = val12 } t.PTCWindow = val11 } { // Field #7 'HistoricalRoots' (dynamic) - buf := buf[offset7:offset9] + if dec.GetPosition() != startPos0+int(offset7) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset7)), "HistoricalRoots") + } + dec.PushLimit(int(offset9 - offset7)) val13 := t.HistoricalRoots - itemCount := len(buf) / 32 - if len(buf)%32 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 32), "HistoricalRoots") + sszLen := dec.GetLength() + itemCount := sszLen / 32 + if sszLen%32 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 32), "HistoricalRoots") } if itemCount > 16777216 { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 16777216), "HistoricalRoots") } val13 = sszutils.ExpandSlice(val13, itemCount) + startPos8 := dec.GetPosition() for idx1 := range itemCount { - buf := buf[32*idx1 : 32*(idx1+1)] - copy(val13[idx1][:], buf) + if _, err = dec.DecodeBytes(val13[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos8+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos8+int(32*(idx1+1))), "HistoricalRoots[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "HistoricalRoots") } t.HistoricalRoots = val13 } { // Field #9 'ETH1DataVotes' (dynamic) - buf := buf[offset9:offset11] + if dec.GetPosition() != startPos0+int(offset9) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset9)), "ETH1DataVotes") + } + dec.PushLimit(int(offset11 - offset9)) val14 := t.ETH1DataVotes - itemCount := len(buf) / 72 - if len(buf)%72 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 72), "ETH1DataVotes") + sszLen := dec.GetLength() + itemCount := sszLen / 72 + if sszLen%72 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 72), "ETH1DataVotes") } if itemCount > int(expr9) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr9)), "ETH1DataVotes") } val14 = sszutils.ExpandSlice(val14, itemCount) + startPos9 := dec.GetPosition() for idx1 := range itemCount { if val14[idx1] == nil { val14[idx1] = new(phase0.ETH1Data) } - buf := buf[72*idx1 : 72*(idx1+1)] - if err = val14[idx1].UnmarshalSSZ(buf); err != nil { + if buf, err := dec.DecodeBytesBuf(72); err != nil { return sszutils.ErrorWithPathf(err, "ETH1DataVotes[%d]", idx1) + } else if err = val14[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "ETH1DataVotes[%d]", idx1) + } + if dec.GetPosition() != startPos9+int(72*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos9+int(72*(idx1+1))), "ETH1DataVotes[%d]", idx1) } } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "ETH1DataVotes") + } t.ETH1DataVotes = val14 } { // Field #11 'Validators' (dynamic) - buf := buf[offset11:offset12] + if dec.GetPosition() != startPos0+int(offset11) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset11)), "Validators") + } + dec.PushLimit(int(offset12 - offset11)) val15 := t.Validators - itemCount := len(buf) / 121 - if len(buf)%121 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 121), "Validators") + sszLen := dec.GetLength() + itemCount := sszLen / 121 + if sszLen%121 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 121), "Validators") } if itemCount > 1099511627776 { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1099511627776), "Validators") } val15 = sszutils.ExpandSlice(val15, itemCount) + startPos10 := dec.GetPosition() for idx1 := range itemCount { if val15[idx1] == nil { val15[idx1] = new(phase0.Validator) } - buf := buf[121*idx1 : 121*(idx1+1)] - if err = val15[idx1].UnmarshalSSZ(buf); err != nil { + if buf, err := dec.DecodeBytesBuf(121); err != nil { return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } else if err = val15[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } + if dec.GetPosition() != startPos10+int(121*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos10+int(121*(idx1+1))), "Validators[%d]", idx1) } } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Validators") + } t.Validators = val15 } { // Field #12 'Balances' (dynamic) - buf := buf[offset12:offset15] + if dec.GetPosition() != startPos0+int(offset12) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset12)), "Balances") + } + dec.PushLimit(int(offset15 - offset12)) val16 := t.Balances - itemCount := len(buf) / 8 - if len(buf)%8 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 8), "Balances") + sszLen := dec.GetLength() + itemCount := sszLen / 8 + if sszLen%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 8), "Balances") } if itemCount > 1099511627776 { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1099511627776), "Balances") } val16 = sszutils.ExpandSlice(val16, itemCount) - sszutils.UnmarshalUint64Slice(val16, buf) + if err = sszutils.DecodeUint64Slice(dec, val16); err != nil { + return sszutils.ErrorWithPath(err, "Balances") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Balances") + } t.Balances = val16 } { // Field #15 'PreviousEpochParticipation' (dynamic) - buf := buf[offset15:offset16] + if dec.GetPosition() != startPos0+int(offset15) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset15)), "PreviousEpochParticipation") + } + dec.PushLimit(int(offset16 - offset15)) val17 := t.PreviousEpochParticipation - itemCount := len(buf) + itemCount := dec.GetLength() if itemCount > 1099511627776 { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1099511627776), "PreviousEpochParticipation") } val17 = sszutils.ExpandSlice(val17, itemCount) + startPos11 := dec.GetPosition() for idx1 := range itemCount { - buf := buf[1*idx1 : 1*(idx1+1)] - val17[idx1] = altair.ParticipationFlags(buf[0]) + if val, err := dec.DecodeUint8(); err != nil { + return sszutils.ErrorWithPathf(err, "PreviousEpochParticipation[%d]", idx1) + } else { + val17[idx1] = altair.ParticipationFlags(val) + } + if dec.GetPosition() != startPos11+int(1*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos11+int(1*(idx1+1))), "PreviousEpochParticipation[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "PreviousEpochParticipation") } t.PreviousEpochParticipation = val17 } { // Field #16 'CurrentEpochParticipation' (dynamic) - buf := buf[offset16:offset21] + if dec.GetPosition() != startPos0+int(offset16) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset16)), "CurrentEpochParticipation") + } + dec.PushLimit(int(offset21 - offset16)) val18 := t.CurrentEpochParticipation - itemCount := len(buf) + itemCount := dec.GetLength() if itemCount > 1099511627776 { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1099511627776), "CurrentEpochParticipation") } val18 = sszutils.ExpandSlice(val18, itemCount) + startPos12 := dec.GetPosition() for idx1 := range itemCount { - buf := buf[1*idx1 : 1*(idx1+1)] - val18[idx1] = altair.ParticipationFlags(buf[0]) + if val, err := dec.DecodeUint8(); err != nil { + return sszutils.ErrorWithPathf(err, "CurrentEpochParticipation[%d]", idx1) + } else { + val18[idx1] = altair.ParticipationFlags(val) + } + if dec.GetPosition() != startPos12+int(1*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos12+int(1*(idx1+1))), "CurrentEpochParticipation[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "CurrentEpochParticipation") } t.CurrentEpochParticipation = val18 } { // Field #21 'InactivityScores' (dynamic) - buf := buf[offset21:offset27] + if dec.GetPosition() != startPos0+int(offset21) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset21)), "InactivityScores") + } + dec.PushLimit(int(offset27 - offset21)) val19 := t.InactivityScores - itemCount := len(buf) / 8 - if len(buf)%8 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 8), "InactivityScores") + sszLen := dec.GetLength() + itemCount := sszLen / 8 + if sszLen%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 8), "InactivityScores") } if itemCount > 1099511627776 { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1099511627776), "InactivityScores") } val19 = sszutils.ExpandSlice(val19, itemCount) - sszutils.UnmarshalUint64Slice(val19, buf) + if err = sszutils.DecodeUint64Slice(dec, val19); err != nil { + return sszutils.ErrorWithPath(err, "InactivityScores") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "InactivityScores") + } t.InactivityScores = val19 } { // Field #27 'HistoricalSummaries' (dynamic) - buf := buf[offset27:offset34] + if dec.GetPosition() != startPos0+int(offset27) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset27)), "HistoricalSummaries") + } + dec.PushLimit(int(offset34 - offset27)) val20 := t.HistoricalSummaries - itemCount := len(buf) / 64 - if len(buf)%64 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 64), "HistoricalSummaries") + sszLen := dec.GetLength() + itemCount := sszLen / 64 + if sszLen%64 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 64), "HistoricalSummaries") } if itemCount > 16777216 { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 16777216), "HistoricalSummaries") } val20 = sszutils.ExpandSlice(val20, itemCount) + startPos13 := dec.GetPosition() for idx1 := range itemCount { if val20[idx1] == nil { val20[idx1] = new(capella.HistoricalSummary) } - buf := buf[64*idx1 : 64*(idx1+1)] - if err = val20[idx1].UnmarshalSSZ(buf); err != nil { + if buf, err := dec.DecodeBytesBuf(64); err != nil { return sszutils.ErrorWithPathf(err, "HistoricalSummaries[%d]", idx1) + } else if err = val20[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "HistoricalSummaries[%d]", idx1) + } + if dec.GetPosition() != startPos13+int(64*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos13+int(64*(idx1+1))), "HistoricalSummaries[%d]", idx1) } } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "HistoricalSummaries") + } t.HistoricalSummaries = val20 } { // Field #34 'PendingDeposits' (dynamic) - buf := buf[offset34:offset35] + if dec.GetPosition() != startPos0+int(offset34) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset34)), "PendingDeposits") + } + dec.PushLimit(int(offset35 - offset34)) val21 := t.PendingDeposits - itemCount := len(buf) / 192 - if len(buf)%192 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 192), "PendingDeposits") + sszLen := dec.GetLength() + itemCount := sszLen / 192 + if sszLen%192 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 192), "PendingDeposits") } if itemCount > int(expr10) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr10)), "PendingDeposits") } val21 = sszutils.ExpandSlice(val21, itemCount) + startPos14 := dec.GetPosition() for idx1 := range itemCount { if val21[idx1] == nil { val21[idx1] = new(electra.PendingDeposit) } - buf := buf[192*idx1 : 192*(idx1+1)] - if err = val21[idx1].UnmarshalSSZ(buf); err != nil { + if buf, err := dec.DecodeBytesBuf(192); err != nil { return sszutils.ErrorWithPathf(err, "PendingDeposits[%d]", idx1) + } else if err = val21[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "PendingDeposits[%d]", idx1) + } + if dec.GetPosition() != startPos14+int(192*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos14+int(192*(idx1+1))), "PendingDeposits[%d]", idx1) } } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "PendingDeposits") + } t.PendingDeposits = val21 } { // Field #35 'PendingPartialWithdrawals' (dynamic) - buf := buf[offset35:offset36] + if dec.GetPosition() != startPos0+int(offset35) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset35)), "PendingPartialWithdrawals") + } + dec.PushLimit(int(offset36 - offset35)) val22 := t.PendingPartialWithdrawals - itemCount := len(buf) / 24 - if len(buf)%24 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 24), "PendingPartialWithdrawals") + sszLen := dec.GetLength() + itemCount := sszLen / 24 + if sszLen%24 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 24), "PendingPartialWithdrawals") } if itemCount > int(expr11) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr11)), "PendingPartialWithdrawals") } val22 = sszutils.ExpandSlice(val22, itemCount) + startPos15 := dec.GetPosition() for idx1 := range itemCount { if val22[idx1] == nil { val22[idx1] = new(electra.PendingPartialWithdrawal) } - buf := buf[24*idx1 : 24*(idx1+1)] - if err = val22[idx1].UnmarshalSSZ(buf); err != nil { + if buf, err := dec.DecodeBytesBuf(24); err != nil { return sszutils.ErrorWithPathf(err, "PendingPartialWithdrawals[%d]", idx1) + } else if err = val22[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "PendingPartialWithdrawals[%d]", idx1) + } + if dec.GetPosition() != startPos15+int(24*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos15+int(24*(idx1+1))), "PendingPartialWithdrawals[%d]", idx1) } } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "PendingPartialWithdrawals") + } t.PendingPartialWithdrawals = val22 } { // Field #36 'PendingConsolidations' (dynamic) - buf := buf[offset36:offset38] + if dec.GetPosition() != startPos0+int(offset36) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset36)), "PendingConsolidations") + } + dec.PushLimit(int(offset38 - offset36)) val23 := t.PendingConsolidations - itemCount := len(buf) / 16 - if len(buf)%16 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 16), "PendingConsolidations") + sszLen := dec.GetLength() + itemCount := sszLen / 16 + if sszLen%16 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 16), "PendingConsolidations") } if itemCount > int(expr12) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr12)), "PendingConsolidations") } val23 = sszutils.ExpandSlice(val23, itemCount) + startPos16 := dec.GetPosition() for idx1 := range itemCount { if val23[idx1] == nil { val23[idx1] = new(electra.PendingConsolidation) } - buf := buf[16*idx1 : 16*(idx1+1)] - if err = val23[idx1].UnmarshalSSZ(buf); err != nil { + if buf, err := dec.DecodeBytesBuf(16); err != nil { return sszutils.ErrorWithPathf(err, "PendingConsolidations[%d]", idx1) + } else if err = val23[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "PendingConsolidations[%d]", idx1) + } + if dec.GetPosition() != startPos16+int(16*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos16+int(16*(idx1+1))), "PendingConsolidations[%d]", idx1) } } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "PendingConsolidations") + } t.PendingConsolidations = val23 } { // Field #38 'Builders' (dynamic) - buf := buf[offset38:offset42] + if dec.GetPosition() != startPos0+int(offset38) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset38)), "Builders") + } + dec.PushLimit(int(offset42 - offset38)) val24 := t.Builders - itemCount := len(buf) / 93 - if len(buf)%93 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 93), "Builders") + sszLen := dec.GetLength() + itemCount := sszLen / 93 + if sszLen%93 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 93), "Builders") } if itemCount > int(expr13) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr13)), "Builders") } val24 = sszutils.ExpandSlice(val24, itemCount) + startPos17 := dec.GetPosition() for idx1 := range itemCount { if val24[idx1] == nil { val24[idx1] = new(gloas.Builder) } - buf := buf[93*idx1 : 93*(idx1+1)] - if err = val24[idx1].UnmarshalSSZ(buf); err != nil { + if buf, err := dec.DecodeBytesBuf(93); err != nil { return sszutils.ErrorWithPathf(err, "Builders[%d]", idx1) + } else if err = val24[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Builders[%d]", idx1) + } + if dec.GetPosition() != startPos17+int(93*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos17+int(93*(idx1+1))), "Builders[%d]", idx1) } } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Builders") + } t.Builders = val24 } { // Field #42 'BuilderPendingWithdrawals' (dynamic) - buf := buf[offset42:offset43] + if dec.GetPosition() != startPos0+int(offset42) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset42)), "BuilderPendingWithdrawals") + } + dec.PushLimit(int(offset43 - offset42)) val25 := t.BuilderPendingWithdrawals - itemCount := len(buf) / 36 - if len(buf)%36 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 36), "BuilderPendingWithdrawals") + sszLen := dec.GetLength() + itemCount := sszLen / 36 + if sszLen%36 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 36), "BuilderPendingWithdrawals") } if itemCount > int(expr14) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr14)), "BuilderPendingWithdrawals") } val25 = sszutils.ExpandSlice(val25, itemCount) + startPos18 := dec.GetPosition() for idx1 := range itemCount { if val25[idx1] == nil { val25[idx1] = new(gloas.BuilderPendingWithdrawal) } - buf := buf[36*idx1 : 36*(idx1+1)] - if err = val25[idx1].UnmarshalSSZ(buf); err != nil { + if buf, err := dec.DecodeBytesBuf(36); err != nil { return sszutils.ErrorWithPathf(err, "BuilderPendingWithdrawals[%d]", idx1) + } else if err = val25[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "BuilderPendingWithdrawals[%d]", idx1) + } + if dec.GetPosition() != startPos18+int(36*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos18+int(36*(idx1+1))), "BuilderPendingWithdrawals[%d]", idx1) } } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "BuilderPendingWithdrawals") + } t.BuilderPendingWithdrawals = val25 } { // Field #43 'LatestExecutionPayloadBid' (dynamic) - buf := buf[offset43:offset44] - if t.LatestExecutionPayloadBid == nil { - t.LatestExecutionPayloadBid = new(ExecutionPayloadBid) + if dec.GetPosition() != startPos0+int(offset43) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset43)), "LatestExecutionPayloadBid") } - if viewFn := t.LatestExecutionPayloadBid.UnmarshalSSZDynView((*heze.ExecutionPayloadBid)(nil)); viewFn != nil { + dec.PushLimit(int(offset44 - offset43)) + val26 := t.LatestExecutionPayloadBid + if val26 == nil { + val26 = new(ExecutionPayloadBid) + } + if buf, err := dec.DecodeBytesBuf(dec.GetLength()); err != nil { + return err + } else if viewFn := val26.UnmarshalSSZDynView((*heze.ExecutionPayloadBid)(nil)); viewFn != nil { if err = viewFn(ds, buf); err != nil { return err } } else { return sszutils.ErrNotImplemented } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "LatestExecutionPayloadBid") + } + t.LatestExecutionPayloadBid = val26 } { // Field #44 'PayloadExpectedWithdrawals' (dynamic) - buf := buf[offset44:] - val26 := t.PayloadExpectedWithdrawals - itemCount := len(buf) / 44 - if len(buf)%44 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 44), "PayloadExpectedWithdrawals") + if dec.GetPosition() != startPos0+int(offset44) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset44)), "PayloadExpectedWithdrawals") + } + dec.PushLimit(int(maxOffset - offset44)) + val27 := t.PayloadExpectedWithdrawals + sszLen := dec.GetLength() + itemCount := sszLen / 44 + if sszLen%44 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 44), "PayloadExpectedWithdrawals") } if itemCount > int(expr15) { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr15)), "PayloadExpectedWithdrawals") } - val26 = sszutils.ExpandSlice(val26, itemCount) + val27 = sszutils.ExpandSlice(val27, itemCount) + startPos19 := dec.GetPosition() for idx1 := range itemCount { - if val26[idx1] == nil { - val26[idx1] = new(capella.Withdrawal) + if val27[idx1] == nil { + val27[idx1] = new(capella.Withdrawal) } - buf := buf[44*idx1 : 44*(idx1+1)] - if err = val26[idx1].UnmarshalSSZ(buf); err != nil { + if buf, err := dec.DecodeBytesBuf(44); err != nil { return sszutils.ErrorWithPathf(err, "PayloadExpectedWithdrawals[%d]", idx1) + } else if err = val27[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "PayloadExpectedWithdrawals[%d]", idx1) + } + if dec.GetPosition() != startPos19+int(44*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos19+int(44*(idx1+1))), "PayloadExpectedWithdrawals[%d]", idx1) } } - t.PayloadExpectedWithdrawals = val26 + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "PayloadExpectedWithdrawals") + } + t.PayloadExpectedWithdrawals = val27 } return nil } diff --git a/spec/all/generate.yaml b/spec/all/generate.yaml index c6d97b9d..ab4c5f75 100644 --- a/spec/all/generate.yaml +++ b/spec/all/generate.yaml @@ -3,6 +3,7 @@ package: . types: - name: BeaconState output: beaconstate_ssz.go + with-streaming: true view-only: true views: - ../phase0.BeaconState diff --git a/spec/altair/beaconstate_ssz.go b/spec/altair/beaconstate_ssz.go index 39815e37..7668164e 100644 --- a/spec/altair/beaconstate_ssz.go +++ b/spec/altair/beaconstate_ssz.go @@ -1,5 +1,5 @@ // Code generated by dynamic-ssz. DO NOT EDIT. -// Hash: a28c3fb685f753e6e7253bfeeadac8e81281443f52be4f8a66fe952e0c3bd3d6 +// Hash: b4ec801dd7c6763a50a4b9dd0f1713200c63d59122b3bf81e7cca0f2048532b2 // Version: v1.3.1 (https://github.com/pk910/dynamic-ssz) package altair @@ -270,6 +270,438 @@ func (t *BeaconState) MarshalSSZTo(buf []byte) (dst []byte, err error) { return dst, nil } +// MarshalSSZEncoder marshals the *BeaconState to the given SSZ encoder using dynamic specifications. +func (t *BeaconState) MarshalSSZEncoder(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + type encoderCtx struct { + ds sszutils.DynamicSpecs + exprs [7]uint64 + sizeFn1 func(ctx *encoderCtx, t []phase0.Root) (size int) + sizeFn2 func(ctx *encoderCtx, t []*phase0.ETH1Data) (size int) + sizeFn3 func(ctx *encoderCtx, t []*phase0.Validator) (size int) + sizeFn4 func(ctx *encoderCtx, t []phase0.Gwei) (size int) + sizeFn5 func(ctx *encoderCtx, t []ParticipationFlags) (size int) + sizeFn6 func(ctx *encoderCtx, t []ParticipationFlags) (size int) + sizeFn7 func(ctx *encoderCtx, t []uint64) (size int) + } + ctx := &encoderCtx{ds: ds} + canSeek := enc.Seekable() + ctx.exprs[0], err = sszutils.ResolveSpecValueWithDefault(ds, "SLOTS_PER_HISTORICAL_ROOT", 8192) + if err != nil { + return err + } + ctx.exprs[1], err = sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_HISTORICAL_VECTOR", 65536) + if err != nil { + return err + } + ctx.exprs[2], err = sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_SLASHINGS_VECTOR", 8192) + if err != nil { + return err + } + ctx.exprs[3], err = sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE", 512) + if err != nil { + return err + } + ctx.exprs[4], err = sszutils.ResolveSpecValueWithDefault(ds, "HISTORICAL_ROOTS_LIMIT", 16777216) + if err != nil { + return err + } + ctx.exprs[5], err = sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_ETH1_VOTING_PERIOD*SLOTS_PER_EPOCH", 2048) + if err != nil { + return err + } + ctx.exprs[6], err = sszutils.ResolveSpecValueWithDefault(ds, "VALIDATOR_REGISTRY_LIMIT", 1099511627776) + if err != nil { + return err + } + // size for []phase0.Root + ctx.sizeFn1 = func(ctx *encoderCtx, t []phase0.Root) (size int) { + size += len(t) * 32 + return size + } + // size for []*phase0.ETH1Data + ctx.sizeFn2 = func(ctx *encoderCtx, t []*phase0.ETH1Data) (size int) { + size += len(t) * 72 + return size + } + // size for []*phase0.Validator + ctx.sizeFn3 = func(ctx *encoderCtx, t []*phase0.Validator) (size int) { + size += len(t) * 121 + return size + } + // size for []phase0.Gwei + ctx.sizeFn4 = func(ctx *encoderCtx, t []phase0.Gwei) (size int) { + size += len(t) * 8 + return size + } + // size for []ParticipationFlags + ctx.sizeFn5 = func(ctx *encoderCtx, t []ParticipationFlags) (size int) { + size += len(t) + return size + } + // size for []ParticipationFlags + ctx.sizeFn6 = func(ctx *encoderCtx, t []ParticipationFlags) (size int) { + size += len(t) + return size + } + // size for []uint64 + ctx.sizeFn7 = func(ctx *encoderCtx, t []uint64) (size int) { + size += len(t) * 8 + return size + } + size1 := 32 * int(ctx.exprs[0]) + size2 := 32 * int(ctx.exprs[1]) + size3 := 8 * int(ctx.exprs[2]) + size5 := 48 * int(ctx.exprs[3]) + size4 := size5 + 48 // size expression for '*SyncCommittee' + if t == nil { + t = new(BeaconState) + } + dstlen := enc.GetPosition() + dynoff := uint32(size1 + size1 + size2 + size3 + size4 + size4 + 405) + { // Field #0 'GenesisTime' + enc.EncodeUint64(t.GenesisTime) + } + { // Field #1 'GenesisValidatorsRoot' + enc.EncodeBytes(t.GenesisValidatorsRoot[:32]) + } + { // Field #2 'Slot' + enc.EncodeUint64(uint64(t.Slot)) + } + { // Field #3 'Fork' + t := t.Fork + if t == nil { + t = new(phase0.Fork) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "Fork") + } else { + enc.SetBuffer(buf) + } + } + { // Field #4 'LatestBlockHeader' + t := t.LatestBlockHeader + if t == nil { + t = new(phase0.BeaconBlockHeader) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") + } else { + enc.SetBuffer(buf) + } + } + { // Field #5 'BlockRoots' + t := t.BlockRoots + vlen := len(t) + if vlen > int(ctx.exprs[0]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[0])), "BlockRoots") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:32]) + } + if vlen < int(ctx.exprs[0]) { + enc.EncodeZeroPadding((int(ctx.exprs[0]) - vlen) * 32) + } + } + { // Field #6 'StateRoots' + t := t.StateRoots + vlen := len(t) + if vlen > int(ctx.exprs[0]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[0])), "StateRoots") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:32]) + } + if vlen < int(ctx.exprs[0]) { + enc.EncodeZeroPadding((int(ctx.exprs[0]) - vlen) * 32) + } + } + // Offset #7 'HistoricalRoots' + offset7 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn1(ctx, t.HistoricalRoots)) + } + { // Field #8 'ETH1Data' + t := t.ETH1Data + if t == nil { + t = new(phase0.ETH1Data) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "ETH1Data") + } else { + enc.SetBuffer(buf) + } + } + // Offset #9 'ETH1DataVotes' + offset9 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn2(ctx, t.ETH1DataVotes)) + } + { // Field #10 'ETH1DepositIndex' + enc.EncodeUint64(t.ETH1DepositIndex) + } + // Offset #11 'Validators' + offset11 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn3(ctx, t.Validators)) + } + // Offset #12 'Balances' + offset12 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn4(ctx, t.Balances)) + } + { // Field #13 'RANDAOMixes' + t := t.RANDAOMixes + vlen := len(t) + if vlen > int(ctx.exprs[1]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[1])), "RANDAOMixes") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:32]) + } + if vlen < int(ctx.exprs[1]) { + enc.EncodeZeroPadding((int(ctx.exprs[1]) - vlen) * 32) + } + } + { // Field #14 'Slashings' + t := t.Slashings + vlen := len(t) + if vlen > int(ctx.exprs[2]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[2])), "Slashings") + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + if vlen < int(ctx.exprs[2]) { + enc.EncodeZeroPadding((int(ctx.exprs[2]) - vlen) * 8) + } + } + // Offset #15 'PreviousEpochParticipation' + offset15 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn5(ctx, t.PreviousEpochParticipation)) + } + // Offset #16 'CurrentEpochParticipation' + offset16 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn6(ctx, t.CurrentEpochParticipation)) + } + { // Field #17 'JustificationBits' + vlen := len(t.JustificationBits) + if vlen > 1 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 1), "JustificationBits") + } + enc.EncodeBytes(t.JustificationBits[:vlen]) + if vlen < 1 { + enc.EncodeZeroPadding((1 - vlen) * 1) + } + } + { // Field #18 'PreviousJustifiedCheckpoint' + t := t.PreviousJustifiedCheckpoint + if t == nil { + t = new(phase0.Checkpoint) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } else { + enc.SetBuffer(buf) + } + } + { // Field #19 'CurrentJustifiedCheckpoint' + t := t.CurrentJustifiedCheckpoint + if t == nil { + t = new(phase0.Checkpoint) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } else { + enc.SetBuffer(buf) + } + } + { // Field #20 'FinalizedCheckpoint' + t := t.FinalizedCheckpoint + if t == nil { + t = new(phase0.Checkpoint) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") + } else { + enc.SetBuffer(buf) + } + } + // Offset #21 'InactivityScores' + offset21 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn7(ctx, t.InactivityScores)) + } + { // Field #22 'CurrentSyncCommittee' + t := t.CurrentSyncCommittee + if t == nil { + t = new(SyncCommittee) + } + { // Field #0 'Pubkeys' + t := t.Pubkeys + vlen := len(t) + if vlen > int(ctx.exprs[3]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[3])), "CurrentSyncCommittee.Pubkeys") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:48]) + } + if vlen < int(ctx.exprs[3]) { + enc.EncodeZeroPadding((int(ctx.exprs[3]) - vlen) * 48) + } + } + { // Field #1 'AggregatePubkey' + enc.EncodeBytes(t.AggregatePubkey[:48]) + } + } + { // Field #23 'NextSyncCommittee' + t := t.NextSyncCommittee + if t == nil { + t = new(SyncCommittee) + } + { // Field #0 'Pubkeys' + t := t.Pubkeys + vlen := len(t) + if vlen > int(ctx.exprs[3]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[3])), "NextSyncCommittee.Pubkeys") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:48]) + } + if vlen < int(ctx.exprs[3]) { + enc.EncodeZeroPadding((int(ctx.exprs[3]) - vlen) * 48) + } + } + { // Field #1 'AggregatePubkey' + enc.EncodeBytes(t.AggregatePubkey[:48]) + } + } + { // Dynamic Field #7 'HistoricalRoots' + if canSeek { + enc.EncodeOffsetAt(offset7, uint32(enc.GetPosition()-dstlen)) + } + t := t.HistoricalRoots + vlen := len(t) + if vlen > int(ctx.exprs[4]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[4])), "HistoricalRoots") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:32]) + } + } + { // Dynamic Field #9 'ETH1DataVotes' + if canSeek { + enc.EncodeOffsetAt(offset9, uint32(enc.GetPosition()-dstlen)) + } + t := t.ETH1DataVotes + vlen := len(t) + if vlen > int(ctx.exprs[5]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[5])), "ETH1DataVotes") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(phase0.ETH1Data) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "ETH1DataVotes[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #11 'Validators' + if canSeek { + enc.EncodeOffsetAt(offset11, uint32(enc.GetPosition()-dstlen)) + } + t := t.Validators + vlen := len(t) + if vlen > int(ctx.exprs[6]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[6])), "Validators") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(phase0.Validator) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #12 'Balances' + if canSeek { + enc.EncodeOffsetAt(offset12, uint32(enc.GetPosition()-dstlen)) + } + t := t.Balances + vlen := len(t) + if vlen > int(ctx.exprs[6]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[6])), "Balances") + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + } + { // Dynamic Field #15 'PreviousEpochParticipation' + if canSeek { + enc.EncodeOffsetAt(offset15, uint32(enc.GetPosition()-dstlen)) + } + t := t.PreviousEpochParticipation + vlen := len(t) + if vlen > int(ctx.exprs[6]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[6])), "PreviousEpochParticipation") + } + for idx1 := range vlen { + enc.EncodeUint8(byte(t[idx1])) + } + } + { // Dynamic Field #16 'CurrentEpochParticipation' + if canSeek { + enc.EncodeOffsetAt(offset16, uint32(enc.GetPosition()-dstlen)) + } + t := t.CurrentEpochParticipation + vlen := len(t) + if vlen > int(ctx.exprs[6]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[6])), "CurrentEpochParticipation") + } + for idx1 := range vlen { + enc.EncodeUint8(byte(t[idx1])) + } + } + { // Dynamic Field #21 'InactivityScores' + if canSeek { + enc.EncodeOffsetAt(offset21, uint32(enc.GetPosition()-dstlen)) + } + t := t.InactivityScores + vlen := len(t) + if vlen > int(ctx.exprs[6]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[6])), "InactivityScores") + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + } + return nil +} + // UnmarshalSSZ unmarshals the *BeaconState from SSZ-encoded bytes. func (t *BeaconState) UnmarshalSSZ(buf []byte) (err error) { buflen := len(buf) @@ -561,6 +993,494 @@ func (t *BeaconState) UnmarshalSSZ(buf []byte) (err error) { return nil } +// UnmarshalSSZDecoder unmarshals the *BeaconState from the given SSZ decoder using dynamic specifications. +func (t *BeaconState) UnmarshalSSZDecoder(ds sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { + expr0, err := sszutils.ResolveSpecValueWithDefault(ds, "SLOTS_PER_HISTORICAL_ROOT", 8192) + if err != nil { + return err + } + expr1, err := sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_HISTORICAL_VECTOR", 65536) + if err != nil { + return err + } + expr2, err := sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_SLASHINGS_VECTOR", 8192) + if err != nil { + return err + } + expr3, err := sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE", 512) + if err != nil { + return err + } + expr4, err := sszutils.ResolveSpecValueWithDefault(ds, "HISTORICAL_ROOTS_LIMIT", 16777216) + if err != nil { + return err + } + expr5, err := sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_ETH1_VOTING_PERIOD*SLOTS_PER_EPOCH", 2048) + if err != nil { + return err + } + expr6, err := sszutils.ResolveSpecValueWithDefault(ds, "VALIDATOR_REGISTRY_LIMIT", 1099511627776) + if err != nil { + return err + } + size1 := 32 * int(expr0) + size2 := 32 * int(expr1) + size3 := 8 * int(expr2) + size5 := 48 * int(expr3) + size4 := size5 + 48 // size expression for '*SyncCommittee' + totalSize := size1+size1+size2+size3+size4+size4+405 + maxOffset := uint32(dec.GetLength()) + startPos0 := dec.GetPosition() + if maxOffset < uint32(totalSize) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(totalSize)) + } + // Field #0 'GenesisTime' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "GenesisTime") + } else { + t.GenesisTime = val + } + // Field #1 'GenesisValidatorsRoot' (static) + if _, err = dec.DecodeBytes(t.GenesisValidatorsRoot[:32]); err != nil { + return err + } + // Field #2 'Slot' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "Slot") + } else { + t.Slot = phase0.Slot(val) + } + // Field #3 'Fork' (static) + if t.Fork == nil { + t.Fork = new(phase0.Fork) + } + if buf, err := dec.DecodeBytesBuf(16); err != nil { + return sszutils.ErrorWithPath(err, "Fork") + } else if err = t.Fork.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "Fork") + } + // Field #4 'LatestBlockHeader' (static) + if t.LatestBlockHeader == nil { + t.LatestBlockHeader = new(phase0.BeaconBlockHeader) + } + if buf, err := dec.DecodeBytesBuf(112); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") + } else if err = t.LatestBlockHeader.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") + } + { // Field #5 'BlockRoots' (static) + val1 := t.BlockRoots + val1 = sszutils.ExpandSlice(val1, int(expr0)) + startPos1 := dec.GetPosition() + for idx1 := range int(expr0) { + if _, err = dec.DecodeBytes(val1[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos1+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos1+int(32*(idx1+1))), "BlockRoots[%d]", idx1) + } + } + t.BlockRoots = val1 + } + { // Field #6 'StateRoots' (static) + val2 := t.StateRoots + val2 = sszutils.ExpandSlice(val2, int(expr0)) + startPos2 := dec.GetPosition() + for idx1 := range int(expr0) { + if _, err = dec.DecodeBytes(val2[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos2+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos2+int(32*(idx1+1))), "StateRoots[%d]", idx1) + } + } + t.StateRoots = val2 + } + // Field #7 'HistoricalRoots' (offset) + offset7, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "HistoricalRoots") + } + if offset7 != uint32(totalSize) { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset7, totalSize), "HistoricalRoots") + } + // Field #8 'ETH1Data' (static) + if t.ETH1Data == nil { + t.ETH1Data = new(phase0.ETH1Data) + } + if buf, err := dec.DecodeBytesBuf(72); err != nil { + return sszutils.ErrorWithPath(err, "ETH1Data") + } else if err = t.ETH1Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "ETH1Data") + } + // Field #9 'ETH1DataVotes' (offset) + offset9, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "ETH1DataVotes") + } + if offset9 < offset7 || offset9 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset9, offset7, maxOffset), "ETH1DataVotes") + } + // Field #10 'ETH1DepositIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "ETH1DepositIndex") + } else { + t.ETH1DepositIndex = val + } + // Field #11 'Validators' (offset) + offset11, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Validators") + } + if offset11 < offset9 || offset11 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset11, offset9, maxOffset), "Validators") + } + // Field #12 'Balances' (offset) + offset12, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Balances") + } + if offset12 < offset11 || offset12 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset12, offset11, maxOffset), "Balances") + } + { // Field #13 'RANDAOMixes' (static) + val3 := t.RANDAOMixes + val3 = sszutils.ExpandSlice(val3, int(expr1)) + startPos3 := dec.GetPosition() + for idx1 := range int(expr1) { + if _, err = dec.DecodeBytes(val3[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos3+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos3+int(32*(idx1+1))), "RANDAOMixes[%d]", idx1) + } + } + t.RANDAOMixes = val3 + } + { // Field #14 'Slashings' (static) + val4 := t.Slashings + val4 = sszutils.ExpandSlice(val4, int(expr2)) + if err = sszutils.DecodeUint64Slice(dec, val4[:int(expr2)]); err != nil { + return sszutils.ErrorWithPath(err, "Slashings") + } + t.Slashings = val4 + } + // Field #15 'PreviousEpochParticipation' (offset) + offset15, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "PreviousEpochParticipation") + } + if offset15 < offset12 || offset15 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset15, offset12, maxOffset), "PreviousEpochParticipation") + } + // Field #16 'CurrentEpochParticipation' (offset) + offset16, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "CurrentEpochParticipation") + } + if offset16 < offset15 || offset16 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset16, offset15, maxOffset), "CurrentEpochParticipation") + } + // Field #17 'JustificationBits' (static) + t.JustificationBits = sszutils.ExpandSlice(t.JustificationBits, 1) + if _, err = dec.DecodeBytes(t.JustificationBits[:1]); err != nil { + return err + } + // Field #18 'PreviousJustifiedCheckpoint' (static) + if t.PreviousJustifiedCheckpoint == nil { + t.PreviousJustifiedCheckpoint = new(phase0.Checkpoint) + } + if buf, err := dec.DecodeBytesBuf(40); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } else if err = t.PreviousJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } + // Field #19 'CurrentJustifiedCheckpoint' (static) + if t.CurrentJustifiedCheckpoint == nil { + t.CurrentJustifiedCheckpoint = new(phase0.Checkpoint) + } + if buf, err := dec.DecodeBytesBuf(40); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } else if err = t.CurrentJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } + // Field #20 'FinalizedCheckpoint' (static) + if t.FinalizedCheckpoint == nil { + t.FinalizedCheckpoint = new(phase0.Checkpoint) + } + if buf, err := dec.DecodeBytesBuf(40); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") + } else if err = t.FinalizedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") + } + // Field #21 'InactivityScores' (offset) + offset21, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "InactivityScores") + } + if offset21 < offset16 || offset21 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset21, offset16, maxOffset), "InactivityScores") + } + { // Field #22 'CurrentSyncCommittee' (static) + val5 := t.CurrentSyncCommittee + if val5 == nil { + val5 = new(SyncCommittee) + } + totalSize := size5+48 + maxOffset := uint32(dec.GetLength()) + if maxOffset < uint32(totalSize) { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(totalSize)), "CurrentSyncCommittee") + } + { // Field #0 'Pubkeys' (static) + val6 := val5.Pubkeys + val6 = sszutils.ExpandSlice(val6, int(expr3)) + startPos4 := dec.GetPosition() + for idx1 := range int(expr3) { + if _, err = dec.DecodeBytes(val6[idx1][:48]); err != nil { + return err + } + if dec.GetPosition() != startPos4+int(48*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos4+int(48*(idx1+1))), "CurrentSyncCommittee.Pubkeys[%d]", idx1) + } + } + val5.Pubkeys = val6 + } + // Field #1 'AggregatePubkey' (static) + if _, err = dec.DecodeBytes(val5.AggregatePubkey[:48]); err != nil { + return err + } + t.CurrentSyncCommittee = val5 + } + { // Field #23 'NextSyncCommittee' (static) + val7 := t.NextSyncCommittee + if val7 == nil { + val7 = new(SyncCommittee) + } + totalSize := size5+48 + maxOffset := uint32(dec.GetLength()) + if maxOffset < uint32(totalSize) { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(totalSize)), "NextSyncCommittee") + } + { // Field #0 'Pubkeys' (static) + val8 := val7.Pubkeys + val8 = sszutils.ExpandSlice(val8, int(expr3)) + startPos5 := dec.GetPosition() + for idx1 := range int(expr3) { + if _, err = dec.DecodeBytes(val8[idx1][:48]); err != nil { + return err + } + if dec.GetPosition() != startPos5+int(48*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos5+int(48*(idx1+1))), "NextSyncCommittee.Pubkeys[%d]", idx1) + } + } + val7.Pubkeys = val8 + } + // Field #1 'AggregatePubkey' (static) + if _, err = dec.DecodeBytes(val7.AggregatePubkey[:48]); err != nil { + return err + } + t.NextSyncCommittee = val7 + } + { // Field #7 'HistoricalRoots' (dynamic) + if dec.GetPosition() != startPos0+int(offset7) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset7)), "HistoricalRoots") + } + dec.PushLimit(int(offset9 - offset7)) + val9 := t.HistoricalRoots + sszLen := dec.GetLength() + itemCount := sszLen / 32 + if sszLen%32 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 32), "HistoricalRoots") + } + if itemCount > int(expr4) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr4)), "HistoricalRoots") + } + val9 = sszutils.ExpandSlice(val9, itemCount) + startPos6 := dec.GetPosition() + for idx1 := range itemCount { + if _, err = dec.DecodeBytes(val9[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos6+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos6+int(32*(idx1+1))), "HistoricalRoots[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "HistoricalRoots") + } + t.HistoricalRoots = val9 + } + { // Field #9 'ETH1DataVotes' (dynamic) + if dec.GetPosition() != startPos0+int(offset9) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset9)), "ETH1DataVotes") + } + dec.PushLimit(int(offset11 - offset9)) + val10 := t.ETH1DataVotes + sszLen := dec.GetLength() + itemCount := sszLen / 72 + if sszLen%72 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 72), "ETH1DataVotes") + } + if itemCount > int(expr5) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr5)), "ETH1DataVotes") + } + val10 = sszutils.ExpandSlice(val10, itemCount) + startPos7 := dec.GetPosition() + for idx1 := range itemCount { + if val10[idx1] == nil { + val10[idx1] = new(phase0.ETH1Data) + } + if buf, err := dec.DecodeBytesBuf(72); err != nil { + return sszutils.ErrorWithPathf(err, "ETH1DataVotes[%d]", idx1) + } else if err = val10[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "ETH1DataVotes[%d]", idx1) + } + if dec.GetPosition() != startPos7+int(72*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos7+int(72*(idx1+1))), "ETH1DataVotes[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "ETH1DataVotes") + } + t.ETH1DataVotes = val10 + } + { // Field #11 'Validators' (dynamic) + if dec.GetPosition() != startPos0+int(offset11) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset11)), "Validators") + } + dec.PushLimit(int(offset12 - offset11)) + val11 := t.Validators + sszLen := dec.GetLength() + itemCount := sszLen / 121 + if sszLen%121 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 121), "Validators") + } + if itemCount > int(expr6) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "Validators") + } + val11 = sszutils.ExpandSlice(val11, itemCount) + startPos8 := dec.GetPosition() + for idx1 := range itemCount { + if val11[idx1] == nil { + val11[idx1] = new(phase0.Validator) + } + if buf, err := dec.DecodeBytesBuf(121); err != nil { + return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } else if err = val11[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } + if dec.GetPosition() != startPos8+int(121*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos8+int(121*(idx1+1))), "Validators[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Validators") + } + t.Validators = val11 + } + { // Field #12 'Balances' (dynamic) + if dec.GetPosition() != startPos0+int(offset12) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset12)), "Balances") + } + dec.PushLimit(int(offset15 - offset12)) + val12 := t.Balances + sszLen := dec.GetLength() + itemCount := sszLen / 8 + if sszLen%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 8), "Balances") + } + if itemCount > int(expr6) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "Balances") + } + val12 = sszutils.ExpandSlice(val12, itemCount) + if err = sszutils.DecodeUint64Slice(dec, val12); err != nil { + return sszutils.ErrorWithPath(err, "Balances") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Balances") + } + t.Balances = val12 + } + { // Field #15 'PreviousEpochParticipation' (dynamic) + if dec.GetPosition() != startPos0+int(offset15) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset15)), "PreviousEpochParticipation") + } + dec.PushLimit(int(offset16 - offset15)) + val13 := t.PreviousEpochParticipation + itemCount := dec.GetLength() + if itemCount > int(expr6) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "PreviousEpochParticipation") + } + val13 = sszutils.ExpandSlice(val13, itemCount) + startPos9 := dec.GetPosition() + for idx1 := range itemCount { + if val, err := dec.DecodeUint8(); err != nil { + return sszutils.ErrorWithPathf(err, "PreviousEpochParticipation[%d]", idx1) + } else { + val13[idx1] = ParticipationFlags(val) + } + if dec.GetPosition() != startPos9+int(1*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos9+int(1*(idx1+1))), "PreviousEpochParticipation[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "PreviousEpochParticipation") + } + t.PreviousEpochParticipation = val13 + } + { // Field #16 'CurrentEpochParticipation' (dynamic) + if dec.GetPosition() != startPos0+int(offset16) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset16)), "CurrentEpochParticipation") + } + dec.PushLimit(int(offset21 - offset16)) + val14 := t.CurrentEpochParticipation + itemCount := dec.GetLength() + if itemCount > int(expr6) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "CurrentEpochParticipation") + } + val14 = sszutils.ExpandSlice(val14, itemCount) + startPos10 := dec.GetPosition() + for idx1 := range itemCount { + if val, err := dec.DecodeUint8(); err != nil { + return sszutils.ErrorWithPathf(err, "CurrentEpochParticipation[%d]", idx1) + } else { + val14[idx1] = ParticipationFlags(val) + } + if dec.GetPosition() != startPos10+int(1*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos10+int(1*(idx1+1))), "CurrentEpochParticipation[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "CurrentEpochParticipation") + } + t.CurrentEpochParticipation = val14 + } + { // Field #21 'InactivityScores' (dynamic) + if dec.GetPosition() != startPos0+int(offset21) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset21)), "InactivityScores") + } + dec.PushLimit(int(maxOffset - offset21)) + val15 := t.InactivityScores + sszLen := dec.GetLength() + itemCount := sszLen / 8 + if sszLen%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 8), "InactivityScores") + } + if itemCount > int(expr6) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "InactivityScores") + } + val15 = sszutils.ExpandSlice(val15, itemCount) + if err = sszutils.DecodeUint64Slice(dec, val15); err != nil { + return sszutils.ErrorWithPath(err, "InactivityScores") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "InactivityScores") + } + t.InactivityScores = val15 + } + return nil +} + // SizeSSZ returns the SSZ encoded size of the *BeaconState. func (t *BeaconState) SizeSSZ() (size int) { if t == nil { diff --git a/spec/altair/generate.yaml b/spec/altair/generate.yaml index 12ea5799..8086ea7f 100644 --- a/spec/altair/generate.yaml +++ b/spec/altair/generate.yaml @@ -9,6 +9,7 @@ types: output: beaconblockbody_ssz.go - name: BeaconState output: beaconstate_ssz.go + with-streaming: true - name: ContributionAndProof output: contributionandproof_ssz.go - name: SignedBeaconBlock diff --git a/spec/bellatrix/beaconblock_ssz.go b/spec/bellatrix/beaconblock_ssz.go index d805e98f..d2f2733a 100644 --- a/spec/bellatrix/beaconblock_ssz.go +++ b/spec/bellatrix/beaconblock_ssz.go @@ -1,5 +1,5 @@ // Code generated by dynamic-ssz. DO NOT EDIT. -// Hash: 721e5a859da1ceba8060ec554dc0909c5bd47b0c255717f863232c7cd14ab846 +// Hash: 5edd268e228e3e74bc7c18611f731d4d07ba39771055460b137ac1a1d7751da0 // Version: v1.3.1 (https://github.com/pk910/dynamic-ssz) package bellatrix diff --git a/spec/bellatrix/beaconblockbody_ssz.go b/spec/bellatrix/beaconblockbody_ssz.go index 1a6e5890..d215da91 100644 --- a/spec/bellatrix/beaconblockbody_ssz.go +++ b/spec/bellatrix/beaconblockbody_ssz.go @@ -1,5 +1,5 @@ // Code generated by dynamic-ssz. DO NOT EDIT. -// Hash: bd149b46d27118911ec2d90f1738d8a9e985877612d3cf68c914deca8b53e224 +// Hash: 852d5ceb4446cb88c955927d26ef7a7043add876b21dc8e62b75b5d4d6818751 // Version: v1.3.1 (https://github.com/pk910/dynamic-ssz) package bellatrix diff --git a/spec/bellatrix/beaconstate_ssz.go b/spec/bellatrix/beaconstate_ssz.go index 5dcfaf69..ffcfbf97 100644 --- a/spec/bellatrix/beaconstate_ssz.go +++ b/spec/bellatrix/beaconstate_ssz.go @@ -1,5 +1,5 @@ // Code generated by dynamic-ssz. DO NOT EDIT. -// Hash: 920b384d0932afe6b5c62711a86363d3f9b14d6d976fb611951850a3d3b0504b +// Hash: e4c8a0b11572e4ddadb63d77e0848475011a22991f26d0ddec3d572cb4838db4 // Version: v1.3.1 (https://github.com/pk910/dynamic-ssz) package bellatrix @@ -283,6 +283,466 @@ func (t *BeaconState) MarshalSSZTo(buf []byte) (dst []byte, err error) { return dst, nil } +// MarshalSSZEncoder marshals the *BeaconState to the given SSZ encoder using dynamic specifications. +func (t *BeaconState) MarshalSSZEncoder(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + type encoderCtx struct { + ds sszutils.DynamicSpecs + exprs [7]uint64 + sizeFn1 func(ctx *encoderCtx, t []phase0.Root) (size int) + sizeFn2 func(ctx *encoderCtx, t []*phase0.ETH1Data) (size int) + sizeFn3 func(ctx *encoderCtx, t []*phase0.Validator) (size int) + sizeFn4 func(ctx *encoderCtx, t []phase0.Gwei) (size int) + sizeFn5 func(ctx *encoderCtx, t []altair.ParticipationFlags) (size int) + sizeFn6 func(ctx *encoderCtx, t []altair.ParticipationFlags) (size int) + sizeFn7 func(ctx *encoderCtx, t []uint64) (size int) + sizeFn8 func(ctx *encoderCtx, t *ExecutionPayloadHeader) (size int) + } + ctx := &encoderCtx{ds: ds} + canSeek := enc.Seekable() + ctx.exprs[0], err = sszutils.ResolveSpecValueWithDefault(ds, "SLOTS_PER_HISTORICAL_ROOT", 8192) + if err != nil { + return err + } + ctx.exprs[1], err = sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_HISTORICAL_VECTOR", 65536) + if err != nil { + return err + } + ctx.exprs[2], err = sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_SLASHINGS_VECTOR", 8192) + if err != nil { + return err + } + ctx.exprs[3], err = sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE", 512) + if err != nil { + return err + } + ctx.exprs[4], err = sszutils.ResolveSpecValueWithDefault(ds, "HISTORICAL_ROOTS_LIMIT", 16777216) + if err != nil { + return err + } + ctx.exprs[5], err = sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_ETH1_VOTING_PERIOD*SLOTS_PER_EPOCH", 2048) + if err != nil { + return err + } + ctx.exprs[6], err = sszutils.ResolveSpecValueWithDefault(ds, "VALIDATOR_REGISTRY_LIMIT", 1099511627776) + if err != nil { + return err + } + // size for []phase0.Root + ctx.sizeFn1 = func(ctx *encoderCtx, t []phase0.Root) (size int) { + size += len(t) * 32 + return size + } + // size for []*phase0.ETH1Data + ctx.sizeFn2 = func(ctx *encoderCtx, t []*phase0.ETH1Data) (size int) { + size += len(t) * 72 + return size + } + // size for []*phase0.Validator + ctx.sizeFn3 = func(ctx *encoderCtx, t []*phase0.Validator) (size int) { + size += len(t) * 121 + return size + } + // size for []phase0.Gwei + ctx.sizeFn4 = func(ctx *encoderCtx, t []phase0.Gwei) (size int) { + size += len(t) * 8 + return size + } + // size for []altair.ParticipationFlags + ctx.sizeFn5 = func(ctx *encoderCtx, t []altair.ParticipationFlags) (size int) { + size += len(t) + return size + } + // size for []altair.ParticipationFlags + ctx.sizeFn6 = func(ctx *encoderCtx, t []altair.ParticipationFlags) (size int) { + size += len(t) + return size + } + // size for []uint64 + ctx.sizeFn7 = func(ctx *encoderCtx, t []uint64) (size int) { + size += len(t) * 8 + return size + } + // size for *ExecutionPayloadHeader + ctx.sizeFn8 = func(ctx *encoderCtx, t *ExecutionPayloadHeader) (size int) { + size += t.SizeSSZ() + return size + } + size1 := 32 * int(ctx.exprs[0]) + size2 := 32 * int(ctx.exprs[1]) + size3 := 8 * int(ctx.exprs[2]) + size5 := 48 * int(ctx.exprs[3]) + size4 := size5 + 48 // size expression for '*SyncCommittee' + if t == nil { + t = new(BeaconState) + } + dstlen := enc.GetPosition() + dynoff := uint32(size1 + size1 + size2 + size3 + size4 + size4 + 409) + { // Field #0 'GenesisTime' + enc.EncodeUint64(t.GenesisTime) + } + { // Field #1 'GenesisValidatorsRoot' + enc.EncodeBytes(t.GenesisValidatorsRoot[:32]) + } + { // Field #2 'Slot' + enc.EncodeUint64(uint64(t.Slot)) + } + { // Field #3 'Fork' + t := t.Fork + if t == nil { + t = new(phase0.Fork) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "Fork") + } else { + enc.SetBuffer(buf) + } + } + { // Field #4 'LatestBlockHeader' + t := t.LatestBlockHeader + if t == nil { + t = new(phase0.BeaconBlockHeader) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") + } else { + enc.SetBuffer(buf) + } + } + { // Field #5 'BlockRoots' + t := t.BlockRoots + vlen := len(t) + if vlen > int(ctx.exprs[0]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[0])), "BlockRoots") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:32]) + } + if vlen < int(ctx.exprs[0]) { + enc.EncodeZeroPadding((int(ctx.exprs[0]) - vlen) * 32) + } + } + { // Field #6 'StateRoots' + t := t.StateRoots + vlen := len(t) + if vlen > int(ctx.exprs[0]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[0])), "StateRoots") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:32]) + } + if vlen < int(ctx.exprs[0]) { + enc.EncodeZeroPadding((int(ctx.exprs[0]) - vlen) * 32) + } + } + // Offset #7 'HistoricalRoots' + offset7 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn1(ctx, t.HistoricalRoots)) + } + { // Field #8 'ETH1Data' + t := t.ETH1Data + if t == nil { + t = new(phase0.ETH1Data) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "ETH1Data") + } else { + enc.SetBuffer(buf) + } + } + // Offset #9 'ETH1DataVotes' + offset9 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn2(ctx, t.ETH1DataVotes)) + } + { // Field #10 'ETH1DepositIndex' + enc.EncodeUint64(t.ETH1DepositIndex) + } + // Offset #11 'Validators' + offset11 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn3(ctx, t.Validators)) + } + // Offset #12 'Balances' + offset12 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn4(ctx, t.Balances)) + } + { // Field #13 'RANDAOMixes' + t := t.RANDAOMixes + vlen := len(t) + if vlen > int(ctx.exprs[1]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[1])), "RANDAOMixes") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:32]) + } + if vlen < int(ctx.exprs[1]) { + enc.EncodeZeroPadding((int(ctx.exprs[1]) - vlen) * 32) + } + } + { // Field #14 'Slashings' + t := t.Slashings + vlen := len(t) + if vlen > int(ctx.exprs[2]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[2])), "Slashings") + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + if vlen < int(ctx.exprs[2]) { + enc.EncodeZeroPadding((int(ctx.exprs[2]) - vlen) * 8) + } + } + // Offset #15 'PreviousEpochParticipation' + offset15 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn5(ctx, t.PreviousEpochParticipation)) + } + // Offset #16 'CurrentEpochParticipation' + offset16 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn6(ctx, t.CurrentEpochParticipation)) + } + { // Field #17 'JustificationBits' + vlen := len(t.JustificationBits) + if vlen > 1 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 1), "JustificationBits") + } + enc.EncodeBytes(t.JustificationBits[:vlen]) + if vlen < 1 { + enc.EncodeZeroPadding((1 - vlen) * 1) + } + } + { // Field #18 'PreviousJustifiedCheckpoint' + t := t.PreviousJustifiedCheckpoint + if t == nil { + t = new(phase0.Checkpoint) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } else { + enc.SetBuffer(buf) + } + } + { // Field #19 'CurrentJustifiedCheckpoint' + t := t.CurrentJustifiedCheckpoint + if t == nil { + t = new(phase0.Checkpoint) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } else { + enc.SetBuffer(buf) + } + } + { // Field #20 'FinalizedCheckpoint' + t := t.FinalizedCheckpoint + if t == nil { + t = new(phase0.Checkpoint) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") + } else { + enc.SetBuffer(buf) + } + } + // Offset #21 'InactivityScores' + offset21 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn7(ctx, t.InactivityScores)) + } + { // Field #22 'CurrentSyncCommittee' + t := t.CurrentSyncCommittee + if t == nil { + t = new(altair.SyncCommittee) + } + { // Field #0 'Pubkeys' + t := t.Pubkeys + vlen := len(t) + if vlen > int(ctx.exprs[3]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[3])), "CurrentSyncCommittee.Pubkeys") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:48]) + } + if vlen < int(ctx.exprs[3]) { + enc.EncodeZeroPadding((int(ctx.exprs[3]) - vlen) * 48) + } + } + { // Field #1 'AggregatePubkey' + enc.EncodeBytes(t.AggregatePubkey[:48]) + } + } + { // Field #23 'NextSyncCommittee' + t := t.NextSyncCommittee + if t == nil { + t = new(altair.SyncCommittee) + } + { // Field #0 'Pubkeys' + t := t.Pubkeys + vlen := len(t) + if vlen > int(ctx.exprs[3]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[3])), "NextSyncCommittee.Pubkeys") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:48]) + } + if vlen < int(ctx.exprs[3]) { + enc.EncodeZeroPadding((int(ctx.exprs[3]) - vlen) * 48) + } + } + { // Field #1 'AggregatePubkey' + enc.EncodeBytes(t.AggregatePubkey[:48]) + } + } + // Offset #24 'LatestExecutionPayloadHeader' + offset24 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn8(ctx, t.LatestExecutionPayloadHeader)) + } + { // Dynamic Field #7 'HistoricalRoots' + if canSeek { + enc.EncodeOffsetAt(offset7, uint32(enc.GetPosition()-dstlen)) + } + t := t.HistoricalRoots + vlen := len(t) + if vlen > int(ctx.exprs[4]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[4])), "HistoricalRoots") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:32]) + } + } + { // Dynamic Field #9 'ETH1DataVotes' + if canSeek { + enc.EncodeOffsetAt(offset9, uint32(enc.GetPosition()-dstlen)) + } + t := t.ETH1DataVotes + vlen := len(t) + if vlen > int(ctx.exprs[5]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[5])), "ETH1DataVotes") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(phase0.ETH1Data) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "ETH1DataVotes[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #11 'Validators' + if canSeek { + enc.EncodeOffsetAt(offset11, uint32(enc.GetPosition()-dstlen)) + } + t := t.Validators + vlen := len(t) + if vlen > int(ctx.exprs[6]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[6])), "Validators") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(phase0.Validator) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #12 'Balances' + if canSeek { + enc.EncodeOffsetAt(offset12, uint32(enc.GetPosition()-dstlen)) + } + t := t.Balances + vlen := len(t) + if vlen > int(ctx.exprs[6]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[6])), "Balances") + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + } + { // Dynamic Field #15 'PreviousEpochParticipation' + if canSeek { + enc.EncodeOffsetAt(offset15, uint32(enc.GetPosition()-dstlen)) + } + t := t.PreviousEpochParticipation + vlen := len(t) + if vlen > int(ctx.exprs[6]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[6])), "PreviousEpochParticipation") + } + for idx1 := range vlen { + enc.EncodeUint8(byte(t[idx1])) + } + } + { // Dynamic Field #16 'CurrentEpochParticipation' + if canSeek { + enc.EncodeOffsetAt(offset16, uint32(enc.GetPosition()-dstlen)) + } + t := t.CurrentEpochParticipation + vlen := len(t) + if vlen > int(ctx.exprs[6]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[6])), "CurrentEpochParticipation") + } + for idx1 := range vlen { + enc.EncodeUint8(byte(t[idx1])) + } + } + { // Dynamic Field #21 'InactivityScores' + if canSeek { + enc.EncodeOffsetAt(offset21, uint32(enc.GetPosition()-dstlen)) + } + t := t.InactivityScores + vlen := len(t) + if vlen > int(ctx.exprs[6]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[6])), "InactivityScores") + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + } + { // Dynamic Field #24 'LatestExecutionPayloadHeader' + if canSeek { + enc.EncodeOffsetAt(offset24, uint32(enc.GetPosition()-dstlen)) + } + t := t.LatestExecutionPayloadHeader + if t == nil { + t = new(ExecutionPayloadHeader) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "LatestExecutionPayloadHeader") + } else { + enc.SetBuffer(buf) + } + } + return nil +} + // UnmarshalSSZ unmarshals the *BeaconState from SSZ-encoded bytes. func (t *BeaconState) UnmarshalSSZ(buf []byte) (err error) { buflen := len(buf) @@ -588,6 +1048,521 @@ func (t *BeaconState) UnmarshalSSZ(buf []byte) (err error) { return nil } +// UnmarshalSSZDecoder unmarshals the *BeaconState from the given SSZ decoder using dynamic specifications. +func (t *BeaconState) UnmarshalSSZDecoder(ds sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { + expr0, err := sszutils.ResolveSpecValueWithDefault(ds, "SLOTS_PER_HISTORICAL_ROOT", 8192) + if err != nil { + return err + } + expr1, err := sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_HISTORICAL_VECTOR", 65536) + if err != nil { + return err + } + expr2, err := sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_SLASHINGS_VECTOR", 8192) + if err != nil { + return err + } + expr3, err := sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE", 512) + if err != nil { + return err + } + expr4, err := sszutils.ResolveSpecValueWithDefault(ds, "HISTORICAL_ROOTS_LIMIT", 16777216) + if err != nil { + return err + } + expr5, err := sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_ETH1_VOTING_PERIOD*SLOTS_PER_EPOCH", 2048) + if err != nil { + return err + } + expr6, err := sszutils.ResolveSpecValueWithDefault(ds, "VALIDATOR_REGISTRY_LIMIT", 1099511627776) + if err != nil { + return err + } + size1 := 32 * int(expr0) + size2 := 32 * int(expr1) + size3 := 8 * int(expr2) + size5 := 48 * int(expr3) + size4 := size5 + 48 // size expression for '*SyncCommittee' + totalSize := size1+size1+size2+size3+size4+size4+409 + maxOffset := uint32(dec.GetLength()) + startPos0 := dec.GetPosition() + if maxOffset < uint32(totalSize) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(totalSize)) + } + // Field #0 'GenesisTime' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "GenesisTime") + } else { + t.GenesisTime = val + } + // Field #1 'GenesisValidatorsRoot' (static) + if _, err = dec.DecodeBytes(t.GenesisValidatorsRoot[:32]); err != nil { + return err + } + // Field #2 'Slot' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "Slot") + } else { + t.Slot = phase0.Slot(val) + } + // Field #3 'Fork' (static) + if t.Fork == nil { + t.Fork = new(phase0.Fork) + } + if buf, err := dec.DecodeBytesBuf(16); err != nil { + return sszutils.ErrorWithPath(err, "Fork") + } else if err = t.Fork.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "Fork") + } + // Field #4 'LatestBlockHeader' (static) + if t.LatestBlockHeader == nil { + t.LatestBlockHeader = new(phase0.BeaconBlockHeader) + } + if buf, err := dec.DecodeBytesBuf(112); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") + } else if err = t.LatestBlockHeader.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") + } + { // Field #5 'BlockRoots' (static) + val1 := t.BlockRoots + val1 = sszutils.ExpandSlice(val1, int(expr0)) + startPos1 := dec.GetPosition() + for idx1 := range int(expr0) { + if _, err = dec.DecodeBytes(val1[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos1+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos1+int(32*(idx1+1))), "BlockRoots[%d]", idx1) + } + } + t.BlockRoots = val1 + } + { // Field #6 'StateRoots' (static) + val2 := t.StateRoots + val2 = sszutils.ExpandSlice(val2, int(expr0)) + startPos2 := dec.GetPosition() + for idx1 := range int(expr0) { + if _, err = dec.DecodeBytes(val2[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos2+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos2+int(32*(idx1+1))), "StateRoots[%d]", idx1) + } + } + t.StateRoots = val2 + } + // Field #7 'HistoricalRoots' (offset) + offset7, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "HistoricalRoots") + } + if offset7 != uint32(totalSize) { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset7, totalSize), "HistoricalRoots") + } + // Field #8 'ETH1Data' (static) + if t.ETH1Data == nil { + t.ETH1Data = new(phase0.ETH1Data) + } + if buf, err := dec.DecodeBytesBuf(72); err != nil { + return sszutils.ErrorWithPath(err, "ETH1Data") + } else if err = t.ETH1Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "ETH1Data") + } + // Field #9 'ETH1DataVotes' (offset) + offset9, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "ETH1DataVotes") + } + if offset9 < offset7 || offset9 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset9, offset7, maxOffset), "ETH1DataVotes") + } + // Field #10 'ETH1DepositIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "ETH1DepositIndex") + } else { + t.ETH1DepositIndex = val + } + // Field #11 'Validators' (offset) + offset11, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Validators") + } + if offset11 < offset9 || offset11 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset11, offset9, maxOffset), "Validators") + } + // Field #12 'Balances' (offset) + offset12, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Balances") + } + if offset12 < offset11 || offset12 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset12, offset11, maxOffset), "Balances") + } + { // Field #13 'RANDAOMixes' (static) + val3 := t.RANDAOMixes + val3 = sszutils.ExpandSlice(val3, int(expr1)) + startPos3 := dec.GetPosition() + for idx1 := range int(expr1) { + if _, err = dec.DecodeBytes(val3[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos3+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos3+int(32*(idx1+1))), "RANDAOMixes[%d]", idx1) + } + } + t.RANDAOMixes = val3 + } + { // Field #14 'Slashings' (static) + val4 := t.Slashings + val4 = sszutils.ExpandSlice(val4, int(expr2)) + if err = sszutils.DecodeUint64Slice(dec, val4[:int(expr2)]); err != nil { + return sszutils.ErrorWithPath(err, "Slashings") + } + t.Slashings = val4 + } + // Field #15 'PreviousEpochParticipation' (offset) + offset15, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "PreviousEpochParticipation") + } + if offset15 < offset12 || offset15 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset15, offset12, maxOffset), "PreviousEpochParticipation") + } + // Field #16 'CurrentEpochParticipation' (offset) + offset16, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "CurrentEpochParticipation") + } + if offset16 < offset15 || offset16 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset16, offset15, maxOffset), "CurrentEpochParticipation") + } + // Field #17 'JustificationBits' (static) + t.JustificationBits = sszutils.ExpandSlice(t.JustificationBits, 1) + if _, err = dec.DecodeBytes(t.JustificationBits[:1]); err != nil { + return err + } + // Field #18 'PreviousJustifiedCheckpoint' (static) + if t.PreviousJustifiedCheckpoint == nil { + t.PreviousJustifiedCheckpoint = new(phase0.Checkpoint) + } + if buf, err := dec.DecodeBytesBuf(40); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } else if err = t.PreviousJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } + // Field #19 'CurrentJustifiedCheckpoint' (static) + if t.CurrentJustifiedCheckpoint == nil { + t.CurrentJustifiedCheckpoint = new(phase0.Checkpoint) + } + if buf, err := dec.DecodeBytesBuf(40); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } else if err = t.CurrentJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } + // Field #20 'FinalizedCheckpoint' (static) + if t.FinalizedCheckpoint == nil { + t.FinalizedCheckpoint = new(phase0.Checkpoint) + } + if buf, err := dec.DecodeBytesBuf(40); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") + } else if err = t.FinalizedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") + } + // Field #21 'InactivityScores' (offset) + offset21, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "InactivityScores") + } + if offset21 < offset16 || offset21 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset21, offset16, maxOffset), "InactivityScores") + } + { // Field #22 'CurrentSyncCommittee' (static) + val5 := t.CurrentSyncCommittee + if val5 == nil { + val5 = new(altair.SyncCommittee) + } + totalSize := size5+48 + maxOffset := uint32(dec.GetLength()) + if maxOffset < uint32(totalSize) { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(totalSize)), "CurrentSyncCommittee") + } + { // Field #0 'Pubkeys' (static) + val6 := val5.Pubkeys + val6 = sszutils.ExpandSlice(val6, int(expr3)) + startPos4 := dec.GetPosition() + for idx1 := range int(expr3) { + if _, err = dec.DecodeBytes(val6[idx1][:48]); err != nil { + return err + } + if dec.GetPosition() != startPos4+int(48*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos4+int(48*(idx1+1))), "CurrentSyncCommittee.Pubkeys[%d]", idx1) + } + } + val5.Pubkeys = val6 + } + // Field #1 'AggregatePubkey' (static) + if _, err = dec.DecodeBytes(val5.AggregatePubkey[:48]); err != nil { + return err + } + t.CurrentSyncCommittee = val5 + } + { // Field #23 'NextSyncCommittee' (static) + val7 := t.NextSyncCommittee + if val7 == nil { + val7 = new(altair.SyncCommittee) + } + totalSize := size5+48 + maxOffset := uint32(dec.GetLength()) + if maxOffset < uint32(totalSize) { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(totalSize)), "NextSyncCommittee") + } + { // Field #0 'Pubkeys' (static) + val8 := val7.Pubkeys + val8 = sszutils.ExpandSlice(val8, int(expr3)) + startPos5 := dec.GetPosition() + for idx1 := range int(expr3) { + if _, err = dec.DecodeBytes(val8[idx1][:48]); err != nil { + return err + } + if dec.GetPosition() != startPos5+int(48*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos5+int(48*(idx1+1))), "NextSyncCommittee.Pubkeys[%d]", idx1) + } + } + val7.Pubkeys = val8 + } + // Field #1 'AggregatePubkey' (static) + if _, err = dec.DecodeBytes(val7.AggregatePubkey[:48]); err != nil { + return err + } + t.NextSyncCommittee = val7 + } + // Field #24 'LatestExecutionPayloadHeader' (offset) + offset24, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "LatestExecutionPayloadHeader") + } + if offset24 < offset21 || offset24 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset24, offset21, maxOffset), "LatestExecutionPayloadHeader") + } + { // Field #7 'HistoricalRoots' (dynamic) + if dec.GetPosition() != startPos0+int(offset7) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset7)), "HistoricalRoots") + } + dec.PushLimit(int(offset9 - offset7)) + val9 := t.HistoricalRoots + sszLen := dec.GetLength() + itemCount := sszLen / 32 + if sszLen%32 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 32), "HistoricalRoots") + } + if itemCount > int(expr4) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr4)), "HistoricalRoots") + } + val9 = sszutils.ExpandSlice(val9, itemCount) + startPos6 := dec.GetPosition() + for idx1 := range itemCount { + if _, err = dec.DecodeBytes(val9[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos6+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos6+int(32*(idx1+1))), "HistoricalRoots[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "HistoricalRoots") + } + t.HistoricalRoots = val9 + } + { // Field #9 'ETH1DataVotes' (dynamic) + if dec.GetPosition() != startPos0+int(offset9) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset9)), "ETH1DataVotes") + } + dec.PushLimit(int(offset11 - offset9)) + val10 := t.ETH1DataVotes + sszLen := dec.GetLength() + itemCount := sszLen / 72 + if sszLen%72 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 72), "ETH1DataVotes") + } + if itemCount > int(expr5) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr5)), "ETH1DataVotes") + } + val10 = sszutils.ExpandSlice(val10, itemCount) + startPos7 := dec.GetPosition() + for idx1 := range itemCount { + if val10[idx1] == nil { + val10[idx1] = new(phase0.ETH1Data) + } + if buf, err := dec.DecodeBytesBuf(72); err != nil { + return sszutils.ErrorWithPathf(err, "ETH1DataVotes[%d]", idx1) + } else if err = val10[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "ETH1DataVotes[%d]", idx1) + } + if dec.GetPosition() != startPos7+int(72*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos7+int(72*(idx1+1))), "ETH1DataVotes[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "ETH1DataVotes") + } + t.ETH1DataVotes = val10 + } + { // Field #11 'Validators' (dynamic) + if dec.GetPosition() != startPos0+int(offset11) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset11)), "Validators") + } + dec.PushLimit(int(offset12 - offset11)) + val11 := t.Validators + sszLen := dec.GetLength() + itemCount := sszLen / 121 + if sszLen%121 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 121), "Validators") + } + if itemCount > int(expr6) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "Validators") + } + val11 = sszutils.ExpandSlice(val11, itemCount) + startPos8 := dec.GetPosition() + for idx1 := range itemCount { + if val11[idx1] == nil { + val11[idx1] = new(phase0.Validator) + } + if buf, err := dec.DecodeBytesBuf(121); err != nil { + return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } else if err = val11[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } + if dec.GetPosition() != startPos8+int(121*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos8+int(121*(idx1+1))), "Validators[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Validators") + } + t.Validators = val11 + } + { // Field #12 'Balances' (dynamic) + if dec.GetPosition() != startPos0+int(offset12) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset12)), "Balances") + } + dec.PushLimit(int(offset15 - offset12)) + val12 := t.Balances + sszLen := dec.GetLength() + itemCount := sszLen / 8 + if sszLen%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 8), "Balances") + } + if itemCount > int(expr6) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "Balances") + } + val12 = sszutils.ExpandSlice(val12, itemCount) + if err = sszutils.DecodeUint64Slice(dec, val12); err != nil { + return sszutils.ErrorWithPath(err, "Balances") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Balances") + } + t.Balances = val12 + } + { // Field #15 'PreviousEpochParticipation' (dynamic) + if dec.GetPosition() != startPos0+int(offset15) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset15)), "PreviousEpochParticipation") + } + dec.PushLimit(int(offset16 - offset15)) + val13 := t.PreviousEpochParticipation + itemCount := dec.GetLength() + if itemCount > int(expr6) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "PreviousEpochParticipation") + } + val13 = sszutils.ExpandSlice(val13, itemCount) + startPos9 := dec.GetPosition() + for idx1 := range itemCount { + if val, err := dec.DecodeUint8(); err != nil { + return sszutils.ErrorWithPathf(err, "PreviousEpochParticipation[%d]", idx1) + } else { + val13[idx1] = altair.ParticipationFlags(val) + } + if dec.GetPosition() != startPos9+int(1*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos9+int(1*(idx1+1))), "PreviousEpochParticipation[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "PreviousEpochParticipation") + } + t.PreviousEpochParticipation = val13 + } + { // Field #16 'CurrentEpochParticipation' (dynamic) + if dec.GetPosition() != startPos0+int(offset16) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset16)), "CurrentEpochParticipation") + } + dec.PushLimit(int(offset21 - offset16)) + val14 := t.CurrentEpochParticipation + itemCount := dec.GetLength() + if itemCount > int(expr6) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "CurrentEpochParticipation") + } + val14 = sszutils.ExpandSlice(val14, itemCount) + startPos10 := dec.GetPosition() + for idx1 := range itemCount { + if val, err := dec.DecodeUint8(); err != nil { + return sszutils.ErrorWithPathf(err, "CurrentEpochParticipation[%d]", idx1) + } else { + val14[idx1] = altair.ParticipationFlags(val) + } + if dec.GetPosition() != startPos10+int(1*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos10+int(1*(idx1+1))), "CurrentEpochParticipation[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "CurrentEpochParticipation") + } + t.CurrentEpochParticipation = val14 + } + { // Field #21 'InactivityScores' (dynamic) + if dec.GetPosition() != startPos0+int(offset21) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset21)), "InactivityScores") + } + dec.PushLimit(int(offset24 - offset21)) + val15 := t.InactivityScores + sszLen := dec.GetLength() + itemCount := sszLen / 8 + if sszLen%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 8), "InactivityScores") + } + if itemCount > int(expr6) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "InactivityScores") + } + val15 = sszutils.ExpandSlice(val15, itemCount) + if err = sszutils.DecodeUint64Slice(dec, val15); err != nil { + return sszutils.ErrorWithPath(err, "InactivityScores") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "InactivityScores") + } + t.InactivityScores = val15 + } + { // Field #24 'LatestExecutionPayloadHeader' (dynamic) + if dec.GetPosition() != startPos0+int(offset24) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset24)), "LatestExecutionPayloadHeader") + } + dec.PushLimit(int(maxOffset - offset24)) + val16 := t.LatestExecutionPayloadHeader + if val16 == nil { + val16 = new(ExecutionPayloadHeader) + } + if buf, err := dec.DecodeBytesBuf(dec.GetLength()); err != nil { + return sszutils.ErrorWithPath(err, "LatestExecutionPayloadHeader") + } else if err = val16.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "LatestExecutionPayloadHeader") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "LatestExecutionPayloadHeader") + } + t.LatestExecutionPayloadHeader = val16 + } + return nil +} + // SizeSSZ returns the SSZ encoded size of the *BeaconState. func (t *BeaconState) SizeSSZ() (size int) { if t == nil { diff --git a/spec/bellatrix/executionpayload_ssz.go b/spec/bellatrix/executionpayload_ssz.go index 0e3659c3..fc4cc234 100644 --- a/spec/bellatrix/executionpayload_ssz.go +++ b/spec/bellatrix/executionpayload_ssz.go @@ -1,5 +1,5 @@ // Code generated by dynamic-ssz. DO NOT EDIT. -// Hash: 8ef8fc09ad1c23fe94e4373419700a7a6674d3739ce1a8280709d7bfa290d78f +// Hash: b97602d9e397e0491f18b0f9313d3f3eff3a87e73ed1955c2fc1f31a0ce34656 // Version: v1.3.1 (https://github.com/pk910/dynamic-ssz) package bellatrix @@ -57,7 +57,7 @@ func (t *ExecutionPayload) MarshalSSZTo(buf []byte) (dst []byte, err error) { } // Offset Field #10 'ExtraData' dst = append(dst, 0, 0, 0, 0) - { // Static Field #11 'BaseFeePerGas' + { // Static Field #11 'BaseFeePerGasLE' dst = append(dst, t.BaseFeePerGasLE[:32]...) } { // Static Field #12 'BlockHash' @@ -145,7 +145,7 @@ func (t *ExecutionPayload) UnmarshalSSZ(buf []byte) (err error) { if offset10 != 508 { return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset10, 508), "ExtraData:o") } - { // Field #11 'BaseFeePerGas' (static) + { // Field #11 'BaseFeePerGasLE' (static) buf := buf[440:472] copy(t.BaseFeePerGasLE[:], buf) } @@ -225,7 +225,7 @@ func (t *ExecutionPayload) SizeSSZ() (size int) { // Field #8 'GasUsed' static (8 bytes) // Field #9 'Timestamp' static (8 bytes) // Field #10 'ExtraData' offset (4 bytes) - // Field #11 'BaseFeePerGas' static (32 bytes) + // Field #11 'BaseFeePerGasLE' static (32 bytes) // Field #12 'BlockHash' static (32 bytes) // Field #13 'Transactions' offset (4 bytes) size += 508 diff --git a/spec/bellatrix/executionpayloadheader_ssz.go b/spec/bellatrix/executionpayloadheader_ssz.go index f9035ce1..eda2b4ca 100644 --- a/spec/bellatrix/executionpayloadheader_ssz.go +++ b/spec/bellatrix/executionpayloadheader_ssz.go @@ -1,5 +1,5 @@ // Code generated by dynamic-ssz. DO NOT EDIT. -// Hash: 244b350b8c090c2e87fe089696c37c9b1c3fcd724910f8c84dc665ec423b443d +// Hash: 3451f87de70688d20be6a61a504f20017c971de451473620dc74fd9abcc720aa // Version: v1.3.1 (https://github.com/pk910/dynamic-ssz) package bellatrix @@ -57,7 +57,7 @@ func (t *ExecutionPayloadHeader) MarshalSSZTo(buf []byte) (dst []byte, err error } // Offset Field #10 'ExtraData' dst = append(dst, 0, 0, 0, 0) - { // Static Field #11 'BaseFeePerGas' + { // Static Field #11 'BaseFeePerGasLE' dst = append(dst, t.BaseFeePerGasLE[:32]...) } { // Static Field #12 'BlockHash' @@ -128,7 +128,7 @@ func (t *ExecutionPayloadHeader) UnmarshalSSZ(buf []byte) (err error) { if offset10 != 536 { return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset10, 536), "ExtraData:o") } - { // Field #11 'BaseFeePerGas' (static) + { // Field #11 'BaseFeePerGasLE' (static) buf := buf[440:472] copy(t.BaseFeePerGasLE[:], buf) } @@ -167,7 +167,7 @@ func (t *ExecutionPayloadHeader) SizeSSZ() (size int) { // Field #8 'GasUsed' static (8 bytes) // Field #9 'Timestamp' static (8 bytes) // Field #10 'ExtraData' offset (4 bytes) - // Field #11 'BaseFeePerGas' static (32 bytes) + // Field #11 'BaseFeePerGasLE' static (32 bytes) // Field #12 'BlockHash' static (32 bytes) // Field #13 'TransactionsRoot' static (32 bytes) size += 536 @@ -234,7 +234,7 @@ func (t *ExecutionPayloadHeader) HashTreeRootWith(hh sszutils.HashWalker) error hh.AppendBytes32(t.ExtraData[:]) hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(32, vlen, 1)) } - { // Field #11 'BaseFeePerGas' + { // Field #11 'BaseFeePerGasLE' hh.PutBytes(t.BaseFeePerGasLE[:32]) } { // Field #12 'BlockHash' diff --git a/spec/bellatrix/generate.yaml b/spec/bellatrix/generate.yaml index c963c532..799c5e93 100644 --- a/spec/bellatrix/generate.yaml +++ b/spec/bellatrix/generate.yaml @@ -9,6 +9,7 @@ types: output: beaconblockbody_ssz.go - name: BeaconState output: beaconstate_ssz.go + with-streaming: true - name: ExecutionPayload output: executionpayload_ssz.go - name: ExecutionPayloadHeader diff --git a/spec/bellatrix/signedbeaconblock_ssz.go b/spec/bellatrix/signedbeaconblock_ssz.go index 18a1d574..03060668 100644 --- a/spec/bellatrix/signedbeaconblock_ssz.go +++ b/spec/bellatrix/signedbeaconblock_ssz.go @@ -1,5 +1,5 @@ // Code generated by dynamic-ssz. DO NOT EDIT. -// Hash: 05974f2ea32bfa501808b9893fa3851bf0e9ed3e5d2870f0a6265a6e207ceec3 +// Hash: 3bcdb5549f4472686bc012a8dd103ad16829db287cb31324e056bee4518b1def // Version: v1.3.1 (https://github.com/pk910/dynamic-ssz) package bellatrix diff --git a/spec/capella/beaconblock_ssz.go b/spec/capella/beaconblock_ssz.go index 0eca749e..95c2766e 100644 --- a/spec/capella/beaconblock_ssz.go +++ b/spec/capella/beaconblock_ssz.go @@ -1,5 +1,5 @@ // Code generated by dynamic-ssz. DO NOT EDIT. -// Hash: 7246aa557afef6969b210d597ef4b6cdc56c54c2142fb7d519b13b399ce02f48 +// Hash: 5fe01b11fd1f026ddcd65206cc16c6a0392c4143ac0a17ed5bd39287c6dd67d3 // Version: v1.3.1 (https://github.com/pk910/dynamic-ssz) package capella diff --git a/spec/capella/beaconblockbody_ssz.go b/spec/capella/beaconblockbody_ssz.go index cd510f1c..ad4b570d 100644 --- a/spec/capella/beaconblockbody_ssz.go +++ b/spec/capella/beaconblockbody_ssz.go @@ -1,5 +1,5 @@ // Code generated by dynamic-ssz. DO NOT EDIT. -// Hash: 5840d7bc98a354c7f79eb07685f7f8f5e159adff77ad0a5ced29dcece135ea47 +// Hash: 6fc3083abe3768f17e3483368c358408363d5f25fcc700affe438c914982371d // Version: v1.3.1 (https://github.com/pk910/dynamic-ssz) package capella diff --git a/spec/capella/beaconstate_ssz.go b/spec/capella/beaconstate_ssz.go index 389b11ea..7196eba0 100644 --- a/spec/capella/beaconstate_ssz.go +++ b/spec/capella/beaconstate_ssz.go @@ -1,5 +1,5 @@ // Code generated by dynamic-ssz. DO NOT EDIT. -// Hash: 816b120ae80f320cd4722fc7c1ad1bc91973eab501f026fb018919d70cfbf7ae +// Hash: 03207e693a5046ae307e093e4120172e436a49a51ca879c8ec34b8e38a7526e5 // Version: v1.3.1 (https://github.com/pk910/dynamic-ssz) package capella @@ -308,6 +308,507 @@ func (t *BeaconState) MarshalSSZTo(buf []byte) (dst []byte, err error) { return dst, nil } +// MarshalSSZEncoder marshals the *BeaconState to the given SSZ encoder using dynamic specifications. +func (t *BeaconState) MarshalSSZEncoder(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + type encoderCtx struct { + ds sszutils.DynamicSpecs + exprs [7]uint64 + sizeFn1 func(ctx *encoderCtx, t []phase0.Root) (size int) + sizeFn2 func(ctx *encoderCtx, t []*phase0.ETH1Data) (size int) + sizeFn3 func(ctx *encoderCtx, t []*phase0.Validator) (size int) + sizeFn4 func(ctx *encoderCtx, t []phase0.Gwei) (size int) + sizeFn5 func(ctx *encoderCtx, t []altair.ParticipationFlags) (size int) + sizeFn6 func(ctx *encoderCtx, t []altair.ParticipationFlags) (size int) + sizeFn7 func(ctx *encoderCtx, t []uint64) (size int) + sizeFn8 func(ctx *encoderCtx, t *ExecutionPayloadHeader) (size int) + sizeFn9 func(ctx *encoderCtx, t []*HistoricalSummary) (size int) + } + ctx := &encoderCtx{ds: ds} + canSeek := enc.Seekable() + ctx.exprs[0], err = sszutils.ResolveSpecValueWithDefault(ds, "SLOTS_PER_HISTORICAL_ROOT", 8192) + if err != nil { + return err + } + ctx.exprs[1], err = sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_HISTORICAL_VECTOR", 65536) + if err != nil { + return err + } + ctx.exprs[2], err = sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_SLASHINGS_VECTOR", 8192) + if err != nil { + return err + } + ctx.exprs[3], err = sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE", 512) + if err != nil { + return err + } + ctx.exprs[4], err = sszutils.ResolveSpecValueWithDefault(ds, "HISTORICAL_ROOTS_LIMIT", 16777216) + if err != nil { + return err + } + ctx.exprs[5], err = sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_ETH1_VOTING_PERIOD*SLOTS_PER_EPOCH", 2048) + if err != nil { + return err + } + ctx.exprs[6], err = sszutils.ResolveSpecValueWithDefault(ds, "VALIDATOR_REGISTRY_LIMIT", 1099511627776) + if err != nil { + return err + } + // size for []phase0.Root + ctx.sizeFn1 = func(ctx *encoderCtx, t []phase0.Root) (size int) { + size += len(t) * 32 + return size + } + // size for []*phase0.ETH1Data + ctx.sizeFn2 = func(ctx *encoderCtx, t []*phase0.ETH1Data) (size int) { + size += len(t) * 72 + return size + } + // size for []*phase0.Validator + ctx.sizeFn3 = func(ctx *encoderCtx, t []*phase0.Validator) (size int) { + size += len(t) * 121 + return size + } + // size for []phase0.Gwei + ctx.sizeFn4 = func(ctx *encoderCtx, t []phase0.Gwei) (size int) { + size += len(t) * 8 + return size + } + // size for []altair.ParticipationFlags + ctx.sizeFn5 = func(ctx *encoderCtx, t []altair.ParticipationFlags) (size int) { + size += len(t) + return size + } + // size for []altair.ParticipationFlags + ctx.sizeFn6 = func(ctx *encoderCtx, t []altair.ParticipationFlags) (size int) { + size += len(t) + return size + } + // size for []uint64 + ctx.sizeFn7 = func(ctx *encoderCtx, t []uint64) (size int) { + size += len(t) * 8 + return size + } + // size for *ExecutionPayloadHeader + ctx.sizeFn8 = func(ctx *encoderCtx, t *ExecutionPayloadHeader) (size int) { + size += t.SizeSSZ() + return size + } + // size for []*HistoricalSummary + ctx.sizeFn9 = func(ctx *encoderCtx, t []*HistoricalSummary) (size int) { + size += len(t) * 64 + return size + } + size1 := 32 * int(ctx.exprs[0]) + size2 := 32 * int(ctx.exprs[1]) + size3 := 8 * int(ctx.exprs[2]) + size5 := 48 * int(ctx.exprs[3]) + size4 := size5 + 48 // size expression for '*SyncCommittee' + if t == nil { + t = new(BeaconState) + } + dstlen := enc.GetPosition() + dynoff := uint32(size1 + size1 + size2 + size3 + size4 + size4 + 429) + { // Field #0 'GenesisTime' + enc.EncodeUint64(t.GenesisTime) + } + { // Field #1 'GenesisValidatorsRoot' + enc.EncodeBytes(t.GenesisValidatorsRoot[:32]) + } + { // Field #2 'Slot' + enc.EncodeUint64(uint64(t.Slot)) + } + { // Field #3 'Fork' + t := t.Fork + if t == nil { + t = new(phase0.Fork) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "Fork") + } else { + enc.SetBuffer(buf) + } + } + { // Field #4 'LatestBlockHeader' + t := t.LatestBlockHeader + if t == nil { + t = new(phase0.BeaconBlockHeader) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") + } else { + enc.SetBuffer(buf) + } + } + { // Field #5 'BlockRoots' + t := t.BlockRoots + vlen := len(t) + if vlen > int(ctx.exprs[0]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[0])), "BlockRoots") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:32]) + } + if vlen < int(ctx.exprs[0]) { + enc.EncodeZeroPadding((int(ctx.exprs[0]) - vlen) * 32) + } + } + { // Field #6 'StateRoots' + t := t.StateRoots + vlen := len(t) + if vlen > int(ctx.exprs[0]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[0])), "StateRoots") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:32]) + } + if vlen < int(ctx.exprs[0]) { + enc.EncodeZeroPadding((int(ctx.exprs[0]) - vlen) * 32) + } + } + // Offset #7 'HistoricalRoots' + offset7 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn1(ctx, t.HistoricalRoots)) + } + { // Field #8 'ETH1Data' + t := t.ETH1Data + if t == nil { + t = new(phase0.ETH1Data) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "ETH1Data") + } else { + enc.SetBuffer(buf) + } + } + // Offset #9 'ETH1DataVotes' + offset9 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn2(ctx, t.ETH1DataVotes)) + } + { // Field #10 'ETH1DepositIndex' + enc.EncodeUint64(t.ETH1DepositIndex) + } + // Offset #11 'Validators' + offset11 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn3(ctx, t.Validators)) + } + // Offset #12 'Balances' + offset12 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn4(ctx, t.Balances)) + } + { // Field #13 'RANDAOMixes' + t := t.RANDAOMixes + vlen := len(t) + if vlen > int(ctx.exprs[1]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[1])), "RANDAOMixes") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:32]) + } + if vlen < int(ctx.exprs[1]) { + enc.EncodeZeroPadding((int(ctx.exprs[1]) - vlen) * 32) + } + } + { // Field #14 'Slashings' + t := t.Slashings + vlen := len(t) + if vlen > int(ctx.exprs[2]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[2])), "Slashings") + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + if vlen < int(ctx.exprs[2]) { + enc.EncodeZeroPadding((int(ctx.exprs[2]) - vlen) * 8) + } + } + // Offset #15 'PreviousEpochParticipation' + offset15 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn5(ctx, t.PreviousEpochParticipation)) + } + // Offset #16 'CurrentEpochParticipation' + offset16 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn6(ctx, t.CurrentEpochParticipation)) + } + { // Field #17 'JustificationBits' + vlen := len(t.JustificationBits) + if vlen > 1 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 1), "JustificationBits") + } + enc.EncodeBytes(t.JustificationBits[:vlen]) + if vlen < 1 { + enc.EncodeZeroPadding((1 - vlen) * 1) + } + } + { // Field #18 'PreviousJustifiedCheckpoint' + t := t.PreviousJustifiedCheckpoint + if t == nil { + t = new(phase0.Checkpoint) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } else { + enc.SetBuffer(buf) + } + } + { // Field #19 'CurrentJustifiedCheckpoint' + t := t.CurrentJustifiedCheckpoint + if t == nil { + t = new(phase0.Checkpoint) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } else { + enc.SetBuffer(buf) + } + } + { // Field #20 'FinalizedCheckpoint' + t := t.FinalizedCheckpoint + if t == nil { + t = new(phase0.Checkpoint) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") + } else { + enc.SetBuffer(buf) + } + } + // Offset #21 'InactivityScores' + offset21 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn7(ctx, t.InactivityScores)) + } + { // Field #22 'CurrentSyncCommittee' + t := t.CurrentSyncCommittee + if t == nil { + t = new(altair.SyncCommittee) + } + { // Field #0 'Pubkeys' + t := t.Pubkeys + vlen := len(t) + if vlen > int(ctx.exprs[3]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[3])), "CurrentSyncCommittee.Pubkeys") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:48]) + } + if vlen < int(ctx.exprs[3]) { + enc.EncodeZeroPadding((int(ctx.exprs[3]) - vlen) * 48) + } + } + { // Field #1 'AggregatePubkey' + enc.EncodeBytes(t.AggregatePubkey[:48]) + } + } + { // Field #23 'NextSyncCommittee' + t := t.NextSyncCommittee + if t == nil { + t = new(altair.SyncCommittee) + } + { // Field #0 'Pubkeys' + t := t.Pubkeys + vlen := len(t) + if vlen > int(ctx.exprs[3]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[3])), "NextSyncCommittee.Pubkeys") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:48]) + } + if vlen < int(ctx.exprs[3]) { + enc.EncodeZeroPadding((int(ctx.exprs[3]) - vlen) * 48) + } + } + { // Field #1 'AggregatePubkey' + enc.EncodeBytes(t.AggregatePubkey[:48]) + } + } + // Offset #24 'LatestExecutionPayloadHeader' + offset24 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn8(ctx, t.LatestExecutionPayloadHeader)) + } + { // Field #25 'NextWithdrawalIndex' + enc.EncodeUint64(uint64(t.NextWithdrawalIndex)) + } + { // Field #26 'NextWithdrawalValidatorIndex' + enc.EncodeUint64(uint64(t.NextWithdrawalValidatorIndex)) + } + // Offset #27 'HistoricalSummaries' + offset27 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn9(ctx, t.HistoricalSummaries)) + } + { // Dynamic Field #7 'HistoricalRoots' + if canSeek { + enc.EncodeOffsetAt(offset7, uint32(enc.GetPosition()-dstlen)) + } + t := t.HistoricalRoots + vlen := len(t) + if vlen > int(ctx.exprs[4]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[4])), "HistoricalRoots") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:32]) + } + } + { // Dynamic Field #9 'ETH1DataVotes' + if canSeek { + enc.EncodeOffsetAt(offset9, uint32(enc.GetPosition()-dstlen)) + } + t := t.ETH1DataVotes + vlen := len(t) + if vlen > int(ctx.exprs[5]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[5])), "ETH1DataVotes") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(phase0.ETH1Data) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "ETH1DataVotes[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #11 'Validators' + if canSeek { + enc.EncodeOffsetAt(offset11, uint32(enc.GetPosition()-dstlen)) + } + t := t.Validators + vlen := len(t) + if vlen > int(ctx.exprs[6]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[6])), "Validators") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(phase0.Validator) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #12 'Balances' + if canSeek { + enc.EncodeOffsetAt(offset12, uint32(enc.GetPosition()-dstlen)) + } + t := t.Balances + vlen := len(t) + if vlen > int(ctx.exprs[6]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[6])), "Balances") + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + } + { // Dynamic Field #15 'PreviousEpochParticipation' + if canSeek { + enc.EncodeOffsetAt(offset15, uint32(enc.GetPosition()-dstlen)) + } + t := t.PreviousEpochParticipation + vlen := len(t) + if vlen > int(ctx.exprs[6]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[6])), "PreviousEpochParticipation") + } + for idx1 := range vlen { + enc.EncodeUint8(byte(t[idx1])) + } + } + { // Dynamic Field #16 'CurrentEpochParticipation' + if canSeek { + enc.EncodeOffsetAt(offset16, uint32(enc.GetPosition()-dstlen)) + } + t := t.CurrentEpochParticipation + vlen := len(t) + if vlen > int(ctx.exprs[6]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[6])), "CurrentEpochParticipation") + } + for idx1 := range vlen { + enc.EncodeUint8(byte(t[idx1])) + } + } + { // Dynamic Field #21 'InactivityScores' + if canSeek { + enc.EncodeOffsetAt(offset21, uint32(enc.GetPosition()-dstlen)) + } + t := t.InactivityScores + vlen := len(t) + if vlen > int(ctx.exprs[6]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[6])), "InactivityScores") + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + } + { // Dynamic Field #24 'LatestExecutionPayloadHeader' + if canSeek { + enc.EncodeOffsetAt(offset24, uint32(enc.GetPosition()-dstlen)) + } + t := t.LatestExecutionPayloadHeader + if t == nil { + t = new(ExecutionPayloadHeader) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "LatestExecutionPayloadHeader") + } else { + enc.SetBuffer(buf) + } + } + { // Dynamic Field #27 'HistoricalSummaries' + if canSeek { + enc.EncodeOffsetAt(offset27, uint32(enc.GetPosition()-dstlen)) + } + t := t.HistoricalSummaries + vlen := len(t) + if vlen > int(ctx.exprs[4]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[4])), "HistoricalSummaries") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(HistoricalSummary) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "HistoricalSummaries[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + return nil +} + // UnmarshalSSZ unmarshals the *BeaconState from SSZ-encoded bytes. func (t *BeaconState) UnmarshalSSZ(buf []byte) (err error) { buflen := len(buf) @@ -648,6 +1149,575 @@ func (t *BeaconState) UnmarshalSSZ(buf []byte) (err error) { return nil } +// UnmarshalSSZDecoder unmarshals the *BeaconState from the given SSZ decoder using dynamic specifications. +func (t *BeaconState) UnmarshalSSZDecoder(ds sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { + expr0, err := sszutils.ResolveSpecValueWithDefault(ds, "SLOTS_PER_HISTORICAL_ROOT", 8192) + if err != nil { + return err + } + expr1, err := sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_HISTORICAL_VECTOR", 65536) + if err != nil { + return err + } + expr2, err := sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_SLASHINGS_VECTOR", 8192) + if err != nil { + return err + } + expr3, err := sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE", 512) + if err != nil { + return err + } + expr4, err := sszutils.ResolveSpecValueWithDefault(ds, "HISTORICAL_ROOTS_LIMIT", 16777216) + if err != nil { + return err + } + expr5, err := sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_ETH1_VOTING_PERIOD*SLOTS_PER_EPOCH", 2048) + if err != nil { + return err + } + expr6, err := sszutils.ResolveSpecValueWithDefault(ds, "VALIDATOR_REGISTRY_LIMIT", 1099511627776) + if err != nil { + return err + } + size1 := 32 * int(expr0) + size2 := 32 * int(expr1) + size3 := 8 * int(expr2) + size5 := 48 * int(expr3) + size4 := size5 + 48 // size expression for '*SyncCommittee' + totalSize := size1+size1+size2+size3+size4+size4+429 + maxOffset := uint32(dec.GetLength()) + startPos0 := dec.GetPosition() + if maxOffset < uint32(totalSize) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(totalSize)) + } + // Field #0 'GenesisTime' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "GenesisTime") + } else { + t.GenesisTime = val + } + // Field #1 'GenesisValidatorsRoot' (static) + if _, err = dec.DecodeBytes(t.GenesisValidatorsRoot[:32]); err != nil { + return err + } + // Field #2 'Slot' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "Slot") + } else { + t.Slot = phase0.Slot(val) + } + // Field #3 'Fork' (static) + if t.Fork == nil { + t.Fork = new(phase0.Fork) + } + if buf, err := dec.DecodeBytesBuf(16); err != nil { + return sszutils.ErrorWithPath(err, "Fork") + } else if err = t.Fork.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "Fork") + } + // Field #4 'LatestBlockHeader' (static) + if t.LatestBlockHeader == nil { + t.LatestBlockHeader = new(phase0.BeaconBlockHeader) + } + if buf, err := dec.DecodeBytesBuf(112); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") + } else if err = t.LatestBlockHeader.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") + } + { // Field #5 'BlockRoots' (static) + val1 := t.BlockRoots + val1 = sszutils.ExpandSlice(val1, int(expr0)) + startPos1 := dec.GetPosition() + for idx1 := range int(expr0) { + if _, err = dec.DecodeBytes(val1[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos1+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos1+int(32*(idx1+1))), "BlockRoots[%d]", idx1) + } + } + t.BlockRoots = val1 + } + { // Field #6 'StateRoots' (static) + val2 := t.StateRoots + val2 = sszutils.ExpandSlice(val2, int(expr0)) + startPos2 := dec.GetPosition() + for idx1 := range int(expr0) { + if _, err = dec.DecodeBytes(val2[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos2+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos2+int(32*(idx1+1))), "StateRoots[%d]", idx1) + } + } + t.StateRoots = val2 + } + // Field #7 'HistoricalRoots' (offset) + offset7, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "HistoricalRoots") + } + if offset7 != uint32(totalSize) { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset7, totalSize), "HistoricalRoots") + } + // Field #8 'ETH1Data' (static) + if t.ETH1Data == nil { + t.ETH1Data = new(phase0.ETH1Data) + } + if buf, err := dec.DecodeBytesBuf(72); err != nil { + return sszutils.ErrorWithPath(err, "ETH1Data") + } else if err = t.ETH1Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "ETH1Data") + } + // Field #9 'ETH1DataVotes' (offset) + offset9, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "ETH1DataVotes") + } + if offset9 < offset7 || offset9 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset9, offset7, maxOffset), "ETH1DataVotes") + } + // Field #10 'ETH1DepositIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "ETH1DepositIndex") + } else { + t.ETH1DepositIndex = val + } + // Field #11 'Validators' (offset) + offset11, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Validators") + } + if offset11 < offset9 || offset11 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset11, offset9, maxOffset), "Validators") + } + // Field #12 'Balances' (offset) + offset12, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Balances") + } + if offset12 < offset11 || offset12 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset12, offset11, maxOffset), "Balances") + } + { // Field #13 'RANDAOMixes' (static) + val3 := t.RANDAOMixes + val3 = sszutils.ExpandSlice(val3, int(expr1)) + startPos3 := dec.GetPosition() + for idx1 := range int(expr1) { + if _, err = dec.DecodeBytes(val3[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos3+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos3+int(32*(idx1+1))), "RANDAOMixes[%d]", idx1) + } + } + t.RANDAOMixes = val3 + } + { // Field #14 'Slashings' (static) + val4 := t.Slashings + val4 = sszutils.ExpandSlice(val4, int(expr2)) + if err = sszutils.DecodeUint64Slice(dec, val4[:int(expr2)]); err != nil { + return sszutils.ErrorWithPath(err, "Slashings") + } + t.Slashings = val4 + } + // Field #15 'PreviousEpochParticipation' (offset) + offset15, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "PreviousEpochParticipation") + } + if offset15 < offset12 || offset15 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset15, offset12, maxOffset), "PreviousEpochParticipation") + } + // Field #16 'CurrentEpochParticipation' (offset) + offset16, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "CurrentEpochParticipation") + } + if offset16 < offset15 || offset16 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset16, offset15, maxOffset), "CurrentEpochParticipation") + } + // Field #17 'JustificationBits' (static) + t.JustificationBits = sszutils.ExpandSlice(t.JustificationBits, 1) + if _, err = dec.DecodeBytes(t.JustificationBits[:1]); err != nil { + return err + } + // Field #18 'PreviousJustifiedCheckpoint' (static) + if t.PreviousJustifiedCheckpoint == nil { + t.PreviousJustifiedCheckpoint = new(phase0.Checkpoint) + } + if buf, err := dec.DecodeBytesBuf(40); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } else if err = t.PreviousJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } + // Field #19 'CurrentJustifiedCheckpoint' (static) + if t.CurrentJustifiedCheckpoint == nil { + t.CurrentJustifiedCheckpoint = new(phase0.Checkpoint) + } + if buf, err := dec.DecodeBytesBuf(40); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } else if err = t.CurrentJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } + // Field #20 'FinalizedCheckpoint' (static) + if t.FinalizedCheckpoint == nil { + t.FinalizedCheckpoint = new(phase0.Checkpoint) + } + if buf, err := dec.DecodeBytesBuf(40); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") + } else if err = t.FinalizedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") + } + // Field #21 'InactivityScores' (offset) + offset21, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "InactivityScores") + } + if offset21 < offset16 || offset21 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset21, offset16, maxOffset), "InactivityScores") + } + { // Field #22 'CurrentSyncCommittee' (static) + val5 := t.CurrentSyncCommittee + if val5 == nil { + val5 = new(altair.SyncCommittee) + } + totalSize := size5+48 + maxOffset := uint32(dec.GetLength()) + if maxOffset < uint32(totalSize) { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(totalSize)), "CurrentSyncCommittee") + } + { // Field #0 'Pubkeys' (static) + val6 := val5.Pubkeys + val6 = sszutils.ExpandSlice(val6, int(expr3)) + startPos4 := dec.GetPosition() + for idx1 := range int(expr3) { + if _, err = dec.DecodeBytes(val6[idx1][:48]); err != nil { + return err + } + if dec.GetPosition() != startPos4+int(48*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos4+int(48*(idx1+1))), "CurrentSyncCommittee.Pubkeys[%d]", idx1) + } + } + val5.Pubkeys = val6 + } + // Field #1 'AggregatePubkey' (static) + if _, err = dec.DecodeBytes(val5.AggregatePubkey[:48]); err != nil { + return err + } + t.CurrentSyncCommittee = val5 + } + { // Field #23 'NextSyncCommittee' (static) + val7 := t.NextSyncCommittee + if val7 == nil { + val7 = new(altair.SyncCommittee) + } + totalSize := size5+48 + maxOffset := uint32(dec.GetLength()) + if maxOffset < uint32(totalSize) { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(totalSize)), "NextSyncCommittee") + } + { // Field #0 'Pubkeys' (static) + val8 := val7.Pubkeys + val8 = sszutils.ExpandSlice(val8, int(expr3)) + startPos5 := dec.GetPosition() + for idx1 := range int(expr3) { + if _, err = dec.DecodeBytes(val8[idx1][:48]); err != nil { + return err + } + if dec.GetPosition() != startPos5+int(48*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos5+int(48*(idx1+1))), "NextSyncCommittee.Pubkeys[%d]", idx1) + } + } + val7.Pubkeys = val8 + } + // Field #1 'AggregatePubkey' (static) + if _, err = dec.DecodeBytes(val7.AggregatePubkey[:48]); err != nil { + return err + } + t.NextSyncCommittee = val7 + } + // Field #24 'LatestExecutionPayloadHeader' (offset) + offset24, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "LatestExecutionPayloadHeader") + } + if offset24 < offset21 || offset24 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset24, offset21, maxOffset), "LatestExecutionPayloadHeader") + } + // Field #25 'NextWithdrawalIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "NextWithdrawalIndex") + } else { + t.NextWithdrawalIndex = WithdrawalIndex(val) + } + // Field #26 'NextWithdrawalValidatorIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "NextWithdrawalValidatorIndex") + } else { + t.NextWithdrawalValidatorIndex = phase0.ValidatorIndex(val) + } + // Field #27 'HistoricalSummaries' (offset) + offset27, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "HistoricalSummaries") + } + if offset27 < offset24 || offset27 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset27, offset24, maxOffset), "HistoricalSummaries") + } + { // Field #7 'HistoricalRoots' (dynamic) + if dec.GetPosition() != startPos0+int(offset7) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset7)), "HistoricalRoots") + } + dec.PushLimit(int(offset9 - offset7)) + val9 := t.HistoricalRoots + sszLen := dec.GetLength() + itemCount := sszLen / 32 + if sszLen%32 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 32), "HistoricalRoots") + } + if itemCount > int(expr4) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr4)), "HistoricalRoots") + } + val9 = sszutils.ExpandSlice(val9, itemCount) + startPos6 := dec.GetPosition() + for idx1 := range itemCount { + if _, err = dec.DecodeBytes(val9[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos6+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos6+int(32*(idx1+1))), "HistoricalRoots[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "HistoricalRoots") + } + t.HistoricalRoots = val9 + } + { // Field #9 'ETH1DataVotes' (dynamic) + if dec.GetPosition() != startPos0+int(offset9) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset9)), "ETH1DataVotes") + } + dec.PushLimit(int(offset11 - offset9)) + val10 := t.ETH1DataVotes + sszLen := dec.GetLength() + itemCount := sszLen / 72 + if sszLen%72 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 72), "ETH1DataVotes") + } + if itemCount > int(expr5) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr5)), "ETH1DataVotes") + } + val10 = sszutils.ExpandSlice(val10, itemCount) + startPos7 := dec.GetPosition() + for idx1 := range itemCount { + if val10[idx1] == nil { + val10[idx1] = new(phase0.ETH1Data) + } + if buf, err := dec.DecodeBytesBuf(72); err != nil { + return sszutils.ErrorWithPathf(err, "ETH1DataVotes[%d]", idx1) + } else if err = val10[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "ETH1DataVotes[%d]", idx1) + } + if dec.GetPosition() != startPos7+int(72*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos7+int(72*(idx1+1))), "ETH1DataVotes[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "ETH1DataVotes") + } + t.ETH1DataVotes = val10 + } + { // Field #11 'Validators' (dynamic) + if dec.GetPosition() != startPos0+int(offset11) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset11)), "Validators") + } + dec.PushLimit(int(offset12 - offset11)) + val11 := t.Validators + sszLen := dec.GetLength() + itemCount := sszLen / 121 + if sszLen%121 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 121), "Validators") + } + if itemCount > int(expr6) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "Validators") + } + val11 = sszutils.ExpandSlice(val11, itemCount) + startPos8 := dec.GetPosition() + for idx1 := range itemCount { + if val11[idx1] == nil { + val11[idx1] = new(phase0.Validator) + } + if buf, err := dec.DecodeBytesBuf(121); err != nil { + return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } else if err = val11[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } + if dec.GetPosition() != startPos8+int(121*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos8+int(121*(idx1+1))), "Validators[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Validators") + } + t.Validators = val11 + } + { // Field #12 'Balances' (dynamic) + if dec.GetPosition() != startPos0+int(offset12) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset12)), "Balances") + } + dec.PushLimit(int(offset15 - offset12)) + val12 := t.Balances + sszLen := dec.GetLength() + itemCount := sszLen / 8 + if sszLen%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 8), "Balances") + } + if itemCount > int(expr6) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "Balances") + } + val12 = sszutils.ExpandSlice(val12, itemCount) + if err = sszutils.DecodeUint64Slice(dec, val12); err != nil { + return sszutils.ErrorWithPath(err, "Balances") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Balances") + } + t.Balances = val12 + } + { // Field #15 'PreviousEpochParticipation' (dynamic) + if dec.GetPosition() != startPos0+int(offset15) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset15)), "PreviousEpochParticipation") + } + dec.PushLimit(int(offset16 - offset15)) + val13 := t.PreviousEpochParticipation + itemCount := dec.GetLength() + if itemCount > int(expr6) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "PreviousEpochParticipation") + } + val13 = sszutils.ExpandSlice(val13, itemCount) + startPos9 := dec.GetPosition() + for idx1 := range itemCount { + if val, err := dec.DecodeUint8(); err != nil { + return sszutils.ErrorWithPathf(err, "PreviousEpochParticipation[%d]", idx1) + } else { + val13[idx1] = altair.ParticipationFlags(val) + } + if dec.GetPosition() != startPos9+int(1*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos9+int(1*(idx1+1))), "PreviousEpochParticipation[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "PreviousEpochParticipation") + } + t.PreviousEpochParticipation = val13 + } + { // Field #16 'CurrentEpochParticipation' (dynamic) + if dec.GetPosition() != startPos0+int(offset16) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset16)), "CurrentEpochParticipation") + } + dec.PushLimit(int(offset21 - offset16)) + val14 := t.CurrentEpochParticipation + itemCount := dec.GetLength() + if itemCount > int(expr6) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "CurrentEpochParticipation") + } + val14 = sszutils.ExpandSlice(val14, itemCount) + startPos10 := dec.GetPosition() + for idx1 := range itemCount { + if val, err := dec.DecodeUint8(); err != nil { + return sszutils.ErrorWithPathf(err, "CurrentEpochParticipation[%d]", idx1) + } else { + val14[idx1] = altair.ParticipationFlags(val) + } + if dec.GetPosition() != startPos10+int(1*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos10+int(1*(idx1+1))), "CurrentEpochParticipation[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "CurrentEpochParticipation") + } + t.CurrentEpochParticipation = val14 + } + { // Field #21 'InactivityScores' (dynamic) + if dec.GetPosition() != startPos0+int(offset21) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset21)), "InactivityScores") + } + dec.PushLimit(int(offset24 - offset21)) + val15 := t.InactivityScores + sszLen := dec.GetLength() + itemCount := sszLen / 8 + if sszLen%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 8), "InactivityScores") + } + if itemCount > int(expr6) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "InactivityScores") + } + val15 = sszutils.ExpandSlice(val15, itemCount) + if err = sszutils.DecodeUint64Slice(dec, val15); err != nil { + return sszutils.ErrorWithPath(err, "InactivityScores") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "InactivityScores") + } + t.InactivityScores = val15 + } + { // Field #24 'LatestExecutionPayloadHeader' (dynamic) + if dec.GetPosition() != startPos0+int(offset24) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset24)), "LatestExecutionPayloadHeader") + } + dec.PushLimit(int(offset27 - offset24)) + val16 := t.LatestExecutionPayloadHeader + if val16 == nil { + val16 = new(ExecutionPayloadHeader) + } + if buf, err := dec.DecodeBytesBuf(dec.GetLength()); err != nil { + return sszutils.ErrorWithPath(err, "LatestExecutionPayloadHeader") + } else if err = val16.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "LatestExecutionPayloadHeader") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "LatestExecutionPayloadHeader") + } + t.LatestExecutionPayloadHeader = val16 + } + { // Field #27 'HistoricalSummaries' (dynamic) + if dec.GetPosition() != startPos0+int(offset27) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset27)), "HistoricalSummaries") + } + dec.PushLimit(int(maxOffset - offset27)) + val17 := t.HistoricalSummaries + sszLen := dec.GetLength() + itemCount := sszLen / 64 + if sszLen%64 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 64), "HistoricalSummaries") + } + if itemCount > int(expr4) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr4)), "HistoricalSummaries") + } + val17 = sszutils.ExpandSlice(val17, itemCount) + startPos11 := dec.GetPosition() + for idx1 := range itemCount { + if val17[idx1] == nil { + val17[idx1] = new(HistoricalSummary) + } + if buf, err := dec.DecodeBytesBuf(64); err != nil { + return sszutils.ErrorWithPathf(err, "HistoricalSummaries[%d]", idx1) + } else if err = val17[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "HistoricalSummaries[%d]", idx1) + } + if dec.GetPosition() != startPos11+int(64*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos11+int(64*(idx1+1))), "HistoricalSummaries[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "HistoricalSummaries") + } + t.HistoricalSummaries = val17 + } + return nil +} + // SizeSSZ returns the SSZ encoded size of the *BeaconState. func (t *BeaconState) SizeSSZ() (size int) { if t == nil { diff --git a/spec/capella/executionpayload_ssz.go b/spec/capella/executionpayload_ssz.go index c7519bdc..adf2babf 100644 --- a/spec/capella/executionpayload_ssz.go +++ b/spec/capella/executionpayload_ssz.go @@ -1,5 +1,5 @@ // Code generated by dynamic-ssz. DO NOT EDIT. -// Hash: e971353850c7a8147795247fa9010449b1c28c13f1552d66b848523554f961b3 +// Hash: 75b099aed7c4506cb32c944b6955298b86b95c40a86692773fecbc20e3414d67 // Version: v1.3.1 (https://github.com/pk910/dynamic-ssz) package capella @@ -57,7 +57,7 @@ func (t *ExecutionPayload) MarshalSSZTo(buf []byte) (dst []byte, err error) { } // Offset Field #10 'ExtraData' dst = append(dst, 0, 0, 0, 0) - { // Static Field #11 'BaseFeePerGas' + { // Static Field #11 'BaseFeePerGasLE' dst = append(dst, t.BaseFeePerGasLE[:32]...) } { // Static Field #12 'BlockHash' @@ -163,7 +163,7 @@ func (t *ExecutionPayload) UnmarshalSSZ(buf []byte) (err error) { if offset10 != 512 { return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset10, 512), "ExtraData:o") } - { // Field #11 'BaseFeePerGas' (static) + { // Field #11 'BaseFeePerGasLE' (static) buf := buf[440:472] copy(t.BaseFeePerGasLE[:], buf) } @@ -270,7 +270,7 @@ func (t *ExecutionPayload) SizeSSZ() (size int) { // Field #8 'GasUsed' static (8 bytes) // Field #9 'Timestamp' static (8 bytes) // Field #10 'ExtraData' offset (4 bytes) - // Field #11 'BaseFeePerGas' static (32 bytes) + // Field #11 'BaseFeePerGasLE' static (32 bytes) // Field #12 'BlockHash' static (32 bytes) // Field #13 'Transactions' offset (4 bytes) // Field #14 'Withdrawals' offset (4 bytes) @@ -349,7 +349,7 @@ func (t *ExecutionPayload) HashTreeRootWith(hh sszutils.HashWalker) error { hh.AppendBytes32(t.ExtraData[:]) hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(32, vlen, 1)) } - { // Field #11 'BaseFeePerGas' + { // Field #11 'BaseFeePerGasLE' hh.PutBytes(t.BaseFeePerGasLE[:32]) } { // Field #12 'BlockHash' diff --git a/spec/capella/executionpayloadheader_ssz.go b/spec/capella/executionpayloadheader_ssz.go index 49835b44..1429d9a8 100644 --- a/spec/capella/executionpayloadheader_ssz.go +++ b/spec/capella/executionpayloadheader_ssz.go @@ -1,5 +1,5 @@ // Code generated by dynamic-ssz. DO NOT EDIT. -// Hash: 56086eb70ef7ef503e14152499bf7a6012e881b899e3a13ad3bf54d5ece71e0d +// Hash: 98ffeeff33c42477fc9c7ae616171119b9d8bad88900a875c6f914cec7149095 // Version: v1.3.1 (https://github.com/pk910/dynamic-ssz) package capella @@ -57,7 +57,7 @@ func (t *ExecutionPayloadHeader) MarshalSSZTo(buf []byte) (dst []byte, err error } // Offset Field #10 'ExtraData' dst = append(dst, 0, 0, 0, 0) - { // Static Field #11 'BaseFeePerGas' + { // Static Field #11 'BaseFeePerGasLE' dst = append(dst, t.BaseFeePerGasLE[:32]...) } { // Static Field #12 'BlockHash' @@ -131,7 +131,7 @@ func (t *ExecutionPayloadHeader) UnmarshalSSZ(buf []byte) (err error) { if offset10 != 568 { return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset10, 568), "ExtraData:o") } - { // Field #11 'BaseFeePerGas' (static) + { // Field #11 'BaseFeePerGasLE' (static) buf := buf[440:472] copy(t.BaseFeePerGasLE[:], buf) } @@ -174,7 +174,7 @@ func (t *ExecutionPayloadHeader) SizeSSZ() (size int) { // Field #8 'GasUsed' static (8 bytes) // Field #9 'Timestamp' static (8 bytes) // Field #10 'ExtraData' offset (4 bytes) - // Field #11 'BaseFeePerGas' static (32 bytes) + // Field #11 'BaseFeePerGasLE' static (32 bytes) // Field #12 'BlockHash' static (32 bytes) // Field #13 'TransactionsRoot' static (32 bytes) // Field #14 'WithdrawalsRoot' static (32 bytes) @@ -242,7 +242,7 @@ func (t *ExecutionPayloadHeader) HashTreeRootWith(hh sszutils.HashWalker) error hh.AppendBytes32(t.ExtraData[:]) hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(32, vlen, 1)) } - { // Field #11 'BaseFeePerGas' + { // Field #11 'BaseFeePerGasLE' hh.PutBytes(t.BaseFeePerGasLE[:32]) } { // Field #12 'BlockHash' diff --git a/spec/capella/generate.yaml b/spec/capella/generate.yaml index 3908306f..9dc1688e 100644 --- a/spec/capella/generate.yaml +++ b/spec/capella/generate.yaml @@ -9,6 +9,7 @@ types: output: beaconblock_ssz.go - name: BeaconState output: beaconstate_ssz.go + with-streaming: true - name: BLSToExecutionChange output: blstoexecutionchange_ssz.go - name: ExecutionPayloadHeader diff --git a/spec/capella/signedbeaconblock_ssz.go b/spec/capella/signedbeaconblock_ssz.go index 204f90d5..1e899838 100644 --- a/spec/capella/signedbeaconblock_ssz.go +++ b/spec/capella/signedbeaconblock_ssz.go @@ -1,5 +1,5 @@ // Code generated by dynamic-ssz. DO NOT EDIT. -// Hash: ff0e79adb03fb66620844f8e4ed4037d96218cb53b0d5301906b15edcc33653a +// Hash: 5e4819ac7d706c663856359e1497b6c623c1fbf05eb1d4bd2211d0f00825b2a9 // Version: v1.3.1 (https://github.com/pk910/dynamic-ssz) package capella diff --git a/spec/deneb/beaconstate_ssz.go b/spec/deneb/beaconstate_ssz.go index e53cf2e0..596c5c5d 100644 --- a/spec/deneb/beaconstate_ssz.go +++ b/spec/deneb/beaconstate_ssz.go @@ -1,5 +1,5 @@ // Code generated by dynamic-ssz. DO NOT EDIT. -// Hash: 018bc2d81eda4937b696d9126ba849860e10099559080ac1612d372825535861 +// Hash: 8a22f0570f997086bc89eff6fac6312c1a5aabd474311d01d65bbeee7bac831e // Version: v1.3.1 (https://github.com/pk910/dynamic-ssz) package deneb @@ -309,6 +309,507 @@ func (t *BeaconState) MarshalSSZTo(buf []byte) (dst []byte, err error) { return dst, nil } +// MarshalSSZEncoder marshals the *BeaconState to the given SSZ encoder using dynamic specifications. +func (t *BeaconState) MarshalSSZEncoder(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + type encoderCtx struct { + ds sszutils.DynamicSpecs + exprs [7]uint64 + sizeFn1 func(ctx *encoderCtx, t []phase0.Root) (size int) + sizeFn2 func(ctx *encoderCtx, t []*phase0.ETH1Data) (size int) + sizeFn3 func(ctx *encoderCtx, t []*phase0.Validator) (size int) + sizeFn4 func(ctx *encoderCtx, t []phase0.Gwei) (size int) + sizeFn5 func(ctx *encoderCtx, t []altair.ParticipationFlags) (size int) + sizeFn6 func(ctx *encoderCtx, t []altair.ParticipationFlags) (size int) + sizeFn7 func(ctx *encoderCtx, t []uint64) (size int) + sizeFn8 func(ctx *encoderCtx, t *ExecutionPayloadHeader) (size int) + sizeFn9 func(ctx *encoderCtx, t []*capella.HistoricalSummary) (size int) + } + ctx := &encoderCtx{ds: ds} + canSeek := enc.Seekable() + ctx.exprs[0], err = sszutils.ResolveSpecValueWithDefault(ds, "SLOTS_PER_HISTORICAL_ROOT", 8192) + if err != nil { + return err + } + ctx.exprs[1], err = sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_HISTORICAL_VECTOR", 65536) + if err != nil { + return err + } + ctx.exprs[2], err = sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_SLASHINGS_VECTOR", 8192) + if err != nil { + return err + } + ctx.exprs[3], err = sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE", 512) + if err != nil { + return err + } + ctx.exprs[4], err = sszutils.ResolveSpecValueWithDefault(ds, "HISTORICAL_ROOTS_LIMIT", 16777216) + if err != nil { + return err + } + ctx.exprs[5], err = sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_ETH1_VOTING_PERIOD*SLOTS_PER_EPOCH", 2048) + if err != nil { + return err + } + ctx.exprs[6], err = sszutils.ResolveSpecValueWithDefault(ds, "VALIDATOR_REGISTRY_LIMIT", 1099511627776) + if err != nil { + return err + } + // size for []phase0.Root + ctx.sizeFn1 = func(ctx *encoderCtx, t []phase0.Root) (size int) { + size += len(t) * 32 + return size + } + // size for []*phase0.ETH1Data + ctx.sizeFn2 = func(ctx *encoderCtx, t []*phase0.ETH1Data) (size int) { + size += len(t) * 72 + return size + } + // size for []*phase0.Validator + ctx.sizeFn3 = func(ctx *encoderCtx, t []*phase0.Validator) (size int) { + size += len(t) * 121 + return size + } + // size for []phase0.Gwei + ctx.sizeFn4 = func(ctx *encoderCtx, t []phase0.Gwei) (size int) { + size += len(t) * 8 + return size + } + // size for []altair.ParticipationFlags + ctx.sizeFn5 = func(ctx *encoderCtx, t []altair.ParticipationFlags) (size int) { + size += len(t) + return size + } + // size for []altair.ParticipationFlags + ctx.sizeFn6 = func(ctx *encoderCtx, t []altair.ParticipationFlags) (size int) { + size += len(t) + return size + } + // size for []uint64 + ctx.sizeFn7 = func(ctx *encoderCtx, t []uint64) (size int) { + size += len(t) * 8 + return size + } + // size for *ExecutionPayloadHeader + ctx.sizeFn8 = func(ctx *encoderCtx, t *ExecutionPayloadHeader) (size int) { + size += t.SizeSSZ() + return size + } + // size for []*capella.HistoricalSummary + ctx.sizeFn9 = func(ctx *encoderCtx, t []*capella.HistoricalSummary) (size int) { + size += len(t) * 64 + return size + } + size1 := 32 * int(ctx.exprs[0]) + size2 := 32 * int(ctx.exprs[1]) + size3 := 8 * int(ctx.exprs[2]) + size5 := 48 * int(ctx.exprs[3]) + size4 := size5 + 48 // size expression for '*SyncCommittee' + if t == nil { + t = new(BeaconState) + } + dstlen := enc.GetPosition() + dynoff := uint32(size1 + size1 + size2 + size3 + size4 + size4 + 429) + { // Field #0 'GenesisTime' + enc.EncodeUint64(t.GenesisTime) + } + { // Field #1 'GenesisValidatorsRoot' + enc.EncodeBytes(t.GenesisValidatorsRoot[:32]) + } + { // Field #2 'Slot' + enc.EncodeUint64(uint64(t.Slot)) + } + { // Field #3 'Fork' + t := t.Fork + if t == nil { + t = new(phase0.Fork) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "Fork") + } else { + enc.SetBuffer(buf) + } + } + { // Field #4 'LatestBlockHeader' + t := t.LatestBlockHeader + if t == nil { + t = new(phase0.BeaconBlockHeader) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") + } else { + enc.SetBuffer(buf) + } + } + { // Field #5 'BlockRoots' + t := t.BlockRoots + vlen := len(t) + if vlen > int(ctx.exprs[0]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[0])), "BlockRoots") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:32]) + } + if vlen < int(ctx.exprs[0]) { + enc.EncodeZeroPadding((int(ctx.exprs[0]) - vlen) * 32) + } + } + { // Field #6 'StateRoots' + t := t.StateRoots + vlen := len(t) + if vlen > int(ctx.exprs[0]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[0])), "StateRoots") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:32]) + } + if vlen < int(ctx.exprs[0]) { + enc.EncodeZeroPadding((int(ctx.exprs[0]) - vlen) * 32) + } + } + // Offset #7 'HistoricalRoots' + offset7 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn1(ctx, t.HistoricalRoots)) + } + { // Field #8 'ETH1Data' + t := t.ETH1Data + if t == nil { + t = new(phase0.ETH1Data) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "ETH1Data") + } else { + enc.SetBuffer(buf) + } + } + // Offset #9 'ETH1DataVotes' + offset9 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn2(ctx, t.ETH1DataVotes)) + } + { // Field #10 'ETH1DepositIndex' + enc.EncodeUint64(t.ETH1DepositIndex) + } + // Offset #11 'Validators' + offset11 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn3(ctx, t.Validators)) + } + // Offset #12 'Balances' + offset12 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn4(ctx, t.Balances)) + } + { // Field #13 'RANDAOMixes' + t := t.RANDAOMixes + vlen := len(t) + if vlen > int(ctx.exprs[1]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[1])), "RANDAOMixes") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:32]) + } + if vlen < int(ctx.exprs[1]) { + enc.EncodeZeroPadding((int(ctx.exprs[1]) - vlen) * 32) + } + } + { // Field #14 'Slashings' + t := t.Slashings + vlen := len(t) + if vlen > int(ctx.exprs[2]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[2])), "Slashings") + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + if vlen < int(ctx.exprs[2]) { + enc.EncodeZeroPadding((int(ctx.exprs[2]) - vlen) * 8) + } + } + // Offset #15 'PreviousEpochParticipation' + offset15 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn5(ctx, t.PreviousEpochParticipation)) + } + // Offset #16 'CurrentEpochParticipation' + offset16 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn6(ctx, t.CurrentEpochParticipation)) + } + { // Field #17 'JustificationBits' + vlen := len(t.JustificationBits) + if vlen > 1 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 1), "JustificationBits") + } + enc.EncodeBytes(t.JustificationBits[:vlen]) + if vlen < 1 { + enc.EncodeZeroPadding((1 - vlen) * 1) + } + } + { // Field #18 'PreviousJustifiedCheckpoint' + t := t.PreviousJustifiedCheckpoint + if t == nil { + t = new(phase0.Checkpoint) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } else { + enc.SetBuffer(buf) + } + } + { // Field #19 'CurrentJustifiedCheckpoint' + t := t.CurrentJustifiedCheckpoint + if t == nil { + t = new(phase0.Checkpoint) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } else { + enc.SetBuffer(buf) + } + } + { // Field #20 'FinalizedCheckpoint' + t := t.FinalizedCheckpoint + if t == nil { + t = new(phase0.Checkpoint) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") + } else { + enc.SetBuffer(buf) + } + } + // Offset #21 'InactivityScores' + offset21 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn7(ctx, t.InactivityScores)) + } + { // Field #22 'CurrentSyncCommittee' + t := t.CurrentSyncCommittee + if t == nil { + t = new(altair.SyncCommittee) + } + { // Field #0 'Pubkeys' + t := t.Pubkeys + vlen := len(t) + if vlen > int(ctx.exprs[3]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[3])), "CurrentSyncCommittee.Pubkeys") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:48]) + } + if vlen < int(ctx.exprs[3]) { + enc.EncodeZeroPadding((int(ctx.exprs[3]) - vlen) * 48) + } + } + { // Field #1 'AggregatePubkey' + enc.EncodeBytes(t.AggregatePubkey[:48]) + } + } + { // Field #23 'NextSyncCommittee' + t := t.NextSyncCommittee + if t == nil { + t = new(altair.SyncCommittee) + } + { // Field #0 'Pubkeys' + t := t.Pubkeys + vlen := len(t) + if vlen > int(ctx.exprs[3]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[3])), "NextSyncCommittee.Pubkeys") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:48]) + } + if vlen < int(ctx.exprs[3]) { + enc.EncodeZeroPadding((int(ctx.exprs[3]) - vlen) * 48) + } + } + { // Field #1 'AggregatePubkey' + enc.EncodeBytes(t.AggregatePubkey[:48]) + } + } + // Offset #24 'LatestExecutionPayloadHeader' + offset24 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn8(ctx, t.LatestExecutionPayloadHeader)) + } + { // Field #25 'NextWithdrawalIndex' + enc.EncodeUint64(uint64(t.NextWithdrawalIndex)) + } + { // Field #26 'NextWithdrawalValidatorIndex' + enc.EncodeUint64(uint64(t.NextWithdrawalValidatorIndex)) + } + // Offset #27 'HistoricalSummaries' + offset27 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn9(ctx, t.HistoricalSummaries)) + } + { // Dynamic Field #7 'HistoricalRoots' + if canSeek { + enc.EncodeOffsetAt(offset7, uint32(enc.GetPosition()-dstlen)) + } + t := t.HistoricalRoots + vlen := len(t) + if vlen > int(ctx.exprs[4]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[4])), "HistoricalRoots") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:32]) + } + } + { // Dynamic Field #9 'ETH1DataVotes' + if canSeek { + enc.EncodeOffsetAt(offset9, uint32(enc.GetPosition()-dstlen)) + } + t := t.ETH1DataVotes + vlen := len(t) + if vlen > int(ctx.exprs[5]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[5])), "ETH1DataVotes") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(phase0.ETH1Data) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "ETH1DataVotes[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #11 'Validators' + if canSeek { + enc.EncodeOffsetAt(offset11, uint32(enc.GetPosition()-dstlen)) + } + t := t.Validators + vlen := len(t) + if vlen > int(ctx.exprs[6]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[6])), "Validators") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(phase0.Validator) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #12 'Balances' + if canSeek { + enc.EncodeOffsetAt(offset12, uint32(enc.GetPosition()-dstlen)) + } + t := t.Balances + vlen := len(t) + if vlen > int(ctx.exprs[6]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[6])), "Balances") + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + } + { // Dynamic Field #15 'PreviousEpochParticipation' + if canSeek { + enc.EncodeOffsetAt(offset15, uint32(enc.GetPosition()-dstlen)) + } + t := t.PreviousEpochParticipation + vlen := len(t) + if vlen > int(ctx.exprs[6]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[6])), "PreviousEpochParticipation") + } + for idx1 := range vlen { + enc.EncodeUint8(byte(t[idx1])) + } + } + { // Dynamic Field #16 'CurrentEpochParticipation' + if canSeek { + enc.EncodeOffsetAt(offset16, uint32(enc.GetPosition()-dstlen)) + } + t := t.CurrentEpochParticipation + vlen := len(t) + if vlen > int(ctx.exprs[6]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[6])), "CurrentEpochParticipation") + } + for idx1 := range vlen { + enc.EncodeUint8(byte(t[idx1])) + } + } + { // Dynamic Field #21 'InactivityScores' + if canSeek { + enc.EncodeOffsetAt(offset21, uint32(enc.GetPosition()-dstlen)) + } + t := t.InactivityScores + vlen := len(t) + if vlen > int(ctx.exprs[6]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[6])), "InactivityScores") + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + } + { // Dynamic Field #24 'LatestExecutionPayloadHeader' + if canSeek { + enc.EncodeOffsetAt(offset24, uint32(enc.GetPosition()-dstlen)) + } + t := t.LatestExecutionPayloadHeader + if t == nil { + t = new(ExecutionPayloadHeader) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "LatestExecutionPayloadHeader") + } else { + enc.SetBuffer(buf) + } + } + { // Dynamic Field #27 'HistoricalSummaries' + if canSeek { + enc.EncodeOffsetAt(offset27, uint32(enc.GetPosition()-dstlen)) + } + t := t.HistoricalSummaries + vlen := len(t) + if vlen > int(ctx.exprs[4]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[4])), "HistoricalSummaries") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(capella.HistoricalSummary) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "HistoricalSummaries[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + return nil +} + // UnmarshalSSZ unmarshals the *BeaconState from SSZ-encoded bytes. func (t *BeaconState) UnmarshalSSZ(buf []byte) (err error) { buflen := len(buf) @@ -649,6 +1150,575 @@ func (t *BeaconState) UnmarshalSSZ(buf []byte) (err error) { return nil } +// UnmarshalSSZDecoder unmarshals the *BeaconState from the given SSZ decoder using dynamic specifications. +func (t *BeaconState) UnmarshalSSZDecoder(ds sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { + expr0, err := sszutils.ResolveSpecValueWithDefault(ds, "SLOTS_PER_HISTORICAL_ROOT", 8192) + if err != nil { + return err + } + expr1, err := sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_HISTORICAL_VECTOR", 65536) + if err != nil { + return err + } + expr2, err := sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_SLASHINGS_VECTOR", 8192) + if err != nil { + return err + } + expr3, err := sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE", 512) + if err != nil { + return err + } + expr4, err := sszutils.ResolveSpecValueWithDefault(ds, "HISTORICAL_ROOTS_LIMIT", 16777216) + if err != nil { + return err + } + expr5, err := sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_ETH1_VOTING_PERIOD*SLOTS_PER_EPOCH", 2048) + if err != nil { + return err + } + expr6, err := sszutils.ResolveSpecValueWithDefault(ds, "VALIDATOR_REGISTRY_LIMIT", 1099511627776) + if err != nil { + return err + } + size1 := 32 * int(expr0) + size2 := 32 * int(expr1) + size3 := 8 * int(expr2) + size5 := 48 * int(expr3) + size4 := size5 + 48 // size expression for '*SyncCommittee' + totalSize := size1+size1+size2+size3+size4+size4+429 + maxOffset := uint32(dec.GetLength()) + startPos0 := dec.GetPosition() + if maxOffset < uint32(totalSize) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(totalSize)) + } + // Field #0 'GenesisTime' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "GenesisTime") + } else { + t.GenesisTime = val + } + // Field #1 'GenesisValidatorsRoot' (static) + if _, err = dec.DecodeBytes(t.GenesisValidatorsRoot[:32]); err != nil { + return err + } + // Field #2 'Slot' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "Slot") + } else { + t.Slot = phase0.Slot(val) + } + // Field #3 'Fork' (static) + if t.Fork == nil { + t.Fork = new(phase0.Fork) + } + if buf, err := dec.DecodeBytesBuf(16); err != nil { + return sszutils.ErrorWithPath(err, "Fork") + } else if err = t.Fork.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "Fork") + } + // Field #4 'LatestBlockHeader' (static) + if t.LatestBlockHeader == nil { + t.LatestBlockHeader = new(phase0.BeaconBlockHeader) + } + if buf, err := dec.DecodeBytesBuf(112); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") + } else if err = t.LatestBlockHeader.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") + } + { // Field #5 'BlockRoots' (static) + val1 := t.BlockRoots + val1 = sszutils.ExpandSlice(val1, int(expr0)) + startPos1 := dec.GetPosition() + for idx1 := range int(expr0) { + if _, err = dec.DecodeBytes(val1[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos1+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos1+int(32*(idx1+1))), "BlockRoots[%d]", idx1) + } + } + t.BlockRoots = val1 + } + { // Field #6 'StateRoots' (static) + val2 := t.StateRoots + val2 = sszutils.ExpandSlice(val2, int(expr0)) + startPos2 := dec.GetPosition() + for idx1 := range int(expr0) { + if _, err = dec.DecodeBytes(val2[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos2+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos2+int(32*(idx1+1))), "StateRoots[%d]", idx1) + } + } + t.StateRoots = val2 + } + // Field #7 'HistoricalRoots' (offset) + offset7, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "HistoricalRoots") + } + if offset7 != uint32(totalSize) { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset7, totalSize), "HistoricalRoots") + } + // Field #8 'ETH1Data' (static) + if t.ETH1Data == nil { + t.ETH1Data = new(phase0.ETH1Data) + } + if buf, err := dec.DecodeBytesBuf(72); err != nil { + return sszutils.ErrorWithPath(err, "ETH1Data") + } else if err = t.ETH1Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "ETH1Data") + } + // Field #9 'ETH1DataVotes' (offset) + offset9, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "ETH1DataVotes") + } + if offset9 < offset7 || offset9 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset9, offset7, maxOffset), "ETH1DataVotes") + } + // Field #10 'ETH1DepositIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "ETH1DepositIndex") + } else { + t.ETH1DepositIndex = val + } + // Field #11 'Validators' (offset) + offset11, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Validators") + } + if offset11 < offset9 || offset11 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset11, offset9, maxOffset), "Validators") + } + // Field #12 'Balances' (offset) + offset12, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Balances") + } + if offset12 < offset11 || offset12 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset12, offset11, maxOffset), "Balances") + } + { // Field #13 'RANDAOMixes' (static) + val3 := t.RANDAOMixes + val3 = sszutils.ExpandSlice(val3, int(expr1)) + startPos3 := dec.GetPosition() + for idx1 := range int(expr1) { + if _, err = dec.DecodeBytes(val3[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos3+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos3+int(32*(idx1+1))), "RANDAOMixes[%d]", idx1) + } + } + t.RANDAOMixes = val3 + } + { // Field #14 'Slashings' (static) + val4 := t.Slashings + val4 = sszutils.ExpandSlice(val4, int(expr2)) + if err = sszutils.DecodeUint64Slice(dec, val4[:int(expr2)]); err != nil { + return sszutils.ErrorWithPath(err, "Slashings") + } + t.Slashings = val4 + } + // Field #15 'PreviousEpochParticipation' (offset) + offset15, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "PreviousEpochParticipation") + } + if offset15 < offset12 || offset15 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset15, offset12, maxOffset), "PreviousEpochParticipation") + } + // Field #16 'CurrentEpochParticipation' (offset) + offset16, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "CurrentEpochParticipation") + } + if offset16 < offset15 || offset16 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset16, offset15, maxOffset), "CurrentEpochParticipation") + } + // Field #17 'JustificationBits' (static) + t.JustificationBits = sszutils.ExpandSlice(t.JustificationBits, 1) + if _, err = dec.DecodeBytes(t.JustificationBits[:1]); err != nil { + return err + } + // Field #18 'PreviousJustifiedCheckpoint' (static) + if t.PreviousJustifiedCheckpoint == nil { + t.PreviousJustifiedCheckpoint = new(phase0.Checkpoint) + } + if buf, err := dec.DecodeBytesBuf(40); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } else if err = t.PreviousJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } + // Field #19 'CurrentJustifiedCheckpoint' (static) + if t.CurrentJustifiedCheckpoint == nil { + t.CurrentJustifiedCheckpoint = new(phase0.Checkpoint) + } + if buf, err := dec.DecodeBytesBuf(40); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } else if err = t.CurrentJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } + // Field #20 'FinalizedCheckpoint' (static) + if t.FinalizedCheckpoint == nil { + t.FinalizedCheckpoint = new(phase0.Checkpoint) + } + if buf, err := dec.DecodeBytesBuf(40); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") + } else if err = t.FinalizedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") + } + // Field #21 'InactivityScores' (offset) + offset21, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "InactivityScores") + } + if offset21 < offset16 || offset21 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset21, offset16, maxOffset), "InactivityScores") + } + { // Field #22 'CurrentSyncCommittee' (static) + val5 := t.CurrentSyncCommittee + if val5 == nil { + val5 = new(altair.SyncCommittee) + } + totalSize := size5+48 + maxOffset := uint32(dec.GetLength()) + if maxOffset < uint32(totalSize) { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(totalSize)), "CurrentSyncCommittee") + } + { // Field #0 'Pubkeys' (static) + val6 := val5.Pubkeys + val6 = sszutils.ExpandSlice(val6, int(expr3)) + startPos4 := dec.GetPosition() + for idx1 := range int(expr3) { + if _, err = dec.DecodeBytes(val6[idx1][:48]); err != nil { + return err + } + if dec.GetPosition() != startPos4+int(48*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos4+int(48*(idx1+1))), "CurrentSyncCommittee.Pubkeys[%d]", idx1) + } + } + val5.Pubkeys = val6 + } + // Field #1 'AggregatePubkey' (static) + if _, err = dec.DecodeBytes(val5.AggregatePubkey[:48]); err != nil { + return err + } + t.CurrentSyncCommittee = val5 + } + { // Field #23 'NextSyncCommittee' (static) + val7 := t.NextSyncCommittee + if val7 == nil { + val7 = new(altair.SyncCommittee) + } + totalSize := size5+48 + maxOffset := uint32(dec.GetLength()) + if maxOffset < uint32(totalSize) { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(totalSize)), "NextSyncCommittee") + } + { // Field #0 'Pubkeys' (static) + val8 := val7.Pubkeys + val8 = sszutils.ExpandSlice(val8, int(expr3)) + startPos5 := dec.GetPosition() + for idx1 := range int(expr3) { + if _, err = dec.DecodeBytes(val8[idx1][:48]); err != nil { + return err + } + if dec.GetPosition() != startPos5+int(48*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos5+int(48*(idx1+1))), "NextSyncCommittee.Pubkeys[%d]", idx1) + } + } + val7.Pubkeys = val8 + } + // Field #1 'AggregatePubkey' (static) + if _, err = dec.DecodeBytes(val7.AggregatePubkey[:48]); err != nil { + return err + } + t.NextSyncCommittee = val7 + } + // Field #24 'LatestExecutionPayloadHeader' (offset) + offset24, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "LatestExecutionPayloadHeader") + } + if offset24 < offset21 || offset24 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset24, offset21, maxOffset), "LatestExecutionPayloadHeader") + } + // Field #25 'NextWithdrawalIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "NextWithdrawalIndex") + } else { + t.NextWithdrawalIndex = capella.WithdrawalIndex(val) + } + // Field #26 'NextWithdrawalValidatorIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "NextWithdrawalValidatorIndex") + } else { + t.NextWithdrawalValidatorIndex = phase0.ValidatorIndex(val) + } + // Field #27 'HistoricalSummaries' (offset) + offset27, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "HistoricalSummaries") + } + if offset27 < offset24 || offset27 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset27, offset24, maxOffset), "HistoricalSummaries") + } + { // Field #7 'HistoricalRoots' (dynamic) + if dec.GetPosition() != startPos0+int(offset7) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset7)), "HistoricalRoots") + } + dec.PushLimit(int(offset9 - offset7)) + val9 := t.HistoricalRoots + sszLen := dec.GetLength() + itemCount := sszLen / 32 + if sszLen%32 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 32), "HistoricalRoots") + } + if itemCount > int(expr4) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr4)), "HistoricalRoots") + } + val9 = sszutils.ExpandSlice(val9, itemCount) + startPos6 := dec.GetPosition() + for idx1 := range itemCount { + if _, err = dec.DecodeBytes(val9[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos6+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos6+int(32*(idx1+1))), "HistoricalRoots[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "HistoricalRoots") + } + t.HistoricalRoots = val9 + } + { // Field #9 'ETH1DataVotes' (dynamic) + if dec.GetPosition() != startPos0+int(offset9) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset9)), "ETH1DataVotes") + } + dec.PushLimit(int(offset11 - offset9)) + val10 := t.ETH1DataVotes + sszLen := dec.GetLength() + itemCount := sszLen / 72 + if sszLen%72 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 72), "ETH1DataVotes") + } + if itemCount > int(expr5) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr5)), "ETH1DataVotes") + } + val10 = sszutils.ExpandSlice(val10, itemCount) + startPos7 := dec.GetPosition() + for idx1 := range itemCount { + if val10[idx1] == nil { + val10[idx1] = new(phase0.ETH1Data) + } + if buf, err := dec.DecodeBytesBuf(72); err != nil { + return sszutils.ErrorWithPathf(err, "ETH1DataVotes[%d]", idx1) + } else if err = val10[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "ETH1DataVotes[%d]", idx1) + } + if dec.GetPosition() != startPos7+int(72*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos7+int(72*(idx1+1))), "ETH1DataVotes[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "ETH1DataVotes") + } + t.ETH1DataVotes = val10 + } + { // Field #11 'Validators' (dynamic) + if dec.GetPosition() != startPos0+int(offset11) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset11)), "Validators") + } + dec.PushLimit(int(offset12 - offset11)) + val11 := t.Validators + sszLen := dec.GetLength() + itemCount := sszLen / 121 + if sszLen%121 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 121), "Validators") + } + if itemCount > int(expr6) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "Validators") + } + val11 = sszutils.ExpandSlice(val11, itemCount) + startPos8 := dec.GetPosition() + for idx1 := range itemCount { + if val11[idx1] == nil { + val11[idx1] = new(phase0.Validator) + } + if buf, err := dec.DecodeBytesBuf(121); err != nil { + return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } else if err = val11[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } + if dec.GetPosition() != startPos8+int(121*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos8+int(121*(idx1+1))), "Validators[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Validators") + } + t.Validators = val11 + } + { // Field #12 'Balances' (dynamic) + if dec.GetPosition() != startPos0+int(offset12) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset12)), "Balances") + } + dec.PushLimit(int(offset15 - offset12)) + val12 := t.Balances + sszLen := dec.GetLength() + itemCount := sszLen / 8 + if sszLen%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 8), "Balances") + } + if itemCount > int(expr6) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "Balances") + } + val12 = sszutils.ExpandSlice(val12, itemCount) + if err = sszutils.DecodeUint64Slice(dec, val12); err != nil { + return sszutils.ErrorWithPath(err, "Balances") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Balances") + } + t.Balances = val12 + } + { // Field #15 'PreviousEpochParticipation' (dynamic) + if dec.GetPosition() != startPos0+int(offset15) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset15)), "PreviousEpochParticipation") + } + dec.PushLimit(int(offset16 - offset15)) + val13 := t.PreviousEpochParticipation + itemCount := dec.GetLength() + if itemCount > int(expr6) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "PreviousEpochParticipation") + } + val13 = sszutils.ExpandSlice(val13, itemCount) + startPos9 := dec.GetPosition() + for idx1 := range itemCount { + if val, err := dec.DecodeUint8(); err != nil { + return sszutils.ErrorWithPathf(err, "PreviousEpochParticipation[%d]", idx1) + } else { + val13[idx1] = altair.ParticipationFlags(val) + } + if dec.GetPosition() != startPos9+int(1*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos9+int(1*(idx1+1))), "PreviousEpochParticipation[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "PreviousEpochParticipation") + } + t.PreviousEpochParticipation = val13 + } + { // Field #16 'CurrentEpochParticipation' (dynamic) + if dec.GetPosition() != startPos0+int(offset16) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset16)), "CurrentEpochParticipation") + } + dec.PushLimit(int(offset21 - offset16)) + val14 := t.CurrentEpochParticipation + itemCount := dec.GetLength() + if itemCount > int(expr6) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "CurrentEpochParticipation") + } + val14 = sszutils.ExpandSlice(val14, itemCount) + startPos10 := dec.GetPosition() + for idx1 := range itemCount { + if val, err := dec.DecodeUint8(); err != nil { + return sszutils.ErrorWithPathf(err, "CurrentEpochParticipation[%d]", idx1) + } else { + val14[idx1] = altair.ParticipationFlags(val) + } + if dec.GetPosition() != startPos10+int(1*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos10+int(1*(idx1+1))), "CurrentEpochParticipation[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "CurrentEpochParticipation") + } + t.CurrentEpochParticipation = val14 + } + { // Field #21 'InactivityScores' (dynamic) + if dec.GetPosition() != startPos0+int(offset21) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset21)), "InactivityScores") + } + dec.PushLimit(int(offset24 - offset21)) + val15 := t.InactivityScores + sszLen := dec.GetLength() + itemCount := sszLen / 8 + if sszLen%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 8), "InactivityScores") + } + if itemCount > int(expr6) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "InactivityScores") + } + val15 = sszutils.ExpandSlice(val15, itemCount) + if err = sszutils.DecodeUint64Slice(dec, val15); err != nil { + return sszutils.ErrorWithPath(err, "InactivityScores") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "InactivityScores") + } + t.InactivityScores = val15 + } + { // Field #24 'LatestExecutionPayloadHeader' (dynamic) + if dec.GetPosition() != startPos0+int(offset24) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset24)), "LatestExecutionPayloadHeader") + } + dec.PushLimit(int(offset27 - offset24)) + val16 := t.LatestExecutionPayloadHeader + if val16 == nil { + val16 = new(ExecutionPayloadHeader) + } + if buf, err := dec.DecodeBytesBuf(dec.GetLength()); err != nil { + return sszutils.ErrorWithPath(err, "LatestExecutionPayloadHeader") + } else if err = val16.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "LatestExecutionPayloadHeader") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "LatestExecutionPayloadHeader") + } + t.LatestExecutionPayloadHeader = val16 + } + { // Field #27 'HistoricalSummaries' (dynamic) + if dec.GetPosition() != startPos0+int(offset27) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset27)), "HistoricalSummaries") + } + dec.PushLimit(int(maxOffset - offset27)) + val17 := t.HistoricalSummaries + sszLen := dec.GetLength() + itemCount := sszLen / 64 + if sszLen%64 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 64), "HistoricalSummaries") + } + if itemCount > int(expr4) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr4)), "HistoricalSummaries") + } + val17 = sszutils.ExpandSlice(val17, itemCount) + startPos11 := dec.GetPosition() + for idx1 := range itemCount { + if val17[idx1] == nil { + val17[idx1] = new(capella.HistoricalSummary) + } + if buf, err := dec.DecodeBytesBuf(64); err != nil { + return sszutils.ErrorWithPathf(err, "HistoricalSummaries[%d]", idx1) + } else if err = val17[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "HistoricalSummaries[%d]", idx1) + } + if dec.GetPosition() != startPos11+int(64*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos11+int(64*(idx1+1))), "HistoricalSummaries[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "HistoricalSummaries") + } + t.HistoricalSummaries = val17 + } + return nil +} + // SizeSSZ returns the SSZ encoded size of the *BeaconState. func (t *BeaconState) SizeSSZ() (size int) { if t == nil { diff --git a/spec/deneb/generate.yaml b/spec/deneb/generate.yaml index 5c644550..ff3088ac 100644 --- a/spec/deneb/generate.yaml +++ b/spec/deneb/generate.yaml @@ -9,6 +9,7 @@ types: output: beaconblock_ssz.go - name: BeaconState output: beaconstate_ssz.go + with-streaming: true - name: BlobIdentifier output: blobidentifier_ssz.go - name: BlobSidecar diff --git a/spec/electra/beaconstate_ssz.go b/spec/electra/beaconstate_ssz.go index afd0fc5d..2ff209f9 100644 --- a/spec/electra/beaconstate_ssz.go +++ b/spec/electra/beaconstate_ssz.go @@ -1,5 +1,5 @@ // Code generated by dynamic-ssz. DO NOT EDIT. -// Hash: 5e1a5b9110381bd1a93207ee539c050a38d7d6a48b6c3f665c0a7a15159acb10 +// Hash: e228b2457c16d75f6012a36ae9a283035900578d227c059f577fc1ced67591ed // Version: v1.3.1 (https://github.com/pk910/dynamic-ssz) package electra @@ -384,6 +384,642 @@ func (t *BeaconState) MarshalSSZTo(buf []byte) (dst []byte, err error) { return dst, nil } +// MarshalSSZEncoder marshals the *BeaconState to the given SSZ encoder using dynamic specifications. +func (t *BeaconState) MarshalSSZEncoder(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + type encoderCtx struct { + ds sszutils.DynamicSpecs + exprs [10]uint64 + sizeFn1 func(ctx *encoderCtx, t []phase0.Root) (size int) + sizeFn10 func(ctx *encoderCtx, t []*PendingDeposit) (size int) + sizeFn11 func(ctx *encoderCtx, t []*PendingPartialWithdrawal) (size int) + sizeFn12 func(ctx *encoderCtx, t []*PendingConsolidation) (size int) + sizeFn2 func(ctx *encoderCtx, t []*phase0.ETH1Data) (size int) + sizeFn3 func(ctx *encoderCtx, t []*phase0.Validator) (size int) + sizeFn4 func(ctx *encoderCtx, t []phase0.Gwei) (size int) + sizeFn5 func(ctx *encoderCtx, t []altair.ParticipationFlags) (size int) + sizeFn6 func(ctx *encoderCtx, t []altair.ParticipationFlags) (size int) + sizeFn7 func(ctx *encoderCtx, t []uint64) (size int) + sizeFn8 func(ctx *encoderCtx, t *deneb.ExecutionPayloadHeader) (size int) + sizeFn9 func(ctx *encoderCtx, t []*capella.HistoricalSummary) (size int) + } + ctx := &encoderCtx{ds: ds} + canSeek := enc.Seekable() + ctx.exprs[0], err = sszutils.ResolveSpecValueWithDefault(ds, "SLOTS_PER_HISTORICAL_ROOT", 8192) + if err != nil { + return err + } + ctx.exprs[1], err = sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_HISTORICAL_VECTOR", 65536) + if err != nil { + return err + } + ctx.exprs[2], err = sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_SLASHINGS_VECTOR", 8192) + if err != nil { + return err + } + ctx.exprs[3], err = sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE", 512) + if err != nil { + return err + } + ctx.exprs[4], err = sszutils.ResolveSpecValueWithDefault(ds, "HISTORICAL_ROOTS_LIMIT", 16777216) + if err != nil { + return err + } + ctx.exprs[5], err = sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_ETH1_VOTING_PERIOD*SLOTS_PER_EPOCH", 2048) + if err != nil { + return err + } + ctx.exprs[6], err = sszutils.ResolveSpecValueWithDefault(ds, "VALIDATOR_REGISTRY_LIMIT", 1099511627776) + if err != nil { + return err + } + ctx.exprs[7], err = sszutils.ResolveSpecValueWithDefault(ds, "PENDING_DEPOSITS_LIMIT", 134217728) + if err != nil { + return err + } + ctx.exprs[8], err = sszutils.ResolveSpecValueWithDefault(ds, "PENDING_PARTIAL_WITHDRAWALS_LIMIT", 134217728) + if err != nil { + return err + } + ctx.exprs[9], err = sszutils.ResolveSpecValueWithDefault(ds, "PENDING_CONSOLIDATIONS_LIMIT", 262144) + if err != nil { + return err + } + // size for []phase0.Root + ctx.sizeFn1 = func(ctx *encoderCtx, t []phase0.Root) (size int) { + size += len(t) * 32 + return size + } + // size for []*phase0.ETH1Data + ctx.sizeFn2 = func(ctx *encoderCtx, t []*phase0.ETH1Data) (size int) { + size += len(t) * 72 + return size + } + // size for []*phase0.Validator + ctx.sizeFn3 = func(ctx *encoderCtx, t []*phase0.Validator) (size int) { + size += len(t) * 121 + return size + } + // size for []phase0.Gwei + ctx.sizeFn4 = func(ctx *encoderCtx, t []phase0.Gwei) (size int) { + size += len(t) * 8 + return size + } + // size for []altair.ParticipationFlags + ctx.sizeFn5 = func(ctx *encoderCtx, t []altair.ParticipationFlags) (size int) { + size += len(t) + return size + } + // size for []altair.ParticipationFlags + ctx.sizeFn6 = func(ctx *encoderCtx, t []altair.ParticipationFlags) (size int) { + size += len(t) + return size + } + // size for []uint64 + ctx.sizeFn7 = func(ctx *encoderCtx, t []uint64) (size int) { + size += len(t) * 8 + return size + } + // size for *deneb.ExecutionPayloadHeader + ctx.sizeFn8 = func(ctx *encoderCtx, t *deneb.ExecutionPayloadHeader) (size int) { + size += t.SizeSSZ() + return size + } + // size for []*capella.HistoricalSummary + ctx.sizeFn9 = func(ctx *encoderCtx, t []*capella.HistoricalSummary) (size int) { + size += len(t) * 64 + return size + } + // size for []*PendingDeposit + ctx.sizeFn10 = func(ctx *encoderCtx, t []*PendingDeposit) (size int) { + size += len(t) * 192 + return size + } + // size for []*PendingPartialWithdrawal + ctx.sizeFn11 = func(ctx *encoderCtx, t []*PendingPartialWithdrawal) (size int) { + size += len(t) * 24 + return size + } + // size for []*PendingConsolidation + ctx.sizeFn12 = func(ctx *encoderCtx, t []*PendingConsolidation) (size int) { + size += len(t) * 16 + return size + } + size1 := 32 * int(ctx.exprs[0]) + size2 := 32 * int(ctx.exprs[1]) + size3 := 8 * int(ctx.exprs[2]) + size5 := 48 * int(ctx.exprs[3]) + size4 := size5 + 48 // size expression for '*SyncCommittee' + if t == nil { + t = new(BeaconState) + } + dstlen := enc.GetPosition() + dynoff := uint32(size1 + size1 + size2 + size3 + size4 + size4 + 489) + { // Field #0 'GenesisTime' + enc.EncodeUint64(t.GenesisTime) + } + { // Field #1 'GenesisValidatorsRoot' + enc.EncodeBytes(t.GenesisValidatorsRoot[:32]) + } + { // Field #2 'Slot' + enc.EncodeUint64(uint64(t.Slot)) + } + { // Field #3 'Fork' + t := t.Fork + if t == nil { + t = new(phase0.Fork) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "Fork") + } else { + enc.SetBuffer(buf) + } + } + { // Field #4 'LatestBlockHeader' + t := t.LatestBlockHeader + if t == nil { + t = new(phase0.BeaconBlockHeader) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") + } else { + enc.SetBuffer(buf) + } + } + { // Field #5 'BlockRoots' + t := t.BlockRoots + vlen := len(t) + if vlen > int(ctx.exprs[0]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[0])), "BlockRoots") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:32]) + } + if vlen < int(ctx.exprs[0]) { + enc.EncodeZeroPadding((int(ctx.exprs[0]) - vlen) * 32) + } + } + { // Field #6 'StateRoots' + t := t.StateRoots + vlen := len(t) + if vlen > int(ctx.exprs[0]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[0])), "StateRoots") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:32]) + } + if vlen < int(ctx.exprs[0]) { + enc.EncodeZeroPadding((int(ctx.exprs[0]) - vlen) * 32) + } + } + // Offset #7 'HistoricalRoots' + offset7 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn1(ctx, t.HistoricalRoots)) + } + { // Field #8 'ETH1Data' + t := t.ETH1Data + if t == nil { + t = new(phase0.ETH1Data) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "ETH1Data") + } else { + enc.SetBuffer(buf) + } + } + // Offset #9 'ETH1DataVotes' + offset9 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn2(ctx, t.ETH1DataVotes)) + } + { // Field #10 'ETH1DepositIndex' + enc.EncodeUint64(t.ETH1DepositIndex) + } + // Offset #11 'Validators' + offset11 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn3(ctx, t.Validators)) + } + // Offset #12 'Balances' + offset12 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn4(ctx, t.Balances)) + } + { // Field #13 'RANDAOMixes' + t := t.RANDAOMixes + vlen := len(t) + if vlen > int(ctx.exprs[1]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[1])), "RANDAOMixes") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:32]) + } + if vlen < int(ctx.exprs[1]) { + enc.EncodeZeroPadding((int(ctx.exprs[1]) - vlen) * 32) + } + } + { // Field #14 'Slashings' + t := t.Slashings + vlen := len(t) + if vlen > int(ctx.exprs[2]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[2])), "Slashings") + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + if vlen < int(ctx.exprs[2]) { + enc.EncodeZeroPadding((int(ctx.exprs[2]) - vlen) * 8) + } + } + // Offset #15 'PreviousEpochParticipation' + offset15 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn5(ctx, t.PreviousEpochParticipation)) + } + // Offset #16 'CurrentEpochParticipation' + offset16 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn6(ctx, t.CurrentEpochParticipation)) + } + { // Field #17 'JustificationBits' + vlen := len(t.JustificationBits) + if vlen > 1 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 1), "JustificationBits") + } + enc.EncodeBytes(t.JustificationBits[:vlen]) + if vlen < 1 { + enc.EncodeZeroPadding((1 - vlen) * 1) + } + } + { // Field #18 'PreviousJustifiedCheckpoint' + t := t.PreviousJustifiedCheckpoint + if t == nil { + t = new(phase0.Checkpoint) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } else { + enc.SetBuffer(buf) + } + } + { // Field #19 'CurrentJustifiedCheckpoint' + t := t.CurrentJustifiedCheckpoint + if t == nil { + t = new(phase0.Checkpoint) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } else { + enc.SetBuffer(buf) + } + } + { // Field #20 'FinalizedCheckpoint' + t := t.FinalizedCheckpoint + if t == nil { + t = new(phase0.Checkpoint) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") + } else { + enc.SetBuffer(buf) + } + } + // Offset #21 'InactivityScores' + offset21 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn7(ctx, t.InactivityScores)) + } + { // Field #22 'CurrentSyncCommittee' + t := t.CurrentSyncCommittee + if t == nil { + t = new(altair.SyncCommittee) + } + { // Field #0 'Pubkeys' + t := t.Pubkeys + vlen := len(t) + if vlen > int(ctx.exprs[3]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[3])), "CurrentSyncCommittee.Pubkeys") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:48]) + } + if vlen < int(ctx.exprs[3]) { + enc.EncodeZeroPadding((int(ctx.exprs[3]) - vlen) * 48) + } + } + { // Field #1 'AggregatePubkey' + enc.EncodeBytes(t.AggregatePubkey[:48]) + } + } + { // Field #23 'NextSyncCommittee' + t := t.NextSyncCommittee + if t == nil { + t = new(altair.SyncCommittee) + } + { // Field #0 'Pubkeys' + t := t.Pubkeys + vlen := len(t) + if vlen > int(ctx.exprs[3]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[3])), "NextSyncCommittee.Pubkeys") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:48]) + } + if vlen < int(ctx.exprs[3]) { + enc.EncodeZeroPadding((int(ctx.exprs[3]) - vlen) * 48) + } + } + { // Field #1 'AggregatePubkey' + enc.EncodeBytes(t.AggregatePubkey[:48]) + } + } + // Offset #24 'LatestExecutionPayloadHeader' + offset24 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn8(ctx, t.LatestExecutionPayloadHeader)) + } + { // Field #25 'NextWithdrawalIndex' + enc.EncodeUint64(uint64(t.NextWithdrawalIndex)) + } + { // Field #26 'NextWithdrawalValidatorIndex' + enc.EncodeUint64(uint64(t.NextWithdrawalValidatorIndex)) + } + // Offset #27 'HistoricalSummaries' + offset27 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn9(ctx, t.HistoricalSummaries)) + } + { // Field #28 'DepositRequestsStartIndex' + enc.EncodeUint64(t.DepositRequestsStartIndex) + } + { // Field #29 'DepositBalanceToConsume' + enc.EncodeUint64(uint64(t.DepositBalanceToConsume)) + } + { // Field #30 'ExitBalanceToConsume' + enc.EncodeUint64(uint64(t.ExitBalanceToConsume)) + } + { // Field #31 'EarliestExitEpoch' + enc.EncodeUint64(uint64(t.EarliestExitEpoch)) + } + { // Field #32 'ConsolidationBalanceToConsume' + enc.EncodeUint64(uint64(t.ConsolidationBalanceToConsume)) + } + { // Field #33 'EarliestConsolidationEpoch' + enc.EncodeUint64(uint64(t.EarliestConsolidationEpoch)) + } + // Offset #34 'PendingDeposits' + offset34 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn10(ctx, t.PendingDeposits)) + } + // Offset #35 'PendingPartialWithdrawals' + offset35 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn11(ctx, t.PendingPartialWithdrawals)) + } + // Offset #36 'PendingConsolidations' + offset36 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn12(ctx, t.PendingConsolidations)) + } + { // Dynamic Field #7 'HistoricalRoots' + if canSeek { + enc.EncodeOffsetAt(offset7, uint32(enc.GetPosition()-dstlen)) + } + t := t.HistoricalRoots + vlen := len(t) + if vlen > int(ctx.exprs[4]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[4])), "HistoricalRoots") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:32]) + } + } + { // Dynamic Field #9 'ETH1DataVotes' + if canSeek { + enc.EncodeOffsetAt(offset9, uint32(enc.GetPosition()-dstlen)) + } + t := t.ETH1DataVotes + vlen := len(t) + if vlen > int(ctx.exprs[5]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[5])), "ETH1DataVotes") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(phase0.ETH1Data) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "ETH1DataVotes[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #11 'Validators' + if canSeek { + enc.EncodeOffsetAt(offset11, uint32(enc.GetPosition()-dstlen)) + } + t := t.Validators + vlen := len(t) + if vlen > int(ctx.exprs[6]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[6])), "Validators") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(phase0.Validator) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #12 'Balances' + if canSeek { + enc.EncodeOffsetAt(offset12, uint32(enc.GetPosition()-dstlen)) + } + t := t.Balances + vlen := len(t) + if vlen > int(ctx.exprs[6]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[6])), "Balances") + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + } + { // Dynamic Field #15 'PreviousEpochParticipation' + if canSeek { + enc.EncodeOffsetAt(offset15, uint32(enc.GetPosition()-dstlen)) + } + t := t.PreviousEpochParticipation + vlen := len(t) + if vlen > int(ctx.exprs[6]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[6])), "PreviousEpochParticipation") + } + for idx1 := range vlen { + enc.EncodeUint8(byte(t[idx1])) + } + } + { // Dynamic Field #16 'CurrentEpochParticipation' + if canSeek { + enc.EncodeOffsetAt(offset16, uint32(enc.GetPosition()-dstlen)) + } + t := t.CurrentEpochParticipation + vlen := len(t) + if vlen > int(ctx.exprs[6]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[6])), "CurrentEpochParticipation") + } + for idx1 := range vlen { + enc.EncodeUint8(byte(t[idx1])) + } + } + { // Dynamic Field #21 'InactivityScores' + if canSeek { + enc.EncodeOffsetAt(offset21, uint32(enc.GetPosition()-dstlen)) + } + t := t.InactivityScores + vlen := len(t) + if vlen > int(ctx.exprs[6]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[6])), "InactivityScores") + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + } + { // Dynamic Field #24 'LatestExecutionPayloadHeader' + if canSeek { + enc.EncodeOffsetAt(offset24, uint32(enc.GetPosition()-dstlen)) + } + t := t.LatestExecutionPayloadHeader + if t == nil { + t = new(deneb.ExecutionPayloadHeader) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "LatestExecutionPayloadHeader") + } else { + enc.SetBuffer(buf) + } + } + { // Dynamic Field #27 'HistoricalSummaries' + if canSeek { + enc.EncodeOffsetAt(offset27, uint32(enc.GetPosition()-dstlen)) + } + t := t.HistoricalSummaries + vlen := len(t) + if vlen > int(ctx.exprs[4]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[4])), "HistoricalSummaries") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(capella.HistoricalSummary) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "HistoricalSummaries[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #34 'PendingDeposits' + if canSeek { + enc.EncodeOffsetAt(offset34, uint32(enc.GetPosition()-dstlen)) + } + t := t.PendingDeposits + vlen := len(t) + if vlen > int(ctx.exprs[7]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[7])), "PendingDeposits") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(PendingDeposit) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "PendingDeposits[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #35 'PendingPartialWithdrawals' + if canSeek { + enc.EncodeOffsetAt(offset35, uint32(enc.GetPosition()-dstlen)) + } + t := t.PendingPartialWithdrawals + vlen := len(t) + if vlen > int(ctx.exprs[8]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[8])), "PendingPartialWithdrawals") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(PendingPartialWithdrawal) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "PendingPartialWithdrawals[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #36 'PendingConsolidations' + if canSeek { + enc.EncodeOffsetAt(offset36, uint32(enc.GetPosition()-dstlen)) + } + t := t.PendingConsolidations + vlen := len(t) + if vlen > int(ctx.exprs[9]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[9])), "PendingConsolidations") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(PendingConsolidation) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "PendingConsolidations[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + return nil +} + // UnmarshalSSZ unmarshals the *BeaconState from SSZ-encoded bytes. func (t *BeaconState) UnmarshalSSZ(buf []byte) (err error) { buflen := len(buf) @@ -829,6 +1465,749 @@ func (t *BeaconState) UnmarshalSSZ(buf []byte) (err error) { return nil } +// UnmarshalSSZDecoder unmarshals the *BeaconState from the given SSZ decoder using dynamic specifications. +func (t *BeaconState) UnmarshalSSZDecoder(ds sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { + expr0, err := sszutils.ResolveSpecValueWithDefault(ds, "SLOTS_PER_HISTORICAL_ROOT", 8192) + if err != nil { + return err + } + expr1, err := sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_HISTORICAL_VECTOR", 65536) + if err != nil { + return err + } + expr2, err := sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_SLASHINGS_VECTOR", 8192) + if err != nil { + return err + } + expr3, err := sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE", 512) + if err != nil { + return err + } + expr4, err := sszutils.ResolveSpecValueWithDefault(ds, "HISTORICAL_ROOTS_LIMIT", 16777216) + if err != nil { + return err + } + expr5, err := sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_ETH1_VOTING_PERIOD*SLOTS_PER_EPOCH", 2048) + if err != nil { + return err + } + expr6, err := sszutils.ResolveSpecValueWithDefault(ds, "VALIDATOR_REGISTRY_LIMIT", 1099511627776) + if err != nil { + return err + } + expr7, err := sszutils.ResolveSpecValueWithDefault(ds, "PENDING_DEPOSITS_LIMIT", 134217728) + if err != nil { + return err + } + expr8, err := sszutils.ResolveSpecValueWithDefault(ds, "PENDING_PARTIAL_WITHDRAWALS_LIMIT", 134217728) + if err != nil { + return err + } + expr9, err := sszutils.ResolveSpecValueWithDefault(ds, "PENDING_CONSOLIDATIONS_LIMIT", 262144) + if err != nil { + return err + } + size1 := 32 * int(expr0) + size2 := 32 * int(expr1) + size3 := 8 * int(expr2) + size5 := 48 * int(expr3) + size4 := size5 + 48 // size expression for '*SyncCommittee' + totalSize := size1+size1+size2+size3+size4+size4+489 + maxOffset := uint32(dec.GetLength()) + startPos0 := dec.GetPosition() + if maxOffset < uint32(totalSize) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(totalSize)) + } + // Field #0 'GenesisTime' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "GenesisTime") + } else { + t.GenesisTime = val + } + // Field #1 'GenesisValidatorsRoot' (static) + if _, err = dec.DecodeBytes(t.GenesisValidatorsRoot[:32]); err != nil { + return err + } + // Field #2 'Slot' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "Slot") + } else { + t.Slot = phase0.Slot(val) + } + // Field #3 'Fork' (static) + if t.Fork == nil { + t.Fork = new(phase0.Fork) + } + if buf, err := dec.DecodeBytesBuf(16); err != nil { + return sszutils.ErrorWithPath(err, "Fork") + } else if err = t.Fork.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "Fork") + } + // Field #4 'LatestBlockHeader' (static) + if t.LatestBlockHeader == nil { + t.LatestBlockHeader = new(phase0.BeaconBlockHeader) + } + if buf, err := dec.DecodeBytesBuf(112); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") + } else if err = t.LatestBlockHeader.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") + } + { // Field #5 'BlockRoots' (static) + val1 := t.BlockRoots + val1 = sszutils.ExpandSlice(val1, int(expr0)) + startPos1 := dec.GetPosition() + for idx1 := range int(expr0) { + if _, err = dec.DecodeBytes(val1[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos1+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos1+int(32*(idx1+1))), "BlockRoots[%d]", idx1) + } + } + t.BlockRoots = val1 + } + { // Field #6 'StateRoots' (static) + val2 := t.StateRoots + val2 = sszutils.ExpandSlice(val2, int(expr0)) + startPos2 := dec.GetPosition() + for idx1 := range int(expr0) { + if _, err = dec.DecodeBytes(val2[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos2+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos2+int(32*(idx1+1))), "StateRoots[%d]", idx1) + } + } + t.StateRoots = val2 + } + // Field #7 'HistoricalRoots' (offset) + offset7, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "HistoricalRoots") + } + if offset7 != uint32(totalSize) { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset7, totalSize), "HistoricalRoots") + } + // Field #8 'ETH1Data' (static) + if t.ETH1Data == nil { + t.ETH1Data = new(phase0.ETH1Data) + } + if buf, err := dec.DecodeBytesBuf(72); err != nil { + return sszutils.ErrorWithPath(err, "ETH1Data") + } else if err = t.ETH1Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "ETH1Data") + } + // Field #9 'ETH1DataVotes' (offset) + offset9, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "ETH1DataVotes") + } + if offset9 < offset7 || offset9 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset9, offset7, maxOffset), "ETH1DataVotes") + } + // Field #10 'ETH1DepositIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "ETH1DepositIndex") + } else { + t.ETH1DepositIndex = val + } + // Field #11 'Validators' (offset) + offset11, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Validators") + } + if offset11 < offset9 || offset11 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset11, offset9, maxOffset), "Validators") + } + // Field #12 'Balances' (offset) + offset12, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Balances") + } + if offset12 < offset11 || offset12 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset12, offset11, maxOffset), "Balances") + } + { // Field #13 'RANDAOMixes' (static) + val3 := t.RANDAOMixes + val3 = sszutils.ExpandSlice(val3, int(expr1)) + startPos3 := dec.GetPosition() + for idx1 := range int(expr1) { + if _, err = dec.DecodeBytes(val3[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos3+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos3+int(32*(idx1+1))), "RANDAOMixes[%d]", idx1) + } + } + t.RANDAOMixes = val3 + } + { // Field #14 'Slashings' (static) + val4 := t.Slashings + val4 = sszutils.ExpandSlice(val4, int(expr2)) + if err = sszutils.DecodeUint64Slice(dec, val4[:int(expr2)]); err != nil { + return sszutils.ErrorWithPath(err, "Slashings") + } + t.Slashings = val4 + } + // Field #15 'PreviousEpochParticipation' (offset) + offset15, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "PreviousEpochParticipation") + } + if offset15 < offset12 || offset15 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset15, offset12, maxOffset), "PreviousEpochParticipation") + } + // Field #16 'CurrentEpochParticipation' (offset) + offset16, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "CurrentEpochParticipation") + } + if offset16 < offset15 || offset16 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset16, offset15, maxOffset), "CurrentEpochParticipation") + } + // Field #17 'JustificationBits' (static) + t.JustificationBits = sszutils.ExpandSlice(t.JustificationBits, 1) + if _, err = dec.DecodeBytes(t.JustificationBits[:1]); err != nil { + return err + } + // Field #18 'PreviousJustifiedCheckpoint' (static) + if t.PreviousJustifiedCheckpoint == nil { + t.PreviousJustifiedCheckpoint = new(phase0.Checkpoint) + } + if buf, err := dec.DecodeBytesBuf(40); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } else if err = t.PreviousJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } + // Field #19 'CurrentJustifiedCheckpoint' (static) + if t.CurrentJustifiedCheckpoint == nil { + t.CurrentJustifiedCheckpoint = new(phase0.Checkpoint) + } + if buf, err := dec.DecodeBytesBuf(40); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } else if err = t.CurrentJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } + // Field #20 'FinalizedCheckpoint' (static) + if t.FinalizedCheckpoint == nil { + t.FinalizedCheckpoint = new(phase0.Checkpoint) + } + if buf, err := dec.DecodeBytesBuf(40); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") + } else if err = t.FinalizedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") + } + // Field #21 'InactivityScores' (offset) + offset21, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "InactivityScores") + } + if offset21 < offset16 || offset21 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset21, offset16, maxOffset), "InactivityScores") + } + { // Field #22 'CurrentSyncCommittee' (static) + val5 := t.CurrentSyncCommittee + if val5 == nil { + val5 = new(altair.SyncCommittee) + } + totalSize := size5+48 + maxOffset := uint32(dec.GetLength()) + if maxOffset < uint32(totalSize) { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(totalSize)), "CurrentSyncCommittee") + } + { // Field #0 'Pubkeys' (static) + val6 := val5.Pubkeys + val6 = sszutils.ExpandSlice(val6, int(expr3)) + startPos4 := dec.GetPosition() + for idx1 := range int(expr3) { + if _, err = dec.DecodeBytes(val6[idx1][:48]); err != nil { + return err + } + if dec.GetPosition() != startPos4+int(48*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos4+int(48*(idx1+1))), "CurrentSyncCommittee.Pubkeys[%d]", idx1) + } + } + val5.Pubkeys = val6 + } + // Field #1 'AggregatePubkey' (static) + if _, err = dec.DecodeBytes(val5.AggregatePubkey[:48]); err != nil { + return err + } + t.CurrentSyncCommittee = val5 + } + { // Field #23 'NextSyncCommittee' (static) + val7 := t.NextSyncCommittee + if val7 == nil { + val7 = new(altair.SyncCommittee) + } + totalSize := size5+48 + maxOffset := uint32(dec.GetLength()) + if maxOffset < uint32(totalSize) { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(totalSize)), "NextSyncCommittee") + } + { // Field #0 'Pubkeys' (static) + val8 := val7.Pubkeys + val8 = sszutils.ExpandSlice(val8, int(expr3)) + startPos5 := dec.GetPosition() + for idx1 := range int(expr3) { + if _, err = dec.DecodeBytes(val8[idx1][:48]); err != nil { + return err + } + if dec.GetPosition() != startPos5+int(48*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos5+int(48*(idx1+1))), "NextSyncCommittee.Pubkeys[%d]", idx1) + } + } + val7.Pubkeys = val8 + } + // Field #1 'AggregatePubkey' (static) + if _, err = dec.DecodeBytes(val7.AggregatePubkey[:48]); err != nil { + return err + } + t.NextSyncCommittee = val7 + } + // Field #24 'LatestExecutionPayloadHeader' (offset) + offset24, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "LatestExecutionPayloadHeader") + } + if offset24 < offset21 || offset24 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset24, offset21, maxOffset), "LatestExecutionPayloadHeader") + } + // Field #25 'NextWithdrawalIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "NextWithdrawalIndex") + } else { + t.NextWithdrawalIndex = capella.WithdrawalIndex(val) + } + // Field #26 'NextWithdrawalValidatorIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "NextWithdrawalValidatorIndex") + } else { + t.NextWithdrawalValidatorIndex = phase0.ValidatorIndex(val) + } + // Field #27 'HistoricalSummaries' (offset) + offset27, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "HistoricalSummaries") + } + if offset27 < offset24 || offset27 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset27, offset24, maxOffset), "HistoricalSummaries") + } + // Field #28 'DepositRequestsStartIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "DepositRequestsStartIndex") + } else { + t.DepositRequestsStartIndex = val + } + // Field #29 'DepositBalanceToConsume' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "DepositBalanceToConsume") + } else { + t.DepositBalanceToConsume = phase0.Gwei(val) + } + // Field #30 'ExitBalanceToConsume' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "ExitBalanceToConsume") + } else { + t.ExitBalanceToConsume = phase0.Gwei(val) + } + // Field #31 'EarliestExitEpoch' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "EarliestExitEpoch") + } else { + t.EarliestExitEpoch = phase0.Epoch(val) + } + // Field #32 'ConsolidationBalanceToConsume' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "ConsolidationBalanceToConsume") + } else { + t.ConsolidationBalanceToConsume = phase0.Gwei(val) + } + // Field #33 'EarliestConsolidationEpoch' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "EarliestConsolidationEpoch") + } else { + t.EarliestConsolidationEpoch = phase0.Epoch(val) + } + // Field #34 'PendingDeposits' (offset) + offset34, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "PendingDeposits") + } + if offset34 < offset27 || offset34 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset34, offset27, maxOffset), "PendingDeposits") + } + // Field #35 'PendingPartialWithdrawals' (offset) + offset35, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "PendingPartialWithdrawals") + } + if offset35 < offset34 || offset35 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset35, offset34, maxOffset), "PendingPartialWithdrawals") + } + // Field #36 'PendingConsolidations' (offset) + offset36, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "PendingConsolidations") + } + if offset36 < offset35 || offset36 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset36, offset35, maxOffset), "PendingConsolidations") + } + { // Field #7 'HistoricalRoots' (dynamic) + if dec.GetPosition() != startPos0+int(offset7) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset7)), "HistoricalRoots") + } + dec.PushLimit(int(offset9 - offset7)) + val9 := t.HistoricalRoots + sszLen := dec.GetLength() + itemCount := sszLen / 32 + if sszLen%32 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 32), "HistoricalRoots") + } + if itemCount > int(expr4) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr4)), "HistoricalRoots") + } + val9 = sszutils.ExpandSlice(val9, itemCount) + startPos6 := dec.GetPosition() + for idx1 := range itemCount { + if _, err = dec.DecodeBytes(val9[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos6+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos6+int(32*(idx1+1))), "HistoricalRoots[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "HistoricalRoots") + } + t.HistoricalRoots = val9 + } + { // Field #9 'ETH1DataVotes' (dynamic) + if dec.GetPosition() != startPos0+int(offset9) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset9)), "ETH1DataVotes") + } + dec.PushLimit(int(offset11 - offset9)) + val10 := t.ETH1DataVotes + sszLen := dec.GetLength() + itemCount := sszLen / 72 + if sszLen%72 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 72), "ETH1DataVotes") + } + if itemCount > int(expr5) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr5)), "ETH1DataVotes") + } + val10 = sszutils.ExpandSlice(val10, itemCount) + startPos7 := dec.GetPosition() + for idx1 := range itemCount { + if val10[idx1] == nil { + val10[idx1] = new(phase0.ETH1Data) + } + if buf, err := dec.DecodeBytesBuf(72); err != nil { + return sszutils.ErrorWithPathf(err, "ETH1DataVotes[%d]", idx1) + } else if err = val10[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "ETH1DataVotes[%d]", idx1) + } + if dec.GetPosition() != startPos7+int(72*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos7+int(72*(idx1+1))), "ETH1DataVotes[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "ETH1DataVotes") + } + t.ETH1DataVotes = val10 + } + { // Field #11 'Validators' (dynamic) + if dec.GetPosition() != startPos0+int(offset11) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset11)), "Validators") + } + dec.PushLimit(int(offset12 - offset11)) + val11 := t.Validators + sszLen := dec.GetLength() + itemCount := sszLen / 121 + if sszLen%121 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 121), "Validators") + } + if itemCount > int(expr6) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "Validators") + } + val11 = sszutils.ExpandSlice(val11, itemCount) + startPos8 := dec.GetPosition() + for idx1 := range itemCount { + if val11[idx1] == nil { + val11[idx1] = new(phase0.Validator) + } + if buf, err := dec.DecodeBytesBuf(121); err != nil { + return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } else if err = val11[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } + if dec.GetPosition() != startPos8+int(121*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos8+int(121*(idx1+1))), "Validators[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Validators") + } + t.Validators = val11 + } + { // Field #12 'Balances' (dynamic) + if dec.GetPosition() != startPos0+int(offset12) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset12)), "Balances") + } + dec.PushLimit(int(offset15 - offset12)) + val12 := t.Balances + sszLen := dec.GetLength() + itemCount := sszLen / 8 + if sszLen%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 8), "Balances") + } + if itemCount > int(expr6) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "Balances") + } + val12 = sszutils.ExpandSlice(val12, itemCount) + if err = sszutils.DecodeUint64Slice(dec, val12); err != nil { + return sszutils.ErrorWithPath(err, "Balances") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Balances") + } + t.Balances = val12 + } + { // Field #15 'PreviousEpochParticipation' (dynamic) + if dec.GetPosition() != startPos0+int(offset15) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset15)), "PreviousEpochParticipation") + } + dec.PushLimit(int(offset16 - offset15)) + val13 := t.PreviousEpochParticipation + itemCount := dec.GetLength() + if itemCount > int(expr6) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "PreviousEpochParticipation") + } + val13 = sszutils.ExpandSlice(val13, itemCount) + startPos9 := dec.GetPosition() + for idx1 := range itemCount { + if val, err := dec.DecodeUint8(); err != nil { + return sszutils.ErrorWithPathf(err, "PreviousEpochParticipation[%d]", idx1) + } else { + val13[idx1] = altair.ParticipationFlags(val) + } + if dec.GetPosition() != startPos9+int(1*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos9+int(1*(idx1+1))), "PreviousEpochParticipation[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "PreviousEpochParticipation") + } + t.PreviousEpochParticipation = val13 + } + { // Field #16 'CurrentEpochParticipation' (dynamic) + if dec.GetPosition() != startPos0+int(offset16) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset16)), "CurrentEpochParticipation") + } + dec.PushLimit(int(offset21 - offset16)) + val14 := t.CurrentEpochParticipation + itemCount := dec.GetLength() + if itemCount > int(expr6) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "CurrentEpochParticipation") + } + val14 = sszutils.ExpandSlice(val14, itemCount) + startPos10 := dec.GetPosition() + for idx1 := range itemCount { + if val, err := dec.DecodeUint8(); err != nil { + return sszutils.ErrorWithPathf(err, "CurrentEpochParticipation[%d]", idx1) + } else { + val14[idx1] = altair.ParticipationFlags(val) + } + if dec.GetPosition() != startPos10+int(1*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos10+int(1*(idx1+1))), "CurrentEpochParticipation[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "CurrentEpochParticipation") + } + t.CurrentEpochParticipation = val14 + } + { // Field #21 'InactivityScores' (dynamic) + if dec.GetPosition() != startPos0+int(offset21) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset21)), "InactivityScores") + } + dec.PushLimit(int(offset24 - offset21)) + val15 := t.InactivityScores + sszLen := dec.GetLength() + itemCount := sszLen / 8 + if sszLen%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 8), "InactivityScores") + } + if itemCount > int(expr6) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "InactivityScores") + } + val15 = sszutils.ExpandSlice(val15, itemCount) + if err = sszutils.DecodeUint64Slice(dec, val15); err != nil { + return sszutils.ErrorWithPath(err, "InactivityScores") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "InactivityScores") + } + t.InactivityScores = val15 + } + { // Field #24 'LatestExecutionPayloadHeader' (dynamic) + if dec.GetPosition() != startPos0+int(offset24) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset24)), "LatestExecutionPayloadHeader") + } + dec.PushLimit(int(offset27 - offset24)) + val16 := t.LatestExecutionPayloadHeader + if val16 == nil { + val16 = new(deneb.ExecutionPayloadHeader) + } + if buf, err := dec.DecodeBytesBuf(dec.GetLength()); err != nil { + return sszutils.ErrorWithPath(err, "LatestExecutionPayloadHeader") + } else if err = val16.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "LatestExecutionPayloadHeader") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "LatestExecutionPayloadHeader") + } + t.LatestExecutionPayloadHeader = val16 + } + { // Field #27 'HistoricalSummaries' (dynamic) + if dec.GetPosition() != startPos0+int(offset27) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset27)), "HistoricalSummaries") + } + dec.PushLimit(int(offset34 - offset27)) + val17 := t.HistoricalSummaries + sszLen := dec.GetLength() + itemCount := sszLen / 64 + if sszLen%64 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 64), "HistoricalSummaries") + } + if itemCount > int(expr4) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr4)), "HistoricalSummaries") + } + val17 = sszutils.ExpandSlice(val17, itemCount) + startPos11 := dec.GetPosition() + for idx1 := range itemCount { + if val17[idx1] == nil { + val17[idx1] = new(capella.HistoricalSummary) + } + if buf, err := dec.DecodeBytesBuf(64); err != nil { + return sszutils.ErrorWithPathf(err, "HistoricalSummaries[%d]", idx1) + } else if err = val17[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "HistoricalSummaries[%d]", idx1) + } + if dec.GetPosition() != startPos11+int(64*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos11+int(64*(idx1+1))), "HistoricalSummaries[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "HistoricalSummaries") + } + t.HistoricalSummaries = val17 + } + { // Field #34 'PendingDeposits' (dynamic) + if dec.GetPosition() != startPos0+int(offset34) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset34)), "PendingDeposits") + } + dec.PushLimit(int(offset35 - offset34)) + val18 := t.PendingDeposits + sszLen := dec.GetLength() + itemCount := sszLen / 192 + if sszLen%192 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 192), "PendingDeposits") + } + if itemCount > int(expr7) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr7)), "PendingDeposits") + } + val18 = sszutils.ExpandSlice(val18, itemCount) + startPos12 := dec.GetPosition() + for idx1 := range itemCount { + if val18[idx1] == nil { + val18[idx1] = new(PendingDeposit) + } + if buf, err := dec.DecodeBytesBuf(192); err != nil { + return sszutils.ErrorWithPathf(err, "PendingDeposits[%d]", idx1) + } else if err = val18[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "PendingDeposits[%d]", idx1) + } + if dec.GetPosition() != startPos12+int(192*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos12+int(192*(idx1+1))), "PendingDeposits[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "PendingDeposits") + } + t.PendingDeposits = val18 + } + { // Field #35 'PendingPartialWithdrawals' (dynamic) + if dec.GetPosition() != startPos0+int(offset35) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset35)), "PendingPartialWithdrawals") + } + dec.PushLimit(int(offset36 - offset35)) + val19 := t.PendingPartialWithdrawals + sszLen := dec.GetLength() + itemCount := sszLen / 24 + if sszLen%24 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 24), "PendingPartialWithdrawals") + } + if itemCount > int(expr8) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr8)), "PendingPartialWithdrawals") + } + val19 = sszutils.ExpandSlice(val19, itemCount) + startPos13 := dec.GetPosition() + for idx1 := range itemCount { + if val19[idx1] == nil { + val19[idx1] = new(PendingPartialWithdrawal) + } + if buf, err := dec.DecodeBytesBuf(24); err != nil { + return sszutils.ErrorWithPathf(err, "PendingPartialWithdrawals[%d]", idx1) + } else if err = val19[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "PendingPartialWithdrawals[%d]", idx1) + } + if dec.GetPosition() != startPos13+int(24*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos13+int(24*(idx1+1))), "PendingPartialWithdrawals[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "PendingPartialWithdrawals") + } + t.PendingPartialWithdrawals = val19 + } + { // Field #36 'PendingConsolidations' (dynamic) + if dec.GetPosition() != startPos0+int(offset36) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset36)), "PendingConsolidations") + } + dec.PushLimit(int(maxOffset - offset36)) + val20 := t.PendingConsolidations + sszLen := dec.GetLength() + itemCount := sszLen / 16 + if sszLen%16 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 16), "PendingConsolidations") + } + if itemCount > int(expr9) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr9)), "PendingConsolidations") + } + val20 = sszutils.ExpandSlice(val20, itemCount) + startPos14 := dec.GetPosition() + for idx1 := range itemCount { + if val20[idx1] == nil { + val20[idx1] = new(PendingConsolidation) + } + if buf, err := dec.DecodeBytesBuf(16); err != nil { + return sszutils.ErrorWithPathf(err, "PendingConsolidations[%d]", idx1) + } else if err = val20[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "PendingConsolidations[%d]", idx1) + } + if dec.GetPosition() != startPos14+int(16*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos14+int(16*(idx1+1))), "PendingConsolidations[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "PendingConsolidations") + } + t.PendingConsolidations = val20 + } + return nil +} + // SizeSSZ returns the SSZ encoded size of the *BeaconState. func (t *BeaconState) SizeSSZ() (size int) { if t == nil { diff --git a/spec/electra/generate.yaml b/spec/electra/generate.yaml index 4d753f48..c82384b2 100644 --- a/spec/electra/generate.yaml +++ b/spec/electra/generate.yaml @@ -15,6 +15,7 @@ types: output: beaconblock_ssz.go - name: BeaconState output: beaconstate_ssz.go + with-streaming: true - name: Consolidation output: consolidation_ssz.go - name: ConsolidationRequest diff --git a/spec/fulu/beaconstate_ssz.go b/spec/fulu/beaconstate_ssz.go index 73b863b1..c83f5de9 100644 --- a/spec/fulu/beaconstate_ssz.go +++ b/spec/fulu/beaconstate_ssz.go @@ -1,5 +1,5 @@ // Code generated by dynamic-ssz. DO NOT EDIT. -// Hash: 9b45e970f7c1def85648262018b43e9e234d9d674e0b8da0764038f74f254f82 +// Hash: e7529fc59cd717399e7ea3a4b32362d7d2e7e5701e975d780a89992a3906b45e // Version: v1.3.1 (https://github.com/pk910/dynamic-ssz) package fulu @@ -396,6 +396,658 @@ func (t *BeaconState) MarshalSSZTo(buf []byte) (dst []byte, err error) { return dst, nil } +// MarshalSSZEncoder marshals the *BeaconState to the given SSZ encoder using dynamic specifications. +func (t *BeaconState) MarshalSSZEncoder(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + type encoderCtx struct { + ds sszutils.DynamicSpecs + exprs [11]uint64 + sizeFn1 func(ctx *encoderCtx, t []phase0.Root) (size int) + sizeFn10 func(ctx *encoderCtx, t []*electra.PendingDeposit) (size int) + sizeFn11 func(ctx *encoderCtx, t []*electra.PendingPartialWithdrawal) (size int) + sizeFn12 func(ctx *encoderCtx, t []*electra.PendingConsolidation) (size int) + sizeFn2 func(ctx *encoderCtx, t []*phase0.ETH1Data) (size int) + sizeFn3 func(ctx *encoderCtx, t []*phase0.Validator) (size int) + sizeFn4 func(ctx *encoderCtx, t []phase0.Gwei) (size int) + sizeFn5 func(ctx *encoderCtx, t []altair.ParticipationFlags) (size int) + sizeFn6 func(ctx *encoderCtx, t []altair.ParticipationFlags) (size int) + sizeFn7 func(ctx *encoderCtx, t []uint64) (size int) + sizeFn8 func(ctx *encoderCtx, t *deneb.ExecutionPayloadHeader) (size int) + sizeFn9 func(ctx *encoderCtx, t []*capella.HistoricalSummary) (size int) + } + ctx := &encoderCtx{ds: ds} + canSeek := enc.Seekable() + ctx.exprs[0], err = sszutils.ResolveSpecValueWithDefault(ds, "SLOTS_PER_HISTORICAL_ROOT", 8192) + if err != nil { + return err + } + ctx.exprs[1], err = sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_HISTORICAL_VECTOR", 65536) + if err != nil { + return err + } + ctx.exprs[2], err = sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_SLASHINGS_VECTOR", 8192) + if err != nil { + return err + } + ctx.exprs[3], err = sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE", 512) + if err != nil { + return err + } + ctx.exprs[4], err = sszutils.ResolveSpecValueWithDefault(ds, "(MIN_SEED_LOOKAHEAD+1)*SLOTS_PER_EPOCH", 64) + if err != nil { + return err + } + ctx.exprs[5], err = sszutils.ResolveSpecValueWithDefault(ds, "HISTORICAL_ROOTS_LIMIT", 16777216) + if err != nil { + return err + } + ctx.exprs[6], err = sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_ETH1_VOTING_PERIOD*SLOTS_PER_EPOCH", 2048) + if err != nil { + return err + } + ctx.exprs[7], err = sszutils.ResolveSpecValueWithDefault(ds, "VALIDATOR_REGISTRY_LIMIT", 1099511627776) + if err != nil { + return err + } + ctx.exprs[8], err = sszutils.ResolveSpecValueWithDefault(ds, "PENDING_DEPOSITS_LIMIT", 134217728) + if err != nil { + return err + } + ctx.exprs[9], err = sszutils.ResolveSpecValueWithDefault(ds, "PENDING_PARTIAL_WITHDRAWALS_LIMIT", 134217728) + if err != nil { + return err + } + ctx.exprs[10], err = sszutils.ResolveSpecValueWithDefault(ds, "PENDING_CONSOLIDATIONS_LIMIT", 262144) + if err != nil { + return err + } + // size for []phase0.Root + ctx.sizeFn1 = func(ctx *encoderCtx, t []phase0.Root) (size int) { + size += len(t) * 32 + return size + } + // size for []*phase0.ETH1Data + ctx.sizeFn2 = func(ctx *encoderCtx, t []*phase0.ETH1Data) (size int) { + size += len(t) * 72 + return size + } + // size for []*phase0.Validator + ctx.sizeFn3 = func(ctx *encoderCtx, t []*phase0.Validator) (size int) { + size += len(t) * 121 + return size + } + // size for []phase0.Gwei + ctx.sizeFn4 = func(ctx *encoderCtx, t []phase0.Gwei) (size int) { + size += len(t) * 8 + return size + } + // size for []altair.ParticipationFlags + ctx.sizeFn5 = func(ctx *encoderCtx, t []altair.ParticipationFlags) (size int) { + size += len(t) + return size + } + // size for []altair.ParticipationFlags + ctx.sizeFn6 = func(ctx *encoderCtx, t []altair.ParticipationFlags) (size int) { + size += len(t) + return size + } + // size for []uint64 + ctx.sizeFn7 = func(ctx *encoderCtx, t []uint64) (size int) { + size += len(t) * 8 + return size + } + // size for *deneb.ExecutionPayloadHeader + ctx.sizeFn8 = func(ctx *encoderCtx, t *deneb.ExecutionPayloadHeader) (size int) { + size += t.SizeSSZ() + return size + } + // size for []*capella.HistoricalSummary + ctx.sizeFn9 = func(ctx *encoderCtx, t []*capella.HistoricalSummary) (size int) { + size += len(t) * 64 + return size + } + // size for []*electra.PendingDeposit + ctx.sizeFn10 = func(ctx *encoderCtx, t []*electra.PendingDeposit) (size int) { + size += len(t) * 192 + return size + } + // size for []*electra.PendingPartialWithdrawal + ctx.sizeFn11 = func(ctx *encoderCtx, t []*electra.PendingPartialWithdrawal) (size int) { + size += len(t) * 24 + return size + } + // size for []*electra.PendingConsolidation + ctx.sizeFn12 = func(ctx *encoderCtx, t []*electra.PendingConsolidation) (size int) { + size += len(t) * 16 + return size + } + size1 := 32 * int(ctx.exprs[0]) + size2 := 32 * int(ctx.exprs[1]) + size3 := 8 * int(ctx.exprs[2]) + size5 := 48 * int(ctx.exprs[3]) + size4 := size5 + 48 // size expression for '*SyncCommittee' + size6 := 8 * int(ctx.exprs[4]) + if t == nil { + t = new(BeaconState) + } + dstlen := enc.GetPosition() + dynoff := uint32(size1 + size1 + size2 + size3 + size4 + size4 + size6 + 489) + { // Field #0 'GenesisTime' + enc.EncodeUint64(t.GenesisTime) + } + { // Field #1 'GenesisValidatorsRoot' + enc.EncodeBytes(t.GenesisValidatorsRoot[:32]) + } + { // Field #2 'Slot' + enc.EncodeUint64(uint64(t.Slot)) + } + { // Field #3 'Fork' + t := t.Fork + if t == nil { + t = new(phase0.Fork) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "Fork") + } else { + enc.SetBuffer(buf) + } + } + { // Field #4 'LatestBlockHeader' + t := t.LatestBlockHeader + if t == nil { + t = new(phase0.BeaconBlockHeader) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") + } else { + enc.SetBuffer(buf) + } + } + { // Field #5 'BlockRoots' + t := t.BlockRoots + vlen := len(t) + if vlen > int(ctx.exprs[0]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[0])), "BlockRoots") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:32]) + } + if vlen < int(ctx.exprs[0]) { + enc.EncodeZeroPadding((int(ctx.exprs[0]) - vlen) * 32) + } + } + { // Field #6 'StateRoots' + t := t.StateRoots + vlen := len(t) + if vlen > int(ctx.exprs[0]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[0])), "StateRoots") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:32]) + } + if vlen < int(ctx.exprs[0]) { + enc.EncodeZeroPadding((int(ctx.exprs[0]) - vlen) * 32) + } + } + // Offset #7 'HistoricalRoots' + offset7 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn1(ctx, t.HistoricalRoots)) + } + { // Field #8 'ETH1Data' + t := t.ETH1Data + if t == nil { + t = new(phase0.ETH1Data) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "ETH1Data") + } else { + enc.SetBuffer(buf) + } + } + // Offset #9 'ETH1DataVotes' + offset9 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn2(ctx, t.ETH1DataVotes)) + } + { // Field #10 'ETH1DepositIndex' + enc.EncodeUint64(t.ETH1DepositIndex) + } + // Offset #11 'Validators' + offset11 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn3(ctx, t.Validators)) + } + // Offset #12 'Balances' + offset12 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn4(ctx, t.Balances)) + } + { // Field #13 'RANDAOMixes' + t := t.RANDAOMixes + vlen := len(t) + if vlen > int(ctx.exprs[1]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[1])), "RANDAOMixes") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:32]) + } + if vlen < int(ctx.exprs[1]) { + enc.EncodeZeroPadding((int(ctx.exprs[1]) - vlen) * 32) + } + } + { // Field #14 'Slashings' + t := t.Slashings + vlen := len(t) + if vlen > int(ctx.exprs[2]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[2])), "Slashings") + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + if vlen < int(ctx.exprs[2]) { + enc.EncodeZeroPadding((int(ctx.exprs[2]) - vlen) * 8) + } + } + // Offset #15 'PreviousEpochParticipation' + offset15 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn5(ctx, t.PreviousEpochParticipation)) + } + // Offset #16 'CurrentEpochParticipation' + offset16 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn6(ctx, t.CurrentEpochParticipation)) + } + { // Field #17 'JustificationBits' + vlen := len(t.JustificationBits) + if vlen > 1 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 1), "JustificationBits") + } + enc.EncodeBytes(t.JustificationBits[:vlen]) + if vlen < 1 { + enc.EncodeZeroPadding((1 - vlen) * 1) + } + } + { // Field #18 'PreviousJustifiedCheckpoint' + t := t.PreviousJustifiedCheckpoint + if t == nil { + t = new(phase0.Checkpoint) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } else { + enc.SetBuffer(buf) + } + } + { // Field #19 'CurrentJustifiedCheckpoint' + t := t.CurrentJustifiedCheckpoint + if t == nil { + t = new(phase0.Checkpoint) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } else { + enc.SetBuffer(buf) + } + } + { // Field #20 'FinalizedCheckpoint' + t := t.FinalizedCheckpoint + if t == nil { + t = new(phase0.Checkpoint) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") + } else { + enc.SetBuffer(buf) + } + } + // Offset #21 'InactivityScores' + offset21 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn7(ctx, t.InactivityScores)) + } + { // Field #22 'CurrentSyncCommittee' + t := t.CurrentSyncCommittee + if t == nil { + t = new(altair.SyncCommittee) + } + { // Field #0 'Pubkeys' + t := t.Pubkeys + vlen := len(t) + if vlen > int(ctx.exprs[3]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[3])), "CurrentSyncCommittee.Pubkeys") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:48]) + } + if vlen < int(ctx.exprs[3]) { + enc.EncodeZeroPadding((int(ctx.exprs[3]) - vlen) * 48) + } + } + { // Field #1 'AggregatePubkey' + enc.EncodeBytes(t.AggregatePubkey[:48]) + } + } + { // Field #23 'NextSyncCommittee' + t := t.NextSyncCommittee + if t == nil { + t = new(altair.SyncCommittee) + } + { // Field #0 'Pubkeys' + t := t.Pubkeys + vlen := len(t) + if vlen > int(ctx.exprs[3]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[3])), "NextSyncCommittee.Pubkeys") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:48]) + } + if vlen < int(ctx.exprs[3]) { + enc.EncodeZeroPadding((int(ctx.exprs[3]) - vlen) * 48) + } + } + { // Field #1 'AggregatePubkey' + enc.EncodeBytes(t.AggregatePubkey[:48]) + } + } + // Offset #24 'LatestExecutionPayloadHeader' + offset24 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn8(ctx, t.LatestExecutionPayloadHeader)) + } + { // Field #25 'NextWithdrawalIndex' + enc.EncodeUint64(uint64(t.NextWithdrawalIndex)) + } + { // Field #26 'NextWithdrawalValidatorIndex' + enc.EncodeUint64(uint64(t.NextWithdrawalValidatorIndex)) + } + // Offset #27 'HistoricalSummaries' + offset27 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn9(ctx, t.HistoricalSummaries)) + } + { // Field #28 'DepositRequestsStartIndex' + enc.EncodeUint64(t.DepositRequestsStartIndex) + } + { // Field #29 'DepositBalanceToConsume' + enc.EncodeUint64(uint64(t.DepositBalanceToConsume)) + } + { // Field #30 'ExitBalanceToConsume' + enc.EncodeUint64(uint64(t.ExitBalanceToConsume)) + } + { // Field #31 'EarliestExitEpoch' + enc.EncodeUint64(uint64(t.EarliestExitEpoch)) + } + { // Field #32 'ConsolidationBalanceToConsume' + enc.EncodeUint64(uint64(t.ConsolidationBalanceToConsume)) + } + { // Field #33 'EarliestConsolidationEpoch' + enc.EncodeUint64(uint64(t.EarliestConsolidationEpoch)) + } + // Offset #34 'PendingDeposits' + offset34 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn10(ctx, t.PendingDeposits)) + } + // Offset #35 'PendingPartialWithdrawals' + offset35 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn11(ctx, t.PendingPartialWithdrawals)) + } + // Offset #36 'PendingConsolidations' + offset36 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn12(ctx, t.PendingConsolidations)) + } + { // Field #37 'ProposerLookahead' + t := t.ProposerLookahead + vlen := len(t) + if vlen > int(ctx.exprs[4]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[4])), "ProposerLookahead") + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + if vlen < int(ctx.exprs[4]) { + enc.EncodeZeroPadding((int(ctx.exprs[4]) - vlen) * 8) + } + } + { // Dynamic Field #7 'HistoricalRoots' + if canSeek { + enc.EncodeOffsetAt(offset7, uint32(enc.GetPosition()-dstlen)) + } + t := t.HistoricalRoots + vlen := len(t) + if vlen > int(ctx.exprs[5]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[5])), "HistoricalRoots") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:32]) + } + } + { // Dynamic Field #9 'ETH1DataVotes' + if canSeek { + enc.EncodeOffsetAt(offset9, uint32(enc.GetPosition()-dstlen)) + } + t := t.ETH1DataVotes + vlen := len(t) + if vlen > int(ctx.exprs[6]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[6])), "ETH1DataVotes") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(phase0.ETH1Data) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "ETH1DataVotes[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #11 'Validators' + if canSeek { + enc.EncodeOffsetAt(offset11, uint32(enc.GetPosition()-dstlen)) + } + t := t.Validators + vlen := len(t) + if vlen > int(ctx.exprs[7]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[7])), "Validators") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(phase0.Validator) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #12 'Balances' + if canSeek { + enc.EncodeOffsetAt(offset12, uint32(enc.GetPosition()-dstlen)) + } + t := t.Balances + vlen := len(t) + if vlen > int(ctx.exprs[7]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[7])), "Balances") + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + } + { // Dynamic Field #15 'PreviousEpochParticipation' + if canSeek { + enc.EncodeOffsetAt(offset15, uint32(enc.GetPosition()-dstlen)) + } + t := t.PreviousEpochParticipation + vlen := len(t) + if vlen > int(ctx.exprs[7]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[7])), "PreviousEpochParticipation") + } + for idx1 := range vlen { + enc.EncodeUint8(byte(t[idx1])) + } + } + { // Dynamic Field #16 'CurrentEpochParticipation' + if canSeek { + enc.EncodeOffsetAt(offset16, uint32(enc.GetPosition()-dstlen)) + } + t := t.CurrentEpochParticipation + vlen := len(t) + if vlen > int(ctx.exprs[7]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[7])), "CurrentEpochParticipation") + } + for idx1 := range vlen { + enc.EncodeUint8(byte(t[idx1])) + } + } + { // Dynamic Field #21 'InactivityScores' + if canSeek { + enc.EncodeOffsetAt(offset21, uint32(enc.GetPosition()-dstlen)) + } + t := t.InactivityScores + vlen := len(t) + if vlen > int(ctx.exprs[7]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[7])), "InactivityScores") + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + } + { // Dynamic Field #24 'LatestExecutionPayloadHeader' + if canSeek { + enc.EncodeOffsetAt(offset24, uint32(enc.GetPosition()-dstlen)) + } + t := t.LatestExecutionPayloadHeader + if t == nil { + t = new(deneb.ExecutionPayloadHeader) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "LatestExecutionPayloadHeader") + } else { + enc.SetBuffer(buf) + } + } + { // Dynamic Field #27 'HistoricalSummaries' + if canSeek { + enc.EncodeOffsetAt(offset27, uint32(enc.GetPosition()-dstlen)) + } + t := t.HistoricalSummaries + vlen := len(t) + if vlen > int(ctx.exprs[5]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[5])), "HistoricalSummaries") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(capella.HistoricalSummary) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "HistoricalSummaries[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #34 'PendingDeposits' + if canSeek { + enc.EncodeOffsetAt(offset34, uint32(enc.GetPosition()-dstlen)) + } + t := t.PendingDeposits + vlen := len(t) + if vlen > int(ctx.exprs[8]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[8])), "PendingDeposits") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(electra.PendingDeposit) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "PendingDeposits[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #35 'PendingPartialWithdrawals' + if canSeek { + enc.EncodeOffsetAt(offset35, uint32(enc.GetPosition()-dstlen)) + } + t := t.PendingPartialWithdrawals + vlen := len(t) + if vlen > int(ctx.exprs[9]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[9])), "PendingPartialWithdrawals") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(electra.PendingPartialWithdrawal) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "PendingPartialWithdrawals[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #36 'PendingConsolidations' + if canSeek { + enc.EncodeOffsetAt(offset36, uint32(enc.GetPosition()-dstlen)) + } + t := t.PendingConsolidations + vlen := len(t) + if vlen > int(ctx.exprs[10]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[10])), "PendingConsolidations") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(electra.PendingConsolidation) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "PendingConsolidations[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + return nil +} + // UnmarshalSSZ unmarshals the *BeaconState from SSZ-encoded bytes. func (t *BeaconState) UnmarshalSSZ(buf []byte) (err error) { buflen := len(buf) @@ -848,6 +1500,762 @@ func (t *BeaconState) UnmarshalSSZ(buf []byte) (err error) { return nil } +// UnmarshalSSZDecoder unmarshals the *BeaconState from the given SSZ decoder using dynamic specifications. +func (t *BeaconState) UnmarshalSSZDecoder(ds sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { + expr0, err := sszutils.ResolveSpecValueWithDefault(ds, "SLOTS_PER_HISTORICAL_ROOT", 8192) + if err != nil { + return err + } + expr1, err := sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_HISTORICAL_VECTOR", 65536) + if err != nil { + return err + } + expr2, err := sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_SLASHINGS_VECTOR", 8192) + if err != nil { + return err + } + expr3, err := sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE", 512) + if err != nil { + return err + } + expr4, err := sszutils.ResolveSpecValueWithDefault(ds, "(MIN_SEED_LOOKAHEAD+1)*SLOTS_PER_EPOCH", 64) + if err != nil { + return err + } + expr5, err := sszutils.ResolveSpecValueWithDefault(ds, "HISTORICAL_ROOTS_LIMIT", 16777216) + if err != nil { + return err + } + expr6, err := sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_ETH1_VOTING_PERIOD*SLOTS_PER_EPOCH", 2048) + if err != nil { + return err + } + expr7, err := sszutils.ResolveSpecValueWithDefault(ds, "VALIDATOR_REGISTRY_LIMIT", 1099511627776) + if err != nil { + return err + } + expr8, err := sszutils.ResolveSpecValueWithDefault(ds, "PENDING_DEPOSITS_LIMIT", 134217728) + if err != nil { + return err + } + expr9, err := sszutils.ResolveSpecValueWithDefault(ds, "PENDING_PARTIAL_WITHDRAWALS_LIMIT", 134217728) + if err != nil { + return err + } + expr10, err := sszutils.ResolveSpecValueWithDefault(ds, "PENDING_CONSOLIDATIONS_LIMIT", 262144) + if err != nil { + return err + } + size1 := 32 * int(expr0) + size2 := 32 * int(expr1) + size3 := 8 * int(expr2) + size5 := 48 * int(expr3) + size4 := size5 + 48 // size expression for '*SyncCommittee' + size6 := 8 * int(expr4) + totalSize := size1+size1+size2+size3+size4+size4+size6+489 + maxOffset := uint32(dec.GetLength()) + startPos0 := dec.GetPosition() + if maxOffset < uint32(totalSize) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(totalSize)) + } + // Field #0 'GenesisTime' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "GenesisTime") + } else { + t.GenesisTime = val + } + // Field #1 'GenesisValidatorsRoot' (static) + if _, err = dec.DecodeBytes(t.GenesisValidatorsRoot[:32]); err != nil { + return err + } + // Field #2 'Slot' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "Slot") + } else { + t.Slot = phase0.Slot(val) + } + // Field #3 'Fork' (static) + if t.Fork == nil { + t.Fork = new(phase0.Fork) + } + if buf, err := dec.DecodeBytesBuf(16); err != nil { + return sszutils.ErrorWithPath(err, "Fork") + } else if err = t.Fork.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "Fork") + } + // Field #4 'LatestBlockHeader' (static) + if t.LatestBlockHeader == nil { + t.LatestBlockHeader = new(phase0.BeaconBlockHeader) + } + if buf, err := dec.DecodeBytesBuf(112); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") + } else if err = t.LatestBlockHeader.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") + } + { // Field #5 'BlockRoots' (static) + val1 := t.BlockRoots + val1 = sszutils.ExpandSlice(val1, int(expr0)) + startPos1 := dec.GetPosition() + for idx1 := range int(expr0) { + if _, err = dec.DecodeBytes(val1[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos1+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos1+int(32*(idx1+1))), "BlockRoots[%d]", idx1) + } + } + t.BlockRoots = val1 + } + { // Field #6 'StateRoots' (static) + val2 := t.StateRoots + val2 = sszutils.ExpandSlice(val2, int(expr0)) + startPos2 := dec.GetPosition() + for idx1 := range int(expr0) { + if _, err = dec.DecodeBytes(val2[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos2+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos2+int(32*(idx1+1))), "StateRoots[%d]", idx1) + } + } + t.StateRoots = val2 + } + // Field #7 'HistoricalRoots' (offset) + offset7, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "HistoricalRoots") + } + if offset7 != uint32(totalSize) { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset7, totalSize), "HistoricalRoots") + } + // Field #8 'ETH1Data' (static) + if t.ETH1Data == nil { + t.ETH1Data = new(phase0.ETH1Data) + } + if buf, err := dec.DecodeBytesBuf(72); err != nil { + return sszutils.ErrorWithPath(err, "ETH1Data") + } else if err = t.ETH1Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "ETH1Data") + } + // Field #9 'ETH1DataVotes' (offset) + offset9, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "ETH1DataVotes") + } + if offset9 < offset7 || offset9 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset9, offset7, maxOffset), "ETH1DataVotes") + } + // Field #10 'ETH1DepositIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "ETH1DepositIndex") + } else { + t.ETH1DepositIndex = val + } + // Field #11 'Validators' (offset) + offset11, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Validators") + } + if offset11 < offset9 || offset11 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset11, offset9, maxOffset), "Validators") + } + // Field #12 'Balances' (offset) + offset12, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Balances") + } + if offset12 < offset11 || offset12 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset12, offset11, maxOffset), "Balances") + } + { // Field #13 'RANDAOMixes' (static) + val3 := t.RANDAOMixes + val3 = sszutils.ExpandSlice(val3, int(expr1)) + startPos3 := dec.GetPosition() + for idx1 := range int(expr1) { + if _, err = dec.DecodeBytes(val3[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos3+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos3+int(32*(idx1+1))), "RANDAOMixes[%d]", idx1) + } + } + t.RANDAOMixes = val3 + } + { // Field #14 'Slashings' (static) + val4 := t.Slashings + val4 = sszutils.ExpandSlice(val4, int(expr2)) + if err = sszutils.DecodeUint64Slice(dec, val4[:int(expr2)]); err != nil { + return sszutils.ErrorWithPath(err, "Slashings") + } + t.Slashings = val4 + } + // Field #15 'PreviousEpochParticipation' (offset) + offset15, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "PreviousEpochParticipation") + } + if offset15 < offset12 || offset15 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset15, offset12, maxOffset), "PreviousEpochParticipation") + } + // Field #16 'CurrentEpochParticipation' (offset) + offset16, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "CurrentEpochParticipation") + } + if offset16 < offset15 || offset16 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset16, offset15, maxOffset), "CurrentEpochParticipation") + } + // Field #17 'JustificationBits' (static) + t.JustificationBits = sszutils.ExpandSlice(t.JustificationBits, 1) + if _, err = dec.DecodeBytes(t.JustificationBits[:1]); err != nil { + return err + } + // Field #18 'PreviousJustifiedCheckpoint' (static) + if t.PreviousJustifiedCheckpoint == nil { + t.PreviousJustifiedCheckpoint = new(phase0.Checkpoint) + } + if buf, err := dec.DecodeBytesBuf(40); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } else if err = t.PreviousJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } + // Field #19 'CurrentJustifiedCheckpoint' (static) + if t.CurrentJustifiedCheckpoint == nil { + t.CurrentJustifiedCheckpoint = new(phase0.Checkpoint) + } + if buf, err := dec.DecodeBytesBuf(40); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } else if err = t.CurrentJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } + // Field #20 'FinalizedCheckpoint' (static) + if t.FinalizedCheckpoint == nil { + t.FinalizedCheckpoint = new(phase0.Checkpoint) + } + if buf, err := dec.DecodeBytesBuf(40); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") + } else if err = t.FinalizedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") + } + // Field #21 'InactivityScores' (offset) + offset21, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "InactivityScores") + } + if offset21 < offset16 || offset21 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset21, offset16, maxOffset), "InactivityScores") + } + { // Field #22 'CurrentSyncCommittee' (static) + val5 := t.CurrentSyncCommittee + if val5 == nil { + val5 = new(altair.SyncCommittee) + } + totalSize := size5+48 + maxOffset := uint32(dec.GetLength()) + if maxOffset < uint32(totalSize) { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(totalSize)), "CurrentSyncCommittee") + } + { // Field #0 'Pubkeys' (static) + val6 := val5.Pubkeys + val6 = sszutils.ExpandSlice(val6, int(expr3)) + startPos4 := dec.GetPosition() + for idx1 := range int(expr3) { + if _, err = dec.DecodeBytes(val6[idx1][:48]); err != nil { + return err + } + if dec.GetPosition() != startPos4+int(48*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos4+int(48*(idx1+1))), "CurrentSyncCommittee.Pubkeys[%d]", idx1) + } + } + val5.Pubkeys = val6 + } + // Field #1 'AggregatePubkey' (static) + if _, err = dec.DecodeBytes(val5.AggregatePubkey[:48]); err != nil { + return err + } + t.CurrentSyncCommittee = val5 + } + { // Field #23 'NextSyncCommittee' (static) + val7 := t.NextSyncCommittee + if val7 == nil { + val7 = new(altair.SyncCommittee) + } + totalSize := size5+48 + maxOffset := uint32(dec.GetLength()) + if maxOffset < uint32(totalSize) { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(totalSize)), "NextSyncCommittee") + } + { // Field #0 'Pubkeys' (static) + val8 := val7.Pubkeys + val8 = sszutils.ExpandSlice(val8, int(expr3)) + startPos5 := dec.GetPosition() + for idx1 := range int(expr3) { + if _, err = dec.DecodeBytes(val8[idx1][:48]); err != nil { + return err + } + if dec.GetPosition() != startPos5+int(48*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos5+int(48*(idx1+1))), "NextSyncCommittee.Pubkeys[%d]", idx1) + } + } + val7.Pubkeys = val8 + } + // Field #1 'AggregatePubkey' (static) + if _, err = dec.DecodeBytes(val7.AggregatePubkey[:48]); err != nil { + return err + } + t.NextSyncCommittee = val7 + } + // Field #24 'LatestExecutionPayloadHeader' (offset) + offset24, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "LatestExecutionPayloadHeader") + } + if offset24 < offset21 || offset24 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset24, offset21, maxOffset), "LatestExecutionPayloadHeader") + } + // Field #25 'NextWithdrawalIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "NextWithdrawalIndex") + } else { + t.NextWithdrawalIndex = capella.WithdrawalIndex(val) + } + // Field #26 'NextWithdrawalValidatorIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "NextWithdrawalValidatorIndex") + } else { + t.NextWithdrawalValidatorIndex = phase0.ValidatorIndex(val) + } + // Field #27 'HistoricalSummaries' (offset) + offset27, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "HistoricalSummaries") + } + if offset27 < offset24 || offset27 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset27, offset24, maxOffset), "HistoricalSummaries") + } + // Field #28 'DepositRequestsStartIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "DepositRequestsStartIndex") + } else { + t.DepositRequestsStartIndex = val + } + // Field #29 'DepositBalanceToConsume' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "DepositBalanceToConsume") + } else { + t.DepositBalanceToConsume = phase0.Gwei(val) + } + // Field #30 'ExitBalanceToConsume' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "ExitBalanceToConsume") + } else { + t.ExitBalanceToConsume = phase0.Gwei(val) + } + // Field #31 'EarliestExitEpoch' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "EarliestExitEpoch") + } else { + t.EarliestExitEpoch = phase0.Epoch(val) + } + // Field #32 'ConsolidationBalanceToConsume' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "ConsolidationBalanceToConsume") + } else { + t.ConsolidationBalanceToConsume = phase0.Gwei(val) + } + // Field #33 'EarliestConsolidationEpoch' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "EarliestConsolidationEpoch") + } else { + t.EarliestConsolidationEpoch = phase0.Epoch(val) + } + // Field #34 'PendingDeposits' (offset) + offset34, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "PendingDeposits") + } + if offset34 < offset27 || offset34 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset34, offset27, maxOffset), "PendingDeposits") + } + // Field #35 'PendingPartialWithdrawals' (offset) + offset35, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "PendingPartialWithdrawals") + } + if offset35 < offset34 || offset35 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset35, offset34, maxOffset), "PendingPartialWithdrawals") + } + // Field #36 'PendingConsolidations' (offset) + offset36, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "PendingConsolidations") + } + if offset36 < offset35 || offset36 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset36, offset35, maxOffset), "PendingConsolidations") + } + { // Field #37 'ProposerLookahead' (static) + val9 := t.ProposerLookahead + val9 = sszutils.ExpandSlice(val9, int(expr4)) + if err = sszutils.DecodeUint64Slice(dec, val9[:int(expr4)]); err != nil { + return sszutils.ErrorWithPath(err, "ProposerLookahead") + } + t.ProposerLookahead = val9 + } + { // Field #7 'HistoricalRoots' (dynamic) + if dec.GetPosition() != startPos0+int(offset7) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset7)), "HistoricalRoots") + } + dec.PushLimit(int(offset9 - offset7)) + val10 := t.HistoricalRoots + sszLen := dec.GetLength() + itemCount := sszLen / 32 + if sszLen%32 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 32), "HistoricalRoots") + } + if itemCount > int(expr5) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr5)), "HistoricalRoots") + } + val10 = sszutils.ExpandSlice(val10, itemCount) + startPos6 := dec.GetPosition() + for idx1 := range itemCount { + if _, err = dec.DecodeBytes(val10[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos6+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos6+int(32*(idx1+1))), "HistoricalRoots[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "HistoricalRoots") + } + t.HistoricalRoots = val10 + } + { // Field #9 'ETH1DataVotes' (dynamic) + if dec.GetPosition() != startPos0+int(offset9) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset9)), "ETH1DataVotes") + } + dec.PushLimit(int(offset11 - offset9)) + val11 := t.ETH1DataVotes + sszLen := dec.GetLength() + itemCount := sszLen / 72 + if sszLen%72 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 72), "ETH1DataVotes") + } + if itemCount > int(expr6) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "ETH1DataVotes") + } + val11 = sszutils.ExpandSlice(val11, itemCount) + startPos7 := dec.GetPosition() + for idx1 := range itemCount { + if val11[idx1] == nil { + val11[idx1] = new(phase0.ETH1Data) + } + if buf, err := dec.DecodeBytesBuf(72); err != nil { + return sszutils.ErrorWithPathf(err, "ETH1DataVotes[%d]", idx1) + } else if err = val11[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "ETH1DataVotes[%d]", idx1) + } + if dec.GetPosition() != startPos7+int(72*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos7+int(72*(idx1+1))), "ETH1DataVotes[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "ETH1DataVotes") + } + t.ETH1DataVotes = val11 + } + { // Field #11 'Validators' (dynamic) + if dec.GetPosition() != startPos0+int(offset11) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset11)), "Validators") + } + dec.PushLimit(int(offset12 - offset11)) + val12 := t.Validators + sszLen := dec.GetLength() + itemCount := sszLen / 121 + if sszLen%121 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 121), "Validators") + } + if itemCount > int(expr7) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr7)), "Validators") + } + val12 = sszutils.ExpandSlice(val12, itemCount) + startPos8 := dec.GetPosition() + for idx1 := range itemCount { + if val12[idx1] == nil { + val12[idx1] = new(phase0.Validator) + } + if buf, err := dec.DecodeBytesBuf(121); err != nil { + return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } else if err = val12[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } + if dec.GetPosition() != startPos8+int(121*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos8+int(121*(idx1+1))), "Validators[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Validators") + } + t.Validators = val12 + } + { // Field #12 'Balances' (dynamic) + if dec.GetPosition() != startPos0+int(offset12) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset12)), "Balances") + } + dec.PushLimit(int(offset15 - offset12)) + val13 := t.Balances + sszLen := dec.GetLength() + itemCount := sszLen / 8 + if sszLen%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 8), "Balances") + } + if itemCount > int(expr7) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr7)), "Balances") + } + val13 = sszutils.ExpandSlice(val13, itemCount) + if err = sszutils.DecodeUint64Slice(dec, val13); err != nil { + return sszutils.ErrorWithPath(err, "Balances") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Balances") + } + t.Balances = val13 + } + { // Field #15 'PreviousEpochParticipation' (dynamic) + if dec.GetPosition() != startPos0+int(offset15) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset15)), "PreviousEpochParticipation") + } + dec.PushLimit(int(offset16 - offset15)) + val14 := t.PreviousEpochParticipation + itemCount := dec.GetLength() + if itemCount > int(expr7) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr7)), "PreviousEpochParticipation") + } + val14 = sszutils.ExpandSlice(val14, itemCount) + startPos9 := dec.GetPosition() + for idx1 := range itemCount { + if val, err := dec.DecodeUint8(); err != nil { + return sszutils.ErrorWithPathf(err, "PreviousEpochParticipation[%d]", idx1) + } else { + val14[idx1] = altair.ParticipationFlags(val) + } + if dec.GetPosition() != startPos9+int(1*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos9+int(1*(idx1+1))), "PreviousEpochParticipation[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "PreviousEpochParticipation") + } + t.PreviousEpochParticipation = val14 + } + { // Field #16 'CurrentEpochParticipation' (dynamic) + if dec.GetPosition() != startPos0+int(offset16) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset16)), "CurrentEpochParticipation") + } + dec.PushLimit(int(offset21 - offset16)) + val15 := t.CurrentEpochParticipation + itemCount := dec.GetLength() + if itemCount > int(expr7) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr7)), "CurrentEpochParticipation") + } + val15 = sszutils.ExpandSlice(val15, itemCount) + startPos10 := dec.GetPosition() + for idx1 := range itemCount { + if val, err := dec.DecodeUint8(); err != nil { + return sszutils.ErrorWithPathf(err, "CurrentEpochParticipation[%d]", idx1) + } else { + val15[idx1] = altair.ParticipationFlags(val) + } + if dec.GetPosition() != startPos10+int(1*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos10+int(1*(idx1+1))), "CurrentEpochParticipation[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "CurrentEpochParticipation") + } + t.CurrentEpochParticipation = val15 + } + { // Field #21 'InactivityScores' (dynamic) + if dec.GetPosition() != startPos0+int(offset21) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset21)), "InactivityScores") + } + dec.PushLimit(int(offset24 - offset21)) + val16 := t.InactivityScores + sszLen := dec.GetLength() + itemCount := sszLen / 8 + if sszLen%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 8), "InactivityScores") + } + if itemCount > int(expr7) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr7)), "InactivityScores") + } + val16 = sszutils.ExpandSlice(val16, itemCount) + if err = sszutils.DecodeUint64Slice(dec, val16); err != nil { + return sszutils.ErrorWithPath(err, "InactivityScores") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "InactivityScores") + } + t.InactivityScores = val16 + } + { // Field #24 'LatestExecutionPayloadHeader' (dynamic) + if dec.GetPosition() != startPos0+int(offset24) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset24)), "LatestExecutionPayloadHeader") + } + dec.PushLimit(int(offset27 - offset24)) + val17 := t.LatestExecutionPayloadHeader + if val17 == nil { + val17 = new(deneb.ExecutionPayloadHeader) + } + if buf, err := dec.DecodeBytesBuf(dec.GetLength()); err != nil { + return sszutils.ErrorWithPath(err, "LatestExecutionPayloadHeader") + } else if err = val17.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "LatestExecutionPayloadHeader") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "LatestExecutionPayloadHeader") + } + t.LatestExecutionPayloadHeader = val17 + } + { // Field #27 'HistoricalSummaries' (dynamic) + if dec.GetPosition() != startPos0+int(offset27) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset27)), "HistoricalSummaries") + } + dec.PushLimit(int(offset34 - offset27)) + val18 := t.HistoricalSummaries + sszLen := dec.GetLength() + itemCount := sszLen / 64 + if sszLen%64 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 64), "HistoricalSummaries") + } + if itemCount > int(expr5) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr5)), "HistoricalSummaries") + } + val18 = sszutils.ExpandSlice(val18, itemCount) + startPos11 := dec.GetPosition() + for idx1 := range itemCount { + if val18[idx1] == nil { + val18[idx1] = new(capella.HistoricalSummary) + } + if buf, err := dec.DecodeBytesBuf(64); err != nil { + return sszutils.ErrorWithPathf(err, "HistoricalSummaries[%d]", idx1) + } else if err = val18[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "HistoricalSummaries[%d]", idx1) + } + if dec.GetPosition() != startPos11+int(64*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos11+int(64*(idx1+1))), "HistoricalSummaries[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "HistoricalSummaries") + } + t.HistoricalSummaries = val18 + } + { // Field #34 'PendingDeposits' (dynamic) + if dec.GetPosition() != startPos0+int(offset34) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset34)), "PendingDeposits") + } + dec.PushLimit(int(offset35 - offset34)) + val19 := t.PendingDeposits + sszLen := dec.GetLength() + itemCount := sszLen / 192 + if sszLen%192 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 192), "PendingDeposits") + } + if itemCount > int(expr8) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr8)), "PendingDeposits") + } + val19 = sszutils.ExpandSlice(val19, itemCount) + startPos12 := dec.GetPosition() + for idx1 := range itemCount { + if val19[idx1] == nil { + val19[idx1] = new(electra.PendingDeposit) + } + if buf, err := dec.DecodeBytesBuf(192); err != nil { + return sszutils.ErrorWithPathf(err, "PendingDeposits[%d]", idx1) + } else if err = val19[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "PendingDeposits[%d]", idx1) + } + if dec.GetPosition() != startPos12+int(192*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos12+int(192*(idx1+1))), "PendingDeposits[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "PendingDeposits") + } + t.PendingDeposits = val19 + } + { // Field #35 'PendingPartialWithdrawals' (dynamic) + if dec.GetPosition() != startPos0+int(offset35) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset35)), "PendingPartialWithdrawals") + } + dec.PushLimit(int(offset36 - offset35)) + val20 := t.PendingPartialWithdrawals + sszLen := dec.GetLength() + itemCount := sszLen / 24 + if sszLen%24 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 24), "PendingPartialWithdrawals") + } + if itemCount > int(expr9) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr9)), "PendingPartialWithdrawals") + } + val20 = sszutils.ExpandSlice(val20, itemCount) + startPos13 := dec.GetPosition() + for idx1 := range itemCount { + if val20[idx1] == nil { + val20[idx1] = new(electra.PendingPartialWithdrawal) + } + if buf, err := dec.DecodeBytesBuf(24); err != nil { + return sszutils.ErrorWithPathf(err, "PendingPartialWithdrawals[%d]", idx1) + } else if err = val20[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "PendingPartialWithdrawals[%d]", idx1) + } + if dec.GetPosition() != startPos13+int(24*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos13+int(24*(idx1+1))), "PendingPartialWithdrawals[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "PendingPartialWithdrawals") + } + t.PendingPartialWithdrawals = val20 + } + { // Field #36 'PendingConsolidations' (dynamic) + if dec.GetPosition() != startPos0+int(offset36) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset36)), "PendingConsolidations") + } + dec.PushLimit(int(maxOffset - offset36)) + val21 := t.PendingConsolidations + sszLen := dec.GetLength() + itemCount := sszLen / 16 + if sszLen%16 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 16), "PendingConsolidations") + } + if itemCount > int(expr10) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr10)), "PendingConsolidations") + } + val21 = sszutils.ExpandSlice(val21, itemCount) + startPos14 := dec.GetPosition() + for idx1 := range itemCount { + if val21[idx1] == nil { + val21[idx1] = new(electra.PendingConsolidation) + } + if buf, err := dec.DecodeBytesBuf(16); err != nil { + return sszutils.ErrorWithPathf(err, "PendingConsolidations[%d]", idx1) + } else if err = val21[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "PendingConsolidations[%d]", idx1) + } + if dec.GetPosition() != startPos14+int(16*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos14+int(16*(idx1+1))), "PendingConsolidations[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "PendingConsolidations") + } + t.PendingConsolidations = val21 + } + return nil +} + // SizeSSZ returns the SSZ encoded size of the *BeaconState. func (t *BeaconState) SizeSSZ() (size int) { if t == nil { diff --git a/spec/fulu/generate.yaml b/spec/fulu/generate.yaml index 7ed04200..cfa73bce 100644 --- a/spec/fulu/generate.yaml +++ b/spec/fulu/generate.yaml @@ -5,3 +5,4 @@ without-dynamic-expressions: true types: - name: BeaconState output: beaconstate_ssz.go + with-streaming: true diff --git a/spec/gloas/beaconstate_ssz.go b/spec/gloas/beaconstate_ssz.go index 8e3d4dcd..0e963c3d 100644 --- a/spec/gloas/beaconstate_ssz.go +++ b/spec/gloas/beaconstate_ssz.go @@ -1,5 +1,5 @@ // Code generated by dynamic-ssz. DO NOT EDIT. -// Hash: 2450ed495344616c6c988b50db98e2243bcb3627719bd885f1687ba1049d3c1e +// Hash: 414842dd5f71e392ab621cd732c34343953fdbecc308ee9b0197db2bb3fe0b8e // Version: v1.3.1 (https://github.com/pk910/dynamic-ssz) package gloas @@ -506,576 +506,2372 @@ func (t *BeaconState) MarshalSSZTo(buf []byte) (dst []byte, err error) { return dst, nil } +// MarshalSSZEncoder marshals the *BeaconState to the given SSZ encoder using dynamic specifications. +func (t *BeaconState) MarshalSSZEncoder(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + type encoderCtx struct { + ds sszutils.DynamicSpecs + exprs [16]uint64 + sizeFn1 func(ctx *encoderCtx, t []phase0.Root) (size int) + sizeFn10 func(ctx *encoderCtx, t []*electra.PendingPartialWithdrawal) (size int) + sizeFn11 func(ctx *encoderCtx, t []*electra.PendingConsolidation) (size int) + sizeFn12 func(ctx *encoderCtx, t []*Builder) (size int) + sizeFn13 func(ctx *encoderCtx, t []*BuilderPendingWithdrawal) (size int) + sizeFn14 func(ctx *encoderCtx, t *ExecutionPayloadBid) (size int) + sizeFn15 func(ctx *encoderCtx, t []*capella.Withdrawal) (size int) + sizeFn2 func(ctx *encoderCtx, t []*phase0.ETH1Data) (size int) + sizeFn3 func(ctx *encoderCtx, t []*phase0.Validator) (size int) + sizeFn4 func(ctx *encoderCtx, t []phase0.Gwei) (size int) + sizeFn5 func(ctx *encoderCtx, t []altair.ParticipationFlags) (size int) + sizeFn6 func(ctx *encoderCtx, t []altair.ParticipationFlags) (size int) + sizeFn7 func(ctx *encoderCtx, t []uint64) (size int) + sizeFn8 func(ctx *encoderCtx, t []*capella.HistoricalSummary) (size int) + sizeFn9 func(ctx *encoderCtx, t []*electra.PendingDeposit) (size int) + } + ctx := &encoderCtx{ds: ds} + canSeek := enc.Seekable() + ctx.exprs[0], err = sszutils.ResolveSpecValueWithDefault(ds, "SLOTS_PER_HISTORICAL_ROOT", 8192) + if err != nil { + return err + } + ctx.exprs[1], err = sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_HISTORICAL_VECTOR", 65536) + if err != nil { + return err + } + ctx.exprs[2], err = sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_SLASHINGS_VECTOR", 8192) + if err != nil { + return err + } + ctx.exprs[3], err = sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE", 512) + if err != nil { + return err + } + ctx.exprs[4], err = sszutils.ResolveSpecValueWithDefault(ds, "(MIN_SEED_LOOKAHEAD+1)*SLOTS_PER_EPOCH", 64) + if err != nil { + return err + } + ctx.exprs[5], err = sszutils.ResolveSpecValueWithDefault(ds, "SLOTS_PER_HISTORICAL_ROOT/8", 1024) + if err != nil { + return err + } + ctx.exprs[6], err = sszutils.ResolveSpecValueWithDefault(ds, "SLOTS_PER_EPOCH*2", 64) + if err != nil { + return err + } + ctx.exprs[7], err = sszutils.ResolveSpecValueWithDefault(ds, "PTC_SIZE", 512) + if err != nil { + return err + } + ctx.exprs[8], err = sszutils.ResolveSpecValueWithDefault(ds, "(2+MIN_SEED_LOOKAHEAD)*SLOTS_PER_EPOCH", 96) + if err != nil { + return err + } + ctx.exprs[9], err = sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_ETH1_VOTING_PERIOD*SLOTS_PER_EPOCH", 2048) + if err != nil { + return err + } + ctx.exprs[10], err = sszutils.ResolveSpecValueWithDefault(ds, "PENDING_DEPOSITS_LIMIT", 134217728) + if err != nil { + return err + } + ctx.exprs[11], err = sszutils.ResolveSpecValueWithDefault(ds, "PENDING_PARTIAL_WITHDRAWALS_LIMIT", 134217728) + if err != nil { + return err + } + ctx.exprs[12], err = sszutils.ResolveSpecValueWithDefault(ds, "PENDING_CONSOLIDATIONS_LIMIT", 262144) + if err != nil { + return err + } + ctx.exprs[13], err = sszutils.ResolveSpecValueWithDefault(ds, "BUILDER_REGISTRY_LIMIT", 1099511627776) + if err != nil { + return err + } + ctx.exprs[14], err = sszutils.ResolveSpecValueWithDefault(ds, "BUILDER_PENDING_WITHDRAWALS_LIMIT", 1048576) + if err != nil { + return err + } + ctx.exprs[15], err = sszutils.ResolveSpecValueWithDefault(ds, "MAX_WITHDRAWALS_PER_PAYLOAD", 16) + if err != nil { + return err + } + // size for []phase0.Root + ctx.sizeFn1 = func(ctx *encoderCtx, t []phase0.Root) (size int) { + size += len(t) * 32 + return size + } + // size for []*phase0.ETH1Data + ctx.sizeFn2 = func(ctx *encoderCtx, t []*phase0.ETH1Data) (size int) { + size += len(t) * 72 + return size + } + // size for []*phase0.Validator + ctx.sizeFn3 = func(ctx *encoderCtx, t []*phase0.Validator) (size int) { + size += len(t) * 121 + return size + } + // size for []phase0.Gwei + ctx.sizeFn4 = func(ctx *encoderCtx, t []phase0.Gwei) (size int) { + size += len(t) * 8 + return size + } + // size for []altair.ParticipationFlags + ctx.sizeFn5 = func(ctx *encoderCtx, t []altair.ParticipationFlags) (size int) { + size += len(t) + return size + } + // size for []altair.ParticipationFlags + ctx.sizeFn6 = func(ctx *encoderCtx, t []altair.ParticipationFlags) (size int) { + size += len(t) + return size + } + // size for []uint64 + ctx.sizeFn7 = func(ctx *encoderCtx, t []uint64) (size int) { + size += len(t) * 8 + return size + } + // size for []*capella.HistoricalSummary + ctx.sizeFn8 = func(ctx *encoderCtx, t []*capella.HistoricalSummary) (size int) { + size += len(t) * 64 + return size + } + // size for []*electra.PendingDeposit + ctx.sizeFn9 = func(ctx *encoderCtx, t []*electra.PendingDeposit) (size int) { + size += len(t) * 192 + return size + } + // size for []*electra.PendingPartialWithdrawal + ctx.sizeFn10 = func(ctx *encoderCtx, t []*electra.PendingPartialWithdrawal) (size int) { + size += len(t) * 24 + return size + } + // size for []*electra.PendingConsolidation + ctx.sizeFn11 = func(ctx *encoderCtx, t []*electra.PendingConsolidation) (size int) { + size += len(t) * 16 + return size + } + // size for []*Builder + ctx.sizeFn12 = func(ctx *encoderCtx, t []*Builder) (size int) { + size += len(t) * 93 + return size + } + // size for []*BuilderPendingWithdrawal + ctx.sizeFn13 = func(ctx *encoderCtx, t []*BuilderPendingWithdrawal) (size int) { + size += len(t) * 36 + return size + } + // size for *ExecutionPayloadBid + ctx.sizeFn14 = func(ctx *encoderCtx, t *ExecutionPayloadBid) (size int) { + size += t.SizeSSZ() + return size + } + // size for []*capella.Withdrawal + ctx.sizeFn15 = func(ctx *encoderCtx, t []*capella.Withdrawal) (size int) { + size += len(t) * 44 + return size + } + size1 := 32 * int(ctx.exprs[0]) + size2 := 32 * int(ctx.exprs[1]) + size3 := 8 * int(ctx.exprs[2]) + size5 := 48 * int(ctx.exprs[3]) + size4 := size5 + 48 // size expression for '*SyncCommittee' + size6 := 8 * int(ctx.exprs[4]) + size7 := 1 * int(ctx.exprs[5]) + size8 := 44 * int(ctx.exprs[6]) + size10 := 8 * int(ctx.exprs[7]) + size9 := size10 * int(ctx.exprs[8]) + if t == nil { + t = new(BeaconState) + } + dstlen := enc.GetPosition() + dynoff := uint32(size1 + size1 + size2 + size3 + size4 + size4 + size6 + size7 + size8 + size9 + 541) + { // Field #0 'GenesisTime' + enc.EncodeUint64(t.GenesisTime) + } + { // Field #1 'GenesisValidatorsRoot' + enc.EncodeBytes(t.GenesisValidatorsRoot[:32]) + } + { // Field #2 'Slot' + enc.EncodeUint64(uint64(t.Slot)) + } + { // Field #3 'Fork' + t := t.Fork + if t == nil { + t = new(phase0.Fork) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "Fork") + } else { + enc.SetBuffer(buf) + } + } + { // Field #4 'LatestBlockHeader' + t := t.LatestBlockHeader + if t == nil { + t = new(phase0.BeaconBlockHeader) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") + } else { + enc.SetBuffer(buf) + } + } + { // Field #5 'BlockRoots' + t := t.BlockRoots + vlen := len(t) + if vlen > int(ctx.exprs[0]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[0])), "BlockRoots") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:32]) + } + if vlen < int(ctx.exprs[0]) { + enc.EncodeZeroPadding((int(ctx.exprs[0]) - vlen) * 32) + } + } + { // Field #6 'StateRoots' + t := t.StateRoots + vlen := len(t) + if vlen > int(ctx.exprs[0]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[0])), "StateRoots") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:32]) + } + if vlen < int(ctx.exprs[0]) { + enc.EncodeZeroPadding((int(ctx.exprs[0]) - vlen) * 32) + } + } + // Offset #7 'HistoricalRoots' + offset7 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn1(ctx, t.HistoricalRoots)) + } + { // Field #8 'ETH1Data' + t := t.ETH1Data + if t == nil { + t = new(phase0.ETH1Data) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "ETH1Data") + } else { + enc.SetBuffer(buf) + } + } + // Offset #9 'ETH1DataVotes' + offset9 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn2(ctx, t.ETH1DataVotes)) + } + { // Field #10 'ETH1DepositIndex' + enc.EncodeUint64(t.ETH1DepositIndex) + } + // Offset #11 'Validators' + offset11 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn3(ctx, t.Validators)) + } + // Offset #12 'Balances' + offset12 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn4(ctx, t.Balances)) + } + { // Field #13 'RANDAOMixes' + t := t.RANDAOMixes + vlen := len(t) + if vlen > int(ctx.exprs[1]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[1])), "RANDAOMixes") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:32]) + } + if vlen < int(ctx.exprs[1]) { + enc.EncodeZeroPadding((int(ctx.exprs[1]) - vlen) * 32) + } + } + { // Field #14 'Slashings' + t := t.Slashings + vlen := len(t) + if vlen > int(ctx.exprs[2]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[2])), "Slashings") + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + if vlen < int(ctx.exprs[2]) { + enc.EncodeZeroPadding((int(ctx.exprs[2]) - vlen) * 8) + } + } + // Offset #15 'PreviousEpochParticipation' + offset15 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn5(ctx, t.PreviousEpochParticipation)) + } + // Offset #16 'CurrentEpochParticipation' + offset16 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn6(ctx, t.CurrentEpochParticipation)) + } + { // Field #17 'JustificationBits' + vlen := len(t.JustificationBits) + if vlen > 1 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 1), "JustificationBits") + } + enc.EncodeBytes(t.JustificationBits[:vlen]) + if vlen < 1 { + enc.EncodeZeroPadding((1 - vlen) * 1) + } + } + { // Field #18 'PreviousJustifiedCheckpoint' + t := t.PreviousJustifiedCheckpoint + if t == nil { + t = new(phase0.Checkpoint) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } else { + enc.SetBuffer(buf) + } + } + { // Field #19 'CurrentJustifiedCheckpoint' + t := t.CurrentJustifiedCheckpoint + if t == nil { + t = new(phase0.Checkpoint) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } else { + enc.SetBuffer(buf) + } + } + { // Field #20 'FinalizedCheckpoint' + t := t.FinalizedCheckpoint + if t == nil { + t = new(phase0.Checkpoint) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") + } else { + enc.SetBuffer(buf) + } + } + // Offset #21 'InactivityScores' + offset21 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn7(ctx, t.InactivityScores)) + } + { // Field #22 'CurrentSyncCommittee' + t := t.CurrentSyncCommittee + if t == nil { + t = new(altair.SyncCommittee) + } + { // Field #0 'Pubkeys' + t := t.Pubkeys + vlen := len(t) + if vlen > int(ctx.exprs[3]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[3])), "CurrentSyncCommittee.Pubkeys") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:48]) + } + if vlen < int(ctx.exprs[3]) { + enc.EncodeZeroPadding((int(ctx.exprs[3]) - vlen) * 48) + } + } + { // Field #1 'AggregatePubkey' + enc.EncodeBytes(t.AggregatePubkey[:48]) + } + } + { // Field #23 'NextSyncCommittee' + t := t.NextSyncCommittee + if t == nil { + t = new(altair.SyncCommittee) + } + { // Field #0 'Pubkeys' + t := t.Pubkeys + vlen := len(t) + if vlen > int(ctx.exprs[3]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[3])), "NextSyncCommittee.Pubkeys") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:48]) + } + if vlen < int(ctx.exprs[3]) { + enc.EncodeZeroPadding((int(ctx.exprs[3]) - vlen) * 48) + } + } + { // Field #1 'AggregatePubkey' + enc.EncodeBytes(t.AggregatePubkey[:48]) + } + } + { // Field #24 'LatestBlockHash' + enc.EncodeBytes(t.LatestBlockHash[:32]) + } + { // Field #25 'NextWithdrawalIndex' + enc.EncodeUint64(uint64(t.NextWithdrawalIndex)) + } + { // Field #26 'NextWithdrawalValidatorIndex' + enc.EncodeUint64(uint64(t.NextWithdrawalValidatorIndex)) + } + // Offset #27 'HistoricalSummaries' + offset27 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn8(ctx, t.HistoricalSummaries)) + } + { // Field #28 'DepositRequestsStartIndex' + enc.EncodeUint64(t.DepositRequestsStartIndex) + } + { // Field #29 'DepositBalanceToConsume' + enc.EncodeUint64(uint64(t.DepositBalanceToConsume)) + } + { // Field #30 'ExitBalanceToConsume' + enc.EncodeUint64(uint64(t.ExitBalanceToConsume)) + } + { // Field #31 'EarliestExitEpoch' + enc.EncodeUint64(uint64(t.EarliestExitEpoch)) + } + { // Field #32 'ConsolidationBalanceToConsume' + enc.EncodeUint64(uint64(t.ConsolidationBalanceToConsume)) + } + { // Field #33 'EarliestConsolidationEpoch' + enc.EncodeUint64(uint64(t.EarliestConsolidationEpoch)) + } + // Offset #34 'PendingDeposits' + offset34 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn9(ctx, t.PendingDeposits)) + } + // Offset #35 'PendingPartialWithdrawals' + offset35 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn10(ctx, t.PendingPartialWithdrawals)) + } + // Offset #36 'PendingConsolidations' + offset36 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn11(ctx, t.PendingConsolidations)) + } + { // Field #37 'ProposerLookahead' + t := t.ProposerLookahead + vlen := len(t) + if vlen > int(ctx.exprs[4]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[4])), "ProposerLookahead") + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + if vlen < int(ctx.exprs[4]) { + enc.EncodeZeroPadding((int(ctx.exprs[4]) - vlen) * 8) + } + } + // Offset #38 'Builders' + offset38 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn12(ctx, t.Builders)) + } + { // Field #39 'NextWithdrawalBuilderIndex' + enc.EncodeUint64(uint64(t.NextWithdrawalBuilderIndex)) + } + { // Field #40 'ExecutionPayloadAvailability' + vlen := len(t.ExecutionPayloadAvailability) + if vlen > int(ctx.exprs[5]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[5])), "ExecutionPayloadAvailability") + } + enc.EncodeBytes(t.ExecutionPayloadAvailability[:vlen]) + if vlen < int(ctx.exprs[5]) { + enc.EncodeZeroPadding((int(ctx.exprs[5]) - vlen) * 1) + } + } + { // Field #41 'BuilderPendingPayments' + t := t.BuilderPendingPayments + vlen := len(t) + if vlen > int(ctx.exprs[6]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[6])), "BuilderPendingPayments") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(BuilderPendingPayment) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "BuilderPendingPayments[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + if vlen < int(ctx.exprs[6]) { + enc.EncodeZeroPadding((int(ctx.exprs[6]) - vlen) * 44) + } + } + // Offset #42 'BuilderPendingWithdrawals' + offset42 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn13(ctx, t.BuilderPendingWithdrawals)) + } + // Offset #43 'LatestExecutionPayloadBid' + offset43 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn14(ctx, t.LatestExecutionPayloadBid)) + } + // Offset #44 'PayloadExpectedWithdrawals' + offset44 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn15(ctx, t.PayloadExpectedWithdrawals)) + } + { // Field #45 'PTCWindow' + t := t.PTCWindow + vlen := len(t) + if vlen > int(ctx.exprs[8]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[8])), "PTCWindow") + } + for idx1 := range vlen { + t := t[idx1] + vlen := len(t) + if vlen > int(ctx.exprs[7]) { + return sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[7])), "PTCWindow[%d]", idx1) + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + if vlen < int(ctx.exprs[7]) { + enc.EncodeZeroPadding((int(ctx.exprs[7]) - vlen) * 8) + } + } + if vlen < int(ctx.exprs[8]) { + enc.EncodeZeroPadding((int(ctx.exprs[8]) - vlen) * 4096) + } + } + { // Dynamic Field #7 'HistoricalRoots' + if canSeek { + enc.EncodeOffsetAt(offset7, uint32(enc.GetPosition()-dstlen)) + } + t := t.HistoricalRoots + vlen := len(t) + if vlen > 16777216 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16777216), "HistoricalRoots") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:32]) + } + } + { // Dynamic Field #9 'ETH1DataVotes' + if canSeek { + enc.EncodeOffsetAt(offset9, uint32(enc.GetPosition()-dstlen)) + } + t := t.ETH1DataVotes + vlen := len(t) + if vlen > int(ctx.exprs[9]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[9])), "ETH1DataVotes") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(phase0.ETH1Data) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "ETH1DataVotes[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #11 'Validators' + if canSeek { + enc.EncodeOffsetAt(offset11, uint32(enc.GetPosition()-dstlen)) + } + t := t.Validators + vlen := len(t) + if vlen > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1099511627776), "Validators") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(phase0.Validator) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #12 'Balances' + if canSeek { + enc.EncodeOffsetAt(offset12, uint32(enc.GetPosition()-dstlen)) + } + t := t.Balances + vlen := len(t) + if vlen > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1099511627776), "Balances") + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + } + { // Dynamic Field #15 'PreviousEpochParticipation' + if canSeek { + enc.EncodeOffsetAt(offset15, uint32(enc.GetPosition()-dstlen)) + } + t := t.PreviousEpochParticipation + vlen := len(t) + if vlen > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1099511627776), "PreviousEpochParticipation") + } + for idx1 := range vlen { + enc.EncodeUint8(byte(t[idx1])) + } + } + { // Dynamic Field #16 'CurrentEpochParticipation' + if canSeek { + enc.EncodeOffsetAt(offset16, uint32(enc.GetPosition()-dstlen)) + } + t := t.CurrentEpochParticipation + vlen := len(t) + if vlen > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1099511627776), "CurrentEpochParticipation") + } + for idx1 := range vlen { + enc.EncodeUint8(byte(t[idx1])) + } + } + { // Dynamic Field #21 'InactivityScores' + if canSeek { + enc.EncodeOffsetAt(offset21, uint32(enc.GetPosition()-dstlen)) + } + t := t.InactivityScores + vlen := len(t) + if vlen > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1099511627776), "InactivityScores") + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + } + { // Dynamic Field #27 'HistoricalSummaries' + if canSeek { + enc.EncodeOffsetAt(offset27, uint32(enc.GetPosition()-dstlen)) + } + t := t.HistoricalSummaries + vlen := len(t) + if vlen > 16777216 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16777216), "HistoricalSummaries") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(capella.HistoricalSummary) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "HistoricalSummaries[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #34 'PendingDeposits' + if canSeek { + enc.EncodeOffsetAt(offset34, uint32(enc.GetPosition()-dstlen)) + } + t := t.PendingDeposits + vlen := len(t) + if vlen > int(ctx.exprs[10]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[10])), "PendingDeposits") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(electra.PendingDeposit) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "PendingDeposits[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #35 'PendingPartialWithdrawals' + if canSeek { + enc.EncodeOffsetAt(offset35, uint32(enc.GetPosition()-dstlen)) + } + t := t.PendingPartialWithdrawals + vlen := len(t) + if vlen > int(ctx.exprs[11]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[11])), "PendingPartialWithdrawals") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(electra.PendingPartialWithdrawal) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "PendingPartialWithdrawals[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #36 'PendingConsolidations' + if canSeek { + enc.EncodeOffsetAt(offset36, uint32(enc.GetPosition()-dstlen)) + } + t := t.PendingConsolidations + vlen := len(t) + if vlen > int(ctx.exprs[12]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[12])), "PendingConsolidations") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(electra.PendingConsolidation) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "PendingConsolidations[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #38 'Builders' + if canSeek { + enc.EncodeOffsetAt(offset38, uint32(enc.GetPosition()-dstlen)) + } + t := t.Builders + vlen := len(t) + if vlen > int(ctx.exprs[13]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[13])), "Builders") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(Builder) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "Builders[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #42 'BuilderPendingWithdrawals' + if canSeek { + enc.EncodeOffsetAt(offset42, uint32(enc.GetPosition()-dstlen)) + } + t := t.BuilderPendingWithdrawals + vlen := len(t) + if vlen > int(ctx.exprs[14]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[14])), "BuilderPendingWithdrawals") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(BuilderPendingWithdrawal) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "BuilderPendingWithdrawals[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #43 'LatestExecutionPayloadBid' + if canSeek { + enc.EncodeOffsetAt(offset43, uint32(enc.GetPosition()-dstlen)) + } + t := t.LatestExecutionPayloadBid + if t == nil { + t = new(ExecutionPayloadBid) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "LatestExecutionPayloadBid") + } else { + enc.SetBuffer(buf) + } + } + { // Dynamic Field #44 'PayloadExpectedWithdrawals' + if canSeek { + enc.EncodeOffsetAt(offset44, uint32(enc.GetPosition()-dstlen)) + } + t := t.PayloadExpectedWithdrawals + vlen := len(t) + if vlen > int(ctx.exprs[15]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[15])), "PayloadExpectedWithdrawals") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(capella.Withdrawal) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "PayloadExpectedWithdrawals[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + return nil +} + // UnmarshalSSZ unmarshals the *BeaconState from SSZ-encoded bytes. func (t *BeaconState) UnmarshalSSZ(buf []byte) (err error) { buflen := len(buf) if buflen < 3134333 { return sszutils.ErrFixedFieldsEOFFn(buflen, 3134333) } - { // Field #0 'GenesisTime' (static) - buf := buf[0:8] - t.GenesisTime = binary.LittleEndian.Uint64(buf) + { // Field #0 'GenesisTime' (static) + buf := buf[0:8] + t.GenesisTime = binary.LittleEndian.Uint64(buf) + } + { // Field #1 'GenesisValidatorsRoot' (static) + buf := buf[8:40] + copy(t.GenesisValidatorsRoot[:], buf) + } + { // Field #2 'Slot' (static) + buf := buf[40:48] + t.Slot = phase0.Slot(binary.LittleEndian.Uint64(buf)) + } + { // Field #3 'Fork' (static) + buf := buf[48:64] + if t.Fork == nil { + t.Fork = new(phase0.Fork) + } + if err = t.Fork.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "Fork") + } + } + { // Field #4 'LatestBlockHeader' (static) + buf := buf[64:176] + if t.LatestBlockHeader == nil { + t.LatestBlockHeader = new(phase0.BeaconBlockHeader) + } + if err = t.LatestBlockHeader.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") + } + } + { // Field #5 'BlockRoots' (static) + buf := buf[176:262320] + val1 := t.BlockRoots + val1 = sszutils.ExpandSlice(val1, 8192) + for idx1 := range 8192 { + buf := buf[32*idx1 : 32*(idx1+1)] + copy(val1[idx1][:], buf) + } + t.BlockRoots = val1 + } + { // Field #6 'StateRoots' (static) + buf := buf[262320:524464] + val2 := t.StateRoots + val2 = sszutils.ExpandSlice(val2, 8192) + for idx1 := range 8192 { + buf := buf[32*idx1 : 32*(idx1+1)] + copy(val2[idx1][:], buf) + } + t.StateRoots = val2 + } + // Field #7 'HistoricalRoots' (offset) + offset7 := int(binary.LittleEndian.Uint32(buf[524464:524468])) + if offset7 != 3134333 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset7, 3134333), "HistoricalRoots:o") + } + { // Field #8 'ETH1Data' (static) + buf := buf[524468:524540] + if t.ETH1Data == nil { + t.ETH1Data = new(phase0.ETH1Data) + } + if err = t.ETH1Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "ETH1Data") + } + } + // Field #9 'ETH1DataVotes' (offset) + offset9 := int(binary.LittleEndian.Uint32(buf[524540:524544])) + if offset9 < offset7 || offset9 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset9, offset7, buflen), "ETH1DataVotes:o") + } + { // Field #10 'ETH1DepositIndex' (static) + buf := buf[524544:524552] + t.ETH1DepositIndex = binary.LittleEndian.Uint64(buf) + } + // Field #11 'Validators' (offset) + offset11 := int(binary.LittleEndian.Uint32(buf[524552:524556])) + if offset11 < offset9 || offset11 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset11, offset9, buflen), "Validators:o") + } + // Field #12 'Balances' (offset) + offset12 := int(binary.LittleEndian.Uint32(buf[524556:524560])) + if offset12 < offset11 || offset12 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset12, offset11, buflen), "Balances:o") + } + { // Field #13 'RANDAOMixes' (static) + buf := buf[524560:2621712] + val3 := t.RANDAOMixes + val3 = sszutils.ExpandSlice(val3, 65536) + for idx1 := range 65536 { + buf := buf[32*idx1 : 32*(idx1+1)] + copy(val3[idx1][:], buf) + } + t.RANDAOMixes = val3 + } + { // Field #14 'Slashings' (static) + buf := buf[2621712:2687248] + val4 := t.Slashings + val4 = sszutils.ExpandSlice(val4, 8192) + sszutils.UnmarshalUint64Slice(val4[:8192], buf) + t.Slashings = val4 + } + // Field #15 'PreviousEpochParticipation' (offset) + offset15 := int(binary.LittleEndian.Uint32(buf[2687248:2687252])) + if offset15 < offset12 || offset15 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset15, offset12, buflen), "PreviousEpochParticipation:o") + } + // Field #16 'CurrentEpochParticipation' (offset) + offset16 := int(binary.LittleEndian.Uint32(buf[2687252:2687256])) + if offset16 < offset15 || offset16 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset16, offset15, buflen), "CurrentEpochParticipation:o") + } + { // Field #17 'JustificationBits' (static) + buf := buf[2687256:2687257] + t.JustificationBits = sszutils.ExpandSlice(t.JustificationBits, 1) + copy(t.JustificationBits[:], buf) + } + { // Field #18 'PreviousJustifiedCheckpoint' (static) + buf := buf[2687257:2687297] + if t.PreviousJustifiedCheckpoint == nil { + t.PreviousJustifiedCheckpoint = new(phase0.Checkpoint) + } + if err = t.PreviousJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } + } + { // Field #19 'CurrentJustifiedCheckpoint' (static) + buf := buf[2687297:2687337] + if t.CurrentJustifiedCheckpoint == nil { + t.CurrentJustifiedCheckpoint = new(phase0.Checkpoint) + } + if err = t.CurrentJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } + } + { // Field #20 'FinalizedCheckpoint' (static) + buf := buf[2687337:2687377] + if t.FinalizedCheckpoint == nil { + t.FinalizedCheckpoint = new(phase0.Checkpoint) + } + if err = t.FinalizedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") + } + } + // Field #21 'InactivityScores' (offset) + offset21 := int(binary.LittleEndian.Uint32(buf[2687377:2687381])) + if offset21 < offset16 || offset21 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset21, offset16, buflen), "InactivityScores:o") + } + { // Field #22 'CurrentSyncCommittee' (static) + buf := buf[2687381:2712005] + if t.CurrentSyncCommittee == nil { + t.CurrentSyncCommittee = new(altair.SyncCommittee) + } + if err = t.CurrentSyncCommittee.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "CurrentSyncCommittee") + } + } + { // Field #23 'NextSyncCommittee' (static) + buf := buf[2712005:2736629] + if t.NextSyncCommittee == nil { + t.NextSyncCommittee = new(altair.SyncCommittee) + } + if err = t.NextSyncCommittee.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "NextSyncCommittee") + } + } + { // Field #24 'LatestBlockHash' (static) + buf := buf[2736629:2736661] + copy(t.LatestBlockHash[:], buf) + } + { // Field #25 'NextWithdrawalIndex' (static) + buf := buf[2736661:2736669] + t.NextWithdrawalIndex = capella.WithdrawalIndex(binary.LittleEndian.Uint64(buf)) + } + { // Field #26 'NextWithdrawalValidatorIndex' (static) + buf := buf[2736669:2736677] + t.NextWithdrawalValidatorIndex = phase0.ValidatorIndex(binary.LittleEndian.Uint64(buf)) + } + // Field #27 'HistoricalSummaries' (offset) + offset27 := int(binary.LittleEndian.Uint32(buf[2736677:2736681])) + if offset27 < offset21 || offset27 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset27, offset21, buflen), "HistoricalSummaries:o") + } + { // Field #28 'DepositRequestsStartIndex' (static) + buf := buf[2736681:2736689] + t.DepositRequestsStartIndex = binary.LittleEndian.Uint64(buf) + } + { // Field #29 'DepositBalanceToConsume' (static) + buf := buf[2736689:2736697] + t.DepositBalanceToConsume = phase0.Gwei(binary.LittleEndian.Uint64(buf)) + } + { // Field #30 'ExitBalanceToConsume' (static) + buf := buf[2736697:2736705] + t.ExitBalanceToConsume = phase0.Gwei(binary.LittleEndian.Uint64(buf)) + } + { // Field #31 'EarliestExitEpoch' (static) + buf := buf[2736705:2736713] + t.EarliestExitEpoch = phase0.Epoch(binary.LittleEndian.Uint64(buf)) + } + { // Field #32 'ConsolidationBalanceToConsume' (static) + buf := buf[2736713:2736721] + t.ConsolidationBalanceToConsume = phase0.Gwei(binary.LittleEndian.Uint64(buf)) + } + { // Field #33 'EarliestConsolidationEpoch' (static) + buf := buf[2736721:2736729] + t.EarliestConsolidationEpoch = phase0.Epoch(binary.LittleEndian.Uint64(buf)) + } + // Field #34 'PendingDeposits' (offset) + offset34 := int(binary.LittleEndian.Uint32(buf[2736729:2736733])) + if offset34 < offset27 || offset34 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset34, offset27, buflen), "PendingDeposits:o") + } + // Field #35 'PendingPartialWithdrawals' (offset) + offset35 := int(binary.LittleEndian.Uint32(buf[2736733:2736737])) + if offset35 < offset34 || offset35 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset35, offset34, buflen), "PendingPartialWithdrawals:o") + } + // Field #36 'PendingConsolidations' (offset) + offset36 := int(binary.LittleEndian.Uint32(buf[2736737:2736741])) + if offset36 < offset35 || offset36 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset36, offset35, buflen), "PendingConsolidations:o") + } + { // Field #37 'ProposerLookahead' (static) + buf := buf[2736741:2737253] + val5 := t.ProposerLookahead + val5 = sszutils.ExpandSlice(val5, 64) + sszutils.UnmarshalUint64Slice(val5[:64], buf) + t.ProposerLookahead = val5 + } + // Field #38 'Builders' (offset) + offset38 := int(binary.LittleEndian.Uint32(buf[2737253:2737257])) + if offset38 < offset36 || offset38 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset38, offset36, buflen), "Builders:o") + } + { // Field #39 'NextWithdrawalBuilderIndex' (static) + buf := buf[2737257:2737265] + t.NextWithdrawalBuilderIndex = BuilderIndex(binary.LittleEndian.Uint64(buf)) + } + { // Field #40 'ExecutionPayloadAvailability' (static) + buf := buf[2737265:2738289] + t.ExecutionPayloadAvailability = sszutils.ExpandSlice(t.ExecutionPayloadAvailability, 1024) + copy(t.ExecutionPayloadAvailability[:], buf) + } + { // Field #41 'BuilderPendingPayments' (static) + buf := buf[2738289:2741105] + val6 := t.BuilderPendingPayments + val6 = sszutils.ExpandSlice(val6, 64) + for idx1 := range 64 { + if val6[idx1] == nil { + val6[idx1] = new(BuilderPendingPayment) + } + buf := buf[44*idx1 : 44*(idx1+1)] + if err = val6[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "BuilderPendingPayments[%d]", idx1) + } + } + t.BuilderPendingPayments = val6 + } + // Field #42 'BuilderPendingWithdrawals' (offset) + offset42 := int(binary.LittleEndian.Uint32(buf[2741105:2741109])) + if offset42 < offset38 || offset42 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset42, offset38, buflen), "BuilderPendingWithdrawals:o") } - { // Field #1 'GenesisValidatorsRoot' (static) - buf := buf[8:40] - copy(t.GenesisValidatorsRoot[:], buf) + // Field #43 'LatestExecutionPayloadBid' (offset) + offset43 := int(binary.LittleEndian.Uint32(buf[2741109:2741113])) + if offset43 < offset42 || offset43 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset43, offset42, buflen), "LatestExecutionPayloadBid:o") + } + // Field #44 'PayloadExpectedWithdrawals' (offset) + offset44 := int(binary.LittleEndian.Uint32(buf[2741113:2741117])) + if offset44 < offset43 || offset44 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset44, offset43, buflen), "PayloadExpectedWithdrawals:o") + } + { // Field #45 'PTCWindow' (static) + buf := buf[2741117:3134333] + val7 := t.PTCWindow + val7 = sszutils.ExpandSlice(val7, 96) + for idx1 := range 96 { + val8 := val7[idx1] + buf := buf[4096*idx1 : 4096*(idx1+1)] + val8 = sszutils.ExpandSlice(val8, 512) + sszutils.UnmarshalUint64Slice(val8[:512], buf) + val7[idx1] = val8 + } + t.PTCWindow = val7 + } + { // Field #7 'HistoricalRoots' (dynamic) + buf := buf[offset7:offset9] + val9 := t.HistoricalRoots + itemCount := len(buf) / 32 + if len(buf)%32 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 32), "HistoricalRoots") + } + if itemCount > 16777216 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 16777216), "HistoricalRoots") + } + val9 = sszutils.ExpandSlice(val9, itemCount) + for idx1 := range itemCount { + buf := buf[32*idx1 : 32*(idx1+1)] + copy(val9[idx1][:], buf) + } + t.HistoricalRoots = val9 + } + { // Field #9 'ETH1DataVotes' (dynamic) + buf := buf[offset9:offset11] + val10 := t.ETH1DataVotes + itemCount := len(buf) / 72 + if len(buf)%72 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 72), "ETH1DataVotes") + } + if itemCount > 2048 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 2048), "ETH1DataVotes") + } + val10 = sszutils.ExpandSlice(val10, itemCount) + for idx1 := range itemCount { + if val10[idx1] == nil { + val10[idx1] = new(phase0.ETH1Data) + } + buf := buf[72*idx1 : 72*(idx1+1)] + if err = val10[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "ETH1DataVotes[%d]", idx1) + } + } + t.ETH1DataVotes = val10 + } + { // Field #11 'Validators' (dynamic) + buf := buf[offset11:offset12] + val11 := t.Validators + itemCount := len(buf) / 121 + if len(buf)%121 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 121), "Validators") + } + if itemCount > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1099511627776), "Validators") + } + val11 = sszutils.ExpandSlice(val11, itemCount) + for idx1 := range itemCount { + if val11[idx1] == nil { + val11[idx1] = new(phase0.Validator) + } + buf := buf[121*idx1 : 121*(idx1+1)] + if err = val11[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } + } + t.Validators = val11 + } + { // Field #12 'Balances' (dynamic) + buf := buf[offset12:offset15] + val12 := t.Balances + itemCount := len(buf) / 8 + if len(buf)%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 8), "Balances") + } + if itemCount > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1099511627776), "Balances") + } + val12 = sszutils.ExpandSlice(val12, itemCount) + sszutils.UnmarshalUint64Slice(val12, buf) + t.Balances = val12 + } + { // Field #15 'PreviousEpochParticipation' (dynamic) + buf := buf[offset15:offset16] + val13 := t.PreviousEpochParticipation + itemCount := len(buf) + if itemCount > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1099511627776), "PreviousEpochParticipation") + } + val13 = sszutils.ExpandSlice(val13, itemCount) + for idx1 := range itemCount { + buf := buf[1*idx1 : 1*(idx1+1)] + val13[idx1] = altair.ParticipationFlags(buf[0]) + } + t.PreviousEpochParticipation = val13 + } + { // Field #16 'CurrentEpochParticipation' (dynamic) + buf := buf[offset16:offset21] + val14 := t.CurrentEpochParticipation + itemCount := len(buf) + if itemCount > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1099511627776), "CurrentEpochParticipation") + } + val14 = sszutils.ExpandSlice(val14, itemCount) + for idx1 := range itemCount { + buf := buf[1*idx1 : 1*(idx1+1)] + val14[idx1] = altair.ParticipationFlags(buf[0]) + } + t.CurrentEpochParticipation = val14 + } + { // Field #21 'InactivityScores' (dynamic) + buf := buf[offset21:offset27] + val15 := t.InactivityScores + itemCount := len(buf) / 8 + if len(buf)%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 8), "InactivityScores") + } + if itemCount > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1099511627776), "InactivityScores") + } + val15 = sszutils.ExpandSlice(val15, itemCount) + sszutils.UnmarshalUint64Slice(val15, buf) + t.InactivityScores = val15 + } + { // Field #27 'HistoricalSummaries' (dynamic) + buf := buf[offset27:offset34] + val16 := t.HistoricalSummaries + itemCount := len(buf) / 64 + if len(buf)%64 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 64), "HistoricalSummaries") + } + if itemCount > 16777216 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 16777216), "HistoricalSummaries") + } + val16 = sszutils.ExpandSlice(val16, itemCount) + for idx1 := range itemCount { + if val16[idx1] == nil { + val16[idx1] = new(capella.HistoricalSummary) + } + buf := buf[64*idx1 : 64*(idx1+1)] + if err = val16[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "HistoricalSummaries[%d]", idx1) + } + } + t.HistoricalSummaries = val16 + } + { // Field #34 'PendingDeposits' (dynamic) + buf := buf[offset34:offset35] + val17 := t.PendingDeposits + itemCount := len(buf) / 192 + if len(buf)%192 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 192), "PendingDeposits") + } + if itemCount > 134217728 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 134217728), "PendingDeposits") + } + val17 = sszutils.ExpandSlice(val17, itemCount) + for idx1 := range itemCount { + if val17[idx1] == nil { + val17[idx1] = new(electra.PendingDeposit) + } + buf := buf[192*idx1 : 192*(idx1+1)] + if err = val17[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "PendingDeposits[%d]", idx1) + } + } + t.PendingDeposits = val17 + } + { // Field #35 'PendingPartialWithdrawals' (dynamic) + buf := buf[offset35:offset36] + val18 := t.PendingPartialWithdrawals + itemCount := len(buf) / 24 + if len(buf)%24 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 24), "PendingPartialWithdrawals") + } + if itemCount > 134217728 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 134217728), "PendingPartialWithdrawals") + } + val18 = sszutils.ExpandSlice(val18, itemCount) + for idx1 := range itemCount { + if val18[idx1] == nil { + val18[idx1] = new(electra.PendingPartialWithdrawal) + } + buf := buf[24*idx1 : 24*(idx1+1)] + if err = val18[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "PendingPartialWithdrawals[%d]", idx1) + } + } + t.PendingPartialWithdrawals = val18 + } + { // Field #36 'PendingConsolidations' (dynamic) + buf := buf[offset36:offset38] + val19 := t.PendingConsolidations + itemCount := len(buf) / 16 + if len(buf)%16 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 16), "PendingConsolidations") + } + if itemCount > 262144 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 262144), "PendingConsolidations") + } + val19 = sszutils.ExpandSlice(val19, itemCount) + for idx1 := range itemCount { + if val19[idx1] == nil { + val19[idx1] = new(electra.PendingConsolidation) + } + buf := buf[16*idx1 : 16*(idx1+1)] + if err = val19[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "PendingConsolidations[%d]", idx1) + } + } + t.PendingConsolidations = val19 + } + { // Field #38 'Builders' (dynamic) + buf := buf[offset38:offset42] + val20 := t.Builders + itemCount := len(buf) / 93 + if len(buf)%93 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 93), "Builders") + } + if itemCount > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1099511627776), "Builders") + } + val20 = sszutils.ExpandSlice(val20, itemCount) + for idx1 := range itemCount { + if val20[idx1] == nil { + val20[idx1] = new(Builder) + } + buf := buf[93*idx1 : 93*(idx1+1)] + if err = val20[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Builders[%d]", idx1) + } + } + t.Builders = val20 } - { // Field #2 'Slot' (static) - buf := buf[40:48] - t.Slot = phase0.Slot(binary.LittleEndian.Uint64(buf)) + { // Field #42 'BuilderPendingWithdrawals' (dynamic) + buf := buf[offset42:offset43] + val21 := t.BuilderPendingWithdrawals + itemCount := len(buf) / 36 + if len(buf)%36 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 36), "BuilderPendingWithdrawals") + } + if itemCount > 1048576 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1048576), "BuilderPendingWithdrawals") + } + val21 = sszutils.ExpandSlice(val21, itemCount) + for idx1 := range itemCount { + if val21[idx1] == nil { + val21[idx1] = new(BuilderPendingWithdrawal) + } + buf := buf[36*idx1 : 36*(idx1+1)] + if err = val21[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "BuilderPendingWithdrawals[%d]", idx1) + } + } + t.BuilderPendingWithdrawals = val21 } - { // Field #3 'Fork' (static) - buf := buf[48:64] - if t.Fork == nil { - t.Fork = new(phase0.Fork) + { // Field #43 'LatestExecutionPayloadBid' (dynamic) + buf := buf[offset43:offset44] + if t.LatestExecutionPayloadBid == nil { + t.LatestExecutionPayloadBid = new(ExecutionPayloadBid) } - if err = t.Fork.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "Fork") + if err = t.LatestExecutionPayloadBid.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "LatestExecutionPayloadBid") } } - { // Field #4 'LatestBlockHeader' (static) - buf := buf[64:176] - if t.LatestBlockHeader == nil { - t.LatestBlockHeader = new(phase0.BeaconBlockHeader) + { // Field #44 'PayloadExpectedWithdrawals' (dynamic) + buf := buf[offset44:] + val22 := t.PayloadExpectedWithdrawals + itemCount := len(buf) / 44 + if len(buf)%44 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 44), "PayloadExpectedWithdrawals") } - if err = t.LatestBlockHeader.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "LatestBlockHeader") + if itemCount > 16 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 16), "PayloadExpectedWithdrawals") + } + val22 = sszutils.ExpandSlice(val22, itemCount) + for idx1 := range itemCount { + if val22[idx1] == nil { + val22[idx1] = new(capella.Withdrawal) + } + buf := buf[44*idx1 : 44*(idx1+1)] + if err = val22[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "PayloadExpectedWithdrawals[%d]", idx1) + } } + t.PayloadExpectedWithdrawals = val22 + } + return nil +} + +// UnmarshalSSZDecoder unmarshals the *BeaconState from the given SSZ decoder using dynamic specifications. +func (t *BeaconState) UnmarshalSSZDecoder(ds sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { + expr0, err := sszutils.ResolveSpecValueWithDefault(ds, "SLOTS_PER_HISTORICAL_ROOT", 8192) + if err != nil { + return err + } + expr1, err := sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_HISTORICAL_VECTOR", 65536) + if err != nil { + return err + } + expr2, err := sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_SLASHINGS_VECTOR", 8192) + if err != nil { + return err + } + expr3, err := sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE", 512) + if err != nil { + return err + } + expr4, err := sszutils.ResolveSpecValueWithDefault(ds, "(MIN_SEED_LOOKAHEAD+1)*SLOTS_PER_EPOCH", 64) + if err != nil { + return err + } + expr5, err := sszutils.ResolveSpecValueWithDefault(ds, "SLOTS_PER_HISTORICAL_ROOT/8", 1024) + if err != nil { + return err + } + expr6, err := sszutils.ResolveSpecValueWithDefault(ds, "SLOTS_PER_EPOCH*2", 64) + if err != nil { + return err + } + expr7, err := sszutils.ResolveSpecValueWithDefault(ds, "PTC_SIZE", 512) + if err != nil { + return err + } + expr8, err := sszutils.ResolveSpecValueWithDefault(ds, "(2+MIN_SEED_LOOKAHEAD)*SLOTS_PER_EPOCH", 96) + if err != nil { + return err + } + expr9, err := sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_ETH1_VOTING_PERIOD*SLOTS_PER_EPOCH", 2048) + if err != nil { + return err + } + expr10, err := sszutils.ResolveSpecValueWithDefault(ds, "PENDING_DEPOSITS_LIMIT", 134217728) + if err != nil { + return err + } + expr11, err := sszutils.ResolveSpecValueWithDefault(ds, "PENDING_PARTIAL_WITHDRAWALS_LIMIT", 134217728) + if err != nil { + return err + } + expr12, err := sszutils.ResolveSpecValueWithDefault(ds, "PENDING_CONSOLIDATIONS_LIMIT", 262144) + if err != nil { + return err + } + expr13, err := sszutils.ResolveSpecValueWithDefault(ds, "BUILDER_REGISTRY_LIMIT", 1099511627776) + if err != nil { + return err + } + expr14, err := sszutils.ResolveSpecValueWithDefault(ds, "BUILDER_PENDING_WITHDRAWALS_LIMIT", 1048576) + if err != nil { + return err + } + expr15, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_WITHDRAWALS_PER_PAYLOAD", 16) + if err != nil { + return err + } + size1 := 32 * int(expr0) + size2 := 32 * int(expr1) + size3 := 8 * int(expr2) + size5 := 48 * int(expr3) + size4 := size5 + 48 // size expression for '*SyncCommittee' + size6 := 8 * int(expr4) + size7 := 1 * int(expr5) + size8 := 44 * int(expr6) + size10 := 8 * int(expr7) + size9 := size10 * int(expr8) + totalSize := size1+size1+size2+size3+size4+size4+size6+size7+size8+size9+541 + maxOffset := uint32(dec.GetLength()) + startPos0 := dec.GetPosition() + if maxOffset < uint32(totalSize) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(totalSize)) + } + // Field #0 'GenesisTime' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "GenesisTime") + } else { + t.GenesisTime = val + } + // Field #1 'GenesisValidatorsRoot' (static) + if _, err = dec.DecodeBytes(t.GenesisValidatorsRoot[:32]); err != nil { + return err + } + // Field #2 'Slot' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "Slot") + } else { + t.Slot = phase0.Slot(val) + } + // Field #3 'Fork' (static) + if t.Fork == nil { + t.Fork = new(phase0.Fork) + } + if buf, err := dec.DecodeBytesBuf(16); err != nil { + return sszutils.ErrorWithPath(err, "Fork") + } else if err = t.Fork.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "Fork") + } + // Field #4 'LatestBlockHeader' (static) + if t.LatestBlockHeader == nil { + t.LatestBlockHeader = new(phase0.BeaconBlockHeader) + } + if buf, err := dec.DecodeBytesBuf(112); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") + } else if err = t.LatestBlockHeader.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") } { // Field #5 'BlockRoots' (static) - buf := buf[176:262320] val1 := t.BlockRoots - val1 = sszutils.ExpandSlice(val1, 8192) - for idx1 := range 8192 { - buf := buf[32*idx1 : 32*(idx1+1)] - copy(val1[idx1][:], buf) + val1 = sszutils.ExpandSlice(val1, int(expr0)) + startPos1 := dec.GetPosition() + for idx1 := range int(expr0) { + if _, err = dec.DecodeBytes(val1[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos1+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos1+int(32*(idx1+1))), "BlockRoots[%d]", idx1) + } } t.BlockRoots = val1 } { // Field #6 'StateRoots' (static) - buf := buf[262320:524464] val2 := t.StateRoots - val2 = sszutils.ExpandSlice(val2, 8192) - for idx1 := range 8192 { - buf := buf[32*idx1 : 32*(idx1+1)] - copy(val2[idx1][:], buf) + val2 = sszutils.ExpandSlice(val2, int(expr0)) + startPos2 := dec.GetPosition() + for idx1 := range int(expr0) { + if _, err = dec.DecodeBytes(val2[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos2+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos2+int(32*(idx1+1))), "StateRoots[%d]", idx1) + } } t.StateRoots = val2 } // Field #7 'HistoricalRoots' (offset) - offset7 := int(binary.LittleEndian.Uint32(buf[524464:524468])) - if offset7 != 3134333 { - return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset7, 3134333), "HistoricalRoots:o") + offset7, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "HistoricalRoots") } - { // Field #8 'ETH1Data' (static) - buf := buf[524468:524540] - if t.ETH1Data == nil { - t.ETH1Data = new(phase0.ETH1Data) - } - if err = t.ETH1Data.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "ETH1Data") - } + if offset7 != uint32(totalSize) { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset7, totalSize), "HistoricalRoots") + } + // Field #8 'ETH1Data' (static) + if t.ETH1Data == nil { + t.ETH1Data = new(phase0.ETH1Data) + } + if buf, err := dec.DecodeBytesBuf(72); err != nil { + return sszutils.ErrorWithPath(err, "ETH1Data") + } else if err = t.ETH1Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "ETH1Data") } // Field #9 'ETH1DataVotes' (offset) - offset9 := int(binary.LittleEndian.Uint32(buf[524540:524544])) - if offset9 < offset7 || offset9 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset9, offset7, buflen), "ETH1DataVotes:o") + offset9, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "ETH1DataVotes") } - { // Field #10 'ETH1DepositIndex' (static) - buf := buf[524544:524552] - t.ETH1DepositIndex = binary.LittleEndian.Uint64(buf) + if offset9 < offset7 || offset9 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset9, offset7, maxOffset), "ETH1DataVotes") + } + // Field #10 'ETH1DepositIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "ETH1DepositIndex") + } else { + t.ETH1DepositIndex = val } // Field #11 'Validators' (offset) - offset11 := int(binary.LittleEndian.Uint32(buf[524552:524556])) - if offset11 < offset9 || offset11 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset11, offset9, buflen), "Validators:o") + offset11, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Validators") + } + if offset11 < offset9 || offset11 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset11, offset9, maxOffset), "Validators") } // Field #12 'Balances' (offset) - offset12 := int(binary.LittleEndian.Uint32(buf[524556:524560])) - if offset12 < offset11 || offset12 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset12, offset11, buflen), "Balances:o") + offset12, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Balances") + } + if offset12 < offset11 || offset12 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset12, offset11, maxOffset), "Balances") } { // Field #13 'RANDAOMixes' (static) - buf := buf[524560:2621712] val3 := t.RANDAOMixes - val3 = sszutils.ExpandSlice(val3, 65536) - for idx1 := range 65536 { - buf := buf[32*idx1 : 32*(idx1+1)] - copy(val3[idx1][:], buf) + val3 = sszutils.ExpandSlice(val3, int(expr1)) + startPos3 := dec.GetPosition() + for idx1 := range int(expr1) { + if _, err = dec.DecodeBytes(val3[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos3+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos3+int(32*(idx1+1))), "RANDAOMixes[%d]", idx1) + } } t.RANDAOMixes = val3 } { // Field #14 'Slashings' (static) - buf := buf[2621712:2687248] val4 := t.Slashings - val4 = sszutils.ExpandSlice(val4, 8192) - sszutils.UnmarshalUint64Slice(val4[:8192], buf) + val4 = sszutils.ExpandSlice(val4, int(expr2)) + if err = sszutils.DecodeUint64Slice(dec, val4[:int(expr2)]); err != nil { + return sszutils.ErrorWithPath(err, "Slashings") + } t.Slashings = val4 } // Field #15 'PreviousEpochParticipation' (offset) - offset15 := int(binary.LittleEndian.Uint32(buf[2687248:2687252])) - if offset15 < offset12 || offset15 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset15, offset12, buflen), "PreviousEpochParticipation:o") + offset15, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "PreviousEpochParticipation") + } + if offset15 < offset12 || offset15 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset15, offset12, maxOffset), "PreviousEpochParticipation") } // Field #16 'CurrentEpochParticipation' (offset) - offset16 := int(binary.LittleEndian.Uint32(buf[2687252:2687256])) - if offset16 < offset15 || offset16 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset16, offset15, buflen), "CurrentEpochParticipation:o") + offset16, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "CurrentEpochParticipation") } - { // Field #17 'JustificationBits' (static) - buf := buf[2687256:2687257] - t.JustificationBits = sszutils.ExpandSlice(t.JustificationBits, 1) - copy(t.JustificationBits[:], buf) + if offset16 < offset15 || offset16 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset16, offset15, maxOffset), "CurrentEpochParticipation") } - { // Field #18 'PreviousJustifiedCheckpoint' (static) - buf := buf[2687257:2687297] - if t.PreviousJustifiedCheckpoint == nil { - t.PreviousJustifiedCheckpoint = new(phase0.Checkpoint) - } - if err = t.PreviousJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") - } + // Field #17 'JustificationBits' (static) + t.JustificationBits = sszutils.ExpandSlice(t.JustificationBits, 1) + if _, err = dec.DecodeBytes(t.JustificationBits[:1]); err != nil { + return err } - { // Field #19 'CurrentJustifiedCheckpoint' (static) - buf := buf[2687297:2687337] - if t.CurrentJustifiedCheckpoint == nil { - t.CurrentJustifiedCheckpoint = new(phase0.Checkpoint) - } - if err = t.CurrentJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") - } + // Field #18 'PreviousJustifiedCheckpoint' (static) + if t.PreviousJustifiedCheckpoint == nil { + t.PreviousJustifiedCheckpoint = new(phase0.Checkpoint) } - { // Field #20 'FinalizedCheckpoint' (static) - buf := buf[2687337:2687377] - if t.FinalizedCheckpoint == nil { - t.FinalizedCheckpoint = new(phase0.Checkpoint) - } - if err = t.FinalizedCheckpoint.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") - } + if buf, err := dec.DecodeBytesBuf(40); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } else if err = t.PreviousJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } + // Field #19 'CurrentJustifiedCheckpoint' (static) + if t.CurrentJustifiedCheckpoint == nil { + t.CurrentJustifiedCheckpoint = new(phase0.Checkpoint) + } + if buf, err := dec.DecodeBytesBuf(40); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } else if err = t.CurrentJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } + // Field #20 'FinalizedCheckpoint' (static) + if t.FinalizedCheckpoint == nil { + t.FinalizedCheckpoint = new(phase0.Checkpoint) + } + if buf, err := dec.DecodeBytesBuf(40); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") + } else if err = t.FinalizedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") } // Field #21 'InactivityScores' (offset) - offset21 := int(binary.LittleEndian.Uint32(buf[2687377:2687381])) - if offset21 < offset16 || offset21 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset21, offset16, buflen), "InactivityScores:o") + offset21, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "InactivityScores") + } + if offset21 < offset16 || offset21 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset21, offset16, maxOffset), "InactivityScores") } { // Field #22 'CurrentSyncCommittee' (static) - buf := buf[2687381:2712005] - if t.CurrentSyncCommittee == nil { - t.CurrentSyncCommittee = new(altair.SyncCommittee) + val5 := t.CurrentSyncCommittee + if val5 == nil { + val5 = new(altair.SyncCommittee) + } + totalSize := size5+48 + maxOffset := uint32(dec.GetLength()) + if maxOffset < uint32(totalSize) { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(totalSize)), "CurrentSyncCommittee") + } + { // Field #0 'Pubkeys' (static) + val6 := val5.Pubkeys + val6 = sszutils.ExpandSlice(val6, int(expr3)) + startPos4 := dec.GetPosition() + for idx1 := range int(expr3) { + if _, err = dec.DecodeBytes(val6[idx1][:48]); err != nil { + return err + } + if dec.GetPosition() != startPos4+int(48*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos4+int(48*(idx1+1))), "CurrentSyncCommittee.Pubkeys[%d]", idx1) + } + } + val5.Pubkeys = val6 } - if err = t.CurrentSyncCommittee.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "CurrentSyncCommittee") + // Field #1 'AggregatePubkey' (static) + if _, err = dec.DecodeBytes(val5.AggregatePubkey[:48]); err != nil { + return err } + t.CurrentSyncCommittee = val5 } { // Field #23 'NextSyncCommittee' (static) - buf := buf[2712005:2736629] - if t.NextSyncCommittee == nil { - t.NextSyncCommittee = new(altair.SyncCommittee) + val7 := t.NextSyncCommittee + if val7 == nil { + val7 = new(altair.SyncCommittee) + } + totalSize := size5+48 + maxOffset := uint32(dec.GetLength()) + if maxOffset < uint32(totalSize) { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(totalSize)), "NextSyncCommittee") + } + { // Field #0 'Pubkeys' (static) + val8 := val7.Pubkeys + val8 = sszutils.ExpandSlice(val8, int(expr3)) + startPos5 := dec.GetPosition() + for idx1 := range int(expr3) { + if _, err = dec.DecodeBytes(val8[idx1][:48]); err != nil { + return err + } + if dec.GetPosition() != startPos5+int(48*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos5+int(48*(idx1+1))), "NextSyncCommittee.Pubkeys[%d]", idx1) + } + } + val7.Pubkeys = val8 } - if err = t.NextSyncCommittee.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "NextSyncCommittee") + // Field #1 'AggregatePubkey' (static) + if _, err = dec.DecodeBytes(val7.AggregatePubkey[:48]); err != nil { + return err } + t.NextSyncCommittee = val7 } - { // Field #24 'LatestBlockHash' (static) - buf := buf[2736629:2736661] - copy(t.LatestBlockHash[:], buf) + // Field #24 'LatestBlockHash' (static) + if _, err = dec.DecodeBytes(t.LatestBlockHash[:32]); err != nil { + return err } - { // Field #25 'NextWithdrawalIndex' (static) - buf := buf[2736661:2736669] - t.NextWithdrawalIndex = capella.WithdrawalIndex(binary.LittleEndian.Uint64(buf)) + // Field #25 'NextWithdrawalIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "NextWithdrawalIndex") + } else { + t.NextWithdrawalIndex = capella.WithdrawalIndex(val) } - { // Field #26 'NextWithdrawalValidatorIndex' (static) - buf := buf[2736669:2736677] - t.NextWithdrawalValidatorIndex = phase0.ValidatorIndex(binary.LittleEndian.Uint64(buf)) + // Field #26 'NextWithdrawalValidatorIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "NextWithdrawalValidatorIndex") + } else { + t.NextWithdrawalValidatorIndex = phase0.ValidatorIndex(val) } // Field #27 'HistoricalSummaries' (offset) - offset27 := int(binary.LittleEndian.Uint32(buf[2736677:2736681])) - if offset27 < offset21 || offset27 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset27, offset21, buflen), "HistoricalSummaries:o") - } - { // Field #28 'DepositRequestsStartIndex' (static) - buf := buf[2736681:2736689] - t.DepositRequestsStartIndex = binary.LittleEndian.Uint64(buf) - } - { // Field #29 'DepositBalanceToConsume' (static) - buf := buf[2736689:2736697] - t.DepositBalanceToConsume = phase0.Gwei(binary.LittleEndian.Uint64(buf)) - } - { // Field #30 'ExitBalanceToConsume' (static) - buf := buf[2736697:2736705] - t.ExitBalanceToConsume = phase0.Gwei(binary.LittleEndian.Uint64(buf)) - } - { // Field #31 'EarliestExitEpoch' (static) - buf := buf[2736705:2736713] - t.EarliestExitEpoch = phase0.Epoch(binary.LittleEndian.Uint64(buf)) - } - { // Field #32 'ConsolidationBalanceToConsume' (static) - buf := buf[2736713:2736721] - t.ConsolidationBalanceToConsume = phase0.Gwei(binary.LittleEndian.Uint64(buf)) - } - { // Field #33 'EarliestConsolidationEpoch' (static) - buf := buf[2736721:2736729] - t.EarliestConsolidationEpoch = phase0.Epoch(binary.LittleEndian.Uint64(buf)) + offset27, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "HistoricalSummaries") + } + if offset27 < offset21 || offset27 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset27, offset21, maxOffset), "HistoricalSummaries") + } + // Field #28 'DepositRequestsStartIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "DepositRequestsStartIndex") + } else { + t.DepositRequestsStartIndex = val + } + // Field #29 'DepositBalanceToConsume' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "DepositBalanceToConsume") + } else { + t.DepositBalanceToConsume = phase0.Gwei(val) + } + // Field #30 'ExitBalanceToConsume' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "ExitBalanceToConsume") + } else { + t.ExitBalanceToConsume = phase0.Gwei(val) + } + // Field #31 'EarliestExitEpoch' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "EarliestExitEpoch") + } else { + t.EarliestExitEpoch = phase0.Epoch(val) + } + // Field #32 'ConsolidationBalanceToConsume' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "ConsolidationBalanceToConsume") + } else { + t.ConsolidationBalanceToConsume = phase0.Gwei(val) + } + // Field #33 'EarliestConsolidationEpoch' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "EarliestConsolidationEpoch") + } else { + t.EarliestConsolidationEpoch = phase0.Epoch(val) } // Field #34 'PendingDeposits' (offset) - offset34 := int(binary.LittleEndian.Uint32(buf[2736729:2736733])) - if offset34 < offset27 || offset34 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset34, offset27, buflen), "PendingDeposits:o") + offset34, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "PendingDeposits") + } + if offset34 < offset27 || offset34 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset34, offset27, maxOffset), "PendingDeposits") } // Field #35 'PendingPartialWithdrawals' (offset) - offset35 := int(binary.LittleEndian.Uint32(buf[2736733:2736737])) - if offset35 < offset34 || offset35 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset35, offset34, buflen), "PendingPartialWithdrawals:o") + offset35, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "PendingPartialWithdrawals") + } + if offset35 < offset34 || offset35 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset35, offset34, maxOffset), "PendingPartialWithdrawals") } // Field #36 'PendingConsolidations' (offset) - offset36 := int(binary.LittleEndian.Uint32(buf[2736737:2736741])) - if offset36 < offset35 || offset36 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset36, offset35, buflen), "PendingConsolidations:o") + offset36, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "PendingConsolidations") + } + if offset36 < offset35 || offset36 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset36, offset35, maxOffset), "PendingConsolidations") } { // Field #37 'ProposerLookahead' (static) - buf := buf[2736741:2737253] - val5 := t.ProposerLookahead - val5 = sszutils.ExpandSlice(val5, 64) - sszutils.UnmarshalUint64Slice(val5[:64], buf) - t.ProposerLookahead = val5 + val9 := t.ProposerLookahead + val9 = sszutils.ExpandSlice(val9, int(expr4)) + if err = sszutils.DecodeUint64Slice(dec, val9[:int(expr4)]); err != nil { + return sszutils.ErrorWithPath(err, "ProposerLookahead") + } + t.ProposerLookahead = val9 } // Field #38 'Builders' (offset) - offset38 := int(binary.LittleEndian.Uint32(buf[2737253:2737257])) - if offset38 < offset36 || offset38 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset38, offset36, buflen), "Builders:o") + offset38, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Builders") } - { // Field #39 'NextWithdrawalBuilderIndex' (static) - buf := buf[2737257:2737265] - t.NextWithdrawalBuilderIndex = BuilderIndex(binary.LittleEndian.Uint64(buf)) + if offset38 < offset36 || offset38 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset38, offset36, maxOffset), "Builders") } - { // Field #40 'ExecutionPayloadAvailability' (static) - buf := buf[2737265:2738289] - t.ExecutionPayloadAvailability = sszutils.ExpandSlice(t.ExecutionPayloadAvailability, 1024) - copy(t.ExecutionPayloadAvailability[:], buf) + // Field #39 'NextWithdrawalBuilderIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "NextWithdrawalBuilderIndex") + } else { + t.NextWithdrawalBuilderIndex = BuilderIndex(val) + } + // Field #40 'ExecutionPayloadAvailability' (static) + t.ExecutionPayloadAvailability = sszutils.ExpandSlice(t.ExecutionPayloadAvailability, int(expr5)) + if _, err = dec.DecodeBytes(t.ExecutionPayloadAvailability[:int(expr5)]); err != nil { + return err } { // Field #41 'BuilderPendingPayments' (static) - buf := buf[2738289:2741105] - val6 := t.BuilderPendingPayments - val6 = sszutils.ExpandSlice(val6, 64) - for idx1 := range 64 { - if val6[idx1] == nil { - val6[idx1] = new(BuilderPendingPayment) + val10 := t.BuilderPendingPayments + val10 = sszutils.ExpandSlice(val10, int(expr6)) + startPos6 := dec.GetPosition() + for idx1 := range int(expr6) { + if val10[idx1] == nil { + val10[idx1] = new(BuilderPendingPayment) } - buf := buf[44*idx1 : 44*(idx1+1)] - if err = val6[idx1].UnmarshalSSZ(buf); err != nil { + if buf, err := dec.DecodeBytesBuf(44); err != nil { + return sszutils.ErrorWithPathf(err, "BuilderPendingPayments[%d]", idx1) + } else if err = val10[idx1].UnmarshalSSZ(buf); err != nil { return sszutils.ErrorWithPathf(err, "BuilderPendingPayments[%d]", idx1) } + if dec.GetPosition() != startPos6+int(44*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos6+int(44*(idx1+1))), "BuilderPendingPayments[%d]", idx1) + } } - t.BuilderPendingPayments = val6 + t.BuilderPendingPayments = val10 } // Field #42 'BuilderPendingWithdrawals' (offset) - offset42 := int(binary.LittleEndian.Uint32(buf[2741105:2741109])) - if offset42 < offset38 || offset42 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset42, offset38, buflen), "BuilderPendingWithdrawals:o") + offset42, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "BuilderPendingWithdrawals") + } + if offset42 < offset38 || offset42 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset42, offset38, maxOffset), "BuilderPendingWithdrawals") } // Field #43 'LatestExecutionPayloadBid' (offset) - offset43 := int(binary.LittleEndian.Uint32(buf[2741109:2741113])) - if offset43 < offset42 || offset43 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset43, offset42, buflen), "LatestExecutionPayloadBid:o") + offset43, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "LatestExecutionPayloadBid") + } + if offset43 < offset42 || offset43 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset43, offset42, maxOffset), "LatestExecutionPayloadBid") } // Field #44 'PayloadExpectedWithdrawals' (offset) - offset44 := int(binary.LittleEndian.Uint32(buf[2741113:2741117])) - if offset44 < offset43 || offset44 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset44, offset43, buflen), "PayloadExpectedWithdrawals:o") + offset44, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "PayloadExpectedWithdrawals") + } + if offset44 < offset43 || offset44 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset44, offset43, maxOffset), "PayloadExpectedWithdrawals") } { // Field #45 'PTCWindow' (static) - buf := buf[2741117:3134333] - val7 := t.PTCWindow - val7 = sszutils.ExpandSlice(val7, 96) - for idx1 := range 96 { - val8 := val7[idx1] - buf := buf[4096*idx1 : 4096*(idx1+1)] - val8 = sszutils.ExpandSlice(val8, 512) - sszutils.UnmarshalUint64Slice(val8[:512], buf) - val7[idx1] = val8 + val11 := t.PTCWindow + val11 = sszutils.ExpandSlice(val11, int(expr8)) + startPos7 := dec.GetPosition() + for idx1 := range int(expr8) { + val12 := val11[idx1] + val12 = sszutils.ExpandSlice(val12, int(expr7)) + if err = sszutils.DecodeUint64Slice(dec, val12[:int(expr7)]); err != nil { + return sszutils.ErrorWithPathf(err, "PTCWindow[%d]", idx1) + } + if dec.GetPosition() != startPos7+int(size10*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos7+int(size10*(idx1+1))), "PTCWindow[%d]", idx1) + } + val11[idx1] = val12 } - t.PTCWindow = val7 + t.PTCWindow = val11 } { // Field #7 'HistoricalRoots' (dynamic) - buf := buf[offset7:offset9] - val9 := t.HistoricalRoots - itemCount := len(buf) / 32 - if len(buf)%32 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 32), "HistoricalRoots") + if dec.GetPosition() != startPos0+int(offset7) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset7)), "HistoricalRoots") + } + dec.PushLimit(int(offset9 - offset7)) + val13 := t.HistoricalRoots + sszLen := dec.GetLength() + itemCount := sszLen / 32 + if sszLen%32 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 32), "HistoricalRoots") } if itemCount > 16777216 { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 16777216), "HistoricalRoots") } - val9 = sszutils.ExpandSlice(val9, itemCount) + val13 = sszutils.ExpandSlice(val13, itemCount) + startPos8 := dec.GetPosition() for idx1 := range itemCount { - buf := buf[32*idx1 : 32*(idx1+1)] - copy(val9[idx1][:], buf) + if _, err = dec.DecodeBytes(val13[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos8+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos8+int(32*(idx1+1))), "HistoricalRoots[%d]", idx1) + } } - t.HistoricalRoots = val9 + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "HistoricalRoots") + } + t.HistoricalRoots = val13 } { // Field #9 'ETH1DataVotes' (dynamic) - buf := buf[offset9:offset11] - val10 := t.ETH1DataVotes - itemCount := len(buf) / 72 - if len(buf)%72 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 72), "ETH1DataVotes") + if dec.GetPosition() != startPos0+int(offset9) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset9)), "ETH1DataVotes") } - if itemCount > 2048 { - return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 2048), "ETH1DataVotes") + dec.PushLimit(int(offset11 - offset9)) + val14 := t.ETH1DataVotes + sszLen := dec.GetLength() + itemCount := sszLen / 72 + if sszLen%72 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 72), "ETH1DataVotes") } - val10 = sszutils.ExpandSlice(val10, itemCount) + if itemCount > int(expr9) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr9)), "ETH1DataVotes") + } + val14 = sszutils.ExpandSlice(val14, itemCount) + startPos9 := dec.GetPosition() for idx1 := range itemCount { - if val10[idx1] == nil { - val10[idx1] = new(phase0.ETH1Data) + if val14[idx1] == nil { + val14[idx1] = new(phase0.ETH1Data) } - buf := buf[72*idx1 : 72*(idx1+1)] - if err = val10[idx1].UnmarshalSSZ(buf); err != nil { + if buf, err := dec.DecodeBytesBuf(72); err != nil { return sszutils.ErrorWithPathf(err, "ETH1DataVotes[%d]", idx1) + } else if err = val14[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "ETH1DataVotes[%d]", idx1) + } + if dec.GetPosition() != startPos9+int(72*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos9+int(72*(idx1+1))), "ETH1DataVotes[%d]", idx1) } } - t.ETH1DataVotes = val10 + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "ETH1DataVotes") + } + t.ETH1DataVotes = val14 } { // Field #11 'Validators' (dynamic) - buf := buf[offset11:offset12] - val11 := t.Validators - itemCount := len(buf) / 121 - if len(buf)%121 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 121), "Validators") + if dec.GetPosition() != startPos0+int(offset11) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset11)), "Validators") + } + dec.PushLimit(int(offset12 - offset11)) + val15 := t.Validators + sszLen := dec.GetLength() + itemCount := sszLen / 121 + if sszLen%121 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 121), "Validators") } if itemCount > 1099511627776 { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1099511627776), "Validators") } - val11 = sszutils.ExpandSlice(val11, itemCount) + val15 = sszutils.ExpandSlice(val15, itemCount) + startPos10 := dec.GetPosition() for idx1 := range itemCount { - if val11[idx1] == nil { - val11[idx1] = new(phase0.Validator) + if val15[idx1] == nil { + val15[idx1] = new(phase0.Validator) } - buf := buf[121*idx1 : 121*(idx1+1)] - if err = val11[idx1].UnmarshalSSZ(buf); err != nil { + if buf, err := dec.DecodeBytesBuf(121); err != nil { return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } else if err = val15[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } + if dec.GetPosition() != startPos10+int(121*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos10+int(121*(idx1+1))), "Validators[%d]", idx1) } } - t.Validators = val11 + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Validators") + } + t.Validators = val15 } { // Field #12 'Balances' (dynamic) - buf := buf[offset12:offset15] - val12 := t.Balances - itemCount := len(buf) / 8 - if len(buf)%8 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 8), "Balances") + if dec.GetPosition() != startPos0+int(offset12) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset12)), "Balances") + } + dec.PushLimit(int(offset15 - offset12)) + val16 := t.Balances + sszLen := dec.GetLength() + itemCount := sszLen / 8 + if sszLen%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 8), "Balances") } if itemCount > 1099511627776 { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1099511627776), "Balances") } - val12 = sszutils.ExpandSlice(val12, itemCount) - sszutils.UnmarshalUint64Slice(val12, buf) - t.Balances = val12 + val16 = sszutils.ExpandSlice(val16, itemCount) + if err = sszutils.DecodeUint64Slice(dec, val16); err != nil { + return sszutils.ErrorWithPath(err, "Balances") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Balances") + } + t.Balances = val16 } { // Field #15 'PreviousEpochParticipation' (dynamic) - buf := buf[offset15:offset16] - val13 := t.PreviousEpochParticipation - itemCount := len(buf) + if dec.GetPosition() != startPos0+int(offset15) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset15)), "PreviousEpochParticipation") + } + dec.PushLimit(int(offset16 - offset15)) + val17 := t.PreviousEpochParticipation + itemCount := dec.GetLength() if itemCount > 1099511627776 { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1099511627776), "PreviousEpochParticipation") } - val13 = sszutils.ExpandSlice(val13, itemCount) + val17 = sszutils.ExpandSlice(val17, itemCount) + startPos11 := dec.GetPosition() for idx1 := range itemCount { - buf := buf[1*idx1 : 1*(idx1+1)] - val13[idx1] = altair.ParticipationFlags(buf[0]) + if val, err := dec.DecodeUint8(); err != nil { + return sszutils.ErrorWithPathf(err, "PreviousEpochParticipation[%d]", idx1) + } else { + val17[idx1] = altair.ParticipationFlags(val) + } + if dec.GetPosition() != startPos11+int(1*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos11+int(1*(idx1+1))), "PreviousEpochParticipation[%d]", idx1) + } } - t.PreviousEpochParticipation = val13 + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "PreviousEpochParticipation") + } + t.PreviousEpochParticipation = val17 } { // Field #16 'CurrentEpochParticipation' (dynamic) - buf := buf[offset16:offset21] - val14 := t.CurrentEpochParticipation - itemCount := len(buf) + if dec.GetPosition() != startPos0+int(offset16) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset16)), "CurrentEpochParticipation") + } + dec.PushLimit(int(offset21 - offset16)) + val18 := t.CurrentEpochParticipation + itemCount := dec.GetLength() if itemCount > 1099511627776 { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1099511627776), "CurrentEpochParticipation") } - val14 = sszutils.ExpandSlice(val14, itemCount) + val18 = sszutils.ExpandSlice(val18, itemCount) + startPos12 := dec.GetPosition() for idx1 := range itemCount { - buf := buf[1*idx1 : 1*(idx1+1)] - val14[idx1] = altair.ParticipationFlags(buf[0]) + if val, err := dec.DecodeUint8(); err != nil { + return sszutils.ErrorWithPathf(err, "CurrentEpochParticipation[%d]", idx1) + } else { + val18[idx1] = altair.ParticipationFlags(val) + } + if dec.GetPosition() != startPos12+int(1*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos12+int(1*(idx1+1))), "CurrentEpochParticipation[%d]", idx1) + } } - t.CurrentEpochParticipation = val14 + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "CurrentEpochParticipation") + } + t.CurrentEpochParticipation = val18 } { // Field #21 'InactivityScores' (dynamic) - buf := buf[offset21:offset27] - val15 := t.InactivityScores - itemCount := len(buf) / 8 - if len(buf)%8 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 8), "InactivityScores") + if dec.GetPosition() != startPos0+int(offset21) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset21)), "InactivityScores") + } + dec.PushLimit(int(offset27 - offset21)) + val19 := t.InactivityScores + sszLen := dec.GetLength() + itemCount := sszLen / 8 + if sszLen%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 8), "InactivityScores") } if itemCount > 1099511627776 { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1099511627776), "InactivityScores") } - val15 = sszutils.ExpandSlice(val15, itemCount) - sszutils.UnmarshalUint64Slice(val15, buf) - t.InactivityScores = val15 + val19 = sszutils.ExpandSlice(val19, itemCount) + if err = sszutils.DecodeUint64Slice(dec, val19); err != nil { + return sszutils.ErrorWithPath(err, "InactivityScores") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "InactivityScores") + } + t.InactivityScores = val19 } { // Field #27 'HistoricalSummaries' (dynamic) - buf := buf[offset27:offset34] - val16 := t.HistoricalSummaries - itemCount := len(buf) / 64 - if len(buf)%64 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 64), "HistoricalSummaries") + if dec.GetPosition() != startPos0+int(offset27) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset27)), "HistoricalSummaries") + } + dec.PushLimit(int(offset34 - offset27)) + val20 := t.HistoricalSummaries + sszLen := dec.GetLength() + itemCount := sszLen / 64 + if sszLen%64 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 64), "HistoricalSummaries") } if itemCount > 16777216 { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 16777216), "HistoricalSummaries") } - val16 = sszutils.ExpandSlice(val16, itemCount) + val20 = sszutils.ExpandSlice(val20, itemCount) + startPos13 := dec.GetPosition() for idx1 := range itemCount { - if val16[idx1] == nil { - val16[idx1] = new(capella.HistoricalSummary) + if val20[idx1] == nil { + val20[idx1] = new(capella.HistoricalSummary) } - buf := buf[64*idx1 : 64*(idx1+1)] - if err = val16[idx1].UnmarshalSSZ(buf); err != nil { + if buf, err := dec.DecodeBytesBuf(64); err != nil { + return sszutils.ErrorWithPathf(err, "HistoricalSummaries[%d]", idx1) + } else if err = val20[idx1].UnmarshalSSZ(buf); err != nil { return sszutils.ErrorWithPathf(err, "HistoricalSummaries[%d]", idx1) } + if dec.GetPosition() != startPos13+int(64*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos13+int(64*(idx1+1))), "HistoricalSummaries[%d]", idx1) + } } - t.HistoricalSummaries = val16 + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "HistoricalSummaries") + } + t.HistoricalSummaries = val20 } { // Field #34 'PendingDeposits' (dynamic) - buf := buf[offset34:offset35] - val17 := t.PendingDeposits - itemCount := len(buf) / 192 - if len(buf)%192 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 192), "PendingDeposits") + if dec.GetPosition() != startPos0+int(offset34) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset34)), "PendingDeposits") } - if itemCount > 134217728 { - return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 134217728), "PendingDeposits") + dec.PushLimit(int(offset35 - offset34)) + val21 := t.PendingDeposits + sszLen := dec.GetLength() + itemCount := sszLen / 192 + if sszLen%192 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 192), "PendingDeposits") } - val17 = sszutils.ExpandSlice(val17, itemCount) + if itemCount > int(expr10) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr10)), "PendingDeposits") + } + val21 = sszutils.ExpandSlice(val21, itemCount) + startPos14 := dec.GetPosition() for idx1 := range itemCount { - if val17[idx1] == nil { - val17[idx1] = new(electra.PendingDeposit) + if val21[idx1] == nil { + val21[idx1] = new(electra.PendingDeposit) } - buf := buf[192*idx1 : 192*(idx1+1)] - if err = val17[idx1].UnmarshalSSZ(buf); err != nil { + if buf, err := dec.DecodeBytesBuf(192); err != nil { return sszutils.ErrorWithPathf(err, "PendingDeposits[%d]", idx1) + } else if err = val21[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "PendingDeposits[%d]", idx1) + } + if dec.GetPosition() != startPos14+int(192*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos14+int(192*(idx1+1))), "PendingDeposits[%d]", idx1) } } - t.PendingDeposits = val17 + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "PendingDeposits") + } + t.PendingDeposits = val21 } { // Field #35 'PendingPartialWithdrawals' (dynamic) - buf := buf[offset35:offset36] - val18 := t.PendingPartialWithdrawals - itemCount := len(buf) / 24 - if len(buf)%24 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 24), "PendingPartialWithdrawals") + if dec.GetPosition() != startPos0+int(offset35) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset35)), "PendingPartialWithdrawals") } - if itemCount > 134217728 { - return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 134217728), "PendingPartialWithdrawals") + dec.PushLimit(int(offset36 - offset35)) + val22 := t.PendingPartialWithdrawals + sszLen := dec.GetLength() + itemCount := sszLen / 24 + if sszLen%24 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 24), "PendingPartialWithdrawals") } - val18 = sszutils.ExpandSlice(val18, itemCount) + if itemCount > int(expr11) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr11)), "PendingPartialWithdrawals") + } + val22 = sszutils.ExpandSlice(val22, itemCount) + startPos15 := dec.GetPosition() for idx1 := range itemCount { - if val18[idx1] == nil { - val18[idx1] = new(electra.PendingPartialWithdrawal) + if val22[idx1] == nil { + val22[idx1] = new(electra.PendingPartialWithdrawal) } - buf := buf[24*idx1 : 24*(idx1+1)] - if err = val18[idx1].UnmarshalSSZ(buf); err != nil { + if buf, err := dec.DecodeBytesBuf(24); err != nil { + return sszutils.ErrorWithPathf(err, "PendingPartialWithdrawals[%d]", idx1) + } else if err = val22[idx1].UnmarshalSSZ(buf); err != nil { return sszutils.ErrorWithPathf(err, "PendingPartialWithdrawals[%d]", idx1) } + if dec.GetPosition() != startPos15+int(24*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos15+int(24*(idx1+1))), "PendingPartialWithdrawals[%d]", idx1) + } } - t.PendingPartialWithdrawals = val18 + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "PendingPartialWithdrawals") + } + t.PendingPartialWithdrawals = val22 } { // Field #36 'PendingConsolidations' (dynamic) - buf := buf[offset36:offset38] - val19 := t.PendingConsolidations - itemCount := len(buf) / 16 - if len(buf)%16 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 16), "PendingConsolidations") + if dec.GetPosition() != startPos0+int(offset36) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset36)), "PendingConsolidations") } - if itemCount > 262144 { - return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 262144), "PendingConsolidations") + dec.PushLimit(int(offset38 - offset36)) + val23 := t.PendingConsolidations + sszLen := dec.GetLength() + itemCount := sszLen / 16 + if sszLen%16 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 16), "PendingConsolidations") } - val19 = sszutils.ExpandSlice(val19, itemCount) + if itemCount > int(expr12) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr12)), "PendingConsolidations") + } + val23 = sszutils.ExpandSlice(val23, itemCount) + startPos16 := dec.GetPosition() for idx1 := range itemCount { - if val19[idx1] == nil { - val19[idx1] = new(electra.PendingConsolidation) + if val23[idx1] == nil { + val23[idx1] = new(electra.PendingConsolidation) } - buf := buf[16*idx1 : 16*(idx1+1)] - if err = val19[idx1].UnmarshalSSZ(buf); err != nil { + if buf, err := dec.DecodeBytesBuf(16); err != nil { return sszutils.ErrorWithPathf(err, "PendingConsolidations[%d]", idx1) + } else if err = val23[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "PendingConsolidations[%d]", idx1) + } + if dec.GetPosition() != startPos16+int(16*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos16+int(16*(idx1+1))), "PendingConsolidations[%d]", idx1) } } - t.PendingConsolidations = val19 + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "PendingConsolidations") + } + t.PendingConsolidations = val23 } { // Field #38 'Builders' (dynamic) - buf := buf[offset38:offset42] - val20 := t.Builders - itemCount := len(buf) / 93 - if len(buf)%93 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 93), "Builders") + if dec.GetPosition() != startPos0+int(offset38) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset38)), "Builders") } - if itemCount > 1099511627776 { - return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1099511627776), "Builders") + dec.PushLimit(int(offset42 - offset38)) + val24 := t.Builders + sszLen := dec.GetLength() + itemCount := sszLen / 93 + if sszLen%93 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 93), "Builders") } - val20 = sszutils.ExpandSlice(val20, itemCount) + if itemCount > int(expr13) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr13)), "Builders") + } + val24 = sszutils.ExpandSlice(val24, itemCount) + startPos17 := dec.GetPosition() for idx1 := range itemCount { - if val20[idx1] == nil { - val20[idx1] = new(Builder) + if val24[idx1] == nil { + val24[idx1] = new(Builder) } - buf := buf[93*idx1 : 93*(idx1+1)] - if err = val20[idx1].UnmarshalSSZ(buf); err != nil { + if buf, err := dec.DecodeBytesBuf(93); err != nil { + return sszutils.ErrorWithPathf(err, "Builders[%d]", idx1) + } else if err = val24[idx1].UnmarshalSSZ(buf); err != nil { return sszutils.ErrorWithPathf(err, "Builders[%d]", idx1) } + if dec.GetPosition() != startPos17+int(93*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos17+int(93*(idx1+1))), "Builders[%d]", idx1) + } } - t.Builders = val20 + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Builders") + } + t.Builders = val24 } { // Field #42 'BuilderPendingWithdrawals' (dynamic) - buf := buf[offset42:offset43] - val21 := t.BuilderPendingWithdrawals - itemCount := len(buf) / 36 - if len(buf)%36 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 36), "BuilderPendingWithdrawals") + if dec.GetPosition() != startPos0+int(offset42) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset42)), "BuilderPendingWithdrawals") } - if itemCount > 1048576 { - return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1048576), "BuilderPendingWithdrawals") + dec.PushLimit(int(offset43 - offset42)) + val25 := t.BuilderPendingWithdrawals + sszLen := dec.GetLength() + itemCount := sszLen / 36 + if sszLen%36 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 36), "BuilderPendingWithdrawals") } - val21 = sszutils.ExpandSlice(val21, itemCount) + if itemCount > int(expr14) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr14)), "BuilderPendingWithdrawals") + } + val25 = sszutils.ExpandSlice(val25, itemCount) + startPos18 := dec.GetPosition() for idx1 := range itemCount { - if val21[idx1] == nil { - val21[idx1] = new(BuilderPendingWithdrawal) + if val25[idx1] == nil { + val25[idx1] = new(BuilderPendingWithdrawal) } - buf := buf[36*idx1 : 36*(idx1+1)] - if err = val21[idx1].UnmarshalSSZ(buf); err != nil { + if buf, err := dec.DecodeBytesBuf(36); err != nil { return sszutils.ErrorWithPathf(err, "BuilderPendingWithdrawals[%d]", idx1) + } else if err = val25[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "BuilderPendingWithdrawals[%d]", idx1) + } + if dec.GetPosition() != startPos18+int(36*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos18+int(36*(idx1+1))), "BuilderPendingWithdrawals[%d]", idx1) } } - t.BuilderPendingWithdrawals = val21 + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "BuilderPendingWithdrawals") + } + t.BuilderPendingWithdrawals = val25 } { // Field #43 'LatestExecutionPayloadBid' (dynamic) - buf := buf[offset43:offset44] - if t.LatestExecutionPayloadBid == nil { - t.LatestExecutionPayloadBid = new(ExecutionPayloadBid) + if dec.GetPosition() != startPos0+int(offset43) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset43)), "LatestExecutionPayloadBid") } - if err = t.LatestExecutionPayloadBid.UnmarshalSSZ(buf); err != nil { + dec.PushLimit(int(offset44 - offset43)) + val26 := t.LatestExecutionPayloadBid + if val26 == nil { + val26 = new(ExecutionPayloadBid) + } + if buf, err := dec.DecodeBytesBuf(dec.GetLength()); err != nil { + return sszutils.ErrorWithPath(err, "LatestExecutionPayloadBid") + } else if err = val26.UnmarshalSSZ(buf); err != nil { return sszutils.ErrorWithPath(err, "LatestExecutionPayloadBid") } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "LatestExecutionPayloadBid") + } + t.LatestExecutionPayloadBid = val26 } { // Field #44 'PayloadExpectedWithdrawals' (dynamic) - buf := buf[offset44:] - val22 := t.PayloadExpectedWithdrawals - itemCount := len(buf) / 44 - if len(buf)%44 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 44), "PayloadExpectedWithdrawals") + if dec.GetPosition() != startPos0+int(offset44) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset44)), "PayloadExpectedWithdrawals") } - if itemCount > 16 { - return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 16), "PayloadExpectedWithdrawals") + dec.PushLimit(int(maxOffset - offset44)) + val27 := t.PayloadExpectedWithdrawals + sszLen := dec.GetLength() + itemCount := sszLen / 44 + if sszLen%44 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 44), "PayloadExpectedWithdrawals") } - val22 = sszutils.ExpandSlice(val22, itemCount) + if itemCount > int(expr15) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr15)), "PayloadExpectedWithdrawals") + } + val27 = sszutils.ExpandSlice(val27, itemCount) + startPos19 := dec.GetPosition() for idx1 := range itemCount { - if val22[idx1] == nil { - val22[idx1] = new(capella.Withdrawal) + if val27[idx1] == nil { + val27[idx1] = new(capella.Withdrawal) } - buf := buf[44*idx1 : 44*(idx1+1)] - if err = val22[idx1].UnmarshalSSZ(buf); err != nil { + if buf, err := dec.DecodeBytesBuf(44); err != nil { return sszutils.ErrorWithPathf(err, "PayloadExpectedWithdrawals[%d]", idx1) + } else if err = val27[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "PayloadExpectedWithdrawals[%d]", idx1) + } + if dec.GetPosition() != startPos19+int(44*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos19+int(44*(idx1+1))), "PayloadExpectedWithdrawals[%d]", idx1) } } - t.PayloadExpectedWithdrawals = val22 + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "PayloadExpectedWithdrawals") + } + t.PayloadExpectedWithdrawals = val27 } return nil } diff --git a/spec/gloas/generate.yaml b/spec/gloas/generate.yaml index 43a2e981..038d548b 100644 --- a/spec/gloas/generate.yaml +++ b/spec/gloas/generate.yaml @@ -9,6 +9,7 @@ types: output: beaconblock_ssz.go - name: BeaconState output: beaconstate_ssz.go + with-streaming: true - name: Builder output: builder_ssz.go - name: BuilderPendingPayment diff --git a/spec/heze/beaconstate_ssz.go b/spec/heze/beaconstate_ssz.go index 33707b65..29bb3d89 100644 --- a/spec/heze/beaconstate_ssz.go +++ b/spec/heze/beaconstate_ssz.go @@ -1,5 +1,5 @@ // Code generated by dynamic-ssz. DO NOT EDIT. -// Hash: 809734e2d17ff86d3fdc3cfefa88b2a5ff9a64f9874c0b5dd26a9e299d7ff299 +// Hash: dd891ada1387b473df68a4997fb6a407c607ee49947fe2366645979d69697cf1 // Version: v1.3.1 (https://github.com/pk910/dynamic-ssz) package heze @@ -8,6 +8,7 @@ import ( "github.com/ethpandaops/go-eth2-client/spec/altair" "github.com/ethpandaops/go-eth2-client/spec/capella" + "github.com/ethpandaops/go-eth2-client/spec/deneb" "github.com/ethpandaops/go-eth2-client/spec/electra" "github.com/ethpandaops/go-eth2-client/spec/gloas" "github.com/ethpandaops/go-eth2-client/spec/phase0" @@ -507,576 +508,2575 @@ func (t *BeaconState) MarshalSSZTo(buf []byte) (dst []byte, err error) { return dst, nil } +// MarshalSSZEncoder marshals the *BeaconState to the given SSZ encoder using dynamic specifications. +func (t *BeaconState) MarshalSSZEncoder(ds sszutils.DynamicSpecs, enc sszutils.Encoder) (err error) { + type encoderCtx struct { + ds sszutils.DynamicSpecs + exprs [18]uint64 + sizeFn1 func(ctx *encoderCtx, t []phase0.Root) (size int) + sizeFn10 func(ctx *encoderCtx, t []*electra.PendingPartialWithdrawal) (size int) + sizeFn11 func(ctx *encoderCtx, t []*electra.PendingConsolidation) (size int) + sizeFn12 func(ctx *encoderCtx, t []*gloas.Builder) (size int) + sizeFn13 func(ctx *encoderCtx, t []*gloas.BuilderPendingWithdrawal) (size int) + sizeFn14 func(ctx *encoderCtx, t *ExecutionPayloadBid) (size int) + sizeFn15 func(ctx *encoderCtx, t []*capella.Withdrawal) (size int) + sizeFn16 func(ctx *encoderCtx, t []deneb.KZGCommitment) (size int) + sizeFn2 func(ctx *encoderCtx, t []*phase0.ETH1Data) (size int) + sizeFn3 func(ctx *encoderCtx, t []*phase0.Validator) (size int) + sizeFn4 func(ctx *encoderCtx, t []phase0.Gwei) (size int) + sizeFn5 func(ctx *encoderCtx, t []altair.ParticipationFlags) (size int) + sizeFn6 func(ctx *encoderCtx, t []altair.ParticipationFlags) (size int) + sizeFn7 func(ctx *encoderCtx, t []uint64) (size int) + sizeFn8 func(ctx *encoderCtx, t []*capella.HistoricalSummary) (size int) + sizeFn9 func(ctx *encoderCtx, t []*electra.PendingDeposit) (size int) + } + ctx := &encoderCtx{ds: ds} + canSeek := enc.Seekable() + ctx.exprs[0], err = sszutils.ResolveSpecValueWithDefault(ds, "SLOTS_PER_HISTORICAL_ROOT", 8192) + if err != nil { + return err + } + ctx.exprs[1], err = sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_HISTORICAL_VECTOR", 65536) + if err != nil { + return err + } + ctx.exprs[2], err = sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_SLASHINGS_VECTOR", 8192) + if err != nil { + return err + } + ctx.exprs[3], err = sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE", 512) + if err != nil { + return err + } + ctx.exprs[4], err = sszutils.ResolveSpecValueWithDefault(ds, "(MIN_SEED_LOOKAHEAD+1)*SLOTS_PER_EPOCH", 64) + if err != nil { + return err + } + ctx.exprs[5], err = sszutils.ResolveSpecValueWithDefault(ds, "SLOTS_PER_HISTORICAL_ROOT/8", 1024) + if err != nil { + return err + } + ctx.exprs[6], err = sszutils.ResolveSpecValueWithDefault(ds, "SLOTS_PER_EPOCH*2", 64) + if err != nil { + return err + } + ctx.exprs[7], err = sszutils.ResolveSpecValueWithDefault(ds, "PTC_SIZE", 512) + if err != nil { + return err + } + ctx.exprs[8], err = sszutils.ResolveSpecValueWithDefault(ds, "(2+MIN_SEED_LOOKAHEAD)*SLOTS_PER_EPOCH", 96) + if err != nil { + return err + } + ctx.exprs[9], err = sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_ETH1_VOTING_PERIOD*SLOTS_PER_EPOCH", 2048) + if err != nil { + return err + } + ctx.exprs[10], err = sszutils.ResolveSpecValueWithDefault(ds, "PENDING_DEPOSITS_LIMIT", 134217728) + if err != nil { + return err + } + ctx.exprs[11], err = sszutils.ResolveSpecValueWithDefault(ds, "PENDING_PARTIAL_WITHDRAWALS_LIMIT", 134217728) + if err != nil { + return err + } + ctx.exprs[12], err = sszutils.ResolveSpecValueWithDefault(ds, "PENDING_CONSOLIDATIONS_LIMIT", 262144) + if err != nil { + return err + } + ctx.exprs[13], err = sszutils.ResolveSpecValueWithDefault(ds, "BUILDER_REGISTRY_LIMIT", 1099511627776) + if err != nil { + return err + } + ctx.exprs[14], err = sszutils.ResolveSpecValueWithDefault(ds, "BUILDER_PENDING_WITHDRAWALS_LIMIT", 1048576) + if err != nil { + return err + } + ctx.exprs[15], err = sszutils.ResolveSpecValueWithDefault(ds, "INCLUSION_LIST_COMMITTEE_SIZE/8", 2) + if err != nil { + return err + } + ctx.exprs[16], err = sszutils.ResolveSpecValueWithDefault(ds, "MAX_BLOB_COMMITMENTS_PER_BLOCK", 4096) + if err != nil { + return err + } + ctx.exprs[17], err = sszutils.ResolveSpecValueWithDefault(ds, "MAX_WITHDRAWALS_PER_PAYLOAD", 16) + if err != nil { + return err + } + // size for []phase0.Root + ctx.sizeFn1 = func(ctx *encoderCtx, t []phase0.Root) (size int) { + size += len(t) * 32 + return size + } + // size for []*phase0.ETH1Data + ctx.sizeFn2 = func(ctx *encoderCtx, t []*phase0.ETH1Data) (size int) { + size += len(t) * 72 + return size + } + // size for []*phase0.Validator + ctx.sizeFn3 = func(ctx *encoderCtx, t []*phase0.Validator) (size int) { + size += len(t) * 121 + return size + } + // size for []phase0.Gwei + ctx.sizeFn4 = func(ctx *encoderCtx, t []phase0.Gwei) (size int) { + size += len(t) * 8 + return size + } + // size for []altair.ParticipationFlags + ctx.sizeFn5 = func(ctx *encoderCtx, t []altair.ParticipationFlags) (size int) { + size += len(t) + return size + } + // size for []altair.ParticipationFlags + ctx.sizeFn6 = func(ctx *encoderCtx, t []altair.ParticipationFlags) (size int) { + size += len(t) + return size + } + // size for []uint64 + ctx.sizeFn7 = func(ctx *encoderCtx, t []uint64) (size int) { + size += len(t) * 8 + return size + } + // size for []*capella.HistoricalSummary + ctx.sizeFn8 = func(ctx *encoderCtx, t []*capella.HistoricalSummary) (size int) { + size += len(t) * 64 + return size + } + // size for []*electra.PendingDeposit + ctx.sizeFn9 = func(ctx *encoderCtx, t []*electra.PendingDeposit) (size int) { + size += len(t) * 192 + return size + } + // size for []*electra.PendingPartialWithdrawal + ctx.sizeFn10 = func(ctx *encoderCtx, t []*electra.PendingPartialWithdrawal) (size int) { + size += len(t) * 24 + return size + } + // size for []*electra.PendingConsolidation + ctx.sizeFn11 = func(ctx *encoderCtx, t []*electra.PendingConsolidation) (size int) { + size += len(t) * 16 + return size + } + // size for []*gloas.Builder + ctx.sizeFn12 = func(ctx *encoderCtx, t []*gloas.Builder) (size int) { + size += len(t) * 93 + return size + } + // size for []*gloas.BuilderPendingWithdrawal + ctx.sizeFn13 = func(ctx *encoderCtx, t []*gloas.BuilderPendingWithdrawal) (size int) { + size += len(t) * 36 + return size + } + // size for *ExecutionPayloadBid + ctx.sizeFn14 = func(ctx *encoderCtx, t *ExecutionPayloadBid) (size int) { + if t == nil { + t = new(ExecutionPayloadBid) + } + // Field #0 'ParentBlockHash' static (32 bytes) + // Field #1 'ParentBlockRoot' static (32 bytes) + // Field #2 'BlockHash' static (32 bytes) + // Field #3 'PrevRandao' static (32 bytes) + // Field #4 'FeeRecipient' static (20 bytes) + // Field #5 'GasLimit' static (8 bytes) + // Field #6 'BuilderIndex' static (8 bytes) + // Field #7 'Slot' static (8 bytes) + // Field #8 'Value' static (8 bytes) + // Field #9 'ExecutionPayment' static (8 bytes) + // Field #10 'BlobKZGCommitments' offset (4 bytes) + // Field #11 'ExecutionRequestsRoot' static (32 bytes) + size += 224 + { // Field #12 'InclusionListBits' + size += int(ctx.exprs[15]) + } + { // Dynamic field #10 'BlobKZGCommitments' + size += ctx.sizeFn16(ctx, t.BlobKZGCommitments) + } + return size + } + // size for []*capella.Withdrawal + ctx.sizeFn15 = func(ctx *encoderCtx, t []*capella.Withdrawal) (size int) { + size += len(t) * 44 + return size + } + // size for []deneb.KZGCommitment + ctx.sizeFn16 = func(ctx *encoderCtx, t []deneb.KZGCommitment) (size int) { + size += len(t) * 48 + return size + } + size1 := 32 * int(ctx.exprs[0]) + size2 := 32 * int(ctx.exprs[1]) + size3 := 8 * int(ctx.exprs[2]) + size5 := 48 * int(ctx.exprs[3]) + size4 := size5 + 48 // size expression for '*SyncCommittee' + size6 := 8 * int(ctx.exprs[4]) + size7 := 1 * int(ctx.exprs[5]) + size8 := 44 * int(ctx.exprs[6]) + size10 := 8 * int(ctx.exprs[7]) + size9 := size10 * int(ctx.exprs[8]) + size11 := 1 * int(ctx.exprs[15]) + if t == nil { + t = new(BeaconState) + } + dstlen := enc.GetPosition() + dynoff := uint32(size1 + size1 + size2 + size3 + size4 + size4 + size6 + size7 + size8 + size9 + 541) + { // Field #0 'GenesisTime' + enc.EncodeUint64(t.GenesisTime) + } + { // Field #1 'GenesisValidatorsRoot' + enc.EncodeBytes(t.GenesisValidatorsRoot[:32]) + } + { // Field #2 'Slot' + enc.EncodeUint64(uint64(t.Slot)) + } + { // Field #3 'Fork' + t := t.Fork + if t == nil { + t = new(phase0.Fork) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "Fork") + } else { + enc.SetBuffer(buf) + } + } + { // Field #4 'LatestBlockHeader' + t := t.LatestBlockHeader + if t == nil { + t = new(phase0.BeaconBlockHeader) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") + } else { + enc.SetBuffer(buf) + } + } + { // Field #5 'BlockRoots' + t := t.BlockRoots + vlen := len(t) + if vlen > int(ctx.exprs[0]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[0])), "BlockRoots") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:32]) + } + if vlen < int(ctx.exprs[0]) { + enc.EncodeZeroPadding((int(ctx.exprs[0]) - vlen) * 32) + } + } + { // Field #6 'StateRoots' + t := t.StateRoots + vlen := len(t) + if vlen > int(ctx.exprs[0]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[0])), "StateRoots") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:32]) + } + if vlen < int(ctx.exprs[0]) { + enc.EncodeZeroPadding((int(ctx.exprs[0]) - vlen) * 32) + } + } + // Offset #7 'HistoricalRoots' + offset7 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn1(ctx, t.HistoricalRoots)) + } + { // Field #8 'ETH1Data' + t := t.ETH1Data + if t == nil { + t = new(phase0.ETH1Data) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "ETH1Data") + } else { + enc.SetBuffer(buf) + } + } + // Offset #9 'ETH1DataVotes' + offset9 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn2(ctx, t.ETH1DataVotes)) + } + { // Field #10 'ETH1DepositIndex' + enc.EncodeUint64(t.ETH1DepositIndex) + } + // Offset #11 'Validators' + offset11 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn3(ctx, t.Validators)) + } + // Offset #12 'Balances' + offset12 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn4(ctx, t.Balances)) + } + { // Field #13 'RANDAOMixes' + t := t.RANDAOMixes + vlen := len(t) + if vlen > int(ctx.exprs[1]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[1])), "RANDAOMixes") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:32]) + } + if vlen < int(ctx.exprs[1]) { + enc.EncodeZeroPadding((int(ctx.exprs[1]) - vlen) * 32) + } + } + { // Field #14 'Slashings' + t := t.Slashings + vlen := len(t) + if vlen > int(ctx.exprs[2]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[2])), "Slashings") + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + if vlen < int(ctx.exprs[2]) { + enc.EncodeZeroPadding((int(ctx.exprs[2]) - vlen) * 8) + } + } + // Offset #15 'PreviousEpochParticipation' + offset15 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn5(ctx, t.PreviousEpochParticipation)) + } + // Offset #16 'CurrentEpochParticipation' + offset16 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn6(ctx, t.CurrentEpochParticipation)) + } + { // Field #17 'JustificationBits' + vlen := len(t.JustificationBits) + if vlen > 1 { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, 1), "JustificationBits") + } + enc.EncodeBytes(t.JustificationBits[:vlen]) + if vlen < 1 { + enc.EncodeZeroPadding((1 - vlen) * 1) + } + } + { // Field #18 'PreviousJustifiedCheckpoint' + t := t.PreviousJustifiedCheckpoint + if t == nil { + t = new(phase0.Checkpoint) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } else { + enc.SetBuffer(buf) + } + } + { // Field #19 'CurrentJustifiedCheckpoint' + t := t.CurrentJustifiedCheckpoint + if t == nil { + t = new(phase0.Checkpoint) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } else { + enc.SetBuffer(buf) + } + } + { // Field #20 'FinalizedCheckpoint' + t := t.FinalizedCheckpoint + if t == nil { + t = new(phase0.Checkpoint) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") + } else { + enc.SetBuffer(buf) + } + } + // Offset #21 'InactivityScores' + offset21 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn7(ctx, t.InactivityScores)) + } + { // Field #22 'CurrentSyncCommittee' + t := t.CurrentSyncCommittee + if t == nil { + t = new(altair.SyncCommittee) + } + { // Field #0 'Pubkeys' + t := t.Pubkeys + vlen := len(t) + if vlen > int(ctx.exprs[3]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[3])), "CurrentSyncCommittee.Pubkeys") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:48]) + } + if vlen < int(ctx.exprs[3]) { + enc.EncodeZeroPadding((int(ctx.exprs[3]) - vlen) * 48) + } + } + { // Field #1 'AggregatePubkey' + enc.EncodeBytes(t.AggregatePubkey[:48]) + } + } + { // Field #23 'NextSyncCommittee' + t := t.NextSyncCommittee + if t == nil { + t = new(altair.SyncCommittee) + } + { // Field #0 'Pubkeys' + t := t.Pubkeys + vlen := len(t) + if vlen > int(ctx.exprs[3]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[3])), "NextSyncCommittee.Pubkeys") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:48]) + } + if vlen < int(ctx.exprs[3]) { + enc.EncodeZeroPadding((int(ctx.exprs[3]) - vlen) * 48) + } + } + { // Field #1 'AggregatePubkey' + enc.EncodeBytes(t.AggregatePubkey[:48]) + } + } + { // Field #24 'LatestBlockHash' + enc.EncodeBytes(t.LatestBlockHash[:32]) + } + { // Field #25 'NextWithdrawalIndex' + enc.EncodeUint64(uint64(t.NextWithdrawalIndex)) + } + { // Field #26 'NextWithdrawalValidatorIndex' + enc.EncodeUint64(uint64(t.NextWithdrawalValidatorIndex)) + } + // Offset #27 'HistoricalSummaries' + offset27 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn8(ctx, t.HistoricalSummaries)) + } + { // Field #28 'DepositRequestsStartIndex' + enc.EncodeUint64(t.DepositRequestsStartIndex) + } + { // Field #29 'DepositBalanceToConsume' + enc.EncodeUint64(uint64(t.DepositBalanceToConsume)) + } + { // Field #30 'ExitBalanceToConsume' + enc.EncodeUint64(uint64(t.ExitBalanceToConsume)) + } + { // Field #31 'EarliestExitEpoch' + enc.EncodeUint64(uint64(t.EarliestExitEpoch)) + } + { // Field #32 'ConsolidationBalanceToConsume' + enc.EncodeUint64(uint64(t.ConsolidationBalanceToConsume)) + } + { // Field #33 'EarliestConsolidationEpoch' + enc.EncodeUint64(uint64(t.EarliestConsolidationEpoch)) + } + // Offset #34 'PendingDeposits' + offset34 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn9(ctx, t.PendingDeposits)) + } + // Offset #35 'PendingPartialWithdrawals' + offset35 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn10(ctx, t.PendingPartialWithdrawals)) + } + // Offset #36 'PendingConsolidations' + offset36 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn11(ctx, t.PendingConsolidations)) + } + { // Field #37 'ProposerLookahead' + t := t.ProposerLookahead + vlen := len(t) + if vlen > int(ctx.exprs[4]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[4])), "ProposerLookahead") + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + if vlen < int(ctx.exprs[4]) { + enc.EncodeZeroPadding((int(ctx.exprs[4]) - vlen) * 8) + } + } + // Offset #38 'Builders' + offset38 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn12(ctx, t.Builders)) + } + { // Field #39 'NextWithdrawalBuilderIndex' + enc.EncodeUint64(uint64(t.NextWithdrawalBuilderIndex)) + } + { // Field #40 'ExecutionPayloadAvailability' + vlen := len(t.ExecutionPayloadAvailability) + if vlen > int(ctx.exprs[5]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[5])), "ExecutionPayloadAvailability") + } + enc.EncodeBytes(t.ExecutionPayloadAvailability[:vlen]) + if vlen < int(ctx.exprs[5]) { + enc.EncodeZeroPadding((int(ctx.exprs[5]) - vlen) * 1) + } + } + { // Field #41 'BuilderPendingPayments' + t := t.BuilderPendingPayments + vlen := len(t) + if vlen > int(ctx.exprs[6]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[6])), "BuilderPendingPayments") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(gloas.BuilderPendingPayment) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "BuilderPendingPayments[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + if vlen < int(ctx.exprs[6]) { + enc.EncodeZeroPadding((int(ctx.exprs[6]) - vlen) * 44) + } + } + // Offset #42 'BuilderPendingWithdrawals' + offset42 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn13(ctx, t.BuilderPendingWithdrawals)) + } + // Offset #43 'LatestExecutionPayloadBid' + offset43 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn14(ctx, t.LatestExecutionPayloadBid)) + } + // Offset #44 'PayloadExpectedWithdrawals' + offset44 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn15(ctx, t.PayloadExpectedWithdrawals)) + } + { // Field #45 'PTCWindow' + t := t.PTCWindow + vlen := len(t) + if vlen > int(ctx.exprs[8]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[8])), "PTCWindow") + } + for idx1 := range vlen { + t := t[idx1] + vlen := len(t) + if vlen > int(ctx.exprs[7]) { + return sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[7])), "PTCWindow[%d]", idx1) + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + if vlen < int(ctx.exprs[7]) { + enc.EncodeZeroPadding((int(ctx.exprs[7]) - vlen) * 8) + } + } + if vlen < int(ctx.exprs[8]) { + enc.EncodeZeroPadding((int(ctx.exprs[8]) - vlen) * 4096) + } + } + { // Dynamic Field #7 'HistoricalRoots' + if canSeek { + enc.EncodeOffsetAt(offset7, uint32(enc.GetPosition()-dstlen)) + } + t := t.HistoricalRoots + vlen := len(t) + if vlen > 16777216 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16777216), "HistoricalRoots") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:32]) + } + } + { // Dynamic Field #9 'ETH1DataVotes' + if canSeek { + enc.EncodeOffsetAt(offset9, uint32(enc.GetPosition()-dstlen)) + } + t := t.ETH1DataVotes + vlen := len(t) + if vlen > int(ctx.exprs[9]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[9])), "ETH1DataVotes") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(phase0.ETH1Data) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "ETH1DataVotes[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #11 'Validators' + if canSeek { + enc.EncodeOffsetAt(offset11, uint32(enc.GetPosition()-dstlen)) + } + t := t.Validators + vlen := len(t) + if vlen > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1099511627776), "Validators") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(phase0.Validator) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #12 'Balances' + if canSeek { + enc.EncodeOffsetAt(offset12, uint32(enc.GetPosition()-dstlen)) + } + t := t.Balances + vlen := len(t) + if vlen > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1099511627776), "Balances") + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + } + { // Dynamic Field #15 'PreviousEpochParticipation' + if canSeek { + enc.EncodeOffsetAt(offset15, uint32(enc.GetPosition()-dstlen)) + } + t := t.PreviousEpochParticipation + vlen := len(t) + if vlen > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1099511627776), "PreviousEpochParticipation") + } + for idx1 := range vlen { + enc.EncodeUint8(byte(t[idx1])) + } + } + { // Dynamic Field #16 'CurrentEpochParticipation' + if canSeek { + enc.EncodeOffsetAt(offset16, uint32(enc.GetPosition()-dstlen)) + } + t := t.CurrentEpochParticipation + vlen := len(t) + if vlen > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1099511627776), "CurrentEpochParticipation") + } + for idx1 := range vlen { + enc.EncodeUint8(byte(t[idx1])) + } + } + { // Dynamic Field #21 'InactivityScores' + if canSeek { + enc.EncodeOffsetAt(offset21, uint32(enc.GetPosition()-dstlen)) + } + t := t.InactivityScores + vlen := len(t) + if vlen > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 1099511627776), "InactivityScores") + } + sszutils.EncodeUint64Slice(enc, t[:vlen]) + } + { // Dynamic Field #27 'HistoricalSummaries' + if canSeek { + enc.EncodeOffsetAt(offset27, uint32(enc.GetPosition()-dstlen)) + } + t := t.HistoricalSummaries + vlen := len(t) + if vlen > 16777216 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 16777216), "HistoricalSummaries") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(capella.HistoricalSummary) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "HistoricalSummaries[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #34 'PendingDeposits' + if canSeek { + enc.EncodeOffsetAt(offset34, uint32(enc.GetPosition()-dstlen)) + } + t := t.PendingDeposits + vlen := len(t) + if vlen > int(ctx.exprs[10]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[10])), "PendingDeposits") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(electra.PendingDeposit) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "PendingDeposits[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #35 'PendingPartialWithdrawals' + if canSeek { + enc.EncodeOffsetAt(offset35, uint32(enc.GetPosition()-dstlen)) + } + t := t.PendingPartialWithdrawals + vlen := len(t) + if vlen > int(ctx.exprs[11]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[11])), "PendingPartialWithdrawals") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(electra.PendingPartialWithdrawal) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "PendingPartialWithdrawals[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #36 'PendingConsolidations' + if canSeek { + enc.EncodeOffsetAt(offset36, uint32(enc.GetPosition()-dstlen)) + } + t := t.PendingConsolidations + vlen := len(t) + if vlen > int(ctx.exprs[12]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[12])), "PendingConsolidations") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(electra.PendingConsolidation) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "PendingConsolidations[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #38 'Builders' + if canSeek { + enc.EncodeOffsetAt(offset38, uint32(enc.GetPosition()-dstlen)) + } + t := t.Builders + vlen := len(t) + if vlen > int(ctx.exprs[13]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[13])), "Builders") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(gloas.Builder) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "Builders[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #42 'BuilderPendingWithdrawals' + if canSeek { + enc.EncodeOffsetAt(offset42, uint32(enc.GetPosition()-dstlen)) + } + t := t.BuilderPendingWithdrawals + vlen := len(t) + if vlen > int(ctx.exprs[14]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[14])), "BuilderPendingWithdrawals") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(gloas.BuilderPendingWithdrawal) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "BuilderPendingWithdrawals[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + { // Dynamic Field #43 'LatestExecutionPayloadBid' + if canSeek { + enc.EncodeOffsetAt(offset43, uint32(enc.GetPosition()-dstlen)) + } + t := t.LatestExecutionPayloadBid + if t == nil { + t = new(ExecutionPayloadBid) + } + dstlen := enc.GetPosition() + dynoff := uint32(size11 + 224) + { // Field #0 'ParentBlockHash' + enc.EncodeBytes(t.ParentBlockHash[:32]) + } + { // Field #1 'ParentBlockRoot' + enc.EncodeBytes(t.ParentBlockRoot[:32]) + } + { // Field #2 'BlockHash' + enc.EncodeBytes(t.BlockHash[:32]) + } + { // Field #3 'PrevRandao' + enc.EncodeBytes(t.PrevRandao[:32]) + } + { // Field #4 'FeeRecipient' + enc.EncodeBytes(t.FeeRecipient[:20]) + } + { // Field #5 'GasLimit' + enc.EncodeUint64(t.GasLimit) + } + { // Field #6 'BuilderIndex' + enc.EncodeUint64(uint64(t.BuilderIndex)) + } + { // Field #7 'Slot' + enc.EncodeUint64(uint64(t.Slot)) + } + { // Field #8 'Value' + enc.EncodeUint64(uint64(t.Value)) + } + { // Field #9 'ExecutionPayment' + enc.EncodeUint64(uint64(t.ExecutionPayment)) + } + // Offset #10 'BlobKZGCommitments' + offset10 := enc.GetPosition() + if canSeek { + enc.EncodeOffset(0) + } else { + enc.EncodeOffset(dynoff) + dynoff += uint32(ctx.sizeFn16(ctx, t.BlobKZGCommitments)) + } + { // Field #11 'ExecutionRequestsRoot' + enc.EncodeBytes(t.ExecutionRequestsRoot[:32]) + } + { // Field #12 'InclusionListBits' + vlen := len(t.InclusionListBits) + if vlen > int(ctx.exprs[15]) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(ctx.exprs[15])), "LatestExecutionPayloadBid.InclusionListBits") + } + enc.EncodeBytes(t.InclusionListBits[:vlen]) + if vlen < int(ctx.exprs[15]) { + enc.EncodeZeroPadding((int(ctx.exprs[15]) - vlen) * 1) + } + } + { // Dynamic Field #10 'BlobKZGCommitments' + if canSeek { + enc.EncodeOffsetAt(offset10, uint32(enc.GetPosition()-dstlen)) + } + t := t.BlobKZGCommitments + vlen := len(t) + if vlen > int(ctx.exprs[16]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[16])), "LatestExecutionPayloadBid.BlobKZGCommitments") + } + for idx1 := range vlen { + enc.EncodeBytes(t[idx1][:48]) + } + } + } + { // Dynamic Field #44 'PayloadExpectedWithdrawals' + if canSeek { + enc.EncodeOffsetAt(offset44, uint32(enc.GetPosition()-dstlen)) + } + t := t.PayloadExpectedWithdrawals + vlen := len(t) + if vlen > int(ctx.exprs[17]) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(ctx.exprs[17])), "PayloadExpectedWithdrawals") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(capella.Withdrawal) + } + if buf, err := t.MarshalSSZTo(enc.GetBuffer()); err != nil { + return sszutils.ErrorWithPathf(err, "PayloadExpectedWithdrawals[%d]", idx1) + } else { + enc.SetBuffer(buf) + } + } + } + return nil +} + // UnmarshalSSZ unmarshals the *BeaconState from SSZ-encoded bytes. func (t *BeaconState) UnmarshalSSZ(buf []byte) (err error) { buflen := len(buf) if buflen < 3134333 { return sszutils.ErrFixedFieldsEOFFn(buflen, 3134333) } - { // Field #0 'GenesisTime' (static) - buf := buf[0:8] - t.GenesisTime = binary.LittleEndian.Uint64(buf) + { // Field #0 'GenesisTime' (static) + buf := buf[0:8] + t.GenesisTime = binary.LittleEndian.Uint64(buf) + } + { // Field #1 'GenesisValidatorsRoot' (static) + buf := buf[8:40] + copy(t.GenesisValidatorsRoot[:], buf) + } + { // Field #2 'Slot' (static) + buf := buf[40:48] + t.Slot = phase0.Slot(binary.LittleEndian.Uint64(buf)) + } + { // Field #3 'Fork' (static) + buf := buf[48:64] + if t.Fork == nil { + t.Fork = new(phase0.Fork) + } + if err = t.Fork.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "Fork") + } + } + { // Field #4 'LatestBlockHeader' (static) + buf := buf[64:176] + if t.LatestBlockHeader == nil { + t.LatestBlockHeader = new(phase0.BeaconBlockHeader) + } + if err = t.LatestBlockHeader.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") + } + } + { // Field #5 'BlockRoots' (static) + buf := buf[176:262320] + val1 := t.BlockRoots + val1 = sszutils.ExpandSlice(val1, 8192) + for idx1 := range 8192 { + buf := buf[32*idx1 : 32*(idx1+1)] + copy(val1[idx1][:], buf) + } + t.BlockRoots = val1 + } + { // Field #6 'StateRoots' (static) + buf := buf[262320:524464] + val2 := t.StateRoots + val2 = sszutils.ExpandSlice(val2, 8192) + for idx1 := range 8192 { + buf := buf[32*idx1 : 32*(idx1+1)] + copy(val2[idx1][:], buf) + } + t.StateRoots = val2 + } + // Field #7 'HistoricalRoots' (offset) + offset7 := int(binary.LittleEndian.Uint32(buf[524464:524468])) + if offset7 != 3134333 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset7, 3134333), "HistoricalRoots:o") + } + { // Field #8 'ETH1Data' (static) + buf := buf[524468:524540] + if t.ETH1Data == nil { + t.ETH1Data = new(phase0.ETH1Data) + } + if err = t.ETH1Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "ETH1Data") + } + } + // Field #9 'ETH1DataVotes' (offset) + offset9 := int(binary.LittleEndian.Uint32(buf[524540:524544])) + if offset9 < offset7 || offset9 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset9, offset7, buflen), "ETH1DataVotes:o") + } + { // Field #10 'ETH1DepositIndex' (static) + buf := buf[524544:524552] + t.ETH1DepositIndex = binary.LittleEndian.Uint64(buf) + } + // Field #11 'Validators' (offset) + offset11 := int(binary.LittleEndian.Uint32(buf[524552:524556])) + if offset11 < offset9 || offset11 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset11, offset9, buflen), "Validators:o") + } + // Field #12 'Balances' (offset) + offset12 := int(binary.LittleEndian.Uint32(buf[524556:524560])) + if offset12 < offset11 || offset12 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset12, offset11, buflen), "Balances:o") + } + { // Field #13 'RANDAOMixes' (static) + buf := buf[524560:2621712] + val3 := t.RANDAOMixes + val3 = sszutils.ExpandSlice(val3, 65536) + for idx1 := range 65536 { + buf := buf[32*idx1 : 32*(idx1+1)] + copy(val3[idx1][:], buf) + } + t.RANDAOMixes = val3 + } + { // Field #14 'Slashings' (static) + buf := buf[2621712:2687248] + val4 := t.Slashings + val4 = sszutils.ExpandSlice(val4, 8192) + sszutils.UnmarshalUint64Slice(val4[:8192], buf) + t.Slashings = val4 + } + // Field #15 'PreviousEpochParticipation' (offset) + offset15 := int(binary.LittleEndian.Uint32(buf[2687248:2687252])) + if offset15 < offset12 || offset15 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset15, offset12, buflen), "PreviousEpochParticipation:o") + } + // Field #16 'CurrentEpochParticipation' (offset) + offset16 := int(binary.LittleEndian.Uint32(buf[2687252:2687256])) + if offset16 < offset15 || offset16 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset16, offset15, buflen), "CurrentEpochParticipation:o") + } + { // Field #17 'JustificationBits' (static) + buf := buf[2687256:2687257] + t.JustificationBits = sszutils.ExpandSlice(t.JustificationBits, 1) + copy(t.JustificationBits[:], buf) + } + { // Field #18 'PreviousJustifiedCheckpoint' (static) + buf := buf[2687257:2687297] + if t.PreviousJustifiedCheckpoint == nil { + t.PreviousJustifiedCheckpoint = new(phase0.Checkpoint) + } + if err = t.PreviousJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } + } + { // Field #19 'CurrentJustifiedCheckpoint' (static) + buf := buf[2687297:2687337] + if t.CurrentJustifiedCheckpoint == nil { + t.CurrentJustifiedCheckpoint = new(phase0.Checkpoint) + } + if err = t.CurrentJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } + } + { // Field #20 'FinalizedCheckpoint' (static) + buf := buf[2687337:2687377] + if t.FinalizedCheckpoint == nil { + t.FinalizedCheckpoint = new(phase0.Checkpoint) + } + if err = t.FinalizedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") + } + } + // Field #21 'InactivityScores' (offset) + offset21 := int(binary.LittleEndian.Uint32(buf[2687377:2687381])) + if offset21 < offset16 || offset21 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset21, offset16, buflen), "InactivityScores:o") + } + { // Field #22 'CurrentSyncCommittee' (static) + buf := buf[2687381:2712005] + if t.CurrentSyncCommittee == nil { + t.CurrentSyncCommittee = new(altair.SyncCommittee) + } + if err = t.CurrentSyncCommittee.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "CurrentSyncCommittee") + } + } + { // Field #23 'NextSyncCommittee' (static) + buf := buf[2712005:2736629] + if t.NextSyncCommittee == nil { + t.NextSyncCommittee = new(altair.SyncCommittee) + } + if err = t.NextSyncCommittee.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "NextSyncCommittee") + } + } + { // Field #24 'LatestBlockHash' (static) + buf := buf[2736629:2736661] + copy(t.LatestBlockHash[:], buf) + } + { // Field #25 'NextWithdrawalIndex' (static) + buf := buf[2736661:2736669] + t.NextWithdrawalIndex = capella.WithdrawalIndex(binary.LittleEndian.Uint64(buf)) + } + { // Field #26 'NextWithdrawalValidatorIndex' (static) + buf := buf[2736669:2736677] + t.NextWithdrawalValidatorIndex = phase0.ValidatorIndex(binary.LittleEndian.Uint64(buf)) + } + // Field #27 'HistoricalSummaries' (offset) + offset27 := int(binary.LittleEndian.Uint32(buf[2736677:2736681])) + if offset27 < offset21 || offset27 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset27, offset21, buflen), "HistoricalSummaries:o") + } + { // Field #28 'DepositRequestsStartIndex' (static) + buf := buf[2736681:2736689] + t.DepositRequestsStartIndex = binary.LittleEndian.Uint64(buf) + } + { // Field #29 'DepositBalanceToConsume' (static) + buf := buf[2736689:2736697] + t.DepositBalanceToConsume = phase0.Gwei(binary.LittleEndian.Uint64(buf)) + } + { // Field #30 'ExitBalanceToConsume' (static) + buf := buf[2736697:2736705] + t.ExitBalanceToConsume = phase0.Gwei(binary.LittleEndian.Uint64(buf)) + } + { // Field #31 'EarliestExitEpoch' (static) + buf := buf[2736705:2736713] + t.EarliestExitEpoch = phase0.Epoch(binary.LittleEndian.Uint64(buf)) + } + { // Field #32 'ConsolidationBalanceToConsume' (static) + buf := buf[2736713:2736721] + t.ConsolidationBalanceToConsume = phase0.Gwei(binary.LittleEndian.Uint64(buf)) + } + { // Field #33 'EarliestConsolidationEpoch' (static) + buf := buf[2736721:2736729] + t.EarliestConsolidationEpoch = phase0.Epoch(binary.LittleEndian.Uint64(buf)) + } + // Field #34 'PendingDeposits' (offset) + offset34 := int(binary.LittleEndian.Uint32(buf[2736729:2736733])) + if offset34 < offset27 || offset34 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset34, offset27, buflen), "PendingDeposits:o") + } + // Field #35 'PendingPartialWithdrawals' (offset) + offset35 := int(binary.LittleEndian.Uint32(buf[2736733:2736737])) + if offset35 < offset34 || offset35 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset35, offset34, buflen), "PendingPartialWithdrawals:o") + } + // Field #36 'PendingConsolidations' (offset) + offset36 := int(binary.LittleEndian.Uint32(buf[2736737:2736741])) + if offset36 < offset35 || offset36 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset36, offset35, buflen), "PendingConsolidations:o") + } + { // Field #37 'ProposerLookahead' (static) + buf := buf[2736741:2737253] + val5 := t.ProposerLookahead + val5 = sszutils.ExpandSlice(val5, 64) + sszutils.UnmarshalUint64Slice(val5[:64], buf) + t.ProposerLookahead = val5 + } + // Field #38 'Builders' (offset) + offset38 := int(binary.LittleEndian.Uint32(buf[2737253:2737257])) + if offset38 < offset36 || offset38 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset38, offset36, buflen), "Builders:o") + } + { // Field #39 'NextWithdrawalBuilderIndex' (static) + buf := buf[2737257:2737265] + t.NextWithdrawalBuilderIndex = gloas.BuilderIndex(binary.LittleEndian.Uint64(buf)) + } + { // Field #40 'ExecutionPayloadAvailability' (static) + buf := buf[2737265:2738289] + t.ExecutionPayloadAvailability = sszutils.ExpandSlice(t.ExecutionPayloadAvailability, 1024) + copy(t.ExecutionPayloadAvailability[:], buf) + } + { // Field #41 'BuilderPendingPayments' (static) + buf := buf[2738289:2741105] + val6 := t.BuilderPendingPayments + val6 = sszutils.ExpandSlice(val6, 64) + for idx1 := range 64 { + if val6[idx1] == nil { + val6[idx1] = new(gloas.BuilderPendingPayment) + } + buf := buf[44*idx1 : 44*(idx1+1)] + if err = val6[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "BuilderPendingPayments[%d]", idx1) + } + } + t.BuilderPendingPayments = val6 + } + // Field #42 'BuilderPendingWithdrawals' (offset) + offset42 := int(binary.LittleEndian.Uint32(buf[2741105:2741109])) + if offset42 < offset38 || offset42 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset42, offset38, buflen), "BuilderPendingWithdrawals:o") } - { // Field #1 'GenesisValidatorsRoot' (static) - buf := buf[8:40] - copy(t.GenesisValidatorsRoot[:], buf) + // Field #43 'LatestExecutionPayloadBid' (offset) + offset43 := int(binary.LittleEndian.Uint32(buf[2741109:2741113])) + if offset43 < offset42 || offset43 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset43, offset42, buflen), "LatestExecutionPayloadBid:o") + } + // Field #44 'PayloadExpectedWithdrawals' (offset) + offset44 := int(binary.LittleEndian.Uint32(buf[2741113:2741117])) + if offset44 < offset43 || offset44 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset44, offset43, buflen), "PayloadExpectedWithdrawals:o") + } + { // Field #45 'PTCWindow' (static) + buf := buf[2741117:3134333] + val7 := t.PTCWindow + val7 = sszutils.ExpandSlice(val7, 96) + for idx1 := range 96 { + val8 := val7[idx1] + buf := buf[4096*idx1 : 4096*(idx1+1)] + val8 = sszutils.ExpandSlice(val8, 512) + sszutils.UnmarshalUint64Slice(val8[:512], buf) + val7[idx1] = val8 + } + t.PTCWindow = val7 + } + { // Field #7 'HistoricalRoots' (dynamic) + buf := buf[offset7:offset9] + val9 := t.HistoricalRoots + itemCount := len(buf) / 32 + if len(buf)%32 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 32), "HistoricalRoots") + } + if itemCount > 16777216 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 16777216), "HistoricalRoots") + } + val9 = sszutils.ExpandSlice(val9, itemCount) + for idx1 := range itemCount { + buf := buf[32*idx1 : 32*(idx1+1)] + copy(val9[idx1][:], buf) + } + t.HistoricalRoots = val9 + } + { // Field #9 'ETH1DataVotes' (dynamic) + buf := buf[offset9:offset11] + val10 := t.ETH1DataVotes + itemCount := len(buf) / 72 + if len(buf)%72 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 72), "ETH1DataVotes") + } + if itemCount > 2048 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 2048), "ETH1DataVotes") + } + val10 = sszutils.ExpandSlice(val10, itemCount) + for idx1 := range itemCount { + if val10[idx1] == nil { + val10[idx1] = new(phase0.ETH1Data) + } + buf := buf[72*idx1 : 72*(idx1+1)] + if err = val10[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "ETH1DataVotes[%d]", idx1) + } + } + t.ETH1DataVotes = val10 + } + { // Field #11 'Validators' (dynamic) + buf := buf[offset11:offset12] + val11 := t.Validators + itemCount := len(buf) / 121 + if len(buf)%121 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 121), "Validators") + } + if itemCount > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1099511627776), "Validators") + } + val11 = sszutils.ExpandSlice(val11, itemCount) + for idx1 := range itemCount { + if val11[idx1] == nil { + val11[idx1] = new(phase0.Validator) + } + buf := buf[121*idx1 : 121*(idx1+1)] + if err = val11[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } + } + t.Validators = val11 + } + { // Field #12 'Balances' (dynamic) + buf := buf[offset12:offset15] + val12 := t.Balances + itemCount := len(buf) / 8 + if len(buf)%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 8), "Balances") + } + if itemCount > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1099511627776), "Balances") + } + val12 = sszutils.ExpandSlice(val12, itemCount) + sszutils.UnmarshalUint64Slice(val12, buf) + t.Balances = val12 + } + { // Field #15 'PreviousEpochParticipation' (dynamic) + buf := buf[offset15:offset16] + val13 := t.PreviousEpochParticipation + itemCount := len(buf) + if itemCount > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1099511627776), "PreviousEpochParticipation") + } + val13 = sszutils.ExpandSlice(val13, itemCount) + for idx1 := range itemCount { + buf := buf[1*idx1 : 1*(idx1+1)] + val13[idx1] = altair.ParticipationFlags(buf[0]) + } + t.PreviousEpochParticipation = val13 + } + { // Field #16 'CurrentEpochParticipation' (dynamic) + buf := buf[offset16:offset21] + val14 := t.CurrentEpochParticipation + itemCount := len(buf) + if itemCount > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1099511627776), "CurrentEpochParticipation") + } + val14 = sszutils.ExpandSlice(val14, itemCount) + for idx1 := range itemCount { + buf := buf[1*idx1 : 1*(idx1+1)] + val14[idx1] = altair.ParticipationFlags(buf[0]) + } + t.CurrentEpochParticipation = val14 + } + { // Field #21 'InactivityScores' (dynamic) + buf := buf[offset21:offset27] + val15 := t.InactivityScores + itemCount := len(buf) / 8 + if len(buf)%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 8), "InactivityScores") + } + if itemCount > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1099511627776), "InactivityScores") + } + val15 = sszutils.ExpandSlice(val15, itemCount) + sszutils.UnmarshalUint64Slice(val15, buf) + t.InactivityScores = val15 + } + { // Field #27 'HistoricalSummaries' (dynamic) + buf := buf[offset27:offset34] + val16 := t.HistoricalSummaries + itemCount := len(buf) / 64 + if len(buf)%64 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 64), "HistoricalSummaries") + } + if itemCount > 16777216 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 16777216), "HistoricalSummaries") + } + val16 = sszutils.ExpandSlice(val16, itemCount) + for idx1 := range itemCount { + if val16[idx1] == nil { + val16[idx1] = new(capella.HistoricalSummary) + } + buf := buf[64*idx1 : 64*(idx1+1)] + if err = val16[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "HistoricalSummaries[%d]", idx1) + } + } + t.HistoricalSummaries = val16 + } + { // Field #34 'PendingDeposits' (dynamic) + buf := buf[offset34:offset35] + val17 := t.PendingDeposits + itemCount := len(buf) / 192 + if len(buf)%192 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 192), "PendingDeposits") + } + if itemCount > 134217728 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 134217728), "PendingDeposits") + } + val17 = sszutils.ExpandSlice(val17, itemCount) + for idx1 := range itemCount { + if val17[idx1] == nil { + val17[idx1] = new(electra.PendingDeposit) + } + buf := buf[192*idx1 : 192*(idx1+1)] + if err = val17[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "PendingDeposits[%d]", idx1) + } + } + t.PendingDeposits = val17 + } + { // Field #35 'PendingPartialWithdrawals' (dynamic) + buf := buf[offset35:offset36] + val18 := t.PendingPartialWithdrawals + itemCount := len(buf) / 24 + if len(buf)%24 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 24), "PendingPartialWithdrawals") + } + if itemCount > 134217728 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 134217728), "PendingPartialWithdrawals") + } + val18 = sszutils.ExpandSlice(val18, itemCount) + for idx1 := range itemCount { + if val18[idx1] == nil { + val18[idx1] = new(electra.PendingPartialWithdrawal) + } + buf := buf[24*idx1 : 24*(idx1+1)] + if err = val18[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "PendingPartialWithdrawals[%d]", idx1) + } + } + t.PendingPartialWithdrawals = val18 + } + { // Field #36 'PendingConsolidations' (dynamic) + buf := buf[offset36:offset38] + val19 := t.PendingConsolidations + itemCount := len(buf) / 16 + if len(buf)%16 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 16), "PendingConsolidations") + } + if itemCount > 262144 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 262144), "PendingConsolidations") + } + val19 = sszutils.ExpandSlice(val19, itemCount) + for idx1 := range itemCount { + if val19[idx1] == nil { + val19[idx1] = new(electra.PendingConsolidation) + } + buf := buf[16*idx1 : 16*(idx1+1)] + if err = val19[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "PendingConsolidations[%d]", idx1) + } + } + t.PendingConsolidations = val19 + } + { // Field #38 'Builders' (dynamic) + buf := buf[offset38:offset42] + val20 := t.Builders + itemCount := len(buf) / 93 + if len(buf)%93 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 93), "Builders") + } + if itemCount > 1099511627776 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1099511627776), "Builders") + } + val20 = sszutils.ExpandSlice(val20, itemCount) + for idx1 := range itemCount { + if val20[idx1] == nil { + val20[idx1] = new(gloas.Builder) + } + buf := buf[93*idx1 : 93*(idx1+1)] + if err = val20[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Builders[%d]", idx1) + } + } + t.Builders = val20 } - { // Field #2 'Slot' (static) - buf := buf[40:48] - t.Slot = phase0.Slot(binary.LittleEndian.Uint64(buf)) + { // Field #42 'BuilderPendingWithdrawals' (dynamic) + buf := buf[offset42:offset43] + val21 := t.BuilderPendingWithdrawals + itemCount := len(buf) / 36 + if len(buf)%36 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 36), "BuilderPendingWithdrawals") + } + if itemCount > 1048576 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1048576), "BuilderPendingWithdrawals") + } + val21 = sszutils.ExpandSlice(val21, itemCount) + for idx1 := range itemCount { + if val21[idx1] == nil { + val21[idx1] = new(gloas.BuilderPendingWithdrawal) + } + buf := buf[36*idx1 : 36*(idx1+1)] + if err = val21[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "BuilderPendingWithdrawals[%d]", idx1) + } + } + t.BuilderPendingWithdrawals = val21 } - { // Field #3 'Fork' (static) - buf := buf[48:64] - if t.Fork == nil { - t.Fork = new(phase0.Fork) + { // Field #43 'LatestExecutionPayloadBid' (dynamic) + buf := buf[offset43:offset44] + if t.LatestExecutionPayloadBid == nil { + t.LatestExecutionPayloadBid = new(ExecutionPayloadBid) } - if err = t.Fork.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "Fork") + if err = t.LatestExecutionPayloadBid.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "LatestExecutionPayloadBid") } } - { // Field #4 'LatestBlockHeader' (static) - buf := buf[64:176] - if t.LatestBlockHeader == nil { - t.LatestBlockHeader = new(phase0.BeaconBlockHeader) + { // Field #44 'PayloadExpectedWithdrawals' (dynamic) + buf := buf[offset44:] + val22 := t.PayloadExpectedWithdrawals + itemCount := len(buf) / 44 + if len(buf)%44 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 44), "PayloadExpectedWithdrawals") } - if err = t.LatestBlockHeader.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "LatestBlockHeader") + if itemCount > 16 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 16), "PayloadExpectedWithdrawals") + } + val22 = sszutils.ExpandSlice(val22, itemCount) + for idx1 := range itemCount { + if val22[idx1] == nil { + val22[idx1] = new(capella.Withdrawal) + } + buf := buf[44*idx1 : 44*(idx1+1)] + if err = val22[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "PayloadExpectedWithdrawals[%d]", idx1) + } } + t.PayloadExpectedWithdrawals = val22 + } + return nil +} + +// UnmarshalSSZDecoder unmarshals the *BeaconState from the given SSZ decoder using dynamic specifications. +func (t *BeaconState) UnmarshalSSZDecoder(ds sszutils.DynamicSpecs, dec sszutils.Decoder) (err error) { + expr0, err := sszutils.ResolveSpecValueWithDefault(ds, "SLOTS_PER_HISTORICAL_ROOT", 8192) + if err != nil { + return err + } + expr1, err := sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_HISTORICAL_VECTOR", 65536) + if err != nil { + return err + } + expr2, err := sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_SLASHINGS_VECTOR", 8192) + if err != nil { + return err + } + expr3, err := sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE", 512) + if err != nil { + return err + } + expr4, err := sszutils.ResolveSpecValueWithDefault(ds, "(MIN_SEED_LOOKAHEAD+1)*SLOTS_PER_EPOCH", 64) + if err != nil { + return err + } + expr5, err := sszutils.ResolveSpecValueWithDefault(ds, "SLOTS_PER_HISTORICAL_ROOT/8", 1024) + if err != nil { + return err + } + expr6, err := sszutils.ResolveSpecValueWithDefault(ds, "SLOTS_PER_EPOCH*2", 64) + if err != nil { + return err + } + expr7, err := sszutils.ResolveSpecValueWithDefault(ds, "PTC_SIZE", 512) + if err != nil { + return err + } + expr8, err := sszutils.ResolveSpecValueWithDefault(ds, "(2+MIN_SEED_LOOKAHEAD)*SLOTS_PER_EPOCH", 96) + if err != nil { + return err + } + expr9, err := sszutils.ResolveSpecValueWithDefault(ds, "EPOCHS_PER_ETH1_VOTING_PERIOD*SLOTS_PER_EPOCH", 2048) + if err != nil { + return err + } + expr10, err := sszutils.ResolveSpecValueWithDefault(ds, "PENDING_DEPOSITS_LIMIT", 134217728) + if err != nil { + return err + } + expr11, err := sszutils.ResolveSpecValueWithDefault(ds, "PENDING_PARTIAL_WITHDRAWALS_LIMIT", 134217728) + if err != nil { + return err + } + expr12, err := sszutils.ResolveSpecValueWithDefault(ds, "PENDING_CONSOLIDATIONS_LIMIT", 262144) + if err != nil { + return err + } + expr13, err := sszutils.ResolveSpecValueWithDefault(ds, "BUILDER_REGISTRY_LIMIT", 1099511627776) + if err != nil { + return err + } + expr14, err := sszutils.ResolveSpecValueWithDefault(ds, "BUILDER_PENDING_WITHDRAWALS_LIMIT", 1048576) + if err != nil { + return err + } + expr15, err := sszutils.ResolveSpecValueWithDefault(ds, "INCLUSION_LIST_COMMITTEE_SIZE/8", 2) + if err != nil { + return err + } + expr16, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BLOB_COMMITMENTS_PER_BLOCK", 4096) + if err != nil { + return err + } + expr17, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_WITHDRAWALS_PER_PAYLOAD", 16) + if err != nil { + return err + } + size1 := 32 * int(expr0) + size2 := 32 * int(expr1) + size3 := 8 * int(expr2) + size5 := 48 * int(expr3) + size4 := size5 + 48 // size expression for '*SyncCommittee' + size6 := 8 * int(expr4) + size7 := 1 * int(expr5) + size8 := 44 * int(expr6) + size10 := 8 * int(expr7) + size9 := size10 * int(expr8) + size11 := 1 * int(expr15) + totalSize := size1+size1+size2+size3+size4+size4+size6+size7+size8+size9+541 + maxOffset := uint32(dec.GetLength()) + startPos0 := dec.GetPosition() + if maxOffset < uint32(totalSize) { + return sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(totalSize)) + } + // Field #0 'GenesisTime' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "GenesisTime") + } else { + t.GenesisTime = val + } + // Field #1 'GenesisValidatorsRoot' (static) + if _, err = dec.DecodeBytes(t.GenesisValidatorsRoot[:32]); err != nil { + return err + } + // Field #2 'Slot' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "Slot") + } else { + t.Slot = phase0.Slot(val) + } + // Field #3 'Fork' (static) + if t.Fork == nil { + t.Fork = new(phase0.Fork) + } + if buf, err := dec.DecodeBytesBuf(16); err != nil { + return sszutils.ErrorWithPath(err, "Fork") + } else if err = t.Fork.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "Fork") + } + // Field #4 'LatestBlockHeader' (static) + if t.LatestBlockHeader == nil { + t.LatestBlockHeader = new(phase0.BeaconBlockHeader) + } + if buf, err := dec.DecodeBytesBuf(112); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") + } else if err = t.LatestBlockHeader.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "LatestBlockHeader") } { // Field #5 'BlockRoots' (static) - buf := buf[176:262320] val1 := t.BlockRoots - val1 = sszutils.ExpandSlice(val1, 8192) - for idx1 := range 8192 { - buf := buf[32*idx1 : 32*(idx1+1)] - copy(val1[idx1][:], buf) + val1 = sszutils.ExpandSlice(val1, int(expr0)) + startPos1 := dec.GetPosition() + for idx1 := range int(expr0) { + if _, err = dec.DecodeBytes(val1[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos1+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos1+int(32*(idx1+1))), "BlockRoots[%d]", idx1) + } } t.BlockRoots = val1 } { // Field #6 'StateRoots' (static) - buf := buf[262320:524464] val2 := t.StateRoots - val2 = sszutils.ExpandSlice(val2, 8192) - for idx1 := range 8192 { - buf := buf[32*idx1 : 32*(idx1+1)] - copy(val2[idx1][:], buf) + val2 = sszutils.ExpandSlice(val2, int(expr0)) + startPos2 := dec.GetPosition() + for idx1 := range int(expr0) { + if _, err = dec.DecodeBytes(val2[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos2+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos2+int(32*(idx1+1))), "StateRoots[%d]", idx1) + } } t.StateRoots = val2 } // Field #7 'HistoricalRoots' (offset) - offset7 := int(binary.LittleEndian.Uint32(buf[524464:524468])) - if offset7 != 3134333 { - return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset7, 3134333), "HistoricalRoots:o") + offset7, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "HistoricalRoots") } - { // Field #8 'ETH1Data' (static) - buf := buf[524468:524540] - if t.ETH1Data == nil { - t.ETH1Data = new(phase0.ETH1Data) - } - if err = t.ETH1Data.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "ETH1Data") - } + if offset7 != uint32(totalSize) { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset7, totalSize), "HistoricalRoots") + } + // Field #8 'ETH1Data' (static) + if t.ETH1Data == nil { + t.ETH1Data = new(phase0.ETH1Data) + } + if buf, err := dec.DecodeBytesBuf(72); err != nil { + return sszutils.ErrorWithPath(err, "ETH1Data") + } else if err = t.ETH1Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "ETH1Data") } // Field #9 'ETH1DataVotes' (offset) - offset9 := int(binary.LittleEndian.Uint32(buf[524540:524544])) - if offset9 < offset7 || offset9 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset9, offset7, buflen), "ETH1DataVotes:o") + offset9, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "ETH1DataVotes") } - { // Field #10 'ETH1DepositIndex' (static) - buf := buf[524544:524552] - t.ETH1DepositIndex = binary.LittleEndian.Uint64(buf) + if offset9 < offset7 || offset9 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset9, offset7, maxOffset), "ETH1DataVotes") + } + // Field #10 'ETH1DepositIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "ETH1DepositIndex") + } else { + t.ETH1DepositIndex = val } // Field #11 'Validators' (offset) - offset11 := int(binary.LittleEndian.Uint32(buf[524552:524556])) - if offset11 < offset9 || offset11 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset11, offset9, buflen), "Validators:o") + offset11, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Validators") + } + if offset11 < offset9 || offset11 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset11, offset9, maxOffset), "Validators") } // Field #12 'Balances' (offset) - offset12 := int(binary.LittleEndian.Uint32(buf[524556:524560])) - if offset12 < offset11 || offset12 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset12, offset11, buflen), "Balances:o") + offset12, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Balances") + } + if offset12 < offset11 || offset12 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset12, offset11, maxOffset), "Balances") } { // Field #13 'RANDAOMixes' (static) - buf := buf[524560:2621712] val3 := t.RANDAOMixes - val3 = sszutils.ExpandSlice(val3, 65536) - for idx1 := range 65536 { - buf := buf[32*idx1 : 32*(idx1+1)] - copy(val3[idx1][:], buf) + val3 = sszutils.ExpandSlice(val3, int(expr1)) + startPos3 := dec.GetPosition() + for idx1 := range int(expr1) { + if _, err = dec.DecodeBytes(val3[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos3+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos3+int(32*(idx1+1))), "RANDAOMixes[%d]", idx1) + } } t.RANDAOMixes = val3 } { // Field #14 'Slashings' (static) - buf := buf[2621712:2687248] val4 := t.Slashings - val4 = sszutils.ExpandSlice(val4, 8192) - sszutils.UnmarshalUint64Slice(val4[:8192], buf) + val4 = sszutils.ExpandSlice(val4, int(expr2)) + if err = sszutils.DecodeUint64Slice(dec, val4[:int(expr2)]); err != nil { + return sszutils.ErrorWithPath(err, "Slashings") + } t.Slashings = val4 } // Field #15 'PreviousEpochParticipation' (offset) - offset15 := int(binary.LittleEndian.Uint32(buf[2687248:2687252])) - if offset15 < offset12 || offset15 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset15, offset12, buflen), "PreviousEpochParticipation:o") + offset15, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "PreviousEpochParticipation") + } + if offset15 < offset12 || offset15 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset15, offset12, maxOffset), "PreviousEpochParticipation") } // Field #16 'CurrentEpochParticipation' (offset) - offset16 := int(binary.LittleEndian.Uint32(buf[2687252:2687256])) - if offset16 < offset15 || offset16 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset16, offset15, buflen), "CurrentEpochParticipation:o") + offset16, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "CurrentEpochParticipation") } - { // Field #17 'JustificationBits' (static) - buf := buf[2687256:2687257] - t.JustificationBits = sszutils.ExpandSlice(t.JustificationBits, 1) - copy(t.JustificationBits[:], buf) + if offset16 < offset15 || offset16 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset16, offset15, maxOffset), "CurrentEpochParticipation") } - { // Field #18 'PreviousJustifiedCheckpoint' (static) - buf := buf[2687257:2687297] - if t.PreviousJustifiedCheckpoint == nil { - t.PreviousJustifiedCheckpoint = new(phase0.Checkpoint) - } - if err = t.PreviousJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") - } + // Field #17 'JustificationBits' (static) + t.JustificationBits = sszutils.ExpandSlice(t.JustificationBits, 1) + if _, err = dec.DecodeBytes(t.JustificationBits[:1]); err != nil { + return err } - { // Field #19 'CurrentJustifiedCheckpoint' (static) - buf := buf[2687297:2687337] - if t.CurrentJustifiedCheckpoint == nil { - t.CurrentJustifiedCheckpoint = new(phase0.Checkpoint) - } - if err = t.CurrentJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") - } + // Field #18 'PreviousJustifiedCheckpoint' (static) + if t.PreviousJustifiedCheckpoint == nil { + t.PreviousJustifiedCheckpoint = new(phase0.Checkpoint) } - { // Field #20 'FinalizedCheckpoint' (static) - buf := buf[2687337:2687377] - if t.FinalizedCheckpoint == nil { - t.FinalizedCheckpoint = new(phase0.Checkpoint) - } - if err = t.FinalizedCheckpoint.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") - } + if buf, err := dec.DecodeBytesBuf(40); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } else if err = t.PreviousJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "PreviousJustifiedCheckpoint") + } + // Field #19 'CurrentJustifiedCheckpoint' (static) + if t.CurrentJustifiedCheckpoint == nil { + t.CurrentJustifiedCheckpoint = new(phase0.Checkpoint) + } + if buf, err := dec.DecodeBytesBuf(40); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } else if err = t.CurrentJustifiedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "CurrentJustifiedCheckpoint") + } + // Field #20 'FinalizedCheckpoint' (static) + if t.FinalizedCheckpoint == nil { + t.FinalizedCheckpoint = new(phase0.Checkpoint) + } + if buf, err := dec.DecodeBytesBuf(40); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") + } else if err = t.FinalizedCheckpoint.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "FinalizedCheckpoint") } // Field #21 'InactivityScores' (offset) - offset21 := int(binary.LittleEndian.Uint32(buf[2687377:2687381])) - if offset21 < offset16 || offset21 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset21, offset16, buflen), "InactivityScores:o") + offset21, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "InactivityScores") + } + if offset21 < offset16 || offset21 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset21, offset16, maxOffset), "InactivityScores") } { // Field #22 'CurrentSyncCommittee' (static) - buf := buf[2687381:2712005] - if t.CurrentSyncCommittee == nil { - t.CurrentSyncCommittee = new(altair.SyncCommittee) + val5 := t.CurrentSyncCommittee + if val5 == nil { + val5 = new(altair.SyncCommittee) + } + totalSize := size5+48 + maxOffset := uint32(dec.GetLength()) + if maxOffset < uint32(totalSize) { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(totalSize)), "CurrentSyncCommittee") + } + { // Field #0 'Pubkeys' (static) + val6 := val5.Pubkeys + val6 = sszutils.ExpandSlice(val6, int(expr3)) + startPos4 := dec.GetPosition() + for idx1 := range int(expr3) { + if _, err = dec.DecodeBytes(val6[idx1][:48]); err != nil { + return err + } + if dec.GetPosition() != startPos4+int(48*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos4+int(48*(idx1+1))), "CurrentSyncCommittee.Pubkeys[%d]", idx1) + } + } + val5.Pubkeys = val6 } - if err = t.CurrentSyncCommittee.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "CurrentSyncCommittee") + // Field #1 'AggregatePubkey' (static) + if _, err = dec.DecodeBytes(val5.AggregatePubkey[:48]); err != nil { + return err } + t.CurrentSyncCommittee = val5 } { // Field #23 'NextSyncCommittee' (static) - buf := buf[2712005:2736629] - if t.NextSyncCommittee == nil { - t.NextSyncCommittee = new(altair.SyncCommittee) + val7 := t.NextSyncCommittee + if val7 == nil { + val7 = new(altair.SyncCommittee) + } + totalSize := size5+48 + maxOffset := uint32(dec.GetLength()) + if maxOffset < uint32(totalSize) { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(totalSize)), "NextSyncCommittee") + } + { // Field #0 'Pubkeys' (static) + val8 := val7.Pubkeys + val8 = sszutils.ExpandSlice(val8, int(expr3)) + startPos5 := dec.GetPosition() + for idx1 := range int(expr3) { + if _, err = dec.DecodeBytes(val8[idx1][:48]); err != nil { + return err + } + if dec.GetPosition() != startPos5+int(48*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos5+int(48*(idx1+1))), "NextSyncCommittee.Pubkeys[%d]", idx1) + } + } + val7.Pubkeys = val8 } - if err = t.NextSyncCommittee.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "NextSyncCommittee") + // Field #1 'AggregatePubkey' (static) + if _, err = dec.DecodeBytes(val7.AggregatePubkey[:48]); err != nil { + return err } + t.NextSyncCommittee = val7 } - { // Field #24 'LatestBlockHash' (static) - buf := buf[2736629:2736661] - copy(t.LatestBlockHash[:], buf) + // Field #24 'LatestBlockHash' (static) + if _, err = dec.DecodeBytes(t.LatestBlockHash[:32]); err != nil { + return err } - { // Field #25 'NextWithdrawalIndex' (static) - buf := buf[2736661:2736669] - t.NextWithdrawalIndex = capella.WithdrawalIndex(binary.LittleEndian.Uint64(buf)) + // Field #25 'NextWithdrawalIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "NextWithdrawalIndex") + } else { + t.NextWithdrawalIndex = capella.WithdrawalIndex(val) } - { // Field #26 'NextWithdrawalValidatorIndex' (static) - buf := buf[2736669:2736677] - t.NextWithdrawalValidatorIndex = phase0.ValidatorIndex(binary.LittleEndian.Uint64(buf)) + // Field #26 'NextWithdrawalValidatorIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "NextWithdrawalValidatorIndex") + } else { + t.NextWithdrawalValidatorIndex = phase0.ValidatorIndex(val) } // Field #27 'HistoricalSummaries' (offset) - offset27 := int(binary.LittleEndian.Uint32(buf[2736677:2736681])) - if offset27 < offset21 || offset27 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset27, offset21, buflen), "HistoricalSummaries:o") - } - { // Field #28 'DepositRequestsStartIndex' (static) - buf := buf[2736681:2736689] - t.DepositRequestsStartIndex = binary.LittleEndian.Uint64(buf) - } - { // Field #29 'DepositBalanceToConsume' (static) - buf := buf[2736689:2736697] - t.DepositBalanceToConsume = phase0.Gwei(binary.LittleEndian.Uint64(buf)) - } - { // Field #30 'ExitBalanceToConsume' (static) - buf := buf[2736697:2736705] - t.ExitBalanceToConsume = phase0.Gwei(binary.LittleEndian.Uint64(buf)) - } - { // Field #31 'EarliestExitEpoch' (static) - buf := buf[2736705:2736713] - t.EarliestExitEpoch = phase0.Epoch(binary.LittleEndian.Uint64(buf)) - } - { // Field #32 'ConsolidationBalanceToConsume' (static) - buf := buf[2736713:2736721] - t.ConsolidationBalanceToConsume = phase0.Gwei(binary.LittleEndian.Uint64(buf)) - } - { // Field #33 'EarliestConsolidationEpoch' (static) - buf := buf[2736721:2736729] - t.EarliestConsolidationEpoch = phase0.Epoch(binary.LittleEndian.Uint64(buf)) + offset27, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "HistoricalSummaries") + } + if offset27 < offset21 || offset27 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset27, offset21, maxOffset), "HistoricalSummaries") + } + // Field #28 'DepositRequestsStartIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "DepositRequestsStartIndex") + } else { + t.DepositRequestsStartIndex = val + } + // Field #29 'DepositBalanceToConsume' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "DepositBalanceToConsume") + } else { + t.DepositBalanceToConsume = phase0.Gwei(val) + } + // Field #30 'ExitBalanceToConsume' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "ExitBalanceToConsume") + } else { + t.ExitBalanceToConsume = phase0.Gwei(val) + } + // Field #31 'EarliestExitEpoch' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "EarliestExitEpoch") + } else { + t.EarliestExitEpoch = phase0.Epoch(val) + } + // Field #32 'ConsolidationBalanceToConsume' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "ConsolidationBalanceToConsume") + } else { + t.ConsolidationBalanceToConsume = phase0.Gwei(val) + } + // Field #33 'EarliestConsolidationEpoch' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "EarliestConsolidationEpoch") + } else { + t.EarliestConsolidationEpoch = phase0.Epoch(val) } // Field #34 'PendingDeposits' (offset) - offset34 := int(binary.LittleEndian.Uint32(buf[2736729:2736733])) - if offset34 < offset27 || offset34 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset34, offset27, buflen), "PendingDeposits:o") + offset34, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "PendingDeposits") + } + if offset34 < offset27 || offset34 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset34, offset27, maxOffset), "PendingDeposits") } // Field #35 'PendingPartialWithdrawals' (offset) - offset35 := int(binary.LittleEndian.Uint32(buf[2736733:2736737])) - if offset35 < offset34 || offset35 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset35, offset34, buflen), "PendingPartialWithdrawals:o") + offset35, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "PendingPartialWithdrawals") + } + if offset35 < offset34 || offset35 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset35, offset34, maxOffset), "PendingPartialWithdrawals") } // Field #36 'PendingConsolidations' (offset) - offset36 := int(binary.LittleEndian.Uint32(buf[2736737:2736741])) - if offset36 < offset35 || offset36 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset36, offset35, buflen), "PendingConsolidations:o") + offset36, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "PendingConsolidations") + } + if offset36 < offset35 || offset36 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset36, offset35, maxOffset), "PendingConsolidations") } { // Field #37 'ProposerLookahead' (static) - buf := buf[2736741:2737253] - val5 := t.ProposerLookahead - val5 = sszutils.ExpandSlice(val5, 64) - sszutils.UnmarshalUint64Slice(val5[:64], buf) - t.ProposerLookahead = val5 + val9 := t.ProposerLookahead + val9 = sszutils.ExpandSlice(val9, int(expr4)) + if err = sszutils.DecodeUint64Slice(dec, val9[:int(expr4)]); err != nil { + return sszutils.ErrorWithPath(err, "ProposerLookahead") + } + t.ProposerLookahead = val9 } // Field #38 'Builders' (offset) - offset38 := int(binary.LittleEndian.Uint32(buf[2737253:2737257])) - if offset38 < offset36 || offset38 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset38, offset36, buflen), "Builders:o") + offset38, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "Builders") } - { // Field #39 'NextWithdrawalBuilderIndex' (static) - buf := buf[2737257:2737265] - t.NextWithdrawalBuilderIndex = gloas.BuilderIndex(binary.LittleEndian.Uint64(buf)) + if offset38 < offset36 || offset38 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset38, offset36, maxOffset), "Builders") } - { // Field #40 'ExecutionPayloadAvailability' (static) - buf := buf[2737265:2738289] - t.ExecutionPayloadAvailability = sszutils.ExpandSlice(t.ExecutionPayloadAvailability, 1024) - copy(t.ExecutionPayloadAvailability[:], buf) + // Field #39 'NextWithdrawalBuilderIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "NextWithdrawalBuilderIndex") + } else { + t.NextWithdrawalBuilderIndex = gloas.BuilderIndex(val) + } + // Field #40 'ExecutionPayloadAvailability' (static) + t.ExecutionPayloadAvailability = sszutils.ExpandSlice(t.ExecutionPayloadAvailability, int(expr5)) + if _, err = dec.DecodeBytes(t.ExecutionPayloadAvailability[:int(expr5)]); err != nil { + return err } { // Field #41 'BuilderPendingPayments' (static) - buf := buf[2738289:2741105] - val6 := t.BuilderPendingPayments - val6 = sszutils.ExpandSlice(val6, 64) - for idx1 := range 64 { - if val6[idx1] == nil { - val6[idx1] = new(gloas.BuilderPendingPayment) - } - buf := buf[44*idx1 : 44*(idx1+1)] - if err = val6[idx1].UnmarshalSSZ(buf); err != nil { + val10 := t.BuilderPendingPayments + val10 = sszutils.ExpandSlice(val10, int(expr6)) + startPos6 := dec.GetPosition() + for idx1 := range int(expr6) { + if val10[idx1] == nil { + val10[idx1] = new(gloas.BuilderPendingPayment) + } + if buf, err := dec.DecodeBytesBuf(44); err != nil { + return sszutils.ErrorWithPathf(err, "BuilderPendingPayments[%d]", idx1) + } else if err = val10[idx1].UnmarshalSSZ(buf); err != nil { return sszutils.ErrorWithPathf(err, "BuilderPendingPayments[%d]", idx1) } + if dec.GetPosition() != startPos6+int(44*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos6+int(44*(idx1+1))), "BuilderPendingPayments[%d]", idx1) + } } - t.BuilderPendingPayments = val6 + t.BuilderPendingPayments = val10 } // Field #42 'BuilderPendingWithdrawals' (offset) - offset42 := int(binary.LittleEndian.Uint32(buf[2741105:2741109])) - if offset42 < offset38 || offset42 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset42, offset38, buflen), "BuilderPendingWithdrawals:o") + offset42, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "BuilderPendingWithdrawals") + } + if offset42 < offset38 || offset42 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset42, offset38, maxOffset), "BuilderPendingWithdrawals") } // Field #43 'LatestExecutionPayloadBid' (offset) - offset43 := int(binary.LittleEndian.Uint32(buf[2741109:2741113])) - if offset43 < offset42 || offset43 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset43, offset42, buflen), "LatestExecutionPayloadBid:o") + offset43, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "LatestExecutionPayloadBid") + } + if offset43 < offset42 || offset43 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset43, offset42, maxOffset), "LatestExecutionPayloadBid") } // Field #44 'PayloadExpectedWithdrawals' (offset) - offset44 := int(binary.LittleEndian.Uint32(buf[2741113:2741117])) - if offset44 < offset43 || offset44 > buflen { - return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset44, offset43, buflen), "PayloadExpectedWithdrawals:o") + offset44, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "PayloadExpectedWithdrawals") + } + if offset44 < offset43 || offset44 > maxOffset { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset44, offset43, maxOffset), "PayloadExpectedWithdrawals") } { // Field #45 'PTCWindow' (static) - buf := buf[2741117:3134333] - val7 := t.PTCWindow - val7 = sszutils.ExpandSlice(val7, 96) - for idx1 := range 96 { - val8 := val7[idx1] - buf := buf[4096*idx1 : 4096*(idx1+1)] - val8 = sszutils.ExpandSlice(val8, 512) - sszutils.UnmarshalUint64Slice(val8[:512], buf) - val7[idx1] = val8 + val11 := t.PTCWindow + val11 = sszutils.ExpandSlice(val11, int(expr8)) + startPos7 := dec.GetPosition() + for idx1 := range int(expr8) { + val12 := val11[idx1] + val12 = sszutils.ExpandSlice(val12, int(expr7)) + if err = sszutils.DecodeUint64Slice(dec, val12[:int(expr7)]); err != nil { + return sszutils.ErrorWithPathf(err, "PTCWindow[%d]", idx1) + } + if dec.GetPosition() != startPos7+int(size10*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos7+int(size10*(idx1+1))), "PTCWindow[%d]", idx1) + } + val11[idx1] = val12 } - t.PTCWindow = val7 + t.PTCWindow = val11 } { // Field #7 'HistoricalRoots' (dynamic) - buf := buf[offset7:offset9] - val9 := t.HistoricalRoots - itemCount := len(buf) / 32 - if len(buf)%32 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 32), "HistoricalRoots") + if dec.GetPosition() != startPos0+int(offset7) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset7)), "HistoricalRoots") + } + dec.PushLimit(int(offset9 - offset7)) + val13 := t.HistoricalRoots + sszLen := dec.GetLength() + itemCount := sszLen / 32 + if sszLen%32 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 32), "HistoricalRoots") } if itemCount > 16777216 { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 16777216), "HistoricalRoots") } - val9 = sszutils.ExpandSlice(val9, itemCount) + val13 = sszutils.ExpandSlice(val13, itemCount) + startPos8 := dec.GetPosition() for idx1 := range itemCount { - buf := buf[32*idx1 : 32*(idx1+1)] - copy(val9[idx1][:], buf) + if _, err = dec.DecodeBytes(val13[idx1][:32]); err != nil { + return err + } + if dec.GetPosition() != startPos8+int(32*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos8+int(32*(idx1+1))), "HistoricalRoots[%d]", idx1) + } } - t.HistoricalRoots = val9 + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "HistoricalRoots") + } + t.HistoricalRoots = val13 } { // Field #9 'ETH1DataVotes' (dynamic) - buf := buf[offset9:offset11] - val10 := t.ETH1DataVotes - itemCount := len(buf) / 72 - if len(buf)%72 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 72), "ETH1DataVotes") + if dec.GetPosition() != startPos0+int(offset9) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset9)), "ETH1DataVotes") } - if itemCount > 2048 { - return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 2048), "ETH1DataVotes") + dec.PushLimit(int(offset11 - offset9)) + val14 := t.ETH1DataVotes + sszLen := dec.GetLength() + itemCount := sszLen / 72 + if sszLen%72 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 72), "ETH1DataVotes") } - val10 = sszutils.ExpandSlice(val10, itemCount) + if itemCount > int(expr9) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr9)), "ETH1DataVotes") + } + val14 = sszutils.ExpandSlice(val14, itemCount) + startPos9 := dec.GetPosition() for idx1 := range itemCount { - if val10[idx1] == nil { - val10[idx1] = new(phase0.ETH1Data) + if val14[idx1] == nil { + val14[idx1] = new(phase0.ETH1Data) } - buf := buf[72*idx1 : 72*(idx1+1)] - if err = val10[idx1].UnmarshalSSZ(buf); err != nil { + if buf, err := dec.DecodeBytesBuf(72); err != nil { return sszutils.ErrorWithPathf(err, "ETH1DataVotes[%d]", idx1) + } else if err = val14[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "ETH1DataVotes[%d]", idx1) + } + if dec.GetPosition() != startPos9+int(72*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos9+int(72*(idx1+1))), "ETH1DataVotes[%d]", idx1) } } - t.ETH1DataVotes = val10 + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "ETH1DataVotes") + } + t.ETH1DataVotes = val14 } { // Field #11 'Validators' (dynamic) - buf := buf[offset11:offset12] - val11 := t.Validators - itemCount := len(buf) / 121 - if len(buf)%121 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 121), "Validators") + if dec.GetPosition() != startPos0+int(offset11) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset11)), "Validators") + } + dec.PushLimit(int(offset12 - offset11)) + val15 := t.Validators + sszLen := dec.GetLength() + itemCount := sszLen / 121 + if sszLen%121 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 121), "Validators") } if itemCount > 1099511627776 { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1099511627776), "Validators") } - val11 = sszutils.ExpandSlice(val11, itemCount) + val15 = sszutils.ExpandSlice(val15, itemCount) + startPos10 := dec.GetPosition() for idx1 := range itemCount { - if val11[idx1] == nil { - val11[idx1] = new(phase0.Validator) + if val15[idx1] == nil { + val15[idx1] = new(phase0.Validator) } - buf := buf[121*idx1 : 121*(idx1+1)] - if err = val11[idx1].UnmarshalSSZ(buf); err != nil { + if buf, err := dec.DecodeBytesBuf(121); err != nil { return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } else if err = val15[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Validators[%d]", idx1) + } + if dec.GetPosition() != startPos10+int(121*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos10+int(121*(idx1+1))), "Validators[%d]", idx1) } } - t.Validators = val11 + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Validators") + } + t.Validators = val15 } { // Field #12 'Balances' (dynamic) - buf := buf[offset12:offset15] - val12 := t.Balances - itemCount := len(buf) / 8 - if len(buf)%8 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 8), "Balances") + if dec.GetPosition() != startPos0+int(offset12) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset12)), "Balances") + } + dec.PushLimit(int(offset15 - offset12)) + val16 := t.Balances + sszLen := dec.GetLength() + itemCount := sszLen / 8 + if sszLen%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 8), "Balances") } if itemCount > 1099511627776 { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1099511627776), "Balances") } - val12 = sszutils.ExpandSlice(val12, itemCount) - sszutils.UnmarshalUint64Slice(val12, buf) - t.Balances = val12 + val16 = sszutils.ExpandSlice(val16, itemCount) + if err = sszutils.DecodeUint64Slice(dec, val16); err != nil { + return sszutils.ErrorWithPath(err, "Balances") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Balances") + } + t.Balances = val16 } { // Field #15 'PreviousEpochParticipation' (dynamic) - buf := buf[offset15:offset16] - val13 := t.PreviousEpochParticipation - itemCount := len(buf) + if dec.GetPosition() != startPos0+int(offset15) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset15)), "PreviousEpochParticipation") + } + dec.PushLimit(int(offset16 - offset15)) + val17 := t.PreviousEpochParticipation + itemCount := dec.GetLength() if itemCount > 1099511627776 { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1099511627776), "PreviousEpochParticipation") } - val13 = sszutils.ExpandSlice(val13, itemCount) + val17 = sszutils.ExpandSlice(val17, itemCount) + startPos11 := dec.GetPosition() for idx1 := range itemCount { - buf := buf[1*idx1 : 1*(idx1+1)] - val13[idx1] = altair.ParticipationFlags(buf[0]) + if val, err := dec.DecodeUint8(); err != nil { + return sszutils.ErrorWithPathf(err, "PreviousEpochParticipation[%d]", idx1) + } else { + val17[idx1] = altair.ParticipationFlags(val) + } + if dec.GetPosition() != startPos11+int(1*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos11+int(1*(idx1+1))), "PreviousEpochParticipation[%d]", idx1) + } } - t.PreviousEpochParticipation = val13 + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "PreviousEpochParticipation") + } + t.PreviousEpochParticipation = val17 } { // Field #16 'CurrentEpochParticipation' (dynamic) - buf := buf[offset16:offset21] - val14 := t.CurrentEpochParticipation - itemCount := len(buf) + if dec.GetPosition() != startPos0+int(offset16) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset16)), "CurrentEpochParticipation") + } + dec.PushLimit(int(offset21 - offset16)) + val18 := t.CurrentEpochParticipation + itemCount := dec.GetLength() if itemCount > 1099511627776 { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1099511627776), "CurrentEpochParticipation") } - val14 = sszutils.ExpandSlice(val14, itemCount) + val18 = sszutils.ExpandSlice(val18, itemCount) + startPos12 := dec.GetPosition() for idx1 := range itemCount { - buf := buf[1*idx1 : 1*(idx1+1)] - val14[idx1] = altair.ParticipationFlags(buf[0]) + if val, err := dec.DecodeUint8(); err != nil { + return sszutils.ErrorWithPathf(err, "CurrentEpochParticipation[%d]", idx1) + } else { + val18[idx1] = altair.ParticipationFlags(val) + } + if dec.GetPosition() != startPos12+int(1*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos12+int(1*(idx1+1))), "CurrentEpochParticipation[%d]", idx1) + } } - t.CurrentEpochParticipation = val14 + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "CurrentEpochParticipation") + } + t.CurrentEpochParticipation = val18 } { // Field #21 'InactivityScores' (dynamic) - buf := buf[offset21:offset27] - val15 := t.InactivityScores - itemCount := len(buf) / 8 - if len(buf)%8 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 8), "InactivityScores") + if dec.GetPosition() != startPos0+int(offset21) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset21)), "InactivityScores") + } + dec.PushLimit(int(offset27 - offset21)) + val19 := t.InactivityScores + sszLen := dec.GetLength() + itemCount := sszLen / 8 + if sszLen%8 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 8), "InactivityScores") } if itemCount > 1099511627776 { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1099511627776), "InactivityScores") } - val15 = sszutils.ExpandSlice(val15, itemCount) - sszutils.UnmarshalUint64Slice(val15, buf) - t.InactivityScores = val15 + val19 = sszutils.ExpandSlice(val19, itemCount) + if err = sszutils.DecodeUint64Slice(dec, val19); err != nil { + return sszutils.ErrorWithPath(err, "InactivityScores") + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "InactivityScores") + } + t.InactivityScores = val19 } { // Field #27 'HistoricalSummaries' (dynamic) - buf := buf[offset27:offset34] - val16 := t.HistoricalSummaries - itemCount := len(buf) / 64 - if len(buf)%64 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 64), "HistoricalSummaries") + if dec.GetPosition() != startPos0+int(offset27) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset27)), "HistoricalSummaries") + } + dec.PushLimit(int(offset34 - offset27)) + val20 := t.HistoricalSummaries + sszLen := dec.GetLength() + itemCount := sszLen / 64 + if sszLen%64 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 64), "HistoricalSummaries") } if itemCount > 16777216 { return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 16777216), "HistoricalSummaries") } - val16 = sszutils.ExpandSlice(val16, itemCount) + val20 = sszutils.ExpandSlice(val20, itemCount) + startPos13 := dec.GetPosition() for idx1 := range itemCount { - if val16[idx1] == nil { - val16[idx1] = new(capella.HistoricalSummary) + if val20[idx1] == nil { + val20[idx1] = new(capella.HistoricalSummary) } - buf := buf[64*idx1 : 64*(idx1+1)] - if err = val16[idx1].UnmarshalSSZ(buf); err != nil { + if buf, err := dec.DecodeBytesBuf(64); err != nil { + return sszutils.ErrorWithPathf(err, "HistoricalSummaries[%d]", idx1) + } else if err = val20[idx1].UnmarshalSSZ(buf); err != nil { return sszutils.ErrorWithPathf(err, "HistoricalSummaries[%d]", idx1) } + if dec.GetPosition() != startPos13+int(64*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos13+int(64*(idx1+1))), "HistoricalSummaries[%d]", idx1) + } } - t.HistoricalSummaries = val16 + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "HistoricalSummaries") + } + t.HistoricalSummaries = val20 } { // Field #34 'PendingDeposits' (dynamic) - buf := buf[offset34:offset35] - val17 := t.PendingDeposits - itemCount := len(buf) / 192 - if len(buf)%192 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 192), "PendingDeposits") + if dec.GetPosition() != startPos0+int(offset34) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset34)), "PendingDeposits") } - if itemCount > 134217728 { - return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 134217728), "PendingDeposits") + dec.PushLimit(int(offset35 - offset34)) + val21 := t.PendingDeposits + sszLen := dec.GetLength() + itemCount := sszLen / 192 + if sszLen%192 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 192), "PendingDeposits") } - val17 = sszutils.ExpandSlice(val17, itemCount) + if itemCount > int(expr10) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr10)), "PendingDeposits") + } + val21 = sszutils.ExpandSlice(val21, itemCount) + startPos14 := dec.GetPosition() for idx1 := range itemCount { - if val17[idx1] == nil { - val17[idx1] = new(electra.PendingDeposit) + if val21[idx1] == nil { + val21[idx1] = new(electra.PendingDeposit) } - buf := buf[192*idx1 : 192*(idx1+1)] - if err = val17[idx1].UnmarshalSSZ(buf); err != nil { + if buf, err := dec.DecodeBytesBuf(192); err != nil { return sszutils.ErrorWithPathf(err, "PendingDeposits[%d]", idx1) + } else if err = val21[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "PendingDeposits[%d]", idx1) + } + if dec.GetPosition() != startPos14+int(192*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos14+int(192*(idx1+1))), "PendingDeposits[%d]", idx1) } } - t.PendingDeposits = val17 + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "PendingDeposits") + } + t.PendingDeposits = val21 } { // Field #35 'PendingPartialWithdrawals' (dynamic) - buf := buf[offset35:offset36] - val18 := t.PendingPartialWithdrawals - itemCount := len(buf) / 24 - if len(buf)%24 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 24), "PendingPartialWithdrawals") + if dec.GetPosition() != startPos0+int(offset35) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset35)), "PendingPartialWithdrawals") } - if itemCount > 134217728 { - return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 134217728), "PendingPartialWithdrawals") + dec.PushLimit(int(offset36 - offset35)) + val22 := t.PendingPartialWithdrawals + sszLen := dec.GetLength() + itemCount := sszLen / 24 + if sszLen%24 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 24), "PendingPartialWithdrawals") } - val18 = sszutils.ExpandSlice(val18, itemCount) + if itemCount > int(expr11) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr11)), "PendingPartialWithdrawals") + } + val22 = sszutils.ExpandSlice(val22, itemCount) + startPos15 := dec.GetPosition() for idx1 := range itemCount { - if val18[idx1] == nil { - val18[idx1] = new(electra.PendingPartialWithdrawal) + if val22[idx1] == nil { + val22[idx1] = new(electra.PendingPartialWithdrawal) } - buf := buf[24*idx1 : 24*(idx1+1)] - if err = val18[idx1].UnmarshalSSZ(buf); err != nil { + if buf, err := dec.DecodeBytesBuf(24); err != nil { + return sszutils.ErrorWithPathf(err, "PendingPartialWithdrawals[%d]", idx1) + } else if err = val22[idx1].UnmarshalSSZ(buf); err != nil { return sszutils.ErrorWithPathf(err, "PendingPartialWithdrawals[%d]", idx1) } + if dec.GetPosition() != startPos15+int(24*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos15+int(24*(idx1+1))), "PendingPartialWithdrawals[%d]", idx1) + } } - t.PendingPartialWithdrawals = val18 + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "PendingPartialWithdrawals") + } + t.PendingPartialWithdrawals = val22 } { // Field #36 'PendingConsolidations' (dynamic) - buf := buf[offset36:offset38] - val19 := t.PendingConsolidations - itemCount := len(buf) / 16 - if len(buf)%16 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 16), "PendingConsolidations") + if dec.GetPosition() != startPos0+int(offset36) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset36)), "PendingConsolidations") } - if itemCount > 262144 { - return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 262144), "PendingConsolidations") + dec.PushLimit(int(offset38 - offset36)) + val23 := t.PendingConsolidations + sszLen := dec.GetLength() + itemCount := sszLen / 16 + if sszLen%16 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 16), "PendingConsolidations") } - val19 = sszutils.ExpandSlice(val19, itemCount) + if itemCount > int(expr12) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr12)), "PendingConsolidations") + } + val23 = sszutils.ExpandSlice(val23, itemCount) + startPos16 := dec.GetPosition() for idx1 := range itemCount { - if val19[idx1] == nil { - val19[idx1] = new(electra.PendingConsolidation) + if val23[idx1] == nil { + val23[idx1] = new(electra.PendingConsolidation) } - buf := buf[16*idx1 : 16*(idx1+1)] - if err = val19[idx1].UnmarshalSSZ(buf); err != nil { + if buf, err := dec.DecodeBytesBuf(16); err != nil { return sszutils.ErrorWithPathf(err, "PendingConsolidations[%d]", idx1) + } else if err = val23[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "PendingConsolidations[%d]", idx1) + } + if dec.GetPosition() != startPos16+int(16*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos16+int(16*(idx1+1))), "PendingConsolidations[%d]", idx1) } } - t.PendingConsolidations = val19 + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "PendingConsolidations") + } + t.PendingConsolidations = val23 } { // Field #38 'Builders' (dynamic) - buf := buf[offset38:offset42] - val20 := t.Builders - itemCount := len(buf) / 93 - if len(buf)%93 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 93), "Builders") + if dec.GetPosition() != startPos0+int(offset38) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset38)), "Builders") } - if itemCount > 1099511627776 { - return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1099511627776), "Builders") + dec.PushLimit(int(offset42 - offset38)) + val24 := t.Builders + sszLen := dec.GetLength() + itemCount := sszLen / 93 + if sszLen%93 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 93), "Builders") } - val20 = sszutils.ExpandSlice(val20, itemCount) + if itemCount > int(expr13) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr13)), "Builders") + } + val24 = sszutils.ExpandSlice(val24, itemCount) + startPos17 := dec.GetPosition() for idx1 := range itemCount { - if val20[idx1] == nil { - val20[idx1] = new(gloas.Builder) + if val24[idx1] == nil { + val24[idx1] = new(gloas.Builder) } - buf := buf[93*idx1 : 93*(idx1+1)] - if err = val20[idx1].UnmarshalSSZ(buf); err != nil { + if buf, err := dec.DecodeBytesBuf(93); err != nil { + return sszutils.ErrorWithPathf(err, "Builders[%d]", idx1) + } else if err = val24[idx1].UnmarshalSSZ(buf); err != nil { return sszutils.ErrorWithPathf(err, "Builders[%d]", idx1) } + if dec.GetPosition() != startPos17+int(93*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos17+int(93*(idx1+1))), "Builders[%d]", idx1) + } } - t.Builders = val20 + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "Builders") + } + t.Builders = val24 } { // Field #42 'BuilderPendingWithdrawals' (dynamic) - buf := buf[offset42:offset43] - val21 := t.BuilderPendingWithdrawals - itemCount := len(buf) / 36 - if len(buf)%36 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 36), "BuilderPendingWithdrawals") + if dec.GetPosition() != startPos0+int(offset42) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset42)), "BuilderPendingWithdrawals") } - if itemCount > 1048576 { - return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 1048576), "BuilderPendingWithdrawals") + dec.PushLimit(int(offset43 - offset42)) + val25 := t.BuilderPendingWithdrawals + sszLen := dec.GetLength() + itemCount := sszLen / 36 + if sszLen%36 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 36), "BuilderPendingWithdrawals") } - val21 = sszutils.ExpandSlice(val21, itemCount) + if itemCount > int(expr14) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr14)), "BuilderPendingWithdrawals") + } + val25 = sszutils.ExpandSlice(val25, itemCount) + startPos18 := dec.GetPosition() for idx1 := range itemCount { - if val21[idx1] == nil { - val21[idx1] = new(gloas.BuilderPendingWithdrawal) + if val25[idx1] == nil { + val25[idx1] = new(gloas.BuilderPendingWithdrawal) } - buf := buf[36*idx1 : 36*(idx1+1)] - if err = val21[idx1].UnmarshalSSZ(buf); err != nil { + if buf, err := dec.DecodeBytesBuf(36); err != nil { return sszutils.ErrorWithPathf(err, "BuilderPendingWithdrawals[%d]", idx1) + } else if err = val25[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "BuilderPendingWithdrawals[%d]", idx1) + } + if dec.GetPosition() != startPos18+int(36*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos18+int(36*(idx1+1))), "BuilderPendingWithdrawals[%d]", idx1) } } - t.BuilderPendingWithdrawals = val21 + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "BuilderPendingWithdrawals") + } + t.BuilderPendingWithdrawals = val25 } { // Field #43 'LatestExecutionPayloadBid' (dynamic) - buf := buf[offset43:offset44] - if t.LatestExecutionPayloadBid == nil { - t.LatestExecutionPayloadBid = new(ExecutionPayloadBid) + if dec.GetPosition() != startPos0+int(offset43) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset43)), "LatestExecutionPayloadBid") + } + dec.PushLimit(int(offset44 - offset43)) + val26 := t.LatestExecutionPayloadBid + if val26 == nil { + val26 = new(ExecutionPayloadBid) + } + totalSize := size11+224 + maxOffset := uint32(dec.GetLength()) + startPos19 := dec.GetPosition() + if maxOffset < uint32(totalSize) { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(maxOffset, uint32(totalSize)), "LatestExecutionPayloadBid") + } + // Field #0 'ParentBlockHash' (static) + if _, err = dec.DecodeBytes(val26.ParentBlockHash[:32]); err != nil { + return err + } + // Field #1 'ParentBlockRoot' (static) + if _, err = dec.DecodeBytes(val26.ParentBlockRoot[:32]); err != nil { + return err + } + // Field #2 'BlockHash' (static) + if _, err = dec.DecodeBytes(val26.BlockHash[:32]); err != nil { + return err + } + // Field #3 'PrevRandao' (static) + if _, err = dec.DecodeBytes(val26.PrevRandao[:32]); err != nil { + return err + } + // Field #4 'FeeRecipient' (static) + if _, err = dec.DecodeBytes(val26.FeeRecipient[:20]); err != nil { + return err + } + // Field #5 'GasLimit' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "LatestExecutionPayloadBid.GasLimit") + } else { + val26.GasLimit = val + } + // Field #6 'BuilderIndex' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "LatestExecutionPayloadBid.BuilderIndex") + } else { + val26.BuilderIndex = gloas.BuilderIndex(val) + } + // Field #7 'Slot' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "LatestExecutionPayloadBid.Slot") + } else { + val26.Slot = phase0.Slot(val) + } + // Field #8 'Value' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "LatestExecutionPayloadBid.Value") + } else { + val26.Value = phase0.Gwei(val) + } + // Field #9 'ExecutionPayment' (static) + if val, err := dec.DecodeUint64(); err != nil { + return sszutils.ErrorWithPath(err, "LatestExecutionPayloadBid.ExecutionPayment") + } else { + val26.ExecutionPayment = phase0.Gwei(val) + } + // Field #10 'BlobKZGCommitments' (offset) + offset10, err := dec.DecodeOffset() + if err != nil { + return sszutils.ErrorWithPath(err, "LatestExecutionPayloadBid.BlobKZGCommitments") + } + if offset10 != uint32(totalSize) { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset10, totalSize), "LatestExecutionPayloadBid.BlobKZGCommitments") + } + // Field #11 'ExecutionRequestsRoot' (static) + if _, err = dec.DecodeBytes(val26.ExecutionRequestsRoot[:32]); err != nil { + return err + } + // Field #12 'InclusionListBits' (static) + val26.InclusionListBits = sszutils.ExpandSlice(val26.InclusionListBits, int(expr15)) + if _, err = dec.DecodeBytes(val26.InclusionListBits[:int(expr15)]); err != nil { + return err + } + { // Field #10 'BlobKZGCommitments' (dynamic) + if dec.GetPosition() != startPos19+int(offset10) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos19+int(offset10)), "LatestExecutionPayloadBid.BlobKZGCommitments") + } + dec.PushLimit(int(maxOffset - offset10)) + val27 := val26.BlobKZGCommitments + sszLen := dec.GetLength() + itemCount := sszLen / 48 + if sszLen%48 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 48), "LatestExecutionPayloadBid.BlobKZGCommitments") + } + if itemCount > int(expr16) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr16)), "LatestExecutionPayloadBid.BlobKZGCommitments") + } + val27 = sszutils.ExpandSlice(val27, itemCount) + startPos20 := dec.GetPosition() + for idx1 := range itemCount { + if _, err = dec.DecodeBytes(val27[idx1][:48]); err != nil { + return err + } + if dec.GetPosition() != startPos20+int(48*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos20+int(48*(idx1+1))), "LatestExecutionPayloadBid.BlobKZGCommitments[%d]", idx1) + } + } + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "LatestExecutionPayloadBid.BlobKZGCommitments") + } + val26.BlobKZGCommitments = val27 } - if err = t.LatestExecutionPayloadBid.UnmarshalSSZ(buf); err != nil { - return sszutils.ErrorWithPath(err, "LatestExecutionPayloadBid") + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "LatestExecutionPayloadBid") } + t.LatestExecutionPayloadBid = val26 } { // Field #44 'PayloadExpectedWithdrawals' (dynamic) - buf := buf[offset44:] - val22 := t.PayloadExpectedWithdrawals - itemCount := len(buf) / 44 - if len(buf)%44 != 0 { - return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 44), "PayloadExpectedWithdrawals") + if dec.GetPosition() != startPos0+int(offset44) { + return sszutils.ErrorWithPath(sszutils.ErrFieldNotConsumedFn(dec.GetPosition(), startPos0+int(offset44)), "PayloadExpectedWithdrawals") } - if itemCount > 16 { - return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 16), "PayloadExpectedWithdrawals") + dec.PushLimit(int(maxOffset - offset44)) + val28 := t.PayloadExpectedWithdrawals + sszLen := dec.GetLength() + itemCount := sszLen / 44 + if sszLen%44 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(sszLen, 44), "PayloadExpectedWithdrawals") } - val22 = sszutils.ExpandSlice(val22, itemCount) + if itemCount > int(expr17) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr17)), "PayloadExpectedWithdrawals") + } + val28 = sszutils.ExpandSlice(val28, itemCount) + startPos21 := dec.GetPosition() for idx1 := range itemCount { - if val22[idx1] == nil { - val22[idx1] = new(capella.Withdrawal) + if val28[idx1] == nil { + val28[idx1] = new(capella.Withdrawal) } - buf := buf[44*idx1 : 44*(idx1+1)] - if err = val22[idx1].UnmarshalSSZ(buf); err != nil { + if buf, err := dec.DecodeBytesBuf(44); err != nil { return sszutils.ErrorWithPathf(err, "PayloadExpectedWithdrawals[%d]", idx1) + } else if err = val28[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "PayloadExpectedWithdrawals[%d]", idx1) + } + if dec.GetPosition() != startPos21+int(44*(idx1+1)) { + return sszutils.ErrorWithPathf(sszutils.ErrStaticElementNotConsumedFn(dec.GetPosition(), startPos21+int(44*(idx1+1))), "PayloadExpectedWithdrawals[%d]", idx1) } } - t.PayloadExpectedWithdrawals = val22 + if diff := dec.PopLimit(); diff != 0 { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(diff), "PayloadExpectedWithdrawals") + } + t.PayloadExpectedWithdrawals = val28 } return nil } diff --git a/spec/heze/generate.yaml b/spec/heze/generate.yaml index 547a34ed..6118fd09 100644 --- a/spec/heze/generate.yaml +++ b/spec/heze/generate.yaml @@ -9,6 +9,7 @@ types: output: beaconblockbody_ssz.go - name: BeaconState output: beaconstate_ssz.go + with-streaming: true - name: ExecutionPayloadBid output: executionpayloadbid_ssz.go - name: SignedBeaconBlock From 2672300fa313d8ff48c956ee5e15a31fb6880610 Mon Sep 17 00:00:00 2001 From: pk910 Date: Wed, 13 May 2026 00:49:32 +0200 Subject: [PATCH 2/2] defer http context cleanup for streaming requests --- http/http.go | 42 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 5 deletions(-) diff --git a/http/http.go b/http/http.go index 4b9367b2..8b12afaa 100644 --- a/http/http.go +++ b/http/http.go @@ -234,16 +234,29 @@ type httpResponse struct { // bodySize is the Content-Length of the streaming body, or -1 when the // server did not advertise one (e.g. chunked transfer). bodySize int64 + // cancel is the request context's cancel function, transferred to the + // response when the body is handed back for streaming. It must be + // invoked when the caller is done with the body so the request context + // is released; firing it sooner would cancel the in-flight body reads. + cancel context.CancelFunc } // Close releases the streaming body if one is held. Safe to call when no // stream is held (no-op). func (r *httpResponse) Close() error { - if r == nil || r.bodyReader == nil { + if r == nil { return nil } - err := r.bodyReader.Close() - r.bodyReader = nil + + var err error + if r.bodyReader != nil { + err = r.bodyReader.Close() + r.bodyReader = nil + } + if r.cancel != nil { + r.cancel() + r.cancel = nil + } return err } @@ -313,7 +326,16 @@ func (s *Service) getInternal(ctx context.Context, } opCtx, cancel := context.WithTimeout(ctx, timeout) - defer cancel() + // cancel must not fire until the response body has been fully consumed + // in streaming mode, since the request context controls the lifetime of + // resp.Body reads. The streaming success path transfers ownership of + // cancel to the returned httpResponse and clears this local copy so the + // defer below becomes a no-op. + defer func() { + if cancel != nil { + cancel() + } + }() req, err := http.NewRequestWithContext(opCtx, http.MethodGet, callURL.String(), nil) if err != nil { @@ -383,7 +405,12 @@ func (s *Service) getInternal(ctx context.Context, // reader so the SSZ decoder can read directly off the wire. Everything // else (non-2xx, JSON, etc.) is buffered below, matching the original // behavior so callers that don't care about streaming see no change. - if stream && statusFamily == 2 && res.contentType == ContentTypeSSZ { + // + // A known Content-Length is required: the streaming SSZ decoder is sized + // from this value, and chunked-encoded responses (Teku) report + // ContentLength = -1. For those, fall through to the buffered path so + // the decoder sees the full payload size up front. + if stream && statusFamily == 2 && res.contentType == ContentTypeSSZ && resp.ContentLength > 0 { if err := populateConsensusVersion(res, resp); err != nil { _ = resp.Body.Close() @@ -392,6 +419,11 @@ func (s *Service) getInternal(ctx context.Context, res.bodyReader = resp.Body res.bodySize = resp.ContentLength + // Transfer ownership of the request context cancel to the caller; + // the deferred cancel above becomes a no-op so resp.Body reads are + // not interrupted. The caller releases the context via res.Close(). + res.cancel = cancel + cancel = nil span.AddEvent("Received response", trace.WithAttributes( attribute.Int64("size", resp.ContentLength),