mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-09 05:57:59 +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",
|
||||
"once_cell",
|
||||
"parity-scale-codec",
|
||||
"parity-util-mem",
|
||||
"paste",
|
||||
"pretty_assertions",
|
||||
"scale-info",
|
||||
@@ -3378,35 +3377,31 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "kvdb"
|
||||
version = "0.12.0"
|
||||
version = "0.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "585089ceadba0197ffe9af6740ab350b325e3c1f5fccfbc3522e0250c750409b"
|
||||
checksum = "e7d770dcb02bf6835887c3a979b5107a04ff4bbde97a5f0928d27404a155add9"
|
||||
dependencies = [
|
||||
"parity-util-mem",
|
||||
"smallvec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "kvdb-memorydb"
|
||||
version = "0.12.0"
|
||||
version = "0.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "40d109c87bfb7759edd2a49b2649c1afe25af785d930ad6a38479b4dc70dd873"
|
||||
checksum = "bf7a85fe66f9ff9cd74e169fdd2c94c6e1e74c412c99a73b4df3200b5d3760b2"
|
||||
dependencies = [
|
||||
"kvdb",
|
||||
"parity-util-mem",
|
||||
"parking_lot 0.12.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "kvdb-rocksdb"
|
||||
version = "0.16.0"
|
||||
version = "0.17.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c076cc2cdbac89b9910c853a36c957d3862a779f31c2661174222cefb49ee597"
|
||||
checksum = "2182b8219fee6bd83aacaab7344e840179ae079d5216aa4e249b4d704646a844"
|
||||
dependencies = [
|
||||
"kvdb",
|
||||
"log",
|
||||
"num_cpus",
|
||||
"parity-util-mem",
|
||||
"parking_lot 0.12.1",
|
||||
"regex",
|
||||
"rocksdb",
|
||||
@@ -4081,13 +4076,12 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "memory-db"
|
||||
version = "0.30.0"
|
||||
version = "0.31.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "34ac11bb793c28fa095b7554466f53b3a60a2cd002afdac01bcf135cbd73a269"
|
||||
checksum = "5e0c7cba9ce19ac7ffd2053ac9f49843bbd3f4318feedfd74e85c19d5fb0ba66"
|
||||
dependencies = [
|
||||
"hash-db",
|
||||
"hashbrown 0.12.3",
|
||||
"parity-util-mem",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -4433,7 +4427,6 @@ dependencies = [
|
||||
"node-primitives",
|
||||
"node-testing",
|
||||
"parity-db",
|
||||
"parity-util-mem",
|
||||
"rand 0.7.3",
|
||||
"sc-basic-authorship",
|
||||
"sc-client-api",
|
||||
@@ -4527,7 +4520,6 @@ dependencies = [
|
||||
"sp-tracing",
|
||||
"sp-transaction-pool",
|
||||
"sp-transaction-storage-proof",
|
||||
"sp-trie",
|
||||
"substrate-build-script-utils",
|
||||
"substrate-frame-cli",
|
||||
"substrate-rpc-client",
|
||||
@@ -6379,33 +6371,6 @@ version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
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]]
|
||||
name = "parity-wasm"
|
||||
version = "0.45.0"
|
||||
@@ -8066,7 +8031,6 @@ dependencies = [
|
||||
"futures",
|
||||
"futures-timer",
|
||||
"log",
|
||||
"parity-util-mem",
|
||||
"sc-client-api",
|
||||
"sc-network-common",
|
||||
"sc-transaction-pool-api",
|
||||
@@ -8498,7 +8462,6 @@ dependencies = [
|
||||
"jsonrpsee",
|
||||
"log",
|
||||
"parity-scale-codec",
|
||||
"parity-util-mem",
|
||||
"parking_lot 0.12.1",
|
||||
"pin-project",
|
||||
"rand 0.7.3",
|
||||
@@ -8600,8 +8563,6 @@ version = "0.10.0-dev"
|
||||
dependencies = [
|
||||
"log",
|
||||
"parity-scale-codec",
|
||||
"parity-util-mem",
|
||||
"parity-util-mem-derive",
|
||||
"parking_lot 0.12.1",
|
||||
"sc-client-api",
|
||||
"sp-core",
|
||||
@@ -8715,7 +8676,6 @@ dependencies = [
|
||||
"linked-hash-map",
|
||||
"log",
|
||||
"parity-scale-codec",
|
||||
"parity-util-mem",
|
||||
"parking_lot 0.12.1",
|
||||
"sc-block-builder",
|
||||
"sc-client-api",
|
||||
@@ -9723,7 +9683,6 @@ dependencies = [
|
||||
"impl-trait-for-tuples",
|
||||
"log",
|
||||
"parity-scale-codec",
|
||||
"parity-util-mem",
|
||||
"paste",
|
||||
"rand 0.7.3",
|
||||
"scale-info",
|
||||
@@ -9908,7 +9867,6 @@ name = "sp-test-primitives"
|
||||
version = "2.0.0"
|
||||
dependencies = [
|
||||
"parity-scale-codec",
|
||||
"parity-util-mem",
|
||||
"serde",
|
||||
"sp-application-crypto",
|
||||
"sp-core",
|
||||
@@ -10333,7 +10291,6 @@ dependencies = [
|
||||
"pallet-babe",
|
||||
"pallet-timestamp",
|
||||
"parity-scale-codec",
|
||||
"parity-util-mem",
|
||||
"sc-block-builder",
|
||||
"sc-executor",
|
||||
"sc-service",
|
||||
@@ -10850,9 +10807,9 @@ checksum = "a7f741b240f1a48843f9b8e0444fb55fb2a4ff67293b50a9179dfd5ea67f8d41"
|
||||
|
||||
[[package]]
|
||||
name = "trie-bench"
|
||||
version = "0.32.0"
|
||||
version = "0.33.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f0dae77b1daad50cd3ed94c506d2dab27e2e47f7b5153a6d4b1992bb3f6028cb"
|
||||
checksum = "c5b26bd2cdd7641c5beb476b314c0cb1f629832bf21a6235f545e2d47bc9d05a"
|
||||
dependencies = [
|
||||
"criterion",
|
||||
"hash-db",
|
||||
|
||||
@@ -23,8 +23,8 @@ sp-state-machine = { version = "0.13.0", path = "../../../primitives/state-machi
|
||||
serde = "1.0.136"
|
||||
serde_json = "1.0.85"
|
||||
derive_more = { version = "0.99.17", default-features = false, features = ["display"] }
|
||||
kvdb = "0.12.0"
|
||||
kvdb-rocksdb = "0.16.0"
|
||||
kvdb = "0.13.0"
|
||||
kvdb-rocksdb = "0.17.0"
|
||||
sp-trie = { version = "7.0.0", path = "../../../primitives/trie" }
|
||||
sp-core = { version = "7.0.0", path = "../../../primitives/core" }
|
||||
sp-consensus = { version = "0.10.0-dev", path = "../../../primitives/consensus/common" }
|
||||
@@ -37,7 +37,6 @@ tempfile = "3.1.0"
|
||||
fs_extra = "1"
|
||||
rand = { version = "0.7.2", features = ["small_rng"] }
|
||||
lazy_static = "1.4.0"
|
||||
parity-util-mem = { version = "0.12.0", default-features = false, features = ["primitive-types"] }
|
||||
parity-db = "0.4.2"
|
||||
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" }
|
||||
|
||||
@@ -29,7 +29,6 @@ pub enum DatabaseType {
|
||||
pub struct TempDatabase(tempfile::TempDir);
|
||||
|
||||
struct ParityDbWrapper(parity_db::Db);
|
||||
parity_util_mem::malloc_size_of_is_0!(ParityDbWrapper);
|
||||
|
||||
impl KeyValueDB for ParityDbWrapper {
|
||||
/// 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" }
|
||||
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]
|
||||
sc-keystore = { version = "4.0.0-dev", path = "../../../client/keystore" }
|
||||
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.
|
||||
#[derive(Default, Clone, Debug)]
|
||||
pub struct MemoryInfo {
|
||||
@@ -215,8 +204,6 @@ pub struct MemoryInfo {
|
||||
pub state_cache: MemorySize,
|
||||
/// Size of backend database cache.
|
||||
pub database_cache: MemorySize,
|
||||
/// Size of the state db.
|
||||
pub state_db: StateDbMemoryInfo,
|
||||
}
|
||||
|
||||
/// I/O statistics for client instance.
|
||||
@@ -264,13 +251,9 @@ impl fmt::Display for UsageInfo {
|
||||
write!(
|
||||
f,
|
||||
"caches: ({} state, {} db overlay), \
|
||||
state db: ({} non-canonical, {} pruning, {} pinned), \
|
||||
i/o: ({} tx, {} write, {} read, {} avg tx, {}/{} key cache reads/total, {} trie nodes writes)",
|
||||
self.memory.state_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.bytes_written,
|
||||
self.io.bytes_read,
|
||||
|
||||
@@ -17,9 +17,9 @@ codec = { package = "parity-scale-codec", version = "3.0.0", features = [
|
||||
"derive",
|
||||
] }
|
||||
hash-db = "0.15.2"
|
||||
kvdb = "0.12.0"
|
||||
kvdb-memorydb = "0.12.0"
|
||||
kvdb-rocksdb = { version = "0.16.0", optional = true }
|
||||
kvdb = "0.13.0"
|
||||
kvdb-memorydb = "0.13.0"
|
||||
kvdb-rocksdb = { version = "0.17.0", optional = true }
|
||||
linked-hash-map = "0.5.4"
|
||||
log = "0.4.17"
|
||||
parity-db = "0.4.2"
|
||||
@@ -36,7 +36,7 @@ sp-trie = { version = "7.0.0", path = "../../primitives/trie" }
|
||||
|
||||
[dev-dependencies]
|
||||
criterion = "0.3.3"
|
||||
kvdb-rocksdb = "0.16.0"
|
||||
kvdb-rocksdb = "0.17.0"
|
||||
rand = "0.8.4"
|
||||
tempfile = "3.1.0"
|
||||
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(
|
||||
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 {
|
||||
memory: MemoryInfo { state_cache, database_cache, state_db },
|
||||
memory: MemoryInfo { state_cache, database_cache },
|
||||
io: IoInfo {
|
||||
transactions: io_stats.transactions,
|
||||
bytes_read: io_stats.bytes_read,
|
||||
|
||||
@@ -59,15 +59,11 @@ pub struct Cache<B: BlockT> {
|
||||
|
||||
struct LRUMap<K, V>(LinkedHashMap<K, V>, usize, usize);
|
||||
|
||||
/// Internal trait similar to `heapsize` but using
|
||||
/// a simply estimation.
|
||||
/// Internal trait similar to `heapsize` but using a simple estimation.
|
||||
///
|
||||
/// This should not be made public, it is implementation
|
||||
/// detail trait. If it need to become public please
|
||||
/// consider using `malloc_size_of`.
|
||||
/// This should not be made public, it is an implementation detail trait.
|
||||
trait EstimateSize {
|
||||
/// Return a size estimation of additional size needed
|
||||
/// to cache this struct (in bytes).
|
||||
/// Return a size estimation of the additional size needed to cache this struct (in bytes).
|
||||
fn estimate_size(&self) -> usize;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@ ansi_term = "0.12.1"
|
||||
futures = "0.3.21"
|
||||
futures-timer = "3.0.1"
|
||||
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-network-common = { version = "0.10.0-dev", path = "../network/common" }
|
||||
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_timer::Delay;
|
||||
use log::{debug, info, trace};
|
||||
use parity_util_mem::MallocSizeOf;
|
||||
use sc_client_api::{BlockchainEvents, UsageProvider};
|
||||
use sc_network_common::service::NetworkStatusProvider;
|
||||
use sc_transaction_pool_api::TransactionPool;
|
||||
use sp_blockchain::HeaderMetadata;
|
||||
use sp_runtime::traits::{Block as BlockT, Header};
|
||||
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.
|
||||
pub async fn build<B: BlockT, C, N, P>(
|
||||
client: Arc<C>,
|
||||
network: N,
|
||||
pool: Arc<P>,
|
||||
format: OutputFormat,
|
||||
) where
|
||||
pub async fn build<B: BlockT, C, N>(client: Arc<C>, network: N, format: OutputFormat)
|
||||
where
|
||||
N: NetworkStatusProvider<B>,
|
||||
C: UsageProvider<B> + HeaderMetadata<B> + BlockchainEvents<B>,
|
||||
<C as HeaderMetadata<B>>::Error: Display,
|
||||
P: TransactionPool + MallocSizeOf,
|
||||
{
|
||||
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",
|
||||
)
|
||||
}
|
||||
trace!(
|
||||
target: "usage",
|
||||
"Subsystems memory [txpool: {} kB]",
|
||||
parity_util_mem::malloc_size(&*pool) / 1024,
|
||||
);
|
||||
display.display(&info, net_status);
|
||||
future::ready(())
|
||||
});
|
||||
|
||||
@@ -80,9 +80,6 @@ sp-tracing = { version = "6.0.0", path = "../../primitives/tracing" }
|
||||
sc-sysinfo = { version = "6.0.0-dev", path = "../sysinfo" }
|
||||
tracing = "0.1.29"
|
||||
tracing-futures = { version = "0.2.4" }
|
||||
parity-util-mem = { version = "0.12.0", default-features = false, features = [
|
||||
"primitive-types",
|
||||
] }
|
||||
async-trait = "0.1.57"
|
||||
tokio = { version = "1.22.0", features = ["time", "rt-multi-thread", "parking_lot"] }
|
||||
tempfile = "3.1.0"
|
||||
|
||||
@@ -436,9 +436,7 @@ where
|
||||
TBl::Hash: Unpin,
|
||||
TBl::Header: Unpin,
|
||||
TBackend: 'static + sc_client_api::backend::Backend<TBl> + Send,
|
||||
TExPool: MaintainedTransactionPool<Block = TBl, Hash = <TBl as BlockT>::Hash>
|
||||
+ parity_util_mem::MallocSizeOf
|
||||
+ 'static,
|
||||
TExPool: MaintainedTransactionPool<Block = TBl, Hash = <TBl as BlockT>::Hash> + 'static,
|
||||
{
|
||||
let SpawnTasksParams {
|
||||
mut config,
|
||||
@@ -540,12 +538,7 @@ where
|
||||
spawn_handle.spawn(
|
||||
"informant",
|
||||
None,
|
||||
sc_informant::build(
|
||||
client.clone(),
|
||||
network,
|
||||
transaction_pool.clone(),
|
||||
config.informant_output_format,
|
||||
),
|
||||
sc_informant::build(client.clone(), network, config.informant_output_format),
|
||||
);
|
||||
|
||||
task_manager.keep_alive((config.base_path, rpc));
|
||||
|
||||
@@ -43,7 +43,6 @@ struct PrometheusMetrics {
|
||||
// I/O
|
||||
database_cache: Gauge<U64>,
|
||||
state_cache: Gauge<U64>,
|
||||
state_db: GaugeVec<U64>,
|
||||
}
|
||||
|
||||
impl PrometheusMetrics {
|
||||
@@ -117,13 +116,6 @@ impl PrometheusMetrics {
|
||||
Gauge::new("substrate_state_cache_bytes", "State cache size in bytes")?,
|
||||
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() {
|
||||
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_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]
|
||||
codec = { package = "parity-scale-codec", version = "3.0.0", features = ["derive"] }
|
||||
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"
|
||||
sc-client-api = { version = "4.0.0-dev", path = "../api" }
|
||||
sp-core = { version = "7.0.0", path = "../../primitives/core" }
|
||||
|
||||
@@ -49,10 +49,8 @@ mod test;
|
||||
use codec::Codec;
|
||||
use log::trace;
|
||||
use noncanonical::NonCanonicalOverlay;
|
||||
use parity_util_mem::{malloc_size, MallocSizeOf};
|
||||
use parking_lot::RwLock;
|
||||
use pruning::{HaveBlock, RefWindow};
|
||||
use sc_client_api::{MemorySize, StateDbMemoryInfo};
|
||||
use std::{
|
||||
collections::{hash_map::Entry, HashMap},
|
||||
fmt,
|
||||
@@ -220,8 +218,6 @@ pub struct Constraints {
|
||||
/// Maximum blocks. Defaults to 0 when unspecified, effectively keeping only non-canonical
|
||||
/// states.
|
||||
pub max_blocks: Option<u32>,
|
||||
/// Maximum memory in the pruning overlay.
|
||||
pub max_mem: Option<usize>,
|
||||
}
|
||||
|
||||
/// Pruning mode.
|
||||
@@ -238,7 +234,7 @@ pub enum PruningMode {
|
||||
impl PruningMode {
|
||||
/// Create a mode that keeps given number of blocks.
|
||||
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?
|
||||
@@ -276,7 +272,7 @@ impl Default for PruningMode {
|
||||
|
||||
impl Default for Constraints {
|
||||
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,
|
||||
}
|
||||
|
||||
impl<BlockHash: Hash + MallocSizeOf, Key: Hash + MallocSizeOf, D: MetaDb>
|
||||
StateDbSync<BlockHash, Key, D>
|
||||
{
|
||||
impl<BlockHash: Hash, Key: Hash, D: MetaDb> StateDbSync<BlockHash, Key, D> {
|
||||
fn new(
|
||||
mode: PruningMode,
|
||||
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 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)?),
|
||||
PruningMode::ArchiveAll | PruningMode::ArchiveCanonical => None,
|
||||
};
|
||||
@@ -392,10 +385,6 @@ impl<BlockHash: Hash + MallocSizeOf, Key: Hash + MallocSizeOf, D: MetaDb>
|
||||
break
|
||||
}
|
||||
|
||||
if constraints.max_mem.map_or(false, |m| pruning.mem_used() > m) {
|
||||
break
|
||||
}
|
||||
|
||||
let pinned = &self.pinned;
|
||||
match pruning.next_hash() {
|
||||
// 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)
|
||||
}
|
||||
|
||||
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.
|
||||
@@ -512,9 +493,7 @@ pub struct StateDb<BlockHash: Hash, Key: Hash, D: MetaDb> {
|
||||
db: RwLock<StateDbSync<BlockHash, Key, D>>,
|
||||
}
|
||||
|
||||
impl<BlockHash: Hash + MallocSizeOf, Key: Hash + MallocSizeOf, D: MetaDb>
|
||||
StateDb<BlockHash, Key, D>
|
||||
{
|
||||
impl<BlockHash: Hash, Key: Hash, D: MetaDb> StateDb<BlockHash, Key, D> {
|
||||
/// Create an instance of [`StateDb`].
|
||||
pub fn open(
|
||||
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)?;
|
||||
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`
|
||||
@@ -772,10 +746,8 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn block_record_unavailable() {
|
||||
let (mut db, state_db) = make_test_db(PruningMode::Constrained(Constraints {
|
||||
max_blocks: Some(1),
|
||||
max_mem: None,
|
||||
}));
|
||||
let (mut db, state_db) =
|
||||
make_test_db(PruningMode::Constrained(Constraints { max_blocks: Some(1) }));
|
||||
// import 2 blocks
|
||||
for i in &[5, 6] {
|
||||
db.commit(
|
||||
@@ -809,19 +781,13 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn prune_window_0() {
|
||||
let (db, _) = make_test_db(PruningMode::Constrained(Constraints {
|
||||
max_blocks: Some(0),
|
||||
max_mem: None,
|
||||
}));
|
||||
let (db, _) = make_test_db(PruningMode::Constrained(Constraints { max_blocks: Some(0) }));
|
||||
assert!(db.data_eq(&make_db(&[21, 3, 922, 94])));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn prune_window_1() {
|
||||
let (db, sdb) = make_test_db(PruningMode::Constrained(Constraints {
|
||||
max_blocks: Some(1),
|
||||
max_mem: None,
|
||||
}));
|
||||
let (db, sdb) = make_test_db(PruningMode::Constrained(Constraints { max_blocks: Some(1) }));
|
||||
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(21), 2), IsPruned::Pruned);
|
||||
@@ -831,10 +797,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn prune_window_2() {
|
||||
let (db, sdb) = make_test_db(PruningMode::Constrained(Constraints {
|
||||
max_blocks: Some(2),
|
||||
max_mem: None,
|
||||
}));
|
||||
let (db, sdb) = make_test_db(PruningMode::Constrained(Constraints { max_blocks: Some(2) }));
|
||||
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(21), 2), IsPruned::NotPruned);
|
||||
@@ -858,7 +821,7 @@ mod tests {
|
||||
)
|
||||
.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>), _> =
|
||||
StateDb::open(db.clone(), Some(new_mode), false, false);
|
||||
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;
|
||||
|
||||
/// See module documentation.
|
||||
#[derive(parity_util_mem_derive::MallocSizeOf)]
|
||||
pub struct NonCanonicalOverlay<BlockHash: Hash, Key: Hash> {
|
||||
last_canonicalized: Option<(BlockHash, u64)>,
|
||||
levels: VecDeque<OverlayLevel<BlockHash, Key>>,
|
||||
@@ -41,7 +40,6 @@ pub struct NonCanonicalOverlay<BlockHash: Hash, Key: Hash> {
|
||||
pinned_insertions: HashMap<BlockHash, (Vec<Key>, u32)>,
|
||||
}
|
||||
|
||||
#[derive(parity_util_mem_derive::MallocSizeOf)]
|
||||
#[cfg_attr(test, derive(PartialEq, Debug))]
|
||||
struct OverlayLevel<BlockHash: Hash, Key: Hash> {
|
||||
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))]
|
||||
#[derive(parity_util_mem_derive::MallocSizeOf)]
|
||||
struct BlockOverlay<BlockHash: Hash, Key: Hash> {
|
||||
hash: BlockHash,
|
||||
journal_index: u64,
|
||||
|
||||
@@ -36,7 +36,6 @@ pub(crate) const LAST_PRUNED: &[u8] = b"last_pruned";
|
||||
const PRUNING_JOURNAL: &[u8] = b"pruning_journal";
|
||||
|
||||
/// See module documentation.
|
||||
#[derive(parity_util_mem_derive::MallocSizeOf)]
|
||||
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
|
||||
/// 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
|
||||
/// - `DbBacked`, used when the backend database supports reference counting, only keep
|
||||
/// 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> {
|
||||
Mem {
|
||||
/// 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 {
|
||||
// The backend database
|
||||
#[ignore_malloc_size_of = "Shared data"]
|
||||
db: D,
|
||||
/// 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
|
||||
@@ -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> {
|
||||
hash: BlockHash,
|
||||
deleted: HashSet<Key>,
|
||||
@@ -345,10 +342,6 @@ impl<BlockHash: Hash, Key: Hash, D: MetaDb> RefWindow<BlockHash, Key, D> {
|
||||
Ok(res)
|
||||
}
|
||||
|
||||
pub fn mem_used(&self) -> usize {
|
||||
0
|
||||
}
|
||||
|
||||
fn is_empty(&self) -> bool {
|
||||
self.window_size() == 0
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ futures = "0.3.21"
|
||||
futures-timer = "3.0.2"
|
||||
linked-hash-map = "0.5.4"
|
||||
log = "0.4.17"
|
||||
parity-util-mem = { version = "0.12.0", default-features = false, features = ["primitive-types"] }
|
||||
parking_lot = "0.12.1"
|
||||
serde = { version = "1.0.136", features = ["derive"] }
|
||||
thiserror = "1.0.30"
|
||||
|
||||
@@ -84,7 +84,7 @@ pub struct PruneStatus<Hash, Ex> {
|
||||
|
||||
/// Immutable transaction
|
||||
#[cfg_attr(test, derive(Clone))]
|
||||
#[derive(PartialEq, Eq, parity_util_mem::MallocSizeOf)]
|
||||
#[derive(PartialEq, Eq)]
|
||||
pub struct Transaction<Hash, Extrinsic> {
|
||||
/// Raw extrinsic representing that transaction.
|
||||
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.
|
||||
/// Most likely it is required to revalidate them and recompute set of
|
||||
/// required tags.
|
||||
#[derive(Debug, parity_util_mem::MallocSizeOf)]
|
||||
#[derive(Debug)]
|
||||
pub struct BasePool<Hash: hash::Hash + Eq, Ex> {
|
||||
reject_future_transactions: bool,
|
||||
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]
|
||||
fn should_remove_invalid_transactions() {
|
||||
// given
|
||||
|
||||
@@ -28,7 +28,6 @@ use std::time::Instant;
|
||||
|
||||
use super::base_pool::Transaction;
|
||||
|
||||
#[derive(parity_util_mem::MallocSizeOf)]
|
||||
/// Transaction with partially satisfied dependencies.
|
||||
pub struct WaitingTransaction<Hash, Ex> {
|
||||
/// Transaction details.
|
||||
@@ -108,7 +107,7 @@ impl<Hash, Ex> WaitingTransaction<Hash, Ex> {
|
||||
///
|
||||
/// Contains transactions that are still awaiting for some other transactions that
|
||||
/// could provide a tag that they require.
|
||||
#[derive(Debug, parity_util_mem::MallocSizeOf)]
|
||||
#[derive(Debug)]
|
||||
pub struct FutureTransactions<Hash: hash::Hash + Eq, Ex> {
|
||||
/// tags that are not yet provided by any transaction and we await for them
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
#[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>>,
|
||||
}
|
||||
|
||||
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> {
|
||||
/// Create a new transaction pool.
|
||||
pub fn new(options: Options, is_validator: IsValidator, api: Arc<B>) -> Self {
|
||||
|
||||
@@ -37,7 +37,7 @@ use super::{
|
||||
/// An in-pool transaction reference.
|
||||
///
|
||||
/// Should be cheap to clone.
|
||||
#[derive(Debug, parity_util_mem::MallocSizeOf)]
|
||||
#[derive(Debug)]
|
||||
pub struct TransactionRef<Hash, Ex> {
|
||||
/// The actual transaction data.
|
||||
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> {}
|
||||
|
||||
#[derive(Debug, parity_util_mem::MallocSizeOf)]
|
||||
#[derive(Debug)]
|
||||
pub struct ReadyTx<Hash, Ex> {
|
||||
/// A reference to a transaction
|
||||
pub transaction: TransactionRef<Hash, Ex>,
|
||||
@@ -105,7 +105,7 @@ qed
|
||||
"#;
|
||||
|
||||
/// 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> {
|
||||
/// Next free insertion id (used to indicate when a transaction was inserted into the pool).
|
||||
insertion_id: u64,
|
||||
@@ -742,25 +742,6 @@ mod tests {
|
||||
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]
|
||||
fn should_order_refs() {
|
||||
let mut id = 1;
|
||||
|
||||
@@ -33,7 +33,7 @@ pub trait Size {
|
||||
/// Map with size tracking.
|
||||
///
|
||||
/// Size reported might be slightly off and only approximately true.
|
||||
#[derive(Debug, parity_util_mem::MallocSizeOf)]
|
||||
#[derive(Debug)]
|
||||
pub struct TrackedMap<K, V> {
|
||||
index: Arc<RwLock<HashMap<K, V>>>,
|
||||
bytes: AtomicIsize,
|
||||
|
||||
@@ -110,16 +110,6 @@ pub struct ValidatedPool<B: ChainApi> {
|
||||
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> {
|
||||
/// Create a new transaction pool.
|
||||
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.
|
||||
pub enum RevalidationType {
|
||||
/// 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]
|
||||
fn finalization() {
|
||||
let xt = uxt(Alice, 209);
|
||||
|
||||
@@ -44,7 +44,6 @@ serde_json = "1.0.85"
|
||||
assert_matches = "1.3.0"
|
||||
pretty_assertions = "1.2.1"
|
||||
frame-system = { version = "4.0.0-dev", path = "../system" }
|
||||
parity-util-mem = { version = "0.12.0", default-features = false, features = ["primitive-types"] }
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
|
||||
@@ -72,7 +72,7 @@ use sp_runtime::{
|
||||
generic,
|
||||
traits::{
|
||||
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,
|
||||
},
|
||||
DispatchError, RuntimeDebug,
|
||||
@@ -250,7 +250,6 @@ pub mod pallet {
|
||||
+ Copy
|
||||
+ sp_std::hash::Hash
|
||||
+ sp_std::str::FromStr
|
||||
+ MaybeMallocSizeOf
|
||||
+ MaxEncodedLen
|
||||
+ TypeInfo;
|
||||
|
||||
@@ -268,7 +267,6 @@ pub mod pallet {
|
||||
+ sp_std::hash::Hash
|
||||
+ AsRef<[u8]>
|
||||
+ AsMut<[u8]>
|
||||
+ MaybeMallocSizeOf
|
||||
+ MaxEncodedLen;
|
||||
|
||||
/// 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"
|
||||
|
||||
[dependencies]
|
||||
kvdb = "0.12.0"
|
||||
kvdb = "0.13.0"
|
||||
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 }
|
||||
impl-trait-for-tuples = "0.2.2"
|
||||
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"
|
||||
rand = { version = "0.7.2", optional = true }
|
||||
scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }
|
||||
@@ -48,7 +47,6 @@ std = [
|
||||
"either/use_std",
|
||||
"hash256-std-hasher/std",
|
||||
"log/std",
|
||||
"parity-util-mem/std",
|
||||
"rand",
|
||||
"scale-info/std",
|
||||
"serde",
|
||||
|
||||
@@ -25,10 +25,7 @@ use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
codec::{Codec, Decode, Encode},
|
||||
traits::{
|
||||
self, Block as BlockT, Header as HeaderT, MaybeMallocSizeOf, MaybeSerialize, Member,
|
||||
NumberFor,
|
||||
},
|
||||
traits::{self, Block as BlockT, Header as HeaderT, MaybeSerialize, Member, NumberFor},
|
||||
Justifications,
|
||||
};
|
||||
use sp_core::RuntimeDebug;
|
||||
@@ -82,7 +79,7 @@ impl<Block: BlockT> fmt::Display for BlockId<Block> {
|
||||
|
||||
/// Abstraction over a substrate block.
|
||||
#[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(deny_unknown_fields))]
|
||||
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>
|
||||
where
|
||||
Header: HeaderT,
|
||||
Extrinsic: Member + Codec + traits::Extrinsic + MaybeMallocSizeOf,
|
||||
Extrinsic: Member + Codec + traits::Extrinsic,
|
||||
{
|
||||
type Extrinsic = Extrinsic;
|
||||
type Header = Header;
|
||||
|
||||
@@ -34,7 +34,7 @@ use sp_core::RuntimeDebug;
|
||||
|
||||
/// Generic header digest.
|
||||
#[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 {
|
||||
/// A list of logs in the digest.
|
||||
pub logs: Vec<DigestItem>,
|
||||
@@ -70,7 +70,6 @@ impl Digest {
|
||||
/// Digest item that is able to encode/decode 'system' digest items and
|
||||
/// provide opaque access to other items.
|
||||
#[derive(PartialEq, Eq, Clone, RuntimeDebug)]
|
||||
#[cfg_attr(feature = "std", derive(parity_util_mem::MallocSizeOf))]
|
||||
pub enum DigestItem {
|
||||
/// A pre-runtime digest.
|
||||
///
|
||||
|
||||
@@ -22,7 +22,7 @@ use crate::{
|
||||
generic::Digest,
|
||||
scale_info::TypeInfo,
|
||||
traits::{
|
||||
self, AtLeast32BitUnsigned, Hash as HashT, MaybeDisplay, MaybeMallocSizeOf, MaybeSerialize,
|
||||
self, AtLeast32BitUnsigned, Hash as HashT, MaybeDisplay, MaybeSerialize,
|
||||
MaybeSerializeDeserialize, Member, SimpleBitOps,
|
||||
},
|
||||
};
|
||||
@@ -54,22 +54,6 @@ pub struct Header<Number: Copy + Into<U256> + TryFrom<U256>, Hash: HashT> {
|
||||
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")]
|
||||
pub fn serialize_number<S, T: Copy + Into<U256> + TryFrom<U256>>(
|
||||
val: &T,
|
||||
@@ -103,8 +87,7 @@ where
|
||||
+ Copy
|
||||
+ Into<U256>
|
||||
+ TryFrom<U256>
|
||||
+ sp_std::str::FromStr
|
||||
+ MaybeMallocSizeOf,
|
||||
+ sp_std::str::FromStr,
|
||||
Hash: HashT,
|
||||
Hash::Output: Default
|
||||
+ sp_std::hash::Hash
|
||||
@@ -115,8 +98,7 @@ where
|
||||
+ Debug
|
||||
+ MaybeDisplay
|
||||
+ SimpleBitOps
|
||||
+ Codec
|
||||
+ MaybeMallocSizeOf,
|
||||
+ Codec,
|
||||
{
|
||||
type Number = Number;
|
||||
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>
|
||||
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 {
|
||||
#[cfg(feature = "std")]
|
||||
fn fmt(&self, fmt: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result {
|
||||
|
||||
@@ -204,13 +204,10 @@ impl Header {
|
||||
}
|
||||
|
||||
/// 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);
|
||||
|
||||
impl<Xt> traits::Extrinsic for ExtrinsicWrapper<Xt>
|
||||
where
|
||||
Xt: parity_util_mem::MallocSizeOf,
|
||||
{
|
||||
impl<Xt> traits::Extrinsic for ExtrinsicWrapper<Xt> {
|
||||
type Call = ();
|
||||
type SignaturePayload = ();
|
||||
|
||||
@@ -243,7 +240,7 @@ impl<Xt> Deref for ExtrinsicWrapper<Xt> {
|
||||
}
|
||||
|
||||
/// 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> {
|
||||
/// Block 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>
|
||||
where
|
||||
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.
|
||||
trait MaybeSerializeDeserialize: DeserializeOwned, Serialize;
|
||||
|
||||
/// A type that implements MallocSizeOf.
|
||||
trait MaybeMallocSizeOf: parity_util_mem::MallocSizeOf;
|
||||
);
|
||||
|
||||
/// 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`.
|
||||
///
|
||||
/// You can also create a `new` one from those fields.
|
||||
pub trait Header:
|
||||
Clone + Send + Sync + Codec + Eq + MaybeSerialize + Debug + MaybeMallocSizeOf + 'static
|
||||
{
|
||||
pub trait Header: Clone + Send + Sync + Codec + Eq + MaybeSerialize + Debug + 'static {
|
||||
/// Header number.
|
||||
type Number: Member
|
||||
+ MaybeSerializeDeserialize
|
||||
@@ -840,8 +835,7 @@ pub trait Header:
|
||||
+ MaybeDisplay
|
||||
+ AtLeast32BitUnsigned
|
||||
+ Codec
|
||||
+ sp_std::str::FromStr
|
||||
+ MaybeMallocSizeOf;
|
||||
+ sp_std::str::FromStr;
|
||||
/// Header hash type
|
||||
type Hash: Member
|
||||
+ MaybeSerializeDeserialize
|
||||
@@ -855,7 +849,6 @@ pub trait Header:
|
||||
+ Codec
|
||||
+ AsRef<[u8]>
|
||||
+ AsMut<[u8]>
|
||||
+ MaybeMallocSizeOf
|
||||
+ TypeInfo;
|
||||
/// Hashing algorithm
|
||||
type Hashing: Hash<Output = Self::Hash>;
|
||||
@@ -904,13 +897,11 @@ pub trait Header:
|
||||
/// `Extrinsic` pieces of information as well as a `Header`.
|
||||
///
|
||||
/// You can get an iterator over each of the `extrinsics` and retrieve the `header`.
|
||||
pub trait Block:
|
||||
Clone + Send + Sync + Codec + Eq + MaybeSerialize + Debug + MaybeMallocSizeOf + 'static
|
||||
{
|
||||
pub trait Block: Clone + Send + Sync + Codec + Eq + MaybeSerialize + Debug + 'static {
|
||||
/// Type for extrinsics.
|
||||
type Extrinsic: Member + Codec + Extrinsic + MaybeSerialize + MaybeMallocSizeOf;
|
||||
type Extrinsic: Member + Codec + Extrinsic + MaybeSerialize;
|
||||
/// Header type.
|
||||
type Header: Header<Hash = Self::Hash> + MaybeMallocSizeOf;
|
||||
type Header: Header<Hash = Self::Hash>;
|
||||
/// Block hash type.
|
||||
type Hash: Member
|
||||
+ MaybeSerializeDeserialize
|
||||
@@ -924,7 +915,6 @@ pub trait Block:
|
||||
+ Codec
|
||||
+ AsRef<[u8]>
|
||||
+ AsMut<[u8]>
|
||||
+ MaybeMallocSizeOf
|
||||
+ TypeInfo;
|
||||
|
||||
/// Returns a reference to the header.
|
||||
@@ -945,7 +935,7 @@ pub trait Block:
|
||||
}
|
||||
|
||||
/// Something that acts like an `Extrinsic`.
|
||||
pub trait Extrinsic: Sized + MaybeMallocSizeOf {
|
||||
pub trait Extrinsic: Sized {
|
||||
/// The function 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
|
||||
/// by our local node (for instance off-chain workers).
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Encode, Decode, RuntimeDebug)]
|
||||
#[cfg_attr(feature = "std", derive(parity_util_mem::MallocSizeOf))]
|
||||
pub enum TransactionSource {
|
||||
/// Transaction is already included in block.
|
||||
///
|
||||
|
||||
@@ -13,7 +13,6 @@ targets = ["x86_64-unknown-linux-gnu"]
|
||||
|
||||
[dependencies]
|
||||
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 }
|
||||
sp-application-crypto = { version = "7.0.0", default-features = false, path = "../application-crypto" }
|
||||
sp-core = { version = "7.0.0", default-features = false, path = "../core" }
|
||||
@@ -25,7 +24,6 @@ default = [
|
||||
]
|
||||
std = [
|
||||
"codec/std",
|
||||
"parity-util-mem/std",
|
||||
"serde",
|
||||
"sp-application-crypto/std",
|
||||
"sp-core/std",
|
||||
|
||||
@@ -29,7 +29,6 @@ use sp_runtime::traits::{BlakeTwo256, Extrinsic as ExtrinsicT, Verify};
|
||||
|
||||
/// Extrinsic for test-runtime.
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Decode, RuntimeDebug)]
|
||||
#[cfg_attr(feature = "std", derive(parity_util_mem::MallocSizeOf))]
|
||||
pub enum Extrinsic {
|
||||
IncludeData(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 }
|
||||
lazy_static = { version = "1.4.0", 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 }
|
||||
parking_lot = { version = "0.12.1", optional = true }
|
||||
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]
|
||||
array-bytes = "4.1"
|
||||
criterion = "0.3.3"
|
||||
trie-bench = "0.32.0"
|
||||
trie-bench = "0.33.0"
|
||||
trie-standardmap = "0.15.2"
|
||||
sp-runtime = { version = "7.0.0", path = "../runtime" }
|
||||
|
||||
@@ -62,4 +62,3 @@ std = [
|
||||
"trie-db/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.
|
||||
pub type TrieError<L> = trie_db::TrieError<TrieHash<L>, CError<L>>;
|
||||
/// 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.
|
||||
/// This uses a `KeyFunction` for prefixing keys internally (avoiding
|
||||
/// key conflict for non random keys).
|
||||
pub type PrefixedMemoryDB<H> =
|
||||
memory_db::MemoryDB<H, memory_db::PrefixedKey<H>, trie_db::DBValue, MemTracker>;
|
||||
pub type PrefixedMemoryDB<H> = memory_db::MemoryDB<H, memory_db::PrefixedKey<H>, trie_db::DBValue>;
|
||||
/// 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<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.
|
||||
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.
|
||||
pub type TrieDB<'a, 'cache, L> = trie_db::TrieDB<'a, 'cache, L>;
|
||||
@@ -548,8 +542,7 @@ mod tests {
|
||||
type LayoutV0 = super::LayoutV0<Blake2Hasher>;
|
||||
type LayoutV1 = super::LayoutV1<Blake2Hasher>;
|
||||
|
||||
type MemoryDBMeta<H> =
|
||||
memory_db::MemoryDB<H, memory_db::HashKey<H>, trie_db::DBValue, MemTracker>;
|
||||
type MemoryDBMeta<H> = memory_db::MemoryDB<H, memory_db::HashKey<H>, trie_db::DBValue>;
|
||||
|
||||
fn hashed_null_node<T: TrieConfiguration>() -> TrieHash<T> {
|
||||
<T::Codec as NodeCodecT>::hashed_null_node()
|
||||
|
||||
@@ -160,7 +160,6 @@ allow = [
|
||||
]
|
||||
# List of crates to deny
|
||||
deny = [
|
||||
{ name = "parity-util-mem", version = "<0.6" }
|
||||
# Each entry the name of a crate and a version range. If version is
|
||||
# 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"] }
|
||||
sp-inherents = { version = "4.0.0-dev", default-features = false, path = "../../primitives/inherents" }
|
||||
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-core = { version = "7.0.0", default-features = false, path = "../../primitives/core" }
|
||||
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-transaction-pool = { version = "4.0.0-dev", default-features = false, path = "../../primitives/transaction-pool" }
|
||||
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" }
|
||||
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" }
|
||||
@@ -67,7 +66,6 @@ default = [
|
||||
"std",
|
||||
]
|
||||
std = [
|
||||
"parity-util-mem/std",
|
||||
"beefy-primitives/std",
|
||||
"beefy-merkle-tree/std",
|
||||
"sp-application-crypto/std",
|
||||
|
||||
@@ -166,8 +166,6 @@ pub enum Extrinsic {
|
||||
Store(Vec<u8>),
|
||||
}
|
||||
|
||||
parity_util_mem::malloc_size_of_is_0!(Extrinsic); // non-opaque extrinsic does not need this
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
impl serde::Serialize for Extrinsic {
|
||||
fn serialize<S>(&self, seq: S) -> Result<S::Ok, S::Error>
|
||||
|
||||
@@ -22,11 +22,11 @@ handlebars = "4.2.2"
|
||||
hash-db = "0.15.2"
|
||||
Inflector = "0.11.4"
|
||||
itertools = "0.10.3"
|
||||
kvdb = "0.12.0"
|
||||
kvdb = "0.13.0"
|
||||
lazy_static = "1.4.0"
|
||||
linked-hash-map = "0.5.4"
|
||||
log = "0.4.17"
|
||||
memory-db = "0.30.0"
|
||||
memory-db = "0.31.0"
|
||||
rand = { version = "0.8.4", features = ["small_rng"] }
|
||||
rand_pcg = "0.3.1"
|
||||
serde = "1.0.136"
|
||||
|
||||
Reference in New Issue
Block a user