From 1af2a7529ef7db618b902b3dfed2e5a447de85a0 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 | 1 + rpc/ethereum/backend/backend.go | 4 ++-- rpc/ethereum/namespaces/eth/api.go | 9 +++++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9861b45ba6..f6f318408e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Bug Fixes * (rpc) [tharsis#1059](https://github.com/tharsis/ethermint/pull/1059) Remove unnecessary event filtering logic on the `eth_baseFee` JSON-RPC endpoint. +* (rpc) [tharsis#1082](https://github.com/tharsis/ethermint/pull/1082) fix gas price returned in getTransaction api. ### API Breaking diff --git a/rpc/ethereum/backend/backend.go b/rpc/ethereum/backend/backend.go index 567f4e56ca..706147f36d 100644 --- a/rpc/ethereum/backend/backend.go +++ b/rpc/ethereum/backend/backend.go @@ -666,7 +666,7 @@ func (e *EVMBackend) GetTransactionByHash(txHash common.Hash) (*types.RPCTransac common.Hash{}, uint64(0), uint64(0), - e.chainID, + nil, ) if err != nil { return nil, err @@ -734,7 +734,7 @@ func (e *EVMBackend) GetTransactionByHash(txHash common.Hash) (*types.RPCTransac common.BytesToHash(block.BlockID.Hash.Bytes()), uint64(res.Height), txIndex, - e.chainID, + nil, ) } diff --git a/rpc/ethereum/namespaces/eth/api.go b/rpc/ethereum/namespaces/eth/api.go index 1667d7913e..768c58eda1 100644 --- a/rpc/ethereum/namespaces/eth/api.go +++ b/rpc/ethereum/namespaces/eth/api.go @@ -733,12 +733,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, ) } @@ -952,7 +957,7 @@ func (e *PublicAPI) GetPendingTransactions() ([]*rpctypes.RPCTransaction, error) common.Hash{}, uint64(0), uint64(0), - e.chainIDEpoch, + nil, ) if err != nil { return nil, err