Split BPF loader to match the rest of the programs (#4636)
This commit is contained in:
@ -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),
|
||||
|
Reference in New Issue
Block a user