Skip to content

Commit 5362fbb

Browse files
WebWizrd8shawntabrizibkchr
committed
Metadata v14 (companion to #3336) (#564)
* Remove event pallet::metadata attributes * Add scale-info deps, TypeInfo derives, update call variants * Update metadata runtime APIs * Add missing scale_info dependency, update rococo runtime API * Add missing scale_info dependency * Remove pushed diener patches * Cargo.lock * Add missing scale-info dependencies * Fixes * Statemint runtime fixes * Call struct variant empty matches * Add missing scale-info dependency * Fixes * scale-info 1.0 * cargo update -p xcm * update lock * Update Cargo.lock * update to latest polkadot * remove rpc_http_threads paritytech/substrate#9737 * replace task executor with tokio handler paritytech/substrate#9737 * fix test compilation? * Update Cargo.lock * cargo update * remove unused * Update substrate and polkadot * Update test/client/src/lib.rs Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com> Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
1 parent 0cb3cb2 commit 5362fbb

File tree

36 files changed

+576
-409
lines changed

36 files changed

+576
-409
lines changed

Cargo.lock

+352-248
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/cli/src/lib.rs

+17-13
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,15 @@
2020

2121
use sc_cli;
2222
use sc_service::{
23-
BasePath,
24-
config::{TelemetryEndpoints, PrometheusConfig},
25-
TransactionPoolOptions,
23+
config::{PrometheusConfig, TelemetryEndpoints},
24+
BasePath, TransactionPoolOptions,
2625
};
2726
use std::{
2827
fs,
2928
io::{self, Write},
29+
net::SocketAddr,
3030
};
3131
use structopt::StructOpt;
32-
use std::net::SocketAddr;
3332

3433
/// The `purge-chain` command used to remove the whole chain: the parachain and the relaychain.
3534
#[derive(Debug, StructOpt)]
@@ -66,10 +65,12 @@ impl PurgeChainCmd {
6665
let db_paths = databases
6766
.iter()
6867
.map(|(chain_label, database)| {
69-
database.path().ok_or_else(|| sc_cli::Error::Input(format!(
70-
"Cannot purge custom database implementation of: {}",
71-
chain_label,
72-
)))
68+
database.path().ok_or_else(|| {
69+
sc_cli::Error::Input(format!(
70+
"Cannot purge custom database implementation of: {}",
71+
chain_label,
72+
))
73+
})
7374
})
7475
.collect::<sc_cli::Result<Vec<_>>>()?;
7576

@@ -152,11 +153,11 @@ impl RunCmd {
152153
pub fn normalize(&self) -> NormalizedRunCmd {
153154
let mut new_base = self.base.clone();
154155

155-
new_base.validator = self.base.validator || self.collator;
156+
new_base.validator = self.base.validator || self.collator;
156157

157-
NormalizedRunCmd {
158-
base: new_base,
159-
parachain_id: self.parachain_id,
158+
NormalizedRunCmd {
159+
base: new_base,
160+
parachain_id: self.parachain_id,
160161
}
161162
}
162163
}
@@ -205,7 +206,10 @@ impl sc_cli::CliConfiguration for NormalizedRunCmd {
205206
self.base.force_authoring()
206207
}
207208

208-
fn prometheus_config(&self, default_listen_port: u16) -> sc_cli::Result<Option<PrometheusConfig>> {
209+
fn prometheus_config(
210+
&self,
211+
default_listen_port: u16,
212+
) -> sc_cli::Result<Option<PrometheusConfig>> {
209213
self.base.prometheus_config(default_listen_port)
210214
}
211215

pallets/aura-ext/Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ sp-application-crypto = { git = "https://github.com/paritytech/substrate", defau
1818

1919
# Other Dependencies
2020
codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false, features = ["derive"]}
21+
scale-info = { version = "1.0.0", default-features = false, features = ["derive"] }
2122
serde = { version = "1.0.101", optional = true, features = ["derive"] }
2223

2324
[dev-dependencies]
@@ -27,6 +28,7 @@ cumulus-pallet-parachain-system = { path = "../parachain-system" }
2728
default = [ "std" ]
2829
std = [
2930
"codec/std",
31+
"scale-info/std",
3032
"serde",
3133
"frame-support/std",
3234
"sp-runtime/std",

pallets/collator-selection/Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ targets = ['x86_64-unknown-linux-gnu']
1515
[dependencies]
1616
log = { version = "0.4.0", default-features = false }
1717
codec = { default-features = false, features = ['derive'], package = 'parity-scale-codec', version = '2.0.0' }
18+
scale-info = { version = "1.0.0", default-features = false, features = ["derive"] }
1819
serde = { version = "1.0.119", default-features = false }
1920
sp-std = { default-features = false, git = 'https://github.com/paritytech/substrate', branch = "master" }
2021
sp-runtime = { default-features = false, git = 'https://github.com/paritytech/substrate', branch = "master" }
@@ -46,6 +47,7 @@ runtime-benchmarks = [
4647
std = [
4748
'codec/std',
4849
'log/std',
50+
'scale-info/std',
4951
'sp-runtime/std',
5052
'sp-staking/std',
5153
'sp-std/std',

pallets/collator-selection/src/lib.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ pub mod pallet {
162162
}
163163

164164
/// Basic information about a collation candidate.
165-
#[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug)]
165+
#[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug, scale_info::TypeInfo)]
166166
pub struct CandidateInfo<AccountId, Balance> {
167167
/// Account identifier.
168168
pub who: AccountId,
@@ -247,7 +247,6 @@ pub mod pallet {
247247
}
248248

249249
#[pallet::event]
250-
#[pallet::metadata(T::AccountId = "AccountId", BalanceOf<T> = "Balance")]
251250
#[pallet::generate_deposit(pub(super) fn deposit_event)]
252251
pub enum Event<T: Config> {
253252
NewInvulnerables(Vec<T::AccountId>),

pallets/dmp-queue/Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ edition = "2018"
77
[dependencies]
88
# Other dependencies
99
codec = { package = "parity-scale-codec", version = "2.0.0", features = [ "derive" ], default-features = false }
10+
scale-info = { version = "1.0.0", default-features = false, features = ["derive"] }
1011
log = { version = "0.4.14", default-features = false }
1112

1213
# Substrate Dependencies
@@ -32,6 +33,7 @@ default = [ "std" ]
3233
std = [
3334
"codec/std",
3435
"log/std",
36+
"scale-info/std",
3537
"sp-std/std",
3638
"sp-io/std",
3739
"sp-runtime/std",

pallets/dmp-queue/src/lib.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
2222
#![cfg_attr(not(feature = "std"), no_std)]
2323

24+
use scale_info::TypeInfo;
2425
use sp_std::{prelude::*, convert::TryFrom};
2526
use cumulus_primitives_core::relay_chain::BlockNumber as RelayBlockNumber;
2627
use cumulus_primitives_core::DmpMessageHandler;
@@ -30,7 +31,7 @@ use xcm::{VersionedXcm, latest::prelude::*};
3031
use frame_support::{traits::EnsureOrigin, dispatch::Weight, weights::constants::WEIGHT_PER_MILLIS};
3132
pub use pallet::*;
3233

33-
#[derive(Copy, Clone, Eq, PartialEq, Encode, Decode, RuntimeDebug)]
34+
#[derive(Copy, Clone, Eq, PartialEq, Encode, Decode, RuntimeDebug, TypeInfo)]
3435
pub struct ConfigData {
3536
/// The maximum amount of weight any individual message may consume. Messages above this weight
3637
/// go into the overweight queue and may only be serviced explicitly by the
@@ -47,7 +48,7 @@ impl Default for ConfigData {
4748
}
4849

4950
/// Information concerning our message pages.
50-
#[derive(Copy, Clone, Eq, PartialEq, Default, Encode, Decode, RuntimeDebug)]
51+
#[derive(Copy, Clone, Eq, PartialEq, Default, Encode, Decode, RuntimeDebug, TypeInfo)]
5152
pub struct PageIndexData {
5253
/// The lowest used page index.
5354
begin_used: PageCounter,
@@ -166,7 +167,6 @@ pub mod pallet {
166167

167168
#[pallet::event]
168169
#[pallet::generate_deposit(pub(super) fn deposit_event)]
169-
#[pallet::metadata(T::BlockNumber = "BlockNumber")]
170170
pub enum Event<T: Config> {
171171
/// Downward message is invalid XCM.
172172
/// \[ id \]
@@ -755,7 +755,10 @@ mod tests {
755755
assert_noop!(DmpQueue::service_overweight(Origin::root(), 0, 9999), Error::<Test>::OverLimit);
756756
assert_eq!(take_trace(), vec![ msg_limit_reached(10000) ]);
757757

758-
let base_weight = super::Call::<Test>::service_overweight(0, 0).get_dispatch_info().weight;
758+
let base_weight = super::Call::<Test>::service_overweight {
759+
index: 0,
760+
weight_limit: 0,
761+
}.get_dispatch_info().weight;
759762
use frame_support::weights::GetDispatchInfo;
760763
let info = DmpQueue::service_overweight(Origin::root(), 0, 20000).unwrap();
761764
let actual_weight = info.actual_weight.unwrap();

pallets/parachain-system/Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ sp-externalities = { git = "https://github.com/paritytech/substrate", default-fe
3131

3232
# Other Dependencies
3333
codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false, features = ["derive"]}
34+
scale-info = { version = "1.0.0", default-features = false, features = ["derive"] }
3435
serde = { version = "1.0.101", optional = true, features = ["derive"] }
3536
log = { version = "0.4.14", default-features = false }
3637
environmental = { version = "1.1.2", default-features = false }
@@ -55,6 +56,7 @@ default = [ "std" ]
5556
std = [
5657
"serde",
5758
"codec/std",
59+
"scale-info/std",
5860
"frame-support/std",
5961
"pallet-balances/std",
6062
"sp-core/std",

pallets/parachain-system/src/lib.rs

+14-12
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
use cumulus_primitives_core::{
3131
relay_chain, AbridgedHostConfiguration, ChannelStatus, CollationInfo, DmpMessageHandler,
3232
GetChannelInfo, InboundDownwardMessage, InboundHrmpMessage, MessageSendError, OnValidationData,
33-
OutboundHrmpMessage, ParaId, UpwardMessage, UpwardMessageSender, XcmpMessageHandler,
34-
XcmpMessageSource, PersistedValidationData,
33+
OutboundHrmpMessage, ParaId, PersistedValidationData, UpwardMessage, UpwardMessageSender,
34+
XcmpMessageHandler, XcmpMessageSource,
3535
};
3636
use cumulus_primitives_parachain_inherent::ParachainInherentData;
3737
use frame_support::{
@@ -46,7 +46,7 @@ use frame_system::{ensure_none, ensure_root};
4646
use polkadot_parachain::primitives::RelayChainBlockNumber;
4747
use relay_state_snapshot::MessagingStateSnapshot;
4848
use sp_runtime::{
49-
traits::{BlakeTwo256, Block as BlockT, Hash, BlockNumberProvider},
49+
traits::{BlakeTwo256, Block as BlockT, BlockNumberProvider, Hash},
5050
transaction_validity::{
5151
InvalidTransaction, TransactionLongevity, TransactionSource, TransactionValidity,
5252
ValidTransaction,
@@ -393,7 +393,10 @@ pub mod pallet {
393393
}
394394

395395
#[pallet::weight(1_000_000)]
396-
pub fn enact_authorized_upgrade(_: OriginFor<T>, code: Vec<u8>) -> DispatchResultWithPostInfo {
396+
pub fn enact_authorized_upgrade(
397+
_: OriginFor<T>,
398+
code: Vec<u8>,
399+
) -> DispatchResultWithPostInfo {
397400
Self::validate_authorized_upgrade(&code[..])?;
398401
Self::set_code_impl(code)?;
399402
AuthorizedUpgrade::<T>::kill();
@@ -403,7 +406,6 @@ pub mod pallet {
403406

404407
#[pallet::event]
405408
#[pallet::generate_deposit(pub(super) fn deposit_event)]
406-
#[pallet::metadata(T::Hash = "Hash")]
407409
pub enum Event<T: Config> {
408410
/// The validation function has been scheduled to apply as of the contained relay chain
409411
/// block number.
@@ -576,11 +578,11 @@ pub mod pallet {
576578
.flatten()
577579
.expect("validation function params are always injected into inherent data; qed");
578580

579-
Some(Call::set_validation_data(data))
581+
Some(Call::set_validation_data { data })
580582
}
581583

582584
fn is_inherent(call: &Self::Call) -> bool {
583-
matches!(call, Call::set_validation_data(_))
585+
matches!(call, Call::set_validation_data { .. })
584586
}
585587
}
586588

@@ -599,9 +601,9 @@ pub mod pallet {
599601
#[pallet::validate_unsigned]
600602
impl<T: Config> sp_runtime::traits::ValidateUnsigned for Pallet<T> {
601603
type Call = Call<T>;
602-
604+
603605
fn validate_unsigned(_source: TransactionSource, call: &Self::Call) -> TransactionValidity {
604-
if let Call::enact_authorized_upgrade(ref code) = call {
606+
if let Call::enact_authorized_upgrade { ref code } = call {
605607
if let Ok(hash) = Self::validate_authorized_upgrade(code) {
606608
return Ok(ValidTransaction {
607609
priority: 100,
@@ -612,7 +614,7 @@ pub mod pallet {
612614
});
613615
}
614616
}
615-
if let Call::set_validation_data(..) = call {
617+
if let Call::set_validation_data { .. } = call {
616618
return Ok(Default::default());
617619
}
618620
Err(InvalidTransaction::Call.into())
@@ -942,7 +944,7 @@ impl<T: Config> Pallet<T> {
942944

943945
pub struct ParachainSetCode<T>(sp_std::marker::PhantomData<T>);
944946

945-
impl<T: Config> frame_system::SetCode for ParachainSetCode<T> {
947+
impl<T: Config> frame_system::SetCode<T> for ParachainSetCode<T> {
946948
fn set_code(code: Vec<u8>) -> DispatchResult {
947949
Pallet::<T>::set_code_impl(code)
948950
}
@@ -956,7 +958,7 @@ impl<T: Config> frame_system::SetCode for ParachainSetCode<T> {
956958
/// A head for an empty chain is agreed to be a zero hash.
957959
///
958960
/// [hash chain]: https://en.wikipedia.org/wiki/Hash_chain
959-
#[derive(Default, Clone, codec::Encode, codec::Decode)]
961+
#[derive(Default, Clone, codec::Encode, codec::Decode, scale_info::TypeInfo)]
960962
struct MessageQueueChain(relay_chain::Hash);
961963

962964
impl MessageQueueChain {

pallets/parachain-system/src/relay_state_snapshot.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use codec::{Decode, Encode};
1818
use cumulus_primitives_core::{
1919
relay_chain, AbridgedHostConfiguration, AbridgedHrmpChannel, ParaId,
2020
};
21+
use scale_info::TypeInfo;
2122
use sp_trie::{MemoryDB, HashDBT, EMPTY_PREFIX};
2223
use sp_runtime::traits::HashFor;
2324
use sp_state_machine::{Backend, TrieBackend};
@@ -29,7 +30,7 @@ use sp_trie::StorageProof;
2930
/// This data is essential for making sure that the parachain is aware of current resource use on
3031
/// the relay chain and that the candidates produced for this parachain do not exceed any of these
3132
/// limits.
32-
#[derive(Clone, Encode, Decode)]
33+
#[derive(Clone, Encode, Decode, TypeInfo)]
3334
pub struct MessagingStateSnapshot {
3435
/// The current message queue chain head for downward message queue.
3536
///

pallets/parachain-system/src/validate_block/implementation.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ where
128128
.iter()
129129
.filter_map(|e| e.call().is_sub_type())
130130
.find_map(|c| match c {
131-
crate::Call::set_validation_data(validation_data) => Some(validation_data.clone()),
131+
crate::Call::set_validation_data { data: validation_data } => Some(validation_data.clone()),
132132
_ => None,
133133
})
134134
.expect("Could not find `set_validation_data` inherent");

pallets/xcm/Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ version = "0.1.0"
66

77
[dependencies]
88
codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false, features = ["derive"] }
9+
scale-info = { version = "1.0.0", default-features = false, features = ["derive"] }
910
serde = { version = "1.0.101", optional = true, features = ["derive"] }
1011

1112
sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
@@ -22,6 +23,7 @@ cumulus-primitives-core = { path = "../../primitives/core", default-features = f
2223
default = ["std"]
2324
std = [
2425
"codec/std",
26+
"scale-info/std",
2527
"serde",
2628
"cumulus-primitives-core/std",
2729
"sp-std/std",

pallets/xcm/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ use sp_std::{prelude::*, convert::TryFrom};
2424
use cumulus_primitives_core::{ParaId, DmpMessageHandler};
2525
use cumulus_primitives_core::relay_chain::BlockNumber as RelayBlockNumber;
2626
use codec::{Encode, Decode};
27+
use scale_info::TypeInfo;
2728
use sp_runtime::traits::BadOrigin;
2829
use xcm::{VersionedXcm, latest::{Xcm, Outcome, Parent, ExecuteXcm}};
2930
use frame_support::dispatch::Weight;
@@ -60,7 +61,6 @@ pub mod pallet {
6061

6162
#[pallet::event]
6263
#[pallet::generate_deposit(pub(super) fn deposit_event)]
63-
#[pallet::metadata(T::BlockNumber = "BlockNumber")]
6464
pub enum Event<T: Config> {
6565
/// Downward message is invalid XCM.
6666
/// \[ id \]
@@ -74,7 +74,7 @@ pub mod pallet {
7474
}
7575

7676
/// Origin for the parachains module.
77-
#[derive(PartialEq, Eq, Clone, Encode, Decode)]
77+
#[derive(PartialEq, Eq, Clone, Encode, Decode, TypeInfo)]
7878
#[cfg_attr(feature = "std", derive(Debug))]
7979
#[pallet::origin]
8080
pub enum Origin {

pallets/xcmp-queue/Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ edition = "2018"
77
[dependencies]
88
# Other dependencies
99
codec = { package = "parity-scale-codec", version = "2.0.0", features = [ "derive" ], default-features = false }
10+
scale-info = { version = "1.0.0", default-features = false, features = ["derive"] }
1011
log = { version = "0.4.14", default-features = false }
1112
rand_chacha = { version = "0.3.0", default-features = false }
1213

@@ -35,6 +36,7 @@ default = [ "std" ]
3536
std = [
3637
"codec/std",
3738
"log/std",
39+
"scale-info/std",
3840
"sp-std/std",
3941
"sp-runtime/std",
4042
"frame-support/std",

0 commit comments

Comments
 (0)