refactor: dead-code sweep in sync / api / storage subspecs#751
Merged
tcoratger merged 5 commits intoMay 21, 2026
Merged
Conversation
The endpoints package only needs a docstring; route registration imports each module directly from routes.py. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
SyncProgress, SyncService.get_progress, and SyncService.reset have no production callers; callers query store and peer_manager directly for progress information. Removing them shrinks the service surface. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The two methods were one-line passthroughs to the internal _peers dict. Renaming to a public attribute lets callers iterate or look up without going through wrappers, matching standard Python practice. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- has_block / has_state: no production caller checks existence without reading the payload; get_block / get_state already return None for missing entries. - commit(): a single-statement wrapper around _conn.commit(); only test code used it. Tests now go through batch_write(), the canonical atomic write API. Together these narrow the Database Protocol surface to the methods production callers actually use. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The endpoint, its client helpers (fetch_finalized_block, fetch_finalized_anchor) and the ApiServer.signed_block_getter plumbing existed to ship the anchor SignedBlock alongside the finalized state for checkpoint sync. They have no production callers — __main__.py uses fetch_finalized_state alone, and Store.create_store no longer needs the anchor SignedBlock to seed the store. Removes the endpoint module, the route entry, the client helpers, the FINALIZED_BLOCK_ENDPOINT constant, the signed_block_getter field on ApiServer, and the corresponding test fixtures and test classes. 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
Removes unused code and narrows public surface across
sync,api, andstoragesubspecs. Nine items, no behaviour change for any production caller.Commits (one per logical change)
refactor(api): drop empty re-exports from endpoints/__init__.py— package only needed a docstring; routes import each endpoint module directly.refactor(sync): drop unused SyncProgress / get_progress / reset— no production caller; callers querystoreandpeer_managerdirectly.refactor(sync): expose PeerManager.peers, drop get_peer/get_all_peers— the two methods were one-line passthroughs to the internal_peersdict. Renaming to a public attribute matches standard Python practice; updated the single production caller (node.py) and tests.refactor(storage): drop has_block / has_state / commit from Database— none have production callers. Existence checks already work viaget_block/get_statereturningNone;commit()was a single-statement wrapper around_conn.commit()only used in tests. Tests now go throughbatch_write(), the canonical atomic-write API.refactor(api): drop /lean/v0/blocks/finalized endpoint— the endpoint and its client helpers (fetch_finalized_block,fetch_finalized_anchor) shipped the anchor SignedBlock alongside the finalized state for checkpoint sync. No production caller:__main__.pyusesfetch_finalized_statealone, andStore.create_storeno longer needs the anchor SignedBlock. Removes the endpoint module, route entry, client helpers,FINALIZED_BLOCK_ENDPOINTconstant,ApiServer.signed_block_getterfield, and the matching test fixtures.Diff size
~790 lines removed across 17 files (≈60 inserted).
Test plan
uv run --group lint ruff check— cleanuv run --group lint ruff format --check— cleanuv run --group lint ty check src/ tests/— cleanuv run --group lint codespell …— cleanuv run --group docs mdformat --check docs/— cleanuv lock --check— cleanuv run pytest tests/lean_spec/subspecs/{sync,storage,api}/— 207 passeduv run pytest tests/api/(conformance) — 29 passed🤖 Generated with Claude Code