Skip to content

fix: clamp attestation target walk to finalized boundary#818

Draft
latifkasuli wants to merge 1 commit into
leanEthereum:mainfrom
latifkasuli:fix/stale-safe-target-finalization
Draft

fix: clamp attestation target walk to finalized boundary#818
latifkasuli wants to merge 1 commit into
leanEthereum:mainfrom
latifkasuli:fix/stale-safe-target-finalization

Conversation

@latifkasuli
Copy link
Copy Markdown
Contributor

Summary

Fixes an Lstar attestation-target boundary bug where get_attestation_target() could walk below the latest finalized checkpoint when safe_target was stale behind finalization.

The target-selection walk now uses max(safe_target.slot, latest_finalized.slot) as its lower bound, and the justifiability walk stops at the finalized boundary before calling is_justifiable_after().

Root Cause

safe_target can legally lag behind latest_finalized. In that state, the previous implementation walked backward from head toward the stale safe target, crossed below the finalized slot, and then called:

slot.is_justifiable_after(latest_finalized.slot)

on a candidate slot before finalization. That violates the slot helper invariant and raises:

Candidate slot must not be before finalized slot

Validation

  • Pre-fix targeted regression fails with Candidate slot must not be before finalized slot
  • uv run --group test pytest tests/lean_spec/spec/forks/lstar/forkchoice/test_attestation_target.py -q --no-cov
  • uv run --group test pytest tests/lean_spec/spec/forks/lstar/forkchoice/test_block_production_justification_gap.py tests/lean_spec/spec/forks/lstar/state -q --no-cov
  • uv run --group lint ruff check src/lean_spec/spec/forks/lstar/spec.py tests/lean_spec/spec/forks/lstar/forkchoice/test_attestation_target.py
  • uv run --group lint ruff format --check src/lean_spec/spec/forks/lstar/spec.py tests/lean_spec/spec/forks/lstar/forkchoice/test_attestation_target.py
  • uv run --group lint ty check src/lean_spec/spec/forks/lstar/spec.py tests/lean_spec/spec/forks/lstar/forkchoice/test_attestation_target.py
  • git diff --check

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant