Documentation ¶
Overview ¶
Copyright 2021 Evmos Foundation This file is part of Evmos' Ethermint library.
The Ethermint library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
The Ethermint library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with the Ethermint library. If not, see https://github.com/Helios-Chain-Labs/ethermint/blob/main/LICENSE
Copyright 2021 Evmos Foundation This file is part of Evmos' Ethermint library.
The Ethermint library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
The Ethermint library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with the Ethermint library. If not, see https://github.com/Helios-Chain-Labs/ethermint/blob/main/LICENSE
Copyright 2021 Evmos Foundation This file is part of Evmos' Ethermint library.
The Ethermint library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
The Ethermint library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with the Ethermint library. If not, see https://github.com/Helios-Chain-Labs/ethermint/blob/main/LICENSE
Copyright 2021 Evmos Foundation This file is part of Evmos' Ethermint library.
The Ethermint library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
The Ethermint library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with the Ethermint library. If not, see https://github.com/Helios-Chain-Labs/ethermint/blob/main/LICENSE
Copyright 2021 Evmos Foundation This file is part of Evmos' Ethermint library.
The Ethermint library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
The Ethermint library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with the Ethermint library. If not, see https://github.com/Helios-Chain-Labs/ethermint/blob/main/LICENSE
Copyright 2021 Evmos Foundation This file is part of Evmos' Ethermint library.
The Ethermint library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
The Ethermint library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with the Ethermint library. If not, see https://github.com/Helios-Chain-Labs/ethermint/blob/main/LICENSE
Copyright 2021 Evmos Foundation This file is part of Evmos' Ethermint library.
The Ethermint library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
The Ethermint library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with the Ethermint library. If not, see https://github.com/Helios-Chain-Labs/ethermint/blob/main/LICENSE
Copyright 2021 Evmos Foundation This file is part of Evmos' Ethermint library.
The Ethermint library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
The Ethermint library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with the Ethermint library. If not, see https://github.com/Helios-Chain-Labs/ethermint/blob/main/LICENSE
Copyright 2021 Evmos Foundation This file is part of Evmos' Ethermint library.
The Ethermint library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
The Ethermint library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with the Ethermint library. If not, see https://github.com/Helios-Chain-Labs/ethermint/blob/main/LICENSE
Copyright 2021 Evmos Foundation This file is part of Evmos' Ethermint library.
The Ethermint library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
The Ethermint library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with the Ethermint library. If not, see https://github.com/Helios-Chain-Labs/ethermint/blob/main/LICENSE
Copyright 2021 Evmos Foundation This file is part of Evmos' Ethermint library.
The Ethermint library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
The Ethermint library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with the Ethermint library. If not, see https://github.com/Helios-Chain-Labs/ethermint/blob/main/LICENSE
Copyright 2021 Evmos Foundation This file is part of Evmos' Ethermint library.
The Ethermint library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
The Ethermint library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with the Ethermint library. If not, see https://github.com/Helios-Chain-Labs/ethermint/blob/main/LICENSE
Index ¶
- func BlocksBloom(k *Keeper, ctx sdk.Context) *big.Int
- func CheckSenderBalance(balance sdkmath.Int, tx *ethtypes.Transaction) error
- func DeductFees(bankKeeper types.BankKeeper, ctx sdk.Context, acc sdk.AccountI, fees sdk.Coins) error
- func GasToRefund(availableRefund, gasConsumed, refundQuotient uint64) uint64
- func GetProposerAddress(ctx sdk.Context, proposerAddress sdk.ConsAddress) sdk.ConsAddress
- func ToCosmosEndBlockEvent(k *Keeper, ctx sdk.Context) tracing.CosmosEndBlockEvent
- func ToCosmosStartBlockEvent(k *Keeper, ctx sdk.Context, coinbaseAddr common.Address, ...) tracing.CosmosStartBlockEvent
- func VerifyFee(msg *types.MsgEthereumTx, denom string, baseFee *big.Int, ...) (sdk.Coins, error)
- type CustomContractFn
- type EVMBlockConfig
- type EVMConfig
- type Keeper
- func (k Keeper) Account(c context.Context, req *types.QueryAccountRequest) (*types.QueryAccountResponse, error)
- func (k *Keeper) AddBalance(ctx sdk.Context, addr sdk.AccAddress, coins sdk.Coins) error
- func (k Keeper) AddTransientGasUsed(ctx sdk.Context, gasUsed uint64) (uint64, error)
- func (k *Keeper) ApplyMessage(ctx sdk.Context, msg *core.Message, tracer *tracers.Tracer, commit bool) (*types.MsgEthereumTxResponse, error)
- func (k *Keeper) ApplyMessageWithConfig(ctx sdk.Context, msg *core.Message, cfg *EVMConfig, commit bool) (resp *types.MsgEthereumTxResponse, err error)
- func (k *Keeper) ApplyTransaction(ctx sdk.Context, msgEth *types.MsgEthereumTx) (*types.MsgEthereumTxResponse, error)
- func (k Keeper) Balance(c context.Context, req *types.QueryBalanceRequest) (*types.QueryBalanceResponse, error)
- func (k Keeper) BaseFee(c context.Context, _ *types.QueryBaseFeeRequest) (*types.QueryBaseFeeResponse, error)
- func (k *Keeper) BeginBlock(ctx sdk.Context) error
- func (k Keeper) ChainID() *big.Int
- func (k Keeper) Code(c context.Context, req *types.QueryCodeRequest) (*types.QueryCodeResponse, error)
- func (k Keeper) CollectTxBloom(ctx sdk.Context)
- func (k Keeper) CosmosAccount(c context.Context, req *types.QueryCosmosAccountRequest) (*types.QueryCosmosAccountResponse, error)
- func (k *Keeper) DeductTxCostsFromUserBalance(ctx sdk.Context, fees sdk.Coins, from common.Address) error
- func (k *Keeper) DeleteAccount(ctx sdk.Context, addr common.Address) error
- func (k *Keeper) EVMBlockConfig(ctx sdk.Context, chainID *big.Int) (*EVMBlockConfig, error)
- func (k *Keeper) EVMConfig(ctx sdk.Context, chainID *big.Int, txHash common.Hash) (*EVMConfig, error)
- func (k Keeper) EmitBlockBloomEvent(ctx sdk.Context, bloom []byte)
- func (k *Keeper) EndBlock(ctx sdk.Context) error
- func (k Keeper) EstimateGas(c context.Context, req *types.EthCallRequest) (*types.EstimateGasResponse, error)
- func (k Keeper) EthCall(c context.Context, req *types.EthCallRequest) (*types.MsgEthereumTxResponse, error)
- func (k *Keeper) EthereumTx(goCtx context.Context, msg *types.MsgEthereumTx) (*types.MsgEthereumTxResponse, 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) GetAuthority() sdk.AccAddress
- func (k *Keeper) GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) *big.Int
- func (k Keeper) GetBaseFee(ctx sdk.Context, ethCfg *params.ChainConfig) *big.Int
- func (k *Keeper) GetCode(ctx sdk.Context, codeHash common.Hash) []byte
- func (k Keeper) GetCoinbaseAddress(ctx sdk.Context) (common.Address, error)
- func (k *Keeper) GetEVMDenomBalance(ctx sdk.Context, addr common.Address) *big.Int
- func (k *Keeper) GetEthIntrinsicGas(msg *core.Message, rules params.Rules, isContractCreation bool) (uint64, error)
- func (k Keeper) GetHashFn(ctx sdk.Context) vm.GetHashFunc
- func (k Keeper) GetLegacyParams(ctx sdk.Context) types.Params
- func (k *Keeper) GetNonce(ctx sdk.Context, addr common.Address) uint64
- func (k Keeper) GetParams(ctx sdk.Context) types.Params
- func (k *Keeper) GetState(ctx sdk.Context, addr common.Address, key common.Hash) common.Hash
- func (k Keeper) GetTransientGasUsed(ctx sdk.Context) uint64
- func (k *Keeper) InitChainer(ctx sdk.Context)
- func (k Keeper) Logger(ctx sdk.Context) log.Logger
- func (k *Keeper) NewEVM(ctx sdk.Context, msg *core.Message, cfg *EVMConfig, stateDB vm.StateDB) *vm.EVM
- func (k Keeper) Params(c context.Context, _ *types.QueryParamsRequest) (*types.QueryParamsResponse, error)
- func (k *Keeper) PostTxProcessing(ctx sdk.Context, msg *core.Message, receipt *ethtypes.Receipt) error
- func (k *Keeper) RefundGas(ctx sdk.Context, msg *core.Message, leftoverGas uint64, denom string) error
- func (k *Keeper) RemoveParamsCache(ctx sdk.Context)
- func (k *Keeper) ResetGasMeterAndConsumeGas(ctx sdk.Context, gasUsed uint64)
- func (k *Keeper) SetAccount(ctx sdk.Context, addr common.Address, account statedb.Account) error
- func (k *Keeper) SetBalance(ctx sdk.Context, addr common.Address, amount *big.Int, evmDenom string) error
- func (k *Keeper) SetCode(ctx sdk.Context, codeHash, code []byte)
- func (k *Keeper) SetHooks(eh types.EvmHooks) *Keeper
- func (k Keeper) SetParams(ctx sdk.Context, p types.Params) error
- func (k *Keeper) SetState(ctx sdk.Context, addr common.Address, key common.Hash, value []byte)
- func (k *Keeper) SetTracer(tracer *cosmostracing.Hooks)
- func (k Keeper) SetTransientGasUsed(ctx sdk.Context, gasUsed uint64)
- func (k Keeper) SetTxBloom(ctx sdk.Context, bloom *big.Int)
- func (k Keeper) Storage(c context.Context, req *types.QueryStorageRequest) (*types.QueryStorageResponse, error)
- func (k *Keeper) SubBalance(ctx sdk.Context, addr sdk.AccAddress, coins sdk.Coins) error
- func (k Keeper) TraceBlock(c context.Context, req *types.QueryTraceBlockRequest) (*types.QueryTraceBlockResponse, error)
- func (k Keeper) TraceCall(c context.Context, req *types.QueryTraceCallRequest) (*types.QueryTraceCallResponse, error)
- func (k Keeper) TraceTx(c context.Context, req *types.QueryTraceTxRequest) (*types.QueryTraceTxResponse, error)
- func (k *Keeper) Transfer(ctx sdk.Context, sender, recipient sdk.AccAddress, coins sdk.Coins) error
- func (k *Keeper) TxConfig(ctx sdk.Context, txHash common.Hash) statedb.TxConfig
- func (k *Keeper) UpdateParams(goCtx context.Context, req *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error)
- func (k Keeper) VMConfig(ctx sdk.Context, cfg *EVMConfig) vm.Config
- func (k Keeper) ValidatorAccount(c context.Context, req *types.QueryValidatorAccountRequest) (*types.QueryValidatorAccountResponse, error)
- func (k *Keeper) WithChainID(ctx sdk.Context)
- type Migrator
- type MultiEvmHooks
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckSenderBalance ¶
func CheckSenderBalance( balance sdkmath.Int, tx *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 ¶
func DeductFees(bankKeeper types.BankKeeper, ctx sdk.Context, acc sdk.AccountI, fees sdk.Coins) 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 ToCosmosEndBlockEvent ¶
func ToCosmosEndBlockEvent(k *Keeper, ctx sdk.Context) tracing.CosmosEndBlockEvent
func ToCosmosStartBlockEvent ¶
func VerifyFee ¶
func VerifyFee( msg *types.MsgEthereumTx, 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 CustomContractFn ¶
CustomContractFn defines a custom precompiled contract generator with ctx, rules and returns a precompiled contract.
type EVMBlockConfig ¶
type EVMBlockConfig struct { Params types.Params FeeMarketParams feemarkettypes.Params ChainConfig *params.ChainConfig CoinBase common.Address BaseFee *big.Int // not supported, always zero Random *common.Hash // unused, always zero Difficulty *big.Int // cache the big.Int version of block number, avoid repeated allocation BlockNumber *big.Int BlockTime uint64 Rules params.Rules }
EVMBlockConfig encapsulates the common parameters needed to execute an EVM message, it's cached in object store during the block execution.
type EVMConfig ¶
type EVMConfig struct { *EVMBlockConfig TxConfig statedb.TxConfig Tracer *cosmostracing.Hooks DebugTrace bool Overrides *rpctypes.StateOverride BlockOverrides *rpctypes.BlockOverrides }
EVMConfig encapsulates common parameters needed to create an EVM to execute a message It's mainly to reduce the number of method parameters
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.Codec, storeKey, objectKey storetypes.StoreKey, authority sdk.AccAddress, ak types.AccountKeeper, bankKeeper types.BankKeeper, sk types.StakingKeeper, fmk types.FeeMarketKeeper, ss paramstypes.Subspace, customContractFns []CustomContractFn, ) *Keeper
NewKeeper generates new evm module keeper
func (Keeper) Account ¶
func (k Keeper) Account(c context.Context, req *types.QueryAccountRequest) (*types.QueryAccountResponse, error)
Account implements the Query/Account gRPC method
func (*Keeper) AddBalance ¶
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, msg *core.Message, tracer *tracers.Tracer, commit bool) (*types.MsgEthereumTxResponse, error)
ApplyMessage calls ApplyMessageWithConfig with an empty TxConfig.
func (*Keeper) ApplyMessageWithConfig ¶
func (k *Keeper) ApplyMessageWithConfig( ctx sdk.Context, msg *core.Message, cfg *EVMConfig, commit bool, ) (resp *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.
This is expected used in debug_trace* where AnteHandler is not executed
Commit parameter ¶
If commit is true, the `StateDB` will be committed, otherwise discarded.
debugTrace parameter ¶
The message is applied with steps to mimic AnteHandler
- the sender is consumed with gasLimit * gasPrice in full at the beginning of the execution and then refund with unused gas after execution.
- sender nonce is incremented by 1 before execution
func (*Keeper) ApplyTransaction ¶
func (k *Keeper) ApplyTransaction(ctx sdk.Context, msgEth *types.MsgEthereumTx) (*types.MsgEthereumTxResponse, 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 in order 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, error)
Balance implements the Query/Balance gRPC method
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 sets the sdk Context and EIP155 chain id to the Keeper.
func (Keeper) Code ¶
func (k Keeper) Code(c context.Context, req *types.QueryCodeRequest) (*types.QueryCodeResponse, error)
Code implements the Query/Code gRPC method
func (Keeper) CollectTxBloom ¶
func (Keeper) CosmosAccount ¶
func (k Keeper) CosmosAccount(c context.Context, req *types.QueryCosmosAccountRequest) (*types.QueryCosmosAccountResponse, error)
func (*Keeper) DeductTxCostsFromUserBalance ¶
func (k *Keeper) DeductTxCostsFromUserBalance( ctx sdk.Context, fees sdk.Coins, from common.Address, ) error
DeductTxCostsFromUserBalance deducts the fees from the user balance. Returns an error if the specified sender address does not exist or the account balance is not sufficient.
func (*Keeper) DeleteAccount ¶
DeleteAccount handles contract's suicide call: - remove code - remove states - remove auth account
NOTE: balance should be cleared separately
func (*Keeper) EVMBlockConfig ¶
EVMBlockConfig creates the EVMBlockConfig based on current state
func (*Keeper) EVMConfig ¶
func (k *Keeper) EVMConfig(ctx sdk.Context, chainID *big.Int, txHash common.Hash) (*EVMConfig, error)
EVMConfig creates the EVMConfig based on current state
func (Keeper) EmitBlockBloomEvent ¶
EmitBlockBloomEvent emit block bloom events
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, error)
EstimateGas implements eth_estimateGas rpc api.
func (Keeper) EthCall ¶
func (k Keeper) EthCall(c context.Context, req *types.EthCallRequest) (*types.MsgEthereumTxResponse, error)
EthCall implements eth_call rpc api.
func (*Keeper) EthereumTx ¶
func (k *Keeper) EthereumTx(goCtx context.Context, msg *types.MsgEthereumTx) (*types.MsgEthereumTxResponse, 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 load nonce and codehash without balance, more efficient in cases where balance is not needed.
func (*Keeper) GetAccountOrEmpty ¶
GetAccountOrEmpty returns empty account if not exist, returns error if it's not `EthAccount`
func (Keeper) GetAccountStorage ¶
GetAccountStorage return state storage associated with an account
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 specified denom
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) GetCoinbaseAddress ¶
GetCoinbaseAddress returns the block proposer's validator operator address.
func (*Keeper) GetEVMDenomBalance ¶
GetEVMDenomBalance returns the balance of evm denom
func (*Keeper) GetEthIntrinsicGas ¶
func (k *Keeper) GetEthIntrinsicGas(msg *core.Message, rules params.Rules, isContractCreation bool) (uint64, error)
GetEthIntrinsicGas returns the intrinsic gas cost for the transaction
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) GetLegacyParams ¶
GetLegacyParams returns param set for version before migrate
func (*Keeper) GetNonce ¶
GetNonce returns the sequence number of an account, returns 0 if not exists.
func (*Keeper) GetState ¶
GetState loads contract state from database, implements `statedb.Keeper` interface.
func (Keeper) GetTransientGasUsed ¶
GetTransientGasUsed returns the gas used by current cosmos tx.
func (*Keeper) InitChainer ¶
func (*Keeper) NewEVM ¶
func (k *Keeper) NewEVM( ctx sdk.Context, msg *core.Message, cfg *EVMConfig, 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/Helios-Chain-Labs/ethermint/pull/1520#pullrequestreview-1200504697 for more information.
func (Keeper) Params ¶
func (k Keeper) Params(c context.Context, _ *types.QueryParamsRequest) (*types.QueryParamsResponse, error)
Params implements the Query/Params gRPC method
func (*Keeper) PostTxProcessing ¶
func (k *Keeper) PostTxProcessing(ctx sdk.Context, msg *core.Message, receipt *ethtypes.Receipt) error
PostTxProcessing delegate 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) error
RefundGas transfers the leftover gas to the sender of the message, caped 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) RemoveParamsCache ¶
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 ¶
SetAccount updates nonce/balance/codeHash together.
func (*Keeper) SetBalance ¶
func (k *Keeper) SetBalance(ctx sdk.Context, addr common.Address, amount *big.Int, evmDenom string) error
SetBalance reset the account's balance, mainly used by unit tests
func (*Keeper) SetHooks ¶
SetHooks sets the hooks for the EVM module It should be called only once during initialization, it panic if called more than once.
func (Keeper) SetParams ¶
SetParams sets the EVM params each in their individual key for better get performance
func (*Keeper) SetTracer ¶
func (k *Keeper) SetTracer(tracer *cosmostracing.Hooks)
SetTracer should only be called during initialization
func (Keeper) SetTransientGasUsed ¶
SetTransientGasUsed sets the gas used by current cosmos tx.
func (Keeper) Storage ¶
func (k Keeper) Storage(c context.Context, req *types.QueryStorageRequest) (*types.QueryStorageResponse, error)
Storage implements the Query/Storage gRPC method
func (*Keeper) SubBalance ¶
func (Keeper) TraceBlock ¶
func (k Keeper) TraceBlock(c context.Context, req *types.QueryTraceBlockRequest) (*types.QueryTraceBlockResponse, 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 ¶
func (k Keeper) TraceCall(c context.Context, req *types.QueryTraceCallRequest) (*types.QueryTraceCallResponse, 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, 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) UpdateParams ¶
func (k *Keeper) UpdateParams(goCtx context.Context, req *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, 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 ¶
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, error)
ValidatorAccount implements the Query/Balance gRPC method
func (*Keeper) WithChainID ¶
WithChainID sets the chain id to the local variable in the keeper
type Migrator ¶
type Migrator struct {
// contains filtered or unexported fields
}
Migrator is a struct for handling in-place store migrations.
func NewMigrator ¶
NewMigrator returns a new Migrator.
func (Migrator) Migrate3to4 ¶
Migrate3to4 migrates the store from consensus version 3 to 4
func (Migrator) Migrate4to5 ¶
Migrate4to5 migrates the store from consensus version 4 to 5
type MultiEvmHooks ¶
MultiEvmHooks combine multiple evm hooks, all hook functions are run in array sequence
func NewMultiEvmHooks ¶
func NewMultiEvmHooks(hooks ...types.EvmHooks) MultiEvmHooks
NewMultiEvmHooks combine multiple evm hooks
func (MultiEvmHooks) PostTxProcessing ¶
func (mh MultiEvmHooks) PostTxProcessing(ctx sdk.Context, msg *core.Message, receipt *ethtypes.Receipt) error
PostTxProcessing delegate the call to underlying hooks