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

Create uninitialized task for v1 gas price service #2442

Open
wants to merge 15 commits into
base: feature/allow-DA-blocks-to-be-received-out-of-order
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 2 additions & 0 deletions crates/services/gas_price_service/src/v0/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,15 @@ where
Metadata: MetadataStorage,
{
async fn run(&mut self, watcher: &mut StateWatcher) -> TaskNextAction {
tracing::debug!("Starting gas price service");
tokio::select! {
biased;
_ = watcher.while_started() => {
tracing::debug!("Stopping gas price service");
TaskNextAction::Stop
}
l2_block_res = self.l2_block_source.get_l2_block() => {
tracing::debug!("Received L2 block");
let res = self.process_l2_block_res(l2_block_res).await;
TaskNextAction::always_continue(res)
}
Expand Down
14 changes: 8 additions & 6 deletions crates/services/gas_price_service/src/v0/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,16 @@ async fn next_gas_price__affected_by_new_l2_block() {
algo_updater,
);

tracing::debug!("service created");

let read_algo = service.next_block_algorithm();
let initial = read_algo.next_gas_price();
let mut watcher = StateWatcher::started();
tokio::spawn(async move { service.run(&mut watcher).await });

// when
service.run(&mut watcher).await;
l2_block_sender.send(l2_block).await.unwrap();
service.shutdown().await.unwrap();
tokio::time::sleep(std::time::Duration::from_millis(10)).await;

// then
let new = read_algo.next_gas_price();
Expand Down Expand Up @@ -212,14 +214,14 @@ async fn next__new_l2_block_saves_old_metadata() {
algo_updater,
);

// when
let read_algo = service.next_block_algorithm();
let mut watcher = StateWatcher::default();
let start = read_algo.next_gas_price();
let mut watcher = StateWatcher::started();
Copy link
Member

Choose a reason for hiding this comment

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

is there a reason this isn't StateWatcher::default()?

tokio::spawn(async move { service.run(&mut watcher).await });

service.run(&mut watcher).await;
// when
l2_block_sender.send(l2_block).await.unwrap();
service.shutdown().await.unwrap();
tokio::time::sleep(std::time::Duration::from_millis(10)).await;

// then
let new = read_algo.next_gas_price();
Expand Down
4 changes: 3 additions & 1 deletion crates/services/gas_price_service/src/v1/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ impl From<&V1AlgorithmConfig> for AlgorithmUpdaterV1 {
.map(|size| u128::from(*size))
.sum();
Self {
new_scaled_exec_price: value.new_exec_gas_price,
new_scaled_exec_price: value
.new_exec_gas_price
.saturating_mul(value.gas_price_factor.get()),
l2_block_height: 0,
new_scaled_da_gas_price: value.min_da_gas_price,
gas_price_factor: value.gas_price_factor,
Expand Down
4 changes: 2 additions & 2 deletions crates/services/gas_price_service/src/v1/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,11 @@ async fn next_gas_price__affected_by_new_l2_block() {
let read_algo = service.next_block_algorithm();
let initial = read_algo.next_gas_price();
let mut watcher = StateWatcher::started();
tokio::spawn(async move { service.run(&mut watcher).await });

// when
service.run(&mut watcher).await;
l2_block_sender.send(l2_block).await.unwrap();
service.shutdown().await.unwrap();
tokio::time::sleep(std::time::Duration::from_millis(10)).await;

// then
let new = read_algo.next_gas_price();
Expand Down
Loading