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
@@ -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.
///