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

filter non eth txs in block rpc response #741

Merged
merged 17 commits into from
Nov 16, 2021

Conversation

crypto-facs
Copy link
Contributor

Closes: #705

Description

Right now there is an inconsistency between eth_getBlockByNumber and other RPC endpoints such us eth_getTransactionReceipt or eth_transactionByHashAndIndex.

Get block is returning non EVM txs that can not be found on other endpoints causing web3 tools to experience unexpected failures. This PR ensures there is consistency between the endpoints.


For contributor use:

  • Targeted PR against correct branch (see CONTRIBUTING.md)
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Code follows the module structure standards.
  • Wrote unit and integration tests
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/)
  • Added relevant godoc comments.
  • Added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • Re-reviewed Files changed in the Github PR explorer

For admin use:

  • Added appropriate labels to PR (ex. WIP, R4R, docs, etc)
  • Reviewers assigned
  • Squashed all commits, uses message "Merge pull request #XYZ: [title]" (coding standards)

Copy link
Contributor

@tomtau tomtau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good -- it may be worth checking other Web3 methods though.
e.g. eth_getBlockTransactionCountByNumber is still returning an incorrect number of Ethereum txs (thanks @calvinaco for testing this)

Copy link
Contributor

@fedekunze fedekunze left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK. Pending @tomtau comments to be resolved

@crypto-facs
Copy link
Contributor Author

Took @thomas-nguy additions on crypto's branch to cover the remaining endpoitns. Should be good now

Copy link
Contributor

@fedekunze fedekunze left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to define the assumptions for the index queries, are we assuming the index always corresponds to an ethereum tx? or does it include the other cosmos txs in the block and we should return an error if the tx is not an Ethereum one?

rpc/ethereum/namespaces/eth/api.go Outdated Show resolved Hide resolved
rpc/ethereum/namespaces/eth/api.go Show resolved Hide resolved
@@ -721,7 +714,8 @@ func (e *PublicAPI) GetTransactionByBlockNumberAndIndex(blockNum rpctypes.BlockN
}

i := int(idx)
if i >= len(resBlock.Block.Txs) {
ethMsgs := e.getEthereumMsgFromTendermintBlock(resBlock)
if i >= len(ethMsgs) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

L723 (txBz := resBlock.Block.Txs[i] ) is inconsistent with the L685. See comment about assuming the index corresponds to an ethereum tx

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line 723-730 needs to be removed @crypto-facs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! If we agree this #741 (comment) is the right approach to handle index across the endpoints I will add the filter here too.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok please remove

Copy link
Contributor

@fedekunze fedekunze left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see prev comments

@crypto-facs crypto-facs marked this pull request as draft November 11, 2021 17:57
@crypto-facs
Copy link
Contributor Author

Hey guys so I am seeing another issue. At the moment the index returned by the transactionReceipt is out of sync with the other indexes. for example if txIndex on transactionReceipt is 0x3 that does not guarantee that if you query eth_getTransactionByBlockHashAndIndex that transaction index is going to be found.

It might be wise to work on the integratoin tests and have them check this scenarios before we move forward with this. Because there are many scenarios to cover.

@crypto-facs crypto-facs marked this pull request as ready for review November 16, 2021 01:03
Copy link
Contributor

@tomtau tomtau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks all right -- backend.go just needs to be formatted with gofumpt

@tomtau
Copy link
Contributor

tomtau commented Nov 16, 2021

I assume the solidity test failing is unrelated: https://github.com/tharsis/ethermint/runs/4219178563?check_suite_focus=true

Copy link
Contributor

@fedekunze fedekunze left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, pending minor comments and lint fixes

rpc/ethereum/backend/backend.go Outdated Show resolved Hide resolved
rpc/ethereum/namespaces/eth/api.go Outdated Show resolved Hide resolved
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Problem: tx index is incorrect when there's failed tx in block
4 participants