From 7ff797bcef821d2cd4d09d2bae421ebc649fa594 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Mei=C3=9Fner?= Date: Mon, 25 Sep 2023 17:16:31 +0200 Subject: [PATCH] Refactor - Remove parameter `feature_set` from `load_program_from_bytes()` (#33395) Replaces parameter feature_set with delay_visibility_of_program_deployment in load_program_from_bytes(). --- ledger-tool/src/program.rs | 5 ++++- programs/bpf_loader/src/lib.rs | 10 +++++----- runtime/src/bank.rs | 6 ++++-- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/ledger-tool/src/program.rs b/ledger-tool/src/program.rs index ef72c98a4da403..4acad738160be0 100644 --- a/ledger-tool/src/program.rs +++ b/ledger-tool/src/program.rs @@ -27,6 +27,7 @@ use { account::AccountSharedData, account_utils::StateMut, bpf_loader_upgradeable::{self, UpgradeableLoaderState}, + feature_set, pubkey::Pubkey, slot_history::Slot, transaction_context::{IndexOfAccount, InstructionAccount}, @@ -357,7 +358,9 @@ fn load_program<'a>( #[allow(unused_mut)] let mut verified_executable = if is_elf { let result = load_program_from_bytes( - &invoke_context.feature_set, + invoke_context + .feature_set + .is_active(&feature_set::delay_visibility_of_program_deployment::id()), log_collector, &mut load_program_metrics, &contents, diff --git a/programs/bpf_loader/src/lib.rs b/programs/bpf_loader/src/lib.rs index ae585d8f9582f2..fa4bc849028144 100644 --- a/programs/bpf_loader/src/lib.rs +++ b/programs/bpf_loader/src/lib.rs @@ -35,7 +35,7 @@ use { cap_bpf_program_instruction_accounts, delay_visibility_of_program_deployment, enable_bpf_loader_extend_program_ix, enable_bpf_loader_set_authority_checked_ix, enable_program_redeployment_cooldown, limit_max_instruction_trace_length, - native_programs_consume_cu, remove_bpf_loader_incorrect_program_id, FeatureSet, + native_programs_consume_cu, remove_bpf_loader_incorrect_program_id, }, instruction::{AccountMeta, InstructionError}, loader_instruction::LoaderInstruction, @@ -67,7 +67,7 @@ pub const UPGRADEABLE_LOADER_COMPUTE_UNITS: u64 = 2_370; #[allow(clippy::too_many_arguments)] pub fn load_program_from_bytes( - feature_set: &FeatureSet, + delay_visibility_of_program_deployment: bool, log_collector: Option>>, load_program_metrics: &mut LoadProgramMetrics, programdata: &[u8], @@ -77,7 +77,7 @@ pub fn load_program_from_bytes( program_runtime_environment: Arc>>, reloading: bool, ) -> Result { - let effective_slot = if feature_set.is_active(&delay_visibility_of_program_deployment::id()) { + let effective_slot = if delay_visibility_of_program_deployment { deployment_slot.saturating_add(DELAY_VISIBILITY_SLOT_OFFSET) } else { deployment_slot @@ -132,7 +132,7 @@ macro_rules! deploy_program { register_syscalls_time.stop(); load_program_metrics.register_syscalls_us = register_syscalls_time.as_us(); let executor = load_program_from_bytes( - &$invoke_context.feature_set, + $invoke_context.feature_set.is_active(&delay_visibility_of_program_deployment::id()), $invoke_context.get_log_collector(), &mut load_program_metrics, $new_programdata, @@ -1707,7 +1707,7 @@ pub mod test_utils { .expect("Failed to get account key"); if let Ok(loaded_program) = load_program_from_bytes( - &FeatureSet::all_enabled(), + true, None, &mut load_program_metrics, account.data(), diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index c767ce4a3120c9..3c8cba7471f51f 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -4684,7 +4684,8 @@ impl Bank { ProgramAccountLoadResult::ProgramOfLoaderV1orV2(program_account) => { solana_bpf_loader_program::load_program_from_bytes( - &self.feature_set, + self.feature_set + .is_active(&feature_set::delay_visibility_of_program_deployment::id()), None, &mut load_program_metrics, program_account.data(), @@ -4706,7 +4707,8 @@ impl Bank { .ok_or(InstructionError::InvalidAccountData) .and_then(|programdata| { solana_bpf_loader_program::load_program_from_bytes( - &self.feature_set, + self.feature_set + .is_active(&feature_set::delay_visibility_of_program_deployment::id()), None, &mut load_program_metrics, programdata,