Skip to content

Commit

Permalink
fix: merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
Unique-Divine committed Sep 15, 2024
1 parent f2aea94 commit f9ef4ee
Show file tree
Hide file tree
Showing 11 changed files with 70 additions and 70 deletions.
10 changes: 5 additions & 5 deletions eth/rpc/backend/account_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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) {
Expand Down Expand Up @@ -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 {
Expand Down
36 changes: 18 additions & 18 deletions eth/rpc/backend/blocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand All @@ -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())
Expand All @@ -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
Expand All @@ -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.
Expand All @@ -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")
Expand All @@ -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")
Expand All @@ -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")
Expand All @@ -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
Expand All @@ -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 {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand All @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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) {
Expand Down
12 changes: 6 additions & 6 deletions eth/rpc/backend/call_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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")
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions eth/rpc/backend/chain_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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")
Expand All @@ -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
Expand Down Expand Up @@ -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
}
Expand All @@ -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
}
6 changes: 3 additions & 3 deletions eth/rpc/backend/filters.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand All @@ -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
Expand Down
Loading

0 comments on commit f9ef4ee

Please sign in to comment.