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

Feature - Loader built-in program v4 #30464

Merged
merged 3 commits into from
Mar 23, 2023
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
13 changes: 13 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ members = [
"programs/compute-budget",
"programs/config",
"programs/ed25519-tests",
"programs/loader-v3",
"programs/stake",
"programs/vote",
"programs/zk-token-proof",
Expand Down
10 changes: 7 additions & 3 deletions program-runtime/src/loaded_programs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use {
vm::{BuiltInProgram, VerifiedExecutable},
},
solana_sdk::{
bpf_loader, bpf_loader_deprecated, bpf_loader_upgradeable, clock::Slot, pubkey::Pubkey,
saturating_add_assign,
bpf_loader, bpf_loader_deprecated, bpf_loader_upgradeable, clock::Slot, loader_v3,
pubkey::Pubkey, saturating_add_assign,
},
std::{
collections::HashMap,
Expand Down Expand Up @@ -61,7 +61,7 @@ pub enum LoadedProgramType {
Invalid,
LegacyV0(VerifiedExecutable<RequisiteVerifier, InvokeContext<'static>>),
LegacyV1(VerifiedExecutable<RequisiteVerifier, InvokeContext<'static>>),
// Typed(TypedProgram<InvokeContext<'static>>),
Typed(VerifiedExecutable<RequisiteVerifier, InvokeContext<'static>>),
BuiltIn(BuiltInProgram<InvokeContext<'static>>),
}

Expand All @@ -71,6 +71,7 @@ impl Debug for LoadedProgramType {
LoadedProgramType::Invalid => write!(f, "LoadedProgramType::Invalid"),
LoadedProgramType::LegacyV0(_) => write!(f, "LoadedProgramType::LegacyV0"),
LoadedProgramType::LegacyV1(_) => write!(f, "LoadedProgramType::LegacyV1"),
LoadedProgramType::Typed(_) => write!(f, "LoadedProgramType::Typed"),
LoadedProgramType::BuiltIn(_) => write!(f, "LoadedProgramType::BuiltIn"),
}
}
Expand Down Expand Up @@ -143,6 +144,8 @@ impl LoadedProgram {
LoadedProgramType::LegacyV0(VerifiedExecutable::from_executable(executable)?)
} else if bpf_loader::check_id(loader_key) || bpf_loader_upgradeable::check_id(loader_key) {
LoadedProgramType::LegacyV1(VerifiedExecutable::from_executable(executable)?)
} else if loader_v3::check_id(loader_key) {
LoadedProgramType::Typed(VerifiedExecutable::from_executable(executable)?)
} else {
panic!();
};
Expand All @@ -156,6 +159,7 @@ impl LoadedProgram {
match &mut program {
LoadedProgramType::LegacyV0(executable) => executable.jit_compile(),
LoadedProgramType::LegacyV1(executable) => executable.jit_compile(),
LoadedProgramType::Typed(executable) => executable.jit_compile(),
_ => Err(EbpfError::JitNotCompiled),
}?;
jit_compile_time.stop();
Expand Down
2 changes: 1 addition & 1 deletion programs/bpf_loader/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ fn process_instruction_common(
LoadedProgramType::Invalid => Err(InstructionError::InvalidAccountData),
LoadedProgramType::LegacyV0(executable) => execute(executable, invoke_context),
LoadedProgramType::LegacyV1(executable) => execute(executable, invoke_context),
LoadedProgramType::BuiltIn(_) => Err(InstructionError::IncorrectProgramId),
_ => Err(InstructionError::IncorrectProgramId),
}
}

Expand Down
28 changes: 28 additions & 0 deletions programs/loader-v3/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[package]
name = "solana-loader-v3-program"
version = "1.16.0"
description = "Solana Loader v3"
authors = ["Solana Maintainers <[email protected]>"]
repository = "https://github.com/solana-labs/solana"
license = "Apache-2.0"
homepage = "https://solana.com/"
edition = "2021"
publish = false

[dependencies]
log = { workspace = true }
rand = { workspace = true }
solana-measure = { workspace = true }
solana-program-runtime = { workspace = true }
solana-sdk = { workspace = true }
solana_rbpf = { workspace = true }

[dev-dependencies]
bincode = { workspace = true }

[lib]
crate-type = ["lib"]
name = "solana_loader_v3_program"

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
Loading