From eb4a34bd462a15a95293267a5863e16322a7a5cf Mon Sep 17 00:00:00 2001 From: jedleggett <4679729+jedleggett@users.noreply.github.com> Date: Tue, 21 Mar 2023 10:06:49 -0500 Subject: [PATCH] Fix Tests (#281) * fix tests --- core/src/bundle_stage.rs | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/core/src/bundle_stage.rs b/core/src/bundle_stage.rs index a8fcff2c37..7219253cd0 100644 --- a/core/src/bundle_stage.rs +++ b/core/src/bundle_stage.rs @@ -1498,6 +1498,7 @@ impl BundleStage { ) { const LOOP_STATS_METRICS_PERIOD: Duration = Duration::from_secs(1); + let ticks_per_slot = poh_recorder.read().unwrap().ticks_per_slot(); let recorder = poh_recorder.read().unwrap().recorder(); let qos_service = QosService::new(cost_model, id); @@ -1520,19 +1521,11 @@ impl BundleStage { current_bundle_block_limit: MAX_BLOCK_UNITS, current_tx_block_limit: MAX_BLOCK_UNITS.saturating_sub(preallocated_bundle_cost), initial_allocated_cost: preallocated_bundle_cost, - unreserved_ticks: poh_recorder - .write() - .unwrap() - .ticks_per_slot() - .saturating_div(5), + unreserved_ticks: ticks_per_slot.saturating_div(5), // 20% for non-bundles }; debug!( "initialize bundled reserved space: {preallocated_bundle_cost} cu for {} ticks", - poh_recorder - .write() - .unwrap() - .ticks_per_slot() - .saturating_sub(reserved_space.unreserved_ticks) + ticks_per_slot.saturating_sub(reserved_space.unreserved_ticks) ); while !exit.load(Ordering::Relaxed) { @@ -1744,6 +1737,8 @@ mod tests { { bank.write_cost_tracker().unwrap().set_limits(1, 1, 1); } + let current_block_cost_limit = bank.read_cost_tracker().unwrap().block_cost_limit(); + debug!("current block cost limit: {current_block_cost_limit}"); let blockstore = Arc::new( Blockstore::open(ledger_path.path()) .expect("Expected to be able to open database ledger"), @@ -1756,6 +1751,7 @@ mod tests { }; let (exit, poh_recorder, poh_service, _entry_receiver) = create_test_recorder(&bank, &blockstore, Some(poh_config), None); + let ticks_per_slot = poh_recorder.read().unwrap().ticks_per_slot(); let recorder = poh_recorder.read().unwrap().recorder(); let cost_model = Arc::new(RwLock::new(CostModel::default())); let qos_service = QosService::new(cost_model, 0); @@ -1780,10 +1776,10 @@ mod tests { &mut bundle_stage_leader_stats, &TEST_MAX_RETRY_DURATION, &mut BundleReservedSpace { - current_tx_block_limit: 1, - current_bundle_block_limit: 1, + current_tx_block_limit: current_block_cost_limit, + current_bundle_block_limit: current_block_cost_limit, initial_allocated_cost: 0, - unreserved_ticks: poh_recorder.read().unwrap().ticks_per_slot(), + unreserved_ticks: ticks_per_slot, }, ); @@ -2048,7 +2044,8 @@ mod tests { bank.write_cost_tracker() .unwrap() .set_limits(u64::MAX, u64::MAX, u64::MAX); - + let current_block_cost_limit = bank.read_cost_tracker().unwrap().block_cost_limit(); + debug!("current block cost limit: {current_block_cost_limit}"); let ledger_path = get_tmp_ledger_path_auto_delete!(); let blockstore = Arc::new( Blockstore::open(ledger_path.path()) @@ -2062,6 +2059,7 @@ mod tests { }; let (exit, poh_recorder, poh_service, _entry_receiver) = create_test_recorder(&bank, &blockstore, Some(poh_config), None); + let ticks_per_slot = poh_recorder.read().unwrap().ticks_per_slot(); let recorder = poh_recorder.read().unwrap().recorder(); let (gossip_vote_sender, _gossip_vote_receiver) = unbounded(); let cost_model = Arc::new(RwLock::new(CostModel::default())); @@ -2117,10 +2115,10 @@ mod tests { &mut bundle_stage_leader_stats, &TEST_MAX_RETRY_DURATION, &mut BundleReservedSpace { - current_tx_block_limit: u64::MAX, - current_bundle_block_limit: u64::MAX, + current_tx_block_limit: current_block_cost_limit, + current_bundle_block_limit: current_block_cost_limit, initial_allocated_cost: 0, - unreserved_ticks: poh_recorder.read().unwrap().ticks_per_slot(), + unreserved_ticks: ticks_per_slot, }, ); info!("test_bundle_max_retries result: {:?}", result);