iotex-core: Index | Files

package evm

import ""


Package Files

contract.go evm.go evmstatedbadapter.go kvstorefortrie.go serializablebytes.go


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"


var (

    // ErrInconsistentNonce is the error that the nonce is different from executor's nonce
    ErrInconsistentNonce = errors.New("Nonce is not identical to executor nonce")

func CanTransfer Uses

func CanTransfer(db vm.StateDB, fromHash common.Address, balance *big.Int) bool

CanTransfer checks whether the from account has enough balance

func ExecuteContract Uses

func ExecuteContract(
    ctx context.Context,
    sm protocol.StateManager,
    execution *action.Execution,
    getBlockHash GetBlockHash,
    depositGasFunc DepositGas,
) ([]byte, *action.Receipt, error)

ExecuteContract processes a transfer which contains a contract

func MakeTransfer Uses

func MakeTransfer(db vm.StateDB, fromHash, toHash common.Address, amount *big.Int)

MakeTransfer transfers account

func SimulateExecution Uses

func SimulateExecution(
    ctx context.Context,
    sm protocol.StateManager,
    caller address.Address,
    ex *action.Execution,
    getBlockHash GetBlockHash,
) ([]byte, *action.Receipt, error)

SimulateExecution simulates the execution in evm

type Contract Uses

type Contract interface {
    GetCommittedState(hash.Hash256) ([]byte, error)
    GetState(hash.Hash256) ([]byte, error)
    SetState(hash.Hash256, []byte) error
    GetCode() ([]byte, error)
    SetCode(hash.Hash256, []byte)
    SelfState() *state.Account
    Commit() error
    RootHash() hash.Hash256
    LoadRoot() error
    Iterator() (trie.Iterator, error)
    Snapshot() Contract

Contract is a special type of account with code and storage trie.

type DepositGas Uses

type DepositGas func(context.Context, protocol.StateManager, *big.Int) error

DepositGas deposits gas

type GetBlockHash Uses

type GetBlockHash func(uint64) (hash.Hash256, error)

GetBlockHash gets block hash by height

type Params Uses

type Params struct {
    // contains filtered or unexported fields

Params is the context and parameters

type SerializableBytes Uses

type SerializableBytes []byte

SerializableBytes defines a type of serializable bytes

func (*SerializableBytes) Deserialize Uses

func (sb *SerializableBytes) Deserialize(data []byte) error

Deserialize copies data into bytes

func (SerializableBytes) Serialize Uses

func (sb SerializableBytes) Serialize() ([]byte, error)

Serialize copies and return bytes

type StateDBAdapter Uses

type StateDBAdapter struct {
    // contains filtered or unexported fields

StateDBAdapter represents the state db adapter for evm to access iotx blockchain

func NewStateDBAdapter Uses

func NewStateDBAdapter(
    sm protocol.StateManager,
    blockHeight uint64,
    notFixTopicCopyBug bool,
    asyncContractTrie bool,
    executionHash hash.Hash256,
    opts ...StateDBOption,
) *StateDBAdapter

NewStateDBAdapter creates a new state db with iotex blockchain

func (*StateDBAdapter) AccountState Uses

func (stateDB *StateDBAdapter) AccountState(encodedAddr string) (*state.Account, error)

AccountState returns an account state

func (*StateDBAdapter) AddBalance Uses

func (stateDB *StateDBAdapter) AddBalance(evmAddr common.Address, amount *big.Int)

AddBalance adds balance to account

func (*StateDBAdapter) AddLog Uses

func (stateDB *StateDBAdapter) AddLog(evmLog *types.Log)

AddLog adds log

func (*StateDBAdapter) AddPreimage Uses

func (stateDB *StateDBAdapter) AddPreimage(hash common.Hash, preimage []byte)

AddPreimage adds the preimage of a hash

func (*StateDBAdapter) AddRefund Uses

func (stateDB *StateDBAdapter) AddRefund(gas uint64)

AddRefund adds refund

func (*StateDBAdapter) CommitContracts Uses

func (stateDB *StateDBAdapter) CommitContracts() error

CommitContracts commits contract code to db and update pending contract account changes to trie

func (*StateDBAdapter) CreateAccount Uses

func (stateDB *StateDBAdapter) CreateAccount(evmAddr common.Address)

CreateAccount creates an account in iotx blockchain

func (*StateDBAdapter) Empty Uses

func (stateDB *StateDBAdapter) Empty(evmAddr common.Address) bool

Empty returns true if the the contract is empty

func (*StateDBAdapter) Error Uses

func (stateDB *StateDBAdapter) Error() error

Error returns the first stored error during evm contract execution

func (*StateDBAdapter) Exist Uses

func (stateDB *StateDBAdapter) Exist(evmAddr common.Address) bool

Exist checks the existence of an address

func (*StateDBAdapter) ForEachStorage Uses

func (stateDB *StateDBAdapter) ForEachStorage(addr common.Address, cb func(common.Hash, common.Hash) bool) error

ForEachStorage loops each storage

func (*StateDBAdapter) GetBalance Uses

func (stateDB *StateDBAdapter) GetBalance(evmAddr common.Address) *big.Int

GetBalance gets the balance of account

func (*StateDBAdapter) GetCode Uses

func (stateDB *StateDBAdapter) GetCode(evmAddr common.Address) []byte

GetCode returns contract's code

func (*StateDBAdapter) GetCodeHash Uses

func (stateDB *StateDBAdapter) GetCodeHash(evmAddr common.Address) common.Hash

GetCodeHash returns contract's code hash

func (*StateDBAdapter) GetCodeSize Uses

func (stateDB *StateDBAdapter) GetCodeSize(evmAddr common.Address) int

GetCodeSize gets the code size saved in hash

func (*StateDBAdapter) GetCommittedState Uses

func (stateDB *StateDBAdapter) GetCommittedState(evmAddr common.Address, k common.Hash) common.Hash

GetCommittedState gets committed state

func (*StateDBAdapter) GetNonce Uses

func (stateDB *StateDBAdapter) GetNonce(evmAddr common.Address) uint64

GetNonce gets the nonce of account

func (*StateDBAdapter) GetRefund Uses

func (stateDB *StateDBAdapter) GetRefund() uint64

GetRefund gets refund

func (*StateDBAdapter) GetState Uses

func (stateDB *StateDBAdapter) GetState(evmAddr common.Address, k common.Hash) common.Hash

GetState gets state

func (*StateDBAdapter) HasSuicided Uses

func (stateDB *StateDBAdapter) HasSuicided(evmAddr common.Address) bool

HasSuicided returns whether the contract has been killed

func (*StateDBAdapter) Logs Uses

func (stateDB *StateDBAdapter) Logs() []*action.Log

Logs returns the logs

func (*StateDBAdapter) RevertToSnapshot Uses

func (stateDB *StateDBAdapter) RevertToSnapshot(snapshot int)

RevertToSnapshot reverts the state factory to the state at a given snapshot

func (*StateDBAdapter) SetCode Uses

func (stateDB *StateDBAdapter) SetCode(evmAddr common.Address, code []byte)

SetCode sets contract's code

func (*StateDBAdapter) SetNonce Uses

func (stateDB *StateDBAdapter) SetNonce(evmAddr common.Address, nonce uint64)

SetNonce sets the nonce of account

func (*StateDBAdapter) SetState Uses

func (stateDB *StateDBAdapter) SetState(evmAddr common.Address, k, v common.Hash)

SetState sets state

func (*StateDBAdapter) Snapshot Uses

func (stateDB *StateDBAdapter) Snapshot() int

Snapshot returns the snapshot id

func (*StateDBAdapter) SubBalance Uses

func (stateDB *StateDBAdapter) SubBalance(evmAddr common.Address, amount *big.Int)

SubBalance subtracts balance from account

func (*StateDBAdapter) SubRefund Uses

func (stateDB *StateDBAdapter) SubRefund(gas uint64)

SubRefund subtracts refund

func (*StateDBAdapter) Suicide Uses

func (stateDB *StateDBAdapter) Suicide(evmAddr common.Address) bool

Suicide kills the contract

type StateDBOption Uses

type StateDBOption func(*StateDBAdapter) error

StateDBOption set StateDBAdapter construction param

Package evm imports 27 packages (graph) and is imported by 5 packages. Updated 2020-07-06. Refresh now. Tools for package owners.