Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

Commit

Permalink
Fix get block (#781)
Browse files Browse the repository at this point in the history
  • Loading branch information
crypto-facs authored Nov 26, 2021
1 parent c8d4d3f commit bfe059e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

* (feemarket) [tharsis#770](https://github.com/tharsis/ethermint/pull/770) Enable fee market (EIP1559) by default.
* (rpc) [tharsis#769](https://github.com/tharsis/ethermint/pull/769) Fix default Ethereum signer for JSON-RPC.
* (rpc) [tharsis#781](https://github.com/tharsis/ethermint/pull/781) Fix get block invalid transactions filter.
* (rpc) [tharsis#782](https://github.com/tharsis/ethermint/pull/782) Fix wrong block gas limit returned by JSON-RPC.

## [v0.8.0] - 2021-11-17
Expand Down
22 changes: 11 additions & 11 deletions rpc/ethereum/backend/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,13 @@ func (e *EVMBackend) EthBlockFromTendermint(
return nil, err
}

resBlockResult, err := e.clientCtx.Client.BlockResults(ctx, &block.Height)
if err != nil {
return nil, err
}

txResults := resBlockResult.TxsResults

for i, txBz := range block.Txs {
tx, err := e.clientCtx.TxConfig.TxDecoder()(txBz)
if err != nil {
Expand All @@ -375,10 +382,9 @@ func (e *EVMBackend) EthBlockFromTendermint(

tx := ethMsg.AsTransaction()

// check tx exists on EVM and it has the correct block height
ethTx, err := e.GetTxByEthHash(tx.Hash())
if err != nil || ethTx.Height != block.Height {
e.logger.Debug("failed to query eth tx", "hash", tx.Hash().Hex())
// check tx exists on EVM by cross checking with blockResults
if txResults[i].Code != 0 {
e.logger.Debug("invalid tx result code", "hash", tx.Hash().Hex())
continue
}

Expand Down Expand Up @@ -435,15 +441,9 @@ func (e *EVMBackend) EthBlockFromTendermint(
e.logger.Error("failed to query consensus params", "error", err.Error())
}

resBlockResult, err := e.clientCtx.Client.BlockResults(e.ctx, &block.Height)
if err != nil {
e.logger.Debug("EthBlockFromTendermint block result not found", "height", block.Height, "error", err.Error())
return nil, err
}

gasUsed := uint64(0)

for _, txsResult := range resBlockResult.TxsResults {
for _, txsResult := range txResults {
gasUsed += uint64(txsResult.GetGasUsed())
}

Expand Down

0 comments on commit bfe059e

Please sign in to comment.