Companion for #8615: enrich metadata with type information (#3336)

* Use beefy branch with scale-info

* Add patches

* Sprinkle some TypeInfo derives

* Add some TypeInfo deriv

* Cargo.lock

* Derive TypeInfo and skip type params for Xcm types

* Cargo.lock

* Fix up scale_info bounds attributes

* Fix up dependencies

* Use my own beefy-primitives branch

* Bump BEEFY

* Update patches

* Add some scale-info dependencies and TypeInfo derives

* More TypeInfo decoration

* Update scale-info

* Some TypeInfos and remove more Event pallet::metadata

* Moar TypeInfos

* TypeInfos galore, fix up metadata runtime API

* TypeInfo

* TypeInfos, update other runtime metadata APIs

* Fix up Kusama, comment out some `usize` QueueSize parameter types

* Remove local diener patches

* Cargo.lock

* Cargo.lock

* Update to scale-info crates.io release

* Update primitive-types branch

* Update pallet-beefy to use custom branch

* Update other parity-common deps

* Update parity-common patches

* bump a bunch of deps in parity-common

* Remove parity-common patches

* Bump finality-grandpa version

* Cargo.lock

* Update scale-info to 0.9.1

* Add recursion_limit for runtime-parachains

* Add some scale_info attributes

* Cargo.lock

* Revert finality-grandpa bump

* Cargo.lock, scale-info update

* cargo update

* Make sure using patched version of finality-grandpa

* Use patched scale-info

* Update to scale-info 0.10.0

* Update finality-grandpa

* Cargo.lock

* Update beefy deps

* Update beefy deps again

* Add scale-info dependency

* Remove deprecated pallet::metadata attributes.

* Add some missing scale-info deps and derives

* Use some variant struct call syntax

* Add missing TypeInfo impl

* Add some more TypeInfo impls

* Convert some call enum struct variant constructors

* More scale-info deps and derives

* Call enum struct variants

* TypeInfo derives

* Call enum variant structs

* scale-info deps and derives

* Call enum variant struct constructors

* Use beefy-primitives scale-info feature

* Use grandpa-bridge-gadget master branch

* Remove finality-grandpa patch

* Add missing scale_info dependency and derive

* Fix up some call variant constructors

* Add missing scale_info dependency

* Fix some test errors

* More TypeInfo derives

* More call variant structs

* Call variant structs in tests

* Cargo.lock

* Fmt

* Fix more call struct variants

* Another call struct variant

* add scale-info/std features explicitly

* More call struct variants

* Add missing scale-info dependency

* Fmt

* review: activate scale-info/std where missing

* Remove some duplicate std feature activation

* review: add scale_info bounds() attr

* More call variant structs

* Remove recursion limit

* Update beefy-primitives

* Update beefy-primitives

* Fix simnet call variant struct errors

* Fmt

* cargo update -p beefy-primitives

* Add some missing TypeInfo derives

* Fix some call variants

* Fix some call variant underscores

* Cargo.lock

* Cargo.lock

* Add missing TypeInfo derive

* Add some more missing TypeInfo derives

* Even more missing TypeInfo derives

* Add TypeInfo derives to new xcm types

* Fmt

* Cargo.lock

* Add missing TypeInfo impls

* Cargo.lock

* More missing TypeInfos

* Fixes

* Cargo.lock

* Cargo.lock

* Add TypeInfo impls to xcm v2

* Update to scale-info 1.0

* Update finality-grandpa 0.14.4, patch for now

* Update beefy

* Remove patched finality-grandpa

* Add TypeInfo impl to Outcome

* Fixes

* Call variant struct

* Call variant struct

* Fix test

* Add TypeInfo impl

* Cargo.lock

* Cargo.lock

* Cargo.lock

* git checkout master Cargo.lock

* update Substrate

* Add missing scale-info features for beefy-primitives

* Fmt

* Remove check for now

* Update beefy-primitives, removes scale-info feature

* Update beefy-primitives again

Co-authored-by: adoerr <0xad@gmx.net>
Co-authored-by: Andronik Ordian <write@reusable.software>
Co-authored-by: thiolliere <gui.thiolliere@gmail.com>
Co-authored-by: parity-processbot <>
Co-authored-by: Bastian Köcher <info@kchr.de>
This commit is contained in:
Andrew Jones
2021-09-15 21:38:45 +01:00
committed by GitHub
parent 44d2e9adbd
commit 4c7539cab5
95 changed files with 819 additions and 548 deletions
+3 -1
View File
@@ -9,7 +9,8 @@ bitvec = { version = "0.20.1", default-features = false, features = ["alloc"] }
parity-scale-codec = { version = "2.0.0", default-features = false, features = ["derive"] }
log = { version = "0.4.14", default-features = false }
rustc-hex = { version = "2.1.0", default-features = false }
serde = { version = "1.0.130", features = ["derive"], optional = true }
scale-info = { version = "1.0", default-features = false, features = ["derive"] }
serde = { version = "1.0.130", features = [ "derive" ], optional = true }
derive_more = "0.99.14"
bitflags = "1.3.2"
@@ -56,6 +57,7 @@ std = [
"bitvec/std",
"parity-scale-codec/std",
"rustc-hex/std",
"scale-info/std",
"serde",
"primitives/std",
"inherents/std",
@@ -33,7 +33,7 @@ pub mod migration;
const LOG_TARGET: &str = "runtime::configuration";
/// All configuration of the runtime with respect to parachains and parathreads.
#[derive(Clone, Encode, Decode, PartialEq, sp_core::RuntimeDebug)]
#[derive(Clone, Encode, Decode, PartialEq, sp_core::RuntimeDebug, scale_info::TypeInfo)]
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))]
pub struct HostConfiguration<BlockNumber> {
// NOTE: This structure is used by parachains via merkle proofs. Therefore, this struct requires
+3 -2
View File
@@ -30,6 +30,7 @@ use primitives::v1::{
InvalidDisputeStatementKind, MultiDisputeStatementSet, SessionIndex, SigningContext,
ValidDisputeStatementKind, ValidatorId, ValidatorIndex, ValidatorSignature,
};
use scale_info::TypeInfo;
use sp_runtime::{
traits::{AppVerify, One, Saturating, Zero},
DispatchError, RuntimeDebug, SaturatedConversion,
@@ -37,14 +38,14 @@ use sp_runtime::{
use sp_std::{collections::btree_set::BTreeSet, prelude::*};
/// Whether the dispute is local or remote.
#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug)]
#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo)]
pub enum DisputeLocation {
Local,
Remote,
}
/// The result of a dispute, whether the candidate is deemed valid (for) or invalid (against).
#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug)]
#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo)]
pub enum DisputeResult {
Valid,
Invalid,
+3 -2
View File
@@ -25,6 +25,7 @@ use primitives::v1::{
Balance, Hash, HrmpChannelId, Id as ParaId, InboundHrmpMessage, OutboundHrmpMessage,
SessionIndex,
};
use scale_info::TypeInfo;
use sp_runtime::traits::{AccountIdConversion, BlakeTwo256, Hash as HashT, UniqueSaturatedInto};
use sp_std::{
collections::{btree_map::BTreeMap, btree_set::BTreeSet},
@@ -35,7 +36,7 @@ use sp_std::{
pub use pallet::*;
/// A description of a request to open an HRMP channel.
#[derive(Encode, Decode)]
#[derive(Encode, Decode, TypeInfo)]
pub struct HrmpOpenChannelRequest {
/// Indicates if this request was confirmed by the recipient.
pub confirmed: bool,
@@ -53,7 +54,7 @@ pub struct HrmpOpenChannelRequest {
}
/// A metadata of an HRMP channel.
#[derive(Encode, Decode)]
#[derive(Encode, Decode, TypeInfo)]
#[cfg_attr(test, derive(Debug))]
pub struct HrmpChannel {
// NOTE: This structure is used by parachains via merkle proofs. Therefore, this struct requires
+3 -3
View File
@@ -28,6 +28,7 @@ use primitives::v1::{
CandidateHash, CandidateReceipt, CommittedCandidateReceipt, CoreIndex, GroupIndex, HeadData,
Id as ParaId, SigningContext, UncheckedSignedAvailabilityBitfields, ValidatorIndex,
};
use scale_info::TypeInfo;
use sp_runtime::{
traits::{One, Saturating},
DispatchError,
@@ -43,7 +44,7 @@ pub use pallet::*;
///
/// The bitfield's signature should be checked at the point of submission. Afterwards it can be
/// dropped.
#[derive(Encode, Decode)]
#[derive(Encode, Decode, TypeInfo)]
#[cfg_attr(test, derive(Debug))]
pub struct AvailabilityBitfieldRecord<N> {
bitfield: AvailabilityBitfield, // one bit per core.
@@ -51,7 +52,7 @@ pub struct AvailabilityBitfieldRecord<N> {
}
/// A backed candidate pending availability.
#[derive(Encode, Decode, PartialEq)]
#[derive(Encode, Decode, PartialEq, TypeInfo)]
#[cfg_attr(test, derive(Debug))]
pub struct CandidatePendingAvailability<H, N> {
/// The availability core this is assigned to.
@@ -134,7 +135,6 @@ pub mod pallet {
#[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)]
#[pallet::metadata(T::Hash = "Hash")]
pub enum Event<T: Config> {
/// A candidate was backed. `[candidate, head_data]`
CandidateBacked(CandidateReceipt<T::Hash>, HeadData, CoreIndex, GroupIndex),
@@ -27,6 +27,7 @@ use crate::{
use frame_support::traits::{OneSessionHandler, Randomness};
use parity_scale_codec::{Decode, Encode};
use primitives::v1::{BlockNumber, ConsensusLog, SessionIndex, ValidatorId};
use scale_info::TypeInfo;
use sp_std::prelude::*;
pub use pallet::*;
@@ -61,7 +62,7 @@ impl<BlockNumber: Default + From<u32>> Default for SessionChangeNotification<Blo
}
}
#[derive(Encode, Decode)]
#[derive(Encode, Decode, TypeInfo)]
struct BufferedSessionChange {
validators: Vec<ValidatorId>,
queued: Vec<ValidatorId>,
+1 -1
View File
@@ -54,7 +54,7 @@ pub mod pallet {
/// Origin for the parachains.
#[pallet::origin]
#[derive(PartialEq, Eq, Clone, Encode, Decode, sp_core::RuntimeDebug)]
#[derive(PartialEq, Eq, Clone, Encode, Decode, sp_core::RuntimeDebug, scale_info::TypeInfo)]
pub enum Origin {
/// It comes from a parachain.
Parachain(ParaId),
+5 -4
View File
@@ -31,6 +31,7 @@ use primitives::v1::{
ConsensusLog, HeadData, Id as ParaId, SessionIndex, UpgradeGoAhead, UpgradeRestriction,
ValidationCode, ValidationCodeHash,
};
use scale_info::TypeInfo;
use sp_core::RuntimeDebug;
use sp_runtime::{traits::One, DispatchResult, SaturatedConversion};
use sp_std::{prelude::*, result};
@@ -43,7 +44,7 @@ pub use crate::Origin as ParachainOrigin;
pub use pallet::*;
// the two key times necessary to track for every code replacement.
#[derive(Default, Encode, Decode)]
#[derive(Default, Encode, Decode, TypeInfo)]
#[cfg_attr(test, derive(Debug, Clone, PartialEq))]
pub struct ReplacementTimes<N> {
/// The relay-chain block number that the code upgrade was expected to be activated.
@@ -58,7 +59,7 @@ pub struct ReplacementTimes<N> {
/// Metadata used to track previous parachain validation code that we keep in
/// the state.
#[derive(Default, Encode, Decode)]
#[derive(Default, Encode, Decode, TypeInfo)]
#[cfg_attr(test, derive(Debug, Clone, PartialEq))]
pub struct ParaPastCodeMeta<N> {
/// Block numbers where the code was expected to be replaced and where the code
@@ -87,7 +88,7 @@ enum UseCodeAt<N> {
/// If the para is in a "transition state", it is expected that the parachain is
/// queued in the `ActionsQueue` to transition it into a stable state. Its lifecycle
/// state will be used to determine the state transition to apply to the para.
#[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug)]
#[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug, TypeInfo)]
pub enum ParaLifecycle {
/// Para is new and is onboarding as a Parathread or Parachain.
Onboarding,
@@ -255,7 +256,7 @@ impl<N: Ord + Copy + PartialEq> ParaPastCodeMeta<N> {
}
/// Arguments for initializing a para.
#[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug)]
#[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug, TypeInfo)]
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
pub struct ParaGenesisArgs {
/// The initial head data to use.
@@ -135,11 +135,11 @@ pub mod pallet {
},
};
Some(Call::enter(inherent_data))
Some(Call::enter { data: inherent_data })
}
fn is_inherent(call: &Self::Call) -> bool {
matches!(call, Call::enter(..))
matches!(call, Call::enter { .. })
}
}
@@ -429,12 +429,14 @@ mod tests {
System::set_block_consumed_resources(used_block_weight, 0);
// execute the paras inherent
let post_info = Call::<Test>::enter(ParachainsInherentData {
bitfields: signed_bitfields,
backed_candidates,
disputes: Vec::new(),
parent_header: default_header(),
})
let post_info = Call::<Test>::enter {
data: ParachainsInherentData {
bitfields: signed_bitfields,
backed_candidates,
disputes: Vec::new(),
parent_header: default_header(),
},
}
.dispatch_bypass_filter(None.into())
.unwrap_err()
.post_info;
@@ -477,12 +479,14 @@ mod tests {
System::set_block_consumed_resources(used_block_weight, 0);
// execute the paras inherent
let post_info = Call::<Test>::enter(ParachainsInherentData {
bitfields: signed_bitfields,
backed_candidates,
disputes: Vec::new(),
parent_header: header,
})
let post_info = Call::<Test>::enter {
data: ParachainsInherentData {
bitfields: signed_bitfields,
backed_candidates,
disputes: Vec::new(),
parent_header: header,
},
}
.dispatch_bypass_filter(None.into())
.unwrap();
+5 -4
View File
@@ -40,6 +40,7 @@ use primitives::v1::{
CollatorId, CoreIndex, CoreOccupied, GroupIndex, GroupRotationInfo, Id as ParaId,
ParathreadClaim, ParathreadEntry, ScheduledCore, ValidatorIndex,
};
use scale_info::TypeInfo;
use sp_runtime::traits::{One, Saturating};
use sp_std::{convert::TryInto, prelude::*};
@@ -48,7 +49,7 @@ use crate::{configuration, initializer::SessionChangeNotification, paras};
pub use pallet::*;
/// A queued parathread entry, pre-assigned to a core.
#[derive(Encode, Decode, Default)]
#[derive(Encode, Decode, Default, TypeInfo)]
#[cfg_attr(test, derive(PartialEq, Debug))]
pub struct QueuedParathread {
claim: ParathreadEntry,
@@ -56,7 +57,7 @@ pub struct QueuedParathread {
}
/// The queue of all parathread claims.
#[derive(Encode, Decode, Default)]
#[derive(Encode, Decode, Default, TypeInfo)]
#[cfg_attr(test, derive(PartialEq, Debug))]
pub struct ParathreadClaimQueue {
queue: Vec<QueuedParathread>,
@@ -97,7 +98,7 @@ pub enum FreedReason {
}
/// The assignment type.
#[derive(Clone, Encode, Decode)]
#[derive(Clone, Encode, Decode, TypeInfo)]
#[cfg_attr(feature = "std", derive(PartialEq, Debug))]
pub enum AssignmentKind {
/// A parachain.
@@ -107,7 +108,7 @@ pub enum AssignmentKind {
}
/// How a free core is scheduled to be assigned.
#[derive(Clone, Encode, Decode)]
#[derive(Clone, Encode, Decode, TypeInfo)]
#[cfg_attr(feature = "std", derive(PartialEq, Debug))]
pub struct CoreAssignment {
/// The core that is assigned.