From d359cbd9c9f936afd43283cda68a8b4f02333747 Mon Sep 17 00:00:00 2001 From: yihuang Date: Thu, 19 May 2022 14:48:37 +0800 Subject: [PATCH] fix: gas price value in `eth_getTransaction` JSON-RPC response (#1082) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Solution: - pass the correct baseFee parameter Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com> --- CHANGELOG.md | 4 ++++ rpc/backend/evm_backend.go | 9 +++++++-- rpc/namespaces/ethereum/eth/api.go | 9 +++++++-- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e1bc91612..c944b8982d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,10 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (cli) [tharsis#1086](https://github.com/tharsis/ethermint/pull/1086) Add rollback command. +### Bug Fixes + +* (rpc) [tharsis#1082](https://github.com/tharsis/ethermint/pull/1082) fix gas price returned in getTransaction api. + ## [v0.15.0] - 2022-05-09 ### State Machine Breaking diff --git a/rpc/backend/evm_backend.go b/rpc/backend/evm_backend.go index 619afd1bc5..c622961bcf 100644 --- a/rpc/backend/evm_backend.go +++ b/rpc/backend/evm_backend.go @@ -586,7 +586,7 @@ func (b *Backend) GetTransactionByHash(txHash common.Hash) (*types.RPCTransactio common.Hash{}, uint64(0), uint64(0), - b.chainID, + nil, ) if err != nil { return nil, err @@ -649,12 +649,17 @@ func (b *Backend) GetTransactionByHash(txHash common.Hash) (*types.RPCTransactio return nil, errors.New("can't find index of ethereum tx") } + baseFee, err := b.BaseFee(block.Block.Height) + if err != nil { + return nil, err + } + return types.NewTransactionFromMsg( msg, common.BytesToHash(block.BlockID.Hash.Bytes()), uint64(res.Height), txIndex, - b.chainID, + baseFee, ) } diff --git a/rpc/namespaces/ethereum/eth/api.go b/rpc/namespaces/ethereum/eth/api.go index 625739e97c..7e5b100fa7 100644 --- a/rpc/namespaces/ethereum/eth/api.go +++ b/rpc/namespaces/ethereum/eth/api.go @@ -764,12 +764,17 @@ func (e *PublicAPI) getTransactionByBlockAndIndex(block *tmrpctypes.ResultBlock, msg = ethMsgs[i] } + baseFee, err := e.backend.BaseFee(block.Block.Height) + if err != nil { + return nil, err + } + return rpctypes.NewTransactionFromMsg( msg, common.BytesToHash(block.Block.Hash()), uint64(block.Block.Height), uint64(idx), - e.chainIDEpoch, + baseFee, ) } @@ -983,7 +988,7 @@ func (e *PublicAPI) GetPendingTransactions() ([]*rpctypes.RPCTransaction, error) common.Hash{}, uint64(0), uint64(0), - e.chainIDEpoch, + nil, ) if err != nil { return nil, err