refactor(sync): drop _SyncStoreView adapter, make SyncService implement StoreView#730
Merged
tcoratger merged 1 commit intoMay 18, 2026
Conversation
…nt StoreView _SyncStoreView was a dataclass wrapping a lambda wrapping a getter on SyncService.store. Three layers of indirection to read two fields. SyncService can satisfy the StoreView protocol structurally with two short methods, removing the wrapper without growing the call surface. Also drops the finalized_slot method from the StoreView protocol. It was defined on the protocol, implemented on _SyncStoreView and on FakeStoreView, and never called from backfill_sync. Pure protocol bloat. Two dead set-but-not-read writes in tests removed too. The StoreView protocol itself stays. It breaks a real circular dependency (BackfillSync is imported by SyncService, so the field type cannot reference SyncService directly), keeps the test seam (FakeStoreView is 5 lines, no real Store construction needed), and documents BackfillSync's exact dependency on forkchoice state in 8 lines. Net: -28 lines, zero behavior change. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
_SyncStoreViewwas a dataclass wrapping a lambda wrapping a getter onSyncService.store. Three layers of indirection to read two fields.SyncServicecan satisfy theStoreViewprotocol structurally withtwo short methods, removing the wrapper without growing the call
surface.
Net: -28 lines, zero behavior change.
What changed
service.py_SyncStoreViewdataclass.has_root(root)andhead_slot()methods onSyncServiceitself. Each is a one-liner reading
self.store._initialize_subservices:store_view=selfinstead of_SyncStoreView(_get_store=lambda: self.store).The live store reference is observed because backfill calls back
through
selfand readsself.storeon demand.backfill_sync.pyfinalized_slot()method from theStoreViewProtocol. It was declared on the protocol, implemented on the
removed wrapper and on
FakeStoreView, and never called fromany production code in
backfill_sync.py. Pure protocol bloat.test_backfill_sync.pyfinalized_slot()method and thefinalized: Slotfield from
FakeStoreView.store_view.finalized = Slot(10)dead writes(lines 379 and 411). These had no effect on production code or
assertions — they were leftover setup from when the protocol
included
finalized_slot.Why
StoreViewstaysThe protocol earns its 8 lines:
service.pyimportsBackfillSyncfrombackfill_sync.py. Typing the field asSyncServicewould create a cycle. The Protocol sidesteps this.FakeStoreViewis a 5-line dataclass. Without theprotocol, tests would need to construct real
Storeinstances(with
blocks,head,latest_finalized,config, etc.) just toexercise backfill.
BackfillSyncsees exactly what it needs from forkchoice without grepping.
Test plan
ruff check,ruff format --check,ty checkall passpytest tests/lean_spec/subspecs/sync-> 156 passedOut of scope
The next queued items from the sync-layer review:
make_default_block_processorfactory -> methodSyncServicemarketing-tone docstring (Reactive/Simple/Resilient/Observable)🤖 Generated with Claude Code