Split BPF loader to match the rest of the programs (#4636)
This commit is contained in:
parent
dd1c3514a8
commit
0dcdc37fec
|
@ -18,7 +18,8 @@ members = [
|
|||
"metrics",
|
||||
"netutil",
|
||||
"programs/bpf",
|
||||
"programs/bpf_loader",
|
||||
"programs/bpf_loader_api",
|
||||
"programs/bpf_loader_program",
|
||||
"programs/budget_api",
|
||||
"programs/budget_program",
|
||||
"programs/config_api",
|
||||
|
|
|
@ -16,7 +16,8 @@ serde_derive = "1.0.92"
|
|||
serde_json = "1.0.39"
|
||||
serde_yaml = "0.8.9"
|
||||
solana = { path = "../core", version = "0.16.0" }
|
||||
solana-bpfloader = { path = "../programs/bpf_loader", version = "0.16.0" }
|
||||
solana-bpf-loader-api = { path = "../programs/bpf_loader_api", version = "0.16.0" }
|
||||
solana-bpf-loader-program = { path = "../programs/bpf_loader_program", version = "0.16.0" }
|
||||
solana-budget-api = { path = "../programs/budget_api", version = "0.16.0" }
|
||||
solana-budget-program = { path = "../programs/budget_program", version = "0.16.0" }
|
||||
solana-config-api = { path = "../programs/config_api", version = "0.16.0" }
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
//! A command-line executable for generating the chain's genesis block.
|
||||
#[macro_use]
|
||||
extern crate solana_bpf_loader;
|
||||
extern crate solana_bpf_loader_program;
|
||||
#[macro_use]
|
||||
extern crate solana_vote_program;
|
||||
#[macro_use]
|
||||
|
@ -303,7 +303,7 @@ fn main() -> Result<(), Box<dyn error::Error>> {
|
|||
),
|
||||
],
|
||||
&[
|
||||
solana_bpf_loader!(),
|
||||
solana_bpf_loader_program!(),
|
||||
solana_vote_program!(),
|
||||
solana_stake_program!(),
|
||||
solana_budget_program!(),
|
||||
|
|
|
@ -21,7 +21,7 @@ walkdir = "2"
|
|||
bincode = "1.1.4"
|
||||
byteorder = "1.3.2"
|
||||
elf = "0.0.10"
|
||||
solana-bpfloader = { path = "../bpf_loader", version = "0.16.0" }
|
||||
solana-bpf-loader-api = { path = "../bpf_loader_api", version = "0.16.0" }
|
||||
solana-logger = { path = "../../logger", version = "0.16.0" }
|
||||
solana-runtime = { path = "../../runtime", version = "0.16.0" }
|
||||
solana-sdk = { path = "../../sdk", version = "0.16.0" }
|
||||
|
|
|
@ -60,7 +60,7 @@ fn bench_program_verify(bencher: &mut Bencher) {
|
|||
vm.set_elf(&elf).unwrap();
|
||||
|
||||
bencher.iter(|| {
|
||||
vm.set_verifier(solana_bpf_loader::bpf_verifier::check)
|
||||
vm.set_verifier(solana_bpf_loader_api::bpf_verifier::check)
|
||||
.unwrap();
|
||||
});
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ fn bench_program_alu(bencher: &mut Bencher) {
|
|||
inner_iter.write_u64::<LittleEndian>(0).unwrap();
|
||||
|
||||
let elf = load_elf().unwrap();
|
||||
let (mut vm, _) = solana_bpf_loader::create_vm(&elf).unwrap();
|
||||
let (mut vm, _) = solana_bpf_loader_api::create_vm(&elf).unwrap();
|
||||
|
||||
println!("Interpreted:");
|
||||
assert_eq!(
|
||||
|
|
|
@ -4,7 +4,6 @@ mod bpf {
|
|||
use solana_runtime::bank_client::BankClient;
|
||||
use solana_runtime::genesis_utils::{create_genesis_block, GenesisBlockInfo};
|
||||
use solana_runtime::loader_utils::load_program;
|
||||
use solana_sdk::native_loader;
|
||||
use std::env;
|
||||
use std::fs::File;
|
||||
use std::path::PathBuf;
|
||||
|
@ -33,30 +32,6 @@ mod bpf {
|
|||
use solana_sdk::signature::KeypairUtil;
|
||||
use std::io::Read;
|
||||
|
||||
#[test]
|
||||
fn test_program_bpf_c_noop() {
|
||||
solana_logger::setup();
|
||||
|
||||
let mut file = File::open(create_bpf_path("noop")).expect("file open failed");
|
||||
let mut elf = Vec::new();
|
||||
file.read_to_end(&mut elf).unwrap();
|
||||
|
||||
let GenesisBlockInfo {
|
||||
genesis_block,
|
||||
mint_keypair,
|
||||
..
|
||||
} = create_genesis_block(50);
|
||||
let bank = Bank::new(&genesis_block);
|
||||
let bank_client = BankClient::new(bank);
|
||||
|
||||
// Call user program
|
||||
let program_id = load_program(&bank_client, &mint_keypair, &bpf_loader::id(), elf);
|
||||
let instruction = create_invoke_instruction(mint_keypair.pubkey(), program_id, &1u8);
|
||||
bank_client
|
||||
.send_instruction(&mint_keypair, instruction)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_program_bpf_c() {
|
||||
solana_logger::setup();
|
||||
|
@ -84,15 +59,8 @@ mod bpf {
|
|||
let bank = Bank::new(&genesis_block);
|
||||
let bank_client = BankClient::new(bank);
|
||||
|
||||
let loader_pubkey = load_program(
|
||||
&bank_client,
|
||||
&mint_keypair,
|
||||
&native_loader::id(),
|
||||
"solana_bpf_loader".as_bytes().to_vec(),
|
||||
);
|
||||
|
||||
// Call user program
|
||||
let program_id = load_program(&bank_client, &mint_keypair, &loader_pubkey, elf);
|
||||
let program_id = load_program(&bank_client, &mint_keypair, &bpf_loader::id(), elf);
|
||||
let instruction =
|
||||
create_invoke_instruction(mint_keypair.pubkey(), program_id, &1u8);
|
||||
bank_client
|
||||
|
@ -105,6 +73,7 @@ mod bpf {
|
|||
#[cfg(feature = "bpf_rust")]
|
||||
mod bpf_rust {
|
||||
use super::*;
|
||||
use solana_sdk::bpf_loader;
|
||||
use solana_sdk::client::SyncClient;
|
||||
use solana_sdk::instruction::{AccountMeta, Instruction};
|
||||
use solana_sdk::signature::{Keypair, KeypairUtil};
|
||||
|
@ -136,15 +105,8 @@ mod bpf {
|
|||
let bank = Bank::new(&genesis_block);
|
||||
let bank_client = BankClient::new(bank);
|
||||
|
||||
let loader_pubkey = load_program(
|
||||
&bank_client,
|
||||
&mint_keypair,
|
||||
&native_loader::id(),
|
||||
"solana_bpf_loader".as_bytes().to_vec(),
|
||||
);
|
||||
|
||||
// Call user program
|
||||
let program_id = load_program(&bank_client, &mint_keypair, &loader_pubkey, elf);
|
||||
let program_id = load_program(&bank_client, &mint_keypair, &bpf_loader::id(), elf);
|
||||
let account_metas = vec![
|
||||
AccountMeta::new(mint_keypair.pubkey(), true),
|
||||
AccountMeta::new(Keypair::new().pubkey(), false),
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[package]
|
||||
name = "solana-bpfloader"
|
||||
name = "solana-bpf-loader-api"
|
||||
version = "0.16.0"
|
||||
description = "Solana BPF Loader"
|
||||
authors = ["Solana Maintainers <maintainers@solana.com>"]
|
||||
|
@ -19,5 +19,5 @@ solana-sdk = { path = "../../sdk", version = "0.16.0" }
|
|||
solana_rbpf = "=0.1.13"
|
||||
|
||||
[lib]
|
||||
crate-type = ["lib", "cdylib"]
|
||||
name = "solana_bpf_loader"
|
||||
crate-type = ["lib"]
|
||||
name = "solana_bpf_loader_api"
|
|
@ -22,7 +22,6 @@ use solana_sdk::account::KeyedAccount;
|
|||
use solana_sdk::instruction::InstructionError;
|
||||
use solana_sdk::loader_instruction::LoaderInstruction;
|
||||
use solana_sdk::pubkey::Pubkey;
|
||||
use solana_sdk::solana_entrypoint;
|
||||
use std::alloc::Layout;
|
||||
use std::any::Any;
|
||||
use std::ffi::CStr;
|
||||
|
@ -304,8 +303,7 @@ fn deserialize_parameters(keyed_accounts: &mut [KeyedAccount], buffer: &[u8]) {
|
|||
}
|
||||
}
|
||||
|
||||
solana_entrypoint!(entrypoint);
|
||||
fn entrypoint(
|
||||
pub fn process_instruction(
|
||||
program_id: &Pubkey,
|
||||
keyed_accounts: &mut [KeyedAccount],
|
||||
tx_data: &[u8],
|
|
@ -0,0 +1 @@
|
|||
/target/
|
|
@ -0,0 +1,19 @@
|
|||
[package]
|
||||
name = "solana-bpf-loader-program"
|
||||
version = "0.16.0"
|
||||
description = "Solana BPF Loader"
|
||||
authors = ["Solana Maintainers <maintainers@solana.com>"]
|
||||
repository = "https://github.com/solana-labs/solana"
|
||||
license = "Apache-2.0"
|
||||
homepage = "https://solana.com/"
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
log = "0.4.2"
|
||||
solana-logger = { path = "../../logger", version = "0.16.0" }
|
||||
solana-sdk = { path = "../../sdk", version = "0.16.0" }
|
||||
solana-bpf-loader-api = { path = "../bpf_loader_api", version = "0.16.0" }
|
||||
|
||||
[lib]
|
||||
crate-type = ["lib", "cdylib"]
|
||||
name = "solana_bpf_loader_program"
|
|
@ -0,0 +1,12 @@
|
|||
#[macro_export]
|
||||
macro_rules! solana_bpf_loader_program {
|
||||
() => {
|
||||
(
|
||||
"solana_bpf_loader_program".to_string(),
|
||||
solana_sdk::bpf_loader::id(),
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
use solana_bpf_loader_api::process_instruction;
|
||||
solana_sdk::solana_entrypoint!(process_instruction);
|
|
@ -26,7 +26,8 @@ serde_derive = "1.0.92"
|
|||
serde_json = "1.0.38"
|
||||
solana-logger = { path = "../logger", version = "0.16.0" }
|
||||
solana-metrics = { path = "../metrics", version = "0.16.0" }
|
||||
solana-bpfloader = { path = "../programs/bpf_loader", version = "0.16.0" }
|
||||
solana-bpf-loader-api = { path = "../programs/bpf_loader_api", version = "0.16.0" }
|
||||
solana-bpf-loader-program = { path = "../programs/bpf_loader_program", version = "0.16.0" }
|
||||
solana-noop-program = { path = "../programs/noop_program", version = "0.16.0" }
|
||||
solana-sdk = { path = "../sdk", version = "0.16.0" }
|
||||
solana-stake-api = { path = "../programs/stake_api", version = "0.16.0" }
|
||||
|
|
|
@ -64,7 +64,7 @@ pub fn create_genesis_block_with_leader(
|
|||
),
|
||||
],
|
||||
&[
|
||||
solana_bpf_loader!(),
|
||||
solana_bpf_loader_program!(),
|
||||
solana_vote_program!(),
|
||||
solana_stake_program!(),
|
||||
],
|
||||
|
|
|
@ -28,7 +28,7 @@ extern crate solana_vote_program;
|
|||
extern crate solana_stake_program;
|
||||
|
||||
#[macro_use]
|
||||
extern crate solana_bpf_loader;
|
||||
extern crate solana_bpf_loader_program;
|
||||
|
||||
#[macro_use]
|
||||
extern crate serde_derive;
|
||||
|
|
Loading…
Reference in New Issue