Skip to content

fix(fundraiser): avoid overflow in contribution limits - #791

Closed
Bismithblde wants to merge 1 commit into
solana-foundation:mainfrom
Bismithblde:fix/fundraiser-contribution-overflow
Closed

Bismithblde wants to merge 1 commit into
solana-foundation:mainfrom
Bismithblde:fix/fundraiser-contribution-overflow

Conversation

@Bismithblde

Copy link
Copy Markdown

Linked issue

Fixes #790

What and why

A fundraiser target above u64::MAX / 10 is accepted at initialization, but even a one-token contribution panics when calculating target * 10 / 100 in u64.

Calculate the contribution limit once in u128 and reuse it for both contribution checks. Widen the cumulative comparison as well. The existing 10% cap and rounding are preserved. Update the README's embedded implementation.

Testing

  • Both existing fundraiser integration tests passed before the change.
  • Added a LiteSVM regression which failed against the original SBF program with attempt to multiply with overflow.
  • The regression tests u64::MAX / 10 + 1 and u64::MAX, small contributions, the exact cumulative cap, over-limit rejections, token balances and recorded totals.
  • Rebuilt using NO_DNA=1 cargo build-sbf --manifest-path programs/fundraiser/Cargo.toml --sbf-out-dir target/deploy --tools-version v1.57 --arch v3.
  • cargo test with the shared local target directory passed all three fundraiser integration tests.
  • git diff --check passed.

AI disclosure

  • No AI tooling was used beyond editor autocomplete.
  • AI tooling was used. Tool and extent: OpenAI Codex investigated and reproduced the overflow, wrote the fix, regression test and README update, and ran the listed checks.

@github-actions github-actions Bot added the needs-issue PR does not reference an issue a maintainer has accepted label Nov 9, 2026
@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Hi @Bismithblde,

Thanks for the pull request. We ask that every change references an issue a maintainer has accepted, and there isn't one linked here.

These examples are a teaching resource and each one has to stay small enough to read in one sitting, so whether a new example or framework flavor belongs here is worth settling before anyone writes it. Agreeing on the approach in an issue first means nobody writes code that can't be merged. See CONTRIBUTING.md for the full workflow.

Please open an issue describing the change, or comment on the existing one. Once a maintainer has labelled it accepted, put Fixes #<issue> in this description and reopen this pull request; the check runs again and clears itself. Typos, broken links and comment-only fixes are exempt: write Linked issue: trivial instead.

@github-actions github-actions Bot closed this Nov 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-issue PR does not reference an issue a maintainer has accepted

Projects

None yet

Development

Successfully merging this pull request may close these issues.

token-fundraiser: large valid targets cause contribution-limit overflow

1 participant