Fix get block (#781)

This commit is contained in:
crypto-facs 2021-11-26 13:10:40 -05:00 committed by GitHub
parent c8d4d3f9a3
commit bfe059e43e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 11 deletions

View File

@ -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

View File

@ -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())
}