From 660c1a304dac1a2e5787d374ff402c83b60a3a91 Mon Sep 17 00:00:00 2001 From: HuangYi Date: Wed, 5 Jan 2022 15:09:54 +0800 Subject: [PATCH 1/3] GetBlock rpc api report wrong gasUsed Closes: #877 Solution: - workaround at rpc side, ignore the gasUsed in such cases. --- rpc/ethereum/backend/backend.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rpc/ethereum/backend/backend.go b/rpc/ethereum/backend/backend.go index 1924f39a4a..bc485e4032 100644 --- a/rpc/ethereum/backend/backend.go +++ b/rpc/ethereum/backend/backend.go @@ -443,6 +443,11 @@ func (e *EVMBackend) EthBlockFromTendermint( gasUsed := uint64(0) for _, txsResult := range txResults { + // workaround for cosmos-sdk bug. https://github.com/tharsis/ethermint/issues/877 + if txsResult.GetCode() == 11 && txsResult.GetLog() == "no block gas left to run tx: out of gas" { + // block gas limit has exceeded, other txs must have failed with same reason. + break + } gasUsed += uint64(txsResult.GetGasUsed()) } From de0a430274cf8ea5b460e18abed0337b8506c82a Mon Sep 17 00:00:00 2001 From: yihuang Date: Wed, 5 Jan 2022 15:17:40 +0800 Subject: [PATCH 2/3] Update rpc/ethereum/backend/backend.go --- rpc/ethereum/backend/backend.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpc/ethereum/backend/backend.go b/rpc/ethereum/backend/backend.go index bc485e4032..16063c770a 100644 --- a/rpc/ethereum/backend/backend.go +++ b/rpc/ethereum/backend/backend.go @@ -443,7 +443,7 @@ func (e *EVMBackend) EthBlockFromTendermint( gasUsed := uint64(0) for _, txsResult := range txResults { - // workaround for cosmos-sdk bug. https://github.com/tharsis/ethermint/issues/877 + // workaround for cosmos-sdk bug. https://github.com/cosmos/cosmos-sdk/issues/10832 if txsResult.GetCode() == 11 && txsResult.GetLog() == "no block gas left to run tx: out of gas" { // block gas limit has exceeded, other txs must have failed with same reason. break From 5f5c3705f1c5b40c7257e58fab83ce41d9ae4a3d Mon Sep 17 00:00:00 2001 From: HuangYi Date: Wed, 5 Jan 2022 15:22:22 +0800 Subject: [PATCH 3/3] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 68a2e2611e..2b64ab2eba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -68,6 +68,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (rpc) [tharsis#860](https://github.com/tharsis/ethermint/pull/860) Fix `eth_getLogs` when specify blockHash without address/topics, and limit the response size. * (rpc) [tharsis#865](https://github.com/tharsis/ethermint/pull/865) Fix RPC Filter parameters being ignored * (evm) [tharsis#871](https://github.com/tharsis/ethermint/pull/871) Set correct nonce in `EthCall` and `EstimateGas` grpc query. +* (rpc) [tharsis#878](https://github.com/tharsis/ethermint/pull/878) Workaround to make GetBlock RPC api report correct block gas used. ## [v0.9.0] - 2021-12-01