diff --git a/program-runtime/src/loaded_programs.rs b/program-runtime/src/loaded_programs.rs index 00c972baa4f544..5c228ad6cd599f 100644 --- a/program-runtime/src/loaded_programs.rs +++ b/program-runtime/src/loaded_programs.rs @@ -427,10 +427,7 @@ impl LoadedPrograms { if existing.deployment_slot == entry.deployment_slot && existing.effective_slot == entry.effective_slot { - if matches!(existing.program, LoadedProgramType::Builtin(_)) { - // Allow built-ins to be overwritten - second_level.swap_remove(entry_index); - } else if matches!(existing.program, LoadedProgramType::Unloaded) { + if matches!(existing.program, LoadedProgramType::Unloaded) { // The unloaded program is getting reloaded // Copy over the usage counter to the new entry entry.usage_counter.store( diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index fda195e2f3d31c..34b978c294110f 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -7315,7 +7315,7 @@ impl Bank { self.add_builtin( program_id, "mockup".to_string(), - LoadedProgram::new_builtin(0, 0, entrypoint), + LoadedProgram::new_builtin(self.slot, 0, entrypoint), ); } diff --git a/runtime/src/bank/tests.rs b/runtime/src/bank/tests.rs index 0f581b46dee39b..26606dcb1200b4 100644 --- a/runtime/src/bank/tests.rs +++ b/runtime/src/bank/tests.rs @@ -4857,7 +4857,7 @@ fn test_add_duplicate_static_program() { mint_keypair, .. } = create_genesis_config_with_leader(500, &solana_sdk::pubkey::new_rand(), 0); - let mut bank = Bank::new_for_tests(&genesis_config); + let bank = Bank::new_for_tests(&genesis_config); declare_process_instruction!(process_instruction, 1, |_invoke_context| { Err(InstructionError::Custom(42)) @@ -4886,6 +4886,9 @@ fn test_add_duplicate_static_program() { bank.last_blockhash(), ); + let slot = bank.slot().saturating_add(1); + let mut bank = Bank::new_from_parent(&Arc::new(bank), &Pubkey::default(), slot); + let vote_loader_account = bank.get_account(&solana_vote_program::id()).unwrap(); bank.add_mockup_builtin(solana_vote_program::id(), process_instruction); let new_vote_loader_account = bank.get_account(&solana_vote_program::id()).unwrap(); @@ -6290,7 +6293,7 @@ fn test_transaction_with_program_ids_passed_to_programs() { fn test_account_ids_after_program_ids() { solana_logger::setup(); let (genesis_config, mint_keypair) = create_genesis_config(500); - let mut bank = Bank::new_for_tests(&genesis_config); + let bank = Bank::new_for_tests(&genesis_config); let from_pubkey = solana_sdk::pubkey::new_rand(); let to_pubkey = solana_sdk::pubkey::new_rand(); @@ -6310,6 +6313,9 @@ fn test_account_ids_after_program_ids() { tx.message.account_keys.push(solana_sdk::pubkey::new_rand()); + let slot = bank.slot().saturating_add(1); + let mut bank = Bank::new_from_parent(&Arc::new(bank), &Pubkey::default(), slot); + bank.add_mockup_builtin(solana_vote_program::id(), process_instruction); let result = bank.process_transaction(&tx); assert_eq!(result, Ok(())); @@ -6455,7 +6461,7 @@ fn test_program_id_as_payer() { #[test] fn test_ref_account_key_after_program_id() { let (genesis_config, mint_keypair) = create_genesis_config(500); - let mut bank = Bank::new_for_tests(&genesis_config); + let bank = Bank::new_for_tests(&genesis_config); let from_pubkey = solana_sdk::pubkey::new_rand(); let to_pubkey = solana_sdk::pubkey::new_rand(); @@ -6465,6 +6471,9 @@ fn test_ref_account_key_after_program_id() { AccountMeta::new(to_pubkey, false), ]; + let slot = bank.slot().saturating_add(1); + let mut bank = Bank::new_from_parent(&Arc::new(bank), &Pubkey::default(), slot); + bank.add_mockup_builtin(solana_vote_program::id(), process_instruction); let instruction = Instruction::new_with_bincode(solana_vote_program::id(), &10, account_metas);