File tree Expand file tree Collapse file tree
src/lean_spec/subspecs/forkchoice
tests/consensus/devnet/fc Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1616
1717from lean_spec .subspecs .chain .config import (
1818 INTERVALS_PER_SLOT ,
19+ JUSTIFICATION_LOOKBACK_SLOTS ,
1920 SECONDS_PER_INTERVAL ,
2021 SECONDS_PER_SLOT ,
2122)
@@ -725,7 +726,8 @@ def get_attestation_target(self) -> Checkpoint:
725726 ensuring the target is in a justifiable slot range:
726727
727728 1. **Start at Head**: Begin with the current head block
728- 2. **Walk Toward Safe**: Move backward (up to 3 steps) if safe target is newer
729+ 2. **Walk Toward Safe**: Move backward (up to `JUSTIFICATION_LOOKBACK_SLOTS` steps)
730+ if safe target is newer
729731 3. **Ensure Justifiable**: Continue walking back until slot is justifiable
730732 4. **Return Checkpoint**: Create checkpoint from selected block
731733
@@ -745,11 +747,11 @@ def get_attestation_target(self) -> Checkpoint:
745747 # Start from current head
746748 target_block_root = self .head
747749
748- # Walk back toward safe target (up to 3 steps)
750+ # Walk back toward safe target (up to `JUSTIFICATION_LOOKBACK_SLOTS` steps)
749751 #
750752 # This ensures the target doesn't advance too far ahead of safe target,
751753 # providing a balance between liveness and safety.
752- for _ in range (3 ):
754+ for _ in range (JUSTIFICATION_LOOKBACK_SLOTS ):
753755 if self .blocks [target_block_root ].slot > self .blocks [self .safe_target ].slot :
754756 target_block_root = self .blocks [target_block_root ].parent_root
755757
Original file line number Diff line number Diff line change @@ -313,7 +313,7 @@ def test_attestation_target_justifiable_constraint(
313313 Justifiability Rules (see Slot.is_justifiable_after)
314314 -----------------------------------------------------
315315
316- The target starts from current head and walks back at most 3 slots towards safe target.
316+ The target starts from current head and looks back at most 3 slots towards safe target.
317317
318318 Then, a slot is deemed justifiable at distance delta from finalization if:
319319 1. delta ≤ 5
You can’t perform that action at this time.
0 commit comments