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(gas_price_service_v1): ensure that the algo updater is synced to l2 block height #2504

Merged
merged 5 commits into from
Dec 24, 2024
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
12 changes: 9 additions & 3 deletions crates/services/gas_price_service/src/v1/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -777,13 +777,19 @@ async fn uninitialized_task__init__if_metadata_behind_l2_height_then_sync() {
empty_block_stream(),
gas_price_db,
FakeDABlockCost::never_returns(),
onchain_db,
onchain_db.clone(),
)
.unwrap();

// when
service.init(&StateWatcher::started()).await.unwrap();
let gas_price_service = service.init(&StateWatcher::started()).await.unwrap();

// then
// no panic
// sleep to allow the service to sync
tokio::time::sleep(std::time::Duration::from_millis(100)).await;
Copy link
Contributor

Choose a reason for hiding this comment

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

personally I'm not a fan of sleep of sleeps to wait for a condition to happen, but this is orthogonal to the PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agree, but with tokio time I can accept it since tokio auto-advances time when all futures are pending.

(Reference https://docs.rs/tokio/latest/tokio/time/fn.pause.html)


let on_chain_height = u32::from(onchain_db.height);
let algo_updater_height = gas_price_service.algorithm_updater().l2_block_height;

assert_eq!(on_chain_height, algo_updater_height);
}
Loading