Skip to content

Commit 62c5987

Browse files
tcoratgerclaude
andauthored
refactor(forks): move fork-stable types to lean_spec.types (Stage 2 of leanEthereum#686) (leanEthereum#695)
Promote the data primitives whose shape is stable across the leanSpec fork chain out of the lstar fork package and into lean_spec.types: - Slot (with its 3SF-mini justifiability methods) - ValidatorIndex, SubnetId - Checkpoint Validator and Validators stay in the fork because their XMSS-bound key shape is signature-scheme specific. ValidatorIndices stays for now because to_aggregation_bits couples it to the fork's AggregationBits; that decomposition can land as a follow-up. Config also stays in the fork: the single-field shape is the most likely container to grow per fork (deposits, RANDAO, fee parameters), so promoting it to subspecs/chain/ would just churn it back out later. Tighten the ForkProtocol surface using the freshly promoted types: SpecStoreType.from_anchor and ForkProtocol.create_store now take ValidatorIndex | None instead of Uint64 | None. Also drop the fork-side re-exports per CLAUDE.md (no compat shims) and update all call sites across src/, tests/, and packages/. Refs leanEthereum#686 Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 8cdc4b0 commit 62c5987

134 files changed

Lines changed: 269 additions & 395 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/testing/src/consensus_testing/genesis.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
"""Consensus layer pre-state generation."""
22

33
from lean_spec.forks.lstar.containers.block import AggregatedAttestations, Block, BlockBody
4-
from lean_spec.forks.lstar.containers.slot import Slot
54
from lean_spec.forks.lstar.containers.state import State, Validators
6-
from lean_spec.forks.lstar.containers.validator import Validator, ValidatorIndex
5+
from lean_spec.forks.lstar.containers.validator import Validator
76
from lean_spec.forks.lstar.spec import LstarSpec
87
from lean_spec.forks.protocol import ForkProtocol
98
from lean_spec.subspecs.ssz.hash import hash_tree_root
10-
from lean_spec.types import Bytes52, Uint64
9+
from lean_spec.types import Bytes52, Slot, Uint64, ValidatorIndex
1110

1211
from .keys import XmssKeyManager
1312

packages/testing/src/consensus_testing/keys.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,14 @@
4040
from typing import ClassVar, Literal
4141

4242
from lean_spec.config import LEAN_ENV
43-
from lean_spec.forks.lstar.containers import AttestationData, ValidatorIndex, ValidatorIndices
43+
from lean_spec.forks.lstar.containers import (
44+
AttestationData,
45+
ValidatorIndices,
46+
)
4447
from lean_spec.forks.lstar.containers.block.types import (
4548
AggregatedAttestations,
4649
AttestationSignatures,
4750
)
48-
from lean_spec.forks.lstar.containers.slot import Slot
4951
from lean_spec.subspecs.koalabear import Fp
5052
from lean_spec.subspecs.ssz.hash import hash_tree_root
5153
from lean_spec.subspecs.xmss.aggregation import AggregatedSignatureProof
@@ -62,7 +64,7 @@
6264
HashTreeOpening,
6365
Randomness,
6466
)
65-
from lean_spec.types import Bytes32, Uint64
67+
from lean_spec.types import Bytes32, Slot, Uint64, ValidatorIndex
6668

6769
SecretField = Literal["attestation_secret", "proposal_secret"]
6870
"""Discriminator for which secret key to load from a validator key pair."""

packages/testing/src/consensus_testing/test_fixtures/api_endpoint.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
from typing import Any, ClassVar
55

66
from lean_spec.forks.lstar import Store
7-
from lean_spec.forks.lstar.containers import BlockBody, Slot, ValidatorIndex
7+
from lean_spec.forks.lstar.containers import BlockBody
88
from lean_spec.forks.lstar.containers.block import Block
99
from lean_spec.forks.lstar.containers.block.types import AggregatedAttestations
1010
from lean_spec.forks.lstar.containers.state import State
1111
from lean_spec.forks.lstar.spec import LstarSpec
1212
from lean_spec.subspecs.ssz.hash import hash_tree_root
13-
from lean_spec.types import Bytes32, Uint64
13+
from lean_spec.types import Bytes32, Slot, Uint64, ValidatorIndex
1414

1515
from ..genesis import build_anchor, generate_pre_state
1616
from .base import BaseConsensusFixture

packages/testing/src/consensus_testing/test_fixtures/fork_choice.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,10 @@
1919
from lean_spec.forks.lstar.containers.block.types import (
2020
AggregatedAttestations,
2121
)
22-
from lean_spec.forks.lstar.containers.slot import Slot
2322
from lean_spec.forks.lstar.containers.state import State, Validators
24-
from lean_spec.forks.lstar.containers.validator import ValidatorIndex
2523
from lean_spec.subspecs.chain.clock import Interval
2624
from lean_spec.subspecs.ssz import hash_tree_root
27-
from lean_spec.types import Uint64
25+
from lean_spec.types import Slot, Uint64, ValidatorIndex
2826

2927
from ..keys import (
3028
LEAN_ENV_TO_SCHEMES,

packages/testing/src/consensus_testing/test_fixtures/justifiability.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
from typing import Any, ClassVar
1515

16-
from lean_spec.forks.lstar.containers.slot import Slot
16+
from lean_spec.types import Slot
1717

1818
from .base import BaseConsensusFixture
1919

packages/testing/src/consensus_testing/test_fixtures/networking_codec.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
from typing import Any, ClassVar
44

5-
from lean_spec.forks.lstar.containers.validator import SubnetId
65
from lean_spec.snappy import compress, decompress, frame_compress, frame_decompress
76
from lean_spec.subspecs.networking.discovery.codec import decode_message, encode_message
87
from lean_spec.subspecs.networking.discovery.messages import (
@@ -56,7 +55,7 @@
5655
from lean_spec.subspecs.networking.transport.peer_id import KeyType, PeerId, PublicKeyProto
5756
from lean_spec.subspecs.networking.types import NodeId, SeqNumber
5857
from lean_spec.subspecs.networking.varint import decode_varint, encode_varint
59-
from lean_spec.types import Bytes16, Bytes33, Bytes64
58+
from lean_spec.types import Bytes16, Bytes33, Bytes64, SubnetId
6059

6160
from .base import BaseConsensusFixture
6261

packages/testing/src/consensus_testing/test_fixtures/sync.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@
77

88
from typing import Any, ClassVar
99

10-
from lean_spec.forks.lstar.containers.slot import Slot
1110
from lean_spec.forks.lstar.spec import LstarSpec
1211
from lean_spec.subspecs.sync.checkpoint_sync import verify_checkpoint_state
13-
from lean_spec.types import Uint64
12+
from lean_spec.types import Slot, Uint64
1413

1514
from ..genesis import build_anchor, generate_pre_state
1615
from .base import BaseConsensusFixture

packages/testing/src/consensus_testing/test_fixtures/verify_signatures.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
AttestationSignatures,
1717
)
1818
from lean_spec.forks.lstar.containers.state import State
19-
from lean_spec.forks.lstar.containers.validator import ValidatorIndex
20-
from lean_spec.types import Boolean
19+
from lean_spec.types import Boolean, ValidatorIndex
2120

2221
from ..keys import XmssKeyManager
2322
from ..test_types import BlockSpec

packages/testing/src/consensus_testing/test_types/aggregated_attestation_spec.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,10 @@
55
from lean_spec.forks.lstar.containers.attestation import AggregatedAttestation, AttestationData
66
from lean_spec.forks.lstar.containers.block.block import Block
77
from lean_spec.forks.lstar.containers.block.types import AggregatedAttestations
8-
from lean_spec.forks.lstar.containers.checkpoint import Checkpoint
9-
from lean_spec.forks.lstar.containers.slot import Slot
108
from lean_spec.forks.lstar.containers.state import State
11-
from lean_spec.forks.lstar.containers.validator import ValidatorIndex, ValidatorIndices
9+
from lean_spec.forks.lstar.containers.validator import ValidatorIndices
1210
from lean_spec.subspecs.xmss.aggregation import AggregatedSignatureProof
13-
from lean_spec.types import ByteListMiB, Bytes32, CamelModel
11+
from lean_spec.types import ByteListMiB, Bytes32, CamelModel, Checkpoint, Slot, ValidatorIndex
1412

1513
from ..keys import XmssKeyManager
1614
from .utils import resolve_checkpoint

packages/testing/src/consensus_testing/test_types/block_spec.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,14 @@
2020
AggregatedAttestations,
2121
AttestationSignatures,
2222
)
23-
from lean_spec.forks.lstar.containers.slot import Slot
2423
from lean_spec.forks.lstar.containers.state import State
25-
from lean_spec.forks.lstar.containers.validator import ValidatorIndex, ValidatorIndices
24+
from lean_spec.forks.lstar.containers.validator import ValidatorIndices
2625
from lean_spec.forks.lstar.store import Store
2726
from lean_spec.subspecs.chain.clock import Interval
2827
from lean_spec.subspecs.ssz.hash import hash_tree_root
2928
from lean_spec.subspecs.xmss.aggregation import AggregatedSignatureProof
3029
from lean_spec.subspecs.xmss.containers import Signature
31-
from lean_spec.types import Bytes32, CamelModel
30+
from lean_spec.types import Bytes32, CamelModel, Slot, ValidatorIndex
3231

3332
from ..keys import LEAN_ENV_TO_SCHEMES, XmssKeyManager, create_dummy_signature
3433
from .aggregated_attestation_spec import AggregatedAttestationSpec

0 commit comments

Comments
 (0)