Skip to content

refactor(lstar): use math.ceil for 2/3 supermajority threshold#742

Open
tcoratger wants to merge 1 commit into
leanEthereum:mainfrom
tcoratger:refactor/lstar-min-target-score
Open

refactor(lstar): use math.ceil for 2/3 supermajority threshold#742
tcoratger wants to merge 1 commit into
leanEthereum:mainfrom
tcoratger:refactor/lstar-min-target-score

Conversation

@tcoratger
Copy link
Copy Markdown
Collaborator

Summary

  • Replace the -(-num_validators * 2 // 3) ceiling-division trick with math.ceil(int(num_validators) * 2 / 3).
  • The negation trick required the reader to recognise that flooring on a negated value yields a ceiling; math.ceil expresses the intent directly.
  • The int() cast keeps the multiplication out of the Uint64.__mul__ overload that rejects plain-int operands, and validator counts are capped well within float precision.

Test plan

  • ruff check src/lean_spec/forks/lstar/spec.py — clean.
  • Equivalence verified across n ∈ {0, 1, 2, 3, 99, 100, 101, 4096, 8192, 99999}.

🤖 Generated with Claude Code

Replace the -(-n * 2 // 3) ceiling-division trick with math.ceil.
The trick relied on the reader recognising that flooring on a
negated value yields a ceiling; math.ceil expresses the intent
directly. Validator counts are capped well within float precision,
and the int() cast keeps the multiplication out of the Uint64
operator that rejects plain-int operands.

Equivalence verified across n = 0, 1, 2, 3, 99..101, 4096, 8192,
99999.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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