Skip to content

Conversation

manav2401
Copy link
Member

@manav2401 manav2401 commented Aug 18, 2025

Description

This PR adds the ability to send state-sync transaction receipts (or bor receipts in short) in eth/69 protocol (which is newly added from upstream). This will allow nodes using snap sync to persist the state-sync transaction receipts (as there's no execution involved in snap sync and hence they're not generated locally).

This PR changes the implementation of 2 p2p messages:

  • GetReceiptsMsg (code: 0x0f): Fetches bor receipts for requested blocks and include them in the final encoded message
  • ReceiptsMsg (code: 0x10): Accepts the bor receipts from incoming p2p packet. They are excluded from receipt root (in header) and hence this needs to be taken care of while handling incoming receipts.

Moreover, this PR also changes how receipts are handled in InsertReceiptChain function which didn't handle bor receipts earlier. Bor receipts can be identified by their 0 gas used field. Upon insertion, as they're stored separately from normal block receipts, they need to be extracted from the encoded packet which is handled in this PR.

Note that this change is forward compatible and allows to do a hard fork in future where we include bor receipts as a part of receipt root without any p2p changes.

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

Please complete this section if any breaking changes have been made, otherwise delete it

Nodes audience

In case this PR includes changes that must be applied only to a subset of nodes, please specify how you handled it (e.g. by adding a flag with a default value...)

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 amoy
  • I have created new e2e tests into express-cli

Manual tests

Please complete this section with the steps you performed if you ran manual tests for this functionality, otherwise delete it

Additional comments

Please post additional comments in this section if you have them, otherwise delete it

@manav2401 manav2401 changed the title Manav/state sync receipts in snap sync eth, core: handle state-sync data in eth/69 messages Aug 18, 2025
@manav2401 manav2401 marked this pull request as ready for review August 27, 2025 13:46
Comment on lines +12 to +15
borReceiptsCacheHit = metrics.NewRegisteredGauge("bor/receipts/cache/hit", nil)
borReceiptsCacheMiss = metrics.NewRegisteredGauge("bor/receipts/cache/miss", nil)
borReceiptsRLPCacheHit = metrics.NewRegisteredGauge("bor/rlpreceipts/cache/hit", nil)
borReceiptsRLPCacheMiss = metrics.NewRegisteredGauge("bor/rlpreceipts/cache/miss", nil)
Copy link
Member Author

Choose a reason for hiding this comment

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

These metrics have been added to see the hit/miss ratio. For normal receipts, they've been removed from upstream. If the ratio is bad, probably worth removing for bor receipts as well.

if header.EmptyReceipts() && !isSprintEndBlock(borCfg, header.Number.Uint64()) {
fetchReceipts = false
}
if syncMode == SnapSync && fetchReceipts {
Copy link
Member Author

Choose a reason for hiding this comment

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

Will be writing a new test around this change.

Copy link

sonarqubecloud bot commented Oct 3, 2025

Quality Gate Failed Quality Gate failed

Failed conditions
7.7% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

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