Documentation ¶
Index ¶
- func EncodeAddressValue(value any, offset uint) (common.Hash, error)
- func EncodeBoolValue(value any, offset uint) (common.Hash, error)
- func EncodeBytes32Value(value any, offset uint) (common.Hash, error)
- func EncodeStringValue(value any, offset uint) (common.Hash, error)
- func EncodeUintValue(value any, offset uint) (common.Hash, error)
- func SetStorage(name string, address common.Address, values StorageValues, db vm.StateDB) error
- type ElementEncoder
- type EncodedStorage
- func ComputeStorageSlots(layout *solc.StorageLayout, values StorageValues) ([]*EncodedStorage, error)
- func EncodeStorage(entry solc.StorageLayoutEntry, value any, storageType solc.StorageLayoutType) ([]*EncodedStorage, error)
- func EncodeStorageKeyValue(value any, entry solc.StorageLayoutEntry, storageType solc.StorageLayoutType) ([]*EncodedStorage, error)
- func MergeStorage(storage []*EncodedStorage) []*EncodedStorage
- type MemoryStateDB
- func (db *MemoryStateDB) AddAddressToAccessList(addr common.Address)
- func (db *MemoryStateDB) AddBalance(addr common.Address, amount *big.Int)
- func (db *MemoryStateDB) AddLog(*types.Log)
- func (db *MemoryStateDB) AddPreimage(common.Hash, []byte)
- func (db *MemoryStateDB) AddRefund(uint64)
- func (db *MemoryStateDB) AddSlotToAccessList(addr common.Address, slot common.Hash)
- func (db *MemoryStateDB) AddressInAccessList(addr common.Address) bool
- func (db *MemoryStateDB) CreateAccount(addr common.Address)
- func (db *MemoryStateDB) DeleteState(addr common.Address, key common.Hash)
- func (db *MemoryStateDB) Empty(addr common.Address) bool
- func (db *MemoryStateDB) Exist(addr common.Address) bool
- func (db *MemoryStateDB) ForEachStorage(addr common.Address, cb func(common.Hash, common.Hash) bool) error
- func (db *MemoryStateDB) Genesis() *core.Genesis
- func (db *MemoryStateDB) GetAccount(addr common.Address) *core.GenesisAccount
- func (db *MemoryStateDB) GetBalance(addr common.Address) *big.Int
- func (db *MemoryStateDB) GetCode(addr common.Address) []byte
- func (db *MemoryStateDB) GetCodeHash(addr common.Address) common.Hash
- func (db *MemoryStateDB) GetCodeSize(addr common.Address) int
- func (db *MemoryStateDB) GetCommittedState(common.Address, common.Hash) common.Hash
- func (db *MemoryStateDB) GetLiveStateAccount(addr common.Address) *types.StateAccount
- func (db *MemoryStateDB) GetNonce(addr common.Address) uint64
- func (db *MemoryStateDB) GetProof(addr common.Address) ([][]byte, error)
- func (db *MemoryStateDB) GetProofByHash(addrHash common.Hash) ([][]byte, error)
- func (db *MemoryStateDB) GetRefund() uint64
- func (db *MemoryStateDB) GetRootHash() common.Hash
- func (db *MemoryStateDB) GetState(addr common.Address, key common.Hash) common.Hash
- func (db *MemoryStateDB) GetStorageProof(a common.Address, key common.Hash) ([][]byte, error)
- func (db *MemoryStateDB) GetTransientState(addr common.Address, key common.Hash) common.Hash
- func (db *MemoryStateDB) HasSelfDestructed(common.Address) bool
- func (db *MemoryStateDB) Prepare(rules params.Rules, sender, coinbase common.Address, dest *common.Address, ...)
- func (db *MemoryStateDB) PrepareAccessList(sender common.Address, dest *common.Address, precompiles []common.Address, ...)
- func (db *MemoryStateDB) RevertToSnapshot(int)
- func (db *MemoryStateDB) SelfDestruct(common.Address)
- func (db *MemoryStateDB) Selfdestruct6780(common.Address)
- func (db *MemoryStateDB) SetCode(addr common.Address, code []byte)
- func (db *MemoryStateDB) SetNonce(addr common.Address, value uint64)
- func (db *MemoryStateDB) SetState(addr common.Address, key, value common.Hash)
- func (db *MemoryStateDB) SetTransientState(addr common.Address, key, value common.Hash)
- func (db *MemoryStateDB) SlotInAccessList(addr common.Address, slot common.Hash) (addressOk bool, slotOk bool)
- func (db *MemoryStateDB) Snapshot() int
- func (db *MemoryStateDB) SubBalance(addr common.Address, amount *big.Int)
- func (db *MemoryStateDB) SubRefund(uint64)
- type StorageConfig
- type StorageValues
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EncodeAddressValue ¶
EncodeAddressValue will encode an address like value given a storage offset.
func EncodeBoolValue ¶
EncodeBoolValue will encode a boolean value given a storage offset.
func EncodeBytes32Value ¶
EncodeBytes32Value will encode a bytes32 value. The offset is included so that it can implement the ElementEncoder interface, but the offset must always be 0.
func EncodeStringValue ¶
EncodeStringValue will encode a string to a type suitable for storage in state. The offset must be 0.
func EncodeUintValue ¶
EncodeUintValue will encode a uint value given a storage offset
func SetStorage ¶
SetStorage will set the storage values in a db given a contract name, address and the storage values
Types ¶
type ElementEncoder ¶
ElementEncoder is a function that can encode an element based on a solidity type
type EncodedStorage ¶
EncodedStorage represents the storage key and value serialized to be placed in Ethereum state.
func ComputeStorageSlots ¶
func ComputeStorageSlots(layout *solc.StorageLayout, values StorageValues) ([]*EncodedStorage, error)
ComputeStorageSlots will compute the storage slots for a given contract.
func EncodeStorage ¶
func EncodeStorage(entry solc.StorageLayoutEntry, value any, storageType solc.StorageLayoutType) ([]*EncodedStorage, error)
EncodeStorage will encode a storage layout
func EncodeStorageKeyValue ¶
func EncodeStorageKeyValue(value any, entry solc.StorageLayoutEntry, storageType solc.StorageLayoutType) ([]*EncodedStorage, error)
EncodeStorageKeyValue encodes the key value pair that is stored in state given a StorageLayoutEntry and StorageLayoutType. A single input may result in multiple outputs. Unknown or unimplemented types will return an error. Note that encoding uints is *not* overflow safe, so be sure to check the ABI before setting very large values
func MergeStorage ¶
func MergeStorage(storage []*EncodedStorage) []*EncodedStorage
MergeStorage will combine any overlapping storage slots for when values are tightly packed. Do this by checking to see if any of the produced storage slots have a matching key, if so use a binary or to add the storage values together
type MemoryStateDB ¶
type MemoryStateDB struct {
// contains filtered or unexported fields
}
MemoryStateDB implements geth's StateDB interface but operates on a core.Genesis so that a genesis.json can easily be created.
func NewMemoryStateDB ¶
func NewMemoryStateDB(genesis *core.Genesis) *MemoryStateDB
func (*MemoryStateDB) AddAddressToAccessList ¶
func (db *MemoryStateDB) AddAddressToAccessList(addr common.Address)
AddAddressToAccessList adds the given address to the access list. This operation is safe to perform even if the feature/fork is not active yet
func (*MemoryStateDB) AddBalance ¶
func (db *MemoryStateDB) AddBalance(addr common.Address, amount *big.Int)
func (*MemoryStateDB) AddLog ¶
func (db *MemoryStateDB) AddLog(*types.Log)
func (*MemoryStateDB) AddPreimage ¶
func (db *MemoryStateDB) AddPreimage(common.Hash, []byte)
func (*MemoryStateDB) AddRefund ¶
func (db *MemoryStateDB) AddRefund(uint64)
func (*MemoryStateDB) AddSlotToAccessList ¶
func (db *MemoryStateDB) AddSlotToAccessList(addr common.Address, slot common.Hash)
AddSlotToAccessList adds the given (address,slot) to the access list. This operation is safe to perform even if the feature/fork is not active yet
func (*MemoryStateDB) AddressInAccessList ¶
func (db *MemoryStateDB) AddressInAccessList(addr common.Address) bool
func (*MemoryStateDB) CreateAccount ¶
func (db *MemoryStateDB) CreateAccount(addr common.Address)
func (*MemoryStateDB) DeleteState ¶
func (db *MemoryStateDB) DeleteState(addr common.Address, key common.Hash)
func (*MemoryStateDB) Empty ¶
func (db *MemoryStateDB) Empty(addr common.Address) bool
Empty returns whether the given account is empty. Empty is defined according to EIP161 (balance = nonce = code = 0).
func (*MemoryStateDB) Exist ¶
func (db *MemoryStateDB) Exist(addr common.Address) bool
Exist reports whether the given account exists in state. Notably this should also return true for suicided accounts.
func (*MemoryStateDB) ForEachStorage ¶
func (*MemoryStateDB) Genesis ¶
func (db *MemoryStateDB) Genesis() *core.Genesis
Genesis is a getter for the underlying core.Genesis
func (*MemoryStateDB) GetAccount ¶
func (db *MemoryStateDB) GetAccount(addr common.Address) *core.GenesisAccount
GetAccount is a getter for a core.GenesisAccount found in the core.Genesis
func (*MemoryStateDB) GetBalance ¶
func (db *MemoryStateDB) GetBalance(addr common.Address) *big.Int
func (*MemoryStateDB) GetCodeHash ¶
func (db *MemoryStateDB) GetCodeHash(addr common.Address) common.Hash
func (*MemoryStateDB) GetCodeSize ¶
func (db *MemoryStateDB) GetCodeSize(addr common.Address) int
func (*MemoryStateDB) GetCommittedState ¶
func (*MemoryStateDB) GetLiveStateAccount ¶
func (db *MemoryStateDB) GetLiveStateAccount(addr common.Address) *types.StateAccount
func (*MemoryStateDB) GetProof ¶
func (db *MemoryStateDB) GetProof(addr common.Address) ([][]byte, error)
func (*MemoryStateDB) GetProofByHash ¶
func (db *MemoryStateDB) GetProofByHash(addrHash common.Hash) ([][]byte, error)
func (*MemoryStateDB) GetRefund ¶
func (db *MemoryStateDB) GetRefund() uint64
func (*MemoryStateDB) GetRootHash ¶
func (db *MemoryStateDB) GetRootHash() common.Hash
func (*MemoryStateDB) GetStorageProof ¶
func (*MemoryStateDB) GetTransientState ¶
func (*MemoryStateDB) HasSelfDestructed ¶
func (db *MemoryStateDB) HasSelfDestructed(common.Address) bool
func (*MemoryStateDB) PrepareAccessList ¶
func (db *MemoryStateDB) PrepareAccessList(sender common.Address, dest *common.Address, precompiles []common.Address, txAccesses types.AccessList)
func (*MemoryStateDB) RevertToSnapshot ¶
func (db *MemoryStateDB) RevertToSnapshot(int)
func (*MemoryStateDB) SelfDestruct ¶
func (db *MemoryStateDB) SelfDestruct(common.Address)
func (*MemoryStateDB) Selfdestruct6780 ¶
func (db *MemoryStateDB) Selfdestruct6780(common.Address)
func (*MemoryStateDB) SetNonce ¶
func (db *MemoryStateDB) SetNonce(addr common.Address, value uint64)
func (*MemoryStateDB) SetState ¶
func (db *MemoryStateDB) SetState(addr common.Address, key, value common.Hash)
func (*MemoryStateDB) SetTransientState ¶
func (db *MemoryStateDB) SetTransientState(addr common.Address, key, value common.Hash)
func (*MemoryStateDB) SlotInAccessList ¶
func (*MemoryStateDB) Snapshot ¶
func (db *MemoryStateDB) Snapshot() int
func (*MemoryStateDB) SubBalance ¶
func (db *MemoryStateDB) SubBalance(addr common.Address, amount *big.Int)
func (*MemoryStateDB) SubRefund ¶
func (db *MemoryStateDB) SubRefund(uint64)
type StorageConfig ¶
type StorageConfig map[string]StorageValues
StorageConfig represents the storage configuration for the L2 predeploy contracts.
type StorageValues ¶
StorageValues represents the values to be set in storage. The key is the name of the storage variable and the value is the value to set in storage.