Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Struct field "system_program" is unsafe, but is not documented. #8

Open
bluestar0505 opened this issue Apr 23, 2022 · 1 comment
Open

Comments

@bluestar0505
Copy link

bluestar0505 commented Apr 23, 2022

Anchor:
anchor-cli 0.24.2
Rust:
rustc 1.60.0 (7737e0b5c 2022-04-04)

`yokoiakiomini2@yokoiakiomini2s-Mac-mini solana-twitter % anchor build                                               
BPF SDK: /Users/yokoiakiomini2/.local/share/solana/install/releases/1.10.8/solana-release/bin/sdk/bpf
cargo-build-bpf child: rustup toolchain list -v
cargo-build-bpf child: cargo +bpf build --target bpfel-unknown-unknown --release
   Compiling solana-twitter v0.1.0 (/Volumes/Data/04_OutSourcing/Github/solana-reference/Anchor/solana-twitter/programs/solana-twitter)
    Finished release [optimized] target(s) in 6.48s
cargo-build-bpf child: /Users/yokoiakiomini2/.local/share/solana/install/releases/1.10.8/solana-release/bin/sdk/bpf/scripts/strip.sh /Volumes/Data/04_OutSourcing/Github/solana-reference/Anchor/solana-twitter/target/bpfel-unknown-unknown/release/solana_twitter.so /Volumes/Data/04_OutSourcing/Github/solana-reference/Anchor/solana-twitter/target/deploy/solana_twitter.so
cargo-build-bpf child: /Users/yokoiakiomini2/.local/share/solana/install/releases/1.10.8/solana-release/bin/sdk/bpf/dependencies/bpf-tools/llvm/bin/llvm-readelf --dyn-symbols /Volumes/Data/04_OutSourcing/Github/solana-reference/Anchor/solana-twitter/target/deploy/solana_twitter.so

To deploy this program:
  $ solana program deploy /Volumes/Data/04_OutSourcing/Github/solana-reference/Anchor/solana-twitter/target/deploy/solana_twitter.so
The program address will default to this keypair (override with --program-id):
  /Volumes/Data/04_OutSourcing/Github/solana-reference/Anchor/solana-twitter/target/deploy/solana_twitter-keypair.json
Error: 
        /Volumes/Data/04_OutSourcing/Github/solana-reference/Anchor/solana-twitter/programs/solana-twitter/src/lib.rs:28:8
        Struct field "system_program" is unsafe, but is not documented.
        Please add a `/// CHECK:` doc comment explaining why no checks through types are necessary.
        See https://book.anchor-lang.com/chapter_3/the_accounts_struct.html#safety-checks for more information.
@bluestar0505
Copy link
Author

EDIT 2022-03-22: In newer versions of Anchor, we can achieve the same result by using yet another type of account called Program and passing it the System type to ensure it is the official System program.

#[derive(Accounts)]
pub struct SendTweet<'info> {
    // ...
    pub system_program: Program<'info, System>,
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant