* Add BPF test program instruction monitoring (#11984)
(cherry picked from commit fab2d44abd
)
* fix conflicts
Co-authored-by: Jack May <jack@solana.com>
This commit is contained in:
@ -35,7 +35,7 @@ fn rerun_if_changed(files: &[&str], directories: &[&str], excludes: &[&str]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let bpf_c = !env::var("CARGO_FEATURE_BPF_C").is_err();
|
let bpf_c = env::var("CARGO_FEATURE_BPF_C").is_ok();
|
||||||
if bpf_c {
|
if bpf_c {
|
||||||
let install_dir =
|
let install_dir =
|
||||||
"OUT_DIR=../target/".to_string() + &env::var("PROFILE").unwrap() + &"/bpf".to_string();
|
"OUT_DIR=../target/".to_string() + &env::var("PROFILE").unwrap() + &"/bpf".to_string();
|
||||||
@ -52,7 +52,7 @@ fn main() {
|
|||||||
rerun_if_changed(&["c/makefile"], &["c/src", "../../sdk"], &["/target/"]);
|
rerun_if_changed(&["c/makefile"], &["c/src", "../../sdk"], &["/target/"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
let bpf_rust = !env::var("CARGO_FEATURE_BPF_RUST").is_err();
|
let bpf_rust = env::var("CARGO_FEATURE_BPF_RUST").is_ok();
|
||||||
if bpf_rust {
|
if bpf_rust {
|
||||||
let install_dir =
|
let install_dir =
|
||||||
"target/".to_string() + &env::var("PROFILE").unwrap() + &"/bpf".to_string();
|
"target/".to_string() + &env::var("PROFILE").unwrap() + &"/bpf".to_string();
|
||||||
@ -100,7 +100,7 @@ fn main() {
|
|||||||
.arg(&src)
|
.arg(&src)
|
||||||
.arg(&install_dir)
|
.arg(&install_dir)
|
||||||
.status()
|
.status()
|
||||||
.expect(&format!("Failed to cp {} to {}", src, install_dir))
|
.unwrap_or_else(|_| panic!("Failed to cp {} to {}", src, install_dir))
|
||||||
.success());
|
.success());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,8 +26,7 @@ use solana_sdk::{
|
|||||||
instruction::{AccountMeta, CompiledInstruction, Instruction, InstructionError},
|
instruction::{AccountMeta, CompiledInstruction, Instruction, InstructionError},
|
||||||
message::Message,
|
message::Message,
|
||||||
pubkey::Pubkey,
|
pubkey::Pubkey,
|
||||||
signature::Keypair,
|
signature::{Keypair, Signer},
|
||||||
signature::Signer,
|
|
||||||
sysvar::{clock, fees, rent, rewards, slot_hashes, stake_history},
|
sysvar::{clock, fees, rent, rewards, slot_hashes, stake_history},
|
||||||
transaction::TransactionError,
|
transaction::TransactionError,
|
||||||
};
|
};
|
||||||
@ -84,7 +83,7 @@ fn run_program(
|
|||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let mut parameter_bytes = serialize_parameters(
|
let mut parameter_bytes = serialize_parameters(
|
||||||
&bpf_loader::id(),
|
&loader_id,
|
||||||
program_id,
|
program_id,
|
||||||
parameter_accounts,
|
parameter_accounts,
|
||||||
&instruction_data,
|
&instruction_data,
|
||||||
@ -95,7 +94,7 @@ fn run_program(
|
|||||||
vm.execute_program(parameter_bytes.as_mut_slice(), &[], &[heap_region.clone()])
|
vm.execute_program(parameter_bytes.as_mut_slice(), &[], &[heap_region.clone()])
|
||||||
.unwrap()
|
.unwrap()
|
||||||
);
|
);
|
||||||
deserialize_parameters(&bpf_loader::id(), parameter_accounts, ¶meter_bytes).unwrap();
|
deserialize_parameters(&loader_id, parameter_accounts, ¶meter_bytes).unwrap();
|
||||||
Ok(vm.get_total_instruction_count())
|
Ok(vm.get_total_instruction_count())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user