diff --git a/polkadot/cli/Cargo.toml b/polkadot/cli/Cargo.toml index e49d8446ba..d956a0290b 100644 --- a/polkadot/cli/Cargo.toml +++ b/polkadot/cli/Cargo.toml @@ -21,6 +21,7 @@ app_dirs = "1.2" tokio-core = "0.1.12" futures = "0.1.17" ctrlc = { git = "https://github.com/paritytech/rust-ctrlc.git" } +fdlimit = "0.1" substrate-client = { path = "../../substrate/client" } substrate-network = { path = "../../substrate/network" } substrate-codec = { path = "../../substrate/codec" } diff --git a/polkadot/cli/src/lib.rs b/polkadot/cli/src/lib.rs index b3f62fb65b..d10fdfd32b 100644 --- a/polkadot/cli/src/lib.rs +++ b/polkadot/cli/src/lib.rs @@ -27,6 +27,7 @@ extern crate time; extern crate futures; extern crate tokio_core; extern crate ctrlc; +extern crate fdlimit; extern crate ed25519; extern crate triehash; extern crate substrate_codec as codec; @@ -98,6 +99,7 @@ pub fn run(args: I) -> error::Result<()> where // TODO [ToDr] Split parameters parsing from actual execution. let log_pattern = matches.value_of("log").unwrap_or(""); init_logger(log_pattern); + fdlimit::raise_fd_limit(); let mut config = service::Configuration::default(); @@ -111,6 +113,8 @@ pub fn run(args: I) -> error::Result<()> where .to_string_lossy() .into(); + config.database_path = db_path(&base_path).to_string_lossy().into(); + let mut role = service::Role::FULL; if matches.is_present("collator") { info!("Starting collator."); @@ -204,6 +208,12 @@ fn keystore_path(base_path: &Path) -> PathBuf { path } +fn db_path(base_path: &Path) -> PathBuf { + let mut path = base_path.to_owned(); + path.push("db"); + path +} + fn network_path(base_path: &Path) -> PathBuf { let mut path = base_path.to_owned(); path.push("network"); diff --git a/polkadot/keystore/Cargo.toml b/polkadot/keystore/Cargo.toml index 16ec981769..92026c9c8d 100644 --- a/polkadot/keystore/Cargo.toml +++ b/polkadot/keystore/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" authors = ["Parity Technologies "] [dependencies] -ethcrypto = { git = "https://github.com/paritytech/parity", default_features = false } +ethcore-crypto = { git = "https://github.com/paritytech/parity", default_features = false } ed25519 = { path = "../../substrate/ed25519" } error-chain = "0.11" hex = "0.3" diff --git a/polkadot/keystore/src/lib.rs b/polkadot/keystore/src/lib.rs index d91d986e56..62268edf6e 100644 --- a/polkadot/keystore/src/lib.rs +++ b/polkadot/keystore/src/lib.rs @@ -16,7 +16,7 @@ //! Keystore (and session key management) for polkadot. -extern crate ethcrypto as crypto; +extern crate ethcore_crypto as crypto; extern crate subtle; extern crate ed25519; extern crate rand; diff --git a/polkadot/runtime/wasm/target/wasm32-unknown-unknown/release/polkadot_runtime.compact.wasm b/polkadot/runtime/wasm/target/wasm32-unknown-unknown/release/polkadot_runtime.compact.wasm index 1d1a95c6ce..e81d2066e6 100644 Binary files a/polkadot/runtime/wasm/target/wasm32-unknown-unknown/release/polkadot_runtime.compact.wasm and b/polkadot/runtime/wasm/target/wasm32-unknown-unknown/release/polkadot_runtime.compact.wasm differ diff --git a/polkadot/runtime/wasm/target/wasm32-unknown-unknown/release/polkadot_runtime.wasm b/polkadot/runtime/wasm/target/wasm32-unknown-unknown/release/polkadot_runtime.wasm index e0991b6397..7e31a2dea6 100755 Binary files a/polkadot/runtime/wasm/target/wasm32-unknown-unknown/release/polkadot_runtime.wasm and b/polkadot/runtime/wasm/target/wasm32-unknown-unknown/release/polkadot_runtime.wasm differ diff --git a/polkadot/service/Cargo.toml b/polkadot/service/Cargo.toml index d88c069470..469dc2e201 100644 --- a/polkadot/service/Cargo.toml +++ b/polkadot/service/Cargo.toml @@ -24,5 +24,6 @@ substrate-runtime-io = { path = "../../substrate/runtime-io" } substrate-primitives = { path = "../../substrate/primitives" } substrate-network = { path = "../../substrate/network" } substrate-client = { path = "../../substrate/client" } +substrate-client-db = { path = "../../substrate/client/db" } substrate-codec = { path = "../../substrate/codec" } substrate-executor = { path = "../../substrate/executor" } diff --git a/polkadot/service/src/config.rs b/polkadot/service/src/config.rs index ed1b86daf4..d4cacf37b9 100644 --- a/polkadot/service/src/config.rs +++ b/polkadot/service/src/config.rs @@ -39,6 +39,8 @@ pub struct Configuration { pub network: NetworkConfiguration, /// Path to key files. pub keystore_path: String, + /// Path to the database. + pub database_path: String, /// Additional key seeds. pub keys: Vec, /// Chain specification. @@ -52,6 +54,7 @@ impl Default for Configuration { transaction_pool: Default::default(), network: Default::default(), keystore_path: Default::default(), + database_path: Default::default(), keys: Default::default(), chain_spec: ChainSpec::Development, } diff --git a/polkadot/service/src/lib.rs b/polkadot/service/src/lib.rs index d21415f7d0..7d770b67d3 100644 --- a/polkadot/service/src/lib.rs +++ b/polkadot/service/src/lib.rs @@ -33,6 +33,7 @@ extern crate substrate_runtime_io as runtime_io; extern crate substrate_primitives as primitives; extern crate substrate_network as network; extern crate substrate_codec as codec; +extern crate substrate_client_db as client_db; extern crate substrate_executor; extern crate exit_future; @@ -64,14 +65,13 @@ use polkadot_api::PolkadotApi; use polkadot_runtime::{GenesisConfig, ConsensusConfig, CouncilConfig, DemocracyConfig, SessionConfig, StakingConfig, BuildExternalities}; use client::{genesis, BlockchainEvents}; -use client::in_mem::Backend as InMemory; use network::ManageNetwork; use exit_future::Signal; pub use self::error::{ErrorKind, Error}; pub use config::{Configuration, Role, ChainSpec}; -type Client = client::Client>; +type Client = client::Client>; /// Polkadot service. pub struct Service { @@ -275,7 +275,12 @@ impl Service { (primitives::block::Header::decode(&mut block.header.encode().as_ref()).expect("to_vec() always gives a valid serialisation; qed"), storage.into_iter().collect()) }; - let client = Arc::new(client::new_in_mem(executor, prepare_genesis)?); + let db_settings = client_db::DatabaseSettings { + cache_size: None, + path: config.database_path.into(), + }; + + let client = Arc::new(client_db::new_client(db_settings, executor, prepare_genesis)?); let best_header = client.best_block_header()?; info!("Starting Polkadot. Best block is #{}", best_header.number); let transaction_pool = Arc::new(Mutex::new(TransactionPool::new(config.transaction_pool)));