Skip to content

refactor: drop unused constants, Bytes1, and BaseUint.to_bytes override#750

Merged
tcoratger merged 1 commit into
leanEthereum:mainfrom
tcoratger:refactor/audit-deletes
May 21, 2026
Merged

refactor: drop unused constants, Bytes1, and BaseUint.to_bytes override#750
tcoratger merged 1 commit into
leanEthereum:mainfrom
tcoratger:refactor/audit-deletes

Conversation

@tcoratger
Copy link
Copy Markdown
Collaborator

Summary

Four audit deletions bundled together. Net −63 / +2 across 6 files.

  • snappy/constants.pyMAX_VARINT_LENGTH removed (no references anywhere). BLOCK_LOG inlined into BLOCK_SIZE = 1 << 16 (its single use); the 64 KB rationale already lives in the BLOCK_SIZE docstring.
  • types/byte_arrays.py + types/__init__.py + testsBytes1 deleted. The only consumer outside its own definition was one parametrize case in test_byte_arrays.py; class, public re-export, and test case all gone.
  • types/uint.py + testsBaseUint.to_bytes override deleted. Production code (encode_bytes, xmss/prf.py) passes length and byteorder explicitly at every call site, so nothing relied on the Uint-aware defaults. The three orphaned tests (test_to_bytes_default, test_to_bytes_specifics, test_to_bytes_overflow) leave with the override — they only existed to verify its defaults. Literal and SupportsIndex imports dropped (only the override used them).

Skipped: StateT/BlockT TypeVars

The audit's fifth item (forks/lstar/store.py:7,24-28) was already addressed by merged PR #744 (PEP 695 generic syntax). The current __all__ is ["AttestationSignatureEntry", "Store"] and there are no module-level StateT/BlockT definitions.

Test plan

  • ruff check — clean on all six files.
  • uv run pytest tests/lean_spec/snappy/ tests/lean_spec/types/test_uint.py tests/lean_spec/types/test_byte_arrays.py — 496 tests pass.
  • grep -rn "MAX_VARINT_LENGTH\|BLOCK_LOG\|Bytes1" across src/, tests/, packages/ — only the expected Bytes16/Bytes12 substring matches remain.

🤖 Generated with Claude Code

Four audit deletions bundled together.

- snappy MAX_VARINT_LENGTH constant: unused anywhere in src or tests.
- snappy BLOCK_LOG constant: referenced once as 1 << BLOCK_LOG;
  inlined into BLOCK_SIZE = 1 << 16. The 64 KB rationale already
  lives in the BLOCK_SIZE docstring.
- Bytes1 type: only appearance outside its own definition was one
  parametrize case in test_byte_arrays. Class, public re-export, and
  test case all gone.
- BaseUint.to_bytes override: production code passes length and
  byteorder explicitly at every call site, so nothing relied on the
  Uint-aware defaults. The override and its three dedicated tests
  (test_to_bytes_default, test_to_bytes_specifics,
  test_to_bytes_overflow) all leave; the only remaining .to_bytes
  caller in encode_bytes already passes its arguments explicitly,
  and now resolves to int.to_bytes directly. Literal and
  SupportsIndex imports also drop since they were only used by the
  override signature.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@tcoratger tcoratger merged commit 4e4a9db into leanEthereum:main May 21, 2026
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.

1 participant