mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-23 03:51:29 +00:00
12ba8f3645
* rename proto * p header * regen * regen ssz * fix randao * random name changes * bazel builds * bt * incorrect prev randao Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
8291 lines
187 KiB
Go
8291 lines
187 KiB
Go
// Code generated by fastssz. DO NOT EDIT.
|
|
// Hash: 342009e14499c97e5b523e1d7e879dbf6958487ebed52cd1332874420149a0a5
|
|
package eth
|
|
|
|
import (
|
|
ssz "github.com/ferranbt/fastssz"
|
|
github_com_prysmaticlabs_eth2_types "github.com/prysmaticlabs/eth2-types"
|
|
v1 "github.com/prysmaticlabs/prysm/proto/engine/v1"
|
|
)
|
|
|
|
// MarshalSSZ ssz marshals the Attestation object
|
|
func (a *Attestation) MarshalSSZ() ([]byte, error) {
|
|
return ssz.MarshalSSZ(a)
|
|
}
|
|
|
|
// MarshalSSZTo ssz marshals the Attestation object to a target array
|
|
func (a *Attestation) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
|
dst = buf
|
|
offset := int(228)
|
|
|
|
// Offset (0) 'AggregationBits'
|
|
dst = ssz.WriteOffset(dst, offset)
|
|
offset += len(a.AggregationBits)
|
|
|
|
// Field (1) 'Data'
|
|
if a.Data == nil {
|
|
a.Data = new(AttestationData)
|
|
}
|
|
if dst, err = a.Data.MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
|
|
// Field (2) 'Signature'
|
|
if len(a.Signature) != 96 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, a.Signature...)
|
|
|
|
// Field (0) 'AggregationBits'
|
|
if len(a.AggregationBits) > 2048 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, a.AggregationBits...)
|
|
|
|
return
|
|
}
|
|
|
|
// UnmarshalSSZ ssz unmarshals the Attestation object
|
|
func (a *Attestation) UnmarshalSSZ(buf []byte) error {
|
|
var err error
|
|
size := uint64(len(buf))
|
|
if size < 228 {
|
|
return ssz.ErrSize
|
|
}
|
|
|
|
tail := buf
|
|
var o0 uint64
|
|
|
|
// Offset (0) 'AggregationBits'
|
|
if o0 = ssz.ReadOffset(buf[0:4]); o0 > size {
|
|
return ssz.ErrOffset
|
|
}
|
|
|
|
if o0 < 228 {
|
|
return ssz.ErrInvalidVariableOffset
|
|
}
|
|
|
|
// Field (1) 'Data'
|
|
if a.Data == nil {
|
|
a.Data = new(AttestationData)
|
|
}
|
|
if err = a.Data.UnmarshalSSZ(buf[4:132]); err != nil {
|
|
return err
|
|
}
|
|
|
|
// Field (2) 'Signature'
|
|
if cap(a.Signature) == 0 {
|
|
a.Signature = make([]byte, 0, len(buf[132:228]))
|
|
}
|
|
a.Signature = append(a.Signature, buf[132:228]...)
|
|
|
|
// Field (0) 'AggregationBits'
|
|
{
|
|
buf = tail[o0:]
|
|
if err = ssz.ValidateBitlist(buf, 2048); err != nil {
|
|
return err
|
|
}
|
|
if cap(a.AggregationBits) == 0 {
|
|
a.AggregationBits = make([]byte, 0, len(buf))
|
|
}
|
|
a.AggregationBits = append(a.AggregationBits, buf...)
|
|
}
|
|
return err
|
|
}
|
|
|
|
// SizeSSZ returns the ssz encoded size in bytes for the Attestation object
|
|
func (a *Attestation) SizeSSZ() (size int) {
|
|
size = 228
|
|
|
|
// Field (0) 'AggregationBits'
|
|
size += len(a.AggregationBits)
|
|
|
|
return
|
|
}
|
|
|
|
// HashTreeRoot ssz hashes the Attestation object
|
|
func (a *Attestation) HashTreeRoot() ([32]byte, error) {
|
|
return ssz.HashWithDefaultHasher(a)
|
|
}
|
|
|
|
// HashTreeRootWith ssz hashes the Attestation object with a hasher
|
|
func (a *Attestation) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|
indx := hh.Index()
|
|
|
|
// Field (0) 'AggregationBits'
|
|
if len(a.AggregationBits) == 0 {
|
|
err = ssz.ErrEmptyBitlist
|
|
return
|
|
}
|
|
hh.PutBitlist(a.AggregationBits, 2048)
|
|
|
|
// Field (1) 'Data'
|
|
if err = a.Data.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
|
|
// Field (2) 'Signature'
|
|
if len(a.Signature) != 96 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(a.Signature)
|
|
|
|
hh.Merkleize(indx)
|
|
return
|
|
}
|
|
|
|
// MarshalSSZ ssz marshals the AggregateAttestationAndProof object
|
|
func (a *AggregateAttestationAndProof) MarshalSSZ() ([]byte, error) {
|
|
return ssz.MarshalSSZ(a)
|
|
}
|
|
|
|
// MarshalSSZTo ssz marshals the AggregateAttestationAndProof object to a target array
|
|
func (a *AggregateAttestationAndProof) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
|
dst = buf
|
|
offset := int(108)
|
|
|
|
// Field (0) 'AggregatorIndex'
|
|
dst = ssz.MarshalUint64(dst, uint64(a.AggregatorIndex))
|
|
|
|
// Offset (1) 'Aggregate'
|
|
dst = ssz.WriteOffset(dst, offset)
|
|
if a.Aggregate == nil {
|
|
a.Aggregate = new(Attestation)
|
|
}
|
|
offset += a.Aggregate.SizeSSZ()
|
|
|
|
// Field (2) 'SelectionProof'
|
|
if len(a.SelectionProof) != 96 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, a.SelectionProof...)
|
|
|
|
// Field (1) 'Aggregate'
|
|
if dst, err = a.Aggregate.MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// UnmarshalSSZ ssz unmarshals the AggregateAttestationAndProof object
|
|
func (a *AggregateAttestationAndProof) UnmarshalSSZ(buf []byte) error {
|
|
var err error
|
|
size := uint64(len(buf))
|
|
if size < 108 {
|
|
return ssz.ErrSize
|
|
}
|
|
|
|
tail := buf
|
|
var o1 uint64
|
|
|
|
// Field (0) 'AggregatorIndex'
|
|
a.AggregatorIndex = github_com_prysmaticlabs_eth2_types.ValidatorIndex(ssz.UnmarshallUint64(buf[0:8]))
|
|
|
|
// Offset (1) 'Aggregate'
|
|
if o1 = ssz.ReadOffset(buf[8:12]); o1 > size {
|
|
return ssz.ErrOffset
|
|
}
|
|
|
|
if o1 < 108 {
|
|
return ssz.ErrInvalidVariableOffset
|
|
}
|
|
|
|
// Field (2) 'SelectionProof'
|
|
if cap(a.SelectionProof) == 0 {
|
|
a.SelectionProof = make([]byte, 0, len(buf[12:108]))
|
|
}
|
|
a.SelectionProof = append(a.SelectionProof, buf[12:108]...)
|
|
|
|
// Field (1) 'Aggregate'
|
|
{
|
|
buf = tail[o1:]
|
|
if a.Aggregate == nil {
|
|
a.Aggregate = new(Attestation)
|
|
}
|
|
if err = a.Aggregate.UnmarshalSSZ(buf); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
return err
|
|
}
|
|
|
|
// SizeSSZ returns the ssz encoded size in bytes for the AggregateAttestationAndProof object
|
|
func (a *AggregateAttestationAndProof) SizeSSZ() (size int) {
|
|
size = 108
|
|
|
|
// Field (1) 'Aggregate'
|
|
if a.Aggregate == nil {
|
|
a.Aggregate = new(Attestation)
|
|
}
|
|
size += a.Aggregate.SizeSSZ()
|
|
|
|
return
|
|
}
|
|
|
|
// HashTreeRoot ssz hashes the AggregateAttestationAndProof object
|
|
func (a *AggregateAttestationAndProof) HashTreeRoot() ([32]byte, error) {
|
|
return ssz.HashWithDefaultHasher(a)
|
|
}
|
|
|
|
// HashTreeRootWith ssz hashes the AggregateAttestationAndProof object with a hasher
|
|
func (a *AggregateAttestationAndProof) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|
indx := hh.Index()
|
|
|
|
// Field (0) 'AggregatorIndex'
|
|
hh.PutUint64(uint64(a.AggregatorIndex))
|
|
|
|
// Field (1) 'Aggregate'
|
|
if err = a.Aggregate.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
|
|
// Field (2) 'SelectionProof'
|
|
if len(a.SelectionProof) != 96 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(a.SelectionProof)
|
|
|
|
hh.Merkleize(indx)
|
|
return
|
|
}
|
|
|
|
// MarshalSSZ ssz marshals the SignedAggregateAttestationAndProof object
|
|
func (s *SignedAggregateAttestationAndProof) MarshalSSZ() ([]byte, error) {
|
|
return ssz.MarshalSSZ(s)
|
|
}
|
|
|
|
// MarshalSSZTo ssz marshals the SignedAggregateAttestationAndProof object to a target array
|
|
func (s *SignedAggregateAttestationAndProof) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
|
dst = buf
|
|
offset := int(100)
|
|
|
|
// Offset (0) 'Message'
|
|
dst = ssz.WriteOffset(dst, offset)
|
|
if s.Message == nil {
|
|
s.Message = new(AggregateAttestationAndProof)
|
|
}
|
|
offset += s.Message.SizeSSZ()
|
|
|
|
// Field (1) 'Signature'
|
|
if len(s.Signature) != 96 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, s.Signature...)
|
|
|
|
// Field (0) 'Message'
|
|
if dst, err = s.Message.MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// UnmarshalSSZ ssz unmarshals the SignedAggregateAttestationAndProof object
|
|
func (s *SignedAggregateAttestationAndProof) UnmarshalSSZ(buf []byte) error {
|
|
var err error
|
|
size := uint64(len(buf))
|
|
if size < 100 {
|
|
return ssz.ErrSize
|
|
}
|
|
|
|
tail := buf
|
|
var o0 uint64
|
|
|
|
// Offset (0) 'Message'
|
|
if o0 = ssz.ReadOffset(buf[0:4]); o0 > size {
|
|
return ssz.ErrOffset
|
|
}
|
|
|
|
if o0 < 100 {
|
|
return ssz.ErrInvalidVariableOffset
|
|
}
|
|
|
|
// Field (1) 'Signature'
|
|
if cap(s.Signature) == 0 {
|
|
s.Signature = make([]byte, 0, len(buf[4:100]))
|
|
}
|
|
s.Signature = append(s.Signature, buf[4:100]...)
|
|
|
|
// Field (0) 'Message'
|
|
{
|
|
buf = tail[o0:]
|
|
if s.Message == nil {
|
|
s.Message = new(AggregateAttestationAndProof)
|
|
}
|
|
if err = s.Message.UnmarshalSSZ(buf); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
return err
|
|
}
|
|
|
|
// SizeSSZ returns the ssz encoded size in bytes for the SignedAggregateAttestationAndProof object
|
|
func (s *SignedAggregateAttestationAndProof) SizeSSZ() (size int) {
|
|
size = 100
|
|
|
|
// Field (0) 'Message'
|
|
if s.Message == nil {
|
|
s.Message = new(AggregateAttestationAndProof)
|
|
}
|
|
size += s.Message.SizeSSZ()
|
|
|
|
return
|
|
}
|
|
|
|
// HashTreeRoot ssz hashes the SignedAggregateAttestationAndProof object
|
|
func (s *SignedAggregateAttestationAndProof) HashTreeRoot() ([32]byte, error) {
|
|
return ssz.HashWithDefaultHasher(s)
|
|
}
|
|
|
|
// HashTreeRootWith ssz hashes the SignedAggregateAttestationAndProof object with a hasher
|
|
func (s *SignedAggregateAttestationAndProof) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|
indx := hh.Index()
|
|
|
|
// Field (0) 'Message'
|
|
if err = s.Message.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
|
|
// Field (1) 'Signature'
|
|
if len(s.Signature) != 96 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(s.Signature)
|
|
|
|
hh.Merkleize(indx)
|
|
return
|
|
}
|
|
|
|
// MarshalSSZ ssz marshals the AttestationData object
|
|
func (a *AttestationData) MarshalSSZ() ([]byte, error) {
|
|
return ssz.MarshalSSZ(a)
|
|
}
|
|
|
|
// MarshalSSZTo ssz marshals the AttestationData object to a target array
|
|
func (a *AttestationData) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
|
dst = buf
|
|
|
|
// Field (0) 'Slot'
|
|
dst = ssz.MarshalUint64(dst, uint64(a.Slot))
|
|
|
|
// Field (1) 'CommitteeIndex'
|
|
dst = ssz.MarshalUint64(dst, uint64(a.CommitteeIndex))
|
|
|
|
// Field (2) 'BeaconBlockRoot'
|
|
if len(a.BeaconBlockRoot) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, a.BeaconBlockRoot...)
|
|
|
|
// Field (3) 'Source'
|
|
if a.Source == nil {
|
|
a.Source = new(Checkpoint)
|
|
}
|
|
if dst, err = a.Source.MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
|
|
// Field (4) 'Target'
|
|
if a.Target == nil {
|
|
a.Target = new(Checkpoint)
|
|
}
|
|
if dst, err = a.Target.MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// UnmarshalSSZ ssz unmarshals the AttestationData object
|
|
func (a *AttestationData) UnmarshalSSZ(buf []byte) error {
|
|
var err error
|
|
size := uint64(len(buf))
|
|
if size != 128 {
|
|
return ssz.ErrSize
|
|
}
|
|
|
|
// Field (0) 'Slot'
|
|
a.Slot = github_com_prysmaticlabs_eth2_types.Slot(ssz.UnmarshallUint64(buf[0:8]))
|
|
|
|
// Field (1) 'CommitteeIndex'
|
|
a.CommitteeIndex = github_com_prysmaticlabs_eth2_types.CommitteeIndex(ssz.UnmarshallUint64(buf[8:16]))
|
|
|
|
// Field (2) 'BeaconBlockRoot'
|
|
if cap(a.BeaconBlockRoot) == 0 {
|
|
a.BeaconBlockRoot = make([]byte, 0, len(buf[16:48]))
|
|
}
|
|
a.BeaconBlockRoot = append(a.BeaconBlockRoot, buf[16:48]...)
|
|
|
|
// Field (3) 'Source'
|
|
if a.Source == nil {
|
|
a.Source = new(Checkpoint)
|
|
}
|
|
if err = a.Source.UnmarshalSSZ(buf[48:88]); err != nil {
|
|
return err
|
|
}
|
|
|
|
// Field (4) 'Target'
|
|
if a.Target == nil {
|
|
a.Target = new(Checkpoint)
|
|
}
|
|
if err = a.Target.UnmarshalSSZ(buf[88:128]); err != nil {
|
|
return err
|
|
}
|
|
|
|
return err
|
|
}
|
|
|
|
// SizeSSZ returns the ssz encoded size in bytes for the AttestationData object
|
|
func (a *AttestationData) SizeSSZ() (size int) {
|
|
size = 128
|
|
return
|
|
}
|
|
|
|
// HashTreeRoot ssz hashes the AttestationData object
|
|
func (a *AttestationData) HashTreeRoot() ([32]byte, error) {
|
|
return ssz.HashWithDefaultHasher(a)
|
|
}
|
|
|
|
// HashTreeRootWith ssz hashes the AttestationData object with a hasher
|
|
func (a *AttestationData) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|
indx := hh.Index()
|
|
|
|
// Field (0) 'Slot'
|
|
hh.PutUint64(uint64(a.Slot))
|
|
|
|
// Field (1) 'CommitteeIndex'
|
|
hh.PutUint64(uint64(a.CommitteeIndex))
|
|
|
|
// Field (2) 'BeaconBlockRoot'
|
|
if len(a.BeaconBlockRoot) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(a.BeaconBlockRoot)
|
|
|
|
// Field (3) 'Source'
|
|
if err = a.Source.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
|
|
// Field (4) 'Target'
|
|
if err = a.Target.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
|
|
hh.Merkleize(indx)
|
|
return
|
|
}
|
|
|
|
// MarshalSSZ ssz marshals the Checkpoint object
|
|
func (c *Checkpoint) MarshalSSZ() ([]byte, error) {
|
|
return ssz.MarshalSSZ(c)
|
|
}
|
|
|
|
// MarshalSSZTo ssz marshals the Checkpoint object to a target array
|
|
func (c *Checkpoint) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
|
dst = buf
|
|
|
|
// Field (0) 'Epoch'
|
|
dst = ssz.MarshalUint64(dst, uint64(c.Epoch))
|
|
|
|
// Field (1) 'Root'
|
|
if len(c.Root) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, c.Root...)
|
|
|
|
return
|
|
}
|
|
|
|
// UnmarshalSSZ ssz unmarshals the Checkpoint object
|
|
func (c *Checkpoint) UnmarshalSSZ(buf []byte) error {
|
|
var err error
|
|
size := uint64(len(buf))
|
|
if size != 40 {
|
|
return ssz.ErrSize
|
|
}
|
|
|
|
// Field (0) 'Epoch'
|
|
c.Epoch = github_com_prysmaticlabs_eth2_types.Epoch(ssz.UnmarshallUint64(buf[0:8]))
|
|
|
|
// Field (1) 'Root'
|
|
if cap(c.Root) == 0 {
|
|
c.Root = make([]byte, 0, len(buf[8:40]))
|
|
}
|
|
c.Root = append(c.Root, buf[8:40]...)
|
|
|
|
return err
|
|
}
|
|
|
|
// SizeSSZ returns the ssz encoded size in bytes for the Checkpoint object
|
|
func (c *Checkpoint) SizeSSZ() (size int) {
|
|
size = 40
|
|
return
|
|
}
|
|
|
|
// HashTreeRoot ssz hashes the Checkpoint object
|
|
func (c *Checkpoint) HashTreeRoot() ([32]byte, error) {
|
|
return ssz.HashWithDefaultHasher(c)
|
|
}
|
|
|
|
// HashTreeRootWith ssz hashes the Checkpoint object with a hasher
|
|
func (c *Checkpoint) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|
indx := hh.Index()
|
|
|
|
// Field (0) 'Epoch'
|
|
hh.PutUint64(uint64(c.Epoch))
|
|
|
|
// Field (1) 'Root'
|
|
if len(c.Root) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(c.Root)
|
|
|
|
hh.Merkleize(indx)
|
|
return
|
|
}
|
|
|
|
// MarshalSSZ ssz marshals the BeaconBlock object
|
|
func (b *BeaconBlock) MarshalSSZ() ([]byte, error) {
|
|
return ssz.MarshalSSZ(b)
|
|
}
|
|
|
|
// MarshalSSZTo ssz marshals the BeaconBlock object to a target array
|
|
func (b *BeaconBlock) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
|
dst = buf
|
|
offset := int(84)
|
|
|
|
// Field (0) 'Slot'
|
|
dst = ssz.MarshalUint64(dst, uint64(b.Slot))
|
|
|
|
// Field (1) 'ProposerIndex'
|
|
dst = ssz.MarshalUint64(dst, uint64(b.ProposerIndex))
|
|
|
|
// Field (2) 'ParentRoot'
|
|
if len(b.ParentRoot) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, b.ParentRoot...)
|
|
|
|
// Field (3) 'StateRoot'
|
|
if len(b.StateRoot) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, b.StateRoot...)
|
|
|
|
// Offset (4) 'Body'
|
|
dst = ssz.WriteOffset(dst, offset)
|
|
if b.Body == nil {
|
|
b.Body = new(BeaconBlockBody)
|
|
}
|
|
offset += b.Body.SizeSSZ()
|
|
|
|
// Field (4) 'Body'
|
|
if dst, err = b.Body.MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// UnmarshalSSZ ssz unmarshals the BeaconBlock object
|
|
func (b *BeaconBlock) UnmarshalSSZ(buf []byte) error {
|
|
var err error
|
|
size := uint64(len(buf))
|
|
if size < 84 {
|
|
return ssz.ErrSize
|
|
}
|
|
|
|
tail := buf
|
|
var o4 uint64
|
|
|
|
// Field (0) 'Slot'
|
|
b.Slot = github_com_prysmaticlabs_eth2_types.Slot(ssz.UnmarshallUint64(buf[0:8]))
|
|
|
|
// Field (1) 'ProposerIndex'
|
|
b.ProposerIndex = github_com_prysmaticlabs_eth2_types.ValidatorIndex(ssz.UnmarshallUint64(buf[8:16]))
|
|
|
|
// Field (2) 'ParentRoot'
|
|
if cap(b.ParentRoot) == 0 {
|
|
b.ParentRoot = make([]byte, 0, len(buf[16:48]))
|
|
}
|
|
b.ParentRoot = append(b.ParentRoot, buf[16:48]...)
|
|
|
|
// Field (3) 'StateRoot'
|
|
if cap(b.StateRoot) == 0 {
|
|
b.StateRoot = make([]byte, 0, len(buf[48:80]))
|
|
}
|
|
b.StateRoot = append(b.StateRoot, buf[48:80]...)
|
|
|
|
// Offset (4) 'Body'
|
|
if o4 = ssz.ReadOffset(buf[80:84]); o4 > size {
|
|
return ssz.ErrOffset
|
|
}
|
|
|
|
if o4 < 84 {
|
|
return ssz.ErrInvalidVariableOffset
|
|
}
|
|
|
|
// Field (4) 'Body'
|
|
{
|
|
buf = tail[o4:]
|
|
if b.Body == nil {
|
|
b.Body = new(BeaconBlockBody)
|
|
}
|
|
if err = b.Body.UnmarshalSSZ(buf); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
return err
|
|
}
|
|
|
|
// SizeSSZ returns the ssz encoded size in bytes for the BeaconBlock object
|
|
func (b *BeaconBlock) SizeSSZ() (size int) {
|
|
size = 84
|
|
|
|
// Field (4) 'Body'
|
|
if b.Body == nil {
|
|
b.Body = new(BeaconBlockBody)
|
|
}
|
|
size += b.Body.SizeSSZ()
|
|
|
|
return
|
|
}
|
|
|
|
// HashTreeRoot ssz hashes the BeaconBlock object
|
|
func (b *BeaconBlock) HashTreeRoot() ([32]byte, error) {
|
|
return ssz.HashWithDefaultHasher(b)
|
|
}
|
|
|
|
// HashTreeRootWith ssz hashes the BeaconBlock object with a hasher
|
|
func (b *BeaconBlock) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|
indx := hh.Index()
|
|
|
|
// Field (0) 'Slot'
|
|
hh.PutUint64(uint64(b.Slot))
|
|
|
|
// Field (1) 'ProposerIndex'
|
|
hh.PutUint64(uint64(b.ProposerIndex))
|
|
|
|
// Field (2) 'ParentRoot'
|
|
if len(b.ParentRoot) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(b.ParentRoot)
|
|
|
|
// Field (3) 'StateRoot'
|
|
if len(b.StateRoot) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(b.StateRoot)
|
|
|
|
// Field (4) 'Body'
|
|
if err = b.Body.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
|
|
hh.Merkleize(indx)
|
|
return
|
|
}
|
|
|
|
// MarshalSSZ ssz marshals the SignedBeaconBlock object
|
|
func (s *SignedBeaconBlock) MarshalSSZ() ([]byte, error) {
|
|
return ssz.MarshalSSZ(s)
|
|
}
|
|
|
|
// MarshalSSZTo ssz marshals the SignedBeaconBlock object to a target array
|
|
func (s *SignedBeaconBlock) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
|
dst = buf
|
|
offset := int(100)
|
|
|
|
// Offset (0) 'Block'
|
|
dst = ssz.WriteOffset(dst, offset)
|
|
if s.Block == nil {
|
|
s.Block = new(BeaconBlock)
|
|
}
|
|
offset += s.Block.SizeSSZ()
|
|
|
|
// Field (1) 'Signature'
|
|
if len(s.Signature) != 96 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, s.Signature...)
|
|
|
|
// Field (0) 'Block'
|
|
if dst, err = s.Block.MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// UnmarshalSSZ ssz unmarshals the SignedBeaconBlock object
|
|
func (s *SignedBeaconBlock) UnmarshalSSZ(buf []byte) error {
|
|
var err error
|
|
size := uint64(len(buf))
|
|
if size < 100 {
|
|
return ssz.ErrSize
|
|
}
|
|
|
|
tail := buf
|
|
var o0 uint64
|
|
|
|
// Offset (0) 'Block'
|
|
if o0 = ssz.ReadOffset(buf[0:4]); o0 > size {
|
|
return ssz.ErrOffset
|
|
}
|
|
|
|
if o0 < 100 {
|
|
return ssz.ErrInvalidVariableOffset
|
|
}
|
|
|
|
// Field (1) 'Signature'
|
|
if cap(s.Signature) == 0 {
|
|
s.Signature = make([]byte, 0, len(buf[4:100]))
|
|
}
|
|
s.Signature = append(s.Signature, buf[4:100]...)
|
|
|
|
// Field (0) 'Block'
|
|
{
|
|
buf = tail[o0:]
|
|
if s.Block == nil {
|
|
s.Block = new(BeaconBlock)
|
|
}
|
|
if err = s.Block.UnmarshalSSZ(buf); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
return err
|
|
}
|
|
|
|
// SizeSSZ returns the ssz encoded size in bytes for the SignedBeaconBlock object
|
|
func (s *SignedBeaconBlock) SizeSSZ() (size int) {
|
|
size = 100
|
|
|
|
// Field (0) 'Block'
|
|
if s.Block == nil {
|
|
s.Block = new(BeaconBlock)
|
|
}
|
|
size += s.Block.SizeSSZ()
|
|
|
|
return
|
|
}
|
|
|
|
// HashTreeRoot ssz hashes the SignedBeaconBlock object
|
|
func (s *SignedBeaconBlock) HashTreeRoot() ([32]byte, error) {
|
|
return ssz.HashWithDefaultHasher(s)
|
|
}
|
|
|
|
// HashTreeRootWith ssz hashes the SignedBeaconBlock object with a hasher
|
|
func (s *SignedBeaconBlock) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|
indx := hh.Index()
|
|
|
|
// Field (0) 'Block'
|
|
if err = s.Block.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
|
|
// Field (1) 'Signature'
|
|
if len(s.Signature) != 96 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(s.Signature)
|
|
|
|
hh.Merkleize(indx)
|
|
return
|
|
}
|
|
|
|
// MarshalSSZ ssz marshals the BeaconBlockAltair object
|
|
func (b *BeaconBlockAltair) MarshalSSZ() ([]byte, error) {
|
|
return ssz.MarshalSSZ(b)
|
|
}
|
|
|
|
// MarshalSSZTo ssz marshals the BeaconBlockAltair object to a target array
|
|
func (b *BeaconBlockAltair) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
|
dst = buf
|
|
offset := int(84)
|
|
|
|
// Field (0) 'Slot'
|
|
dst = ssz.MarshalUint64(dst, uint64(b.Slot))
|
|
|
|
// Field (1) 'ProposerIndex'
|
|
dst = ssz.MarshalUint64(dst, uint64(b.ProposerIndex))
|
|
|
|
// Field (2) 'ParentRoot'
|
|
if len(b.ParentRoot) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, b.ParentRoot...)
|
|
|
|
// Field (3) 'StateRoot'
|
|
if len(b.StateRoot) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, b.StateRoot...)
|
|
|
|
// Offset (4) 'Body'
|
|
dst = ssz.WriteOffset(dst, offset)
|
|
if b.Body == nil {
|
|
b.Body = new(BeaconBlockBodyAltair)
|
|
}
|
|
offset += b.Body.SizeSSZ()
|
|
|
|
// Field (4) 'Body'
|
|
if dst, err = b.Body.MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// UnmarshalSSZ ssz unmarshals the BeaconBlockAltair object
|
|
func (b *BeaconBlockAltair) UnmarshalSSZ(buf []byte) error {
|
|
var err error
|
|
size := uint64(len(buf))
|
|
if size < 84 {
|
|
return ssz.ErrSize
|
|
}
|
|
|
|
tail := buf
|
|
var o4 uint64
|
|
|
|
// Field (0) 'Slot'
|
|
b.Slot = github_com_prysmaticlabs_eth2_types.Slot(ssz.UnmarshallUint64(buf[0:8]))
|
|
|
|
// Field (1) 'ProposerIndex'
|
|
b.ProposerIndex = github_com_prysmaticlabs_eth2_types.ValidatorIndex(ssz.UnmarshallUint64(buf[8:16]))
|
|
|
|
// Field (2) 'ParentRoot'
|
|
if cap(b.ParentRoot) == 0 {
|
|
b.ParentRoot = make([]byte, 0, len(buf[16:48]))
|
|
}
|
|
b.ParentRoot = append(b.ParentRoot, buf[16:48]...)
|
|
|
|
// Field (3) 'StateRoot'
|
|
if cap(b.StateRoot) == 0 {
|
|
b.StateRoot = make([]byte, 0, len(buf[48:80]))
|
|
}
|
|
b.StateRoot = append(b.StateRoot, buf[48:80]...)
|
|
|
|
// Offset (4) 'Body'
|
|
if o4 = ssz.ReadOffset(buf[80:84]); o4 > size {
|
|
return ssz.ErrOffset
|
|
}
|
|
|
|
if o4 < 84 {
|
|
return ssz.ErrInvalidVariableOffset
|
|
}
|
|
|
|
// Field (4) 'Body'
|
|
{
|
|
buf = tail[o4:]
|
|
if b.Body == nil {
|
|
b.Body = new(BeaconBlockBodyAltair)
|
|
}
|
|
if err = b.Body.UnmarshalSSZ(buf); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
return err
|
|
}
|
|
|
|
// SizeSSZ returns the ssz encoded size in bytes for the BeaconBlockAltair object
|
|
func (b *BeaconBlockAltair) SizeSSZ() (size int) {
|
|
size = 84
|
|
|
|
// Field (4) 'Body'
|
|
if b.Body == nil {
|
|
b.Body = new(BeaconBlockBodyAltair)
|
|
}
|
|
size += b.Body.SizeSSZ()
|
|
|
|
return
|
|
}
|
|
|
|
// HashTreeRoot ssz hashes the BeaconBlockAltair object
|
|
func (b *BeaconBlockAltair) HashTreeRoot() ([32]byte, error) {
|
|
return ssz.HashWithDefaultHasher(b)
|
|
}
|
|
|
|
// HashTreeRootWith ssz hashes the BeaconBlockAltair object with a hasher
|
|
func (b *BeaconBlockAltair) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|
indx := hh.Index()
|
|
|
|
// Field (0) 'Slot'
|
|
hh.PutUint64(uint64(b.Slot))
|
|
|
|
// Field (1) 'ProposerIndex'
|
|
hh.PutUint64(uint64(b.ProposerIndex))
|
|
|
|
// Field (2) 'ParentRoot'
|
|
if len(b.ParentRoot) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(b.ParentRoot)
|
|
|
|
// Field (3) 'StateRoot'
|
|
if len(b.StateRoot) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(b.StateRoot)
|
|
|
|
// Field (4) 'Body'
|
|
if err = b.Body.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
|
|
hh.Merkleize(indx)
|
|
return
|
|
}
|
|
|
|
// MarshalSSZ ssz marshals the SignedBeaconBlockAltair object
|
|
func (s *SignedBeaconBlockAltair) MarshalSSZ() ([]byte, error) {
|
|
return ssz.MarshalSSZ(s)
|
|
}
|
|
|
|
// MarshalSSZTo ssz marshals the SignedBeaconBlockAltair object to a target array
|
|
func (s *SignedBeaconBlockAltair) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
|
dst = buf
|
|
offset := int(100)
|
|
|
|
// Offset (0) 'Block'
|
|
dst = ssz.WriteOffset(dst, offset)
|
|
if s.Block == nil {
|
|
s.Block = new(BeaconBlockAltair)
|
|
}
|
|
offset += s.Block.SizeSSZ()
|
|
|
|
// Field (1) 'Signature'
|
|
if len(s.Signature) != 96 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, s.Signature...)
|
|
|
|
// Field (0) 'Block'
|
|
if dst, err = s.Block.MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// UnmarshalSSZ ssz unmarshals the SignedBeaconBlockAltair object
|
|
func (s *SignedBeaconBlockAltair) UnmarshalSSZ(buf []byte) error {
|
|
var err error
|
|
size := uint64(len(buf))
|
|
if size < 100 {
|
|
return ssz.ErrSize
|
|
}
|
|
|
|
tail := buf
|
|
var o0 uint64
|
|
|
|
// Offset (0) 'Block'
|
|
if o0 = ssz.ReadOffset(buf[0:4]); o0 > size {
|
|
return ssz.ErrOffset
|
|
}
|
|
|
|
if o0 < 100 {
|
|
return ssz.ErrInvalidVariableOffset
|
|
}
|
|
|
|
// Field (1) 'Signature'
|
|
if cap(s.Signature) == 0 {
|
|
s.Signature = make([]byte, 0, len(buf[4:100]))
|
|
}
|
|
s.Signature = append(s.Signature, buf[4:100]...)
|
|
|
|
// Field (0) 'Block'
|
|
{
|
|
buf = tail[o0:]
|
|
if s.Block == nil {
|
|
s.Block = new(BeaconBlockAltair)
|
|
}
|
|
if err = s.Block.UnmarshalSSZ(buf); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
return err
|
|
}
|
|
|
|
// SizeSSZ returns the ssz encoded size in bytes for the SignedBeaconBlockAltair object
|
|
func (s *SignedBeaconBlockAltair) SizeSSZ() (size int) {
|
|
size = 100
|
|
|
|
// Field (0) 'Block'
|
|
if s.Block == nil {
|
|
s.Block = new(BeaconBlockAltair)
|
|
}
|
|
size += s.Block.SizeSSZ()
|
|
|
|
return
|
|
}
|
|
|
|
// HashTreeRoot ssz hashes the SignedBeaconBlockAltair object
|
|
func (s *SignedBeaconBlockAltair) HashTreeRoot() ([32]byte, error) {
|
|
return ssz.HashWithDefaultHasher(s)
|
|
}
|
|
|
|
// HashTreeRootWith ssz hashes the SignedBeaconBlockAltair object with a hasher
|
|
func (s *SignedBeaconBlockAltair) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|
indx := hh.Index()
|
|
|
|
// Field (0) 'Block'
|
|
if err = s.Block.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
|
|
// Field (1) 'Signature'
|
|
if len(s.Signature) != 96 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(s.Signature)
|
|
|
|
hh.Merkleize(indx)
|
|
return
|
|
}
|
|
|
|
// MarshalSSZ ssz marshals the BeaconBlockBody object
|
|
func (b *BeaconBlockBody) MarshalSSZ() ([]byte, error) {
|
|
return ssz.MarshalSSZ(b)
|
|
}
|
|
|
|
// MarshalSSZTo ssz marshals the BeaconBlockBody object to a target array
|
|
func (b *BeaconBlockBody) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
|
dst = buf
|
|
offset := int(220)
|
|
|
|
// Field (0) 'RandaoReveal'
|
|
if len(b.RandaoReveal) != 96 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, b.RandaoReveal...)
|
|
|
|
// Field (1) 'Eth1Data'
|
|
if b.Eth1Data == nil {
|
|
b.Eth1Data = new(Eth1Data)
|
|
}
|
|
if dst, err = b.Eth1Data.MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
|
|
// Field (2) 'Graffiti'
|
|
if len(b.Graffiti) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, b.Graffiti...)
|
|
|
|
// Offset (3) 'ProposerSlashings'
|
|
dst = ssz.WriteOffset(dst, offset)
|
|
offset += len(b.ProposerSlashings) * 416
|
|
|
|
// Offset (4) 'AttesterSlashings'
|
|
dst = ssz.WriteOffset(dst, offset)
|
|
for ii := 0; ii < len(b.AttesterSlashings); ii++ {
|
|
offset += 4
|
|
offset += b.AttesterSlashings[ii].SizeSSZ()
|
|
}
|
|
|
|
// Offset (5) 'Attestations'
|
|
dst = ssz.WriteOffset(dst, offset)
|
|
for ii := 0; ii < len(b.Attestations); ii++ {
|
|
offset += 4
|
|
offset += b.Attestations[ii].SizeSSZ()
|
|
}
|
|
|
|
// Offset (6) 'Deposits'
|
|
dst = ssz.WriteOffset(dst, offset)
|
|
offset += len(b.Deposits) * 1240
|
|
|
|
// Offset (7) 'VoluntaryExits'
|
|
dst = ssz.WriteOffset(dst, offset)
|
|
offset += len(b.VoluntaryExits) * 112
|
|
|
|
// Field (3) 'ProposerSlashings'
|
|
if len(b.ProposerSlashings) > 16 {
|
|
err = ssz.ErrListTooBig
|
|
return
|
|
}
|
|
for ii := 0; ii < len(b.ProposerSlashings); ii++ {
|
|
if dst, err = b.ProposerSlashings[ii].MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
}
|
|
|
|
// Field (4) 'AttesterSlashings'
|
|
if len(b.AttesterSlashings) > 2 {
|
|
err = ssz.ErrListTooBig
|
|
return
|
|
}
|
|
{
|
|
offset = 4 * len(b.AttesterSlashings)
|
|
for ii := 0; ii < len(b.AttesterSlashings); ii++ {
|
|
dst = ssz.WriteOffset(dst, offset)
|
|
offset += b.AttesterSlashings[ii].SizeSSZ()
|
|
}
|
|
}
|
|
for ii := 0; ii < len(b.AttesterSlashings); ii++ {
|
|
if dst, err = b.AttesterSlashings[ii].MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
}
|
|
|
|
// Field (5) 'Attestations'
|
|
if len(b.Attestations) > 128 {
|
|
err = ssz.ErrListTooBig
|
|
return
|
|
}
|
|
{
|
|
offset = 4 * len(b.Attestations)
|
|
for ii := 0; ii < len(b.Attestations); ii++ {
|
|
dst = ssz.WriteOffset(dst, offset)
|
|
offset += b.Attestations[ii].SizeSSZ()
|
|
}
|
|
}
|
|
for ii := 0; ii < len(b.Attestations); ii++ {
|
|
if dst, err = b.Attestations[ii].MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
}
|
|
|
|
// Field (6) 'Deposits'
|
|
if len(b.Deposits) > 16 {
|
|
err = ssz.ErrListTooBig
|
|
return
|
|
}
|
|
for ii := 0; ii < len(b.Deposits); ii++ {
|
|
if dst, err = b.Deposits[ii].MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
}
|
|
|
|
// Field (7) 'VoluntaryExits'
|
|
if len(b.VoluntaryExits) > 16 {
|
|
err = ssz.ErrListTooBig
|
|
return
|
|
}
|
|
for ii := 0; ii < len(b.VoluntaryExits); ii++ {
|
|
if dst, err = b.VoluntaryExits[ii].MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// UnmarshalSSZ ssz unmarshals the BeaconBlockBody object
|
|
func (b *BeaconBlockBody) UnmarshalSSZ(buf []byte) error {
|
|
var err error
|
|
size := uint64(len(buf))
|
|
if size < 220 {
|
|
return ssz.ErrSize
|
|
}
|
|
|
|
tail := buf
|
|
var o3, o4, o5, o6, o7 uint64
|
|
|
|
// Field (0) 'RandaoReveal'
|
|
if cap(b.RandaoReveal) == 0 {
|
|
b.RandaoReveal = make([]byte, 0, len(buf[0:96]))
|
|
}
|
|
b.RandaoReveal = append(b.RandaoReveal, buf[0:96]...)
|
|
|
|
// Field (1) 'Eth1Data'
|
|
if b.Eth1Data == nil {
|
|
b.Eth1Data = new(Eth1Data)
|
|
}
|
|
if err = b.Eth1Data.UnmarshalSSZ(buf[96:168]); err != nil {
|
|
return err
|
|
}
|
|
|
|
// Field (2) 'Graffiti'
|
|
if cap(b.Graffiti) == 0 {
|
|
b.Graffiti = make([]byte, 0, len(buf[168:200]))
|
|
}
|
|
b.Graffiti = append(b.Graffiti, buf[168:200]...)
|
|
|
|
// Offset (3) 'ProposerSlashings'
|
|
if o3 = ssz.ReadOffset(buf[200:204]); o3 > size {
|
|
return ssz.ErrOffset
|
|
}
|
|
|
|
if o3 < 220 {
|
|
return ssz.ErrInvalidVariableOffset
|
|
}
|
|
|
|
// Offset (4) 'AttesterSlashings'
|
|
if o4 = ssz.ReadOffset(buf[204:208]); o4 > size || o3 > o4 {
|
|
return ssz.ErrOffset
|
|
}
|
|
|
|
// Offset (5) 'Attestations'
|
|
if o5 = ssz.ReadOffset(buf[208:212]); o5 > size || o4 > o5 {
|
|
return ssz.ErrOffset
|
|
}
|
|
|
|
// Offset (6) 'Deposits'
|
|
if o6 = ssz.ReadOffset(buf[212:216]); o6 > size || o5 > o6 {
|
|
return ssz.ErrOffset
|
|
}
|
|
|
|
// Offset (7) 'VoluntaryExits'
|
|
if o7 = ssz.ReadOffset(buf[216:220]); o7 > size || o6 > o7 {
|
|
return ssz.ErrOffset
|
|
}
|
|
|
|
// Field (3) 'ProposerSlashings'
|
|
{
|
|
buf = tail[o3:o4]
|
|
num, err := ssz.DivideInt2(len(buf), 416, 16)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
b.ProposerSlashings = make([]*ProposerSlashing, num)
|
|
for ii := 0; ii < num; ii++ {
|
|
if b.ProposerSlashings[ii] == nil {
|
|
b.ProposerSlashings[ii] = new(ProposerSlashing)
|
|
}
|
|
if err = b.ProposerSlashings[ii].UnmarshalSSZ(buf[ii*416 : (ii+1)*416]); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
}
|
|
|
|
// Field (4) 'AttesterSlashings'
|
|
{
|
|
buf = tail[o4:o5]
|
|
num, err := ssz.DecodeDynamicLength(buf, 2)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
b.AttesterSlashings = make([]*AttesterSlashing, num)
|
|
err = ssz.UnmarshalDynamic(buf, num, func(indx int, buf []byte) (err error) {
|
|
if b.AttesterSlashings[indx] == nil {
|
|
b.AttesterSlashings[indx] = new(AttesterSlashing)
|
|
}
|
|
if err = b.AttesterSlashings[indx].UnmarshalSSZ(buf); err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
})
|
|
if err != nil {
|
|
return err
|
|
}
|
|
}
|
|
|
|
// Field (5) 'Attestations'
|
|
{
|
|
buf = tail[o5:o6]
|
|
num, err := ssz.DecodeDynamicLength(buf, 128)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
b.Attestations = make([]*Attestation, num)
|
|
err = ssz.UnmarshalDynamic(buf, num, func(indx int, buf []byte) (err error) {
|
|
if b.Attestations[indx] == nil {
|
|
b.Attestations[indx] = new(Attestation)
|
|
}
|
|
if err = b.Attestations[indx].UnmarshalSSZ(buf); err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
})
|
|
if err != nil {
|
|
return err
|
|
}
|
|
}
|
|
|
|
// Field (6) 'Deposits'
|
|
{
|
|
buf = tail[o6:o7]
|
|
num, err := ssz.DivideInt2(len(buf), 1240, 16)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
b.Deposits = make([]*Deposit, num)
|
|
for ii := 0; ii < num; ii++ {
|
|
if b.Deposits[ii] == nil {
|
|
b.Deposits[ii] = new(Deposit)
|
|
}
|
|
if err = b.Deposits[ii].UnmarshalSSZ(buf[ii*1240 : (ii+1)*1240]); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
}
|
|
|
|
// Field (7) 'VoluntaryExits'
|
|
{
|
|
buf = tail[o7:]
|
|
num, err := ssz.DivideInt2(len(buf), 112, 16)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
b.VoluntaryExits = make([]*SignedVoluntaryExit, num)
|
|
for ii := 0; ii < num; ii++ {
|
|
if b.VoluntaryExits[ii] == nil {
|
|
b.VoluntaryExits[ii] = new(SignedVoluntaryExit)
|
|
}
|
|
if err = b.VoluntaryExits[ii].UnmarshalSSZ(buf[ii*112 : (ii+1)*112]); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
}
|
|
return err
|
|
}
|
|
|
|
// SizeSSZ returns the ssz encoded size in bytes for the BeaconBlockBody object
|
|
func (b *BeaconBlockBody) SizeSSZ() (size int) {
|
|
size = 220
|
|
|
|
// Field (3) 'ProposerSlashings'
|
|
size += len(b.ProposerSlashings) * 416
|
|
|
|
// Field (4) 'AttesterSlashings'
|
|
for ii := 0; ii < len(b.AttesterSlashings); ii++ {
|
|
size += 4
|
|
size += b.AttesterSlashings[ii].SizeSSZ()
|
|
}
|
|
|
|
// Field (5) 'Attestations'
|
|
for ii := 0; ii < len(b.Attestations); ii++ {
|
|
size += 4
|
|
size += b.Attestations[ii].SizeSSZ()
|
|
}
|
|
|
|
// Field (6) 'Deposits'
|
|
size += len(b.Deposits) * 1240
|
|
|
|
// Field (7) 'VoluntaryExits'
|
|
size += len(b.VoluntaryExits) * 112
|
|
|
|
return
|
|
}
|
|
|
|
// HashTreeRoot ssz hashes the BeaconBlockBody object
|
|
func (b *BeaconBlockBody) HashTreeRoot() ([32]byte, error) {
|
|
return ssz.HashWithDefaultHasher(b)
|
|
}
|
|
|
|
// HashTreeRootWith ssz hashes the BeaconBlockBody object with a hasher
|
|
func (b *BeaconBlockBody) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|
indx := hh.Index()
|
|
|
|
// Field (0) 'RandaoReveal'
|
|
if len(b.RandaoReveal) != 96 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(b.RandaoReveal)
|
|
|
|
// Field (1) 'Eth1Data'
|
|
if err = b.Eth1Data.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
|
|
// Field (2) 'Graffiti'
|
|
if len(b.Graffiti) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(b.Graffiti)
|
|
|
|
// Field (3) 'ProposerSlashings'
|
|
{
|
|
subIndx := hh.Index()
|
|
num := uint64(len(b.ProposerSlashings))
|
|
if num > 16 {
|
|
err = ssz.ErrIncorrectListSize
|
|
return
|
|
}
|
|
for _, elem := range b.ProposerSlashings {
|
|
if err = elem.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
}
|
|
hh.MerkleizeWithMixin(subIndx, num, 16)
|
|
}
|
|
|
|
// Field (4) 'AttesterSlashings'
|
|
{
|
|
subIndx := hh.Index()
|
|
num := uint64(len(b.AttesterSlashings))
|
|
if num > 2 {
|
|
err = ssz.ErrIncorrectListSize
|
|
return
|
|
}
|
|
for _, elem := range b.AttesterSlashings {
|
|
if err = elem.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
}
|
|
hh.MerkleizeWithMixin(subIndx, num, 2)
|
|
}
|
|
|
|
// Field (5) 'Attestations'
|
|
{
|
|
subIndx := hh.Index()
|
|
num := uint64(len(b.Attestations))
|
|
if num > 128 {
|
|
err = ssz.ErrIncorrectListSize
|
|
return
|
|
}
|
|
for _, elem := range b.Attestations {
|
|
if err = elem.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
}
|
|
hh.MerkleizeWithMixin(subIndx, num, 128)
|
|
}
|
|
|
|
// Field (6) 'Deposits'
|
|
{
|
|
subIndx := hh.Index()
|
|
num := uint64(len(b.Deposits))
|
|
if num > 16 {
|
|
err = ssz.ErrIncorrectListSize
|
|
return
|
|
}
|
|
for _, elem := range b.Deposits {
|
|
if err = elem.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
}
|
|
hh.MerkleizeWithMixin(subIndx, num, 16)
|
|
}
|
|
|
|
// Field (7) 'VoluntaryExits'
|
|
{
|
|
subIndx := hh.Index()
|
|
num := uint64(len(b.VoluntaryExits))
|
|
if num > 16 {
|
|
err = ssz.ErrIncorrectListSize
|
|
return
|
|
}
|
|
for _, elem := range b.VoluntaryExits {
|
|
if err = elem.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
}
|
|
hh.MerkleizeWithMixin(subIndx, num, 16)
|
|
}
|
|
|
|
hh.Merkleize(indx)
|
|
return
|
|
}
|
|
|
|
// MarshalSSZ ssz marshals the BeaconBlockBodyAltair object
|
|
func (b *BeaconBlockBodyAltair) MarshalSSZ() ([]byte, error) {
|
|
return ssz.MarshalSSZ(b)
|
|
}
|
|
|
|
// MarshalSSZTo ssz marshals the BeaconBlockBodyAltair object to a target array
|
|
func (b *BeaconBlockBodyAltair) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
|
dst = buf
|
|
offset := int(380)
|
|
|
|
// Field (0) 'RandaoReveal'
|
|
if len(b.RandaoReveal) != 96 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, b.RandaoReveal...)
|
|
|
|
// Field (1) 'Eth1Data'
|
|
if b.Eth1Data == nil {
|
|
b.Eth1Data = new(Eth1Data)
|
|
}
|
|
if dst, err = b.Eth1Data.MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
|
|
// Field (2) 'Graffiti'
|
|
if len(b.Graffiti) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, b.Graffiti...)
|
|
|
|
// Offset (3) 'ProposerSlashings'
|
|
dst = ssz.WriteOffset(dst, offset)
|
|
offset += len(b.ProposerSlashings) * 416
|
|
|
|
// Offset (4) 'AttesterSlashings'
|
|
dst = ssz.WriteOffset(dst, offset)
|
|
for ii := 0; ii < len(b.AttesterSlashings); ii++ {
|
|
offset += 4
|
|
offset += b.AttesterSlashings[ii].SizeSSZ()
|
|
}
|
|
|
|
// Offset (5) 'Attestations'
|
|
dst = ssz.WriteOffset(dst, offset)
|
|
for ii := 0; ii < len(b.Attestations); ii++ {
|
|
offset += 4
|
|
offset += b.Attestations[ii].SizeSSZ()
|
|
}
|
|
|
|
// Offset (6) 'Deposits'
|
|
dst = ssz.WriteOffset(dst, offset)
|
|
offset += len(b.Deposits) * 1240
|
|
|
|
// Offset (7) 'VoluntaryExits'
|
|
dst = ssz.WriteOffset(dst, offset)
|
|
offset += len(b.VoluntaryExits) * 112
|
|
|
|
// Field (8) 'SyncAggregate'
|
|
if b.SyncAggregate == nil {
|
|
b.SyncAggregate = new(SyncAggregate)
|
|
}
|
|
if dst, err = b.SyncAggregate.MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
|
|
// Field (3) 'ProposerSlashings'
|
|
if len(b.ProposerSlashings) > 16 {
|
|
err = ssz.ErrListTooBig
|
|
return
|
|
}
|
|
for ii := 0; ii < len(b.ProposerSlashings); ii++ {
|
|
if dst, err = b.ProposerSlashings[ii].MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
}
|
|
|
|
// Field (4) 'AttesterSlashings'
|
|
if len(b.AttesterSlashings) > 2 {
|
|
err = ssz.ErrListTooBig
|
|
return
|
|
}
|
|
{
|
|
offset = 4 * len(b.AttesterSlashings)
|
|
for ii := 0; ii < len(b.AttesterSlashings); ii++ {
|
|
dst = ssz.WriteOffset(dst, offset)
|
|
offset += b.AttesterSlashings[ii].SizeSSZ()
|
|
}
|
|
}
|
|
for ii := 0; ii < len(b.AttesterSlashings); ii++ {
|
|
if dst, err = b.AttesterSlashings[ii].MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
}
|
|
|
|
// Field (5) 'Attestations'
|
|
if len(b.Attestations) > 128 {
|
|
err = ssz.ErrListTooBig
|
|
return
|
|
}
|
|
{
|
|
offset = 4 * len(b.Attestations)
|
|
for ii := 0; ii < len(b.Attestations); ii++ {
|
|
dst = ssz.WriteOffset(dst, offset)
|
|
offset += b.Attestations[ii].SizeSSZ()
|
|
}
|
|
}
|
|
for ii := 0; ii < len(b.Attestations); ii++ {
|
|
if dst, err = b.Attestations[ii].MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
}
|
|
|
|
// Field (6) 'Deposits'
|
|
if len(b.Deposits) > 16 {
|
|
err = ssz.ErrListTooBig
|
|
return
|
|
}
|
|
for ii := 0; ii < len(b.Deposits); ii++ {
|
|
if dst, err = b.Deposits[ii].MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
}
|
|
|
|
// Field (7) 'VoluntaryExits'
|
|
if len(b.VoluntaryExits) > 16 {
|
|
err = ssz.ErrListTooBig
|
|
return
|
|
}
|
|
for ii := 0; ii < len(b.VoluntaryExits); ii++ {
|
|
if dst, err = b.VoluntaryExits[ii].MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// UnmarshalSSZ ssz unmarshals the BeaconBlockBodyAltair object
|
|
func (b *BeaconBlockBodyAltair) UnmarshalSSZ(buf []byte) error {
|
|
var err error
|
|
size := uint64(len(buf))
|
|
if size < 380 {
|
|
return ssz.ErrSize
|
|
}
|
|
|
|
tail := buf
|
|
var o3, o4, o5, o6, o7 uint64
|
|
|
|
// Field (0) 'RandaoReveal'
|
|
if cap(b.RandaoReveal) == 0 {
|
|
b.RandaoReveal = make([]byte, 0, len(buf[0:96]))
|
|
}
|
|
b.RandaoReveal = append(b.RandaoReveal, buf[0:96]...)
|
|
|
|
// Field (1) 'Eth1Data'
|
|
if b.Eth1Data == nil {
|
|
b.Eth1Data = new(Eth1Data)
|
|
}
|
|
if err = b.Eth1Data.UnmarshalSSZ(buf[96:168]); err != nil {
|
|
return err
|
|
}
|
|
|
|
// Field (2) 'Graffiti'
|
|
if cap(b.Graffiti) == 0 {
|
|
b.Graffiti = make([]byte, 0, len(buf[168:200]))
|
|
}
|
|
b.Graffiti = append(b.Graffiti, buf[168:200]...)
|
|
|
|
// Offset (3) 'ProposerSlashings'
|
|
if o3 = ssz.ReadOffset(buf[200:204]); o3 > size {
|
|
return ssz.ErrOffset
|
|
}
|
|
|
|
if o3 < 380 {
|
|
return ssz.ErrInvalidVariableOffset
|
|
}
|
|
|
|
// Offset (4) 'AttesterSlashings'
|
|
if o4 = ssz.ReadOffset(buf[204:208]); o4 > size || o3 > o4 {
|
|
return ssz.ErrOffset
|
|
}
|
|
|
|
// Offset (5) 'Attestations'
|
|
if o5 = ssz.ReadOffset(buf[208:212]); o5 > size || o4 > o5 {
|
|
return ssz.ErrOffset
|
|
}
|
|
|
|
// Offset (6) 'Deposits'
|
|
if o6 = ssz.ReadOffset(buf[212:216]); o6 > size || o5 > o6 {
|
|
return ssz.ErrOffset
|
|
}
|
|
|
|
// Offset (7) 'VoluntaryExits'
|
|
if o7 = ssz.ReadOffset(buf[216:220]); o7 > size || o6 > o7 {
|
|
return ssz.ErrOffset
|
|
}
|
|
|
|
// Field (8) 'SyncAggregate'
|
|
if b.SyncAggregate == nil {
|
|
b.SyncAggregate = new(SyncAggregate)
|
|
}
|
|
if err = b.SyncAggregate.UnmarshalSSZ(buf[220:380]); err != nil {
|
|
return err
|
|
}
|
|
|
|
// Field (3) 'ProposerSlashings'
|
|
{
|
|
buf = tail[o3:o4]
|
|
num, err := ssz.DivideInt2(len(buf), 416, 16)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
b.ProposerSlashings = make([]*ProposerSlashing, num)
|
|
for ii := 0; ii < num; ii++ {
|
|
if b.ProposerSlashings[ii] == nil {
|
|
b.ProposerSlashings[ii] = new(ProposerSlashing)
|
|
}
|
|
if err = b.ProposerSlashings[ii].UnmarshalSSZ(buf[ii*416 : (ii+1)*416]); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
}
|
|
|
|
// Field (4) 'AttesterSlashings'
|
|
{
|
|
buf = tail[o4:o5]
|
|
num, err := ssz.DecodeDynamicLength(buf, 2)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
b.AttesterSlashings = make([]*AttesterSlashing, num)
|
|
err = ssz.UnmarshalDynamic(buf, num, func(indx int, buf []byte) (err error) {
|
|
if b.AttesterSlashings[indx] == nil {
|
|
b.AttesterSlashings[indx] = new(AttesterSlashing)
|
|
}
|
|
if err = b.AttesterSlashings[indx].UnmarshalSSZ(buf); err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
})
|
|
if err != nil {
|
|
return err
|
|
}
|
|
}
|
|
|
|
// Field (5) 'Attestations'
|
|
{
|
|
buf = tail[o5:o6]
|
|
num, err := ssz.DecodeDynamicLength(buf, 128)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
b.Attestations = make([]*Attestation, num)
|
|
err = ssz.UnmarshalDynamic(buf, num, func(indx int, buf []byte) (err error) {
|
|
if b.Attestations[indx] == nil {
|
|
b.Attestations[indx] = new(Attestation)
|
|
}
|
|
if err = b.Attestations[indx].UnmarshalSSZ(buf); err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
})
|
|
if err != nil {
|
|
return err
|
|
}
|
|
}
|
|
|
|
// Field (6) 'Deposits'
|
|
{
|
|
buf = tail[o6:o7]
|
|
num, err := ssz.DivideInt2(len(buf), 1240, 16)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
b.Deposits = make([]*Deposit, num)
|
|
for ii := 0; ii < num; ii++ {
|
|
if b.Deposits[ii] == nil {
|
|
b.Deposits[ii] = new(Deposit)
|
|
}
|
|
if err = b.Deposits[ii].UnmarshalSSZ(buf[ii*1240 : (ii+1)*1240]); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
}
|
|
|
|
// Field (7) 'VoluntaryExits'
|
|
{
|
|
buf = tail[o7:]
|
|
num, err := ssz.DivideInt2(len(buf), 112, 16)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
b.VoluntaryExits = make([]*SignedVoluntaryExit, num)
|
|
for ii := 0; ii < num; ii++ {
|
|
if b.VoluntaryExits[ii] == nil {
|
|
b.VoluntaryExits[ii] = new(SignedVoluntaryExit)
|
|
}
|
|
if err = b.VoluntaryExits[ii].UnmarshalSSZ(buf[ii*112 : (ii+1)*112]); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
}
|
|
return err
|
|
}
|
|
|
|
// SizeSSZ returns the ssz encoded size in bytes for the BeaconBlockBodyAltair object
|
|
func (b *BeaconBlockBodyAltair) SizeSSZ() (size int) {
|
|
size = 380
|
|
|
|
// Field (3) 'ProposerSlashings'
|
|
size += len(b.ProposerSlashings) * 416
|
|
|
|
// Field (4) 'AttesterSlashings'
|
|
for ii := 0; ii < len(b.AttesterSlashings); ii++ {
|
|
size += 4
|
|
size += b.AttesterSlashings[ii].SizeSSZ()
|
|
}
|
|
|
|
// Field (5) 'Attestations'
|
|
for ii := 0; ii < len(b.Attestations); ii++ {
|
|
size += 4
|
|
size += b.Attestations[ii].SizeSSZ()
|
|
}
|
|
|
|
// Field (6) 'Deposits'
|
|
size += len(b.Deposits) * 1240
|
|
|
|
// Field (7) 'VoluntaryExits'
|
|
size += len(b.VoluntaryExits) * 112
|
|
|
|
return
|
|
}
|
|
|
|
// HashTreeRoot ssz hashes the BeaconBlockBodyAltair object
|
|
func (b *BeaconBlockBodyAltair) HashTreeRoot() ([32]byte, error) {
|
|
return ssz.HashWithDefaultHasher(b)
|
|
}
|
|
|
|
// HashTreeRootWith ssz hashes the BeaconBlockBodyAltair object with a hasher
|
|
func (b *BeaconBlockBodyAltair) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|
indx := hh.Index()
|
|
|
|
// Field (0) 'RandaoReveal'
|
|
if len(b.RandaoReveal) != 96 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(b.RandaoReveal)
|
|
|
|
// Field (1) 'Eth1Data'
|
|
if err = b.Eth1Data.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
|
|
// Field (2) 'Graffiti'
|
|
if len(b.Graffiti) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(b.Graffiti)
|
|
|
|
// Field (3) 'ProposerSlashings'
|
|
{
|
|
subIndx := hh.Index()
|
|
num := uint64(len(b.ProposerSlashings))
|
|
if num > 16 {
|
|
err = ssz.ErrIncorrectListSize
|
|
return
|
|
}
|
|
for _, elem := range b.ProposerSlashings {
|
|
if err = elem.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
}
|
|
hh.MerkleizeWithMixin(subIndx, num, 16)
|
|
}
|
|
|
|
// Field (4) 'AttesterSlashings'
|
|
{
|
|
subIndx := hh.Index()
|
|
num := uint64(len(b.AttesterSlashings))
|
|
if num > 2 {
|
|
err = ssz.ErrIncorrectListSize
|
|
return
|
|
}
|
|
for _, elem := range b.AttesterSlashings {
|
|
if err = elem.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
}
|
|
hh.MerkleizeWithMixin(subIndx, num, 2)
|
|
}
|
|
|
|
// Field (5) 'Attestations'
|
|
{
|
|
subIndx := hh.Index()
|
|
num := uint64(len(b.Attestations))
|
|
if num > 128 {
|
|
err = ssz.ErrIncorrectListSize
|
|
return
|
|
}
|
|
for _, elem := range b.Attestations {
|
|
if err = elem.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
}
|
|
hh.MerkleizeWithMixin(subIndx, num, 128)
|
|
}
|
|
|
|
// Field (6) 'Deposits'
|
|
{
|
|
subIndx := hh.Index()
|
|
num := uint64(len(b.Deposits))
|
|
if num > 16 {
|
|
err = ssz.ErrIncorrectListSize
|
|
return
|
|
}
|
|
for _, elem := range b.Deposits {
|
|
if err = elem.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
}
|
|
hh.MerkleizeWithMixin(subIndx, num, 16)
|
|
}
|
|
|
|
// Field (7) 'VoluntaryExits'
|
|
{
|
|
subIndx := hh.Index()
|
|
num := uint64(len(b.VoluntaryExits))
|
|
if num > 16 {
|
|
err = ssz.ErrIncorrectListSize
|
|
return
|
|
}
|
|
for _, elem := range b.VoluntaryExits {
|
|
if err = elem.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
}
|
|
hh.MerkleizeWithMixin(subIndx, num, 16)
|
|
}
|
|
|
|
// Field (8) 'SyncAggregate'
|
|
if err = b.SyncAggregate.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
|
|
hh.Merkleize(indx)
|
|
return
|
|
}
|
|
|
|
// MarshalSSZ ssz marshals the ProposerSlashing object
|
|
func (p *ProposerSlashing) MarshalSSZ() ([]byte, error) {
|
|
return ssz.MarshalSSZ(p)
|
|
}
|
|
|
|
// MarshalSSZTo ssz marshals the ProposerSlashing object to a target array
|
|
func (p *ProposerSlashing) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
|
dst = buf
|
|
|
|
// Field (0) 'Header_1'
|
|
if p.Header_1 == nil {
|
|
p.Header_1 = new(SignedBeaconBlockHeader)
|
|
}
|
|
if dst, err = p.Header_1.MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
|
|
// Field (1) 'Header_2'
|
|
if p.Header_2 == nil {
|
|
p.Header_2 = new(SignedBeaconBlockHeader)
|
|
}
|
|
if dst, err = p.Header_2.MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// UnmarshalSSZ ssz unmarshals the ProposerSlashing object
|
|
func (p *ProposerSlashing) UnmarshalSSZ(buf []byte) error {
|
|
var err error
|
|
size := uint64(len(buf))
|
|
if size != 416 {
|
|
return ssz.ErrSize
|
|
}
|
|
|
|
// Field (0) 'Header_1'
|
|
if p.Header_1 == nil {
|
|
p.Header_1 = new(SignedBeaconBlockHeader)
|
|
}
|
|
if err = p.Header_1.UnmarshalSSZ(buf[0:208]); err != nil {
|
|
return err
|
|
}
|
|
|
|
// Field (1) 'Header_2'
|
|
if p.Header_2 == nil {
|
|
p.Header_2 = new(SignedBeaconBlockHeader)
|
|
}
|
|
if err = p.Header_2.UnmarshalSSZ(buf[208:416]); err != nil {
|
|
return err
|
|
}
|
|
|
|
return err
|
|
}
|
|
|
|
// SizeSSZ returns the ssz encoded size in bytes for the ProposerSlashing object
|
|
func (p *ProposerSlashing) SizeSSZ() (size int) {
|
|
size = 416
|
|
return
|
|
}
|
|
|
|
// HashTreeRoot ssz hashes the ProposerSlashing object
|
|
func (p *ProposerSlashing) HashTreeRoot() ([32]byte, error) {
|
|
return ssz.HashWithDefaultHasher(p)
|
|
}
|
|
|
|
// HashTreeRootWith ssz hashes the ProposerSlashing object with a hasher
|
|
func (p *ProposerSlashing) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|
indx := hh.Index()
|
|
|
|
// Field (0) 'Header_1'
|
|
if err = p.Header_1.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
|
|
// Field (1) 'Header_2'
|
|
if err = p.Header_2.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
|
|
hh.Merkleize(indx)
|
|
return
|
|
}
|
|
|
|
// MarshalSSZ ssz marshals the AttesterSlashing object
|
|
func (a *AttesterSlashing) MarshalSSZ() ([]byte, error) {
|
|
return ssz.MarshalSSZ(a)
|
|
}
|
|
|
|
// MarshalSSZTo ssz marshals the AttesterSlashing object to a target array
|
|
func (a *AttesterSlashing) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
|
dst = buf
|
|
offset := int(8)
|
|
|
|
// Offset (0) 'Attestation_1'
|
|
dst = ssz.WriteOffset(dst, offset)
|
|
if a.Attestation_1 == nil {
|
|
a.Attestation_1 = new(IndexedAttestation)
|
|
}
|
|
offset += a.Attestation_1.SizeSSZ()
|
|
|
|
// Offset (1) 'Attestation_2'
|
|
dst = ssz.WriteOffset(dst, offset)
|
|
if a.Attestation_2 == nil {
|
|
a.Attestation_2 = new(IndexedAttestation)
|
|
}
|
|
offset += a.Attestation_2.SizeSSZ()
|
|
|
|
// Field (0) 'Attestation_1'
|
|
if dst, err = a.Attestation_1.MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
|
|
// Field (1) 'Attestation_2'
|
|
if dst, err = a.Attestation_2.MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// UnmarshalSSZ ssz unmarshals the AttesterSlashing object
|
|
func (a *AttesterSlashing) UnmarshalSSZ(buf []byte) error {
|
|
var err error
|
|
size := uint64(len(buf))
|
|
if size < 8 {
|
|
return ssz.ErrSize
|
|
}
|
|
|
|
tail := buf
|
|
var o0, o1 uint64
|
|
|
|
// Offset (0) 'Attestation_1'
|
|
if o0 = ssz.ReadOffset(buf[0:4]); o0 > size {
|
|
return ssz.ErrOffset
|
|
}
|
|
|
|
if o0 < 8 {
|
|
return ssz.ErrInvalidVariableOffset
|
|
}
|
|
|
|
// Offset (1) 'Attestation_2'
|
|
if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 {
|
|
return ssz.ErrOffset
|
|
}
|
|
|
|
// Field (0) 'Attestation_1'
|
|
{
|
|
buf = tail[o0:o1]
|
|
if a.Attestation_1 == nil {
|
|
a.Attestation_1 = new(IndexedAttestation)
|
|
}
|
|
if err = a.Attestation_1.UnmarshalSSZ(buf); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
|
|
// Field (1) 'Attestation_2'
|
|
{
|
|
buf = tail[o1:]
|
|
if a.Attestation_2 == nil {
|
|
a.Attestation_2 = new(IndexedAttestation)
|
|
}
|
|
if err = a.Attestation_2.UnmarshalSSZ(buf); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
return err
|
|
}
|
|
|
|
// SizeSSZ returns the ssz encoded size in bytes for the AttesterSlashing object
|
|
func (a *AttesterSlashing) SizeSSZ() (size int) {
|
|
size = 8
|
|
|
|
// Field (0) 'Attestation_1'
|
|
if a.Attestation_1 == nil {
|
|
a.Attestation_1 = new(IndexedAttestation)
|
|
}
|
|
size += a.Attestation_1.SizeSSZ()
|
|
|
|
// Field (1) 'Attestation_2'
|
|
if a.Attestation_2 == nil {
|
|
a.Attestation_2 = new(IndexedAttestation)
|
|
}
|
|
size += a.Attestation_2.SizeSSZ()
|
|
|
|
return
|
|
}
|
|
|
|
// HashTreeRoot ssz hashes the AttesterSlashing object
|
|
func (a *AttesterSlashing) HashTreeRoot() ([32]byte, error) {
|
|
return ssz.HashWithDefaultHasher(a)
|
|
}
|
|
|
|
// HashTreeRootWith ssz hashes the AttesterSlashing object with a hasher
|
|
func (a *AttesterSlashing) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|
indx := hh.Index()
|
|
|
|
// Field (0) 'Attestation_1'
|
|
if err = a.Attestation_1.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
|
|
// Field (1) 'Attestation_2'
|
|
if err = a.Attestation_2.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
|
|
hh.Merkleize(indx)
|
|
return
|
|
}
|
|
|
|
// MarshalSSZ ssz marshals the Deposit object
|
|
func (d *Deposit) MarshalSSZ() ([]byte, error) {
|
|
return ssz.MarshalSSZ(d)
|
|
}
|
|
|
|
// MarshalSSZTo ssz marshals the Deposit object to a target array
|
|
func (d *Deposit) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
|
dst = buf
|
|
|
|
// Field (0) 'Proof'
|
|
if len(d.Proof) != 33 {
|
|
err = ssz.ErrVectorLength
|
|
return
|
|
}
|
|
for ii := 0; ii < 33; ii++ {
|
|
if len(d.Proof[ii]) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, d.Proof[ii]...)
|
|
}
|
|
|
|
// Field (1) 'Data'
|
|
if d.Data == nil {
|
|
d.Data = new(Deposit_Data)
|
|
}
|
|
if dst, err = d.Data.MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// UnmarshalSSZ ssz unmarshals the Deposit object
|
|
func (d *Deposit) UnmarshalSSZ(buf []byte) error {
|
|
var err error
|
|
size := uint64(len(buf))
|
|
if size != 1240 {
|
|
return ssz.ErrSize
|
|
}
|
|
|
|
// Field (0) 'Proof'
|
|
d.Proof = make([][]byte, 33)
|
|
for ii := 0; ii < 33; ii++ {
|
|
if cap(d.Proof[ii]) == 0 {
|
|
d.Proof[ii] = make([]byte, 0, len(buf[0:1056][ii*32:(ii+1)*32]))
|
|
}
|
|
d.Proof[ii] = append(d.Proof[ii], buf[0:1056][ii*32:(ii+1)*32]...)
|
|
}
|
|
|
|
// Field (1) 'Data'
|
|
if d.Data == nil {
|
|
d.Data = new(Deposit_Data)
|
|
}
|
|
if err = d.Data.UnmarshalSSZ(buf[1056:1240]); err != nil {
|
|
return err
|
|
}
|
|
|
|
return err
|
|
}
|
|
|
|
// SizeSSZ returns the ssz encoded size in bytes for the Deposit object
|
|
func (d *Deposit) SizeSSZ() (size int) {
|
|
size = 1240
|
|
return
|
|
}
|
|
|
|
// HashTreeRoot ssz hashes the Deposit object
|
|
func (d *Deposit) HashTreeRoot() ([32]byte, error) {
|
|
return ssz.HashWithDefaultHasher(d)
|
|
}
|
|
|
|
// HashTreeRootWith ssz hashes the Deposit object with a hasher
|
|
func (d *Deposit) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|
indx := hh.Index()
|
|
|
|
// Field (0) 'Proof'
|
|
{
|
|
if len(d.Proof) != 33 {
|
|
err = ssz.ErrVectorLength
|
|
return
|
|
}
|
|
subIndx := hh.Index()
|
|
for _, i := range d.Proof {
|
|
if len(i) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.Append(i)
|
|
}
|
|
hh.Merkleize(subIndx)
|
|
}
|
|
|
|
// Field (1) 'Data'
|
|
if err = d.Data.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
|
|
hh.Merkleize(indx)
|
|
return
|
|
}
|
|
|
|
// MarshalSSZ ssz marshals the VoluntaryExit object
|
|
func (v *VoluntaryExit) MarshalSSZ() ([]byte, error) {
|
|
return ssz.MarshalSSZ(v)
|
|
}
|
|
|
|
// MarshalSSZTo ssz marshals the VoluntaryExit object to a target array
|
|
func (v *VoluntaryExit) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
|
dst = buf
|
|
|
|
// Field (0) 'Epoch'
|
|
dst = ssz.MarshalUint64(dst, uint64(v.Epoch))
|
|
|
|
// Field (1) 'ValidatorIndex'
|
|
dst = ssz.MarshalUint64(dst, uint64(v.ValidatorIndex))
|
|
|
|
return
|
|
}
|
|
|
|
// UnmarshalSSZ ssz unmarshals the VoluntaryExit object
|
|
func (v *VoluntaryExit) UnmarshalSSZ(buf []byte) error {
|
|
var err error
|
|
size := uint64(len(buf))
|
|
if size != 16 {
|
|
return ssz.ErrSize
|
|
}
|
|
|
|
// Field (0) 'Epoch'
|
|
v.Epoch = github_com_prysmaticlabs_eth2_types.Epoch(ssz.UnmarshallUint64(buf[0:8]))
|
|
|
|
// Field (1) 'ValidatorIndex'
|
|
v.ValidatorIndex = github_com_prysmaticlabs_eth2_types.ValidatorIndex(ssz.UnmarshallUint64(buf[8:16]))
|
|
|
|
return err
|
|
}
|
|
|
|
// SizeSSZ returns the ssz encoded size in bytes for the VoluntaryExit object
|
|
func (v *VoluntaryExit) SizeSSZ() (size int) {
|
|
size = 16
|
|
return
|
|
}
|
|
|
|
// HashTreeRoot ssz hashes the VoluntaryExit object
|
|
func (v *VoluntaryExit) HashTreeRoot() ([32]byte, error) {
|
|
return ssz.HashWithDefaultHasher(v)
|
|
}
|
|
|
|
// HashTreeRootWith ssz hashes the VoluntaryExit object with a hasher
|
|
func (v *VoluntaryExit) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|
indx := hh.Index()
|
|
|
|
// Field (0) 'Epoch'
|
|
hh.PutUint64(uint64(v.Epoch))
|
|
|
|
// Field (1) 'ValidatorIndex'
|
|
hh.PutUint64(uint64(v.ValidatorIndex))
|
|
|
|
hh.Merkleize(indx)
|
|
return
|
|
}
|
|
|
|
// MarshalSSZ ssz marshals the SignedVoluntaryExit object
|
|
func (s *SignedVoluntaryExit) MarshalSSZ() ([]byte, error) {
|
|
return ssz.MarshalSSZ(s)
|
|
}
|
|
|
|
// MarshalSSZTo ssz marshals the SignedVoluntaryExit object to a target array
|
|
func (s *SignedVoluntaryExit) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
|
dst = buf
|
|
|
|
// Field (0) 'Exit'
|
|
if s.Exit == nil {
|
|
s.Exit = new(VoluntaryExit)
|
|
}
|
|
if dst, err = s.Exit.MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
|
|
// Field (1) 'Signature'
|
|
if len(s.Signature) != 96 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, s.Signature...)
|
|
|
|
return
|
|
}
|
|
|
|
// UnmarshalSSZ ssz unmarshals the SignedVoluntaryExit object
|
|
func (s *SignedVoluntaryExit) UnmarshalSSZ(buf []byte) error {
|
|
var err error
|
|
size := uint64(len(buf))
|
|
if size != 112 {
|
|
return ssz.ErrSize
|
|
}
|
|
|
|
// Field (0) 'Exit'
|
|
if s.Exit == nil {
|
|
s.Exit = new(VoluntaryExit)
|
|
}
|
|
if err = s.Exit.UnmarshalSSZ(buf[0:16]); err != nil {
|
|
return err
|
|
}
|
|
|
|
// Field (1) 'Signature'
|
|
if cap(s.Signature) == 0 {
|
|
s.Signature = make([]byte, 0, len(buf[16:112]))
|
|
}
|
|
s.Signature = append(s.Signature, buf[16:112]...)
|
|
|
|
return err
|
|
}
|
|
|
|
// SizeSSZ returns the ssz encoded size in bytes for the SignedVoluntaryExit object
|
|
func (s *SignedVoluntaryExit) SizeSSZ() (size int) {
|
|
size = 112
|
|
return
|
|
}
|
|
|
|
// HashTreeRoot ssz hashes the SignedVoluntaryExit object
|
|
func (s *SignedVoluntaryExit) HashTreeRoot() ([32]byte, error) {
|
|
return ssz.HashWithDefaultHasher(s)
|
|
}
|
|
|
|
// HashTreeRootWith ssz hashes the SignedVoluntaryExit object with a hasher
|
|
func (s *SignedVoluntaryExit) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|
indx := hh.Index()
|
|
|
|
// Field (0) 'Exit'
|
|
if err = s.Exit.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
|
|
// Field (1) 'Signature'
|
|
if len(s.Signature) != 96 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(s.Signature)
|
|
|
|
hh.Merkleize(indx)
|
|
return
|
|
}
|
|
|
|
// MarshalSSZ ssz marshals the Eth1Data object
|
|
func (e *Eth1Data) MarshalSSZ() ([]byte, error) {
|
|
return ssz.MarshalSSZ(e)
|
|
}
|
|
|
|
// MarshalSSZTo ssz marshals the Eth1Data object to a target array
|
|
func (e *Eth1Data) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
|
dst = buf
|
|
|
|
// Field (0) 'DepositRoot'
|
|
if len(e.DepositRoot) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, e.DepositRoot...)
|
|
|
|
// Field (1) 'DepositCount'
|
|
dst = ssz.MarshalUint64(dst, e.DepositCount)
|
|
|
|
// Field (2) 'BlockHash'
|
|
if len(e.BlockHash) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, e.BlockHash...)
|
|
|
|
return
|
|
}
|
|
|
|
// UnmarshalSSZ ssz unmarshals the Eth1Data object
|
|
func (e *Eth1Data) UnmarshalSSZ(buf []byte) error {
|
|
var err error
|
|
size := uint64(len(buf))
|
|
if size != 72 {
|
|
return ssz.ErrSize
|
|
}
|
|
|
|
// Field (0) 'DepositRoot'
|
|
if cap(e.DepositRoot) == 0 {
|
|
e.DepositRoot = make([]byte, 0, len(buf[0:32]))
|
|
}
|
|
e.DepositRoot = append(e.DepositRoot, buf[0:32]...)
|
|
|
|
// Field (1) 'DepositCount'
|
|
e.DepositCount = ssz.UnmarshallUint64(buf[32:40])
|
|
|
|
// Field (2) 'BlockHash'
|
|
if cap(e.BlockHash) == 0 {
|
|
e.BlockHash = make([]byte, 0, len(buf[40:72]))
|
|
}
|
|
e.BlockHash = append(e.BlockHash, buf[40:72]...)
|
|
|
|
return err
|
|
}
|
|
|
|
// SizeSSZ returns the ssz encoded size in bytes for the Eth1Data object
|
|
func (e *Eth1Data) SizeSSZ() (size int) {
|
|
size = 72
|
|
return
|
|
}
|
|
|
|
// HashTreeRoot ssz hashes the Eth1Data object
|
|
func (e *Eth1Data) HashTreeRoot() ([32]byte, error) {
|
|
return ssz.HashWithDefaultHasher(e)
|
|
}
|
|
|
|
// HashTreeRootWith ssz hashes the Eth1Data object with a hasher
|
|
func (e *Eth1Data) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|
indx := hh.Index()
|
|
|
|
// Field (0) 'DepositRoot'
|
|
if len(e.DepositRoot) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(e.DepositRoot)
|
|
|
|
// Field (1) 'DepositCount'
|
|
hh.PutUint64(e.DepositCount)
|
|
|
|
// Field (2) 'BlockHash'
|
|
if len(e.BlockHash) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(e.BlockHash)
|
|
|
|
hh.Merkleize(indx)
|
|
return
|
|
}
|
|
|
|
// MarshalSSZ ssz marshals the BeaconBlockHeader object
|
|
func (b *BeaconBlockHeader) MarshalSSZ() ([]byte, error) {
|
|
return ssz.MarshalSSZ(b)
|
|
}
|
|
|
|
// MarshalSSZTo ssz marshals the BeaconBlockHeader object to a target array
|
|
func (b *BeaconBlockHeader) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
|
dst = buf
|
|
|
|
// Field (0) 'Slot'
|
|
dst = ssz.MarshalUint64(dst, uint64(b.Slot))
|
|
|
|
// Field (1) 'ProposerIndex'
|
|
dst = ssz.MarshalUint64(dst, uint64(b.ProposerIndex))
|
|
|
|
// Field (2) 'ParentRoot'
|
|
if len(b.ParentRoot) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, b.ParentRoot...)
|
|
|
|
// Field (3) 'StateRoot'
|
|
if len(b.StateRoot) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, b.StateRoot...)
|
|
|
|
// Field (4) 'BodyRoot'
|
|
if len(b.BodyRoot) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, b.BodyRoot...)
|
|
|
|
return
|
|
}
|
|
|
|
// UnmarshalSSZ ssz unmarshals the BeaconBlockHeader object
|
|
func (b *BeaconBlockHeader) UnmarshalSSZ(buf []byte) error {
|
|
var err error
|
|
size := uint64(len(buf))
|
|
if size != 112 {
|
|
return ssz.ErrSize
|
|
}
|
|
|
|
// Field (0) 'Slot'
|
|
b.Slot = github_com_prysmaticlabs_eth2_types.Slot(ssz.UnmarshallUint64(buf[0:8]))
|
|
|
|
// Field (1) 'ProposerIndex'
|
|
b.ProposerIndex = github_com_prysmaticlabs_eth2_types.ValidatorIndex(ssz.UnmarshallUint64(buf[8:16]))
|
|
|
|
// Field (2) 'ParentRoot'
|
|
if cap(b.ParentRoot) == 0 {
|
|
b.ParentRoot = make([]byte, 0, len(buf[16:48]))
|
|
}
|
|
b.ParentRoot = append(b.ParentRoot, buf[16:48]...)
|
|
|
|
// Field (3) 'StateRoot'
|
|
if cap(b.StateRoot) == 0 {
|
|
b.StateRoot = make([]byte, 0, len(buf[48:80]))
|
|
}
|
|
b.StateRoot = append(b.StateRoot, buf[48:80]...)
|
|
|
|
// Field (4) 'BodyRoot'
|
|
if cap(b.BodyRoot) == 0 {
|
|
b.BodyRoot = make([]byte, 0, len(buf[80:112]))
|
|
}
|
|
b.BodyRoot = append(b.BodyRoot, buf[80:112]...)
|
|
|
|
return err
|
|
}
|
|
|
|
// SizeSSZ returns the ssz encoded size in bytes for the BeaconBlockHeader object
|
|
func (b *BeaconBlockHeader) SizeSSZ() (size int) {
|
|
size = 112
|
|
return
|
|
}
|
|
|
|
// HashTreeRoot ssz hashes the BeaconBlockHeader object
|
|
func (b *BeaconBlockHeader) HashTreeRoot() ([32]byte, error) {
|
|
return ssz.HashWithDefaultHasher(b)
|
|
}
|
|
|
|
// HashTreeRootWith ssz hashes the BeaconBlockHeader object with a hasher
|
|
func (b *BeaconBlockHeader) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|
indx := hh.Index()
|
|
|
|
// Field (0) 'Slot'
|
|
hh.PutUint64(uint64(b.Slot))
|
|
|
|
// Field (1) 'ProposerIndex'
|
|
hh.PutUint64(uint64(b.ProposerIndex))
|
|
|
|
// Field (2) 'ParentRoot'
|
|
if len(b.ParentRoot) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(b.ParentRoot)
|
|
|
|
// Field (3) 'StateRoot'
|
|
if len(b.StateRoot) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(b.StateRoot)
|
|
|
|
// Field (4) 'BodyRoot'
|
|
if len(b.BodyRoot) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(b.BodyRoot)
|
|
|
|
hh.Merkleize(indx)
|
|
return
|
|
}
|
|
|
|
// MarshalSSZ ssz marshals the SignedBeaconBlockHeader object
|
|
func (s *SignedBeaconBlockHeader) MarshalSSZ() ([]byte, error) {
|
|
return ssz.MarshalSSZ(s)
|
|
}
|
|
|
|
// MarshalSSZTo ssz marshals the SignedBeaconBlockHeader object to a target array
|
|
func (s *SignedBeaconBlockHeader) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
|
dst = buf
|
|
|
|
// Field (0) 'Header'
|
|
if s.Header == nil {
|
|
s.Header = new(BeaconBlockHeader)
|
|
}
|
|
if dst, err = s.Header.MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
|
|
// Field (1) 'Signature'
|
|
if len(s.Signature) != 96 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, s.Signature...)
|
|
|
|
return
|
|
}
|
|
|
|
// UnmarshalSSZ ssz unmarshals the SignedBeaconBlockHeader object
|
|
func (s *SignedBeaconBlockHeader) UnmarshalSSZ(buf []byte) error {
|
|
var err error
|
|
size := uint64(len(buf))
|
|
if size != 208 {
|
|
return ssz.ErrSize
|
|
}
|
|
|
|
// Field (0) 'Header'
|
|
if s.Header == nil {
|
|
s.Header = new(BeaconBlockHeader)
|
|
}
|
|
if err = s.Header.UnmarshalSSZ(buf[0:112]); err != nil {
|
|
return err
|
|
}
|
|
|
|
// Field (1) 'Signature'
|
|
if cap(s.Signature) == 0 {
|
|
s.Signature = make([]byte, 0, len(buf[112:208]))
|
|
}
|
|
s.Signature = append(s.Signature, buf[112:208]...)
|
|
|
|
return err
|
|
}
|
|
|
|
// SizeSSZ returns the ssz encoded size in bytes for the SignedBeaconBlockHeader object
|
|
func (s *SignedBeaconBlockHeader) SizeSSZ() (size int) {
|
|
size = 208
|
|
return
|
|
}
|
|
|
|
// HashTreeRoot ssz hashes the SignedBeaconBlockHeader object
|
|
func (s *SignedBeaconBlockHeader) HashTreeRoot() ([32]byte, error) {
|
|
return ssz.HashWithDefaultHasher(s)
|
|
}
|
|
|
|
// HashTreeRootWith ssz hashes the SignedBeaconBlockHeader object with a hasher
|
|
func (s *SignedBeaconBlockHeader) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|
indx := hh.Index()
|
|
|
|
// Field (0) 'Header'
|
|
if err = s.Header.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
|
|
// Field (1) 'Signature'
|
|
if len(s.Signature) != 96 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(s.Signature)
|
|
|
|
hh.Merkleize(indx)
|
|
return
|
|
}
|
|
|
|
// MarshalSSZ ssz marshals the IndexedAttestation object
|
|
func (i *IndexedAttestation) MarshalSSZ() ([]byte, error) {
|
|
return ssz.MarshalSSZ(i)
|
|
}
|
|
|
|
// MarshalSSZTo ssz marshals the IndexedAttestation object to a target array
|
|
func (i *IndexedAttestation) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
|
dst = buf
|
|
offset := int(228)
|
|
|
|
// Offset (0) 'AttestingIndices'
|
|
dst = ssz.WriteOffset(dst, offset)
|
|
offset += len(i.AttestingIndices) * 8
|
|
|
|
// Field (1) 'Data'
|
|
if i.Data == nil {
|
|
i.Data = new(AttestationData)
|
|
}
|
|
if dst, err = i.Data.MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
|
|
// Field (2) 'Signature'
|
|
if len(i.Signature) != 96 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, i.Signature...)
|
|
|
|
// Field (0) 'AttestingIndices'
|
|
if len(i.AttestingIndices) > 2048 {
|
|
err = ssz.ErrListTooBig
|
|
return
|
|
}
|
|
for ii := 0; ii < len(i.AttestingIndices); ii++ {
|
|
dst = ssz.MarshalUint64(dst, i.AttestingIndices[ii])
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// UnmarshalSSZ ssz unmarshals the IndexedAttestation object
|
|
func (i *IndexedAttestation) UnmarshalSSZ(buf []byte) error {
|
|
var err error
|
|
size := uint64(len(buf))
|
|
if size < 228 {
|
|
return ssz.ErrSize
|
|
}
|
|
|
|
tail := buf
|
|
var o0 uint64
|
|
|
|
// Offset (0) 'AttestingIndices'
|
|
if o0 = ssz.ReadOffset(buf[0:4]); o0 > size {
|
|
return ssz.ErrOffset
|
|
}
|
|
|
|
if o0 < 228 {
|
|
return ssz.ErrInvalidVariableOffset
|
|
}
|
|
|
|
// Field (1) 'Data'
|
|
if i.Data == nil {
|
|
i.Data = new(AttestationData)
|
|
}
|
|
if err = i.Data.UnmarshalSSZ(buf[4:132]); err != nil {
|
|
return err
|
|
}
|
|
|
|
// Field (2) 'Signature'
|
|
if cap(i.Signature) == 0 {
|
|
i.Signature = make([]byte, 0, len(buf[132:228]))
|
|
}
|
|
i.Signature = append(i.Signature, buf[132:228]...)
|
|
|
|
// Field (0) 'AttestingIndices'
|
|
{
|
|
buf = tail[o0:]
|
|
num, err := ssz.DivideInt2(len(buf), 8, 2048)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
i.AttestingIndices = ssz.ExtendUint64(i.AttestingIndices, num)
|
|
for ii := 0; ii < num; ii++ {
|
|
i.AttestingIndices[ii] = ssz.UnmarshallUint64(buf[ii*8 : (ii+1)*8])
|
|
}
|
|
}
|
|
return err
|
|
}
|
|
|
|
// SizeSSZ returns the ssz encoded size in bytes for the IndexedAttestation object
|
|
func (i *IndexedAttestation) SizeSSZ() (size int) {
|
|
size = 228
|
|
|
|
// Field (0) 'AttestingIndices'
|
|
size += len(i.AttestingIndices) * 8
|
|
|
|
return
|
|
}
|
|
|
|
// HashTreeRoot ssz hashes the IndexedAttestation object
|
|
func (i *IndexedAttestation) HashTreeRoot() ([32]byte, error) {
|
|
return ssz.HashWithDefaultHasher(i)
|
|
}
|
|
|
|
// HashTreeRootWith ssz hashes the IndexedAttestation object with a hasher
|
|
func (i *IndexedAttestation) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|
indx := hh.Index()
|
|
|
|
// Field (0) 'AttestingIndices'
|
|
{
|
|
if len(i.AttestingIndices) > 2048 {
|
|
err = ssz.ErrListTooBig
|
|
return
|
|
}
|
|
subIndx := hh.Index()
|
|
for _, i := range i.AttestingIndices {
|
|
hh.AppendUint64(i)
|
|
}
|
|
hh.FillUpTo32()
|
|
numItems := uint64(len(i.AttestingIndices))
|
|
hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(2048, numItems, 8))
|
|
}
|
|
|
|
// Field (1) 'Data'
|
|
if err = i.Data.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
|
|
// Field (2) 'Signature'
|
|
if len(i.Signature) != 96 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(i.Signature)
|
|
|
|
hh.Merkleize(indx)
|
|
return
|
|
}
|
|
|
|
// MarshalSSZ ssz marshals the SyncAggregate object
|
|
func (s *SyncAggregate) MarshalSSZ() ([]byte, error) {
|
|
return ssz.MarshalSSZ(s)
|
|
}
|
|
|
|
// MarshalSSZTo ssz marshals the SyncAggregate object to a target array
|
|
func (s *SyncAggregate) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
|
dst = buf
|
|
|
|
// Field (0) 'SyncCommitteeBits'
|
|
if len(s.SyncCommitteeBits) != 64 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, s.SyncCommitteeBits...)
|
|
|
|
// Field (1) 'SyncCommitteeSignature'
|
|
if len(s.SyncCommitteeSignature) != 96 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, s.SyncCommitteeSignature...)
|
|
|
|
return
|
|
}
|
|
|
|
// UnmarshalSSZ ssz unmarshals the SyncAggregate object
|
|
func (s *SyncAggregate) UnmarshalSSZ(buf []byte) error {
|
|
var err error
|
|
size := uint64(len(buf))
|
|
if size != 160 {
|
|
return ssz.ErrSize
|
|
}
|
|
|
|
// Field (0) 'SyncCommitteeBits'
|
|
if cap(s.SyncCommitteeBits) == 0 {
|
|
s.SyncCommitteeBits = make([]byte, 0, len(buf[0:64]))
|
|
}
|
|
s.SyncCommitteeBits = append(s.SyncCommitteeBits, buf[0:64]...)
|
|
|
|
// Field (1) 'SyncCommitteeSignature'
|
|
if cap(s.SyncCommitteeSignature) == 0 {
|
|
s.SyncCommitteeSignature = make([]byte, 0, len(buf[64:160]))
|
|
}
|
|
s.SyncCommitteeSignature = append(s.SyncCommitteeSignature, buf[64:160]...)
|
|
|
|
return err
|
|
}
|
|
|
|
// SizeSSZ returns the ssz encoded size in bytes for the SyncAggregate object
|
|
func (s *SyncAggregate) SizeSSZ() (size int) {
|
|
size = 160
|
|
return
|
|
}
|
|
|
|
// HashTreeRoot ssz hashes the SyncAggregate object
|
|
func (s *SyncAggregate) HashTreeRoot() ([32]byte, error) {
|
|
return ssz.HashWithDefaultHasher(s)
|
|
}
|
|
|
|
// HashTreeRootWith ssz hashes the SyncAggregate object with a hasher
|
|
func (s *SyncAggregate) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|
indx := hh.Index()
|
|
|
|
// Field (0) 'SyncCommitteeBits'
|
|
if len(s.SyncCommitteeBits) != 64 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(s.SyncCommitteeBits)
|
|
|
|
// Field (1) 'SyncCommitteeSignature'
|
|
if len(s.SyncCommitteeSignature) != 96 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(s.SyncCommitteeSignature)
|
|
|
|
hh.Merkleize(indx)
|
|
return
|
|
}
|
|
|
|
// MarshalSSZ ssz marshals the SignedBeaconBlockBellatrix object
|
|
func (s *SignedBeaconBlockBellatrix) MarshalSSZ() ([]byte, error) {
|
|
return ssz.MarshalSSZ(s)
|
|
}
|
|
|
|
// MarshalSSZTo ssz marshals the SignedBeaconBlockBellatrix object to a target array
|
|
func (s *SignedBeaconBlockBellatrix) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
|
dst = buf
|
|
offset := int(100)
|
|
|
|
// Offset (0) 'Block'
|
|
dst = ssz.WriteOffset(dst, offset)
|
|
if s.Block == nil {
|
|
s.Block = new(BeaconBlockBellatrix)
|
|
}
|
|
offset += s.Block.SizeSSZ()
|
|
|
|
// Field (1) 'Signature'
|
|
if len(s.Signature) != 96 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, s.Signature...)
|
|
|
|
// Field (0) 'Block'
|
|
if dst, err = s.Block.MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// UnmarshalSSZ ssz unmarshals the SignedBeaconBlockBellatrix object
|
|
func (s *SignedBeaconBlockBellatrix) UnmarshalSSZ(buf []byte) error {
|
|
var err error
|
|
size := uint64(len(buf))
|
|
if size < 100 {
|
|
return ssz.ErrSize
|
|
}
|
|
|
|
tail := buf
|
|
var o0 uint64
|
|
|
|
// Offset (0) 'Block'
|
|
if o0 = ssz.ReadOffset(buf[0:4]); o0 > size {
|
|
return ssz.ErrOffset
|
|
}
|
|
|
|
if o0 < 100 {
|
|
return ssz.ErrInvalidVariableOffset
|
|
}
|
|
|
|
// Field (1) 'Signature'
|
|
if cap(s.Signature) == 0 {
|
|
s.Signature = make([]byte, 0, len(buf[4:100]))
|
|
}
|
|
s.Signature = append(s.Signature, buf[4:100]...)
|
|
|
|
// Field (0) 'Block'
|
|
{
|
|
buf = tail[o0:]
|
|
if s.Block == nil {
|
|
s.Block = new(BeaconBlockBellatrix)
|
|
}
|
|
if err = s.Block.UnmarshalSSZ(buf); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
return err
|
|
}
|
|
|
|
// SizeSSZ returns the ssz encoded size in bytes for the SignedBeaconBlockBellatrix object
|
|
func (s *SignedBeaconBlockBellatrix) SizeSSZ() (size int) {
|
|
size = 100
|
|
|
|
// Field (0) 'Block'
|
|
if s.Block == nil {
|
|
s.Block = new(BeaconBlockBellatrix)
|
|
}
|
|
size += s.Block.SizeSSZ()
|
|
|
|
return
|
|
}
|
|
|
|
// HashTreeRoot ssz hashes the SignedBeaconBlockBellatrix object
|
|
func (s *SignedBeaconBlockBellatrix) HashTreeRoot() ([32]byte, error) {
|
|
return ssz.HashWithDefaultHasher(s)
|
|
}
|
|
|
|
// HashTreeRootWith ssz hashes the SignedBeaconBlockBellatrix object with a hasher
|
|
func (s *SignedBeaconBlockBellatrix) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|
indx := hh.Index()
|
|
|
|
// Field (0) 'Block'
|
|
if err = s.Block.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
|
|
// Field (1) 'Signature'
|
|
if len(s.Signature) != 96 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(s.Signature)
|
|
|
|
hh.Merkleize(indx)
|
|
return
|
|
}
|
|
|
|
// MarshalSSZ ssz marshals the BeaconBlockBellatrix object
|
|
func (b *BeaconBlockBellatrix) MarshalSSZ() ([]byte, error) {
|
|
return ssz.MarshalSSZ(b)
|
|
}
|
|
|
|
// MarshalSSZTo ssz marshals the BeaconBlockBellatrix object to a target array
|
|
func (b *BeaconBlockBellatrix) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
|
dst = buf
|
|
offset := int(84)
|
|
|
|
// Field (0) 'Slot'
|
|
dst = ssz.MarshalUint64(dst, uint64(b.Slot))
|
|
|
|
// Field (1) 'ProposerIndex'
|
|
dst = ssz.MarshalUint64(dst, uint64(b.ProposerIndex))
|
|
|
|
// Field (2) 'ParentRoot'
|
|
if len(b.ParentRoot) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, b.ParentRoot...)
|
|
|
|
// Field (3) 'StateRoot'
|
|
if len(b.StateRoot) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, b.StateRoot...)
|
|
|
|
// Offset (4) 'Body'
|
|
dst = ssz.WriteOffset(dst, offset)
|
|
if b.Body == nil {
|
|
b.Body = new(BeaconBlockBodyBellatrix)
|
|
}
|
|
offset += b.Body.SizeSSZ()
|
|
|
|
// Field (4) 'Body'
|
|
if dst, err = b.Body.MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// UnmarshalSSZ ssz unmarshals the BeaconBlockBellatrix object
|
|
func (b *BeaconBlockBellatrix) UnmarshalSSZ(buf []byte) error {
|
|
var err error
|
|
size := uint64(len(buf))
|
|
if size < 84 {
|
|
return ssz.ErrSize
|
|
}
|
|
|
|
tail := buf
|
|
var o4 uint64
|
|
|
|
// Field (0) 'Slot'
|
|
b.Slot = github_com_prysmaticlabs_eth2_types.Slot(ssz.UnmarshallUint64(buf[0:8]))
|
|
|
|
// Field (1) 'ProposerIndex'
|
|
b.ProposerIndex = github_com_prysmaticlabs_eth2_types.ValidatorIndex(ssz.UnmarshallUint64(buf[8:16]))
|
|
|
|
// Field (2) 'ParentRoot'
|
|
if cap(b.ParentRoot) == 0 {
|
|
b.ParentRoot = make([]byte, 0, len(buf[16:48]))
|
|
}
|
|
b.ParentRoot = append(b.ParentRoot, buf[16:48]...)
|
|
|
|
// Field (3) 'StateRoot'
|
|
if cap(b.StateRoot) == 0 {
|
|
b.StateRoot = make([]byte, 0, len(buf[48:80]))
|
|
}
|
|
b.StateRoot = append(b.StateRoot, buf[48:80]...)
|
|
|
|
// Offset (4) 'Body'
|
|
if o4 = ssz.ReadOffset(buf[80:84]); o4 > size {
|
|
return ssz.ErrOffset
|
|
}
|
|
|
|
if o4 < 84 {
|
|
return ssz.ErrInvalidVariableOffset
|
|
}
|
|
|
|
// Field (4) 'Body'
|
|
{
|
|
buf = tail[o4:]
|
|
if b.Body == nil {
|
|
b.Body = new(BeaconBlockBodyBellatrix)
|
|
}
|
|
if err = b.Body.UnmarshalSSZ(buf); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
return err
|
|
}
|
|
|
|
// SizeSSZ returns the ssz encoded size in bytes for the BeaconBlockBellatrix object
|
|
func (b *BeaconBlockBellatrix) SizeSSZ() (size int) {
|
|
size = 84
|
|
|
|
// Field (4) 'Body'
|
|
if b.Body == nil {
|
|
b.Body = new(BeaconBlockBodyBellatrix)
|
|
}
|
|
size += b.Body.SizeSSZ()
|
|
|
|
return
|
|
}
|
|
|
|
// HashTreeRoot ssz hashes the BeaconBlockBellatrix object
|
|
func (b *BeaconBlockBellatrix) HashTreeRoot() ([32]byte, error) {
|
|
return ssz.HashWithDefaultHasher(b)
|
|
}
|
|
|
|
// HashTreeRootWith ssz hashes the BeaconBlockBellatrix object with a hasher
|
|
func (b *BeaconBlockBellatrix) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|
indx := hh.Index()
|
|
|
|
// Field (0) 'Slot'
|
|
hh.PutUint64(uint64(b.Slot))
|
|
|
|
// Field (1) 'ProposerIndex'
|
|
hh.PutUint64(uint64(b.ProposerIndex))
|
|
|
|
// Field (2) 'ParentRoot'
|
|
if len(b.ParentRoot) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(b.ParentRoot)
|
|
|
|
// Field (3) 'StateRoot'
|
|
if len(b.StateRoot) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(b.StateRoot)
|
|
|
|
// Field (4) 'Body'
|
|
if err = b.Body.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
|
|
hh.Merkleize(indx)
|
|
return
|
|
}
|
|
|
|
// MarshalSSZ ssz marshals the BeaconBlockBodyBellatrix object
|
|
func (b *BeaconBlockBodyBellatrix) MarshalSSZ() ([]byte, error) {
|
|
return ssz.MarshalSSZ(b)
|
|
}
|
|
|
|
// MarshalSSZTo ssz marshals the BeaconBlockBodyBellatrix object to a target array
|
|
func (b *BeaconBlockBodyBellatrix) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
|
dst = buf
|
|
offset := int(384)
|
|
|
|
// Field (0) 'RandaoReveal'
|
|
if len(b.RandaoReveal) != 96 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, b.RandaoReveal...)
|
|
|
|
// Field (1) 'Eth1Data'
|
|
if b.Eth1Data == nil {
|
|
b.Eth1Data = new(Eth1Data)
|
|
}
|
|
if dst, err = b.Eth1Data.MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
|
|
// Field (2) 'Graffiti'
|
|
if len(b.Graffiti) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, b.Graffiti...)
|
|
|
|
// Offset (3) 'ProposerSlashings'
|
|
dst = ssz.WriteOffset(dst, offset)
|
|
offset += len(b.ProposerSlashings) * 416
|
|
|
|
// Offset (4) 'AttesterSlashings'
|
|
dst = ssz.WriteOffset(dst, offset)
|
|
for ii := 0; ii < len(b.AttesterSlashings); ii++ {
|
|
offset += 4
|
|
offset += b.AttesterSlashings[ii].SizeSSZ()
|
|
}
|
|
|
|
// Offset (5) 'Attestations'
|
|
dst = ssz.WriteOffset(dst, offset)
|
|
for ii := 0; ii < len(b.Attestations); ii++ {
|
|
offset += 4
|
|
offset += b.Attestations[ii].SizeSSZ()
|
|
}
|
|
|
|
// Offset (6) 'Deposits'
|
|
dst = ssz.WriteOffset(dst, offset)
|
|
offset += len(b.Deposits) * 1240
|
|
|
|
// Offset (7) 'VoluntaryExits'
|
|
dst = ssz.WriteOffset(dst, offset)
|
|
offset += len(b.VoluntaryExits) * 112
|
|
|
|
// Field (8) 'SyncAggregate'
|
|
if b.SyncAggregate == nil {
|
|
b.SyncAggregate = new(SyncAggregate)
|
|
}
|
|
if dst, err = b.SyncAggregate.MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
|
|
// Offset (9) 'ExecutionPayload'
|
|
dst = ssz.WriteOffset(dst, offset)
|
|
if b.ExecutionPayload == nil {
|
|
b.ExecutionPayload = new(v1.ExecutionPayload)
|
|
}
|
|
offset += b.ExecutionPayload.SizeSSZ()
|
|
|
|
// Field (3) 'ProposerSlashings'
|
|
if len(b.ProposerSlashings) > 16 {
|
|
err = ssz.ErrListTooBig
|
|
return
|
|
}
|
|
for ii := 0; ii < len(b.ProposerSlashings); ii++ {
|
|
if dst, err = b.ProposerSlashings[ii].MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
}
|
|
|
|
// Field (4) 'AttesterSlashings'
|
|
if len(b.AttesterSlashings) > 2 {
|
|
err = ssz.ErrListTooBig
|
|
return
|
|
}
|
|
{
|
|
offset = 4 * len(b.AttesterSlashings)
|
|
for ii := 0; ii < len(b.AttesterSlashings); ii++ {
|
|
dst = ssz.WriteOffset(dst, offset)
|
|
offset += b.AttesterSlashings[ii].SizeSSZ()
|
|
}
|
|
}
|
|
for ii := 0; ii < len(b.AttesterSlashings); ii++ {
|
|
if dst, err = b.AttesterSlashings[ii].MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
}
|
|
|
|
// Field (5) 'Attestations'
|
|
if len(b.Attestations) > 128 {
|
|
err = ssz.ErrListTooBig
|
|
return
|
|
}
|
|
{
|
|
offset = 4 * len(b.Attestations)
|
|
for ii := 0; ii < len(b.Attestations); ii++ {
|
|
dst = ssz.WriteOffset(dst, offset)
|
|
offset += b.Attestations[ii].SizeSSZ()
|
|
}
|
|
}
|
|
for ii := 0; ii < len(b.Attestations); ii++ {
|
|
if dst, err = b.Attestations[ii].MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
}
|
|
|
|
// Field (6) 'Deposits'
|
|
if len(b.Deposits) > 16 {
|
|
err = ssz.ErrListTooBig
|
|
return
|
|
}
|
|
for ii := 0; ii < len(b.Deposits); ii++ {
|
|
if dst, err = b.Deposits[ii].MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
}
|
|
|
|
// Field (7) 'VoluntaryExits'
|
|
if len(b.VoluntaryExits) > 16 {
|
|
err = ssz.ErrListTooBig
|
|
return
|
|
}
|
|
for ii := 0; ii < len(b.VoluntaryExits); ii++ {
|
|
if dst, err = b.VoluntaryExits[ii].MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
}
|
|
|
|
// Field (9) 'ExecutionPayload'
|
|
if dst, err = b.ExecutionPayload.MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// UnmarshalSSZ ssz unmarshals the BeaconBlockBodyBellatrix object
|
|
func (b *BeaconBlockBodyBellatrix) UnmarshalSSZ(buf []byte) error {
|
|
var err error
|
|
size := uint64(len(buf))
|
|
if size < 384 {
|
|
return ssz.ErrSize
|
|
}
|
|
|
|
tail := buf
|
|
var o3, o4, o5, o6, o7, o9 uint64
|
|
|
|
// Field (0) 'RandaoReveal'
|
|
if cap(b.RandaoReveal) == 0 {
|
|
b.RandaoReveal = make([]byte, 0, len(buf[0:96]))
|
|
}
|
|
b.RandaoReveal = append(b.RandaoReveal, buf[0:96]...)
|
|
|
|
// Field (1) 'Eth1Data'
|
|
if b.Eth1Data == nil {
|
|
b.Eth1Data = new(Eth1Data)
|
|
}
|
|
if err = b.Eth1Data.UnmarshalSSZ(buf[96:168]); err != nil {
|
|
return err
|
|
}
|
|
|
|
// Field (2) 'Graffiti'
|
|
if cap(b.Graffiti) == 0 {
|
|
b.Graffiti = make([]byte, 0, len(buf[168:200]))
|
|
}
|
|
b.Graffiti = append(b.Graffiti, buf[168:200]...)
|
|
|
|
// Offset (3) 'ProposerSlashings'
|
|
if o3 = ssz.ReadOffset(buf[200:204]); o3 > size {
|
|
return ssz.ErrOffset
|
|
}
|
|
|
|
if o3 < 384 {
|
|
return ssz.ErrInvalidVariableOffset
|
|
}
|
|
|
|
// Offset (4) 'AttesterSlashings'
|
|
if o4 = ssz.ReadOffset(buf[204:208]); o4 > size || o3 > o4 {
|
|
return ssz.ErrOffset
|
|
}
|
|
|
|
// Offset (5) 'Attestations'
|
|
if o5 = ssz.ReadOffset(buf[208:212]); o5 > size || o4 > o5 {
|
|
return ssz.ErrOffset
|
|
}
|
|
|
|
// Offset (6) 'Deposits'
|
|
if o6 = ssz.ReadOffset(buf[212:216]); o6 > size || o5 > o6 {
|
|
return ssz.ErrOffset
|
|
}
|
|
|
|
// Offset (7) 'VoluntaryExits'
|
|
if o7 = ssz.ReadOffset(buf[216:220]); o7 > size || o6 > o7 {
|
|
return ssz.ErrOffset
|
|
}
|
|
|
|
// Field (8) 'SyncAggregate'
|
|
if b.SyncAggregate == nil {
|
|
b.SyncAggregate = new(SyncAggregate)
|
|
}
|
|
if err = b.SyncAggregate.UnmarshalSSZ(buf[220:380]); err != nil {
|
|
return err
|
|
}
|
|
|
|
// Offset (9) 'ExecutionPayload'
|
|
if o9 = ssz.ReadOffset(buf[380:384]); o9 > size || o7 > o9 {
|
|
return ssz.ErrOffset
|
|
}
|
|
|
|
// Field (3) 'ProposerSlashings'
|
|
{
|
|
buf = tail[o3:o4]
|
|
num, err := ssz.DivideInt2(len(buf), 416, 16)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
b.ProposerSlashings = make([]*ProposerSlashing, num)
|
|
for ii := 0; ii < num; ii++ {
|
|
if b.ProposerSlashings[ii] == nil {
|
|
b.ProposerSlashings[ii] = new(ProposerSlashing)
|
|
}
|
|
if err = b.ProposerSlashings[ii].UnmarshalSSZ(buf[ii*416 : (ii+1)*416]); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
}
|
|
|
|
// Field (4) 'AttesterSlashings'
|
|
{
|
|
buf = tail[o4:o5]
|
|
num, err := ssz.DecodeDynamicLength(buf, 2)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
b.AttesterSlashings = make([]*AttesterSlashing, num)
|
|
err = ssz.UnmarshalDynamic(buf, num, func(indx int, buf []byte) (err error) {
|
|
if b.AttesterSlashings[indx] == nil {
|
|
b.AttesterSlashings[indx] = new(AttesterSlashing)
|
|
}
|
|
if err = b.AttesterSlashings[indx].UnmarshalSSZ(buf); err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
})
|
|
if err != nil {
|
|
return err
|
|
}
|
|
}
|
|
|
|
// Field (5) 'Attestations'
|
|
{
|
|
buf = tail[o5:o6]
|
|
num, err := ssz.DecodeDynamicLength(buf, 128)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
b.Attestations = make([]*Attestation, num)
|
|
err = ssz.UnmarshalDynamic(buf, num, func(indx int, buf []byte) (err error) {
|
|
if b.Attestations[indx] == nil {
|
|
b.Attestations[indx] = new(Attestation)
|
|
}
|
|
if err = b.Attestations[indx].UnmarshalSSZ(buf); err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
})
|
|
if err != nil {
|
|
return err
|
|
}
|
|
}
|
|
|
|
// Field (6) 'Deposits'
|
|
{
|
|
buf = tail[o6:o7]
|
|
num, err := ssz.DivideInt2(len(buf), 1240, 16)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
b.Deposits = make([]*Deposit, num)
|
|
for ii := 0; ii < num; ii++ {
|
|
if b.Deposits[ii] == nil {
|
|
b.Deposits[ii] = new(Deposit)
|
|
}
|
|
if err = b.Deposits[ii].UnmarshalSSZ(buf[ii*1240 : (ii+1)*1240]); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
}
|
|
|
|
// Field (7) 'VoluntaryExits'
|
|
{
|
|
buf = tail[o7:o9]
|
|
num, err := ssz.DivideInt2(len(buf), 112, 16)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
b.VoluntaryExits = make([]*SignedVoluntaryExit, num)
|
|
for ii := 0; ii < num; ii++ {
|
|
if b.VoluntaryExits[ii] == nil {
|
|
b.VoluntaryExits[ii] = new(SignedVoluntaryExit)
|
|
}
|
|
if err = b.VoluntaryExits[ii].UnmarshalSSZ(buf[ii*112 : (ii+1)*112]); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
}
|
|
|
|
// Field (9) 'ExecutionPayload'
|
|
{
|
|
buf = tail[o9:]
|
|
if b.ExecutionPayload == nil {
|
|
b.ExecutionPayload = new(v1.ExecutionPayload)
|
|
}
|
|
if err = b.ExecutionPayload.UnmarshalSSZ(buf); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
return err
|
|
}
|
|
|
|
// SizeSSZ returns the ssz encoded size in bytes for the BeaconBlockBodyBellatrix object
|
|
func (b *BeaconBlockBodyBellatrix) SizeSSZ() (size int) {
|
|
size = 384
|
|
|
|
// Field (3) 'ProposerSlashings'
|
|
size += len(b.ProposerSlashings) * 416
|
|
|
|
// Field (4) 'AttesterSlashings'
|
|
for ii := 0; ii < len(b.AttesterSlashings); ii++ {
|
|
size += 4
|
|
size += b.AttesterSlashings[ii].SizeSSZ()
|
|
}
|
|
|
|
// Field (5) 'Attestations'
|
|
for ii := 0; ii < len(b.Attestations); ii++ {
|
|
size += 4
|
|
size += b.Attestations[ii].SizeSSZ()
|
|
}
|
|
|
|
// Field (6) 'Deposits'
|
|
size += len(b.Deposits) * 1240
|
|
|
|
// Field (7) 'VoluntaryExits'
|
|
size += len(b.VoluntaryExits) * 112
|
|
|
|
// Field (9) 'ExecutionPayload'
|
|
if b.ExecutionPayload == nil {
|
|
b.ExecutionPayload = new(v1.ExecutionPayload)
|
|
}
|
|
size += b.ExecutionPayload.SizeSSZ()
|
|
|
|
return
|
|
}
|
|
|
|
// HashTreeRoot ssz hashes the BeaconBlockBodyBellatrix object
|
|
func (b *BeaconBlockBodyBellatrix) HashTreeRoot() ([32]byte, error) {
|
|
return ssz.HashWithDefaultHasher(b)
|
|
}
|
|
|
|
// HashTreeRootWith ssz hashes the BeaconBlockBodyBellatrix object with a hasher
|
|
func (b *BeaconBlockBodyBellatrix) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|
indx := hh.Index()
|
|
|
|
// Field (0) 'RandaoReveal'
|
|
if len(b.RandaoReveal) != 96 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(b.RandaoReveal)
|
|
|
|
// Field (1) 'Eth1Data'
|
|
if err = b.Eth1Data.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
|
|
// Field (2) 'Graffiti'
|
|
if len(b.Graffiti) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(b.Graffiti)
|
|
|
|
// Field (3) 'ProposerSlashings'
|
|
{
|
|
subIndx := hh.Index()
|
|
num := uint64(len(b.ProposerSlashings))
|
|
if num > 16 {
|
|
err = ssz.ErrIncorrectListSize
|
|
return
|
|
}
|
|
for _, elem := range b.ProposerSlashings {
|
|
if err = elem.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
}
|
|
hh.MerkleizeWithMixin(subIndx, num, 16)
|
|
}
|
|
|
|
// Field (4) 'AttesterSlashings'
|
|
{
|
|
subIndx := hh.Index()
|
|
num := uint64(len(b.AttesterSlashings))
|
|
if num > 2 {
|
|
err = ssz.ErrIncorrectListSize
|
|
return
|
|
}
|
|
for _, elem := range b.AttesterSlashings {
|
|
if err = elem.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
}
|
|
hh.MerkleizeWithMixin(subIndx, num, 2)
|
|
}
|
|
|
|
// Field (5) 'Attestations'
|
|
{
|
|
subIndx := hh.Index()
|
|
num := uint64(len(b.Attestations))
|
|
if num > 128 {
|
|
err = ssz.ErrIncorrectListSize
|
|
return
|
|
}
|
|
for _, elem := range b.Attestations {
|
|
if err = elem.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
}
|
|
hh.MerkleizeWithMixin(subIndx, num, 128)
|
|
}
|
|
|
|
// Field (6) 'Deposits'
|
|
{
|
|
subIndx := hh.Index()
|
|
num := uint64(len(b.Deposits))
|
|
if num > 16 {
|
|
err = ssz.ErrIncorrectListSize
|
|
return
|
|
}
|
|
for _, elem := range b.Deposits {
|
|
if err = elem.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
}
|
|
hh.MerkleizeWithMixin(subIndx, num, 16)
|
|
}
|
|
|
|
// Field (7) 'VoluntaryExits'
|
|
{
|
|
subIndx := hh.Index()
|
|
num := uint64(len(b.VoluntaryExits))
|
|
if num > 16 {
|
|
err = ssz.ErrIncorrectListSize
|
|
return
|
|
}
|
|
for _, elem := range b.VoluntaryExits {
|
|
if err = elem.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
}
|
|
hh.MerkleizeWithMixin(subIndx, num, 16)
|
|
}
|
|
|
|
// Field (8) 'SyncAggregate'
|
|
if err = b.SyncAggregate.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
|
|
// Field (9) 'ExecutionPayload'
|
|
if err = b.ExecutionPayload.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
|
|
hh.Merkleize(indx)
|
|
return
|
|
}
|
|
|
|
// MarshalSSZ ssz marshals the Deposit_Data object
|
|
func (d *Deposit_Data) MarshalSSZ() ([]byte, error) {
|
|
return ssz.MarshalSSZ(d)
|
|
}
|
|
|
|
// MarshalSSZTo ssz marshals the Deposit_Data object to a target array
|
|
func (d *Deposit_Data) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
|
dst = buf
|
|
|
|
// Field (0) 'PublicKey'
|
|
if len(d.PublicKey) != 48 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, d.PublicKey...)
|
|
|
|
// Field (1) 'WithdrawalCredentials'
|
|
if len(d.WithdrawalCredentials) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, d.WithdrawalCredentials...)
|
|
|
|
// Field (2) 'Amount'
|
|
dst = ssz.MarshalUint64(dst, d.Amount)
|
|
|
|
// Field (3) 'Signature'
|
|
if len(d.Signature) != 96 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, d.Signature...)
|
|
|
|
return
|
|
}
|
|
|
|
// UnmarshalSSZ ssz unmarshals the Deposit_Data object
|
|
func (d *Deposit_Data) UnmarshalSSZ(buf []byte) error {
|
|
var err error
|
|
size := uint64(len(buf))
|
|
if size != 184 {
|
|
return ssz.ErrSize
|
|
}
|
|
|
|
// Field (0) 'PublicKey'
|
|
if cap(d.PublicKey) == 0 {
|
|
d.PublicKey = make([]byte, 0, len(buf[0:48]))
|
|
}
|
|
d.PublicKey = append(d.PublicKey, buf[0:48]...)
|
|
|
|
// Field (1) 'WithdrawalCredentials'
|
|
if cap(d.WithdrawalCredentials) == 0 {
|
|
d.WithdrawalCredentials = make([]byte, 0, len(buf[48:80]))
|
|
}
|
|
d.WithdrawalCredentials = append(d.WithdrawalCredentials, buf[48:80]...)
|
|
|
|
// Field (2) 'Amount'
|
|
d.Amount = ssz.UnmarshallUint64(buf[80:88])
|
|
|
|
// Field (3) 'Signature'
|
|
if cap(d.Signature) == 0 {
|
|
d.Signature = make([]byte, 0, len(buf[88:184]))
|
|
}
|
|
d.Signature = append(d.Signature, buf[88:184]...)
|
|
|
|
return err
|
|
}
|
|
|
|
// SizeSSZ returns the ssz encoded size in bytes for the Deposit_Data object
|
|
func (d *Deposit_Data) SizeSSZ() (size int) {
|
|
size = 184
|
|
return
|
|
}
|
|
|
|
// HashTreeRoot ssz hashes the Deposit_Data object
|
|
func (d *Deposit_Data) HashTreeRoot() ([32]byte, error) {
|
|
return ssz.HashWithDefaultHasher(d)
|
|
}
|
|
|
|
// HashTreeRootWith ssz hashes the Deposit_Data object with a hasher
|
|
func (d *Deposit_Data) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|
indx := hh.Index()
|
|
|
|
// Field (0) 'PublicKey'
|
|
if len(d.PublicKey) != 48 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(d.PublicKey)
|
|
|
|
// Field (1) 'WithdrawalCredentials'
|
|
if len(d.WithdrawalCredentials) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(d.WithdrawalCredentials)
|
|
|
|
// Field (2) 'Amount'
|
|
hh.PutUint64(d.Amount)
|
|
|
|
// Field (3) 'Signature'
|
|
if len(d.Signature) != 96 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(d.Signature)
|
|
|
|
hh.Merkleize(indx)
|
|
return
|
|
}
|
|
|
|
// MarshalSSZ ssz marshals the BeaconState object
|
|
func (b *BeaconState) MarshalSSZ() ([]byte, error) {
|
|
return ssz.MarshalSSZ(b)
|
|
}
|
|
|
|
// MarshalSSZTo ssz marshals the BeaconState object to a target array
|
|
func (b *BeaconState) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
|
dst = buf
|
|
offset := int(2687377)
|
|
|
|
// Field (0) 'GenesisTime'
|
|
dst = ssz.MarshalUint64(dst, b.GenesisTime)
|
|
|
|
// Field (1) 'GenesisValidatorsRoot'
|
|
if len(b.GenesisValidatorsRoot) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, b.GenesisValidatorsRoot...)
|
|
|
|
// Field (2) 'Slot'
|
|
dst = ssz.MarshalUint64(dst, uint64(b.Slot))
|
|
|
|
// Field (3) 'Fork'
|
|
if b.Fork == nil {
|
|
b.Fork = new(Fork)
|
|
}
|
|
if dst, err = b.Fork.MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
|
|
// Field (4) 'LatestBlockHeader'
|
|
if b.LatestBlockHeader == nil {
|
|
b.LatestBlockHeader = new(BeaconBlockHeader)
|
|
}
|
|
if dst, err = b.LatestBlockHeader.MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
|
|
// Field (5) 'BlockRoots'
|
|
if len(b.BlockRoots) != 8192 {
|
|
err = ssz.ErrVectorLength
|
|
return
|
|
}
|
|
for ii := 0; ii < 8192; ii++ {
|
|
if len(b.BlockRoots[ii]) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, b.BlockRoots[ii]...)
|
|
}
|
|
|
|
// Field (6) 'StateRoots'
|
|
if len(b.StateRoots) != 8192 {
|
|
err = ssz.ErrVectorLength
|
|
return
|
|
}
|
|
for ii := 0; ii < 8192; ii++ {
|
|
if len(b.StateRoots[ii]) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, b.StateRoots[ii]...)
|
|
}
|
|
|
|
// Offset (7) 'HistoricalRoots'
|
|
dst = ssz.WriteOffset(dst, offset)
|
|
offset += len(b.HistoricalRoots) * 32
|
|
|
|
// Field (8) 'Eth1Data'
|
|
if b.Eth1Data == nil {
|
|
b.Eth1Data = new(Eth1Data)
|
|
}
|
|
if dst, err = b.Eth1Data.MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
|
|
// Offset (9) 'Eth1DataVotes'
|
|
dst = ssz.WriteOffset(dst, offset)
|
|
offset += len(b.Eth1DataVotes) * 72
|
|
|
|
// Field (10) 'Eth1DepositIndex'
|
|
dst = ssz.MarshalUint64(dst, b.Eth1DepositIndex)
|
|
|
|
// Offset (11) 'Validators'
|
|
dst = ssz.WriteOffset(dst, offset)
|
|
offset += len(b.Validators) * 121
|
|
|
|
// Offset (12) 'Balances'
|
|
dst = ssz.WriteOffset(dst, offset)
|
|
offset += len(b.Balances) * 8
|
|
|
|
// Field (13) 'RandaoMixes'
|
|
if len(b.RandaoMixes) != 65536 {
|
|
err = ssz.ErrVectorLength
|
|
return
|
|
}
|
|
for ii := 0; ii < 65536; ii++ {
|
|
if len(b.RandaoMixes[ii]) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, b.RandaoMixes[ii]...)
|
|
}
|
|
|
|
// Field (14) 'Slashings'
|
|
if len(b.Slashings) != 8192 {
|
|
err = ssz.ErrVectorLength
|
|
return
|
|
}
|
|
for ii := 0; ii < 8192; ii++ {
|
|
dst = ssz.MarshalUint64(dst, b.Slashings[ii])
|
|
}
|
|
|
|
// Offset (15) 'PreviousEpochAttestations'
|
|
dst = ssz.WriteOffset(dst, offset)
|
|
for ii := 0; ii < len(b.PreviousEpochAttestations); ii++ {
|
|
offset += 4
|
|
offset += b.PreviousEpochAttestations[ii].SizeSSZ()
|
|
}
|
|
|
|
// Offset (16) 'CurrentEpochAttestations'
|
|
dst = ssz.WriteOffset(dst, offset)
|
|
for ii := 0; ii < len(b.CurrentEpochAttestations); ii++ {
|
|
offset += 4
|
|
offset += b.CurrentEpochAttestations[ii].SizeSSZ()
|
|
}
|
|
|
|
// Field (17) 'JustificationBits'
|
|
if len(b.JustificationBits) != 1 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, b.JustificationBits...)
|
|
|
|
// Field (18) 'PreviousJustifiedCheckpoint'
|
|
if b.PreviousJustifiedCheckpoint == nil {
|
|
b.PreviousJustifiedCheckpoint = new(Checkpoint)
|
|
}
|
|
if dst, err = b.PreviousJustifiedCheckpoint.MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
|
|
// Field (19) 'CurrentJustifiedCheckpoint'
|
|
if b.CurrentJustifiedCheckpoint == nil {
|
|
b.CurrentJustifiedCheckpoint = new(Checkpoint)
|
|
}
|
|
if dst, err = b.CurrentJustifiedCheckpoint.MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
|
|
// Field (20) 'FinalizedCheckpoint'
|
|
if b.FinalizedCheckpoint == nil {
|
|
b.FinalizedCheckpoint = new(Checkpoint)
|
|
}
|
|
if dst, err = b.FinalizedCheckpoint.MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
|
|
// Field (7) 'HistoricalRoots'
|
|
if len(b.HistoricalRoots) > 16777216 {
|
|
err = ssz.ErrListTooBig
|
|
return
|
|
}
|
|
for ii := 0; ii < len(b.HistoricalRoots); ii++ {
|
|
if len(b.HistoricalRoots[ii]) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, b.HistoricalRoots[ii]...)
|
|
}
|
|
|
|
// Field (9) 'Eth1DataVotes'
|
|
if len(b.Eth1DataVotes) > 2048 {
|
|
err = ssz.ErrListTooBig
|
|
return
|
|
}
|
|
for ii := 0; ii < len(b.Eth1DataVotes); ii++ {
|
|
if dst, err = b.Eth1DataVotes[ii].MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
}
|
|
|
|
// Field (11) 'Validators'
|
|
if len(b.Validators) > 1099511627776 {
|
|
err = ssz.ErrListTooBig
|
|
return
|
|
}
|
|
for ii := 0; ii < len(b.Validators); ii++ {
|
|
if dst, err = b.Validators[ii].MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
}
|
|
|
|
// Field (12) 'Balances'
|
|
if len(b.Balances) > 1099511627776 {
|
|
err = ssz.ErrListTooBig
|
|
return
|
|
}
|
|
for ii := 0; ii < len(b.Balances); ii++ {
|
|
dst = ssz.MarshalUint64(dst, b.Balances[ii])
|
|
}
|
|
|
|
// Field (15) 'PreviousEpochAttestations'
|
|
if len(b.PreviousEpochAttestations) > 4096 {
|
|
err = ssz.ErrListTooBig
|
|
return
|
|
}
|
|
{
|
|
offset = 4 * len(b.PreviousEpochAttestations)
|
|
for ii := 0; ii < len(b.PreviousEpochAttestations); ii++ {
|
|
dst = ssz.WriteOffset(dst, offset)
|
|
offset += b.PreviousEpochAttestations[ii].SizeSSZ()
|
|
}
|
|
}
|
|
for ii := 0; ii < len(b.PreviousEpochAttestations); ii++ {
|
|
if dst, err = b.PreviousEpochAttestations[ii].MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
}
|
|
|
|
// Field (16) 'CurrentEpochAttestations'
|
|
if len(b.CurrentEpochAttestations) > 4096 {
|
|
err = ssz.ErrListTooBig
|
|
return
|
|
}
|
|
{
|
|
offset = 4 * len(b.CurrentEpochAttestations)
|
|
for ii := 0; ii < len(b.CurrentEpochAttestations); ii++ {
|
|
dst = ssz.WriteOffset(dst, offset)
|
|
offset += b.CurrentEpochAttestations[ii].SizeSSZ()
|
|
}
|
|
}
|
|
for ii := 0; ii < len(b.CurrentEpochAttestations); ii++ {
|
|
if dst, err = b.CurrentEpochAttestations[ii].MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// UnmarshalSSZ ssz unmarshals the BeaconState object
|
|
func (b *BeaconState) UnmarshalSSZ(buf []byte) error {
|
|
var err error
|
|
size := uint64(len(buf))
|
|
if size < 2687377 {
|
|
return ssz.ErrSize
|
|
}
|
|
|
|
tail := buf
|
|
var o7, o9, o11, o12, o15, o16 uint64
|
|
|
|
// Field (0) 'GenesisTime'
|
|
b.GenesisTime = ssz.UnmarshallUint64(buf[0:8])
|
|
|
|
// Field (1) 'GenesisValidatorsRoot'
|
|
if cap(b.GenesisValidatorsRoot) == 0 {
|
|
b.GenesisValidatorsRoot = make([]byte, 0, len(buf[8:40]))
|
|
}
|
|
b.GenesisValidatorsRoot = append(b.GenesisValidatorsRoot, buf[8:40]...)
|
|
|
|
// Field (2) 'Slot'
|
|
b.Slot = github_com_prysmaticlabs_eth2_types.Slot(ssz.UnmarshallUint64(buf[40:48]))
|
|
|
|
// Field (3) 'Fork'
|
|
if b.Fork == nil {
|
|
b.Fork = new(Fork)
|
|
}
|
|
if err = b.Fork.UnmarshalSSZ(buf[48:64]); err != nil {
|
|
return err
|
|
}
|
|
|
|
// Field (4) 'LatestBlockHeader'
|
|
if b.LatestBlockHeader == nil {
|
|
b.LatestBlockHeader = new(BeaconBlockHeader)
|
|
}
|
|
if err = b.LatestBlockHeader.UnmarshalSSZ(buf[64:176]); err != nil {
|
|
return err
|
|
}
|
|
|
|
// Field (5) 'BlockRoots'
|
|
b.BlockRoots = make([][]byte, 8192)
|
|
for ii := 0; ii < 8192; ii++ {
|
|
if cap(b.BlockRoots[ii]) == 0 {
|
|
b.BlockRoots[ii] = make([]byte, 0, len(buf[176:262320][ii*32:(ii+1)*32]))
|
|
}
|
|
b.BlockRoots[ii] = append(b.BlockRoots[ii], buf[176:262320][ii*32:(ii+1)*32]...)
|
|
}
|
|
|
|
// Field (6) 'StateRoots'
|
|
b.StateRoots = make([][]byte, 8192)
|
|
for ii := 0; ii < 8192; ii++ {
|
|
if cap(b.StateRoots[ii]) == 0 {
|
|
b.StateRoots[ii] = make([]byte, 0, len(buf[262320:524464][ii*32:(ii+1)*32]))
|
|
}
|
|
b.StateRoots[ii] = append(b.StateRoots[ii], buf[262320:524464][ii*32:(ii+1)*32]...)
|
|
}
|
|
|
|
// Offset (7) 'HistoricalRoots'
|
|
if o7 = ssz.ReadOffset(buf[524464:524468]); o7 > size {
|
|
return ssz.ErrOffset
|
|
}
|
|
|
|
if o7 < 2687377 {
|
|
return ssz.ErrInvalidVariableOffset
|
|
}
|
|
|
|
// Field (8) 'Eth1Data'
|
|
if b.Eth1Data == nil {
|
|
b.Eth1Data = new(Eth1Data)
|
|
}
|
|
if err = b.Eth1Data.UnmarshalSSZ(buf[524468:524540]); err != nil {
|
|
return err
|
|
}
|
|
|
|
// Offset (9) 'Eth1DataVotes'
|
|
if o9 = ssz.ReadOffset(buf[524540:524544]); o9 > size || o7 > o9 {
|
|
return ssz.ErrOffset
|
|
}
|
|
|
|
// Field (10) 'Eth1DepositIndex'
|
|
b.Eth1DepositIndex = ssz.UnmarshallUint64(buf[524544:524552])
|
|
|
|
// Offset (11) 'Validators'
|
|
if o11 = ssz.ReadOffset(buf[524552:524556]); o11 > size || o9 > o11 {
|
|
return ssz.ErrOffset
|
|
}
|
|
|
|
// Offset (12) 'Balances'
|
|
if o12 = ssz.ReadOffset(buf[524556:524560]); o12 > size || o11 > o12 {
|
|
return ssz.ErrOffset
|
|
}
|
|
|
|
// Field (13) 'RandaoMixes'
|
|
b.RandaoMixes = make([][]byte, 65536)
|
|
for ii := 0; ii < 65536; ii++ {
|
|
if cap(b.RandaoMixes[ii]) == 0 {
|
|
b.RandaoMixes[ii] = make([]byte, 0, len(buf[524560:2621712][ii*32:(ii+1)*32]))
|
|
}
|
|
b.RandaoMixes[ii] = append(b.RandaoMixes[ii], buf[524560:2621712][ii*32:(ii+1)*32]...)
|
|
}
|
|
|
|
// Field (14) 'Slashings'
|
|
b.Slashings = ssz.ExtendUint64(b.Slashings, 8192)
|
|
for ii := 0; ii < 8192; ii++ {
|
|
b.Slashings[ii] = ssz.UnmarshallUint64(buf[2621712:2687248][ii*8 : (ii+1)*8])
|
|
}
|
|
|
|
// Offset (15) 'PreviousEpochAttestations'
|
|
if o15 = ssz.ReadOffset(buf[2687248:2687252]); o15 > size || o12 > o15 {
|
|
return ssz.ErrOffset
|
|
}
|
|
|
|
// Offset (16) 'CurrentEpochAttestations'
|
|
if o16 = ssz.ReadOffset(buf[2687252:2687256]); o16 > size || o15 > o16 {
|
|
return ssz.ErrOffset
|
|
}
|
|
|
|
// Field (17) 'JustificationBits'
|
|
if cap(b.JustificationBits) == 0 {
|
|
b.JustificationBits = make([]byte, 0, len(buf[2687256:2687257]))
|
|
}
|
|
b.JustificationBits = append(b.JustificationBits, buf[2687256:2687257]...)
|
|
|
|
// Field (18) 'PreviousJustifiedCheckpoint'
|
|
if b.PreviousJustifiedCheckpoint == nil {
|
|
b.PreviousJustifiedCheckpoint = new(Checkpoint)
|
|
}
|
|
if err = b.PreviousJustifiedCheckpoint.UnmarshalSSZ(buf[2687257:2687297]); err != nil {
|
|
return err
|
|
}
|
|
|
|
// Field (19) 'CurrentJustifiedCheckpoint'
|
|
if b.CurrentJustifiedCheckpoint == nil {
|
|
b.CurrentJustifiedCheckpoint = new(Checkpoint)
|
|
}
|
|
if err = b.CurrentJustifiedCheckpoint.UnmarshalSSZ(buf[2687297:2687337]); err != nil {
|
|
return err
|
|
}
|
|
|
|
// Field (20) 'FinalizedCheckpoint'
|
|
if b.FinalizedCheckpoint == nil {
|
|
b.FinalizedCheckpoint = new(Checkpoint)
|
|
}
|
|
if err = b.FinalizedCheckpoint.UnmarshalSSZ(buf[2687337:2687377]); err != nil {
|
|
return err
|
|
}
|
|
|
|
// Field (7) 'HistoricalRoots'
|
|
{
|
|
buf = tail[o7:o9]
|
|
num, err := ssz.DivideInt2(len(buf), 32, 16777216)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
b.HistoricalRoots = make([][]byte, num)
|
|
for ii := 0; ii < num; ii++ {
|
|
if cap(b.HistoricalRoots[ii]) == 0 {
|
|
b.HistoricalRoots[ii] = make([]byte, 0, len(buf[ii*32:(ii+1)*32]))
|
|
}
|
|
b.HistoricalRoots[ii] = append(b.HistoricalRoots[ii], buf[ii*32:(ii+1)*32]...)
|
|
}
|
|
}
|
|
|
|
// Field (9) 'Eth1DataVotes'
|
|
{
|
|
buf = tail[o9:o11]
|
|
num, err := ssz.DivideInt2(len(buf), 72, 2048)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
b.Eth1DataVotes = make([]*Eth1Data, num)
|
|
for ii := 0; ii < num; ii++ {
|
|
if b.Eth1DataVotes[ii] == nil {
|
|
b.Eth1DataVotes[ii] = new(Eth1Data)
|
|
}
|
|
if err = b.Eth1DataVotes[ii].UnmarshalSSZ(buf[ii*72 : (ii+1)*72]); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
}
|
|
|
|
// Field (11) 'Validators'
|
|
{
|
|
buf = tail[o11:o12]
|
|
num, err := ssz.DivideInt2(len(buf), 121, 1099511627776)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
b.Validators = make([]*Validator, num)
|
|
for ii := 0; ii < num; ii++ {
|
|
if b.Validators[ii] == nil {
|
|
b.Validators[ii] = new(Validator)
|
|
}
|
|
if err = b.Validators[ii].UnmarshalSSZ(buf[ii*121 : (ii+1)*121]); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
}
|
|
|
|
// Field (12) 'Balances'
|
|
{
|
|
buf = tail[o12:o15]
|
|
num, err := ssz.DivideInt2(len(buf), 8, 1099511627776)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
b.Balances = ssz.ExtendUint64(b.Balances, num)
|
|
for ii := 0; ii < num; ii++ {
|
|
b.Balances[ii] = ssz.UnmarshallUint64(buf[ii*8 : (ii+1)*8])
|
|
}
|
|
}
|
|
|
|
// Field (15) 'PreviousEpochAttestations'
|
|
{
|
|
buf = tail[o15:o16]
|
|
num, err := ssz.DecodeDynamicLength(buf, 4096)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
b.PreviousEpochAttestations = make([]*PendingAttestation, num)
|
|
err = ssz.UnmarshalDynamic(buf, num, func(indx int, buf []byte) (err error) {
|
|
if b.PreviousEpochAttestations[indx] == nil {
|
|
b.PreviousEpochAttestations[indx] = new(PendingAttestation)
|
|
}
|
|
if err = b.PreviousEpochAttestations[indx].UnmarshalSSZ(buf); err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
})
|
|
if err != nil {
|
|
return err
|
|
}
|
|
}
|
|
|
|
// Field (16) 'CurrentEpochAttestations'
|
|
{
|
|
buf = tail[o16:]
|
|
num, err := ssz.DecodeDynamicLength(buf, 4096)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
b.CurrentEpochAttestations = make([]*PendingAttestation, num)
|
|
err = ssz.UnmarshalDynamic(buf, num, func(indx int, buf []byte) (err error) {
|
|
if b.CurrentEpochAttestations[indx] == nil {
|
|
b.CurrentEpochAttestations[indx] = new(PendingAttestation)
|
|
}
|
|
if err = b.CurrentEpochAttestations[indx].UnmarshalSSZ(buf); err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
})
|
|
if err != nil {
|
|
return err
|
|
}
|
|
}
|
|
return err
|
|
}
|
|
|
|
// SizeSSZ returns the ssz encoded size in bytes for the BeaconState object
|
|
func (b *BeaconState) SizeSSZ() (size int) {
|
|
size = 2687377
|
|
|
|
// Field (7) 'HistoricalRoots'
|
|
size += len(b.HistoricalRoots) * 32
|
|
|
|
// Field (9) 'Eth1DataVotes'
|
|
size += len(b.Eth1DataVotes) * 72
|
|
|
|
// Field (11) 'Validators'
|
|
size += len(b.Validators) * 121
|
|
|
|
// Field (12) 'Balances'
|
|
size += len(b.Balances) * 8
|
|
|
|
// Field (15) 'PreviousEpochAttestations'
|
|
for ii := 0; ii < len(b.PreviousEpochAttestations); ii++ {
|
|
size += 4
|
|
size += b.PreviousEpochAttestations[ii].SizeSSZ()
|
|
}
|
|
|
|
// Field (16) 'CurrentEpochAttestations'
|
|
for ii := 0; ii < len(b.CurrentEpochAttestations); ii++ {
|
|
size += 4
|
|
size += b.CurrentEpochAttestations[ii].SizeSSZ()
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// HashTreeRoot ssz hashes the BeaconState object
|
|
func (b *BeaconState) HashTreeRoot() ([32]byte, error) {
|
|
return ssz.HashWithDefaultHasher(b)
|
|
}
|
|
|
|
// HashTreeRootWith ssz hashes the BeaconState object with a hasher
|
|
func (b *BeaconState) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|
indx := hh.Index()
|
|
|
|
// Field (0) 'GenesisTime'
|
|
hh.PutUint64(b.GenesisTime)
|
|
|
|
// Field (1) 'GenesisValidatorsRoot'
|
|
if len(b.GenesisValidatorsRoot) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(b.GenesisValidatorsRoot)
|
|
|
|
// Field (2) 'Slot'
|
|
hh.PutUint64(uint64(b.Slot))
|
|
|
|
// Field (3) 'Fork'
|
|
if err = b.Fork.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
|
|
// Field (4) 'LatestBlockHeader'
|
|
if err = b.LatestBlockHeader.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
|
|
// Field (5) 'BlockRoots'
|
|
{
|
|
if len(b.BlockRoots) != 8192 {
|
|
err = ssz.ErrVectorLength
|
|
return
|
|
}
|
|
subIndx := hh.Index()
|
|
for _, i := range b.BlockRoots {
|
|
if len(i) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.Append(i)
|
|
}
|
|
hh.Merkleize(subIndx)
|
|
}
|
|
|
|
// Field (6) 'StateRoots'
|
|
{
|
|
if len(b.StateRoots) != 8192 {
|
|
err = ssz.ErrVectorLength
|
|
return
|
|
}
|
|
subIndx := hh.Index()
|
|
for _, i := range b.StateRoots {
|
|
if len(i) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.Append(i)
|
|
}
|
|
hh.Merkleize(subIndx)
|
|
}
|
|
|
|
// Field (7) 'HistoricalRoots'
|
|
{
|
|
if len(b.HistoricalRoots) > 16777216 {
|
|
err = ssz.ErrListTooBig
|
|
return
|
|
}
|
|
subIndx := hh.Index()
|
|
for _, i := range b.HistoricalRoots {
|
|
if len(i) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.Append(i)
|
|
}
|
|
numItems := uint64(len(b.HistoricalRoots))
|
|
hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(16777216, numItems, 32))
|
|
}
|
|
|
|
// Field (8) 'Eth1Data'
|
|
if err = b.Eth1Data.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
|
|
// Field (9) 'Eth1DataVotes'
|
|
{
|
|
subIndx := hh.Index()
|
|
num := uint64(len(b.Eth1DataVotes))
|
|
if num > 2048 {
|
|
err = ssz.ErrIncorrectListSize
|
|
return
|
|
}
|
|
for _, elem := range b.Eth1DataVotes {
|
|
if err = elem.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
}
|
|
hh.MerkleizeWithMixin(subIndx, num, 2048)
|
|
}
|
|
|
|
// Field (10) 'Eth1DepositIndex'
|
|
hh.PutUint64(b.Eth1DepositIndex)
|
|
|
|
// Field (11) 'Validators'
|
|
{
|
|
subIndx := hh.Index()
|
|
num := uint64(len(b.Validators))
|
|
if num > 1099511627776 {
|
|
err = ssz.ErrIncorrectListSize
|
|
return
|
|
}
|
|
for _, elem := range b.Validators {
|
|
if err = elem.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
}
|
|
hh.MerkleizeWithMixin(subIndx, num, 1099511627776)
|
|
}
|
|
|
|
// Field (12) 'Balances'
|
|
{
|
|
if len(b.Balances) > 1099511627776 {
|
|
err = ssz.ErrListTooBig
|
|
return
|
|
}
|
|
subIndx := hh.Index()
|
|
for _, i := range b.Balances {
|
|
hh.AppendUint64(i)
|
|
}
|
|
hh.FillUpTo32()
|
|
numItems := uint64(len(b.Balances))
|
|
hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(1099511627776, numItems, 8))
|
|
}
|
|
|
|
// Field (13) 'RandaoMixes'
|
|
{
|
|
if len(b.RandaoMixes) != 65536 {
|
|
err = ssz.ErrVectorLength
|
|
return
|
|
}
|
|
subIndx := hh.Index()
|
|
for _, i := range b.RandaoMixes {
|
|
if len(i) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.Append(i)
|
|
}
|
|
hh.Merkleize(subIndx)
|
|
}
|
|
|
|
// Field (14) 'Slashings'
|
|
{
|
|
if len(b.Slashings) != 8192 {
|
|
err = ssz.ErrVectorLength
|
|
return
|
|
}
|
|
subIndx := hh.Index()
|
|
for _, i := range b.Slashings {
|
|
hh.AppendUint64(i)
|
|
}
|
|
hh.Merkleize(subIndx)
|
|
}
|
|
|
|
// Field (15) 'PreviousEpochAttestations'
|
|
{
|
|
subIndx := hh.Index()
|
|
num := uint64(len(b.PreviousEpochAttestations))
|
|
if num > 4096 {
|
|
err = ssz.ErrIncorrectListSize
|
|
return
|
|
}
|
|
for _, elem := range b.PreviousEpochAttestations {
|
|
if err = elem.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
}
|
|
hh.MerkleizeWithMixin(subIndx, num, 4096)
|
|
}
|
|
|
|
// Field (16) 'CurrentEpochAttestations'
|
|
{
|
|
subIndx := hh.Index()
|
|
num := uint64(len(b.CurrentEpochAttestations))
|
|
if num > 4096 {
|
|
err = ssz.ErrIncorrectListSize
|
|
return
|
|
}
|
|
for _, elem := range b.CurrentEpochAttestations {
|
|
if err = elem.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
}
|
|
hh.MerkleizeWithMixin(subIndx, num, 4096)
|
|
}
|
|
|
|
// Field (17) 'JustificationBits'
|
|
if len(b.JustificationBits) != 1 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(b.JustificationBits)
|
|
|
|
// Field (18) 'PreviousJustifiedCheckpoint'
|
|
if err = b.PreviousJustifiedCheckpoint.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
|
|
// Field (19) 'CurrentJustifiedCheckpoint'
|
|
if err = b.CurrentJustifiedCheckpoint.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
|
|
// Field (20) 'FinalizedCheckpoint'
|
|
if err = b.FinalizedCheckpoint.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
|
|
hh.Merkleize(indx)
|
|
return
|
|
}
|
|
|
|
// MarshalSSZ ssz marshals the BeaconStateAltair object
|
|
func (b *BeaconStateAltair) MarshalSSZ() ([]byte, error) {
|
|
return ssz.MarshalSSZ(b)
|
|
}
|
|
|
|
// MarshalSSZTo ssz marshals the BeaconStateAltair object to a target array
|
|
func (b *BeaconStateAltair) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
|
dst = buf
|
|
offset := int(2736629)
|
|
|
|
// Field (0) 'GenesisTime'
|
|
dst = ssz.MarshalUint64(dst, b.GenesisTime)
|
|
|
|
// Field (1) 'GenesisValidatorsRoot'
|
|
if len(b.GenesisValidatorsRoot) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, b.GenesisValidatorsRoot...)
|
|
|
|
// Field (2) 'Slot'
|
|
dst = ssz.MarshalUint64(dst, uint64(b.Slot))
|
|
|
|
// Field (3) 'Fork'
|
|
if b.Fork == nil {
|
|
b.Fork = new(Fork)
|
|
}
|
|
if dst, err = b.Fork.MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
|
|
// Field (4) 'LatestBlockHeader'
|
|
if b.LatestBlockHeader == nil {
|
|
b.LatestBlockHeader = new(BeaconBlockHeader)
|
|
}
|
|
if dst, err = b.LatestBlockHeader.MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
|
|
// Field (5) 'BlockRoots'
|
|
if len(b.BlockRoots) != 8192 {
|
|
err = ssz.ErrVectorLength
|
|
return
|
|
}
|
|
for ii := 0; ii < 8192; ii++ {
|
|
if len(b.BlockRoots[ii]) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, b.BlockRoots[ii]...)
|
|
}
|
|
|
|
// Field (6) 'StateRoots'
|
|
if len(b.StateRoots) != 8192 {
|
|
err = ssz.ErrVectorLength
|
|
return
|
|
}
|
|
for ii := 0; ii < 8192; ii++ {
|
|
if len(b.StateRoots[ii]) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, b.StateRoots[ii]...)
|
|
}
|
|
|
|
// Offset (7) 'HistoricalRoots'
|
|
dst = ssz.WriteOffset(dst, offset)
|
|
offset += len(b.HistoricalRoots) * 32
|
|
|
|
// Field (8) 'Eth1Data'
|
|
if b.Eth1Data == nil {
|
|
b.Eth1Data = new(Eth1Data)
|
|
}
|
|
if dst, err = b.Eth1Data.MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
|
|
// Offset (9) 'Eth1DataVotes'
|
|
dst = ssz.WriteOffset(dst, offset)
|
|
offset += len(b.Eth1DataVotes) * 72
|
|
|
|
// Field (10) 'Eth1DepositIndex'
|
|
dst = ssz.MarshalUint64(dst, b.Eth1DepositIndex)
|
|
|
|
// Offset (11) 'Validators'
|
|
dst = ssz.WriteOffset(dst, offset)
|
|
offset += len(b.Validators) * 121
|
|
|
|
// Offset (12) 'Balances'
|
|
dst = ssz.WriteOffset(dst, offset)
|
|
offset += len(b.Balances) * 8
|
|
|
|
// Field (13) 'RandaoMixes'
|
|
if len(b.RandaoMixes) != 65536 {
|
|
err = ssz.ErrVectorLength
|
|
return
|
|
}
|
|
for ii := 0; ii < 65536; ii++ {
|
|
if len(b.RandaoMixes[ii]) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, b.RandaoMixes[ii]...)
|
|
}
|
|
|
|
// Field (14) 'Slashings'
|
|
if len(b.Slashings) != 8192 {
|
|
err = ssz.ErrVectorLength
|
|
return
|
|
}
|
|
for ii := 0; ii < 8192; ii++ {
|
|
dst = ssz.MarshalUint64(dst, b.Slashings[ii])
|
|
}
|
|
|
|
// Offset (15) 'PreviousEpochParticipation'
|
|
dst = ssz.WriteOffset(dst, offset)
|
|
offset += len(b.PreviousEpochParticipation)
|
|
|
|
// Offset (16) 'CurrentEpochParticipation'
|
|
dst = ssz.WriteOffset(dst, offset)
|
|
offset += len(b.CurrentEpochParticipation)
|
|
|
|
// Field (17) 'JustificationBits'
|
|
if len(b.JustificationBits) != 1 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, b.JustificationBits...)
|
|
|
|
// Field (18) 'PreviousJustifiedCheckpoint'
|
|
if b.PreviousJustifiedCheckpoint == nil {
|
|
b.PreviousJustifiedCheckpoint = new(Checkpoint)
|
|
}
|
|
if dst, err = b.PreviousJustifiedCheckpoint.MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
|
|
// Field (19) 'CurrentJustifiedCheckpoint'
|
|
if b.CurrentJustifiedCheckpoint == nil {
|
|
b.CurrentJustifiedCheckpoint = new(Checkpoint)
|
|
}
|
|
if dst, err = b.CurrentJustifiedCheckpoint.MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
|
|
// Field (20) 'FinalizedCheckpoint'
|
|
if b.FinalizedCheckpoint == nil {
|
|
b.FinalizedCheckpoint = new(Checkpoint)
|
|
}
|
|
if dst, err = b.FinalizedCheckpoint.MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
|
|
// Offset (21) 'InactivityScores'
|
|
dst = ssz.WriteOffset(dst, offset)
|
|
offset += len(b.InactivityScores) * 8
|
|
|
|
// Field (22) 'CurrentSyncCommittee'
|
|
if b.CurrentSyncCommittee == nil {
|
|
b.CurrentSyncCommittee = new(SyncCommittee)
|
|
}
|
|
if dst, err = b.CurrentSyncCommittee.MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
|
|
// Field (23) 'NextSyncCommittee'
|
|
if b.NextSyncCommittee == nil {
|
|
b.NextSyncCommittee = new(SyncCommittee)
|
|
}
|
|
if dst, err = b.NextSyncCommittee.MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
|
|
// Field (7) 'HistoricalRoots'
|
|
if len(b.HistoricalRoots) > 16777216 {
|
|
err = ssz.ErrListTooBig
|
|
return
|
|
}
|
|
for ii := 0; ii < len(b.HistoricalRoots); ii++ {
|
|
if len(b.HistoricalRoots[ii]) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, b.HistoricalRoots[ii]...)
|
|
}
|
|
|
|
// Field (9) 'Eth1DataVotes'
|
|
if len(b.Eth1DataVotes) > 2048 {
|
|
err = ssz.ErrListTooBig
|
|
return
|
|
}
|
|
for ii := 0; ii < len(b.Eth1DataVotes); ii++ {
|
|
if dst, err = b.Eth1DataVotes[ii].MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
}
|
|
|
|
// Field (11) 'Validators'
|
|
if len(b.Validators) > 1099511627776 {
|
|
err = ssz.ErrListTooBig
|
|
return
|
|
}
|
|
for ii := 0; ii < len(b.Validators); ii++ {
|
|
if dst, err = b.Validators[ii].MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
}
|
|
|
|
// Field (12) 'Balances'
|
|
if len(b.Balances) > 1099511627776 {
|
|
err = ssz.ErrListTooBig
|
|
return
|
|
}
|
|
for ii := 0; ii < len(b.Balances); ii++ {
|
|
dst = ssz.MarshalUint64(dst, b.Balances[ii])
|
|
}
|
|
|
|
// Field (15) 'PreviousEpochParticipation'
|
|
if len(b.PreviousEpochParticipation) > 1099511627776 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, b.PreviousEpochParticipation...)
|
|
|
|
// Field (16) 'CurrentEpochParticipation'
|
|
if len(b.CurrentEpochParticipation) > 1099511627776 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, b.CurrentEpochParticipation...)
|
|
|
|
// Field (21) 'InactivityScores'
|
|
if len(b.InactivityScores) > 1099511627776 {
|
|
err = ssz.ErrListTooBig
|
|
return
|
|
}
|
|
for ii := 0; ii < len(b.InactivityScores); ii++ {
|
|
dst = ssz.MarshalUint64(dst, b.InactivityScores[ii])
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// UnmarshalSSZ ssz unmarshals the BeaconStateAltair object
|
|
func (b *BeaconStateAltair) UnmarshalSSZ(buf []byte) error {
|
|
var err error
|
|
size := uint64(len(buf))
|
|
if size < 2736629 {
|
|
return ssz.ErrSize
|
|
}
|
|
|
|
tail := buf
|
|
var o7, o9, o11, o12, o15, o16, o21 uint64
|
|
|
|
// Field (0) 'GenesisTime'
|
|
b.GenesisTime = ssz.UnmarshallUint64(buf[0:8])
|
|
|
|
// Field (1) 'GenesisValidatorsRoot'
|
|
if cap(b.GenesisValidatorsRoot) == 0 {
|
|
b.GenesisValidatorsRoot = make([]byte, 0, len(buf[8:40]))
|
|
}
|
|
b.GenesisValidatorsRoot = append(b.GenesisValidatorsRoot, buf[8:40]...)
|
|
|
|
// Field (2) 'Slot'
|
|
b.Slot = github_com_prysmaticlabs_eth2_types.Slot(ssz.UnmarshallUint64(buf[40:48]))
|
|
|
|
// Field (3) 'Fork'
|
|
if b.Fork == nil {
|
|
b.Fork = new(Fork)
|
|
}
|
|
if err = b.Fork.UnmarshalSSZ(buf[48:64]); err != nil {
|
|
return err
|
|
}
|
|
|
|
// Field (4) 'LatestBlockHeader'
|
|
if b.LatestBlockHeader == nil {
|
|
b.LatestBlockHeader = new(BeaconBlockHeader)
|
|
}
|
|
if err = b.LatestBlockHeader.UnmarshalSSZ(buf[64:176]); err != nil {
|
|
return err
|
|
}
|
|
|
|
// Field (5) 'BlockRoots'
|
|
b.BlockRoots = make([][]byte, 8192)
|
|
for ii := 0; ii < 8192; ii++ {
|
|
if cap(b.BlockRoots[ii]) == 0 {
|
|
b.BlockRoots[ii] = make([]byte, 0, len(buf[176:262320][ii*32:(ii+1)*32]))
|
|
}
|
|
b.BlockRoots[ii] = append(b.BlockRoots[ii], buf[176:262320][ii*32:(ii+1)*32]...)
|
|
}
|
|
|
|
// Field (6) 'StateRoots'
|
|
b.StateRoots = make([][]byte, 8192)
|
|
for ii := 0; ii < 8192; ii++ {
|
|
if cap(b.StateRoots[ii]) == 0 {
|
|
b.StateRoots[ii] = make([]byte, 0, len(buf[262320:524464][ii*32:(ii+1)*32]))
|
|
}
|
|
b.StateRoots[ii] = append(b.StateRoots[ii], buf[262320:524464][ii*32:(ii+1)*32]...)
|
|
}
|
|
|
|
// Offset (7) 'HistoricalRoots'
|
|
if o7 = ssz.ReadOffset(buf[524464:524468]); o7 > size {
|
|
return ssz.ErrOffset
|
|
}
|
|
|
|
if o7 < 2736629 {
|
|
return ssz.ErrInvalidVariableOffset
|
|
}
|
|
|
|
// Field (8) 'Eth1Data'
|
|
if b.Eth1Data == nil {
|
|
b.Eth1Data = new(Eth1Data)
|
|
}
|
|
if err = b.Eth1Data.UnmarshalSSZ(buf[524468:524540]); err != nil {
|
|
return err
|
|
}
|
|
|
|
// Offset (9) 'Eth1DataVotes'
|
|
if o9 = ssz.ReadOffset(buf[524540:524544]); o9 > size || o7 > o9 {
|
|
return ssz.ErrOffset
|
|
}
|
|
|
|
// Field (10) 'Eth1DepositIndex'
|
|
b.Eth1DepositIndex = ssz.UnmarshallUint64(buf[524544:524552])
|
|
|
|
// Offset (11) 'Validators'
|
|
if o11 = ssz.ReadOffset(buf[524552:524556]); o11 > size || o9 > o11 {
|
|
return ssz.ErrOffset
|
|
}
|
|
|
|
// Offset (12) 'Balances'
|
|
if o12 = ssz.ReadOffset(buf[524556:524560]); o12 > size || o11 > o12 {
|
|
return ssz.ErrOffset
|
|
}
|
|
|
|
// Field (13) 'RandaoMixes'
|
|
b.RandaoMixes = make([][]byte, 65536)
|
|
for ii := 0; ii < 65536; ii++ {
|
|
if cap(b.RandaoMixes[ii]) == 0 {
|
|
b.RandaoMixes[ii] = make([]byte, 0, len(buf[524560:2621712][ii*32:(ii+1)*32]))
|
|
}
|
|
b.RandaoMixes[ii] = append(b.RandaoMixes[ii], buf[524560:2621712][ii*32:(ii+1)*32]...)
|
|
}
|
|
|
|
// Field (14) 'Slashings'
|
|
b.Slashings = ssz.ExtendUint64(b.Slashings, 8192)
|
|
for ii := 0; ii < 8192; ii++ {
|
|
b.Slashings[ii] = ssz.UnmarshallUint64(buf[2621712:2687248][ii*8 : (ii+1)*8])
|
|
}
|
|
|
|
// Offset (15) 'PreviousEpochParticipation'
|
|
if o15 = ssz.ReadOffset(buf[2687248:2687252]); o15 > size || o12 > o15 {
|
|
return ssz.ErrOffset
|
|
}
|
|
|
|
// Offset (16) 'CurrentEpochParticipation'
|
|
if o16 = ssz.ReadOffset(buf[2687252:2687256]); o16 > size || o15 > o16 {
|
|
return ssz.ErrOffset
|
|
}
|
|
|
|
// Field (17) 'JustificationBits'
|
|
if cap(b.JustificationBits) == 0 {
|
|
b.JustificationBits = make([]byte, 0, len(buf[2687256:2687257]))
|
|
}
|
|
b.JustificationBits = append(b.JustificationBits, buf[2687256:2687257]...)
|
|
|
|
// Field (18) 'PreviousJustifiedCheckpoint'
|
|
if b.PreviousJustifiedCheckpoint == nil {
|
|
b.PreviousJustifiedCheckpoint = new(Checkpoint)
|
|
}
|
|
if err = b.PreviousJustifiedCheckpoint.UnmarshalSSZ(buf[2687257:2687297]); err != nil {
|
|
return err
|
|
}
|
|
|
|
// Field (19) 'CurrentJustifiedCheckpoint'
|
|
if b.CurrentJustifiedCheckpoint == nil {
|
|
b.CurrentJustifiedCheckpoint = new(Checkpoint)
|
|
}
|
|
if err = b.CurrentJustifiedCheckpoint.UnmarshalSSZ(buf[2687297:2687337]); err != nil {
|
|
return err
|
|
}
|
|
|
|
// Field (20) 'FinalizedCheckpoint'
|
|
if b.FinalizedCheckpoint == nil {
|
|
b.FinalizedCheckpoint = new(Checkpoint)
|
|
}
|
|
if err = b.FinalizedCheckpoint.UnmarshalSSZ(buf[2687337:2687377]); err != nil {
|
|
return err
|
|
}
|
|
|
|
// Offset (21) 'InactivityScores'
|
|
if o21 = ssz.ReadOffset(buf[2687377:2687381]); o21 > size || o16 > o21 {
|
|
return ssz.ErrOffset
|
|
}
|
|
|
|
// Field (22) 'CurrentSyncCommittee'
|
|
if b.CurrentSyncCommittee == nil {
|
|
b.CurrentSyncCommittee = new(SyncCommittee)
|
|
}
|
|
if err = b.CurrentSyncCommittee.UnmarshalSSZ(buf[2687381:2712005]); err != nil {
|
|
return err
|
|
}
|
|
|
|
// Field (23) 'NextSyncCommittee'
|
|
if b.NextSyncCommittee == nil {
|
|
b.NextSyncCommittee = new(SyncCommittee)
|
|
}
|
|
if err = b.NextSyncCommittee.UnmarshalSSZ(buf[2712005:2736629]); err != nil {
|
|
return err
|
|
}
|
|
|
|
// Field (7) 'HistoricalRoots'
|
|
{
|
|
buf = tail[o7:o9]
|
|
num, err := ssz.DivideInt2(len(buf), 32, 16777216)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
b.HistoricalRoots = make([][]byte, num)
|
|
for ii := 0; ii < num; ii++ {
|
|
if cap(b.HistoricalRoots[ii]) == 0 {
|
|
b.HistoricalRoots[ii] = make([]byte, 0, len(buf[ii*32:(ii+1)*32]))
|
|
}
|
|
b.HistoricalRoots[ii] = append(b.HistoricalRoots[ii], buf[ii*32:(ii+1)*32]...)
|
|
}
|
|
}
|
|
|
|
// Field (9) 'Eth1DataVotes'
|
|
{
|
|
buf = tail[o9:o11]
|
|
num, err := ssz.DivideInt2(len(buf), 72, 2048)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
b.Eth1DataVotes = make([]*Eth1Data, num)
|
|
for ii := 0; ii < num; ii++ {
|
|
if b.Eth1DataVotes[ii] == nil {
|
|
b.Eth1DataVotes[ii] = new(Eth1Data)
|
|
}
|
|
if err = b.Eth1DataVotes[ii].UnmarshalSSZ(buf[ii*72 : (ii+1)*72]); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
}
|
|
|
|
// Field (11) 'Validators'
|
|
{
|
|
buf = tail[o11:o12]
|
|
num, err := ssz.DivideInt2(len(buf), 121, 1099511627776)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
b.Validators = make([]*Validator, num)
|
|
for ii := 0; ii < num; ii++ {
|
|
if b.Validators[ii] == nil {
|
|
b.Validators[ii] = new(Validator)
|
|
}
|
|
if err = b.Validators[ii].UnmarshalSSZ(buf[ii*121 : (ii+1)*121]); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
}
|
|
|
|
// Field (12) 'Balances'
|
|
{
|
|
buf = tail[o12:o15]
|
|
num, err := ssz.DivideInt2(len(buf), 8, 1099511627776)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
b.Balances = ssz.ExtendUint64(b.Balances, num)
|
|
for ii := 0; ii < num; ii++ {
|
|
b.Balances[ii] = ssz.UnmarshallUint64(buf[ii*8 : (ii+1)*8])
|
|
}
|
|
}
|
|
|
|
// Field (15) 'PreviousEpochParticipation'
|
|
{
|
|
buf = tail[o15:o16]
|
|
if len(buf) > 1099511627776 {
|
|
return ssz.ErrBytesLength
|
|
}
|
|
if cap(b.PreviousEpochParticipation) == 0 {
|
|
b.PreviousEpochParticipation = make([]byte, 0, len(buf))
|
|
}
|
|
b.PreviousEpochParticipation = append(b.PreviousEpochParticipation, buf...)
|
|
}
|
|
|
|
// Field (16) 'CurrentEpochParticipation'
|
|
{
|
|
buf = tail[o16:o21]
|
|
if len(buf) > 1099511627776 {
|
|
return ssz.ErrBytesLength
|
|
}
|
|
if cap(b.CurrentEpochParticipation) == 0 {
|
|
b.CurrentEpochParticipation = make([]byte, 0, len(buf))
|
|
}
|
|
b.CurrentEpochParticipation = append(b.CurrentEpochParticipation, buf...)
|
|
}
|
|
|
|
// Field (21) 'InactivityScores'
|
|
{
|
|
buf = tail[o21:]
|
|
num, err := ssz.DivideInt2(len(buf), 8, 1099511627776)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
b.InactivityScores = ssz.ExtendUint64(b.InactivityScores, num)
|
|
for ii := 0; ii < num; ii++ {
|
|
b.InactivityScores[ii] = ssz.UnmarshallUint64(buf[ii*8 : (ii+1)*8])
|
|
}
|
|
}
|
|
return err
|
|
}
|
|
|
|
// SizeSSZ returns the ssz encoded size in bytes for the BeaconStateAltair object
|
|
func (b *BeaconStateAltair) SizeSSZ() (size int) {
|
|
size = 2736629
|
|
|
|
// Field (7) 'HistoricalRoots'
|
|
size += len(b.HistoricalRoots) * 32
|
|
|
|
// Field (9) 'Eth1DataVotes'
|
|
size += len(b.Eth1DataVotes) * 72
|
|
|
|
// Field (11) 'Validators'
|
|
size += len(b.Validators) * 121
|
|
|
|
// Field (12) 'Balances'
|
|
size += len(b.Balances) * 8
|
|
|
|
// Field (15) 'PreviousEpochParticipation'
|
|
size += len(b.PreviousEpochParticipation)
|
|
|
|
// Field (16) 'CurrentEpochParticipation'
|
|
size += len(b.CurrentEpochParticipation)
|
|
|
|
// Field (21) 'InactivityScores'
|
|
size += len(b.InactivityScores) * 8
|
|
|
|
return
|
|
}
|
|
|
|
// HashTreeRoot ssz hashes the BeaconStateAltair object
|
|
func (b *BeaconStateAltair) HashTreeRoot() ([32]byte, error) {
|
|
return ssz.HashWithDefaultHasher(b)
|
|
}
|
|
|
|
// HashTreeRootWith ssz hashes the BeaconStateAltair object with a hasher
|
|
func (b *BeaconStateAltair) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|
indx := hh.Index()
|
|
|
|
// Field (0) 'GenesisTime'
|
|
hh.PutUint64(b.GenesisTime)
|
|
|
|
// Field (1) 'GenesisValidatorsRoot'
|
|
if len(b.GenesisValidatorsRoot) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(b.GenesisValidatorsRoot)
|
|
|
|
// Field (2) 'Slot'
|
|
hh.PutUint64(uint64(b.Slot))
|
|
|
|
// Field (3) 'Fork'
|
|
if err = b.Fork.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
|
|
// Field (4) 'LatestBlockHeader'
|
|
if err = b.LatestBlockHeader.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
|
|
// Field (5) 'BlockRoots'
|
|
{
|
|
if len(b.BlockRoots) != 8192 {
|
|
err = ssz.ErrVectorLength
|
|
return
|
|
}
|
|
subIndx := hh.Index()
|
|
for _, i := range b.BlockRoots {
|
|
if len(i) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.Append(i)
|
|
}
|
|
hh.Merkleize(subIndx)
|
|
}
|
|
|
|
// Field (6) 'StateRoots'
|
|
{
|
|
if len(b.StateRoots) != 8192 {
|
|
err = ssz.ErrVectorLength
|
|
return
|
|
}
|
|
subIndx := hh.Index()
|
|
for _, i := range b.StateRoots {
|
|
if len(i) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.Append(i)
|
|
}
|
|
hh.Merkleize(subIndx)
|
|
}
|
|
|
|
// Field (7) 'HistoricalRoots'
|
|
{
|
|
if len(b.HistoricalRoots) > 16777216 {
|
|
err = ssz.ErrListTooBig
|
|
return
|
|
}
|
|
subIndx := hh.Index()
|
|
for _, i := range b.HistoricalRoots {
|
|
if len(i) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.Append(i)
|
|
}
|
|
numItems := uint64(len(b.HistoricalRoots))
|
|
hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(16777216, numItems, 32))
|
|
}
|
|
|
|
// Field (8) 'Eth1Data'
|
|
if err = b.Eth1Data.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
|
|
// Field (9) 'Eth1DataVotes'
|
|
{
|
|
subIndx := hh.Index()
|
|
num := uint64(len(b.Eth1DataVotes))
|
|
if num > 2048 {
|
|
err = ssz.ErrIncorrectListSize
|
|
return
|
|
}
|
|
for _, elem := range b.Eth1DataVotes {
|
|
if err = elem.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
}
|
|
hh.MerkleizeWithMixin(subIndx, num, 2048)
|
|
}
|
|
|
|
// Field (10) 'Eth1DepositIndex'
|
|
hh.PutUint64(b.Eth1DepositIndex)
|
|
|
|
// Field (11) 'Validators'
|
|
{
|
|
subIndx := hh.Index()
|
|
num := uint64(len(b.Validators))
|
|
if num > 1099511627776 {
|
|
err = ssz.ErrIncorrectListSize
|
|
return
|
|
}
|
|
for _, elem := range b.Validators {
|
|
if err = elem.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
}
|
|
hh.MerkleizeWithMixin(subIndx, num, 1099511627776)
|
|
}
|
|
|
|
// Field (12) 'Balances'
|
|
{
|
|
if len(b.Balances) > 1099511627776 {
|
|
err = ssz.ErrListTooBig
|
|
return
|
|
}
|
|
subIndx := hh.Index()
|
|
for _, i := range b.Balances {
|
|
hh.AppendUint64(i)
|
|
}
|
|
hh.FillUpTo32()
|
|
numItems := uint64(len(b.Balances))
|
|
hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(1099511627776, numItems, 8))
|
|
}
|
|
|
|
// Field (13) 'RandaoMixes'
|
|
{
|
|
if len(b.RandaoMixes) != 65536 {
|
|
err = ssz.ErrVectorLength
|
|
return
|
|
}
|
|
subIndx := hh.Index()
|
|
for _, i := range b.RandaoMixes {
|
|
if len(i) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.Append(i)
|
|
}
|
|
hh.Merkleize(subIndx)
|
|
}
|
|
|
|
// Field (14) 'Slashings'
|
|
{
|
|
if len(b.Slashings) != 8192 {
|
|
err = ssz.ErrVectorLength
|
|
return
|
|
}
|
|
subIndx := hh.Index()
|
|
for _, i := range b.Slashings {
|
|
hh.AppendUint64(i)
|
|
}
|
|
hh.Merkleize(subIndx)
|
|
}
|
|
|
|
// Field (15) 'PreviousEpochParticipation'
|
|
{
|
|
elemIndx := hh.Index()
|
|
byteLen := uint64(len(b.PreviousEpochParticipation))
|
|
if byteLen > 1099511627776 {
|
|
err = ssz.ErrIncorrectListSize
|
|
return
|
|
}
|
|
hh.PutBytes(b.PreviousEpochParticipation)
|
|
hh.MerkleizeWithMixin(elemIndx, byteLen, (1099511627776+31)/32)
|
|
}
|
|
|
|
// Field (16) 'CurrentEpochParticipation'
|
|
{
|
|
elemIndx := hh.Index()
|
|
byteLen := uint64(len(b.CurrentEpochParticipation))
|
|
if byteLen > 1099511627776 {
|
|
err = ssz.ErrIncorrectListSize
|
|
return
|
|
}
|
|
hh.PutBytes(b.CurrentEpochParticipation)
|
|
hh.MerkleizeWithMixin(elemIndx, byteLen, (1099511627776+31)/32)
|
|
}
|
|
|
|
// Field (17) 'JustificationBits'
|
|
if len(b.JustificationBits) != 1 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(b.JustificationBits)
|
|
|
|
// Field (18) 'PreviousJustifiedCheckpoint'
|
|
if err = b.PreviousJustifiedCheckpoint.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
|
|
// Field (19) 'CurrentJustifiedCheckpoint'
|
|
if err = b.CurrentJustifiedCheckpoint.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
|
|
// Field (20) 'FinalizedCheckpoint'
|
|
if err = b.FinalizedCheckpoint.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
|
|
// Field (21) 'InactivityScores'
|
|
{
|
|
if len(b.InactivityScores) > 1099511627776 {
|
|
err = ssz.ErrListTooBig
|
|
return
|
|
}
|
|
subIndx := hh.Index()
|
|
for _, i := range b.InactivityScores {
|
|
hh.AppendUint64(i)
|
|
}
|
|
hh.FillUpTo32()
|
|
numItems := uint64(len(b.InactivityScores))
|
|
hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(1099511627776, numItems, 8))
|
|
}
|
|
|
|
// Field (22) 'CurrentSyncCommittee'
|
|
if err = b.CurrentSyncCommittee.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
|
|
// Field (23) 'NextSyncCommittee'
|
|
if err = b.NextSyncCommittee.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
|
|
hh.Merkleize(indx)
|
|
return
|
|
}
|
|
|
|
// MarshalSSZ ssz marshals the Fork object
|
|
func (f *Fork) MarshalSSZ() ([]byte, error) {
|
|
return ssz.MarshalSSZ(f)
|
|
}
|
|
|
|
// MarshalSSZTo ssz marshals the Fork object to a target array
|
|
func (f *Fork) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
|
dst = buf
|
|
|
|
// Field (0) 'PreviousVersion'
|
|
if len(f.PreviousVersion) != 4 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, f.PreviousVersion...)
|
|
|
|
// Field (1) 'CurrentVersion'
|
|
if len(f.CurrentVersion) != 4 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, f.CurrentVersion...)
|
|
|
|
// Field (2) 'Epoch'
|
|
dst = ssz.MarshalUint64(dst, uint64(f.Epoch))
|
|
|
|
return
|
|
}
|
|
|
|
// UnmarshalSSZ ssz unmarshals the Fork object
|
|
func (f *Fork) UnmarshalSSZ(buf []byte) error {
|
|
var err error
|
|
size := uint64(len(buf))
|
|
if size != 16 {
|
|
return ssz.ErrSize
|
|
}
|
|
|
|
// Field (0) 'PreviousVersion'
|
|
if cap(f.PreviousVersion) == 0 {
|
|
f.PreviousVersion = make([]byte, 0, len(buf[0:4]))
|
|
}
|
|
f.PreviousVersion = append(f.PreviousVersion, buf[0:4]...)
|
|
|
|
// Field (1) 'CurrentVersion'
|
|
if cap(f.CurrentVersion) == 0 {
|
|
f.CurrentVersion = make([]byte, 0, len(buf[4:8]))
|
|
}
|
|
f.CurrentVersion = append(f.CurrentVersion, buf[4:8]...)
|
|
|
|
// Field (2) 'Epoch'
|
|
f.Epoch = github_com_prysmaticlabs_eth2_types.Epoch(ssz.UnmarshallUint64(buf[8:16]))
|
|
|
|
return err
|
|
}
|
|
|
|
// SizeSSZ returns the ssz encoded size in bytes for the Fork object
|
|
func (f *Fork) SizeSSZ() (size int) {
|
|
size = 16
|
|
return
|
|
}
|
|
|
|
// HashTreeRoot ssz hashes the Fork object
|
|
func (f *Fork) HashTreeRoot() ([32]byte, error) {
|
|
return ssz.HashWithDefaultHasher(f)
|
|
}
|
|
|
|
// HashTreeRootWith ssz hashes the Fork object with a hasher
|
|
func (f *Fork) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|
indx := hh.Index()
|
|
|
|
// Field (0) 'PreviousVersion'
|
|
if len(f.PreviousVersion) != 4 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(f.PreviousVersion)
|
|
|
|
// Field (1) 'CurrentVersion'
|
|
if len(f.CurrentVersion) != 4 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(f.CurrentVersion)
|
|
|
|
// Field (2) 'Epoch'
|
|
hh.PutUint64(uint64(f.Epoch))
|
|
|
|
hh.Merkleize(indx)
|
|
return
|
|
}
|
|
|
|
// MarshalSSZ ssz marshals the PendingAttestation object
|
|
func (p *PendingAttestation) MarshalSSZ() ([]byte, error) {
|
|
return ssz.MarshalSSZ(p)
|
|
}
|
|
|
|
// MarshalSSZTo ssz marshals the PendingAttestation object to a target array
|
|
func (p *PendingAttestation) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
|
dst = buf
|
|
offset := int(148)
|
|
|
|
// Offset (0) 'AggregationBits'
|
|
dst = ssz.WriteOffset(dst, offset)
|
|
offset += len(p.AggregationBits)
|
|
|
|
// Field (1) 'Data'
|
|
if p.Data == nil {
|
|
p.Data = new(AttestationData)
|
|
}
|
|
if dst, err = p.Data.MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
|
|
// Field (2) 'InclusionDelay'
|
|
dst = ssz.MarshalUint64(dst, uint64(p.InclusionDelay))
|
|
|
|
// Field (3) 'ProposerIndex'
|
|
dst = ssz.MarshalUint64(dst, uint64(p.ProposerIndex))
|
|
|
|
// Field (0) 'AggregationBits'
|
|
if len(p.AggregationBits) > 2048 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, p.AggregationBits...)
|
|
|
|
return
|
|
}
|
|
|
|
// UnmarshalSSZ ssz unmarshals the PendingAttestation object
|
|
func (p *PendingAttestation) UnmarshalSSZ(buf []byte) error {
|
|
var err error
|
|
size := uint64(len(buf))
|
|
if size < 148 {
|
|
return ssz.ErrSize
|
|
}
|
|
|
|
tail := buf
|
|
var o0 uint64
|
|
|
|
// Offset (0) 'AggregationBits'
|
|
if o0 = ssz.ReadOffset(buf[0:4]); o0 > size {
|
|
return ssz.ErrOffset
|
|
}
|
|
|
|
if o0 < 148 {
|
|
return ssz.ErrInvalidVariableOffset
|
|
}
|
|
|
|
// Field (1) 'Data'
|
|
if p.Data == nil {
|
|
p.Data = new(AttestationData)
|
|
}
|
|
if err = p.Data.UnmarshalSSZ(buf[4:132]); err != nil {
|
|
return err
|
|
}
|
|
|
|
// Field (2) 'InclusionDelay'
|
|
p.InclusionDelay = github_com_prysmaticlabs_eth2_types.Slot(ssz.UnmarshallUint64(buf[132:140]))
|
|
|
|
// Field (3) 'ProposerIndex'
|
|
p.ProposerIndex = github_com_prysmaticlabs_eth2_types.ValidatorIndex(ssz.UnmarshallUint64(buf[140:148]))
|
|
|
|
// Field (0) 'AggregationBits'
|
|
{
|
|
buf = tail[o0:]
|
|
if err = ssz.ValidateBitlist(buf, 2048); err != nil {
|
|
return err
|
|
}
|
|
if cap(p.AggregationBits) == 0 {
|
|
p.AggregationBits = make([]byte, 0, len(buf))
|
|
}
|
|
p.AggregationBits = append(p.AggregationBits, buf...)
|
|
}
|
|
return err
|
|
}
|
|
|
|
// SizeSSZ returns the ssz encoded size in bytes for the PendingAttestation object
|
|
func (p *PendingAttestation) SizeSSZ() (size int) {
|
|
size = 148
|
|
|
|
// Field (0) 'AggregationBits'
|
|
size += len(p.AggregationBits)
|
|
|
|
return
|
|
}
|
|
|
|
// HashTreeRoot ssz hashes the PendingAttestation object
|
|
func (p *PendingAttestation) HashTreeRoot() ([32]byte, error) {
|
|
return ssz.HashWithDefaultHasher(p)
|
|
}
|
|
|
|
// HashTreeRootWith ssz hashes the PendingAttestation object with a hasher
|
|
func (p *PendingAttestation) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|
indx := hh.Index()
|
|
|
|
// Field (0) 'AggregationBits'
|
|
if len(p.AggregationBits) == 0 {
|
|
err = ssz.ErrEmptyBitlist
|
|
return
|
|
}
|
|
hh.PutBitlist(p.AggregationBits, 2048)
|
|
|
|
// Field (1) 'Data'
|
|
if err = p.Data.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
|
|
// Field (2) 'InclusionDelay'
|
|
hh.PutUint64(uint64(p.InclusionDelay))
|
|
|
|
// Field (3) 'ProposerIndex'
|
|
hh.PutUint64(uint64(p.ProposerIndex))
|
|
|
|
hh.Merkleize(indx)
|
|
return
|
|
}
|
|
|
|
// MarshalSSZ ssz marshals the HistoricalBatch object
|
|
func (h *HistoricalBatch) MarshalSSZ() ([]byte, error) {
|
|
return ssz.MarshalSSZ(h)
|
|
}
|
|
|
|
// MarshalSSZTo ssz marshals the HistoricalBatch object to a target array
|
|
func (h *HistoricalBatch) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
|
dst = buf
|
|
|
|
// Field (0) 'BlockRoots'
|
|
if len(h.BlockRoots) != 8192 {
|
|
err = ssz.ErrVectorLength
|
|
return
|
|
}
|
|
for ii := 0; ii < 8192; ii++ {
|
|
if len(h.BlockRoots[ii]) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, h.BlockRoots[ii]...)
|
|
}
|
|
|
|
// Field (1) 'StateRoots'
|
|
if len(h.StateRoots) != 8192 {
|
|
err = ssz.ErrVectorLength
|
|
return
|
|
}
|
|
for ii := 0; ii < 8192; ii++ {
|
|
if len(h.StateRoots[ii]) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, h.StateRoots[ii]...)
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// UnmarshalSSZ ssz unmarshals the HistoricalBatch object
|
|
func (h *HistoricalBatch) UnmarshalSSZ(buf []byte) error {
|
|
var err error
|
|
size := uint64(len(buf))
|
|
if size != 524288 {
|
|
return ssz.ErrSize
|
|
}
|
|
|
|
// Field (0) 'BlockRoots'
|
|
h.BlockRoots = make([][]byte, 8192)
|
|
for ii := 0; ii < 8192; ii++ {
|
|
if cap(h.BlockRoots[ii]) == 0 {
|
|
h.BlockRoots[ii] = make([]byte, 0, len(buf[0:262144][ii*32:(ii+1)*32]))
|
|
}
|
|
h.BlockRoots[ii] = append(h.BlockRoots[ii], buf[0:262144][ii*32:(ii+1)*32]...)
|
|
}
|
|
|
|
// Field (1) 'StateRoots'
|
|
h.StateRoots = make([][]byte, 8192)
|
|
for ii := 0; ii < 8192; ii++ {
|
|
if cap(h.StateRoots[ii]) == 0 {
|
|
h.StateRoots[ii] = make([]byte, 0, len(buf[262144:524288][ii*32:(ii+1)*32]))
|
|
}
|
|
h.StateRoots[ii] = append(h.StateRoots[ii], buf[262144:524288][ii*32:(ii+1)*32]...)
|
|
}
|
|
|
|
return err
|
|
}
|
|
|
|
// SizeSSZ returns the ssz encoded size in bytes for the HistoricalBatch object
|
|
func (h *HistoricalBatch) SizeSSZ() (size int) {
|
|
size = 524288
|
|
return
|
|
}
|
|
|
|
// HashTreeRoot ssz hashes the HistoricalBatch object
|
|
func (h *HistoricalBatch) HashTreeRoot() ([32]byte, error) {
|
|
return ssz.HashWithDefaultHasher(h)
|
|
}
|
|
|
|
// HashTreeRootWith ssz hashes the HistoricalBatch object with a hasher
|
|
func (h *HistoricalBatch) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|
indx := hh.Index()
|
|
|
|
// Field (0) 'BlockRoots'
|
|
{
|
|
if len(h.BlockRoots) != 8192 {
|
|
err = ssz.ErrVectorLength
|
|
return
|
|
}
|
|
subIndx := hh.Index()
|
|
for _, i := range h.BlockRoots {
|
|
if len(i) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.Append(i)
|
|
}
|
|
hh.Merkleize(subIndx)
|
|
}
|
|
|
|
// Field (1) 'StateRoots'
|
|
{
|
|
if len(h.StateRoots) != 8192 {
|
|
err = ssz.ErrVectorLength
|
|
return
|
|
}
|
|
subIndx := hh.Index()
|
|
for _, i := range h.StateRoots {
|
|
if len(i) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.Append(i)
|
|
}
|
|
hh.Merkleize(subIndx)
|
|
}
|
|
|
|
hh.Merkleize(indx)
|
|
return
|
|
}
|
|
|
|
// MarshalSSZ ssz marshals the SigningData object
|
|
func (s *SigningData) MarshalSSZ() ([]byte, error) {
|
|
return ssz.MarshalSSZ(s)
|
|
}
|
|
|
|
// MarshalSSZTo ssz marshals the SigningData object to a target array
|
|
func (s *SigningData) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
|
dst = buf
|
|
|
|
// Field (0) 'ObjectRoot'
|
|
if len(s.ObjectRoot) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, s.ObjectRoot...)
|
|
|
|
// Field (1) 'Domain'
|
|
if len(s.Domain) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, s.Domain...)
|
|
|
|
return
|
|
}
|
|
|
|
// UnmarshalSSZ ssz unmarshals the SigningData object
|
|
func (s *SigningData) UnmarshalSSZ(buf []byte) error {
|
|
var err error
|
|
size := uint64(len(buf))
|
|
if size != 64 {
|
|
return ssz.ErrSize
|
|
}
|
|
|
|
// Field (0) 'ObjectRoot'
|
|
if cap(s.ObjectRoot) == 0 {
|
|
s.ObjectRoot = make([]byte, 0, len(buf[0:32]))
|
|
}
|
|
s.ObjectRoot = append(s.ObjectRoot, buf[0:32]...)
|
|
|
|
// Field (1) 'Domain'
|
|
if cap(s.Domain) == 0 {
|
|
s.Domain = make([]byte, 0, len(buf[32:64]))
|
|
}
|
|
s.Domain = append(s.Domain, buf[32:64]...)
|
|
|
|
return err
|
|
}
|
|
|
|
// SizeSSZ returns the ssz encoded size in bytes for the SigningData object
|
|
func (s *SigningData) SizeSSZ() (size int) {
|
|
size = 64
|
|
return
|
|
}
|
|
|
|
// HashTreeRoot ssz hashes the SigningData object
|
|
func (s *SigningData) HashTreeRoot() ([32]byte, error) {
|
|
return ssz.HashWithDefaultHasher(s)
|
|
}
|
|
|
|
// HashTreeRootWith ssz hashes the SigningData object with a hasher
|
|
func (s *SigningData) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|
indx := hh.Index()
|
|
|
|
// Field (0) 'ObjectRoot'
|
|
if len(s.ObjectRoot) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(s.ObjectRoot)
|
|
|
|
// Field (1) 'Domain'
|
|
if len(s.Domain) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(s.Domain)
|
|
|
|
hh.Merkleize(indx)
|
|
return
|
|
}
|
|
|
|
// MarshalSSZ ssz marshals the ForkData object
|
|
func (f *ForkData) MarshalSSZ() ([]byte, error) {
|
|
return ssz.MarshalSSZ(f)
|
|
}
|
|
|
|
// MarshalSSZTo ssz marshals the ForkData object to a target array
|
|
func (f *ForkData) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
|
dst = buf
|
|
|
|
// Field (0) 'CurrentVersion'
|
|
if len(f.CurrentVersion) != 4 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, f.CurrentVersion...)
|
|
|
|
// Field (1) 'GenesisValidatorsRoot'
|
|
if len(f.GenesisValidatorsRoot) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, f.GenesisValidatorsRoot...)
|
|
|
|
return
|
|
}
|
|
|
|
// UnmarshalSSZ ssz unmarshals the ForkData object
|
|
func (f *ForkData) UnmarshalSSZ(buf []byte) error {
|
|
var err error
|
|
size := uint64(len(buf))
|
|
if size != 36 {
|
|
return ssz.ErrSize
|
|
}
|
|
|
|
// Field (0) 'CurrentVersion'
|
|
if cap(f.CurrentVersion) == 0 {
|
|
f.CurrentVersion = make([]byte, 0, len(buf[0:4]))
|
|
}
|
|
f.CurrentVersion = append(f.CurrentVersion, buf[0:4]...)
|
|
|
|
// Field (1) 'GenesisValidatorsRoot'
|
|
if cap(f.GenesisValidatorsRoot) == 0 {
|
|
f.GenesisValidatorsRoot = make([]byte, 0, len(buf[4:36]))
|
|
}
|
|
f.GenesisValidatorsRoot = append(f.GenesisValidatorsRoot, buf[4:36]...)
|
|
|
|
return err
|
|
}
|
|
|
|
// SizeSSZ returns the ssz encoded size in bytes for the ForkData object
|
|
func (f *ForkData) SizeSSZ() (size int) {
|
|
size = 36
|
|
return
|
|
}
|
|
|
|
// HashTreeRoot ssz hashes the ForkData object
|
|
func (f *ForkData) HashTreeRoot() ([32]byte, error) {
|
|
return ssz.HashWithDefaultHasher(f)
|
|
}
|
|
|
|
// HashTreeRootWith ssz hashes the ForkData object with a hasher
|
|
func (f *ForkData) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|
indx := hh.Index()
|
|
|
|
// Field (0) 'CurrentVersion'
|
|
if len(f.CurrentVersion) != 4 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(f.CurrentVersion)
|
|
|
|
// Field (1) 'GenesisValidatorsRoot'
|
|
if len(f.GenesisValidatorsRoot) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(f.GenesisValidatorsRoot)
|
|
|
|
hh.Merkleize(indx)
|
|
return
|
|
}
|
|
|
|
// MarshalSSZ ssz marshals the DepositMessage object
|
|
func (d *DepositMessage) MarshalSSZ() ([]byte, error) {
|
|
return ssz.MarshalSSZ(d)
|
|
}
|
|
|
|
// MarshalSSZTo ssz marshals the DepositMessage object to a target array
|
|
func (d *DepositMessage) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
|
dst = buf
|
|
|
|
// Field (0) 'PublicKey'
|
|
if len(d.PublicKey) != 48 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, d.PublicKey...)
|
|
|
|
// Field (1) 'WithdrawalCredentials'
|
|
if len(d.WithdrawalCredentials) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, d.WithdrawalCredentials...)
|
|
|
|
// Field (2) 'Amount'
|
|
dst = ssz.MarshalUint64(dst, d.Amount)
|
|
|
|
return
|
|
}
|
|
|
|
// UnmarshalSSZ ssz unmarshals the DepositMessage object
|
|
func (d *DepositMessage) UnmarshalSSZ(buf []byte) error {
|
|
var err error
|
|
size := uint64(len(buf))
|
|
if size != 88 {
|
|
return ssz.ErrSize
|
|
}
|
|
|
|
// Field (0) 'PublicKey'
|
|
if cap(d.PublicKey) == 0 {
|
|
d.PublicKey = make([]byte, 0, len(buf[0:48]))
|
|
}
|
|
d.PublicKey = append(d.PublicKey, buf[0:48]...)
|
|
|
|
// Field (1) 'WithdrawalCredentials'
|
|
if cap(d.WithdrawalCredentials) == 0 {
|
|
d.WithdrawalCredentials = make([]byte, 0, len(buf[48:80]))
|
|
}
|
|
d.WithdrawalCredentials = append(d.WithdrawalCredentials, buf[48:80]...)
|
|
|
|
// Field (2) 'Amount'
|
|
d.Amount = ssz.UnmarshallUint64(buf[80:88])
|
|
|
|
return err
|
|
}
|
|
|
|
// SizeSSZ returns the ssz encoded size in bytes for the DepositMessage object
|
|
func (d *DepositMessage) SizeSSZ() (size int) {
|
|
size = 88
|
|
return
|
|
}
|
|
|
|
// HashTreeRoot ssz hashes the DepositMessage object
|
|
func (d *DepositMessage) HashTreeRoot() ([32]byte, error) {
|
|
return ssz.HashWithDefaultHasher(d)
|
|
}
|
|
|
|
// HashTreeRootWith ssz hashes the DepositMessage object with a hasher
|
|
func (d *DepositMessage) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|
indx := hh.Index()
|
|
|
|
// Field (0) 'PublicKey'
|
|
if len(d.PublicKey) != 48 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(d.PublicKey)
|
|
|
|
// Field (1) 'WithdrawalCredentials'
|
|
if len(d.WithdrawalCredentials) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(d.WithdrawalCredentials)
|
|
|
|
// Field (2) 'Amount'
|
|
hh.PutUint64(d.Amount)
|
|
|
|
hh.Merkleize(indx)
|
|
return
|
|
}
|
|
|
|
// MarshalSSZ ssz marshals the SyncCommittee object
|
|
func (s *SyncCommittee) MarshalSSZ() ([]byte, error) {
|
|
return ssz.MarshalSSZ(s)
|
|
}
|
|
|
|
// MarshalSSZTo ssz marshals the SyncCommittee object to a target array
|
|
func (s *SyncCommittee) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
|
dst = buf
|
|
|
|
// Field (0) 'Pubkeys'
|
|
if len(s.Pubkeys) != 512 {
|
|
err = ssz.ErrVectorLength
|
|
return
|
|
}
|
|
for ii := 0; ii < 512; ii++ {
|
|
if len(s.Pubkeys[ii]) != 48 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, s.Pubkeys[ii]...)
|
|
}
|
|
|
|
// Field (1) 'AggregatePubkey'
|
|
if len(s.AggregatePubkey) != 48 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, s.AggregatePubkey...)
|
|
|
|
return
|
|
}
|
|
|
|
// UnmarshalSSZ ssz unmarshals the SyncCommittee object
|
|
func (s *SyncCommittee) UnmarshalSSZ(buf []byte) error {
|
|
var err error
|
|
size := uint64(len(buf))
|
|
if size != 24624 {
|
|
return ssz.ErrSize
|
|
}
|
|
|
|
// Field (0) 'Pubkeys'
|
|
s.Pubkeys = make([][]byte, 512)
|
|
for ii := 0; ii < 512; ii++ {
|
|
if cap(s.Pubkeys[ii]) == 0 {
|
|
s.Pubkeys[ii] = make([]byte, 0, len(buf[0:24576][ii*48:(ii+1)*48]))
|
|
}
|
|
s.Pubkeys[ii] = append(s.Pubkeys[ii], buf[0:24576][ii*48:(ii+1)*48]...)
|
|
}
|
|
|
|
// Field (1) 'AggregatePubkey'
|
|
if cap(s.AggregatePubkey) == 0 {
|
|
s.AggregatePubkey = make([]byte, 0, len(buf[24576:24624]))
|
|
}
|
|
s.AggregatePubkey = append(s.AggregatePubkey, buf[24576:24624]...)
|
|
|
|
return err
|
|
}
|
|
|
|
// SizeSSZ returns the ssz encoded size in bytes for the SyncCommittee object
|
|
func (s *SyncCommittee) SizeSSZ() (size int) {
|
|
size = 24624
|
|
return
|
|
}
|
|
|
|
// HashTreeRoot ssz hashes the SyncCommittee object
|
|
func (s *SyncCommittee) HashTreeRoot() ([32]byte, error) {
|
|
return ssz.HashWithDefaultHasher(s)
|
|
}
|
|
|
|
// HashTreeRootWith ssz hashes the SyncCommittee object with a hasher
|
|
func (s *SyncCommittee) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|
indx := hh.Index()
|
|
|
|
// Field (0) 'Pubkeys'
|
|
{
|
|
if len(s.Pubkeys) != 512 {
|
|
err = ssz.ErrVectorLength
|
|
return
|
|
}
|
|
subIndx := hh.Index()
|
|
for _, i := range s.Pubkeys {
|
|
if len(i) != 48 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(i)
|
|
}
|
|
hh.Merkleize(subIndx)
|
|
}
|
|
|
|
// Field (1) 'AggregatePubkey'
|
|
if len(s.AggregatePubkey) != 48 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(s.AggregatePubkey)
|
|
|
|
hh.Merkleize(indx)
|
|
return
|
|
}
|
|
|
|
// MarshalSSZ ssz marshals the SyncAggregatorSelectionData object
|
|
func (s *SyncAggregatorSelectionData) MarshalSSZ() ([]byte, error) {
|
|
return ssz.MarshalSSZ(s)
|
|
}
|
|
|
|
// MarshalSSZTo ssz marshals the SyncAggregatorSelectionData object to a target array
|
|
func (s *SyncAggregatorSelectionData) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
|
dst = buf
|
|
|
|
// Field (0) 'Slot'
|
|
dst = ssz.MarshalUint64(dst, uint64(s.Slot))
|
|
|
|
// Field (1) 'SubcommitteeIndex'
|
|
dst = ssz.MarshalUint64(dst, s.SubcommitteeIndex)
|
|
|
|
return
|
|
}
|
|
|
|
// UnmarshalSSZ ssz unmarshals the SyncAggregatorSelectionData object
|
|
func (s *SyncAggregatorSelectionData) UnmarshalSSZ(buf []byte) error {
|
|
var err error
|
|
size := uint64(len(buf))
|
|
if size != 16 {
|
|
return ssz.ErrSize
|
|
}
|
|
|
|
// Field (0) 'Slot'
|
|
s.Slot = github_com_prysmaticlabs_eth2_types.Slot(ssz.UnmarshallUint64(buf[0:8]))
|
|
|
|
// Field (1) 'SubcommitteeIndex'
|
|
s.SubcommitteeIndex = ssz.UnmarshallUint64(buf[8:16])
|
|
|
|
return err
|
|
}
|
|
|
|
// SizeSSZ returns the ssz encoded size in bytes for the SyncAggregatorSelectionData object
|
|
func (s *SyncAggregatorSelectionData) SizeSSZ() (size int) {
|
|
size = 16
|
|
return
|
|
}
|
|
|
|
// HashTreeRoot ssz hashes the SyncAggregatorSelectionData object
|
|
func (s *SyncAggregatorSelectionData) HashTreeRoot() ([32]byte, error) {
|
|
return ssz.HashWithDefaultHasher(s)
|
|
}
|
|
|
|
// HashTreeRootWith ssz hashes the SyncAggregatorSelectionData object with a hasher
|
|
func (s *SyncAggregatorSelectionData) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|
indx := hh.Index()
|
|
|
|
// Field (0) 'Slot'
|
|
hh.PutUint64(uint64(s.Slot))
|
|
|
|
// Field (1) 'SubcommitteeIndex'
|
|
hh.PutUint64(s.SubcommitteeIndex)
|
|
|
|
hh.Merkleize(indx)
|
|
return
|
|
}
|
|
|
|
// MarshalSSZ ssz marshals the BeaconStateBellatrix object
|
|
func (b *BeaconStateBellatrix) MarshalSSZ() ([]byte, error) {
|
|
return ssz.MarshalSSZ(b)
|
|
}
|
|
|
|
// MarshalSSZTo ssz marshals the BeaconStateBellatrix object to a target array
|
|
func (b *BeaconStateBellatrix) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
|
dst = buf
|
|
offset := int(2736633)
|
|
|
|
// Field (0) 'GenesisTime'
|
|
dst = ssz.MarshalUint64(dst, b.GenesisTime)
|
|
|
|
// Field (1) 'GenesisValidatorsRoot'
|
|
if len(b.GenesisValidatorsRoot) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, b.GenesisValidatorsRoot...)
|
|
|
|
// Field (2) 'Slot'
|
|
dst = ssz.MarshalUint64(dst, uint64(b.Slot))
|
|
|
|
// Field (3) 'Fork'
|
|
if b.Fork == nil {
|
|
b.Fork = new(Fork)
|
|
}
|
|
if dst, err = b.Fork.MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
|
|
// Field (4) 'LatestBlockHeader'
|
|
if b.LatestBlockHeader == nil {
|
|
b.LatestBlockHeader = new(BeaconBlockHeader)
|
|
}
|
|
if dst, err = b.LatestBlockHeader.MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
|
|
// Field (5) 'BlockRoots'
|
|
if len(b.BlockRoots) != 8192 {
|
|
err = ssz.ErrVectorLength
|
|
return
|
|
}
|
|
for ii := 0; ii < 8192; ii++ {
|
|
if len(b.BlockRoots[ii]) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, b.BlockRoots[ii]...)
|
|
}
|
|
|
|
// Field (6) 'StateRoots'
|
|
if len(b.StateRoots) != 8192 {
|
|
err = ssz.ErrVectorLength
|
|
return
|
|
}
|
|
for ii := 0; ii < 8192; ii++ {
|
|
if len(b.StateRoots[ii]) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, b.StateRoots[ii]...)
|
|
}
|
|
|
|
// Offset (7) 'HistoricalRoots'
|
|
dst = ssz.WriteOffset(dst, offset)
|
|
offset += len(b.HistoricalRoots) * 32
|
|
|
|
// Field (8) 'Eth1Data'
|
|
if b.Eth1Data == nil {
|
|
b.Eth1Data = new(Eth1Data)
|
|
}
|
|
if dst, err = b.Eth1Data.MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
|
|
// Offset (9) 'Eth1DataVotes'
|
|
dst = ssz.WriteOffset(dst, offset)
|
|
offset += len(b.Eth1DataVotes) * 72
|
|
|
|
// Field (10) 'Eth1DepositIndex'
|
|
dst = ssz.MarshalUint64(dst, b.Eth1DepositIndex)
|
|
|
|
// Offset (11) 'Validators'
|
|
dst = ssz.WriteOffset(dst, offset)
|
|
offset += len(b.Validators) * 121
|
|
|
|
// Offset (12) 'Balances'
|
|
dst = ssz.WriteOffset(dst, offset)
|
|
offset += len(b.Balances) * 8
|
|
|
|
// Field (13) 'RandaoMixes'
|
|
if len(b.RandaoMixes) != 65536 {
|
|
err = ssz.ErrVectorLength
|
|
return
|
|
}
|
|
for ii := 0; ii < 65536; ii++ {
|
|
if len(b.RandaoMixes[ii]) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, b.RandaoMixes[ii]...)
|
|
}
|
|
|
|
// Field (14) 'Slashings'
|
|
if len(b.Slashings) != 8192 {
|
|
err = ssz.ErrVectorLength
|
|
return
|
|
}
|
|
for ii := 0; ii < 8192; ii++ {
|
|
dst = ssz.MarshalUint64(dst, b.Slashings[ii])
|
|
}
|
|
|
|
// Offset (15) 'PreviousEpochParticipation'
|
|
dst = ssz.WriteOffset(dst, offset)
|
|
offset += len(b.PreviousEpochParticipation)
|
|
|
|
// Offset (16) 'CurrentEpochParticipation'
|
|
dst = ssz.WriteOffset(dst, offset)
|
|
offset += len(b.CurrentEpochParticipation)
|
|
|
|
// Field (17) 'JustificationBits'
|
|
if len(b.JustificationBits) != 1 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, b.JustificationBits...)
|
|
|
|
// Field (18) 'PreviousJustifiedCheckpoint'
|
|
if b.PreviousJustifiedCheckpoint == nil {
|
|
b.PreviousJustifiedCheckpoint = new(Checkpoint)
|
|
}
|
|
if dst, err = b.PreviousJustifiedCheckpoint.MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
|
|
// Field (19) 'CurrentJustifiedCheckpoint'
|
|
if b.CurrentJustifiedCheckpoint == nil {
|
|
b.CurrentJustifiedCheckpoint = new(Checkpoint)
|
|
}
|
|
if dst, err = b.CurrentJustifiedCheckpoint.MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
|
|
// Field (20) 'FinalizedCheckpoint'
|
|
if b.FinalizedCheckpoint == nil {
|
|
b.FinalizedCheckpoint = new(Checkpoint)
|
|
}
|
|
if dst, err = b.FinalizedCheckpoint.MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
|
|
// Offset (21) 'InactivityScores'
|
|
dst = ssz.WriteOffset(dst, offset)
|
|
offset += len(b.InactivityScores) * 8
|
|
|
|
// Field (22) 'CurrentSyncCommittee'
|
|
if b.CurrentSyncCommittee == nil {
|
|
b.CurrentSyncCommittee = new(SyncCommittee)
|
|
}
|
|
if dst, err = b.CurrentSyncCommittee.MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
|
|
// Field (23) 'NextSyncCommittee'
|
|
if b.NextSyncCommittee == nil {
|
|
b.NextSyncCommittee = new(SyncCommittee)
|
|
}
|
|
if dst, err = b.NextSyncCommittee.MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
|
|
// Offset (24) 'LatestExecutionPayloadHeader'
|
|
dst = ssz.WriteOffset(dst, offset)
|
|
if b.LatestExecutionPayloadHeader == nil {
|
|
b.LatestExecutionPayloadHeader = new(ExecutionPayloadHeader)
|
|
}
|
|
offset += b.LatestExecutionPayloadHeader.SizeSSZ()
|
|
|
|
// Field (7) 'HistoricalRoots'
|
|
if len(b.HistoricalRoots) > 16777216 {
|
|
err = ssz.ErrListTooBig
|
|
return
|
|
}
|
|
for ii := 0; ii < len(b.HistoricalRoots); ii++ {
|
|
if len(b.HistoricalRoots[ii]) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, b.HistoricalRoots[ii]...)
|
|
}
|
|
|
|
// Field (9) 'Eth1DataVotes'
|
|
if len(b.Eth1DataVotes) > 2048 {
|
|
err = ssz.ErrListTooBig
|
|
return
|
|
}
|
|
for ii := 0; ii < len(b.Eth1DataVotes); ii++ {
|
|
if dst, err = b.Eth1DataVotes[ii].MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
}
|
|
|
|
// Field (11) 'Validators'
|
|
if len(b.Validators) > 1099511627776 {
|
|
err = ssz.ErrListTooBig
|
|
return
|
|
}
|
|
for ii := 0; ii < len(b.Validators); ii++ {
|
|
if dst, err = b.Validators[ii].MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
}
|
|
|
|
// Field (12) 'Balances'
|
|
if len(b.Balances) > 1099511627776 {
|
|
err = ssz.ErrListTooBig
|
|
return
|
|
}
|
|
for ii := 0; ii < len(b.Balances); ii++ {
|
|
dst = ssz.MarshalUint64(dst, b.Balances[ii])
|
|
}
|
|
|
|
// Field (15) 'PreviousEpochParticipation'
|
|
if len(b.PreviousEpochParticipation) > 1099511627776 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, b.PreviousEpochParticipation...)
|
|
|
|
// Field (16) 'CurrentEpochParticipation'
|
|
if len(b.CurrentEpochParticipation) > 1099511627776 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, b.CurrentEpochParticipation...)
|
|
|
|
// Field (21) 'InactivityScores'
|
|
if len(b.InactivityScores) > 1099511627776 {
|
|
err = ssz.ErrListTooBig
|
|
return
|
|
}
|
|
for ii := 0; ii < len(b.InactivityScores); ii++ {
|
|
dst = ssz.MarshalUint64(dst, b.InactivityScores[ii])
|
|
}
|
|
|
|
// Field (24) 'LatestExecutionPayloadHeader'
|
|
if dst, err = b.LatestExecutionPayloadHeader.MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// UnmarshalSSZ ssz unmarshals the BeaconStateBellatrix object
|
|
func (b *BeaconStateBellatrix) UnmarshalSSZ(buf []byte) error {
|
|
var err error
|
|
size := uint64(len(buf))
|
|
if size < 2736633 {
|
|
return ssz.ErrSize
|
|
}
|
|
|
|
tail := buf
|
|
var o7, o9, o11, o12, o15, o16, o21, o24 uint64
|
|
|
|
// Field (0) 'GenesisTime'
|
|
b.GenesisTime = ssz.UnmarshallUint64(buf[0:8])
|
|
|
|
// Field (1) 'GenesisValidatorsRoot'
|
|
if cap(b.GenesisValidatorsRoot) == 0 {
|
|
b.GenesisValidatorsRoot = make([]byte, 0, len(buf[8:40]))
|
|
}
|
|
b.GenesisValidatorsRoot = append(b.GenesisValidatorsRoot, buf[8:40]...)
|
|
|
|
// Field (2) 'Slot'
|
|
b.Slot = github_com_prysmaticlabs_eth2_types.Slot(ssz.UnmarshallUint64(buf[40:48]))
|
|
|
|
// Field (3) 'Fork'
|
|
if b.Fork == nil {
|
|
b.Fork = new(Fork)
|
|
}
|
|
if err = b.Fork.UnmarshalSSZ(buf[48:64]); err != nil {
|
|
return err
|
|
}
|
|
|
|
// Field (4) 'LatestBlockHeader'
|
|
if b.LatestBlockHeader == nil {
|
|
b.LatestBlockHeader = new(BeaconBlockHeader)
|
|
}
|
|
if err = b.LatestBlockHeader.UnmarshalSSZ(buf[64:176]); err != nil {
|
|
return err
|
|
}
|
|
|
|
// Field (5) 'BlockRoots'
|
|
b.BlockRoots = make([][]byte, 8192)
|
|
for ii := 0; ii < 8192; ii++ {
|
|
if cap(b.BlockRoots[ii]) == 0 {
|
|
b.BlockRoots[ii] = make([]byte, 0, len(buf[176:262320][ii*32:(ii+1)*32]))
|
|
}
|
|
b.BlockRoots[ii] = append(b.BlockRoots[ii], buf[176:262320][ii*32:(ii+1)*32]...)
|
|
}
|
|
|
|
// Field (6) 'StateRoots'
|
|
b.StateRoots = make([][]byte, 8192)
|
|
for ii := 0; ii < 8192; ii++ {
|
|
if cap(b.StateRoots[ii]) == 0 {
|
|
b.StateRoots[ii] = make([]byte, 0, len(buf[262320:524464][ii*32:(ii+1)*32]))
|
|
}
|
|
b.StateRoots[ii] = append(b.StateRoots[ii], buf[262320:524464][ii*32:(ii+1)*32]...)
|
|
}
|
|
|
|
// Offset (7) 'HistoricalRoots'
|
|
if o7 = ssz.ReadOffset(buf[524464:524468]); o7 > size {
|
|
return ssz.ErrOffset
|
|
}
|
|
|
|
if o7 < 2736633 {
|
|
return ssz.ErrInvalidVariableOffset
|
|
}
|
|
|
|
// Field (8) 'Eth1Data'
|
|
if b.Eth1Data == nil {
|
|
b.Eth1Data = new(Eth1Data)
|
|
}
|
|
if err = b.Eth1Data.UnmarshalSSZ(buf[524468:524540]); err != nil {
|
|
return err
|
|
}
|
|
|
|
// Offset (9) 'Eth1DataVotes'
|
|
if o9 = ssz.ReadOffset(buf[524540:524544]); o9 > size || o7 > o9 {
|
|
return ssz.ErrOffset
|
|
}
|
|
|
|
// Field (10) 'Eth1DepositIndex'
|
|
b.Eth1DepositIndex = ssz.UnmarshallUint64(buf[524544:524552])
|
|
|
|
// Offset (11) 'Validators'
|
|
if o11 = ssz.ReadOffset(buf[524552:524556]); o11 > size || o9 > o11 {
|
|
return ssz.ErrOffset
|
|
}
|
|
|
|
// Offset (12) 'Balances'
|
|
if o12 = ssz.ReadOffset(buf[524556:524560]); o12 > size || o11 > o12 {
|
|
return ssz.ErrOffset
|
|
}
|
|
|
|
// Field (13) 'RandaoMixes'
|
|
b.RandaoMixes = make([][]byte, 65536)
|
|
for ii := 0; ii < 65536; ii++ {
|
|
if cap(b.RandaoMixes[ii]) == 0 {
|
|
b.RandaoMixes[ii] = make([]byte, 0, len(buf[524560:2621712][ii*32:(ii+1)*32]))
|
|
}
|
|
b.RandaoMixes[ii] = append(b.RandaoMixes[ii], buf[524560:2621712][ii*32:(ii+1)*32]...)
|
|
}
|
|
|
|
// Field (14) 'Slashings'
|
|
b.Slashings = ssz.ExtendUint64(b.Slashings, 8192)
|
|
for ii := 0; ii < 8192; ii++ {
|
|
b.Slashings[ii] = ssz.UnmarshallUint64(buf[2621712:2687248][ii*8 : (ii+1)*8])
|
|
}
|
|
|
|
// Offset (15) 'PreviousEpochParticipation'
|
|
if o15 = ssz.ReadOffset(buf[2687248:2687252]); o15 > size || o12 > o15 {
|
|
return ssz.ErrOffset
|
|
}
|
|
|
|
// Offset (16) 'CurrentEpochParticipation'
|
|
if o16 = ssz.ReadOffset(buf[2687252:2687256]); o16 > size || o15 > o16 {
|
|
return ssz.ErrOffset
|
|
}
|
|
|
|
// Field (17) 'JustificationBits'
|
|
if cap(b.JustificationBits) == 0 {
|
|
b.JustificationBits = make([]byte, 0, len(buf[2687256:2687257]))
|
|
}
|
|
b.JustificationBits = append(b.JustificationBits, buf[2687256:2687257]...)
|
|
|
|
// Field (18) 'PreviousJustifiedCheckpoint'
|
|
if b.PreviousJustifiedCheckpoint == nil {
|
|
b.PreviousJustifiedCheckpoint = new(Checkpoint)
|
|
}
|
|
if err = b.PreviousJustifiedCheckpoint.UnmarshalSSZ(buf[2687257:2687297]); err != nil {
|
|
return err
|
|
}
|
|
|
|
// Field (19) 'CurrentJustifiedCheckpoint'
|
|
if b.CurrentJustifiedCheckpoint == nil {
|
|
b.CurrentJustifiedCheckpoint = new(Checkpoint)
|
|
}
|
|
if err = b.CurrentJustifiedCheckpoint.UnmarshalSSZ(buf[2687297:2687337]); err != nil {
|
|
return err
|
|
}
|
|
|
|
// Field (20) 'FinalizedCheckpoint'
|
|
if b.FinalizedCheckpoint == nil {
|
|
b.FinalizedCheckpoint = new(Checkpoint)
|
|
}
|
|
if err = b.FinalizedCheckpoint.UnmarshalSSZ(buf[2687337:2687377]); err != nil {
|
|
return err
|
|
}
|
|
|
|
// Offset (21) 'InactivityScores'
|
|
if o21 = ssz.ReadOffset(buf[2687377:2687381]); o21 > size || o16 > o21 {
|
|
return ssz.ErrOffset
|
|
}
|
|
|
|
// Field (22) 'CurrentSyncCommittee'
|
|
if b.CurrentSyncCommittee == nil {
|
|
b.CurrentSyncCommittee = new(SyncCommittee)
|
|
}
|
|
if err = b.CurrentSyncCommittee.UnmarshalSSZ(buf[2687381:2712005]); err != nil {
|
|
return err
|
|
}
|
|
|
|
// Field (23) 'NextSyncCommittee'
|
|
if b.NextSyncCommittee == nil {
|
|
b.NextSyncCommittee = new(SyncCommittee)
|
|
}
|
|
if err = b.NextSyncCommittee.UnmarshalSSZ(buf[2712005:2736629]); err != nil {
|
|
return err
|
|
}
|
|
|
|
// Offset (24) 'LatestExecutionPayloadHeader'
|
|
if o24 = ssz.ReadOffset(buf[2736629:2736633]); o24 > size || o21 > o24 {
|
|
return ssz.ErrOffset
|
|
}
|
|
|
|
// Field (7) 'HistoricalRoots'
|
|
{
|
|
buf = tail[o7:o9]
|
|
num, err := ssz.DivideInt2(len(buf), 32, 16777216)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
b.HistoricalRoots = make([][]byte, num)
|
|
for ii := 0; ii < num; ii++ {
|
|
if cap(b.HistoricalRoots[ii]) == 0 {
|
|
b.HistoricalRoots[ii] = make([]byte, 0, len(buf[ii*32:(ii+1)*32]))
|
|
}
|
|
b.HistoricalRoots[ii] = append(b.HistoricalRoots[ii], buf[ii*32:(ii+1)*32]...)
|
|
}
|
|
}
|
|
|
|
// Field (9) 'Eth1DataVotes'
|
|
{
|
|
buf = tail[o9:o11]
|
|
num, err := ssz.DivideInt2(len(buf), 72, 2048)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
b.Eth1DataVotes = make([]*Eth1Data, num)
|
|
for ii := 0; ii < num; ii++ {
|
|
if b.Eth1DataVotes[ii] == nil {
|
|
b.Eth1DataVotes[ii] = new(Eth1Data)
|
|
}
|
|
if err = b.Eth1DataVotes[ii].UnmarshalSSZ(buf[ii*72 : (ii+1)*72]); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
}
|
|
|
|
// Field (11) 'Validators'
|
|
{
|
|
buf = tail[o11:o12]
|
|
num, err := ssz.DivideInt2(len(buf), 121, 1099511627776)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
b.Validators = make([]*Validator, num)
|
|
for ii := 0; ii < num; ii++ {
|
|
if b.Validators[ii] == nil {
|
|
b.Validators[ii] = new(Validator)
|
|
}
|
|
if err = b.Validators[ii].UnmarshalSSZ(buf[ii*121 : (ii+1)*121]); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
}
|
|
|
|
// Field (12) 'Balances'
|
|
{
|
|
buf = tail[o12:o15]
|
|
num, err := ssz.DivideInt2(len(buf), 8, 1099511627776)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
b.Balances = ssz.ExtendUint64(b.Balances, num)
|
|
for ii := 0; ii < num; ii++ {
|
|
b.Balances[ii] = ssz.UnmarshallUint64(buf[ii*8 : (ii+1)*8])
|
|
}
|
|
}
|
|
|
|
// Field (15) 'PreviousEpochParticipation'
|
|
{
|
|
buf = tail[o15:o16]
|
|
if len(buf) > 1099511627776 {
|
|
return ssz.ErrBytesLength
|
|
}
|
|
if cap(b.PreviousEpochParticipation) == 0 {
|
|
b.PreviousEpochParticipation = make([]byte, 0, len(buf))
|
|
}
|
|
b.PreviousEpochParticipation = append(b.PreviousEpochParticipation, buf...)
|
|
}
|
|
|
|
// Field (16) 'CurrentEpochParticipation'
|
|
{
|
|
buf = tail[o16:o21]
|
|
if len(buf) > 1099511627776 {
|
|
return ssz.ErrBytesLength
|
|
}
|
|
if cap(b.CurrentEpochParticipation) == 0 {
|
|
b.CurrentEpochParticipation = make([]byte, 0, len(buf))
|
|
}
|
|
b.CurrentEpochParticipation = append(b.CurrentEpochParticipation, buf...)
|
|
}
|
|
|
|
// Field (21) 'InactivityScores'
|
|
{
|
|
buf = tail[o21:o24]
|
|
num, err := ssz.DivideInt2(len(buf), 8, 1099511627776)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
b.InactivityScores = ssz.ExtendUint64(b.InactivityScores, num)
|
|
for ii := 0; ii < num; ii++ {
|
|
b.InactivityScores[ii] = ssz.UnmarshallUint64(buf[ii*8 : (ii+1)*8])
|
|
}
|
|
}
|
|
|
|
// Field (24) 'LatestExecutionPayloadHeader'
|
|
{
|
|
buf = tail[o24:]
|
|
if b.LatestExecutionPayloadHeader == nil {
|
|
b.LatestExecutionPayloadHeader = new(ExecutionPayloadHeader)
|
|
}
|
|
if err = b.LatestExecutionPayloadHeader.UnmarshalSSZ(buf); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
return err
|
|
}
|
|
|
|
// SizeSSZ returns the ssz encoded size in bytes for the BeaconStateBellatrix object
|
|
func (b *BeaconStateBellatrix) SizeSSZ() (size int) {
|
|
size = 2736633
|
|
|
|
// Field (7) 'HistoricalRoots'
|
|
size += len(b.HistoricalRoots) * 32
|
|
|
|
// Field (9) 'Eth1DataVotes'
|
|
size += len(b.Eth1DataVotes) * 72
|
|
|
|
// Field (11) 'Validators'
|
|
size += len(b.Validators) * 121
|
|
|
|
// Field (12) 'Balances'
|
|
size += len(b.Balances) * 8
|
|
|
|
// Field (15) 'PreviousEpochParticipation'
|
|
size += len(b.PreviousEpochParticipation)
|
|
|
|
// Field (16) 'CurrentEpochParticipation'
|
|
size += len(b.CurrentEpochParticipation)
|
|
|
|
// Field (21) 'InactivityScores'
|
|
size += len(b.InactivityScores) * 8
|
|
|
|
// Field (24) 'LatestExecutionPayloadHeader'
|
|
if b.LatestExecutionPayloadHeader == nil {
|
|
b.LatestExecutionPayloadHeader = new(ExecutionPayloadHeader)
|
|
}
|
|
size += b.LatestExecutionPayloadHeader.SizeSSZ()
|
|
|
|
return
|
|
}
|
|
|
|
// HashTreeRoot ssz hashes the BeaconStateBellatrix object
|
|
func (b *BeaconStateBellatrix) HashTreeRoot() ([32]byte, error) {
|
|
return ssz.HashWithDefaultHasher(b)
|
|
}
|
|
|
|
// HashTreeRootWith ssz hashes the BeaconStateBellatrix object with a hasher
|
|
func (b *BeaconStateBellatrix) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|
indx := hh.Index()
|
|
|
|
// Field (0) 'GenesisTime'
|
|
hh.PutUint64(b.GenesisTime)
|
|
|
|
// Field (1) 'GenesisValidatorsRoot'
|
|
if len(b.GenesisValidatorsRoot) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(b.GenesisValidatorsRoot)
|
|
|
|
// Field (2) 'Slot'
|
|
hh.PutUint64(uint64(b.Slot))
|
|
|
|
// Field (3) 'Fork'
|
|
if err = b.Fork.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
|
|
// Field (4) 'LatestBlockHeader'
|
|
if err = b.LatestBlockHeader.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
|
|
// Field (5) 'BlockRoots'
|
|
{
|
|
if len(b.BlockRoots) != 8192 {
|
|
err = ssz.ErrVectorLength
|
|
return
|
|
}
|
|
subIndx := hh.Index()
|
|
for _, i := range b.BlockRoots {
|
|
if len(i) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.Append(i)
|
|
}
|
|
hh.Merkleize(subIndx)
|
|
}
|
|
|
|
// Field (6) 'StateRoots'
|
|
{
|
|
if len(b.StateRoots) != 8192 {
|
|
err = ssz.ErrVectorLength
|
|
return
|
|
}
|
|
subIndx := hh.Index()
|
|
for _, i := range b.StateRoots {
|
|
if len(i) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.Append(i)
|
|
}
|
|
hh.Merkleize(subIndx)
|
|
}
|
|
|
|
// Field (7) 'HistoricalRoots'
|
|
{
|
|
if len(b.HistoricalRoots) > 16777216 {
|
|
err = ssz.ErrListTooBig
|
|
return
|
|
}
|
|
subIndx := hh.Index()
|
|
for _, i := range b.HistoricalRoots {
|
|
if len(i) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.Append(i)
|
|
}
|
|
numItems := uint64(len(b.HistoricalRoots))
|
|
hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(16777216, numItems, 32))
|
|
}
|
|
|
|
// Field (8) 'Eth1Data'
|
|
if err = b.Eth1Data.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
|
|
// Field (9) 'Eth1DataVotes'
|
|
{
|
|
subIndx := hh.Index()
|
|
num := uint64(len(b.Eth1DataVotes))
|
|
if num > 2048 {
|
|
err = ssz.ErrIncorrectListSize
|
|
return
|
|
}
|
|
for _, elem := range b.Eth1DataVotes {
|
|
if err = elem.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
}
|
|
hh.MerkleizeWithMixin(subIndx, num, 2048)
|
|
}
|
|
|
|
// Field (10) 'Eth1DepositIndex'
|
|
hh.PutUint64(b.Eth1DepositIndex)
|
|
|
|
// Field (11) 'Validators'
|
|
{
|
|
subIndx := hh.Index()
|
|
num := uint64(len(b.Validators))
|
|
if num > 1099511627776 {
|
|
err = ssz.ErrIncorrectListSize
|
|
return
|
|
}
|
|
for _, elem := range b.Validators {
|
|
if err = elem.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
}
|
|
hh.MerkleizeWithMixin(subIndx, num, 1099511627776)
|
|
}
|
|
|
|
// Field (12) 'Balances'
|
|
{
|
|
if len(b.Balances) > 1099511627776 {
|
|
err = ssz.ErrListTooBig
|
|
return
|
|
}
|
|
subIndx := hh.Index()
|
|
for _, i := range b.Balances {
|
|
hh.AppendUint64(i)
|
|
}
|
|
hh.FillUpTo32()
|
|
numItems := uint64(len(b.Balances))
|
|
hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(1099511627776, numItems, 8))
|
|
}
|
|
|
|
// Field (13) 'RandaoMixes'
|
|
{
|
|
if len(b.RandaoMixes) != 65536 {
|
|
err = ssz.ErrVectorLength
|
|
return
|
|
}
|
|
subIndx := hh.Index()
|
|
for _, i := range b.RandaoMixes {
|
|
if len(i) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.Append(i)
|
|
}
|
|
hh.Merkleize(subIndx)
|
|
}
|
|
|
|
// Field (14) 'Slashings'
|
|
{
|
|
if len(b.Slashings) != 8192 {
|
|
err = ssz.ErrVectorLength
|
|
return
|
|
}
|
|
subIndx := hh.Index()
|
|
for _, i := range b.Slashings {
|
|
hh.AppendUint64(i)
|
|
}
|
|
hh.Merkleize(subIndx)
|
|
}
|
|
|
|
// Field (15) 'PreviousEpochParticipation'
|
|
{
|
|
elemIndx := hh.Index()
|
|
byteLen := uint64(len(b.PreviousEpochParticipation))
|
|
if byteLen > 1099511627776 {
|
|
err = ssz.ErrIncorrectListSize
|
|
return
|
|
}
|
|
hh.PutBytes(b.PreviousEpochParticipation)
|
|
hh.MerkleizeWithMixin(elemIndx, byteLen, (1099511627776+31)/32)
|
|
}
|
|
|
|
// Field (16) 'CurrentEpochParticipation'
|
|
{
|
|
elemIndx := hh.Index()
|
|
byteLen := uint64(len(b.CurrentEpochParticipation))
|
|
if byteLen > 1099511627776 {
|
|
err = ssz.ErrIncorrectListSize
|
|
return
|
|
}
|
|
hh.PutBytes(b.CurrentEpochParticipation)
|
|
hh.MerkleizeWithMixin(elemIndx, byteLen, (1099511627776+31)/32)
|
|
}
|
|
|
|
// Field (17) 'JustificationBits'
|
|
if len(b.JustificationBits) != 1 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(b.JustificationBits)
|
|
|
|
// Field (18) 'PreviousJustifiedCheckpoint'
|
|
if err = b.PreviousJustifiedCheckpoint.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
|
|
// Field (19) 'CurrentJustifiedCheckpoint'
|
|
if err = b.CurrentJustifiedCheckpoint.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
|
|
// Field (20) 'FinalizedCheckpoint'
|
|
if err = b.FinalizedCheckpoint.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
|
|
// Field (21) 'InactivityScores'
|
|
{
|
|
if len(b.InactivityScores) > 1099511627776 {
|
|
err = ssz.ErrListTooBig
|
|
return
|
|
}
|
|
subIndx := hh.Index()
|
|
for _, i := range b.InactivityScores {
|
|
hh.AppendUint64(i)
|
|
}
|
|
hh.FillUpTo32()
|
|
numItems := uint64(len(b.InactivityScores))
|
|
hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(1099511627776, numItems, 8))
|
|
}
|
|
|
|
// Field (22) 'CurrentSyncCommittee'
|
|
if err = b.CurrentSyncCommittee.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
|
|
// Field (23) 'NextSyncCommittee'
|
|
if err = b.NextSyncCommittee.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
|
|
// Field (24) 'LatestExecutionPayloadHeader'
|
|
if err = b.LatestExecutionPayloadHeader.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
|
|
hh.Merkleize(indx)
|
|
return
|
|
}
|
|
|
|
// MarshalSSZ ssz marshals the ExecutionPayloadHeader object
|
|
func (e *ExecutionPayloadHeader) MarshalSSZ() ([]byte, error) {
|
|
return ssz.MarshalSSZ(e)
|
|
}
|
|
|
|
// MarshalSSZTo ssz marshals the ExecutionPayloadHeader object to a target array
|
|
func (e *ExecutionPayloadHeader) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
|
dst = buf
|
|
offset := int(536)
|
|
|
|
// Field (0) 'ParentHash'
|
|
if len(e.ParentHash) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, e.ParentHash...)
|
|
|
|
// Field (1) 'FeeRecipient'
|
|
if len(e.FeeRecipient) != 20 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, e.FeeRecipient...)
|
|
|
|
// Field (2) 'StateRoot'
|
|
if len(e.StateRoot) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, e.StateRoot...)
|
|
|
|
// Field (3) 'ReceiptRoot'
|
|
if len(e.ReceiptRoot) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, e.ReceiptRoot...)
|
|
|
|
// Field (4) 'LogsBloom'
|
|
if len(e.LogsBloom) != 256 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, e.LogsBloom...)
|
|
|
|
// Field (5) 'PrevRandao'
|
|
if len(e.PrevRandao) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, e.PrevRandao...)
|
|
|
|
// Field (6) 'BlockNumber'
|
|
dst = ssz.MarshalUint64(dst, e.BlockNumber)
|
|
|
|
// Field (7) 'GasLimit'
|
|
dst = ssz.MarshalUint64(dst, e.GasLimit)
|
|
|
|
// Field (8) 'GasUsed'
|
|
dst = ssz.MarshalUint64(dst, e.GasUsed)
|
|
|
|
// Field (9) 'Timestamp'
|
|
dst = ssz.MarshalUint64(dst, e.Timestamp)
|
|
|
|
// Offset (10) 'ExtraData'
|
|
dst = ssz.WriteOffset(dst, offset)
|
|
offset += len(e.ExtraData)
|
|
|
|
// Field (11) 'BaseFeePerGas'
|
|
if len(e.BaseFeePerGas) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, e.BaseFeePerGas...)
|
|
|
|
// Field (12) 'BlockHash'
|
|
if len(e.BlockHash) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, e.BlockHash...)
|
|
|
|
// Field (13) 'TransactionsRoot'
|
|
if len(e.TransactionsRoot) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, e.TransactionsRoot...)
|
|
|
|
// Field (10) 'ExtraData'
|
|
if len(e.ExtraData) > 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, e.ExtraData...)
|
|
|
|
return
|
|
}
|
|
|
|
// UnmarshalSSZ ssz unmarshals the ExecutionPayloadHeader object
|
|
func (e *ExecutionPayloadHeader) UnmarshalSSZ(buf []byte) error {
|
|
var err error
|
|
size := uint64(len(buf))
|
|
if size < 536 {
|
|
return ssz.ErrSize
|
|
}
|
|
|
|
tail := buf
|
|
var o10 uint64
|
|
|
|
// Field (0) 'ParentHash'
|
|
if cap(e.ParentHash) == 0 {
|
|
e.ParentHash = make([]byte, 0, len(buf[0:32]))
|
|
}
|
|
e.ParentHash = append(e.ParentHash, buf[0:32]...)
|
|
|
|
// Field (1) 'FeeRecipient'
|
|
if cap(e.FeeRecipient) == 0 {
|
|
e.FeeRecipient = make([]byte, 0, len(buf[32:52]))
|
|
}
|
|
e.FeeRecipient = append(e.FeeRecipient, buf[32:52]...)
|
|
|
|
// Field (2) 'StateRoot'
|
|
if cap(e.StateRoot) == 0 {
|
|
e.StateRoot = make([]byte, 0, len(buf[52:84]))
|
|
}
|
|
e.StateRoot = append(e.StateRoot, buf[52:84]...)
|
|
|
|
// Field (3) 'ReceiptRoot'
|
|
if cap(e.ReceiptRoot) == 0 {
|
|
e.ReceiptRoot = make([]byte, 0, len(buf[84:116]))
|
|
}
|
|
e.ReceiptRoot = append(e.ReceiptRoot, buf[84:116]...)
|
|
|
|
// Field (4) 'LogsBloom'
|
|
if cap(e.LogsBloom) == 0 {
|
|
e.LogsBloom = make([]byte, 0, len(buf[116:372]))
|
|
}
|
|
e.LogsBloom = append(e.LogsBloom, buf[116:372]...)
|
|
|
|
// Field (5) 'PrevRandao'
|
|
if cap(e.PrevRandao) == 0 {
|
|
e.PrevRandao = make([]byte, 0, len(buf[372:404]))
|
|
}
|
|
e.PrevRandao = append(e.PrevRandao, buf[372:404]...)
|
|
|
|
// Field (6) 'BlockNumber'
|
|
e.BlockNumber = ssz.UnmarshallUint64(buf[404:412])
|
|
|
|
// Field (7) 'GasLimit'
|
|
e.GasLimit = ssz.UnmarshallUint64(buf[412:420])
|
|
|
|
// Field (8) 'GasUsed'
|
|
e.GasUsed = ssz.UnmarshallUint64(buf[420:428])
|
|
|
|
// Field (9) 'Timestamp'
|
|
e.Timestamp = ssz.UnmarshallUint64(buf[428:436])
|
|
|
|
// Offset (10) 'ExtraData'
|
|
if o10 = ssz.ReadOffset(buf[436:440]); o10 > size {
|
|
return ssz.ErrOffset
|
|
}
|
|
|
|
if o10 < 536 {
|
|
return ssz.ErrInvalidVariableOffset
|
|
}
|
|
|
|
// Field (11) 'BaseFeePerGas'
|
|
if cap(e.BaseFeePerGas) == 0 {
|
|
e.BaseFeePerGas = make([]byte, 0, len(buf[440:472]))
|
|
}
|
|
e.BaseFeePerGas = append(e.BaseFeePerGas, buf[440:472]...)
|
|
|
|
// Field (12) 'BlockHash'
|
|
if cap(e.BlockHash) == 0 {
|
|
e.BlockHash = make([]byte, 0, len(buf[472:504]))
|
|
}
|
|
e.BlockHash = append(e.BlockHash, buf[472:504]...)
|
|
|
|
// Field (13) 'TransactionsRoot'
|
|
if cap(e.TransactionsRoot) == 0 {
|
|
e.TransactionsRoot = make([]byte, 0, len(buf[504:536]))
|
|
}
|
|
e.TransactionsRoot = append(e.TransactionsRoot, buf[504:536]...)
|
|
|
|
// Field (10) 'ExtraData'
|
|
{
|
|
buf = tail[o10:]
|
|
if len(buf) > 32 {
|
|
return ssz.ErrBytesLength
|
|
}
|
|
if cap(e.ExtraData) == 0 {
|
|
e.ExtraData = make([]byte, 0, len(buf))
|
|
}
|
|
e.ExtraData = append(e.ExtraData, buf...)
|
|
}
|
|
return err
|
|
}
|
|
|
|
// SizeSSZ returns the ssz encoded size in bytes for the ExecutionPayloadHeader object
|
|
func (e *ExecutionPayloadHeader) SizeSSZ() (size int) {
|
|
size = 536
|
|
|
|
// Field (10) 'ExtraData'
|
|
size += len(e.ExtraData)
|
|
|
|
return
|
|
}
|
|
|
|
// HashTreeRoot ssz hashes the ExecutionPayloadHeader object
|
|
func (e *ExecutionPayloadHeader) HashTreeRoot() ([32]byte, error) {
|
|
return ssz.HashWithDefaultHasher(e)
|
|
}
|
|
|
|
// HashTreeRootWith ssz hashes the ExecutionPayloadHeader object with a hasher
|
|
func (e *ExecutionPayloadHeader) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|
indx := hh.Index()
|
|
|
|
// Field (0) 'ParentHash'
|
|
if len(e.ParentHash) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(e.ParentHash)
|
|
|
|
// Field (1) 'FeeRecipient'
|
|
if len(e.FeeRecipient) != 20 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(e.FeeRecipient)
|
|
|
|
// Field (2) 'StateRoot'
|
|
if len(e.StateRoot) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(e.StateRoot)
|
|
|
|
// Field (3) 'ReceiptRoot'
|
|
if len(e.ReceiptRoot) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(e.ReceiptRoot)
|
|
|
|
// Field (4) 'LogsBloom'
|
|
if len(e.LogsBloom) != 256 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(e.LogsBloom)
|
|
|
|
// Field (5) 'PrevRandao'
|
|
if len(e.PrevRandao) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(e.PrevRandao)
|
|
|
|
// Field (6) 'BlockNumber'
|
|
hh.PutUint64(e.BlockNumber)
|
|
|
|
// Field (7) 'GasLimit'
|
|
hh.PutUint64(e.GasLimit)
|
|
|
|
// Field (8) 'GasUsed'
|
|
hh.PutUint64(e.GasUsed)
|
|
|
|
// Field (9) 'Timestamp'
|
|
hh.PutUint64(e.Timestamp)
|
|
|
|
// Field (10) 'ExtraData'
|
|
{
|
|
elemIndx := hh.Index()
|
|
byteLen := uint64(len(e.ExtraData))
|
|
if byteLen > 32 {
|
|
err = ssz.ErrIncorrectListSize
|
|
return
|
|
}
|
|
hh.PutBytes(e.ExtraData)
|
|
hh.MerkleizeWithMixin(elemIndx, byteLen, (32+31)/32)
|
|
}
|
|
|
|
// Field (11) 'BaseFeePerGas'
|
|
if len(e.BaseFeePerGas) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(e.BaseFeePerGas)
|
|
|
|
// Field (12) 'BlockHash'
|
|
if len(e.BlockHash) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(e.BlockHash)
|
|
|
|
// Field (13) 'TransactionsRoot'
|
|
if len(e.TransactionsRoot) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(e.TransactionsRoot)
|
|
|
|
hh.Merkleize(indx)
|
|
return
|
|
}
|
|
|
|
// MarshalSSZ ssz marshals the PowBlock object
|
|
func (p *PowBlock) MarshalSSZ() ([]byte, error) {
|
|
return ssz.MarshalSSZ(p)
|
|
}
|
|
|
|
// MarshalSSZTo ssz marshals the PowBlock object to a target array
|
|
func (p *PowBlock) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
|
dst = buf
|
|
|
|
// Field (0) 'BlockHash'
|
|
if len(p.BlockHash) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, p.BlockHash...)
|
|
|
|
// Field (1) 'ParentHash'
|
|
if len(p.ParentHash) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, p.ParentHash...)
|
|
|
|
// Field (2) 'TotalDifficulty'
|
|
if len(p.TotalDifficulty) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, p.TotalDifficulty...)
|
|
|
|
return
|
|
}
|
|
|
|
// UnmarshalSSZ ssz unmarshals the PowBlock object
|
|
func (p *PowBlock) UnmarshalSSZ(buf []byte) error {
|
|
var err error
|
|
size := uint64(len(buf))
|
|
if size != 96 {
|
|
return ssz.ErrSize
|
|
}
|
|
|
|
// Field (0) 'BlockHash'
|
|
if cap(p.BlockHash) == 0 {
|
|
p.BlockHash = make([]byte, 0, len(buf[0:32]))
|
|
}
|
|
p.BlockHash = append(p.BlockHash, buf[0:32]...)
|
|
|
|
// Field (1) 'ParentHash'
|
|
if cap(p.ParentHash) == 0 {
|
|
p.ParentHash = make([]byte, 0, len(buf[32:64]))
|
|
}
|
|
p.ParentHash = append(p.ParentHash, buf[32:64]...)
|
|
|
|
// Field (2) 'TotalDifficulty'
|
|
if cap(p.TotalDifficulty) == 0 {
|
|
p.TotalDifficulty = make([]byte, 0, len(buf[64:96]))
|
|
}
|
|
p.TotalDifficulty = append(p.TotalDifficulty, buf[64:96]...)
|
|
|
|
return err
|
|
}
|
|
|
|
// SizeSSZ returns the ssz encoded size in bytes for the PowBlock object
|
|
func (p *PowBlock) SizeSSZ() (size int) {
|
|
size = 96
|
|
return
|
|
}
|
|
|
|
// HashTreeRoot ssz hashes the PowBlock object
|
|
func (p *PowBlock) HashTreeRoot() ([32]byte, error) {
|
|
return ssz.HashWithDefaultHasher(p)
|
|
}
|
|
|
|
// HashTreeRootWith ssz hashes the PowBlock object with a hasher
|
|
func (p *PowBlock) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|
indx := hh.Index()
|
|
|
|
// Field (0) 'BlockHash'
|
|
if len(p.BlockHash) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(p.BlockHash)
|
|
|
|
// Field (1) 'ParentHash'
|
|
if len(p.ParentHash) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(p.ParentHash)
|
|
|
|
// Field (2) 'TotalDifficulty'
|
|
if len(p.TotalDifficulty) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(p.TotalDifficulty)
|
|
|
|
hh.Merkleize(indx)
|
|
return
|
|
}
|
|
|
|
// MarshalSSZ ssz marshals the Status object
|
|
func (s *Status) MarshalSSZ() ([]byte, error) {
|
|
return ssz.MarshalSSZ(s)
|
|
}
|
|
|
|
// MarshalSSZTo ssz marshals the Status object to a target array
|
|
func (s *Status) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
|
dst = buf
|
|
|
|
// Field (0) 'ForkDigest'
|
|
if len(s.ForkDigest) != 4 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, s.ForkDigest...)
|
|
|
|
// Field (1) 'FinalizedRoot'
|
|
if len(s.FinalizedRoot) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, s.FinalizedRoot...)
|
|
|
|
// Field (2) 'FinalizedEpoch'
|
|
dst = ssz.MarshalUint64(dst, uint64(s.FinalizedEpoch))
|
|
|
|
// Field (3) 'HeadRoot'
|
|
if len(s.HeadRoot) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, s.HeadRoot...)
|
|
|
|
// Field (4) 'HeadSlot'
|
|
dst = ssz.MarshalUint64(dst, uint64(s.HeadSlot))
|
|
|
|
return
|
|
}
|
|
|
|
// UnmarshalSSZ ssz unmarshals the Status object
|
|
func (s *Status) UnmarshalSSZ(buf []byte) error {
|
|
var err error
|
|
size := uint64(len(buf))
|
|
if size != 84 {
|
|
return ssz.ErrSize
|
|
}
|
|
|
|
// Field (0) 'ForkDigest'
|
|
if cap(s.ForkDigest) == 0 {
|
|
s.ForkDigest = make([]byte, 0, len(buf[0:4]))
|
|
}
|
|
s.ForkDigest = append(s.ForkDigest, buf[0:4]...)
|
|
|
|
// Field (1) 'FinalizedRoot'
|
|
if cap(s.FinalizedRoot) == 0 {
|
|
s.FinalizedRoot = make([]byte, 0, len(buf[4:36]))
|
|
}
|
|
s.FinalizedRoot = append(s.FinalizedRoot, buf[4:36]...)
|
|
|
|
// Field (2) 'FinalizedEpoch'
|
|
s.FinalizedEpoch = github_com_prysmaticlabs_eth2_types.Epoch(ssz.UnmarshallUint64(buf[36:44]))
|
|
|
|
// Field (3) 'HeadRoot'
|
|
if cap(s.HeadRoot) == 0 {
|
|
s.HeadRoot = make([]byte, 0, len(buf[44:76]))
|
|
}
|
|
s.HeadRoot = append(s.HeadRoot, buf[44:76]...)
|
|
|
|
// Field (4) 'HeadSlot'
|
|
s.HeadSlot = github_com_prysmaticlabs_eth2_types.Slot(ssz.UnmarshallUint64(buf[76:84]))
|
|
|
|
return err
|
|
}
|
|
|
|
// SizeSSZ returns the ssz encoded size in bytes for the Status object
|
|
func (s *Status) SizeSSZ() (size int) {
|
|
size = 84
|
|
return
|
|
}
|
|
|
|
// HashTreeRoot ssz hashes the Status object
|
|
func (s *Status) HashTreeRoot() ([32]byte, error) {
|
|
return ssz.HashWithDefaultHasher(s)
|
|
}
|
|
|
|
// HashTreeRootWith ssz hashes the Status object with a hasher
|
|
func (s *Status) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|
indx := hh.Index()
|
|
|
|
// Field (0) 'ForkDigest'
|
|
if len(s.ForkDigest) != 4 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(s.ForkDigest)
|
|
|
|
// Field (1) 'FinalizedRoot'
|
|
if len(s.FinalizedRoot) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(s.FinalizedRoot)
|
|
|
|
// Field (2) 'FinalizedEpoch'
|
|
hh.PutUint64(uint64(s.FinalizedEpoch))
|
|
|
|
// Field (3) 'HeadRoot'
|
|
if len(s.HeadRoot) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(s.HeadRoot)
|
|
|
|
// Field (4) 'HeadSlot'
|
|
hh.PutUint64(uint64(s.HeadSlot))
|
|
|
|
hh.Merkleize(indx)
|
|
return
|
|
}
|
|
|
|
// MarshalSSZ ssz marshals the BeaconBlocksByRangeRequest object
|
|
func (b *BeaconBlocksByRangeRequest) MarshalSSZ() ([]byte, error) {
|
|
return ssz.MarshalSSZ(b)
|
|
}
|
|
|
|
// MarshalSSZTo ssz marshals the BeaconBlocksByRangeRequest object to a target array
|
|
func (b *BeaconBlocksByRangeRequest) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
|
dst = buf
|
|
|
|
// Field (0) 'StartSlot'
|
|
dst = ssz.MarshalUint64(dst, uint64(b.StartSlot))
|
|
|
|
// Field (1) 'Count'
|
|
dst = ssz.MarshalUint64(dst, b.Count)
|
|
|
|
// Field (2) 'Step'
|
|
dst = ssz.MarshalUint64(dst, b.Step)
|
|
|
|
return
|
|
}
|
|
|
|
// UnmarshalSSZ ssz unmarshals the BeaconBlocksByRangeRequest object
|
|
func (b *BeaconBlocksByRangeRequest) UnmarshalSSZ(buf []byte) error {
|
|
var err error
|
|
size := uint64(len(buf))
|
|
if size != 24 {
|
|
return ssz.ErrSize
|
|
}
|
|
|
|
// Field (0) 'StartSlot'
|
|
b.StartSlot = github_com_prysmaticlabs_eth2_types.Slot(ssz.UnmarshallUint64(buf[0:8]))
|
|
|
|
// Field (1) 'Count'
|
|
b.Count = ssz.UnmarshallUint64(buf[8:16])
|
|
|
|
// Field (2) 'Step'
|
|
b.Step = ssz.UnmarshallUint64(buf[16:24])
|
|
|
|
return err
|
|
}
|
|
|
|
// SizeSSZ returns the ssz encoded size in bytes for the BeaconBlocksByRangeRequest object
|
|
func (b *BeaconBlocksByRangeRequest) SizeSSZ() (size int) {
|
|
size = 24
|
|
return
|
|
}
|
|
|
|
// HashTreeRoot ssz hashes the BeaconBlocksByRangeRequest object
|
|
func (b *BeaconBlocksByRangeRequest) HashTreeRoot() ([32]byte, error) {
|
|
return ssz.HashWithDefaultHasher(b)
|
|
}
|
|
|
|
// HashTreeRootWith ssz hashes the BeaconBlocksByRangeRequest object with a hasher
|
|
func (b *BeaconBlocksByRangeRequest) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|
indx := hh.Index()
|
|
|
|
// Field (0) 'StartSlot'
|
|
hh.PutUint64(uint64(b.StartSlot))
|
|
|
|
// Field (1) 'Count'
|
|
hh.PutUint64(b.Count)
|
|
|
|
// Field (2) 'Step'
|
|
hh.PutUint64(b.Step)
|
|
|
|
hh.Merkleize(indx)
|
|
return
|
|
}
|
|
|
|
// MarshalSSZ ssz marshals the ENRForkID object
|
|
func (e *ENRForkID) MarshalSSZ() ([]byte, error) {
|
|
return ssz.MarshalSSZ(e)
|
|
}
|
|
|
|
// MarshalSSZTo ssz marshals the ENRForkID object to a target array
|
|
func (e *ENRForkID) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
|
dst = buf
|
|
|
|
// Field (0) 'CurrentForkDigest'
|
|
if len(e.CurrentForkDigest) != 4 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, e.CurrentForkDigest...)
|
|
|
|
// Field (1) 'NextForkVersion'
|
|
if len(e.NextForkVersion) != 4 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, e.NextForkVersion...)
|
|
|
|
// Field (2) 'NextForkEpoch'
|
|
dst = ssz.MarshalUint64(dst, uint64(e.NextForkEpoch))
|
|
|
|
return
|
|
}
|
|
|
|
// UnmarshalSSZ ssz unmarshals the ENRForkID object
|
|
func (e *ENRForkID) UnmarshalSSZ(buf []byte) error {
|
|
var err error
|
|
size := uint64(len(buf))
|
|
if size != 16 {
|
|
return ssz.ErrSize
|
|
}
|
|
|
|
// Field (0) 'CurrentForkDigest'
|
|
if cap(e.CurrentForkDigest) == 0 {
|
|
e.CurrentForkDigest = make([]byte, 0, len(buf[0:4]))
|
|
}
|
|
e.CurrentForkDigest = append(e.CurrentForkDigest, buf[0:4]...)
|
|
|
|
// Field (1) 'NextForkVersion'
|
|
if cap(e.NextForkVersion) == 0 {
|
|
e.NextForkVersion = make([]byte, 0, len(buf[4:8]))
|
|
}
|
|
e.NextForkVersion = append(e.NextForkVersion, buf[4:8]...)
|
|
|
|
// Field (2) 'NextForkEpoch'
|
|
e.NextForkEpoch = github_com_prysmaticlabs_eth2_types.Epoch(ssz.UnmarshallUint64(buf[8:16]))
|
|
|
|
return err
|
|
}
|
|
|
|
// SizeSSZ returns the ssz encoded size in bytes for the ENRForkID object
|
|
func (e *ENRForkID) SizeSSZ() (size int) {
|
|
size = 16
|
|
return
|
|
}
|
|
|
|
// HashTreeRoot ssz hashes the ENRForkID object
|
|
func (e *ENRForkID) HashTreeRoot() ([32]byte, error) {
|
|
return ssz.HashWithDefaultHasher(e)
|
|
}
|
|
|
|
// HashTreeRootWith ssz hashes the ENRForkID object with a hasher
|
|
func (e *ENRForkID) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|
indx := hh.Index()
|
|
|
|
// Field (0) 'CurrentForkDigest'
|
|
if len(e.CurrentForkDigest) != 4 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(e.CurrentForkDigest)
|
|
|
|
// Field (1) 'NextForkVersion'
|
|
if len(e.NextForkVersion) != 4 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(e.NextForkVersion)
|
|
|
|
// Field (2) 'NextForkEpoch'
|
|
hh.PutUint64(uint64(e.NextForkEpoch))
|
|
|
|
hh.Merkleize(indx)
|
|
return
|
|
}
|
|
|
|
// MarshalSSZ ssz marshals the MetaDataV0 object
|
|
func (m *MetaDataV0) MarshalSSZ() ([]byte, error) {
|
|
return ssz.MarshalSSZ(m)
|
|
}
|
|
|
|
// MarshalSSZTo ssz marshals the MetaDataV0 object to a target array
|
|
func (m *MetaDataV0) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
|
dst = buf
|
|
|
|
// Field (0) 'SeqNumber'
|
|
dst = ssz.MarshalUint64(dst, m.SeqNumber)
|
|
|
|
// Field (1) 'Attnets'
|
|
if len(m.Attnets) != 8 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, m.Attnets...)
|
|
|
|
return
|
|
}
|
|
|
|
// UnmarshalSSZ ssz unmarshals the MetaDataV0 object
|
|
func (m *MetaDataV0) UnmarshalSSZ(buf []byte) error {
|
|
var err error
|
|
size := uint64(len(buf))
|
|
if size != 16 {
|
|
return ssz.ErrSize
|
|
}
|
|
|
|
// Field (0) 'SeqNumber'
|
|
m.SeqNumber = ssz.UnmarshallUint64(buf[0:8])
|
|
|
|
// Field (1) 'Attnets'
|
|
if cap(m.Attnets) == 0 {
|
|
m.Attnets = make([]byte, 0, len(buf[8:16]))
|
|
}
|
|
m.Attnets = append(m.Attnets, buf[8:16]...)
|
|
|
|
return err
|
|
}
|
|
|
|
// SizeSSZ returns the ssz encoded size in bytes for the MetaDataV0 object
|
|
func (m *MetaDataV0) SizeSSZ() (size int) {
|
|
size = 16
|
|
return
|
|
}
|
|
|
|
// HashTreeRoot ssz hashes the MetaDataV0 object
|
|
func (m *MetaDataV0) HashTreeRoot() ([32]byte, error) {
|
|
return ssz.HashWithDefaultHasher(m)
|
|
}
|
|
|
|
// HashTreeRootWith ssz hashes the MetaDataV0 object with a hasher
|
|
func (m *MetaDataV0) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|
indx := hh.Index()
|
|
|
|
// Field (0) 'SeqNumber'
|
|
hh.PutUint64(m.SeqNumber)
|
|
|
|
// Field (1) 'Attnets'
|
|
if len(m.Attnets) != 8 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(m.Attnets)
|
|
|
|
hh.Merkleize(indx)
|
|
return
|
|
}
|
|
|
|
// MarshalSSZ ssz marshals the MetaDataV1 object
|
|
func (m *MetaDataV1) MarshalSSZ() ([]byte, error) {
|
|
return ssz.MarshalSSZ(m)
|
|
}
|
|
|
|
// MarshalSSZTo ssz marshals the MetaDataV1 object to a target array
|
|
func (m *MetaDataV1) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
|
dst = buf
|
|
|
|
// Field (0) 'SeqNumber'
|
|
dst = ssz.MarshalUint64(dst, m.SeqNumber)
|
|
|
|
// Field (1) 'Attnets'
|
|
if len(m.Attnets) != 8 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, m.Attnets...)
|
|
|
|
// Field (2) 'Syncnets'
|
|
if len(m.Syncnets) != 1 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, m.Syncnets...)
|
|
|
|
return
|
|
}
|
|
|
|
// UnmarshalSSZ ssz unmarshals the MetaDataV1 object
|
|
func (m *MetaDataV1) UnmarshalSSZ(buf []byte) error {
|
|
var err error
|
|
size := uint64(len(buf))
|
|
if size != 17 {
|
|
return ssz.ErrSize
|
|
}
|
|
|
|
// Field (0) 'SeqNumber'
|
|
m.SeqNumber = ssz.UnmarshallUint64(buf[0:8])
|
|
|
|
// Field (1) 'Attnets'
|
|
if cap(m.Attnets) == 0 {
|
|
m.Attnets = make([]byte, 0, len(buf[8:16]))
|
|
}
|
|
m.Attnets = append(m.Attnets, buf[8:16]...)
|
|
|
|
// Field (2) 'Syncnets'
|
|
if cap(m.Syncnets) == 0 {
|
|
m.Syncnets = make([]byte, 0, len(buf[16:17]))
|
|
}
|
|
m.Syncnets = append(m.Syncnets, buf[16:17]...)
|
|
|
|
return err
|
|
}
|
|
|
|
// SizeSSZ returns the ssz encoded size in bytes for the MetaDataV1 object
|
|
func (m *MetaDataV1) SizeSSZ() (size int) {
|
|
size = 17
|
|
return
|
|
}
|
|
|
|
// HashTreeRoot ssz hashes the MetaDataV1 object
|
|
func (m *MetaDataV1) HashTreeRoot() ([32]byte, error) {
|
|
return ssz.HashWithDefaultHasher(m)
|
|
}
|
|
|
|
// HashTreeRootWith ssz hashes the MetaDataV1 object with a hasher
|
|
func (m *MetaDataV1) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|
indx := hh.Index()
|
|
|
|
// Field (0) 'SeqNumber'
|
|
hh.PutUint64(m.SeqNumber)
|
|
|
|
// Field (1) 'Attnets'
|
|
if len(m.Attnets) != 8 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(m.Attnets)
|
|
|
|
// Field (2) 'Syncnets'
|
|
if len(m.Syncnets) != 1 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(m.Syncnets)
|
|
|
|
hh.Merkleize(indx)
|
|
return
|
|
}
|
|
|
|
// MarshalSSZ ssz marshals the SyncCommitteeMessage object
|
|
func (s *SyncCommitteeMessage) MarshalSSZ() ([]byte, error) {
|
|
return ssz.MarshalSSZ(s)
|
|
}
|
|
|
|
// MarshalSSZTo ssz marshals the SyncCommitteeMessage object to a target array
|
|
func (s *SyncCommitteeMessage) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
|
dst = buf
|
|
|
|
// Field (0) 'Slot'
|
|
dst = ssz.MarshalUint64(dst, uint64(s.Slot))
|
|
|
|
// Field (1) 'BlockRoot'
|
|
if len(s.BlockRoot) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, s.BlockRoot...)
|
|
|
|
// Field (2) 'ValidatorIndex'
|
|
dst = ssz.MarshalUint64(dst, uint64(s.ValidatorIndex))
|
|
|
|
// Field (3) 'Signature'
|
|
if len(s.Signature) != 96 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, s.Signature...)
|
|
|
|
return
|
|
}
|
|
|
|
// UnmarshalSSZ ssz unmarshals the SyncCommitteeMessage object
|
|
func (s *SyncCommitteeMessage) UnmarshalSSZ(buf []byte) error {
|
|
var err error
|
|
size := uint64(len(buf))
|
|
if size != 144 {
|
|
return ssz.ErrSize
|
|
}
|
|
|
|
// Field (0) 'Slot'
|
|
s.Slot = github_com_prysmaticlabs_eth2_types.Slot(ssz.UnmarshallUint64(buf[0:8]))
|
|
|
|
// Field (1) 'BlockRoot'
|
|
if cap(s.BlockRoot) == 0 {
|
|
s.BlockRoot = make([]byte, 0, len(buf[8:40]))
|
|
}
|
|
s.BlockRoot = append(s.BlockRoot, buf[8:40]...)
|
|
|
|
// Field (2) 'ValidatorIndex'
|
|
s.ValidatorIndex = github_com_prysmaticlabs_eth2_types.ValidatorIndex(ssz.UnmarshallUint64(buf[40:48]))
|
|
|
|
// Field (3) 'Signature'
|
|
if cap(s.Signature) == 0 {
|
|
s.Signature = make([]byte, 0, len(buf[48:144]))
|
|
}
|
|
s.Signature = append(s.Signature, buf[48:144]...)
|
|
|
|
return err
|
|
}
|
|
|
|
// SizeSSZ returns the ssz encoded size in bytes for the SyncCommitteeMessage object
|
|
func (s *SyncCommitteeMessage) SizeSSZ() (size int) {
|
|
size = 144
|
|
return
|
|
}
|
|
|
|
// HashTreeRoot ssz hashes the SyncCommitteeMessage object
|
|
func (s *SyncCommitteeMessage) HashTreeRoot() ([32]byte, error) {
|
|
return ssz.HashWithDefaultHasher(s)
|
|
}
|
|
|
|
// HashTreeRootWith ssz hashes the SyncCommitteeMessage object with a hasher
|
|
func (s *SyncCommitteeMessage) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|
indx := hh.Index()
|
|
|
|
// Field (0) 'Slot'
|
|
hh.PutUint64(uint64(s.Slot))
|
|
|
|
// Field (1) 'BlockRoot'
|
|
if len(s.BlockRoot) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(s.BlockRoot)
|
|
|
|
// Field (2) 'ValidatorIndex'
|
|
hh.PutUint64(uint64(s.ValidatorIndex))
|
|
|
|
// Field (3) 'Signature'
|
|
if len(s.Signature) != 96 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(s.Signature)
|
|
|
|
hh.Merkleize(indx)
|
|
return
|
|
}
|
|
|
|
// MarshalSSZ ssz marshals the SyncCommitteeContribution object
|
|
func (s *SyncCommitteeContribution) MarshalSSZ() ([]byte, error) {
|
|
return ssz.MarshalSSZ(s)
|
|
}
|
|
|
|
// MarshalSSZTo ssz marshals the SyncCommitteeContribution object to a target array
|
|
func (s *SyncCommitteeContribution) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
|
dst = buf
|
|
|
|
// Field (0) 'Slot'
|
|
dst = ssz.MarshalUint64(dst, uint64(s.Slot))
|
|
|
|
// Field (1) 'BlockRoot'
|
|
if len(s.BlockRoot) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, s.BlockRoot...)
|
|
|
|
// Field (2) 'SubcommitteeIndex'
|
|
dst = ssz.MarshalUint64(dst, s.SubcommitteeIndex)
|
|
|
|
// Field (3) 'AggregationBits'
|
|
if len(s.AggregationBits) != 16 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, s.AggregationBits...)
|
|
|
|
// Field (4) 'Signature'
|
|
if len(s.Signature) != 96 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, s.Signature...)
|
|
|
|
return
|
|
}
|
|
|
|
// UnmarshalSSZ ssz unmarshals the SyncCommitteeContribution object
|
|
func (s *SyncCommitteeContribution) UnmarshalSSZ(buf []byte) error {
|
|
var err error
|
|
size := uint64(len(buf))
|
|
if size != 160 {
|
|
return ssz.ErrSize
|
|
}
|
|
|
|
// Field (0) 'Slot'
|
|
s.Slot = github_com_prysmaticlabs_eth2_types.Slot(ssz.UnmarshallUint64(buf[0:8]))
|
|
|
|
// Field (1) 'BlockRoot'
|
|
if cap(s.BlockRoot) == 0 {
|
|
s.BlockRoot = make([]byte, 0, len(buf[8:40]))
|
|
}
|
|
s.BlockRoot = append(s.BlockRoot, buf[8:40]...)
|
|
|
|
// Field (2) 'SubcommitteeIndex'
|
|
s.SubcommitteeIndex = ssz.UnmarshallUint64(buf[40:48])
|
|
|
|
// Field (3) 'AggregationBits'
|
|
if cap(s.AggregationBits) == 0 {
|
|
s.AggregationBits = make([]byte, 0, len(buf[48:64]))
|
|
}
|
|
s.AggregationBits = append(s.AggregationBits, buf[48:64]...)
|
|
|
|
// Field (4) 'Signature'
|
|
if cap(s.Signature) == 0 {
|
|
s.Signature = make([]byte, 0, len(buf[64:160]))
|
|
}
|
|
s.Signature = append(s.Signature, buf[64:160]...)
|
|
|
|
return err
|
|
}
|
|
|
|
// SizeSSZ returns the ssz encoded size in bytes for the SyncCommitteeContribution object
|
|
func (s *SyncCommitteeContribution) SizeSSZ() (size int) {
|
|
size = 160
|
|
return
|
|
}
|
|
|
|
// HashTreeRoot ssz hashes the SyncCommitteeContribution object
|
|
func (s *SyncCommitteeContribution) HashTreeRoot() ([32]byte, error) {
|
|
return ssz.HashWithDefaultHasher(s)
|
|
}
|
|
|
|
// HashTreeRootWith ssz hashes the SyncCommitteeContribution object with a hasher
|
|
func (s *SyncCommitteeContribution) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|
indx := hh.Index()
|
|
|
|
// Field (0) 'Slot'
|
|
hh.PutUint64(uint64(s.Slot))
|
|
|
|
// Field (1) 'BlockRoot'
|
|
if len(s.BlockRoot) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(s.BlockRoot)
|
|
|
|
// Field (2) 'SubcommitteeIndex'
|
|
hh.PutUint64(s.SubcommitteeIndex)
|
|
|
|
// Field (3) 'AggregationBits'
|
|
if len(s.AggregationBits) != 16 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(s.AggregationBits)
|
|
|
|
// Field (4) 'Signature'
|
|
if len(s.Signature) != 96 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(s.Signature)
|
|
|
|
hh.Merkleize(indx)
|
|
return
|
|
}
|
|
|
|
// MarshalSSZ ssz marshals the ContributionAndProof object
|
|
func (c *ContributionAndProof) MarshalSSZ() ([]byte, error) {
|
|
return ssz.MarshalSSZ(c)
|
|
}
|
|
|
|
// MarshalSSZTo ssz marshals the ContributionAndProof object to a target array
|
|
func (c *ContributionAndProof) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
|
dst = buf
|
|
|
|
// Field (0) 'AggregatorIndex'
|
|
dst = ssz.MarshalUint64(dst, uint64(c.AggregatorIndex))
|
|
|
|
// Field (1) 'Contribution'
|
|
if c.Contribution == nil {
|
|
c.Contribution = new(SyncCommitteeContribution)
|
|
}
|
|
if dst, err = c.Contribution.MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
|
|
// Field (2) 'SelectionProof'
|
|
if len(c.SelectionProof) != 96 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, c.SelectionProof...)
|
|
|
|
return
|
|
}
|
|
|
|
// UnmarshalSSZ ssz unmarshals the ContributionAndProof object
|
|
func (c *ContributionAndProof) UnmarshalSSZ(buf []byte) error {
|
|
var err error
|
|
size := uint64(len(buf))
|
|
if size != 264 {
|
|
return ssz.ErrSize
|
|
}
|
|
|
|
// Field (0) 'AggregatorIndex'
|
|
c.AggregatorIndex = github_com_prysmaticlabs_eth2_types.ValidatorIndex(ssz.UnmarshallUint64(buf[0:8]))
|
|
|
|
// Field (1) 'Contribution'
|
|
if c.Contribution == nil {
|
|
c.Contribution = new(SyncCommitteeContribution)
|
|
}
|
|
if err = c.Contribution.UnmarshalSSZ(buf[8:168]); err != nil {
|
|
return err
|
|
}
|
|
|
|
// Field (2) 'SelectionProof'
|
|
if cap(c.SelectionProof) == 0 {
|
|
c.SelectionProof = make([]byte, 0, len(buf[168:264]))
|
|
}
|
|
c.SelectionProof = append(c.SelectionProof, buf[168:264]...)
|
|
|
|
return err
|
|
}
|
|
|
|
// SizeSSZ returns the ssz encoded size in bytes for the ContributionAndProof object
|
|
func (c *ContributionAndProof) SizeSSZ() (size int) {
|
|
size = 264
|
|
return
|
|
}
|
|
|
|
// HashTreeRoot ssz hashes the ContributionAndProof object
|
|
func (c *ContributionAndProof) HashTreeRoot() ([32]byte, error) {
|
|
return ssz.HashWithDefaultHasher(c)
|
|
}
|
|
|
|
// HashTreeRootWith ssz hashes the ContributionAndProof object with a hasher
|
|
func (c *ContributionAndProof) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|
indx := hh.Index()
|
|
|
|
// Field (0) 'AggregatorIndex'
|
|
hh.PutUint64(uint64(c.AggregatorIndex))
|
|
|
|
// Field (1) 'Contribution'
|
|
if err = c.Contribution.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
|
|
// Field (2) 'SelectionProof'
|
|
if len(c.SelectionProof) != 96 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(c.SelectionProof)
|
|
|
|
hh.Merkleize(indx)
|
|
return
|
|
}
|
|
|
|
// MarshalSSZ ssz marshals the SignedContributionAndProof object
|
|
func (s *SignedContributionAndProof) MarshalSSZ() ([]byte, error) {
|
|
return ssz.MarshalSSZ(s)
|
|
}
|
|
|
|
// MarshalSSZTo ssz marshals the SignedContributionAndProof object to a target array
|
|
func (s *SignedContributionAndProof) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
|
dst = buf
|
|
|
|
// Field (0) 'Message'
|
|
if s.Message == nil {
|
|
s.Message = new(ContributionAndProof)
|
|
}
|
|
if dst, err = s.Message.MarshalSSZTo(dst); err != nil {
|
|
return
|
|
}
|
|
|
|
// Field (1) 'Signature'
|
|
if len(s.Signature) != 96 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, s.Signature...)
|
|
|
|
return
|
|
}
|
|
|
|
// UnmarshalSSZ ssz unmarshals the SignedContributionAndProof object
|
|
func (s *SignedContributionAndProof) UnmarshalSSZ(buf []byte) error {
|
|
var err error
|
|
size := uint64(len(buf))
|
|
if size != 360 {
|
|
return ssz.ErrSize
|
|
}
|
|
|
|
// Field (0) 'Message'
|
|
if s.Message == nil {
|
|
s.Message = new(ContributionAndProof)
|
|
}
|
|
if err = s.Message.UnmarshalSSZ(buf[0:264]); err != nil {
|
|
return err
|
|
}
|
|
|
|
// Field (1) 'Signature'
|
|
if cap(s.Signature) == 0 {
|
|
s.Signature = make([]byte, 0, len(buf[264:360]))
|
|
}
|
|
s.Signature = append(s.Signature, buf[264:360]...)
|
|
|
|
return err
|
|
}
|
|
|
|
// SizeSSZ returns the ssz encoded size in bytes for the SignedContributionAndProof object
|
|
func (s *SignedContributionAndProof) SizeSSZ() (size int) {
|
|
size = 360
|
|
return
|
|
}
|
|
|
|
// HashTreeRoot ssz hashes the SignedContributionAndProof object
|
|
func (s *SignedContributionAndProof) HashTreeRoot() ([32]byte, error) {
|
|
return ssz.HashWithDefaultHasher(s)
|
|
}
|
|
|
|
// HashTreeRootWith ssz hashes the SignedContributionAndProof object with a hasher
|
|
func (s *SignedContributionAndProof) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|
indx := hh.Index()
|
|
|
|
// Field (0) 'Message'
|
|
if err = s.Message.HashTreeRootWith(hh); err != nil {
|
|
return
|
|
}
|
|
|
|
// Field (1) 'Signature'
|
|
if len(s.Signature) != 96 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(s.Signature)
|
|
|
|
hh.Merkleize(indx)
|
|
return
|
|
}
|
|
|
|
// MarshalSSZ ssz marshals the Validator object
|
|
func (v *Validator) MarshalSSZ() ([]byte, error) {
|
|
return ssz.MarshalSSZ(v)
|
|
}
|
|
|
|
// MarshalSSZTo ssz marshals the Validator object to a target array
|
|
func (v *Validator) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
|
dst = buf
|
|
|
|
// Field (0) 'PublicKey'
|
|
if len(v.PublicKey) != 48 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, v.PublicKey...)
|
|
|
|
// Field (1) 'WithdrawalCredentials'
|
|
if len(v.WithdrawalCredentials) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
dst = append(dst, v.WithdrawalCredentials...)
|
|
|
|
// Field (2) 'EffectiveBalance'
|
|
dst = ssz.MarshalUint64(dst, v.EffectiveBalance)
|
|
|
|
// Field (3) 'Slashed'
|
|
dst = ssz.MarshalBool(dst, v.Slashed)
|
|
|
|
// Field (4) 'ActivationEligibilityEpoch'
|
|
dst = ssz.MarshalUint64(dst, uint64(v.ActivationEligibilityEpoch))
|
|
|
|
// Field (5) 'ActivationEpoch'
|
|
dst = ssz.MarshalUint64(dst, uint64(v.ActivationEpoch))
|
|
|
|
// Field (6) 'ExitEpoch'
|
|
dst = ssz.MarshalUint64(dst, uint64(v.ExitEpoch))
|
|
|
|
// Field (7) 'WithdrawableEpoch'
|
|
dst = ssz.MarshalUint64(dst, uint64(v.WithdrawableEpoch))
|
|
|
|
return
|
|
}
|
|
|
|
// UnmarshalSSZ ssz unmarshals the Validator object
|
|
func (v *Validator) UnmarshalSSZ(buf []byte) error {
|
|
var err error
|
|
size := uint64(len(buf))
|
|
if size != 121 {
|
|
return ssz.ErrSize
|
|
}
|
|
|
|
// Field (0) 'PublicKey'
|
|
if cap(v.PublicKey) == 0 {
|
|
v.PublicKey = make([]byte, 0, len(buf[0:48]))
|
|
}
|
|
v.PublicKey = append(v.PublicKey, buf[0:48]...)
|
|
|
|
// Field (1) 'WithdrawalCredentials'
|
|
if cap(v.WithdrawalCredentials) == 0 {
|
|
v.WithdrawalCredentials = make([]byte, 0, len(buf[48:80]))
|
|
}
|
|
v.WithdrawalCredentials = append(v.WithdrawalCredentials, buf[48:80]...)
|
|
|
|
// Field (2) 'EffectiveBalance'
|
|
v.EffectiveBalance = ssz.UnmarshallUint64(buf[80:88])
|
|
|
|
// Field (3) 'Slashed'
|
|
v.Slashed = ssz.UnmarshalBool(buf[88:89])
|
|
|
|
// Field (4) 'ActivationEligibilityEpoch'
|
|
v.ActivationEligibilityEpoch = github_com_prysmaticlabs_eth2_types.Epoch(ssz.UnmarshallUint64(buf[89:97]))
|
|
|
|
// Field (5) 'ActivationEpoch'
|
|
v.ActivationEpoch = github_com_prysmaticlabs_eth2_types.Epoch(ssz.UnmarshallUint64(buf[97:105]))
|
|
|
|
// Field (6) 'ExitEpoch'
|
|
v.ExitEpoch = github_com_prysmaticlabs_eth2_types.Epoch(ssz.UnmarshallUint64(buf[105:113]))
|
|
|
|
// Field (7) 'WithdrawableEpoch'
|
|
v.WithdrawableEpoch = github_com_prysmaticlabs_eth2_types.Epoch(ssz.UnmarshallUint64(buf[113:121]))
|
|
|
|
return err
|
|
}
|
|
|
|
// SizeSSZ returns the ssz encoded size in bytes for the Validator object
|
|
func (v *Validator) SizeSSZ() (size int) {
|
|
size = 121
|
|
return
|
|
}
|
|
|
|
// HashTreeRoot ssz hashes the Validator object
|
|
func (v *Validator) HashTreeRoot() ([32]byte, error) {
|
|
return ssz.HashWithDefaultHasher(v)
|
|
}
|
|
|
|
// HashTreeRootWith ssz hashes the Validator object with a hasher
|
|
func (v *Validator) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
|
indx := hh.Index()
|
|
|
|
// Field (0) 'PublicKey'
|
|
if len(v.PublicKey) != 48 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(v.PublicKey)
|
|
|
|
// Field (1) 'WithdrawalCredentials'
|
|
if len(v.WithdrawalCredentials) != 32 {
|
|
err = ssz.ErrBytesLength
|
|
return
|
|
}
|
|
hh.PutBytes(v.WithdrawalCredentials)
|
|
|
|
// Field (2) 'EffectiveBalance'
|
|
hh.PutUint64(v.EffectiveBalance)
|
|
|
|
// Field (3) 'Slashed'
|
|
hh.PutBool(v.Slashed)
|
|
|
|
// Field (4) 'ActivationEligibilityEpoch'
|
|
hh.PutUint64(uint64(v.ActivationEligibilityEpoch))
|
|
|
|
// Field (5) 'ActivationEpoch'
|
|
hh.PutUint64(uint64(v.ActivationEpoch))
|
|
|
|
// Field (6) 'ExitEpoch'
|
|
hh.PutUint64(uint64(v.ExitEpoch))
|
|
|
|
// Field (7) 'WithdrawableEpoch'
|
|
hh.PutUint64(uint64(v.WithdrawableEpoch))
|
|
|
|
hh.Merkleize(indx)
|
|
return
|
|
}
|