Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Update transaction validation logic in ethclient #1409

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Leekyungun
Copy link

Description

This PR resolves an issue where blocks containing system transactions could not be retrieved properly using getBlock.
For such blocks, the transactionsRoot is set to EmptyTxsHash, but the Transactions list contains one transaction, which leads to a mismatch and prevents block information from being retrieved.
The validation logic has been updated to handle these cases correctly.
Example block with system transaction: https://amoy.polygonscan.com/block/16653120

Changes

  • Bugfix (non-breaking change that solves an issue)
  • Hotfix (change that solves an urgent issue, and requires immediate attention)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (change that is not backwards-compatible and/or changes current functionality)
  • Changes only for a subset of nodes

Breaking changes

No breaking changes have been introduced in this PR.

Nodes audience

This PR affects all nodes and does not include changes limited to a subset of nodes.

Checklist

  • I have added at least 2 reviewer or the whole pos-v1 team
  • I have added sufficient documentation in code
  • I will be resolving comments - if any - by pushing each fix in a separate commit and linking the commit hash in the comment reply
  • Created a task in Jira and informed the team for implementation in Erigon client (if applicable)
  • Includes RPC methods changes, and the Notion documentation has been updated

Cross repository changes

  • This PR requires changes to heimdall
    • In case link the PR here:
  • This PR requires changes to matic-cli
    • In case link the PR here:

Testing

  • I have added unit tests
  • I have added tests to CI
  • I have tested this code manually on local environment
  • I have tested this code manually on remote devnet using express-cli
  • I have tested this code manually on mumbai/amoy
  • I have created new e2e tests into express-cli

Manual tests

  1. Retrieved a block with system transactions (transactionsRoot as EmptyTxsHash but including Transactions).
  2. Verified that block information is now retrieved correctly without validation errors.
  3. Confirmed that other blocks without system transactions remain unaffected.

Additional comments

See the example block for context:
https://amoy.polygonscan.com/block/16653120

- Resolved an issue where blocks containing system transactions could not be fetched correctly.
- The `transactionsRoot` of such blocks is set to `EmptyTxsHash`, but the `Transactions` list contains one transaction, causing a mismatch.
- Updated validation to properly handle these cases.

Reference:
Example block with system transaction: https://amoy.polygonscan.com/block/16653120
@manav2401
Copy link
Contributor

Hi, thanks for raising this PR. The issues seems correct that it will happen when there's only 1 transaction which is a state-sync (system) transaction and nothing else.

But, IMO, we shouldn't get rid of the error. Let me see if there's some way to find out if it's a state-sync tx or not.

@manav2401
Copy link
Contributor

Hi @Leekyungun, can you update the PR to handle this specific condition explicitly instead of removing this check?

Basically, system transactions are directly applied on state and hence the TxHash field in header is unaffected (EmptyTxsHash in this case). Can you add a check to match the to and from fields of the only transaction. If it's 0x00..00, then it's indeed a system transaction and we can skip this check in that case. If it's not, this check should be applied.

Also, could you raise the PR against develop branch instead? Lmk if you're upto do this. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants