From 8ff6323ce9f084ba2d61f5082e12d75afd892b62 Mon Sep 17 00:00:00 2001 From: Pankaj Garg Date: Tue, 14 Jan 2025 13:44:14 -0800 Subject: [PATCH] change deploy_program_internal -> deploy_program --- programs/bpf_loader/src/lib.rs | 28 ++----------------- .../bank/builtins/core_bpf_migration/mod.rs | 16 +++++++++-- 2 files changed, 17 insertions(+), 27 deletions(-) diff --git a/programs/bpf_loader/src/lib.rs b/programs/bpf_loader/src/lib.rs index cfd0b8d91bd354..fbf5b4288fd937 100644 --- a/programs/bpf_loader/src/lib.rs +++ b/programs/bpf_loader/src/lib.rs @@ -109,8 +109,7 @@ pub fn load_program_from_bytes( /// Directly deploy a program using a provided invoke context. /// This function should only be invoked from the runtime, since it does not /// provide any account loads or checks. -#[cfg_attr(feature = "svm-internal", qualifiers(pub))] -fn deploy_program_internal( +pub fn deploy_program( log_collector: Option>>, program_cache_for_tx_batch: &mut ProgramCacheForTxBatch, program_runtime_environment: ProgramRuntimeEnvironment, @@ -185,7 +184,7 @@ macro_rules! deploy_program { // This will never fail since the epoch schedule is already configured. InstructionError::ProgramEnvironmentSetupFailure })?; - let load_program_metrics = $crate::deploy_program_internal( + let load_program_metrics = $crate::deploy_program( $invoke_context.get_log_collector(), $invoke_context.program_cache_for_tx_batch, environments.program_runtime_v1.clone(), @@ -199,27 +198,6 @@ macro_rules! deploy_program { }; } -// This function/wrapper is added specifically for non "svm-internal" users. It enables the reducing -// of public visibility of some internal APIs. -pub fn deploy_program( - invoke_context: &mut InvokeContext, - program_id: &Pubkey, - loader_key: &Pubkey, - account_size: usize, - programdata: &[u8], - deployment_slot: Slot, -) -> Result<(), InstructionError> { - deploy_program!( - invoke_context, - program_id, - loader_key, - account_size, - programdata, - deployment_slot - ); - Ok(()) -} - fn write_program_data( program_data_offset: usize, bytes: &[u8], @@ -3868,7 +3846,7 @@ mod tests { let mut file = File::open("test_elfs/out/sbpfv3_return_ok.so").expect("file open failed"); let mut elf = Vec::new(); file.read_to_end(&mut elf).unwrap(); - deploy_program( + deploy_program!( invoke_context, &program_id, &bpf_loader_upgradeable::id(), diff --git a/runtime/src/bank/builtins/core_bpf_migration/mod.rs b/runtime/src/bank/builtins/core_bpf_migration/mod.rs index 653559ecd38259..1a7dce8f08ac3e 100644 --- a/runtime/src/bank/builtins/core_bpf_migration/mod.rs +++ b/runtime/src/bank/builtins/core_bpf_migration/mod.rs @@ -173,14 +173,26 @@ impl Bank { compute_budget, ); - solana_bpf_loader_program::deploy_program( - &mut dummy_invoke_context, + let environments = dummy_invoke_context + .get_environments_for_slot(self.slot.saturating_add( + solana_program_runtime::loaded_programs::DELAY_VISIBILITY_SLOT_OFFSET, + )) + .map_err(|_err| { + // This will never fail since the epoch schedule is already configured. + InstructionError::ProgramEnvironmentSetupFailure + })?; + + let load_program_metrics = solana_bpf_loader_program::deploy_program( + dummy_invoke_context.get_log_collector(), + dummy_invoke_context.program_cache_for_tx_batch, + environments.program_runtime_v1.clone(), program_id, &bpf_loader_upgradeable::id(), data_len, elf, self.slot, )?; + load_program_metrics.submit_datapoint(&mut dummy_invoke_context.timings); } // Update the program cache by merging with `programs_modified`, which