Skip to content

Commit b0360e2

Browse files
tcoratgerclaude
andauthored
refactor(head-sync): flatten descendant processing into an iterative drain (leanEthereum#1112)
Rework the gossip head follower so the descendant cascade is a single iterative loop instead of mutual recursion through three methods. - Collapse the on_gossip_block return into Store | None. None means the block was cached pending an unknown parent; a store means it was integrated. This deletes the single-bool HeadSyncResult wrapper and the repeated two-channel returns. - Replace the recursion with a deque worklist over block roots. A long backfilled chain can no longer exhaust the stack, and the gossiped block is processed explicitly so a failure is a direct early return. - Delete the reentrancy set. The processed path is now fully synchronous (no awaits), so a concurrent entry for the same root cannot interleave; the already-in-store check is the sufficient guard. - Inline the cache-and-backfill helper into its only caller. - Hash each block once: reuse the gossiped block root and the cached child roots rather than recomputing. - Trim the module, class, field, and inline documentation; correct the service write-back comment, which now describes a true invariant. Tests move from asserting a result wrapper to asserting the store contract directly, and the reentrancy-guard test is removed with the set. Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 46f9532 commit b0360e2

3 files changed

Lines changed: 95 additions & 428 deletions

File tree

0 commit comments

Comments
 (0)