Documentation ¶
Overview ¶
Package state provides a caching layer atop the Ethereum state trie.
Index ¶
- Constants
- Variables
- func EncodeBeforeState(w io.Writer, list Items, codeHash HashCodes)
- func FindByHistory(tx kv.Tx, indexC kv.Cursor, changesC kv.CursorDupSort, storage bool, ...) ([]byte, error)
- func GetAsOf(tx kv.Tx, indexC kv.Cursor, changesC kv.CursorDupSort, storage bool, ...) ([]byte, error)
- func WalkAsOfAccounts(tx kv.Tx, startAddress types.Address, timestamp uint64, ...) error
- func WalkAsOfStorage(tx kv.Tx, address types.Address, incarnation uint16, startLocation types.Hash, ...) error
- type BalanceIncrease
- type ChangeSetWriter
- func (w *ChangeSetWriter) CreateContract(address types.Address) error
- func (w *ChangeSetWriter) DeleteAccount(address types.Address, original *account.StateAccount) error
- func (w *ChangeSetWriter) GetAccountChanges() (*changeset.ChangeSet, error)
- func (w *ChangeSetWriter) GetStorageChanges() (*changeset.ChangeSet, error)
- func (w *ChangeSetWriter) PrintChangedAccounts()
- func (w *ChangeSetWriter) UpdateAccountCode(address types.Address, incarnation uint16, codeHash types.Hash, code []byte) error
- func (w *ChangeSetWriter) UpdateAccountData(address types.Address, original, account *account.StateAccount) error
- func (w *ChangeSetWriter) WriteAccountStorage(address types.Address, incarnation uint16, key *types.Hash, ...) error
- func (w *ChangeSetWriter) WriteChangeSets() error
- func (w *ChangeSetWriter) WriteHistory() error
- type Code
- type Entire
- type EntireCode
- type GetOneFun
- type HashCode
- type HashCodes
- type HistoryStateReader
- func (dbr *HistoryStateReader) GetOne(bucket string, key []byte) ([]byte, error)
- func (r *HistoryStateReader) ReadAccountCode(address types.Address, incarnation uint16, codeHash types.Hash) ([]byte, error)
- func (r *HistoryStateReader) ReadAccountCodeSize(address types.Address, incarnation uint16, codeHash types.Hash) (int, error)
- func (r *HistoryStateReader) ReadAccountData(address types.Address) (*account.StateAccount, error)
- func (r *HistoryStateReader) ReadAccountIncarnation(address types.Address) (uint16, error)
- func (r *HistoryStateReader) ReadAccountStorage(address types.Address, incarnation uint16, key *types.Hash) ([]byte, error)
- func (dbr *HistoryStateReader) Rollback()
- func (dbr *HistoryStateReader) SetBlockNumber(blockNr uint64)
- type IntraBlockState
- func (sdb *IntraBlockState) AddAddressToAccessList(addr types.Address)
- func (sdb *IntraBlockState) AddBalance(addr types.Address, amount *uint256.Int)
- func (sdb *IntraBlockState) AddLog(log2 *block.Log)
- func (sdb *IntraBlockState) AddRefund(gas uint64)
- func (sdb *IntraBlockState) AddSlotToAccessList(addr types.Address, slot types.Hash)
- func (sdb *IntraBlockState) AddressInAccessList(addr types.Address) bool
- func (sdb *IntraBlockState) BalanceIncreaseSet() map[types.Address]uint256.Int
- func (sdb *IntraBlockState) BeforeStateRoot() (hash types.Hash)
- func (sdb *IntraBlockState) BeginWriteCodes()
- func (sdb *IntraBlockState) BeginWriteSnapshot()
- func (sdb *IntraBlockState) CodeHashes() map[types.Hash][]byte
- func (sdb *IntraBlockState) CommitBlock(chainRules *params.Rules, stateWriter StateWriter) error
- func (sdb *IntraBlockState) CreateAccount(addr types.Address, contractCreation bool)
- func (sdb *IntraBlockState) Empty(addr types.Address) bool
- func (sdb *IntraBlockState) Error() error
- func (sdb *IntraBlockState) Exist(addr types.Address) bool
- func (sdb *IntraBlockState) FinalizeTx(chainRules *params.Rules, stateWriter StateWriter) error
- func (s *IntraBlockState) GenerateRootHash() types.Hash
- func (sdb *IntraBlockState) GetBalance(addr types.Address) *uint256.Int
- func (sdb *IntraBlockState) GetCode(addr types.Address) []byte
- func (sdb *IntraBlockState) GetCodeHash(addr types.Address) types.Hash
- func (sdb *IntraBlockState) GetCodeSize(addr types.Address) int
- func (sdb *IntraBlockState) GetCommittedState(addr types.Address, key *types.Hash, value *uint256.Int)
- func (sdb *IntraBlockState) GetIncarnation(addr types.Address) uint16
- func (sdb *IntraBlockState) GetLogs(hash types.Hash) []*block.Log
- func (sdb *IntraBlockState) GetNonce(addr types.Address) uint64
- func (sdb *IntraBlockState) GetOrNewStateObject(addr types.Address) *stateObject
- func (sdb *IntraBlockState) GetRefund() uint64
- func (sdb *IntraBlockState) GetState(addr types.Address, key *types.Hash, value *uint256.Int)
- func (sdb *IntraBlockState) GetStateReader() StateReader
- func (sdb *IntraBlockState) HasSelfdestructed(addr types.Address) bool
- func (sdb *IntraBlockState) HasSuicided(addr types.Address) bool
- func (s *IntraBlockState) IntermediateRoot() types.Hash
- func (sdb *IntraBlockState) Logs() []*block.Log
- func (sdb *IntraBlockState) MakeWriteSet(chainRules *params.Rules, stateWriter StateWriter) error
- func (sdb *IntraBlockState) Prepare(thash, bhash types.Hash, ti int)
- func (sdb *IntraBlockState) PrepareAccessList(sender types.Address, dst *types.Address, precompiles []types.Address, ...)
- func (sdb *IntraBlockState) PrepareReadableSnapshot(data []byte) error
- func (sdb *IntraBlockState) Print()
- func (sdb *IntraBlockState) Reset()
- func (sdb *IntraBlockState) RevertToSnapshot(revid int)
- func (sdb *IntraBlockState) Selfdestruct(addr types.Address) bool
- func (sdb *IntraBlockState) SetBalance(addr types.Address, amount *uint256.Int)
- func (sdb *IntraBlockState) SetCode(addr types.Address, code []byte)
- func (s *IntraBlockState) SetGetOneFun(f1 GetOneFun)
- func (sdb *IntraBlockState) SetHeight(height uint64)
- func (sdb *IntraBlockState) SetIncarnation(addr types.Address, incarnation uint16)
- func (sdb *IntraBlockState) SetNonce(addr types.Address, nonce uint64)
- func (sdb *IntraBlockState) SetOutHash(hash types.Hash)
- func (sdb *IntraBlockState) SetSnapshot(snap *Snapshot)
- func (sdb *IntraBlockState) SetState(addr types.Address, key *types.Hash, value uint256.Int)
- func (sdb *IntraBlockState) SetStateReader(reader StateReader)
- func (sdb *IntraBlockState) SetStorage(addr types.Address, storage Storage)
- func (sdb *IntraBlockState) SetTrace(trace bool)
- func (sdb *IntraBlockState) SetTracer(tracer StateTracer)
- func (sdb *IntraBlockState) SlotInAccessList(addr types.Address, slot types.Hash) (addressPresent bool, slotPresent bool)
- func (sdb *IntraBlockState) Snap() *Snapshot
- func (sdb *IntraBlockState) Snapshot() int
- func (sdb *IntraBlockState) SoftFinalise()
- func (sdb *IntraBlockState) SubBalance(addr types.Address, amount *uint256.Int)
- func (sdb *IntraBlockState) SubRefund(gas uint64)
- func (sdb *IntraBlockState) Suicide(addr types.Address) bool
- func (sdb *IntraBlockState) TxIndex() int
- func (sdb *IntraBlockState) WrittenSnapshot(hash types.Hash) []byte
- type Item
- type Items
- type NoopWriter
- func (nw *NoopWriter) CreateContract(address types.Address) error
- func (nw *NoopWriter) DeleteAccount(address types.Address, original *account.StateAccount) error
- func (nw *NoopWriter) UpdateAccountCode(address types.Address, incarnation uint16, codeHash types.Hash, code []byte) error
- func (nw *NoopWriter) UpdateAccountData(address types.Address, original, account *account.StateAccount) error
- func (nw *NoopWriter) WriteAccountStorage(address types.Address, incarnation uint16, key *types.Hash, ...) error
- func (nw *NoopWriter) WriteChangeSets() error
- func (nw *NoopWriter) WriteHistory() error
- type PlainState
- func (s *PlainState) CreateContract(address types.Address) error
- func (s *PlainState) DeleteAccount(address types.Address, original *account.StateAccount) error
- func (s *PlainState) ForEachStorage(addr types.Address, startLocation types.Hash, ...) error
- func (s *PlainState) GetBlockNr() uint64
- func (s *PlainState) ReadAccountCode(address types.Address, incarnation uint16, codeHash types.Hash) ([]byte, error)
- func (s *PlainState) ReadAccountCodeSize(address types.Address, incarnation uint16, codeHash types.Hash) (int, error)
- func (s *PlainState) ReadAccountData(address types.Address) (*account.StateAccount, error)
- func (s *PlainState) ReadAccountIncarnation(address types.Address) (uint16, error)
- func (s *PlainState) ReadAccountStorage(address types.Address, incarnation uint16, key *types.Hash) ([]byte, error)
- func (s *PlainState) SetBlockNr(blockNr uint64)
- func (s *PlainState) SetTrace(trace bool)
- func (s *PlainState) UpdateAccountCode(address types.Address, incarnation uint16, codeHash types.Hash, code []byte) error
- func (s *PlainState) UpdateAccountData(address types.Address, original, account *account.StateAccount) error
- func (s *PlainState) WriteAccountStorage(address types.Address, incarnation uint16, key *types.Hash, ...) error
- type PlainStateReader
- func (r *PlainStateReader) ReadAccountCode(address types.Address, incarnation uint16, codeHash types.Hash) ([]byte, error)
- func (r *PlainStateReader) ReadAccountCodeSize(address types.Address, incarnation uint16, codeHash types.Hash) (int, error)
- func (r *PlainStateReader) ReadAccountData(address types.Address) (*account.StateAccount, error)
- func (r *PlainStateReader) ReadAccountIncarnation(address types.Address) (uint16, error)
- func (r *PlainStateReader) ReadAccountStorage(address types.Address, incarnation uint16, key *types.Hash) ([]byte, error)
- type PlainStateWriter
- func (w *PlainStateWriter) ChangeSetWriter() *ChangeSetWriter
- func (w *PlainStateWriter) CreateContract(address types.Address) error
- func (w *PlainStateWriter) DeleteAccount(address types.Address, original *account.StateAccount) error
- func (w *PlainStateWriter) UpdateAccountCode(address types.Address, incarnation uint16, codeHash types.Hash, code []byte) error
- func (w *PlainStateWriter) UpdateAccountData(address types.Address, original, account *account.StateAccount) error
- func (w *PlainStateWriter) WriteAccountStorage(address types.Address, incarnation uint16, key *types.Hash, ...) error
- func (w *PlainStateWriter) WriteChangeSets() error
- func (w *PlainStateWriter) WriteHistory() error
- type Snapshot
- func (s *Snapshot) AddAccount(address types.Address, account *account.StateAccount)
- func (s *Snapshot) AddStorage(address types.Address, key *types.Hash, incarnation uint16, value []byte)
- func (s *Snapshot) CanWrite() bool
- func (s *Snapshot) ReadAccountData(address types.Address) (*account.StateAccount, error)
- func (s *Snapshot) ReadAccountStorage(address types.Address, incarnation uint16, key *types.Hash) ([]byte, error)
- func (s *Snapshot) SetGetFun(f GetOneFun)
- func (s *Snapshot) SetHash(hash types.Hash)
- 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 ¶
var SystemAddress = types.HexToAddress("0xfffffffffffffffffffffffffffffffffffffffe")
SystemAddress - sender address for internal state updates.
Functions ¶
func FindByHistory ¶
func WalkAsOfAccounts ¶
Types ¶
type BalanceIncrease ¶
type BalanceIncrease struct {
// contains filtered or unexported fields
}
BalanceIncrease represents the increase of balance of an account that did not require reading the account first
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 kv.RwTx, blockNumber uint64) *ChangeSetWriter
func (*ChangeSetWriter) CreateContract ¶
func (w *ChangeSetWriter) CreateContract(address types.Address) error
func (*ChangeSetWriter) DeleteAccount ¶
func (w *ChangeSetWriter) DeleteAccount(address types.Address, original *account.StateAccount) error
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 (w *ChangeSetWriter) UpdateAccountData(address types.Address, original, account *account.StateAccount) error
func (*ChangeSetWriter) WriteAccountStorage ¶
func (*ChangeSetWriter) WriteChangeSets ¶
func (w *ChangeSetWriter) WriteChangeSets() error
func (*ChangeSetWriter) WriteHistory ¶
func (w *ChangeSetWriter) WriteHistory() error
type Entire ¶
type EntireCode ¶
type HistoryStateReader ¶
type HistoryStateReader struct {
// contains filtered or unexported fields
}
func NewStateHistoryReader ¶
func (*HistoryStateReader) GetOne ¶
func (dbr *HistoryStateReader) GetOne(bucket string, key []byte) ([]byte, error)
func (*HistoryStateReader) ReadAccountCode ¶
func (*HistoryStateReader) ReadAccountCodeSize ¶
func (*HistoryStateReader) ReadAccountData ¶
func (r *HistoryStateReader) ReadAccountData(address types.Address) (*account.StateAccount, error)
func (*HistoryStateReader) ReadAccountIncarnation ¶
func (r *HistoryStateReader) ReadAccountIncarnation(address types.Address) (uint16, error)
func (*HistoryStateReader) ReadAccountStorage ¶
func (*HistoryStateReader) Rollback ¶
func (dbr *HistoryStateReader) Rollback()
func (*HistoryStateReader) SetBlockNumber ¶
func (dbr *HistoryStateReader) SetBlockNumber(blockNr uint64)
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 types.Address)
AddAddressToAccessList adds the given address to the access list
func (*IntraBlockState) AddBalance ¶
func (sdb *IntraBlockState) AddBalance(addr types.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(log2 *block.Log)
func (*IntraBlockState) AddRefund ¶
func (sdb *IntraBlockState) AddRefund(gas uint64)
AddRefund adds gas to the refund counter
func (*IntraBlockState) AddSlotToAccessList ¶
func (sdb *IntraBlockState) AddSlotToAccessList(addr types.Address, slot types.Hash)
AddSlotToAccessList adds the given (address, slot)-tuple to the access list
func (*IntraBlockState) AddressInAccessList ¶
func (sdb *IntraBlockState) AddressInAccessList(addr types.Address) bool
AddressInAccessList returns true if the given address is in the access list.
func (*IntraBlockState) BalanceIncreaseSet ¶
func (sdb *IntraBlockState) BalanceIncreaseSet() map[types.Address]uint256.Int
func (*IntraBlockState) BeforeStateRoot ¶
func (sdb *IntraBlockState) BeforeStateRoot() (hash types.Hash)
BeforeStateRoot calculate used state hash
it should be invoked after all txs exec
func (*IntraBlockState) BeginWriteCodes ¶
func (sdb *IntraBlockState) BeginWriteCodes()
func (*IntraBlockState) BeginWriteSnapshot ¶
func (sdb *IntraBlockState) BeginWriteSnapshot()
func (*IntraBlockState) CodeHashes ¶
func (sdb *IntraBlockState) CodeHashes() map[types.Hash][]byte
func (*IntraBlockState) CommitBlock ¶
func (sdb *IntraBlockState) CommitBlock(chainRules *params.Rules, stateWriter StateWriter) error
CommitBlock finalizes the state by removing the self destructed objects and clears the journal as well as the refunds.
func (*IntraBlockState) CreateAccount ¶
func (sdb *IntraBlockState) CreateAccount(addr types.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 AMT doesn't disappear.
func (*IntraBlockState) Empty ¶
func (sdb *IntraBlockState) Empty(addr types.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 types.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(chainRules *params.Rules, stateWriter StateWriter) error
FinalizeTx should be called after every transaction.
func (*IntraBlockState) GenerateRootHash ¶
func (s *IntraBlockState) GenerateRootHash() types.Hash
GenerateRootHash calculate root hash
func (*IntraBlockState) GetBalance ¶
func (sdb *IntraBlockState) GetBalance(addr types.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 types.Address) []byte
DESCRIBED: docs/programmers_guide/guide.md#address---identifier-of-an-account
func (*IntraBlockState) GetCodeHash ¶
func (sdb *IntraBlockState) GetCodeHash(addr types.Address) types.Hash
DESCRIBED: docs/programmers_guide/guide.md#address---identifier-of-an-account
func (*IntraBlockState) GetCodeSize ¶
func (sdb *IntraBlockState) GetCodeSize(addr types.Address) int
DESCRIBED: docs/programmers_guide/guide.md#address---identifier-of-an-account
func (*IntraBlockState) GetCommittedState ¶
func (sdb *IntraBlockState) GetCommittedState(addr types.Address, key *types.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 types.Address) uint16
func (*IntraBlockState) GetNonce ¶
func (sdb *IntraBlockState) GetNonce(addr types.Address) uint64
DESCRIBED: docs/programmers_guide/guide.md#address---identifier-of-an-account
func (*IntraBlockState) GetOrNewStateObject ¶
func (sdb *IntraBlockState) GetOrNewStateObject(addr types.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) GetStateReader ¶
func (sdb *IntraBlockState) GetStateReader() StateReader
func (*IntraBlockState) HasSelfdestructed ¶
func (sdb *IntraBlockState) HasSelfdestructed(addr types.Address) bool
func (*IntraBlockState) HasSuicided ¶
func (sdb *IntraBlockState) HasSuicided(addr types.Address) bool
func (*IntraBlockState) IntermediateRoot ¶
func (s *IntraBlockState) IntermediateRoot() types.Hash
IntermediateRoot root
func (*IntraBlockState) Logs ¶
func (sdb *IntraBlockState) Logs() []*block.Log
func (*IntraBlockState) MakeWriteSet ¶
func (sdb *IntraBlockState) MakeWriteSet(chainRules *params.Rules, stateWriter StateWriter) error
func (*IntraBlockState) Prepare ¶
func (sdb *IntraBlockState) Prepare(thash, bhash types.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 types.Address, dst *types.Address, precompiles []types.Address, list transaction.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) PrepareReadableSnapshot ¶
func (sdb *IntraBlockState) PrepareReadableSnapshot(data []byte) error
func (*IntraBlockState) Print ¶
func (sdb *IntraBlockState) Print()
func (*IntraBlockState) Reset ¶
func (sdb *IntraBlockState) Reset()
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) Selfdestruct ¶
func (sdb *IntraBlockState) Selfdestruct(addr types.Address) bool
Selfdestruct 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) SetBalance ¶
func (sdb *IntraBlockState) SetBalance(addr types.Address, amount *uint256.Int)
DESCRIBED: docs/programmers_guide/guide.md#address---identifier-of-an-account
func (*IntraBlockState) SetCode ¶
func (sdb *IntraBlockState) SetCode(addr types.Address, code []byte)
DESCRIBED: docs/programmers_guide/guide.md#code-hash DESCRIBED: docs/programmers_guide/guide.md#address---identifier-of-an-account
func (*IntraBlockState) SetGetOneFun ¶
func (s *IntraBlockState) SetGetOneFun(f1 GetOneFun)
func (*IntraBlockState) SetHeight ¶
func (sdb *IntraBlockState) SetHeight(height uint64)
func (*IntraBlockState) SetIncarnation ¶
func (sdb *IntraBlockState) SetIncarnation(addr types.Address, incarnation uint16)
SetIncarnation sets incarnation for account if account exists
func (*IntraBlockState) SetNonce ¶
func (sdb *IntraBlockState) SetNonce(addr types.Address, nonce uint64)
DESCRIBED: docs/programmers_guide/guide.md#address---identifier-of-an-account
func (*IntraBlockState) SetOutHash ¶
func (sdb *IntraBlockState) SetOutHash(hash types.Hash)
func (*IntraBlockState) SetSnapshot ¶
func (sdb *IntraBlockState) SetSnapshot(snap *Snapshot)
func (*IntraBlockState) SetState ¶
DESCRIBED: docs/programmers_guide/guide.md#address---identifier-of-an-account
func (*IntraBlockState) SetStateReader ¶
func (sdb *IntraBlockState) SetStateReader(reader StateReader)
func (*IntraBlockState) SetStorage ¶
func (sdb *IntraBlockState) SetStorage(addr types.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 types.Address, slot types.Hash) (addressPresent bool, slotPresent bool)
SlotInAccessList returns true if the given (address, slot)-tuple is in the access list.
func (*IntraBlockState) Snap ¶
func (sdb *IntraBlockState) Snap() *Snapshot
func (*IntraBlockState) Snapshot ¶
func (sdb *IntraBlockState) Snapshot() int
Snapshot returns an identifier for the current revision of the state.
func (*IntraBlockState) SoftFinalise ¶
func (sdb *IntraBlockState) SoftFinalise()
func (*IntraBlockState) SubBalance ¶
func (sdb *IntraBlockState) SubBalance(addr types.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 types.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.
func (*IntraBlockState) WrittenSnapshot ¶
func (sdb *IntraBlockState) WrittenSnapshot(hash types.Hash) []byte
type NoopWriter ¶
type NoopWriter struct { }
func NewNoopWriter ¶
func NewNoopWriter() *NoopWriter
func (*NoopWriter) CreateContract ¶
func (nw *NoopWriter) CreateContract(address types.Address) error
func (*NoopWriter) DeleteAccount ¶
func (nw *NoopWriter) DeleteAccount(address types.Address, original *account.StateAccount) error
func (*NoopWriter) UpdateAccountCode ¶
func (*NoopWriter) UpdateAccountData ¶
func (nw *NoopWriter) UpdateAccountData(address types.Address, original, account *account.StateAccount) error
func (*NoopWriter) WriteAccountStorage ¶
func (*NoopWriter) WriteChangeSets ¶
func (nw *NoopWriter) WriteChangeSets() error
func (*NoopWriter) WriteHistory ¶
func (nw *NoopWriter) WriteHistory() error
type PlainState ¶
type PlainState struct {
// contains filtered or unexported fields
}
State at the beginning of blockNr
func NewPlainState ¶
func NewPlainState(tx kv.Tx, blockNr uint64) *PlainState
func (*PlainState) CreateContract ¶
func (s *PlainState) CreateContract(address types.Address) error
func (*PlainState) DeleteAccount ¶
func (s *PlainState) DeleteAccount(address types.Address, original *account.StateAccount) error
func (*PlainState) ForEachStorage ¶
func (*PlainState) GetBlockNr ¶
func (s *PlainState) GetBlockNr() uint64
func (*PlainState) ReadAccountCode ¶
func (*PlainState) ReadAccountCodeSize ¶
func (*PlainState) ReadAccountData ¶
func (s *PlainState) ReadAccountData(address types.Address) (*account.StateAccount, error)
func (*PlainState) ReadAccountIncarnation ¶
func (s *PlainState) ReadAccountIncarnation(address types.Address) (uint16, error)
func (*PlainState) ReadAccountStorage ¶
func (*PlainState) SetBlockNr ¶
func (s *PlainState) SetBlockNr(blockNr uint64)
func (*PlainState) SetTrace ¶
func (s *PlainState) SetTrace(trace bool)
func (*PlainState) UpdateAccountCode ¶
func (*PlainState) UpdateAccountData ¶
func (s *PlainState) UpdateAccountData(address types.Address, original, account *account.StateAccount) error
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 kv.Getter) *PlainStateReader
func (*PlainStateReader) ReadAccountCode ¶
func (*PlainStateReader) ReadAccountCodeSize ¶
func (*PlainStateReader) ReadAccountData ¶
func (r *PlainStateReader) ReadAccountData(address types.Address) (*account.StateAccount, error)
func (*PlainStateReader) ReadAccountIncarnation ¶
func (r *PlainStateReader) ReadAccountIncarnation(address types.Address) (uint16, error)
func (*PlainStateReader) ReadAccountStorage ¶
type PlainStateWriter ¶
type PlainStateWriter struct {
// contains filtered or unexported fields
}
func NewPlainStateWriter ¶
func NewPlainStateWriter(db putDel, changeSetsDB kv.RwTx, blockNumber uint64) *PlainStateWriter
func NewPlainStateWriterNoHistory ¶
func NewPlainStateWriterNoHistory(db putDel) *PlainStateWriter
func (*PlainStateWriter) ChangeSetWriter ¶
func (w *PlainStateWriter) ChangeSetWriter() *ChangeSetWriter
func (*PlainStateWriter) CreateContract ¶
func (w *PlainStateWriter) CreateContract(address types.Address) error
func (*PlainStateWriter) DeleteAccount ¶
func (w *PlainStateWriter) DeleteAccount(address types.Address, original *account.StateAccount) error
func (*PlainStateWriter) UpdateAccountCode ¶
func (*PlainStateWriter) UpdateAccountData ¶
func (w *PlainStateWriter) UpdateAccountData(address types.Address, original, account *account.StateAccount) error
func (*PlainStateWriter) WriteAccountStorage ¶
func (*PlainStateWriter) WriteChangeSets ¶
func (w *PlainStateWriter) WriteChangeSets() error
func (*PlainStateWriter) WriteHistory ¶
func (w *PlainStateWriter) WriteHistory() error
type Snapshot ¶
type Snapshot struct { Items Items `json:"items"` OutHash types.Hash `json:"outHash"` // contains filtered or unexported fields }
func NewReadableSnapshot ¶
func NewReadableSnapshot() *Snapshot
func NewWritableSnapshot ¶
func NewWritableSnapshot() *Snapshot
func ReadSnapshotData ¶
func (*Snapshot) AddAccount ¶
func (s *Snapshot) AddAccount(address types.Address, account *account.StateAccount)
func (*Snapshot) AddStorage ¶
func (*Snapshot) ReadAccountData ¶
func (*Snapshot) ReadAccountStorage ¶
type StateReader ¶
type StateReader interface { ReadAccountData(address types.Address) (*account.StateAccount, error) ReadAccountStorage(address types.Address, incarnation uint16, key *types.Hash) ([]byte, error) ReadAccountCode(address types.Address, incarnation uint16, codeHash types.Hash) ([]byte, error) ReadAccountCodeSize(address types.Address, incarnation uint16, codeHash types.Hash) (int, error) ReadAccountIncarnation(address types.Address) (uint16, error) }
type StateTracer ¶
type StateWriter ¶
type StateWriter interface { UpdateAccountData(address types.Address, original, account *account.StateAccount) error UpdateAccountCode(address types.Address, incarnation uint16, codeHash types.Hash, code []byte) error DeleteAccount(address types.Address, original *account.StateAccount) error WriteAccountStorage(address types.Address, incarnation uint16, key *types.Hash, original, value *uint256.Int) error CreateContract(address types.Address) error }
type WriterWithChangeSets ¶
type WriterWithChangeSets interface { StateWriter WriteChangeSets() error WriteHistory() error }