refactor: use UintBn64 for Eth1Data.depositCount - #9747
Conversation
🤖 Generated with AI assistance Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2748289f4f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // proposer-chosen values above 2**53. The number of deposits actually processed is always within | ||
| // safe-integer range (bounded by MAX_DEPOSITS and the real deposit index), so narrow to a number | ||
| // for the arithmetic below. | ||
| const depositCount = Number(eth1DataToUse.depositCount); |
There was a problem hiding this comment.
Keep deposit-count arithmetic in bigint until clamping
For valid uint64 values near the safe-integer boundary, this conversion changes the consensus result before MAX_DEPOSITS is applied. For example, with depositCount = 9007199254740993n and eth1DepositIndex = 9007199254740992, the spec subtraction yields one pending deposit, but Number(depositCount) rounds down and this function returns zero. Perform the comparison and subtraction as bigint, clamp to MAX_DEPOSITS, and only then convert the bounded result to number.
AGENTS.md reference: AGENTS.md:L434-L435
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Good catch — done in dc14727. Moved the comparison and subtraction to bigint and narrow only the final MAX_DEPOSITS-bounded result to a number, so a depositCount above 2**53 can no longer change the count through float rounding.
🤖 Generated with AI assistance Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…until MAX_DEPOSITS clamp Addresses Codex review: convert to number only after clamping, so a depositCount above 2**53 cannot change the consensus-enforced count. 🤖 Generated with AI assistance Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
No description provided.