Documentation ¶
Index ¶
- type AccountDiff
- type CachedSource
- func (c *CachedSource) Balance(addr common.Address) (*uint256.Int, error)
- func (c *CachedSource) Code(addr common.Address) ([]byte, error)
- func (c *CachedSource) Nonce(addr common.Address) (uint64, error)
- func (c *CachedSource) StateRoot() common.Hash
- func (c *CachedSource) StorageAt(addr common.Address, key common.Hash) (common.Hash, error)
- func (c *CachedSource) URLOrAlias() string
- type ExportDiff
- type ForkDB
- func (f *ForkDB) ContractCode(addr common.Address, codeHash common.Hash) ([]byte, error)
- func (f *ForkDB) ContractCodeSize(addr common.Address, codeHash common.Hash) (int, error)
- func (f *ForkDB) CopyTrie(trie state.Trie) state.Trie
- func (f *ForkDB) DiskDB() ethdb.KeyValueStore
- func (f *ForkDB) OpenStorageTrie(stateRoot common.Hash, address common.Address, root common.Hash, ...) (state.Trie, error)
- func (f *ForkDB) OpenTrie(root common.Hash) (state.Trie, error)
- func (f *ForkDB) PointCache() *utils.PointCache
- func (f *ForkDB) Reader(root common.Hash) (state.Reader, error)
- func (f *ForkDB) Snapshot() *snapshot.Tree
- func (f *ForkDB) TrieDB() *triedb.Database
- type ForkID
- type ForkSource
- type ForkableState
- func (fst *ForkableState) ActiveFork() (id ForkID, active bool)
- func (fst *ForkableState) AddAddressToAccessList(addr common.Address)
- func (fst *ForkableState) AddBalance(address common.Address, u *uint256.Int, reason tracing.BalanceChangeReason)
- func (fst *ForkableState) AddLog(log *types.Log)
- func (fst *ForkableState) AddPreimage(hash common.Hash, img []byte)
- func (fst *ForkableState) AddRefund(u uint64)
- func (fst *ForkableState) AddSlotToAccessList(addr common.Address, slot common.Hash)
- func (fst *ForkableState) AddressInAccessList(addr common.Address) bool
- func (fst *ForkableState) CreateAccount(address common.Address)
- func (fst *ForkableState) CreateContract(address common.Address)
- func (fst *ForkableState) CreateFork(source ForkSource) (ForkID, error)
- func (fst *ForkableState) CreateSelectFork(source ForkSource) (ForkID, error)
- func (fst *ForkableState) Empty(address common.Address) bool
- func (fst *ForkableState) Exist(address common.Address) bool
- func (fst *ForkableState) ExportDiff(id ForkID) (*ExportDiff, error)
- func (fst *ForkableState) Finalise(deleteEmptyObjects bool)
- func (fst *ForkableState) ForkURLOrAlias(id ForkID) (string, error)
- func (fst *ForkableState) GetBalance(address common.Address) *uint256.Int
- func (fst *ForkableState) GetCode(address common.Address) []byte
- func (fst *ForkableState) GetCodeHash(address common.Address) common.Hash
- func (fst *ForkableState) GetCodeSize(address common.Address) int
- func (fst *ForkableState) GetCommittedState(address common.Address, hash common.Hash) common.Hash
- func (fst *ForkableState) GetNonce(address common.Address) uint64
- func (fst *ForkableState) GetRefund() uint64
- func (fst *ForkableState) GetState(address common.Address, k common.Hash) common.Hash
- func (fst *ForkableState) GetStorageRoot(addr common.Address) common.Hash
- func (fst *ForkableState) GetTransientState(addr common.Address, key common.Hash) common.Hash
- func (fst *ForkableState) HasSelfDestructed(address common.Address) bool
- func (fst *ForkableState) IsPersistent(addr common.Address) bool
- func (fst *ForkableState) MakeExcluded(addr common.Address)
- func (fst *ForkableState) MakePersistent(addr common.Address)
- func (fst *ForkableState) PointCache() *utils.PointCache
- func (fst *ForkableState) Prepare(rules params.Rules, sender, coinbase common.Address, dest *common.Address, ...)
- func (fst *ForkableState) ResetFork(id ForkID, src ForkSource) error
- func (fst *ForkableState) RevertToSnapshot(i int)
- func (fst *ForkableState) RevokeExcluded(addr common.Address)
- func (fst *ForkableState) RevokePersistent(addr common.Address)
- func (fst *ForkableState) SelectFork(id ForkID) error
- func (fst *ForkableState) SelfDestruct(address common.Address)
- func (fst *ForkableState) Selfdestruct6780(address common.Address)
- func (fst *ForkableState) SetBalance(addr common.Address, amount *uint256.Int, reason tracing.BalanceChangeReason)
- func (fst *ForkableState) SetCode(address common.Address, bytes []byte)
- func (fst *ForkableState) SetNonce(address common.Address, u uint64)
- func (fst *ForkableState) SetState(address common.Address, k common.Hash, v common.Hash)
- func (fst *ForkableState) SetTransientState(addr common.Address, key, value common.Hash)
- func (fst *ForkableState) SlotInAccessList(addr common.Address, slot common.Hash) (addressOk bool, slotOk bool)
- func (fst *ForkableState) Snapshot() int
- func (fst *ForkableState) SubBalance(address common.Address, u *uint256.Int, reason tracing.BalanceChangeReason)
- func (fst *ForkableState) SubRefund(u uint64)
- func (fst *ForkableState) SubstituteBaseState(base VMStateDB)
- func (fst *ForkableState) Witness() *stateless.Witness
- type ForkedAccountsTrie
- func (f *ForkedAccountsTrie) ClearDiff()
- func (f *ForkedAccountsTrie) Commit(collectLeaf bool) (common.Hash, *trienode.NodeSet)
- func (f *ForkedAccountsTrie) ContractCode(addr common.Address, codeHash common.Hash) ([]byte, error)
- func (f *ForkedAccountsTrie) ContractCodeSize(addr common.Address, codeHash common.Hash) (int, error)
- func (f *ForkedAccountsTrie) Copy() *ForkedAccountsTrie
- func (f *ForkedAccountsTrie) DeleteAccount(address common.Address) error
- func (f *ForkedAccountsTrie) DeleteStorage(addr common.Address, key []byte) error
- func (f *ForkedAccountsTrie) ExportDiff() *ExportDiff
- func (f *ForkedAccountsTrie) GetAccount(address common.Address) (*types.StateAccount, error)
- func (f *ForkedAccountsTrie) GetKey(bytes []byte) []byte
- func (f *ForkedAccountsTrie) GetStorage(addr common.Address, key []byte) ([]byte, error)
- func (f *ForkedAccountsTrie) HasDiff() bool
- func (f *ForkedAccountsTrie) Hash() common.Hash
- func (f *ForkedAccountsTrie) IsVerkle() bool
- func (f *ForkedAccountsTrie) NodeIterator(startKey []byte) (trie.NodeIterator, error)
- func (f *ForkedAccountsTrie) Prove(key []byte, proofDb ethdb.KeyValueWriter) error
- func (f *ForkedAccountsTrie) UpdateAccount(address common.Address, account *types.StateAccount, codeLen int) error
- func (f *ForkedAccountsTrie) UpdateContractCode(addr common.Address, codeHash common.Hash, code []byte) error
- func (f *ForkedAccountsTrie) UpdateStorage(addr common.Address, key, value []byte) error
- func (f *ForkedAccountsTrie) Witness() map[string]struct{}
- type Header
- type RPCClient
- type RPCSource
- func (r *RPCSource) Balance(addr common.Address) (*uint256.Int, error)
- func (r *RPCSource) BlockHash() common.Hash
- func (r *RPCSource) Close()
- func (r *RPCSource) Code(addr common.Address) ([]byte, error)
- func (r *RPCSource) Nonce(addr common.Address) (uint64, error)
- func (r *RPCSource) StateRoot() common.Hash
- func (r *RPCSource) StorageAt(addr common.Address, key common.Hash) (common.Hash, error)
- func (c *RPCSource) URLOrAlias() string
- type VMStateDB
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccountDiff ¶
type AccountDiff struct { // Nonce change. // No diff if nil. Nonce *uint64 `json:"nonce"` // Balance change. // No diff if nil. Balance *uint256.Int `json:"balance"` // Storage changes. // No diff if not present in map. Deletions are zero-value entries. Storage map[common.Hash]common.Hash `json:"storage"` // CodeHash, for lookup of contract bytecode in the code diff map. // No code-diff if nil. CodeHash *common.Hash `json:"codeHash"` }
AccountDiff represents changes to an account. Unchanged values of the account are not included.
func (*AccountDiff) Copy ¶
func (d *AccountDiff) Copy() *AccountDiff
type CachedSource ¶
type CachedSource struct {
// contains filtered or unexported fields
}
CachedSource wraps a ForkSource, and caches the retrieved data for faster repeat-queries. The ForkSource should be immutable (as per the StateRoot value). All cache data accumulates in-memory in LRU collections per data type.
func Cache ¶
func Cache(src ForkSource) *CachedSource
func (*CachedSource) StateRoot ¶
func (c *CachedSource) StateRoot() common.Hash
func (*CachedSource) URLOrAlias ¶
func (c *CachedSource) URLOrAlias() string
type ExportDiff ¶
type ExportDiff struct { // Accounts diff. Deleted accounts are set to nil. // Warning: this only contains finalized state changes. // The state itself holds on to non-flushed changes. Account map[common.Address]*AccountDiff `json:"account"` // Stores new contract codes by code-hash Code map[common.Hash][]byte `json:"code"` }
func NewExportDiff ¶
func NewExportDiff() *ExportDiff
func (*ExportDiff) Any ¶
func (ed *ExportDiff) Any() bool
func (*ExportDiff) Clear ¶
func (ed *ExportDiff) Clear()
func (*ExportDiff) Copy ¶
func (ed *ExportDiff) Copy() *ExportDiff
type ForkDB ¶
type ForkDB struct {
// contains filtered or unexported fields
}
ForkDB is a virtual state database: it wraps a forked accounts trie, and can maintain a state diff, so we can mutate the forked state, and even finalize state changes (so we can accurately measure things like cold storage gas cost).
func NewForkDB ¶
func NewForkDB(source ForkSource) *ForkDB
func (*ForkDB) ContractCode ¶
func (*ForkDB) ContractCodeSize ¶
func (*ForkDB) DiskDB ¶
func (f *ForkDB) DiskDB() ethdb.KeyValueStore
func (*ForkDB) OpenStorageTrie ¶
func (*ForkDB) PointCache ¶
func (f *ForkDB) PointCache() *utils.PointCache
func (*ForkDB) Reader ¶
Reader for read-only access to a known state. All cold reads go through this. So the state-DB creates one initially, and then holds on to it. The diff will be overlayed on the reader still. To get rid of the diff, it has to be explicitly cleared. Warning: diffs applied to the original state that the reader wraps will be visible. Geth StateDB is meant to be reinitialized after committing state.
type ForkSource ¶
type ForkSource interface { // URLOrAlias returns the URL or alias that the fork uses. This is not unique to a single fork. URLOrAlias() string // StateRoot returns the accounts-trie root of the committed-to state. // This root must never change. StateRoot() common.Hash // Nonce returns 0, without error, if the account does not exist. Nonce(addr common.Address) (uint64, error) // Balance returns 0, without error, if the account does not exist. Balance(addr common.Address) (*uint256.Int, error) // StorageAt returns a zeroed hash, without error, if the storage does not exist. StorageAt(addr common.Address, key common.Hash) (common.Hash, error) // Code returns an empty byte slice, without error, if no code exists. Code(addr common.Address) ([]byte, error) }
ForkSource is a read-only source for ethereum state, that can be used to fork a ForkableState.
type ForkableState ¶
type ForkableState struct {
// contains filtered or unexported fields
}
ForkableState implements the vm.StateDB interface, and a few other methods as defined in the VMStateDB interface. This state can be forked in-place, swapping over operations to route to in-memory states that wrap fork sources.
func NewForkableState ¶
func NewForkableState(base VMStateDB) *ForkableState
func (*ForkableState) ActiveFork ¶
func (fst *ForkableState) ActiveFork() (id ForkID, active bool)
ActiveFork returns the ID current active fork, or active == false if no fork is active.
func (*ForkableState) AddAddressToAccessList ¶
func (fst *ForkableState) AddAddressToAccessList(addr common.Address)
func (*ForkableState) AddBalance ¶
func (fst *ForkableState) AddBalance(address common.Address, u *uint256.Int, reason tracing.BalanceChangeReason)
func (*ForkableState) AddLog ¶
func (fst *ForkableState) AddLog(log *types.Log)
func (*ForkableState) AddPreimage ¶
func (fst *ForkableState) AddPreimage(hash common.Hash, img []byte)
func (*ForkableState) AddRefund ¶
func (fst *ForkableState) AddRefund(u uint64)
func (*ForkableState) AddSlotToAccessList ¶
func (fst *ForkableState) AddSlotToAccessList(addr common.Address, slot common.Hash)
func (*ForkableState) AddressInAccessList ¶
func (fst *ForkableState) AddressInAccessList(addr common.Address) bool
func (*ForkableState) CreateAccount ¶
func (fst *ForkableState) CreateAccount(address common.Address)
func (*ForkableState) CreateContract ¶
func (fst *ForkableState) CreateContract(address common.Address)
func (*ForkableState) CreateFork ¶
func (fst *ForkableState) CreateFork(source ForkSource) (ForkID, error)
CreateFork is like vm.createFork, it creates a fork, but does not select it yet.
func (*ForkableState) CreateSelectFork ¶
func (fst *ForkableState) CreateSelectFork(source ForkSource) (ForkID, error)
CreateSelectFork is like vm.createSelectFork, it creates a fork, and selects it immediately.
func (*ForkableState) ExportDiff ¶
func (fst *ForkableState) ExportDiff(id ForkID) (*ExportDiff, error)
ExportDiff exports a state diff. Warning: diffs are like flushed states. So we flush the state, making all the contents cold, losing transient storage, etc.
func (*ForkableState) Finalise ¶
func (fst *ForkableState) Finalise(deleteEmptyObjects bool)
Finalise finalises the state by removing the destructed objects and clears the journal as well as the refunds. Finalise, however, will not push any updates into the tries just yet.
The changes will be flushed to the underlying DB. A *ForkDB if the state is currently forked.
func (*ForkableState) ForkURLOrAlias ¶
func (fst *ForkableState) ForkURLOrAlias(id ForkID) (string, error)
ForkURLOrAlias returns the URL or alias that the fork was configured with as source. Returns an error if no fork is active
func (*ForkableState) GetBalance ¶
func (fst *ForkableState) GetBalance(address common.Address) *uint256.Int
func (*ForkableState) GetCodeHash ¶
func (fst *ForkableState) GetCodeHash(address common.Address) common.Hash
func (*ForkableState) GetCodeSize ¶
func (fst *ForkableState) GetCodeSize(address common.Address) int
func (*ForkableState) GetCommittedState ¶
func (*ForkableState) GetRefund ¶
func (fst *ForkableState) GetRefund() uint64
func (*ForkableState) GetStorageRoot ¶
func (fst *ForkableState) GetStorageRoot(addr common.Address) common.Hash
func (*ForkableState) GetTransientState ¶
func (*ForkableState) HasSelfDestructed ¶
func (fst *ForkableState) HasSelfDestructed(address common.Address) bool
func (*ForkableState) IsPersistent ¶
func (fst *ForkableState) IsPersistent(addr common.Address) bool
IsPersistent is like vm.isPersistent, it checks if an account persists across forks.
func (*ForkableState) MakeExcluded ¶
func (fst *ForkableState) MakeExcluded(addr common.Address)
MakeExcluded excludes an account from forking. This is useful for things like scripts, which should always use the fallback state.
func (*ForkableState) MakePersistent ¶
func (fst *ForkableState) MakePersistent(addr common.Address)
MakePersistent is like vm.makePersistent, it maintains this account context across all forks. It does not make the account of a fork persistent, it makes an account override what might be in a fork.
func (*ForkableState) PointCache ¶
func (fst *ForkableState) PointCache() *utils.PointCache
func (*ForkableState) ResetFork ¶
func (fst *ForkableState) ResetFork(id ForkID, src ForkSource) error
ResetFork resets the fork to be coupled to the given fork-source. Any ephemeral state changes (transient storage, warm s-loads, etc.) as well as any uncommitted state, as well as any previously flushed diffs, will be lost.
func (*ForkableState) RevertToSnapshot ¶
func (fst *ForkableState) RevertToSnapshot(i int)
func (*ForkableState) RevokeExcluded ¶
func (fst *ForkableState) RevokeExcluded(addr common.Address)
RevokeExcluded undoes MakeExcluded. It will panic if the account was marked as persistent in a different fork.
func (*ForkableState) RevokePersistent ¶
func (fst *ForkableState) RevokePersistent(addr common.Address)
RevokePersistent is like vm.revokePersistent, it undoes a previous vm.makePersistent.
func (*ForkableState) SelectFork ¶
func (fst *ForkableState) SelectFork(id ForkID) error
SelectFork is like vm.selectFork, it activates the usage of a previously created fork.
func (*ForkableState) SelfDestruct ¶
func (fst *ForkableState) SelfDestruct(address common.Address)
func (*ForkableState) Selfdestruct6780 ¶
func (fst *ForkableState) Selfdestruct6780(address common.Address)
func (*ForkableState) SetBalance ¶
func (fst *ForkableState) SetBalance(addr common.Address, amount *uint256.Int, reason tracing.BalanceChangeReason)
func (*ForkableState) SetCode ¶
func (fst *ForkableState) SetCode(address common.Address, bytes []byte)
func (*ForkableState) SetNonce ¶
func (fst *ForkableState) SetNonce(address common.Address, u uint64)
func (*ForkableState) SetTransientState ¶
func (fst *ForkableState) SetTransientState(addr common.Address, key, value common.Hash)
func (*ForkableState) SlotInAccessList ¶
func (*ForkableState) Snapshot ¶
func (fst *ForkableState) Snapshot() int
func (*ForkableState) SubBalance ¶
func (fst *ForkableState) SubBalance(address common.Address, u *uint256.Int, reason tracing.BalanceChangeReason)
func (*ForkableState) SubRefund ¶
func (fst *ForkableState) SubRefund(u uint64)
func (*ForkableState) SubstituteBaseState ¶
func (fst *ForkableState) SubstituteBaseState(base VMStateDB)
SubstituteBaseState substitutes in a fallback state.
func (*ForkableState) Witness ¶
func (fst *ForkableState) Witness() *stateless.Witness
type ForkedAccountsTrie ¶
type ForkedAccountsTrie struct {
// contains filtered or unexported fields
}
func (*ForkedAccountsTrie) ClearDiff ¶
func (f *ForkedAccountsTrie) ClearDiff()
ClearDiff clears the flushed changes. This does not clear the warm state changes. To fully clear, first Finalise the forked state that uses this trie, and then clear the diff.
func (*ForkedAccountsTrie) ContractCode ¶
func (f *ForkedAccountsTrie) ContractCode(addr common.Address, codeHash common.Hash) ([]byte, error)
ContractCode is not directly part of the vm.State interface, but is used by the ForkDB to retrieve the contract code.
func (*ForkedAccountsTrie) ContractCodeSize ¶
func (f *ForkedAccountsTrie) ContractCodeSize(addr common.Address, codeHash common.Hash) (int, error)
ContractCodeSize is not directly part of the vm.State interface, but is used by the ForkDB to retrieve the contract code-size.
func (*ForkedAccountsTrie) Copy ¶
func (f *ForkedAccountsTrie) Copy() *ForkedAccountsTrie
func (*ForkedAccountsTrie) DeleteAccount ¶
func (f *ForkedAccountsTrie) DeleteAccount(address common.Address) error
func (*ForkedAccountsTrie) DeleteStorage ¶
func (f *ForkedAccountsTrie) DeleteStorage(addr common.Address, key []byte) error
func (*ForkedAccountsTrie) ExportDiff ¶
func (f *ForkedAccountsTrie) ExportDiff() *ExportDiff
func (*ForkedAccountsTrie) GetAccount ¶
func (f *ForkedAccountsTrie) GetAccount(address common.Address) (*types.StateAccount, error)
func (*ForkedAccountsTrie) GetKey ¶
func (f *ForkedAccountsTrie) GetKey(bytes []byte) []byte
func (*ForkedAccountsTrie) GetStorage ¶
func (*ForkedAccountsTrie) HasDiff ¶
func (f *ForkedAccountsTrie) HasDiff() bool
func (*ForkedAccountsTrie) Hash ¶
func (f *ForkedAccountsTrie) Hash() common.Hash
func (*ForkedAccountsTrie) IsVerkle ¶
func (f *ForkedAccountsTrie) IsVerkle() bool
func (*ForkedAccountsTrie) NodeIterator ¶
func (f *ForkedAccountsTrie) NodeIterator(startKey []byte) (trie.NodeIterator, error)
func (*ForkedAccountsTrie) Prove ¶
func (f *ForkedAccountsTrie) Prove(key []byte, proofDb ethdb.KeyValueWriter) error
func (*ForkedAccountsTrie) UpdateAccount ¶
func (f *ForkedAccountsTrie) UpdateAccount(address common.Address, account *types.StateAccount, codeLen int) error
func (*ForkedAccountsTrie) UpdateContractCode ¶
func (*ForkedAccountsTrie) UpdateStorage ¶
func (f *ForkedAccountsTrie) UpdateStorage(addr common.Address, key, value []byte) error
func (*ForkedAccountsTrie) Witness ¶
func (f *ForkedAccountsTrie) Witness() map[string]struct{}
type RPCSource ¶
type RPCSource struct {
// contains filtered or unexported fields
}
func RPCSourceByHash ¶
func RPCSourceByNumber ¶
func (*RPCSource) Close ¶
func (r *RPCSource) Close()
Close stops any ongoing RPC requests by cancelling the RPC context