evmtypes

package
v1.5.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 18, 2021 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventTypeEvmTx = TypeMsgEvmTx

	AttributeKeyContractAddress = "contract"
	AttributeKeyRecipient       = "recipient"
	AttributeValueCategory      = ModuleName
)

Evm module events

View Source
const (
	// TypeMsgEvmTx defines the types string of an Ethereum tranasction
	TypeMsgEvmTx = "ethereum"
	RouteKey     = "vm"
)

message types and route constants

View Source
const (
	QueryProtocolVersion = "protocolVersion"
	QueryBalance         = "balance"
	QueryBlockNumber     = "blockNumber"
	QueryStorage         = "storage"
	QueryCode            = "code"
	QueryNonce           = "nonce"
	QueryHashToHeight    = "hashToHeight"
	QueryTransactionLogs = "transactionLogs"
	QueryBloom           = "bloom"
	QueryLogs            = "logs"
	QueryAccount         = "account"
	QueryExportAccount   = "exportAccount"
	QuerySectionBloom    = "sectionBloom"
)

Supported endpoints

View Source
const AppName = "ci123chain"

AppName represents the application name as the 'user agent' on the larger Ethereum network.

View Source
const (
	// ModuleName string name of module
	ModuleName = "evm"
)
View Source
const ProtocolVersion = 63

ProtocolVersion is the supported Ethereum protocol version (e.g., Homestead, Olympic, etc.)

View Source
const SectionSize = 4096
View Source
const Version = "0.0.0"

Version contains the application semantic version.

TODO: How do we want to version this being that an initial Eth has been developed?

Variables

View Source
var (
	ErrComputeGas            = sdkerrors.Register(string(DefaultCodespace), uint32(CodeComputeGas), "invalid intrinsic gas for transaction")
	ErrInvalidState          = sdkerrors.Register(string(DefaultCodespace), uint32(CodeInvalidState), "invalid vm state")
	ErrInvalidParams         = sdkerrors.Register(string(DefaultCodespace), uint32(CodeMissingPassword), "invalid params")
	ErrMissingPassword       = sdkerrors.Register(string(DefaultCodespace), uint32(CodeCheckParamsError), "missing password")
	ErrInvalidPassword       = sdkerrors.Register(string(DefaultCodespace), uint32(CodeInvalidPassword), "invalid password")
	ErrTimeOut               = sdkerrors.Register(string(DefaultCodespace), uint32(CodeTimeOut), "timeout")
	ErrInvalidPrivateKey     = sdkerrors.Register(string(DefaultCodespace), uint32(CodeInvalidPrivateKey), "invalid private_key")
	ErrUnlockTimeTooLarger   = sdkerrors.Register(string(DefaultCodespace), uint32(CodeUnlockTimeTooLarge), "unlock time too large")
	ErrInvalidClientStatus   = sdkerrors.Register(string(DefaultCodespace), uint32(CodeInvalidClientStatus), "unlock time too large")
	ErrGetNodeFailed         = sdkerrors.Register(string(DefaultCodespace), uint32(CodeGetNodeFailed), "get node failed")
	ErrInvalidNodeStatus     = sdkerrors.Register(string(DefaultCodespace), uint32(CodeInvalidNodeStatus), "invalid node status")
	ErrGetABCIInfoFailed     = sdkerrors.Register(string(DefaultCodespace), uint32(CodeGetABCIInfoFailed), "get abci info failed")
	ErrGetBlockNumber        = sdkerrors.Register(string(DefaultCodespace), uint32(CodeGetBlockNumber), "get block number failed")
	ErrGetBlockFailed        = sdkerrors.Register(string(DefaultCodespace), uint32(CodeGetBlockFailed), "get block failed")
	ErrCdcMarshalFailed      = sdkerrors.Register(string(DefaultCodespace), uint32(CodeCdcMarshalFailed), "cdc marshal failed")
	ErrCdcUnmarshalFailed    = sdkerrors.Register(string(DefaultCodespace), uint32(CodeCdcUnmarshalFailed), "cdc unmarshal failed")
	ErrQueryAccountsFailed   = sdkerrors.Register(string(DefaultCodespace), uint32(CodeeQueryAccountFailed), "query account failed")
	ErrGetStorageAtFailed    = sdkerrors.Register(string(DefaultCodespace), uint32(CodeGetStorageAtFailed), "get storage failed")
	ErrClientQueryTxFailed   = sdkerrors.Register(string(DefaultCodespace), uint32(CodeClientQueryTxFailed), "client query tx failed")
	ErrAccountExisted        = sdkerrors.Register(string(DefaultCodespace), uint32(CodeAccountExisted), "account already exists")
	ErrImportRawKeyFailed    = sdkerrors.Register(string(DefaultCodespace), uint32(CodeImportRawKeyFailed), "import raw key failed")
	ErrBloomFilterSectionNum = sdkerrors.Register(string(DefaultCodespace), uint32(CodeBloomFilterSectionNum), "section count not multiple of 8")
	ErrSectionOutOfBounds    = sdkerrors.Register(string(DefaultCodespace), uint32(CodeSectionOutOfBounds), "section out of bounds")
	ErrBloomBitOutOfBounds   = sdkerrors.Register(string(DefaultCodespace), uint32(CodeBloomBitOutOfBounds), "bloom bit out of bounds")

	ErrContractMethodInvalid = sdkerrors.Register(string(DefaultCodespace), uint32(CodeContractMethodInvalid), "contract method invalid")
)
View Source
var (
	KeyPrefixBlockHash   = []byte{0x01}
	KeyPrefixBloom       = []byte{0x02}
	KeyPrefixLogs        = []byte{0x03}
	KeyPrefixCode        = []byte{0x04}
	KeyPrefixStorage     = []byte{0x05}
	KeyPrefixChainConfig = []byte{0x06}
	KeyPrefixSection     = []byte{0x07}
)

KVStore key prefixes

View Source
var GitCommit = ""

GitCommit contains the git SHA1 short hash set by build flags.

View Source
var ModuleCdc *codec.Codec

ModuleCdc defines the evm module's codec

View Source
var (
	ParamStoreKeyEVMDenom = []byte("EVMDenom")
)

Parameter keys

Functions

func AddressStoragePrefix

func AddressStoragePrefix(address ethcmn.Address) []byte

AddressStoragePrefix returns a prefix to iterate over a given account storage.

func AssertValidKey

func AssertValidKey(key []byte)

Check if the key is valid(key is not nil)

func AssertValidValue

func AssertValidValue(value []byte)

Check if the value is valid(value is not nil)

func BloomKey

func BloomKey(height int64) []byte

BloomKey defines the store key for a block Bloom

func ClientVersion

func ClientVersion() string

ClientVersion returns the full version string for identification on the larger Ethereum network.

func EVMEncode

func EVMEncode(args utils.CallData) ([]byte, error)

func EncodeResultData

func EncodeResultData(data ResultData) ([]byte, error)

EncodeResultData takes all of the necessary data from the EVM execution and returns the data as a byte slice encoded with amino

func MarshalBigInt

func MarshalBigInt(i *big.Int) (string, error)

MarshalBigInt marshalls big int into text string for consistent encoding

func MarshalLogs

func MarshalLogs(logs []*ethtypes.Log) ([]byte, error)

MarshalLogs encodes an array of logs using amino

func MustMarshalBigInt

func MustMarshalBigInt(i *big.Int) string

MustMarshalBigInt marshalls big int into text string for consistent encoding. It panics if an error is encountered.

func MustUnmarshalBigInt

func MustUnmarshalBigInt(s string) *big.Int

MustUnmarshalBigInt unmarshalls string from *big.Int. It panics if an error is encountered.

func ParamKeyTable

func ParamKeyTable() params.KeyTable

ParamKeyTable returns the parameter key table.

func RegisterCodec

func RegisterCodec(cdc *codec.Codec)

RegisterCodec registers all the necessary types and interfaces for the evm module

func TxDecoder

func TxDecoder(cdc *codec.Codec) sdk.TxDecoder

TxDecoder returns an sdk.TxDecoder that can decode both auth.StdTx and MsgEthereumTx transactions.

func UnmarshalBigInt

func UnmarshalBigInt(s string) (*big.Int, error)

UnmarshalBigInt unmarshalls string from *big.Int

func UnmarshalLogs

func UnmarshalLogs(in []byte) ([]*ethtypes.Log, error)

UnmarshalLogs decodes an amino-encoded byte array into an array of logs

func ValidType

func ValidType(signature *utils.Signature) error

func ValidateLog

func ValidateLog(log *ethtypes.Log) error

ValidateLog performs a basic validation of an ethereum Log fields.

Types

type AccountKeeper

type AccountKeeper interface {
	NewAccountWithAddress(ctx sdk.Context, addr sdk.AccAddress) accountexported.Account
	GetAllAccounts(ctx sdk.Context) (accounts []accountexported.Account)
	GetAccount(ctx sdk.Context, addr sdk.AccAddress) accountexported.Account
	SetAccount(ctx sdk.Context, account accountexported.Account)
	RemoveAccount(ctx sdk.Context, account accountexported.Account)
}

AccountKeeper defines the expected account keeper interface

type ChainConfig

type ChainConfig struct {
	HomesteadBlock sdk.Int `json:"homestead_block" yaml:"homestead_block"` // Homestead switch block (< 0 no fork, 0 = already homestead)

	DAOForkBlock   sdk.Int `json:"dao_fork_block" yaml:"dao_fork_block"`     // TheDAO hard-fork switch block (< 0 no fork)
	DAOForkSupport bool    `json:"dao_fork_support" yaml:"dao_fork_support"` // Whether the nodes supports or opposes the DAO hard-fork

	// EIP150 implements the Gas price changes (https://github.com/ethereum/EIPs/issues/150)
	EIP150Block sdk.Int `json:"eip150_block" yaml:"eip150_block"` // EIP150 HF block (< 0 no fork)
	EIP150Hash  string  `json:"eip150_hash" yaml:"eip150_hash"`   // EIP150 HF hash (needed for header only clients as only gas pricing changed)

	EIP155Block sdk.Int `json:"eip155_block" yaml:"eip155_block"` // EIP155 HF block
	EIP158Block sdk.Int `json:"eip158_block" yaml:"eip158_block"` // EIP158 HF block

	ByzantiumBlock      sdk.Int `json:"byzantium_block" yaml:"byzantium_block"`           // Byzantium switch block (< 0 no fork, 0 = already on byzantium)
	ConstantinopleBlock sdk.Int `json:"constantinople_block" yaml:"constantinople_block"` // Constantinople switch block (< 0 no fork, 0 = already activated)
	PetersburgBlock     sdk.Int `json:"petersburg_block" yaml:"petersburg_block"`         // Petersburg switch block (< 0 same as Constantinople)
	IstanbulBlock       sdk.Int `json:"istanbul_block" yaml:"istanbul_block"`             // Istanbul switch block (< 0 no fork, 0 = already on istanbul)
	MuirGlacierBlock    sdk.Int `json:"muir_glacier_block" yaml:"muir_glacier_block"`     // Eip-2384 (bomb delay) switch block (< 0 no fork, 0 = already activated)

	YoloV1Block sdk.Int `json:"yoloV1_block" yaml:"yoloV1_block"` // YOLO v1: https://github.com/ethereum/EIPs/pull/2657 (Ephemeral testnet)
	EWASMBlock  sdk.Int `json:"ewasm_block" yaml:"ewasm_block"`   // EWASM switch block (< 0 no fork, 0 = already activated)
}

ChainConfig defines the Ethereum ChainConfig parameters using sdk.Int values instead of big.Int.

NOTE 1: Since empty/uninitialized Ints (i.e with a nil big.Int value) are parsed to zero, we need to manually specify that negative Int values will be considered as nil. See getBlockValue for reference.

NOTE 2: This types is not a configurable Param since the SDK does not allow for validation against a previous stored parameter values or the current block height (retrieved from context). If you want to update the configs values, use an software upgrade procedure.

func DefaultChainConfig

func DefaultChainConfig() ChainConfig

DefaultChainConfig returns default evm parameters. Th

func (ChainConfig) EthereumConfig

func (cc ChainConfig) EthereumConfig(chainID *big.Int) *params.ChainConfig

EthereumConfig returns an Ethereum ChainConfig for EVM state transitions. All the negative or nil values are converted to nil

func (ChainConfig) String

func (cc ChainConfig) String() string

String implements the fmt.Stringer interface

func (ChainConfig) Validate

func (cc ChainConfig) Validate() error

Validate performs a basic validation of the ChainConfig params. The function will return an error if any of the block values is uninitialized (i.e nil) or if the EIP150Hash is an invalid hash.

type Code

type Code []byte

Code is account Code types alias

func (Code) String

func (c Code) String() string

type CodeType

type CodeType = sdk.CodeType
const (
	DefaultCodespace sdk.CodespaceType = "evm"

	CodeCheckParamsError CodeType = 1701

	CodeComputeGas            CodeType = 1702
	CodeInvalidState          CodeType = 1703
	CodeMissingPassword       CodeType = 1704
	CodeInvalidPassword       CodeType = 1705
	CodeTimeOut               CodeType = 1706
	CodeInvalidPrivateKey     CodeType = 1707
	CodeUnlockTimeTooLarge    CodeType = 1708
	CodeInvalidClientStatus   CodeType = 1709
	CodeGetNodeFailed         CodeType = 1710
	CodeInvalidNodeStatus     CodeType = 1711
	CodeGetABCIInfoFailed     CodeType = 1712
	CodeGetBlockNumber        CodeType = 1713
	CodeGetBlockFailed        CodeType = 1714
	CodeCdcMarshalFailed      CodeType = 1715
	CodeCdcUnmarshalFailed    CodeType = 1716
	CodeeQueryAccountFailed   CodeType = 1717
	CodeGetStorageAtFailed    CodeType = 1718
	CodeClientQueryTxFailed   CodeType = 1719
	CodeAccountExisted        CodeType = 1720
	CodeImportRawKeyFailed    CodeType = 1721
	CodeBloomFilterSectionNum CodeType = 1722
	CodeSectionOutOfBounds    CodeType = 1723
	CodeBloomBitOutOfBounds   CodeType = 1724

	CodeContractMethodInvalid CodeType = 1730
)

type CommitStateDB

type CommitStateDB struct {
	// contains filtered or unexported fields
}

CommitStateDB implements the Geth state.StateDB interface. Instead of using a trie and database for querying and persistence, the Keeper uses KVStores and an account mapper is used to facilitate state transitions.

TODO: This implementation is subject to change in regards to its statefull manner. In otherwords, how this relates to the keeper in this module.

func NewCommitStateDB

func NewCommitStateDB(
	ctx sdk.Context, storeKey sdk.StoreKey, paramSpace params.Subspace, ak AccountKeeper,
) *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 (*CommitStateDB) AddBalance

func (csdb *CommitStateDB) AddBalance(addr ethcmn.Address, amount *big.Int)

AddBalance adds amount to the account associated with addr.

func (*CommitStateDB) AddLog

func (csdb *CommitStateDB) AddLog(log *ethtypes.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 ethcmn.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) AllLogs

func (csdb *CommitStateDB) AllLogs() []*ethtypes.Log

AllLogs returns all the current logs in the state.

func (*CommitStateDB) BlockHash

func (csdb *CommitStateDB) BlockHash() ethcmn.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) (ethcmn.Hash, 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 ethcmn.Address)

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:

  1. sends funds to sha(account ++ (nonce + 1))
  2. 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) DeleteLogs

func (csdb *CommitStateDB) DeleteLogs(hash ethcmn.Hash)

DeleteLogs removes the logs from the KVStore. It is used during journal.Revert.

func (*CommitStateDB) Empty

func (csdb *CommitStateDB) Empty(addr ethcmn.Address) 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 ethcmn.Address) 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) error

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 ethcmn.Address, cb func(key, value ethcmn.Hash) (stop bool)) error

ForEachStorage iterates over each storage items, all invoke the provided callback on each key, value pair.

func (*CommitStateDB) GetBalance

func (csdb *CommitStateDB) GetBalance(addr ethcmn.Address) *big.Int

GetBalance retrieves the balance from the given address or 0 if object not found.

func (*CommitStateDB) GetCode

func (csdb *CommitStateDB) GetCode(addr ethcmn.Address) []byte

GetCode returns the code for a given account.

func (*CommitStateDB) GetCodeHash

func (csdb *CommitStateDB) GetCodeHash(addr ethcmn.Address) ethcmn.Hash

GetCodeHash returns the code hash for a given account.

func (*CommitStateDB) GetCodeSize

func (csdb *CommitStateDB) GetCodeSize(addr ethcmn.Address) int

GetCodeSize returns the code size for a given account.

func (*CommitStateDB) GetCommittedState

func (csdb *CommitStateDB) GetCommittedState(addr ethcmn.Address, hash ethcmn.Hash) ethcmn.Hash

GetCommittedState retrieves a value from the given account's committed storage.

func (*CommitStateDB) GetLogs

func (csdb *CommitStateDB) GetLogs(hash ethcmn.Hash) ([]*ethtypes.Log, error)

GetLogs returns the current logs for a given transaction hash from the KVStore.

func (*CommitStateDB) GetNonce

func (csdb *CommitStateDB) GetNonce(addr ethcmn.Address) uint64

GetNonce returns the nonce (sequence number) for a given account.

func (*CommitStateDB) GetOrNewStateObject

func (csdb *CommitStateDB) GetOrNewStateObject(addr ethcmn.Address) StateObject

GetOrNewStateObject retrieves a state object or create a new state object if nil.

func (*CommitStateDB) GetParams

func (csdb *CommitStateDB) GetParams() (params Params)

GetParams returns the total set of evm parameters.

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 ethcmn.Address, hash ethcmn.Hash) ethcmn.Hash

GetState retrieves a value from the given account's storage store.

func (*CommitStateDB) HasSuicided

func (csdb *CommitStateDB) HasSuicided(addr ethcmn.Address) bool

HasSuicided returns if the given account for the specified address has been killed.

func (*CommitStateDB) IntermediateRoot

func (csdb *CommitStateDB) IntermediateRoot(deleteEmptyObjects bool) (ethcmn.Hash, error)

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) Preimages

func (csdb *CommitStateDB) Preimages() map[ethcmn.Hash][]byte

Preimages returns a list of SHA3 preimages that have been submitted.

func (*CommitStateDB) Prepare

func (csdb *CommitStateDB) Prepare(thash, bhash ethcmn.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) RawDump

func (csdb *CommitStateDB) RawDump() ethstate.Dump

RawDump returns a raw state dump.

TODO: Implement if we need it, especially for the RPC API.

func (*CommitStateDB) Reset

func (csdb *CommitStateDB) Reset(_ ethcmn.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 ethcmn.Address, amount *big.Int)

SetBalance sets the balance of an account.

func (*CommitStateDB) SetCode

func (csdb *CommitStateDB) SetCode(addr ethcmn.Address, code []byte)

SetCode sets the code for a given account.

func (*CommitStateDB) SetLogs

func (csdb *CommitStateDB) SetLogs(hash ethcmn.Hash, logs []*ethtypes.Log) error

SetLogs sets the logs for a transaction in the KVStore.

func (*CommitStateDB) SetNonce

func (csdb *CommitStateDB) SetNonce(addr ethcmn.Address, nonce uint64)

SetNonce sets the nonce (sequence number) of an account.

func (*CommitStateDB) SetParams

func (csdb *CommitStateDB) SetParams(params Params)

SetParams sets the evm parameters to the param space.

func (*CommitStateDB) SetState

func (csdb *CommitStateDB) SetState(addr ethcmn.Address, key, value ethcmn.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) StorageTrie

func (csdb *CommitStateDB) StorageTrie(addr ethcmn.Address) ethstate.Trie

StorageTrie returns nil as the state in Ethermint does not use a direct storage trie.

func (*CommitStateDB) SubBalance

func (csdb *CommitStateDB) SubBalance(addr ethcmn.Address, 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 ethcmn.Address) 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

type ExecutionResult

type ExecutionResult struct {
	Logs    []*ethtypes.Log
	Bloom   *big.Int
	Result  *sdk.Result
	GasInfo GasInfo
}

ExecutionResult represents what's returned from a transition

type GasInfo

type GasInfo struct {
	GasLimit    uint64
	GasConsumed uint64
	GasRefunded uint64
}

GasInfo returns the gas limit, gas consumed and gas refunded from the EVM transition execution

type GenesisAccount

type GenesisAccount struct {
	Address ethcmn.Address `json:"address"`
	Balance *big.Int       `json:"balance"`
	Code    hexutil.Bytes  `json:"code,omitempty"`
	Storage Storage        `json:"storage,omitempty"`
}

GenesisAccount defines an account to be initialized in the genesis state. Its main difference between with Geth's GenesisAccount is that it uses a custom storage types and that it doesn't contain the private key field.

func (GenesisAccount) Validate

func (ga GenesisAccount) Validate() error

Validate performs a basic validation of a GenesisAccount fields.

type GenesisState

type GenesisState struct {
	Accounts    []GenesisAccount  `json:"accounts"`
	TxsLogs     []TransactionLogs `json:"txs_logs"`
	ChainConfig ChainConfig       `json:"chain_config"`
	Params      Params            `json:"params"`
}

GenesisState defines the evm module genesis state

func DefaultGenesisState

func DefaultGenesisState() GenesisState

DefaultGenesisState sets default evm genesis state with empty accounts and default params and chain configs values.

func (GenesisState) Validate

func (gs GenesisState) Validate() error

Validate performs basic genesis state validation returning an error upon any failure.

type MsgEvmTx

type MsgEvmTx struct {
	From sdk.AccAddress
	Data TxData
	// contains filtered or unexported fields
}

MsgEthereumTx encapsulates an Ethereum transaction as an SDK message.

func NewMsgEthereumTxContract

func NewMsgEthereumTxContract(
	from sdk.AccAddress, nonce uint64, amount *big.Int, gasLimit uint64, gasPrice *big.Int, payload []byte,
) MsgEvmTx

NewMsgEthereumTxContract returns a reference to a new Ethereum transaction message designated for contract creation.

func NewMsgEvmTx

func NewMsgEvmTx(
	from sdk.AccAddress, nonce uint64, to *ethcmn.Address, amount *big.Int,
	gasLimit uint64, gasPrice *big.Int, payload []byte,
) MsgEvmTx

NewMsgEvmTx returns a reference to a new Ethereum transaction message.

func (MsgEvmTx) Bytes

func (msg MsgEvmTx) Bytes() []byte

func (MsgEvmTx) GetFromAddress

func (msg MsgEvmTx) GetFromAddress() sdk.AccAddress

func (MsgEvmTx) MsgType

func (msg MsgEvmTx) MsgType() string

Type returns the types value of an MsgEthereumTx.

func (MsgEvmTx) Route

func (msg MsgEvmTx) Route() string

Route returns the route value of an MsgEthereumTx.

func (MsgEvmTx) String

func (msg MsgEvmTx) String() string

func (MsgEvmTx) To

func (msg MsgEvmTx) To() *ethcmn.Address

To returns the recipient address of the transaction. It returns nil if the transaction is a contract creation.

func (MsgEvmTx) ValidateBasic

func (msg MsgEvmTx) ValidateBasic() error

ValidateBasic implements the sdk.Msg interface. It performs basic validation checks of a Transaction. If returns an error if validation fails.

type Params

type Params struct {
	EvmDenom string `json:"evm_denom" yaml:"evm_denom"`
}

Params defines the EVM module parameters

func DefaultParams

func DefaultParams() Params

DefaultParams returns default evm parameters

func NewParams

func NewParams(evmDenom string) Params

NewParams creates a new Params instance

func (*Params) ParamSetPairs

func (p *Params) ParamSetPairs() params.ParamSetPairs

ParamSetPairs returns the parameter set pairs.

func (Params) String

func (p Params) String() string

String implements the fmt.Stringer interface

func (Params) Validate

func (p Params) Validate() error

Validate performs basic validation on evm parameters.

type QueryBloomFilter

type QueryBloomFilter struct {
	Bloom ethtypes.Bloom `json:"bloom"`
}

QueryBloomFilter is response types for tx logs query

func (QueryBloomFilter) String

func (q QueryBloomFilter) String() string

type QueryETHLogs

type QueryETHLogs struct {
	Logs []*ethtypes.Log `json:"logs"`
}

QueryETHLogs is response types for tx logs query

func (QueryETHLogs) String

func (q QueryETHLogs) String() string

type QueryResAccount

type QueryResAccount struct {
	Balance  string `json:"balance"`
	CodeHash []byte `json:"codeHash"`
	Nonce    uint64 `json:"nonce"`
}

QueryAccount is response types for querying Ethereum state objects

type QueryResBalance

type QueryResBalance struct {
	Balance string `json:"balance"`
}

QueryResBalance is response types for balance query

func (QueryResBalance) String

func (q QueryResBalance) String() string

type QueryResBlockNumber

type QueryResBlockNumber struct {
	Number int64 `json:"blockNumber"`
}

QueryResBlockNumber is response types for block number query

func (QueryResBlockNumber) String

func (q QueryResBlockNumber) String() string

type QueryResCode

type QueryResCode struct {
	Code []byte
}

QueryResCode is response types for code query

func (QueryResCode) String

func (q QueryResCode) String() string

type QueryResExportAccount

type QueryResExportAccount = GenesisAccount

type QueryResNonce

type QueryResNonce struct {
	Nonce uint64 `json:"nonce"`
}

QueryResNonce is response types for Nonce query

func (QueryResNonce) String

func (q QueryResNonce) String() string

type QueryResProtocolVersion

type QueryResProtocolVersion struct {
	Version string `json:"version"`
}

QueryResProtocolVersion is response types for protocol version query

func (QueryResProtocolVersion) String

func (q QueryResProtocolVersion) String() string

type QueryResStorage

type QueryResStorage struct {
	Value []byte `json:"value"`
}

QueryResStorage is response types for storage query

func (QueryResStorage) String

func (q QueryResStorage) String() string

type QuerySectionBloomReq

type QuerySectionBloomReq struct {
	Sections []uint64 `json:"sections"`
	Filter   uint     `json:"filter"`
}

QuerySectionBloom

type QuerySectionBloomRes

type QuerySectionBloomRes map[uint64][]byte

type ResultData

type ResultData struct {
	ContractAddress ethcmn.Address  `json:"contract_address"`
	Bloom           ethtypes.Bloom  `json:"bloom"`
	Logs            []*ethtypes.Log `json:"logs"`
	Ret             []byte          `json:"ret"`
	TxHash          ethcmn.Hash     `json:"tx_hash"`
}

ResultData represents the data returned in an sdk.Result

func DecodeResultData

func DecodeResultData(in []byte) (ResultData, error)

DecodeResultData decodes an amino-encoded byte slice into ResultData

func (ResultData) String

func (rd ResultData) String() string

String implements fmt.Stringer interface.

type State

type State struct {
	Key   ethcmn.Hash `json:"key"`
	Value ethcmn.Hash `json:"value"`
}

State represents a single Storage key value pair item.

func NewState

func NewState(key, value ethcmn.Hash) State

NewState creates a new State instance

func (State) Validate

func (s State) Validate() error

Validate performs a basic validation of the State fields.

type StateObject

type StateObject interface {
	GetCommittedState(db ethstate.Database, key ethcmn.Hash) ethcmn.Hash
	GetState(db ethstate.Database, key ethcmn.Hash) ethcmn.Hash
	SetState(db ethstate.Database, key, value ethcmn.Hash)

	Code(db ethstate.Database) []byte
	SetCode(codeHash ethcmn.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() ethcmn.Address

	SetNonce(nonce uint64)
	Nonce() uint64
}

StateObject interface for interacting with state object

type StateTransition

type StateTransition struct {
	// TxData fields
	AccountNonce uint64
	Price        *big.Int
	GasLimit     uint64
	Recipient    *common.Address
	Amount       *big.Int
	Payload      []byte

	ChainID  *big.Int
	Csdb     *CommitStateDB
	TxHash   *common.Hash
	Sender   common.Address
	Simulate bool // i.e CheckTx execution
}

StateTransition defines data to transitionDB in evm

func (StateTransition) TransitionDb

func (st StateTransition) TransitionDb(ctx sdk.Context, config ChainConfig) (*ExecutionResult, error)

TransitionDb will transition the state by applying the current transaction and returning the evm execution result. NOTE: State transition checks are run during AnteHandler execution.

type Storage

type Storage []State

Storage represents the account Storage map as a slice of single key value State pairs. This is to prevent non determinism at genesis initialization or export.

func (Storage) Copy

func (s Storage) Copy() Storage

Copy returns a copy of storage.

func (Storage) String

func (s Storage) String() string

String implements the stringer interface

func (Storage) Validate

func (s Storage) Validate() error

Validate performs a basic validation of the Storage fields.

type Store

type Store struct {
	// contains filtered or unexported fields
}

func NewStore

func NewStore(parent types.KVStore, prefix []byte) Store

func (Store) Delete

func (s Store) Delete(key []byte)

Implements KVStore

func (Store) Get

func (s Store) Get(key []byte) []byte

Implements KVStore

func (Store) Has

func (s Store) Has(key []byte) bool

Implements KVStore

func (Store) Set

func (s Store) Set(key, value []byte)

ImplemenmiddleIns.fun["allocate"] = allocatets KVStore

type TransactionLogs

type TransactionLogs struct {
	Hash ethcmn.Hash     `json:"hash"`
	Logs []*ethtypes.Log `json:"logs"`
}

TransactionLogs define the logs generated from a transaction execution with a given hash. It it used for import/export data as transactions are not persisted on blockchain state after an upgrade.

func NewTransactionLogs

func NewTransactionLogs(hash ethcmn.Hash, logs []*ethtypes.Log) TransactionLogs

NewTransactionLogs creates a new NewTransactionLogs instance.

func (TransactionLogs) Validate

func (tx TransactionLogs) Validate() error

Validate performs a basic validation of a GenesisAccount fields.

type TxData

type TxData struct {
	AccountNonce uint64          `json:"nonce"`
	Price        *big.Int        `json:"gasPrice"`
	GasLimit     uint64          `json:"gas"`
	Recipient    *ethcmn.Address `json:"to" rlp:"nil"` // nil means contract creation
	Amount       *big.Int        `json:"value"`
	Payload      []byte          `json:"input"`

	// signature values
	V *big.Int `json:"v"`
	R *big.Int `json:"r"`
	S *big.Int `json:"s"`

	// hash is only used when marshaling to JSON
	Hash *ethcmn.Hash `json:"hash" rlp:"-"`
}

TxData implements the Ethereum transaction data structure. It is used solely as intended in Ethereum abiding by the protocol.

func (TxData) MarshalAmino

func (td TxData) MarshalAmino() ([]byte, error)

MarshalAmino defines custom encoding scheme for TxData

func (TxData) String

func (td TxData) String() string

func (*TxData) UnmarshalAmino

func (td *TxData) UnmarshalAmino(data []byte) error

UnmarshalAmino defines custom decoding scheme for TxData

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL