Skip to content

Conversation

@manav2401
Copy link
Member

@manav2401 manav2401 commented Oct 15, 2025

Description

After the state-sync HF, state-sync (or bor) transactions will be part of block body and bor receipts will also be stored along with normal block receipts (i.e. under same key). This PR does some changes around handling receipts via p2p after the HF. Note that it only affects nodes syncing via snap syncing (which is disabled until this HF goes through).

  • Separate pre and post HF logic for serving GetReceipts query -- pre HF, normal and bor receipts are fetched separately and later merged and encoded. Post HF, they can be fetched in single call and encoding is relatively easier.
  • Changes in ReceiptRoot calculation -- currently, state-sync receipts are excluded but post-HF, they should be part of receipt root. As we don't have access to block number (to check if we're cross HF or not), this change can't be implemented directly in handler. The encoded packet is sent ahead until the point we have access to header.
  • Skip splitting receipts (into normal and state-sync) when inserting in InsertReceiptChain.
  • Extends a small e2e test to confirm if bor receipts are stored in block and are available with normal block data.

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 eth: include bor receipts in ReceiptHash post HF eth: fixes in receipt handling via p2p post HF Oct 19, 2025
@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

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

See analysis details on SonarQube Cloud

@lucca30 lucca30 merged commit be7f430 into lmartins/state-sync-txs-on-block-body Oct 20, 2025
6 of 8 checks passed
manav2401 added a commit that referenced this pull request Oct 30, 2025
* first working version of new state sync tx

* remove logs

* fix lint

* fix integration tests

* test fixes

* lint fix

* fix parallel processor

* type improvement and unit tests

* remove duplicates

* ignore data test output

* fixing method calls and fields

* build fix

* remove bor filter for after hf blocks

* sort logs just when necessary

* ssTxs: fix receiptsHash mismatch (#1829)

* ssTxs: fix receiptsHash mismatch

* chore: remove block hash and number

* revert: add block number

* core(tx): fix Hash method for StateSyncTxType (#1830)

* eth: fixes in receipt handling via p2p post HF (#1825)

* eth: include bor receipts in ReceiptHash post HF

* eth: rename to receiptListHash

* eth: extrat typecasting logic for better testing, fix type matching issue

* eth: add e2e tests for receipt delivery

* eth/protocols/eth: apply HF logic while handling receipt query over eth69

* core: skip split receipts post HF

* tests/bor: extend e2e test to check presence of state-sync in block

* core/types: return nil for chainID() call over state-sync tx

* internal/ethapi: handle bor txs and receipts post HF (#1834)

* fix: cumulativeGasUsed in insertStateSyncTransactionAndCalculateReceipt (#1835)

* fix: sort logs and remove duplicate append in Finalize (#1836)

* fix: append tx only in FinalizeAndAssemble and use state instead of wrappedState

* consensus/bor: sort logs before extracting state-sync logs

* chore: revert statedb changes

---------

Co-authored-by: Manav Darji <[email protected]>

* chore: nit (#1838)

* chore: typos

* fix: lint

* Renaming to Madhugiri HF

* chore: nits

* (fix): handle pointers to receipt list received via p2p

* (chore): rename tests with HF name

* chore: more nits

* core: add blocktime in bor receipt logs (#1848)

* core/types: derive bloom for bor receipts

---------

Co-authored-by: kamuikatsurgi <[email protected]>
Co-authored-by: Krishang Shah <[email protected]>
Co-authored-by: Manav Darji <[email protected]>
manav2401 added a commit that referenced this pull request Oct 30, 2025
…1842)

* first working version of new state sync tx

* remove logs

* fix lint

* fix integration tests

* test fixes

* lint fix

* fix parallel processor

* type improvement and unit tests

* remove duplicates

* ignore data test output

* fixing method calls and fields

* build fix

* remove bor filter for after hf blocks

* sort logs just when necessary

* ssTxs: fix receiptsHash mismatch (#1829)

* ssTxs: fix receiptsHash mismatch

* chore: remove block hash and number

* revert: add block number

* core(tx): fix Hash method for StateSyncTxType (#1830)

* eth: fixes in receipt handling via p2p post HF (#1825)

* eth: include bor receipts in ReceiptHash post HF

* eth: rename to receiptListHash

* eth: extrat typecasting logic for better testing, fix type matching issue

* eth: add e2e tests for receipt delivery

* eth/protocols/eth: apply HF logic while handling receipt query over eth69

* core: skip split receipts post HF

* tests/bor: extend e2e test to check presence of state-sync in block

* core/types: return nil for chainID() call over state-sync tx

* internal/ethapi: handle bor txs and receipts post HF (#1834)

* fix: cumulativeGasUsed in insertStateSyncTransactionAndCalculateReceipt (#1835)

* fix: sort logs and remove duplicate append in Finalize (#1836)

* fix: append tx only in FinalizeAndAssemble and use state instead of wrappedState

* consensus/bor: sort logs before extracting state-sync logs

* chore: revert statedb changes

---------

Co-authored-by: Manav Darji <[email protected]>

* chore: nit (#1838)

* chore: typos

* fix: lint

* Renaming to Madhugiri HF

* chore: nits

* (fix): handle pointers to receipt list received via p2p

* (chore): rename tests with HF name

* chore: more nits

* core: implement eip7883

* core: implement eip7825

* fix lint

* fix isOsaka condition

* fix lint and add comment for int test failing

* fix failing test / address comments

* core: add blocktime in bor receipt logs (#1848)

* core/types: derive bloom for bor receipts

* prioritize ss hf / remove todo

* fix lint

* split precompiled contracts and addresses for madhugiri HF from osaka

* revert err msg to align with geth

* eth/gasestimator: check ErrGasLimitTooHigh conditions (#32348)

This PR makes 2 changes to how
[EIP-7825](ethereum/go-ethereum#31824) behaves.

When `eth_estimateGas` or `eth_createAccessList` is called without any
gas limit in the payload, geth will choose the block's gas limit or the
`RPCGasCap`, which can be larger than the `maxTxGas`.

When this happens for `estimateGas`, the gas estimation just errors out
and ends, when it should continue doing binary search to find the lowest
possible gas limit.

This PR will: 
- Add a check to see if `hi` is larger than `maxTxGas` and cap it to
`maxTxGas` if it's larger. And add a special case handling for gas
estimation execute when it errs with `ErrGasLimitTooHigh`

---------

Co-authored-by: Gary Rong <[email protected]>

* internal/ethapi: skip tx gas limit check for calls (#32641)

This disables the tx gaslimit cap for eth_call and related RPC operations.

I don't like how this fix works. Ideally we'd be checking the tx
gaslimit somewhere else, like in the block validator, or any other place
that considers block transactions. Doing the check in StateTransition
means it affects all possible ways of executing a message.

The challenge is finding a place for this check that also triggers
correctly in tests where it is wanted. So for now, we are just combining
this with the EOA sender check for transactions. Both are disabled for
call-type messages.

* internal/ethapi: use gas from gaspool for call defaults

* eth/gasestimator: check for madhugiri HF

* consensus/bor: honour MaxTxGas for system calls

---------

Co-authored-by: Lucca Martins <[email protected]>
Co-authored-by: kamuikatsurgi <[email protected]>
Co-authored-by: Krishang Shah <[email protected]>
Co-authored-by: Manav Darji <[email protected]>
Co-authored-by: Minhyuk Kim <[email protected]>
Co-authored-by: Gary Rong <[email protected]>
Co-authored-by: Felix Lange <[email protected]>
manav2401 added a commit that referenced this pull request Oct 30, 2025
…block time (#1851)

* first working version of new state sync tx

* remove logs

* fix lint

* fix integration tests

* test fixes

* lint fix

* fix parallel processor

* type improvement and unit tests

* remove duplicates

* ignore data test output

* fixing method calls and fields

* build fix

* remove bor filter for after hf blocks

* sort logs just when necessary

* ssTxs: fix receiptsHash mismatch (#1829)

* ssTxs: fix receiptsHash mismatch

* chore: remove block hash and number

* revert: add block number

* core(tx): fix Hash method for StateSyncTxType (#1830)

* eth: fixes in receipt handling via p2p post HF (#1825)

* eth: include bor receipts in ReceiptHash post HF

* eth: rename to receiptListHash

* eth: extrat typecasting logic for better testing, fix type matching issue

* eth: add e2e tests for receipt delivery

* eth/protocols/eth: apply HF logic while handling receipt query over eth69

* core: skip split receipts post HF

* tests/bor: extend e2e test to check presence of state-sync in block

* core/types: return nil for chainID() call over state-sync tx

* internal/ethapi: handle bor txs and receipts post HF (#1834)

* fix: cumulativeGasUsed in insertStateSyncTransactionAndCalculateReceipt (#1835)

* fix: sort logs and remove duplicate append in Finalize (#1836)

* fix: append tx only in FinalizeAndAssemble and use state instead of wrappedState

* consensus/bor: sort logs before extracting state-sync logs

* chore: revert statedb changes

---------

Co-authored-by: Manav Darji <[email protected]>

* chore: nit (#1838)

* chore: typos

* fix: lint

* Renaming to Madhugiri HF

* chore: nits

* (fix): handle pointers to receipt list received via p2p

* (chore): rename tests with HF name

* chore: more nits

* core: add blocktime in bor receipt logs (#1848)

* core/types: derive bloom for bor receipts

* (chore): update madhugiri block for amoy

* Change consensus block time to 1s at Madhugiri HF (#1852)

---------

Co-authored-by: Lucca Martins <[email protected]>
Co-authored-by: kamuikatsurgi <[email protected]>
Co-authored-by: Krishang Shah <[email protected]>
Co-authored-by: Jerry <[email protected]>
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.

4 participants