backend

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2021 License: LGPL-3.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TxLogsFromEvents

func TxLogsFromEvents(events []abci.Event) ([]*ethtypes.Log, error)

TxLogsFromEvents parses ethereum logs from cosmos events

Types

type Backend

type Backend interface {
	// Fee API
	FeeHistory(blockCount rpc.DecimalOrHex, lastBlock rpc.BlockNumber, rewardPercentiles []float64) (*types.FeeHistoryResult, error)

	// General Ethereum API
	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() int64
	SuggestGasTipCap() (*big.Int, error)

	// Blockchain API
	BlockNumber() (hexutil.Uint64, error)
	GetTendermintBlockByNumber(blockNum types.BlockNumber) (*tmrpctypes.ResultBlock, error)
	GetTendermintBlockByHash(blockHash common.Hash) (*tmrpctypes.ResultBlock, error)
	GetBlockByNumber(blockNum types.BlockNumber, fullTx bool) (map[string]interface{}, error)
	GetBlockByHash(hash common.Hash, fullTx bool) (map[string]interface{}, error)
	BlockByNumber(blockNum types.BlockNumber) (*ethtypes.Block, error)
	BlockByHash(blockHash common.Hash) (*ethtypes.Block, error)
	CurrentHeader() *ethtypes.Header
	HeaderByNumber(blockNum types.BlockNumber) (*ethtypes.Header, error)
	HeaderByHash(blockHash common.Hash) (*ethtypes.Header, error)
	PendingTransactions() ([]*sdk.Tx, error)
	GetTransactionLogs(txHash common.Hash) ([]*ethtypes.Log, error)
	GetTransactionCount(address common.Address, blockNum types.BlockNumber) (*hexutil.Uint64, error)
	SendTransaction(args evmtypes.TransactionArgs) (common.Hash, error)
	GetCoinbase() (sdk.AccAddress, error)
	GetTransactionByHash(txHash common.Hash) (*types.RPCTransaction, error)
	GetTxByEthHash(txHash common.Hash) (*tmrpctypes.ResultTx, error)
	GetTxByTxIndex(height int64, txIndex uint) (*tmrpctypes.ResultTx, error)
	EstimateGas(args evmtypes.TransactionArgs, blockNrOptional *types.BlockNumber) (hexutil.Uint64, error)
	BaseFee(height int64) (*big.Int, error)

	// Filter API
	BloomStatus() (uint64, uint64)
	GetLogs(hash common.Hash) ([][]*ethtypes.Log, error)
	GetLogsByHeight(height *int64) ([][]*ethtypes.Log, error)
	GetFilteredBlocks(from int64, to int64, filter [][]filters.BloomIV, filterAddresses bool) ([]int64, error)
	ChainConfig() *params.ChainConfig
	SetTxDefaults(args evmtypes.TransactionArgs) (evmtypes.TransactionArgs, error)
	GetEthereumMsgsFromTendermintBlock(block *tmrpctypes.ResultBlock, blockRes *tmrpctypes.ResultBlockResults) []*evmtypes.MsgEthereumTx
}

Backend implements the functionality shared within namespaces. Implemented by EVMBackend.

type EVMBackend

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

EVMBackend implements the Backend interface

func NewEVMBackend

func NewEVMBackend(ctx *server.Context, logger log.Logger, clientCtx client.Context) *EVMBackend

NewEVMBackend creates a new EVMBackend instance

func (*EVMBackend) BaseFee

func (e *EVMBackend) BaseFee(height int64) (*big.Int, error)

BaseFee returns the base fee tracked by the Fee Market module. If the base fee is not enabled, it returns the initial base fee amount. Return nil if London is not activated.

func (*EVMBackend) BlockBloom

func (e *EVMBackend) BlockBloom(height *int64) (ethtypes.Bloom, error)

BlockBloom query block bloom filter from block results

func (*EVMBackend) BlockByHash

func (e *EVMBackend) BlockByHash(hash common.Hash) (*ethtypes.Block, error)

BlockByHash returns the block identified by hash.

func (*EVMBackend) BlockByNumber

func (e *EVMBackend) BlockByNumber(blockNum types.BlockNumber) (*ethtypes.Block, error)

BlockByNumber returns the block identified by number.

func (*EVMBackend) BlockNumber

func (e *EVMBackend) BlockNumber() (hexutil.Uint64, error)

BlockNumber returns the current block number in abci app state. Because abci app state could lag behind from tendermint latest block, it's more stable for the client to use the latest block number in abci app state than tendermint rpc.

func (*EVMBackend) BloomStatus

func (e *EVMBackend) BloomStatus() (uint64, uint64)

BloomStatus returns the BloomBitsBlocks and the number of processed sections maintained by the chain indexer.

func (*EVMBackend) ChainConfig

func (e *EVMBackend) ChainConfig() *params.ChainConfig

ChainConfig return the ethereum chain configuration

func (*EVMBackend) CurrentHeader

func (e *EVMBackend) CurrentHeader() *ethtypes.Header

CurrentHeader returns the latest block header

func (*EVMBackend) EstimateGas

func (e *EVMBackend) EstimateGas(args evmtypes.TransactionArgs, blockNrOptional *types.BlockNumber) (hexutil.Uint64, error)

EstimateGas returns an estimate of gas usage for the given smart contract call.

func (*EVMBackend) EthBlockFromTendermint

func (e *EVMBackend) EthBlockFromTendermint(
	block *tmtypes.Block,
	fullTx bool,
) (map[string]interface{}, error)

EthBlockFromTendermint returns a JSON-RPC compatible Ethereum block from a given Tendermint block and its block result.

func (*EVMBackend) EthBlockFromTm

func (e *EVMBackend) EthBlockFromTm(block *tmtypes.Block) (*ethtypes.Block, error)

func (*EVMBackend) FeeHistory

func (e *EVMBackend) FeeHistory(
	userBlockCount rpc.DecimalOrHex,
	lastBlock rpc.BlockNumber,
	rewardPercentiles []float64,
) (*rpctypes.FeeHistoryResult, error)

func (*EVMBackend) GetBlockByHash

func (e *EVMBackend) GetBlockByHash(hash common.Hash, fullTx bool) (map[string]interface{}, error)

GetBlockByHash returns the block identified by hash.

func (*EVMBackend) GetBlockByNumber

func (e *EVMBackend) GetBlockByNumber(blockNum types.BlockNumber, fullTx bool) (map[string]interface{}, error)

GetBlockByNumber returns the block identified by number.

func (*EVMBackend) GetCoinbase

func (e *EVMBackend) GetCoinbase() (sdk.AccAddress, error)

GetCoinbase is the address that staking rewards will be send to (alias for Etherbase).

func (*EVMBackend) GetEthereumMsgsFromTendermintBlock

func (e *EVMBackend) GetEthereumMsgsFromTendermintBlock(block *tmrpctypes.ResultBlock, blockRes *tmrpctypes.ResultBlockResults) []*evmtypes.MsgEthereumTx

GetEthereumMsgsFromTendermintBlock returns all real MsgEthereumTxs from a Tendermint block. It also ensures consistency over the correct txs indexes across RPC endpoints

func (*EVMBackend) GetFilteredBlocks

func (e *EVMBackend) GetFilteredBlocks(
	from int64,
	to int64,
	filters [][]filters.BloomIV,
	filterAddresses bool,
) ([]int64, error)

GetFilteredBlocks returns the block height list match the given bloom filters.

func (*EVMBackend) GetLogs

func (e *EVMBackend) GetLogs(hash common.Hash) ([][]*ethtypes.Log, error)

GetLogs returns all the logs from all the ethereum transactions in a block.

func (*EVMBackend) GetLogsByHeight

func (e *EVMBackend) GetLogsByHeight(height *int64) ([][]*ethtypes.Log, error)

GetLogsByHeight returns all the logs from all the ethereum transactions in a block.

func (*EVMBackend) GetLogsByNumber

func (e *EVMBackend) GetLogsByNumber(blockNum types.BlockNumber) ([][]*ethtypes.Log, error)

func (*EVMBackend) GetTendermintBlockByHash

func (e *EVMBackend) GetTendermintBlockByHash(blockHash common.Hash) (*tmrpctypes.ResultBlock, error)

GetTendermintBlockByHash returns a Tendermint format block by block number

func (*EVMBackend) GetTendermintBlockByNumber

func (e *EVMBackend) GetTendermintBlockByNumber(blockNum types.BlockNumber) (*tmrpctypes.ResultBlock, error)

GetTendermintBlockByNumber returns a Tendermint format block by block number

func (*EVMBackend) GetTransactionByHash

func (e *EVMBackend) GetTransactionByHash(txHash common.Hash) (*types.RPCTransaction, error)

GetTransactionByHash returns the Ethereum format transaction identified by Ethereum transaction hash

func (*EVMBackend) GetTransactionCount

func (e *EVMBackend) GetTransactionCount(address common.Address, blockNum types.BlockNumber) (*hexutil.Uint64, error)

GetTransactionCount returns the number of transactions at the given address up to the given block number.

func (*EVMBackend) GetTransactionLogs

func (e *EVMBackend) GetTransactionLogs(txHash common.Hash) ([]*ethtypes.Log, error)

GetTransactionLogs returns the logs given a transaction hash. It returns an error if there's an encoding error. If no logs are found for the tx hash, the error is nil.

func (*EVMBackend) GetTxByEthHash

func (e *EVMBackend) GetTxByEthHash(hash common.Hash) (*tmrpctypes.ResultTx, error)

GetTxByEthHash uses `/tx_query` to find transaction by ethereum tx hash TODO: Don't need to convert once hashing is fixed on Tendermint https://github.com/tendermint/tendermint/issues/6539

func (*EVMBackend) GetTxByTxIndex

func (e *EVMBackend) GetTxByTxIndex(height int64, index uint) (*tmrpctypes.ResultTx, error)

GetTxByTxIndex uses `/tx_query` to find transaction by tx index of valid ethereum txs

func (*EVMBackend) HeaderByHash

func (e *EVMBackend) HeaderByHash(blockHash common.Hash) (*ethtypes.Header, error)

HeaderByHash returns the block header identified by hash.

func (*EVMBackend) HeaderByNumber

func (e *EVMBackend) HeaderByNumber(blockNum types.BlockNumber) (*ethtypes.Header, error)

HeaderByNumber returns the block header identified by height.

func (*EVMBackend) PendingTransactions

func (e *EVMBackend) PendingTransactions() ([]*sdk.Tx, error)

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 (*EVMBackend) RPCEVMTimeout

func (e *EVMBackend) RPCEVMTimeout() time.Duration

RPCEVMTimeout is the global evm timeout for eth-call variants.

func (*EVMBackend) RPCFeeHistoryCap

func (e *EVMBackend) RPCFeeHistoryCap() int32

RPCFeeHistoryCap is the limit for total number of blocks that can be fetched

func (*EVMBackend) RPCFilterCap

func (e *EVMBackend) RPCFilterCap() int32

RPCFilterCap is the limit for total number of filters that can be created

func (*EVMBackend) RPCGasCap

func (e *EVMBackend) RPCGasCap() uint64

RPCGasCap is the global gas cap for eth-call variants.

func (*EVMBackend) RPCMinGasPrice

func (e *EVMBackend) RPCMinGasPrice() int64

func (*EVMBackend) RPCTxFeeCap

func (e *EVMBackend) RPCTxFeeCap() float64

RPCGasCap is the global gas cap for eth-call variants.

func (*EVMBackend) SendTransaction

func (e *EVMBackend) SendTransaction(args evmtypes.TransactionArgs) (common.Hash, error)

func (*EVMBackend) SetTxDefaults

SetTxDefaults populates tx message with default values in case they are not provided on the args

func (*EVMBackend) SuggestGasTipCap

func (e *EVMBackend) SuggestGasTipCap() (*big.Int, error)

SuggestGasTipCap returns the suggested tip cap

Jump to

Keyboard shortcuts

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