diff --git a/beacon-chain/blockchain/service.go b/beacon-chain/blockchain/service.go index 8faa3d43a49b..09d0cce7906d 100644 --- a/beacon-chain/blockchain/service.go +++ b/beacon-chain/blockchain/service.go @@ -13,7 +13,6 @@ import ( "github.com/pkg/errors" "go.opencensus.io/trace" - "github.com/ethereum/go-ethereum/common" "github.com/prysmaticlabs/prysm/v5/async/event" "github.com/prysmaticlabs/prysm/v5/beacon-chain/blockchain/kzg" "github.com/prysmaticlabs/prysm/v5/beacon-chain/cache" @@ -291,6 +290,10 @@ func (s *Service) StartFromSavedState(saved state.BeaconState) error { fRoot := s.ensureRootNotZeros(bytesutil.ToBytes32(finalized.Root)) s.cfg.ForkChoiceStore.Lock() defer s.cfg.ForkChoiceStore.Unlock() + if err := s.cfg.ForkChoiceStore.UpdateJustifiedCheckpoint(s.ctx, &forkchoicetypes.Checkpoint{Epoch: justified.Epoch, + Root: bytesutil.ToBytes32(justified.Root)}); err != nil { + return errors.Wrap(err, "could not update forkchoice's justified checkpoint") + } if err := s.cfg.ForkChoiceStore.UpdateFinalizedCheckpoint(&forkchoicetypes.Checkpoint{Epoch: finalized.Epoch, Root: bytesutil.ToBytes32(finalized.Root)}); err != nil { return errors.Wrap(err, "could not update forkchoice's finalized checkpoint") @@ -304,26 +307,6 @@ func (s *Service) StartFromSavedState(saved state.BeaconState) error { if err := s.cfg.ForkChoiceStore.InsertNode(s.ctx, st, fRoot); err != nil { return errors.Wrap(err, "could not insert finalized block to forkchoice") } - - var ( - roots [][32]byte - states []state.BeaconState - jRoot = s.ensureRootNotZeros(bytesutil.ToBytes32(justified.Root)) - ) - for parentRoot := jRoot; common.BytesToHash(fRoot[:]) != common.BytesToHash(parentRoot[:]); { - parentState, err := s.cfg.StateGen.StateByRoot(s.ctx, parentRoot) - if err != nil { - return errors.Wrap(err, "could not get parent state") - } - roots = append(roots, parentRoot) - states = append(states, parentState) - parentRoot = bytesutil.ToBytes32(parentState.LatestBlockHeader().ParentRoot) - } - for i := len(roots) - 1; i >= 0; i-- { - if err := s.cfg.ForkChoiceStore.InsertNode(s.ctx, states[i], roots[i]); err != nil { - return errors.Wrap(err, "could not insert block to forkchoice") - } - } if !features.Get().EnableStartOptimistic { lastValidatedCheckpoint, err := s.cfg.BeaconDB.LastValidatedCheckpoint(s.ctx) if err != nil { diff --git a/build/dockerfiles/Dockerfile b/build/dockerfiles/Dockerfile index 0227854fef60..d2599cf52b35 100644 --- a/build/dockerfiles/Dockerfile +++ b/build/dockerfiles/Dockerfile @@ -1,5 +1,5 @@ # Build Geth in a stock Go builder container -FROM --platform=${BUILDPLATFORM} golang:1.21 as builder +FROM --platform=${BUILDPLATFORM} golang:1.21 AS builder RUN apt-get update && apt-get install -y \ gcc \ diff --git a/proto/engine/v1/engine.ssz.go b/proto/engine/v1/engine.ssz.go index c8b73b594749..5a1f77324a87 100644 --- a/proto/engine/v1/engine.ssz.go +++ b/proto/engine/v1/engine.ssz.go @@ -1258,886 +1258,15 @@ func (e *ExecutionPayloadDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { return } -// MarshalSSZ ssz marshals the ExecutionPayloadElectra object -func (e *ExecutionPayloadElectra) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(e) -} - -// MarshalSSZTo ssz marshals the ExecutionPayloadElectra object to a target array -func (e *ExecutionPayloadElectra) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - offset := int(536) - - // Field (0) 'ParentHash' - if size := len(e.ParentHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentHash", size, 32) - return - } - dst = append(dst, e.ParentHash...) - - // Field (1) 'FeeRecipient' - if size := len(e.FeeRecipient); size != 20 { - err = ssz.ErrBytesLengthFn("--.FeeRecipient", size, 20) - return - } - dst = append(dst, e.FeeRecipient...) - - // Field (2) 'StateRoot' - if size := len(e.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return - } - dst = append(dst, e.StateRoot...) - - // Field (3) 'ReceiptsRoot' - if size := len(e.ReceiptsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ReceiptsRoot", size, 32) - return - } - dst = append(dst, e.ReceiptsRoot...) - - // Field (4) 'LogsBloom' - if size := len(e.LogsBloom); size != 256 { - err = ssz.ErrBytesLengthFn("--.LogsBloom", size, 256) - return - } - dst = append(dst, e.LogsBloom...) - - // Field (5) 'PrevRandao' - if size := len(e.PrevRandao); size != 32 { - err = ssz.ErrBytesLengthFn("--.PrevRandao", size, 32) - 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 size := len(e.BaseFeePerGas); size != 32 { - err = ssz.ErrBytesLengthFn("--.BaseFeePerGas", size, 32) - return - } - dst = append(dst, e.BaseFeePerGas...) - - // Field (12) 'BlockHash' - if size := len(e.BlockHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockHash", size, 32) - return - } - dst = append(dst, e.BlockHash...) - - // Offset (13) 'Transactions' - dst = ssz.WriteOffset(dst, offset) - for ii := 0; ii < len(e.Transactions); ii++ { - offset += 4 - offset += len(e.Transactions[ii]) - } - - // Offset (14) 'Withdrawals' - dst = ssz.WriteOffset(dst, offset) - offset += len(e.Withdrawals) * 44 - - // Field (15) 'BlobGasUsed' - dst = ssz.MarshalUint64(dst, e.BlobGasUsed) - - // Field (16) 'ExcessBlobGas' - dst = ssz.MarshalUint64(dst, e.ExcessBlobGas) - - // Offset (17) 'DepositRequests' - dst = ssz.WriteOffset(dst, offset) - offset += len(e.DepositRequests) * 192 - - // Offset (18) 'WithdrawalRequests' - dst = ssz.WriteOffset(dst, offset) - offset += len(e.WithdrawalRequests) * 76 - - // Field (10) 'ExtraData' - if size := len(e.ExtraData); size > 32 { - err = ssz.ErrBytesLengthFn("--.ExtraData", size, 32) - return - } - dst = append(dst, e.ExtraData...) - - // Field (13) 'Transactions' - if size := len(e.Transactions); size > 1048576 { - err = ssz.ErrListTooBigFn("--.Transactions", size, 1048576) - return - } - { - offset = 4 * len(e.Transactions) - for ii := 0; ii < len(e.Transactions); ii++ { - dst = ssz.WriteOffset(dst, offset) - offset += len(e.Transactions[ii]) - } - } - for ii := 0; ii < len(e.Transactions); ii++ { - if size := len(e.Transactions[ii]); size > 1073741824 { - err = ssz.ErrBytesLengthFn("--.Transactions[ii]", size, 1073741824) - return - } - dst = append(dst, e.Transactions[ii]...) - } - - // Field (14) 'Withdrawals' - if size := len(e.Withdrawals); size > 16 { - err = ssz.ErrListTooBigFn("--.Withdrawals", size, 16) - return - } - for ii := 0; ii < len(e.Withdrawals); ii++ { - if dst, err = e.Withdrawals[ii].MarshalSSZTo(dst); err != nil { - return - } - } - - // Field (17) 'DepositRequests' - if size := len(e.DepositRequests); size > 8192 { - err = ssz.ErrListTooBigFn("--.DepositRequests", size, 8192) - return - } - for ii := 0; ii < len(e.DepositRequests); ii++ { - if dst, err = e.DepositRequests[ii].MarshalSSZTo(dst); err != nil { - return - } - } - - // Field (18) 'WithdrawalRequests' - if size := len(e.WithdrawalRequests); size > 16 { - err = ssz.ErrListTooBigFn("--.WithdrawalRequests", size, 16) - return - } - for ii := 0; ii < len(e.WithdrawalRequests); ii++ { - if dst, err = e.WithdrawalRequests[ii].MarshalSSZTo(dst); err != nil { - return - } - } - - return -} - -// UnmarshalSSZ ssz unmarshals the ExecutionPayloadElectra object -func (e *ExecutionPayloadElectra) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 536 { - return ssz.ErrSize - } - - tail := buf - var o10, o13, o14, o17, o18 uint64 - - // Field (0) 'ParentHash' - if cap(e.ParentHash) == 0 { - e.ParentHash = make([]byte, 0, len(buf[0:32])) - } - e.ParentHash = append(e.ParentHash, buf[0:32]...) - - // Field (1) 'FeeRecipient' - if cap(e.FeeRecipient) == 0 { - e.FeeRecipient = make([]byte, 0, len(buf[32:52])) - } - e.FeeRecipient = append(e.FeeRecipient, buf[32:52]...) - - // Field (2) 'StateRoot' - if cap(e.StateRoot) == 0 { - e.StateRoot = make([]byte, 0, len(buf[52:84])) - } - e.StateRoot = append(e.StateRoot, buf[52:84]...) - - // Field (3) 'ReceiptsRoot' - if cap(e.ReceiptsRoot) == 0 { - e.ReceiptsRoot = make([]byte, 0, len(buf[84:116])) - } - e.ReceiptsRoot = append(e.ReceiptsRoot, buf[84:116]...) - - // Field (4) 'LogsBloom' - if cap(e.LogsBloom) == 0 { - e.LogsBloom = make([]byte, 0, len(buf[116:372])) - } - e.LogsBloom = append(e.LogsBloom, buf[116:372]...) - - // Field (5) 'PrevRandao' - if cap(e.PrevRandao) == 0 { - e.PrevRandao = make([]byte, 0, len(buf[372:404])) - } - e.PrevRandao = append(e.PrevRandao, buf[372:404]...) - - // Field (6) 'BlockNumber' - e.BlockNumber = ssz.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]...) - - // Offset (13) 'Transactions' - if o13 = ssz.ReadOffset(buf[504:508]); o13 > size || o10 > o13 { - return ssz.ErrOffset - } - - // Offset (14) 'Withdrawals' - if o14 = ssz.ReadOffset(buf[508:512]); o14 > size || o13 > o14 { - return ssz.ErrOffset - } - - // Field (15) 'BlobGasUsed' - e.BlobGasUsed = ssz.UnmarshallUint64(buf[512:520]) - - // Field (16) 'ExcessBlobGas' - e.ExcessBlobGas = ssz.UnmarshallUint64(buf[520:528]) - - // Offset (17) 'DepositRequests' - if o17 = ssz.ReadOffset(buf[528:532]); o17 > size || o14 > o17 { - return ssz.ErrOffset - } - - // Offset (18) 'WithdrawalRequests' - if o18 = ssz.ReadOffset(buf[532:536]); o18 > size || o17 > o18 { - return ssz.ErrOffset - } - - // Field (10) 'ExtraData' - { - buf = tail[o10:o13] - if len(buf) > 32 { - return ssz.ErrBytesLength - } - if cap(e.ExtraData) == 0 { - e.ExtraData = make([]byte, 0, len(buf)) - } - e.ExtraData = append(e.ExtraData, buf...) - } - - // Field (13) 'Transactions' - { - buf = tail[o13:o14] - num, err := ssz.DecodeDynamicLength(buf, 1048576) - if err != nil { - return err - } - e.Transactions = make([][]byte, num) - err = ssz.UnmarshalDynamic(buf, num, func(indx int, buf []byte) (err error) { - if len(buf) > 1073741824 { - return ssz.ErrBytesLength - } - if cap(e.Transactions[indx]) == 0 { - e.Transactions[indx] = make([]byte, 0, len(buf)) - } - e.Transactions[indx] = append(e.Transactions[indx], buf...) - return nil - }) - if err != nil { - return err - } - } - - // Field (14) 'Withdrawals' - { - buf = tail[o14:o17] - num, err := ssz.DivideInt2(len(buf), 44, 16) - if err != nil { - return err - } - e.Withdrawals = make([]*Withdrawal, num) - for ii := 0; ii < num; ii++ { - if e.Withdrawals[ii] == nil { - e.Withdrawals[ii] = new(Withdrawal) - } - if err = e.Withdrawals[ii].UnmarshalSSZ(buf[ii*44 : (ii+1)*44]); err != nil { - return err - } - } - } - - // Field (17) 'DepositRequests' - { - buf = tail[o17:o18] - num, err := ssz.DivideInt2(len(buf), 192, 8192) - if err != nil { - return err - } - e.DepositRequests = make([]*DepositRequest, num) - for ii := 0; ii < num; ii++ { - if e.DepositRequests[ii] == nil { - e.DepositRequests[ii] = new(DepositRequest) - } - if err = e.DepositRequests[ii].UnmarshalSSZ(buf[ii*192 : (ii+1)*192]); err != nil { - return err - } - } - } - - // Field (18) 'WithdrawalRequests' - { - buf = tail[o18:] - num, err := ssz.DivideInt2(len(buf), 76, 16) - if err != nil { - return err - } - e.WithdrawalRequests = make([]*WithdrawalRequest, num) - for ii := 0; ii < num; ii++ { - if e.WithdrawalRequests[ii] == nil { - e.WithdrawalRequests[ii] = new(WithdrawalRequest) - } - if err = e.WithdrawalRequests[ii].UnmarshalSSZ(buf[ii*76 : (ii+1)*76]); err != nil { - return err - } - } - } - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the ExecutionPayloadElectra object -func (e *ExecutionPayloadElectra) SizeSSZ() (size int) { - size = 536 - - // Field (10) 'ExtraData' - size += len(e.ExtraData) - - // Field (13) 'Transactions' - for ii := 0; ii < len(e.Transactions); ii++ { - size += 4 - size += len(e.Transactions[ii]) - } - - // Field (14) 'Withdrawals' - size += len(e.Withdrawals) * 44 - - // Field (17) 'DepositRequests' - size += len(e.DepositRequests) * 192 - - // Field (18) 'WithdrawalRequests' - size += len(e.WithdrawalRequests) * 76 - - return -} - -// HashTreeRoot ssz hashes the ExecutionPayloadElectra object -func (e *ExecutionPayloadElectra) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(e) -} - -// HashTreeRootWith ssz hashes the ExecutionPayloadElectra object with a hasher -func (e *ExecutionPayloadElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'ParentHash' - if size := len(e.ParentHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentHash", size, 32) - return - } - hh.PutBytes(e.ParentHash) - - // Field (1) 'FeeRecipient' - if size := len(e.FeeRecipient); size != 20 { - err = ssz.ErrBytesLengthFn("--.FeeRecipient", size, 20) - return - } - hh.PutBytes(e.FeeRecipient) - - // Field (2) 'StateRoot' - if size := len(e.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return - } - hh.PutBytes(e.StateRoot) - - // Field (3) 'ReceiptsRoot' - if size := len(e.ReceiptsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ReceiptsRoot", size, 32) - return - } - hh.PutBytes(e.ReceiptsRoot) - - // Field (4) 'LogsBloom' - if size := len(e.LogsBloom); size != 256 { - err = ssz.ErrBytesLengthFn("--.LogsBloom", size, 256) - return - } - hh.PutBytes(e.LogsBloom) - - // Field (5) 'PrevRandao' - if size := len(e.PrevRandao); size != 32 { - err = ssz.ErrBytesLengthFn("--.PrevRandao", size, 32) - return - } - hh.PutBytes(e.PrevRandao) - - // Field (6) 'BlockNumber' - 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 size := len(e.BaseFeePerGas); size != 32 { - err = ssz.ErrBytesLengthFn("--.BaseFeePerGas", size, 32) - return - } - hh.PutBytes(e.BaseFeePerGas) - - // Field (12) 'BlockHash' - if size := len(e.BlockHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockHash", size, 32) - return - } - hh.PutBytes(e.BlockHash) - - // Field (13) 'Transactions' - { - subIndx := hh.Index() - num := uint64(len(e.Transactions)) - if num > 1048576 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range e.Transactions { - { - elemIndx := hh.Index() - byteLen := uint64(len(elem)) - if byteLen > 1073741824 { - err = ssz.ErrIncorrectListSize - return - } - hh.AppendBytes32(elem) - hh.MerkleizeWithMixin(elemIndx, byteLen, (1073741824+31)/32) - } - } - hh.MerkleizeWithMixin(subIndx, num, 1048576) - } - - // Field (14) 'Withdrawals' - { - subIndx := hh.Index() - num := uint64(len(e.Withdrawals)) - if num > 16 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range e.Withdrawals { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } - } - hh.MerkleizeWithMixin(subIndx, num, 16) - } - - // Field (15) 'BlobGasUsed' - hh.PutUint64(e.BlobGasUsed) - - // Field (16) 'ExcessBlobGas' - hh.PutUint64(e.ExcessBlobGas) - - // Field (17) 'DepositRequests' - { - subIndx := hh.Index() - num := uint64(len(e.DepositRequests)) - if num > 8192 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range e.DepositRequests { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } - } - hh.MerkleizeWithMixin(subIndx, num, 8192) - } - - // Field (18) 'WithdrawalRequests' - { - subIndx := hh.Index() - num := uint64(len(e.WithdrawalRequests)) - if num > 16 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range e.WithdrawalRequests { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } - } - hh.MerkleizeWithMixin(subIndx, num, 16) - } - - 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 size := len(e.ParentHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentHash", size, 32) - return - } - dst = append(dst, e.ParentHash...) - - // Field (1) 'FeeRecipient' - if size := len(e.FeeRecipient); size != 20 { - err = ssz.ErrBytesLengthFn("--.FeeRecipient", size, 20) - return - } - dst = append(dst, e.FeeRecipient...) - - // Field (2) 'StateRoot' - if size := len(e.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return - } - dst = append(dst, e.StateRoot...) - - // Field (3) 'ReceiptsRoot' - if size := len(e.ReceiptsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ReceiptsRoot", size, 32) - return - } - dst = append(dst, e.ReceiptsRoot...) - - // Field (4) 'LogsBloom' - if size := len(e.LogsBloom); size != 256 { - err = ssz.ErrBytesLengthFn("--.LogsBloom", size, 256) - return - } - dst = append(dst, e.LogsBloom...) - - // Field (5) 'PrevRandao' - if size := len(e.PrevRandao); size != 32 { - err = ssz.ErrBytesLengthFn("--.PrevRandao", size, 32) - 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 size := len(e.BaseFeePerGas); size != 32 { - err = ssz.ErrBytesLengthFn("--.BaseFeePerGas", size, 32) - return - } - dst = append(dst, e.BaseFeePerGas...) - - // Field (12) 'BlockHash' - if size := len(e.BlockHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockHash", size, 32) - return - } - dst = append(dst, e.BlockHash...) - - // Field (13) 'TransactionsRoot' - if size := len(e.TransactionsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.TransactionsRoot", size, 32) - return - } - dst = append(dst, e.TransactionsRoot...) - - // Field (10) 'ExtraData' - if size := len(e.ExtraData); size > 32 { - err = ssz.ErrBytesLengthFn("--.ExtraData", size, 32) - return - } - dst = append(dst, e.ExtraData...) - - return -} - -// UnmarshalSSZ ssz unmarshals the ExecutionPayloadHeader object -func (e *ExecutionPayloadHeader) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size < 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) 'ReceiptsRoot' - if cap(e.ReceiptsRoot) == 0 { - e.ReceiptsRoot = make([]byte, 0, len(buf[84:116])) - } - e.ReceiptsRoot = append(e.ReceiptsRoot, buf[84:116]...) - - // Field (4) 'LogsBloom' - if cap(e.LogsBloom) == 0 { - e.LogsBloom = make([]byte, 0, len(buf[116:372])) - } - e.LogsBloom = append(e.LogsBloom, buf[116:372]...) - - // Field (5) 'PrevRandao' - if cap(e.PrevRandao) == 0 { - e.PrevRandao = make([]byte, 0, len(buf[372:404])) - } - e.PrevRandao = append(e.PrevRandao, buf[372:404]...) - - // Field (6) 'BlockNumber' - e.BlockNumber = ssz.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 size := len(e.ParentHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.ParentHash", size, 32) - return - } - hh.PutBytes(e.ParentHash) - - // Field (1) 'FeeRecipient' - if size := len(e.FeeRecipient); size != 20 { - err = ssz.ErrBytesLengthFn("--.FeeRecipient", size, 20) - return - } - hh.PutBytes(e.FeeRecipient) - - // Field (2) 'StateRoot' - if size := len(e.StateRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.StateRoot", size, 32) - return - } - hh.PutBytes(e.StateRoot) - - // Field (3) 'ReceiptsRoot' - if size := len(e.ReceiptsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.ReceiptsRoot", size, 32) - return - } - hh.PutBytes(e.ReceiptsRoot) - - // Field (4) 'LogsBloom' - if size := len(e.LogsBloom); size != 256 { - err = ssz.ErrBytesLengthFn("--.LogsBloom", size, 256) - return - } - hh.PutBytes(e.LogsBloom) - - // Field (5) 'PrevRandao' - if size := len(e.PrevRandao); size != 32 { - err = ssz.ErrBytesLengthFn("--.PrevRandao", size, 32) - return - } - hh.PutBytes(e.PrevRandao) - - // Field (6) 'BlockNumber' - 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 size := len(e.BaseFeePerGas); size != 32 { - err = ssz.ErrBytesLengthFn("--.BaseFeePerGas", size, 32) - return - } - hh.PutBytes(e.BaseFeePerGas) - - // Field (12) 'BlockHash' - if size := len(e.BlockHash); size != 32 { - err = ssz.ErrBytesLengthFn("--.BlockHash", size, 32) - return - } - hh.PutBytes(e.BlockHash) - - // Field (13) 'TransactionsRoot' - if size := len(e.TransactionsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.TransactionsRoot", size, 32) - return - } - hh.PutBytes(e.TransactionsRoot) - - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the ExecutionPayloadHeaderCapella object -func (e *ExecutionPayloadHeaderCapella) MarshalSSZ() ([]byte, error) { +// MarshalSSZ ssz marshals the ExecutionPayloadHeader object +func (e *ExecutionPayloadHeader) MarshalSSZ() ([]byte, error) { return ssz.MarshalSSZ(e) } -// MarshalSSZTo ssz marshals the ExecutionPayloadHeaderCapella object to a target array -func (e *ExecutionPayloadHeaderCapella) MarshalSSZTo(buf []byte) (dst []byte, err error) { +// MarshalSSZTo ssz marshals the ExecutionPayloadHeader object to a target array +func (e *ExecutionPayloadHeader) MarshalSSZTo(buf []byte) (dst []byte, err error) { dst = buf - offset := int(568) + offset := int(536) // Field (0) 'ParentHash' if size := len(e.ParentHash); size != 32 { @@ -2218,13 +1347,6 @@ func (e *ExecutionPayloadHeaderCapella) MarshalSSZTo(buf []byte) (dst []byte, er } dst = append(dst, e.TransactionsRoot...) - // Field (14) 'WithdrawalsRoot' - if size := len(e.WithdrawalsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.WithdrawalsRoot", size, 32) - return - } - dst = append(dst, e.WithdrawalsRoot...) - // Field (10) 'ExtraData' if size := len(e.ExtraData); size > 32 { err = ssz.ErrBytesLengthFn("--.ExtraData", size, 32) @@ -2235,11 +1357,11 @@ func (e *ExecutionPayloadHeaderCapella) MarshalSSZTo(buf []byte) (dst []byte, er return } -// UnmarshalSSZ ssz unmarshals the ExecutionPayloadHeaderCapella object -func (e *ExecutionPayloadHeaderCapella) UnmarshalSSZ(buf []byte) error { +// UnmarshalSSZ ssz unmarshals the ExecutionPayloadHeader object +func (e *ExecutionPayloadHeader) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 568 { + if size < 536 { return ssz.ErrSize } @@ -2299,7 +1421,7 @@ func (e *ExecutionPayloadHeaderCapella) UnmarshalSSZ(buf []byte) error { return ssz.ErrOffset } - if o10 != 568 { + if o10 != 536 { return ssz.ErrInvalidVariableOffset } @@ -2321,12 +1443,6 @@ func (e *ExecutionPayloadHeaderCapella) UnmarshalSSZ(buf []byte) error { } e.TransactionsRoot = append(e.TransactionsRoot, buf[504:536]...) - // Field (14) 'WithdrawalsRoot' - if cap(e.WithdrawalsRoot) == 0 { - e.WithdrawalsRoot = make([]byte, 0, len(buf[536:568])) - } - e.WithdrawalsRoot = append(e.WithdrawalsRoot, buf[536:568]...) - // Field (10) 'ExtraData' { buf = tail[o10:] @@ -2341,9 +1457,9 @@ func (e *ExecutionPayloadHeaderCapella) UnmarshalSSZ(buf []byte) error { return err } -// SizeSSZ returns the ssz encoded size in bytes for the ExecutionPayloadHeaderCapella object -func (e *ExecutionPayloadHeaderCapella) SizeSSZ() (size int) { - size = 568 +// 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) @@ -2351,13 +1467,13 @@ func (e *ExecutionPayloadHeaderCapella) SizeSSZ() (size int) { return } -// HashTreeRoot ssz hashes the ExecutionPayloadHeaderCapella object -func (e *ExecutionPayloadHeaderCapella) HashTreeRoot() ([32]byte, error) { +// HashTreeRoot ssz hashes the ExecutionPayloadHeader object +func (e *ExecutionPayloadHeader) HashTreeRoot() ([32]byte, error) { return ssz.HashWithDefaultHasher(e) } -// HashTreeRootWith ssz hashes the ExecutionPayloadHeaderCapella object with a hasher -func (e *ExecutionPayloadHeaderCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) { +// HashTreeRootWith ssz hashes the ExecutionPayloadHeader object with a hasher +func (e *ExecutionPayloadHeader) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() // Field (0) 'ParentHash' @@ -2447,26 +1563,19 @@ func (e *ExecutionPayloadHeaderCapella) HashTreeRootWith(hh *ssz.Hasher) (err er } hh.PutBytes(e.TransactionsRoot) - // Field (14) 'WithdrawalsRoot' - if size := len(e.WithdrawalsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.WithdrawalsRoot", size, 32) - return - } - hh.PutBytes(e.WithdrawalsRoot) - hh.Merkleize(indx) return } -// MarshalSSZ ssz marshals the ExecutionPayloadHeaderDeneb object -func (e *ExecutionPayloadHeaderDeneb) MarshalSSZ() ([]byte, error) { +// MarshalSSZ ssz marshals the ExecutionPayloadHeaderCapella object +func (e *ExecutionPayloadHeaderCapella) MarshalSSZ() ([]byte, error) { return ssz.MarshalSSZ(e) } -// MarshalSSZTo ssz marshals the ExecutionPayloadHeaderDeneb object to a target array -func (e *ExecutionPayloadHeaderDeneb) MarshalSSZTo(buf []byte) (dst []byte, err error) { +// MarshalSSZTo ssz marshals the ExecutionPayloadHeaderCapella object to a target array +func (e *ExecutionPayloadHeaderCapella) MarshalSSZTo(buf []byte) (dst []byte, err error) { dst = buf - offset := int(584) + offset := int(568) // Field (0) 'ParentHash' if size := len(e.ParentHash); size != 32 { @@ -2554,12 +1663,6 @@ func (e *ExecutionPayloadHeaderDeneb) MarshalSSZTo(buf []byte) (dst []byte, err } dst = append(dst, e.WithdrawalsRoot...) - // Field (15) 'BlobGasUsed' - dst = ssz.MarshalUint64(dst, e.BlobGasUsed) - - // Field (16) 'ExcessBlobGas' - dst = ssz.MarshalUint64(dst, e.ExcessBlobGas) - // Field (10) 'ExtraData' if size := len(e.ExtraData); size > 32 { err = ssz.ErrBytesLengthFn("--.ExtraData", size, 32) @@ -2570,11 +1673,11 @@ func (e *ExecutionPayloadHeaderDeneb) MarshalSSZTo(buf []byte) (dst []byte, err return } -// UnmarshalSSZ ssz unmarshals the ExecutionPayloadHeaderDeneb object -func (e *ExecutionPayloadHeaderDeneb) UnmarshalSSZ(buf []byte) error { +// UnmarshalSSZ ssz unmarshals the ExecutionPayloadHeaderCapella object +func (e *ExecutionPayloadHeaderCapella) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 584 { + if size < 568 { return ssz.ErrSize } @@ -2634,7 +1737,7 @@ func (e *ExecutionPayloadHeaderDeneb) UnmarshalSSZ(buf []byte) error { return ssz.ErrOffset } - if o10 != 584 { + if o10 != 568 { return ssz.ErrInvalidVariableOffset } @@ -2662,12 +1765,6 @@ func (e *ExecutionPayloadHeaderDeneb) UnmarshalSSZ(buf []byte) error { } e.WithdrawalsRoot = append(e.WithdrawalsRoot, buf[536:568]...) - // Field (15) 'BlobGasUsed' - e.BlobGasUsed = ssz.UnmarshallUint64(buf[568:576]) - - // Field (16) 'ExcessBlobGas' - e.ExcessBlobGas = ssz.UnmarshallUint64(buf[576:584]) - // Field (10) 'ExtraData' { buf = tail[o10:] @@ -2682,9 +1779,9 @@ func (e *ExecutionPayloadHeaderDeneb) UnmarshalSSZ(buf []byte) error { return err } -// SizeSSZ returns the ssz encoded size in bytes for the ExecutionPayloadHeaderDeneb object -func (e *ExecutionPayloadHeaderDeneb) SizeSSZ() (size int) { - size = 584 +// SizeSSZ returns the ssz encoded size in bytes for the ExecutionPayloadHeaderCapella object +func (e *ExecutionPayloadHeaderCapella) SizeSSZ() (size int) { + size = 568 // Field (10) 'ExtraData' size += len(e.ExtraData) @@ -2692,13 +1789,13 @@ func (e *ExecutionPayloadHeaderDeneb) SizeSSZ() (size int) { return } -// HashTreeRoot ssz hashes the ExecutionPayloadHeaderDeneb object -func (e *ExecutionPayloadHeaderDeneb) HashTreeRoot() ([32]byte, error) { +// HashTreeRoot ssz hashes the ExecutionPayloadHeaderCapella object +func (e *ExecutionPayloadHeaderCapella) HashTreeRoot() ([32]byte, error) { return ssz.HashWithDefaultHasher(e) } -// HashTreeRootWith ssz hashes the ExecutionPayloadHeaderDeneb object with a hasher -func (e *ExecutionPayloadHeaderDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { +// HashTreeRootWith ssz hashes the ExecutionPayloadHeaderCapella object with a hasher +func (e *ExecutionPayloadHeaderCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() // Field (0) 'ParentHash' @@ -2795,25 +1892,19 @@ func (e *ExecutionPayloadHeaderDeneb) HashTreeRootWith(hh *ssz.Hasher) (err erro } hh.PutBytes(e.WithdrawalsRoot) - // Field (15) 'BlobGasUsed' - hh.PutUint64(e.BlobGasUsed) - - // Field (16) 'ExcessBlobGas' - hh.PutUint64(e.ExcessBlobGas) - hh.Merkleize(indx) return } -// MarshalSSZ ssz marshals the ExecutionPayloadHeaderElectra object -func (e *ExecutionPayloadHeaderElectra) MarshalSSZ() ([]byte, error) { +// MarshalSSZ ssz marshals the ExecutionPayloadHeaderDeneb object +func (e *ExecutionPayloadHeaderDeneb) MarshalSSZ() ([]byte, error) { return ssz.MarshalSSZ(e) } -// MarshalSSZTo ssz marshals the ExecutionPayloadHeaderElectra object to a target array -func (e *ExecutionPayloadHeaderElectra) MarshalSSZTo(buf []byte) (dst []byte, err error) { +// MarshalSSZTo ssz marshals the ExecutionPayloadHeaderDeneb object to a target array +func (e *ExecutionPayloadHeaderDeneb) MarshalSSZTo(buf []byte) (dst []byte, err error) { dst = buf - offset := int(648) + offset := int(584) // Field (0) 'ParentHash' if size := len(e.ParentHash); size != 32 { @@ -2907,20 +1998,6 @@ func (e *ExecutionPayloadHeaderElectra) MarshalSSZTo(buf []byte) (dst []byte, er // Field (16) 'ExcessBlobGas' dst = ssz.MarshalUint64(dst, e.ExcessBlobGas) - // Field (17) 'DepositRequestsRoot' - if size := len(e.DepositRequestsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.DepositRequestsRoot", size, 32) - return - } - dst = append(dst, e.DepositRequestsRoot...) - - // Field (18) 'WithdrawalRequestsRoot' - if size := len(e.WithdrawalRequestsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.WithdrawalRequestsRoot", size, 32) - return - } - dst = append(dst, e.WithdrawalRequestsRoot...) - // Field (10) 'ExtraData' if size := len(e.ExtraData); size > 32 { err = ssz.ErrBytesLengthFn("--.ExtraData", size, 32) @@ -2931,11 +2008,11 @@ func (e *ExecutionPayloadHeaderElectra) MarshalSSZTo(buf []byte) (dst []byte, er return } -// UnmarshalSSZ ssz unmarshals the ExecutionPayloadHeaderElectra object -func (e *ExecutionPayloadHeaderElectra) UnmarshalSSZ(buf []byte) error { +// UnmarshalSSZ ssz unmarshals the ExecutionPayloadHeaderDeneb object +func (e *ExecutionPayloadHeaderDeneb) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 648 { + if size < 584 { return ssz.ErrSize } @@ -2995,7 +2072,7 @@ func (e *ExecutionPayloadHeaderElectra) UnmarshalSSZ(buf []byte) error { return ssz.ErrOffset } - if o10 != 648 { + if o10 != 584 { return ssz.ErrInvalidVariableOffset } @@ -3029,18 +2106,6 @@ func (e *ExecutionPayloadHeaderElectra) UnmarshalSSZ(buf []byte) error { // Field (16) 'ExcessBlobGas' e.ExcessBlobGas = ssz.UnmarshallUint64(buf[576:584]) - // Field (17) 'DepositRequestsRoot' - if cap(e.DepositRequestsRoot) == 0 { - e.DepositRequestsRoot = make([]byte, 0, len(buf[584:616])) - } - e.DepositRequestsRoot = append(e.DepositRequestsRoot, buf[584:616]...) - - // Field (18) 'WithdrawalRequestsRoot' - if cap(e.WithdrawalRequestsRoot) == 0 { - e.WithdrawalRequestsRoot = make([]byte, 0, len(buf[616:648])) - } - e.WithdrawalRequestsRoot = append(e.WithdrawalRequestsRoot, buf[616:648]...) - // Field (10) 'ExtraData' { buf = tail[o10:] @@ -3055,9 +2120,9 @@ func (e *ExecutionPayloadHeaderElectra) UnmarshalSSZ(buf []byte) error { return err } -// SizeSSZ returns the ssz encoded size in bytes for the ExecutionPayloadHeaderElectra object -func (e *ExecutionPayloadHeaderElectra) SizeSSZ() (size int) { - size = 648 +// SizeSSZ returns the ssz encoded size in bytes for the ExecutionPayloadHeaderDeneb object +func (e *ExecutionPayloadHeaderDeneb) SizeSSZ() (size int) { + size = 584 // Field (10) 'ExtraData' size += len(e.ExtraData) @@ -3065,13 +2130,13 @@ func (e *ExecutionPayloadHeaderElectra) SizeSSZ() (size int) { return } -// HashTreeRoot ssz hashes the ExecutionPayloadHeaderElectra object -func (e *ExecutionPayloadHeaderElectra) HashTreeRoot() ([32]byte, error) { +// HashTreeRoot ssz hashes the ExecutionPayloadHeaderDeneb object +func (e *ExecutionPayloadHeaderDeneb) HashTreeRoot() ([32]byte, error) { return ssz.HashWithDefaultHasher(e) } -// HashTreeRootWith ssz hashes the ExecutionPayloadHeaderElectra object with a hasher -func (e *ExecutionPayloadHeaderElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) { +// HashTreeRootWith ssz hashes the ExecutionPayloadHeaderDeneb object with a hasher +func (e *ExecutionPayloadHeaderDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) { indx := hh.Index() // Field (0) 'ParentHash' @@ -3174,20 +2239,6 @@ func (e *ExecutionPayloadHeaderElectra) HashTreeRootWith(hh *ssz.Hasher) (err er // Field (16) 'ExcessBlobGas' hh.PutUint64(e.ExcessBlobGas) - // Field (17) 'DepositRequestsRoot' - if size := len(e.DepositRequestsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.DepositRequestsRoot", size, 32) - return - } - hh.PutBytes(e.DepositRequestsRoot) - - // Field (18) 'WithdrawalRequestsRoot' - if size := len(e.WithdrawalRequestsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("--.WithdrawalRequestsRoot", size, 32) - return - } - hh.PutBytes(e.WithdrawalRequestsRoot) - hh.Merkleize(indx) return } @@ -3510,214 +2561,3 @@ func (b *BlobsBundle) HashTreeRootWith(hh *ssz.Hasher) (err error) { hh.Merkleize(indx) return } - -// MarshalSSZ ssz marshals the WithdrawalRequest object -func (w *WithdrawalRequest) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(w) -} - -// MarshalSSZTo ssz marshals the WithdrawalRequest object to a target array -func (w *WithdrawalRequest) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - - // Field (0) 'SourceAddress' - if size := len(w.SourceAddress); size != 20 { - err = ssz.ErrBytesLengthFn("--.SourceAddress", size, 20) - return - } - dst = append(dst, w.SourceAddress...) - - // Field (1) 'ValidatorPubkey' - if size := len(w.ValidatorPubkey); size != 48 { - err = ssz.ErrBytesLengthFn("--.ValidatorPubkey", size, 48) - return - } - dst = append(dst, w.ValidatorPubkey...) - - // Field (2) 'Amount' - dst = ssz.MarshalUint64(dst, w.Amount) - - return -} - -// UnmarshalSSZ ssz unmarshals the WithdrawalRequest object -func (w *WithdrawalRequest) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size != 76 { - return ssz.ErrSize - } - - // Field (0) 'SourceAddress' - if cap(w.SourceAddress) == 0 { - w.SourceAddress = make([]byte, 0, len(buf[0:20])) - } - w.SourceAddress = append(w.SourceAddress, buf[0:20]...) - - // Field (1) 'ValidatorPubkey' - if cap(w.ValidatorPubkey) == 0 { - w.ValidatorPubkey = make([]byte, 0, len(buf[20:68])) - } - w.ValidatorPubkey = append(w.ValidatorPubkey, buf[20:68]...) - - // Field (2) 'Amount' - w.Amount = ssz.UnmarshallUint64(buf[68:76]) - - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the WithdrawalRequest object -func (w *WithdrawalRequest) SizeSSZ() (size int) { - size = 76 - return -} - -// HashTreeRoot ssz hashes the WithdrawalRequest object -func (w *WithdrawalRequest) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(w) -} - -// HashTreeRootWith ssz hashes the WithdrawalRequest object with a hasher -func (w *WithdrawalRequest) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'SourceAddress' - if size := len(w.SourceAddress); size != 20 { - err = ssz.ErrBytesLengthFn("--.SourceAddress", size, 20) - return - } - hh.PutBytes(w.SourceAddress) - - // Field (1) 'ValidatorPubkey' - if size := len(w.ValidatorPubkey); size != 48 { - err = ssz.ErrBytesLengthFn("--.ValidatorPubkey", size, 48) - return - } - hh.PutBytes(w.ValidatorPubkey) - - // Field (2) 'Amount' - hh.PutUint64(w.Amount) - - hh.Merkleize(indx) - return -} - -// MarshalSSZ ssz marshals the DepositRequest object -func (d *DepositRequest) MarshalSSZ() ([]byte, error) { - return ssz.MarshalSSZ(d) -} - -// MarshalSSZTo ssz marshals the DepositRequest object to a target array -func (d *DepositRequest) MarshalSSZTo(buf []byte) (dst []byte, err error) { - dst = buf - - // Field (0) 'Pubkey' - if size := len(d.Pubkey); size != 48 { - err = ssz.ErrBytesLengthFn("--.Pubkey", size, 48) - return - } - dst = append(dst, d.Pubkey...) - - // Field (1) 'WithdrawalCredentials' - if size := len(d.WithdrawalCredentials); size != 32 { - err = ssz.ErrBytesLengthFn("--.WithdrawalCredentials", size, 32) - return - } - dst = append(dst, d.WithdrawalCredentials...) - - // Field (2) 'Amount' - dst = ssz.MarshalUint64(dst, d.Amount) - - // Field (3) 'Signature' - if size := len(d.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return - } - dst = append(dst, d.Signature...) - - // Field (4) 'Index' - dst = ssz.MarshalUint64(dst, d.Index) - - return -} - -// UnmarshalSSZ ssz unmarshals the DepositRequest object -func (d *DepositRequest) UnmarshalSSZ(buf []byte) error { - var err error - size := uint64(len(buf)) - if size != 192 { - return ssz.ErrSize - } - - // Field (0) 'Pubkey' - if cap(d.Pubkey) == 0 { - d.Pubkey = make([]byte, 0, len(buf[0:48])) - } - d.Pubkey = append(d.Pubkey, buf[0:48]...) - - // Field (1) 'WithdrawalCredentials' - if cap(d.WithdrawalCredentials) == 0 { - d.WithdrawalCredentials = make([]byte, 0, len(buf[48:80])) - } - d.WithdrawalCredentials = append(d.WithdrawalCredentials, buf[48:80]...) - - // Field (2) 'Amount' - d.Amount = ssz.UnmarshallUint64(buf[80:88]) - - // Field (3) 'Signature' - if cap(d.Signature) == 0 { - d.Signature = make([]byte, 0, len(buf[88:184])) - } - d.Signature = append(d.Signature, buf[88:184]...) - - // Field (4) 'Index' - d.Index = ssz.UnmarshallUint64(buf[184:192]) - - return err -} - -// SizeSSZ returns the ssz encoded size in bytes for the DepositRequest object -func (d *DepositRequest) SizeSSZ() (size int) { - size = 192 - return -} - -// HashTreeRoot ssz hashes the DepositRequest object -func (d *DepositRequest) HashTreeRoot() ([32]byte, error) { - return ssz.HashWithDefaultHasher(d) -} - -// HashTreeRootWith ssz hashes the DepositRequest object with a hasher -func (d *DepositRequest) HashTreeRootWith(hh *ssz.Hasher) (err error) { - indx := hh.Index() - - // Field (0) 'Pubkey' - if size := len(d.Pubkey); size != 48 { - err = ssz.ErrBytesLengthFn("--.Pubkey", size, 48) - return - } - hh.PutBytes(d.Pubkey) - - // Field (1) 'WithdrawalCredentials' - if size := len(d.WithdrawalCredentials); size != 32 { - err = ssz.ErrBytesLengthFn("--.WithdrawalCredentials", size, 32) - return - } - hh.PutBytes(d.WithdrawalCredentials) - - // Field (2) 'Amount' - hh.PutUint64(d.Amount) - - // Field (3) 'Signature' - if size := len(d.Signature); size != 96 { - err = ssz.ErrBytesLengthFn("--.Signature", size, 96) - return - } - hh.PutBytes(d.Signature) - - // Field (4) 'Index' - hh.PutUint64(d.Index) - - hh.Merkleize(indx) - return -}