Skip to content

PIP-74: state-sync txs inclusion#42

Merged
marcello33 merged 13 commits intorelease/3.2from
mardizzone/ssTxs-inclusion
Oct 27, 2025
Merged

PIP-74: state-sync txs inclusion#42
marcello33 merged 13 commits intorelease/3.2from
mardizzone/ssTxs-inclusion

Conversation

@marcello33
Copy link

In this PR, we implement the canonical inclusion of state-sync txs in block bodies, as per relative PIP.
This PR reflects the Erigon's changes for this PR in bor:

The PR introduces a new typed system transaction, which is included to blocks that execute StateSync events.
Such txs have zero gas/fees and does not run EVM code, but anchors all StateSync outcomes into the canonical transaction/receipt set. This results in inclusion of such txs into transactionsRoot, receiptsRoot, and logsBloom.

The changes requires a hard fork.

Test worked when enabling StateSync HF from block 0 with the following kurtosis configs

  • parameters:
polygon_pos_package:
  participants:
    - kind: validator
      cl_type: heimdall-v2
      cl_image: 0xpolygon/heimdall-v2:0.3.1
      el_type: erigon
      el_image: 0xpolygon/erigon:v3.0.18-test
      count: 4
    - kind: rpc
      cl_type: heimdall-v2
      cl_image: 0xpolygon/heimdall-v2:0.3.1
      el_type: erigon
      el_image: 0xpolygon/erigon:v3.0.18-test
      count: 2
  additional_services:
    - test_runner
  • erigon genesis
{
 "config": {
   ...
   },
   "bor": {
     "agraBlock": 0,
     "napoliBlock": 0,
     "jaipurBlock": 0,
     "delhiBlock": 0,
     "indoreBlock": 0,
     "ahmedabadBlock": 0,
     "bhilaiBlock": 0,
     "stateSyncBlock": 0,
     ...
}

Receipt was successfully received
image

kamuikatsurgi and others added 2 commits October 15, 2025 14:49
* rlp: fix encoding/decoding of state-sync tx

* chore: add state-sync tx receipt in Finalize

* ssTxs: fix receiptsHash mismatch

* chore: remove block hash and number

* revert: add block number

* fix: rpc fixes

* polygon/sync: announce blocks/hashes for blocks received via hash announcements (#44)

* fix: log slicing in newStateSyncReceipt

---------

Co-authored-by: Manav Darji <manavdarji.india@gmail.com>
@kamuikatsurgi kamuikatsurgi requested a review from Copilot October 24, 2025 10:05
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements canonical inclusion of state-sync transactions in block bodies per the Polygon Improvement Proposal (PIP-74). It introduces a new typed system transaction (StateSyncTxType = 127) that anchors StateSync event outcomes into the canonical transaction/receipt set without consuming gas or executing EVM code. This change requires a hard fork activation.

Key changes:

  • New StateSyncTx transaction type with zero gas/fees that doesn't run EVM code
  • State-sync transactions are included in transactionsRoot, receiptsRoot, and logsBloom
  • Receipt generation for state-sync transactions to maintain canonical chain integrity

Reviewed Changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
polygon/bor/borcfg/bor_config.go Adds StateSyncBlock hard fork configuration and accessor methods
execution/types/state_sync_tx.go Implements the new StateSyncTx transaction type with encoding/decoding logic
execution/types/transaction.go Adds StateSyncTxType constant and decoder support
execution/types/state_data.go Updates StateSyncData.Data field type from string to []byte
polygon/bor/bor.go Implements state-sync transaction and receipt assembly in block finalization
execution/stagedsync/stage_senders.go Skips sender recovery for state-sync transactions
execution/stagedsync/exec3_serial.go Skips execution of state-sync transactions
execution/stagedsync/exec3_parallel.go Handles state-sync transaction logs in parallel execution
rpc/jsonrpc/eth_block.go Conditionally excludes bor transactions post state-sync fork
rpc/ethapi/api.go Handles state-sync transaction serialization without chain ID or access list
execution/chain/chain_config.go Adds state-sync fork check methods
core/vm/evmtypes/rules.go Adds state-sync rules to EVM context

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

kamuikatsurgi and others added 3 commits October 24, 2025 15:37
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@kamuikatsurgi kamuikatsurgi requested a review from Copilot October 27, 2025 05:14
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 21 out of 21 changed files in this pull request and generated 8 comments.

Comments suppressed due to low confidence (1)

polygon/bor/bor.go:1

  • [nitpick] The comment pluralization is inconsistent. 'producers' intervals' should be 'producer intervals' to match the original meaning of delay between two producer turns/intervals.
// Copyright 2024 The Erigon Authors

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: kamuikatsurgi <shahkrishang11@gmail.com>
@marcello33 marcello33 requested a review from a team October 27, 2025 06:58
@manav2401 manav2401 changed the title state-sync txs inclusion PIP-74: state-sync txs inclusion Oct 27, 2025
@marcello33 marcello33 merged commit c14d186 into release/3.2 Oct 27, 2025
9 checks passed
@kamuikatsurgi kamuikatsurgi deleted the mardizzone/ssTxs-inclusion branch October 27, 2025 10:14
kamuikatsurgi added a commit that referenced this pull request Oct 28, 2025
* StateSync txs inclusion

* change pip number

* refactor local cache for last ss data

* test logs

* process state sync txs in serial and parallel executor

* enforce zero effectiveGasPrice on ssTx

* chore: nits

* rlp: fix encoding/decoding of state-sync tx (#43)

* rlp: fix encoding/decoding of state-sync tx

* chore: add state-sync tx receipt in Finalize

* ssTxs: fix receiptsHash mismatch

* chore: remove block hash and number

* revert: add block number

* fix: rpc fixes

* polygon/sync: announce blocks/hashes for blocks received via hash announcements (#44)

* fix: log slicing in newStateSyncReceipt

---------

Co-authored-by: Manav Darji <manavdarji.india@gmail.com>

* chore: remove todo

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* chore: remove todo

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* chore: rename HF to Madhugiri

* chore: nits

* rpc/jsonrpc, txnprovider: state-sync txn handling over rpc post HF (#46)

Co-authored-by: kamuikatsurgi <shahkrishang11@gmail.com>

---------

Co-authored-by: kamuikatsurgi <shahkrishang11@gmail.com>
Co-authored-by: Krishang Shah <109511742+kamuikatsurgi@users.noreply.github.com>
Co-authored-by: Manav Darji <manavdarji.india@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments