Patricia alt 2 - #5
Merged
Merged
Conversation
…ider, block header decoder does not encode for hash calculation
This was referenced Mar 19, 2026
Merged
1 task
4 tasks
12 tasks
2 tasks
This was referenced May 5, 2026
12 tasks
16 tasks
12 tasks
16 tasks
16 tasks
kamilchodola
added a commit
that referenced
this pull request
May 28, 2026
#3+#4 (correctness/robustness): the sparse-vs-Patricia agreement counter lived in static fields on FlatWorldStateScope. Every scope (read-only RPC, parallel block processing, snapshot validation) updated and read the same counter, so one scope's mismatch could reset another's confidence and one scope's wins could promote another to authoritative without that scope validating its own sparse trie. Moved to SparseAuthoritativeTracker held by FlatScopeProvider so each provider owns its own confidence. Also tied _sparseIsAuthoritative to SparseTrieSkipPatricia: the previous condition (just 10 consecutive matches and !VerificationMode) flipped sparse into the authoritative root/commit role while Patricia BulkSet still ran on every block, paying for trie work whose result was thrown away. Now sparse takes over only when the operator has explicitly opted out of Patricia persistence via SparseTrieSkipPatricia (currently default-on for the EXPB sparse-storage runs). #5 (performance): storage commit walked every retained sparse storage trie on every block. With cross-block PreservedSparseTrie reuse and no LFU pruning yet, that's O(retained contracts) per commit and grows unboundedly. Expose DirtyStorageAccountHashes (a lock-free enumeration of SparseRootComputer's _storageChanges keys) and walk only the contracts whose storage actually changed this block. CommitStorageTrie still skips clean subtrees internally as a second filter, but now we don't even iterate cold contracts at the outer level. Test updates: FlatWorldStateScopeProviderTests registers SparseAuthoritativeTracker in the Autofac container; FlatOverridableWorldScope and WriteBatchBenchmark pass new instances at construction. All 432 State.Flat tests pass.
5 tasks
16 tasks
stdevMac
added a commit
that referenced
this pull request
Jun 16, 2026
- GetFinalizedHash: treat a cached Keccak.Zero as "not set" so it no longer shadows a previously-persisted finalized hash (LukaszRozmej #4). - Use != Keccak.Zero instead of .IsZero for file-style consistency; keep the guard deliberately (a zero finalized must not clobber a persisted one) and document the OnForkChoiceUpdated monitoring blip (LukaszRozmej #2/#3, asdacap). - Rename forkChoiceUpdatedV1_to_unknown_block_fails -> ..._is_syncing_and_records_forkchoice to match the new contract (LukaszRozmej #5).
16 tasks
13 tasks
stdevMac
added a commit
that referenced
this pull request
Jul 5, 2026
… pivot update (#11995) * fix(sync): unwedge UpdatingPivot stage for nodes restarted before first pivot update A node restarted before its first pivot update was persisted could sit in the UpdatingPivot sync stage forever: - ForkchoiceUpdatedHandler returned SYNCING without recording the forkchoice state when the head header could not be resolved (e.g. zero peers right after restart), so even a CL re-sending FCU every slot never fed StartingSyncPivotUpdater. - BeaconSync.GetFinalizedHash only consulted the in-memory block cache, ignoring the finalized hash already persisted by the block tree. Record FinalizedBlockHash/HeadBlockHash in the unresolvable-header syncing path, and fall back to the block tree's persisted finalized hash. Both are safe: finalized blocks cannot reorg and TryOverwritePivot enforces monotonicity, so stale values can only yield older-but-valid pivots. No fallback for GetHeadBlockHash: heads can reorg and the block tree's head reflects local processing progress, not the CL forkchoice target. * fix(sync): distinguish no-FCU-data from unresolvable-finalized in pivot wait log 'Waiting for Forkchoice message from Consensus Layer' was misleading when a finalized hash was already known but its block number could not be resolved (e.g. no peers); log the known hash and peer count instead. * fix(sync): persist forkchoice hashes on the unresolvable-header path The e2e bench caught a gap in e51f44dd43: recording the forkchoice state only in IBlockCacheService does not survive the very restart the fix targets — a node killed before its first pivot update came back with no FCU data and waited forever despite the earlier fix. Persist the finalized/safe hashes via BlockTree.ForkChoiceUpdated in the same unresolvable-header branch (zero-guarded). This is safe there: finalized blocks cannot reorg, TryUpdateSyncPivot no-ops while the finalized header is unknown, and the OnForkChoiceUpdated event only feeds monitoring. BlockTree.Initializer already loads FinalizedHash back from the metadata db at startup, which is exactly what BeaconSync's GetFinalizedHash fallback reads after the restart. forkChoiceUpdatedV1_to_unknown_block_fails is updated to the new contract: the head must not move for an unresolvable forkchoice state, but finalized/safe are now recorded. * fix(sync): address review feedback on UpdatingPivot fix - GetFinalizedHash: treat a cached Keccak.Zero as "not set" so it no longer shadows a previously-persisted finalized hash (LukaszRozmej #4). - Use != Keccak.Zero instead of .IsZero for file-style consistency; keep the guard deliberately (a zero finalized must not clobber a persisted one) and document the OnForkChoiceUpdated monitoring blip (LukaszRozmej #2/#3, asdacap). - Rename forkChoiceUpdatedV1_to_unknown_block_fails -> ..._is_syncing_and_records_forkchoice to match the new contract (LukaszRozmej #5). * fix(sync): trim pivot-fix comments and strengthen zero-hash pivot tests per review --------- Co-authored-by: lukasz.rozmej <lukasz.rozmej@gmail.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
3 tasks
This was referenced Jul 29, 2026
This was referenced Aug 6, 2026
This was referenced Aug 13, 2026
This was referenced Aug 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.