mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 19:17:58 +00:00
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:
committed by
GitHub
parent
994f8076b1
commit
729cba9d9e
@@ -40,12 +40,16 @@ pub struct ImportParams {
|
||||
#[clap(flatten)]
|
||||
pub database_params: DatabaseParams,
|
||||
|
||||
/// Force start with unsafe pruning settings.
|
||||
/// THIS IS A DEPRECATED CLI-ARGUMENT.
|
||||
///
|
||||
/// When running as a validator it is highly recommended to disable state
|
||||
/// pruning (i.e. 'archive') which is the default. The node will refuse to
|
||||
/// start as a validator if pruning is enabled unless this option is set.
|
||||
/// It has been preserved in order to not break the compatibility with the existing scripts.
|
||||
/// Enabling this option will lead to a runtime warning.
|
||||
/// In future this option will be removed completely, thus specifying it will lead to a start
|
||||
/// up error.
|
||||
///
|
||||
/// Details: <https://github.com/paritytech/substrate/issues/8103>
|
||||
#[clap(long)]
|
||||
#[deprecated = "According to https://github.com/paritytech/substrate/issues/8103"]
|
||||
pub unsafe_pruning: bool,
|
||||
|
||||
/// Method for executing Wasm runtime code.
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
use crate::error;
|
||||
use clap::Args;
|
||||
use sc_service::{KeepBlocks, PruningMode, Role};
|
||||
use sc_service::{KeepBlocks, PruningMode};
|
||||
|
||||
/// Parameters to define the pruning mode
|
||||
#[derive(Debug, Clone, PartialEq, Args)]
|
||||
@@ -39,29 +39,17 @@ pub struct PruningParams {
|
||||
|
||||
impl PruningParams {
|
||||
/// Get the pruning value from the parameters
|
||||
pub fn state_pruning(&self, unsafe_pruning: bool, role: &Role) -> error::Result<PruningMode> {
|
||||
// by default we disable pruning if the node is an authority (i.e.
|
||||
// `ArchiveAll`), otherwise we keep state for the last 256 blocks. if the
|
||||
// node is an authority and pruning is enabled explicitly, then we error
|
||||
// unless `unsafe_pruning` is set.
|
||||
Ok(match &self.pruning {
|
||||
Some(ref s) if s == "archive" => PruningMode::ArchiveAll,
|
||||
None if role.is_authority() => PruningMode::ArchiveAll,
|
||||
None => PruningMode::default(),
|
||||
Some(s) => {
|
||||
if role.is_authority() && !unsafe_pruning {
|
||||
return Err(error::Error::Input(
|
||||
"Validators should run with state pruning disabled (i.e. archive). \
|
||||
You can ignore this check with `--unsafe-pruning`."
|
||||
.to_string(),
|
||||
))
|
||||
}
|
||||
|
||||
PruningMode::keep_blocks(s.parse().map_err(|_| {
|
||||
error::Error::Input("Invalid pruning mode specified".to_string())
|
||||
})?)
|
||||
},
|
||||
})
|
||||
pub fn state_pruning(&self) -> error::Result<Option<PruningMode>> {
|
||||
self.pruning
|
||||
.as_ref()
|
||||
.map(|s| match s.as_str() {
|
||||
"archive" => Ok(PruningMode::ArchiveAll),
|
||||
bc => bc
|
||||
.parse()
|
||||
.map_err(|_| error::Error::Input("Invalid pruning mode specified".to_string()))
|
||||
.map(PruningMode::keep_blocks),
|
||||
})
|
||||
.transpose()
|
||||
}
|
||||
|
||||
/// Get the block pruning value from the parameters
|
||||
|
||||
Reference in New Issue
Block a user