From f9ef4eec0aff533a4a219741bdb388a6069a9b42 Mon Sep 17 00:00:00 2001 From: Unique-Divine Date: Sun, 15 Sep 2024 11:34:20 +0900 Subject: [PATCH] fix: merge conflict --- eth/rpc/backend/account_info.go | 10 +++--- eth/rpc/backend/blocks.go | 36 +++++++++---------- eth/rpc/backend/call_tx.go | 12 +++---- eth/rpc/backend/chain_info.go | 16 ++++----- eth/rpc/backend/filters.go | 6 ++-- eth/rpc/backend/node_info.go | 22 ++++++------ eth/rpc/backend/sign_tx.go | 6 ++-- eth/rpc/backend/tracing.go | 6 ++-- eth/rpc/backend/tx_info.go | 20 +++++------ eth/rpc/backend/utils.go | 4 +-- .../testutil/testnetwork/validator_node.go | 2 +- 11 files changed, 70 insertions(+), 70 deletions(-) diff --git a/eth/rpc/backend/account_info.go b/eth/rpc/backend/account_info.go index e5bfdc448..94478a259 100644 --- a/eth/rpc/backend/account_info.go +++ b/eth/rpc/backend/account_info.go @@ -21,7 +21,7 @@ import ( ) // GetCode returns the contract code at the given address and block number. -func (b *EVMBackend) GetCode( +func (b *Backend) GetCode( address common.Address, blockNrOrHash rpc.BlockNumberOrHash, ) (hexutil.Bytes, error) { blockNum, err := b.BlockNumberFromTendermint(blockNrOrHash) @@ -42,7 +42,7 @@ func (b *EVMBackend) GetCode( } // GetProof returns an account object with proof and any storage proofs -func (b *EVMBackend) GetProof( +func (b *Backend) GetProof( address common.Address, storageKeys []string, blockNrOrHash rpc.BlockNumberOrHash, @@ -131,7 +131,7 @@ func (b *EVMBackend) GetProof( } // GetStorageAt returns the contract storage at the given address, block number, and key. -func (b *EVMBackend) GetStorageAt(address common.Address, key string, blockNrOrHash rpc.BlockNumberOrHash) (hexutil.Bytes, error) { +func (b *Backend) GetStorageAt(address common.Address, key string, blockNrOrHash rpc.BlockNumberOrHash) (hexutil.Bytes, error) { blockNum, err := b.BlockNumberFromTendermint(blockNrOrHash) if err != nil { return nil, err @@ -152,7 +152,7 @@ func (b *EVMBackend) GetStorageAt(address common.Address, key string, blockNrOrH } // GetBalance returns the provided account's balance up to the provided block number. -func (b *EVMBackend) GetBalance( +func (b *Backend) GetBalance( address common.Address, blockNrOrHash rpc.BlockNumberOrHash, ) (*hexutil.Big, error) { @@ -189,7 +189,7 @@ func (b *EVMBackend) GetBalance( } // GetTransactionCount returns the number of transactions at the given address up to the given block number. -func (b *EVMBackend) GetTransactionCount(address common.Address, blockNum rpc.BlockNumber) (*hexutil.Uint64, error) { +func (b *Backend) GetTransactionCount(address common.Address, blockNum rpc.BlockNumber) (*hexutil.Uint64, error) { n := hexutil.Uint64(0) bn, err := b.BlockNumber() if err != nil { diff --git a/eth/rpc/backend/blocks.go b/eth/rpc/backend/blocks.go index e476298ee..ea3e38f95 100644 --- a/eth/rpc/backend/blocks.go +++ b/eth/rpc/backend/blocks.go @@ -31,7 +31,7 @@ import ( // 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 (b *EVMBackend) BlockNumber() (hexutil.Uint64, error) { +func (b *Backend) BlockNumber() (hexutil.Uint64, error) { // do any grpc query, ignore the response and use the returned block height var header metadata.MD _, err := b.queryClient.Params(b.ctx, &evm.QueryParamsRequest{}, grpc.Header(&header)) @@ -59,7 +59,7 @@ func (b *EVMBackend) BlockNumber() (hexutil.Uint64, 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 (b *EVMBackend) GetBlockByNumber(blockNum rpc.BlockNumber, fullTx bool) (map[string]interface{}, error) { +func (b *Backend) GetBlockByNumber(blockNum rpc.BlockNumber, fullTx bool) (map[string]interface{}, error) { resBlock, err := b.TendermintBlockByNumber(blockNum) if err != nil { return nil, nil @@ -87,7 +87,7 @@ func (b *EVMBackend) GetBlockByNumber(blockNum rpc.BlockNumber, fullTx bool) (ma // GetBlockByHash returns the JSON-RPC compatible Ethereum block identified by // hash. -func (b *EVMBackend) GetBlockByHash(hash common.Hash, fullTx bool) (map[string]interface{}, error) { +func (b *Backend) GetBlockByHash(hash common.Hash, fullTx bool) (map[string]interface{}, error) { resBlock, err := b.TendermintBlockByHash(hash) if err != nil { return nil, err @@ -115,7 +115,7 @@ func (b *EVMBackend) GetBlockByHash(hash common.Hash, fullTx bool) (map[string]i // GetBlockTransactionCountByHash returns the number of Ethereum transactions in // the block identified by hash. -func (b *EVMBackend) GetBlockTransactionCountByHash(hash common.Hash) *hexutil.Uint { +func (b *Backend) GetBlockTransactionCountByHash(hash common.Hash) *hexutil.Uint { sc, ok := b.clientCtx.Client.(tmrpcclient.SignClient) if !ok { b.logger.Error("invalid rpc client") @@ -137,7 +137,7 @@ func (b *EVMBackend) GetBlockTransactionCountByHash(hash common.Hash) *hexutil.U // GetBlockTransactionCountByNumber returns the number of Ethereum transactions // in the block identified by number. -func (b *EVMBackend) GetBlockTransactionCountByNumber(blockNum rpc.BlockNumber) *hexutil.Uint { +func (b *Backend) GetBlockTransactionCountByNumber(blockNum rpc.BlockNumber) *hexutil.Uint { block, err := b.TendermintBlockByNumber(blockNum) if err != nil { b.logger.Debug("block not found", "height", blockNum.Int64(), "error", err.Error()) @@ -154,7 +154,7 @@ func (b *EVMBackend) GetBlockTransactionCountByNumber(blockNum rpc.BlockNumber) // GetBlockTransactionCount returns the number of Ethereum transactions in a // given block. -func (b *EVMBackend) GetBlockTransactionCount(block *tmrpctypes.ResultBlock) *hexutil.Uint { +func (b *Backend) GetBlockTransactionCount(block *tmrpctypes.ResultBlock) *hexutil.Uint { blockRes, err := b.TendermintBlockResultByNumber(&block.Block.Height) if err != nil { return nil @@ -167,7 +167,7 @@ func (b *EVMBackend) GetBlockTransactionCount(block *tmrpctypes.ResultBlock) *he // TendermintBlockByNumber returns a Tendermint-formatted block for a given // block number -func (b *EVMBackend) TendermintBlockByNumber(blockNum rpc.BlockNumber) (*tmrpctypes.ResultBlock, error) { +func (b *Backend) TendermintBlockByNumber(blockNum rpc.BlockNumber) (*tmrpctypes.ResultBlock, error) { height := blockNum.Int64() if height <= 0 { // fetch the latest block number from the app state, more accurate than the tendermint block store state. @@ -193,7 +193,7 @@ func (b *EVMBackend) TendermintBlockByNumber(blockNum rpc.BlockNumber) (*tmrpcty // TendermintBlockResultByNumber returns a Tendermint-formatted block result // by block number -func (b *EVMBackend) TendermintBlockResultByNumber(height *int64) (*tmrpctypes.ResultBlockResults, error) { +func (b *Backend) TendermintBlockResultByNumber(height *int64) (*tmrpctypes.ResultBlockResults, error) { sc, ok := b.clientCtx.Client.(tmrpcclient.SignClient) if !ok { return nil, errors.New("invalid rpc client") @@ -202,7 +202,7 @@ func (b *EVMBackend) TendermintBlockResultByNumber(height *int64) (*tmrpctypes.R } // TendermintBlockByHash returns a Tendermint-formatted block by block number -func (b *EVMBackend) TendermintBlockByHash(blockHash common.Hash) (*tmrpctypes.ResultBlock, error) { +func (b *Backend) TendermintBlockByHash(blockHash common.Hash) (*tmrpctypes.ResultBlock, error) { sc, ok := b.clientCtx.Client.(tmrpcclient.SignClient) if !ok { return nil, errors.New("invalid rpc client") @@ -222,7 +222,7 @@ func (b *EVMBackend) TendermintBlockByHash(blockHash common.Hash) (*tmrpctypes.R } // BlockNumberFromTendermint returns the BlockNumber from BlockNumberOrHash -func (b *EVMBackend) BlockNumberFromTendermint(blockNrOrHash rpc.BlockNumberOrHash) (rpc.BlockNumber, error) { +func (b *Backend) BlockNumberFromTendermint(blockNrOrHash rpc.BlockNumberOrHash) (rpc.BlockNumber, error) { switch { case blockNrOrHash.BlockHash == nil && blockNrOrHash.BlockNumber == nil: return rpc.EthEarliestBlockNumber, fmt.Errorf("types BlockHash and BlockNumber cannot be both nil") @@ -240,7 +240,7 @@ func (b *EVMBackend) BlockNumberFromTendermint(blockNrOrHash rpc.BlockNumberOrHa } // BlockNumberFromTendermintByHash returns the block height of given block hash -func (b *EVMBackend) BlockNumberFromTendermintByHash(blockHash common.Hash) (*big.Int, error) { +func (b *Backend) BlockNumberFromTendermintByHash(blockHash common.Hash) (*big.Int, error) { resBlock, err := b.TendermintBlockByHash(blockHash) if err != nil { return nil, err @@ -254,7 +254,7 @@ func (b *EVMBackend) BlockNumberFromTendermintByHash(blockHash common.Hash) (*bi // EthMsgsFromTendermintBlock returns all real MsgEthereumTxs from a // Tendermint block. It also ensures consistency over the correct txs indexes // across RPC endpoints -func (b *EVMBackend) EthMsgsFromTendermintBlock( +func (b *Backend) EthMsgsFromTendermintBlock( resBlock *tmrpctypes.ResultBlock, blockRes *tmrpctypes.ResultBlockResults, ) []*evm.MsgEthereumTx { @@ -299,7 +299,7 @@ func (b *EVMBackend) EthMsgsFromTendermintBlock( } // HeaderByNumber returns the block header identified by height. -func (b *EVMBackend) HeaderByNumber(blockNum rpc.BlockNumber) (*gethcore.Header, error) { +func (b *Backend) HeaderByNumber(blockNum rpc.BlockNumber) (*gethcore.Header, error) { resBlock, err := b.TendermintBlockByNumber(blockNum) if err != nil { return nil, err @@ -330,7 +330,7 @@ func (b *EVMBackend) HeaderByNumber(blockNum rpc.BlockNumber) (*gethcore.Header, } // HeaderByHash returns the block header identified by hash. -func (b *EVMBackend) HeaderByHash(blockHash common.Hash) (*gethcore.Header, error) { +func (b *Backend) HeaderByHash(blockHash common.Hash) (*gethcore.Header, error) { resBlock, err := b.TendermintBlockByHash(blockHash) if err != nil { return nil, err @@ -360,7 +360,7 @@ func (b *EVMBackend) HeaderByHash(blockHash common.Hash) (*gethcore.Header, erro } // BlockBloom query block bloom filter from block results -func (b *EVMBackend) BlockBloom(blockRes *tmrpctypes.ResultBlockResults) (gethcore.Bloom, error) { +func (b *Backend) BlockBloom(blockRes *tmrpctypes.ResultBlockResults) (gethcore.Bloom, error) { msgType := proto.MessageName((*evm.EventBlockBloom)(nil)) for _, event := range blockRes.EndBlockEvents { if event.Type != msgType { @@ -382,7 +382,7 @@ func (b *EVMBackend) BlockBloom(blockRes *tmrpctypes.ResultBlockResults) (gethco // RPCBlockFromTendermintBlock returns a JSON-RPC compatible Ethereum block from a // given Tendermint block and its block result. -func (b *EVMBackend) RPCBlockFromTendermintBlock( +func (b *Backend) RPCBlockFromTendermintBlock( resBlock *tmrpctypes.ResultBlock, blockRes *tmrpctypes.ResultBlockResults, fullTx bool, @@ -478,7 +478,7 @@ func (b *EVMBackend) RPCBlockFromTendermintBlock( } // EthBlockByNumber returns the Ethereum Block identified by number. -func (b *EVMBackend) EthBlockByNumber(blockNum rpc.BlockNumber) (*gethcore.Block, error) { +func (b *Backend) EthBlockByNumber(blockNum rpc.BlockNumber) (*gethcore.Block, error) { resBlock, err := b.TendermintBlockByNumber(blockNum) if err != nil { return nil, err @@ -498,7 +498,7 @@ func (b *EVMBackend) EthBlockByNumber(blockNum rpc.BlockNumber) (*gethcore.Block // EthBlockFromTendermintBlock returns an Ethereum Block type from Tendermint block // EthBlockFromTendermintBlock -func (b *EVMBackend) EthBlockFromTendermintBlock( +func (b *Backend) EthBlockFromTendermintBlock( resBlock *tmrpctypes.ResultBlock, blockRes *tmrpctypes.ResultBlockResults, ) (*gethcore.Block, error) { diff --git a/eth/rpc/backend/call_tx.go b/eth/rpc/backend/call_tx.go index 6e04d65ee..12f7ce378 100644 --- a/eth/rpc/backend/call_tx.go +++ b/eth/rpc/backend/call_tx.go @@ -26,7 +26,7 @@ import ( // 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 (b *EVMBackend) Resend(args evm.JsonTxArgs, gasPrice *hexutil.Big, gasLimit *hexutil.Uint64) (common.Hash, error) { +func (b *Backend) Resend(args evm.JsonTxArgs, gasPrice *hexutil.Big, gasLimit *hexutil.Uint64) (common.Hash, error) { if args.Nonce == nil { return common.Hash{}, fmt.Errorf("missing transaction nonce in transaction spec") } @@ -102,7 +102,7 @@ func (b *EVMBackend) Resend(args evm.JsonTxArgs, gasPrice *hexutil.Big, gasLimit } // SendRawTransaction send a raw Ethereum transaction. -func (b *EVMBackend) SendRawTransaction(data hexutil.Bytes) (common.Hash, error) { +func (b *Backend) SendRawTransaction(data hexutil.Bytes) (common.Hash, error) { // RLP decode raw transaction bytes tx := &gethcore.Transaction{} if err := tx.UnmarshalBinary(data); err != nil { @@ -170,7 +170,7 @@ func (b *EVMBackend) SendRawTransaction(data hexutil.Bytes) (common.Hash, error) // SetTxDefaults populates tx message with default values in case they are not // provided on the args -func (b *EVMBackend) SetTxDefaults(args evm.JsonTxArgs) (evm.JsonTxArgs, error) { +func (b *Backend) SetTxDefaults(args evm.JsonTxArgs) (evm.JsonTxArgs, error) { if args.GasPrice != nil && (args.MaxFeePerGas != nil || args.MaxPriorityFeePerGas != nil) { return args, errors.New("both gasPrice and (maxFeePerGas or maxPriorityFeePerGas) specified") } @@ -297,7 +297,7 @@ func (b *EVMBackend) SetTxDefaults(args evm.JsonTxArgs) (evm.JsonTxArgs, error) } // EstimateGas returns an estimate of gas usage for the given smart contract call. -func (b *EVMBackend) EstimateGas( +func (b *Backend) EstimateGas( args evm.JsonTxArgs, blockNrOptional *rpc.BlockNumber, ) (hexutil.Uint64, error) { blockNr := rpc.EthPendingBlockNumber @@ -335,7 +335,7 @@ func (b *EVMBackend) EstimateGas( // DoCall performs a simulated call operation through the evmtypes. It returns the // estimated gas used on the operation or an error if fails. -func (b *EVMBackend) DoCall( +func (b *Backend) DoCall( args evm.JsonTxArgs, blockNr rpc.BlockNumber, ) (*evm.MsgEthereumTxResponse, error) { bz, err := json.Marshal(&args) @@ -390,7 +390,7 @@ func (b *EVMBackend) DoCall( } // GasPrice returns the current gas price based on Ethermint's gas price oracle. -func (b *EVMBackend) GasPrice() (*hexutil.Big, error) { +func (b *Backend) GasPrice() (*hexutil.Big, error) { var ( result *big.Int err error diff --git a/eth/rpc/backend/chain_info.go b/eth/rpc/backend/chain_info.go index a0a2b881f..6b478a577 100644 --- a/eth/rpc/backend/chain_info.go +++ b/eth/rpc/backend/chain_info.go @@ -21,7 +21,7 @@ import ( ) // ChainID is the EIP-155 replay-protection chain id for the current ethereum chain config. -func (b *EVMBackend) ChainID() (*hexutil.Big, error) { +func (b *Backend) ChainID() (*hexutil.Big, error) { eip155ChainID, err := eth.ParseEthChainID(b.clientCtx.ChainID) if err != nil { panic(err) @@ -41,7 +41,7 @@ func (b *EVMBackend) ChainID() (*hexutil.Big, error) { } // ChainConfig returns the latest ethereum chain configuration -func (b *EVMBackend) ChainConfig() *params.ChainConfig { +func (b *Backend) ChainConfig() *params.ChainConfig { _, err := b.queryClient.Params(b.ctx, &evm.QueryParamsRequest{}) if err != nil { return nil @@ -52,7 +52,7 @@ func (b *EVMBackend) ChainConfig() *params.ChainConfig { // BaseFee returns the base fee tracked by the Fee Market module. // If the base fee is not enabled globally, the query returns nil. -func (b *EVMBackend) BaseFee( +func (b *Backend) BaseFee( blockRes *tmrpctypes.ResultBlockResults, ) (baseFee *big.Int, err error) { // return BaseFee if feemarket is enabled @@ -68,13 +68,13 @@ func (b *EVMBackend) BaseFee( // 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 (b *EVMBackend) CurrentHeader() (*gethcore.Header, error) { +func (b *Backend) CurrentHeader() (*gethcore.Header, error) { return b.HeaderByNumber(rpc.EthLatestBlockNumber) } // 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 (b *EVMBackend) PendingTransactions() ([]*sdk.Tx, error) { +func (b *Backend) PendingTransactions() ([]*sdk.Tx, error) { mc, ok := b.clientCtx.Client.(tmrpcclient.MempoolClient) if !ok { return nil, errors.New("invalid rpc client") @@ -98,7 +98,7 @@ func (b *EVMBackend) PendingTransactions() ([]*sdk.Tx, error) { } // FeeHistory returns data relevant for fee estimation based on the specified range of blocks. -func (b *EVMBackend) FeeHistory( +func (b *Backend) FeeHistory( userBlockCount gethrpc.DecimalOrHex, // number blocks to fetch, maximum is 100 lastBlock gethrpc.BlockNumber, // the block to start search , to oldest rewardPercentiles []float64, // percentiles to fetch reward @@ -196,7 +196,7 @@ func (b *EVMBackend) FeeHistory( // SuggestGasTipCap: Not yet supported. Returns 0 as the suggested tip cap. After // implementing tx prioritization, this function can come to life. -func (b *EVMBackend) SuggestGasTipCap(baseFee *big.Int) (*big.Int, error) { +func (b *Backend) SuggestGasTipCap(baseFee *big.Int) (*big.Int, error) { maxDelta := big.NewInt(0) return maxDelta, nil } @@ -205,7 +205,7 @@ func DefaultMinGasPrice() sdkmath.LegacyDec { return sdkmath.LegacyZeroDec() } // GlobalMinGasPrice returns the minimum gas price for all nodes. This is // distinct from the individual configuration set by the validator set. -func (b *EVMBackend) GlobalMinGasPrice() (sdkmath.LegacyDec, error) { +func (b *Backend) GlobalMinGasPrice() (sdkmath.LegacyDec, error) { // TODO: feat(eth): dynamic fees return DefaultMinGasPrice(), nil } diff --git a/eth/rpc/backend/filters.go b/eth/rpc/backend/filters.go index da0c393a7..02fa6c11f 100644 --- a/eth/rpc/backend/filters.go +++ b/eth/rpc/backend/filters.go @@ -8,7 +8,7 @@ import ( ) // GetLogs returns all the logs from all the ethereum transactions in a block. -func (b *EVMBackend) GetLogs(hash common.Hash) ([][]*gethcore.Log, error) { +func (b *Backend) GetLogs(hash common.Hash) ([][]*gethcore.Log, error) { resBlock, err := b.TendermintBlockByHash(hash) if err != nil { return nil, err @@ -20,7 +20,7 @@ func (b *EVMBackend) GetLogs(hash common.Hash) ([][]*gethcore.Log, error) { } // GetLogsByHeight returns all the logs from all the ethereum transactions in a block. -func (b *EVMBackend) GetLogsByHeight(height *int64) ([][]*gethcore.Log, error) { +func (b *Backend) GetLogsByHeight(height *int64) ([][]*gethcore.Log, error) { // NOTE: we query the state in case the tx result logs are not persisted after an upgrade. blockRes, err := b.TendermintBlockResultByNumber(height) if err != nil { @@ -34,7 +34,7 @@ func (b *EVMBackend) GetLogsByHeight(height *int64) ([][]*gethcore.Log, error) { // - bloomBitsBlocks: The number of blocks a single bloom bit section vector // contains on the server side. // - bloomSections: The number of processed sections maintained by the indexer. -func (b *EVMBackend) BloomStatus() ( +func (b *Backend) BloomStatus() ( bloomBitBlocks, bloomSections uint64, ) { return 4096, 0 diff --git a/eth/rpc/backend/node_info.go b/eth/rpc/backend/node_info.go index 69a8238ce..93f3cc32b 100644 --- a/eth/rpc/backend/node_info.go +++ b/eth/rpc/backend/node_info.go @@ -12,7 +12,7 @@ import ( ) // Accounts returns the list of accounts available to this node. -func (b *EVMBackend) Accounts() ([]common.Address, error) { +func (b *Backend) Accounts() ([]common.Address, error) { addresses := make([]common.Address, 0) // return [] instead of nil if empty infos, err := b.clientCtx.Keyring.List() @@ -39,7 +39,7 @@ func (b *EVMBackend) Accounts() ([]common.Address, error) { // - 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 (b *EVMBackend) Syncing() (interface{}, error) { +func (b *Backend) Syncing() (interface{}, error) { status, err := b.clientCtx.Client.Status(b.ctx) if err != nil { return false, err @@ -60,49 +60,49 @@ func (b *EVMBackend) Syncing() (interface{}, error) { // UnprotectedAllowed returns the node configuration value for allowing // unprotected transactions (i.e not replay-protected) -func (b EVMBackend) UnprotectedAllowed() bool { +func (b Backend) UnprotectedAllowed() bool { return b.allowUnprotectedTxs } // RPCGasCap is the global gas cap for eth-call variants. -func (b *EVMBackend) RPCGasCap() uint64 { +func (b *Backend) RPCGasCap() uint64 { return b.cfg.JSONRPC.GasCap } // RPCEVMTimeout is the global evm timeout for eth-call variants. -func (b *EVMBackend) RPCEVMTimeout() time.Duration { +func (b *Backend) RPCEVMTimeout() time.Duration { return b.cfg.JSONRPC.EVMTimeout } // RPCGasCap is the global gas cap for eth-call variants. -func (b *EVMBackend) RPCTxFeeCap() float64 { +func (b *Backend) RPCTxFeeCap() float64 { return b.cfg.JSONRPC.TxFeeCap } // RPCFilterCap is the limit for total number of filters that can be created -func (b *EVMBackend) RPCFilterCap() int32 { +func (b *Backend) RPCFilterCap() int32 { return b.cfg.JSONRPC.FilterCap } // RPCFeeHistoryCap is the limit for total number of blocks that can be fetched -func (b *EVMBackend) RPCFeeHistoryCap() int32 { +func (b *Backend) RPCFeeHistoryCap() int32 { return b.cfg.JSONRPC.FeeHistoryCap } // RPCLogsCap defines the max number of results can be returned from single `eth_getLogs` query. -func (b *EVMBackend) RPCLogsCap() int32 { +func (b *Backend) RPCLogsCap() int32 { return b.cfg.JSONRPC.LogsCap } // RPCBlockRangeCap defines the max block range allowed for `eth_getLogs` query. -func (b *EVMBackend) RPCBlockRangeCap() int32 { +func (b *Backend) RPCBlockRangeCap() int32 { return b.cfg.JSONRPC.BlockRangeCap } // 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 (b *EVMBackend) RPCMinGasPrice() int64 { +func (b *Backend) RPCMinGasPrice() int64 { evmParams, err := b.queryClient.Params(b.ctx, &evm.QueryParamsRequest{}) if err != nil { return eth.DefaultGasPrice diff --git a/eth/rpc/backend/sign_tx.go b/eth/rpc/backend/sign_tx.go index a84a3fcc3..7d3032ea3 100644 --- a/eth/rpc/backend/sign_tx.go +++ b/eth/rpc/backend/sign_tx.go @@ -20,7 +20,7 @@ import ( ) // SendTransaction sends transaction based on received args using Node's key to sign it -func (b *EVMBackend) SendTransaction(args evm.JsonTxArgs) (common.Hash, error) { +func (b *Backend) SendTransaction(args evm.JsonTxArgs) (common.Hash, error) { // Look up the wallet containing the requested signer _, err := b.clientCtx.Keyring.KeyByAddress(sdk.AccAddress(args.GetFrom().Bytes())) if err != nil { @@ -109,7 +109,7 @@ func (b *EVMBackend) SendTransaction(args evm.JsonTxArgs) (common.Hash, error) { } // Sign signs the provided data using the private key of address via Geth's signature standard. -func (b *EVMBackend) Sign(address common.Address, data hexutil.Bytes) (hexutil.Bytes, error) { +func (b *Backend) Sign(address common.Address, data hexutil.Bytes) (hexutil.Bytes, error) { from := sdk.AccAddress(address.Bytes()) _, err := b.clientCtx.Keyring.KeyByAddress(from) @@ -130,7 +130,7 @@ func (b *EVMBackend) Sign(address common.Address, data hexutil.Bytes) (hexutil.B } // SignTypedData signs EIP-712 conformant typed data -func (b *EVMBackend) SignTypedData(address common.Address, typedData apitypes.TypedData) (hexutil.Bytes, error) { +func (b *Backend) SignTypedData(address common.Address, typedData apitypes.TypedData) (hexutil.Bytes, error) { from := sdk.AccAddress(address.Bytes()) _, err := b.clientCtx.Keyring.KeyByAddress(from) diff --git a/eth/rpc/backend/tracing.go b/eth/rpc/backend/tracing.go index ff81ee5ac..425e3d00e 100644 --- a/eth/rpc/backend/tracing.go +++ b/eth/rpc/backend/tracing.go @@ -18,7 +18,7 @@ import ( // TraceTransaction returns the structured logs created during the execution of EVM // and returns them as a JSON object. -func (b *EVMBackend) TraceTransaction(hash common.Hash, config *evm.TraceConfig) (interface{}, error) { +func (b *Backend) TraceTransaction(hash common.Hash, config *evm.TraceConfig) (interface{}, error) { // Get transaction by hash transaction, err := b.GetTxByEthHash(hash) if err != nil { @@ -136,7 +136,7 @@ func (b *EVMBackend) TraceTransaction(hash common.Hash, config *evm.TraceConfig) // 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 (b *EVMBackend) TraceBlock(height rpc.BlockNumber, +func (b *Backend) TraceBlock(height rpc.BlockNumber, config *evm.TraceConfig, block *tmrpctypes.ResultBlock, ) ([]*evm.TxTraceResult, error) { @@ -215,7 +215,7 @@ func (b *EVMBackend) TraceBlock(height rpc.BlockNumber, // 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 (b *EVMBackend) TraceCall( +func (b *Backend) TraceCall( txArgs evm.JsonTxArgs, contextBlock rpc.BlockNumber, config *evm.TraceConfig, diff --git a/eth/rpc/backend/tx_info.go b/eth/rpc/backend/tx_info.go index 0ab058477..2f5003d0b 100644 --- a/eth/rpc/backend/tx_info.go +++ b/eth/rpc/backend/tx_info.go @@ -25,7 +25,7 @@ import ( // 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 (b *EVMBackend) GetTransactionByHash(txHash common.Hash) (*rpc.EthTxJsonRPC, error) { +func (b *Backend) GetTransactionByHash(txHash common.Hash) (*rpc.EthTxJsonRPC, error) { res, err := b.GetTxByEthHash(txHash) if err != nil { return b.getTransactionByHashPending(txHash) @@ -90,7 +90,7 @@ func (b *EVMBackend) GetTransactionByHash(txHash common.Hash) (*rpc.EthTxJsonRPC } // getTransactionByHashPending find pending tx from mempool -func (b *EVMBackend) getTransactionByHashPending(txHash common.Hash) (*rpc.EthTxJsonRPC, error) { +func (b *Backend) getTransactionByHashPending(txHash common.Hash) (*rpc.EthTxJsonRPC, error) { hexTx := txHash.Hex() // try to find tx in mempool txs, err := b.PendingTransactions() @@ -129,7 +129,7 @@ func (b *EVMBackend) getTransactionByHashPending(txHash common.Hash) (*rpc.EthTx // GetGasUsed returns gasUsed from transaction, patching to // price * gas in the event the tx is reverted. -func (b *EVMBackend) GetGasUsed(res *eth.TxResult, price *big.Int, gas uint64) uint64 { +func (b *Backend) GetGasUsed(res *eth.TxResult, price *big.Int, gas uint64) uint64 { if res.Failed && res.Height < b.cfg.JSONRPC.FixRevertGasRefundHeight { return new(big.Int).Mul(price, new(big.Int).SetUint64(gas)).Uint64() } @@ -137,7 +137,7 @@ func (b *EVMBackend) GetGasUsed(res *eth.TxResult, price *big.Int, gas uint64) u } // GetTransactionReceipt returns the transaction receipt identified by hash. -func (b *EVMBackend) GetTransactionReceipt(hash common.Hash) (map[string]interface{}, error) { +func (b *Backend) GetTransactionReceipt(hash common.Hash) (map[string]interface{}, error) { hexTx := hash.Hex() b.logger.Debug("eth_getTransactionReceipt", "hash", hexTx) @@ -263,7 +263,7 @@ func (b *EVMBackend) GetTransactionReceipt(hash common.Hash) (map[string]interfa } // GetTransactionByBlockHashAndIndex returns the transaction identified by hash and index. -func (b *EVMBackend) GetTransactionByBlockHashAndIndex(hash common.Hash, idx hexutil.Uint) (*rpc.EthTxJsonRPC, error) { +func (b *Backend) GetTransactionByBlockHashAndIndex(hash common.Hash, idx hexutil.Uint) (*rpc.EthTxJsonRPC, error) { b.logger.Debug("eth_getTransactionByBlockHashAndIndex", "hash", hash.Hex(), "index", idx) sc, ok := b.clientCtx.Client.(tmrpcclient.SignClient) if !ok { @@ -285,7 +285,7 @@ func (b *EVMBackend) GetTransactionByBlockHashAndIndex(hash common.Hash, idx hex } // GetTransactionByBlockNumberAndIndex returns the transaction identified by number and index. -func (b *EVMBackend) GetTransactionByBlockNumberAndIndex(blockNum rpc.BlockNumber, idx hexutil.Uint) (*rpc.EthTxJsonRPC, error) { +func (b *Backend) GetTransactionByBlockNumberAndIndex(blockNum rpc.BlockNumber, idx hexutil.Uint) (*rpc.EthTxJsonRPC, error) { b.logger.Debug("eth_getTransactionByBlockNumberAndIndex", "number", blockNum, "index", idx) block, err := b.TendermintBlockByNumber(blockNum) @@ -305,7 +305,7 @@ func (b *EVMBackend) GetTransactionByBlockNumberAndIndex(blockNum rpc.BlockNumbe // 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/cometbft/cometbft/issues/6539 -func (b *EVMBackend) GetTxByEthHash(hash common.Hash) (*eth.TxResult, error) { +func (b *Backend) GetTxByEthHash(hash common.Hash) (*eth.TxResult, error) { if b.indexer != nil { return b.indexer.GetByTxHash(hash) } @@ -322,7 +322,7 @@ func (b *EVMBackend) GetTxByEthHash(hash common.Hash) (*eth.TxResult, error) { } // GetTxByTxIndex uses `/tx_query` to find transaction by tx index of valid ethereum txs -func (b *EVMBackend) GetTxByTxIndex(height int64, index uint) (*eth.TxResult, error) { +func (b *Backend) GetTxByTxIndex(height int64, index uint) (*eth.TxResult, error) { int32Index := int32(index) // #nosec G701 -- checked for int overflow already if b.indexer != nil { return b.indexer.GetByBlockAndIndex(height, int32Index) @@ -343,7 +343,7 @@ func (b *EVMBackend) GetTxByTxIndex(height int64, index uint) (*eth.TxResult, er } // queryTendermintTxIndexer query tx in tendermint tx indexer -func (b *EVMBackend) queryTendermintTxIndexer(query string, txGetter func(*rpc.ParsedTxs) *rpc.ParsedTx) (*eth.TxResult, error) { +func (b *Backend) queryTendermintTxIndexer(query string, txGetter func(*rpc.ParsedTxs) *rpc.ParsedTx) (*eth.TxResult, error) { resTxs, err := b.clientCtx.Client.TxSearch(b.ctx, query, false, nil, nil, "") if err != nil { return nil, err @@ -370,7 +370,7 @@ func (b *EVMBackend) queryTendermintTxIndexer(query string, txGetter func(*rpc.P } // GetTransactionByBlockAndIndex is the common code shared by `GetTransactionByBlockNumberAndIndex` and `GetTransactionByBlockHashAndIndex`. -func (b *EVMBackend) GetTransactionByBlockAndIndex(block *tmrpctypes.ResultBlock, idx hexutil.Uint) (*rpc.EthTxJsonRPC, error) { +func (b *Backend) GetTransactionByBlockAndIndex(block *tmrpctypes.ResultBlock, idx hexutil.Uint) (*rpc.EthTxJsonRPC, error) { blockRes, err := b.TendermintBlockResultByNumber(&block.Block.Height) if err != nil { return nil, nil diff --git a/eth/rpc/backend/utils.go b/eth/rpc/backend/utils.go index 90eae9f74..83c128a8e 100644 --- a/eth/rpc/backend/utils.go +++ b/eth/rpc/backend/utils.go @@ -48,7 +48,7 @@ func (s sortGasAndReward) Less(i, j int) bool { // If the pending value is true, it will iterate over the mempool (pending) // txs in order to compute and return the pending tx sequence. // Todo: include the ability to specify a blockNumber -func (b *EVMBackend) getAccountNonce(accAddr common.Address, pending bool, height int64, logger log.Logger) (uint64, error) { +func (b *Backend) getAccountNonce(accAddr common.Address, pending bool, height int64, logger log.Logger) (uint64, error) { queryClient := authtypes.NewQueryClient(b.clientCtx) adr := sdk.AccAddress(accAddr.Bytes()).String() ctx := rpc.NewContextWithHeight(height) @@ -104,7 +104,7 @@ func (b *EVMBackend) getAccountNonce(accAddr common.Address, pending bool, heigh } // output: targetOneFeeHistory -func (b *EVMBackend) processBlock( +func (b *Backend) processBlock( tendermintBlock *tmrpctypes.ResultBlock, ethBlock *map[string]interface{}, rewardPercentiles []float64, diff --git a/x/common/testutil/testnetwork/validator_node.go b/x/common/testutil/testnetwork/validator_node.go index 3e8e0ea3c..bbdb53395 100644 --- a/x/common/testutil/testnetwork/validator_node.go +++ b/x/common/testutil/testnetwork/validator_node.go @@ -86,7 +86,7 @@ type Validator struct { JSONRPCClient *ethclient.Client EthRpcQueryClient *ethrpc.QueryClient - EthRpcBackend *backend.EVMBackend + EthRpcBackend *backend.Backend EthTxIndexer eth.EVMTxIndexer EthRPC_ETH *rpcapi.EthAPI