Skip to content

Patricia alt 2 - #5

Merged
tkstanczak merged 6 commits into
masterfrom
patricia_alt_2
May 22, 2018
Merged

Patricia alt 2#5
tkstanczak merged 6 commits into
masterfrom
patricia_alt_2

Conversation

@tkstanczak

Copy link
Copy Markdown
Member

No description provided.

@tkstanczak
tkstanczak merged commit 5a4b7f7 into master May 22, 2018
@tkstanczak
tkstanczak deleted the patricia_alt_2 branch August 29, 2018 00:58
@claude claude Bot mentioned this pull request Apr 30, 2026
12 tasks
@LukaszRozmej LukaszRozmej mentioned this pull request May 18, 2026
16 tasks
@claude claude Bot mentioned this pull request May 21, 2026
12 tasks
@LukaszRozmej LukaszRozmej mentioned this pull request May 25, 2026
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.
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).
@claude claude Bot mentioned this pull request Jun 26, 2026
16 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>
@claude claude Bot mentioned this pull request Jul 10, 2026
2 tasks
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.

1 participant