backend

package
v2.0.0-rc.9 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2024 License: Apache-2.0 Imports: 44 Imported by: 0

Documentation

Overview

Copyright (c) 2023-2024 Nibi, Inc.

Copyright (c) 2023-2024 Nibi, Inc.

Copyright (c) 2023-2024 Nibi, Inc.

Copyright (c) 2023-2024 Nibi, Inc.

Copyright (c) 2023-2024 Nibi, Inc.

Copyright (c) 2023-2024 Nibi, Inc.

Copyright (c) 2023-2024 Nibi, Inc.

Copyright (c) 2023-2024 Nibi, Inc.

Copyright (c) 2023-2024 Nibi, Inc.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllTxLogsFromEvents

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

AllTxLogsFromEvents parses all ethereum logs from cosmos events

func GetHexProofs

func GetHexProofs(proofOps *crypto.ProofOps) []string

GetHexProofs returns list of hex data of proof op

func GetLogsFromBlockResults

func GetLogsFromBlockResults(blockRes *tmrpctypes.ResultBlockResults) ([][]*gethcore.Log, error)

GetLogsFromBlockResults returns the list of event logs from the tendermint block result response

func ParseTxLogsFromEvent

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

ParseTxLogsFromEvent parse tx logs from one event

func ShouldIgnoreGasUsed

func ShouldIgnoreGasUsed(res *abci.ResponseDeliverTx) bool

ShouldIgnoreGasUsed returns true if the gasUsed in result should be ignored workaround for issue: https://github.com/cosmos/cosmos-sdk/issues/10832

func TxLogsFromEvents

func TxLogsFromEvents(events []abci.Event, msgIndex int) ([]*gethcore.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 implements the functionality shared within ethereum namespaces as defined by EIP-1474.

func NewBackend

func NewBackend(
	ctx *server.Context,
	logger log.Logger,
	clientCtx client.Context,
	allowUnprotectedTxs bool,
	evmTxIndexer eth.EVMTxIndexer,
) *Backend

NewBackend creates a new Backend instance for cosmos and ethereum namespaces

func (*Backend) Accounts

func (b *Backend) Accounts() ([]gethcommon.Address, error)

Accounts returns the list of accounts available to this node.

func (*Backend) BaseFee

func (b *Backend) BaseFee(
	blockRes *tmrpctypes.ResultBlockResults,
) (baseFee *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.

func (*Backend) BlockBloom

func (b *Backend) BlockBloom(blockRes *tmrpctypes.ResultBlockResults) (gethcore.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) BlockNumberFromTendermint

func (b *Backend) BlockNumberFromTendermint(blockNrOrHash rpc.BlockNumberOrHash) (rpc.BlockNumber, error)

BlockNumberFromTendermint returns the BlockNumber from BlockNumberOrHash

func (*Backend) BlockNumberFromTendermintByHash

func (b *Backend) BlockNumberFromTendermintByHash(blockHash gethcommon.Hash) (*big.Int, error)

BlockNumberFromTendermintByHash returns the block height of given block hash

func (*Backend) ChainConfig

func (b *Backend) ChainConfig() *params.ChainConfig

ChainConfig returns the latest ethereum chain configuration

func (*Backend) ChainID

func (b *Backend) ChainID() *hexutil.Big

ChainID is the EIP-155 replay-protection chain id for the current ethereum chain config.

func (*Backend) CurrentHeader

func (b *Backend) CurrentHeader() (*gethcore.Header, error)

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 evm.JsonTxArgs, blockNr rpc.BlockNumber,
) (*evm.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 evm.JsonTxArgs, blockNrOptional *rpc.BlockNumber,
) (hexutil.Uint64, error)

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

func (*Backend) EthBlockByNumber

func (b *Backend) EthBlockByNumber(blockNum rpc.BlockNumber) (*gethcore.Block, error)

EthBlockByNumber returns the Ethereum Block identified by number.

func (*Backend) EthBlockFromTendermintBlock

func (b *Backend) EthBlockFromTendermintBlock(
	resBlock *tmrpctypes.ResultBlock,
	blockRes *tmrpctypes.ResultBlockResults,
) (*gethcore.Block, error)

EthBlockFromTendermintBlock returns an Ethereum Block type from Tendermint block EthBlockFromTendermintBlock

func (*Backend) EthMsgsFromTendermintBlock

func (b *Backend) EthMsgsFromTendermintBlock(
	resBlock *tmrpctypes.ResultBlock,
	blockRes *tmrpctypes.ResultBlockResults,
) []*evm.MsgEthereumTx

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

func (*Backend) FeeHistory

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

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

func (*Backend) GasPrice

func (b *Backend) GasPrice() (*hexutil.Big, error)

GasPrice returns the current gas price based on Ethermint's gas price oracle.

func (*Backend) GetBalance

func (b *Backend) GetBalance(
	address gethcommon.Address,
	blockNrOrHash rpc.BlockNumberOrHash,
) (*hexutil.Big, error)

GetBalance returns the provided account's balance up to the provided block number.

func (*Backend) GetBlockByHash

func (b *Backend) GetBlockByHash(hash gethcommon.Hash, fullTx bool) (map[string]interface{}, error)

GetBlockByHash returns the JSON-RPC compatible Ethereum block identified by hash.

func (*Backend) GetBlockByNumber

func (b *Backend) GetBlockByNumber(blockNum rpc.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) GetBlockTransactionCount

func (b *Backend) GetBlockTransactionCount(block *tmrpctypes.ResultBlock) *hexutil.Uint

GetBlockTransactionCount returns the number of Ethereum transactions in a given block.

func (*Backend) GetBlockTransactionCountByHash

func (b *Backend) GetBlockTransactionCountByHash(hash gethcommon.Hash) *hexutil.Uint

GetBlockTransactionCountByHash returns the number of Ethereum transactions in the block identified by hash.

func (*Backend) GetBlockTransactionCountByNumber

func (b *Backend) GetBlockTransactionCountByNumber(blockNum rpc.BlockNumber) *hexutil.Uint

GetBlockTransactionCountByNumber returns the number of Ethereum transactions in the block identified by number.

func (*Backend) GetCode

func (b *Backend) GetCode(
	address gethcommon.Address, blockNrOrHash rpc.BlockNumberOrHash,
) (hexutil.Bytes, error)

GetCode returns the contract code at the given address and block number.

func (*Backend) GetProof

func (b *Backend) GetProof(
	address gethcommon.Address,
	storageKeys []string,
	blockNrOrHash rpc.BlockNumberOrHash,
) (*rpc.AccountResult, error)

GetProof returns an account object with proof and any storage proofs

func (*Backend) GetStorageAt

func (b *Backend) GetStorageAt(address gethcommon.Address, key string, blockNrOrHash rpc.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 *tmrpctypes.ResultBlock, idx hexutil.Uint) (*rpc.EthTxJsonRPC, error)

GetTransactionByBlockAndIndex is the common code shared by `GetTransactionByBlockNumberAndIndex` and `GetTransactionByBlockHashAndIndex`.

func (*Backend) GetTransactionByBlockHashAndIndex

func (b *Backend) GetTransactionByBlockHashAndIndex(hash gethcommon.Hash, idx hexutil.Uint) (*rpc.EthTxJsonRPC, error)

GetTransactionByBlockHashAndIndex returns the transaction identified by hash and index.

func (*Backend) GetTransactionByBlockNumberAndIndex

func (b *Backend) GetTransactionByBlockNumberAndIndex(blockNum rpc.BlockNumber, idx hexutil.Uint) (*rpc.EthTxJsonRPC, error)

GetTransactionByBlockNumberAndIndex returns the transaction identified by number and index.

func (*Backend) GetTransactionByHash

func (b *Backend) GetTransactionByHash(txHash gethcommon.Hash) (*rpc.EthTxJsonRPC, error)

GetTransactionByHash returns the Ethereum format transaction identified by Ethereum transaction hash. If the transaction is not found or has been discarded from a pruning node, this resolves to nil.

func (*Backend) GetTransactionCount

func (b *Backend) GetTransactionCount(address gethcommon.Address, blockNum rpc.BlockNumber) (*hexutil.Uint64, error)

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

func (*Backend) GetTransactionReceipt

func (b *Backend) GetTransactionReceipt(hash gethcommon.Hash) (*TransactionReceipt, error)

GetTransactionReceipt returns the transaction receipt identified by hash.

func (*Backend) GetTxByEthHash

func (b *Backend) GetTxByEthHash(hash gethcommon.Hash) (*eth.TxResult, error)

GetTxByEthHash uses `/tx_query` to find transaction by ethereum tx hash

func (*Backend) GetTxByTxIndex

func (b *Backend) GetTxByTxIndex(height int64, index uint) (*eth.TxResult, error)

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

func (*Backend) GlobalMinGasPrice

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

GlobalMinGasPrice returns the minimum gas price for all nodes. This is distinct from the individual configuration set by the validator set.

func (*Backend) HeaderByNumber

func (b *Backend) HeaderByNumber(blockNum rpc.BlockNumber) (*gethcore.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) RPCBlockFromTendermintBlock

func (b *Backend) RPCBlockFromTendermintBlock(
	resBlock *tmrpctypes.ResultBlock,
	blockRes *tmrpctypes.ResultBlockResults,
	fullTx bool,
) (map[string]interface{}, error)

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

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

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

func (b *Backend) SendRawTransaction(data hexutil.Bytes) (common.Hash, error)

SendRawTransaction send a raw Ethereum transaction.

func (*Backend) SetTxDefaults

func (b *Backend) SetTxDefaults(args evm.JsonTxArgs) (evm.JsonTxArgs, error)

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

func (*Backend) SuggestGasTipCap

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

SuggestGasTipCap Not yet supported. Returns 0 as the suggested tip cap. After implementing tx prioritization, this function can come to life.

func (*Backend) Syncing

func (b *Backend) Syncing() (interface{}, error)

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 peers. 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) TendermintBlockByHash

func (b *Backend) TendermintBlockByHash(blockHash gethcommon.Hash) (*tmrpctypes.ResultBlock, error)

TendermintBlockByHash returns a Tendermint-formatted block by block number

func (*Backend) TendermintBlockByNumber

func (b *Backend) TendermintBlockByNumber(blockNum rpc.BlockNumber) (*tmrpctypes.ResultBlock, error)

TendermintBlockByNumber returns a Tendermint-formatted block for a given block number

func (*Backend) TendermintBlockResultByNumber

func (b *Backend) TendermintBlockResultByNumber(height *int64) (*tmrpctypes.ResultBlockResults, error)

TendermintBlockResultByNumber returns a Tendermint-formatted block result by block number

func (*Backend) TraceBlock

func (b *Backend) TraceBlock(height rpc.BlockNumber,
	config *evm.TraceConfig,
	block *tmrpctypes.ResultBlock,
) ([]*evm.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) TraceCall

func (b *Backend) TraceCall(
	txArgs evm.JsonTxArgs,
	contextBlock rpc.BlockNumber,
	config *evm.TraceConfig,
) (interface{}, error)

TraceCall implements eth debug_traceCall method which lets you run an eth_call within the context of the given block execution using the final state of parent block as the base. Method returns the structured logs created during the execution of EVM. The method returns the same output as debug_traceTransaction. https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-debug#debugtracecall

func (*Backend) TraceTransaction

func (b *Backend) TraceTransaction(hash gethcommon.Hash, config *evm.TraceConfig) (interface{}, error)

TraceTransaction returns the structured logs created during the execution of EVM and returns them as a JSON object.

type CosmosBackend

type CosmosBackend interface {
}

CosmosBackend: Currently unused. Backend functionality for the shared "cosmos" RPC namespace. Implements [BackendI] in combination with Backend. TODO: feat(eth): Implement the cosmos JSON-RPC defined by Wallet Connect V2: https://docs.walletconnect.com/2.0/json-rpc/cosmos.

type TransactionReceipt

type TransactionReceipt struct {
	gethcore.Receipt

	ContractAddress   *gethcommon.Address `json:"contractAddress,omitempty"`
	From              gethcommon.Address
	To                *gethcommon.Address
	EffectiveGasPrice *big.Int
}

TransactionReceipt represents the results of a transaction. TransactionReceipt is an extension of gethcore.Receipt, the response type for the "eth_getTransactionReceipt" JSON-RPC method. Reason being, the gethcore.Receipt struct has an incorrect JSON struct tag on one field and doesn't marshal JSON as expected, so we embed and extend it here.

Jump to

Keyboard shortcuts

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