basics/pda-rent-payer: create_new_account has no caller check — worth a note for people copying it?
Maintainer thường phản hồi trong vòng 1 ngày
@khoap1220-hue đang làm issue này rồi.
Từ ngày 25/10/2026.
Đánh giá
- Độ khó
- 1/5
- Thời gian dự kiến
- Dưới một giờ
- Mức phù hợp với người mới
- 78/100
- Loại issue
- Tài liệu
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Công nghệ
- blockchain, rust
- Lĩnh vực
- documentation, security
Hướng nghiên cứu
Bắt đầu trong basics/pda-rent-payer tại accounts struct của create_new_account, sau đó so sánh hướng dẫn về Authority trong basics/checking-accounts. Chỉ thêm bình luận giải thích hoặc tham chiếu chéo đã được thống nhất, đồng thời giữ nguyên hành vi cố ý không hạn chế của ví dụ; hoàn thành khi giới hạn của caller-check và các phương án thay thế an toàn hơn trong thực tế đã rõ ràng với người đọc.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
create_new_account spends from a program-owned vault, and nothing in the
instruction constrains who may call it.
The accounts struct is:
pub struct CreateNewAccount<'info> {
#[account(mut)]
new_account: Signer<'info>,
#[account(mut, seeds = [b"rent_vault"], bump)]
rent_vault: SystemAccount<'info>,
system_program: Program<'info, System>,
}
new_account is a Signer, but it signs for itself — it is the account being
created, and the caller generates that keypair. rent_vault is a PDA on a
single literal seed, shared by everyone. So there is no authority account and
no has_one, and each call moves one rent-exempt minimum out of the shared
vault into an account the caller controls.
That is almost certainly intentional for the example's purpose — it exists to
show a PDA signing for itself, and it does that cleanly and readably. My
question is only about the people who copy it, since a rent vault is exactly
the kind of helper that gets lifted into a real program.
Would a short comment on the accounts struct be welcome? Something like:
// NOTE: this example does not restrict who may call it. A real rent vault
// needs an authority check — a `has_one` against an admin recorded at
// initialisation, seeds that bind the vault to one funder, or a per-caller
// limit. (A bare `authority: Signer` alone is not enough — any keypair
// can sign for itself.)
Happy to open a PR with just that comment if it's useful. I did not want to add
a constraint, since that would change what the example teaches.
For context: basics/checking-accounts is the example that teaches exactly this
check, so a pointer between the two might do the job on its own.
- Ngôn ngữ chính
- Rust
- Star
- 1.4k
- Fork
- 559
- Merge trung bình
- 20 giờ 9 phút
- Pull request đã merge (30 ngày)
- 17
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của solana-foundation/program-examples
-
Migrate deprecated .accounts() to .accountsPartial() in Anchor testsCó thể làm lại được @ankittiwari-04 đã nhận 24 ngày trước và không có pull request nào đang mở. Đang mởaccepted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
solana-foundation/program-examples#747 · 4 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
native/pinocchio examples: deploy script points at program.so, which the build never producesCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mởaccepted
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 35/100
solana-foundation/program-examples#787 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
token-2022/cpi-guard: add a Pinocchio versionCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mởaccepted
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 20/100
solana-foundation/program-examples#786 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
token-2022/memo-transfer: add a Pinocchio versionCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mởaccepted
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 30/100
solana-foundation/program-examples#785 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
token-swap: later deposits can dilute LPs after fee growthCó thể đã có người làm @Bismithblde đã nhận 2 ngày trước. Đang mởaccepted
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
solana-foundation/program-examples#783 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của solana-foundation/program-examples
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
RustCrypto/utils#1597 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Non-`main` default branchesĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
max-sixty/worktrunk#4727 · 7 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
Maintainer thường phản hồi trong vòng 1 ngày
-
follow-up
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
carrick-sh/carrick#1859 ·
Maintainer thường phản hồi trong vòng 1 ngày