diff --git a/bench-tps/src/bench.rs b/bench-tps/src/bench.rs index ccf601214c1743..075e08343a6447 100644 --- a/bench-tps/src/bench.rs +++ b/bench-tps/src/bench.rs @@ -1223,7 +1223,7 @@ pub fn fund_keypairs( mod tests { use { super::*, - solana_runtime::{bank::Bank, bank_client::BankClient}, + solana_runtime::{bank::Bank, bank_client::BankClient, bank_forks::BankForks}, solana_sdk::{ commitment_config::CommitmentConfig, feature_set::FeatureSet, @@ -1234,16 +1234,18 @@ mod tests { }, }; - fn bank_with_all_features(genesis_config: &GenesisConfig) -> Arc { + fn bank_with_all_features( + genesis_config: &GenesisConfig, + ) -> (Arc, Arc>) { let mut bank = Bank::new_for_tests(genesis_config); bank.feature_set = Arc::new(FeatureSet::all_enabled()); - bank.wrap_with_bank_forks_for_tests().0 + bank.wrap_with_bank_forks_for_tests() } #[test] fn test_bench_tps_bank_client() { let (genesis_config, id) = create_genesis_config(sol_to_lamports(10_000.0)); - let bank = bank_with_all_features(&genesis_config); + let (bank, _bank_forks) = bank_with_all_features(&genesis_config); let client = Arc::new(BankClient::new_shared(bank)); let config = Config { @@ -1264,7 +1266,7 @@ mod tests { #[test] fn test_bench_tps_fund_keys() { let (genesis_config, id) = create_genesis_config(sol_to_lamports(10_000.0)); - let bank = bank_with_all_features(&genesis_config); + let (bank, _bank_forks) = bank_with_all_features(&genesis_config); let client = Arc::new(BankClient::new_shared(bank)); let keypair_count = 20; let lamports = 20; @@ -1289,7 +1291,7 @@ mod tests { let (mut genesis_config, id) = create_genesis_config(sol_to_lamports(10_000.0)); let fee_rate_governor = FeeRateGovernor::new(11, 0); genesis_config.fee_rate_governor = fee_rate_governor; - let bank = bank_with_all_features(&genesis_config); + let (bank, _bank_forks) = bank_with_all_features(&genesis_config); let client = Arc::new(BankClient::new_shared(bank)); let keypair_count = 20; let lamports = 20; @@ -1307,7 +1309,7 @@ mod tests { #[test] fn test_bench_tps_create_durable_nonce() { let (genesis_config, id) = create_genesis_config(sol_to_lamports(10_000.0)); - let bank = bank_with_all_features(&genesis_config); + let (bank, _bank_forks) = bank_with_all_features(&genesis_config); let client = Arc::new(BankClient::new_shared(bank)); let keypair_count = 10; let lamports = 10_000_000; diff --git a/core/benches/banking_stage.rs b/core/benches/banking_stage.rs index 7a69eaf674d520..45c6e02e20f424 100644 --- a/core/benches/banking_stage.rs +++ b/core/benches/banking_stage.rs @@ -398,7 +398,7 @@ fn simulate_process_entries( let bank_fork = BankForks::new_rw_arc(bank); let bank = bank_fork.read().unwrap().get_with_scheduler(slot).unwrap(); bank.clone_without_scheduler() - .set_fork_graph_in_program_cache(bank_fork.clone()); + .set_fork_graph_in_program_cache(Arc::downgrade(&bank_fork)); for i in 0..(num_accounts / 2) { bank.transfer(initial_lamports, mint_keypair, &keypairs[i * 2].pubkey()) diff --git a/core/benches/consumer.rs b/core/benches/consumer.rs index 6dd9eb5b8bf0fa..d736b93ef96ffd 100644 --- a/core/benches/consumer.rs +++ b/core/benches/consumer.rs @@ -19,7 +19,7 @@ use { poh_recorder::{create_test_recorder, PohRecorder}, poh_service::PohService, }, - solana_runtime::bank::Bank, + solana_runtime::{bank::Bank, bank_forks::BankForks}, solana_sdk::{ account::{Account, ReadableAccount}, signature::Keypair, @@ -89,6 +89,7 @@ fn create_consumer(poh_recorder: &RwLock) -> Consumer { struct BenchFrame { bank: Arc, + _bank_forks: Arc>, ledger_path: TempDir, exit: Arc, poh_recorder: Arc>, @@ -115,7 +116,7 @@ fn setup() -> BenchFrame { bank.write_cost_tracker() .unwrap() .set_limits(u64::MAX, u64::MAX, u64::MAX); - let bank = bank.wrap_with_bank_forks_for_tests().0; + let (bank, bank_forks) = bank.wrap_with_bank_forks_for_tests(); let ledger_path = TempDir::new().unwrap(); let blockstore = Arc::new( @@ -126,6 +127,7 @@ fn setup() -> BenchFrame { BenchFrame { bank, + _bank_forks: bank_forks, ledger_path, exit, poh_recorder, @@ -147,6 +149,7 @@ fn bench_process_and_record_transactions(bencher: &mut Bencher, batch_size: usiz let BenchFrame { bank, + _bank_forks, ledger_path: _ledger_path, exit, poh_recorder, diff --git a/core/src/banking_stage.rs b/core/src/banking_stage.rs index 0e732e62e66b2b..52d4e787d0009b 100644 --- a/core/src/banking_stage.rs +++ b/core/src/banking_stage.rs @@ -1064,7 +1064,7 @@ mod tests { drop(poh_recorder); let mut blockhash = start_hash; - let bank = Bank::new_no_wallclock_throttle_for_tests(&genesis_config).0; + let (bank, _bank_forks) = Bank::new_no_wallclock_throttle_for_tests(&genesis_config); bank.process_transaction(&fund_tx).unwrap(); //receive entries + ticks loop { @@ -1208,7 +1208,7 @@ mod tests { .map(|(_bank, (entry, _tick_height))| entry) .collect(); - let bank = Bank::new_no_wallclock_throttle_for_tests(&genesis_config).0; + let (bank, _bank_forks) = Bank::new_no_wallclock_throttle_for_tests(&genesis_config); for entry in entries { bank.process_entry_transactions(entry.transactions) .iter() @@ -1232,7 +1232,7 @@ mod tests { mint_keypair, .. } = create_genesis_config(10_000); - let bank = Bank::new_no_wallclock_throttle_for_tests(&genesis_config).0; + let (bank, _bank_forks) = Bank::new_no_wallclock_throttle_for_tests(&genesis_config); let ledger_path = get_tmp_ledger_path_auto_delete!(); { let blockstore = Blockstore::open(ledger_path.path()) diff --git a/core/src/banking_stage/consume_worker.rs b/core/src/banking_stage/consume_worker.rs index f83ca6724d415e..57a4778d3204b3 100644 --- a/core/src/banking_stage/consume_worker.rs +++ b/core/src/banking_stage/consume_worker.rs @@ -710,7 +710,8 @@ mod tests { }, solana_poh::poh_recorder::{PohRecorder, WorkingBankEntry}, solana_runtime::{ - prioritization_fee_cache::PrioritizationFeeCache, vote_sender_types::ReplayVoteReceiver, + bank_forks::BankForks, prioritization_fee_cache::PrioritizationFeeCache, + vote_sender_types::ReplayVoteReceiver, }, solana_sdk::{ genesis_config::GenesisConfig, poh_config::PohConfig, pubkey::Pubkey, @@ -729,6 +730,7 @@ mod tests { mint_keypair: Keypair, genesis_config: GenesisConfig, bank: Arc, + _bank_forks: Arc>, _ledger_path: TempDir, _entry_receiver: Receiver, poh_recorder: Arc>, @@ -745,7 +747,7 @@ mod tests { mint_keypair, .. } = create_slow_genesis_config(10_000); - let bank = Bank::new_no_wallclock_throttle_for_tests(&genesis_config).0; + let (bank, bank_forks) = Bank::new_no_wallclock_throttle_for_tests(&genesis_config); let ledger_path = get_tmp_ledger_path_auto_delete!(); let blockstore = Blockstore::open(ledger_path.path()) @@ -788,6 +790,7 @@ mod tests { mint_keypair, genesis_config, bank, + _bank_forks: bank_forks, _ledger_path: ledger_path, _entry_receiver: entry_receiver, poh_recorder, diff --git a/core/src/banking_stage/consumer.rs b/core/src/banking_stage/consumer.rs index 6ae0881da45d8a..3493a5f3a85408 100644 --- a/core/src/banking_stage/consumer.rs +++ b/core/src/banking_stage/consumer.rs @@ -851,7 +851,7 @@ mod tests { solana_poh::poh_recorder::{PohRecorder, Record, WorkingBankEntry}, solana_program_runtime::timings::ProgramTiming, solana_rpc::transaction_status_service::TransactionStatusService, - solana_runtime::prioritization_fee_cache::PrioritizationFeeCache, + solana_runtime::{bank_forks::BankForks, prioritization_fee_cache::PrioritizationFeeCache}, solana_sdk::{ account::AccountSharedData, account_utils::StateMut, @@ -989,6 +989,7 @@ mod tests { ) -> ( Vec, Arc, + Arc>, Arc>, Receiver, GenesisConfigInfo, @@ -1003,7 +1004,7 @@ mod tests { } = &genesis_config_info; let blockstore = Blockstore::open(ledger_path).expect("Expected to be able to open database ledger"); - let bank = Bank::new_no_wallclock_throttle_for_tests(genesis_config).0; + let (bank, bank_forks) = Bank::new_no_wallclock_throttle_for_tests(genesis_config); let exit = Arc::new(AtomicBool::default()); let (poh_recorder, entry_receiver, record_receiver) = PohRecorder::new( bank.tick_height(), @@ -1032,6 +1033,7 @@ mod tests { ( transactions, bank, + bank_forks, poh_recorder, entry_receiver, genesis_config_info, @@ -1059,7 +1061,7 @@ mod tests { mint_keypair, .. } = create_slow_genesis_config(10_000); - let bank = Bank::new_no_wallclock_throttle_for_tests(&genesis_config).0; + let (bank, _bank_forks) = Bank::new_no_wallclock_throttle_for_tests(&genesis_config); let pubkey = solana_sdk::pubkey::new_rand(); let transactions = sanitize_transactions(vec![system_transaction::transfer( @@ -1187,7 +1189,7 @@ mod tests { mint_keypair, .. } = create_slow_genesis_config(10_000); - let bank = Bank::new_no_wallclock_throttle_for_tests(&genesis_config).0; + let (bank, _bank_forks) = Bank::new_no_wallclock_throttle_for_tests(&genesis_config); let pubkey = Pubkey::new_unique(); // setup nonce account with a durable nonce different from the current @@ -1343,7 +1345,7 @@ mod tests { mint_keypair, .. } = create_slow_genesis_config(10_000); - let bank = Bank::new_no_wallclock_throttle_for_tests(&genesis_config).0; + let (bank, _bank_forks) = Bank::new_no_wallclock_throttle_for_tests(&genesis_config); let pubkey = solana_sdk::pubkey::new_rand(); let transactions = { @@ -1427,7 +1429,7 @@ mod tests { } = create_slow_genesis_config(10_000); let mut bank = Bank::new_for_tests(&genesis_config); bank.ns_per_slot = u128::MAX; - let bank = bank.wrap_with_bank_forks_for_tests().0; + let (bank, _bank_forks) = bank.wrap_with_bank_forks_for_tests(); let pubkey = solana_sdk::pubkey::new_rand(); let ledger_path = get_tmp_ledger_path_auto_delete!(); @@ -1583,7 +1585,7 @@ mod tests { mint_keypair, .. } = create_slow_genesis_config(10_000); - let bank = Bank::new_no_wallclock_throttle_for_tests(&genesis_config).0; + let (bank, _bank_forks) = Bank::new_no_wallclock_throttle_for_tests(&genesis_config); let pubkey = solana_sdk::pubkey::new_rand(); let pubkey1 = solana_sdk::pubkey::new_rand(); @@ -1660,7 +1662,7 @@ mod tests { mint_keypair, .. } = create_slow_genesis_config(lamports); - let bank = Bank::new_no_wallclock_throttle_for_tests(&genesis_config).0; + let (bank, _bank_forks) = Bank::new_no_wallclock_throttle_for_tests(&genesis_config); // set cost tracker limits to MAX so it will not filter out TXs bank.write_cost_tracker() .unwrap() @@ -1721,7 +1723,7 @@ mod tests { mint_keypair, .. } = create_slow_genesis_config(10_000); - let bank = Bank::new_no_wallclock_throttle_for_tests(&genesis_config).0; + let (bank, _bank_forks) = Bank::new_no_wallclock_throttle_for_tests(&genesis_config); // set cost tracker limits to MAX so it will not filter out TXs bank.write_cost_tracker() .unwrap() @@ -1780,7 +1782,7 @@ mod tests { mint_keypair, .. } = create_slow_genesis_config(10_000); - let bank = Bank::new_no_wallclock_throttle_for_tests(&genesis_config).0; + let (bank, _bank_forks) = Bank::new_no_wallclock_throttle_for_tests(&genesis_config); let pubkey = solana_sdk::pubkey::new_rand(); @@ -1861,7 +1863,7 @@ mod tests { } = create_slow_genesis_config(solana_sdk::native_token::sol_to_lamports(1000.0)); genesis_config.rent.lamports_per_byte_year = 50; genesis_config.rent.exemption_threshold = 2.0; - let bank = Bank::new_no_wallclock_throttle_for_tests(&genesis_config).0; + let (bank, _bank_forks) = Bank::new_no_wallclock_throttle_for_tests(&genesis_config); let pubkey = solana_sdk::pubkey::new_rand(); let pubkey1 = solana_sdk::pubkey::new_rand(); let keypair1 = Keypair::new(); @@ -2130,7 +2132,7 @@ mod tests { fn test_consume_buffered_packets() { let ledger_path = get_tmp_ledger_path_auto_delete!(); { - let (transactions, bank, poh_recorder, _entry_receiver, _, poh_simulator) = + let (transactions, bank, _bank_forks, poh_recorder, _entry_receiver, _, poh_simulator) = setup_conflicting_transactions(ledger_path.path()); let recorder: TransactionRecorder = poh_recorder.read().unwrap().new_recorder(); let num_conflicting_transactions = transactions.len(); @@ -2203,8 +2205,15 @@ mod tests { fn test_consume_buffered_packets_sanitization_error() { let ledger_path = get_tmp_ledger_path_auto_delete!(); { - let (mut transactions, bank, poh_recorder, _entry_receiver, _, poh_simulator) = - setup_conflicting_transactions(ledger_path.path()); + let ( + mut transactions, + bank, + _bank_forks, + poh_recorder, + _entry_receiver, + _, + poh_simulator, + ) = setup_conflicting_transactions(ledger_path.path()); let duplicate_account_key = transactions[0].message.account_keys[0]; transactions[0] .message @@ -2259,7 +2268,7 @@ mod tests { fn test_consume_buffered_packets_retryable() { let ledger_path = get_tmp_ledger_path_auto_delete!(); { - let (transactions, bank, poh_recorder, _entry_receiver, _, poh_simulator) = + let (transactions, bank, _bank_forks, poh_recorder, _entry_receiver, _, poh_simulator) = setup_conflicting_transactions(ledger_path.path()); let recorder = poh_recorder.read().unwrap().new_recorder(); let num_conflicting_transactions = transactions.len(); @@ -2355,8 +2364,15 @@ mod tests { fn test_consume_buffered_packets_batch_priority_guard() { let ledger_path = get_tmp_ledger_path_auto_delete!(); { - let (_, bank, poh_recorder, _entry_receiver, genesis_config_info, poh_simulator) = - setup_conflicting_transactions(ledger_path.path()); + let ( + _, + bank, + _bank_forks, + poh_recorder, + _entry_receiver, + genesis_config_info, + poh_simulator, + ) = setup_conflicting_transactions(ledger_path.path()); let recorder = poh_recorder.read().unwrap().new_recorder(); // Setup transactions: diff --git a/core/src/banking_stage/decision_maker.rs b/core/src/banking_stage/decision_maker.rs index 6ad2c3042b254f..1bd0b224fdf034 100644 --- a/core/src/banking_stage/decision_maker.rs +++ b/core/src/banking_stage/decision_maker.rs @@ -148,7 +148,7 @@ mod tests { #[test] fn test_make_consume_or_forward_decision() { let genesis_config = create_genesis_config(2).genesis_config; - let bank = Bank::new_no_wallclock_throttle_for_tests(&genesis_config).0; + let (bank, _bank_forks) = Bank::new_no_wallclock_throttle_for_tests(&genesis_config); let ledger_path = temp_dir(); let blockstore = Arc::new(Blockstore::open(ledger_path.as_path()).unwrap()); let (exit, poh_recorder, poh_service, _entry_receiver) = diff --git a/core/src/banking_stage/read_write_account_set.rs b/core/src/banking_stage/read_write_account_set.rs index 4b1efc015e2bbf..9ed0f24500d9db 100644 --- a/core/src/banking_stage/read_write_account_set.rs +++ b/core/src/banking_stage/read_write_account_set.rs @@ -84,7 +84,7 @@ mod tests { use { super::ReadWriteAccountSet, solana_ledger::genesis_utils::GenesisConfigInfo, - solana_runtime::{bank::Bank, genesis_utils::create_genesis_config}, + solana_runtime::{bank::Bank, bank_forks::BankForks, genesis_utils::create_genesis_config}, solana_sdk::{ account::AccountSharedData, address_lookup_table::{ @@ -101,7 +101,10 @@ mod tests { signer::Signer, transaction::{MessageHash, SanitizedTransaction, VersionedTransaction}, }, - std::{borrow::Cow, sync::Arc}, + std::{ + borrow::Cow, + sync::{Arc, RwLock}, + }, }; fn create_test_versioned_message( @@ -171,9 +174,9 @@ mod tests { ) } - fn create_test_bank() -> Arc { + fn create_test_bank() -> (Arc, Arc>) { let GenesisConfigInfo { genesis_config, .. } = create_genesis_config(10_000); - Bank::new_no_wallclock_throttle_for_tests(&genesis_config).0 + Bank::new_no_wallclock_throttle_for_tests(&genesis_config) } // Helper function (could potentially use test_case in future). @@ -182,7 +185,7 @@ mod tests { // conflict_index = 2 means write lock conflict with address table key // conflict_index = 3 means read lock conflict with address table key fn test_check_and_take_locks(conflict_index: usize, add_write: bool, expectation: bool) { - let bank = create_test_bank(); + let (bank, _bank_forks) = create_test_bank(); let (bank, table_address) = create_test_address_lookup_table(bank, 2); let tx = create_test_sanitized_transaction( &Keypair::new(), diff --git a/core/src/banking_stage/unprocessed_transaction_storage.rs b/core/src/banking_stage/unprocessed_transaction_storage.rs index bc2dec2a82c7c1..e790993dfcccd0 100644 --- a/core/src/banking_stage/unprocessed_transaction_storage.rs +++ b/core/src/banking_stage/unprocessed_transaction_storage.rs @@ -1069,7 +1069,7 @@ mod tests { mint_keypair, .. } = create_genesis_config(10); - let current_bank = Bank::new_with_bank_forks_for_tests(&genesis_config).0; + let (current_bank, _bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config); let simple_transactions: Vec = (0..256) .map(|_id| { diff --git a/core/tests/unified_scheduler.rs b/core/tests/unified_scheduler.rs index 22f9fab0c05122..141e2fd822813e 100644 --- a/core/tests/unified_scheduler.rs +++ b/core/tests/unified_scheduler.rs @@ -83,7 +83,7 @@ fn test_scheduler_waited_by_drop_bank_service() { bank_forks.write().unwrap().install_scheduler_pool(pool); let genesis = 0; let genesis_bank = &bank_forks.read().unwrap().get(genesis).unwrap(); - genesis_bank.set_fork_graph_in_program_cache(bank_forks.clone()); + genesis_bank.set_fork_graph_in_program_cache(Arc::downgrade(&bank_forks)); // Create bank, which is pruned later let pruned = 2; diff --git a/ledger/benches/blockstore_processor.rs b/ledger/benches/blockstore_processor.rs index 489da8f432cfd2..8d01aa69c0d2af 100644 --- a/ledger/benches/blockstore_processor.rs +++ b/ledger/benches/blockstore_processor.rs @@ -12,7 +12,7 @@ use { }, solana_program_runtime::timings::ExecuteTimings, solana_runtime::{ - bank::Bank, prioritization_fee_cache::PrioritizationFeeCache, + bank::Bank, bank_forks::BankForks, prioritization_fee_cache::PrioritizationFeeCache, transaction_batch::TransactionBatch, }, solana_sdk::{ @@ -24,7 +24,10 @@ use { system_program, system_transaction, transaction::SanitizedTransaction, }, - std::{borrow::Cow, sync::Arc}, + std::{ + borrow::Cow, + sync::{Arc, RwLock}, + }, test::Bencher, }; @@ -74,6 +77,7 @@ fn create_transactions(bank: &Bank, num: usize) -> Vec { struct BenchFrame { bank: Arc, + _bank_forks: Arc>, prioritization_fee_cache: PrioritizationFeeCache, } @@ -100,10 +104,11 @@ fn setup(apply_cost_tracker_during_replay: bool) -> BenchFrame { bank.write_cost_tracker() .unwrap() .set_limits(u64::MAX, u64::MAX, u64::MAX); - let bank = bank.wrap_with_bank_forks_for_tests().0; + let (bank, bank_forks) = bank.wrap_with_bank_forks_for_tests(); let prioritization_fee_cache = PrioritizationFeeCache::default(); BenchFrame { bank, + _bank_forks: bank_forks, prioritization_fee_cache, } } @@ -124,6 +129,7 @@ fn bench_execute_batch( let BenchFrame { bank, + _bank_forks, prioritization_fee_cache, } = setup(apply_cost_tracker_during_replay); let transactions = create_transactions(&bank, 2_usize.pow(20)); diff --git a/ledger/src/blockstore_processor.rs b/ledger/src/blockstore_processor.rs index c21ebda1cd55c1..9866ad2291f928 100644 --- a/ledger/src/blockstore_processor.rs +++ b/ledger/src/blockstore_processor.rs @@ -3007,7 +3007,7 @@ pub mod tests { mint_keypair, .. } = create_genesis_config(2); - let bank = Bank::new_with_bank_forks_for_tests(&genesis_config).0; + let (bank, _bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config); let keypair = Keypair::new(); let slot_entries = create_ticks(genesis_config.ticks_per_slot, 1, genesis_config.hash()); let tx = system_transaction::transfer( @@ -3172,7 +3172,7 @@ pub mod tests { mint_keypair, .. } = create_genesis_config(1000); - let bank = Bank::new_with_bank_forks_for_tests(&genesis_config).0; + let (bank, _bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config); let keypair1 = Keypair::new(); let keypair2 = Keypair::new(); @@ -3209,7 +3209,7 @@ pub mod tests { mint_keypair, .. } = create_genesis_config(1000); - let bank = Bank::new_with_bank_forks_for_tests(&genesis_config).0; + let (bank, _bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config); let keypair1 = Keypair::new(); let keypair2 = Keypair::new(); let keypair3 = Keypair::new(); @@ -3269,7 +3269,7 @@ pub mod tests { mint_keypair, .. } = create_genesis_config(1000); - let bank = Bank::new_with_bank_forks_for_tests(&genesis_config).0; + let (bank, _bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config); let keypair1 = Keypair::new(); let keypair2 = Keypair::new(); let keypair3 = Keypair::new(); @@ -3419,12 +3419,11 @@ pub mod tests { let mock_program_id = solana_sdk::pubkey::new_rand(); - let bank = Bank::new_with_mockup_builtin_for_tests( + let (bank, _bank_forks) = Bank::new_with_mockup_builtin_for_tests( &genesis_config, mock_program_id, MockBuiltinOk::vm, - ) - .0; + ); let tx = Transaction::new_signed_with_payer( &[Instruction::new_with_bincode( @@ -3463,12 +3462,11 @@ pub mod tests { let mut bankhash_err = None; (0..get_instruction_errors().len()).for_each(|err| { - let bank = Bank::new_with_mockup_builtin_for_tests( + let (bank, _bank_forks) = Bank::new_with_mockup_builtin_for_tests( &genesis_config, mock_program_id, MockBuiltinErr::vm, - ) - .0; + ); let tx = Transaction::new_signed_with_payer( &[Instruction::new_with_bincode( @@ -3504,7 +3502,7 @@ pub mod tests { mint_keypair, .. } = create_genesis_config(1000); - let bank = Bank::new_with_bank_forks_for_tests(&genesis_config).0; + let (bank, _bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config); let keypair1 = Keypair::new(); let keypair2 = Keypair::new(); let keypair3 = Keypair::new(); @@ -3598,7 +3596,7 @@ pub mod tests { mint_keypair, .. } = create_genesis_config(1000); - let bank = Bank::new_with_bank_forks_for_tests(&genesis_config).0; + let (bank, _bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config); let keypair1 = Keypair::new(); let keypair2 = Keypair::new(); let keypair3 = Keypair::new(); @@ -3644,7 +3642,7 @@ pub mod tests { mint_keypair, .. } = create_genesis_config(1_000_000_000); - let bank = Bank::new_with_bank_forks_for_tests(&genesis_config).0; + let (bank, _bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config); const NUM_TRANSFERS_PER_ENTRY: usize = 8; const NUM_TRANSFERS: usize = NUM_TRANSFERS_PER_ENTRY * 32; @@ -3711,7 +3709,7 @@ pub mod tests { .. } = create_genesis_config((num_accounts + 1) as u64 * initial_lamports); - let bank = Bank::new_with_bank_forks_for_tests(&genesis_config).0; + let (bank, _bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config); let mut keypairs: Vec = vec![]; @@ -3778,7 +3776,7 @@ pub mod tests { mint_keypair, .. } = create_genesis_config(1000); - let bank = Bank::new_with_bank_forks_for_tests(&genesis_config).0; + let (bank, _bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config); let keypair1 = Keypair::new(); let keypair2 = Keypair::new(); let keypair3 = Keypair::new(); @@ -3840,7 +3838,7 @@ pub mod tests { mint_keypair, .. } = create_genesis_config(11_000); - let bank = Bank::new_with_bank_forks_for_tests(&genesis_config).0; + let (bank, _bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config); let pubkey = solana_sdk::pubkey::new_rand(); bank.transfer(1_000, &mint_keypair, &pubkey).unwrap(); assert_eq!(bank.transaction_count(), 1); @@ -3881,7 +3879,7 @@ pub mod tests { mint_keypair, .. } = create_genesis_config(11_000); - let bank = Bank::new_with_bank_forks_for_tests(&genesis_config).0; + let (bank, _bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config); let keypair1 = Keypair::new(); let keypair2 = Keypair::new(); let success_tx = system_transaction::transfer( @@ -4181,7 +4179,7 @@ pub mod tests { mint_keypair, .. } = create_genesis_config(100); - let bank0 = Bank::new_with_bank_forks_for_tests(&genesis_config).0; + let (bank0, _bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config); let genesis_hash = genesis_config.hash(); let keypair = Keypair::new(); @@ -4245,7 +4243,7 @@ pub mod tests { mint_keypair, .. } = create_genesis_config(1_000_000_000); - let bank = Bank::new_with_bank_forks_for_tests(&genesis_config).0; + let (bank, _bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config); let present_account_key = Keypair::new(); let present_account = AccountSharedData::new(1, 10, &Pubkey::default()); @@ -4714,9 +4712,8 @@ pub mod tests { .. } = create_genesis_config(100 * LAMPORTS_PER_SOL); let genesis_hash = genesis_config.hash(); - let bank = BankWithScheduler::new_without_scheduler( - Bank::new_with_bank_forks_for_tests(&genesis_config).0, - ); + let (bank, _bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config); + let bank = BankWithScheduler::new_without_scheduler(bank); let replay_tx_thread_pool = create_thread_pool(1); let mut timing = ConfirmationTiming::default(); let mut progress = ConfirmationProgress::new(genesis_hash); diff --git a/poh/src/poh_service.rs b/poh/src/poh_service.rs index 8cd0d40266b37d..04dc8d4c5a1fed 100644 --- a/poh/src/poh_service.rs +++ b/poh/src/poh_service.rs @@ -400,7 +400,7 @@ mod tests { fn test_poh_service() { solana_logger::setup(); let GenesisConfigInfo { genesis_config, .. } = create_genesis_config(2); - let bank = Bank::new_no_wallclock_throttle_for_tests(&genesis_config).0; + let (bank, _bank_forks) = Bank::new_no_wallclock_throttle_for_tests(&genesis_config); let prev_hash = bank.last_blockhash(); let ledger_path = get_tmp_ledger_path_auto_delete!(); let blockstore = Blockstore::open(ledger_path.path()) diff --git a/program-runtime/src/loaded_programs.rs b/program-runtime/src/loaded_programs.rs index 47eb63c2638877..bba852cff21077 100644 --- a/program-runtime/src/loaded_programs.rs +++ b/program-runtime/src/loaded_programs.rs @@ -30,6 +30,7 @@ use { std::{ collections::{hash_map::Entry, HashMap}, fmt::{Debug, Formatter}, + sync::Weak, }, }; @@ -640,7 +641,7 @@ pub struct ProgramCache { /// Statistics counters pub stats: ProgramCacheStats, /// Reference to the block store - pub fork_graph: Option>>, + pub fork_graph: Option>>, /// Coordinates TX batches waiting for others to complete their task during cooperative loading pub loading_task_waiter: Arc, } @@ -825,7 +826,7 @@ impl ProgramCache { } } - pub fn set_fork_graph(&mut self, fork_graph: Arc>) { + pub fn set_fork_graph(&mut self, fork_graph: Weak>) { self.fork_graph = Some(fork_graph); } @@ -948,6 +949,7 @@ impl ProgramCache { error!("Program cache doesn't have fork graph."); return; }; + let fork_graph = fork_graph.upgrade().unwrap(); let Ok(fork_graph) = fork_graph.read() else { error!("Failed to lock fork graph for reading."); return; @@ -1059,7 +1061,8 @@ impl ProgramCache { is_first_round: bool, ) -> Option<(Pubkey, u64)> { debug_assert!(self.fork_graph.is_some()); - let locked_fork_graph = self.fork_graph.as_ref().unwrap().read().unwrap(); + let fork_graph = self.fork_graph.as_ref().unwrap().upgrade().unwrap(); + let locked_fork_graph = fork_graph.read().unwrap(); let mut cooperative_loading_task = None; match &self.index { IndexImplementation::V1 { @@ -1166,6 +1169,8 @@ impl ProgramCache { self.fork_graph .as_ref() .unwrap() + .upgrade() + .unwrap() .read() .unwrap() .relationship(loaded_program.deployment_slot, slot), @@ -2026,7 +2031,7 @@ mod tests { relation: BlockRelation::Unrelated, })); - cache.set_fork_graph(fork_graph); + cache.set_fork_graph(Arc::downgrade(&fork_graph)); cache.prune(0, 0); assert!(cache.get_flattened_entries_for_tests().is_empty()); @@ -2039,7 +2044,7 @@ mod tests { relation: BlockRelation::Ancestor, })); - cache.set_fork_graph(fork_graph); + cache.set_fork_graph(Arc::downgrade(&fork_graph)); cache.prune(0, 0); assert!(cache.get_flattened_entries_for_tests().is_empty()); @@ -2052,7 +2057,7 @@ mod tests { relation: BlockRelation::Descendant, })); - cache.set_fork_graph(fork_graph); + cache.set_fork_graph(Arc::downgrade(&fork_graph)); cache.prune(0, 0); assert!(cache.get_flattened_entries_for_tests().is_empty()); @@ -2064,7 +2069,7 @@ mod tests { let fork_graph = Arc::new(RwLock::new(TestForkGraph { relation: BlockRelation::Unknown, })); - cache.set_fork_graph(fork_graph); + cache.set_fork_graph(Arc::downgrade(&fork_graph)); cache.prune(0, 0); assert!(cache.get_flattened_entries_for_tests().is_empty()); @@ -2081,7 +2086,7 @@ mod tests { relation: BlockRelation::Ancestor, })); - cache.set_fork_graph(fork_graph); + cache.set_fork_graph(Arc::downgrade(&fork_graph)); let program1 = Pubkey::new_unique(); cache.assign_program(program1, new_test_entry(10, 10)); @@ -2171,7 +2176,8 @@ mod tests { loading_slot: Slot, keys: &[Pubkey], ) -> Vec<(Pubkey, (ProgramCacheMatchCriteria, u64))> { - let locked_fork_graph = cache.fork_graph.as_ref().unwrap().read().unwrap(); + let fork_graph = cache.fork_graph.as_ref().unwrap().upgrade().unwrap(); + let locked_fork_graph = fork_graph.read().unwrap(); let entries = cache.get_flattened_entries_for_tests(); keys.iter() .filter_map(|key| { @@ -2239,7 +2245,7 @@ mod tests { fork_graph.insert_fork(&[0, 5, 11, 25, 27]); let fork_graph = Arc::new(RwLock::new(fork_graph)); - cache.set_fork_graph(fork_graph); + cache.set_fork_graph(Arc::downgrade(&fork_graph)); let program1 = Pubkey::new_unique(); cache.assign_program(program1, new_test_entry(0, 1)); @@ -2434,7 +2440,7 @@ mod tests { fork_graph.insert_fork(&[0, 5, 11, 25, 27]); let fork_graph = Arc::new(RwLock::new(fork_graph)); - cache.set_fork_graph(fork_graph); + cache.set_fork_graph(Arc::downgrade(&fork_graph)); let program1 = Pubkey::new_unique(); cache.assign_program(program1, new_test_entry(0, 1)); @@ -2491,7 +2497,7 @@ mod tests { fork_graph.insert_fork(&[0, 5, 11, 25, 27]); let fork_graph = Arc::new(RwLock::new(fork_graph)); - cache.set_fork_graph(fork_graph); + cache.set_fork_graph(Arc::downgrade(&fork_graph)); let program1 = Pubkey::new_unique(); cache.assign_program(program1, new_test_entry(0, 1)); @@ -2547,7 +2553,7 @@ mod tests { let mut cache = new_mock_cache::(); let fork_graph = TestForkGraphSpecific::default(); let fork_graph = Arc::new(RwLock::new(fork_graph)); - cache.set_fork_graph(fork_graph); + cache.set_fork_graph(Arc::downgrade(&fork_graph)); let program1 = Pubkey::new_unique(); let mut missing = vec![(program1, (ProgramCacheMatchCriteria::NoCriteria, 1))]; @@ -2619,7 +2625,7 @@ mod tests { fork_graph.insert_fork(&[0, 10, 20]); fork_graph.insert_fork(&[0, 5]); let fork_graph = Arc::new(RwLock::new(fork_graph)); - cache.set_fork_graph(fork_graph); + cache.set_fork_graph(Arc::downgrade(&fork_graph)); let program1 = Pubkey::new_unique(); cache.assign_program(program1, new_test_entry(0, 1)); @@ -2659,7 +2665,7 @@ mod tests { fork_graph.insert_fork(&[0, 10, 20]); fork_graph.insert_fork(&[0, 5, 6]); let fork_graph = Arc::new(RwLock::new(fork_graph)); - cache.set_fork_graph(fork_graph); + cache.set_fork_graph(Arc::downgrade(&fork_graph)); let program1 = Pubkey::new_unique(); cache.assign_program(program1, new_test_entry(0, 1)); diff --git a/programs/sbf/tests/programs.rs b/programs/sbf/tests/programs.rs index b26c2e74e230ff..55802a89dcbc33 100644 --- a/programs/sbf/tests/programs.rs +++ b/programs/sbf/tests/programs.rs @@ -23,6 +23,7 @@ use { solana_runtime::{ bank::{Bank, TransactionBalancesSet}, bank_client::BankClient, + bank_forks::BankForks, genesis_utils::{ bootstrap_validator_stake_lamports, create_genesis_config, create_genesis_config_with_leader_ex, GenesisConfigInfo, @@ -73,7 +74,12 @@ use { TransactionWithStatusMeta, VersionedTransactionWithStatusMeta, }, std::{ - assert_eq, cell::RefCell, collections::HashMap, str::FromStr, sync::Arc, time::Duration, + assert_eq, + cell::RefCell, + collections::HashMap, + str::FromStr, + sync::{Arc, RwLock}, + time::Duration, }, }; @@ -2530,7 +2536,7 @@ fn test_program_upgradeable_locks() { payer_keypair: &Keypair, buffer_keypair: &Keypair, program_keypair: &Keypair, - ) -> (Arc, Transaction, Transaction) { + ) -> (Arc, Arc>, Transaction, Transaction) { solana_logger::setup(); let GenesisConfigInfo { @@ -2600,7 +2606,7 @@ fn test_program_upgradeable_locks() { bank.last_blockhash(), ); - (bank, invoke_tx, upgrade_tx) + (bank, bank_forks, invoke_tx, upgrade_tx) } let payer_keypair = keypair_from_seed(&[56u8; 32]).unwrap(); @@ -2608,13 +2614,13 @@ fn test_program_upgradeable_locks() { let program_keypair = keypair_from_seed(&[77u8; 32]).unwrap(); let results1 = { - let (bank, invoke_tx, upgrade_tx) = + let (bank, _bank_forks, invoke_tx, upgrade_tx) = setup_program_upgradeable_locks(&payer_keypair, &buffer_keypair, &program_keypair); execute_transactions(&bank, vec![upgrade_tx, invoke_tx]) }; let results2 = { - let (bank, invoke_tx, upgrade_tx) = + let (bank, _bank_forks, invoke_tx, upgrade_tx) = setup_program_upgradeable_locks(&payer_keypair, &buffer_keypair, &program_keypair); execute_transactions(&bank, vec![invoke_tx, upgrade_tx]) }; diff --git a/rpc/src/transaction_status_service.rs b/rpc/src/transaction_status_service.rs index f8356296e970a6..34e9b7fdc6f8b2 100644 --- a/rpc/src/transaction_status_service.rs +++ b/rpc/src/transaction_status_service.rs @@ -291,7 +291,7 @@ pub(crate) mod tests { #[test] fn test_notify_transaction() { let genesis_config = create_genesis_config(2).genesis_config; - let bank = Bank::new_no_wallclock_throttle_for_tests(&genesis_config).0; + let (bank, _bank_forks) = Bank::new_no_wallclock_throttle_for_tests(&genesis_config); let (transaction_status_sender, transaction_status_receiver) = unbounded(); let ledger_path = get_tmp_ledger_path_auto_delete!(); diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index 81a717e217a2a7..b73a16696f8fcf 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -190,7 +190,7 @@ use { AtomicBool, AtomicI64, AtomicU64, AtomicUsize, Ordering::{AcqRel, Acquire, Relaxed}, }, - Arc, LockResult, Mutex, RwLock, RwLockReadGuard, RwLockWriteGuard, + Arc, LockResult, Mutex, RwLock, RwLockReadGuard, RwLockWriteGuard, Weak, }, thread::Builder, time::{Duration, Instant}, @@ -1351,7 +1351,7 @@ impl Bank { new } - pub fn set_fork_graph_in_program_cache(&self, fork_graph: Arc>) { + pub fn set_fork_graph_in_program_cache(&self, fork_graph: Weak>) { self.transaction_processor .program_cache .write() diff --git a/runtime/src/bank/tests.rs b/runtime/src/bank/tests.rs index 1081c224499b8d..c4a771e4ad0dda 100644 --- a/runtime/src/bank/tests.rs +++ b/runtime/src/bank/tests.rs @@ -318,7 +318,7 @@ fn create_simple_test_arc_bank(lamports: u64) -> (Arc, Arc = (0..max_keys) .enumerate() @@ -6435,9 +6431,8 @@ fn test_same_program_id_uses_unique_executable_accounts() { let (genesis_config, mint_keypair) = create_genesis_config(50000); let program1_pubkey = solana_sdk::pubkey::new_rand(); - let bank = - Bank::new_with_mockup_builtin_for_tests(&genesis_config, program1_pubkey, MockBuiltin::vm) - .0; + let (bank, _bank_forks) = + Bank::new_with_mockup_builtin_for_tests(&genesis_config, program1_pubkey, MockBuiltin::vm); // Add a new program owned by the first let program2_pubkey = solana_sdk::pubkey::new_rand(); @@ -6645,11 +6640,8 @@ fn test_add_builtin_no_overwrite() { let slot = 123; let program_id = solana_sdk::pubkey::new_rand(); - let mut bank = Arc::new(Bank::new_from_parent( - create_simple_test_arc_bank(100_000).0, - &Pubkey::default(), - slot, - )); + let (parent_bank, _bank_forks) = create_simple_test_arc_bank(100_000); + let mut bank = Arc::new(Bank::new_from_parent(parent_bank, &Pubkey::default(), slot)); assert_eq!(bank.get_account_modified_slot(&program_id), None); Arc::get_mut(&mut bank) @@ -6669,11 +6661,8 @@ fn test_add_builtin_loader_no_overwrite() { let slot = 123; let loader_id = solana_sdk::pubkey::new_rand(); - let mut bank = Arc::new(Bank::new_from_parent( - create_simple_test_arc_bank(100_000).0, - &Pubkey::default(), - slot, - )); + let (parent_bank, _bank_forks) = create_simple_test_arc_bank(100_000); + let mut bank = Arc::new(Bank::new_from_parent(parent_bank, &Pubkey::default(), slot)); assert_eq!(bank.get_account_modified_slot(&loader_id), None); Arc::get_mut(&mut bank) @@ -6839,11 +6828,8 @@ fn test_add_builtin_account_after_frozen() { let slot = 123; let program_id = Pubkey::from_str("CiXgo2KHKSDmDnV1F6B69eWFgNAPiSBjjYvfB4cvRNre").unwrap(); - let bank = Bank::new_from_parent( - create_simple_test_arc_bank(100_000).0, - &Pubkey::default(), - slot, - ); + let (parent_bank, _bank_forks) = create_simple_test_arc_bank(100_000); + let bank = Bank::new_from_parent(parent_bank, &Pubkey::default(), slot); bank.freeze(); bank.add_builtin_account("mock_program", &program_id); @@ -6970,11 +6956,8 @@ fn test_add_precompiled_account_after_frozen() { let slot = 123; let program_id = Pubkey::from_str("CiXgo2KHKSDmDnV1F6B69eWFgNAPiSBjjYvfB4cvRNre").unwrap(); - let bank = Bank::new_from_parent( - create_simple_test_arc_bank(100_000).0, - &Pubkey::default(), - slot, - ); + let (parent_bank, _bank_forks) = create_simple_test_arc_bank(100_000); + let bank = Bank::new_from_parent(parent_bank, &Pubkey::default(), slot); bank.freeze(); bank.add_precompiled_account(&program_id); @@ -7855,7 +7838,7 @@ fn test_bpf_loader_upgradeable_deploy_with_max_len() { #[test] fn test_compute_active_feature_set() { - let bank0 = create_simple_test_arc_bank(100_000).0; + let (bank0, _bank_forks) = create_simple_test_arc_bank(100_000); let mut bank = Bank::new_from_parent(bank0, &Pubkey::default(), 1); let test_feature = "TestFeature11111111111111111111111111111111" @@ -7906,7 +7889,7 @@ fn test_compute_active_feature_set() { #[test] fn test_reserved_account_keys() { - let bank0 = create_simple_test_arc_bank(100_000).0; + let (bank0, _bank_forks) = create_simple_test_arc_bank(100_000); let mut bank = Bank::new_from_parent(bank0, &Pubkey::default(), 1); bank.feature_set = Arc::new(FeatureSet::default()); @@ -8188,7 +8171,7 @@ fn test_timestamp_fast() { #[test] fn test_program_is_native_loader() { let (genesis_config, mint_keypair) = create_genesis_config(50000); - let bank = Bank::new_with_bank_forks_for_tests(&genesis_config).0; + let (bank, _bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config); let tx = Transaction::new_signed_with_payer( &[Instruction::new_with_bincode( @@ -9213,7 +9196,7 @@ fn test_tx_log_order() { &Pubkey::new_unique(), bootstrap_validator_stake_lamports(), ); - let bank = Bank::new_with_bank_forks_for_tests(&genesis_config).0; + let (bank, _bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config); *bank.transaction_log_collector_config.write().unwrap() = TransactionLogCollectorConfig { mentioned_addresses: HashSet::new(), filter: TransactionLogCollectorFilter::All, @@ -9303,9 +9286,8 @@ fn test_tx_return_data() { bootstrap_validator_stake_lamports(), ); let mock_program_id = Pubkey::from([2u8; 32]); - let bank = - Bank::new_with_mockup_builtin_for_tests(&genesis_config, mock_program_id, MockBuiltin::vm) - .0; + let (bank, _bank_forks) = + Bank::new_with_mockup_builtin_for_tests(&genesis_config, mock_program_id, MockBuiltin::vm); declare_process_instruction!(MockBuiltin, 1, |invoke_context| { let mock_program_id = Pubkey::from([2u8; 32]); @@ -9505,8 +9487,8 @@ fn test_transfer_sysvar() { ); let program_id = solana_sdk::pubkey::new_rand(); - let bank = - Bank::new_with_mockup_builtin_for_tests(&genesis_config, program_id, MockBuiltin::vm).0; + let (bank, _bank_forks) = + Bank::new_with_mockup_builtin_for_tests(&genesis_config, program_id, MockBuiltin::vm); declare_process_instruction!(MockBuiltin, 1, |invoke_context| { let transaction_context = &invoke_context.transaction_context; @@ -9715,8 +9697,8 @@ fn test_compute_budget_program_noop() { bootstrap_validator_stake_lamports(), ); let program_id = solana_sdk::pubkey::new_rand(); - let bank = - Bank::new_with_mockup_builtin_for_tests(&genesis_config, program_id, MockBuiltin::vm).0; + let (bank, _bank_forks) = + Bank::new_with_mockup_builtin_for_tests(&genesis_config, program_id, MockBuiltin::vm); declare_process_instruction!(MockBuiltin, 1, |invoke_context| { let compute_budget = invoke_context.get_compute_budget(); @@ -9760,8 +9742,8 @@ fn test_compute_request_instruction() { bootstrap_validator_stake_lamports(), ); let program_id = solana_sdk::pubkey::new_rand(); - let bank = - Bank::new_with_mockup_builtin_for_tests(&genesis_config, program_id, MockBuiltin::vm).0; + let (bank, _bank_forks) = + Bank::new_with_mockup_builtin_for_tests(&genesis_config, program_id, MockBuiltin::vm); declare_process_instruction!(MockBuiltin, 1, |invoke_context| { let compute_budget = invoke_context.get_compute_budget(); @@ -9806,8 +9788,8 @@ fn test_failed_compute_request_instruction() { ); let program_id = solana_sdk::pubkey::new_rand(); - let bank = - Bank::new_with_mockup_builtin_for_tests(&genesis_config, program_id, MockBuiltin::vm).0; + let (bank, _bank_forks) = + Bank::new_with_mockup_builtin_for_tests(&genesis_config, program_id, MockBuiltin::vm); let payer0_keypair = Keypair::new(); let payer1_keypair = Keypair::new(); @@ -9979,7 +9961,7 @@ fn test_call_precomiled_program() { .. } = create_genesis_config_with_leader(42, &Pubkey::new_unique(), 42); activate_all_features(&mut genesis_config); - let bank = Bank::new_with_bank_forks_for_tests(&genesis_config).0; + let (bank, _bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config); // libsecp256k1 // Since libsecp256k1 is still using the old version of rand, this test @@ -10244,7 +10226,7 @@ fn test_an_empty_instruction_without_program() { let message = Message::new(&[ix], Some(&mint_keypair.pubkey())); let tx = Transaction::new(&[&mint_keypair], message, genesis_config.hash()); - let bank = Bank::new_with_bank_forks_for_tests(&genesis_config).0; + let (bank, _bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config); assert_eq!( bank.process_transaction(&tx).unwrap_err(), TransactionError::InstructionError(0, InstructionError::UnsupportedProgramId), @@ -10272,7 +10254,7 @@ fn test_accounts_data_size_with_good_transaction() { const ACCOUNT_SIZE: u64 = MAX_PERMITTED_DATA_LENGTH; let (genesis_config, mint_keypair) = create_genesis_config(1_000 * LAMPORTS_PER_SOL); let bank = Bank::new_for_tests(&genesis_config); - let bank = bank.wrap_with_bank_forks_for_tests().0; + let (bank, _bank_forks) = bank.wrap_with_bank_forks_for_tests(); let transaction = system_transaction::create_account( &mint_keypair, &Keypair::new(), @@ -10313,7 +10295,7 @@ fn test_accounts_data_size_with_bad_transaction() { const ACCOUNT_SIZE: u64 = MAX_PERMITTED_DATA_LENGTH; let (genesis_config, _mint_keypair) = create_genesis_config(1_000 * LAMPORTS_PER_SOL); let bank = Bank::new_for_tests(&genesis_config); - let bank = bank.wrap_with_bank_forks_for_tests().0; + let (bank, _bank_forks) = bank.wrap_with_bank_forks_for_tests(); let transaction = system_transaction::create_account( &Keypair::new(), &Keypair::new(), @@ -10430,12 +10412,11 @@ fn test_invalid_rent_state_changes_existing_accounts() { ), ); - let bank = Bank::new_with_mockup_builtin_for_tests( + let (bank, _bank_forks) = Bank::new_with_mockup_builtin_for_tests( &genesis_config, mock_program_id, MockTransferBuiltin::vm, - ) - .0; + ); let recent_blockhash = bank.last_blockhash(); let check_account_is_rent_exempt = |pubkey: &Pubkey| -> bool { @@ -10517,12 +10498,11 @@ fn test_invalid_rent_state_changes_new_accounts() { let account_data_size = 100; let rent_exempt_minimum = genesis_config.rent.minimum_balance(account_data_size); - let bank = Bank::new_with_mockup_builtin_for_tests( + let (bank, _bank_forks) = Bank::new_with_mockup_builtin_for_tests( &genesis_config, mock_program_id, MockTransferBuiltin::vm, - ) - .0; + ); let recent_blockhash = bank.last_blockhash(); let check_account_is_rent_exempt = |pubkey: &Pubkey| -> bool { @@ -10580,12 +10560,11 @@ fn test_drained_created_account() { // Create legacy accounts of various kinds let created_keypair = Keypair::new(); - let bank = Bank::new_with_mockup_builtin_for_tests( + let (bank, _bank_forks) = Bank::new_with_mockup_builtin_for_tests( &genesis_config, mock_program_id, MockTransferBuiltin::vm, - ) - .0; + ); let recent_blockhash = bank.last_blockhash(); // Create and drain a small data size account @@ -10696,7 +10675,7 @@ fn test_rent_state_changes_sysvars() { Account::from(validator_vote_account), ); - let bank = Bank::new_with_bank_forks_for_tests(&genesis_config).0; + let (bank, _bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config); // Ensure transactions with sysvars succeed, even though sysvars appear RentPaying by balance let tx = Transaction::new_signed_with_payer( @@ -10739,7 +10718,7 @@ fn test_invalid_rent_state_changes_fee_payer() { Account::new(rent_exempt_minimum, 0, &system_program::id()), ); - let bank = Bank::new_with_bank_forks_for_tests(&genesis_config).0; + let (bank, _bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config); let recent_blockhash = bank.last_blockhash(); let check_account_is_rent_exempt = |pubkey: &Pubkey| -> bool { @@ -10968,7 +10947,7 @@ fn test_rent_state_incinerator() { genesis_config.rent = Rent::default(); let rent_exempt_minimum = genesis_config.rent.minimum_balance(0); - let bank = Bank::new_with_bank_forks_for_tests(&genesis_config).0; + let (bank, _bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config); for amount in [rent_exempt_minimum - 1, rent_exempt_minimum] { bank.transfer(amount, &mint_keypair, &solana_sdk::incinerator::id()) @@ -11138,12 +11117,11 @@ fn test_resize_and_rent() { activate_all_features(&mut genesis_config); let mock_program_id = Pubkey::new_unique(); - let bank = Bank::new_with_mockup_builtin_for_tests( + let (bank, _bank_forks) = Bank::new_with_mockup_builtin_for_tests( &genesis_config, mock_program_id, MockReallocBuiltin::vm, - ) - .0; + ); let recent_blockhash = bank.last_blockhash(); @@ -11414,12 +11392,11 @@ fn test_accounts_data_size_and_resize_transactions() { .. } = genesis_utils::create_genesis_config(100 * LAMPORTS_PER_SOL); let mock_program_id = Pubkey::new_unique(); - let bank = Bank::new_with_mockup_builtin_for_tests( + let (bank, _bank_forks) = Bank::new_with_mockup_builtin_for_tests( &genesis_config, mock_program_id, MockReallocBuiltin::vm, - ) - .0; + ); let recent_blockhash = bank.last_blockhash(); @@ -11669,7 +11646,7 @@ fn test_cap_accounts_data_allocations_per_transaction() { / MAX_PERMITTED_DATA_LENGTH as usize; let (genesis_config, mint_keypair) = create_genesis_config(1_000_000 * LAMPORTS_PER_SOL); - let bank = Bank::new_with_bank_forks_for_tests(&genesis_config).0; + let (bank, _bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config); let mut instructions = Vec::new(); let mut keypairs = vec![mint_keypair.insecure_clone()]; @@ -11876,7 +11853,7 @@ fn test_calculate_fee_with_request_heap_frame_flag() { fn test_is_in_slot_hashes_history() { use solana_sdk::slot_hashes::MAX_ENTRIES; - let bank0 = create_simple_test_arc_bank(1).0; + let (bank0, _bank_forks) = create_simple_test_arc_bank(1); assert!(!bank0.is_in_slot_hashes_history(&0)); assert!(!bank0.is_in_slot_hashes_history(&1)); let mut last_bank = bank0; @@ -12183,7 +12160,7 @@ fn test_squash_timing_add_assign() { #[test] fn test_system_instruction_allocate() { let (genesis_config, mint_keypair) = create_genesis_config_no_tx_fee(sol_to_lamports(1.0)); - let bank = Bank::new_with_bank_forks_for_tests(&genesis_config).0; + let (bank, _bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config); let bank_client = BankClient::new_shared(bank); let data_len = 2; let amount = genesis_config.rent.minimum_balance(data_len); @@ -12310,7 +12287,7 @@ fn test_create_zero_lamport_without_clean() { #[test] fn test_system_instruction_assign_with_seed() { let (genesis_config, mint_keypair) = create_genesis_config_no_tx_fee(sol_to_lamports(1.0)); - let bank = Bank::new_with_bank_forks_for_tests(&genesis_config).0; + let (bank, _bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config); let bank_client = BankClient::new_shared(bank); let alice_keypair = Keypair::new(); @@ -12351,7 +12328,7 @@ fn test_system_instruction_unsigned_transaction() { let amount = genesis_config.rent.minimum_balance(0); // Fund to account to bypass AccountNotFound error - let bank = Bank::new_with_bank_forks_for_tests(&genesis_config).0; + let (bank, _bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config); let bank_client = BankClient::new_shared(bank); bank_client .transfer_and_confirm(amount, &alice_keypair, &mallory_pubkey) @@ -12855,8 +12832,8 @@ fn test_get_accounts_for_bank_hash_details(skip_rewrites: bool) { fn test_failed_simulation_compute_units() { let (genesis_config, mint_keypair) = create_genesis_config(LAMPORTS_PER_SOL); let program_id = Pubkey::new_unique(); - let bank = - Bank::new_with_mockup_builtin_for_tests(&genesis_config, program_id, MockBuiltin::vm).0; + let (bank, _bank_forks) = + Bank::new_with_mockup_builtin_for_tests(&genesis_config, program_id, MockBuiltin::vm); const TEST_UNITS: u64 = 10_000; const MOCK_BUILTIN_UNITS: u64 = 1; diff --git a/runtime/src/bank_client.rs b/runtime/src/bank_client.rs index e8c8f7774ec66e..9cac83470bc964 100644 --- a/runtime/src/bank_client.rs +++ b/runtime/src/bank_client.rs @@ -321,7 +321,7 @@ mod tests { let jane_doe_keypair = Keypair::new(); let jane_pubkey = jane_doe_keypair.pubkey(); let doe_keypairs = vec![&john_doe_keypair, &jane_doe_keypair]; - let bank = Bank::new_with_bank_forks_for_tests(&genesis_config).0; + let (bank, _bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config); let bank_client = BankClient::new_shared(bank); let amount = genesis_config.rent.minimum_balance(0); diff --git a/runtime/src/bank_forks.rs b/runtime/src/bank_forks.rs index bbdd2d270a189d..3dd82c1fe85c98 100644 --- a/runtime/src/bank_forks.rs +++ b/runtime/src/bank_forks.rs @@ -134,7 +134,7 @@ impl BankForks { scheduler_pool: None, })); - root_bank.set_fork_graph_in_program_cache(bank_forks.clone()); + root_bank.set_fork_graph_in_program_cache(Arc::downgrade(&bank_forks)); bank_forks } @@ -751,6 +751,14 @@ mod tests { std::{sync::atomic::Ordering::Relaxed, time::Duration}, }; + #[test] + fn test_bank_forks_new_rw_arc_memory_leak() { + for _ in 0..1000 { + let GenesisConfigInfo { genesis_config, .. } = create_genesis_config(10_000); + BankForks::new_rw_arc(Bank::new_for_tests(&genesis_config)); + } + } + #[test] fn test_bank_forks_new() { let GenesisConfigInfo { genesis_config, .. } = create_genesis_config(10_000); diff --git a/runtime/tests/stake.rs b/runtime/tests/stake.rs index 7c53e1e44a3af3..9922b8c9a5d075 100755 --- a/runtime/tests/stake.rs +++ b/runtime/tests/stake.rs @@ -142,7 +142,7 @@ fn test_stake_create_and_split_single_signature() { let staker_pubkey = staker_keypair.pubkey(); - let bank = Bank::new_with_bank_forks_for_tests(&genesis_config).0; + let (bank, _bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config); let bank_client = BankClient::new_shared(bank.clone()); let stake_address = @@ -218,7 +218,7 @@ fn test_stake_create_and_split_to_existing_system_account() { let staker_pubkey = staker_keypair.pubkey(); - let bank = Bank::new_with_bank_forks_for_tests(&genesis_config).0; + let (bank, _bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config); let bank_client = BankClient::new_shared(bank.clone()); let stake_address = @@ -593,7 +593,7 @@ fn test_create_stake_account_from_seed() { &solana_sdk::pubkey::new_rand(), 1_000_000, ); - let bank = Bank::new_with_bank_forks_for_tests(&genesis_config).0; + let (bank, _bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config); let mint_pubkey = mint_keypair.pubkey(); let bank_client = BankClient::new_shared(bank.clone()); diff --git a/stake-accounts/src/stake_accounts.rs b/stake-accounts/src/stake_accounts.rs index 084b7837cd99f4..bcea83eee9a627 100644 --- a/stake-accounts/src/stake_accounts.rs +++ b/stake-accounts/src/stake_accounts.rs @@ -283,7 +283,7 @@ pub(crate) fn move_stake_accounts( mod tests { use { super::*, - solana_runtime::{bank::Bank, bank_client::BankClient}, + solana_runtime::{bank::Bank, bank_client::BankClient, bank_forks::BankForks}, solana_sdk::{ account::{AccountSharedData, ReadableAccount}, client::SyncClient, @@ -292,16 +292,16 @@ mod tests { stake::state::StakeStateV2, }, solana_stake_program::stake_state, - std::sync::Arc, + std::sync::{Arc, RwLock}, }; - fn create_bank(lamports: u64) -> (Arc, Keypair, u64, u64) { + fn create_bank(lamports: u64) -> (Arc, Arc>, Keypair, u64, u64) { let (mut genesis_config, mint_keypair) = create_genesis_config(lamports); genesis_config.fee_rate_governor = solana_sdk::fee_calculator::FeeRateGovernor::new(0, 0); - let bank = Bank::new_with_bank_forks_for_tests(&genesis_config).0; + let (bank, bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config); let stake_rent = bank.get_minimum_balance_for_rent_exemption(StakeStateV2::size_of()); let system_rent = bank.get_minimum_balance_for_rent_exemption(0); - (bank, mint_keypair, stake_rent, system_rent) + (bank, bank_forks, mint_keypair, stake_rent, system_rent) } fn create_account( @@ -355,7 +355,7 @@ mod tests { #[test] fn test_new_derived_stake_account() { - let (bank, funding_keypair, stake_rent, system_rent) = create_bank(10_000_000); + let (bank, _bank_forks, funding_keypair, stake_rent, system_rent) = create_bank(10_000_000); let funding_pubkey = funding_keypair.pubkey(); let bank_client = BankClient::new_shared(bank); let fee_payer_keypair = create_account(&bank_client, &funding_keypair, system_rent); @@ -392,7 +392,7 @@ mod tests { #[test] fn test_authorize_stake_accounts() { - let (bank, funding_keypair, stake_rent, system_rent) = create_bank(10_000_000); + let (bank, _bank_forks, funding_keypair, stake_rent, system_rent) = create_bank(10_000_000); let funding_pubkey = funding_keypair.pubkey(); let bank_client = BankClient::new_shared(bank); let fee_payer_keypair = create_account(&bank_client, &funding_keypair, system_rent); @@ -454,7 +454,7 @@ mod tests { #[test] fn test_lockup_stake_accounts() { - let (bank, funding_keypair, stake_rent, system_rent) = create_bank(10_000_000); + let (bank, _bank_forks, funding_keypair, stake_rent, system_rent) = create_bank(10_000_000); let funding_pubkey = funding_keypair.pubkey(); let bank_client = BankClient::new_shared(bank); let fee_payer_keypair = create_account(&bank_client, &funding_keypair, system_rent); @@ -545,7 +545,7 @@ mod tests { #[test] fn test_rebase_stake_accounts() { - let (bank, funding_keypair, stake_rent, system_rent) = create_bank(10_000_000); + let (bank, _bank_forks, funding_keypair, stake_rent, system_rent) = create_bank(10_000_000); let funding_pubkey = funding_keypair.pubkey(); let bank_client = BankClient::new_shared(bank); let fee_payer_keypair = create_account(&bank_client, &funding_keypair, system_rent); @@ -608,7 +608,7 @@ mod tests { #[test] fn test_move_stake_accounts() { - let (bank, funding_keypair, stake_rent, system_rent) = create_bank(10_000_000); + let (bank, _bank_forks, funding_keypair, stake_rent, system_rent) = create_bank(10_000_000); let funding_pubkey = funding_keypair.pubkey(); let bank_client = BankClient::new_shared(bank); let fee_payer_keypair = create_account(&bank_client, &funding_keypair, system_rent); diff --git a/svm/src/transaction_processor.rs b/svm/src/transaction_processor.rs index 19f638674ef99e..73afc8cac772db 100644 --- a/svm/src/transaction_processor.rs +++ b/svm/src/transaction_processor.rs @@ -1305,8 +1305,9 @@ mod tests { fn test_replenish_program_cache_with_nonexistent_accounts() { let mock_bank = MockBankCallback::default(); let batch_processor = TransactionBatchProcessor::::default(); + let fork_graph = Arc::new(RwLock::new(TestForkGraph {})); batch_processor.program_cache.write().unwrap().fork_graph = - Some(Arc::new(RwLock::new(TestForkGraph {}))); + Some(Arc::downgrade(&fork_graph)); let key = Pubkey::new_unique(); let mut account_maps: HashMap = HashMap::new(); @@ -1319,8 +1320,9 @@ mod tests { fn test_replenish_program_cache() { let mock_bank = MockBankCallback::default(); let batch_processor = TransactionBatchProcessor::::default(); + let fork_graph = Arc::new(RwLock::new(TestForkGraph {})); batch_processor.program_cache.write().unwrap().fork_graph = - Some(Arc::new(RwLock::new(TestForkGraph {}))); + Some(Arc::downgrade(&fork_graph)); let key = Pubkey::new_unique(); let mut account_data = AccountSharedData::default(); @@ -1800,8 +1802,9 @@ mod tests { fn test_add_builtin() { let mock_bank = MockBankCallback::default(); let batch_processor = TransactionBatchProcessor::::default(); + let fork_graph = Arc::new(RwLock::new(TestForkGraph {})); batch_processor.program_cache.write().unwrap().fork_graph = - Some(Arc::new(RwLock::new(TestForkGraph {}))); + Some(Arc::downgrade(&fork_graph)); let key = Pubkey::new_unique(); let name = "a_builtin_name"; @@ -1843,8 +1846,9 @@ mod tests { fn fast_concur_test() { let mut mock_bank = MockBankCallback::default(); let batch_processor = TransactionBatchProcessor::::new(5, 5, HashSet::new()); + let fork_graph = Arc::new(RwLock::new(TestForkGraph {})); batch_processor.program_cache.write().unwrap().fork_graph = - Some(Arc::new(RwLock::new(TestForkGraph {}))); + Some(Arc::downgrade(&fork_graph)); let programs = vec![ deploy_program("hello-solana".to_string(), &mut mock_bank), diff --git a/svm/tests/conformance.rs b/svm/tests/conformance.rs index 9cf5c72682de5f..85697440f088fa 100644 --- a/svm/tests/conformance.rs +++ b/svm/tests/conformance.rs @@ -245,6 +245,7 @@ fn run_fixture(fixture: InstrFixture, filename: OsString, execute_as_instr: bool mock_bank.override_feature_set(feature_set); let batch_processor = TransactionBatchProcessor::::new(42, 2, HashSet::new()); + let fork_graph = Arc::new(RwLock::new(MockForkGraph {})); { let mut program_cache = batch_processor.program_cache.write().unwrap(); program_cache.environments = ProgramRuntimeEnvironments { @@ -254,7 +255,7 @@ fn run_fixture(fixture: InstrFixture, filename: OsString, execute_as_instr: bool FunctionRegistry::default(), )), }; - program_cache.fork_graph = Some(Arc::new(RwLock::new(MockForkGraph {}))); + program_cache.fork_graph = Some(Arc::downgrade(&fork_graph.clone())); } batch_processor.fill_missing_sysvar_cache_entries(&mock_bank); diff --git a/svm/tests/integration_test.rs b/svm/tests/integration_test.rs index c0966c6a5b3168..5c5d74f984c8ec 100644 --- a/svm/tests/integration_test.rs +++ b/svm/tests/integration_test.rs @@ -129,6 +129,7 @@ fn create_custom_environment<'a>() -> BuiltinProgram> { } fn create_executable_environment( + fork_graph: Arc>, mock_bank: &mut MockBankCallback, program_cache: &mut ProgramCache, ) { @@ -141,7 +142,7 @@ fn create_executable_environment( )), }; - program_cache.fork_graph = Some(Arc::new(RwLock::new(MockForkGraph {}))); + program_cache.fork_graph = Some(Arc::downgrade(&fork_graph)); // We must fill in the sysvar cache entries let time_now = SystemTime::now() @@ -446,7 +447,10 @@ fn svm_integration() { HashSet::new(), ); + let fork_graph = Arc::new(RwLock::new(MockForkGraph {})); + create_executable_environment( + fork_graph.clone(), &mut mock_bank, &mut batch_processor.program_cache.write().unwrap(), ); diff --git a/unified-scheduler-pool/src/lib.rs b/unified-scheduler-pool/src/lib.rs index c57217285f4762..ff3911ff806cb2 100644 --- a/unified-scheduler-pool/src/lib.rs +++ b/unified-scheduler-pool/src/lib.rs @@ -1477,7 +1477,10 @@ mod tests { system_transaction, transaction::{SanitizedTransaction, TransactionError}, }, - std::{sync::Arc, thread::JoinHandle}, + std::{ + sync::{Arc, RwLock}, + thread::JoinHandle, + }, }; #[derive(Debug)] @@ -1756,7 +1759,7 @@ mod tests { .. } = create_genesis_config(10_000); let bank = Bank::new_for_tests(&genesis_config); - let bank = setup_dummy_fork_graph(bank); + let (bank, _bank_forks) = setup_dummy_fork_graph(bank); let context = SchedulingContext::new(bank.clone()); @@ -1824,7 +1827,7 @@ mod tests { let GenesisConfigInfo { genesis_config, .. } = create_genesis_config(10_000); let bank = Bank::new_for_tests(&genesis_config); - let bank = setup_dummy_fork_graph(bank); + let (bank, _bank_forks) = setup_dummy_fork_graph(bank); let context = SchedulingContext::new(bank.clone()); @@ -1876,7 +1879,7 @@ mod tests { .. } = create_genesis_config(10_000); let bank = Bank::new_for_tests(&genesis_config); - let bank = setup_dummy_fork_graph(bank); + let (bank, _bank_forks) = setup_dummy_fork_graph(bank); let context = SchedulingContext::new(bank.clone()); @@ -1957,7 +1960,7 @@ mod tests { )); let bank = Bank::new_for_tests(&genesis_config); - let bank = setup_dummy_fork_graph(bank); + let (bank, _bank_forks) = setup_dummy_fork_graph(bank); let ignored_prioritization_fee_cache = Arc::new(PrioritizationFeeCache::new(0u64)); let pool = SchedulerPool::, _>::new( None, @@ -2050,7 +2053,7 @@ mod tests { } = create_genesis_config(10_000); let bank = Bank::new_for_tests(&genesis_config); - let bank = setup_dummy_fork_graph(bank); + let (bank, _bank_forks) = setup_dummy_fork_graph(bank); let ignored_prioritization_fee_cache = Arc::new(PrioritizationFeeCache::new(0u64)); let pool = SchedulerPool::, _>::new( None, @@ -2197,12 +2200,12 @@ mod tests { assert!(!child_bank.has_installed_scheduler()); } - fn setup_dummy_fork_graph(bank: Bank) -> Arc { + fn setup_dummy_fork_graph(bank: Bank) -> (Arc, Arc>) { let slot = bank.slot(); let bank_fork = BankForks::new_rw_arc(bank); let bank = bank_fork.read().unwrap().get(slot).unwrap(); - bank.set_fork_graph_in_program_cache(bank_fork); - bank + bank.set_fork_graph_in_program_cache(Arc::downgrade(&bank_fork)); + (bank, bank_fork) } #[test] @@ -2221,7 +2224,7 @@ mod tests { genesis_config.hash(), )); let bank = Bank::new_for_tests(&genesis_config); - let bank = setup_dummy_fork_graph(bank); + let (bank, _bank_forks) = setup_dummy_fork_graph(bank); let ignored_prioritization_fee_cache = Arc::new(PrioritizationFeeCache::new(0u64)); let pool = DefaultSchedulerPool::new_dyn(None, None, None, None, ignored_prioritization_fee_cache); @@ -2255,7 +2258,7 @@ mod tests { .. } = create_genesis_config(10_000); let bank = Bank::new_for_tests(&genesis_config); - let bank = setup_dummy_fork_graph(bank); + let (bank, _bank_forks) = setup_dummy_fork_graph(bank); let ignored_prioritization_fee_cache = Arc::new(PrioritizationFeeCache::new(0u64)); let pool_raw = DefaultSchedulerPool::do_new( @@ -2384,7 +2387,7 @@ mod tests { let GenesisConfigInfo { genesis_config, .. } = create_genesis_config(10_000); let bank = Bank::new_for_tests(&genesis_config); - let bank = setup_dummy_fork_graph(bank); + let (bank, _bank_forks) = setup_dummy_fork_graph(bank); // Use 2 transactions with different timings to deliberately cover the two code paths of // notifying panics in the handler threads, taken conditionally depending on whether the @@ -2466,7 +2469,7 @@ mod tests { } = create_genesis_config(10_000); let bank = Bank::new_for_tests(&genesis_config); - let bank = setup_dummy_fork_graph(bank); + let (bank, _bank_forks) = setup_dummy_fork_graph(bank); let ignored_prioritization_fee_cache = Arc::new(PrioritizationFeeCache::new(0u64)); let pool = SchedulerPool::, _>::new( None, @@ -2558,7 +2561,7 @@ mod tests { )); let bank = Bank::new_for_tests(&genesis_config); - let bank = setup_dummy_fork_graph(bank); + let (bank, _bank_forks) = setup_dummy_fork_graph(bank); let ignored_prioritization_fee_cache = Arc::new(PrioritizationFeeCache::new(0u64)); let pool = SchedulerPool::, _>::new_dyn( None, @@ -2619,7 +2622,7 @@ mod tests { // Create two banks for two contexts let bank0 = Bank::new_for_tests(&genesis_config); - let bank0 = setup_dummy_fork_graph(bank0); + let bank0 = setup_dummy_fork_graph(bank0).0; let bank1 = Arc::new(Bank::new_from_parent( bank0.clone(), &Pubkey::default(), @@ -2817,7 +2820,7 @@ mod tests { slot.checked_add(1).unwrap(), ); } - let bank = setup_dummy_fork_graph(bank); + let (bank, _bank_forks) = setup_dummy_fork_graph(bank); let context = SchedulingContext::new(bank.clone()); let ignored_prioritization_fee_cache = Arc::new(PrioritizationFeeCache::new(0u64)); @@ -2888,7 +2891,7 @@ mod tests { .. } = create_genesis_config(10_000); let bank = Bank::new_for_tests(&genesis_config); - let bank = &setup_dummy_fork_graph(bank); + let (bank, _bank_forks) = &setup_dummy_fork_graph(bank); let mut tx = system_transaction::transfer( mint_keypair,