diff --git a/client/cli/src/lib.rs b/client/cli/src/lib.rs index c5d0fd4043..d9545f191a 100644 --- a/client/cli/src/lib.rs +++ b/client/cli/src/lib.rs @@ -30,7 +30,7 @@ use std::{ }; use structopt::StructOpt; -/// The `purge-chain` command used to remove the whole chain: the parachain and the relaychain. +/// The `purge-chain` command used to remove the whole chain: the parachain and the relay chain. #[derive(Debug, StructOpt)] pub struct PurgeChainCmd { /// The base struct of the purge-chain command. diff --git a/client/network/tests/sync.rs b/client/network/tests/sync.rs index 56f5bc3a72..f61d43a968 100644 --- a/client/network/tests/sync.rs +++ b/client/network/tests/sync.rs @@ -29,7 +29,7 @@ async fn sync_blocks_from_tip_without_being_connected_to_a_collator() { let tokio_handle = tokio::runtime::Handle::current(); // start alice - let alice = run_relay_chain_validator_node(tokio_handle.clone(), Alice, || {}, vec![]); + let alice = run_relay_chain_validator_node(tokio_handle.clone(), Alice, || {}, Vec::new()); // start bob let bob = diff --git a/client/pov-recovery/tests/pov_recovery.rs b/client/pov-recovery/tests/pov_recovery.rs index bbad4b2416..d8c8c97155 100644 --- a/client/pov-recovery/tests/pov_recovery.rs +++ b/client/pov-recovery/tests/pov_recovery.rs @@ -39,7 +39,7 @@ async fn pov_recovery() { tokio_handle.clone(), Alice, || {}, - vec![], + Vec::new(), ); // Start bob diff --git a/pallets/asset-tx-payment/src/tests.rs b/pallets/asset-tx-payment/src/tests.rs index 97330c5a49..86a84da817 100644 --- a/pallets/asset-tx-payment/src/tests.rs +++ b/pallets/asset-tx-payment/src/tests.rs @@ -255,7 +255,7 @@ impl ExtBuilder { (6, 60 * self.balance_factor), ] } else { - vec![] + Vec::new() }, } .assimilate_storage(&mut t) diff --git a/pallets/collator-selection/src/benchmarking.rs b/pallets/collator-selection/src/benchmarking.rs index dd6531403d..e9c50e3df6 100644 --- a/pallets/collator-selection/src/benchmarking.rs +++ b/pallets/collator-selection/src/benchmarking.rs @@ -88,7 +88,7 @@ fn register_validators(count: u32) { let validators = (0..count).map(|c| validator::(c)).collect::>(); for (who, keys) in validators { - >::set_keys(RawOrigin::Signed(who).into(), keys, vec![]).unwrap(); + >::set_keys(RawOrigin::Signed(who).into(), keys, Vec::new()).unwrap(); } } @@ -160,7 +160,7 @@ benchmarks! { >::set_keys( RawOrigin::Signed(caller.clone()).into(), keys::(c + 1), - vec![] + Vec::new() ).unwrap(); }: _(RawOrigin::Signed(caller.clone())) diff --git a/pallets/collator-selection/src/mock.rs b/pallets/collator-selection/src/mock.rs index 600d4bc12c..478936379f 100644 --- a/pallets/collator-selection/src/mock.rs +++ b/pallets/collator-selection/src/mock.rs @@ -145,7 +145,7 @@ impl From for MockSessionKeys { } parameter_types! { - pub static SessionHandlerCollators: Vec = vec![]; + pub static SessionHandlerCollators: Vec = Vec::new(); pub static SessionChangeBlock: u64 = 0; } diff --git a/pallets/collator-selection/src/tests.rs b/pallets/collator-selection/src/tests.rs index 7ccfc308ea..d8cba9f227 100644 --- a/pallets/collator-selection/src/tests.rs +++ b/pallets/collator-selection/src/tests.rs @@ -188,7 +188,7 @@ fn register_as_candidate_works() { // given assert_eq!(CollatorSelection::desired_candidates(), 2); assert_eq!(CollatorSelection::candidacy_bond(), 10); - assert_eq!(CollatorSelection::candidates(), vec![]); + assert_eq!(CollatorSelection::candidates(), Vec::new()); assert_eq!(CollatorSelection::invulnerables(), vec![1, 2]); // take two endowed, non-invulnerables accounts. diff --git a/pallets/dmp-queue/src/lib.rs b/pallets/dmp-queue/src/lib.rs index 1a6baf21b3..5f845a00c9 100644 --- a/pallets/dmp-queue/src/lib.rs +++ b/pallets/dmp-queue/src/lib.rs @@ -475,7 +475,7 @@ mod tests { Xcm(vec![Transact { origin_type: OriginKind::Native, require_weight_at_most: weight, - call: vec![].into(), + call: Vec::new().into(), }]) } @@ -506,7 +506,7 @@ mod tests { new_test_ext().execute_with(|| { let weight_used = handle_messages(&[], 1000); assert_eq!(weight_used, 0); - assert_eq!(take_trace(), vec![]); + assert_eq!(take_trace(), Vec::new()); assert!(queue_is_empty()); }); } diff --git a/pallets/parachain-system/src/lib.rs b/pallets/parachain-system/src/lib.rs index 9f2e044c72..04b827daa6 100644 --- a/pallets/parachain-system/src/lib.rs +++ b/pallets/parachain-system/src/lib.rs @@ -609,7 +609,7 @@ pub mod pallet { if let Ok(hash) = Self::validate_authorized_upgrade(code) { return Ok(ValidTransaction { priority: 100, - requires: vec![], + requires: Vec::new(), provides: vec![hash.as_ref().to_vec()], longevity: TransactionLongevity::max_value(), propagate: true, @@ -1008,7 +1008,7 @@ pub trait CheckInherents { ) -> frame_support::inherent::CheckInherentsResult; } -/// Implements [`BlockNumberProvider`] that returns relaychain block number fetched from +/// Implements [`BlockNumberProvider`] that returns relay chain block number fetched from /// validation data. /// NTOE: When validation data is not available (e.g. within on_initialize), 0 will be returned. pub struct RelaychainBlockNumberProvider(sp_std::marker::PhantomData); diff --git a/pallets/parachain-system/src/validate_block/tests.rs b/pallets/parachain-system/src/validate_block/tests.rs index 5414e717d3..c45b2625ff 100644 --- a/pallets/parachain-system/src/validate_block/tests.rs +++ b/pallets/parachain-system/src/validate_block/tests.rs @@ -92,7 +92,7 @@ fn validate_block_no_extra_extrinsics() { let (client, parent_head) = create_test_client(); let TestBlockData { block, validation_data } = - build_block_with_witness(&client, vec![], parent_head.clone(), Default::default()); + build_block_with_witness(&client, Vec::new(), parent_head.clone(), Default::default()); let header = block.header().clone(); let res_header = @@ -133,7 +133,7 @@ fn validate_block_invalid_parent_hash() { if env::var("RUN_TEST").is_ok() { let (client, parent_head) = create_test_client(); let TestBlockData { block, validation_data } = - build_block_with_witness(&client, vec![], parent_head.clone(), Default::default()); + build_block_with_witness(&client, Vec::new(), parent_head.clone(), Default::default()); let (mut header, extrinsics, witness) = block.deconstruct(); header.set_parent_hash(Hash::from_low_u64_be(1)); @@ -159,7 +159,7 @@ fn validate_block_fails_on_invalid_validation_data() { if env::var("RUN_TEST").is_ok() { let (client, parent_head) = create_test_client(); let TestBlockData { block, .. } = - build_block_with_witness(&client, vec![], parent_head.clone(), Default::default()); + build_block_with_witness(&client, Vec::new(), parent_head.clone(), Default::default()); call_validate_block(parent_head, block, Hash::random()).unwrap_err(); } else { @@ -184,7 +184,7 @@ fn check_inherent_fails_on_validate_block_as_expected() { let TestBlockData { block, validation_data } = build_block_with_witness( &client, - vec![], + Vec::new(), parent_head.clone(), RelayStateSproofBuilder { current_slot: 1337.into(), ..Default::default() }, ); diff --git a/parachain-template/README.md b/parachain-template/README.md index 1580521ccd..6dcc70c538 100644 --- a/parachain-template/README.md +++ b/parachain-template/README.md @@ -2,13 +2,21 @@ A new [Cumulus](https://github.com/paritytech/cumulus/)-based Substrate node, ready for hacking ☁️.. -This project is a fork of the [Substrate Node Template](https://github.com/substrate-developer-hub/substrate-node-template) +This project is originally a fork of the +[Substrate Node Template](https://github.com/substrate-developer-hub/substrate-node-template) modified to include dependencies required for registering this node as a **parathread** or -**parachain** to the Rococo **relay chain**. -Rococo is [Polkadot's parachain testnet](https://polkadot.network/blog/introducing-rococo-polkadots-parachain-testnet/) 👑. +**parachain** to a **relay chain**. + +The stand-alone version of this template is hosted on the +[Substrate Devhub Parachain Template](https://github.com/substrate-developer-hub/substrate-parachain-template/) +for each release of Polkadot. It is generated directly to the upstream +[Parachain Template in Cumulus](https://github.com/paritytech/cumulus/tree/master/parachain-template) +at each release branch using the +[Substrate Template Generator](https://github.com/paritytech/substrate-template-generator/). 👉 Learn more about parachains [here](https://wiki.polkadot.network/docs/learn-parachains), and parathreads [here](https://wiki.polkadot.network/docs/learn-parathreads). -To learn about how to actually use the template to hack together your own parachain check out the -`README` from the [`substrate-parachain-template` repository](https://github.com/substrate-developer-hub/substrate-parachain-template/). + +🧙 Learn about how to use this template and run your own parachain testnet for it in the +[Devhub Cumulus Tutorial](https://docs.substrate.io/tutorials/v3/cumulus/start-relay/). \ No newline at end of file diff --git a/parachain-template/node/src/chain_spec.rs b/parachain-template/node/src/chain_spec.rs index d779a0e403..0b6ba77b12 100644 --- a/parachain-template/node/src/chain_spec.rs +++ b/parachain-template/node/src/chain_spec.rs @@ -11,7 +11,7 @@ pub type ChainSpec = sc_service::GenericChainSpec; /// Helper function to generate a crypto pair from seed -pub fn get_pair_from_seed(seed: &str) -> ::Public { +pub fn get_public_from_seed(seed: &str) -> ::Public { TPublic::Pair::from_string(&format!("//{}", seed), None) .expect("static values are valid; qed") .public() @@ -40,7 +40,7 @@ type AccountPublic = ::Signer; /// /// This function's return type must always match the session keys of the chain in tuple format. pub fn get_collator_keys_from_seed(seed: &str) -> AuraId { - get_pair_from_seed::(seed) + get_public_from_seed::(seed) } /// Helper function to generate an account ID from seed @@ -48,7 +48,7 @@ pub fn get_account_id_from_seed(seed: &str) -> AccountId where AccountPublic: From<::Public>, { - AccountPublic::from(get_pair_from_seed::(seed)).into_account() + AccountPublic::from(get_public_from_seed::(seed)).into_account() } /// Generate the session keys from individual elements. @@ -61,7 +61,7 @@ pub fn template_session_keys(keys: AuraId) -> parachain_template_runtime::Sessio pub fn development_config() -> ChainSpec { // Give your base currency a unit name and decimal places let mut properties = sc_chain_spec::Properties::new(); - properties.insert("tokenSymbol".into(), "ROC".into()); + properties.insert("tokenSymbol".into(), "UNIT".into()); properties.insert("tokenDecimals".into(), 12.into()); properties.insert("ss58Format".into(), 42.into()); @@ -101,7 +101,7 @@ pub fn development_config() -> ChainSpec { 1000.into(), ) }, - vec![], + Vec::new(), None, None, None, @@ -115,7 +115,7 @@ pub fn development_config() -> ChainSpec { pub fn local_testnet_config() -> ChainSpec { // Give your base currency a unit name and decimal places let mut properties = sc_chain_spec::Properties::new(); - properties.insert("tokenSymbol".into(), "ROC".into()); + properties.insert("tokenSymbol".into(), "UNIT".into()); properties.insert("tokenDecimals".into(), 12.into()); properties.insert("ss58Format".into(), 42.into()); @@ -156,7 +156,7 @@ pub fn local_testnet_config() -> ChainSpec { ) }, // Bootnodes - vec![], + Vec::new(), // Telemetry None, // Protocol ID @@ -194,8 +194,7 @@ fn testnet_genesis( }, session: parachain_template_runtime::SessionConfig { keys: invulnerables - .iter() - .cloned() + .into_iter() .map(|(acc, aura)| { ( acc.clone(), // account id diff --git a/parachain-template/node/src/cli.rs b/parachain-template/node/src/cli.rs index 1cbee43811..1ed730984d 100644 --- a/parachain-template/node/src/cli.rs +++ b/parachain-template/node/src/cli.rs @@ -51,7 +51,7 @@ pub struct ExportGenesisStateCommand { pub raw: bool, /// The name of the chain for that the genesis state should be exported. - #[structopt(long, conflicts_with = "parachain-id")] + #[structopt(long)] pub chain: Option, } @@ -84,9 +84,9 @@ pub struct Cli { #[structopt(flatten)] pub run: cumulus_client_cli::RunCmd, - /// Relaychain arguments + /// Relay chain arguments #[structopt(raw = true)] - pub relaychain_args: Vec, + pub relay_chain_args: Vec, } #[derive(Debug)] diff --git a/parachain-template/node/src/command.rs b/parachain-template/node/src/command.rs index ba82034537..59fb46e3a2 100644 --- a/parachain-template/node/src/command.rs +++ b/parachain-template/node/src/command.rs @@ -37,13 +37,11 @@ impl SubstrateCli for Cli { } fn description() -> String { - format!( - "Parachain Collator Template\n\nThe command-line arguments provided first will be \ + "Parachain Collator Template\n\nThe command-line arguments provided first will be \ passed to the parachain node, while the arguments provided after -- will be passed \ - to the relaychain node.\n\n\ - {} [parachain-args] -- [relaychain-args]", - Self::executable_name() - ) + to the relay chain node.\n\n\ + parachain-collator -- " + .into() } fn author() -> String { @@ -79,8 +77,8 @@ impl SubstrateCli for RelayChainCli { fn description() -> String { "Parachain Collator Template\n\nThe command-line arguments provided first will be \ passed to the parachain node, while the arguments provided after -- will be passed \ - to the relaychain node.\n\n\ - parachain-collator [parachain-args] -- [relaychain-args]" + to the relay chain node.\n\n\ + parachain-collator -- " .into() } @@ -168,7 +166,7 @@ pub fn run() -> Result<()> { runner.sync_run(|config| { let polkadot_cli = RelayChainCli::new( &config, - [RelayChainCli::executable_name()].iter().chain(cli.relaychain_args.iter()), + [RelayChainCli::executable_name()].iter().chain(cli.relay_chain_args.iter()), ); let polkadot_config = SubstrateCli::create_configuration( @@ -245,11 +243,11 @@ pub fn run() -> Result<()> { runner.run_node_until_exit(|config| async move { let para_id = chain_spec::Extensions::try_get(&*config.chain_spec) .map(|e| e.para_id) - .ok_or_else(|| "Could not find parachain extension for chain-spec.")?; + .ok_or_else(|| "Could not find parachain ID in chain-spec.")?; let polkadot_cli = RelayChainCli::new( &config, - [RelayChainCli::executable_name()].iter().chain(cli.relaychain_args.iter()), + [RelayChainCli::executable_name()].iter().chain(cli.relay_chain_args.iter()), ); let id = ParaId::from(para_id); diff --git a/parachain-template/node/src/main.rs b/parachain-template/node/src/main.rs index 99dc7849cf..ba9f28b354 100644 --- a/parachain-template/node/src/main.rs +++ b/parachain-template/node/src/main.rs @@ -1,4 +1,4 @@ -//! Substrate Node CLI library. +//! Substrate Parachain Node Template CLI #![warn(missing_docs)] diff --git a/parachain-template/runtime/src/lib.rs b/parachain-template/runtime/src/lib.rs index 7f1f780798..d7cb4d70dd 100644 --- a/parachain-template/runtime/src/lib.rs +++ b/parachain-template/runtime/src/lib.rs @@ -23,7 +23,7 @@ use sp_version::RuntimeVersion; use frame_support::{ construct_runtime, match_type, parameter_types, - traits::Everything, + traits::{Everything, Nothing}, weights::{ constants::{BlockExecutionWeight, ExtrinsicBaseWeight, WEIGHT_PER_SECOND}, DispatchClass, IdentityFee, Weight, WeightToFeeCoefficient, WeightToFeeCoefficients, @@ -33,7 +33,7 @@ use frame_support::{ }; use frame_system::{ limits::{BlockLength, BlockWeights}, - EnsureOneOf, EnsureRoot, + EnsureRoot, }; pub use sp_consensus_aura::sr25519::AuthorityId as AuraId; pub use sp_runtime::{MultiAddress, Perbill, Permill}; @@ -42,18 +42,18 @@ pub use sp_runtime::{MultiAddress, Perbill, Permill}; pub use sp_runtime::BuildStorage; // Polkadot Imports -use pallet_xcm::{EnsureXcm, IsMajorityOfBody, XcmPassthrough}; +use pallet_xcm::XcmPassthrough; use polkadot_parachain::primitives::Sibling; use polkadot_runtime_common::{BlockHashCount, RocksDbWeight, SlowAdjustingFeeUpdate}; // XCM Imports use xcm::latest::prelude::*; use xcm_builder::{ - AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom, - AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter, EnsureXcmOrigin, - FixedWeightBounds, IsConcrete, LocationInverter, NativeAsset, ParentAsSuperuser, - ParentIsDefault, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, - SignedAccountId32AsNative, SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, + AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter, + EnsureXcmOrigin, FixedWeightBounds, IsConcrete, LocationInverter, NativeAsset, ParentIsDefault, + RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, + SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, + UsingComponents, }; use xcm_executor::{Config, XcmExecutor}; @@ -118,18 +118,8 @@ pub type Executive = frame_executive::Executive< frame_system::ChainContext, Runtime, AllPallets, - OnRuntimeUpgrade, >; -pub struct OnRuntimeUpgrade; -impl frame_support::traits::OnRuntimeUpgrade for OnRuntimeUpgrade { - fn on_runtime_upgrade() -> u64 { - frame_support::migrations::migrate_from_pallet_version_to_storage_version::< - AllPalletsWithSystem, - >(&RocksDbWeight::get()) - } -} - /// Handles converting a weight scalar to a fee value, based on the scale and granularity of the /// node's balance type. /// @@ -213,12 +203,9 @@ pub const UNIT: Balance = 1_000_000_000_000; pub const MILLIUNIT: Balance = 1_000_000_000; pub const MICROUNIT: Balance = 1_000_000; -/// The existential deposit. Set to 1/10 of the Rococo Relay Chain. +/// The existential deposit. Set to 1/10 of the Connected Relay Chain. pub const EXISTENTIAL_DEPOSIT: Balance = MILLIUNIT; -// 1 in 4 blocks (on average, not counting collisions) will be primary babe blocks. -pub const PRIMARY_PROBABILITY: (u64, u64) = (1, 4); - /// We assume that ~5% of the block weight is consumed by `on_initialize` handlers. This is /// used to limit the maximal weight of a single extrinsic. const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(5); @@ -395,7 +382,7 @@ impl parachain_info::Config for Runtime {} impl cumulus_pallet_aura_ext::Config for Runtime {} parameter_types! { - pub const RocLocation: MultiLocation = MultiLocation::parent(); + pub const RelayLocation: MultiLocation = MultiLocation::parent(); pub const RelayNetwork: NetworkId = NetworkId::Any; pub RelayChainOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into(); pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into(); @@ -418,7 +405,7 @@ pub type LocalAssetTransactor = CurrencyAdapter< // Use this currency: Balances, // Use this currency when it is a fungible asset matching the given location or name: - IsConcrete, + IsConcrete, // Do a simple punn to convert an AccountId32 MultiLocation into a native chain account ID: LocationToAccountId, // Our chain's account ID type (we can't get away without mentioning it explicitly): @@ -436,14 +423,11 @@ pub type XcmOriginToTransactDispatchOrigin = ( // foreign chains who want to have a local sovereign account on this chain which they control. SovereignSignedViaLocation, // Native converter for Relay-chain (Parent) location; will converts to a `Relay` origin when - // recognised. + // recognized. RelayChainAsNative, // Native converter for sibling Parachains; will convert to a `SiblingPara` origin when - // recognised. + // recognized. SiblingParachainAsNative, - // Superuser converter for the Relay-chain (Parent) location. This will allow it to issue a - // transaction from the Root origin. - ParentAsSuperuser, // Native signed account converter; this just converts an `AccountId32` origin into a normal // `Origin::Signed` origin of the same 32-byte value. SignedAccountId32AsNative, @@ -463,22 +447,12 @@ match_type! { MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Executive, .. }) } }; } -match_type! { - pub type ParentOrSiblings: impl Contains = { - MultiLocation { parents: 1, interior: Here } | - MultiLocation { parents: 1, interior: X1(_) } - }; -} pub type Barrier = ( TakeWeightCredit, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, // ^^^ Parent and its exec plurality get free execution - // Expected responses are OK. - AllowKnownQueryResponses, - // Subscriptions for version tracking are OK. - AllowSubscriptionsFrom, ); pub struct XcmConfig; @@ -489,11 +463,11 @@ impl Config for XcmConfig { type AssetTransactor = LocalAssetTransactor; type OriginConverter = XcmOriginToTransactDispatchOrigin; type IsReserve = NativeAsset; - type IsTeleporter = NativeAsset; // Should be enough to allow teleportation of ROC + type IsTeleporter = (); // Teleporting is disabled. type LocationInverter = LocationInverter; type Barrier = Barrier; type Weigher = FixedWeightBounds; - type Trader = UsingComponents, RocLocation, AccountId, Balances, ()>; + type Trader = UsingComponents, RelayLocation, AccountId, Balances, ()>; type ResponseHandler = PolkadotXcm; type AssetTrap = PolkadotXcm; type AssetClaims = PolkadotXcm; @@ -505,13 +479,13 @@ parameter_types! { } /// No local origins on this chain are allowed to dispatch XCM sends/executions. -pub type LocalOriginToLocation = (); +pub type LocalOriginToLocation = SignedToAccountId32; /// The means for routing XCM messages which are not for local execution into the right message /// queues. pub type XcmRouter = ( // Two routers - use UMP to communicate with the relay chain: - cumulus_primitives_utility::ParentAsUmp, + cumulus_primitives_utility::ParentAsUmp, // ..and XCMP to communicate with the sibling chains. XcmpQueue, ); @@ -521,16 +495,19 @@ impl pallet_xcm::Config for Runtime { type SendXcmOrigin = EnsureXcmOrigin; type XcmRouter = XcmRouter; type ExecuteXcmOrigin = EnsureXcmOrigin; - type XcmExecuteFilter = Everything; + type XcmExecuteFilter = Nothing; + // ^ Disable dispatchable execute on the XCM pallet. + // Needs to be `Everything` for local testing. type XcmExecutor = XcmExecutor; type XcmTeleportFilter = Everything; - type XcmReserveTransferFilter = Everything; + type XcmReserveTransferFilter = Nothing; type Weigher = FixedWeightBounds; type LocationInverter = LocationInverter; type Origin = Origin; type Call = Call; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; + // ^ Override for AdvertisedXcmVersion default type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; } @@ -543,7 +520,7 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime { type Event = Event; type XcmExecutor = XcmExecutor; type ChannelInfo = ParachainSystem; - type VersionWrapper = PolkadotXcm; + type VersionWrapper = (); } impl cumulus_pallet_dmp_queue::Config for Runtime { @@ -587,12 +564,8 @@ parameter_types! { pub const ExecutiveBody: BodyId = BodyId::Executive; } -// We allow root and the Relay Chain council to execute privileged collator selection operations. -pub type CollatorSelectionUpdateOrigin = EnsureOneOf< - AccountId, - EnsureRoot, - EnsureXcm>, ->; +// We allow root only to execute privileged collator selection operations. +pub type CollatorSelectionUpdateOrigin = EnsureRoot; impl pallet_collator_selection::Config for Runtime { type Event = Event; @@ -627,8 +600,8 @@ construct_runtime!( ParachainSystem: cumulus_pallet_parachain_system::{ Pallet, Call, Config, Storage, Inherent, Event, ValidateUnsigned, } = 1, - Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 3, - ParachainInfo: parachain_info::{Pallet, Storage, Config} = 4, + Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 2, + ParachainInfo: parachain_info::{Pallet, Storage, Config} = 3, // Monetary stuff. Balances: pallet_balances::{Pallet, Call, Storage, Config, Event} = 10, @@ -775,7 +748,6 @@ impl_runtime_apis! { list_benchmark!(list, extra, frame_system, SystemBench::); list_benchmark!(list, extra, pallet_balances, Balances); - list_benchmark!(list, extra, pallet_session, SessionBench::); list_benchmark!(list, extra, pallet_timestamp, Timestamp); list_benchmark!(list, extra, pallet_collator_selection, CollatorSelection); @@ -816,6 +788,7 @@ impl_runtime_apis! { add_benchmark!(params, batches, pallet_session, SessionBench::); add_benchmark!(params, batches, pallet_timestamp, Timestamp); add_benchmark!(params, batches, pallet_collator_selection, CollatorSelection); + add_benchmark!(params, batches, pallet_session, Session); if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) } Ok(batches) diff --git a/polkadot-parachains/src/chain_spec.rs b/polkadot-parachains/src/chain_spec.rs index facd0acfcb..da2acf4d03 100644 --- a/polkadot-parachains/src/chain_spec.rs +++ b/polkadot-parachains/src/chain_spec.rs @@ -90,7 +90,7 @@ pub fn get_chain_spec() -> ChainSpec { 1000.into(), ) }, - vec![], + Vec::new(), None, None, None, @@ -104,7 +104,7 @@ pub fn get_shell_chain_spec() -> ShellChainSpec { "shell_local_testnet", ChainType::Local, move || shell_testnet_genesis(1000.into()), - vec![], + Vec::new(), None, None, None, @@ -194,7 +194,7 @@ const STATEMINE_ED: StatemintBalance = statemine_runtime::constants::currency::E const WESTMINT_ED: StatemintBalance = westmint_runtime::constants::currency::EXISTENTIAL_DEPOSIT; /// Helper function to generate a crypto pair from seed -pub fn get_pair_from_seed(seed: &str) -> ::Public { +pub fn get_public_from_seed(seed: &str) -> ::Public { TPublic::Pair::from_string(&format!("//{}", seed), None) .expect("static values are valid; qed") .public() @@ -204,7 +204,7 @@ pub fn get_pair_from_seed(seed: &str) -> AuraId { - get_pair_from_seed::(seed) + get_public_from_seed::(seed) } /// Generate the session keys from individual elements. @@ -255,7 +255,7 @@ pub fn statemint_development_config() -> StatemintChainSpec { 1000.into(), ) }, - vec![], + Vec::new(), None, None, Some(properties), @@ -304,7 +304,7 @@ pub fn statemint_local_config() -> StatemintChainSpec { 1000.into(), ) }, - vec![], + Vec::new(), None, None, Some(properties), @@ -335,12 +335,11 @@ fn statemint_genesis( }, session: statemint_runtime::SessionConfig { keys: invulnerables - .iter() - .cloned() + .into_iter() .map(|(acc, aura)| { ( acc.clone(), // account id - acc.clone(), // validator id + acc, // validator id statemint_session_keys(aura), // session keys ) }) @@ -381,7 +380,7 @@ pub fn statemine_development_config() -> StatemineChainSpec { 1000.into(), ) }, - vec![], + Vec::new(), None, None, Some(properties), @@ -430,7 +429,7 @@ pub fn statemine_local_config() -> StatemineChainSpec { 1000.into(), ) }, - vec![], + Vec::new(), None, None, Some(properties), @@ -478,11 +477,11 @@ pub fn statemine_config() -> StatemineChainSpec { .unchecked_into(), ), ], - vec![], + Vec::new(), 1000.into(), ) }, - vec![], + Vec::new(), None, None, Some(properties), @@ -513,12 +512,11 @@ fn statemine_genesis( }, session: statemine_runtime::SessionConfig { keys: invulnerables - .iter() - .cloned() + .into_iter() .map(|(acc, aura)| { ( acc.clone(), // account id - acc.clone(), // validator id + acc, // validator id statemine_session_keys(aura), // session keys ) }) @@ -558,7 +556,7 @@ pub fn westmint_development_config() -> WestmintChainSpec { 1000.into(), ) }, - vec![], + Vec::new(), None, None, Some(properties), @@ -608,7 +606,7 @@ pub fn westmint_local_config() -> WestmintChainSpec { 1000.into(), ) }, - vec![], + Vec::new(), None, None, Some(properties), @@ -656,13 +654,13 @@ pub fn westmint_config() -> WestmintChainSpec { .unchecked_into(), ), ], - vec![], + Vec::new(), // re-use the Westend sudo key hex!("6648d7f3382690650c681aba1b993cd11e54deb4df21a3a18c3e2177de9f7342").into(), 1000.into(), ) }, - vec![], + Vec::new(), None, None, Some(properties), @@ -695,12 +693,11 @@ fn westmint_genesis( }, session: westmint_runtime::SessionConfig { keys: invulnerables - .iter() - .cloned() + .into_iter() .map(|(acc, aura)| { ( acc.clone(), // account id - acc.clone(), // validator id + acc, // validator id westmint_session_keys(aura), // session keys ) }) diff --git a/polkadot-parachains/src/cli.rs b/polkadot-parachains/src/cli.rs index 0b4bf72032..e0a98be20f 100644 --- a/polkadot-parachains/src/cli.rs +++ b/polkadot-parachains/src/cli.rs @@ -110,7 +110,7 @@ pub struct Cli { #[structopt(flatten)] pub run: cumulus_client_cli::RunCmd, - /// Relaychain arguments + /// Relay chain arguments #[structopt(raw = true)] pub relaychain_args: Vec, } diff --git a/polkadot-parachains/src/command.rs b/polkadot-parachains/src/command.rs index 1e067b1405..e9b2952bf9 100644 --- a/polkadot-parachains/src/command.rs +++ b/polkadot-parachains/src/command.rs @@ -185,8 +185,8 @@ impl SubstrateCli for RelayChainCli { format!( "Polkadot collator\n\nThe command-line arguments provided first will be \ passed to the parachain node, while the arguments provided after -- will be passed \ - to the relaychain node.\n\n\ - {} [parachain-args] -- [relaychain-args]", + to the relay chain node.\n\n\ + {} [parachain-args] -- [relay_chain-args]", Self::executable_name() ) } diff --git a/primitives/core/src/lib.rs b/primitives/core/src/lib.rs index ff35ef5a1c..86668a37b1 100644 --- a/primitives/core/src/lib.rs +++ b/primitives/core/src/lib.rs @@ -122,7 +122,7 @@ pub trait XcmpMessageSource { impl XcmpMessageSource for () { fn take_outbound_messages(_maximum_channels: usize) -> Vec<(ParaId, Vec)> { - vec![] + Vec::new() } } diff --git a/primitives/parachain-inherent/src/client_side.rs b/primitives/parachain-inherent/src/client_side.rs index 3190b992e7..3a4f9d9e9f 100644 --- a/primitives/parachain-inherent/src/client_side.rs +++ b/primitives/parachain-inherent/src/client_side.rs @@ -165,7 +165,7 @@ fn collect_relay_storage_proof( .ok()? .unwrap_or_default(); - let mut relevant_keys = vec![]; + let mut relevant_keys = Vec::new(); relevant_keys.push(relay_well_known_keys::CURRENT_SLOT.to_vec()); relevant_keys.push(relay_well_known_keys::ACTIVE_CONFIG.to_vec()); relevant_keys.push(relay_well_known_keys::dmq_mqc_head(para_id)); diff --git a/test/relay-sproof-builder/src/lib.rs b/test/relay-sproof-builder/src/lib.rs index a3ad558c0f..425e142388 100644 --- a/test/relay-sproof-builder/src/lib.rs +++ b/test/relay-sproof-builder/src/lib.rs @@ -120,7 +120,7 @@ impl RelayStateSproofBuilder { let (db, root) = MemoryDB::>::default_with_root(); let mut backend = sp_state_machine::TrieBackend::new(db, root); - let mut relevant_keys = vec![]; + let mut relevant_keys = Vec::new(); { use codec::Encode as _; diff --git a/test/service/src/chain_spec.rs b/test/service/src/chain_spec.rs index db8504cc98..ec3667c547 100644 --- a/test/service/src/chain_spec.rs +++ b/test/service/src/chain_spec.rs @@ -83,7 +83,7 @@ pub fn get_chain_spec(id: ParaId) -> ChainSpec { "local_testnet", ChainType::Local, move || GenesisExt { runtime_genesis_config: local_testnet_genesis() }, - vec![], + Vec::new(), None, None, None, diff --git a/test/service/tests/integration.rs b/test/service/tests/integration.rs index e78405473d..6203da3678 100644 --- a/test/service/tests/integration.rs +++ b/test/service/tests/integration.rs @@ -30,7 +30,7 @@ async fn test_collating_and_non_collator_mode_catching_up() { let tokio_handle = tokio::runtime::Handle::current(); // start alice - let alice = run_relay_chain_validator_node(tokio_handle.clone(), Alice, || {}, vec![]); + let alice = run_relay_chain_validator_node(tokio_handle.clone(), Alice, || {}, Vec::new()); // start bob let bob = diff --git a/test/service/tests/runtime_upgrade.rs b/test/service/tests/runtime_upgrade.rs index 519947f996..2b0ae271e1 100644 --- a/test/service/tests/runtime_upgrade.rs +++ b/test/service/tests/runtime_upgrade.rs @@ -31,7 +31,7 @@ async fn test_runtime_upgrade() { let tokio_handle = tokio::runtime::Handle::current(); // start alice - let alice = run_relay_chain_validator_node(tokio_handle.clone(), Alice, || {}, vec![]); + let alice = run_relay_chain_validator_node(tokio_handle.clone(), Alice, || {}, Vec::new()); // start bob let bob =