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:
Marcin S
2022-12-06 09:55:10 -05:00
committed by GitHub
parent 07117e7913
commit aa21e56744
46 changed files with 70 additions and 426 deletions
+1 -1
View File
@@ -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"
-2
View File
@@ -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>
{
-7
View File
@@ -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 {
+3 -9
View File
@@ -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,
+6 -16
View File
@@ -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>>),
+2 -3
View File
@@ -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 = []
+4 -11
View File
@@ -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()