From 74970a0b5de0d13b8783cf6e64c90fe6375deb82 Mon Sep 17 00:00:00 2001 From: Ryo Onodera Date: Thu, 16 Mar 2023 09:33:18 +0900 Subject: [PATCH] Remove unused ProcessOptions::entry_callback (#30600) * Confine entry_callback under cfg(test) for clarity * Fix ci * Actually remove entry_callback altogether * fix clippy --- core/src/replay_stage.rs | 1 - ledger/src/blockstore_processor.rs | 84 +----------------------------- 2 files changed, 2 insertions(+), 83 deletions(-) diff --git a/core/src/replay_stage.rs b/core/src/replay_stage.rs index 6da51fa8c..e17772321 100644 --- a/core/src/replay_stage.rs +++ b/core/src/replay_stage.rs @@ -1836,7 +1836,6 @@ impl ReplayStage { false, transaction_status_sender, Some(replay_vote_sender), - None, verify_recyclers, false, log_messages_bytes_limit, diff --git a/ledger/src/blockstore_processor.rs b/ledger/src/blockstore_processor.rs index 55322eb12..c4ed97f01 100644 --- a/ledger/src/blockstore_processor.rs +++ b/ledger/src/blockstore_processor.rs @@ -207,7 +207,6 @@ struct ExecuteBatchesInternalMetrics { fn execute_batches_internal( bank: &Arc, batches: &[TransactionBatchWithIndexes], - entry_callback: Option<&ProcessCallback>, transaction_status_sender: Option<&TransactionStatusSender>, replay_vote_sender: Option<&ReplayVoteSender>, log_messages_bytes_limit: Option, @@ -227,18 +226,14 @@ fn execute_batches_internal( let mut timings = ExecuteTimings::default(); let (result, execute_batches_time): (Result<()>, Measure) = measure!( { - let result = execute_batch( + execute_batch( transaction_batch, bank, transaction_status_sender, replay_vote_sender, &mut timings, log_messages_bytes_limit, - ); - if let Some(entry_callback) = entry_callback { - entry_callback(bank); - } - result + ) }, "execute_batch", ); @@ -303,7 +298,6 @@ fn rebatch_transactions<'a>( fn execute_batches( bank: &Arc, batches: &[TransactionBatchWithIndexes], - entry_callback: Option<&ProcessCallback>, transaction_status_sender: Option<&TransactionStatusSender>, replay_vote_sender: Option<&ReplayVoteSender>, confirmation_timing: &mut ConfirmationTiming, @@ -386,7 +380,6 @@ fn execute_batches( let execute_batches_internal_metrics = execute_batches_internal( bank, rebatched_txs, - entry_callback, transaction_status_sender, replay_vote_sender, log_messages_bytes_limit, @@ -440,7 +433,6 @@ pub fn process_entries_for_tests( bank, &mut replay_entries, randomize, - None, transaction_status_sender, replay_vote_sender, &mut confirmation_timing, @@ -458,7 +450,6 @@ fn process_entries_with_callback( bank: &Arc, entries: &mut [ReplayEntry], randomize: bool, - entry_callback: Option<&ProcessCallback>, transaction_status_sender: Option<&TransactionStatusSender>, replay_vote_sender: Option<&ReplayVoteSender>, confirmation_timing: &mut ConfirmationTiming, @@ -485,7 +476,6 @@ fn process_entries_with_callback( execute_batches( bank, &batches, - entry_callback, transaction_status_sender, replay_vote_sender, confirmation_timing, @@ -551,7 +541,6 @@ fn process_entries_with_callback( execute_batches( bank, &batches, - entry_callback, transaction_status_sender, replay_vote_sender, confirmation_timing, @@ -566,7 +555,6 @@ fn process_entries_with_callback( execute_batches( bank, &batches, - entry_callback, transaction_status_sender, replay_vote_sender, confirmation_timing, @@ -610,7 +598,6 @@ pub struct ProcessOptions { pub poh_verify: bool, pub full_leader_cache: bool, pub halt_at_slot: Option, - pub entry_callback: Option, pub new_hard_forks: Option>, pub debug_keys: Option>>, pub account_indexes: AccountSecondaryIndexes, @@ -905,7 +892,6 @@ fn confirm_full_slot( skip_verification, transaction_status_sender, replay_vote_sender, - opts.entry_callback.as_ref(), recyclers, opts.allow_dead_slots, opts.runtime_config.log_messages_bytes_limit, @@ -1032,7 +1018,6 @@ pub fn confirm_slot( skip_verification: bool, transaction_status_sender: Option<&TransactionStatusSender>, replay_vote_sender: Option<&ReplayVoteSender>, - entry_callback: Option<&ProcessCallback>, recyclers: &VerifyRecyclers, allow_dead_slots: bool, log_messages_bytes_limit: Option, @@ -1062,7 +1047,6 @@ pub fn confirm_slot( skip_verification, transaction_status_sender, replay_vote_sender, - entry_callback, recyclers, log_messages_bytes_limit, prioritization_fee_cache, @@ -1078,7 +1062,6 @@ fn confirm_slot_entries( skip_verification: bool, transaction_status_sender: Option<&TransactionStatusSender>, replay_vote_sender: Option<&ReplayVoteSender>, - entry_callback: Option<&ProcessCallback>, recyclers: &VerifyRecyclers, log_messages_bytes_limit: Option, prioritization_fee_cache: &PrioritizationFeeCache, @@ -1176,7 +1159,6 @@ fn confirm_slot_entries( bank, &mut replay_entries, true, // shuffle transactions. - entry_callback, transaction_status_sender, replay_vote_sender, timing, @@ -2655,65 +2637,6 @@ pub mod tests { assert_eq!(leader_schedule.max_schedules(), std::usize::MAX); } - #[test] - fn test_process_ledger_options_entry_callback() { - let GenesisConfigInfo { - genesis_config, - mint_keypair, - .. - } = create_genesis_config(100); - let (ledger_path, last_entry_hash) = create_new_tmp_ledger_auto_delete!(&genesis_config); - let blockstore = Blockstore::open(ledger_path.path()).unwrap(); - let blockhash = genesis_config.hash(); - let keypairs = [Keypair::new(), Keypair::new(), Keypair::new()]; - - let tx = system_transaction::transfer(&mint_keypair, &keypairs[0].pubkey(), 1, blockhash); - let entry_1 = next_entry(&last_entry_hash, 1, vec![tx]); - - let tx = system_transaction::transfer(&mint_keypair, &keypairs[1].pubkey(), 1, blockhash); - let entry_2 = next_entry(&entry_1.hash, 1, vec![tx]); - - let mut entries = vec![entry_1, entry_2]; - entries.extend(create_ticks( - genesis_config.ticks_per_slot, - 0, - last_entry_hash, - )); - blockstore - .write_entries( - 1, - 0, - 0, - genesis_config.ticks_per_slot, - None, - true, - &Arc::new(Keypair::new()), - entries, - 0, - ) - .unwrap(); - - let callback_counter: Arc> = Arc::default(); - let entry_callback = { - let counter = callback_counter.clone(); - let pubkeys: Vec = keypairs.iter().map(|k| k.pubkey()).collect(); - Arc::new(move |bank: &Bank| { - let mut counter = counter.write().unwrap(); - assert_eq!(bank.get_balance(&pubkeys[*counter]), 1); - assert_eq!(bank.get_balance(&pubkeys[*counter + 1]), 0); - *counter += 1; - }) - }; - - let opts = ProcessOptions { - entry_callback: Some(entry_callback), - accounts_db_test_hash_calculation: true, - ..ProcessOptions::default() - }; - test_process_blockstore(&genesis_config, &blockstore, &opts, &Arc::default()); - assert_eq!(*callback_counter.write().unwrap(), 2); - } - #[test] fn test_process_entries_tick() { let GenesisConfigInfo { genesis_config, .. } = create_genesis_config(1000); @@ -4070,7 +3993,6 @@ pub mod tests { false, None, None, - None, &VerifyRecyclers::default(), None, &PrioritizationFeeCache::new(0u64), @@ -4214,7 +4136,6 @@ pub mod tests { false, Some(&transaction_status_sender), None, - None, &VerifyRecyclers::default(), None, &PrioritizationFeeCache::new(0u64), @@ -4260,7 +4181,6 @@ pub mod tests { false, Some(&transaction_status_sender), None, - None, &VerifyRecyclers::default(), None, &PrioritizationFeeCache::new(0u64),