Documentation
¶
Index ¶
- Constants
- Variables
- func ErrCodeStoreOutOfGas() sdk.Error
- func ErrContractAddressCollision() sdk.Error
- func ErrDepth() sdk.Error
- func ErrEmptyInputs() sdk.Error
- func ErrExecutionReverted() sdk.Error
- func ErrGasUintOverflow() sdk.Error
- func ErrInsufficientBalance() sdk.Error
- func ErrInvalidJump() sdk.Error
- func ErrMaxCodeSizeExceeded() sdk.Error
- func ErrNoCodeExist() sdk.Error
- func ErrNoCompatibleInterpreter() sdk.Error
- func ErrNoPayload() sdk.Error
- func ErrOutOfGas() sdk.Error
- func ErrReturnDataOutOfBounds() sdk.Error
- func ErrTraceLimitReached() sdk.Error
- func ErrWriteProtection() sdk.Error
- func RegisterCodec(cdc *codec.Codec)
- func ValidateGenesis(data GenesisState) error
- type AccountKeeper
- type BankKeeper
- type CommitStateDB
- func (csdb *CommitStateDB) AddBalance(addr sdk.AccAddress, amount *big.Int)
- func (csdb *CommitStateDB) AddLog(log *Log)
- func (csdb *CommitStateDB) AddPreimage(hash sdk.Hash, preimage []byte)
- func (csdb *CommitStateDB) AddRefund(gas uint64)
- func (csdb *CommitStateDB) BlockHash() sdk.Hash
- func (csdb *CommitStateDB) ClearStateObjects()
- func (csdb *CommitStateDB) Commit(deleteEmptyObjects bool) (root sdk.Hash, err error)
- func (csdb *CommitStateDB) Copy() *CommitStateDB
- func (csdb *CommitStateDB) CreateAccount(addr sdk.AccAddress)
- func (csdb *CommitStateDB) Database() ethstate.Database
- func (csdb *CommitStateDB) Empty(addr sdk.AccAddress) bool
- func (csdb *CommitStateDB) Error() error
- func (csdb *CommitStateDB) Exist(addr sdk.AccAddress) bool
- func (csdb *CommitStateDB) Finalise(deleteEmptyObjects bool)
- func (csdb *CommitStateDB) ForEachStorage(addr sdk.AccAddress, cb func(key, value sdk.Hash) bool) error
- func (csdb *CommitStateDB) GetBalance(addr sdk.AccAddress) *big.Int
- func (csdb *CommitStateDB) GetCode(addr sdk.AccAddress) []byte
- func (csdb *CommitStateDB) GetCodeHash(addr sdk.AccAddress) sdk.Hash
- func (csdb *CommitStateDB) GetCodeSize(addr sdk.AccAddress) int
- func (csdb *CommitStateDB) GetCommittedState(addr sdk.AccAddress, hash sdk.Hash) sdk.Hash
- func (csdb *CommitStateDB) GetLogs(hash sdk.Hash) []*Log
- func (csdb *CommitStateDB) GetNonce(addr sdk.AccAddress) uint64
- func (csdb *CommitStateDB) GetOrNewStateObject(addr sdk.AccAddress) StateObject
- func (csdb *CommitStateDB) GetRefund() uint64
- func (csdb *CommitStateDB) GetState(addr sdk.AccAddress, hash sdk.Hash) sdk.Hash
- func (csdb *CommitStateDB) HasSuicided(addr sdk.AccAddress) bool
- func (csdb *CommitStateDB) IntermediateRoot(deleteEmptyObjects bool) sdk.Hash
- func (csdb *CommitStateDB) Logs() []*Log
- func (csdb *CommitStateDB) Preimages() map[sdk.Hash][]byte
- func (csdb *CommitStateDB) Prepare(thash, bhash sdk.Hash, txi int)
- func (csdb *CommitStateDB) Reset(_ sdk.Hash) error
- func (csdb *CommitStateDB) RevertToSnapshot(revID int)
- func (csdb *CommitStateDB) SetBalance(addr sdk.AccAddress, amount *big.Int)
- func (csdb *CommitStateDB) SetCode(addr sdk.AccAddress, code []byte)
- func (csdb *CommitStateDB) SetNonce(addr sdk.AccAddress, nonce uint64)
- func (csdb *CommitStateDB) SetState(addr sdk.AccAddress, key, value sdk.Hash)
- func (csdb *CommitStateDB) Snapshot() int
- func (csdb *CommitStateDB) SubBalance(addr sdk.AccAddress, amount *big.Int)
- func (csdb *CommitStateDB) SubRefund(gas uint64)
- func (csdb *CommitStateDB) Suicide(addr sdk.AccAddress) bool
- func (csdb *CommitStateDB) TxIndex() int
- func (csdb *CommitStateDB) UpdateAccounts()
- func (csdb *CommitStateDB) WithContext(ctx sdk.Context) *CommitStateDB
- func (csdb *CommitStateDB) WithTxHash(txHash []byte) *CommitStateDB
- type GenesisState
- type Log
- type LogForStorage
- type MsgContract
- type MsgContractQuery
- type Params
- type QueryLogsResult
- type QueryStorageResult
- type SimulationResult
- type StateObject
- type VMCommonGasParams
Constants ¶
const ( DefaultCodespace sdk.CodespaceType = ModuleName CodeOutOfGas sdk.CodeType = 101 CodeStoreOutOfGas sdk.CodeType = 102 CodeDepth sdk.CodeType = 103 CodeTraceLimitReached sdk.CodeType = 104 CodeNoCompatibleInterpreter sdk.CodeType = 105 CodeEmptyInputs sdk.CodeType = 106 CodeInsufficientBalance sdk.CodeType = 107 CodeContractExist sdk.CodeType = 108 CodeNoCodeExist sdk.CodeType = 109 CodeMaxCodeSizeExceeded sdk.CodeType = 110 CodeWriteProtection sdk.CodeType = 111 CodeReturnDataOutOfBounds sdk.CodeType = 112 CodeExecutionReverted sdk.CodeType = 113 CodeInvalidJump sdk.CodeType = 114 CodeGasUintOverflow sdk.CodeType = 115 CodeNoPayload sdk.CodeType = 116 )
const ( EventTypeNewContract = "new_contract" AttributeKeyAddress = "address" AttributeValueCategory = "vm" )
const ( // ModuleName is the name of the vm module ModuleName = "vm" // StoreKey is the string store representation StoreKey = ModuleName CodeKey = StoreKey + "_code" // QuerierRoute is the querier route for the vm module QuerierRoute = ModuleName // RouterKey is the msg router key for the vm module RouterKey = ModuleName )
const ( DefaultMaxCodeSize uint64 = 1024 * 1024 CallCreateDepth uint64 = 1024 DefaultContractCreationGas = 53000 DefaultCreateDataGas = 200 )
const ( QueryParameters = "params" QueryCode = "code" QueryStorage = "storage" QueryTxLogs = "logs" EstimateGas = "estimate_gas" QueryCall = "call" )
const (
TypeMsgContract = "contract"
)
Variables ¶
var ( KeyMaxCodeSize = []byte("MaxCodeSize") KeyVMOpGasParams = []byte("VMOpGasParams") KeyVMCommonGasParams = []byte("VMCommonGasParams") DefaultVMOpGasParams = [256]uint64{}/* 256 elements not displayed */ DefaultVMCommonGasParams = VMCommonGasParams{ContractCreationGas: DefaultContractCreationGas, CreateDataGas: DefaultCreateDataGas} //protocol_params.go::CreateDataGas )
var ModuleCdc *codec.Codec
generic sealed codec to be used throughout this module
Functions ¶
func ErrCodeStoreOutOfGas ¶
func ErrEmptyInputs ¶
func ErrExecutionReverted ¶
func ErrGasUintOverflow ¶
func ErrInsufficientBalance ¶
func ErrInvalidJump ¶
func ErrMaxCodeSizeExceeded ¶
func ErrNoCodeExist ¶
func ErrNoPayload ¶
func ErrOutOfGas ¶
func ErrTraceLimitReached ¶
func ErrWriteProtection ¶
func ValidateGenesis ¶
func ValidateGenesis(data GenesisState) error
Types ¶
type AccountKeeper ¶
type BankKeeper ¶
type BankKeeper interface {
SendCoins(ctx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins) sdk.Error
}
type CommitStateDB ¶
type CommitStateDB struct {
// contains filtered or unexported fields
}
func NewCommitStateDB ¶
func NewCommitStateDB(ak auth.AccountKeeper, storageKey, codeKey sdk.StoreKey) *CommitStateDB
NewCommitStateDB returns a reference to a newly initialized CommitStateDB which implements Geth's state.StateDB interface.
CONTRACT: Stores used for state must be cache-wrapped as the ordering of the key/value space matters in determining the merkle root. func NewCommitStateDB(ctx sdk.Context, ak auth.AccountKeeper, storageKey, codeKey sdk.StoreKey) *CommitStateDB {
func NewStateDB ¶
func NewStateDB(db *CommitStateDB) *CommitStateDB
func (*CommitStateDB) AddBalance ¶
func (csdb *CommitStateDB) AddBalance(addr sdk.AccAddress, amount *big.Int)
AddBalance adds amount to the account associated with addr.
func (*CommitStateDB) AddLog ¶
func (csdb *CommitStateDB) AddLog(log *Log)
AddLog adds a new log to the state and sets the log metadata from the state.
func (*CommitStateDB) AddPreimage ¶
func (csdb *CommitStateDB) AddPreimage(hash sdk.Hash, preimage []byte)
AddPreimage records a SHA3 preimage seen by the VM.
func (*CommitStateDB) AddRefund ¶
func (csdb *CommitStateDB) AddRefund(gas uint64)
AddRefund adds gas to the refund counter.
func (*CommitStateDB) BlockHash ¶
func (csdb *CommitStateDB) BlockHash() sdk.Hash
BlockHash returns the current block hash set by Prepare.
func (*CommitStateDB) ClearStateObjects ¶
func (csdb *CommitStateDB) ClearStateObjects()
ClearStateObjects clears cache of state objects to handle account changes outside of the EVM
func (*CommitStateDB) Commit ¶
func (csdb *CommitStateDB) Commit(deleteEmptyObjects bool) (root sdk.Hash, err error)
Commit writes the state to the appropriate KVStores. For each state object in the cache, it will either be removed, or have it's code set and/or it's state (storage) updated. In addition, the state object (account) itself will be written. Finally, the root hash (version) will be returned.
func (*CommitStateDB) Copy ¶
func (csdb *CommitStateDB) Copy() *CommitStateDB
Copy creates a deep, independent copy of the state.
NOTE: Snapshots of the copied state cannot be applied to the copy.
func (*CommitStateDB) CreateAccount ¶
func (csdb *CommitStateDB) CreateAccount(addr sdk.AccAddress)
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 (*CommitStateDB) Database ¶
func (csdb *CommitStateDB) Database() ethstate.Database
Database retrieves the low level database supporting the lower level trie ops. It is not used in Ethermint, so it returns nil.
func (*CommitStateDB) Empty ¶
func (csdb *CommitStateDB) Empty(addr sdk.AccAddress) bool
Empty returns whether the state object is either non-existent or empty according to the EIP161 specification (balance = nonce = code = 0).
func (*CommitStateDB) Error ¶
func (csdb *CommitStateDB) Error() error
Error returns the first non-nil error the StateDB encountered.
func (*CommitStateDB) Exist ¶
func (csdb *CommitStateDB) Exist(addr sdk.AccAddress) bool
Exist reports whether the given account address exists in the state. Notably, this also returns true for suicided accounts.
func (*CommitStateDB) Finalise ¶
func (csdb *CommitStateDB) Finalise(deleteEmptyObjects bool)
Finalise finalizes the state objects (accounts) state by setting their state, removing the csdb destructed objects and clearing the journal as well as the refunds.
func (*CommitStateDB) ForEachStorage ¶
func (csdb *CommitStateDB) ForEachStorage(addr sdk.AccAddress, cb func(key, value sdk.Hash) bool) error
ForEachStorage iterates over each storage items, all invokes the provided callback on each key, value pair .
func (*CommitStateDB) GetBalance ¶
func (csdb *CommitStateDB) GetBalance(addr sdk.AccAddress) *big.Int
GetBalance retrieves the balance from the given address or 0 if object not found.
func (*CommitStateDB) GetCode ¶
func (csdb *CommitStateDB) GetCode(addr sdk.AccAddress) []byte
GetCode returns the code for a given account.
func (*CommitStateDB) GetCodeHash ¶
func (csdb *CommitStateDB) GetCodeHash(addr sdk.AccAddress) sdk.Hash
GetCodeHash returns the code hash for a given account.
func (*CommitStateDB) GetCodeSize ¶
func (csdb *CommitStateDB) GetCodeSize(addr sdk.AccAddress) int
GetCodeSize returns the code size for a given account.
func (*CommitStateDB) GetCommittedState ¶
func (csdb *CommitStateDB) GetCommittedState(addr sdk.AccAddress, hash sdk.Hash) sdk.Hash
GetCommittedState retrieves a value from the given account's committed storage.
func (*CommitStateDB) GetLogs ¶
func (csdb *CommitStateDB) GetLogs(hash sdk.Hash) []*Log
GetLogs returns the current logs for a given hash in the state.
func (*CommitStateDB) GetNonce ¶
func (csdb *CommitStateDB) GetNonce(addr sdk.AccAddress) uint64
GetNonce returns the nonce (sequence number) for a given account.
func (*CommitStateDB) GetOrNewStateObject ¶
func (csdb *CommitStateDB) GetOrNewStateObject(addr sdk.AccAddress) StateObject
GetOrNewStateObject retrieves a state object or create a new state object if nil.
func (*CommitStateDB) GetRefund ¶
func (csdb *CommitStateDB) GetRefund() uint64
GetRefund returns the current value of the refund counter.
func (*CommitStateDB) GetState ¶
func (csdb *CommitStateDB) GetState(addr sdk.AccAddress, hash sdk.Hash) sdk.Hash
GetState retrieves a value from the given account's storage store.
func (*CommitStateDB) HasSuicided ¶
func (csdb *CommitStateDB) HasSuicided(addr sdk.AccAddress) bool
HasSuicided returns if the given account for the specified address has been killed.
func (*CommitStateDB) IntermediateRoot ¶
func (csdb *CommitStateDB) IntermediateRoot(deleteEmptyObjects bool) sdk.Hash
IntermediateRoot returns the current root hash of the state. It is called in between transactions to get the root hash that goes into transaction receipts.
NOTE: The SDK has not concept or method of getting any intermediate merkle root as commitment of the merkle-ized tree doesn't happen until the BaseApps' EndBlocker.
func (*CommitStateDB) Logs ¶
func (csdb *CommitStateDB) Logs() []*Log
Logs returns all the current logs in the state.
func (*CommitStateDB) Preimages ¶
func (csdb *CommitStateDB) Preimages() map[sdk.Hash][]byte
Preimages returns a list of SHA3 preimages that have been submitted.
func (*CommitStateDB) Prepare ¶
func (csdb *CommitStateDB) Prepare(thash, bhash sdk.Hash, txi int)
Prepare sets the current transaction hash and index and block hash which is used when the EVM emits new state logs.
func (*CommitStateDB) Reset ¶
func (csdb *CommitStateDB) Reset(_ sdk.Hash) error
Reset clears out all ephemeral state objects from the state db, but keeps the underlying account mapper and store keys to avoid reloading data for the next operations.
func (*CommitStateDB) RevertToSnapshot ¶
func (csdb *CommitStateDB) RevertToSnapshot(revID int)
RevertToSnapshot reverts all state changes made since the given revision.
func (*CommitStateDB) SetBalance ¶
func (csdb *CommitStateDB) SetBalance(addr sdk.AccAddress, amount *big.Int)
SetBalance sets the balance of an account.
func (*CommitStateDB) SetCode ¶
func (csdb *CommitStateDB) SetCode(addr sdk.AccAddress, code []byte)
SetCode sets the code for a given account.
func (*CommitStateDB) SetNonce ¶
func (csdb *CommitStateDB) SetNonce(addr sdk.AccAddress, nonce uint64)
SetNonce sets the nonce (sequence number) of an account.
func (*CommitStateDB) SetState ¶
func (csdb *CommitStateDB) SetState(addr sdk.AccAddress, key, value sdk.Hash)
SetState sets the storage state with a key, value pair for an account.
func (*CommitStateDB) Snapshot ¶
func (csdb *CommitStateDB) Snapshot() int
Snapshot returns an identifier for the current revision of the state.
func (*CommitStateDB) SubBalance ¶
func (csdb *CommitStateDB) SubBalance(addr sdk.AccAddress, amount *big.Int)
SubBalance subtracts amount from the account associated with addr.
func (*CommitStateDB) SubRefund ¶
func (csdb *CommitStateDB) SubRefund(gas uint64)
SubRefund removes gas from the refund counter. It will panic if the refund counter goes below zero.
func (*CommitStateDB) Suicide ¶
func (csdb *CommitStateDB) Suicide(addr sdk.AccAddress) bool
Suicide marks the given account as suicided and 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 (*CommitStateDB) TxIndex ¶
func (csdb *CommitStateDB) TxIndex() int
TxIndex returns the current transaction index set by Prepare.
func (*CommitStateDB) UpdateAccounts ¶
func (csdb *CommitStateDB) UpdateAccounts()
UpdateAccounts updates the nonce and coin balances of accounts
func (*CommitStateDB) WithContext ¶
func (csdb *CommitStateDB) WithContext(ctx sdk.Context) *CommitStateDB
WithContext returns a Database with an updated sdk context
func (*CommitStateDB) WithTxHash ¶
func (csdb *CommitStateDB) WithTxHash(txHash []byte) *CommitStateDB
type GenesisState ¶
type GenesisState struct {
Params Params `json:"params" yaml:"params"`
}
func DefaultGenesisState ¶
func DefaultGenesisState() GenesisState
func NewGenesisState ¶
func NewGenesisState(params Params) GenesisState
type Log ¶
type Log struct { // address of the contract that generated the event Address sdk.AccAddress `json:"address" yaml:"address"` // list of topics provided by the contract. Topics []sdk.Hash `json:"topics" yaml:"topics"` // supplied by the contract, usually ABI-encoded Data hexutil.Bytes `json:"data" yaml:"data` BlockNumber uint64 `json:"blockNumber" yaml:"blockNumber"` TxHash sdk.Hash `json:"transactionHash" yaml:"transactionHash"` TxIndex uint `json:"transactionIndex" yaml:"transactionIndex"` BlockHash sdk.Hash `json:"blockHash" yaml:"blockHash"` Index uint `json:"logIndex" yaml:"logIndex"` Removed bool `json:"removed" yaml:"removed"` }
type LogForStorage ¶
type LogForStorage Log
LogForStorage is a wrapper around a Log that flattens and parses the entire content of a log including non-consensus fields.
type MsgContract ¶
type MsgContract struct { From sdk.AccAddress `json:"from" yaml:"from"` To sdk.AccAddress `json:"to" yaml:"to"` Payload hexutil.Bytes `json:"payload" yaml:"payload"` Amount sdk.Coin `json:"amount" yaml:"amount"` }
func NewMsgContract ¶
func NewMsgContract(from, to sdk.AccAddress, payload []byte, amount sdk.Coin) MsgContract
func (MsgContract) GetSignBytes ¶
func (msg MsgContract) GetSignBytes() []byte
func (MsgContract) GetSigners ¶
func (msg MsgContract) GetSigners() []sdk.AccAddress
func (MsgContract) Route ¶
func (msg MsgContract) Route() string
func (MsgContract) Type ¶
func (msg MsgContract) Type() string
func (MsgContract) ValidateBasic ¶
func (msg MsgContract) ValidateBasic() sdk.Error
type MsgContractQuery ¶
type MsgContractQuery MsgContract
func NewMsgContractQuery ¶
func NewMsgContractQuery(from, to sdk.AccAddress, payload []byte, amount sdk.Coin) MsgContractQuery
type Params ¶
type Params struct { MaxCodeSize uint64 `json:"max_code_size" yaml:"max_code_size"` VMOpGasParams [256]uint64 `json:"vm_op_gas_params" yaml:"vm_op_gas_params"` VMCommonGasParams VMCommonGasParams `json:"vm_common_gas_params" yaml:"vm_common_gas_params"` }
func DefaultParams ¶
func DefaultParams() Params
func NewParams ¶
func NewParams(maxCodeSize uint64, vmOpGasParams [256]uint64, vmCommonGasParams VMCommonGasParams) Params
func (*Params) ParamSetPairs ¶
func (p *Params) ParamSetPairs() params.ParamSetPairs
type QueryLogsResult ¶
type QueryLogsResult struct {
Logs []*Log `json:"logs"`
}
for query logs
func (QueryLogsResult) String ¶
func (q QueryLogsResult) String() string
type QueryStorageResult ¶
for query storage
func (QueryStorageResult) String ¶
func (q QueryStorageResult) String() string
type SimulationResult ¶
for Gas Estimate
func (SimulationResult) String ¶
func (r SimulationResult) String() string
type StateObject ¶
type StateObject interface { GetCommittedState(key sdk.Hash) sdk.Hash GetState(key sdk.Hash) sdk.Hash SetState(key, value sdk.Hash) Code() []byte SetCode(codeHash sdk.Hash, code []byte) CodeHash() []byte AddBalance(amount *big.Int) SubBalance(amount *big.Int) SetBalance(amount *big.Int) Balance() *big.Int ReturnGas(gas *big.Int) Address() sdk.Address SetNonce(nonce uint64) Nonce() uint64 }
StateObject interface for interacting with state object