diff --git a/api/nodeidentityopts.go b/api/nodeidentityopts.go new file mode 100644 index 00000000..ebd31646 --- /dev/null +++ b/api/nodeidentityopts.go @@ -0,0 +1,19 @@ +// Copyright © 2026 Attestant Limited. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package api + +// NodeIdentityOpts are the options for obtaining the node's network identity. +type NodeIdentityOpts struct { + Common CommonOpts +} diff --git a/api/submitexecutionpayloadbidopts.go b/api/submitexecutionpayloadbidopts.go new file mode 100644 index 00000000..a1da3539 --- /dev/null +++ b/api/submitexecutionpayloadbidopts.go @@ -0,0 +1,40 @@ +// Copyright © 2026 Attestant Limited. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package api + +import ( + "github.com/ethpandaops/go-eth2-client/spec" + "github.com/ethpandaops/go-eth2-client/spec/all" +) + +// SubmitExecutionPayloadBidOpts are the options for submitting execution +// payload bids. +type SubmitExecutionPayloadBidOpts struct { + Common CommonOpts + + // SignedExecutionPayloadBid is the signed bid to publish. Its Version + // selects the wire schema and the consensus version header. + SignedExecutionPayloadBid *spec.VersionedSignedExecutionPayloadBid +} + +// SubmitAgnosticExecutionPayloadBidOpts are the options for submitting +// execution payload bids supplied as a fork-agnostic +// *all.SignedExecutionPayloadBid. +type SubmitAgnosticExecutionPayloadBidOpts struct { + Common CommonOpts + + // SignedExecutionPayloadBid is the signed bid to publish. Its Version + // selects the wire schema and the consensus version header. + SignedExecutionPayloadBid *all.SignedExecutionPayloadBid +} diff --git a/api/submitexecutionpayloadenvelopeopts.go b/api/submitexecutionpayloadenvelopeopts.go new file mode 100644 index 00000000..9a6797b1 --- /dev/null +++ b/api/submitexecutionpayloadenvelopeopts.go @@ -0,0 +1,69 @@ +// Copyright © 2026 Attestant Limited. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package api + +import ( + apiv2 "github.com/ethpandaops/go-eth2-client/api/v2" + "github.com/ethpandaops/go-eth2-client/spec" + "github.com/ethpandaops/go-eth2-client/spec/all" + "github.com/ethpandaops/go-eth2-client/spec/deneb" +) + +// SubmitExecutionPayloadEnvelopeOpts are the options for submitting execution +// payload envelopes. The submission always uses the stateless request form +// (SignedExecutionPayloadEnvelopeContents): the signed envelope plus the +// blobs and KZG cell proofs the beacon node needs to build data column +// sidecars. The stateful/blinded form only works when the beacon node cached +// the full envelope from its own block production, so it is not offered here. +type SubmitExecutionPayloadEnvelopeOpts struct { + Common CommonOpts + + // SignedExecutionPayloadEnvelope is the signed envelope to publish. + // Its Version selects the wire schema and the consensus version header. + SignedExecutionPayloadEnvelope *spec.VersionedSignedExecutionPayloadEnvelope + + // KZGProofs are the cell KZG proofs for the blobs committed to by the + // envelope's payload. + KZGProofs []deneb.KZGProof + + // Blobs are the blobs committed to by the envelope's payload. + Blobs []deneb.Blob + + // BroadcastValidation is the validation required of the consensus node + // before broadcasting the envelope. + BroadcastValidation *apiv2.BroadcastValidation +} + +// SubmitAgnosticExecutionPayloadEnvelopeOpts are the options for submitting +// execution payload envelopes supplied as a fork-agnostic +// *all.SignedExecutionPayloadEnvelope. See +// SubmitExecutionPayloadEnvelopeOpts for the request form semantics. +type SubmitAgnosticExecutionPayloadEnvelopeOpts struct { + Common CommonOpts + + // SignedExecutionPayloadEnvelope is the signed envelope to publish. + // Its Version selects the wire schema and the consensus version header. + SignedExecutionPayloadEnvelope *all.SignedExecutionPayloadEnvelope + + // KZGProofs are the cell KZG proofs for the blobs committed to by the + // envelope's payload. + KZGProofs []deneb.KZGProof + + // Blobs are the blobs committed to by the envelope's payload. + Blobs []deneb.Blob + + // BroadcastValidation is the validation required of the consensus node + // before broadcasting the envelope. + BroadcastValidation *apiv2.BroadcastValidation +} diff --git a/api/v1/all/blindedbeaconblock.go b/api/v1/all/blindedbeaconblock.go new file mode 100644 index 00000000..ce60fdc4 --- /dev/null +++ b/api/v1/all/blindedbeaconblock.go @@ -0,0 +1,283 @@ +// Copyright © 2026 Attestant Limited. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package all + +import ( + "errors" + "fmt" + + "github.com/ethpandaops/go-eth2-client/api" + apiv1bellatrix "github.com/ethpandaops/go-eth2-client/api/v1/bellatrix" + apiv1capella "github.com/ethpandaops/go-eth2-client/api/v1/capella" + apiv1deneb "github.com/ethpandaops/go-eth2-client/api/v1/deneb" + apiv1electra "github.com/ethpandaops/go-eth2-client/api/v1/electra" + "github.com/ethpandaops/go-eth2-client/spec/phase0" + "github.com/ethpandaops/go-eth2-client/spec/version" + dynssz "github.com/pk910/dynamic-ssz" + "github.com/pk910/dynamic-ssz/sszutils" +) + +// BlindedBeaconBlock is a fork-agnostic blinded beacon block. The Body's +// contents depend on Version. Blinded blocks exist as a wire type from +// Bellatrix up to (excluding) Gloas; other forks are not supported by this +// type. +type BlindedBeaconBlock struct { + Version version.DataVersion + Slot phase0.Slot + ProposerIndex phase0.ValidatorIndex + ParentRoot phase0.Root + StateRoot phase0.Root + Body *BlindedBeaconBlockBody +} + +// viewType returns the fork-specific schema type pointer used as the view +// descriptor for the active Version. +func (b *BlindedBeaconBlock) viewType() (any, error) { + switch b.Version { + case version.DataVersionBellatrix: + return (*apiv1bellatrix.BlindedBeaconBlock)(nil), nil + case version.DataVersionCapella: + return (*apiv1capella.BlindedBeaconBlock)(nil), nil + case version.DataVersionDeneb: + return (*apiv1deneb.BlindedBeaconBlock)(nil), nil + case version.DataVersionElectra, + version.DataVersionFulu: + // Fulu reuses the Electra blinded block schema unchanged. + return (*apiv1electra.BlindedBeaconBlock)(nil), nil + default: + return nil, fmt.Errorf("BlindedBeaconBlock: unsupported version %d", b.Version) + } +} + +// MarshalSSZDyn marshals the blinded block using the view that matches +// Version. +func (b *BlindedBeaconBlock) MarshalSSZDyn(ds sszutils.DynamicSpecs, buf []byte) ([]byte, error) { + view, err := b.viewType() + if err != nil { + return nil, err + } + + m, ok := any(b).(sszutils.DynamicViewMarshaler) + if !ok { + return nil, errors.New("BlindedBeaconBlock: generated SSZ code missing") + } + + fn := m.MarshalSSZDynView(view) + if fn == nil { + return nil, fmt.Errorf("BlindedBeaconBlock: no view marshaler for version %d", b.Version) + } + + return fn(ds, buf) +} + +// SizeSSZDyn returns the SSZ size of the blinded block for the active +// Version. +func (b *BlindedBeaconBlock) SizeSSZDyn(ds sszutils.DynamicSpecs) int { + view, err := b.viewType() + if err != nil { + return 0 + } + + sz, ok := any(b).(sszutils.DynamicViewSizer) + if !ok { + return 0 + } + + fn := sz.SizeSSZDynView(view) + if fn == nil { + return 0 + } + + return fn(ds) +} + +// UnmarshalSSZDyn decodes the blinded block into the view that matches +// Version. +func (b *BlindedBeaconBlock) UnmarshalSSZDyn(ds sszutils.DynamicSpecs, buf []byte) error { + view, err := b.viewType() + if err != nil { + return err + } + + u, ok := any(b).(sszutils.DynamicViewUnmarshaler) + if !ok { + return errors.New("BlindedBeaconBlock: generated SSZ code missing") + } + + fn := u.UnmarshalSSZDynView(view) + if fn == nil { + return fmt.Errorf("BlindedBeaconBlock: no view unmarshaler for version %d", b.Version) + } + + if err := fn(ds, buf); err != nil { + return err + } + + b.populateVersion(b.Version) + + return nil +} + +// populateVersion sets Version and propagates it to any nested versionable +// children. +func (b *BlindedBeaconBlock) populateVersion(v version.DataVersion) { + propagateVersion(b, v) +} + +// ToView returns a fresh fork-specific BlindedBeaconBlock populated with b's +// fields, recursing into Body via copyByName. +func (b *BlindedBeaconBlock) ToView() (any, error) { + return toViewByCopy(b) +} + +// FromView populates b from a fork-specific BlindedBeaconBlock. +func (b *BlindedBeaconBlock) FromView(view any) error { + v, err := blindedBeaconBlockVersion(view) + if err != nil { + return err + } + + if b.Version == version.DataVersionUnknown { + b.Version = v + } + + if err := copyByName(view, b); err != nil { + return err + } + + b.populateVersion(b.Version) + + return nil +} + +// blindedBeaconBlockVersion maps a BlindedBeaconBlock view type to its +// DataVersion. +func blindedBeaconBlockVersion(view any) (version.DataVersion, error) { + switch view.(type) { + case *apiv1bellatrix.BlindedBeaconBlock: + return version.DataVersionBellatrix, nil + case *apiv1capella.BlindedBeaconBlock: + return version.DataVersionCapella, nil + case *apiv1deneb.BlindedBeaconBlock: + return version.DataVersionDeneb, nil + case *apiv1electra.BlindedBeaconBlock: + return version.DataVersionElectra, nil + default: + return version.DataVersionUnknown, fmt.Errorf("BlindedBeaconBlock: unsupported view type %T", view) + } +} + +// HashTreeRootWithDyn computes the SSZ hash tree root using the active +// Version's view. +func (b *BlindedBeaconBlock) HashTreeRootWithDyn(ds sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + view, err := b.viewType() + if err != nil { + return err + } + + h, ok := any(b).(sszutils.DynamicViewHashRoot) + if !ok { + return errors.New("BlindedBeaconBlock: generated SSZ code missing") + } + + fn := h.HashTreeRootWithDynView(view) + if fn == nil { + return fmt.Errorf("BlindedBeaconBlock: no view hasher for version %d", b.Version) + } + + return fn(ds, hh) +} + +// MarshalSSZ implements the fastssz.Marshaler interface. +func (b *BlindedBeaconBlock) MarshalSSZ() ([]byte, error) { + ds := dynssz.GetGlobalDynSsz() + + return b.MarshalSSZDyn(ds, make([]byte, 0, b.SizeSSZDyn(ds))) +} + +// MarshalSSZTo implements the fastssz.Marshaler interface. +func (b *BlindedBeaconBlock) MarshalSSZTo(dst []byte) ([]byte, error) { + return b.MarshalSSZDyn(dynssz.GetGlobalDynSsz(), dst) +} + +// UnmarshalSSZ implements the fastssz.Unmarshaler interface. +func (b *BlindedBeaconBlock) UnmarshalSSZ(buf []byte) error { + return b.UnmarshalSSZDyn(dynssz.GetGlobalDynSsz(), buf) +} + +// SizeSSZ implements the fastssz.Marshaler interface. +func (b *BlindedBeaconBlock) SizeSSZ() int { + return b.SizeSSZDyn(dynssz.GetGlobalDynSsz()) +} + +// HashTreeRoot implements the fastssz.HashRoot interface. +func (b *BlindedBeaconBlock) HashTreeRoot() ([32]byte, error) { + return dynssz.GetGlobalDynSsz().HashTreeRoot(b) +} + +// HashTreeRootWith implements the fastssz.HashRoot interface. +func (b *BlindedBeaconBlock) HashTreeRootWith(hh sszutils.HashWalker) error { + return b.HashTreeRootWithDyn(dynssz.GetGlobalDynSsz(), hh) +} + +// ToVersioned converts b into a *api.VersionedBlindedBeaconBlock. +func (b *BlindedBeaconBlock) ToVersioned() (*api.VersionedBlindedBeaconBlock, error) { + out := &api.VersionedBlindedBeaconBlock{} + if err := toVersioned(b.Version, b, out); err != nil { + return nil, err + } + + return out, nil +} + +// FromVersioned populates b from src. +func (b *BlindedBeaconBlock) FromVersioned(src *api.VersionedBlindedBeaconBlock) error { + return fromVersioned(b, src) +} + +// MarshalJSON delegates to the per-fork BlindedBeaconBlock that matches +// Version. +func (b *BlindedBeaconBlock) MarshalJSON() ([]byte, error) { + return marshalAsView(b) +} + +// UnmarshalJSON delegates to the per-fork BlindedBeaconBlock that matches +// Version. Caller must set Version before calling. +func (b *BlindedBeaconBlock) UnmarshalJSON(data []byte) error { + if err := unmarshalAsView(b, data); err != nil { + return err + } + + b.populateVersion(b.Version) + + return nil +} + +// MarshalYAML delegates to the per-fork BlindedBeaconBlock that matches +// Version. +func (b *BlindedBeaconBlock) MarshalYAML() ([]byte, error) { + return marshalAsViewYAML(b) +} + +// UnmarshalYAML delegates to the per-fork BlindedBeaconBlock that matches +// Version. Caller must set Version before calling. +func (b *BlindedBeaconBlock) UnmarshalYAML(data []byte) error { + if err := unmarshalAsViewYAML(b, data); err != nil { + return err + } + + b.populateVersion(b.Version) + + return nil +} diff --git a/api/v1/all/blindedbeaconblock_ssz.go b/api/v1/all/blindedbeaconblock_ssz.go new file mode 100644 index 00000000..5c35cf1a --- /dev/null +++ b/api/v1/all/blindedbeaconblock_ssz.go @@ -0,0 +1,598 @@ +// Code generated by dynamic-ssz. DO NOT EDIT. +// Hash: b60939a5a59438931b81b47e98b0059dde5e06e67c79bfb3cd5c8efe55162344 +// Version: v1.3.2 (https://github.com/pk910/dynamic-ssz) +package all + +import ( + "encoding/binary" + + "github.com/ethpandaops/go-eth2-client/api/v1/bellatrix" + "github.com/ethpandaops/go-eth2-client/api/v1/capella" + "github.com/ethpandaops/go-eth2-client/api/v1/deneb" + "github.com/ethpandaops/go-eth2-client/api/v1/electra" + "github.com/ethpandaops/go-eth2-client/spec/phase0" + "github.com/pk910/dynamic-ssz/sszutils" +) + +var _ = sszutils.ErrListTooBig + +var _ = sszutils.Annotate[*bellatrix.BlindedBeaconBlock](`ssz-static:"false"`) +var _ = sszutils.Annotate[*capella.BlindedBeaconBlock](`ssz-static:"false"`) +var _ = sszutils.Annotate[*deneb.BlindedBeaconBlock](`ssz-static:"false"`) +var _ = sszutils.Annotate[*electra.BlindedBeaconBlock](`ssz-static:"false"`) + +func (t *BlindedBeaconBlock) MarshalSSZDynView(view any) func(ds sszutils.DynamicSpecs, buf []byte) ([]byte, error) { + switch view.(type) { + case *bellatrix.BlindedBeaconBlock: + return t.marshalSSZView_BlindedBeaconBlock + case *capella.BlindedBeaconBlock: + return t.marshalSSZView_BlindedBeaconBlock_0 + case *deneb.BlindedBeaconBlock: + return t.marshalSSZView_BlindedBeaconBlock_1 + case *electra.BlindedBeaconBlock: + return t.marshalSSZView_BlindedBeaconBlock_2 + } + return nil +} +func (t *BlindedBeaconBlock) marshalSSZView_BlindedBeaconBlock(ds sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + dst = buf + if t == nil { + t = new(BlindedBeaconBlock) + } + dstlen := len(dst) + { // Static Field #0 'Slot' + dst = binary.LittleEndian.AppendUint64(dst, uint64(t.Slot)) + } + { // Static Field #1 'ProposerIndex' + dst = binary.LittleEndian.AppendUint64(dst, uint64(t.ProposerIndex)) + } + { // Static Field #2 'ParentRoot' + dst = append(dst, t.ParentRoot[:32]...) + } + { // Static Field #3 'StateRoot' + dst = append(dst, t.StateRoot[:32]...) + } + // Offset Field #4 'Body' + dst = append(dst, 0, 0, 0, 0) + { // Dynamic Field #4 'Body' + binary.LittleEndian.PutUint32(dst[dstlen+80:], uint32(len(dst)-dstlen)) + t := t.Body + if t == nil { + t = new(BlindedBeaconBlockBody) + } + if viewFn := t.MarshalSSZDynView((*bellatrix.BlindedBeaconBlockBody)(nil)); viewFn != nil { + if dst, err = viewFn(ds, dst); err != nil { + return nil, err + } + } else { + return nil, sszutils.ErrNotImplemented + } + } + return dst, nil +} + +func (t *BlindedBeaconBlock) marshalSSZView_BlindedBeaconBlock_0(ds sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + dst = buf + if t == nil { + t = new(BlindedBeaconBlock) + } + dstlen := len(dst) + { // Static Field #0 'Slot' + dst = binary.LittleEndian.AppendUint64(dst, uint64(t.Slot)) + } + { // Static Field #1 'ProposerIndex' + dst = binary.LittleEndian.AppendUint64(dst, uint64(t.ProposerIndex)) + } + { // Static Field #2 'ParentRoot' + dst = append(dst, t.ParentRoot[:32]...) + } + { // Static Field #3 'StateRoot' + dst = append(dst, t.StateRoot[:32]...) + } + // Offset Field #4 'Body' + dst = append(dst, 0, 0, 0, 0) + { // Dynamic Field #4 'Body' + binary.LittleEndian.PutUint32(dst[dstlen+80:], uint32(len(dst)-dstlen)) + t := t.Body + if t == nil { + t = new(BlindedBeaconBlockBody) + } + if viewFn := t.MarshalSSZDynView((*capella.BlindedBeaconBlockBody)(nil)); viewFn != nil { + if dst, err = viewFn(ds, dst); err != nil { + return nil, err + } + } else { + return nil, sszutils.ErrNotImplemented + } + } + return dst, nil +} + +func (t *BlindedBeaconBlock) marshalSSZView_BlindedBeaconBlock_1(ds sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + dst = buf + if t == nil { + t = new(BlindedBeaconBlock) + } + dstlen := len(dst) + { // Static Field #0 'Slot' + dst = binary.LittleEndian.AppendUint64(dst, uint64(t.Slot)) + } + { // Static Field #1 'ProposerIndex' + dst = binary.LittleEndian.AppendUint64(dst, uint64(t.ProposerIndex)) + } + { // Static Field #2 'ParentRoot' + dst = append(dst, t.ParentRoot[:32]...) + } + { // Static Field #3 'StateRoot' + dst = append(dst, t.StateRoot[:32]...) + } + // Offset Field #4 'Body' + dst = append(dst, 0, 0, 0, 0) + { // Dynamic Field #4 'Body' + binary.LittleEndian.PutUint32(dst[dstlen+80:], uint32(len(dst)-dstlen)) + t := t.Body + if t == nil { + t = new(BlindedBeaconBlockBody) + } + if viewFn := t.MarshalSSZDynView((*deneb.BlindedBeaconBlockBody)(nil)); viewFn != nil { + if dst, err = viewFn(ds, dst); err != nil { + return nil, err + } + } else { + return nil, sszutils.ErrNotImplemented + } + } + return dst, nil +} + +func (t *BlindedBeaconBlock) marshalSSZView_BlindedBeaconBlock_2(ds sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + dst = buf + if t == nil { + t = new(BlindedBeaconBlock) + } + dstlen := len(dst) + { // Static Field #0 'Slot' + dst = binary.LittleEndian.AppendUint64(dst, uint64(t.Slot)) + } + { // Static Field #1 'ProposerIndex' + dst = binary.LittleEndian.AppendUint64(dst, uint64(t.ProposerIndex)) + } + { // Static Field #2 'ParentRoot' + dst = append(dst, t.ParentRoot[:32]...) + } + { // Static Field #3 'StateRoot' + dst = append(dst, t.StateRoot[:32]...) + } + // Offset Field #4 'Body' + dst = append(dst, 0, 0, 0, 0) + { // Dynamic Field #4 'Body' + binary.LittleEndian.PutUint32(dst[dstlen+80:], uint32(len(dst)-dstlen)) + t := t.Body + if t == nil { + t = new(BlindedBeaconBlockBody) + } + if viewFn := t.MarshalSSZDynView((*electra.BlindedBeaconBlockBody)(nil)); viewFn != nil { + if dst, err = viewFn(ds, dst); err != nil { + return nil, err + } + } else { + return nil, sszutils.ErrNotImplemented + } + } + return dst, nil +} + +func (t *BlindedBeaconBlock) UnmarshalSSZDynView(view any) func(ds sszutils.DynamicSpecs, buf []byte) error { + switch view.(type) { + case *bellatrix.BlindedBeaconBlock: + return t.unmarshalSSZView_BlindedBeaconBlock + case *capella.BlindedBeaconBlock: + return t.unmarshalSSZView_BlindedBeaconBlock_0 + case *deneb.BlindedBeaconBlock: + return t.unmarshalSSZView_BlindedBeaconBlock_1 + case *electra.BlindedBeaconBlock: + return t.unmarshalSSZView_BlindedBeaconBlock_2 + } + return nil +} +func (t *BlindedBeaconBlock) unmarshalSSZView_BlindedBeaconBlock(ds sszutils.DynamicSpecs, buf []byte) (err error) { + buflen := len(buf) + if buflen < 84 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 84) + } + { // Field #0 'Slot' (static) + buf := buf[0:8] + t.Slot = phase0.Slot(binary.LittleEndian.Uint64(buf)) + } + { // Field #1 'ProposerIndex' (static) + buf := buf[8:16] + t.ProposerIndex = phase0.ValidatorIndex(binary.LittleEndian.Uint64(buf)) + } + { // Field #2 'ParentRoot' (static) + buf := buf[16:48] + copy(t.ParentRoot[:], buf) + } + { // Field #3 'StateRoot' (static) + buf := buf[48:80] + copy(t.StateRoot[:], buf) + } + // Field #4 'Body' (offset) + offset4 := int(binary.LittleEndian.Uint32(buf[80:84])) + if offset4 != 84 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset4, 84), "Body:o") + } + { // Field #4 'Body' (dynamic) + buf := buf[offset4:] + if t.Body == nil { + t.Body = new(BlindedBeaconBlockBody) + } + if viewFn := t.Body.UnmarshalSSZDynView((*bellatrix.BlindedBeaconBlockBody)(nil)); viewFn != nil { + if err = viewFn(ds, buf); err != nil { + return err + } + } else { + return sszutils.ErrNotImplemented + } + } + return nil +} + +func (t *BlindedBeaconBlock) unmarshalSSZView_BlindedBeaconBlock_0(ds sszutils.DynamicSpecs, buf []byte) (err error) { + buflen := len(buf) + if buflen < 84 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 84) + } + { // Field #0 'Slot' (static) + buf := buf[0:8] + t.Slot = phase0.Slot(binary.LittleEndian.Uint64(buf)) + } + { // Field #1 'ProposerIndex' (static) + buf := buf[8:16] + t.ProposerIndex = phase0.ValidatorIndex(binary.LittleEndian.Uint64(buf)) + } + { // Field #2 'ParentRoot' (static) + buf := buf[16:48] + copy(t.ParentRoot[:], buf) + } + { // Field #3 'StateRoot' (static) + buf := buf[48:80] + copy(t.StateRoot[:], buf) + } + // Field #4 'Body' (offset) + offset4 := int(binary.LittleEndian.Uint32(buf[80:84])) + if offset4 != 84 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset4, 84), "Body:o") + } + { // Field #4 'Body' (dynamic) + buf := buf[offset4:] + if t.Body == nil { + t.Body = new(BlindedBeaconBlockBody) + } + if viewFn := t.Body.UnmarshalSSZDynView((*capella.BlindedBeaconBlockBody)(nil)); viewFn != nil { + if err = viewFn(ds, buf); err != nil { + return err + } + } else { + return sszutils.ErrNotImplemented + } + } + return nil +} + +func (t *BlindedBeaconBlock) unmarshalSSZView_BlindedBeaconBlock_1(ds sszutils.DynamicSpecs, buf []byte) (err error) { + buflen := len(buf) + if buflen < 84 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 84) + } + { // Field #0 'Slot' (static) + buf := buf[0:8] + t.Slot = phase0.Slot(binary.LittleEndian.Uint64(buf)) + } + { // Field #1 'ProposerIndex' (static) + buf := buf[8:16] + t.ProposerIndex = phase0.ValidatorIndex(binary.LittleEndian.Uint64(buf)) + } + { // Field #2 'ParentRoot' (static) + buf := buf[16:48] + copy(t.ParentRoot[:], buf) + } + { // Field #3 'StateRoot' (static) + buf := buf[48:80] + copy(t.StateRoot[:], buf) + } + // Field #4 'Body' (offset) + offset4 := int(binary.LittleEndian.Uint32(buf[80:84])) + if offset4 != 84 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset4, 84), "Body:o") + } + { // Field #4 'Body' (dynamic) + buf := buf[offset4:] + if t.Body == nil { + t.Body = new(BlindedBeaconBlockBody) + } + if viewFn := t.Body.UnmarshalSSZDynView((*deneb.BlindedBeaconBlockBody)(nil)); viewFn != nil { + if err = viewFn(ds, buf); err != nil { + return err + } + } else { + return sszutils.ErrNotImplemented + } + } + return nil +} + +func (t *BlindedBeaconBlock) unmarshalSSZView_BlindedBeaconBlock_2(ds sszutils.DynamicSpecs, buf []byte) (err error) { + buflen := len(buf) + if buflen < 84 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 84) + } + { // Field #0 'Slot' (static) + buf := buf[0:8] + t.Slot = phase0.Slot(binary.LittleEndian.Uint64(buf)) + } + { // Field #1 'ProposerIndex' (static) + buf := buf[8:16] + t.ProposerIndex = phase0.ValidatorIndex(binary.LittleEndian.Uint64(buf)) + } + { // Field #2 'ParentRoot' (static) + buf := buf[16:48] + copy(t.ParentRoot[:], buf) + } + { // Field #3 'StateRoot' (static) + buf := buf[48:80] + copy(t.StateRoot[:], buf) + } + // Field #4 'Body' (offset) + offset4 := int(binary.LittleEndian.Uint32(buf[80:84])) + if offset4 != 84 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset4, 84), "Body:o") + } + { // Field #4 'Body' (dynamic) + buf := buf[offset4:] + if t.Body == nil { + t.Body = new(BlindedBeaconBlockBody) + } + if viewFn := t.Body.UnmarshalSSZDynView((*electra.BlindedBeaconBlockBody)(nil)); viewFn != nil { + if err = viewFn(ds, buf); err != nil { + return err + } + } else { + return sszutils.ErrNotImplemented + } + } + return nil +} + +func (t *BlindedBeaconBlock) SizeSSZDynView(view any) func(ds sszutils.DynamicSpecs) int { + switch view.(type) { + case *bellatrix.BlindedBeaconBlock: + return t.sizeSSZView_BlindedBeaconBlock + case *capella.BlindedBeaconBlock: + return t.sizeSSZView_BlindedBeaconBlock_0 + case *deneb.BlindedBeaconBlock: + return t.sizeSSZView_BlindedBeaconBlock_1 + case *electra.BlindedBeaconBlock: + return t.sizeSSZView_BlindedBeaconBlock_2 + } + return nil +} +func (t *BlindedBeaconBlock) sizeSSZView_BlindedBeaconBlock(ds sszutils.DynamicSpecs) (size int) { + if t == nil { + t = new(BlindedBeaconBlock) + } + // Field #0 'Slot' static (8 bytes) + // Field #1 'ProposerIndex' static (8 bytes) + // Field #2 'ParentRoot' static (32 bytes) + // Field #3 'StateRoot' static (32 bytes) + // Field #4 'Body' offset (4 bytes) + size += 84 + { // Dynamic field #4 'Body' + if viewFn := t.Body.SizeSSZDynView((*bellatrix.BlindedBeaconBlockBody)(nil)); viewFn != nil { + size += viewFn(ds) + } + } + return size +} + +func (t *BlindedBeaconBlock) sizeSSZView_BlindedBeaconBlock_0(ds sszutils.DynamicSpecs) (size int) { + if t == nil { + t = new(BlindedBeaconBlock) + } + // Field #0 'Slot' static (8 bytes) + // Field #1 'ProposerIndex' static (8 bytes) + // Field #2 'ParentRoot' static (32 bytes) + // Field #3 'StateRoot' static (32 bytes) + // Field #4 'Body' offset (4 bytes) + size += 84 + { // Dynamic field #4 'Body' + if viewFn := t.Body.SizeSSZDynView((*capella.BlindedBeaconBlockBody)(nil)); viewFn != nil { + size += viewFn(ds) + } + } + return size +} + +func (t *BlindedBeaconBlock) sizeSSZView_BlindedBeaconBlock_1(ds sszutils.DynamicSpecs) (size int) { + if t == nil { + t = new(BlindedBeaconBlock) + } + // Field #0 'Slot' static (8 bytes) + // Field #1 'ProposerIndex' static (8 bytes) + // Field #2 'ParentRoot' static (32 bytes) + // Field #3 'StateRoot' static (32 bytes) + // Field #4 'Body' offset (4 bytes) + size += 84 + { // Dynamic field #4 'Body' + if viewFn := t.Body.SizeSSZDynView((*deneb.BlindedBeaconBlockBody)(nil)); viewFn != nil { + size += viewFn(ds) + } + } + return size +} + +func (t *BlindedBeaconBlock) sizeSSZView_BlindedBeaconBlock_2(ds sszutils.DynamicSpecs) (size int) { + if t == nil { + t = new(BlindedBeaconBlock) + } + // Field #0 'Slot' static (8 bytes) + // Field #1 'ProposerIndex' static (8 bytes) + // Field #2 'ParentRoot' static (32 bytes) + // Field #3 'StateRoot' static (32 bytes) + // Field #4 'Body' offset (4 bytes) + size += 84 + { // Dynamic field #4 'Body' + if viewFn := t.Body.SizeSSZDynView((*electra.BlindedBeaconBlockBody)(nil)); viewFn != nil { + size += viewFn(ds) + } + } + return size +} + +func (t *BlindedBeaconBlock) HashTreeRootWithDynView(view any) func(ds sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + switch view.(type) { + case *bellatrix.BlindedBeaconBlock: + return t.hashTreeRootView_BlindedBeaconBlock + case *capella.BlindedBeaconBlock: + return t.hashTreeRootView_BlindedBeaconBlock_0 + case *deneb.BlindedBeaconBlock: + return t.hashTreeRootView_BlindedBeaconBlock_1 + case *electra.BlindedBeaconBlock: + return t.hashTreeRootView_BlindedBeaconBlock_2 + } + return nil +} +func (t *BlindedBeaconBlock) hashTreeRootView_BlindedBeaconBlock(ds sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + if t == nil { + t = new(BlindedBeaconBlock) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Slot' + hh.PutUint64(uint64(t.Slot)) + } + { // Field #1 'ProposerIndex' + hh.PutUint64(uint64(t.ProposerIndex)) + } + { // Field #2 'ParentRoot' + hh.PutBytes(t.ParentRoot[:32]) + } + { // Field #3 'StateRoot' + hh.PutBytes(t.StateRoot[:32]) + } + { // Field #4 'Body' + t := t.Body + if t == nil { + t = new(BlindedBeaconBlockBody) + } + if viewFn := t.HashTreeRootWithDynView((*bellatrix.BlindedBeaconBlockBody)(nil)); viewFn != nil { + if err := viewFn(ds, hh); err != nil { + return err + } + } else { + return sszutils.ErrNotImplemented + } + } + hh.Merkleize(idx) + return nil +} + +func (t *BlindedBeaconBlock) hashTreeRootView_BlindedBeaconBlock_0(ds sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + if t == nil { + t = new(BlindedBeaconBlock) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Slot' + hh.PutUint64(uint64(t.Slot)) + } + { // Field #1 'ProposerIndex' + hh.PutUint64(uint64(t.ProposerIndex)) + } + { // Field #2 'ParentRoot' + hh.PutBytes(t.ParentRoot[:32]) + } + { // Field #3 'StateRoot' + hh.PutBytes(t.StateRoot[:32]) + } + { // Field #4 'Body' + t := t.Body + if t == nil { + t = new(BlindedBeaconBlockBody) + } + if viewFn := t.HashTreeRootWithDynView((*capella.BlindedBeaconBlockBody)(nil)); viewFn != nil { + if err := viewFn(ds, hh); err != nil { + return err + } + } else { + return sszutils.ErrNotImplemented + } + } + hh.Merkleize(idx) + return nil +} + +func (t *BlindedBeaconBlock) hashTreeRootView_BlindedBeaconBlock_1(ds sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + if t == nil { + t = new(BlindedBeaconBlock) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Slot' + hh.PutUint64(uint64(t.Slot)) + } + { // Field #1 'ProposerIndex' + hh.PutUint64(uint64(t.ProposerIndex)) + } + { // Field #2 'ParentRoot' + hh.PutBytes(t.ParentRoot[:32]) + } + { // Field #3 'StateRoot' + hh.PutBytes(t.StateRoot[:32]) + } + { // Field #4 'Body' + t := t.Body + if t == nil { + t = new(BlindedBeaconBlockBody) + } + if viewFn := t.HashTreeRootWithDynView((*deneb.BlindedBeaconBlockBody)(nil)); viewFn != nil { + if err := viewFn(ds, hh); err != nil { + return err + } + } else { + return sszutils.ErrNotImplemented + } + } + hh.Merkleize(idx) + return nil +} + +func (t *BlindedBeaconBlock) hashTreeRootView_BlindedBeaconBlock_2(ds sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + if t == nil { + t = new(BlindedBeaconBlock) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Slot' + hh.PutUint64(uint64(t.Slot)) + } + { // Field #1 'ProposerIndex' + hh.PutUint64(uint64(t.ProposerIndex)) + } + { // Field #2 'ParentRoot' + hh.PutBytes(t.ParentRoot[:32]) + } + { // Field #3 'StateRoot' + hh.PutBytes(t.StateRoot[:32]) + } + { // Field #4 'Body' + t := t.Body + if t == nil { + t = new(BlindedBeaconBlockBody) + } + if viewFn := t.HashTreeRootWithDynView((*electra.BlindedBeaconBlockBody)(nil)); viewFn != nil { + if err := viewFn(ds, hh); err != nil { + return err + } + } else { + return sszutils.ErrNotImplemented + } + } + hh.Merkleize(idx) + return nil +} diff --git a/api/v1/all/blindedbeaconblock_test.go b/api/v1/all/blindedbeaconblock_test.go new file mode 100644 index 00000000..551c68aa --- /dev/null +++ b/api/v1/all/blindedbeaconblock_test.go @@ -0,0 +1,252 @@ +// Copyright © 2026 Attestant Limited. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package all_test + +import ( + "encoding/json" + "testing" + + apiv1all "github.com/ethpandaops/go-eth2-client/api/v1/all" + apiv1bellatrix "github.com/ethpandaops/go-eth2-client/api/v1/bellatrix" + apiv1capella "github.com/ethpandaops/go-eth2-client/api/v1/capella" + apiv1deneb "github.com/ethpandaops/go-eth2-client/api/v1/deneb" + apiv1electra "github.com/ethpandaops/go-eth2-client/api/v1/electra" + "github.com/ethpandaops/go-eth2-client/spec/phase0" + "github.com/ethpandaops/go-eth2-client/spec/version" + "github.com/stretchr/testify/require" +) + +// blindedBeaconBlockTests enumerates the per-fork views the agnostic +// BlindedBeaconBlock must be wire-compatible with. +func blindedBeaconBlockTests() []struct { + name string + version version.DataVersion + view any +} { + return []struct { + name string + version version.DataVersion + view any + }{ + { + name: "Bellatrix", + version: version.DataVersionBellatrix, + view: &apiv1bellatrix.BlindedBeaconBlock{ + Slot: 12345, + ProposerIndex: 42, + ParentRoot: phase0.Root{0x11}, + StateRoot: phase0.Root{0x12}, + Body: testBellatrixBlindedBody(), + }, + }, + { + name: "Capella", + version: version.DataVersionCapella, + view: &apiv1capella.BlindedBeaconBlock{ + Slot: 12345, + ProposerIndex: 42, + ParentRoot: phase0.Root{0x11}, + StateRoot: phase0.Root{0x12}, + Body: testCapellaBlindedBody(), + }, + }, + { + name: "Deneb", + version: version.DataVersionDeneb, + view: &apiv1deneb.BlindedBeaconBlock{ + Slot: 12345, + ProposerIndex: 42, + ParentRoot: phase0.Root{0x11}, + StateRoot: phase0.Root{0x12}, + Body: testDenebBlindedBody(), + }, + }, + { + name: "Electra", + version: version.DataVersionElectra, + view: &apiv1electra.BlindedBeaconBlock{ + Slot: 12345, + ProposerIndex: 42, + ParentRoot: phase0.Root{0x11}, + StateRoot: phase0.Root{0x12}, + Body: testElectraBlindedBody(), + }, + }, + { + // Fulu reuses the Electra wire schema; the agnostic type must + // accept the Electra view when pinned to the Fulu version. + name: "Fulu", + version: version.DataVersionFulu, + view: &apiv1electra.BlindedBeaconBlock{ + Slot: 12345, + ProposerIndex: 42, + ParentRoot: phase0.Root{0x11}, + StateRoot: phase0.Root{0x12}, + Body: testElectraBlindedBody(), + }, + }, + } +} + +// TestBlindedBeaconBlockJSONWireCompat verifies that the agnostic type +// marshals to byte-identical JSON versus the per-fork type, and that JSON +// round-trips losslessly through the agnostic type. +func TestBlindedBeaconBlockJSONWireCompat(t *testing.T) { + for _, test := range blindedBeaconBlockTests() { + t.Run(test.name, func(t *testing.T) { + expected, err := json.Marshal(test.view) + require.NoError(t, err) + + agnostic := &apiv1all.BlindedBeaconBlock{Version: test.version} + require.NoError(t, agnostic.FromView(test.view)) + require.Equal(t, test.version, agnostic.Version) + + got, err := json.Marshal(agnostic) + require.NoError(t, err) + require.Equal(t, string(expected), string(got), + "agnostic JSON differs from per-fork JSON") + + // Round-trip through UnmarshalJSON with Version pre-set. + rt := &apiv1all.BlindedBeaconBlock{Version: test.version} + require.NoError(t, json.Unmarshal(expected, rt)) + + rtJSON, err := json.Marshal(rt) + require.NoError(t, err) + require.Equal(t, string(expected), string(rtJSON), + "round-tripped JSON differs from per-fork JSON") + + // Version must propagate to nested versionable children. + require.NotNil(t, rt.Body) + require.Equal(t, test.version, rt.Body.Version) + }) + } +} + +// TestBlindedBeaconBlockSSZWireCompat verifies that the agnostic type +// produces byte-identical SSZ and the same hash tree root as the per-fork +// type, and that SSZ round-trips losslessly through the agnostic type. +func TestBlindedBeaconBlockSSZWireCompat(t *testing.T) { + for _, test := range blindedBeaconBlockTests() { + t.Run(test.name, func(t *testing.T) { + codec, ok := test.view.(sszCodec) + require.True(t, ok) + + expected, err := codec.MarshalSSZ() + require.NoError(t, err) + + agnostic := &apiv1all.BlindedBeaconBlock{Version: test.version} + require.NoError(t, agnostic.FromView(test.view)) + + got, err := agnostic.MarshalSSZ() + require.NoError(t, err) + require.Equal(t, expected, got, "agnostic SSZ differs from per-fork SSZ") + + expectedRoot, err := codec.HashTreeRoot() + require.NoError(t, err) + + gotRoot, err := agnostic.HashTreeRoot() + require.NoError(t, err) + require.Equal(t, expectedRoot, gotRoot, + "agnostic hash tree root differs from per-fork root") + + // Round-trip through UnmarshalSSZ with Version pre-set. + rt := &apiv1all.BlindedBeaconBlock{Version: test.version} + require.NoError(t, rt.UnmarshalSSZ(expected)) + + rtSSZ, err := rt.MarshalSSZ() + require.NoError(t, err) + require.Equal(t, expected, rtSSZ, + "round-tripped SSZ differs from per-fork SSZ") + }) + } +} + +// TestBlindedBeaconBlockViewRoundtrip verifies ToView reproduces the +// per-fork view the agnostic instance was built from, and that ToVersioned +// wires the block into api.VersionedBlindedBeaconBlock. +func TestBlindedBeaconBlockViewRoundtrip(t *testing.T) { + for _, test := range blindedBeaconBlockTests() { + t.Run(test.name, func(t *testing.T) { + agnostic := &apiv1all.BlindedBeaconBlock{Version: test.version} + require.NoError(t, agnostic.FromView(test.view)) + + view, err := agnostic.ToView() + require.NoError(t, err) + require.IsType(t, test.view, view) + require.Equal(t, test.view, view) + + versioned, err := agnostic.ToVersioned() + require.NoError(t, err) + require.Equal(t, test.version, versioned.Version) + + rt := &apiv1all.BlindedBeaconBlock{} + require.NoError(t, rt.FromVersioned(versioned)) + require.Equal(t, agnostic, rt) + }) + } +} + +// TestBlindedBeaconBlockBodyWireCompat verifies the standalone agnostic +// blinded body type against the per-fork bodies. +func TestBlindedBeaconBlockBodyWireCompat(t *testing.T) { + tests := []struct { + name string + version version.DataVersion + view any + }{ + {name: "Bellatrix", version: version.DataVersionBellatrix, view: testBellatrixBlindedBody()}, + {name: "Capella", version: version.DataVersionCapella, view: testCapellaBlindedBody()}, + {name: "Deneb", version: version.DataVersionDeneb, view: testDenebBlindedBody()}, + {name: "Electra", version: version.DataVersionElectra, view: testElectraBlindedBody()}, + {name: "Fulu", version: version.DataVersionFulu, view: testElectraBlindedBody()}, + } + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + expected, err := json.Marshal(test.view) + require.NoError(t, err) + + agnostic := &apiv1all.BlindedBeaconBlockBody{Version: test.version} + require.NoError(t, agnostic.FromView(test.view)) + + got, err := json.Marshal(agnostic) + require.NoError(t, err) + require.Equal(t, string(expected), string(got), + "agnostic JSON differs from per-fork JSON") + + view, err := agnostic.ToView() + require.NoError(t, err) + require.IsType(t, test.view, view) + require.Equal(t, test.view, view) + + codec, ok := test.view.(sszCodec) + require.True(t, ok) + + expectedSSZ, err := codec.MarshalSSZ() + require.NoError(t, err) + + gotSSZ, err := agnostic.MarshalSSZ() + require.NoError(t, err) + require.Equal(t, expectedSSZ, gotSSZ, + "agnostic SSZ differs from per-fork SSZ") + + rt := &apiv1all.BlindedBeaconBlockBody{Version: test.version} + require.NoError(t, rt.UnmarshalSSZ(expectedSSZ)) + + rtSSZ, err := rt.MarshalSSZ() + require.NoError(t, err) + require.Equal(t, expectedSSZ, rtSSZ, + "round-tripped SSZ differs from per-fork SSZ") + }) + } +} diff --git a/api/v1/all/blindedbeaconblockbody.go b/api/v1/all/blindedbeaconblockbody.go new file mode 100644 index 00000000..ce4f918f --- /dev/null +++ b/api/v1/all/blindedbeaconblockbody.go @@ -0,0 +1,280 @@ +// Copyright © 2026 Attestant Limited. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package all + +import ( + "errors" + "fmt" + + apiv1bellatrix "github.com/ethpandaops/go-eth2-client/api/v1/bellatrix" + apiv1capella "github.com/ethpandaops/go-eth2-client/api/v1/capella" + apiv1deneb "github.com/ethpandaops/go-eth2-client/api/v1/deneb" + apiv1electra "github.com/ethpandaops/go-eth2-client/api/v1/electra" + specall "github.com/ethpandaops/go-eth2-client/spec/all" + "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/phase0" + "github.com/ethpandaops/go-eth2-client/spec/version" + dynssz "github.com/pk910/dynamic-ssz" + "github.com/pk910/dynamic-ssz/sszutils" +) + +// BlindedBeaconBlockBody is a fork-agnostic blinded beacon block body +// containing the union of fields from every fork. Fields populated on a +// given instance depend on Version. Blinded blocks exist as a wire type +// from Bellatrix up to (excluding) Gloas; other forks are not supported by +// this type. +type BlindedBeaconBlockBody struct { + Version version.DataVersion + RANDAOReveal phase0.BLSSignature + ETH1Data *phase0.ETH1Data + Graffiti [32]byte + ProposerSlashings []*phase0.ProposerSlashing + AttesterSlashings []*specall.AttesterSlashing + Attestations []*specall.Attestation + Deposits []*phase0.Deposit + VoluntaryExits []*phase0.SignedVoluntaryExit + SyncAggregate *altair.SyncAggregate + ExecutionPayloadHeader *specall.ExecutionPayloadHeader + BLSToExecutionChanges []*capella.SignedBLSToExecutionChange + BlobKZGCommitments []deneb.KZGCommitment + ExecutionRequests *specall.ExecutionRequests +} + +// viewType returns the fork-specific schema type pointer used as the view +// descriptor for the active Version. +func (b *BlindedBeaconBlockBody) viewType() (any, error) { + switch b.Version { + case version.DataVersionBellatrix: + return (*apiv1bellatrix.BlindedBeaconBlockBody)(nil), nil + case version.DataVersionCapella: + return (*apiv1capella.BlindedBeaconBlockBody)(nil), nil + case version.DataVersionDeneb: + return (*apiv1deneb.BlindedBeaconBlockBody)(nil), nil + case version.DataVersionElectra, + version.DataVersionFulu: + // Fulu reuses the Electra blinded block-body schema unchanged. + return (*apiv1electra.BlindedBeaconBlockBody)(nil), nil + default: + return nil, fmt.Errorf("BlindedBeaconBlockBody: unsupported version %d", b.Version) + } +} + +// MarshalSSZDyn marshals the blinded block body using the view that matches +// Version. +func (b *BlindedBeaconBlockBody) MarshalSSZDyn(ds sszutils.DynamicSpecs, buf []byte) ([]byte, error) { + view, err := b.viewType() + if err != nil { + return nil, err + } + + m, ok := any(b).(sszutils.DynamicViewMarshaler) + if !ok { + return nil, errors.New("BlindedBeaconBlockBody: generated SSZ code missing") + } + + fn := m.MarshalSSZDynView(view) + if fn == nil { + return nil, fmt.Errorf("BlindedBeaconBlockBody: no view marshaler for version %d", b.Version) + } + + return fn(ds, buf) +} + +// SizeSSZDyn returns the SSZ size of the blinded block body for the active +// Version. +func (b *BlindedBeaconBlockBody) SizeSSZDyn(ds sszutils.DynamicSpecs) int { + view, err := b.viewType() + if err != nil { + return 0 + } + + sz, ok := any(b).(sszutils.DynamicViewSizer) + if !ok { + return 0 + } + + fn := sz.SizeSSZDynView(view) + if fn == nil { + return 0 + } + + return fn(ds) +} + +// UnmarshalSSZDyn decodes the blinded block body into the view that matches +// Version. +func (b *BlindedBeaconBlockBody) UnmarshalSSZDyn(ds sszutils.DynamicSpecs, buf []byte) error { + view, err := b.viewType() + if err != nil { + return err + } + + u, ok := any(b).(sszutils.DynamicViewUnmarshaler) + if !ok { + return errors.New("BlindedBeaconBlockBody: generated SSZ code missing") + } + + fn := u.UnmarshalSSZDynView(view) + if fn == nil { + return fmt.Errorf("BlindedBeaconBlockBody: no view unmarshaler for version %d", b.Version) + } + + if err := fn(ds, buf); err != nil { + return err + } + + b.populateVersion(b.Version) + + return nil +} + +// populateVersion sets Version and propagates it to any nested versionable +// children. +func (b *BlindedBeaconBlockBody) populateVersion(v version.DataVersion) { + propagateVersion(b, v) +} + +// ToView returns a fresh fork-specific BlindedBeaconBlockBody populated with +// b's fields, recursing into nested children via copyByName. +func (b *BlindedBeaconBlockBody) ToView() (any, error) { + return toViewByCopy(b) +} + +// FromView populates b from a fork-specific BlindedBeaconBlockBody. +func (b *BlindedBeaconBlockBody) FromView(view any) error { + v, err := blindedBeaconBlockBodyVersion(view) + if err != nil { + return err + } + + if b.Version == version.DataVersionUnknown { + b.Version = v + } + + if err := copyByName(view, b); err != nil { + return err + } + + b.populateVersion(b.Version) + + return nil +} + +// blindedBeaconBlockBodyVersion maps a BlindedBeaconBlockBody view type to +// its DataVersion. +func blindedBeaconBlockBodyVersion(view any) (version.DataVersion, error) { + switch view.(type) { + case *apiv1bellatrix.BlindedBeaconBlockBody: + return version.DataVersionBellatrix, nil + case *apiv1capella.BlindedBeaconBlockBody: + return version.DataVersionCapella, nil + case *apiv1deneb.BlindedBeaconBlockBody: + return version.DataVersionDeneb, nil + case *apiv1electra.BlindedBeaconBlockBody: + return version.DataVersionElectra, nil + default: + return version.DataVersionUnknown, fmt.Errorf("BlindedBeaconBlockBody: unsupported view type %T", view) + } +} + +// HashTreeRootWithDyn computes the SSZ hash tree root using the active +// Version's view. +func (b *BlindedBeaconBlockBody) HashTreeRootWithDyn(ds sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + view, err := b.viewType() + if err != nil { + return err + } + + h, ok := any(b).(sszutils.DynamicViewHashRoot) + if !ok { + return errors.New("BlindedBeaconBlockBody: generated SSZ code missing") + } + + fn := h.HashTreeRootWithDynView(view) + if fn == nil { + return fmt.Errorf("BlindedBeaconBlockBody: no view hasher for version %d", b.Version) + } + + return fn(ds, hh) +} + +// MarshalSSZ implements the fastssz.Marshaler interface. +func (b *BlindedBeaconBlockBody) MarshalSSZ() ([]byte, error) { + ds := dynssz.GetGlobalDynSsz() + + return b.MarshalSSZDyn(ds, make([]byte, 0, b.SizeSSZDyn(ds))) +} + +// MarshalSSZTo implements the fastssz.Marshaler interface. +func (b *BlindedBeaconBlockBody) MarshalSSZTo(dst []byte) ([]byte, error) { + return b.MarshalSSZDyn(dynssz.GetGlobalDynSsz(), dst) +} + +// UnmarshalSSZ implements the fastssz.Unmarshaler interface. +func (b *BlindedBeaconBlockBody) UnmarshalSSZ(buf []byte) error { + return b.UnmarshalSSZDyn(dynssz.GetGlobalDynSsz(), buf) +} + +// SizeSSZ implements the fastssz.Marshaler interface. +func (b *BlindedBeaconBlockBody) SizeSSZ() int { + return b.SizeSSZDyn(dynssz.GetGlobalDynSsz()) +} + +// HashTreeRoot implements the fastssz.HashRoot interface. +func (b *BlindedBeaconBlockBody) HashTreeRoot() ([32]byte, error) { + return dynssz.GetGlobalDynSsz().HashTreeRoot(b) +} + +// HashTreeRootWith implements the fastssz.HashRoot interface. +func (b *BlindedBeaconBlockBody) HashTreeRootWith(hh sszutils.HashWalker) error { + return b.HashTreeRootWithDyn(dynssz.GetGlobalDynSsz(), hh) +} + +// MarshalJSON delegates to the per-fork BlindedBeaconBlockBody that matches +// Version. +func (b *BlindedBeaconBlockBody) MarshalJSON() ([]byte, error) { + return marshalAsView(b) +} + +// UnmarshalJSON delegates to the per-fork BlindedBeaconBlockBody that +// matches Version. Caller must set Version before calling. +func (b *BlindedBeaconBlockBody) UnmarshalJSON(data []byte) error { + if err := unmarshalAsView(b, data); err != nil { + return err + } + + b.populateVersion(b.Version) + + return nil +} + +// MarshalYAML delegates to the per-fork BlindedBeaconBlockBody that matches +// Version. +func (b *BlindedBeaconBlockBody) MarshalYAML() ([]byte, error) { + return marshalAsViewYAML(b) +} + +// UnmarshalYAML delegates to the per-fork BlindedBeaconBlockBody that +// matches Version. Caller must set Version before calling. +func (b *BlindedBeaconBlockBody) UnmarshalYAML(data []byte) error { + if err := unmarshalAsViewYAML(b, data); err != nil { + return err + } + + b.populateVersion(b.Version) + + return nil +} diff --git a/api/v1/all/blindedbeaconblockbody_ssz.go b/api/v1/all/blindedbeaconblockbody_ssz.go new file mode 100644 index 00000000..08ba41b9 --- /dev/null +++ b/api/v1/all/blindedbeaconblockbody_ssz.go @@ -0,0 +1,6334 @@ +// Code generated by dynamic-ssz. DO NOT EDIT. +// Hash: c19d86f4305ae14e5991545cd35ef87b02cbc90bf0c02ba70356f8d19dccc076 +// Version: v1.3.2 (https://github.com/pk910/dynamic-ssz) +package all + +import ( + "encoding/binary" + "math/bits" + + "github.com/ethpandaops/go-eth2-client/api/v1/bellatrix" + "github.com/ethpandaops/go-eth2-client/api/v1/capella" + "github.com/ethpandaops/go-eth2-client/api/v1/deneb" + "github.com/ethpandaops/go-eth2-client/api/v1/electra" + "github.com/ethpandaops/go-eth2-client/spec/all" + "github.com/ethpandaops/go-eth2-client/spec/altair" + capella1 "github.com/ethpandaops/go-eth2-client/spec/capella" + electra1 "github.com/ethpandaops/go-eth2-client/spec/electra" + "github.com/ethpandaops/go-eth2-client/spec/phase0" + "github.com/holiman/uint256" + "github.com/pk910/dynamic-ssz/hasher" + "github.com/pk910/dynamic-ssz/sszutils" +) + +var _ = sszutils.ErrListTooBig + +var _ = sszutils.Annotate[*bellatrix.BlindedBeaconBlockBody](`ssz-static:"false"`) +var _ = sszutils.Annotate[*capella.BlindedBeaconBlockBody](`ssz-static:"false"`) +var _ = sszutils.Annotate[*deneb.BlindedBeaconBlockBody](`ssz-static:"false"`) +var _ = sszutils.Annotate[*electra.BlindedBeaconBlockBody](`ssz-static:"false"`) + +func (t *BlindedBeaconBlockBody) MarshalSSZDynView(view any) func(ds sszutils.DynamicSpecs, buf []byte) ([]byte, error) { + switch view.(type) { + case *bellatrix.BlindedBeaconBlockBody: + return t.marshalSSZView_BlindedBeaconBlockBody + case *capella.BlindedBeaconBlockBody: + return t.marshalSSZView_BlindedBeaconBlockBody_0 + case *deneb.BlindedBeaconBlockBody: + return t.marshalSSZView_BlindedBeaconBlockBody_1 + case *electra.BlindedBeaconBlockBody: + return t.marshalSSZView_BlindedBeaconBlockBody_2 + } + return nil +} +func (t *BlindedBeaconBlockBody) marshalSSZView_BlindedBeaconBlockBody(ds sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + dst = buf + expr0, err := sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE/8", 64) + if err != nil { + return dst, err + } + expr1, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_PROPOSER_SLASHINGS", 16) + if err != nil { + return dst, err + } + expr2, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_ATTESTER_SLASHINGS", 2) + if err != nil { + return dst, err + } + expr3, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_ATTESTATIONS", 128) + if err != nil { + return dst, err + } + expr4, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_VALIDATORS_PER_COMMITTEE", 2048) + if err != nil { + return dst, err + } + expr5, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_DEPOSITS", 16) + if err != nil { + return dst, err + } + expr6, err := sszutils.ResolveSpecValueWithDefault(ds, "DEPOSIT_CONTRACT_TREE_DEPTH+1", 33) + if err != nil { + return dst, err + } + expr7, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_VOLUNTARY_EXITS", 16) + if err != nil { + return dst, err + } + zeroBytes := sszutils.ZeroBytes() + if t == nil { + t = new(BlindedBeaconBlockBody) + } + dstlen := len(dst) + { // Static Field #0 'RANDAOReveal' + dst = append(dst, t.RANDAOReveal[:96]...) + } + { // Static Field #1 'ETH1Data' + t := t.ETH1Data + if t == nil { + t = new(phase0.ETH1Data) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "ETH1Data") + } + } + { // Static Field #2 'Graffiti' + dst = append(dst, t.Graffiti[:32]...) + } + // Offset Field #3 'ProposerSlashings' + // Offset Field #4 'AttesterSlashings' + // Offset Field #5 'Attestations' + // Offset Field #6 'Deposits' + // Offset Field #7 'VoluntaryExits' + dst = append(dst, zeroBytes[:20]...) + { // Static Field #8 'SyncAggregate' + t := t.SyncAggregate + if t == nil { + t = new(altair.SyncAggregate) + } + { // Static Field #0 'SyncCommitteeBits' + vlen := len(t.SyncCommitteeBits) + if vlen > int(expr0) { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(expr0)), "SyncAggregate.SyncCommitteeBits") + } + dst = append(dst, t.SyncCommitteeBits[:vlen]...) + if vlen < int(expr0) { + dst = sszutils.AppendZeroPadding(dst, (int(expr0)-vlen)*1) + } + } + { // Static Field #1 'SyncCommitteeSignature' + dst = append(dst, t.SyncCommitteeSignature[:96]...) + } + } + // Offset Field #9 'ExecutionPayloadHeader' + offset9 := len(dst) + dst = append(dst, 0, 0, 0, 0) + { // Dynamic Field #3 'ProposerSlashings' + binary.LittleEndian.PutUint32(dst[dstlen+200:], uint32(len(dst)-dstlen)) + t := t.ProposerSlashings + vlen := len(t) + if vlen > int(expr1) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr1)), "ProposerSlashings") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(phase0.ProposerSlashing) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "ProposerSlashings[%d]", idx1) + } + } + } + { // Dynamic Field #4 'AttesterSlashings' + binary.LittleEndian.PutUint32(dst[dstlen+204:], uint32(len(dst)-dstlen)) + t := t.AttesterSlashings + vlen := len(t) + if vlen > int(expr2) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr2)), "AttesterSlashings") + } + dstlen := len(dst) + dst = sszutils.AppendZeroPadding(dst, vlen*4) + for idx1 := range vlen { + binary.LittleEndian.PutUint32(dst[dstlen+(idx1*4):], uint32(len(dst)-dstlen)) + t := t[idx1] + if t == nil { + t = new(all.AttesterSlashing) + } + dstlen := len(dst) + // Offset Field #0 'Attestation1' + // Offset Field #1 'Attestation2' + dst = append(dst, 0, 0, 0, 0, 0, 0, 0, 0) + { // Dynamic Field #0 'Attestation1' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.Attestation1 + if t == nil { + t = new(all.IndexedAttestation) + } + dstlen := len(dst) + // Offset Field #0 'AttestingIndices' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.AttestationData) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "AttesterSlashings[%d].Attestation1.Data", idx1) + } + } + { // Static Field #2 'Signature' + dst = append(dst, t.Signature[:96]...) + } + { // Dynamic Field #0 'AttestingIndices' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.AttestingIndices + vlen := len(t) + if vlen > 2048 { + return nil, sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(vlen, 2048), "AttesterSlashings[%d].Attestation1.AttestingIndices", idx1) + } + dst = sszutils.MarshalUint64Slice(dst, t[:vlen]) + } + } + { // Dynamic Field #1 'Attestation2' + binary.LittleEndian.PutUint32(dst[dstlen+4:], uint32(len(dst)-dstlen)) + t := t.Attestation2 + if t == nil { + t = new(all.IndexedAttestation) + } + dstlen := len(dst) + // Offset Field #0 'AttestingIndices' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.AttestationData) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "AttesterSlashings[%d].Attestation2.Data", idx1) + } + } + { // Static Field #2 'Signature' + dst = append(dst, t.Signature[:96]...) + } + { // Dynamic Field #0 'AttestingIndices' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.AttestingIndices + vlen := len(t) + if vlen > 2048 { + return nil, sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(vlen, 2048), "AttesterSlashings[%d].Attestation2.AttestingIndices", idx1) + } + dst = sszutils.MarshalUint64Slice(dst, t[:vlen]) + } + } + } + } + { // Dynamic Field #5 'Attestations' + binary.LittleEndian.PutUint32(dst[dstlen+208:], uint32(len(dst)-dstlen)) + t := t.Attestations + vlen := len(t) + if vlen > int(expr3) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr3)), "Attestations") + } + dstlen := len(dst) + dst = sszutils.AppendZeroPadding(dst, vlen*4) + for idx1 := range vlen { + binary.LittleEndian.PutUint32(dst[dstlen+(idx1*4):], uint32(len(dst)-dstlen)) + t := t[idx1] + if t == nil { + t = new(all.Attestation) + } + dstlen := len(dst) + // Offset Field #0 'AggregationBits' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.AttestationData) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "Attestations[%d].Data", idx1) + } + } + { // Static Field #2 'Signature' + dst = append(dst, t.Signature[:96]...) + } + { // Dynamic Field #0 'AggregationBits' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.AggregationBits + vlen := len(t) + bval := []byte(t[:]) + if vlen == 0 { + bval = []byte{0x01} + } else if bval[vlen-1] == 0x00 { + return nil, sszutils.ErrorWithPathf(sszutils.ErrBitlistNotTerminatedFn(), "Attestations[%d].AggregationBits", idx1) + } + if vlen > 0 { + bitCount := 8*(vlen-1) + bits.Len8(bval[vlen-1]) - 1 + if bitCount > int(expr4) { + return nil, sszutils.ErrorWithPathf(sszutils.ErrBitlistLengthFn(bitCount, int(expr4)), "Attestations[%d].AggregationBits", idx1) + } + } + dst = append(dst, bval...) + } + } + } + { // Dynamic Field #6 'Deposits' + binary.LittleEndian.PutUint32(dst[dstlen+212:], uint32(len(dst)-dstlen)) + t := t.Deposits + vlen := len(t) + if vlen > int(expr5) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr5)), "Deposits") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(phase0.Deposit) + } + { // Static Field #0 'Proof' + t := t.Proof + vlen := len(t) + if vlen > int(expr6) { + return nil, sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, int(expr6)), "Deposits[%d].Proof", idx1) + } + for idx2 := range vlen { + vlen := len(t[idx2]) + if vlen > 32 { + return nil, sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, 32), "Deposits[%d].Proof[%d]", idx1, idx2) + } + dst = append(dst, t[idx2][:vlen]...) + if vlen < 32 { + dst = sszutils.AppendZeroPadding(dst, (32-vlen)*1) + } + } + if vlen < int(expr6) { + dst = sszutils.AppendZeroPadding(dst, (int(expr6)-vlen)*32) + } + } + { // Static Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.DepositData) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "Deposits[%d].Data", idx1) + } + } + } + } + { // Dynamic Field #7 'VoluntaryExits' + binary.LittleEndian.PutUint32(dst[dstlen+216:], uint32(len(dst)-dstlen)) + t := t.VoluntaryExits + vlen := len(t) + if vlen > int(expr7) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr7)), "VoluntaryExits") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(phase0.SignedVoluntaryExit) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "VoluntaryExits[%d]", idx1) + } + } + } + { // Dynamic Field #9 'ExecutionPayloadHeader' + binary.LittleEndian.PutUint32(dst[offset9:], uint32(len(dst)-dstlen)) + t := t.ExecutionPayloadHeader + if t == nil { + t = new(all.ExecutionPayloadHeader) + } + dstlen := len(dst) + { // Static Field #0 'ParentHash' + dst = append(dst, t.ParentHash[:32]...) + } + { // Static Field #1 'FeeRecipient' + dst = append(dst, t.FeeRecipient[:20]...) + } + { // Static Field #2 'StateRoot' + dst = append(dst, t.StateRoot[:32]...) + } + { // Static Field #3 'ReceiptsRoot' + dst = append(dst, t.ReceiptsRoot[:32]...) + } + { // Static Field #4 'LogsBloom' + dst = append(dst, t.LogsBloom[:256]...) + } + { // Static Field #5 'PrevRandao' + dst = append(dst, t.PrevRandao[:32]...) + } + { // Static Field #6 'BlockNumber' + dst = binary.LittleEndian.AppendUint64(dst, t.BlockNumber) + } + { // Static Field #7 'GasLimit' + dst = binary.LittleEndian.AppendUint64(dst, t.GasLimit) + } + { // Static Field #8 'GasUsed' + dst = binary.LittleEndian.AppendUint64(dst, t.GasUsed) + } + { // Static Field #9 'Timestamp' + dst = binary.LittleEndian.AppendUint64(dst, t.Timestamp) + } + // Offset Field #10 'ExtraData' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #11 'BaseFeePerGasLE' + dst = append(dst, t.BaseFeePerGasLE[:32]...) + } + { // Static Field #12 'BlockHash' + dst = append(dst, t.BlockHash[:32]...) + } + { // Static Field #13 'TransactionsRoot' + dst = append(dst, t.TransactionsRoot[:32]...) + } + { // Dynamic Field #10 'ExtraData' + binary.LittleEndian.PutUint32(dst[dstlen+436:], uint32(len(dst)-dstlen)) + vlen := len(t.ExtraData) + if vlen > 32 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 32), "ExecutionPayloadHeader.ExtraData") + } + dst = append(dst, t.ExtraData[:]...) + } + } + return dst, nil +} + +func (t *BlindedBeaconBlockBody) marshalSSZView_BlindedBeaconBlockBody_0(ds sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + dst = buf + expr0, err := sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE/8", 64) + if err != nil { + return dst, err + } + expr1, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_PROPOSER_SLASHINGS", 16) + if err != nil { + return dst, err + } + expr2, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_ATTESTER_SLASHINGS", 2) + if err != nil { + return dst, err + } + expr3, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_ATTESTATIONS", 128) + if err != nil { + return dst, err + } + expr4, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_VALIDATORS_PER_COMMITTEE", 2048) + if err != nil { + return dst, err + } + expr5, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_DEPOSITS", 16) + if err != nil { + return dst, err + } + expr6, err := sszutils.ResolveSpecValueWithDefault(ds, "DEPOSIT_CONTRACT_TREE_DEPTH+1", 33) + if err != nil { + return dst, err + } + expr7, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_VOLUNTARY_EXITS", 16) + if err != nil { + return dst, err + } + expr8, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BLS_TO_EXECUTION_CHANGES", 16) + if err != nil { + return dst, err + } + zeroBytes := sszutils.ZeroBytes() + if t == nil { + t = new(BlindedBeaconBlockBody) + } + dstlen := len(dst) + { // Static Field #0 'RANDAOReveal' + dst = append(dst, t.RANDAOReveal[:96]...) + } + { // Static Field #1 'ETH1Data' + t := t.ETH1Data + if t == nil { + t = new(phase0.ETH1Data) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "ETH1Data") + } + } + { // Static Field #2 'Graffiti' + dst = append(dst, t.Graffiti[:32]...) + } + // Offset Field #3 'ProposerSlashings' + // Offset Field #4 'AttesterSlashings' + // Offset Field #5 'Attestations' + // Offset Field #6 'Deposits' + // Offset Field #7 'VoluntaryExits' + dst = append(dst, zeroBytes[:20]...) + { // Static Field #8 'SyncAggregate' + t := t.SyncAggregate + if t == nil { + t = new(altair.SyncAggregate) + } + { // Static Field #0 'SyncCommitteeBits' + vlen := len(t.SyncCommitteeBits) + if vlen > int(expr0) { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(expr0)), "SyncAggregate.SyncCommitteeBits") + } + dst = append(dst, t.SyncCommitteeBits[:vlen]...) + if vlen < int(expr0) { + dst = sszutils.AppendZeroPadding(dst, (int(expr0)-vlen)*1) + } + } + { // Static Field #1 'SyncCommitteeSignature' + dst = append(dst, t.SyncCommitteeSignature[:96]...) + } + } + // Offset Field #9 'ExecutionPayloadHeader' + offset9 := len(dst) + // Offset Field #10 'BLSToExecutionChanges' + dst = append(dst, 0, 0, 0, 0, 0, 0, 0, 0) + { // Dynamic Field #3 'ProposerSlashings' + binary.LittleEndian.PutUint32(dst[dstlen+200:], uint32(len(dst)-dstlen)) + t := t.ProposerSlashings + vlen := len(t) + if vlen > int(expr1) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr1)), "ProposerSlashings") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(phase0.ProposerSlashing) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "ProposerSlashings[%d]", idx1) + } + } + } + { // Dynamic Field #4 'AttesterSlashings' + binary.LittleEndian.PutUint32(dst[dstlen+204:], uint32(len(dst)-dstlen)) + t := t.AttesterSlashings + vlen := len(t) + if vlen > int(expr2) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr2)), "AttesterSlashings") + } + dstlen := len(dst) + dst = sszutils.AppendZeroPadding(dst, vlen*4) + for idx1 := range vlen { + binary.LittleEndian.PutUint32(dst[dstlen+(idx1*4):], uint32(len(dst)-dstlen)) + t := t[idx1] + if t == nil { + t = new(all.AttesterSlashing) + } + dstlen := len(dst) + // Offset Field #0 'Attestation1' + // Offset Field #1 'Attestation2' + dst = append(dst, 0, 0, 0, 0, 0, 0, 0, 0) + { // Dynamic Field #0 'Attestation1' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.Attestation1 + if t == nil { + t = new(all.IndexedAttestation) + } + dstlen := len(dst) + // Offset Field #0 'AttestingIndices' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.AttestationData) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "AttesterSlashings[%d].Attestation1.Data", idx1) + } + } + { // Static Field #2 'Signature' + dst = append(dst, t.Signature[:96]...) + } + { // Dynamic Field #0 'AttestingIndices' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.AttestingIndices + vlen := len(t) + if vlen > 2048 { + return nil, sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(vlen, 2048), "AttesterSlashings[%d].Attestation1.AttestingIndices", idx1) + } + dst = sszutils.MarshalUint64Slice(dst, t[:vlen]) + } + } + { // Dynamic Field #1 'Attestation2' + binary.LittleEndian.PutUint32(dst[dstlen+4:], uint32(len(dst)-dstlen)) + t := t.Attestation2 + if t == nil { + t = new(all.IndexedAttestation) + } + dstlen := len(dst) + // Offset Field #0 'AttestingIndices' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.AttestationData) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "AttesterSlashings[%d].Attestation2.Data", idx1) + } + } + { // Static Field #2 'Signature' + dst = append(dst, t.Signature[:96]...) + } + { // Dynamic Field #0 'AttestingIndices' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.AttestingIndices + vlen := len(t) + if vlen > 2048 { + return nil, sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(vlen, 2048), "AttesterSlashings[%d].Attestation2.AttestingIndices", idx1) + } + dst = sszutils.MarshalUint64Slice(dst, t[:vlen]) + } + } + } + } + { // Dynamic Field #5 'Attestations' + binary.LittleEndian.PutUint32(dst[dstlen+208:], uint32(len(dst)-dstlen)) + t := t.Attestations + vlen := len(t) + if vlen > int(expr3) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr3)), "Attestations") + } + dstlen := len(dst) + dst = sszutils.AppendZeroPadding(dst, vlen*4) + for idx1 := range vlen { + binary.LittleEndian.PutUint32(dst[dstlen+(idx1*4):], uint32(len(dst)-dstlen)) + t := t[idx1] + if t == nil { + t = new(all.Attestation) + } + dstlen := len(dst) + // Offset Field #0 'AggregationBits' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.AttestationData) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "Attestations[%d].Data", idx1) + } + } + { // Static Field #2 'Signature' + dst = append(dst, t.Signature[:96]...) + } + { // Dynamic Field #0 'AggregationBits' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.AggregationBits + vlen := len(t) + bval := []byte(t[:]) + if vlen == 0 { + bval = []byte{0x01} + } else if bval[vlen-1] == 0x00 { + return nil, sszutils.ErrorWithPathf(sszutils.ErrBitlistNotTerminatedFn(), "Attestations[%d].AggregationBits", idx1) + } + if vlen > 0 { + bitCount := 8*(vlen-1) + bits.Len8(bval[vlen-1]) - 1 + if bitCount > int(expr4) { + return nil, sszutils.ErrorWithPathf(sszutils.ErrBitlistLengthFn(bitCount, int(expr4)), "Attestations[%d].AggregationBits", idx1) + } + } + dst = append(dst, bval...) + } + } + } + { // Dynamic Field #6 'Deposits' + binary.LittleEndian.PutUint32(dst[dstlen+212:], uint32(len(dst)-dstlen)) + t := t.Deposits + vlen := len(t) + if vlen > int(expr5) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr5)), "Deposits") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(phase0.Deposit) + } + { // Static Field #0 'Proof' + t := t.Proof + vlen := len(t) + if vlen > int(expr6) { + return nil, sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, int(expr6)), "Deposits[%d].Proof", idx1) + } + for idx2 := range vlen { + vlen := len(t[idx2]) + if vlen > 32 { + return nil, sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, 32), "Deposits[%d].Proof[%d]", idx1, idx2) + } + dst = append(dst, t[idx2][:vlen]...) + if vlen < 32 { + dst = sszutils.AppendZeroPadding(dst, (32-vlen)*1) + } + } + if vlen < int(expr6) { + dst = sszutils.AppendZeroPadding(dst, (int(expr6)-vlen)*32) + } + } + { // Static Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.DepositData) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "Deposits[%d].Data", idx1) + } + } + } + } + { // Dynamic Field #7 'VoluntaryExits' + binary.LittleEndian.PutUint32(dst[dstlen+216:], uint32(len(dst)-dstlen)) + t := t.VoluntaryExits + vlen := len(t) + if vlen > int(expr7) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr7)), "VoluntaryExits") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(phase0.SignedVoluntaryExit) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "VoluntaryExits[%d]", idx1) + } + } + } + { // Dynamic Field #9 'ExecutionPayloadHeader' + binary.LittleEndian.PutUint32(dst[offset9:], uint32(len(dst)-dstlen)) + t := t.ExecutionPayloadHeader + if t == nil { + t = new(all.ExecutionPayloadHeader) + } + dstlen := len(dst) + { // Static Field #0 'ParentHash' + dst = append(dst, t.ParentHash[:32]...) + } + { // Static Field #1 'FeeRecipient' + dst = append(dst, t.FeeRecipient[:20]...) + } + { // Static Field #2 'StateRoot' + dst = append(dst, t.StateRoot[:32]...) + } + { // Static Field #3 'ReceiptsRoot' + dst = append(dst, t.ReceiptsRoot[:32]...) + } + { // Static Field #4 'LogsBloom' + dst = append(dst, t.LogsBloom[:256]...) + } + { // Static Field #5 'PrevRandao' + dst = append(dst, t.PrevRandao[:32]...) + } + { // Static Field #6 'BlockNumber' + dst = binary.LittleEndian.AppendUint64(dst, t.BlockNumber) + } + { // Static Field #7 'GasLimit' + dst = binary.LittleEndian.AppendUint64(dst, t.GasLimit) + } + { // Static Field #8 'GasUsed' + dst = binary.LittleEndian.AppendUint64(dst, t.GasUsed) + } + { // Static Field #9 'Timestamp' + dst = binary.LittleEndian.AppendUint64(dst, t.Timestamp) + } + // Offset Field #10 'ExtraData' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #11 'BaseFeePerGasLE' + dst = append(dst, t.BaseFeePerGasLE[:32]...) + } + { // Static Field #12 'BlockHash' + dst = append(dst, t.BlockHash[:32]...) + } + { // Static Field #13 'TransactionsRoot' + dst = append(dst, t.TransactionsRoot[:32]...) + } + { // Static Field #14 'WithdrawalsRoot' + dst = append(dst, t.WithdrawalsRoot[:32]...) + } + { // Dynamic Field #10 'ExtraData' + binary.LittleEndian.PutUint32(dst[dstlen+436:], uint32(len(dst)-dstlen)) + vlen := len(t.ExtraData) + if vlen > 32 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 32), "ExecutionPayloadHeader.ExtraData") + } + dst = append(dst, t.ExtraData[:]...) + } + } + { // Dynamic Field #10 'BLSToExecutionChanges' + binary.LittleEndian.PutUint32(dst[offset9+4:], uint32(len(dst)-dstlen)) + t := t.BLSToExecutionChanges + vlen := len(t) + if vlen > int(expr8) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr8)), "BLSToExecutionChanges") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(capella1.SignedBLSToExecutionChange) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "BLSToExecutionChanges[%d]", idx1) + } + } + } + return dst, nil +} + +func (t *BlindedBeaconBlockBody) marshalSSZView_BlindedBeaconBlockBody_1(ds sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + dst = buf + expr0, err := sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE/8", 64) + if err != nil { + return dst, err + } + expr1, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_PROPOSER_SLASHINGS", 16) + if err != nil { + return dst, err + } + expr2, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_ATTESTER_SLASHINGS", 2) + if err != nil { + return dst, err + } + expr3, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_ATTESTATIONS", 128) + if err != nil { + return dst, err + } + expr4, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_VALIDATORS_PER_COMMITTEE", 2048) + if err != nil { + return dst, err + } + expr5, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_DEPOSITS", 16) + if err != nil { + return dst, err + } + expr6, err := sszutils.ResolveSpecValueWithDefault(ds, "DEPOSIT_CONTRACT_TREE_DEPTH+1", 33) + if err != nil { + return dst, err + } + expr7, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_VOLUNTARY_EXITS", 16) + if err != nil { + return dst, err + } + expr8, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BLS_TO_EXECUTION_CHANGES", 16) + if err != nil { + return dst, err + } + expr9, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BLOB_COMMITMENTS_PER_BLOCK", 4096) + if err != nil { + return dst, err + } + zeroBytes := sszutils.ZeroBytes() + if t == nil { + t = new(BlindedBeaconBlockBody) + } + dstlen := len(dst) + { // Static Field #0 'RANDAOReveal' + dst = append(dst, t.RANDAOReveal[:96]...) + } + { // Static Field #1 'ETH1Data' + t := t.ETH1Data + if t == nil { + t = new(phase0.ETH1Data) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "ETH1Data") + } + } + { // Static Field #2 'Graffiti' + dst = append(dst, t.Graffiti[:32]...) + } + // Offset Field #3 'ProposerSlashings' + // Offset Field #4 'AttesterSlashings' + // Offset Field #5 'Attestations' + // Offset Field #6 'Deposits' + // Offset Field #7 'VoluntaryExits' + dst = append(dst, zeroBytes[:20]...) + { // Static Field #8 'SyncAggregate' + t := t.SyncAggregate + if t == nil { + t = new(altair.SyncAggregate) + } + { // Static Field #0 'SyncCommitteeBits' + vlen := len(t.SyncCommitteeBits) + if vlen > int(expr0) { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(expr0)), "SyncAggregate.SyncCommitteeBits") + } + dst = append(dst, t.SyncCommitteeBits[:vlen]...) + if vlen < int(expr0) { + dst = sszutils.AppendZeroPadding(dst, (int(expr0)-vlen)*1) + } + } + { // Static Field #1 'SyncCommitteeSignature' + dst = append(dst, t.SyncCommitteeSignature[:96]...) + } + } + // Offset Field #9 'ExecutionPayloadHeader' + offset9 := len(dst) + // Offset Field #10 'BLSToExecutionChanges' + // Offset Field #11 'BlobKZGCommitments' + dst = append(dst, zeroBytes[:12]...) + { // Dynamic Field #3 'ProposerSlashings' + binary.LittleEndian.PutUint32(dst[dstlen+200:], uint32(len(dst)-dstlen)) + t := t.ProposerSlashings + vlen := len(t) + if vlen > int(expr1) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr1)), "ProposerSlashings") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(phase0.ProposerSlashing) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "ProposerSlashings[%d]", idx1) + } + } + } + { // Dynamic Field #4 'AttesterSlashings' + binary.LittleEndian.PutUint32(dst[dstlen+204:], uint32(len(dst)-dstlen)) + t := t.AttesterSlashings + vlen := len(t) + if vlen > int(expr2) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr2)), "AttesterSlashings") + } + dstlen := len(dst) + dst = sszutils.AppendZeroPadding(dst, vlen*4) + for idx1 := range vlen { + binary.LittleEndian.PutUint32(dst[dstlen+(idx1*4):], uint32(len(dst)-dstlen)) + t := t[idx1] + if t == nil { + t = new(all.AttesterSlashing) + } + dstlen := len(dst) + // Offset Field #0 'Attestation1' + // Offset Field #1 'Attestation2' + dst = append(dst, 0, 0, 0, 0, 0, 0, 0, 0) + { // Dynamic Field #0 'Attestation1' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.Attestation1 + if t == nil { + t = new(all.IndexedAttestation) + } + dstlen := len(dst) + // Offset Field #0 'AttestingIndices' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.AttestationData) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "AttesterSlashings[%d].Attestation1.Data", idx1) + } + } + { // Static Field #2 'Signature' + dst = append(dst, t.Signature[:96]...) + } + { // Dynamic Field #0 'AttestingIndices' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.AttestingIndices + vlen := len(t) + if vlen > 2048 { + return nil, sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(vlen, 2048), "AttesterSlashings[%d].Attestation1.AttestingIndices", idx1) + } + dst = sszutils.MarshalUint64Slice(dst, t[:vlen]) + } + } + { // Dynamic Field #1 'Attestation2' + binary.LittleEndian.PutUint32(dst[dstlen+4:], uint32(len(dst)-dstlen)) + t := t.Attestation2 + if t == nil { + t = new(all.IndexedAttestation) + } + dstlen := len(dst) + // Offset Field #0 'AttestingIndices' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.AttestationData) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "AttesterSlashings[%d].Attestation2.Data", idx1) + } + } + { // Static Field #2 'Signature' + dst = append(dst, t.Signature[:96]...) + } + { // Dynamic Field #0 'AttestingIndices' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.AttestingIndices + vlen := len(t) + if vlen > 2048 { + return nil, sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(vlen, 2048), "AttesterSlashings[%d].Attestation2.AttestingIndices", idx1) + } + dst = sszutils.MarshalUint64Slice(dst, t[:vlen]) + } + } + } + } + { // Dynamic Field #5 'Attestations' + binary.LittleEndian.PutUint32(dst[dstlen+208:], uint32(len(dst)-dstlen)) + t := t.Attestations + vlen := len(t) + if vlen > int(expr3) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr3)), "Attestations") + } + dstlen := len(dst) + dst = sszutils.AppendZeroPadding(dst, vlen*4) + for idx1 := range vlen { + binary.LittleEndian.PutUint32(dst[dstlen+(idx1*4):], uint32(len(dst)-dstlen)) + t := t[idx1] + if t == nil { + t = new(all.Attestation) + } + dstlen := len(dst) + // Offset Field #0 'AggregationBits' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.AttestationData) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "Attestations[%d].Data", idx1) + } + } + { // Static Field #2 'Signature' + dst = append(dst, t.Signature[:96]...) + } + { // Dynamic Field #0 'AggregationBits' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.AggregationBits + vlen := len(t) + bval := []byte(t[:]) + if vlen == 0 { + bval = []byte{0x01} + } else if bval[vlen-1] == 0x00 { + return nil, sszutils.ErrorWithPathf(sszutils.ErrBitlistNotTerminatedFn(), "Attestations[%d].AggregationBits", idx1) + } + if vlen > 0 { + bitCount := 8*(vlen-1) + bits.Len8(bval[vlen-1]) - 1 + if bitCount > int(expr4) { + return nil, sszutils.ErrorWithPathf(sszutils.ErrBitlistLengthFn(bitCount, int(expr4)), "Attestations[%d].AggregationBits", idx1) + } + } + dst = append(dst, bval...) + } + } + } + { // Dynamic Field #6 'Deposits' + binary.LittleEndian.PutUint32(dst[dstlen+212:], uint32(len(dst)-dstlen)) + t := t.Deposits + vlen := len(t) + if vlen > int(expr5) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr5)), "Deposits") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(phase0.Deposit) + } + { // Static Field #0 'Proof' + t := t.Proof + vlen := len(t) + if vlen > int(expr6) { + return nil, sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, int(expr6)), "Deposits[%d].Proof", idx1) + } + for idx2 := range vlen { + vlen := len(t[idx2]) + if vlen > 32 { + return nil, sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, 32), "Deposits[%d].Proof[%d]", idx1, idx2) + } + dst = append(dst, t[idx2][:vlen]...) + if vlen < 32 { + dst = sszutils.AppendZeroPadding(dst, (32-vlen)*1) + } + } + if vlen < int(expr6) { + dst = sszutils.AppendZeroPadding(dst, (int(expr6)-vlen)*32) + } + } + { // Static Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.DepositData) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "Deposits[%d].Data", idx1) + } + } + } + } + { // Dynamic Field #7 'VoluntaryExits' + binary.LittleEndian.PutUint32(dst[dstlen+216:], uint32(len(dst)-dstlen)) + t := t.VoluntaryExits + vlen := len(t) + if vlen > int(expr7) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr7)), "VoluntaryExits") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(phase0.SignedVoluntaryExit) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "VoluntaryExits[%d]", idx1) + } + } + } + { // Dynamic Field #9 'ExecutionPayloadHeader' + binary.LittleEndian.PutUint32(dst[offset9:], uint32(len(dst)-dstlen)) + t := t.ExecutionPayloadHeader + if t == nil { + t = new(all.ExecutionPayloadHeader) + } + dstlen := len(dst) + { // Static Field #0 'ParentHash' + dst = append(dst, t.ParentHash[:32]...) + } + { // Static Field #1 'FeeRecipient' + dst = append(dst, t.FeeRecipient[:20]...) + } + { // Static Field #2 'StateRoot' + dst = append(dst, t.StateRoot[:32]...) + } + { // Static Field #3 'ReceiptsRoot' + dst = append(dst, t.ReceiptsRoot[:32]...) + } + { // Static Field #4 'LogsBloom' + dst = append(dst, t.LogsBloom[:256]...) + } + { // Static Field #5 'PrevRandao' + dst = append(dst, t.PrevRandao[:32]...) + } + { // Static Field #6 'BlockNumber' + dst = binary.LittleEndian.AppendUint64(dst, t.BlockNumber) + } + { // Static Field #7 'GasLimit' + dst = binary.LittleEndian.AppendUint64(dst, t.GasLimit) + } + { // Static Field #8 'GasUsed' + dst = binary.LittleEndian.AppendUint64(dst, t.GasUsed) + } + { // Static Field #9 'Timestamp' + dst = binary.LittleEndian.AppendUint64(dst, t.Timestamp) + } + // Offset Field #10 'ExtraData' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #11 'BaseFeePerGas' + t := t.BaseFeePerGas + if t == nil { + t = new(uint256.Int) + } + dst = sszutils.MarshalUint64Slice(dst, (*t)[:4]) + } + { // Static Field #12 'BlockHash' + dst = append(dst, t.BlockHash[:32]...) + } + { // Static Field #13 'TransactionsRoot' + dst = append(dst, t.TransactionsRoot[:32]...) + } + { // Static Field #14 'WithdrawalsRoot' + dst = append(dst, t.WithdrawalsRoot[:32]...) + } + { // Static Field #15 'BlobGasUsed' + dst = binary.LittleEndian.AppendUint64(dst, t.BlobGasUsed) + } + { // Static Field #16 'ExcessBlobGas' + dst = binary.LittleEndian.AppendUint64(dst, t.ExcessBlobGas) + } + { // Dynamic Field #10 'ExtraData' + binary.LittleEndian.PutUint32(dst[dstlen+436:], uint32(len(dst)-dstlen)) + vlen := len(t.ExtraData) + if vlen > 32 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 32), "ExecutionPayloadHeader.ExtraData") + } + dst = append(dst, t.ExtraData[:]...) + } + } + { // Dynamic Field #10 'BLSToExecutionChanges' + binary.LittleEndian.PutUint32(dst[offset9+4:], uint32(len(dst)-dstlen)) + t := t.BLSToExecutionChanges + vlen := len(t) + if vlen > int(expr8) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr8)), "BLSToExecutionChanges") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(capella1.SignedBLSToExecutionChange) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "BLSToExecutionChanges[%d]", idx1) + } + } + } + { // Dynamic Field #11 'BlobKZGCommitments' + binary.LittleEndian.PutUint32(dst[offset9+8:], uint32(len(dst)-dstlen)) + t := t.BlobKZGCommitments + vlen := len(t) + if vlen > int(expr9) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr9)), "BlobKZGCommitments") + } + dst = sszutils.MarshalFixedBytesSlice(dst, t[:vlen]) + } + return dst, nil +} + +func (t *BlindedBeaconBlockBody) marshalSSZView_BlindedBeaconBlockBody_2(ds sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + dst = buf + expr0, err := sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE/8", 64) + if err != nil { + return dst, err + } + expr1, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_PROPOSER_SLASHINGS", 16) + if err != nil { + return dst, err + } + expr2, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_ATTESTER_SLASHINGS_ELECTRA", 1) + if err != nil { + return dst, err + } + expr3, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_VALIDATORS_PER_COMMITTEE*MAX_COMMITTEES_PER_SLOT", 131072) + if err != nil { + return dst, err + } + expr4, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_ATTESTATIONS_ELECTRA", 8) + if err != nil { + return dst, err + } + expr5, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_COMMITTEES_PER_SLOT/8", 8) + if err != nil { + return dst, err + } + expr6, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_DEPOSITS", 16) + if err != nil { + return dst, err + } + expr7, err := sszutils.ResolveSpecValueWithDefault(ds, "DEPOSIT_CONTRACT_TREE_DEPTH+1", 33) + if err != nil { + return dst, err + } + expr8, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_VOLUNTARY_EXITS", 16) + if err != nil { + return dst, err + } + expr9, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BLS_TO_EXECUTION_CHANGES", 16) + if err != nil { + return dst, err + } + expr10, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BLOB_COMMITMENTS_PER_BLOCK", 4096) + if err != nil { + return dst, err + } + expr11, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_DEPOSIT_REQUESTS_PER_PAYLOAD", 8192) + if err != nil { + return dst, err + } + expr12, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_WITHDRAWAL_REQUESTS_PER_PAYLOAD", 16) + if err != nil { + return dst, err + } + expr13, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD", 2) + if err != nil { + return dst, err + } + zeroBytes := sszutils.ZeroBytes() + if t == nil { + t = new(BlindedBeaconBlockBody) + } + dstlen := len(dst) + { // Static Field #0 'RANDAOReveal' + dst = append(dst, t.RANDAOReveal[:96]...) + } + { // Static Field #1 'ETH1Data' + t := t.ETH1Data + if t == nil { + t = new(phase0.ETH1Data) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "ETH1Data") + } + } + { // Static Field #2 'Graffiti' + dst = append(dst, t.Graffiti[:32]...) + } + // Offset Field #3 'ProposerSlashings' + // Offset Field #4 'AttesterSlashings' + // Offset Field #5 'Attestations' + // Offset Field #6 'Deposits' + // Offset Field #7 'VoluntaryExits' + dst = append(dst, zeroBytes[:20]...) + { // Static Field #8 'SyncAggregate' + t := t.SyncAggregate + if t == nil { + t = new(altair.SyncAggregate) + } + { // Static Field #0 'SyncCommitteeBits' + vlen := len(t.SyncCommitteeBits) + if vlen > int(expr0) { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(expr0)), "SyncAggregate.SyncCommitteeBits") + } + dst = append(dst, t.SyncCommitteeBits[:vlen]...) + if vlen < int(expr0) { + dst = sszutils.AppendZeroPadding(dst, (int(expr0)-vlen)*1) + } + } + { // Static Field #1 'SyncCommitteeSignature' + dst = append(dst, t.SyncCommitteeSignature[:96]...) + } + } + // Offset Field #9 'ExecutionPayloadHeader' + offset9 := len(dst) + // Offset Field #10 'BLSToExecutionChanges' + // Offset Field #11 'BlobKZGCommitments' + // Offset Field #12 'ExecutionRequests' + dst = append(dst, zeroBytes[:16]...) + { // Dynamic Field #3 'ProposerSlashings' + binary.LittleEndian.PutUint32(dst[dstlen+200:], uint32(len(dst)-dstlen)) + t := t.ProposerSlashings + vlen := len(t) + if vlen > int(expr1) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr1)), "ProposerSlashings") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(phase0.ProposerSlashing) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "ProposerSlashings[%d]", idx1) + } + } + } + { // Dynamic Field #4 'AttesterSlashings' + binary.LittleEndian.PutUint32(dst[dstlen+204:], uint32(len(dst)-dstlen)) + t := t.AttesterSlashings + vlen := len(t) + if vlen > int(expr2) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr2)), "AttesterSlashings") + } + dstlen := len(dst) + dst = sszutils.AppendZeroPadding(dst, vlen*4) + for idx1 := range vlen { + binary.LittleEndian.PutUint32(dst[dstlen+(idx1*4):], uint32(len(dst)-dstlen)) + t := t[idx1] + if t == nil { + t = new(all.AttesterSlashing) + } + dstlen := len(dst) + // Offset Field #0 'Attestation1' + // Offset Field #1 'Attestation2' + dst = append(dst, 0, 0, 0, 0, 0, 0, 0, 0) + { // Dynamic Field #0 'Attestation1' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.Attestation1 + if t == nil { + t = new(all.IndexedAttestation) + } + dstlen := len(dst) + // Offset Field #0 'AttestingIndices' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.AttestationData) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "AttesterSlashings[%d].Attestation1.Data", idx1) + } + } + { // Static Field #2 'Signature' + dst = append(dst, t.Signature[:96]...) + } + { // Dynamic Field #0 'AttestingIndices' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.AttestingIndices + vlen := len(t) + if vlen > int(expr3) { + return nil, sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(vlen, int(expr3)), "AttesterSlashings[%d].Attestation1.AttestingIndices", idx1) + } + dst = sszutils.MarshalUint64Slice(dst, t[:vlen]) + } + } + { // Dynamic Field #1 'Attestation2' + binary.LittleEndian.PutUint32(dst[dstlen+4:], uint32(len(dst)-dstlen)) + t := t.Attestation2 + if t == nil { + t = new(all.IndexedAttestation) + } + dstlen := len(dst) + // Offset Field #0 'AttestingIndices' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.AttestationData) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "AttesterSlashings[%d].Attestation2.Data", idx1) + } + } + { // Static Field #2 'Signature' + dst = append(dst, t.Signature[:96]...) + } + { // Dynamic Field #0 'AttestingIndices' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.AttestingIndices + vlen := len(t) + if vlen > int(expr3) { + return nil, sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(vlen, int(expr3)), "AttesterSlashings[%d].Attestation2.AttestingIndices", idx1) + } + dst = sszutils.MarshalUint64Slice(dst, t[:vlen]) + } + } + } + } + { // Dynamic Field #5 'Attestations' + binary.LittleEndian.PutUint32(dst[dstlen+208:], uint32(len(dst)-dstlen)) + t := t.Attestations + vlen := len(t) + if vlen > int(expr4) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr4)), "Attestations") + } + dstlen := len(dst) + dst = sszutils.AppendZeroPadding(dst, vlen*4) + for idx1 := range vlen { + binary.LittleEndian.PutUint32(dst[dstlen+(idx1*4):], uint32(len(dst)-dstlen)) + t := t[idx1] + if t == nil { + t = new(all.Attestation) + } + dstlen := len(dst) + // Offset Field #0 'AggregationBits' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.AttestationData) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "Attestations[%d].Data", idx1) + } + } + { // Static Field #2 'Signature' + dst = append(dst, t.Signature[:96]...) + } + { // Static Field #3 'CommitteeBits' + vlen := len(t.CommitteeBits) + if vlen > int(expr5) { + return nil, sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, int(expr5)), "Attestations[%d].CommitteeBits", idx1) + } + dst = append(dst, t.CommitteeBits[:vlen]...) + if vlen < int(expr5) { + dst = sszutils.AppendZeroPadding(dst, (int(expr5)-vlen)*1) + } + } + { // Dynamic Field #0 'AggregationBits' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.AggregationBits + vlen := len(t) + bval := []byte(t[:]) + if vlen == 0 { + bval = []byte{0x01} + } else if bval[vlen-1] == 0x00 { + return nil, sszutils.ErrorWithPathf(sszutils.ErrBitlistNotTerminatedFn(), "Attestations[%d].AggregationBits", idx1) + } + if vlen > 0 { + bitCount := 8*(vlen-1) + bits.Len8(bval[vlen-1]) - 1 + if bitCount > int(expr3) { + return nil, sszutils.ErrorWithPathf(sszutils.ErrBitlistLengthFn(bitCount, int(expr3)), "Attestations[%d].AggregationBits", idx1) + } + } + dst = append(dst, bval...) + } + } + } + { // Dynamic Field #6 'Deposits' + binary.LittleEndian.PutUint32(dst[dstlen+212:], uint32(len(dst)-dstlen)) + t := t.Deposits + vlen := len(t) + if vlen > int(expr6) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr6)), "Deposits") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(phase0.Deposit) + } + { // Static Field #0 'Proof' + t := t.Proof + vlen := len(t) + if vlen > int(expr7) { + return nil, sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, int(expr7)), "Deposits[%d].Proof", idx1) + } + for idx2 := range vlen { + vlen := len(t[idx2]) + if vlen > 32 { + return nil, sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, 32), "Deposits[%d].Proof[%d]", idx1, idx2) + } + dst = append(dst, t[idx2][:vlen]...) + if vlen < 32 { + dst = sszutils.AppendZeroPadding(dst, (32-vlen)*1) + } + } + if vlen < int(expr7) { + dst = sszutils.AppendZeroPadding(dst, (int(expr7)-vlen)*32) + } + } + { // Static Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.DepositData) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "Deposits[%d].Data", idx1) + } + } + } + } + { // Dynamic Field #7 'VoluntaryExits' + binary.LittleEndian.PutUint32(dst[dstlen+216:], uint32(len(dst)-dstlen)) + t := t.VoluntaryExits + vlen := len(t) + if vlen > int(expr8) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr8)), "VoluntaryExits") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(phase0.SignedVoluntaryExit) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "VoluntaryExits[%d]", idx1) + } + } + } + { // Dynamic Field #9 'ExecutionPayloadHeader' + binary.LittleEndian.PutUint32(dst[offset9:], uint32(len(dst)-dstlen)) + t := t.ExecutionPayloadHeader + if t == nil { + t = new(all.ExecutionPayloadHeader) + } + dstlen := len(dst) + { // Static Field #0 'ParentHash' + dst = append(dst, t.ParentHash[:32]...) + } + { // Static Field #1 'FeeRecipient' + dst = append(dst, t.FeeRecipient[:20]...) + } + { // Static Field #2 'StateRoot' + dst = append(dst, t.StateRoot[:32]...) + } + { // Static Field #3 'ReceiptsRoot' + dst = append(dst, t.ReceiptsRoot[:32]...) + } + { // Static Field #4 'LogsBloom' + dst = append(dst, t.LogsBloom[:256]...) + } + { // Static Field #5 'PrevRandao' + dst = append(dst, t.PrevRandao[:32]...) + } + { // Static Field #6 'BlockNumber' + dst = binary.LittleEndian.AppendUint64(dst, t.BlockNumber) + } + { // Static Field #7 'GasLimit' + dst = binary.LittleEndian.AppendUint64(dst, t.GasLimit) + } + { // Static Field #8 'GasUsed' + dst = binary.LittleEndian.AppendUint64(dst, t.GasUsed) + } + { // Static Field #9 'Timestamp' + dst = binary.LittleEndian.AppendUint64(dst, t.Timestamp) + } + // Offset Field #10 'ExtraData' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #11 'BaseFeePerGas' + t := t.BaseFeePerGas + if t == nil { + t = new(uint256.Int) + } + dst = sszutils.MarshalUint64Slice(dst, (*t)[:4]) + } + { // Static Field #12 'BlockHash' + dst = append(dst, t.BlockHash[:32]...) + } + { // Static Field #13 'TransactionsRoot' + dst = append(dst, t.TransactionsRoot[:32]...) + } + { // Static Field #14 'WithdrawalsRoot' + dst = append(dst, t.WithdrawalsRoot[:32]...) + } + { // Static Field #15 'BlobGasUsed' + dst = binary.LittleEndian.AppendUint64(dst, t.BlobGasUsed) + } + { // Static Field #16 'ExcessBlobGas' + dst = binary.LittleEndian.AppendUint64(dst, t.ExcessBlobGas) + } + { // Dynamic Field #10 'ExtraData' + binary.LittleEndian.PutUint32(dst[dstlen+436:], uint32(len(dst)-dstlen)) + vlen := len(t.ExtraData) + if vlen > 32 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 32), "ExecutionPayloadHeader.ExtraData") + } + dst = append(dst, t.ExtraData[:]...) + } + } + { // Dynamic Field #10 'BLSToExecutionChanges' + binary.LittleEndian.PutUint32(dst[offset9+4:], uint32(len(dst)-dstlen)) + t := t.BLSToExecutionChanges + vlen := len(t) + if vlen > int(expr9) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr9)), "BLSToExecutionChanges") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(capella1.SignedBLSToExecutionChange) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "BLSToExecutionChanges[%d]", idx1) + } + } + } + { // Dynamic Field #11 'BlobKZGCommitments' + binary.LittleEndian.PutUint32(dst[offset9+8:], uint32(len(dst)-dstlen)) + t := t.BlobKZGCommitments + vlen := len(t) + if vlen > int(expr10) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr10)), "BlobKZGCommitments") + } + dst = sszutils.MarshalFixedBytesSlice(dst, t[:vlen]) + } + { // Dynamic Field #12 'ExecutionRequests' + binary.LittleEndian.PutUint32(dst[offset9+12:], uint32(len(dst)-dstlen)) + t := t.ExecutionRequests + if t == nil { + t = new(all.ExecutionRequests) + } + dstlen := len(dst) + // Offset Field #0 'Deposits' + // Offset Field #1 'Withdrawals' + // Offset Field #2 'Consolidations' + dst = append(dst, zeroBytes[:12]...) + { // Dynamic Field #0 'Deposits' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.Deposits + vlen := len(t) + if vlen > int(expr11) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr11)), "ExecutionRequests.Deposits") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(electra1.DepositRequest) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "ExecutionRequests.Deposits[%d]", idx1) + } + } + } + { // Dynamic Field #1 'Withdrawals' + binary.LittleEndian.PutUint32(dst[dstlen+4:], uint32(len(dst)-dstlen)) + t := t.Withdrawals + vlen := len(t) + if vlen > int(expr12) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr12)), "ExecutionRequests.Withdrawals") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(electra1.WithdrawalRequest) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "ExecutionRequests.Withdrawals[%d]", idx1) + } + } + } + { // Dynamic Field #2 'Consolidations' + binary.LittleEndian.PutUint32(dst[dstlen+8:], uint32(len(dst)-dstlen)) + t := t.Consolidations + vlen := len(t) + if vlen > int(expr13) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr13)), "ExecutionRequests.Consolidations") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(electra1.ConsolidationRequest) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "ExecutionRequests.Consolidations[%d]", idx1) + } + } + } + } + return dst, nil +} + +func (t *BlindedBeaconBlockBody) UnmarshalSSZDynView(view any) func(ds sszutils.DynamicSpecs, buf []byte) error { + switch view.(type) { + case *bellatrix.BlindedBeaconBlockBody: + return t.unmarshalSSZView_BlindedBeaconBlockBody + case *capella.BlindedBeaconBlockBody: + return t.unmarshalSSZView_BlindedBeaconBlockBody_0 + case *deneb.BlindedBeaconBlockBody: + return t.unmarshalSSZView_BlindedBeaconBlockBody_1 + case *electra.BlindedBeaconBlockBody: + return t.unmarshalSSZView_BlindedBeaconBlockBody_2 + } + return nil +} +func (t *BlindedBeaconBlockBody) unmarshalSSZView_BlindedBeaconBlockBody(ds sszutils.DynamicSpecs, buf []byte) (err error) { + expr0, err := sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE/8", 64) + if err != nil { + return err + } + expr1, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_PROPOSER_SLASHINGS", 16) + if err != nil { + return err + } + expr2, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_ATTESTER_SLASHINGS", 2) + if err != nil { + return err + } + expr3, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_ATTESTATIONS", 128) + if err != nil { + return err + } + expr4, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_VALIDATORS_PER_COMMITTEE", 2048) + if err != nil { + return err + } + expr5, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_DEPOSITS", 16) + if err != nil { + return err + } + expr6, err := sszutils.ResolveSpecValueWithDefault(ds, "DEPOSIT_CONTRACT_TREE_DEPTH+1", 33) + if err != nil { + return err + } + expr7, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_VOLUNTARY_EXITS", 16) + if err != nil { + return err + } + size2 := 1 * int(expr0) + size1 := size2 + 96 // size expression for '*SyncAggregate' + size4 := 32 * int(expr6) + size3 := size4 + 184 // size expression for '*Deposit' + exproffset := 0 + totalSize := size1 + 224 + buflen := len(buf) + if buflen < totalSize { + return sszutils.ErrFixedFieldsEOFFn(buflen, totalSize) + } + { // Field #0 'RANDAOReveal' (static) + buf := buf[0:96] + copy(t.RANDAOReveal[:], buf) + } + { // Field #1 'ETH1Data' (static) + buf := buf[96:168] + if t.ETH1Data == nil { + t.ETH1Data = new(phase0.ETH1Data) + } + if err = t.ETH1Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "ETH1Data") + } + } + { // Field #2 'Graffiti' (static) + buf := buf[168:200] + copy(t.Graffiti[:], buf) + } + // Field #3 'ProposerSlashings' (offset) + offset3 := int(binary.LittleEndian.Uint32(buf[200:204])) + if offset3 != totalSize { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset3, totalSize), "ProposerSlashings:o") + } + // Field #4 'AttesterSlashings' (offset) + offset4 := int(binary.LittleEndian.Uint32(buf[204:208])) + if offset4 < offset3 || offset4 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset4, offset3, buflen), "AttesterSlashings:o") + } + // Field #5 'Attestations' (offset) + offset5 := int(binary.LittleEndian.Uint32(buf[208:212])) + if offset5 < offset4 || offset5 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset5, offset4, buflen), "Attestations:o") + } + // Field #6 'Deposits' (offset) + offset6 := int(binary.LittleEndian.Uint32(buf[212:216])) + if offset6 < offset5 || offset6 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset6, offset5, buflen), "Deposits:o") + } + // Field #7 'VoluntaryExits' (offset) + offset7 := int(binary.LittleEndian.Uint32(buf[216:220])) + if offset7 < offset6 || offset7 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset7, offset6, buflen), "VoluntaryExits:o") + } + { // Field #8 'SyncAggregate' (static) + buf := buf[220 : size1+220] + exproffset += int(size1) + val1 := t.SyncAggregate + if val1 == nil { + val1 = new(altair.SyncAggregate) + } + exproffset := 0 + totalSize := size2 + 96 + buflen := len(buf) + if buflen < totalSize { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, totalSize), "SyncAggregate") + } + if buflen > totalSize { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(buflen-totalSize), "SyncAggregate") + } + { // Field #0 'SyncCommitteeBits' (static) + buf := buf[0 : size2+0] + exproffset += int(size2) + val1.SyncCommitteeBits = sszutils.ExpandSlice(val1.SyncCommitteeBits, int(expr0)) + copy(val1.SyncCommitteeBits[:], buf) + } + { // Field #1 'SyncCommitteeSignature' (static) + buf := buf[exproffset+0 : exproffset+96] + copy(val1.SyncCommitteeSignature[:], buf) + } + t.SyncAggregate = val1 + } + // Field #9 'ExecutionPayloadHeader' (offset) + offset9 := int(binary.LittleEndian.Uint32(buf[exproffset+220 : exproffset+224])) + if offset9 < offset7 || offset9 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset9, offset7, buflen), "ExecutionPayloadHeader:o") + } + { // Field #3 'ProposerSlashings' (dynamic) + buf := buf[offset3:offset4] + val2 := t.ProposerSlashings + itemCount := len(buf) / 416 + if len(buf)%416 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 416), "ProposerSlashings") + } + if itemCount > int(expr1) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr1)), "ProposerSlashings") + } + val2 = sszutils.ExpandSlice(val2, itemCount) + for idx1 := range itemCount { + if val2[idx1] == nil { + val2[idx1] = new(phase0.ProposerSlashing) + } + buf := buf[416*idx1 : 416*(idx1+1)] + if err = val2[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "ProposerSlashings[%d]", idx1) + } + } + t.ProposerSlashings = val2 + } + { // Field #4 'AttesterSlashings' (dynamic) + buf := buf[offset4:offset5] + val3 := t.AttesterSlashings + startOffset := int(0) + if len(buf) != 0 { + if len(buf) < 4 { + return sszutils.ErrorWithPath(sszutils.ErrListOffsetsEOFFn(len(buf), 4), "AttesterSlashings") + } + startOffset = int(binary.LittleEndian.Uint32(buf[0:4])) + } + itemCount := startOffset / 4 + if startOffset%4 != 0 || len(buf) < startOffset || (len(buf) != 0 && startOffset == 0) { + return sszutils.ErrorWithPath(sszutils.ErrInvalidListStartOffsetFn(startOffset, len(buf)), "AttesterSlashings") + } + if itemCount > int(expr2) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr2)), "AttesterSlashings") + } + val3 = sszutils.ExpandSlice(val3, itemCount) + for idx1 := range itemCount { + var endOffset int + if idx1 < itemCount-1 { + endOffset = int(binary.LittleEndian.Uint32(buf[(idx1+1)*4 : (idx1+2)*4])) + } else { + endOffset = len(buf) + } + if endOffset < startOffset || endOffset > len(buf) { + return sszutils.ErrorWithPathf(sszutils.ErrElementOffsetOutOfRangeFn(endOffset, startOffset, len(buf)), "AttesterSlashings[%d]", idx1) + } + buf := buf[startOffset:endOffset] + startOffset = endOffset + val4 := val3[idx1] + if val4 == nil { + val4 = new(all.AttesterSlashing) + } + buflen := len(buf) + if buflen < 8 { + return sszutils.ErrorWithPathf(sszutils.ErrFixedFieldsEOFFn(buflen, 8), "AttesterSlashings[%d]", idx1) + } + // Field #0 'Attestation1' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 8 { + return sszutils.ErrorWithPathf(sszutils.ErrFirstOffsetMismatchFn(offset0, 8), "AttesterSlashings[%d].Attestation1:o", idx1) + } + // Field #1 'Attestation2' (offset) + offset1 := int(binary.LittleEndian.Uint32(buf[4:8])) + if offset1 < offset0 || offset1 > buflen { + return sszutils.ErrorWithPathf(sszutils.ErrOffsetOutOfRangeFn(offset1, offset0, buflen), "AttesterSlashings[%d].Attestation2:o", idx1) + } + { // Field #0 'Attestation1' (dynamic) + buf := buf[offset0:offset1] + if val4.Attestation1 == nil { + val4.Attestation1 = new(all.IndexedAttestation) + } + buflen := len(buf) + if buflen < 228 { + return sszutils.ErrorWithPathf(sszutils.ErrFixedFieldsEOFFn(buflen, 228), "AttesterSlashings[%d].Attestation1", idx1) + } + // Field #0 'AttestingIndices' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 228 { + return sszutils.ErrorWithPathf(sszutils.ErrFirstOffsetMismatchFn(offset0, 228), "AttesterSlashings[%d].Attestation1.AttestingIndices:o", idx1) + } + { // Field #1 'Data' (static) + buf := buf[4:132] + if val4.Attestation1.Data == nil { + val4.Attestation1.Data = new(phase0.AttestationData) + } + if err = val4.Attestation1.Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "AttesterSlashings[%d].Attestation1.Data", idx1) + } + } + { // Field #2 'Signature' (static) + buf := buf[132:228] + copy(val4.Attestation1.Signature[:], buf) + } + { // Field #0 'AttestingIndices' (dynamic) + buf := buf[offset0:] + val5 := val4.Attestation1.AttestingIndices + itemCount := len(buf) / 8 + if len(buf)%8 != 0 { + return sszutils.ErrorWithPathf(sszutils.ErrListNotAlignedFn(len(buf), 8), "AttesterSlashings[%d].Attestation1.AttestingIndices", idx1) + } + if itemCount > 2048 { + return sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(itemCount, 2048), "AttesterSlashings[%d].Attestation1.AttestingIndices", idx1) + } + val5 = sszutils.ExpandSlice(val5, itemCount) + sszutils.UnmarshalUint64Slice(val5, buf) + val4.Attestation1.AttestingIndices = val5 + } + } + { // Field #1 'Attestation2' (dynamic) + buf := buf[offset1:] + if val4.Attestation2 == nil { + val4.Attestation2 = new(all.IndexedAttestation) + } + buflen := len(buf) + if buflen < 228 { + return sszutils.ErrorWithPathf(sszutils.ErrFixedFieldsEOFFn(buflen, 228), "AttesterSlashings[%d].Attestation2", idx1) + } + // Field #0 'AttestingIndices' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 228 { + return sszutils.ErrorWithPathf(sszutils.ErrFirstOffsetMismatchFn(offset0, 228), "AttesterSlashings[%d].Attestation2.AttestingIndices:o", idx1) + } + { // Field #1 'Data' (static) + buf := buf[4:132] + if val4.Attestation2.Data == nil { + val4.Attestation2.Data = new(phase0.AttestationData) + } + if err = val4.Attestation2.Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "AttesterSlashings[%d].Attestation2.Data", idx1) + } + } + { // Field #2 'Signature' (static) + buf := buf[132:228] + copy(val4.Attestation2.Signature[:], buf) + } + { // Field #0 'AttestingIndices' (dynamic) + buf := buf[offset0:] + val6 := val4.Attestation2.AttestingIndices + itemCount := len(buf) / 8 + if len(buf)%8 != 0 { + return sszutils.ErrorWithPathf(sszutils.ErrListNotAlignedFn(len(buf), 8), "AttesterSlashings[%d].Attestation2.AttestingIndices", idx1) + } + if itemCount > 2048 { + return sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(itemCount, 2048), "AttesterSlashings[%d].Attestation2.AttestingIndices", idx1) + } + val6 = sszutils.ExpandSlice(val6, itemCount) + sszutils.UnmarshalUint64Slice(val6, buf) + val4.Attestation2.AttestingIndices = val6 + } + } + val3[idx1] = val4 + } + t.AttesterSlashings = val3 + } + { // Field #5 'Attestations' (dynamic) + buf := buf[offset5:offset6] + val7 := t.Attestations + startOffset := int(0) + if len(buf) != 0 { + if len(buf) < 4 { + return sszutils.ErrorWithPath(sszutils.ErrListOffsetsEOFFn(len(buf), 4), "Attestations") + } + startOffset = int(binary.LittleEndian.Uint32(buf[0:4])) + } + itemCount := startOffset / 4 + if startOffset%4 != 0 || len(buf) < startOffset || (len(buf) != 0 && startOffset == 0) { + return sszutils.ErrorWithPath(sszutils.ErrInvalidListStartOffsetFn(startOffset, len(buf)), "Attestations") + } + if itemCount > int(expr3) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr3)), "Attestations") + } + val7 = sszutils.ExpandSlice(val7, itemCount) + for idx1 := range itemCount { + var endOffset int + if idx1 < itemCount-1 { + endOffset = int(binary.LittleEndian.Uint32(buf[(idx1+1)*4 : (idx1+2)*4])) + } else { + endOffset = len(buf) + } + if endOffset < startOffset || endOffset > len(buf) { + return sszutils.ErrorWithPathf(sszutils.ErrElementOffsetOutOfRangeFn(endOffset, startOffset, len(buf)), "Attestations[%d]", idx1) + } + buf := buf[startOffset:endOffset] + startOffset = endOffset + val8 := val7[idx1] + if val8 == nil { + val8 = new(all.Attestation) + } + buflen := len(buf) + if buflen < 228 { + return sszutils.ErrorWithPathf(sszutils.ErrFixedFieldsEOFFn(buflen, 228), "Attestations[%d]", idx1) + } + // Field #0 'AggregationBits' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 228 { + return sszutils.ErrorWithPathf(sszutils.ErrFirstOffsetMismatchFn(offset0, 228), "Attestations[%d].AggregationBits:o", idx1) + } + { // Field #1 'Data' (static) + buf := buf[4:132] + if val8.Data == nil { + val8.Data = new(phase0.AttestationData) + } + if err = val8.Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Attestations[%d].Data", idx1) + } + } + { // Field #2 'Signature' (static) + buf := buf[132:228] + copy(val8.Signature[:], buf) + } + { // Field #0 'AggregationBits' (dynamic) + buf := buf[offset0:] + val9 := val8.AggregationBits + blen := len(buf) + if blen == 0 || buf[blen-1] == 0x00 { + return sszutils.ErrorWithPathf(sszutils.ErrBitlistNotTerminatedFn(), "Attestations[%d].AggregationBits", idx1) + } + bitCount := 8*(blen-1) + int(bits.Len8(buf[blen-1])) - 1 + if bitCount > int(expr4) { + return sszutils.ErrorWithPathf(sszutils.ErrBitlistLengthFn(bitCount, int(expr4)), "Attestations[%d].AggregationBits", idx1) + } + val9 = sszutils.ExpandSlice(val9, blen) + copy(val9[:], buf) + val8.AggregationBits = val9 + } + val7[idx1] = val8 + } + t.Attestations = val7 + } + { // Field #6 'Deposits' (dynamic) + buf := buf[offset6:offset7] + val10 := t.Deposits + itemCount := len(buf) / size3 + if len(buf)%size3 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), size3), "Deposits") + } + if itemCount > int(expr5) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr5)), "Deposits") + } + val10 = sszutils.ExpandSlice(val10, itemCount) + for idx1 := range itemCount { + val11 := val10[idx1] + if val11 == nil { + val11 = new(phase0.Deposit) + } + buf := buf[size3*idx1 : size3*(idx1+1)] + exproffset := 0 + totalSize := size4 + 184 + buflen := len(buf) + if buflen < totalSize { + return sszutils.ErrorWithPathf(sszutils.ErrFixedFieldsEOFFn(buflen, totalSize), "Deposits[%d]", idx1) + } + if buflen > totalSize { + return sszutils.ErrorWithPathf(sszutils.ErrTrailingDataFn(buflen-totalSize), "Deposits[%d]", idx1) + } + { // Field #0 'Proof' (static) + buf := buf[0 : size4+0] + exproffset += int(size4) + val12 := val11.Proof + val12 = sszutils.ExpandSlice(val12, int(expr6)) + for idx2 := range int(expr6) { + buf := buf[32*idx2 : 32*(idx2+1)] + val12[idx2] = sszutils.ExpandSlice(val12[idx2], 32) + copy(val12[idx2][:], buf) + } + val11.Proof = val12 + } + { // Field #1 'Data' (static) + buf := buf[exproffset+0 : exproffset+184] + if val11.Data == nil { + val11.Data = new(phase0.DepositData) + } + if err = val11.Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Deposits[%d].Data", idx1) + } + } + val10[idx1] = val11 + } + t.Deposits = val10 + } + { // Field #7 'VoluntaryExits' (dynamic) + buf := buf[offset7:offset9] + val13 := t.VoluntaryExits + itemCount := len(buf) / 112 + if len(buf)%112 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 112), "VoluntaryExits") + } + if itemCount > int(expr7) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr7)), "VoluntaryExits") + } + val13 = sszutils.ExpandSlice(val13, itemCount) + for idx1 := range itemCount { + if val13[idx1] == nil { + val13[idx1] = new(phase0.SignedVoluntaryExit) + } + buf := buf[112*idx1 : 112*(idx1+1)] + if err = val13[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "VoluntaryExits[%d]", idx1) + } + } + t.VoluntaryExits = val13 + } + { // Field #9 'ExecutionPayloadHeader' (dynamic) + buf := buf[offset9:] + if t.ExecutionPayloadHeader == nil { + t.ExecutionPayloadHeader = new(all.ExecutionPayloadHeader) + } + buflen := len(buf) + if buflen < 536 { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, 536), "ExecutionPayloadHeader") + } + { // Field #0 'ParentHash' (static) + buf := buf[0:32] + copy(t.ExecutionPayloadHeader.ParentHash[:], buf) + } + { // Field #1 'FeeRecipient' (static) + buf := buf[32:52] + copy(t.ExecutionPayloadHeader.FeeRecipient[:], buf) + } + { // Field #2 'StateRoot' (static) + buf := buf[52:84] + copy(t.ExecutionPayloadHeader.StateRoot[:], buf) + } + { // Field #3 'ReceiptsRoot' (static) + buf := buf[84:116] + copy(t.ExecutionPayloadHeader.ReceiptsRoot[:], buf) + } + { // Field #4 'LogsBloom' (static) + buf := buf[116:372] + copy(t.ExecutionPayloadHeader.LogsBloom[:], buf) + } + { // Field #5 'PrevRandao' (static) + buf := buf[372:404] + copy(t.ExecutionPayloadHeader.PrevRandao[:], buf) + } + { // Field #6 'BlockNumber' (static) + buf := buf[404:412] + t.ExecutionPayloadHeader.BlockNumber = binary.LittleEndian.Uint64(buf) + } + { // Field #7 'GasLimit' (static) + buf := buf[412:420] + t.ExecutionPayloadHeader.GasLimit = binary.LittleEndian.Uint64(buf) + } + { // Field #8 'GasUsed' (static) + buf := buf[420:428] + t.ExecutionPayloadHeader.GasUsed = binary.LittleEndian.Uint64(buf) + } + { // Field #9 'Timestamp' (static) + buf := buf[428:436] + t.ExecutionPayloadHeader.Timestamp = binary.LittleEndian.Uint64(buf) + } + // Field #10 'ExtraData' (offset) + offset10 := int(binary.LittleEndian.Uint32(buf[436:440])) + if offset10 != 536 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset10, 536), "ExecutionPayloadHeader.ExtraData:o") + } + { // Field #11 'BaseFeePerGasLE' (static) + buf := buf[440:472] + copy(t.ExecutionPayloadHeader.BaseFeePerGasLE[:], buf) + } + { // Field #12 'BlockHash' (static) + buf := buf[472:504] + copy(t.ExecutionPayloadHeader.BlockHash[:], buf) + } + { // Field #13 'TransactionsRoot' (static) + buf := buf[504:536] + copy(t.ExecutionPayloadHeader.TransactionsRoot[:], buf) + } + { // Field #10 'ExtraData' (dynamic) + buf := buf[offset10:] + if len(buf) > 32 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(len(buf), 32), "ExecutionPayloadHeader.ExtraData") + } + t.ExecutionPayloadHeader.ExtraData = sszutils.ExpandSlice(t.ExecutionPayloadHeader.ExtraData, len(buf)) + copy(t.ExecutionPayloadHeader.ExtraData[:], buf) + } + } + return nil +} + +func (t *BlindedBeaconBlockBody) unmarshalSSZView_BlindedBeaconBlockBody_0(ds sszutils.DynamicSpecs, buf []byte) (err error) { + expr0, err := sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE/8", 64) + if err != nil { + return err + } + expr1, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_PROPOSER_SLASHINGS", 16) + if err != nil { + return err + } + expr2, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_ATTESTER_SLASHINGS", 2) + if err != nil { + return err + } + expr3, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_ATTESTATIONS", 128) + if err != nil { + return err + } + expr4, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_VALIDATORS_PER_COMMITTEE", 2048) + if err != nil { + return err + } + expr5, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_DEPOSITS", 16) + if err != nil { + return err + } + expr6, err := sszutils.ResolveSpecValueWithDefault(ds, "DEPOSIT_CONTRACT_TREE_DEPTH+1", 33) + if err != nil { + return err + } + expr7, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_VOLUNTARY_EXITS", 16) + if err != nil { + return err + } + expr8, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BLS_TO_EXECUTION_CHANGES", 16) + if err != nil { + return err + } + size2 := 1 * int(expr0) + size1 := size2 + 96 // size expression for '*SyncAggregate' + size4 := 32 * int(expr6) + size3 := size4 + 184 // size expression for '*Deposit' + exproffset := 0 + totalSize := size1 + 228 + buflen := len(buf) + if buflen < totalSize { + return sszutils.ErrFixedFieldsEOFFn(buflen, totalSize) + } + { // Field #0 'RANDAOReveal' (static) + buf := buf[0:96] + copy(t.RANDAOReveal[:], buf) + } + { // Field #1 'ETH1Data' (static) + buf := buf[96:168] + if t.ETH1Data == nil { + t.ETH1Data = new(phase0.ETH1Data) + } + if err = t.ETH1Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "ETH1Data") + } + } + { // Field #2 'Graffiti' (static) + buf := buf[168:200] + copy(t.Graffiti[:], buf) + } + // Field #3 'ProposerSlashings' (offset) + offset3 := int(binary.LittleEndian.Uint32(buf[200:204])) + if offset3 != totalSize { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset3, totalSize), "ProposerSlashings:o") + } + // Field #4 'AttesterSlashings' (offset) + offset4 := int(binary.LittleEndian.Uint32(buf[204:208])) + if offset4 < offset3 || offset4 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset4, offset3, buflen), "AttesterSlashings:o") + } + // Field #5 'Attestations' (offset) + offset5 := int(binary.LittleEndian.Uint32(buf[208:212])) + if offset5 < offset4 || offset5 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset5, offset4, buflen), "Attestations:o") + } + // Field #6 'Deposits' (offset) + offset6 := int(binary.LittleEndian.Uint32(buf[212:216])) + if offset6 < offset5 || offset6 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset6, offset5, buflen), "Deposits:o") + } + // Field #7 'VoluntaryExits' (offset) + offset7 := int(binary.LittleEndian.Uint32(buf[216:220])) + if offset7 < offset6 || offset7 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset7, offset6, buflen), "VoluntaryExits:o") + } + { // Field #8 'SyncAggregate' (static) + buf := buf[220 : size1+220] + exproffset += int(size1) + val1 := t.SyncAggregate + if val1 == nil { + val1 = new(altair.SyncAggregate) + } + exproffset := 0 + totalSize := size2 + 96 + buflen := len(buf) + if buflen < totalSize { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, totalSize), "SyncAggregate") + } + if buflen > totalSize { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(buflen-totalSize), "SyncAggregate") + } + { // Field #0 'SyncCommitteeBits' (static) + buf := buf[0 : size2+0] + exproffset += int(size2) + val1.SyncCommitteeBits = sszutils.ExpandSlice(val1.SyncCommitteeBits, int(expr0)) + copy(val1.SyncCommitteeBits[:], buf) + } + { // Field #1 'SyncCommitteeSignature' (static) + buf := buf[exproffset+0 : exproffset+96] + copy(val1.SyncCommitteeSignature[:], buf) + } + t.SyncAggregate = val1 + } + // Field #9 'ExecutionPayloadHeader' (offset) + offset9 := int(binary.LittleEndian.Uint32(buf[exproffset+220 : exproffset+224])) + if offset9 < offset7 || offset9 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset9, offset7, buflen), "ExecutionPayloadHeader:o") + } + // Field #10 'BLSToExecutionChanges' (offset) + offset10 := int(binary.LittleEndian.Uint32(buf[exproffset+224 : exproffset+228])) + if offset10 < offset9 || offset10 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset10, offset9, buflen), "BLSToExecutionChanges:o") + } + { // Field #3 'ProposerSlashings' (dynamic) + buf := buf[offset3:offset4] + val2 := t.ProposerSlashings + itemCount := len(buf) / 416 + if len(buf)%416 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 416), "ProposerSlashings") + } + if itemCount > int(expr1) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr1)), "ProposerSlashings") + } + val2 = sszutils.ExpandSlice(val2, itemCount) + for idx1 := range itemCount { + if val2[idx1] == nil { + val2[idx1] = new(phase0.ProposerSlashing) + } + buf := buf[416*idx1 : 416*(idx1+1)] + if err = val2[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "ProposerSlashings[%d]", idx1) + } + } + t.ProposerSlashings = val2 + } + { // Field #4 'AttesterSlashings' (dynamic) + buf := buf[offset4:offset5] + val3 := t.AttesterSlashings + startOffset := int(0) + if len(buf) != 0 { + if len(buf) < 4 { + return sszutils.ErrorWithPath(sszutils.ErrListOffsetsEOFFn(len(buf), 4), "AttesterSlashings") + } + startOffset = int(binary.LittleEndian.Uint32(buf[0:4])) + } + itemCount := startOffset / 4 + if startOffset%4 != 0 || len(buf) < startOffset || (len(buf) != 0 && startOffset == 0) { + return sszutils.ErrorWithPath(sszutils.ErrInvalidListStartOffsetFn(startOffset, len(buf)), "AttesterSlashings") + } + if itemCount > int(expr2) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr2)), "AttesterSlashings") + } + val3 = sszutils.ExpandSlice(val3, itemCount) + for idx1 := range itemCount { + var endOffset int + if idx1 < itemCount-1 { + endOffset = int(binary.LittleEndian.Uint32(buf[(idx1+1)*4 : (idx1+2)*4])) + } else { + endOffset = len(buf) + } + if endOffset < startOffset || endOffset > len(buf) { + return sszutils.ErrorWithPathf(sszutils.ErrElementOffsetOutOfRangeFn(endOffset, startOffset, len(buf)), "AttesterSlashings[%d]", idx1) + } + buf := buf[startOffset:endOffset] + startOffset = endOffset + val4 := val3[idx1] + if val4 == nil { + val4 = new(all.AttesterSlashing) + } + buflen := len(buf) + if buflen < 8 { + return sszutils.ErrorWithPathf(sszutils.ErrFixedFieldsEOFFn(buflen, 8), "AttesterSlashings[%d]", idx1) + } + // Field #0 'Attestation1' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 8 { + return sszutils.ErrorWithPathf(sszutils.ErrFirstOffsetMismatchFn(offset0, 8), "AttesterSlashings[%d].Attestation1:o", idx1) + } + // Field #1 'Attestation2' (offset) + offset1 := int(binary.LittleEndian.Uint32(buf[4:8])) + if offset1 < offset0 || offset1 > buflen { + return sszutils.ErrorWithPathf(sszutils.ErrOffsetOutOfRangeFn(offset1, offset0, buflen), "AttesterSlashings[%d].Attestation2:o", idx1) + } + { // Field #0 'Attestation1' (dynamic) + buf := buf[offset0:offset1] + if val4.Attestation1 == nil { + val4.Attestation1 = new(all.IndexedAttestation) + } + buflen := len(buf) + if buflen < 228 { + return sszutils.ErrorWithPathf(sszutils.ErrFixedFieldsEOFFn(buflen, 228), "AttesterSlashings[%d].Attestation1", idx1) + } + // Field #0 'AttestingIndices' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 228 { + return sszutils.ErrorWithPathf(sszutils.ErrFirstOffsetMismatchFn(offset0, 228), "AttesterSlashings[%d].Attestation1.AttestingIndices:o", idx1) + } + { // Field #1 'Data' (static) + buf := buf[4:132] + if val4.Attestation1.Data == nil { + val4.Attestation1.Data = new(phase0.AttestationData) + } + if err = val4.Attestation1.Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "AttesterSlashings[%d].Attestation1.Data", idx1) + } + } + { // Field #2 'Signature' (static) + buf := buf[132:228] + copy(val4.Attestation1.Signature[:], buf) + } + { // Field #0 'AttestingIndices' (dynamic) + buf := buf[offset0:] + val5 := val4.Attestation1.AttestingIndices + itemCount := len(buf) / 8 + if len(buf)%8 != 0 { + return sszutils.ErrorWithPathf(sszutils.ErrListNotAlignedFn(len(buf), 8), "AttesterSlashings[%d].Attestation1.AttestingIndices", idx1) + } + if itemCount > 2048 { + return sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(itemCount, 2048), "AttesterSlashings[%d].Attestation1.AttestingIndices", idx1) + } + val5 = sszutils.ExpandSlice(val5, itemCount) + sszutils.UnmarshalUint64Slice(val5, buf) + val4.Attestation1.AttestingIndices = val5 + } + } + { // Field #1 'Attestation2' (dynamic) + buf := buf[offset1:] + if val4.Attestation2 == nil { + val4.Attestation2 = new(all.IndexedAttestation) + } + buflen := len(buf) + if buflen < 228 { + return sszutils.ErrorWithPathf(sszutils.ErrFixedFieldsEOFFn(buflen, 228), "AttesterSlashings[%d].Attestation2", idx1) + } + // Field #0 'AttestingIndices' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 228 { + return sszutils.ErrorWithPathf(sszutils.ErrFirstOffsetMismatchFn(offset0, 228), "AttesterSlashings[%d].Attestation2.AttestingIndices:o", idx1) + } + { // Field #1 'Data' (static) + buf := buf[4:132] + if val4.Attestation2.Data == nil { + val4.Attestation2.Data = new(phase0.AttestationData) + } + if err = val4.Attestation2.Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "AttesterSlashings[%d].Attestation2.Data", idx1) + } + } + { // Field #2 'Signature' (static) + buf := buf[132:228] + copy(val4.Attestation2.Signature[:], buf) + } + { // Field #0 'AttestingIndices' (dynamic) + buf := buf[offset0:] + val6 := val4.Attestation2.AttestingIndices + itemCount := len(buf) / 8 + if len(buf)%8 != 0 { + return sszutils.ErrorWithPathf(sszutils.ErrListNotAlignedFn(len(buf), 8), "AttesterSlashings[%d].Attestation2.AttestingIndices", idx1) + } + if itemCount > 2048 { + return sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(itemCount, 2048), "AttesterSlashings[%d].Attestation2.AttestingIndices", idx1) + } + val6 = sszutils.ExpandSlice(val6, itemCount) + sszutils.UnmarshalUint64Slice(val6, buf) + val4.Attestation2.AttestingIndices = val6 + } + } + val3[idx1] = val4 + } + t.AttesterSlashings = val3 + } + { // Field #5 'Attestations' (dynamic) + buf := buf[offset5:offset6] + val7 := t.Attestations + startOffset := int(0) + if len(buf) != 0 { + if len(buf) < 4 { + return sszutils.ErrorWithPath(sszutils.ErrListOffsetsEOFFn(len(buf), 4), "Attestations") + } + startOffset = int(binary.LittleEndian.Uint32(buf[0:4])) + } + itemCount := startOffset / 4 + if startOffset%4 != 0 || len(buf) < startOffset || (len(buf) != 0 && startOffset == 0) { + return sszutils.ErrorWithPath(sszutils.ErrInvalidListStartOffsetFn(startOffset, len(buf)), "Attestations") + } + if itemCount > int(expr3) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr3)), "Attestations") + } + val7 = sszutils.ExpandSlice(val7, itemCount) + for idx1 := range itemCount { + var endOffset int + if idx1 < itemCount-1 { + endOffset = int(binary.LittleEndian.Uint32(buf[(idx1+1)*4 : (idx1+2)*4])) + } else { + endOffset = len(buf) + } + if endOffset < startOffset || endOffset > len(buf) { + return sszutils.ErrorWithPathf(sszutils.ErrElementOffsetOutOfRangeFn(endOffset, startOffset, len(buf)), "Attestations[%d]", idx1) + } + buf := buf[startOffset:endOffset] + startOffset = endOffset + val8 := val7[idx1] + if val8 == nil { + val8 = new(all.Attestation) + } + buflen := len(buf) + if buflen < 228 { + return sszutils.ErrorWithPathf(sszutils.ErrFixedFieldsEOFFn(buflen, 228), "Attestations[%d]", idx1) + } + // Field #0 'AggregationBits' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 228 { + return sszutils.ErrorWithPathf(sszutils.ErrFirstOffsetMismatchFn(offset0, 228), "Attestations[%d].AggregationBits:o", idx1) + } + { // Field #1 'Data' (static) + buf := buf[4:132] + if val8.Data == nil { + val8.Data = new(phase0.AttestationData) + } + if err = val8.Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Attestations[%d].Data", idx1) + } + } + { // Field #2 'Signature' (static) + buf := buf[132:228] + copy(val8.Signature[:], buf) + } + { // Field #0 'AggregationBits' (dynamic) + buf := buf[offset0:] + val9 := val8.AggregationBits + blen := len(buf) + if blen == 0 || buf[blen-1] == 0x00 { + return sszutils.ErrorWithPathf(sszutils.ErrBitlistNotTerminatedFn(), "Attestations[%d].AggregationBits", idx1) + } + bitCount := 8*(blen-1) + int(bits.Len8(buf[blen-1])) - 1 + if bitCount > int(expr4) { + return sszutils.ErrorWithPathf(sszutils.ErrBitlistLengthFn(bitCount, int(expr4)), "Attestations[%d].AggregationBits", idx1) + } + val9 = sszutils.ExpandSlice(val9, blen) + copy(val9[:], buf) + val8.AggregationBits = val9 + } + val7[idx1] = val8 + } + t.Attestations = val7 + } + { // Field #6 'Deposits' (dynamic) + buf := buf[offset6:offset7] + val10 := t.Deposits + itemCount := len(buf) / size3 + if len(buf)%size3 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), size3), "Deposits") + } + if itemCount > int(expr5) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr5)), "Deposits") + } + val10 = sszutils.ExpandSlice(val10, itemCount) + for idx1 := range itemCount { + val11 := val10[idx1] + if val11 == nil { + val11 = new(phase0.Deposit) + } + buf := buf[size3*idx1 : size3*(idx1+1)] + exproffset := 0 + totalSize := size4 + 184 + buflen := len(buf) + if buflen < totalSize { + return sszutils.ErrorWithPathf(sszutils.ErrFixedFieldsEOFFn(buflen, totalSize), "Deposits[%d]", idx1) + } + if buflen > totalSize { + return sszutils.ErrorWithPathf(sszutils.ErrTrailingDataFn(buflen-totalSize), "Deposits[%d]", idx1) + } + { // Field #0 'Proof' (static) + buf := buf[0 : size4+0] + exproffset += int(size4) + val12 := val11.Proof + val12 = sszutils.ExpandSlice(val12, int(expr6)) + for idx2 := range int(expr6) { + buf := buf[32*idx2 : 32*(idx2+1)] + val12[idx2] = sszutils.ExpandSlice(val12[idx2], 32) + copy(val12[idx2][:], buf) + } + val11.Proof = val12 + } + { // Field #1 'Data' (static) + buf := buf[exproffset+0 : exproffset+184] + if val11.Data == nil { + val11.Data = new(phase0.DepositData) + } + if err = val11.Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Deposits[%d].Data", idx1) + } + } + val10[idx1] = val11 + } + t.Deposits = val10 + } + { // Field #7 'VoluntaryExits' (dynamic) + buf := buf[offset7:offset9] + val13 := t.VoluntaryExits + itemCount := len(buf) / 112 + if len(buf)%112 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 112), "VoluntaryExits") + } + if itemCount > int(expr7) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr7)), "VoluntaryExits") + } + val13 = sszutils.ExpandSlice(val13, itemCount) + for idx1 := range itemCount { + if val13[idx1] == nil { + val13[idx1] = new(phase0.SignedVoluntaryExit) + } + buf := buf[112*idx1 : 112*(idx1+1)] + if err = val13[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "VoluntaryExits[%d]", idx1) + } + } + t.VoluntaryExits = val13 + } + { // Field #9 'ExecutionPayloadHeader' (dynamic) + buf := buf[offset9:offset10] + if t.ExecutionPayloadHeader == nil { + t.ExecutionPayloadHeader = new(all.ExecutionPayloadHeader) + } + buflen := len(buf) + if buflen < 568 { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, 568), "ExecutionPayloadHeader") + } + { // Field #0 'ParentHash' (static) + buf := buf[0:32] + copy(t.ExecutionPayloadHeader.ParentHash[:], buf) + } + { // Field #1 'FeeRecipient' (static) + buf := buf[32:52] + copy(t.ExecutionPayloadHeader.FeeRecipient[:], buf) + } + { // Field #2 'StateRoot' (static) + buf := buf[52:84] + copy(t.ExecutionPayloadHeader.StateRoot[:], buf) + } + { // Field #3 'ReceiptsRoot' (static) + buf := buf[84:116] + copy(t.ExecutionPayloadHeader.ReceiptsRoot[:], buf) + } + { // Field #4 'LogsBloom' (static) + buf := buf[116:372] + copy(t.ExecutionPayloadHeader.LogsBloom[:], buf) + } + { // Field #5 'PrevRandao' (static) + buf := buf[372:404] + copy(t.ExecutionPayloadHeader.PrevRandao[:], buf) + } + { // Field #6 'BlockNumber' (static) + buf := buf[404:412] + t.ExecutionPayloadHeader.BlockNumber = binary.LittleEndian.Uint64(buf) + } + { // Field #7 'GasLimit' (static) + buf := buf[412:420] + t.ExecutionPayloadHeader.GasLimit = binary.LittleEndian.Uint64(buf) + } + { // Field #8 'GasUsed' (static) + buf := buf[420:428] + t.ExecutionPayloadHeader.GasUsed = binary.LittleEndian.Uint64(buf) + } + { // Field #9 'Timestamp' (static) + buf := buf[428:436] + t.ExecutionPayloadHeader.Timestamp = binary.LittleEndian.Uint64(buf) + } + // Field #10 'ExtraData' (offset) + offset10 := int(binary.LittleEndian.Uint32(buf[436:440])) + if offset10 != 568 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset10, 568), "ExecutionPayloadHeader.ExtraData:o") + } + { // Field #11 'BaseFeePerGasLE' (static) + buf := buf[440:472] + copy(t.ExecutionPayloadHeader.BaseFeePerGasLE[:], buf) + } + { // Field #12 'BlockHash' (static) + buf := buf[472:504] + copy(t.ExecutionPayloadHeader.BlockHash[:], buf) + } + { // Field #13 'TransactionsRoot' (static) + buf := buf[504:536] + copy(t.ExecutionPayloadHeader.TransactionsRoot[:], buf) + } + { // Field #14 'WithdrawalsRoot' (static) + buf := buf[536:568] + copy(t.ExecutionPayloadHeader.WithdrawalsRoot[:], buf) + } + { // Field #10 'ExtraData' (dynamic) + buf := buf[offset10:] + if len(buf) > 32 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(len(buf), 32), "ExecutionPayloadHeader.ExtraData") + } + t.ExecutionPayloadHeader.ExtraData = sszutils.ExpandSlice(t.ExecutionPayloadHeader.ExtraData, len(buf)) + copy(t.ExecutionPayloadHeader.ExtraData[:], buf) + } + } + { // Field #10 'BLSToExecutionChanges' (dynamic) + buf := buf[offset10:] + val14 := t.BLSToExecutionChanges + itemCount := len(buf) / 172 + if len(buf)%172 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 172), "BLSToExecutionChanges") + } + if itemCount > int(expr8) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr8)), "BLSToExecutionChanges") + } + val14 = sszutils.ExpandSlice(val14, itemCount) + for idx1 := range itemCount { + if val14[idx1] == nil { + val14[idx1] = new(capella1.SignedBLSToExecutionChange) + } + buf := buf[172*idx1 : 172*(idx1+1)] + if err = val14[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "BLSToExecutionChanges[%d]", idx1) + } + } + t.BLSToExecutionChanges = val14 + } + return nil +} + +func (t *BlindedBeaconBlockBody) unmarshalSSZView_BlindedBeaconBlockBody_1(ds sszutils.DynamicSpecs, buf []byte) (err error) { + expr0, err := sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE/8", 64) + if err != nil { + return err + } + expr1, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_PROPOSER_SLASHINGS", 16) + if err != nil { + return err + } + expr2, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_ATTESTER_SLASHINGS", 2) + if err != nil { + return err + } + expr3, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_ATTESTATIONS", 128) + if err != nil { + return err + } + expr4, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_VALIDATORS_PER_COMMITTEE", 2048) + if err != nil { + return err + } + expr5, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_DEPOSITS", 16) + if err != nil { + return err + } + expr6, err := sszutils.ResolveSpecValueWithDefault(ds, "DEPOSIT_CONTRACT_TREE_DEPTH+1", 33) + if err != nil { + return err + } + expr7, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_VOLUNTARY_EXITS", 16) + if err != nil { + return err + } + expr8, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BLS_TO_EXECUTION_CHANGES", 16) + if err != nil { + return err + } + expr9, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BLOB_COMMITMENTS_PER_BLOCK", 4096) + if err != nil { + return err + } + size2 := 1 * int(expr0) + size1 := size2 + 96 // size expression for '*SyncAggregate' + size4 := 32 * int(expr6) + size3 := size4 + 184 // size expression for '*Deposit' + exproffset := 0 + totalSize := size1 + 232 + buflen := len(buf) + if buflen < totalSize { + return sszutils.ErrFixedFieldsEOFFn(buflen, totalSize) + } + { // Field #0 'RANDAOReveal' (static) + buf := buf[0:96] + copy(t.RANDAOReveal[:], buf) + } + { // Field #1 'ETH1Data' (static) + buf := buf[96:168] + if t.ETH1Data == nil { + t.ETH1Data = new(phase0.ETH1Data) + } + if err = t.ETH1Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "ETH1Data") + } + } + { // Field #2 'Graffiti' (static) + buf := buf[168:200] + copy(t.Graffiti[:], buf) + } + // Field #3 'ProposerSlashings' (offset) + offset3 := int(binary.LittleEndian.Uint32(buf[200:204])) + if offset3 != totalSize { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset3, totalSize), "ProposerSlashings:o") + } + // Field #4 'AttesterSlashings' (offset) + offset4 := int(binary.LittleEndian.Uint32(buf[204:208])) + if offset4 < offset3 || offset4 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset4, offset3, buflen), "AttesterSlashings:o") + } + // Field #5 'Attestations' (offset) + offset5 := int(binary.LittleEndian.Uint32(buf[208:212])) + if offset5 < offset4 || offset5 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset5, offset4, buflen), "Attestations:o") + } + // Field #6 'Deposits' (offset) + offset6 := int(binary.LittleEndian.Uint32(buf[212:216])) + if offset6 < offset5 || offset6 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset6, offset5, buflen), "Deposits:o") + } + // Field #7 'VoluntaryExits' (offset) + offset7 := int(binary.LittleEndian.Uint32(buf[216:220])) + if offset7 < offset6 || offset7 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset7, offset6, buflen), "VoluntaryExits:o") + } + { // Field #8 'SyncAggregate' (static) + buf := buf[220 : size1+220] + exproffset += int(size1) + val1 := t.SyncAggregate + if val1 == nil { + val1 = new(altair.SyncAggregate) + } + exproffset := 0 + totalSize := size2 + 96 + buflen := len(buf) + if buflen < totalSize { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, totalSize), "SyncAggregate") + } + if buflen > totalSize { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(buflen-totalSize), "SyncAggregate") + } + { // Field #0 'SyncCommitteeBits' (static) + buf := buf[0 : size2+0] + exproffset += int(size2) + val1.SyncCommitteeBits = sszutils.ExpandSlice(val1.SyncCommitteeBits, int(expr0)) + copy(val1.SyncCommitteeBits[:], buf) + } + { // Field #1 'SyncCommitteeSignature' (static) + buf := buf[exproffset+0 : exproffset+96] + copy(val1.SyncCommitteeSignature[:], buf) + } + t.SyncAggregate = val1 + } + // Field #9 'ExecutionPayloadHeader' (offset) + offset9 := int(binary.LittleEndian.Uint32(buf[exproffset+220 : exproffset+224])) + if offset9 < offset7 || offset9 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset9, offset7, buflen), "ExecutionPayloadHeader:o") + } + // Field #10 'BLSToExecutionChanges' (offset) + offset10 := int(binary.LittleEndian.Uint32(buf[exproffset+224 : exproffset+228])) + if offset10 < offset9 || offset10 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset10, offset9, buflen), "BLSToExecutionChanges:o") + } + // Field #11 'BlobKZGCommitments' (offset) + offset11 := int(binary.LittleEndian.Uint32(buf[exproffset+228 : exproffset+232])) + if offset11 < offset10 || offset11 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset11, offset10, buflen), "BlobKZGCommitments:o") + } + { // Field #3 'ProposerSlashings' (dynamic) + buf := buf[offset3:offset4] + val2 := t.ProposerSlashings + itemCount := len(buf) / 416 + if len(buf)%416 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 416), "ProposerSlashings") + } + if itemCount > int(expr1) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr1)), "ProposerSlashings") + } + val2 = sszutils.ExpandSlice(val2, itemCount) + for idx1 := range itemCount { + if val2[idx1] == nil { + val2[idx1] = new(phase0.ProposerSlashing) + } + buf := buf[416*idx1 : 416*(idx1+1)] + if err = val2[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "ProposerSlashings[%d]", idx1) + } + } + t.ProposerSlashings = val2 + } + { // Field #4 'AttesterSlashings' (dynamic) + buf := buf[offset4:offset5] + val3 := t.AttesterSlashings + startOffset := int(0) + if len(buf) != 0 { + if len(buf) < 4 { + return sszutils.ErrorWithPath(sszutils.ErrListOffsetsEOFFn(len(buf), 4), "AttesterSlashings") + } + startOffset = int(binary.LittleEndian.Uint32(buf[0:4])) + } + itemCount := startOffset / 4 + if startOffset%4 != 0 || len(buf) < startOffset || (len(buf) != 0 && startOffset == 0) { + return sszutils.ErrorWithPath(sszutils.ErrInvalidListStartOffsetFn(startOffset, len(buf)), "AttesterSlashings") + } + if itemCount > int(expr2) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr2)), "AttesterSlashings") + } + val3 = sszutils.ExpandSlice(val3, itemCount) + for idx1 := range itemCount { + var endOffset int + if idx1 < itemCount-1 { + endOffset = int(binary.LittleEndian.Uint32(buf[(idx1+1)*4 : (idx1+2)*4])) + } else { + endOffset = len(buf) + } + if endOffset < startOffset || endOffset > len(buf) { + return sszutils.ErrorWithPathf(sszutils.ErrElementOffsetOutOfRangeFn(endOffset, startOffset, len(buf)), "AttesterSlashings[%d]", idx1) + } + buf := buf[startOffset:endOffset] + startOffset = endOffset + val4 := val3[idx1] + if val4 == nil { + val4 = new(all.AttesterSlashing) + } + buflen := len(buf) + if buflen < 8 { + return sszutils.ErrorWithPathf(sszutils.ErrFixedFieldsEOFFn(buflen, 8), "AttesterSlashings[%d]", idx1) + } + // Field #0 'Attestation1' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 8 { + return sszutils.ErrorWithPathf(sszutils.ErrFirstOffsetMismatchFn(offset0, 8), "AttesterSlashings[%d].Attestation1:o", idx1) + } + // Field #1 'Attestation2' (offset) + offset1 := int(binary.LittleEndian.Uint32(buf[4:8])) + if offset1 < offset0 || offset1 > buflen { + return sszutils.ErrorWithPathf(sszutils.ErrOffsetOutOfRangeFn(offset1, offset0, buflen), "AttesterSlashings[%d].Attestation2:o", idx1) + } + { // Field #0 'Attestation1' (dynamic) + buf := buf[offset0:offset1] + if val4.Attestation1 == nil { + val4.Attestation1 = new(all.IndexedAttestation) + } + buflen := len(buf) + if buflen < 228 { + return sszutils.ErrorWithPathf(sszutils.ErrFixedFieldsEOFFn(buflen, 228), "AttesterSlashings[%d].Attestation1", idx1) + } + // Field #0 'AttestingIndices' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 228 { + return sszutils.ErrorWithPathf(sszutils.ErrFirstOffsetMismatchFn(offset0, 228), "AttesterSlashings[%d].Attestation1.AttestingIndices:o", idx1) + } + { // Field #1 'Data' (static) + buf := buf[4:132] + if val4.Attestation1.Data == nil { + val4.Attestation1.Data = new(phase0.AttestationData) + } + if err = val4.Attestation1.Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "AttesterSlashings[%d].Attestation1.Data", idx1) + } + } + { // Field #2 'Signature' (static) + buf := buf[132:228] + copy(val4.Attestation1.Signature[:], buf) + } + { // Field #0 'AttestingIndices' (dynamic) + buf := buf[offset0:] + val5 := val4.Attestation1.AttestingIndices + itemCount := len(buf) / 8 + if len(buf)%8 != 0 { + return sszutils.ErrorWithPathf(sszutils.ErrListNotAlignedFn(len(buf), 8), "AttesterSlashings[%d].Attestation1.AttestingIndices", idx1) + } + if itemCount > 2048 { + return sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(itemCount, 2048), "AttesterSlashings[%d].Attestation1.AttestingIndices", idx1) + } + val5 = sszutils.ExpandSlice(val5, itemCount) + sszutils.UnmarshalUint64Slice(val5, buf) + val4.Attestation1.AttestingIndices = val5 + } + } + { // Field #1 'Attestation2' (dynamic) + buf := buf[offset1:] + if val4.Attestation2 == nil { + val4.Attestation2 = new(all.IndexedAttestation) + } + buflen := len(buf) + if buflen < 228 { + return sszutils.ErrorWithPathf(sszutils.ErrFixedFieldsEOFFn(buflen, 228), "AttesterSlashings[%d].Attestation2", idx1) + } + // Field #0 'AttestingIndices' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 228 { + return sszutils.ErrorWithPathf(sszutils.ErrFirstOffsetMismatchFn(offset0, 228), "AttesterSlashings[%d].Attestation2.AttestingIndices:o", idx1) + } + { // Field #1 'Data' (static) + buf := buf[4:132] + if val4.Attestation2.Data == nil { + val4.Attestation2.Data = new(phase0.AttestationData) + } + if err = val4.Attestation2.Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "AttesterSlashings[%d].Attestation2.Data", idx1) + } + } + { // Field #2 'Signature' (static) + buf := buf[132:228] + copy(val4.Attestation2.Signature[:], buf) + } + { // Field #0 'AttestingIndices' (dynamic) + buf := buf[offset0:] + val6 := val4.Attestation2.AttestingIndices + itemCount := len(buf) / 8 + if len(buf)%8 != 0 { + return sszutils.ErrorWithPathf(sszutils.ErrListNotAlignedFn(len(buf), 8), "AttesterSlashings[%d].Attestation2.AttestingIndices", idx1) + } + if itemCount > 2048 { + return sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(itemCount, 2048), "AttesterSlashings[%d].Attestation2.AttestingIndices", idx1) + } + val6 = sszutils.ExpandSlice(val6, itemCount) + sszutils.UnmarshalUint64Slice(val6, buf) + val4.Attestation2.AttestingIndices = val6 + } + } + val3[idx1] = val4 + } + t.AttesterSlashings = val3 + } + { // Field #5 'Attestations' (dynamic) + buf := buf[offset5:offset6] + val7 := t.Attestations + startOffset := int(0) + if len(buf) != 0 { + if len(buf) < 4 { + return sszutils.ErrorWithPath(sszutils.ErrListOffsetsEOFFn(len(buf), 4), "Attestations") + } + startOffset = int(binary.LittleEndian.Uint32(buf[0:4])) + } + itemCount := startOffset / 4 + if startOffset%4 != 0 || len(buf) < startOffset || (len(buf) != 0 && startOffset == 0) { + return sszutils.ErrorWithPath(sszutils.ErrInvalidListStartOffsetFn(startOffset, len(buf)), "Attestations") + } + if itemCount > int(expr3) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr3)), "Attestations") + } + val7 = sszutils.ExpandSlice(val7, itemCount) + for idx1 := range itemCount { + var endOffset int + if idx1 < itemCount-1 { + endOffset = int(binary.LittleEndian.Uint32(buf[(idx1+1)*4 : (idx1+2)*4])) + } else { + endOffset = len(buf) + } + if endOffset < startOffset || endOffset > len(buf) { + return sszutils.ErrorWithPathf(sszutils.ErrElementOffsetOutOfRangeFn(endOffset, startOffset, len(buf)), "Attestations[%d]", idx1) + } + buf := buf[startOffset:endOffset] + startOffset = endOffset + val8 := val7[idx1] + if val8 == nil { + val8 = new(all.Attestation) + } + buflen := len(buf) + if buflen < 228 { + return sszutils.ErrorWithPathf(sszutils.ErrFixedFieldsEOFFn(buflen, 228), "Attestations[%d]", idx1) + } + // Field #0 'AggregationBits' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 228 { + return sszutils.ErrorWithPathf(sszutils.ErrFirstOffsetMismatchFn(offset0, 228), "Attestations[%d].AggregationBits:o", idx1) + } + { // Field #1 'Data' (static) + buf := buf[4:132] + if val8.Data == nil { + val8.Data = new(phase0.AttestationData) + } + if err = val8.Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Attestations[%d].Data", idx1) + } + } + { // Field #2 'Signature' (static) + buf := buf[132:228] + copy(val8.Signature[:], buf) + } + { // Field #0 'AggregationBits' (dynamic) + buf := buf[offset0:] + val9 := val8.AggregationBits + blen := len(buf) + if blen == 0 || buf[blen-1] == 0x00 { + return sszutils.ErrorWithPathf(sszutils.ErrBitlistNotTerminatedFn(), "Attestations[%d].AggregationBits", idx1) + } + bitCount := 8*(blen-1) + int(bits.Len8(buf[blen-1])) - 1 + if bitCount > int(expr4) { + return sszutils.ErrorWithPathf(sszutils.ErrBitlistLengthFn(bitCount, int(expr4)), "Attestations[%d].AggregationBits", idx1) + } + val9 = sszutils.ExpandSlice(val9, blen) + copy(val9[:], buf) + val8.AggregationBits = val9 + } + val7[idx1] = val8 + } + t.Attestations = val7 + } + { // Field #6 'Deposits' (dynamic) + buf := buf[offset6:offset7] + val10 := t.Deposits + itemCount := len(buf) / size3 + if len(buf)%size3 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), size3), "Deposits") + } + if itemCount > int(expr5) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr5)), "Deposits") + } + val10 = sszutils.ExpandSlice(val10, itemCount) + for idx1 := range itemCount { + val11 := val10[idx1] + if val11 == nil { + val11 = new(phase0.Deposit) + } + buf := buf[size3*idx1 : size3*(idx1+1)] + exproffset := 0 + totalSize := size4 + 184 + buflen := len(buf) + if buflen < totalSize { + return sszutils.ErrorWithPathf(sszutils.ErrFixedFieldsEOFFn(buflen, totalSize), "Deposits[%d]", idx1) + } + if buflen > totalSize { + return sszutils.ErrorWithPathf(sszutils.ErrTrailingDataFn(buflen-totalSize), "Deposits[%d]", idx1) + } + { // Field #0 'Proof' (static) + buf := buf[0 : size4+0] + exproffset += int(size4) + val12 := val11.Proof + val12 = sszutils.ExpandSlice(val12, int(expr6)) + for idx2 := range int(expr6) { + buf := buf[32*idx2 : 32*(idx2+1)] + val12[idx2] = sszutils.ExpandSlice(val12[idx2], 32) + copy(val12[idx2][:], buf) + } + val11.Proof = val12 + } + { // Field #1 'Data' (static) + buf := buf[exproffset+0 : exproffset+184] + if val11.Data == nil { + val11.Data = new(phase0.DepositData) + } + if err = val11.Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Deposits[%d].Data", idx1) + } + } + val10[idx1] = val11 + } + t.Deposits = val10 + } + { // Field #7 'VoluntaryExits' (dynamic) + buf := buf[offset7:offset9] + val13 := t.VoluntaryExits + itemCount := len(buf) / 112 + if len(buf)%112 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 112), "VoluntaryExits") + } + if itemCount > int(expr7) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr7)), "VoluntaryExits") + } + val13 = sszutils.ExpandSlice(val13, itemCount) + for idx1 := range itemCount { + if val13[idx1] == nil { + val13[idx1] = new(phase0.SignedVoluntaryExit) + } + buf := buf[112*idx1 : 112*(idx1+1)] + if err = val13[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "VoluntaryExits[%d]", idx1) + } + } + t.VoluntaryExits = val13 + } + { // Field #9 'ExecutionPayloadHeader' (dynamic) + buf := buf[offset9:offset10] + if t.ExecutionPayloadHeader == nil { + t.ExecutionPayloadHeader = new(all.ExecutionPayloadHeader) + } + buflen := len(buf) + if buflen < 584 { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, 584), "ExecutionPayloadHeader") + } + { // Field #0 'ParentHash' (static) + buf := buf[0:32] + copy(t.ExecutionPayloadHeader.ParentHash[:], buf) + } + { // Field #1 'FeeRecipient' (static) + buf := buf[32:52] + copy(t.ExecutionPayloadHeader.FeeRecipient[:], buf) + } + { // Field #2 'StateRoot' (static) + buf := buf[52:84] + copy(t.ExecutionPayloadHeader.StateRoot[:], buf) + } + { // Field #3 'ReceiptsRoot' (static) + buf := buf[84:116] + copy(t.ExecutionPayloadHeader.ReceiptsRoot[:], buf) + } + { // Field #4 'LogsBloom' (static) + buf := buf[116:372] + copy(t.ExecutionPayloadHeader.LogsBloom[:], buf) + } + { // Field #5 'PrevRandao' (static) + buf := buf[372:404] + copy(t.ExecutionPayloadHeader.PrevRandao[:], buf) + } + { // Field #6 'BlockNumber' (static) + buf := buf[404:412] + t.ExecutionPayloadHeader.BlockNumber = binary.LittleEndian.Uint64(buf) + } + { // Field #7 'GasLimit' (static) + buf := buf[412:420] + t.ExecutionPayloadHeader.GasLimit = binary.LittleEndian.Uint64(buf) + } + { // Field #8 'GasUsed' (static) + buf := buf[420:428] + t.ExecutionPayloadHeader.GasUsed = binary.LittleEndian.Uint64(buf) + } + { // Field #9 'Timestamp' (static) + buf := buf[428:436] + t.ExecutionPayloadHeader.Timestamp = binary.LittleEndian.Uint64(buf) + } + // Field #10 'ExtraData' (offset) + offset10 := int(binary.LittleEndian.Uint32(buf[436:440])) + if offset10 != 584 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset10, 584), "ExecutionPayloadHeader.ExtraData:o") + } + { // Field #11 'BaseFeePerGas' (static) + buf := buf[440:472] + val14 := t.ExecutionPayloadHeader.BaseFeePerGas + if val14 == nil { + val14 = new(uint256.Int) + } + sszutils.UnmarshalUint64Slice((*val14)[:4], buf) + t.ExecutionPayloadHeader.BaseFeePerGas = val14 + } + { // Field #12 'BlockHash' (static) + buf := buf[472:504] + copy(t.ExecutionPayloadHeader.BlockHash[:], buf) + } + { // Field #13 'TransactionsRoot' (static) + buf := buf[504:536] + copy(t.ExecutionPayloadHeader.TransactionsRoot[:], buf) + } + { // Field #14 'WithdrawalsRoot' (static) + buf := buf[536:568] + copy(t.ExecutionPayloadHeader.WithdrawalsRoot[:], buf) + } + { // Field #15 'BlobGasUsed' (static) + buf := buf[568:576] + t.ExecutionPayloadHeader.BlobGasUsed = binary.LittleEndian.Uint64(buf) + } + { // Field #16 'ExcessBlobGas' (static) + buf := buf[576:584] + t.ExecutionPayloadHeader.ExcessBlobGas = binary.LittleEndian.Uint64(buf) + } + { // Field #10 'ExtraData' (dynamic) + buf := buf[offset10:] + if len(buf) > 32 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(len(buf), 32), "ExecutionPayloadHeader.ExtraData") + } + t.ExecutionPayloadHeader.ExtraData = sszutils.ExpandSlice(t.ExecutionPayloadHeader.ExtraData, len(buf)) + copy(t.ExecutionPayloadHeader.ExtraData[:], buf) + } + } + { // Field #10 'BLSToExecutionChanges' (dynamic) + buf := buf[offset10:offset11] + val15 := t.BLSToExecutionChanges + itemCount := len(buf) / 172 + if len(buf)%172 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 172), "BLSToExecutionChanges") + } + if itemCount > int(expr8) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr8)), "BLSToExecutionChanges") + } + val15 = sszutils.ExpandSlice(val15, itemCount) + for idx1 := range itemCount { + if val15[idx1] == nil { + val15[idx1] = new(capella1.SignedBLSToExecutionChange) + } + buf := buf[172*idx1 : 172*(idx1+1)] + if err = val15[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "BLSToExecutionChanges[%d]", idx1) + } + } + t.BLSToExecutionChanges = val15 + } + { // Field #11 'BlobKZGCommitments' (dynamic) + buf := buf[offset11:] + val16 := t.BlobKZGCommitments + itemCount := len(buf) / 48 + if len(buf)%48 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 48), "BlobKZGCommitments") + } + if itemCount > int(expr9) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr9)), "BlobKZGCommitments") + } + val16 = sszutils.ExpandSlice(val16, itemCount) + sszutils.UnmarshalFixedBytesSlice(val16[:itemCount], buf) + t.BlobKZGCommitments = val16 + } + return nil +} + +func (t *BlindedBeaconBlockBody) unmarshalSSZView_BlindedBeaconBlockBody_2(ds sszutils.DynamicSpecs, buf []byte) (err error) { + expr0, err := sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE/8", 64) + if err != nil { + return err + } + expr1, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_PROPOSER_SLASHINGS", 16) + if err != nil { + return err + } + expr2, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_ATTESTER_SLASHINGS_ELECTRA", 1) + if err != nil { + return err + } + expr3, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_VALIDATORS_PER_COMMITTEE*MAX_COMMITTEES_PER_SLOT", 131072) + if err != nil { + return err + } + expr4, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_ATTESTATIONS_ELECTRA", 8) + if err != nil { + return err + } + expr5, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_COMMITTEES_PER_SLOT/8", 8) + if err != nil { + return err + } + expr6, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_DEPOSITS", 16) + if err != nil { + return err + } + expr7, err := sszutils.ResolveSpecValueWithDefault(ds, "DEPOSIT_CONTRACT_TREE_DEPTH+1", 33) + if err != nil { + return err + } + expr8, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_VOLUNTARY_EXITS", 16) + if err != nil { + return err + } + expr9, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BLS_TO_EXECUTION_CHANGES", 16) + if err != nil { + return err + } + expr10, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BLOB_COMMITMENTS_PER_BLOCK", 4096) + if err != nil { + return err + } + expr11, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_DEPOSIT_REQUESTS_PER_PAYLOAD", 8192) + if err != nil { + return err + } + expr12, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_WITHDRAWAL_REQUESTS_PER_PAYLOAD", 16) + if err != nil { + return err + } + expr13, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD", 2) + if err != nil { + return err + } + size2 := 1 * int(expr0) + size1 := size2 + 96 // size expression for '*SyncAggregate' + size3 := 1 * int(expr5) + size5 := 32 * int(expr7) + size4 := size5 + 184 // size expression for '*Deposit' + exproffset := 0 + totalSize := size1 + 236 + buflen := len(buf) + if buflen < totalSize { + return sszutils.ErrFixedFieldsEOFFn(buflen, totalSize) + } + { // Field #0 'RANDAOReveal' (static) + buf := buf[0:96] + copy(t.RANDAOReveal[:], buf) + } + { // Field #1 'ETH1Data' (static) + buf := buf[96:168] + if t.ETH1Data == nil { + t.ETH1Data = new(phase0.ETH1Data) + } + if err = t.ETH1Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "ETH1Data") + } + } + { // Field #2 'Graffiti' (static) + buf := buf[168:200] + copy(t.Graffiti[:], buf) + } + // Field #3 'ProposerSlashings' (offset) + offset3 := int(binary.LittleEndian.Uint32(buf[200:204])) + if offset3 != totalSize { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset3, totalSize), "ProposerSlashings:o") + } + // Field #4 'AttesterSlashings' (offset) + offset4 := int(binary.LittleEndian.Uint32(buf[204:208])) + if offset4 < offset3 || offset4 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset4, offset3, buflen), "AttesterSlashings:o") + } + // Field #5 'Attestations' (offset) + offset5 := int(binary.LittleEndian.Uint32(buf[208:212])) + if offset5 < offset4 || offset5 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset5, offset4, buflen), "Attestations:o") + } + // Field #6 'Deposits' (offset) + offset6 := int(binary.LittleEndian.Uint32(buf[212:216])) + if offset6 < offset5 || offset6 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset6, offset5, buflen), "Deposits:o") + } + // Field #7 'VoluntaryExits' (offset) + offset7 := int(binary.LittleEndian.Uint32(buf[216:220])) + if offset7 < offset6 || offset7 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset7, offset6, buflen), "VoluntaryExits:o") + } + { // Field #8 'SyncAggregate' (static) + buf := buf[220 : size1+220] + exproffset += int(size1) + val1 := t.SyncAggregate + if val1 == nil { + val1 = new(altair.SyncAggregate) + } + exproffset := 0 + totalSize := size2 + 96 + buflen := len(buf) + if buflen < totalSize { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, totalSize), "SyncAggregate") + } + if buflen > totalSize { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(buflen-totalSize), "SyncAggregate") + } + { // Field #0 'SyncCommitteeBits' (static) + buf := buf[0 : size2+0] + exproffset += int(size2) + val1.SyncCommitteeBits = sszutils.ExpandSlice(val1.SyncCommitteeBits, int(expr0)) + copy(val1.SyncCommitteeBits[:], buf) + } + { // Field #1 'SyncCommitteeSignature' (static) + buf := buf[exproffset+0 : exproffset+96] + copy(val1.SyncCommitteeSignature[:], buf) + } + t.SyncAggregate = val1 + } + // Field #9 'ExecutionPayloadHeader' (offset) + offset9 := int(binary.LittleEndian.Uint32(buf[exproffset+220 : exproffset+224])) + if offset9 < offset7 || offset9 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset9, offset7, buflen), "ExecutionPayloadHeader:o") + } + // Field #10 'BLSToExecutionChanges' (offset) + offset10 := int(binary.LittleEndian.Uint32(buf[exproffset+224 : exproffset+228])) + if offset10 < offset9 || offset10 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset10, offset9, buflen), "BLSToExecutionChanges:o") + } + // Field #11 'BlobKZGCommitments' (offset) + offset11 := int(binary.LittleEndian.Uint32(buf[exproffset+228 : exproffset+232])) + if offset11 < offset10 || offset11 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset11, offset10, buflen), "BlobKZGCommitments:o") + } + // Field #12 'ExecutionRequests' (offset) + offset12 := int(binary.LittleEndian.Uint32(buf[exproffset+232 : exproffset+236])) + if offset12 < offset11 || offset12 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset12, offset11, buflen), "ExecutionRequests:o") + } + { // Field #3 'ProposerSlashings' (dynamic) + buf := buf[offset3:offset4] + val2 := t.ProposerSlashings + itemCount := len(buf) / 416 + if len(buf)%416 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 416), "ProposerSlashings") + } + if itemCount > int(expr1) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr1)), "ProposerSlashings") + } + val2 = sszutils.ExpandSlice(val2, itemCount) + for idx1 := range itemCount { + if val2[idx1] == nil { + val2[idx1] = new(phase0.ProposerSlashing) + } + buf := buf[416*idx1 : 416*(idx1+1)] + if err = val2[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "ProposerSlashings[%d]", idx1) + } + } + t.ProposerSlashings = val2 + } + { // Field #4 'AttesterSlashings' (dynamic) + buf := buf[offset4:offset5] + val3 := t.AttesterSlashings + startOffset := int(0) + if len(buf) != 0 { + if len(buf) < 4 { + return sszutils.ErrorWithPath(sszutils.ErrListOffsetsEOFFn(len(buf), 4), "AttesterSlashings") + } + startOffset = int(binary.LittleEndian.Uint32(buf[0:4])) + } + itemCount := startOffset / 4 + if startOffset%4 != 0 || len(buf) < startOffset || (len(buf) != 0 && startOffset == 0) { + return sszutils.ErrorWithPath(sszutils.ErrInvalidListStartOffsetFn(startOffset, len(buf)), "AttesterSlashings") + } + if itemCount > int(expr2) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr2)), "AttesterSlashings") + } + val3 = sszutils.ExpandSlice(val3, itemCount) + for idx1 := range itemCount { + var endOffset int + if idx1 < itemCount-1 { + endOffset = int(binary.LittleEndian.Uint32(buf[(idx1+1)*4 : (idx1+2)*4])) + } else { + endOffset = len(buf) + } + if endOffset < startOffset || endOffset > len(buf) { + return sszutils.ErrorWithPathf(sszutils.ErrElementOffsetOutOfRangeFn(endOffset, startOffset, len(buf)), "AttesterSlashings[%d]", idx1) + } + buf := buf[startOffset:endOffset] + startOffset = endOffset + val4 := val3[idx1] + if val4 == nil { + val4 = new(all.AttesterSlashing) + } + buflen := len(buf) + if buflen < 8 { + return sszutils.ErrorWithPathf(sszutils.ErrFixedFieldsEOFFn(buflen, 8), "AttesterSlashings[%d]", idx1) + } + // Field #0 'Attestation1' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 8 { + return sszutils.ErrorWithPathf(sszutils.ErrFirstOffsetMismatchFn(offset0, 8), "AttesterSlashings[%d].Attestation1:o", idx1) + } + // Field #1 'Attestation2' (offset) + offset1 := int(binary.LittleEndian.Uint32(buf[4:8])) + if offset1 < offset0 || offset1 > buflen { + return sszutils.ErrorWithPathf(sszutils.ErrOffsetOutOfRangeFn(offset1, offset0, buflen), "AttesterSlashings[%d].Attestation2:o", idx1) + } + { // Field #0 'Attestation1' (dynamic) + buf := buf[offset0:offset1] + if val4.Attestation1 == nil { + val4.Attestation1 = new(all.IndexedAttestation) + } + buflen := len(buf) + if buflen < 228 { + return sszutils.ErrorWithPathf(sszutils.ErrFixedFieldsEOFFn(buflen, 228), "AttesterSlashings[%d].Attestation1", idx1) + } + // Field #0 'AttestingIndices' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 228 { + return sszutils.ErrorWithPathf(sszutils.ErrFirstOffsetMismatchFn(offset0, 228), "AttesterSlashings[%d].Attestation1.AttestingIndices:o", idx1) + } + { // Field #1 'Data' (static) + buf := buf[4:132] + if val4.Attestation1.Data == nil { + val4.Attestation1.Data = new(phase0.AttestationData) + } + if err = val4.Attestation1.Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "AttesterSlashings[%d].Attestation1.Data", idx1) + } + } + { // Field #2 'Signature' (static) + buf := buf[132:228] + copy(val4.Attestation1.Signature[:], buf) + } + { // Field #0 'AttestingIndices' (dynamic) + buf := buf[offset0:] + val5 := val4.Attestation1.AttestingIndices + itemCount := len(buf) / 8 + if len(buf)%8 != 0 { + return sszutils.ErrorWithPathf(sszutils.ErrListNotAlignedFn(len(buf), 8), "AttesterSlashings[%d].Attestation1.AttestingIndices", idx1) + } + if itemCount > int(expr3) { + return sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(itemCount, int(expr3)), "AttesterSlashings[%d].Attestation1.AttestingIndices", idx1) + } + val5 = sszutils.ExpandSlice(val5, itemCount) + sszutils.UnmarshalUint64Slice(val5, buf) + val4.Attestation1.AttestingIndices = val5 + } + } + { // Field #1 'Attestation2' (dynamic) + buf := buf[offset1:] + if val4.Attestation2 == nil { + val4.Attestation2 = new(all.IndexedAttestation) + } + buflen := len(buf) + if buflen < 228 { + return sszutils.ErrorWithPathf(sszutils.ErrFixedFieldsEOFFn(buflen, 228), "AttesterSlashings[%d].Attestation2", idx1) + } + // Field #0 'AttestingIndices' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 228 { + return sszutils.ErrorWithPathf(sszutils.ErrFirstOffsetMismatchFn(offset0, 228), "AttesterSlashings[%d].Attestation2.AttestingIndices:o", idx1) + } + { // Field #1 'Data' (static) + buf := buf[4:132] + if val4.Attestation2.Data == nil { + val4.Attestation2.Data = new(phase0.AttestationData) + } + if err = val4.Attestation2.Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "AttesterSlashings[%d].Attestation2.Data", idx1) + } + } + { // Field #2 'Signature' (static) + buf := buf[132:228] + copy(val4.Attestation2.Signature[:], buf) + } + { // Field #0 'AttestingIndices' (dynamic) + buf := buf[offset0:] + val6 := val4.Attestation2.AttestingIndices + itemCount := len(buf) / 8 + if len(buf)%8 != 0 { + return sszutils.ErrorWithPathf(sszutils.ErrListNotAlignedFn(len(buf), 8), "AttesterSlashings[%d].Attestation2.AttestingIndices", idx1) + } + if itemCount > int(expr3) { + return sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(itemCount, int(expr3)), "AttesterSlashings[%d].Attestation2.AttestingIndices", idx1) + } + val6 = sszutils.ExpandSlice(val6, itemCount) + sszutils.UnmarshalUint64Slice(val6, buf) + val4.Attestation2.AttestingIndices = val6 + } + } + val3[idx1] = val4 + } + t.AttesterSlashings = val3 + } + { // Field #5 'Attestations' (dynamic) + buf := buf[offset5:offset6] + val7 := t.Attestations + startOffset := int(0) + if len(buf) != 0 { + if len(buf) < 4 { + return sszutils.ErrorWithPath(sszutils.ErrListOffsetsEOFFn(len(buf), 4), "Attestations") + } + startOffset = int(binary.LittleEndian.Uint32(buf[0:4])) + } + itemCount := startOffset / 4 + if startOffset%4 != 0 || len(buf) < startOffset || (len(buf) != 0 && startOffset == 0) { + return sszutils.ErrorWithPath(sszutils.ErrInvalidListStartOffsetFn(startOffset, len(buf)), "Attestations") + } + if itemCount > int(expr4) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr4)), "Attestations") + } + val7 = sszutils.ExpandSlice(val7, itemCount) + for idx1 := range itemCount { + var endOffset int + if idx1 < itemCount-1 { + endOffset = int(binary.LittleEndian.Uint32(buf[(idx1+1)*4 : (idx1+2)*4])) + } else { + endOffset = len(buf) + } + if endOffset < startOffset || endOffset > len(buf) { + return sszutils.ErrorWithPathf(sszutils.ErrElementOffsetOutOfRangeFn(endOffset, startOffset, len(buf)), "Attestations[%d]", idx1) + } + buf := buf[startOffset:endOffset] + startOffset = endOffset + val8 := val7[idx1] + if val8 == nil { + val8 = new(all.Attestation) + } + exproffset := 0 + totalSize := size3 + 228 + buflen := len(buf) + if buflen < totalSize { + return sszutils.ErrorWithPathf(sszutils.ErrFixedFieldsEOFFn(buflen, totalSize), "Attestations[%d]", idx1) + } + // Field #0 'AggregationBits' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != totalSize { + return sszutils.ErrorWithPathf(sszutils.ErrFirstOffsetMismatchFn(offset0, totalSize), "Attestations[%d].AggregationBits:o", idx1) + } + { // Field #1 'Data' (static) + buf := buf[4:132] + if val8.Data == nil { + val8.Data = new(phase0.AttestationData) + } + if err = val8.Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Attestations[%d].Data", idx1) + } + } + { // Field #2 'Signature' (static) + buf := buf[132:228] + copy(val8.Signature[:], buf) + } + { // Field #3 'CommitteeBits' (static) + buf := buf[228 : size3+228] + exproffset += int(size3) + val8.CommitteeBits = sszutils.ExpandSlice(val8.CommitteeBits, int(expr5)) + copy(val8.CommitteeBits[:], buf) + } + { // Field #0 'AggregationBits' (dynamic) + buf := buf[offset0:] + val9 := val8.AggregationBits + blen := len(buf) + if blen == 0 || buf[blen-1] == 0x00 { + return sszutils.ErrorWithPathf(sszutils.ErrBitlistNotTerminatedFn(), "Attestations[%d].AggregationBits", idx1) + } + bitCount := 8*(blen-1) + int(bits.Len8(buf[blen-1])) - 1 + if bitCount > int(expr3) { + return sszutils.ErrorWithPathf(sszutils.ErrBitlistLengthFn(bitCount, int(expr3)), "Attestations[%d].AggregationBits", idx1) + } + val9 = sszutils.ExpandSlice(val9, blen) + copy(val9[:], buf) + val8.AggregationBits = val9 + } + val7[idx1] = val8 + } + t.Attestations = val7 + } + { // Field #6 'Deposits' (dynamic) + buf := buf[offset6:offset7] + val10 := t.Deposits + itemCount := len(buf) / size4 + if len(buf)%size4 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), size4), "Deposits") + } + if itemCount > int(expr6) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "Deposits") + } + val10 = sszutils.ExpandSlice(val10, itemCount) + for idx1 := range itemCount { + val11 := val10[idx1] + if val11 == nil { + val11 = new(phase0.Deposit) + } + buf := buf[size4*idx1 : size4*(idx1+1)] + exproffset := 0 + totalSize := size5 + 184 + buflen := len(buf) + if buflen < totalSize { + return sszutils.ErrorWithPathf(sszutils.ErrFixedFieldsEOFFn(buflen, totalSize), "Deposits[%d]", idx1) + } + if buflen > totalSize { + return sszutils.ErrorWithPathf(sszutils.ErrTrailingDataFn(buflen-totalSize), "Deposits[%d]", idx1) + } + { // Field #0 'Proof' (static) + buf := buf[0 : size5+0] + exproffset += int(size5) + val12 := val11.Proof + val12 = sszutils.ExpandSlice(val12, int(expr7)) + for idx2 := range int(expr7) { + buf := buf[32*idx2 : 32*(idx2+1)] + val12[idx2] = sszutils.ExpandSlice(val12[idx2], 32) + copy(val12[idx2][:], buf) + } + val11.Proof = val12 + } + { // Field #1 'Data' (static) + buf := buf[exproffset+0 : exproffset+184] + if val11.Data == nil { + val11.Data = new(phase0.DepositData) + } + if err = val11.Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Deposits[%d].Data", idx1) + } + } + val10[idx1] = val11 + } + t.Deposits = val10 + } + { // Field #7 'VoluntaryExits' (dynamic) + buf := buf[offset7:offset9] + val13 := t.VoluntaryExits + itemCount := len(buf) / 112 + if len(buf)%112 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 112), "VoluntaryExits") + } + if itemCount > int(expr8) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr8)), "VoluntaryExits") + } + val13 = sszutils.ExpandSlice(val13, itemCount) + for idx1 := range itemCount { + if val13[idx1] == nil { + val13[idx1] = new(phase0.SignedVoluntaryExit) + } + buf := buf[112*idx1 : 112*(idx1+1)] + if err = val13[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "VoluntaryExits[%d]", idx1) + } + } + t.VoluntaryExits = val13 + } + { // Field #9 'ExecutionPayloadHeader' (dynamic) + buf := buf[offset9:offset10] + if t.ExecutionPayloadHeader == nil { + t.ExecutionPayloadHeader = new(all.ExecutionPayloadHeader) + } + buflen := len(buf) + if buflen < 584 { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, 584), "ExecutionPayloadHeader") + } + { // Field #0 'ParentHash' (static) + buf := buf[0:32] + copy(t.ExecutionPayloadHeader.ParentHash[:], buf) + } + { // Field #1 'FeeRecipient' (static) + buf := buf[32:52] + copy(t.ExecutionPayloadHeader.FeeRecipient[:], buf) + } + { // Field #2 'StateRoot' (static) + buf := buf[52:84] + copy(t.ExecutionPayloadHeader.StateRoot[:], buf) + } + { // Field #3 'ReceiptsRoot' (static) + buf := buf[84:116] + copy(t.ExecutionPayloadHeader.ReceiptsRoot[:], buf) + } + { // Field #4 'LogsBloom' (static) + buf := buf[116:372] + copy(t.ExecutionPayloadHeader.LogsBloom[:], buf) + } + { // Field #5 'PrevRandao' (static) + buf := buf[372:404] + copy(t.ExecutionPayloadHeader.PrevRandao[:], buf) + } + { // Field #6 'BlockNumber' (static) + buf := buf[404:412] + t.ExecutionPayloadHeader.BlockNumber = binary.LittleEndian.Uint64(buf) + } + { // Field #7 'GasLimit' (static) + buf := buf[412:420] + t.ExecutionPayloadHeader.GasLimit = binary.LittleEndian.Uint64(buf) + } + { // Field #8 'GasUsed' (static) + buf := buf[420:428] + t.ExecutionPayloadHeader.GasUsed = binary.LittleEndian.Uint64(buf) + } + { // Field #9 'Timestamp' (static) + buf := buf[428:436] + t.ExecutionPayloadHeader.Timestamp = binary.LittleEndian.Uint64(buf) + } + // Field #10 'ExtraData' (offset) + offset10 := int(binary.LittleEndian.Uint32(buf[436:440])) + if offset10 != 584 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset10, 584), "ExecutionPayloadHeader.ExtraData:o") + } + { // Field #11 'BaseFeePerGas' (static) + buf := buf[440:472] + val14 := t.ExecutionPayloadHeader.BaseFeePerGas + if val14 == nil { + val14 = new(uint256.Int) + } + sszutils.UnmarshalUint64Slice((*val14)[:4], buf) + t.ExecutionPayloadHeader.BaseFeePerGas = val14 + } + { // Field #12 'BlockHash' (static) + buf := buf[472:504] + copy(t.ExecutionPayloadHeader.BlockHash[:], buf) + } + { // Field #13 'TransactionsRoot' (static) + buf := buf[504:536] + copy(t.ExecutionPayloadHeader.TransactionsRoot[:], buf) + } + { // Field #14 'WithdrawalsRoot' (static) + buf := buf[536:568] + copy(t.ExecutionPayloadHeader.WithdrawalsRoot[:], buf) + } + { // Field #15 'BlobGasUsed' (static) + buf := buf[568:576] + t.ExecutionPayloadHeader.BlobGasUsed = binary.LittleEndian.Uint64(buf) + } + { // Field #16 'ExcessBlobGas' (static) + buf := buf[576:584] + t.ExecutionPayloadHeader.ExcessBlobGas = binary.LittleEndian.Uint64(buf) + } + { // Field #10 'ExtraData' (dynamic) + buf := buf[offset10:] + if len(buf) > 32 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(len(buf), 32), "ExecutionPayloadHeader.ExtraData") + } + t.ExecutionPayloadHeader.ExtraData = sszutils.ExpandSlice(t.ExecutionPayloadHeader.ExtraData, len(buf)) + copy(t.ExecutionPayloadHeader.ExtraData[:], buf) + } + } + { // Field #10 'BLSToExecutionChanges' (dynamic) + buf := buf[offset10:offset11] + val15 := t.BLSToExecutionChanges + itemCount := len(buf) / 172 + if len(buf)%172 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 172), "BLSToExecutionChanges") + } + if itemCount > int(expr9) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr9)), "BLSToExecutionChanges") + } + val15 = sszutils.ExpandSlice(val15, itemCount) + for idx1 := range itemCount { + if val15[idx1] == nil { + val15[idx1] = new(capella1.SignedBLSToExecutionChange) + } + buf := buf[172*idx1 : 172*(idx1+1)] + if err = val15[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "BLSToExecutionChanges[%d]", idx1) + } + } + t.BLSToExecutionChanges = val15 + } + { // Field #11 'BlobKZGCommitments' (dynamic) + buf := buf[offset11:offset12] + val16 := t.BlobKZGCommitments + itemCount := len(buf) / 48 + if len(buf)%48 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 48), "BlobKZGCommitments") + } + if itemCount > int(expr10) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr10)), "BlobKZGCommitments") + } + val16 = sszutils.ExpandSlice(val16, itemCount) + sszutils.UnmarshalFixedBytesSlice(val16[:itemCount], buf) + t.BlobKZGCommitments = val16 + } + { // Field #12 'ExecutionRequests' (dynamic) + buf := buf[offset12:] + if t.ExecutionRequests == nil { + t.ExecutionRequests = new(all.ExecutionRequests) + } + buflen := len(buf) + if buflen < 12 { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, 12), "ExecutionRequests") + } + // Field #0 'Deposits' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 12 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset0, 12), "ExecutionRequests.Deposits:o") + } + // Field #1 'Withdrawals' (offset) + offset1 := int(binary.LittleEndian.Uint32(buf[4:8])) + if offset1 < offset0 || offset1 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset1, offset0, buflen), "ExecutionRequests.Withdrawals:o") + } + // Field #2 'Consolidations' (offset) + offset2 := int(binary.LittleEndian.Uint32(buf[8:12])) + if offset2 < offset1 || offset2 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset2, offset1, buflen), "ExecutionRequests.Consolidations:o") + } + { // Field #0 'Deposits' (dynamic) + buf := buf[offset0:offset1] + val17 := t.ExecutionRequests.Deposits + itemCount := len(buf) / 192 + if len(buf)%192 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 192), "ExecutionRequests.Deposits") + } + if itemCount > int(expr11) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr11)), "ExecutionRequests.Deposits") + } + val17 = sszutils.ExpandSlice(val17, itemCount) + for idx1 := range itemCount { + if val17[idx1] == nil { + val17[idx1] = new(electra1.DepositRequest) + } + buf := buf[192*idx1 : 192*(idx1+1)] + if err = val17[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "ExecutionRequests.Deposits[%d]", idx1) + } + } + t.ExecutionRequests.Deposits = val17 + } + { // Field #1 'Withdrawals' (dynamic) + buf := buf[offset1:offset2] + val18 := t.ExecutionRequests.Withdrawals + itemCount := len(buf) / 76 + if len(buf)%76 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 76), "ExecutionRequests.Withdrawals") + } + if itemCount > int(expr12) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr12)), "ExecutionRequests.Withdrawals") + } + val18 = sszutils.ExpandSlice(val18, itemCount) + for idx1 := range itemCount { + if val18[idx1] == nil { + val18[idx1] = new(electra1.WithdrawalRequest) + } + buf := buf[76*idx1 : 76*(idx1+1)] + if err = val18[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "ExecutionRequests.Withdrawals[%d]", idx1) + } + } + t.ExecutionRequests.Withdrawals = val18 + } + { // Field #2 'Consolidations' (dynamic) + buf := buf[offset2:] + val19 := t.ExecutionRequests.Consolidations + itemCount := len(buf) / 116 + if len(buf)%116 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 116), "ExecutionRequests.Consolidations") + } + if itemCount > int(expr13) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr13)), "ExecutionRequests.Consolidations") + } + val19 = sszutils.ExpandSlice(val19, itemCount) + for idx1 := range itemCount { + if val19[idx1] == nil { + val19[idx1] = new(electra1.ConsolidationRequest) + } + buf := buf[116*idx1 : 116*(idx1+1)] + if err = val19[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "ExecutionRequests.Consolidations[%d]", idx1) + } + } + t.ExecutionRequests.Consolidations = val19 + } + } + return nil +} + +func (t *BlindedBeaconBlockBody) SizeSSZDynView(view any) func(ds sszutils.DynamicSpecs) int { + switch view.(type) { + case *bellatrix.BlindedBeaconBlockBody: + return t.sizeSSZView_BlindedBeaconBlockBody + case *capella.BlindedBeaconBlockBody: + return t.sizeSSZView_BlindedBeaconBlockBody_0 + case *deneb.BlindedBeaconBlockBody: + return t.sizeSSZView_BlindedBeaconBlockBody_1 + case *electra.BlindedBeaconBlockBody: + return t.sizeSSZView_BlindedBeaconBlockBody_2 + } + return nil +} +func (t *BlindedBeaconBlockBody) sizeSSZView_BlindedBeaconBlockBody(ds sszutils.DynamicSpecs) (size int) { + expr0, err := sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE/8", 64) + if err != nil { + return 0 + } + expr1, err := sszutils.ResolveSpecValueWithDefault(ds, "DEPOSIT_CONTRACT_TREE_DEPTH+1", 33) + if err != nil { + return 0 + } + if t == nil { + t = new(BlindedBeaconBlockBody) + } + // Field #0 'RANDAOReveal' static (96 bytes) + // Field #1 'ETH1Data' static (72 bytes) + // Field #2 'Graffiti' static (32 bytes) + // Field #3 'ProposerSlashings' offset (4 bytes) + // Field #4 'AttesterSlashings' offset (4 bytes) + // Field #5 'Attestations' offset (4 bytes) + // Field #6 'Deposits' offset (4 bytes) + // Field #7 'VoluntaryExits' offset (4 bytes) + // Field #9 'ExecutionPayloadHeader' offset (4 bytes) + size += 224 + { // Field #8 'SyncAggregate' + t := t.SyncAggregate + if t == nil { + t = new(altair.SyncAggregate) + } + // Field #1 'SyncCommitteeSignature' static (96 bytes) + size += 96 + { // Field #0 'SyncCommitteeBits' + size += int(expr0) + } + } + { // Dynamic field #3 'ProposerSlashings' + size += len(t.ProposerSlashings) * 416 + } + { // Dynamic field #4 'AttesterSlashings' + t := t.AttesterSlashings + vlen := len(t) + size += vlen * 4 // Offsets + for i1 := range vlen { + t := t[i1] + if t == nil { + t = new(all.AttesterSlashing) + } + // Field #0 'Attestation1' offset (4 bytes) + // Field #1 'Attestation2' offset (4 bytes) + size += 8 + { // Dynamic field #0 'Attestation1' + t := t.Attestation1 + if t == nil { + t = new(all.IndexedAttestation) + } + // Field #0 'AttestingIndices' offset (4 bytes) + // Field #1 'Data' static (128 bytes) + // Field #2 'Signature' static (96 bytes) + size += 228 + { // Dynamic field #0 'AttestingIndices' + size += len(t.AttestingIndices) * 8 + } + } + { // Dynamic field #1 'Attestation2' + t := t.Attestation2 + if t == nil { + t = new(all.IndexedAttestation) + } + // Field #0 'AttestingIndices' offset (4 bytes) + // Field #1 'Data' static (128 bytes) + // Field #2 'Signature' static (96 bytes) + size += 228 + { // Dynamic field #0 'AttestingIndices' + size += len(t.AttestingIndices) * 8 + } + } + } + } + { // Dynamic field #5 'Attestations' + t := t.Attestations + vlen := len(t) + size += vlen * 4 // Offsets + for i2 := range vlen { + t := t[i2] + if t == nil { + t = new(all.Attestation) + } + // Field #0 'AggregationBits' offset (4 bytes) + // Field #1 'Data' static (128 bytes) + // Field #2 'Signature' static (96 bytes) + size += 228 + { // Dynamic field #0 'AggregationBits' + if len(t.AggregationBits) == 0 { + size += 1 + } else { + size += len(t.AggregationBits) + } + } + } + } + { // Dynamic field #6 'Deposits' + t := t.Deposits + vlen := len(t) + if vlen > 0 { + s1 := 0 + t := t[0] + if t == nil { + t = new(phase0.Deposit) + } + // Field #1 'Data' static (184 bytes) + s1 += 184 + { // Field #0 'Proof' + s1 += int(expr1) * 32 + } + size += s1 * vlen + } + } + { // Dynamic field #7 'VoluntaryExits' + size += len(t.VoluntaryExits) * 112 + } + { // Dynamic field #9 'ExecutionPayloadHeader' + t := t.ExecutionPayloadHeader + if t == nil { + t = new(all.ExecutionPayloadHeader) + } + // Field #0 'ParentHash' static (32 bytes) + // Field #1 'FeeRecipient' static (20 bytes) + // Field #2 'StateRoot' static (32 bytes) + // Field #3 'ReceiptsRoot' static (32 bytes) + // Field #4 'LogsBloom' static (256 bytes) + // Field #5 'PrevRandao' static (32 bytes) + // Field #6 'BlockNumber' static (8 bytes) + // Field #7 'GasLimit' static (8 bytes) + // Field #8 'GasUsed' static (8 bytes) + // Field #9 'Timestamp' static (8 bytes) + // Field #10 'ExtraData' offset (4 bytes) + // Field #11 'BaseFeePerGasLE' static (32 bytes) + // Field #12 'BlockHash' static (32 bytes) + // Field #13 'TransactionsRoot' static (32 bytes) + size += 536 + { // Dynamic field #10 'ExtraData' + size += len(t.ExtraData) + } + } + return size +} + +func (t *BlindedBeaconBlockBody) sizeSSZView_BlindedBeaconBlockBody_0(ds sszutils.DynamicSpecs) (size int) { + expr0, err := sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE/8", 64) + if err != nil { + return 0 + } + expr1, err := sszutils.ResolveSpecValueWithDefault(ds, "DEPOSIT_CONTRACT_TREE_DEPTH+1", 33) + if err != nil { + return 0 + } + if t == nil { + t = new(BlindedBeaconBlockBody) + } + // Field #0 'RANDAOReveal' static (96 bytes) + // Field #1 'ETH1Data' static (72 bytes) + // Field #2 'Graffiti' static (32 bytes) + // Field #3 'ProposerSlashings' offset (4 bytes) + // Field #4 'AttesterSlashings' offset (4 bytes) + // Field #5 'Attestations' offset (4 bytes) + // Field #6 'Deposits' offset (4 bytes) + // Field #7 'VoluntaryExits' offset (4 bytes) + // Field #9 'ExecutionPayloadHeader' offset (4 bytes) + // Field #10 'BLSToExecutionChanges' offset (4 bytes) + size += 228 + { // Field #8 'SyncAggregate' + t := t.SyncAggregate + if t == nil { + t = new(altair.SyncAggregate) + } + // Field #1 'SyncCommitteeSignature' static (96 bytes) + size += 96 + { // Field #0 'SyncCommitteeBits' + size += int(expr0) + } + } + { // Dynamic field #3 'ProposerSlashings' + size += len(t.ProposerSlashings) * 416 + } + { // Dynamic field #4 'AttesterSlashings' + t := t.AttesterSlashings + vlen := len(t) + size += vlen * 4 // Offsets + for i1 := range vlen { + t := t[i1] + if t == nil { + t = new(all.AttesterSlashing) + } + // Field #0 'Attestation1' offset (4 bytes) + // Field #1 'Attestation2' offset (4 bytes) + size += 8 + { // Dynamic field #0 'Attestation1' + t := t.Attestation1 + if t == nil { + t = new(all.IndexedAttestation) + } + // Field #0 'AttestingIndices' offset (4 bytes) + // Field #1 'Data' static (128 bytes) + // Field #2 'Signature' static (96 bytes) + size += 228 + { // Dynamic field #0 'AttestingIndices' + size += len(t.AttestingIndices) * 8 + } + } + { // Dynamic field #1 'Attestation2' + t := t.Attestation2 + if t == nil { + t = new(all.IndexedAttestation) + } + // Field #0 'AttestingIndices' offset (4 bytes) + // Field #1 'Data' static (128 bytes) + // Field #2 'Signature' static (96 bytes) + size += 228 + { // Dynamic field #0 'AttestingIndices' + size += len(t.AttestingIndices) * 8 + } + } + } + } + { // Dynamic field #5 'Attestations' + t := t.Attestations + vlen := len(t) + size += vlen * 4 // Offsets + for i2 := range vlen { + t := t[i2] + if t == nil { + t = new(all.Attestation) + } + // Field #0 'AggregationBits' offset (4 bytes) + // Field #1 'Data' static (128 bytes) + // Field #2 'Signature' static (96 bytes) + size += 228 + { // Dynamic field #0 'AggregationBits' + if len(t.AggregationBits) == 0 { + size += 1 + } else { + size += len(t.AggregationBits) + } + } + } + } + { // Dynamic field #6 'Deposits' + t := t.Deposits + vlen := len(t) + if vlen > 0 { + s1 := 0 + t := t[0] + if t == nil { + t = new(phase0.Deposit) + } + // Field #1 'Data' static (184 bytes) + s1 += 184 + { // Field #0 'Proof' + s1 += int(expr1) * 32 + } + size += s1 * vlen + } + } + { // Dynamic field #7 'VoluntaryExits' + size += len(t.VoluntaryExits) * 112 + } + { // Dynamic field #9 'ExecutionPayloadHeader' + t := t.ExecutionPayloadHeader + if t == nil { + t = new(all.ExecutionPayloadHeader) + } + // Field #0 'ParentHash' static (32 bytes) + // Field #1 'FeeRecipient' static (20 bytes) + // Field #2 'StateRoot' static (32 bytes) + // Field #3 'ReceiptsRoot' static (32 bytes) + // Field #4 'LogsBloom' static (256 bytes) + // Field #5 'PrevRandao' static (32 bytes) + // Field #6 'BlockNumber' static (8 bytes) + // Field #7 'GasLimit' static (8 bytes) + // Field #8 'GasUsed' static (8 bytes) + // Field #9 'Timestamp' static (8 bytes) + // Field #10 'ExtraData' offset (4 bytes) + // Field #11 'BaseFeePerGasLE' static (32 bytes) + // Field #12 'BlockHash' static (32 bytes) + // Field #13 'TransactionsRoot' static (32 bytes) + // Field #14 'WithdrawalsRoot' static (32 bytes) + size += 568 + { // Dynamic field #10 'ExtraData' + size += len(t.ExtraData) + } + } + { // Dynamic field #10 'BLSToExecutionChanges' + size += len(t.BLSToExecutionChanges) * 172 + } + return size +} + +func (t *BlindedBeaconBlockBody) sizeSSZView_BlindedBeaconBlockBody_1(ds sszutils.DynamicSpecs) (size int) { + expr0, err := sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE/8", 64) + if err != nil { + return 0 + } + expr1, err := sszutils.ResolveSpecValueWithDefault(ds, "DEPOSIT_CONTRACT_TREE_DEPTH+1", 33) + if err != nil { + return 0 + } + if t == nil { + t = new(BlindedBeaconBlockBody) + } + // Field #0 'RANDAOReveal' static (96 bytes) + // Field #1 'ETH1Data' static (72 bytes) + // Field #2 'Graffiti' static (32 bytes) + // Field #3 'ProposerSlashings' offset (4 bytes) + // Field #4 'AttesterSlashings' offset (4 bytes) + // Field #5 'Attestations' offset (4 bytes) + // Field #6 'Deposits' offset (4 bytes) + // Field #7 'VoluntaryExits' offset (4 bytes) + // Field #9 'ExecutionPayloadHeader' offset (4 bytes) + // Field #10 'BLSToExecutionChanges' offset (4 bytes) + // Field #11 'BlobKZGCommitments' offset (4 bytes) + size += 232 + { // Field #8 'SyncAggregate' + t := t.SyncAggregate + if t == nil { + t = new(altair.SyncAggregate) + } + // Field #1 'SyncCommitteeSignature' static (96 bytes) + size += 96 + { // Field #0 'SyncCommitteeBits' + size += int(expr0) + } + } + { // Dynamic field #3 'ProposerSlashings' + size += len(t.ProposerSlashings) * 416 + } + { // Dynamic field #4 'AttesterSlashings' + t := t.AttesterSlashings + vlen := len(t) + size += vlen * 4 // Offsets + for i1 := range vlen { + t := t[i1] + if t == nil { + t = new(all.AttesterSlashing) + } + // Field #0 'Attestation1' offset (4 bytes) + // Field #1 'Attestation2' offset (4 bytes) + size += 8 + { // Dynamic field #0 'Attestation1' + t := t.Attestation1 + if t == nil { + t = new(all.IndexedAttestation) + } + // Field #0 'AttestingIndices' offset (4 bytes) + // Field #1 'Data' static (128 bytes) + // Field #2 'Signature' static (96 bytes) + size += 228 + { // Dynamic field #0 'AttestingIndices' + size += len(t.AttestingIndices) * 8 + } + } + { // Dynamic field #1 'Attestation2' + t := t.Attestation2 + if t == nil { + t = new(all.IndexedAttestation) + } + // Field #0 'AttestingIndices' offset (4 bytes) + // Field #1 'Data' static (128 bytes) + // Field #2 'Signature' static (96 bytes) + size += 228 + { // Dynamic field #0 'AttestingIndices' + size += len(t.AttestingIndices) * 8 + } + } + } + } + { // Dynamic field #5 'Attestations' + t := t.Attestations + vlen := len(t) + size += vlen * 4 // Offsets + for i2 := range vlen { + t := t[i2] + if t == nil { + t = new(all.Attestation) + } + // Field #0 'AggregationBits' offset (4 bytes) + // Field #1 'Data' static (128 bytes) + // Field #2 'Signature' static (96 bytes) + size += 228 + { // Dynamic field #0 'AggregationBits' + if len(t.AggregationBits) == 0 { + size += 1 + } else { + size += len(t.AggregationBits) + } + } + } + } + { // Dynamic field #6 'Deposits' + t := t.Deposits + vlen := len(t) + if vlen > 0 { + s1 := 0 + t := t[0] + if t == nil { + t = new(phase0.Deposit) + } + // Field #1 'Data' static (184 bytes) + s1 += 184 + { // Field #0 'Proof' + s1 += int(expr1) * 32 + } + size += s1 * vlen + } + } + { // Dynamic field #7 'VoluntaryExits' + size += len(t.VoluntaryExits) * 112 + } + { // Dynamic field #9 'ExecutionPayloadHeader' + t := t.ExecutionPayloadHeader + if t == nil { + t = new(all.ExecutionPayloadHeader) + } + // Field #0 'ParentHash' static (32 bytes) + // Field #1 'FeeRecipient' static (20 bytes) + // Field #2 'StateRoot' static (32 bytes) + // Field #3 'ReceiptsRoot' static (32 bytes) + // Field #4 'LogsBloom' static (256 bytes) + // Field #5 'PrevRandao' static (32 bytes) + // Field #6 'BlockNumber' static (8 bytes) + // Field #7 'GasLimit' static (8 bytes) + // Field #8 'GasUsed' static (8 bytes) + // Field #9 'Timestamp' static (8 bytes) + // Field #10 'ExtraData' offset (4 bytes) + // Field #11 'BaseFeePerGas' static (32 bytes) + // Field #12 'BlockHash' static (32 bytes) + // Field #13 'TransactionsRoot' static (32 bytes) + // Field #14 'WithdrawalsRoot' static (32 bytes) + // Field #15 'BlobGasUsed' static (8 bytes) + // Field #16 'ExcessBlobGas' static (8 bytes) + size += 584 + { // Dynamic field #10 'ExtraData' + size += len(t.ExtraData) + } + } + { // Dynamic field #10 'BLSToExecutionChanges' + size += len(t.BLSToExecutionChanges) * 172 + } + { // Dynamic field #11 'BlobKZGCommitments' + size += len(t.BlobKZGCommitments) * 48 + } + return size +} + +func (t *BlindedBeaconBlockBody) sizeSSZView_BlindedBeaconBlockBody_2(ds sszutils.DynamicSpecs) (size int) { + expr0, err := sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE/8", 64) + if err != nil { + return 0 + } + expr1, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_COMMITTEES_PER_SLOT/8", 8) + if err != nil { + return 0 + } + expr2, err := sszutils.ResolveSpecValueWithDefault(ds, "DEPOSIT_CONTRACT_TREE_DEPTH+1", 33) + if err != nil { + return 0 + } + if t == nil { + t = new(BlindedBeaconBlockBody) + } + // Field #0 'RANDAOReveal' static (96 bytes) + // Field #1 'ETH1Data' static (72 bytes) + // Field #2 'Graffiti' static (32 bytes) + // Field #3 'ProposerSlashings' offset (4 bytes) + // Field #4 'AttesterSlashings' offset (4 bytes) + // Field #5 'Attestations' offset (4 bytes) + // Field #6 'Deposits' offset (4 bytes) + // Field #7 'VoluntaryExits' offset (4 bytes) + // Field #9 'ExecutionPayloadHeader' offset (4 bytes) + // Field #10 'BLSToExecutionChanges' offset (4 bytes) + // Field #11 'BlobKZGCommitments' offset (4 bytes) + // Field #12 'ExecutionRequests' offset (4 bytes) + size += 236 + { // Field #8 'SyncAggregate' + t := t.SyncAggregate + if t == nil { + t = new(altair.SyncAggregate) + } + // Field #1 'SyncCommitteeSignature' static (96 bytes) + size += 96 + { // Field #0 'SyncCommitteeBits' + size += int(expr0) + } + } + { // Dynamic field #3 'ProposerSlashings' + size += len(t.ProposerSlashings) * 416 + } + { // Dynamic field #4 'AttesterSlashings' + t := t.AttesterSlashings + vlen := len(t) + size += vlen * 4 // Offsets + for i1 := range vlen { + t := t[i1] + if t == nil { + t = new(all.AttesterSlashing) + } + // Field #0 'Attestation1' offset (4 bytes) + // Field #1 'Attestation2' offset (4 bytes) + size += 8 + { // Dynamic field #0 'Attestation1' + t := t.Attestation1 + if t == nil { + t = new(all.IndexedAttestation) + } + // Field #0 'AttestingIndices' offset (4 bytes) + // Field #1 'Data' static (128 bytes) + // Field #2 'Signature' static (96 bytes) + size += 228 + { // Dynamic field #0 'AttestingIndices' + size += len(t.AttestingIndices) * 8 + } + } + { // Dynamic field #1 'Attestation2' + t := t.Attestation2 + if t == nil { + t = new(all.IndexedAttestation) + } + // Field #0 'AttestingIndices' offset (4 bytes) + // Field #1 'Data' static (128 bytes) + // Field #2 'Signature' static (96 bytes) + size += 228 + { // Dynamic field #0 'AttestingIndices' + size += len(t.AttestingIndices) * 8 + } + } + } + } + { // Dynamic field #5 'Attestations' + t := t.Attestations + vlen := len(t) + size += vlen * 4 // Offsets + for i2 := range vlen { + t := t[i2] + if t == nil { + t = new(all.Attestation) + } + // Field #0 'AggregationBits' offset (4 bytes) + // Field #1 'Data' static (128 bytes) + // Field #2 'Signature' static (96 bytes) + size += 228 + { // Field #3 'CommitteeBits' + size += int(expr1) + } + { // Dynamic field #0 'AggregationBits' + if len(t.AggregationBits) == 0 { + size += 1 + } else { + size += len(t.AggregationBits) + } + } + } + } + { // Dynamic field #6 'Deposits' + t := t.Deposits + vlen := len(t) + if vlen > 0 { + s1 := 0 + t := t[0] + if t == nil { + t = new(phase0.Deposit) + } + // Field #1 'Data' static (184 bytes) + s1 += 184 + { // Field #0 'Proof' + s1 += int(expr2) * 32 + } + size += s1 * vlen + } + } + { // Dynamic field #7 'VoluntaryExits' + size += len(t.VoluntaryExits) * 112 + } + { // Dynamic field #9 'ExecutionPayloadHeader' + t := t.ExecutionPayloadHeader + if t == nil { + t = new(all.ExecutionPayloadHeader) + } + // Field #0 'ParentHash' static (32 bytes) + // Field #1 'FeeRecipient' static (20 bytes) + // Field #2 'StateRoot' static (32 bytes) + // Field #3 'ReceiptsRoot' static (32 bytes) + // Field #4 'LogsBloom' static (256 bytes) + // Field #5 'PrevRandao' static (32 bytes) + // Field #6 'BlockNumber' static (8 bytes) + // Field #7 'GasLimit' static (8 bytes) + // Field #8 'GasUsed' static (8 bytes) + // Field #9 'Timestamp' static (8 bytes) + // Field #10 'ExtraData' offset (4 bytes) + // Field #11 'BaseFeePerGas' static (32 bytes) + // Field #12 'BlockHash' static (32 bytes) + // Field #13 'TransactionsRoot' static (32 bytes) + // Field #14 'WithdrawalsRoot' static (32 bytes) + // Field #15 'BlobGasUsed' static (8 bytes) + // Field #16 'ExcessBlobGas' static (8 bytes) + size += 584 + { // Dynamic field #10 'ExtraData' + size += len(t.ExtraData) + } + } + { // Dynamic field #10 'BLSToExecutionChanges' + size += len(t.BLSToExecutionChanges) * 172 + } + { // Dynamic field #11 'BlobKZGCommitments' + size += len(t.BlobKZGCommitments) * 48 + } + { // Dynamic field #12 'ExecutionRequests' + t := t.ExecutionRequests + if t == nil { + t = new(all.ExecutionRequests) + } + // Field #0 'Deposits' offset (4 bytes) + // Field #1 'Withdrawals' offset (4 bytes) + // Field #2 'Consolidations' offset (4 bytes) + size += 12 + { // Dynamic field #0 'Deposits' + size += len(t.Deposits) * 192 + } + { // Dynamic field #1 'Withdrawals' + size += len(t.Withdrawals) * 76 + } + { // Dynamic field #2 'Consolidations' + size += len(t.Consolidations) * 116 + } + } + return size +} + +func (t *BlindedBeaconBlockBody) HashTreeRootWithDynView(view any) func(ds sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + switch view.(type) { + case *bellatrix.BlindedBeaconBlockBody: + return t.hashTreeRootView_BlindedBeaconBlockBody + case *capella.BlindedBeaconBlockBody: + return t.hashTreeRootView_BlindedBeaconBlockBody_0 + case *deneb.BlindedBeaconBlockBody: + return t.hashTreeRootView_BlindedBeaconBlockBody_1 + case *electra.BlindedBeaconBlockBody: + return t.hashTreeRootView_BlindedBeaconBlockBody_2 + } + return nil +} +func (t *BlindedBeaconBlockBody) hashTreeRootView_BlindedBeaconBlockBody(ds sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + expr0, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_PROPOSER_SLASHINGS", 16) + if err != nil { + return err + } + expr1, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_ATTESTER_SLASHINGS", 2) + if err != nil { + return err + } + expr2, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_ATTESTATIONS", 128) + if err != nil { + return err + } + expr3, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_VALIDATORS_PER_COMMITTEE", 2048) + if err != nil { + return err + } + expr4, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_DEPOSITS", 16) + if err != nil { + return err + } + expr5, err := sszutils.ResolveSpecValueWithDefault(ds, "DEPOSIT_CONTRACT_TREE_DEPTH+1", 33) + if err != nil { + return err + } + expr6, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_VOLUNTARY_EXITS", 16) + if err != nil { + return err + } + expr7, err := sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE/8", 64) + if err != nil { + return err + } + if t == nil { + t = new(BlindedBeaconBlockBody) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'RANDAOReveal' + hh.PutBytes(t.RANDAOReveal[:96]) + } + { // Field #1 'ETH1Data' + t := t.ETH1Data + if t == nil { + t = new(phase0.ETH1Data) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPath(err, "ETH1Data") + } + } + { // Field #2 'Graffiti' + hh.PutBytes(t.Graffiti[:32]) + } + { // Field #3 'ProposerSlashings' + t := t.ProposerSlashings + vlen := uint64(len(t)) + if vlen > expr0 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr0), "ProposerSlashings") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(phase0.ProposerSlashing) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "ProposerSlashings[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr0, vlen, 32)) + } + { // Field #4 'AttesterSlashings' + t := t.AttesterSlashings + vlen := uint64(len(t)) + if vlen > expr1 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr1), "AttesterSlashings") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(all.AttesterSlashing) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Attestation1' + t := t.Attestation1 + if t == nil { + t = new(all.IndexedAttestation) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'AttestingIndices' + t := t.AttestingIndices + vlen := uint64(len(t)) + if vlen > 2048 { + return sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(vlen, 2048), "AttesterSlashings[%d].Attestation1.AttestingIndices", idx1) + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + sszutils.HashUint64Slice(hh, t) + hh.FillUpTo32() + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(2048, vlen, 8)) + } + { // Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.AttestationData) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "AttesterSlashings[%d].Attestation1.Data", idx1) + } + } + { // Field #2 'Signature' + hh.PutBytes(t.Signature[:96]) + } + hh.Merkleize(idx) + } + { // Field #1 'Attestation2' + t := t.Attestation2 + if t == nil { + t = new(all.IndexedAttestation) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'AttestingIndices' + t := t.AttestingIndices + vlen := uint64(len(t)) + if vlen > 2048 { + return sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(vlen, 2048), "AttesterSlashings[%d].Attestation2.AttestingIndices", idx1) + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + sszutils.HashUint64Slice(hh, t) + hh.FillUpTo32() + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(2048, vlen, 8)) + } + { // Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.AttestationData) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "AttesterSlashings[%d].Attestation2.Data", idx1) + } + } + { // Field #2 'Signature' + hh.PutBytes(t.Signature[:96]) + } + hh.Merkleize(idx) + } + hh.Merkleize(idx) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr1, vlen, 32)) + } + { // Field #5 'Attestations' + t := t.Attestations + vlen := uint64(len(t)) + if vlen > expr2 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr2), "Attestations") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(all.Attestation) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'AggregationBits' + t := t.AggregationBits + if l := len(t); l > 0 && t[l-1] == 0x00 { + return sszutils.ErrorWithPathf(sszutils.ErrBitlistNotTerminatedFn(), "Attestations[%d].AggregationBits", idx1) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + bitlist, size := hasher.ParseBitlistWithHasher(hh, t[:]) + if size > expr3 { + return sszutils.ErrorWithPathf(sszutils.ErrBitlistLengthFn(size, expr3), "Attestations[%d].AggregationBits", idx1) + } + hh.AppendBytes32(bitlist) + hh.MerkleizeWithMixin(idx, size, sszutils.CalculateBitlistLimit(expr3)) + } + { // Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.AttestationData) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "Attestations[%d].Data", idx1) + } + } + { // Field #2 'Signature' + hh.PutBytes(t.Signature[:96]) + } + hh.Merkleize(idx) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr2, vlen, 32)) + } + { // Field #6 'Deposits' + t := t.Deposits + vlen := uint64(len(t)) + if vlen > expr4 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr4), "Deposits") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(phase0.Deposit) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Proof' + t := t.Proof + vlen := len(t) + if vlen > int(expr5) { + return sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, int(expr5)), "Deposits[%d].Proof", idx1) + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + var val1, val1Empty []byte + for idx2 := range int(expr5) { + if idx2 < vlen { + val1 = t[idx2] + } else if idx2 == vlen { + val1 = val1Empty + } + vlen := len(val1) + if vlen > 32 { + return sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, 32), "Deposits[%d].Proof[%d]", idx1, idx2) + } + val := val1[:] + if vlen < 32 { + val = sszutils.AppendZeroPadding(val, (32-vlen)*1) + } + hh.PutBytes(val[:32]) + if (idx2+1)%256 == 0 { + hh.Collapse() + } + } + hh.Merkleize(idx) + } + { // Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.DepositData) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "Deposits[%d].Data", idx1) + } + } + hh.Merkleize(idx) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr4, vlen, 32)) + } + { // Field #7 'VoluntaryExits' + t := t.VoluntaryExits + vlen := uint64(len(t)) + if vlen > expr6 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr6), "VoluntaryExits") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(phase0.SignedVoluntaryExit) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "VoluntaryExits[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr6, vlen, 32)) + } + { // Field #8 'SyncAggregate' + t := t.SyncAggregate + if t == nil { + t = new(altair.SyncAggregate) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'SyncCommitteeBits' + vlen := len(t.SyncCommitteeBits) + if vlen > int(expr7) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(expr7)), "SyncAggregate.SyncCommitteeBits") + } + val := t.SyncCommitteeBits[:] + if vlen < int(expr7) { + val = sszutils.AppendZeroPadding(val, (int(expr7)-vlen)*1) + } + hh.PutBytes(val[:int(expr7)]) + } + { // Field #1 'SyncCommitteeSignature' + hh.PutBytes(t.SyncCommitteeSignature[:96]) + } + hh.Merkleize(idx) + } + { // Field #9 'ExecutionPayloadHeader' + t := t.ExecutionPayloadHeader + if t == nil { + t = new(all.ExecutionPayloadHeader) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'ParentHash' + hh.PutBytes(t.ParentHash[:32]) + } + { // Field #1 'FeeRecipient' + hh.PutBytes(t.FeeRecipient[:20]) + } + { // Field #2 'StateRoot' + hh.PutBytes(t.StateRoot[:32]) + } + { // Field #3 'ReceiptsRoot' + hh.PutBytes(t.ReceiptsRoot[:32]) + } + { // Field #4 'LogsBloom' + hh.PutBytes(t.LogsBloom[:256]) + } + { // Field #5 'PrevRandao' + hh.PutBytes(t.PrevRandao[:32]) + } + { // Field #6 'BlockNumber' + hh.PutUint64(t.BlockNumber) + } + { // Field #7 'GasLimit' + hh.PutUint64(t.GasLimit) + } + { // Field #8 'GasUsed' + hh.PutUint64(t.GasUsed) + } + { // Field #9 'Timestamp' + hh.PutUint64(t.Timestamp) + } + { // Field #10 'ExtraData' + vlen := uint64(len(t.ExtraData)) + if vlen > 32 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 32), "ExecutionPayloadHeader.ExtraData") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + hh.AppendBytes32(t.ExtraData[:]) + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(32, vlen, 1)) + } + { // Field #11 'BaseFeePerGasLE' + hh.PutBytes(t.BaseFeePerGasLE[:32]) + } + { // Field #12 'BlockHash' + hh.PutBytes(t.BlockHash[:32]) + } + { // Field #13 'TransactionsRoot' + hh.PutBytes(t.TransactionsRoot[:32]) + } + hh.Merkleize(idx) + } + hh.Merkleize(idx) + return nil +} + +func (t *BlindedBeaconBlockBody) hashTreeRootView_BlindedBeaconBlockBody_0(ds sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + expr0, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_PROPOSER_SLASHINGS", 16) + if err != nil { + return err + } + expr1, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_ATTESTER_SLASHINGS", 2) + if err != nil { + return err + } + expr2, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_ATTESTATIONS", 128) + if err != nil { + return err + } + expr3, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_VALIDATORS_PER_COMMITTEE", 2048) + if err != nil { + return err + } + expr4, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_DEPOSITS", 16) + if err != nil { + return err + } + expr5, err := sszutils.ResolveSpecValueWithDefault(ds, "DEPOSIT_CONTRACT_TREE_DEPTH+1", 33) + if err != nil { + return err + } + expr6, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_VOLUNTARY_EXITS", 16) + if err != nil { + return err + } + expr7, err := sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE/8", 64) + if err != nil { + return err + } + expr8, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BLS_TO_EXECUTION_CHANGES", 16) + if err != nil { + return err + } + if t == nil { + t = new(BlindedBeaconBlockBody) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'RANDAOReveal' + hh.PutBytes(t.RANDAOReveal[:96]) + } + { // Field #1 'ETH1Data' + t := t.ETH1Data + if t == nil { + t = new(phase0.ETH1Data) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPath(err, "ETH1Data") + } + } + { // Field #2 'Graffiti' + hh.PutBytes(t.Graffiti[:32]) + } + { // Field #3 'ProposerSlashings' + t := t.ProposerSlashings + vlen := uint64(len(t)) + if vlen > expr0 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr0), "ProposerSlashings") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(phase0.ProposerSlashing) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "ProposerSlashings[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr0, vlen, 32)) + } + { // Field #4 'AttesterSlashings' + t := t.AttesterSlashings + vlen := uint64(len(t)) + if vlen > expr1 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr1), "AttesterSlashings") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(all.AttesterSlashing) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Attestation1' + t := t.Attestation1 + if t == nil { + t = new(all.IndexedAttestation) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'AttestingIndices' + t := t.AttestingIndices + vlen := uint64(len(t)) + if vlen > 2048 { + return sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(vlen, 2048), "AttesterSlashings[%d].Attestation1.AttestingIndices", idx1) + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + sszutils.HashUint64Slice(hh, t) + hh.FillUpTo32() + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(2048, vlen, 8)) + } + { // Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.AttestationData) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "AttesterSlashings[%d].Attestation1.Data", idx1) + } + } + { // Field #2 'Signature' + hh.PutBytes(t.Signature[:96]) + } + hh.Merkleize(idx) + } + { // Field #1 'Attestation2' + t := t.Attestation2 + if t == nil { + t = new(all.IndexedAttestation) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'AttestingIndices' + t := t.AttestingIndices + vlen := uint64(len(t)) + if vlen > 2048 { + return sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(vlen, 2048), "AttesterSlashings[%d].Attestation2.AttestingIndices", idx1) + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + sszutils.HashUint64Slice(hh, t) + hh.FillUpTo32() + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(2048, vlen, 8)) + } + { // Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.AttestationData) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "AttesterSlashings[%d].Attestation2.Data", idx1) + } + } + { // Field #2 'Signature' + hh.PutBytes(t.Signature[:96]) + } + hh.Merkleize(idx) + } + hh.Merkleize(idx) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr1, vlen, 32)) + } + { // Field #5 'Attestations' + t := t.Attestations + vlen := uint64(len(t)) + if vlen > expr2 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr2), "Attestations") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(all.Attestation) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'AggregationBits' + t := t.AggregationBits + if l := len(t); l > 0 && t[l-1] == 0x00 { + return sszutils.ErrorWithPathf(sszutils.ErrBitlistNotTerminatedFn(), "Attestations[%d].AggregationBits", idx1) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + bitlist, size := hasher.ParseBitlistWithHasher(hh, t[:]) + if size > expr3 { + return sszutils.ErrorWithPathf(sszutils.ErrBitlistLengthFn(size, expr3), "Attestations[%d].AggregationBits", idx1) + } + hh.AppendBytes32(bitlist) + hh.MerkleizeWithMixin(idx, size, sszutils.CalculateBitlistLimit(expr3)) + } + { // Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.AttestationData) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "Attestations[%d].Data", idx1) + } + } + { // Field #2 'Signature' + hh.PutBytes(t.Signature[:96]) + } + hh.Merkleize(idx) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr2, vlen, 32)) + } + { // Field #6 'Deposits' + t := t.Deposits + vlen := uint64(len(t)) + if vlen > expr4 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr4), "Deposits") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(phase0.Deposit) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Proof' + t := t.Proof + vlen := len(t) + if vlen > int(expr5) { + return sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, int(expr5)), "Deposits[%d].Proof", idx1) + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + var val1, val1Empty []byte + for idx2 := range int(expr5) { + if idx2 < vlen { + val1 = t[idx2] + } else if idx2 == vlen { + val1 = val1Empty + } + vlen := len(val1) + if vlen > 32 { + return sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, 32), "Deposits[%d].Proof[%d]", idx1, idx2) + } + val := val1[:] + if vlen < 32 { + val = sszutils.AppendZeroPadding(val, (32-vlen)*1) + } + hh.PutBytes(val[:32]) + if (idx2+1)%256 == 0 { + hh.Collapse() + } + } + hh.Merkleize(idx) + } + { // Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.DepositData) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "Deposits[%d].Data", idx1) + } + } + hh.Merkleize(idx) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr4, vlen, 32)) + } + { // Field #7 'VoluntaryExits' + t := t.VoluntaryExits + vlen := uint64(len(t)) + if vlen > expr6 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr6), "VoluntaryExits") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(phase0.SignedVoluntaryExit) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "VoluntaryExits[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr6, vlen, 32)) + } + { // Field #8 'SyncAggregate' + t := t.SyncAggregate + if t == nil { + t = new(altair.SyncAggregate) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'SyncCommitteeBits' + vlen := len(t.SyncCommitteeBits) + if vlen > int(expr7) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(expr7)), "SyncAggregate.SyncCommitteeBits") + } + val := t.SyncCommitteeBits[:] + if vlen < int(expr7) { + val = sszutils.AppendZeroPadding(val, (int(expr7)-vlen)*1) + } + hh.PutBytes(val[:int(expr7)]) + } + { // Field #1 'SyncCommitteeSignature' + hh.PutBytes(t.SyncCommitteeSignature[:96]) + } + hh.Merkleize(idx) + } + { // Field #9 'ExecutionPayloadHeader' + t := t.ExecutionPayloadHeader + if t == nil { + t = new(all.ExecutionPayloadHeader) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'ParentHash' + hh.PutBytes(t.ParentHash[:32]) + } + { // Field #1 'FeeRecipient' + hh.PutBytes(t.FeeRecipient[:20]) + } + { // Field #2 'StateRoot' + hh.PutBytes(t.StateRoot[:32]) + } + { // Field #3 'ReceiptsRoot' + hh.PutBytes(t.ReceiptsRoot[:32]) + } + { // Field #4 'LogsBloom' + hh.PutBytes(t.LogsBloom[:256]) + } + { // Field #5 'PrevRandao' + hh.PutBytes(t.PrevRandao[:32]) + } + { // Field #6 'BlockNumber' + hh.PutUint64(t.BlockNumber) + } + { // Field #7 'GasLimit' + hh.PutUint64(t.GasLimit) + } + { // Field #8 'GasUsed' + hh.PutUint64(t.GasUsed) + } + { // Field #9 'Timestamp' + hh.PutUint64(t.Timestamp) + } + { // Field #10 'ExtraData' + vlen := uint64(len(t.ExtraData)) + if vlen > 32 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 32), "ExecutionPayloadHeader.ExtraData") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + hh.AppendBytes32(t.ExtraData[:]) + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(32, vlen, 1)) + } + { // Field #11 'BaseFeePerGasLE' + hh.PutBytes(t.BaseFeePerGasLE[:32]) + } + { // Field #12 'BlockHash' + hh.PutBytes(t.BlockHash[:32]) + } + { // Field #13 'TransactionsRoot' + hh.PutBytes(t.TransactionsRoot[:32]) + } + { // Field #14 'WithdrawalsRoot' + hh.PutBytes(t.WithdrawalsRoot[:32]) + } + hh.Merkleize(idx) + } + { // Field #10 'BLSToExecutionChanges' + t := t.BLSToExecutionChanges + vlen := uint64(len(t)) + if vlen > expr8 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr8), "BLSToExecutionChanges") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(capella1.SignedBLSToExecutionChange) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "BLSToExecutionChanges[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr8, vlen, 32)) + } + hh.Merkleize(idx) + return nil +} + +func (t *BlindedBeaconBlockBody) hashTreeRootView_BlindedBeaconBlockBody_1(ds sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + expr0, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_PROPOSER_SLASHINGS", 16) + if err != nil { + return err + } + expr1, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_ATTESTER_SLASHINGS", 2) + if err != nil { + return err + } + expr2, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_ATTESTATIONS", 128) + if err != nil { + return err + } + expr3, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_VALIDATORS_PER_COMMITTEE", 2048) + if err != nil { + return err + } + expr4, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_DEPOSITS", 16) + if err != nil { + return err + } + expr5, err := sszutils.ResolveSpecValueWithDefault(ds, "DEPOSIT_CONTRACT_TREE_DEPTH+1", 33) + if err != nil { + return err + } + expr6, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_VOLUNTARY_EXITS", 16) + if err != nil { + return err + } + expr7, err := sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE/8", 64) + if err != nil { + return err + } + expr8, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BLS_TO_EXECUTION_CHANGES", 16) + if err != nil { + return err + } + expr9, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BLOB_COMMITMENTS_PER_BLOCK", 4096) + if err != nil { + return err + } + if t == nil { + t = new(BlindedBeaconBlockBody) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'RANDAOReveal' + hh.PutBytes(t.RANDAOReveal[:96]) + } + { // Field #1 'ETH1Data' + t := t.ETH1Data + if t == nil { + t = new(phase0.ETH1Data) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPath(err, "ETH1Data") + } + } + { // Field #2 'Graffiti' + hh.PutBytes(t.Graffiti[:32]) + } + { // Field #3 'ProposerSlashings' + t := t.ProposerSlashings + vlen := uint64(len(t)) + if vlen > expr0 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr0), "ProposerSlashings") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(phase0.ProposerSlashing) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "ProposerSlashings[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr0, vlen, 32)) + } + { // Field #4 'AttesterSlashings' + t := t.AttesterSlashings + vlen := uint64(len(t)) + if vlen > expr1 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr1), "AttesterSlashings") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(all.AttesterSlashing) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Attestation1' + t := t.Attestation1 + if t == nil { + t = new(all.IndexedAttestation) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'AttestingIndices' + t := t.AttestingIndices + vlen := uint64(len(t)) + if vlen > 2048 { + return sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(vlen, 2048), "AttesterSlashings[%d].Attestation1.AttestingIndices", idx1) + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + sszutils.HashUint64Slice(hh, t) + hh.FillUpTo32() + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(2048, vlen, 8)) + } + { // Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.AttestationData) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "AttesterSlashings[%d].Attestation1.Data", idx1) + } + } + { // Field #2 'Signature' + hh.PutBytes(t.Signature[:96]) + } + hh.Merkleize(idx) + } + { // Field #1 'Attestation2' + t := t.Attestation2 + if t == nil { + t = new(all.IndexedAttestation) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'AttestingIndices' + t := t.AttestingIndices + vlen := uint64(len(t)) + if vlen > 2048 { + return sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(vlen, 2048), "AttesterSlashings[%d].Attestation2.AttestingIndices", idx1) + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + sszutils.HashUint64Slice(hh, t) + hh.FillUpTo32() + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(2048, vlen, 8)) + } + { // Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.AttestationData) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "AttesterSlashings[%d].Attestation2.Data", idx1) + } + } + { // Field #2 'Signature' + hh.PutBytes(t.Signature[:96]) + } + hh.Merkleize(idx) + } + hh.Merkleize(idx) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr1, vlen, 32)) + } + { // Field #5 'Attestations' + t := t.Attestations + vlen := uint64(len(t)) + if vlen > expr2 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr2), "Attestations") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(all.Attestation) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'AggregationBits' + t := t.AggregationBits + if l := len(t); l > 0 && t[l-1] == 0x00 { + return sszutils.ErrorWithPathf(sszutils.ErrBitlistNotTerminatedFn(), "Attestations[%d].AggregationBits", idx1) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + bitlist, size := hasher.ParseBitlistWithHasher(hh, t[:]) + if size > expr3 { + return sszutils.ErrorWithPathf(sszutils.ErrBitlistLengthFn(size, expr3), "Attestations[%d].AggregationBits", idx1) + } + hh.AppendBytes32(bitlist) + hh.MerkleizeWithMixin(idx, size, sszutils.CalculateBitlistLimit(expr3)) + } + { // Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.AttestationData) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "Attestations[%d].Data", idx1) + } + } + { // Field #2 'Signature' + hh.PutBytes(t.Signature[:96]) + } + hh.Merkleize(idx) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr2, vlen, 32)) + } + { // Field #6 'Deposits' + t := t.Deposits + vlen := uint64(len(t)) + if vlen > expr4 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr4), "Deposits") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(phase0.Deposit) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Proof' + t := t.Proof + vlen := len(t) + if vlen > int(expr5) { + return sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, int(expr5)), "Deposits[%d].Proof", idx1) + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + var val1, val1Empty []byte + for idx2 := range int(expr5) { + if idx2 < vlen { + val1 = t[idx2] + } else if idx2 == vlen { + val1 = val1Empty + } + vlen := len(val1) + if vlen > 32 { + return sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, 32), "Deposits[%d].Proof[%d]", idx1, idx2) + } + val := val1[:] + if vlen < 32 { + val = sszutils.AppendZeroPadding(val, (32-vlen)*1) + } + hh.PutBytes(val[:32]) + if (idx2+1)%256 == 0 { + hh.Collapse() + } + } + hh.Merkleize(idx) + } + { // Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.DepositData) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "Deposits[%d].Data", idx1) + } + } + hh.Merkleize(idx) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr4, vlen, 32)) + } + { // Field #7 'VoluntaryExits' + t := t.VoluntaryExits + vlen := uint64(len(t)) + if vlen > expr6 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr6), "VoluntaryExits") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(phase0.SignedVoluntaryExit) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "VoluntaryExits[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr6, vlen, 32)) + } + { // Field #8 'SyncAggregate' + t := t.SyncAggregate + if t == nil { + t = new(altair.SyncAggregate) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'SyncCommitteeBits' + vlen := len(t.SyncCommitteeBits) + if vlen > int(expr7) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(expr7)), "SyncAggregate.SyncCommitteeBits") + } + val := t.SyncCommitteeBits[:] + if vlen < int(expr7) { + val = sszutils.AppendZeroPadding(val, (int(expr7)-vlen)*1) + } + hh.PutBytes(val[:int(expr7)]) + } + { // Field #1 'SyncCommitteeSignature' + hh.PutBytes(t.SyncCommitteeSignature[:96]) + } + hh.Merkleize(idx) + } + { // Field #9 'ExecutionPayloadHeader' + t := t.ExecutionPayloadHeader + if t == nil { + t = new(all.ExecutionPayloadHeader) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'ParentHash' + hh.PutBytes(t.ParentHash[:32]) + } + { // Field #1 'FeeRecipient' + hh.PutBytes(t.FeeRecipient[:20]) + } + { // Field #2 'StateRoot' + hh.PutBytes(t.StateRoot[:32]) + } + { // Field #3 'ReceiptsRoot' + hh.PutBytes(t.ReceiptsRoot[:32]) + } + { // Field #4 'LogsBloom' + hh.PutBytes(t.LogsBloom[:256]) + } + { // Field #5 'PrevRandao' + hh.PutBytes(t.PrevRandao[:32]) + } + { // Field #6 'BlockNumber' + hh.PutUint64(t.BlockNumber) + } + { // Field #7 'GasLimit' + hh.PutUint64(t.GasLimit) + } + { // Field #8 'GasUsed' + hh.PutUint64(t.GasUsed) + } + { // Field #9 'Timestamp' + hh.PutUint64(t.Timestamp) + } + { // Field #10 'ExtraData' + vlen := uint64(len(t.ExtraData)) + if vlen > 32 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 32), "ExecutionPayloadHeader.ExtraData") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + hh.AppendBytes32(t.ExtraData[:]) + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(32, vlen, 1)) + } + { // Field #11 'BaseFeePerGas' + t := t.BaseFeePerGas + if t == nil { + t = new(uint256.Int) + } + if root, err := t.HashTreeRoot(); err != nil { + return sszutils.ErrorWithPath(err, "ExecutionPayloadHeader.BaseFeePerGas") + } else { + hh.AppendBytes32(root[:]) + } + } + { // Field #12 'BlockHash' + hh.PutBytes(t.BlockHash[:32]) + } + { // Field #13 'TransactionsRoot' + hh.PutBytes(t.TransactionsRoot[:32]) + } + { // Field #14 'WithdrawalsRoot' + hh.PutBytes(t.WithdrawalsRoot[:32]) + } + { // Field #15 'BlobGasUsed' + hh.PutUint64(t.BlobGasUsed) + } + { // Field #16 'ExcessBlobGas' + hh.PutUint64(t.ExcessBlobGas) + } + hh.Merkleize(idx) + } + { // Field #10 'BLSToExecutionChanges' + t := t.BLSToExecutionChanges + vlen := uint64(len(t)) + if vlen > expr8 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr8), "BLSToExecutionChanges") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(capella1.SignedBLSToExecutionChange) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "BLSToExecutionChanges[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr8, vlen, 32)) + } + { // Field #11 'BlobKZGCommitments' + t := t.BlobKZGCommitments + vlen := uint64(len(t)) + if vlen > expr9 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr9), "BlobKZGCommitments") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + hh.PutBytes(t[idx1][:48]) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr9, vlen, 32)) + } + hh.Merkleize(idx) + return nil +} + +func (t *BlindedBeaconBlockBody) hashTreeRootView_BlindedBeaconBlockBody_2(ds sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + expr0, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_PROPOSER_SLASHINGS", 16) + if err != nil { + return err + } + expr1, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_ATTESTER_SLASHINGS_ELECTRA", 1) + if err != nil { + return err + } + expr2, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_VALIDATORS_PER_COMMITTEE*MAX_COMMITTEES_PER_SLOT", 131072) + if err != nil { + return err + } + expr3, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_ATTESTATIONS_ELECTRA", 8) + if err != nil { + return err + } + expr4, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_COMMITTEES_PER_SLOT/8", 8) + if err != nil { + return err + } + expr5, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_DEPOSITS", 16) + if err != nil { + return err + } + expr6, err := sszutils.ResolveSpecValueWithDefault(ds, "DEPOSIT_CONTRACT_TREE_DEPTH+1", 33) + if err != nil { + return err + } + expr7, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_VOLUNTARY_EXITS", 16) + if err != nil { + return err + } + expr8, err := sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE/8", 64) + if err != nil { + return err + } + expr9, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BLS_TO_EXECUTION_CHANGES", 16) + if err != nil { + return err + } + expr10, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BLOB_COMMITMENTS_PER_BLOCK", 4096) + if err != nil { + return err + } + expr11, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_DEPOSIT_REQUESTS_PER_PAYLOAD", 8192) + if err != nil { + return err + } + expr12, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_WITHDRAWAL_REQUESTS_PER_PAYLOAD", 16) + if err != nil { + return err + } + expr13, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD", 2) + if err != nil { + return err + } + if t == nil { + t = new(BlindedBeaconBlockBody) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'RANDAOReveal' + hh.PutBytes(t.RANDAOReveal[:96]) + } + { // Field #1 'ETH1Data' + t := t.ETH1Data + if t == nil { + t = new(phase0.ETH1Data) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPath(err, "ETH1Data") + } + } + { // Field #2 'Graffiti' + hh.PutBytes(t.Graffiti[:32]) + } + { // Field #3 'ProposerSlashings' + t := t.ProposerSlashings + vlen := uint64(len(t)) + if vlen > expr0 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr0), "ProposerSlashings") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(phase0.ProposerSlashing) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "ProposerSlashings[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr0, vlen, 32)) + } + { // Field #4 'AttesterSlashings' + t := t.AttesterSlashings + vlen := uint64(len(t)) + if vlen > expr1 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr1), "AttesterSlashings") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(all.AttesterSlashing) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Attestation1' + t := t.Attestation1 + if t == nil { + t = new(all.IndexedAttestation) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'AttestingIndices' + t := t.AttestingIndices + vlen := uint64(len(t)) + if vlen > expr2 { + return sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(vlen, expr2), "AttesterSlashings[%d].Attestation1.AttestingIndices", idx1) + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + sszutils.HashUint64Slice(hh, t) + hh.FillUpTo32() + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr2, vlen, 8)) + } + { // Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.AttestationData) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "AttesterSlashings[%d].Attestation1.Data", idx1) + } + } + { // Field #2 'Signature' + hh.PutBytes(t.Signature[:96]) + } + hh.Merkleize(idx) + } + { // Field #1 'Attestation2' + t := t.Attestation2 + if t == nil { + t = new(all.IndexedAttestation) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'AttestingIndices' + t := t.AttestingIndices + vlen := uint64(len(t)) + if vlen > expr2 { + return sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(vlen, expr2), "AttesterSlashings[%d].Attestation2.AttestingIndices", idx1) + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + sszutils.HashUint64Slice(hh, t) + hh.FillUpTo32() + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr2, vlen, 8)) + } + { // Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.AttestationData) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "AttesterSlashings[%d].Attestation2.Data", idx1) + } + } + { // Field #2 'Signature' + hh.PutBytes(t.Signature[:96]) + } + hh.Merkleize(idx) + } + hh.Merkleize(idx) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr1, vlen, 32)) + } + { // Field #5 'Attestations' + t := t.Attestations + vlen := uint64(len(t)) + if vlen > expr3 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr3), "Attestations") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(all.Attestation) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'AggregationBits' + t := t.AggregationBits + if l := len(t); l > 0 && t[l-1] == 0x00 { + return sszutils.ErrorWithPathf(sszutils.ErrBitlistNotTerminatedFn(), "Attestations[%d].AggregationBits", idx1) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + bitlist, size := hasher.ParseBitlistWithHasher(hh, t[:]) + if size > expr2 { + return sszutils.ErrorWithPathf(sszutils.ErrBitlistLengthFn(size, expr2), "Attestations[%d].AggregationBits", idx1) + } + hh.AppendBytes32(bitlist) + hh.MerkleizeWithMixin(idx, size, sszutils.CalculateBitlistLimit(expr2)) + } + { // Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.AttestationData) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "Attestations[%d].Data", idx1) + } + } + { // Field #2 'Signature' + hh.PutBytes(t.Signature[:96]) + } + { // Field #3 'CommitteeBits' + vlen := len(t.CommitteeBits) + if vlen > int(expr4) { + return sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, int(expr4)), "Attestations[%d].CommitteeBits", idx1) + } + val := t.CommitteeBits[:] + if vlen < int(expr4) { + val = sszutils.AppendZeroPadding(val, (int(expr4)-vlen)*1) + } + hh.PutBytes(val[:int(expr4)]) + } + hh.Merkleize(idx) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr3, vlen, 32)) + } + { // Field #6 'Deposits' + t := t.Deposits + vlen := uint64(len(t)) + if vlen > expr5 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr5), "Deposits") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(phase0.Deposit) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Proof' + t := t.Proof + vlen := len(t) + if vlen > int(expr6) { + return sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, int(expr6)), "Deposits[%d].Proof", idx1) + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + var val1, val1Empty []byte + for idx2 := range int(expr6) { + if idx2 < vlen { + val1 = t[idx2] + } else if idx2 == vlen { + val1 = val1Empty + } + vlen := len(val1) + if vlen > 32 { + return sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, 32), "Deposits[%d].Proof[%d]", idx1, idx2) + } + val := val1[:] + if vlen < 32 { + val = sszutils.AppendZeroPadding(val, (32-vlen)*1) + } + hh.PutBytes(val[:32]) + if (idx2+1)%256 == 0 { + hh.Collapse() + } + } + hh.Merkleize(idx) + } + { // Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.DepositData) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "Deposits[%d].Data", idx1) + } + } + hh.Merkleize(idx) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr5, vlen, 32)) + } + { // Field #7 'VoluntaryExits' + t := t.VoluntaryExits + vlen := uint64(len(t)) + if vlen > expr7 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr7), "VoluntaryExits") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(phase0.SignedVoluntaryExit) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "VoluntaryExits[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr7, vlen, 32)) + } + { // Field #8 'SyncAggregate' + t := t.SyncAggregate + if t == nil { + t = new(altair.SyncAggregate) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'SyncCommitteeBits' + vlen := len(t.SyncCommitteeBits) + if vlen > int(expr8) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(expr8)), "SyncAggregate.SyncCommitteeBits") + } + val := t.SyncCommitteeBits[:] + if vlen < int(expr8) { + val = sszutils.AppendZeroPadding(val, (int(expr8)-vlen)*1) + } + hh.PutBytes(val[:int(expr8)]) + } + { // Field #1 'SyncCommitteeSignature' + hh.PutBytes(t.SyncCommitteeSignature[:96]) + } + hh.Merkleize(idx) + } + { // Field #9 'ExecutionPayloadHeader' + t := t.ExecutionPayloadHeader + if t == nil { + t = new(all.ExecutionPayloadHeader) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'ParentHash' + hh.PutBytes(t.ParentHash[:32]) + } + { // Field #1 'FeeRecipient' + hh.PutBytes(t.FeeRecipient[:20]) + } + { // Field #2 'StateRoot' + hh.PutBytes(t.StateRoot[:32]) + } + { // Field #3 'ReceiptsRoot' + hh.PutBytes(t.ReceiptsRoot[:32]) + } + { // Field #4 'LogsBloom' + hh.PutBytes(t.LogsBloom[:256]) + } + { // Field #5 'PrevRandao' + hh.PutBytes(t.PrevRandao[:32]) + } + { // Field #6 'BlockNumber' + hh.PutUint64(t.BlockNumber) + } + { // Field #7 'GasLimit' + hh.PutUint64(t.GasLimit) + } + { // Field #8 'GasUsed' + hh.PutUint64(t.GasUsed) + } + { // Field #9 'Timestamp' + hh.PutUint64(t.Timestamp) + } + { // Field #10 'ExtraData' + vlen := uint64(len(t.ExtraData)) + if vlen > 32 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 32), "ExecutionPayloadHeader.ExtraData") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + hh.AppendBytes32(t.ExtraData[:]) + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(32, vlen, 1)) + } + { // Field #11 'BaseFeePerGas' + t := t.BaseFeePerGas + if t == nil { + t = new(uint256.Int) + } + if root, err := t.HashTreeRoot(); err != nil { + return sszutils.ErrorWithPath(err, "ExecutionPayloadHeader.BaseFeePerGas") + } else { + hh.AppendBytes32(root[:]) + } + } + { // Field #12 'BlockHash' + hh.PutBytes(t.BlockHash[:32]) + } + { // Field #13 'TransactionsRoot' + hh.PutBytes(t.TransactionsRoot[:32]) + } + { // Field #14 'WithdrawalsRoot' + hh.PutBytes(t.WithdrawalsRoot[:32]) + } + { // Field #15 'BlobGasUsed' + hh.PutUint64(t.BlobGasUsed) + } + { // Field #16 'ExcessBlobGas' + hh.PutUint64(t.ExcessBlobGas) + } + hh.Merkleize(idx) + } + { // Field #10 'BLSToExecutionChanges' + t := t.BLSToExecutionChanges + vlen := uint64(len(t)) + if vlen > expr9 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr9), "BLSToExecutionChanges") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(capella1.SignedBLSToExecutionChange) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "BLSToExecutionChanges[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr9, vlen, 32)) + } + { // Field #11 'BlobKZGCommitments' + t := t.BlobKZGCommitments + vlen := uint64(len(t)) + if vlen > expr10 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr10), "BlobKZGCommitments") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + hh.PutBytes(t[idx1][:48]) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr10, vlen, 32)) + } + { // Field #12 'ExecutionRequests' + t := t.ExecutionRequests + if t == nil { + t = new(all.ExecutionRequests) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Deposits' + t := t.Deposits + vlen := uint64(len(t)) + if vlen > expr11 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr11), "ExecutionRequests.Deposits") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(electra1.DepositRequest) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "ExecutionRequests.Deposits[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr11, vlen, 32)) + } + { // Field #1 'Withdrawals' + t := t.Withdrawals + vlen := uint64(len(t)) + if vlen > expr12 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr12), "ExecutionRequests.Withdrawals") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(electra1.WithdrawalRequest) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "ExecutionRequests.Withdrawals[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr12, vlen, 32)) + } + { // Field #2 'Consolidations' + t := t.Consolidations + vlen := uint64(len(t)) + if vlen > expr13 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr13), "ExecutionRequests.Consolidations") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(electra1.ConsolidationRequest) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "ExecutionRequests.Consolidations[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr13, vlen, 32)) + } + hh.Merkleize(idx) + } + hh.Merkleize(idx) + return nil +} diff --git a/api/v1/all/blockcontents.go b/api/v1/all/blockcontents.go new file mode 100644 index 00000000..b56dee29 --- /dev/null +++ b/api/v1/all/blockcontents.go @@ -0,0 +1,275 @@ +// Copyright © 2026 Attestant Limited. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package all + +import ( + "errors" + "fmt" + + "github.com/ethpandaops/go-eth2-client/api" + apiv1deneb "github.com/ethpandaops/go-eth2-client/api/v1/deneb" + apiv1electra "github.com/ethpandaops/go-eth2-client/api/v1/electra" + apiv1fulu "github.com/ethpandaops/go-eth2-client/api/v1/fulu" + specall "github.com/ethpandaops/go-eth2-client/spec/all" + "github.com/ethpandaops/go-eth2-client/spec/deneb" + "github.com/ethpandaops/go-eth2-client/spec/version" + dynssz "github.com/pk910/dynamic-ssz" + "github.com/pk910/dynamic-ssz/sszutils" +) + +// BlockContents is a fork-agnostic block contents: the beacon block together +// with the blob sidecar data (KZG proofs and blobs). Block contents exist as +// a wire type from Deneb onwards; earlier forks use bare beacon blocks and +// are not supported by this type. +type BlockContents struct { + Version version.DataVersion + Block *specall.BeaconBlock + KZGProofs []deneb.KZGProof + Blobs []deneb.Blob +} + +// viewType returns the fork-specific schema type pointer used as the view +// descriptor for the active Version. +func (b *BlockContents) viewType() (any, error) { + switch b.Version { + case version.DataVersionDeneb: + return (*apiv1deneb.BlockContents)(nil), nil + case version.DataVersionElectra: + return (*apiv1electra.BlockContents)(nil), nil + case version.DataVersionFulu: + // Fulu reuses the Electra block schema; only the KZG proof list + // limit differs (cell proofs). + return (*apiv1fulu.BlockContents)(nil), nil + default: + return nil, fmt.Errorf("BlockContents: unsupported version %d", b.Version) + } +} + +// MarshalSSZDyn marshals the block contents using the view that matches +// Version. +func (b *BlockContents) MarshalSSZDyn(ds sszutils.DynamicSpecs, buf []byte) ([]byte, error) { + view, err := b.viewType() + if err != nil { + return nil, err + } + + m, ok := any(b).(sszutils.DynamicViewMarshaler) + if !ok { + return nil, errors.New("BlockContents: generated SSZ code missing") + } + + fn := m.MarshalSSZDynView(view) + if fn == nil { + return nil, fmt.Errorf("BlockContents: no view marshaler for version %d", b.Version) + } + + return fn(ds, buf) +} + +// SizeSSZDyn returns the SSZ size of the block contents for the active +// Version. +func (b *BlockContents) SizeSSZDyn(ds sszutils.DynamicSpecs) int { + view, err := b.viewType() + if err != nil { + return 0 + } + + sz, ok := any(b).(sszutils.DynamicViewSizer) + if !ok { + return 0 + } + + fn := sz.SizeSSZDynView(view) + if fn == nil { + return 0 + } + + return fn(ds) +} + +// UnmarshalSSZDyn decodes the block contents into the view that matches +// Version. +func (b *BlockContents) UnmarshalSSZDyn(ds sszutils.DynamicSpecs, buf []byte) error { + view, err := b.viewType() + if err != nil { + return err + } + + u, ok := any(b).(sszutils.DynamicViewUnmarshaler) + if !ok { + return errors.New("BlockContents: generated SSZ code missing") + } + + fn := u.UnmarshalSSZDynView(view) + if fn == nil { + return fmt.Errorf("BlockContents: no view unmarshaler for version %d", b.Version) + } + + if err := fn(ds, buf); 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 *BlockContents) populateVersion(v version.DataVersion) { + propagateVersion(b, v) +} + +// ToView returns a fresh fork-specific BlockContents populated with b's +// fields, recursing into Block via copyByName. +func (b *BlockContents) ToView() (any, error) { + return toViewByCopy(b) +} + +// FromView populates b from a fork-specific BlockContents. +func (b *BlockContents) FromView(view any) error { + v, err := blockContentsVersion(view) + if err != nil { + return err + } + + if b.Version == version.DataVersionUnknown { + b.Version = v + } + + if err := copyByName(view, b); err != nil { + return err + } + + b.populateVersion(b.Version) + + return nil +} + +// blockContentsVersion maps a BlockContents view type to its DataVersion. +func blockContentsVersion(view any) (version.DataVersion, error) { + switch view.(type) { + case *apiv1deneb.BlockContents: + return version.DataVersionDeneb, nil + case *apiv1electra.BlockContents: + return version.DataVersionElectra, nil + case *apiv1fulu.BlockContents: + return version.DataVersionFulu, nil + default: + return version.DataVersionUnknown, fmt.Errorf("BlockContents: unsupported view type %T", view) + } +} + +// HashTreeRootWithDyn computes the SSZ hash tree root using the active +// Version's view. +func (b *BlockContents) HashTreeRootWithDyn(ds sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + view, err := b.viewType() + if err != nil { + return err + } + + h, ok := any(b).(sszutils.DynamicViewHashRoot) + if !ok { + return errors.New("BlockContents: generated SSZ code missing") + } + + fn := h.HashTreeRootWithDynView(view) + if fn == nil { + return fmt.Errorf("BlockContents: no view hasher for version %d", b.Version) + } + + return fn(ds, hh) +} + +// MarshalSSZ implements the fastssz.Marshaler interface. +func (b *BlockContents) MarshalSSZ() ([]byte, error) { + ds := dynssz.GetGlobalDynSsz() + + return b.MarshalSSZDyn(ds, make([]byte, 0, b.SizeSSZDyn(ds))) +} + +// MarshalSSZTo implements the fastssz.Marshaler interface. +func (b *BlockContents) MarshalSSZTo(dst []byte) ([]byte, error) { + return b.MarshalSSZDyn(dynssz.GetGlobalDynSsz(), dst) +} + +// UnmarshalSSZ implements the fastssz.Unmarshaler interface. +func (b *BlockContents) UnmarshalSSZ(buf []byte) error { + return b.UnmarshalSSZDyn(dynssz.GetGlobalDynSsz(), buf) +} + +// SizeSSZ implements the fastssz.Marshaler interface. +func (b *BlockContents) SizeSSZ() int { + return b.SizeSSZDyn(dynssz.GetGlobalDynSsz()) +} + +// HashTreeRoot implements the fastssz.HashRoot interface. +func (b *BlockContents) HashTreeRoot() ([32]byte, error) { + return dynssz.GetGlobalDynSsz().HashTreeRoot(b) +} + +// HashTreeRootWith implements the fastssz.HashRoot interface. +func (b *BlockContents) HashTreeRootWith(hh sszutils.HashWalker) error { + return b.HashTreeRootWithDyn(dynssz.GetGlobalDynSsz(), hh) +} + +// ToVersioned converts b into a *api.VersionedProposal. +func (b *BlockContents) ToVersioned() (*api.VersionedProposal, error) { + out := &api.VersionedProposal{} + if err := toVersioned(b.Version, b, out); err != nil { + return nil, err + } + + return out, nil +} + +// FromVersioned populates b from src. Only unblinded block contents +// proposals (Deneb onwards) are supported. +func (b *BlockContents) FromVersioned(src *api.VersionedProposal) error { + return fromVersioned(b, src) +} + +// MarshalJSON delegates to the per-fork BlockContents that matches Version. +func (b *BlockContents) MarshalJSON() ([]byte, error) { + return marshalAsView(b) +} + +// UnmarshalJSON delegates to the per-fork BlockContents that matches +// Version. Caller must set Version before calling. +func (b *BlockContents) UnmarshalJSON(data []byte) error { + if err := unmarshalAsView(b, data); err != nil { + return err + } + + b.populateVersion(b.Version) + + return nil +} + +// MarshalYAML delegates to the per-fork BlockContents that matches Version. +func (b *BlockContents) MarshalYAML() ([]byte, error) { + return marshalAsViewYAML(b) +} + +// UnmarshalYAML delegates to the per-fork BlockContents that matches +// Version. Caller must set Version before calling. +func (b *BlockContents) UnmarshalYAML(data []byte) error { + if err := unmarshalAsViewYAML(b, data); err != nil { + return err + } + + b.populateVersion(b.Version) + + return nil +} diff --git a/api/v1/all/blockcontents_ssz.go b/api/v1/all/blockcontents_ssz.go new file mode 100644 index 00000000..d2b805e4 --- /dev/null +++ b/api/v1/all/blockcontents_ssz.go @@ -0,0 +1,6638 @@ +// Code generated by dynamic-ssz. DO NOT EDIT. +// Hash: 40fb6011d06db0c0d0a2976e96bf993a49e919c83f6d8aee92e4e514a6ecb231 +// Version: v1.3.2 (https://github.com/pk910/dynamic-ssz) +package all + +import ( + "encoding/binary" + "math/bits" + + "github.com/ethpandaops/go-eth2-client/api/v1/deneb" + "github.com/ethpandaops/go-eth2-client/api/v1/electra" + "github.com/ethpandaops/go-eth2-client/api/v1/fulu" + "github.com/ethpandaops/go-eth2-client/spec/all" + "github.com/ethpandaops/go-eth2-client/spec/altair" + "github.com/ethpandaops/go-eth2-client/spec/capella" + electra1 "github.com/ethpandaops/go-eth2-client/spec/electra" + "github.com/ethpandaops/go-eth2-client/spec/phase0" + "github.com/holiman/uint256" + "github.com/pk910/dynamic-ssz/hasher" + "github.com/pk910/dynamic-ssz/sszutils" +) + +var _ = sszutils.ErrListTooBig + +var _ = sszutils.Annotate[*deneb.BlockContents](`ssz-static:"false"`) +var _ = sszutils.Annotate[*electra.BlockContents](`ssz-static:"false"`) +var _ = sszutils.Annotate[*fulu.BlockContents](`ssz-static:"false"`) + +func (t *BlockContents) MarshalSSZDynView(view any) func(ds sszutils.DynamicSpecs, buf []byte) ([]byte, error) { + switch view.(type) { + case *deneb.BlockContents: + return t.marshalSSZView_BlockContents + case *electra.BlockContents: + return t.marshalSSZView_BlockContents_0 + case *fulu.BlockContents: + return t.marshalSSZView_BlockContents_1 + } + return nil +} +func (t *BlockContents) marshalSSZView_BlockContents(ds sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + dst = buf + expr0, err := sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE/8", 64) + if err != nil { + return dst, err + } + expr1, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_PROPOSER_SLASHINGS", 16) + if err != nil { + return dst, err + } + expr2, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_ATTESTER_SLASHINGS", 2) + if err != nil { + return dst, err + } + expr3, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_ATTESTATIONS", 128) + if err != nil { + return dst, err + } + expr4, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_VALIDATORS_PER_COMMITTEE", 2048) + if err != nil { + return dst, err + } + expr5, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_DEPOSITS", 16) + if err != nil { + return dst, err + } + expr6, err := sszutils.ResolveSpecValueWithDefault(ds, "DEPOSIT_CONTRACT_TREE_DEPTH+1", 33) + if err != nil { + return dst, err + } + expr7, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_VOLUNTARY_EXITS", 16) + if err != nil { + return dst, err + } + expr8, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_EXTRA_DATA_BYTES", 32) + if err != nil { + return dst, err + } + expr9, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_TRANSACTIONS_PER_PAYLOAD", 1048576) + if err != nil { + return dst, err + } + expr10, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BYTES_PER_TRANSACTION", 1073741824) + if err != nil { + return dst, err + } + expr11, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_WITHDRAWALS_PER_PAYLOAD", 16) + if err != nil { + return dst, err + } + expr12, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BLS_TO_EXECUTION_CHANGES", 16) + if err != nil { + return dst, err + } + expr13, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BLOB_COMMITMENTS_PER_BLOCK", 4096) + if err != nil { + return dst, err + } + zeroBytes := sszutils.ZeroBytes() + if t == nil { + t = new(BlockContents) + } + dstlen := len(dst) + // Offset Field #0 'Block' + // Offset Field #1 'KZGProofs' + // Offset Field #2 'Blobs' + dst = append(dst, zeroBytes[:12]...) + { // Dynamic Field #0 'Block' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.Block + if t == nil { + t = new(all.BeaconBlock) + } + dstlen := len(dst) + { // Static Field #0 'Slot' + dst = binary.LittleEndian.AppendUint64(dst, uint64(t.Slot)) + } + { // Static Field #1 'ProposerIndex' + dst = binary.LittleEndian.AppendUint64(dst, uint64(t.ProposerIndex)) + } + { // Static Field #2 'ParentRoot' + dst = append(dst, t.ParentRoot[:32]...) + } + { // Static Field #3 'StateRoot' + dst = append(dst, t.StateRoot[:32]...) + } + // Offset Field #4 'Body' + dst = append(dst, 0, 0, 0, 0) + { // Dynamic Field #4 'Body' + binary.LittleEndian.PutUint32(dst[dstlen+80:], uint32(len(dst)-dstlen)) + t := t.Body + if t == nil { + t = new(all.BeaconBlockBody) + } + dstlen := len(dst) + { // Static Field #0 'RANDAOReveal' + dst = append(dst, t.RANDAOReveal[:96]...) + } + { // Static Field #1 'ETH1Data' + t := t.ETH1Data + if t == nil { + t = new(phase0.ETH1Data) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "Block.Body.ETH1Data") + } + } + { // Static Field #2 'Graffiti' + dst = append(dst, t.Graffiti[:32]...) + } + // Offset Field #3 'ProposerSlashings' + // Offset Field #4 'AttesterSlashings' + // Offset Field #5 'Attestations' + // Offset Field #6 'Deposits' + // Offset Field #7 'VoluntaryExits' + dst = append(dst, zeroBytes[:20]...) + { // Static Field #8 'SyncAggregate' + t := t.SyncAggregate + if t == nil { + t = new(altair.SyncAggregate) + } + { // Static Field #0 'SyncCommitteeBits' + vlen := len(t.SyncCommitteeBits) + if vlen > int(expr0) { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(expr0)), "Block.Body.SyncAggregate.SyncCommitteeBits") + } + dst = append(dst, t.SyncCommitteeBits[:vlen]...) + if vlen < int(expr0) { + dst = sszutils.AppendZeroPadding(dst, (int(expr0)-vlen)*1) + } + } + { // Static Field #1 'SyncCommitteeSignature' + dst = append(dst, t.SyncCommitteeSignature[:96]...) + } + } + // Offset Field #9 'ExecutionPayload' + offset9 := len(dst) + // Offset Field #10 'BLSToExecutionChanges' + // Offset Field #11 'BlobKZGCommitments' + dst = append(dst, zeroBytes[:12]...) + { // Dynamic Field #3 'ProposerSlashings' + binary.LittleEndian.PutUint32(dst[dstlen+200:], uint32(len(dst)-dstlen)) + t := t.ProposerSlashings + vlen := len(t) + if vlen > int(expr1) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr1)), "Block.Body.ProposerSlashings") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(phase0.ProposerSlashing) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "Block.Body.ProposerSlashings[%d]", idx1) + } + } + } + { // Dynamic Field #4 'AttesterSlashings' + binary.LittleEndian.PutUint32(dst[dstlen+204:], uint32(len(dst)-dstlen)) + t := t.AttesterSlashings + vlen := len(t) + if vlen > int(expr2) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr2)), "Block.Body.AttesterSlashings") + } + dstlen := len(dst) + dst = sszutils.AppendZeroPadding(dst, vlen*4) + for idx1 := range vlen { + binary.LittleEndian.PutUint32(dst[dstlen+(idx1*4):], uint32(len(dst)-dstlen)) + t := t[idx1] + if t == nil { + t = new(all.AttesterSlashing) + } + dstlen := len(dst) + // Offset Field #0 'Attestation1' + // Offset Field #1 'Attestation2' + dst = append(dst, 0, 0, 0, 0, 0, 0, 0, 0) + { // Dynamic Field #0 'Attestation1' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.Attestation1 + if t == nil { + t = new(all.IndexedAttestation) + } + dstlen := len(dst) + // Offset Field #0 'AttestingIndices' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.AttestationData) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "Block.Body.AttesterSlashings[%d].Attestation1.Data", idx1) + } + } + { // Static Field #2 'Signature' + dst = append(dst, t.Signature[:96]...) + } + { // Dynamic Field #0 'AttestingIndices' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.AttestingIndices + vlen := len(t) + if vlen > 2048 { + return nil, sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(vlen, 2048), "Block.Body.AttesterSlashings[%d].Attestation1.AttestingIndices", idx1) + } + dst = sszutils.MarshalUint64Slice(dst, t[:vlen]) + } + } + { // Dynamic Field #1 'Attestation2' + binary.LittleEndian.PutUint32(dst[dstlen+4:], uint32(len(dst)-dstlen)) + t := t.Attestation2 + if t == nil { + t = new(all.IndexedAttestation) + } + dstlen := len(dst) + // Offset Field #0 'AttestingIndices' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.AttestationData) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "Block.Body.AttesterSlashings[%d].Attestation2.Data", idx1) + } + } + { // Static Field #2 'Signature' + dst = append(dst, t.Signature[:96]...) + } + { // Dynamic Field #0 'AttestingIndices' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.AttestingIndices + vlen := len(t) + if vlen > 2048 { + return nil, sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(vlen, 2048), "Block.Body.AttesterSlashings[%d].Attestation2.AttestingIndices", idx1) + } + dst = sszutils.MarshalUint64Slice(dst, t[:vlen]) + } + } + } + } + { // Dynamic Field #5 'Attestations' + binary.LittleEndian.PutUint32(dst[dstlen+208:], uint32(len(dst)-dstlen)) + t := t.Attestations + vlen := len(t) + if vlen > int(expr3) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr3)), "Block.Body.Attestations") + } + dstlen := len(dst) + dst = sszutils.AppendZeroPadding(dst, vlen*4) + for idx1 := range vlen { + binary.LittleEndian.PutUint32(dst[dstlen+(idx1*4):], uint32(len(dst)-dstlen)) + t := t[idx1] + if t == nil { + t = new(all.Attestation) + } + dstlen := len(dst) + // Offset Field #0 'AggregationBits' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.AttestationData) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "Block.Body.Attestations[%d].Data", idx1) + } + } + { // Static Field #2 'Signature' + dst = append(dst, t.Signature[:96]...) + } + { // Dynamic Field #0 'AggregationBits' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.AggregationBits + vlen := len(t) + bval := []byte(t[:]) + if vlen == 0 { + bval = []byte{0x01} + } else if bval[vlen-1] == 0x00 { + return nil, sszutils.ErrorWithPathf(sszutils.ErrBitlistNotTerminatedFn(), "Block.Body.Attestations[%d].AggregationBits", idx1) + } + if vlen > 0 { + bitCount := 8*(vlen-1) + bits.Len8(bval[vlen-1]) - 1 + if bitCount > int(expr4) { + return nil, sszutils.ErrorWithPathf(sszutils.ErrBitlistLengthFn(bitCount, int(expr4)), "Block.Body.Attestations[%d].AggregationBits", idx1) + } + } + dst = append(dst, bval...) + } + } + } + { // Dynamic Field #6 'Deposits' + binary.LittleEndian.PutUint32(dst[dstlen+212:], uint32(len(dst)-dstlen)) + t := t.Deposits + vlen := len(t) + if vlen > int(expr5) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr5)), "Block.Body.Deposits") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(phase0.Deposit) + } + { // Static Field #0 'Proof' + t := t.Proof + vlen := len(t) + if vlen > int(expr6) { + return nil, sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, int(expr6)), "Block.Body.Deposits[%d].Proof", idx1) + } + for idx2 := range vlen { + vlen := len(t[idx2]) + if vlen > 32 { + return nil, sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, 32), "Block.Body.Deposits[%d].Proof[%d]", idx1, idx2) + } + dst = append(dst, t[idx2][:vlen]...) + if vlen < 32 { + dst = sszutils.AppendZeroPadding(dst, (32-vlen)*1) + } + } + if vlen < int(expr6) { + dst = sszutils.AppendZeroPadding(dst, (int(expr6)-vlen)*32) + } + } + { // Static Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.DepositData) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "Block.Body.Deposits[%d].Data", idx1) + } + } + } + } + { // Dynamic Field #7 'VoluntaryExits' + binary.LittleEndian.PutUint32(dst[dstlen+216:], uint32(len(dst)-dstlen)) + t := t.VoluntaryExits + vlen := len(t) + if vlen > int(expr7) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr7)), "Block.Body.VoluntaryExits") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(phase0.SignedVoluntaryExit) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "Block.Body.VoluntaryExits[%d]", idx1) + } + } + } + { // Dynamic Field #9 'ExecutionPayload' + binary.LittleEndian.PutUint32(dst[offset9:], uint32(len(dst)-dstlen)) + t := t.ExecutionPayload + if t == nil { + t = new(all.ExecutionPayload) + } + dstlen := len(dst) + { // Static Field #0 'ParentHash' + dst = append(dst, t.ParentHash[:32]...) + } + { // Static Field #1 'FeeRecipient' + dst = append(dst, t.FeeRecipient[:20]...) + } + { // Static Field #2 'StateRoot' + dst = append(dst, t.StateRoot[:32]...) + } + { // Static Field #3 'ReceiptsRoot' + dst = append(dst, t.ReceiptsRoot[:32]...) + } + { // Static Field #4 'LogsBloom' + dst = append(dst, t.LogsBloom[:256]...) + } + { // Static Field #5 'PrevRandao' + dst = append(dst, t.PrevRandao[:32]...) + } + { // Static Field #6 'BlockNumber' + dst = binary.LittleEndian.AppendUint64(dst, t.BlockNumber) + } + { // Static Field #7 'GasLimit' + dst = binary.LittleEndian.AppendUint64(dst, t.GasLimit) + } + { // Static Field #8 'GasUsed' + dst = binary.LittleEndian.AppendUint64(dst, t.GasUsed) + } + { // Static Field #9 'Timestamp' + dst = binary.LittleEndian.AppendUint64(dst, t.Timestamp) + } + // Offset Field #10 'ExtraData' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #11 'BaseFeePerGas' + t := t.BaseFeePerGas + if t == nil { + t = new(uint256.Int) + } + dst = sszutils.MarshalUint64Slice(dst, (*t)[:4]) + } + { // Static Field #12 'BlockHash' + dst = append(dst, t.BlockHash[:32]...) + } + // Offset Field #13 'Transactions' + // Offset Field #14 'Withdrawals' + dst = append(dst, 0, 0, 0, 0, 0, 0, 0, 0) + { // Static Field #15 'BlobGasUsed' + dst = binary.LittleEndian.AppendUint64(dst, t.BlobGasUsed) + } + { // Static Field #16 'ExcessBlobGas' + dst = binary.LittleEndian.AppendUint64(dst, t.ExcessBlobGas) + } + { // Dynamic Field #10 'ExtraData' + binary.LittleEndian.PutUint32(dst[dstlen+436:], uint32(len(dst)-dstlen)) + vlen := len(t.ExtraData) + if vlen > int(expr8) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr8)), "Block.Body.ExecutionPayload.ExtraData") + } + dst = append(dst, t.ExtraData[:]...) + } + { // Dynamic Field #13 'Transactions' + binary.LittleEndian.PutUint32(dst[dstlen+504:], uint32(len(dst)-dstlen)) + t := t.Transactions + vlen := len(t) + if vlen > int(expr9) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr9)), "Block.Body.ExecutionPayload.Transactions") + } + dstlen := len(dst) + dst = sszutils.AppendZeroPadding(dst, vlen*4) + for idx1 := range vlen { + binary.LittleEndian.PutUint32(dst[dstlen+(idx1*4):], uint32(len(dst)-dstlen)) + vlen := len(t[idx1]) + if vlen > int(expr10) { + return nil, sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(vlen, int(expr10)), "Block.Body.ExecutionPayload.Transactions[%d]", idx1) + } + dst = append(dst, t[idx1][:]...) + } + } + { // Dynamic Field #14 'Withdrawals' + binary.LittleEndian.PutUint32(dst[dstlen+508:], uint32(len(dst)-dstlen)) + t := t.Withdrawals + vlen := len(t) + if vlen > int(expr11) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr11)), "Block.Body.ExecutionPayload.Withdrawals") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(capella.Withdrawal) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "Block.Body.ExecutionPayload.Withdrawals[%d]", idx1) + } + } + } + } + { // Dynamic Field #10 'BLSToExecutionChanges' + binary.LittleEndian.PutUint32(dst[offset9+4:], uint32(len(dst)-dstlen)) + t := t.BLSToExecutionChanges + vlen := len(t) + if vlen > int(expr12) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr12)), "Block.Body.BLSToExecutionChanges") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(capella.SignedBLSToExecutionChange) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "Block.Body.BLSToExecutionChanges[%d]", idx1) + } + } + } + { // Dynamic Field #11 'BlobKZGCommitments' + binary.LittleEndian.PutUint32(dst[offset9+8:], uint32(len(dst)-dstlen)) + t := t.BlobKZGCommitments + vlen := len(t) + if vlen > int(expr13) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr13)), "Block.Body.BlobKZGCommitments") + } + dst = sszutils.MarshalFixedBytesSlice(dst, t[:vlen]) + } + } + } + { // Dynamic Field #1 'KZGProofs' + binary.LittleEndian.PutUint32(dst[dstlen+4:], uint32(len(dst)-dstlen)) + t := t.KZGProofs + vlen := len(t) + if vlen > int(expr13) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr13)), "KZGProofs") + } + dst = sszutils.MarshalFixedBytesSlice(dst, t[:vlen]) + } + { // Dynamic Field #2 'Blobs' + binary.LittleEndian.PutUint32(dst[dstlen+8:], uint32(len(dst)-dstlen)) + t := t.Blobs + vlen := len(t) + if vlen > int(expr13) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr13)), "Blobs") + } + dst = sszutils.MarshalFixedBytesSlice(dst, t[:vlen]) + } + return dst, nil +} + +func (t *BlockContents) marshalSSZView_BlockContents_0(ds sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + dst = buf + expr0, err := sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE/8", 64) + if err != nil { + return dst, err + } + expr1, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_PROPOSER_SLASHINGS", 16) + if err != nil { + return dst, err + } + expr2, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_ATTESTER_SLASHINGS_ELECTRA", 1) + if err != nil { + return dst, err + } + expr3, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_VALIDATORS_PER_COMMITTEE*MAX_COMMITTEES_PER_SLOT", 131072) + if err != nil { + return dst, err + } + expr4, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_ATTESTATIONS_ELECTRA", 8) + if err != nil { + return dst, err + } + expr5, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_COMMITTEES_PER_SLOT/8", 8) + if err != nil { + return dst, err + } + expr6, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_DEPOSITS", 16) + if err != nil { + return dst, err + } + expr7, err := sszutils.ResolveSpecValueWithDefault(ds, "DEPOSIT_CONTRACT_TREE_DEPTH+1", 33) + if err != nil { + return dst, err + } + expr8, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_VOLUNTARY_EXITS", 16) + if err != nil { + return dst, err + } + expr9, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_EXTRA_DATA_BYTES", 32) + if err != nil { + return dst, err + } + expr10, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_TRANSACTIONS_PER_PAYLOAD", 1048576) + if err != nil { + return dst, err + } + expr11, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BYTES_PER_TRANSACTION", 1073741824) + if err != nil { + return dst, err + } + expr12, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_WITHDRAWALS_PER_PAYLOAD", 16) + if err != nil { + return dst, err + } + expr13, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BLS_TO_EXECUTION_CHANGES", 16) + if err != nil { + return dst, err + } + expr14, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BLOB_COMMITMENTS_PER_BLOCK", 4096) + if err != nil { + return dst, err + } + expr15, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_DEPOSIT_REQUESTS_PER_PAYLOAD", 8192) + if err != nil { + return dst, err + } + expr16, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_WITHDRAWAL_REQUESTS_PER_PAYLOAD", 16) + if err != nil { + return dst, err + } + expr17, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD", 2) + if err != nil { + return dst, err + } + zeroBytes := sszutils.ZeroBytes() + if t == nil { + t = new(BlockContents) + } + dstlen := len(dst) + // Offset Field #0 'Block' + // Offset Field #1 'KZGProofs' + // Offset Field #2 'Blobs' + dst = append(dst, zeroBytes[:12]...) + { // Dynamic Field #0 'Block' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.Block + if t == nil { + t = new(all.BeaconBlock) + } + dstlen := len(dst) + { // Static Field #0 'Slot' + dst = binary.LittleEndian.AppendUint64(dst, uint64(t.Slot)) + } + { // Static Field #1 'ProposerIndex' + dst = binary.LittleEndian.AppendUint64(dst, uint64(t.ProposerIndex)) + } + { // Static Field #2 'ParentRoot' + dst = append(dst, t.ParentRoot[:32]...) + } + { // Static Field #3 'StateRoot' + dst = append(dst, t.StateRoot[:32]...) + } + // Offset Field #4 'Body' + dst = append(dst, 0, 0, 0, 0) + { // Dynamic Field #4 'Body' + binary.LittleEndian.PutUint32(dst[dstlen+80:], uint32(len(dst)-dstlen)) + t := t.Body + if t == nil { + t = new(all.BeaconBlockBody) + } + dstlen := len(dst) + { // Static Field #0 'RANDAOReveal' + dst = append(dst, t.RANDAOReveal[:96]...) + } + { // Static Field #1 'ETH1Data' + t := t.ETH1Data + if t == nil { + t = new(phase0.ETH1Data) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "Block.Body.ETH1Data") + } + } + { // Static Field #2 'Graffiti' + dst = append(dst, t.Graffiti[:32]...) + } + // Offset Field #3 'ProposerSlashings' + // Offset Field #4 'AttesterSlashings' + // Offset Field #5 'Attestations' + // Offset Field #6 'Deposits' + // Offset Field #7 'VoluntaryExits' + dst = append(dst, zeroBytes[:20]...) + { // Static Field #8 'SyncAggregate' + t := t.SyncAggregate + if t == nil { + t = new(altair.SyncAggregate) + } + { // Static Field #0 'SyncCommitteeBits' + vlen := len(t.SyncCommitteeBits) + if vlen > int(expr0) { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(expr0)), "Block.Body.SyncAggregate.SyncCommitteeBits") + } + dst = append(dst, t.SyncCommitteeBits[:vlen]...) + if vlen < int(expr0) { + dst = sszutils.AppendZeroPadding(dst, (int(expr0)-vlen)*1) + } + } + { // Static Field #1 'SyncCommitteeSignature' + dst = append(dst, t.SyncCommitteeSignature[:96]...) + } + } + // Offset Field #9 'ExecutionPayload' + offset9 := len(dst) + // Offset Field #10 'BLSToExecutionChanges' + // Offset Field #11 'BlobKZGCommitments' + // Offset Field #12 'ExecutionRequests' + dst = append(dst, zeroBytes[:16]...) + { // Dynamic Field #3 'ProposerSlashings' + binary.LittleEndian.PutUint32(dst[dstlen+200:], uint32(len(dst)-dstlen)) + t := t.ProposerSlashings + vlen := len(t) + if vlen > int(expr1) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr1)), "Block.Body.ProposerSlashings") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(phase0.ProposerSlashing) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "Block.Body.ProposerSlashings[%d]", idx1) + } + } + } + { // Dynamic Field #4 'AttesterSlashings' + binary.LittleEndian.PutUint32(dst[dstlen+204:], uint32(len(dst)-dstlen)) + t := t.AttesterSlashings + vlen := len(t) + if vlen > int(expr2) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr2)), "Block.Body.AttesterSlashings") + } + dstlen := len(dst) + dst = sszutils.AppendZeroPadding(dst, vlen*4) + for idx1 := range vlen { + binary.LittleEndian.PutUint32(dst[dstlen+(idx1*4):], uint32(len(dst)-dstlen)) + t := t[idx1] + if t == nil { + t = new(all.AttesterSlashing) + } + dstlen := len(dst) + // Offset Field #0 'Attestation1' + // Offset Field #1 'Attestation2' + dst = append(dst, 0, 0, 0, 0, 0, 0, 0, 0) + { // Dynamic Field #0 'Attestation1' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.Attestation1 + if t == nil { + t = new(all.IndexedAttestation) + } + dstlen := len(dst) + // Offset Field #0 'AttestingIndices' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.AttestationData) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "Block.Body.AttesterSlashings[%d].Attestation1.Data", idx1) + } + } + { // Static Field #2 'Signature' + dst = append(dst, t.Signature[:96]...) + } + { // Dynamic Field #0 'AttestingIndices' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.AttestingIndices + vlen := len(t) + if vlen > int(expr3) { + return nil, sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(vlen, int(expr3)), "Block.Body.AttesterSlashings[%d].Attestation1.AttestingIndices", idx1) + } + dst = sszutils.MarshalUint64Slice(dst, t[:vlen]) + } + } + { // Dynamic Field #1 'Attestation2' + binary.LittleEndian.PutUint32(dst[dstlen+4:], uint32(len(dst)-dstlen)) + t := t.Attestation2 + if t == nil { + t = new(all.IndexedAttestation) + } + dstlen := len(dst) + // Offset Field #0 'AttestingIndices' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.AttestationData) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "Block.Body.AttesterSlashings[%d].Attestation2.Data", idx1) + } + } + { // Static Field #2 'Signature' + dst = append(dst, t.Signature[:96]...) + } + { // Dynamic Field #0 'AttestingIndices' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.AttestingIndices + vlen := len(t) + if vlen > int(expr3) { + return nil, sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(vlen, int(expr3)), "Block.Body.AttesterSlashings[%d].Attestation2.AttestingIndices", idx1) + } + dst = sszutils.MarshalUint64Slice(dst, t[:vlen]) + } + } + } + } + { // Dynamic Field #5 'Attestations' + binary.LittleEndian.PutUint32(dst[dstlen+208:], uint32(len(dst)-dstlen)) + t := t.Attestations + vlen := len(t) + if vlen > int(expr4) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr4)), "Block.Body.Attestations") + } + dstlen := len(dst) + dst = sszutils.AppendZeroPadding(dst, vlen*4) + for idx1 := range vlen { + binary.LittleEndian.PutUint32(dst[dstlen+(idx1*4):], uint32(len(dst)-dstlen)) + t := t[idx1] + if t == nil { + t = new(all.Attestation) + } + dstlen := len(dst) + // Offset Field #0 'AggregationBits' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.AttestationData) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "Block.Body.Attestations[%d].Data", idx1) + } + } + { // Static Field #2 'Signature' + dst = append(dst, t.Signature[:96]...) + } + { // Static Field #3 'CommitteeBits' + vlen := len(t.CommitteeBits) + if vlen > int(expr5) { + return nil, sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, int(expr5)), "Block.Body.Attestations[%d].CommitteeBits", idx1) + } + dst = append(dst, t.CommitteeBits[:vlen]...) + if vlen < int(expr5) { + dst = sszutils.AppendZeroPadding(dst, (int(expr5)-vlen)*1) + } + } + { // Dynamic Field #0 'AggregationBits' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.AggregationBits + vlen := len(t) + bval := []byte(t[:]) + if vlen == 0 { + bval = []byte{0x01} + } else if bval[vlen-1] == 0x00 { + return nil, sszutils.ErrorWithPathf(sszutils.ErrBitlistNotTerminatedFn(), "Block.Body.Attestations[%d].AggregationBits", idx1) + } + if vlen > 0 { + bitCount := 8*(vlen-1) + bits.Len8(bval[vlen-1]) - 1 + if bitCount > int(expr3) { + return nil, sszutils.ErrorWithPathf(sszutils.ErrBitlistLengthFn(bitCount, int(expr3)), "Block.Body.Attestations[%d].AggregationBits", idx1) + } + } + dst = append(dst, bval...) + } + } + } + { // Dynamic Field #6 'Deposits' + binary.LittleEndian.PutUint32(dst[dstlen+212:], uint32(len(dst)-dstlen)) + t := t.Deposits + vlen := len(t) + if vlen > int(expr6) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr6)), "Block.Body.Deposits") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(phase0.Deposit) + } + { // Static Field #0 'Proof' + t := t.Proof + vlen := len(t) + if vlen > int(expr7) { + return nil, sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, int(expr7)), "Block.Body.Deposits[%d].Proof", idx1) + } + for idx2 := range vlen { + vlen := len(t[idx2]) + if vlen > 32 { + return nil, sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, 32), "Block.Body.Deposits[%d].Proof[%d]", idx1, idx2) + } + dst = append(dst, t[idx2][:vlen]...) + if vlen < 32 { + dst = sszutils.AppendZeroPadding(dst, (32-vlen)*1) + } + } + if vlen < int(expr7) { + dst = sszutils.AppendZeroPadding(dst, (int(expr7)-vlen)*32) + } + } + { // Static Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.DepositData) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "Block.Body.Deposits[%d].Data", idx1) + } + } + } + } + { // Dynamic Field #7 'VoluntaryExits' + binary.LittleEndian.PutUint32(dst[dstlen+216:], uint32(len(dst)-dstlen)) + t := t.VoluntaryExits + vlen := len(t) + if vlen > int(expr8) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr8)), "Block.Body.VoluntaryExits") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(phase0.SignedVoluntaryExit) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "Block.Body.VoluntaryExits[%d]", idx1) + } + } + } + { // Dynamic Field #9 'ExecutionPayload' + binary.LittleEndian.PutUint32(dst[offset9:], uint32(len(dst)-dstlen)) + t := t.ExecutionPayload + if t == nil { + t = new(all.ExecutionPayload) + } + dstlen := len(dst) + { // Static Field #0 'ParentHash' + dst = append(dst, t.ParentHash[:32]...) + } + { // Static Field #1 'FeeRecipient' + dst = append(dst, t.FeeRecipient[:20]...) + } + { // Static Field #2 'StateRoot' + dst = append(dst, t.StateRoot[:32]...) + } + { // Static Field #3 'ReceiptsRoot' + dst = append(dst, t.ReceiptsRoot[:32]...) + } + { // Static Field #4 'LogsBloom' + dst = append(dst, t.LogsBloom[:256]...) + } + { // Static Field #5 'PrevRandao' + dst = append(dst, t.PrevRandao[:32]...) + } + { // Static Field #6 'BlockNumber' + dst = binary.LittleEndian.AppendUint64(dst, t.BlockNumber) + } + { // Static Field #7 'GasLimit' + dst = binary.LittleEndian.AppendUint64(dst, t.GasLimit) + } + { // Static Field #8 'GasUsed' + dst = binary.LittleEndian.AppendUint64(dst, t.GasUsed) + } + { // Static Field #9 'Timestamp' + dst = binary.LittleEndian.AppendUint64(dst, t.Timestamp) + } + // Offset Field #10 'ExtraData' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #11 'BaseFeePerGas' + t := t.BaseFeePerGas + if t == nil { + t = new(uint256.Int) + } + dst = sszutils.MarshalUint64Slice(dst, (*t)[:4]) + } + { // Static Field #12 'BlockHash' + dst = append(dst, t.BlockHash[:32]...) + } + // Offset Field #13 'Transactions' + // Offset Field #14 'Withdrawals' + dst = append(dst, 0, 0, 0, 0, 0, 0, 0, 0) + { // Static Field #15 'BlobGasUsed' + dst = binary.LittleEndian.AppendUint64(dst, t.BlobGasUsed) + } + { // Static Field #16 'ExcessBlobGas' + dst = binary.LittleEndian.AppendUint64(dst, t.ExcessBlobGas) + } + { // Dynamic Field #10 'ExtraData' + binary.LittleEndian.PutUint32(dst[dstlen+436:], uint32(len(dst)-dstlen)) + vlen := len(t.ExtraData) + if vlen > int(expr9) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr9)), "Block.Body.ExecutionPayload.ExtraData") + } + dst = append(dst, t.ExtraData[:]...) + } + { // Dynamic Field #13 'Transactions' + binary.LittleEndian.PutUint32(dst[dstlen+504:], uint32(len(dst)-dstlen)) + t := t.Transactions + vlen := len(t) + if vlen > int(expr10) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr10)), "Block.Body.ExecutionPayload.Transactions") + } + dstlen := len(dst) + dst = sszutils.AppendZeroPadding(dst, vlen*4) + for idx1 := range vlen { + binary.LittleEndian.PutUint32(dst[dstlen+(idx1*4):], uint32(len(dst)-dstlen)) + vlen := len(t[idx1]) + if vlen > int(expr11) { + return nil, sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(vlen, int(expr11)), "Block.Body.ExecutionPayload.Transactions[%d]", idx1) + } + dst = append(dst, t[idx1][:]...) + } + } + { // Dynamic Field #14 'Withdrawals' + binary.LittleEndian.PutUint32(dst[dstlen+508:], uint32(len(dst)-dstlen)) + t := t.Withdrawals + vlen := len(t) + if vlen > int(expr12) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr12)), "Block.Body.ExecutionPayload.Withdrawals") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(capella.Withdrawal) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "Block.Body.ExecutionPayload.Withdrawals[%d]", idx1) + } + } + } + } + { // Dynamic Field #10 'BLSToExecutionChanges' + binary.LittleEndian.PutUint32(dst[offset9+4:], uint32(len(dst)-dstlen)) + t := t.BLSToExecutionChanges + vlen := len(t) + if vlen > int(expr13) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr13)), "Block.Body.BLSToExecutionChanges") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(capella.SignedBLSToExecutionChange) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "Block.Body.BLSToExecutionChanges[%d]", idx1) + } + } + } + { // Dynamic Field #11 'BlobKZGCommitments' + binary.LittleEndian.PutUint32(dst[offset9+8:], uint32(len(dst)-dstlen)) + t := t.BlobKZGCommitments + vlen := len(t) + if vlen > int(expr14) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr14)), "Block.Body.BlobKZGCommitments") + } + dst = sszutils.MarshalFixedBytesSlice(dst, t[:vlen]) + } + { // Dynamic Field #12 'ExecutionRequests' + binary.LittleEndian.PutUint32(dst[offset9+12:], uint32(len(dst)-dstlen)) + t := t.ExecutionRequests + if t == nil { + t = new(all.ExecutionRequests) + } + dstlen := len(dst) + // Offset Field #0 'Deposits' + // Offset Field #1 'Withdrawals' + // Offset Field #2 'Consolidations' + dst = append(dst, zeroBytes[:12]...) + { // Dynamic Field #0 'Deposits' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.Deposits + vlen := len(t) + if vlen > int(expr15) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr15)), "Block.Body.ExecutionRequests.Deposits") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(electra1.DepositRequest) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "Block.Body.ExecutionRequests.Deposits[%d]", idx1) + } + } + } + { // Dynamic Field #1 'Withdrawals' + binary.LittleEndian.PutUint32(dst[dstlen+4:], uint32(len(dst)-dstlen)) + t := t.Withdrawals + vlen := len(t) + if vlen > int(expr16) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr16)), "Block.Body.ExecutionRequests.Withdrawals") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(electra1.WithdrawalRequest) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "Block.Body.ExecutionRequests.Withdrawals[%d]", idx1) + } + } + } + { // Dynamic Field #2 'Consolidations' + binary.LittleEndian.PutUint32(dst[dstlen+8:], uint32(len(dst)-dstlen)) + t := t.Consolidations + vlen := len(t) + if vlen > int(expr17) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr17)), "Block.Body.ExecutionRequests.Consolidations") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(electra1.ConsolidationRequest) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "Block.Body.ExecutionRequests.Consolidations[%d]", idx1) + } + } + } + } + } + } + { // Dynamic Field #1 'KZGProofs' + binary.LittleEndian.PutUint32(dst[dstlen+4:], uint32(len(dst)-dstlen)) + t := t.KZGProofs + vlen := len(t) + if vlen > int(expr14) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr14)), "KZGProofs") + } + dst = sszutils.MarshalFixedBytesSlice(dst, t[:vlen]) + } + { // Dynamic Field #2 'Blobs' + binary.LittleEndian.PutUint32(dst[dstlen+8:], uint32(len(dst)-dstlen)) + t := t.Blobs + vlen := len(t) + if vlen > int(expr14) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr14)), "Blobs") + } + dst = sszutils.MarshalFixedBytesSlice(dst, t[:vlen]) + } + return dst, nil +} + +func (t *BlockContents) marshalSSZView_BlockContents_1(ds sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + dst = buf + expr0, err := sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE/8", 64) + if err != nil { + return dst, err + } + expr1, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_PROPOSER_SLASHINGS", 16) + if err != nil { + return dst, err + } + expr2, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_ATTESTER_SLASHINGS_ELECTRA", 1) + if err != nil { + return dst, err + } + expr3, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_VALIDATORS_PER_COMMITTEE*MAX_COMMITTEES_PER_SLOT", 131072) + if err != nil { + return dst, err + } + expr4, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_ATTESTATIONS_ELECTRA", 8) + if err != nil { + return dst, err + } + expr5, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_COMMITTEES_PER_SLOT/8", 8) + if err != nil { + return dst, err + } + expr6, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_DEPOSITS", 16) + if err != nil { + return dst, err + } + expr7, err := sszutils.ResolveSpecValueWithDefault(ds, "DEPOSIT_CONTRACT_TREE_DEPTH+1", 33) + if err != nil { + return dst, err + } + expr8, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_VOLUNTARY_EXITS", 16) + if err != nil { + return dst, err + } + expr9, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_EXTRA_DATA_BYTES", 32) + if err != nil { + return dst, err + } + expr10, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_TRANSACTIONS_PER_PAYLOAD", 1048576) + if err != nil { + return dst, err + } + expr11, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BYTES_PER_TRANSACTION", 1073741824) + if err != nil { + return dst, err + } + expr12, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_WITHDRAWALS_PER_PAYLOAD", 16) + if err != nil { + return dst, err + } + expr13, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BLS_TO_EXECUTION_CHANGES", 16) + if err != nil { + return dst, err + } + expr14, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BLOB_COMMITMENTS_PER_BLOCK", 4096) + if err != nil { + return dst, err + } + expr15, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_DEPOSIT_REQUESTS_PER_PAYLOAD", 8192) + if err != nil { + return dst, err + } + expr16, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_WITHDRAWAL_REQUESTS_PER_PAYLOAD", 16) + if err != nil { + return dst, err + } + expr17, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD", 2) + if err != nil { + return dst, err + } + zeroBytes := sszutils.ZeroBytes() + if t == nil { + t = new(BlockContents) + } + dstlen := len(dst) + // Offset Field #0 'Block' + // Offset Field #1 'KZGProofs' + // Offset Field #2 'Blobs' + dst = append(dst, zeroBytes[:12]...) + { // Dynamic Field #0 'Block' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.Block + if t == nil { + t = new(all.BeaconBlock) + } + dstlen := len(dst) + { // Static Field #0 'Slot' + dst = binary.LittleEndian.AppendUint64(dst, uint64(t.Slot)) + } + { // Static Field #1 'ProposerIndex' + dst = binary.LittleEndian.AppendUint64(dst, uint64(t.ProposerIndex)) + } + { // Static Field #2 'ParentRoot' + dst = append(dst, t.ParentRoot[:32]...) + } + { // Static Field #3 'StateRoot' + dst = append(dst, t.StateRoot[:32]...) + } + // Offset Field #4 'Body' + dst = append(dst, 0, 0, 0, 0) + { // Dynamic Field #4 'Body' + binary.LittleEndian.PutUint32(dst[dstlen+80:], uint32(len(dst)-dstlen)) + t := t.Body + if t == nil { + t = new(all.BeaconBlockBody) + } + dstlen := len(dst) + { // Static Field #0 'RANDAOReveal' + dst = append(dst, t.RANDAOReveal[:96]...) + } + { // Static Field #1 'ETH1Data' + t := t.ETH1Data + if t == nil { + t = new(phase0.ETH1Data) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "Block.Body.ETH1Data") + } + } + { // Static Field #2 'Graffiti' + dst = append(dst, t.Graffiti[:32]...) + } + // Offset Field #3 'ProposerSlashings' + // Offset Field #4 'AttesterSlashings' + // Offset Field #5 'Attestations' + // Offset Field #6 'Deposits' + // Offset Field #7 'VoluntaryExits' + dst = append(dst, zeroBytes[:20]...) + { // Static Field #8 'SyncAggregate' + t := t.SyncAggregate + if t == nil { + t = new(altair.SyncAggregate) + } + { // Static Field #0 'SyncCommitteeBits' + vlen := len(t.SyncCommitteeBits) + if vlen > int(expr0) { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(expr0)), "Block.Body.SyncAggregate.SyncCommitteeBits") + } + dst = append(dst, t.SyncCommitteeBits[:vlen]...) + if vlen < int(expr0) { + dst = sszutils.AppendZeroPadding(dst, (int(expr0)-vlen)*1) + } + } + { // Static Field #1 'SyncCommitteeSignature' + dst = append(dst, t.SyncCommitteeSignature[:96]...) + } + } + // Offset Field #9 'ExecutionPayload' + offset9 := len(dst) + // Offset Field #10 'BLSToExecutionChanges' + // Offset Field #11 'BlobKZGCommitments' + // Offset Field #12 'ExecutionRequests' + dst = append(dst, zeroBytes[:16]...) + { // Dynamic Field #3 'ProposerSlashings' + binary.LittleEndian.PutUint32(dst[dstlen+200:], uint32(len(dst)-dstlen)) + t := t.ProposerSlashings + vlen := len(t) + if vlen > int(expr1) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr1)), "Block.Body.ProposerSlashings") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(phase0.ProposerSlashing) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "Block.Body.ProposerSlashings[%d]", idx1) + } + } + } + { // Dynamic Field #4 'AttesterSlashings' + binary.LittleEndian.PutUint32(dst[dstlen+204:], uint32(len(dst)-dstlen)) + t := t.AttesterSlashings + vlen := len(t) + if vlen > int(expr2) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr2)), "Block.Body.AttesterSlashings") + } + dstlen := len(dst) + dst = sszutils.AppendZeroPadding(dst, vlen*4) + for idx1 := range vlen { + binary.LittleEndian.PutUint32(dst[dstlen+(idx1*4):], uint32(len(dst)-dstlen)) + t := t[idx1] + if t == nil { + t = new(all.AttesterSlashing) + } + dstlen := len(dst) + // Offset Field #0 'Attestation1' + // Offset Field #1 'Attestation2' + dst = append(dst, 0, 0, 0, 0, 0, 0, 0, 0) + { // Dynamic Field #0 'Attestation1' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.Attestation1 + if t == nil { + t = new(all.IndexedAttestation) + } + dstlen := len(dst) + // Offset Field #0 'AttestingIndices' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.AttestationData) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "Block.Body.AttesterSlashings[%d].Attestation1.Data", idx1) + } + } + { // Static Field #2 'Signature' + dst = append(dst, t.Signature[:96]...) + } + { // Dynamic Field #0 'AttestingIndices' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.AttestingIndices + vlen := len(t) + if vlen > int(expr3) { + return nil, sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(vlen, int(expr3)), "Block.Body.AttesterSlashings[%d].Attestation1.AttestingIndices", idx1) + } + dst = sszutils.MarshalUint64Slice(dst, t[:vlen]) + } + } + { // Dynamic Field #1 'Attestation2' + binary.LittleEndian.PutUint32(dst[dstlen+4:], uint32(len(dst)-dstlen)) + t := t.Attestation2 + if t == nil { + t = new(all.IndexedAttestation) + } + dstlen := len(dst) + // Offset Field #0 'AttestingIndices' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.AttestationData) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "Block.Body.AttesterSlashings[%d].Attestation2.Data", idx1) + } + } + { // Static Field #2 'Signature' + dst = append(dst, t.Signature[:96]...) + } + { // Dynamic Field #0 'AttestingIndices' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.AttestingIndices + vlen := len(t) + if vlen > int(expr3) { + return nil, sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(vlen, int(expr3)), "Block.Body.AttesterSlashings[%d].Attestation2.AttestingIndices", idx1) + } + dst = sszutils.MarshalUint64Slice(dst, t[:vlen]) + } + } + } + } + { // Dynamic Field #5 'Attestations' + binary.LittleEndian.PutUint32(dst[dstlen+208:], uint32(len(dst)-dstlen)) + t := t.Attestations + vlen := len(t) + if vlen > int(expr4) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr4)), "Block.Body.Attestations") + } + dstlen := len(dst) + dst = sszutils.AppendZeroPadding(dst, vlen*4) + for idx1 := range vlen { + binary.LittleEndian.PutUint32(dst[dstlen+(idx1*4):], uint32(len(dst)-dstlen)) + t := t[idx1] + if t == nil { + t = new(all.Attestation) + } + dstlen := len(dst) + // Offset Field #0 'AggregationBits' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.AttestationData) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "Block.Body.Attestations[%d].Data", idx1) + } + } + { // Static Field #2 'Signature' + dst = append(dst, t.Signature[:96]...) + } + { // Static Field #3 'CommitteeBits' + vlen := len(t.CommitteeBits) + if vlen > int(expr5) { + return nil, sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, int(expr5)), "Block.Body.Attestations[%d].CommitteeBits", idx1) + } + dst = append(dst, t.CommitteeBits[:vlen]...) + if vlen < int(expr5) { + dst = sszutils.AppendZeroPadding(dst, (int(expr5)-vlen)*1) + } + } + { // Dynamic Field #0 'AggregationBits' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.AggregationBits + vlen := len(t) + bval := []byte(t[:]) + if vlen == 0 { + bval = []byte{0x01} + } else if bval[vlen-1] == 0x00 { + return nil, sszutils.ErrorWithPathf(sszutils.ErrBitlistNotTerminatedFn(), "Block.Body.Attestations[%d].AggregationBits", idx1) + } + if vlen > 0 { + bitCount := 8*(vlen-1) + bits.Len8(bval[vlen-1]) - 1 + if bitCount > int(expr3) { + return nil, sszutils.ErrorWithPathf(sszutils.ErrBitlistLengthFn(bitCount, int(expr3)), "Block.Body.Attestations[%d].AggregationBits", idx1) + } + } + dst = append(dst, bval...) + } + } + } + { // Dynamic Field #6 'Deposits' + binary.LittleEndian.PutUint32(dst[dstlen+212:], uint32(len(dst)-dstlen)) + t := t.Deposits + vlen := len(t) + if vlen > int(expr6) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr6)), "Block.Body.Deposits") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(phase0.Deposit) + } + { // Static Field #0 'Proof' + t := t.Proof + vlen := len(t) + if vlen > int(expr7) { + return nil, sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, int(expr7)), "Block.Body.Deposits[%d].Proof", idx1) + } + for idx2 := range vlen { + vlen := len(t[idx2]) + if vlen > 32 { + return nil, sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, 32), "Block.Body.Deposits[%d].Proof[%d]", idx1, idx2) + } + dst = append(dst, t[idx2][:vlen]...) + if vlen < 32 { + dst = sszutils.AppendZeroPadding(dst, (32-vlen)*1) + } + } + if vlen < int(expr7) { + dst = sszutils.AppendZeroPadding(dst, (int(expr7)-vlen)*32) + } + } + { // Static Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.DepositData) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "Block.Body.Deposits[%d].Data", idx1) + } + } + } + } + { // Dynamic Field #7 'VoluntaryExits' + binary.LittleEndian.PutUint32(dst[dstlen+216:], uint32(len(dst)-dstlen)) + t := t.VoluntaryExits + vlen := len(t) + if vlen > int(expr8) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr8)), "Block.Body.VoluntaryExits") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(phase0.SignedVoluntaryExit) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "Block.Body.VoluntaryExits[%d]", idx1) + } + } + } + { // Dynamic Field #9 'ExecutionPayload' + binary.LittleEndian.PutUint32(dst[offset9:], uint32(len(dst)-dstlen)) + t := t.ExecutionPayload + if t == nil { + t = new(all.ExecutionPayload) + } + dstlen := len(dst) + { // Static Field #0 'ParentHash' + dst = append(dst, t.ParentHash[:32]...) + } + { // Static Field #1 'FeeRecipient' + dst = append(dst, t.FeeRecipient[:20]...) + } + { // Static Field #2 'StateRoot' + dst = append(dst, t.StateRoot[:32]...) + } + { // Static Field #3 'ReceiptsRoot' + dst = append(dst, t.ReceiptsRoot[:32]...) + } + { // Static Field #4 'LogsBloom' + dst = append(dst, t.LogsBloom[:256]...) + } + { // Static Field #5 'PrevRandao' + dst = append(dst, t.PrevRandao[:32]...) + } + { // Static Field #6 'BlockNumber' + dst = binary.LittleEndian.AppendUint64(dst, t.BlockNumber) + } + { // Static Field #7 'GasLimit' + dst = binary.LittleEndian.AppendUint64(dst, t.GasLimit) + } + { // Static Field #8 'GasUsed' + dst = binary.LittleEndian.AppendUint64(dst, t.GasUsed) + } + { // Static Field #9 'Timestamp' + dst = binary.LittleEndian.AppendUint64(dst, t.Timestamp) + } + // Offset Field #10 'ExtraData' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #11 'BaseFeePerGas' + t := t.BaseFeePerGas + if t == nil { + t = new(uint256.Int) + } + dst = sszutils.MarshalUint64Slice(dst, (*t)[:4]) + } + { // Static Field #12 'BlockHash' + dst = append(dst, t.BlockHash[:32]...) + } + // Offset Field #13 'Transactions' + // Offset Field #14 'Withdrawals' + dst = append(dst, 0, 0, 0, 0, 0, 0, 0, 0) + { // Static Field #15 'BlobGasUsed' + dst = binary.LittleEndian.AppendUint64(dst, t.BlobGasUsed) + } + { // Static Field #16 'ExcessBlobGas' + dst = binary.LittleEndian.AppendUint64(dst, t.ExcessBlobGas) + } + { // Dynamic Field #10 'ExtraData' + binary.LittleEndian.PutUint32(dst[dstlen+436:], uint32(len(dst)-dstlen)) + vlen := len(t.ExtraData) + if vlen > int(expr9) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr9)), "Block.Body.ExecutionPayload.ExtraData") + } + dst = append(dst, t.ExtraData[:]...) + } + { // Dynamic Field #13 'Transactions' + binary.LittleEndian.PutUint32(dst[dstlen+504:], uint32(len(dst)-dstlen)) + t := t.Transactions + vlen := len(t) + if vlen > int(expr10) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr10)), "Block.Body.ExecutionPayload.Transactions") + } + dstlen := len(dst) + dst = sszutils.AppendZeroPadding(dst, vlen*4) + for idx1 := range vlen { + binary.LittleEndian.PutUint32(dst[dstlen+(idx1*4):], uint32(len(dst)-dstlen)) + vlen := len(t[idx1]) + if vlen > int(expr11) { + return nil, sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(vlen, int(expr11)), "Block.Body.ExecutionPayload.Transactions[%d]", idx1) + } + dst = append(dst, t[idx1][:]...) + } + } + { // Dynamic Field #14 'Withdrawals' + binary.LittleEndian.PutUint32(dst[dstlen+508:], uint32(len(dst)-dstlen)) + t := t.Withdrawals + vlen := len(t) + if vlen > int(expr12) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr12)), "Block.Body.ExecutionPayload.Withdrawals") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(capella.Withdrawal) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "Block.Body.ExecutionPayload.Withdrawals[%d]", idx1) + } + } + } + } + { // Dynamic Field #10 'BLSToExecutionChanges' + binary.LittleEndian.PutUint32(dst[offset9+4:], uint32(len(dst)-dstlen)) + t := t.BLSToExecutionChanges + vlen := len(t) + if vlen > int(expr13) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr13)), "Block.Body.BLSToExecutionChanges") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(capella.SignedBLSToExecutionChange) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "Block.Body.BLSToExecutionChanges[%d]", idx1) + } + } + } + { // Dynamic Field #11 'BlobKZGCommitments' + binary.LittleEndian.PutUint32(dst[offset9+8:], uint32(len(dst)-dstlen)) + t := t.BlobKZGCommitments + vlen := len(t) + if vlen > int(expr14) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr14)), "Block.Body.BlobKZGCommitments") + } + dst = sszutils.MarshalFixedBytesSlice(dst, t[:vlen]) + } + { // Dynamic Field #12 'ExecutionRequests' + binary.LittleEndian.PutUint32(dst[offset9+12:], uint32(len(dst)-dstlen)) + t := t.ExecutionRequests + if t == nil { + t = new(all.ExecutionRequests) + } + dstlen := len(dst) + // Offset Field #0 'Deposits' + // Offset Field #1 'Withdrawals' + // Offset Field #2 'Consolidations' + dst = append(dst, zeroBytes[:12]...) + { // Dynamic Field #0 'Deposits' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.Deposits + vlen := len(t) + if vlen > int(expr15) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr15)), "Block.Body.ExecutionRequests.Deposits") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(electra1.DepositRequest) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "Block.Body.ExecutionRequests.Deposits[%d]", idx1) + } + } + } + { // Dynamic Field #1 'Withdrawals' + binary.LittleEndian.PutUint32(dst[dstlen+4:], uint32(len(dst)-dstlen)) + t := t.Withdrawals + vlen := len(t) + if vlen > int(expr16) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr16)), "Block.Body.ExecutionRequests.Withdrawals") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(electra1.WithdrawalRequest) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "Block.Body.ExecutionRequests.Withdrawals[%d]", idx1) + } + } + } + { // Dynamic Field #2 'Consolidations' + binary.LittleEndian.PutUint32(dst[dstlen+8:], uint32(len(dst)-dstlen)) + t := t.Consolidations + vlen := len(t) + if vlen > int(expr17) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr17)), "Block.Body.ExecutionRequests.Consolidations") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(electra1.ConsolidationRequest) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "Block.Body.ExecutionRequests.Consolidations[%d]", idx1) + } + } + } + } + } + } + { // Dynamic Field #1 'KZGProofs' + binary.LittleEndian.PutUint32(dst[dstlen+4:], uint32(len(dst)-dstlen)) + t := t.KZGProofs + vlen := len(t) + if vlen > 33554432 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 33554432), "KZGProofs") + } + dst = sszutils.MarshalFixedBytesSlice(dst, t[:vlen]) + } + { // Dynamic Field #2 'Blobs' + binary.LittleEndian.PutUint32(dst[dstlen+8:], uint32(len(dst)-dstlen)) + t := t.Blobs + vlen := len(t) + if vlen > 4096 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 4096), "Blobs") + } + dst = sszutils.MarshalFixedBytesSlice(dst, t[:vlen]) + } + return dst, nil +} + +func (t *BlockContents) UnmarshalSSZDynView(view any) func(ds sszutils.DynamicSpecs, buf []byte) error { + switch view.(type) { + case *deneb.BlockContents: + return t.unmarshalSSZView_BlockContents + case *electra.BlockContents: + return t.unmarshalSSZView_BlockContents_0 + case *fulu.BlockContents: + return t.unmarshalSSZView_BlockContents_1 + } + return nil +} +func (t *BlockContents) unmarshalSSZView_BlockContents(ds sszutils.DynamicSpecs, buf []byte) (err error) { + expr0, err := sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE/8", 64) + if err != nil { + return err + } + expr1, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_PROPOSER_SLASHINGS", 16) + if err != nil { + return err + } + expr2, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_ATTESTER_SLASHINGS", 2) + if err != nil { + return err + } + expr3, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_ATTESTATIONS", 128) + if err != nil { + return err + } + expr4, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_VALIDATORS_PER_COMMITTEE", 2048) + if err != nil { + return err + } + expr5, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_DEPOSITS", 16) + if err != nil { + return err + } + expr6, err := sszutils.ResolveSpecValueWithDefault(ds, "DEPOSIT_CONTRACT_TREE_DEPTH+1", 33) + if err != nil { + return err + } + expr7, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_VOLUNTARY_EXITS", 16) + if err != nil { + return err + } + expr8, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_EXTRA_DATA_BYTES", 32) + if err != nil { + return err + } + expr9, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_TRANSACTIONS_PER_PAYLOAD", 1048576) + if err != nil { + return err + } + expr10, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BYTES_PER_TRANSACTION", 1073741824) + if err != nil { + return err + } + expr11, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_WITHDRAWALS_PER_PAYLOAD", 16) + if err != nil { + return err + } + expr12, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BLS_TO_EXECUTION_CHANGES", 16) + if err != nil { + return err + } + expr13, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BLOB_COMMITMENTS_PER_BLOCK", 4096) + if err != nil { + return err + } + size2 := 1 * int(expr0) + size1 := size2 + 96 // size expression for '*SyncAggregate' + size4 := 32 * int(expr6) + size3 := size4 + 184 // size expression for '*Deposit' + buflen := len(buf) + if buflen < 12 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 12) + } + // Field #0 'Block' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 12 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset0, 12), "Block:o") + } + // Field #1 'KZGProofs' (offset) + offset1 := int(binary.LittleEndian.Uint32(buf[4:8])) + if offset1 < offset0 || offset1 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset1, offset0, buflen), "KZGProofs:o") + } + // Field #2 'Blobs' (offset) + offset2 := int(binary.LittleEndian.Uint32(buf[8:12])) + if offset2 < offset1 || offset2 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset2, offset1, buflen), "Blobs:o") + } + { // Field #0 'Block' (dynamic) + buf := buf[offset0:offset1] + if t.Block == nil { + t.Block = new(all.BeaconBlock) + } + buflen := len(buf) + if buflen < 84 { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, 84), "Block") + } + { // Field #0 'Slot' (static) + buf := buf[0:8] + t.Block.Slot = phase0.Slot(binary.LittleEndian.Uint64(buf)) + } + { // Field #1 'ProposerIndex' (static) + buf := buf[8:16] + t.Block.ProposerIndex = phase0.ValidatorIndex(binary.LittleEndian.Uint64(buf)) + } + { // Field #2 'ParentRoot' (static) + buf := buf[16:48] + copy(t.Block.ParentRoot[:], buf) + } + { // Field #3 'StateRoot' (static) + buf := buf[48:80] + copy(t.Block.StateRoot[:], buf) + } + // Field #4 'Body' (offset) + offset4 := int(binary.LittleEndian.Uint32(buf[80:84])) + if offset4 != 84 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset4, 84), "Block.Body:o") + } + { // Field #4 'Body' (dynamic) + buf := buf[offset4:] + if t.Block.Body == nil { + t.Block.Body = new(all.BeaconBlockBody) + } + exproffset := 0 + totalSize := size1 + 232 + buflen := len(buf) + if buflen < totalSize { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, totalSize), "Block.Body") + } + { // Field #0 'RANDAOReveal' (static) + buf := buf[0:96] + copy(t.Block.Body.RANDAOReveal[:], buf) + } + { // Field #1 'ETH1Data' (static) + buf := buf[96:168] + if t.Block.Body.ETH1Data == nil { + t.Block.Body.ETH1Data = new(phase0.ETH1Data) + } + if err = t.Block.Body.ETH1Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "Block.Body.ETH1Data") + } + } + { // Field #2 'Graffiti' (static) + buf := buf[168:200] + copy(t.Block.Body.Graffiti[:], buf) + } + // Field #3 'ProposerSlashings' (offset) + offset3 := int(binary.LittleEndian.Uint32(buf[200:204])) + if offset3 != totalSize { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset3, totalSize), "Block.Body.ProposerSlashings:o") + } + // Field #4 'AttesterSlashings' (offset) + offset4 := int(binary.LittleEndian.Uint32(buf[204:208])) + if offset4 < offset3 || offset4 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset4, offset3, buflen), "Block.Body.AttesterSlashings:o") + } + // Field #5 'Attestations' (offset) + offset5 := int(binary.LittleEndian.Uint32(buf[208:212])) + if offset5 < offset4 || offset5 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset5, offset4, buflen), "Block.Body.Attestations:o") + } + // Field #6 'Deposits' (offset) + offset6 := int(binary.LittleEndian.Uint32(buf[212:216])) + if offset6 < offset5 || offset6 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset6, offset5, buflen), "Block.Body.Deposits:o") + } + // Field #7 'VoluntaryExits' (offset) + offset7 := int(binary.LittleEndian.Uint32(buf[216:220])) + if offset7 < offset6 || offset7 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset7, offset6, buflen), "Block.Body.VoluntaryExits:o") + } + { // Field #8 'SyncAggregate' (static) + buf := buf[220 : size1+220] + exproffset += int(size1) + val1 := t.Block.Body.SyncAggregate + if val1 == nil { + val1 = new(altair.SyncAggregate) + } + exproffset := 0 + totalSize := size2 + 96 + buflen := len(buf) + if buflen < totalSize { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, totalSize), "Block.Body.SyncAggregate") + } + if buflen > totalSize { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(buflen-totalSize), "Block.Body.SyncAggregate") + } + { // Field #0 'SyncCommitteeBits' (static) + buf := buf[0 : size2+0] + exproffset += int(size2) + val1.SyncCommitteeBits = sszutils.ExpandSlice(val1.SyncCommitteeBits, int(expr0)) + copy(val1.SyncCommitteeBits[:], buf) + } + { // Field #1 'SyncCommitteeSignature' (static) + buf := buf[exproffset+0 : exproffset+96] + copy(val1.SyncCommitteeSignature[:], buf) + } + t.Block.Body.SyncAggregate = val1 + } + // Field #9 'ExecutionPayload' (offset) + offset9 := int(binary.LittleEndian.Uint32(buf[exproffset+220 : exproffset+224])) + if offset9 < offset7 || offset9 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset9, offset7, buflen), "Block.Body.ExecutionPayload:o") + } + // Field #10 'BLSToExecutionChanges' (offset) + offset10 := int(binary.LittleEndian.Uint32(buf[exproffset+224 : exproffset+228])) + if offset10 < offset9 || offset10 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset10, offset9, buflen), "Block.Body.BLSToExecutionChanges:o") + } + // Field #11 'BlobKZGCommitments' (offset) + offset11 := int(binary.LittleEndian.Uint32(buf[exproffset+228 : exproffset+232])) + if offset11 < offset10 || offset11 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset11, offset10, buflen), "Block.Body.BlobKZGCommitments:o") + } + { // Field #3 'ProposerSlashings' (dynamic) + buf := buf[offset3:offset4] + val2 := t.Block.Body.ProposerSlashings + itemCount := len(buf) / 416 + if len(buf)%416 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 416), "Block.Body.ProposerSlashings") + } + if itemCount > int(expr1) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr1)), "Block.Body.ProposerSlashings") + } + val2 = sszutils.ExpandSlice(val2, itemCount) + for idx1 := range itemCount { + if val2[idx1] == nil { + val2[idx1] = new(phase0.ProposerSlashing) + } + buf := buf[416*idx1 : 416*(idx1+1)] + if err = val2[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Block.Body.ProposerSlashings[%d]", idx1) + } + } + t.Block.Body.ProposerSlashings = val2 + } + { // Field #4 'AttesterSlashings' (dynamic) + buf := buf[offset4:offset5] + val3 := t.Block.Body.AttesterSlashings + startOffset := int(0) + if len(buf) != 0 { + if len(buf) < 4 { + return sszutils.ErrorWithPath(sszutils.ErrListOffsetsEOFFn(len(buf), 4), "Block.Body.AttesterSlashings") + } + startOffset = int(binary.LittleEndian.Uint32(buf[0:4])) + } + itemCount := startOffset / 4 + if startOffset%4 != 0 || len(buf) < startOffset || (len(buf) != 0 && startOffset == 0) { + return sszutils.ErrorWithPath(sszutils.ErrInvalidListStartOffsetFn(startOffset, len(buf)), "Block.Body.AttesterSlashings") + } + if itemCount > int(expr2) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr2)), "Block.Body.AttesterSlashings") + } + val3 = sszutils.ExpandSlice(val3, 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)), "Block.Body.AttesterSlashings[%d]", idx1) + } + buf := buf[startOffset:endOffset] + startOffset = endOffset + val4 := val3[idx1] + if val4 == nil { + val4 = new(all.AttesterSlashing) + } + buflen := len(buf) + if buflen < 8 { + return sszutils.ErrorWithPathf(sszutils.ErrFixedFieldsEOFFn(buflen, 8), "Block.Body.AttesterSlashings[%d]", idx1) + } + // Field #0 'Attestation1' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 8 { + return sszutils.ErrorWithPathf(sszutils.ErrFirstOffsetMismatchFn(offset0, 8), "Block.Body.AttesterSlashings[%d].Attestation1:o", idx1) + } + // Field #1 'Attestation2' (offset) + offset1 := int(binary.LittleEndian.Uint32(buf[4:8])) + if offset1 < offset0 || offset1 > buflen { + return sszutils.ErrorWithPathf(sszutils.ErrOffsetOutOfRangeFn(offset1, offset0, buflen), "Block.Body.AttesterSlashings[%d].Attestation2:o", idx1) + } + { // Field #0 'Attestation1' (dynamic) + buf := buf[offset0:offset1] + if val4.Attestation1 == nil { + val4.Attestation1 = new(all.IndexedAttestation) + } + buflen := len(buf) + if buflen < 228 { + return sszutils.ErrorWithPathf(sszutils.ErrFixedFieldsEOFFn(buflen, 228), "Block.Body.AttesterSlashings[%d].Attestation1", idx1) + } + // Field #0 'AttestingIndices' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 228 { + return sszutils.ErrorWithPathf(sszutils.ErrFirstOffsetMismatchFn(offset0, 228), "Block.Body.AttesterSlashings[%d].Attestation1.AttestingIndices:o", idx1) + } + { // Field #1 'Data' (static) + buf := buf[4:132] + if val4.Attestation1.Data == nil { + val4.Attestation1.Data = new(phase0.AttestationData) + } + if err = val4.Attestation1.Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Block.Body.AttesterSlashings[%d].Attestation1.Data", idx1) + } + } + { // Field #2 'Signature' (static) + buf := buf[132:228] + copy(val4.Attestation1.Signature[:], buf) + } + { // Field #0 'AttestingIndices' (dynamic) + buf := buf[offset0:] + val5 := val4.Attestation1.AttestingIndices + itemCount := len(buf) / 8 + if len(buf)%8 != 0 { + return sszutils.ErrorWithPathf(sszutils.ErrListNotAlignedFn(len(buf), 8), "Block.Body.AttesterSlashings[%d].Attestation1.AttestingIndices", idx1) + } + if itemCount > 2048 { + return sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(itemCount, 2048), "Block.Body.AttesterSlashings[%d].Attestation1.AttestingIndices", idx1) + } + val5 = sszutils.ExpandSlice(val5, itemCount) + sszutils.UnmarshalUint64Slice(val5, buf) + val4.Attestation1.AttestingIndices = val5 + } + } + { // Field #1 'Attestation2' (dynamic) + buf := buf[offset1:] + if val4.Attestation2 == nil { + val4.Attestation2 = new(all.IndexedAttestation) + } + buflen := len(buf) + if buflen < 228 { + return sszutils.ErrorWithPathf(sszutils.ErrFixedFieldsEOFFn(buflen, 228), "Block.Body.AttesterSlashings[%d].Attestation2", idx1) + } + // Field #0 'AttestingIndices' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 228 { + return sszutils.ErrorWithPathf(sszutils.ErrFirstOffsetMismatchFn(offset0, 228), "Block.Body.AttesterSlashings[%d].Attestation2.AttestingIndices:o", idx1) + } + { // Field #1 'Data' (static) + buf := buf[4:132] + if val4.Attestation2.Data == nil { + val4.Attestation2.Data = new(phase0.AttestationData) + } + if err = val4.Attestation2.Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Block.Body.AttesterSlashings[%d].Attestation2.Data", idx1) + } + } + { // Field #2 'Signature' (static) + buf := buf[132:228] + copy(val4.Attestation2.Signature[:], buf) + } + { // Field #0 'AttestingIndices' (dynamic) + buf := buf[offset0:] + val6 := val4.Attestation2.AttestingIndices + itemCount := len(buf) / 8 + if len(buf)%8 != 0 { + return sszutils.ErrorWithPathf(sszutils.ErrListNotAlignedFn(len(buf), 8), "Block.Body.AttesterSlashings[%d].Attestation2.AttestingIndices", idx1) + } + if itemCount > 2048 { + return sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(itemCount, 2048), "Block.Body.AttesterSlashings[%d].Attestation2.AttestingIndices", idx1) + } + val6 = sszutils.ExpandSlice(val6, itemCount) + sszutils.UnmarshalUint64Slice(val6, buf) + val4.Attestation2.AttestingIndices = val6 + } + } + val3[idx1] = val4 + } + t.Block.Body.AttesterSlashings = val3 + } + { // Field #5 'Attestations' (dynamic) + buf := buf[offset5:offset6] + val7 := t.Block.Body.Attestations + startOffset := int(0) + if len(buf) != 0 { + if len(buf) < 4 { + return sszutils.ErrorWithPath(sszutils.ErrListOffsetsEOFFn(len(buf), 4), "Block.Body.Attestations") + } + startOffset = int(binary.LittleEndian.Uint32(buf[0:4])) + } + itemCount := startOffset / 4 + if startOffset%4 != 0 || len(buf) < startOffset || (len(buf) != 0 && startOffset == 0) { + return sszutils.ErrorWithPath(sszutils.ErrInvalidListStartOffsetFn(startOffset, len(buf)), "Block.Body.Attestations") + } + if itemCount > int(expr3) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr3)), "Block.Body.Attestations") + } + val7 = sszutils.ExpandSlice(val7, 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)), "Block.Body.Attestations[%d]", idx1) + } + buf := buf[startOffset:endOffset] + startOffset = endOffset + val8 := val7[idx1] + if val8 == nil { + val8 = new(all.Attestation) + } + buflen := len(buf) + if buflen < 228 { + return sszutils.ErrorWithPathf(sszutils.ErrFixedFieldsEOFFn(buflen, 228), "Block.Body.Attestations[%d]", idx1) + } + // Field #0 'AggregationBits' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 228 { + return sszutils.ErrorWithPathf(sszutils.ErrFirstOffsetMismatchFn(offset0, 228), "Block.Body.Attestations[%d].AggregationBits:o", idx1) + } + { // Field #1 'Data' (static) + buf := buf[4:132] + if val8.Data == nil { + val8.Data = new(phase0.AttestationData) + } + if err = val8.Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Block.Body.Attestations[%d].Data", idx1) + } + } + { // Field #2 'Signature' (static) + buf := buf[132:228] + copy(val8.Signature[:], buf) + } + { // Field #0 'AggregationBits' (dynamic) + buf := buf[offset0:] + val9 := val8.AggregationBits + blen := len(buf) + if blen == 0 || buf[blen-1] == 0x00 { + return sszutils.ErrorWithPathf(sszutils.ErrBitlistNotTerminatedFn(), "Block.Body.Attestations[%d].AggregationBits", idx1) + } + bitCount := 8*(blen-1) + int(bits.Len8(buf[blen-1])) - 1 + if bitCount > int(expr4) { + return sszutils.ErrorWithPathf(sszutils.ErrBitlistLengthFn(bitCount, int(expr4)), "Block.Body.Attestations[%d].AggregationBits", idx1) + } + val9 = sszutils.ExpandSlice(val9, blen) + copy(val9[:], buf) + val8.AggregationBits = val9 + } + val7[idx1] = val8 + } + t.Block.Body.Attestations = val7 + } + { // Field #6 'Deposits' (dynamic) + buf := buf[offset6:offset7] + val10 := t.Block.Body.Deposits + itemCount := len(buf) / size3 + if len(buf)%size3 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), size3), "Block.Body.Deposits") + } + if itemCount > int(expr5) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr5)), "Block.Body.Deposits") + } + val10 = sszutils.ExpandSlice(val10, itemCount) + for idx1 := range itemCount { + val11 := val10[idx1] + if val11 == nil { + val11 = new(phase0.Deposit) + } + buf := buf[size3*idx1 : size3*(idx1+1)] + exproffset := 0 + totalSize := size4 + 184 + buflen := len(buf) + if buflen < totalSize { + return sszutils.ErrorWithPathf(sszutils.ErrFixedFieldsEOFFn(buflen, totalSize), "Block.Body.Deposits[%d]", idx1) + } + if buflen > totalSize { + return sszutils.ErrorWithPathf(sszutils.ErrTrailingDataFn(buflen-totalSize), "Block.Body.Deposits[%d]", idx1) + } + { // Field #0 'Proof' (static) + buf := buf[0 : size4+0] + exproffset += int(size4) + val12 := val11.Proof + val12 = sszutils.ExpandSlice(val12, int(expr6)) + for idx2 := range int(expr6) { + buf := buf[32*idx2 : 32*(idx2+1)] + val12[idx2] = sszutils.ExpandSlice(val12[idx2], 32) + copy(val12[idx2][:], buf) + } + val11.Proof = val12 + } + { // Field #1 'Data' (static) + buf := buf[exproffset+0 : exproffset+184] + if val11.Data == nil { + val11.Data = new(phase0.DepositData) + } + if err = val11.Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Block.Body.Deposits[%d].Data", idx1) + } + } + val10[idx1] = val11 + } + t.Block.Body.Deposits = val10 + } + { // Field #7 'VoluntaryExits' (dynamic) + buf := buf[offset7:offset9] + val13 := t.Block.Body.VoluntaryExits + itemCount := len(buf) / 112 + if len(buf)%112 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 112), "Block.Body.VoluntaryExits") + } + if itemCount > int(expr7) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr7)), "Block.Body.VoluntaryExits") + } + val13 = sszutils.ExpandSlice(val13, itemCount) + for idx1 := range itemCount { + if val13[idx1] == nil { + val13[idx1] = new(phase0.SignedVoluntaryExit) + } + buf := buf[112*idx1 : 112*(idx1+1)] + if err = val13[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Block.Body.VoluntaryExits[%d]", idx1) + } + } + t.Block.Body.VoluntaryExits = val13 + } + { // Field #9 'ExecutionPayload' (dynamic) + buf := buf[offset9:offset10] + if t.Block.Body.ExecutionPayload == nil { + t.Block.Body.ExecutionPayload = new(all.ExecutionPayload) + } + buflen := len(buf) + if buflen < 528 { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, 528), "Block.Body.ExecutionPayload") + } + { // Field #0 'ParentHash' (static) + buf := buf[0:32] + copy(t.Block.Body.ExecutionPayload.ParentHash[:], buf) + } + { // Field #1 'FeeRecipient' (static) + buf := buf[32:52] + copy(t.Block.Body.ExecutionPayload.FeeRecipient[:], buf) + } + { // Field #2 'StateRoot' (static) + buf := buf[52:84] + copy(t.Block.Body.ExecutionPayload.StateRoot[:], buf) + } + { // Field #3 'ReceiptsRoot' (static) + buf := buf[84:116] + copy(t.Block.Body.ExecutionPayload.ReceiptsRoot[:], buf) + } + { // Field #4 'LogsBloom' (static) + buf := buf[116:372] + copy(t.Block.Body.ExecutionPayload.LogsBloom[:], buf) + } + { // Field #5 'PrevRandao' (static) + buf := buf[372:404] + copy(t.Block.Body.ExecutionPayload.PrevRandao[:], buf) + } + { // Field #6 'BlockNumber' (static) + buf := buf[404:412] + t.Block.Body.ExecutionPayload.BlockNumber = binary.LittleEndian.Uint64(buf) + } + { // Field #7 'GasLimit' (static) + buf := buf[412:420] + t.Block.Body.ExecutionPayload.GasLimit = binary.LittleEndian.Uint64(buf) + } + { // Field #8 'GasUsed' (static) + buf := buf[420:428] + t.Block.Body.ExecutionPayload.GasUsed = binary.LittleEndian.Uint64(buf) + } + { // Field #9 'Timestamp' (static) + buf := buf[428:436] + t.Block.Body.ExecutionPayload.Timestamp = binary.LittleEndian.Uint64(buf) + } + // Field #10 'ExtraData' (offset) + offset10 := int(binary.LittleEndian.Uint32(buf[436:440])) + if offset10 != 528 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset10, 528), "Block.Body.ExecutionPayload.ExtraData:o") + } + { // Field #11 'BaseFeePerGas' (static) + buf := buf[440:472] + val14 := t.Block.Body.ExecutionPayload.BaseFeePerGas + if val14 == nil { + val14 = new(uint256.Int) + } + sszutils.UnmarshalUint64Slice((*val14)[:4], buf) + t.Block.Body.ExecutionPayload.BaseFeePerGas = val14 + } + { // Field #12 'BlockHash' (static) + buf := buf[472:504] + copy(t.Block.Body.ExecutionPayload.BlockHash[:], buf) + } + // Field #13 'Transactions' (offset) + offset13 := int(binary.LittleEndian.Uint32(buf[504:508])) + if offset13 < offset10 || offset13 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset13, offset10, buflen), "Block.Body.ExecutionPayload.Transactions:o") + } + // Field #14 'Withdrawals' (offset) + offset14 := int(binary.LittleEndian.Uint32(buf[508:512])) + if offset14 < offset13 || offset14 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset14, offset13, buflen), "Block.Body.ExecutionPayload.Withdrawals:o") + } + { // Field #15 'BlobGasUsed' (static) + buf := buf[512:520] + t.Block.Body.ExecutionPayload.BlobGasUsed = binary.LittleEndian.Uint64(buf) + } + { // Field #16 'ExcessBlobGas' (static) + buf := buf[520:528] + t.Block.Body.ExecutionPayload.ExcessBlobGas = binary.LittleEndian.Uint64(buf) + } + { // Field #10 'ExtraData' (dynamic) + buf := buf[offset10:offset13] + if len(buf) > int(expr8) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(len(buf), int(expr8)), "Block.Body.ExecutionPayload.ExtraData") + } + t.Block.Body.ExecutionPayload.ExtraData = sszutils.ExpandSlice(t.Block.Body.ExecutionPayload.ExtraData, len(buf)) + copy(t.Block.Body.ExecutionPayload.ExtraData[:], buf) + } + { // Field #13 'Transactions' (dynamic) + buf := buf[offset13:offset14] + val15 := t.Block.Body.ExecutionPayload.Transactions + startOffset := int(0) + if len(buf) != 0 { + if len(buf) < 4 { + return sszutils.ErrorWithPath(sszutils.ErrListOffsetsEOFFn(len(buf), 4), "Block.Body.ExecutionPayload.Transactions") + } + startOffset = int(binary.LittleEndian.Uint32(buf[0:4])) + } + itemCount := startOffset / 4 + if startOffset%4 != 0 || len(buf) < startOffset || (len(buf) != 0 && startOffset == 0) { + return sszutils.ErrorWithPath(sszutils.ErrInvalidListStartOffsetFn(startOffset, len(buf)), "Block.Body.ExecutionPayload.Transactions") + } + if itemCount > int(expr9) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr9)), "Block.Body.ExecutionPayload.Transactions") + } + val15 = sszutils.ExpandSlice(val15, 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)), "Block.Body.ExecutionPayload.Transactions[%d]", idx1) + } + buf := buf[startOffset:endOffset] + startOffset = endOffset + val16 := val15[idx1] + if len(buf) > int(expr10) { + return sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(len(buf), int(expr10)), "Block.Body.ExecutionPayload.Transactions[%d]", idx1) + } + val16 = sszutils.ExpandSlice(val16, len(buf)) + copy(val16[:], buf) + val15[idx1] = val16 + } + t.Block.Body.ExecutionPayload.Transactions = val15 + } + { // Field #14 'Withdrawals' (dynamic) + buf := buf[offset14:] + val17 := t.Block.Body.ExecutionPayload.Withdrawals + itemCount := len(buf) / 44 + if len(buf)%44 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 44), "Block.Body.ExecutionPayload.Withdrawals") + } + if itemCount > int(expr11) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr11)), "Block.Body.ExecutionPayload.Withdrawals") + } + val17 = sszutils.ExpandSlice(val17, itemCount) + for idx1 := range itemCount { + if val17[idx1] == nil { + val17[idx1] = new(capella.Withdrawal) + } + buf := buf[44*idx1 : 44*(idx1+1)] + if err = val17[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Block.Body.ExecutionPayload.Withdrawals[%d]", idx1) + } + } + t.Block.Body.ExecutionPayload.Withdrawals = val17 + } + } + { // Field #10 'BLSToExecutionChanges' (dynamic) + buf := buf[offset10:offset11] + val18 := t.Block.Body.BLSToExecutionChanges + itemCount := len(buf) / 172 + if len(buf)%172 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 172), "Block.Body.BLSToExecutionChanges") + } + if itemCount > int(expr12) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr12)), "Block.Body.BLSToExecutionChanges") + } + val18 = sszutils.ExpandSlice(val18, itemCount) + for idx1 := range itemCount { + if val18[idx1] == nil { + val18[idx1] = new(capella.SignedBLSToExecutionChange) + } + buf := buf[172*idx1 : 172*(idx1+1)] + if err = val18[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Block.Body.BLSToExecutionChanges[%d]", idx1) + } + } + t.Block.Body.BLSToExecutionChanges = val18 + } + { // Field #11 'BlobKZGCommitments' (dynamic) + buf := buf[offset11:] + val19 := t.Block.Body.BlobKZGCommitments + itemCount := len(buf) / 48 + if len(buf)%48 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 48), "Block.Body.BlobKZGCommitments") + } + if itemCount > int(expr13) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr13)), "Block.Body.BlobKZGCommitments") + } + val19 = sszutils.ExpandSlice(val19, itemCount) + sszutils.UnmarshalFixedBytesSlice(val19[:itemCount], buf) + t.Block.Body.BlobKZGCommitments = val19 + } + } + } + { // Field #1 'KZGProofs' (dynamic) + buf := buf[offset1:offset2] + val20 := t.KZGProofs + itemCount := len(buf) / 48 + if len(buf)%48 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 48), "KZGProofs") + } + if itemCount > int(expr13) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr13)), "KZGProofs") + } + val20 = sszutils.ExpandSlice(val20, itemCount) + sszutils.UnmarshalFixedBytesSlice(val20[:itemCount], buf) + t.KZGProofs = val20 + } + { // Field #2 'Blobs' (dynamic) + buf := buf[offset2:] + val21 := t.Blobs + itemCount := len(buf) / 131072 + if len(buf)%131072 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 131072), "Blobs") + } + if itemCount > int(expr13) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr13)), "Blobs") + } + val21 = sszutils.ExpandSlice(val21, itemCount) + sszutils.UnmarshalFixedBytesSlice(val21[:itemCount], buf) + t.Blobs = val21 + } + return nil +} + +func (t *BlockContents) unmarshalSSZView_BlockContents_0(ds sszutils.DynamicSpecs, buf []byte) (err error) { + expr0, err := sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE/8", 64) + if err != nil { + return err + } + expr1, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_PROPOSER_SLASHINGS", 16) + if err != nil { + return err + } + expr2, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_ATTESTER_SLASHINGS_ELECTRA", 1) + if err != nil { + return err + } + expr3, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_VALIDATORS_PER_COMMITTEE*MAX_COMMITTEES_PER_SLOT", 131072) + if err != nil { + return err + } + expr4, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_ATTESTATIONS_ELECTRA", 8) + if err != nil { + return err + } + expr5, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_COMMITTEES_PER_SLOT/8", 8) + if err != nil { + return err + } + expr6, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_DEPOSITS", 16) + if err != nil { + return err + } + expr7, err := sszutils.ResolveSpecValueWithDefault(ds, "DEPOSIT_CONTRACT_TREE_DEPTH+1", 33) + if err != nil { + return err + } + expr8, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_VOLUNTARY_EXITS", 16) + if err != nil { + return err + } + expr9, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_EXTRA_DATA_BYTES", 32) + if err != nil { + return err + } + expr10, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_TRANSACTIONS_PER_PAYLOAD", 1048576) + if err != nil { + return err + } + expr11, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BYTES_PER_TRANSACTION", 1073741824) + if err != nil { + return err + } + expr12, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_WITHDRAWALS_PER_PAYLOAD", 16) + if err != nil { + return err + } + expr13, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BLS_TO_EXECUTION_CHANGES", 16) + if err != nil { + return err + } + expr14, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BLOB_COMMITMENTS_PER_BLOCK", 4096) + if err != nil { + return err + } + expr15, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_DEPOSIT_REQUESTS_PER_PAYLOAD", 8192) + if err != nil { + return err + } + expr16, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_WITHDRAWAL_REQUESTS_PER_PAYLOAD", 16) + if err != nil { + return err + } + expr17, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD", 2) + if err != nil { + return err + } + size2 := 1 * int(expr0) + size1 := size2 + 96 // size expression for '*SyncAggregate' + size3 := 1 * int(expr5) + size5 := 32 * int(expr7) + size4 := size5 + 184 // size expression for '*Deposit' + buflen := len(buf) + if buflen < 12 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 12) + } + // Field #0 'Block' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 12 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset0, 12), "Block:o") + } + // Field #1 'KZGProofs' (offset) + offset1 := int(binary.LittleEndian.Uint32(buf[4:8])) + if offset1 < offset0 || offset1 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset1, offset0, buflen), "KZGProofs:o") + } + // Field #2 'Blobs' (offset) + offset2 := int(binary.LittleEndian.Uint32(buf[8:12])) + if offset2 < offset1 || offset2 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset2, offset1, buflen), "Blobs:o") + } + { // Field #0 'Block' (dynamic) + buf := buf[offset0:offset1] + if t.Block == nil { + t.Block = new(all.BeaconBlock) + } + buflen := len(buf) + if buflen < 84 { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, 84), "Block") + } + { // Field #0 'Slot' (static) + buf := buf[0:8] + t.Block.Slot = phase0.Slot(binary.LittleEndian.Uint64(buf)) + } + { // Field #1 'ProposerIndex' (static) + buf := buf[8:16] + t.Block.ProposerIndex = phase0.ValidatorIndex(binary.LittleEndian.Uint64(buf)) + } + { // Field #2 'ParentRoot' (static) + buf := buf[16:48] + copy(t.Block.ParentRoot[:], buf) + } + { // Field #3 'StateRoot' (static) + buf := buf[48:80] + copy(t.Block.StateRoot[:], buf) + } + // Field #4 'Body' (offset) + offset4 := int(binary.LittleEndian.Uint32(buf[80:84])) + if offset4 != 84 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset4, 84), "Block.Body:o") + } + { // Field #4 'Body' (dynamic) + buf := buf[offset4:] + if t.Block.Body == nil { + t.Block.Body = new(all.BeaconBlockBody) + } + exproffset := 0 + totalSize := size1 + 236 + buflen := len(buf) + if buflen < totalSize { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, totalSize), "Block.Body") + } + { // Field #0 'RANDAOReveal' (static) + buf := buf[0:96] + copy(t.Block.Body.RANDAOReveal[:], buf) + } + { // Field #1 'ETH1Data' (static) + buf := buf[96:168] + if t.Block.Body.ETH1Data == nil { + t.Block.Body.ETH1Data = new(phase0.ETH1Data) + } + if err = t.Block.Body.ETH1Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "Block.Body.ETH1Data") + } + } + { // Field #2 'Graffiti' (static) + buf := buf[168:200] + copy(t.Block.Body.Graffiti[:], buf) + } + // Field #3 'ProposerSlashings' (offset) + offset3 := int(binary.LittleEndian.Uint32(buf[200:204])) + if offset3 != totalSize { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset3, totalSize), "Block.Body.ProposerSlashings:o") + } + // Field #4 'AttesterSlashings' (offset) + offset4 := int(binary.LittleEndian.Uint32(buf[204:208])) + if offset4 < offset3 || offset4 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset4, offset3, buflen), "Block.Body.AttesterSlashings:o") + } + // Field #5 'Attestations' (offset) + offset5 := int(binary.LittleEndian.Uint32(buf[208:212])) + if offset5 < offset4 || offset5 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset5, offset4, buflen), "Block.Body.Attestations:o") + } + // Field #6 'Deposits' (offset) + offset6 := int(binary.LittleEndian.Uint32(buf[212:216])) + if offset6 < offset5 || offset6 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset6, offset5, buflen), "Block.Body.Deposits:o") + } + // Field #7 'VoluntaryExits' (offset) + offset7 := int(binary.LittleEndian.Uint32(buf[216:220])) + if offset7 < offset6 || offset7 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset7, offset6, buflen), "Block.Body.VoluntaryExits:o") + } + { // Field #8 'SyncAggregate' (static) + buf := buf[220 : size1+220] + exproffset += int(size1) + val1 := t.Block.Body.SyncAggregate + if val1 == nil { + val1 = new(altair.SyncAggregate) + } + exproffset := 0 + totalSize := size2 + 96 + buflen := len(buf) + if buflen < totalSize { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, totalSize), "Block.Body.SyncAggregate") + } + if buflen > totalSize { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(buflen-totalSize), "Block.Body.SyncAggregate") + } + { // Field #0 'SyncCommitteeBits' (static) + buf := buf[0 : size2+0] + exproffset += int(size2) + val1.SyncCommitteeBits = sszutils.ExpandSlice(val1.SyncCommitteeBits, int(expr0)) + copy(val1.SyncCommitteeBits[:], buf) + } + { // Field #1 'SyncCommitteeSignature' (static) + buf := buf[exproffset+0 : exproffset+96] + copy(val1.SyncCommitteeSignature[:], buf) + } + t.Block.Body.SyncAggregate = val1 + } + // Field #9 'ExecutionPayload' (offset) + offset9 := int(binary.LittleEndian.Uint32(buf[exproffset+220 : exproffset+224])) + if offset9 < offset7 || offset9 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset9, offset7, buflen), "Block.Body.ExecutionPayload:o") + } + // Field #10 'BLSToExecutionChanges' (offset) + offset10 := int(binary.LittleEndian.Uint32(buf[exproffset+224 : exproffset+228])) + if offset10 < offset9 || offset10 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset10, offset9, buflen), "Block.Body.BLSToExecutionChanges:o") + } + // Field #11 'BlobKZGCommitments' (offset) + offset11 := int(binary.LittleEndian.Uint32(buf[exproffset+228 : exproffset+232])) + if offset11 < offset10 || offset11 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset11, offset10, buflen), "Block.Body.BlobKZGCommitments:o") + } + // Field #12 'ExecutionRequests' (offset) + offset12 := int(binary.LittleEndian.Uint32(buf[exproffset+232 : exproffset+236])) + if offset12 < offset11 || offset12 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset12, offset11, buflen), "Block.Body.ExecutionRequests:o") + } + { // Field #3 'ProposerSlashings' (dynamic) + buf := buf[offset3:offset4] + val2 := t.Block.Body.ProposerSlashings + itemCount := len(buf) / 416 + if len(buf)%416 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 416), "Block.Body.ProposerSlashings") + } + if itemCount > int(expr1) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr1)), "Block.Body.ProposerSlashings") + } + val2 = sszutils.ExpandSlice(val2, itemCount) + for idx1 := range itemCount { + if val2[idx1] == nil { + val2[idx1] = new(phase0.ProposerSlashing) + } + buf := buf[416*idx1 : 416*(idx1+1)] + if err = val2[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Block.Body.ProposerSlashings[%d]", idx1) + } + } + t.Block.Body.ProposerSlashings = val2 + } + { // Field #4 'AttesterSlashings' (dynamic) + buf := buf[offset4:offset5] + val3 := t.Block.Body.AttesterSlashings + startOffset := int(0) + if len(buf) != 0 { + if len(buf) < 4 { + return sszutils.ErrorWithPath(sszutils.ErrListOffsetsEOFFn(len(buf), 4), "Block.Body.AttesterSlashings") + } + startOffset = int(binary.LittleEndian.Uint32(buf[0:4])) + } + itemCount := startOffset / 4 + if startOffset%4 != 0 || len(buf) < startOffset || (len(buf) != 0 && startOffset == 0) { + return sszutils.ErrorWithPath(sszutils.ErrInvalidListStartOffsetFn(startOffset, len(buf)), "Block.Body.AttesterSlashings") + } + if itemCount > int(expr2) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr2)), "Block.Body.AttesterSlashings") + } + val3 = sszutils.ExpandSlice(val3, 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)), "Block.Body.AttesterSlashings[%d]", idx1) + } + buf := buf[startOffset:endOffset] + startOffset = endOffset + val4 := val3[idx1] + if val4 == nil { + val4 = new(all.AttesterSlashing) + } + buflen := len(buf) + if buflen < 8 { + return sszutils.ErrorWithPathf(sszutils.ErrFixedFieldsEOFFn(buflen, 8), "Block.Body.AttesterSlashings[%d]", idx1) + } + // Field #0 'Attestation1' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 8 { + return sszutils.ErrorWithPathf(sszutils.ErrFirstOffsetMismatchFn(offset0, 8), "Block.Body.AttesterSlashings[%d].Attestation1:o", idx1) + } + // Field #1 'Attestation2' (offset) + offset1 := int(binary.LittleEndian.Uint32(buf[4:8])) + if offset1 < offset0 || offset1 > buflen { + return sszutils.ErrorWithPathf(sszutils.ErrOffsetOutOfRangeFn(offset1, offset0, buflen), "Block.Body.AttesterSlashings[%d].Attestation2:o", idx1) + } + { // Field #0 'Attestation1' (dynamic) + buf := buf[offset0:offset1] + if val4.Attestation1 == nil { + val4.Attestation1 = new(all.IndexedAttestation) + } + buflen := len(buf) + if buflen < 228 { + return sszutils.ErrorWithPathf(sszutils.ErrFixedFieldsEOFFn(buflen, 228), "Block.Body.AttesterSlashings[%d].Attestation1", idx1) + } + // Field #0 'AttestingIndices' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 228 { + return sszutils.ErrorWithPathf(sszutils.ErrFirstOffsetMismatchFn(offset0, 228), "Block.Body.AttesterSlashings[%d].Attestation1.AttestingIndices:o", idx1) + } + { // Field #1 'Data' (static) + buf := buf[4:132] + if val4.Attestation1.Data == nil { + val4.Attestation1.Data = new(phase0.AttestationData) + } + if err = val4.Attestation1.Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Block.Body.AttesterSlashings[%d].Attestation1.Data", idx1) + } + } + { // Field #2 'Signature' (static) + buf := buf[132:228] + copy(val4.Attestation1.Signature[:], buf) + } + { // Field #0 'AttestingIndices' (dynamic) + buf := buf[offset0:] + val5 := val4.Attestation1.AttestingIndices + itemCount := len(buf) / 8 + if len(buf)%8 != 0 { + return sszutils.ErrorWithPathf(sszutils.ErrListNotAlignedFn(len(buf), 8), "Block.Body.AttesterSlashings[%d].Attestation1.AttestingIndices", idx1) + } + if itemCount > int(expr3) { + return sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(itemCount, int(expr3)), "Block.Body.AttesterSlashings[%d].Attestation1.AttestingIndices", idx1) + } + val5 = sszutils.ExpandSlice(val5, itemCount) + sszutils.UnmarshalUint64Slice(val5, buf) + val4.Attestation1.AttestingIndices = val5 + } + } + { // Field #1 'Attestation2' (dynamic) + buf := buf[offset1:] + if val4.Attestation2 == nil { + val4.Attestation2 = new(all.IndexedAttestation) + } + buflen := len(buf) + if buflen < 228 { + return sszutils.ErrorWithPathf(sszutils.ErrFixedFieldsEOFFn(buflen, 228), "Block.Body.AttesterSlashings[%d].Attestation2", idx1) + } + // Field #0 'AttestingIndices' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 228 { + return sszutils.ErrorWithPathf(sszutils.ErrFirstOffsetMismatchFn(offset0, 228), "Block.Body.AttesterSlashings[%d].Attestation2.AttestingIndices:o", idx1) + } + { // Field #1 'Data' (static) + buf := buf[4:132] + if val4.Attestation2.Data == nil { + val4.Attestation2.Data = new(phase0.AttestationData) + } + if err = val4.Attestation2.Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Block.Body.AttesterSlashings[%d].Attestation2.Data", idx1) + } + } + { // Field #2 'Signature' (static) + buf := buf[132:228] + copy(val4.Attestation2.Signature[:], buf) + } + { // Field #0 'AttestingIndices' (dynamic) + buf := buf[offset0:] + val6 := val4.Attestation2.AttestingIndices + itemCount := len(buf) / 8 + if len(buf)%8 != 0 { + return sszutils.ErrorWithPathf(sszutils.ErrListNotAlignedFn(len(buf), 8), "Block.Body.AttesterSlashings[%d].Attestation2.AttestingIndices", idx1) + } + if itemCount > int(expr3) { + return sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(itemCount, int(expr3)), "Block.Body.AttesterSlashings[%d].Attestation2.AttestingIndices", idx1) + } + val6 = sszutils.ExpandSlice(val6, itemCount) + sszutils.UnmarshalUint64Slice(val6, buf) + val4.Attestation2.AttestingIndices = val6 + } + } + val3[idx1] = val4 + } + t.Block.Body.AttesterSlashings = val3 + } + { // Field #5 'Attestations' (dynamic) + buf := buf[offset5:offset6] + val7 := t.Block.Body.Attestations + startOffset := int(0) + if len(buf) != 0 { + if len(buf) < 4 { + return sszutils.ErrorWithPath(sszutils.ErrListOffsetsEOFFn(len(buf), 4), "Block.Body.Attestations") + } + startOffset = int(binary.LittleEndian.Uint32(buf[0:4])) + } + itemCount := startOffset / 4 + if startOffset%4 != 0 || len(buf) < startOffset || (len(buf) != 0 && startOffset == 0) { + return sszutils.ErrorWithPath(sszutils.ErrInvalidListStartOffsetFn(startOffset, len(buf)), "Block.Body.Attestations") + } + if itemCount > int(expr4) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr4)), "Block.Body.Attestations") + } + val7 = sszutils.ExpandSlice(val7, 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)), "Block.Body.Attestations[%d]", idx1) + } + buf := buf[startOffset:endOffset] + startOffset = endOffset + val8 := val7[idx1] + if val8 == nil { + val8 = new(all.Attestation) + } + exproffset := 0 + totalSize := size3 + 228 + buflen := len(buf) + if buflen < totalSize { + return sszutils.ErrorWithPathf(sszutils.ErrFixedFieldsEOFFn(buflen, totalSize), "Block.Body.Attestations[%d]", idx1) + } + // Field #0 'AggregationBits' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != totalSize { + return sszutils.ErrorWithPathf(sszutils.ErrFirstOffsetMismatchFn(offset0, totalSize), "Block.Body.Attestations[%d].AggregationBits:o", idx1) + } + { // Field #1 'Data' (static) + buf := buf[4:132] + if val8.Data == nil { + val8.Data = new(phase0.AttestationData) + } + if err = val8.Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Block.Body.Attestations[%d].Data", idx1) + } + } + { // Field #2 'Signature' (static) + buf := buf[132:228] + copy(val8.Signature[:], buf) + } + { // Field #3 'CommitteeBits' (static) + buf := buf[228 : size3+228] + exproffset += int(size3) + val8.CommitteeBits = sszutils.ExpandSlice(val8.CommitteeBits, int(expr5)) + copy(val8.CommitteeBits[:], buf) + } + { // Field #0 'AggregationBits' (dynamic) + buf := buf[offset0:] + val9 := val8.AggregationBits + blen := len(buf) + if blen == 0 || buf[blen-1] == 0x00 { + return sszutils.ErrorWithPathf(sszutils.ErrBitlistNotTerminatedFn(), "Block.Body.Attestations[%d].AggregationBits", idx1) + } + bitCount := 8*(blen-1) + int(bits.Len8(buf[blen-1])) - 1 + if bitCount > int(expr3) { + return sszutils.ErrorWithPathf(sszutils.ErrBitlistLengthFn(bitCount, int(expr3)), "Block.Body.Attestations[%d].AggregationBits", idx1) + } + val9 = sszutils.ExpandSlice(val9, blen) + copy(val9[:], buf) + val8.AggregationBits = val9 + } + val7[idx1] = val8 + } + t.Block.Body.Attestations = val7 + } + { // Field #6 'Deposits' (dynamic) + buf := buf[offset6:offset7] + val10 := t.Block.Body.Deposits + itemCount := len(buf) / size4 + if len(buf)%size4 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), size4), "Block.Body.Deposits") + } + if itemCount > int(expr6) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "Block.Body.Deposits") + } + val10 = sszutils.ExpandSlice(val10, itemCount) + for idx1 := range itemCount { + val11 := val10[idx1] + if val11 == nil { + val11 = new(phase0.Deposit) + } + buf := buf[size4*idx1 : size4*(idx1+1)] + exproffset := 0 + totalSize := size5 + 184 + buflen := len(buf) + if buflen < totalSize { + return sszutils.ErrorWithPathf(sszutils.ErrFixedFieldsEOFFn(buflen, totalSize), "Block.Body.Deposits[%d]", idx1) + } + if buflen > totalSize { + return sszutils.ErrorWithPathf(sszutils.ErrTrailingDataFn(buflen-totalSize), "Block.Body.Deposits[%d]", idx1) + } + { // Field #0 'Proof' (static) + buf := buf[0 : size5+0] + exproffset += int(size5) + val12 := val11.Proof + val12 = sszutils.ExpandSlice(val12, int(expr7)) + for idx2 := range int(expr7) { + buf := buf[32*idx2 : 32*(idx2+1)] + val12[idx2] = sszutils.ExpandSlice(val12[idx2], 32) + copy(val12[idx2][:], buf) + } + val11.Proof = val12 + } + { // Field #1 'Data' (static) + buf := buf[exproffset+0 : exproffset+184] + if val11.Data == nil { + val11.Data = new(phase0.DepositData) + } + if err = val11.Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Block.Body.Deposits[%d].Data", idx1) + } + } + val10[idx1] = val11 + } + t.Block.Body.Deposits = val10 + } + { // Field #7 'VoluntaryExits' (dynamic) + buf := buf[offset7:offset9] + val13 := t.Block.Body.VoluntaryExits + itemCount := len(buf) / 112 + if len(buf)%112 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 112), "Block.Body.VoluntaryExits") + } + if itemCount > int(expr8) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr8)), "Block.Body.VoluntaryExits") + } + val13 = sszutils.ExpandSlice(val13, itemCount) + for idx1 := range itemCount { + if val13[idx1] == nil { + val13[idx1] = new(phase0.SignedVoluntaryExit) + } + buf := buf[112*idx1 : 112*(idx1+1)] + if err = val13[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Block.Body.VoluntaryExits[%d]", idx1) + } + } + t.Block.Body.VoluntaryExits = val13 + } + { // Field #9 'ExecutionPayload' (dynamic) + buf := buf[offset9:offset10] + if t.Block.Body.ExecutionPayload == nil { + t.Block.Body.ExecutionPayload = new(all.ExecutionPayload) + } + buflen := len(buf) + if buflen < 528 { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, 528), "Block.Body.ExecutionPayload") + } + { // Field #0 'ParentHash' (static) + buf := buf[0:32] + copy(t.Block.Body.ExecutionPayload.ParentHash[:], buf) + } + { // Field #1 'FeeRecipient' (static) + buf := buf[32:52] + copy(t.Block.Body.ExecutionPayload.FeeRecipient[:], buf) + } + { // Field #2 'StateRoot' (static) + buf := buf[52:84] + copy(t.Block.Body.ExecutionPayload.StateRoot[:], buf) + } + { // Field #3 'ReceiptsRoot' (static) + buf := buf[84:116] + copy(t.Block.Body.ExecutionPayload.ReceiptsRoot[:], buf) + } + { // Field #4 'LogsBloom' (static) + buf := buf[116:372] + copy(t.Block.Body.ExecutionPayload.LogsBloom[:], buf) + } + { // Field #5 'PrevRandao' (static) + buf := buf[372:404] + copy(t.Block.Body.ExecutionPayload.PrevRandao[:], buf) + } + { // Field #6 'BlockNumber' (static) + buf := buf[404:412] + t.Block.Body.ExecutionPayload.BlockNumber = binary.LittleEndian.Uint64(buf) + } + { // Field #7 'GasLimit' (static) + buf := buf[412:420] + t.Block.Body.ExecutionPayload.GasLimit = binary.LittleEndian.Uint64(buf) + } + { // Field #8 'GasUsed' (static) + buf := buf[420:428] + t.Block.Body.ExecutionPayload.GasUsed = binary.LittleEndian.Uint64(buf) + } + { // Field #9 'Timestamp' (static) + buf := buf[428:436] + t.Block.Body.ExecutionPayload.Timestamp = binary.LittleEndian.Uint64(buf) + } + // Field #10 'ExtraData' (offset) + offset10 := int(binary.LittleEndian.Uint32(buf[436:440])) + if offset10 != 528 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset10, 528), "Block.Body.ExecutionPayload.ExtraData:o") + } + { // Field #11 'BaseFeePerGas' (static) + buf := buf[440:472] + val14 := t.Block.Body.ExecutionPayload.BaseFeePerGas + if val14 == nil { + val14 = new(uint256.Int) + } + sszutils.UnmarshalUint64Slice((*val14)[:4], buf) + t.Block.Body.ExecutionPayload.BaseFeePerGas = val14 + } + { // Field #12 'BlockHash' (static) + buf := buf[472:504] + copy(t.Block.Body.ExecutionPayload.BlockHash[:], buf) + } + // Field #13 'Transactions' (offset) + offset13 := int(binary.LittleEndian.Uint32(buf[504:508])) + if offset13 < offset10 || offset13 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset13, offset10, buflen), "Block.Body.ExecutionPayload.Transactions:o") + } + // Field #14 'Withdrawals' (offset) + offset14 := int(binary.LittleEndian.Uint32(buf[508:512])) + if offset14 < offset13 || offset14 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset14, offset13, buflen), "Block.Body.ExecutionPayload.Withdrawals:o") + } + { // Field #15 'BlobGasUsed' (static) + buf := buf[512:520] + t.Block.Body.ExecutionPayload.BlobGasUsed = binary.LittleEndian.Uint64(buf) + } + { // Field #16 'ExcessBlobGas' (static) + buf := buf[520:528] + t.Block.Body.ExecutionPayload.ExcessBlobGas = binary.LittleEndian.Uint64(buf) + } + { // Field #10 'ExtraData' (dynamic) + buf := buf[offset10:offset13] + if len(buf) > int(expr9) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(len(buf), int(expr9)), "Block.Body.ExecutionPayload.ExtraData") + } + t.Block.Body.ExecutionPayload.ExtraData = sszutils.ExpandSlice(t.Block.Body.ExecutionPayload.ExtraData, len(buf)) + copy(t.Block.Body.ExecutionPayload.ExtraData[:], buf) + } + { // Field #13 'Transactions' (dynamic) + buf := buf[offset13:offset14] + val15 := t.Block.Body.ExecutionPayload.Transactions + startOffset := int(0) + if len(buf) != 0 { + if len(buf) < 4 { + return sszutils.ErrorWithPath(sszutils.ErrListOffsetsEOFFn(len(buf), 4), "Block.Body.ExecutionPayload.Transactions") + } + startOffset = int(binary.LittleEndian.Uint32(buf[0:4])) + } + itemCount := startOffset / 4 + if startOffset%4 != 0 || len(buf) < startOffset || (len(buf) != 0 && startOffset == 0) { + return sszutils.ErrorWithPath(sszutils.ErrInvalidListStartOffsetFn(startOffset, len(buf)), "Block.Body.ExecutionPayload.Transactions") + } + if itemCount > int(expr10) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr10)), "Block.Body.ExecutionPayload.Transactions") + } + val15 = sszutils.ExpandSlice(val15, 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)), "Block.Body.ExecutionPayload.Transactions[%d]", idx1) + } + buf := buf[startOffset:endOffset] + startOffset = endOffset + val16 := val15[idx1] + if len(buf) > int(expr11) { + return sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(len(buf), int(expr11)), "Block.Body.ExecutionPayload.Transactions[%d]", idx1) + } + val16 = sszutils.ExpandSlice(val16, len(buf)) + copy(val16[:], buf) + val15[idx1] = val16 + } + t.Block.Body.ExecutionPayload.Transactions = val15 + } + { // Field #14 'Withdrawals' (dynamic) + buf := buf[offset14:] + val17 := t.Block.Body.ExecutionPayload.Withdrawals + itemCount := len(buf) / 44 + if len(buf)%44 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 44), "Block.Body.ExecutionPayload.Withdrawals") + } + if itemCount > int(expr12) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr12)), "Block.Body.ExecutionPayload.Withdrawals") + } + val17 = sszutils.ExpandSlice(val17, itemCount) + for idx1 := range itemCount { + if val17[idx1] == nil { + val17[idx1] = new(capella.Withdrawal) + } + buf := buf[44*idx1 : 44*(idx1+1)] + if err = val17[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Block.Body.ExecutionPayload.Withdrawals[%d]", idx1) + } + } + t.Block.Body.ExecutionPayload.Withdrawals = val17 + } + } + { // Field #10 'BLSToExecutionChanges' (dynamic) + buf := buf[offset10:offset11] + val18 := t.Block.Body.BLSToExecutionChanges + itemCount := len(buf) / 172 + if len(buf)%172 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 172), "Block.Body.BLSToExecutionChanges") + } + if itemCount > int(expr13) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr13)), "Block.Body.BLSToExecutionChanges") + } + val18 = sszutils.ExpandSlice(val18, itemCount) + for idx1 := range itemCount { + if val18[idx1] == nil { + val18[idx1] = new(capella.SignedBLSToExecutionChange) + } + buf := buf[172*idx1 : 172*(idx1+1)] + if err = val18[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Block.Body.BLSToExecutionChanges[%d]", idx1) + } + } + t.Block.Body.BLSToExecutionChanges = val18 + } + { // Field #11 'BlobKZGCommitments' (dynamic) + buf := buf[offset11:offset12] + val19 := t.Block.Body.BlobKZGCommitments + itemCount := len(buf) / 48 + if len(buf)%48 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 48), "Block.Body.BlobKZGCommitments") + } + if itemCount > int(expr14) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr14)), "Block.Body.BlobKZGCommitments") + } + val19 = sszutils.ExpandSlice(val19, itemCount) + sszutils.UnmarshalFixedBytesSlice(val19[:itemCount], buf) + t.Block.Body.BlobKZGCommitments = val19 + } + { // Field #12 'ExecutionRequests' (dynamic) + buf := buf[offset12:] + if t.Block.Body.ExecutionRequests == nil { + t.Block.Body.ExecutionRequests = new(all.ExecutionRequests) + } + buflen := len(buf) + if buflen < 12 { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, 12), "Block.Body.ExecutionRequests") + } + // Field #0 'Deposits' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 12 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset0, 12), "Block.Body.ExecutionRequests.Deposits:o") + } + // Field #1 'Withdrawals' (offset) + offset1 := int(binary.LittleEndian.Uint32(buf[4:8])) + if offset1 < offset0 || offset1 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset1, offset0, buflen), "Block.Body.ExecutionRequests.Withdrawals:o") + } + // Field #2 'Consolidations' (offset) + offset2 := int(binary.LittleEndian.Uint32(buf[8:12])) + if offset2 < offset1 || offset2 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset2, offset1, buflen), "Block.Body.ExecutionRequests.Consolidations:o") + } + { // Field #0 'Deposits' (dynamic) + buf := buf[offset0:offset1] + val20 := t.Block.Body.ExecutionRequests.Deposits + itemCount := len(buf) / 192 + if len(buf)%192 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 192), "Block.Body.ExecutionRequests.Deposits") + } + if itemCount > int(expr15) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr15)), "Block.Body.ExecutionRequests.Deposits") + } + val20 = sszutils.ExpandSlice(val20, itemCount) + for idx1 := range itemCount { + if val20[idx1] == nil { + val20[idx1] = new(electra1.DepositRequest) + } + buf := buf[192*idx1 : 192*(idx1+1)] + if err = val20[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Block.Body.ExecutionRequests.Deposits[%d]", idx1) + } + } + t.Block.Body.ExecutionRequests.Deposits = val20 + } + { // Field #1 'Withdrawals' (dynamic) + buf := buf[offset1:offset2] + val21 := t.Block.Body.ExecutionRequests.Withdrawals + itemCount := len(buf) / 76 + if len(buf)%76 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 76), "Block.Body.ExecutionRequests.Withdrawals") + } + if itemCount > int(expr16) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr16)), "Block.Body.ExecutionRequests.Withdrawals") + } + val21 = sszutils.ExpandSlice(val21, itemCount) + for idx1 := range itemCount { + if val21[idx1] == nil { + val21[idx1] = new(electra1.WithdrawalRequest) + } + buf := buf[76*idx1 : 76*(idx1+1)] + if err = val21[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Block.Body.ExecutionRequests.Withdrawals[%d]", idx1) + } + } + t.Block.Body.ExecutionRequests.Withdrawals = val21 + } + { // Field #2 'Consolidations' (dynamic) + buf := buf[offset2:] + val22 := t.Block.Body.ExecutionRequests.Consolidations + itemCount := len(buf) / 116 + if len(buf)%116 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 116), "Block.Body.ExecutionRequests.Consolidations") + } + if itemCount > int(expr17) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr17)), "Block.Body.ExecutionRequests.Consolidations") + } + val22 = sszutils.ExpandSlice(val22, itemCount) + for idx1 := range itemCount { + if val22[idx1] == nil { + val22[idx1] = new(electra1.ConsolidationRequest) + } + buf := buf[116*idx1 : 116*(idx1+1)] + if err = val22[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Block.Body.ExecutionRequests.Consolidations[%d]", idx1) + } + } + t.Block.Body.ExecutionRequests.Consolidations = val22 + } + } + } + } + { // Field #1 'KZGProofs' (dynamic) + buf := buf[offset1:offset2] + val23 := t.KZGProofs + itemCount := len(buf) / 48 + if len(buf)%48 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 48), "KZGProofs") + } + if itemCount > int(expr14) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr14)), "KZGProofs") + } + val23 = sszutils.ExpandSlice(val23, itemCount) + sszutils.UnmarshalFixedBytesSlice(val23[:itemCount], buf) + t.KZGProofs = val23 + } + { // Field #2 'Blobs' (dynamic) + buf := buf[offset2:] + val24 := t.Blobs + itemCount := len(buf) / 131072 + if len(buf)%131072 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 131072), "Blobs") + } + if itemCount > int(expr14) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr14)), "Blobs") + } + val24 = sszutils.ExpandSlice(val24, itemCount) + sszutils.UnmarshalFixedBytesSlice(val24[:itemCount], buf) + t.Blobs = val24 + } + return nil +} + +func (t *BlockContents) unmarshalSSZView_BlockContents_1(ds sszutils.DynamicSpecs, buf []byte) (err error) { + expr0, err := sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE/8", 64) + if err != nil { + return err + } + expr1, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_PROPOSER_SLASHINGS", 16) + if err != nil { + return err + } + expr2, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_ATTESTER_SLASHINGS_ELECTRA", 1) + if err != nil { + return err + } + expr3, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_VALIDATORS_PER_COMMITTEE*MAX_COMMITTEES_PER_SLOT", 131072) + if err != nil { + return err + } + expr4, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_ATTESTATIONS_ELECTRA", 8) + if err != nil { + return err + } + expr5, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_COMMITTEES_PER_SLOT/8", 8) + if err != nil { + return err + } + expr6, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_DEPOSITS", 16) + if err != nil { + return err + } + expr7, err := sszutils.ResolveSpecValueWithDefault(ds, "DEPOSIT_CONTRACT_TREE_DEPTH+1", 33) + if err != nil { + return err + } + expr8, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_VOLUNTARY_EXITS", 16) + if err != nil { + return err + } + expr9, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_EXTRA_DATA_BYTES", 32) + if err != nil { + return err + } + expr10, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_TRANSACTIONS_PER_PAYLOAD", 1048576) + if err != nil { + return err + } + expr11, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BYTES_PER_TRANSACTION", 1073741824) + if err != nil { + return err + } + expr12, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_WITHDRAWALS_PER_PAYLOAD", 16) + if err != nil { + return err + } + expr13, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BLS_TO_EXECUTION_CHANGES", 16) + if err != nil { + return err + } + expr14, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BLOB_COMMITMENTS_PER_BLOCK", 4096) + if err != nil { + return err + } + expr15, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_DEPOSIT_REQUESTS_PER_PAYLOAD", 8192) + if err != nil { + return err + } + expr16, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_WITHDRAWAL_REQUESTS_PER_PAYLOAD", 16) + if err != nil { + return err + } + expr17, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD", 2) + if err != nil { + return err + } + size2 := 1 * int(expr0) + size1 := size2 + 96 // size expression for '*SyncAggregate' + size3 := 1 * int(expr5) + size5 := 32 * int(expr7) + size4 := size5 + 184 // size expression for '*Deposit' + buflen := len(buf) + if buflen < 12 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 12) + } + // Field #0 'Block' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 12 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset0, 12), "Block:o") + } + // Field #1 'KZGProofs' (offset) + offset1 := int(binary.LittleEndian.Uint32(buf[4:8])) + if offset1 < offset0 || offset1 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset1, offset0, buflen), "KZGProofs:o") + } + // Field #2 'Blobs' (offset) + offset2 := int(binary.LittleEndian.Uint32(buf[8:12])) + if offset2 < offset1 || offset2 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset2, offset1, buflen), "Blobs:o") + } + { // Field #0 'Block' (dynamic) + buf := buf[offset0:offset1] + if t.Block == nil { + t.Block = new(all.BeaconBlock) + } + buflen := len(buf) + if buflen < 84 { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, 84), "Block") + } + { // Field #0 'Slot' (static) + buf := buf[0:8] + t.Block.Slot = phase0.Slot(binary.LittleEndian.Uint64(buf)) + } + { // Field #1 'ProposerIndex' (static) + buf := buf[8:16] + t.Block.ProposerIndex = phase0.ValidatorIndex(binary.LittleEndian.Uint64(buf)) + } + { // Field #2 'ParentRoot' (static) + buf := buf[16:48] + copy(t.Block.ParentRoot[:], buf) + } + { // Field #3 'StateRoot' (static) + buf := buf[48:80] + copy(t.Block.StateRoot[:], buf) + } + // Field #4 'Body' (offset) + offset4 := int(binary.LittleEndian.Uint32(buf[80:84])) + if offset4 != 84 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset4, 84), "Block.Body:o") + } + { // Field #4 'Body' (dynamic) + buf := buf[offset4:] + if t.Block.Body == nil { + t.Block.Body = new(all.BeaconBlockBody) + } + exproffset := 0 + totalSize := size1 + 236 + buflen := len(buf) + if buflen < totalSize { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, totalSize), "Block.Body") + } + { // Field #0 'RANDAOReveal' (static) + buf := buf[0:96] + copy(t.Block.Body.RANDAOReveal[:], buf) + } + { // Field #1 'ETH1Data' (static) + buf := buf[96:168] + if t.Block.Body.ETH1Data == nil { + t.Block.Body.ETH1Data = new(phase0.ETH1Data) + } + if err = t.Block.Body.ETH1Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "Block.Body.ETH1Data") + } + } + { // Field #2 'Graffiti' (static) + buf := buf[168:200] + copy(t.Block.Body.Graffiti[:], buf) + } + // Field #3 'ProposerSlashings' (offset) + offset3 := int(binary.LittleEndian.Uint32(buf[200:204])) + if offset3 != totalSize { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset3, totalSize), "Block.Body.ProposerSlashings:o") + } + // Field #4 'AttesterSlashings' (offset) + offset4 := int(binary.LittleEndian.Uint32(buf[204:208])) + if offset4 < offset3 || offset4 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset4, offset3, buflen), "Block.Body.AttesterSlashings:o") + } + // Field #5 'Attestations' (offset) + offset5 := int(binary.LittleEndian.Uint32(buf[208:212])) + if offset5 < offset4 || offset5 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset5, offset4, buflen), "Block.Body.Attestations:o") + } + // Field #6 'Deposits' (offset) + offset6 := int(binary.LittleEndian.Uint32(buf[212:216])) + if offset6 < offset5 || offset6 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset6, offset5, buflen), "Block.Body.Deposits:o") + } + // Field #7 'VoluntaryExits' (offset) + offset7 := int(binary.LittleEndian.Uint32(buf[216:220])) + if offset7 < offset6 || offset7 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset7, offset6, buflen), "Block.Body.VoluntaryExits:o") + } + { // Field #8 'SyncAggregate' (static) + buf := buf[220 : size1+220] + exproffset += int(size1) + val1 := t.Block.Body.SyncAggregate + if val1 == nil { + val1 = new(altair.SyncAggregate) + } + exproffset := 0 + totalSize := size2 + 96 + buflen := len(buf) + if buflen < totalSize { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, totalSize), "Block.Body.SyncAggregate") + } + if buflen > totalSize { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(buflen-totalSize), "Block.Body.SyncAggregate") + } + { // Field #0 'SyncCommitteeBits' (static) + buf := buf[0 : size2+0] + exproffset += int(size2) + val1.SyncCommitteeBits = sszutils.ExpandSlice(val1.SyncCommitteeBits, int(expr0)) + copy(val1.SyncCommitteeBits[:], buf) + } + { // Field #1 'SyncCommitteeSignature' (static) + buf := buf[exproffset+0 : exproffset+96] + copy(val1.SyncCommitteeSignature[:], buf) + } + t.Block.Body.SyncAggregate = val1 + } + // Field #9 'ExecutionPayload' (offset) + offset9 := int(binary.LittleEndian.Uint32(buf[exproffset+220 : exproffset+224])) + if offset9 < offset7 || offset9 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset9, offset7, buflen), "Block.Body.ExecutionPayload:o") + } + // Field #10 'BLSToExecutionChanges' (offset) + offset10 := int(binary.LittleEndian.Uint32(buf[exproffset+224 : exproffset+228])) + if offset10 < offset9 || offset10 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset10, offset9, buflen), "Block.Body.BLSToExecutionChanges:o") + } + // Field #11 'BlobKZGCommitments' (offset) + offset11 := int(binary.LittleEndian.Uint32(buf[exproffset+228 : exproffset+232])) + if offset11 < offset10 || offset11 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset11, offset10, buflen), "Block.Body.BlobKZGCommitments:o") + } + // Field #12 'ExecutionRequests' (offset) + offset12 := int(binary.LittleEndian.Uint32(buf[exproffset+232 : exproffset+236])) + if offset12 < offset11 || offset12 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset12, offset11, buflen), "Block.Body.ExecutionRequests:o") + } + { // Field #3 'ProposerSlashings' (dynamic) + buf := buf[offset3:offset4] + val2 := t.Block.Body.ProposerSlashings + itemCount := len(buf) / 416 + if len(buf)%416 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 416), "Block.Body.ProposerSlashings") + } + if itemCount > int(expr1) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr1)), "Block.Body.ProposerSlashings") + } + val2 = sszutils.ExpandSlice(val2, itemCount) + for idx1 := range itemCount { + if val2[idx1] == nil { + val2[idx1] = new(phase0.ProposerSlashing) + } + buf := buf[416*idx1 : 416*(idx1+1)] + if err = val2[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Block.Body.ProposerSlashings[%d]", idx1) + } + } + t.Block.Body.ProposerSlashings = val2 + } + { // Field #4 'AttesterSlashings' (dynamic) + buf := buf[offset4:offset5] + val3 := t.Block.Body.AttesterSlashings + startOffset := int(0) + if len(buf) != 0 { + if len(buf) < 4 { + return sszutils.ErrorWithPath(sszutils.ErrListOffsetsEOFFn(len(buf), 4), "Block.Body.AttesterSlashings") + } + startOffset = int(binary.LittleEndian.Uint32(buf[0:4])) + } + itemCount := startOffset / 4 + if startOffset%4 != 0 || len(buf) < startOffset || (len(buf) != 0 && startOffset == 0) { + return sszutils.ErrorWithPath(sszutils.ErrInvalidListStartOffsetFn(startOffset, len(buf)), "Block.Body.AttesterSlashings") + } + if itemCount > int(expr2) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr2)), "Block.Body.AttesterSlashings") + } + val3 = sszutils.ExpandSlice(val3, 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)), "Block.Body.AttesterSlashings[%d]", idx1) + } + buf := buf[startOffset:endOffset] + startOffset = endOffset + val4 := val3[idx1] + if val4 == nil { + val4 = new(all.AttesterSlashing) + } + buflen := len(buf) + if buflen < 8 { + return sszutils.ErrorWithPathf(sszutils.ErrFixedFieldsEOFFn(buflen, 8), "Block.Body.AttesterSlashings[%d]", idx1) + } + // Field #0 'Attestation1' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 8 { + return sszutils.ErrorWithPathf(sszutils.ErrFirstOffsetMismatchFn(offset0, 8), "Block.Body.AttesterSlashings[%d].Attestation1:o", idx1) + } + // Field #1 'Attestation2' (offset) + offset1 := int(binary.LittleEndian.Uint32(buf[4:8])) + if offset1 < offset0 || offset1 > buflen { + return sszutils.ErrorWithPathf(sszutils.ErrOffsetOutOfRangeFn(offset1, offset0, buflen), "Block.Body.AttesterSlashings[%d].Attestation2:o", idx1) + } + { // Field #0 'Attestation1' (dynamic) + buf := buf[offset0:offset1] + if val4.Attestation1 == nil { + val4.Attestation1 = new(all.IndexedAttestation) + } + buflen := len(buf) + if buflen < 228 { + return sszutils.ErrorWithPathf(sszutils.ErrFixedFieldsEOFFn(buflen, 228), "Block.Body.AttesterSlashings[%d].Attestation1", idx1) + } + // Field #0 'AttestingIndices' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 228 { + return sszutils.ErrorWithPathf(sszutils.ErrFirstOffsetMismatchFn(offset0, 228), "Block.Body.AttesterSlashings[%d].Attestation1.AttestingIndices:o", idx1) + } + { // Field #1 'Data' (static) + buf := buf[4:132] + if val4.Attestation1.Data == nil { + val4.Attestation1.Data = new(phase0.AttestationData) + } + if err = val4.Attestation1.Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Block.Body.AttesterSlashings[%d].Attestation1.Data", idx1) + } + } + { // Field #2 'Signature' (static) + buf := buf[132:228] + copy(val4.Attestation1.Signature[:], buf) + } + { // Field #0 'AttestingIndices' (dynamic) + buf := buf[offset0:] + val5 := val4.Attestation1.AttestingIndices + itemCount := len(buf) / 8 + if len(buf)%8 != 0 { + return sszutils.ErrorWithPathf(sszutils.ErrListNotAlignedFn(len(buf), 8), "Block.Body.AttesterSlashings[%d].Attestation1.AttestingIndices", idx1) + } + if itemCount > int(expr3) { + return sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(itemCount, int(expr3)), "Block.Body.AttesterSlashings[%d].Attestation1.AttestingIndices", idx1) + } + val5 = sszutils.ExpandSlice(val5, itemCount) + sszutils.UnmarshalUint64Slice(val5, buf) + val4.Attestation1.AttestingIndices = val5 + } + } + { // Field #1 'Attestation2' (dynamic) + buf := buf[offset1:] + if val4.Attestation2 == nil { + val4.Attestation2 = new(all.IndexedAttestation) + } + buflen := len(buf) + if buflen < 228 { + return sszutils.ErrorWithPathf(sszutils.ErrFixedFieldsEOFFn(buflen, 228), "Block.Body.AttesterSlashings[%d].Attestation2", idx1) + } + // Field #0 'AttestingIndices' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 228 { + return sszutils.ErrorWithPathf(sszutils.ErrFirstOffsetMismatchFn(offset0, 228), "Block.Body.AttesterSlashings[%d].Attestation2.AttestingIndices:o", idx1) + } + { // Field #1 'Data' (static) + buf := buf[4:132] + if val4.Attestation2.Data == nil { + val4.Attestation2.Data = new(phase0.AttestationData) + } + if err = val4.Attestation2.Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Block.Body.AttesterSlashings[%d].Attestation2.Data", idx1) + } + } + { // Field #2 'Signature' (static) + buf := buf[132:228] + copy(val4.Attestation2.Signature[:], buf) + } + { // Field #0 'AttestingIndices' (dynamic) + buf := buf[offset0:] + val6 := val4.Attestation2.AttestingIndices + itemCount := len(buf) / 8 + if len(buf)%8 != 0 { + return sszutils.ErrorWithPathf(sszutils.ErrListNotAlignedFn(len(buf), 8), "Block.Body.AttesterSlashings[%d].Attestation2.AttestingIndices", idx1) + } + if itemCount > int(expr3) { + return sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(itemCount, int(expr3)), "Block.Body.AttesterSlashings[%d].Attestation2.AttestingIndices", idx1) + } + val6 = sszutils.ExpandSlice(val6, itemCount) + sszutils.UnmarshalUint64Slice(val6, buf) + val4.Attestation2.AttestingIndices = val6 + } + } + val3[idx1] = val4 + } + t.Block.Body.AttesterSlashings = val3 + } + { // Field #5 'Attestations' (dynamic) + buf := buf[offset5:offset6] + val7 := t.Block.Body.Attestations + startOffset := int(0) + if len(buf) != 0 { + if len(buf) < 4 { + return sszutils.ErrorWithPath(sszutils.ErrListOffsetsEOFFn(len(buf), 4), "Block.Body.Attestations") + } + startOffset = int(binary.LittleEndian.Uint32(buf[0:4])) + } + itemCount := startOffset / 4 + if startOffset%4 != 0 || len(buf) < startOffset || (len(buf) != 0 && startOffset == 0) { + return sszutils.ErrorWithPath(sszutils.ErrInvalidListStartOffsetFn(startOffset, len(buf)), "Block.Body.Attestations") + } + if itemCount > int(expr4) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr4)), "Block.Body.Attestations") + } + val7 = sszutils.ExpandSlice(val7, 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)), "Block.Body.Attestations[%d]", idx1) + } + buf := buf[startOffset:endOffset] + startOffset = endOffset + val8 := val7[idx1] + if val8 == nil { + val8 = new(all.Attestation) + } + exproffset := 0 + totalSize := size3 + 228 + buflen := len(buf) + if buflen < totalSize { + return sszutils.ErrorWithPathf(sszutils.ErrFixedFieldsEOFFn(buflen, totalSize), "Block.Body.Attestations[%d]", idx1) + } + // Field #0 'AggregationBits' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != totalSize { + return sszutils.ErrorWithPathf(sszutils.ErrFirstOffsetMismatchFn(offset0, totalSize), "Block.Body.Attestations[%d].AggregationBits:o", idx1) + } + { // Field #1 'Data' (static) + buf := buf[4:132] + if val8.Data == nil { + val8.Data = new(phase0.AttestationData) + } + if err = val8.Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Block.Body.Attestations[%d].Data", idx1) + } + } + { // Field #2 'Signature' (static) + buf := buf[132:228] + copy(val8.Signature[:], buf) + } + { // Field #3 'CommitteeBits' (static) + buf := buf[228 : size3+228] + exproffset += int(size3) + val8.CommitteeBits = sszutils.ExpandSlice(val8.CommitteeBits, int(expr5)) + copy(val8.CommitteeBits[:], buf) + } + { // Field #0 'AggregationBits' (dynamic) + buf := buf[offset0:] + val9 := val8.AggregationBits + blen := len(buf) + if blen == 0 || buf[blen-1] == 0x00 { + return sszutils.ErrorWithPathf(sszutils.ErrBitlistNotTerminatedFn(), "Block.Body.Attestations[%d].AggregationBits", idx1) + } + bitCount := 8*(blen-1) + int(bits.Len8(buf[blen-1])) - 1 + if bitCount > int(expr3) { + return sszutils.ErrorWithPathf(sszutils.ErrBitlistLengthFn(bitCount, int(expr3)), "Block.Body.Attestations[%d].AggregationBits", idx1) + } + val9 = sszutils.ExpandSlice(val9, blen) + copy(val9[:], buf) + val8.AggregationBits = val9 + } + val7[idx1] = val8 + } + t.Block.Body.Attestations = val7 + } + { // Field #6 'Deposits' (dynamic) + buf := buf[offset6:offset7] + val10 := t.Block.Body.Deposits + itemCount := len(buf) / size4 + if len(buf)%size4 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), size4), "Block.Body.Deposits") + } + if itemCount > int(expr6) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "Block.Body.Deposits") + } + val10 = sszutils.ExpandSlice(val10, itemCount) + for idx1 := range itemCount { + val11 := val10[idx1] + if val11 == nil { + val11 = new(phase0.Deposit) + } + buf := buf[size4*idx1 : size4*(idx1+1)] + exproffset := 0 + totalSize := size5 + 184 + buflen := len(buf) + if buflen < totalSize { + return sszutils.ErrorWithPathf(sszutils.ErrFixedFieldsEOFFn(buflen, totalSize), "Block.Body.Deposits[%d]", idx1) + } + if buflen > totalSize { + return sszutils.ErrorWithPathf(sszutils.ErrTrailingDataFn(buflen-totalSize), "Block.Body.Deposits[%d]", idx1) + } + { // Field #0 'Proof' (static) + buf := buf[0 : size5+0] + exproffset += int(size5) + val12 := val11.Proof + val12 = sszutils.ExpandSlice(val12, int(expr7)) + for idx2 := range int(expr7) { + buf := buf[32*idx2 : 32*(idx2+1)] + val12[idx2] = sszutils.ExpandSlice(val12[idx2], 32) + copy(val12[idx2][:], buf) + } + val11.Proof = val12 + } + { // Field #1 'Data' (static) + buf := buf[exproffset+0 : exproffset+184] + if val11.Data == nil { + val11.Data = new(phase0.DepositData) + } + if err = val11.Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Block.Body.Deposits[%d].Data", idx1) + } + } + val10[idx1] = val11 + } + t.Block.Body.Deposits = val10 + } + { // Field #7 'VoluntaryExits' (dynamic) + buf := buf[offset7:offset9] + val13 := t.Block.Body.VoluntaryExits + itemCount := len(buf) / 112 + if len(buf)%112 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 112), "Block.Body.VoluntaryExits") + } + if itemCount > int(expr8) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr8)), "Block.Body.VoluntaryExits") + } + val13 = sszutils.ExpandSlice(val13, itemCount) + for idx1 := range itemCount { + if val13[idx1] == nil { + val13[idx1] = new(phase0.SignedVoluntaryExit) + } + buf := buf[112*idx1 : 112*(idx1+1)] + if err = val13[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Block.Body.VoluntaryExits[%d]", idx1) + } + } + t.Block.Body.VoluntaryExits = val13 + } + { // Field #9 'ExecutionPayload' (dynamic) + buf := buf[offset9:offset10] + if t.Block.Body.ExecutionPayload == nil { + t.Block.Body.ExecutionPayload = new(all.ExecutionPayload) + } + buflen := len(buf) + if buflen < 528 { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, 528), "Block.Body.ExecutionPayload") + } + { // Field #0 'ParentHash' (static) + buf := buf[0:32] + copy(t.Block.Body.ExecutionPayload.ParentHash[:], buf) + } + { // Field #1 'FeeRecipient' (static) + buf := buf[32:52] + copy(t.Block.Body.ExecutionPayload.FeeRecipient[:], buf) + } + { // Field #2 'StateRoot' (static) + buf := buf[52:84] + copy(t.Block.Body.ExecutionPayload.StateRoot[:], buf) + } + { // Field #3 'ReceiptsRoot' (static) + buf := buf[84:116] + copy(t.Block.Body.ExecutionPayload.ReceiptsRoot[:], buf) + } + { // Field #4 'LogsBloom' (static) + buf := buf[116:372] + copy(t.Block.Body.ExecutionPayload.LogsBloom[:], buf) + } + { // Field #5 'PrevRandao' (static) + buf := buf[372:404] + copy(t.Block.Body.ExecutionPayload.PrevRandao[:], buf) + } + { // Field #6 'BlockNumber' (static) + buf := buf[404:412] + t.Block.Body.ExecutionPayload.BlockNumber = binary.LittleEndian.Uint64(buf) + } + { // Field #7 'GasLimit' (static) + buf := buf[412:420] + t.Block.Body.ExecutionPayload.GasLimit = binary.LittleEndian.Uint64(buf) + } + { // Field #8 'GasUsed' (static) + buf := buf[420:428] + t.Block.Body.ExecutionPayload.GasUsed = binary.LittleEndian.Uint64(buf) + } + { // Field #9 'Timestamp' (static) + buf := buf[428:436] + t.Block.Body.ExecutionPayload.Timestamp = binary.LittleEndian.Uint64(buf) + } + // Field #10 'ExtraData' (offset) + offset10 := int(binary.LittleEndian.Uint32(buf[436:440])) + if offset10 != 528 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset10, 528), "Block.Body.ExecutionPayload.ExtraData:o") + } + { // Field #11 'BaseFeePerGas' (static) + buf := buf[440:472] + val14 := t.Block.Body.ExecutionPayload.BaseFeePerGas + if val14 == nil { + val14 = new(uint256.Int) + } + sszutils.UnmarshalUint64Slice((*val14)[:4], buf) + t.Block.Body.ExecutionPayload.BaseFeePerGas = val14 + } + { // Field #12 'BlockHash' (static) + buf := buf[472:504] + copy(t.Block.Body.ExecutionPayload.BlockHash[:], buf) + } + // Field #13 'Transactions' (offset) + offset13 := int(binary.LittleEndian.Uint32(buf[504:508])) + if offset13 < offset10 || offset13 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset13, offset10, buflen), "Block.Body.ExecutionPayload.Transactions:o") + } + // Field #14 'Withdrawals' (offset) + offset14 := int(binary.LittleEndian.Uint32(buf[508:512])) + if offset14 < offset13 || offset14 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset14, offset13, buflen), "Block.Body.ExecutionPayload.Withdrawals:o") + } + { // Field #15 'BlobGasUsed' (static) + buf := buf[512:520] + t.Block.Body.ExecutionPayload.BlobGasUsed = binary.LittleEndian.Uint64(buf) + } + { // Field #16 'ExcessBlobGas' (static) + buf := buf[520:528] + t.Block.Body.ExecutionPayload.ExcessBlobGas = binary.LittleEndian.Uint64(buf) + } + { // Field #10 'ExtraData' (dynamic) + buf := buf[offset10:offset13] + if len(buf) > int(expr9) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(len(buf), int(expr9)), "Block.Body.ExecutionPayload.ExtraData") + } + t.Block.Body.ExecutionPayload.ExtraData = sszutils.ExpandSlice(t.Block.Body.ExecutionPayload.ExtraData, len(buf)) + copy(t.Block.Body.ExecutionPayload.ExtraData[:], buf) + } + { // Field #13 'Transactions' (dynamic) + buf := buf[offset13:offset14] + val15 := t.Block.Body.ExecutionPayload.Transactions + startOffset := int(0) + if len(buf) != 0 { + if len(buf) < 4 { + return sszutils.ErrorWithPath(sszutils.ErrListOffsetsEOFFn(len(buf), 4), "Block.Body.ExecutionPayload.Transactions") + } + startOffset = int(binary.LittleEndian.Uint32(buf[0:4])) + } + itemCount := startOffset / 4 + if startOffset%4 != 0 || len(buf) < startOffset || (len(buf) != 0 && startOffset == 0) { + return sszutils.ErrorWithPath(sszutils.ErrInvalidListStartOffsetFn(startOffset, len(buf)), "Block.Body.ExecutionPayload.Transactions") + } + if itemCount > int(expr10) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr10)), "Block.Body.ExecutionPayload.Transactions") + } + val15 = sszutils.ExpandSlice(val15, 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)), "Block.Body.ExecutionPayload.Transactions[%d]", idx1) + } + buf := buf[startOffset:endOffset] + startOffset = endOffset + val16 := val15[idx1] + if len(buf) > int(expr11) { + return sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(len(buf), int(expr11)), "Block.Body.ExecutionPayload.Transactions[%d]", idx1) + } + val16 = sszutils.ExpandSlice(val16, len(buf)) + copy(val16[:], buf) + val15[idx1] = val16 + } + t.Block.Body.ExecutionPayload.Transactions = val15 + } + { // Field #14 'Withdrawals' (dynamic) + buf := buf[offset14:] + val17 := t.Block.Body.ExecutionPayload.Withdrawals + itemCount := len(buf) / 44 + if len(buf)%44 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 44), "Block.Body.ExecutionPayload.Withdrawals") + } + if itemCount > int(expr12) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr12)), "Block.Body.ExecutionPayload.Withdrawals") + } + val17 = sszutils.ExpandSlice(val17, itemCount) + for idx1 := range itemCount { + if val17[idx1] == nil { + val17[idx1] = new(capella.Withdrawal) + } + buf := buf[44*idx1 : 44*(idx1+1)] + if err = val17[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Block.Body.ExecutionPayload.Withdrawals[%d]", idx1) + } + } + t.Block.Body.ExecutionPayload.Withdrawals = val17 + } + } + { // Field #10 'BLSToExecutionChanges' (dynamic) + buf := buf[offset10:offset11] + val18 := t.Block.Body.BLSToExecutionChanges + itemCount := len(buf) / 172 + if len(buf)%172 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 172), "Block.Body.BLSToExecutionChanges") + } + if itemCount > int(expr13) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr13)), "Block.Body.BLSToExecutionChanges") + } + val18 = sszutils.ExpandSlice(val18, itemCount) + for idx1 := range itemCount { + if val18[idx1] == nil { + val18[idx1] = new(capella.SignedBLSToExecutionChange) + } + buf := buf[172*idx1 : 172*(idx1+1)] + if err = val18[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Block.Body.BLSToExecutionChanges[%d]", idx1) + } + } + t.Block.Body.BLSToExecutionChanges = val18 + } + { // Field #11 'BlobKZGCommitments' (dynamic) + buf := buf[offset11:offset12] + val19 := t.Block.Body.BlobKZGCommitments + itemCount := len(buf) / 48 + if len(buf)%48 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 48), "Block.Body.BlobKZGCommitments") + } + if itemCount > int(expr14) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr14)), "Block.Body.BlobKZGCommitments") + } + val19 = sszutils.ExpandSlice(val19, itemCount) + sszutils.UnmarshalFixedBytesSlice(val19[:itemCount], buf) + t.Block.Body.BlobKZGCommitments = val19 + } + { // Field #12 'ExecutionRequests' (dynamic) + buf := buf[offset12:] + if t.Block.Body.ExecutionRequests == nil { + t.Block.Body.ExecutionRequests = new(all.ExecutionRequests) + } + buflen := len(buf) + if buflen < 12 { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, 12), "Block.Body.ExecutionRequests") + } + // Field #0 'Deposits' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 12 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset0, 12), "Block.Body.ExecutionRequests.Deposits:o") + } + // Field #1 'Withdrawals' (offset) + offset1 := int(binary.LittleEndian.Uint32(buf[4:8])) + if offset1 < offset0 || offset1 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset1, offset0, buflen), "Block.Body.ExecutionRequests.Withdrawals:o") + } + // Field #2 'Consolidations' (offset) + offset2 := int(binary.LittleEndian.Uint32(buf[8:12])) + if offset2 < offset1 || offset2 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset2, offset1, buflen), "Block.Body.ExecutionRequests.Consolidations:o") + } + { // Field #0 'Deposits' (dynamic) + buf := buf[offset0:offset1] + val20 := t.Block.Body.ExecutionRequests.Deposits + itemCount := len(buf) / 192 + if len(buf)%192 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 192), "Block.Body.ExecutionRequests.Deposits") + } + if itemCount > int(expr15) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr15)), "Block.Body.ExecutionRequests.Deposits") + } + val20 = sszutils.ExpandSlice(val20, itemCount) + for idx1 := range itemCount { + if val20[idx1] == nil { + val20[idx1] = new(electra1.DepositRequest) + } + buf := buf[192*idx1 : 192*(idx1+1)] + if err = val20[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Block.Body.ExecutionRequests.Deposits[%d]", idx1) + } + } + t.Block.Body.ExecutionRequests.Deposits = val20 + } + { // Field #1 'Withdrawals' (dynamic) + buf := buf[offset1:offset2] + val21 := t.Block.Body.ExecutionRequests.Withdrawals + itemCount := len(buf) / 76 + if len(buf)%76 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 76), "Block.Body.ExecutionRequests.Withdrawals") + } + if itemCount > int(expr16) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr16)), "Block.Body.ExecutionRequests.Withdrawals") + } + val21 = sszutils.ExpandSlice(val21, itemCount) + for idx1 := range itemCount { + if val21[idx1] == nil { + val21[idx1] = new(electra1.WithdrawalRequest) + } + buf := buf[76*idx1 : 76*(idx1+1)] + if err = val21[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Block.Body.ExecutionRequests.Withdrawals[%d]", idx1) + } + } + t.Block.Body.ExecutionRequests.Withdrawals = val21 + } + { // Field #2 'Consolidations' (dynamic) + buf := buf[offset2:] + val22 := t.Block.Body.ExecutionRequests.Consolidations + itemCount := len(buf) / 116 + if len(buf)%116 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 116), "Block.Body.ExecutionRequests.Consolidations") + } + if itemCount > int(expr17) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr17)), "Block.Body.ExecutionRequests.Consolidations") + } + val22 = sszutils.ExpandSlice(val22, itemCount) + for idx1 := range itemCount { + if val22[idx1] == nil { + val22[idx1] = new(electra1.ConsolidationRequest) + } + buf := buf[116*idx1 : 116*(idx1+1)] + if err = val22[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "Block.Body.ExecutionRequests.Consolidations[%d]", idx1) + } + } + t.Block.Body.ExecutionRequests.Consolidations = val22 + } + } + } + } + { // Field #1 'KZGProofs' (dynamic) + buf := buf[offset1:offset2] + val23 := t.KZGProofs + itemCount := len(buf) / 48 + if len(buf)%48 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 48), "KZGProofs") + } + if itemCount > 33554432 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 33554432), "KZGProofs") + } + val23 = sszutils.ExpandSlice(val23, itemCount) + sszutils.UnmarshalFixedBytesSlice(val23[:itemCount], buf) + t.KZGProofs = val23 + } + { // Field #2 'Blobs' (dynamic) + buf := buf[offset2:] + val24 := t.Blobs + itemCount := len(buf) / 131072 + if len(buf)%131072 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 131072), "Blobs") + } + if itemCount > 4096 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 4096), "Blobs") + } + val24 = sszutils.ExpandSlice(val24, itemCount) + sszutils.UnmarshalFixedBytesSlice(val24[:itemCount], buf) + t.Blobs = val24 + } + return nil +} + +func (t *BlockContents) SizeSSZDynView(view any) func(ds sszutils.DynamicSpecs) int { + switch view.(type) { + case *deneb.BlockContents: + return t.sizeSSZView_BlockContents + case *electra.BlockContents: + return t.sizeSSZView_BlockContents_0 + case *fulu.BlockContents: + return t.sizeSSZView_BlockContents_1 + } + return nil +} +func (t *BlockContents) sizeSSZView_BlockContents(ds sszutils.DynamicSpecs) (size int) { + expr0, err := sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE/8", 64) + if err != nil { + return 0 + } + expr1, err := sszutils.ResolveSpecValueWithDefault(ds, "DEPOSIT_CONTRACT_TREE_DEPTH+1", 33) + if err != nil { + return 0 + } + if t == nil { + t = new(BlockContents) + } + // Field #0 'Block' offset (4 bytes) + // Field #1 'KZGProofs' offset (4 bytes) + // Field #2 'Blobs' offset (4 bytes) + size += 12 + { // Dynamic field #0 'Block' + t := t.Block + if t == nil { + t = new(all.BeaconBlock) + } + // Field #0 'Slot' static (8 bytes) + // Field #1 'ProposerIndex' static (8 bytes) + // Field #2 'ParentRoot' static (32 bytes) + // Field #3 'StateRoot' static (32 bytes) + // Field #4 'Body' offset (4 bytes) + size += 84 + { // Dynamic field #4 'Body' + t := t.Body + if t == nil { + t = new(all.BeaconBlockBody) + } + // Field #0 'RANDAOReveal' static (96 bytes) + // Field #1 'ETH1Data' static (72 bytes) + // Field #2 'Graffiti' static (32 bytes) + // Field #3 'ProposerSlashings' offset (4 bytes) + // Field #4 'AttesterSlashings' offset (4 bytes) + // Field #5 'Attestations' offset (4 bytes) + // Field #6 'Deposits' offset (4 bytes) + // Field #7 'VoluntaryExits' offset (4 bytes) + // Field #9 'ExecutionPayload' offset (4 bytes) + // Field #10 'BLSToExecutionChanges' offset (4 bytes) + // Field #11 'BlobKZGCommitments' offset (4 bytes) + size += 232 + { // Field #8 'SyncAggregate' + t := t.SyncAggregate + if t == nil { + t = new(altair.SyncAggregate) + } + // Field #1 'SyncCommitteeSignature' static (96 bytes) + size += 96 + { // Field #0 'SyncCommitteeBits' + size += int(expr0) + } + } + { // Dynamic field #3 'ProposerSlashings' + size += len(t.ProposerSlashings) * 416 + } + { // Dynamic field #4 'AttesterSlashings' + t := t.AttesterSlashings + vlen := len(t) + size += vlen * 4 // Offsets + for i1 := range vlen { + t := t[i1] + if t == nil { + t = new(all.AttesterSlashing) + } + // Field #0 'Attestation1' offset (4 bytes) + // Field #1 'Attestation2' offset (4 bytes) + size += 8 + { // Dynamic field #0 'Attestation1' + t := t.Attestation1 + if t == nil { + t = new(all.IndexedAttestation) + } + // Field #0 'AttestingIndices' offset (4 bytes) + // Field #1 'Data' static (128 bytes) + // Field #2 'Signature' static (96 bytes) + size += 228 + { // Dynamic field #0 'AttestingIndices' + size += len(t.AttestingIndices) * 8 + } + } + { // Dynamic field #1 'Attestation2' + t := t.Attestation2 + if t == nil { + t = new(all.IndexedAttestation) + } + // Field #0 'AttestingIndices' offset (4 bytes) + // Field #1 'Data' static (128 bytes) + // Field #2 'Signature' static (96 bytes) + size += 228 + { // Dynamic field #0 'AttestingIndices' + size += len(t.AttestingIndices) * 8 + } + } + } + } + { // Dynamic field #5 'Attestations' + t := t.Attestations + vlen := len(t) + size += vlen * 4 // Offsets + for i2 := range vlen { + t := t[i2] + if t == nil { + t = new(all.Attestation) + } + // Field #0 'AggregationBits' offset (4 bytes) + // Field #1 'Data' static (128 bytes) + // Field #2 'Signature' static (96 bytes) + size += 228 + { // Dynamic field #0 'AggregationBits' + if len(t.AggregationBits) == 0 { + size += 1 + } else { + size += len(t.AggregationBits) + } + } + } + } + { // Dynamic field #6 'Deposits' + t := t.Deposits + vlen := len(t) + if vlen > 0 { + s1 := 0 + t := t[0] + if t == nil { + t = new(phase0.Deposit) + } + // Field #1 'Data' static (184 bytes) + s1 += 184 + { // Field #0 'Proof' + s1 += int(expr1) * 32 + } + size += s1 * vlen + } + } + { // Dynamic field #7 'VoluntaryExits' + size += len(t.VoluntaryExits) * 112 + } + { // Dynamic field #9 'ExecutionPayload' + t := t.ExecutionPayload + if t == nil { + t = new(all.ExecutionPayload) + } + // Field #0 'ParentHash' static (32 bytes) + // Field #1 'FeeRecipient' static (20 bytes) + // Field #2 'StateRoot' static (32 bytes) + // Field #3 'ReceiptsRoot' static (32 bytes) + // Field #4 'LogsBloom' static (256 bytes) + // Field #5 'PrevRandao' static (32 bytes) + // Field #6 'BlockNumber' static (8 bytes) + // Field #7 'GasLimit' static (8 bytes) + // Field #8 'GasUsed' static (8 bytes) + // Field #9 'Timestamp' static (8 bytes) + // Field #10 'ExtraData' offset (4 bytes) + // Field #11 'BaseFeePerGas' static (32 bytes) + // Field #12 'BlockHash' static (32 bytes) + // Field #13 'Transactions' offset (4 bytes) + // Field #14 'Withdrawals' offset (4 bytes) + // Field #15 'BlobGasUsed' static (8 bytes) + // Field #16 'ExcessBlobGas' static (8 bytes) + size += 528 + { // Dynamic field #10 'ExtraData' + size += len(t.ExtraData) + } + { // Dynamic field #13 'Transactions' + t := t.Transactions + vlen := len(t) + size += vlen * 4 // Offsets + for i3 := range vlen { + size += len(t[i3]) + } + } + { // Dynamic field #14 'Withdrawals' + size += len(t.Withdrawals) * 44 + } + } + { // Dynamic field #10 'BLSToExecutionChanges' + size += len(t.BLSToExecutionChanges) * 172 + } + { // Dynamic field #11 'BlobKZGCommitments' + size += len(t.BlobKZGCommitments) * 48 + } + } + } + { // Dynamic field #1 'KZGProofs' + size += len(t.KZGProofs) * 48 + } + { // Dynamic field #2 'Blobs' + size += len(t.Blobs) * 131072 + } + return size +} + +func (t *BlockContents) sizeSSZView_BlockContents_0(ds sszutils.DynamicSpecs) (size int) { + expr0, err := sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE/8", 64) + if err != nil { + return 0 + } + expr1, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_COMMITTEES_PER_SLOT/8", 8) + if err != nil { + return 0 + } + expr2, err := sszutils.ResolveSpecValueWithDefault(ds, "DEPOSIT_CONTRACT_TREE_DEPTH+1", 33) + if err != nil { + return 0 + } + if t == nil { + t = new(BlockContents) + } + // Field #0 'Block' offset (4 bytes) + // Field #1 'KZGProofs' offset (4 bytes) + // Field #2 'Blobs' offset (4 bytes) + size += 12 + { // Dynamic field #0 'Block' + t := t.Block + if t == nil { + t = new(all.BeaconBlock) + } + // Field #0 'Slot' static (8 bytes) + // Field #1 'ProposerIndex' static (8 bytes) + // Field #2 'ParentRoot' static (32 bytes) + // Field #3 'StateRoot' static (32 bytes) + // Field #4 'Body' offset (4 bytes) + size += 84 + { // Dynamic field #4 'Body' + t := t.Body + if t == nil { + t = new(all.BeaconBlockBody) + } + // Field #0 'RANDAOReveal' static (96 bytes) + // Field #1 'ETH1Data' static (72 bytes) + // Field #2 'Graffiti' static (32 bytes) + // Field #3 'ProposerSlashings' offset (4 bytes) + // Field #4 'AttesterSlashings' offset (4 bytes) + // Field #5 'Attestations' offset (4 bytes) + // Field #6 'Deposits' offset (4 bytes) + // Field #7 'VoluntaryExits' offset (4 bytes) + // Field #9 'ExecutionPayload' offset (4 bytes) + // Field #10 'BLSToExecutionChanges' offset (4 bytes) + // Field #11 'BlobKZGCommitments' offset (4 bytes) + // Field #12 'ExecutionRequests' offset (4 bytes) + size += 236 + { // Field #8 'SyncAggregate' + t := t.SyncAggregate + if t == nil { + t = new(altair.SyncAggregate) + } + // Field #1 'SyncCommitteeSignature' static (96 bytes) + size += 96 + { // Field #0 'SyncCommitteeBits' + size += int(expr0) + } + } + { // Dynamic field #3 'ProposerSlashings' + size += len(t.ProposerSlashings) * 416 + } + { // Dynamic field #4 'AttesterSlashings' + t := t.AttesterSlashings + vlen := len(t) + size += vlen * 4 // Offsets + for i1 := range vlen { + t := t[i1] + if t == nil { + t = new(all.AttesterSlashing) + } + // Field #0 'Attestation1' offset (4 bytes) + // Field #1 'Attestation2' offset (4 bytes) + size += 8 + { // Dynamic field #0 'Attestation1' + t := t.Attestation1 + if t == nil { + t = new(all.IndexedAttestation) + } + // Field #0 'AttestingIndices' offset (4 bytes) + // Field #1 'Data' static (128 bytes) + // Field #2 'Signature' static (96 bytes) + size += 228 + { // Dynamic field #0 'AttestingIndices' + size += len(t.AttestingIndices) * 8 + } + } + { // Dynamic field #1 'Attestation2' + t := t.Attestation2 + if t == nil { + t = new(all.IndexedAttestation) + } + // Field #0 'AttestingIndices' offset (4 bytes) + // Field #1 'Data' static (128 bytes) + // Field #2 'Signature' static (96 bytes) + size += 228 + { // Dynamic field #0 'AttestingIndices' + size += len(t.AttestingIndices) * 8 + } + } + } + } + { // Dynamic field #5 'Attestations' + t := t.Attestations + vlen := len(t) + size += vlen * 4 // Offsets + for i2 := range vlen { + t := t[i2] + if t == nil { + t = new(all.Attestation) + } + // Field #0 'AggregationBits' offset (4 bytes) + // Field #1 'Data' static (128 bytes) + // Field #2 'Signature' static (96 bytes) + size += 228 + { // Field #3 'CommitteeBits' + size += int(expr1) + } + { // Dynamic field #0 'AggregationBits' + if len(t.AggregationBits) == 0 { + size += 1 + } else { + size += len(t.AggregationBits) + } + } + } + } + { // Dynamic field #6 'Deposits' + t := t.Deposits + vlen := len(t) + if vlen > 0 { + s1 := 0 + t := t[0] + if t == nil { + t = new(phase0.Deposit) + } + // Field #1 'Data' static (184 bytes) + s1 += 184 + { // Field #0 'Proof' + s1 += int(expr2) * 32 + } + size += s1 * vlen + } + } + { // Dynamic field #7 'VoluntaryExits' + size += len(t.VoluntaryExits) * 112 + } + { // Dynamic field #9 'ExecutionPayload' + t := t.ExecutionPayload + if t == nil { + t = new(all.ExecutionPayload) + } + // Field #0 'ParentHash' static (32 bytes) + // Field #1 'FeeRecipient' static (20 bytes) + // Field #2 'StateRoot' static (32 bytes) + // Field #3 'ReceiptsRoot' static (32 bytes) + // Field #4 'LogsBloom' static (256 bytes) + // Field #5 'PrevRandao' static (32 bytes) + // Field #6 'BlockNumber' static (8 bytes) + // Field #7 'GasLimit' static (8 bytes) + // Field #8 'GasUsed' static (8 bytes) + // Field #9 'Timestamp' static (8 bytes) + // Field #10 'ExtraData' offset (4 bytes) + // Field #11 'BaseFeePerGas' static (32 bytes) + // Field #12 'BlockHash' static (32 bytes) + // Field #13 'Transactions' offset (4 bytes) + // Field #14 'Withdrawals' offset (4 bytes) + // Field #15 'BlobGasUsed' static (8 bytes) + // Field #16 'ExcessBlobGas' static (8 bytes) + size += 528 + { // Dynamic field #10 'ExtraData' + size += len(t.ExtraData) + } + { // Dynamic field #13 'Transactions' + t := t.Transactions + vlen := len(t) + size += vlen * 4 // Offsets + for i3 := range vlen { + size += len(t[i3]) + } + } + { // Dynamic field #14 'Withdrawals' + size += len(t.Withdrawals) * 44 + } + } + { // Dynamic field #10 'BLSToExecutionChanges' + size += len(t.BLSToExecutionChanges) * 172 + } + { // Dynamic field #11 'BlobKZGCommitments' + size += len(t.BlobKZGCommitments) * 48 + } + { // Dynamic field #12 'ExecutionRequests' + t := t.ExecutionRequests + if t == nil { + t = new(all.ExecutionRequests) + } + // Field #0 'Deposits' offset (4 bytes) + // Field #1 'Withdrawals' offset (4 bytes) + // Field #2 'Consolidations' offset (4 bytes) + size += 12 + { // Dynamic field #0 'Deposits' + size += len(t.Deposits) * 192 + } + { // Dynamic field #1 'Withdrawals' + size += len(t.Withdrawals) * 76 + } + { // Dynamic field #2 'Consolidations' + size += len(t.Consolidations) * 116 + } + } + } + } + { // Dynamic field #1 'KZGProofs' + size += len(t.KZGProofs) * 48 + } + { // Dynamic field #2 'Blobs' + size += len(t.Blobs) * 131072 + } + return size +} + +func (t *BlockContents) sizeSSZView_BlockContents_1(ds sszutils.DynamicSpecs) (size int) { + expr0, err := sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE/8", 64) + if err != nil { + return 0 + } + expr1, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_COMMITTEES_PER_SLOT/8", 8) + if err != nil { + return 0 + } + expr2, err := sszutils.ResolveSpecValueWithDefault(ds, "DEPOSIT_CONTRACT_TREE_DEPTH+1", 33) + if err != nil { + return 0 + } + if t == nil { + t = new(BlockContents) + } + // Field #0 'Block' offset (4 bytes) + // Field #1 'KZGProofs' offset (4 bytes) + // Field #2 'Blobs' offset (4 bytes) + size += 12 + { // Dynamic field #0 'Block' + t := t.Block + if t == nil { + t = new(all.BeaconBlock) + } + // Field #0 'Slot' static (8 bytes) + // Field #1 'ProposerIndex' static (8 bytes) + // Field #2 'ParentRoot' static (32 bytes) + // Field #3 'StateRoot' static (32 bytes) + // Field #4 'Body' offset (4 bytes) + size += 84 + { // Dynamic field #4 'Body' + t := t.Body + if t == nil { + t = new(all.BeaconBlockBody) + } + // Field #0 'RANDAOReveal' static (96 bytes) + // Field #1 'ETH1Data' static (72 bytes) + // Field #2 'Graffiti' static (32 bytes) + // Field #3 'ProposerSlashings' offset (4 bytes) + // Field #4 'AttesterSlashings' offset (4 bytes) + // Field #5 'Attestations' offset (4 bytes) + // Field #6 'Deposits' offset (4 bytes) + // Field #7 'VoluntaryExits' offset (4 bytes) + // Field #9 'ExecutionPayload' offset (4 bytes) + // Field #10 'BLSToExecutionChanges' offset (4 bytes) + // Field #11 'BlobKZGCommitments' offset (4 bytes) + // Field #12 'ExecutionRequests' offset (4 bytes) + size += 236 + { // Field #8 'SyncAggregate' + t := t.SyncAggregate + if t == nil { + t = new(altair.SyncAggregate) + } + // Field #1 'SyncCommitteeSignature' static (96 bytes) + size += 96 + { // Field #0 'SyncCommitteeBits' + size += int(expr0) + } + } + { // Dynamic field #3 'ProposerSlashings' + size += len(t.ProposerSlashings) * 416 + } + { // Dynamic field #4 'AttesterSlashings' + t := t.AttesterSlashings + vlen := len(t) + size += vlen * 4 // Offsets + for i1 := range vlen { + t := t[i1] + if t == nil { + t = new(all.AttesterSlashing) + } + // Field #0 'Attestation1' offset (4 bytes) + // Field #1 'Attestation2' offset (4 bytes) + size += 8 + { // Dynamic field #0 'Attestation1' + t := t.Attestation1 + if t == nil { + t = new(all.IndexedAttestation) + } + // Field #0 'AttestingIndices' offset (4 bytes) + // Field #1 'Data' static (128 bytes) + // Field #2 'Signature' static (96 bytes) + size += 228 + { // Dynamic field #0 'AttestingIndices' + size += len(t.AttestingIndices) * 8 + } + } + { // Dynamic field #1 'Attestation2' + t := t.Attestation2 + if t == nil { + t = new(all.IndexedAttestation) + } + // Field #0 'AttestingIndices' offset (4 bytes) + // Field #1 'Data' static (128 bytes) + // Field #2 'Signature' static (96 bytes) + size += 228 + { // Dynamic field #0 'AttestingIndices' + size += len(t.AttestingIndices) * 8 + } + } + } + } + { // Dynamic field #5 'Attestations' + t := t.Attestations + vlen := len(t) + size += vlen * 4 // Offsets + for i2 := range vlen { + t := t[i2] + if t == nil { + t = new(all.Attestation) + } + // Field #0 'AggregationBits' offset (4 bytes) + // Field #1 'Data' static (128 bytes) + // Field #2 'Signature' static (96 bytes) + size += 228 + { // Field #3 'CommitteeBits' + size += int(expr1) + } + { // Dynamic field #0 'AggregationBits' + if len(t.AggregationBits) == 0 { + size += 1 + } else { + size += len(t.AggregationBits) + } + } + } + } + { // Dynamic field #6 'Deposits' + t := t.Deposits + vlen := len(t) + if vlen > 0 { + s1 := 0 + t := t[0] + if t == nil { + t = new(phase0.Deposit) + } + // Field #1 'Data' static (184 bytes) + s1 += 184 + { // Field #0 'Proof' + s1 += int(expr2) * 32 + } + size += s1 * vlen + } + } + { // Dynamic field #7 'VoluntaryExits' + size += len(t.VoluntaryExits) * 112 + } + { // Dynamic field #9 'ExecutionPayload' + t := t.ExecutionPayload + if t == nil { + t = new(all.ExecutionPayload) + } + // Field #0 'ParentHash' static (32 bytes) + // Field #1 'FeeRecipient' static (20 bytes) + // Field #2 'StateRoot' static (32 bytes) + // Field #3 'ReceiptsRoot' static (32 bytes) + // Field #4 'LogsBloom' static (256 bytes) + // Field #5 'PrevRandao' static (32 bytes) + // Field #6 'BlockNumber' static (8 bytes) + // Field #7 'GasLimit' static (8 bytes) + // Field #8 'GasUsed' static (8 bytes) + // Field #9 'Timestamp' static (8 bytes) + // Field #10 'ExtraData' offset (4 bytes) + // Field #11 'BaseFeePerGas' static (32 bytes) + // Field #12 'BlockHash' static (32 bytes) + // Field #13 'Transactions' offset (4 bytes) + // Field #14 'Withdrawals' offset (4 bytes) + // Field #15 'BlobGasUsed' static (8 bytes) + // Field #16 'ExcessBlobGas' static (8 bytes) + size += 528 + { // Dynamic field #10 'ExtraData' + size += len(t.ExtraData) + } + { // Dynamic field #13 'Transactions' + t := t.Transactions + vlen := len(t) + size += vlen * 4 // Offsets + for i3 := range vlen { + size += len(t[i3]) + } + } + { // Dynamic field #14 'Withdrawals' + size += len(t.Withdrawals) * 44 + } + } + { // Dynamic field #10 'BLSToExecutionChanges' + size += len(t.BLSToExecutionChanges) * 172 + } + { // Dynamic field #11 'BlobKZGCommitments' + size += len(t.BlobKZGCommitments) * 48 + } + { // Dynamic field #12 'ExecutionRequests' + t := t.ExecutionRequests + if t == nil { + t = new(all.ExecutionRequests) + } + // Field #0 'Deposits' offset (4 bytes) + // Field #1 'Withdrawals' offset (4 bytes) + // Field #2 'Consolidations' offset (4 bytes) + size += 12 + { // Dynamic field #0 'Deposits' + size += len(t.Deposits) * 192 + } + { // Dynamic field #1 'Withdrawals' + size += len(t.Withdrawals) * 76 + } + { // Dynamic field #2 'Consolidations' + size += len(t.Consolidations) * 116 + } + } + } + } + { // Dynamic field #1 'KZGProofs' + size += len(t.KZGProofs) * 48 + } + { // Dynamic field #2 'Blobs' + size += len(t.Blobs) * 131072 + } + return size +} + +func (t *BlockContents) HashTreeRootWithDynView(view any) func(ds sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + switch view.(type) { + case *deneb.BlockContents: + return t.hashTreeRootView_BlockContents + case *electra.BlockContents: + return t.hashTreeRootView_BlockContents_0 + case *fulu.BlockContents: + return t.hashTreeRootView_BlockContents_1 + } + return nil +} +func (t *BlockContents) hashTreeRootView_BlockContents(ds sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + expr0, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_PROPOSER_SLASHINGS", 16) + if err != nil { + return err + } + expr1, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_ATTESTER_SLASHINGS", 2) + if err != nil { + return err + } + expr2, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_ATTESTATIONS", 128) + if err != nil { + return err + } + expr3, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_VALIDATORS_PER_COMMITTEE", 2048) + if err != nil { + return err + } + expr4, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_DEPOSITS", 16) + if err != nil { + return err + } + expr5, err := sszutils.ResolveSpecValueWithDefault(ds, "DEPOSIT_CONTRACT_TREE_DEPTH+1", 33) + if err != nil { + return err + } + expr6, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_VOLUNTARY_EXITS", 16) + if err != nil { + return err + } + expr7, err := sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE/8", 64) + if err != nil { + return err + } + expr8, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_EXTRA_DATA_BYTES", 32) + if err != nil { + return err + } + expr9, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_TRANSACTIONS_PER_PAYLOAD", 1048576) + if err != nil { + return err + } + expr10, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BYTES_PER_TRANSACTION", 1073741824) + if err != nil { + return err + } + expr11, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_WITHDRAWALS_PER_PAYLOAD", 16) + if err != nil { + return err + } + expr12, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BLS_TO_EXECUTION_CHANGES", 16) + if err != nil { + return err + } + expr13, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BLOB_COMMITMENTS_PER_BLOCK", 4096) + if err != nil { + return err + } + if t == nil { + t = new(BlockContents) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Block' + t := t.Block + if t == nil { + t = new(all.BeaconBlock) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Slot' + hh.PutUint64(uint64(t.Slot)) + } + { // Field #1 'ProposerIndex' + hh.PutUint64(uint64(t.ProposerIndex)) + } + { // Field #2 'ParentRoot' + hh.PutBytes(t.ParentRoot[:32]) + } + { // Field #3 'StateRoot' + hh.PutBytes(t.StateRoot[:32]) + } + { // Field #4 'Body' + t := t.Body + if t == nil { + t = new(all.BeaconBlockBody) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'RANDAOReveal' + hh.PutBytes(t.RANDAOReveal[:96]) + } + { // Field #1 'ETH1Data' + t := t.ETH1Data + if t == nil { + t = new(phase0.ETH1Data) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPath(err, "Block.Body.ETH1Data") + } + } + { // Field #2 'Graffiti' + hh.PutBytes(t.Graffiti[:32]) + } + { // Field #3 'ProposerSlashings' + t := t.ProposerSlashings + vlen := uint64(len(t)) + if vlen > expr0 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr0), "Block.Body.ProposerSlashings") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(phase0.ProposerSlashing) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "Block.Body.ProposerSlashings[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr0, vlen, 32)) + } + { // Field #4 'AttesterSlashings' + t := t.AttesterSlashings + vlen := uint64(len(t)) + if vlen > expr1 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr1), "Block.Body.AttesterSlashings") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(all.AttesterSlashing) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Attestation1' + t := t.Attestation1 + if t == nil { + t = new(all.IndexedAttestation) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'AttestingIndices' + t := t.AttestingIndices + vlen := uint64(len(t)) + if vlen > 2048 { + return sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(vlen, 2048), "Block.Body.AttesterSlashings[%d].Attestation1.AttestingIndices", idx1) + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + sszutils.HashUint64Slice(hh, t) + hh.FillUpTo32() + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(2048, vlen, 8)) + } + { // Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.AttestationData) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "Block.Body.AttesterSlashings[%d].Attestation1.Data", idx1) + } + } + { // Field #2 'Signature' + hh.PutBytes(t.Signature[:96]) + } + hh.Merkleize(idx) + } + { // Field #1 'Attestation2' + t := t.Attestation2 + if t == nil { + t = new(all.IndexedAttestation) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'AttestingIndices' + t := t.AttestingIndices + vlen := uint64(len(t)) + if vlen > 2048 { + return sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(vlen, 2048), "Block.Body.AttesterSlashings[%d].Attestation2.AttestingIndices", idx1) + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + sszutils.HashUint64Slice(hh, t) + hh.FillUpTo32() + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(2048, vlen, 8)) + } + { // Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.AttestationData) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "Block.Body.AttesterSlashings[%d].Attestation2.Data", idx1) + } + } + { // Field #2 'Signature' + hh.PutBytes(t.Signature[:96]) + } + hh.Merkleize(idx) + } + hh.Merkleize(idx) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr1, vlen, 32)) + } + { // Field #5 'Attestations' + t := t.Attestations + vlen := uint64(len(t)) + if vlen > expr2 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr2), "Block.Body.Attestations") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(all.Attestation) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'AggregationBits' + t := t.AggregationBits + if l := len(t); l > 0 && t[l-1] == 0x00 { + return sszutils.ErrorWithPathf(sszutils.ErrBitlistNotTerminatedFn(), "Block.Body.Attestations[%d].AggregationBits", idx1) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + bitlist, size := hasher.ParseBitlistWithHasher(hh, t[:]) + if size > expr3 { + return sszutils.ErrorWithPathf(sszutils.ErrBitlistLengthFn(size, expr3), "Block.Body.Attestations[%d].AggregationBits", idx1) + } + hh.AppendBytes32(bitlist) + hh.MerkleizeWithMixin(idx, size, sszutils.CalculateBitlistLimit(expr3)) + } + { // Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.AttestationData) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "Block.Body.Attestations[%d].Data", idx1) + } + } + { // Field #2 'Signature' + hh.PutBytes(t.Signature[:96]) + } + hh.Merkleize(idx) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr2, vlen, 32)) + } + { // Field #6 'Deposits' + t := t.Deposits + vlen := uint64(len(t)) + if vlen > expr4 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr4), "Block.Body.Deposits") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(phase0.Deposit) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Proof' + t := t.Proof + vlen := len(t) + if vlen > int(expr5) { + return sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, int(expr5)), "Block.Body.Deposits[%d].Proof", idx1) + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + var val1, val1Empty []byte + for idx2 := range int(expr5) { + if idx2 < vlen { + val1 = t[idx2] + } else if idx2 == vlen { + val1 = val1Empty + } + vlen := len(val1) + if vlen > 32 { + return sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, 32), "Block.Body.Deposits[%d].Proof[%d]", idx1, idx2) + } + val := val1[:] + if vlen < 32 { + val = sszutils.AppendZeroPadding(val, (32-vlen)*1) + } + hh.PutBytes(val[:32]) + if (idx2+1)%256 == 0 { + hh.Collapse() + } + } + hh.Merkleize(idx) + } + { // Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.DepositData) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "Block.Body.Deposits[%d].Data", idx1) + } + } + hh.Merkleize(idx) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr4, vlen, 32)) + } + { // Field #7 'VoluntaryExits' + t := t.VoluntaryExits + vlen := uint64(len(t)) + if vlen > expr6 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr6), "Block.Body.VoluntaryExits") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(phase0.SignedVoluntaryExit) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "Block.Body.VoluntaryExits[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr6, vlen, 32)) + } + { // Field #8 'SyncAggregate' + t := t.SyncAggregate + if t == nil { + t = new(altair.SyncAggregate) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'SyncCommitteeBits' + vlen := len(t.SyncCommitteeBits) + if vlen > int(expr7) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(expr7)), "Block.Body.SyncAggregate.SyncCommitteeBits") + } + val := t.SyncCommitteeBits[:] + if vlen < int(expr7) { + val = sszutils.AppendZeroPadding(val, (int(expr7)-vlen)*1) + } + hh.PutBytes(val[:int(expr7)]) + } + { // Field #1 'SyncCommitteeSignature' + hh.PutBytes(t.SyncCommitteeSignature[:96]) + } + hh.Merkleize(idx) + } + { // Field #9 'ExecutionPayload' + t := t.ExecutionPayload + if t == nil { + t = new(all.ExecutionPayload) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'ParentHash' + hh.PutBytes(t.ParentHash[:32]) + } + { // Field #1 'FeeRecipient' + hh.PutBytes(t.FeeRecipient[:20]) + } + { // Field #2 'StateRoot' + hh.PutBytes(t.StateRoot[:32]) + } + { // Field #3 'ReceiptsRoot' + hh.PutBytes(t.ReceiptsRoot[:32]) + } + { // Field #4 'LogsBloom' + hh.PutBytes(t.LogsBloom[:256]) + } + { // Field #5 'PrevRandao' + hh.PutBytes(t.PrevRandao[:32]) + } + { // Field #6 'BlockNumber' + hh.PutUint64(t.BlockNumber) + } + { // Field #7 'GasLimit' + hh.PutUint64(t.GasLimit) + } + { // Field #8 'GasUsed' + hh.PutUint64(t.GasUsed) + } + { // Field #9 'Timestamp' + hh.PutUint64(t.Timestamp) + } + { // Field #10 'ExtraData' + vlen := uint64(len(t.ExtraData)) + if vlen > expr8 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr8), "Block.Body.ExecutionPayload.ExtraData") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + hh.AppendBytes32(t.ExtraData[:]) + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr8, vlen, 1)) + } + { // Field #11 'BaseFeePerGas' + t := t.BaseFeePerGas + if t == nil { + t = new(uint256.Int) + } + if root, err := t.HashTreeRoot(); err != nil { + return sszutils.ErrorWithPath(err, "Block.Body.ExecutionPayload.BaseFeePerGas") + } else { + hh.AppendBytes32(root[:]) + } + } + { // Field #12 'BlockHash' + hh.PutBytes(t.BlockHash[:32]) + } + { // Field #13 'Transactions' + t := t.Transactions + vlen := uint64(len(t)) + if vlen > expr9 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr9), "Block.Body.ExecutionPayload.Transactions") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + vlen := uint64(len(t[idx1])) + if vlen > expr10 { + return sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(vlen, expr10), "Block.Body.ExecutionPayload.Transactions[%d]", idx1) + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + hh.AppendBytes32(t[idx1][:]) + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr10, vlen, 1)) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr9, vlen, 32)) + } + { // Field #14 'Withdrawals' + t := t.Withdrawals + vlen := uint64(len(t)) + if vlen > expr11 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr11), "Block.Body.ExecutionPayload.Withdrawals") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(capella.Withdrawal) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "Block.Body.ExecutionPayload.Withdrawals[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr11, vlen, 32)) + } + { // Field #15 'BlobGasUsed' + hh.PutUint64(t.BlobGasUsed) + } + { // Field #16 'ExcessBlobGas' + hh.PutUint64(t.ExcessBlobGas) + } + hh.Merkleize(idx) + } + { // Field #10 'BLSToExecutionChanges' + t := t.BLSToExecutionChanges + vlen := uint64(len(t)) + if vlen > expr12 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr12), "Block.Body.BLSToExecutionChanges") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(capella.SignedBLSToExecutionChange) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "Block.Body.BLSToExecutionChanges[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr12, vlen, 32)) + } + { // Field #11 'BlobKZGCommitments' + t := t.BlobKZGCommitments + vlen := uint64(len(t)) + if vlen > expr13 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr13), "Block.Body.BlobKZGCommitments") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + hh.PutBytes(t[idx1][:48]) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr13, vlen, 32)) + } + hh.Merkleize(idx) + } + hh.Merkleize(idx) + } + { // Field #1 'KZGProofs' + t := t.KZGProofs + vlen := uint64(len(t)) + if vlen > expr13 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr13), "KZGProofs") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + hh.PutBytes(t[idx1][:48]) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr13, vlen, 32)) + } + { // Field #2 'Blobs' + t := t.Blobs + vlen := uint64(len(t)) + if vlen > expr13 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr13), "Blobs") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + hh.PutBytes(t[idx1][:131072]) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr13, vlen, 32)) + } + hh.Merkleize(idx) + return nil +} + +func (t *BlockContents) hashTreeRootView_BlockContents_0(ds sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + expr0, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_PROPOSER_SLASHINGS", 16) + if err != nil { + return err + } + expr1, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_ATTESTER_SLASHINGS_ELECTRA", 1) + if err != nil { + return err + } + expr2, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_VALIDATORS_PER_COMMITTEE*MAX_COMMITTEES_PER_SLOT", 131072) + if err != nil { + return err + } + expr3, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_ATTESTATIONS_ELECTRA", 8) + if err != nil { + return err + } + expr4, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_COMMITTEES_PER_SLOT/8", 8) + if err != nil { + return err + } + expr5, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_DEPOSITS", 16) + if err != nil { + return err + } + expr6, err := sszutils.ResolveSpecValueWithDefault(ds, "DEPOSIT_CONTRACT_TREE_DEPTH+1", 33) + if err != nil { + return err + } + expr7, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_VOLUNTARY_EXITS", 16) + if err != nil { + return err + } + expr8, err := sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE/8", 64) + if err != nil { + return err + } + expr9, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_EXTRA_DATA_BYTES", 32) + if err != nil { + return err + } + expr10, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_TRANSACTIONS_PER_PAYLOAD", 1048576) + if err != nil { + return err + } + expr11, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BYTES_PER_TRANSACTION", 1073741824) + if err != nil { + return err + } + expr12, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_WITHDRAWALS_PER_PAYLOAD", 16) + if err != nil { + return err + } + expr13, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BLS_TO_EXECUTION_CHANGES", 16) + if err != nil { + return err + } + expr14, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BLOB_COMMITMENTS_PER_BLOCK", 4096) + if err != nil { + return err + } + expr15, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_DEPOSIT_REQUESTS_PER_PAYLOAD", 8192) + if err != nil { + return err + } + expr16, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_WITHDRAWAL_REQUESTS_PER_PAYLOAD", 16) + if err != nil { + return err + } + expr17, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD", 2) + if err != nil { + return err + } + if t == nil { + t = new(BlockContents) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Block' + t := t.Block + if t == nil { + t = new(all.BeaconBlock) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Slot' + hh.PutUint64(uint64(t.Slot)) + } + { // Field #1 'ProposerIndex' + hh.PutUint64(uint64(t.ProposerIndex)) + } + { // Field #2 'ParentRoot' + hh.PutBytes(t.ParentRoot[:32]) + } + { // Field #3 'StateRoot' + hh.PutBytes(t.StateRoot[:32]) + } + { // Field #4 'Body' + t := t.Body + if t == nil { + t = new(all.BeaconBlockBody) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'RANDAOReveal' + hh.PutBytes(t.RANDAOReveal[:96]) + } + { // Field #1 'ETH1Data' + t := t.ETH1Data + if t == nil { + t = new(phase0.ETH1Data) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPath(err, "Block.Body.ETH1Data") + } + } + { // Field #2 'Graffiti' + hh.PutBytes(t.Graffiti[:32]) + } + { // Field #3 'ProposerSlashings' + t := t.ProposerSlashings + vlen := uint64(len(t)) + if vlen > expr0 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr0), "Block.Body.ProposerSlashings") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(phase0.ProposerSlashing) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "Block.Body.ProposerSlashings[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr0, vlen, 32)) + } + { // Field #4 'AttesterSlashings' + t := t.AttesterSlashings + vlen := uint64(len(t)) + if vlen > expr1 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr1), "Block.Body.AttesterSlashings") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(all.AttesterSlashing) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Attestation1' + t := t.Attestation1 + if t == nil { + t = new(all.IndexedAttestation) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'AttestingIndices' + t := t.AttestingIndices + vlen := uint64(len(t)) + if vlen > expr2 { + return sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(vlen, expr2), "Block.Body.AttesterSlashings[%d].Attestation1.AttestingIndices", idx1) + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + sszutils.HashUint64Slice(hh, t) + hh.FillUpTo32() + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr2, vlen, 8)) + } + { // Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.AttestationData) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "Block.Body.AttesterSlashings[%d].Attestation1.Data", idx1) + } + } + { // Field #2 'Signature' + hh.PutBytes(t.Signature[:96]) + } + hh.Merkleize(idx) + } + { // Field #1 'Attestation2' + t := t.Attestation2 + if t == nil { + t = new(all.IndexedAttestation) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'AttestingIndices' + t := t.AttestingIndices + vlen := uint64(len(t)) + if vlen > expr2 { + return sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(vlen, expr2), "Block.Body.AttesterSlashings[%d].Attestation2.AttestingIndices", idx1) + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + sszutils.HashUint64Slice(hh, t) + hh.FillUpTo32() + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr2, vlen, 8)) + } + { // Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.AttestationData) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "Block.Body.AttesterSlashings[%d].Attestation2.Data", idx1) + } + } + { // Field #2 'Signature' + hh.PutBytes(t.Signature[:96]) + } + hh.Merkleize(idx) + } + hh.Merkleize(idx) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr1, vlen, 32)) + } + { // Field #5 'Attestations' + t := t.Attestations + vlen := uint64(len(t)) + if vlen > expr3 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr3), "Block.Body.Attestations") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(all.Attestation) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'AggregationBits' + t := t.AggregationBits + if l := len(t); l > 0 && t[l-1] == 0x00 { + return sszutils.ErrorWithPathf(sszutils.ErrBitlistNotTerminatedFn(), "Block.Body.Attestations[%d].AggregationBits", idx1) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + bitlist, size := hasher.ParseBitlistWithHasher(hh, t[:]) + if size > expr2 { + return sszutils.ErrorWithPathf(sszutils.ErrBitlistLengthFn(size, expr2), "Block.Body.Attestations[%d].AggregationBits", idx1) + } + hh.AppendBytes32(bitlist) + hh.MerkleizeWithMixin(idx, size, sszutils.CalculateBitlistLimit(expr2)) + } + { // Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.AttestationData) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "Block.Body.Attestations[%d].Data", idx1) + } + } + { // Field #2 'Signature' + hh.PutBytes(t.Signature[:96]) + } + { // Field #3 'CommitteeBits' + vlen := len(t.CommitteeBits) + if vlen > int(expr4) { + return sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, int(expr4)), "Block.Body.Attestations[%d].CommitteeBits", idx1) + } + val := t.CommitteeBits[:] + if vlen < int(expr4) { + val = sszutils.AppendZeroPadding(val, (int(expr4)-vlen)*1) + } + hh.PutBytes(val[:int(expr4)]) + } + hh.Merkleize(idx) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr3, vlen, 32)) + } + { // Field #6 'Deposits' + t := t.Deposits + vlen := uint64(len(t)) + if vlen > expr5 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr5), "Block.Body.Deposits") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(phase0.Deposit) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Proof' + t := t.Proof + vlen := len(t) + if vlen > int(expr6) { + return sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, int(expr6)), "Block.Body.Deposits[%d].Proof", idx1) + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + var val1, val1Empty []byte + for idx2 := range int(expr6) { + if idx2 < vlen { + val1 = t[idx2] + } else if idx2 == vlen { + val1 = val1Empty + } + vlen := len(val1) + if vlen > 32 { + return sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, 32), "Block.Body.Deposits[%d].Proof[%d]", idx1, idx2) + } + val := val1[:] + if vlen < 32 { + val = sszutils.AppendZeroPadding(val, (32-vlen)*1) + } + hh.PutBytes(val[:32]) + if (idx2+1)%256 == 0 { + hh.Collapse() + } + } + hh.Merkleize(idx) + } + { // Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.DepositData) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "Block.Body.Deposits[%d].Data", idx1) + } + } + hh.Merkleize(idx) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr5, vlen, 32)) + } + { // Field #7 'VoluntaryExits' + t := t.VoluntaryExits + vlen := uint64(len(t)) + if vlen > expr7 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr7), "Block.Body.VoluntaryExits") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(phase0.SignedVoluntaryExit) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "Block.Body.VoluntaryExits[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr7, vlen, 32)) + } + { // Field #8 'SyncAggregate' + t := t.SyncAggregate + if t == nil { + t = new(altair.SyncAggregate) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'SyncCommitteeBits' + vlen := len(t.SyncCommitteeBits) + if vlen > int(expr8) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(expr8)), "Block.Body.SyncAggregate.SyncCommitteeBits") + } + val := t.SyncCommitteeBits[:] + if vlen < int(expr8) { + val = sszutils.AppendZeroPadding(val, (int(expr8)-vlen)*1) + } + hh.PutBytes(val[:int(expr8)]) + } + { // Field #1 'SyncCommitteeSignature' + hh.PutBytes(t.SyncCommitteeSignature[:96]) + } + hh.Merkleize(idx) + } + { // Field #9 'ExecutionPayload' + t := t.ExecutionPayload + if t == nil { + t = new(all.ExecutionPayload) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'ParentHash' + hh.PutBytes(t.ParentHash[:32]) + } + { // Field #1 'FeeRecipient' + hh.PutBytes(t.FeeRecipient[:20]) + } + { // Field #2 'StateRoot' + hh.PutBytes(t.StateRoot[:32]) + } + { // Field #3 'ReceiptsRoot' + hh.PutBytes(t.ReceiptsRoot[:32]) + } + { // Field #4 'LogsBloom' + hh.PutBytes(t.LogsBloom[:256]) + } + { // Field #5 'PrevRandao' + hh.PutBytes(t.PrevRandao[:32]) + } + { // Field #6 'BlockNumber' + hh.PutUint64(t.BlockNumber) + } + { // Field #7 'GasLimit' + hh.PutUint64(t.GasLimit) + } + { // Field #8 'GasUsed' + hh.PutUint64(t.GasUsed) + } + { // Field #9 'Timestamp' + hh.PutUint64(t.Timestamp) + } + { // Field #10 'ExtraData' + vlen := uint64(len(t.ExtraData)) + if vlen > expr9 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr9), "Block.Body.ExecutionPayload.ExtraData") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + hh.AppendBytes32(t.ExtraData[:]) + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr9, vlen, 1)) + } + { // Field #11 'BaseFeePerGas' + t := t.BaseFeePerGas + if t == nil { + t = new(uint256.Int) + } + if root, err := t.HashTreeRoot(); err != nil { + return sszutils.ErrorWithPath(err, "Block.Body.ExecutionPayload.BaseFeePerGas") + } else { + hh.AppendBytes32(root[:]) + } + } + { // Field #12 'BlockHash' + hh.PutBytes(t.BlockHash[:32]) + } + { // Field #13 'Transactions' + t := t.Transactions + vlen := uint64(len(t)) + if vlen > expr10 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr10), "Block.Body.ExecutionPayload.Transactions") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + vlen := uint64(len(t[idx1])) + if vlen > expr11 { + return sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(vlen, expr11), "Block.Body.ExecutionPayload.Transactions[%d]", idx1) + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + hh.AppendBytes32(t[idx1][:]) + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr11, vlen, 1)) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr10, vlen, 32)) + } + { // Field #14 'Withdrawals' + t := t.Withdrawals + vlen := uint64(len(t)) + if vlen > expr12 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr12), "Block.Body.ExecutionPayload.Withdrawals") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(capella.Withdrawal) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "Block.Body.ExecutionPayload.Withdrawals[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr12, vlen, 32)) + } + { // Field #15 'BlobGasUsed' + hh.PutUint64(t.BlobGasUsed) + } + { // Field #16 'ExcessBlobGas' + hh.PutUint64(t.ExcessBlobGas) + } + hh.Merkleize(idx) + } + { // Field #10 'BLSToExecutionChanges' + t := t.BLSToExecutionChanges + vlen := uint64(len(t)) + if vlen > expr13 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr13), "Block.Body.BLSToExecutionChanges") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(capella.SignedBLSToExecutionChange) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "Block.Body.BLSToExecutionChanges[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr13, vlen, 32)) + } + { // Field #11 'BlobKZGCommitments' + t := t.BlobKZGCommitments + vlen := uint64(len(t)) + if vlen > expr14 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr14), "Block.Body.BlobKZGCommitments") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + hh.PutBytes(t[idx1][:48]) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr14, vlen, 32)) + } + { // Field #12 'ExecutionRequests' + t := t.ExecutionRequests + if t == nil { + t = new(all.ExecutionRequests) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Deposits' + t := t.Deposits + vlen := uint64(len(t)) + if vlen > expr15 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr15), "Block.Body.ExecutionRequests.Deposits") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(electra1.DepositRequest) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "Block.Body.ExecutionRequests.Deposits[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr15, vlen, 32)) + } + { // Field #1 'Withdrawals' + t := t.Withdrawals + vlen := uint64(len(t)) + if vlen > expr16 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr16), "Block.Body.ExecutionRequests.Withdrawals") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(electra1.WithdrawalRequest) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "Block.Body.ExecutionRequests.Withdrawals[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr16, vlen, 32)) + } + { // Field #2 'Consolidations' + t := t.Consolidations + vlen := uint64(len(t)) + if vlen > expr17 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr17), "Block.Body.ExecutionRequests.Consolidations") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(electra1.ConsolidationRequest) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "Block.Body.ExecutionRequests.Consolidations[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr17, vlen, 32)) + } + hh.Merkleize(idx) + } + hh.Merkleize(idx) + } + hh.Merkleize(idx) + } + { // Field #1 'KZGProofs' + t := t.KZGProofs + vlen := uint64(len(t)) + if vlen > expr14 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr14), "KZGProofs") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + hh.PutBytes(t[idx1][:48]) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr14, vlen, 32)) + } + { // Field #2 'Blobs' + t := t.Blobs + vlen := uint64(len(t)) + if vlen > expr14 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr14), "Blobs") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + hh.PutBytes(t[idx1][:131072]) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr14, vlen, 32)) + } + hh.Merkleize(idx) + return nil +} + +func (t *BlockContents) hashTreeRootView_BlockContents_1(ds sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + expr0, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_PROPOSER_SLASHINGS", 16) + if err != nil { + return err + } + expr1, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_ATTESTER_SLASHINGS_ELECTRA", 1) + if err != nil { + return err + } + expr2, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_VALIDATORS_PER_COMMITTEE*MAX_COMMITTEES_PER_SLOT", 131072) + if err != nil { + return err + } + expr3, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_ATTESTATIONS_ELECTRA", 8) + if err != nil { + return err + } + expr4, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_COMMITTEES_PER_SLOT/8", 8) + if err != nil { + return err + } + expr5, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_DEPOSITS", 16) + if err != nil { + return err + } + expr6, err := sszutils.ResolveSpecValueWithDefault(ds, "DEPOSIT_CONTRACT_TREE_DEPTH+1", 33) + if err != nil { + return err + } + expr7, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_VOLUNTARY_EXITS", 16) + if err != nil { + return err + } + expr8, err := sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE/8", 64) + if err != nil { + return err + } + expr9, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_EXTRA_DATA_BYTES", 32) + if err != nil { + return err + } + expr10, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_TRANSACTIONS_PER_PAYLOAD", 1048576) + if err != nil { + return err + } + expr11, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BYTES_PER_TRANSACTION", 1073741824) + if err != nil { + return err + } + expr12, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_WITHDRAWALS_PER_PAYLOAD", 16) + if err != nil { + return err + } + expr13, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BLS_TO_EXECUTION_CHANGES", 16) + if err != nil { + return err + } + expr14, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BLOB_COMMITMENTS_PER_BLOCK", 4096) + if err != nil { + return err + } + expr15, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_DEPOSIT_REQUESTS_PER_PAYLOAD", 8192) + if err != nil { + return err + } + expr16, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_WITHDRAWAL_REQUESTS_PER_PAYLOAD", 16) + if err != nil { + return err + } + expr17, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD", 2) + if err != nil { + return err + } + if t == nil { + t = new(BlockContents) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Block' + t := t.Block + if t == nil { + t = new(all.BeaconBlock) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Slot' + hh.PutUint64(uint64(t.Slot)) + } + { // Field #1 'ProposerIndex' + hh.PutUint64(uint64(t.ProposerIndex)) + } + { // Field #2 'ParentRoot' + hh.PutBytes(t.ParentRoot[:32]) + } + { // Field #3 'StateRoot' + hh.PutBytes(t.StateRoot[:32]) + } + { // Field #4 'Body' + t := t.Body + if t == nil { + t = new(all.BeaconBlockBody) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'RANDAOReveal' + hh.PutBytes(t.RANDAOReveal[:96]) + } + { // Field #1 'ETH1Data' + t := t.ETH1Data + if t == nil { + t = new(phase0.ETH1Data) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPath(err, "Block.Body.ETH1Data") + } + } + { // Field #2 'Graffiti' + hh.PutBytes(t.Graffiti[:32]) + } + { // Field #3 'ProposerSlashings' + t := t.ProposerSlashings + vlen := uint64(len(t)) + if vlen > expr0 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr0), "Block.Body.ProposerSlashings") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(phase0.ProposerSlashing) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "Block.Body.ProposerSlashings[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr0, vlen, 32)) + } + { // Field #4 'AttesterSlashings' + t := t.AttesterSlashings + vlen := uint64(len(t)) + if vlen > expr1 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr1), "Block.Body.AttesterSlashings") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(all.AttesterSlashing) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Attestation1' + t := t.Attestation1 + if t == nil { + t = new(all.IndexedAttestation) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'AttestingIndices' + t := t.AttestingIndices + vlen := uint64(len(t)) + if vlen > expr2 { + return sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(vlen, expr2), "Block.Body.AttesterSlashings[%d].Attestation1.AttestingIndices", idx1) + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + sszutils.HashUint64Slice(hh, t) + hh.FillUpTo32() + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr2, vlen, 8)) + } + { // Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.AttestationData) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "Block.Body.AttesterSlashings[%d].Attestation1.Data", idx1) + } + } + { // Field #2 'Signature' + hh.PutBytes(t.Signature[:96]) + } + hh.Merkleize(idx) + } + { // Field #1 'Attestation2' + t := t.Attestation2 + if t == nil { + t = new(all.IndexedAttestation) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'AttestingIndices' + t := t.AttestingIndices + vlen := uint64(len(t)) + if vlen > expr2 { + return sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(vlen, expr2), "Block.Body.AttesterSlashings[%d].Attestation2.AttestingIndices", idx1) + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + sszutils.HashUint64Slice(hh, t) + hh.FillUpTo32() + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr2, vlen, 8)) + } + { // Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.AttestationData) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "Block.Body.AttesterSlashings[%d].Attestation2.Data", idx1) + } + } + { // Field #2 'Signature' + hh.PutBytes(t.Signature[:96]) + } + hh.Merkleize(idx) + } + hh.Merkleize(idx) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr1, vlen, 32)) + } + { // Field #5 'Attestations' + t := t.Attestations + vlen := uint64(len(t)) + if vlen > expr3 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr3), "Block.Body.Attestations") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(all.Attestation) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'AggregationBits' + t := t.AggregationBits + if l := len(t); l > 0 && t[l-1] == 0x00 { + return sszutils.ErrorWithPathf(sszutils.ErrBitlistNotTerminatedFn(), "Block.Body.Attestations[%d].AggregationBits", idx1) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + bitlist, size := hasher.ParseBitlistWithHasher(hh, t[:]) + if size > expr2 { + return sszutils.ErrorWithPathf(sszutils.ErrBitlistLengthFn(size, expr2), "Block.Body.Attestations[%d].AggregationBits", idx1) + } + hh.AppendBytes32(bitlist) + hh.MerkleizeWithMixin(idx, size, sszutils.CalculateBitlistLimit(expr2)) + } + { // Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.AttestationData) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "Block.Body.Attestations[%d].Data", idx1) + } + } + { // Field #2 'Signature' + hh.PutBytes(t.Signature[:96]) + } + { // Field #3 'CommitteeBits' + vlen := len(t.CommitteeBits) + if vlen > int(expr4) { + return sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, int(expr4)), "Block.Body.Attestations[%d].CommitteeBits", idx1) + } + val := t.CommitteeBits[:] + if vlen < int(expr4) { + val = sszutils.AppendZeroPadding(val, (int(expr4)-vlen)*1) + } + hh.PutBytes(val[:int(expr4)]) + } + hh.Merkleize(idx) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr3, vlen, 32)) + } + { // Field #6 'Deposits' + t := t.Deposits + vlen := uint64(len(t)) + if vlen > expr5 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr5), "Block.Body.Deposits") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(phase0.Deposit) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Proof' + t := t.Proof + vlen := len(t) + if vlen > int(expr6) { + return sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, int(expr6)), "Block.Body.Deposits[%d].Proof", idx1) + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + var val1, val1Empty []byte + for idx2 := range int(expr6) { + if idx2 < vlen { + val1 = t[idx2] + } else if idx2 == vlen { + val1 = val1Empty + } + vlen := len(val1) + if vlen > 32 { + return sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, 32), "Block.Body.Deposits[%d].Proof[%d]", idx1, idx2) + } + val := val1[:] + if vlen < 32 { + val = sszutils.AppendZeroPadding(val, (32-vlen)*1) + } + hh.PutBytes(val[:32]) + if (idx2+1)%256 == 0 { + hh.Collapse() + } + } + hh.Merkleize(idx) + } + { // Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.DepositData) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "Block.Body.Deposits[%d].Data", idx1) + } + } + hh.Merkleize(idx) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr5, vlen, 32)) + } + { // Field #7 'VoluntaryExits' + t := t.VoluntaryExits + vlen := uint64(len(t)) + if vlen > expr7 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr7), "Block.Body.VoluntaryExits") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(phase0.SignedVoluntaryExit) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "Block.Body.VoluntaryExits[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr7, vlen, 32)) + } + { // Field #8 'SyncAggregate' + t := t.SyncAggregate + if t == nil { + t = new(altair.SyncAggregate) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'SyncCommitteeBits' + vlen := len(t.SyncCommitteeBits) + if vlen > int(expr8) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(expr8)), "Block.Body.SyncAggregate.SyncCommitteeBits") + } + val := t.SyncCommitteeBits[:] + if vlen < int(expr8) { + val = sszutils.AppendZeroPadding(val, (int(expr8)-vlen)*1) + } + hh.PutBytes(val[:int(expr8)]) + } + { // Field #1 'SyncCommitteeSignature' + hh.PutBytes(t.SyncCommitteeSignature[:96]) + } + hh.Merkleize(idx) + } + { // Field #9 'ExecutionPayload' + t := t.ExecutionPayload + if t == nil { + t = new(all.ExecutionPayload) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'ParentHash' + hh.PutBytes(t.ParentHash[:32]) + } + { // Field #1 'FeeRecipient' + hh.PutBytes(t.FeeRecipient[:20]) + } + { // Field #2 'StateRoot' + hh.PutBytes(t.StateRoot[:32]) + } + { // Field #3 'ReceiptsRoot' + hh.PutBytes(t.ReceiptsRoot[:32]) + } + { // Field #4 'LogsBloom' + hh.PutBytes(t.LogsBloom[:256]) + } + { // Field #5 'PrevRandao' + hh.PutBytes(t.PrevRandao[:32]) + } + { // Field #6 'BlockNumber' + hh.PutUint64(t.BlockNumber) + } + { // Field #7 'GasLimit' + hh.PutUint64(t.GasLimit) + } + { // Field #8 'GasUsed' + hh.PutUint64(t.GasUsed) + } + { // Field #9 'Timestamp' + hh.PutUint64(t.Timestamp) + } + { // Field #10 'ExtraData' + vlen := uint64(len(t.ExtraData)) + if vlen > expr9 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr9), "Block.Body.ExecutionPayload.ExtraData") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + hh.AppendBytes32(t.ExtraData[:]) + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr9, vlen, 1)) + } + { // Field #11 'BaseFeePerGas' + t := t.BaseFeePerGas + if t == nil { + t = new(uint256.Int) + } + if root, err := t.HashTreeRoot(); err != nil { + return sszutils.ErrorWithPath(err, "Block.Body.ExecutionPayload.BaseFeePerGas") + } else { + hh.AppendBytes32(root[:]) + } + } + { // Field #12 'BlockHash' + hh.PutBytes(t.BlockHash[:32]) + } + { // Field #13 'Transactions' + t := t.Transactions + vlen := uint64(len(t)) + if vlen > expr10 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr10), "Block.Body.ExecutionPayload.Transactions") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + vlen := uint64(len(t[idx1])) + if vlen > expr11 { + return sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(vlen, expr11), "Block.Body.ExecutionPayload.Transactions[%d]", idx1) + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + hh.AppendBytes32(t[idx1][:]) + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr11, vlen, 1)) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr10, vlen, 32)) + } + { // Field #14 'Withdrawals' + t := t.Withdrawals + vlen := uint64(len(t)) + if vlen > expr12 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr12), "Block.Body.ExecutionPayload.Withdrawals") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(capella.Withdrawal) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "Block.Body.ExecutionPayload.Withdrawals[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr12, vlen, 32)) + } + { // Field #15 'BlobGasUsed' + hh.PutUint64(t.BlobGasUsed) + } + { // Field #16 'ExcessBlobGas' + hh.PutUint64(t.ExcessBlobGas) + } + hh.Merkleize(idx) + } + { // Field #10 'BLSToExecutionChanges' + t := t.BLSToExecutionChanges + vlen := uint64(len(t)) + if vlen > expr13 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr13), "Block.Body.BLSToExecutionChanges") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(capella.SignedBLSToExecutionChange) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "Block.Body.BLSToExecutionChanges[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr13, vlen, 32)) + } + { // Field #11 'BlobKZGCommitments' + t := t.BlobKZGCommitments + vlen := uint64(len(t)) + if vlen > expr14 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr14), "Block.Body.BlobKZGCommitments") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + hh.PutBytes(t[idx1][:48]) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr14, vlen, 32)) + } + { // Field #12 'ExecutionRequests' + t := t.ExecutionRequests + if t == nil { + t = new(all.ExecutionRequests) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Deposits' + t := t.Deposits + vlen := uint64(len(t)) + if vlen > expr15 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr15), "Block.Body.ExecutionRequests.Deposits") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(electra1.DepositRequest) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "Block.Body.ExecutionRequests.Deposits[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr15, vlen, 32)) + } + { // Field #1 'Withdrawals' + t := t.Withdrawals + vlen := uint64(len(t)) + if vlen > expr16 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr16), "Block.Body.ExecutionRequests.Withdrawals") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(electra1.WithdrawalRequest) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "Block.Body.ExecutionRequests.Withdrawals[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr16, vlen, 32)) + } + { // Field #2 'Consolidations' + t := t.Consolidations + vlen := uint64(len(t)) + if vlen > expr17 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr17), "Block.Body.ExecutionRequests.Consolidations") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(electra1.ConsolidationRequest) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "Block.Body.ExecutionRequests.Consolidations[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr17, vlen, 32)) + } + hh.Merkleize(idx) + } + hh.Merkleize(idx) + } + hh.Merkleize(idx) + } + { // Field #1 'KZGProofs' + t := t.KZGProofs + vlen := uint64(len(t)) + if vlen > 33554432 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 33554432), "KZGProofs") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + hh.PutBytes(t[idx1][:48]) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(33554432, vlen, 32)) + } + { // Field #2 'Blobs' + t := t.Blobs + vlen := uint64(len(t)) + if vlen > 4096 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 4096), "Blobs") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + hh.PutBytes(t[idx1][:131072]) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(4096, vlen, 32)) + } + hh.Merkleize(idx) + return nil +} diff --git a/api/v1/all/blockcontents_test.go b/api/v1/all/blockcontents_test.go new file mode 100644 index 00000000..8e8de66a --- /dev/null +++ b/api/v1/all/blockcontents_test.go @@ -0,0 +1,227 @@ +// Copyright © 2026 Attestant Limited. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package all_test + +import ( + "encoding/json" + "testing" + + apiv1all "github.com/ethpandaops/go-eth2-client/api/v1/all" + apiv1deneb "github.com/ethpandaops/go-eth2-client/api/v1/deneb" + apiv1electra "github.com/ethpandaops/go-eth2-client/api/v1/electra" + apiv1fulu "github.com/ethpandaops/go-eth2-client/api/v1/fulu" + "github.com/ethpandaops/go-eth2-client/spec/version" + "github.com/stretchr/testify/require" +) + +// blockContentsTests enumerates the per-fork views the agnostic BlockContents +// must be wire-compatible with. +func blockContentsTests() []struct { + name string + version version.DataVersion + view any +} { + return []struct { + name string + version version.DataVersion + view any + }{ + { + name: "Deneb", + version: version.DataVersionDeneb, + view: &apiv1deneb.BlockContents{ + Block: testDenebSignedBeaconBlock().Message, + KZGProofs: testKZGProofs(), + Blobs: testBlobs(), + }, + }, + { + name: "Electra", + version: version.DataVersionElectra, + view: &apiv1electra.BlockContents{ + Block: testElectraSignedBeaconBlock().Message, + KZGProofs: testKZGProofs(), + Blobs: testBlobs(), + }, + }, + { + name: "Fulu", + version: version.DataVersionFulu, + view: &apiv1fulu.BlockContents{ + Block: testElectraSignedBeaconBlock().Message, + KZGProofs: testKZGProofs(), + Blobs: testBlobs(), + }, + }, + } +} + +// TestBlockContentsJSONWireCompat verifies that the agnostic type marshals to +// byte-identical JSON versus the per-fork type, and that JSON round-trips +// losslessly through the agnostic type. +func TestBlockContentsJSONWireCompat(t *testing.T) { + for _, test := range blockContentsTests() { + t.Run(test.name, func(t *testing.T) { + expected, err := json.Marshal(test.view) + require.NoError(t, err) + + agnostic := &apiv1all.BlockContents{} + require.NoError(t, agnostic.FromView(test.view)) + require.Equal(t, test.version, agnostic.Version) + + got, err := json.Marshal(agnostic) + require.NoError(t, err) + require.Equal(t, string(expected), string(got), + "agnostic JSON differs from per-fork JSON") + + // Round-trip through UnmarshalJSON with Version pre-set. + rt := &apiv1all.BlockContents{Version: test.version} + require.NoError(t, json.Unmarshal(expected, rt)) + + rtJSON, err := json.Marshal(rt) + require.NoError(t, err) + require.Equal(t, string(expected), string(rtJSON), + "round-tripped JSON differs from per-fork JSON") + + // Version must propagate to nested versionable children. + require.NotNil(t, rt.Block) + require.Equal(t, test.version, rt.Block.Version) + require.NotNil(t, rt.Block.Body) + require.Equal(t, test.version, rt.Block.Body.Version) + }) + } +} + +// TestBlockContentsSSZWireCompat verifies that the agnostic type produces +// byte-identical SSZ and the same hash tree root as the per-fork type, and +// that SSZ round-trips losslessly through the agnostic type. +func TestBlockContentsSSZWireCompat(t *testing.T) { + for _, test := range blockContentsTests() { + t.Run(test.name, func(t *testing.T) { + codec, ok := test.view.(sszCodec) + require.True(t, ok) + + expected, err := codec.MarshalSSZ() + require.NoError(t, err) + + agnostic := &apiv1all.BlockContents{} + require.NoError(t, agnostic.FromView(test.view)) + + got, err := agnostic.MarshalSSZ() + require.NoError(t, err) + require.Equal(t, expected, got, "agnostic SSZ differs from per-fork SSZ") + + expectedRoot, err := codec.HashTreeRoot() + require.NoError(t, err) + + gotRoot, err := agnostic.HashTreeRoot() + require.NoError(t, err) + require.Equal(t, expectedRoot, gotRoot, + "agnostic hash tree root differs from per-fork root") + + // Round-trip through UnmarshalSSZ with Version pre-set. + rt := &apiv1all.BlockContents{Version: test.version} + require.NoError(t, rt.UnmarshalSSZ(expected)) + + rtSSZ, err := rt.MarshalSSZ() + require.NoError(t, err) + require.Equal(t, expected, rtSSZ, + "round-tripped SSZ differs from per-fork SSZ") + + // Version must propagate to nested versionable children. + require.NotNil(t, rt.Block) + require.Equal(t, test.version, rt.Block.Version) + }) + } +} + +// TestBlockContentsViewRoundtrip verifies ToView reproduces the per-fork view +// the agnostic instance was built from. +func TestBlockContentsViewRoundtrip(t *testing.T) { + for _, test := range blockContentsTests() { + t.Run(test.name, func(t *testing.T) { + agnostic := &apiv1all.BlockContents{} + require.NoError(t, agnostic.FromView(test.view)) + + view, err := agnostic.ToView() + require.NoError(t, err) + require.IsType(t, test.view, view) + require.Equal(t, test.view, view) + }) + } +} + +// TestBlockContentsToVersioned verifies conversion to and from +// api.VersionedProposal: exactly the plain (unblinded) per-fork field is +// populated with the exact view, and the Blinded flag and blinded fields +// stay untouched. +func TestBlockContentsToVersioned(t *testing.T) { + for _, test := range blockContentsTests() { + t.Run(test.name, func(t *testing.T) { + agnostic := &apiv1all.BlockContents{} + require.NoError(t, agnostic.FromView(test.view)) + + versioned, err := agnostic.ToVersioned() + require.NoError(t, err) + require.Equal(t, test.version, versioned.Version) + require.False(t, versioned.Blinded, "unblinded contents must not set the Blinded flag") + + var fieldView any + + switch test.version { + case version.DataVersionDeneb: + fieldView = versioned.Deneb + require.Nil(t, versioned.DenebBlinded) + case version.DataVersionElectra: + fieldView = versioned.Electra + require.Nil(t, versioned.ElectraBlinded) + case version.DataVersionFulu: + fieldView = versioned.Fulu + require.Nil(t, versioned.FuluBlinded) + default: + t.Fatalf("unexpected version %v", test.version) + } + + require.IsType(t, test.view, fieldView) + require.Equal(t, test.view, fieldView) + + rt := &apiv1all.BlockContents{} + require.NoError(t, rt.FromVersioned(versioned)) + require.Equal(t, test.version, rt.Version) + require.Equal(t, agnostic, rt) + }) + } +} + +// TestBlockContentsUnsupportedVersion verifies unsupported versions are +// rejected with a clear error. +func TestBlockContentsUnsupportedVersion(t *testing.T) { + for _, v := range []version.DataVersion{ + version.DataVersionUnknown, + version.DataVersionPhase0, + version.DataVersionCapella, + version.DataVersionGloas, + } { + b := &apiv1all.BlockContents{Version: v} + + _, err := b.ToView() + require.ErrorContains(t, err, "unsupported version") + + _, err = json.Marshal(b) + require.ErrorContains(t, err, "unsupported version") + + _, err = b.MarshalSSZ() + require.ErrorContains(t, err, "unsupported version") + } +} diff --git a/api/v1/all/generate.go b/api/v1/all/generate.go new file mode 100644 index 00000000..66e14949 --- /dev/null +++ b/api/v1/all/generate.go @@ -0,0 +1,17 @@ +// Copyright © 2026 Attestant Limited. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package all + +//go:generate rm -f *_ssz.go +//go:generate go tool dynssz-gen -config generate.yaml diff --git a/api/v1/all/generate.yaml b/api/v1/all/generate.yaml new file mode 100644 index 00000000..fb1b3386 --- /dev/null +++ b/api/v1/all/generate.yaml @@ -0,0 +1,51 @@ +package: . + +types: + - name: BlindedBeaconBlockBody + output: blindedbeaconblockbody_ssz.go + view-only: true + views: + - ../bellatrix.BlindedBeaconBlockBody + - ../capella.BlindedBeaconBlockBody + - ../deneb.BlindedBeaconBlockBody + - ../electra.BlindedBeaconBlockBody + + - name: BlindedBeaconBlock + output: blindedbeaconblock_ssz.go + view-only: true + views: + - ../bellatrix.BlindedBeaconBlock + - ../capella.BlindedBeaconBlock + - ../deneb.BlindedBeaconBlock + - ../electra.BlindedBeaconBlock + + - name: SignedBlindedBeaconBlock + output: signedblindedbeaconblock_ssz.go + view-only: true + views: + - ../bellatrix.SignedBlindedBeaconBlock + - ../capella.SignedBlindedBeaconBlock + - ../deneb.SignedBlindedBeaconBlock + - ../electra.SignedBlindedBeaconBlock + + - name: BlockContents + output: blockcontents_ssz.go + view-only: true + views: + - ../deneb.BlockContents + - ../electra.BlockContents + - ../fulu.BlockContents + + - name: SignedBlockContents + output: signedblockcontents_ssz.go + view-only: true + views: + - ../deneb.SignedBlockContents + - ../electra.SignedBlockContents + - ../fulu.SignedBlockContents + + - name: SignedExecutionPayloadEnvelopeContents + output: signedexecutionpayloadenvelopecontents_ssz.go + view-only: true + views: + - ../gloas.SignedExecutionPayloadEnvelopeContents diff --git a/api/v1/all/jsonyaml.go b/api/v1/all/jsonyaml.go new file mode 100644 index 00000000..d84238f5 --- /dev/null +++ b/api/v1/all/jsonyaml.go @@ -0,0 +1,425 @@ +// Copyright © 2026 Attestant Limited. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package all + +import ( + "encoding/json" + "errors" + "fmt" + "reflect" + + "github.com/ethpandaops/go-eth2-client/spec/version" + "github.com/goccy/go-yaml" +) + +// viewProvider is implemented by fork-agnostic union types that can map their +// active Version to a fork-specific schema type via viewType(). +type viewProvider interface { + viewType() (any, error) +} + +// viewer is implemented by every fork-agnostic union type's ToView method. +type viewer interface { + ToView() (any, error) +} + +// fromViewer is implemented by every fork-agnostic union type's FromView method. +type fromViewer interface { + FromView(view any) error +} + +// versionSetter is implemented by every fork-agnostic union type's +// populateVersion method. fromVersioned uses it to pin the Version (taken +// from the Versioned* struct's authoritative Version field) before FromView +// runs — otherwise FromView's per-view-type inference loses precision when +// multiple versions share a single view. +type versionSetter interface { + populateVersion(v version.DataVersion) +} + +// versionFieldName maps a DataVersion to the per-fork field name on a +// Versioned* struct (e.g. *api.VersionedSignedProposal). +func versionFieldName(v version.DataVersion) (string, error) { + switch v { + case version.DataVersionPhase0: + return "Phase0", nil + case version.DataVersionAltair: + return "Altair", nil + case version.DataVersionBellatrix: + return "Bellatrix", nil + case version.DataVersionCapella: + return "Capella", nil + case version.DataVersionDeneb: + return "Deneb", nil + case version.DataVersionElectra: + return "Electra", nil + case version.DataVersionFulu: + return "Fulu", nil + case version.DataVersionGloas: + return "Gloas", nil + case version.DataVersionHeze: + return "Heze", nil + default: + return "", fmt.Errorf("unsupported version %d", v) + } +} + +// toVersioned populates a Versioned* struct from a fork-agnostic source. +// It calls src.ToView to produce the fork-specific view and stores it in the +// dst field whose name matches srcVersion (Phase0, Altair, …, Heze). The +// Version field on dst is also set. +// +// dst must be a non-nil pointer to a struct shaped like the api package's +// Versioned* types: a Version field plus per-fork pointer fields. +func toVersioned(srcVersion version.DataVersion, src viewer, dst any) error { + view, err := src.ToView() + if err != nil { + return err + } + + dv := reflect.ValueOf(dst) + if dv.Kind() != reflect.Pointer || dv.IsNil() { + return errors.New("toVersioned: dst must be a non-nil pointer") + } + + dv = dv.Elem() + + versionField := dv.FieldByName("Version") + if !versionField.IsValid() { + return fmt.Errorf("toVersioned: %T has no Version field", dst) + } + + versionField.Set(reflect.ValueOf(srcVersion)) + + fieldName, err := versionFieldName(srcVersion) + if err != nil { + return fmt.Errorf("toVersioned: %w", err) + } + + f := dv.FieldByName(fieldName) + if !f.IsValid() { + return fmt.Errorf("toVersioned: %T has no %s field", dst, fieldName) + } + + rv := reflect.ValueOf(view) + if !rv.Type().AssignableTo(f.Type()) { + return fmt.Errorf("toVersioned: view type %T not assignable to %s field of type %s", + view, fieldName, f.Type()) + } + + f.Set(rv) + + return nil +} + +// fromVersioned populates a fork-agnostic destination from a Versioned* +// struct by extracting the field matching src.Version and feeding it to +// dst.FromView. +// +// src must be a non-nil pointer to a struct shaped like the api package's +// Versioned* types. +func fromVersioned(dst fromViewer, src any) error { + sv := reflect.ValueOf(src) + if sv.Kind() != reflect.Pointer || sv.IsNil() { + return errors.New("fromVersioned: src must be a non-nil pointer") + } + + sv = sv.Elem() + + versionField := sv.FieldByName("Version") + if !versionField.IsValid() { + return fmt.Errorf("fromVersioned: %T has no Version field", src) + } + + v, ok := versionField.Interface().(version.DataVersion) + if !ok { + return fmt.Errorf("fromVersioned: Version field on %T is %T not version.DataVersion", + src, versionField.Interface()) + } + + fieldName, err := versionFieldName(v) + if err != nil { + return fmt.Errorf("fromVersioned: %w", err) + } + + f := sv.FieldByName(fieldName) + if !f.IsValid() { + return fmt.Errorf("fromVersioned: %T has no %s field", src, fieldName) + } + + if f.Kind() == reflect.Pointer && f.IsNil() { + return fmt.Errorf("fromVersioned: %T.%s is nil for Version=%s", src, fieldName, v) + } + + // Pin the authoritative Version on dst before FromView, so FromView's + // type-switch inference doesn't downgrade it when multiple versions + // share a single view. + if vs, ok := dst.(versionSetter); ok { + vs.populateVersion(v) + } + + return dst.FromView(f.Interface()) +} + +// toViewByCopy is the generic implementation of ToView shared by every +// fork-agnostic union type. It allocates a fresh fork-specific instance for +// the active Version and field-copies src into it via copyByName. copyByName +// recursively handles nested struct pointers and slices, so all fork-specific +// children — including nested fork-agnostic types via their own field +// structure — are populated transparently. +func toViewByCopy(src viewProvider) (any, error) { + inst, err := newViewInstance(src) + if err != nil { + return nil, err + } + + if err := copyByName(src, inst); err != nil { + return nil, err + } + + return inst, nil +} + +// marshalAsView delegates JSON marshaling to the per-fork type that matches +// src.Version. It allocates a fresh fork-specific instance, copies matching +// fields from src into it via copyByName, and lets json.Marshal route through +// the per-fork type's MarshalJSON. +func marshalAsView(src viewProvider) ([]byte, error) { + inst, err := newViewInstance(src) + if err != nil { + return nil, err + } + + if err := copyByName(src, inst); err != nil { + return nil, err + } + + return json.Marshal(inst) +} + +// unmarshalAsView delegates JSON unmarshaling to the per-fork type matching +// dst.Version, then copies the populated view back into dst. The caller is +// responsible for invoking populateVersion afterwards to seed the version on +// any nested versionable children that copyByName allocated. +func unmarshalAsView(dst viewProvider, data []byte) error { + inst, err := newViewInstance(dst) + if err != nil { + return err + } + + if err := json.Unmarshal(data, inst); err != nil { + return err + } + + return copyByName(inst, dst) +} + +// marshalAsViewYAML mirrors marshalAsView for YAML. +func marshalAsViewYAML(src viewProvider) ([]byte, error) { + inst, err := newViewInstance(src) + if err != nil { + return nil, err + } + + if err := copyByName(src, inst); err != nil { + return nil, err + } + + return yaml.Marshal(inst) +} + +// unmarshalAsViewYAML mirrors unmarshalAsView for YAML. +func unmarshalAsViewYAML(dst viewProvider, data []byte) error { + inst, err := newViewInstance(dst) + if err != nil { + return err + } + + if err := yaml.Unmarshal(data, inst); err != nil { + return err + } + + return copyByName(inst, dst) +} + +// newViewInstance allocates a fresh instance of the fork-specific schema type +// indicated by p.viewType(). +func newViewInstance(p viewProvider) (any, error) { + view, err := p.viewType() + if err != nil { + return nil, err + } + + return reflect.New(reflect.TypeOf(view).Elem()).Interface(), nil +} + +// copyByName copies fields from src to dst by matching field names. Both +// arguments must be pointers to structs. For directly-assignable types +// (same Go type on both sides) the field is assigned. For pointer or slice +// fields where src/dst element types differ — *all.SignedBeaconBlock / +// *deneb.SignedBeaconBlock, slices of those, etc. — copyByName recursively +// allocates and copies. Fields present on src but missing on dst (e.g. +// Version when dst is per-fork) are silently skipped. +func copyByName(src, dst any) error { + sv := reflect.ValueOf(src) + dv := reflect.ValueOf(dst) + + if sv.Kind() == reflect.Pointer { + if sv.IsNil() { + return nil + } + + sv = sv.Elem() + } + + if dv.Kind() == reflect.Pointer { + if dv.IsNil() { + return errors.New("copyByName: destination is a nil pointer") + } + + dv = dv.Elem() + } + + if sv.Kind() != reflect.Struct || dv.Kind() != reflect.Struct { + return fmt.Errorf("copyByName: src kind=%s, dst kind=%s; both must be structs", sv.Kind(), dv.Kind()) + } + + for i := range dv.NumField() { + df := dv.Type().Field(i) + if !df.IsExported() { + continue + } + + sf := sv.FieldByName(df.Name) + if !sf.IsValid() { + continue + } + + if err := copyValue(sf, dv.Field(i)); err != nil { + return fmt.Errorf("field %s: %w", df.Name, err) + } + } + + return nil +} + +// copyValue copies a single field value, recursing into nested struct +// pointers and slices when types differ. Direct assignment is preferred +// when src.Type() is assignable to dst.Type(). +func copyValue(src, dst reflect.Value) error { + if src.Type().AssignableTo(dst.Type()) { + dst.Set(src) + + return nil + } + + switch src.Kind() { + case reflect.Pointer: + if dst.Kind() != reflect.Pointer { + return fmt.Errorf("incompatible kinds %s -> %s", src.Kind(), dst.Kind()) + } + + if src.IsNil() { + dst.Set(reflect.Zero(dst.Type())) + + return nil + } + + newDst := reflect.New(dst.Type().Elem()) + if err := copyByName(src.Interface(), newDst.Interface()); err != nil { + return err + } + + dst.Set(newDst) + + return nil + case reflect.Slice: + if dst.Kind() != reflect.Slice { + return fmt.Errorf("incompatible kinds %s -> %s", src.Kind(), dst.Kind()) + } + + if src.IsNil() { + dst.Set(reflect.Zero(dst.Type())) + + return nil + } + + n := src.Len() + newDst := reflect.MakeSlice(dst.Type(), n, n) + + for i := range n { + if err := copyValue(src.Index(i), newDst.Index(i)); err != nil { + return err + } + } + + dst.Set(newDst) + + return nil + default: + return fmt.Errorf("cannot copy %s to %s", src.Type(), dst.Type()) + } +} + +// dataVersionType is the reflect.Type of version.DataVersion, used by +// propagateVersion to identify Version fields on nested versionable children. +var dataVersionType = reflect.TypeFor[version.DataVersion]() + +// propagateVersion seeds the Version field on every fork-agnostic struct +// reachable from root (a pointer to a struct). It mirrors the spec/all +// package's populateVersion cascade, which is unexported and therefore not +// callable from this package: any exported struct field named Version of +// type version.DataVersion is set to v, recursing through pointers, structs, +// and slices of structs or pointers. +func propagateVersion(root any, v version.DataVersion) { + propagateVersionValue(reflect.ValueOf(root), v) +} + +// propagateVersionValue is the recursive worker for propagateVersion. +func propagateVersionValue(val reflect.Value, v version.DataVersion) { + switch val.Kind() { + case reflect.Pointer: + if !val.IsNil() { + propagateVersionValue(val.Elem(), v) + } + case reflect.Struct: + t := val.Type() + for i := range val.NumField() { + f := t.Field(i) + if !f.IsExported() { + continue + } + + fv := val.Field(i) + if f.Name == "Version" && f.Type == dataVersionType { + fv.Set(reflect.ValueOf(v)) + + continue + } + + propagateVersionValue(fv, v) + } + case reflect.Slice: + // Only element kinds that can contain nested structs are walked; + // byte slices, hashes, blobs etc. are skipped. + switch val.Type().Elem().Kind() { + case reflect.Pointer, reflect.Struct: + for i := range val.Len() { + propagateVersionValue(val.Index(i), v) + } + default: + } + default: + } +} diff --git a/api/v1/all/signedblindedbeaconblock.go b/api/v1/all/signedblindedbeaconblock.go new file mode 100644 index 00000000..4974cab0 --- /dev/null +++ b/api/v1/all/signedblindedbeaconblock.go @@ -0,0 +1,279 @@ +// Copyright © 2026 Attestant Limited. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package all + +import ( + "errors" + "fmt" + + "github.com/ethpandaops/go-eth2-client/api" + apiv1bellatrix "github.com/ethpandaops/go-eth2-client/api/v1/bellatrix" + apiv1capella "github.com/ethpandaops/go-eth2-client/api/v1/capella" + apiv1deneb "github.com/ethpandaops/go-eth2-client/api/v1/deneb" + apiv1electra "github.com/ethpandaops/go-eth2-client/api/v1/electra" + "github.com/ethpandaops/go-eth2-client/spec/phase0" + "github.com/ethpandaops/go-eth2-client/spec/version" + dynssz "github.com/pk910/dynamic-ssz" + "github.com/pk910/dynamic-ssz/sszutils" +) + +// SignedBlindedBeaconBlock is a fork-agnostic signed blinded beacon block. +// Blinded blocks exist as a wire type from Bellatrix up to (excluding) +// Gloas; other forks are not supported by this type. +type SignedBlindedBeaconBlock struct { + Version version.DataVersion + Message *BlindedBeaconBlock + Signature phase0.BLSSignature +} + +// viewType returns the fork-specific schema type pointer used as the view +// descriptor for the active Version. +func (s *SignedBlindedBeaconBlock) viewType() (any, error) { + switch s.Version { + case version.DataVersionBellatrix: + return (*apiv1bellatrix.SignedBlindedBeaconBlock)(nil), nil + case version.DataVersionCapella: + return (*apiv1capella.SignedBlindedBeaconBlock)(nil), nil + case version.DataVersionDeneb: + return (*apiv1deneb.SignedBlindedBeaconBlock)(nil), nil + case version.DataVersionElectra, + version.DataVersionFulu: + // Fulu reuses the Electra signed blinded block schema unchanged. + return (*apiv1electra.SignedBlindedBeaconBlock)(nil), nil + default: + return nil, fmt.Errorf("SignedBlindedBeaconBlock: unsupported version %d", s.Version) + } +} + +// MarshalSSZDyn marshals the signed blinded block using the view that +// matches Version. +func (s *SignedBlindedBeaconBlock) MarshalSSZDyn(ds sszutils.DynamicSpecs, buf []byte) ([]byte, error) { + view, err := s.viewType() + if err != nil { + return nil, err + } + + m, ok := any(s).(sszutils.DynamicViewMarshaler) + if !ok { + return nil, errors.New("SignedBlindedBeaconBlock: generated SSZ code missing") + } + + fn := m.MarshalSSZDynView(view) + if fn == nil { + return nil, fmt.Errorf("SignedBlindedBeaconBlock: no view marshaler for version %d", s.Version) + } + + return fn(ds, buf) +} + +// SizeSSZDyn returns the SSZ size of the signed blinded block for the +// active Version. +func (s *SignedBlindedBeaconBlock) SizeSSZDyn(ds sszutils.DynamicSpecs) int { + view, err := s.viewType() + if err != nil { + return 0 + } + + sz, ok := any(s).(sszutils.DynamicViewSizer) + if !ok { + return 0 + } + + fn := sz.SizeSSZDynView(view) + if fn == nil { + return 0 + } + + return fn(ds) +} + +// UnmarshalSSZDyn decodes the signed blinded block into the view that +// matches Version. +func (s *SignedBlindedBeaconBlock) UnmarshalSSZDyn(ds sszutils.DynamicSpecs, buf []byte) error { + view, err := s.viewType() + if err != nil { + return err + } + + u, ok := any(s).(sszutils.DynamicViewUnmarshaler) + if !ok { + return errors.New("SignedBlindedBeaconBlock: generated SSZ code missing") + } + + fn := u.UnmarshalSSZDynView(view) + if fn == nil { + return fmt.Errorf("SignedBlindedBeaconBlock: no view unmarshaler for version %d", s.Version) + } + + if err := fn(ds, buf); err != nil { + return err + } + + s.populateVersion(s.Version) + + return nil +} + +// populateVersion sets Version and propagates it to any nested versionable +// children. +func (s *SignedBlindedBeaconBlock) populateVersion(v version.DataVersion) { + propagateVersion(s, v) +} + +// ToView returns a fresh fork-specific SignedBlindedBeaconBlock populated +// with s's fields, recursing into Message via copyByName. +func (s *SignedBlindedBeaconBlock) ToView() (any, error) { + return toViewByCopy(s) +} + +// FromView populates s from a fork-specific SignedBlindedBeaconBlock. +func (s *SignedBlindedBeaconBlock) FromView(view any) error { + v, err := signedBlindedBeaconBlockVersion(view) + if err != nil { + return err + } + + if s.Version == version.DataVersionUnknown { + s.Version = v + } + + if err := copyByName(view, s); err != nil { + return err + } + + s.populateVersion(s.Version) + + return nil +} + +// signedBlindedBeaconBlockVersion maps a SignedBlindedBeaconBlock view type +// to its DataVersion. +func signedBlindedBeaconBlockVersion(view any) (version.DataVersion, error) { + switch view.(type) { + case *apiv1bellatrix.SignedBlindedBeaconBlock: + return version.DataVersionBellatrix, nil + case *apiv1capella.SignedBlindedBeaconBlock: + return version.DataVersionCapella, nil + case *apiv1deneb.SignedBlindedBeaconBlock: + return version.DataVersionDeneb, nil + case *apiv1electra.SignedBlindedBeaconBlock: + return version.DataVersionElectra, nil + default: + return version.DataVersionUnknown, fmt.Errorf("SignedBlindedBeaconBlock: unsupported view type %T", view) + } +} + +// HashTreeRootWithDyn computes the SSZ hash tree root using the active +// Version's view. +func (s *SignedBlindedBeaconBlock) HashTreeRootWithDyn(ds sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + view, err := s.viewType() + if err != nil { + return err + } + + h, ok := any(s).(sszutils.DynamicViewHashRoot) + if !ok { + return errors.New("SignedBlindedBeaconBlock: generated SSZ code missing") + } + + fn := h.HashTreeRootWithDynView(view) + if fn == nil { + return fmt.Errorf("SignedBlindedBeaconBlock: no view hasher for version %d", s.Version) + } + + return fn(ds, hh) +} + +// MarshalSSZ implements the fastssz.Marshaler interface. +func (s *SignedBlindedBeaconBlock) MarshalSSZ() ([]byte, error) { + ds := dynssz.GetGlobalDynSsz() + + return s.MarshalSSZDyn(ds, make([]byte, 0, s.SizeSSZDyn(ds))) +} + +// MarshalSSZTo implements the fastssz.Marshaler interface. +func (s *SignedBlindedBeaconBlock) MarshalSSZTo(dst []byte) ([]byte, error) { + return s.MarshalSSZDyn(dynssz.GetGlobalDynSsz(), dst) +} + +// UnmarshalSSZ implements the fastssz.Unmarshaler interface. +func (s *SignedBlindedBeaconBlock) UnmarshalSSZ(buf []byte) error { + return s.UnmarshalSSZDyn(dynssz.GetGlobalDynSsz(), buf) +} + +// SizeSSZ implements the fastssz.Marshaler interface. +func (s *SignedBlindedBeaconBlock) SizeSSZ() int { + return s.SizeSSZDyn(dynssz.GetGlobalDynSsz()) +} + +// HashTreeRoot implements the fastssz.HashRoot interface. +func (s *SignedBlindedBeaconBlock) HashTreeRoot() ([32]byte, error) { + return dynssz.GetGlobalDynSsz().HashTreeRoot(s) +} + +// HashTreeRootWith implements the fastssz.HashRoot interface. +func (s *SignedBlindedBeaconBlock) HashTreeRootWith(hh sszutils.HashWalker) error { + return s.HashTreeRootWithDyn(dynssz.GetGlobalDynSsz(), hh) +} + +// ToVersioned converts s into a *api.VersionedSignedBlindedBeaconBlock. +func (s *SignedBlindedBeaconBlock) ToVersioned() (*api.VersionedSignedBlindedBeaconBlock, error) { + out := &api.VersionedSignedBlindedBeaconBlock{} + if err := toVersioned(s.Version, s, out); err != nil { + return nil, err + } + + return out, nil +} + +// FromVersioned populates s from src. +func (s *SignedBlindedBeaconBlock) FromVersioned(src *api.VersionedSignedBlindedBeaconBlock) error { + return fromVersioned(s, src) +} + +// MarshalJSON delegates to the per-fork SignedBlindedBeaconBlock that +// matches Version. +func (s *SignedBlindedBeaconBlock) MarshalJSON() ([]byte, error) { + return marshalAsView(s) +} + +// UnmarshalJSON delegates to the per-fork SignedBlindedBeaconBlock that +// matches Version. Caller must set Version before calling. +func (s *SignedBlindedBeaconBlock) UnmarshalJSON(data []byte) error { + if err := unmarshalAsView(s, data); err != nil { + return err + } + + s.populateVersion(s.Version) + + return nil +} + +// MarshalYAML delegates to the per-fork SignedBlindedBeaconBlock that +// matches Version. +func (s *SignedBlindedBeaconBlock) MarshalYAML() ([]byte, error) { + return marshalAsViewYAML(s) +} + +// UnmarshalYAML delegates to the per-fork SignedBlindedBeaconBlock that +// matches Version. Caller must set Version before calling. +func (s *SignedBlindedBeaconBlock) UnmarshalYAML(data []byte) error { + if err := unmarshalAsViewYAML(s, data); err != nil { + return err + } + + s.populateVersion(s.Version) + + return nil +} diff --git a/api/v1/all/signedblindedbeaconblock_ssz.go b/api/v1/all/signedblindedbeaconblock_ssz.go new file mode 100644 index 00000000..aa0edda2 --- /dev/null +++ b/api/v1/all/signedblindedbeaconblock_ssz.go @@ -0,0 +1,465 @@ +// Code generated by dynamic-ssz. DO NOT EDIT. +// Hash: d2870f53372fbb16fffebe66aeb3a2a0ba0bf8cbe60ae6ccfc832c925f98b73f +// Version: v1.3.2 (https://github.com/pk910/dynamic-ssz) +package all + +import ( + "encoding/binary" + + "github.com/ethpandaops/go-eth2-client/api/v1/bellatrix" + "github.com/ethpandaops/go-eth2-client/api/v1/capella" + "github.com/ethpandaops/go-eth2-client/api/v1/deneb" + "github.com/ethpandaops/go-eth2-client/api/v1/electra" + "github.com/pk910/dynamic-ssz/sszutils" +) + +var _ = sszutils.ErrListTooBig + +var _ = sszutils.Annotate[*bellatrix.SignedBlindedBeaconBlock](`ssz-static:"false"`) +var _ = sszutils.Annotate[*capella.SignedBlindedBeaconBlock](`ssz-static:"false"`) +var _ = sszutils.Annotate[*deneb.SignedBlindedBeaconBlock](`ssz-static:"false"`) +var _ = sszutils.Annotate[*electra.SignedBlindedBeaconBlock](`ssz-static:"false"`) + +func (t *SignedBlindedBeaconBlock) MarshalSSZDynView(view any) func(ds sszutils.DynamicSpecs, buf []byte) ([]byte, error) { + switch view.(type) { + case *bellatrix.SignedBlindedBeaconBlock: + return t.marshalSSZView_SignedBlindedBeaconBlock + case *capella.SignedBlindedBeaconBlock: + return t.marshalSSZView_SignedBlindedBeaconBlock_0 + case *deneb.SignedBlindedBeaconBlock: + return t.marshalSSZView_SignedBlindedBeaconBlock_1 + case *electra.SignedBlindedBeaconBlock: + return t.marshalSSZView_SignedBlindedBeaconBlock_2 + } + return nil +} +func (t *SignedBlindedBeaconBlock) marshalSSZView_SignedBlindedBeaconBlock(ds sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + dst = buf + if t == nil { + t = new(SignedBlindedBeaconBlock) + } + dstlen := len(dst) + // Offset Field #0 'Message' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #1 'Signature' + dst = append(dst, t.Signature[:96]...) + } + { // Dynamic Field #0 'Message' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.Message + if t == nil { + t = new(BlindedBeaconBlock) + } + if viewFn := t.MarshalSSZDynView((*bellatrix.BlindedBeaconBlock)(nil)); viewFn != nil { + if dst, err = viewFn(ds, dst); err != nil { + return nil, err + } + } else { + return nil, sszutils.ErrNotImplemented + } + } + return dst, nil +} + +func (t *SignedBlindedBeaconBlock) marshalSSZView_SignedBlindedBeaconBlock_0(ds sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + dst = buf + if t == nil { + t = new(SignedBlindedBeaconBlock) + } + dstlen := len(dst) + // Offset Field #0 'Message' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #1 'Signature' + dst = append(dst, t.Signature[:96]...) + } + { // Dynamic Field #0 'Message' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.Message + if t == nil { + t = new(BlindedBeaconBlock) + } + if viewFn := t.MarshalSSZDynView((*capella.BlindedBeaconBlock)(nil)); viewFn != nil { + if dst, err = viewFn(ds, dst); err != nil { + return nil, err + } + } else { + return nil, sszutils.ErrNotImplemented + } + } + return dst, nil +} + +func (t *SignedBlindedBeaconBlock) marshalSSZView_SignedBlindedBeaconBlock_1(ds sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + dst = buf + if t == nil { + t = new(SignedBlindedBeaconBlock) + } + dstlen := len(dst) + // Offset Field #0 'Message' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #1 'Signature' + dst = append(dst, t.Signature[:96]...) + } + { // Dynamic Field #0 'Message' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.Message + if t == nil { + t = new(BlindedBeaconBlock) + } + if viewFn := t.MarshalSSZDynView((*deneb.BlindedBeaconBlock)(nil)); viewFn != nil { + if dst, err = viewFn(ds, dst); err != nil { + return nil, err + } + } else { + return nil, sszutils.ErrNotImplemented + } + } + return dst, nil +} + +func (t *SignedBlindedBeaconBlock) marshalSSZView_SignedBlindedBeaconBlock_2(ds sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + dst = buf + if t == nil { + t = new(SignedBlindedBeaconBlock) + } + dstlen := len(dst) + // Offset Field #0 'Message' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #1 'Signature' + dst = append(dst, t.Signature[:96]...) + } + { // Dynamic Field #0 'Message' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.Message + if t == nil { + t = new(BlindedBeaconBlock) + } + if viewFn := t.MarshalSSZDynView((*electra.BlindedBeaconBlock)(nil)); viewFn != nil { + if dst, err = viewFn(ds, dst); err != nil { + return nil, err + } + } else { + return nil, sszutils.ErrNotImplemented + } + } + return dst, nil +} + +func (t *SignedBlindedBeaconBlock) UnmarshalSSZDynView(view any) func(ds sszutils.DynamicSpecs, buf []byte) error { + switch view.(type) { + case *bellatrix.SignedBlindedBeaconBlock: + return t.unmarshalSSZView_SignedBlindedBeaconBlock + case *capella.SignedBlindedBeaconBlock: + return t.unmarshalSSZView_SignedBlindedBeaconBlock_0 + case *deneb.SignedBlindedBeaconBlock: + return t.unmarshalSSZView_SignedBlindedBeaconBlock_1 + case *electra.SignedBlindedBeaconBlock: + return t.unmarshalSSZView_SignedBlindedBeaconBlock_2 + } + return nil +} +func (t *SignedBlindedBeaconBlock) unmarshalSSZView_SignedBlindedBeaconBlock(ds sszutils.DynamicSpecs, buf []byte) (err error) { + buflen := len(buf) + if buflen < 100 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 100) + } + // Field #0 'Message' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 100 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset0, 100), "Message:o") + } + { // Field #1 'Signature' (static) + buf := buf[4:100] + copy(t.Signature[:], buf) + } + { // Field #0 'Message' (dynamic) + buf := buf[offset0:] + if t.Message == nil { + t.Message = new(BlindedBeaconBlock) + } + if viewFn := t.Message.UnmarshalSSZDynView((*bellatrix.BlindedBeaconBlock)(nil)); viewFn != nil { + if err = viewFn(ds, buf); err != nil { + return err + } + } else { + return sszutils.ErrNotImplemented + } + } + return nil +} + +func (t *SignedBlindedBeaconBlock) unmarshalSSZView_SignedBlindedBeaconBlock_0(ds sszutils.DynamicSpecs, buf []byte) (err error) { + buflen := len(buf) + if buflen < 100 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 100) + } + // Field #0 'Message' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 100 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset0, 100), "Message:o") + } + { // Field #1 'Signature' (static) + buf := buf[4:100] + copy(t.Signature[:], buf) + } + { // Field #0 'Message' (dynamic) + buf := buf[offset0:] + if t.Message == nil { + t.Message = new(BlindedBeaconBlock) + } + if viewFn := t.Message.UnmarshalSSZDynView((*capella.BlindedBeaconBlock)(nil)); viewFn != nil { + if err = viewFn(ds, buf); err != nil { + return err + } + } else { + return sszutils.ErrNotImplemented + } + } + return nil +} + +func (t *SignedBlindedBeaconBlock) unmarshalSSZView_SignedBlindedBeaconBlock_1(ds sszutils.DynamicSpecs, buf []byte) (err error) { + buflen := len(buf) + if buflen < 100 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 100) + } + // Field #0 'Message' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 100 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset0, 100), "Message:o") + } + { // Field #1 'Signature' (static) + buf := buf[4:100] + copy(t.Signature[:], buf) + } + { // Field #0 'Message' (dynamic) + buf := buf[offset0:] + if t.Message == nil { + t.Message = new(BlindedBeaconBlock) + } + if viewFn := t.Message.UnmarshalSSZDynView((*deneb.BlindedBeaconBlock)(nil)); viewFn != nil { + if err = viewFn(ds, buf); err != nil { + return err + } + } else { + return sszutils.ErrNotImplemented + } + } + return nil +} + +func (t *SignedBlindedBeaconBlock) unmarshalSSZView_SignedBlindedBeaconBlock_2(ds sszutils.DynamicSpecs, buf []byte) (err error) { + buflen := len(buf) + if buflen < 100 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 100) + } + // Field #0 'Message' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 100 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset0, 100), "Message:o") + } + { // Field #1 'Signature' (static) + buf := buf[4:100] + copy(t.Signature[:], buf) + } + { // Field #0 'Message' (dynamic) + buf := buf[offset0:] + if t.Message == nil { + t.Message = new(BlindedBeaconBlock) + } + if viewFn := t.Message.UnmarshalSSZDynView((*electra.BlindedBeaconBlock)(nil)); viewFn != nil { + if err = viewFn(ds, buf); err != nil { + return err + } + } else { + return sszutils.ErrNotImplemented + } + } + return nil +} + +func (t *SignedBlindedBeaconBlock) SizeSSZDynView(view any) func(ds sszutils.DynamicSpecs) int { + switch view.(type) { + case *bellatrix.SignedBlindedBeaconBlock: + return t.sizeSSZView_SignedBlindedBeaconBlock + case *capella.SignedBlindedBeaconBlock: + return t.sizeSSZView_SignedBlindedBeaconBlock_0 + case *deneb.SignedBlindedBeaconBlock: + return t.sizeSSZView_SignedBlindedBeaconBlock_1 + case *electra.SignedBlindedBeaconBlock: + return t.sizeSSZView_SignedBlindedBeaconBlock_2 + } + return nil +} +func (t *SignedBlindedBeaconBlock) sizeSSZView_SignedBlindedBeaconBlock(ds sszutils.DynamicSpecs) (size int) { + if t == nil { + t = new(SignedBlindedBeaconBlock) + } + // Field #0 'Message' offset (4 bytes) + // Field #1 'Signature' static (96 bytes) + size += 100 + { // Dynamic field #0 'Message' + if viewFn := t.Message.SizeSSZDynView((*bellatrix.BlindedBeaconBlock)(nil)); viewFn != nil { + size += viewFn(ds) + } + } + return size +} + +func (t *SignedBlindedBeaconBlock) sizeSSZView_SignedBlindedBeaconBlock_0(ds sszutils.DynamicSpecs) (size int) { + if t == nil { + t = new(SignedBlindedBeaconBlock) + } + // Field #0 'Message' offset (4 bytes) + // Field #1 'Signature' static (96 bytes) + size += 100 + { // Dynamic field #0 'Message' + if viewFn := t.Message.SizeSSZDynView((*capella.BlindedBeaconBlock)(nil)); viewFn != nil { + size += viewFn(ds) + } + } + return size +} + +func (t *SignedBlindedBeaconBlock) sizeSSZView_SignedBlindedBeaconBlock_1(ds sszutils.DynamicSpecs) (size int) { + if t == nil { + t = new(SignedBlindedBeaconBlock) + } + // Field #0 'Message' offset (4 bytes) + // Field #1 'Signature' static (96 bytes) + size += 100 + { // Dynamic field #0 'Message' + if viewFn := t.Message.SizeSSZDynView((*deneb.BlindedBeaconBlock)(nil)); viewFn != nil { + size += viewFn(ds) + } + } + return size +} + +func (t *SignedBlindedBeaconBlock) sizeSSZView_SignedBlindedBeaconBlock_2(ds sszutils.DynamicSpecs) (size int) { + if t == nil { + t = new(SignedBlindedBeaconBlock) + } + // Field #0 'Message' offset (4 bytes) + // Field #1 'Signature' static (96 bytes) + size += 100 + { // Dynamic field #0 'Message' + if viewFn := t.Message.SizeSSZDynView((*electra.BlindedBeaconBlock)(nil)); viewFn != nil { + size += viewFn(ds) + } + } + return size +} + +func (t *SignedBlindedBeaconBlock) HashTreeRootWithDynView(view any) func(ds sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + switch view.(type) { + case *bellatrix.SignedBlindedBeaconBlock: + return t.hashTreeRootView_SignedBlindedBeaconBlock + case *capella.SignedBlindedBeaconBlock: + return t.hashTreeRootView_SignedBlindedBeaconBlock_0 + case *deneb.SignedBlindedBeaconBlock: + return t.hashTreeRootView_SignedBlindedBeaconBlock_1 + case *electra.SignedBlindedBeaconBlock: + return t.hashTreeRootView_SignedBlindedBeaconBlock_2 + } + return nil +} +func (t *SignedBlindedBeaconBlock) hashTreeRootView_SignedBlindedBeaconBlock(ds sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + if t == nil { + t = new(SignedBlindedBeaconBlock) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Message' + t := t.Message + if t == nil { + t = new(BlindedBeaconBlock) + } + if viewFn := t.HashTreeRootWithDynView((*bellatrix.BlindedBeaconBlock)(nil)); viewFn != nil { + if err := viewFn(ds, hh); err != nil { + return err + } + } else { + return sszutils.ErrNotImplemented + } + } + { // Field #1 'Signature' + hh.PutBytes(t.Signature[:96]) + } + hh.Merkleize(idx) + return nil +} + +func (t *SignedBlindedBeaconBlock) hashTreeRootView_SignedBlindedBeaconBlock_0(ds sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + if t == nil { + t = new(SignedBlindedBeaconBlock) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Message' + t := t.Message + if t == nil { + t = new(BlindedBeaconBlock) + } + if viewFn := t.HashTreeRootWithDynView((*capella.BlindedBeaconBlock)(nil)); viewFn != nil { + if err := viewFn(ds, hh); err != nil { + return err + } + } else { + return sszutils.ErrNotImplemented + } + } + { // Field #1 'Signature' + hh.PutBytes(t.Signature[:96]) + } + hh.Merkleize(idx) + return nil +} + +func (t *SignedBlindedBeaconBlock) hashTreeRootView_SignedBlindedBeaconBlock_1(ds sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + if t == nil { + t = new(SignedBlindedBeaconBlock) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Message' + t := t.Message + if t == nil { + t = new(BlindedBeaconBlock) + } + if viewFn := t.HashTreeRootWithDynView((*deneb.BlindedBeaconBlock)(nil)); viewFn != nil { + if err := viewFn(ds, hh); err != nil { + return err + } + } else { + return sszutils.ErrNotImplemented + } + } + { // Field #1 'Signature' + hh.PutBytes(t.Signature[:96]) + } + hh.Merkleize(idx) + return nil +} + +func (t *SignedBlindedBeaconBlock) hashTreeRootView_SignedBlindedBeaconBlock_2(ds sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + if t == nil { + t = new(SignedBlindedBeaconBlock) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Message' + t := t.Message + if t == nil { + t = new(BlindedBeaconBlock) + } + if viewFn := t.HashTreeRootWithDynView((*electra.BlindedBeaconBlock)(nil)); viewFn != nil { + if err := viewFn(ds, hh); err != nil { + return err + } + } else { + return sszutils.ErrNotImplemented + } + } + { // Field #1 'Signature' + hh.PutBytes(t.Signature[:96]) + } + hh.Merkleize(idx) + return nil +} diff --git a/api/v1/all/signedblindedbeaconblock_test.go b/api/v1/all/signedblindedbeaconblock_test.go new file mode 100644 index 00000000..b3c0e101 --- /dev/null +++ b/api/v1/all/signedblindedbeaconblock_test.go @@ -0,0 +1,454 @@ +// Copyright © 2026 Attestant Limited. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package all_test + +import ( + "encoding/json" + "testing" + + bitfield "github.com/OffchainLabs/go-bitfield" + apiv1all "github.com/ethpandaops/go-eth2-client/api/v1/all" + apiv1bellatrix "github.com/ethpandaops/go-eth2-client/api/v1/bellatrix" + apiv1capella "github.com/ethpandaops/go-eth2-client/api/v1/capella" + apiv1deneb "github.com/ethpandaops/go-eth2-client/api/v1/deneb" + apiv1electra "github.com/ethpandaops/go-eth2-client/api/v1/electra" + "github.com/ethpandaops/go-eth2-client/spec/altair" + "github.com/ethpandaops/go-eth2-client/spec/bellatrix" + "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/phase0" + "github.com/ethpandaops/go-eth2-client/spec/version" + "github.com/holiman/uint256" + "github.com/stretchr/testify/require" +) + +// testAttestationData builds a phase0 attestation data with realistic-ish data. +func testAttestationData() *phase0.AttestationData { + return &phase0.AttestationData{ + Slot: 12344, + Index: 1, + BeaconBlockRoot: phase0.Root{0x31}, + Source: &phase0.Checkpoint{Epoch: 384, Root: phase0.Root{0x32}}, + Target: &phase0.Checkpoint{Epoch: 385, Root: phase0.Root{0x33}}, + } +} + +// testPhase0Attestation builds a phase0 attestation. +func testPhase0Attestation() *phase0.Attestation { + return &phase0.Attestation{ + AggregationBits: bitfield.NewBitlist(128), + Data: testAttestationData(), + Signature: phase0.BLSSignature{0x34}, + } +} + +// testElectraAttestation builds an electra attestation. +func testElectraAttestation() *electra.Attestation { + return &electra.Attestation{ + AggregationBits: bitfield.NewBitlist(128), + Data: testAttestationData(), + Signature: phase0.BLSSignature{0x34}, + CommitteeBits: bitfield.NewBitvector64(), + } +} + +// testBellatrixBlindedBody builds a Bellatrix blinded beacon block body. +func testBellatrixBlindedBody() *apiv1bellatrix.BlindedBeaconBlockBody { + return &apiv1bellatrix.BlindedBeaconBlockBody{ + RANDAOReveal: phase0.BLSSignature{0x13}, + ETH1Data: &phase0.ETH1Data{ + DepositRoot: phase0.Root{0x14}, + DepositCount: 15, + BlockHash: make([]byte, 32), + }, + Graffiti: [32]byte{'b', 'u', 'i', 'l', 'd'}, + ProposerSlashings: []*phase0.ProposerSlashing{}, + AttesterSlashings: []*phase0.AttesterSlashing{}, + Attestations: []*phase0.Attestation{testPhase0Attestation()}, + Deposits: []*phase0.Deposit{}, + VoluntaryExits: []*phase0.SignedVoluntaryExit{}, + SyncAggregate: &altair.SyncAggregate{ + SyncCommitteeBits: bitfield.NewBitvector512(), + SyncCommitteeSignature: phase0.BLSSignature{0x16}, + }, + ExecutionPayloadHeader: &bellatrix.ExecutionPayloadHeader{ + ParentHash: phase0.Hash32{0x01}, + FeeRecipient: bellatrix.ExecutionAddress{0x02}, + StateRoot: [32]byte{0x03}, + ReceiptsRoot: [32]byte{0x04}, + LogsBloom: [256]byte{0x05}, + PrevRandao: [32]byte{0x06}, + BlockNumber: 7, + GasLimit: 30_000_000, + GasUsed: 21_000, + Timestamp: 1_600_000_000, + ExtraData: []byte{0x08}, + BaseFeePerGasLE: [32]byte{0x09}, + BlockHash: phase0.Hash32{0x0a}, + TransactionsRoot: phase0.Root{0x0b}, + }, + } +} + +// testCapellaBlindedBody builds a Capella blinded beacon block body. +func testCapellaBlindedBody() *apiv1capella.BlindedBeaconBlockBody { + return &apiv1capella.BlindedBeaconBlockBody{ + RANDAOReveal: phase0.BLSSignature{0x13}, + ETH1Data: &phase0.ETH1Data{ + DepositRoot: phase0.Root{0x14}, + DepositCount: 15, + BlockHash: make([]byte, 32), + }, + Graffiti: [32]byte{'b', 'u', 'i', 'l', 'd'}, + ProposerSlashings: []*phase0.ProposerSlashing{}, + AttesterSlashings: []*phase0.AttesterSlashing{}, + Attestations: []*phase0.Attestation{testPhase0Attestation()}, + Deposits: []*phase0.Deposit{}, + VoluntaryExits: []*phase0.SignedVoluntaryExit{}, + SyncAggregate: &altair.SyncAggregate{ + SyncCommitteeBits: bitfield.NewBitvector512(), + SyncCommitteeSignature: phase0.BLSSignature{0x16}, + }, + ExecutionPayloadHeader: &capella.ExecutionPayloadHeader{ + ParentHash: phase0.Hash32{0x01}, + FeeRecipient: bellatrix.ExecutionAddress{0x02}, + StateRoot: [32]byte{0x03}, + ReceiptsRoot: [32]byte{0x04}, + LogsBloom: [256]byte{0x05}, + PrevRandao: [32]byte{0x06}, + BlockNumber: 7, + GasLimit: 30_000_000, + GasUsed: 21_000, + Timestamp: 1_600_000_000, + ExtraData: []byte{0x08}, + BaseFeePerGasLE: [32]byte{0x09}, + BlockHash: phase0.Hash32{0x0a}, + TransactionsRoot: phase0.Root{0x0b}, + WithdrawalsRoot: phase0.Root{0x0c}, + }, + BLSToExecutionChanges: []*capella.SignedBLSToExecutionChange{}, + } +} + +// testDenebExecutionPayloadHeader builds a Deneb execution payload header +// (also used by Electra/Fulu blinded bodies). +func testDenebExecutionPayloadHeader() *deneb.ExecutionPayloadHeader { + return &deneb.ExecutionPayloadHeader{ + ParentHash: phase0.Hash32{0x01}, + FeeRecipient: bellatrix.ExecutionAddress{0x02}, + StateRoot: phase0.Root{0x03}, + ReceiptsRoot: phase0.Root{0x04}, + LogsBloom: [256]byte{0x05}, + PrevRandao: [32]byte{0x06}, + BlockNumber: 7, + GasLimit: 30_000_000, + GasUsed: 21_000, + Timestamp: 1_600_000_000, + ExtraData: []byte{0x08}, + BaseFeePerGas: uint256.NewInt(9), + BlockHash: phase0.Hash32{0x0a}, + TransactionsRoot: phase0.Root{0x0b}, + WithdrawalsRoot: phase0.Root{0x0c}, + BlobGasUsed: 131072, + ExcessBlobGas: 262144, + } +} + +// testDenebBlindedBody builds a Deneb blinded beacon block body. +func testDenebBlindedBody() *apiv1deneb.BlindedBeaconBlockBody { + return &apiv1deneb.BlindedBeaconBlockBody{ + RANDAOReveal: phase0.BLSSignature{0x13}, + ETH1Data: &phase0.ETH1Data{ + DepositRoot: phase0.Root{0x14}, + DepositCount: 15, + BlockHash: make([]byte, 32), + }, + Graffiti: [32]byte{'b', 'u', 'i', 'l', 'd'}, + ProposerSlashings: []*phase0.ProposerSlashing{}, + AttesterSlashings: []*phase0.AttesterSlashing{}, + Attestations: []*phase0.Attestation{testPhase0Attestation()}, + Deposits: []*phase0.Deposit{}, + VoluntaryExits: []*phase0.SignedVoluntaryExit{}, + SyncAggregate: &altair.SyncAggregate{ + SyncCommitteeBits: bitfield.NewBitvector512(), + SyncCommitteeSignature: phase0.BLSSignature{0x16}, + }, + ExecutionPayloadHeader: testDenebExecutionPayloadHeader(), + BLSToExecutionChanges: []*capella.SignedBLSToExecutionChange{}, + BlobKZGCommitments: []deneb.KZGCommitment{{0x17}}, + } +} + +// testElectraBlindedBody builds an Electra blinded beacon block body (also +// the Fulu wire schema). +func testElectraBlindedBody() *apiv1electra.BlindedBeaconBlockBody { + return &apiv1electra.BlindedBeaconBlockBody{ + RANDAOReveal: phase0.BLSSignature{0x13}, + ETH1Data: &phase0.ETH1Data{ + DepositRoot: phase0.Root{0x14}, + DepositCount: 15, + BlockHash: make([]byte, 32), + }, + Graffiti: [32]byte{'b', 'u', 'i', 'l', 'd'}, + ProposerSlashings: []*phase0.ProposerSlashing{}, + AttesterSlashings: []*electra.AttesterSlashing{}, + Attestations: []*electra.Attestation{testElectraAttestation()}, + Deposits: []*phase0.Deposit{}, + VoluntaryExits: []*phase0.SignedVoluntaryExit{}, + SyncAggregate: &altair.SyncAggregate{ + SyncCommitteeBits: bitfield.NewBitvector512(), + SyncCommitteeSignature: phase0.BLSSignature{0x16}, + }, + ExecutionPayloadHeader: testDenebExecutionPayloadHeader(), + BLSToExecutionChanges: []*capella.SignedBLSToExecutionChange{}, + BlobKZGCommitments: []deneb.KZGCommitment{{0x17}}, + ExecutionRequests: &electra.ExecutionRequests{ + Deposits: []*electra.DepositRequest{}, + Withdrawals: []*electra.WithdrawalRequest{}, + Consolidations: []*electra.ConsolidationRequest{}, + }, + } +} + +// signedBlindedBeaconBlockTests enumerates the per-fork views the agnostic +// SignedBlindedBeaconBlock must be wire-compatible with. +func signedBlindedBeaconBlockTests() []struct { + name string + version version.DataVersion + view any +} { + return []struct { + name string + version version.DataVersion + view any + }{ + { + name: "Bellatrix", + version: version.DataVersionBellatrix, + view: &apiv1bellatrix.SignedBlindedBeaconBlock{ + Message: &apiv1bellatrix.BlindedBeaconBlock{ + Slot: 12345, + ProposerIndex: 42, + ParentRoot: phase0.Root{0x11}, + StateRoot: phase0.Root{0x12}, + Body: testBellatrixBlindedBody(), + }, + Signature: phase0.BLSSignature{0x18}, + }, + }, + { + name: "Capella", + version: version.DataVersionCapella, + view: &apiv1capella.SignedBlindedBeaconBlock{ + Message: &apiv1capella.BlindedBeaconBlock{ + Slot: 12345, + ProposerIndex: 42, + ParentRoot: phase0.Root{0x11}, + StateRoot: phase0.Root{0x12}, + Body: testCapellaBlindedBody(), + }, + Signature: phase0.BLSSignature{0x18}, + }, + }, + { + name: "Deneb", + version: version.DataVersionDeneb, + view: &apiv1deneb.SignedBlindedBeaconBlock{ + Message: &apiv1deneb.BlindedBeaconBlock{ + Slot: 12345, + ProposerIndex: 42, + ParentRoot: phase0.Root{0x11}, + StateRoot: phase0.Root{0x12}, + Body: testDenebBlindedBody(), + }, + Signature: phase0.BLSSignature{0x18}, + }, + }, + { + name: "Electra", + version: version.DataVersionElectra, + view: &apiv1electra.SignedBlindedBeaconBlock{ + Message: &apiv1electra.BlindedBeaconBlock{ + Slot: 12345, + ProposerIndex: 42, + ParentRoot: phase0.Root{0x11}, + StateRoot: phase0.Root{0x12}, + Body: testElectraBlindedBody(), + }, + Signature: phase0.BLSSignature{0x18}, + }, + }, + { + // Fulu reuses the Electra wire schema; the agnostic type must + // accept the Electra view when pinned to the Fulu version. + name: "Fulu", + version: version.DataVersionFulu, + view: &apiv1electra.SignedBlindedBeaconBlock{ + Message: &apiv1electra.BlindedBeaconBlock{ + Slot: 12345, + ProposerIndex: 42, + ParentRoot: phase0.Root{0x11}, + StateRoot: phase0.Root{0x12}, + Body: testElectraBlindedBody(), + }, + Signature: phase0.BLSSignature{0x18}, + }, + }, + } +} + +// TestSignedBlindedBeaconBlockJSONWireCompat verifies that the agnostic type +// marshals to byte-identical JSON versus the per-fork type, and that JSON +// round-trips losslessly through the agnostic type. +func TestSignedBlindedBeaconBlockJSONWireCompat(t *testing.T) { + for _, test := range signedBlindedBeaconBlockTests() { + t.Run(test.name, func(t *testing.T) { + expected, err := json.Marshal(test.view) + require.NoError(t, err) + + agnostic := &apiv1all.SignedBlindedBeaconBlock{Version: test.version} + require.NoError(t, agnostic.FromView(test.view)) + require.Equal(t, test.version, agnostic.Version) + + got, err := json.Marshal(agnostic) + require.NoError(t, err) + require.Equal(t, string(expected), string(got), + "agnostic JSON differs from per-fork JSON") + + // Round-trip through UnmarshalJSON with Version pre-set. + rt := &apiv1all.SignedBlindedBeaconBlock{Version: test.version} + require.NoError(t, json.Unmarshal(expected, rt)) + + rtJSON, err := json.Marshal(rt) + require.NoError(t, err) + require.Equal(t, string(expected), string(rtJSON), + "round-tripped JSON differs from per-fork JSON") + + // Version must propagate to nested versionable children. + require.NotNil(t, rt.Message) + require.Equal(t, test.version, rt.Message.Version) + require.NotNil(t, rt.Message.Body) + require.Equal(t, test.version, rt.Message.Body.Version) + require.NotNil(t, rt.Message.Body.ExecutionPayloadHeader) + require.Equal(t, test.version, rt.Message.Body.ExecutionPayloadHeader.Version) + + // The nested agnostic header must marshal standalone at every + // supported version (Electra/Fulu map to the Deneb schema). + _, err = json.Marshal(rt.Message.Body.ExecutionPayloadHeader) + require.NoError(t, err, "nested header must marshal standalone") + }) + } +} + +// TestSignedBlindedBeaconBlockSSZWireCompat verifies that the agnostic type +// produces byte-identical SSZ and the same hash tree root as the per-fork +// type, and that SSZ round-trips losslessly through the agnostic type. +func TestSignedBlindedBeaconBlockSSZWireCompat(t *testing.T) { + for _, test := range signedBlindedBeaconBlockTests() { + t.Run(test.name, func(t *testing.T) { + codec, ok := test.view.(sszCodec) + require.True(t, ok) + + expected, err := codec.MarshalSSZ() + require.NoError(t, err) + + agnostic := &apiv1all.SignedBlindedBeaconBlock{Version: test.version} + require.NoError(t, agnostic.FromView(test.view)) + + got, err := agnostic.MarshalSSZ() + require.NoError(t, err) + require.Equal(t, expected, got, "agnostic SSZ differs from per-fork SSZ") + + expectedRoot, err := codec.HashTreeRoot() + require.NoError(t, err) + + gotRoot, err := agnostic.HashTreeRoot() + require.NoError(t, err) + require.Equal(t, expectedRoot, gotRoot, + "agnostic hash tree root differs from per-fork root") + + // Round-trip through UnmarshalSSZ with Version pre-set. + rt := &apiv1all.SignedBlindedBeaconBlock{Version: test.version} + require.NoError(t, rt.UnmarshalSSZ(expected)) + + rtSSZ, err := rt.MarshalSSZ() + require.NoError(t, err) + require.Equal(t, expected, rtSSZ, + "round-tripped SSZ differs from per-fork SSZ") + + // Version must propagate to nested versionable children. + require.NotNil(t, rt.Message) + require.Equal(t, test.version, rt.Message.Version) + }) + } +} + +// TestSignedBlindedBeaconBlockViewRoundtrip verifies ToView reproduces the +// per-fork view the agnostic instance was built from. +func TestSignedBlindedBeaconBlockViewRoundtrip(t *testing.T) { + for _, test := range signedBlindedBeaconBlockTests() { + t.Run(test.name, func(t *testing.T) { + agnostic := &apiv1all.SignedBlindedBeaconBlock{Version: test.version} + require.NoError(t, agnostic.FromView(test.view)) + + view, err := agnostic.ToView() + require.NoError(t, err) + require.IsType(t, test.view, view) + require.Equal(t, test.view, view) + }) + } +} + +// TestSignedBlindedBeaconBlockToVersioned verifies conversion to and from +// api.VersionedSignedBlindedBeaconBlock. +func TestSignedBlindedBeaconBlockToVersioned(t *testing.T) { + for _, test := range signedBlindedBeaconBlockTests() { + t.Run(test.name, func(t *testing.T) { + agnostic := &apiv1all.SignedBlindedBeaconBlock{Version: test.version} + require.NoError(t, agnostic.FromView(test.view)) + + versioned, err := agnostic.ToVersioned() + require.NoError(t, err) + require.Equal(t, test.version, versioned.Version) + + rt := &apiv1all.SignedBlindedBeaconBlock{} + require.NoError(t, rt.FromVersioned(versioned)) + require.Equal(t, test.version, rt.Version) + require.Equal(t, agnostic, rt) + }) + } +} + +// TestSignedBlindedBeaconBlockUnsupportedVersion verifies unsupported +// versions are rejected with a clear error. +func TestSignedBlindedBeaconBlockUnsupportedVersion(t *testing.T) { + for _, v := range []version.DataVersion{ + version.DataVersionUnknown, + version.DataVersionPhase0, + version.DataVersionAltair, + version.DataVersionGloas, + } { + s := &apiv1all.SignedBlindedBeaconBlock{Version: v} + + _, err := s.ToView() + require.ErrorContains(t, err, "unsupported version") + + _, err = json.Marshal(s) + require.ErrorContains(t, err, "unsupported version") + + _, err = s.MarshalSSZ() + require.ErrorContains(t, err, "unsupported version") + } +} diff --git a/api/v1/all/signedblockcontents.go b/api/v1/all/signedblockcontents.go new file mode 100644 index 00000000..0e09c114 --- /dev/null +++ b/api/v1/all/signedblockcontents.go @@ -0,0 +1,278 @@ +// Copyright © 2026 Attestant Limited. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package all + +import ( + "errors" + "fmt" + + "github.com/ethpandaops/go-eth2-client/api" + apiv1deneb "github.com/ethpandaops/go-eth2-client/api/v1/deneb" + apiv1electra "github.com/ethpandaops/go-eth2-client/api/v1/electra" + apiv1fulu "github.com/ethpandaops/go-eth2-client/api/v1/fulu" + specall "github.com/ethpandaops/go-eth2-client/spec/all" + "github.com/ethpandaops/go-eth2-client/spec/deneb" + "github.com/ethpandaops/go-eth2-client/spec/version" + dynssz "github.com/pk910/dynamic-ssz" + "github.com/pk910/dynamic-ssz/sszutils" +) + +// SignedBlockContents is a fork-agnostic signed block contents: the signed +// beacon block together with the blob sidecar data (KZG proofs and blobs). +// Block contents exist as a wire type from Deneb onwards; earlier forks +// submit bare signed beacon blocks and are not supported by this type. +type SignedBlockContents struct { + Version version.DataVersion + SignedBlock *specall.SignedBeaconBlock + KZGProofs []deneb.KZGProof + Blobs []deneb.Blob +} + +// viewType returns the fork-specific schema type pointer used as the view +// descriptor for the active Version. +func (s *SignedBlockContents) viewType() (any, error) { + switch s.Version { + case version.DataVersionDeneb: + return (*apiv1deneb.SignedBlockContents)(nil), nil + case version.DataVersionElectra: + return (*apiv1electra.SignedBlockContents)(nil), nil + case version.DataVersionFulu: + // Fulu reuses the Electra signed block schema; only the KZG proof + // list limit differs (cell proofs). + return (*apiv1fulu.SignedBlockContents)(nil), nil + default: + return nil, fmt.Errorf("SignedBlockContents: unsupported version %d", s.Version) + } +} + +// MarshalSSZDyn marshals the signed block contents using the view that +// matches Version. +func (s *SignedBlockContents) MarshalSSZDyn(ds sszutils.DynamicSpecs, buf []byte) ([]byte, error) { + view, err := s.viewType() + if err != nil { + return nil, err + } + + m, ok := any(s).(sszutils.DynamicViewMarshaler) + if !ok { + return nil, errors.New("SignedBlockContents: generated SSZ code missing") + } + + fn := m.MarshalSSZDynView(view) + if fn == nil { + return nil, fmt.Errorf("SignedBlockContents: no view marshaler for version %d", s.Version) + } + + return fn(ds, buf) +} + +// SizeSSZDyn returns the SSZ size of the signed block contents for the +// active Version. +func (s *SignedBlockContents) SizeSSZDyn(ds sszutils.DynamicSpecs) int { + view, err := s.viewType() + if err != nil { + return 0 + } + + sz, ok := any(s).(sszutils.DynamicViewSizer) + if !ok { + return 0 + } + + fn := sz.SizeSSZDynView(view) + if fn == nil { + return 0 + } + + return fn(ds) +} + +// UnmarshalSSZDyn decodes the signed block contents into the view that +// matches Version. +func (s *SignedBlockContents) UnmarshalSSZDyn(ds sszutils.DynamicSpecs, buf []byte) error { + view, err := s.viewType() + if err != nil { + return err + } + + u, ok := any(s).(sszutils.DynamicViewUnmarshaler) + if !ok { + return errors.New("SignedBlockContents: generated SSZ code missing") + } + + fn := u.UnmarshalSSZDynView(view) + if fn == nil { + return fmt.Errorf("SignedBlockContents: no view unmarshaler for version %d", s.Version) + } + + if err := fn(ds, buf); err != nil { + return err + } + + s.populateVersion(s.Version) + + return nil +} + +// populateVersion sets Version and propagates it to any nested versionable +// children allocated by the SSZ unmarshal. +func (s *SignedBlockContents) populateVersion(v version.DataVersion) { + propagateVersion(s, v) +} + +// ToView returns a fresh fork-specific SignedBlockContents populated with +// s's fields, recursing into SignedBlock via copyByName. +func (s *SignedBlockContents) ToView() (any, error) { + return toViewByCopy(s) +} + +// FromView populates s from a fork-specific SignedBlockContents. +func (s *SignedBlockContents) FromView(view any) error { + v, err := signedBlockContentsVersion(view) + if err != nil { + return err + } + + if s.Version == version.DataVersionUnknown { + s.Version = v + } + + if err := copyByName(view, s); err != nil { + return err + } + + s.populateVersion(s.Version) + + return nil +} + +// signedBlockContentsVersion maps a SignedBlockContents view type to its +// DataVersion. +func signedBlockContentsVersion(view any) (version.DataVersion, error) { + switch view.(type) { + case *apiv1deneb.SignedBlockContents: + return version.DataVersionDeneb, nil + case *apiv1electra.SignedBlockContents: + return version.DataVersionElectra, nil + case *apiv1fulu.SignedBlockContents: + return version.DataVersionFulu, nil + default: + return version.DataVersionUnknown, fmt.Errorf("SignedBlockContents: unsupported view type %T", view) + } +} + +// HashTreeRootWithDyn computes the SSZ hash tree root using the active +// Version's view. +func (s *SignedBlockContents) HashTreeRootWithDyn(ds sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + view, err := s.viewType() + if err != nil { + return err + } + + h, ok := any(s).(sszutils.DynamicViewHashRoot) + if !ok { + return errors.New("SignedBlockContents: generated SSZ code missing") + } + + fn := h.HashTreeRootWithDynView(view) + if fn == nil { + return fmt.Errorf("SignedBlockContents: no view hasher for version %d", s.Version) + } + + return fn(ds, hh) +} + +// MarshalSSZ implements the fastssz.Marshaler interface. +func (s *SignedBlockContents) MarshalSSZ() ([]byte, error) { + ds := dynssz.GetGlobalDynSsz() + + return s.MarshalSSZDyn(ds, make([]byte, 0, s.SizeSSZDyn(ds))) +} + +// MarshalSSZTo implements the fastssz.Marshaler interface. +func (s *SignedBlockContents) MarshalSSZTo(dst []byte) ([]byte, error) { + return s.MarshalSSZDyn(dynssz.GetGlobalDynSsz(), dst) +} + +// UnmarshalSSZ implements the fastssz.Unmarshaler interface. +func (s *SignedBlockContents) UnmarshalSSZ(buf []byte) error { + return s.UnmarshalSSZDyn(dynssz.GetGlobalDynSsz(), buf) +} + +// SizeSSZ implements the fastssz.Marshaler interface. +func (s *SignedBlockContents) SizeSSZ() int { + return s.SizeSSZDyn(dynssz.GetGlobalDynSsz()) +} + +// HashTreeRoot implements the fastssz.HashRoot interface. +func (s *SignedBlockContents) HashTreeRoot() ([32]byte, error) { + return dynssz.GetGlobalDynSsz().HashTreeRoot(s) +} + +// HashTreeRootWith implements the fastssz.HashRoot interface. +func (s *SignedBlockContents) HashTreeRootWith(hh sszutils.HashWalker) error { + return s.HashTreeRootWithDyn(dynssz.GetGlobalDynSsz(), hh) +} + +// ToVersioned converts s into a *api.VersionedSignedProposal. +func (s *SignedBlockContents) ToVersioned() (*api.VersionedSignedProposal, error) { + out := &api.VersionedSignedProposal{} + if err := toVersioned(s.Version, s, out); err != nil { + return nil, err + } + + return out, nil +} + +// FromVersioned populates s from src. Only unblinded block contents +// proposals (Deneb onwards) are supported. +func (s *SignedBlockContents) FromVersioned(src *api.VersionedSignedProposal) error { + return fromVersioned(s, src) +} + +// MarshalJSON delegates to the per-fork SignedBlockContents that matches +// Version. +func (s *SignedBlockContents) MarshalJSON() ([]byte, error) { + return marshalAsView(s) +} + +// UnmarshalJSON delegates to the per-fork SignedBlockContents that matches +// Version. Caller must set Version before calling. +func (s *SignedBlockContents) UnmarshalJSON(data []byte) error { + if err := unmarshalAsView(s, data); err != nil { + return err + } + + s.populateVersion(s.Version) + + return nil +} + +// MarshalYAML delegates to the per-fork SignedBlockContents that matches +// Version. +func (s *SignedBlockContents) MarshalYAML() ([]byte, error) { + return marshalAsViewYAML(s) +} + +// UnmarshalYAML delegates to the per-fork SignedBlockContents that matches +// Version. Caller must set Version before calling. +func (s *SignedBlockContents) UnmarshalYAML(data []byte) error { + if err := unmarshalAsViewYAML(s, data); err != nil { + return err + } + + s.populateVersion(s.Version) + + return nil +} diff --git a/api/v1/all/signedblockcontents_ssz.go b/api/v1/all/signedblockcontents_ssz.go new file mode 100644 index 00000000..83723a55 --- /dev/null +++ b/api/v1/all/signedblockcontents_ssz.go @@ -0,0 +1,6794 @@ +// Code generated by dynamic-ssz. DO NOT EDIT. +// Hash: 84b8749aa0c253c66da5cc5cbc7f3430c9a0a6595a81621ca5312b56cc2408e7 +// Version: v1.3.2 (https://github.com/pk910/dynamic-ssz) +package all + +import ( + "encoding/binary" + "math/bits" + + "github.com/ethpandaops/go-eth2-client/api/v1/deneb" + "github.com/ethpandaops/go-eth2-client/api/v1/electra" + "github.com/ethpandaops/go-eth2-client/api/v1/fulu" + "github.com/ethpandaops/go-eth2-client/spec/all" + "github.com/ethpandaops/go-eth2-client/spec/altair" + "github.com/ethpandaops/go-eth2-client/spec/capella" + electra1 "github.com/ethpandaops/go-eth2-client/spec/electra" + "github.com/ethpandaops/go-eth2-client/spec/phase0" + "github.com/holiman/uint256" + "github.com/pk910/dynamic-ssz/hasher" + "github.com/pk910/dynamic-ssz/sszutils" +) + +var _ = sszutils.ErrListTooBig + +var _ = sszutils.Annotate[*deneb.SignedBlockContents](`ssz-static:"false"`) +var _ = sszutils.Annotate[*electra.SignedBlockContents](`ssz-static:"false"`) +var _ = sszutils.Annotate[*fulu.SignedBlockContents](`ssz-static:"false"`) + +func (t *SignedBlockContents) MarshalSSZDynView(view any) func(ds sszutils.DynamicSpecs, buf []byte) ([]byte, error) { + switch view.(type) { + case *deneb.SignedBlockContents: + return t.marshalSSZView_SignedBlockContents + case *electra.SignedBlockContents: + return t.marshalSSZView_SignedBlockContents_0 + case *fulu.SignedBlockContents: + return t.marshalSSZView_SignedBlockContents_1 + } + return nil +} +func (t *SignedBlockContents) marshalSSZView_SignedBlockContents(ds sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + dst = buf + expr0, err := sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE/8", 64) + if err != nil { + return dst, err + } + expr1, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_PROPOSER_SLASHINGS", 16) + if err != nil { + return dst, err + } + expr2, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_ATTESTER_SLASHINGS", 2) + if err != nil { + return dst, err + } + expr3, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_ATTESTATIONS", 128) + if err != nil { + return dst, err + } + expr4, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_VALIDATORS_PER_COMMITTEE", 2048) + if err != nil { + return dst, err + } + expr5, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_DEPOSITS", 16) + if err != nil { + return dst, err + } + expr6, err := sszutils.ResolveSpecValueWithDefault(ds, "DEPOSIT_CONTRACT_TREE_DEPTH+1", 33) + if err != nil { + return dst, err + } + expr7, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_VOLUNTARY_EXITS", 16) + if err != nil { + return dst, err + } + expr8, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_EXTRA_DATA_BYTES", 32) + if err != nil { + return dst, err + } + expr9, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_TRANSACTIONS_PER_PAYLOAD", 1048576) + if err != nil { + return dst, err + } + expr10, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BYTES_PER_TRANSACTION", 1073741824) + if err != nil { + return dst, err + } + expr11, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_WITHDRAWALS_PER_PAYLOAD", 16) + if err != nil { + return dst, err + } + expr12, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BLS_TO_EXECUTION_CHANGES", 16) + if err != nil { + return dst, err + } + expr13, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BLOB_COMMITMENTS_PER_BLOCK", 4096) + if err != nil { + return dst, err + } + zeroBytes := sszutils.ZeroBytes() + if t == nil { + t = new(SignedBlockContents) + } + dstlen := len(dst) + // Offset Field #0 'SignedBlock' + // Offset Field #1 'KZGProofs' + // Offset Field #2 'Blobs' + dst = append(dst, zeroBytes[:12]...) + { // Dynamic Field #0 'SignedBlock' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.SignedBlock + if t == nil { + t = new(all.SignedBeaconBlock) + } + dstlen := len(dst) + // Offset Field #0 'Message' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #1 'Signature' + dst = append(dst, t.Signature[:96]...) + } + { // Dynamic Field #0 'Message' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.Message + if t == nil { + t = new(all.BeaconBlock) + } + dstlen := len(dst) + { // Static Field #0 'Slot' + dst = binary.LittleEndian.AppendUint64(dst, uint64(t.Slot)) + } + { // Static Field #1 'ProposerIndex' + dst = binary.LittleEndian.AppendUint64(dst, uint64(t.ProposerIndex)) + } + { // Static Field #2 'ParentRoot' + dst = append(dst, t.ParentRoot[:32]...) + } + { // Static Field #3 'StateRoot' + dst = append(dst, t.StateRoot[:32]...) + } + // Offset Field #4 'Body' + dst = append(dst, 0, 0, 0, 0) + { // Dynamic Field #4 'Body' + binary.LittleEndian.PutUint32(dst[dstlen+80:], uint32(len(dst)-dstlen)) + t := t.Body + if t == nil { + t = new(all.BeaconBlockBody) + } + dstlen := len(dst) + { // Static Field #0 'RANDAOReveal' + dst = append(dst, t.RANDAOReveal[:96]...) + } + { // Static Field #1 'ETH1Data' + t := t.ETH1Data + if t == nil { + t = new(phase0.ETH1Data) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "SignedBlock.Message.Body.ETH1Data") + } + } + { // Static Field #2 'Graffiti' + dst = append(dst, t.Graffiti[:32]...) + } + // Offset Field #3 'ProposerSlashings' + // Offset Field #4 'AttesterSlashings' + // Offset Field #5 'Attestations' + // Offset Field #6 'Deposits' + // Offset Field #7 'VoluntaryExits' + dst = append(dst, zeroBytes[:20]...) + { // Static Field #8 'SyncAggregate' + t := t.SyncAggregate + if t == nil { + t = new(altair.SyncAggregate) + } + { // Static Field #0 'SyncCommitteeBits' + vlen := len(t.SyncCommitteeBits) + if vlen > int(expr0) { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(expr0)), "SignedBlock.Message.Body.SyncAggregate.SyncCommitteeBits") + } + dst = append(dst, t.SyncCommitteeBits[:vlen]...) + if vlen < int(expr0) { + dst = sszutils.AppendZeroPadding(dst, (int(expr0)-vlen)*1) + } + } + { // Static Field #1 'SyncCommitteeSignature' + dst = append(dst, t.SyncCommitteeSignature[:96]...) + } + } + // Offset Field #9 'ExecutionPayload' + offset9 := len(dst) + // Offset Field #10 'BLSToExecutionChanges' + // Offset Field #11 'BlobKZGCommitments' + dst = append(dst, zeroBytes[:12]...) + { // Dynamic Field #3 'ProposerSlashings' + binary.LittleEndian.PutUint32(dst[dstlen+200:], uint32(len(dst)-dstlen)) + t := t.ProposerSlashings + vlen := len(t) + if vlen > int(expr1) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr1)), "SignedBlock.Message.Body.ProposerSlashings") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(phase0.ProposerSlashing) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.ProposerSlashings[%d]", idx1) + } + } + } + { // Dynamic Field #4 'AttesterSlashings' + binary.LittleEndian.PutUint32(dst[dstlen+204:], uint32(len(dst)-dstlen)) + t := t.AttesterSlashings + vlen := len(t) + if vlen > int(expr2) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr2)), "SignedBlock.Message.Body.AttesterSlashings") + } + dstlen := len(dst) + dst = sszutils.AppendZeroPadding(dst, vlen*4) + for idx1 := range vlen { + binary.LittleEndian.PutUint32(dst[dstlen+(idx1*4):], uint32(len(dst)-dstlen)) + t := t[idx1] + if t == nil { + t = new(all.AttesterSlashing) + } + dstlen := len(dst) + // Offset Field #0 'Attestation1' + // Offset Field #1 'Attestation2' + dst = append(dst, 0, 0, 0, 0, 0, 0, 0, 0) + { // Dynamic Field #0 'Attestation1' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.Attestation1 + if t == nil { + t = new(all.IndexedAttestation) + } + dstlen := len(dst) + // Offset Field #0 'AttestingIndices' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.AttestationData) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.AttesterSlashings[%d].Attestation1.Data", idx1) + } + } + { // Static Field #2 'Signature' + dst = append(dst, t.Signature[:96]...) + } + { // Dynamic Field #0 'AttestingIndices' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.AttestingIndices + vlen := len(t) + if vlen > 2048 { + return nil, sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(vlen, 2048), "SignedBlock.Message.Body.AttesterSlashings[%d].Attestation1.AttestingIndices", idx1) + } + dst = sszutils.MarshalUint64Slice(dst, t[:vlen]) + } + } + { // Dynamic Field #1 'Attestation2' + binary.LittleEndian.PutUint32(dst[dstlen+4:], uint32(len(dst)-dstlen)) + t := t.Attestation2 + if t == nil { + t = new(all.IndexedAttestation) + } + dstlen := len(dst) + // Offset Field #0 'AttestingIndices' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.AttestationData) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.AttesterSlashings[%d].Attestation2.Data", idx1) + } + } + { // Static Field #2 'Signature' + dst = append(dst, t.Signature[:96]...) + } + { // Dynamic Field #0 'AttestingIndices' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.AttestingIndices + vlen := len(t) + if vlen > 2048 { + return nil, sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(vlen, 2048), "SignedBlock.Message.Body.AttesterSlashings[%d].Attestation2.AttestingIndices", idx1) + } + dst = sszutils.MarshalUint64Slice(dst, t[:vlen]) + } + } + } + } + { // Dynamic Field #5 'Attestations' + binary.LittleEndian.PutUint32(dst[dstlen+208:], uint32(len(dst)-dstlen)) + t := t.Attestations + vlen := len(t) + if vlen > int(expr3) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr3)), "SignedBlock.Message.Body.Attestations") + } + dstlen := len(dst) + dst = sszutils.AppendZeroPadding(dst, vlen*4) + for idx1 := range vlen { + binary.LittleEndian.PutUint32(dst[dstlen+(idx1*4):], uint32(len(dst)-dstlen)) + t := t[idx1] + if t == nil { + t = new(all.Attestation) + } + dstlen := len(dst) + // Offset Field #0 'AggregationBits' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.AttestationData) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.Attestations[%d].Data", idx1) + } + } + { // Static Field #2 'Signature' + dst = append(dst, t.Signature[:96]...) + } + { // Dynamic Field #0 'AggregationBits' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.AggregationBits + vlen := len(t) + bval := []byte(t[:]) + if vlen == 0 { + bval = []byte{0x01} + } else if bval[vlen-1] == 0x00 { + return nil, sszutils.ErrorWithPathf(sszutils.ErrBitlistNotTerminatedFn(), "SignedBlock.Message.Body.Attestations[%d].AggregationBits", idx1) + } + if vlen > 0 { + bitCount := 8*(vlen-1) + bits.Len8(bval[vlen-1]) - 1 + if bitCount > int(expr4) { + return nil, sszutils.ErrorWithPathf(sszutils.ErrBitlistLengthFn(bitCount, int(expr4)), "SignedBlock.Message.Body.Attestations[%d].AggregationBits", idx1) + } + } + dst = append(dst, bval...) + } + } + } + { // Dynamic Field #6 'Deposits' + binary.LittleEndian.PutUint32(dst[dstlen+212:], uint32(len(dst)-dstlen)) + t := t.Deposits + vlen := len(t) + if vlen > int(expr5) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr5)), "SignedBlock.Message.Body.Deposits") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(phase0.Deposit) + } + { // Static Field #0 'Proof' + t := t.Proof + vlen := len(t) + if vlen > int(expr6) { + return nil, sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, int(expr6)), "SignedBlock.Message.Body.Deposits[%d].Proof", idx1) + } + for idx2 := range vlen { + vlen := len(t[idx2]) + if vlen > 32 { + return nil, sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, 32), "SignedBlock.Message.Body.Deposits[%d].Proof[%d]", idx1, idx2) + } + dst = append(dst, t[idx2][:vlen]...) + if vlen < 32 { + dst = sszutils.AppendZeroPadding(dst, (32-vlen)*1) + } + } + if vlen < int(expr6) { + dst = sszutils.AppendZeroPadding(dst, (int(expr6)-vlen)*32) + } + } + { // Static Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.DepositData) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.Deposits[%d].Data", idx1) + } + } + } + } + { // Dynamic Field #7 'VoluntaryExits' + binary.LittleEndian.PutUint32(dst[dstlen+216:], uint32(len(dst)-dstlen)) + t := t.VoluntaryExits + vlen := len(t) + if vlen > int(expr7) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr7)), "SignedBlock.Message.Body.VoluntaryExits") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(phase0.SignedVoluntaryExit) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.VoluntaryExits[%d]", idx1) + } + } + } + { // Dynamic Field #9 'ExecutionPayload' + binary.LittleEndian.PutUint32(dst[offset9:], uint32(len(dst)-dstlen)) + t := t.ExecutionPayload + if t == nil { + t = new(all.ExecutionPayload) + } + dstlen := len(dst) + { // Static Field #0 'ParentHash' + dst = append(dst, t.ParentHash[:32]...) + } + { // Static Field #1 'FeeRecipient' + dst = append(dst, t.FeeRecipient[:20]...) + } + { // Static Field #2 'StateRoot' + dst = append(dst, t.StateRoot[:32]...) + } + { // Static Field #3 'ReceiptsRoot' + dst = append(dst, t.ReceiptsRoot[:32]...) + } + { // Static Field #4 'LogsBloom' + dst = append(dst, t.LogsBloom[:256]...) + } + { // Static Field #5 'PrevRandao' + dst = append(dst, t.PrevRandao[:32]...) + } + { // Static Field #6 'BlockNumber' + dst = binary.LittleEndian.AppendUint64(dst, t.BlockNumber) + } + { // Static Field #7 'GasLimit' + dst = binary.LittleEndian.AppendUint64(dst, t.GasLimit) + } + { // Static Field #8 'GasUsed' + dst = binary.LittleEndian.AppendUint64(dst, t.GasUsed) + } + { // Static Field #9 'Timestamp' + dst = binary.LittleEndian.AppendUint64(dst, t.Timestamp) + } + // Offset Field #10 'ExtraData' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #11 'BaseFeePerGas' + t := t.BaseFeePerGas + if t == nil { + t = new(uint256.Int) + } + dst = sszutils.MarshalUint64Slice(dst, (*t)[:4]) + } + { // Static Field #12 'BlockHash' + dst = append(dst, t.BlockHash[:32]...) + } + // Offset Field #13 'Transactions' + // Offset Field #14 'Withdrawals' + dst = append(dst, 0, 0, 0, 0, 0, 0, 0, 0) + { // Static Field #15 'BlobGasUsed' + dst = binary.LittleEndian.AppendUint64(dst, t.BlobGasUsed) + } + { // Static Field #16 'ExcessBlobGas' + dst = binary.LittleEndian.AppendUint64(dst, t.ExcessBlobGas) + } + { // Dynamic Field #10 'ExtraData' + binary.LittleEndian.PutUint32(dst[dstlen+436:], uint32(len(dst)-dstlen)) + vlen := len(t.ExtraData) + if vlen > int(expr8) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr8)), "SignedBlock.Message.Body.ExecutionPayload.ExtraData") + } + dst = append(dst, t.ExtraData[:]...) + } + { // Dynamic Field #13 'Transactions' + binary.LittleEndian.PutUint32(dst[dstlen+504:], uint32(len(dst)-dstlen)) + t := t.Transactions + vlen := len(t) + if vlen > int(expr9) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr9)), "SignedBlock.Message.Body.ExecutionPayload.Transactions") + } + dstlen := len(dst) + dst = sszutils.AppendZeroPadding(dst, vlen*4) + for idx1 := range vlen { + binary.LittleEndian.PutUint32(dst[dstlen+(idx1*4):], uint32(len(dst)-dstlen)) + vlen := len(t[idx1]) + if vlen > int(expr10) { + return nil, sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(vlen, int(expr10)), "SignedBlock.Message.Body.ExecutionPayload.Transactions[%d]", idx1) + } + dst = append(dst, t[idx1][:]...) + } + } + { // Dynamic Field #14 'Withdrawals' + binary.LittleEndian.PutUint32(dst[dstlen+508:], uint32(len(dst)-dstlen)) + t := t.Withdrawals + vlen := len(t) + if vlen > int(expr11) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr11)), "SignedBlock.Message.Body.ExecutionPayload.Withdrawals") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(capella.Withdrawal) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.ExecutionPayload.Withdrawals[%d]", idx1) + } + } + } + } + { // Dynamic Field #10 'BLSToExecutionChanges' + binary.LittleEndian.PutUint32(dst[offset9+4:], uint32(len(dst)-dstlen)) + t := t.BLSToExecutionChanges + vlen := len(t) + if vlen > int(expr12) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr12)), "SignedBlock.Message.Body.BLSToExecutionChanges") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(capella.SignedBLSToExecutionChange) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.BLSToExecutionChanges[%d]", idx1) + } + } + } + { // Dynamic Field #11 'BlobKZGCommitments' + binary.LittleEndian.PutUint32(dst[offset9+8:], uint32(len(dst)-dstlen)) + t := t.BlobKZGCommitments + vlen := len(t) + if vlen > int(expr13) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr13)), "SignedBlock.Message.Body.BlobKZGCommitments") + } + dst = sszutils.MarshalFixedBytesSlice(dst, t[:vlen]) + } + } + } + } + { // Dynamic Field #1 'KZGProofs' + binary.LittleEndian.PutUint32(dst[dstlen+4:], uint32(len(dst)-dstlen)) + t := t.KZGProofs + vlen := len(t) + if vlen > int(expr13) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr13)), "KZGProofs") + } + dst = sszutils.MarshalFixedBytesSlice(dst, t[:vlen]) + } + { // Dynamic Field #2 'Blobs' + binary.LittleEndian.PutUint32(dst[dstlen+8:], uint32(len(dst)-dstlen)) + t := t.Blobs + vlen := len(t) + if vlen > int(expr13) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr13)), "Blobs") + } + dst = sszutils.MarshalFixedBytesSlice(dst, t[:vlen]) + } + return dst, nil +} + +func (t *SignedBlockContents) marshalSSZView_SignedBlockContents_0(ds sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + dst = buf + expr0, err := sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE/8", 64) + if err != nil { + return dst, err + } + expr1, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_PROPOSER_SLASHINGS", 16) + if err != nil { + return dst, err + } + expr2, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_ATTESTER_SLASHINGS_ELECTRA", 1) + if err != nil { + return dst, err + } + expr3, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_VALIDATORS_PER_COMMITTEE*MAX_COMMITTEES_PER_SLOT", 131072) + if err != nil { + return dst, err + } + expr4, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_ATTESTATIONS_ELECTRA", 8) + if err != nil { + return dst, err + } + expr5, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_COMMITTEES_PER_SLOT/8", 8) + if err != nil { + return dst, err + } + expr6, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_DEPOSITS", 16) + if err != nil { + return dst, err + } + expr7, err := sszutils.ResolveSpecValueWithDefault(ds, "DEPOSIT_CONTRACT_TREE_DEPTH+1", 33) + if err != nil { + return dst, err + } + expr8, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_VOLUNTARY_EXITS", 16) + if err != nil { + return dst, err + } + expr9, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_EXTRA_DATA_BYTES", 32) + if err != nil { + return dst, err + } + expr10, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_TRANSACTIONS_PER_PAYLOAD", 1048576) + if err != nil { + return dst, err + } + expr11, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BYTES_PER_TRANSACTION", 1073741824) + if err != nil { + return dst, err + } + expr12, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_WITHDRAWALS_PER_PAYLOAD", 16) + if err != nil { + return dst, err + } + expr13, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BLS_TO_EXECUTION_CHANGES", 16) + if err != nil { + return dst, err + } + expr14, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BLOB_COMMITMENTS_PER_BLOCK", 4096) + if err != nil { + return dst, err + } + expr15, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_DEPOSIT_REQUESTS_PER_PAYLOAD", 8192) + if err != nil { + return dst, err + } + expr16, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_WITHDRAWAL_REQUESTS_PER_PAYLOAD", 16) + if err != nil { + return dst, err + } + expr17, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD", 2) + if err != nil { + return dst, err + } + zeroBytes := sszutils.ZeroBytes() + if t == nil { + t = new(SignedBlockContents) + } + dstlen := len(dst) + // Offset Field #0 'SignedBlock' + // Offset Field #1 'KZGProofs' + // Offset Field #2 'Blobs' + dst = append(dst, zeroBytes[:12]...) + { // Dynamic Field #0 'SignedBlock' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.SignedBlock + if t == nil { + t = new(all.SignedBeaconBlock) + } + dstlen := len(dst) + // Offset Field #0 'Message' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #1 'Signature' + dst = append(dst, t.Signature[:96]...) + } + { // Dynamic Field #0 'Message' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.Message + if t == nil { + t = new(all.BeaconBlock) + } + dstlen := len(dst) + { // Static Field #0 'Slot' + dst = binary.LittleEndian.AppendUint64(dst, uint64(t.Slot)) + } + { // Static Field #1 'ProposerIndex' + dst = binary.LittleEndian.AppendUint64(dst, uint64(t.ProposerIndex)) + } + { // Static Field #2 'ParentRoot' + dst = append(dst, t.ParentRoot[:32]...) + } + { // Static Field #3 'StateRoot' + dst = append(dst, t.StateRoot[:32]...) + } + // Offset Field #4 'Body' + dst = append(dst, 0, 0, 0, 0) + { // Dynamic Field #4 'Body' + binary.LittleEndian.PutUint32(dst[dstlen+80:], uint32(len(dst)-dstlen)) + t := t.Body + if t == nil { + t = new(all.BeaconBlockBody) + } + dstlen := len(dst) + { // Static Field #0 'RANDAOReveal' + dst = append(dst, t.RANDAOReveal[:96]...) + } + { // Static Field #1 'ETH1Data' + t := t.ETH1Data + if t == nil { + t = new(phase0.ETH1Data) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "SignedBlock.Message.Body.ETH1Data") + } + } + { // Static Field #2 'Graffiti' + dst = append(dst, t.Graffiti[:32]...) + } + // Offset Field #3 'ProposerSlashings' + // Offset Field #4 'AttesterSlashings' + // Offset Field #5 'Attestations' + // Offset Field #6 'Deposits' + // Offset Field #7 'VoluntaryExits' + dst = append(dst, zeroBytes[:20]...) + { // Static Field #8 'SyncAggregate' + t := t.SyncAggregate + if t == nil { + t = new(altair.SyncAggregate) + } + { // Static Field #0 'SyncCommitteeBits' + vlen := len(t.SyncCommitteeBits) + if vlen > int(expr0) { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(expr0)), "SignedBlock.Message.Body.SyncAggregate.SyncCommitteeBits") + } + dst = append(dst, t.SyncCommitteeBits[:vlen]...) + if vlen < int(expr0) { + dst = sszutils.AppendZeroPadding(dst, (int(expr0)-vlen)*1) + } + } + { // Static Field #1 'SyncCommitteeSignature' + dst = append(dst, t.SyncCommitteeSignature[:96]...) + } + } + // Offset Field #9 'ExecutionPayload' + offset9 := len(dst) + // Offset Field #10 'BLSToExecutionChanges' + // Offset Field #11 'BlobKZGCommitments' + // Offset Field #12 'ExecutionRequests' + dst = append(dst, zeroBytes[:16]...) + { // Dynamic Field #3 'ProposerSlashings' + binary.LittleEndian.PutUint32(dst[dstlen+200:], uint32(len(dst)-dstlen)) + t := t.ProposerSlashings + vlen := len(t) + if vlen > int(expr1) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr1)), "SignedBlock.Message.Body.ProposerSlashings") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(phase0.ProposerSlashing) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.ProposerSlashings[%d]", idx1) + } + } + } + { // Dynamic Field #4 'AttesterSlashings' + binary.LittleEndian.PutUint32(dst[dstlen+204:], uint32(len(dst)-dstlen)) + t := t.AttesterSlashings + vlen := len(t) + if vlen > int(expr2) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr2)), "SignedBlock.Message.Body.AttesterSlashings") + } + dstlen := len(dst) + dst = sszutils.AppendZeroPadding(dst, vlen*4) + for idx1 := range vlen { + binary.LittleEndian.PutUint32(dst[dstlen+(idx1*4):], uint32(len(dst)-dstlen)) + t := t[idx1] + if t == nil { + t = new(all.AttesterSlashing) + } + dstlen := len(dst) + // Offset Field #0 'Attestation1' + // Offset Field #1 'Attestation2' + dst = append(dst, 0, 0, 0, 0, 0, 0, 0, 0) + { // Dynamic Field #0 'Attestation1' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.Attestation1 + if t == nil { + t = new(all.IndexedAttestation) + } + dstlen := len(dst) + // Offset Field #0 'AttestingIndices' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.AttestationData) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.AttesterSlashings[%d].Attestation1.Data", idx1) + } + } + { // Static Field #2 'Signature' + dst = append(dst, t.Signature[:96]...) + } + { // Dynamic Field #0 'AttestingIndices' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.AttestingIndices + vlen := len(t) + if vlen > int(expr3) { + return nil, sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(vlen, int(expr3)), "SignedBlock.Message.Body.AttesterSlashings[%d].Attestation1.AttestingIndices", idx1) + } + dst = sszutils.MarshalUint64Slice(dst, t[:vlen]) + } + } + { // Dynamic Field #1 'Attestation2' + binary.LittleEndian.PutUint32(dst[dstlen+4:], uint32(len(dst)-dstlen)) + t := t.Attestation2 + if t == nil { + t = new(all.IndexedAttestation) + } + dstlen := len(dst) + // Offset Field #0 'AttestingIndices' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.AttestationData) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.AttesterSlashings[%d].Attestation2.Data", idx1) + } + } + { // Static Field #2 'Signature' + dst = append(dst, t.Signature[:96]...) + } + { // Dynamic Field #0 'AttestingIndices' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.AttestingIndices + vlen := len(t) + if vlen > int(expr3) { + return nil, sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(vlen, int(expr3)), "SignedBlock.Message.Body.AttesterSlashings[%d].Attestation2.AttestingIndices", idx1) + } + dst = sszutils.MarshalUint64Slice(dst, t[:vlen]) + } + } + } + } + { // Dynamic Field #5 'Attestations' + binary.LittleEndian.PutUint32(dst[dstlen+208:], uint32(len(dst)-dstlen)) + t := t.Attestations + vlen := len(t) + if vlen > int(expr4) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr4)), "SignedBlock.Message.Body.Attestations") + } + dstlen := len(dst) + dst = sszutils.AppendZeroPadding(dst, vlen*4) + for idx1 := range vlen { + binary.LittleEndian.PutUint32(dst[dstlen+(idx1*4):], uint32(len(dst)-dstlen)) + t := t[idx1] + if t == nil { + t = new(all.Attestation) + } + dstlen := len(dst) + // Offset Field #0 'AggregationBits' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.AttestationData) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.Attestations[%d].Data", idx1) + } + } + { // Static Field #2 'Signature' + dst = append(dst, t.Signature[:96]...) + } + { // Static Field #3 'CommitteeBits' + vlen := len(t.CommitteeBits) + if vlen > int(expr5) { + return nil, sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, int(expr5)), "SignedBlock.Message.Body.Attestations[%d].CommitteeBits", idx1) + } + dst = append(dst, t.CommitteeBits[:vlen]...) + if vlen < int(expr5) { + dst = sszutils.AppendZeroPadding(dst, (int(expr5)-vlen)*1) + } + } + { // Dynamic Field #0 'AggregationBits' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.AggregationBits + vlen := len(t) + bval := []byte(t[:]) + if vlen == 0 { + bval = []byte{0x01} + } else if bval[vlen-1] == 0x00 { + return nil, sszutils.ErrorWithPathf(sszutils.ErrBitlistNotTerminatedFn(), "SignedBlock.Message.Body.Attestations[%d].AggregationBits", idx1) + } + if vlen > 0 { + bitCount := 8*(vlen-1) + bits.Len8(bval[vlen-1]) - 1 + if bitCount > int(expr3) { + return nil, sszutils.ErrorWithPathf(sszutils.ErrBitlistLengthFn(bitCount, int(expr3)), "SignedBlock.Message.Body.Attestations[%d].AggregationBits", idx1) + } + } + dst = append(dst, bval...) + } + } + } + { // Dynamic Field #6 'Deposits' + binary.LittleEndian.PutUint32(dst[dstlen+212:], uint32(len(dst)-dstlen)) + t := t.Deposits + vlen := len(t) + if vlen > int(expr6) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr6)), "SignedBlock.Message.Body.Deposits") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(phase0.Deposit) + } + { // Static Field #0 'Proof' + t := t.Proof + vlen := len(t) + if vlen > int(expr7) { + return nil, sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, int(expr7)), "SignedBlock.Message.Body.Deposits[%d].Proof", idx1) + } + for idx2 := range vlen { + vlen := len(t[idx2]) + if vlen > 32 { + return nil, sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, 32), "SignedBlock.Message.Body.Deposits[%d].Proof[%d]", idx1, idx2) + } + dst = append(dst, t[idx2][:vlen]...) + if vlen < 32 { + dst = sszutils.AppendZeroPadding(dst, (32-vlen)*1) + } + } + if vlen < int(expr7) { + dst = sszutils.AppendZeroPadding(dst, (int(expr7)-vlen)*32) + } + } + { // Static Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.DepositData) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.Deposits[%d].Data", idx1) + } + } + } + } + { // Dynamic Field #7 'VoluntaryExits' + binary.LittleEndian.PutUint32(dst[dstlen+216:], uint32(len(dst)-dstlen)) + t := t.VoluntaryExits + vlen := len(t) + if vlen > int(expr8) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr8)), "SignedBlock.Message.Body.VoluntaryExits") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(phase0.SignedVoluntaryExit) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.VoluntaryExits[%d]", idx1) + } + } + } + { // Dynamic Field #9 'ExecutionPayload' + binary.LittleEndian.PutUint32(dst[offset9:], uint32(len(dst)-dstlen)) + t := t.ExecutionPayload + if t == nil { + t = new(all.ExecutionPayload) + } + dstlen := len(dst) + { // Static Field #0 'ParentHash' + dst = append(dst, t.ParentHash[:32]...) + } + { // Static Field #1 'FeeRecipient' + dst = append(dst, t.FeeRecipient[:20]...) + } + { // Static Field #2 'StateRoot' + dst = append(dst, t.StateRoot[:32]...) + } + { // Static Field #3 'ReceiptsRoot' + dst = append(dst, t.ReceiptsRoot[:32]...) + } + { // Static Field #4 'LogsBloom' + dst = append(dst, t.LogsBloom[:256]...) + } + { // Static Field #5 'PrevRandao' + dst = append(dst, t.PrevRandao[:32]...) + } + { // Static Field #6 'BlockNumber' + dst = binary.LittleEndian.AppendUint64(dst, t.BlockNumber) + } + { // Static Field #7 'GasLimit' + dst = binary.LittleEndian.AppendUint64(dst, t.GasLimit) + } + { // Static Field #8 'GasUsed' + dst = binary.LittleEndian.AppendUint64(dst, t.GasUsed) + } + { // Static Field #9 'Timestamp' + dst = binary.LittleEndian.AppendUint64(dst, t.Timestamp) + } + // Offset Field #10 'ExtraData' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #11 'BaseFeePerGas' + t := t.BaseFeePerGas + if t == nil { + t = new(uint256.Int) + } + dst = sszutils.MarshalUint64Slice(dst, (*t)[:4]) + } + { // Static Field #12 'BlockHash' + dst = append(dst, t.BlockHash[:32]...) + } + // Offset Field #13 'Transactions' + // Offset Field #14 'Withdrawals' + dst = append(dst, 0, 0, 0, 0, 0, 0, 0, 0) + { // Static Field #15 'BlobGasUsed' + dst = binary.LittleEndian.AppendUint64(dst, t.BlobGasUsed) + } + { // Static Field #16 'ExcessBlobGas' + dst = binary.LittleEndian.AppendUint64(dst, t.ExcessBlobGas) + } + { // Dynamic Field #10 'ExtraData' + binary.LittleEndian.PutUint32(dst[dstlen+436:], uint32(len(dst)-dstlen)) + vlen := len(t.ExtraData) + if vlen > int(expr9) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr9)), "SignedBlock.Message.Body.ExecutionPayload.ExtraData") + } + dst = append(dst, t.ExtraData[:]...) + } + { // Dynamic Field #13 'Transactions' + binary.LittleEndian.PutUint32(dst[dstlen+504:], uint32(len(dst)-dstlen)) + t := t.Transactions + vlen := len(t) + if vlen > int(expr10) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr10)), "SignedBlock.Message.Body.ExecutionPayload.Transactions") + } + dstlen := len(dst) + dst = sszutils.AppendZeroPadding(dst, vlen*4) + for idx1 := range vlen { + binary.LittleEndian.PutUint32(dst[dstlen+(idx1*4):], uint32(len(dst)-dstlen)) + vlen := len(t[idx1]) + if vlen > int(expr11) { + return nil, sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(vlen, int(expr11)), "SignedBlock.Message.Body.ExecutionPayload.Transactions[%d]", idx1) + } + dst = append(dst, t[idx1][:]...) + } + } + { // Dynamic Field #14 'Withdrawals' + binary.LittleEndian.PutUint32(dst[dstlen+508:], uint32(len(dst)-dstlen)) + t := t.Withdrawals + vlen := len(t) + if vlen > int(expr12) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr12)), "SignedBlock.Message.Body.ExecutionPayload.Withdrawals") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(capella.Withdrawal) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.ExecutionPayload.Withdrawals[%d]", idx1) + } + } + } + } + { // Dynamic Field #10 'BLSToExecutionChanges' + binary.LittleEndian.PutUint32(dst[offset9+4:], uint32(len(dst)-dstlen)) + t := t.BLSToExecutionChanges + vlen := len(t) + if vlen > int(expr13) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr13)), "SignedBlock.Message.Body.BLSToExecutionChanges") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(capella.SignedBLSToExecutionChange) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.BLSToExecutionChanges[%d]", idx1) + } + } + } + { // Dynamic Field #11 'BlobKZGCommitments' + binary.LittleEndian.PutUint32(dst[offset9+8:], uint32(len(dst)-dstlen)) + t := t.BlobKZGCommitments + vlen := len(t) + if vlen > int(expr14) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr14)), "SignedBlock.Message.Body.BlobKZGCommitments") + } + dst = sszutils.MarshalFixedBytesSlice(dst, t[:vlen]) + } + { // Dynamic Field #12 'ExecutionRequests' + binary.LittleEndian.PutUint32(dst[offset9+12:], uint32(len(dst)-dstlen)) + t := t.ExecutionRequests + if t == nil { + t = new(all.ExecutionRequests) + } + dstlen := len(dst) + // Offset Field #0 'Deposits' + // Offset Field #1 'Withdrawals' + // Offset Field #2 'Consolidations' + dst = append(dst, zeroBytes[:12]...) + { // Dynamic Field #0 'Deposits' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.Deposits + vlen := len(t) + if vlen > int(expr15) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr15)), "SignedBlock.Message.Body.ExecutionRequests.Deposits") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(electra1.DepositRequest) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.ExecutionRequests.Deposits[%d]", idx1) + } + } + } + { // Dynamic Field #1 'Withdrawals' + binary.LittleEndian.PutUint32(dst[dstlen+4:], uint32(len(dst)-dstlen)) + t := t.Withdrawals + vlen := len(t) + if vlen > int(expr16) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr16)), "SignedBlock.Message.Body.ExecutionRequests.Withdrawals") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(electra1.WithdrawalRequest) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.ExecutionRequests.Withdrawals[%d]", idx1) + } + } + } + { // Dynamic Field #2 'Consolidations' + binary.LittleEndian.PutUint32(dst[dstlen+8:], uint32(len(dst)-dstlen)) + t := t.Consolidations + vlen := len(t) + if vlen > int(expr17) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr17)), "SignedBlock.Message.Body.ExecutionRequests.Consolidations") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(electra1.ConsolidationRequest) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.ExecutionRequests.Consolidations[%d]", idx1) + } + } + } + } + } + } + } + { // Dynamic Field #1 'KZGProofs' + binary.LittleEndian.PutUint32(dst[dstlen+4:], uint32(len(dst)-dstlen)) + t := t.KZGProofs + vlen := len(t) + if vlen > int(expr14) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr14)), "KZGProofs") + } + dst = sszutils.MarshalFixedBytesSlice(dst, t[:vlen]) + } + { // Dynamic Field #2 'Blobs' + binary.LittleEndian.PutUint32(dst[dstlen+8:], uint32(len(dst)-dstlen)) + t := t.Blobs + vlen := len(t) + if vlen > int(expr14) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr14)), "Blobs") + } + dst = sszutils.MarshalFixedBytesSlice(dst, t[:vlen]) + } + return dst, nil +} + +func (t *SignedBlockContents) marshalSSZView_SignedBlockContents_1(ds sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + dst = buf + expr0, err := sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE/8", 64) + if err != nil { + return dst, err + } + expr1, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_PROPOSER_SLASHINGS", 16) + if err != nil { + return dst, err + } + expr2, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_ATTESTER_SLASHINGS_ELECTRA", 1) + if err != nil { + return dst, err + } + expr3, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_VALIDATORS_PER_COMMITTEE*MAX_COMMITTEES_PER_SLOT", 131072) + if err != nil { + return dst, err + } + expr4, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_ATTESTATIONS_ELECTRA", 8) + if err != nil { + return dst, err + } + expr5, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_COMMITTEES_PER_SLOT/8", 8) + if err != nil { + return dst, err + } + expr6, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_DEPOSITS", 16) + if err != nil { + return dst, err + } + expr7, err := sszutils.ResolveSpecValueWithDefault(ds, "DEPOSIT_CONTRACT_TREE_DEPTH+1", 33) + if err != nil { + return dst, err + } + expr8, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_VOLUNTARY_EXITS", 16) + if err != nil { + return dst, err + } + expr9, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_EXTRA_DATA_BYTES", 32) + if err != nil { + return dst, err + } + expr10, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_TRANSACTIONS_PER_PAYLOAD", 1048576) + if err != nil { + return dst, err + } + expr11, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BYTES_PER_TRANSACTION", 1073741824) + if err != nil { + return dst, err + } + expr12, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_WITHDRAWALS_PER_PAYLOAD", 16) + if err != nil { + return dst, err + } + expr13, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BLS_TO_EXECUTION_CHANGES", 16) + if err != nil { + return dst, err + } + expr14, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BLOB_COMMITMENTS_PER_BLOCK", 4096) + if err != nil { + return dst, err + } + expr15, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_DEPOSIT_REQUESTS_PER_PAYLOAD", 8192) + if err != nil { + return dst, err + } + expr16, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_WITHDRAWAL_REQUESTS_PER_PAYLOAD", 16) + if err != nil { + return dst, err + } + expr17, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD", 2) + if err != nil { + return dst, err + } + zeroBytes := sszutils.ZeroBytes() + if t == nil { + t = new(SignedBlockContents) + } + dstlen := len(dst) + // Offset Field #0 'SignedBlock' + // Offset Field #1 'KZGProofs' + // Offset Field #2 'Blobs' + dst = append(dst, zeroBytes[:12]...) + { // Dynamic Field #0 'SignedBlock' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.SignedBlock + if t == nil { + t = new(all.SignedBeaconBlock) + } + dstlen := len(dst) + // Offset Field #0 'Message' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #1 'Signature' + dst = append(dst, t.Signature[:96]...) + } + { // Dynamic Field #0 'Message' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.Message + if t == nil { + t = new(all.BeaconBlock) + } + dstlen := len(dst) + { // Static Field #0 'Slot' + dst = binary.LittleEndian.AppendUint64(dst, uint64(t.Slot)) + } + { // Static Field #1 'ProposerIndex' + dst = binary.LittleEndian.AppendUint64(dst, uint64(t.ProposerIndex)) + } + { // Static Field #2 'ParentRoot' + dst = append(dst, t.ParentRoot[:32]...) + } + { // Static Field #3 'StateRoot' + dst = append(dst, t.StateRoot[:32]...) + } + // Offset Field #4 'Body' + dst = append(dst, 0, 0, 0, 0) + { // Dynamic Field #4 'Body' + binary.LittleEndian.PutUint32(dst[dstlen+80:], uint32(len(dst)-dstlen)) + t := t.Body + if t == nil { + t = new(all.BeaconBlockBody) + } + dstlen := len(dst) + { // Static Field #0 'RANDAOReveal' + dst = append(dst, t.RANDAOReveal[:96]...) + } + { // Static Field #1 'ETH1Data' + t := t.ETH1Data + if t == nil { + t = new(phase0.ETH1Data) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "SignedBlock.Message.Body.ETH1Data") + } + } + { // Static Field #2 'Graffiti' + dst = append(dst, t.Graffiti[:32]...) + } + // Offset Field #3 'ProposerSlashings' + // Offset Field #4 'AttesterSlashings' + // Offset Field #5 'Attestations' + // Offset Field #6 'Deposits' + // Offset Field #7 'VoluntaryExits' + dst = append(dst, zeroBytes[:20]...) + { // Static Field #8 'SyncAggregate' + t := t.SyncAggregate + if t == nil { + t = new(altair.SyncAggregate) + } + { // Static Field #0 'SyncCommitteeBits' + vlen := len(t.SyncCommitteeBits) + if vlen > int(expr0) { + return nil, sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(expr0)), "SignedBlock.Message.Body.SyncAggregate.SyncCommitteeBits") + } + dst = append(dst, t.SyncCommitteeBits[:vlen]...) + if vlen < int(expr0) { + dst = sszutils.AppendZeroPadding(dst, (int(expr0)-vlen)*1) + } + } + { // Static Field #1 'SyncCommitteeSignature' + dst = append(dst, t.SyncCommitteeSignature[:96]...) + } + } + // Offset Field #9 'ExecutionPayload' + offset9 := len(dst) + // Offset Field #10 'BLSToExecutionChanges' + // Offset Field #11 'BlobKZGCommitments' + // Offset Field #12 'ExecutionRequests' + dst = append(dst, zeroBytes[:16]...) + { // Dynamic Field #3 'ProposerSlashings' + binary.LittleEndian.PutUint32(dst[dstlen+200:], uint32(len(dst)-dstlen)) + t := t.ProposerSlashings + vlen := len(t) + if vlen > int(expr1) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr1)), "SignedBlock.Message.Body.ProposerSlashings") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(phase0.ProposerSlashing) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.ProposerSlashings[%d]", idx1) + } + } + } + { // Dynamic Field #4 'AttesterSlashings' + binary.LittleEndian.PutUint32(dst[dstlen+204:], uint32(len(dst)-dstlen)) + t := t.AttesterSlashings + vlen := len(t) + if vlen > int(expr2) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr2)), "SignedBlock.Message.Body.AttesterSlashings") + } + dstlen := len(dst) + dst = sszutils.AppendZeroPadding(dst, vlen*4) + for idx1 := range vlen { + binary.LittleEndian.PutUint32(dst[dstlen+(idx1*4):], uint32(len(dst)-dstlen)) + t := t[idx1] + if t == nil { + t = new(all.AttesterSlashing) + } + dstlen := len(dst) + // Offset Field #0 'Attestation1' + // Offset Field #1 'Attestation2' + dst = append(dst, 0, 0, 0, 0, 0, 0, 0, 0) + { // Dynamic Field #0 'Attestation1' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.Attestation1 + if t == nil { + t = new(all.IndexedAttestation) + } + dstlen := len(dst) + // Offset Field #0 'AttestingIndices' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.AttestationData) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.AttesterSlashings[%d].Attestation1.Data", idx1) + } + } + { // Static Field #2 'Signature' + dst = append(dst, t.Signature[:96]...) + } + { // Dynamic Field #0 'AttestingIndices' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.AttestingIndices + vlen := len(t) + if vlen > int(expr3) { + return nil, sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(vlen, int(expr3)), "SignedBlock.Message.Body.AttesterSlashings[%d].Attestation1.AttestingIndices", idx1) + } + dst = sszutils.MarshalUint64Slice(dst, t[:vlen]) + } + } + { // Dynamic Field #1 'Attestation2' + binary.LittleEndian.PutUint32(dst[dstlen+4:], uint32(len(dst)-dstlen)) + t := t.Attestation2 + if t == nil { + t = new(all.IndexedAttestation) + } + dstlen := len(dst) + // Offset Field #0 'AttestingIndices' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.AttestationData) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.AttesterSlashings[%d].Attestation2.Data", idx1) + } + } + { // Static Field #2 'Signature' + dst = append(dst, t.Signature[:96]...) + } + { // Dynamic Field #0 'AttestingIndices' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.AttestingIndices + vlen := len(t) + if vlen > int(expr3) { + return nil, sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(vlen, int(expr3)), "SignedBlock.Message.Body.AttesterSlashings[%d].Attestation2.AttestingIndices", idx1) + } + dst = sszutils.MarshalUint64Slice(dst, t[:vlen]) + } + } + } + } + { // Dynamic Field #5 'Attestations' + binary.LittleEndian.PutUint32(dst[dstlen+208:], uint32(len(dst)-dstlen)) + t := t.Attestations + vlen := len(t) + if vlen > int(expr4) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr4)), "SignedBlock.Message.Body.Attestations") + } + dstlen := len(dst) + dst = sszutils.AppendZeroPadding(dst, vlen*4) + for idx1 := range vlen { + binary.LittleEndian.PutUint32(dst[dstlen+(idx1*4):], uint32(len(dst)-dstlen)) + t := t[idx1] + if t == nil { + t = new(all.Attestation) + } + dstlen := len(dst) + // Offset Field #0 'AggregationBits' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.AttestationData) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.Attestations[%d].Data", idx1) + } + } + { // Static Field #2 'Signature' + dst = append(dst, t.Signature[:96]...) + } + { // Static Field #3 'CommitteeBits' + vlen := len(t.CommitteeBits) + if vlen > int(expr5) { + return nil, sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, int(expr5)), "SignedBlock.Message.Body.Attestations[%d].CommitteeBits", idx1) + } + dst = append(dst, t.CommitteeBits[:vlen]...) + if vlen < int(expr5) { + dst = sszutils.AppendZeroPadding(dst, (int(expr5)-vlen)*1) + } + } + { // Dynamic Field #0 'AggregationBits' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.AggregationBits + vlen := len(t) + bval := []byte(t[:]) + if vlen == 0 { + bval = []byte{0x01} + } else if bval[vlen-1] == 0x00 { + return nil, sszutils.ErrorWithPathf(sszutils.ErrBitlistNotTerminatedFn(), "SignedBlock.Message.Body.Attestations[%d].AggregationBits", idx1) + } + if vlen > 0 { + bitCount := 8*(vlen-1) + bits.Len8(bval[vlen-1]) - 1 + if bitCount > int(expr3) { + return nil, sszutils.ErrorWithPathf(sszutils.ErrBitlistLengthFn(bitCount, int(expr3)), "SignedBlock.Message.Body.Attestations[%d].AggregationBits", idx1) + } + } + dst = append(dst, bval...) + } + } + } + { // Dynamic Field #6 'Deposits' + binary.LittleEndian.PutUint32(dst[dstlen+212:], uint32(len(dst)-dstlen)) + t := t.Deposits + vlen := len(t) + if vlen > int(expr6) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr6)), "SignedBlock.Message.Body.Deposits") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(phase0.Deposit) + } + { // Static Field #0 'Proof' + t := t.Proof + vlen := len(t) + if vlen > int(expr7) { + return nil, sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, int(expr7)), "SignedBlock.Message.Body.Deposits[%d].Proof", idx1) + } + for idx2 := range vlen { + vlen := len(t[idx2]) + if vlen > 32 { + return nil, sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, 32), "SignedBlock.Message.Body.Deposits[%d].Proof[%d]", idx1, idx2) + } + dst = append(dst, t[idx2][:vlen]...) + if vlen < 32 { + dst = sszutils.AppendZeroPadding(dst, (32-vlen)*1) + } + } + if vlen < int(expr7) { + dst = sszutils.AppendZeroPadding(dst, (int(expr7)-vlen)*32) + } + } + { // Static Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.DepositData) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.Deposits[%d].Data", idx1) + } + } + } + } + { // Dynamic Field #7 'VoluntaryExits' + binary.LittleEndian.PutUint32(dst[dstlen+216:], uint32(len(dst)-dstlen)) + t := t.VoluntaryExits + vlen := len(t) + if vlen > int(expr8) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr8)), "SignedBlock.Message.Body.VoluntaryExits") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(phase0.SignedVoluntaryExit) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.VoluntaryExits[%d]", idx1) + } + } + } + { // Dynamic Field #9 'ExecutionPayload' + binary.LittleEndian.PutUint32(dst[offset9:], uint32(len(dst)-dstlen)) + t := t.ExecutionPayload + if t == nil { + t = new(all.ExecutionPayload) + } + dstlen := len(dst) + { // Static Field #0 'ParentHash' + dst = append(dst, t.ParentHash[:32]...) + } + { // Static Field #1 'FeeRecipient' + dst = append(dst, t.FeeRecipient[:20]...) + } + { // Static Field #2 'StateRoot' + dst = append(dst, t.StateRoot[:32]...) + } + { // Static Field #3 'ReceiptsRoot' + dst = append(dst, t.ReceiptsRoot[:32]...) + } + { // Static Field #4 'LogsBloom' + dst = append(dst, t.LogsBloom[:256]...) + } + { // Static Field #5 'PrevRandao' + dst = append(dst, t.PrevRandao[:32]...) + } + { // Static Field #6 'BlockNumber' + dst = binary.LittleEndian.AppendUint64(dst, t.BlockNumber) + } + { // Static Field #7 'GasLimit' + dst = binary.LittleEndian.AppendUint64(dst, t.GasLimit) + } + { // Static Field #8 'GasUsed' + dst = binary.LittleEndian.AppendUint64(dst, t.GasUsed) + } + { // Static Field #9 'Timestamp' + dst = binary.LittleEndian.AppendUint64(dst, t.Timestamp) + } + // Offset Field #10 'ExtraData' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #11 'BaseFeePerGas' + t := t.BaseFeePerGas + if t == nil { + t = new(uint256.Int) + } + dst = sszutils.MarshalUint64Slice(dst, (*t)[:4]) + } + { // Static Field #12 'BlockHash' + dst = append(dst, t.BlockHash[:32]...) + } + // Offset Field #13 'Transactions' + // Offset Field #14 'Withdrawals' + dst = append(dst, 0, 0, 0, 0, 0, 0, 0, 0) + { // Static Field #15 'BlobGasUsed' + dst = binary.LittleEndian.AppendUint64(dst, t.BlobGasUsed) + } + { // Static Field #16 'ExcessBlobGas' + dst = binary.LittleEndian.AppendUint64(dst, t.ExcessBlobGas) + } + { // Dynamic Field #10 'ExtraData' + binary.LittleEndian.PutUint32(dst[dstlen+436:], uint32(len(dst)-dstlen)) + vlen := len(t.ExtraData) + if vlen > int(expr9) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr9)), "SignedBlock.Message.Body.ExecutionPayload.ExtraData") + } + dst = append(dst, t.ExtraData[:]...) + } + { // Dynamic Field #13 'Transactions' + binary.LittleEndian.PutUint32(dst[dstlen+504:], uint32(len(dst)-dstlen)) + t := t.Transactions + vlen := len(t) + if vlen > int(expr10) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr10)), "SignedBlock.Message.Body.ExecutionPayload.Transactions") + } + dstlen := len(dst) + dst = sszutils.AppendZeroPadding(dst, vlen*4) + for idx1 := range vlen { + binary.LittleEndian.PutUint32(dst[dstlen+(idx1*4):], uint32(len(dst)-dstlen)) + vlen := len(t[idx1]) + if vlen > int(expr11) { + return nil, sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(vlen, int(expr11)), "SignedBlock.Message.Body.ExecutionPayload.Transactions[%d]", idx1) + } + dst = append(dst, t[idx1][:]...) + } + } + { // Dynamic Field #14 'Withdrawals' + binary.LittleEndian.PutUint32(dst[dstlen+508:], uint32(len(dst)-dstlen)) + t := t.Withdrawals + vlen := len(t) + if vlen > int(expr12) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr12)), "SignedBlock.Message.Body.ExecutionPayload.Withdrawals") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(capella.Withdrawal) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.ExecutionPayload.Withdrawals[%d]", idx1) + } + } + } + } + { // Dynamic Field #10 'BLSToExecutionChanges' + binary.LittleEndian.PutUint32(dst[offset9+4:], uint32(len(dst)-dstlen)) + t := t.BLSToExecutionChanges + vlen := len(t) + if vlen > int(expr13) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr13)), "SignedBlock.Message.Body.BLSToExecutionChanges") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(capella.SignedBLSToExecutionChange) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.BLSToExecutionChanges[%d]", idx1) + } + } + } + { // Dynamic Field #11 'BlobKZGCommitments' + binary.LittleEndian.PutUint32(dst[offset9+8:], uint32(len(dst)-dstlen)) + t := t.BlobKZGCommitments + vlen := len(t) + if vlen > int(expr14) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr14)), "SignedBlock.Message.Body.BlobKZGCommitments") + } + dst = sszutils.MarshalFixedBytesSlice(dst, t[:vlen]) + } + { // Dynamic Field #12 'ExecutionRequests' + binary.LittleEndian.PutUint32(dst[offset9+12:], uint32(len(dst)-dstlen)) + t := t.ExecutionRequests + if t == nil { + t = new(all.ExecutionRequests) + } + dstlen := len(dst) + // Offset Field #0 'Deposits' + // Offset Field #1 'Withdrawals' + // Offset Field #2 'Consolidations' + dst = append(dst, zeroBytes[:12]...) + { // Dynamic Field #0 'Deposits' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.Deposits + vlen := len(t) + if vlen > int(expr15) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr15)), "SignedBlock.Message.Body.ExecutionRequests.Deposits") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(electra1.DepositRequest) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.ExecutionRequests.Deposits[%d]", idx1) + } + } + } + { // Dynamic Field #1 'Withdrawals' + binary.LittleEndian.PutUint32(dst[dstlen+4:], uint32(len(dst)-dstlen)) + t := t.Withdrawals + vlen := len(t) + if vlen > int(expr16) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr16)), "SignedBlock.Message.Body.ExecutionRequests.Withdrawals") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(electra1.WithdrawalRequest) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.ExecutionRequests.Withdrawals[%d]", idx1) + } + } + } + { // Dynamic Field #2 'Consolidations' + binary.LittleEndian.PutUint32(dst[dstlen+8:], uint32(len(dst)-dstlen)) + t := t.Consolidations + vlen := len(t) + if vlen > int(expr17) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr17)), "SignedBlock.Message.Body.ExecutionRequests.Consolidations") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(electra1.ConsolidationRequest) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.ExecutionRequests.Consolidations[%d]", idx1) + } + } + } + } + } + } + } + { // Dynamic Field #1 'KZGProofs' + binary.LittleEndian.PutUint32(dst[dstlen+4:], uint32(len(dst)-dstlen)) + t := t.KZGProofs + vlen := len(t) + if vlen > 33554432 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 33554432), "KZGProofs") + } + dst = sszutils.MarshalFixedBytesSlice(dst, t[:vlen]) + } + { // Dynamic Field #2 'Blobs' + binary.LittleEndian.PutUint32(dst[dstlen+8:], uint32(len(dst)-dstlen)) + t := t.Blobs + vlen := len(t) + if vlen > 4096 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 4096), "Blobs") + } + dst = sszutils.MarshalFixedBytesSlice(dst, t[:vlen]) + } + return dst, nil +} + +func (t *SignedBlockContents) UnmarshalSSZDynView(view any) func(ds sszutils.DynamicSpecs, buf []byte) error { + switch view.(type) { + case *deneb.SignedBlockContents: + return t.unmarshalSSZView_SignedBlockContents + case *electra.SignedBlockContents: + return t.unmarshalSSZView_SignedBlockContents_0 + case *fulu.SignedBlockContents: + return t.unmarshalSSZView_SignedBlockContents_1 + } + return nil +} +func (t *SignedBlockContents) unmarshalSSZView_SignedBlockContents(ds sszutils.DynamicSpecs, buf []byte) (err error) { + expr0, err := sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE/8", 64) + if err != nil { + return err + } + expr1, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_PROPOSER_SLASHINGS", 16) + if err != nil { + return err + } + expr2, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_ATTESTER_SLASHINGS", 2) + if err != nil { + return err + } + expr3, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_ATTESTATIONS", 128) + if err != nil { + return err + } + expr4, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_VALIDATORS_PER_COMMITTEE", 2048) + if err != nil { + return err + } + expr5, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_DEPOSITS", 16) + if err != nil { + return err + } + expr6, err := sszutils.ResolveSpecValueWithDefault(ds, "DEPOSIT_CONTRACT_TREE_DEPTH+1", 33) + if err != nil { + return err + } + expr7, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_VOLUNTARY_EXITS", 16) + if err != nil { + return err + } + expr8, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_EXTRA_DATA_BYTES", 32) + if err != nil { + return err + } + expr9, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_TRANSACTIONS_PER_PAYLOAD", 1048576) + if err != nil { + return err + } + expr10, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BYTES_PER_TRANSACTION", 1073741824) + if err != nil { + return err + } + expr11, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_WITHDRAWALS_PER_PAYLOAD", 16) + if err != nil { + return err + } + expr12, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BLS_TO_EXECUTION_CHANGES", 16) + if err != nil { + return err + } + expr13, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BLOB_COMMITMENTS_PER_BLOCK", 4096) + if err != nil { + return err + } + size2 := 1 * int(expr0) + size1 := size2 + 96 // size expression for '*SyncAggregate' + size4 := 32 * int(expr6) + size3 := size4 + 184 // size expression for '*Deposit' + buflen := len(buf) + if buflen < 12 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 12) + } + // Field #0 'SignedBlock' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 12 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset0, 12), "SignedBlock:o") + } + // Field #1 'KZGProofs' (offset) + offset1 := int(binary.LittleEndian.Uint32(buf[4:8])) + if offset1 < offset0 || offset1 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset1, offset0, buflen), "KZGProofs:o") + } + // Field #2 'Blobs' (offset) + offset2 := int(binary.LittleEndian.Uint32(buf[8:12])) + if offset2 < offset1 || offset2 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset2, offset1, buflen), "Blobs:o") + } + { // Field #0 'SignedBlock' (dynamic) + buf := buf[offset0:offset1] + if t.SignedBlock == nil { + t.SignedBlock = new(all.SignedBeaconBlock) + } + buflen := len(buf) + if buflen < 100 { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, 100), "SignedBlock") + } + // Field #0 'Message' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 100 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset0, 100), "SignedBlock.Message:o") + } + { // Field #1 'Signature' (static) + buf := buf[4:100] + copy(t.SignedBlock.Signature[:], buf) + } + { // Field #0 'Message' (dynamic) + buf := buf[offset0:] + if t.SignedBlock.Message == nil { + t.SignedBlock.Message = new(all.BeaconBlock) + } + buflen := len(buf) + if buflen < 84 { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, 84), "SignedBlock.Message") + } + { // Field #0 'Slot' (static) + buf := buf[0:8] + t.SignedBlock.Message.Slot = phase0.Slot(binary.LittleEndian.Uint64(buf)) + } + { // Field #1 'ProposerIndex' (static) + buf := buf[8:16] + t.SignedBlock.Message.ProposerIndex = phase0.ValidatorIndex(binary.LittleEndian.Uint64(buf)) + } + { // Field #2 'ParentRoot' (static) + buf := buf[16:48] + copy(t.SignedBlock.Message.ParentRoot[:], buf) + } + { // Field #3 'StateRoot' (static) + buf := buf[48:80] + copy(t.SignedBlock.Message.StateRoot[:], buf) + } + // Field #4 'Body' (offset) + offset4 := int(binary.LittleEndian.Uint32(buf[80:84])) + if offset4 != 84 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset4, 84), "SignedBlock.Message.Body:o") + } + { // Field #4 'Body' (dynamic) + buf := buf[offset4:] + if t.SignedBlock.Message.Body == nil { + t.SignedBlock.Message.Body = new(all.BeaconBlockBody) + } + exproffset := 0 + totalSize := size1 + 232 + buflen := len(buf) + if buflen < totalSize { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, totalSize), "SignedBlock.Message.Body") + } + { // Field #0 'RANDAOReveal' (static) + buf := buf[0:96] + copy(t.SignedBlock.Message.Body.RANDAOReveal[:], buf) + } + { // Field #1 'ETH1Data' (static) + buf := buf[96:168] + if t.SignedBlock.Message.Body.ETH1Data == nil { + t.SignedBlock.Message.Body.ETH1Data = new(phase0.ETH1Data) + } + if err = t.SignedBlock.Message.Body.ETH1Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "SignedBlock.Message.Body.ETH1Data") + } + } + { // Field #2 'Graffiti' (static) + buf := buf[168:200] + copy(t.SignedBlock.Message.Body.Graffiti[:], buf) + } + // Field #3 'ProposerSlashings' (offset) + offset3 := int(binary.LittleEndian.Uint32(buf[200:204])) + if offset3 != totalSize { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset3, totalSize), "SignedBlock.Message.Body.ProposerSlashings:o") + } + // Field #4 'AttesterSlashings' (offset) + offset4 := int(binary.LittleEndian.Uint32(buf[204:208])) + if offset4 < offset3 || offset4 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset4, offset3, buflen), "SignedBlock.Message.Body.AttesterSlashings:o") + } + // Field #5 'Attestations' (offset) + offset5 := int(binary.LittleEndian.Uint32(buf[208:212])) + if offset5 < offset4 || offset5 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset5, offset4, buflen), "SignedBlock.Message.Body.Attestations:o") + } + // Field #6 'Deposits' (offset) + offset6 := int(binary.LittleEndian.Uint32(buf[212:216])) + if offset6 < offset5 || offset6 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset6, offset5, buflen), "SignedBlock.Message.Body.Deposits:o") + } + // Field #7 'VoluntaryExits' (offset) + offset7 := int(binary.LittleEndian.Uint32(buf[216:220])) + if offset7 < offset6 || offset7 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset7, offset6, buflen), "SignedBlock.Message.Body.VoluntaryExits:o") + } + { // Field #8 'SyncAggregate' (static) + buf := buf[220 : size1+220] + exproffset += int(size1) + val1 := t.SignedBlock.Message.Body.SyncAggregate + if val1 == nil { + val1 = new(altair.SyncAggregate) + } + exproffset := 0 + totalSize := size2 + 96 + buflen := len(buf) + if buflen < totalSize { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, totalSize), "SignedBlock.Message.Body.SyncAggregate") + } + if buflen > totalSize { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(buflen-totalSize), "SignedBlock.Message.Body.SyncAggregate") + } + { // Field #0 'SyncCommitteeBits' (static) + buf := buf[0 : size2+0] + exproffset += int(size2) + val1.SyncCommitteeBits = sszutils.ExpandSlice(val1.SyncCommitteeBits, int(expr0)) + copy(val1.SyncCommitteeBits[:], buf) + } + { // Field #1 'SyncCommitteeSignature' (static) + buf := buf[exproffset+0 : exproffset+96] + copy(val1.SyncCommitteeSignature[:], buf) + } + t.SignedBlock.Message.Body.SyncAggregate = val1 + } + // Field #9 'ExecutionPayload' (offset) + offset9 := int(binary.LittleEndian.Uint32(buf[exproffset+220 : exproffset+224])) + if offset9 < offset7 || offset9 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset9, offset7, buflen), "SignedBlock.Message.Body.ExecutionPayload:o") + } + // Field #10 'BLSToExecutionChanges' (offset) + offset10 := int(binary.LittleEndian.Uint32(buf[exproffset+224 : exproffset+228])) + if offset10 < offset9 || offset10 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset10, offset9, buflen), "SignedBlock.Message.Body.BLSToExecutionChanges:o") + } + // Field #11 'BlobKZGCommitments' (offset) + offset11 := int(binary.LittleEndian.Uint32(buf[exproffset+228 : exproffset+232])) + if offset11 < offset10 || offset11 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset11, offset10, buflen), "SignedBlock.Message.Body.BlobKZGCommitments:o") + } + { // Field #3 'ProposerSlashings' (dynamic) + buf := buf[offset3:offset4] + val2 := t.SignedBlock.Message.Body.ProposerSlashings + itemCount := len(buf) / 416 + if len(buf)%416 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 416), "SignedBlock.Message.Body.ProposerSlashings") + } + if itemCount > int(expr1) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr1)), "SignedBlock.Message.Body.ProposerSlashings") + } + val2 = sszutils.ExpandSlice(val2, itemCount) + for idx1 := range itemCount { + if val2[idx1] == nil { + val2[idx1] = new(phase0.ProposerSlashing) + } + buf := buf[416*idx1 : 416*(idx1+1)] + if err = val2[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.ProposerSlashings[%d]", idx1) + } + } + t.SignedBlock.Message.Body.ProposerSlashings = val2 + } + { // Field #4 'AttesterSlashings' (dynamic) + buf := buf[offset4:offset5] + val3 := t.SignedBlock.Message.Body.AttesterSlashings + startOffset := int(0) + if len(buf) != 0 { + if len(buf) < 4 { + return sszutils.ErrorWithPath(sszutils.ErrListOffsetsEOFFn(len(buf), 4), "SignedBlock.Message.Body.AttesterSlashings") + } + startOffset = int(binary.LittleEndian.Uint32(buf[0:4])) + } + itemCount := startOffset / 4 + if startOffset%4 != 0 || len(buf) < startOffset || (len(buf) != 0 && startOffset == 0) { + return sszutils.ErrorWithPath(sszutils.ErrInvalidListStartOffsetFn(startOffset, len(buf)), "SignedBlock.Message.Body.AttesterSlashings") + } + if itemCount > int(expr2) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr2)), "SignedBlock.Message.Body.AttesterSlashings") + } + val3 = sszutils.ExpandSlice(val3, 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)), "SignedBlock.Message.Body.AttesterSlashings[%d]", idx1) + } + buf := buf[startOffset:endOffset] + startOffset = endOffset + val4 := val3[idx1] + if val4 == nil { + val4 = new(all.AttesterSlashing) + } + buflen := len(buf) + if buflen < 8 { + return sszutils.ErrorWithPathf(sszutils.ErrFixedFieldsEOFFn(buflen, 8), "SignedBlock.Message.Body.AttesterSlashings[%d]", idx1) + } + // Field #0 'Attestation1' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 8 { + return sszutils.ErrorWithPathf(sszutils.ErrFirstOffsetMismatchFn(offset0, 8), "SignedBlock.Message.Body.AttesterSlashings[%d].Attestation1:o", idx1) + } + // Field #1 'Attestation2' (offset) + offset1 := int(binary.LittleEndian.Uint32(buf[4:8])) + if offset1 < offset0 || offset1 > buflen { + return sszutils.ErrorWithPathf(sszutils.ErrOffsetOutOfRangeFn(offset1, offset0, buflen), "SignedBlock.Message.Body.AttesterSlashings[%d].Attestation2:o", idx1) + } + { // Field #0 'Attestation1' (dynamic) + buf := buf[offset0:offset1] + if val4.Attestation1 == nil { + val4.Attestation1 = new(all.IndexedAttestation) + } + buflen := len(buf) + if buflen < 228 { + return sszutils.ErrorWithPathf(sszutils.ErrFixedFieldsEOFFn(buflen, 228), "SignedBlock.Message.Body.AttesterSlashings[%d].Attestation1", idx1) + } + // Field #0 'AttestingIndices' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 228 { + return sszutils.ErrorWithPathf(sszutils.ErrFirstOffsetMismatchFn(offset0, 228), "SignedBlock.Message.Body.AttesterSlashings[%d].Attestation1.AttestingIndices:o", idx1) + } + { // Field #1 'Data' (static) + buf := buf[4:132] + if val4.Attestation1.Data == nil { + val4.Attestation1.Data = new(phase0.AttestationData) + } + if err = val4.Attestation1.Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.AttesterSlashings[%d].Attestation1.Data", idx1) + } + } + { // Field #2 'Signature' (static) + buf := buf[132:228] + copy(val4.Attestation1.Signature[:], buf) + } + { // Field #0 'AttestingIndices' (dynamic) + buf := buf[offset0:] + val5 := val4.Attestation1.AttestingIndices + itemCount := len(buf) / 8 + if len(buf)%8 != 0 { + return sszutils.ErrorWithPathf(sszutils.ErrListNotAlignedFn(len(buf), 8), "SignedBlock.Message.Body.AttesterSlashings[%d].Attestation1.AttestingIndices", idx1) + } + if itemCount > 2048 { + return sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(itemCount, 2048), "SignedBlock.Message.Body.AttesterSlashings[%d].Attestation1.AttestingIndices", idx1) + } + val5 = sszutils.ExpandSlice(val5, itemCount) + sszutils.UnmarshalUint64Slice(val5, buf) + val4.Attestation1.AttestingIndices = val5 + } + } + { // Field #1 'Attestation2' (dynamic) + buf := buf[offset1:] + if val4.Attestation2 == nil { + val4.Attestation2 = new(all.IndexedAttestation) + } + buflen := len(buf) + if buflen < 228 { + return sszutils.ErrorWithPathf(sszutils.ErrFixedFieldsEOFFn(buflen, 228), "SignedBlock.Message.Body.AttesterSlashings[%d].Attestation2", idx1) + } + // Field #0 'AttestingIndices' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 228 { + return sszutils.ErrorWithPathf(sszutils.ErrFirstOffsetMismatchFn(offset0, 228), "SignedBlock.Message.Body.AttesterSlashings[%d].Attestation2.AttestingIndices:o", idx1) + } + { // Field #1 'Data' (static) + buf := buf[4:132] + if val4.Attestation2.Data == nil { + val4.Attestation2.Data = new(phase0.AttestationData) + } + if err = val4.Attestation2.Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.AttesterSlashings[%d].Attestation2.Data", idx1) + } + } + { // Field #2 'Signature' (static) + buf := buf[132:228] + copy(val4.Attestation2.Signature[:], buf) + } + { // Field #0 'AttestingIndices' (dynamic) + buf := buf[offset0:] + val6 := val4.Attestation2.AttestingIndices + itemCount := len(buf) / 8 + if len(buf)%8 != 0 { + return sszutils.ErrorWithPathf(sszutils.ErrListNotAlignedFn(len(buf), 8), "SignedBlock.Message.Body.AttesterSlashings[%d].Attestation2.AttestingIndices", idx1) + } + if itemCount > 2048 { + return sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(itemCount, 2048), "SignedBlock.Message.Body.AttesterSlashings[%d].Attestation2.AttestingIndices", idx1) + } + val6 = sszutils.ExpandSlice(val6, itemCount) + sszutils.UnmarshalUint64Slice(val6, buf) + val4.Attestation2.AttestingIndices = val6 + } + } + val3[idx1] = val4 + } + t.SignedBlock.Message.Body.AttesterSlashings = val3 + } + { // Field #5 'Attestations' (dynamic) + buf := buf[offset5:offset6] + val7 := t.SignedBlock.Message.Body.Attestations + startOffset := int(0) + if len(buf) != 0 { + if len(buf) < 4 { + return sszutils.ErrorWithPath(sszutils.ErrListOffsetsEOFFn(len(buf), 4), "SignedBlock.Message.Body.Attestations") + } + startOffset = int(binary.LittleEndian.Uint32(buf[0:4])) + } + itemCount := startOffset / 4 + if startOffset%4 != 0 || len(buf) < startOffset || (len(buf) != 0 && startOffset == 0) { + return sszutils.ErrorWithPath(sszutils.ErrInvalidListStartOffsetFn(startOffset, len(buf)), "SignedBlock.Message.Body.Attestations") + } + if itemCount > int(expr3) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr3)), "SignedBlock.Message.Body.Attestations") + } + val7 = sszutils.ExpandSlice(val7, 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)), "SignedBlock.Message.Body.Attestations[%d]", idx1) + } + buf := buf[startOffset:endOffset] + startOffset = endOffset + val8 := val7[idx1] + if val8 == nil { + val8 = new(all.Attestation) + } + buflen := len(buf) + if buflen < 228 { + return sszutils.ErrorWithPathf(sszutils.ErrFixedFieldsEOFFn(buflen, 228), "SignedBlock.Message.Body.Attestations[%d]", idx1) + } + // Field #0 'AggregationBits' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 228 { + return sszutils.ErrorWithPathf(sszutils.ErrFirstOffsetMismatchFn(offset0, 228), "SignedBlock.Message.Body.Attestations[%d].AggregationBits:o", idx1) + } + { // Field #1 'Data' (static) + buf := buf[4:132] + if val8.Data == nil { + val8.Data = new(phase0.AttestationData) + } + if err = val8.Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.Attestations[%d].Data", idx1) + } + } + { // Field #2 'Signature' (static) + buf := buf[132:228] + copy(val8.Signature[:], buf) + } + { // Field #0 'AggregationBits' (dynamic) + buf := buf[offset0:] + val9 := val8.AggregationBits + blen := len(buf) + if blen == 0 || buf[blen-1] == 0x00 { + return sszutils.ErrorWithPathf(sszutils.ErrBitlistNotTerminatedFn(), "SignedBlock.Message.Body.Attestations[%d].AggregationBits", idx1) + } + bitCount := 8*(blen-1) + int(bits.Len8(buf[blen-1])) - 1 + if bitCount > int(expr4) { + return sszutils.ErrorWithPathf(sszutils.ErrBitlistLengthFn(bitCount, int(expr4)), "SignedBlock.Message.Body.Attestations[%d].AggregationBits", idx1) + } + val9 = sszutils.ExpandSlice(val9, blen) + copy(val9[:], buf) + val8.AggregationBits = val9 + } + val7[idx1] = val8 + } + t.SignedBlock.Message.Body.Attestations = val7 + } + { // Field #6 'Deposits' (dynamic) + buf := buf[offset6:offset7] + val10 := t.SignedBlock.Message.Body.Deposits + itemCount := len(buf) / size3 + if len(buf)%size3 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), size3), "SignedBlock.Message.Body.Deposits") + } + if itemCount > int(expr5) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr5)), "SignedBlock.Message.Body.Deposits") + } + val10 = sszutils.ExpandSlice(val10, itemCount) + for idx1 := range itemCount { + val11 := val10[idx1] + if val11 == nil { + val11 = new(phase0.Deposit) + } + buf := buf[size3*idx1 : size3*(idx1+1)] + exproffset := 0 + totalSize := size4 + 184 + buflen := len(buf) + if buflen < totalSize { + return sszutils.ErrorWithPathf(sszutils.ErrFixedFieldsEOFFn(buflen, totalSize), "SignedBlock.Message.Body.Deposits[%d]", idx1) + } + if buflen > totalSize { + return sszutils.ErrorWithPathf(sszutils.ErrTrailingDataFn(buflen-totalSize), "SignedBlock.Message.Body.Deposits[%d]", idx1) + } + { // Field #0 'Proof' (static) + buf := buf[0 : size4+0] + exproffset += int(size4) + val12 := val11.Proof + val12 = sszutils.ExpandSlice(val12, int(expr6)) + for idx2 := range int(expr6) { + buf := buf[32*idx2 : 32*(idx2+1)] + val12[idx2] = sszutils.ExpandSlice(val12[idx2], 32) + copy(val12[idx2][:], buf) + } + val11.Proof = val12 + } + { // Field #1 'Data' (static) + buf := buf[exproffset+0 : exproffset+184] + if val11.Data == nil { + val11.Data = new(phase0.DepositData) + } + if err = val11.Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.Deposits[%d].Data", idx1) + } + } + val10[idx1] = val11 + } + t.SignedBlock.Message.Body.Deposits = val10 + } + { // Field #7 'VoluntaryExits' (dynamic) + buf := buf[offset7:offset9] + val13 := t.SignedBlock.Message.Body.VoluntaryExits + itemCount := len(buf) / 112 + if len(buf)%112 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 112), "SignedBlock.Message.Body.VoluntaryExits") + } + if itemCount > int(expr7) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr7)), "SignedBlock.Message.Body.VoluntaryExits") + } + val13 = sszutils.ExpandSlice(val13, itemCount) + for idx1 := range itemCount { + if val13[idx1] == nil { + val13[idx1] = new(phase0.SignedVoluntaryExit) + } + buf := buf[112*idx1 : 112*(idx1+1)] + if err = val13[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.VoluntaryExits[%d]", idx1) + } + } + t.SignedBlock.Message.Body.VoluntaryExits = val13 + } + { // Field #9 'ExecutionPayload' (dynamic) + buf := buf[offset9:offset10] + if t.SignedBlock.Message.Body.ExecutionPayload == nil { + t.SignedBlock.Message.Body.ExecutionPayload = new(all.ExecutionPayload) + } + buflen := len(buf) + if buflen < 528 { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, 528), "SignedBlock.Message.Body.ExecutionPayload") + } + { // Field #0 'ParentHash' (static) + buf := buf[0:32] + copy(t.SignedBlock.Message.Body.ExecutionPayload.ParentHash[:], buf) + } + { // Field #1 'FeeRecipient' (static) + buf := buf[32:52] + copy(t.SignedBlock.Message.Body.ExecutionPayload.FeeRecipient[:], buf) + } + { // Field #2 'StateRoot' (static) + buf := buf[52:84] + copy(t.SignedBlock.Message.Body.ExecutionPayload.StateRoot[:], buf) + } + { // Field #3 'ReceiptsRoot' (static) + buf := buf[84:116] + copy(t.SignedBlock.Message.Body.ExecutionPayload.ReceiptsRoot[:], buf) + } + { // Field #4 'LogsBloom' (static) + buf := buf[116:372] + copy(t.SignedBlock.Message.Body.ExecutionPayload.LogsBloom[:], buf) + } + { // Field #5 'PrevRandao' (static) + buf := buf[372:404] + copy(t.SignedBlock.Message.Body.ExecutionPayload.PrevRandao[:], buf) + } + { // Field #6 'BlockNumber' (static) + buf := buf[404:412] + t.SignedBlock.Message.Body.ExecutionPayload.BlockNumber = binary.LittleEndian.Uint64(buf) + } + { // Field #7 'GasLimit' (static) + buf := buf[412:420] + t.SignedBlock.Message.Body.ExecutionPayload.GasLimit = binary.LittleEndian.Uint64(buf) + } + { // Field #8 'GasUsed' (static) + buf := buf[420:428] + t.SignedBlock.Message.Body.ExecutionPayload.GasUsed = binary.LittleEndian.Uint64(buf) + } + { // Field #9 'Timestamp' (static) + buf := buf[428:436] + t.SignedBlock.Message.Body.ExecutionPayload.Timestamp = binary.LittleEndian.Uint64(buf) + } + // Field #10 'ExtraData' (offset) + offset10 := int(binary.LittleEndian.Uint32(buf[436:440])) + if offset10 != 528 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset10, 528), "SignedBlock.Message.Body.ExecutionPayload.ExtraData:o") + } + { // Field #11 'BaseFeePerGas' (static) + buf := buf[440:472] + val14 := t.SignedBlock.Message.Body.ExecutionPayload.BaseFeePerGas + if val14 == nil { + val14 = new(uint256.Int) + } + sszutils.UnmarshalUint64Slice((*val14)[:4], buf) + t.SignedBlock.Message.Body.ExecutionPayload.BaseFeePerGas = val14 + } + { // Field #12 'BlockHash' (static) + buf := buf[472:504] + copy(t.SignedBlock.Message.Body.ExecutionPayload.BlockHash[:], buf) + } + // Field #13 'Transactions' (offset) + offset13 := int(binary.LittleEndian.Uint32(buf[504:508])) + if offset13 < offset10 || offset13 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset13, offset10, buflen), "SignedBlock.Message.Body.ExecutionPayload.Transactions:o") + } + // Field #14 'Withdrawals' (offset) + offset14 := int(binary.LittleEndian.Uint32(buf[508:512])) + if offset14 < offset13 || offset14 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset14, offset13, buflen), "SignedBlock.Message.Body.ExecutionPayload.Withdrawals:o") + } + { // Field #15 'BlobGasUsed' (static) + buf := buf[512:520] + t.SignedBlock.Message.Body.ExecutionPayload.BlobGasUsed = binary.LittleEndian.Uint64(buf) + } + { // Field #16 'ExcessBlobGas' (static) + buf := buf[520:528] + t.SignedBlock.Message.Body.ExecutionPayload.ExcessBlobGas = binary.LittleEndian.Uint64(buf) + } + { // Field #10 'ExtraData' (dynamic) + buf := buf[offset10:offset13] + if len(buf) > int(expr8) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(len(buf), int(expr8)), "SignedBlock.Message.Body.ExecutionPayload.ExtraData") + } + t.SignedBlock.Message.Body.ExecutionPayload.ExtraData = sszutils.ExpandSlice(t.SignedBlock.Message.Body.ExecutionPayload.ExtraData, len(buf)) + copy(t.SignedBlock.Message.Body.ExecutionPayload.ExtraData[:], buf) + } + { // Field #13 'Transactions' (dynamic) + buf := buf[offset13:offset14] + val15 := t.SignedBlock.Message.Body.ExecutionPayload.Transactions + startOffset := int(0) + if len(buf) != 0 { + if len(buf) < 4 { + return sszutils.ErrorWithPath(sszutils.ErrListOffsetsEOFFn(len(buf), 4), "SignedBlock.Message.Body.ExecutionPayload.Transactions") + } + startOffset = int(binary.LittleEndian.Uint32(buf[0:4])) + } + itemCount := startOffset / 4 + if startOffset%4 != 0 || len(buf) < startOffset || (len(buf) != 0 && startOffset == 0) { + return sszutils.ErrorWithPath(sszutils.ErrInvalidListStartOffsetFn(startOffset, len(buf)), "SignedBlock.Message.Body.ExecutionPayload.Transactions") + } + if itemCount > int(expr9) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr9)), "SignedBlock.Message.Body.ExecutionPayload.Transactions") + } + val15 = sszutils.ExpandSlice(val15, 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)), "SignedBlock.Message.Body.ExecutionPayload.Transactions[%d]", idx1) + } + buf := buf[startOffset:endOffset] + startOffset = endOffset + val16 := val15[idx1] + if len(buf) > int(expr10) { + return sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(len(buf), int(expr10)), "SignedBlock.Message.Body.ExecutionPayload.Transactions[%d]", idx1) + } + val16 = sszutils.ExpandSlice(val16, len(buf)) + copy(val16[:], buf) + val15[idx1] = val16 + } + t.SignedBlock.Message.Body.ExecutionPayload.Transactions = val15 + } + { // Field #14 'Withdrawals' (dynamic) + buf := buf[offset14:] + val17 := t.SignedBlock.Message.Body.ExecutionPayload.Withdrawals + itemCount := len(buf) / 44 + if len(buf)%44 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 44), "SignedBlock.Message.Body.ExecutionPayload.Withdrawals") + } + if itemCount > int(expr11) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr11)), "SignedBlock.Message.Body.ExecutionPayload.Withdrawals") + } + val17 = sszutils.ExpandSlice(val17, itemCount) + for idx1 := range itemCount { + if val17[idx1] == nil { + val17[idx1] = new(capella.Withdrawal) + } + buf := buf[44*idx1 : 44*(idx1+1)] + if err = val17[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.ExecutionPayload.Withdrawals[%d]", idx1) + } + } + t.SignedBlock.Message.Body.ExecutionPayload.Withdrawals = val17 + } + } + { // Field #10 'BLSToExecutionChanges' (dynamic) + buf := buf[offset10:offset11] + val18 := t.SignedBlock.Message.Body.BLSToExecutionChanges + itemCount := len(buf) / 172 + if len(buf)%172 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 172), "SignedBlock.Message.Body.BLSToExecutionChanges") + } + if itemCount > int(expr12) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr12)), "SignedBlock.Message.Body.BLSToExecutionChanges") + } + val18 = sszutils.ExpandSlice(val18, itemCount) + for idx1 := range itemCount { + if val18[idx1] == nil { + val18[idx1] = new(capella.SignedBLSToExecutionChange) + } + buf := buf[172*idx1 : 172*(idx1+1)] + if err = val18[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.BLSToExecutionChanges[%d]", idx1) + } + } + t.SignedBlock.Message.Body.BLSToExecutionChanges = val18 + } + { // Field #11 'BlobKZGCommitments' (dynamic) + buf := buf[offset11:] + val19 := t.SignedBlock.Message.Body.BlobKZGCommitments + itemCount := len(buf) / 48 + if len(buf)%48 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 48), "SignedBlock.Message.Body.BlobKZGCommitments") + } + if itemCount > int(expr13) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr13)), "SignedBlock.Message.Body.BlobKZGCommitments") + } + val19 = sszutils.ExpandSlice(val19, itemCount) + sszutils.UnmarshalFixedBytesSlice(val19[:itemCount], buf) + t.SignedBlock.Message.Body.BlobKZGCommitments = val19 + } + } + } + } + { // Field #1 'KZGProofs' (dynamic) + buf := buf[offset1:offset2] + val20 := t.KZGProofs + itemCount := len(buf) / 48 + if len(buf)%48 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 48), "KZGProofs") + } + if itemCount > int(expr13) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr13)), "KZGProofs") + } + val20 = sszutils.ExpandSlice(val20, itemCount) + sszutils.UnmarshalFixedBytesSlice(val20[:itemCount], buf) + t.KZGProofs = val20 + } + { // Field #2 'Blobs' (dynamic) + buf := buf[offset2:] + val21 := t.Blobs + itemCount := len(buf) / 131072 + if len(buf)%131072 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 131072), "Blobs") + } + if itemCount > int(expr13) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr13)), "Blobs") + } + val21 = sszutils.ExpandSlice(val21, itemCount) + sszutils.UnmarshalFixedBytesSlice(val21[:itemCount], buf) + t.Blobs = val21 + } + return nil +} + +func (t *SignedBlockContents) unmarshalSSZView_SignedBlockContents_0(ds sszutils.DynamicSpecs, buf []byte) (err error) { + expr0, err := sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE/8", 64) + if err != nil { + return err + } + expr1, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_PROPOSER_SLASHINGS", 16) + if err != nil { + return err + } + expr2, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_ATTESTER_SLASHINGS_ELECTRA", 1) + if err != nil { + return err + } + expr3, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_VALIDATORS_PER_COMMITTEE*MAX_COMMITTEES_PER_SLOT", 131072) + if err != nil { + return err + } + expr4, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_ATTESTATIONS_ELECTRA", 8) + if err != nil { + return err + } + expr5, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_COMMITTEES_PER_SLOT/8", 8) + if err != nil { + return err + } + expr6, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_DEPOSITS", 16) + if err != nil { + return err + } + expr7, err := sszutils.ResolveSpecValueWithDefault(ds, "DEPOSIT_CONTRACT_TREE_DEPTH+1", 33) + if err != nil { + return err + } + expr8, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_VOLUNTARY_EXITS", 16) + if err != nil { + return err + } + expr9, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_EXTRA_DATA_BYTES", 32) + if err != nil { + return err + } + expr10, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_TRANSACTIONS_PER_PAYLOAD", 1048576) + if err != nil { + return err + } + expr11, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BYTES_PER_TRANSACTION", 1073741824) + if err != nil { + return err + } + expr12, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_WITHDRAWALS_PER_PAYLOAD", 16) + if err != nil { + return err + } + expr13, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BLS_TO_EXECUTION_CHANGES", 16) + if err != nil { + return err + } + expr14, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BLOB_COMMITMENTS_PER_BLOCK", 4096) + if err != nil { + return err + } + expr15, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_DEPOSIT_REQUESTS_PER_PAYLOAD", 8192) + if err != nil { + return err + } + expr16, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_WITHDRAWAL_REQUESTS_PER_PAYLOAD", 16) + if err != nil { + return err + } + expr17, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD", 2) + if err != nil { + return err + } + size2 := 1 * int(expr0) + size1 := size2 + 96 // size expression for '*SyncAggregate' + size3 := 1 * int(expr5) + size5 := 32 * int(expr7) + size4 := size5 + 184 // size expression for '*Deposit' + buflen := len(buf) + if buflen < 12 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 12) + } + // Field #0 'SignedBlock' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 12 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset0, 12), "SignedBlock:o") + } + // Field #1 'KZGProofs' (offset) + offset1 := int(binary.LittleEndian.Uint32(buf[4:8])) + if offset1 < offset0 || offset1 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset1, offset0, buflen), "KZGProofs:o") + } + // Field #2 'Blobs' (offset) + offset2 := int(binary.LittleEndian.Uint32(buf[8:12])) + if offset2 < offset1 || offset2 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset2, offset1, buflen), "Blobs:o") + } + { // Field #0 'SignedBlock' (dynamic) + buf := buf[offset0:offset1] + if t.SignedBlock == nil { + t.SignedBlock = new(all.SignedBeaconBlock) + } + buflen := len(buf) + if buflen < 100 { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, 100), "SignedBlock") + } + // Field #0 'Message' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 100 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset0, 100), "SignedBlock.Message:o") + } + { // Field #1 'Signature' (static) + buf := buf[4:100] + copy(t.SignedBlock.Signature[:], buf) + } + { // Field #0 'Message' (dynamic) + buf := buf[offset0:] + if t.SignedBlock.Message == nil { + t.SignedBlock.Message = new(all.BeaconBlock) + } + buflen := len(buf) + if buflen < 84 { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, 84), "SignedBlock.Message") + } + { // Field #0 'Slot' (static) + buf := buf[0:8] + t.SignedBlock.Message.Slot = phase0.Slot(binary.LittleEndian.Uint64(buf)) + } + { // Field #1 'ProposerIndex' (static) + buf := buf[8:16] + t.SignedBlock.Message.ProposerIndex = phase0.ValidatorIndex(binary.LittleEndian.Uint64(buf)) + } + { // Field #2 'ParentRoot' (static) + buf := buf[16:48] + copy(t.SignedBlock.Message.ParentRoot[:], buf) + } + { // Field #3 'StateRoot' (static) + buf := buf[48:80] + copy(t.SignedBlock.Message.StateRoot[:], buf) + } + // Field #4 'Body' (offset) + offset4 := int(binary.LittleEndian.Uint32(buf[80:84])) + if offset4 != 84 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset4, 84), "SignedBlock.Message.Body:o") + } + { // Field #4 'Body' (dynamic) + buf := buf[offset4:] + if t.SignedBlock.Message.Body == nil { + t.SignedBlock.Message.Body = new(all.BeaconBlockBody) + } + exproffset := 0 + totalSize := size1 + 236 + buflen := len(buf) + if buflen < totalSize { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, totalSize), "SignedBlock.Message.Body") + } + { // Field #0 'RANDAOReveal' (static) + buf := buf[0:96] + copy(t.SignedBlock.Message.Body.RANDAOReveal[:], buf) + } + { // Field #1 'ETH1Data' (static) + buf := buf[96:168] + if t.SignedBlock.Message.Body.ETH1Data == nil { + t.SignedBlock.Message.Body.ETH1Data = new(phase0.ETH1Data) + } + if err = t.SignedBlock.Message.Body.ETH1Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "SignedBlock.Message.Body.ETH1Data") + } + } + { // Field #2 'Graffiti' (static) + buf := buf[168:200] + copy(t.SignedBlock.Message.Body.Graffiti[:], buf) + } + // Field #3 'ProposerSlashings' (offset) + offset3 := int(binary.LittleEndian.Uint32(buf[200:204])) + if offset3 != totalSize { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset3, totalSize), "SignedBlock.Message.Body.ProposerSlashings:o") + } + // Field #4 'AttesterSlashings' (offset) + offset4 := int(binary.LittleEndian.Uint32(buf[204:208])) + if offset4 < offset3 || offset4 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset4, offset3, buflen), "SignedBlock.Message.Body.AttesterSlashings:o") + } + // Field #5 'Attestations' (offset) + offset5 := int(binary.LittleEndian.Uint32(buf[208:212])) + if offset5 < offset4 || offset5 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset5, offset4, buflen), "SignedBlock.Message.Body.Attestations:o") + } + // Field #6 'Deposits' (offset) + offset6 := int(binary.LittleEndian.Uint32(buf[212:216])) + if offset6 < offset5 || offset6 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset6, offset5, buflen), "SignedBlock.Message.Body.Deposits:o") + } + // Field #7 'VoluntaryExits' (offset) + offset7 := int(binary.LittleEndian.Uint32(buf[216:220])) + if offset7 < offset6 || offset7 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset7, offset6, buflen), "SignedBlock.Message.Body.VoluntaryExits:o") + } + { // Field #8 'SyncAggregate' (static) + buf := buf[220 : size1+220] + exproffset += int(size1) + val1 := t.SignedBlock.Message.Body.SyncAggregate + if val1 == nil { + val1 = new(altair.SyncAggregate) + } + exproffset := 0 + totalSize := size2 + 96 + buflen := len(buf) + if buflen < totalSize { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, totalSize), "SignedBlock.Message.Body.SyncAggregate") + } + if buflen > totalSize { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(buflen-totalSize), "SignedBlock.Message.Body.SyncAggregate") + } + { // Field #0 'SyncCommitteeBits' (static) + buf := buf[0 : size2+0] + exproffset += int(size2) + val1.SyncCommitteeBits = sszutils.ExpandSlice(val1.SyncCommitteeBits, int(expr0)) + copy(val1.SyncCommitteeBits[:], buf) + } + { // Field #1 'SyncCommitteeSignature' (static) + buf := buf[exproffset+0 : exproffset+96] + copy(val1.SyncCommitteeSignature[:], buf) + } + t.SignedBlock.Message.Body.SyncAggregate = val1 + } + // Field #9 'ExecutionPayload' (offset) + offset9 := int(binary.LittleEndian.Uint32(buf[exproffset+220 : exproffset+224])) + if offset9 < offset7 || offset9 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset9, offset7, buflen), "SignedBlock.Message.Body.ExecutionPayload:o") + } + // Field #10 'BLSToExecutionChanges' (offset) + offset10 := int(binary.LittleEndian.Uint32(buf[exproffset+224 : exproffset+228])) + if offset10 < offset9 || offset10 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset10, offset9, buflen), "SignedBlock.Message.Body.BLSToExecutionChanges:o") + } + // Field #11 'BlobKZGCommitments' (offset) + offset11 := int(binary.LittleEndian.Uint32(buf[exproffset+228 : exproffset+232])) + if offset11 < offset10 || offset11 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset11, offset10, buflen), "SignedBlock.Message.Body.BlobKZGCommitments:o") + } + // Field #12 'ExecutionRequests' (offset) + offset12 := int(binary.LittleEndian.Uint32(buf[exproffset+232 : exproffset+236])) + if offset12 < offset11 || offset12 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset12, offset11, buflen), "SignedBlock.Message.Body.ExecutionRequests:o") + } + { // Field #3 'ProposerSlashings' (dynamic) + buf := buf[offset3:offset4] + val2 := t.SignedBlock.Message.Body.ProposerSlashings + itemCount := len(buf) / 416 + if len(buf)%416 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 416), "SignedBlock.Message.Body.ProposerSlashings") + } + if itemCount > int(expr1) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr1)), "SignedBlock.Message.Body.ProposerSlashings") + } + val2 = sszutils.ExpandSlice(val2, itemCount) + for idx1 := range itemCount { + if val2[idx1] == nil { + val2[idx1] = new(phase0.ProposerSlashing) + } + buf := buf[416*idx1 : 416*(idx1+1)] + if err = val2[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.ProposerSlashings[%d]", idx1) + } + } + t.SignedBlock.Message.Body.ProposerSlashings = val2 + } + { // Field #4 'AttesterSlashings' (dynamic) + buf := buf[offset4:offset5] + val3 := t.SignedBlock.Message.Body.AttesterSlashings + startOffset := int(0) + if len(buf) != 0 { + if len(buf) < 4 { + return sszutils.ErrorWithPath(sszutils.ErrListOffsetsEOFFn(len(buf), 4), "SignedBlock.Message.Body.AttesterSlashings") + } + startOffset = int(binary.LittleEndian.Uint32(buf[0:4])) + } + itemCount := startOffset / 4 + if startOffset%4 != 0 || len(buf) < startOffset || (len(buf) != 0 && startOffset == 0) { + return sszutils.ErrorWithPath(sszutils.ErrInvalidListStartOffsetFn(startOffset, len(buf)), "SignedBlock.Message.Body.AttesterSlashings") + } + if itemCount > int(expr2) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr2)), "SignedBlock.Message.Body.AttesterSlashings") + } + val3 = sszutils.ExpandSlice(val3, 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)), "SignedBlock.Message.Body.AttesterSlashings[%d]", idx1) + } + buf := buf[startOffset:endOffset] + startOffset = endOffset + val4 := val3[idx1] + if val4 == nil { + val4 = new(all.AttesterSlashing) + } + buflen := len(buf) + if buflen < 8 { + return sszutils.ErrorWithPathf(sszutils.ErrFixedFieldsEOFFn(buflen, 8), "SignedBlock.Message.Body.AttesterSlashings[%d]", idx1) + } + // Field #0 'Attestation1' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 8 { + return sszutils.ErrorWithPathf(sszutils.ErrFirstOffsetMismatchFn(offset0, 8), "SignedBlock.Message.Body.AttesterSlashings[%d].Attestation1:o", idx1) + } + // Field #1 'Attestation2' (offset) + offset1 := int(binary.LittleEndian.Uint32(buf[4:8])) + if offset1 < offset0 || offset1 > buflen { + return sszutils.ErrorWithPathf(sszutils.ErrOffsetOutOfRangeFn(offset1, offset0, buflen), "SignedBlock.Message.Body.AttesterSlashings[%d].Attestation2:o", idx1) + } + { // Field #0 'Attestation1' (dynamic) + buf := buf[offset0:offset1] + if val4.Attestation1 == nil { + val4.Attestation1 = new(all.IndexedAttestation) + } + buflen := len(buf) + if buflen < 228 { + return sszutils.ErrorWithPathf(sszutils.ErrFixedFieldsEOFFn(buflen, 228), "SignedBlock.Message.Body.AttesterSlashings[%d].Attestation1", idx1) + } + // Field #0 'AttestingIndices' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 228 { + return sszutils.ErrorWithPathf(sszutils.ErrFirstOffsetMismatchFn(offset0, 228), "SignedBlock.Message.Body.AttesterSlashings[%d].Attestation1.AttestingIndices:o", idx1) + } + { // Field #1 'Data' (static) + buf := buf[4:132] + if val4.Attestation1.Data == nil { + val4.Attestation1.Data = new(phase0.AttestationData) + } + if err = val4.Attestation1.Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.AttesterSlashings[%d].Attestation1.Data", idx1) + } + } + { // Field #2 'Signature' (static) + buf := buf[132:228] + copy(val4.Attestation1.Signature[:], buf) + } + { // Field #0 'AttestingIndices' (dynamic) + buf := buf[offset0:] + val5 := val4.Attestation1.AttestingIndices + itemCount := len(buf) / 8 + if len(buf)%8 != 0 { + return sszutils.ErrorWithPathf(sszutils.ErrListNotAlignedFn(len(buf), 8), "SignedBlock.Message.Body.AttesterSlashings[%d].Attestation1.AttestingIndices", idx1) + } + if itemCount > int(expr3) { + return sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(itemCount, int(expr3)), "SignedBlock.Message.Body.AttesterSlashings[%d].Attestation1.AttestingIndices", idx1) + } + val5 = sszutils.ExpandSlice(val5, itemCount) + sszutils.UnmarshalUint64Slice(val5, buf) + val4.Attestation1.AttestingIndices = val5 + } + } + { // Field #1 'Attestation2' (dynamic) + buf := buf[offset1:] + if val4.Attestation2 == nil { + val4.Attestation2 = new(all.IndexedAttestation) + } + buflen := len(buf) + if buflen < 228 { + return sszutils.ErrorWithPathf(sszutils.ErrFixedFieldsEOFFn(buflen, 228), "SignedBlock.Message.Body.AttesterSlashings[%d].Attestation2", idx1) + } + // Field #0 'AttestingIndices' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 228 { + return sszutils.ErrorWithPathf(sszutils.ErrFirstOffsetMismatchFn(offset0, 228), "SignedBlock.Message.Body.AttesterSlashings[%d].Attestation2.AttestingIndices:o", idx1) + } + { // Field #1 'Data' (static) + buf := buf[4:132] + if val4.Attestation2.Data == nil { + val4.Attestation2.Data = new(phase0.AttestationData) + } + if err = val4.Attestation2.Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.AttesterSlashings[%d].Attestation2.Data", idx1) + } + } + { // Field #2 'Signature' (static) + buf := buf[132:228] + copy(val4.Attestation2.Signature[:], buf) + } + { // Field #0 'AttestingIndices' (dynamic) + buf := buf[offset0:] + val6 := val4.Attestation2.AttestingIndices + itemCount := len(buf) / 8 + if len(buf)%8 != 0 { + return sszutils.ErrorWithPathf(sszutils.ErrListNotAlignedFn(len(buf), 8), "SignedBlock.Message.Body.AttesterSlashings[%d].Attestation2.AttestingIndices", idx1) + } + if itemCount > int(expr3) { + return sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(itemCount, int(expr3)), "SignedBlock.Message.Body.AttesterSlashings[%d].Attestation2.AttestingIndices", idx1) + } + val6 = sszutils.ExpandSlice(val6, itemCount) + sszutils.UnmarshalUint64Slice(val6, buf) + val4.Attestation2.AttestingIndices = val6 + } + } + val3[idx1] = val4 + } + t.SignedBlock.Message.Body.AttesterSlashings = val3 + } + { // Field #5 'Attestations' (dynamic) + buf := buf[offset5:offset6] + val7 := t.SignedBlock.Message.Body.Attestations + startOffset := int(0) + if len(buf) != 0 { + if len(buf) < 4 { + return sszutils.ErrorWithPath(sszutils.ErrListOffsetsEOFFn(len(buf), 4), "SignedBlock.Message.Body.Attestations") + } + startOffset = int(binary.LittleEndian.Uint32(buf[0:4])) + } + itemCount := startOffset / 4 + if startOffset%4 != 0 || len(buf) < startOffset || (len(buf) != 0 && startOffset == 0) { + return sszutils.ErrorWithPath(sszutils.ErrInvalidListStartOffsetFn(startOffset, len(buf)), "SignedBlock.Message.Body.Attestations") + } + if itemCount > int(expr4) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr4)), "SignedBlock.Message.Body.Attestations") + } + val7 = sszutils.ExpandSlice(val7, 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)), "SignedBlock.Message.Body.Attestations[%d]", idx1) + } + buf := buf[startOffset:endOffset] + startOffset = endOffset + val8 := val7[idx1] + if val8 == nil { + val8 = new(all.Attestation) + } + exproffset := 0 + totalSize := size3 + 228 + buflen := len(buf) + if buflen < totalSize { + return sszutils.ErrorWithPathf(sszutils.ErrFixedFieldsEOFFn(buflen, totalSize), "SignedBlock.Message.Body.Attestations[%d]", idx1) + } + // Field #0 'AggregationBits' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != totalSize { + return sszutils.ErrorWithPathf(sszutils.ErrFirstOffsetMismatchFn(offset0, totalSize), "SignedBlock.Message.Body.Attestations[%d].AggregationBits:o", idx1) + } + { // Field #1 'Data' (static) + buf := buf[4:132] + if val8.Data == nil { + val8.Data = new(phase0.AttestationData) + } + if err = val8.Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.Attestations[%d].Data", idx1) + } + } + { // Field #2 'Signature' (static) + buf := buf[132:228] + copy(val8.Signature[:], buf) + } + { // Field #3 'CommitteeBits' (static) + buf := buf[228 : size3+228] + exproffset += int(size3) + val8.CommitteeBits = sszutils.ExpandSlice(val8.CommitteeBits, int(expr5)) + copy(val8.CommitteeBits[:], buf) + } + { // Field #0 'AggregationBits' (dynamic) + buf := buf[offset0:] + val9 := val8.AggregationBits + blen := len(buf) + if blen == 0 || buf[blen-1] == 0x00 { + return sszutils.ErrorWithPathf(sszutils.ErrBitlistNotTerminatedFn(), "SignedBlock.Message.Body.Attestations[%d].AggregationBits", idx1) + } + bitCount := 8*(blen-1) + int(bits.Len8(buf[blen-1])) - 1 + if bitCount > int(expr3) { + return sszutils.ErrorWithPathf(sszutils.ErrBitlistLengthFn(bitCount, int(expr3)), "SignedBlock.Message.Body.Attestations[%d].AggregationBits", idx1) + } + val9 = sszutils.ExpandSlice(val9, blen) + copy(val9[:], buf) + val8.AggregationBits = val9 + } + val7[idx1] = val8 + } + t.SignedBlock.Message.Body.Attestations = val7 + } + { // Field #6 'Deposits' (dynamic) + buf := buf[offset6:offset7] + val10 := t.SignedBlock.Message.Body.Deposits + itemCount := len(buf) / size4 + if len(buf)%size4 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), size4), "SignedBlock.Message.Body.Deposits") + } + if itemCount > int(expr6) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "SignedBlock.Message.Body.Deposits") + } + val10 = sszutils.ExpandSlice(val10, itemCount) + for idx1 := range itemCount { + val11 := val10[idx1] + if val11 == nil { + val11 = new(phase0.Deposit) + } + buf := buf[size4*idx1 : size4*(idx1+1)] + exproffset := 0 + totalSize := size5 + 184 + buflen := len(buf) + if buflen < totalSize { + return sszutils.ErrorWithPathf(sszutils.ErrFixedFieldsEOFFn(buflen, totalSize), "SignedBlock.Message.Body.Deposits[%d]", idx1) + } + if buflen > totalSize { + return sszutils.ErrorWithPathf(sszutils.ErrTrailingDataFn(buflen-totalSize), "SignedBlock.Message.Body.Deposits[%d]", idx1) + } + { // Field #0 'Proof' (static) + buf := buf[0 : size5+0] + exproffset += int(size5) + val12 := val11.Proof + val12 = sszutils.ExpandSlice(val12, int(expr7)) + for idx2 := range int(expr7) { + buf := buf[32*idx2 : 32*(idx2+1)] + val12[idx2] = sszutils.ExpandSlice(val12[idx2], 32) + copy(val12[idx2][:], buf) + } + val11.Proof = val12 + } + { // Field #1 'Data' (static) + buf := buf[exproffset+0 : exproffset+184] + if val11.Data == nil { + val11.Data = new(phase0.DepositData) + } + if err = val11.Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.Deposits[%d].Data", idx1) + } + } + val10[idx1] = val11 + } + t.SignedBlock.Message.Body.Deposits = val10 + } + { // Field #7 'VoluntaryExits' (dynamic) + buf := buf[offset7:offset9] + val13 := t.SignedBlock.Message.Body.VoluntaryExits + itemCount := len(buf) / 112 + if len(buf)%112 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 112), "SignedBlock.Message.Body.VoluntaryExits") + } + if itemCount > int(expr8) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr8)), "SignedBlock.Message.Body.VoluntaryExits") + } + val13 = sszutils.ExpandSlice(val13, itemCount) + for idx1 := range itemCount { + if val13[idx1] == nil { + val13[idx1] = new(phase0.SignedVoluntaryExit) + } + buf := buf[112*idx1 : 112*(idx1+1)] + if err = val13[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.VoluntaryExits[%d]", idx1) + } + } + t.SignedBlock.Message.Body.VoluntaryExits = val13 + } + { // Field #9 'ExecutionPayload' (dynamic) + buf := buf[offset9:offset10] + if t.SignedBlock.Message.Body.ExecutionPayload == nil { + t.SignedBlock.Message.Body.ExecutionPayload = new(all.ExecutionPayload) + } + buflen := len(buf) + if buflen < 528 { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, 528), "SignedBlock.Message.Body.ExecutionPayload") + } + { // Field #0 'ParentHash' (static) + buf := buf[0:32] + copy(t.SignedBlock.Message.Body.ExecutionPayload.ParentHash[:], buf) + } + { // Field #1 'FeeRecipient' (static) + buf := buf[32:52] + copy(t.SignedBlock.Message.Body.ExecutionPayload.FeeRecipient[:], buf) + } + { // Field #2 'StateRoot' (static) + buf := buf[52:84] + copy(t.SignedBlock.Message.Body.ExecutionPayload.StateRoot[:], buf) + } + { // Field #3 'ReceiptsRoot' (static) + buf := buf[84:116] + copy(t.SignedBlock.Message.Body.ExecutionPayload.ReceiptsRoot[:], buf) + } + { // Field #4 'LogsBloom' (static) + buf := buf[116:372] + copy(t.SignedBlock.Message.Body.ExecutionPayload.LogsBloom[:], buf) + } + { // Field #5 'PrevRandao' (static) + buf := buf[372:404] + copy(t.SignedBlock.Message.Body.ExecutionPayload.PrevRandao[:], buf) + } + { // Field #6 'BlockNumber' (static) + buf := buf[404:412] + t.SignedBlock.Message.Body.ExecutionPayload.BlockNumber = binary.LittleEndian.Uint64(buf) + } + { // Field #7 'GasLimit' (static) + buf := buf[412:420] + t.SignedBlock.Message.Body.ExecutionPayload.GasLimit = binary.LittleEndian.Uint64(buf) + } + { // Field #8 'GasUsed' (static) + buf := buf[420:428] + t.SignedBlock.Message.Body.ExecutionPayload.GasUsed = binary.LittleEndian.Uint64(buf) + } + { // Field #9 'Timestamp' (static) + buf := buf[428:436] + t.SignedBlock.Message.Body.ExecutionPayload.Timestamp = binary.LittleEndian.Uint64(buf) + } + // Field #10 'ExtraData' (offset) + offset10 := int(binary.LittleEndian.Uint32(buf[436:440])) + if offset10 != 528 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset10, 528), "SignedBlock.Message.Body.ExecutionPayload.ExtraData:o") + } + { // Field #11 'BaseFeePerGas' (static) + buf := buf[440:472] + val14 := t.SignedBlock.Message.Body.ExecutionPayload.BaseFeePerGas + if val14 == nil { + val14 = new(uint256.Int) + } + sszutils.UnmarshalUint64Slice((*val14)[:4], buf) + t.SignedBlock.Message.Body.ExecutionPayload.BaseFeePerGas = val14 + } + { // Field #12 'BlockHash' (static) + buf := buf[472:504] + copy(t.SignedBlock.Message.Body.ExecutionPayload.BlockHash[:], buf) + } + // Field #13 'Transactions' (offset) + offset13 := int(binary.LittleEndian.Uint32(buf[504:508])) + if offset13 < offset10 || offset13 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset13, offset10, buflen), "SignedBlock.Message.Body.ExecutionPayload.Transactions:o") + } + // Field #14 'Withdrawals' (offset) + offset14 := int(binary.LittleEndian.Uint32(buf[508:512])) + if offset14 < offset13 || offset14 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset14, offset13, buflen), "SignedBlock.Message.Body.ExecutionPayload.Withdrawals:o") + } + { // Field #15 'BlobGasUsed' (static) + buf := buf[512:520] + t.SignedBlock.Message.Body.ExecutionPayload.BlobGasUsed = binary.LittleEndian.Uint64(buf) + } + { // Field #16 'ExcessBlobGas' (static) + buf := buf[520:528] + t.SignedBlock.Message.Body.ExecutionPayload.ExcessBlobGas = binary.LittleEndian.Uint64(buf) + } + { // Field #10 'ExtraData' (dynamic) + buf := buf[offset10:offset13] + if len(buf) > int(expr9) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(len(buf), int(expr9)), "SignedBlock.Message.Body.ExecutionPayload.ExtraData") + } + t.SignedBlock.Message.Body.ExecutionPayload.ExtraData = sszutils.ExpandSlice(t.SignedBlock.Message.Body.ExecutionPayload.ExtraData, len(buf)) + copy(t.SignedBlock.Message.Body.ExecutionPayload.ExtraData[:], buf) + } + { // Field #13 'Transactions' (dynamic) + buf := buf[offset13:offset14] + val15 := t.SignedBlock.Message.Body.ExecutionPayload.Transactions + startOffset := int(0) + if len(buf) != 0 { + if len(buf) < 4 { + return sszutils.ErrorWithPath(sszutils.ErrListOffsetsEOFFn(len(buf), 4), "SignedBlock.Message.Body.ExecutionPayload.Transactions") + } + startOffset = int(binary.LittleEndian.Uint32(buf[0:4])) + } + itemCount := startOffset / 4 + if startOffset%4 != 0 || len(buf) < startOffset || (len(buf) != 0 && startOffset == 0) { + return sszutils.ErrorWithPath(sszutils.ErrInvalidListStartOffsetFn(startOffset, len(buf)), "SignedBlock.Message.Body.ExecutionPayload.Transactions") + } + if itemCount > int(expr10) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr10)), "SignedBlock.Message.Body.ExecutionPayload.Transactions") + } + val15 = sszutils.ExpandSlice(val15, 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)), "SignedBlock.Message.Body.ExecutionPayload.Transactions[%d]", idx1) + } + buf := buf[startOffset:endOffset] + startOffset = endOffset + val16 := val15[idx1] + if len(buf) > int(expr11) { + return sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(len(buf), int(expr11)), "SignedBlock.Message.Body.ExecutionPayload.Transactions[%d]", idx1) + } + val16 = sszutils.ExpandSlice(val16, len(buf)) + copy(val16[:], buf) + val15[idx1] = val16 + } + t.SignedBlock.Message.Body.ExecutionPayload.Transactions = val15 + } + { // Field #14 'Withdrawals' (dynamic) + buf := buf[offset14:] + val17 := t.SignedBlock.Message.Body.ExecutionPayload.Withdrawals + itemCount := len(buf) / 44 + if len(buf)%44 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 44), "SignedBlock.Message.Body.ExecutionPayload.Withdrawals") + } + if itemCount > int(expr12) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr12)), "SignedBlock.Message.Body.ExecutionPayload.Withdrawals") + } + val17 = sszutils.ExpandSlice(val17, itemCount) + for idx1 := range itemCount { + if val17[idx1] == nil { + val17[idx1] = new(capella.Withdrawal) + } + buf := buf[44*idx1 : 44*(idx1+1)] + if err = val17[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.ExecutionPayload.Withdrawals[%d]", idx1) + } + } + t.SignedBlock.Message.Body.ExecutionPayload.Withdrawals = val17 + } + } + { // Field #10 'BLSToExecutionChanges' (dynamic) + buf := buf[offset10:offset11] + val18 := t.SignedBlock.Message.Body.BLSToExecutionChanges + itemCount := len(buf) / 172 + if len(buf)%172 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 172), "SignedBlock.Message.Body.BLSToExecutionChanges") + } + if itemCount > int(expr13) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr13)), "SignedBlock.Message.Body.BLSToExecutionChanges") + } + val18 = sszutils.ExpandSlice(val18, itemCount) + for idx1 := range itemCount { + if val18[idx1] == nil { + val18[idx1] = new(capella.SignedBLSToExecutionChange) + } + buf := buf[172*idx1 : 172*(idx1+1)] + if err = val18[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.BLSToExecutionChanges[%d]", idx1) + } + } + t.SignedBlock.Message.Body.BLSToExecutionChanges = val18 + } + { // Field #11 'BlobKZGCommitments' (dynamic) + buf := buf[offset11:offset12] + val19 := t.SignedBlock.Message.Body.BlobKZGCommitments + itemCount := len(buf) / 48 + if len(buf)%48 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 48), "SignedBlock.Message.Body.BlobKZGCommitments") + } + if itemCount > int(expr14) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr14)), "SignedBlock.Message.Body.BlobKZGCommitments") + } + val19 = sszutils.ExpandSlice(val19, itemCount) + sszutils.UnmarshalFixedBytesSlice(val19[:itemCount], buf) + t.SignedBlock.Message.Body.BlobKZGCommitments = val19 + } + { // Field #12 'ExecutionRequests' (dynamic) + buf := buf[offset12:] + if t.SignedBlock.Message.Body.ExecutionRequests == nil { + t.SignedBlock.Message.Body.ExecutionRequests = new(all.ExecutionRequests) + } + buflen := len(buf) + if buflen < 12 { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, 12), "SignedBlock.Message.Body.ExecutionRequests") + } + // Field #0 'Deposits' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 12 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset0, 12), "SignedBlock.Message.Body.ExecutionRequests.Deposits:o") + } + // Field #1 'Withdrawals' (offset) + offset1 := int(binary.LittleEndian.Uint32(buf[4:8])) + if offset1 < offset0 || offset1 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset1, offset0, buflen), "SignedBlock.Message.Body.ExecutionRequests.Withdrawals:o") + } + // Field #2 'Consolidations' (offset) + offset2 := int(binary.LittleEndian.Uint32(buf[8:12])) + if offset2 < offset1 || offset2 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset2, offset1, buflen), "SignedBlock.Message.Body.ExecutionRequests.Consolidations:o") + } + { // Field #0 'Deposits' (dynamic) + buf := buf[offset0:offset1] + val20 := t.SignedBlock.Message.Body.ExecutionRequests.Deposits + itemCount := len(buf) / 192 + if len(buf)%192 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 192), "SignedBlock.Message.Body.ExecutionRequests.Deposits") + } + if itemCount > int(expr15) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr15)), "SignedBlock.Message.Body.ExecutionRequests.Deposits") + } + val20 = sszutils.ExpandSlice(val20, itemCount) + for idx1 := range itemCount { + if val20[idx1] == nil { + val20[idx1] = new(electra1.DepositRequest) + } + buf := buf[192*idx1 : 192*(idx1+1)] + if err = val20[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.ExecutionRequests.Deposits[%d]", idx1) + } + } + t.SignedBlock.Message.Body.ExecutionRequests.Deposits = val20 + } + { // Field #1 'Withdrawals' (dynamic) + buf := buf[offset1:offset2] + val21 := t.SignedBlock.Message.Body.ExecutionRequests.Withdrawals + itemCount := len(buf) / 76 + if len(buf)%76 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 76), "SignedBlock.Message.Body.ExecutionRequests.Withdrawals") + } + if itemCount > int(expr16) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr16)), "SignedBlock.Message.Body.ExecutionRequests.Withdrawals") + } + val21 = sszutils.ExpandSlice(val21, itemCount) + for idx1 := range itemCount { + if val21[idx1] == nil { + val21[idx1] = new(electra1.WithdrawalRequest) + } + buf := buf[76*idx1 : 76*(idx1+1)] + if err = val21[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.ExecutionRequests.Withdrawals[%d]", idx1) + } + } + t.SignedBlock.Message.Body.ExecutionRequests.Withdrawals = val21 + } + { // Field #2 'Consolidations' (dynamic) + buf := buf[offset2:] + val22 := t.SignedBlock.Message.Body.ExecutionRequests.Consolidations + itemCount := len(buf) / 116 + if len(buf)%116 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 116), "SignedBlock.Message.Body.ExecutionRequests.Consolidations") + } + if itemCount > int(expr17) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr17)), "SignedBlock.Message.Body.ExecutionRequests.Consolidations") + } + val22 = sszutils.ExpandSlice(val22, itemCount) + for idx1 := range itemCount { + if val22[idx1] == nil { + val22[idx1] = new(electra1.ConsolidationRequest) + } + buf := buf[116*idx1 : 116*(idx1+1)] + if err = val22[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.ExecutionRequests.Consolidations[%d]", idx1) + } + } + t.SignedBlock.Message.Body.ExecutionRequests.Consolidations = val22 + } + } + } + } + } + { // Field #1 'KZGProofs' (dynamic) + buf := buf[offset1:offset2] + val23 := t.KZGProofs + itemCount := len(buf) / 48 + if len(buf)%48 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 48), "KZGProofs") + } + if itemCount > int(expr14) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr14)), "KZGProofs") + } + val23 = sszutils.ExpandSlice(val23, itemCount) + sszutils.UnmarshalFixedBytesSlice(val23[:itemCount], buf) + t.KZGProofs = val23 + } + { // Field #2 'Blobs' (dynamic) + buf := buf[offset2:] + val24 := t.Blobs + itemCount := len(buf) / 131072 + if len(buf)%131072 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 131072), "Blobs") + } + if itemCount > int(expr14) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr14)), "Blobs") + } + val24 = sszutils.ExpandSlice(val24, itemCount) + sszutils.UnmarshalFixedBytesSlice(val24[:itemCount], buf) + t.Blobs = val24 + } + return nil +} + +func (t *SignedBlockContents) unmarshalSSZView_SignedBlockContents_1(ds sszutils.DynamicSpecs, buf []byte) (err error) { + expr0, err := sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE/8", 64) + if err != nil { + return err + } + expr1, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_PROPOSER_SLASHINGS", 16) + if err != nil { + return err + } + expr2, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_ATTESTER_SLASHINGS_ELECTRA", 1) + if err != nil { + return err + } + expr3, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_VALIDATORS_PER_COMMITTEE*MAX_COMMITTEES_PER_SLOT", 131072) + if err != nil { + return err + } + expr4, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_ATTESTATIONS_ELECTRA", 8) + if err != nil { + return err + } + expr5, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_COMMITTEES_PER_SLOT/8", 8) + if err != nil { + return err + } + expr6, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_DEPOSITS", 16) + if err != nil { + return err + } + expr7, err := sszutils.ResolveSpecValueWithDefault(ds, "DEPOSIT_CONTRACT_TREE_DEPTH+1", 33) + if err != nil { + return err + } + expr8, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_VOLUNTARY_EXITS", 16) + if err != nil { + return err + } + expr9, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_EXTRA_DATA_BYTES", 32) + if err != nil { + return err + } + expr10, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_TRANSACTIONS_PER_PAYLOAD", 1048576) + if err != nil { + return err + } + expr11, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BYTES_PER_TRANSACTION", 1073741824) + if err != nil { + return err + } + expr12, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_WITHDRAWALS_PER_PAYLOAD", 16) + if err != nil { + return err + } + expr13, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BLS_TO_EXECUTION_CHANGES", 16) + if err != nil { + return err + } + expr14, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BLOB_COMMITMENTS_PER_BLOCK", 4096) + if err != nil { + return err + } + expr15, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_DEPOSIT_REQUESTS_PER_PAYLOAD", 8192) + if err != nil { + return err + } + expr16, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_WITHDRAWAL_REQUESTS_PER_PAYLOAD", 16) + if err != nil { + return err + } + expr17, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD", 2) + if err != nil { + return err + } + size2 := 1 * int(expr0) + size1 := size2 + 96 // size expression for '*SyncAggregate' + size3 := 1 * int(expr5) + size5 := 32 * int(expr7) + size4 := size5 + 184 // size expression for '*Deposit' + buflen := len(buf) + if buflen < 12 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 12) + } + // Field #0 'SignedBlock' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 12 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset0, 12), "SignedBlock:o") + } + // Field #1 'KZGProofs' (offset) + offset1 := int(binary.LittleEndian.Uint32(buf[4:8])) + if offset1 < offset0 || offset1 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset1, offset0, buflen), "KZGProofs:o") + } + // Field #2 'Blobs' (offset) + offset2 := int(binary.LittleEndian.Uint32(buf[8:12])) + if offset2 < offset1 || offset2 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset2, offset1, buflen), "Blobs:o") + } + { // Field #0 'SignedBlock' (dynamic) + buf := buf[offset0:offset1] + if t.SignedBlock == nil { + t.SignedBlock = new(all.SignedBeaconBlock) + } + buflen := len(buf) + if buflen < 100 { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, 100), "SignedBlock") + } + // Field #0 'Message' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 100 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset0, 100), "SignedBlock.Message:o") + } + { // Field #1 'Signature' (static) + buf := buf[4:100] + copy(t.SignedBlock.Signature[:], buf) + } + { // Field #0 'Message' (dynamic) + buf := buf[offset0:] + if t.SignedBlock.Message == nil { + t.SignedBlock.Message = new(all.BeaconBlock) + } + buflen := len(buf) + if buflen < 84 { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, 84), "SignedBlock.Message") + } + { // Field #0 'Slot' (static) + buf := buf[0:8] + t.SignedBlock.Message.Slot = phase0.Slot(binary.LittleEndian.Uint64(buf)) + } + { // Field #1 'ProposerIndex' (static) + buf := buf[8:16] + t.SignedBlock.Message.ProposerIndex = phase0.ValidatorIndex(binary.LittleEndian.Uint64(buf)) + } + { // Field #2 'ParentRoot' (static) + buf := buf[16:48] + copy(t.SignedBlock.Message.ParentRoot[:], buf) + } + { // Field #3 'StateRoot' (static) + buf := buf[48:80] + copy(t.SignedBlock.Message.StateRoot[:], buf) + } + // Field #4 'Body' (offset) + offset4 := int(binary.LittleEndian.Uint32(buf[80:84])) + if offset4 != 84 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset4, 84), "SignedBlock.Message.Body:o") + } + { // Field #4 'Body' (dynamic) + buf := buf[offset4:] + if t.SignedBlock.Message.Body == nil { + t.SignedBlock.Message.Body = new(all.BeaconBlockBody) + } + exproffset := 0 + totalSize := size1 + 236 + buflen := len(buf) + if buflen < totalSize { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, totalSize), "SignedBlock.Message.Body") + } + { // Field #0 'RANDAOReveal' (static) + buf := buf[0:96] + copy(t.SignedBlock.Message.Body.RANDAOReveal[:], buf) + } + { // Field #1 'ETH1Data' (static) + buf := buf[96:168] + if t.SignedBlock.Message.Body.ETH1Data == nil { + t.SignedBlock.Message.Body.ETH1Data = new(phase0.ETH1Data) + } + if err = t.SignedBlock.Message.Body.ETH1Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "SignedBlock.Message.Body.ETH1Data") + } + } + { // Field #2 'Graffiti' (static) + buf := buf[168:200] + copy(t.SignedBlock.Message.Body.Graffiti[:], buf) + } + // Field #3 'ProposerSlashings' (offset) + offset3 := int(binary.LittleEndian.Uint32(buf[200:204])) + if offset3 != totalSize { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset3, totalSize), "SignedBlock.Message.Body.ProposerSlashings:o") + } + // Field #4 'AttesterSlashings' (offset) + offset4 := int(binary.LittleEndian.Uint32(buf[204:208])) + if offset4 < offset3 || offset4 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset4, offset3, buflen), "SignedBlock.Message.Body.AttesterSlashings:o") + } + // Field #5 'Attestations' (offset) + offset5 := int(binary.LittleEndian.Uint32(buf[208:212])) + if offset5 < offset4 || offset5 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset5, offset4, buflen), "SignedBlock.Message.Body.Attestations:o") + } + // Field #6 'Deposits' (offset) + offset6 := int(binary.LittleEndian.Uint32(buf[212:216])) + if offset6 < offset5 || offset6 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset6, offset5, buflen), "SignedBlock.Message.Body.Deposits:o") + } + // Field #7 'VoluntaryExits' (offset) + offset7 := int(binary.LittleEndian.Uint32(buf[216:220])) + if offset7 < offset6 || offset7 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset7, offset6, buflen), "SignedBlock.Message.Body.VoluntaryExits:o") + } + { // Field #8 'SyncAggregate' (static) + buf := buf[220 : size1+220] + exproffset += int(size1) + val1 := t.SignedBlock.Message.Body.SyncAggregate + if val1 == nil { + val1 = new(altair.SyncAggregate) + } + exproffset := 0 + totalSize := size2 + 96 + buflen := len(buf) + if buflen < totalSize { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, totalSize), "SignedBlock.Message.Body.SyncAggregate") + } + if buflen > totalSize { + return sszutils.ErrorWithPath(sszutils.ErrTrailingDataFn(buflen-totalSize), "SignedBlock.Message.Body.SyncAggregate") + } + { // Field #0 'SyncCommitteeBits' (static) + buf := buf[0 : size2+0] + exproffset += int(size2) + val1.SyncCommitteeBits = sszutils.ExpandSlice(val1.SyncCommitteeBits, int(expr0)) + copy(val1.SyncCommitteeBits[:], buf) + } + { // Field #1 'SyncCommitteeSignature' (static) + buf := buf[exproffset+0 : exproffset+96] + copy(val1.SyncCommitteeSignature[:], buf) + } + t.SignedBlock.Message.Body.SyncAggregate = val1 + } + // Field #9 'ExecutionPayload' (offset) + offset9 := int(binary.LittleEndian.Uint32(buf[exproffset+220 : exproffset+224])) + if offset9 < offset7 || offset9 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset9, offset7, buflen), "SignedBlock.Message.Body.ExecutionPayload:o") + } + // Field #10 'BLSToExecutionChanges' (offset) + offset10 := int(binary.LittleEndian.Uint32(buf[exproffset+224 : exproffset+228])) + if offset10 < offset9 || offset10 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset10, offset9, buflen), "SignedBlock.Message.Body.BLSToExecutionChanges:o") + } + // Field #11 'BlobKZGCommitments' (offset) + offset11 := int(binary.LittleEndian.Uint32(buf[exproffset+228 : exproffset+232])) + if offset11 < offset10 || offset11 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset11, offset10, buflen), "SignedBlock.Message.Body.BlobKZGCommitments:o") + } + // Field #12 'ExecutionRequests' (offset) + offset12 := int(binary.LittleEndian.Uint32(buf[exproffset+232 : exproffset+236])) + if offset12 < offset11 || offset12 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset12, offset11, buflen), "SignedBlock.Message.Body.ExecutionRequests:o") + } + { // Field #3 'ProposerSlashings' (dynamic) + buf := buf[offset3:offset4] + val2 := t.SignedBlock.Message.Body.ProposerSlashings + itemCount := len(buf) / 416 + if len(buf)%416 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 416), "SignedBlock.Message.Body.ProposerSlashings") + } + if itemCount > int(expr1) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr1)), "SignedBlock.Message.Body.ProposerSlashings") + } + val2 = sszutils.ExpandSlice(val2, itemCount) + for idx1 := range itemCount { + if val2[idx1] == nil { + val2[idx1] = new(phase0.ProposerSlashing) + } + buf := buf[416*idx1 : 416*(idx1+1)] + if err = val2[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.ProposerSlashings[%d]", idx1) + } + } + t.SignedBlock.Message.Body.ProposerSlashings = val2 + } + { // Field #4 'AttesterSlashings' (dynamic) + buf := buf[offset4:offset5] + val3 := t.SignedBlock.Message.Body.AttesterSlashings + startOffset := int(0) + if len(buf) != 0 { + if len(buf) < 4 { + return sszutils.ErrorWithPath(sszutils.ErrListOffsetsEOFFn(len(buf), 4), "SignedBlock.Message.Body.AttesterSlashings") + } + startOffset = int(binary.LittleEndian.Uint32(buf[0:4])) + } + itemCount := startOffset / 4 + if startOffset%4 != 0 || len(buf) < startOffset || (len(buf) != 0 && startOffset == 0) { + return sszutils.ErrorWithPath(sszutils.ErrInvalidListStartOffsetFn(startOffset, len(buf)), "SignedBlock.Message.Body.AttesterSlashings") + } + if itemCount > int(expr2) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr2)), "SignedBlock.Message.Body.AttesterSlashings") + } + val3 = sszutils.ExpandSlice(val3, 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)), "SignedBlock.Message.Body.AttesterSlashings[%d]", idx1) + } + buf := buf[startOffset:endOffset] + startOffset = endOffset + val4 := val3[idx1] + if val4 == nil { + val4 = new(all.AttesterSlashing) + } + buflen := len(buf) + if buflen < 8 { + return sszutils.ErrorWithPathf(sszutils.ErrFixedFieldsEOFFn(buflen, 8), "SignedBlock.Message.Body.AttesterSlashings[%d]", idx1) + } + // Field #0 'Attestation1' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 8 { + return sszutils.ErrorWithPathf(sszutils.ErrFirstOffsetMismatchFn(offset0, 8), "SignedBlock.Message.Body.AttesterSlashings[%d].Attestation1:o", idx1) + } + // Field #1 'Attestation2' (offset) + offset1 := int(binary.LittleEndian.Uint32(buf[4:8])) + if offset1 < offset0 || offset1 > buflen { + return sszutils.ErrorWithPathf(sszutils.ErrOffsetOutOfRangeFn(offset1, offset0, buflen), "SignedBlock.Message.Body.AttesterSlashings[%d].Attestation2:o", idx1) + } + { // Field #0 'Attestation1' (dynamic) + buf := buf[offset0:offset1] + if val4.Attestation1 == nil { + val4.Attestation1 = new(all.IndexedAttestation) + } + buflen := len(buf) + if buflen < 228 { + return sszutils.ErrorWithPathf(sszutils.ErrFixedFieldsEOFFn(buflen, 228), "SignedBlock.Message.Body.AttesterSlashings[%d].Attestation1", idx1) + } + // Field #0 'AttestingIndices' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 228 { + return sszutils.ErrorWithPathf(sszutils.ErrFirstOffsetMismatchFn(offset0, 228), "SignedBlock.Message.Body.AttesterSlashings[%d].Attestation1.AttestingIndices:o", idx1) + } + { // Field #1 'Data' (static) + buf := buf[4:132] + if val4.Attestation1.Data == nil { + val4.Attestation1.Data = new(phase0.AttestationData) + } + if err = val4.Attestation1.Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.AttesterSlashings[%d].Attestation1.Data", idx1) + } + } + { // Field #2 'Signature' (static) + buf := buf[132:228] + copy(val4.Attestation1.Signature[:], buf) + } + { // Field #0 'AttestingIndices' (dynamic) + buf := buf[offset0:] + val5 := val4.Attestation1.AttestingIndices + itemCount := len(buf) / 8 + if len(buf)%8 != 0 { + return sszutils.ErrorWithPathf(sszutils.ErrListNotAlignedFn(len(buf), 8), "SignedBlock.Message.Body.AttesterSlashings[%d].Attestation1.AttestingIndices", idx1) + } + if itemCount > int(expr3) { + return sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(itemCount, int(expr3)), "SignedBlock.Message.Body.AttesterSlashings[%d].Attestation1.AttestingIndices", idx1) + } + val5 = sszutils.ExpandSlice(val5, itemCount) + sszutils.UnmarshalUint64Slice(val5, buf) + val4.Attestation1.AttestingIndices = val5 + } + } + { // Field #1 'Attestation2' (dynamic) + buf := buf[offset1:] + if val4.Attestation2 == nil { + val4.Attestation2 = new(all.IndexedAttestation) + } + buflen := len(buf) + if buflen < 228 { + return sszutils.ErrorWithPathf(sszutils.ErrFixedFieldsEOFFn(buflen, 228), "SignedBlock.Message.Body.AttesterSlashings[%d].Attestation2", idx1) + } + // Field #0 'AttestingIndices' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 228 { + return sszutils.ErrorWithPathf(sszutils.ErrFirstOffsetMismatchFn(offset0, 228), "SignedBlock.Message.Body.AttesterSlashings[%d].Attestation2.AttestingIndices:o", idx1) + } + { // Field #1 'Data' (static) + buf := buf[4:132] + if val4.Attestation2.Data == nil { + val4.Attestation2.Data = new(phase0.AttestationData) + } + if err = val4.Attestation2.Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.AttesterSlashings[%d].Attestation2.Data", idx1) + } + } + { // Field #2 'Signature' (static) + buf := buf[132:228] + copy(val4.Attestation2.Signature[:], buf) + } + { // Field #0 'AttestingIndices' (dynamic) + buf := buf[offset0:] + val6 := val4.Attestation2.AttestingIndices + itemCount := len(buf) / 8 + if len(buf)%8 != 0 { + return sszutils.ErrorWithPathf(sszutils.ErrListNotAlignedFn(len(buf), 8), "SignedBlock.Message.Body.AttesterSlashings[%d].Attestation2.AttestingIndices", idx1) + } + if itemCount > int(expr3) { + return sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(itemCount, int(expr3)), "SignedBlock.Message.Body.AttesterSlashings[%d].Attestation2.AttestingIndices", idx1) + } + val6 = sszutils.ExpandSlice(val6, itemCount) + sszutils.UnmarshalUint64Slice(val6, buf) + val4.Attestation2.AttestingIndices = val6 + } + } + val3[idx1] = val4 + } + t.SignedBlock.Message.Body.AttesterSlashings = val3 + } + { // Field #5 'Attestations' (dynamic) + buf := buf[offset5:offset6] + val7 := t.SignedBlock.Message.Body.Attestations + startOffset := int(0) + if len(buf) != 0 { + if len(buf) < 4 { + return sszutils.ErrorWithPath(sszutils.ErrListOffsetsEOFFn(len(buf), 4), "SignedBlock.Message.Body.Attestations") + } + startOffset = int(binary.LittleEndian.Uint32(buf[0:4])) + } + itemCount := startOffset / 4 + if startOffset%4 != 0 || len(buf) < startOffset || (len(buf) != 0 && startOffset == 0) { + return sszutils.ErrorWithPath(sszutils.ErrInvalidListStartOffsetFn(startOffset, len(buf)), "SignedBlock.Message.Body.Attestations") + } + if itemCount > int(expr4) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr4)), "SignedBlock.Message.Body.Attestations") + } + val7 = sszutils.ExpandSlice(val7, 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)), "SignedBlock.Message.Body.Attestations[%d]", idx1) + } + buf := buf[startOffset:endOffset] + startOffset = endOffset + val8 := val7[idx1] + if val8 == nil { + val8 = new(all.Attestation) + } + exproffset := 0 + totalSize := size3 + 228 + buflen := len(buf) + if buflen < totalSize { + return sszutils.ErrorWithPathf(sszutils.ErrFixedFieldsEOFFn(buflen, totalSize), "SignedBlock.Message.Body.Attestations[%d]", idx1) + } + // Field #0 'AggregationBits' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != totalSize { + return sszutils.ErrorWithPathf(sszutils.ErrFirstOffsetMismatchFn(offset0, totalSize), "SignedBlock.Message.Body.Attestations[%d].AggregationBits:o", idx1) + } + { // Field #1 'Data' (static) + buf := buf[4:132] + if val8.Data == nil { + val8.Data = new(phase0.AttestationData) + } + if err = val8.Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.Attestations[%d].Data", idx1) + } + } + { // Field #2 'Signature' (static) + buf := buf[132:228] + copy(val8.Signature[:], buf) + } + { // Field #3 'CommitteeBits' (static) + buf := buf[228 : size3+228] + exproffset += int(size3) + val8.CommitteeBits = sszutils.ExpandSlice(val8.CommitteeBits, int(expr5)) + copy(val8.CommitteeBits[:], buf) + } + { // Field #0 'AggregationBits' (dynamic) + buf := buf[offset0:] + val9 := val8.AggregationBits + blen := len(buf) + if blen == 0 || buf[blen-1] == 0x00 { + return sszutils.ErrorWithPathf(sszutils.ErrBitlistNotTerminatedFn(), "SignedBlock.Message.Body.Attestations[%d].AggregationBits", idx1) + } + bitCount := 8*(blen-1) + int(bits.Len8(buf[blen-1])) - 1 + if bitCount > int(expr3) { + return sszutils.ErrorWithPathf(sszutils.ErrBitlistLengthFn(bitCount, int(expr3)), "SignedBlock.Message.Body.Attestations[%d].AggregationBits", idx1) + } + val9 = sszutils.ExpandSlice(val9, blen) + copy(val9[:], buf) + val8.AggregationBits = val9 + } + val7[idx1] = val8 + } + t.SignedBlock.Message.Body.Attestations = val7 + } + { // Field #6 'Deposits' (dynamic) + buf := buf[offset6:offset7] + val10 := t.SignedBlock.Message.Body.Deposits + itemCount := len(buf) / size4 + if len(buf)%size4 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), size4), "SignedBlock.Message.Body.Deposits") + } + if itemCount > int(expr6) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "SignedBlock.Message.Body.Deposits") + } + val10 = sszutils.ExpandSlice(val10, itemCount) + for idx1 := range itemCount { + val11 := val10[idx1] + if val11 == nil { + val11 = new(phase0.Deposit) + } + buf := buf[size4*idx1 : size4*(idx1+1)] + exproffset := 0 + totalSize := size5 + 184 + buflen := len(buf) + if buflen < totalSize { + return sszutils.ErrorWithPathf(sszutils.ErrFixedFieldsEOFFn(buflen, totalSize), "SignedBlock.Message.Body.Deposits[%d]", idx1) + } + if buflen > totalSize { + return sszutils.ErrorWithPathf(sszutils.ErrTrailingDataFn(buflen-totalSize), "SignedBlock.Message.Body.Deposits[%d]", idx1) + } + { // Field #0 'Proof' (static) + buf := buf[0 : size5+0] + exproffset += int(size5) + val12 := val11.Proof + val12 = sszutils.ExpandSlice(val12, int(expr7)) + for idx2 := range int(expr7) { + buf := buf[32*idx2 : 32*(idx2+1)] + val12[idx2] = sszutils.ExpandSlice(val12[idx2], 32) + copy(val12[idx2][:], buf) + } + val11.Proof = val12 + } + { // Field #1 'Data' (static) + buf := buf[exproffset+0 : exproffset+184] + if val11.Data == nil { + val11.Data = new(phase0.DepositData) + } + if err = val11.Data.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.Deposits[%d].Data", idx1) + } + } + val10[idx1] = val11 + } + t.SignedBlock.Message.Body.Deposits = val10 + } + { // Field #7 'VoluntaryExits' (dynamic) + buf := buf[offset7:offset9] + val13 := t.SignedBlock.Message.Body.VoluntaryExits + itemCount := len(buf) / 112 + if len(buf)%112 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 112), "SignedBlock.Message.Body.VoluntaryExits") + } + if itemCount > int(expr8) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr8)), "SignedBlock.Message.Body.VoluntaryExits") + } + val13 = sszutils.ExpandSlice(val13, itemCount) + for idx1 := range itemCount { + if val13[idx1] == nil { + val13[idx1] = new(phase0.SignedVoluntaryExit) + } + buf := buf[112*idx1 : 112*(idx1+1)] + if err = val13[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.VoluntaryExits[%d]", idx1) + } + } + t.SignedBlock.Message.Body.VoluntaryExits = val13 + } + { // Field #9 'ExecutionPayload' (dynamic) + buf := buf[offset9:offset10] + if t.SignedBlock.Message.Body.ExecutionPayload == nil { + t.SignedBlock.Message.Body.ExecutionPayload = new(all.ExecutionPayload) + } + buflen := len(buf) + if buflen < 528 { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, 528), "SignedBlock.Message.Body.ExecutionPayload") + } + { // Field #0 'ParentHash' (static) + buf := buf[0:32] + copy(t.SignedBlock.Message.Body.ExecutionPayload.ParentHash[:], buf) + } + { // Field #1 'FeeRecipient' (static) + buf := buf[32:52] + copy(t.SignedBlock.Message.Body.ExecutionPayload.FeeRecipient[:], buf) + } + { // Field #2 'StateRoot' (static) + buf := buf[52:84] + copy(t.SignedBlock.Message.Body.ExecutionPayload.StateRoot[:], buf) + } + { // Field #3 'ReceiptsRoot' (static) + buf := buf[84:116] + copy(t.SignedBlock.Message.Body.ExecutionPayload.ReceiptsRoot[:], buf) + } + { // Field #4 'LogsBloom' (static) + buf := buf[116:372] + copy(t.SignedBlock.Message.Body.ExecutionPayload.LogsBloom[:], buf) + } + { // Field #5 'PrevRandao' (static) + buf := buf[372:404] + copy(t.SignedBlock.Message.Body.ExecutionPayload.PrevRandao[:], buf) + } + { // Field #6 'BlockNumber' (static) + buf := buf[404:412] + t.SignedBlock.Message.Body.ExecutionPayload.BlockNumber = binary.LittleEndian.Uint64(buf) + } + { // Field #7 'GasLimit' (static) + buf := buf[412:420] + t.SignedBlock.Message.Body.ExecutionPayload.GasLimit = binary.LittleEndian.Uint64(buf) + } + { // Field #8 'GasUsed' (static) + buf := buf[420:428] + t.SignedBlock.Message.Body.ExecutionPayload.GasUsed = binary.LittleEndian.Uint64(buf) + } + { // Field #9 'Timestamp' (static) + buf := buf[428:436] + t.SignedBlock.Message.Body.ExecutionPayload.Timestamp = binary.LittleEndian.Uint64(buf) + } + // Field #10 'ExtraData' (offset) + offset10 := int(binary.LittleEndian.Uint32(buf[436:440])) + if offset10 != 528 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset10, 528), "SignedBlock.Message.Body.ExecutionPayload.ExtraData:o") + } + { // Field #11 'BaseFeePerGas' (static) + buf := buf[440:472] + val14 := t.SignedBlock.Message.Body.ExecutionPayload.BaseFeePerGas + if val14 == nil { + val14 = new(uint256.Int) + } + sszutils.UnmarshalUint64Slice((*val14)[:4], buf) + t.SignedBlock.Message.Body.ExecutionPayload.BaseFeePerGas = val14 + } + { // Field #12 'BlockHash' (static) + buf := buf[472:504] + copy(t.SignedBlock.Message.Body.ExecutionPayload.BlockHash[:], buf) + } + // Field #13 'Transactions' (offset) + offset13 := int(binary.LittleEndian.Uint32(buf[504:508])) + if offset13 < offset10 || offset13 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset13, offset10, buflen), "SignedBlock.Message.Body.ExecutionPayload.Transactions:o") + } + // Field #14 'Withdrawals' (offset) + offset14 := int(binary.LittleEndian.Uint32(buf[508:512])) + if offset14 < offset13 || offset14 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset14, offset13, buflen), "SignedBlock.Message.Body.ExecutionPayload.Withdrawals:o") + } + { // Field #15 'BlobGasUsed' (static) + buf := buf[512:520] + t.SignedBlock.Message.Body.ExecutionPayload.BlobGasUsed = binary.LittleEndian.Uint64(buf) + } + { // Field #16 'ExcessBlobGas' (static) + buf := buf[520:528] + t.SignedBlock.Message.Body.ExecutionPayload.ExcessBlobGas = binary.LittleEndian.Uint64(buf) + } + { // Field #10 'ExtraData' (dynamic) + buf := buf[offset10:offset13] + if len(buf) > int(expr9) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(len(buf), int(expr9)), "SignedBlock.Message.Body.ExecutionPayload.ExtraData") + } + t.SignedBlock.Message.Body.ExecutionPayload.ExtraData = sszutils.ExpandSlice(t.SignedBlock.Message.Body.ExecutionPayload.ExtraData, len(buf)) + copy(t.SignedBlock.Message.Body.ExecutionPayload.ExtraData[:], buf) + } + { // Field #13 'Transactions' (dynamic) + buf := buf[offset13:offset14] + val15 := t.SignedBlock.Message.Body.ExecutionPayload.Transactions + startOffset := int(0) + if len(buf) != 0 { + if len(buf) < 4 { + return sszutils.ErrorWithPath(sszutils.ErrListOffsetsEOFFn(len(buf), 4), "SignedBlock.Message.Body.ExecutionPayload.Transactions") + } + startOffset = int(binary.LittleEndian.Uint32(buf[0:4])) + } + itemCount := startOffset / 4 + if startOffset%4 != 0 || len(buf) < startOffset || (len(buf) != 0 && startOffset == 0) { + return sszutils.ErrorWithPath(sszutils.ErrInvalidListStartOffsetFn(startOffset, len(buf)), "SignedBlock.Message.Body.ExecutionPayload.Transactions") + } + if itemCount > int(expr10) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr10)), "SignedBlock.Message.Body.ExecutionPayload.Transactions") + } + val15 = sszutils.ExpandSlice(val15, 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)), "SignedBlock.Message.Body.ExecutionPayload.Transactions[%d]", idx1) + } + buf := buf[startOffset:endOffset] + startOffset = endOffset + val16 := val15[idx1] + if len(buf) > int(expr11) { + return sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(len(buf), int(expr11)), "SignedBlock.Message.Body.ExecutionPayload.Transactions[%d]", idx1) + } + val16 = sszutils.ExpandSlice(val16, len(buf)) + copy(val16[:], buf) + val15[idx1] = val16 + } + t.SignedBlock.Message.Body.ExecutionPayload.Transactions = val15 + } + { // Field #14 'Withdrawals' (dynamic) + buf := buf[offset14:] + val17 := t.SignedBlock.Message.Body.ExecutionPayload.Withdrawals + itemCount := len(buf) / 44 + if len(buf)%44 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 44), "SignedBlock.Message.Body.ExecutionPayload.Withdrawals") + } + if itemCount > int(expr12) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr12)), "SignedBlock.Message.Body.ExecutionPayload.Withdrawals") + } + val17 = sszutils.ExpandSlice(val17, itemCount) + for idx1 := range itemCount { + if val17[idx1] == nil { + val17[idx1] = new(capella.Withdrawal) + } + buf := buf[44*idx1 : 44*(idx1+1)] + if err = val17[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.ExecutionPayload.Withdrawals[%d]", idx1) + } + } + t.SignedBlock.Message.Body.ExecutionPayload.Withdrawals = val17 + } + } + { // Field #10 'BLSToExecutionChanges' (dynamic) + buf := buf[offset10:offset11] + val18 := t.SignedBlock.Message.Body.BLSToExecutionChanges + itemCount := len(buf) / 172 + if len(buf)%172 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 172), "SignedBlock.Message.Body.BLSToExecutionChanges") + } + if itemCount > int(expr13) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr13)), "SignedBlock.Message.Body.BLSToExecutionChanges") + } + val18 = sszutils.ExpandSlice(val18, itemCount) + for idx1 := range itemCount { + if val18[idx1] == nil { + val18[idx1] = new(capella.SignedBLSToExecutionChange) + } + buf := buf[172*idx1 : 172*(idx1+1)] + if err = val18[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.BLSToExecutionChanges[%d]", idx1) + } + } + t.SignedBlock.Message.Body.BLSToExecutionChanges = val18 + } + { // Field #11 'BlobKZGCommitments' (dynamic) + buf := buf[offset11:offset12] + val19 := t.SignedBlock.Message.Body.BlobKZGCommitments + itemCount := len(buf) / 48 + if len(buf)%48 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 48), "SignedBlock.Message.Body.BlobKZGCommitments") + } + if itemCount > int(expr14) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr14)), "SignedBlock.Message.Body.BlobKZGCommitments") + } + val19 = sszutils.ExpandSlice(val19, itemCount) + sszutils.UnmarshalFixedBytesSlice(val19[:itemCount], buf) + t.SignedBlock.Message.Body.BlobKZGCommitments = val19 + } + { // Field #12 'ExecutionRequests' (dynamic) + buf := buf[offset12:] + if t.SignedBlock.Message.Body.ExecutionRequests == nil { + t.SignedBlock.Message.Body.ExecutionRequests = new(all.ExecutionRequests) + } + buflen := len(buf) + if buflen < 12 { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, 12), "SignedBlock.Message.Body.ExecutionRequests") + } + // Field #0 'Deposits' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 12 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset0, 12), "SignedBlock.Message.Body.ExecutionRequests.Deposits:o") + } + // Field #1 'Withdrawals' (offset) + offset1 := int(binary.LittleEndian.Uint32(buf[4:8])) + if offset1 < offset0 || offset1 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset1, offset0, buflen), "SignedBlock.Message.Body.ExecutionRequests.Withdrawals:o") + } + // Field #2 'Consolidations' (offset) + offset2 := int(binary.LittleEndian.Uint32(buf[8:12])) + if offset2 < offset1 || offset2 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset2, offset1, buflen), "SignedBlock.Message.Body.ExecutionRequests.Consolidations:o") + } + { // Field #0 'Deposits' (dynamic) + buf := buf[offset0:offset1] + val20 := t.SignedBlock.Message.Body.ExecutionRequests.Deposits + itemCount := len(buf) / 192 + if len(buf)%192 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 192), "SignedBlock.Message.Body.ExecutionRequests.Deposits") + } + if itemCount > int(expr15) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr15)), "SignedBlock.Message.Body.ExecutionRequests.Deposits") + } + val20 = sszutils.ExpandSlice(val20, itemCount) + for idx1 := range itemCount { + if val20[idx1] == nil { + val20[idx1] = new(electra1.DepositRequest) + } + buf := buf[192*idx1 : 192*(idx1+1)] + if err = val20[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.ExecutionRequests.Deposits[%d]", idx1) + } + } + t.SignedBlock.Message.Body.ExecutionRequests.Deposits = val20 + } + { // Field #1 'Withdrawals' (dynamic) + buf := buf[offset1:offset2] + val21 := t.SignedBlock.Message.Body.ExecutionRequests.Withdrawals + itemCount := len(buf) / 76 + if len(buf)%76 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 76), "SignedBlock.Message.Body.ExecutionRequests.Withdrawals") + } + if itemCount > int(expr16) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr16)), "SignedBlock.Message.Body.ExecutionRequests.Withdrawals") + } + val21 = sszutils.ExpandSlice(val21, itemCount) + for idx1 := range itemCount { + if val21[idx1] == nil { + val21[idx1] = new(electra1.WithdrawalRequest) + } + buf := buf[76*idx1 : 76*(idx1+1)] + if err = val21[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.ExecutionRequests.Withdrawals[%d]", idx1) + } + } + t.SignedBlock.Message.Body.ExecutionRequests.Withdrawals = val21 + } + { // Field #2 'Consolidations' (dynamic) + buf := buf[offset2:] + val22 := t.SignedBlock.Message.Body.ExecutionRequests.Consolidations + itemCount := len(buf) / 116 + if len(buf)%116 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 116), "SignedBlock.Message.Body.ExecutionRequests.Consolidations") + } + if itemCount > int(expr17) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr17)), "SignedBlock.Message.Body.ExecutionRequests.Consolidations") + } + val22 = sszutils.ExpandSlice(val22, itemCount) + for idx1 := range itemCount { + if val22[idx1] == nil { + val22[idx1] = new(electra1.ConsolidationRequest) + } + buf := buf[116*idx1 : 116*(idx1+1)] + if err = val22[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.ExecutionRequests.Consolidations[%d]", idx1) + } + } + t.SignedBlock.Message.Body.ExecutionRequests.Consolidations = val22 + } + } + } + } + } + { // Field #1 'KZGProofs' (dynamic) + buf := buf[offset1:offset2] + val23 := t.KZGProofs + itemCount := len(buf) / 48 + if len(buf)%48 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 48), "KZGProofs") + } + if itemCount > 33554432 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 33554432), "KZGProofs") + } + val23 = sszutils.ExpandSlice(val23, itemCount) + sszutils.UnmarshalFixedBytesSlice(val23[:itemCount], buf) + t.KZGProofs = val23 + } + { // Field #2 'Blobs' (dynamic) + buf := buf[offset2:] + val24 := t.Blobs + itemCount := len(buf) / 131072 + if len(buf)%131072 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 131072), "Blobs") + } + if itemCount > 4096 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 4096), "Blobs") + } + val24 = sszutils.ExpandSlice(val24, itemCount) + sszutils.UnmarshalFixedBytesSlice(val24[:itemCount], buf) + t.Blobs = val24 + } + return nil +} + +func (t *SignedBlockContents) SizeSSZDynView(view any) func(ds sszutils.DynamicSpecs) int { + switch view.(type) { + case *deneb.SignedBlockContents: + return t.sizeSSZView_SignedBlockContents + case *electra.SignedBlockContents: + return t.sizeSSZView_SignedBlockContents_0 + case *fulu.SignedBlockContents: + return t.sizeSSZView_SignedBlockContents_1 + } + return nil +} +func (t *SignedBlockContents) sizeSSZView_SignedBlockContents(ds sszutils.DynamicSpecs) (size int) { + expr0, err := sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE/8", 64) + if err != nil { + return 0 + } + expr1, err := sszutils.ResolveSpecValueWithDefault(ds, "DEPOSIT_CONTRACT_TREE_DEPTH+1", 33) + if err != nil { + return 0 + } + if t == nil { + t = new(SignedBlockContents) + } + // Field #0 'SignedBlock' offset (4 bytes) + // Field #1 'KZGProofs' offset (4 bytes) + // Field #2 'Blobs' offset (4 bytes) + size += 12 + { // Dynamic field #0 'SignedBlock' + t := t.SignedBlock + if t == nil { + t = new(all.SignedBeaconBlock) + } + // Field #0 'Message' offset (4 bytes) + // Field #1 'Signature' static (96 bytes) + size += 100 + { // Dynamic field #0 'Message' + t := t.Message + if t == nil { + t = new(all.BeaconBlock) + } + // Field #0 'Slot' static (8 bytes) + // Field #1 'ProposerIndex' static (8 bytes) + // Field #2 'ParentRoot' static (32 bytes) + // Field #3 'StateRoot' static (32 bytes) + // Field #4 'Body' offset (4 bytes) + size += 84 + { // Dynamic field #4 'Body' + t := t.Body + if t == nil { + t = new(all.BeaconBlockBody) + } + // Field #0 'RANDAOReveal' static (96 bytes) + // Field #1 'ETH1Data' static (72 bytes) + // Field #2 'Graffiti' static (32 bytes) + // Field #3 'ProposerSlashings' offset (4 bytes) + // Field #4 'AttesterSlashings' offset (4 bytes) + // Field #5 'Attestations' offset (4 bytes) + // Field #6 'Deposits' offset (4 bytes) + // Field #7 'VoluntaryExits' offset (4 bytes) + // Field #9 'ExecutionPayload' offset (4 bytes) + // Field #10 'BLSToExecutionChanges' offset (4 bytes) + // Field #11 'BlobKZGCommitments' offset (4 bytes) + size += 232 + { // Field #8 'SyncAggregate' + t := t.SyncAggregate + if t == nil { + t = new(altair.SyncAggregate) + } + // Field #1 'SyncCommitteeSignature' static (96 bytes) + size += 96 + { // Field #0 'SyncCommitteeBits' + size += int(expr0) + } + } + { // Dynamic field #3 'ProposerSlashings' + size += len(t.ProposerSlashings) * 416 + } + { // Dynamic field #4 'AttesterSlashings' + t := t.AttesterSlashings + vlen := len(t) + size += vlen * 4 // Offsets + for i1 := range vlen { + t := t[i1] + if t == nil { + t = new(all.AttesterSlashing) + } + // Field #0 'Attestation1' offset (4 bytes) + // Field #1 'Attestation2' offset (4 bytes) + size += 8 + { // Dynamic field #0 'Attestation1' + t := t.Attestation1 + if t == nil { + t = new(all.IndexedAttestation) + } + // Field #0 'AttestingIndices' offset (4 bytes) + // Field #1 'Data' static (128 bytes) + // Field #2 'Signature' static (96 bytes) + size += 228 + { // Dynamic field #0 'AttestingIndices' + size += len(t.AttestingIndices) * 8 + } + } + { // Dynamic field #1 'Attestation2' + t := t.Attestation2 + if t == nil { + t = new(all.IndexedAttestation) + } + // Field #0 'AttestingIndices' offset (4 bytes) + // Field #1 'Data' static (128 bytes) + // Field #2 'Signature' static (96 bytes) + size += 228 + { // Dynamic field #0 'AttestingIndices' + size += len(t.AttestingIndices) * 8 + } + } + } + } + { // Dynamic field #5 'Attestations' + t := t.Attestations + vlen := len(t) + size += vlen * 4 // Offsets + for i2 := range vlen { + t := t[i2] + if t == nil { + t = new(all.Attestation) + } + // Field #0 'AggregationBits' offset (4 bytes) + // Field #1 'Data' static (128 bytes) + // Field #2 'Signature' static (96 bytes) + size += 228 + { // Dynamic field #0 'AggregationBits' + if len(t.AggregationBits) == 0 { + size += 1 + } else { + size += len(t.AggregationBits) + } + } + } + } + { // Dynamic field #6 'Deposits' + t := t.Deposits + vlen := len(t) + if vlen > 0 { + s1 := 0 + t := t[0] + if t == nil { + t = new(phase0.Deposit) + } + // Field #1 'Data' static (184 bytes) + s1 += 184 + { // Field #0 'Proof' + s1 += int(expr1) * 32 + } + size += s1 * vlen + } + } + { // Dynamic field #7 'VoluntaryExits' + size += len(t.VoluntaryExits) * 112 + } + { // Dynamic field #9 'ExecutionPayload' + t := t.ExecutionPayload + if t == nil { + t = new(all.ExecutionPayload) + } + // Field #0 'ParentHash' static (32 bytes) + // Field #1 'FeeRecipient' static (20 bytes) + // Field #2 'StateRoot' static (32 bytes) + // Field #3 'ReceiptsRoot' static (32 bytes) + // Field #4 'LogsBloom' static (256 bytes) + // Field #5 'PrevRandao' static (32 bytes) + // Field #6 'BlockNumber' static (8 bytes) + // Field #7 'GasLimit' static (8 bytes) + // Field #8 'GasUsed' static (8 bytes) + // Field #9 'Timestamp' static (8 bytes) + // Field #10 'ExtraData' offset (4 bytes) + // Field #11 'BaseFeePerGas' static (32 bytes) + // Field #12 'BlockHash' static (32 bytes) + // Field #13 'Transactions' offset (4 bytes) + // Field #14 'Withdrawals' offset (4 bytes) + // Field #15 'BlobGasUsed' static (8 bytes) + // Field #16 'ExcessBlobGas' static (8 bytes) + size += 528 + { // Dynamic field #10 'ExtraData' + size += len(t.ExtraData) + } + { // Dynamic field #13 'Transactions' + t := t.Transactions + vlen := len(t) + size += vlen * 4 // Offsets + for i3 := range vlen { + size += len(t[i3]) + } + } + { // Dynamic field #14 'Withdrawals' + size += len(t.Withdrawals) * 44 + } + } + { // Dynamic field #10 'BLSToExecutionChanges' + size += len(t.BLSToExecutionChanges) * 172 + } + { // Dynamic field #11 'BlobKZGCommitments' + size += len(t.BlobKZGCommitments) * 48 + } + } + } + } + { // Dynamic field #1 'KZGProofs' + size += len(t.KZGProofs) * 48 + } + { // Dynamic field #2 'Blobs' + size += len(t.Blobs) * 131072 + } + return size +} + +func (t *SignedBlockContents) sizeSSZView_SignedBlockContents_0(ds sszutils.DynamicSpecs) (size int) { + expr0, err := sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE/8", 64) + if err != nil { + return 0 + } + expr1, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_COMMITTEES_PER_SLOT/8", 8) + if err != nil { + return 0 + } + expr2, err := sszutils.ResolveSpecValueWithDefault(ds, "DEPOSIT_CONTRACT_TREE_DEPTH+1", 33) + if err != nil { + return 0 + } + if t == nil { + t = new(SignedBlockContents) + } + // Field #0 'SignedBlock' offset (4 bytes) + // Field #1 'KZGProofs' offset (4 bytes) + // Field #2 'Blobs' offset (4 bytes) + size += 12 + { // Dynamic field #0 'SignedBlock' + t := t.SignedBlock + if t == nil { + t = new(all.SignedBeaconBlock) + } + // Field #0 'Message' offset (4 bytes) + // Field #1 'Signature' static (96 bytes) + size += 100 + { // Dynamic field #0 'Message' + t := t.Message + if t == nil { + t = new(all.BeaconBlock) + } + // Field #0 'Slot' static (8 bytes) + // Field #1 'ProposerIndex' static (8 bytes) + // Field #2 'ParentRoot' static (32 bytes) + // Field #3 'StateRoot' static (32 bytes) + // Field #4 'Body' offset (4 bytes) + size += 84 + { // Dynamic field #4 'Body' + t := t.Body + if t == nil { + t = new(all.BeaconBlockBody) + } + // Field #0 'RANDAOReveal' static (96 bytes) + // Field #1 'ETH1Data' static (72 bytes) + // Field #2 'Graffiti' static (32 bytes) + // Field #3 'ProposerSlashings' offset (4 bytes) + // Field #4 'AttesterSlashings' offset (4 bytes) + // Field #5 'Attestations' offset (4 bytes) + // Field #6 'Deposits' offset (4 bytes) + // Field #7 'VoluntaryExits' offset (4 bytes) + // Field #9 'ExecutionPayload' offset (4 bytes) + // Field #10 'BLSToExecutionChanges' offset (4 bytes) + // Field #11 'BlobKZGCommitments' offset (4 bytes) + // Field #12 'ExecutionRequests' offset (4 bytes) + size += 236 + { // Field #8 'SyncAggregate' + t := t.SyncAggregate + if t == nil { + t = new(altair.SyncAggregate) + } + // Field #1 'SyncCommitteeSignature' static (96 bytes) + size += 96 + { // Field #0 'SyncCommitteeBits' + size += int(expr0) + } + } + { // Dynamic field #3 'ProposerSlashings' + size += len(t.ProposerSlashings) * 416 + } + { // Dynamic field #4 'AttesterSlashings' + t := t.AttesterSlashings + vlen := len(t) + size += vlen * 4 // Offsets + for i1 := range vlen { + t := t[i1] + if t == nil { + t = new(all.AttesterSlashing) + } + // Field #0 'Attestation1' offset (4 bytes) + // Field #1 'Attestation2' offset (4 bytes) + size += 8 + { // Dynamic field #0 'Attestation1' + t := t.Attestation1 + if t == nil { + t = new(all.IndexedAttestation) + } + // Field #0 'AttestingIndices' offset (4 bytes) + // Field #1 'Data' static (128 bytes) + // Field #2 'Signature' static (96 bytes) + size += 228 + { // Dynamic field #0 'AttestingIndices' + size += len(t.AttestingIndices) * 8 + } + } + { // Dynamic field #1 'Attestation2' + t := t.Attestation2 + if t == nil { + t = new(all.IndexedAttestation) + } + // Field #0 'AttestingIndices' offset (4 bytes) + // Field #1 'Data' static (128 bytes) + // Field #2 'Signature' static (96 bytes) + size += 228 + { // Dynamic field #0 'AttestingIndices' + size += len(t.AttestingIndices) * 8 + } + } + } + } + { // Dynamic field #5 'Attestations' + t := t.Attestations + vlen := len(t) + size += vlen * 4 // Offsets + for i2 := range vlen { + t := t[i2] + if t == nil { + t = new(all.Attestation) + } + // Field #0 'AggregationBits' offset (4 bytes) + // Field #1 'Data' static (128 bytes) + // Field #2 'Signature' static (96 bytes) + size += 228 + { // Field #3 'CommitteeBits' + size += int(expr1) + } + { // Dynamic field #0 'AggregationBits' + if len(t.AggregationBits) == 0 { + size += 1 + } else { + size += len(t.AggregationBits) + } + } + } + } + { // Dynamic field #6 'Deposits' + t := t.Deposits + vlen := len(t) + if vlen > 0 { + s1 := 0 + t := t[0] + if t == nil { + t = new(phase0.Deposit) + } + // Field #1 'Data' static (184 bytes) + s1 += 184 + { // Field #0 'Proof' + s1 += int(expr2) * 32 + } + size += s1 * vlen + } + } + { // Dynamic field #7 'VoluntaryExits' + size += len(t.VoluntaryExits) * 112 + } + { // Dynamic field #9 'ExecutionPayload' + t := t.ExecutionPayload + if t == nil { + t = new(all.ExecutionPayload) + } + // Field #0 'ParentHash' static (32 bytes) + // Field #1 'FeeRecipient' static (20 bytes) + // Field #2 'StateRoot' static (32 bytes) + // Field #3 'ReceiptsRoot' static (32 bytes) + // Field #4 'LogsBloom' static (256 bytes) + // Field #5 'PrevRandao' static (32 bytes) + // Field #6 'BlockNumber' static (8 bytes) + // Field #7 'GasLimit' static (8 bytes) + // Field #8 'GasUsed' static (8 bytes) + // Field #9 'Timestamp' static (8 bytes) + // Field #10 'ExtraData' offset (4 bytes) + // Field #11 'BaseFeePerGas' static (32 bytes) + // Field #12 'BlockHash' static (32 bytes) + // Field #13 'Transactions' offset (4 bytes) + // Field #14 'Withdrawals' offset (4 bytes) + // Field #15 'BlobGasUsed' static (8 bytes) + // Field #16 'ExcessBlobGas' static (8 bytes) + size += 528 + { // Dynamic field #10 'ExtraData' + size += len(t.ExtraData) + } + { // Dynamic field #13 'Transactions' + t := t.Transactions + vlen := len(t) + size += vlen * 4 // Offsets + for i3 := range vlen { + size += len(t[i3]) + } + } + { // Dynamic field #14 'Withdrawals' + size += len(t.Withdrawals) * 44 + } + } + { // Dynamic field #10 'BLSToExecutionChanges' + size += len(t.BLSToExecutionChanges) * 172 + } + { // Dynamic field #11 'BlobKZGCommitments' + size += len(t.BlobKZGCommitments) * 48 + } + { // Dynamic field #12 'ExecutionRequests' + t := t.ExecutionRequests + if t == nil { + t = new(all.ExecutionRequests) + } + // Field #0 'Deposits' offset (4 bytes) + // Field #1 'Withdrawals' offset (4 bytes) + // Field #2 'Consolidations' offset (4 bytes) + size += 12 + { // Dynamic field #0 'Deposits' + size += len(t.Deposits) * 192 + } + { // Dynamic field #1 'Withdrawals' + size += len(t.Withdrawals) * 76 + } + { // Dynamic field #2 'Consolidations' + size += len(t.Consolidations) * 116 + } + } + } + } + } + { // Dynamic field #1 'KZGProofs' + size += len(t.KZGProofs) * 48 + } + { // Dynamic field #2 'Blobs' + size += len(t.Blobs) * 131072 + } + return size +} + +func (t *SignedBlockContents) sizeSSZView_SignedBlockContents_1(ds sszutils.DynamicSpecs) (size int) { + expr0, err := sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE/8", 64) + if err != nil { + return 0 + } + expr1, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_COMMITTEES_PER_SLOT/8", 8) + if err != nil { + return 0 + } + expr2, err := sszutils.ResolveSpecValueWithDefault(ds, "DEPOSIT_CONTRACT_TREE_DEPTH+1", 33) + if err != nil { + return 0 + } + if t == nil { + t = new(SignedBlockContents) + } + // Field #0 'SignedBlock' offset (4 bytes) + // Field #1 'KZGProofs' offset (4 bytes) + // Field #2 'Blobs' offset (4 bytes) + size += 12 + { // Dynamic field #0 'SignedBlock' + t := t.SignedBlock + if t == nil { + t = new(all.SignedBeaconBlock) + } + // Field #0 'Message' offset (4 bytes) + // Field #1 'Signature' static (96 bytes) + size += 100 + { // Dynamic field #0 'Message' + t := t.Message + if t == nil { + t = new(all.BeaconBlock) + } + // Field #0 'Slot' static (8 bytes) + // Field #1 'ProposerIndex' static (8 bytes) + // Field #2 'ParentRoot' static (32 bytes) + // Field #3 'StateRoot' static (32 bytes) + // Field #4 'Body' offset (4 bytes) + size += 84 + { // Dynamic field #4 'Body' + t := t.Body + if t == nil { + t = new(all.BeaconBlockBody) + } + // Field #0 'RANDAOReveal' static (96 bytes) + // Field #1 'ETH1Data' static (72 bytes) + // Field #2 'Graffiti' static (32 bytes) + // Field #3 'ProposerSlashings' offset (4 bytes) + // Field #4 'AttesterSlashings' offset (4 bytes) + // Field #5 'Attestations' offset (4 bytes) + // Field #6 'Deposits' offset (4 bytes) + // Field #7 'VoluntaryExits' offset (4 bytes) + // Field #9 'ExecutionPayload' offset (4 bytes) + // Field #10 'BLSToExecutionChanges' offset (4 bytes) + // Field #11 'BlobKZGCommitments' offset (4 bytes) + // Field #12 'ExecutionRequests' offset (4 bytes) + size += 236 + { // Field #8 'SyncAggregate' + t := t.SyncAggregate + if t == nil { + t = new(altair.SyncAggregate) + } + // Field #1 'SyncCommitteeSignature' static (96 bytes) + size += 96 + { // Field #0 'SyncCommitteeBits' + size += int(expr0) + } + } + { // Dynamic field #3 'ProposerSlashings' + size += len(t.ProposerSlashings) * 416 + } + { // Dynamic field #4 'AttesterSlashings' + t := t.AttesterSlashings + vlen := len(t) + size += vlen * 4 // Offsets + for i1 := range vlen { + t := t[i1] + if t == nil { + t = new(all.AttesterSlashing) + } + // Field #0 'Attestation1' offset (4 bytes) + // Field #1 'Attestation2' offset (4 bytes) + size += 8 + { // Dynamic field #0 'Attestation1' + t := t.Attestation1 + if t == nil { + t = new(all.IndexedAttestation) + } + // Field #0 'AttestingIndices' offset (4 bytes) + // Field #1 'Data' static (128 bytes) + // Field #2 'Signature' static (96 bytes) + size += 228 + { // Dynamic field #0 'AttestingIndices' + size += len(t.AttestingIndices) * 8 + } + } + { // Dynamic field #1 'Attestation2' + t := t.Attestation2 + if t == nil { + t = new(all.IndexedAttestation) + } + // Field #0 'AttestingIndices' offset (4 bytes) + // Field #1 'Data' static (128 bytes) + // Field #2 'Signature' static (96 bytes) + size += 228 + { // Dynamic field #0 'AttestingIndices' + size += len(t.AttestingIndices) * 8 + } + } + } + } + { // Dynamic field #5 'Attestations' + t := t.Attestations + vlen := len(t) + size += vlen * 4 // Offsets + for i2 := range vlen { + t := t[i2] + if t == nil { + t = new(all.Attestation) + } + // Field #0 'AggregationBits' offset (4 bytes) + // Field #1 'Data' static (128 bytes) + // Field #2 'Signature' static (96 bytes) + size += 228 + { // Field #3 'CommitteeBits' + size += int(expr1) + } + { // Dynamic field #0 'AggregationBits' + if len(t.AggregationBits) == 0 { + size += 1 + } else { + size += len(t.AggregationBits) + } + } + } + } + { // Dynamic field #6 'Deposits' + t := t.Deposits + vlen := len(t) + if vlen > 0 { + s1 := 0 + t := t[0] + if t == nil { + t = new(phase0.Deposit) + } + // Field #1 'Data' static (184 bytes) + s1 += 184 + { // Field #0 'Proof' + s1 += int(expr2) * 32 + } + size += s1 * vlen + } + } + { // Dynamic field #7 'VoluntaryExits' + size += len(t.VoluntaryExits) * 112 + } + { // Dynamic field #9 'ExecutionPayload' + t := t.ExecutionPayload + if t == nil { + t = new(all.ExecutionPayload) + } + // Field #0 'ParentHash' static (32 bytes) + // Field #1 'FeeRecipient' static (20 bytes) + // Field #2 'StateRoot' static (32 bytes) + // Field #3 'ReceiptsRoot' static (32 bytes) + // Field #4 'LogsBloom' static (256 bytes) + // Field #5 'PrevRandao' static (32 bytes) + // Field #6 'BlockNumber' static (8 bytes) + // Field #7 'GasLimit' static (8 bytes) + // Field #8 'GasUsed' static (8 bytes) + // Field #9 'Timestamp' static (8 bytes) + // Field #10 'ExtraData' offset (4 bytes) + // Field #11 'BaseFeePerGas' static (32 bytes) + // Field #12 'BlockHash' static (32 bytes) + // Field #13 'Transactions' offset (4 bytes) + // Field #14 'Withdrawals' offset (4 bytes) + // Field #15 'BlobGasUsed' static (8 bytes) + // Field #16 'ExcessBlobGas' static (8 bytes) + size += 528 + { // Dynamic field #10 'ExtraData' + size += len(t.ExtraData) + } + { // Dynamic field #13 'Transactions' + t := t.Transactions + vlen := len(t) + size += vlen * 4 // Offsets + for i3 := range vlen { + size += len(t[i3]) + } + } + { // Dynamic field #14 'Withdrawals' + size += len(t.Withdrawals) * 44 + } + } + { // Dynamic field #10 'BLSToExecutionChanges' + size += len(t.BLSToExecutionChanges) * 172 + } + { // Dynamic field #11 'BlobKZGCommitments' + size += len(t.BlobKZGCommitments) * 48 + } + { // Dynamic field #12 'ExecutionRequests' + t := t.ExecutionRequests + if t == nil { + t = new(all.ExecutionRequests) + } + // Field #0 'Deposits' offset (4 bytes) + // Field #1 'Withdrawals' offset (4 bytes) + // Field #2 'Consolidations' offset (4 bytes) + size += 12 + { // Dynamic field #0 'Deposits' + size += len(t.Deposits) * 192 + } + { // Dynamic field #1 'Withdrawals' + size += len(t.Withdrawals) * 76 + } + { // Dynamic field #2 'Consolidations' + size += len(t.Consolidations) * 116 + } + } + } + } + } + { // Dynamic field #1 'KZGProofs' + size += len(t.KZGProofs) * 48 + } + { // Dynamic field #2 'Blobs' + size += len(t.Blobs) * 131072 + } + return size +} + +func (t *SignedBlockContents) HashTreeRootWithDynView(view any) func(ds sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + switch view.(type) { + case *deneb.SignedBlockContents: + return t.hashTreeRootView_SignedBlockContents + case *electra.SignedBlockContents: + return t.hashTreeRootView_SignedBlockContents_0 + case *fulu.SignedBlockContents: + return t.hashTreeRootView_SignedBlockContents_1 + } + return nil +} +func (t *SignedBlockContents) hashTreeRootView_SignedBlockContents(ds sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + expr0, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_PROPOSER_SLASHINGS", 16) + if err != nil { + return err + } + expr1, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_ATTESTER_SLASHINGS", 2) + if err != nil { + return err + } + expr2, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_ATTESTATIONS", 128) + if err != nil { + return err + } + expr3, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_VALIDATORS_PER_COMMITTEE", 2048) + if err != nil { + return err + } + expr4, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_DEPOSITS", 16) + if err != nil { + return err + } + expr5, err := sszutils.ResolveSpecValueWithDefault(ds, "DEPOSIT_CONTRACT_TREE_DEPTH+1", 33) + if err != nil { + return err + } + expr6, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_VOLUNTARY_EXITS", 16) + if err != nil { + return err + } + expr7, err := sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE/8", 64) + if err != nil { + return err + } + expr8, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_EXTRA_DATA_BYTES", 32) + if err != nil { + return err + } + expr9, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_TRANSACTIONS_PER_PAYLOAD", 1048576) + if err != nil { + return err + } + expr10, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BYTES_PER_TRANSACTION", 1073741824) + if err != nil { + return err + } + expr11, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_WITHDRAWALS_PER_PAYLOAD", 16) + if err != nil { + return err + } + expr12, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BLS_TO_EXECUTION_CHANGES", 16) + if err != nil { + return err + } + expr13, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BLOB_COMMITMENTS_PER_BLOCK", 4096) + if err != nil { + return err + } + if t == nil { + t = new(SignedBlockContents) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'SignedBlock' + t := t.SignedBlock + if t == nil { + t = new(all.SignedBeaconBlock) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Message' + t := t.Message + if t == nil { + t = new(all.BeaconBlock) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Slot' + hh.PutUint64(uint64(t.Slot)) + } + { // Field #1 'ProposerIndex' + hh.PutUint64(uint64(t.ProposerIndex)) + } + { // Field #2 'ParentRoot' + hh.PutBytes(t.ParentRoot[:32]) + } + { // Field #3 'StateRoot' + hh.PutBytes(t.StateRoot[:32]) + } + { // Field #4 'Body' + t := t.Body + if t == nil { + t = new(all.BeaconBlockBody) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'RANDAOReveal' + hh.PutBytes(t.RANDAOReveal[:96]) + } + { // Field #1 'ETH1Data' + t := t.ETH1Data + if t == nil { + t = new(phase0.ETH1Data) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPath(err, "SignedBlock.Message.Body.ETH1Data") + } + } + { // Field #2 'Graffiti' + hh.PutBytes(t.Graffiti[:32]) + } + { // Field #3 'ProposerSlashings' + t := t.ProposerSlashings + vlen := uint64(len(t)) + if vlen > expr0 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr0), "SignedBlock.Message.Body.ProposerSlashings") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(phase0.ProposerSlashing) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.ProposerSlashings[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr0, vlen, 32)) + } + { // Field #4 'AttesterSlashings' + t := t.AttesterSlashings + vlen := uint64(len(t)) + if vlen > expr1 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr1), "SignedBlock.Message.Body.AttesterSlashings") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(all.AttesterSlashing) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Attestation1' + t := t.Attestation1 + if t == nil { + t = new(all.IndexedAttestation) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'AttestingIndices' + t := t.AttestingIndices + vlen := uint64(len(t)) + if vlen > 2048 { + return sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(vlen, 2048), "SignedBlock.Message.Body.AttesterSlashings[%d].Attestation1.AttestingIndices", idx1) + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + sszutils.HashUint64Slice(hh, t) + hh.FillUpTo32() + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(2048, vlen, 8)) + } + { // Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.AttestationData) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.AttesterSlashings[%d].Attestation1.Data", idx1) + } + } + { // Field #2 'Signature' + hh.PutBytes(t.Signature[:96]) + } + hh.Merkleize(idx) + } + { // Field #1 'Attestation2' + t := t.Attestation2 + if t == nil { + t = new(all.IndexedAttestation) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'AttestingIndices' + t := t.AttestingIndices + vlen := uint64(len(t)) + if vlen > 2048 { + return sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(vlen, 2048), "SignedBlock.Message.Body.AttesterSlashings[%d].Attestation2.AttestingIndices", idx1) + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + sszutils.HashUint64Slice(hh, t) + hh.FillUpTo32() + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(2048, vlen, 8)) + } + { // Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.AttestationData) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.AttesterSlashings[%d].Attestation2.Data", idx1) + } + } + { // Field #2 'Signature' + hh.PutBytes(t.Signature[:96]) + } + hh.Merkleize(idx) + } + hh.Merkleize(idx) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr1, vlen, 32)) + } + { // Field #5 'Attestations' + t := t.Attestations + vlen := uint64(len(t)) + if vlen > expr2 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr2), "SignedBlock.Message.Body.Attestations") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(all.Attestation) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'AggregationBits' + t := t.AggregationBits + if l := len(t); l > 0 && t[l-1] == 0x00 { + return sszutils.ErrorWithPathf(sszutils.ErrBitlistNotTerminatedFn(), "SignedBlock.Message.Body.Attestations[%d].AggregationBits", idx1) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + bitlist, size := hasher.ParseBitlistWithHasher(hh, t[:]) + if size > expr3 { + return sszutils.ErrorWithPathf(sszutils.ErrBitlistLengthFn(size, expr3), "SignedBlock.Message.Body.Attestations[%d].AggregationBits", idx1) + } + hh.AppendBytes32(bitlist) + hh.MerkleizeWithMixin(idx, size, sszutils.CalculateBitlistLimit(expr3)) + } + { // Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.AttestationData) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.Attestations[%d].Data", idx1) + } + } + { // Field #2 'Signature' + hh.PutBytes(t.Signature[:96]) + } + hh.Merkleize(idx) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr2, vlen, 32)) + } + { // Field #6 'Deposits' + t := t.Deposits + vlen := uint64(len(t)) + if vlen > expr4 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr4), "SignedBlock.Message.Body.Deposits") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(phase0.Deposit) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Proof' + t := t.Proof + vlen := len(t) + if vlen > int(expr5) { + return sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, int(expr5)), "SignedBlock.Message.Body.Deposits[%d].Proof", idx1) + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + var val1, val1Empty []byte + for idx2 := range int(expr5) { + if idx2 < vlen { + val1 = t[idx2] + } else if idx2 == vlen { + val1 = val1Empty + } + vlen := len(val1) + if vlen > 32 { + return sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, 32), "SignedBlock.Message.Body.Deposits[%d].Proof[%d]", idx1, idx2) + } + val := val1[:] + if vlen < 32 { + val = sszutils.AppendZeroPadding(val, (32-vlen)*1) + } + hh.PutBytes(val[:32]) + if (idx2+1)%256 == 0 { + hh.Collapse() + } + } + hh.Merkleize(idx) + } + { // Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.DepositData) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.Deposits[%d].Data", idx1) + } + } + hh.Merkleize(idx) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr4, vlen, 32)) + } + { // Field #7 'VoluntaryExits' + t := t.VoluntaryExits + vlen := uint64(len(t)) + if vlen > expr6 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr6), "SignedBlock.Message.Body.VoluntaryExits") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(phase0.SignedVoluntaryExit) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.VoluntaryExits[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr6, vlen, 32)) + } + { // Field #8 'SyncAggregate' + t := t.SyncAggregate + if t == nil { + t = new(altair.SyncAggregate) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'SyncCommitteeBits' + vlen := len(t.SyncCommitteeBits) + if vlen > int(expr7) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(expr7)), "SignedBlock.Message.Body.SyncAggregate.SyncCommitteeBits") + } + val := t.SyncCommitteeBits[:] + if vlen < int(expr7) { + val = sszutils.AppendZeroPadding(val, (int(expr7)-vlen)*1) + } + hh.PutBytes(val[:int(expr7)]) + } + { // Field #1 'SyncCommitteeSignature' + hh.PutBytes(t.SyncCommitteeSignature[:96]) + } + hh.Merkleize(idx) + } + { // Field #9 'ExecutionPayload' + t := t.ExecutionPayload + if t == nil { + t = new(all.ExecutionPayload) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'ParentHash' + hh.PutBytes(t.ParentHash[:32]) + } + { // Field #1 'FeeRecipient' + hh.PutBytes(t.FeeRecipient[:20]) + } + { // Field #2 'StateRoot' + hh.PutBytes(t.StateRoot[:32]) + } + { // Field #3 'ReceiptsRoot' + hh.PutBytes(t.ReceiptsRoot[:32]) + } + { // Field #4 'LogsBloom' + hh.PutBytes(t.LogsBloom[:256]) + } + { // Field #5 'PrevRandao' + hh.PutBytes(t.PrevRandao[:32]) + } + { // Field #6 'BlockNumber' + hh.PutUint64(t.BlockNumber) + } + { // Field #7 'GasLimit' + hh.PutUint64(t.GasLimit) + } + { // Field #8 'GasUsed' + hh.PutUint64(t.GasUsed) + } + { // Field #9 'Timestamp' + hh.PutUint64(t.Timestamp) + } + { // Field #10 'ExtraData' + vlen := uint64(len(t.ExtraData)) + if vlen > expr8 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr8), "SignedBlock.Message.Body.ExecutionPayload.ExtraData") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + hh.AppendBytes32(t.ExtraData[:]) + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr8, vlen, 1)) + } + { // Field #11 'BaseFeePerGas' + t := t.BaseFeePerGas + if t == nil { + t = new(uint256.Int) + } + if root, err := t.HashTreeRoot(); err != nil { + return sszutils.ErrorWithPath(err, "SignedBlock.Message.Body.ExecutionPayload.BaseFeePerGas") + } else { + hh.AppendBytes32(root[:]) + } + } + { // Field #12 'BlockHash' + hh.PutBytes(t.BlockHash[:32]) + } + { // Field #13 'Transactions' + t := t.Transactions + vlen := uint64(len(t)) + if vlen > expr9 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr9), "SignedBlock.Message.Body.ExecutionPayload.Transactions") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + vlen := uint64(len(t[idx1])) + if vlen > expr10 { + return sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(vlen, expr10), "SignedBlock.Message.Body.ExecutionPayload.Transactions[%d]", idx1) + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + hh.AppendBytes32(t[idx1][:]) + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr10, vlen, 1)) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr9, vlen, 32)) + } + { // Field #14 'Withdrawals' + t := t.Withdrawals + vlen := uint64(len(t)) + if vlen > expr11 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr11), "SignedBlock.Message.Body.ExecutionPayload.Withdrawals") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(capella.Withdrawal) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.ExecutionPayload.Withdrawals[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr11, vlen, 32)) + } + { // Field #15 'BlobGasUsed' + hh.PutUint64(t.BlobGasUsed) + } + { // Field #16 'ExcessBlobGas' + hh.PutUint64(t.ExcessBlobGas) + } + hh.Merkleize(idx) + } + { // Field #10 'BLSToExecutionChanges' + t := t.BLSToExecutionChanges + vlen := uint64(len(t)) + if vlen > expr12 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr12), "SignedBlock.Message.Body.BLSToExecutionChanges") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(capella.SignedBLSToExecutionChange) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.BLSToExecutionChanges[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr12, vlen, 32)) + } + { // Field #11 'BlobKZGCommitments' + t := t.BlobKZGCommitments + vlen := uint64(len(t)) + if vlen > expr13 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr13), "SignedBlock.Message.Body.BlobKZGCommitments") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + hh.PutBytes(t[idx1][:48]) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr13, vlen, 32)) + } + hh.Merkleize(idx) + } + hh.Merkleize(idx) + } + { // Field #1 'Signature' + hh.PutBytes(t.Signature[:96]) + } + hh.Merkleize(idx) + } + { // Field #1 'KZGProofs' + t := t.KZGProofs + vlen := uint64(len(t)) + if vlen > expr13 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr13), "KZGProofs") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + hh.PutBytes(t[idx1][:48]) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr13, vlen, 32)) + } + { // Field #2 'Blobs' + t := t.Blobs + vlen := uint64(len(t)) + if vlen > expr13 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr13), "Blobs") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + hh.PutBytes(t[idx1][:131072]) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr13, vlen, 32)) + } + hh.Merkleize(idx) + return nil +} + +func (t *SignedBlockContents) hashTreeRootView_SignedBlockContents_0(ds sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + expr0, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_PROPOSER_SLASHINGS", 16) + if err != nil { + return err + } + expr1, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_ATTESTER_SLASHINGS_ELECTRA", 1) + if err != nil { + return err + } + expr2, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_VALIDATORS_PER_COMMITTEE*MAX_COMMITTEES_PER_SLOT", 131072) + if err != nil { + return err + } + expr3, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_ATTESTATIONS_ELECTRA", 8) + if err != nil { + return err + } + expr4, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_COMMITTEES_PER_SLOT/8", 8) + if err != nil { + return err + } + expr5, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_DEPOSITS", 16) + if err != nil { + return err + } + expr6, err := sszutils.ResolveSpecValueWithDefault(ds, "DEPOSIT_CONTRACT_TREE_DEPTH+1", 33) + if err != nil { + return err + } + expr7, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_VOLUNTARY_EXITS", 16) + if err != nil { + return err + } + expr8, err := sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE/8", 64) + if err != nil { + return err + } + expr9, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_EXTRA_DATA_BYTES", 32) + if err != nil { + return err + } + expr10, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_TRANSACTIONS_PER_PAYLOAD", 1048576) + if err != nil { + return err + } + expr11, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BYTES_PER_TRANSACTION", 1073741824) + if err != nil { + return err + } + expr12, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_WITHDRAWALS_PER_PAYLOAD", 16) + if err != nil { + return err + } + expr13, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BLS_TO_EXECUTION_CHANGES", 16) + if err != nil { + return err + } + expr14, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BLOB_COMMITMENTS_PER_BLOCK", 4096) + if err != nil { + return err + } + expr15, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_DEPOSIT_REQUESTS_PER_PAYLOAD", 8192) + if err != nil { + return err + } + expr16, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_WITHDRAWAL_REQUESTS_PER_PAYLOAD", 16) + if err != nil { + return err + } + expr17, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD", 2) + if err != nil { + return err + } + if t == nil { + t = new(SignedBlockContents) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'SignedBlock' + t := t.SignedBlock + if t == nil { + t = new(all.SignedBeaconBlock) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Message' + t := t.Message + if t == nil { + t = new(all.BeaconBlock) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Slot' + hh.PutUint64(uint64(t.Slot)) + } + { // Field #1 'ProposerIndex' + hh.PutUint64(uint64(t.ProposerIndex)) + } + { // Field #2 'ParentRoot' + hh.PutBytes(t.ParentRoot[:32]) + } + { // Field #3 'StateRoot' + hh.PutBytes(t.StateRoot[:32]) + } + { // Field #4 'Body' + t := t.Body + if t == nil { + t = new(all.BeaconBlockBody) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'RANDAOReveal' + hh.PutBytes(t.RANDAOReveal[:96]) + } + { // Field #1 'ETH1Data' + t := t.ETH1Data + if t == nil { + t = new(phase0.ETH1Data) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPath(err, "SignedBlock.Message.Body.ETH1Data") + } + } + { // Field #2 'Graffiti' + hh.PutBytes(t.Graffiti[:32]) + } + { // Field #3 'ProposerSlashings' + t := t.ProposerSlashings + vlen := uint64(len(t)) + if vlen > expr0 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr0), "SignedBlock.Message.Body.ProposerSlashings") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(phase0.ProposerSlashing) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.ProposerSlashings[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr0, vlen, 32)) + } + { // Field #4 'AttesterSlashings' + t := t.AttesterSlashings + vlen := uint64(len(t)) + if vlen > expr1 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr1), "SignedBlock.Message.Body.AttesterSlashings") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(all.AttesterSlashing) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Attestation1' + t := t.Attestation1 + if t == nil { + t = new(all.IndexedAttestation) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'AttestingIndices' + t := t.AttestingIndices + vlen := uint64(len(t)) + if vlen > expr2 { + return sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(vlen, expr2), "SignedBlock.Message.Body.AttesterSlashings[%d].Attestation1.AttestingIndices", idx1) + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + sszutils.HashUint64Slice(hh, t) + hh.FillUpTo32() + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr2, vlen, 8)) + } + { // Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.AttestationData) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.AttesterSlashings[%d].Attestation1.Data", idx1) + } + } + { // Field #2 'Signature' + hh.PutBytes(t.Signature[:96]) + } + hh.Merkleize(idx) + } + { // Field #1 'Attestation2' + t := t.Attestation2 + if t == nil { + t = new(all.IndexedAttestation) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'AttestingIndices' + t := t.AttestingIndices + vlen := uint64(len(t)) + if vlen > expr2 { + return sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(vlen, expr2), "SignedBlock.Message.Body.AttesterSlashings[%d].Attestation2.AttestingIndices", idx1) + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + sszutils.HashUint64Slice(hh, t) + hh.FillUpTo32() + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr2, vlen, 8)) + } + { // Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.AttestationData) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.AttesterSlashings[%d].Attestation2.Data", idx1) + } + } + { // Field #2 'Signature' + hh.PutBytes(t.Signature[:96]) + } + hh.Merkleize(idx) + } + hh.Merkleize(idx) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr1, vlen, 32)) + } + { // Field #5 'Attestations' + t := t.Attestations + vlen := uint64(len(t)) + if vlen > expr3 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr3), "SignedBlock.Message.Body.Attestations") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(all.Attestation) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'AggregationBits' + t := t.AggregationBits + if l := len(t); l > 0 && t[l-1] == 0x00 { + return sszutils.ErrorWithPathf(sszutils.ErrBitlistNotTerminatedFn(), "SignedBlock.Message.Body.Attestations[%d].AggregationBits", idx1) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + bitlist, size := hasher.ParseBitlistWithHasher(hh, t[:]) + if size > expr2 { + return sszutils.ErrorWithPathf(sszutils.ErrBitlistLengthFn(size, expr2), "SignedBlock.Message.Body.Attestations[%d].AggregationBits", idx1) + } + hh.AppendBytes32(bitlist) + hh.MerkleizeWithMixin(idx, size, sszutils.CalculateBitlistLimit(expr2)) + } + { // Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.AttestationData) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.Attestations[%d].Data", idx1) + } + } + { // Field #2 'Signature' + hh.PutBytes(t.Signature[:96]) + } + { // Field #3 'CommitteeBits' + vlen := len(t.CommitteeBits) + if vlen > int(expr4) { + return sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, int(expr4)), "SignedBlock.Message.Body.Attestations[%d].CommitteeBits", idx1) + } + val := t.CommitteeBits[:] + if vlen < int(expr4) { + val = sszutils.AppendZeroPadding(val, (int(expr4)-vlen)*1) + } + hh.PutBytes(val[:int(expr4)]) + } + hh.Merkleize(idx) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr3, vlen, 32)) + } + { // Field #6 'Deposits' + t := t.Deposits + vlen := uint64(len(t)) + if vlen > expr5 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr5), "SignedBlock.Message.Body.Deposits") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(phase0.Deposit) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Proof' + t := t.Proof + vlen := len(t) + if vlen > int(expr6) { + return sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, int(expr6)), "SignedBlock.Message.Body.Deposits[%d].Proof", idx1) + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + var val1, val1Empty []byte + for idx2 := range int(expr6) { + if idx2 < vlen { + val1 = t[idx2] + } else if idx2 == vlen { + val1 = val1Empty + } + vlen := len(val1) + if vlen > 32 { + return sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, 32), "SignedBlock.Message.Body.Deposits[%d].Proof[%d]", idx1, idx2) + } + val := val1[:] + if vlen < 32 { + val = sszutils.AppendZeroPadding(val, (32-vlen)*1) + } + hh.PutBytes(val[:32]) + if (idx2+1)%256 == 0 { + hh.Collapse() + } + } + hh.Merkleize(idx) + } + { // Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.DepositData) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.Deposits[%d].Data", idx1) + } + } + hh.Merkleize(idx) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr5, vlen, 32)) + } + { // Field #7 'VoluntaryExits' + t := t.VoluntaryExits + vlen := uint64(len(t)) + if vlen > expr7 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr7), "SignedBlock.Message.Body.VoluntaryExits") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(phase0.SignedVoluntaryExit) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.VoluntaryExits[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr7, vlen, 32)) + } + { // Field #8 'SyncAggregate' + t := t.SyncAggregate + if t == nil { + t = new(altair.SyncAggregate) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'SyncCommitteeBits' + vlen := len(t.SyncCommitteeBits) + if vlen > int(expr8) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(expr8)), "SignedBlock.Message.Body.SyncAggregate.SyncCommitteeBits") + } + val := t.SyncCommitteeBits[:] + if vlen < int(expr8) { + val = sszutils.AppendZeroPadding(val, (int(expr8)-vlen)*1) + } + hh.PutBytes(val[:int(expr8)]) + } + { // Field #1 'SyncCommitteeSignature' + hh.PutBytes(t.SyncCommitteeSignature[:96]) + } + hh.Merkleize(idx) + } + { // Field #9 'ExecutionPayload' + t := t.ExecutionPayload + if t == nil { + t = new(all.ExecutionPayload) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'ParentHash' + hh.PutBytes(t.ParentHash[:32]) + } + { // Field #1 'FeeRecipient' + hh.PutBytes(t.FeeRecipient[:20]) + } + { // Field #2 'StateRoot' + hh.PutBytes(t.StateRoot[:32]) + } + { // Field #3 'ReceiptsRoot' + hh.PutBytes(t.ReceiptsRoot[:32]) + } + { // Field #4 'LogsBloom' + hh.PutBytes(t.LogsBloom[:256]) + } + { // Field #5 'PrevRandao' + hh.PutBytes(t.PrevRandao[:32]) + } + { // Field #6 'BlockNumber' + hh.PutUint64(t.BlockNumber) + } + { // Field #7 'GasLimit' + hh.PutUint64(t.GasLimit) + } + { // Field #8 'GasUsed' + hh.PutUint64(t.GasUsed) + } + { // Field #9 'Timestamp' + hh.PutUint64(t.Timestamp) + } + { // Field #10 'ExtraData' + vlen := uint64(len(t.ExtraData)) + if vlen > expr9 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr9), "SignedBlock.Message.Body.ExecutionPayload.ExtraData") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + hh.AppendBytes32(t.ExtraData[:]) + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr9, vlen, 1)) + } + { // Field #11 'BaseFeePerGas' + t := t.BaseFeePerGas + if t == nil { + t = new(uint256.Int) + } + if root, err := t.HashTreeRoot(); err != nil { + return sszutils.ErrorWithPath(err, "SignedBlock.Message.Body.ExecutionPayload.BaseFeePerGas") + } else { + hh.AppendBytes32(root[:]) + } + } + { // Field #12 'BlockHash' + hh.PutBytes(t.BlockHash[:32]) + } + { // Field #13 'Transactions' + t := t.Transactions + vlen := uint64(len(t)) + if vlen > expr10 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr10), "SignedBlock.Message.Body.ExecutionPayload.Transactions") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + vlen := uint64(len(t[idx1])) + if vlen > expr11 { + return sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(vlen, expr11), "SignedBlock.Message.Body.ExecutionPayload.Transactions[%d]", idx1) + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + hh.AppendBytes32(t[idx1][:]) + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr11, vlen, 1)) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr10, vlen, 32)) + } + { // Field #14 'Withdrawals' + t := t.Withdrawals + vlen := uint64(len(t)) + if vlen > expr12 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr12), "SignedBlock.Message.Body.ExecutionPayload.Withdrawals") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(capella.Withdrawal) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.ExecutionPayload.Withdrawals[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr12, vlen, 32)) + } + { // Field #15 'BlobGasUsed' + hh.PutUint64(t.BlobGasUsed) + } + { // Field #16 'ExcessBlobGas' + hh.PutUint64(t.ExcessBlobGas) + } + hh.Merkleize(idx) + } + { // Field #10 'BLSToExecutionChanges' + t := t.BLSToExecutionChanges + vlen := uint64(len(t)) + if vlen > expr13 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr13), "SignedBlock.Message.Body.BLSToExecutionChanges") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(capella.SignedBLSToExecutionChange) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.BLSToExecutionChanges[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr13, vlen, 32)) + } + { // Field #11 'BlobKZGCommitments' + t := t.BlobKZGCommitments + vlen := uint64(len(t)) + if vlen > expr14 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr14), "SignedBlock.Message.Body.BlobKZGCommitments") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + hh.PutBytes(t[idx1][:48]) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr14, vlen, 32)) + } + { // Field #12 'ExecutionRequests' + t := t.ExecutionRequests + if t == nil { + t = new(all.ExecutionRequests) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Deposits' + t := t.Deposits + vlen := uint64(len(t)) + if vlen > expr15 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr15), "SignedBlock.Message.Body.ExecutionRequests.Deposits") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(electra1.DepositRequest) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.ExecutionRequests.Deposits[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr15, vlen, 32)) + } + { // Field #1 'Withdrawals' + t := t.Withdrawals + vlen := uint64(len(t)) + if vlen > expr16 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr16), "SignedBlock.Message.Body.ExecutionRequests.Withdrawals") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(electra1.WithdrawalRequest) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.ExecutionRequests.Withdrawals[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr16, vlen, 32)) + } + { // Field #2 'Consolidations' + t := t.Consolidations + vlen := uint64(len(t)) + if vlen > expr17 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr17), "SignedBlock.Message.Body.ExecutionRequests.Consolidations") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(electra1.ConsolidationRequest) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.ExecutionRequests.Consolidations[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr17, vlen, 32)) + } + hh.Merkleize(idx) + } + hh.Merkleize(idx) + } + hh.Merkleize(idx) + } + { // Field #1 'Signature' + hh.PutBytes(t.Signature[:96]) + } + hh.Merkleize(idx) + } + { // Field #1 'KZGProofs' + t := t.KZGProofs + vlen := uint64(len(t)) + if vlen > expr14 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr14), "KZGProofs") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + hh.PutBytes(t[idx1][:48]) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr14, vlen, 32)) + } + { // Field #2 'Blobs' + t := t.Blobs + vlen := uint64(len(t)) + if vlen > expr14 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr14), "Blobs") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + hh.PutBytes(t[idx1][:131072]) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr14, vlen, 32)) + } + hh.Merkleize(idx) + return nil +} + +func (t *SignedBlockContents) hashTreeRootView_SignedBlockContents_1(ds sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + expr0, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_PROPOSER_SLASHINGS", 16) + if err != nil { + return err + } + expr1, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_ATTESTER_SLASHINGS_ELECTRA", 1) + if err != nil { + return err + } + expr2, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_VALIDATORS_PER_COMMITTEE*MAX_COMMITTEES_PER_SLOT", 131072) + if err != nil { + return err + } + expr3, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_ATTESTATIONS_ELECTRA", 8) + if err != nil { + return err + } + expr4, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_COMMITTEES_PER_SLOT/8", 8) + if err != nil { + return err + } + expr5, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_DEPOSITS", 16) + if err != nil { + return err + } + expr6, err := sszutils.ResolveSpecValueWithDefault(ds, "DEPOSIT_CONTRACT_TREE_DEPTH+1", 33) + if err != nil { + return err + } + expr7, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_VOLUNTARY_EXITS", 16) + if err != nil { + return err + } + expr8, err := sszutils.ResolveSpecValueWithDefault(ds, "SYNC_COMMITTEE_SIZE/8", 64) + if err != nil { + return err + } + expr9, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_EXTRA_DATA_BYTES", 32) + if err != nil { + return err + } + expr10, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_TRANSACTIONS_PER_PAYLOAD", 1048576) + if err != nil { + return err + } + expr11, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BYTES_PER_TRANSACTION", 1073741824) + if err != nil { + return err + } + expr12, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_WITHDRAWALS_PER_PAYLOAD", 16) + if err != nil { + return err + } + expr13, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BLS_TO_EXECUTION_CHANGES", 16) + if err != nil { + return err + } + expr14, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BLOB_COMMITMENTS_PER_BLOCK", 4096) + if err != nil { + return err + } + expr15, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_DEPOSIT_REQUESTS_PER_PAYLOAD", 8192) + if err != nil { + return err + } + expr16, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_WITHDRAWAL_REQUESTS_PER_PAYLOAD", 16) + if err != nil { + return err + } + expr17, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD", 2) + if err != nil { + return err + } + if t == nil { + t = new(SignedBlockContents) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'SignedBlock' + t := t.SignedBlock + if t == nil { + t = new(all.SignedBeaconBlock) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Message' + t := t.Message + if t == nil { + t = new(all.BeaconBlock) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Slot' + hh.PutUint64(uint64(t.Slot)) + } + { // Field #1 'ProposerIndex' + hh.PutUint64(uint64(t.ProposerIndex)) + } + { // Field #2 'ParentRoot' + hh.PutBytes(t.ParentRoot[:32]) + } + { // Field #3 'StateRoot' + hh.PutBytes(t.StateRoot[:32]) + } + { // Field #4 'Body' + t := t.Body + if t == nil { + t = new(all.BeaconBlockBody) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'RANDAOReveal' + hh.PutBytes(t.RANDAOReveal[:96]) + } + { // Field #1 'ETH1Data' + t := t.ETH1Data + if t == nil { + t = new(phase0.ETH1Data) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPath(err, "SignedBlock.Message.Body.ETH1Data") + } + } + { // Field #2 'Graffiti' + hh.PutBytes(t.Graffiti[:32]) + } + { // Field #3 'ProposerSlashings' + t := t.ProposerSlashings + vlen := uint64(len(t)) + if vlen > expr0 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr0), "SignedBlock.Message.Body.ProposerSlashings") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(phase0.ProposerSlashing) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.ProposerSlashings[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr0, vlen, 32)) + } + { // Field #4 'AttesterSlashings' + t := t.AttesterSlashings + vlen := uint64(len(t)) + if vlen > expr1 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr1), "SignedBlock.Message.Body.AttesterSlashings") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(all.AttesterSlashing) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Attestation1' + t := t.Attestation1 + if t == nil { + t = new(all.IndexedAttestation) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'AttestingIndices' + t := t.AttestingIndices + vlen := uint64(len(t)) + if vlen > expr2 { + return sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(vlen, expr2), "SignedBlock.Message.Body.AttesterSlashings[%d].Attestation1.AttestingIndices", idx1) + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + sszutils.HashUint64Slice(hh, t) + hh.FillUpTo32() + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr2, vlen, 8)) + } + { // Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.AttestationData) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.AttesterSlashings[%d].Attestation1.Data", idx1) + } + } + { // Field #2 'Signature' + hh.PutBytes(t.Signature[:96]) + } + hh.Merkleize(idx) + } + { // Field #1 'Attestation2' + t := t.Attestation2 + if t == nil { + t = new(all.IndexedAttestation) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'AttestingIndices' + t := t.AttestingIndices + vlen := uint64(len(t)) + if vlen > expr2 { + return sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(vlen, expr2), "SignedBlock.Message.Body.AttesterSlashings[%d].Attestation2.AttestingIndices", idx1) + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + sszutils.HashUint64Slice(hh, t) + hh.FillUpTo32() + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr2, vlen, 8)) + } + { // Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.AttestationData) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.AttesterSlashings[%d].Attestation2.Data", idx1) + } + } + { // Field #2 'Signature' + hh.PutBytes(t.Signature[:96]) + } + hh.Merkleize(idx) + } + hh.Merkleize(idx) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr1, vlen, 32)) + } + { // Field #5 'Attestations' + t := t.Attestations + vlen := uint64(len(t)) + if vlen > expr3 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr3), "SignedBlock.Message.Body.Attestations") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(all.Attestation) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'AggregationBits' + t := t.AggregationBits + if l := len(t); l > 0 && t[l-1] == 0x00 { + return sszutils.ErrorWithPathf(sszutils.ErrBitlistNotTerminatedFn(), "SignedBlock.Message.Body.Attestations[%d].AggregationBits", idx1) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + bitlist, size := hasher.ParseBitlistWithHasher(hh, t[:]) + if size > expr2 { + return sszutils.ErrorWithPathf(sszutils.ErrBitlistLengthFn(size, expr2), "SignedBlock.Message.Body.Attestations[%d].AggregationBits", idx1) + } + hh.AppendBytes32(bitlist) + hh.MerkleizeWithMixin(idx, size, sszutils.CalculateBitlistLimit(expr2)) + } + { // Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.AttestationData) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.Attestations[%d].Data", idx1) + } + } + { // Field #2 'Signature' + hh.PutBytes(t.Signature[:96]) + } + { // Field #3 'CommitteeBits' + vlen := len(t.CommitteeBits) + if vlen > int(expr4) { + return sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, int(expr4)), "SignedBlock.Message.Body.Attestations[%d].CommitteeBits", idx1) + } + val := t.CommitteeBits[:] + if vlen < int(expr4) { + val = sszutils.AppendZeroPadding(val, (int(expr4)-vlen)*1) + } + hh.PutBytes(val[:int(expr4)]) + } + hh.Merkleize(idx) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr3, vlen, 32)) + } + { // Field #6 'Deposits' + t := t.Deposits + vlen := uint64(len(t)) + if vlen > expr5 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr5), "SignedBlock.Message.Body.Deposits") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(phase0.Deposit) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Proof' + t := t.Proof + vlen := len(t) + if vlen > int(expr6) { + return sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, int(expr6)), "SignedBlock.Message.Body.Deposits[%d].Proof", idx1) + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + var val1, val1Empty []byte + for idx2 := range int(expr6) { + if idx2 < vlen { + val1 = t[idx2] + } else if idx2 == vlen { + val1 = val1Empty + } + vlen := len(val1) + if vlen > 32 { + return sszutils.ErrorWithPathf(sszutils.ErrVectorLengthFn(vlen, 32), "SignedBlock.Message.Body.Deposits[%d].Proof[%d]", idx1, idx2) + } + val := val1[:] + if vlen < 32 { + val = sszutils.AppendZeroPadding(val, (32-vlen)*1) + } + hh.PutBytes(val[:32]) + if (idx2+1)%256 == 0 { + hh.Collapse() + } + } + hh.Merkleize(idx) + } + { // Field #1 'Data' + t := t.Data + if t == nil { + t = new(phase0.DepositData) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.Deposits[%d].Data", idx1) + } + } + hh.Merkleize(idx) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr5, vlen, 32)) + } + { // Field #7 'VoluntaryExits' + t := t.VoluntaryExits + vlen := uint64(len(t)) + if vlen > expr7 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr7), "SignedBlock.Message.Body.VoluntaryExits") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(phase0.SignedVoluntaryExit) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.VoluntaryExits[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr7, vlen, 32)) + } + { // Field #8 'SyncAggregate' + t := t.SyncAggregate + if t == nil { + t = new(altair.SyncAggregate) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'SyncCommitteeBits' + vlen := len(t.SyncCommitteeBits) + if vlen > int(expr8) { + return sszutils.ErrorWithPath(sszutils.ErrVectorLengthFn(vlen, int(expr8)), "SignedBlock.Message.Body.SyncAggregate.SyncCommitteeBits") + } + val := t.SyncCommitteeBits[:] + if vlen < int(expr8) { + val = sszutils.AppendZeroPadding(val, (int(expr8)-vlen)*1) + } + hh.PutBytes(val[:int(expr8)]) + } + { // Field #1 'SyncCommitteeSignature' + hh.PutBytes(t.SyncCommitteeSignature[:96]) + } + hh.Merkleize(idx) + } + { // Field #9 'ExecutionPayload' + t := t.ExecutionPayload + if t == nil { + t = new(all.ExecutionPayload) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'ParentHash' + hh.PutBytes(t.ParentHash[:32]) + } + { // Field #1 'FeeRecipient' + hh.PutBytes(t.FeeRecipient[:20]) + } + { // Field #2 'StateRoot' + hh.PutBytes(t.StateRoot[:32]) + } + { // Field #3 'ReceiptsRoot' + hh.PutBytes(t.ReceiptsRoot[:32]) + } + { // Field #4 'LogsBloom' + hh.PutBytes(t.LogsBloom[:256]) + } + { // Field #5 'PrevRandao' + hh.PutBytes(t.PrevRandao[:32]) + } + { // Field #6 'BlockNumber' + hh.PutUint64(t.BlockNumber) + } + { // Field #7 'GasLimit' + hh.PutUint64(t.GasLimit) + } + { // Field #8 'GasUsed' + hh.PutUint64(t.GasUsed) + } + { // Field #9 'Timestamp' + hh.PutUint64(t.Timestamp) + } + { // Field #10 'ExtraData' + vlen := uint64(len(t.ExtraData)) + if vlen > expr9 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr9), "SignedBlock.Message.Body.ExecutionPayload.ExtraData") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + hh.AppendBytes32(t.ExtraData[:]) + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr9, vlen, 1)) + } + { // Field #11 'BaseFeePerGas' + t := t.BaseFeePerGas + if t == nil { + t = new(uint256.Int) + } + if root, err := t.HashTreeRoot(); err != nil { + return sszutils.ErrorWithPath(err, "SignedBlock.Message.Body.ExecutionPayload.BaseFeePerGas") + } else { + hh.AppendBytes32(root[:]) + } + } + { // Field #12 'BlockHash' + hh.PutBytes(t.BlockHash[:32]) + } + { // Field #13 'Transactions' + t := t.Transactions + vlen := uint64(len(t)) + if vlen > expr10 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr10), "SignedBlock.Message.Body.ExecutionPayload.Transactions") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + vlen := uint64(len(t[idx1])) + if vlen > expr11 { + return sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(vlen, expr11), "SignedBlock.Message.Body.ExecutionPayload.Transactions[%d]", idx1) + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + hh.AppendBytes32(t[idx1][:]) + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr11, vlen, 1)) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr10, vlen, 32)) + } + { // Field #14 'Withdrawals' + t := t.Withdrawals + vlen := uint64(len(t)) + if vlen > expr12 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr12), "SignedBlock.Message.Body.ExecutionPayload.Withdrawals") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(capella.Withdrawal) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.ExecutionPayload.Withdrawals[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr12, vlen, 32)) + } + { // Field #15 'BlobGasUsed' + hh.PutUint64(t.BlobGasUsed) + } + { // Field #16 'ExcessBlobGas' + hh.PutUint64(t.ExcessBlobGas) + } + hh.Merkleize(idx) + } + { // Field #10 'BLSToExecutionChanges' + t := t.BLSToExecutionChanges + vlen := uint64(len(t)) + if vlen > expr13 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr13), "SignedBlock.Message.Body.BLSToExecutionChanges") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(capella.SignedBLSToExecutionChange) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.BLSToExecutionChanges[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr13, vlen, 32)) + } + { // Field #11 'BlobKZGCommitments' + t := t.BlobKZGCommitments + vlen := uint64(len(t)) + if vlen > expr14 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr14), "SignedBlock.Message.Body.BlobKZGCommitments") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + hh.PutBytes(t[idx1][:48]) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr14, vlen, 32)) + } + { // Field #12 'ExecutionRequests' + t := t.ExecutionRequests + if t == nil { + t = new(all.ExecutionRequests) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Deposits' + t := t.Deposits + vlen := uint64(len(t)) + if vlen > expr15 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr15), "SignedBlock.Message.Body.ExecutionRequests.Deposits") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(electra1.DepositRequest) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.ExecutionRequests.Deposits[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr15, vlen, 32)) + } + { // Field #1 'Withdrawals' + t := t.Withdrawals + vlen := uint64(len(t)) + if vlen > expr16 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr16), "SignedBlock.Message.Body.ExecutionRequests.Withdrawals") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(electra1.WithdrawalRequest) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.ExecutionRequests.Withdrawals[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr16, vlen, 32)) + } + { // Field #2 'Consolidations' + t := t.Consolidations + vlen := uint64(len(t)) + if vlen > expr17 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr17), "SignedBlock.Message.Body.ExecutionRequests.Consolidations") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(electra1.ConsolidationRequest) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "SignedBlock.Message.Body.ExecutionRequests.Consolidations[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr17, vlen, 32)) + } + hh.Merkleize(idx) + } + hh.Merkleize(idx) + } + hh.Merkleize(idx) + } + { // Field #1 'Signature' + hh.PutBytes(t.Signature[:96]) + } + hh.Merkleize(idx) + } + { // Field #1 'KZGProofs' + t := t.KZGProofs + vlen := uint64(len(t)) + if vlen > 33554432 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 33554432), "KZGProofs") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + hh.PutBytes(t[idx1][:48]) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(33554432, vlen, 32)) + } + { // Field #2 'Blobs' + t := t.Blobs + vlen := uint64(len(t)) + if vlen > 4096 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 4096), "Blobs") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + hh.PutBytes(t[idx1][:131072]) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(4096, vlen, 32)) + } + hh.Merkleize(idx) + return nil +} diff --git a/api/v1/all/signedblockcontents_test.go b/api/v1/all/signedblockcontents_test.go new file mode 100644 index 00000000..c0e57200 --- /dev/null +++ b/api/v1/all/signedblockcontents_test.go @@ -0,0 +1,389 @@ +// Copyright © 2026 Attestant Limited. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package all_test + +import ( + "encoding/json" + "testing" + + bitfield "github.com/OffchainLabs/go-bitfield" + "github.com/ethpandaops/go-eth2-client/api" + apiv1all "github.com/ethpandaops/go-eth2-client/api/v1/all" + apiv1deneb "github.com/ethpandaops/go-eth2-client/api/v1/deneb" + apiv1electra "github.com/ethpandaops/go-eth2-client/api/v1/electra" + apiv1fulu "github.com/ethpandaops/go-eth2-client/api/v1/fulu" + "github.com/ethpandaops/go-eth2-client/spec/altair" + "github.com/ethpandaops/go-eth2-client/spec/bellatrix" + "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/phase0" + "github.com/ethpandaops/go-eth2-client/spec/version" + "github.com/holiman/uint256" + "github.com/stretchr/testify/require" +) + +// sszCodec is the SSZ surface shared by the per-fork block contents types. +type sszCodec interface { + MarshalSSZ() ([]byte, error) + HashTreeRoot() ([32]byte, error) +} + +// testExecutionPayload builds a Deneb execution payload with realistic-ish data. +func testExecutionPayload() *deneb.ExecutionPayload { + return &deneb.ExecutionPayload{ + ParentHash: phase0.Hash32{0x01}, + FeeRecipient: bellatrix.ExecutionAddress{0x02}, + StateRoot: phase0.Root{0x03}, + ReceiptsRoot: phase0.Root{0x04}, + LogsBloom: [256]byte{0x05}, + PrevRandao: [32]byte{0x06}, + BlockNumber: 7, + GasLimit: 30_000_000, + GasUsed: 21_000, + Timestamp: 1_600_000_000, + ExtraData: []byte{0x08}, + BaseFeePerGas: uint256.NewInt(9), + BlockHash: phase0.Hash32{0x0a}, + Transactions: []bellatrix.Transaction{{0x0b, 0x0c}}, + Withdrawals: []*capella.Withdrawal{ + {Index: 1, ValidatorIndex: 2, Address: bellatrix.ExecutionAddress{0x0d}, Amount: 3}, + }, + BlobGasUsed: 131072, + ExcessBlobGas: 262144, + } +} + +// testDenebSignedBeaconBlock builds a Deneb signed beacon block. +func testDenebSignedBeaconBlock() *deneb.SignedBeaconBlock { + return &deneb.SignedBeaconBlock{ + Message: &deneb.BeaconBlock{ + Slot: 12345, + ProposerIndex: 42, + ParentRoot: phase0.Root{0x11}, + StateRoot: phase0.Root{0x12}, + Body: &deneb.BeaconBlockBody{ + RANDAOReveal: phase0.BLSSignature{0x13}, + ETH1Data: &phase0.ETH1Data{ + DepositRoot: phase0.Root{0x14}, + DepositCount: 15, + BlockHash: make([]byte, 32), + }, + Graffiti: [32]byte{'b', 'u', 'i', 'l', 'd'}, + ProposerSlashings: []*phase0.ProposerSlashing{}, + AttesterSlashings: []*phase0.AttesterSlashing{}, + Attestations: []*phase0.Attestation{}, + Deposits: []*phase0.Deposit{}, + VoluntaryExits: []*phase0.SignedVoluntaryExit{}, + SyncAggregate: &altair.SyncAggregate{ + SyncCommitteeBits: bitfield.NewBitvector512(), + SyncCommitteeSignature: phase0.BLSSignature{0x16}, + }, + ExecutionPayload: testExecutionPayload(), + BLSToExecutionChanges: []*capella.SignedBLSToExecutionChange{}, + BlobKZGCommitments: []deneb.KZGCommitment{{0x17}}, + }, + }, + Signature: phase0.BLSSignature{0x18}, + } +} + +// testElectraSignedBeaconBlock builds an Electra signed beacon block (also the +// Fulu wire schema). +func testElectraSignedBeaconBlock() *electra.SignedBeaconBlock { + return &electra.SignedBeaconBlock{ + Message: &electra.BeaconBlock{ + Slot: 12345, + ProposerIndex: 42, + ParentRoot: phase0.Root{0x11}, + StateRoot: phase0.Root{0x12}, + Body: &electra.BeaconBlockBody{ + RANDAOReveal: phase0.BLSSignature{0x13}, + ETH1Data: &phase0.ETH1Data{ + DepositRoot: phase0.Root{0x14}, + DepositCount: 15, + BlockHash: make([]byte, 32), + }, + Graffiti: [32]byte{'b', 'u', 'i', 'l', 'd'}, + ProposerSlashings: []*phase0.ProposerSlashing{}, + AttesterSlashings: []*electra.AttesterSlashing{}, + Attestations: []*electra.Attestation{}, + Deposits: []*phase0.Deposit{}, + VoluntaryExits: []*phase0.SignedVoluntaryExit{}, + SyncAggregate: &altair.SyncAggregate{ + SyncCommitteeBits: bitfield.NewBitvector512(), + SyncCommitteeSignature: phase0.BLSSignature{0x16}, + }, + ExecutionPayload: testExecutionPayload(), + BLSToExecutionChanges: []*capella.SignedBLSToExecutionChange{}, + BlobKZGCommitments: []deneb.KZGCommitment{{0x17}}, + ExecutionRequests: &electra.ExecutionRequests{ + Deposits: []*electra.DepositRequest{}, + Withdrawals: []*electra.WithdrawalRequest{}, + Consolidations: []*electra.ConsolidationRequest{}, + }, + }, + }, + Signature: phase0.BLSSignature{0x18}, + } +} + +// testKZGProofs and testBlobs are the sidecar data shared by every fork. +func testKZGProofs() []deneb.KZGProof { + return []deneb.KZGProof{{0x21}, {0x22}} +} + +func testBlobs() []deneb.Blob { + return []deneb.Blob{{0x23}} +} + +// signedBlockContentsTests enumerates the per-fork views the agnostic +// SignedBlockContents must be wire-compatible with. +func signedBlockContentsTests() []struct { + name string + version version.DataVersion + view any +} { + return []struct { + name string + version version.DataVersion + view any + }{ + { + name: "Deneb", + version: version.DataVersionDeneb, + view: &apiv1deneb.SignedBlockContents{ + SignedBlock: testDenebSignedBeaconBlock(), + KZGProofs: testKZGProofs(), + Blobs: testBlobs(), + }, + }, + { + name: "Electra", + version: version.DataVersionElectra, + view: &apiv1electra.SignedBlockContents{ + SignedBlock: testElectraSignedBeaconBlock(), + KZGProofs: testKZGProofs(), + Blobs: testBlobs(), + }, + }, + { + name: "Fulu", + version: version.DataVersionFulu, + view: &apiv1fulu.SignedBlockContents{ + SignedBlock: testElectraSignedBeaconBlock(), + KZGProofs: testKZGProofs(), + Blobs: testBlobs(), + }, + }, + } +} + +// TestSignedBlockContentsJSONWireCompat verifies that the agnostic type +// marshals to byte-identical JSON versus the per-fork type, and that JSON +// round-trips losslessly through the agnostic type. +func TestSignedBlockContentsJSONWireCompat(t *testing.T) { + for _, test := range signedBlockContentsTests() { + t.Run(test.name, func(t *testing.T) { + expected, err := json.Marshal(test.view) + require.NoError(t, err) + + agnostic := &apiv1all.SignedBlockContents{} + require.NoError(t, agnostic.FromView(test.view)) + require.Equal(t, test.version, agnostic.Version) + + got, err := json.Marshal(agnostic) + require.NoError(t, err) + require.Equal(t, string(expected), string(got), + "agnostic JSON differs from per-fork JSON") + + // Round-trip through UnmarshalJSON with Version pre-set. + rt := &apiv1all.SignedBlockContents{Version: test.version} + require.NoError(t, json.Unmarshal(expected, rt)) + + rtJSON, err := json.Marshal(rt) + require.NoError(t, err) + require.Equal(t, string(expected), string(rtJSON), + "round-tripped JSON differs from per-fork JSON") + + // Version must propagate to nested versionable children. + require.NotNil(t, rt.SignedBlock) + require.Equal(t, test.version, rt.SignedBlock.Version) + require.NotNil(t, rt.SignedBlock.Message) + require.Equal(t, test.version, rt.SignedBlock.Message.Version) + require.NotNil(t, rt.SignedBlock.Message.Body) + require.Equal(t, test.version, rt.SignedBlock.Message.Body.Version) + }) + } +} + +// TestSignedBlockContentsSSZWireCompat verifies that the agnostic type +// produces byte-identical SSZ and the same hash tree root as the per-fork +// type, and that SSZ round-trips losslessly through the agnostic type. +func TestSignedBlockContentsSSZWireCompat(t *testing.T) { + for _, test := range signedBlockContentsTests() { + t.Run(test.name, func(t *testing.T) { + codec, ok := test.view.(sszCodec) + require.True(t, ok) + + expected, err := codec.MarshalSSZ() + require.NoError(t, err) + + agnostic := &apiv1all.SignedBlockContents{} + require.NoError(t, agnostic.FromView(test.view)) + + got, err := agnostic.MarshalSSZ() + require.NoError(t, err) + require.Equal(t, expected, got, "agnostic SSZ differs from per-fork SSZ") + + expectedRoot, err := codec.HashTreeRoot() + require.NoError(t, err) + + gotRoot, err := agnostic.HashTreeRoot() + require.NoError(t, err) + require.Equal(t, expectedRoot, gotRoot, + "agnostic hash tree root differs from per-fork root") + + // Round-trip through UnmarshalSSZ with Version pre-set. + rt := &apiv1all.SignedBlockContents{Version: test.version} + require.NoError(t, rt.UnmarshalSSZ(expected)) + + rtSSZ, err := rt.MarshalSSZ() + require.NoError(t, err) + require.Equal(t, expected, rtSSZ, + "round-tripped SSZ differs from per-fork SSZ") + + // Version must propagate to nested versionable children. + require.NotNil(t, rt.SignedBlock) + require.Equal(t, test.version, rt.SignedBlock.Version) + }) + } +} + +// TestSignedBlockContentsViewRoundtrip verifies ToView reproduces the +// per-fork view the agnostic instance was built from. +func TestSignedBlockContentsViewRoundtrip(t *testing.T) { + for _, test := range signedBlockContentsTests() { + t.Run(test.name, func(t *testing.T) { + agnostic := &apiv1all.SignedBlockContents{} + require.NoError(t, agnostic.FromView(test.view)) + + view, err := agnostic.ToView() + require.NoError(t, err) + require.IsType(t, test.view, view) + require.Equal(t, test.view, view) + }) + } +} + +// TestSignedBlockContentsToVersioned verifies conversion to and from +// api.VersionedSignedProposal: exactly the plain (unblinded) per-fork field +// is populated, the Blinded flag stays false, and the per-fork field carries +// the exact wire bytes the http client submits (it marshals that field for +// both JSON and SSZ after AssertPresent). +func TestSignedBlockContentsToVersioned(t *testing.T) { + for _, test := range signedBlockContentsTests() { + t.Run(test.name, func(t *testing.T) { + agnostic := &apiv1all.SignedBlockContents{} + require.NoError(t, agnostic.FromView(test.view)) + + versioned, err := agnostic.ToVersioned() + require.NoError(t, err) + require.Equal(t, test.version, versioned.Version) + require.False(t, versioned.Blinded, "unblinded contents must not set the Blinded flag") + require.NoError(t, versioned.AssertPresent()) + + // The per-fork field must be the exact view type; the blinded + // fields must stay untouched. + var fieldView any + + switch test.version { + case version.DataVersionDeneb: + fieldView = versioned.Deneb + require.Nil(t, versioned.DenebBlinded) + case version.DataVersionElectra: + fieldView = versioned.Electra + require.Nil(t, versioned.ElectraBlinded) + case version.DataVersionFulu: + fieldView = versioned.Fulu + require.Nil(t, versioned.FuluBlinded) + default: + t.Fatalf("unexpected version %v", test.version) + } + + require.IsType(t, test.view, fieldView) + require.Equal(t, test.view, fieldView) + + // Byte-compare the body the http client would submit + // (json.Marshal / MarshalSSZ of the per-fork field). + expectedJSON, err := json.Marshal(test.view) + require.NoError(t, err) + + gotJSON, err := json.Marshal(fieldView) + require.NoError(t, err) + require.Equal(t, string(expectedJSON), string(gotJSON), + "submitted proposal JSON body differs from per-fork JSON") + + expectedSSZ, err := test.view.(sszCodec).MarshalSSZ() + require.NoError(t, err) + + gotSSZ, err := fieldView.(sszCodec).MarshalSSZ() + require.NoError(t, err) + require.Equal(t, expectedSSZ, gotSSZ, + "submitted proposal SSZ body differs from per-fork SSZ") + + rt := &apiv1all.SignedBlockContents{} + require.NoError(t, rt.FromVersioned(versioned)) + require.Equal(t, test.version, rt.Version) + require.Equal(t, agnostic, rt) + }) + } +} + +// TestSignedBlockContentsFromVersionedBlinded verifies that a blinded +// proposal (Blinded flag set, only the *Blinded field populated) is rejected +// rather than silently mis-read. +func TestSignedBlockContentsFromVersionedBlinded(t *testing.T) { + versioned := &api.VersionedSignedProposal{ + Version: version.DataVersionFulu, + Blinded: true, + FuluBlinded: &apiv1electra.SignedBlindedBeaconBlock{}, + } + + rt := &apiv1all.SignedBlockContents{} + require.Error(t, rt.FromVersioned(versioned), + "blinded proposals must not convert into unblinded block contents") +} + +// TestSignedBlockContentsUnsupportedVersion verifies unsupported versions are +// rejected with a clear error. +func TestSignedBlockContentsUnsupportedVersion(t *testing.T) { + for _, v := range []version.DataVersion{ + version.DataVersionUnknown, + version.DataVersionPhase0, + version.DataVersionCapella, + version.DataVersionGloas, + } { + s := &apiv1all.SignedBlockContents{Version: v} + + _, err := s.ToView() + require.ErrorContains(t, err, "unsupported version") + + _, err = json.Marshal(s) + require.ErrorContains(t, err, "unsupported version") + + _, err = s.MarshalSSZ() + require.ErrorContains(t, err, "unsupported version") + } +} diff --git a/api/v1/all/signedexecutionpayloadenvelopecontents.go b/api/v1/all/signedexecutionpayloadenvelopecontents.go new file mode 100644 index 00000000..b33dda52 --- /dev/null +++ b/api/v1/all/signedexecutionpayloadenvelopecontents.go @@ -0,0 +1,254 @@ +// Copyright © 2026 Attestant Limited. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package all + +import ( + "errors" + "fmt" + + apiv1gloas "github.com/ethpandaops/go-eth2-client/api/v1/gloas" + specall "github.com/ethpandaops/go-eth2-client/spec/all" + "github.com/ethpandaops/go-eth2-client/spec/deneb" + "github.com/ethpandaops/go-eth2-client/spec/version" + dynssz "github.com/pk910/dynamic-ssz" + "github.com/pk910/dynamic-ssz/sszutils" +) + +// SignedExecutionPayloadEnvelopeContents is the fork-agnostic stateless +// request body for publishing an execution payload envelope: the signed +// envelope together with the blob sidecar data (KZG cell proofs and blobs). +// Envelopes exist as a wire type from Gloas onwards; later forks that share +// the schema reuse the gloas view. +type SignedExecutionPayloadEnvelopeContents struct { + Version version.DataVersion + SignedExecutionPayloadEnvelope *specall.SignedExecutionPayloadEnvelope + KZGProofs []deneb.KZGProof + Blobs []deneb.Blob +} + +// viewType returns the fork-specific schema type pointer used as the view +// descriptor for the active Version. +func (s *SignedExecutionPayloadEnvelopeContents) viewType() (any, error) { + switch s.Version { + case version.DataVersionGloas, version.DataVersionHeze: + return (*apiv1gloas.SignedExecutionPayloadEnvelopeContents)(nil), nil + default: + return nil, fmt.Errorf("SignedExecutionPayloadEnvelopeContents: unsupported version %d", s.Version) + } +} + +// MarshalSSZDyn marshals the signed envelope contents using the view that +// matches Version. +func (s *SignedExecutionPayloadEnvelopeContents) MarshalSSZDyn(ds sszutils.DynamicSpecs, buf []byte) ([]byte, error) { + view, err := s.viewType() + if err != nil { + return nil, err + } + + m, ok := any(s).(sszutils.DynamicViewMarshaler) + if !ok { + return nil, errors.New("SignedExecutionPayloadEnvelopeContents: generated SSZ code missing") + } + + fn := m.MarshalSSZDynView(view) + if fn == nil { + return nil, fmt.Errorf("SignedExecutionPayloadEnvelopeContents: no view marshaler for version %d", s.Version) + } + + return fn(ds, buf) +} + +// SizeSSZDyn returns the SSZ size of the signed envelope contents for the +// active Version. +func (s *SignedExecutionPayloadEnvelopeContents) SizeSSZDyn(ds sszutils.DynamicSpecs) int { + view, err := s.viewType() + if err != nil { + return 0 + } + + sz, ok := any(s).(sszutils.DynamicViewSizer) + if !ok { + return 0 + } + + fn := sz.SizeSSZDynView(view) + if fn == nil { + return 0 + } + + return fn(ds) +} + +// UnmarshalSSZDyn decodes the signed envelope contents into the view that +// matches Version. +func (s *SignedExecutionPayloadEnvelopeContents) UnmarshalSSZDyn(ds sszutils.DynamicSpecs, buf []byte) error { + view, err := s.viewType() + if err != nil { + return err + } + + u, ok := any(s).(sszutils.DynamicViewUnmarshaler) + if !ok { + return errors.New("SignedExecutionPayloadEnvelopeContents: generated SSZ code missing") + } + + fn := u.UnmarshalSSZDynView(view) + if fn == nil { + return fmt.Errorf("SignedExecutionPayloadEnvelopeContents: no view unmarshaler for version %d", s.Version) + } + + if err := fn(ds, buf); err != nil { + return err + } + + s.populateVersion(s.Version) + + return nil +} + +// populateVersion sets Version and propagates it to any nested versionable +// children. +func (s *SignedExecutionPayloadEnvelopeContents) populateVersion(v version.DataVersion) { + propagateVersion(s, v) +} + +// ToView returns a fresh fork-specific SignedExecutionPayloadEnvelopeContents +// populated with s's fields, recursing into the envelope via copyByName. +func (s *SignedExecutionPayloadEnvelopeContents) ToView() (any, error) { + return toViewByCopy(s) +} + +// FromView populates s from a fork-specific +// SignedExecutionPayloadEnvelopeContents. +func (s *SignedExecutionPayloadEnvelopeContents) FromView(view any) error { + v, err := signedExecutionPayloadEnvelopeContentsVersion(view) + if err != nil { + return err + } + + if s.Version == version.DataVersionUnknown { + s.Version = v + } + + if err := copyByName(view, s); err != nil { + return err + } + + s.populateVersion(s.Version) + + return nil +} + +// signedExecutionPayloadEnvelopeContentsVersion maps a +// SignedExecutionPayloadEnvelopeContents view type to its DataVersion. +func signedExecutionPayloadEnvelopeContentsVersion(view any) (version.DataVersion, error) { + switch view.(type) { + case *apiv1gloas.SignedExecutionPayloadEnvelopeContents: + return version.DataVersionGloas, nil + default: + return version.DataVersionUnknown, + fmt.Errorf("SignedExecutionPayloadEnvelopeContents: unsupported view type %T", view) + } +} + +// HashTreeRootWithDyn computes the SSZ hash tree root using the active +// Version's view. +func (s *SignedExecutionPayloadEnvelopeContents) HashTreeRootWithDyn(ds sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + view, err := s.viewType() + if err != nil { + return err + } + + h, ok := any(s).(sszutils.DynamicViewHashRoot) + if !ok { + return errors.New("SignedExecutionPayloadEnvelopeContents: generated SSZ code missing") + } + + fn := h.HashTreeRootWithDynView(view) + if fn == nil { + return fmt.Errorf("SignedExecutionPayloadEnvelopeContents: no view hasher for version %d", s.Version) + } + + return fn(ds, hh) +} + +// MarshalSSZ implements the fastssz.Marshaler interface. +func (s *SignedExecutionPayloadEnvelopeContents) MarshalSSZ() ([]byte, error) { + ds := dynssz.GetGlobalDynSsz() + + return s.MarshalSSZDyn(ds, make([]byte, 0, s.SizeSSZDyn(ds))) +} + +// MarshalSSZTo implements the fastssz.Marshaler interface. +func (s *SignedExecutionPayloadEnvelopeContents) MarshalSSZTo(dst []byte) ([]byte, error) { + return s.MarshalSSZDyn(dynssz.GetGlobalDynSsz(), dst) +} + +// UnmarshalSSZ implements the fastssz.Unmarshaler interface. +func (s *SignedExecutionPayloadEnvelopeContents) UnmarshalSSZ(buf []byte) error { + return s.UnmarshalSSZDyn(dynssz.GetGlobalDynSsz(), buf) +} + +// SizeSSZ implements the fastssz.Marshaler interface. +func (s *SignedExecutionPayloadEnvelopeContents) SizeSSZ() int { + return s.SizeSSZDyn(dynssz.GetGlobalDynSsz()) +} + +// HashTreeRoot implements the fastssz.HashRoot interface. +func (s *SignedExecutionPayloadEnvelopeContents) HashTreeRoot() ([32]byte, error) { + return dynssz.GetGlobalDynSsz().HashTreeRoot(s) +} + +// HashTreeRootWith implements the fastssz.HashRoot interface. +func (s *SignedExecutionPayloadEnvelopeContents) HashTreeRootWith(hh sszutils.HashWalker) error { + return s.HashTreeRootWithDyn(dynssz.GetGlobalDynSsz(), hh) +} + +// MarshalJSON delegates to the per-fork +// SignedExecutionPayloadEnvelopeContents that matches Version. +func (s *SignedExecutionPayloadEnvelopeContents) MarshalJSON() ([]byte, error) { + return marshalAsView(s) +} + +// UnmarshalJSON delegates to the per-fork +// SignedExecutionPayloadEnvelopeContents that matches Version. Caller must +// set Version before calling. +func (s *SignedExecutionPayloadEnvelopeContents) UnmarshalJSON(data []byte) error { + if err := unmarshalAsView(s, data); err != nil { + return err + } + + s.populateVersion(s.Version) + + return nil +} + +// MarshalYAML delegates to the per-fork +// SignedExecutionPayloadEnvelopeContents that matches Version. +func (s *SignedExecutionPayloadEnvelopeContents) MarshalYAML() ([]byte, error) { + return marshalAsViewYAML(s) +} + +// UnmarshalYAML delegates to the per-fork +// SignedExecutionPayloadEnvelopeContents that matches Version. Caller must +// set Version before calling. +func (s *SignedExecutionPayloadEnvelopeContents) UnmarshalYAML(data []byte) error { + if err := unmarshalAsViewYAML(s, data); err != nil { + return err + } + + s.populateVersion(s.Version) + + return nil +} diff --git a/api/v1/all/signedexecutionpayloadenvelopecontents_ssz.go b/api/v1/all/signedexecutionpayloadenvelopecontents_ssz.go new file mode 100644 index 00000000..d7709c70 --- /dev/null +++ b/api/v1/all/signedexecutionpayloadenvelopecontents_ssz.go @@ -0,0 +1,1288 @@ +// Code generated by dynamic-ssz. DO NOT EDIT. +// Hash: f3c91fa730a723f211a7b35fe312c487d88c538a0582764fc375b93cf20028c7 +// Version: v1.3.2 (https://github.com/pk910/dynamic-ssz) +package all + +import ( + "encoding/binary" + + "github.com/ethpandaops/go-eth2-client/api/v1/gloas" + "github.com/ethpandaops/go-eth2-client/spec/all" + "github.com/ethpandaops/go-eth2-client/spec/capella" + "github.com/ethpandaops/go-eth2-client/spec/electra" + gloas1 "github.com/ethpandaops/go-eth2-client/spec/gloas" + "github.com/holiman/uint256" + "github.com/pk910/dynamic-ssz/sszutils" +) + +var _ = sszutils.ErrListTooBig + +var _ = sszutils.Annotate[*gloas.SignedExecutionPayloadEnvelopeContents](`ssz-static:"false"`) + +func (t *SignedExecutionPayloadEnvelopeContents) MarshalSSZDynView(view any) func(ds sszutils.DynamicSpecs, buf []byte) ([]byte, error) { + switch view.(type) { + case *gloas.SignedExecutionPayloadEnvelopeContents: + return t.marshalSSZView_SignedExecutionPayloadEnvelopeContents + } + return nil +} +func (t *SignedExecutionPayloadEnvelopeContents) marshalSSZView_SignedExecutionPayloadEnvelopeContents(ds sszutils.DynamicSpecs, buf []byte) (dst []byte, err error) { + dst = buf + expr0, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_EXTRA_DATA_BYTES", 32) + if err != nil { + return dst, err + } + expr1, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_TRANSACTIONS_PER_PAYLOAD", 1048576) + if err != nil { + return dst, err + } + expr2, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BYTES_PER_TRANSACTION", 1073741824) + if err != nil { + return dst, err + } + expr3, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_WITHDRAWALS_PER_PAYLOAD", 16) + if err != nil { + return dst, err + } + expr4, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_DEPOSIT_REQUESTS_PER_PAYLOAD", 8192) + if err != nil { + return dst, err + } + expr5, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_WITHDRAWAL_REQUESTS_PER_PAYLOAD", 16) + if err != nil { + return dst, err + } + expr6, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD", 2) + if err != nil { + return dst, err + } + expr7, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BUILDER_DEPOSIT_REQUESTS_PER_PAYLOAD", 256) + if err != nil { + return dst, err + } + expr8, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BUILDER_EXIT_REQUESTS_PER_PAYLOAD", 16) + if err != nil { + return dst, err + } + expr9, err := sszutils.ResolveSpecValueWithDefault(ds, "FIELD_ELEMENTS_PER_EXT_BLOB*MAX_BLOB_COMMITMENTS_PER_BLOCK", 33554432) + if err != nil { + return dst, err + } + expr10, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BLOB_COMMITMENTS_PER_BLOCK", 4096) + if err != nil { + return dst, err + } + zeroBytes := sszutils.ZeroBytes() + if t == nil { + t = new(SignedExecutionPayloadEnvelopeContents) + } + dstlen := len(dst) + // Offset Field #0 'SignedExecutionPayloadEnvelope' + // Offset Field #1 'KZGProofs' + // Offset Field #2 'Blobs' + dst = append(dst, zeroBytes[:12]...) + { // Dynamic Field #0 'SignedExecutionPayloadEnvelope' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.SignedExecutionPayloadEnvelope + if t == nil { + t = new(all.SignedExecutionPayloadEnvelope) + } + dstlen := len(dst) + // Offset Field #0 'Message' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #1 'Signature' + dst = append(dst, t.Signature[:96]...) + } + { // Dynamic Field #0 'Message' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.Message + if t == nil { + t = new(all.ExecutionPayloadEnvelope) + } + dstlen := len(dst) + // Offset Field #0 'Payload' + // Offset Field #1 'ExecutionRequests' + dst = append(dst, 0, 0, 0, 0, 0, 0, 0, 0) + { // Static Field #2 'BuilderIndex' + dst = binary.LittleEndian.AppendUint64(dst, uint64(t.BuilderIndex)) + } + { // Static Field #3 'BeaconBlockRoot' + dst = append(dst, t.BeaconBlockRoot[:32]...) + } + { // Static Field #4 'ParentBeaconBlockRoot' + dst = append(dst, t.ParentBeaconBlockRoot[:32]...) + } + { // Dynamic Field #0 'Payload' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.Payload + if t == nil { + t = new(all.ExecutionPayload) + } + dstlen := len(dst) + { // Static Field #0 'ParentHash' + dst = append(dst, t.ParentHash[:32]...) + } + { // Static Field #1 'FeeRecipient' + dst = append(dst, t.FeeRecipient[:20]...) + } + { // Static Field #2 'StateRoot' + dst = append(dst, t.StateRoot[:32]...) + } + { // Static Field #3 'ReceiptsRoot' + dst = append(dst, t.ReceiptsRoot[:32]...) + } + { // Static Field #4 'LogsBloom' + dst = append(dst, t.LogsBloom[:256]...) + } + { // Static Field #5 'PrevRandao' + dst = append(dst, t.PrevRandao[:32]...) + } + { // Static Field #6 'BlockNumber' + dst = binary.LittleEndian.AppendUint64(dst, t.BlockNumber) + } + { // Static Field #7 'GasLimit' + dst = binary.LittleEndian.AppendUint64(dst, t.GasLimit) + } + { // Static Field #8 'GasUsed' + dst = binary.LittleEndian.AppendUint64(dst, t.GasUsed) + } + { // Static Field #9 'Timestamp' + dst = binary.LittleEndian.AppendUint64(dst, t.Timestamp) + } + // Offset Field #10 'ExtraData' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #11 'BaseFeePerGas' + t := t.BaseFeePerGas + if t == nil { + t = new(uint256.Int) + } + dst = sszutils.MarshalUint64Slice(dst, (*t)[:4]) + } + { // Static Field #12 'BlockHash' + dst = append(dst, t.BlockHash[:32]...) + } + // Offset Field #13 'Transactions' + // Offset Field #14 'Withdrawals' + dst = append(dst, 0, 0, 0, 0, 0, 0, 0, 0) + { // Static Field #15 'BlobGasUsed' + dst = binary.LittleEndian.AppendUint64(dst, t.BlobGasUsed) + } + { // Static Field #16 'ExcessBlobGas' + dst = binary.LittleEndian.AppendUint64(dst, t.ExcessBlobGas) + } + // Offset Field #17 'BlockAccessList' + dst = append(dst, 0, 0, 0, 0) + { // Static Field #18 'SlotNumber' + dst = binary.LittleEndian.AppendUint64(dst, t.SlotNumber) + } + { // Dynamic Field #10 'ExtraData' + binary.LittleEndian.PutUint32(dst[dstlen+436:], uint32(len(dst)-dstlen)) + vlen := len(t.ExtraData) + if vlen > int(expr0) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr0)), "SignedExecutionPayloadEnvelope.Message.Payload.ExtraData") + } + dst = append(dst, t.ExtraData[:]...) + } + { // Dynamic Field #13 'Transactions' + binary.LittleEndian.PutUint32(dst[dstlen+504:], uint32(len(dst)-dstlen)) + t := t.Transactions + vlen := len(t) + if vlen > int(expr1) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr1)), "SignedExecutionPayloadEnvelope.Message.Payload.Transactions") + } + dstlen := len(dst) + dst = sszutils.AppendZeroPadding(dst, vlen*4) + for idx1 := range vlen { + binary.LittleEndian.PutUint32(dst[dstlen+(idx1*4):], uint32(len(dst)-dstlen)) + vlen := len(t[idx1]) + if vlen > int(expr2) { + return nil, sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(vlen, int(expr2)), "SignedExecutionPayloadEnvelope.Message.Payload.Transactions[%d]", idx1) + } + dst = append(dst, t[idx1][:]...) + } + } + { // Dynamic Field #14 'Withdrawals' + binary.LittleEndian.PutUint32(dst[dstlen+508:], uint32(len(dst)-dstlen)) + t := t.Withdrawals + vlen := len(t) + if vlen > int(expr3) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr3)), "SignedExecutionPayloadEnvelope.Message.Payload.Withdrawals") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(capella.Withdrawal) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "SignedExecutionPayloadEnvelope.Message.Payload.Withdrawals[%d]", idx1) + } + } + } + { // Dynamic Field #17 'BlockAccessList' + binary.LittleEndian.PutUint32(dst[dstlen+528:], uint32(len(dst)-dstlen)) + vlen := len(t.BlockAccessList) + if vlen > int(expr2) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr2)), "SignedExecutionPayloadEnvelope.Message.Payload.BlockAccessList") + } + dst = append(dst, t.BlockAccessList[:]...) + } + } + { // Dynamic Field #1 'ExecutionRequests' + binary.LittleEndian.PutUint32(dst[dstlen+4:], uint32(len(dst)-dstlen)) + t := t.ExecutionRequests + if t == nil { + t = new(all.ExecutionRequests) + } + dstlen := len(dst) + // Offset Field #0 'Deposits' + // Offset Field #1 'Withdrawals' + // Offset Field #2 'Consolidations' + // Offset Field #3 'BuilderDeposits' + // Offset Field #4 'BuilderExits' + dst = append(dst, zeroBytes[:20]...) + { // Dynamic Field #0 'Deposits' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.Deposits + vlen := len(t) + if vlen > int(expr4) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr4)), "SignedExecutionPayloadEnvelope.Message.ExecutionRequests.Deposits") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(electra.DepositRequest) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "SignedExecutionPayloadEnvelope.Message.ExecutionRequests.Deposits[%d]", idx1) + } + } + } + { // Dynamic Field #1 'Withdrawals' + binary.LittleEndian.PutUint32(dst[dstlen+4:], uint32(len(dst)-dstlen)) + t := t.Withdrawals + vlen := len(t) + if vlen > int(expr5) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr5)), "SignedExecutionPayloadEnvelope.Message.ExecutionRequests.Withdrawals") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(electra.WithdrawalRequest) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "SignedExecutionPayloadEnvelope.Message.ExecutionRequests.Withdrawals[%d]", idx1) + } + } + } + { // Dynamic Field #2 'Consolidations' + binary.LittleEndian.PutUint32(dst[dstlen+8:], uint32(len(dst)-dstlen)) + t := t.Consolidations + vlen := len(t) + if vlen > int(expr6) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr6)), "SignedExecutionPayloadEnvelope.Message.ExecutionRequests.Consolidations") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(electra.ConsolidationRequest) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "SignedExecutionPayloadEnvelope.Message.ExecutionRequests.Consolidations[%d]", idx1) + } + } + } + { // Dynamic Field #3 'BuilderDeposits' + binary.LittleEndian.PutUint32(dst[dstlen+12:], uint32(len(dst)-dstlen)) + t := t.BuilderDeposits + vlen := len(t) + if vlen > int(expr7) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr7)), "SignedExecutionPayloadEnvelope.Message.ExecutionRequests.BuilderDeposits") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(gloas1.BuilderDepositRequest) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "SignedExecutionPayloadEnvelope.Message.ExecutionRequests.BuilderDeposits[%d]", idx1) + } + } + } + { // Dynamic Field #4 'BuilderExits' + binary.LittleEndian.PutUint32(dst[dstlen+16:], uint32(len(dst)-dstlen)) + t := t.BuilderExits + vlen := len(t) + if vlen > int(expr8) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr8)), "SignedExecutionPayloadEnvelope.Message.ExecutionRequests.BuilderExits") + } + for idx1 := range vlen { + t := t[idx1] + if t == nil { + t = new(gloas1.BuilderExitRequest) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPathf(err, "SignedExecutionPayloadEnvelope.Message.ExecutionRequests.BuilderExits[%d]", idx1) + } + } + } + } + } + } + { // Dynamic Field #1 'KZGProofs' + binary.LittleEndian.PutUint32(dst[dstlen+4:], uint32(len(dst)-dstlen)) + t := t.KZGProofs + vlen := len(t) + if vlen > int(expr9) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr9)), "KZGProofs") + } + dst = sszutils.MarshalFixedBytesSlice(dst, t[:vlen]) + } + { // Dynamic Field #2 'Blobs' + binary.LittleEndian.PutUint32(dst[dstlen+8:], uint32(len(dst)-dstlen)) + t := t.Blobs + vlen := len(t) + if vlen > int(expr10) { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, int(expr10)), "Blobs") + } + dst = sszutils.MarshalFixedBytesSlice(dst, t[:vlen]) + } + return dst, nil +} + +func (t *SignedExecutionPayloadEnvelopeContents) UnmarshalSSZDynView(view any) func(ds sszutils.DynamicSpecs, buf []byte) error { + switch view.(type) { + case *gloas.SignedExecutionPayloadEnvelopeContents: + return t.unmarshalSSZView_SignedExecutionPayloadEnvelopeContents + } + return nil +} +func (t *SignedExecutionPayloadEnvelopeContents) unmarshalSSZView_SignedExecutionPayloadEnvelopeContents(ds sszutils.DynamicSpecs, buf []byte) (err error) { + expr0, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_EXTRA_DATA_BYTES", 32) + if err != nil { + return err + } + expr1, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_TRANSACTIONS_PER_PAYLOAD", 1048576) + if err != nil { + return err + } + expr2, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BYTES_PER_TRANSACTION", 1073741824) + if err != nil { + return err + } + expr3, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_WITHDRAWALS_PER_PAYLOAD", 16) + if err != nil { + return err + } + expr4, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_DEPOSIT_REQUESTS_PER_PAYLOAD", 8192) + if err != nil { + return err + } + expr5, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_WITHDRAWAL_REQUESTS_PER_PAYLOAD", 16) + if err != nil { + return err + } + expr6, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD", 2) + if err != nil { + return err + } + expr7, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BUILDER_DEPOSIT_REQUESTS_PER_PAYLOAD", 256) + if err != nil { + return err + } + expr8, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BUILDER_EXIT_REQUESTS_PER_PAYLOAD", 16) + if err != nil { + return err + } + expr9, err := sszutils.ResolveSpecValueWithDefault(ds, "FIELD_ELEMENTS_PER_EXT_BLOB*MAX_BLOB_COMMITMENTS_PER_BLOCK", 33554432) + if err != nil { + return err + } + expr10, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BLOB_COMMITMENTS_PER_BLOCK", 4096) + if err != nil { + return err + } + buflen := len(buf) + if buflen < 12 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 12) + } + // Field #0 'SignedExecutionPayloadEnvelope' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 12 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset0, 12), "SignedExecutionPayloadEnvelope:o") + } + // Field #1 'KZGProofs' (offset) + offset1 := int(binary.LittleEndian.Uint32(buf[4:8])) + if offset1 < offset0 || offset1 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset1, offset0, buflen), "KZGProofs:o") + } + // Field #2 'Blobs' (offset) + offset2 := int(binary.LittleEndian.Uint32(buf[8:12])) + if offset2 < offset1 || offset2 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset2, offset1, buflen), "Blobs:o") + } + { // Field #0 'SignedExecutionPayloadEnvelope' (dynamic) + buf := buf[offset0:offset1] + if t.SignedExecutionPayloadEnvelope == nil { + t.SignedExecutionPayloadEnvelope = new(all.SignedExecutionPayloadEnvelope) + } + buflen := len(buf) + if buflen < 100 { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, 100), "SignedExecutionPayloadEnvelope") + } + // Field #0 'Message' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 100 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset0, 100), "SignedExecutionPayloadEnvelope.Message:o") + } + { // Field #1 'Signature' (static) + buf := buf[4:100] + copy(t.SignedExecutionPayloadEnvelope.Signature[:], buf) + } + { // Field #0 'Message' (dynamic) + buf := buf[offset0:] + if t.SignedExecutionPayloadEnvelope.Message == nil { + t.SignedExecutionPayloadEnvelope.Message = new(all.ExecutionPayloadEnvelope) + } + buflen := len(buf) + if buflen < 80 { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, 80), "SignedExecutionPayloadEnvelope.Message") + } + // Field #0 'Payload' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 80 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset0, 80), "SignedExecutionPayloadEnvelope.Message.Payload:o") + } + // Field #1 'ExecutionRequests' (offset) + offset1 := int(binary.LittleEndian.Uint32(buf[4:8])) + if offset1 < offset0 || offset1 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset1, offset0, buflen), "SignedExecutionPayloadEnvelope.Message.ExecutionRequests:o") + } + { // Field #2 'BuilderIndex' (static) + buf := buf[8:16] + t.SignedExecutionPayloadEnvelope.Message.BuilderIndex = gloas1.BuilderIndex(binary.LittleEndian.Uint64(buf)) + } + { // Field #3 'BeaconBlockRoot' (static) + buf := buf[16:48] + copy(t.SignedExecutionPayloadEnvelope.Message.BeaconBlockRoot[:], buf) + } + { // Field #4 'ParentBeaconBlockRoot' (static) + buf := buf[48:80] + copy(t.SignedExecutionPayloadEnvelope.Message.ParentBeaconBlockRoot[:], buf) + } + { // Field #0 'Payload' (dynamic) + buf := buf[offset0:offset1] + if t.SignedExecutionPayloadEnvelope.Message.Payload == nil { + t.SignedExecutionPayloadEnvelope.Message.Payload = new(all.ExecutionPayload) + } + buflen := len(buf) + if buflen < 540 { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, 540), "SignedExecutionPayloadEnvelope.Message.Payload") + } + { // Field #0 'ParentHash' (static) + buf := buf[0:32] + copy(t.SignedExecutionPayloadEnvelope.Message.Payload.ParentHash[:], buf) + } + { // Field #1 'FeeRecipient' (static) + buf := buf[32:52] + copy(t.SignedExecutionPayloadEnvelope.Message.Payload.FeeRecipient[:], buf) + } + { // Field #2 'StateRoot' (static) + buf := buf[52:84] + copy(t.SignedExecutionPayloadEnvelope.Message.Payload.StateRoot[:], buf) + } + { // Field #3 'ReceiptsRoot' (static) + buf := buf[84:116] + copy(t.SignedExecutionPayloadEnvelope.Message.Payload.ReceiptsRoot[:], buf) + } + { // Field #4 'LogsBloom' (static) + buf := buf[116:372] + copy(t.SignedExecutionPayloadEnvelope.Message.Payload.LogsBloom[:], buf) + } + { // Field #5 'PrevRandao' (static) + buf := buf[372:404] + copy(t.SignedExecutionPayloadEnvelope.Message.Payload.PrevRandao[:], buf) + } + { // Field #6 'BlockNumber' (static) + buf := buf[404:412] + t.SignedExecutionPayloadEnvelope.Message.Payload.BlockNumber = binary.LittleEndian.Uint64(buf) + } + { // Field #7 'GasLimit' (static) + buf := buf[412:420] + t.SignedExecutionPayloadEnvelope.Message.Payload.GasLimit = binary.LittleEndian.Uint64(buf) + } + { // Field #8 'GasUsed' (static) + buf := buf[420:428] + t.SignedExecutionPayloadEnvelope.Message.Payload.GasUsed = binary.LittleEndian.Uint64(buf) + } + { // Field #9 'Timestamp' (static) + buf := buf[428:436] + t.SignedExecutionPayloadEnvelope.Message.Payload.Timestamp = binary.LittleEndian.Uint64(buf) + } + // Field #10 'ExtraData' (offset) + offset10 := int(binary.LittleEndian.Uint32(buf[436:440])) + if offset10 != 540 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset10, 540), "SignedExecutionPayloadEnvelope.Message.Payload.ExtraData:o") + } + { // Field #11 'BaseFeePerGas' (static) + buf := buf[440:472] + val1 := t.SignedExecutionPayloadEnvelope.Message.Payload.BaseFeePerGas + if val1 == nil { + val1 = new(uint256.Int) + } + sszutils.UnmarshalUint64Slice((*val1)[:4], buf) + t.SignedExecutionPayloadEnvelope.Message.Payload.BaseFeePerGas = val1 + } + { // Field #12 'BlockHash' (static) + buf := buf[472:504] + copy(t.SignedExecutionPayloadEnvelope.Message.Payload.BlockHash[:], buf) + } + // Field #13 'Transactions' (offset) + offset13 := int(binary.LittleEndian.Uint32(buf[504:508])) + if offset13 < offset10 || offset13 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset13, offset10, buflen), "SignedExecutionPayloadEnvelope.Message.Payload.Transactions:o") + } + // Field #14 'Withdrawals' (offset) + offset14 := int(binary.LittleEndian.Uint32(buf[508:512])) + if offset14 < offset13 || offset14 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset14, offset13, buflen), "SignedExecutionPayloadEnvelope.Message.Payload.Withdrawals:o") + } + { // Field #15 'BlobGasUsed' (static) + buf := buf[512:520] + t.SignedExecutionPayloadEnvelope.Message.Payload.BlobGasUsed = binary.LittleEndian.Uint64(buf) + } + { // Field #16 'ExcessBlobGas' (static) + buf := buf[520:528] + t.SignedExecutionPayloadEnvelope.Message.Payload.ExcessBlobGas = binary.LittleEndian.Uint64(buf) + } + // Field #17 'BlockAccessList' (offset) + offset17 := int(binary.LittleEndian.Uint32(buf[528:532])) + if offset17 < offset14 || offset17 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset17, offset14, buflen), "SignedExecutionPayloadEnvelope.Message.Payload.BlockAccessList:o") + } + { // Field #18 'SlotNumber' (static) + buf := buf[532:540] + t.SignedExecutionPayloadEnvelope.Message.Payload.SlotNumber = binary.LittleEndian.Uint64(buf) + } + { // Field #10 'ExtraData' (dynamic) + buf := buf[offset10:offset13] + if len(buf) > int(expr0) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(len(buf), int(expr0)), "SignedExecutionPayloadEnvelope.Message.Payload.ExtraData") + } + t.SignedExecutionPayloadEnvelope.Message.Payload.ExtraData = sszutils.ExpandSlice(t.SignedExecutionPayloadEnvelope.Message.Payload.ExtraData, len(buf)) + copy(t.SignedExecutionPayloadEnvelope.Message.Payload.ExtraData[:], buf) + } + { // Field #13 'Transactions' (dynamic) + buf := buf[offset13:offset14] + val2 := t.SignedExecutionPayloadEnvelope.Message.Payload.Transactions + startOffset := int(0) + if len(buf) != 0 { + if len(buf) < 4 { + return sszutils.ErrorWithPath(sszutils.ErrListOffsetsEOFFn(len(buf), 4), "SignedExecutionPayloadEnvelope.Message.Payload.Transactions") + } + startOffset = int(binary.LittleEndian.Uint32(buf[0:4])) + } + itemCount := startOffset / 4 + if startOffset%4 != 0 || len(buf) < startOffset || (len(buf) != 0 && startOffset == 0) { + return sszutils.ErrorWithPath(sszutils.ErrInvalidListStartOffsetFn(startOffset, len(buf)), "SignedExecutionPayloadEnvelope.Message.Payload.Transactions") + } + if itemCount > int(expr1) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr1)), "SignedExecutionPayloadEnvelope.Message.Payload.Transactions") + } + val2 = sszutils.ExpandSlice(val2, itemCount) + for idx1 := range itemCount { + var endOffset int + if idx1 < itemCount-1 { + endOffset = int(binary.LittleEndian.Uint32(buf[(idx1+1)*4 : (idx1+2)*4])) + } else { + endOffset = len(buf) + } + if endOffset < startOffset || endOffset > len(buf) { + return sszutils.ErrorWithPathf(sszutils.ErrElementOffsetOutOfRangeFn(endOffset, startOffset, len(buf)), "SignedExecutionPayloadEnvelope.Message.Payload.Transactions[%d]", idx1) + } + buf := buf[startOffset:endOffset] + startOffset = endOffset + val3 := val2[idx1] + if len(buf) > int(expr2) { + return sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(len(buf), int(expr2)), "SignedExecutionPayloadEnvelope.Message.Payload.Transactions[%d]", idx1) + } + val3 = sszutils.ExpandSlice(val3, len(buf)) + copy(val3[:], buf) + val2[idx1] = val3 + } + t.SignedExecutionPayloadEnvelope.Message.Payload.Transactions = val2 + } + { // Field #14 'Withdrawals' (dynamic) + buf := buf[offset14:offset17] + val4 := t.SignedExecutionPayloadEnvelope.Message.Payload.Withdrawals + itemCount := len(buf) / 44 + if len(buf)%44 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 44), "SignedExecutionPayloadEnvelope.Message.Payload.Withdrawals") + } + if itemCount > int(expr3) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr3)), "SignedExecutionPayloadEnvelope.Message.Payload.Withdrawals") + } + val4 = sszutils.ExpandSlice(val4, itemCount) + for idx1 := range itemCount { + if val4[idx1] == nil { + val4[idx1] = new(capella.Withdrawal) + } + buf := buf[44*idx1 : 44*(idx1+1)] + if err = val4[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "SignedExecutionPayloadEnvelope.Message.Payload.Withdrawals[%d]", idx1) + } + } + t.SignedExecutionPayloadEnvelope.Message.Payload.Withdrawals = val4 + } + { // Field #17 'BlockAccessList' (dynamic) + buf := buf[offset17:] + if len(buf) > int(expr2) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(len(buf), int(expr2)), "SignedExecutionPayloadEnvelope.Message.Payload.BlockAccessList") + } + t.SignedExecutionPayloadEnvelope.Message.Payload.BlockAccessList = sszutils.ExpandSlice(t.SignedExecutionPayloadEnvelope.Message.Payload.BlockAccessList, len(buf)) + copy(t.SignedExecutionPayloadEnvelope.Message.Payload.BlockAccessList[:], buf) + } + } + { // Field #1 'ExecutionRequests' (dynamic) + buf := buf[offset1:] + if t.SignedExecutionPayloadEnvelope.Message.ExecutionRequests == nil { + t.SignedExecutionPayloadEnvelope.Message.ExecutionRequests = new(all.ExecutionRequests) + } + buflen := len(buf) + if buflen < 20 { + return sszutils.ErrorWithPath(sszutils.ErrFixedFieldsEOFFn(buflen, 20), "SignedExecutionPayloadEnvelope.Message.ExecutionRequests") + } + // Field #0 'Deposits' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 20 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset0, 20), "SignedExecutionPayloadEnvelope.Message.ExecutionRequests.Deposits:o") + } + // Field #1 'Withdrawals' (offset) + offset1 := int(binary.LittleEndian.Uint32(buf[4:8])) + if offset1 < offset0 || offset1 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset1, offset0, buflen), "SignedExecutionPayloadEnvelope.Message.ExecutionRequests.Withdrawals:o") + } + // Field #2 'Consolidations' (offset) + offset2 := int(binary.LittleEndian.Uint32(buf[8:12])) + if offset2 < offset1 || offset2 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset2, offset1, buflen), "SignedExecutionPayloadEnvelope.Message.ExecutionRequests.Consolidations:o") + } + // Field #3 'BuilderDeposits' (offset) + offset3 := int(binary.LittleEndian.Uint32(buf[12:16])) + if offset3 < offset2 || offset3 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset3, offset2, buflen), "SignedExecutionPayloadEnvelope.Message.ExecutionRequests.BuilderDeposits:o") + } + // Field #4 'BuilderExits' (offset) + offset4 := int(binary.LittleEndian.Uint32(buf[16:20])) + if offset4 < offset3 || offset4 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset4, offset3, buflen), "SignedExecutionPayloadEnvelope.Message.ExecutionRequests.BuilderExits:o") + } + { // Field #0 'Deposits' (dynamic) + buf := buf[offset0:offset1] + val5 := t.SignedExecutionPayloadEnvelope.Message.ExecutionRequests.Deposits + itemCount := len(buf) / 192 + if len(buf)%192 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 192), "SignedExecutionPayloadEnvelope.Message.ExecutionRequests.Deposits") + } + if itemCount > int(expr4) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr4)), "SignedExecutionPayloadEnvelope.Message.ExecutionRequests.Deposits") + } + val5 = sszutils.ExpandSlice(val5, itemCount) + for idx1 := range itemCount { + if val5[idx1] == nil { + val5[idx1] = new(electra.DepositRequest) + } + buf := buf[192*idx1 : 192*(idx1+1)] + if err = val5[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "SignedExecutionPayloadEnvelope.Message.ExecutionRequests.Deposits[%d]", idx1) + } + } + t.SignedExecutionPayloadEnvelope.Message.ExecutionRequests.Deposits = val5 + } + { // Field #1 'Withdrawals' (dynamic) + buf := buf[offset1:offset2] + val6 := t.SignedExecutionPayloadEnvelope.Message.ExecutionRequests.Withdrawals + itemCount := len(buf) / 76 + if len(buf)%76 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 76), "SignedExecutionPayloadEnvelope.Message.ExecutionRequests.Withdrawals") + } + if itemCount > int(expr5) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr5)), "SignedExecutionPayloadEnvelope.Message.ExecutionRequests.Withdrawals") + } + val6 = sszutils.ExpandSlice(val6, itemCount) + for idx1 := range itemCount { + if val6[idx1] == nil { + val6[idx1] = new(electra.WithdrawalRequest) + } + buf := buf[76*idx1 : 76*(idx1+1)] + if err = val6[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "SignedExecutionPayloadEnvelope.Message.ExecutionRequests.Withdrawals[%d]", idx1) + } + } + t.SignedExecutionPayloadEnvelope.Message.ExecutionRequests.Withdrawals = val6 + } + { // Field #2 'Consolidations' (dynamic) + buf := buf[offset2:offset3] + val7 := t.SignedExecutionPayloadEnvelope.Message.ExecutionRequests.Consolidations + itemCount := len(buf) / 116 + if len(buf)%116 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 116), "SignedExecutionPayloadEnvelope.Message.ExecutionRequests.Consolidations") + } + if itemCount > int(expr6) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr6)), "SignedExecutionPayloadEnvelope.Message.ExecutionRequests.Consolidations") + } + val7 = sszutils.ExpandSlice(val7, itemCount) + for idx1 := range itemCount { + if val7[idx1] == nil { + val7[idx1] = new(electra.ConsolidationRequest) + } + buf := buf[116*idx1 : 116*(idx1+1)] + if err = val7[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "SignedExecutionPayloadEnvelope.Message.ExecutionRequests.Consolidations[%d]", idx1) + } + } + t.SignedExecutionPayloadEnvelope.Message.ExecutionRequests.Consolidations = val7 + } + { // Field #3 'BuilderDeposits' (dynamic) + buf := buf[offset3:offset4] + val8 := t.SignedExecutionPayloadEnvelope.Message.ExecutionRequests.BuilderDeposits + itemCount := len(buf) / 184 + if len(buf)%184 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 184), "SignedExecutionPayloadEnvelope.Message.ExecutionRequests.BuilderDeposits") + } + if itemCount > int(expr7) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr7)), "SignedExecutionPayloadEnvelope.Message.ExecutionRequests.BuilderDeposits") + } + val8 = sszutils.ExpandSlice(val8, itemCount) + for idx1 := range itemCount { + if val8[idx1] == nil { + val8[idx1] = new(gloas1.BuilderDepositRequest) + } + buf := buf[184*idx1 : 184*(idx1+1)] + if err = val8[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "SignedExecutionPayloadEnvelope.Message.ExecutionRequests.BuilderDeposits[%d]", idx1) + } + } + t.SignedExecutionPayloadEnvelope.Message.ExecutionRequests.BuilderDeposits = val8 + } + { // Field #4 'BuilderExits' (dynamic) + buf := buf[offset4:] + val9 := t.SignedExecutionPayloadEnvelope.Message.ExecutionRequests.BuilderExits + itemCount := len(buf) / 68 + if len(buf)%68 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 68), "SignedExecutionPayloadEnvelope.Message.ExecutionRequests.BuilderExits") + } + if itemCount > int(expr8) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr8)), "SignedExecutionPayloadEnvelope.Message.ExecutionRequests.BuilderExits") + } + val9 = sszutils.ExpandSlice(val9, itemCount) + for idx1 := range itemCount { + if val9[idx1] == nil { + val9[idx1] = new(gloas1.BuilderExitRequest) + } + buf := buf[68*idx1 : 68*(idx1+1)] + if err = val9[idx1].UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPathf(err, "SignedExecutionPayloadEnvelope.Message.ExecutionRequests.BuilderExits[%d]", idx1) + } + } + t.SignedExecutionPayloadEnvelope.Message.ExecutionRequests.BuilderExits = val9 + } + } + } + } + { // Field #1 'KZGProofs' (dynamic) + buf := buf[offset1:offset2] + val10 := t.KZGProofs + itemCount := len(buf) / 48 + if len(buf)%48 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 48), "KZGProofs") + } + if itemCount > int(expr9) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr9)), "KZGProofs") + } + val10 = sszutils.ExpandSlice(val10, itemCount) + sszutils.UnmarshalFixedBytesSlice(val10[:itemCount], buf) + t.KZGProofs = val10 + } + { // Field #2 'Blobs' (dynamic) + buf := buf[offset2:] + val11 := t.Blobs + itemCount := len(buf) / 131072 + if len(buf)%131072 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 131072), "Blobs") + } + if itemCount > int(expr10) { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, int(expr10)), "Blobs") + } + val11 = sszutils.ExpandSlice(val11, itemCount) + sszutils.UnmarshalFixedBytesSlice(val11[:itemCount], buf) + t.Blobs = val11 + } + return nil +} + +func (t *SignedExecutionPayloadEnvelopeContents) SizeSSZDynView(view any) func(ds sszutils.DynamicSpecs) int { + switch view.(type) { + case *gloas.SignedExecutionPayloadEnvelopeContents: + return t.sizeSSZView_SignedExecutionPayloadEnvelopeContents + } + return nil +} +func (t *SignedExecutionPayloadEnvelopeContents) sizeSSZView_SignedExecutionPayloadEnvelopeContents(ds sszutils.DynamicSpecs) (size int) { + if t == nil { + t = new(SignedExecutionPayloadEnvelopeContents) + } + // Field #0 'SignedExecutionPayloadEnvelope' offset (4 bytes) + // Field #1 'KZGProofs' offset (4 bytes) + // Field #2 'Blobs' offset (4 bytes) + size += 12 + { // Dynamic field #0 'SignedExecutionPayloadEnvelope' + t := t.SignedExecutionPayloadEnvelope + if t == nil { + t = new(all.SignedExecutionPayloadEnvelope) + } + // Field #0 'Message' offset (4 bytes) + // Field #1 'Signature' static (96 bytes) + size += 100 + { // Dynamic field #0 'Message' + t := t.Message + if t == nil { + t = new(all.ExecutionPayloadEnvelope) + } + // Field #0 'Payload' offset (4 bytes) + // Field #1 'ExecutionRequests' offset (4 bytes) + // Field #2 'BuilderIndex' static (8 bytes) + // Field #3 'BeaconBlockRoot' static (32 bytes) + // Field #4 'ParentBeaconBlockRoot' static (32 bytes) + size += 80 + { // Dynamic field #0 'Payload' + t := t.Payload + if t == nil { + t = new(all.ExecutionPayload) + } + // Field #0 'ParentHash' static (32 bytes) + // Field #1 'FeeRecipient' static (20 bytes) + // Field #2 'StateRoot' static (32 bytes) + // Field #3 'ReceiptsRoot' static (32 bytes) + // Field #4 'LogsBloom' static (256 bytes) + // Field #5 'PrevRandao' static (32 bytes) + // Field #6 'BlockNumber' static (8 bytes) + // Field #7 'GasLimit' static (8 bytes) + // Field #8 'GasUsed' static (8 bytes) + // Field #9 'Timestamp' static (8 bytes) + // Field #10 'ExtraData' offset (4 bytes) + // Field #11 'BaseFeePerGas' static (32 bytes) + // Field #12 'BlockHash' static (32 bytes) + // Field #13 'Transactions' offset (4 bytes) + // Field #14 'Withdrawals' offset (4 bytes) + // Field #15 'BlobGasUsed' static (8 bytes) + // Field #16 'ExcessBlobGas' static (8 bytes) + // Field #17 'BlockAccessList' offset (4 bytes) + // Field #18 'SlotNumber' static (8 bytes) + size += 540 + { // Dynamic field #10 'ExtraData' + size += len(t.ExtraData) + } + { // Dynamic field #13 'Transactions' + t := t.Transactions + vlen := len(t) + size += vlen * 4 // Offsets + for i1 := range vlen { + size += len(t[i1]) + } + } + { // Dynamic field #14 'Withdrawals' + size += len(t.Withdrawals) * 44 + } + { // Dynamic field #17 'BlockAccessList' + size += len(t.BlockAccessList) + } + } + { // Dynamic field #1 'ExecutionRequests' + t := t.ExecutionRequests + if t == nil { + t = new(all.ExecutionRequests) + } + // Field #0 'Deposits' offset (4 bytes) + // Field #1 'Withdrawals' offset (4 bytes) + // Field #2 'Consolidations' offset (4 bytes) + // Field #3 'BuilderDeposits' offset (4 bytes) + // Field #4 'BuilderExits' offset (4 bytes) + size += 20 + { // Dynamic field #0 'Deposits' + size += len(t.Deposits) * 192 + } + { // Dynamic field #1 'Withdrawals' + size += len(t.Withdrawals) * 76 + } + { // Dynamic field #2 'Consolidations' + size += len(t.Consolidations) * 116 + } + { // Dynamic field #3 'BuilderDeposits' + size += len(t.BuilderDeposits) * 184 + } + { // Dynamic field #4 'BuilderExits' + size += len(t.BuilderExits) * 68 + } + } + } + } + { // Dynamic field #1 'KZGProofs' + size += len(t.KZGProofs) * 48 + } + { // Dynamic field #2 'Blobs' + size += len(t.Blobs) * 131072 + } + return size +} + +func (t *SignedExecutionPayloadEnvelopeContents) HashTreeRootWithDynView(view any) func(ds sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + switch view.(type) { + case *gloas.SignedExecutionPayloadEnvelopeContents: + return t.hashTreeRootView_SignedExecutionPayloadEnvelopeContents + } + return nil +} +func (t *SignedExecutionPayloadEnvelopeContents) hashTreeRootView_SignedExecutionPayloadEnvelopeContents(ds sszutils.DynamicSpecs, hh sszutils.HashWalker) error { + expr0, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_EXTRA_DATA_BYTES", 32) + if err != nil { + return err + } + expr1, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_TRANSACTIONS_PER_PAYLOAD", 1048576) + if err != nil { + return err + } + expr2, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BYTES_PER_TRANSACTION", 1073741824) + if err != nil { + return err + } + expr3, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_WITHDRAWALS_PER_PAYLOAD", 16) + if err != nil { + return err + } + expr4, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_DEPOSIT_REQUESTS_PER_PAYLOAD", 8192) + if err != nil { + return err + } + expr5, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_WITHDRAWAL_REQUESTS_PER_PAYLOAD", 16) + if err != nil { + return err + } + expr6, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD", 2) + if err != nil { + return err + } + expr7, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BUILDER_DEPOSIT_REQUESTS_PER_PAYLOAD", 256) + if err != nil { + return err + } + expr8, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BUILDER_EXIT_REQUESTS_PER_PAYLOAD", 16) + if err != nil { + return err + } + expr9, err := sszutils.ResolveSpecValueWithDefault(ds, "FIELD_ELEMENTS_PER_EXT_BLOB*MAX_BLOB_COMMITMENTS_PER_BLOCK", 33554432) + if err != nil { + return err + } + expr10, err := sszutils.ResolveSpecValueWithDefault(ds, "MAX_BLOB_COMMITMENTS_PER_BLOCK", 4096) + if err != nil { + return err + } + if t == nil { + t = new(SignedExecutionPayloadEnvelopeContents) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'SignedExecutionPayloadEnvelope' + t := t.SignedExecutionPayloadEnvelope + if t == nil { + t = new(all.SignedExecutionPayloadEnvelope) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Message' + t := t.Message + if t == nil { + t = new(all.ExecutionPayloadEnvelope) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Payload' + t := t.Payload + if t == nil { + t = new(all.ExecutionPayload) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'ParentHash' + hh.PutBytes(t.ParentHash[:32]) + } + { // Field #1 'FeeRecipient' + hh.PutBytes(t.FeeRecipient[:20]) + } + { // Field #2 'StateRoot' + hh.PutBytes(t.StateRoot[:32]) + } + { // Field #3 'ReceiptsRoot' + hh.PutBytes(t.ReceiptsRoot[:32]) + } + { // Field #4 'LogsBloom' + hh.PutBytes(t.LogsBloom[:256]) + } + { // Field #5 'PrevRandao' + hh.PutBytes(t.PrevRandao[:32]) + } + { // Field #6 'BlockNumber' + hh.PutUint64(t.BlockNumber) + } + { // Field #7 'GasLimit' + hh.PutUint64(t.GasLimit) + } + { // Field #8 'GasUsed' + hh.PutUint64(t.GasUsed) + } + { // Field #9 'Timestamp' + hh.PutUint64(t.Timestamp) + } + { // Field #10 'ExtraData' + vlen := uint64(len(t.ExtraData)) + if vlen > expr0 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr0), "SignedExecutionPayloadEnvelope.Message.Payload.ExtraData") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + hh.AppendBytes32(t.ExtraData[:]) + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr0, vlen, 1)) + } + { // Field #11 'BaseFeePerGas' + t := t.BaseFeePerGas + if t == nil { + t = new(uint256.Int) + } + if root, err := t.HashTreeRoot(); err != nil { + return sszutils.ErrorWithPath(err, "SignedExecutionPayloadEnvelope.Message.Payload.BaseFeePerGas") + } else { + hh.AppendBytes32(root[:]) + } + } + { // Field #12 'BlockHash' + hh.PutBytes(t.BlockHash[:32]) + } + { // Field #13 'Transactions' + t := t.Transactions + vlen := uint64(len(t)) + if vlen > expr1 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr1), "SignedExecutionPayloadEnvelope.Message.Payload.Transactions") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + vlen := uint64(len(t[idx1])) + if vlen > expr2 { + return sszutils.ErrorWithPathf(sszutils.ErrListLengthFn(vlen, expr2), "SignedExecutionPayloadEnvelope.Message.Payload.Transactions[%d]", idx1) + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + hh.AppendBytes32(t[idx1][:]) + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr2, vlen, 1)) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr1, vlen, 32)) + } + { // Field #14 'Withdrawals' + t := t.Withdrawals + vlen := uint64(len(t)) + if vlen > expr3 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr3), "SignedExecutionPayloadEnvelope.Message.Payload.Withdrawals") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(capella.Withdrawal) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "SignedExecutionPayloadEnvelope.Message.Payload.Withdrawals[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr3, vlen, 32)) + } + { // Field #15 'BlobGasUsed' + hh.PutUint64(t.BlobGasUsed) + } + { // Field #16 'ExcessBlobGas' + hh.PutUint64(t.ExcessBlobGas) + } + { // Field #17 'BlockAccessList' + vlen := uint64(len(t.BlockAccessList)) + if vlen > expr2 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr2), "SignedExecutionPayloadEnvelope.Message.Payload.BlockAccessList") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + hh.AppendBytes32(t.BlockAccessList[:]) + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr2, vlen, 1)) + } + { // Field #18 'SlotNumber' + hh.PutUint64(t.SlotNumber) + } + hh.Merkleize(idx) + } + { // Field #1 'ExecutionRequests' + t := t.ExecutionRequests + if t == nil { + t = new(all.ExecutionRequests) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'Deposits' + t := t.Deposits + vlen := uint64(len(t)) + if vlen > expr4 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr4), "SignedExecutionPayloadEnvelope.Message.ExecutionRequests.Deposits") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(electra.DepositRequest) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "SignedExecutionPayloadEnvelope.Message.ExecutionRequests.Deposits[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr4, vlen, 32)) + } + { // Field #1 'Withdrawals' + t := t.Withdrawals + vlen := uint64(len(t)) + if vlen > expr5 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr5), "SignedExecutionPayloadEnvelope.Message.ExecutionRequests.Withdrawals") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(electra.WithdrawalRequest) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "SignedExecutionPayloadEnvelope.Message.ExecutionRequests.Withdrawals[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr5, vlen, 32)) + } + { // Field #2 'Consolidations' + t := t.Consolidations + vlen := uint64(len(t)) + if vlen > expr6 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr6), "SignedExecutionPayloadEnvelope.Message.ExecutionRequests.Consolidations") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(electra.ConsolidationRequest) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "SignedExecutionPayloadEnvelope.Message.ExecutionRequests.Consolidations[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr6, vlen, 32)) + } + { // Field #3 'BuilderDeposits' + t := t.BuilderDeposits + vlen := uint64(len(t)) + if vlen > expr7 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr7), "SignedExecutionPayloadEnvelope.Message.ExecutionRequests.BuilderDeposits") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(gloas1.BuilderDepositRequest) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "SignedExecutionPayloadEnvelope.Message.ExecutionRequests.BuilderDeposits[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr7, vlen, 32)) + } + { // Field #4 'BuilderExits' + t := t.BuilderExits + vlen := uint64(len(t)) + if vlen > expr8 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr8), "SignedExecutionPayloadEnvelope.Message.ExecutionRequests.BuilderExits") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + t := t[idx1] + if t == nil { + t = new(gloas1.BuilderExitRequest) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPathf(err, "SignedExecutionPayloadEnvelope.Message.ExecutionRequests.BuilderExits[%d]", idx1) + } + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr8, vlen, 32)) + } + hh.Merkleize(idx) + } + { // Field #2 'BuilderIndex' + hh.PutUint64(uint64(t.BuilderIndex)) + } + { // Field #3 'BeaconBlockRoot' + hh.PutBytes(t.BeaconBlockRoot[:32]) + } + { // Field #4 'ParentBeaconBlockRoot' + hh.PutBytes(t.ParentBeaconBlockRoot[:32]) + } + hh.Merkleize(idx) + } + { // Field #1 'Signature' + hh.PutBytes(t.Signature[:96]) + } + hh.Merkleize(idx) + } + { // Field #1 'KZGProofs' + t := t.KZGProofs + vlen := uint64(len(t)) + if vlen > expr9 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr9), "KZGProofs") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + hh.PutBytes(t[idx1][:48]) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr9, vlen, 32)) + } + { // Field #2 'Blobs' + t := t.Blobs + vlen := uint64(len(t)) + if vlen > expr10 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, expr10), "Blobs") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + hh.PutBytes(t[idx1][:131072]) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(expr10, vlen, 32)) + } + hh.Merkleize(idx) + return nil +} diff --git a/api/v1/all/signedexecutionpayloadenvelopecontents_test.go b/api/v1/all/signedexecutionpayloadenvelopecontents_test.go new file mode 100644 index 00000000..babc7e4f --- /dev/null +++ b/api/v1/all/signedexecutionpayloadenvelopecontents_test.go @@ -0,0 +1,184 @@ +// Copyright © 2026 Attestant Limited. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package all_test + +import ( + "encoding/json" + "testing" + + apiv1all "github.com/ethpandaops/go-eth2-client/api/v1/all" + apiv1gloas "github.com/ethpandaops/go-eth2-client/api/v1/gloas" + "github.com/ethpandaops/go-eth2-client/spec/bellatrix" + "github.com/ethpandaops/go-eth2-client/spec/capella" + "github.com/ethpandaops/go-eth2-client/spec/electra" + "github.com/ethpandaops/go-eth2-client/spec/gloas" + "github.com/ethpandaops/go-eth2-client/spec/phase0" + "github.com/ethpandaops/go-eth2-client/spec/version" + "github.com/holiman/uint256" + "github.com/stretchr/testify/require" +) + +// testGloasSignedExecutionPayloadEnvelope builds a gloas signed execution +// payload envelope with realistic-ish data. +func testGloasSignedExecutionPayloadEnvelope() *gloas.SignedExecutionPayloadEnvelope { + return &gloas.SignedExecutionPayloadEnvelope{ + Message: &gloas.ExecutionPayloadEnvelope{ + Payload: &gloas.ExecutionPayload{ + ParentHash: phase0.Hash32{0x01}, + FeeRecipient: bellatrix.ExecutionAddress{0x02}, + StateRoot: phase0.Root{0x03}, + ReceiptsRoot: phase0.Root{0x04}, + LogsBloom: [256]byte{0x05}, + PrevRandao: [32]byte{0x06}, + BlockNumber: 7, + GasLimit: 30_000_000, + GasUsed: 21_000, + Timestamp: 1_600_000_000, + ExtraData: []byte{0x08}, + BaseFeePerGas: uint256.NewInt(9), + BlockHash: phase0.Hash32{0x0a}, + Transactions: []bellatrix.Transaction{{0x0b, 0x0c}}, + Withdrawals: []*capella.Withdrawal{ + {Index: 1, ValidatorIndex: 2, Address: bellatrix.ExecutionAddress{0x0d}, Amount: 3}, + }, + BlobGasUsed: 131072, + ExcessBlobGas: 262144, + BlockAccessList: gloas.BlockAccessList{0x0e}, + SlotNumber: 12345, + }, + ExecutionRequests: &gloas.ExecutionRequests{ + Deposits: []*electra.DepositRequest{}, + Withdrawals: []*electra.WithdrawalRequest{}, + Consolidations: []*electra.ConsolidationRequest{}, + BuilderDeposits: []*gloas.BuilderDepositRequest{}, + BuilderExits: []*gloas.BuilderExitRequest{}, + }, + BuilderIndex: 42, + BeaconBlockRoot: phase0.Root{0x11}, + ParentBeaconBlockRoot: phase0.Root{0x12}, + }, + Signature: phase0.BLSSignature{0x13}, + } +} + +// signedExecutionPayloadEnvelopeContentsTests enumerates the versions the +// agnostic SignedExecutionPayloadEnvelopeContents must be wire-compatible +// with. Gloas and Heze share the gloas view. +func signedExecutionPayloadEnvelopeContentsTests() []struct { + name string + version version.DataVersion + view *apiv1gloas.SignedExecutionPayloadEnvelopeContents +} { + return []struct { + name string + version version.DataVersion + view *apiv1gloas.SignedExecutionPayloadEnvelopeContents + }{ + { + name: "Gloas", + version: version.DataVersionGloas, + view: &apiv1gloas.SignedExecutionPayloadEnvelopeContents{ + SignedExecutionPayloadEnvelope: testGloasSignedExecutionPayloadEnvelope(), + KZGProofs: testKZGProofs(), + Blobs: testBlobs(), + }, + }, + { + name: "Heze", + version: version.DataVersionHeze, + view: &apiv1gloas.SignedExecutionPayloadEnvelopeContents{ + SignedExecutionPayloadEnvelope: testGloasSignedExecutionPayloadEnvelope(), + KZGProofs: testKZGProofs(), + Blobs: testBlobs(), + }, + }, + } +} + +// TestSignedExecutionPayloadEnvelopeContentsJSONWireCompat verifies that the +// agnostic type marshals to byte-identical JSON versus the per-fork type, +// and that JSON round-trips losslessly through the agnostic type. +func TestSignedExecutionPayloadEnvelopeContentsJSONWireCompat(t *testing.T) { + for _, test := range signedExecutionPayloadEnvelopeContentsTests() { + t.Run(test.name, func(t *testing.T) { + expected, err := json.Marshal(test.view) + require.NoError(t, err) + + agnostic := &apiv1all.SignedExecutionPayloadEnvelopeContents{Version: test.version} + require.NoError(t, agnostic.FromView(test.view)) + require.Equal(t, test.version, agnostic.Version) + + got, err := json.Marshal(agnostic) + require.NoError(t, err) + require.Equal(t, string(expected), string(got), + "agnostic JSON differs from per-fork JSON") + + // Round-trip through UnmarshalJSON with Version pre-set. + rt := &apiv1all.SignedExecutionPayloadEnvelopeContents{Version: test.version} + require.NoError(t, json.Unmarshal(expected, rt)) + + rtJSON, err := json.Marshal(rt) + require.NoError(t, err) + require.Equal(t, string(expected), string(rtJSON), + "round-tripped JSON differs from per-fork JSON") + + // Version must propagate to the nested versionable envelope. + require.NotNil(t, rt.SignedExecutionPayloadEnvelope) + require.Equal(t, test.version, rt.SignedExecutionPayloadEnvelope.Version) + require.NotNil(t, rt.SignedExecutionPayloadEnvelope.Message) + require.Equal(t, test.version, rt.SignedExecutionPayloadEnvelope.Message.Version) + }) + } +} + +// TestSignedExecutionPayloadEnvelopeContentsSSZWireCompat verifies that the +// agnostic type produces byte-identical SSZ and the same hash tree root as +// the per-fork type, and that SSZ round-trips losslessly through the +// agnostic type. +func TestSignedExecutionPayloadEnvelopeContentsSSZWireCompat(t *testing.T) { + for _, test := range signedExecutionPayloadEnvelopeContentsTests() { + t.Run(test.name, func(t *testing.T) { + expected, err := test.view.MarshalSSZ() + require.NoError(t, err) + + agnostic := &apiv1all.SignedExecutionPayloadEnvelopeContents{Version: test.version} + require.NoError(t, agnostic.FromView(test.view)) + + got, err := agnostic.MarshalSSZ() + require.NoError(t, err) + require.Equal(t, expected, got, "agnostic SSZ differs from per-fork SSZ") + + expectedRoot, err := test.view.HashTreeRoot() + require.NoError(t, err) + + gotRoot, err := agnostic.HashTreeRoot() + require.NoError(t, err) + require.Equal(t, expectedRoot, gotRoot, + "agnostic hash tree root differs from per-fork root") + + // Round-trip through UnmarshalSSZ with Version pre-set. + rt := &apiv1all.SignedExecutionPayloadEnvelopeContents{Version: test.version} + require.NoError(t, rt.UnmarshalSSZ(expected)) + + rtSSZ, err := rt.MarshalSSZ() + require.NoError(t, err) + require.Equal(t, expected, rtSSZ, + "round-tripped SSZ differs from per-fork SSZ") + + // Version must propagate to the nested versionable envelope. + require.NotNil(t, rt.SignedExecutionPayloadEnvelope) + require.Equal(t, test.version, rt.SignedExecutionPayloadEnvelope.Version) + }) + } +} diff --git a/api/v1/all/versionedproposal.go b/api/v1/all/versionedproposal.go new file mode 100644 index 00000000..326a3285 --- /dev/null +++ b/api/v1/all/versionedproposal.go @@ -0,0 +1,82 @@ +// Copyright © 2026 Attestant Limited. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package all + +import ( + "errors" + "fmt" + + "github.com/ethpandaops/go-eth2-client/api" + "github.com/ethpandaops/go-eth2-client/spec/all" + "github.com/ethpandaops/go-eth2-client/spec/bellatrix" + "github.com/ethpandaops/go-eth2-client/spec/capella" + "github.com/ethpandaops/go-eth2-client/spec/gloas" + "github.com/ethpandaops/go-eth2-client/spec/version" +) + +// ProposalFromSignedBlock wraps a signed beacon block into the versioned +// signed proposal consumed by the block submission API, for the forks whose +// proposals are bare blocks: +// - Bellatrix/Capella: pre-blobs, the block is the whole proposal. +// - Gloas onwards: EIP-7732 separates the execution payload (and its +// blobs) from the block, so there is no block-contents wrapper. +// +// Deneb through Fulu proposals carry blobs alongside the block and are +// rejected here — use SignedBlockContents.ToVersioned for those. +func ProposalFromSignedBlock(block *all.SignedBeaconBlock) (*api.VersionedSignedProposal, error) { + if block == nil { + return nil, errors.New("ProposalFromSignedBlock: nil block") + } + + view, err := block.ToView() + if err != nil { + return nil, err + } + + proposal := &api.VersionedSignedProposal{ + Version: block.Version, + } + + switch block.Version { + case version.DataVersionBellatrix: + bellatrixBlock, ok := view.(*bellatrix.SignedBeaconBlock) + if !ok { + return nil, fmt.Errorf("ProposalFromSignedBlock: unexpected view type %T for %s", view, block.Version) + } + + proposal.Bellatrix = bellatrixBlock + case version.DataVersionCapella: + capellaBlock, ok := view.(*capella.SignedBeaconBlock) + if !ok { + return nil, fmt.Errorf("ProposalFromSignedBlock: unexpected view type %T for %s", view, block.Version) + } + + proposal.Capella = capellaBlock + case version.DataVersionGloas, version.DataVersionHeze: + gloasBlock, ok := view.(*gloas.SignedBeaconBlock) + if !ok { + return nil, fmt.Errorf("ProposalFromSignedBlock: unexpected view type %T for %s", view, block.Version) + } + + if block.Version == version.DataVersionHeze { + proposal.Heze = gloasBlock + } else { + proposal.Gloas = gloasBlock + } + default: + return nil, fmt.Errorf("ProposalFromSignedBlock: unsupported version %s", block.Version) + } + + return proposal, nil +} diff --git a/api/v1/all/versionedproposal_test.go b/api/v1/all/versionedproposal_test.go new file mode 100644 index 00000000..ca546068 --- /dev/null +++ b/api/v1/all/versionedproposal_test.go @@ -0,0 +1,164 @@ +// Copyright © 2026 Attestant Limited. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package all_test + +import ( + "testing" + + apiv1all "github.com/ethpandaops/go-eth2-client/api/v1/all" + "github.com/ethpandaops/go-eth2-client/spec/all" + "github.com/ethpandaops/go-eth2-client/spec/bellatrix" + "github.com/ethpandaops/go-eth2-client/spec/capella" + "github.com/ethpandaops/go-eth2-client/spec/gloas" + "github.com/ethpandaops/go-eth2-client/spec/phase0" + "github.com/ethpandaops/go-eth2-client/spec/version" + "github.com/stretchr/testify/require" +) + +// testGloasSignedBeaconBlock builds a minimal gloas signed beacon block. +func testGloasSignedBeaconBlock() *gloas.SignedBeaconBlock { + return &gloas.SignedBeaconBlock{ + Message: &gloas.BeaconBlock{ + Slot: 12345, + ProposerIndex: 42, + ParentRoot: phase0.Root{0x01}, + StateRoot: phase0.Root{0x02}, + Body: &gloas.BeaconBlockBody{ + RANDAOReveal: phase0.BLSSignature{0x03}, + Graffiti: [32]byte{0x04}, + }, + }, + Signature: phase0.BLSSignature{0x05}, + } +} + +// TestProposalFromSignedBlock verifies the bare-block-to-proposal mapping for +// post-Gloas forks: the block lands in the field matching its version, with +// no blinded flag and no other fields set. +func TestProposalFromSignedBlock(t *testing.T) { + tests := []struct { + name string + version version.DataVersion + }{ + {name: "gloas", version: version.DataVersionGloas}, + {name: "heze", version: version.DataVersionHeze}, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + view := testGloasSignedBeaconBlock() + + block := &all.SignedBeaconBlock{Version: test.version} + require.NoError(t, block.FromView(view)) + block.Version = test.version + + proposal, err := apiv1all.ProposalFromSignedBlock(block) + require.NoError(t, err) + require.Equal(t, test.version, proposal.Version) + require.False(t, proposal.Blinded) + + switch test.version { + case version.DataVersionGloas: + require.NotNil(t, proposal.Gloas) + require.Nil(t, proposal.Heze) + require.Equal(t, view, proposal.Gloas) + case version.DataVersionHeze: + require.NotNil(t, proposal.Heze) + require.Nil(t, proposal.Gloas) + require.Equal(t, view, proposal.Heze) + default: + t.Fatalf("unexpected version %s", test.version) + } + }) + } +} + +// TestProposalFromSignedBlockPreDeneb verifies the bare-block-to-proposal +// mapping for the pre-blobs forks: bellatrix and capella proposals are plain +// signed beacon blocks. +func TestProposalFromSignedBlockPreDeneb(t *testing.T) { + t.Run("bellatrix", func(t *testing.T) { + view := &bellatrix.SignedBeaconBlock{ + Message: &bellatrix.BeaconBlock{ + Slot: 123, + ProposerIndex: 7, + ParentRoot: phase0.Root{0x01}, + StateRoot: phase0.Root{0x02}, + Body: &bellatrix.BeaconBlockBody{ + RANDAOReveal: phase0.BLSSignature{0x03}, + Graffiti: [32]byte{0x04}, + ExecutionPayload: &bellatrix.ExecutionPayload{BlockNumber: 9}, + }, + }, + Signature: phase0.BLSSignature{0x05}, + } + + block := &all.SignedBeaconBlock{Version: version.DataVersionBellatrix} + require.NoError(t, block.FromView(view)) + + proposal, err := apiv1all.ProposalFromSignedBlock(block) + require.NoError(t, err) + require.Equal(t, version.DataVersionBellatrix, proposal.Version) + require.False(t, proposal.Blinded) + require.NotNil(t, proposal.Bellatrix) + require.Nil(t, proposal.Capella) + require.Equal(t, view, proposal.Bellatrix) + }) + + t.Run("capella", func(t *testing.T) { + view := &capella.SignedBeaconBlock{ + Message: &capella.BeaconBlock{ + Slot: 456, + ProposerIndex: 8, + ParentRoot: phase0.Root{0x11}, + StateRoot: phase0.Root{0x12}, + Body: &capella.BeaconBlockBody{ + RANDAOReveal: phase0.BLSSignature{0x13}, + Graffiti: [32]byte{0x14}, + ExecutionPayload: &capella.ExecutionPayload{BlockNumber: 10}, + }, + }, + Signature: phase0.BLSSignature{0x15}, + } + + block := &all.SignedBeaconBlock{Version: version.DataVersionCapella} + require.NoError(t, block.FromView(view)) + + proposal, err := apiv1all.ProposalFromSignedBlock(block) + require.NoError(t, err) + require.Equal(t, version.DataVersionCapella, proposal.Version) + require.False(t, proposal.Blinded) + require.NotNil(t, proposal.Capella) + require.Nil(t, proposal.Bellatrix) + require.Equal(t, view, proposal.Capella) + }) +} + +// TestProposalFromSignedBlockUnsupportedVersion verifies blob-carrying +// versions (Deneb through Fulu) are rejected: those forks submit +// SignedBlockContents, not bare blocks. +func TestProposalFromSignedBlockUnsupportedVersion(t *testing.T) { + for _, v := range []version.DataVersion{ + version.DataVersionDeneb, + version.DataVersionElectra, + version.DataVersionFulu, + } { + block := &all.SignedBeaconBlock{Version: v} + _, err := apiv1all.ProposalFromSignedBlock(block) + require.ErrorContains(t, err, "unsupported version", "version %s", v) + } + + _, err := apiv1all.ProposalFromSignedBlock(nil) + require.ErrorContains(t, err, "nil block") +} diff --git a/api/v1/gloas/generate.go b/api/v1/gloas/generate.go new file mode 100644 index 00000000..b3dc2440 --- /dev/null +++ b/api/v1/gloas/generate.go @@ -0,0 +1,17 @@ +// Copyright © 2026 Attestant Limited. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package gloas + +//go:generate rm -f *_ssz.go +//go:generate go tool dynssz-gen -config generate.yaml diff --git a/api/v1/gloas/generate.yaml b/api/v1/gloas/generate.yaml new file mode 100644 index 00000000..afca147b --- /dev/null +++ b/api/v1/gloas/generate.yaml @@ -0,0 +1,7 @@ +package: . +legacy: true +without-dynamic-expressions: true + +types: + - name: SignedExecutionPayloadEnvelopeContents + output: signedexecutionpayloadenvelopecontents_ssz.go diff --git a/api/v1/gloas/signedexecutionpayloadenvelopecontents.go b/api/v1/gloas/signedexecutionpayloadenvelopecontents.go new file mode 100644 index 00000000..8c75ae85 --- /dev/null +++ b/api/v1/gloas/signedexecutionpayloadenvelopecontents.go @@ -0,0 +1,43 @@ +// Copyright © 2026 Attestant Limited. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package gloas + +import ( + "fmt" + + "github.com/ethpandaops/go-eth2-client/spec/deneb" + "github.com/ethpandaops/go-eth2-client/spec/gloas" + "github.com/goccy/go-yaml" +) + +// SignedExecutionPayloadEnvelopeContents is the stateless request body for +// publishing an execution payload envelope: the signed envelope together with +// the blobs and KZG cell proofs the beacon node needs to build data column +// sidecars when it has none cached from its own block production. +type SignedExecutionPayloadEnvelopeContents struct { + SignedExecutionPayloadEnvelope *gloas.SignedExecutionPayloadEnvelope + + KZGProofs []deneb.KZGProof `dynssz-max:"FIELD_ELEMENTS_PER_EXT_BLOB*MAX_BLOB_COMMITMENTS_PER_BLOCK" ssz-max:"33554432" ssz-size:"?,48"` + Blobs []deneb.Blob `dynssz-max:"MAX_BLOB_COMMITMENTS_PER_BLOCK" ssz-max:"4096" ssz-size:"?,131072"` +} + +// String returns a string version of the structure. +func (s *SignedExecutionPayloadEnvelopeContents) String() string { + data, err := yaml.Marshal(s) + if err != nil { + return fmt.Sprintf("ERR: %v", err) + } + + return string(data) +} diff --git a/api/v1/gloas/signedexecutionpayloadenvelopecontents_json.go b/api/v1/gloas/signedexecutionpayloadenvelopecontents_json.go new file mode 100644 index 00000000..2651d85a --- /dev/null +++ b/api/v1/gloas/signedexecutionpayloadenvelopecontents_json.go @@ -0,0 +1,61 @@ +// Copyright © 2026 Attestant Limited. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package gloas + +import ( + "encoding/json" + + "github.com/ethpandaops/go-eth2-client/codecs" + "github.com/ethpandaops/go-eth2-client/spec/deneb" + "github.com/ethpandaops/go-eth2-client/spec/gloas" + "github.com/pkg/errors" +) + +// signedExecutionPayloadEnvelopeContentsJSON is the spec representation of the struct. +type signedExecutionPayloadEnvelopeContentsJSON struct { + SignedExecutionPayloadEnvelope *gloas.SignedExecutionPayloadEnvelope `json:"signed_execution_payload_envelope"` + KZGProofs []deneb.KZGProof `json:"kzg_proofs"` + Blobs []deneb.Blob `json:"blobs"` +} + +// MarshalJSON implements json.Marshaler. +func (s *SignedExecutionPayloadEnvelopeContents) MarshalJSON() ([]byte, error) { + return json.Marshal(&signedExecutionPayloadEnvelopeContentsJSON{ + SignedExecutionPayloadEnvelope: s.SignedExecutionPayloadEnvelope, + KZGProofs: s.KZGProofs, + Blobs: s.Blobs, + }) +} + +// UnmarshalJSON implements json.Unmarshaler. +func (s *SignedExecutionPayloadEnvelopeContents) UnmarshalJSON(input []byte) error { + raw, err := codecs.RawJSON(&signedExecutionPayloadEnvelopeContentsJSON{}, input) + if err != nil { + return err + } + + if err := json.Unmarshal(raw["signed_execution_payload_envelope"], &s.SignedExecutionPayloadEnvelope); err != nil { + return errors.Wrap(err, "signed_execution_payload_envelope") + } + + if err := json.Unmarshal(raw["kzg_proofs"], &s.KZGProofs); err != nil { + return errors.Wrap(err, "kzg_proofs") + } + + if err := json.Unmarshal(raw["blobs"], &s.Blobs); err != nil { + return errors.Wrap(err, "blobs") + } + + return nil +} diff --git a/api/v1/gloas/signedexecutionpayloadenvelopecontents_ssz.go b/api/v1/gloas/signedexecutionpayloadenvelopecontents_ssz.go new file mode 100644 index 00000000..b5caab41 --- /dev/null +++ b/api/v1/gloas/signedexecutionpayloadenvelopecontents_ssz.go @@ -0,0 +1,208 @@ +// Code generated by dynamic-ssz. DO NOT EDIT. +// Hash: 6ecdc0cd698d484e3ac1a42f7662ed752495c6d7df4a01f4ecc524385b0f31d9 +// Version: v1.3.2 (https://github.com/pk910/dynamic-ssz) +package gloas + +import ( + "encoding/binary" + + "github.com/ethpandaops/go-eth2-client/spec/gloas" + dynssz "github.com/pk910/dynamic-ssz" + "github.com/pk910/dynamic-ssz/hasher" + "github.com/pk910/dynamic-ssz/sszutils" +) + +var _ = sszutils.ErrListTooBig + +var _ = sszutils.Annotate[SignedExecutionPayloadEnvelopeContents](`ssz-static:"false"`) + +// MarshalSSZ marshals the *SignedExecutionPayloadEnvelopeContents to SSZ-encoded bytes. +func (t *SignedExecutionPayloadEnvelopeContents) MarshalSSZ() ([]byte, error) { + return dynssz.GetGlobalDynSsz().MarshalSSZ(t) +} + +// MarshalSSZTo marshals the *SignedExecutionPayloadEnvelopeContents to SSZ-encoded bytes, appending to the provided buffer. +func (t *SignedExecutionPayloadEnvelopeContents) MarshalSSZTo(buf []byte) (dst []byte, err error) { + dst = buf + zeroBytes := sszutils.ZeroBytes() + if t == nil { + t = new(SignedExecutionPayloadEnvelopeContents) + } + dstlen := len(dst) + // Offset Field #0 'SignedExecutionPayloadEnvelope' + // Offset Field #1 'KZGProofs' + // Offset Field #2 'Blobs' + dst = append(dst, zeroBytes[:12]...) + { // Dynamic Field #0 'SignedExecutionPayloadEnvelope' + binary.LittleEndian.PutUint32(dst[dstlen:], uint32(len(dst)-dstlen)) + t := t.SignedExecutionPayloadEnvelope + if t == nil { + t = new(gloas.SignedExecutionPayloadEnvelope) + } + if dst, err = t.MarshalSSZTo(dst); err != nil { + return nil, sszutils.ErrorWithPath(err, "SignedExecutionPayloadEnvelope") + } + } + { // Dynamic Field #1 'KZGProofs' + binary.LittleEndian.PutUint32(dst[dstlen+4:], uint32(len(dst)-dstlen)) + t := t.KZGProofs + vlen := len(t) + if vlen > 33554432 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 33554432), "KZGProofs") + } + dst = sszutils.MarshalFixedBytesSlice(dst, t[:vlen]) + } + { // Dynamic Field #2 'Blobs' + binary.LittleEndian.PutUint32(dst[dstlen+8:], uint32(len(dst)-dstlen)) + t := t.Blobs + vlen := len(t) + if vlen > 4096 { + return nil, sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 4096), "Blobs") + } + dst = sszutils.MarshalFixedBytesSlice(dst, t[:vlen]) + } + return dst, nil +} + +// UnmarshalSSZ unmarshals the *SignedExecutionPayloadEnvelopeContents from SSZ-encoded bytes. +func (t *SignedExecutionPayloadEnvelopeContents) UnmarshalSSZ(buf []byte) (err error) { + buflen := len(buf) + if buflen < 12 { + return sszutils.ErrFixedFieldsEOFFn(buflen, 12) + } + // Field #0 'SignedExecutionPayloadEnvelope' (offset) + offset0 := int(binary.LittleEndian.Uint32(buf[0:4])) + if offset0 != 12 { + return sszutils.ErrorWithPath(sszutils.ErrFirstOffsetMismatchFn(offset0, 12), "SignedExecutionPayloadEnvelope:o") + } + // Field #1 'KZGProofs' (offset) + offset1 := int(binary.LittleEndian.Uint32(buf[4:8])) + if offset1 < offset0 || offset1 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset1, offset0, buflen), "KZGProofs:o") + } + // Field #2 'Blobs' (offset) + offset2 := int(binary.LittleEndian.Uint32(buf[8:12])) + if offset2 < offset1 || offset2 > buflen { + return sszutils.ErrorWithPath(sszutils.ErrOffsetOutOfRangeFn(offset2, offset1, buflen), "Blobs:o") + } + { // Field #0 'SignedExecutionPayloadEnvelope' (dynamic) + buf := buf[offset0:offset1] + if t.SignedExecutionPayloadEnvelope == nil { + t.SignedExecutionPayloadEnvelope = new(gloas.SignedExecutionPayloadEnvelope) + } + if err = t.SignedExecutionPayloadEnvelope.UnmarshalSSZ(buf); err != nil { + return sszutils.ErrorWithPath(err, "SignedExecutionPayloadEnvelope") + } + } + { // Field #1 'KZGProofs' (dynamic) + buf := buf[offset1:offset2] + val1 := t.KZGProofs + itemCount := len(buf) / 48 + if len(buf)%48 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 48), "KZGProofs") + } + if itemCount > 33554432 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 33554432), "KZGProofs") + } + val1 = sszutils.ExpandSlice(val1, itemCount) + sszutils.UnmarshalFixedBytesSlice(val1[:itemCount], buf) + t.KZGProofs = val1 + } + { // Field #2 'Blobs' (dynamic) + buf := buf[offset2:] + val2 := t.Blobs + itemCount := len(buf) / 131072 + if len(buf)%131072 != 0 { + return sszutils.ErrorWithPath(sszutils.ErrListNotAlignedFn(len(buf), 131072), "Blobs") + } + if itemCount > 4096 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(itemCount, 4096), "Blobs") + } + val2 = sszutils.ExpandSlice(val2, itemCount) + sszutils.UnmarshalFixedBytesSlice(val2[:itemCount], buf) + t.Blobs = val2 + } + return nil +} + +// SizeSSZ returns the SSZ encoded size of the *SignedExecutionPayloadEnvelopeContents. +func (t *SignedExecutionPayloadEnvelopeContents) SizeSSZ() (size int) { + if t == nil { + t = new(SignedExecutionPayloadEnvelopeContents) + } + // Field #0 'SignedExecutionPayloadEnvelope' offset (4 bytes) + // Field #1 'KZGProofs' offset (4 bytes) + // Field #2 'Blobs' offset (4 bytes) + size += 12 + { // Dynamic field #0 'SignedExecutionPayloadEnvelope' + size += t.SignedExecutionPayloadEnvelope.SizeSSZ() + } + { // Dynamic field #1 'KZGProofs' + size += len(t.KZGProofs) * 48 + } + { // Dynamic field #2 'Blobs' + size += len(t.Blobs) * 131072 + } + return size +} + +// HashTreeRoot computes the SSZ hash tree root of the *SignedExecutionPayloadEnvelopeContents. +func (t *SignedExecutionPayloadEnvelopeContents) HashTreeRoot() (root [32]byte, err error) { + err = hasher.WithDefaultHasher(func(hh sszutils.HashWalker) (err error) { + err = t.HashTreeRootWith(hh) + if err == nil { + root, err = hh.HashRoot() + } + return + }) + return +} + +// HashTreeRootWith computes the SSZ hash tree root of the *SignedExecutionPayloadEnvelopeContents using the given hash walker. +func (t *SignedExecutionPayloadEnvelopeContents) HashTreeRootWith(hh sszutils.HashWalker) error { + if t == nil { + t = new(SignedExecutionPayloadEnvelopeContents) + } + idx := hh.StartTree(sszutils.TreeTypeNone) + { // Field #0 'SignedExecutionPayloadEnvelope' + t := t.SignedExecutionPayloadEnvelope + if t == nil { + t = new(gloas.SignedExecutionPayloadEnvelope) + } + if err := t.HashTreeRootWith(hh); err != nil { + return sszutils.ErrorWithPath(err, "SignedExecutionPayloadEnvelope") + } + } + { // Field #1 'KZGProofs' + t := t.KZGProofs + vlen := uint64(len(t)) + if vlen > 33554432 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 33554432), "KZGProofs") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + hh.PutBytes(t[idx1][:48]) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(33554432, vlen, 32)) + } + { // Field #2 'Blobs' + t := t.Blobs + vlen := uint64(len(t)) + if vlen > 4096 { + return sszutils.ErrorWithPath(sszutils.ErrListLengthFn(vlen, 4096), "Blobs") + } + idx := hh.StartTree(sszutils.TreeTypeBinary) + for idx1 := range int(vlen) { + hh.PutBytes(t[idx1][:131072]) + if (idx1+1)%256 == 0 { + hh.Collapse() + } + } + hh.MerkleizeWithMixin(idx, vlen, sszutils.CalculateLimit(4096, vlen, 32)) + } + hh.Merkleize(idx) + return nil +} diff --git a/api/v1/gloas/signedexecutionpayloadenvelopecontents_yaml.go b/api/v1/gloas/signedexecutionpayloadenvelopecontents_yaml.go new file mode 100644 index 00000000..ddb3179e --- /dev/null +++ b/api/v1/gloas/signedexecutionpayloadenvelopecontents_yaml.go @@ -0,0 +1,61 @@ +// Copyright © 2026 Attestant Limited. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package gloas + +import ( + "bytes" + "encoding/json" + + "github.com/ethpandaops/go-eth2-client/spec/deneb" + "github.com/ethpandaops/go-eth2-client/spec/gloas" + "github.com/goccy/go-yaml" + "github.com/pkg/errors" +) + +// signedExecutionPayloadEnvelopeContentsYAML is the spec representation of the struct. +type signedExecutionPayloadEnvelopeContentsYAML struct { + SignedExecutionPayloadEnvelope *gloas.SignedExecutionPayloadEnvelope `yaml:"signed_execution_payload_envelope"` + KZGProofs []deneb.KZGProof `yaml:"kzg_proofs"` + Blobs []deneb.Blob `yaml:"blobs"` +} + +// MarshalYAML implements yaml.Marshaler. +func (s *SignedExecutionPayloadEnvelopeContents) MarshalYAML() ([]byte, error) { + yamlBytes, err := yaml.MarshalWithOptions(&signedExecutionPayloadEnvelopeContentsYAML{ + SignedExecutionPayloadEnvelope: s.SignedExecutionPayloadEnvelope, + KZGProofs: s.KZGProofs, + Blobs: s.Blobs, + }, yaml.Flow(true)) + if err != nil { + return nil, err + } + + return bytes.ReplaceAll(yamlBytes, []byte(`"`), []byte(`'`)), nil +} + +// UnmarshalYAML implements yaml.Unmarshaler. +func (s *SignedExecutionPayloadEnvelopeContents) UnmarshalYAML(input []byte) error { + // We unmarshal to the JSON struct to save on duplicate code. + var unmarshaled signedExecutionPayloadEnvelopeContentsJSON + if err := yaml.Unmarshal(input, &unmarshaled); err != nil { + return errors.Wrap(err, "failed to unmarshal YAML") + } + + marshaled, err := json.Marshal(unmarshaled) + if err != nil { + return errors.Wrap(err, "failed to marshal JSON") + } + + return s.UnmarshalJSON(marshaled) +} diff --git a/api/v1/nodeidentity.go b/api/v1/nodeidentity.go new file mode 100644 index 00000000..a184500a --- /dev/null +++ b/api/v1/nodeidentity.go @@ -0,0 +1,53 @@ +// Copyright © 2026 Attestant Limited. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package v1 + +import ( + "fmt" +) + +// NodeIdentity contains the node's network identity. +type NodeIdentity struct { + // PeerID is the node's libp2p peer ID. + PeerID string `json:"peer_id"` + // ENR is the node's Ethereum node record. + ENR string `json:"enr"` + // P2PAddresses are the multiaddrs on which eth2 RPC requests are served. + P2PAddresses []string `json:"p2p_addresses"` + // DiscoveryAddresses are the multiaddrs on which the node listens for + // discv5 requests. + DiscoveryAddresses []string `json:"discovery_addresses"` + // Metadata is the node's libp2p metadata. + Metadata NodeIdentityMetadata `json:"metadata"` +} + +// NodeIdentityMetadata is the node's libp2p metadata. +type NodeIdentityMetadata struct { + // SeqNumber versions the node's metadata (decimal string). + SeqNumber string `json:"seq_number"` + // Attnets is the hex bitvector of persistent attestation subnet + // subscriptions. + Attnets string `json:"attnets"` + // Syncnets is the hex bitvector of sync committee subnet subscriptions + // (Altair onwards). + Syncnets string `json:"syncnets,omitempty"` + // CustodyGroupCount is the node's custody group count (Fulu onwards, + // decimal string). + CustodyGroupCount string `json:"custody_group_count,omitempty"` +} + +// String returns a string version of the structure. +func (n *NodeIdentity) String() string { + return fmt.Sprintf("%s %v", n.PeerID, n.P2PAddresses) +} diff --git a/http/nodeidentity.go b/http/nodeidentity.go new file mode 100644 index 00000000..2b3c2d24 --- /dev/null +++ b/http/nodeidentity.go @@ -0,0 +1,61 @@ +// Copyright © 2026 Attestant Limited. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package http + +import ( + "bytes" + "context" + "fmt" + + client "github.com/ethpandaops/go-eth2-client" + "github.com/ethpandaops/go-eth2-client/api" + apiv1 "github.com/ethpandaops/go-eth2-client/api/v1" +) + +// NodeIdentity obtains the node's network identity. +func (s *Service) NodeIdentity(ctx context.Context, + opts *api.NodeIdentityOpts, +) ( + *api.Response[*apiv1.NodeIdentity], + error, +) { + if err := s.assertIsActive(ctx); err != nil { + return nil, err + } + + if opts == nil { + return nil, client.ErrNoOptions + } + + endpoint := "/eth/v1/node/identity" + + httpResponse, err := s.get(ctx, endpoint, "", &opts.Common, false) + if err != nil { + return nil, err + } + + if httpResponse.contentType != ContentTypeJSON { + return nil, fmt.Errorf("unexpected content type %v (expected JSON)", httpResponse.contentType) + } + + data, meta, err := decodeJSONResponse(bytes.NewReader(httpResponse.body), &apiv1.NodeIdentity{}) + if err != nil { + return nil, err + } + + return &api.Response[*apiv1.NodeIdentity]{ + Data: data, + Metadata: meta, + }, nil +} diff --git a/http/submitexecutionpayloadbid.go b/http/submitexecutionpayloadbid.go new file mode 100644 index 00000000..c9605a81 --- /dev/null +++ b/http/submitexecutionpayloadbid.go @@ -0,0 +1,140 @@ +// Copyright © 2026 Attestant Limited. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package http + +import ( + "bytes" + "context" + "encoding/json" + "errors" + "fmt" + "strings" + + client "github.com/ethpandaops/go-eth2-client" + "github.com/ethpandaops/go-eth2-client/api" + "github.com/ethpandaops/go-eth2-client/spec" +) + +// SubmitExecutionPayloadBid submits a signed execution payload bid for +// gossip broadcast. +func (s *Service) SubmitExecutionPayloadBid(ctx context.Context, + opts *api.SubmitExecutionPayloadBidOpts, +) error { + if err := s.assertIsSynced(ctx); err != nil { + return err + } + + if opts == nil { + return client.ErrNoOptions + } + + if opts.SignedExecutionPayloadBid == nil { + return errors.Join(errors.New("no bid supplied"), client.ErrInvalidOptions) + } + + versioned := opts.SignedExecutionPayloadBid + + var bid any + + switch versioned.Version { + case spec.DataVersionGloas: + if versioned.Gloas == nil { + return errors.Join(errors.New("no gloas bid supplied"), client.ErrInvalidOptions) + } + + bid = versioned.Gloas + case spec.DataVersionHeze: + if versioned.Heze == nil { + return errors.Join(errors.New("no heze bid supplied"), client.ErrInvalidOptions) + } + + bid = versioned.Heze + default: + return errors.Join( + fmt.Errorf("unsupported bid version %s", versioned.Version), + client.ErrInvalidOptions, + ) + } + + return s.postExecutionPayloadBid(ctx, &opts.Common, versioned.Version, bid) +} + +// SubmitAgnosticExecutionPayloadBid submits a signed execution payload bid +// supplied as a fork-agnostic *all.SignedExecutionPayloadBid for gossip +// broadcast. +func (s *Service) SubmitAgnosticExecutionPayloadBid(ctx context.Context, + opts *api.SubmitAgnosticExecutionPayloadBidOpts, +) error { + if err := s.assertIsSynced(ctx); err != nil { + return err + } + + if opts == nil { + return client.ErrNoOptions + } + + if opts.SignedExecutionPayloadBid == nil { + return errors.Join(errors.New("no bid supplied"), client.ErrInvalidOptions) + } + + return s.postExecutionPayloadBid(ctx, &opts.Common, + opts.SignedExecutionPayloadBid.Version, opts.SignedExecutionPayloadBid) +} + +// postExecutionPayloadBid marshals the bid to the negotiated content type +// (SSZ unless JSON is enforced) and performs the POST shared by both submit +// variants. +func (s *Service) postExecutionPayloadBid(ctx context.Context, + common *api.CommonOpts, + consensusVersion spec.DataVersion, + bid any, +) error { + var ( + body []byte + contentType ContentType + err error + ) + + if s.enforceJSON { + contentType = ContentTypeJSON + + body, err = json.Marshal(bid) + if err != nil { + return errors.Join(errors.New("failed to marshal JSON"), err) + } + } else { + contentType = ContentTypeSSZ + + ds, dsErr := s.dynSSZForRequest(ctx) + if dsErr != nil { + return dsErr + } + + body, err = ds.MarshalSSZ(bid) + if err != nil { + return errors.Join(errors.New("failed to marshal SSZ"), err) + } + } + + endpoint := "/eth/v1/beacon/execution_payload_bids" + + headers := make(map[string]string) + headers["Eth-Consensus-Version"] = strings.ToLower(consensusVersion.String()) + + if _, err := s.post(ctx, endpoint, "", common, bytes.NewBuffer(body), contentType, headers); err != nil { + return errors.Join(errors.New("failed to submit execution payload bid"), err) + } + + return nil +} diff --git a/http/submitexecutionpayloadenvelope.go b/http/submitexecutionpayloadenvelope.go new file mode 100644 index 00000000..71c8cc8c --- /dev/null +++ b/http/submitexecutionpayloadenvelope.go @@ -0,0 +1,202 @@ +// Copyright © 2026 Attestant Limited. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package http + +import ( + "bytes" + "context" + "encoding/json" + "errors" + "fmt" + "strings" + + client "github.com/ethpandaops/go-eth2-client" + "github.com/ethpandaops/go-eth2-client/api" + apiv1all "github.com/ethpandaops/go-eth2-client/api/v1/all" + apiv1gloas "github.com/ethpandaops/go-eth2-client/api/v1/gloas" + apiv2 "github.com/ethpandaops/go-eth2-client/api/v2" + "github.com/ethpandaops/go-eth2-client/spec" + "github.com/ethpandaops/go-eth2-client/spec/deneb" +) + +// SubmitExecutionPayloadEnvelope submits a signed execution payload envelope +// using the stateless request form: a SignedExecutionPayloadEnvelopeContents +// body (signed envelope plus blobs and KZG proofs) with the +// Eth-Execution-Payload-Blinded header set to false. The stateful/blinded +// form only works when the beacon node cached the full envelope from its own +// block production, so builders publishing externally-built payloads must use +// the stateless form. +func (s *Service) SubmitExecutionPayloadEnvelope(ctx context.Context, + opts *api.SubmitExecutionPayloadEnvelopeOpts, +) error { + if err := s.assertIsSynced(ctx); err != nil { + return err + } + + if opts == nil { + return client.ErrNoOptions + } + + if opts.SignedExecutionPayloadEnvelope == nil { + return errors.Join(errors.New("no envelope supplied"), client.ErrInvalidOptions) + } + + versioned := opts.SignedExecutionPayloadEnvelope + + var contents any + + switch versioned.Version { + case spec.DataVersionGloas, spec.DataVersionHeze: + // All current envelope-bearing forks (Gloas, Heze) reuse the gloas schema. + if versioned.Gloas == nil { + return errors.Join(errors.New("no gloas envelope supplied"), client.ErrInvalidOptions) + } + + contents = &apiv1gloas.SignedExecutionPayloadEnvelopeContents{ + SignedExecutionPayloadEnvelope: versioned.Gloas, + KZGProofs: nonNilKZGProofs(opts.KZGProofs), + Blobs: nonNilBlobs(opts.Blobs), + } + default: + return errors.Join( + fmt.Errorf("unsupported envelope version %s", versioned.Version), + client.ErrInvalidOptions, + ) + } + + body, contentType, err := s.submitExecutionPayloadEnvelopeData(ctx, contents) + if err != nil { + return err + } + + return s.postExecutionPayloadEnvelope(ctx, &opts.Common, versioned.Version, + opts.BroadcastValidation, body, contentType) +} + +// SubmitAgnosticExecutionPayloadEnvelope submits a signed execution payload +// envelope supplied as a fork-agnostic *all.SignedExecutionPayloadEnvelope, +// using the same stateless request form as SubmitExecutionPayloadEnvelope. +func (s *Service) SubmitAgnosticExecutionPayloadEnvelope(ctx context.Context, + opts *api.SubmitAgnosticExecutionPayloadEnvelopeOpts, +) error { + if err := s.assertIsSynced(ctx); err != nil { + return err + } + + if opts == nil { + return client.ErrNoOptions + } + + if opts.SignedExecutionPayloadEnvelope == nil { + return errors.Join(errors.New("no envelope supplied"), client.ErrInvalidOptions) + } + + contents := &apiv1all.SignedExecutionPayloadEnvelopeContents{ + Version: opts.SignedExecutionPayloadEnvelope.Version, + SignedExecutionPayloadEnvelope: opts.SignedExecutionPayloadEnvelope, + KZGProofs: nonNilKZGProofs(opts.KZGProofs), + Blobs: nonNilBlobs(opts.Blobs), + } + + body, contentType, err := s.submitExecutionPayloadEnvelopeData(ctx, contents) + if err != nil { + return err + } + + return s.postExecutionPayloadEnvelope(ctx, &opts.Common, contents.Version, + opts.BroadcastValidation, body, contentType) +} + +// postExecutionPayloadEnvelope performs the POST shared by both submit +// variants, setting the consensus version and stateless-form headers. +func (s *Service) postExecutionPayloadEnvelope(ctx context.Context, + common *api.CommonOpts, + consensusVersion spec.DataVersion, + broadcastValidation *apiv2.BroadcastValidation, + body []byte, + contentType ContentType, +) error { + endpoint := "/eth/v1/beacon/execution_payload_envelopes" + + query := "" + if broadcastValidation != nil { + query = "broadcast_validation=" + broadcastValidation.String() + } + + headers := make(map[string]string) + headers["Eth-Consensus-Version"] = strings.ToLower(consensusVersion.String()) + // Always the stateless form: header "false" selects the Contents body + // schema. Strict consensus clients reject the request when the header is + // missing. + headers["Eth-Execution-Payload-Blinded"] = "false" + + if _, err := s.post(ctx, endpoint, query, common, bytes.NewBuffer(body), contentType, headers); err != nil { + return errors.Join(errors.New("failed to submit execution payload envelope"), err) + } + + return nil +} + +// submitExecutionPayloadEnvelopeData marshals the envelope contents to the +// negotiated content type (SSZ unless JSON is enforced). +func (s *Service) submitExecutionPayloadEnvelopeData(ctx context.Context, + contents any, +) ( + []byte, + ContentType, + error, +) { + if s.enforceJSON { + body, err := json.Marshal(contents) + if err != nil { + return nil, ContentTypeUnknown, errors.Join(errors.New("failed to marshal JSON"), err) + } + + return body, ContentTypeJSON, nil + } + + ds, err := s.dynSSZForRequest(ctx) + if err != nil { + return nil, ContentTypeUnknown, err + } + + body, err := ds.MarshalSSZ(contents) + if err != nil { + return nil, ContentTypeUnknown, errors.Join(errors.New("failed to marshal SSZ"), err) + } + + return body, ContentTypeSSZ, nil +} + +// nonNilKZGProofs normalises a nil KZG proof slice to an empty one: the +// beacon-API schema requires kzg_proofs to be present (as an empty array +// when the payload carries no blobs). +func nonNilKZGProofs(proofs []deneb.KZGProof) []deneb.KZGProof { + if proofs == nil { + return []deneb.KZGProof{} + } + + return proofs +} + +// nonNilBlobs normalises a nil blob slice to an empty one: the beacon-API +// schema requires blobs to be present (as an empty array when the payload +// carries no blobs). +func nonNilBlobs(blobs []deneb.Blob) []deneb.Blob { + if blobs == nil { + return []deneb.Blob{} + } + + return blobs +} diff --git a/mock/nodeidentity.go b/mock/nodeidentity.go new file mode 100644 index 00000000..c633e8c3 --- /dev/null +++ b/mock/nodeidentity.go @@ -0,0 +1,34 @@ +// Copyright © 2026 Attestant Limited. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package mock + +import ( + "context" + + "github.com/ethpandaops/go-eth2-client/api" + apiv1 "github.com/ethpandaops/go-eth2-client/api/v1" +) + +// NodeIdentity provides the node's network identity. +func (*Service) NodeIdentity(_ context.Context, _ *api.NodeIdentityOpts) (*api.Response[*apiv1.NodeIdentity], error) { + return &api.Response[*apiv1.NodeIdentity]{ + Data: &apiv1.NodeIdentity{ + PeerID: "16Uiu2HAm8maLMjag1TAUM52zPfmLbVMGFdwUAWgoHu1HDQLR6e17", + ENR: "enr:-", + P2PAddresses: []string{}, + DiscoveryAddresses: []string{}, + }, + Metadata: make(map[string]any), + }, nil +} diff --git a/mock/submitexecutionpayloadbid.go b/mock/submitexecutionpayloadbid.go new file mode 100644 index 00000000..ae9f28dc --- /dev/null +++ b/mock/submitexecutionpayloadbid.go @@ -0,0 +1,30 @@ +// Copyright © 2026 Attestant Limited. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package mock + +import ( + "context" + + "github.com/ethpandaops/go-eth2-client/api" +) + +// SubmitExecutionPayloadBid submits an execution payload bid. +func (*Service) SubmitExecutionPayloadBid(_ context.Context, _ *api.SubmitExecutionPayloadBidOpts) error { + return nil +} + +// SubmitAgnosticExecutionPayloadBid submits a fork-agnostic execution payload bid. +func (*Service) SubmitAgnosticExecutionPayloadBid(_ context.Context, _ *api.SubmitAgnosticExecutionPayloadBidOpts) error { + return nil +} diff --git a/mock/submitexecutionpayloadenvelope.go b/mock/submitexecutionpayloadenvelope.go new file mode 100644 index 00000000..923eaf07 --- /dev/null +++ b/mock/submitexecutionpayloadenvelope.go @@ -0,0 +1,30 @@ +// Copyright © 2026 Attestant Limited. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package mock + +import ( + "context" + + "github.com/ethpandaops/go-eth2-client/api" +) + +// SubmitExecutionPayloadEnvelope submits an execution payload envelope. +func (*Service) SubmitExecutionPayloadEnvelope(_ context.Context, _ *api.SubmitExecutionPayloadEnvelopeOpts) error { + return nil +} + +// SubmitAgnosticExecutionPayloadEnvelope submits a fork-agnostic execution payload envelope. +func (*Service) SubmitAgnosticExecutionPayloadEnvelope(_ context.Context, _ *api.SubmitAgnosticExecutionPayloadEnvelopeOpts) error { + return nil +} diff --git a/multi/nodeidentity.go b/multi/nodeidentity.go new file mode 100644 index 00000000..6efe15aa --- /dev/null +++ b/multi/nodeidentity.go @@ -0,0 +1,49 @@ +// Copyright © 2026 Attestant Limited. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package multi + +import ( + "context" + + consensusclient "github.com/ethpandaops/go-eth2-client" + "github.com/ethpandaops/go-eth2-client/api" + apiv1 "github.com/ethpandaops/go-eth2-client/api/v1" +) + +// NodeIdentity provides the node's network identity. +func (s *Service) NodeIdentity(ctx context.Context, + opts *api.NodeIdentityOpts, +) ( + *api.Response[*apiv1.NodeIdentity], + error, +) { + res, err := s.doCall(ctx, func(ctx context.Context, client consensusclient.Service) (any, error) { + identity, err := client.(consensusclient.NodeIdentityProvider).NodeIdentity(ctx, opts) + if err != nil { + return nil, err + } + + return identity, nil + }, nil) + if err != nil { + return nil, err + } + + response, isResponse := res.(*api.Response[*apiv1.NodeIdentity]) + if !isResponse { + return nil, ErrIncorrectType + } + + return response, nil +} diff --git a/multi/submitexecutionpayloadbid.go b/multi/submitexecutionpayloadbid.go new file mode 100644 index 00000000..7831286d --- /dev/null +++ b/multi/submitexecutionpayloadbid.go @@ -0,0 +1,53 @@ +// Copyright © 2026 Attestant Limited. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package multi + +import ( + "context" + + consensusclient "github.com/ethpandaops/go-eth2-client" + "github.com/ethpandaops/go-eth2-client/api" +) + +// SubmitExecutionPayloadBid submits an execution payload bid. +func (s *Service) SubmitExecutionPayloadBid(ctx context.Context, + opts *api.SubmitExecutionPayloadBidOpts, +) error { + _, err := s.doCall(ctx, func(ctx context.Context, client consensusclient.Service) (any, error) { + err := client.(consensusclient.ExecutionPayloadBidSubmitter).SubmitExecutionPayloadBid(ctx, opts) + if err != nil { + return nil, err + } + + return true, nil + }, nil) + + return err +} + +// SubmitAgnosticExecutionPayloadBid submits a fork-agnostic execution payload bid. +func (s *Service) SubmitAgnosticExecutionPayloadBid(ctx context.Context, + opts *api.SubmitAgnosticExecutionPayloadBidOpts, +) error { + _, err := s.doCall(ctx, func(ctx context.Context, client consensusclient.Service) (any, error) { + err := client.(consensusclient.ExecutionPayloadBidSubmitter).SubmitAgnosticExecutionPayloadBid(ctx, opts) + if err != nil { + return nil, err + } + + return true, nil + }, nil) + + return err +} diff --git a/multi/submitexecutionpayloadenvelope.go b/multi/submitexecutionpayloadenvelope.go new file mode 100644 index 00000000..15a10c75 --- /dev/null +++ b/multi/submitexecutionpayloadenvelope.go @@ -0,0 +1,53 @@ +// Copyright © 2026 Attestant Limited. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package multi + +import ( + "context" + + consensusclient "github.com/ethpandaops/go-eth2-client" + "github.com/ethpandaops/go-eth2-client/api" +) + +// SubmitExecutionPayloadEnvelope submits an execution payload envelope. +func (s *Service) SubmitExecutionPayloadEnvelope(ctx context.Context, + opts *api.SubmitExecutionPayloadEnvelopeOpts, +) error { + _, err := s.doCall(ctx, func(ctx context.Context, client consensusclient.Service) (any, error) { + err := client.(consensusclient.ExecutionPayloadEnvelopeSubmitter).SubmitExecutionPayloadEnvelope(ctx, opts) + if err != nil { + return nil, err + } + + return true, nil + }, nil) + + return err +} + +// SubmitAgnosticExecutionPayloadEnvelope submits a fork-agnostic execution payload envelope. +func (s *Service) SubmitAgnosticExecutionPayloadEnvelope(ctx context.Context, + opts *api.SubmitAgnosticExecutionPayloadEnvelopeOpts, +) error { + _, err := s.doCall(ctx, func(ctx context.Context, client consensusclient.Service) (any, error) { + err := client.(consensusclient.ExecutionPayloadEnvelopeSubmitter).SubmitAgnosticExecutionPayloadEnvelope(ctx, opts) + if err != nil { + return nil, err + } + + return true, nil + }, nil) + + return err +} diff --git a/service.go b/service.go index 73ac7aab..a94ee79c 100644 --- a/service.go +++ b/service.go @@ -521,6 +521,17 @@ type GenesisProvider interface { ) } +// NodeIdentityProvider is the interface for providing the node's network identity. +type NodeIdentityProvider interface { + // NodeIdentity provides the node's network identity. + NodeIdentity(ctx context.Context, + opts *api.NodeIdentityOpts, + ) ( + *api.Response[*apiv1.NodeIdentity], + error, + ) +} + // NodePeersProvider is the interface for providing peer information. type NodePeersProvider interface { // NodePeers provides the peers of the node. @@ -664,6 +675,41 @@ type ExecutionPayloadProvider interface { ) } +// ExecutionPayloadEnvelopeSubmitter is the interface for submitting execution +// payload envelopes. +type ExecutionPayloadEnvelopeSubmitter interface { + // SubmitExecutionPayloadEnvelope submits a signed execution payload + // envelope (with its blobs and KZG proofs) for broadcast. + SubmitExecutionPayloadEnvelope(ctx context.Context, + opts *api.SubmitExecutionPayloadEnvelopeOpts, + ) error + + // SubmitAgnosticExecutionPayloadEnvelope submits a signed execution + // payload envelope supplied as a fork-agnostic + // *all.SignedExecutionPayloadEnvelope (with its blobs and KZG proofs) + // for broadcast. + SubmitAgnosticExecutionPayloadEnvelope(ctx context.Context, + opts *api.SubmitAgnosticExecutionPayloadEnvelopeOpts, + ) error +} + +// ExecutionPayloadBidSubmitter is the interface for submitting execution +// payload bids. +type ExecutionPayloadBidSubmitter interface { + // SubmitExecutionPayloadBid submits a signed execution payload bid for + // gossip broadcast. + SubmitExecutionPayloadBid(ctx context.Context, + opts *api.SubmitExecutionPayloadBidOpts, + ) error + + // SubmitAgnosticExecutionPayloadBid submits a signed execution payload + // bid supplied as a fork-agnostic *all.SignedExecutionPayloadBid for + // gossip broadcast. + SubmitAgnosticExecutionPayloadBid(ctx context.Context, + opts *api.SubmitAgnosticExecutionPayloadBidOpts, + ) error +} + // PendingDepositProvider is the interface for providing pending deposit information. type PendingDepositProvider interface { // PendingDeposits provides the pending deposits for a given state. diff --git a/spec/all/executionpayloadheader.go b/spec/all/executionpayloadheader.go index e5e5fe50..e809fbf8 100644 --- a/spec/all/executionpayloadheader.go +++ b/spec/all/executionpayloadheader.go @@ -60,7 +60,11 @@ func (e *ExecutionPayloadHeader) viewType() (any, error) { return (*bellatrix.ExecutionPayloadHeader)(nil), nil case version.DataVersionCapella: return (*capella.ExecutionPayloadHeader)(nil), nil - case version.DataVersionDeneb: + case version.DataVersionDeneb, + version.DataVersionElectra, + version.DataVersionFulu: + // Electra and Fulu reuse the Deneb execution-payload-header schema + // unchanged (matching the ExecutionPayload multiplexer). return (*deneb.ExecutionPayloadHeader)(nil), nil default: return nil, fmt.Errorf("ExecutionPayloadHeader: unsupported version %d", e.Version)