Skip to content

Commit ddfd5fb

Browse files
committed
refactor: move from remerkleable to ethereum_types and py-ssz
1 parent b39afbd commit ddfd5fb

4 files changed

Lines changed: 26 additions & 21 deletions

File tree

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ classifiers = [
1919
]
2020
requires-python = ">=3.12"
2121
dependencies = [
22+
"ethereum-types<=0.2.4,<0.3",
2223
"pydantic>=2.9.2,<3",
2324
"remerkleable>=0.1.28,<0.2",
25+
"ssz>=0.5.2,<0.6",
2426
"typing-extensions>=4.4",
2527
]
2628

src/lean_spec/subspecs/pqdevnet-0/block.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,20 @@
88
"""
99

1010
from dataclasses import dataclass
11-
from remerkleable.basic import uint64
12-
from remerkleable.byte_arrays import Bytes32
13-
from remerkleable.complex import List
1411
from pydantic import BaseModel, ConfigDict
1512

13+
from ethereum_types.bytes import Bytes32
14+
from ethereum_types.numeric import U64
15+
from ssz.sedes.list import List
16+
1617
from preset import VALIDATOR_REGISTRY_LIMIT
1718
from vote import Vote
1819

1920
@dataclass
2021
class Block(BaseModel):
2122
model_config = ConfigDict(arbitrary_types_allowed=True)
2223

23-
slot: uint64
24+
slot: U64
2425
parent: Bytes32
2526
votes: List[Vote, VALIDATOR_REGISTRY_LIMIT]
2627
# Diverged from 3SF-mini.py: Removed Optional from `state_root`

src/lean_spec/subspecs/pqdevnet-0/state.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@
88
"""
99

1010
from dataclasses import dataclass
11-
from remerkleable.basic import uint64
12-
from remerkleable.bitfields import Bitlist
13-
from remerkleable.byte_arrays import Bytes32
14-
from remerkleable.complex import List
1511
from pydantic import BaseModel, ConfigDict
1612

13+
from ethereum_types.bytes import Bytes32
14+
from ethereum_types.numeric import U64
15+
from ssz.sedes.bitlist import Bitlist
16+
from ssz.sedes.list import List
17+
1718
from preset import MAX_HISTORICAL_BLOCK_HASHES, VALIDATOR_REGISTRY_LIMIT
1819

1920
@dataclass
@@ -22,19 +23,19 @@ class State(BaseModel):
2223

2324
# Diverged from 3SF-mini.py:
2425
# - Removed `config: Config` from the state
25-
# - Using uint64 instead of native int for all fields
26-
# - Using Bytes32 instead of native str for all fields
26+
# - Using `U64` instead of native int for all fields
27+
# - Using `Bytes32` instead of native str for all fields
2728

2829
latest_justified_hash: Bytes32
29-
latest_justified_slot: uint64
30+
latest_justified_slot: U64
3031

3132
latest_finalized_hash: Bytes32
32-
latest_finalized_slot: uint64
33+
latest_finalized_slot: U64
3334

3435
historical_block_hashes: List[Bytes32, MAX_HISTORICAL_BLOCK_HASHES]
3536
justified_slots: List[bool, MAX_HISTORICAL_BLOCK_HASHES]
3637

3738
# Diverged from 3SF-mini.py:
3839
# - Flattened `justifications: Dict[str, List[bool]]` for SSZ compatibility
3940
justifications_roots: List[Bytes32, MAX_HISTORICAL_BLOCK_HASHES]
40-
justifications_validators: Bitlist[MAX_HISTORICAL_BLOCK_HASHES * VALIDATOR_REGISTRY_LIMIT]
41+
justifications_validators: Bitlist(MAX_HISTORICAL_BLOCK_HASHES * VALIDATOR_REGISTRY_LIMIT)

src/lean_spec/subspecs/pqdevnet-0/vote.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,24 @@
55
"""
66

77
from dataclasses import dataclass
8-
from remerkleable.basic import uint64
9-
from remerkleable.byte_arrays import Bytes32
108
from pydantic import BaseModel, ConfigDict
119

10+
from ethereum_types.bytes import Bytes32
11+
from ethereum_types.numeric import U64
12+
1213
@dataclass
1314
class Vote(BaseModel):
1415
model_config = ConfigDict(arbitrary_types_allowed=True)
1516

1617
# Diverged from 3SF-mini.py:
17-
# - Using `uint64` instead of native `int` for all fields
18+
# - Using `U64` instead of native `int` for all fields
1819
# - Using `Bytes32` instead of native `str` for all fields
1920

20-
validator_id: uint64
21-
slot: uint64
21+
validator_id: U64
22+
slot: U64
2223
head: Bytes32
23-
head_slot: uint64
24+
head_slot: U64
2425
target: Bytes32
25-
target_slot: uint64
26+
target_slot: U64
2627
source: Bytes32
27-
source_slot: uint64
28+
source_slot: U64

0 commit comments

Comments
 (0)