mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 21:56:43 +00:00
remove ssz encoding. do not wrap encoded BALs into RLP bytes (RLP encode the BALs directly)
This commit is contained in:
parent
6b4a72749c
commit
5d629c9a99
4 changed files with 17 additions and 1255 deletions
|
|
@ -150,18 +150,6 @@ func (b *ConstructionBlockAccessList) PrettyPrint() string {
|
|||
return enc.PrettyPrint()
|
||||
}
|
||||
|
||||
// Hash computes the SSZ hash of the access list
|
||||
func (b *ConstructionBlockAccessList) Hash() common.Hash {
|
||||
hash, err := b.toEncodingObj().HashTreeRoot()
|
||||
if err != nil {
|
||||
// errors here are related to BAL values exceeding maximum size defined
|
||||
// by the spec. Hard-fail because these cases are not expected to be hit
|
||||
// under reasonable conditions.
|
||||
panic(err)
|
||||
}
|
||||
return hash
|
||||
}
|
||||
|
||||
// Copy returns a deep copy of the access list.
|
||||
func (b *ConstructionBlockAccessList) Copy() *ConstructionBlockAccessList {
|
||||
res := NewBlockAccessList()
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import (
|
|||
"bytes"
|
||||
"cmp"
|
||||
"fmt"
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
"io"
|
||||
"maps"
|
||||
|
|
@ -31,8 +32,7 @@ import (
|
|||
"github.com/holiman/uint256"
|
||||
)
|
||||
|
||||
//go:generate go run github.com/ferranbt/fastssz/sszgen --output bal_encoding_ssz_generated.go --path . --objs encodingStorageWrite,encodingCodeChange,encodingBalanceChange,encodingAccountNonce,encodingAccountAccess,encodingBlockAccessList
|
||||
//go:generate go run github.com/ethereum/go-ethereum/rlp/rlpgen -out bal_encoding_rlp_generated.go -type encodingBlockAccessList -decoder
|
||||
//go:generate go run github.com/ethereum/go-ethereum/rlp/rlpgen -out bal_encoding_rlp_generated.go -type BlockAccessList -decoder
|
||||
|
||||
// These are objects used as input for the access list encoding. They mirror
|
||||
// the spec format.
|
||||
|
|
@ -42,10 +42,10 @@ type BlockAccessList struct {
|
|||
Accesses []AccountAccess `ssz-max:"300000"`
|
||||
}
|
||||
|
||||
// validate returns an error if the contents of the access list are not ordered
|
||||
// Validate returns an error if the contents of the access list are not ordered
|
||||
// according to the spec or any code changes are contained which exceed protocol
|
||||
// max code size.
|
||||
func (e *BlockAccessList) validate() error {
|
||||
func (e *BlockAccessList) Validate() error {
|
||||
var (
|
||||
prev *[20]byte
|
||||
)
|
||||
|
|
@ -63,6 +63,18 @@ func (e *BlockAccessList) validate() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (e *BlockAccessList) Hash() common.Hash {
|
||||
var enc bytes.Buffer
|
||||
err := e.EncodeRLP(&enc)
|
||||
if err != nil {
|
||||
// errors here are related to BAL values exceeding maximum size defined
|
||||
// by the spec. Hard-fail because these cases are not expected to be hit
|
||||
// under reasonable conditions.
|
||||
panic(err)
|
||||
}
|
||||
return crypto.Keccak256Hash(enc.Bytes())
|
||||
}
|
||||
|
||||
// encodeBalance encodes the provided balance into 16-bytes.
|
||||
func encodeBalance(val *uint256.Int) [16]byte {
|
||||
valBytes := val.Bytes()
|
||||
|
|
@ -184,44 +196,11 @@ func (e *AccountAccess) validate() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// EncodeRLP returns the SSZ-encoded access list wrapped into RLP bytes.
|
||||
// EncodeRLP returns the RLP-encoded access list
|
||||
func (b *ConstructionBlockAccessList) EncodeRLP(wr io.Writer) error {
|
||||
w := rlp.NewEncoderBuffer(wr)
|
||||
buf, err := b.encodeSSZ()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
w.WriteBytes(buf)
|
||||
return w.Flush()
|
||||
}
|
||||
|
||||
// DecodeRLP decodes the bloc accessList.
|
||||
func (b *BlockAccessList) DecodeSSZRLP(s *rlp.Stream) error {
|
||||
encBytes, err := s.Bytes()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return b.decodeSSZ(encBytes)
|
||||
}
|
||||
|
||||
// EncodeFullRLP returns the RLP-encoded access list wrapped into RLP bytes.
|
||||
func (b *ConstructionBlockAccessList) EncodeFullRLP(wr io.Writer) error {
|
||||
return b.toEncodingObj().EncodeRLP(wr)
|
||||
}
|
||||
|
||||
// DecodeFullRLP decodes the block accessList with full RLP format.
|
||||
func (b *BlockAccessList) DecodeFullRLP(s *rlp.Stream) error {
|
||||
var obj BlockAccessList
|
||||
if err := obj.DecodeRLP(s); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := obj.validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
*b = obj
|
||||
return nil
|
||||
}
|
||||
|
||||
var _ rlp.Encoder = &ConstructionBlockAccessList{}
|
||||
|
||||
// toEncodingObj creates an instance of the ConstructionAccountAccess of the type that is
|
||||
|
|
@ -312,25 +291,6 @@ func (b *ConstructionBlockAccessList) toEncodingObj() *BlockAccessList {
|
|||
return &res
|
||||
}
|
||||
|
||||
func (b *ConstructionBlockAccessList) encodeSSZ() ([]byte, error) {
|
||||
encoderObj := b.toEncodingObj()
|
||||
dst, err := encoderObj.MarshalSSZTo(nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return dst, nil
|
||||
}
|
||||
|
||||
func (b *BlockAccessList) decodeSSZ(buf []byte) error {
|
||||
if err := b.UnmarshalSSZ(buf); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := b.validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e *BlockAccessList) PrettyPrint() string {
|
||||
var res bytes.Buffer
|
||||
printWithIndent := func(indent int, text string) {
|
||||
|
|
|
|||
|
|
@ -1,280 +0,0 @@
|
|||
// Code generated by rlpgen. DO NOT EDIT.
|
||||
|
||||
package bal
|
||||
|
||||
import "github.com/ethereum/go-ethereum/rlp"
|
||||
import "io"
|
||||
|
||||
func (obj *BlockAccessList) EncodeRLP(_w io.Writer) error {
|
||||
w := rlp.NewEncoderBuffer(_w)
|
||||
_tmp0 := w.List()
|
||||
_tmp1 := w.List()
|
||||
for _, _tmp2 := range obj.Accesses {
|
||||
_tmp3 := w.List()
|
||||
w.WriteBytes(_tmp2.Address[:])
|
||||
_tmp4 := w.List()
|
||||
for _, _tmp5 := range _tmp2.StorageWrites {
|
||||
_tmp6 := w.List()
|
||||
w.WriteBytes(_tmp5.Slot[:])
|
||||
_tmp7 := w.List()
|
||||
for _, _tmp8 := range _tmp5.Accesses {
|
||||
_tmp9 := w.List()
|
||||
w.WriteUint64(uint64(_tmp8.TxIdx))
|
||||
w.WriteBytes(_tmp8.ValueAfter[:])
|
||||
w.ListEnd(_tmp9)
|
||||
}
|
||||
w.ListEnd(_tmp7)
|
||||
w.ListEnd(_tmp6)
|
||||
}
|
||||
w.ListEnd(_tmp4)
|
||||
_tmp10 := w.List()
|
||||
for _, _tmp11 := range _tmp2.StorageReads {
|
||||
w.WriteBytes(_tmp11[:])
|
||||
}
|
||||
w.ListEnd(_tmp10)
|
||||
_tmp12 := w.List()
|
||||
for _, _tmp13 := range _tmp2.BalanceChanges {
|
||||
_tmp14 := w.List()
|
||||
w.WriteUint64(uint64(_tmp13.TxIdx))
|
||||
w.WriteBytes(_tmp13.Balance[:])
|
||||
w.ListEnd(_tmp14)
|
||||
}
|
||||
w.ListEnd(_tmp12)
|
||||
_tmp15 := w.List()
|
||||
for _, _tmp16 := range _tmp2.NonceChanges {
|
||||
_tmp17 := w.List()
|
||||
w.WriteUint64(uint64(_tmp16.TxIdx))
|
||||
w.WriteUint64(_tmp16.Nonce)
|
||||
w.ListEnd(_tmp17)
|
||||
}
|
||||
w.ListEnd(_tmp15)
|
||||
_tmp18 := w.List()
|
||||
for _, _tmp19 := range _tmp2.Code {
|
||||
_tmp20 := w.List()
|
||||
w.WriteUint64(uint64(_tmp19.TxIndex))
|
||||
w.WriteBytes(_tmp19.Code)
|
||||
w.ListEnd(_tmp20)
|
||||
}
|
||||
w.ListEnd(_tmp18)
|
||||
w.ListEnd(_tmp3)
|
||||
}
|
||||
w.ListEnd(_tmp1)
|
||||
w.ListEnd(_tmp0)
|
||||
return w.Flush()
|
||||
}
|
||||
|
||||
func (obj *BlockAccessList) DecodeRLP(dec *rlp.Stream) error {
|
||||
var _tmp0 BlockAccessList
|
||||
{
|
||||
if _, err := dec.List(); err != nil {
|
||||
return err
|
||||
}
|
||||
// Accesses:
|
||||
var _tmp1 []AccountAccess
|
||||
if _, err := dec.List(); err != nil {
|
||||
return err
|
||||
}
|
||||
for dec.MoreDataInList() {
|
||||
var _tmp2 AccountAccess
|
||||
{
|
||||
if _, err := dec.List(); err != nil {
|
||||
return err
|
||||
}
|
||||
// Address:
|
||||
var _tmp3 [20]byte
|
||||
if err := dec.ReadBytes(_tmp3[:]); err != nil {
|
||||
return err
|
||||
}
|
||||
_tmp2.Address = _tmp3
|
||||
// StorageWrites:
|
||||
var _tmp4 []encodingSlotWrites
|
||||
if _, err := dec.List(); err != nil {
|
||||
return err
|
||||
}
|
||||
for dec.MoreDataInList() {
|
||||
var _tmp5 encodingSlotWrites
|
||||
{
|
||||
if _, err := dec.List(); err != nil {
|
||||
return err
|
||||
}
|
||||
// Slot:
|
||||
var _tmp6 [32]byte
|
||||
if err := dec.ReadBytes(_tmp6[:]); err != nil {
|
||||
return err
|
||||
}
|
||||
_tmp5.Slot = _tmp6
|
||||
// Accesses:
|
||||
var _tmp7 []encodingStorageWrite
|
||||
if _, err := dec.List(); err != nil {
|
||||
return err
|
||||
}
|
||||
for dec.MoreDataInList() {
|
||||
var _tmp8 encodingStorageWrite
|
||||
{
|
||||
if _, err := dec.List(); err != nil {
|
||||
return err
|
||||
}
|
||||
// TxIdx:
|
||||
_tmp9, err := dec.Uint16()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_tmp8.TxIdx = _tmp9
|
||||
// ValueAfter:
|
||||
var _tmp10 [32]byte
|
||||
if err := dec.ReadBytes(_tmp10[:]); err != nil {
|
||||
return err
|
||||
}
|
||||
_tmp8.ValueAfter = _tmp10
|
||||
if err := dec.ListEnd(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
_tmp7 = append(_tmp7, _tmp8)
|
||||
}
|
||||
if err := dec.ListEnd(); err != nil {
|
||||
return err
|
||||
}
|
||||
_tmp5.Accesses = _tmp7
|
||||
if err := dec.ListEnd(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
_tmp4 = append(_tmp4, _tmp5)
|
||||
}
|
||||
if err := dec.ListEnd(); err != nil {
|
||||
return err
|
||||
}
|
||||
_tmp2.StorageWrites = _tmp4
|
||||
// StorageReads:
|
||||
var _tmp11 [][32]byte
|
||||
if _, err := dec.List(); err != nil {
|
||||
return err
|
||||
}
|
||||
for dec.MoreDataInList() {
|
||||
var _tmp12 [32]byte
|
||||
if err := dec.ReadBytes(_tmp12[:]); err != nil {
|
||||
return err
|
||||
}
|
||||
_tmp11 = append(_tmp11, _tmp12)
|
||||
}
|
||||
if err := dec.ListEnd(); err != nil {
|
||||
return err
|
||||
}
|
||||
_tmp2.StorageReads = _tmp11
|
||||
// BalanceChanges:
|
||||
var _tmp13 []encodingBalanceChange
|
||||
if _, err := dec.List(); err != nil {
|
||||
return err
|
||||
}
|
||||
for dec.MoreDataInList() {
|
||||
var _tmp14 encodingBalanceChange
|
||||
{
|
||||
if _, err := dec.List(); err != nil {
|
||||
return err
|
||||
}
|
||||
// TxIdx:
|
||||
_tmp15, err := dec.Uint16()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_tmp14.TxIdx = _tmp15
|
||||
// Balance:
|
||||
var _tmp16 [16]byte
|
||||
if err := dec.ReadBytes(_tmp16[:]); err != nil {
|
||||
return err
|
||||
}
|
||||
_tmp14.Balance = _tmp16
|
||||
if err := dec.ListEnd(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
_tmp13 = append(_tmp13, _tmp14)
|
||||
}
|
||||
if err := dec.ListEnd(); err != nil {
|
||||
return err
|
||||
}
|
||||
_tmp2.BalanceChanges = _tmp13
|
||||
// NonceChanges:
|
||||
var _tmp17 []encodingAccountNonce
|
||||
if _, err := dec.List(); err != nil {
|
||||
return err
|
||||
}
|
||||
for dec.MoreDataInList() {
|
||||
var _tmp18 encodingAccountNonce
|
||||
{
|
||||
if _, err := dec.List(); err != nil {
|
||||
return err
|
||||
}
|
||||
// TxIdx:
|
||||
_tmp19, err := dec.Uint16()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_tmp18.TxIdx = _tmp19
|
||||
// Nonce:
|
||||
_tmp20, err := dec.Uint64()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_tmp18.Nonce = _tmp20
|
||||
if err := dec.ListEnd(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
_tmp17 = append(_tmp17, _tmp18)
|
||||
}
|
||||
if err := dec.ListEnd(); err != nil {
|
||||
return err
|
||||
}
|
||||
_tmp2.NonceChanges = _tmp17
|
||||
// Code:
|
||||
var _tmp21 []encodingCodeChange
|
||||
if _, err := dec.List(); err != nil {
|
||||
return err
|
||||
}
|
||||
for dec.MoreDataInList() {
|
||||
var _tmp22 encodingCodeChange
|
||||
{
|
||||
if _, err := dec.List(); err != nil {
|
||||
return err
|
||||
}
|
||||
// TxIndex:
|
||||
_tmp23, err := dec.Uint16()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_tmp22.TxIndex = _tmp23
|
||||
// Code:
|
||||
_tmp24, err := dec.Bytes()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_tmp22.Code = _tmp24
|
||||
if err := dec.ListEnd(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
_tmp21 = append(_tmp21, _tmp22)
|
||||
}
|
||||
if err := dec.ListEnd(); err != nil {
|
||||
return err
|
||||
}
|
||||
_tmp2.Code = _tmp21
|
||||
if err := dec.ListEnd(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
_tmp1 = append(_tmp1, _tmp2)
|
||||
}
|
||||
if err := dec.ListEnd(); err != nil {
|
||||
return err
|
||||
}
|
||||
_tmp0.Accesses = _tmp1
|
||||
if err := dec.ListEnd(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
*obj = _tmp0
|
||||
return nil
|
||||
}
|
||||
|
|
@ -1,906 +0,0 @@
|
|||
// Code generated by fastssz. DO NOT EDIT.
|
||||
// Hash: 52e68d5f470c3c68962d9d1adb13fcc3828c2efcd43c4c592c091935bb9f35f6
|
||||
// Version: 0.1.3
|
||||
package bal
|
||||
|
||||
import (
|
||||
ssz "github.com/ferranbt/fastssz"
|
||||
)
|
||||
|
||||
// MarshalSSZ ssz marshals the BlockAccessList object
|
||||
func (e *BlockAccessList) MarshalSSZ() ([]byte, error) {
|
||||
return ssz.MarshalSSZ(e)
|
||||
}
|
||||
|
||||
// MarshalSSZTo ssz marshals the BlockAccessList object to a target array
|
||||
func (e *BlockAccessList) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
||||
dst = buf
|
||||
offset := int(4)
|
||||
|
||||
// Offset (0) 'Accesses'
|
||||
dst = ssz.WriteOffset(dst, offset)
|
||||
|
||||
// Field (0) 'Accesses'
|
||||
if size := len(e.Accesses); size > 300000 {
|
||||
err = ssz.ErrListTooBigFn("BlockAccessList.Accesses", size, 300000)
|
||||
return
|
||||
}
|
||||
{
|
||||
offset = 4 * len(e.Accesses)
|
||||
for ii := 0; ii < len(e.Accesses); ii++ {
|
||||
dst = ssz.WriteOffset(dst, offset)
|
||||
offset += e.Accesses[ii].SizeSSZ()
|
||||
}
|
||||
}
|
||||
for ii := 0; ii < len(e.Accesses); ii++ {
|
||||
if dst, err = e.Accesses[ii].MarshalSSZTo(dst); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// UnmarshalSSZ ssz unmarshals the BlockAccessList object
|
||||
func (e *BlockAccessList) UnmarshalSSZ(buf []byte) error {
|
||||
var err error
|
||||
size := uint64(len(buf))
|
||||
if size < 4 {
|
||||
return ssz.ErrSize
|
||||
}
|
||||
|
||||
tail := buf
|
||||
var o0 uint64
|
||||
|
||||
// Offset (0) 'Accesses'
|
||||
if o0 = ssz.ReadOffset(buf[0:4]); o0 > size {
|
||||
return ssz.ErrOffset
|
||||
}
|
||||
|
||||
if o0 != 4 {
|
||||
return ssz.ErrInvalidVariableOffset
|
||||
}
|
||||
|
||||
// Field (0) 'Accesses'
|
||||
{
|
||||
buf = tail[o0:]
|
||||
num, err := ssz.DecodeDynamicLength(buf, 300000)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
e.Accesses = make([]AccountAccess, num)
|
||||
err = ssz.UnmarshalDynamic(buf, num, func(indx int, buf []byte) (err error) {
|
||||
if err = e.Accesses[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 BlockAccessList object
|
||||
func (e *BlockAccessList) SizeSSZ() (size int) {
|
||||
size = 4
|
||||
|
||||
// Field (0) 'Accesses'
|
||||
for ii := 0; ii < len(e.Accesses); ii++ {
|
||||
size += 4
|
||||
size += e.Accesses[ii].SizeSSZ()
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// HashTreeRoot ssz hashes the BlockAccessList object
|
||||
func (e *BlockAccessList) HashTreeRoot() ([32]byte, error) {
|
||||
return ssz.HashWithDefaultHasher(e)
|
||||
}
|
||||
|
||||
// HashTreeRootWith ssz hashes the BlockAccessList object with a hasher
|
||||
func (e *BlockAccessList) HashTreeRootWith(hh ssz.HashWalker) (err error) {
|
||||
indx := hh.Index()
|
||||
|
||||
// Field (0) 'Accesses'
|
||||
{
|
||||
subIndx := hh.Index()
|
||||
num := uint64(len(e.Accesses))
|
||||
if num > 300000 {
|
||||
err = ssz.ErrIncorrectListSize
|
||||
return
|
||||
}
|
||||
for _, elem := range e.Accesses {
|
||||
if err = elem.HashTreeRootWith(hh); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
hh.MerkleizeWithMixin(subIndx, num, 300000)
|
||||
}
|
||||
|
||||
hh.Merkleize(indx)
|
||||
return
|
||||
}
|
||||
|
||||
// GetTree ssz hashes the BlockAccessList object
|
||||
func (e *BlockAccessList) GetTree() (*ssz.Node, error) {
|
||||
return ssz.ProofTree(e)
|
||||
}
|
||||
|
||||
// MarshalSSZ ssz marshals the encodingCodeChange object
|
||||
func (e *encodingCodeChange) MarshalSSZ() ([]byte, error) {
|
||||
return ssz.MarshalSSZ(e)
|
||||
}
|
||||
|
||||
// MarshalSSZTo ssz marshals the encodingCodeChange object to a target array
|
||||
func (e *encodingCodeChange) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
||||
dst = buf
|
||||
offset := int(6)
|
||||
|
||||
// Field (0) 'TxIndex'
|
||||
dst = ssz.MarshalUint16(dst, e.TxIndex)
|
||||
|
||||
// Offset (1) 'Code'
|
||||
dst = ssz.WriteOffset(dst, offset)
|
||||
|
||||
// Field (1) 'Code'
|
||||
if size := len(e.Code); size > 24576 {
|
||||
err = ssz.ErrBytesLengthFn("encodingCodeChange.Code", size, 24576)
|
||||
return
|
||||
}
|
||||
dst = append(dst, e.Code...)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// UnmarshalSSZ ssz unmarshals the encodingCodeChange object
|
||||
func (e *encodingCodeChange) UnmarshalSSZ(buf []byte) error {
|
||||
var err error
|
||||
size := uint64(len(buf))
|
||||
if size < 6 {
|
||||
return ssz.ErrSize
|
||||
}
|
||||
|
||||
tail := buf
|
||||
var o1 uint64
|
||||
|
||||
// Field (0) 'TxIndex'
|
||||
e.TxIndex = ssz.UnmarshallUint16(buf[0:2])
|
||||
|
||||
// Offset (1) 'Code'
|
||||
if o1 = ssz.ReadOffset(buf[2:6]); o1 > size {
|
||||
return ssz.ErrOffset
|
||||
}
|
||||
|
||||
if o1 != 6 {
|
||||
return ssz.ErrInvalidVariableOffset
|
||||
}
|
||||
|
||||
// Field (1) 'Code'
|
||||
{
|
||||
buf = tail[o1:]
|
||||
if len(buf) > 24576 {
|
||||
return ssz.ErrBytesLength
|
||||
}
|
||||
if cap(e.Code) == 0 {
|
||||
e.Code = make([]byte, 0, len(buf))
|
||||
}
|
||||
e.Code = append(e.Code, buf...)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
// SizeSSZ returns the ssz encoded size in bytes for the encodingCodeChange object
|
||||
func (e *encodingCodeChange) SizeSSZ() (size int) {
|
||||
size = 6
|
||||
|
||||
// Field (1) 'Code'
|
||||
size += len(e.Code)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// HashTreeRoot ssz hashes the encodingCodeChange object
|
||||
func (e *encodingCodeChange) HashTreeRoot() ([32]byte, error) {
|
||||
return ssz.HashWithDefaultHasher(e)
|
||||
}
|
||||
|
||||
// HashTreeRootWith ssz hashes the encodingCodeChange object with a hasher
|
||||
func (e *encodingCodeChange) HashTreeRootWith(hh ssz.HashWalker) (err error) {
|
||||
indx := hh.Index()
|
||||
|
||||
// Field (0) 'TxIndex'
|
||||
hh.PutUint16(e.TxIndex)
|
||||
|
||||
// Field (1) 'Code'
|
||||
{
|
||||
elemIndx := hh.Index()
|
||||
byteLen := uint64(len(e.Code))
|
||||
if byteLen > 24576 {
|
||||
err = ssz.ErrIncorrectListSize
|
||||
return
|
||||
}
|
||||
hh.Append(e.Code)
|
||||
hh.MerkleizeWithMixin(elemIndx, byteLen, (24576+31)/32)
|
||||
}
|
||||
|
||||
hh.Merkleize(indx)
|
||||
return
|
||||
}
|
||||
|
||||
// GetTree ssz hashes the encodingCodeChange object
|
||||
func (e *encodingCodeChange) GetTree() (*ssz.Node, error) {
|
||||
return ssz.ProofTree(e)
|
||||
}
|
||||
|
||||
// MarshalSSZ ssz marshals the encodingBalanceChange object
|
||||
func (e *encodingBalanceChange) MarshalSSZ() ([]byte, error) {
|
||||
return ssz.MarshalSSZ(e)
|
||||
}
|
||||
|
||||
// MarshalSSZTo ssz marshals the encodingBalanceChange object to a target array
|
||||
func (e *encodingBalanceChange) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
||||
dst = buf
|
||||
|
||||
// Field (0) 'TxIdx'
|
||||
dst = ssz.MarshalUint16(dst, e.TxIdx)
|
||||
|
||||
// Field (1) 'Balance'
|
||||
dst = append(dst, e.Balance[:]...)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// UnmarshalSSZ ssz unmarshals the encodingBalanceChange object
|
||||
func (e *encodingBalanceChange) UnmarshalSSZ(buf []byte) error {
|
||||
var err error
|
||||
size := uint64(len(buf))
|
||||
if size != 18 {
|
||||
return ssz.ErrSize
|
||||
}
|
||||
|
||||
// Field (0) 'TxIdx'
|
||||
e.TxIdx = ssz.UnmarshallUint16(buf[0:2])
|
||||
|
||||
// Field (1) 'Balance'
|
||||
copy(e.Balance[:], buf[2:18])
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
// SizeSSZ returns the ssz encoded size in bytes for the encodingBalanceChange object
|
||||
func (e *encodingBalanceChange) SizeSSZ() (size int) {
|
||||
size = 18
|
||||
return
|
||||
}
|
||||
|
||||
// HashTreeRoot ssz hashes the encodingBalanceChange object
|
||||
func (e *encodingBalanceChange) HashTreeRoot() ([32]byte, error) {
|
||||
return ssz.HashWithDefaultHasher(e)
|
||||
}
|
||||
|
||||
// HashTreeRootWith ssz hashes the encodingBalanceChange object with a hasher
|
||||
func (e *encodingBalanceChange) HashTreeRootWith(hh ssz.HashWalker) (err error) {
|
||||
indx := hh.Index()
|
||||
|
||||
// Field (0) 'TxIdx'
|
||||
hh.PutUint16(e.TxIdx)
|
||||
|
||||
// Field (1) 'Balance'
|
||||
hh.PutBytes(e.Balance[:])
|
||||
|
||||
hh.Merkleize(indx)
|
||||
return
|
||||
}
|
||||
|
||||
// GetTree ssz hashes the encodingBalanceChange object
|
||||
func (e *encodingBalanceChange) GetTree() (*ssz.Node, error) {
|
||||
return ssz.ProofTree(e)
|
||||
}
|
||||
|
||||
// MarshalSSZ ssz marshals the encodingAccountNonce object
|
||||
func (e *encodingAccountNonce) MarshalSSZ() ([]byte, error) {
|
||||
return ssz.MarshalSSZ(e)
|
||||
}
|
||||
|
||||
// MarshalSSZTo ssz marshals the encodingAccountNonce object to a target array
|
||||
func (e *encodingAccountNonce) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
||||
dst = buf
|
||||
|
||||
// Field (0) 'TxIdx'
|
||||
dst = ssz.MarshalUint16(dst, e.TxIdx)
|
||||
|
||||
// Field (1) 'Nonce'
|
||||
dst = ssz.MarshalUint64(dst, e.Nonce)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// UnmarshalSSZ ssz unmarshals the encodingAccountNonce object
|
||||
func (e *encodingAccountNonce) UnmarshalSSZ(buf []byte) error {
|
||||
var err error
|
||||
size := uint64(len(buf))
|
||||
if size != 10 {
|
||||
return ssz.ErrSize
|
||||
}
|
||||
|
||||
// Field (0) 'TxIdx'
|
||||
e.TxIdx = ssz.UnmarshallUint16(buf[0:2])
|
||||
|
||||
// Field (1) 'Nonce'
|
||||
e.Nonce = ssz.UnmarshallUint64(buf[2:10])
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
// SizeSSZ returns the ssz encoded size in bytes for the encodingAccountNonce object
|
||||
func (e *encodingAccountNonce) SizeSSZ() (size int) {
|
||||
size = 10
|
||||
return
|
||||
}
|
||||
|
||||
// HashTreeRoot ssz hashes the encodingAccountNonce object
|
||||
func (e *encodingAccountNonce) HashTreeRoot() ([32]byte, error) {
|
||||
return ssz.HashWithDefaultHasher(e)
|
||||
}
|
||||
|
||||
// HashTreeRootWith ssz hashes the encodingAccountNonce object with a hasher
|
||||
func (e *encodingAccountNonce) HashTreeRootWith(hh ssz.HashWalker) (err error) {
|
||||
indx := hh.Index()
|
||||
|
||||
// Field (0) 'TxIdx'
|
||||
hh.PutUint16(e.TxIdx)
|
||||
|
||||
// Field (1) 'Nonce'
|
||||
hh.PutUint64(e.Nonce)
|
||||
|
||||
hh.Merkleize(indx)
|
||||
return
|
||||
}
|
||||
|
||||
// GetTree ssz hashes the encodingAccountNonce object
|
||||
func (e *encodingAccountNonce) GetTree() (*ssz.Node, error) {
|
||||
return ssz.ProofTree(e)
|
||||
}
|
||||
|
||||
// MarshalSSZ ssz marshals the encodingStorageWrite object
|
||||
func (e *encodingStorageWrite) MarshalSSZ() ([]byte, error) {
|
||||
return ssz.MarshalSSZ(e)
|
||||
}
|
||||
|
||||
// MarshalSSZTo ssz marshals the encodingStorageWrite object to a target array
|
||||
func (e *encodingStorageWrite) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
||||
dst = buf
|
||||
|
||||
// Field (0) 'TxIdx'
|
||||
dst = ssz.MarshalUint16(dst, e.TxIdx)
|
||||
|
||||
// Field (1) 'ValueAfter'
|
||||
dst = append(dst, e.ValueAfter[:]...)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// UnmarshalSSZ ssz unmarshals the encodingStorageWrite object
|
||||
func (e *encodingStorageWrite) UnmarshalSSZ(buf []byte) error {
|
||||
var err error
|
||||
size := uint64(len(buf))
|
||||
if size != 34 {
|
||||
return ssz.ErrSize
|
||||
}
|
||||
|
||||
// Field (0) 'TxIdx'
|
||||
e.TxIdx = ssz.UnmarshallUint16(buf[0:2])
|
||||
|
||||
// Field (1) 'ValueAfter'
|
||||
copy(e.ValueAfter[:], buf[2:34])
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
// SizeSSZ returns the ssz encoded size in bytes for the encodingStorageWrite object
|
||||
func (e *encodingStorageWrite) SizeSSZ() (size int) {
|
||||
size = 34
|
||||
return
|
||||
}
|
||||
|
||||
// HashTreeRoot ssz hashes the encodingStorageWrite object
|
||||
func (e *encodingStorageWrite) HashTreeRoot() ([32]byte, error) {
|
||||
return ssz.HashWithDefaultHasher(e)
|
||||
}
|
||||
|
||||
// HashTreeRootWith ssz hashes the encodingStorageWrite object with a hasher
|
||||
func (e *encodingStorageWrite) HashTreeRootWith(hh ssz.HashWalker) (err error) {
|
||||
indx := hh.Index()
|
||||
|
||||
// Field (0) 'TxIdx'
|
||||
hh.PutUint16(e.TxIdx)
|
||||
|
||||
// Field (1) 'ValueAfter'
|
||||
hh.PutBytes(e.ValueAfter[:])
|
||||
|
||||
hh.Merkleize(indx)
|
||||
return
|
||||
}
|
||||
|
||||
// GetTree ssz hashes the encodingStorageWrite object
|
||||
func (e *encodingStorageWrite) GetTree() (*ssz.Node, error) {
|
||||
return ssz.ProofTree(e)
|
||||
}
|
||||
|
||||
// MarshalSSZ ssz marshals the encodingSlotWrites object
|
||||
func (e *encodingSlotWrites) MarshalSSZ() ([]byte, error) {
|
||||
return ssz.MarshalSSZ(e)
|
||||
}
|
||||
|
||||
// MarshalSSZTo ssz marshals the encodingSlotWrites object to a target array
|
||||
func (e *encodingSlotWrites) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
||||
dst = buf
|
||||
offset := int(36)
|
||||
|
||||
// Field (0) 'Slot'
|
||||
dst = append(dst, e.Slot[:]...)
|
||||
|
||||
// Offset (1) 'Accesses'
|
||||
dst = ssz.WriteOffset(dst, offset)
|
||||
|
||||
// Field (1) 'Accesses'
|
||||
if size := len(e.Accesses); size > 300000 {
|
||||
err = ssz.ErrListTooBigFn("encodingSlotWrites.Accesses", size, 300000)
|
||||
return
|
||||
}
|
||||
for ii := 0; ii < len(e.Accesses); ii++ {
|
||||
if dst, err = e.Accesses[ii].MarshalSSZTo(dst); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// UnmarshalSSZ ssz unmarshals the encodingSlotWrites object
|
||||
func (e *encodingSlotWrites) UnmarshalSSZ(buf []byte) error {
|
||||
var err error
|
||||
size := uint64(len(buf))
|
||||
if size < 36 {
|
||||
return ssz.ErrSize
|
||||
}
|
||||
|
||||
tail := buf
|
||||
var o1 uint64
|
||||
|
||||
// Field (0) 'Slot'
|
||||
copy(e.Slot[:], buf[0:32])
|
||||
|
||||
// Offset (1) 'Accesses'
|
||||
if o1 = ssz.ReadOffset(buf[32:36]); o1 > size {
|
||||
return ssz.ErrOffset
|
||||
}
|
||||
|
||||
if o1 != 36 {
|
||||
return ssz.ErrInvalidVariableOffset
|
||||
}
|
||||
|
||||
// Field (1) 'Accesses'
|
||||
{
|
||||
buf = tail[o1:]
|
||||
num, err := ssz.DivideInt2(len(buf), 34, 300000)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
e.Accesses = make([]encodingStorageWrite, num)
|
||||
for ii := 0; ii < num; ii++ {
|
||||
if err = e.Accesses[ii].UnmarshalSSZ(buf[ii*34 : (ii+1)*34]); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
// SizeSSZ returns the ssz encoded size in bytes for the encodingSlotWrites object
|
||||
func (e *encodingSlotWrites) SizeSSZ() (size int) {
|
||||
size = 36
|
||||
|
||||
// Field (1) 'Accesses'
|
||||
size += len(e.Accesses) * 34
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// HashTreeRoot ssz hashes the encodingSlotWrites object
|
||||
func (e *encodingSlotWrites) HashTreeRoot() ([32]byte, error) {
|
||||
return ssz.HashWithDefaultHasher(e)
|
||||
}
|
||||
|
||||
// HashTreeRootWith ssz hashes the encodingSlotWrites object with a hasher
|
||||
func (e *encodingSlotWrites) HashTreeRootWith(hh ssz.HashWalker) (err error) {
|
||||
indx := hh.Index()
|
||||
|
||||
// Field (0) 'Slot'
|
||||
hh.PutBytes(e.Slot[:])
|
||||
|
||||
// Field (1) 'Accesses'
|
||||
{
|
||||
subIndx := hh.Index()
|
||||
num := uint64(len(e.Accesses))
|
||||
if num > 300000 {
|
||||
err = ssz.ErrIncorrectListSize
|
||||
return
|
||||
}
|
||||
for _, elem := range e.Accesses {
|
||||
if err = elem.HashTreeRootWith(hh); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
hh.MerkleizeWithMixin(subIndx, num, 300000)
|
||||
}
|
||||
|
||||
hh.Merkleize(indx)
|
||||
return
|
||||
}
|
||||
|
||||
// GetTree ssz hashes the encodingSlotWrites object
|
||||
func (e *encodingSlotWrites) GetTree() (*ssz.Node, error) {
|
||||
return ssz.ProofTree(e)
|
||||
}
|
||||
|
||||
// MarshalSSZ ssz marshals the AccountAccess object
|
||||
func (e *AccountAccess) MarshalSSZ() ([]byte, error) {
|
||||
return ssz.MarshalSSZ(e)
|
||||
}
|
||||
|
||||
// MarshalSSZTo ssz marshals the AccountAccess object to a target array
|
||||
func (e *AccountAccess) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
||||
dst = buf
|
||||
offset := int(40)
|
||||
|
||||
// Field (0) 'Address'
|
||||
dst = append(dst, e.Address[:]...)
|
||||
|
||||
// Offset (1) 'StorageWrites'
|
||||
dst = ssz.WriteOffset(dst, offset)
|
||||
for ii := 0; ii < len(e.StorageWrites); ii++ {
|
||||
offset += 4
|
||||
offset += e.StorageWrites[ii].SizeSSZ()
|
||||
}
|
||||
|
||||
// Offset (2) 'StorageReads'
|
||||
dst = ssz.WriteOffset(dst, offset)
|
||||
offset += len(e.StorageReads) * 32
|
||||
|
||||
// Offset (3) 'BalanceChanges'
|
||||
dst = ssz.WriteOffset(dst, offset)
|
||||
offset += len(e.BalanceChanges) * 18
|
||||
|
||||
// Offset (4) 'NonceChanges'
|
||||
dst = ssz.WriteOffset(dst, offset)
|
||||
offset += len(e.NonceChanges) * 10
|
||||
|
||||
// Offset (5) 'Code'
|
||||
dst = ssz.WriteOffset(dst, offset)
|
||||
|
||||
// Field (1) 'StorageWrites'
|
||||
if size := len(e.StorageWrites); size > 300000 {
|
||||
err = ssz.ErrListTooBigFn("AccountAccess.StorageWrites", size, 300000)
|
||||
return
|
||||
}
|
||||
{
|
||||
offset = 4 * len(e.StorageWrites)
|
||||
for ii := 0; ii < len(e.StorageWrites); ii++ {
|
||||
dst = ssz.WriteOffset(dst, offset)
|
||||
offset += e.StorageWrites[ii].SizeSSZ()
|
||||
}
|
||||
}
|
||||
for ii := 0; ii < len(e.StorageWrites); ii++ {
|
||||
if dst, err = e.StorageWrites[ii].MarshalSSZTo(dst); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// Field (2) 'StorageReads'
|
||||
if size := len(e.StorageReads); size > 300000 {
|
||||
err = ssz.ErrListTooBigFn("AccountAccess.StorageReads", size, 300000)
|
||||
return
|
||||
}
|
||||
for ii := 0; ii < len(e.StorageReads); ii++ {
|
||||
dst = append(dst, e.StorageReads[ii][:]...)
|
||||
}
|
||||
|
||||
// Field (3) 'BalanceChanges'
|
||||
if size := len(e.BalanceChanges); size > 300000 {
|
||||
err = ssz.ErrListTooBigFn("AccountAccess.BalanceChanges", size, 300000)
|
||||
return
|
||||
}
|
||||
for ii := 0; ii < len(e.BalanceChanges); ii++ {
|
||||
if dst, err = e.BalanceChanges[ii].MarshalSSZTo(dst); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// Field (4) 'NonceChanges'
|
||||
if size := len(e.NonceChanges); size > 300000 {
|
||||
err = ssz.ErrListTooBigFn("AccountAccess.NonceChanges", size, 300000)
|
||||
return
|
||||
}
|
||||
for ii := 0; ii < len(e.NonceChanges); ii++ {
|
||||
if dst, err = e.NonceChanges[ii].MarshalSSZTo(dst); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// Field (5) 'Code'
|
||||
if size := len(e.Code); size > 1 {
|
||||
err = ssz.ErrListTooBigFn("AccountAccess.Code", size, 1)
|
||||
return
|
||||
}
|
||||
{
|
||||
offset = 4 * len(e.Code)
|
||||
for ii := 0; ii < len(e.Code); ii++ {
|
||||
dst = ssz.WriteOffset(dst, offset)
|
||||
offset += e.Code[ii].SizeSSZ()
|
||||
}
|
||||
}
|
||||
for ii := 0; ii < len(e.Code); ii++ {
|
||||
if dst, err = e.Code[ii].MarshalSSZTo(dst); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// UnmarshalSSZ ssz unmarshals the AccountAccess object
|
||||
func (e *AccountAccess) UnmarshalSSZ(buf []byte) error {
|
||||
var err error
|
||||
size := uint64(len(buf))
|
||||
if size < 40 {
|
||||
return ssz.ErrSize
|
||||
}
|
||||
|
||||
tail := buf
|
||||
var o1, o2, o3, o4, o5 uint64
|
||||
|
||||
// Field (0) 'Address'
|
||||
copy(e.Address[:], buf[0:20])
|
||||
|
||||
// Offset (1) 'StorageWrites'
|
||||
if o1 = ssz.ReadOffset(buf[20:24]); o1 > size {
|
||||
return ssz.ErrOffset
|
||||
}
|
||||
|
||||
if o1 != 40 {
|
||||
return ssz.ErrInvalidVariableOffset
|
||||
}
|
||||
|
||||
// Offset (2) 'StorageReads'
|
||||
if o2 = ssz.ReadOffset(buf[24:28]); o2 > size || o1 > o2 {
|
||||
return ssz.ErrOffset
|
||||
}
|
||||
|
||||
// Offset (3) 'BalanceChanges'
|
||||
if o3 = ssz.ReadOffset(buf[28:32]); o3 > size || o2 > o3 {
|
||||
return ssz.ErrOffset
|
||||
}
|
||||
|
||||
// Offset (4) 'NonceChanges'
|
||||
if o4 = ssz.ReadOffset(buf[32:36]); o4 > size || o3 > o4 {
|
||||
return ssz.ErrOffset
|
||||
}
|
||||
|
||||
// Offset (5) 'Code'
|
||||
if o5 = ssz.ReadOffset(buf[36:40]); o5 > size || o4 > o5 {
|
||||
return ssz.ErrOffset
|
||||
}
|
||||
|
||||
// Field (1) 'StorageWrites'
|
||||
{
|
||||
buf = tail[o1:o2]
|
||||
num, err := ssz.DecodeDynamicLength(buf, 300000)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
e.StorageWrites = make([]encodingSlotWrites, num)
|
||||
err = ssz.UnmarshalDynamic(buf, num, func(indx int, buf []byte) (err error) {
|
||||
if err = e.StorageWrites[indx].UnmarshalSSZ(buf); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// Field (2) 'StorageReads'
|
||||
{
|
||||
buf = tail[o2:o3]
|
||||
num, err := ssz.DivideInt2(len(buf), 32, 300000)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
e.StorageReads = make([][32]byte, num)
|
||||
for ii := 0; ii < num; ii++ {
|
||||
copy(e.StorageReads[ii][:], buf[ii*32:(ii+1)*32])
|
||||
}
|
||||
}
|
||||
|
||||
// Field (3) 'BalanceChanges'
|
||||
{
|
||||
buf = tail[o3:o4]
|
||||
num, err := ssz.DivideInt2(len(buf), 18, 300000)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
e.BalanceChanges = make([]encodingBalanceChange, num)
|
||||
for ii := 0; ii < num; ii++ {
|
||||
if err = e.BalanceChanges[ii].UnmarshalSSZ(buf[ii*18 : (ii+1)*18]); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Field (4) 'NonceChanges'
|
||||
{
|
||||
buf = tail[o4:o5]
|
||||
num, err := ssz.DivideInt2(len(buf), 10, 300000)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
e.NonceChanges = make([]encodingAccountNonce, num)
|
||||
for ii := 0; ii < num; ii++ {
|
||||
if err = e.NonceChanges[ii].UnmarshalSSZ(buf[ii*10 : (ii+1)*10]); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Field (5) 'Code'
|
||||
{
|
||||
buf = tail[o5:]
|
||||
num, err := ssz.DecodeDynamicLength(buf, 1)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
e.Code = make([]encodingCodeChange, num)
|
||||
err = ssz.UnmarshalDynamic(buf, num, func(indx int, buf []byte) (err error) {
|
||||
if err = e.Code[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 AccountAccess object
|
||||
func (e *AccountAccess) SizeSSZ() (size int) {
|
||||
size = 40
|
||||
|
||||
// Field (1) 'StorageWrites'
|
||||
for ii := 0; ii < len(e.StorageWrites); ii++ {
|
||||
size += 4
|
||||
size += e.StorageWrites[ii].SizeSSZ()
|
||||
}
|
||||
|
||||
// Field (2) 'StorageReads'
|
||||
size += len(e.StorageReads) * 32
|
||||
|
||||
// Field (3) 'BalanceChanges'
|
||||
size += len(e.BalanceChanges) * 18
|
||||
|
||||
// Field (4) 'NonceChanges'
|
||||
size += len(e.NonceChanges) * 10
|
||||
|
||||
// Field (5) 'Code'
|
||||
for ii := 0; ii < len(e.Code); ii++ {
|
||||
size += 4
|
||||
size += e.Code[ii].SizeSSZ()
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// HashTreeRoot ssz hashes the AccountAccess object
|
||||
func (e *AccountAccess) HashTreeRoot() ([32]byte, error) {
|
||||
return ssz.HashWithDefaultHasher(e)
|
||||
}
|
||||
|
||||
// HashTreeRootWith ssz hashes the AccountAccess object with a hasher
|
||||
func (e *AccountAccess) HashTreeRootWith(hh ssz.HashWalker) (err error) {
|
||||
indx := hh.Index()
|
||||
|
||||
// Field (0) 'Address'
|
||||
hh.PutBytes(e.Address[:])
|
||||
|
||||
// Field (1) 'StorageWrites'
|
||||
{
|
||||
subIndx := hh.Index()
|
||||
num := uint64(len(e.StorageWrites))
|
||||
if num > 300000 {
|
||||
err = ssz.ErrIncorrectListSize
|
||||
return
|
||||
}
|
||||
for _, elem := range e.StorageWrites {
|
||||
if err = elem.HashTreeRootWith(hh); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
hh.MerkleizeWithMixin(subIndx, num, 300000)
|
||||
}
|
||||
|
||||
// Field (2) 'StorageReads'
|
||||
{
|
||||
if size := len(e.StorageReads); size > 300000 {
|
||||
err = ssz.ErrListTooBigFn("AccountAccess.StorageReads", size, 300000)
|
||||
return
|
||||
}
|
||||
subIndx := hh.Index()
|
||||
for _, i := range e.StorageReads {
|
||||
hh.Append(i[:])
|
||||
}
|
||||
numItems := uint64(len(e.StorageReads))
|
||||
hh.MerkleizeWithMixin(subIndx, numItems, 300000)
|
||||
}
|
||||
|
||||
// Field (3) 'BalanceChanges'
|
||||
{
|
||||
subIndx := hh.Index()
|
||||
num := uint64(len(e.BalanceChanges))
|
||||
if num > 300000 {
|
||||
err = ssz.ErrIncorrectListSize
|
||||
return
|
||||
}
|
||||
for _, elem := range e.BalanceChanges {
|
||||
if err = elem.HashTreeRootWith(hh); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
hh.MerkleizeWithMixin(subIndx, num, 300000)
|
||||
}
|
||||
|
||||
// Field (4) 'NonceChanges'
|
||||
{
|
||||
subIndx := hh.Index()
|
||||
num := uint64(len(e.NonceChanges))
|
||||
if num > 300000 {
|
||||
err = ssz.ErrIncorrectListSize
|
||||
return
|
||||
}
|
||||
for _, elem := range e.NonceChanges {
|
||||
if err = elem.HashTreeRootWith(hh); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
hh.MerkleizeWithMixin(subIndx, num, 300000)
|
||||
}
|
||||
|
||||
// Field (5) 'Code'
|
||||
{
|
||||
subIndx := hh.Index()
|
||||
num := uint64(len(e.Code))
|
||||
if num > 1 {
|
||||
err = ssz.ErrIncorrectListSize
|
||||
return
|
||||
}
|
||||
for _, elem := range e.Code {
|
||||
if err = elem.HashTreeRootWith(hh); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
hh.MerkleizeWithMixin(subIndx, num, 1)
|
||||
}
|
||||
|
||||
hh.Merkleize(indx)
|
||||
return
|
||||
}
|
||||
|
||||
// GetTree ssz hashes the AccountAccess object
|
||||
func (e *AccountAccess) GetTree() (*ssz.Node, error) {
|
||||
return ssz.ProofTree(e)
|
||||
}
|
||||
Loading…
Reference in a new issue