feat(supervisor): pre-interop db support#2368
Conversation
Codecov ReportAttention: Patch coverage is
✅ All tests successful. No failed tests found. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull Request Overview
This PR adds pre-interop database initialization support by introducing dedicated initialization methods for both derivation and log storage, updating consumers to call these methods, and adapting tests and metrics accordingly.
- Introduce
initialise_derivation_storageandinitialise_log_storagein storage traits and providers - Refactor
ChainDbto use new initialization methods and update supervisor/bootstrap code - Enhance tests, metrics, and configuration to support the new initialization flow
Reviewed Changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/supervisor/storage/src/traits.rs | Added initialise_derivation_storage and initialise_log_storage methods to writer traits |
| crates/supervisor/storage/src/providers/log_provider.rs | Implemented initialise_log_storage, changed missing-block error to DatabaseNotInitialised, added empty-storage test |
| crates/supervisor/storage/src/providers/head_ref_provider.rs | Enhanced update_safety_head_ref to prevent downgrading and renamed parameter to incoming_head_ref |
| crates/supervisor/storage/src/providers/derivation_provider.rs | Implemented initialise_derivation_storage, switched EntryNotFound to DatabaseNotInitialised, extended tests |
| crates/supervisor/storage/src/metrics.rs | Updated metrics method list to include new initialization and renamed methods |
| crates/supervisor/storage/src/chaindb.rs | Removed unified initialise, added calls to new init methods in ChainDb, left TODOs |
| crates/supervisor/core/src/supervisor.rs | Replaced db.initialise with separate init calls for log and derivation storage |
| crates/supervisor/core/src/logindexer/indexer.rs | Added test stub for initialise_log_storage in LogStorageWriter impl |
| crates/supervisor/core/src/config/rollup_config_set.rs | Derived Default for Genesis and RollupConfig |
| crates/supervisor/core/src/chain_processor/task.rs | Added _rollup_config field and updated constructor/tests with initialise_* stubs |
| crates/supervisor/core/src/chain_processor/chain.rs | Added rollup_config field, increased channel buffer, updated tests for new init methods |
Comments suppressed due to low confidence (10)
crates/supervisor/storage/src/providers/log_provider.rs:149
- Replacing
EntryNotFoundwithDatabaseNotInitialisedhere conflates missing entries and uninitialized database states; consider preserving a distinct error forEntryNotFoundor document the new semantics clearly.
StorageError::DatabaseNotInitialised
crates/supervisor/storage/src/providers/derivation_provider.rs:564
- [nitpick] This test comment refers to a second initialization but calls
insert_pair; consider renaming the helper or aligning the test to use aninitialize_*helper for clarity.
assert!(insert_pair(&db, &anchor).is_ok());
crates/supervisor/storage/src/chaindb.rs:72
- Rather than scattering two separate init calls, provide a single
initialize(anchor)method onChainDbto encapsulate both log and derivation initialization and reduce the chance of forgetting one.
// todo: make sure all get method return DatabaseNotInitialised error if db is not initialised
crates/supervisor/core/src/config/rollup_config_set.rs:10
- [nitpick] Deriving
DefaultforGenesismay produce semantically invalid default anchors. Consider whether a meaningful default is appropriate or removeDefault.
#[derive(Debug, Default, Clone)]
crates/supervisor/storage/src/traits.rs:63
- [nitpick] The doc comment uses US spelling
Initializeswhereas the method name uses British spellinginitialise_derivation_storage; consider aligning spelling for consistency.
/// Initializes the derivation storage with a given [`DerivedRefPair`].
crates/supervisor/core/src/logindexer/indexer.rs:170
- In this test stub
impl LogStorageWriter for Db, the method signature has no body and will cause a compilation error. Add a body (e.g.,Ok(())).
fn initialise_log_storage(&self, _block: BlockInfo) -> Result<(), StorageError>;
crates/supervisor/core/src/chain_processor/task.rs:497
- Test stub for
initialise_log_storageis missing a method body. Provide an implementation (e.g., returningOk(())) for this trait in tests.
fn initialise_log_storage(
crates/supervisor/core/src/chain_processor/task.rs:517
- Test stub for
initialise_derivation_storagelacks a method body. Implement the stub to returnOk(())to satisfy the trait in tests.
fn initialise_derivation_storage(
crates/supervisor/core/src/chain_processor/chain.rs:244
- In the test
impl LogStorageWriter for Db,initialise_log_storagehas no body. Add a default body to avoid compilation errors.
fn initialise_log_storage(
crates/supervisor/core/src/chain_processor/chain.rs:264
- The test stub for
initialise_derivation_storageis missing an implementation. Provide a stub body (e.g.,Ok(())).
fn initialise_derivation_storage(
Closes #2351
Part of #2272