Skip to content

refactor: use UintBn64 for Eth1Data.depositCount - #9747

Open
lodekeeper wants to merge 6 commits into
ChainSafe:unstablefrom
lodekeeper:fix/eth1-deposit-count-uintbn64
Open

refactor: use UintBn64 for Eth1Data.depositCount#9747
lodekeeper wants to merge 6 commits into
ChainSafe:unstablefrom
lodekeeper:fix/eth1-deposit-count-uintbn64

Conversation

@lodekeeper

Copy link
Copy Markdown
Contributor

No description provided.

🤖 Generated with AI assistance

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@nflaig nflaig changed the title fix(types): use UintBn64 for Eth1Data.depositCount fix: use UintBn64 for Eth1Data.depositCount Aug 2, 2026
@nflaig
nflaig marked this pull request as ready for review August 2, 2026 15:49
@nflaig
nflaig requested a review from a team as a code owner August 2, 2026 15:49
@nflaig nflaig changed the title fix: use UintBn64 for Eth1Data.depositCount refactor: use UintBn64 for Eth1Data.depositCount Aug 2, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

lodekeeper and others added 5 commits August 2, 2026 16:11
🤖 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants