Documentation ¶
Overview ¶
Package state provides a caching layer atop the Ethereum state trie.
Index ¶
- Constants
- func FindByHistory(tx ethdb.Tx, storage bool, key []byte, timestamp uint64) ([]byte, error)
- func GetAsOf(tx ethdb.Tx, storage bool, key []byte, timestamp uint64) ([]byte, error)
- func WalkAsOfAccounts(tx ethdb.Tx, startAddress common.Address, timestamp uint64, ...) error
- func WalkAsOfStorage(tx ethdb.Tx, address common.Address, incarnation uint64, ...) error
- type CachedReader
- func (cr *CachedReader) ReadAccountCode(address common.Address, incarnation uint64, codeHash common.Hash) ([]byte, error)
- func (cr *CachedReader) ReadAccountCodeSize(address common.Address, incarnation uint64, codeHash common.Hash) (int, error)
- func (cr *CachedReader) ReadAccountData(address common.Address) (*accounts.Account, error)
- func (cr *CachedReader) ReadAccountIncarnation(address common.Address) (uint64, error)
- func (cr *CachedReader) ReadAccountStorage(address common.Address, incarnation uint64, key *common.Hash) ([]byte, error)
- type CachedWriter
- func (cw *CachedWriter) CreateContract(address common.Address) error
- func (cw *CachedWriter) DeleteAccount(ctx context.Context, address common.Address, original *accounts.Account) error
- func (cw *CachedWriter) UpdateAccountCode(address common.Address, incarnation uint64, codeHash common.Hash, code []byte) error
- func (cw *CachedWriter) UpdateAccountData(ctx context.Context, address common.Address, ...) error
- func (cw *CachedWriter) WriteAccountStorage(ctx context.Context, address common.Address, incarnation uint64, ...) error
- func (cw *CachedWriter) WriteChangeSets() error
- func (cw *CachedWriter) WriteHistory() error
- type ChangeSetWriter
- func (w *ChangeSetWriter) CreateContract(address common.Address) error
- func (w *ChangeSetWriter) DeleteAccount(ctx context.Context, address common.Address, original *accounts.Account) error
- func (w *ChangeSetWriter) GetAccountChanges() (*changeset.ChangeSet, error)
- func (w *ChangeSetWriter) GetStorageChanges() (*changeset.ChangeSet, error)
- func (w *ChangeSetWriter) PrintChangedAccounts()
- func (w *ChangeSetWriter) UpdateAccountCode(address common.Address, incarnation uint64, codeHash common.Hash, code []byte) error
- func (w *ChangeSetWriter) UpdateAccountData(ctx context.Context, address common.Address, ...) error
- func (w *ChangeSetWriter) WriteAccountStorage(ctx context.Context, address common.Address, incarnation uint64, ...) error
- func (w *ChangeSetWriter) WriteChangeSets() error
- func (w *ChangeSetWriter) WriteHistory() error
- type Code
- type DbStateReader
- func (dbr *DbStateReader) ReadAccountCode(address common.Address, incarnation uint64, codeHash common.Hash) ([]byte, error)
- func (dbr *DbStateReader) ReadAccountCodeSize(address common.Address, incarnation uint64, codeHash common.Hash) (codeSize int, err error)
- func (dbr *DbStateReader) ReadAccountData(address common.Address) (*accounts.Account, error)
- func (dbr *DbStateReader) ReadAccountIncarnation(address common.Address) (uint64, error)
- func (dbr *DbStateReader) ReadAccountStorage(address common.Address, incarnation uint64, key *common.Hash) ([]byte, error)
- func (dbr *DbStateReader) SetAccountCache(accountCache *fastcache.Cache)
- func (dbr *DbStateReader) SetCodeCache(codeCache *fastcache.Cache)
- func (dbr *DbStateReader) SetCodeSizeCache(codeSizeCache *fastcache.Cache)
- func (dbr *DbStateReader) SetStorageCache(storageCache *fastcache.Cache)
- type DbStateWriter
- func (dsw *DbStateWriter) ChangeSetWriter() *ChangeSetWriter
- func (dsw *DbStateWriter) CreateContract(address common.Address) error
- func (dsw *DbStateWriter) DeleteAccount(ctx context.Context, address common.Address, original *accounts.Account) error
- func (dsw *DbStateWriter) UpdateAccountCode(address common.Address, incarnation uint64, codeHash common.Hash, code []byte) error
- func (dsw *DbStateWriter) UpdateAccountData(ctx context.Context, address common.Address, ...) error
- func (dsw *DbStateWriter) WriteAccountStorage(ctx context.Context, address common.Address, incarnation uint64, ...) error
- func (dsw *DbStateWriter) WriteChangeSets() error
- func (dsw *DbStateWriter) WriteHistory() error
- type Dump
- type DumpAccount
- type DumpCollector
- type Dumper
- func (d *Dumper) DefaultDump() []byte
- func (d *Dumper) DefaultRawDump() Dump
- func (d *Dumper) Dump(excludeCode, excludeStorage, excludeMissingPreimages bool) []byte
- func (d *Dumper) DumpToCollector(c DumpCollector, excludeCode, excludeStorage, _ bool, ...) ([]byte, error)
- func (d *Dumper) IterativeDump(excludeCode, excludeStorage, excludeMissingPreimages bool, ...)
- func (d *Dumper) IteratorDump(excludeCode, excludeStorage, excludeMissingPreimages bool, ...) (IteratorDump, error)
- func (d *Dumper) RawDump(excludeCode, excludeStorage, excludeMissingPreimages bool) Dump
- type IntraBlockState
- func (sdb *IntraBlockState) AddAddressToAccessList(addr common.Address)
- func (sdb *IntraBlockState) AddBalance(addr common.Address, amount *uint256.Int)
- func (sdb *IntraBlockState) AddLog(log *types.Log)
- func (sdb *IntraBlockState) AddPreimage(hash common.Hash, preimage []byte)
- func (sdb *IntraBlockState) AddRefund(gas uint64)
- func (sdb *IntraBlockState) AddSlotToAccessList(addr common.Address, slot common.Hash)
- func (sdb *IntraBlockState) AddressInAccessList(addr common.Address) bool
- func (sdb *IntraBlockState) CommitBlock(ctx context.Context, stateWriter StateWriter) error
- func (sdb *IntraBlockState) Copy() *IntraBlockState
- func (sdb *IntraBlockState) CreateAccount(addr common.Address, contractCreation bool)
- func (sdb *IntraBlockState) Empty(addr common.Address) bool
- func (sdb *IntraBlockState) Error() error
- func (sdb *IntraBlockState) Exist(addr common.Address) bool
- func (sdb *IntraBlockState) FinalizeTx(ctx context.Context, stateWriter StateWriter) error
- func (sdb *IntraBlockState) GetBalance(addr common.Address) *uint256.Int
- func (sdb *IntraBlockState) GetCode(addr common.Address) []byte
- func (sdb *IntraBlockState) GetCodeHash(addr common.Address) common.Hash
- func (sdb *IntraBlockState) GetCodeSize(addr common.Address) int
- func (sdb *IntraBlockState) GetCommittedState(addr common.Address, key *common.Hash, value *uint256.Int)
- func (sdb *IntraBlockState) GetIncarnation(addr common.Address) uint64
- func (sdb *IntraBlockState) GetLogs(hash common.Hash) []*types.Log
- func (sdb *IntraBlockState) GetNonce(addr common.Address) uint64
- func (sdb *IntraBlockState) GetOrNewStateObject(addr common.Address) *stateObject
- func (sdb *IntraBlockState) GetRefund() uint64
- func (sdb *IntraBlockState) GetState(addr common.Address, key *common.Hash, value *uint256.Int)
- func (sdb *IntraBlockState) HasSuicided(addr common.Address) bool
- func (sdb *IntraBlockState) Logs() []*types.Log
- func (sdb *IntraBlockState) Preimages() map[common.Hash][]byte
- func (sdb *IntraBlockState) Prepare(thash, bhash common.Hash, ti int)
- func (sdb *IntraBlockState) PrepareAccessList(sender common.Address, dst *common.Address, precompiles []common.Address, ...)
- func (sdb *IntraBlockState) Reset() error
- func (sdb *IntraBlockState) RevertToSnapshot(revid int)
- func (sdb *IntraBlockState) SetBalance(addr common.Address, amount *uint256.Int)
- func (sdb *IntraBlockState) SetCode(addr common.Address, code []byte)
- func (sdb *IntraBlockState) SetIncarnation(addr common.Address, incarnation uint64)
- func (sdb *IntraBlockState) SetNonce(addr common.Address, nonce uint64)
- func (sdb *IntraBlockState) SetState(addr common.Address, key *common.Hash, value uint256.Int)
- func (sdb *IntraBlockState) SetStorage(addr common.Address, storage Storage)
- func (sdb *IntraBlockState) SetTrace(trace bool)
- func (sdb *IntraBlockState) SetTracer(tracer StateTracer)
- func (sdb *IntraBlockState) SlotInAccessList(addr common.Address, slot common.Hash) (addressPresent bool, slotPresent bool)
- func (sdb *IntraBlockState) Snapshot() int
- func (sdb *IntraBlockState) SubBalance(addr common.Address, amount *uint256.Int)
- func (sdb *IntraBlockState) SubRefund(gas uint64)
- func (sdb *IntraBlockState) Suicide(addr common.Address) bool
- func (sdb *IntraBlockState) TxIndex() int
- type IteratorDump
- type NoopWriter
- func (nw *NoopWriter) CreateContract(address common.Address) error
- func (nw *NoopWriter) DeleteAccount(_ context.Context, address common.Address, original *accounts.Account) error
- func (nw *NoopWriter) UpdateAccountCode(address common.Address, incarnation uint64, codeHash common.Hash, code []byte) error
- func (nw *NoopWriter) UpdateAccountData(_ context.Context, address common.Address, original, account *accounts.Account) error
- func (nw *NoopWriter) WriteAccountStorage(_ context.Context, address common.Address, incarnation uint64, ...) error
- func (nw *NoopWriter) WriteChangeSets() error
- func (nw *NoopWriter) WriteHistory() error
- type PlainDBStatedeprecated
- func (dbs *PlainDBState) CreateContract(address common.Address) error
- func (dbs *PlainDBState) DeleteAccount(_ context.Context, address common.Address, original *accounts.Account) error
- func (dbs *PlainDBState) ForEachStorage(addr common.Address, startLocation common.Hash, ...) error
- func (dbs *PlainDBState) GetBlockNr() uint64
- func (dbs *PlainDBState) ReadAccountCode(address common.Address, incarnation uint64, codeHash common.Hash) ([]byte, error)
- func (dbs *PlainDBState) ReadAccountCodeSize(address common.Address, incarnation uint64, codeHash common.Hash) (int, error)
- func (dbs *PlainDBState) ReadAccountData(address common.Address) (*accounts.Account, error)
- func (dbs *PlainDBState) ReadAccountIncarnation(address common.Address) (uint64, error)
- func (dbs *PlainDBState) ReadAccountStorage(address common.Address, incarnation uint64, key *common.Hash) ([]byte, error)
- func (dbs *PlainDBState) SetBlockNr(blockNr uint64)
- func (dbs *PlainDBState) UpdateAccountCode(address common.Address, incarnation uint64, codeHash common.Hash, code []byte) error
- func (dbs *PlainDBState) UpdateAccountData(_ context.Context, address common.Address, original, account *accounts.Account) error
- func (dbs *PlainDBState) WriteAccountStorage(_ context.Context, address common.Address, incarnation uint64, ...) error
- type PlainKVState
- func (s *PlainKVState) CreateContract(address common.Address) error
- func (s *PlainKVState) DeleteAccount(_ context.Context, address common.Address, original *accounts.Account) error
- func (s *PlainKVState) ForEachStorage(addr common.Address, startLocation common.Hash, ...) error
- func (s *PlainKVState) GetBlockNr() uint64
- func (s *PlainKVState) ReadAccountCode(address common.Address, incarnation uint64, codeHash common.Hash) ([]byte, error)
- func (s *PlainKVState) ReadAccountCodeSize(address common.Address, incarnation uint64, codeHash common.Hash) (int, error)
- func (s *PlainKVState) ReadAccountData(address common.Address) (*accounts.Account, error)
- func (s *PlainKVState) ReadAccountIncarnation(address common.Address) (uint64, error)
- func (s *PlainKVState) ReadAccountStorage(address common.Address, incarnation uint64, key *common.Hash) ([]byte, error)
- func (s *PlainKVState) SetBlockNr(blockNr uint64)
- func (s *PlainKVState) UpdateAccountCode(address common.Address, incarnation uint64, codeHash common.Hash, code []byte) error
- func (s *PlainKVState) UpdateAccountData(_ context.Context, address common.Address, original, account *accounts.Account) error
- func (s *PlainKVState) WriteAccountStorage(_ context.Context, address common.Address, incarnation uint64, ...) error
- type PlainStateReader
- func (r *PlainStateReader) ReadAccountCode(address common.Address, incarnation uint64, codeHash common.Hash) ([]byte, error)
- func (r *PlainStateReader) ReadAccountCodeSize(address common.Address, incarnation uint64, codeHash common.Hash) (int, error)
- func (r *PlainStateReader) ReadAccountData(address common.Address) (*accounts.Account, error)
- func (r *PlainStateReader) ReadAccountIncarnation(address common.Address) (uint64, error)
- func (r *PlainStateReader) ReadAccountStorage(address common.Address, incarnation uint64, key *common.Hash) ([]byte, error)
- type PlainStateWriter
- func (w *PlainStateWriter) ChangeSetWriter() *ChangeSetWriter
- func (w *PlainStateWriter) CreateContract(address common.Address) error
- func (w *PlainStateWriter) DeleteAccount(ctx context.Context, address common.Address, original *accounts.Account) error
- func (w *PlainStateWriter) UpdateAccountCode(address common.Address, incarnation uint64, codeHash common.Hash, code []byte) error
- func (w *PlainStateWriter) UpdateAccountData(ctx context.Context, address common.Address, ...) error
- func (w *PlainStateWriter) WriteAccountStorage(ctx context.Context, address common.Address, incarnation uint64, ...) error
- func (w *PlainStateWriter) WriteChangeSets() error
- func (w *PlainStateWriter) WriteHistory() error
- type PreimageWriter
- type StateReader
- type StateTracer
- type StateWriter
- type Storage
- type WriterWithChangeSets
Constants ¶
const ( //FirstContractIncarnation - first incarnation for contract accounts. After 1 it increases by 1. FirstContractIncarnation = 1 //NonContractIncarnation incarnation for non contracts NonContractIncarnation = 0 )
Variables ¶
This section is empty.
Functions ¶
func FindByHistory ¶
func WalkAsOfAccounts ¶
Types ¶
type CachedReader ¶
type CachedReader struct {
// contains filtered or unexported fields
}
CachedReader is a wrapper for an instance of type StateReader This wrapper only makes calls to the underlying reader if the item is not in the cache
func NewCachedReader ¶
func NewCachedReader(r StateReader, cache *shards.StateCache) *CachedReader
NewCachedReader wraps a given state reader into the cached reader
func (*CachedReader) ReadAccountCode ¶
func (cr *CachedReader) ReadAccountCode(address common.Address, incarnation uint64, codeHash common.Hash) ([]byte, error)
ReadAccountCode is called when code of an account needs to be fetched from the state Usually, one of (address;incarnation) or codeHash is enough to uniquely identify the code
func (*CachedReader) ReadAccountCodeSize ¶
func (*CachedReader) ReadAccountData ¶
ReadAccountData is called when an account needs to be fetched from the state
func (*CachedReader) ReadAccountIncarnation ¶
func (cr *CachedReader) ReadAccountIncarnation(address common.Address) (uint64, error)
ReadAccountIncarnation is called when incarnation of the account is required (to create and recreate contract)
func (*CachedReader) ReadAccountStorage ¶
func (cr *CachedReader) ReadAccountStorage(address common.Address, incarnation uint64, key *common.Hash) ([]byte, error)
ReadAccountStorage is called when a storage item needs to be fetched from the state
type CachedWriter ¶
type CachedWriter struct {
// contains filtered or unexported fields
}
CachedWriter is a wrapper for an instance of type StateWriter
func NewCachedWriter ¶
func NewCachedWriter(w WriterWithChangeSets, cache *shards.StateCache) *CachedWriter
NewCachedWriter wraps a given state writer into a cached writer
func (*CachedWriter) CreateContract ¶
func (cw *CachedWriter) CreateContract(address common.Address) error
func (*CachedWriter) DeleteAccount ¶
func (*CachedWriter) UpdateAccountCode ¶
func (*CachedWriter) UpdateAccountData ¶
func (*CachedWriter) WriteAccountStorage ¶
func (*CachedWriter) WriteChangeSets ¶
func (cw *CachedWriter) WriteChangeSets() error
func (*CachedWriter) WriteHistory ¶
func (cw *CachedWriter) WriteHistory() error
type ChangeSetWriter ¶
type ChangeSetWriter struct {
// contains filtered or unexported fields
}
ChangeSetWriter is a mock StateWriter that accumulates changes in-memory into ChangeSets.
func NewChangeSetWriter ¶
func NewChangeSetWriter() *ChangeSetWriter
func NewChangeSetWriterPlain ¶
func NewChangeSetWriterPlain(db ethdb.RwTx, blockNumber uint64) *ChangeSetWriter
func (*ChangeSetWriter) CreateContract ¶
func (w *ChangeSetWriter) CreateContract(address common.Address) error
func (*ChangeSetWriter) DeleteAccount ¶
func (*ChangeSetWriter) GetAccountChanges ¶
func (w *ChangeSetWriter) GetAccountChanges() (*changeset.ChangeSet, error)
func (*ChangeSetWriter) GetStorageChanges ¶
func (w *ChangeSetWriter) GetStorageChanges() (*changeset.ChangeSet, error)
func (*ChangeSetWriter) PrintChangedAccounts ¶
func (w *ChangeSetWriter) PrintChangedAccounts()
func (*ChangeSetWriter) UpdateAccountCode ¶
func (*ChangeSetWriter) UpdateAccountData ¶
func (*ChangeSetWriter) WriteAccountStorage ¶
func (*ChangeSetWriter) WriteChangeSets ¶
func (w *ChangeSetWriter) WriteChangeSets() error
func (*ChangeSetWriter) WriteHistory ¶
func (w *ChangeSetWriter) WriteHistory() error
type DbStateReader ¶
type DbStateReader struct {
// contains filtered or unexported fields
}
Implements StateReader by wrapping database only, without trie
func NewDbStateReader ¶
func NewDbStateReader(db ethdb.Getter) *DbStateReader
func (*DbStateReader) ReadAccountCode ¶
func (*DbStateReader) ReadAccountCodeSize ¶
func (*DbStateReader) ReadAccountData ¶
func (*DbStateReader) ReadAccountIncarnation ¶
func (dbr *DbStateReader) ReadAccountIncarnation(address common.Address) (uint64, error)
func (*DbStateReader) ReadAccountStorage ¶
func (*DbStateReader) SetAccountCache ¶
func (dbr *DbStateReader) SetAccountCache(accountCache *fastcache.Cache)
func (*DbStateReader) SetCodeCache ¶
func (dbr *DbStateReader) SetCodeCache(codeCache *fastcache.Cache)
func (*DbStateReader) SetCodeSizeCache ¶
func (dbr *DbStateReader) SetCodeSizeCache(codeSizeCache *fastcache.Cache)
func (*DbStateReader) SetStorageCache ¶
func (dbr *DbStateReader) SetStorageCache(storageCache *fastcache.Cache)
type DbStateWriter ¶
type DbStateWriter struct {
// contains filtered or unexported fields
}
func NewDbStateWriter ¶
func NewDbStateWriter(db ethdb.Database, blockNr uint64) *DbStateWriter
func (*DbStateWriter) ChangeSetWriter ¶
func (dsw *DbStateWriter) ChangeSetWriter() *ChangeSetWriter
func (*DbStateWriter) CreateContract ¶
func (dsw *DbStateWriter) CreateContract(address common.Address) error
func (*DbStateWriter) DeleteAccount ¶
func (*DbStateWriter) UpdateAccountCode ¶
func (*DbStateWriter) UpdateAccountData ¶
func (*DbStateWriter) WriteAccountStorage ¶
func (*DbStateWriter) WriteChangeSets ¶
func (dsw *DbStateWriter) WriteChangeSets() error
WriteChangeSets causes accumulated change sets to be written into the database (or batch) associated with the `dsw`
func (*DbStateWriter) WriteHistory ¶
func (dsw *DbStateWriter) WriteHistory() error
type Dump ¶
type Dump struct { Root string `json:"root"` Accounts map[common.Address]DumpAccount `json:"accounts"` }
Dump represents the full dump in a collected format, as one large map.
type DumpAccount ¶
type DumpAccount struct { Balance string `json:"balance"` Nonce uint64 `json:"nonce"` Root string `json:"root"` CodeHash string `json:"codeHash"` Code string `json:"code,omitempty"` Storage map[string]string `json:"storage,omitempty"` Address *common.Address `json:"address,omitempty"` // Address only present in iterative (line-by-line) mode SecureKey *hexutil.Bytes `json:"key,omitempty"` // If we don't have address, we can output the key }
DumpAccount represents an account in the state.
type DumpCollector ¶
type DumpCollector interface { // OnRoot is called with the state root OnRoot(common.Hash) // OnAccount is called once for each account in the trie OnAccount(common.Address, DumpAccount) }
DumpCollector interface which the state trie calls during iteration
type Dumper ¶
type Dumper struct {
// contains filtered or unexported fields
}
func (*Dumper) DefaultDump ¶
DefaultDump returns a JSON string representing the state with the default params
func (*Dumper) DefaultRawDump ¶
func (*Dumper) Dump ¶
Dump returns a JSON string representing the entire state as a single json-object
func (*Dumper) DumpToCollector ¶
func (*Dumper) IterativeDump ¶
func (d *Dumper) IterativeDump(excludeCode, excludeStorage, excludeMissingPreimages bool, output *json.Encoder)
IterativeDump dumps out accounts as json-objects, delimited by linebreaks on stdout
func (*Dumper) IteratorDump ¶
func (d *Dumper) IteratorDump(excludeCode, excludeStorage, excludeMissingPreimages bool, start common.Address, maxResults int) (IteratorDump, error)
IteratorDump dumps out a batch of accounts starts with the given start key
type IntraBlockState ¶
type IntraBlockState struct {
// contains filtered or unexported fields
}
IntraBlockState is responsible for caching and managing state changes that occur during block's execution. NOT THREAD SAFE!
func (*IntraBlockState) AddAddressToAccessList ¶
func (sdb *IntraBlockState) AddAddressToAccessList(addr common.Address)
AddAddressToAccessList adds the given address to the access list
func (*IntraBlockState) AddBalance ¶
func (sdb *IntraBlockState) AddBalance(addr common.Address, amount *uint256.Int)
AddBalance adds amount to the account associated with addr. DESCRIBED: docs/programmers_guide/guide.md#address---identifier-of-an-account
func (*IntraBlockState) AddLog ¶
func (sdb *IntraBlockState) AddLog(log *types.Log)
func (*IntraBlockState) AddPreimage ¶
func (sdb *IntraBlockState) AddPreimage(hash common.Hash, preimage []byte)
AddPreimage records a SHA3 preimage seen by the VM.
func (*IntraBlockState) AddRefund ¶
func (sdb *IntraBlockState) AddRefund(gas uint64)
AddRefund adds gas to the refund counter
func (*IntraBlockState) AddSlotToAccessList ¶
func (sdb *IntraBlockState) AddSlotToAccessList(addr common.Address, slot common.Hash)
AddSlotToAccessList adds the given (address, slot)-tuple to the access list
func (*IntraBlockState) AddressInAccessList ¶
func (sdb *IntraBlockState) AddressInAccessList(addr common.Address) bool
AddressInAccessList returns true if the given address is in the access list.
func (*IntraBlockState) CommitBlock ¶
func (sdb *IntraBlockState) CommitBlock(ctx context.Context, stateWriter StateWriter) error
CommitBlock finalizes the state by removing the self destructed objects and clears the journal as well as the refunds.
func (*IntraBlockState) Copy ¶
func (sdb *IntraBlockState) Copy() *IntraBlockState
Copy creates a deep, independent copy of the state. Snapshots of the copied state cannot be applied to the copy.
func (*IntraBlockState) CreateAccount ¶
func (sdb *IntraBlockState) CreateAccount(addr common.Address, contractCreation bool)
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:
- sends funds to sha(account ++ (nonce + 1))
- tx_create(sha(account ++ nonce)) (note that this gets the address of 1)
Carrying over the balance ensures that Ether doesn't disappear.
func (*IntraBlockState) Empty ¶
func (sdb *IntraBlockState) Empty(addr common.Address) bool
Empty returns whether the state object is either non-existent or empty according to the EIP161 specification (balance = nonce = code = 0)
func (*IntraBlockState) Error ¶
func (sdb *IntraBlockState) Error() error
func (*IntraBlockState) Exist ¶
func (sdb *IntraBlockState) Exist(addr common.Address) bool
Exist reports whether the given account address exists in the state. Notably this also returns true for suicided accounts.
func (*IntraBlockState) FinalizeTx ¶
func (sdb *IntraBlockState) FinalizeTx(ctx context.Context, stateWriter StateWriter) error
FinalizeTx should be called after every transaction.
func (*IntraBlockState) GetBalance ¶
func (sdb *IntraBlockState) GetBalance(addr common.Address) *uint256.Int
GetBalance retrieves the balance from the given address or 0 if object not found DESCRIBED: docs/programmers_guide/guide.md#address---identifier-of-an-account
func (*IntraBlockState) GetCode ¶
func (sdb *IntraBlockState) GetCode(addr common.Address) []byte
DESCRIBED: docs/programmers_guide/guide.md#address---identifier-of-an-account
func (*IntraBlockState) GetCodeHash ¶
func (sdb *IntraBlockState) GetCodeHash(addr common.Address) common.Hash
DESCRIBED: docs/programmers_guide/guide.md#address---identifier-of-an-account
func (*IntraBlockState) GetCodeSize ¶
func (sdb *IntraBlockState) GetCodeSize(addr common.Address) int
DESCRIBED: docs/programmers_guide/guide.md#address---identifier-of-an-account
func (*IntraBlockState) GetCommittedState ¶
func (sdb *IntraBlockState) GetCommittedState(addr common.Address, key *common.Hash, value *uint256.Int)
GetCommittedState retrieves a value from the given account's committed storage trie. DESCRIBED: docs/programmers_guide/guide.md#address---identifier-of-an-account
func (*IntraBlockState) GetIncarnation ¶
func (sdb *IntraBlockState) GetIncarnation(addr common.Address) uint64
func (*IntraBlockState) GetLogs ¶
func (sdb *IntraBlockState) GetLogs(hash common.Hash) []*types.Log
func (*IntraBlockState) GetNonce ¶
func (sdb *IntraBlockState) GetNonce(addr common.Address) uint64
DESCRIBED: docs/programmers_guide/guide.md#address---identifier-of-an-account
func (*IntraBlockState) GetOrNewStateObject ¶
func (sdb *IntraBlockState) GetOrNewStateObject(addr common.Address) *stateObject
Retrieve a state object or create a new state object if nil.
func (*IntraBlockState) GetRefund ¶
func (sdb *IntraBlockState) GetRefund() uint64
GetRefund returns the current value of the refund counter.
func (*IntraBlockState) GetState ¶
GetState retrieves a value from the given account's storage trie. DESCRIBED: docs/programmers_guide/guide.md#address---identifier-of-an-account
func (*IntraBlockState) HasSuicided ¶
func (sdb *IntraBlockState) HasSuicided(addr common.Address) bool
func (*IntraBlockState) Logs ¶
func (sdb *IntraBlockState) Logs() []*types.Log
func (*IntraBlockState) Preimages ¶
func (sdb *IntraBlockState) Preimages() map[common.Hash][]byte
Preimages returns a list of SHA3 preimages that have been submitted.
func (*IntraBlockState) Prepare ¶
func (sdb *IntraBlockState) Prepare(thash, bhash common.Hash, ti int)
Prepare sets the current transaction hash and index and block hash which is used when the EVM emits new state logs.
func (*IntraBlockState) PrepareAccessList ¶
func (sdb *IntraBlockState) PrepareAccessList(sender common.Address, dst *common.Address, precompiles []common.Address, list types.AccessList)
PrepareAccessList handles the preparatory steps for executing a state transition with regards to both EIP-2929 and EIP-2930:
- 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)
This method should only be called if Yolov3/Berlin/2929+2930 is applicable at the current number.
func (*IntraBlockState) Reset ¶
func (sdb *IntraBlockState) Reset() error
Reset clears out all ephemeral state objects from the state db, but keeps the underlying state trie to avoid reloading data for the next operations.
func (*IntraBlockState) RevertToSnapshot ¶
func (sdb *IntraBlockState) RevertToSnapshot(revid int)
RevertToSnapshot reverts all state changes made since the given revision.
func (*IntraBlockState) SetBalance ¶
func (sdb *IntraBlockState) SetBalance(addr common.Address, amount *uint256.Int)
DESCRIBED: docs/programmers_guide/guide.md#address---identifier-of-an-account
func (*IntraBlockState) SetCode ¶
func (sdb *IntraBlockState) SetCode(addr common.Address, code []byte)
DESCRIBED: docs/programmers_guide/guide.md#code-hash DESCRIBED: docs/programmers_guide/guide.md#address---identifier-of-an-account
func (*IntraBlockState) SetIncarnation ¶
func (sdb *IntraBlockState) SetIncarnation(addr common.Address, incarnation uint64)
SetIncarnation sets incarnation for account if account exists
func (*IntraBlockState) SetNonce ¶
func (sdb *IntraBlockState) SetNonce(addr common.Address, nonce uint64)
DESCRIBED: docs/programmers_guide/guide.md#address---identifier-of-an-account
func (*IntraBlockState) SetState ¶
DESCRIBED: docs/programmers_guide/guide.md#address---identifier-of-an-account
func (*IntraBlockState) SetStorage ¶
func (sdb *IntraBlockState) SetStorage(addr common.Address, storage Storage)
SetStorage replaces the entire storage for the specified account with given storage. This function should only be used for debugging.
func (*IntraBlockState) SetTrace ¶
func (sdb *IntraBlockState) SetTrace(trace bool)
func (*IntraBlockState) SetTracer ¶
func (sdb *IntraBlockState) SetTracer(tracer StateTracer)
func (*IntraBlockState) SlotInAccessList ¶
func (sdb *IntraBlockState) 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 (*IntraBlockState) Snapshot ¶
func (sdb *IntraBlockState) Snapshot() int
Snapshot returns an identifier for the current revision of the state.
func (*IntraBlockState) SubBalance ¶
func (sdb *IntraBlockState) SubBalance(addr common.Address, amount *uint256.Int)
SubBalance subtracts amount from the account associated with addr. DESCRIBED: docs/programmers_guide/guide.md#address---identifier-of-an-account
func (*IntraBlockState) SubRefund ¶
func (sdb *IntraBlockState) SubRefund(gas uint64)
SubRefund removes gas from the refund counter. This method will panic if the refund counter goes below zero
func (*IntraBlockState) Suicide ¶
func (sdb *IntraBlockState) Suicide(addr common.Address) bool
Suicide marks the given account as suicided. 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 Suicide.
func (*IntraBlockState) TxIndex ¶
func (sdb *IntraBlockState) TxIndex() int
TxIndex returns the current transaction index set by Prepare.
type IteratorDump ¶
type IteratorDump struct { Root string `json:"root"` Accounts map[common.Address]DumpAccount `json:"accounts"` Next []byte `json:"next,omitempty"` // nil if no more accounts }
IteratorDump is an implementation for iterating over data.
func (*IteratorDump) OnAccount ¶
func (d *IteratorDump) OnAccount(addr common.Address, account DumpAccount)
OnAccount implements DumpCollector interface
func (*IteratorDump) OnRoot ¶
func (d *IteratorDump) OnRoot(root common.Hash)
OnRoot implements DumpCollector interface
type NoopWriter ¶
type NoopWriter struct { }
func NewNoopWriter ¶
func NewNoopWriter() *NoopWriter
func (*NoopWriter) CreateContract ¶
func (nw *NoopWriter) CreateContract(address common.Address) error
func (*NoopWriter) DeleteAccount ¶
func (*NoopWriter) UpdateAccountCode ¶
func (*NoopWriter) UpdateAccountData ¶
func (*NoopWriter) WriteAccountStorage ¶
func (*NoopWriter) WriteChangeSets ¶
func (nw *NoopWriter) WriteChangeSets() error
func (*NoopWriter) WriteHistory ¶
func (nw *NoopWriter) WriteHistory() error
type PlainDBState
deprecated
type PlainDBState struct {
// contains filtered or unexported fields
}
Deprecated: use PlainKVState Implements StateReader by wrapping database only, without trie
func NewPlainDBState ¶
func NewPlainDBState(db ethdb.GetterBeginner, blockNr uint64) *PlainDBState
func (*PlainDBState) CreateContract ¶
func (dbs *PlainDBState) CreateContract(address common.Address) error
func (*PlainDBState) DeleteAccount ¶
func (*PlainDBState) ForEachStorage ¶
func (*PlainDBState) GetBlockNr ¶
func (dbs *PlainDBState) GetBlockNr() uint64
func (*PlainDBState) ReadAccountCode ¶
func (*PlainDBState) ReadAccountCodeSize ¶
func (*PlainDBState) ReadAccountData ¶
func (*PlainDBState) ReadAccountIncarnation ¶
func (dbs *PlainDBState) ReadAccountIncarnation(address common.Address) (uint64, error)
func (*PlainDBState) ReadAccountStorage ¶
func (*PlainDBState) SetBlockNr ¶
func (dbs *PlainDBState) SetBlockNr(blockNr uint64)
func (*PlainDBState) UpdateAccountCode ¶
func (*PlainDBState) UpdateAccountData ¶
type PlainKVState ¶
type PlainKVState struct {
// contains filtered or unexported fields
}
func NewPlainKvState ¶
func NewPlainKvState(tx ethdb.Tx, blockNr uint64) *PlainKVState
func (*PlainKVState) CreateContract ¶
func (s *PlainKVState) CreateContract(address common.Address) error
func (*PlainKVState) DeleteAccount ¶
func (*PlainKVState) ForEachStorage ¶
func (*PlainKVState) GetBlockNr ¶
func (s *PlainKVState) GetBlockNr() uint64
func (*PlainKVState) ReadAccountCode ¶
func (*PlainKVState) ReadAccountCodeSize ¶
func (*PlainKVState) ReadAccountData ¶
func (*PlainKVState) ReadAccountIncarnation ¶
func (s *PlainKVState) ReadAccountIncarnation(address common.Address) (uint64, error)
func (*PlainKVState) ReadAccountStorage ¶
func (*PlainKVState) SetBlockNr ¶
func (s *PlainKVState) SetBlockNr(blockNr uint64)
func (*PlainKVState) UpdateAccountCode ¶
func (*PlainKVState) UpdateAccountData ¶
type PlainStateReader ¶
type PlainStateReader struct {
// contains filtered or unexported fields
}
PlainStateReader reads data from so called "plain state". Data in the plain state is stored using un-hashed account/storage items as opposed to the "normal" state that uses hashes of merkle paths to store items.
func NewPlainStateReader ¶
func NewPlainStateReader(db ethdb.KVGetter) *PlainStateReader
func (*PlainStateReader) ReadAccountCode ¶
func (*PlainStateReader) ReadAccountCodeSize ¶
func (*PlainStateReader) ReadAccountData ¶
func (*PlainStateReader) ReadAccountIncarnation ¶
func (r *PlainStateReader) ReadAccountIncarnation(address common.Address) (uint64, error)
func (*PlainStateReader) ReadAccountStorage ¶
type PlainStateWriter ¶
type PlainStateWriter struct {
// contains filtered or unexported fields
}
func NewPlainStateWriter ¶
func (*PlainStateWriter) ChangeSetWriter ¶
func (w *PlainStateWriter) ChangeSetWriter() *ChangeSetWriter
func (*PlainStateWriter) CreateContract ¶
func (w *PlainStateWriter) CreateContract(address common.Address) error
func (*PlainStateWriter) DeleteAccount ¶
func (*PlainStateWriter) UpdateAccountCode ¶
func (*PlainStateWriter) UpdateAccountData ¶
func (*PlainStateWriter) WriteAccountStorage ¶
func (*PlainStateWriter) WriteChangeSets ¶
func (w *PlainStateWriter) WriteChangeSets() error
func (*PlainStateWriter) WriteHistory ¶
func (w *PlainStateWriter) WriteHistory() error
type PreimageWriter ¶
type PreimageWriter struct {
// contains filtered or unexported fields
}
func (*PreimageWriter) HashAddress ¶
func (*PreimageWriter) SetSavePreimages ¶
func (pw *PreimageWriter) SetSavePreimages(save bool)
type StateReader ¶
type StateReader interface { ReadAccountData(address common.Address) (*accounts.Account, error) ReadAccountStorage(address common.Address, incarnation uint64, key *common.Hash) ([]byte, error) ReadAccountCode(address common.Address, incarnation uint64, codeHash common.Hash) ([]byte, error) ReadAccountCodeSize(address common.Address, incarnation uint64, codeHash common.Hash) (int, error) ReadAccountIncarnation(address common.Address) (uint64, error) }
type StateTracer ¶
type StateWriter ¶
type StateWriter interface { UpdateAccountData(ctx context.Context, address common.Address, original, account *accounts.Account) error UpdateAccountCode(address common.Address, incarnation uint64, codeHash common.Hash, code []byte) error DeleteAccount(ctx context.Context, address common.Address, original *accounts.Account) error WriteAccountStorage(ctx context.Context, address common.Address, incarnation uint64, key *common.Hash, original, value *uint256.Int) error CreateContract(address common.Address) error }
type WriterWithChangeSets ¶
type WriterWithChangeSets interface { StateWriter WriteChangeSets() error WriteHistory() error }