From 918be5cfa554001904e87e3d1fd81da2d703422d Mon Sep 17 00:00:00 2001 From: HaoranYi Date: Thu, 11 Jan 2024 20:55:40 +0000 Subject: [PATCH] delete sof_alloc_free_syscall enabled tests --- programs/sbf/tests/programs.rs | 150 +-------------------------------- 1 file changed, 3 insertions(+), 147 deletions(-) diff --git a/programs/sbf/tests/programs.rs b/programs/sbf/tests/programs.rs index 472268f49ad169..49e70d3d33d62f 100644 --- a/programs/sbf/tests/programs.rs +++ b/programs/sbf/tests/programs.rs @@ -280,7 +280,7 @@ fn load_upgradeable_program_wrapper( authority_keypair, name, ); - return program_keypair.pubkey(); + program_keypair.pubkey() } fn load_upgradeable_program_and_advance_slot( @@ -442,8 +442,7 @@ fn test_program_sbf_loader_deprecated() { /// deprecated when `disable_bpf_loader_instructions` feature is activated. /// /// The same test has been migrated to -/// `test_sol_alloc_free_no_longer_deployable_with_upgradeable_loader` and -/// `test_sol_alloc_free_deployable_with_upgradeable_loader` with a new version +/// `test_sol_alloc_free_no_longer_deployable_with_upgradeable_loader` with a new version /// of bpf_upgradeable_loader! #[test] #[cfg(feature = "sbf_rust")] @@ -469,7 +468,7 @@ fn test_sol_alloc_free_no_longer_deployable() { .accounts .remove(&feature_set::deprecate_executable_meta_update_in_bpf_loader::id()); - let (bank, bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config); + let (bank, _bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config); let elf = load_program_from_file("solana_sbf_rust_deprecated_loader"); let mut program_account = AccountSharedData::new(1, elf.len(), &bpf_loader::id()); @@ -492,70 +491,11 @@ fn test_sol_alloc_free_no_longer_deployable() { bank.last_blockhash(), ); - let invoke_tx = Transaction::new( - &[&mint_keypair], - Message::new( - &[Instruction::new_with_bytes( - program_address, - &[255], - vec![AccountMeta::new(mint_keypair.pubkey(), true)], - )], - Some(&mint_keypair.pubkey()), - ), - bank.last_blockhash(), - ); - // Try and deploy a program that depends on _sol_alloc_free assert_eq!( bank.process_transaction(&finalize_tx).unwrap_err(), TransactionError::InstructionError(0, InstructionError::InvalidAccountData) ); - - // Enable _sol_alloc_free syscall - let slot = bank.slot(); - drop(bank); - let mut bank = Arc::into_inner(bank_forks.write().unwrap().remove(slot).unwrap()).unwrap(); - bank.deactivate_feature(&solana_sdk::feature_set::disable_deploy_of_alloc_free_syscall::id()); - bank.clear_signatures(); - bank.clear_program_cache(); - let bank = bank_forks - .write() - .unwrap() - .insert(bank) - .clone_without_scheduler(); - - // Try and finalize the program now that sol_alloc_free is re-enabled - assert!(bank.process_transaction(&finalize_tx).is_ok()); - let new_slot = bank.slot() + 1; - let bank = bank_forks - .write() - .unwrap() - .insert(Bank::new_from_parent(bank, &Pubkey::default(), new_slot)) - .clone_without_scheduler(); - - // invoke the program - assert!(bank.process_transaction(&invoke_tx).is_ok()); - - // disable _sol_alloc_free - let slot = bank.slot(); - drop(bank); - let mut bank = Arc::try_unwrap(bank_forks.write().unwrap().remove(slot).unwrap()).unwrap(); - bank.activate_feature(&solana_sdk::feature_set::disable_deploy_of_alloc_free_syscall::id()); - bank.clear_signatures(); - let bank = bank_forks - .write() - .unwrap() - .insert(bank) - .clone_without_scheduler(); - - // invoke should still succeed because cached - assert!(bank.process_transaction(&invoke_tx).is_ok()); - - bank.clear_signatures(); - bank.clear_program_cache(); - - // invoke should still succeed on execute because the program is already deployed - assert!(bank.process_transaction(&invoke_tx).is_ok()); } #[test] @@ -598,90 +538,6 @@ fn test_sol_alloc_free_no_longer_deployable_with_upgradeable_loader() { ); } -#[test] -#[cfg(feature = "sbf_rust")] -fn test_sol_alloc_free_deployable_with_upgradeable_loader() { - solana_logger::setup(); - - let GenesisConfigInfo { - mut genesis_config, - mint_keypair, - .. - } = create_genesis_config(50); - - // deactivate `disable_deploy_of_alloc_free_syscall` feature so that the program - // that depends on sol_alloc_free_ can be deployed and executed. - genesis_config - .accounts - .remove(&solana_sdk::feature_set::disable_deploy_of_alloc_free_syscall::id()); - - 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(); - - // Populate loader account with `solana_sbf_rust_deprecated_loader` elf, which - // depends on `sol_alloc_free_` syscall. This can be verified with - // $ elfdump solana_sbf_rust_deprecated_loader.so - // : 0000000000001ab8 000000070000000a R_BPF_64_32 0000000000000000 sol_alloc_free_ - // In the symbol table, there is `sol_alloc_free_`. - // In fact, `sol_alloc_free_` is called from sbf allocator, which is originated from - // AccountInfo::realloc() in the program code. - - // expect that deployment success! - let (bank, program_id) = load_upgradeable_program_and_advance_slot( - &mut bank_client, - bank_forks.as_ref(), - &mint_keypair, - &authority_keypair, - "solana_sbf_rust_deprecated_loader", - ); - - // expect that the program call success! - let instruction = Instruction::new_with_bytes( - program_id, - &[255], - vec![AccountMeta::new(mint_keypair.pubkey(), true)], - ); - - let result = bank_client.send_and_confirm_instruction(&mint_keypair, instruction); - assert!(result.is_ok()); - - // now disable _sol_alloc_free - let slot = bank.slot(); - drop(bank_client); - drop(bank); - let mut bank = Arc::try_unwrap(bank_forks.write().unwrap().remove(slot).unwrap()).unwrap(); - bank.activate_feature(&solana_sdk::feature_set::disable_deploy_of_alloc_free_syscall::id()); - bank.clear_signatures(); - let bank = bank_forks - .write() - .unwrap() - .insert(bank) - .clone_without_scheduler(); - - let invoke_tx = Transaction::new( - &[&mint_keypair], - Message::new( - &[Instruction::new_with_bytes( - program_id, - &[255], - vec![AccountMeta::new(mint_keypair.pubkey(), true)], - )], - Some(&mint_keypair.pubkey()), - ), - bank.last_blockhash(), - ); - - // invoke should still succeed because cached - assert!(bank.process_transaction(&invoke_tx).is_ok()); - - bank.clear_signatures(); - bank.clear_program_cache(); - - // invoke should still succeed on execute because the program is already deployed - assert!(bank.process_transaction(&invoke_tx).is_ok()); -} - #[test] #[cfg(feature = "sbf_rust")] fn test_program_sbf_duplicate_accounts() {