Skip to content

chore: add vulture dead-code detection and remove findings - #915

Merged
tcoratger merged 2 commits into
leanEthereum:mainfrom
leolara:chore/vulture-dead-code
Jun 10, 2026
Merged

chore: add vulture dead-code detection and remove findings#915
tcoratger merged 2 commits into
leanEthereum:mainfrom
leolara:chore/vulture-dead-code

Conversation

@leolara

@leolara leolara commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

What

Adds vulture for dead-code detection, then removes the dead code it found. Split into two commits so the tooling and the removals can be reviewed independently.

Commit 1 — add vulture dead-code detection

  • Adds vulture to the lint dependency group and a just deadcode recipe.
  • Configures vulture in pyproject.toml to scan src, packages, tests, and the whitelist together (most spec code is exercised only through the test suite, so the tests must be in scope or every test-only-used symbol reads as a false positive).
  • Adds a tight vulture_whitelist.py that names each indirectly-used symbol explicitly (framework dispatch, serialization, interpreter protocols) instead of relying on wide glob ignores. Excluded from ruff and ty since it is data, not executable code.
  • just deadcode is intentionally not wired into just check: vulture has unavoidable false positives on a Pydantic-heavy codebase, so gating CI on it would be noisy.

Commit 2 — remove dead code flagged by vulture

Removes the six symbols just deadcode reported and that were confirmed unused:

  • a write-only last-RPC timestamp on the gossipsub peer state
  • a mock response-stream flag that was set but never asserted
  • an unused parametrize column in the merkleization tests
  • an uncalled mock outbound-stream method
  • two uncalled test helpers (a key-file stub writer and an interop finalization waiter)

Three reported symbols were kept as confirmed false positives and recorded in the whitelist instead of removed:

  • subscribed — essential event field, compared via dataclass equality in tests
  • REAL — constructed via CryptoMode("real") from the --crypto CLI option
  • MESSAGE_LENGTH — documented XMSS protocol parameter

Verification

  • just deadcode → clean (exit 0)
  • just check → passes (lint, format, ty, codespell, mdformat, lock)
  • affected unit tests pass

Notes

Draft: the whitelist makes ignores explicit, which means a newly-added Pydantic validator/serializer or fixture will trip vulture until added to vulture_whitelist.py. That is the intended trade-off for tight, greppable ignores.

leolara added 2 commits June 10, 2026 19:09
Add vulture as a lint dependency, a `just deadcode` recipe, and a
vulture_whitelist.py that names each indirectly-used symbol explicitly
(framework dispatch, serialization, interpreter protocols) instead of
relying on wide glob ignores. Exclude the whitelist from ruff and ty
since it is data for vulture, not executable code.
Remove symbols that `just deadcode` reported and that were confirmed
unused:

- a write-only last-RPC timestamp on the gossipsub peer state
- a mock response-stream flag that was set but never asserted
- an unused parametrize column in the merkleization tests
- an uncalled mock outbound-stream method
- two uncalled test helpers (a key-file stub writer and an interop
  finalization waiter)

@tcoratger tcoratger left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

@tcoratger
tcoratger marked this pull request as ready for review June 10, 2026 14:47
@tcoratger
tcoratger merged commit 992b7a6 into leanEthereum:main Jun 10, 2026
12 of 13 checks passed
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.

2 participants