diff --git a/Cargo.toml b/Cargo.toml index 8aee5cd..0c04a4a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -87,3 +87,6 @@ test-case = "3.1.0" [features] default = ["default-config"] default-config = [] + +[profile.release] +panic = "abort" diff --git a/src/service.rs b/src/service.rs index 94260ef..e610e44 100644 --- a/src/service.rs +++ b/src/service.rs @@ -24,7 +24,7 @@ impl Service { let task_runner = TaskRunner::new(app.clone()); task_runner.add_task("Broadcast transactions", tasks::broadcast_txs); - task_runner.add_task("Escalate transactions", tasks::escalate_txs); + task_runner.add_task("Escalate transactions", tasks::escalate_txs_task); task_runner.add_task("Prune blocks", tasks::prune_blocks); task_runner.add_task("Prune transactions", tasks::prune_txs); task_runner.add_task("Finalize transactions", tasks::finalize_txs); diff --git a/src/tasks.rs b/src/tasks.rs index b86014b..7e13973 100644 --- a/src/tasks.rs +++ b/src/tasks.rs @@ -7,7 +7,7 @@ pub mod metrics; pub mod prune; pub use self::broadcast::broadcast_txs; -pub use self::escalate::escalate_txs; +pub use self::escalate::escalate_txs_task; pub use self::finalize::finalize_txs; pub use self::handle_reorgs::{handle_hard_reorgs, handle_soft_reorgs}; pub use self::index::index_chain; diff --git a/src/tasks/escalate.rs b/src/tasks/escalate.rs index 25bc21a..1be0649 100644 --- a/src/tasks/escalate.rs +++ b/src/tasks/escalate.rs @@ -14,36 +14,40 @@ use crate::broadcast_utils::should_send_relayer_transactions; use crate::db::TxForEscalation; use crate::types::RelayerInfo; -pub async fn escalate_txs(app: Arc) -> eyre::Result<()> { +pub async fn escalate_txs_task(app: Arc) -> eyre::Result<()> { loop { - tracing::info!("Escalating transactions"); + escalate_txs(&app).await?; - let txs_for_escalation = app - .db - .get_txs_for_escalation(app.config.service.escalation_interval) - .await?; + tokio::time::sleep(app.config.service.escalation_interval).await; + } +} - tracing::info!( - "Got {} transactions to escalate", - txs_for_escalation.len() - ); +#[tracing::instrument(skip(app))] +async fn escalate_txs(app: &App) -> eyre::Result<()> { + tracing::info!("Escalating transactions"); - let txs_for_escalation = split_txs_per_relayer(txs_for_escalation); + let txs_for_escalation = app + .db + .get_txs_for_escalation(app.config.service.escalation_interval) + .await?; - let mut futures = FuturesUnordered::new(); + tracing::info!("Got {} transactions to escalate", txs_for_escalation.len()); - for (relayer_id, txs) in txs_for_escalation { - futures.push(escalate_relayer_txs(&app, relayer_id, txs)); - } + let txs_for_escalation = split_txs_per_relayer(txs_for_escalation); - while let Some(result) = futures.next().await { - if let Err(err) = result { - tracing::error!(error = ?err, "Failed escalating txs"); - } - } + let mut futures = FuturesUnordered::new(); - tokio::time::sleep(app.config.service.escalation_interval).await; + for (relayer_id, txs) in txs_for_escalation { + futures.push(escalate_relayer_txs(&app, relayer_id, txs)); + } + + while let Some(result) = futures.next().await { + if let Err(err) = result { + tracing::error!(error = ?err, "Failed escalating txs"); + } } + + Ok(()) } #[tracing::instrument(skip(app, txs))]