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
8 changes: 1 addition & 7 deletions crates/supervisor/storage/src/chaindb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,7 @@ impl ChainDb {
self.env.update(|tx| {
DerivationProvider::new(tx).initialise(anchor)?;
LogProvider::new(tx).initialise(anchor.derived)?;

let sp = SafetyHeadRefProvider::new(tx);
// todo: cross check if we can consider following safety head ref update
sp.update_safety_head_ref(SafetyLevel::LocalUnsafe, &anchor.derived)?;
sp.update_safety_head_ref(SafetyLevel::CrossUnsafe, &anchor.derived)?;
sp.update_safety_head_ref(SafetyLevel::LocalSafe, &anchor.derived)?;
sp.update_safety_head_ref(SafetyLevel::CrossSafe, &anchor.derived)
SafetyHeadRefProvider::new(tx).initialise(anchor.derived)
})?
}
}
Expand Down
14 changes: 13 additions & 1 deletion crates/supervisor/storage/src/providers/head_ref_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,20 @@

impl<Tx> SafetyHeadRefProvider<'_, Tx>
where
Tx: DbTxMut,
Tx: DbTxMut + DbTx,
{
pub(crate) fn initialise(&self, anchor: BlockInfo) -> Result<(), StorageError> {
match self.get_safety_head_ref(SafetyLevel::LocalUnsafe) {
Ok(_) => Ok(()), // if it is set already, skip.

Check warning on line 50 in crates/supervisor/storage/src/providers/head_ref_provider.rs

View check run for this annotation

Codecov / codecov/patch

crates/supervisor/storage/src/providers/head_ref_provider.rs#L50

Added line #L50 was not covered by tests
Err(StorageError::EntryNotFound(_)) => {
self.update_safety_head_ref(SafetyLevel::LocalUnsafe, &anchor)?;
self.update_safety_head_ref(SafetyLevel::CrossUnsafe, &anchor)?;
self.update_safety_head_ref(SafetyLevel::LocalSafe, &anchor)?;
self.update_safety_head_ref(SafetyLevel::CrossSafe, &anchor)
}
Err(err) => Err(err),

Check warning on line 57 in crates/supervisor/storage/src/providers/head_ref_provider.rs

View check run for this annotation

Codecov / codecov/patch

crates/supervisor/storage/src/providers/head_ref_provider.rs#L57

Added line #L57 was not covered by tests
}
}
pub(crate) fn update_safety_head_ref(
&self,
safety_level: SafetyLevel,
Expand Down