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
55 changes: 4 additions & 51 deletions src/lean_spec/subspecs/chain/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,14 @@

from typing_extensions import Final

from lean_spec.types import BasisPoint, StrictBaseModel, Uint64
from lean_spec.types import StrictBaseModel, Uint64

# --- Time Parameters ---

INTERVALS_PER_SLOT = Uint64(4)
"""Number of intervals per slot for forkchoice processing."""

SLOT_DURATION_MS: Final = Uint64(4000)
"""The fixed duration of a single slot in milliseconds."""

SECONDS_PER_SLOT: Final = SLOT_DURATION_MS // Uint64(1000)
SECONDS_PER_SLOT: Final = Uint64(4)
"""The fixed duration of a single slot in seconds."""

SECONDS_PER_INTERVAL = SECONDS_PER_SLOT // INTERVALS_PER_SLOT
Expand All @@ -26,40 +23,6 @@
JUSTIFICATION_LOOKBACK_SLOTS: Final = Uint64(3)
"""The number of slots to lookback for justification."""

PROPOSER_REORG_CUTOFF_BPS: Final = Uint64(2500)
"""
The deadline within a slot (in basis points) for a proposer to publish a
block.

Honest validators may re-org blocks published after this cutoff.

(2500 bps = 25% of slot duration).
"""

VOTE_DUE_BPS: Final = Uint64(5000)
"""
The deadline within a slot (in basis points) by which validators must
submit their votes.

(5000 bps = 50% of slot duration).
"""

FAST_CONFIRM_DUE_BPS: Final = Uint64(7500)
"""
The deadline within a slot (in basis points) for achieving a fast
confirmation.

(7500 bps = 75% of slot duration).
"""

VIEW_FREEZE_CUTOFF_BPS: Final = Uint64(7500)
"""
The cutoff within a slot (in basis points) after which the current view is
considered 'frozen', preventing further changes.

(7500 bps = 75% of slot duration).
"""

# --- State List Length Presets ---

HISTORICAL_ROOTS_LIMIT: Final = Uint64(2**18)
Expand All @@ -81,13 +44,8 @@ class _ChainConfig(StrictBaseModel):
"""

# Time Parameters
slot_duration_ms: Uint64
second_per_slot: Uint64
seconds_per_slot: Uint64
justification_lookback_slots: Uint64
proposer_reorg_cutoff_bps: BasisPoint
vote_due_bps: BasisPoint
fast_confirm_due_bps: BasisPoint
view_freeze_cutoff_bps: BasisPoint

# State List Length Presets
historical_roots_limit: Uint64
Expand All @@ -96,13 +54,8 @@ class _ChainConfig(StrictBaseModel):

# The Devnet Chain Configuration.
DEVNET_CONFIG: Final = _ChainConfig(
slot_duration_ms=SLOT_DURATION_MS,
second_per_slot=SECONDS_PER_SLOT,
seconds_per_slot=SECONDS_PER_SLOT,
justification_lookback_slots=JUSTIFICATION_LOOKBACK_SLOTS,
proposer_reorg_cutoff_bps=PROPOSER_REORG_CUTOFF_BPS,
vote_due_bps=VOTE_DUE_BPS,
fast_confirm_due_bps=FAST_CONFIRM_DUE_BPS,
view_freeze_cutoff_bps=VIEW_FREEZE_CUTOFF_BPS,
historical_roots_limit=HISTORICAL_ROOTS_LIMIT,
validator_registry_limit=VALIDATOR_REGISTRY_LIMIT,
)
2 changes: 1 addition & 1 deletion src/lean_spec/subspecs/networking/gossipsub/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class GossipsubParameters(StrictBaseModel):
"""The number of history windows to gossip about."""

seen_ttl_secs: int = (
DEVNET_CONFIG.second_per_slot.as_int()
DEVNET_CONFIG.seconds_per_slot.as_int()
* DEVNET_CONFIG.justification_lookback_slots.as_int()
* 2
)
Expand Down
Loading