Rename native_program.rs to instruction_processor_utils.rs
Prefer the term "instruction processor" over "program". Reserve the term "native" for the loader and shared object it loads. Compiling an instruction processor to BPF shouldn't imply changing to a non-native entrypoint.
This commit is contained in:
parent
dd4c512954
commit
0a9f063d3e
|
@ -347,19 +347,25 @@ impl Bank {
|
|||
);
|
||||
|
||||
// Add native programs mandatory for the runtime to function
|
||||
self.add_native_program("solana_system_program", &solana_sdk::system_program::id());
|
||||
self.add_native_program("solana_bpf_loader", &solana_sdk::bpf_loader::id());
|
||||
self.add_native_program("solana_vote_program", &solana_vote_api::id());
|
||||
self.register_native_instruction_processor(
|
||||
"solana_system_program",
|
||||
&solana_sdk::system_program::id(),
|
||||
);
|
||||
self.register_native_instruction_processor(
|
||||
"solana_bpf_loader",
|
||||
&solana_sdk::bpf_loader::id(),
|
||||
);
|
||||
self.register_native_instruction_processor("solana_vote_program", &solana_vote_api::id());
|
||||
|
||||
// Add additional native programs specified in the genesis block
|
||||
for (name, program_id) in &genesis_block.native_programs {
|
||||
self.add_native_program(name, program_id);
|
||||
self.register_native_instruction_processor(name, program_id);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn add_native_program(&self, name: &str, program_id: &Pubkey) {
|
||||
pub fn register_native_instruction_processor(&self, name: &str, program_id: &Pubkey) {
|
||||
debug!("Adding native program {} under {:?}", name, program_id);
|
||||
let account = native_loader::create_program_account(name);
|
||||
let account = native_loader::create_loadable_account(name);
|
||||
self.accounts
|
||||
.store_slow(self.accounts_id, program_id, &account);
|
||||
}
|
||||
|
@ -931,15 +937,8 @@ impl Bank {
|
|||
self.runtime
|
||||
.add_instruction_processor(program_id, process_instruction);
|
||||
|
||||
// Add a bogus executable account to load.
|
||||
let bogus_account = Account {
|
||||
lamports: 1,
|
||||
data: vec![],
|
||||
owner: native_loader::id(),
|
||||
executable: true,
|
||||
};
|
||||
self.accounts
|
||||
.store_slow(self.accounts_id, &program_id, &bogus_account);
|
||||
// Register a bogus executable account, which will be loaded and ignored.
|
||||
self.register_native_instruction_processor("", &program_id);
|
||||
}
|
||||
|
||||
pub fn is_in_subtree_of(&self, parent: u64) -> bool {
|
||||
|
|
|
@ -7,8 +7,8 @@ use libloading::os::windows::*;
|
|||
use log::*;
|
||||
use solana_sdk::account::KeyedAccount;
|
||||
use solana_sdk::instruction::InstructionError;
|
||||
use solana_sdk::instruction_processor_utils;
|
||||
use solana_sdk::loader_instruction::LoaderInstruction;
|
||||
use solana_sdk::native_program;
|
||||
use solana_sdk::pubkey::Pubkey;
|
||||
use std::env;
|
||||
use std::path::PathBuf;
|
||||
|
@ -69,14 +69,14 @@ pub fn entrypoint(
|
|||
// TODO linux tls bug can cause crash on dlclose(), workaround by never unloading
|
||||
match Library::open(Some(&path), libc::RTLD_NODELETE | libc::RTLD_NOW) {
|
||||
Ok(library) => unsafe {
|
||||
let entrypoint: Symbol<native_program::Entrypoint> =
|
||||
match library.get(native_program::ENTRYPOINT.as_bytes()) {
|
||||
let entrypoint: Symbol<instruction_processor_utils::Entrypoint> =
|
||||
match library.get(instruction_processor_utils::ENTRYPOINT.as_bytes()) {
|
||||
Ok(s) => s,
|
||||
Err(e) => {
|
||||
warn!(
|
||||
"{:?}: Unable to find {:?} in program",
|
||||
e,
|
||||
native_program::ENTRYPOINT
|
||||
instruction_processor_utils::ENTRYPOINT
|
||||
);
|
||||
return Err(InstructionError::GenericError);
|
||||
}
|
||||
|
|
|
@ -4,10 +4,10 @@ pub mod fee_calculator;
|
|||
pub mod genesis_block;
|
||||
pub mod hash;
|
||||
pub mod instruction;
|
||||
pub mod instruction_processor_utils;
|
||||
pub mod loader_instruction;
|
||||
pub mod message;
|
||||
pub mod native_loader;
|
||||
pub mod native_program;
|
||||
pub mod packet;
|
||||
pub mod pubkey;
|
||||
pub mod rpc_port;
|
||||
|
|
|
@ -14,7 +14,7 @@ pub fn check_id(program_id: &Pubkey) -> bool {
|
|||
}
|
||||
|
||||
/// Create an executable account with the given shared object name.
|
||||
pub fn create_program_account(name: &str) -> Account {
|
||||
pub fn create_loadable_account(name: &str) -> Account {
|
||||
Account {
|
||||
lamports: 1,
|
||||
owner: id(),
|
||||
|
|
Loading…
Reference in New Issue