Skip to content

Commit

Permalink
fix: GetBlock rpc api reports wrong gasUsed (evmos#878)
Browse files Browse the repository at this point in the history
* GetBlock rpc api report wrong gasUsed

Closes: evmos#877

Solution:
- workaround at rpc side, ignore the gasUsed in such cases.

* Update rpc/ethereum/backend/backend.go

* changelog
  • Loading branch information
yihuang authored Jan 5, 2022
1 parent 03768c2 commit e9f1ab6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 5 additions & 0 deletions rpc/ethereum/backend/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,11 @@ func (e *EVMBackend) EthBlockFromTendermint(
gasUsed := uint64(0)

for _, txsResult := range txResults {
// 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
}
gasUsed += uint64(txsResult.GetGasUsed())
}

Expand Down

0 comments on commit e9f1ab6

Please sign in to comment.