diff --git a/substrate/Cargo.lock b/substrate/Cargo.lock index 0fe8e4919e..93aa1d393f 100644 --- a/substrate/Cargo.lock +++ b/substrate/Cargo.lock @@ -3294,9 +3294,9 @@ dependencies = [ [[package]] name = "memory-db" -version = "0.24.0" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0777fbb396f666701d939e9b3876c18ada6b3581257d88631f2590bc366d8ebe" +checksum = "36f36ddb0b2cdc25d38babba472108798e3477f02be5165f038c5e393e50c57a" dependencies = [ "hash-db", "hashbrown 0.8.0", @@ -3640,6 +3640,7 @@ dependencies = [ "sp-runtime", "sp-timestamp", "sp-transaction-pool", + "sp-trie", "structopt", "substrate-browser-utils", "substrate-build-script-utils", @@ -9345,7 +9346,7 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3bfd5b7557925ce778ff9b9ef90e3ade34c524b5ff10e239c69a42d546d2af56" dependencies = [ - "rand 0.7.3", + "rand 0.3.23", ] [[package]] diff --git a/substrate/bin/node/cli/Cargo.toml b/substrate/bin/node/cli/Cargo.toml index 03620976be..4fbb48513b 100644 --- a/substrate/bin/node/cli/Cargo.toml +++ b/substrate/bin/node/cli/Cargo.toml @@ -109,6 +109,7 @@ browser-utils = { package = "substrate-browser-utils", path = "../../../utils/br node-executor = { version = "2.0.0-rc5", path = "../executor", features = [ "wasmtime" ] } sc-cli = { version = "0.8.0-rc5", optional = true, path = "../../../client/cli", features = [ "wasmtime" ] } sc-service = { version = "0.8.0-rc5", default-features = false, path = "../../../client/service", features = [ "wasmtime" ] } +sp-trie = { version = "2.0.0-rc5", default-features = false, path = "../../../primitives/trie", features = ["memory-tracker"] } [dev-dependencies] sc-keystore = { version = "2.0.0-rc5", path = "../../../client/keystore" } diff --git a/substrate/primitives/trie/Cargo.toml b/substrate/primitives/trie/Cargo.toml index c296acaa50..8dd386e095 100644 --- a/substrate/primitives/trie/Cargo.toml +++ b/substrate/primitives/trie/Cargo.toml @@ -43,3 +43,4 @@ std = [ "trie-root/std", "sp-core/std", ] +memory-tracker = [] diff --git a/substrate/primitives/trie/src/lib.rs b/substrate/primitives/trie/src/lib.rs index c8f37a820d..5ab06cecca 100644 --- a/substrate/primitives/trie/src/lib.rs +++ b/substrate/primitives/trie/src/lib.rs @@ -78,6 +78,11 @@ impl TrieConfiguration for Layout { } } +#[cfg(not(feature = "memory-tracker"))] +type MemTracker = memory_db::NoopTracker; +#[cfg(feature = "memory-tracker")] +type MemTracker = memory_db::MemCounter; + /// TrieDB error over `TrieConfiguration` trait. pub type TrieError = trie_db::TrieError, CError>; /// Reexport from `hash_db`, with genericity set for `Hasher` trait. @@ -88,13 +93,19 @@ pub type HashDB<'a, H> = dyn hash_db::HashDB + 'a; /// Reexport from `hash_db`, with genericity set for `Hasher` trait. /// This uses a `KeyFunction` for prefixing keys internally (avoiding /// key conflict for non random keys). -pub type PrefixedMemoryDB = memory_db::MemoryDB, trie_db::DBValue>; +pub type PrefixedMemoryDB = memory_db::MemoryDB< + H, memory_db::PrefixedKey, trie_db::DBValue, MemTracker +>; /// Reexport from `hash_db`, with genericity set for `Hasher` trait. /// This uses a noops `KeyFunction` (key addressing must be hashed or using /// an encoding scheme that avoid key conflict). -pub type MemoryDB = memory_db::MemoryDB, trie_db::DBValue>; +pub type MemoryDB = memory_db::MemoryDB< + H, memory_db::HashKey, trie_db::DBValue, MemTracker, +>; /// Reexport from `hash_db`, with genericity set for `Hasher` trait. -pub type GenericMemoryDB = memory_db::MemoryDB; +pub type GenericMemoryDB = memory_db::MemoryDB< + H, KF, trie_db::DBValue, MemTracker +>; /// Persistent trie database read-access interface for the a given hasher. pub type TrieDB<'a, L> = trie_db::TrieDB<'a, L>;