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

オープン 初心者向け
#790 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

  • #791 @Bismithblde による — マージされずにクローズ

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
82/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
rust
領域
blockchain

調査の方向性

まず programs/fundraiser/src/instructions/contribute.rs:67 を確認してください。ここでは貢献者ごとの上限がオーバーフローしており、その上限がトランザクションと累積貢献のチェックでどのように再利用されるかを調べてください。対象値 u64::MAX / 10 + 1 と u64::MAX について LiteSVM の回帰テストを追加または実行してください。上限ちょうどの貢献が成功し、上限を超える貢献が失敗し、残高と記録された貢献額が正しいことを完了条件とします。

索引モデルが issue の本文から書いたものです。

説明

Problem

The Anchor fundraiser accepts u64 fundraising targets, but calculating the per-contributor 10% limit uses u64 multiplication before division. For a target greater than u64::MAX / 10, target * 10 overflows and contributions panic, even when the contribution is small and the final limit fits in u64.

Reproduction

A Rust LiteSVM integration test creates a six-decimal mint, initializes a fundraiser with a target of u64::MAX / 10 + 1, then contributes 1,000,000 base units (one token).

Initialization succeeds. The contribution fails with attempt to multiply with overflow at programs/fundraiser/src/instructions/contribute.rs:67.

The same issue affects a target of u64::MAX. The existing initialization instruction accepts both values.

Proposed fix

Calculate the percentage once in u128 and reuse it for the per-transaction and cumulative contributor limits. Compare the cumulative contribution in u128 as well. This preserves the 10% policy and integer rounding.

The regression fails against the original program and passes after the fix. It covers both targets, acceptance up to the exact cap, rejection above the cap, and resulting balances and recorded contributions. All three fundraiser integration tests pass locally.

主要言語
Rust
スター
1.4k
フォーク
562
平均マージ
23時間 5分
マージ済み PR(30日)
19

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

solana-foundation/program-examples のほかの issue

solana-foundation/program-examples の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。