Remove MessageProcessor::loaders

This commit is contained in:
Michael Vines 2020-10-29 14:15:00 -07:00
parent df8dab9d2b
commit 2664a1f7ef
3 changed files with 2 additions and 32 deletions

View File

@ -21,7 +21,6 @@ use solana_sdk::{
bpf_loader, bpf_loader_deprecated, bpf_loader, bpf_loader_deprecated,
decode_error::DecodeError, decode_error::DecodeError,
entrypoint::SUCCESS, entrypoint::SUCCESS,
feature_set::compute_budget_balancing,
feature_set::{bpf_just_in_time_compilation, compute_budget_balancing}, feature_set::{bpf_just_in_time_compilation, compute_budget_balancing},
instruction::InstructionError, instruction::InstructionError,
keyed_account::{is_executable, next_keyed_account, KeyedAccount}, keyed_account::{is_executable, next_keyed_account, KeyedAccount},

View File

@ -1296,8 +1296,6 @@ fn call<'a>(
for (program_id, process_instruction) in invoke_context.get_programs().iter() { for (program_id, process_instruction) in invoke_context.get_programs().iter() {
message_processor.add_program(*program_id, *process_instruction); message_processor.add_program(*program_id, *process_instruction);
} }
message_processor.add_loader(bpf_loader::id(), crate::process_instruction);
message_processor.add_loader(bpf_loader_deprecated::id(), crate::process_instruction);
#[allow(clippy::deref_addrof)] #[allow(clippy::deref_addrof)]
match message_processor.process_cross_program_instruction( match message_processor.process_cross_program_instruction(

View File

@ -328,8 +328,6 @@ pub struct MessageProcessor {
#[serde(skip)] #[serde(skip)]
programs: Vec<(Pubkey, ProcessInstructionWithContext)>, programs: Vec<(Pubkey, ProcessInstructionWithContext)>,
#[serde(skip)] #[serde(skip)]
loaders: Vec<(Pubkey, ProcessInstructionWithContext)>,
#[serde(skip)]
native_loader: NativeLoader, native_loader: NativeLoader,
} }
@ -338,7 +336,6 @@ impl std::fmt::Debug for MessageProcessor {
#[derive(Debug)] #[derive(Debug)]
struct MessageProcessor<'a> { struct MessageProcessor<'a> {
programs: Vec<String>, programs: Vec<String>,
loaders: Vec<String>,
native_loader: &'a NativeLoader, native_loader: &'a NativeLoader,
} }
// rustc doesn't compile due to bug without this work around // rustc doesn't compile due to bug without this work around
@ -353,14 +350,6 @@ impl std::fmt::Debug for MessageProcessor {
format!("{}: {:p}", pubkey, erased_instruction) format!("{}: {:p}", pubkey, erased_instruction)
}) })
.collect::<Vec<_>>(), .collect::<Vec<_>>(),
loaders: self
.loaders
.iter()
.map(|(pubkey, instruction)| {
let erased_instruction: ErasedProcessInstructionWithContext = *instruction;
format!("{}: {:p}", pubkey, erased_instruction)
})
.collect::<Vec<_>>(),
native_loader: &self.native_loader, native_loader: &self.native_loader,
}; };
@ -372,7 +361,6 @@ impl Default for MessageProcessor {
fn default() -> Self { fn default() -> Self {
Self { Self {
programs: vec![], programs: vec![],
loaders: vec![],
native_loader: NativeLoader::default(), native_loader: NativeLoader::default(),
} }
} }
@ -381,7 +369,6 @@ impl Clone for MessageProcessor {
fn clone(&self) -> Self { fn clone(&self) -> Self {
MessageProcessor { MessageProcessor {
programs: self.programs.clone(), programs: self.programs.clone(),
loaders: self.loaders.clone(),
native_loader: NativeLoader::default(), native_loader: NativeLoader::default(),
} }
} }
@ -414,10 +401,7 @@ impl MessageProcessor {
program_id: Pubkey, program_id: Pubkey,
process_instruction: ProcessInstructionWithContext, process_instruction: ProcessInstructionWithContext,
) { ) {
match self.loaders.iter_mut().find(|(key, _)| program_id == *key) { self.add_program(program_id, process_instruction);
Some((_, processor)) => *processor = process_instruction,
None => self.loaders.push((program_id, process_instruction)),
}
} }
fn get_compute_budget(feature_set: &FeatureSet) -> ComputeBudget { fn get_compute_budget(feature_set: &FeatureSet) -> ComputeBudget {
@ -462,17 +446,6 @@ impl MessageProcessor {
if let Some(root_account) = keyed_accounts.iter().next() { if let Some(root_account) = keyed_accounts.iter().next() {
if native_loader::check_id(&root_account.owner()?) { if native_loader::check_id(&root_account.owner()?) {
let root_id = root_account.unsigned_key(); let root_id = root_account.unsigned_key();
for (id, process_instruction) in &self.loaders {
if id == root_id {
// Call the program via a builtin loader
return process_instruction(
&root_id,
&keyed_accounts[1..],
instruction_data,
invoke_context,
);
}
}
for (id, process_instruction) in &self.programs { for (id, process_instruction) in &self.programs {
if id == root_id { if id == root_id {
// Call the builtin program // Call the builtin program
@ -493,7 +466,7 @@ impl MessageProcessor {
); );
} else { } else {
let owner_id = &root_account.owner()?; let owner_id = &root_account.owner()?;
for (id, process_instruction) in &self.loaders { for (id, process_instruction) in &self.programs {
if id == owner_id { if id == owner_id {
// Call the program via a builtin loader // Call the program via a builtin loader
return process_instruction( return process_instruction(