Skip to content

Commit

Permalink
refactor(katana): make gas oracle a critical task (#2859)
Browse files Browse the repository at this point in the history
  • Loading branch information
kariy authored Jan 2, 2025
1 parent 3ccea4b commit 38f68db
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
13 changes: 8 additions & 5 deletions crates/katana/core/src/backend/gas_oracle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use katana_primitives::block::GasPrices;
use katana_tasks::TaskSpawner;
use parking_lot::Mutex;
use tokio::time::Duration;
use tracing::info;
use tracing::error;
use url::Url;

const BUFFER_SIZE: usize = 60;
Expand Down Expand Up @@ -83,10 +83,13 @@ impl L1GasOracle {
let prices = oracle.prices.clone();
let l1_provider = oracle.l1_provider.clone();

task_spawner.build_task().graceful_shutdown().name("L1 Gas Oracle worker").spawn(
task_spawner.build_task().critical().name("L1 Gas Oracle worker").spawn(
async move {
let mut worker = GasOracleWorker::new(prices, l1_provider);
worker.run().await
worker
.run()
.await
.inspect_err(|error| error!(target: "gas_oracle", %error, "Gas oracle worker failed."))
},
);
}
Expand Down Expand Up @@ -174,13 +177,13 @@ impl GasOracleWorker {

let mut prices = self.prices.lock();

if let Err(e) = update_gas_price(
if let Err(error) = update_gas_price(
&mut prices,
&mut self.gas_price_buffer,
&mut self.data_gas_price_buffer,
fee_history,
) {
info!(%e, "Error running the gas oracle");
error!(target: "gas_oracle", %error, "Error updating gas prices.");
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/katana/node/src/exit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ impl<'a> NodeStoppedFuture<'a> {
pub(crate) fn new(handle: &'a LaunchedNode) -> Self {
let fut = Box::pin(async {
handle.node.task_manager.wait_for_shutdown().await;
handle.rpc.clone().stopped().await;
handle.rpc.stop()?;
Ok(())
});
Self { fut }
Expand Down

0 comments on commit 38f68db

Please sign in to comment.