token-fundraiser: large valid targets cause contribution-limit overflow
维护者通常 1 天内回复
还没有人认领这个 Issue。
- #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 分钟
- 30 天内合并 PR
- 19
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
solana-foundation/program-examples 的其他 Issue
-
Migrate deprecated .accounts() to .accountsPartial() in Anchor tests可能重新可做 @ankittiwari-04 于 27 天前认领,目前没有进行中的 PR。 未关闭accepted
难度 2/5 1-3 小时 新手友好度 75/100
solana-foundation/program-examples#747 · 4 条评论 ·
维护者通常 1 天内回复
-
basics/pda-rent-payer: create_new_account has no caller check — worth a note for people copying it?可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 1/5 1 小时以内 新手友好度 78/100
solana-foundation/program-examples#671 · 3 条评论 ·
维护者通常 1 天内回复
-
native/pinocchio examples: deploy script points at program.so, which the build never produces可能已有人在做 @MarkFeder 今天认领。 未关闭accepted
难度 1/5 1 小时以内 新手友好度 35/100
solana-foundation/program-examples#787 ·
维护者通常 1 天内回复
-
token-2022/cpi-guard: add a Pinocchio version可能已有人在做 @MarkFeder 今天认领。 未关闭accepted
难度 3/5 1-2 天 新手友好度 20/100
solana-foundation/program-examples#786 ·
维护者通常 1 天内回复
-
token-2022/memo-transfer: add a Pinocchio version可能已有人在做 @MarkFeder 今天认领。 未关闭accepted
难度 4/5 3-5 天 新手友好度 30/100
solana-foundation/program-examples#785 · 1 条评论 ·
维护者通常 1 天内回复
查看 solana-foundation/program-examples 的全部 Issue
相似的 Issue
-
SPLADE `/embed_sparse` output depends on the other inputs in the batch (candle BertModel / DistilBertModel)可能已有人在做 @0z5a 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
huggingface/text-embeddings-inference#979 ·
维护者通常 1 天内回复
-
good first issue help wanted
难度 2/5 1-3 小时 新手友好度 78/100
servo/rust-smallvec#874 ·
-
难度 1/5 1 小时以内 新手友好度 94/100
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 65/100
维护者通常 2 天内回复
-
ci enhancement need-triage
难度 2/5 1-3 小时 新手友好度 86/100
维护者通常 1 天内回复