backend

package
v0.11.4 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2023 License: Apache-2.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllTxLogsFromEvents

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

AllTxLogsFromEvents parses all ethereum logs from cosmos events

func ParseTxLogsFromEvent

func ParseTxLogsFromEvent(event abci.Event) ([]*ethtypes.Log, error)

ParseTxLogsFromEvent parse tx logs from one event

func TxLogsFromEvents

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

TxLogsFromEvents parses ethereum logs from cosmos events for specific msg index

Types

type Backend

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

Backend implements the BackendI interface

func NewBackend

func NewBackend(ctx *server.Context, tmNode *node.Node, evmkeeper *evmkeeper.Keeper, ms storetypes.MultiStore, logger log.Logger, clientCtx client.Context) (*Backend, error)

NewBackend creates a new Backend instance for cosmos and ethereum namespaces

func (*Backend) BaseFee

func (b *Backend) BaseFee() (*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(height *int64) (ethtypes.Bloom, error)

BlockBloom query block bloom filter from block results

func (*Backend) BlockNumber

func (b *Backend) 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 (*Backend) BloomStatus

func (b *Backend) BloomStatus() (uint64, uint64)

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) CurrentHeader

func (b *Backend) CurrentHeader() *types.Header

CurrentHeader returns the latest block header

func (*Backend) EstimateGas

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

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

func (*Backend) FeeHistory

func (b *Backend) FeeHistory(
	userBlockCount rpc.DecimalOrHex,
	lastBlock rpc.BlockNumber,
	rewardPercentiles []float64,
) (*types.FeeHistoryResult, error)

FeeHistory returns data relevant for fee estimation based on the specified range of blocks.

func (*Backend) GetBlockByHash

func (b *Backend) GetBlockByHash(hash common.Hash, fullTx bool) (*types.Block, error)

GetBlockByHash returns the block identified by hash.

func (*Backend) GetBlockByNumber

func (b *Backend) GetBlockByNumber(blockNum types.BlockNumber, fullTx bool) (*types.Block, error)

GetBlockByNumber returns the block identified by number.

func (*Backend) GetBlockStore added in v0.10.0

func (b *Backend) GetBlockStore() *store.BlockStore

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) GetConsensusReactor added in v0.10.0

func (b *Backend) GetConsensusReactor() *cs.Reactor

func (*Backend) GetEVMContext added in v0.10.0

func (b *Backend) GetEVMContext() *evm.Context

func (*Backend) GetEVMKeeper added in v0.10.0

func (b *Backend) GetEVMKeeper() *evmkeeper.Keeper

func (*Backend) GetLogs

func (b *Backend) GetLogs(hash common.Hash) ([][]*ethtypes.Log, error)

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

func (*Backend) GetLogsByHeight

func (b *Backend) GetLogsByHeight(height *int64) ([][]*ethtypes.Log, error)

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

func (*Backend) GetLogsByNumber

func (b *Backend) GetLogsByNumber(blockNum types.BlockNumber) ([][]*ethtypes.Log, error)

func (*Backend) GetMempool added in v0.10.0

func (b *Backend) GetMempool() mempool.Mempool

func (*Backend) GetNode added in v0.10.0

func (b *Backend) GetNode() *node.Node

func (*Backend) GetSwitch added in v0.10.0

func (b *Backend) GetSwitch() *p2p.Switch

func (*Backend) GetTendermintBlockByHash

func (b *Backend) GetTendermintBlockByHash(blockHash common.Hash) (*tmrpctypes.ResultBlock, error)

GetTendermintBlockByHash returns a Tendermint format block by block number

func (*Backend) GetTendermintBlockByNumber

func (b *Backend) GetTendermintBlockByNumber(blockNum types.BlockNumber) (*tmrpctypes.ResultBlock, error)

GetTendermintBlockByNumber returns a Tendermint format block by block number

func (*Backend) GetTransactionByHash

func (b *Backend) GetTransactionByHash(txHash common.Hash) (*types.Transaction, error)

GetTransactionByHash returns the Ethereum format transaction identified by Ethereum transaction hash

func (*Backend) GetTransactionCount

func (b *Backend) 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 (*Backend) GetTxByTxIndex

func (b *Backend) GetTxByTxIndex(height int64, index uint) (*tmrpctypes.ResultTx, error)

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

func (*Backend) GetTxPool added in v0.10.0

func (b *Backend) GetTxPool() *pool.TxPool

func (*Backend) HeaderByHash

func (b *Backend) HeaderByHash(blockHash common.Hash) (*types.Header, error)

HeaderByHash returns the block header identified by hash.

func (*Backend) HeaderByNumber

func (b *Backend) HeaderByNumber(blockNum types.BlockNumber) (*types.Header, error)

HeaderByNumber returns the block header identified by height.

func (*Backend) PendingTransactions

func (b *Backend) 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 (*Backend) RPCBlockRangeCap

func (b *Backend) RPCBlockRangeCap() int32

RPCBlockRangeCap defines the max block range allowed for `eth_getLogs` query.

func (*Backend) RPCEVMTimeout

func (b *Backend) RPCEVMTimeout() time.Duration

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

func (*Backend) RPCFeeHistoryCap

func (b *Backend) RPCFeeHistoryCap() int32

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

func (*Backend) RPCFilterCap

func (b *Backend) RPCFilterCap() int32

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

func (*Backend) RPCGasCap

func (b *Backend) RPCGasCap() uint64

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

func (*Backend) RPCLogsCap

func (b *Backend) RPCLogsCap() int32

RPCLogsCap defines the max number of results can be returned from single `eth_getLogs` query.

func (*Backend) RPCMinGasPrice

func (b *Backend) RPCMinGasPrice() int64

func (*Backend) RPCTxFeeCap

func (b *Backend) RPCTxFeeCap() float64

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

func (*Backend) SendTransaction

func (b *Backend) SendTransaction(args evmtypes.TransactionArgs) (common.Hash, error)

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) SuggestGasTipCap

func (b *Backend) SuggestGasTipCap() (*big.Int, error)

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.

type BackendI

type BackendI interface {
	CosmosBackend
	EVMBackend
	TMBackend
}

BackendI implements the Cosmos and EVM backend.

type CosmosBackend

type CosmosBackend interface {
	// TODO: define
	// GetAccounts()
	// SignDirect()
	// SignAmino()
	GetEVMKeeper() *evmkeeper.Keeper
	GetEVMContext() *evm.Context
}

CosmosBackend implements the functionality shared within cosmos namespaces as defined by Wallet Connect V2: https://docs.walletconnect.com/2.0/json-rpc/cosmos. Implemented by Backend.

type EVMBackend

type EVMBackend interface {
	// 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.
	RPCFilterCap() int32
	RPCMinGasPrice() int64
	SuggestGasTipCap() (*big.Int, error)
	RPCLogsCap() int32
	RPCBlockRangeCap() int32

	// 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) (*types.Block, error)
	GetBlockByHash(hash common.Hash, fullTx bool) (*types.Block, error)
	CurrentHeader() *types.Header
	HeaderByNumber(blockNum types.BlockNumber) (*types.Header, error)
	HeaderByHash(blockHash common.Hash) (*types.Header, error)
	PendingTransactions() ([]*sdk.Tx, 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.Transaction, error)
	GetTxByTxIndex(height int64, txIndex uint) (*tmrpctypes.ResultTx, error)
	EstimateGas(args evmtypes.TransactionArgs, blockNrOptional *types.BlockNumber) (hexutil.Uint64, error)
	BaseFee() (*big.Int, error)
	GetLogsByNumber(blockNum types.BlockNumber) ([][]*ethtypes.Log, error)
	BlockBloom(height *int64) (ethtypes.Bloom, error)

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

	// Filter API
	BloomStatus() (uint64, uint64)
	GetLogs(hash common.Hash) ([][]*ethtypes.Log, error)
	GetLogsByHeight(height *int64) ([][]*ethtypes.Log, error)
	ChainConfig() *params.ChainConfig
	SetTxDefaults(args evmtypes.TransactionArgs) (evmtypes.TransactionArgs, 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 TMBackend added in v0.10.0

type TMBackend interface {
	// tendermint helpers
	GetNode() *node.Node
	GetBlockStore() *store.BlockStore
	GetMempool() mempool.Mempool
	GetConsensusReactor() *cs.Reactor
	GetSwitch() *p2p.Switch
	GetTxPool() *pool.TxPool
}

Jump to

Keyboard shortcuts

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