Documentation ¶
Index ¶
- Constants
- Variables
- func CanTransfer(db vm.StateDB, fromHash common.Address, balance *big.Int) bool
- func ExecuteContract(blkHeight uint64, blkHash hash.Hash32B, producer address.Address, ...) (*action.Receipt, error)
- func GetHashFn(stateDB *StateDBAdapter) func(n uint64) common.Hash
- func MakeTransfer(db vm.StateDB, fromHash, toHash common.Address, amount *big.Int)
- type Contract
- type Params
- type StateDBAdapter
- func (stateDB *StateDBAdapter) AccountState(addr string) (*state.Account, error)
- func (stateDB *StateDBAdapter) AddBalance(evmAddr common.Address, amount *big.Int)
- func (stateDB *StateDBAdapter) AddLog(evmLog *types.Log)
- func (stateDB *StateDBAdapter) AddPreimage(hash common.Hash, preimage []byte)
- func (stateDB *StateDBAdapter) AddRefund(gas uint64)
- func (stateDB *StateDBAdapter) Contract(addr hash.PKHash) (Contract, error)
- func (stateDB *StateDBAdapter) CreateAccount(evmAddr common.Address)
- func (stateDB *StateDBAdapter) Empty(evmAddr common.Address) bool
- func (stateDB *StateDBAdapter) Error() error
- func (stateDB *StateDBAdapter) Exist(evmAddr common.Address) bool
- func (stateDB *StateDBAdapter) ForEachStorage(addr common.Address, cb func(common.Hash, common.Hash) bool)
- func (stateDB *StateDBAdapter) GetBalance(evmAddr common.Address) *big.Int
- func (stateDB *StateDBAdapter) GetCode(evmAddr common.Address) []byte
- func (stateDB *StateDBAdapter) GetCodeHash(evmAddr common.Address) common.Hash
- func (stateDB *StateDBAdapter) GetCodeSize(evmAddr common.Address) int
- func (stateDB *StateDBAdapter) GetNonce(evmAddr common.Address) uint64
- func (stateDB *StateDBAdapter) GetRefund() uint64
- func (stateDB *StateDBAdapter) GetState(evmAddr common.Address, k common.Hash) common.Hash
- func (stateDB *StateDBAdapter) HasSuicided(evmAddr common.Address) bool
- func (stateDB *StateDBAdapter) Logs() []*action.Log
- func (stateDB *StateDBAdapter) RevertToSnapshot(snapshot int)
- func (stateDB *StateDBAdapter) SetCode(evmAddr common.Address, code []byte)
- func (stateDB *StateDBAdapter) SetNonce(evmAddr common.Address, nonce uint64)
- func (stateDB *StateDBAdapter) SetState(evmAddr common.Address, k, v common.Hash)
- func (stateDB *StateDBAdapter) Snapshot() int
- func (stateDB *StateDBAdapter) SubBalance(evmAddr common.Address, amount *big.Int)
- func (stateDB *StateDBAdapter) Suicide(evmAddr common.Address) bool
Constants ¶
const ( // CodeKVNameSpace is the bucket name for code CodeKVNameSpace = "Code" // ContractKVNameSpace is the bucket name for contract data storage ContractKVNameSpace = "Contract" // PreimageKVNameSpace is the bucket name for preimage data storage PreimageKVNameSpace = "Preimage" )
const ( // FailureStatus is the status that contract execution failed FailureStatus = uint64(0) // SuccessStatus is the status that contract execution success SuccessStatus = uint64(1) )
Variables ¶
var ErrInconsistentNonce = errors.New("Nonce is not identical to executor nonce")
ErrInconsistentNonce is the error that the nonce is different from executor's nonce
Functions ¶
func CanTransfer ¶
CanTransfer checks whether the from account has enough balance
func ExecuteContract ¶
func ExecuteContract( blkHeight uint64, blkHash hash.Hash32B, producer address.Address, blkTimeStamp int64, sm protocol.StateManager, execution *action.Execution, cm protocol.ChainManager, gasLimit *uint64, enableGasCharge bool, ) (*action.Receipt, error)
ExecuteContract processes a transfer which contains a contract
Types ¶
type Contract ¶
type Contract interface { GetState(hash.Hash32B) ([]byte, error) SetState(hash.Hash32B, []byte) error GetCode() ([]byte, error) SetCode(hash.Hash32B, []byte) SelfState() *state.Account Commit() error RootHash() hash.Hash32B LoadRoot() error Iterator() (trie.Iterator, error) Snapshot() Contract }
Contract is a special type of account with code and storage trie.
type Params ¶
type Params struct {
// contains filtered or unexported fields
}
Params is the context and parameters
type StateDBAdapter ¶
type StateDBAdapter struct {
// contains filtered or unexported fields
}
StateDBAdapter represents the state db adapter for evm to access iotx blockchain
func NewStateDBAdapter ¶
func NewStateDBAdapter(cm protocol.ChainManager, sm protocol.StateManager, blockHeight uint64, blockHash hash.Hash32B, executionHash hash.Hash32B) *StateDBAdapter
NewStateDBAdapter creates a new state db with iotex blockchain
func (*StateDBAdapter) AccountState ¶
func (stateDB *StateDBAdapter) AccountState(addr string) (*state.Account, error)
AccountState returns an account state
func (*StateDBAdapter) AddBalance ¶
func (stateDB *StateDBAdapter) AddBalance(evmAddr common.Address, amount *big.Int)
AddBalance adds balance to account
func (*StateDBAdapter) AddLog ¶
func (stateDB *StateDBAdapter) AddLog(evmLog *types.Log)
AddLog adds log
func (*StateDBAdapter) AddPreimage ¶
func (stateDB *StateDBAdapter) AddPreimage(hash common.Hash, preimage []byte)
AddPreimage adds the preimage of a hash
func (*StateDBAdapter) AddRefund ¶
func (stateDB *StateDBAdapter) AddRefund(gas uint64)
AddRefund adds refund
func (*StateDBAdapter) Contract ¶
func (stateDB *StateDBAdapter) Contract(addr hash.PKHash) (Contract, error)
Contract returns the contract of addr
func (*StateDBAdapter) CreateAccount ¶
func (stateDB *StateDBAdapter) CreateAccount(evmAddr common.Address)
CreateAccount creates an account in iotx blockchain
func (*StateDBAdapter) Empty ¶
func (stateDB *StateDBAdapter) Empty(evmAddr common.Address) bool
Empty returns true if the the contract is empty
func (*StateDBAdapter) Error ¶
func (stateDB *StateDBAdapter) Error() error
Error returns the first stored error during evm contract execution
func (*StateDBAdapter) Exist ¶
func (stateDB *StateDBAdapter) Exist(evmAddr common.Address) bool
Exist checks the existence of an address
func (*StateDBAdapter) ForEachStorage ¶
func (stateDB *StateDBAdapter) ForEachStorage(addr common.Address, cb func(common.Hash, common.Hash) bool)
ForEachStorage loops each storage
func (*StateDBAdapter) GetBalance ¶
func (stateDB *StateDBAdapter) GetBalance(evmAddr common.Address) *big.Int
GetBalance gets the balance of account
func (*StateDBAdapter) GetCode ¶
func (stateDB *StateDBAdapter) GetCode(evmAddr common.Address) []byte
GetCode returns contract's code
func (*StateDBAdapter) GetCodeHash ¶
func (stateDB *StateDBAdapter) GetCodeHash(evmAddr common.Address) common.Hash
GetCodeHash returns contract's code hash
func (*StateDBAdapter) GetCodeSize ¶
func (stateDB *StateDBAdapter) GetCodeSize(evmAddr common.Address) int
GetCodeSize gets the code size saved in hash
func (*StateDBAdapter) GetNonce ¶
func (stateDB *StateDBAdapter) GetNonce(evmAddr common.Address) uint64
GetNonce gets the nonce of account
func (*StateDBAdapter) GetRefund ¶
func (stateDB *StateDBAdapter) GetRefund() uint64
GetRefund gets refund
func (*StateDBAdapter) HasSuicided ¶
func (stateDB *StateDBAdapter) HasSuicided(evmAddr common.Address) bool
HasSuicided returns whether the contract has been killed
func (*StateDBAdapter) Logs ¶
func (stateDB *StateDBAdapter) Logs() []*action.Log
Logs returns the logs
func (*StateDBAdapter) RevertToSnapshot ¶
func (stateDB *StateDBAdapter) RevertToSnapshot(snapshot int)
RevertToSnapshot reverts the state factory to the state at a given snapshot
func (*StateDBAdapter) SetCode ¶
func (stateDB *StateDBAdapter) SetCode(evmAddr common.Address, code []byte)
SetCode sets contract's code
func (*StateDBAdapter) SetNonce ¶
func (stateDB *StateDBAdapter) SetNonce(evmAddr common.Address, nonce uint64)
SetNonce sets the nonce of account
func (*StateDBAdapter) SetState ¶
func (stateDB *StateDBAdapter) SetState(evmAddr common.Address, k, v common.Hash)
SetState sets state
func (*StateDBAdapter) Snapshot ¶
func (stateDB *StateDBAdapter) Snapshot() int
Snapshot returns the snapshot id
func (*StateDBAdapter) SubBalance ¶
func (stateDB *StateDBAdapter) SubBalance(evmAddr common.Address, amount *big.Int)
SubBalance subtracts balance from account