2021-10-19 16:48:15 -05:00
|
|
|
//! Example Rust-based BPF sanity program that finalizes a BPF program
|
2021-03-04 12:34:36 -08:00
|
|
|
|
|
|
|
#![allow(unreachable_code)]
|
|
|
|
|
|
|
|
extern crate solana_program;
|
|
|
|
use solana_program::{
|
2022-02-22 11:59:06 +08:00
|
|
|
account_info::AccountInfo, bpf_loader, entrypoint::ProgramResult, loader_instruction, msg,
|
|
|
|
program::invoke, pubkey::Pubkey,
|
2021-03-04 12:34:36 -08:00
|
|
|
};
|
|
|
|
|
2022-02-22 11:59:06 +08:00
|
|
|
solana_program::entrypoint!(process_instruction);
|
2021-03-04 12:34:36 -08:00
|
|
|
fn process_instruction(
|
|
|
|
_program_id: &Pubkey,
|
|
|
|
accounts: &[AccountInfo],
|
|
|
|
_instruction_data: &[u8],
|
|
|
|
) -> ProgramResult {
|
|
|
|
msg!("Finalize a program");
|
|
|
|
invoke(
|
|
|
|
&loader_instruction::finalize(&accounts[0].key.clone(), &bpf_loader::id()),
|
|
|
|
accounts,
|
|
|
|
)?;
|
|
|
|
msg!("check executable");
|
|
|
|
assert!(accounts[0].executable);
|
|
|
|
Ok(())
|
|
|
|
}
|