Documentation
¶
Overview ¶
Copyright 2022 Evmos Foundation This file is part of Mezo' Mezo packages.
The Mezo packages 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 Mezo packages 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 Mezo packages. If not, see https://github.com/mezo-org/mezod/blob/main/LICENSE
Copyright 2022 Evmos Foundation This file is part of the Evmos Network packages.
Evmos 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 Evmos packages are 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 Evmos packages. If not, see https://github.com/evmos/evmos/blob/main/LICENSE
Copyright 2022 Evmos Foundation This file is part of the Evmos Network packages.
Evmos 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 Evmos packages are 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 Evmos packages. If not, see https://github.com/evmos/evmos/blob/main/LICENSE
Copyright 2022 Evmos Foundation This file is part of the Evmos Network packages.
Evmos 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 Evmos packages are 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 Evmos packages. If not, see https://github.com/evmos/evmos/blob/main/LICENSE
Index ¶
- type Account
- type EVMConfig
- type ExtStateDB
- type JournalEntry
- type Keeper
- type StateDB
- func (s *StateDB) AddAddressToAccessList(addr common.Address)
- func (s *StateDB) AddBalance(addr common.Address, amount *uint256.Int, _ tracing.BalanceChangeReason)
- func (s *StateDB) AddLog(log *ethtypes.Log)
- func (s *StateDB) AddPreimage(_ common.Hash, _ []byte)
- func (s *StateDB) AddRefund(gas uint64)
- func (s *StateDB) AddSlotToAccessList(addr common.Address, slot common.Hash)
- func (s *StateDB) AddressInAccessList(addr common.Address) bool
- func (s *StateDB) Commit() error
- func (s *StateDB) CreateAccount(addr common.Address)
- func (s *StateDB) CreateContract(addr common.Address)
- func (s *StateDB) Empty(addr common.Address) bool
- func (s *StateDB) Exist(addr common.Address) bool
- func (s *StateDB) ForEachStorage(addr common.Address, cb func(key, value common.Hash) bool) error
- func (s *StateDB) GetBalance(addr common.Address) *uint256.Int
- func (s *StateDB) GetCode(addr common.Address) []byte
- func (s *StateDB) GetCodeHash(addr common.Address) common.Hash
- func (s *StateDB) GetCodeSize(addr common.Address) int
- func (s *StateDB) GetCommittedState(addr common.Address, hash common.Hash) common.Hash
- func (s *StateDB) GetContext() sdk.Context
- func (s *StateDB) GetNonce(addr common.Address) uint64
- func (s *StateDB) GetRefund() uint64
- func (s *StateDB) GetState(addr common.Address, hash common.Hash) common.Hash
- func (s *StateDB) GetStorageRoot(addr common.Address) common.Hash
- func (s *StateDB) GetTransientState(addr common.Address, key common.Hash) common.Hash
- func (s *StateDB) HasSelfDestructed(addr common.Address) bool
- func (s *StateDB) Keeper() Keeper
- func (s *StateDB) Logs() []*ethtypes.Log
- func (s *StateDB) PointCache() *utils.PointCache
- func (s *StateDB) Prepare(rules params.Rules, sender, coinbase common.Address, dst *common.Address, ...)
- func (s *StateDB) RevertToSnapshot(revid int)
- func (s *StateDB) SelfDestruct(addr common.Address)
- func (s *StateDB) Selfdestruct6780(addr common.Address)
- func (s *StateDB) SetCode(addr common.Address, code []byte)
- func (s *StateDB) SetNonce(addr common.Address, nonce uint64)
- func (s *StateDB) SetState(addr common.Address, key, value common.Hash)
- func (s *StateDB) SetTransientState(addr common.Address, key, value common.Hash)
- func (s *StateDB) SlotInAccessList(addr common.Address, slot common.Hash) (addressPresent bool, slotPresent bool)
- func (s *StateDB) Snapshot() int
- func (s *StateDB) SubBalance(addr common.Address, amount *uint256.Int, _ tracing.BalanceChangeReason)
- func (s *StateDB) SubRefund(gas uint64)
- func (s *StateDB) Witness() *stateless.Witness
- type Storage
- type TxConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Account ¶
Account is the Ethereum consensus representation of accounts. These objects are stored in the storage of auth module.
func (Account) IsContract ¶
IsContract returns if the account contains contract code.
type EVMConfig ¶
type EVMConfig struct { Params types.Params ChainConfig *params.ChainConfig CoinBase common.Address BaseFee *big.Int }
EVMConfig encapsulates common parameters needed to create an EVM to execute a message It's mainly to reduce the number of method parameters
type ExtStateDB ¶
type ExtStateDB interface { vm.StateDB AppendJournalEntry(JournalEntry) }
ExtStateDB defines an extension to the interface provided by the go-ethereum codebase to support additional state transition functionalities. In particular it supports appending a new entry to the state journal through AppendJournalEntry so that the state can be reverted after running stateful precompiled contracts.
type JournalEntry ¶
type JournalEntry interface { // Revert undoes the changes introduced by this journal entry. Revert(*StateDB) // Dirtied returns the Ethereum address modified by this journal entry. Dirtied() *common.Address }
JournalEntry is a modification entry in the state change journal that can be Reverted on demand.
type Keeper ¶
type Keeper interface { // Read methods GetAccount(ctx sdk.Context, addr common.Address) *Account GetState(ctx sdk.Context, addr common.Address, key common.Hash) common.Hash GetCode(ctx sdk.Context, codeHash common.Hash) []byte // the callback returns false to break early ForEachStorage(ctx sdk.Context, addr common.Address, cb func(key, value common.Hash) bool) // Write methods, only called by `StateDB.Commit()` SetAccount(ctx sdk.Context, addr common.Address, account Account) error SetState(ctx sdk.Context, addr common.Address, key common.Hash, value []byte) SetCode(ctx sdk.Context, codeHash []byte, code []byte) DeleteAccount(ctx sdk.Context, addr common.Address) error }
Keeper provide underlying storage of StateDB
type StateDB ¶
type StateDB struct {
// contains filtered or unexported fields
}
StateDB structs within the ethereum protocol are used to store anything within the merkle trie. StateDBs take care of caching and storing nested states. It's the general query interface to retrieve: * Contracts * Accounts
func (*StateDB) AddAddressToAccessList ¶
AddAddressToAccessList adds the given address to the access list
func (*StateDB) AddBalance ¶
func (s *StateDB) AddBalance(addr common.Address, amount *uint256.Int, _ tracing.BalanceChangeReason)
AddBalance adds amount to the account associated with addr.
func (*StateDB) AddPreimage ¶
AddPreimage records a SHA3 preimage seen by the VM. AddPreimage performs a no-op since the EnablePreimageRecording flag is disabled on the vm.Config during state transitions. No store trie preimages are written to the database.
func (*StateDB) AddSlotToAccessList ¶
AddSlotToAccessList adds the given (address, slot)-tuple to the access list
func (*StateDB) AddressInAccessList ¶
AddressInAccessList returns true if the given address is in the access list.
func (*StateDB) Commit ¶
Commit writes the dirty states to keeper the StateDB object should be discarded after committed.
func (*StateDB) CreateAccount ¶
CreateAccount explicitly creates a state object. If a state object with the address already exists the balance is carried over to the new account.
CreateAccount is called during the EVM CREATE operation. The situation might arise that a contract does the following:
1. sends funds to sha(account ++ (nonce + 1)) 2. tx_create(sha(account ++ nonce)) (note that this gets the address of 1)
Carrying over the balance ensures that Ether doesn't disappear.
func (*StateDB) CreateContract ¶
CreateContract is used whenever a contract is created. This may be preceded by CreateAccount, but that is not required if it already existed in the state due to funds sent beforehand. This operation sets the 'newContract'-flag, which is required in order to correctly handle EIP-6780 'delete-in-same-transaction' logic.
func (*StateDB) Empty ¶
Empty returns whether the state object is either non-existent or empty according to the EIP161 specification (balance = nonce = code = 0)
func (*StateDB) Exist ¶
Exist reports whether the given account address exists in the state. Notably this also returns true for suicided accounts.
func (*StateDB) ForEachStorage ¶
ForEachStorage iterate the contract storage, the iteration order is not defined.
func (*StateDB) GetBalance ¶
GetBalance retrieves the balance from the given address or 0 if object not found
func (*StateDB) GetCodeHash ¶
GetCodeHash returns the code hash of account.
func (*StateDB) GetCodeSize ¶
GetCodeSize returns the code size of account.
func (*StateDB) GetCommittedState ¶
GetCommittedState retrieves a value from the given account's committed storage trie.
func (*StateDB) GetContext ¶
GetContext returns the transaction Context.
func (*StateDB) GetStorageRoot ¶
GetStorageRoot returns a dummy storage root if the state exists for the given address or empty hash if object not found.
func (*StateDB) GetTransientState ¶
GetTransientState gets transient storage for a given account.
func (*StateDB) PointCache ¶
func (s *StateDB) PointCache() *utils.PointCache
func (*StateDB) Prepare ¶
func (s *StateDB) Prepare(rules params.Rules, sender, coinbase common.Address, dst *common.Address, precompiles []common.Address, list ethtypes.AccessList)
Prepare handles the preparatory steps for executing a state transition with. This method must be invoked before state transition.
Berlin fork: - Add sender to access list (2929) - Add destination to access list (2929) - Add precompiles to access list (2929) - Add the contents of the optional tx access list (2930)
Potential EIPs: - Reset access list (Berlin) - Add coinbase to access list (EIP-3651) - Reset transient storage (EIP-1153)
func (*StateDB) RevertToSnapshot ¶
RevertToSnapshot reverts all state changes made since the given revision.
func (*StateDB) SelfDestruct ¶
SelfDestruct marks the given account as selfdestructed. This clears the account balance.
The account's state object is still available until the state is committed, getStateObject will return a non-nil account after SelfDestruct.
func (*StateDB) Selfdestruct6780 ¶
func (*StateDB) SetTransientState ¶
SetTransientState sets transient storage for a given account. It adds the change to the journal so that it can be rolled back to its previous value if there is a revert.
func (*StateDB) SlotInAccessList ¶
func (s *StateDB) SlotInAccessList(addr common.Address, slot common.Hash) (addressPresent bool, slotPresent bool)
SlotInAccessList returns true if the given (address, slot)-tuple is in the access list.
func (*StateDB) SubBalance ¶
func (s *StateDB) SubBalance(addr common.Address, amount *uint256.Int, _ tracing.BalanceChangeReason)
SubBalance subtracts amount from the account associated with addr.
type Storage ¶
Storage represents in-memory cache/buffer of contract storage.
func (Storage) SortedKeys ¶
SortedKeys sort the keys for deterministic iteration
type TxConfig ¶
type TxConfig struct { BlockHash common.Hash // hash of current block TxHash common.Hash // hash of current tx TxIndex uint // the index of current transaction LogIndex uint // the index of next log within current block }
TxConfig encapulates the readonly information of current tx for `StateDB`.
func NewEmptyTxConfig ¶
NewEmptyTxConfig construct an empty TxConfig, used in context where there's no transaction, e.g. `eth_call`/`eth_estimateGas`.