Remove the --unsafe-pruning CLI-argument (step 1) (#10995)

* sc-client-db: utils::open_database(...) — return OpenDbError so that the caller could tell the `OpenDbError::DoesNotExist` clearly

* sc-client-db: utils::open_database(..) — accept the `create: bool` argument

* sc-client-db: pruning — optional argument in the DatabaseSettings

* sc-state-db: Split `Error<E>` into separate `Error<E>` and `StateDbError`

* StateDb::open: choose the pruning-mode depending on the requested and stored values

* sc-state-db: test for different combinations of stored and requested pruning-modes

* CLI-argument: mark the unsafe-pruning as deprecated

* Fix tests

* tests: do not specify --pruning when running the substrate over the existing storage

* fix types for benches

* cargo fmt

* Check whether the pruning-mode and sync-mode are compatible

* cargo fmt

* parity-db: 0.3.11 -> 0.3.12

* sc-state-db: MetaDb::set_meta — a better doc-test

* cargo fmt

* make MetaDb read-only again!

* Remove the stray newline (and run the CI once again please)

* Last nitpicks

* A more comprehensive error message
This commit is contained in:
Roman Gafiyatullin
2022-05-06 13:07:44 +03:00
committed by GitHub
parent 994f8076b1
commit 729cba9d9e
23 changed files with 546 additions and 338 deletions
+3 -3
View File
@@ -307,7 +307,7 @@ where
wasm_runtime_overrides: config.wasm_runtime_overrides.clone(),
no_genesis: matches!(
config.network.sync_mode,
sc_network::config::SyncMode::Fast { .. } | sc_network::config::SyncMode::Warp
SyncMode::Fast { .. } | SyncMode::Warp { .. }
),
wasm_runtime_substitutes,
},
@@ -781,12 +781,12 @@ where
return Err("Warp sync enabled, but no warp sync provider configured.".into())
}
if config.state_pruning.is_archive() {
if client.requires_full_sync() {
match config.network.sync_mode {
SyncMode::Fast { .. } => return Err("Fast sync doesn't work for archive nodes".into()),
SyncMode::Warp => return Err("Warp sync doesn't work for archive nodes".into()),
SyncMode::Full => {},
};
}
}
let transaction_pool_adapter = Arc::new(TransactionPoolAdapter {
@@ -1989,6 +1989,10 @@ where
) -> sp_blockchain::Result<Option<Vec<Vec<u8>>>> {
self.backend.blockchain().block_indexed_body(*id)
}
fn requires_full_sync(&self) -> bool {
self.backend.requires_full_sync()
}
}
impl<B, E, Block, RA> backend::AuxStore for Client<B, E, Block, RA>
+1 -1
View File
@@ -73,7 +73,7 @@ pub struct Configuration {
/// Size in percent of cache size dedicated to child tries
pub state_cache_child_ratio: Option<usize>,
/// State pruning settings.
pub state_pruning: PruningMode,
pub state_pruning: Option<PruningMode>,
/// Number of blocks to keep in the db.
pub keep_blocks: KeepBlocks,
/// Chain configuration.