From f198d7426afe8755343ab3025fc53cec1534d2f6 Mon Sep 17 00:00:00 2001 From: Pankaj Garg Date: Wed, 29 Mar 2023 04:47:49 -0700 Subject: [PATCH] Use feature gate to set effective slot of loaded programs (#30950) --- program-runtime/src/loaded_programs.rs | 3 ++- programs/bpf_loader/src/lib.rs | 7 +++++++ programs/loader-v3/src/lib.rs | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/program-runtime/src/loaded_programs.rs b/program-runtime/src/loaded_programs.rs index d91ea90b951674..d2d33b14115f0f 100644 --- a/program-runtime/src/loaded_programs.rs +++ b/program-runtime/src/loaded_programs.rs @@ -132,6 +132,7 @@ impl LoadedProgram { loader_key: &Pubkey, loader: Arc>>, deployment_slot: Slot, + effective_slot: Slot, elf_bytes: &[u8], account_size: usize, use_jit: bool, @@ -176,7 +177,7 @@ impl LoadedProgram { Ok(Self { deployment_slot, account_size, - effective_slot: deployment_slot.saturating_add(1), + effective_slot, usage_counter: AtomicU64::new(0), program, }) diff --git a/programs/bpf_loader/src/lib.rs b/programs/bpf_loader/src/lib.rs index ca17a06b4d3fed..cfc8b9303065a4 100644 --- a/programs/bpf_loader/src/lib.rs +++ b/programs/bpf_loader/src/lib.rs @@ -119,10 +119,17 @@ pub fn load_program_from_bytes( register_syscalls_time.stop(); load_program_metrics.register_syscalls_us = register_syscalls_time.as_us(); + let effective_slot = if feature_set.is_active(&delay_visibility_of_program_deployment::id()) { + deployment_slot.saturating_add(1) + } else { + deployment_slot + }; + let loaded_program = LoadedProgram::new( loader_key, loader, deployment_slot, + effective_slot, programdata, account_size, use_jit, diff --git a/programs/loader-v3/src/lib.rs b/programs/loader-v3/src/lib.rs index a30195894ab1e0..81eee362a3d608 100644 --- a/programs/loader-v3/src/lib.rs +++ b/programs/loader-v3/src/lib.rs @@ -114,6 +114,7 @@ pub fn load_program_from_account( &loader_v3::id(), Arc::new(loader), state.slot, + state.slot.saturating_add(1), programdata, program.get_data().len(), use_jit,