mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-20 23:15:42 +00:00
Remove mem_info and references to parity-util-mem (#12795)
* Remove mem_info and some references to parity-util-mem * [Draft] Finish removing references to `parity-util-mem` * Upgrade dependencies * Update scripts/ci/deny.toml Co-authored-by: ordian <write@reusable.software> * Fix Cargo.lock (remove unwanted dependency changes) * Removed unused argument * Run cargo fmt (didn't have pre-commit set up) * Fix some CI errors * Fix another CI error * Remove unused dependency Co-authored-by: ordian <write@reusable.software>
This commit is contained in:
Generated
+10
-53
@@ -2241,7 +2241,6 @@ dependencies = [
|
|||||||
"log",
|
"log",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"parity-scale-codec",
|
"parity-scale-codec",
|
||||||
"parity-util-mem",
|
|
||||||
"paste",
|
"paste",
|
||||||
"pretty_assertions",
|
"pretty_assertions",
|
||||||
"scale-info",
|
"scale-info",
|
||||||
@@ -3378,35 +3377,31 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "kvdb"
|
name = "kvdb"
|
||||||
version = "0.12.0"
|
version = "0.13.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "585089ceadba0197ffe9af6740ab350b325e3c1f5fccfbc3522e0250c750409b"
|
checksum = "e7d770dcb02bf6835887c3a979b5107a04ff4bbde97a5f0928d27404a155add9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"parity-util-mem",
|
|
||||||
"smallvec",
|
"smallvec",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "kvdb-memorydb"
|
name = "kvdb-memorydb"
|
||||||
version = "0.12.0"
|
version = "0.13.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "40d109c87bfb7759edd2a49b2649c1afe25af785d930ad6a38479b4dc70dd873"
|
checksum = "bf7a85fe66f9ff9cd74e169fdd2c94c6e1e74c412c99a73b4df3200b5d3760b2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"kvdb",
|
"kvdb",
|
||||||
"parity-util-mem",
|
|
||||||
"parking_lot 0.12.1",
|
"parking_lot 0.12.1",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "kvdb-rocksdb"
|
name = "kvdb-rocksdb"
|
||||||
version = "0.16.0"
|
version = "0.17.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c076cc2cdbac89b9910c853a36c957d3862a779f31c2661174222cefb49ee597"
|
checksum = "2182b8219fee6bd83aacaab7344e840179ae079d5216aa4e249b4d704646a844"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"kvdb",
|
"kvdb",
|
||||||
"log",
|
|
||||||
"num_cpus",
|
"num_cpus",
|
||||||
"parity-util-mem",
|
|
||||||
"parking_lot 0.12.1",
|
"parking_lot 0.12.1",
|
||||||
"regex",
|
"regex",
|
||||||
"rocksdb",
|
"rocksdb",
|
||||||
@@ -4081,13 +4076,12 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "memory-db"
|
name = "memory-db"
|
||||||
version = "0.30.0"
|
version = "0.31.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "34ac11bb793c28fa095b7554466f53b3a60a2cd002afdac01bcf135cbd73a269"
|
checksum = "5e0c7cba9ce19ac7ffd2053ac9f49843bbd3f4318feedfd74e85c19d5fb0ba66"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"hash-db",
|
"hash-db",
|
||||||
"hashbrown 0.12.3",
|
"hashbrown 0.12.3",
|
||||||
"parity-util-mem",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -4433,7 +4427,6 @@ dependencies = [
|
|||||||
"node-primitives",
|
"node-primitives",
|
||||||
"node-testing",
|
"node-testing",
|
||||||
"parity-db",
|
"parity-db",
|
||||||
"parity-util-mem",
|
|
||||||
"rand 0.7.3",
|
"rand 0.7.3",
|
||||||
"sc-basic-authorship",
|
"sc-basic-authorship",
|
||||||
"sc-client-api",
|
"sc-client-api",
|
||||||
@@ -4527,7 +4520,6 @@ dependencies = [
|
|||||||
"sp-tracing",
|
"sp-tracing",
|
||||||
"sp-transaction-pool",
|
"sp-transaction-pool",
|
||||||
"sp-transaction-storage-proof",
|
"sp-transaction-storage-proof",
|
||||||
"sp-trie",
|
|
||||||
"substrate-build-script-utils",
|
"substrate-build-script-utils",
|
||||||
"substrate-frame-cli",
|
"substrate-frame-cli",
|
||||||
"substrate-rpc-client",
|
"substrate-rpc-client",
|
||||||
@@ -6379,33 +6371,6 @@ version = "0.1.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "aa9777aa91b8ad9dd5aaa04a9b6bcb02c7f1deb952fca5a66034d5e63afc5c6f"
|
checksum = "aa9777aa91b8ad9dd5aaa04a9b6bcb02c7f1deb952fca5a66034d5e63afc5c6f"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "parity-util-mem"
|
|
||||||
version = "0.12.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "0d32c34f4f5ca7f9196001c0aba5a1f9a5a12382c8944b8b0f90233282d1e8f8"
|
|
||||||
dependencies = [
|
|
||||||
"cfg-if",
|
|
||||||
"hashbrown 0.12.3",
|
|
||||||
"impl-trait-for-tuples",
|
|
||||||
"parity-util-mem-derive",
|
|
||||||
"parking_lot 0.12.1",
|
|
||||||
"primitive-types",
|
|
||||||
"smallvec",
|
|
||||||
"winapi",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "parity-util-mem-derive"
|
|
||||||
version = "0.1.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "f557c32c6d268a07c921471619c0295f5efad3a0e76d4f97a05c091a51d110b2"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"syn",
|
|
||||||
"synstructure",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "parity-wasm"
|
name = "parity-wasm"
|
||||||
version = "0.45.0"
|
version = "0.45.0"
|
||||||
@@ -8066,7 +8031,6 @@ dependencies = [
|
|||||||
"futures",
|
"futures",
|
||||||
"futures-timer",
|
"futures-timer",
|
||||||
"log",
|
"log",
|
||||||
"parity-util-mem",
|
|
||||||
"sc-client-api",
|
"sc-client-api",
|
||||||
"sc-network-common",
|
"sc-network-common",
|
||||||
"sc-transaction-pool-api",
|
"sc-transaction-pool-api",
|
||||||
@@ -8498,7 +8462,6 @@ dependencies = [
|
|||||||
"jsonrpsee",
|
"jsonrpsee",
|
||||||
"log",
|
"log",
|
||||||
"parity-scale-codec",
|
"parity-scale-codec",
|
||||||
"parity-util-mem",
|
|
||||||
"parking_lot 0.12.1",
|
"parking_lot 0.12.1",
|
||||||
"pin-project",
|
"pin-project",
|
||||||
"rand 0.7.3",
|
"rand 0.7.3",
|
||||||
@@ -8600,8 +8563,6 @@ version = "0.10.0-dev"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"log",
|
"log",
|
||||||
"parity-scale-codec",
|
"parity-scale-codec",
|
||||||
"parity-util-mem",
|
|
||||||
"parity-util-mem-derive",
|
|
||||||
"parking_lot 0.12.1",
|
"parking_lot 0.12.1",
|
||||||
"sc-client-api",
|
"sc-client-api",
|
||||||
"sp-core",
|
"sp-core",
|
||||||
@@ -8715,7 +8676,6 @@ dependencies = [
|
|||||||
"linked-hash-map",
|
"linked-hash-map",
|
||||||
"log",
|
"log",
|
||||||
"parity-scale-codec",
|
"parity-scale-codec",
|
||||||
"parity-util-mem",
|
|
||||||
"parking_lot 0.12.1",
|
"parking_lot 0.12.1",
|
||||||
"sc-block-builder",
|
"sc-block-builder",
|
||||||
"sc-client-api",
|
"sc-client-api",
|
||||||
@@ -9723,7 +9683,6 @@ dependencies = [
|
|||||||
"impl-trait-for-tuples",
|
"impl-trait-for-tuples",
|
||||||
"log",
|
"log",
|
||||||
"parity-scale-codec",
|
"parity-scale-codec",
|
||||||
"parity-util-mem",
|
|
||||||
"paste",
|
"paste",
|
||||||
"rand 0.7.3",
|
"rand 0.7.3",
|
||||||
"scale-info",
|
"scale-info",
|
||||||
@@ -9908,7 +9867,6 @@ name = "sp-test-primitives"
|
|||||||
version = "2.0.0"
|
version = "2.0.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"parity-scale-codec",
|
"parity-scale-codec",
|
||||||
"parity-util-mem",
|
|
||||||
"serde",
|
"serde",
|
||||||
"sp-application-crypto",
|
"sp-application-crypto",
|
||||||
"sp-core",
|
"sp-core",
|
||||||
@@ -10333,7 +10291,6 @@ dependencies = [
|
|||||||
"pallet-babe",
|
"pallet-babe",
|
||||||
"pallet-timestamp",
|
"pallet-timestamp",
|
||||||
"parity-scale-codec",
|
"parity-scale-codec",
|
||||||
"parity-util-mem",
|
|
||||||
"sc-block-builder",
|
"sc-block-builder",
|
||||||
"sc-executor",
|
"sc-executor",
|
||||||
"sc-service",
|
"sc-service",
|
||||||
@@ -10850,9 +10807,9 @@ checksum = "a7f741b240f1a48843f9b8e0444fb55fb2a4ff67293b50a9179dfd5ea67f8d41"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "trie-bench"
|
name = "trie-bench"
|
||||||
version = "0.32.0"
|
version = "0.33.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f0dae77b1daad50cd3ed94c506d2dab27e2e47f7b5153a6d4b1992bb3f6028cb"
|
checksum = "c5b26bd2cdd7641c5beb476b314c0cb1f629832bf21a6235f545e2d47bc9d05a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"criterion",
|
"criterion",
|
||||||
"hash-db",
|
"hash-db",
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ sp-state-machine = { version = "0.13.0", path = "../../../primitives/state-machi
|
|||||||
serde = "1.0.136"
|
serde = "1.0.136"
|
||||||
serde_json = "1.0.85"
|
serde_json = "1.0.85"
|
||||||
derive_more = { version = "0.99.17", default-features = false, features = ["display"] }
|
derive_more = { version = "0.99.17", default-features = false, features = ["display"] }
|
||||||
kvdb = "0.12.0"
|
kvdb = "0.13.0"
|
||||||
kvdb-rocksdb = "0.16.0"
|
kvdb-rocksdb = "0.17.0"
|
||||||
sp-trie = { version = "7.0.0", path = "../../../primitives/trie" }
|
sp-trie = { version = "7.0.0", path = "../../../primitives/trie" }
|
||||||
sp-core = { version = "7.0.0", path = "../../../primitives/core" }
|
sp-core = { version = "7.0.0", path = "../../../primitives/core" }
|
||||||
sp-consensus = { version = "0.10.0-dev", path = "../../../primitives/consensus/common" }
|
sp-consensus = { version = "0.10.0-dev", path = "../../../primitives/consensus/common" }
|
||||||
@@ -37,7 +37,6 @@ tempfile = "3.1.0"
|
|||||||
fs_extra = "1"
|
fs_extra = "1"
|
||||||
rand = { version = "0.7.2", features = ["small_rng"] }
|
rand = { version = "0.7.2", features = ["small_rng"] }
|
||||||
lazy_static = "1.4.0"
|
lazy_static = "1.4.0"
|
||||||
parity-util-mem = { version = "0.12.0", default-features = false, features = ["primitive-types"] }
|
|
||||||
parity-db = "0.4.2"
|
parity-db = "0.4.2"
|
||||||
sc-transaction-pool = { version = "4.0.0-dev", path = "../../../client/transaction-pool" }
|
sc-transaction-pool = { version = "4.0.0-dev", path = "../../../client/transaction-pool" }
|
||||||
sc-transaction-pool-api = { version = "4.0.0-dev", path = "../../../client/transaction-pool/api" }
|
sc-transaction-pool-api = { version = "4.0.0-dev", path = "../../../client/transaction-pool/api" }
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ pub enum DatabaseType {
|
|||||||
pub struct TempDatabase(tempfile::TempDir);
|
pub struct TempDatabase(tempfile::TempDir);
|
||||||
|
|
||||||
struct ParityDbWrapper(parity_db::Db);
|
struct ParityDbWrapper(parity_db::Db);
|
||||||
parity_util_mem::malloc_size_of_is_0!(ParityDbWrapper);
|
|
||||||
|
|
||||||
impl KeyValueDB for ParityDbWrapper {
|
impl KeyValueDB for ParityDbWrapper {
|
||||||
/// Get a value by key.
|
/// Get a value by key.
|
||||||
|
|||||||
@@ -101,11 +101,6 @@ node-inspect = { version = "0.9.0-dev", optional = true, path = "../inspect" }
|
|||||||
try-runtime-cli = { version = "0.10.0-dev", optional = true, path = "../../../utils/frame/try-runtime/cli" }
|
try-runtime-cli = { version = "0.10.0-dev", optional = true, path = "../../../utils/frame/try-runtime/cli" }
|
||||||
serde_json = "1.0.85"
|
serde_json = "1.0.85"
|
||||||
|
|
||||||
[target.'cfg(any(target_arch="x86_64", target_arch="aarch64"))'.dependencies]
|
|
||||||
sp-trie = { version = "7.0.0", default-features = false, path = "../../../primitives/trie", features = [
|
|
||||||
"memory-tracker",
|
|
||||||
] }
|
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
sc-keystore = { version = "4.0.0-dev", path = "../../../client/keystore" }
|
sc-keystore = { version = "4.0.0-dev", path = "../../../client/keystore" }
|
||||||
sc-client-db = { version = "0.10.0-dev", path = "../../../client/db" }
|
sc-client-db = { version = "0.10.0-dev", path = "../../../client/db" }
|
||||||
|
|||||||
@@ -197,17 +197,6 @@ impl fmt::Display for MemorySize {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Memory statistics for state db.
|
|
||||||
#[derive(Default, Clone, Debug)]
|
|
||||||
pub struct StateDbMemoryInfo {
|
|
||||||
/// Memory usage of the non-canonical overlay
|
|
||||||
pub non_canonical: MemorySize,
|
|
||||||
/// Memory usage of the pruning window.
|
|
||||||
pub pruning: Option<MemorySize>,
|
|
||||||
/// Memory usage of the pinned blocks.
|
|
||||||
pub pinned: MemorySize,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Memory statistics for client instance.
|
/// Memory statistics for client instance.
|
||||||
#[derive(Default, Clone, Debug)]
|
#[derive(Default, Clone, Debug)]
|
||||||
pub struct MemoryInfo {
|
pub struct MemoryInfo {
|
||||||
@@ -215,8 +204,6 @@ pub struct MemoryInfo {
|
|||||||
pub state_cache: MemorySize,
|
pub state_cache: MemorySize,
|
||||||
/// Size of backend database cache.
|
/// Size of backend database cache.
|
||||||
pub database_cache: MemorySize,
|
pub database_cache: MemorySize,
|
||||||
/// Size of the state db.
|
|
||||||
pub state_db: StateDbMemoryInfo,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// I/O statistics for client instance.
|
/// I/O statistics for client instance.
|
||||||
@@ -264,13 +251,9 @@ impl fmt::Display for UsageInfo {
|
|||||||
write!(
|
write!(
|
||||||
f,
|
f,
|
||||||
"caches: ({} state, {} db overlay), \
|
"caches: ({} state, {} db overlay), \
|
||||||
state db: ({} non-canonical, {} pruning, {} pinned), \
|
|
||||||
i/o: ({} tx, {} write, {} read, {} avg tx, {}/{} key cache reads/total, {} trie nodes writes)",
|
i/o: ({} tx, {} write, {} read, {} avg tx, {}/{} key cache reads/total, {} trie nodes writes)",
|
||||||
self.memory.state_cache,
|
self.memory.state_cache,
|
||||||
self.memory.database_cache,
|
self.memory.database_cache,
|
||||||
self.memory.state_db.non_canonical,
|
|
||||||
self.memory.state_db.pruning.unwrap_or_default(),
|
|
||||||
self.memory.state_db.pinned,
|
|
||||||
self.io.transactions,
|
self.io.transactions,
|
||||||
self.io.bytes_written,
|
self.io.bytes_written,
|
||||||
self.io.bytes_read,
|
self.io.bytes_read,
|
||||||
|
|||||||
@@ -17,9 +17,9 @@ codec = { package = "parity-scale-codec", version = "3.0.0", features = [
|
|||||||
"derive",
|
"derive",
|
||||||
] }
|
] }
|
||||||
hash-db = "0.15.2"
|
hash-db = "0.15.2"
|
||||||
kvdb = "0.12.0"
|
kvdb = "0.13.0"
|
||||||
kvdb-memorydb = "0.12.0"
|
kvdb-memorydb = "0.13.0"
|
||||||
kvdb-rocksdb = { version = "0.16.0", optional = true }
|
kvdb-rocksdb = { version = "0.17.0", optional = true }
|
||||||
linked-hash-map = "0.5.4"
|
linked-hash-map = "0.5.4"
|
||||||
log = "0.4.17"
|
log = "0.4.17"
|
||||||
parity-db = "0.4.2"
|
parity-db = "0.4.2"
|
||||||
@@ -36,7 +36,7 @@ sp-trie = { version = "7.0.0", path = "../../primitives/trie" }
|
|||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
criterion = "0.3.3"
|
criterion = "0.3.3"
|
||||||
kvdb-rocksdb = "0.16.0"
|
kvdb-rocksdb = "0.17.0"
|
||||||
rand = "0.8.4"
|
rand = "0.8.4"
|
||||||
tempfile = "3.1.0"
|
tempfile = "3.1.0"
|
||||||
quickcheck = { version = "1.0.3", default-features = false }
|
quickcheck = { version = "1.0.3", default-features = false }
|
||||||
|
|||||||
@@ -2086,10 +2086,9 @@ impl<Block: BlockT> sc_client_api::backend::Backend<Block> for Backend<Block> {
|
|||||||
let state_cache = MemorySize::from_bytes(
|
let state_cache = MemorySize::from_bytes(
|
||||||
self.shared_trie_cache.as_ref().map_or(0, |c| c.used_memory_size()),
|
self.shared_trie_cache.as_ref().map_or(0, |c| c.used_memory_size()),
|
||||||
);
|
);
|
||||||
let state_db = self.storage.state_db.memory_info();
|
|
||||||
|
|
||||||
Some(UsageInfo {
|
Some(UsageInfo {
|
||||||
memory: MemoryInfo { state_cache, database_cache, state_db },
|
memory: MemoryInfo { state_cache, database_cache },
|
||||||
io: IoInfo {
|
io: IoInfo {
|
||||||
transactions: io_stats.transactions,
|
transactions: io_stats.transactions,
|
||||||
bytes_read: io_stats.bytes_read,
|
bytes_read: io_stats.bytes_read,
|
||||||
|
|||||||
@@ -59,15 +59,11 @@ pub struct Cache<B: BlockT> {
|
|||||||
|
|
||||||
struct LRUMap<K, V>(LinkedHashMap<K, V>, usize, usize);
|
struct LRUMap<K, V>(LinkedHashMap<K, V>, usize, usize);
|
||||||
|
|
||||||
/// Internal trait similar to `heapsize` but using
|
/// Internal trait similar to `heapsize` but using a simple estimation.
|
||||||
/// a simply estimation.
|
|
||||||
///
|
///
|
||||||
/// This should not be made public, it is implementation
|
/// This should not be made public, it is an implementation detail trait.
|
||||||
/// detail trait. If it need to become public please
|
|
||||||
/// consider using `malloc_size_of`.
|
|
||||||
trait EstimateSize {
|
trait EstimateSize {
|
||||||
/// Return a size estimation of additional size needed
|
/// Return a size estimation of the additional size needed to cache this struct (in bytes).
|
||||||
/// to cache this struct (in bytes).
|
|
||||||
fn estimate_size(&self) -> usize;
|
fn estimate_size(&self) -> usize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ ansi_term = "0.12.1"
|
|||||||
futures = "0.3.21"
|
futures = "0.3.21"
|
||||||
futures-timer = "3.0.1"
|
futures-timer = "3.0.1"
|
||||||
log = "0.4.17"
|
log = "0.4.17"
|
||||||
parity-util-mem = { version = "0.12.0", default-features = false, features = ["primitive-types"] }
|
|
||||||
sc-client-api = { version = "4.0.0-dev", path = "../api" }
|
sc-client-api = { version = "4.0.0-dev", path = "../api" }
|
||||||
sc-network-common = { version = "0.10.0-dev", path = "../network/common" }
|
sc-network-common = { version = "0.10.0-dev", path = "../network/common" }
|
||||||
sc-transaction-pool-api = { version = "4.0.0-dev", path = "../transaction-pool/api" }
|
sc-transaction-pool-api = { version = "4.0.0-dev", path = "../transaction-pool/api" }
|
||||||
|
|||||||
@@ -22,10 +22,8 @@ use ansi_term::Colour;
|
|||||||
use futures::prelude::*;
|
use futures::prelude::*;
|
||||||
use futures_timer::Delay;
|
use futures_timer::Delay;
|
||||||
use log::{debug, info, trace};
|
use log::{debug, info, trace};
|
||||||
use parity_util_mem::MallocSizeOf;
|
|
||||||
use sc_client_api::{BlockchainEvents, UsageProvider};
|
use sc_client_api::{BlockchainEvents, UsageProvider};
|
||||||
use sc_network_common::service::NetworkStatusProvider;
|
use sc_network_common::service::NetworkStatusProvider;
|
||||||
use sc_transaction_pool_api::TransactionPool;
|
|
||||||
use sp_blockchain::HeaderMetadata;
|
use sp_blockchain::HeaderMetadata;
|
||||||
use sp_runtime::traits::{Block as BlockT, Header};
|
use sp_runtime::traits::{Block as BlockT, Header};
|
||||||
use std::{collections::VecDeque, fmt::Display, sync::Arc, time::Duration};
|
use std::{collections::VecDeque, fmt::Display, sync::Arc, time::Duration};
|
||||||
@@ -53,16 +51,11 @@ impl Default for OutputFormat {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Builds the informant and returns a `Future` that drives the informant.
|
/// Builds the informant and returns a `Future` that drives the informant.
|
||||||
pub async fn build<B: BlockT, C, N, P>(
|
pub async fn build<B: BlockT, C, N>(client: Arc<C>, network: N, format: OutputFormat)
|
||||||
client: Arc<C>,
|
where
|
||||||
network: N,
|
|
||||||
pool: Arc<P>,
|
|
||||||
format: OutputFormat,
|
|
||||||
) where
|
|
||||||
N: NetworkStatusProvider<B>,
|
N: NetworkStatusProvider<B>,
|
||||||
C: UsageProvider<B> + HeaderMetadata<B> + BlockchainEvents<B>,
|
C: UsageProvider<B> + HeaderMetadata<B> + BlockchainEvents<B>,
|
||||||
<C as HeaderMetadata<B>>::Error: Display,
|
<C as HeaderMetadata<B>>::Error: Display,
|
||||||
P: TransactionPool + MallocSizeOf,
|
|
||||||
{
|
{
|
||||||
let mut display = display::InformantDisplay::new(format.clone());
|
let mut display = display::InformantDisplay::new(format.clone());
|
||||||
|
|
||||||
@@ -83,11 +76,6 @@ pub async fn build<B: BlockT, C, N, P>(
|
|||||||
"Usage statistics not displayed as backend does not provide it",
|
"Usage statistics not displayed as backend does not provide it",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
trace!(
|
|
||||||
target: "usage",
|
|
||||||
"Subsystems memory [txpool: {} kB]",
|
|
||||||
parity_util_mem::malloc_size(&*pool) / 1024,
|
|
||||||
);
|
|
||||||
display.display(&info, net_status);
|
display.display(&info, net_status);
|
||||||
future::ready(())
|
future::ready(())
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -80,9 +80,6 @@ sp-tracing = { version = "6.0.0", path = "../../primitives/tracing" }
|
|||||||
sc-sysinfo = { version = "6.0.0-dev", path = "../sysinfo" }
|
sc-sysinfo = { version = "6.0.0-dev", path = "../sysinfo" }
|
||||||
tracing = "0.1.29"
|
tracing = "0.1.29"
|
||||||
tracing-futures = { version = "0.2.4" }
|
tracing-futures = { version = "0.2.4" }
|
||||||
parity-util-mem = { version = "0.12.0", default-features = false, features = [
|
|
||||||
"primitive-types",
|
|
||||||
] }
|
|
||||||
async-trait = "0.1.57"
|
async-trait = "0.1.57"
|
||||||
tokio = { version = "1.22.0", features = ["time", "rt-multi-thread", "parking_lot"] }
|
tokio = { version = "1.22.0", features = ["time", "rt-multi-thread", "parking_lot"] }
|
||||||
tempfile = "3.1.0"
|
tempfile = "3.1.0"
|
||||||
|
|||||||
@@ -436,9 +436,7 @@ where
|
|||||||
TBl::Hash: Unpin,
|
TBl::Hash: Unpin,
|
||||||
TBl::Header: Unpin,
|
TBl::Header: Unpin,
|
||||||
TBackend: 'static + sc_client_api::backend::Backend<TBl> + Send,
|
TBackend: 'static + sc_client_api::backend::Backend<TBl> + Send,
|
||||||
TExPool: MaintainedTransactionPool<Block = TBl, Hash = <TBl as BlockT>::Hash>
|
TExPool: MaintainedTransactionPool<Block = TBl, Hash = <TBl as BlockT>::Hash> + 'static,
|
||||||
+ parity_util_mem::MallocSizeOf
|
|
||||||
+ 'static,
|
|
||||||
{
|
{
|
||||||
let SpawnTasksParams {
|
let SpawnTasksParams {
|
||||||
mut config,
|
mut config,
|
||||||
@@ -540,12 +538,7 @@ where
|
|||||||
spawn_handle.spawn(
|
spawn_handle.spawn(
|
||||||
"informant",
|
"informant",
|
||||||
None,
|
None,
|
||||||
sc_informant::build(
|
sc_informant::build(client.clone(), network, config.informant_output_format),
|
||||||
client.clone(),
|
|
||||||
network,
|
|
||||||
transaction_pool.clone(),
|
|
||||||
config.informant_output_format,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
task_manager.keep_alive((config.base_path, rpc));
|
task_manager.keep_alive((config.base_path, rpc));
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ struct PrometheusMetrics {
|
|||||||
// I/O
|
// I/O
|
||||||
database_cache: Gauge<U64>,
|
database_cache: Gauge<U64>,
|
||||||
state_cache: Gauge<U64>,
|
state_cache: Gauge<U64>,
|
||||||
state_db: GaugeVec<U64>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PrometheusMetrics {
|
impl PrometheusMetrics {
|
||||||
@@ -117,13 +116,6 @@ impl PrometheusMetrics {
|
|||||||
Gauge::new("substrate_state_cache_bytes", "State cache size in bytes")?,
|
Gauge::new("substrate_state_cache_bytes", "State cache size in bytes")?,
|
||||||
registry,
|
registry,
|
||||||
)?,
|
)?,
|
||||||
state_db: register(
|
|
||||||
GaugeVec::new(
|
|
||||||
Opts::new("substrate_state_db_cache_bytes", "State DB cache in bytes"),
|
|
||||||
&["subtype"],
|
|
||||||
)?,
|
|
||||||
registry,
|
|
||||||
)?,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -254,18 +246,6 @@ impl MetricsService {
|
|||||||
if let Some(info) = info.usage.as_ref() {
|
if let Some(info) = info.usage.as_ref() {
|
||||||
metrics.database_cache.set(info.memory.database_cache.as_bytes() as u64);
|
metrics.database_cache.set(info.memory.database_cache.as_bytes() as u64);
|
||||||
metrics.state_cache.set(info.memory.state_cache.as_bytes() as u64);
|
metrics.state_cache.set(info.memory.state_cache.as_bytes() as u64);
|
||||||
|
|
||||||
metrics
|
|
||||||
.state_db
|
|
||||||
.with_label_values(&["non_canonical"])
|
|
||||||
.set(info.memory.state_db.non_canonical.as_bytes() as u64);
|
|
||||||
if let Some(pruning) = info.memory.state_db.pruning {
|
|
||||||
metrics.state_db.with_label_values(&["pruning"]).set(pruning.as_bytes() as u64);
|
|
||||||
}
|
|
||||||
metrics
|
|
||||||
.state_db
|
|
||||||
.with_label_values(&["pinned"])
|
|
||||||
.set(info.memory.state_db.pinned.as_bytes() as u64);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,8 +15,6 @@ targets = ["x86_64-unknown-linux-gnu"]
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
codec = { package = "parity-scale-codec", version = "3.0.0", features = ["derive"] }
|
codec = { package = "parity-scale-codec", version = "3.0.0", features = ["derive"] }
|
||||||
log = "0.4.17"
|
log = "0.4.17"
|
||||||
parity-util-mem = { version = "0.12.0", default-features = false, features = ["primitive-types"] }
|
|
||||||
parity-util-mem-derive = "0.1.0"
|
|
||||||
parking_lot = "0.12.1"
|
parking_lot = "0.12.1"
|
||||||
sc-client-api = { version = "4.0.0-dev", path = "../api" }
|
sc-client-api = { version = "4.0.0-dev", path = "../api" }
|
||||||
sp-core = { version = "7.0.0", path = "../../primitives/core" }
|
sp-core = { version = "7.0.0", path = "../../primitives/core" }
|
||||||
|
|||||||
@@ -49,10 +49,8 @@ mod test;
|
|||||||
use codec::Codec;
|
use codec::Codec;
|
||||||
use log::trace;
|
use log::trace;
|
||||||
use noncanonical::NonCanonicalOverlay;
|
use noncanonical::NonCanonicalOverlay;
|
||||||
use parity_util_mem::{malloc_size, MallocSizeOf};
|
|
||||||
use parking_lot::RwLock;
|
use parking_lot::RwLock;
|
||||||
use pruning::{HaveBlock, RefWindow};
|
use pruning::{HaveBlock, RefWindow};
|
||||||
use sc_client_api::{MemorySize, StateDbMemoryInfo};
|
|
||||||
use std::{
|
use std::{
|
||||||
collections::{hash_map::Entry, HashMap},
|
collections::{hash_map::Entry, HashMap},
|
||||||
fmt,
|
fmt,
|
||||||
@@ -220,8 +218,6 @@ pub struct Constraints {
|
|||||||
/// Maximum blocks. Defaults to 0 when unspecified, effectively keeping only non-canonical
|
/// Maximum blocks. Defaults to 0 when unspecified, effectively keeping only non-canonical
|
||||||
/// states.
|
/// states.
|
||||||
pub max_blocks: Option<u32>,
|
pub max_blocks: Option<u32>,
|
||||||
/// Maximum memory in the pruning overlay.
|
|
||||||
pub max_mem: Option<usize>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Pruning mode.
|
/// Pruning mode.
|
||||||
@@ -238,7 +234,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 blocks_pruning(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) })
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Is this an archive (either ArchiveAll or ArchiveCanonical) pruning mode?
|
/// Is this an archive (either ArchiveAll or ArchiveCanonical) pruning mode?
|
||||||
@@ -276,7 +272,7 @@ impl Default for PruningMode {
|
|||||||
|
|
||||||
impl Default for Constraints {
|
impl Default for Constraints {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self { max_blocks: Some(DEFAULT_MAX_BLOCK_CONSTRAINT), max_mem: None }
|
Self { max_blocks: Some(DEFAULT_MAX_BLOCK_CONSTRAINT) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -294,9 +290,7 @@ pub struct StateDbSync<BlockHash: Hash, Key: Hash, D: MetaDb> {
|
|||||||
ref_counting: bool,
|
ref_counting: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<BlockHash: Hash + MallocSizeOf, Key: Hash + MallocSizeOf, D: MetaDb>
|
impl<BlockHash: Hash, Key: Hash, D: MetaDb> StateDbSync<BlockHash, Key, D> {
|
||||||
StateDbSync<BlockHash, Key, D>
|
|
||||||
{
|
|
||||||
fn new(
|
fn new(
|
||||||
mode: PruningMode,
|
mode: PruningMode,
|
||||||
ref_counting: bool,
|
ref_counting: bool,
|
||||||
@@ -306,8 +300,7 @@ impl<BlockHash: Hash + MallocSizeOf, Key: Hash + MallocSizeOf, D: MetaDb>
|
|||||||
|
|
||||||
let non_canonical: NonCanonicalOverlay<BlockHash, Key> = NonCanonicalOverlay::new(&db)?;
|
let non_canonical: NonCanonicalOverlay<BlockHash, Key> = NonCanonicalOverlay::new(&db)?;
|
||||||
let pruning: Option<RefWindow<BlockHash, Key, D>> = match mode {
|
let pruning: Option<RefWindow<BlockHash, Key, D>> = match mode {
|
||||||
PruningMode::Constrained(Constraints { max_mem: Some(_), .. }) => unimplemented!(),
|
PruningMode::Constrained(Constraints { max_blocks }) =>
|
||||||
PruningMode::Constrained(Constraints { max_blocks, .. }) =>
|
|
||||||
Some(RefWindow::new(db, max_blocks.unwrap_or(0), ref_counting)?),
|
Some(RefWindow::new(db, max_blocks.unwrap_or(0), ref_counting)?),
|
||||||
PruningMode::ArchiveAll | PruningMode::ArchiveCanonical => None,
|
PruningMode::ArchiveAll | PruningMode::ArchiveCanonical => None,
|
||||||
};
|
};
|
||||||
@@ -392,10 +385,6 @@ impl<BlockHash: Hash + MallocSizeOf, Key: Hash + MallocSizeOf, D: MetaDb>
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
if constraints.max_mem.map_or(false, |m| pruning.mem_used() > m) {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
let pinned = &self.pinned;
|
let pinned = &self.pinned;
|
||||||
match pruning.next_hash() {
|
match pruning.next_hash() {
|
||||||
// the block record is temporary unavailable, break and try next time
|
// the block record is temporary unavailable, break and try next time
|
||||||
@@ -496,14 +485,6 @@ impl<BlockHash: Hash + MallocSizeOf, Key: Hash + MallocSizeOf, D: MetaDb>
|
|||||||
}
|
}
|
||||||
db.get(key.as_ref()).map_err(Error::Db)
|
db.get(key.as_ref()).map_err(Error::Db)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn memory_info(&self) -> StateDbMemoryInfo {
|
|
||||||
StateDbMemoryInfo {
|
|
||||||
non_canonical: MemorySize::from_bytes(malloc_size(&self.non_canonical)),
|
|
||||||
pruning: self.pruning.as_ref().map(|p| MemorySize::from_bytes(malloc_size(&p))),
|
|
||||||
pinned: MemorySize::from_bytes(malloc_size(&self.pinned)),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// State DB maintenance. See module description.
|
/// State DB maintenance. See module description.
|
||||||
@@ -512,9 +493,7 @@ pub struct StateDb<BlockHash: Hash, Key: Hash, D: MetaDb> {
|
|||||||
db: RwLock<StateDbSync<BlockHash, Key, D>>,
|
db: RwLock<StateDbSync<BlockHash, Key, D>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<BlockHash: Hash + MallocSizeOf, Key: Hash + MallocSizeOf, D: MetaDb>
|
impl<BlockHash: Hash, Key: Hash, D: MetaDb> StateDb<BlockHash, Key, D> {
|
||||||
StateDb<BlockHash, Key, D>
|
|
||||||
{
|
|
||||||
/// Create an instance of [`StateDb`].
|
/// Create an instance of [`StateDb`].
|
||||||
pub fn open(
|
pub fn open(
|
||||||
db: D,
|
db: D,
|
||||||
@@ -637,11 +616,6 @@ impl<BlockHash: Hash + MallocSizeOf, Key: Hash + MallocSizeOf, D: MetaDb>
|
|||||||
*state_db = StateDbSync::new(state_db.mode.clone(), state_db.ref_counting, db)?;
|
*state_db = StateDbSync::new(state_db.mode.clone(), state_db.ref_counting, db)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the current memory statistics of this instance.
|
|
||||||
pub fn memory_info(&self) -> StateDbMemoryInfo {
|
|
||||||
self.db.read().memory_info()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The result return by `StateDb::is_pruned`
|
/// The result return by `StateDb::is_pruned`
|
||||||
@@ -772,10 +746,8 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn block_record_unavailable() {
|
fn block_record_unavailable() {
|
||||||
let (mut db, state_db) = make_test_db(PruningMode::Constrained(Constraints {
|
let (mut db, state_db) =
|
||||||
max_blocks: Some(1),
|
make_test_db(PruningMode::Constrained(Constraints { max_blocks: Some(1) }));
|
||||||
max_mem: None,
|
|
||||||
}));
|
|
||||||
// import 2 blocks
|
// import 2 blocks
|
||||||
for i in &[5, 6] {
|
for i in &[5, 6] {
|
||||||
db.commit(
|
db.commit(
|
||||||
@@ -809,19 +781,13 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn prune_window_0() {
|
fn prune_window_0() {
|
||||||
let (db, _) = make_test_db(PruningMode::Constrained(Constraints {
|
let (db, _) = make_test_db(PruningMode::Constrained(Constraints { max_blocks: Some(0) }));
|
||||||
max_blocks: Some(0),
|
|
||||||
max_mem: None,
|
|
||||||
}));
|
|
||||||
assert!(db.data_eq(&make_db(&[21, 3, 922, 94])));
|
assert!(db.data_eq(&make_db(&[21, 3, 922, 94])));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn prune_window_1() {
|
fn prune_window_1() {
|
||||||
let (db, sdb) = make_test_db(PruningMode::Constrained(Constraints {
|
let (db, sdb) = make_test_db(PruningMode::Constrained(Constraints { max_blocks: Some(1) }));
|
||||||
max_blocks: Some(1),
|
|
||||||
max_mem: None,
|
|
||||||
}));
|
|
||||||
assert_eq!(sdb.is_pruned(&H256::from_low_u64_be(0), 0), IsPruned::Pruned);
|
assert_eq!(sdb.is_pruned(&H256::from_low_u64_be(0), 0), IsPruned::Pruned);
|
||||||
assert_eq!(sdb.is_pruned(&H256::from_low_u64_be(1), 1), IsPruned::Pruned);
|
assert_eq!(sdb.is_pruned(&H256::from_low_u64_be(1), 1), IsPruned::Pruned);
|
||||||
assert_eq!(sdb.is_pruned(&H256::from_low_u64_be(21), 2), IsPruned::Pruned);
|
assert_eq!(sdb.is_pruned(&H256::from_low_u64_be(21), 2), IsPruned::Pruned);
|
||||||
@@ -831,10 +797,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn prune_window_2() {
|
fn prune_window_2() {
|
||||||
let (db, sdb) = make_test_db(PruningMode::Constrained(Constraints {
|
let (db, sdb) = make_test_db(PruningMode::Constrained(Constraints { max_blocks: Some(2) }));
|
||||||
max_blocks: Some(2),
|
|
||||||
max_mem: None,
|
|
||||||
}));
|
|
||||||
assert_eq!(sdb.is_pruned(&H256::from_low_u64_be(0), 0), IsPruned::Pruned);
|
assert_eq!(sdb.is_pruned(&H256::from_low_u64_be(0), 0), IsPruned::Pruned);
|
||||||
assert_eq!(sdb.is_pruned(&H256::from_low_u64_be(1), 1), IsPruned::Pruned);
|
assert_eq!(sdb.is_pruned(&H256::from_low_u64_be(1), 1), IsPruned::Pruned);
|
||||||
assert_eq!(sdb.is_pruned(&H256::from_low_u64_be(21), 2), IsPruned::NotPruned);
|
assert_eq!(sdb.is_pruned(&H256::from_low_u64_be(21), 2), IsPruned::NotPruned);
|
||||||
@@ -858,7 +821,7 @@ mod tests {
|
|||||||
)
|
)
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
);
|
);
|
||||||
let new_mode = PruningMode::Constrained(Constraints { max_blocks: Some(2), max_mem: None });
|
let new_mode = PruningMode::Constrained(Constraints { max_blocks: Some(2) });
|
||||||
let state_db_open_result: Result<(_, StateDb<H256, H256, TestDb>), _> =
|
let state_db_open_result: Result<(_, StateDb<H256, H256, TestDb>), _> =
|
||||||
StateDb::open(db.clone(), Some(new_mode), false, false);
|
StateDb::open(db.clone(), Some(new_mode), false, false);
|
||||||
assert!(state_db_open_result.is_err());
|
assert!(state_db_open_result.is_err());
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ pub(crate) const LAST_CANONICAL: &[u8] = b"last_canonical";
|
|||||||
const MAX_BLOCKS_PER_LEVEL: u64 = 32;
|
const MAX_BLOCKS_PER_LEVEL: u64 = 32;
|
||||||
|
|
||||||
/// See module documentation.
|
/// See module documentation.
|
||||||
#[derive(parity_util_mem_derive::MallocSizeOf)]
|
|
||||||
pub struct NonCanonicalOverlay<BlockHash: Hash, Key: Hash> {
|
pub struct NonCanonicalOverlay<BlockHash: Hash, Key: Hash> {
|
||||||
last_canonicalized: Option<(BlockHash, u64)>,
|
last_canonicalized: Option<(BlockHash, u64)>,
|
||||||
levels: VecDeque<OverlayLevel<BlockHash, Key>>,
|
levels: VecDeque<OverlayLevel<BlockHash, Key>>,
|
||||||
@@ -41,7 +40,6 @@ pub struct NonCanonicalOverlay<BlockHash: Hash, Key: Hash> {
|
|||||||
pinned_insertions: HashMap<BlockHash, (Vec<Key>, u32)>,
|
pinned_insertions: HashMap<BlockHash, (Vec<Key>, u32)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(parity_util_mem_derive::MallocSizeOf)]
|
|
||||||
#[cfg_attr(test, derive(PartialEq, Debug))]
|
#[cfg_attr(test, derive(PartialEq, Debug))]
|
||||||
struct OverlayLevel<BlockHash: Hash, Key: Hash> {
|
struct OverlayLevel<BlockHash: Hash, Key: Hash> {
|
||||||
blocks: Vec<BlockOverlay<BlockHash, Key>>,
|
blocks: Vec<BlockOverlay<BlockHash, Key>>,
|
||||||
@@ -81,7 +79,6 @@ fn to_journal_key(block: u64, index: u64) -> Vec<u8> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(test, derive(PartialEq, Debug))]
|
#[cfg_attr(test, derive(PartialEq, Debug))]
|
||||||
#[derive(parity_util_mem_derive::MallocSizeOf)]
|
|
||||||
struct BlockOverlay<BlockHash: Hash, Key: Hash> {
|
struct BlockOverlay<BlockHash: Hash, Key: Hash> {
|
||||||
hash: BlockHash,
|
hash: BlockHash,
|
||||||
journal_index: u64,
|
journal_index: u64,
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ pub(crate) const LAST_PRUNED: &[u8] = b"last_pruned";
|
|||||||
const PRUNING_JOURNAL: &[u8] = b"pruning_journal";
|
const PRUNING_JOURNAL: &[u8] = b"pruning_journal";
|
||||||
|
|
||||||
/// See module documentation.
|
/// See module documentation.
|
||||||
#[derive(parity_util_mem_derive::MallocSizeOf)]
|
|
||||||
pub struct RefWindow<BlockHash: Hash, Key: Hash, D: MetaDb> {
|
pub struct RefWindow<BlockHash: Hash, Key: Hash, D: MetaDb> {
|
||||||
/// A queue of blocks keep tracking keys that should be deleted for each block in the
|
/// A queue of blocks keep tracking keys that should be deleted for each block in the
|
||||||
/// pruning window.
|
/// pruning window.
|
||||||
@@ -50,7 +49,6 @@ pub struct RefWindow<BlockHash: Hash, Key: Hash, D: MetaDb> {
|
|||||||
/// blocks in memory, and keep track of re-inserted keys to not delete them when pruning
|
/// blocks in memory, and keep track of re-inserted keys to not delete them when pruning
|
||||||
/// - `DbBacked`, used when the backend database supports reference counting, only keep
|
/// - `DbBacked`, used when the backend database supports reference counting, only keep
|
||||||
/// a few number of blocks in memory and load more blocks on demand
|
/// a few number of blocks in memory and load more blocks on demand
|
||||||
#[derive(parity_util_mem_derive::MallocSizeOf)]
|
|
||||||
enum DeathRowQueue<BlockHash: Hash, Key: Hash, D: MetaDb> {
|
enum DeathRowQueue<BlockHash: Hash, Key: Hash, D: MetaDb> {
|
||||||
Mem {
|
Mem {
|
||||||
/// A queue of keys that should be deleted for each block in the pruning window.
|
/// A queue of keys that should be deleted for each block in the pruning window.
|
||||||
@@ -60,7 +58,6 @@ enum DeathRowQueue<BlockHash: Hash, Key: Hash, D: MetaDb> {
|
|||||||
},
|
},
|
||||||
DbBacked {
|
DbBacked {
|
||||||
// The backend database
|
// The backend database
|
||||||
#[ignore_malloc_size_of = "Shared data"]
|
|
||||||
db: D,
|
db: D,
|
||||||
/// A queue of keys that should be deleted for each block in the pruning window.
|
/// A queue of keys that should be deleted for each block in the pruning window.
|
||||||
/// Only caching the first few blocks of the pruning window, blocks inside are
|
/// Only caching the first few blocks of the pruning window, blocks inside are
|
||||||
@@ -251,7 +248,7 @@ fn load_death_row_from_db<BlockHash: Hash, Key: Hash, D: MetaDb>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, parity_util_mem_derive::MallocSizeOf)]
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||||
struct DeathRow<BlockHash: Hash, Key: Hash> {
|
struct DeathRow<BlockHash: Hash, Key: Hash> {
|
||||||
hash: BlockHash,
|
hash: BlockHash,
|
||||||
deleted: HashSet<Key>,
|
deleted: HashSet<Key>,
|
||||||
@@ -345,10 +342,6 @@ impl<BlockHash: Hash, Key: Hash, D: MetaDb> RefWindow<BlockHash, Key, D> {
|
|||||||
Ok(res)
|
Ok(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn mem_used(&self) -> usize {
|
|
||||||
0
|
|
||||||
}
|
|
||||||
|
|
||||||
fn is_empty(&self) -> bool {
|
fn is_empty(&self) -> bool {
|
||||||
self.window_size() == 0
|
self.window_size() == 0
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ futures = "0.3.21"
|
|||||||
futures-timer = "3.0.2"
|
futures-timer = "3.0.2"
|
||||||
linked-hash-map = "0.5.4"
|
linked-hash-map = "0.5.4"
|
||||||
log = "0.4.17"
|
log = "0.4.17"
|
||||||
parity-util-mem = { version = "0.12.0", default-features = false, features = ["primitive-types"] }
|
|
||||||
parking_lot = "0.12.1"
|
parking_lot = "0.12.1"
|
||||||
serde = { version = "1.0.136", features = ["derive"] }
|
serde = { version = "1.0.136", features = ["derive"] }
|
||||||
thiserror = "1.0.30"
|
thiserror = "1.0.30"
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ pub struct PruneStatus<Hash, Ex> {
|
|||||||
|
|
||||||
/// Immutable transaction
|
/// Immutable transaction
|
||||||
#[cfg_attr(test, derive(Clone))]
|
#[cfg_attr(test, derive(Clone))]
|
||||||
#[derive(PartialEq, Eq, parity_util_mem::MallocSizeOf)]
|
#[derive(PartialEq, Eq)]
|
||||||
pub struct Transaction<Hash, Extrinsic> {
|
pub struct Transaction<Hash, Extrinsic> {
|
||||||
/// Raw extrinsic representing that transaction.
|
/// Raw extrinsic representing that transaction.
|
||||||
pub data: Extrinsic,
|
pub data: Extrinsic,
|
||||||
@@ -207,7 +207,7 @@ const RECENTLY_PRUNED_TAGS: usize = 2;
|
|||||||
/// as-is for the second time will fail or produce unwanted results.
|
/// as-is for the second time will fail or produce unwanted results.
|
||||||
/// Most likely it is required to revalidate them and recompute set of
|
/// Most likely it is required to revalidate them and recompute set of
|
||||||
/// required tags.
|
/// required tags.
|
||||||
#[derive(Debug, parity_util_mem::MallocSizeOf)]
|
#[derive(Debug)]
|
||||||
pub struct BasePool<Hash: hash::Hash + Eq, Ex> {
|
pub struct BasePool<Hash: hash::Hash + Eq, Ex> {
|
||||||
reject_future_transactions: bool,
|
reject_future_transactions: bool,
|
||||||
future: FutureTransactions<Hash, Ex>,
|
future: FutureTransactions<Hash, Ex>,
|
||||||
@@ -796,27 +796,6 @@ mod tests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn can_track_heap_size() {
|
|
||||||
let mut pool = pool();
|
|
||||||
pool.import(Transaction {
|
|
||||||
data: vec![5u8; 1024],
|
|
||||||
hash: 5,
|
|
||||||
provides: vec![vec![0], vec![4]],
|
|
||||||
..DEFAULT_TX.clone()
|
|
||||||
})
|
|
||||||
.expect("import 1 should be ok");
|
|
||||||
pool.import(Transaction {
|
|
||||||
data: vec![3u8; 1024],
|
|
||||||
hash: 7,
|
|
||||||
provides: vec![vec![2], vec![7]],
|
|
||||||
..DEFAULT_TX.clone()
|
|
||||||
})
|
|
||||||
.expect("import 2 should be ok");
|
|
||||||
|
|
||||||
assert!(parity_util_mem::malloc_size(&pool) > 5000);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn should_remove_invalid_transactions() {
|
fn should_remove_invalid_transactions() {
|
||||||
// given
|
// given
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ use std::time::Instant;
|
|||||||
|
|
||||||
use super::base_pool::Transaction;
|
use super::base_pool::Transaction;
|
||||||
|
|
||||||
#[derive(parity_util_mem::MallocSizeOf)]
|
|
||||||
/// Transaction with partially satisfied dependencies.
|
/// Transaction with partially satisfied dependencies.
|
||||||
pub struct WaitingTransaction<Hash, Ex> {
|
pub struct WaitingTransaction<Hash, Ex> {
|
||||||
/// Transaction details.
|
/// Transaction details.
|
||||||
@@ -108,7 +107,7 @@ impl<Hash, Ex> WaitingTransaction<Hash, Ex> {
|
|||||||
///
|
///
|
||||||
/// Contains transactions that are still awaiting for some other transactions that
|
/// Contains transactions that are still awaiting for some other transactions that
|
||||||
/// could provide a tag that they require.
|
/// could provide a tag that they require.
|
||||||
#[derive(Debug, parity_util_mem::MallocSizeOf)]
|
#[derive(Debug)]
|
||||||
pub struct FutureTransactions<Hash: hash::Hash + Eq, Ex> {
|
pub struct FutureTransactions<Hash: hash::Hash + Eq, Ex> {
|
||||||
/// tags that are not yet provided by any transaction and we await for them
|
/// tags that are not yet provided by any transaction and we await for them
|
||||||
wanted_tags: HashMap<Tag, HashSet<Hash>>,
|
wanted_tags: HashMap<Tag, HashSet<Hash>>,
|
||||||
@@ -251,33 +250,3 @@ impl<Hash: hash::Hash + Eq + Clone, Ex> FutureTransactions<Hash, Ex> {
|
|||||||
self.waiting.values().fold(0, |acc, tx| acc + tx.transaction.bytes)
|
self.waiting.values().fold(0, |acc, tx| acc + tx.transaction.bytes)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use super::*;
|
|
||||||
use sp_runtime::transaction_validity::TransactionSource;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn can_track_heap_size() {
|
|
||||||
let mut future = FutureTransactions::default();
|
|
||||||
future.import(WaitingTransaction {
|
|
||||||
transaction: Transaction {
|
|
||||||
data: vec![0u8; 1024],
|
|
||||||
bytes: 1,
|
|
||||||
hash: 1,
|
|
||||||
priority: 1,
|
|
||||||
valid_till: 2,
|
|
||||||
requires: vec![vec![1], vec![2]],
|
|
||||||
provides: vec![vec![3], vec![4]],
|
|
||||||
propagate: true,
|
|
||||||
source: TransactionSource::External,
|
|
||||||
}
|
|
||||||
.into(),
|
|
||||||
missing_tags: vec![vec![1u8], vec![2u8]].into_iter().collect(),
|
|
||||||
imported_at: std::time::Instant::now(),
|
|
||||||
});
|
|
||||||
|
|
||||||
// data is at least 1024!
|
|
||||||
assert!(parity_util_mem::malloc_size(&future) > 1024);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -144,15 +144,6 @@ pub struct Pool<B: ChainApi> {
|
|||||||
validated_pool: Arc<ValidatedPool<B>>,
|
validated_pool: Arc<ValidatedPool<B>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<B: ChainApi> parity_util_mem::MallocSizeOf for Pool<B>
|
|
||||||
where
|
|
||||||
ExtrinsicFor<B>: parity_util_mem::MallocSizeOf,
|
|
||||||
{
|
|
||||||
fn size_of(&self, ops: &mut parity_util_mem::MallocSizeOfOps) -> usize {
|
|
||||||
self.validated_pool.size_of(ops)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<B: ChainApi> Pool<B> {
|
impl<B: ChainApi> Pool<B> {
|
||||||
/// Create a new transaction pool.
|
/// Create a new transaction pool.
|
||||||
pub fn new(options: Options, is_validator: IsValidator, api: Arc<B>) -> Self {
|
pub fn new(options: Options, is_validator: IsValidator, api: Arc<B>) -> Self {
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ use super::{
|
|||||||
/// An in-pool transaction reference.
|
/// An in-pool transaction reference.
|
||||||
///
|
///
|
||||||
/// Should be cheap to clone.
|
/// Should be cheap to clone.
|
||||||
#[derive(Debug, parity_util_mem::MallocSizeOf)]
|
#[derive(Debug)]
|
||||||
pub struct TransactionRef<Hash, Ex> {
|
pub struct TransactionRef<Hash, Ex> {
|
||||||
/// The actual transaction data.
|
/// The actual transaction data.
|
||||||
pub transaction: Arc<Transaction<Hash, Ex>>,
|
pub transaction: Arc<Transaction<Hash, Ex>>,
|
||||||
@@ -74,7 +74,7 @@ impl<Hash, Ex> PartialEq for TransactionRef<Hash, Ex> {
|
|||||||
}
|
}
|
||||||
impl<Hash, Ex> Eq for TransactionRef<Hash, Ex> {}
|
impl<Hash, Ex> Eq for TransactionRef<Hash, Ex> {}
|
||||||
|
|
||||||
#[derive(Debug, parity_util_mem::MallocSizeOf)]
|
#[derive(Debug)]
|
||||||
pub struct ReadyTx<Hash, Ex> {
|
pub struct ReadyTx<Hash, Ex> {
|
||||||
/// A reference to a transaction
|
/// A reference to a transaction
|
||||||
pub transaction: TransactionRef<Hash, Ex>,
|
pub transaction: TransactionRef<Hash, Ex>,
|
||||||
@@ -105,7 +105,7 @@ qed
|
|||||||
"#;
|
"#;
|
||||||
|
|
||||||
/// Validated transactions that are block ready with all their dependencies met.
|
/// Validated transactions that are block ready with all their dependencies met.
|
||||||
#[derive(Debug, parity_util_mem::MallocSizeOf)]
|
#[derive(Debug)]
|
||||||
pub struct ReadyTransactions<Hash: hash::Hash + Eq, Ex> {
|
pub struct ReadyTransactions<Hash: hash::Hash + Eq, Ex> {
|
||||||
/// Next free insertion id (used to indicate when a transaction was inserted into the pool).
|
/// Next free insertion id (used to indicate when a transaction was inserted into the pool).
|
||||||
insertion_id: u64,
|
insertion_id: u64,
|
||||||
@@ -742,25 +742,6 @@ mod tests {
|
|||||||
assert_eq!(it.next(), None);
|
assert_eq!(it.next(), None);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn can_report_heap_size() {
|
|
||||||
let mut ready = ReadyTransactions::default();
|
|
||||||
let tx = Transaction {
|
|
||||||
data: vec![5],
|
|
||||||
bytes: 1,
|
|
||||||
hash: 5,
|
|
||||||
priority: 1,
|
|
||||||
valid_till: u64::MAX, // use the max here for testing.
|
|
||||||
requires: vec![],
|
|
||||||
provides: vec![],
|
|
||||||
propagate: true,
|
|
||||||
source: Source::External,
|
|
||||||
};
|
|
||||||
import(&mut ready, tx).unwrap();
|
|
||||||
|
|
||||||
assert!(parity_util_mem::malloc_size(&ready) > 200);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn should_order_refs() {
|
fn should_order_refs() {
|
||||||
let mut id = 1;
|
let mut id = 1;
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ pub trait Size {
|
|||||||
/// Map with size tracking.
|
/// Map with size tracking.
|
||||||
///
|
///
|
||||||
/// Size reported might be slightly off and only approximately true.
|
/// Size reported might be slightly off and only approximately true.
|
||||||
#[derive(Debug, parity_util_mem::MallocSizeOf)]
|
#[derive(Debug)]
|
||||||
pub struct TrackedMap<K, V> {
|
pub struct TrackedMap<K, V> {
|
||||||
index: Arc<RwLock<HashMap<K, V>>>,
|
index: Arc<RwLock<HashMap<K, V>>>,
|
||||||
bytes: AtomicIsize,
|
bytes: AtomicIsize,
|
||||||
|
|||||||
@@ -110,16 +110,6 @@ pub struct ValidatedPool<B: ChainApi> {
|
|||||||
rotator: PoolRotator<ExtrinsicHash<B>>,
|
rotator: PoolRotator<ExtrinsicHash<B>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<B: ChainApi> parity_util_mem::MallocSizeOf for ValidatedPool<B>
|
|
||||||
where
|
|
||||||
ExtrinsicFor<B>: parity_util_mem::MallocSizeOf,
|
|
||||||
{
|
|
||||||
fn size_of(&self, ops: &mut parity_util_mem::MallocSizeOfOps) -> usize {
|
|
||||||
// other entries insignificant or non-primary references
|
|
||||||
self.pool.size_of(ops)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<B: ChainApi> ValidatedPool<B> {
|
impl<B: ChainApi> ValidatedPool<B> {
|
||||||
/// Create a new transaction pool.
|
/// Create a new transaction pool.
|
||||||
pub fn new(options: Options, is_validator: IsValidator, api: Arc<B>) -> Self {
|
pub fn new(options: Options, is_validator: IsValidator, api: Arc<B>) -> Self {
|
||||||
|
|||||||
@@ -135,17 +135,6 @@ impl<T, Block: BlockT> ReadyPoll<T, Block> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<PoolApi, Block> parity_util_mem::MallocSizeOf for BasicPool<PoolApi, Block>
|
|
||||||
where
|
|
||||||
PoolApi: graph::ChainApi<Block = Block>,
|
|
||||||
Block: BlockT,
|
|
||||||
{
|
|
||||||
fn size_of(&self, ops: &mut parity_util_mem::MallocSizeOfOps) -> usize {
|
|
||||||
// other entries insignificant or non-primary references
|
|
||||||
self.pool.size_of(ops)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Type of revalidation.
|
/// Type of revalidation.
|
||||||
pub enum RevalidationType {
|
pub enum RevalidationType {
|
||||||
/// Light revalidation type.
|
/// Light revalidation type.
|
||||||
|
|||||||
@@ -440,17 +440,6 @@ fn should_push_watchers_during_maintenance() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn can_track_heap_size() {
|
|
||||||
let (pool, _api, _guard) = maintained_pool();
|
|
||||||
block_on(pool.submit_one(&BlockId::number(0), SOURCE, uxt(Alice, 209))).expect("1. Imported");
|
|
||||||
block_on(pool.submit_one(&BlockId::number(0), SOURCE, uxt(Alice, 210))).expect("1. Imported");
|
|
||||||
block_on(pool.submit_one(&BlockId::number(0), SOURCE, uxt(Alice, 211))).expect("1. Imported");
|
|
||||||
block_on(pool.submit_one(&BlockId::number(0), SOURCE, uxt(Alice, 212))).expect("1. Imported");
|
|
||||||
|
|
||||||
assert!(parity_util_mem::malloc_size(&pool) > 3000);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn finalization() {
|
fn finalization() {
|
||||||
let xt = uxt(Alice, 209);
|
let xt = uxt(Alice, 209);
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ serde_json = "1.0.85"
|
|||||||
assert_matches = "1.3.0"
|
assert_matches = "1.3.0"
|
||||||
pretty_assertions = "1.2.1"
|
pretty_assertions = "1.2.1"
|
||||||
frame-system = { version = "4.0.0-dev", path = "../system" }
|
frame-system = { version = "4.0.0-dev", path = "../system" }
|
||||||
parity-util-mem = { version = "0.12.0", default-features = false, features = ["primitive-types"] }
|
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["std"]
|
default = ["std"]
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ use sp_runtime::{
|
|||||||
generic,
|
generic,
|
||||||
traits::{
|
traits::{
|
||||||
self, AtLeast32Bit, AtLeast32BitUnsigned, BadOrigin, BlockNumberProvider, Bounded,
|
self, AtLeast32Bit, AtLeast32BitUnsigned, BadOrigin, BlockNumberProvider, Bounded,
|
||||||
CheckEqual, Dispatchable, Hash, Lookup, LookupError, MaybeDisplay, MaybeMallocSizeOf,
|
CheckEqual, Dispatchable, Hash, Lookup, LookupError, MaybeDisplay,
|
||||||
MaybeSerializeDeserialize, Member, One, Saturating, SimpleBitOps, StaticLookup, Zero,
|
MaybeSerializeDeserialize, Member, One, Saturating, SimpleBitOps, StaticLookup, Zero,
|
||||||
},
|
},
|
||||||
DispatchError, RuntimeDebug,
|
DispatchError, RuntimeDebug,
|
||||||
@@ -250,7 +250,6 @@ pub mod pallet {
|
|||||||
+ Copy
|
+ Copy
|
||||||
+ sp_std::hash::Hash
|
+ sp_std::hash::Hash
|
||||||
+ sp_std::str::FromStr
|
+ sp_std::str::FromStr
|
||||||
+ MaybeMallocSizeOf
|
|
||||||
+ MaxEncodedLen
|
+ MaxEncodedLen
|
||||||
+ TypeInfo;
|
+ TypeInfo;
|
||||||
|
|
||||||
@@ -268,7 +267,6 @@ pub mod pallet {
|
|||||||
+ sp_std::hash::Hash
|
+ sp_std::hash::Hash
|
||||||
+ AsRef<[u8]>
|
+ AsRef<[u8]>
|
||||||
+ AsMut<[u8]>
|
+ AsMut<[u8]>
|
||||||
+ MaybeMallocSizeOf
|
|
||||||
+ MaxEncodedLen;
|
+ MaxEncodedLen;
|
||||||
|
|
||||||
/// The hashing system (algorithm) being used in the runtime (e.g. Blake2).
|
/// The hashing system (algorithm) being used in the runtime (e.g. Blake2).
|
||||||
|
|||||||
@@ -11,5 +11,5 @@ documentation = "https://docs.rs/sp-database"
|
|||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
kvdb = "0.12.0"
|
kvdb = "0.13.0"
|
||||||
parking_lot = "0.12.1"
|
parking_lot = "0.12.1"
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ either = { version = "1.5", default-features = false }
|
|||||||
hash256-std-hasher = { version = "0.15.2", default-features = false }
|
hash256-std-hasher = { version = "0.15.2", default-features = false }
|
||||||
impl-trait-for-tuples = "0.2.2"
|
impl-trait-for-tuples = "0.2.2"
|
||||||
log = { version = "0.4.17", default-features = false }
|
log = { version = "0.4.17", default-features = false }
|
||||||
parity-util-mem = { version = "0.12.0", default-features = false, features = ["primitive-types"], optional = true }
|
|
||||||
paste = "1.0"
|
paste = "1.0"
|
||||||
rand = { version = "0.7.2", optional = true }
|
rand = { version = "0.7.2", optional = true }
|
||||||
scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }
|
scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }
|
||||||
@@ -48,7 +47,6 @@ std = [
|
|||||||
"either/use_std",
|
"either/use_std",
|
||||||
"hash256-std-hasher/std",
|
"hash256-std-hasher/std",
|
||||||
"log/std",
|
"log/std",
|
||||||
"parity-util-mem/std",
|
|
||||||
"rand",
|
"rand",
|
||||||
"scale-info/std",
|
"scale-info/std",
|
||||||
"serde",
|
"serde",
|
||||||
|
|||||||
@@ -25,10 +25,7 @@ use serde::{Deserialize, Serialize};
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
codec::{Codec, Decode, Encode},
|
codec::{Codec, Decode, Encode},
|
||||||
traits::{
|
traits::{self, Block as BlockT, Header as HeaderT, MaybeSerialize, Member, NumberFor},
|
||||||
self, Block as BlockT, Header as HeaderT, MaybeMallocSizeOf, MaybeSerialize, Member,
|
|
||||||
NumberFor,
|
|
||||||
},
|
|
||||||
Justifications,
|
Justifications,
|
||||||
};
|
};
|
||||||
use sp_core::RuntimeDebug;
|
use sp_core::RuntimeDebug;
|
||||||
@@ -82,7 +79,7 @@ impl<Block: BlockT> fmt::Display for BlockId<Block> {
|
|||||||
|
|
||||||
/// Abstraction over a substrate block.
|
/// Abstraction over a substrate block.
|
||||||
#[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug)]
|
#[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug)]
|
||||||
#[cfg_attr(feature = "std", derive(Serialize, Deserialize, parity_util_mem::MallocSizeOf))]
|
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
|
||||||
#[cfg_attr(feature = "std", serde(rename_all = "camelCase"))]
|
#[cfg_attr(feature = "std", serde(rename_all = "camelCase"))]
|
||||||
#[cfg_attr(feature = "std", serde(deny_unknown_fields))]
|
#[cfg_attr(feature = "std", serde(deny_unknown_fields))]
|
||||||
pub struct Block<Header, Extrinsic: MaybeSerialize> {
|
pub struct Block<Header, Extrinsic: MaybeSerialize> {
|
||||||
@@ -95,7 +92,7 @@ pub struct Block<Header, Extrinsic: MaybeSerialize> {
|
|||||||
impl<Header, Extrinsic: MaybeSerialize> traits::Block for Block<Header, Extrinsic>
|
impl<Header, Extrinsic: MaybeSerialize> traits::Block for Block<Header, Extrinsic>
|
||||||
where
|
where
|
||||||
Header: HeaderT,
|
Header: HeaderT,
|
||||||
Extrinsic: Member + Codec + traits::Extrinsic + MaybeMallocSizeOf,
|
Extrinsic: Member + Codec + traits::Extrinsic,
|
||||||
{
|
{
|
||||||
type Extrinsic = Extrinsic;
|
type Extrinsic = Extrinsic;
|
||||||
type Header = Header;
|
type Header = Header;
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ use sp_core::RuntimeDebug;
|
|||||||
|
|
||||||
/// Generic header digest.
|
/// Generic header digest.
|
||||||
#[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug, TypeInfo, Default)]
|
#[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug, TypeInfo, Default)]
|
||||||
#[cfg_attr(feature = "std", derive(Serialize, Deserialize, parity_util_mem::MallocSizeOf))]
|
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
|
||||||
pub struct Digest {
|
pub struct Digest {
|
||||||
/// A list of logs in the digest.
|
/// A list of logs in the digest.
|
||||||
pub logs: Vec<DigestItem>,
|
pub logs: Vec<DigestItem>,
|
||||||
@@ -70,7 +70,6 @@ impl Digest {
|
|||||||
/// Digest item that is able to encode/decode 'system' digest items and
|
/// Digest item that is able to encode/decode 'system' digest items and
|
||||||
/// provide opaque access to other items.
|
/// provide opaque access to other items.
|
||||||
#[derive(PartialEq, Eq, Clone, RuntimeDebug)]
|
#[derive(PartialEq, Eq, Clone, RuntimeDebug)]
|
||||||
#[cfg_attr(feature = "std", derive(parity_util_mem::MallocSizeOf))]
|
|
||||||
pub enum DigestItem {
|
pub enum DigestItem {
|
||||||
/// A pre-runtime digest.
|
/// A pre-runtime digest.
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ use crate::{
|
|||||||
generic::Digest,
|
generic::Digest,
|
||||||
scale_info::TypeInfo,
|
scale_info::TypeInfo,
|
||||||
traits::{
|
traits::{
|
||||||
self, AtLeast32BitUnsigned, Hash as HashT, MaybeDisplay, MaybeMallocSizeOf, MaybeSerialize,
|
self, AtLeast32BitUnsigned, Hash as HashT, MaybeDisplay, MaybeSerialize,
|
||||||
MaybeSerializeDeserialize, Member, SimpleBitOps,
|
MaybeSerializeDeserialize, Member, SimpleBitOps,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -54,22 +54,6 @@ pub struct Header<Number: Copy + Into<U256> + TryFrom<U256>, Hash: HashT> {
|
|||||||
pub digest: Digest,
|
pub digest: Digest,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
|
||||||
impl<Number, Hash> parity_util_mem::MallocSizeOf for Header<Number, Hash>
|
|
||||||
where
|
|
||||||
Number: Copy + Into<U256> + TryFrom<U256> + parity_util_mem::MallocSizeOf,
|
|
||||||
Hash: HashT,
|
|
||||||
Hash::Output: parity_util_mem::MallocSizeOf,
|
|
||||||
{
|
|
||||||
fn size_of(&self, ops: &mut parity_util_mem::MallocSizeOfOps) -> usize {
|
|
||||||
self.parent_hash.size_of(ops) +
|
|
||||||
self.number.size_of(ops) +
|
|
||||||
self.state_root.size_of(ops) +
|
|
||||||
self.extrinsics_root.size_of(ops) +
|
|
||||||
self.digest.size_of(ops)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
pub fn serialize_number<S, T: Copy + Into<U256> + TryFrom<U256>>(
|
pub fn serialize_number<S, T: Copy + Into<U256> + TryFrom<U256>>(
|
||||||
val: &T,
|
val: &T,
|
||||||
@@ -103,8 +87,7 @@ where
|
|||||||
+ Copy
|
+ Copy
|
||||||
+ Into<U256>
|
+ Into<U256>
|
||||||
+ TryFrom<U256>
|
+ TryFrom<U256>
|
||||||
+ sp_std::str::FromStr
|
+ sp_std::str::FromStr,
|
||||||
+ MaybeMallocSizeOf,
|
|
||||||
Hash: HashT,
|
Hash: HashT,
|
||||||
Hash::Output: Default
|
Hash::Output: Default
|
||||||
+ sp_std::hash::Hash
|
+ sp_std::hash::Hash
|
||||||
@@ -115,8 +98,7 @@ where
|
|||||||
+ Debug
|
+ Debug
|
||||||
+ MaybeDisplay
|
+ MaybeDisplay
|
||||||
+ SimpleBitOps
|
+ SimpleBitOps
|
||||||
+ Codec
|
+ Codec,
|
||||||
+ MaybeMallocSizeOf,
|
|
||||||
{
|
{
|
||||||
type Number = Number;
|
type Number = Number;
|
||||||
type Hash = <Hash as HashT>::Output;
|
type Hash = <Hash as HashT>::Output;
|
||||||
|
|||||||
@@ -87,18 +87,6 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
|
||||||
impl<Address, Call, Signature, Extra> parity_util_mem::MallocSizeOf
|
|
||||||
for UncheckedExtrinsic<Address, Call, Signature, Extra>
|
|
||||||
where
|
|
||||||
Extra: SignedExtension,
|
|
||||||
{
|
|
||||||
fn size_of(&self, _ops: &mut parity_util_mem::MallocSizeOfOps) -> usize {
|
|
||||||
// Instantiated only in runtime.
|
|
||||||
0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<Address, Call, Signature, Extra: SignedExtension>
|
impl<Address, Call, Signature, Extra: SignedExtension>
|
||||||
UncheckedExtrinsic<Address, Call, Signature, Extra>
|
UncheckedExtrinsic<Address, Call, Signature, Extra>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -874,13 +874,6 @@ impl OpaqueExtrinsic {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
|
||||||
impl parity_util_mem::MallocSizeOf for OpaqueExtrinsic {
|
|
||||||
fn size_of(&self, ops: &mut parity_util_mem::MallocSizeOfOps) -> usize {
|
|
||||||
self.0.size_of(ops)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl sp_std::fmt::Debug for OpaqueExtrinsic {
|
impl sp_std::fmt::Debug for OpaqueExtrinsic {
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
fn fmt(&self, fmt: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result {
|
fn fmt(&self, fmt: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result {
|
||||||
|
|||||||
@@ -204,13 +204,10 @@ impl Header {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// An opaque extrinsic wrapper type.
|
/// An opaque extrinsic wrapper type.
|
||||||
#[derive(PartialEq, Eq, Clone, Debug, Encode, Decode, parity_util_mem::MallocSizeOf)]
|
#[derive(PartialEq, Eq, Clone, Debug, Encode, Decode)]
|
||||||
pub struct ExtrinsicWrapper<Xt>(Xt);
|
pub struct ExtrinsicWrapper<Xt>(Xt);
|
||||||
|
|
||||||
impl<Xt> traits::Extrinsic for ExtrinsicWrapper<Xt>
|
impl<Xt> traits::Extrinsic for ExtrinsicWrapper<Xt> {
|
||||||
where
|
|
||||||
Xt: parity_util_mem::MallocSizeOf,
|
|
||||||
{
|
|
||||||
type Call = ();
|
type Call = ();
|
||||||
type SignaturePayload = ();
|
type SignaturePayload = ();
|
||||||
|
|
||||||
@@ -243,7 +240,7 @@ impl<Xt> Deref for ExtrinsicWrapper<Xt> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Testing block
|
/// Testing block
|
||||||
#[derive(PartialEq, Eq, Clone, Serialize, Debug, Encode, Decode, parity_util_mem::MallocSizeOf)]
|
#[derive(PartialEq, Eq, Clone, Serialize, Debug, Encode, Decode)]
|
||||||
pub struct Block<Xt> {
|
pub struct Block<Xt> {
|
||||||
/// Block header
|
/// Block header
|
||||||
pub header: Header,
|
pub header: Header,
|
||||||
@@ -306,9 +303,6 @@ impl<Call, Extra> TestXt<Call, Extra> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Non-opaque extrinsics always 0.
|
|
||||||
parity_util_mem::malloc_size_of_is_0!(any: TestXt<Call, Extra>);
|
|
||||||
|
|
||||||
impl<Call, Extra> Serialize for TestXt<Call, Extra>
|
impl<Call, Extra> Serialize for TestXt<Call, Extra>
|
||||||
where
|
where
|
||||||
TestXt<Call, Extra>: Encode,
|
TestXt<Call, Extra>: Encode,
|
||||||
|
|||||||
@@ -808,9 +808,6 @@ sp_core::impl_maybe_marker!(
|
|||||||
|
|
||||||
/// A type that implements Serialize, DeserializeOwned and Debug when in std environment.
|
/// A type that implements Serialize, DeserializeOwned and Debug when in std environment.
|
||||||
trait MaybeSerializeDeserialize: DeserializeOwned, Serialize;
|
trait MaybeSerializeDeserialize: DeserializeOwned, Serialize;
|
||||||
|
|
||||||
/// A type that implements MallocSizeOf.
|
|
||||||
trait MaybeMallocSizeOf: parity_util_mem::MallocSizeOf;
|
|
||||||
);
|
);
|
||||||
|
|
||||||
/// A type that can be used in runtime structures.
|
/// A type that can be used in runtime structures.
|
||||||
@@ -828,9 +825,7 @@ pub trait IsMember<MemberId> {
|
|||||||
/// `parent_hash`, as well as a `digest` and a block `number`.
|
/// `parent_hash`, as well as a `digest` and a block `number`.
|
||||||
///
|
///
|
||||||
/// You can also create a `new` one from those fields.
|
/// You can also create a `new` one from those fields.
|
||||||
pub trait Header:
|
pub trait Header: Clone + Send + Sync + Codec + Eq + MaybeSerialize + Debug + 'static {
|
||||||
Clone + Send + Sync + Codec + Eq + MaybeSerialize + Debug + MaybeMallocSizeOf + 'static
|
|
||||||
{
|
|
||||||
/// Header number.
|
/// Header number.
|
||||||
type Number: Member
|
type Number: Member
|
||||||
+ MaybeSerializeDeserialize
|
+ MaybeSerializeDeserialize
|
||||||
@@ -840,8 +835,7 @@ pub trait Header:
|
|||||||
+ MaybeDisplay
|
+ MaybeDisplay
|
||||||
+ AtLeast32BitUnsigned
|
+ AtLeast32BitUnsigned
|
||||||
+ Codec
|
+ Codec
|
||||||
+ sp_std::str::FromStr
|
+ sp_std::str::FromStr;
|
||||||
+ MaybeMallocSizeOf;
|
|
||||||
/// Header hash type
|
/// Header hash type
|
||||||
type Hash: Member
|
type Hash: Member
|
||||||
+ MaybeSerializeDeserialize
|
+ MaybeSerializeDeserialize
|
||||||
@@ -855,7 +849,6 @@ pub trait Header:
|
|||||||
+ Codec
|
+ Codec
|
||||||
+ AsRef<[u8]>
|
+ AsRef<[u8]>
|
||||||
+ AsMut<[u8]>
|
+ AsMut<[u8]>
|
||||||
+ MaybeMallocSizeOf
|
|
||||||
+ TypeInfo;
|
+ TypeInfo;
|
||||||
/// Hashing algorithm
|
/// Hashing algorithm
|
||||||
type Hashing: Hash<Output = Self::Hash>;
|
type Hashing: Hash<Output = Self::Hash>;
|
||||||
@@ -904,13 +897,11 @@ pub trait Header:
|
|||||||
/// `Extrinsic` pieces of information as well as a `Header`.
|
/// `Extrinsic` pieces of information as well as a `Header`.
|
||||||
///
|
///
|
||||||
/// You can get an iterator over each of the `extrinsics` and retrieve the `header`.
|
/// You can get an iterator over each of the `extrinsics` and retrieve the `header`.
|
||||||
pub trait Block:
|
pub trait Block: Clone + Send + Sync + Codec + Eq + MaybeSerialize + Debug + 'static {
|
||||||
Clone + Send + Sync + Codec + Eq + MaybeSerialize + Debug + MaybeMallocSizeOf + 'static
|
|
||||||
{
|
|
||||||
/// Type for extrinsics.
|
/// Type for extrinsics.
|
||||||
type Extrinsic: Member + Codec + Extrinsic + MaybeSerialize + MaybeMallocSizeOf;
|
type Extrinsic: Member + Codec + Extrinsic + MaybeSerialize;
|
||||||
/// Header type.
|
/// Header type.
|
||||||
type Header: Header<Hash = Self::Hash> + MaybeMallocSizeOf;
|
type Header: Header<Hash = Self::Hash>;
|
||||||
/// Block hash type.
|
/// Block hash type.
|
||||||
type Hash: Member
|
type Hash: Member
|
||||||
+ MaybeSerializeDeserialize
|
+ MaybeSerializeDeserialize
|
||||||
@@ -924,7 +915,6 @@ pub trait Block:
|
|||||||
+ Codec
|
+ Codec
|
||||||
+ AsRef<[u8]>
|
+ AsRef<[u8]>
|
||||||
+ AsMut<[u8]>
|
+ AsMut<[u8]>
|
||||||
+ MaybeMallocSizeOf
|
|
||||||
+ TypeInfo;
|
+ TypeInfo;
|
||||||
|
|
||||||
/// Returns a reference to the header.
|
/// Returns a reference to the header.
|
||||||
@@ -945,7 +935,7 @@ pub trait Block:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Something that acts like an `Extrinsic`.
|
/// Something that acts like an `Extrinsic`.
|
||||||
pub trait Extrinsic: Sized + MaybeMallocSizeOf {
|
pub trait Extrinsic: Sized {
|
||||||
/// The function call.
|
/// The function call.
|
||||||
type Call;
|
type Call;
|
||||||
|
|
||||||
|
|||||||
@@ -227,7 +227,6 @@ impl From<UnknownTransaction> for TransactionValidity {
|
|||||||
/// For instance we can disallow specific kinds of transactions if they were not produced
|
/// For instance we can disallow specific kinds of transactions if they were not produced
|
||||||
/// by our local node (for instance off-chain workers).
|
/// by our local node (for instance off-chain workers).
|
||||||
#[derive(Copy, Clone, PartialEq, Eq, Encode, Decode, RuntimeDebug)]
|
#[derive(Copy, Clone, PartialEq, Eq, Encode, Decode, RuntimeDebug)]
|
||||||
#[cfg_attr(feature = "std", derive(parity_util_mem::MallocSizeOf))]
|
|
||||||
pub enum TransactionSource {
|
pub enum TransactionSource {
|
||||||
/// Transaction is already included in block.
|
/// Transaction is already included in block.
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ targets = ["x86_64-unknown-linux-gnu"]
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] }
|
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] }
|
||||||
parity-util-mem = { version = "0.12.0", default-features = false, features = ["primitive-types"] }
|
|
||||||
serde = { version = "1.0.136", features = ["derive"], optional = true }
|
serde = { version = "1.0.136", features = ["derive"], optional = true }
|
||||||
sp-application-crypto = { version = "7.0.0", default-features = false, path = "../application-crypto" }
|
sp-application-crypto = { version = "7.0.0", default-features = false, path = "../application-crypto" }
|
||||||
sp-core = { version = "7.0.0", default-features = false, path = "../core" }
|
sp-core = { version = "7.0.0", default-features = false, path = "../core" }
|
||||||
@@ -25,7 +24,6 @@ default = [
|
|||||||
]
|
]
|
||||||
std = [
|
std = [
|
||||||
"codec/std",
|
"codec/std",
|
||||||
"parity-util-mem/std",
|
|
||||||
"serde",
|
"serde",
|
||||||
"sp-application-crypto/std",
|
"sp-application-crypto/std",
|
||||||
"sp-core/std",
|
"sp-core/std",
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ use sp_runtime::traits::{BlakeTwo256, Extrinsic as ExtrinsicT, Verify};
|
|||||||
|
|
||||||
/// Extrinsic for test-runtime.
|
/// Extrinsic for test-runtime.
|
||||||
#[derive(Clone, PartialEq, Eq, Encode, Decode, RuntimeDebug)]
|
#[derive(Clone, PartialEq, Eq, Encode, Decode, RuntimeDebug)]
|
||||||
#[cfg_attr(feature = "std", derive(parity_util_mem::MallocSizeOf))]
|
|
||||||
pub enum Extrinsic {
|
pub enum Extrinsic {
|
||||||
IncludeData(Vec<u8>),
|
IncludeData(Vec<u8>),
|
||||||
StorageChange(Vec<u8>, Option<Vec<u8>>),
|
StorageChange(Vec<u8>, Option<Vec<u8>>),
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ hashbrown = { version = "0.12.3", optional = true }
|
|||||||
hash-db = { version = "0.15.2", default-features = false }
|
hash-db = { version = "0.15.2", default-features = false }
|
||||||
lazy_static = { version = "1.4.0", optional = true }
|
lazy_static = { version = "1.4.0", optional = true }
|
||||||
lru = { version = "0.8.1", optional = true }
|
lru = { version = "0.8.1", optional = true }
|
||||||
memory-db = { version = "0.30.0", default-features = false }
|
memory-db = { version = "0.31.0", default-features = false }
|
||||||
nohash-hasher = { version = "0.2.0", optional = true }
|
nohash-hasher = { version = "0.2.0", optional = true }
|
||||||
parking_lot = { version = "0.12.1", optional = true }
|
parking_lot = { version = "0.12.1", optional = true }
|
||||||
scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }
|
scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }
|
||||||
@@ -38,7 +38,7 @@ sp-std = { version = "5.0.0", default-features = false, path = "../std" }
|
|||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
array-bytes = "4.1"
|
array-bytes = "4.1"
|
||||||
criterion = "0.3.3"
|
criterion = "0.3.3"
|
||||||
trie-bench = "0.32.0"
|
trie-bench = "0.33.0"
|
||||||
trie-standardmap = "0.15.2"
|
trie-standardmap = "0.15.2"
|
||||||
sp-runtime = { version = "7.0.0", path = "../runtime" }
|
sp-runtime = { version = "7.0.0", path = "../runtime" }
|
||||||
|
|
||||||
@@ -62,4 +62,3 @@ std = [
|
|||||||
"trie-db/std",
|
"trie-db/std",
|
||||||
"trie-root/std",
|
"trie-root/std",
|
||||||
]
|
]
|
||||||
memory-tracker = []
|
|
||||||
|
|||||||
@@ -146,11 +146,6 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "memory-tracker"))]
|
|
||||||
type MemTracker = memory_db::NoopTracker<trie_db::DBValue>;
|
|
||||||
#[cfg(feature = "memory-tracker")]
|
|
||||||
type MemTracker = memory_db::MemCounter<trie_db::DBValue>;
|
|
||||||
|
|
||||||
/// TrieDB error over `TrieConfiguration` trait.
|
/// TrieDB error over `TrieConfiguration` trait.
|
||||||
pub type TrieError<L> = trie_db::TrieError<TrieHash<L>, CError<L>>;
|
pub type TrieError<L> = trie_db::TrieError<TrieHash<L>, CError<L>>;
|
||||||
/// Reexport from `hash_db`, with genericity set for `Hasher` trait.
|
/// Reexport from `hash_db`, with genericity set for `Hasher` trait.
|
||||||
@@ -161,14 +156,13 @@ pub type HashDB<'a, H> = dyn hash_db::HashDB<H, trie_db::DBValue> + 'a;
|
|||||||
/// Reexport from `hash_db`, with genericity set for `Hasher` trait.
|
/// Reexport from `hash_db`, with genericity set for `Hasher` trait.
|
||||||
/// This uses a `KeyFunction` for prefixing keys internally (avoiding
|
/// This uses a `KeyFunction` for prefixing keys internally (avoiding
|
||||||
/// key conflict for non random keys).
|
/// key conflict for non random keys).
|
||||||
pub type PrefixedMemoryDB<H> =
|
pub type PrefixedMemoryDB<H> = memory_db::MemoryDB<H, memory_db::PrefixedKey<H>, trie_db::DBValue>;
|
||||||
memory_db::MemoryDB<H, memory_db::PrefixedKey<H>, trie_db::DBValue, MemTracker>;
|
|
||||||
/// Reexport from `hash_db`, with genericity set for `Hasher` trait.
|
/// Reexport from `hash_db`, with genericity set for `Hasher` trait.
|
||||||
/// This uses a noops `KeyFunction` (key addressing must be hashed or using
|
/// This uses a noops `KeyFunction` (key addressing must be hashed or using
|
||||||
/// an encoding scheme that avoid key conflict).
|
/// an encoding scheme that avoid key conflict).
|
||||||
pub type MemoryDB<H> = memory_db::MemoryDB<H, memory_db::HashKey<H>, trie_db::DBValue, MemTracker>;
|
pub type MemoryDB<H> = memory_db::MemoryDB<H, memory_db::HashKey<H>, trie_db::DBValue>;
|
||||||
/// Reexport from `hash_db`, with genericity set for `Hasher` trait.
|
/// Reexport from `hash_db`, with genericity set for `Hasher` trait.
|
||||||
pub type GenericMemoryDB<H, KF> = memory_db::MemoryDB<H, KF, trie_db::DBValue, MemTracker>;
|
pub type GenericMemoryDB<H, KF> = memory_db::MemoryDB<H, KF, trie_db::DBValue>;
|
||||||
|
|
||||||
/// Persistent trie database read-access interface for the a given hasher.
|
/// Persistent trie database read-access interface for the a given hasher.
|
||||||
pub type TrieDB<'a, 'cache, L> = trie_db::TrieDB<'a, 'cache, L>;
|
pub type TrieDB<'a, 'cache, L> = trie_db::TrieDB<'a, 'cache, L>;
|
||||||
@@ -548,8 +542,7 @@ mod tests {
|
|||||||
type LayoutV0 = super::LayoutV0<Blake2Hasher>;
|
type LayoutV0 = super::LayoutV0<Blake2Hasher>;
|
||||||
type LayoutV1 = super::LayoutV1<Blake2Hasher>;
|
type LayoutV1 = super::LayoutV1<Blake2Hasher>;
|
||||||
|
|
||||||
type MemoryDBMeta<H> =
|
type MemoryDBMeta<H> = memory_db::MemoryDB<H, memory_db::HashKey<H>, trie_db::DBValue>;
|
||||||
memory_db::MemoryDB<H, memory_db::HashKey<H>, trie_db::DBValue, MemTracker>;
|
|
||||||
|
|
||||||
fn hashed_null_node<T: TrieConfiguration>() -> TrieHash<T> {
|
fn hashed_null_node<T: TrieConfiguration>() -> TrieHash<T> {
|
||||||
<T::Codec as NodeCodecT>::hashed_null_node()
|
<T::Codec as NodeCodecT>::hashed_null_node()
|
||||||
|
|||||||
@@ -160,7 +160,6 @@ allow = [
|
|||||||
]
|
]
|
||||||
# List of crates to deny
|
# List of crates to deny
|
||||||
deny = [
|
deny = [
|
||||||
{ name = "parity-util-mem", version = "<0.6" }
|
|
||||||
# Each entry the name of a crate and a version range. If version is
|
# Each entry the name of a crate and a version range. If version is
|
||||||
# not specified, all versions will be matched.
|
# not specified, all versions will be matched.
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ codec = { package = "parity-scale-codec", version = "3.0.0", default-features =
|
|||||||
scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }
|
scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }
|
||||||
sp-inherents = { version = "4.0.0-dev", default-features = false, path = "../../primitives/inherents" }
|
sp-inherents = { version = "4.0.0-dev", default-features = false, path = "../../primitives/inherents" }
|
||||||
sp-keyring = { version = "7.0.0", optional = true, path = "../../primitives/keyring" }
|
sp-keyring = { version = "7.0.0", optional = true, path = "../../primitives/keyring" }
|
||||||
memory-db = { version = "0.30.0", default-features = false }
|
memory-db = { version = "0.31.0", default-features = false }
|
||||||
sp-offchain = { version = "4.0.0-dev", default-features = false, path = "../../primitives/offchain" }
|
sp-offchain = { version = "4.0.0-dev", default-features = false, path = "../../primitives/offchain" }
|
||||||
sp-core = { version = "7.0.0", default-features = false, path = "../../primitives/core" }
|
sp-core = { version = "7.0.0", default-features = false, path = "../../primitives/core" }
|
||||||
sp-std = { version = "5.0.0", default-features = false, path = "../../primitives/std" }
|
sp-std = { version = "5.0.0", default-features = false, path = "../../primitives/std" }
|
||||||
@@ -42,7 +42,6 @@ sp-finality-grandpa = { version = "4.0.0-dev", default-features = false, path =
|
|||||||
sp-trie = { version = "7.0.0", default-features = false, path = "../../primitives/trie" }
|
sp-trie = { version = "7.0.0", default-features = false, path = "../../primitives/trie" }
|
||||||
sp-transaction-pool = { version = "4.0.0-dev", default-features = false, path = "../../primitives/transaction-pool" }
|
sp-transaction-pool = { version = "4.0.0-dev", default-features = false, path = "../../primitives/transaction-pool" }
|
||||||
trie-db = { version = "0.24.0", default-features = false }
|
trie-db = { version = "0.24.0", default-features = false }
|
||||||
parity-util-mem = { version = "0.12.0", default-features = false, features = ["primitive-types"] }
|
|
||||||
sc-service = { version = "0.10.0-dev", default-features = false, optional = true, features = ["test-helpers"], path = "../../client/service" }
|
sc-service = { version = "0.10.0-dev", default-features = false, optional = true, features = ["test-helpers"], path = "../../client/service" }
|
||||||
sp-state-machine = { version = "0.13.0", default-features = false, path = "../../primitives/state-machine" }
|
sp-state-machine = { version = "0.13.0", default-features = false, path = "../../primitives/state-machine" }
|
||||||
sp-externalities = { version = "0.13.0", default-features = false, path = "../../primitives/externalities" }
|
sp-externalities = { version = "0.13.0", default-features = false, path = "../../primitives/externalities" }
|
||||||
@@ -67,7 +66,6 @@ default = [
|
|||||||
"std",
|
"std",
|
||||||
]
|
]
|
||||||
std = [
|
std = [
|
||||||
"parity-util-mem/std",
|
|
||||||
"beefy-primitives/std",
|
"beefy-primitives/std",
|
||||||
"beefy-merkle-tree/std",
|
"beefy-merkle-tree/std",
|
||||||
"sp-application-crypto/std",
|
"sp-application-crypto/std",
|
||||||
|
|||||||
@@ -166,8 +166,6 @@ pub enum Extrinsic {
|
|||||||
Store(Vec<u8>),
|
Store(Vec<u8>),
|
||||||
}
|
}
|
||||||
|
|
||||||
parity_util_mem::malloc_size_of_is_0!(Extrinsic); // non-opaque extrinsic does not need this
|
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
impl serde::Serialize for Extrinsic {
|
impl serde::Serialize for Extrinsic {
|
||||||
fn serialize<S>(&self, seq: S) -> Result<S::Ok, S::Error>
|
fn serialize<S>(&self, seq: S) -> Result<S::Ok, S::Error>
|
||||||
|
|||||||
@@ -22,11 +22,11 @@ handlebars = "4.2.2"
|
|||||||
hash-db = "0.15.2"
|
hash-db = "0.15.2"
|
||||||
Inflector = "0.11.4"
|
Inflector = "0.11.4"
|
||||||
itertools = "0.10.3"
|
itertools = "0.10.3"
|
||||||
kvdb = "0.12.0"
|
kvdb = "0.13.0"
|
||||||
lazy_static = "1.4.0"
|
lazy_static = "1.4.0"
|
||||||
linked-hash-map = "0.5.4"
|
linked-hash-map = "0.5.4"
|
||||||
log = "0.4.17"
|
log = "0.4.17"
|
||||||
memory-db = "0.30.0"
|
memory-db = "0.31.0"
|
||||||
rand = { version = "0.8.4", features = ["small_rng"] }
|
rand = { version = "0.8.4", features = ["small_rng"] }
|
||||||
rand_pcg = "0.3.1"
|
rand_pcg = "0.3.1"
|
||||||
serde = "1.0.136"
|
serde = "1.0.136"
|
||||||
|
|||||||
Reference in New Issue
Block a user