Documentation
¶
Overview ¶
Package state provides a caching layer atop the Ethereum state trie.
Index ¶
- func CreateBloom(receipts EvmReceipts) *types.Bloom
- func InnerAccountChanged(account0 *InnerAccount, account1 *InnerAccount) bool
- type AccessList
- func (al *AccessList) AddAddress(address types.Address) bool
- func (al *AccessList) AddSlot(address types.Address, slot types.Hash) (bool, bool)
- func (al *AccessList) Contains(addr types.Address, slot types.Hash) (bool, bool)
- func (al *AccessList) ContainsAddress(addr types.Address) bool
- func (al *AccessList) Copy() *AccessList
- func (al *AccessList) DeleteAddress(address types.Address)
- func (al *AccessList) DeleteSlot(address types.Address, slot types.Hash)
- type AccessTuple
- type AccessTupleList
- type Account
- type ChainLedger
- type Code
- type ComplexStateLedger
- func (s *ComplexStateLedger) AddAddressToAccessList(addr types2.Address)
- func (l *ComplexStateLedger) AddAddressToEVMAccessList(addr common.Address)
- func (s *ComplexStateLedger) AddBalance(addr *types2.Address, amount *big.Int)
- func (l *ComplexStateLedger) AddEVMBalance(addr common.Address, amount *big.Int)
- func (l *ComplexStateLedger) AddEVMLog(log *etherTypes.Log)
- func (l *ComplexStateLedger) AddEVMPreimage(hash common.Hash, data []byte)
- func (l *ComplexStateLedger) AddEVMRefund(gas uint64)
- func (s *ComplexStateLedger) AddEvent(event *pb.Event)
- func (s *ComplexStateLedger) AddLog(log *pb.EvmLog)
- func (s *ComplexStateLedger) AddPreimage(hash types2.Hash, preimage []byte)
- func (s *ComplexStateLedger) AddRefund(gas uint64)
- func (s *ComplexStateLedger) AddSlotToAccessList(addr types2.Address, slot types2.Hash)
- func (l *ComplexStateLedger) AddSlotToEVMAccessList(addr common.Address, slot common.Hash)
- func (s *ComplexStateLedger) AddState(address *types2.Address, key []byte, value []byte)
- func (s *ComplexStateLedger) AddressInAccessList(addr types2.Address) bool
- func (l *ComplexStateLedger) AddressInEVMAccessList(addr common.Address) bool
- func (s *ComplexStateLedger) Clear()
- func (s *ComplexStateLedger) ClearChangerAndRefund()
- func (s *ComplexStateLedger) Close()
- func (s *ComplexStateLedger) Commit(height uint64, accounts map[string]IAccount, stateRoot *types2.Hash) error
- func (s *ComplexStateLedger) Copy() StateLedger
- func (l *ComplexStateLedger) CreateEVMAccount(addr common.Address)
- func (s *ComplexStateLedger) Database() state.Database
- func (s *ComplexStateLedger) Empty(addr *types2.Address) bool
- func (l *ComplexStateLedger) EmptyEVM(addr common.Address) bool
- func (s *ComplexStateLedger) Error() error
- func (s *ComplexStateLedger) Events(txHash string) []*pb.Event
- func (s *ComplexStateLedger) Exist(addr *types2.Address) bool
- func (l *ComplexStateLedger) ExistEVM(addr common.Address) bool
- func (s *ComplexStateLedger) Finalise(deleteEmptyObjects bool)
- func (s *ComplexStateLedger) FlushDirtyData() (map[string]IAccount, *types2.Hash)
- func (s *ComplexStateLedger) GetAccount(address *types2.Address) IAccount
- func (s *ComplexStateLedger) GetBalance(address *types2.Address) *big.Int
- func (s *ComplexStateLedger) GetCode(address *types2.Address) []byte
- func (s *ComplexStateLedger) GetCodeHash(addr *types2.Address) common.Hash
- func (s *ComplexStateLedger) GetCodeSize(addr *types2.Address) int
- func (s *ComplexStateLedger) GetCommittedState(addr *types2.Address, key []byte) []byte
- func (l *ComplexStateLedger) GetEVMBalance(addr common.Address) *big.Int
- func (l *ComplexStateLedger) GetEVMCode(addr common.Address) []byte
- func (l *ComplexStateLedger) GetEVMCodeHash(addr common.Address) common.Hash
- func (l *ComplexStateLedger) GetEVMCodeSize(addr common.Address) int
- func (l *ComplexStateLedger) GetEVMCommittedState(addr common.Address, hash common.Hash) common.Hash
- func (l *ComplexStateLedger) GetEVMNonce(addr common.Address) uint64
- func (l *ComplexStateLedger) GetEVMRefund() uint64
- func (l *ComplexStateLedger) GetEVMState(addr common.Address, hash common.Hash) common.Hash
- func (s *ComplexStateLedger) GetLogs(hash types2.Hash) []*pb.EvmLog
- func (l *ComplexStateLedger) GetMaxHeight() uint64
- func (s *ComplexStateLedger) GetNonce(address *types2.Address) uint64
- func (s *ComplexStateLedger) GetOrCreateAccount(address *types2.Address) IAccount
- func (s *ComplexStateLedger) GetRefund() uint64
- func (s *ComplexStateLedger) GetState(address *types2.Address, key []byte) (bool, []byte)
- func (s *ComplexStateLedger) HasSuicided(addr *types2.Address) bool
- func (l *ComplexStateLedger) HasSuisideEVM(addr common.Address) bool
- func (s *ComplexStateLedger) IntermediateRoot(deleteEmptyObjects bool) common.Hash
- func (s *ComplexStateLedger) PrepareAccessList(sender types2.Address, dst *types2.Address, precompiles []types2.Address, ...)
- func (s *ComplexStateLedger) PrepareBlock(hash *types2.Hash, height uint64)
- func (l *ComplexStateLedger) PrepareEVM(hash common.Hash, index int)
- func (l *ComplexStateLedger) PrepareEVMAccessList(sender common.Address, dest *common.Address, preEVMcompiles []common.Address, ...)
- func (s *ComplexStateLedger) QueryByPrefix(address *types2.Address, prefix string) (bool, [][]byte)
- func (s *ComplexStateLedger) RevertToSnapshot(revid int)
- func (s *ComplexStateLedger) Rollback(height uint64) error
- func (l *ComplexStateLedger) RollbackState(height uint64) error
- func (s *ComplexStateLedger) SetBalance(address *types2.Address, b *big.Int)
- func (s *ComplexStateLedger) SetCode(address *types2.Address, code []byte)
- func (l *ComplexStateLedger) SetEVMCode(addr common.Address, code []byte)
- func (l *ComplexStateLedger) SetEVMNonce(addr common.Address, nonce uint64)
- func (l *ComplexStateLedger) SetEVMState(addr common.Address, key, value common.Hash)
- func (s *ComplexStateLedger) SetNonce(address *types2.Address, nonce uint64)
- func (s *ComplexStateLedger) SetState(address *types2.Address, key []byte, value []byte)
- func (s *ComplexStateLedger) SlotInAccessList(addr types2.Address, slot types2.Hash) (addressPresent bool, slotPresent bool)
- func (l *ComplexStateLedger) SlotInEVMAceessList(addr common.Address, slot common.Hash) (bool, bool)
- func (s *ComplexStateLedger) Snapshot() int
- func (s *ComplexStateLedger) StateAt(root *types2.Hash) (*ComplexStateLedger, error)
- func (l *ComplexStateLedger) StateDB() StateDB
- func (s *ComplexStateLedger) StorageTrie(addr *types2.Address) state.Trie
- func (s *ComplexStateLedger) SubBalance(addr *types2.Address, amount *big.Int)
- func (l *ComplexStateLedger) SubEVMBalance(addr common.Address, amount *big.Int)
- func (l *ComplexStateLedger) SubEVMRefund(gas uint64)
- func (s *ComplexStateLedger) SubRefund(gas uint64)
- func (s *ComplexStateLedger) Suicide(addr *types2.Address) bool
- func (l *ComplexStateLedger) SuisideEVM(addr common.Address) bool
- func (s *ComplexStateLedger) Version() uint64
- type EvmReceipts
- type IAccount
- type InnerAccount
- type StateAccessor
- type StateDB
- type StateLedger
- type StateObject
- func (s *StateObject) AddBalance(amount *big.Int)
- func (s *StateObject) AddState(key []byte, value []byte)
- func (s *StateObject) Code() []byte
- func (s *StateObject) CodeHash() []byte
- func (s *StateObject) CodeSize(db state.Database) int
- func (s *StateObject) CommitTrie(db state.Database) error
- func (s *StateObject) GetAddress() *types2.Address
- func (s *StateObject) GetBalance() *big.Int
- func (s *StateObject) GetCommittedState(key []byte) []byte
- func (s *StateObject) GetDirtyStates() Storage
- func (s *StateObject) GetNonce() uint64
- func (s *StateObject) GetState(key []byte) (bool, []byte)
- func (s *StateObject) IsEmpty() bool
- func (s *StateObject) Query(prefix string) (bool, [][]byte)
- func (s *StateObject) SetBalance(amount *big.Int)
- func (s *StateObject) SetCodeAndHash(code []byte)
- func (s *StateObject) SetNonce(nonce uint64)
- func (s *StateObject) SetState(key []byte, value []byte)
- func (s *StateObject) SetSuicided(b bool)
- func (s *StateObject) SubBalance(amount *big.Int)
- func (s *StateObject) Suicided() bool
- type Storage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateBloom ¶
func CreateBloom(receipts EvmReceipts) *types.Bloom
func InnerAccountChanged ¶
func InnerAccountChanged(account0 *InnerAccount, account1 *InnerAccount) bool
Types ¶
type AccessList ¶
type AccessList struct {
// contains filtered or unexported fields
}
func NewAccessList ¶
func NewAccessList() *AccessList
func (*AccessList) AddAddress ¶
func (al *AccessList) AddAddress(address types.Address) bool
func (*AccessList) ContainsAddress ¶
func (al *AccessList) ContainsAddress(addr types.Address) bool
func (*AccessList) Copy ¶
func (al *AccessList) Copy() *AccessList
func (*AccessList) DeleteAddress ¶
func (al *AccessList) DeleteAddress(address types.Address)
func (*AccessList) DeleteSlot ¶
func (al *AccessList) DeleteSlot(address types.Address, slot types.Hash)
type AccessTuple ¶
type AccessTupleList ¶
type AccessTupleList []AccessTuple
func (AccessTupleList) StorageKeys ¶
func (al AccessTupleList) StorageKeys() int
type Account ¶
type Account struct { Nonce uint64 Balance *big.Int Root common.Hash // merkle root of the storage trie CodeHash []byte }
Account is the Ethereum consensus representation of accounts. These objects are stored in the main account trie.
type ChainLedger ¶
type ChainLedger interface { // PutBlock put block into store PutBlock(height uint64, block *pb.Block) error // GetBlock get block with height GetBlock(height uint64) (*pb.Block, error) // GetBlockSign get the signature of block GetBlockSign(height uint64) ([]byte, error) // GetBlockByHash get the block using block hash GetBlockByHash(hash *types.Hash) (*pb.Block, error) // GetTransaction get the transaction using transaction hash GetTransaction(hash *types.Hash) (pb.Transaction, error) // GetTransactionMeta get the transaction meta data GetTransactionMeta(hash *types.Hash) (*pb.TransactionMeta, error) // GetReceipt get the transaction receipt GetReceipt(hash *types.Hash) (*pb.Receipt, error) // GetInterchainMeta get interchain meta data GetInterchainMeta(height uint64) (*pb.InterchainMeta, error) // PersistExecutionResult persist the execution result PersistExecutionResult(block *pb.Block, receipts []*pb.Receipt, meta *pb.InterchainMeta) error // GetChainMeta get chain meta data GetChainMeta() *pb.ChainMeta // UpdateChainMeta update the chain meta data UpdateChainMeta(*pb.ChainMeta) // LoadChainMeta get chain meta data LoadChainMeta() *pb.ChainMeta // GetTxCountInBlock get the transaction count in a block GetTransactionCount(height uint64) (uint64, error) RollbackBlockChain(height uint64) error GetBlockHash(height uint64) *types.Hash Close() }
BlockchainLedger handles block, transaction and receipt data.
type ComplexStateLedger ¶
type ComplexStateLedger struct {
// contains filtered or unexported fields
}
ComplexStateLedger 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 New ¶
func New(root *types2.Hash, db state.Database, logger logrus.FieldLogger) (*ComplexStateLedger, error)
New creates a new state from a given trie.
func (*ComplexStateLedger) AddAddressToAccessList ¶
func (s *ComplexStateLedger) AddAddressToAccessList(addr types2.Address)
AddAddressToAccessList adds the given address to the access list
func (*ComplexStateLedger) AddAddressToEVMAccessList ¶
func (l *ComplexStateLedger) AddAddressToEVMAccessList(addr common.Address)
func (*ComplexStateLedger) AddBalance ¶
func (s *ComplexStateLedger) AddBalance(addr *types2.Address, amount *big.Int)
AddBalance adds amount to the account associated with addr.
func (*ComplexStateLedger) AddEVMBalance ¶
func (l *ComplexStateLedger) AddEVMBalance(addr common.Address, amount *big.Int)
func (*ComplexStateLedger) AddEVMLog ¶
func (l *ComplexStateLedger) AddEVMLog(log *etherTypes.Log)
func (*ComplexStateLedger) AddEVMPreimage ¶
func (l *ComplexStateLedger) AddEVMPreimage(hash common.Hash, data []byte)
func (*ComplexStateLedger) AddEVMRefund ¶
func (l *ComplexStateLedger) AddEVMRefund(gas uint64)
func (*ComplexStateLedger) AddEvent ¶
func (s *ComplexStateLedger) AddEvent(event *pb.Event)
func (*ComplexStateLedger) AddLog ¶
func (s *ComplexStateLedger) AddLog(log *pb.EvmLog)
func (*ComplexStateLedger) AddPreimage ¶
func (s *ComplexStateLedger) AddPreimage(hash types2.Hash, preimage []byte)
AddPreimage records a SHA3 preimage seen by the VM.
func (*ComplexStateLedger) AddRefund ¶
func (s *ComplexStateLedger) AddRefund(gas uint64)
AddRefund adds gas to the refund counter
func (*ComplexStateLedger) AddSlotToAccessList ¶
func (s *ComplexStateLedger) AddSlotToAccessList(addr types2.Address, slot types2.Hash)
AddSlotToAccessList adds the given (address, slot)-tuple to the access list
func (*ComplexStateLedger) AddSlotToEVMAccessList ¶
func (l *ComplexStateLedger) AddSlotToEVMAccessList(addr common.Address, slot common.Hash)
func (*ComplexStateLedger) AddState ¶
func (s *ComplexStateLedger) AddState(address *types2.Address, key []byte, value []byte)
func (*ComplexStateLedger) AddressInAccessList ¶
func (s *ComplexStateLedger) AddressInAccessList(addr types2.Address) bool
AddressInAccessList returns true if the given address is in the access list.
func (*ComplexStateLedger) AddressInEVMAccessList ¶
func (l *ComplexStateLedger) AddressInEVMAccessList(addr common.Address) bool
func (*ComplexStateLedger) Clear ¶
func (s *ComplexStateLedger) Clear()
func (*ComplexStateLedger) ClearChangerAndRefund ¶
func (s *ComplexStateLedger) ClearChangerAndRefund()
func (*ComplexStateLedger) Close ¶
func (s *ComplexStateLedger) Close()
func (*ComplexStateLedger) Commit ¶
func (s *ComplexStateLedger) Commit(height uint64, accounts map[string]IAccount, stateRoot *types2.Hash) error
Commit writes the state to the underlying in-memory trie database.
func (*ComplexStateLedger) Copy ¶
func (s *ComplexStateLedger) Copy() StateLedger
func (*ComplexStateLedger) CreateEVMAccount ¶
func (l *ComplexStateLedger) CreateEVMAccount(addr common.Address)
func (*ComplexStateLedger) Database ¶
func (s *ComplexStateLedger) Database() state.Database
Database retrieves the low level database supporting the lower level trie ops.
func (*ComplexStateLedger) Empty ¶
func (s *ComplexStateLedger) Empty(addr *types2.Address) bool
Empty returns whether the state object is either non-existent or empty according to the EIP161 specification (balance = nonce = code = 0)
func (*ComplexStateLedger) EmptyEVM ¶
func (l *ComplexStateLedger) EmptyEVM(addr common.Address) bool
func (*ComplexStateLedger) Error ¶
func (s *ComplexStateLedger) Error() error
func (*ComplexStateLedger) Exist ¶
func (s *ComplexStateLedger) Exist(addr *types2.Address) bool
Exist reports whether the given account address exists in the state. Notably this also returns true for suicided accounts.
func (*ComplexStateLedger) ExistEVM ¶
func (l *ComplexStateLedger) ExistEVM(addr common.Address) bool
func (*ComplexStateLedger) Finalise ¶
func (s *ComplexStateLedger) Finalise(deleteEmptyObjects bool)
Finalise finalises the state by removing the s destructed objects and clears the journal as well as the refunds. Finalise, however, will not push any updates into the tries just yet. Only IntermediateRoot or Commit will do that.
func (*ComplexStateLedger) FlushDirtyData ¶
func (s *ComplexStateLedger) FlushDirtyData() (map[string]IAccount, *types2.Hash)
func (*ComplexStateLedger) GetAccount ¶
func (s *ComplexStateLedger) GetAccount(address *types2.Address) IAccount
func (*ComplexStateLedger) GetBalance ¶
func (s *ComplexStateLedger) GetBalance(address *types2.Address) *big.Int
func (*ComplexStateLedger) GetCode ¶
func (s *ComplexStateLedger) GetCode(address *types2.Address) []byte
func (*ComplexStateLedger) GetCodeHash ¶
func (s *ComplexStateLedger) GetCodeHash(addr *types2.Address) common.Hash
func (*ComplexStateLedger) GetCodeSize ¶
func (s *ComplexStateLedger) GetCodeSize(addr *types2.Address) int
func (*ComplexStateLedger) GetCommittedState ¶
func (s *ComplexStateLedger) GetCommittedState(addr *types2.Address, key []byte) []byte
GetCommittedState retrieves a value from the given account's committed storage trie.
func (*ComplexStateLedger) GetEVMBalance ¶
func (l *ComplexStateLedger) GetEVMBalance(addr common.Address) *big.Int
func (*ComplexStateLedger) GetEVMCode ¶
func (l *ComplexStateLedger) GetEVMCode(addr common.Address) []byte
func (*ComplexStateLedger) GetEVMCodeHash ¶
func (l *ComplexStateLedger) GetEVMCodeHash(addr common.Address) common.Hash
func (*ComplexStateLedger) GetEVMCodeSize ¶
func (l *ComplexStateLedger) GetEVMCodeSize(addr common.Address) int
func (*ComplexStateLedger) GetEVMCommittedState ¶
func (*ComplexStateLedger) GetEVMNonce ¶
func (l *ComplexStateLedger) GetEVMNonce(addr common.Address) uint64
func (*ComplexStateLedger) GetEVMRefund ¶
func (l *ComplexStateLedger) GetEVMRefund() uint64
func (*ComplexStateLedger) GetEVMState ¶
func (*ComplexStateLedger) GetLogs ¶
func (s *ComplexStateLedger) GetLogs(hash types2.Hash) []*pb.EvmLog
func (*ComplexStateLedger) GetMaxHeight ¶
func (l *ComplexStateLedger) GetMaxHeight() uint64
func (*ComplexStateLedger) GetNonce ¶
func (s *ComplexStateLedger) GetNonce(address *types2.Address) uint64
func (*ComplexStateLedger) GetOrCreateAccount ¶
func (s *ComplexStateLedger) GetOrCreateAccount(address *types2.Address) IAccount
func (*ComplexStateLedger) GetRefund ¶
func (s *ComplexStateLedger) GetRefund() uint64
GetRefund returns the current value of the refund counter.
func (*ComplexStateLedger) HasSuicided ¶
func (s *ComplexStateLedger) HasSuicided(addr *types2.Address) bool
func (*ComplexStateLedger) HasSuisideEVM ¶
func (l *ComplexStateLedger) HasSuisideEVM(addr common.Address) bool
func (*ComplexStateLedger) IntermediateRoot ¶
func (s *ComplexStateLedger) IntermediateRoot(deleteEmptyObjects bool) common.Hash
IntermediateRoot computes the current root hash of the state trie. It is called in between transactions to get the root hash that goes into transaction receipts.
func (*ComplexStateLedger) PrepareAccessList ¶
func (s *ComplexStateLedger) PrepareAccessList(sender types2.Address, dst *types2.Address, precompiles []types2.Address, list AccessTupleList)
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 (*ComplexStateLedger) PrepareBlock ¶
func (s *ComplexStateLedger) PrepareBlock(hash *types2.Hash, height uint64)
func (*ComplexStateLedger) PrepareEVM ¶
func (l *ComplexStateLedger) PrepareEVM(hash common.Hash, index int)
func (*ComplexStateLedger) PrepareEVMAccessList ¶
func (l *ComplexStateLedger) PrepareEVMAccessList(sender common.Address, dest *common.Address, preEVMcompiles []common.Address, txEVMAccesses etherTypes.AccessList)
func (*ComplexStateLedger) QueryByPrefix ¶
func (*ComplexStateLedger) RevertToSnapshot ¶
func (s *ComplexStateLedger) RevertToSnapshot(revid int)
RevertToSnapshot reverts all state changes made since the given revision.
func (*ComplexStateLedger) Rollback ¶
func (s *ComplexStateLedger) Rollback(height uint64) error
func (*ComplexStateLedger) RollbackState ¶
func (l *ComplexStateLedger) RollbackState(height uint64) error
func (*ComplexStateLedger) SetBalance ¶
func (s *ComplexStateLedger) SetBalance(address *types2.Address, b *big.Int)
func (*ComplexStateLedger) SetCode ¶
func (s *ComplexStateLedger) SetCode(address *types2.Address, code []byte)
func (*ComplexStateLedger) SetEVMCode ¶
func (l *ComplexStateLedger) SetEVMCode(addr common.Address, code []byte)
func (*ComplexStateLedger) SetEVMNonce ¶
func (l *ComplexStateLedger) SetEVMNonce(addr common.Address, nonce uint64)
func (*ComplexStateLedger) SetEVMState ¶
func (l *ComplexStateLedger) SetEVMState(addr common.Address, key, value common.Hash)
func (*ComplexStateLedger) SetNonce ¶
func (s *ComplexStateLedger) SetNonce(address *types2.Address, nonce uint64)
func (*ComplexStateLedger) SetState ¶
func (s *ComplexStateLedger) SetState(address *types2.Address, key []byte, value []byte)
func (*ComplexStateLedger) SlotInAccessList ¶
func (s *ComplexStateLedger) SlotInAccessList(addr types2.Address, slot types2.Hash) (addressPresent bool, slotPresent bool)
SlotInAccessList returns true if the given (address, slot)-tuple is in the access list.
func (*ComplexStateLedger) SlotInEVMAceessList ¶
func (*ComplexStateLedger) Snapshot ¶
func (s *ComplexStateLedger) Snapshot() int
Snapshot returns an identifier for the current revision of the state.
func (*ComplexStateLedger) StateAt ¶
func (s *ComplexStateLedger) StateAt(root *types2.Hash) (*ComplexStateLedger, error)
func (*ComplexStateLedger) StateDB ¶
func (l *ComplexStateLedger) StateDB() StateDB
func (*ComplexStateLedger) StorageTrie ¶
func (s *ComplexStateLedger) StorageTrie(addr *types2.Address) state.Trie
StorageTrie returns the storage trie of an account. The return value is a copy and is nil for non-existent accounts.
func (*ComplexStateLedger) SubBalance ¶
func (s *ComplexStateLedger) SubBalance(addr *types2.Address, amount *big.Int)
SubBalance subtracts amount from the account associated with addr.
func (*ComplexStateLedger) SubEVMBalance ¶
func (l *ComplexStateLedger) SubEVMBalance(addr common.Address, amount *big.Int)
func (*ComplexStateLedger) SubEVMRefund ¶
func (l *ComplexStateLedger) SubEVMRefund(gas uint64)
func (*ComplexStateLedger) SubRefund ¶
func (s *ComplexStateLedger) SubRefund(gas uint64)
SubRefund removes gas from the refund counter. This method will panic if the refund counter goes below zero
func (*ComplexStateLedger) Suicide ¶
func (s *ComplexStateLedger) Suicide(addr *types2.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 (*ComplexStateLedger) SuisideEVM ¶
func (l *ComplexStateLedger) SuisideEVM(addr common.Address) bool
func (*ComplexStateLedger) Version ¶
func (s *ComplexStateLedger) Version() uint64
type EvmReceipts ¶
type IAccount ¶
type IAccount interface { GetAddress() *types.Address GetState(key []byte) (bool, []byte) GetCommittedState(key []byte) []byte SetState(key []byte, value []byte) AddState(key []byte, value []byte) SetCodeAndHash(code []byte) Code() []byte CodeHash() []byte SetNonce(nonce uint64) GetNonce() uint64 GetBalance() *big.Int SetBalance(balance *big.Int) SubBalance(amount *big.Int) AddBalance(amount *big.Int) Query(prefix string) (bool, [][]byte) IsEmpty() bool Suicided() bool SetSuicided(bool) }
type InnerAccount ¶
type InnerAccount struct { Nonce uint64 `json:"nonce"` Balance *big.Int `json:"balance"` CodeHash []byte `json:"code_hash"` }
func CopyOrNewIfEmpty ¶
func CopyOrNewIfEmpty(o *InnerAccount) *InnerAccount
func (*InnerAccount) Marshal ¶
func (o *InnerAccount) Marshal() ([]byte, error)
Marshal Marshal the account into byte
func (*InnerAccount) Unmarshal ¶
func (o *InnerAccount) Unmarshal(data []byte) error
Unmarshal Unmarshal the account byte into structure
type StateAccessor ¶
type StateAccessor interface { // GetOrCreateAccount GetOrCreateAccount(*types.Address) IAccount // GetAccount GetAccount(*types.Address) IAccount // GetBalance GetBalance(*types.Address) *big.Int // SetBalance SetBalance(*types.Address, *big.Int) // GetState GetState(*types.Address, []byte) (bool, []byte) // SetState SetState(*types.Address, []byte, []byte) // AddState AddState(*types.Address, []byte, []byte) // SetCode SetCode(*types.Address, []byte) // GetCode GetCode(*types.Address) []byte // SetNonce SetNonce(*types.Address, uint64) // GetNonce GetNonce(*types.Address) uint64 // QueryByPrefix QueryByPrefix(address *types.Address, prefix string) (bool, [][]byte) // Commit commits the state data Commit(height uint64, accounts map[string]IAccount, stateRoot *types.Hash) error // FlushDirtyData flushes the dirty data FlushDirtyData() (map[string]IAccount, *types.Hash) // Clear Clear() }
StateAccessor manipulates the state data
type StateDB ¶
type StateDB interface { CreateEVMAccount(common.Address) SubEVMBalance(common.Address, *big.Int) AddEVMBalance(common.Address, *big.Int) GetEVMBalance(common.Address) *big.Int GetEVMNonce(common.Address) uint64 SetEVMNonce(common.Address, uint64) GetEVMCodeHash(common.Address) common.Hash GetEVMCode(common.Address) []byte SetEVMCode(common.Address, []byte) GetEVMCodeSize(common.Address) int AddEVMRefund(uint64) SubEVMRefund(uint64) GetEVMRefund() uint64 GetEVMCommittedState(common.Address, common.Hash) common.Hash GetEVMState(common.Address, common.Hash) common.Hash SetEVMState(common.Address, common.Hash, common.Hash) SuisideEVM(common.Address) bool HasSuisideEVM(common.Address) bool // Exist reports whether the given Account exists in state. // Notably this should also return true for suicided accounts. ExistEVM(common.Address) bool // Empty returns whether the given Account is empty. Empty // is defined according to EIP161 (balance = nonce = code = 0). EmptyEVM(common.Address) bool PrepareEVMAccessList(sender common.Address, dest *common.Address, precompiles []common.Address, txAccesses types2.AccessList) AddressInEVMAccessList(addr common.Address) bool SlotInEVMAceessList(addr common.Address, slot common.Hash) (addressOk bool, slotOk bool) // AddAddressToAccessList adds the given address to the access list. This operation is safe to perform // even if the feature/fork is not active yet AddAddressToEVMAccessList(addr common.Address) // AddSlotToAccessList adds the given (address,slot) to the access list. This operation is safe to perform // even if the feature/fork is not active yet AddSlotToEVMAccessList(addr common.Address, slot common.Hash) RevertToSnapshot(int) Snapshot() int AddEVMLog(log *types2.Log) AddEVMPreimage(common.Hash, []byte) //GetBlockEVMHash(uint64) common.Hash PrepareEVM(common.Hash, int) }
StateDB is an EVM database for full state querying.
type StateLedger ¶
type StateLedger interface { StateAccessor StateDB // AddEvent AddEvent(*pb.Event) // Events Events(txHash string) []*pb.Event AddLog(log *pb.EvmLog) GetLogs(types.Hash) []*pb.EvmLog // Rollback RollbackState(height uint64) error PrepareBlock(*types.Hash, uint64) ClearChangerAndRefund() // Close release resource Close() Copy() StateLedger Finalise(bool) // Version Version() uint64 }
type StateObject ¶
type StateObject struct {
// contains filtered or unexported fields
}
StateObject represents an Ethereum account which is being modified.
The usage pattern is as follows: First you need to obtain a state object. Account values can be accessed and modified through the object. Finally, call CommitTrie to write the modified storage trie into a database.
func (*StateObject) AddBalance ¶
func (s *StateObject) AddBalance(amount *big.Int)
AddBalance adds amount to s's balance. It is used to add funds to the destination account of a transfer.
func (*StateObject) AddState ¶
func (s *StateObject) AddState(key []byte, value []byte)
func (*StateObject) Code ¶
func (s *StateObject) Code() []byte
func (*StateObject) CodeHash ¶
func (s *StateObject) CodeHash() []byte
func (*StateObject) CodeSize ¶
func (s *StateObject) CodeSize(db state.Database) int
CodeSize returns the size of the contract code associated with this object, or zero if none. This method is an almost mirror of Code, but uses a cache inside the database to avoid loading codes seen recently.
func (*StateObject) CommitTrie ¶
func (s *StateObject) CommitTrie(db state.Database) error
CommitTrie the storage trie of the object to db. This updates the trie root.
func (*StateObject) GetAddress ¶
func (s *StateObject) GetAddress() *types2.Address
func (*StateObject) GetBalance ¶
func (s *StateObject) GetBalance() *big.Int
func (*StateObject) GetCommittedState ¶
func (s *StateObject) GetCommittedState(key []byte) []byte
func (*StateObject) GetDirtyStates ¶
func (s *StateObject) GetDirtyStates() Storage
func (*StateObject) GetNonce ¶
func (s *StateObject) GetNonce() uint64
func (*StateObject) IsEmpty ¶
func (s *StateObject) IsEmpty() bool
func (*StateObject) SetBalance ¶
func (s *StateObject) SetBalance(amount *big.Int)
func (*StateObject) SetCodeAndHash ¶
func (s *StateObject) SetCodeAndHash(code []byte)
func (*StateObject) SetNonce ¶
func (s *StateObject) SetNonce(nonce uint64)
func (*StateObject) SetState ¶
func (s *StateObject) SetState(key []byte, value []byte)
func (*StateObject) SetSuicided ¶
func (s *StateObject) SetSuicided(b bool)
func (*StateObject) SubBalance ¶
func (s *StateObject) SubBalance(amount *big.Int)
SubBalance removes amount from s's balance. It is used to remove funds from the origin account of a transfer.
func (*StateObject) Suicided ¶
func (s *StateObject) Suicided() bool