Skip to content
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
8bd82f9
Initial delayed SRC PoC
cffls Feb 26, 2026
b232538
Merge branch 'develop' of github.com:0xPolygon/bor into delay_src
pratikspatil024 Mar 27, 2026
d63daed
miner, core, consensus/bor: pipelined state root computation (PoC)
pratikspatil024 Mar 30, 2026
ceca519
miner: run speculative fillTransactions concurrently with SRC and rem…
pratikspatil024 Apr 1, 2026
3dcdf80
miner: async DB write, concurrent fill, and interrupt timer improvements
pratikspatil024 Apr 1, 2026
07345ad
llint fix
pratikspatil024 Apr 1, 2026
a86db50
addressed comments and fix test, lint
pratikspatil024 Apr 2, 2026
8d5ed1b
core/stateless: (fix unit test) fix NewWitness zeroing breaking witne…
pratikspatil024 Apr 2, 2026
0e2da86
core, consensus/bor, eth, triedb: pipelined state root computation fo…
pratikspatil024 Apr 9, 2026
b283227
tests/bor: add pipelined import SRC self-destruct integration test
pratikspatil024 Apr 10, 2026
acc0ef7
core/state, triedb/pathdb: fix prefetcher race during pipelined SRC
pratikspatil024 Apr 10, 2026
5d45f02
miner, consensus/bor, core, eth: harden pipelined SRC abort handling
pratikspatil024 Apr 16, 2026
46e9ea4
core, miner, core/state: added metrics for pipelined SRC
pratikspatil024 Apr 21, 2026
caac30e
core, core/state, eth, tests/bor, miner: refactor pipelined-src funct…
pratikspatil024 Apr 22, 2026
d2d6641
core, core/txpool, miner: PR review fixes + pipelined import hardening
pratikspatil024 Apr 23, 2026
946f137
core: added metrics for preloadFlatDiffReads in pipelined SRC
pratikspatil024 Apr 28, 2026
d00791d
core: added metrics - cheap exec and auto-collection phases for pipel…
pratikspatil024 Apr 28, 2026
68e80ac
core: stop execution prefetcher in pipelined import path
pratikspatil024 Apr 30, 2026
8ef3578
core, miner: honour producewitnesses in pipelined import SRC path
pratikspatil024 May 1, 2026
bbaa0d6
core: use multi-reader StateDB on pipelined SRC witness-off path
pratikspatil024 May 4, 2026
fcab1bc
core, core/stateless, miner: share execution witness with pipelined SRC
pratikspatil024 May 5, 2026
ecf6ebf
core, core/state, eth, internal/cli, miner: add warm-snapshot handoff…
pratikspatil024 May 5, 2026
d9e22cd
core/state: use warm snapshot for SRC commit trie opens
pratikspatil024 May 6, 2026
696c3c1
core, core/state: add import phase observability
pratikspatil024 May 6, 2026
1bf3f2b
core, core/state: split pipelined prefetch-stop observability
pratikspatil024 May 6, 2026
e68753e
core, core/state: build warm snapshot inside SRC goroutine
pratikspatil024 May 7, 2026
8a24f4e
core/state: make pipelined SRC prefetch stop snapshot-fast
pratikspatil024 May 7, 2026
665746d
core/state: bound snapshot-fast prefetch drain latency
pratikspatil024 May 7, 2026
1d304ca
core, core/state, miner: detach import prefetcher for SRC
pratikspatil024 May 9, 2026
b5f9c0e
consensus, miner: restore Bor early block announcement timing
pratikspatil024 May 13, 2026
4971d12
miner, cli: disable production pipelined SRC
pratikspatil024 May 14, 2026
732cc8b
Merge branch 'develop' of github.com:0xPolygon/bor into pipelined-src…
pratikspatil024 May 20, 2026
c58155c
miner: preserve disabled pipeline behavior
pratikspatil024 May 20, 2026
1f9419a
miner: snapshot pipeline eligibility for cleanup
pratikspatil024 May 20, 2026
d4c7d04
core, state: merge pipelined SRC with BlockSTM v2
pratikspatil024 May 20, 2026
91a2e37
core/state: skip invalid FlatDiff storage prefetch roots
pratikspatil024 May 21, 2026
a8faaaa
Merge remote-tracking branch 'origin/blockstm_redesign' into pipeline…
pratikspatil024 May 21, 2026
c52abe2
core/state: fix V2 FlatDiff storage prefetch roots
pratikspatil024 May 21, 2026
2663f1f
core: expand pipelined import post-exec metrics
pratikspatil024 May 21, 2026
52b0e3a
Merge branch 'pipelined-src' into pipelinedsrc-and-blockstmv2
pratikspatil024 May 21, 2026
7db144e
Merge branch 'blockstm_redesign' of github.com:0xPolygon/bor into pip…
pratikspatil024 May 26, 2026
ef692db
core: log pipelined import mode on V2 failures
pratikspatil024 May 26, 2026
279437a
eth: mask pipelined head state sync checks
pratikspatil024 May 26, 2026
1debaa3
core/state: prioritize FlatDiff in SafeBase reads
pratikspatil024 May 28, 2026
403f268
core/state: apply FlatDiff to SafeBase account reads
pratikspatil024 May 28, 2026
72e2078
core/state: fail V2 on SafeBase read errors
pratikspatil024 May 28, 2026
2a73a8b
core/state: keep SafeBase FlatDiff-agnostic
pratikspatil024 May 29, 2026
1c39714
Merge remote-tracking branch 'origin/develop' into pipelinedsrc-and-b…
pratikspatil024 Jun 11, 2026
a21ee56
Merge pipelinedsrc-and-blockstmv2 into pipelined-src
pratikspatil024 Jun 17, 2026
8a20f42
core: instrument pipelined SRC overlap
pratikspatil024 Jun 18, 2026
2cd62cf
Optimize witness-off pipelined SRC import
pratikspatil024 Jun 26, 2026
02cbd94
core, core/state: carry committed SRC nodes to the next pipelined SRC
pratikspatil024 Jul 10, 2026
7f076aa
core, core/state: retain recent SRC commit nodes in a bounded warm ring
pratikspatil024 Jul 11, 2026
b79bee7
core, eth, internal/cli: allow disabling exec prefetchers on pipeline…
pratikspatil024 Jul 14, 2026
dc98f7c
docs: regenerate CLI docs
pratikspatil024 Jul 14, 2026
575c945
core, eth, internal/cli: scope exec-prefetch flag to the trie prefetcher
pratikspatil024 Jul 14, 2026
eee9fac
triedb/pathdb: index diff-layer trie nodes for direct lookup
pratikspatil024 Jul 14, 2026
ed87a6f
core, state: remove the witness-off SRC warm node ring
pratikspatil024 Jul 16, 2026
02c01db
core: skip exec trie prefetcher when nothing consumes it in witness mode
pratikspatil024 Jul 20, 2026
3048e2b
core, state: let V2 honor the caller's trie-prefetch decision
pratikspatil024 Jul 21, 2026
2087fd7
core, eth, internal/cli: drop the pipeline.exec-prefetch flag
pratikspatil024 Jul 21, 2026
891e450
Merge remote-tracking branch 'origin/develop' into pipelined-src-merge
pratikspatil024 Jul 21, 2026
dc3c343
core, eth: lint cleanup after exec-prefetch removal and develop merge
pratikspatil024 Jul 21, 2026
34ae33c
core, internal/cli, tests: address review findings and deflake peering
pratikspatil024 Jul 21, 2026
874d5d9
core, eth, internal/ethapi, tests: RPC correctness under pipelined im…
pratikspatil024 Jul 22, 2026
0048a6e
Merge branch 'develop' into pipelined-src
pratikspatil024 Jul 22, 2026
612e1df
consensus/bor, core, core/state: extract helpers from new pipeline code
pratikspatil024 Jul 23, 2026
1c60a84
core, core/state, core/txpool, eth, tests: address review findings
pratikspatil024 Jul 23, 2026
c89bdf1
consensus/bor, tests, triedb/pathdb: fix CI peering failure, review nits
pratikspatil024 Jul 23, 2026
ccedec8
miner, tests: guard GetTd underflow, tighten RPC test setup
pratikspatil024 Jul 23, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 93 additions & 1 deletion consensus/bor/bor.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,18 @@
inmemorySnapshots = 128 // Number of recent vote snapshots to keep in memory
inmemorySignatures = 4096 // Number of recent block signatures to keep in memory
veblopBlockTimeout = time.Second * 8 // Timeout for new span check. DO NOT CHANGE THIS VALUE.
minBlockBuildTime = 1 * time.Second // Minimum remaining time before extending the block deadline to avoid empty blocks
// minBlockBuildTime is the minimum remaining time before Prepare() extends
// the block deadline to avoid producing empty blocks. If time.Until(target)
// is less than this value, the target timestamp is pushed forward by one
// blockTime period.
//
// This interacts with pipelined SRC: when a speculative block is aborted,
// the pipeline triggers a fresh commitWork. On chains where blockTime ==
// minBlockBuildTime (e.g., 1-second devnets), the remaining time after the
// abort (~990ms) is always less than minBlockBuildTime, so the timestamp is
// always pushed — adding an extra 1s gap. On mainnet (2s blocks), the
// remaining time (~1.99s) exceeds minBlockBuildTime, so no push occurs.
minBlockBuildTime = 1 * time.Second
)

// Bor protocol constants.
Expand Down Expand Up @@ -1193,7 +1204,7 @@
// check and commit span
if !c.config.IsRio(header.Number) {
if err := c.checkAndCommitSpan(wrappedState, header, cx); err != nil {
log.Error("Error while committing span", "error", err)

Check failure on line 1207 in consensus/bor/bor.go

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Define a constant instead of duplicating this literal "Error while committing span" 3 times.

See more on https://sonarcloud.io/project/issues?id=0xPolygon_bor&issues=AZ1JxLOFMy6llO4qwxL2&open=AZ1JxLOFMy6llO4qwxL2&pullRequest=2180
return nil
}
}
Expand All @@ -1202,7 +1213,7 @@
// commit states
stateSyncData, err = c.CommitStates(wrappedState, header, cx)
if err != nil {
log.Error("Error while committing states", "error", err)

Check failure on line 1216 in consensus/bor/bor.go

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Define a constant instead of duplicating this literal "Error while committing states" 3 times.

See more on https://sonarcloud.io/project/issues?id=0xPolygon_bor&issues=AZ1JxLOFMy6llO4qwxL4&open=AZ1JxLOFMy6llO4qwxL4&pullRequest=2180
return nil
}
}
Expand All @@ -1215,7 +1226,7 @@
// the wrapped state here as it may have a hooked state db instance which can help
// in tracing if it's enabled.
if err = c.changeContractCodeIfNeeded(headerNumber, wrappedState); err != nil {
log.Error("Error changing contract code", "error", err)

Check failure on line 1229 in consensus/bor/bor.go

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Define a constant instead of duplicating this literal "Error changing contract code" 3 times.

See more on https://sonarcloud.io/project/issues?id=0xPolygon_bor&issues=AZ1JxLOFMy6llO4qwxL3&open=AZ1JxLOFMy6llO4qwxL3&pullRequest=2180
return nil
}

Expand Down Expand Up @@ -1388,6 +1399,81 @@
return block, receipts, commitTime, nil
}

// FinalizeForPipeline runs the same post-transaction state modifications as
// FinalizeAndAssemble (state sync, span commits, contract code changes) but
// does NOT compute IntermediateRoot or assemble the block. It returns the
// stateSyncData so the caller can pass it to AssembleBlock later after the
// background SRC goroutine has computed the state root.
//
// This is the pipelined SRC equivalent of the first half of FinalizeAndAssemble.
func (c *Bor) FinalizeForPipeline(chain consensus.ChainHeaderReader, header *types.Header, statedb *state.StateDB, body *types.Body, receipts []*types.Receipt) ([]*types.StateSyncData, error) {
headerNumber := header.Number.Uint64()
if body.Withdrawals != nil || header.WithdrawalsHash != nil {
return nil, consensus.ErrUnexpectedWithdrawals
}
if header.RequestsHash != nil {
return nil, consensus.ErrUnexpectedRequests
}

var (
stateSyncData []*types.StateSyncData
err error
)

if IsSprintStart(headerNumber, c.config.CalculateSprint(headerNumber)) {
cx := statefull.ChainContext{Chain: chain, Bor: c}

if !c.config.IsRio(header.Number) {
if err = c.checkAndCommitSpan(statedb, header, cx); err != nil {
log.Error("Error while committing span", "error", err)
return nil, err
}
}

if c.HeimdallClient != nil {
stateSyncData, err = c.CommitStates(statedb, header, cx)
if err != nil {
log.Error("Error while committing states", "error", err)
return nil, err
}
}
}

if err = c.changeContractCodeIfNeeded(headerNumber, statedb); err != nil {
log.Error("Error changing contract code", "error", err)
return nil, err
}

return stateSyncData, nil
}

// AssembleBlock constructs the final block from a pre-computed state root,
// without calling IntermediateRoot. This is used by pipelined SRC where the
// state root is computed by a background goroutine.
//
// stateSyncData is the state sync data collected during Finalize(). If non-nil
// and the Madhugiri fork is active, a StateSyncTx is appended to the body.
func (c *Bor) AssembleBlock(chain consensus.ChainHeaderReader, header *types.Header, statedb *state.StateDB, body *types.Body, receipts []*types.Receipt, stateRoot common.Hash, stateSyncData []*types.StateSyncData) (*types.Block, []*types.Receipt, error) {
headerNumber := header.Number.Uint64()

header.Root = stateRoot
header.UncleHash = types.CalcUncleHash(nil)

if len(stateSyncData) > 0 && c.config != nil && c.config.IsMadhugiri(big.NewInt(int64(headerNumber))) {
stateSyncTx := types.NewTx(&types.StateSyncTx{
StateSyncData: stateSyncData,
})
body.Transactions = append(body.Transactions, stateSyncTx)
receipts = insertStateSyncTransactionAndCalculateReceipt(stateSyncTx, header, body, statedb, receipts)
} else {
bc := chain.(core.BorStateSyncer)
bc.SetStateSync(stateSyncData)
}

block := types.NewBlock(header, body, receipts, trie.NewStackTrie(nil))
return block, receipts, nil
}

// Authorize injects a private key into the consensus engine to mint new blocks
// with.
func (c *Bor) Authorize(currentSigner common.Address, signFn SignerFn) {
Expand Down Expand Up @@ -1736,6 +1822,12 @@

tempState.IntermediateRoot(false)

// Propagate addresses accessed during LastStateId back to the original
// state so they appear in the FlatDiff ReadSet. Without this, the
// pipelined SRC goroutine's witness won't capture their trie proof
// nodes, causing stateless execution to fail with missing trie nodes.
tempState.PropagateReadsTo(state.Inner())

stateSyncDelay := c.config.CalculateStateSyncDelay(number)
to = time.Unix(int64(header.Time-stateSyncDelay), 0)
} else {
Expand Down
Loading
Loading