From 5c80a5528740a154237e2f7a00d1392eea3353bb Mon Sep 17 00:00:00 2001 From: Ramiro Carlucho Date: Sat, 17 Sep 2022 08:57:58 +0100 Subject: [PATCH] fix(rpc): estimate gas error response (#1340) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * format error on EstimateGas rpc call * changelog Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com> --- CHANGELOG.md | 1 + rpc/backend/call_tx.go | 6 ++++++ tests/integration_tests/test_types.py | 2 ++ 3 files changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 87a11b20..aa4afd65 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -63,6 +63,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (rpc) [#1179](https://github.com/evmos/ethermint/pull/1179) Fix gas used in traceTransaction response. * (rpc) [#1284](https://github.com/evmos/ethermint/pull/1284) Fix internal trace response upon incomplete `eth_sendTransaction` call. +* (rpc) [#1340](https://github.com/evmos/ethermint/pull/1340) Fix error response when `eth_estimateGas` height provided is not found. ## [v0.19.2] - 2022-08-29 diff --git a/rpc/backend/call_tx.go b/rpc/backend/call_tx.go index 96932f92..44b027b7 100644 --- a/rpc/backend/call_tx.go +++ b/rpc/backend/call_tx.go @@ -303,6 +303,12 @@ func (b *Backend) EstimateGas(args evmtypes.TransactionArgs, blockNrOptional *rp GasCap: b.RPCGasCap(), } + _, err = b.TendermintBlockByNumber(blockNr) + if err != nil { + // the error message imitates geth behavior + return 0, errors.New("header not found") + } + // From ContextWithHeight: if the provided height is 0, // it will return an empty context and the gRPC query will use // the latest block height for querying. diff --git a/tests/integration_tests/test_types.py b/tests/integration_tests/test_types.py index afc9dd96..0318317d 100644 --- a/tests/integration_tests/test_types.py +++ b/tests/integration_tests/test_types.py @@ -313,6 +313,8 @@ def test_estimate_gas(ethermint, geth): eth_rpc = ethermint.w3.provider geth_rpc = geth.w3.provider make_same_rpc_calls(eth_rpc, geth_rpc, "eth_estimateGas", [tx]) + make_same_rpc_calls(eth_rpc, geth_rpc, "eth_estimateGas", [tx, "0x0"]) + make_same_rpc_calls(eth_rpc, geth_rpc, "eth_estimateGas", [tx, "0x5000"]) make_same_rpc_calls(eth_rpc, geth_rpc, "eth_estimateGas", [{}])