Skip to content

chore: sweep dead helpers across subspecs#683

Merged
tcoratger merged 1 commit intoleanEthereum:mainfrom
tcoratger:chore/sweep-dead-helpers
Apr 26, 2026
Merged

chore: sweep dead helpers across subspecs#683
tcoratger merged 1 commit intoleanEthereum:mainfrom
tcoratger:chore/sweep-dead-helpers

Conversation

@tcoratger
Copy link
Copy Markdown
Collaborator

Summary

Removes top-level functions, methods, and constants that have zero production callers across src/ (verified by grep). All deletions confirmed by grep across src/ and tests/. Tests that exclusively exercised dead code are dropped; tests that incidentally used a removed helper are rewritten against the surviving public API.

This is PR-A in a multi-PR plan from a wider audit of the subspecs codebase.

Diff: 30 files changed, +43 / −1197.

Removed surface

  • ENR: has, is_compatible_with
  • Eth2Data: no_scheduled_fork
  • Multihash: identity, sha256 (logic inlined into from_data)
  • PeerId: from_secp256k1 (callers go through IdentityKeypair.to_peer_id / PeerId.from_public_key)
  • Secp256k1PublicKey: from_bytes
  • IdentityKeypair: from_bytes, private_key_bytes
  • MessageCache, SeenCache: clear, __len__
  • RPC: is_empty (ControlMessage.is_empty stays — it is used by RPC.encode)
  • GossipsubBehavior: set_message_handler, _message_handler field, the dispatch branch in _handle_message
  • Fp: two_adic_generator, plus TWO_ADIC_GENERATORS and TWO_ADICITY constants
  • SyncService: process_pending_blocks, start_sync, _sync_lock
  • HeadSync: process_all_processable
  • PeerManager: clear
  • BlockCache: get_orphan_parents
  • ValidatorRegistry: from_secret_keys
  • GenesisConfig: create_state

Deliberately kept (against the audit)

  • decode_request in reqresp/codec.py — the audit flagged it as dead because the inbound handler reimplements the logic inline, but it has rich wire-format test coverage and is the symmetric counterpart of encode_request. The cleaner fix is to make the handler use decode_request (separate PR).
  • ENR.udp6_port, quic6_port, attestation_subnets, sync_committee_subnets, is_aggregator + the matching ENR keys (UDP6, QUIC6, ATTNETS, SYNCNETS, IS_AGGREGATOR) — used by packages/testing/src/consensus_testing/test_fixtures/networking_codec.py to build cross-client spec fixtures. Not visible from a src/-only grep.
  • GossipsubMessage.snappy_decompress field — borderline; reflects libp2p protocol behavior the spec should preserve.

Out of scope (deferred)

  • The whole subspecs/networking/discovery/ package (PR-B decision pending: wire in or move to experimental/).
  • Database Protocol slim-down + namespace dataclass collapse (PR-I).
  • SyncService.reset / BackfillSync.reset / HeadSync.reset (deferred to PR-J — likely a deliberate test-cleanup API).

Test plan

  • uvx tox -e all-checks passes (ruff, format, ty, codespell, mdformat).
  • Reviewer to spot-check: any of the removed helpers still wanted as part of the public API?
  • Reviewer to spot-check: each deleted test was either exclusively for a removed helper, or rewritten to exercise the surviving API.

🤖 Generated with Claude Code

Remove top-level functions, methods, and constants that have no production
callers. All deletions verified by grep across src/ and tests/. Tests that
exclusively exercised the removed code are dropped; tests that incidentally
used a removed helper are rewritten against the surviving public API.

Removed surface:

- ENR: has, is_compatible_with
- Eth2Data: no_scheduled_fork
- Multihash: identity, sha256 (logic inlined into from_data)
- PeerId: from_secp256k1 (callers go through IdentityKeypair.to_peer_id)
- Secp256k1PublicKey: from_bytes
- IdentityKeypair: from_bytes, private_key_bytes
- MessageCache, SeenCache: clear, __len__
- RPC: is_empty (ControlMessage.is_empty stays — used by RPC.encode)
- GossipsubBehavior: set_message_handler, _message_handler field
- Fp.two_adic_generator, TWO_ADIC_GENERATORS, TWO_ADICITY
- SyncService: process_pending_blocks, start_sync, _sync_lock
- HeadSync: process_all_processable
- PeerManager: clear
- BlockCache: get_orphan_parents
- ValidatorRegistry: from_secret_keys
- GenesisConfig: create_state

Net: 30 files changed, +43 / -1197.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@tcoratger tcoratger merged commit 908ae9f into leanEthereum:main Apr 26, 2026
12 of 13 checks passed
tcoratger added a commit to tcoratger/leanSpec that referenced this pull request Apr 27, 2026
Absorbs 14 commits from main and resolves two textual conflicts in
genesis/config.py and the matching test (PR leanEthereum#683 deleted the dead
GenesisConfig.create_state helper that this branch had refactored to
take a fork argument; production code goes through fork.generate_genesis
directly, so the wrapper is genuinely dead).

Reroutes two stale subspecs.containers imports left behind by the
auto-merge: a new test file from PR leanEthereum#684 (Checkpoint __lt__) and a
sync test fixture from PR leanEthereum#672. Both now resolve through
forks.devnet4.containers.

Tightens the docstring and inline comment introduced for
update_safe_target by PR leanEthereum#680 to follow the project's documentation
rules (short sentences, bullets over paragraphs).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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