Serialize/Deserialize trait implemented in no-std for numerous types (#7312)

* ParaId: Serialize/Deserialize trait implemented in no-std

* Serialize/Deserialize trait implemented in no-std for more types

* serde in deps enabled

* fix

* missing types added

* update lockfile for {"substrate"}

* ".git/.scripts/commands/fmt/fmt.sh"

---------

Co-authored-by: parity-processbot <>
This commit is contained in:
Michal Kucharczyk
2023-06-01 17:17:49 +01:00
committed by GitHub
parent 306270b889
commit a767358122
16 changed files with 359 additions and 265 deletions
+183 -183
View File
File diff suppressed because it is too large Load Diff
+5 -5
View File
@@ -10,17 +10,17 @@ version.workspace = true
# this crate for WASM. This is critical to avoid forcing all parachain WASM into implementing # this crate for WASM. This is critical to avoid forcing all parachain WASM into implementing
# various unnecessary Substrate-specific endpoints. # various unnecessary Substrate-specific endpoints.
parity-scale-codec = { version = "3.4.0", default-features = false, features = [ "derive" ] } parity-scale-codec = { version = "3.4.0", default-features = false, features = [ "derive" ] }
scale-info = { version = "2.5.0", default-features = false, features = ["derive"] } scale-info = { version = "2.5.0", default-features = false, features = ["derive", "serde"] }
sp-std = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } 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 } sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, features = ["serde"] }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } sp-core = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, features = ["serde"] }
frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
polkadot-core-primitives = { path = "../core-primitives", default-features = false } polkadot-core-primitives = { path = "../core-primitives", default-features = false }
derive_more = "0.99.11" derive_more = "0.99.11"
bounded-collections = { version = "0.1.7", default-features = false } bounded-collections = { version = "0.1.7", default-features = false, features = ["serde"] }
# all optional crates. # all optional crates.
serde = { version = "1.0.163", default-features = false, features = [ "derive" ], optional = true } serde = { version = "1.0.163", default-features = false, features = ["derive", "alloc"] }
[features] [features]
default = ["std"] default = ["std"]
+33 -14
View File
@@ -23,14 +23,9 @@ use bounded_collections::{BoundedVec, ConstU32};
use frame_support::weights::Weight; use frame_support::weights::Weight;
use parity_scale_codec::{CompactAs, Decode, Encode, MaxEncodedLen}; use parity_scale_codec::{CompactAs, Decode, Encode, MaxEncodedLen};
use scale_info::TypeInfo; use scale_info::TypeInfo;
use sp_core::{RuntimeDebug, TypeId};
use sp_runtime::traits::Hash as _;
#[cfg(feature = "std")]
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use sp_core::{bytes, RuntimeDebug, TypeId};
#[cfg(feature = "std")] use sp_runtime::traits::Hash as _;
use sp_core::bytes;
use polkadot_core_primitives::{Hash, OutboundHrmpMessage}; use polkadot_core_primitives::{Hash, OutboundHrmpMessage};
@@ -39,10 +34,21 @@ pub use polkadot_core_primitives::BlockNumber as RelayChainBlockNumber;
/// Parachain head data included in the chain. /// Parachain head data included in the chain.
#[derive( #[derive(
PartialEq, Eq, Clone, PartialOrd, Ord, Encode, Decode, RuntimeDebug, derive_more::From, TypeInfo, PartialEq,
Eq,
Clone,
PartialOrd,
Ord,
Encode,
Decode,
RuntimeDebug,
derive_more::From,
TypeInfo,
Serialize,
Deserialize,
)] )]
#[cfg_attr(feature = "std", derive(Serialize, Deserialize, Hash, Default))] #[cfg_attr(feature = "std", derive(Hash, Default))]
pub struct HeadData(#[cfg_attr(feature = "std", serde(with = "bytes"))] pub Vec<u8>); pub struct HeadData(#[serde(with = "bytes")] pub Vec<u8>);
impl HeadData { impl HeadData {
/// Returns the hash of this head data. /// Returns the hash of this head data.
@@ -52,9 +58,20 @@ impl HeadData {
} }
/// Parachain validation code. /// Parachain validation code.
#[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug, derive_more::From, TypeInfo)] #[derive(
#[cfg_attr(feature = "std", derive(Serialize, Deserialize, Hash))] PartialEq,
pub struct ValidationCode(#[cfg_attr(feature = "std", serde(with = "bytes"))] pub Vec<u8>); Eq,
Clone,
Encode,
Decode,
RuntimeDebug,
derive_more::From,
TypeInfo,
Serialize,
Deserialize,
)]
#[cfg_attr(feature = "std", derive(Hash))]
pub struct ValidationCode(#[serde(with = "bytes")] pub Vec<u8>);
impl ValidationCode { impl ValidationCode {
/// Get the blake2-256 hash of the validation code bytes. /// Get the blake2-256 hash of the validation code bytes.
@@ -129,9 +146,11 @@ pub struct BlockData(#[cfg_attr(feature = "std", serde(with = "bytes"))] pub Vec
PartialEq, PartialEq,
PartialOrd, PartialOrd,
RuntimeDebug, RuntimeDebug,
serde::Serialize,
serde::Deserialize,
TypeInfo, TypeInfo,
)] )]
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize, derive_more::Display))] #[cfg_attr(feature = "std", derive(derive_more::Display))]
pub struct Id(u32); pub struct Id(u32);
impl TypeId for Id { impl TypeId for Id {
+9 -9
View File
@@ -8,20 +8,20 @@ edition.workspace = true
bitvec = { version = "1.0.0", default-features = false, features = ["alloc"] } bitvec = { version = "1.0.0", default-features = false, features = ["alloc"] }
hex-literal = "0.4.1" hex-literal = "0.4.1"
parity-scale-codec = { version = "3.4.0", default-features = false, features = ["bit-vec", "derive"] } parity-scale-codec = { version = "3.4.0", default-features = false, features = ["bit-vec", "derive"] }
scale-info = { version = "2.5.0", default-features = false, features = ["bit-vec", "derive"] } scale-info = { version = "2.5.0", default-features = false, features = ["bit-vec", "derive", "serde"] }
serde = { version = "1.0.163", optional = true, features = ["derive"] } serde = { version = "1.0.163", default-features = false, features = ["derive", "alloc"] }
application-crypto = { package = "sp-application-crypto", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } application-crypto = { package = "sp-application-crypto", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, features = ["serde"] }
inherents = { package = "sp-inherents", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } inherents = { package = "sp-inherents", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
primitives = { package = "sp-core", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } primitives = { package = "sp-core", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
runtime_primitives = { package = "sp-runtime", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } runtime_primitives = { package = "sp-runtime", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-api = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } sp-api = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-arithmetic = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } sp-arithmetic = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, features = ["serde"] }
sp-authority-discovery = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } sp-authority-discovery = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, features = ["serde"] }
sp-consensus-slots = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } sp-consensus-slots = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, features = ["serde"] }
sp-io = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } sp-io = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "master", optional = true } sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "master", optional = true , features = ["serde"]}
sp-staking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } sp-staking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, features = ["serde"] }
sp-std = { package = "sp-std", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } sp-std = { package = "sp-std", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
polkadot-core-primitives = { path = "../core-primitives", default-features = false } polkadot-core-primitives = { path = "../core-primitives", default-features = false }
@@ -44,7 +44,7 @@ std = [
"sp-staking/std", "sp-staking/std",
"sp-arithmetic/std", "sp-arithmetic/std",
"runtime_primitives/std", "runtime_primitives/std",
"serde", "serde/std",
"polkadot-parachain/std", "polkadot-parachain/std",
"polkadot-core-primitives/std", "polkadot-core-primitives/std",
"bitvec/std", "bitvec/std",
@@ -25,11 +25,11 @@ use crate::{BlakeTwo256, HashT as _, PvfExecTimeoutKind, PvfPrepTimeoutKind};
use parity_scale_codec::{Decode, Encode}; use parity_scale_codec::{Decode, Encode};
use polkadot_core_primitives::Hash; use polkadot_core_primitives::Hash;
use scale_info::TypeInfo; use scale_info::TypeInfo;
use serde::{Deserialize, Serialize};
use sp_std::{ops::Deref, time::Duration, vec, vec::Vec}; use sp_std::{ops::Deref, time::Duration, vec, vec::Vec};
/// The different executor parameters for changing the execution environment semantics. /// The different executor parameters for changing the execution environment semantics.
#[derive(Clone, Debug, Encode, Decode, PartialEq, Eq, TypeInfo)] #[derive(Clone, Debug, Encode, Decode, PartialEq, Eq, TypeInfo, Serialize, Deserialize)]
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))]
pub enum ExecutorParam { pub enum ExecutorParam {
/// Maximum number of memory pages (64KiB bytes per page) the executor can allocate. /// Maximum number of memory pages (64KiB bytes per page) the executor can allocate.
#[codec(index = 1)] #[codec(index = 1)]
@@ -93,8 +93,7 @@ impl sp_std::fmt::LowerHex for ExecutorParamsHash {
// into individual fields of the structure. Thus, complex migrations shall be avoided when adding // into individual fields of the structure. Thus, complex migrations shall be avoided when adding
// new entries and removing old ones. At the moment, there's no mandatory parameters defined. If // new entries and removing old ones. At the moment, there's no mandatory parameters defined. If
// they show up, they must be clearly documented as mandatory ones. // they show up, they must be clearly documented as mandatory ones.
#[derive(Clone, Debug, Encode, Decode, PartialEq, Eq, TypeInfo)] #[derive(Clone, Debug, Encode, Decode, PartialEq, Eq, TypeInfo, Serialize, Deserialize)]
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))]
pub struct ExecutorParams(Vec<ExecutorParam>); pub struct ExecutorParams(Vec<ExecutorParam>);
impl ExecutorParams { impl ExecutorParams {
+2 -5
View File
@@ -47,7 +47,6 @@ pub use polkadot_parachain::primitives::{
ValidationCodeHash, LOWEST_PUBLIC_ID, LOWEST_USER_ID, ValidationCodeHash, LOWEST_PUBLIC_ID, LOWEST_USER_ID,
}; };
#[cfg(feature = "std")]
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
pub use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; pub use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
@@ -1762,8 +1761,7 @@ impl<T: Encode> WellKnownKey<T> {
} }
/// Type discriminator for PVF preparation timeouts /// Type discriminator for PVF preparation timeouts
#[derive(Encode, Decode, TypeInfo, Clone, Copy, Debug, PartialEq, Eq)] #[derive(Encode, Decode, TypeInfo, Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))]
pub enum PvfPrepTimeoutKind { pub enum PvfPrepTimeoutKind {
/// For prechecking requests, the time period after which the preparation worker is considered /// For prechecking requests, the time period after which the preparation worker is considered
/// unresponsive and will be killed. /// unresponsive and will be killed.
@@ -1776,8 +1774,7 @@ pub enum PvfPrepTimeoutKind {
} }
/// Type discriminator for PVF execution timeouts /// Type discriminator for PVF execution timeouts
#[derive(Encode, Decode, TypeInfo, Clone, Copy, Debug, PartialEq, Eq)] #[derive(Encode, Decode, TypeInfo, Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))]
pub enum PvfExecTimeoutKind { pub enum PvfExecTimeoutKind {
/// The amount of time to spend on execution during backing. /// The amount of time to spend on execution during backing.
Backing, Backing,
+11 -2
View File
@@ -26,8 +26,17 @@ use primitives::RuntimeDebug;
use scale_info::TypeInfo; use scale_info::TypeInfo;
/// Candidate's acceptance limitations for asynchronous backing per relay parent. /// Candidate's acceptance limitations for asynchronous backing per relay parent.
#[derive(RuntimeDebug, Copy, Clone, PartialEq, Encode, Decode, TypeInfo)] #[derive(
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] RuntimeDebug,
Copy,
Clone,
PartialEq,
Encode,
Decode,
TypeInfo,
serde::Serialize,
serde::Deserialize,
)]
pub struct AsyncBackingParams { pub struct AsyncBackingParams {
/// The maximum number of para blocks between the para head in a relay parent /// The maximum number of para blocks between the para head in a relay parent
/// and a new candidate. Restricts nodes from building arbitrary long chains /// and a new candidate. Restricts nodes from building arbitrary long chains
+6 -7
View File
@@ -11,19 +11,19 @@ parity-scale-codec = { version = "3.4.0", default-features = false, features = [
log = { version = "0.4.17", default-features = false } log = { version = "0.4.17", default-features = false }
rustc-hex = { version = "2.1.0", default-features = false } rustc-hex = { version = "2.1.0", default-features = false }
scale-info = { version = "2.5.0", default-features = false, features = ["derive"] } scale-info = { version = "2.5.0", default-features = false, features = ["derive"] }
serde = { version = "1.0.163", default-features = false } serde = { version = "1.0.163", default-features = false, features = ["alloc"] }
serde_derive = { version = "1.0.117", optional = true } serde_derive = { version = "1.0.117" }
static_assertions = "1.1.0" static_assertions = "1.1.0"
sp-api = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } sp-api = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
inherents = { package = "sp-inherents", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } inherents = { package = "sp-inherents", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-std = { package = "sp-std", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } sp-std = { package = "sp-std", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-io = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } sp-io = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false , features=["serde"]}
sp-session = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } sp-session = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-staking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } sp-staking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, features=["serde"] }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } sp-core = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false , features=["serde"]}
sp-npos-elections = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } sp-npos-elections = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, features=["serde"] }
pallet-authorship = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-authorship = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
@@ -70,7 +70,6 @@ std = [
"scale-info/std", "scale-info/std",
"log/std", "log/std",
"rustc-hex/std", "rustc-hex/std",
"serde_derive",
"serde/std", "serde/std",
"primitives/std", "primitives/std",
"inherents/std", "inherents/std",
+5 -5
View File
@@ -26,7 +26,6 @@ pub use pallet::*;
use parity_scale_codec::{Decode, Encode}; use parity_scale_codec::{Decode, Encode};
use primitives::ValidityError; use primitives::ValidityError;
use scale_info::TypeInfo; use scale_info::TypeInfo;
#[cfg(feature = "std")]
use serde::{self, Deserialize, Deserializer, Serialize, Serializer}; use serde::{self, Deserialize, Deserializer, Serialize, Serializer};
use sp_io::{crypto::secp256k1_ecdsa_recover, hashing::keccak_256}; use sp_io::{crypto::secp256k1_ecdsa_recover, hashing::keccak_256};
use sp_runtime::{ use sp_runtime::{
@@ -36,6 +35,8 @@ use sp_runtime::{
}, },
RuntimeDebug, RuntimeDebug,
}; };
#[cfg(not(feature = "std"))]
use sp_std::alloc::{format, string::String};
use sp_std::{fmt::Debug, prelude::*}; use sp_std::{fmt::Debug, prelude::*};
type CurrencyOf<T> = <<T as Config>::VestingSchedule as VestingSchedule< type CurrencyOf<T> = <<T as Config>::VestingSchedule as VestingSchedule<
@@ -71,8 +72,9 @@ impl WeightInfo for TestWeightInfo {
} }
/// The kind of statement an account needs to make for a claim to be valid. /// The kind of statement an account needs to make for a claim to be valid.
#[derive(Encode, Decode, Clone, Copy, Eq, PartialEq, RuntimeDebug, TypeInfo)] #[derive(
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] Encode, Decode, Clone, Copy, Eq, PartialEq, RuntimeDebug, TypeInfo, Serialize, Deserialize,
)]
pub enum StatementKind { pub enum StatementKind {
/// Statement required to be made by non-SAFT holders. /// Statement required to be made by non-SAFT holders.
Regular, Regular,
@@ -108,7 +110,6 @@ impl Default for StatementKind {
#[derive(Clone, Copy, PartialEq, Eq, Encode, Decode, Default, RuntimeDebug, TypeInfo)] #[derive(Clone, Copy, PartialEq, Eq, Encode, Decode, Default, RuntimeDebug, TypeInfo)]
pub struct EthereumAddress([u8; 20]); pub struct EthereumAddress([u8; 20]);
#[cfg(feature = "std")]
impl Serialize for EthereumAddress { impl Serialize for EthereumAddress {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where where
@@ -119,7 +120,6 @@ impl Serialize for EthereumAddress {
} }
} }
#[cfg(feature = "std")]
impl<'de> Deserialize<'de> for EthereumAddress { impl<'de> Deserialize<'de> for EthereumAddress {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where where
+6 -6
View File
@@ -10,7 +10,7 @@ parity-scale-codec = { version = "3.4.0", default-features = false, features = [
log = { version = "0.4.17", default-features = false } log = { version = "0.4.17", default-features = false }
rustc-hex = { version = "2.1.0", default-features = false } rustc-hex = { version = "2.1.0", default-features = false }
scale-info = { version = "2.5.0", default-features = false, features = ["derive"] } scale-info = { version = "2.5.0", default-features = false, features = ["derive"] }
serde = { version = "1.0.163", features = [ "derive" ], optional = true } serde = { version = "1.0.163", default-features = false, features = ["derive", "alloc"] }
derive_more = "0.99.17" derive_more = "0.99.17"
bitflags = "1.3.2" bitflags = "1.3.2"
@@ -18,11 +18,11 @@ sp-api = { git = "https://github.com/paritytech/substrate", branch = "master", d
inherents = { package = "sp-inherents", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } inherents = { package = "sp-inherents", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-std = { package = "sp-std", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } sp-std = { package = "sp-std", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-io = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } sp-io = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, features=["serde"] }
sp-session = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } sp-session = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-staking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } sp-staking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, features=["serde"] }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } sp-core = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, features=["serde"] }
sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "master", optional = true } sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "master", optional = true, features=["serde"] }
sp-application-crypto = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true } sp-application-crypto = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true }
sp-tracing = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true } sp-tracing = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true }
@@ -69,7 +69,7 @@ std = [
"parity-scale-codec/std", "parity-scale-codec/std",
"rustc-hex/std", "rustc-hex/std",
"scale-info/std", "scale-info/std",
"serde", "serde/std",
"primitives/std", "primitives/std",
"inherents/std", "inherents/std",
"sp-core/std", "sp-core/std",
@@ -44,8 +44,16 @@ pub use pallet::*;
const LOG_TARGET: &str = "runtime::configuration"; const LOG_TARGET: &str = "runtime::configuration";
/// All configuration of the runtime with respect to parachains and parathreads. /// All configuration of the runtime with respect to parachains and parathreads.
#[derive(Clone, Encode, Decode, PartialEq, sp_core::RuntimeDebug, scale_info::TypeInfo)] #[derive(
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] Clone,
Encode,
Decode,
PartialEq,
sp_core::RuntimeDebug,
scale_info::TypeInfo,
serde::Serialize,
serde::Deserialize,
)]
pub struct HostConfiguration<BlockNumber> { pub struct HostConfiguration<BlockNumber> {
// NOTE: This structure is used by parachains via merkle proofs. Therefore, this struct requires // NOTE: This structure is used by parachains via merkle proofs. Therefore, this struct requires
// special treatment. // special treatment.
+2 -6
View File
@@ -129,7 +129,6 @@ use sp_runtime::{
}; };
use sp_std::{cmp, collections::btree_set::BTreeSet, mem, prelude::*}; use sp_std::{cmp, collections::btree_set::BTreeSet, mem, prelude::*};
#[cfg(feature = "std")]
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
pub use crate::Origin as ParachainOrigin; pub use crate::Origin as ParachainOrigin;
@@ -290,15 +289,14 @@ impl<N: Ord + Copy + PartialEq> ParaPastCodeMeta<N> {
} }
/// Arguments for initializing a para. /// Arguments for initializing a para.
#[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug, TypeInfo)] #[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug, TypeInfo, Serialize, Deserialize)]
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
pub struct ParaGenesisArgs { pub struct ParaGenesisArgs {
/// The initial head data to use. /// The initial head data to use.
pub genesis_head: HeadData, pub genesis_head: HeadData,
/// The initial validation code to use. /// The initial validation code to use.
pub validation_code: ValidationCode, pub validation_code: ValidationCode,
/// Parachain or Parathread. /// Parachain or Parathread.
#[cfg_attr(feature = "std", serde(rename = "parachain"))] #[serde(rename = "parachain")]
pub para_kind: ParaKind, pub para_kind: ParaKind,
} }
@@ -309,7 +307,6 @@ pub enum ParaKind {
Parachain, Parachain,
} }
#[cfg(feature = "std")]
impl Serialize for ParaKind { impl Serialize for ParaKind {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where where
@@ -322,7 +319,6 @@ impl Serialize for ParaKind {
} }
} }
#[cfg(feature = "std")]
impl<'de> Deserialize<'de> for ParaKind { impl<'de> Deserialize<'de> for ParaKind {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where where
+5 -5
View File
@@ -6,14 +6,14 @@ authors.workspace = true
edition.workspace = true edition.workspace = true
[dependencies] [dependencies]
bounded-collections = { version = "0.1.7", default-features = false } bounded-collections = { version = "0.1.7", default-features = false, features = ["serde"] }
derivative = { version = "2.2.0", default-features = false, features = [ "use_core" ] } derivative = { version = "2.2.0", default-features = false, features = [ "use_core" ] }
impl-trait-for-tuples = "0.2.2" impl-trait-for-tuples = "0.2.2"
log = { version = "0.4.17", default-features = false } log = { version = "0.4.17", default-features = false }
parity-scale-codec = { version = "3.4.0", default-features = false, features = [ "derive", "max-encoded-len" ] } parity-scale-codec = { version = "3.4.0", default-features = false, features = [ "derive", "max-encoded-len" ] }
scale-info = { version = "2.5.0", default-features = false, features = ["derive"] } scale-info = { version = "2.5.0", default-features = false, features = ["derive", "serde"] }
sp-weights = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } sp-weights = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, feature = ["serde "] }
serde = { version = "1.0.163", optional = true, features = ["derive"] } serde = { version = "1.0.163", default-features = false, features = ["alloc", "derive"] }
xcm-procedural = { path = "procedural" } xcm-procedural = { path = "procedural" }
[dev-dependencies] [dev-dependencies]
@@ -28,6 +28,6 @@ std = [
"bounded-collections/std", "bounded-collections/std",
"parity-scale-codec/std", "parity-scale-codec/std",
"scale-info/std", "scale-info/std",
"serde", "serde/std",
"sp-weights/std", "sp-weights/std",
] ]
+53 -8
View File
@@ -28,15 +28,27 @@ use bounded_collections::{BoundedSlice, BoundedVec, ConstU32};
use core::convert::{TryFrom, TryInto}; use core::convert::{TryFrom, TryInto};
use parity_scale_codec::{self, Decode, Encode, MaxEncodedLen}; use parity_scale_codec::{self, Decode, Encode, MaxEncodedLen};
use scale_info::TypeInfo; use scale_info::TypeInfo;
use serde::{Deserialize, Serialize};
/// A global identifier of a data structure existing within consensus. /// A global identifier of a data structure existing within consensus.
/// ///
/// Maintenance note: Networks with global consensus and which are practically bridgeable within the /// Maintenance note: Networks with global consensus and which are practically bridgeable within the
/// Polkadot ecosystem are given preference over explicit naming in this enumeration. /// Polkadot ecosystem are given preference over explicit naming in this enumeration.
#[derive( #[derive(
Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo, MaxEncodedLen, Copy,
Clone,
Eq,
PartialEq,
Ord,
PartialOrd,
Encode,
Decode,
Debug,
TypeInfo,
MaxEncodedLen,
Serialize,
Deserialize,
)] )]
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))]
pub enum NetworkId { pub enum NetworkId {
/// Network specified by the first 32 bytes of its genesis block. /// Network specified by the first 32 bytes of its genesis block.
ByGenesis([u8; 32]), ByGenesis([u8; 32]),
@@ -78,9 +90,20 @@ impl From<OldNetworkId> for Option<NetworkId> {
/// An identifier of a pluralistic body. /// An identifier of a pluralistic body.
#[derive( #[derive(
Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo, MaxEncodedLen, Copy,
Clone,
Eq,
PartialEq,
Ord,
PartialOrd,
Encode,
Decode,
Debug,
TypeInfo,
MaxEncodedLen,
Serialize,
Deserialize,
)] )]
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))]
pub enum BodyId { pub enum BodyId {
/// The only body in its context. /// The only body in its context.
Unit, Unit,
@@ -137,9 +160,20 @@ impl TryFrom<OldBodyId> for BodyId {
/// A part of a pluralistic body. /// A part of a pluralistic body.
#[derive( #[derive(
Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo, MaxEncodedLen, Copy,
Clone,
Eq,
PartialEq,
Ord,
PartialOrd,
Encode,
Decode,
Debug,
TypeInfo,
MaxEncodedLen,
Serialize,
Deserialize,
)] )]
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))]
pub enum BodyPart { pub enum BodyPart {
/// The body's declaration, under whatever means it decides. /// The body's declaration, under whatever means it decides.
Voice, Voice,
@@ -201,9 +235,20 @@ impl TryFrom<OldBodyPart> for BodyPart {
/// ///
/// Each item assumes a pre-existing location as its context and is defined in terms of it. /// Each item assumes a pre-existing location as its context and is defined in terms of it.
#[derive( #[derive(
Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo, MaxEncodedLen, Copy,
Clone,
Eq,
PartialEq,
Ord,
PartialOrd,
Encode,
Decode,
Debug,
TypeInfo,
MaxEncodedLen,
Serialize,
Deserialize,
)] )]
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))]
pub enum Junction { pub enum Junction {
/// An indexed parachain belonging to and operated by the context. /// An indexed parachain belonging to and operated by the context.
/// ///
+13 -2
View File
@@ -30,9 +30,20 @@ pub(crate) const MAX_JUNCTIONS: usize = 8;
/// Parent junctions cannot be constructed with this type. Refer to `MultiLocation` for /// Parent junctions cannot be constructed with this type. Refer to `MultiLocation` for
/// instructions on constructing parent junctions. /// instructions on constructing parent junctions.
#[derive( #[derive(
Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo, MaxEncodedLen, Copy,
Clone,
Eq,
PartialEq,
Ord,
PartialOrd,
Encode,
Decode,
Debug,
TypeInfo,
MaxEncodedLen,
serde::Serialize,
serde::Deserialize,
)] )]
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))]
pub enum Junctions { pub enum Junctions {
/// The interpreting consensus system. /// The interpreting consensus system.
Here, Here,
+13 -2
View File
@@ -52,9 +52,20 @@ use scale_info::TypeInfo;
/// ///
/// The `MultiLocation` value of `Null` simply refers to the interpreting consensus system. /// The `MultiLocation` value of `Null` simply refers to the interpreting consensus system.
#[derive( #[derive(
Copy, Clone, Decode, Encode, Eq, PartialEq, Ord, PartialOrd, Debug, TypeInfo, MaxEncodedLen, Copy,
Clone,
Decode,
Encode,
Eq,
PartialEq,
Ord,
PartialOrd,
Debug,
TypeInfo,
MaxEncodedLen,
serde::Serialize,
serde::Deserialize,
)] )]
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))]
pub struct MultiLocation { pub struct MultiLocation {
/// The number of parent junctions at the beginning of this `MultiLocation`. /// The number of parent junctions at the beginning of this `MultiLocation`.
pub parents: u8, pub parents: u8,