Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Tests #281

Merged
merged 3 commits into from
Mar 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 15 additions & 17 deletions core/src/bundle_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was not breaking the test, but i went ahead and copied the pattern that fixed the test

let recorder = poh_recorder.read().unwrap().recorder();
let qos_service = QosService::new(cost_model, id);

Expand All @@ -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) {
Expand Down Expand Up @@ -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"),
Expand All @@ -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);
Expand All @@ -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,
},
);

Expand Down Expand Up @@ -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())
Expand All @@ -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()));
Expand Down Expand Up @@ -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);
Expand Down