Skip to content

refactor(node): flatten genesis package and tidy config loader#1105

Merged
tcoratger merged 1 commit into
leanEthereum:mainfrom
tcoratger:genesis-config-refactor
Jun 16, 2026
Merged

refactor(node): flatten genesis package and tidy config loader#1105
tcoratger merged 1 commit into
leanEthereum:mainfrom
tcoratger:genesis-config-refactor

Conversation

@tcoratger

Copy link
Copy Markdown
Collaborator

Summary

The node/genesis/ package held a single module (config.py) plus a re-export-only __init__.py — over-modularization for one small class. This flattens it to a flat node/genesis.py, placed beside its actual consumer node/anchor.py. The node/chain/ package stays focused purely on consensus timing (SlotClock, ChainService); a load-once config loader does not belong there.

Because lean_spec.node.genesis remains a valid import path, no import sites change. The test moves to tests/node/test_genesis.py to keep the test tree mirroring the source tree.

Changes

  • Flatten the packagesrc/lean_spec/node/genesis.py; delete the empty node/genesis/ and tests/node/genesis/ packages.
  • from_yaml_file: read the file with Path.read_text(...) instead of an explicit handle + context manager.
  • _yaml_int_to_hex: derive the hex pad width from the key length (Bytes52.LENGTH * 2) instead of a magic 0104 literal; rename the single-letter parameter.
  • _reject_oversized_validator_set: move to mode="before" so the bound is enforced before every XMSS key is decoded — the old post-validator ran after the decode, so it never delivered the memory-safety guarantee its docstring claimed.
  • Documentation: trim every docstring to the leanest form the doc rules allow (the class essay → one line, the Raises: block → dropped, field/validator docstrings reduced to the single non-obvious fact each). Also align the proposal_public_key wording with the canonical Validator ("signs the block root").

Testing

  • All 63 affected tests pass (tests/node/test_genesis.py, test_anchor.py, tests/cli/test_run.py, tests/node/test_node.py).
  • ruff check, ruff format --check, and ty check all pass.

🤖 Generated with Claude Code

The genesis package held a single module, so flatten it to node/genesis.py
beside its consumer node/anchor.py. The chain package stays focused on
consensus timing.

Tidy the loader itself:
- load the file with Path.read_text instead of an explicit handle
- derive the hex pad width from the key length instead of a magic literal
- bound the validator set before decoding keys (mode="before"), matching
  the memory-safety rationale the check claims
- trim the documentation to the leanest form the rules allow

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@tcoratger tcoratger merged commit 019e910 into leanEthereum:main Jun 16, 2026
14 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