Documentation
¶
Index ¶
- Constants
- func GetHexProofs(proof *crypto.ProofOps) []string
- func GetLogsFromBlockResults(blockRes *cmtrpctypes.ResultBlockResults) ([][]*ethtypes.Log, error)
- func ShouldIgnoreGasUsed(res *abci.ExecTxResult) bool
- type Backend
- func (b *Backend) Accounts() ([]common.Address, error)
- func (b *Backend) BaseFee(ctx context.Context, blockRes *cmtrpctypes.ResultBlockResults) (result *big.Int, err error)
- func (b *Backend) BlockBloomFromCometBlock(ctx context.Context, blockRes *cmtrpctypes.ResultBlockResults) (result ethtypes.Bloom, err error)
- func (b *Backend) BlockNumber(ctx context.Context) (result hexutil.Uint64, err error)
- func (b *Backend) BlockNumberFromComet(ctx context.Context, blockNrOrHash rpctypes.BlockNumberOrHash) (result rpctypes.BlockNumber, err error)
- func (b *Backend) BlockNumberFromCometByHash(ctx context.Context, blockHash common.Hash) (result *big.Int, err error)
- func (b *Backend) BloomStatus() (uint64, uint64)
- func (b *Backend) ChainConfig() *params.ChainConfig
- func (b *Backend) ChainID(ctx context.Context) (result *hexutil.Big, err error)
- func (b *Backend) CometBlockByHash(ctx context.Context, blockHash common.Hash) (result *cmtrpctypes.ResultBlock, err error)
- func (b *Backend) CometBlockByNumber(ctx context.Context, blockNum rpctypes.BlockNumber) (result *cmtrpctypes.ResultBlock, err error)
- func (b *Backend) CometBlockResultByNumber(ctx context.Context, height *int64) (result *cmtrpctypes.ResultBlockResults, err error)
- func (b *Backend) CometHeaderByNumber(ctx context.Context, blockNum rpctypes.BlockNumber) (result *cmtrpctypes.ResultHeader, err error)
- func (b *Backend) Content(ctx context.Context) (result map[string]map[string]map[string]*types.RPCTransaction, err error)
- func (b *Backend) ContentFrom(ctx context.Context, addr common.Address) (result map[string]map[string]*types.RPCTransaction, err error)
- func (b *Backend) CreateAccessList(ctx context.Context, args evmtypes.TransactionArgs, ...) (result *rpctypes.AccessListResult, err error)
- func (b *Backend) CurrentHeader(ctx context.Context) (result *ethtypes.Header, err error)
- func (b *Backend) DoCall(ctx context.Context, args evmtypes.TransactionArgs, ...) (result *evmtypes.MsgEthereumTxResponse, err error)
- func (b *Backend) EstimateGas(ctx context.Context, args evmtypes.TransactionArgs, ...) (result hexutil.Uint64, err error)
- func (b *Backend) EthBlockByNumber(ctx context.Context, blockNum types.BlockNumber) (result *ethtypes.Block, err error)
- func (b *Backend) EthBlockFromCometBlock(ctx context.Context, resBlock *cmtrpctypes.ResultBlock, ...) (result *ethtypes.Block, err error)
- func (b *Backend) EthMsgsFromCometBlock(ctx context.Context, resBlock *cmtrpctypes.ResultBlock, ...) []*evmtypes.MsgEthereumTx
- func (b *Backend) FeeHistory(ctx context.Context, userBlockCount math.HexOrDecimal64, ...) (_ *rpctypes.FeeHistoryResult, err error)
- func (b *Backend) FindEthTxIndexByHash(ctx context.Context, txHash common.Hash, block *cmtrpctypes.ResultBlock, ...) (int32, error)
- func (b *Backend) GasPrice(ctx context.Context) (result *hexutil.Big, err error)
- func (b *Backend) GenerateMinGasCoin(gasPrice hexutil.Big, appConf config.Config) sdk.DecCoin
- func (b *Backend) GetBalance(ctx context.Context, address common.Address, ...) (result *hexutil.Big, err error)
- func (b *Backend) GetBlockByHash(ctx context.Context, hash common.Hash, fullTx bool) (result map[string]interface{}, err error)
- func (b *Backend) GetBlockByNumber(ctx context.Context, blockNum types.BlockNumber, fullTx bool) (result map[string]interface{}, err error)
- func (b *Backend) GetBlockReceipts(ctx context.Context, blockNrOrHash types.BlockNumberOrHash) (result []map[string]interface{}, err error)
- func (b *Backend) GetBlockTransactionCountByHash(ctx context.Context, hash common.Hash) *hexutil.Uint
- func (b *Backend) GetBlockTransactionCountByNumber(ctx context.Context, blockNum types.BlockNumber) *hexutil.Uint
- func (b *Backend) GetCode(ctx context.Context, address common.Address, ...) (bz hexutil.Bytes, err error)
- func (b *Backend) GetCoinbase(ctx context.Context) (result sdk.AccAddress, err error)
- func (b *Backend) GetConfig() config.Config
- func (b *Backend) GetGasUsed(res *servertypes.TxResult, _ *big.Int, _ uint64) uint64
- func (b *Backend) GetHeaderByHash(ctx context.Context, hash common.Hash) (result map[string]interface{}, err error)
- func (b *Backend) GetHeaderByNumber(ctx context.Context, blockNum rpctypes.BlockNumber) (result map[string]interface{}, err error)
- func (b *Backend) GetLogs(ctx context.Context, hash common.Hash) (result [][]*ethtypes.Log, err error)
- func (b *Backend) GetLogsByHeight(ctx context.Context, height *int64) (result [][]*ethtypes.Log, err error)
- func (b *Backend) GetProof(ctx context.Context, address common.Address, storageKeys []string, ...) (result *rpctypes.AccountResult, err error)
- func (b *Backend) GetStorageAt(ctx context.Context, address common.Address, key string, ...) (result hexutil.Bytes, err error)
- func (b *Backend) GetTransactionByBlockAndIndex(ctx context.Context, block *cmtrpctypes.ResultBlock, idx hexutil.Uint) (result *rpctypes.RPCTransaction, err error)
- func (b *Backend) GetTransactionByBlockHashAndIndex(ctx context.Context, hash common.Hash, idx hexutil.Uint) (result *rpctypes.RPCTransaction, err error)
- func (b *Backend) GetTransactionByBlockNumberAndIndex(ctx context.Context, blockNum rpctypes.BlockNumber, idx hexutil.Uint) (result *rpctypes.RPCTransaction, err error)
- func (b *Backend) GetTransactionByHash(ctx context.Context, txHash common.Hash) (result *rpctypes.RPCTransaction, err error)
- func (b *Backend) GetTransactionByHashPending(ctx context.Context, txHash common.Hash) (result *rpctypes.RPCTransaction, err error)
- func (b *Backend) GetTransactionCount(ctx context.Context, address common.Address, blockNum rpctypes.BlockNumber) (result *hexutil.Uint64, err error)
- func (b *Backend) GetTransactionLogs(ctx context.Context, hash common.Hash) (result []*ethtypes.Log, err error)
- func (b *Backend) GetTransactionReceipt(ctx context.Context, hash common.Hash) (result map[string]interface{}, err error)
- func (b *Backend) GetTxByEthHash(ctx context.Context, hash common.Hash) (result *servertypes.TxResult, err error)
- func (b *Backend) GetTxByTxIndex(ctx context.Context, height int64, index uint) (result *servertypes.TxResult, err error)
- func (b *Backend) GlobalMinGasPrice(ctx context.Context) (result *big.Int, err error)
- func (b *Backend) HeaderByHash(ctx context.Context, blockHash common.Hash) (result *ethtypes.Header, err error)
- func (b *Backend) HeaderByNumber(ctx context.Context, blockNum rpctypes.BlockNumber) (result *ethtypes.Header, err error)
- func (b *Backend) ImportRawKey(privkey, password string) (common.Address, error)
- func (b *Backend) Inspect(_ context.Context) (map[string]map[string]map[string]string, error)
- func (b *Backend) ListAccounts() ([]common.Address, error)
- func (b *Backend) MinerFromCometBlock(ctx context.Context, resBlock *cmtrpctypes.ResultBlock) (result common.Address, err error)
- func (b *Backend) NewMnemonic(uid string, _ keyring.Language, hdPath, bip39Passphrase string, ...) (*keyring.Record, error)
- func (b *Backend) PendingTransactions(ctx context.Context) (result []*sdk.Tx, err error)
- func (b *Backend) ProcessBlock(ctx context.Context, cometBlock *cmtrpctypes.ResultBlock, ...) (err error)
- func (b *Backend) QueryCometTxIndexer(ctx context.Context, query string, ...) (result *servertypes.TxResult, err error)
- func (b *Backend) RPCBlockFromCometBlock(ctx context.Context, resBlock *cmtrpctypes.ResultBlock, ...) (result map[string]interface{}, err error)
- func (b *Backend) RPCBlockRangeCap() int32
- func (b *Backend) RPCEVMTimeout() time.Duration
- func (b *Backend) RPCFeeHistoryCap() int32
- func (b *Backend) RPCGasCap() uint64
- func (b *Backend) RPCHeaderFromCometBlock(ctx context.Context, resBlock *cmtrpctypes.ResultBlock, ...) (result map[string]interface{}, err error)
- func (b *Backend) RPCLogsCap() int32
- func (b *Backend) RPCMinGasPrice() *big.Int
- func (b *Backend) RPCTxFeeCap() float64
- func (b *Backend) ReceiptsFromCometBlock(ctx context.Context, resBlock *cmtrpctypes.ResultBlock, ...) (result []*ethtypes.Receipt, err error)
- func (b *Backend) Resend(ctx context.Context, args evmtypes.TransactionArgs, gasPrice *hexutil.Big, ...) (result common.Hash, err error)
- func (b *Backend) SendRawTransaction(ctx context.Context, data hexutil.Bytes) (result common.Hash, err error)
- func (b *Backend) SendTransaction(ctx context.Context, args evmtypes.TransactionArgs) (result common.Hash, err error)
- func (b *Backend) SetEtherbase(ctx context.Context, etherbase common.Address) bool
- func (b *Backend) SetGasPrice(ctx context.Context, gasPrice hexutil.Big) bool
- func (b *Backend) SetTxDefaults(ctx context.Context, args evmtypes.TransactionArgs) (result evmtypes.TransactionArgs, err error)
- func (b *Backend) Sign(address common.Address, data hexutil.Bytes) (hexutil.Bytes, error)
- func (b *Backend) SignTypedData(address common.Address, typedData apitypes.TypedData) (hexutil.Bytes, error)
- func (b *Backend) Status(_ context.Context) (map[string]hexutil.Uint, error)
- func (b *Backend) SuggestGasTipCap(ctx context.Context, baseFee *big.Int) (_ *big.Int, err error)
- func (b *Backend) Syncing(ctx context.Context) (result interface{}, err error)
- func (b *Backend) TraceBlock(ctx context.Context, height rpctypes.BlockNumber, config *rpctypes.TraceConfig, ...) (result []*evmtypes.TxTraceResult, err error)
- func (b *Backend) TraceCall(ctx context.Context, args evmtypes.TransactionArgs, ...) (result interface{}, err error)
- func (b *Backend) TraceTransaction(ctx context.Context, hash common.Hash, config *rpctypes.TraceConfig) (result interface{}, err error)
- func (b *Backend) TrackTxIfSupported(txHash common.Hash)
- func (b Backend) UnprotectedAllowed() bool
- type BackendI
- type EVMBackend
- type Mempool
- type Opt
- type ProcessBlocker
- type TrackingMempool
Constants ¶
const ( StatusPending = "pending" StatusQueued = "queued" )
Variables ¶
This section is empty.
Functions ¶
func GetHexProofs ¶
GetHexProofs returns list of hex data of proof op
func GetLogsFromBlockResults ¶
func GetLogsFromBlockResults(blockRes *cmtrpctypes.ResultBlockResults) ([][]*ethtypes.Log, error)
GetLogsFromBlockResults returns the list of event logs from the CometBFT block result response
func ShouldIgnoreGasUsed ¶
func ShouldIgnoreGasUsed(res *abci.ExecTxResult) bool
ShouldIgnoreGasUsed returns true if the gasUsed in result should be ignored workaround for issue: https://github.com/cosmos/cosmos-sdk/issues/10832
Types ¶
type Backend ¶
type Backend struct {
ClientCtx client.Context
RPCClient tmrpcclient.SignClient
QueryClient *types.QueryClient // gRPC query client
Logger log.Logger
EvmChainID *big.Int
Cfg config.Config
AllowUnprotectedTxs bool
Indexer servertypes.EVMTxIndexer
ProcessBlocker ProcessBlocker
Mempool Mempool
}
Backend implements the BackendI interface
func NewBackend ¶
func NewBackend( ctx *server.Context, clientCtx client.Context, indexer servertypes.EVMTxIndexer, mempool Mempool, opts ...Opt, ) *Backend
NewBackend creates a new Backend instance for cosmos and ethereum namespaces
func (*Backend) BaseFee ¶
func (b *Backend) BaseFee(ctx context.Context, blockRes *cmtrpctypes.ResultBlockResults) (result *big.Int, err error)
BaseFee returns the base fee tracked by the Fee Market module. If the base fee is not enabled globally, the query returns nil. If the London hard fork is not activated at the current height, the query will return nil.
func (*Backend) BlockBloomFromCometBlock ¶ added in v0.5.0
func (b *Backend) BlockBloomFromCometBlock(ctx context.Context, blockRes *cmtrpctypes.ResultBlockResults) (result ethtypes.Bloom, err error)
BlockBloom query block bloom filter from block results
func (*Backend) BlockNumber ¶
BlockNumber returns the current block number in abci app state. Because abci app state could lag behind from cometbft latest block, it's more stable for the client to use the latest block number in abci app state than cometbft rpc.
func (*Backend) BlockNumberFromComet ¶ added in v0.4.0
func (b *Backend) BlockNumberFromComet(ctx context.Context, blockNrOrHash rpctypes.BlockNumberOrHash) (result rpctypes.BlockNumber, err error)
BlockNumberFromComet returns the BlockNumber from BlockNumberOrHash
func (*Backend) BlockNumberFromCometByHash ¶ added in v0.4.0
func (b *Backend) BlockNumberFromCometByHash(ctx context.Context, blockHash common.Hash) (result *big.Int, err error)
BlockNumberFromCometByHash returns the block height of given block hash
func (*Backend) BloomStatus ¶
BloomStatus returns the BloomBitsBlocks and the number of processed sections maintained by the chain indexer.
func (*Backend) ChainConfig ¶
func (b *Backend) ChainConfig() *params.ChainConfig
ChainConfig returns the latest ethereum chain configuration
func (*Backend) ChainID ¶
ChainID is the EIP-155 replay-protection chain id for the current ethereum chain config.
func (*Backend) CometBlockByHash ¶ added in v0.4.0
func (b *Backend) CometBlockByHash(ctx context.Context, blockHash common.Hash) (result *cmtrpctypes.ResultBlock, err error)
CometBlockByHash returns a CometBFT-formatted block by block number
func (*Backend) CometBlockByNumber ¶ added in v0.4.0
func (b *Backend) CometBlockByNumber(ctx context.Context, blockNum rpctypes.BlockNumber) (result *cmtrpctypes.ResultBlock, err error)
CometBlockByNumber returns a CometBFT-formatted block for a given block number
func (*Backend) CometBlockResultByNumber ¶ added in v0.4.0
func (b *Backend) CometBlockResultByNumber(ctx context.Context, height *int64) (result *cmtrpctypes.ResultBlockResults, err error)
CometBlockResultByNumber returns a CometBFT-formatted block result by block number
func (*Backend) CometHeaderByNumber ¶ added in v0.4.0
func (b *Backend) CometHeaderByNumber(ctx context.Context, blockNum rpctypes.BlockNumber) (result *cmtrpctypes.ResultHeader, err error)
CometHeaderByNumber returns a CometBFT-formatted header for a given block number
func (*Backend) Content ¶ added in v0.4.0
func (b *Backend) Content(ctx context.Context) (result map[string]map[string]map[string]*types.RPCTransaction, err error)
Content returns the transactions contained within the transaction pool.
func (*Backend) ContentFrom ¶ added in v0.4.0
func (b *Backend) ContentFrom(ctx context.Context, addr common.Address) (result map[string]map[string]*types.RPCTransaction, err error)
ContentFrom returns the transactions contained within the transaction pool
func (*Backend) CreateAccessList ¶ added in v0.5.0
func (b *Backend) CreateAccessList( ctx context.Context, args evmtypes.TransactionArgs, blockNrOrHash rpctypes.BlockNumberOrHash, overrides *json.RawMessage, ) (result *rpctypes.AccessListResult, err error)
CreateAccessList returns the list of addresses and storage keys used by the transaction (except for the sender account and precompiles), plus the estimated gas if the access list were added to the transaction.
func (*Backend) CurrentHeader ¶
CurrentHeader returns the latest block header This will return error as per node configuration if the ABCI responses are discarded ('discard_abci_responses' config param)
func (*Backend) DoCall ¶
func (b *Backend) DoCall( ctx context.Context, args evmtypes.TransactionArgs, blockNr rpctypes.BlockNumber, overrides *json.RawMessage, ) (result *evmtypes.MsgEthereumTxResponse, err error)
DoCall performs a simulated call operation through the evmtypes. It returns the estimated gas used on the operation or an error if fails.
func (*Backend) EstimateGas ¶
func (b *Backend) EstimateGas( ctx context.Context, args evmtypes.TransactionArgs, blockNrOrHash *rpctypes.BlockNumberOrHash, overrides *json.RawMessage, ) (result hexutil.Uint64, err error)
EstimateGas returns an estimate of gas usage for the given smart contract call.
func (*Backend) EthBlockByNumber ¶
func (b *Backend) EthBlockByNumber(ctx context.Context, blockNum types.BlockNumber) (result *ethtypes.Block, err error)
EthBlockByNumber returns the Ethereum Block identified by number.
func (*Backend) EthBlockFromCometBlock ¶ added in v0.4.0
func (b *Backend) EthBlockFromCometBlock( ctx context.Context, resBlock *cmtrpctypes.ResultBlock, blockRes *cmtrpctypes.ResultBlockResults, ) (result *ethtypes.Block, err error)
RPCBlockFromCometBlock returns a JSON-RPC compatible Ethereum block from a given CometBFT block and its block result.
func (*Backend) EthMsgsFromCometBlock ¶ added in v0.4.0
func (b *Backend) EthMsgsFromCometBlock( ctx context.Context, resBlock *cmtrpctypes.ResultBlock, blockRes *cmtrpctypes.ResultBlockResults, ) []*evmtypes.MsgEthereumTx
EthMsgsFromCometBlock returns all real MsgEthereumTxs from a CometBFT block. It also ensures consistency over the correct txs indexes across RPC endpoints
func (*Backend) FeeHistory ¶
func (b *Backend) FeeHistory( ctx context.Context, userBlockCount math.HexOrDecimal64, lastBlock rpc.BlockNumber, rewardPercentiles []float64, ) (_ *rpctypes.FeeHistoryResult, err error)
FeeHistory returns data relevant for fee estimation based on the specified range of blocks.
func (*Backend) FindEthTxIndexByHash ¶ added in v0.7.0
func (b *Backend) FindEthTxIndexByHash(ctx context.Context, txHash common.Hash, block *cmtrpctypes.ResultBlock, blockRes *cmtrpctypes.ResultBlockResults) (int32, error)
FindEthTxIndexByHash is a fallback that locates an eth tx's index by iterating every valid eth tx in the block. Used for legacy blocks whose ethereum_tx events lack AttributeKeyTxIndex.
func (*Backend) GasPrice ¶
GasPrice returns the current gas price based on Cosmos EVM' gas price oracle.
func (*Backend) GenerateMinGasCoin ¶
func (*Backend) GetBalance ¶
func (b *Backend) GetBalance(ctx context.Context, address common.Address, blockNrOrHash rpctypes.BlockNumberOrHash) (result *hexutil.Big, err error)
GetBalance returns the provided account's *spendable* balance up to the provided block number.
func (*Backend) GetBlockByHash ¶
func (b *Backend) GetBlockByHash(ctx context.Context, hash common.Hash, fullTx bool) (result map[string]interface{}, err error)
GetBlockByHash returns the JSON-RPC compatible Ethereum block identified by hash.
func (*Backend) GetBlockByNumber ¶
func (b *Backend) GetBlockByNumber(ctx context.Context, blockNum types.BlockNumber, fullTx bool) (result map[string]interface{}, err error)
GetBlockByNumber returns the JSON-RPC compatible Ethereum block identified by block number. Depending on fullTx it either returns the full transaction objects or if false only the hashes of the transactions.
func (*Backend) GetBlockReceipts ¶ added in v0.3.0
func (b *Backend) GetBlockReceipts( ctx context.Context, blockNrOrHash types.BlockNumberOrHash, ) (result []map[string]interface{}, err error)
GetBlockReceipts returns the receipts for a given block number or hash.
func (*Backend) GetBlockTransactionCountByHash ¶
func (b *Backend) GetBlockTransactionCountByHash(ctx context.Context, hash common.Hash) *hexutil.Uint
GetBlockTransactionCountByHash returns the number of Ethereum transactions in the block identified by hash.
func (*Backend) GetBlockTransactionCountByNumber ¶
func (b *Backend) GetBlockTransactionCountByNumber(ctx context.Context, blockNum types.BlockNumber) *hexutil.Uint
GetBlockTransactionCountByNumber returns the number of Ethereum transactions in the block identified by number.
func (*Backend) GetCode ¶
func (b *Backend) GetCode(ctx context.Context, address common.Address, blockNrOrHash rpctypes.BlockNumberOrHash) (bz hexutil.Bytes, err error)
GetCode returns the contract code at the given address and block number.
func (*Backend) GetCoinbase ¶
GetCoinbase is the address that staking rewards will be send to (alias for Etherbase).
func (*Backend) GetGasUsed ¶
GetGasUsed returns gasUsed from transaction
func (*Backend) GetHeaderByHash ¶ added in v0.5.0
func (b *Backend) GetHeaderByHash(ctx context.Context, hash common.Hash) (result map[string]interface{}, err error)
GetBlockByHash returns the JSON-RPC compatible Ethereum block identified by hash.
func (*Backend) GetHeaderByNumber ¶ added in v0.5.0
func (b *Backend) GetHeaderByNumber(ctx context.Context, blockNum rpctypes.BlockNumber) (result map[string]interface{}, err error)
GetBlockByNumber returns the JSON-RPC compatible Ethereum block identified by block number. Depending on fullTx it either returns the full transaction objects or if false only the hashes of the transactions.
func (*Backend) GetLogs ¶
func (b *Backend) GetLogs(ctx context.Context, hash common.Hash) (result [][]*ethtypes.Log, err error)
GetLogs returns all the logs from all the ethereum transactions in a block.
func (*Backend) GetLogsByHeight ¶
func (b *Backend) GetLogsByHeight(ctx context.Context, height *int64) (result [][]*ethtypes.Log, err error)
GetLogsByHeight returns all the logs from all the ethereum transactions in a block.
func (*Backend) GetProof ¶
func (b *Backend) GetProof(ctx context.Context, address common.Address, storageKeys []string, blockNrOrHash rpctypes.BlockNumberOrHash) (result *rpctypes.AccountResult, err error)
GetProof returns an account object with proof and any storage proofs
func (*Backend) GetStorageAt ¶
func (b *Backend) GetStorageAt(ctx context.Context, address common.Address, key string, blockNrOrHash rpctypes.BlockNumberOrHash) (result hexutil.Bytes, err error)
GetStorageAt returns the contract storage at the given address, block number, and key.
func (*Backend) GetTransactionByBlockAndIndex ¶
func (b *Backend) GetTransactionByBlockAndIndex(ctx context.Context, block *cmtrpctypes.ResultBlock, idx hexutil.Uint) (result *rpctypes.RPCTransaction, err error)
GetTransactionByBlockAndIndex is the common code shared by `GetTransactionByBlockNumberAndIndex` and `GetTransactionByBlockHashAndIndex`.
func (*Backend) GetTransactionByBlockHashAndIndex ¶
func (b *Backend) GetTransactionByBlockHashAndIndex(ctx context.Context, hash common.Hash, idx hexutil.Uint) (result *rpctypes.RPCTransaction, err error)
GetTransactionByBlockHashAndIndex returns the transaction identified by hash and index.
func (*Backend) GetTransactionByBlockNumberAndIndex ¶
func (b *Backend) GetTransactionByBlockNumberAndIndex(ctx context.Context, blockNum rpctypes.BlockNumber, idx hexutil.Uint) (result *rpctypes.RPCTransaction, err error)
GetTransactionByBlockNumberAndIndex returns the transaction identified by number and index.
func (*Backend) GetTransactionByHash ¶
func (b *Backend) GetTransactionByHash(ctx context.Context, txHash common.Hash) (result *rpctypes.RPCTransaction, err error)
GetTransactionByHash returns the Ethereum format transaction identified by Ethereum transaction hash
func (*Backend) GetTransactionByHashPending ¶ added in v0.4.0
func (b *Backend) GetTransactionByHashPending(ctx context.Context, txHash common.Hash) (result *rpctypes.RPCTransaction, err error)
GetTransactionByHashPending find pending tx from mempool
func (*Backend) GetTransactionCount ¶
func (b *Backend) GetTransactionCount(ctx context.Context, address common.Address, blockNum rpctypes.BlockNumber) (result *hexutil.Uint64, err error)
GetTransactionCount returns the number of transactions at the given address up to the given block number.
func (*Backend) GetTransactionLogs ¶
func (b *Backend) GetTransactionLogs(ctx context.Context, hash common.Hash) (result []*ethtypes.Log, err error)
GetTransactionLogs returns the transaction logs identified by hash.
func (*Backend) GetTransactionReceipt ¶
func (b *Backend) GetTransactionReceipt(ctx context.Context, hash common.Hash) (result map[string]interface{}, err error)
GetTransactionReceipt returns the transaction receipt identified by hash.
func (*Backend) GetTxByEthHash ¶
func (b *Backend) GetTxByEthHash(ctx context.Context, hash common.Hash) (result *servertypes.TxResult, err error)
GetTxByEthHash uses `/tx_query` to find transaction by ethereum tx hash TODO: Don't need to convert once hashing is fixed on CometBFT https://github.com/cometbft/cometbft/issues/6539
func (*Backend) GetTxByTxIndex ¶
func (b *Backend) GetTxByTxIndex(ctx context.Context, height int64, index uint) (result *servertypes.TxResult, err error)
GetTxByTxIndex uses `/tx_query` to find transaction by tx index of valid ethereum txs
func (*Backend) GlobalMinGasPrice ¶
GlobalMinGasPrice returns MinGasPrice param from FeeMarket
func (*Backend) HeaderByHash ¶
func (b *Backend) HeaderByHash(ctx context.Context, blockHash common.Hash) (result *ethtypes.Header, err error)
HeaderByHash returns the block header identified by hash.
func (*Backend) HeaderByNumber ¶
func (b *Backend) HeaderByNumber(ctx context.Context, blockNum rpctypes.BlockNumber) (result *ethtypes.Header, err error)
HeaderByNumber returns the block header identified by height.
func (*Backend) ImportRawKey ¶
ImportRawKey armors and encrypts a given raw hex encoded ECDSA key and stores it into the key directory. The name of the key will have the format "personal_<length-keys>", where <length-keys> is the total number of keys stored on the keyring.
NOTE: The key will be both armored and encrypted using the same passphrase.
func (*Backend) Inspect ¶ added in v0.4.0
Inspect returns the content of the transaction pool and flattens it into an easily inspectable list.
func (*Backend) ListAccounts ¶
ListAccounts will return a list of addresses for accounts this node manages.
func (*Backend) MinerFromCometBlock ¶ added in v0.5.0
func (b *Backend) MinerFromCometBlock( ctx context.Context, resBlock *cmtrpctypes.ResultBlock, ) (result common.Address, err error)
func (*Backend) NewMnemonic ¶
func (b *Backend) NewMnemonic(uid string, _ keyring.Language, hdPath, bip39Passphrase string, algo keyring.SignatureAlgo, ) (*keyring.Record, error)
NewAccount will create a new account and returns the address for the new account.
func (*Backend) PendingTransactions ¶
PendingTransactions returns the transactions that are in the transaction pool and have a from address that is one of the accounts this node manages.
func (*Backend) ProcessBlock ¶ added in v0.4.0
func (b *Backend) ProcessBlock( ctx context.Context, cometBlock *cmtrpctypes.ResultBlock, ethBlock *map[string]interface{}, rewardPercentiles []float64, cometBlockResult *cmtrpctypes.ResultBlockResults, targetOneFeeHistory *types.OneFeeHistory, ) (err error)
ProcessBlock processes a CometBFT block and calculates fee history data for eth_feeHistory RPC. It extracts gas usage, base fees, and transaction reward percentiles from the block data.
The function calculates:
- Current block's base fee and next block's base fee (for EIP-1559)
- Gas used ratio (gasUsed / gasLimit)
- Transaction reward percentiles based on effective gas tip values
Parameters:
- ctx: Context for the request
- cometBlock: The raw CometBFT block containing transaction data
- ethBlock: Ethereum-formatted block with gas limit and usage information
- rewardPercentiles: Percentile values (0-100) for reward calculation
- cometBlockResult: Block execution results containing gas usage per transaction
- targetOneFeeHistory: Output parameter to populate with calculated fee history data
Returns an error if block processing fails due to invalid data types or calculation errors.
func (*Backend) QueryCometTxIndexer ¶ added in v0.4.0
func (b *Backend) QueryCometTxIndexer(ctx context.Context, query string, txGetter func(*rpctypes.ParsedTxs) *rpctypes.ParsedTx) (result *servertypes.TxResult, err error)
QueryCometTxIndexer query tx in CometBFT tx indexer
func (*Backend) RPCBlockFromCometBlock ¶ added in v0.4.0
func (b *Backend) RPCBlockFromCometBlock( ctx context.Context, resBlock *cmtrpctypes.ResultBlock, blockRes *cmtrpctypes.ResultBlockResults, fullTx bool, ) (result map[string]interface{}, err error)
RPCBlockFromCometBlock returns a JSON-RPC compatible Ethereum block from a given CometBFT block and its block result.
func (*Backend) RPCBlockRangeCap ¶
RPCBlockRangeCap defines the max block range allowed for `eth_getLogs` query.
func (*Backend) RPCEVMTimeout ¶
RPCEVMTimeout is the global evm timeout for eth-call variants.
func (*Backend) RPCFeeHistoryCap ¶
RPCFeeHistoryCap is the limit for total number of blocks that can be fetched
func (*Backend) RPCHeaderFromCometBlock ¶ added in v0.5.0
func (b *Backend) RPCHeaderFromCometBlock( ctx context.Context, resBlock *cmtrpctypes.ResultBlock, blockRes *cmtrpctypes.ResultBlockResults, ) (result map[string]interface{}, err error)
RPCBlockFromCometBlock returns a JSON-RPC compatible Ethereum block from a given CometBFT block and its block result.
func (*Backend) RPCLogsCap ¶
RPCLogsCap defines the max number of results can be returned from single `eth_getLogs` query.
func (*Backend) RPCMinGasPrice ¶
RPCMinGasPrice returns the minimum gas price for a transaction obtained from the node config. If set value is 0, it will default to 20.
func (*Backend) RPCTxFeeCap ¶
RPCGasCap is the global gas cap for eth-call variants.
func (*Backend) ReceiptsFromCometBlock ¶ added in v0.5.0
func (b *Backend) ReceiptsFromCometBlock( ctx context.Context, resBlock *cmtrpctypes.ResultBlock, blockRes *cmtrpctypes.ResultBlockResults, msgs []*evmtypes.MsgEthereumTx, ) (result []*ethtypes.Receipt, err error)
func (*Backend) Resend ¶
func (b *Backend) Resend(ctx context.Context, args evmtypes.TransactionArgs, gasPrice *hexutil.Big, gasLimit *hexutil.Uint64) (result common.Hash, err error)
Resend accepts an existing transaction and a new gas price and limit. It will remove the given transaction from the pool and reinsert it with the new gas price and limit.
func (*Backend) SendRawTransaction ¶
func (b *Backend) SendRawTransaction(ctx context.Context, data hexutil.Bytes) (result common.Hash, err error)
SendRawTransaction send a raw Ethereum transaction.
func (*Backend) SendTransaction ¶
func (b *Backend) SendTransaction(ctx context.Context, args evmtypes.TransactionArgs) (result common.Hash, err error)
SendTransaction sends transaction based on received args using Node's key to sign it
func (*Backend) SetEtherbase ¶
SetEtherbase sets the etherbase of the miner
func (*Backend) SetGasPrice ¶
SetGasPrice sets the minimum accepted gas price for the miner. NOTE: this function accepts only integers to have the same interface than go-eth to use float values, the gas prices must be configured using the configuration file
func (*Backend) SetTxDefaults ¶
func (b *Backend) SetTxDefaults(ctx context.Context, args evmtypes.TransactionArgs) (result evmtypes.TransactionArgs, err error)
SetTxDefaults populates tx message with default values in case they are not provided on the args
func (*Backend) Sign ¶
Sign signs the provided data using the private key of address via Geth's signature standard.
func (*Backend) SignTypedData ¶
func (b *Backend) SignTypedData(address common.Address, typedData apitypes.TypedData) (hexutil.Bytes, error)
SignTypedData signs EIP-712 conformant typed data
func (*Backend) Status ¶ added in v0.4.0
Status returns the number of pending and queued transaction in the pool.
func (*Backend) SuggestGasTipCap ¶
SuggestGasTipCap returns the suggested tip cap Although we don't support tx prioritization yet, but we return a positive value to help client to mitigate the base fee changes.
func (*Backend) Syncing ¶
Syncing returns false in case the node is currently not syncing with the network. It can be up to date or has not yet received the latest block headers from its pears. In case it is synchronizing: - startingBlock: block number this node started to synchronize from - currentBlock: block number this node is currently importing - highestBlock: block number of the highest block header this node has received from peers - pulledStates: number of state entries processed until now - knownStates: number of known state entries that still need to be pulled
func (*Backend) TraceBlock ¶
func (b *Backend) TraceBlock(ctx context.Context, height rpctypes.BlockNumber, config *rpctypes.TraceConfig, block *tmrpctypes.ResultBlock, ) (result []*evmtypes.TxTraceResult, err error)
TraceBlock configures a new tracer according to the provided configuration, and executes all the transactions contained within. The return value will be one item per transaction, dependent on the requested tracer.
func (*Backend) TraceCall ¶ added in v0.5.0
func (b *Backend) TraceCall( ctx context.Context, args evmtypes.TransactionArgs, blockNrOrHash rpctypes.BlockNumberOrHash, config *rpctypes.TraceConfig, ) (result interface{}, err error)
TraceCall executes a call with the given arguments and returns the structured logs created during the execution of EVM. It returns them as a JSON object.
func (*Backend) TraceTransaction ¶
func (b *Backend) TraceTransaction(ctx context.Context, hash common.Hash, config *rpctypes.TraceConfig) (result interface{}, err error)
TraceTransaction returns the structured logs created during the execution of EVM and returns them as a JSON object.
func (*Backend) TrackTxIfSupported ¶ added in v0.7.0
TrackTxIfSupported calls TrackTx on the backends mempool if it is a supported method.
func (Backend) UnprotectedAllowed ¶
UnprotectedAllowed returns the node configuration value for allowing unprotected transactions (i.e not replay-protected)
type BackendI ¶
type BackendI interface {
EVMBackend
GetConfig() config.Config
}
BackendI implements the Cosmos and EVM backend.
type EVMBackend ¶
type EVMBackend interface {
// Node specific queries
Accounts() ([]common.Address, error)
Syncing(ctx context.Context) (interface{}, error)
SetEtherbase(ctx context.Context, etherbase common.Address) bool
SetGasPrice(ctx context.Context, gasPrice hexutil.Big) bool
ImportRawKey(privkey, password string) (common.Address, error)
ListAccounts() ([]common.Address, error)
NewMnemonic(uid string, language keyring.Language, hdPath, bip39Passphrase string, algo keyring.SignatureAlgo) (*keyring.Record, error)
UnprotectedAllowed() bool
RPCGasCap() uint64 // global gas cap for eth_call over rpc: DoS protection
RPCEVMTimeout() time.Duration // global timeout for eth_call over rpc: DoS protection
RPCTxFeeCap() float64 // RPCTxFeeCap is the global transaction fee(price * gaslimit) cap for send-transaction variants. The unit is ether.
RPCMinGasPrice() *big.Int
// Sign Tx
Sign(address common.Address, data hexutil.Bytes) (hexutil.Bytes, error)
SendTransaction(ctx context.Context, args evmtypes.TransactionArgs) (common.Hash, error)
SignTypedData(address common.Address, typedData apitypes.TypedData) (hexutil.Bytes, error)
// Blocks Info
BlockNumber(ctx context.Context) (hexutil.Uint64, error)
GetHeaderByNumber(ctx context.Context, blockNum types.BlockNumber) (map[string]interface{}, error)
GetHeaderByHash(ctx context.Context, hash common.Hash) (map[string]interface{}, error)
GetBlockByNumber(ctx context.Context, blockNum types.BlockNumber, fullTx bool) (map[string]interface{}, error)
GetBlockByHash(ctx context.Context, hash common.Hash, fullTx bool) (map[string]interface{}, error)
GetBlockTransactionCountByHash(ctx context.Context, hash common.Hash) *hexutil.Uint
GetBlockTransactionCountByNumber(ctx context.Context, blockNum types.BlockNumber) *hexutil.Uint
CometBlockByNumber(ctx context.Context, blockNum types.BlockNumber) (*tmrpctypes.ResultBlock, error)
CometBlockByHash(ctx context.Context, blockHash common.Hash) (*tmrpctypes.ResultBlock, error)
BlockNumberFromComet(ctx context.Context, blockNrOrHash types.BlockNumberOrHash) (types.BlockNumber, error)
BlockNumberFromCometByHash(ctx context.Context, blockHash common.Hash) (*big.Int, error)
EthMsgsFromCometBlock(ctx context.Context, block *tmrpctypes.ResultBlock, blockRes *tmrpctypes.ResultBlockResults) []*evmtypes.MsgEthereumTx
BlockBloomFromCometBlock(ctx context.Context, blockRes *tmrpctypes.ResultBlockResults) (ethtypes.Bloom, error)
HeaderByNumber(ctx context.Context, blockNum types.BlockNumber) (*ethtypes.Header, error)
HeaderByHash(ctx context.Context, blockHash common.Hash) (*ethtypes.Header, error)
RPCBlockFromCometBlock(ctx context.Context, resBlock *tmrpctypes.ResultBlock, blockRes *tmrpctypes.ResultBlockResults, fullTx bool) (map[string]interface{}, error)
EthBlockByNumber(ctx context.Context, blockNum types.BlockNumber) (*ethtypes.Block, error)
EthBlockFromCometBlock(ctx context.Context, resBlock *tmrpctypes.ResultBlock, blockRes *tmrpctypes.ResultBlockResults) (*ethtypes.Block, error)
GetBlockReceipts(ctx context.Context, blockNrOrHash types.BlockNumberOrHash) ([]map[string]interface{}, error)
// Account Info
GetCode(ctx context.Context, address common.Address, blockNrOrHash types.BlockNumberOrHash) (hexutil.Bytes, error)
GetBalance(ctx context.Context, address common.Address, blockNrOrHash types.BlockNumberOrHash) (*hexutil.Big, error)
GetStorageAt(ctx context.Context, address common.Address, key string, blockNrOrHash types.BlockNumberOrHash) (hexutil.Bytes, error)
GetProof(ctx context.Context, address common.Address, storageKeys []string, blockNrOrHash types.BlockNumberOrHash) (*types.AccountResult, error)
GetTransactionCount(ctx context.Context, address common.Address, blockNum types.BlockNumber) (*hexutil.Uint64, error)
// Chain Info
ChainID(ctx context.Context) (*hexutil.Big, error)
ChainConfig() *params.ChainConfig
GlobalMinGasPrice(ctx context.Context) (*big.Int, error)
BaseFee(ctx context.Context, blockRes *tmrpctypes.ResultBlockResults) (*big.Int, error)
CurrentHeader(ctx context.Context) (*ethtypes.Header, error)
PendingTransactions(ctx context.Context) ([]*sdk.Tx, error)
GetCoinbase(ctx context.Context) (sdk.AccAddress, error)
FeeHistory(ctx context.Context, blockCount math.HexOrDecimal64, lastBlock rpc.BlockNumber, rewardPercentiles []float64) (*types.FeeHistoryResult, error)
SuggestGasTipCap(ctx context.Context, baseFee *big.Int) (*big.Int, error)
// Tx Info
GetTransactionByHash(ctx context.Context, txHash common.Hash) (*types.RPCTransaction, error)
GetTxByEthHash(ctx context.Context, txHash common.Hash) (*servertypes.TxResult, error)
GetTxByTxIndex(ctx context.Context, height int64, txIndex uint) (*servertypes.TxResult, error)
GetTransactionByBlockAndIndex(ctx context.Context, block *tmrpctypes.ResultBlock, idx hexutil.Uint) (*types.RPCTransaction, error)
GetTransactionReceipt(ctx context.Context, hash common.Hash) (map[string]interface{}, error)
GetTransactionLogs(ctx context.Context, hash common.Hash) ([]*ethtypes.Log, error)
GetTransactionByBlockHashAndIndex(ctx context.Context, hash common.Hash, idx hexutil.Uint) (*types.RPCTransaction, error)
GetTransactionByBlockNumberAndIndex(ctx context.Context, blockNum types.BlockNumber, idx hexutil.Uint) (*types.RPCTransaction, error)
CreateAccessList(ctx context.Context, args evmtypes.TransactionArgs, blockNrOrHash types.BlockNumberOrHash, overrides *json.RawMessage) (*types.AccessListResult, error)
// Send Transaction
Resend(ctx context.Context, args evmtypes.TransactionArgs, gasPrice *hexutil.Big, gasLimit *hexutil.Uint64) (common.Hash, error)
SendRawTransaction(ctx context.Context, data hexutil.Bytes) (common.Hash, error)
SetTxDefaults(ctx context.Context, args evmtypes.TransactionArgs) (evmtypes.TransactionArgs, error)
EstimateGas(ctx context.Context, args evmtypes.TransactionArgs, blockNrOrHash *types.BlockNumberOrHash, overrides *json.RawMessage) (hexutil.Uint64, error)
DoCall(ctx context.Context, args evmtypes.TransactionArgs, blockNr types.BlockNumber, overrides *json.RawMessage) (*evmtypes.MsgEthereumTxResponse, error)
GasPrice(ctx context.Context) (*hexutil.Big, error)
// Filter API
GetLogs(ctx context.Context, hash common.Hash) ([][]*ethtypes.Log, error)
GetLogsByHeight(ctx context.Context, height *int64) ([][]*ethtypes.Log, error)
BloomStatus() (uint64, uint64)
// TxPool API
Content(ctx context.Context) (map[string]map[string]map[string]*types.RPCTransaction, error)
ContentFrom(ctx context.Context, address common.Address) (map[string]map[string]*types.RPCTransaction, error)
Inspect(ctx context.Context) (map[string]map[string]map[string]string, error)
Status(ctx context.Context) (map[string]hexutil.Uint, error)
// Tracing
TraceTransaction(ctx context.Context, hash common.Hash, config *types.TraceConfig) (interface{}, error)
TraceBlock(ctx context.Context, height types.BlockNumber, config *types.TraceConfig, block *tmrpctypes.ResultBlock) ([]*evmtypes.TxTraceResult, error)
TraceCall(ctx context.Context, args evmtypes.TransactionArgs, blockNrOrHash types.BlockNumberOrHash, config *types.TraceConfig) (interface{}, error)
}
EVMBackend implements the functionality shared within ethereum namespaces as defined by EIP-1474: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1474.md Implemented by Backend.
type Mempool ¶ added in v0.7.0
type Mempool interface {
sdkmempool.Mempool
// GetTxPool returns the mempools underlying evm txpool.
GetTxPool() *txpool.TxPool
}
Mempool is a mempool that can be used for the rpc backend.
type Opt ¶ added in v0.7.0
type Opt func(*Backend)
Opt is a function type that configures the backend.
func WithLogger ¶ added in v0.7.0
WithLogger sets the logger for the backend.
func WithUnprotectedTxs ¶ added in v0.7.0
WithUnprotectedTxs sets whether to allow unprotected transactions.
type ProcessBlocker ¶ added in v0.4.0
type ProcessBlocker func( ctx context.Context, tendermintBlock *tmrpctypes.ResultBlock, ethBlock *map[string]interface{}, rewardPercentiles []float64, tendermintBlockResult *tmrpctypes.ResultBlockResults, targetOneFeeHistory *types.OneFeeHistory, ) error
ProcessBlocker is a function type that processes a block and its associated data for fee history calculation. It takes a Tendermint block, its corresponding Ethereum block representation, reward percentiles for fee estimation, block results, and a target fee history entry to populate.
Parameters:
- ctx: Context for the request
- tendermintBlock: The raw Tendermint block data
- ethBlock: The Ethereum-formatted block representation
- rewardPercentiles: Percentiles used for fee reward calculation
- tendermintBlockResult: Block execution results from Tendermint
- targetOneFeeHistory: The fee history entry to be populated
Returns an error if block processing fails.
type TrackingMempool ¶ added in v0.7.0
type TrackingMempool interface {
// TrackTx is called when a tx should start to be tracked by the
// TrackingMempool. This is called on tx ingestion from the rpc backend.
// This is NOT called when txs are ingested over p2p, i.e local
// transactions only.
TrackTx(hash common.Hash) error
}
TrackingMempool is a set of methods that a mempool may implement in order to track evm transaction lifecycle events.