From 2664a1f7ef1325a5c2eefc662925e9613e012da0 Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Thu, 29 Oct 2020 14:15:00 -0700 Subject: [PATCH] Remove MessageProcessor::loaders --- programs/bpf_loader/src/lib.rs | 1 - programs/bpf_loader/src/syscalls.rs | 2 -- runtime/src/message_processor.rs | 31 ++--------------------------- 3 files changed, 2 insertions(+), 32 deletions(-) diff --git a/programs/bpf_loader/src/lib.rs b/programs/bpf_loader/src/lib.rs index 889945d382..c3826ebba1 100644 --- a/programs/bpf_loader/src/lib.rs +++ b/programs/bpf_loader/src/lib.rs @@ -21,7 +21,6 @@ use solana_sdk::{ bpf_loader, bpf_loader_deprecated, decode_error::DecodeError, entrypoint::SUCCESS, - feature_set::compute_budget_balancing, feature_set::{bpf_just_in_time_compilation, compute_budget_balancing}, instruction::InstructionError, keyed_account::{is_executable, next_keyed_account, KeyedAccount}, diff --git a/programs/bpf_loader/src/syscalls.rs b/programs/bpf_loader/src/syscalls.rs index bbae9192fe..c2b40a8106 100644 --- a/programs/bpf_loader/src/syscalls.rs +++ b/programs/bpf_loader/src/syscalls.rs @@ -1296,8 +1296,6 @@ fn call<'a>( for (program_id, process_instruction) in invoke_context.get_programs().iter() { 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)] match message_processor.process_cross_program_instruction( diff --git a/runtime/src/message_processor.rs b/runtime/src/message_processor.rs index c60226a038..cf91d5ebc4 100644 --- a/runtime/src/message_processor.rs +++ b/runtime/src/message_processor.rs @@ -328,8 +328,6 @@ pub struct MessageProcessor { #[serde(skip)] programs: Vec<(Pubkey, ProcessInstructionWithContext)>, #[serde(skip)] - loaders: Vec<(Pubkey, ProcessInstructionWithContext)>, - #[serde(skip)] native_loader: NativeLoader, } @@ -338,7 +336,6 @@ impl std::fmt::Debug for MessageProcessor { #[derive(Debug)] struct MessageProcessor<'a> { programs: Vec, - loaders: Vec, native_loader: &'a NativeLoader, } // 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) }) .collect::>(), - loaders: self - .loaders - .iter() - .map(|(pubkey, instruction)| { - let erased_instruction: ErasedProcessInstructionWithContext = *instruction; - format!("{}: {:p}", pubkey, erased_instruction) - }) - .collect::>(), native_loader: &self.native_loader, }; @@ -372,7 +361,6 @@ impl Default for MessageProcessor { fn default() -> Self { Self { programs: vec![], - loaders: vec![], native_loader: NativeLoader::default(), } } @@ -381,7 +369,6 @@ impl Clone for MessageProcessor { fn clone(&self) -> Self { MessageProcessor { programs: self.programs.clone(), - loaders: self.loaders.clone(), native_loader: NativeLoader::default(), } } @@ -414,10 +401,7 @@ impl MessageProcessor { program_id: Pubkey, process_instruction: ProcessInstructionWithContext, ) { - match self.loaders.iter_mut().find(|(key, _)| program_id == *key) { - Some((_, processor)) => *processor = process_instruction, - None => self.loaders.push((program_id, process_instruction)), - } + self.add_program(program_id, process_instruction); } fn get_compute_budget(feature_set: &FeatureSet) -> ComputeBudget { @@ -462,17 +446,6 @@ impl MessageProcessor { if let Some(root_account) = keyed_accounts.iter().next() { if native_loader::check_id(&root_account.owner()?) { 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 { if id == root_id { // Call the builtin program @@ -493,7 +466,7 @@ impl MessageProcessor { ); } else { let owner_id = &root_account.owner()?; - for (id, process_instruction) in &self.loaders { + for (id, process_instruction) in &self.programs { if id == owner_id { // Call the program via a builtin loader return process_instruction(