diff --git a/crates/node/builder/src/launch/common.rs b/crates/node/builder/src/launch/common.rs index fea652ed35..5289f9acf3 100644 --- a/crates/node/builder/src/launch/common.rs +++ b/crates/node/builder/src/launch/common.rs @@ -506,22 +506,9 @@ where // inconsistencies are found, unwind to the first block that's consistent across all // storage layers. // - // The ordering is critical: - // 1. Static file consistency (file-level) - heals interrupted writes without pruning data - // 2. RocksDB consistency - needs static file data to compute tx hashes for pruning - // 3. Static file consistency (checkpoint-level) - compares with MDBX, may prune data - // - // We compute a combined unwind target from checks and run a single unwind pass. - - // Step 1: Heal any file-level inconsistencies (interrupted writes, partial commits) - // This does NOT prune data, so RocksDB can still access transaction data. - factory.static_file_provider().check_file_consistency()?; - - // Step 2: RocksDB consistency check - uses static file data for tx hash lookups - let rocksdb_unwind = - factory.rocksdb_provider().check_consistency(&factory.database_provider_ro()?)?; - - // Step 3: Static file checkpoint consistency - compares with MDBX, may prune data + // Static file check runs first since it heals file-level inconsistencies and RocksDB + // consistency check may depend on static file data for tx hash lookups. + // We compute a combined unwind target from both checks and run a single unwind pass. let static_file_unwind = factory .static_file_provider() .check_consistency(&factory.provider()?)? @@ -530,6 +517,10 @@ where PipelineTarget::Sync(_) => unreachable!("check_consistency returns Unwind"), }); + // RocksDB consistency check + let rocksdb_unwind = + factory.rocksdb_provider().check_consistency(&factory.database_provider_ro()?)?; + // Combine unwind targets - take the minimum (most conservative) if both exist let unwind_target = match (static_file_unwind, rocksdb_unwind) { (None, None) => None, diff --git a/crates/storage/provider/src/providers/rocksdb_stub.rs b/crates/storage/provider/src/providers/rocksdb_stub.rs index 82bd7ea979..4a12a9cd43 100644 --- a/crates/storage/provider/src/providers/rocksdb_stub.rs +++ b/crates/storage/provider/src/providers/rocksdb_stub.rs @@ -86,12 +86,12 @@ impl RocksDBProvider { } /// Gets the first key-value pair from a table (stub implementation). - pub fn first(&self) -> ProviderResult> { + pub const fn first(&self) -> ProviderResult> { Ok(None) } /// Gets the last key-value pair from a table (stub implementation). - pub fn last(&self) -> ProviderResult> { + pub const fn last(&self) -> ProviderResult> { Ok(None) }