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.
Index ¶
- Constants
- func BlockMaxGasFromConsensusParams(goCtx context.Context, clientCtx client.Context, blockHeight int64) (int64, error)
- func CheckTxFee(gasPrice *big.Int, gas uint64, cap float64) error
- func EthHeaderFromTendermint(header tmtypes.Header, bloom gethcore.Bloom, baseFee *big.Int) *gethcore.Header
- func FormatBlock(header tmtypes.Header, size int, gasLimit int64, gasUsed *big.Int, ...) map[string]interface{}
- func NewContextWithHeight(height int64) context.Context
- func ParseTxIndexerResult(txResult *tmrpctypes.ResultTx, tx sdk.Tx, getter func(*ParsedTxs) *ParsedTx) (*eth.TxResult, error)
- func RawTxToEthTx(clientCtx client.Context, txBz tmtypes.Tx) ([]*evm.MsgEthereumTx, error)
- func TxExceedBlockGasLimit(res *abci.ResponseDeliverTx) bool
- func TxStateDBCommitError(res *abci.ResponseDeliverTx) bool
- func TxSuccessOrExpectedFailure(res *abci.ResponseDeliverTx) bool
- type AccountResult
- type AddrLocker
- type BlockNumber
- type BlockNumberOrHash
- type EthTxJsonRPC
- type EventFormat
- type FeeHistoryResult
- type OneFeeHistory
- type OverrideAccount
- type ParsedTx
- type ParsedTxs
- type QueryClient
- type SignTransactionResult
- type StateOverride
- type StorageResult
Constants ¶
const ( EthPendingBlockNumber = BlockNumber(-2) EthLatestBlockNumber = BlockNumber(-1) EthEarliestBlockNumber = BlockNumber(0) )
const ( BlockParamEarliest = "earliest" BlockParamLatest = "latest" BlockParamFinalized = "finalized" BlockParamSafe = "safe" BlockParamPending = "pending" )
const ErrExceedBlockGasLimit = "out of gas in location: block gas meter; gasWanted:"
ErrExceedBlockGasLimit defines the error message when tx execution exceeds the block gas limit. The tx fee is deducted in ante handler, so it shouldn't be ignored in JSON-RPC API.
const ErrStateDBCommit = "failed to commit stateDB"
ErrStateDBCommit defines the error message when commit after executing EVM transaction, for example transfer native token to a distribution module account using an evm transaction. Note, the transfer amount cannot be set to 0, otherwise this problem will not be triggered.
Variables ¶
This section is empty.
Functions ¶
func BlockMaxGasFromConsensusParams ¶
func BlockMaxGasFromConsensusParams( goCtx context.Context, clientCtx client.Context, blockHeight int64, ) (int64, error)
BlockMaxGasFromConsensusParams returns the gas limit for the current block from the chain consensus params.
func CheckTxFee ¶
CheckTxFee is an internal function used to check whether the fee of the given transaction is _reasonable_(under the cap).
func EthHeaderFromTendermint ¶
func EthHeaderFromTendermint( header tmtypes.Header, bloom gethcore.Bloom, baseFee *big.Int, ) *gethcore.Header
EthHeaderFromTendermint: Converts a Tendermint block header to an Eth header.
func FormatBlock ¶
func FormatBlock( header tmtypes.Header, size int, gasLimit int64, gasUsed *big.Int, transactions []interface{}, bloom gethcore.Bloom, validatorAddr gethcommon.Address, baseFee *big.Int, ) map[string]interface{}
FormatBlock creates an ethereum block from a tendermint header and ethereum-formatted transactions.
func NewContextWithHeight ¶
NewContextWithHeight wraps a context with the a gRPC block height header. If the provided height is 0, it will return an empty context and the gRPC query will use the latest block height for querying. Note that all metadata gets processed and removed by tendermint layer, so it wont be accessible at gRPC server level.
func ParseTxIndexerResult ¶
func ParseTxIndexerResult( txResult *tmrpctypes.ResultTx, tx sdk.Tx, getter func(*ParsedTxs) *ParsedTx, ) (*eth.TxResult, error)
ParseTxIndexerResult parse tm tx result to a format compatible with the custom tx indexer.
func RawTxToEthTx ¶
RawTxToEthTx returns a evm MsgEthereum transaction from raw tx bytes.
func TxExceedBlockGasLimit ¶
func TxExceedBlockGasLimit(res *abci.ResponseDeliverTx) bool
TxExceedBlockGasLimit returns true if the tx exceeds block gas limit.
func TxStateDBCommitError ¶
func TxStateDBCommitError(res *abci.ResponseDeliverTx) bool
TxStateDBCommitError returns true if the evm tx commit error.
func TxSuccessOrExpectedFailure ¶
func TxSuccessOrExpectedFailure(res *abci.ResponseDeliverTx) bool
TxSuccessOrExpectedFailure returns true if the transaction was successful or if it failed with an ExceedBlockGasLimit error or TxStateDBCommitError error
Types ¶
type AccountResult ¶
type AccountResult struct { Address common.Address `json:"address"` AccountProof []string `json:"accountProof"` Balance *hexutil.Big `json:"balance"` CodeHash common.Hash `json:"codeHash"` Nonce hexutil.Uint64 `json:"nonce"` StorageHash common.Hash `json:"storageHash"` StorageProof []StorageResult `json:"storageProof"` }
AccountResult struct for account proof
type AddrLocker ¶
type AddrLocker struct {
// contains filtered or unexported fields
}
AddrLocker is a mutex (mutual exclusion lock) structure used to avoid querying outdated account data. It prevents data races by allowing only one goroutine to access critical sections at a time.
func (*AddrLocker) LockAddr ¶
func (l *AddrLocker) LockAddr(address common.Address)
LockAddr acquires the mutex for a specific address, blocking if it is already held by another goroutine. The mutex lock prevents an identical nonce from being read again during the time that the first transaction is being signed.
func (*AddrLocker) UnlockAddr ¶
func (l *AddrLocker) UnlockAddr(address common.Address)
UnlockAddr unlocks the mutex for a specific address, allowing other goroutines to acquire it.
type BlockNumber ¶
type BlockNumber int64
BlockNumber represents a decoded hex string for a block number.
func NewBlockNumber ¶
func NewBlockNumber(n *big.Int) BlockNumber
NewBlockNumber creates a new BlockNumber instance.
func (BlockNumber) Int64 ¶
func (bn BlockNumber) Int64() int64
Int64 converts block number to primitive type. This function enforces the first block starting from 1-index.
func (BlockNumber) TmHeight ¶
func (bn BlockNumber) TmHeight() *int64
TmHeight is a util function used for the Tendermint RPC client. It returns nil if the block number is "latest". Otherwise, it returns the pointer of the int64 value of the height.
func (*BlockNumber) UnmarshalJSON ¶
func (bn *BlockNumber) UnmarshalJSON(data []byte) error
UnmarshalJSON parses the given JSON fragment into a BlockNumber. It supports:
- "latest", "finalized", "earliest" or "pending" as string arguments
- the block number
Returned errors:
- Invalid block number error when the given argument isn't a known string
- Out of range error when the given block number is too large or small
type BlockNumberOrHash ¶
type BlockNumberOrHash struct { BlockNumber *BlockNumber `json:"blockNumber,omitempty"` BlockHash *common.Hash `json:"blockHash,omitempty"` }
BlockNumberOrHash represents a block number or a block hash.
func (*BlockNumberOrHash) UnmarshalJSON ¶
func (bnh *BlockNumberOrHash) UnmarshalJSON(data []byte) error
type EthTxJsonRPC ¶
type EthTxJsonRPC struct { BlockHash *common.Hash `json:"blockHash"` BlockNumber *hexutil.Big `json:"blockNumber"` From common.Address `json:"from"` Gas hexutil.Uint64 `json:"gas"` GasPrice *hexutil.Big `json:"gasPrice"` GasFeeCap *hexutil.Big `json:"maxFeePerGas,omitempty"` GasTipCap *hexutil.Big `json:"maxPriorityFeePerGas,omitempty"` Hash common.Hash `json:"hash"` Input hexutil.Bytes `json:"input"` Nonce hexutil.Uint64 `json:"nonce"` To *common.Address `json:"to"` TransactionIndex *hexutil.Uint64 `json:"transactionIndex"` Value *hexutil.Big `json:"value"` Type hexutil.Uint64 `json:"type"` Accesses *gethcore.AccessList `json:"accessList,omitempty"` ChainID *hexutil.Big `json:"chainId,omitempty"` V *hexutil.Big `json:"v"` R *hexutil.Big `json:"r"` S *hexutil.Big `json:"s"` }
EthTxJsonRPC represents a transaction that will serialize to the RPC representation of a transaction
func NewRPCTxFromEthTx ¶
func NewRPCTxFromEthTx( tx *gethcore.Transaction, blockHash gethcommon.Hash, blockNumber, index uint64, baseFee *big.Int, chainID *big.Int, ) (*EthTxJsonRPC, error)
NewTransactionFromData returns a transaction that will serialize to the RPC representation, with the given location metadata set (if available).
func NewRPCTxFromMsg ¶
func NewRPCTxFromMsg( msg *evm.MsgEthereumTx, blockHash gethcommon.Hash, blockNumber, index uint64, baseFee *big.Int, chainID *big.Int, ) (*EthTxJsonRPC, error)
NewRPCTxFromMsg returns a transaction that will serialize to the RPC representation, with the given location metadata set (if available).
type EventFormat ¶
type EventFormat int
EventFormat is an enum type for an ethereum tx event. Each event format variant has json-rpc logic to make it so that clients using either format will be compatible, meaning nodes will able to sync without restarting from the first block.
type FeeHistoryResult ¶
type OneFeeHistory ¶
type OverrideAccount ¶
type OverrideAccount struct { Nonce *hexutil.Uint64 `json:"nonce"` Code *hexutil.Bytes `json:"code"` Balance **hexutil.Big `json:"balance"` State *map[common.Hash]common.Hash `json:"state"` StateDiff *map[common.Hash]common.Hash `json:"stateDiff"` }
OverrideAccount indicates the overriding fields of account during the execution of a message call. Note, state and stateDiff can't be specified at the same time. If state is set, message execution will only use the data in the given state. Otherwise if statDiff is set, all diff will be applied first and then execute the call message.
type ParsedTx ¶
type ParsedTx struct { MsgIndex int Hash common.Hash // -1 means uninitialized EthTxIndex int32 GasUsed uint64 Failed bool }
ParsedTx is eth tx info parsed from ABCI events. Each `ParsedTx` corresponds to one eth tx msg (evm.MsgEthereumTx).
type ParsedTxs ¶
type ParsedTxs struct { // one item per message Txs []ParsedTx // map tx hash to msg index TxHashes map[common.Hash]int }
ParsedTxs is the tx infos parsed from eth tx events.
func ParseTxResult ¶
ParseTxResult: parses eth tx info from the ABCI events of Eth tx msgs (evm.MsgEthereumTx). It supports each EventFormat.
func (*ParsedTxs) AccumulativeGasUsed ¶
AccumulativeGasUsed calculates the accumulated gas used within the batch of txs
func (*ParsedTxs) GetTxByHash ¶
GetTxByHash find ParsedTx by tx hash, returns nil if not exists.
func (*ParsedTxs) GetTxByMsgIndex ¶
GetTxByMsgIndex returns ParsedTx by msg index
func (*ParsedTxs) GetTxByTxIndex ¶
GetTxByTxIndex returns ParsedTx by tx index
type QueryClient ¶
type QueryClient struct { tx.ServiceClient evm.QueryClient }
QueryClient defines a gRPC Client used for:
- TM transaction simulation
- EVM module queries
func NewQueryClient ¶
func NewQueryClient(clientCtx client.Context) *QueryClient
NewQueryClient creates a new gRPC query client
TODO:🔗 https://github.com/NibiruChain/nibiru/issues/1857 test(eth): Test GetProof (rpc/types/query_client.go) in a similar manner to cosmos-sdk/client/rpc/rpc_test.go using a network after EVM is wired into the app keepers:
func (QueryClient) GetProof ¶
func (QueryClient) GetProof( clientCtx client.Context, storeKey string, key []byte, ) ([]byte, *crypto.ProofOps, error)
GetProof performs an ABCI query with the given key and returns a merkle proof. The desired tendermint height to perform the query should be set in the client context. The query will be performed at one below this height (at the IAVL version) in order to obtain the correct merkle proof. Proof queries at height less than or equal to 2 are not supported. Issue: https://github.com/cosmos/cosmos-sdk/issues/6567
type SignTransactionResult ¶
type SignTransactionResult struct { Raw hexutil.Bytes `json:"raw"` Tx *gethcore.Transaction `json:"tx"` }
SignTransactionResult represents a RLP encoded signed transaction.
type StateOverride ¶
type StateOverride map[common.Address]OverrideAccount
StateOverride is the collection of overridden accounts.