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

ethclient: handle single state-sync tx in get block calls #1435

Merged
merged 1 commit into from
Feb 5, 2025

Conversation

Leekyungun
Copy link

Refer to previous PR: #1409

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

- Declare zeroAddress as a constant
- If there is only one transaction in the block and the header's txHash is `EmptyTxsHash`, it indicates a state-sync transaction. No error handling is required in this case.
@manav2401 manav2401 changed the title fix: Update transaction validation logic in ethclient(continue pull #1409) ethclient: handle single state-sync transaction in ethclient get block Feb 4, 2025
Copy link
Contributor

@manav2401 manav2401 left a comment

Choose a reason for hiding this comment

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

Thanks a lot, waiting for CI to pass.

@manav2401 manav2401 changed the title ethclient: handle single state-sync transaction in ethclient get block ethclient: handle single state-sync tx in get block calls Feb 4, 2025
@pratikspatil024 pratikspatil024 merged commit 51af82c into maticnetwork:develop Feb 5, 2025
10 checks passed
@Leekyungun
Copy link
Author

It took a long time to apply what was supposed to be a simple fix.
Nonetheless, thank you for helping me up to this point.
This was my first open-source contribution.
Thank you, and I'll upload if I find something else to contribute to next time.

Have nice day

@manav2401
Copy link
Contributor

It took a long time to apply what was supposed to be a simple fix.

It would not be correct to merge half-baked solution which requires more efforts later on from us. Hence, I was suggesting changes to make sure it's done right. Could have done ourselves in a different PR but it's better if feedback is incorporated.

Congrats on your first contribution. Thank you for your efforts.

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.

3 participants