Documentation
¶
Index ¶
- func CheckSenderBalance(balance sdkmath.Int, ethTx *ethtypes.Transaction) error
- func DeductFees(bankKeeper types.BankKeeper, vmKeeper types.VMKeeper, ctx sdk.Context, ...) (err error)
- func GasToRefund(availableRefund, gasConsumed, refundQuotient uint64) uint64
- func GetProposerAddress(ctx sdk.Context, proposerAddress sdk.ConsAddress) sdk.ConsAddress
- func VerifyFee(ethTx *ethtypes.Transaction, denom string, baseFee *big.Int, ...) (sdk.Coins, error)
- type Keeper
- func (k Keeper) Account(c context.Context, req *types.QueryAccountRequest) (_ *types.QueryAccountResponse, err error)
- func (k *Keeper) AddPreinstalls(ctx sdk.Context, preinstalls []types.Preinstall) (err error)
- func (k Keeper) AddTransientGasUsed(ctx sdk.Context, gasUsed uint64) (uint64, error)
- func (k *Keeper) ApplyMessage(ctx sdk.Context, stateDB *statedb.StateDB, msg core.Message, ...) (*types.MsgEthereumTxResponse, error)
- func (k *Keeper) ApplyMessageWithConfig(ctx sdk.Context, stateDB *statedb.StateDB, msg core.Message, ...) (_ *types.MsgEthereumTxResponse, err error)
- func (k *Keeper) ApplyTransaction(ctx sdk.Context, tx *ethtypes.Transaction) (_ *types.MsgEthereumTxResponse, err error)
- func (k Keeper) Balance(c context.Context, req *types.QueryBalanceRequest) (_ *types.QueryBalanceResponse, err error)
- func (k Keeper) BaseFee(c context.Context, _ *types.QueryBaseFeeRequest) (*types.QueryBaseFeeResponse, error)
- func (k *Keeper) BeginBlock(ctx sdk.Context) (err error)
- func (k Keeper) CallEVM(ctx sdk.Context, stateDB *statedb.StateDB, abi abi.ABI, ...) (_ *types.MsgEthereumTxResponse, err error)
- func (k Keeper) CallEVMWithData(ctx sdk.Context, stateDB *statedb.StateDB, from common.Address, ...) (_ *types.MsgEthereumTxResponse, err error)
- func (k Keeper) Code(c context.Context, req *types.QueryCodeRequest) (_ *types.QueryCodeResponse, err error)
- func (k Keeper) CollectTxBloom(ctx sdk.Context)
- func (k Keeper) Config(ctx context.Context, _ *types.QueryConfigRequest) (*types.QueryConfigResponse, error)
- func (k Keeper) CosmosAccount(c context.Context, req *types.QueryCosmosAccountRequest) (_ *types.QueryCosmosAccountResponse, err error)
- func (k *Keeper) DeductTxCostsFromUserBalance(ctx sdk.Context, fees sdk.Coins, from common.Address) (err error)
- func (k *Keeper) DeleteAccount(ctx sdk.Context, addr common.Address) error
- func (k *Keeper) DeleteCode(ctx sdk.Context, codeHash []byte)
- func (k *Keeper) DeleteCodeHash(ctx sdk.Context, addr common.Address)
- func (k *Keeper) DeleteState(ctx sdk.Context, addr common.Address, key common.Hash)
- func (k *Keeper) EVMConfig(ctx sdk.Context, proposerAddress sdk.ConsAddress) (_ *statedb.EVMConfig, err error)
- func (k Keeper) EmitBlockBloomEvent(ctx sdk.Context, bloom []byte)
- func (k Keeper) EnableEIPs(ctx sdk.Context, eips ...int64) (err error)
- func (k Keeper) EnableStaticPrecompiles(ctx sdk.Context, addresses ...common.Address) (err error)
- func (k *Keeper) EnableVirtualFeeCollection()
- func (k *Keeper) EndBlock(ctx sdk.Context) (err error)
- func (k Keeper) EstimateGas(c context.Context, req *types.EthCallRequest) (_ *types.EstimateGasResponse, err error)
- func (k Keeper) EstimateGasInternal(c context.Context, req *types.EthCallRequest, fromType types.CallType) (_ *types.EstimateGasResponse, err error)
- func (k Keeper) EthCall(c context.Context, req *types.EthCallRequest) (_ *types.MsgEthereumTxResponse, err error)
- func (k *Keeper) EthereumTx(goCtx context.Context, msg *types.MsgEthereumTx) (_ *types.MsgEthereumTxResponse, err error)
- func (k *Keeper) ForEachStorage(ctx sdk.Context, addr common.Address, cb func(key, value common.Hash) bool)
- func (k *Keeper) GetAccount(ctx sdk.Context, addr common.Address) *statedb.Account
- func (k *Keeper) GetAccountOrEmpty(ctx sdk.Context, addr common.Address) statedb.Account
- func (k Keeper) GetAccountStorage(ctx sdk.Context, address common.Address) types.Storage
- func (k *Keeper) GetAccountWithoutBalance(ctx sdk.Context, addr common.Address) *statedb.Account
- func (k Keeper) GetAuthority() sdk.AccAddress
- func (k *Keeper) GetBalance(ctx sdk.Context, addr common.Address) *uint256.Int
- func (k Keeper) GetBaseFee(ctx sdk.Context) *big.Int
- func (k *Keeper) GetCode(ctx sdk.Context, codeHash common.Hash) []byte
- func (k *Keeper) GetCodeHash(ctx sdk.Context, addr common.Address) common.Hash
- func (k Keeper) GetCoinbaseAddress(ctx sdk.Context, proposerAddress sdk.ConsAddress) (_ common.Address, err error)
- func (k *Keeper) GetEthIntrinsicGas(ctx sdk.Context, msg core.Message, cfg *params.ChainConfig, ...) (_ uint64, err error)
- func (k Keeper) GetEvmCoinInfo(ctx sdk.Context) types.EvmCoinInfo
- func (k *Keeper) GetFastState(ctx sdk.Context, addr common.Address, key common.Hash) []byte
- func (k Keeper) GetHashFn(ctx sdk.Context) vm.GetHashFunc
- func (k Keeper) GetHeaderHash(ctx sdk.Context, height uint64) common.Hash
- func (k Keeper) GetMinGasPrice(ctx sdk.Context) math.LegacyDec
- func (k *Keeper) GetNonce(ctx sdk.Context, addr common.Address) uint64
- func (k Keeper) GetParams(ctx sdk.Context) (params types.Params)
- func (k *Keeper) GetPrecompileInstance(ctx sdktypes.Context, address common.Address) (_ *Precompiles, _ bool, err error)
- func (k *Keeper) GetPrecompileRecipientCallHook(ctx sdktypes.Context) types.CallHook
- func (k *Keeper) GetPrecompilesCallHook(ctx sdktypes.Context) types.CallHook
- func (k *Keeper) GetState(ctx sdk.Context, addr common.Address, key common.Hash) common.Hash
- func (k *Keeper) GetStaticPrecompileInstance(params *types.Params, address common.Address) (vm.PrecompiledContract, bool, error)
- func (k Keeper) GetTransientGasUsed(ctx sdk.Context) uint64
- func (k Keeper) GlobalMinGasPrice(c context.Context, _ *types.QueryGlobalMinGasPriceRequest) (*types.QueryGlobalMinGasPriceResponse, error)
- func (k *Keeper) HasHooks() bool
- func (k Keeper) InitEvmCoinInfo(ctx sdk.Context) (err error)
- func (k Keeper) IsAvailableStaticPrecompile(params *types.Params, address common.Address) bool
- func (k *Keeper) IsContract(ctx sdk.Context, addr common.Address) bool
- func (k Keeper) IterateContracts(ctx sdk.Context, ...)
- func (k Keeper) KVStoreKeys() map[string]storetypes.StoreKey
- func (k Keeper) LoadEvmCoinInfo(ctx sdk.Context) (_ types.EvmCoinInfo, err error)
- func (k Keeper) Logger(ctx sdk.Context) log.Logger
- func (k *Keeper) NewEVM(ctx sdk.Context, msg core.Message, cfg *statedb.EVMConfig, ...) *vm.EVM
- func (k *Keeper) NewEVMWithOverridePrecompiles(ctx sdk.Context, msg core.Message, cfg *statedb.EVMConfig, ...) *vm.EVM
- func (k Keeper) Params(c context.Context, _ *types.QueryParamsRequest) (_ *types.QueryParamsResponse, err error)
- func (k *Keeper) PostTxProcessing(ctx sdk.Context, sender common.Address, msg core.Message, ...) (err error)
- func (k *Keeper) RefundGas(ctx sdk.Context, msg core.Message, leftoverGas uint64, denom string) (err error)
- func (k *Keeper) RegisterPreinstalls(goCtx context.Context, req *types.MsgRegisterPreinstalls) (_ *types.MsgRegisterPreinstallsResponse, err error)
- func (k *Keeper) RegisterStaticPrecompile(address common.Address, precompile vm.PrecompiledContract)
- func (k *Keeper) ResetGasMeterAndConsumeGas(ctx sdk.Context, gasUsed uint64)
- func (k *Keeper) SetAccount(ctx sdk.Context, addr common.Address, account statedb.Account) (err error)
- func (k *Keeper) SetBalance(ctx sdk.Context, addr common.Address, amount *uint256.Int) (err error)
- func (k *Keeper) SetCode(ctx sdk.Context, codeHash, code []byte)
- func (k *Keeper) SetCodeHash(ctx sdk.Context, addrBytes, hashBytes []byte)
- func (k *Keeper) SetConsensusParamsInCtx(ctx sdk.Context) sdk.Context
- func (k Keeper) SetEvmCoinInfo(ctx sdk.Context, coinInfo types.EvmCoinInfo) (err error)
- func (k Keeper) SetHeaderHash(ctx sdk.Context)
- func (k *Keeper) SetHooks(eh types.EvmHooks) *Keeper
- func (k Keeper) SetParams(ctx sdk.Context, params types.Params) (err error)
- func (k *Keeper) SetState(ctx sdk.Context, addr common.Address, key common.Hash, value []byte)
- func (k Keeper) SetTransientGasUsed(ctx sdk.Context, gasUsed uint64)
- func (k Keeper) SetTxBloom(ctx sdk.Context, bloom *big.Int)
- func (k *Keeper) SpendableCoin(ctx sdk.Context, addr common.Address) *uint256.Int
- func (k Keeper) Storage(c context.Context, req *types.QueryStorageRequest) (_ *types.QueryStorageResponse, err error)
- func (k Keeper) TraceBlock(c context.Context, req *types.QueryTraceBlockRequest) (_ *types.QueryTraceBlockResponse, err error)
- func (k Keeper) TraceCall(c context.Context, req *types.QueryTraceCallRequest) (_ *types.QueryTraceCallResponse, err error)
- func (k Keeper) TraceTx(c context.Context, req *types.QueryTraceTxRequest) (_ *types.QueryTraceTxResponse, err error)
- func (k Keeper) Tracer(ctx sdk.Context, msg core.Message, ethCfg *ethparams.ChainConfig) *tracing.Hooks
- func (k *Keeper) TxConfig(ctx sdk.Context, txHash common.Hash) statedb.TxConfig
- func (k *Keeper) UpdateParams(goCtx context.Context, req *types.MsgUpdateParams) (_ *types.MsgUpdateParamsResponse, err error)
- func (k Keeper) VMConfig(ctx sdk.Context, _ core.Message, cfg *statedb.EVMConfig, ...) vm.Config
- func (k Keeper) ValidatorAccount(c context.Context, req *types.QueryValidatorAccountRequest) (_ *types.QueryValidatorAccountResponse, err error)
- func (k *Keeper) WithStaticPrecompiles(precompiles map[common.Address]vm.PrecompiledContract) *Keeper
- type MultiEvmHooks
- type Precompiles
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckSenderBalance ¶
func CheckSenderBalance( balance sdkmath.Int, ethTx *ethtypes.Transaction, ) error
CheckSenderBalance validates that the tx cost value is positive and that the sender has enough funds to pay for the fees and value of the transaction.
func DeductFees ¶ added in v0.7.0
func DeductFees(bankKeeper types.BankKeeper, vmKeeper types.VMKeeper, ctx sdk.Context, acc sdk.AccountI, fees sdk.Coins) (err error)
DeductFees deducts fees from the given account.
func GasToRefund ¶
GasToRefund calculates the amount of gas the state machine should refund to the sender. It is capped by the refund quotient value. Note: do not pass 0 to refundQuotient
func GetProposerAddress ¶
func GetProposerAddress(ctx sdk.Context, proposerAddress sdk.ConsAddress) sdk.ConsAddress
GetProposerAddress returns current block proposer's address when provided proposer address is empty.
func VerifyFee ¶
func VerifyFee( ethTx *ethtypes.Transaction, denom string, baseFee *big.Int, homestead, istanbul, shanghai, isCheckTx bool, ) (sdk.Coins, error)
VerifyFee is used to return the fee for the given transaction data in sdk.Coins. It checks that the gas limit is not reached, the gas limit is higher than the intrinsic gas and that the base fee is higher than the gas fee cap.
Types ¶
type Keeper ¶
type Keeper struct {
// contains filtered or unexported fields
}
Keeper grants access to the EVM module state and implements the go-ethereum StateDB interface.
func NewKeeper ¶
func NewKeeper( cdc codec.BinaryCodec, storeKey, objectKey storetypes.StoreKey, keys []storetypes.StoreKey, authority sdk.AccAddress, ak types.AccountKeeper, bankKeeper types.BankKeeper, sk types.StakingKeeper, fmk types.FeeMarketKeeper, consensusKeeper types.ConsensusParamsKeeper, erc20Keeper types.Erc20Keeper, evmChainID uint64, tracer string, ) *Keeper
NewKeeper generates new evm module keeper
func (Keeper) Account ¶
func (k Keeper) Account(c context.Context, req *types.QueryAccountRequest) (_ *types.QueryAccountResponse, err error)
Account implements the Query/Account gRPC method. The method returns the *spendable* balance of the account in 18 decimals representation.
func (*Keeper) AddPreinstalls ¶ added in v0.4.0
func (Keeper) AddTransientGasUsed ¶
AddTransientGasUsed accumulate gas used by each eth msgs included in current cosmos tx.
func (*Keeper) ApplyMessage ¶
func (k *Keeper) ApplyMessage(ctx sdk.Context, stateDB *statedb.StateDB, msg core.Message, tracingHooks *tracing.Hooks, commit, callFromPrecompile, internal bool) (*types.MsgEthereumTxResponse, error)
ApplyMessage calls ApplyMessageWithConfig with an empty TxConfig. Note: if you call this from a precompile context, ensure that you use the existing stateDB.
func (*Keeper) ApplyMessageWithConfig ¶
func (k *Keeper) ApplyMessageWithConfig(ctx sdk.Context, stateDB *statedb.StateDB, msg core.Message, tracingHooks *tracing.Hooks, commit bool, callFromPrecompile bool, cfg *statedb.EVMConfig, txConfig statedb.TxConfig, internal bool, overrides *rpctypes.StateOverride) (_ *types.MsgEthereumTxResponse, err error)
ApplyMessageWithConfig computes the new state by applying the given message against the existing state. If the message fails, the VM execution error with the reason will be returned to the client and the transaction won't be committed to the store.
Reverted state ¶
The snapshot and rollback are supported by the `statedb.StateDB`.
Different Callers ¶
It's called in three scenarios: 1. `ApplyTransaction`, in the transaction processing flow. 2. `EthCall/EthEstimateGas` grpc query handler. 3. Called by other native modules directly.
Prechecks and Preprocessing ¶
All relevant state transition prechecks for the MsgEthereumTx are performed on the AnteHandler, prior to running the transaction against the state. The prechecks run are the following:
1. the nonce of the message caller is correct 2. caller has enough balance to cover transaction fee(gaslimit * gasprice) 3. the amount of gas required is available in the block 4. the purchased gas is enough to cover intrinsic usage 5. there is no overflow when calculating intrinsic gas 6. caller has enough balance to cover asset transfer for **topmost** call
The preprocessing steps performed by the AnteHandler are:
1. set up the initial access list (iff fork > Berlin)
Tracer parameter ¶
It should be a `vm.Tracer` object or nil, if pass `nil`, it'll create a default one based on keeper options.
Commit parameter ¶
If commit is true, the `StateDB` will be committed or flushed (if called from within a precompile), otherwise discarded.
func (*Keeper) ApplyTransaction ¶
func (k *Keeper) ApplyTransaction(ctx sdk.Context, tx *ethtypes.Transaction) (_ *types.MsgEthereumTxResponse, err error)
ApplyTransaction runs and attempts to perform a state transition with the given transaction (i.e Message), that will only be persisted (committed) to the underlying KVStore if the transaction does not fail.
Gas tracking ¶
Ethereum consumes gas according to the EVM opcodes instead of general reads and writes to store. Because of this, the state transition needs to ignore the SDK gas consumption mechanism defined by the GasKVStore and instead consume the amount of gas used by the VM execution. The amount of gas used is tracked by the EVM and returned in the execution result.
Prior to the execution, the starting tx gas meter is saved and replaced with an infinite gas meter in a new context to ignore the SDK gas consumption config values (read, write, has, delete). After the execution, the gas used from the message execution will be added to the starting gas consumed, taking into consideration the amount of gas returned. Finally, the context is updated with the EVM gas consumed value prior to returning.
For relevant discussion see: https://github.com/cosmos/cosmos-sdk/discussions/9072
func (Keeper) Balance ¶
func (k Keeper) Balance(c context.Context, req *types.QueryBalanceRequest) (_ *types.QueryBalanceResponse, err error)
Balance implements the Query/Balance gRPC method. The method returns the 18 decimal representation of the account's *spendable* balance.
func (Keeper) BaseFee ¶
func (k Keeper) BaseFee(c context.Context, _ *types.QueryBaseFeeRequest) (*types.QueryBaseFeeResponse, error)
BaseFee implements the Query/BaseFee gRPC method
func (*Keeper) BeginBlock ¶
BeginBlock emits a base fee event which will be adjusted to the evm decimals
func (Keeper) CallEVM ¶
func (k Keeper) CallEVM(ctx sdk.Context, stateDB *statedb.StateDB, abi abi.ABI, from, contract common.Address, commit, callFromPrecompile bool, gasCap *big.Int, method string, args ...interface{}) (_ *types.MsgEthereumTxResponse, err error)
CallEVM performs a smart contract method call using given args. Note: if you call this from a precompile context, ensure that you use the existing stateDB.
func (Keeper) CallEVMWithData ¶
func (k Keeper) CallEVMWithData(ctx sdk.Context, stateDB *statedb.StateDB, from common.Address, contract *common.Address, data []byte, commit bool, callFromPrecompile bool, gasCap *big.Int) (_ *types.MsgEthereumTxResponse, err error)
CallEVMWithData performs a smart contract method call using contract data. Note: if you call this from a precompile context, ensure that you use the existing stateDB.
func (Keeper) Code ¶
func (k Keeper) Code(c context.Context, req *types.QueryCodeRequest) (_ *types.QueryCodeResponse, err error)
Code implements the Query/Code gRPC method
func (Keeper) CollectTxBloom ¶ added in v0.7.0
CollectTxBloom collects all tx blooms and emit a single block bloom event
func (Keeper) Config ¶
func (k Keeper) Config(ctx context.Context, _ *types.QueryConfigRequest) (*types.QueryConfigResponse, error)
Config implements the Query/Config gRPC method
func (Keeper) CosmosAccount ¶
func (k Keeper) CosmosAccount(c context.Context, req *types.QueryCosmosAccountRequest) (_ *types.QueryCosmosAccountResponse, err error)
func (*Keeper) DeductTxCostsFromUserBalance ¶
func (k *Keeper) DeductTxCostsFromUserBalance( ctx sdk.Context, fees sdk.Coins, from common.Address, ) (err error)
DeductTxCostsFromUserBalance deducts the fees from the user balance.
func (*Keeper) DeleteAccount ¶
DeleteAccount handles contract's suicide call: - clear balance - remove code - remove states - remove the code hash - remove auth account
func (*Keeper) DeleteCode ¶
DeleteCode deletes the contract code for the given code hash bytes in the corresponding store.
func (*Keeper) DeleteCodeHash ¶
DeleteCodeHash deletes the code hash for the given contract address from the store.
func (*Keeper) DeleteState ¶
DeleteState deletes the entry for the given key in the contract storage at the defined contract address.
func (*Keeper) EVMConfig ¶
func (k *Keeper) EVMConfig(ctx sdk.Context, proposerAddress sdk.ConsAddress) (_ *statedb.EVMConfig, err error)
EVMConfig creates the EVMConfig based on current state
func (Keeper) EmitBlockBloomEvent ¶
EmitBlockBloomEvent emit block bloom events
func (Keeper) EnableEIPs ¶
EnableEIPs enables the given EIPs in the EVM parameters.
func (Keeper) EnableStaticPrecompiles ¶
EnableStaticPrecompiles appends the addresses of the given Precompiles to the list of active static precompiles.
func (*Keeper) EnableVirtualFeeCollection ¶ added in v0.7.0
func (k *Keeper) EnableVirtualFeeCollection()
EnableVirtualFeeCollection switches fee deduction for evm transactions to use the virtual fee collection of the bank keeper via the object store. Note: Do NOT use this if your chain does not have an 18 decimal point precision gas token.
func (*Keeper) EndBlock ¶
EndBlock also retrieves the bloom filter value from the transient store and commits it to the KVStore. The EVM end block logic doesn't update the validator set, thus it returns an empty slice.
func (Keeper) EstimateGas ¶
func (k Keeper) EstimateGas(c context.Context, req *types.EthCallRequest) (_ *types.EstimateGasResponse, err error)
EstimateGas implements eth_estimateGas rpc api.
func (Keeper) EstimateGasInternal ¶
func (k Keeper) EstimateGasInternal(c context.Context, req *types.EthCallRequest, fromType types.CallType) (_ *types.EstimateGasResponse, err error)
EstimateGasInternal returns the gas estimation for the corresponding request. This function is called from the RPC client (eth_estimateGas) and internally. When called from the RPC client, we need to reset the gas meter before simulating the transaction to have an accurate gas estimation for EVM extensions transactions.
func (Keeper) EthCall ¶
func (k Keeper) EthCall(c context.Context, req *types.EthCallRequest) (_ *types.MsgEthereumTxResponse, err error)
EthCall implements eth_call rpc api.
func (*Keeper) EthereumTx ¶
func (k *Keeper) EthereumTx(goCtx context.Context, msg *types.MsgEthereumTx) (_ *types.MsgEthereumTxResponse, err error)
EthereumTx implements the gRPC MsgServer interface. It receives a transaction which is then executed (i.e applied) against the go-ethereum EVM. The provided SDK Context is set to the Keeper so that it can implements and call the StateDB methods without receiving it as a function parameter.
func (*Keeper) ForEachStorage ¶
func (k *Keeper) ForEachStorage(ctx sdk.Context, addr common.Address, cb func(key, value common.Hash) bool)
ForEachStorage iterate contract storage, callback return false to break early
func (*Keeper) GetAccount ¶
GetAccount returns nil if account is not exist
func (*Keeper) GetAccountOrEmpty ¶
GetAccountOrEmpty returns empty account if not exist.
func (Keeper) GetAccountStorage ¶
GetAccountStorage return state storage associated with an account
func (*Keeper) GetAccountWithoutBalance ¶
GetAccountWithoutBalance load nonce and codehash without balance, more efficient in cases where balance is not needed.
func (Keeper) GetAuthority ¶
func (k Keeper) GetAuthority() sdk.AccAddress
GetAuthority returns the x/evm module authority address
func (*Keeper) GetBalance ¶
GetBalance load account's balance of gas token.
func (Keeper) GetBaseFee ¶
GetBaseFee returns current base fee, return values: - `nil`: london hardfork not enabled. - `0`: london hardfork enabled but feemarket is not enabled. - `n`: both london hardfork and feemarket are enabled.
func (*Keeper) GetCode ¶
GetCode loads contract code from database, implements `statedb.Keeper` interface.
func (*Keeper) GetCodeHash ¶
GetCodeHash loads the code hash from the database for the given contract address.
func (Keeper) GetCoinbaseAddress ¶
func (k Keeper) GetCoinbaseAddress(ctx sdk.Context, proposerAddress sdk.ConsAddress) (_ common.Address, err error)
GetCoinbaseAddress converts the block proposer's validator operator address to an Ethereum address for use as block.coinbase in the EVM.
func (*Keeper) GetEthIntrinsicGas ¶
func (k *Keeper) GetEthIntrinsicGas(ctx sdk.Context, msg core.Message, cfg *params.ChainConfig, isContractCreation bool, ) (_ uint64, err error)
GetEthIntrinsicGas returns the intrinsic gas cost for the transaction
func (Keeper) GetEvmCoinInfo ¶ added in v0.5.0
func (k Keeper) GetEvmCoinInfo(ctx sdk.Context) types.EvmCoinInfo
GetEvmCoinInfo returns the EVM Coin Info stored in the module Make sure to call this method ONLY after genesis block.
func (*Keeper) GetFastState ¶
GetFastState loads contract state from database.
func (Keeper) GetHashFn ¶
func (k Keeper) GetHashFn(ctx sdk.Context) vm.GetHashFunc
GetHashFn implements vm.GetHashFunc for Ethermint. It handles 3 cases:
- The requested height matches the current height from context (and thus same epoch number)
- The requested height is from an previous height from the same chain epoch
- The requested height is from a height greater than the latest one
func (Keeper) GetHeaderHash ¶ added in v0.5.0
GetHeaderHash sets block hash into EIP-2935 compatible storage contract.
func (Keeper) GetMinGasPrice ¶
GetMinGasPrice returns the MinGasPrice param from the fee market module adapted according to the evm denom decimals
func (*Keeper) GetNonce ¶
GetNonce returns the sequence number of an account, returns 0 if not exists.
func (*Keeper) GetPrecompileInstance ¶
func (k *Keeper) GetPrecompileInstance( ctx sdktypes.Context, address common.Address, ) (_ *Precompiles, _ bool, err error)
GetPrecompileInstance returns the address and instance of the static or dynamic precompile associated with the given address, or return nil if not found.
func (*Keeper) GetPrecompileRecipientCallHook ¶ added in v0.5.0
GetPrecompileRecipientCallHook returns a call hook for use with state overrides. It checks active precompiles first, then only dynamic precompiles (not static ones which may have been moved/disabled by state overrides).
func (*Keeper) GetPrecompilesCallHook ¶
GetPrecompilesCallHook returns a closure that can be used to instantiate the EVM with a specific precompile instance.
func (*Keeper) GetStaticPrecompileInstance ¶
func (k *Keeper) GetStaticPrecompileInstance(params *types.Params, address common.Address) (vm.PrecompiledContract, bool, error)
GetStaticPrecompileInstance returns the instance of the given static precompile address.
func (Keeper) GetTransientGasUsed ¶
GetTransientGasUsed returns the gas used by current cosmos tx.
func (Keeper) GlobalMinGasPrice ¶
func (k Keeper) GlobalMinGasPrice(c context.Context, _ *types.QueryGlobalMinGasPriceRequest) (*types.QueryGlobalMinGasPriceResponse, error)
GlobalMinGasPrice implements the Query/GlobalMinGasPrice gRPC method
func (Keeper) InitEvmCoinInfo ¶ added in v0.5.0
InitEvmCoinInfo load EvmCoinInfo from bank denom metadata and store it in the module
func (Keeper) IsAvailableStaticPrecompile ¶
IsAvailablePrecompile returns true if the given static precompile address is contained in the EVM keeper's available precompiles map. This function assumes that the Berlin precompiles cannot be disabled.
func (*Keeper) IsContract ¶
IsContract determines if the given address is a smart contract. It checks if the account has associated code and ensures that the code is not a delegated contract (EIP-7702).
func (Keeper) IterateContracts ¶
func (k Keeper) IterateContracts(ctx sdk.Context, cb func(addr common.Address, codeHash common.Hash) (stop bool))
IterateContracts iterates over all smart contract addresses in the EVM keeper and performs a callback function.
The iteration is stopped when the callback function returns true.
func (Keeper) KVStoreKeys ¶ added in v0.3.0
func (k Keeper) KVStoreKeys() map[string]storetypes.StoreKey
KVStoreKeys returns KVStore keys injected to keeper
func (Keeper) LoadEvmCoinInfo ¶ added in v0.5.0
LoadEvmCoinInfo load EvmCoinInfo from bank denom metadata
func (*Keeper) NewEVM ¶
func (k *Keeper) NewEVM( ctx sdk.Context, msg core.Message, cfg *statedb.EVMConfig, tracingHooks *tracing.Hooks, stateDB vm.StateDB, ) *vm.EVM
NewEVM generates a go-ethereum VM from the provided Message fields and the chain parameters (ChainConfig and module Params). It additionally sets the validator operator address as the coinbase address to make it available for the COINBASE opcode, even though there is no beneficiary of the coinbase transaction (since we're not mining).
NOTE: the RANDOM opcode is currently not supported since it requires RANDAO implementation. See https://github.com/evmos/ethermint/pull/1520#pullrequestreview-1200504697 for more information.
func (*Keeper) NewEVMWithOverridePrecompiles ¶ added in v0.5.0
func (k *Keeper) NewEVMWithOverridePrecompiles( ctx sdk.Context, msg core.Message, cfg *statedb.EVMConfig, tracingHooks *tracing.Hooks, stateDB vm.StateDB, overridePrecompiles bool, ) *vm.EVM
NewEVMWithOverridePrecompiles creates a new EVM instance with opcode hooks and optionally overrides the precompiles call hook. If overridePrecompiles is true, the EVM will use the keeper's static precompiles for call hooks; otherwise, it will use the recipient-specific precompile hook. This is useful for scenarios such as eth_call, state overrides, or testing where custom precompile logic is needed. The function sets up the block context, transaction context, and VM configuration before returning the EVM instance.
func (Keeper) Params ¶
func (k Keeper) Params(c context.Context, _ *types.QueryParamsRequest) (_ *types.QueryParamsResponse, err error)
Params implements the Query/Params gRPC method
func (*Keeper) PostTxProcessing ¶ added in v0.2.0
func (k *Keeper) PostTxProcessing( ctx sdk.Context, sender common.Address, msg core.Message, receipt *ethtypes.Receipt, ) (err error)
PostTxProcessing delegates the call to the hooks. If no hook has been registered, this function returns with a `nil` error
func (*Keeper) RefundGas ¶
func (k *Keeper) RefundGas(ctx sdk.Context, msg core.Message, leftoverGas uint64, denom string) (err error)
RefundGas transfers the leftover gas to the sender of the message, capped to half of the total gas consumed in the transaction. Additionally, the function sets the total gas consumed to the value returned by the EVM execution, thus ignoring the previous intrinsic gas consumed during in the AnteHandler.
func (*Keeper) RegisterPreinstalls ¶ added in v0.4.0
func (k *Keeper) RegisterPreinstalls(goCtx context.Context, req *types.MsgRegisterPreinstalls) ( _ *types.MsgRegisterPreinstallsResponse, err error, )
RegisterPreinstalls implements the gRPC MsgServer interface. When a RegisterPreinstalls proposal passes, it creates the preinstalls. The registration can only be performed if the requested authority is the Cosmos SDK governance module account.
func (*Keeper) RegisterStaticPrecompile ¶ added in v0.3.2
func (k *Keeper) RegisterStaticPrecompile(address common.Address, precompile vm.PrecompiledContract)
WithStaticPrecompiles sets the available static precompiled contracts.
func (*Keeper) ResetGasMeterAndConsumeGas ¶
ResetGasMeterAndConsumeGas reset first the gas meter consumed value to zero and set it back to the new value 'gasUsed'
func (*Keeper) SetAccount ¶
func (k *Keeper) SetAccount(ctx sdk.Context, addr common.Address, account statedb.Account) (err error)
SetAccount updates nonce/balance/codeHash together.
func (*Keeper) SetBalance ¶
SetBalance update account's balance, compare with current balance first, then decide to mint or burn.
func (*Keeper) SetCode ¶
SetCode sets the given contract code bytes for the corresponding code hash bytes key in the code store.
func (*Keeper) SetCodeHash ¶
SetCodeHash sets the code hash for the given contract address.
func (*Keeper) SetConsensusParamsInCtx ¶ added in v0.3.0
SetConsensusParamsInCtx will return the original context if consensus params already exist in it, otherwise, it will query the consensus params from the consensus params keeper and then set it in context.
func (Keeper) SetEvmCoinInfo ¶ added in v0.5.0
SetEvmCoinInfo sets the EVM Coin Info stored in the module
func (Keeper) SetHeaderHash ¶ added in v0.5.0
SetHeaderHash sets current block hash into EIP-2935 compatible storage contract.
func (*Keeper) SetHooks ¶ added in v0.2.0
SetHooks sets the hooks for the EVM module Called only once during initialization, panics if called more than once.
func (Keeper) SetParams ¶
SetParams sets the EVM params each in their individual key for better get performance
func (Keeper) SetTransientGasUsed ¶
SetTransientGasUsed sets the gas used by current cosmos tx.
func (Keeper) SetTxBloom ¶ added in v0.7.0
SetTxBloom sets the given bloom bytes to the object store. This value is reset on every block.
func (*Keeper) SpendableCoin ¶ added in v0.3.0
SpendableCoin load account's balance of gas token.
func (Keeper) Storage ¶
func (k Keeper) Storage(c context.Context, req *types.QueryStorageRequest) (_ *types.QueryStorageResponse, err error)
Storage implements the Query/Storage gRPC method
func (Keeper) TraceBlock ¶
func (k Keeper) TraceBlock(c context.Context, req *types.QueryTraceBlockRequest) (_ *types.QueryTraceBlockResponse, err error)
TraceBlock configures a new tracer according to the provided configuration, and executes the given message in the provided environment for all the transactions in the queried block. The return value will be tracer dependent.
func (Keeper) TraceCall ¶ added in v0.5.0
func (k Keeper) TraceCall(c context.Context, req *types.QueryTraceCallRequest) (_ *types.QueryTraceCallResponse, err error)
TraceCall configures a new tracer according to the provided configuration, and executes the given call in the provided environment. The return value will be tracer dependent.
func (Keeper) TraceTx ¶
func (k Keeper) TraceTx(c context.Context, req *types.QueryTraceTxRequest) (_ *types.QueryTraceTxResponse, err error)
TraceTx configures a new tracer according to the provided configuration, and executes the given message in the provided environment. The return value will be tracer-dependent.
func (Keeper) Tracer ¶
func (k Keeper) Tracer(ctx sdk.Context, msg core.Message, ethCfg *ethparams.ChainConfig) *tracing.Hooks
Tracer return a default vm.Tracer based on current keeper state
func (*Keeper) UpdateParams ¶
func (k *Keeper) UpdateParams(goCtx context.Context, req *types.MsgUpdateParams) (_ *types.MsgUpdateParamsResponse, err error)
UpdateParams implements the gRPC MsgServer interface. When an UpdateParams proposal passes, it updates the module parameters. The update can only be performed if the requested authority is the Cosmos SDK governance module account.
func (Keeper) VMConfig ¶
func (k Keeper) VMConfig(ctx sdk.Context, _ core.Message, cfg *statedb.EVMConfig, tracingHooks *tracing.Hooks) vm.Config
VMConfig creates an EVM configuration from the debug setting and the extra EIPs enabled on the module parameters. The config generated uses the default JumpTable from the EVM.
func (Keeper) ValidatorAccount ¶
func (k Keeper) ValidatorAccount(c context.Context, req *types.QueryValidatorAccountRequest) (_ *types.QueryValidatorAccountResponse, err error)
ValidatorAccount implements the Query/Balance gRPC method
func (*Keeper) WithStaticPrecompiles ¶
func (k *Keeper) WithStaticPrecompiles(precompiles map[common.Address]vm.PrecompiledContract) *Keeper
WithStaticPrecompiles sets the available static precompiled contracts.
type MultiEvmHooks ¶ added in v0.2.0
MultiEvmHooks combine multiple evm hooks, all hook functions are run in array sequence
func NewMultiEvmHooks ¶ added in v0.2.0
func NewMultiEvmHooks(hooks ...types.EvmHooks) MultiEvmHooks
NewMultiEvmHooks combine multiple evm hooks