refactor(testing): consolidate consensus_testing genesis builders - #1153
Merged
tcoratger merged 2 commits intoJun 18, 2026
Merged
Conversation
Collapse the genesis/anchor construction helpers into a small, consistent surface and remove duplication. - Merge the keyed and zeroed validator/state builders into one build_genesis_state(..., keyed=...); drop generate_pre_state, make_genesis_state, make_validators, _build_validators. - Rename make_genesis_store to build_genesis_store and unify the build_ verb. - Inline the trivial genesis-block reconstruction at its call sites and remove reconstruct_block_from_header. - Let build_anchor handle slot 0 as the genesis case so build_genesis_store delegates to it; the genesis-block construction now lives in one place. - Inline the former module-level defaults and default fork directly in signatures; whitelist the immutable Uint64/ValidatorIndex/LstarSpec calls in ruff's flake8-bugbear config. - Update all call sites across tests/ and packages/. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The inlined genesis-block construction hurt readability across the fixtures and tests. Bring the helper back, export it, and call it again everywhere the block is rebuilt from a state's latest header, including inside build_anchor. Co-Authored-By: Claude Opus 4.8 (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
Tidies up
packages/testing/src/consensus_testing/genesis.py, which had grown a tangle of overlapping, inconsistently named builders. Collapses them into a small, consistent surface and removes duplication, updating all call sites.The public surface goes from 7 symbols to 3 functions:
What changed
_build_validators(real XMSS keys) andmake_validators(zeroed keys) were the same loop with a different key source; both now live insidebuild_genesis_statebehind akeyedflag.generate_pre_stateandmake_genesis_statecollapse into that one function too.make_genesis_store→build_genesis_store; everything is nowbuild_*.reconstruct_block_from_header— a trivial helper; the genesis-block construction is inlined at its call sites.build_anchornow acceptsanchor_slot=0as the genesis case (its advance loop is simply empty there), sobuild_genesis_storedelegates to it. The genesis-block construction now exists in exactly one place, and theif anchor_slot == 0dodge branches in thesync/api_endpointfixtures collapse away._DEFAULT_GENESIS_TIME,_DEFAULT_VALIDATOR_INDEX) and defaultedforkdirectly in the signatures. The immutableUint64/ValidatorIndex/LstarSpeccalls are whitelisted in ruff'sflake8-bugbear.extend-immutable-callsso the in-signature defaults pass B008.tests/andpackages/.No backward-compatibility shims — old names are removed, not aliased.
Testing
just checkpasses (ruff lint + format, ty, codespell, mdformat, lock).test_anchor,test_node,chain/test_service,api/endpoints,validator/test_service).🤖 Generated with Claude Code