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

v1.17: Upgrade sbf tests to use bpf loader v3 (backport of #34691) #35162

Merged
merged 5 commits into from
Feb 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion programs/sbf/benches/bpf_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ fn bench_program_create_executable(bencher: &mut Bencher) {
}

#[bench]
#[ignore]
fn bench_program_alu(bencher: &mut Bencher) {
let ns_per_s = 1000000000;
let one_million = 1000000;
Expand All @@ -118,13 +119,18 @@ fn bench_program_alu(bencher: &mut Bencher) {
true,
false,
);
#[allow(unused_mut)]
let mut executable =
Executable::<InvokeContext>::from_elf(&elf, Arc::new(program_runtime_environment.unwrap()))
.unwrap();

executable.verify::<RequisiteVerifier>().unwrap();

executable.jit_compile().unwrap();
#[cfg(all(not(target_os = "windows"), target_arch = "x86_64"))]
{
executable.jit_compile().unwrap();
}

create_vm!(
vm,
&executable,
Expand Down Expand Up @@ -181,6 +187,7 @@ fn bench_program_alu(bencher: &mut Bencher) {
}

#[bench]
#[ignore]
fn bench_program_execute_noop(bencher: &mut Bencher) {
let GenesisConfigInfo {
mut genesis_config,
Expand Down
11 changes: 6 additions & 5 deletions programs/sbf/c/src/invoked/invoked.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ extern uint64_t entrypoint(const uint8_t *input) {
static const int INVOKED_PROGRAM_DUP_INDEX = 3;
sol_assert(sol_deserialize(input, &params, 4));

SolPubkey sbf_loader_id =
(SolPubkey){.x = {2, 168, 246, 145, 78, 136, 161, 110, 57, 90, 225,
40, 148, 143, 250, 105, 86, 147, 55, 104, 24, 221,
71, 67, 82, 33, 243, 198, 0, 0, 0, 0}};
SolPubkey sbf_loader_upgradeable_id =
(SolPubkey){.x = {
2, 168, 246, 145, 78, 136, 161, 176, 226, 16, 21, 62,
247, 99, 174, 43, 0, 194, 185, 61, 22, 193, 36, 210, 192,
83, 122, 16, 4, 128, 0, 0}};

for (int i = 0; i < params.data_len; i++) {
sol_assert(params.data[i] == i);
Expand Down Expand Up @@ -63,7 +64,7 @@ extern uint64_t entrypoint(const uint8_t *input) {
sol_assert(
SolPubkey_same(accounts[INVOKED_PROGRAM_INDEX].key, params.program_id))
sol_assert(SolPubkey_same(accounts[INVOKED_PROGRAM_INDEX].owner,
&sbf_loader_id));
&sbf_loader_upgradeable_id));
sol_assert(!accounts[INVOKED_PROGRAM_INDEX].is_signer);
sol_assert(!accounts[INVOKED_PROGRAM_INDEX].is_writable);
sol_assert(accounts[INVOKED_PROGRAM_INDEX].rent_epoch == UINT64_MAX);
Expand Down
2 changes: 1 addition & 1 deletion programs/sbf/c/src/read_program/read_program.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ extern uint64_t entrypoint(const uint8_t *input) {
return ERROR_INVALID_ARGUMENT;
}

char ka_data[] = {0x7F, 0x45, 0x4C, 0x46};
char ka_data[] = {0x02, 0x00, 0x00, 0x00};

sol_assert(params.ka_num == 1);
sol_assert(!sol_memcmp(params.ka[0].data, ka_data, 4));
Expand Down
7 changes: 5 additions & 2 deletions programs/sbf/rust/invoked/src/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use {
crate::instructions::*,
solana_program::{
account_info::AccountInfo,
bpf_loader,
bpf_loader_upgradeable,
entrypoint::{ProgramResult, MAX_PERMITTED_DATA_INCREASE},
log::sol_log_64,
msg,
Expand Down Expand Up @@ -70,7 +70,10 @@ fn process_instruction(
assert!(!accounts[INVOKED_ARGUMENT_INDEX].executable);

assert_eq!(accounts[INVOKED_PROGRAM_INDEX].key, program_id);
assert_eq!(accounts[INVOKED_PROGRAM_INDEX].owner, &bpf_loader::id());
assert_eq!(
accounts[INVOKED_PROGRAM_INDEX].owner,
&bpf_loader_upgradeable::id()
);
assert!(!accounts[INVOKED_PROGRAM_INDEX].is_signer);
assert!(!accounts[INVOKED_PROGRAM_INDEX].is_writable);
assert_eq!(accounts[INVOKED_PROGRAM_INDEX].rent_epoch, u64::MAX);
Expand Down
Loading
Loading