Skip to content

Commit 47434df

Browse files
committed
fix comment
1 parent a649bcf commit 47434df

File tree

5 files changed

+97
-87
lines changed

5 files changed

+97
-87
lines changed
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
"""Specifications for chain and consensus parameters."""
22

3-
from .config import DEVNET_CONFIG, ChainConfig
3+
from .config import DEVNET_CONFIG
44

55
__all__ = [
6-
"ChainConfig",
76
"DEVNET_CONFIG",
87
]

src/lean_spec/subspecs/chain/config.py

Lines changed: 63 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -5,104 +5,82 @@
55
Lean Consensus Experimental Chain.
66
"""
77

8-
from pydantic import BaseModel, ConfigDict, Field
9-
from typing_extensions import Annotated
8+
from pydantic import BaseModel, ConfigDict
9+
from typing_extensions import Final
1010

11-
# The maximum value for an unsigned 64-bit integer (2**64).
12-
UINT64_MAX = 2**64
11+
from lean_spec.subspecs.types import BasisPoint, uint64
1312

14-
# A type alias to represent a uint64.
15-
uint64 = Annotated[int, Field(ge=0, lt=UINT64_MAX)]
13+
# --- Time Parameters ---
1614

17-
# A type alias for basis points, now based on the uint64 type.
15+
# The fixed duration of a single slot in milliseconds.
16+
SLOT_DURATION_MS: Final = 4000
17+
18+
# The deadline within a slot (in basis points) for a proposer to publish a
19+
# block.
20+
#
21+
# Honest validators may re-org blocks published after this cutoff.
22+
#
23+
# (2500 bps = 25% of slot duration).
24+
PROPOSER_REORG_CUTOFF_BPS: Final = 2500
25+
26+
# The deadline within a slot (in basis points) by which validators must
27+
# submit their votes.
28+
#
29+
# (5000 bps = 50% of slot duration).
30+
VOTE_DUE_BPS: Final = 5000
31+
32+
# The deadline within a slot (in basis points) for achieving a fast
33+
# confirmation.
34+
#
35+
# (7500 bps = 75% of slot duration).
36+
FAST_CONFIRM_DUE_BPS: Final = 7500
37+
38+
# The cutoff within a slot (in basis points) after which the current view is
39+
# considered 'frozen', preventing further changes.
40+
#
41+
# (7500 bps = 75% of slot duration).
42+
VIEW_FREEZE_CUTOFF_BPS: Final = 7500
43+
44+
# --- State List Length Presets ---
45+
46+
# The maximum number of historical block roots to store in the state.
1847
#
19-
# A basis point (bps) is 1/100th of a percent. 100% = 10,000 bps.
20-
BasisPoint = Annotated[
21-
uint64,
22-
Field(le=10000, description="A value in basis points (1/10000)."),
23-
]
48+
# With a 4-second slot, this corresponds to a history
49+
# of approximately 12.1 days.
50+
HISTORICAL_ROOTS_LIMIT: Final = 2**18
2451

52+
# The maximum number of validators that can be in the registry.
53+
VALIDATOR_REGISTRY_LIMIT: Final = 2**12
2554

26-
class ChainConfig(BaseModel):
55+
56+
class _ChainConfig(BaseModel):
2757
"""
2858
A model holding the canonical, immutable configuration constants
2959
for the chain.
30-
31-
These parameters are considered "presets" and define the fundamental rules
32-
of the consensus protocol.
3360
"""
3461

3562
# Configuration to make the model immutable.
3663
model_config = ConfigDict(frozen=True, extra="forbid")
3764

38-
# =========================================================================
3965
# Time Parameters
40-
#
41-
# These constants define the timing and deadlines within a single slot.
42-
# =========================================================================
43-
44-
SLOT_DURATION_MS: uint64 = Field(
45-
default=4000,
46-
description="The fixed duration of a single slot in milliseconds.",
47-
)
48-
49-
PROPOSER_REORG_CUTOFF_BPS: BasisPoint = Field(
50-
default=2500,
51-
description=(
52-
"The deadline within a slot (in basis points) for a proposer to "
53-
"publish a block. Honest validators may re-org blocks published "
54-
"after this cutoff. (2500 bps = 25% of slot duration)."
55-
),
56-
)
57-
58-
VOTE_DUE_BPS: BasisPoint = Field(
59-
default=5000,
60-
description=(
61-
"The deadline within a slot (in basis points) by which validators "
62-
"must submit their votes. (5000 bps = 50% of slot duration)."
63-
),
64-
)
65-
66-
FAST_CONFIRM_DUE_BPS: BasisPoint = Field(
67-
default=7500,
68-
description=(
69-
"The deadline within a slot (in basis points) for achieving a "
70-
"fast confirmation. (7500 bps = 75% of slot duration)."
71-
),
72-
)
73-
74-
VIEW_FREEZE_CUTOFF_BPS: BasisPoint = Field(
75-
default=7500,
76-
description=(
77-
"The cutoff within a slot (in basis points) after which the "
78-
"current view is considered 'frozen', preventing further changes. "
79-
"(7500 bps = 75% of slot duration)."
80-
),
81-
)
82-
83-
# =========================================================================
66+
slot_duration_ms: uint64
67+
proposer_reorg_cutoff_bps: BasisPoint
68+
vote_due_bps: BasisPoint
69+
fast_confirm_due_bps: BasisPoint
70+
view_freeze_cutoff_bps: BasisPoint
71+
8472
# State List Length Presets
85-
#
86-
# These constants define the maximum capacity of certain data structures
87-
# within the consensus state, preventing unbounded growth.
88-
# =========================================================================
89-
90-
HISTORICAL_ROOTS_LIMIT: uint64 = Field(
91-
default=2**18,
92-
description=(
93-
"The maximum number of historical block roots to store in the "
94-
"state. With a 4-second slot, this corresponds to a history of "
95-
"approximately 12.1 days."
96-
),
97-
)
98-
99-
VALIDATOR_REGISTRY_LIMIT: uint64 = Field(
100-
default=2**12,
101-
description=(
102-
"The maximum number of validators that can be in the registry."
103-
),
104-
)
105-
106-
107-
# Global constant for the devnet chain configuration.
108-
DEVNET_CONFIG = ChainConfig()
73+
historical_roots_limit: uint64
74+
validator_registry_limit: uint64
75+
76+
77+
# The Devnet Chain Configuration.
78+
DEVNET_CONFIG: Final = _ChainConfig(
79+
slot_duration_ms=SLOT_DURATION_MS,
80+
proposer_reorg_cutoff_bps=PROPOSER_REORG_CUTOFF_BPS,
81+
vote_due_bps=VOTE_DUE_BPS,
82+
fast_confirm_due_bps=FAST_CONFIRM_DUE_BPS,
83+
view_freeze_cutoff_bps=VIEW_FREEZE_CUTOFF_BPS,
84+
historical_roots_limit=HISTORICAL_ROOTS_LIMIT,
85+
validator_registry_limit=VALIDATOR_REGISTRY_LIMIT,
86+
)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
"""Reusable type definitions for the Lean Ethereum specification."""
2+
3+
from .basispt import BasisPoint
4+
from .uint64 import uint64
5+
6+
__all__ = [
7+
"uint64",
8+
"BasisPoint",
9+
]
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
"""Basis Point Type Specification."""
2+
3+
from pydantic import Field
4+
from typing_extensions import Annotated
5+
6+
from ..types import uint64
7+
8+
# A type alias for basis points
9+
#
10+
# A basis point (bps) is 1/100th of a percent. 100% = 10,000 bps.
11+
BasisPoint = Annotated[
12+
uint64,
13+
Field(le=10000, description="A value in basis points (1/10000)."),
14+
]
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
"""Unsigned 64-bit Integer Type Specification."""
2+
3+
from pydantic import Field
4+
from typing_extensions import Annotated
5+
6+
# The maximum value for an unsigned 64-bit integer (2**64).
7+
UINT64_MAX = 2**64
8+
9+
# A type alias to represent a uint64.
10+
uint64 = Annotated[int, Field(ge=0, lt=UINT64_MAX)]

0 commit comments

Comments
 (0)