Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions .claude/rules/ssz-patterns.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
paths:
- "src/lean_spec/subspecs/containers/**/*.py"
- "src/lean_spec/forks/*/containers/**/*.py"
- "src/lean_spec/types/**/*.py"
---

Expand Down Expand Up @@ -36,7 +36,7 @@ When creating SSZ types, follow these established patterns:
Containers should be organized into modules with clear separation:

```
src/lean_spec/subspecs/containers/
src/lean_spec/forks/<fork>/containers/
├── state/
│ ├── __init__.py # Exports State and related types
│ ├── state.py # Main State container class
Expand All @@ -61,11 +61,15 @@ src/lean_spec/subspecs/containers/

```python
# In state/types.py
HISTORICAL_ROOTS_LIMIT = 262144
HISTORICAL_ROOTS_LIMIT = 262144 # 2**18 tracked roots
VALIDATOR_REGISTRY_LIMIT = 4096 # 2**12 registered validators

class JustificationValidators(BaseBitlist):
"""Bitlist for tracking validator justifications."""
LIMIT = HISTORICAL_ROOTS_LIMIT * HISTORICAL_ROOTS_LIMIT
"""Per-root validator vote bitfields, concatenated into one flat bitlist."""
# Worst-case size: one bit per (tracked root, registered validator) pair.
# Any larger LIMIT inflates the bitlist's merkle depth and changes the
# state root for identical data, so this product is consensus-critical.
LIMIT = HISTORICAL_ROOTS_LIMIT * VALIDATOR_REGISTRY_LIMIT

# In block/types.py
class Attestations(SSZList):
Expand Down
9 changes: 8 additions & 1 deletion src/lean_spec/forks/lstar/containers/state/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,13 @@ def shift_window(self, delta: int) -> JustifiedSlots:


class JustificationValidators(BaseBitlist):
"""Bitlist for tracking validator justifications per historical root."""
"""Per-root validator vote bitfields, concatenated into one flat bitlist.

Each tracked root contributes one bit per registered validator.
The cap is the maximum tracked roots times the validator registry limit.

Why this product: a larger cap inflates the bitlist's merkle tree depth.
That changes the state root for identical data, so this limit is consensus-critical.
"""

LIMIT = int(HISTORICAL_ROOTS_LIMIT) * int(VALIDATOR_REGISTRY_LIMIT)
Loading