diff --git a/CHANGELOG.md b/CHANGELOG.md index 15213703..82c882c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/rpc/ethereum/backend/backend.go b/rpc/ethereum/backend/backend.go index 908dd9b2..1e18ff35 100644 --- a/rpc/ethereum/backend/backend.go +++ b/rpc/ethereum/backend/backend.go @@ -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 { @@ -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 } @@ -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()) }