Commit 19cf8ec
refactor(forks): nest forks/ under new spec/ subpackage (leanEthereum#788)
* refactor(forks): nest forks/ under new spec/ subpackage
Group per-fork consensus rules under a dedicated lean_spec.spec namespace
so the protocol specification has a clear home as more spec content
(SSZ, chain, validator, etc.) potentially moves alongside it.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* refactor(crypto): collect koalabear and poseidon under spec/crypto/
Move the two cryptographic primitive subspecs into the spec/ subpackage
created in the previous commit:
- subspecs/koalabear/field.py -> spec/crypto/koalabear.py
- subspecs/poseidon1/{constants,permutation}.py -> spec/crypto/poseidon.py
Each primitive collapses into a single module: koalabear loses its
re-exporting __init__, and poseidon merges its round-constants table
with the permutation engine. The Poseidon1 class is renamed to Poseidon
(and Poseidon1Params -> PoseidonParams) since the file no longer carries
the variant number; PARAMS_16/PARAMS_24 keep their names.
All import sites in src/, tests/, and packages/testing/ are updated.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* refactor(crypto): collapse subspecs/ssz/ into spec/crypto/merkleization.py
Merge the four-file SSZ hashing subspec into a single module that lives
alongside the other primitives under spec/crypto/. The hash-tree-root
dispatch, the binary-tree merkleizer, the length-mix helper, and the
two chunk-width constants now all sit in one place; the cross-file
imports between hash.py, merkleization.py, and constants.py disappear.
All import sites in src/, tests/, and packages/testing/ are updated to
import from spec.crypto.merkleization.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* refactor(crypto): collapse zero-hash cache into a single expression
Replace the three-piece machinery (named max-depth constant, builder
function, module-level call) with one itertools.accumulate that folds
the recurrence h_{d+1} = sha256(h_d || h_d) over the all-zero seed.
The cache now covers depth 64 unconditionally, so _zero_tree_root drops
the past-cache fallback loop and becomes a direct table lookup. The two
tests that exercised the fallback are deleted with the dead code.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* docs(crypto): bullet-format the zero-hash table and depth-mapping comments
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* refactor: move xmss under spec/crypto, rename subspecs -> node
Two related reorgs that finish carving out spec/ vs runtime/:
- XMSS is a cryptographic primitive specification, structurally identical
to the koalabear/poseidon/merkleization siblings, so move the entire
subpackage to lean_spec.spec.crypto.xmss alongside them.
- Everything left under subspecs/ is reference-node runtime (api,
networking, storage, sync, validator, observability, metrics, plus the
chain/genesis fuzzy middle ground and the Node orchestrator itself).
Rename it to lean_spec.node so the package name reflects what it is.
The old inner subspecs/node/ subpackage is dissolved in the same move:
its node.py and anchor.py lift up by one level so the new layout exposes
lean_spec.node.{Node, NodeConfig, anchor.*} directly instead of nesting
them inside lean_spec.node.node.*.
All import sites in src/, tests/, and packages/testing/ are updated, the
per-file ruff ignore in pyproject.toml moves with xmss, and the xmss
internal relative imports are repointed to the new neighbors.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* refactor(node): move snappy/ under node/
Snappy framing is a wire-format runtime concern used by gossip and
reqresp, not a piece of the protocol specification. Group it with the
other runtime services under lean_spec.node.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* refactor(ssz): carve SSZ primitives into spec/ssz/, lift base.py to lean_spec.base
The 8 SSZ-primitive modules under lean_spec.types (bitfields, boolean,
byte_arrays, collections, container, exceptions, ssz_base, uint) move to
lean_spec.spec.ssz alongside the other protocol-spec subpackages. What
stays under lean_spec.types is the domain layer: Slot, Checkpoint,
ValidatorIndex, SubnetId, AggregationBits, the RLP helpers, and the
participation bits — types built on top of SSZ rather than defining it.
base.py (CamelModel, StrictBaseModel) is not SSZ-specific and is used by
both SSZ models and non-SSZ Pydantic models. Moving it would create a
spec/ssz/ssz_base.py → types.base → types/__init__.py → spec/ssz cycle,
so it lifts one level up to lean_spec.base, sitting next to config.py
and log.py as generic Pydantic infrastructure.
All 135 SSZ-touching import sites are split where they mix SSZ and
domain symbols, and 21 sites importing StrictBaseModel/CamelModel are
repointed at lean_spec.base. No backward-compat re-exports.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* refactor(tests): mirror src/lean_spec/ layout under tests/
The unit test tree was lagging behind the recent source reorgs. Bring
tests/lean_spec/ into 1:1 correspondence with src/lean_spec/:
- tests/lean_spec/types/{test_bitfields,test_boolean,test_byte_arrays,
test_collections,test_container,test_ssz_base,test_uint}.py
-> tests/lean_spec/spec/ssz/
- tests/lean_spec/types/test_base.py -> tests/lean_spec/test_base.py
- tests/lean_spec/forks/ -> tests/lean_spec/spec/forks/
- tests/lean_spec/subspecs/{api,chain,genesis,metrics,networking,
observability,storage,sync,validator}/ -> tests/lean_spec/node/
- tests/lean_spec/subspecs/node/{test_anchor,test_node}.py dissolved up
into tests/lean_spec/node/
- tests/lean_spec/subspecs/koalabear/test_field.py
-> tests/lean_spec/spec/crypto/test_koalabear.py
- tests/lean_spec/subspecs/poseidon1/test_permutation.py
-> tests/lean_spec/spec/crypto/test_poseidon.py
- tests/lean_spec/subspecs/ssz/{test_hash,test_merkleization}.py
-> tests/lean_spec/spec/crypto/
- tests/lean_spec/subspecs/xmss/ -> tests/lean_spec/spec/crypto/xmss/
- tests/lean_spec/subspecs/containers/test_attestation_aggregation.py
-> tests/lean_spec/spec/forks/lstar/
- tests/lean_spec/snappy/ -> tests/lean_spec/node/snappy/
- tests/consensus/{lstar,devnet}/poseidon1 -> .../poseidon
- tests/lean_spec/subspecs/conftest.py -> tests/lean_spec/node/conftest.py
Justfile paths updated: codespell --skip for the snappy testdata
fixture, and the test-consensus recipe now points at the new layout.
Side fix: the node/__init__.py eager re-export of Node/NodeConfig was
turning any import of lean_spec.node.<anything> into a load of the
whole api -> networking -> reqresp.handler chain, which then tries to
import SignedBlock from lean_spec.spec.forks while spec.forks is
mid-init. The three call sites switch to the explicit module path
lean_spec.node.node, and the __init__.py drops the re-export.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>1 parent d866322 commit 19cf8ec
339 files changed
Lines changed: 1817 additions & 1946 deletions
File tree
- .claude/rules
- packages/testing/src
- consensus_testing
- forks
- test_fixtures
- test_types
- framework/test_fixtures
- src/lean_spec
- cli
- node
- api
- endpoints
- chain
- genesis
- metrics
- networking
- client
- event_source
- enr
- gossipsub
- reqresp
- service
- transport
- identity
- quic
- observability
- snappy
- storage
- sync
- validator
- spec
- crypto
- xmss
- forks
- lstar
- ssz
- subspecs
- koalabear
- node
- poseidon1
- ssz
- types
- tests
- api
- endpoints
- consensus/lstar
- fc
- networking
- poseidon
- ssz
- state_transition
- interop/helpers
- lean_spec
- cli
- helpers
- node
- api
- chain
- genesis
- metrics
- networking
- client
- enr
- gossipsub
- integration
- reqresp
- service
- transport
- identity
- quic
- observability
- snappy
- testdata
- storage
- sync
- validator
- spec
- crypto
- xmss
- forks
- lstar
- forkchoice
- state
- ssz
- subspecs
- node
- xmss
- types
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
| 39 | + | |
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
| 43 | + | |
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
81 | | - | |
| 81 | + | |
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
11 | | - | |
12 | | - | |
13 | | - | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
50 | 49 | | |
51 | 50 | | |
52 | 51 | | |
53 | 52 | | |
54 | 53 | | |
55 | | - | |
| 54 | + | |
56 | 55 | | |
57 | 56 | | |
58 | 57 | | |
59 | 58 | | |
60 | | - | |
| 59 | + | |
61 | 60 | | |
62 | 61 | | |
63 | 62 | | |
64 | 63 | | |
65 | 64 | | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
72 | 68 | | |
73 | 69 | | |
74 | 70 | | |
| |||
Lines changed: 7 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
150 | 151 | | |
151 | 152 | | |
152 | 153 | | |
153 | | - | |
| 154 | + | |
154 | 155 | | |
155 | 156 | | |
156 | 157 | | |
| |||
Lines changed: 6 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
15 | 17 | | |
16 | 18 | | |
17 | 19 | | |
18 | 20 | | |
19 | 21 | | |
20 | 22 | | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
Lines changed: 6 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| |||
Lines changed: 9 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
9 | 8 | | |
10 | 9 | | |
11 | 10 | | |
| |||
16 | 15 | | |
17 | 16 | | |
18 | 17 | | |
19 | | - | |
20 | | - | |
21 | | - | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
22 | 21 | | |
23 | 22 | | |
24 | 23 | | |
25 | 24 | | |
26 | | - | |
27 | | - | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| |||
Lines changed: 10 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | | - | |
| 10 | + | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
| 39 | + | |
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | | - | |
| 48 | + | |
49 | 49 | | |
50 | | - | |
| 50 | + | |
51 | 51 | | |
52 | | - | |
| 52 | + | |
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| |||
0 commit comments