diff --git a/cli/src/program.rs b/cli/src/program.rs index 05ccc04256ccf4..c17aa44e9e1a80 100644 --- a/cli/src/program.rs +++ b/cli/src/program.rs @@ -2025,8 +2025,9 @@ fn read_and_verify_elf(program_location: &str) -> Result, Box::from_elf( diff --git a/ledger-tool/src/program.rs b/ledger-tool/src/program.rs index b2454c2972342b..7df529519addf3 100644 --- a/ledger-tool/src/program.rs +++ b/ledger-tool/src/program.rs @@ -350,6 +350,7 @@ fn load_program<'a>( let program_runtime_environment = create_program_runtime_environment( &invoke_context.feature_set, invoke_context.get_compute_budget(), + None, /* prev_runtime_environment */ false, /* deployment */ true, /* debugging_features */ ) diff --git a/programs/bpf_loader/src/lib.rs b/programs/bpf_loader/src/lib.rs index 55dcb0dbad14e1..c81948cd832220 100644 --- a/programs/bpf_loader/src/lib.rs +++ b/programs/bpf_loader/src/lib.rs @@ -119,6 +119,7 @@ macro_rules! deploy_program { let program_runtime_environment = create_program_runtime_environment( &$invoke_context.feature_set, $invoke_context.get_compute_budget(), + None, /* prev_runtime_environment */ true, /* deployment */ false, /* debugging_features */ ).map_err(|e| { @@ -1642,6 +1643,7 @@ pub mod test_utils { let program_runtime_environment = create_program_runtime_environment( &invoke_context.feature_set, invoke_context.get_compute_budget(), + None, /* prev_runtime_environment */ false, /* deployment */ false, /* debugging_features */ ); diff --git a/programs/bpf_loader/src/syscalls/mod.rs b/programs/bpf_loader/src/syscalls/mod.rs index 53e37ef1a52367..3edf294ffdd722 100644 --- a/programs/bpf_loader/src/syscalls/mod.rs +++ b/programs/bpf_loader/src/syscalls/mod.rs @@ -145,6 +145,7 @@ macro_rules! register_feature_gated_function { pub fn create_program_runtime_environment<'a>( feature_set: &FeatureSet, compute_budget: &ComputeBudget, + previous_runtime_environment: Option<&BuiltinProgram>>, reject_deployment_of_broken_elfs: bool, debugging_features: bool, ) -> Result>, Error> { @@ -172,10 +173,14 @@ pub fn create_program_runtime_environment<'a>( reject_broken_elfs: reject_deployment_of_broken_elfs, noop_instruction_rate: 256, sanitize_user_provided_values: true, - runtime_environment_key: rand::thread_rng() - .gen::() - .checked_shr(PROGRAM_ENVIRONMENT_KEY_SHIFT) - .unwrap_or(0), + runtime_environment_key: if let Some(previous) = previous_runtime_environment { + previous.get_config().runtime_environment_key + } else { + rand::thread_rng() + .gen::() + .checked_shr(PROGRAM_ENVIRONMENT_KEY_SHIFT) + .unwrap_or(0) + }, external_internal_function_hash_collision: feature_set .is_active(&error_on_syscall_bpf_function_hash_collisions::id()), reject_callx_r10: feature_set.is_active(&reject_callx_r10::id()), diff --git a/programs/sbf/benches/bpf_loader.rs b/programs/sbf/benches/bpf_loader.rs index c72dcd68b9968e..6b6ee6aee90872 100644 --- a/programs/sbf/benches/bpf_loader.rs +++ b/programs/sbf/benches/bpf_loader.rs @@ -93,6 +93,7 @@ fn bench_program_create_executable(bencher: &mut Bencher) { let program_runtime_environment = create_program_runtime_environment( &FeatureSet::default(), &ComputeBudget::default(), + None, true, false, ); @@ -121,6 +122,7 @@ fn bench_program_alu(bencher: &mut Bencher) { let program_runtime_environment = create_program_runtime_environment( &invoke_context.feature_set, &ComputeBudget::default(), + None, true, false, ); @@ -240,6 +242,7 @@ fn bench_create_vm(bencher: &mut Bencher) { let program_runtime_environment = create_program_runtime_environment( &invoke_context.feature_set, &ComputeBudget::default(), + None, true, false, ); @@ -302,6 +305,7 @@ fn bench_instruction_count_tuner(_bencher: &mut Bencher) { let program_runtime_environment = create_program_runtime_environment( &invoke_context.feature_set, &ComputeBudget::default(), + None, true, false, ); diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index 430a960779a23d..a576389052d98b 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -1491,6 +1491,7 @@ impl Bank { let program_runtime_environment_v1 = create_program_runtime_environment( &feature_set, &new.runtime_config.compute_budget.unwrap_or_default(), + Some(&loaded_programs_cache.program_runtime_environment_v1), false, /* deployment */ false, /* debugging_features */ ) @@ -8035,6 +8036,7 @@ impl Bank { let program_runtime_environment_v1 = create_program_runtime_environment( &self.feature_set, &self.runtime_config.compute_budget.unwrap_or_default(), + Some(&loaded_programs_cache.program_runtime_environment_v1), false, /* deployment */ false, /* debugging_features */ )