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(blockRes *cmtrpctypes.ResultBlockResults) (*big.Int, error)
- func (b *Backend) BlockBloom(blockRes *cmtrpctypes.ResultBlockResults) (ethtypes.Bloom, error)
- func (b *Backend) BlockNumber() (hexutil.Uint64, error)
- func (b *Backend) BlockNumberFromComet(blockNrOrHash rpctypes.BlockNumberOrHash) (rpctypes.BlockNumber, error)
- func (b *Backend) BlockNumberFromCometByHash(blockHash common.Hash) (*big.Int, error)
- func (b *Backend) BloomStatus() (uint64, uint64)
- func (b *Backend) ChainConfig() *params.ChainConfig
- func (b *Backend) ChainID() (*hexutil.Big, error)
- func (b *Backend) CometBlockByHash(blockHash common.Hash) (*cmtrpctypes.ResultBlock, error)
- func (b *Backend) CometBlockByNumber(blockNum rpctypes.BlockNumber) (*cmtrpctypes.ResultBlock, error)
- func (b *Backend) CometBlockResultByNumber(height *int64) (*cmtrpctypes.ResultBlockResults, error)
- func (b *Backend) CometHeaderByNumber(blockNum rpctypes.BlockNumber) (*cmtrpctypes.ResultHeader, error)
- func (b *Backend) Content() (map[string]map[string]map[string]*types.RPCTransaction, error)
- func (b *Backend) ContentFrom(addr common.Address) (map[string]map[string]*types.RPCTransaction, error)
- func (b *Backend) CurrentHeader() (*ethtypes.Header, error)
- func (b *Backend) DoCall(args evmtypes.TransactionArgs, blockNr rpctypes.BlockNumber) (*evmtypes.MsgEthereumTxResponse, error)
- func (b *Backend) EstimateGas(args evmtypes.TransactionArgs, blockNrOptional *rpctypes.BlockNumber) (hexutil.Uint64, error)
- func (b *Backend) EthBlockByNumber(blockNum rpctypes.BlockNumber) (*ethtypes.Block, error)
- func (b *Backend) EthBlockFromCometBlock(resBlock *cmtrpctypes.ResultBlock, blockRes *cmtrpctypes.ResultBlockResults) (*ethtypes.Block, error)
- func (b *Backend) EthMsgsFromCometBlock(resBlock *cmtrpctypes.ResultBlock, blockRes *cmtrpctypes.ResultBlockResults) []*evmtypes.MsgEthereumTx
- func (b *Backend) FeeHistory(userBlockCount math.HexOrDecimal64, lastBlock rpc.BlockNumber, ...) (*rpctypes.FeeHistoryResult, error)
- func (b *Backend) GasPrice() (*hexutil.Big, error)
- func (b *Backend) GenerateMinGasCoin(gasPrice hexutil.Big, appConf config.Config) sdk.DecCoin
- func (b *Backend) GetBalance(address common.Address, blockNrOrHash rpctypes.BlockNumberOrHash) (*hexutil.Big, error)
- func (b *Backend) GetBlockByHash(hash common.Hash, fullTx bool) (map[string]interface{}, error)
- func (b *Backend) GetBlockByNumber(blockNum rpctypes.BlockNumber, fullTx bool) (map[string]interface{}, error)
- func (b *Backend) GetBlockReceipts(blockNrOrHash rpctypes.BlockNumberOrHash) ([]map[string]interface{}, error)
- func (b *Backend) GetBlockTransactionCount(block *cmtrpctypes.ResultBlock) *hexutil.Uint
- func (b *Backend) GetBlockTransactionCountByHash(hash common.Hash) *hexutil.Uint
- func (b *Backend) GetBlockTransactionCountByNumber(blockNum rpctypes.BlockNumber) *hexutil.Uint
- func (b *Backend) GetCode(address common.Address, blockNrOrHash rpctypes.BlockNumberOrHash) (hexutil.Bytes, error)
- func (b *Backend) GetCoinbase() (sdk.AccAddress, error)
- func (b *Backend) GetConfig() config.Config
- func (b *Backend) GetGasUsed(res *types.TxResult, price *big.Int, gas uint64) uint64
- func (b *Backend) GetLogs(hash common.Hash) ([][]*ethtypes.Log, error)
- func (b *Backend) GetLogsByHeight(height *int64) ([][]*ethtypes.Log, error)
- func (b *Backend) GetProof(address common.Address, storageKeys []string, ...) (*rpctypes.AccountResult, error)
- func (b *Backend) GetStorageAt(address common.Address, key string, blockNrOrHash rpctypes.BlockNumberOrHash) (hexutil.Bytes, error)
- func (b *Backend) GetTransactionByBlockAndIndex(block *cmtrpctypes.ResultBlock, idx hexutil.Uint) (*rpctypes.RPCTransaction, error)
- func (b *Backend) GetTransactionByBlockHashAndIndex(hash common.Hash, idx hexutil.Uint) (*rpctypes.RPCTransaction, error)
- func (b *Backend) GetTransactionByBlockNumberAndIndex(blockNum rpctypes.BlockNumber, idx hexutil.Uint) (*rpctypes.RPCTransaction, error)
- func (b *Backend) GetTransactionByHash(txHash common.Hash) (*rpctypes.RPCTransaction, error)
- func (b *Backend) GetTransactionByHashPending(txHash common.Hash) (*rpctypes.RPCTransaction, error)
- func (b *Backend) GetTransactionCount(address common.Address, blockNum rpctypes.BlockNumber) (*hexutil.Uint64, error)
- func (b *Backend) GetTransactionLogs(hash common.Hash) ([]*ethtypes.Log, error)
- func (b *Backend) GetTransactionReceipt(hash common.Hash) (map[string]interface{}, error)
- func (b *Backend) GetTxByEthHash(hash common.Hash) (*types.TxResult, error)
- func (b *Backend) GetTxByTxIndex(height int64, index uint) (*types.TxResult, error)
- func (b *Backend) GlobalMinGasPrice() (*big.Int, error)
- func (b *Backend) HeaderByHash(blockHash common.Hash) (*ethtypes.Header, error)
- func (b *Backend) HeaderByNumber(blockNum rpctypes.BlockNumber) (*ethtypes.Header, error)
- func (b *Backend) ImportRawKey(privkey, password string) (common.Address, error)
- func (b *Backend) Inspect() (map[string]map[string]map[string]string, error)
- func (b *Backend) ListAccounts() ([]common.Address, error)
- func (b *Backend) NewMnemonic(uid string, _ keyring.Language, hdPath, bip39Passphrase string, ...) (*keyring.Record, error)
- func (b *Backend) PendingTransactions() ([]*sdk.Tx, error)
- func (b *Backend) ProcessBlock(cometBlock *cmtrpctypes.ResultBlock, ethBlock *map[string]interface{}, ...) error
- func (b *Backend) QueryCometTxIndexer(query string, txGetter func(*rpctypes.ParsedTxs) *rpctypes.ParsedTx) (*types.TxResult, error)
- func (b *Backend) RPCBlockFromCometBlock(resBlock *cmtrpctypes.ResultBlock, blockRes *cmtrpctypes.ResultBlockResults, ...) (map[string]interface{}, error)
- func (b *Backend) RPCBlockRangeCap() int32
- func (b *Backend) RPCEVMTimeout() time.Duration
- func (b *Backend) RPCFeeHistoryCap() int32
- func (b *Backend) RPCFilterCap() int32
- func (b *Backend) RPCGasCap() uint64
- func (b *Backend) RPCLogsCap() int32
- func (b *Backend) RPCMinGasPrice() *big.Int
- func (b *Backend) RPCTxFeeCap() float64
- func (b *Backend) Resend(args evmtypes.TransactionArgs, gasPrice *hexutil.Big, gasLimit *hexutil.Uint64) (common.Hash, error)
- func (b *Backend) SendRawTransaction(data hexutil.Bytes) (common.Hash, error)
- func (b *Backend) SendTransaction(args evmtypes.TransactionArgs) (common.Hash, error)
- func (b *Backend) SetEtherbase(etherbase common.Address) bool
- func (b *Backend) SetGasPrice(gasPrice hexutil.Big) bool
- func (b *Backend) SetTxDefaults(args evmtypes.TransactionArgs) (evmtypes.TransactionArgs, 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() (map[string]hexutil.Uint, error)
- func (b *Backend) SuggestGasTipCap(baseFee *big.Int) (*big.Int, error)
- func (b *Backend) Syncing() (interface{}, error)
- func (b *Backend) TraceBlock(height rpctypes.BlockNumber, config *rpctypes.TraceConfig, ...) ([]*evmtypes.TxTraceResult, error)
- func (b *Backend) TraceTransaction(hash common.Hash, config *rpctypes.TraceConfig) (interface{}, error)
- func (b Backend) UnprotectedAllowed() bool
- type BackendI
- type EVMBackend
- type ProcessBlocker
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 { Ctx context.Context ClientCtx client.Context RPCClient tmrpcclient.SignClient QueryClient *rpctypes.QueryClient // gRPC query client Logger log.Logger EvmChainID *big.Int Cfg config.Config AllowUnprotectedTxs bool Indexer cosmosevmtypes.EVMTxIndexer ProcessBlocker ProcessBlocker }
Backend implements the BackendI interface
func NewBackend ¶
func NewBackend( ctx *server.Context, logger log.Logger, clientCtx client.Context, allowUnprotectedTxs bool, indexer cosmosevmtypes.EVMTxIndexer, ) *Backend
NewBackend creates a new Backend instance for cosmos and ethereum namespaces
func (*Backend) BaseFee ¶
func (b *Backend) BaseFee(blockRes *cmtrpctypes.ResultBlockResults) (*big.Int, 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) BlockBloom ¶
func (b *Backend) BlockBloom(blockRes *cmtrpctypes.ResultBlockResults) (ethtypes.Bloom, 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(blockNrOrHash rpctypes.BlockNumberOrHash) (rpctypes.BlockNumber, error)
BlockNumberFromComet returns the BlockNumber from BlockNumberOrHash
func (*Backend) BlockNumberFromCometByHash ¶ added in v0.4.0
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(blockHash common.Hash) (*cmtrpctypes.ResultBlock, error)
CometBlockByHash returns a CometBFT-formatted block by block number
func (*Backend) CometBlockByNumber ¶ added in v0.4.0
func (b *Backend) CometBlockByNumber(blockNum rpctypes.BlockNumber) (*cmtrpctypes.ResultBlock, error)
CometBlockByNumber returns a CometBFT-formatted block for a given block number
func (*Backend) CometBlockResultByNumber ¶ added in v0.4.0
func (b *Backend) CometBlockResultByNumber(height *int64) (*cmtrpctypes.ResultBlockResults, error)
CometBlockResultByNumber returns a CometBFT-formatted block result by block number
func (*Backend) CometHeaderByNumber ¶ added in v0.4.0
func (b *Backend) CometHeaderByNumber(blockNum rpctypes.BlockNumber) (*cmtrpctypes.ResultHeader, error)
CometHeaderByNumber returns a CometBFT-formatted header for a given block number
func (*Backend) Content ¶ added in v0.4.0
Content returns the transactions contained within the transaction pool.
func (*Backend) ContentFrom ¶ added in v0.4.0
func (b *Backend) ContentFrom(addr common.Address) (map[string]map[string]*types.RPCTransaction, error)
ContentFrom returns the transactions contained within the transaction pool
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( args evmtypes.TransactionArgs, blockNr rpctypes.BlockNumber, ) (*evmtypes.MsgEthereumTxResponse, 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(args evmtypes.TransactionArgs, blockNrOptional *rpctypes.BlockNumber) (hexutil.Uint64, error)
EstimateGas returns an estimate of gas usage for the given smart contract call.
func (*Backend) EthBlockByNumber ¶
EthBlockByNumber returns the Ethereum Block identified by number.
func (*Backend) EthBlockFromCometBlock ¶ added in v0.4.0
func (b *Backend) EthBlockFromCometBlock( resBlock *cmtrpctypes.ResultBlock, blockRes *cmtrpctypes.ResultBlockResults, ) (*ethtypes.Block, error)
EthBlockFromCometBlock returns an Ethereum Block type from CometBFT block
func (*Backend) EthMsgsFromCometBlock ¶ added in v0.4.0
func (b *Backend) EthMsgsFromCometBlock( 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( userBlockCount math.HexOrDecimal64, lastBlock rpc.BlockNumber, rewardPercentiles []float64, ) (*rpctypes.FeeHistoryResult, error)
FeeHistory returns data relevant for fee estimation based on the specified range of blocks.
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(address common.Address, blockNrOrHash rpctypes.BlockNumberOrHash) (*hexutil.Big, error)
GetBalance returns the provided account's *spendable* balance up to the provided block number.
func (*Backend) GetBlockByHash ¶
GetBlockByHash returns the JSON-RPC compatible Ethereum block identified by hash.
func (*Backend) GetBlockByNumber ¶
func (b *Backend) GetBlockByNumber(blockNum rpctypes.BlockNumber, fullTx bool) (map[string]interface{}, 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( blockNrOrHash rpctypes.BlockNumberOrHash, ) ([]map[string]interface{}, error)
GetBlockReceipts returns the receipts for a given block number or hash.
func (*Backend) GetBlockTransactionCount ¶
func (b *Backend) GetBlockTransactionCount(block *cmtrpctypes.ResultBlock) *hexutil.Uint
GetBlockTransactionCount returns the number of Ethereum transactions in a given block.
func (*Backend) GetBlockTransactionCountByHash ¶
GetBlockTransactionCountByHash returns the number of Ethereum transactions in the block identified by hash.
func (*Backend) GetBlockTransactionCountByNumber ¶
func (b *Backend) GetBlockTransactionCountByNumber(blockNum rpctypes.BlockNumber) *hexutil.Uint
GetBlockTransactionCountByNumber returns the number of Ethereum transactions in the block identified by number.
func (*Backend) GetCode ¶
func (b *Backend) GetCode(address common.Address, blockNrOrHash rpctypes.BlockNumberOrHash) (hexutil.Bytes, error)
GetCode returns the contract code at the given address and block number.
func (*Backend) GetCoinbase ¶
func (b *Backend) GetCoinbase() (sdk.AccAddress, error)
GetCoinbase is the address that staking rewards will be send to (alias for Etherbase).
func (*Backend) GetGasUsed ¶
GetGasUsed returns gasUsed from transaction
func (*Backend) GetLogs ¶
GetLogs returns all the logs from all the ethereum transactions in a block.
func (*Backend) GetLogsByHeight ¶
GetLogsByHeight returns all the logs from all the ethereum transactions in a block.
func (*Backend) GetProof ¶
func (b *Backend) GetProof(address common.Address, storageKeys []string, blockNrOrHash rpctypes.BlockNumberOrHash) (*rpctypes.AccountResult, error)
GetProof returns an account object with proof and any storage proofs
func (*Backend) GetStorageAt ¶
func (b *Backend) GetStorageAt(address common.Address, key string, blockNrOrHash rpctypes.BlockNumberOrHash) (hexutil.Bytes, error)
GetStorageAt returns the contract storage at the given address, block number, and key.
func (*Backend) GetTransactionByBlockAndIndex ¶
func (b *Backend) GetTransactionByBlockAndIndex(block *cmtrpctypes.ResultBlock, idx hexutil.Uint) (*rpctypes.RPCTransaction, error)
GetTransactionByBlockAndIndex is the common code shared by `GetTransactionByBlockNumberAndIndex` and `GetTransactionByBlockHashAndIndex`.
func (*Backend) GetTransactionByBlockHashAndIndex ¶
func (b *Backend) GetTransactionByBlockHashAndIndex(hash common.Hash, idx hexutil.Uint) (*rpctypes.RPCTransaction, error)
GetTransactionByBlockHashAndIndex returns the transaction identified by hash and index.
func (*Backend) GetTransactionByBlockNumberAndIndex ¶
func (b *Backend) GetTransactionByBlockNumberAndIndex(blockNum rpctypes.BlockNumber, idx hexutil.Uint) (*rpctypes.RPCTransaction, error)
GetTransactionByBlockNumberAndIndex returns the transaction identified by number and index.
func (*Backend) GetTransactionByHash ¶
GetTransactionByHash returns the Ethereum format transaction identified by Ethereum transaction hash
func (*Backend) GetTransactionByHashPending ¶ added in v0.4.0
GetTransactionByHashPending find pending tx from mempool
func (*Backend) GetTransactionCount ¶
func (b *Backend) GetTransactionCount(address common.Address, blockNum rpctypes.BlockNumber) (*hexutil.Uint64, error)
GetTransactionCount returns the number of transactions at the given address up to the given block number.
func (*Backend) GetTransactionLogs ¶
GetTransactionLogs returns the transaction logs identified by hash.
func (*Backend) GetTransactionReceipt ¶
GetTransactionReceipt returns the transaction receipt identified by hash.
func (*Backend) GetTxByEthHash ¶
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 ¶
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 ¶
HeaderByHash returns the block header identified by hash.
func (*Backend) HeaderByNumber ¶
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) 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( cometBlock *cmtrpctypes.ResultBlock, ethBlock *map[string]interface{}, rewardPercentiles []float64, cometBlockResult *cmtrpctypes.ResultBlockResults, targetOneFeeHistory *types.OneFeeHistory, ) 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:
- 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(query string, txGetter func(*rpctypes.ParsedTxs) *rpctypes.ParsedTx) (*types.TxResult, error)
QueryCometTxIndexer query tx in CometBFT tx indexer
func (*Backend) RPCBlockFromCometBlock ¶ added in v0.4.0
func (b *Backend) RPCBlockFromCometBlock( resBlock *cmtrpctypes.ResultBlock, blockRes *cmtrpctypes.ResultBlockResults, fullTx bool, ) (map[string]interface{}, 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) RPCFilterCap ¶
RPCFilterCap is the limit for total number of filters that can be created
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) Resend ¶
func (b *Backend) Resend(args evmtypes.TransactionArgs, gasPrice *hexutil.Big, gasLimit *hexutil.Uint64) (common.Hash, 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 ¶
SendRawTransaction send a raw Ethereum transaction.
func (*Backend) SendTransaction ¶
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(args evmtypes.TransactionArgs) (evmtypes.TransactionArgs, 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(height rpctypes.BlockNumber, config *rpctypes.TraceConfig, block *tmrpctypes.ResultBlock, ) ([]*evmtypes.TxTraceResult, 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) TraceTransaction ¶
func (b *Backend) TraceTransaction(hash common.Hash, config *rpctypes.TraceConfig) (interface{}, error)
TraceTransaction returns the structured logs created during the execution of EVM and returns them as a JSON object.
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() (interface{}, error) SetEtherbase(etherbase common.Address) bool SetGasPrice(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(args evmtypes.TransactionArgs) (common.Hash, error) SignTypedData(address common.Address, typedData apitypes.TypedData) (hexutil.Bytes, error) // Blocks Info BlockNumber() (hexutil.Uint64, error) GetBlockByNumber(blockNum rpctypes.BlockNumber, fullTx bool) (map[string]interface{}, error) GetBlockByHash(hash common.Hash, fullTx bool) (map[string]interface{}, error) GetBlockTransactionCountByHash(hash common.Hash) *hexutil.Uint GetBlockTransactionCountByNumber(blockNum rpctypes.BlockNumber) *hexutil.Uint CometBlockByNumber(blockNum rpctypes.BlockNumber) (*tmrpctypes.ResultBlock, error) CometBlockByHash(blockHash common.Hash) (*tmrpctypes.ResultBlock, error) BlockNumberFromComet(blockNrOrHash rpctypes.BlockNumberOrHash) (rpctypes.BlockNumber, error) BlockNumberFromCometByHash(blockHash common.Hash) (*big.Int, error) EthMsgsFromCometBlock(block *tmrpctypes.ResultBlock, blockRes *tmrpctypes.ResultBlockResults) []*evmtypes.MsgEthereumTx BlockBloom(blockRes *tmrpctypes.ResultBlockResults) (ethtypes.Bloom, error) HeaderByNumber(blockNum rpctypes.BlockNumber) (*ethtypes.Header, error) HeaderByHash(blockHash common.Hash) (*ethtypes.Header, error) RPCBlockFromCometBlock(resBlock *tmrpctypes.ResultBlock, blockRes *tmrpctypes.ResultBlockResults, fullTx bool) (map[string]interface{}, error) EthBlockByNumber(blockNum rpctypes.BlockNumber) (*ethtypes.Block, error) EthBlockFromCometBlock(resBlock *tmrpctypes.ResultBlock, blockRes *tmrpctypes.ResultBlockResults) (*ethtypes.Block, error) GetBlockReceipts(blockNrOrHash rpctypes.BlockNumberOrHash) ([]map[string]interface{}, error) // Account Info GetCode(address common.Address, blockNrOrHash rpctypes.BlockNumberOrHash) (hexutil.Bytes, error) GetBalance(address common.Address, blockNrOrHash rpctypes.BlockNumberOrHash) (*hexutil.Big, error) GetStorageAt(address common.Address, key string, blockNrOrHash rpctypes.BlockNumberOrHash) (hexutil.Bytes, error) GetProof(address common.Address, storageKeys []string, blockNrOrHash rpctypes.BlockNumberOrHash) (*rpctypes.AccountResult, error) GetTransactionCount(address common.Address, blockNum rpctypes.BlockNumber) (*hexutil.Uint64, error) // Chain Info ChainID() (*hexutil.Big, error) ChainConfig() *params.ChainConfig GlobalMinGasPrice() (*big.Int, error) BaseFee(blockRes *tmrpctypes.ResultBlockResults) (*big.Int, error) CurrentHeader() (*ethtypes.Header, error) PendingTransactions() ([]*sdk.Tx, error) GetCoinbase() (sdk.AccAddress, error) FeeHistory(blockCount math.HexOrDecimal64, lastBlock rpc.BlockNumber, rewardPercentiles []float64) (*rpctypes.FeeHistoryResult, error) SuggestGasTipCap(baseFee *big.Int) (*big.Int, error) // Tx Info GetTransactionByHash(txHash common.Hash) (*rpctypes.RPCTransaction, error) GetTxByEthHash(txHash common.Hash) (*cosmosevmtypes.TxResult, error) GetTxByTxIndex(height int64, txIndex uint) (*cosmosevmtypes.TxResult, error) GetTransactionByBlockAndIndex(block *tmrpctypes.ResultBlock, idx hexutil.Uint) (*rpctypes.RPCTransaction, error) GetTransactionReceipt(hash common.Hash) (map[string]interface{}, error) GetTransactionLogs(hash common.Hash) ([]*ethtypes.Log, error) GetTransactionByBlockHashAndIndex(hash common.Hash, idx hexutil.Uint) (*rpctypes.RPCTransaction, error) GetTransactionByBlockNumberAndIndex(blockNum rpctypes.BlockNumber, idx hexutil.Uint) (*rpctypes.RPCTransaction, error) // Send Transaction Resend(args evmtypes.TransactionArgs, gasPrice *hexutil.Big, gasLimit *hexutil.Uint64) (common.Hash, error) SendRawTransaction(data hexutil.Bytes) (common.Hash, error) SetTxDefaults(args evmtypes.TransactionArgs) (evmtypes.TransactionArgs, error) EstimateGas(args evmtypes.TransactionArgs, blockNrOptional *rpctypes.BlockNumber) (hexutil.Uint64, error) DoCall(args evmtypes.TransactionArgs, blockNr rpctypes.BlockNumber) (*evmtypes.MsgEthereumTxResponse, error) GasPrice() (*hexutil.Big, error) // Filter API GetLogs(hash common.Hash) ([][]*ethtypes.Log, error) GetLogsByHeight(height *int64) ([][]*ethtypes.Log, error) BloomStatus() (uint64, uint64) // TxPool API Content() (map[string]map[string]map[string]*rpctypes.RPCTransaction, error) ContentFrom(address common.Address) (map[string]map[string]*rpctypes.RPCTransaction, error) Inspect() (map[string]map[string]map[string]string, error) Status() (map[string]hexutil.Uint, error) // Tracing TraceTransaction(hash common.Hash, config *rpctypes.TraceConfig) (interface{}, error) TraceBlock(height rpctypes.BlockNumber, config *rpctypes.TraceConfig, block *tmrpctypes.ResultBlock) ([]*evmtypes.TxTraceResult, 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 ProcessBlocker ¶ added in v0.4.0
type ProcessBlocker func( tendermintBlock *tmrpctypes.ResultBlock, ethBlock *map[string]interface{}, rewardPercentiles []float64, tendermintBlockResult *tmrpctypes.ResultBlockResults, targetOneFeeHistory *rpctypes.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:
- 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.