Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Merge branch 'master' into child_trie_w3_change
Browse files Browse the repository at this point in the history
  • Loading branch information
cheme committed Apr 15, 2020
2 parents 83ff4a0 + 88248c0 commit ecb1c39
Show file tree
Hide file tree
Showing 43 changed files with 1,036 additions and 579 deletions.
97 changes: 97 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ members = [
"primitives/consensus/vrf",
"primitives/core",
"primitives/chain-spec",
"primitives/database",
"primitives/debug-derive",
"primitives/storage",
"primitives/externalities",
Expand Down
2 changes: 1 addition & 1 deletion bin/node/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ cli = [
"node-transaction-factory",
"sc-cli",
"frame-benchmarking-cli",
"sc-service/rocksdb",
"sc-service/db",
"structopt",
"substrate-build-script-utils",
]
Expand Down
4 changes: 2 additions & 2 deletions bin/node/testing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
pallet-balances = { version = "2.0.0-dev", path = "../../../frame/balances" }
sc-client = { version = "0.8.0-dev", path = "../../../client/" }
sc-client-db = { version = "0.8.0-dev", path = "../../../client/db/", features = ["kvdb-rocksdb"] }
sc-client-db = { version = "0.8.0-dev", path = "../../../client/db/", features = ["kvdb-rocksdb", "parity-db"] }
sc-client-api = { version = "2.0.0-dev", path = "../../../client/api/" }
codec = { package = "parity-scale-codec", version = "1.3.0" }
pallet-contracts = { version = "2.0.0-dev", path = "../../../frame/contracts" }
Expand Down Expand Up @@ -54,4 +54,4 @@ fs_extra = "1"
[dev-dependencies]
criterion = "0.3.0"
sc-cli = { version = "0.8.0-dev", path = "../../../client/cli" }
sc-service = { version = "0.8.0-dev", path = "../../../client/service", features = ["rocksdb"] }
sc-service = { version = "0.8.0-dev", path = "../../../client/service", features = ["db"] }
2 changes: 1 addition & 1 deletion bin/node/testing/src/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ impl BenchDb {
state_cache_size: 16*1024*1024,
state_cache_child_ratio: Some((0, 100)),
pruning: PruningMode::ArchiveAll,
source: sc_client_db::DatabaseSettingsSrc::Path {
source: sc_client_db::DatabaseSettingsSrc::RocksDb {
path: dir.into(),
cache_size: 512,
},
Expand Down
1 change: 1 addition & 0 deletions client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ sp-blockchain = { version = "2.0.0-dev", path = "../primitives/blockchain" }
sp-state-machine = { version = "0.8.0-dev", path = "../primitives/state-machine" }
sc-telemetry = { version = "2.0.0-dev", path = "telemetry" }
sp-trie = { version = "2.0.0-dev", path = "../primitives/trie" }
sp-database = { version = "2.0.0-dev", path = "../primitives/database" }
prometheus-endpoint = { package = "substrate-prometheus-endpoint", version = "0.8.0-dev", path = "../utils/prometheus" }
tracing = "0.1.10"

Expand Down
14 changes: 14 additions & 0 deletions client/cli/src/arg_enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,20 @@ impl ExecutionStrategy {
}
}

arg_enum! {
/// Database backend
#[allow(missing_docs)]
#[derive(Debug, Clone, Copy)]
pub enum Database {
// Facebooks RocksDB
RocksDb,
// Subdb. https://github.com/paritytech/subdb/
SubDb,
// ParityDb. https://github.com/paritytech/parity-db/
ParityDb,
}
}

/// Default value for the `--execution-syncing` parameter.
pub const DEFAULT_EXECUTION_SYNCING: ExecutionStrategy = ExecutionStrategy::NativeElseWasm;
/// Default value for the `--execution-import-block` parameter.
Expand Down
2 changes: 1 addition & 1 deletion client/cli/src/commands/export_blocks_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl ExportBlocksCmd {
<<<BB as BlockT>::Header as HeaderT>::Number as std::str::FromStr>::Err: std::fmt::Debug,
<BB as BlockT>::Hash: std::str::FromStr,
{
if let DatabaseConfig::Path { ref path, .. } = &config.database {
if let DatabaseConfig::RocksDb { ref path, .. } = &config.database {
info!("DB path: {}", path.display());
}

Expand Down
9 changes: 8 additions & 1 deletion client/cli/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,16 @@ macro_rules! substrate_cli_subcommands {
&self,
base_path: &::std::path::PathBuf,
cache_size: usize,
database: $crate::Database,
) -> $crate::Result<::sc_service::config::DatabaseConfig> {
match self {
$($enum::$variant(cmd) => cmd.database_config(base_path, cache_size)),*
$($enum::$variant(cmd) => cmd.database_config(base_path, cache_size, database)),*
}
}

fn database(&self) -> $crate::Result<::std::option::Option<$crate::Database>> {
match self {
$($enum::$variant(cmd) => cmd.database()),*
}
}

Expand Down
2 changes: 1 addition & 1 deletion client/cli/src/commands/purge_chain_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ impl PurgeChainCmd {
/// Run the purge command
pub fn run(&self, config: Configuration) -> error::Result<()> {
let db_path = match &config.database {
DatabaseConfig::Path { path, .. } => path,
DatabaseConfig::RocksDb { path, .. } => path,
_ => {
eprintln!("Cannot purge custom database implementation");
return Ok(());
Expand Down
23 changes: 20 additions & 3 deletions client/cli/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use crate::{
init_logger, ImportParams, KeystoreParams, NetworkParams, NodeKeyParams,
PruningParams, SharedParams, SubstrateCli,
};
use crate::arg_enums::Database;
use app_dirs::{AppDataType, AppInfo};
use names::{Generator, Name};
use sc_service::config::{
Expand Down Expand Up @@ -152,11 +153,26 @@ pub trait CliConfiguration: Sized {
.unwrap_or(Default::default()))
}

/// Get the database backend variant.
///
/// By default this is retrieved from `ImportParams` if it is available. Otherwise its `None`.
fn database(&self) -> Result<Option<Database>> {
Ok(self.import_params().map(|x| x.database()))
}

/// Get the database configuration.
///
/// By default this is retrieved from `SharedParams`
fn database_config(&self, base_path: &PathBuf, cache_size: usize) -> Result<DatabaseConfig> {
Ok(self.shared_params().database_config(base_path, cache_size))
fn database_config(&self,
base_path: &PathBuf,
cache_size: usize,
database: Database,
) -> Result<DatabaseConfig> {
Ok(self.shared_params().database_config(
base_path,
cache_size,
database,
))
}

/// Get the state cache size.
Expand Down Expand Up @@ -376,6 +392,7 @@ pub trait CliConfiguration: Sized {
let net_config_dir = config_dir.join(DEFAULT_NETWORK_CONFIG_PATH);
let client_id = C::client_id();
let database_cache_size = self.database_cache_size()?.unwrap_or(128);
let database = self.database()?.unwrap_or(Database::RocksDb);
let node_key = self.node_key(&net_config_dir)?;
let role = self.role(is_dev)?;
let max_runtime_instances = self.max_runtime_instances()?.unwrap_or(8);
Expand All @@ -394,7 +411,7 @@ pub trait CliConfiguration: Sized {
node_key,
)?,
keystore: self.keystore_config(&config_dir)?,
database: self.database_config(&config_dir, database_cache_size)?,
database: self.database_config(&config_dir, database_cache_size, database)?,
state_cache_size: self.state_cache_size()?,
state_cache_child_ratio: self.state_cache_child_ratio()?,
pruning: self.pruning(is_dev, &role)?,
Expand Down
17 changes: 16 additions & 1 deletion client/cli/src/params/import_params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use crate::arg_enums::{
ExecutionStrategy, TracingReceiver, WasmExecutionMethod, DEFAULT_EXECUTION_BLOCK_CONSTRUCTION,
DEFAULT_EXECUTION_IMPORT_BLOCK, DEFAULT_EXECUTION_OFFCHAIN_WORKER, DEFAULT_EXECUTION_OTHER,
DEFAULT_EXECUTION_SYNCING,
DEFAULT_EXECUTION_SYNCING, Database,
};
use crate::params::PruningParams;
use crate::Result;
Expand Down Expand Up @@ -54,6 +54,16 @@ pub struct ImportParams {
#[structopt(flatten)]
pub execution_strategies: ExecutionStrategiesParams,

/// Select database backend to use.
#[structopt(
long = "database",
alias = "db",
value_name = "DB",
case_insensitive = true,
default_value = "RocksDb"
)]
pub database: Database,

/// Limit the memory the database cache can use.
#[structopt(long = "db-cache", value_name = "MiB")]
pub database_cache_size: Option<usize>,
Expand Down Expand Up @@ -132,6 +142,11 @@ impl ImportParams {
pub fn database_cache_size(&self) -> Option<usize> {
self.database_cache_size
}

/// Limit the memory the database cache can use.
pub fn database(&self) -> Database {
self.database
}
}

/// Execution strategies parameters.
Expand Down
Loading

0 comments on commit ecb1c39

Please sign in to comment.