Skip to content
This repository was archived by the owner on Jan 16, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
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
7 changes: 6 additions & 1 deletion crates/supervisor/core/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! [`SupervisorService`](crate::SupervisorService) errors.

use crate::{ChainProcessorError, syncnode::ManagedNodeError};
use crate::{ChainProcessorError, CrossSafetyError, syncnode::ManagedNodeError};
use jsonrpsee::types::{ErrorCode, ErrorObjectOwned};
use kona_supervisor_storage::StorageError;
use kona_supervisor_types::AccessListError;
Expand Down Expand Up @@ -41,6 +41,10 @@ pub enum SupervisorError {
/// Indicates the error occurred while parsing the access_list
#[error(transparent)]
AccessListError(#[from] AccessListError),

/// Indicated the error occurred while initializing the safety checker jobs
#[error(transparent)]
CrossSafetyCheckerError(#[from] CrossSafetyError),
}

impl From<SupervisorError> for ErrorObjectOwned {
Expand All @@ -53,6 +57,7 @@ impl From<SupervisorError> for ErrorObjectOwned {
SupervisorError::StorageError(_) |
SupervisorError::ManagedNodeError(_) |
SupervisorError::ChainProcessorError(_) |
SupervisorError::CrossSafetyCheckerError(_) |
SupervisorError::AccessListError(_) => ErrorObjectOwned::from(ErrorCode::InternalError),
SupervisorError::DataAvailability(err) => err.into(),
}
Expand Down
2 changes: 1 addition & 1 deletion crates/supervisor/core/src/safety_checker/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use op_alloy_consensus::interop::SafetyLevel;
use thiserror::Error;

/// Errors returned when validating cross-chain message dependencies.
#[derive(Debug, Error)]
#[derive(Debug, Error, Eq, PartialEq)]
pub enum CrossSafetyError {
/// Indicates a failure while accessing storage during dependency checking.
#[error("storage error: {0}")]
Expand Down
24 changes: 15 additions & 9 deletions crates/supervisor/core/src/safety_checker/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use kona_supervisor_storage::CrossChainSafetyProvider;
use op_alloy_consensus::interop::SafetyLevel;
use tokio_util::sync::CancellationToken;
use tracing::{debug, info, warn};
use tracing::{info, warn};

/// A background job that promotes blocks to a target safety level on a given chain.
///
Expand Down Expand Up @@ -75,7 +75,7 @@
_ = async {
match self.promote_next_block(&checker) {
Ok(block_info) => {
debug!(
info!(

Check warning on line 78 in crates/supervisor/core/src/safety_checker/task.rs

View check run for this annotation

Codecov / codecov/patch

crates/supervisor/core/src/safety_checker/task.rs#L78

Added line #L78 was not covered by tests
target: "safety_checker",
chain_id = self.chain_id,
target_level = %self.target_level,
Expand All @@ -84,13 +84,19 @@
);
}
Err(err) => {
warn!(
target: "safety_checker",
chain_id = self.chain_id,
target_level = %self.target_level,
%err,
"Error promoting next candidate block"
);
match err {

Check warning on line 87 in crates/supervisor/core/src/safety_checker/task.rs

View check run for this annotation

Codecov / codecov/patch

crates/supervisor/core/src/safety_checker/task.rs#L87

Added line #L87 was not covered by tests
// don't spam warnings if head is already on top - nothing to promote
CrossSafetyError::NoBlockToPromote => {},

Check warning on line 89 in crates/supervisor/core/src/safety_checker/task.rs

View check run for this annotation

Codecov / codecov/patch

crates/supervisor/core/src/safety_checker/task.rs#L89

Added line #L89 was not covered by tests
_ => {
warn!(

Check warning on line 91 in crates/supervisor/core/src/safety_checker/task.rs

View check run for this annotation

Codecov / codecov/patch

crates/supervisor/core/src/safety_checker/task.rs#L91

Added line #L91 was not covered by tests
target: "safety_checker",
chain_id = self.chain_id,
target_level = %self.target_level,
%err,
"Error promoting next candidate block"

Check warning on line 96 in crates/supervisor/core/src/safety_checker/task.rs

View check run for this annotation

Codecov / codecov/patch

crates/supervisor/core/src/safety_checker/task.rs#L96

Added line #L96 was not covered by tests
);
}
}
tokio::time::sleep(self.interval).await;
}
}
Expand Down
37 changes: 35 additions & 2 deletions crates/supervisor/core/src/supervisor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
use kona_supervisor_types::{SuperHead, parse_access_list};
use op_alloy_rpc_types::SuperchainDAError;
use reqwest::Url;
use std::{collections::HashMap, sync::Arc};
use std::{collections::HashMap, sync::Arc, time::Duration};
use tokio_util::sync::CancellationToken;
use tracing::{error, info, warn};

use crate::{
ChainProcessor, SupervisorError,
ChainProcessor, CrossSafetyCheckerJob, SupervisorError,
config::Config,
l1_watcher::L1Watcher,
syncnode::{ManagedNode, ManagedNodeApiProvider},
Expand Down Expand Up @@ -131,6 +131,7 @@
self.init_managed_nodes().await?;
self.init_chain_processor().await?;
self.init_l1_watcher()?;
self.init_cross_safety_checker().await?;

Check warning on line 134 in crates/supervisor/core/src/supervisor.rs

View check run for this annotation

Codecov / codecov/patch

crates/supervisor/core/src/supervisor.rs#L134

Added line #L134 was not covered by tests
Ok(())
}

Expand Down Expand Up @@ -166,6 +167,38 @@
}
Ok(())
}
async fn init_cross_safety_checker(&self) -> Result<(), SupervisorError> {
for (&chain_id, config) in &self.config.rollup_config_set.rollups {
let db = Arc::clone(&self.database_factory);
let cancel = self.cancel_token.clone();

Check warning on line 173 in crates/supervisor/core/src/supervisor.rs

View check run for this annotation

Codecov / codecov/patch

crates/supervisor/core/src/supervisor.rs#L170-L173

Added lines #L170 - L173 were not covered by tests

let cross_safe_job = CrossSafetyCheckerJob::new(
chain_id,
db.clone(),
cancel.clone(),
Duration::from_secs(config.block_time),
SafetyLevel::CrossSafe,
)?;

Check warning on line 181 in crates/supervisor/core/src/supervisor.rs

View check run for this annotation

Codecov / codecov/patch

crates/supervisor/core/src/supervisor.rs#L175-L181

Added lines #L175 - L181 were not covered by tests

tokio::spawn(async move {
cross_safe_job.run().await;
});

Check warning on line 185 in crates/supervisor/core/src/supervisor.rs

View check run for this annotation

Codecov / codecov/patch

crates/supervisor/core/src/supervisor.rs#L183-L185

Added lines #L183 - L185 were not covered by tests

let cross_unsafe_job = CrossSafetyCheckerJob::new(
chain_id,
db,
cancel,
Duration::from_secs(config.block_time),
SafetyLevel::CrossUnsafe,
)?;

Check warning on line 193 in crates/supervisor/core/src/supervisor.rs

View check run for this annotation

Codecov / codecov/patch

crates/supervisor/core/src/supervisor.rs#L187-L193

Added lines #L187 - L193 were not covered by tests

tokio::spawn(async move {
cross_unsafe_job.run().await;
});
}

Check warning on line 198 in crates/supervisor/core/src/supervisor.rs

View check run for this annotation

Codecov / codecov/patch

crates/supervisor/core/src/supervisor.rs#L195-L198

Added lines #L195 - L198 were not covered by tests

Ok(())
}

Check warning on line 201 in crates/supervisor/core/src/supervisor.rs

View check run for this annotation

Codecov / codecov/patch

crates/supervisor/core/src/supervisor.rs#L200-L201

Added lines #L200 - L201 were not covered by tests

async fn init_managed_nodes(&mut self) -> Result<(), SupervisorError> {
for config in self.config.l2_consensus_nodes_config.iter() {
Expand Down