Documentation ¶
Overview ¶
Package state provides a caching layer atop the Ethereum state trie.
Index ¶
- Variables
- func FwMarshal(fw FwData) []byte
- func GetKeyTrie(address common.Address, key []byte) string
- func GetKeyTrieValueKey(address common.Address, key []byte, value []byte) (string, common.Hash)
- func NewStateSync(root common.Hash, database trie.DatabaseReader) *trie.Sync
- type Abi
- type Account
- type Action
- type BalanceOp
- type BalanceSet
- type CallSimulator
- func (txSim *CallSimulator) AddBalance(addr common.Address, amount *big.Int)
- func (txSim *CallSimulator) AddLog(log *types.Log)
- func (txSim *CallSimulator) AddNonce(address common.Address)
- func (txSim *CallSimulator) AddPreimage(hash common.Hash, bytes []byte)
- func (txSim *CallSimulator) AddRefund(u uint64)
- func (txSim *CallSimulator) CloneAccount(src common.Address, dest common.Address) error
- func (txSim *CallSimulator) CloseFirewall(contractAddr common.Address)
- func (txSim *CallSimulator) CreateAccount(address common.Address)
- func (txSim *CallSimulator) Empty(address common.Address) bool
- func (txSim *CallSimulator) Exist(address common.Address) bool
- func (txSim *CallSimulator) ForEachStorage(address common.Address, f func(common.Hash, common.Hash) bool)
- func (txSim *CallSimulator) FwAdd(contractAddr common.Address, action Action, list []FwElem)
- func (txSim *CallSimulator) FwClear(contractAddr common.Address, action Action)
- func (txSim *CallSimulator) FwDel(contractAddr common.Address, action Action, list []FwElem)
- func (txSim *CallSimulator) FwImport(contractAddr common.Address, data []byte) error
- func (txSim *CallSimulator) FwSet(contractAddr common.Address, action Action, list []FwElem)
- func (txSim *CallSimulator) GetAbi(address common.Address) []byte
- func (txSim *CallSimulator) GetAbiHash(address common.Address) common.Hash
- func (txSim *CallSimulator) GetBalance(addr common.Address) *big.Int
- func (txSim *CallSimulator) GetCode(addr common.Address) []byte
- func (txSim *CallSimulator) GetCodeHash(address common.Address) common.Hash
- func (txSim *CallSimulator) GetCodeSize(address common.Address) int
- func (txSim *CallSimulator) GetCommittedState(address common.Address, key []byte) []byte
- func (txSim *CallSimulator) GetContractCreator(contractAddr common.Address) common.Address
- func (txSim *CallSimulator) GetFwStatus(contractAddr common.Address) FwStatus
- func (txSim *CallSimulator) GetLogs(hash common.Hash) []*types.Log
- func (txSim *CallSimulator) GetNonce(address common.Address) uint64
- func (txSim *CallSimulator) GetRefund() uint64
- func (txSim *CallSimulator) GetState(addr common.Address, key []byte) []byte
- func (txSim *CallSimulator) HasSuicided(address common.Address) bool
- func (txSim *CallSimulator) IsFwOpened(contractAddr common.Address) bool
- func (txSim *CallSimulator) Logs() []*types.Log
- func (txSim *CallSimulator) OpenFirewall(contractAddr common.Address)
- func (txSim *CallSimulator) RevertToSnapshot(i int)
- func (txSim *CallSimulator) SetAbi(address common.Address, bytes []byte)
- func (txSim *CallSimulator) SetBalance(addr common.Address, amount *big.Int)
- func (txSim *CallSimulator) SetCode(address common.Address, bytes []byte)
- func (txSim *CallSimulator) SetContractCreator(contractAddr common.Address, creator common.Address)
- func (txSim *CallSimulator) SetFwStatus(contractAddr common.Address, status FwStatus)
- func (txSim *CallSimulator) SetNonce(address common.Address, u uint64)
- func (txSim *CallSimulator) SetState(addr common.Address, key, value []byte)
- func (txSim *CallSimulator) Snapshot() int
- func (txSim *CallSimulator) SubBalance(addr common.Address, amount *big.Int)
- func (txSim *CallSimulator) SubRefund(u uint64)
- func (txSim *CallSimulator) Suicide(address common.Address) bool
- type Code
- type CreateAccount
- type Database
- type Dump
- type DumpAccount
- type FwData
- type FwElem
- type FwElems
- type FwStatus
- type ManagedState
- func (ms *ManagedState) GetNonce(addr common.Address) uint64
- func (ms *ManagedState) HasAccount(addr common.Address) bool
- func (ms *ManagedState) NewNonce(addr common.Address) uint64
- func (ms *ManagedState) RemoveNonce(addr common.Address, n uint64)
- func (ms *ManagedState) SetNonce(addr common.Address, nonce uint64)
- func (ms *ManagedState) SetState(statedb *StateDB)
- type NodeIterator
- type ObjectChange
- type ReadOp
- type ReadSet
- type SetAbi
- type SetCode
- type SetCreator
- type SetFwActive
- type SetFwData
- type StateDB
- func (self *StateDB) AddBalance(addr common.Address, amount *big.Int)
- func (self *StateDB) AddLog(log *types.Log)
- func (self *StateDB) AddNonce(addr common.Address)
- func (self *StateDB) AddPreimage(hash common.Hash, preimage []byte)
- func (self *StateDB) AddRefund(gas uint64)
- func (self *StateDB) AddTxSim(txSim *TxSimulator, applyCh chan *TxSimulator, withDag bool) (bool, int)
- func (self *StateDB) ApplyTxSim(txSim *TxSimulator, isProposer bool)
- func (self *StateDB) CloneAccount(src common.Address, dest common.Address) error
- func (self *StateDB) CloseFirewall(addr common.Address)
- func (self *StateDB) Commit(deleteEmptyObjects bool) (root common.Hash, err error)
- func (self *StateDB) Copy() *StateDB
- func (self *StateDB) CreateAccount(addr common.Address)
- func (self *StateDB) Database() Database
- func (self *StateDB) Dump() []byte
- func (self *StateDB) Empty(addr common.Address) bool
- func (self *StateDB) Error() error
- func (self *StateDB) Exist(addr common.Address) bool
- func (self *StateDB) Finalise(deleteEmptyObjects bool)
- func (self *StateDB) ForEachStorage(addr common.Address, cb func(key, value common.Hash) bool)
- func (self *StateDB) FwAdd(addr common.Address, action Action, list []FwElem)
- func (self *StateDB) FwClear(addr common.Address, action Action)
- func (self *StateDB) FwDel(addr common.Address, action Action, list []FwElem)
- func (self *StateDB) FwImport(addr common.Address, data []byte) error
- func (self *StateDB) FwSet(addr common.Address, action Action, list []FwElem)
- func (self *StateDB) GetAbi(addr common.Address) []byte
- func (self *StateDB) GetAbiHash(addr common.Address) common.Hash
- func (self *StateDB) GetBalance(addr common.Address) *big.Int
- func (self *StateDB) GetBalanceByCache(addr common.Address) (*big.Int, bool)
- func (self *StateDB) GetByte(addr common.Address, key []byte) byte
- func (self *StateDB) GetCode(addr common.Address) []byte
- func (self *StateDB) GetCodeHash(addr common.Address) common.Hash
- func (self *StateDB) GetCodeSize(addr common.Address) int
- func (self *StateDB) GetCommittedState(addr common.Address, key []byte) []byte
- func (self *StateDB) GetContractCreator(addr common.Address) common.Address
- func (self *StateDB) GetDag() types.DAG
- func (self *StateDB) GetFloat32(addr common.Address, key []byte) float32
- func (self *StateDB) GetFloat64(addr common.Address, key []byte) float64
- func (self *StateDB) GetFwStatus(addr common.Address) FwStatus
- func (self *StateDB) GetGasUsed() uint64
- func (self *StateDB) GetInt32(addr common.Address, key []byte) int32
- func (self *StateDB) GetInt64(addr common.Address, key []byte) int64
- func (self *StateDB) GetLogs(hash common.Hash) []*types.Log
- func (self *StateDB) GetNonce(addr common.Address) uint64
- func (self *StateDB) GetOrNewStateObject(addr common.Address) *stateObject
- func (self *StateDB) GetOrNewStateObjectSafe(addr common.Address) *stateObject
- func (self *StateDB) GetReceiptHash() common.Hash
- func (self *StateDB) GetReceipts() types.Receipts
- func (self *StateDB) GetRefund() uint64
- func (self *StateDB) GetState(addr common.Address, key []byte) []byte
- func (self *StateDB) GetStateByCache(keyTrie string) ([]byte, bool)
- func (self *StateDB) GetStateByKeyTrie(addr common.Address, keyTrie string) []byte
- func (self *StateDB) GetString(addr common.Address, key []byte) string
- func (self *StateDB) GetTxHash() common.Hash
- func (self *StateDB) GetTxs() types.Transactions
- func (self *StateDB) GetTxsLen() int
- func (self *StateDB) HasSuicided(addr common.Address) bool
- func (self *StateDB) IntermediateRoot(deleteEmptyObjects bool) common.Hash
- func (self *StateDB) IsFwOpened(addr common.Address) bool
- func (self *StateDB) IsProcess() bool
- func (self *StateDB) Logs() []*types.Log
- func (self *StateDB) OpenFirewall(addr common.Address)
- func (self *StateDB) Preimages() map[common.Hash][]byte
- func (self *StateDB) Prepare(thash, bhash common.Hash, ti int)
- func (self *StateDB) RawDump() Dump
- func (self *StateDB) Reset(root common.Hash) error
- func (self *StateDB) RevertToSnapshot(revid int)
- func (self *StateDB) SetAbi(addr common.Address, abi []byte)
- func (self *StateDB) SetBalance(addr common.Address, amount *big.Int)
- func (self *StateDB) SetByte(addr common.Address, key []byte, value byte)
- func (self *StateDB) SetCode(addr common.Address, code []byte)
- func (self *StateDB) SetContractCreator(addr, creator common.Address)
- func (self *StateDB) SetDirty(address common.Address)
- func (self *StateDB) SetFloat32(addr common.Address, key []byte, value float32)
- func (self *StateDB) SetFloat64(addr common.Address, key []byte, value float64)
- func (self *StateDB) SetFwStatus(addr common.Address, status FwStatus)
- func (self *StateDB) SetHashGenerator()
- func (self *StateDB) SetInt32(addr common.Address, key []byte, value int32)
- func (self *StateDB) SetInt64(addr common.Address, key []byte, value int64)
- func (self *StateDB) SetNonce(addr common.Address, nonce uint64)
- func (self *StateDB) SetState(address common.Address, key, value []byte)
- func (self *StateDB) SetStateByCache(keyTrie string, read *ReadOp)
- func (self *StateDB) SetString(addr common.Address, key []byte, value string)
- func (self *StateDB) Snapshot() int
- func (self *StateDB) StartProcess()
- func (self *StateDB) StopProcess()
- func (self *StateDB) StorageTrie(addr common.Address) Trie
- func (self *StateDB) SubBalance(addr common.Address, amount *big.Int)
- func (self *StateDB) SubRefund(gas uint64)
- func (self *StateDB) Suicide(addr common.Address) bool
- func (self *StateDB) UpdateDirtyObject()
- func (self *StateDB) UpdateTrie(receipts []*types.Receipt, txs []*types.Transaction)
- type Storage
- type Suicide
- type Trie
- type TxSimulator
- func (txSim *TxSimulator) AddBalance(addr common.Address, amount *big.Int)
- func (txSim *TxSimulator) AddLog(log *types.Log)
- func (txSim *TxSimulator) AddNonce(address common.Address)
- func (txSim *TxSimulator) AddPreimage(hash common.Hash, bytes []byte)
- func (txSim *TxSimulator) AddRefund(u uint64)
- func (txSim *TxSimulator) CloneAccount(src common.Address, dest common.Address) error
- func (txSim *TxSimulator) CloseFirewall(contractAddr common.Address)
- func (txSim *TxSimulator) CreateAccount(address common.Address)
- func (txSim *TxSimulator) Empty(address common.Address) bool
- func (txSim *TxSimulator) Exist(address common.Address) bool
- func (txSim *TxSimulator) ForEachStorage(address common.Address, f func(common.Hash, common.Hash) bool)
- func (txSim *TxSimulator) FwAdd(contractAddr common.Address, action Action, list []FwElem)
- func (txSim *TxSimulator) FwClear(contractAddr common.Address, action Action)
- func (txSim *TxSimulator) FwDel(contractAddr common.Address, action Action, list []FwElem)
- func (txSim *TxSimulator) FwImport(contractAddr common.Address, data []byte) error
- func (txSim *TxSimulator) FwSet(contractAddr common.Address, action Action, list []FwElem)
- func (txSim *TxSimulator) GetAbi(address common.Address) []byte
- func (txSim *TxSimulator) GetAbiHash(address common.Address) common.Hash
- func (txSim *TxSimulator) GetBalance(addr common.Address) *big.Int
- func (txSim *TxSimulator) GetBalanceMap() map[common.Address]*BalanceOp
- func (txSim *TxSimulator) GetCode(addr common.Address) []byte
- func (txSim *TxSimulator) GetCodeHash(address common.Address) common.Hash
- func (txSim *TxSimulator) GetCodeSize(address common.Address) int
- func (txSim *TxSimulator) GetCommittedState(address common.Address, key []byte) []byte
- func (txSim *TxSimulator) GetContractCreator(contractAddr common.Address) common.Address
- func (txSim *TxSimulator) GetFwStatus(contractAddr common.Address) FwStatus
- func (txSim *TxSimulator) GetHash() common.Hash
- func (txSim *TxSimulator) GetIndex() int
- func (txSim *TxSimulator) GetLogs(hash common.Hash) []*types.Log
- func (txSim *TxSimulator) GetNonce(address common.Address) uint64
- func (txSim *TxSimulator) GetReadMap() map[string]*ReadOp
- func (txSim *TxSimulator) GetReceipt() *types.Receipt
- func (txSim *TxSimulator) GetRefund() uint64
- func (txSim *TxSimulator) GetState(addr common.Address, key []byte) []byte
- func (txSim *TxSimulator) GetWriteMap() map[string]*WriteOp
- func (txSim *TxSimulator) HasSuicided(address common.Address) bool
- func (txSim *TxSimulator) IsFwOpened(contractAddr common.Address) bool
- func (txSim *TxSimulator) Logs() []*types.Log
- func (txSim *TxSimulator) OpenFirewall(contractAddr common.Address)
- func (txSim *TxSimulator) ReTry() bool
- func (txSim *TxSimulator) RevertToSnapshot(i int)
- func (txSim *TxSimulator) SetAbi(address common.Address, bytes []byte)
- func (txSim *TxSimulator) SetBalance(addr common.Address, amount *big.Int)
- func (txSim *TxSimulator) SetCode(address common.Address, bytes []byte)
- func (txSim *TxSimulator) SetContractCreator(contractAddr common.Address, creator common.Address)
- func (txSim *TxSimulator) SetFwStatus(contractAddr common.Address, status FwStatus)
- func (txSim *TxSimulator) SetIndex(index int)
- func (txSim *TxSimulator) SetNonce(address common.Address, u uint64)
- func (txSim *TxSimulator) SetReceipt(rec *types.Receipt)
- func (txSim *TxSimulator) SetState(addr common.Address, key, value []byte)
- func (txSim *TxSimulator) Snapshot() int
- func (txSim *TxSimulator) SubBalance(addr common.Address, amount *big.Int)
- func (txSim *TxSimulator) SubRefund(u uint64)
- func (txSim *TxSimulator) Suicide(address common.Address) bool
- type ValueStorage
- type WriteOp
- type WriteSet
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidFwAction = errors.New("FW: error, action is invalid")
var FwWildchardAddr = common.HexToAddress("0xffffffffffffffffffffffffffffffffffffffff")
var MaxTrieCacheGen = uint16(120)
Trie cache generation limit after which to evict trie nodes from memory.
var (
StoragePrefix = "storage-value-"
)
Functions ¶
func GetKeyTrieValueKey ¶ added in v1.1.0
func NewStateSync ¶
NewStateSync create a new state trie download scheduler.
Types ¶
type Account ¶
type Account struct { Nonce uint64 FwActive uint64 Balance *big.Int Root common.Hash // merkle root of the storage trie CodeHash []byte AbiHash []byte Creator common.Address FwDataHash []byte }
Account is the Ethereum consensus representation of accounts. These objects are stored in the main account trie.
type BalanceSet ¶ added in v1.1.0
type BalanceSet []*BalanceOp
type CallSimulator ¶ added in v1.1.0
type CallSimulator struct {
// contains filtered or unexported fields
}
func NewCallSimulator ¶ added in v1.1.0
func NewCallSimulator(sdb *StateDB) *CallSimulator
func (*CallSimulator) AddBalance ¶ added in v1.1.0
func (txSim *CallSimulator) AddBalance(addr common.Address, amount *big.Int)
AddBalance 模拟交易的balance增加
func (*CallSimulator) AddLog ¶ added in v1.1.0
func (txSim *CallSimulator) AddLog(log *types.Log)
func (*CallSimulator) AddNonce ¶ added in v1.1.0
func (txSim *CallSimulator) AddNonce(address common.Address)
AddNonce 记录nonce有变更的地址,鉴于nonce的变更都是对原有的nonce+1,这里只记录需要变更的地址
func (*CallSimulator) AddPreimage ¶ added in v1.1.0
func (txSim *CallSimulator) AddPreimage(hash common.Hash, bytes []byte)
AddPreimage debug情况下用来记录sha3操作的中间值,不做处理
func (*CallSimulator) AddRefund ¶ added in v1.1.0
func (txSim *CallSimulator) AddRefund(u uint64)
func (*CallSimulator) CloneAccount ¶ added in v1.1.0
CloneAccount 用于合约的迁移,暂时不做处理
func (*CallSimulator) CloseFirewall ¶ added in v1.1.0
func (txSim *CallSimulator) CloseFirewall(contractAddr common.Address)
CloseFirewall 记录关闭防火墙的操作
func (*CallSimulator) CreateAccount ¶ added in v1.1.0
func (txSim *CallSimulator) CreateAccount(address common.Address)
CreateAccount 记录创建账户的操作
func (*CallSimulator) Empty ¶ added in v1.1.0
func (txSim *CallSimulator) Empty(address common.Address) bool
func (*CallSimulator) Exist ¶ added in v1.1.0
func (txSim *CallSimulator) Exist(address common.Address) bool
func (*CallSimulator) ForEachStorage ¶ added in v1.1.0
func (txSim *CallSimulator) ForEachStorage(address common.Address, f func(common.Hash, common.Hash) bool)
ForEachStorage 暂无调用 不做处理
func (*CallSimulator) FwAdd ¶ added in v1.1.0
func (txSim *CallSimulator) FwAdd(contractAddr common.Address, action Action, list []FwElem)
FwAdd 将防火墙的添加最终演变成防火墙的设置操作,并记录该设置操作
func (*CallSimulator) FwClear ¶ added in v1.1.0
func (txSim *CallSimulator) FwClear(contractAddr common.Address, action Action)
FwClear 将防火墙的清理最终演变成防火墙的设置操作,并记录该设置操作
func (*CallSimulator) FwDel ¶ added in v1.1.0
func (txSim *CallSimulator) FwDel(contractAddr common.Address, action Action, list []FwElem)
FwDel 将防火墙的删除最终演变成防火墙的设置操作,并记录该设置操作
func (*CallSimulator) FwImport ¶ added in v1.1.0
func (txSim *CallSimulator) FwImport(contractAddr common.Address, data []byte) error
FwImport 从json数据反序列化信息后,并记录防火墙的设置操作
func (*CallSimulator) FwSet ¶ added in v1.1.0
func (txSim *CallSimulator) FwSet(contractAddr common.Address, action Action, list []FwElem)
FwSet 处理数据并记录防火墙的设置操作
func (*CallSimulator) GetAbi ¶ added in v1.1.0
func (txSim *CallSimulator) GetAbi(address common.Address) []byte
func (*CallSimulator) GetAbiHash ¶ added in v1.1.0
func (txSim *CallSimulator) GetAbiHash(address common.Address) common.Hash
func (*CallSimulator) GetBalance ¶ added in v1.1.0
func (txSim *CallSimulator) GetBalance(addr common.Address) *big.Int
SetBalance 模拟交易的balance设置
func (*CallSimulator) GetCode ¶ added in v1.1.0
func (txSim *CallSimulator) GetCode(addr common.Address) []byte
func (*CallSimulator) GetCodeHash ¶ added in v1.1.0
func (txSim *CallSimulator) GetCodeHash(address common.Address) common.Hash
func (*CallSimulator) GetCodeSize ¶ added in v1.1.0
func (txSim *CallSimulator) GetCodeSize(address common.Address) int
func (*CallSimulator) GetCommittedState ¶ added in v1.1.0
func (txSim *CallSimulator) GetCommittedState(address common.Address, key []byte) []byte
func (*CallSimulator) GetContractCreator ¶ added in v1.1.0
func (txSim *CallSimulator) GetContractCreator(contractAddr common.Address) common.Address
func (*CallSimulator) GetFwStatus ¶ added in v1.1.0
func (txSim *CallSimulator) GetFwStatus(contractAddr common.Address) FwStatus
func (*CallSimulator) GetLogs ¶ added in v1.1.0
func (txSim *CallSimulator) GetLogs(hash common.Hash) []*types.Log
func (*CallSimulator) GetNonce ¶ added in v1.1.0
func (txSim *CallSimulator) GetNonce(address common.Address) uint64
func (*CallSimulator) GetRefund ¶ added in v1.1.0
func (txSim *CallSimulator) GetRefund() uint64
func (*CallSimulator) GetState ¶ added in v1.1.0
func (txSim *CallSimulator) GetState(addr common.Address, key []byte) []byte
GetState 获取数据操作
func (*CallSimulator) HasSuicided ¶ added in v1.1.0
func (txSim *CallSimulator) HasSuicided(address common.Address) bool
func (*CallSimulator) IsFwOpened ¶ added in v1.1.0
func (txSim *CallSimulator) IsFwOpened(contractAddr common.Address) bool
func (*CallSimulator) Logs ¶ added in v1.1.0
func (txSim *CallSimulator) Logs() []*types.Log
func (*CallSimulator) OpenFirewall ¶ added in v1.1.0
func (txSim *CallSimulator) OpenFirewall(contractAddr common.Address)
OpenFirewall 记录开启防火墙的操作
func (*CallSimulator) RevertToSnapshot ¶ added in v1.1.0
func (txSim *CallSimulator) RevertToSnapshot(i int)
RevertToSnapshot 用于回退模拟交易
func (*CallSimulator) SetAbi ¶ added in v1.1.0
func (txSim *CallSimulator) SetAbi(address common.Address, bytes []byte)
SetAbi 记录设置abi的操作
func (*CallSimulator) SetBalance ¶ added in v1.1.0
func (txSim *CallSimulator) SetBalance(addr common.Address, amount *big.Int)
SetBalance 模拟交易的balance设置
func (*CallSimulator) SetCode ¶ added in v1.1.0
func (txSim *CallSimulator) SetCode(address common.Address, bytes []byte)
SetCode 记录设置代码的操作
func (*CallSimulator) SetContractCreator ¶ added in v1.1.0
func (txSim *CallSimulator) SetContractCreator(contractAddr common.Address, creator common.Address)
SetContractCreator 优先判断地址是否是合约,如果是则为合约设置创建人,并记录该操作
func (*CallSimulator) SetFwStatus ¶ added in v1.1.0
func (txSim *CallSimulator) SetFwStatus(contractAddr common.Address, status FwStatus)
SetFwStatus 拆分成防火墙的数据设置操作和防火墙的活跃操作,并记录
func (*CallSimulator) SetNonce ¶ added in v1.1.0
func (txSim *CallSimulator) SetNonce(address common.Address, u uint64)
SetNonce 记录nonce有变更的地址,鉴于nonce的变更都是对原有的nonce+1,这里只记录需要变更的地址
func (*CallSimulator) SetState ¶ added in v1.1.0
func (txSim *CallSimulator) SetState(addr common.Address, key, value []byte)
SetState 将设置的操作存于writeSet内
func (*CallSimulator) Snapshot ¶ added in v1.1.0
func (txSim *CallSimulator) Snapshot() int
func (*CallSimulator) SubBalance ¶ added in v1.1.0
func (txSim *CallSimulator) SubBalance(addr common.Address, amount *big.Int)
SubBalance 模拟交易的balance减少
func (*CallSimulator) SubRefund ¶ added in v1.1.0
func (txSim *CallSimulator) SubRefund(u uint64)
type CreateAccount ¶ added in v1.1.0
type CreateAccount struct {
// contains filtered or unexported fields
}
CreateAccount 创建账户的变更操作
func NewCreateAccount ¶ added in v1.1.0
func NewCreateAccount(po *stateObject, no *stateObject) *CreateAccount
type Database ¶
type Database interface { // OpenTrie opens the main account trie. OpenTrie(root common.Hash) (Trie, error) // OpenStorageTrie opens the storage trie of an account. OpenStorageTrie(addrHash, root common.Hash) (Trie, error) // CopyTrie returns an independent copy of the given trie. CopyTrie(Trie) Trie // ContractCode retrieves a particular contract's code. ContractCode(addrHash, codeHash common.Hash) ([]byte, error) // ContractCodeSize retrieves a particular contracts code's size. ContractCodeSize(addrHash, codeHash common.Hash) (int, error) // TrieDB retrieves the low level trie database used for data storage. TrieDB() *trie.Database ContractAbi(addrHash, abiHash common.Hash) ([]byte, error) }
Database wraps access to tries and contract code.
func NewDatabase ¶
NewDatabase creates a backing store for state. The returned database is safe for concurrent use and retains cached trie nodes in memory. The pool is an optional intermediate trie-node memory pool between the low level storage layer and the high level trie abstraction.
type Dump ¶
type Dump struct { Root string `json:"root"` Accounts map[string]DumpAccount `json:"accounts"` }
type DumpAccount ¶
type FwData ¶
func FwUnMarshal ¶
type FwStatus ¶
type FwStatus struct { ContractAddr common.Address Active bool AcceptedList []FwElem RejectedList []FwElem }
func (*FwStatus) IsAccepted ¶
type ManagedState ¶
type ManagedState struct { *StateDB // contains filtered or unexported fields }
func ManageState ¶
func ManageState(statedb *StateDB) *ManagedState
ManagedState returns a new managed state with the statedb as it's backing layer
func (*ManagedState) GetNonce ¶
func (ms *ManagedState) GetNonce(addr common.Address) uint64
GetNonce returns the canonical nonce for the managed or unmanaged account.
Because GetNonce mutates the DB, we must take a write lock.
func (*ManagedState) HasAccount ¶
func (ms *ManagedState) HasAccount(addr common.Address) bool
HasAccount returns whether the given address is managed or not
func (*ManagedState) NewNonce ¶
func (ms *ManagedState) NewNonce(addr common.Address) uint64
NewNonce returns the new canonical nonce for the managed account
func (*ManagedState) RemoveNonce ¶
func (ms *ManagedState) RemoveNonce(addr common.Address, n uint64)
RemoveNonce removed the nonce from the managed state and all future pending nonces
func (*ManagedState) SetNonce ¶
func (ms *ManagedState) SetNonce(addr common.Address, nonce uint64)
SetNonce sets the new canonical nonce for the managed state
func (*ManagedState) SetState ¶
func (ms *ManagedState) SetState(statedb *StateDB)
SetState sets the backing layer of the managed state
type NodeIterator ¶
type NodeIterator struct { Hash common.Hash // Hash of the current entry being iterated (nil if not standalone) Parent common.Hash // Hash of the first full ancestor node (nil if current is the root) Error error // Failure set in case of an internal error in the iterator // contains filtered or unexported fields }
NodeIterator is an iterator to traverse the entire state trie post-order, including all of the contract code and contract state tries.
func NewNodeIterator ¶
func NewNodeIterator(state *StateDB) *NodeIterator
NewNodeIterator creates an post-order state node iterator.
func (*NodeIterator) Next ¶
func (it *NodeIterator) Next() bool
Next moves the iterator to the next node, returning whether there are any further nodes. In case of an internal error this method returns false and sets the Error field to the encountered failure.
type ObjectChange ¶ added in v1.1.0
type ObjectChange interface {
// contains filtered or unexported methods
}
ObjectChange 用于记录state_object的变更内容
type SetCreator ¶ added in v1.1.0
type SetCreator struct {
// contains filtered or unexported fields
}
func NewSetCreator ¶ added in v1.1.0
func NewSetCreator(object *stateObject, addr common.Address, creator common.Address) *SetCreator
type SetFwActive ¶ added in v1.1.0
type SetFwActive struct {
// contains filtered or unexported fields
}
func NewSetFwActive ¶ added in v1.1.0
func NewSetFwActive(object *stateObject, addr common.Address, active uint64) *SetFwActive
type SetFwData ¶ added in v1.1.0
type SetFwData struct {
// contains filtered or unexported fields
}
type StateDB ¶
type StateDB struct {
// contains filtered or unexported fields
}
StateDBs within the ethereum protocol are used to store anything within the merkle trie. StateDBs take care of caching and storing nested states. It's the general query interface to retrieve: * Contracts * Accounts
func (*StateDB) AddBalance ¶
AddBalance adds amount to the account associated with addr.
func (*StateDB) AddPreimage ¶
AddPreimage records a SHA3 preimage seen by the VM.
func (*StateDB) AddTxSim ¶ added in v1.1.0
func (self *StateDB) AddTxSim(txSim *TxSimulator, applyCh chan *TxSimulator, withDag bool) (bool, int)
AddTxSim 将模拟交易加入到db中
func (*StateDB) ApplyTxSim ¶ added in v1.1.0
func (self *StateDB) ApplyTxSim(txSim *TxSimulator, isProposer bool)
ApplyTxSim 将模拟交易的变更应用到stateObject的MPT树中,可异步进行
func (*StateDB) CloneAccount ¶
func (*StateDB) CloseFirewall ¶
func (*StateDB) Copy ¶
Copy creates a deep, independent copy of the state. Snapshots of the copied state cannot be applied to the copy.
func (*StateDB) CreateAccount ¶
CreateAccount explicitly creates a state object. If a state object with the address already exists the balance is carried over to the new account.
CreateAccount is called during the EVM CREATE operation. The situation might arise that a contract does the following:
- 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 (*StateDB) Database ¶
Database retrieves the low level database supporting the lower level trie ops.
func (*StateDB) Empty ¶
Empty returns whether the state object is either non-existent or empty according to the EIP161 specification (balance = nonce = code = 0)
func (*StateDB) Exist ¶
Exist reports whether the given account address exists in the state. Notably this also returns true for suicided accounts.
func (*StateDB) Finalise ¶
Finalise finalises the state by removing the self destructed objects and clears the journal as well as the refunds.
func (*StateDB) ForEachStorage ¶
func (*StateDB) GetAbiHash ¶
todo: new method -> GetAbiHash
func (*StateDB) GetBalance ¶
Retrieve the balance from the given address or 0 if object not found
func (*StateDB) GetBalanceByCache ¶ added in v1.1.0
GetBalanceByCache 从模拟交易的缓存中获取余额变动
func (*StateDB) GetCommittedState ¶
GetCommittedState retrieves a value from the given account's committed storage trie.
func (*StateDB) GetContractCreator ¶
func (*StateDB) GetFloat32 ¶
func (*StateDB) GetFloat64 ¶
func (*StateDB) GetGasUsed ¶ added in v1.1.0
func (*StateDB) GetOrNewStateObject ¶
Retrieve a state object or create a new state object if nil.
func (*StateDB) GetOrNewStateObjectSafe ¶ added in v1.1.0
func (*StateDB) GetReceiptHash ¶ added in v1.1.0
func (*StateDB) GetReceipts ¶ added in v1.1.0
func (*StateDB) GetStateByCache ¶ added in v1.1.0
GetStateByCache 从模拟交易的缓存中获取状态变动
func (*StateDB) GetStateByKeyTrie ¶ added in v1.1.0
GetStateByKeyTrie retrieves a value from the given account's storage trie.
func (*StateDB) GetTxs ¶ added in v1.1.0
func (self *StateDB) GetTxs() types.Transactions
func (*StateDB) IntermediateRoot ¶
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 (*StateDB) OpenFirewall ¶
func (*StateDB) Prepare ¶
Prepare sets the current transaction hash and index and block hash which is used when the EVM emits new state logs.
func (*StateDB) 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 (*StateDB) RevertToSnapshot ¶
RevertToSnapshot reverts all state changes made since the given revision.
func (*StateDB) SetContractCreator ¶
func (*StateDB) SetFloat32 ¶
func (*StateDB) SetFloat64 ¶
func (*StateDB) SetFwStatus ¶
func (*StateDB) SetHashGenerator ¶ added in v1.1.0
func (self *StateDB) SetHashGenerator()
func (*StateDB) SetStateByCache ¶ added in v1.1.0
SetStateByCache 设置读操作的内容
func (*StateDB) StartProcess ¶ added in v1.1.0
func (self *StateDB) StartProcess()
StartProcess 开始并行计算
func (*StateDB) StorageTrie ¶
StorageTrie returns the storage trie of an account. The return value is a copy and is nil for non-existent accounts.
func (*StateDB) SubBalance ¶
SubBalance subtracts amount from the account associated with addr.
func (*StateDB) SubRefund ¶
SubRefund removes gas from the refund counter. This method will panic if the refund counter goes below zero
func (*StateDB) Suicide ¶
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 (*StateDB) UpdateDirtyObject ¶ added in v1.1.0
func (self *StateDB) UpdateDirtyObject()
func (*StateDB) UpdateTrie ¶ added in v1.1.0
func (self *StateDB) UpdateTrie(receipts []*types.Receipt, txs []*types.Transaction)
type Suicide ¶ added in v1.1.0
type Suicide struct {
// contains filtered or unexported fields
}
func NewSuicide ¶ added in v1.1.0
type Trie ¶
type Trie interface { TryGet(key []byte) ([]byte, error) TryUpdate(key, value []byte) error TryUpdateValue(key, value []byte) error TryDelete(key []byte) error Commit(onleaf trie.LeafCallback) (common.Hash, error) Hash() common.Hash NodeIterator(startKey []byte) trie.NodeIterator GetKey([]byte) []byte // TODO(fjl): remove this when SecureTrie is removed Prove(key []byte, fromLevel uint, proofDb dbhandle.Putter) error }
Trie is a Ethereum Merkle Trie.
type TxSimulator ¶ added in v1.1.0
type TxSimulator struct {
// contains filtered or unexported fields
}
func NewTxSimulator ¶ added in v1.1.0
func NewTxSimulator(sdb *StateDB, transaction *types.Transaction) *TxSimulator
func (*TxSimulator) AddBalance ¶ added in v1.1.0
func (txSim *TxSimulator) AddBalance(addr common.Address, amount *big.Int)
AddBalance 模拟交易的balance增加
func (*TxSimulator) AddLog ¶ added in v1.1.0
func (txSim *TxSimulator) AddLog(log *types.Log)
func (*TxSimulator) AddNonce ¶ added in v1.1.0
func (txSim *TxSimulator) AddNonce(address common.Address)
AddNonce 记录nonce有变更的地址,鉴于nonce的变更都是对原有的nonce+1,这里只记录需要变更的地址
func (*TxSimulator) AddPreimage ¶ added in v1.1.0
func (txSim *TxSimulator) AddPreimage(hash common.Hash, bytes []byte)
AddPreimage debug情况下用来记录sha3操作的中间值,不做处理
func (*TxSimulator) AddRefund ¶ added in v1.1.0
func (txSim *TxSimulator) AddRefund(u uint64)
func (*TxSimulator) CloneAccount ¶ added in v1.1.0
CloneAccount 用于合约的迁移,暂时不做处理
func (*TxSimulator) CloseFirewall ¶ added in v1.1.0
func (txSim *TxSimulator) CloseFirewall(contractAddr common.Address)
CloseFirewall 记录关闭防火墙的操作
func (*TxSimulator) CreateAccount ¶ added in v1.1.0
func (txSim *TxSimulator) CreateAccount(address common.Address)
CreateAccount 记录创建账户的操作
func (*TxSimulator) Empty ¶ added in v1.1.0
func (txSim *TxSimulator) Empty(address common.Address) bool
func (*TxSimulator) Exist ¶ added in v1.1.0
func (txSim *TxSimulator) Exist(address common.Address) bool
func (*TxSimulator) ForEachStorage ¶ added in v1.1.0
func (txSim *TxSimulator) ForEachStorage(address common.Address, f func(common.Hash, common.Hash) bool)
ForEachStorage 暂无调用 不做处理
func (*TxSimulator) FwAdd ¶ added in v1.1.0
func (txSim *TxSimulator) FwAdd(contractAddr common.Address, action Action, list []FwElem)
FwAdd 将防火墙的添加最终演变成防火墙的设置操作,并记录该设置操作
func (*TxSimulator) FwClear ¶ added in v1.1.0
func (txSim *TxSimulator) FwClear(contractAddr common.Address, action Action)
FwClear 将防火墙的清理最终演变成防火墙的设置操作,并记录该设置操作
func (*TxSimulator) FwDel ¶ added in v1.1.0
func (txSim *TxSimulator) FwDel(contractAddr common.Address, action Action, list []FwElem)
FwDel 将防火墙的删除最终演变成防火墙的设置操作,并记录该设置操作
func (*TxSimulator) FwImport ¶ added in v1.1.0
func (txSim *TxSimulator) FwImport(contractAddr common.Address, data []byte) error
FwImport 从json数据反序列化信息后,并记录防火墙的设置操作
func (*TxSimulator) FwSet ¶ added in v1.1.0
func (txSim *TxSimulator) FwSet(contractAddr common.Address, action Action, list []FwElem)
FwSet 处理数据并记录防火墙的设置操作
func (*TxSimulator) GetAbi ¶ added in v1.1.0
func (txSim *TxSimulator) GetAbi(address common.Address) []byte
func (*TxSimulator) GetAbiHash ¶ added in v1.1.0
func (txSim *TxSimulator) GetAbiHash(address common.Address) common.Hash
func (*TxSimulator) GetBalance ¶ added in v1.1.0
func (txSim *TxSimulator) GetBalance(addr common.Address) *big.Int
SetBalance 模拟交易的balance设置
func (*TxSimulator) GetBalanceMap ¶ added in v1.1.0
func (txSim *TxSimulator) GetBalanceMap() map[common.Address]*BalanceOp
func (*TxSimulator) GetCode ¶ added in v1.1.0
func (txSim *TxSimulator) GetCode(addr common.Address) []byte
func (*TxSimulator) GetCodeHash ¶ added in v1.1.0
func (txSim *TxSimulator) GetCodeHash(address common.Address) common.Hash
func (*TxSimulator) GetCodeSize ¶ added in v1.1.0
func (txSim *TxSimulator) GetCodeSize(address common.Address) int
func (*TxSimulator) GetCommittedState ¶ added in v1.1.0
func (txSim *TxSimulator) GetCommittedState(address common.Address, key []byte) []byte
func (*TxSimulator) GetContractCreator ¶ added in v1.1.0
func (txSim *TxSimulator) GetContractCreator(contractAddr common.Address) common.Address
func (*TxSimulator) GetFwStatus ¶ added in v1.1.0
func (txSim *TxSimulator) GetFwStatus(contractAddr common.Address) FwStatus
func (*TxSimulator) GetHash ¶ added in v1.1.0
func (txSim *TxSimulator) GetHash() common.Hash
func (*TxSimulator) GetIndex ¶ added in v1.1.0
func (txSim *TxSimulator) GetIndex() int
GetIndex 获取交易在区块内的位置
func (*TxSimulator) GetLogs ¶ added in v1.1.0
func (txSim *TxSimulator) GetLogs(hash common.Hash) []*types.Log
func (*TxSimulator) GetNonce ¶ added in v1.1.0
func (txSim *TxSimulator) GetNonce(address common.Address) uint64
func (*TxSimulator) GetReadMap ¶ added in v1.1.0
func (txSim *TxSimulator) GetReadMap() map[string]*ReadOp
func (*TxSimulator) GetReceipt ¶ added in v1.1.0
func (txSim *TxSimulator) GetReceipt() *types.Receipt
func (*TxSimulator) GetRefund ¶ added in v1.1.0
func (txSim *TxSimulator) GetRefund() uint64
func (*TxSimulator) GetState ¶ added in v1.1.0
func (txSim *TxSimulator) GetState(addr common.Address, key []byte) []byte
GetState 获取数据操作
func (*TxSimulator) GetWriteMap ¶ added in v1.1.0
func (txSim *TxSimulator) GetWriteMap() map[string]*WriteOp
func (*TxSimulator) HasSuicided ¶ added in v1.1.0
func (txSim *TxSimulator) HasSuicided(address common.Address) bool
func (*TxSimulator) IsFwOpened ¶ added in v1.1.0
func (txSim *TxSimulator) IsFwOpened(contractAddr common.Address) bool
func (*TxSimulator) Logs ¶ added in v1.1.0
func (txSim *TxSimulator) Logs() []*types.Log
func (*TxSimulator) OpenFirewall ¶ added in v1.1.0
func (txSim *TxSimulator) OpenFirewall(contractAddr common.Address)
OpenFirewall 记录开启防火墙的操作
func (*TxSimulator) ReTry ¶ added in v1.1.0
func (txSim *TxSimulator) ReTry() bool
ReTry 用于判断是否需要重新模拟
func (*TxSimulator) RevertToSnapshot ¶ added in v1.1.0
func (txSim *TxSimulator) RevertToSnapshot(i int)
RevertToSnapshot 用于回退模拟交易
func (*TxSimulator) SetAbi ¶ added in v1.1.0
func (txSim *TxSimulator) SetAbi(address common.Address, bytes []byte)
SetAbi 记录设置abi的操作
func (*TxSimulator) SetBalance ¶ added in v1.1.0
func (txSim *TxSimulator) SetBalance(addr common.Address, amount *big.Int)
SetBalance 模拟交易的balance设置
func (*TxSimulator) SetCode ¶ added in v1.1.0
func (txSim *TxSimulator) SetCode(address common.Address, bytes []byte)
SetCode 记录设置代码的操作
func (*TxSimulator) SetContractCreator ¶ added in v1.1.0
func (txSim *TxSimulator) SetContractCreator(contractAddr common.Address, creator common.Address)
SetContractCreator 优先判断地址是否是合约,如果是则为合约设置创建人,并记录该操作
func (*TxSimulator) SetFwStatus ¶ added in v1.1.0
func (txSim *TxSimulator) SetFwStatus(contractAddr common.Address, status FwStatus)
SetFwStatus 拆分成防火墙的数据设置操作和防火墙的活跃操作,并记录
func (*TxSimulator) SetIndex ¶ added in v1.1.0
func (txSim *TxSimulator) SetIndex(index int)
SetIndex 用于标识交易在区块内的位置
func (*TxSimulator) SetNonce ¶ added in v1.1.0
func (txSim *TxSimulator) SetNonce(address common.Address, u uint64)
SetNonce 记录nonce有变更的地址,鉴于nonce的变更都是对原有的nonce+1,这里只记录需要变更的地址
func (*TxSimulator) SetReceipt ¶ added in v1.1.0
func (txSim *TxSimulator) SetReceipt(rec *types.Receipt)
func (*TxSimulator) SetState ¶ added in v1.1.0
func (txSim *TxSimulator) SetState(addr common.Address, key, value []byte)
SetState 将设置的操作存于writeSet内
func (*TxSimulator) Snapshot ¶ added in v1.1.0
func (txSim *TxSimulator) Snapshot() int
func (*TxSimulator) SubBalance ¶ added in v1.1.0
func (txSim *TxSimulator) SubBalance(addr common.Address, amount *big.Int)
SubBalance 模拟交易的balance减少
func (*TxSimulator) SubRefund ¶ added in v1.1.0
func (txSim *TxSimulator) SubRefund(u uint64)
type ValueStorage ¶
func (ValueStorage) Copy ¶
func (self ValueStorage) Copy() ValueStorage