From 4b13eb8478e5ef61da461c78fa459f3ac9c70845 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Fri, 13 Mar 2026 00:45:07 +0000 Subject: [PATCH] commit --- build/checksums.txt | 5 + build/ci.go | 17 + tests/block_test.go | 36 + tests/block_test_util.go | 119 ++- tests/init_test.go | 3 +- tests/stateless_ssz.go | 85 ++ tests/stateless_ssz_encoding.go | 1423 +++++++++++++++++++++++++++++++ 7 files changed, 1682 insertions(+), 6 deletions(-) create mode 100644 tests/stateless_ssz.go create mode 100644 tests/stateless_ssz_encoding.go diff --git a/build/checksums.txt b/build/checksums.txt index 5efe9dd96f..d3a13b5a87 100644 --- a/build/checksums.txt +++ b/build/checksums.txt @@ -10,6 +10,11 @@ a3192784375acec7eaec492799d5c5d0c47a2909a3cc40178898e4ecd20cc416 fixtures_devel # https://github.com/ethereum/execution-spec-tests/releases/download/bal%40v5.3.0 a1840f2e74d7d53f9f36f969bfd280407829b21e85bea206ba907453fdc47ac4 fixtures_bal.tar.gz +# version:spec-tests-zkevm zkevm@v0.3.0 +# https://github.com/ethereum/execution-spec-tests/releases +# https://github.com/ethereum/execution-spec-tests/releases/download/zkevm%40v0.3.0 +7237c6504243a9b2038bd23005e4fae051bc64f1b8c9bac081131d11f33a5c3c fixtures_zkevm.tar.gz + # version:golang 1.25.7 # https://go.dev/dl/ 178f2832820274b43e177d32f06a3ebb0129e427dd20a5e4c88df2c1763cf10a go1.25.7.src.tar.gz diff --git a/build/ci.go b/build/ci.go index 2568bce5da..9480496050 100644 --- a/build/ci.go +++ b/build/ci.go @@ -175,6 +175,9 @@ var ( // This is where the bal-specific release of the tests should be unpacked. executionSpecTestsBALDir = "tests/spec-tests-bal" + + // This is where the zkevm release of the tests should be unpacked. + executionSpecTestsZkevmDir = "tests/spec-tests-zkevm" ) var GOBIN, _ = filepath.Abs(filepath.Join("build", "bin")) @@ -384,6 +387,7 @@ func doTest(cmdline []string) { if !*short { downloadSpecTestFixtures(csdb, *cachedir) downloadBALSpecTestFixtures(csdb, *cachedir) + downloadZkevmSpecTestFixtures(csdb, *cachedir) } // Configure the toolchain. @@ -462,6 +466,19 @@ func downloadBALSpecTestFixtures(csdb *download.ChecksumDB, cachedir string) str return filepath.Join(cachedir, base) } +func downloadZkevmSpecTestFixtures(csdb *download.ChecksumDB, cachedir string) string { + ext := ".tar.gz" + base := "fixtures_zkevm" + archivePath := filepath.Join(cachedir, base+ext) + if err := csdb.DownloadFileFromKnownURL(archivePath); err != nil { + log.Fatal(err) + } + if err := build.ExtractArchive(archivePath, executionSpecTestsZkevmDir); err != nil { + log.Fatal(err) + } + return filepath.Join(cachedir, base) +} + // doCheckGenerate ensures that re-generating generated files does not cause // any mutations in the source file tree. func doCheckGenerate() { diff --git a/tests/block_test.go b/tests/block_test.go index e911c12e23..9e314e763e 100644 --- a/tests/block_test.go +++ b/tests/block_test.go @@ -868,6 +868,42 @@ func TestExecutionSpecBlocktestsBAL(t *testing.T) { testExecutionSpecBlocktests(t, executionSpecBALBlockchainTestDir, skips) } +// TestExecutionSpecZkevmBlocktests runs the zkevm test fixtures from execution-spec-tests +// and validates execution witnesses against geth's stateless execution. +func TestExecutionSpecZkevmBlocktests(t *testing.T) { + if !common.FileExist(executionSpecZkevmBlockchainTestDir) { + t.Skipf("directory %s does not exist", executionSpecZkevmBlockchainTestDir) + } + bt := new(testMatcher) + + bt.walk(t, executionSpecZkevmBlockchainTestDir, func(t *testing.T, name string, test *BlockTest) { + execBlockTest(t, bt, test, true) + + // Validate execution witnesses for blocks that have them + // TODO: Execution specs don't emit a witness when block is valid right now + for _, b := range test.json.Blocks { + if b.ExecutionWitness == nil || b.BlockHeader == nil { + continue + } + block, err := b.decode() + if err != nil { + t.Fatalf("failed to decode block for witness validation: %v", err) + } + if err := test.validateExecutionWitness(block, b.ExecutionWitness); err != nil { + t.Errorf("execution witness validation failed: %v", err) + } + + // Validate that the SSZ-encoded statelessInputBytes witness matches the JSON executionWitness + // TODO: long term, we will only have statelessInputBytes and we will have no redundancy + if b.StatelessInputBytes != nil { + if err := validateStatelessInputWitness([]byte(*b.StatelessInputBytes), b.ExecutionWitness); err != nil { + t.Errorf("stateless input witness mismatch: %v", err) + } + } + } + }) +} + var failures = 0 func execBlockTest(t *testing.T, bt *testMatcher, test *BlockTest, buildAndVerifyBAL bool) { diff --git a/tests/block_test_util.go b/tests/block_test_util.go index 3547a3bd6e..388d1f7a5f 100644 --- a/tests/block_test_util.go +++ b/tests/block_test_util.go @@ -19,6 +19,7 @@ package tests import ( "bytes" + "context" "encoding/hex" "encoding/json" "fmt" @@ -30,6 +31,7 @@ import ( "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/state" + "github.com/ethereum/go-ethereum/core/stateless" "github.com/ethereum/go-ethereum/core/tracing" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/types/bal" @@ -44,6 +46,7 @@ import ( "math/big" "os" "reflect" + "slices" "strings" ) @@ -68,11 +71,20 @@ type btJSON struct { } type btBlock struct { - BlockHeader *btHeader - ExpectException string - Rlp string - UncleHeaders []*btHeader - AccessList *bal.BlockAccessList `json:"blockAccessList,omitempty"` + BlockHeader *btHeader + ExpectException string + Rlp string + UncleHeaders []*btHeader + AccessList *bal.BlockAccessList `json:"blockAccessList,omitempty"` + ExecutionWitness *btExecutionWitness `json:"executionWitness,omitempty"` + StatelessInputBytes *hexutil.Bytes `json:"statelessInputBytes,omitempty"` + StatelessOutputBytes *hexutil.Bytes `json:"statelessOutputBytes,omitempty"` +} + +type btExecutionWitness struct { + State []hexutil.Bytes `json:"state"` + Codes []hexutil.Bytes `json:"codes"` + Headers []hexutil.Bytes `json:"headers"` } //go:generate go run github.com/fjl/gencodec -type btHeader -field-override btHeaderMarshaling -out gen_btheader.go @@ -470,3 +482,100 @@ func (bb *btBlock) decode() (*types.Block, error) { err = rlp.DecodeBytes(data, &b) return &b, err } + +// toWitness converts a btExecutionWitness into a stateless.Witness by RLP-decoding +// the headers and populating the codes and state fields. +func (ew *btExecutionWitness) toWitness() (*stateless.Witness, error) { + w := new(stateless.Witness) + + for _, raw := range ew.Headers { + var h types.Header + if err := rlp.DecodeBytes(raw, &h); err != nil { + return nil, fmt.Errorf("failed to RLP-decode witness header: %v", err) + } + w.Headers = append(w.Headers, &h) + } + // EEST fixtures store headers in ascending block number order, but geth's + // stateless execution expects Headers[0] to be the parent (highest number) + // followed by older ancestors. Reverse the slice to match. + slices.Reverse(w.Headers) + w.Codes = make(map[string]struct{}, len(ew.Codes)) + for _, code := range ew.Codes { + w.Codes[string(code)] = struct{}{} + } + w.State = make(map[string]struct{}, len(ew.State)) + for _, node := range ew.State { + w.State[string(node)] = struct{}{} + } + return w, nil +} + +// validateExecutionWitness checks that the execution witness from the test fixture +// is sufficient to statelessly execute the given block and produce the correct +// state root and receipt hash. +func (t *BlockTest) validateExecutionWitness(block *types.Block, ew *btExecutionWitness) error { + config, ok := Forks[t.json.Network] + if !ok { + return UnsupportedForkError{t.json.Network} + } + witness, err := ew.toWitness() + if err != nil { + return fmt.Errorf("failed to parse execution witness: %v", err) + } + // ExecuteStateless expects the block header to have zeroed root and receipt hash + // so it can compute them from the witness. Make a copy with those fields cleared. + header := types.CopyHeader(block.Header()) + expectedRoot := header.Root + expectedReceiptHash := header.ReceiptHash + header.Root = common.Hash{} + header.ReceiptHash = common.Hash{} + + witnessBlock := types.NewBlockWithHeader(header).WithBody(*block.Body()) + stateRoot, receiptRoot, err := core.ExecuteStateless(context.TODO(), config, vm.Config{}, witnessBlock, witness) + if err != nil { + return fmt.Errorf("stateless execution failed: %v", err) + } + if stateRoot != expectedRoot { + return fmt.Errorf("execution witness state root mismatch: computed %x, expected %x", stateRoot, expectedRoot) + } + if receiptRoot != expectedReceiptHash { + return fmt.Errorf("execution witness receipt root mismatch: computed %x, expected %x", receiptRoot, expectedReceiptHash) + } + return nil +} + +// validateStatelessInputWitness checks that the execution witness encoded in the +// SSZ statelessInputBytes matches the JSON executionWitness field. +func validateStatelessInputWitness(inputBytes []byte, ew *btExecutionWitness) error { + var input SszStatelessInput + if err := input.UnmarshalSSZ(inputBytes); err != nil { + return fmt.Errorf("failed to SSZ-decode statelessInputBytes: %v", err) + } + w := input.Witness + + if len(w.State) != len(ew.State) { + return fmt.Errorf("witness state count mismatch: ssz=%d json=%d", len(w.State), len(ew.State)) + } + for i := range w.State { + if !bytes.Equal(w.State[i], ew.State[i]) { + return fmt.Errorf("witness state[%d] mismatch", i) + } + } + if len(w.Codes) != len(ew.Codes) { + return fmt.Errorf("witness codes count mismatch: ssz=%d json=%d", len(w.Codes), len(ew.Codes)) + } + for i := range w.Codes { + if !bytes.Equal(w.Codes[i], ew.Codes[i]) { + return fmt.Errorf("witness codes[%d] mismatch", i) + } + } + if len(w.Headers) != len(ew.Headers) { + return fmt.Errorf("witness headers count mismatch: ssz=%d json=%d", len(w.Headers), len(ew.Headers)) + } + for i := range w.Headers { + if !bytes.Equal(w.Headers[i], ew.Headers[i]) { + return fmt.Errorf("witness headers[%d] mismatch", i) + } + } + return nil +} diff --git a/tests/init_test.go b/tests/init_test.go index 2f2e4101f8..95db2f2788 100644 --- a/tests/init_test.go +++ b/tests/init_test.go @@ -45,7 +45,8 @@ var ( executionSpecStateTestDir = filepath.Join(".", "spec-tests", "fixtures", "state_tests") executionSpecTransactionTestDir = filepath.Join(".", "spec-tests", "fixtures", "transaction_tests") benchmarksDir = filepath.Join(".", "evm-benchmarks", "benchmarks") - executionSpecBALBlockchainTestDir = filepath.Join(".", "spec-tests-bal", "fixtures", "blockchain_tests") + executionSpecBALBlockchainTestDir = filepath.Join(".", "spec-tests-bal", "fixtures", "blockchain_tests") + executionSpecZkevmBlockchainTestDir = filepath.Join(".", "spec-tests-zkevm", "fixtures", "blockchain_tests", "for_amsterdam") ) func readJSON(reader io.Reader, value interface{}) error { diff --git a/tests/stateless_ssz.go b/tests/stateless_ssz.go new file mode 100644 index 0000000000..07d671a214 --- /dev/null +++ b/tests/stateless_ssz.go @@ -0,0 +1,85 @@ +// Copyright 2024 The go-ethereum Authors +// This file is part of the go-ethereum library. +// +// The go-ethereum library is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// The go-ethereum library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with the go-ethereum library. If not, see . + +package tests + +//go:generate go run github.com/ferranbt/fastssz/sszgen -path . -objs SszWithdrawal,SszExecutionPayload,SszNewPayloadRequest,SszExecutionWitness,SszChainConfig,SszStatelessInput,SszStatelessValidationResult -output stateless_ssz_encoding.go + +// SszWithdrawal mirrors the SSZ encoding of a withdrawal. +type SszWithdrawal struct { + Index uint64 `ssz-size:"8"` + ValidatorIndex uint64 `ssz-size:"8"` + Address [20]byte `ssz-size:"20"` + Amount [32]byte `ssz-size:"32"` +} + +// SszExecutionPayload mirrors the SSZ encoding of an execution payload. +type SszExecutionPayload struct { + ParentHash [32]byte `ssz-size:"32"` + FeeRecipient [20]byte `ssz-size:"20"` + StateRoot [32]byte `ssz-size:"32"` + ReceiptsRoot [32]byte `ssz-size:"32"` + LogsBloom [256]byte `ssz-size:"256"` + PrevRandao [32]byte `ssz-size:"32"` + BlockNumber uint64 + GasLimit uint64 + GasUsed uint64 + Timestamp uint64 + ExtraData []byte `ssz-max:"32"` + BaseFeePerGas [32]byte `ssz-size:"32"` + BlockHash [32]byte `ssz-size:"32"` + Transactions [][]byte `ssz-max:"1048576,1073741824"` + Withdrawals []*SszWithdrawal `ssz-max:"65536"` // TODO: this is here because of a spec test going over 16 + BlobGasUsed uint64 + ExcessBlobGas uint64 + BlockAccessList []byte `ssz-max:"16777216"` + SlotNumber uint64 +} + +// SszNewPayloadRequest mirrors the SSZ encoding of a new payload request. +type SszNewPayloadRequest struct { + ExecutionPayload *SszExecutionPayload + VersionedHashes [][32]byte `ssz-max:"4096" ssz-size:"?,32"` + ParentBeaconBlockRoot [32]byte `ssz-size:"32"` + ExecutionRequests [][]byte `ssz-max:"16,1048576"` +} + +// SszExecutionWitness mirrors the SSZ encoding of an execution witness. +type SszExecutionWitness struct { + State [][]byte `ssz-max:"1048576,1048576"` + Codes [][]byte `ssz-max:"65536,16777216"` + Headers [][]byte `ssz-max:"256,1024"` +} + +// SszChainConfig mirrors the SSZ encoding of a chain config. +type SszChainConfig struct { + ChainId uint64 +} + +// SszStatelessInput mirrors the SSZ encoding of a stateless execution input. +type SszStatelessInput struct { + NewPayloadRequest *SszNewPayloadRequest + Witness *SszExecutionWitness + ChainConfig *SszChainConfig + PublicKeys [][]byte `ssz-max:"1048576,48"` +} + +// SszStatelessValidationResult mirrors the SSZ encoding of a stateless validation result. +type SszStatelessValidationResult struct { + NewPayloadRequestRoot [32]byte `ssz-size:"32"` + SuccessfulValidation bool + ChainConfig *SszChainConfig +} diff --git a/tests/stateless_ssz_encoding.go b/tests/stateless_ssz_encoding.go new file mode 100644 index 0000000000..b5e8dfe96c --- /dev/null +++ b/tests/stateless_ssz_encoding.go @@ -0,0 +1,1423 @@ +// Code generated by fastssz. DO NOT EDIT. +// Hash: a5a3f5976cb6d7bebfd33a8fd96135a2b18cabfeda1c73cb38b6689a4695c1fc +// Version: 0.1.3 +package tests + +import ( + ssz "github.com/ferranbt/fastssz" +) + +// MarshalSSZ ssz marshals the SszWithdrawal object +func (s *SszWithdrawal) MarshalSSZ() ([]byte, error) { + return ssz.MarshalSSZ(s) +} + +// MarshalSSZTo ssz marshals the SszWithdrawal object to a target array +func (s *SszWithdrawal) MarshalSSZTo(buf []byte) (dst []byte, err error) { + dst = buf + + // Field (0) 'Index' + dst = ssz.MarshalUint64(dst, s.Index) + + // Field (1) 'ValidatorIndex' + dst = ssz.MarshalUint64(dst, s.ValidatorIndex) + + // Field (2) 'Address' + dst = append(dst, s.Address[:]...) + + // Field (3) 'Amount' + dst = append(dst, s.Amount[:]...) + + return +} + +// UnmarshalSSZ ssz unmarshals the SszWithdrawal object +func (s *SszWithdrawal) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 68 { + return ssz.ErrSize + } + + // Field (0) 'Index' + s.Index = ssz.UnmarshallUint64(buf[0:8]) + + // Field (1) 'ValidatorIndex' + s.ValidatorIndex = ssz.UnmarshallUint64(buf[8:16]) + + // Field (2) 'Address' + copy(s.Address[:], buf[16:36]) + + // Field (3) 'Amount' + copy(s.Amount[:], buf[36:68]) + + return err +} + +// SizeSSZ returns the ssz encoded size in bytes for the SszWithdrawal object +func (s *SszWithdrawal) SizeSSZ() (size int) { + size = 68 + return +} + +// HashTreeRoot ssz hashes the SszWithdrawal object +func (s *SszWithdrawal) HashTreeRoot() ([32]byte, error) { + return ssz.HashWithDefaultHasher(s) +} + +// HashTreeRootWith ssz hashes the SszWithdrawal object with a hasher +func (s *SszWithdrawal) HashTreeRootWith(hh ssz.HashWalker) (err error) { + indx := hh.Index() + + // Field (0) 'Index' + hh.PutUint64(s.Index) + + // Field (1) 'ValidatorIndex' + hh.PutUint64(s.ValidatorIndex) + + // Field (2) 'Address' + hh.PutBytes(s.Address[:]) + + // Field (3) 'Amount' + hh.PutBytes(s.Amount[:]) + + hh.Merkleize(indx) + return +} + +// GetTree ssz hashes the SszWithdrawal object +func (s *SszWithdrawal) GetTree() (*ssz.Node, error) { + return ssz.ProofTree(s) +} + +// MarshalSSZ ssz marshals the SszExecutionPayload object +func (s *SszExecutionPayload) MarshalSSZ() ([]byte, error) { + return ssz.MarshalSSZ(s) +} + +// MarshalSSZTo ssz marshals the SszExecutionPayload object to a target array +func (s *SszExecutionPayload) MarshalSSZTo(buf []byte) (dst []byte, err error) { + dst = buf + offset := int(540) + + // Field (0) 'ParentHash' + dst = append(dst, s.ParentHash[:]...) + + // Field (1) 'FeeRecipient' + dst = append(dst, s.FeeRecipient[:]...) + + // Field (2) 'StateRoot' + dst = append(dst, s.StateRoot[:]...) + + // Field (3) 'ReceiptsRoot' + dst = append(dst, s.ReceiptsRoot[:]...) + + // Field (4) 'LogsBloom' + dst = append(dst, s.LogsBloom[:]...) + + // Field (5) 'PrevRandao' + dst = append(dst, s.PrevRandao[:]...) + + // Field (6) 'BlockNumber' + dst = ssz.MarshalUint64(dst, s.BlockNumber) + + // Field (7) 'GasLimit' + dst = ssz.MarshalUint64(dst, s.GasLimit) + + // Field (8) 'GasUsed' + dst = ssz.MarshalUint64(dst, s.GasUsed) + + // Field (9) 'Timestamp' + dst = ssz.MarshalUint64(dst, s.Timestamp) + + // Offset (10) 'ExtraData' + dst = ssz.WriteOffset(dst, offset) + offset += len(s.ExtraData) + + // Field (11) 'BaseFeePerGas' + dst = append(dst, s.BaseFeePerGas[:]...) + + // Field (12) 'BlockHash' + dst = append(dst, s.BlockHash[:]...) + + // Offset (13) 'Transactions' + dst = ssz.WriteOffset(dst, offset) + for ii := 0; ii < len(s.Transactions); ii++ { + offset += 4 + offset += len(s.Transactions[ii]) + } + + // Offset (14) 'Withdrawals' + dst = ssz.WriteOffset(dst, offset) + offset += len(s.Withdrawals) * 68 + + // Field (15) 'BlobGasUsed' + dst = ssz.MarshalUint64(dst, s.BlobGasUsed) + + // Field (16) 'ExcessBlobGas' + dst = ssz.MarshalUint64(dst, s.ExcessBlobGas) + + // Offset (17) 'BlockAccessList' + dst = ssz.WriteOffset(dst, offset) + + // Field (18) 'SlotNumber' + dst = ssz.MarshalUint64(dst, s.SlotNumber) + + // Field (10) 'ExtraData' + if size := len(s.ExtraData); size > 32 { + err = ssz.ErrBytesLengthFn("SszExecutionPayload.ExtraData", size, 32) + return + } + dst = append(dst, s.ExtraData...) + + // Field (13) 'Transactions' + if size := len(s.Transactions); size > 1048576 { + err = ssz.ErrListTooBigFn("SszExecutionPayload.Transactions", size, 1048576) + return + } + { + offset = 4 * len(s.Transactions) + for ii := 0; ii < len(s.Transactions); ii++ { + dst = ssz.WriteOffset(dst, offset) + offset += len(s.Transactions[ii]) + } + } + for ii := 0; ii < len(s.Transactions); ii++ { + if size := len(s.Transactions[ii]); size > 1073741824 { + err = ssz.ErrBytesLengthFn("SszExecutionPayload.Transactions[ii]", size, 1073741824) + return + } + dst = append(dst, s.Transactions[ii]...) + } + + // Field (14) 'Withdrawals' + if size := len(s.Withdrawals); size > 65536 { + err = ssz.ErrListTooBigFn("SszExecutionPayload.Withdrawals", size, 65536) + return + } + for ii := 0; ii < len(s.Withdrawals); ii++ { + if dst, err = s.Withdrawals[ii].MarshalSSZTo(dst); err != nil { + return + } + } + + // Field (17) 'BlockAccessList' + if size := len(s.BlockAccessList); size > 16777216 { + err = ssz.ErrBytesLengthFn("SszExecutionPayload.BlockAccessList", size, 16777216) + return + } + dst = append(dst, s.BlockAccessList...) + + return +} + +// UnmarshalSSZ ssz unmarshals the SszExecutionPayload object +func (s *SszExecutionPayload) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 540 { + return ssz.ErrSize + } + + tail := buf + var o10, o13, o14, o17 uint64 + + // Field (0) 'ParentHash' + copy(s.ParentHash[:], buf[0:32]) + + // Field (1) 'FeeRecipient' + copy(s.FeeRecipient[:], buf[32:52]) + + // Field (2) 'StateRoot' + copy(s.StateRoot[:], buf[52:84]) + + // Field (3) 'ReceiptsRoot' + copy(s.ReceiptsRoot[:], buf[84:116]) + + // Field (4) 'LogsBloom' + copy(s.LogsBloom[:], buf[116:372]) + + // Field (5) 'PrevRandao' + copy(s.PrevRandao[:], buf[372:404]) + + // Field (6) 'BlockNumber' + s.BlockNumber = ssz.UnmarshallUint64(buf[404:412]) + + // Field (7) 'GasLimit' + s.GasLimit = ssz.UnmarshallUint64(buf[412:420]) + + // Field (8) 'GasUsed' + s.GasUsed = ssz.UnmarshallUint64(buf[420:428]) + + // Field (9) 'Timestamp' + s.Timestamp = ssz.UnmarshallUint64(buf[428:436]) + + // Offset (10) 'ExtraData' + if o10 = ssz.ReadOffset(buf[436:440]); o10 > size { + return ssz.ErrOffset + } + + if o10 != 540 { + return ssz.ErrInvalidVariableOffset + } + + // Field (11) 'BaseFeePerGas' + copy(s.BaseFeePerGas[:], buf[440:472]) + + // Field (12) 'BlockHash' + copy(s.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' + s.BlobGasUsed = ssz.UnmarshallUint64(buf[512:520]) + + // Field (16) 'ExcessBlobGas' + s.ExcessBlobGas = ssz.UnmarshallUint64(buf[520:528]) + + // Offset (17) 'BlockAccessList' + if o17 = ssz.ReadOffset(buf[528:532]); o17 > size || o14 > o17 { + return ssz.ErrOffset + } + + // Field (18) 'SlotNumber' + s.SlotNumber = ssz.UnmarshallUint64(buf[532:540]) + + // Field (10) 'ExtraData' + { + buf = tail[o10:o13] + if len(buf) > 32 { + return ssz.ErrBytesLength + } + if cap(s.ExtraData) == 0 { + s.ExtraData = make([]byte, 0, len(buf)) + } + s.ExtraData = append(s.ExtraData, buf...) + } + + // Field (13) 'Transactions' + { + buf = tail[o13:o14] + num, err := ssz.DecodeDynamicLength(buf, 1048576) + if err != nil { + return err + } + s.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(s.Transactions[indx]) == 0 { + s.Transactions[indx] = make([]byte, 0, len(buf)) + } + s.Transactions[indx] = append(s.Transactions[indx], buf...) + return nil + }) + if err != nil { + return err + } + } + + // Field (14) 'Withdrawals' + { + buf = tail[o14:o17] + num, err := ssz.DivideInt2(len(buf), 68, 65536) + if err != nil { + return err + } + s.Withdrawals = make([]*SszWithdrawal, num) + for ii := 0; ii < num; ii++ { + if s.Withdrawals[ii] == nil { + s.Withdrawals[ii] = new(SszWithdrawal) + } + if err = s.Withdrawals[ii].UnmarshalSSZ(buf[ii*68 : (ii+1)*68]); err != nil { + return err + } + } + } + + // Field (17) 'BlockAccessList' + { + buf = tail[o17:] + if len(buf) > 16777216 { + return ssz.ErrBytesLength + } + if cap(s.BlockAccessList) == 0 { + s.BlockAccessList = make([]byte, 0, len(buf)) + } + s.BlockAccessList = append(s.BlockAccessList, buf...) + } + return err +} + +// SizeSSZ returns the ssz encoded size in bytes for the SszExecutionPayload object +func (s *SszExecutionPayload) SizeSSZ() (size int) { + size = 540 + + // Field (10) 'ExtraData' + size += len(s.ExtraData) + + // Field (13) 'Transactions' + for ii := 0; ii < len(s.Transactions); ii++ { + size += 4 + size += len(s.Transactions[ii]) + } + + // Field (14) 'Withdrawals' + size += len(s.Withdrawals) * 68 + + // Field (17) 'BlockAccessList' + size += len(s.BlockAccessList) + + return +} + +// HashTreeRoot ssz hashes the SszExecutionPayload object +func (s *SszExecutionPayload) HashTreeRoot() ([32]byte, error) { + return ssz.HashWithDefaultHasher(s) +} + +// HashTreeRootWith ssz hashes the SszExecutionPayload object with a hasher +func (s *SszExecutionPayload) HashTreeRootWith(hh ssz.HashWalker) (err error) { + indx := hh.Index() + + // Field (0) 'ParentHash' + hh.PutBytes(s.ParentHash[:]) + + // Field (1) 'FeeRecipient' + hh.PutBytes(s.FeeRecipient[:]) + + // Field (2) 'StateRoot' + hh.PutBytes(s.StateRoot[:]) + + // Field (3) 'ReceiptsRoot' + hh.PutBytes(s.ReceiptsRoot[:]) + + // Field (4) 'LogsBloom' + hh.PutBytes(s.LogsBloom[:]) + + // Field (5) 'PrevRandao' + hh.PutBytes(s.PrevRandao[:]) + + // Field (6) 'BlockNumber' + hh.PutUint64(s.BlockNumber) + + // Field (7) 'GasLimit' + hh.PutUint64(s.GasLimit) + + // Field (8) 'GasUsed' + hh.PutUint64(s.GasUsed) + + // Field (9) 'Timestamp' + hh.PutUint64(s.Timestamp) + + // Field (10) 'ExtraData' + { + elemIndx := hh.Index() + byteLen := uint64(len(s.ExtraData)) + if byteLen > 32 { + err = ssz.ErrIncorrectListSize + return + } + hh.Append(s.ExtraData) + hh.MerkleizeWithMixin(elemIndx, byteLen, (32+31)/32) + } + + // Field (11) 'BaseFeePerGas' + hh.PutBytes(s.BaseFeePerGas[:]) + + // Field (12) 'BlockHash' + hh.PutBytes(s.BlockHash[:]) + + // Field (13) 'Transactions' + { + subIndx := hh.Index() + num := uint64(len(s.Transactions)) + if num > 1048576 { + err = ssz.ErrIncorrectListSize + return + } + for _, elem := range s.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(s.Withdrawals)) + if num > 65536 { + err = ssz.ErrIncorrectListSize + return + } + for _, elem := range s.Withdrawals { + if err = elem.HashTreeRootWith(hh); err != nil { + return + } + } + hh.MerkleizeWithMixin(subIndx, num, 65536) + } + + // Field (15) 'BlobGasUsed' + hh.PutUint64(s.BlobGasUsed) + + // Field (16) 'ExcessBlobGas' + hh.PutUint64(s.ExcessBlobGas) + + // Field (17) 'BlockAccessList' + { + elemIndx := hh.Index() + byteLen := uint64(len(s.BlockAccessList)) + if byteLen > 16777216 { + err = ssz.ErrIncorrectListSize + return + } + hh.Append(s.BlockAccessList) + hh.MerkleizeWithMixin(elemIndx, byteLen, (16777216+31)/32) + } + + // Field (18) 'SlotNumber' + hh.PutUint64(s.SlotNumber) + + hh.Merkleize(indx) + return +} + +// GetTree ssz hashes the SszExecutionPayload object +func (s *SszExecutionPayload) GetTree() (*ssz.Node, error) { + return ssz.ProofTree(s) +} + +// MarshalSSZ ssz marshals the SszNewPayloadRequest object +func (s *SszNewPayloadRequest) MarshalSSZ() ([]byte, error) { + return ssz.MarshalSSZ(s) +} + +// MarshalSSZTo ssz marshals the SszNewPayloadRequest object to a target array +func (s *SszNewPayloadRequest) MarshalSSZTo(buf []byte) (dst []byte, err error) { + dst = buf + offset := int(44) + + // Offset (0) 'ExecutionPayload' + dst = ssz.WriteOffset(dst, offset) + if s.ExecutionPayload == nil { + s.ExecutionPayload = new(SszExecutionPayload) + } + offset += s.ExecutionPayload.SizeSSZ() + + // Offset (1) 'VersionedHashes' + dst = ssz.WriteOffset(dst, offset) + offset += len(s.VersionedHashes) * 32 + + // Field (2) 'ParentBeaconBlockRoot' + dst = append(dst, s.ParentBeaconBlockRoot[:]...) + + // Offset (3) 'ExecutionRequests' + dst = ssz.WriteOffset(dst, offset) + + // Field (0) 'ExecutionPayload' + if dst, err = s.ExecutionPayload.MarshalSSZTo(dst); err != nil { + return + } + + // Field (1) 'VersionedHashes' + if size := len(s.VersionedHashes); size > 4096 { + err = ssz.ErrListTooBigFn("SszNewPayloadRequest.VersionedHashes", size, 4096) + return + } + for ii := 0; ii < len(s.VersionedHashes); ii++ { + dst = append(dst, s.VersionedHashes[ii][:]...) + } + + // Field (3) 'ExecutionRequests' + if size := len(s.ExecutionRequests); size > 16 { + err = ssz.ErrListTooBigFn("SszNewPayloadRequest.ExecutionRequests", size, 16) + return + } + { + offset = 4 * len(s.ExecutionRequests) + for ii := 0; ii < len(s.ExecutionRequests); ii++ { + dst = ssz.WriteOffset(dst, offset) + offset += len(s.ExecutionRequests[ii]) + } + } + for ii := 0; ii < len(s.ExecutionRequests); ii++ { + if size := len(s.ExecutionRequests[ii]); size > 1048576 { + err = ssz.ErrBytesLengthFn("SszNewPayloadRequest.ExecutionRequests[ii]", size, 1048576) + return + } + dst = append(dst, s.ExecutionRequests[ii]...) + } + + return +} + +// UnmarshalSSZ ssz unmarshals the SszNewPayloadRequest object +func (s *SszNewPayloadRequest) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 44 { + return ssz.ErrSize + } + + tail := buf + var o0, o1, o3 uint64 + + // Offset (0) 'ExecutionPayload' + if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { + return ssz.ErrOffset + } + + if o0 != 44 { + return ssz.ErrInvalidVariableOffset + } + + // Offset (1) 'VersionedHashes' + if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 { + return ssz.ErrOffset + } + + // Field (2) 'ParentBeaconBlockRoot' + copy(s.ParentBeaconBlockRoot[:], buf[8:40]) + + // Offset (3) 'ExecutionRequests' + if o3 = ssz.ReadOffset(buf[40:44]); o3 > size || o1 > o3 { + return ssz.ErrOffset + } + + // Field (0) 'ExecutionPayload' + { + buf = tail[o0:o1] + if s.ExecutionPayload == nil { + s.ExecutionPayload = new(SszExecutionPayload) + } + if err = s.ExecutionPayload.UnmarshalSSZ(buf); err != nil { + return err + } + } + + // Field (1) 'VersionedHashes' + { + buf = tail[o1:o3] + num, err := ssz.DivideInt2(len(buf), 32, 4096) + if err != nil { + return err + } + s.VersionedHashes = make([][32]byte, num) + for ii := 0; ii < num; ii++ { + copy(s.VersionedHashes[ii][:], buf[ii*32:(ii+1)*32]) + } + } + + // Field (3) 'ExecutionRequests' + { + buf = tail[o3:] + num, err := ssz.DecodeDynamicLength(buf, 16) + if err != nil { + return err + } + s.ExecutionRequests = make([][]byte, num) + err = ssz.UnmarshalDynamic(buf, num, func(indx int, buf []byte) (err error) { + if len(buf) > 1048576 { + return ssz.ErrBytesLength + } + if cap(s.ExecutionRequests[indx]) == 0 { + s.ExecutionRequests[indx] = make([]byte, 0, len(buf)) + } + s.ExecutionRequests[indx] = append(s.ExecutionRequests[indx], buf...) + return nil + }) + if err != nil { + return err + } + } + return err +} + +// SizeSSZ returns the ssz encoded size in bytes for the SszNewPayloadRequest object +func (s *SszNewPayloadRequest) SizeSSZ() (size int) { + size = 44 + + // Field (0) 'ExecutionPayload' + if s.ExecutionPayload == nil { + s.ExecutionPayload = new(SszExecutionPayload) + } + size += s.ExecutionPayload.SizeSSZ() + + // Field (1) 'VersionedHashes' + size += len(s.VersionedHashes) * 32 + + // Field (3) 'ExecutionRequests' + for ii := 0; ii < len(s.ExecutionRequests); ii++ { + size += 4 + size += len(s.ExecutionRequests[ii]) + } + + return +} + +// HashTreeRoot ssz hashes the SszNewPayloadRequest object +func (s *SszNewPayloadRequest) HashTreeRoot() ([32]byte, error) { + return ssz.HashWithDefaultHasher(s) +} + +// HashTreeRootWith ssz hashes the SszNewPayloadRequest object with a hasher +func (s *SszNewPayloadRequest) HashTreeRootWith(hh ssz.HashWalker) (err error) { + indx := hh.Index() + + // Field (0) 'ExecutionPayload' + if err = s.ExecutionPayload.HashTreeRootWith(hh); err != nil { + return + } + + // Field (1) 'VersionedHashes' + { + if size := len(s.VersionedHashes); size > 4096 { + err = ssz.ErrListTooBigFn("SszNewPayloadRequest.VersionedHashes", size, 4096) + return + } + subIndx := hh.Index() + for _, i := range s.VersionedHashes { + hh.Append(i[:]) + } + numItems := uint64(len(s.VersionedHashes)) + hh.MerkleizeWithMixin(subIndx, numItems, 4096) + } + + // Field (2) 'ParentBeaconBlockRoot' + hh.PutBytes(s.ParentBeaconBlockRoot[:]) + + // Field (3) 'ExecutionRequests' + { + subIndx := hh.Index() + num := uint64(len(s.ExecutionRequests)) + if num > 16 { + err = ssz.ErrIncorrectListSize + return + } + for _, elem := range s.ExecutionRequests { + { + elemIndx := hh.Index() + byteLen := uint64(len(elem)) + if byteLen > 1048576 { + err = ssz.ErrIncorrectListSize + return + } + hh.AppendBytes32(elem) + hh.MerkleizeWithMixin(elemIndx, byteLen, (1048576+31)/32) + } + } + hh.MerkleizeWithMixin(subIndx, num, 16) + } + + hh.Merkleize(indx) + return +} + +// GetTree ssz hashes the SszNewPayloadRequest object +func (s *SszNewPayloadRequest) GetTree() (*ssz.Node, error) { + return ssz.ProofTree(s) +} + +// MarshalSSZ ssz marshals the SszExecutionWitness object +func (s *SszExecutionWitness) MarshalSSZ() ([]byte, error) { + return ssz.MarshalSSZ(s) +} + +// MarshalSSZTo ssz marshals the SszExecutionWitness object to a target array +func (s *SszExecutionWitness) MarshalSSZTo(buf []byte) (dst []byte, err error) { + dst = buf + offset := int(12) + + // Offset (0) 'State' + dst = ssz.WriteOffset(dst, offset) + for ii := 0; ii < len(s.State); ii++ { + offset += 4 + offset += len(s.State[ii]) + } + + // Offset (1) 'Codes' + dst = ssz.WriteOffset(dst, offset) + for ii := 0; ii < len(s.Codes); ii++ { + offset += 4 + offset += len(s.Codes[ii]) + } + + // Offset (2) 'Headers' + dst = ssz.WriteOffset(dst, offset) + + // Field (0) 'State' + if size := len(s.State); size > 1048576 { + err = ssz.ErrListTooBigFn("SszExecutionWitness.State", size, 1048576) + return + } + { + offset = 4 * len(s.State) + for ii := 0; ii < len(s.State); ii++ { + dst = ssz.WriteOffset(dst, offset) + offset += len(s.State[ii]) + } + } + for ii := 0; ii < len(s.State); ii++ { + if size := len(s.State[ii]); size > 1048576 { + err = ssz.ErrBytesLengthFn("SszExecutionWitness.State[ii]", size, 1048576) + return + } + dst = append(dst, s.State[ii]...) + } + + // Field (1) 'Codes' + if size := len(s.Codes); size > 65536 { + err = ssz.ErrListTooBigFn("SszExecutionWitness.Codes", size, 65536) + return + } + { + offset = 4 * len(s.Codes) + for ii := 0; ii < len(s.Codes); ii++ { + dst = ssz.WriteOffset(dst, offset) + offset += len(s.Codes[ii]) + } + } + for ii := 0; ii < len(s.Codes); ii++ { + if size := len(s.Codes[ii]); size > 16777216 { + err = ssz.ErrBytesLengthFn("SszExecutionWitness.Codes[ii]", size, 16777216) + return + } + dst = append(dst, s.Codes[ii]...) + } + + // Field (2) 'Headers' + if size := len(s.Headers); size > 256 { + err = ssz.ErrListTooBigFn("SszExecutionWitness.Headers", size, 256) + return + } + { + offset = 4 * len(s.Headers) + for ii := 0; ii < len(s.Headers); ii++ { + dst = ssz.WriteOffset(dst, offset) + offset += len(s.Headers[ii]) + } + } + for ii := 0; ii < len(s.Headers); ii++ { + if size := len(s.Headers[ii]); size > 1024 { + err = ssz.ErrBytesLengthFn("SszExecutionWitness.Headers[ii]", size, 1024) + return + } + dst = append(dst, s.Headers[ii]...) + } + + return +} + +// UnmarshalSSZ ssz unmarshals the SszExecutionWitness object +func (s *SszExecutionWitness) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 12 { + return ssz.ErrSize + } + + tail := buf + var o0, o1, o2 uint64 + + // Offset (0) 'State' + if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { + return ssz.ErrOffset + } + + if o0 != 12 { + return ssz.ErrInvalidVariableOffset + } + + // Offset (1) 'Codes' + if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 { + return ssz.ErrOffset + } + + // Offset (2) 'Headers' + if o2 = ssz.ReadOffset(buf[8:12]); o2 > size || o1 > o2 { + return ssz.ErrOffset + } + + // Field (0) 'State' + { + buf = tail[o0:o1] + num, err := ssz.DecodeDynamicLength(buf, 1048576) + if err != nil { + return err + } + s.State = make([][]byte, num) + err = ssz.UnmarshalDynamic(buf, num, func(indx int, buf []byte) (err error) { + if len(buf) > 1048576 { + return ssz.ErrBytesLength + } + if cap(s.State[indx]) == 0 { + s.State[indx] = make([]byte, 0, len(buf)) + } + s.State[indx] = append(s.State[indx], buf...) + return nil + }) + if err != nil { + return err + } + } + + // Field (1) 'Codes' + { + buf = tail[o1:o2] + num, err := ssz.DecodeDynamicLength(buf, 65536) + if err != nil { + return err + } + s.Codes = make([][]byte, num) + err = ssz.UnmarshalDynamic(buf, num, func(indx int, buf []byte) (err error) { + if len(buf) > 16777216 { + return ssz.ErrBytesLength + } + if cap(s.Codes[indx]) == 0 { + s.Codes[indx] = make([]byte, 0, len(buf)) + } + s.Codes[indx] = append(s.Codes[indx], buf...) + return nil + }) + if err != nil { + return err + } + } + + // Field (2) 'Headers' + { + buf = tail[o2:] + num, err := ssz.DecodeDynamicLength(buf, 256) + if err != nil { + return err + } + s.Headers = make([][]byte, num) + err = ssz.UnmarshalDynamic(buf, num, func(indx int, buf []byte) (err error) { + if len(buf) > 1024 { + return ssz.ErrBytesLength + } + if cap(s.Headers[indx]) == 0 { + s.Headers[indx] = make([]byte, 0, len(buf)) + } + s.Headers[indx] = append(s.Headers[indx], buf...) + return nil + }) + if err != nil { + return err + } + } + return err +} + +// SizeSSZ returns the ssz encoded size in bytes for the SszExecutionWitness object +func (s *SszExecutionWitness) SizeSSZ() (size int) { + size = 12 + + // Field (0) 'State' + for ii := 0; ii < len(s.State); ii++ { + size += 4 + size += len(s.State[ii]) + } + + // Field (1) 'Codes' + for ii := 0; ii < len(s.Codes); ii++ { + size += 4 + size += len(s.Codes[ii]) + } + + // Field (2) 'Headers' + for ii := 0; ii < len(s.Headers); ii++ { + size += 4 + size += len(s.Headers[ii]) + } + + return +} + +// HashTreeRoot ssz hashes the SszExecutionWitness object +func (s *SszExecutionWitness) HashTreeRoot() ([32]byte, error) { + return ssz.HashWithDefaultHasher(s) +} + +// HashTreeRootWith ssz hashes the SszExecutionWitness object with a hasher +func (s *SszExecutionWitness) HashTreeRootWith(hh ssz.HashWalker) (err error) { + indx := hh.Index() + + // Field (0) 'State' + { + subIndx := hh.Index() + num := uint64(len(s.State)) + if num > 1048576 { + err = ssz.ErrIncorrectListSize + return + } + for _, elem := range s.State { + { + elemIndx := hh.Index() + byteLen := uint64(len(elem)) + if byteLen > 1048576 { + err = ssz.ErrIncorrectListSize + return + } + hh.AppendBytes32(elem) + hh.MerkleizeWithMixin(elemIndx, byteLen, (1048576+31)/32) + } + } + hh.MerkleizeWithMixin(subIndx, num, 1048576) + } + + // Field (1) 'Codes' + { + subIndx := hh.Index() + num := uint64(len(s.Codes)) + if num > 65536 { + err = ssz.ErrIncorrectListSize + return + } + for _, elem := range s.Codes { + { + elemIndx := hh.Index() + byteLen := uint64(len(elem)) + if byteLen > 16777216 { + err = ssz.ErrIncorrectListSize + return + } + hh.AppendBytes32(elem) + hh.MerkleizeWithMixin(elemIndx, byteLen, (16777216+31)/32) + } + } + hh.MerkleizeWithMixin(subIndx, num, 65536) + } + + // Field (2) 'Headers' + { + subIndx := hh.Index() + num := uint64(len(s.Headers)) + if num > 256 { + err = ssz.ErrIncorrectListSize + return + } + for _, elem := range s.Headers { + { + elemIndx := hh.Index() + byteLen := uint64(len(elem)) + if byteLen > 1024 { + err = ssz.ErrIncorrectListSize + return + } + hh.AppendBytes32(elem) + hh.MerkleizeWithMixin(elemIndx, byteLen, (1024+31)/32) + } + } + hh.MerkleizeWithMixin(subIndx, num, 256) + } + + hh.Merkleize(indx) + return +} + +// GetTree ssz hashes the SszExecutionWitness object +func (s *SszExecutionWitness) GetTree() (*ssz.Node, error) { + return ssz.ProofTree(s) +} + +// MarshalSSZ ssz marshals the SszChainConfig object +func (s *SszChainConfig) MarshalSSZ() ([]byte, error) { + return ssz.MarshalSSZ(s) +} + +// MarshalSSZTo ssz marshals the SszChainConfig object to a target array +func (s *SszChainConfig) MarshalSSZTo(buf []byte) (dst []byte, err error) { + dst = buf + + // Field (0) 'ChainId' + dst = ssz.MarshalUint64(dst, s.ChainId) + + return +} + +// UnmarshalSSZ ssz unmarshals the SszChainConfig object +func (s *SszChainConfig) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 8 { + return ssz.ErrSize + } + + // Field (0) 'ChainId' + s.ChainId = ssz.UnmarshallUint64(buf[0:8]) + + return err +} + +// SizeSSZ returns the ssz encoded size in bytes for the SszChainConfig object +func (s *SszChainConfig) SizeSSZ() (size int) { + size = 8 + return +} + +// HashTreeRoot ssz hashes the SszChainConfig object +func (s *SszChainConfig) HashTreeRoot() ([32]byte, error) { + return ssz.HashWithDefaultHasher(s) +} + +// HashTreeRootWith ssz hashes the SszChainConfig object with a hasher +func (s *SszChainConfig) HashTreeRootWith(hh ssz.HashWalker) (err error) { + indx := hh.Index() + + // Field (0) 'ChainId' + hh.PutUint64(s.ChainId) + + hh.Merkleize(indx) + return +} + +// GetTree ssz hashes the SszChainConfig object +func (s *SszChainConfig) GetTree() (*ssz.Node, error) { + return ssz.ProofTree(s) +} + +// MarshalSSZ ssz marshals the SszStatelessInput object +func (s *SszStatelessInput) MarshalSSZ() ([]byte, error) { + return ssz.MarshalSSZ(s) +} + +// MarshalSSZTo ssz marshals the SszStatelessInput object to a target array +func (s *SszStatelessInput) MarshalSSZTo(buf []byte) (dst []byte, err error) { + dst = buf + offset := int(20) + + // Offset (0) 'NewPayloadRequest' + dst = ssz.WriteOffset(dst, offset) + if s.NewPayloadRequest == nil { + s.NewPayloadRequest = new(SszNewPayloadRequest) + } + offset += s.NewPayloadRequest.SizeSSZ() + + // Offset (1) 'Witness' + dst = ssz.WriteOffset(dst, offset) + if s.Witness == nil { + s.Witness = new(SszExecutionWitness) + } + offset += s.Witness.SizeSSZ() + + // Field (2) 'ChainConfig' + if s.ChainConfig == nil { + s.ChainConfig = new(SszChainConfig) + } + if dst, err = s.ChainConfig.MarshalSSZTo(dst); err != nil { + return + } + + // Offset (3) 'PublicKeys' + dst = ssz.WriteOffset(dst, offset) + + // Field (0) 'NewPayloadRequest' + if dst, err = s.NewPayloadRequest.MarshalSSZTo(dst); err != nil { + return + } + + // Field (1) 'Witness' + if dst, err = s.Witness.MarshalSSZTo(dst); err != nil { + return + } + + // Field (3) 'PublicKeys' + if size := len(s.PublicKeys); size > 1048576 { + err = ssz.ErrListTooBigFn("SszStatelessInput.PublicKeys", size, 1048576) + return + } + { + offset = 4 * len(s.PublicKeys) + for ii := 0; ii < len(s.PublicKeys); ii++ { + dst = ssz.WriteOffset(dst, offset) + offset += len(s.PublicKeys[ii]) + } + } + for ii := 0; ii < len(s.PublicKeys); ii++ { + if size := len(s.PublicKeys[ii]); size > 48 { + err = ssz.ErrBytesLengthFn("SszStatelessInput.PublicKeys[ii]", size, 48) + return + } + dst = append(dst, s.PublicKeys[ii]...) + } + + return +} + +// UnmarshalSSZ ssz unmarshals the SszStatelessInput object +func (s *SszStatelessInput) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 20 { + return ssz.ErrSize + } + + tail := buf + var o0, o1, o3 uint64 + + // Offset (0) 'NewPayloadRequest' + if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { + return ssz.ErrOffset + } + + if o0 != 20 { + return ssz.ErrInvalidVariableOffset + } + + // Offset (1) 'Witness' + if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 { + return ssz.ErrOffset + } + + // Field (2) 'ChainConfig' + if s.ChainConfig == nil { + s.ChainConfig = new(SszChainConfig) + } + if err = s.ChainConfig.UnmarshalSSZ(buf[8:16]); err != nil { + return err + } + + // Offset (3) 'PublicKeys' + if o3 = ssz.ReadOffset(buf[16:20]); o3 > size || o1 > o3 { + return ssz.ErrOffset + } + + // Field (0) 'NewPayloadRequest' + { + buf = tail[o0:o1] + if s.NewPayloadRequest == nil { + s.NewPayloadRequest = new(SszNewPayloadRequest) + } + if err = s.NewPayloadRequest.UnmarshalSSZ(buf); err != nil { + return err + } + } + + // Field (1) 'Witness' + { + buf = tail[o1:o3] + if s.Witness == nil { + s.Witness = new(SszExecutionWitness) + } + if err = s.Witness.UnmarshalSSZ(buf); err != nil { + return err + } + } + + // Field (3) 'PublicKeys' + { + buf = tail[o3:] + num, err := ssz.DecodeDynamicLength(buf, 1048576) + if err != nil { + return err + } + s.PublicKeys = make([][]byte, num) + err = ssz.UnmarshalDynamic(buf, num, func(indx int, buf []byte) (err error) { + if len(buf) > 48 { + return ssz.ErrBytesLength + } + if cap(s.PublicKeys[indx]) == 0 { + s.PublicKeys[indx] = make([]byte, 0, len(buf)) + } + s.PublicKeys[indx] = append(s.PublicKeys[indx], buf...) + return nil + }) + if err != nil { + return err + } + } + return err +} + +// SizeSSZ returns the ssz encoded size in bytes for the SszStatelessInput object +func (s *SszStatelessInput) SizeSSZ() (size int) { + size = 20 + + // Field (0) 'NewPayloadRequest' + if s.NewPayloadRequest == nil { + s.NewPayloadRequest = new(SszNewPayloadRequest) + } + size += s.NewPayloadRequest.SizeSSZ() + + // Field (1) 'Witness' + if s.Witness == nil { + s.Witness = new(SszExecutionWitness) + } + size += s.Witness.SizeSSZ() + + // Field (3) 'PublicKeys' + for ii := 0; ii < len(s.PublicKeys); ii++ { + size += 4 + size += len(s.PublicKeys[ii]) + } + + return +} + +// HashTreeRoot ssz hashes the SszStatelessInput object +func (s *SszStatelessInput) HashTreeRoot() ([32]byte, error) { + return ssz.HashWithDefaultHasher(s) +} + +// HashTreeRootWith ssz hashes the SszStatelessInput object with a hasher +func (s *SszStatelessInput) HashTreeRootWith(hh ssz.HashWalker) (err error) { + indx := hh.Index() + + // Field (0) 'NewPayloadRequest' + if err = s.NewPayloadRequest.HashTreeRootWith(hh); err != nil { + return + } + + // Field (1) 'Witness' + if err = s.Witness.HashTreeRootWith(hh); err != nil { + return + } + + // Field (2) 'ChainConfig' + if s.ChainConfig == nil { + s.ChainConfig = new(SszChainConfig) + } + if err = s.ChainConfig.HashTreeRootWith(hh); err != nil { + return + } + + // Field (3) 'PublicKeys' + { + subIndx := hh.Index() + num := uint64(len(s.PublicKeys)) + if num > 1048576 { + err = ssz.ErrIncorrectListSize + return + } + for _, elem := range s.PublicKeys { + { + elemIndx := hh.Index() + byteLen := uint64(len(elem)) + if byteLen > 48 { + err = ssz.ErrIncorrectListSize + return + } + hh.AppendBytes32(elem) + hh.MerkleizeWithMixin(elemIndx, byteLen, (48+31)/32) + } + } + hh.MerkleizeWithMixin(subIndx, num, 1048576) + } + + hh.Merkleize(indx) + return +} + +// GetTree ssz hashes the SszStatelessInput object +func (s *SszStatelessInput) GetTree() (*ssz.Node, error) { + return ssz.ProofTree(s) +} + +// MarshalSSZ ssz marshals the SszStatelessValidationResult object +func (s *SszStatelessValidationResult) MarshalSSZ() ([]byte, error) { + return ssz.MarshalSSZ(s) +} + +// MarshalSSZTo ssz marshals the SszStatelessValidationResult object to a target array +func (s *SszStatelessValidationResult) MarshalSSZTo(buf []byte) (dst []byte, err error) { + dst = buf + + // Field (0) 'NewPayloadRequestRoot' + dst = append(dst, s.NewPayloadRequestRoot[:]...) + + // Field (1) 'SuccessfulValidation' + dst = ssz.MarshalBool(dst, s.SuccessfulValidation) + + // Field (2) 'ChainConfig' + if s.ChainConfig == nil { + s.ChainConfig = new(SszChainConfig) + } + if dst, err = s.ChainConfig.MarshalSSZTo(dst); err != nil { + return + } + + return +} + +// UnmarshalSSZ ssz unmarshals the SszStatelessValidationResult object +func (s *SszStatelessValidationResult) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 41 { + return ssz.ErrSize + } + + // Field (0) 'NewPayloadRequestRoot' + copy(s.NewPayloadRequestRoot[:], buf[0:32]) + + // Field (1) 'SuccessfulValidation' + s.SuccessfulValidation = ssz.UnmarshalBool(buf[32:33]) + + // Field (2) 'ChainConfig' + if s.ChainConfig == nil { + s.ChainConfig = new(SszChainConfig) + } + if err = s.ChainConfig.UnmarshalSSZ(buf[33:41]); err != nil { + return err + } + + return err +} + +// SizeSSZ returns the ssz encoded size in bytes for the SszStatelessValidationResult object +func (s *SszStatelessValidationResult) SizeSSZ() (size int) { + size = 41 + return +} + +// HashTreeRoot ssz hashes the SszStatelessValidationResult object +func (s *SszStatelessValidationResult) HashTreeRoot() ([32]byte, error) { + return ssz.HashWithDefaultHasher(s) +} + +// HashTreeRootWith ssz hashes the SszStatelessValidationResult object with a hasher +func (s *SszStatelessValidationResult) HashTreeRootWith(hh ssz.HashWalker) (err error) { + indx := hh.Index() + + // Field (0) 'NewPayloadRequestRoot' + hh.PutBytes(s.NewPayloadRequestRoot[:]) + + // Field (1) 'SuccessfulValidation' + hh.PutBool(s.SuccessfulValidation) + + // Field (2) 'ChainConfig' + if s.ChainConfig == nil { + s.ChainConfig = new(SszChainConfig) + } + if err = s.ChainConfig.HashTreeRootWith(hh); err != nil { + return + } + + hh.Merkleize(indx) + return +} + +// GetTree ssz hashes the SszStatelessValidationResult object +func (s *SszStatelessValidationResult) GetTree() (*ssz.Node, error) { + return ssz.ProofTree(s) +}