From eec581354ee189177dc636df65dc3e35962aa02b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Mei=C3=9Fner?= Date: Tue, 27 Aug 2024 16:54:44 +0200 Subject: [PATCH] Adjusts tests. --- cli/tests/program.rs | 163 ++++++++-- programs/sbf/benches/bpf_loader.rs | 6 +- programs/sbf/tests/programs.rs | 464 +++++++++++++---------------- programs/sbf/tests/simulation.rs | 4 +- programs/sbf/tests/sysvar.rs | 4 +- runtime/src/bank/tests.rs | 13 +- 6 files changed, 359 insertions(+), 295 deletions(-) diff --git a/cli/tests/program.rs b/cli/tests/program.rs index 6bec3bcc28b36f..e711f915bb80ae 100644 --- a/cli/tests/program.rs +++ b/cli/tests/program.rs @@ -23,7 +23,7 @@ use { bpf_loader_upgradeable::{self, UpgradeableLoaderState}, commitment_config::CommitmentConfig, compute_budget::{self, ComputeBudgetInstruction}, - feature_set::enable_alt_bn128_syscall, + feature_set::{enable_alt_bn128_syscall, enable_loader_v4}, fee_calculator::FeeRateGovernor, pubkey::Pubkey, rent::Rent, @@ -32,7 +32,7 @@ use { transaction::Transaction, }, solana_streamer::socket::SocketAddrSpace, - solana_test_validator::{TestValidator, TestValidatorGenesis}, + solana_test_validator::TestValidatorGenesis, solana_transaction_status::UiTransactionEncoding, std::{ env, @@ -81,8 +81,17 @@ fn test_cli_program_deploy_non_upgradeable() { let mint_keypair = Keypair::new(); let mint_pubkey = mint_keypair.pubkey(); let faucet_addr = run_local_faucet(mint_keypair, None); - let test_validator = - TestValidator::with_no_fees(mint_pubkey, Some(faucet_addr), SocketAddrSpace::Unspecified); + let test_validator = TestValidatorGenesis::default() + .fee_rate_governor(FeeRateGovernor::new(0, 0)) + .rent(Rent { + lamports_per_byte_year: 1, + exemption_threshold: 1.0, + ..Rent::default() + }) + .faucet_addr(Some(faucet_addr)) + .deactivate_features(&[enable_loader_v4::id()]) + .start_with_mint_address(mint_pubkey, SocketAddrSpace::Unspecified) + .expect("validator start failed"); let rpc_client = RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed()); @@ -286,8 +295,17 @@ fn test_cli_program_deploy_no_authority() { let mint_keypair = Keypair::new(); let mint_pubkey = mint_keypair.pubkey(); let faucet_addr = run_local_faucet(mint_keypair, None); - let test_validator = - TestValidator::with_no_fees(mint_pubkey, Some(faucet_addr), SocketAddrSpace::Unspecified); + let test_validator = TestValidatorGenesis::default() + .fee_rate_governor(FeeRateGovernor::new(0, 0)) + .rent(Rent { + lamports_per_byte_year: 1, + exemption_threshold: 1.0, + ..Rent::default() + }) + .faucet_addr(Some(faucet_addr)) + .deactivate_features(&[enable_loader_v4::id()]) + .start_with_mint_address(mint_pubkey, SocketAddrSpace::Unspecified) + .expect("validator start failed"); let rpc_client = RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed()); @@ -403,6 +421,7 @@ fn test_cli_program_deploy_feature(enable_feature: bool) { test_validator_builder.deactivate_features(&[enable_alt_bn128_syscall::id()]); } + test_validator_builder = test_validator_builder.deactivate_features(&[enable_loader_v4::id()]); let test_validator = test_validator_builder .start_with_mint_address(mint_pubkey, SocketAddrSpace::Unspecified) .expect("validator start failed"); @@ -530,6 +549,7 @@ fn test_cli_program_upgrade_with_feature(enable_feature: bool) { test_validator_builder.deactivate_features(&[enable_alt_bn128_syscall::id()]); } + test_validator_builder = test_validator_builder.deactivate_features(&[enable_loader_v4::id()]); let test_validator = test_validator_builder .start_with_mint_address(mint_pubkey, SocketAddrSpace::Unspecified) .expect("validator start failed"); @@ -678,8 +698,17 @@ fn test_cli_program_deploy_with_authority() { let mint_keypair = Keypair::new(); let mint_pubkey = mint_keypair.pubkey(); let faucet_addr = run_local_faucet(mint_keypair, None); - let test_validator = - TestValidator::with_no_fees(mint_pubkey, Some(faucet_addr), SocketAddrSpace::Unspecified); + let test_validator = TestValidatorGenesis::default() + .fee_rate_governor(FeeRateGovernor::new(0, 0)) + .rent(Rent { + lamports_per_byte_year: 1, + exemption_threshold: 1.0, + ..Rent::default() + }) + .faucet_addr(Some(faucet_addr)) + .deactivate_features(&[enable_loader_v4::id()]) + .start_with_mint_address(mint_pubkey, SocketAddrSpace::Unspecified) + .expect("validator start failed"); let rpc_client = RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed()); @@ -1079,8 +1108,17 @@ fn test_cli_program_upgrade_auto_extend() { let mint_keypair = Keypair::new(); let mint_pubkey = mint_keypair.pubkey(); let faucet_addr = run_local_faucet(mint_keypair, None); - let test_validator = - TestValidator::with_no_fees(mint_pubkey, Some(faucet_addr), SocketAddrSpace::Unspecified); + let test_validator = TestValidatorGenesis::default() + .fee_rate_governor(FeeRateGovernor::new(0, 0)) + .rent(Rent { + lamports_per_byte_year: 1, + exemption_threshold: 1.0, + ..Rent::default() + }) + .faucet_addr(Some(faucet_addr)) + .deactivate_features(&[enable_loader_v4::id()]) + .start_with_mint_address(mint_pubkey, SocketAddrSpace::Unspecified) + .expect("validator start failed"); let rpc_client = RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed()); @@ -1232,8 +1270,17 @@ fn test_cli_program_close_program() { let mint_keypair = Keypair::new(); let mint_pubkey = mint_keypair.pubkey(); let faucet_addr = run_local_faucet(mint_keypair, None); - let test_validator = - TestValidator::with_no_fees(mint_pubkey, Some(faucet_addr), SocketAddrSpace::Unspecified); + let test_validator = TestValidatorGenesis::default() + .fee_rate_governor(FeeRateGovernor::new(0, 0)) + .rent(Rent { + lamports_per_byte_year: 1, + exemption_threshold: 1.0, + ..Rent::default() + }) + .faucet_addr(Some(faucet_addr)) + .deactivate_features(&[enable_loader_v4::id()]) + .start_with_mint_address(mint_pubkey, SocketAddrSpace::Unspecified) + .expect("validator start failed"); let rpc_client = RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed()); @@ -1351,8 +1398,17 @@ fn test_cli_program_extend_program() { let mint_keypair = Keypair::new(); let mint_pubkey = mint_keypair.pubkey(); let faucet_addr = run_local_faucet(mint_keypair, None); - let test_validator = - TestValidator::with_no_fees(mint_pubkey, Some(faucet_addr), SocketAddrSpace::Unspecified); + let test_validator = TestValidatorGenesis::default() + .fee_rate_governor(FeeRateGovernor::new(0, 0)) + .rent(Rent { + lamports_per_byte_year: 1, + exemption_threshold: 1.0, + ..Rent::default() + }) + .faucet_addr(Some(faucet_addr)) + .deactivate_features(&[enable_loader_v4::id()]) + .start_with_mint_address(mint_pubkey, SocketAddrSpace::Unspecified) + .expect("validator start failed"); let rpc_client = RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed()); @@ -1521,8 +1577,17 @@ fn test_cli_program_write_buffer() { let mint_keypair = Keypair::new(); let mint_pubkey = mint_keypair.pubkey(); let faucet_addr = run_local_faucet(mint_keypair, None); - let test_validator = - TestValidator::with_no_fees(mint_pubkey, Some(faucet_addr), SocketAddrSpace::Unspecified); + let test_validator = TestValidatorGenesis::default() + .fee_rate_governor(FeeRateGovernor::new(0, 0)) + .rent(Rent { + lamports_per_byte_year: 1, + exemption_threshold: 1.0, + ..Rent::default() + }) + .faucet_addr(Some(faucet_addr)) + .deactivate_features(&[enable_loader_v4::id()]) + .start_with_mint_address(mint_pubkey, SocketAddrSpace::Unspecified) + .expect("validator start failed"); let rpc_client = RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed()); @@ -2008,8 +2073,17 @@ fn test_cli_program_set_buffer_authority() { let mint_keypair = Keypair::new(); let mint_pubkey = mint_keypair.pubkey(); let faucet_addr = run_local_faucet(mint_keypair, None); - let test_validator = - TestValidator::with_no_fees(mint_pubkey, Some(faucet_addr), SocketAddrSpace::Unspecified); + let test_validator = TestValidatorGenesis::default() + .fee_rate_governor(FeeRateGovernor::new(0, 0)) + .rent(Rent { + lamports_per_byte_year: 1, + exemption_threshold: 1.0, + ..Rent::default() + }) + .faucet_addr(Some(faucet_addr)) + .deactivate_features(&[enable_loader_v4::id()]) + .start_with_mint_address(mint_pubkey, SocketAddrSpace::Unspecified) + .expect("validator start failed"); let rpc_client = RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed()); @@ -2180,8 +2254,17 @@ fn test_cli_program_mismatch_buffer_authority() { let mint_keypair = Keypair::new(); let mint_pubkey = mint_keypair.pubkey(); let faucet_addr = run_local_faucet(mint_keypair, None); - let test_validator = - TestValidator::with_no_fees(mint_pubkey, Some(faucet_addr), SocketAddrSpace::Unspecified); + let test_validator = TestValidatorGenesis::default() + .fee_rate_governor(FeeRateGovernor::new(0, 0)) + .rent(Rent { + lamports_per_byte_year: 1, + exemption_threshold: 1.0, + ..Rent::default() + }) + .faucet_addr(Some(faucet_addr)) + .deactivate_features(&[enable_loader_v4::id()]) + .start_with_mint_address(mint_pubkey, SocketAddrSpace::Unspecified) + .expect("validator start failed"); let rpc_client = RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed()); @@ -2306,8 +2389,17 @@ fn test_cli_program_deploy_with_offline_signing(use_offline_signer_as_fee_payer: let mint_keypair = Keypair::new(); let mint_pubkey = mint_keypair.pubkey(); let faucet_addr = run_local_faucet(mint_keypair, None); - let test_validator = - TestValidator::with_no_fees(mint_pubkey, Some(faucet_addr), SocketAddrSpace::Unspecified); + let test_validator = TestValidatorGenesis::default() + .fee_rate_governor(FeeRateGovernor::new(0, 0)) + .rent(Rent { + lamports_per_byte_year: 1, + exemption_threshold: 1.0, + ..Rent::default() + }) + .faucet_addr(Some(faucet_addr)) + .deactivate_features(&[enable_loader_v4::id()]) + .start_with_mint_address(mint_pubkey, SocketAddrSpace::Unspecified) + .expect("validator start failed"); let rpc_client = RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed()); @@ -2499,8 +2591,17 @@ fn test_cli_program_show() { let mint_keypair = Keypair::new(); let mint_pubkey = mint_keypair.pubkey(); let faucet_addr = run_local_faucet(mint_keypair, None); - let test_validator = - TestValidator::with_no_fees(mint_pubkey, Some(faucet_addr), SocketAddrSpace::Unspecified); + let test_validator = TestValidatorGenesis::default() + .fee_rate_governor(FeeRateGovernor::new(0, 0)) + .rent(Rent { + lamports_per_byte_year: 1, + exemption_threshold: 1.0, + ..Rent::default() + }) + .faucet_addr(Some(faucet_addr)) + .deactivate_features(&[enable_loader_v4::id()]) + .start_with_mint_address(mint_pubkey, SocketAddrSpace::Unspecified) + .expect("validator start failed"); let rpc_client = RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed()); @@ -2696,8 +2797,17 @@ fn test_cli_program_dump() { let mint_keypair = Keypair::new(); let mint_pubkey = mint_keypair.pubkey(); let faucet_addr = run_local_faucet(mint_keypair, None); - let test_validator = - TestValidator::with_no_fees(mint_pubkey, Some(faucet_addr), SocketAddrSpace::Unspecified); + let test_validator = TestValidatorGenesis::default() + .fee_rate_governor(FeeRateGovernor::new(0, 0)) + .rent(Rent { + lamports_per_byte_year: 1, + exemption_threshold: 1.0, + ..Rent::default() + }) + .faucet_addr(Some(faucet_addr)) + .deactivate_features(&[enable_loader_v4::id()]) + .start_with_mint_address(mint_pubkey, SocketAddrSpace::Unspecified) + .expect("validator start failed"); let rpc_client = RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed()); @@ -2835,6 +2945,7 @@ fn test_cli_program_deploy_with_args(compute_unit_price: Option, use_rpc: b exemption_threshold: 1.0, ..Rent::default() }) + .deactivate_features(&[enable_loader_v4::id()]) .rpc_config(JsonRpcConfig { enable_rpc_transaction_history: true, faucet_addr: Some(faucet_addr), diff --git a/programs/sbf/benches/bpf_loader.rs b/programs/sbf/benches/bpf_loader.rs index ab5e950faab874..68e61b30ca21c1 100644 --- a/programs/sbf/benches/bpf_loader.rs +++ b/programs/sbf/benches/bpf_loader.rs @@ -32,7 +32,7 @@ use { bank::Bank, bank_client::BankClient, genesis_utils::{create_genesis_config, GenesisConfigInfo}, - loader_utils::{load_program_from_file, load_upgradeable_program_and_advance_slot}, + loader_utils::{load_program_from_file, load_program_of_loader_v4}, }, solana_sdk::{ account::AccountSharedData, @@ -202,9 +202,9 @@ fn bench_program_execute_noop(bencher: &mut Bencher) { let authority_keypair = Keypair::new(); let mint_pubkey = mint_keypair.pubkey(); - let (_, invoke_program_id) = load_upgradeable_program_and_advance_slot( + let (_bank, invoke_program_id) = load_program_of_loader_v4( &mut bank_client, - bank_forks.as_ref(), + &bank_forks, &mint_keypair, &authority_keypair, "noop", diff --git a/programs/sbf/tests/programs.rs b/programs/sbf/tests/programs.rs index 1b44bacfb55ffa..88342962eca024 100644 --- a/programs/sbf/tests/programs.rs +++ b/programs/sbf/tests/programs.rs @@ -27,8 +27,8 @@ use { create_genesis_config_with_leader_ex, GenesisConfigInfo, }, loader_utils::{ - create_program, load_program_from_file, load_upgradeable_buffer, - load_upgradeable_program, load_upgradeable_program_and_advance_slot, + create_program, instructions_to_load_program_of_loader_v4, load_program_from_file, + load_program_of_loader_v4, load_upgradeable_buffer, load_upgradeable_program, load_upgradeable_program_wrapper, set_upgrade_authority, upgrade_program, }, }, @@ -50,6 +50,7 @@ use { genesis_config::ClusterType, hash::Hash, instruction::{AccountMeta, Instruction, InstructionError}, + loader_v4, message::{v0::LoadedAddresses, Message, SanitizedMessage}, pubkey::Pubkey, rent::Rent, @@ -287,9 +288,9 @@ fn test_program_sbf_sanity() { let authority_keypair = Keypair::new(); // Call user program - let (_, program_id) = load_upgradeable_program_and_advance_slot( + let (_bank, program_id) = load_program_of_loader_v4( &mut bank_client, - bank_forks.as_ref(), + &bank_forks, &mint_keypair, &authority_keypair, program.0, @@ -381,9 +382,9 @@ fn test_sol_alloc_free_no_longer_deployable_with_upgradeable_loader() { // in elf inside syscall table. In this case, `sol_alloc_free_` can't be // found in syscall table. Hence, the verification fails and the deployment // fails. - let (_bank, _program_id) = load_upgradeable_program_and_advance_slot( + let (_bank, _program_id) = load_program_of_loader_v4( &mut bank_client, - bank_forks.as_ref(), + &bank_forks, &mint_keypair, &authority_keypair, "solana_sbf_rust_deprecated_loader", @@ -418,9 +419,9 @@ fn test_program_sbf_duplicate_accounts() { let mut bank_client = BankClient::new_shared(bank.clone()); let authority_keypair = Keypair::new(); - let (bank, program_id) = load_upgradeable_program_and_advance_slot( + let (bank, program_id) = load_program_of_loader_v4( &mut bank_client, - bank_forks.as_ref(), + &bank_forks, &mint_keypair, &authority_keypair, program, @@ -525,9 +526,9 @@ fn test_program_sbf_error_handling() { let mut bank_client = BankClient::new_shared(bank); let authority_keypair = Keypair::new(); - let (_bank, program_id) = load_upgradeable_program_and_advance_slot( + let (_bank, program_id) = load_program_of_loader_v4( &mut bank_client, - bank_forks.as_ref(), + &bank_forks, &mint_keypair, &authority_keypair, program, @@ -635,9 +636,9 @@ fn test_return_data_and_log_data_syscall() { let mut bank_client = BankClient::new_shared(bank.clone()); let authority_keypair = Keypair::new(); - let (bank, program_id) = load_upgradeable_program_and_advance_slot( + let (bank, program_id) = load_program_of_loader_v4( &mut bank_client, - bank_forks.as_ref(), + &bank_forks, &mint_keypair, &authority_keypair, program, @@ -704,23 +705,23 @@ fn test_program_sbf_invoke_sanity() { let mut bank_client = BankClient::new_shared(bank.clone()); let authority_keypair = Keypair::new(); - let invoke_program_id = load_upgradeable_program_wrapper( - &bank_client, + let (_bank, invoke_program_id) = load_program_of_loader_v4( + &mut bank_client, + &bank_forks, &mint_keypair, &authority_keypair, program.1, ); - - let invoked_program_id = load_upgradeable_program_wrapper( - &bank_client, + let (_bank, invoked_program_id) = load_program_of_loader_v4( + &mut bank_client, + &bank_forks, &mint_keypair, &authority_keypair, program.2, ); - - let (bank, noop_program_id) = load_upgradeable_program_and_advance_slot( + let (bank, noop_program_id) = load_program_of_loader_v4( &mut bank_client, - bank_forks.as_ref(), + &bank_forks, &mint_keypair, &authority_keypair, program.3, @@ -1125,16 +1126,16 @@ fn test_program_sbf_program_id_spoofing() { let mut bank_client = BankClient::new_shared(bank.clone()); let authority_keypair = Keypair::new(); - let malicious_swap_pubkey = load_upgradeable_program_wrapper( - &bank_client, + let (_bank, malicious_swap_pubkey) = load_program_of_loader_v4( + &mut bank_client, + &bank_forks, &mint_keypair, &authority_keypair, "solana_sbf_rust_spoof1", ); - - let (bank, malicious_system_pubkey) = load_upgradeable_program_and_advance_slot( + let (bank, malicious_system_pubkey) = load_program_of_loader_v4( &mut bank_client, - bank_forks.as_ref(), + &bank_forks, &mint_keypair, &authority_keypair, "solana_sbf_rust_spoof1_system", @@ -1179,16 +1180,16 @@ fn test_program_sbf_caller_has_access_to_cpi_program() { let mut bank_client = BankClient::new_shared(bank.clone()); let authority_keypair = Keypair::new(); - let caller_pubkey = load_upgradeable_program_wrapper( - &bank_client, + let (_bank, caller_pubkey) = load_program_of_loader_v4( + &mut bank_client, + &bank_forks, &mint_keypair, &authority_keypair, "solana_sbf_rust_caller_access", ); - - let (_bank, caller2_pubkey) = load_upgradeable_program_and_advance_slot( + let (_bank, caller2_pubkey) = load_program_of_loader_v4( &mut bank_client, - bank_forks.as_ref(), + &bank_forks, &mint_keypair, &authority_keypair, "solana_sbf_rust_caller_access", @@ -1221,9 +1222,9 @@ fn test_program_sbf_ro_modify() { let mut bank_client = BankClient::new_shared(bank.clone()); let authority_keypair = Keypair::new(); - let (bank, program_pubkey) = load_upgradeable_program_and_advance_slot( + let (bank, program_pubkey) = load_program_of_loader_v4( &mut bank_client, - bank_forks.as_ref(), + &bank_forks, &mint_keypair, &authority_keypair, "solana_sbf_rust_ro_modify", @@ -1278,9 +1279,9 @@ fn test_program_sbf_call_depth() { let mut bank_client = BankClient::new_shared(bank); let authority_keypair = Keypair::new(); - let (_, program_id) = load_upgradeable_program_and_advance_slot( + let (_bank, program_id) = load_program_of_loader_v4( &mut bank_client, - bank_forks.as_ref(), + &bank_forks, &mint_keypair, &authority_keypair, "solana_sbf_rust_call_depth", @@ -1315,9 +1316,9 @@ fn test_program_sbf_compute_budget() { let mut bank_client = BankClient::new_shared(bank); let authority_keypair = Keypair::new(); - let (_, program_id) = load_upgradeable_program_and_advance_slot( + let (_bank, program_id) = load_program_of_loader_v4( &mut bank_client, - bank_forks.as_ref(), + &bank_forks, &mint_keypair, &authority_keypair, "solana_sbf_rust_noop", @@ -1446,9 +1447,9 @@ fn test_program_sbf_instruction_introspection() { let mut bank_client = BankClient::new_shared(bank.clone()); let authority_keypair = Keypair::new(); - let (bank, program_id) = load_upgradeable_program_and_advance_slot( + let (_bank, program_id) = load_program_of_loader_v4( &mut bank_client, - bank_forks.as_ref(), + &bank_forks, &mint_keypair, &authority_keypair, "solana_sbf_rust_instruction_introspection", @@ -1497,10 +1498,13 @@ fn test_program_sbf_upgrade() { solana_logger::setup(); let GenesisConfigInfo { - genesis_config, + mut genesis_config, mint_keypair, .. } = create_genesis_config(50); + genesis_config + .accounts + .remove(&feature_set::enable_loader_v4::id()); let (bank, bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config); let mut bank_client = BankClient::new_shared(bank); @@ -1636,10 +1640,13 @@ fn test_program_sbf_invoke_stable_genesis_and_bank() { solana_logger::setup(); let GenesisConfigInfo { - genesis_config, + mut genesis_config, mint_keypair, .. } = get_stable_genesis_config(); + genesis_config + .accounts + .remove(&feature_set::enable_loader_v4::id()); let bank = Bank::new_for_tests(&genesis_config); let bank = Arc::new(bank); let bank_client = BankClient::new_shared(bank.clone()); @@ -1818,26 +1825,46 @@ fn test_program_sbf_invoke_in_same_tx_as_deployment() { let mut bank_client = BankClient::new_shared(bank.clone()); // Deploy upgradeable program - let buffer_keypair = Keypair::new(); - let program_keypair = Keypair::new(); - let program_id = program_keypair.pubkey(); let authority_keypair = Keypair::new(); + let (program_keypair, mut deployment_instructions) = instructions_to_load_program_of_loader_v4( + &bank_client, + &mint_keypair, + &authority_keypair, + "solana_sbf_rust_noop", + None, + None, + ); + let deployment_instruction = deployment_instructions.pop().unwrap(); + let program_id = program_keypair.pubkey(); + let signers: &[&[&Keypair]] = &[ + &[&mint_keypair, &program_keypair], + &[&mint_keypair, &program_keypair, &authority_keypair], + &[&mint_keypair, &authority_keypair], + ]; + let signers = std::iter::once(signers[0]) + .chain(std::iter::once(signers[1])) + .chain(std::iter::repeat(signers[2])); + for (instruction, signers) in deployment_instructions.into_iter().zip(signers) { + let message = Message::new(&[instruction], Some(&mint_keypair.pubkey())); + bank_client + .send_and_confirm_message(signers, message) + .unwrap(); + } // Deploy indirect invocation program - let indirect_program_keypair = Keypair::new(); - load_upgradeable_program( - &bank_client, + let (bank, indirect_program_id) = load_program_of_loader_v4( + &mut bank_client, + &bank_forks, &mint_keypair, - &buffer_keypair, - &indirect_program_keypair, &authority_keypair, "solana_sbf_rust_invoke_and_return", ); + // Prepare invocations let invoke_instruction = Instruction::new_with_bytes(program_id, &[0], vec![AccountMeta::new(clock::id(), false)]); let indirect_invoke_instruction = Instruction::new_with_bytes( - indirect_program_keypair.pubkey(), + indirect_program_id, &[0], vec![ AccountMeta::new_readonly(program_id, false), @@ -1845,44 +1872,17 @@ fn test_program_sbf_invoke_in_same_tx_as_deployment() { ], ); - // Prepare deployment - let program = load_upgradeable_buffer( - &bank_client, - &mint_keypair, - &buffer_keypair, - &authority_keypair, - "solana_sbf_rust_noop", - ); - let deployment_instructions = bpf_loader_upgradeable::deploy_with_max_program_len( - &mint_keypair.pubkey(), - &program_keypair.pubkey(), - &buffer_keypair.pubkey(), - &authority_keypair.pubkey(), - 1.max( - bank_client - .get_minimum_balance_for_rent_exemption( - bpf_loader_upgradeable::UpgradeableLoaderState::size_of_program(), - ) - .unwrap(), - ), - program.len() * 2, - ) - .unwrap(); - - let bank = bank_client - .advance_slot(1, bank_forks.as_ref(), &Pubkey::default()) - .expect("Failed to advance slot"); - // Deployment is invisible to both top-level-instructions and CPI instructions for (index, invoke_instruction) in [invoke_instruction, indirect_invoke_instruction] .into_iter() .enumerate() { - let mut instructions = deployment_instructions.clone(); - instructions.push(invoke_instruction); let tx = Transaction::new( &[&mint_keypair, &program_keypair, &authority_keypair], - Message::new(&instructions, Some(&mint_keypair.pubkey())), + Message::new( + &[deployment_instruction.clone(), invoke_instruction], + Some(&mint_keypair.pubkey()), + ), bank.last_blockhash(), ); if index == 0 { @@ -1915,45 +1915,53 @@ fn test_program_sbf_invoke_in_same_tx_as_redeployment() { let mut bank_client = BankClient::new_shared(bank.clone()); // Deploy upgradeable program - let buffer_keypair = Keypair::new(); - let program_keypair = Keypair::new(); - let program_id = program_keypair.pubkey(); let authority_keypair = Keypair::new(); - load_upgradeable_program( - &bank_client, + let (_bank, program_id) = load_program_of_loader_v4( + &mut bank_client, + &bank_forks, &mint_keypair, - &buffer_keypair, - &program_keypair, &authority_keypair, "solana_sbf_rust_noop", ); + let (source_program_keypair, mut redeployment_instructions) = + instructions_to_load_program_of_loader_v4( + &bank_client, + &mint_keypair, + &authority_keypair, + "solana_sbf_rust_panic", + None, + Some(&program_id), + ); + let redeployment_instruction = redeployment_instructions.pop().unwrap(); + let signers: &[&[&Keypair]] = &[ + &[&mint_keypair, &source_program_keypair], + &[&mint_keypair, &source_program_keypair, &authority_keypair], + &[&mint_keypair, &authority_keypair], + ]; + let signers = std::iter::once(signers[0]) + .chain(std::iter::once(signers[1])) + .chain(std::iter::repeat(signers[2])); + for (instruction, signers) in redeployment_instructions.into_iter().zip(signers) { + let message = Message::new(&[instruction], Some(&mint_keypair.pubkey())); + bank_client + .send_and_confirm_message(signers, message) + .unwrap(); + } // Deploy indirect invocation program - let indirect_program_keypair = Keypair::new(); - load_upgradeable_program( - &bank_client, + let (bank, indirect_program_id) = load_program_of_loader_v4( + &mut bank_client, + &bank_forks, &mint_keypair, - &buffer_keypair, - &indirect_program_keypair, &authority_keypair, "solana_sbf_rust_invoke_and_return", ); - // Deploy panic program - let panic_program_keypair = Keypair::new(); - load_upgradeable_program( - &bank_client, - &mint_keypair, - &buffer_keypair, - &panic_program_keypair, - &authority_keypair, - "solana_sbf_rust_panic", - ); - + // Prepare invocations let invoke_instruction = Instruction::new_with_bytes(program_id, &[0], vec![AccountMeta::new(clock::id(), false)]); let indirect_invoke_instruction = Instruction::new_with_bytes( - indirect_program_keypair.pubkey(), + indirect_program_id, &[0], vec![ AccountMeta::new_readonly(program_id, false), @@ -1961,31 +1969,6 @@ fn test_program_sbf_invoke_in_same_tx_as_redeployment() { ], ); - // load_upgradeable_program sets clock sysvar to 1, which causes the program to be effective - // after 2 slots. They need to be called individually to create the correct fork graph in between. - bank_client - .advance_slot(1, bank_forks.as_ref(), &Pubkey::default()) - .unwrap(); - let bank = bank_client - .advance_slot(1, bank_forks.as_ref(), &Pubkey::default()) - .unwrap(); - - // Prepare redeployment - let buffer_keypair = Keypair::new(); - load_upgradeable_buffer( - &bank_client, - &mint_keypair, - &buffer_keypair, - &authority_keypair, - "solana_sbf_rust_panic", - ); - let redeployment_instruction = bpf_loader_upgradeable::upgrade( - &program_id, - &buffer_keypair.pubkey(), - &authority_keypair.pubkey(), - &mint_keypair.pubkey(), - ); - // Redeployment causes programs to be unavailable to both top-level-instructions and CPI instructions for invoke_instruction in [invoke_instruction, indirect_invoke_instruction] { // Call upgradeable program @@ -2025,34 +2008,29 @@ fn test_program_sbf_invoke_in_same_tx_as_undeployment() { let mut bank_client = BankClient::new_shared(bank.clone()); // Deploy upgradeable program - let buffer_keypair = Keypair::new(); - let program_keypair = Keypair::new(); - let program_id = program_keypair.pubkey(); let authority_keypair = Keypair::new(); - load_upgradeable_program( - &bank_client, + let (_bank, program_id) = load_program_of_loader_v4( + &mut bank_client, + &bank_forks, &mint_keypair, - &buffer_keypair, - &program_keypair, &authority_keypair, "solana_sbf_rust_noop", ); // Deploy indirect invocation program - let indirect_program_keypair = Keypair::new(); - load_upgradeable_program( - &bank_client, + let (bank, indirect_program_id) = load_program_of_loader_v4( + &mut bank_client, + &bank_forks, &mint_keypair, - &buffer_keypair, - &indirect_program_keypair, &authority_keypair, "solana_sbf_rust_invoke_and_return", ); + // Prepare invocations let invoke_instruction = Instruction::new_with_bytes(program_id, &[0], vec![AccountMeta::new(clock::id(), false)]); let indirect_invoke_instruction = Instruction::new_with_bytes( - indirect_program_keypair.pubkey(), + indirect_program_id, &[0], vec![ AccountMeta::new_readonly(program_id, false), @@ -2060,26 +2038,8 @@ fn test_program_sbf_invoke_in_same_tx_as_undeployment() { ], ); - // load_upgradeable_program sets clock sysvar to 1, which causes the program to be effective - // after 2 slots. They need to be called individually to create the correct fork graph in between. - bank_client - .advance_slot(1, bank_forks.as_ref(), &Pubkey::default()) - .unwrap(); - let bank = bank_client - .advance_slot(1, bank_forks.as_ref(), &Pubkey::default()) - .unwrap(); - // Prepare undeployment - let (programdata_address, _) = Pubkey::find_program_address( - &[program_keypair.pubkey().as_ref()], - &bpf_loader_upgradeable::id(), - ); - let undeployment_instruction = bpf_loader_upgradeable::close_any( - &programdata_address, - &mint_keypair.pubkey(), - Some(&authority_keypair.pubkey()), - Some(&program_id), - ); + let undeployment_instruction = loader_v4::retract(&program_id, &authority_keypair.pubkey()); // Undeployment is visible to both top-level-instructions and CPI instructions for invoke_instruction in [invoke_instruction, indirect_invoke_instruction] { @@ -2121,29 +2081,22 @@ fn test_program_sbf_invoke_upgradeable_via_cpi() { let mut bank_client = BankClient::new_shared(bank); let authority_keypair = Keypair::new(); - let (_bank, invoke_and_return) = load_upgradeable_program_and_advance_slot( + let (_bank, invoke_and_return) = load_program_of_loader_v4( &mut bank_client, - bank_forks.as_ref(), + &bank_forks, &mint_keypair, &authority_keypair, "solana_sbf_rust_invoke_and_return", ); // Deploy upgradeable program - let program_id = load_upgradeable_program_wrapper( - &bank_client, + let (_bank, program_id) = load_program_of_loader_v4( + &mut bank_client, + &bank_forks, &mint_keypair, &authority_keypair, "solana_sbf_rust_upgradeable", ); - bank_client.set_sysvar_for_tests(&clock::Clock { - slot: 2, - ..clock::Clock::default() - }); - - bank_client - .advance_slot(1, bank_forks.as_ref(), &Pubkey::default()) - .expect("Failed to advance slot"); let mut instruction = Instruction::new_with_bytes( invoke_and_return, @@ -2251,9 +2204,9 @@ fn test_program_sbf_disguised_as_sbf_loader() { let mut bank_client = BankClient::new_shared(bank); let authority_keypair = Keypair::new(); - let (_bank, program_id) = load_upgradeable_program_and_advance_slot( + let (_bank, program_id) = load_program_of_loader_v4( &mut bank_client, - bank_forks.as_ref(), + &bank_forks, &mint_keypair, &authority_keypair, program, @@ -2284,9 +2237,9 @@ fn test_program_reads_from_program_account() { let mut bank_client = BankClient::new_shared(bank); let authority_keypair = Keypair::new(); - let (_bank, program_id) = load_upgradeable_program_and_advance_slot( + let (_bank, program_id) = load_program_of_loader_v4( &mut bank_client, - bank_forks.as_ref(), + &bank_forks, &mint_keypair, &authority_keypair, "read_program", @@ -2317,9 +2270,9 @@ fn test_program_sbf_c_dup() { let mut bank_client = BankClient::new_shared(bank); let authority_keypair = Keypair::new(); - let (_, program_id) = load_upgradeable_program_and_advance_slot( + let (_bank, program_id) = load_program_of_loader_v4( &mut bank_client, - bank_forks.as_ref(), + &bank_forks, &mint_keypair, &authority_keypair, "ser", @@ -2349,30 +2302,23 @@ fn test_program_sbf_upgrade_via_cpi() { let mut bank_client = BankClient::new_shared(bank); let authority_keypair = Keypair::new(); - let (_bank, invoke_and_return) = load_upgradeable_program_and_advance_slot( + let (_bank, invoke_and_return) = load_program_of_loader_v4( &mut bank_client, - bank_forks.as_ref(), + &bank_forks, &mint_keypair, &authority_keypair, "solana_sbf_rust_invoke_and_return", ); // Deploy upgradeable program - let buffer_keypair = Keypair::new(); - let program_keypair = Keypair::new(); - let program_id = program_keypair.pubkey(); let authority_keypair = Keypair::new(); - load_upgradeable_program( - &bank_client, + let (_bank, program_id) = load_program_of_loader_v4( + &mut bank_client, + &bank_forks, &mint_keypair, - &buffer_keypair, - &program_keypair, &authority_keypair, "solana_sbf_rust_upgradeable", ); - bank_client - .advance_slot(1, bank_forks.as_ref(), &Pubkey::default()) - .expect("Failed to advance the slot"); let program_account = bank_client.get_account(&program_id).unwrap().unwrap(); let Ok(bpf_loader_upgradeable::UpgradeableLoaderState::Program { programdata_address, @@ -2454,11 +2400,13 @@ fn test_program_sbf_set_upgrade_authority_via_cpi() { solana_logger::setup(); let GenesisConfigInfo { - genesis_config, + mut genesis_config, mint_keypair, .. } = create_genesis_config(50); - + genesis_config + .accounts + .remove(&feature_set::enable_loader_v4::id()); let (bank, bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config); let mut bank_client = BankClient::new_shared(bank); let authority_keypair = Keypair::new(); @@ -2543,10 +2491,13 @@ fn test_program_upgradeable_locks() { solana_logger::setup(); let GenesisConfigInfo { - genesis_config, + mut genesis_config, mint_keypair, .. } = create_genesis_config(2_000_000_000); + genesis_config + .accounts + .remove(&feature_set::enable_loader_v4::id()); let (bank, bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config); let mut bank_client = BankClient::new_shared(bank.clone()); @@ -2674,9 +2625,9 @@ fn test_program_sbf_ro_account_modify() { let mut bank_client = BankClient::new_shared(bank.clone()); let authority_keypair = Keypair::new(); - let (bank, program_id) = load_upgradeable_program_and_advance_slot( + let (bank, program_id) = load_program_of_loader_v4( &mut bank_client, - bank_forks.as_ref(), + &bank_forks, &mint_keypair, &authority_keypair, "solana_sbf_rust_ro_account_modify", @@ -2748,9 +2699,9 @@ fn test_program_sbf_realloc() { let mut bank_client = BankClient::new_shared(bank.clone()); let authority_keypair = Keypair::new(); - let (bank, program_id) = load_upgradeable_program_and_advance_slot( + let (bank, program_id) = load_program_of_loader_v4( &mut bank_client, - bank_forks.as_ref(), + &bank_forks, &mint_keypair, &authority_keypair, "solana_sbf_rust_realloc", @@ -3165,16 +3116,16 @@ fn test_program_sbf_realloc_invoke() { let mut bank_client = BankClient::new_shared(bank.clone()); let authority_keypair = Keypair::new(); - let realloc_program_id = load_upgradeable_program_wrapper( - &bank_client, + let (_bank, realloc_program_id) = load_program_of_loader_v4( + &mut bank_client, + &bank_forks, &mint_keypair, &authority_keypair, "solana_sbf_rust_realloc", ); - - let (bank, realloc_invoke_program_id) = load_upgradeable_program_and_advance_slot( + let (bank, realloc_invoke_program_id) = load_program_of_loader_v4( &mut bank_client, - bank_forks.as_ref(), + &bank_forks, &mint_keypair, &authority_keypair, "solana_sbf_rust_realloc_invoke", @@ -3778,27 +3729,30 @@ fn test_program_sbf_processed_inner_instruction() { let mut bank_client = BankClient::new_shared(bank.clone()); let authority_keypair = Keypair::new(); - let sibling_program_id = load_upgradeable_program_wrapper( - &bank_client, + let (_bank, sibling_program_id) = load_program_of_loader_v4( + &mut bank_client, + &bank_forks, &mint_keypair, &authority_keypair, "solana_sbf_rust_sibling_instructions", ); - let sibling_inner_program_id = load_upgradeable_program_wrapper( - &bank_client, + let (_bank, sibling_inner_program_id) = load_program_of_loader_v4( + &mut bank_client, + &bank_forks, &mint_keypair, &authority_keypair, "solana_sbf_rust_sibling_inner_instructions", ); - let noop_program_id = load_upgradeable_program_wrapper( - &bank_client, + let (_bank, noop_program_id) = load_program_of_loader_v4( + &mut bank_client, + &bank_forks, &mint_keypair, &authority_keypair, - "solana_sbf_rust_noop", + "noop_program_id", ); - let (_, invoke_and_return_program_id) = load_upgradeable_program_and_advance_slot( + let (_bank, invoke_and_return_program_id) = load_program_of_loader_v4( &mut bank_client, - bank_forks.as_ref(), + &bank_forks, &mint_keypair, &authority_keypair, "solana_sbf_rust_invoke_and_return", @@ -3861,9 +3815,9 @@ fn test_program_fees() { let mut bank_client = BankClient::new_shared(bank); let authority_keypair = Keypair::new(); - let (_bank, program_id) = load_upgradeable_program_and_advance_slot( + let (_bank, program_id) = load_program_of_loader_v4( &mut bank_client, - bank_forks.as_ref(), + &bank_forks, &mint_keypair, &authority_keypair, "solana_sbf_rust_noop", @@ -3948,9 +3902,9 @@ fn test_get_minimum_delegation() { let mut bank_client = BankClient::new_shared(bank.clone()); let authority_keypair = Keypair::new(); - let (_bank, program_id) = load_upgradeable_program_and_advance_slot( + let (_bank, program_id) = load_program_of_loader_v4( &mut bank_client, - bank_forks.as_ref(), + &bank_forks, &mint_keypair, &authority_keypair, "solana_sbf_rust_get_minimum_delegation", @@ -4023,23 +3977,23 @@ fn test_cpi_account_ownership_writability() { let mut bank_client = BankClient::new_shared(bank); let authority_keypair = Keypair::new(); - let invoke_program_id = load_upgradeable_program_wrapper( - &bank_client, + let (_bank, invoke_program_id) = load_program_of_loader_v4( + &mut bank_client, + &bank_forks, &mint_keypair, &authority_keypair, "solana_sbf_rust_invoke", ); - - let invoked_program_id = load_upgradeable_program_wrapper( - &bank_client, + let (_bank, invoked_program_id) = load_program_of_loader_v4( + &mut bank_client, + &bank_forks, &mint_keypair, &authority_keypair, "solana_sbf_rust_invoked", ); - - let (bank, realloc_program_id) = load_upgradeable_program_and_advance_slot( + let (bank, realloc_program_id) = load_program_of_loader_v4( &mut bank_client, - bank_forks.as_ref(), + &bank_forks, &mint_keypair, &authority_keypair, "solana_sbf_rust_realloc", @@ -4207,16 +4161,16 @@ fn test_cpi_account_data_updates() { let mut bank_client = BankClient::new_shared(bank); let authority_keypair = Keypair::new(); - let invoke_program_id = load_upgradeable_program_wrapper( - &bank_client, + let (_bank, invoke_program_id) = load_program_of_loader_v4( + &mut bank_client, + &bank_forks, &mint_keypair, &authority_keypair, "solana_sbf_rust_invoke", ); - - let (bank, realloc_program_id) = load_upgradeable_program_and_advance_slot( + let (bank, realloc_program_id) = load_program_of_loader_v4( &mut bank_client, - bank_forks.as_ref(), + &bank_forks, &mint_keypair, &authority_keypair, "solana_sbf_rust_realloc", @@ -4365,9 +4319,9 @@ fn test_cpi_deprecated_loader_realloc() { let mut bank_client = BankClient::new_shared(bank); let authority_keypair = Keypair::new(); - let (bank, invoke_program_id) = load_upgradeable_program_and_advance_slot( + let (bank, invoke_program_id) = load_program_of_loader_v4( &mut bank_client, - bank_forks.as_ref(), + &bank_forks, &mint_keypair, &authority_keypair, "solana_sbf_rust_invoke", @@ -4510,9 +4464,9 @@ fn test_cpi_change_account_data_memory_allocation() { let mut bank_client = BankClient::new_shared(bank); let authority_keypair = Keypair::new(); - let (bank, invoke_program_id) = load_upgradeable_program_and_advance_slot( + let (bank, invoke_program_id) = load_program_of_loader_v4( &mut bank_client, - bank_forks.as_ref(), + &bank_forks, &mint_keypair, &authority_keypair, "solana_sbf_rust_invoke", @@ -4555,12 +4509,16 @@ fn test_cpi_invalid_account_info_pointers() { let mut bank_client = BankClient::new_shared(bank); let authority_keypair = Keypair::new(); - let c_invoke_program_id = - load_upgradeable_program_wrapper(&bank_client, &mint_keypair, &authority_keypair, "invoke"); - - let (bank, invoke_program_id) = load_upgradeable_program_and_advance_slot( + let (_bank, c_invoke_program_id) = load_program_of_loader_v4( + &mut bank_client, + &bank_forks, + &mint_keypair, + &authority_keypair, + "invoke", + ); + let (bank, invoke_program_id) = load_program_of_loader_v4( &mut bank_client, - bank_forks.as_ref(), + &bank_forks, &mint_keypair, &authority_keypair, "solana_sbf_rust_invoke", @@ -4625,9 +4583,9 @@ fn test_deny_executable_write() { let mut bank_client = BankClient::new_shared(bank); let authority_keypair = Keypair::new(); - let (_bank, invoke_program_id) = load_upgradeable_program_and_advance_slot( + let (_bank, invoke_program_id) = load_program_of_loader_v4( &mut bank_client, - bank_forks.as_ref(), + &bank_forks, &mint_keypair, &authority_keypair, "solana_sbf_rust_invoke", @@ -4680,9 +4638,9 @@ fn test_update_callee_account() { let mut bank_client = BankClient::new_shared(bank.clone()); let authority_keypair = Keypair::new(); - let (bank, invoke_program_id) = load_upgradeable_program_and_advance_slot( + let (bank, invoke_program_id) = load_program_of_loader_v4( &mut bank_client, - bank_forks.as_ref(), + &bank_forks, &mint_keypair, &authority_keypair, "solana_sbf_rust_invoke", @@ -4951,27 +4909,21 @@ fn test_clone_account_data() { let mut bank_client = BankClient::new_shared(bank.clone()); let authority_keypair = Keypair::new(); - let (_, invoke_program_id) = load_upgradeable_program_and_advance_slot( + let (_bank, invoke_program_id) = load_program_of_loader_v4( &mut bank_client, - bank_forks.as_ref(), + &bank_forks, &mint_keypair, &authority_keypair, "solana_sbf_rust_invoke", ); - - let (bank, invoke_program_id2) = load_upgradeable_program_and_advance_slot( + let (bank, invoke_program_id2) = load_program_of_loader_v4( &mut bank_client, - bank_forks.as_ref(), + &bank_forks, &mint_keypair, &authority_keypair, "solana_sbf_rust_invoke", ); - assert_ne!(invoke_program_id, invoke_program_id2); - - println!("invoke_program_id:{invoke_program_id}"); - println!("invoke_program_id2:{invoke_program_id2}"); - let account_keypair = Keypair::new(); let mint_pubkey = mint_keypair.pubkey(); @@ -5086,9 +5038,9 @@ fn test_stack_heap_zeroed() { let mut bank_client = BankClient::new_shared(bank); let authority_keypair = Keypair::new(); - let (bank, invoke_program_id) = load_upgradeable_program_and_advance_slot( + let (bank, invoke_program_id) = load_program_of_loader_v4( &mut bank_client, - bank_forks.as_ref(), + &bank_forks, &mint_keypair, &authority_keypair, "solana_sbf_rust_invoke", @@ -5152,9 +5104,9 @@ fn test_function_call_args() { let mut bank_client = BankClient::new_shared(bank); let authority_keypair = Keypair::new(); - let (bank, program_id) = load_upgradeable_program_and_advance_slot( + let (bank, program_id) = load_program_of_loader_v4( &mut bank_client, - bank_forks.as_ref(), + &bank_forks, &mint_keypair, &authority_keypair, "solana_sbf_rust_call_args", diff --git a/programs/sbf/tests/simulation.rs b/programs/sbf/tests/simulation.rs index a1a9f6a6ce8ab0..1bcc98e262ff3f 100644 --- a/programs/sbf/tests/simulation.rs +++ b/programs/sbf/tests/simulation.rs @@ -6,7 +6,7 @@ use { bank::Bank, bank_client::BankClient, genesis_utils::{create_genesis_config, GenesisConfigInfo}, - loader_utils::load_upgradeable_program_and_advance_slot, + loader_utils::load_program_of_loader_v4, }, solana_sdk::{ instruction::{AccountMeta, Instruction}, @@ -30,7 +30,7 @@ fn test_no_panic_banks_client() { let (bank, bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config); let mut bank_client = BankClient::new_shared(bank.clone()); let authority_keypair = Keypair::new(); - let (bank, program_id) = load_upgradeable_program_and_advance_slot( + let (bank, program_id) = load_program_of_loader_v4( &mut bank_client, bank_forks.as_ref(), &mint_keypair, diff --git a/programs/sbf/tests/sysvar.rs b/programs/sbf/tests/sysvar.rs index 92213bb36d33bb..f7b088bd0a53dc 100644 --- a/programs/sbf/tests/sysvar.rs +++ b/programs/sbf/tests/sysvar.rs @@ -5,7 +5,7 @@ use { bank::Bank, bank_client::BankClient, genesis_utils::{create_genesis_config, GenesisConfigInfo}, - loader_utils::load_upgradeable_program_and_advance_slot, + loader_utils::load_program_of_loader_v4, }, solana_sdk::{ feature_set::disable_fees_sysvar, @@ -43,7 +43,7 @@ fn test_sysvar_syscalls() { let (bank, bank_forks) = bank.wrap_with_bank_forks_for_tests(); let mut bank_client = BankClient::new_shared(bank); let authority_keypair = Keypair::new(); - let (bank, program_id) = load_upgradeable_program_and_advance_slot( + let (bank, program_id) = load_program_of_loader_v4( &mut bank_client, bank_forks.as_ref(), &mint_keypair, diff --git a/runtime/src/bank/tests.rs b/runtime/src/bank/tests.rs index 184c3ec9a55033..72cbe32459662a 100644 --- a/runtime/src/bank/tests.rs +++ b/runtime/src/bank/tests.rs @@ -7009,9 +7009,11 @@ fn test_bank_load_program() { #[test] fn test_bpf_loader_upgradeable_deploy_with_max_len() { - let (genesis_config, mint_keypair) = create_genesis_config_no_tx_fee(1_000_000_000); - let mut bank = Bank::new_for_tests(&genesis_config); - bank.feature_set = Arc::new(FeatureSet::all_enabled()); + let (mut genesis_config, mint_keypair) = create_genesis_config_no_tx_fee(1_000_000_000); + genesis_config + .accounts + .remove(&feature_set::enable_loader_v4::id()); + let bank = Bank::new_for_tests(&genesis_config); let (bank, bank_forks) = bank.wrap_with_bank_forks_for_tests(); let mut bank_client = BankClient::new_shared(bank.clone()); @@ -12997,9 +12999,8 @@ fn test_deploy_last_epoch_slot() { let (mut genesis_config, mint_keypair) = create_genesis_config(1_000_000 * LAMPORTS_PER_SOL); genesis_config .accounts - .remove(&feature_set::reject_callx_r10::id()); - let mut bank = Bank::new_for_tests(&genesis_config); - bank.activate_feature(&feature_set::reject_callx_r10::id()); + .remove(&feature_set::enable_loader_v4::id()); + let bank = Bank::new_for_tests(&genesis_config); // go to the last slot in the epoch let (bank, bank_forks) = bank.wrap_with_bank_forks_for_tests();