Companion for paritytech/substrate#12795 (#6374)

* Begin removing `parity-util-mem`; remove `collect_memory_stats`

* Update some dependencies that were using `parity-util-mem`

* Remove `trie-memory-tracker` feature

* Update Cargo.lock

* Update `kvdb-shared-tests`

* Add back jemalloc

* Add missing license header

* update lockfile for {"substrate"}

Co-authored-by: parity-processbot <>
Co-authored-by: Andronik <write@reusable.software>
This commit is contained in:
Marcin S
2022-12-06 11:41:00 -05:00
committed by GitHub
parent 800a928ab0
commit 3f951cce16
22 changed files with 291 additions and 395 deletions
+193 -239
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -21,7 +21,7 @@ version = "0.9.33"
[dependencies]
polkadot-cli = { path = "cli", features = [ "kusama-native", "westend-native", "rococo-native" ] }
color-eyre = { version = "0.6.1", default-features = false }
parity-util-mem = { version = "0.12.0", default-features = false, features = ["jemalloc-global"] }
tikv-jemallocator = "0.5.0"
[dev-dependencies]
assert_cmd = "2.0.4"
+1 -6
View File
@@ -35,15 +35,11 @@ polkadot-node-metrics = { path = "../node/metrics" }
sc-tracing = { git = "https://github.com/paritytech/substrate", branch = "master", optional = true }
sc-sysinfo = { git = "https://github.com/paritytech/substrate", branch = "master" }
# this crate is used only to enable `trie-memory-tracker` feature
# see https://github.com/paritytech/substrate/pull/6745
sp-trie = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
[build-dependencies]
substrate-build-script-utils = { git = "https://github.com/paritytech/substrate", branch = "master" }
[features]
default = ["db", "cli", "hostperfcheck", "full-node", "trie-memory-tracker", "polkadot-native"]
default = ["db", "cli", "hostperfcheck", "full-node", "polkadot-native"]
db = ["service/db"]
cli = [
"clap",
@@ -60,7 +56,6 @@ runtime-benchmarks = [
"polkadot-node-metrics/runtime-benchmarks",
"polkadot-performance-test?/runtime-benchmarks"
]
trie-memory-tracker = ["sp-trie/memory-tracker"]
full-node = ["service/full-node"]
try-runtime = ["service/try-runtime", "try-runtime-cli/try-runtime"]
fast-runtime = ["service/fast-runtime"]
-2
View File
@@ -10,7 +10,6 @@ sp-std = { git = "https://github.com/paritytech/substrate", branch = "master", d
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
scale-info = { version = "2.1.2", default-features = false, features = ["derive"] }
parity-scale-codec = { version = "3.1.5", default-features = false, features = [ "derive" ] }
parity-util-mem = { version = "0.12.0", default-features = false, optional = true }
[features]
default = [ "std" ]
@@ -21,5 +20,4 @@ std = [
"sp-std/std",
"scale-info/std",
"parity-scale-codec/std",
"parity-util-mem",
]
-6
View File
@@ -21,8 +21,6 @@
//! These core Polkadot types are used by the relay chain and the Parachains.
use parity_scale_codec::{Decode, Encode};
#[cfg(feature = "std")]
use parity_util_mem::MallocSizeOf;
use scale_info::TypeInfo;
use sp_runtime::{
generic,
@@ -66,7 +64,6 @@ pub type Hash = sp_core::H256;
///
/// This type makes it easy to enforce that a hash is a candidate hash on the type level.
#[derive(Clone, Copy, Encode, Decode, Hash, Eq, PartialEq, Default, PartialOrd, Ord, TypeInfo)]
#[cfg_attr(feature = "std", derive(MallocSizeOf))]
pub struct CandidateHash(pub Hash);
#[cfg(feature = "std")]
@@ -127,7 +124,6 @@ pub type DownwardMessage = sp_std::vec::Vec<u8>;
/// A wrapped version of `DownwardMessage`. The difference is that it has attached the block number when
/// the message was sent.
#[derive(Encode, Decode, Clone, sp_runtime::RuntimeDebug, PartialEq, TypeInfo)]
#[cfg_attr(feature = "std", derive(MallocSizeOf))]
pub struct InboundDownwardMessage<BlockNumber = crate::BlockNumber> {
/// The block number at which these messages were put into the downward message queue.
pub sent_at: BlockNumber,
@@ -137,7 +133,6 @@ pub struct InboundDownwardMessage<BlockNumber = crate::BlockNumber> {
/// An HRMP message seen from the perspective of a recipient.
#[derive(Encode, Decode, Clone, sp_runtime::RuntimeDebug, PartialEq, TypeInfo)]
#[cfg_attr(feature = "std", derive(MallocSizeOf))]
pub struct InboundHrmpMessage<BlockNumber = crate::BlockNumber> {
/// The block number at which this message was sent.
/// Specifically, it is the block number at which the candidate that sends this message was
@@ -149,7 +144,6 @@ pub struct InboundHrmpMessage<BlockNumber = crate::BlockNumber> {
/// An HRMP message seen from the perspective of a sender.
#[derive(Encode, Decode, Clone, sp_runtime::RuntimeDebug, PartialEq, Eq, Hash, TypeInfo)]
#[cfg_attr(feature = "std", derive(MallocSizeOf))]
pub struct OutboundHrmpMessage<Id> {
/// The para that will get this message in its downward message queue.
pub recipient: Id,
@@ -13,7 +13,7 @@ bitvec = { version = "1.0.0", default-features = false, features = ["alloc"] }
lru = "0.8"
merlin = "2.0"
schnorrkel = "0.9.1"
kvdb = "0.12.0"
kvdb = "0.13.0"
derive_more = "0.99.17"
thiserror = "1.0.31"
@@ -40,5 +40,5 @@ sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-consensus-babe = { git = "https://github.com/paritytech/substrate", branch = "master" }
polkadot-node-subsystem-test-helpers = { path = "../../subsystem-test-helpers" }
assert_matches = "1.4.0"
kvdb-memorydb = "0.12.0"
kvdb-memorydb = "0.13.0"
test-helpers = { package = "polkadot-primitives-test-helpers", path = "../../../primitives/test-helpers" }
+2 -2
View File
@@ -7,7 +7,7 @@ edition.workspace = true
[dependencies]
futures = "0.3.21"
futures-timer = "3.0.2"
kvdb = "0.12.0"
kvdb = "0.13.0"
thiserror = "1.0.31"
gum = { package = "tracing-gum", path = "../../gum" }
bitvec = "1.0.0"
@@ -24,7 +24,7 @@ polkadot-node-primitives = { path = "../../primitives" }
log = "0.4.17"
env_logger = "0.9.0"
assert_matches = "1.4.0"
kvdb-memorydb = "0.12.0"
kvdb-memorydb = "0.13.0"
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
polkadot-node-subsystem-util = { path = "../../subsystem-util" }
@@ -13,7 +13,7 @@ polkadot-primitives = { path = "../../../primitives" }
polkadot-node-primitives = { path = "../../primitives" }
polkadot-node-subsystem = { path = "../../subsystem" }
polkadot-node-subsystem-util = { path = "../../subsystem-util" }
kvdb = "0.12.0"
kvdb = "0.13.0"
thiserror = "1.0.31"
parity-scale-codec = "3.1.5"
@@ -22,4 +22,4 @@ polkadot-node-subsystem-test-helpers = { path = "../../subsystem-test-helpers" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
parking_lot = "0.12.0"
assert_matches = "1"
kvdb-memorydb = "0.12.0"
kvdb-memorydb = "0.13.0"
@@ -8,7 +8,7 @@ edition.workspace = true
futures = "0.3.21"
gum = { package = "tracing-gum", path = "../../gum" }
parity-scale-codec = "3.1.5"
kvdb = "0.12.0"
kvdb = "0.13.0"
thiserror = "1.0.31"
lru = "0.8.0"
fatality = "0.0.6"
@@ -22,7 +22,7 @@ sc-keystore = { git = "https://github.com/paritytech/substrate", branch = "maste
[dev-dependencies]
kvdb-memorydb = "0.12.0"
kvdb-memorydb = "0.13.0"
polkadot-node-subsystem-test-helpers = { path = "../../subsystem-test-helpers" }
sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
-1
View File
@@ -23,7 +23,6 @@ polkadot-node-core-backing = { path = "../core/backing" }
polkadot-node-primitives = { path = "../primitives" }
polkadot-primitives = { path = "../../primitives" }
polkadot-node-core-pvf = { path = "../core/pvf" }
parity-util-mem = { version = "0.12.0", default-features = false, features = ["jemalloc-global"] }
color-eyre = { version = "0.6.1", default-features = false }
assert_matches = "1.5"
async-trait = "0.1.57"
+1 -1
View File
@@ -18,9 +18,9 @@ polkadot-primitives = { path = "../../primitives" }
orchestra = "0.0.2"
gum = { package = "tracing-gum", path = "../gum" }
lru = "0.8"
parity-util-mem = { version = "0.12.0", default-features = false }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
async-trait = "0.1.57"
tikv-jemalloc-ctl = "0.5.0"
[dev-dependencies]
metered = { package = "prioritized-metered-channel", version = "0.2.0" }
+3 -2
View File
@@ -101,8 +101,6 @@ pub use polkadot_node_metrics::{
Metronome,
};
use parity_util_mem::MemoryAllocationTracker;
pub use orchestra as gen;
pub use orchestra::{
contextbounds, orchestra, subsystem, FromOrchestra, MapSubsystem, MessagePacket,
@@ -118,11 +116,14 @@ pub const KNOWN_LEAVES_CACHE_SIZE: NonZeroUsize = match NonZeroUsize::new(2 * 24
None => panic!("Known leaves cache size must be non-zero"),
};
mod memory_stats;
#[cfg(test)]
mod tests;
use sp_core::traits::SpawnNamed;
use memory_stats::MemoryAllocationTracker;
/// Glue to connect `trait orchestra::Spawner` and `SpawnNamed` from `substrate`.
pub struct SpawnGlue<S>(pub S);
@@ -0,0 +1,53 @@
// Copyright 2017-2022 Parity Technologies (UK) Ltd.
// This file is part of Polkadot.
// Polkadot is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Polkadot is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
use tikv_jemalloc_ctl::{epoch, stats, Error};
#[derive(Clone)]
pub struct MemoryAllocationTracker {
epoch: tikv_jemalloc_ctl::epoch_mib,
allocated: stats::allocated_mib,
resident: stats::resident_mib,
}
impl MemoryAllocationTracker {
pub fn new() -> Result<Self, Error> {
Ok(Self {
epoch: epoch::mib()?,
allocated: stats::allocated::mib()?,
resident: stats::resident::mib()?,
})
}
pub fn snapshot(&self) -> Result<MemoryAllocationSnapshot, Error> {
// update stats by advancing the allocation epoch
self.epoch.advance()?;
let allocated: u64 = self.allocated.read()? as _;
let resident: u64 = self.resident.read()? as _;
Ok(MemoryAllocationSnapshot { allocated, resident })
}
}
/// Snapshot of collected memory metrics.
#[non_exhaustive]
#[derive(Debug, Clone)]
pub struct MemoryAllocationSnapshot {
/// Total resident memory, in bytes.
pub resident: u64,
/// Total allocated memory, in bytes.
pub allocated: u64,
}
+1 -1
View File
@@ -19,7 +19,7 @@
use super::*;
pub use polkadot_node_metrics::metrics::{self, prometheus, Metrics as MetricsTrait};
use parity_util_mem::MemoryAllocationSnapshot;
use memory_stats::MemoryAllocationSnapshot;
/// Overseer Prometheus metrics.
#[derive(Clone)]
+2 -2
View File
@@ -71,8 +71,8 @@ gum = { package = "tracing-gum", path = "../gum/" }
serde = { version = "1.0.137", features = ["derive"] }
serde_json = "1.0.81"
thiserror = "1.0.31"
kvdb = "0.12.0"
kvdb-rocksdb = { version = "0.16.0", optional = true }
kvdb = "0.13.0"
kvdb-rocksdb = { version = "0.17.0", optional = true }
parity-db = { version = "0.4.2", optional = true }
async-trait = "0.1.57"
+3 -4
View File
@@ -32,8 +32,7 @@ sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-application-crypto = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "master" }
kvdb = "0.12.0"
parity-util-mem = { version = "0.12.0", default-features = false }
kvdb = "0.13.0"
parity-db = { version = "0.4.2"}
[dev-dependencies]
@@ -44,6 +43,6 @@ log = "0.4.17"
polkadot-node-subsystem-test-helpers = { path = "../subsystem-test-helpers" }
lazy_static = "1.4.0"
polkadot-primitives-test-helpers = { path = "../../primitives/test-helpers" }
kvdb-shared-tests = "0.10.0"
kvdb-shared-tests = "0.11.0"
tempfile = "3.1.0"
kvdb-memorydb = "0.12.0"
kvdb-memorydb = "0.13.0"
@@ -29,7 +29,6 @@ pub trait Database: KeyValueDB {
pub mod kvdb_impl {
use super::{DBKeyValue, DBTransaction, DBValue, Database, KeyValueDB};
use kvdb::{DBOp, IoStats, IoStatsKind};
use parity_util_mem::{MallocSizeOf, MallocSizeOfOps};
use std::{collections::BTreeSet, io::Result};
/// Adapter implementing subsystem database
@@ -123,13 +122,6 @@ pub mod kvdb_impl {
self.db.has_prefix(col, prefix)
}
}
impl<D: KeyValueDB> MallocSizeOf for DbAdapter<D> {
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
// ignore filter set
self.db.size_of(ops)
}
}
}
/// Utilities for using parity-db database.
@@ -160,12 +152,6 @@ pub mod paritydb_impl {
write_lock: Arc<Mutex<()>>,
}
impl parity_util_mem::MallocSizeOf for DbAdapter {
fn size_of(&self, _ops: &mut parity_util_mem::MallocSizeOfOps) -> usize {
unimplemented!("size_of is not supported for parity_db")
}
}
impl KeyValueDB for DbAdapter {
fn transaction(&self) -> DBTransaction {
DBTransaction::new()
-2
View File
@@ -10,7 +10,6 @@ version.workspace = true
# this crate for WASM. This is critical to avoid forcing all parachain WASM into implementing
# various unnecessary Substrate-specific endpoints.
parity-scale-codec = { version = "3.1.5", default-features = false, features = [ "derive" ] }
parity-util-mem = { version = "0.12.0", default-features = false, optional = true }
scale-info = { version = "2.1.2", default-features = false, features = ["derive"] }
sp-std = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
@@ -32,7 +31,6 @@ std = [
"sp-std/std",
"sp-runtime/std",
"sp-core/std",
"parity-util-mem",
"polkadot-core-primitives/std",
"frame-support/std",
]
+4 -11
View File
@@ -31,9 +31,6 @@ use serde::{Deserialize, Serialize};
#[cfg(feature = "std")]
use sp_core::bytes;
#[cfg(feature = "std")]
use parity_util_mem::MallocSizeOf;
use polkadot_core_primitives::{Hash, OutboundHrmpMessage};
/// Block number type used by the relay chain.
@@ -43,7 +40,7 @@ pub use polkadot_core_primitives::BlockNumber as RelayChainBlockNumber;
#[derive(
PartialEq, Eq, Clone, PartialOrd, Ord, Encode, Decode, RuntimeDebug, derive_more::From, TypeInfo,
)]
#[cfg_attr(feature = "std", derive(Serialize, Deserialize, Hash, MallocSizeOf, Default))]
#[cfg_attr(feature = "std", derive(Serialize, Deserialize, Hash, Default))]
pub struct HeadData(#[cfg_attr(feature = "std", serde(with = "bytes"))] pub Vec<u8>);
impl HeadData {
@@ -55,7 +52,7 @@ impl HeadData {
/// Parachain validation code.
#[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug, derive_more::From, TypeInfo)]
#[cfg_attr(feature = "std", derive(Serialize, Deserialize, Hash, MallocSizeOf))]
#[cfg_attr(feature = "std", derive(Serialize, Deserialize, Hash))]
pub struct ValidationCode(#[cfg_attr(feature = "std", serde(with = "bytes"))] pub Vec<u8>);
impl ValidationCode {
@@ -71,7 +68,6 @@ impl ValidationCode {
///
/// This type makes it easy to enforce that a hash is a validation code hash on the type level.
#[derive(Clone, Copy, Encode, Decode, Hash, Eq, PartialEq, PartialOrd, Ord, TypeInfo)]
#[cfg_attr(feature = "std", derive(MallocSizeOf))]
pub struct ValidationCodeHash(Hash);
impl sp_std::fmt::Display for ValidationCodeHash {
@@ -114,7 +110,7 @@ impl sp_std::fmt::LowerHex for ValidationCodeHash {
///
/// Contains everything required to validate para-block, may contain block and witness data.
#[derive(PartialEq, Eq, Clone, Encode, Decode, derive_more::From, TypeInfo, RuntimeDebug)]
#[cfg_attr(feature = "std", derive(Serialize, Deserialize, MallocSizeOf))]
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
pub struct BlockData(#[cfg_attr(feature = "std", serde(with = "bytes"))] pub Vec<u8>);
/// Unique identifier of a parachain.
@@ -134,10 +130,7 @@ pub struct BlockData(#[cfg_attr(feature = "std", serde(with = "bytes"))] pub Vec
RuntimeDebug,
TypeInfo,
)]
#[cfg_attr(
feature = "std",
derive(serde::Serialize, serde::Deserialize, derive_more::Display, MallocSizeOf)
)]
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize, derive_more::Display))]
pub struct Id(u32);
impl TypeId for Id {
-2
View File
@@ -8,7 +8,6 @@ edition.workspace = true
bitvec = { version = "1.0.0", default-features = false, features = ["alloc"] }
hex-literal = "0.3.4"
parity-scale-codec = { version = "3.1.5", default-features = false, features = ["bit-vec", "derive"] }
parity-util-mem = { version = "0.12.0", default-features = false, optional = true }
scale-info = { version = "2.1.2", default-features = false, features = ["bit-vec", "derive"] }
serde = { version = "1.0.137", optional = true, features = ["derive"] }
@@ -46,7 +45,6 @@ std = [
"sp-arithmetic/std",
"runtime_primitives/std",
"serde",
"parity-util-mem",
"polkadot-parachain/std",
"polkadot-core-primitives/std",
"bitvec/std",
+16 -93
View File
@@ -47,8 +47,6 @@ pub use polkadot_parachain::primitives::{
LOWEST_PUBLIC_ID, LOWEST_USER_ID,
};
#[cfg(feature = "std")]
use parity_util_mem::{MallocSizeOf, MallocSizeOfOps};
#[cfg(feature = "std")]
use serde::{Deserialize, Serialize};
@@ -77,16 +75,6 @@ mod collator_app {
/// Identity that collators use.
pub type CollatorId = collator_app::Public;
#[cfg(feature = "std")]
impl MallocSizeOf for CollatorId {
fn size_of(&self, _ops: &mut MallocSizeOfOps) -> usize {
0
}
fn constant_size() -> Option<usize> {
Some(0)
}
}
/// A Parachain collator keypair.
#[cfg(feature = "std")]
pub type CollatorPair = collator_app::Pair;
@@ -94,16 +82,6 @@ pub type CollatorPair = collator_app::Pair;
/// Signature on candidate's block data by a collator.
pub type CollatorSignature = collator_app::Signature;
#[cfg(feature = "std")]
impl MallocSizeOf for CollatorSignature {
fn size_of(&self, _ops: &mut MallocSizeOfOps) -> usize {
0
}
fn constant_size() -> Option<usize> {
Some(0)
}
}
/// The key type ID for a parachain validator key.
pub const PARACHAIN_KEY_TYPE_ID: KeyTypeId = KeyTypeId(*b"para");
@@ -118,16 +96,6 @@ mod validator_app {
/// so we define it to be the same type as `SessionKey`. In the future it may have different crypto.
pub type ValidatorId = validator_app::Public;
#[cfg(feature = "std")]
impl MallocSizeOf for ValidatorId {
fn size_of(&self, _ops: &mut MallocSizeOfOps) -> usize {
0
}
fn constant_size() -> Option<usize> {
Some(0)
}
}
/// Trait required for type specific indices e.g. `ValidatorIndex` and `GroupIndex`
pub trait TypeIndex {
/// Returns the index associated to this value.
@@ -136,7 +104,7 @@ pub trait TypeIndex {
/// Index of the validator is used as a lightweight replacement of the `ValidatorId` when appropriate.
#[derive(Eq, Ord, PartialEq, PartialOrd, Copy, Clone, Encode, Decode, TypeInfo, RuntimeDebug)]
#[cfg_attr(feature = "std", derive(Serialize, Deserialize, Hash, MallocSizeOf))]
#[cfg_attr(feature = "std", derive(Serialize, Deserialize, Hash))]
pub struct ValidatorIndex(pub u32);
// We should really get https://github.com/paritytech/polkadot/issues/2403 going ..
@@ -163,16 +131,6 @@ application_crypto::with_pair! {
/// so we define it to be the same type as `SessionKey`. In the future it may have different crypto.
pub type ValidatorSignature = validator_app::Signature;
#[cfg(feature = "std")]
impl MallocSizeOf for ValidatorSignature {
fn size_of(&self, _ops: &mut MallocSizeOfOps) -> usize {
0
}
fn constant_size() -> Option<usize> {
Some(0)
}
}
/// A declarations of storage keys where an external observer can find some interesting data.
pub mod well_known_keys {
use super::{HrmpChannelId, Id};
@@ -406,16 +364,6 @@ application_crypto::with_pair! {
pub type AssignmentPair = assignment_app::Pair;
}
#[cfg(feature = "std")]
impl MallocSizeOf for AssignmentId {
fn size_of(&self, _ops: &mut MallocSizeOfOps) -> usize {
0
}
fn constant_size() -> Option<usize> {
Some(0)
}
}
/// The index of the candidate in the list of candidates fully included as-of the block.
pub type CandidateIndex = u32;
@@ -465,7 +413,7 @@ fn check_collator_signature<H: AsRef<[u8]>>(
/// A unique descriptor of the candidate receipt.
#[derive(PartialEq, Eq, Clone, Encode, Decode, TypeInfo, RuntimeDebug)]
#[cfg_attr(feature = "std", derive(Hash, MallocSizeOf))]
#[cfg_attr(feature = "std", derive(Hash))]
pub struct CandidateDescriptor<H = Hash> {
/// The ID of the para this is a candidate for.
pub para_id: Id,
@@ -507,7 +455,6 @@ impl<H: AsRef<[u8]>> CandidateDescriptor<H> {
/// A candidate-receipt.
#[derive(PartialEq, Eq, Clone, Encode, Decode, TypeInfo, RuntimeDebug)]
#[cfg_attr(feature = "std", derive(MallocSizeOf))]
pub struct CandidateReceipt<H = Hash> {
/// The descriptor of the candidate.
pub descriptor: CandidateDescriptor<H>,
@@ -544,7 +491,7 @@ pub struct FullCandidateReceipt<H = Hash, N = BlockNumber> {
/// A candidate-receipt with commitments directly included.
#[derive(PartialEq, Eq, Clone, Encode, Decode, TypeInfo, RuntimeDebug)]
#[cfg_attr(feature = "std", derive(Hash, MallocSizeOf))]
#[cfg_attr(feature = "std", derive(Hash))]
pub struct CommittedCandidateReceipt<H = Hash> {
/// The descriptor of the candidate.
pub descriptor: CandidateDescriptor<H>,
@@ -625,7 +572,7 @@ impl Ord for CommittedCandidateReceipt {
/// The `PersistedValidationData` should be relatively lightweight primarily because it is constructed
/// during inclusion for each candidate and therefore lies on the critical path of inclusion.
#[derive(PartialEq, Eq, Clone, Encode, Decode, TypeInfo, RuntimeDebug)]
#[cfg_attr(feature = "std", derive(Default, MallocSizeOf))]
#[cfg_attr(feature = "std", derive(Default))]
pub struct PersistedValidationData<H = Hash, N = BlockNumber> {
/// The parent head-data.
pub parent_head: HeadData,
@@ -646,7 +593,7 @@ impl<H: Encode, N: Encode> PersistedValidationData<H, N> {
/// Commitments made in a `CandidateReceipt`. Many of these are outputs of validation.
#[derive(PartialEq, Eq, Clone, Encode, Decode, TypeInfo, RuntimeDebug)]
#[cfg_attr(feature = "std", derive(Hash, MallocSizeOf, Default))]
#[cfg_attr(feature = "std", derive(Hash, Default))]
pub struct CandidateCommitments<N = BlockNumber> {
/// Messages destined to be interpreted by the Relay chain itself.
pub upward_messages: Vec<UpwardMessage>,
@@ -787,7 +734,7 @@ pub fn check_candidate_backing<H: AsRef<[u8]> + Clone + Encode>(
#[derive(
Encode, Decode, Default, PartialOrd, Ord, Eq, PartialEq, Clone, Copy, TypeInfo, RuntimeDebug,
)]
#[cfg_attr(feature = "std", derive(Hash, MallocSizeOf))]
#[cfg_attr(feature = "std", derive(Hash))]
pub struct CoreIndex(pub u32);
impl From<u32> for CoreIndex {
@@ -804,7 +751,7 @@ impl TypeIndex for CoreIndex {
/// The unique (during session) index of a validator group.
#[derive(Encode, Decode, Default, Clone, Copy, Debug, PartialEq, Eq, TypeInfo)]
#[cfg_attr(feature = "std", derive(Hash, MallocSizeOf))]
#[cfg_attr(feature = "std", derive(Hash))]
pub struct GroupIndex(pub u32);
impl From<u32> for GroupIndex {
@@ -846,7 +793,7 @@ pub enum CoreOccupied {
/// A helper data-type for tracking validator-group rotations.
#[derive(Clone, Encode, Decode, TypeInfo, RuntimeDebug)]
#[cfg_attr(feature = "std", derive(PartialEq, MallocSizeOf))]
#[cfg_attr(feature = "std", derive(PartialEq))]
pub struct GroupRotationInfo<N = BlockNumber> {
/// The block number where the session started.
pub session_start_block: N,
@@ -934,7 +881,7 @@ impl<N: Saturating + BaseArithmetic + Copy> GroupRotationInfo<N> {
/// Information about a core which is currently occupied.
#[derive(Clone, Encode, Decode, TypeInfo, RuntimeDebug)]
#[cfg_attr(feature = "std", derive(PartialEq, MallocSizeOf))]
#[cfg_attr(feature = "std", derive(PartialEq))]
pub struct OccupiedCore<H = Hash, N = BlockNumber> {
// NOTE: this has no ParaId as it can be deduced from the candidate descriptor.
/// If this core is freed by availability, this is the assignment that is next up on this
@@ -951,7 +898,6 @@ pub struct OccupiedCore<H = Hash, N = BlockNumber> {
/// A bitfield with 1 bit for each validator in the set. `1` bits mean that the corresponding
/// validators has attested to availability on-chain. A 2/3+ majority of `1` bits means that
/// this will be available.
#[cfg_attr(feature = "std", ignore_malloc_size_of = "outside type")]
pub availability: BitVec<u8, bitvec::order::Lsb0>,
/// The group assigned to distribute availability pieces of this candidate.
pub group_responsible: GroupIndex,
@@ -970,7 +916,7 @@ impl<H, N> OccupiedCore<H, N> {
/// Information about a core which is currently occupied.
#[derive(Clone, Encode, Decode, TypeInfo, RuntimeDebug)]
#[cfg_attr(feature = "std", derive(PartialEq, MallocSizeOf))]
#[cfg_attr(feature = "std", derive(PartialEq))]
pub struct ScheduledCore {
/// The ID of a para scheduled.
pub para_id: Id,
@@ -980,7 +926,7 @@ pub struct ScheduledCore {
/// The state of a particular availability core.
#[derive(Clone, Encode, Decode, TypeInfo, RuntimeDebug)]
#[cfg_attr(feature = "std", derive(PartialEq, MallocSizeOf))]
#[cfg_attr(feature = "std", derive(PartialEq))]
pub enum CoreState<H = Hash, N = BlockNumber> {
/// The core is currently occupied.
#[codec(index = 0)]
@@ -1031,7 +977,7 @@ pub enum OccupiedCoreAssumption {
/// An even concerning a candidate.
#[derive(Clone, Encode, Decode, TypeInfo, RuntimeDebug)]
#[cfg_attr(feature = "std", derive(PartialEq, MallocSizeOf))]
#[cfg_attr(feature = "std", derive(PartialEq))]
pub enum CandidateEvent<H = Hash> {
/// This candidate receipt was backed in the most recent block.
/// This includes the core index the candidate is now occupying.
@@ -1050,7 +996,7 @@ pub enum CandidateEvent<H = Hash> {
/// Scraped runtime backing votes and resolved disputes.
#[derive(Clone, Encode, Decode, RuntimeDebug, TypeInfo)]
#[cfg_attr(feature = "std", derive(PartialEq, MallocSizeOf))]
#[cfg_attr(feature = "std", derive(PartialEq))]
pub struct ScrapedOnChainVotes<H: Encode + Decode = Hash> {
/// The session in which the block was included.
pub session: SessionIndex,
@@ -1239,7 +1185,6 @@ impl From<ConsensusLog> for runtime_primitives::DigestItem {
///
/// Statements are either in favor of the candidate's validity or against it.
#[derive(Encode, Decode, Clone, PartialEq, RuntimeDebug, TypeInfo)]
#[cfg_attr(feature = "std", derive(MallocSizeOf))]
pub enum DisputeStatement {
/// A valid statement, of the given kind.
#[codec(index = 0)]
@@ -1320,7 +1265,6 @@ impl DisputeStatement {
/// Different kinds of statements of validity on a candidate.
#[derive(Encode, Decode, Copy, Clone, PartialEq, RuntimeDebug, TypeInfo)]
#[cfg_attr(feature = "std", derive(MallocSizeOf))]
pub enum ValidDisputeStatementKind {
/// An explicit statement issued as part of a dispute.
#[codec(index = 0)]
@@ -1338,7 +1282,6 @@ pub enum ValidDisputeStatementKind {
/// Different kinds of statements of invalidity on a candidate.
#[derive(Encode, Decode, Copy, Clone, PartialEq, RuntimeDebug, TypeInfo)]
#[cfg_attr(feature = "std", derive(MallocSizeOf))]
pub enum InvalidDisputeStatementKind {
/// An explicit statement issued as part of a dispute.
#[codec(index = 0)]
@@ -1367,7 +1310,6 @@ impl ExplicitDisputeStatement {
/// A set of statements about a specific candidate.
#[derive(Encode, Decode, Clone, PartialEq, RuntimeDebug, TypeInfo)]
#[cfg_attr(feature = "std", derive(MallocSizeOf))]
pub struct DisputeStatementSet {
/// The candidate referenced by this set.
pub candidate_hash: CandidateHash,
@@ -1432,22 +1374,6 @@ pub struct DisputeState<N = BlockNumber> {
pub concluded_at: Option<N>,
}
#[cfg(feature = "std")]
impl MallocSizeOf for DisputeState {
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
// destructuring to make sure no new fields are added to the struct without modifying this function
let Self { validators_for, validators_against, start, concluded_at } = self;
// According to the documentation `.capacity()` might not return a byte aligned value, so just in case:
let align_eight = |d: usize| (d + 7) / 8;
align_eight(validators_for.capacity()) +
align_eight(validators_against.capacity()) +
start.size_of(ops) +
concluded_at.size_of(ops)
}
}
/// Parachains inherent-data passed into the runtime by a block author
#[derive(Encode, Decode, Clone, PartialEq, RuntimeDebug, TypeInfo)]
pub struct InherentData<HDR: HeaderT = Header> {
@@ -1464,7 +1390,6 @@ pub struct InherentData<HDR: HeaderT = Header> {
/// An either implicit or explicit attestation to the validity of a parachain
/// candidate.
#[derive(Clone, Eq, PartialEq, Decode, Encode, RuntimeDebug, TypeInfo)]
#[cfg_attr(feature = "std", derive(MallocSizeOf))]
pub enum ValidityAttestation {
/// Implicit validity attestation by issuing.
/// This corresponds to issuance of a `Candidate` statement.
@@ -1600,7 +1525,7 @@ impl CompactStatement {
/// `IndexedVec` struct indexed by type specific indices.
#[derive(Clone, Encode, Decode, RuntimeDebug, TypeInfo)]
#[cfg_attr(feature = "std", derive(PartialEq, MallocSizeOf))]
#[cfg_attr(feature = "std", derive(PartialEq))]
pub struct IndexedVec<K, V>(Vec<V>, PhantomData<fn(K) -> K>);
impl<K, V> Default for IndexedVec<K, V> {
@@ -1679,7 +1604,7 @@ pub fn supermajority_threshold(n: usize) -> usize {
/// Information about validator sets of a session.
#[derive(Clone, Encode, Decode, RuntimeDebug, TypeInfo)]
#[cfg_attr(feature = "std", derive(PartialEq, MallocSizeOf))]
#[cfg_attr(feature = "std", derive(PartialEq))]
pub struct SessionInfo {
/****** New in v2 *******/
/// All the validators actively participating in parachain consensus.
@@ -1705,7 +1630,6 @@ pub struct SessionInfo {
/// `validators`, afterwards any remaining authorities can be found. This is any authorities not
/// participating in parachain consensus - see
/// [`max_validators`](https://github.com/paritytech/polkadot/blob/a52dca2be7840b23c19c153cf7e110b1e3e475f8/runtime/parachains/src/configuration.rs#L148)
#[cfg_attr(feature = "std", ignore_malloc_size_of = "outside type")]
pub discovery_keys: Vec<AuthorityDiscoveryId>,
/// The assignment keys for validators.
///
@@ -1765,7 +1689,7 @@ impl PvfCheckStatement {
/// Old, v1-style info about session info. Only needed for limited
/// backwards-compatibility.
#[derive(Clone, Encode, Decode, RuntimeDebug, TypeInfo)]
#[cfg_attr(feature = "std", derive(PartialEq, MallocSizeOf))]
#[cfg_attr(feature = "std", derive(PartialEq))]
pub struct OldV1SessionInfo {
/// Validators in canonical ordering.
///
@@ -1781,7 +1705,6 @@ pub struct OldV1SessionInfo {
/// `validators`, afterwards any remaining authorities can be found. This is any authorities not
/// participating in parachain consensus - see
/// [`max_validators`](https://github.com/paritytech/polkadot/blob/a52dca2be7840b23c19c153cf7e110b1e3e475f8/runtime/parachains/src/configuration.rs#L148)
#[cfg_attr(feature = "std", ignore_malloc_size_of = "outside type")]
pub discovery_keys: Vec<AuthorityDiscoveryId>,
/// The assignment keys for validators.
///
+5
View File
@@ -20,6 +20,11 @@
use color_eyre::eyre;
/// Global allocator. Changing it to another allocator will require changing
/// `memory_stats::MemoryAllocationTracker`.
#[global_allocator]
pub static ALLOC: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;
fn main() -> eyre::Result<()> {
color_eyre::install()?;
polkadot_cli::run()?;