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

Add BPF Loader 2 to cache #19

Merged
merged 3 commits into from
Jun 26, 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
16 changes: 14 additions & 2 deletions harness/src/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl ProgramCache {
&self.cache
}

/// Add a program to a program cache.
/// Add a program to the cache.
pub fn add_program(
&mut self,
program_id: &Pubkey,
Expand Down Expand Up @@ -70,9 +70,16 @@ impl ProgramCache {
),
);
}

/// Add a builtin program to the cache.
pub fn add_builtin(&mut self, builtin: Builtin) {
let program_id = builtin.program_id;
let entry = builtin.program_cache_entry();
self.cache.replenish(program_id, entry);
}
}

struct Builtin {
pub struct Builtin {
program_id: Pubkey,
name: &'static str,
entrypoint: BuiltinFunctionWithContext,
Expand All @@ -94,6 +101,11 @@ static BUILTINS: &[Builtin] = &[
name: "system_program",
entrypoint: solana_system_program::system_processor::Entrypoint::vm,
},
Builtin {
program_id: bpf_loader::id(),
name: "solana_bpf_loader_program",
entrypoint: solana_bpf_loader_program::Entrypoint::vm,
},
Builtin {
program_id: bpf_loader_upgradeable::id(),
name: "solana_bpf_loader_upgradeable_program",
Expand Down
4 changes: 4 additions & 0 deletions scripts/build-test-programs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

cargo build-sbf --manifest-path test-programs/cpi-target/Cargo.toml
cargo build-sbf --manifest-path test-programs/primary/Cargo.toml
Loading