Skip to content

Commit

Permalink
fix: GetBlock rpc api reports wrong gasUsed (backport 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 committed Feb 23, 2022
1 parent 8fe755d commit 80536af
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 1 addition & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,8 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (rpc) [crypto-org-chain#42](https://github.com/crypto-org-chain/ethermint/pull/42) Fix `eth_getLogs` when specify blockHash without address/topics, and limit the response size.
* (rpc) [tharsis#933](https://github.com/tharsis/ethermint/pull/933) Fix newPendingTransactions subscription deadlock when a Websocket client exits without unsubscribing and the node errors. (backport: #933)

### Bug Fixes

- (rpc) [tharsis#900](https://github.com/tharsis/ethermint/pull/900) newPendingTransactions filter should return ethereum tx hash.
- (rpc) [tharsis#878](https://github.com/tharsis/ethermint/pull/878) Workaround to make GetBlock RPC api report correct block gas used.

## [v0.7.2-cronos-6] - 2021-12-17

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 @@ -343,6 +343,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 80536af

Please sign in to comment.