diff --git a/core/types/bal/bal.go b/core/types/bal/bal.go index 711f15b857..d8593550eb 100644 --- a/core/types/bal/bal.go +++ b/core/types/bal/bal.go @@ -31,9 +31,10 @@ type CodeChange struct { Code []byte `json:"code,omitempty"` } -// AccountAccess contains post-block account state for mutations as well as -// all storage keys that were read during execution. -type AccountAccess struct { +// ConstructionAccountAccess contains post-block account state for mutations as well as +// all storage keys that were read during execution. It is used when building block +// access list during execution. +type ConstructionAccountAccess struct { // StorageWrites is the post-state values of an account's storage slots // that were modified in a block, keyed by the slot key and the tx index // where the modification occurred. @@ -59,9 +60,9 @@ type AccountAccess struct { CodeChange *CodeChange `json:"codeChange,omitempty"` } -// NewAccountAccess initializes the account access object. -func NewAccountAccess() *AccountAccess { - return &AccountAccess{ +// NewConstructionAccountAccess initializes the account access object. +func NewConstructionAccountAccess() *ConstructionAccountAccess { + return &ConstructionAccountAccess{ StorageWrites: make(map[common.Hash]map[uint16]common.Hash), StorageReads: make(map[common.Hash]struct{}), BalanceChanges: make(map[uint16]*uint256.Int), @@ -69,30 +70,30 @@ func NewAccountAccess() *AccountAccess { } } -// BlockAccessList contains post-block modified state and some state accessed +// ConstructionBlockAccessList contains post-block modified state and some state accessed // in execution (account addresses and storage keys). -type BlockAccessList struct { - Accounts map[common.Address]*AccountAccess +type ConstructionBlockAccessList struct { + Accounts map[common.Address]*ConstructionAccountAccess } // NewBlockAccessList instantiates an empty access list. -func NewBlockAccessList() BlockAccessList { - return BlockAccessList{ - Accounts: make(map[common.Address]*AccountAccess), +func NewBlockAccessList() ConstructionBlockAccessList { + return ConstructionBlockAccessList{ + Accounts: make(map[common.Address]*ConstructionAccountAccess), } } // AccountRead records the address of an account that has been read during execution. -func (b *BlockAccessList) AccountRead(addr common.Address) { +func (b *ConstructionBlockAccessList) AccountRead(addr common.Address) { if _, ok := b.Accounts[addr]; !ok { - b.Accounts[addr] = NewAccountAccess() + b.Accounts[addr] = NewConstructionAccountAccess() } } // StorageRead records a storage key read during execution. -func (b *BlockAccessList) StorageRead(address common.Address, key common.Hash) { +func (b *ConstructionBlockAccessList) StorageRead(address common.Address, key common.Hash) { if _, ok := b.Accounts[address]; !ok { - b.Accounts[address] = NewAccountAccess() + b.Accounts[address] = NewConstructionAccountAccess() } if _, ok := b.Accounts[address].StorageWrites[key]; ok { return @@ -102,9 +103,9 @@ func (b *BlockAccessList) StorageRead(address common.Address, key common.Hash) { // StorageWrite records the post-transaction value of a mutated storage slot. // The storage slot is removed from the list of read slots. -func (b *BlockAccessList) StorageWrite(txIdx uint16, address common.Address, key, value common.Hash) { +func (b *ConstructionBlockAccessList) StorageWrite(txIdx uint16, address common.Address, key, value common.Hash) { if _, ok := b.Accounts[address]; !ok { - b.Accounts[address] = NewAccountAccess() + b.Accounts[address] = NewConstructionAccountAccess() } if _, ok := b.Accounts[address].StorageWrites[key]; !ok { b.Accounts[address].StorageWrites[key] = make(map[uint16]common.Hash) @@ -115,9 +116,9 @@ func (b *BlockAccessList) StorageWrite(txIdx uint16, address common.Address, key } // CodeChange records the code of a newly-created contract. -func (b *BlockAccessList) CodeChange(address common.Address, txIndex uint16, code []byte) { +func (b *ConstructionBlockAccessList) CodeChange(address common.Address, txIndex uint16, code []byte) { if _, ok := b.Accounts[address]; !ok { - b.Accounts[address] = NewAccountAccess() + b.Accounts[address] = NewConstructionAccountAccess() } b.Accounts[address].CodeChange = &CodeChange{ TxIndex: txIndex, @@ -127,30 +128,30 @@ func (b *BlockAccessList) CodeChange(address common.Address, txIndex uint16, cod // NonceChange records tx post-state nonce of any contract-like accounts whose // nonce was incremented. -func (b *BlockAccessList) NonceChange(address common.Address, txIdx uint16, postNonce uint64) { +func (b *ConstructionBlockAccessList) NonceChange(address common.Address, txIdx uint16, postNonce uint64) { if _, ok := b.Accounts[address]; !ok { - b.Accounts[address] = NewAccountAccess() + b.Accounts[address] = NewConstructionAccountAccess() } b.Accounts[address].NonceChanges[txIdx] = postNonce } // BalanceChange records the post-transaction balance of an account whose // balance changed. -func (b *BlockAccessList) BalanceChange(txIdx uint16, address common.Address, balance *uint256.Int) { +func (b *ConstructionBlockAccessList) BalanceChange(txIdx uint16, address common.Address, balance *uint256.Int) { if _, ok := b.Accounts[address]; !ok { - b.Accounts[address] = NewAccountAccess() + b.Accounts[address] = NewConstructionAccountAccess() } b.Accounts[address].BalanceChanges[txIdx] = balance.Clone() } // PrettyPrint returns a human-readable representation of the access list -func (b *BlockAccessList) PrettyPrint() string { +func (b *ConstructionBlockAccessList) PrettyPrint() string { enc := b.toEncodingObj() - return enc.prettyPrint() + return enc.PrettyPrint() } // Hash computes the SSZ hash of the access list -func (b *BlockAccessList) Hash() common.Hash { +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 @@ -162,10 +163,10 @@ func (b *BlockAccessList) Hash() common.Hash { } // Copy returns a deep copy of the access list. -func (b *BlockAccessList) Copy() *BlockAccessList { +func (b *ConstructionBlockAccessList) Copy() *ConstructionBlockAccessList { res := NewBlockAccessList() for addr, aa := range b.Accounts { - var aaCopy AccountAccess + var aaCopy ConstructionAccountAccess slotWrites := make(map[common.Hash]map[uint16]common.Hash, len(aa.StorageWrites)) for key, m := range aa.StorageWrites { diff --git a/core/types/bal/bal_encoding.go b/core/types/bal/bal_encoding.go index 870f33d7a7..130b4176e9 100644 --- a/core/types/bal/bal_encoding.go +++ b/core/types/bal/bal_encoding.go @@ -20,6 +20,7 @@ import ( "bytes" "cmp" "fmt" + "github.com/ethereum/go-ethereum/params" "io" "maps" "slices" @@ -36,39 +37,30 @@ import ( // These are objects used as input for the access list encoding. They mirror // the spec format. -// encodingBlockAccessList is the encoding format of BlockAccessList. -type encodingBlockAccessList struct { - Accesses []encodingAccountAccess `ssz-max:"300000"` +// BlockAccessList is the encoding format of ConstructionBlockAccessList. +type BlockAccessList struct { + Accesses []AccountAccess `ssz-max:"300000"` } -// toBlockAccessList converts out of the encoding format, returning an error if -// values in the encoder object are not properly ordered according to the spec. -func (e *encodingBlockAccessList) toBlockAccessList() (*BlockAccessList, error) { +// 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 { var ( - obj = NewBlockAccessList() prev *[20]byte ) for _, entry := range e.Accesses { if prev != nil { if bytes.Compare(entry.Address[:], (*prev)[:]) <= 0 { - return nil, fmt.Errorf("block access list accounts not in lexicographic order") + return fmt.Errorf("block access list accounts not in lexicographic order") } } - prev = &entry.Address - - aa, err := entry.toAccountAccess() - if err != nil { - return nil, err + if err := entry.validate(); err != nil { + return err } - obj.Accounts[entry.Address] = aa + prev = &entry.Address } - return &obj, nil -} - -// encodingCodeChange is the encoding format of CodeChange. -type encodingCodeChange struct { - TxIndex uint16 - Code []byte `ssz-max:"24576"` + return nil } // encodeBalance encodes the provided balance into 16-bytes. @@ -106,62 +98,48 @@ type encodingSlotWrites struct { Accesses []encodingStorageWrite `ssz-max:"300000"` } -// toSlotWrites returns an instance of the encoding-representation slot writes in +// validate returns an instance of the encoding-representation slot writes in // working representation. -func (e *encodingSlotWrites) toSlotWrites() (map[uint16]common.Hash, error) { - var ( - prev *uint16 - obj = make(map[uint16]common.Hash) - ) +func (e *encodingSlotWrites) validate() error { + var prev *uint16 for _, write := range e.Accesses { if prev != nil { if *prev >= write.TxIdx { - return nil, fmt.Errorf("storage write tx indices not in order") + return fmt.Errorf("storage write tx indices not in order") } } prev = &write.TxIdx - obj[write.TxIdx] = write.ValueAfter } - return obj, nil + return nil } -// encodingAccountAccess is the encoding format of AccountAccess. -type encodingAccountAccess struct { +// AccountAccess is the encoding format of ConstructionAccountAccess. +type AccountAccess struct { Address [20]byte `ssz-size:"20"` // 20-byte Ethereum address StorageWrites []encodingSlotWrites `ssz-max:"300000"` // Storage changes (slot -> [tx_index -> new_value]) StorageReads [][32]byte `ssz-max:"300000"` // Read-only storage keys BalanceChanges []encodingBalanceChange `ssz-max:"300000"` // Balance changes ([tx_index -> post_balance]) NonceChanges []encodingAccountNonce `ssz-max:"300000"` // Nonce changes ([tx_index -> new_nonce]) - Code []encodingCodeChange `ssz-max:"1"` // Code changes ([tx_index -> new_code]) + Code []CodeChange `ssz-max:"1"` // Code changes ([tx_index -> new_code]) } -// toAccountAccess converts the account accesses out of encoding format. +// validate converts the account accesses out of encoding format. // If any of the keys in the encoding object are not ordered according to the // spec, an error is returned. -func (e *encodingAccountAccess) toAccountAccess() (*AccountAccess, error) { - res := AccountAccess{ - StorageWrites: make(map[common.Hash]map[uint16]common.Hash), - StorageReads: make(map[common.Hash]struct{}), - BalanceChanges: make(map[uint16]*uint256.Int), - NonceChanges: make(map[uint16]uint64), - CodeChange: nil, - } - +func (e *AccountAccess) validate() error { // Convert slot writes var prevSlotWrite *[32]byte for _, write := range e.StorageWrites { if prevSlotWrite != nil { if bytes.Compare((*prevSlotWrite)[:], write.Slot[:]) >= 0 { - return nil, fmt.Errorf("storage writes slots not in lexicographic order") + return fmt.Errorf("storage writes slots not in lexicographic order") } } prevSlotWrite = &write.Slot - wr, err := write.toSlotWrites() - if err != nil { - return nil, err + if err := write.validate(); err != nil { + return err } - res.StorageWrites[write.Slot] = wr } // Convert slot reads @@ -169,11 +147,10 @@ func (e *encodingAccountAccess) toAccountAccess() (*AccountAccess, error) { for _, read := range e.StorageReads { if prevSlotRead != nil { if bytes.Compare((*prevSlotRead)[:], read[:]) >= 0 { - return nil, fmt.Errorf("storage read slots not in lexicographic order") + return fmt.Errorf("storage read slots not in lexicographic order") } } prevSlotRead = &read - res.StorageReads[read] = struct{}{} } // Convert balance changes @@ -181,11 +158,10 @@ func (e *encodingAccountAccess) toAccountAccess() (*AccountAccess, error) { for _, balanceChange := range e.BalanceChanges { if prevBalanceIndex != nil { if *prevBalanceIndex >= balanceChange.TxIdx { - return nil, fmt.Errorf("balance changes not in ascending order by tx index") + return fmt.Errorf("balance changes not in ascending order by tx index") } } prevBalanceIndex = &balanceChange.TxIdx - res.BalanceChanges[balanceChange.TxIdx] = new(uint256.Int).SetBytes(balanceChange.Balance[:]) } // Convert nonce changes @@ -193,25 +169,23 @@ func (e *encodingAccountAccess) toAccountAccess() (*AccountAccess, error) { for _, nonceChange := range e.NonceChanges { if prevNonceIndex != nil { if *prevNonceIndex >= nonceChange.TxIdx { - return nil, fmt.Errorf("nonce diffs not in ascending order by tx index") + return fmt.Errorf("nonce diffs not in ascending order by tx index") } } prevNonceIndex = &nonceChange.TxIdx - res.NonceChanges[nonceChange.TxIdx] = nonceChange.Nonce } // Convert code change if len(e.Code) == 1 { - res.CodeChange = &CodeChange{ - TxIndex: e.Code[0].TxIndex, - Code: bytes.Clone(e.Code[0].Code), + if len(e.Code[0].Code) > params.MaxCodeSize { + return fmt.Errorf("code change contained oversized code") } } - return &res, nil + return nil } // EncodeRLP returns the SSZ-encoded access list wrapped into RLP bytes. -func (b *BlockAccessList) EncodeRLP(wr io.Writer) error { +func (b *ConstructionBlockAccessList) EncodeRLP(wr io.Writer) error { w := rlp.NewEncoderBuffer(wr) buf, err := b.encodeSSZ() if err != nil { @@ -222,7 +196,7 @@ func (b *BlockAccessList) EncodeRLP(wr io.Writer) error { } // DecodeRLP decodes the bloc accessList. -func (b *BlockAccessList) DecodeRLP(s *rlp.Stream) error { +func (b *BlockAccessList) DecodeSSZRLP(s *rlp.Stream) error { encBytes, err := s.Bytes() if err != nil { return err @@ -231,31 +205,29 @@ func (b *BlockAccessList) DecodeRLP(s *rlp.Stream) error { } // EncodeFullRLP returns the RLP-encoded access list wrapped into RLP bytes. -func (b *BlockAccessList) EncodeFullRLP(wr io.Writer) error { +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 encodingBlockAccessList + var obj BlockAccessList if err := obj.DecodeRLP(s); err != nil { return err } - al, err := obj.toBlockAccessList() - if err != nil { + if err := obj.validate(); err != nil { return err } - *b = *al + *b = obj return nil } -var _ rlp.Encoder = &BlockAccessList{} -var _ rlp.Decoder = &BlockAccessList{} +var _ rlp.Encoder = &ConstructionBlockAccessList{} -// toEncodingObj creates an instance of the AccountAccess of the type that is +// toEncodingObj creates an instance of the ConstructionAccountAccess of the type that is // used as input for the encoding. -func (a *AccountAccess) toEncodingObj(addr common.Address) encodingAccountAccess { - res := encodingAccountAccess{ +func (a *ConstructionAccountAccess) toEncodingObj(addr common.Address) AccountAccess { + res := AccountAccess{ Address: addr, StorageWrites: make([]encodingSlotWrites, 0), StorageReads: make([][32]byte, 0), @@ -314,7 +286,7 @@ func (a *AccountAccess) toEncodingObj(addr common.Address) encodingAccountAccess // Convert code change if a.CodeChange != nil { - res.Code = []encodingCodeChange{ + res.Code = []CodeChange{ { a.CodeChange.TxIndex, bytes.Clone(a.CodeChange.Code), @@ -326,21 +298,21 @@ func (a *AccountAccess) toEncodingObj(addr common.Address) encodingAccountAccess // toEncodingObj returns an instance of the access list expressed as the type // which is used as input for the encoding/decoding. -func (b *BlockAccessList) toEncodingObj() *encodingBlockAccessList { +func (b *ConstructionBlockAccessList) toEncodingObj() *BlockAccessList { var addresses []common.Address for addr := range b.Accounts { addresses = append(addresses, addr) } slices.SortFunc(addresses, common.Address.Cmp) - var res encodingBlockAccessList + var res BlockAccessList for _, addr := range addresses { res.Accesses = append(res.Accesses, b.Accounts[addr].toEncodingObj(addr)) } return &res } -func (b *BlockAccessList) encodeSSZ() ([]byte, error) { +func (b *ConstructionBlockAccessList) encodeSSZ() ([]byte, error) { encoderObj := b.toEncodingObj() dst, err := encoderObj.MarshalSSZTo(nil) if err != nil { @@ -350,19 +322,16 @@ func (b *BlockAccessList) encodeSSZ() ([]byte, error) { } func (b *BlockAccessList) decodeSSZ(buf []byte) error { - var enc encodingBlockAccessList - if err := enc.UnmarshalSSZ(buf); err != nil { + if err := b.UnmarshalSSZ(buf); err != nil { return err } - res, err := enc.toBlockAccessList() - if err != nil { + if err := b.validate(); err != nil { return err } - *b = *res return nil } -func (e *encodingBlockAccessList) prettyPrint() string { +func (e *BlockAccessList) PrettyPrint() string { var res bytes.Buffer printWithIndent := func(indent int, text string) { fmt.Fprintf(&res, "%s%s\n", strings.Repeat(" ", indent), text) diff --git a/core/types/bal/bal_encoding_rlp_generated.go b/core/types/bal/bal_encoding_rlp_generated.go index e595532801..a461d60bc0 100644 --- a/core/types/bal/bal_encoding_rlp_generated.go +++ b/core/types/bal/bal_encoding_rlp_generated.go @@ -5,7 +5,7 @@ package bal import "github.com/ethereum/go-ethereum/rlp" import "io" -func (obj *encodingBlockAccessList) EncodeRLP(_w io.Writer) error { +func (obj *BlockAccessList) EncodeRLP(_w io.Writer) error { w := rlp.NewEncoderBuffer(_w) _tmp0 := w.List() _tmp1 := w.List() @@ -63,19 +63,19 @@ func (obj *encodingBlockAccessList) EncodeRLP(_w io.Writer) error { return w.Flush() } -func (obj *encodingBlockAccessList) DecodeRLP(dec *rlp.Stream) error { - var _tmp0 encodingBlockAccessList +func (obj *BlockAccessList) DecodeRLP(dec *rlp.Stream) error { + var _tmp0 BlockAccessList { if _, err := dec.List(); err != nil { return err } // Accesses: - var _tmp1 []encodingAccountAccess + var _tmp1 []AccountAccess if _, err := dec.List(); err != nil { return err } for dec.MoreDataInList() { - var _tmp2 encodingAccountAccess + var _tmp2 AccountAccess { if _, err := dec.List(); err != nil { return err diff --git a/core/types/bal/bal_encoding_ssz_generated.go b/core/types/bal/bal_encoding_ssz_generated.go index b74075244b..188190aa2d 100644 --- a/core/types/bal/bal_encoding_ssz_generated.go +++ b/core/types/bal/bal_encoding_ssz_generated.go @@ -7,13 +7,13 @@ import ( ssz "github.com/ferranbt/fastssz" ) -// MarshalSSZ ssz marshals the encodingBlockAccessList object -func (e *encodingBlockAccessList) MarshalSSZ() ([]byte, error) { +// MarshalSSZ ssz marshals the BlockAccessList object +func (e *BlockAccessList) MarshalSSZ() ([]byte, error) { return ssz.MarshalSSZ(e) } -// MarshalSSZTo ssz marshals the encodingBlockAccessList object to a target array -func (e *encodingBlockAccessList) MarshalSSZTo(buf []byte) (dst []byte, err error) { +// 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) @@ -22,7 +22,7 @@ func (e *encodingBlockAccessList) MarshalSSZTo(buf []byte) (dst []byte, err erro // Field (0) 'Accesses' if size := len(e.Accesses); size > 300000 { - err = ssz.ErrListTooBigFn("encodingBlockAccessList.Accesses", size, 300000) + err = ssz.ErrListTooBigFn("BlockAccessList.Accesses", size, 300000) return } { @@ -41,8 +41,8 @@ func (e *encodingBlockAccessList) MarshalSSZTo(buf []byte) (dst []byte, err erro return } -// UnmarshalSSZ ssz unmarshals the encodingBlockAccessList object -func (e *encodingBlockAccessList) UnmarshalSSZ(buf []byte) error { +// UnmarshalSSZ ssz unmarshals the BlockAccessList object +func (e *BlockAccessList) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size < 4 { @@ -68,7 +68,7 @@ func (e *encodingBlockAccessList) UnmarshalSSZ(buf []byte) error { if err != nil { return err } - e.Accesses = make([]encodingAccountAccess, num) + 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 @@ -82,8 +82,8 @@ func (e *encodingBlockAccessList) UnmarshalSSZ(buf []byte) error { return err } -// SizeSSZ returns the ssz encoded size in bytes for the encodingBlockAccessList object -func (e *encodingBlockAccessList) SizeSSZ() (size int) { +// SizeSSZ returns the ssz encoded size in bytes for the BlockAccessList object +func (e *BlockAccessList) SizeSSZ() (size int) { size = 4 // Field (0) 'Accesses' @@ -95,13 +95,13 @@ func (e *encodingBlockAccessList) SizeSSZ() (size int) { return } -// HashTreeRoot ssz hashes the encodingBlockAccessList object -func (e *encodingBlockAccessList) HashTreeRoot() ([32]byte, error) { +// HashTreeRoot ssz hashes the BlockAccessList object +func (e *BlockAccessList) HashTreeRoot() ([32]byte, error) { return ssz.HashWithDefaultHasher(e) } -// HashTreeRootWith ssz hashes the encodingBlockAccessList object with a hasher -func (e *encodingBlockAccessList) HashTreeRootWith(hh ssz.HashWalker) (err error) { +// HashTreeRootWith ssz hashes the BlockAccessList object with a hasher +func (e *BlockAccessList) HashTreeRootWith(hh ssz.HashWalker) (err error) { indx := hh.Index() // Field (0) 'Accesses' @@ -124,8 +124,8 @@ func (e *encodingBlockAccessList) HashTreeRootWith(hh ssz.HashWalker) (err error return } -// GetTree ssz hashes the encodingBlockAccessList object -func (e *encodingBlockAccessList) GetTree() (*ssz.Node, error) { +// GetTree ssz hashes the BlockAccessList object +func (e *BlockAccessList) GetTree() (*ssz.Node, error) { return ssz.ProofTree(e) } @@ -547,13 +547,13 @@ func (e *encodingSlotWrites) GetTree() (*ssz.Node, error) { return ssz.ProofTree(e) } -// MarshalSSZ ssz marshals the encodingAccountAccess object -func (e *encodingAccountAccess) MarshalSSZ() ([]byte, error) { +// MarshalSSZ ssz marshals the AccountAccess object +func (e *AccountAccess) MarshalSSZ() ([]byte, error) { return ssz.MarshalSSZ(e) } -// MarshalSSZTo ssz marshals the encodingAccountAccess object to a target array -func (e *encodingAccountAccess) MarshalSSZTo(buf []byte) (dst []byte, err error) { +// 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) @@ -584,7 +584,7 @@ func (e *encodingAccountAccess) MarshalSSZTo(buf []byte) (dst []byte, err error) // Field (1) 'StorageWrites' if size := len(e.StorageWrites); size > 300000 { - err = ssz.ErrListTooBigFn("encodingAccountAccess.StorageWrites", size, 300000) + err = ssz.ErrListTooBigFn("AccountAccess.StorageWrites", size, 300000) return } { @@ -602,7 +602,7 @@ func (e *encodingAccountAccess) MarshalSSZTo(buf []byte) (dst []byte, err error) // Field (2) 'StorageReads' if size := len(e.StorageReads); size > 300000 { - err = ssz.ErrListTooBigFn("encodingAccountAccess.StorageReads", size, 300000) + err = ssz.ErrListTooBigFn("AccountAccess.StorageReads", size, 300000) return } for ii := 0; ii < len(e.StorageReads); ii++ { @@ -611,7 +611,7 @@ func (e *encodingAccountAccess) MarshalSSZTo(buf []byte) (dst []byte, err error) // Field (3) 'BalanceChanges' if size := len(e.BalanceChanges); size > 300000 { - err = ssz.ErrListTooBigFn("encodingAccountAccess.BalanceChanges", size, 300000) + err = ssz.ErrListTooBigFn("AccountAccess.BalanceChanges", size, 300000) return } for ii := 0; ii < len(e.BalanceChanges); ii++ { @@ -622,7 +622,7 @@ func (e *encodingAccountAccess) MarshalSSZTo(buf []byte) (dst []byte, err error) // Field (4) 'NonceChanges' if size := len(e.NonceChanges); size > 300000 { - err = ssz.ErrListTooBigFn("encodingAccountAccess.NonceChanges", size, 300000) + err = ssz.ErrListTooBigFn("AccountAccess.NonceChanges", size, 300000) return } for ii := 0; ii < len(e.NonceChanges); ii++ { @@ -633,7 +633,7 @@ func (e *encodingAccountAccess) MarshalSSZTo(buf []byte) (dst []byte, err error) // Field (5) 'Code' if size := len(e.Code); size > 1 { - err = ssz.ErrListTooBigFn("encodingAccountAccess.Code", size, 1) + err = ssz.ErrListTooBigFn("AccountAccess.Code", size, 1) return } { @@ -652,8 +652,8 @@ func (e *encodingAccountAccess) MarshalSSZTo(buf []byte) (dst []byte, err error) return } -// UnmarshalSSZ ssz unmarshals the encodingAccountAccess object -func (e *encodingAccountAccess) UnmarshalSSZ(buf []byte) error { +// UnmarshalSSZ ssz unmarshals the AccountAccess object +func (e *AccountAccess) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size < 40 { @@ -778,8 +778,8 @@ func (e *encodingAccountAccess) UnmarshalSSZ(buf []byte) error { return err } -// SizeSSZ returns the ssz encoded size in bytes for the encodingAccountAccess object -func (e *encodingAccountAccess) SizeSSZ() (size int) { +// SizeSSZ returns the ssz encoded size in bytes for the AccountAccess object +func (e *AccountAccess) SizeSSZ() (size int) { size = 40 // Field (1) 'StorageWrites' @@ -806,13 +806,13 @@ func (e *encodingAccountAccess) SizeSSZ() (size int) { return } -// HashTreeRoot ssz hashes the encodingAccountAccess object -func (e *encodingAccountAccess) HashTreeRoot() ([32]byte, error) { +// HashTreeRoot ssz hashes the AccountAccess object +func (e *AccountAccess) HashTreeRoot() ([32]byte, error) { return ssz.HashWithDefaultHasher(e) } -// HashTreeRootWith ssz hashes the encodingAccountAccess object with a hasher -func (e *encodingAccountAccess) HashTreeRootWith(hh ssz.HashWalker) (err error) { +// HashTreeRootWith ssz hashes the AccountAccess object with a hasher +func (e *AccountAccess) HashTreeRootWith(hh ssz.HashWalker) (err error) { indx := hh.Index() // Field (0) 'Address' @@ -837,7 +837,7 @@ func (e *encodingAccountAccess) HashTreeRootWith(hh ssz.HashWalker) (err error) // Field (2) 'StorageReads' { if size := len(e.StorageReads); size > 300000 { - err = ssz.ErrListTooBigFn("encodingAccountAccess.StorageReads", size, 300000) + err = ssz.ErrListTooBigFn("AccountAccess.StorageReads", size, 300000) return } subIndx := hh.Index() @@ -900,7 +900,7 @@ func (e *encodingAccountAccess) HashTreeRootWith(hh ssz.HashWalker) (err error) return } -// GetTree ssz hashes the encodingAccountAccess object -func (e *encodingAccountAccess) GetTree() (*ssz.Node, error) { +// GetTree ssz hashes the AccountAccess object +func (e *AccountAccess) GetTree() (*ssz.Node, error) { return ssz.ProofTree(e) } diff --git a/core/types/bal/bal_test.go b/core/types/bal/bal_test.go index 89dd0e3b79..b9c566d487 100644 --- a/core/types/bal/bal_test.go +++ b/core/types/bal/bal_test.go @@ -29,7 +29,7 @@ import ( "github.com/holiman/uint256" ) -func equalBALs(a *BlockAccessList, b *BlockAccessList) bool { +func equalBALs(a *ConstructionBlockAccessList, b *ConstructionBlockAccessList) bool { if len(a.Accounts) != len(b.Accounts) { return false } @@ -57,9 +57,9 @@ func equalBALs(a *BlockAccessList, b *BlockAccessList) bool { return true } -func makeTestBAL() *BlockAccessList { - return &BlockAccessList{ - map[common.Address]*AccountAccess{ +func makeTestBAL() *ConstructionBlockAccessList { + return &ConstructionBlockAccessList{ + map[common.Address]*ConstructionAccountAccess{ common.BytesToAddress([]byte{0xff, 0xff}): { StorageWrites: map[common.Hash]map[uint16]common.Hash{ common.BytesToHash([]byte{0x01}): { @@ -119,7 +119,7 @@ func TestBALEncoding(t *testing.T) { if err != nil { t.Fatalf("encoding failed: %v\n", err) } - var dec BlockAccessList + var dec ConstructionBlockAccessList if err := dec.DecodeRLP(rlp.NewStream(bytes.NewReader(buf.Bytes()), 10000000)); err != nil { t.Fatalf("decoding failed: %v\n", err) } @@ -139,7 +139,7 @@ func TestBALFullRLPEncoding(t *testing.T) { if err != nil { t.Fatalf("encoding failed: %v\n", err) } - var dec BlockAccessList + var dec ConstructionBlockAccessList if err := dec.DecodeFullRLP(rlp.NewStream(bytes.NewReader(buf.Bytes()), 10000000)); err != nil { t.Fatalf("decoding failed: %v\n", err) } @@ -165,7 +165,7 @@ func TestBALDecoding(t *testing.T) { if err != nil { t.Fatal(err) } - var b BlockAccessList + var b ConstructionBlockAccessList if err := b.decodeSSZ(data); err != nil { t.Fatal(err) } @@ -185,7 +185,7 @@ func TestBALEncodeSizeDifference(t *testing.T) { if err != nil { t.Fatal(err) } - var b BlockAccessList + var b ConstructionBlockAccessList if err := b.decodeSSZ(data); err != nil { t.Fatal(err) }