Skip to content

Commit

Permalink
Refactor - Remove parameter feature_set from `load_program_from_byt…
Browse files Browse the repository at this point in the history
…es()` (solana-labs#33395)

Replaces parameter feature_set with delay_visibility_of_program_deployment in load_program_from_bytes().
  • Loading branch information
Lichtso authored Sep 25, 2023
1 parent def8b8f commit 7ff797b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
5 changes: 4 additions & 1 deletion ledger-tool/src/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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,
Expand Down
10 changes: 5 additions & 5 deletions programs/bpf_loader/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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<Rc<RefCell<LogCollector>>>,
load_program_metrics: &mut LoadProgramMetrics,
programdata: &[u8],
Expand All @@ -77,7 +77,7 @@ pub fn load_program_from_bytes(
program_runtime_environment: Arc<BuiltinProgram<InvokeContext<'static>>>,
reloading: bool,
) -> Result<LoadedProgram, InstructionError> {
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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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(),
Expand Down
6 changes: 4 additions & 2 deletions runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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,
Expand Down

0 comments on commit 7ff797b

Please sign in to comment.