mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-18 17:41:01 +00:00
Rename --pruning and --keep-blocks to be more similar to one another (#11934)
* rename prunning and keep-blocks flags * Add aliases in keep-blocks and pruning for backward compatibility * Rename in code variables from and to and
This commit is contained in:
@@ -28,7 +28,7 @@ use sc_consensus::{
|
|||||||
};
|
};
|
||||||
use sc_service::{
|
use sc_service::{
|
||||||
config::{
|
config::{
|
||||||
DatabaseSource, KeepBlocks, KeystoreConfig, NetworkConfiguration, OffchainWorkerConfig,
|
BlocksPruning, DatabaseSource, KeystoreConfig, NetworkConfiguration, OffchainWorkerConfig,
|
||||||
PruningMode, WasmExecutionMethod, WasmtimeInstantiationStrategy,
|
PruningMode, WasmExecutionMethod, WasmtimeInstantiationStrategy,
|
||||||
},
|
},
|
||||||
BasePath, Configuration, Role,
|
BasePath, Configuration, Role,
|
||||||
@@ -75,7 +75,7 @@ fn new_node(tokio_handle: Handle) -> node_cli::service::NewFullBase {
|
|||||||
state_cache_size: 67108864,
|
state_cache_size: 67108864,
|
||||||
state_cache_child_ratio: None,
|
state_cache_child_ratio: None,
|
||||||
state_pruning: Some(PruningMode::ArchiveAll),
|
state_pruning: Some(PruningMode::ArchiveAll),
|
||||||
keep_blocks: KeepBlocks::All,
|
blocks_pruning: BlocksPruning::All,
|
||||||
chain_spec: spec,
|
chain_spec: spec,
|
||||||
wasm_method: WasmExecutionMethod::Compiled {
|
wasm_method: WasmExecutionMethod::Compiled {
|
||||||
instantiation_strategy: WasmtimeInstantiationStrategy::PoolingCopyOnWrite,
|
instantiation_strategy: WasmtimeInstantiationStrategy::PoolingCopyOnWrite,
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ use node_primitives::AccountId;
|
|||||||
use sc_client_api::execution_extensions::ExecutionStrategies;
|
use sc_client_api::execution_extensions::ExecutionStrategies;
|
||||||
use sc_service::{
|
use sc_service::{
|
||||||
config::{
|
config::{
|
||||||
DatabaseSource, KeepBlocks, KeystoreConfig, NetworkConfiguration, OffchainWorkerConfig,
|
BlocksPruning, DatabaseSource, KeystoreConfig, NetworkConfiguration, OffchainWorkerConfig,
|
||||||
PruningMode, TransactionPoolOptions, WasmExecutionMethod,
|
PruningMode, TransactionPoolOptions, WasmExecutionMethod,
|
||||||
},
|
},
|
||||||
BasePath, Configuration, Role,
|
BasePath, Configuration, Role,
|
||||||
@@ -69,7 +69,7 @@ fn new_node(tokio_handle: Handle) -> node_cli::service::NewFullBase {
|
|||||||
state_cache_size: 67108864,
|
state_cache_size: 67108864,
|
||||||
state_cache_child_ratio: None,
|
state_cache_child_ratio: None,
|
||||||
state_pruning: Some(PruningMode::ArchiveAll),
|
state_pruning: Some(PruningMode::ArchiveAll),
|
||||||
keep_blocks: KeepBlocks::All,
|
blocks_pruning: BlocksPruning::All,
|
||||||
chain_spec: spec,
|
chain_spec: spec,
|
||||||
wasm_method: WasmExecutionMethod::Interpreted,
|
wasm_method: WasmExecutionMethod::Interpreted,
|
||||||
// NOTE: we enforce the use of the native runtime to make the errors more debuggable
|
// NOTE: we enforce the use of the native runtime to make the errors more debuggable
|
||||||
|
|||||||
@@ -392,7 +392,7 @@ impl BenchDb {
|
|||||||
state_cache_child_ratio: Some((0, 100)),
|
state_cache_child_ratio: Some((0, 100)),
|
||||||
state_pruning: Some(PruningMode::ArchiveAll),
|
state_pruning: Some(PruningMode::ArchiveAll),
|
||||||
source: database_type.into_settings(dir.into()),
|
source: database_type.into_settings(dir.into()),
|
||||||
keep_blocks: sc_client_db::KeepBlocks::All,
|
blocks_pruning: sc_client_db::BlocksPruning::All,
|
||||||
};
|
};
|
||||||
let task_executor = TaskExecutor::new();
|
let task_executor = TaskExecutor::new();
|
||||||
|
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ impl ChainInfoCmd {
|
|||||||
state_cache_child_ratio: config.state_cache_child_ratio.map(|v| (v, 100)),
|
state_cache_child_ratio: config.state_cache_child_ratio.map(|v| (v, 100)),
|
||||||
state_pruning: config.state_pruning.clone(),
|
state_pruning: config.state_pruning.clone(),
|
||||||
source: config.database.clone(),
|
source: config.database.clone(),
|
||||||
keep_blocks: config.keep_blocks.clone(),
|
blocks_pruning: config.blocks_pruning.clone(),
|
||||||
};
|
};
|
||||||
let backend = sc_service::new_db_backend::<B>(db_config)?;
|
let backend = sc_service::new_db_backend::<B>(db_config)?;
|
||||||
let info: ChainInfo<B> = backend.blockchain().info().into();
|
let info: ChainInfo<B> = backend.blockchain().info().into();
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ use sc_service::{
|
|||||||
NodeKeyConfig, OffchainWorkerConfig, PrometheusConfig, PruningMode, Role, RpcMethods,
|
NodeKeyConfig, OffchainWorkerConfig, PrometheusConfig, PruningMode, Role, RpcMethods,
|
||||||
TelemetryEndpoints, TransactionPoolOptions, WasmExecutionMethod,
|
TelemetryEndpoints, TransactionPoolOptions, WasmExecutionMethod,
|
||||||
},
|
},
|
||||||
ChainSpec, KeepBlocks, TracingReceiver,
|
BlocksPruning, ChainSpec, TracingReceiver,
|
||||||
};
|
};
|
||||||
use sc_tracing::logging::LoggerBuilder;
|
use sc_tracing::logging::LoggerBuilder;
|
||||||
use std::{net::SocketAddr, path::PathBuf};
|
use std::{net::SocketAddr, path::PathBuf};
|
||||||
@@ -257,11 +257,11 @@ pub trait CliConfiguration<DCV: DefaultConfigurationValues = ()>: Sized {
|
|||||||
/// Get the block pruning mode.
|
/// Get the block pruning mode.
|
||||||
///
|
///
|
||||||
/// By default this is retrieved from `block_pruning` if it is available. Otherwise its
|
/// By default this is retrieved from `block_pruning` if it is available. Otherwise its
|
||||||
/// `KeepBlocks::All`.
|
/// `BlocksPruning::All`.
|
||||||
fn keep_blocks(&self) -> Result<KeepBlocks> {
|
fn blocks_pruning(&self) -> Result<BlocksPruning> {
|
||||||
self.pruning_params()
|
self.pruning_params()
|
||||||
.map(|x| x.keep_blocks())
|
.map(|x| x.blocks_pruning())
|
||||||
.unwrap_or_else(|| Ok(KeepBlocks::All))
|
.unwrap_or_else(|| Ok(BlocksPruning::All))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the chain ID (string).
|
/// Get the chain ID (string).
|
||||||
@@ -536,7 +536,7 @@ pub trait CliConfiguration<DCV: DefaultConfigurationValues = ()>: Sized {
|
|||||||
state_cache_size: self.state_cache_size()?,
|
state_cache_size: self.state_cache_size()?,
|
||||||
state_cache_child_ratio: self.state_cache_child_ratio()?,
|
state_cache_child_ratio: self.state_cache_child_ratio()?,
|
||||||
state_pruning: self.state_pruning()?,
|
state_pruning: self.state_pruning()?,
|
||||||
keep_blocks: self.keep_blocks()?,
|
blocks_pruning: self.blocks_pruning()?,
|
||||||
wasm_method: self.wasm_method()?,
|
wasm_method: self.wasm_method()?,
|
||||||
wasm_runtime_overrides: self.wasm_runtime_overrides(),
|
wasm_runtime_overrides: self.wasm_runtime_overrides(),
|
||||||
execution_strategies: self.execution_strategies(is_dev, is_validator)?,
|
execution_strategies: self.execution_strategies(is_dev, is_validator)?,
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
use crate::error;
|
use crate::error;
|
||||||
use clap::Args;
|
use clap::Args;
|
||||||
use sc_service::{KeepBlocks, PruningMode};
|
use sc_service::{BlocksPruning, PruningMode};
|
||||||
|
|
||||||
/// Parameters to define the pruning mode
|
/// Parameters to define the pruning mode
|
||||||
#[derive(Debug, Clone, PartialEq, Args)]
|
#[derive(Debug, Clone, PartialEq, Args)]
|
||||||
@@ -28,37 +28,37 @@ pub struct PruningParams {
|
|||||||
/// Default is to keep only the last 256 blocks,
|
/// Default is to keep only the last 256 blocks,
|
||||||
/// otherwise, the state can be kept for all of the blocks (i.e 'archive'),
|
/// otherwise, the state can be kept for all of the blocks (i.e 'archive'),
|
||||||
/// or for all of the canonical blocks (i.e 'archive-canonical').
|
/// or for all of the canonical blocks (i.e 'archive-canonical').
|
||||||
#[clap(long, value_name = "PRUNING_MODE")]
|
#[clap(alias = "pruning", long, value_name = "PRUNING_MODE")]
|
||||||
pub pruning: Option<String>,
|
pub state_pruning: Option<String>,
|
||||||
/// Specify the number of finalized blocks to keep in the database.
|
/// Specify the number of finalized blocks to keep in the database.
|
||||||
///
|
///
|
||||||
/// Default is to keep all blocks.
|
/// Default is to keep all blocks.
|
||||||
///
|
///
|
||||||
/// NOTE: only finalized blocks are subject for removal!
|
/// NOTE: only finalized blocks are subject for removal!
|
||||||
#[clap(long, value_name = "COUNT")]
|
#[clap(alias = "keep-blocks", long, value_name = "COUNT")]
|
||||||
pub keep_blocks: Option<u32>,
|
pub blocks_pruning: Option<u32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PruningParams {
|
impl PruningParams {
|
||||||
/// Get the pruning value from the parameters
|
/// Get the pruning value from the parameters
|
||||||
pub fn state_pruning(&self) -> error::Result<Option<PruningMode>> {
|
pub fn state_pruning(&self) -> error::Result<Option<PruningMode>> {
|
||||||
self.pruning
|
self.state_pruning
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|s| match s.as_str() {
|
.map(|s| match s.as_str() {
|
||||||
"archive" => Ok(PruningMode::ArchiveAll),
|
"archive" => Ok(PruningMode::ArchiveAll),
|
||||||
bc => bc
|
bc => bc
|
||||||
.parse()
|
.parse()
|
||||||
.map_err(|_| error::Error::Input("Invalid pruning mode specified".to_string()))
|
.map_err(|_| error::Error::Input("Invalid pruning mode specified".to_string()))
|
||||||
.map(PruningMode::keep_blocks),
|
.map(PruningMode::blocks_pruning),
|
||||||
})
|
})
|
||||||
.transpose()
|
.transpose()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the block pruning value from the parameters
|
/// Get the block pruning value from the parameters
|
||||||
pub fn keep_blocks(&self) -> error::Result<KeepBlocks> {
|
pub fn blocks_pruning(&self) -> error::Result<BlocksPruning> {
|
||||||
Ok(match self.keep_blocks {
|
Ok(match self.blocks_pruning {
|
||||||
Some(n) => KeepBlocks::Some(n),
|
Some(n) => BlocksPruning::Some(n),
|
||||||
None => KeepBlocks::All,
|
None => BlocksPruning::All,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -300,12 +300,12 @@ pub struct DatabaseSettings {
|
|||||||
/// Block pruning mode.
|
/// Block pruning mode.
|
||||||
///
|
///
|
||||||
/// NOTE: only finalized blocks are subject for removal!
|
/// NOTE: only finalized blocks are subject for removal!
|
||||||
pub keep_blocks: KeepBlocks,
|
pub blocks_pruning: BlocksPruning,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Block pruning settings.
|
/// Block pruning settings.
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
pub enum KeepBlocks {
|
pub enum BlocksPruning {
|
||||||
/// Keep full block history.
|
/// Keep full block history.
|
||||||
All,
|
All,
|
||||||
/// Keep N recent finalized blocks.
|
/// Keep N recent finalized blocks.
|
||||||
@@ -1012,7 +1012,7 @@ pub struct Backend<Block: BlockT> {
|
|||||||
shared_cache: SharedCache<Block>,
|
shared_cache: SharedCache<Block>,
|
||||||
import_lock: Arc<RwLock<()>>,
|
import_lock: Arc<RwLock<()>>,
|
||||||
is_archive: bool,
|
is_archive: bool,
|
||||||
keep_blocks: KeepBlocks,
|
blocks_pruning: BlocksPruning,
|
||||||
io_stats: FrozenForDuration<(kvdb::IoStats, StateUsageInfo)>,
|
io_stats: FrozenForDuration<(kvdb::IoStats, StateUsageInfo)>,
|
||||||
state_usage: Arc<StateUsageStats>,
|
state_usage: Arc<StateUsageStats>,
|
||||||
genesis_state: RwLock<Option<Arc<DbGenesisStorage<Block>>>>,
|
genesis_state: RwLock<Option<Arc<DbGenesisStorage<Block>>>>,
|
||||||
@@ -1043,21 +1043,21 @@ impl<Block: BlockT> Backend<Block> {
|
|||||||
|
|
||||||
/// Create new memory-backed client backend for tests.
|
/// Create new memory-backed client backend for tests.
|
||||||
#[cfg(any(test, feature = "test-helpers"))]
|
#[cfg(any(test, feature = "test-helpers"))]
|
||||||
pub fn new_test(keep_blocks: u32, canonicalization_delay: u64) -> Self {
|
pub fn new_test(blocks_pruning: u32, canonicalization_delay: u64) -> Self {
|
||||||
Self::new_test_with_tx_storage(keep_blocks, canonicalization_delay)
|
Self::new_test_with_tx_storage(blocks_pruning, canonicalization_delay)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create new memory-backed client backend for tests.
|
/// Create new memory-backed client backend for tests.
|
||||||
#[cfg(any(test, feature = "test-helpers"))]
|
#[cfg(any(test, feature = "test-helpers"))]
|
||||||
pub fn new_test_with_tx_storage(keep_blocks: u32, canonicalization_delay: u64) -> Self {
|
pub fn new_test_with_tx_storage(blocks_pruning: u32, canonicalization_delay: u64) -> Self {
|
||||||
let db = kvdb_memorydb::create(crate::utils::NUM_COLUMNS);
|
let db = kvdb_memorydb::create(crate::utils::NUM_COLUMNS);
|
||||||
let db = sp_database::as_database(db);
|
let db = sp_database::as_database(db);
|
||||||
let db_setting = DatabaseSettings {
|
let db_setting = DatabaseSettings {
|
||||||
state_cache_size: 16777216,
|
state_cache_size: 16777216,
|
||||||
state_cache_child_ratio: Some((50, 100)),
|
state_cache_child_ratio: Some((50, 100)),
|
||||||
state_pruning: Some(PruningMode::keep_blocks(keep_blocks)),
|
state_pruning: Some(PruningMode::blocks_pruning(blocks_pruning)),
|
||||||
source: DatabaseSource::Custom { db, require_create_flag: true },
|
source: DatabaseSource::Custom { db, require_create_flag: true },
|
||||||
keep_blocks: KeepBlocks::Some(keep_blocks),
|
blocks_pruning: BlocksPruning::Some(blocks_pruning),
|
||||||
};
|
};
|
||||||
|
|
||||||
Self::new(db_setting, canonicalization_delay).expect("failed to create test-db")
|
Self::new(db_setting, canonicalization_delay).expect("failed to create test-db")
|
||||||
@@ -1124,7 +1124,7 @@ impl<Block: BlockT> Backend<Block> {
|
|||||||
is_archive: is_archive_pruning,
|
is_archive: is_archive_pruning,
|
||||||
io_stats: FrozenForDuration::new(std::time::Duration::from_secs(1)),
|
io_stats: FrozenForDuration::new(std::time::Duration::from_secs(1)),
|
||||||
state_usage: Arc::new(StateUsageStats::new()),
|
state_usage: Arc::new(StateUsageStats::new()),
|
||||||
keep_blocks: config.keep_blocks,
|
blocks_pruning: config.blocks_pruning,
|
||||||
genesis_state: RwLock::new(None),
|
genesis_state: RwLock::new(None),
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1698,9 +1698,9 @@ impl<Block: BlockT> Backend<Block> {
|
|||||||
finalized: NumberFor<Block>,
|
finalized: NumberFor<Block>,
|
||||||
displaced: &FinalizationDisplaced<Block::Hash, NumberFor<Block>>,
|
displaced: &FinalizationDisplaced<Block::Hash, NumberFor<Block>>,
|
||||||
) -> ClientResult<()> {
|
) -> ClientResult<()> {
|
||||||
if let KeepBlocks::Some(keep_blocks) = self.keep_blocks {
|
if let BlocksPruning::Some(blocks_pruning) = self.blocks_pruning {
|
||||||
// Always keep the last finalized block
|
// Always keep the last finalized block
|
||||||
let keep = std::cmp::max(keep_blocks, 1);
|
let keep = std::cmp::max(blocks_pruning, 1);
|
||||||
if finalized >= keep.into() {
|
if finalized >= keep.into() {
|
||||||
let number = finalized.saturating_sub(keep.into());
|
let number = finalized.saturating_sub(keep.into());
|
||||||
self.prune_block(transaction, BlockId::<Block>::number(number))?;
|
self.prune_block(transaction, BlockId::<Block>::number(number))?;
|
||||||
@@ -2465,9 +2465,9 @@ pub(crate) mod tests {
|
|||||||
DatabaseSettings {
|
DatabaseSettings {
|
||||||
state_cache_size: 16777216,
|
state_cache_size: 16777216,
|
||||||
state_cache_child_ratio: Some((50, 100)),
|
state_cache_child_ratio: Some((50, 100)),
|
||||||
state_pruning: Some(PruningMode::keep_blocks(1)),
|
state_pruning: Some(PruningMode::blocks_pruning(1)),
|
||||||
source: DatabaseSource::Custom { db: backing, require_create_flag: false },
|
source: DatabaseSource::Custom { db: backing, require_create_flag: false },
|
||||||
keep_blocks: KeepBlocks::All,
|
blocks_pruning: BlocksPruning::All,
|
||||||
},
|
},
|
||||||
0,
|
0,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -676,7 +676,7 @@ pub struct FullPeerConfig {
|
|||||||
/// Pruning window size.
|
/// Pruning window size.
|
||||||
///
|
///
|
||||||
/// NOTE: only finalized blocks are subject for removal!
|
/// NOTE: only finalized blocks are subject for removal!
|
||||||
pub keep_blocks: Option<u32>,
|
pub blocks_pruning: Option<u32>,
|
||||||
/// Block announce validator.
|
/// Block announce validator.
|
||||||
pub block_announce_validator: Option<Box<dyn BlockAnnounceValidator<Block> + Send + Sync>>,
|
pub block_announce_validator: Option<Box<dyn BlockAnnounceValidator<Block> + Send + Sync>>,
|
||||||
/// List of notification protocols that the network must support.
|
/// List of notification protocols that the network must support.
|
||||||
@@ -742,10 +742,10 @@ where
|
|||||||
|
|
||||||
/// Add a full peer.
|
/// Add a full peer.
|
||||||
fn add_full_peer_with_config(&mut self, config: FullPeerConfig) {
|
fn add_full_peer_with_config(&mut self, config: FullPeerConfig) {
|
||||||
let mut test_client_builder = match (config.keep_blocks, config.storage_chain) {
|
let mut test_client_builder = match (config.blocks_pruning, config.storage_chain) {
|
||||||
(Some(keep_blocks), true) => TestClientBuilder::with_tx_storage(keep_blocks),
|
(Some(blocks_pruning), true) => TestClientBuilder::with_tx_storage(blocks_pruning),
|
||||||
(None, true) => TestClientBuilder::with_tx_storage(u32::MAX),
|
(None, true) => TestClientBuilder::with_tx_storage(u32::MAX),
|
||||||
(Some(keep_blocks), false) => TestClientBuilder::with_pruning_window(keep_blocks),
|
(Some(blocks_pruning), false) => TestClientBuilder::with_pruning_window(blocks_pruning),
|
||||||
(None, false) => TestClientBuilder::with_default_backend(),
|
(None, false) => TestClientBuilder::with_default_backend(),
|
||||||
};
|
};
|
||||||
if let Some(storage) = config.extra_storage {
|
if let Some(storage) = config.extra_storage {
|
||||||
|
|||||||
@@ -544,7 +544,7 @@ fn syncs_header_only_forks() {
|
|||||||
sp_tracing::try_init_simple();
|
sp_tracing::try_init_simple();
|
||||||
let mut net = TestNet::new(0);
|
let mut net = TestNet::new(0);
|
||||||
net.add_full_peer_with_config(Default::default());
|
net.add_full_peer_with_config(Default::default());
|
||||||
net.add_full_peer_with_config(FullPeerConfig { keep_blocks: Some(3), ..Default::default() });
|
net.add_full_peer_with_config(FullPeerConfig { blocks_pruning: Some(3), ..Default::default() });
|
||||||
net.peer(0).push_blocks(2, false);
|
net.peer(0).push_blocks(2, false);
|
||||||
net.peer(1).push_blocks(2, false);
|
net.peer(1).push_blocks(2, false);
|
||||||
|
|
||||||
|
|||||||
@@ -207,7 +207,7 @@ where
|
|||||||
state_cache_child_ratio: config.state_cache_child_ratio.map(|v| (v, 100)),
|
state_cache_child_ratio: config.state_cache_child_ratio.map(|v| (v, 100)),
|
||||||
state_pruning: config.state_pruning.clone(),
|
state_pruning: config.state_pruning.clone(),
|
||||||
source: config.database.clone(),
|
source: config.database.clone(),
|
||||||
keep_blocks: config.keep_blocks,
|
blocks_pruning: config.blocks_pruning,
|
||||||
};
|
};
|
||||||
|
|
||||||
let backend = new_db_backend(db_config)?;
|
let backend = new_db_backend(db_config)?;
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
//! Service configuration.
|
//! Service configuration.
|
||||||
|
|
||||||
pub use sc_client_api::execution_extensions::{ExecutionStrategies, ExecutionStrategy};
|
pub use sc_client_api::execution_extensions::{ExecutionStrategies, ExecutionStrategy};
|
||||||
pub use sc_client_db::{Database, DatabaseSource, KeepBlocks, PruningMode};
|
pub use sc_client_db::{BlocksPruning, Database, DatabaseSource, PruningMode};
|
||||||
pub use sc_executor::WasmExecutionMethod;
|
pub use sc_executor::WasmExecutionMethod;
|
||||||
#[cfg(feature = "wasmtime")]
|
#[cfg(feature = "wasmtime")]
|
||||||
pub use sc_executor::WasmtimeInstantiationStrategy;
|
pub use sc_executor::WasmtimeInstantiationStrategy;
|
||||||
@@ -79,7 +79,7 @@ pub struct Configuration {
|
|||||||
/// Number of blocks to keep in the db.
|
/// Number of blocks to keep in the db.
|
||||||
///
|
///
|
||||||
/// NOTE: only finalized blocks are subject for removal!
|
/// NOTE: only finalized blocks are subject for removal!
|
||||||
pub keep_blocks: KeepBlocks,
|
pub blocks_pruning: BlocksPruning,
|
||||||
/// Chain configuration.
|
/// Chain configuration.
|
||||||
pub chain_spec: Box<dyn ChainSpec>,
|
pub chain_spec: Box<dyn ChainSpec>,
|
||||||
/// Wasm execution method.
|
/// Wasm execution method.
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ pub use self::{
|
|||||||
error::Error,
|
error::Error,
|
||||||
};
|
};
|
||||||
pub use config::{
|
pub use config::{
|
||||||
BasePath, Configuration, DatabaseSource, KeepBlocks, PruningMode, Role, RpcMethods, TaskType,
|
BasePath, BlocksPruning, Configuration, DatabaseSource, PruningMode, Role, RpcMethods, TaskType,
|
||||||
};
|
};
|
||||||
pub use sc_chain_spec::{
|
pub use sc_chain_spec::{
|
||||||
ChainSpec, ChainType, Extension as ChainSpecExtension, GenericChainSpec, NoExtension,
|
ChainSpec, ChainType, Extension as ChainSpecExtension, GenericChainSpec, NoExtension,
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ use sc_block_builder::BlockBuilderProvider;
|
|||||||
use sc_client_api::{
|
use sc_client_api::{
|
||||||
in_mem, BlockBackend, BlockchainEvents, FinalityNotifications, StorageProvider,
|
in_mem, BlockBackend, BlockchainEvents, FinalityNotifications, StorageProvider,
|
||||||
};
|
};
|
||||||
use sc_client_db::{Backend, DatabaseSettings, DatabaseSource, KeepBlocks, PruningMode};
|
use sc_client_db::{Backend, BlocksPruning, DatabaseSettings, DatabaseSource, PruningMode};
|
||||||
use sc_consensus::{
|
use sc_consensus::{
|
||||||
BlockCheckParams, BlockImport, BlockImportParams, ForkChoiceStrategy, ImportResult,
|
BlockCheckParams, BlockImport, BlockImportParams, ForkChoiceStrategy, ImportResult,
|
||||||
};
|
};
|
||||||
@@ -1200,7 +1200,7 @@ fn doesnt_import_blocks_that_revert_finality() {
|
|||||||
state_cache_size: 1 << 20,
|
state_cache_size: 1 << 20,
|
||||||
state_cache_child_ratio: None,
|
state_cache_child_ratio: None,
|
||||||
state_pruning: Some(PruningMode::ArchiveAll),
|
state_pruning: Some(PruningMode::ArchiveAll),
|
||||||
keep_blocks: KeepBlocks::All,
|
blocks_pruning: BlocksPruning::All,
|
||||||
source: DatabaseSource::RocksDb { path: tmp.path().into(), cache_size: 1024 },
|
source: DatabaseSource::RocksDb { path: tmp.path().into(), cache_size: 1024 },
|
||||||
},
|
},
|
||||||
u64::MAX,
|
u64::MAX,
|
||||||
@@ -1426,8 +1426,8 @@ fn returns_status_for_pruned_blocks() {
|
|||||||
DatabaseSettings {
|
DatabaseSettings {
|
||||||
state_cache_size: 1 << 20,
|
state_cache_size: 1 << 20,
|
||||||
state_cache_child_ratio: None,
|
state_cache_child_ratio: None,
|
||||||
state_pruning: Some(PruningMode::keep_blocks(1)),
|
state_pruning: Some(PruningMode::blocks_pruning(1)),
|
||||||
keep_blocks: KeepBlocks::All,
|
blocks_pruning: BlocksPruning::All,
|
||||||
source: DatabaseSource::RocksDb { path: tmp.path().into(), cache_size: 1024 },
|
source: DatabaseSource::RocksDb { path: tmp.path().into(), cache_size: 1024 },
|
||||||
},
|
},
|
||||||
u64::MAX,
|
u64::MAX,
|
||||||
|
|||||||
@@ -29,8 +29,8 @@ use sc_network::{
|
|||||||
use sc_service::{
|
use sc_service::{
|
||||||
client::Client,
|
client::Client,
|
||||||
config::{BasePath, DatabaseSource, KeystoreConfig},
|
config::{BasePath, DatabaseSource, KeystoreConfig},
|
||||||
ChainSpecExtension, Configuration, Error, GenericChainSpec, KeepBlocks, Role, RuntimeGenesis,
|
BlocksPruning, ChainSpecExtension, Configuration, Error, GenericChainSpec, Role,
|
||||||
SpawnTaskHandle, TaskManager,
|
RuntimeGenesis, SpawnTaskHandle, TaskManager,
|
||||||
};
|
};
|
||||||
use sc_transaction_pool_api::TransactionPool;
|
use sc_transaction_pool_api::TransactionPool;
|
||||||
use sp_api::BlockId;
|
use sp_api::BlockId;
|
||||||
@@ -234,7 +234,7 @@ fn node_config<
|
|||||||
state_cache_size: 16777216,
|
state_cache_size: 16777216,
|
||||||
state_cache_child_ratio: None,
|
state_cache_child_ratio: None,
|
||||||
state_pruning: Default::default(),
|
state_pruning: Default::default(),
|
||||||
keep_blocks: KeepBlocks::All,
|
blocks_pruning: BlocksPruning::All,
|
||||||
chain_spec: Box::new((*spec).clone()),
|
chain_spec: Box::new((*spec).clone()),
|
||||||
wasm_method: sc_service::config::WasmExecutionMethod::Interpreted,
|
wasm_method: sc_service::config::WasmExecutionMethod::Interpreted,
|
||||||
wasm_runtime_overrides: Default::default(),
|
wasm_runtime_overrides: Default::default(),
|
||||||
|
|||||||
@@ -227,7 +227,7 @@ pub enum PruningMode {
|
|||||||
|
|
||||||
impl PruningMode {
|
impl PruningMode {
|
||||||
/// Create a mode that keeps given number of blocks.
|
/// Create a mode that keeps given number of blocks.
|
||||||
pub fn keep_blocks(n: u32) -> PruningMode {
|
pub fn blocks_pruning(n: u32) -> PruningMode {
|
||||||
PruningMode::Constrained(Constraints { max_blocks: Some(n), max_mem: None })
|
PruningMode::Constrained(Constraints { max_blocks: Some(n), max_mem: None })
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -835,34 +835,34 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn pruning_mode_compatibility() {
|
fn pruning_mode_compatibility() {
|
||||||
for (created, reopened, expected) in [
|
for (created, reopened, expected) in [
|
||||||
(None, None, Ok(PruningMode::keep_blocks(256))),
|
(None, None, Ok(PruningMode::blocks_pruning(256))),
|
||||||
(None, Some(PruningMode::keep_blocks(256)), Ok(PruningMode::keep_blocks(256))),
|
(None, Some(PruningMode::blocks_pruning(256)), Ok(PruningMode::blocks_pruning(256))),
|
||||||
(None, Some(PruningMode::keep_blocks(128)), Ok(PruningMode::keep_blocks(128))),
|
(None, Some(PruningMode::blocks_pruning(128)), Ok(PruningMode::blocks_pruning(128))),
|
||||||
(None, Some(PruningMode::keep_blocks(512)), Ok(PruningMode::keep_blocks(512))),
|
(None, Some(PruningMode::blocks_pruning(512)), Ok(PruningMode::blocks_pruning(512))),
|
||||||
(None, Some(PruningMode::ArchiveAll), Err(())),
|
(None, Some(PruningMode::ArchiveAll), Err(())),
|
||||||
(None, Some(PruningMode::ArchiveCanonical), Err(())),
|
(None, Some(PruningMode::ArchiveCanonical), Err(())),
|
||||||
(Some(PruningMode::keep_blocks(256)), None, Ok(PruningMode::keep_blocks(256))),
|
(Some(PruningMode::blocks_pruning(256)), None, Ok(PruningMode::blocks_pruning(256))),
|
||||||
(
|
(
|
||||||
Some(PruningMode::keep_blocks(256)),
|
Some(PruningMode::blocks_pruning(256)),
|
||||||
Some(PruningMode::keep_blocks(256)),
|
Some(PruningMode::blocks_pruning(256)),
|
||||||
Ok(PruningMode::keep_blocks(256)),
|
Ok(PruningMode::blocks_pruning(256)),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
Some(PruningMode::keep_blocks(256)),
|
Some(PruningMode::blocks_pruning(256)),
|
||||||
Some(PruningMode::keep_blocks(128)),
|
Some(PruningMode::blocks_pruning(128)),
|
||||||
Ok(PruningMode::keep_blocks(128)),
|
Ok(PruningMode::blocks_pruning(128)),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
Some(PruningMode::keep_blocks(256)),
|
Some(PruningMode::blocks_pruning(256)),
|
||||||
Some(PruningMode::keep_blocks(512)),
|
Some(PruningMode::blocks_pruning(512)),
|
||||||
Ok(PruningMode::keep_blocks(512)),
|
Ok(PruningMode::blocks_pruning(512)),
|
||||||
),
|
),
|
||||||
(Some(PruningMode::keep_blocks(256)), Some(PruningMode::ArchiveAll), Err(())),
|
(Some(PruningMode::blocks_pruning(256)), Some(PruningMode::ArchiveAll), Err(())),
|
||||||
(Some(PruningMode::keep_blocks(256)), Some(PruningMode::ArchiveCanonical), Err(())),
|
(Some(PruningMode::blocks_pruning(256)), Some(PruningMode::ArchiveCanonical), Err(())),
|
||||||
(Some(PruningMode::ArchiveAll), None, Ok(PruningMode::ArchiveAll)),
|
(Some(PruningMode::ArchiveAll), None, Ok(PruningMode::ArchiveAll)),
|
||||||
(Some(PruningMode::ArchiveAll), Some(PruningMode::keep_blocks(256)), Err(())),
|
(Some(PruningMode::ArchiveAll), Some(PruningMode::blocks_pruning(256)), Err(())),
|
||||||
(Some(PruningMode::ArchiveAll), Some(PruningMode::keep_blocks(128)), Err(())),
|
(Some(PruningMode::ArchiveAll), Some(PruningMode::blocks_pruning(128)), Err(())),
|
||||||
(Some(PruningMode::ArchiveAll), Some(PruningMode::keep_blocks(512)), Err(())),
|
(Some(PruningMode::ArchiveAll), Some(PruningMode::blocks_pruning(512)), Err(())),
|
||||||
(
|
(
|
||||||
Some(PruningMode::ArchiveAll),
|
Some(PruningMode::ArchiveAll),
|
||||||
Some(PruningMode::ArchiveAll),
|
Some(PruningMode::ArchiveAll),
|
||||||
@@ -870,9 +870,9 @@ mod tests {
|
|||||||
),
|
),
|
||||||
(Some(PruningMode::ArchiveAll), Some(PruningMode::ArchiveCanonical), Err(())),
|
(Some(PruningMode::ArchiveAll), Some(PruningMode::ArchiveCanonical), Err(())),
|
||||||
(Some(PruningMode::ArchiveCanonical), None, Ok(PruningMode::ArchiveCanonical)),
|
(Some(PruningMode::ArchiveCanonical), None, Ok(PruningMode::ArchiveCanonical)),
|
||||||
(Some(PruningMode::ArchiveCanonical), Some(PruningMode::keep_blocks(256)), Err(())),
|
(Some(PruningMode::ArchiveCanonical), Some(PruningMode::blocks_pruning(256)), Err(())),
|
||||||
(Some(PruningMode::ArchiveCanonical), Some(PruningMode::keep_blocks(128)), Err(())),
|
(Some(PruningMode::ArchiveCanonical), Some(PruningMode::blocks_pruning(128)), Err(())),
|
||||||
(Some(PruningMode::ArchiveCanonical), Some(PruningMode::keep_blocks(512)), Err(())),
|
(Some(PruningMode::ArchiveCanonical), Some(PruningMode::blocks_pruning(512)), Err(())),
|
||||||
(Some(PruningMode::ArchiveCanonical), Some(PruningMode::ArchiveAll), Err(())),
|
(Some(PruningMode::ArchiveCanonical), Some(PruningMode::ArchiveAll), Err(())),
|
||||||
(
|
(
|
||||||
Some(PruningMode::ArchiveCanonical),
|
Some(PruningMode::ArchiveCanonical),
|
||||||
|
|||||||
@@ -95,14 +95,14 @@ impl<Block: BlockT, ExecutorDispatch, G: GenesisInit>
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Create new `TestClientBuilder` with default backend and pruning window size
|
/// Create new `TestClientBuilder` with default backend and pruning window size
|
||||||
pub fn with_pruning_window(keep_blocks: u32) -> Self {
|
pub fn with_pruning_window(blocks_pruning: u32) -> Self {
|
||||||
let backend = Arc::new(Backend::new_test(keep_blocks, 0));
|
let backend = Arc::new(Backend::new_test(blocks_pruning, 0));
|
||||||
Self::with_backend(backend)
|
Self::with_backend(backend)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create new `TestClientBuilder` with default backend and storage chain mode
|
/// Create new `TestClientBuilder` with default backend and storage chain mode
|
||||||
pub fn with_tx_storage(keep_blocks: u32) -> Self {
|
pub fn with_tx_storage(blocks_pruning: u32) -> Self {
|
||||||
let backend = Arc::new(Backend::new_test_with_tx_storage(keep_blocks, 0));
|
let backend = Arc::new(Backend::new_test_with_tx_storage(blocks_pruning, 0));
|
||||||
Self::with_backend(backend)
|
Self::with_backend(backend)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user