diff --git a/substrate/core/basic-authorship/Cargo.toml b/substrate/core/basic-authorship/Cargo.toml index 0c09c84e78..497f6150be 100644 --- a/substrate/core/basic-authorship/Cargo.toml +++ b/substrate/core/basic-authorship/Cargo.toml @@ -2,14 +2,15 @@ name = "substrate-basic-authorship" version = "0.1.0" authors = ["Parity Technologies "] +edition = "2018" [dependencies] log = "0.4" -parity-codec = "2.2" -sr-primitives = { path = "../sr-primitives" } -substrate-client = { path = "../client" } -substrate-consensus-aura-primitives = { path = "../consensus/aura/primitives" } -substrate-consensus-common = { path = "../consensus/common" } -substrate-primitives = { path = "../primitives" } -substrate-inherents = { path = "../inherents" } -substrate-transaction-pool = { path = "../transaction-pool" } +codec = { package = "parity-codec", version = "2.2" } +runtime_primitives = { package = "sr-primitives", path = "../../core/sr-primitives" } +client = { package = "substrate-client", path = "../../core/client" } +aura_primitives = { package = "substrate-consensus-aura-primitives", path = "../../core/consensus/aura/primitives" } +consensus_common = { package = "substrate-consensus-common", path = "../../core/consensus/common" } +primitives = { package = "substrate-primitives", path = "../../core/primitives" } +inherents = { package = "substrate-inherents", path = "../inherents" } +transaction_pool = { package = "substrate-transaction-pool", path = "../../core/transaction-pool" } diff --git a/substrate/core/basic-authorship/src/basic_authorship.rs b/substrate/core/basic-authorship/src/basic_authorship.rs index a666d48ba4..e5cdbeb7dc 100644 --- a/substrate/core/basic-authorship/src/basic_authorship.rs +++ b/substrate/core/basic-authorship/src/basic_authorship.rs @@ -20,6 +20,8 @@ use std::{sync::Arc, self}; +use log::{info, trace}; + use client::{ self, error, Client as SubstrateClient, CallExecutor, block_builder::api::BlockBuilder as BlockBuilderApi, runtime_api::{Core, ApiExt} diff --git a/substrate/core/basic-authorship/src/lib.rs b/substrate/core/basic-authorship/src/lib.rs index aafb2d0535..a4f6afb8f8 100644 --- a/substrate/core/basic-authorship/src/lib.rs +++ b/substrate/core/basic-authorship/src/lib.rs @@ -18,17 +18,6 @@ #![warn(unused_extern_crates)] -extern crate substrate_primitives as primitives; -extern crate sr_primitives as runtime_primitives; -extern crate substrate_consensus_common as consensus_common; -extern crate substrate_client as client; -extern crate parity_codec as codec; -extern crate substrate_transaction_pool as transaction_pool; -extern crate substrate_inherents as inherents; - -#[macro_use] -extern crate log; - mod basic_authorship; -pub use basic_authorship::{ProposerFactory, BlockBuilder, AuthoringApi, Proposer}; +pub use crate::basic_authorship::{ProposerFactory, BlockBuilder, AuthoringApi, Proposer}; diff --git a/substrate/core/cli/Cargo.toml b/substrate/core/cli/Cargo.toml index 88db4d87c0..0be724a83d 100644 --- a/substrate/core/cli/Cargo.toml +++ b/substrate/core/cli/Cargo.toml @@ -3,6 +3,7 @@ name = "substrate-cli" version = "0.3.0" authors = ["Parity Technologies "] description = "Substrate CLI interface." +edition = "2018" [dependencies] clap = "~2.32" @@ -22,11 +23,11 @@ futures = "0.1.17" fdlimit = "0.1" exit-future = "0.1" sysinfo = "0.7" -substrate-client = { path = "../../core/client" } -substrate-network = { path = "../../core/network" } -sr-primitives = { path = "../../core/sr-primitives" } -substrate-primitives = { path = "../../core/primitives" } -substrate-service = { path = "../../core/service" } +client = { package = "substrate-client", path = "../../core/client" } +network = { package = "substrate-network", path = "../../core/network" } +runtime_primitives = { package = "sr-primitives", path = "../../core/sr-primitives" } +primitives = { package = "substrate-primitives", path = "../../core/primitives" } +service = { package = "substrate-service", path = "../../core/service" } substrate-telemetry = { path = "../../core/telemetry" } names = "0.11.0" structopt = "0.2.13" diff --git a/substrate/core/cli/src/error.rs b/substrate/core/cli/src/error.rs index f30481c848..1bb71274fe 100644 --- a/substrate/core/cli/src/error.rs +++ b/substrate/core/cli/src/error.rs @@ -17,6 +17,8 @@ //! Initialization errors. use client; +use error_chain::{error_chain, error_chain_processing, impl_error_chain_processed, + impl_extract_backtrace, impl_error_chain_kind}; error_chain! { foreign_links { diff --git a/substrate/core/cli/src/informant.rs b/substrate/core/cli/src/informant.rs index 0f24f5f6e6..deda6ab7b6 100644 --- a/substrate/core/cli/src/informant.rs +++ b/substrate/core/cli/src/informant.rs @@ -25,6 +25,9 @@ use tokio::timer::Interval; use sysinfo::{get_current_pid, ProcessExt, System, SystemExt}; use network::{SyncState, SyncProvider}; use client::{backend::Backend, BlockchainEvents}; +use substrate_telemetry::telemetry; +use log::{debug, info, warn}; +use slog::slog_info; use runtime_primitives::generic::BlockId; use runtime_primitives::traits::{Header, As}; diff --git a/substrate/core/cli/src/lib.rs b/substrate/core/cli/src/lib.rs index 3205269faf..8b606d944d 100644 --- a/substrate/core/cli/src/lib.rs +++ b/substrate/core/cli/src/lib.rs @@ -19,39 +19,6 @@ #![warn(missing_docs)] #![warn(unused_extern_crates)] -extern crate app_dirs; -extern crate env_logger; -extern crate atty; -extern crate ansi_term; -extern crate regex; -extern crate time; -extern crate fdlimit; -extern crate futures; -extern crate tokio; -extern crate names; -extern crate backtrace; -extern crate sysinfo; - -extern crate substrate_client as client; -extern crate substrate_network as network; -extern crate sr_primitives as runtime_primitives; -extern crate substrate_service as service; -extern crate substrate_primitives as primitives; -#[macro_use] -extern crate slog; // needed until we can reexport `slog_info` from `substrate_telemetry` -#[macro_use] -extern crate substrate_telemetry; -extern crate exit_future; - -#[macro_use] -extern crate lazy_static; -extern crate clap; -#[macro_use] -extern crate error_chain; -#[macro_use] -extern crate log; -extern crate structopt; - mod params; pub mod error; pub mod informant; @@ -80,6 +47,9 @@ use regex::Regex; use structopt::StructOpt; pub use params::{CoreParams, CoreCommands, ExecutionStrategy}; use app_dirs::{AppInfo, AppDataType}; +use error_chain::bail; +use log::info; +use lazy_static::lazy_static; use futures::Future; diff --git a/substrate/core/client/db/Cargo.toml b/substrate/core/client/db/Cargo.toml index ac89782fdf..2638258569 100644 --- a/substrate/core/client/db/Cargo.toml +++ b/substrate/core/client/db/Cargo.toml @@ -2,6 +2,7 @@ name = "substrate-client-db" version = "0.1.0" authors = ["Parity Technologies "] +edition = "2018" [dependencies] parking_lot = "0.7.1" @@ -11,17 +12,17 @@ kvdb = { git = "https://github.com/paritytech/parity-common", rev="b0317f649ab2c kvdb-rocksdb = { git = "https://github.com/paritytech/parity-common", rev="b0317f649ab2c665b7987b8475878fc4d2e1f81d" } lru-cache = "0.1" hash-db = { version = "0.9" } -substrate-primitives = { path = "../../primitives" } -sr-primitives = { path = "../../sr-primitives" } -substrate-client = { path = "../../client" } -substrate-state-machine = { path = "../../state-machine" } +primitives = { package = "substrate-primitives", path = "../../primitives" } +runtime_primitives = { package = "sr-primitives", path = "../../sr-primitives" } +client = { package = "substrate-client", path = "../../client" } +state-machine = { package = "substrate-state-machine", path = "../../state-machine" } parity-codec = "2.2" parity-codec-derive = "2.1" -substrate-executor = { path = "../../executor" } -substrate-state-db = { path = "../../state-db" } -substrate-trie = { path = "../../trie" } +executor = { package = "substrate-executor", path = "../../executor" } +state_db = { package = "substrate-state-db", path = "../../state-db" } +trie = { package = "substrate-trie", path = "../../trie" } [dev-dependencies] kvdb-memorydb = { git = "https://github.com/paritytech/parity-common", rev="b0317f649ab2c665b7987b8475878fc4d2e1f81d" } substrate-keyring = { path = "../../keyring" } -substrate-test-client = { path = "../../test-client" } +test-client = { package = "substrate-test-client", path = "../../test-client" } diff --git a/substrate/core/client/db/src/cache/list_cache.rs b/substrate/core/client/db/src/cache/list_cache.rs index 6d95349ee3..e40dcda313 100644 --- a/substrate/core/client/db/src/cache/list_cache.rs +++ b/substrate/core/client/db/src/cache/list_cache.rs @@ -41,12 +41,14 @@ use std::collections::BTreeSet; +use log::warn; + use client::error::{ErrorKind as ClientErrorKind, Result as ClientResult}; use runtime_primitives::traits::{Block as BlockT, NumberFor, As, Zero}; -use cache::{CacheItemT, ComplexBlockId}; -use cache::list_entry::{Entry, StorageEntry}; -use cache::list_storage::{Storage, StorageTransaction, Metadata}; +use crate::cache::{CacheItemT, ComplexBlockId}; +use crate::cache::list_entry::{Entry, StorageEntry}; +use crate::cache::list_storage::{Storage, StorageTransaction, Metadata}; /// List-based cache. pub struct ListCache> { @@ -585,7 +587,7 @@ fn read_forks>( pub mod tests { use runtime_primitives::testing::{Header, Block as RawBlock, ExtrinsicWrapper}; use runtime_primitives::traits::Header as HeaderT; - use cache::list_storage::tests::{DummyStorage, FaultyStorage, DummyTransaction}; + use crate::cache::list_storage::tests::{DummyStorage, FaultyStorage, DummyTransaction}; use super::*; type Block = RawBlock>; diff --git a/substrate/core/client/db/src/cache/list_entry.rs b/substrate/core/client/db/src/cache/list_entry.rs index 53d250bd06..b54094fa00 100644 --- a/substrate/core/client/db/src/cache/list_entry.rs +++ b/substrate/core/client/db/src/cache/list_entry.rs @@ -18,9 +18,10 @@ use client::error::Result as ClientResult; use runtime_primitives::traits::{Block as BlockT, NumberFor}; +use parity_codec_derive::{Encode, Decode}; -use cache::{CacheItemT, ComplexBlockId}; -use cache::list_storage::{Storage}; +use crate::cache::{CacheItemT, ComplexBlockId}; +use crate::cache::list_storage::{Storage}; /// Single list-based cache entry. #[derive(Debug)] @@ -112,8 +113,8 @@ impl StorageEntry { #[cfg(test)] mod tests { - use cache::list_cache::tests::test_id; - use cache::list_storage::tests::{DummyStorage, FaultyStorage}; + use crate::cache::list_cache::tests::test_id; + use crate::cache::list_storage::tests::{DummyStorage, FaultyStorage}; use super::*; #[test] diff --git a/substrate/core/client/db/src/cache/list_storage.rs b/substrate/core/client/db/src/cache/list_storage.rs index ec6883d262..b9bf99f67b 100644 --- a/substrate/core/client/db/src/cache/list_storage.rs +++ b/substrate/core/client/db/src/cache/list_storage.rs @@ -21,14 +21,14 @@ use std::sync::Arc; use kvdb::{KeyValueDB, DBTransaction}; use client::error::{Error as ClientError, ErrorKind as ClientErrorKind, Result as ClientResult}; -use codec::{Encode, Decode}; +use parity_codec::{Encode, Decode}; use runtime_primitives::generic::BlockId; use runtime_primitives::traits::{Block as BlockT, Header as HeaderT, NumberFor}; -use utils::{self, db_err, meta_keys}; +use crate::utils::{self, db_err, meta_keys}; -use cache::{CacheItemT, ComplexBlockId}; -use cache::list_cache::{CommitOperation, Fork}; -use cache::list_entry::{Entry, StorageEntry}; +use crate::cache::{CacheItemT, ComplexBlockId}; +use crate::cache::list_cache::{CommitOperation, Fork}; +use crate::cache::list_entry::{Entry, StorageEntry}; /// Single list-cache metadata. #[derive(Debug)] diff --git a/substrate/core/client/db/src/cache/mod.rs b/substrate/core/client/db/src/cache/mod.rs index 11fbd93392..8df8e42518 100644 --- a/substrate/core/client/db/src/cache/mod.rs +++ b/substrate/core/client/db/src/cache/mod.rs @@ -23,10 +23,11 @@ use kvdb::{KeyValueDB, DBTransaction}; use client::blockchain::Cache as BlockchainCache; use client::error::Result as ClientResult; -use codec::{Encode, Decode}; +use parity_codec::{Encode, Decode}; +use parity_codec_derive::{Encode, Decode}; use runtime_primitives::generic::BlockId; use runtime_primitives::traits::{Block as BlockT, Header as HeaderT, NumberFor, As, AuthorityIdFor}; -use utils::{self, COLUMN_META}; +use crate::utils::{self, COLUMN_META}; use self::list_cache::ListCache; diff --git a/substrate/core/client/db/src/lib.rs b/substrate/core/client/db/src/lib.rs index 0b61334b4e..7937969c1c 100644 --- a/substrate/core/client/db/src/lib.rs +++ b/substrate/core/client/db/src/lib.rs @@ -24,32 +24,6 @@ //! //! Finality implies canonicality but not vice-versa. -extern crate substrate_client as client; -extern crate kvdb_rocksdb; -extern crate kvdb; -extern crate hash_db; -extern crate parking_lot; -extern crate lru_cache; -extern crate substrate_state_machine as state_machine; -extern crate substrate_primitives as primitives; -extern crate sr_primitives as runtime_primitives; -extern crate parity_codec as codec; -extern crate substrate_executor as executor; -extern crate substrate_state_db as state_db; -extern crate substrate_trie as trie; - -#[macro_use] -extern crate log; - -#[macro_use] -extern crate parity_codec_derive; - -#[cfg(test)] -extern crate substrate_test_client as test_client; - -#[cfg(test)] -extern crate kvdb_memorydb; - pub mod light; mod cache; @@ -61,7 +35,7 @@ use std::path::PathBuf; use std::io; use client::backend::NewBlockState; -use codec::{Decode, Encode}; +use parity_codec::{Decode, Encode}; use hash_db::Hasher; use kvdb::{KeyValueDB, DBTransaction}; use trie::MemoryDB; @@ -78,6 +52,7 @@ use utils::{Meta, db_err, meta_keys, open_database, read_db, block_id_to_lookup_ use client::LeafSet; use state_db::StateDb; use storage_cache::{CachingState, SharedCache, new_shared_cache}; +use log::{trace, debug, warn}; pub use state_db::PruningMode; const CANONICALIZATION_DELAY: u64 = 256; @@ -116,7 +91,7 @@ pub fn new_client( } mod columns { - pub const META: Option = ::utils::COLUMN_META; + pub const META: Option = crate::utils::COLUMN_META; pub const STATE: Option = Some(1); pub const STATE_META: Option = Some(2); /// maps hashes to lookup keys and numbers to canon hashes. @@ -191,7 +166,7 @@ impl BlockchainDb { impl client::blockchain::HeaderBackend for BlockchainDb { fn header(&self, id: BlockId) -> Result, client::error::Error> { - ::utils::read_header(&*self.db, columns::KEY_LOOKUP, columns::HEADER, id) + utils::read_header(&*self.db, columns::KEY_LOOKUP, columns::HEADER, id) } fn info(&self) -> Result, client::error::Error> { @@ -486,7 +461,7 @@ impl state_machine::ChangesTrieRootsStorage for DbC // the block is not finalized let mut current_num = anchor.number; let mut current_hash: Block::Hash = convert_hash(&anchor.hash); - let maybe_anchor_header: Block::Header = ::utils::require_header::( + let maybe_anchor_header: Block::Header = utils::require_header::( &*self.db, columns::KEY_LOOKUP, columns::HEADER, BlockId::Number(As::sa(current_num)) ).map_err(|e| e.to_string())?; if maybe_anchor_header.hash() == current_hash { @@ -497,7 +472,7 @@ impl state_machine::ChangesTrieRootsStorage for DbC // => we should find the required block hash by traversing // back from the anchor to the block with given number while current_num != block { - let current_header: Block::Header = ::utils::require_header::( + let current_header: Block::Header = utils::require_header::( &*self.db, columns::KEY_LOOKUP, columns::HEADER, BlockId::Hash(current_hash) ).map_err(|e| e.to_string())?; @@ -509,7 +484,7 @@ impl state_machine::ChangesTrieRootsStorage for DbC } }; - Ok(::utils::require_header::(&*self.db, columns::KEY_LOOKUP, columns::HEADER, block_id) + Ok(utils::require_header::(&*self.db, columns::KEY_LOOKUP, columns::HEADER, block_id) .map_err(|e| e.to_string())? .digest().log(DigestItem::as_changes_trie_root) .map(|root| H256::from_slice(root.as_ref()))) @@ -638,7 +613,7 @@ impl Backend { ).into()) } - let lookup_key = ::utils::number_and_hash_to_lookup_key(f_num, f_hash.clone()); + let lookup_key = utils::number_and_hash_to_lookup_key(f_num, f_hash.clone()); transaction.put(columns::META, meta_keys::FINALIZED_BLOCK, &lookup_key); let commit = self.storage.state_db.canonicalize_block(&f_hash); @@ -725,7 +700,7 @@ impl client::backend::Backend for Backend whe let number = pending_block.header.number().clone(); // blocks are keyed by number + hash. - let lookup_key = ::utils::number_and_hash_to_lookup_key(number, hash); + let lookup_key = utils::number_and_hash_to_lookup_key(number, hash); let mut enacted = Vec::default(); let mut retracted = Vec::default(); @@ -752,7 +727,7 @@ impl client::backend::Backend for Backend whe return Err(::client::error::ErrorKind::NotInFinalizedChain.into()); } - ::utils::remove_number_to_key_mapping( + utils::remove_number_to_key_mapping( &mut transaction, columns::KEY_LOOKUP, r.number @@ -762,7 +737,7 @@ impl client::backend::Backend for Backend whe // canonicalize: set the number lookup to map to this block's hash. for e in tree_route.enacted() { enacted.push(e.hash.clone()); - ::utils::insert_number_to_key_mapping( + utils::insert_number_to_key_mapping( &mut transaction, columns::KEY_LOOKUP, e.number, @@ -772,7 +747,7 @@ impl client::backend::Backend for Backend whe } transaction.put(columns::META, meta_keys::BEST_BLOCK, &lookup_key); - ::utils::insert_number_to_key_mapping( + utils::insert_number_to_key_mapping( &mut transaction, columns::KEY_LOOKUP, number, @@ -780,7 +755,7 @@ impl client::backend::Backend for Backend whe ); } - ::utils::insert_hash_to_key_mapping( + utils::insert_hash_to_key_mapping( &mut transaction, columns::KEY_LOOKUP, number, @@ -880,7 +855,7 @@ impl client::backend::Backend for Backend whe let number = header.number().clone(); transaction.put( columns::JUSTIFICATION, - &::utils::number_and_hash_to_lookup_key(number, hash.clone()), + &utils::number_and_hash_to_lookup_key(number, hash.clone()), &justification.encode(), ); } @@ -920,7 +895,7 @@ impl client::backend::Backend for Backend whe let hash = self.blockchain.hash(best)?.ok_or_else( || client::error::ErrorKind::UnknownBlock( format!("Error reverting to {}. Block hash not found.", best)))?; - let key = ::utils::number_and_hash_to_lookup_key(best.clone(), hash.clone()); + let key = utils::number_and_hash_to_lookup_key(best.clone(), hash.clone()); transaction.put(columns::META, meta_keys::BEST_BLOCK, &key); transaction.delete(columns::KEY_LOOKUP, removed.hash().as_ref()); self.storage.db.write(transaction).map_err(db_err)?; @@ -978,6 +953,7 @@ where Block: BlockT {} mod tests { use hash_db::HashDB; use super::*; + use crate::columns; use client::backend::Backend as BTrait; use client::backend::BlockImportOperation as Op; use client::blockchain::HeaderBackend as BlockchainHeaderBackend; @@ -1205,7 +1181,7 @@ mod tests { backend.commit_operation(op).unwrap(); - assert_eq!(backend.storage.db.get(::columns::STATE, key.as_bytes()).unwrap().unwrap(), &b"hello"[..]); + assert_eq!(backend.storage.db.get(columns::STATE, key.as_bytes()).unwrap().unwrap(), &b"hello"[..]); hash }; @@ -1239,7 +1215,7 @@ mod tests { backend.commit_operation(op).unwrap(); - assert_eq!(backend.storage.db.get(::columns::STATE, key.as_bytes()).unwrap().unwrap(), &b"hello"[..]); + assert_eq!(backend.storage.db.get(columns::STATE, key.as_bytes()).unwrap().unwrap(), &b"hello"[..]); hash }; @@ -1271,12 +1247,12 @@ mod tests { backend.commit_operation(op).unwrap(); - assert!(backend.storage.db.get(::columns::STATE, key.as_bytes()).unwrap().is_none()); + assert!(backend.storage.db.get(columns::STATE, key.as_bytes()).unwrap().is_none()); } backend.finalize_block(BlockId::Number(1), None).unwrap(); backend.finalize_block(BlockId::Number(2), None).unwrap(); - assert!(backend.storage.db.get(::columns::STATE, key.as_bytes()).unwrap().is_none()); + assert!(backend.storage.db.get(columns::STATE, key.as_bytes()).unwrap().is_none()); } #[test] diff --git a/substrate/core/client/db/src/light.rs b/substrate/core/client/db/src/light.rs index cbed1348a9..3e197e5ae7 100644 --- a/substrate/core/client/db/src/light.rs +++ b/substrate/core/client/db/src/light.rs @@ -27,18 +27,19 @@ use client::blockchain::{BlockStatus, Cache as BlockchainCache, use client::{cht, LeafSet}; use client::error::{ErrorKind as ClientErrorKind, Result as ClientResult}; use client::light::blockchain::Storage as LightBlockchainStorage; -use codec::{Decode, Encode}; +use parity_codec::{Decode, Encode}; use primitives::Blake2Hasher; use runtime_primitives::generic::BlockId; use runtime_primitives::traits::{Block as BlockT, Header as HeaderT, Zero, One, As, NumberFor, Digest, DigestItem, AuthorityIdFor}; -use cache::{DbCacheSync, DbCache, ComplexBlockId}; -use utils::{meta_keys, Meta, db_err, open_database, +use crate::cache::{DbCacheSync, DbCache, ComplexBlockId}; +use crate::utils::{self, meta_keys, Meta, db_err, open_database, read_db, block_id_to_lookup_key, read_meta}; -use DatabaseSettings; +use crate::DatabaseSettings; +use log::{trace, warn, debug}; pub(crate) mod columns { - pub const META: Option = ::utils::COLUMN_META; + pub const META: Option = crate::utils::COLUMN_META; pub const KEY_LOOKUP: Option = Some(1); pub const HEADER: Option = Some(2); pub const CACHE: Option = Some(3); @@ -135,7 +136,7 @@ impl BlockchainHeaderBackend for LightStorage Block: BlockT, { fn header(&self, id: BlockId) -> ClientResult> { - ::utils::read_header(&*self.db, columns::KEY_LOOKUP, columns::HEADER, id) + utils::read_header(&*self.db, columns::KEY_LOOKUP, columns::HEADER, id) } fn info(&self) -> ClientResult> { @@ -167,7 +168,7 @@ impl BlockchainHeaderBackend for LightStorage fn number(&self, hash: Block::Hash) -> ClientResult>> { if let Some(lookup_key) = block_id_to_lookup_key::(&*self.db, columns::KEY_LOOKUP, BlockId::Hash(hash))? { - let number = ::utils::lookup_key_to_number(&lookup_key)?; + let number = utils::lookup_key_to_number(&lookup_key)?; Ok(Some(number)) } else { Ok(None) @@ -203,7 +204,7 @@ impl LightStorage { ).into()) } - let lookup_key = ::utils::number_and_hash_to_lookup_key(header.number().clone(), hash); + let lookup_key = utils::number_and_hash_to_lookup_key(header.number().clone(), hash); transaction.put(columns::META, meta_keys::FINALIZED_BLOCK, &lookup_key); // build new CHT(s) if required @@ -243,7 +244,7 @@ impl LightStorage { if let Some(hash) = self.hash(prune_block)? { let lookup_key = block_id_to_lookup_key::(&*self.db, columns::KEY_LOOKUP, BlockId::Number(prune_block))? .expect("retrieved hash for `prune_block` right above. therefore retrieving lookup key must succeed. q.e.d."); - ::utils::remove_key_mappings( + utils::remove_key_mappings( transaction, columns::KEY_LOOKUP, prune_block, @@ -324,7 +325,7 @@ impl LightBlockchainStorage for LightStorage } // blocks are keyed by number + hash. - let lookup_key = ::utils::number_and_hash_to_lookup_key(number, hash); + let lookup_key = utils::number_and_hash_to_lookup_key(number, hash); if leaf_state.is_best() { // handle reorg. @@ -345,7 +346,7 @@ impl LightBlockchainStorage for LightStorage (&retracted.number, &retracted.hash)); } - ::utils::remove_number_to_key_mapping( + utils::remove_number_to_key_mapping( &mut transaction, columns::KEY_LOOKUP, retracted.number @@ -353,7 +354,7 @@ impl LightBlockchainStorage for LightStorage } for enacted in tree_route.enacted() { - ::utils::insert_number_to_key_mapping( + utils::insert_number_to_key_mapping( &mut transaction, columns::KEY_LOOKUP, enacted.number, @@ -364,7 +365,7 @@ impl LightBlockchainStorage for LightStorage } transaction.put(columns::META, meta_keys::BEST_BLOCK, &lookup_key); - ::utils::insert_number_to_key_mapping( + utils::insert_number_to_key_mapping( &mut transaction, columns::KEY_LOOKUP, number, @@ -372,7 +373,7 @@ impl LightBlockchainStorage for LightStorage ); } - ::utils::insert_hash_to_key_mapping( + utils::insert_hash_to_key_mapping( &mut transaction, columns::KEY_LOOKUP, number, @@ -473,7 +474,7 @@ impl LightBlockchainStorage for LightStorage /// Build the key for inserting header-CHT at given block. fn cht_key>(cht_type: u8, block: N) -> [u8; 5] { let mut key = [cht_type; 5]; - key[1..].copy_from_slice(&::utils::number_index_key(block)); + key[1..].copy_from_slice(&utils::number_index_key(block)); key } diff --git a/substrate/core/client/db/src/storage_cache.rs b/substrate/core/client/db/src/storage_cache.rs index 3411987d48..455c5a7736 100644 --- a/substrate/core/client/db/src/storage_cache.rs +++ b/substrate/core/client/db/src/storage_cache.rs @@ -23,6 +23,7 @@ use lru_cache::LruCache; use hash_db::Hasher; use runtime_primitives::traits::{Block, Header}; use state_machine::{backend::Backend as StateBackend, TrieBackend}; +use log::trace; const STATE_CACHE_BLOCKS: usize = 12; diff --git a/substrate/core/client/db/src/utils.rs b/substrate/core/client/db/src/utils.rs index 416bf239b2..f1e4f3d2e2 100644 --- a/substrate/core/client/db/src/utils.rs +++ b/substrate/core/client/db/src/utils.rs @@ -22,13 +22,14 @@ use std::io; use kvdb::{KeyValueDB, DBTransaction}; use kvdb_rocksdb::{Database, DatabaseConfig}; +use log::debug; use client; -use codec::Decode; +use parity_codec::Decode; use trie::DBValue; use runtime_primitives::generic::BlockId; use runtime_primitives::traits::{As, Block as BlockT, Header as HeaderT, Zero}; -use DatabaseSettings; +use crate::DatabaseSettings; /// Number of columns in the db. Must be the same for both full && light dbs. /// Otherwise RocksDb will fail to open database && check its type.