From 271f6a20e8a840c9bac1e2155bd0647be933c9bb Mon Sep 17 00:00:00 2001 From: muraca Date: Mon, 20 Feb 2023 23:45:58 +0100 Subject: [PATCH] remove every usage of `#[pallet::getter]` Signed-off-by: muraca --- pallets/collator-selection/src/lib.rs | 14 ++--- pallets/collator-selection/src/tests.rs | 58 ++++++++++--------- pallets/parachain-system/src/lib.rs | 20 +++---- .../pallets/template/src/lib.rs | 1 - .../pallets/template/src/tests.rs | 4 +- parachain-template/runtime/src/xcm_config.rs | 3 +- parachains/pallets/parachain-info/src/lib.rs | 2 +- .../assets/statemine/src/xcm_config.rs | 3 +- .../assets/statemint/src/xcm_config.rs | 3 +- .../assets/westmint/src/xcm_config.rs | 3 +- .../bridge-hub-kusama/src/xcm_config.rs | 3 +- .../bridge-hub-polkadot/src/xcm_config.rs | 3 +- .../bridge-hub-rococo/src/xcm_config.rs | 3 +- .../collectives-polkadot/src/xcm_config.rs | 3 +- .../contracts-rococo/src/xcm_config.rs | 3 +- .../runtimes/starters/shell/src/xcm_config.rs | 3 +- .../runtimes/testing/penpal/src/xcm_config.rs | 2 +- .../testing/rococo-parachain/src/lib.rs | 4 +- test/runtime/src/lib.rs | 2 +- 19 files changed, 73 insertions(+), 64 deletions(-) diff --git a/pallets/collator-selection/src/lib.rs b/pallets/collator-selection/src/lib.rs index 3dba6846cc3..0453dedbfee 100644 --- a/pallets/collator-selection/src/lib.rs +++ b/pallets/collator-selection/src/lib.rs @@ -355,8 +355,8 @@ pub mod pallet { // ensure we are below limit. let length = >::decode_len().unwrap_or_default(); - ensure!((length as u32) < Self::desired_candidates(), Error::::TooManyCandidates); - ensure!(!Self::invulnerables().contains(&who), Error::::AlreadyInvulnerable); + ensure!((length as u32) < DesiredCandidates::::get(), Error::::TooManyCandidates); + ensure!(!Invulnerables::::get().contains(&who), Error::::AlreadyInvulnerable); let validator_key = T::ValidatorIdOf::convert(who.clone()) .ok_or(Error::::NoAssociatedValidatorId)?; @@ -365,7 +365,7 @@ pub mod pallet { Error::::ValidatorNotRegistered ); - let deposit = Self::candidacy_bond(); + let deposit = CandidacyBond::::get(); // First authored block is current block plus kick threshold to handle session delay let incoming = CandidateInfo { who: who.clone(), deposit }; @@ -399,7 +399,7 @@ pub mod pallet { pub fn leave_intent(origin: OriginFor) -> DispatchResultWithPostInfo { let who = ensure_signed(origin)?; ensure!( - Self::candidates().len() as u32 > T::MinCandidates::get(), + Candidates::::get().len() as u32 > T::MinCandidates::get(), Error::::TooFewCandidates ); let current_count = Self::try_remove_candidate(&who)?; @@ -437,7 +437,7 @@ pub mod pallet { pub fn assemble_collators( candidates: BoundedVec, ) -> Vec { - let mut collators = Self::invulnerables().to_vec(); + let mut collators = Invulnerables::::get().to_vec(); collators.extend(candidates); collators } @@ -455,7 +455,7 @@ pub mod pallet { let last_block = >::get(c.who.clone()); let since_last = now.saturating_sub(last_block); if since_last < kick_threshold || - Self::candidates().len() as u32 <= T::MinCandidates::get() + Candidates::::get().len() as u32 <= T::MinCandidates::get() { Some(c.who) } else { @@ -506,7 +506,7 @@ pub mod pallet { >::block_number(), ); - let candidates = Self::candidates(); + let candidates = Candidates::::get(); let candidates_len_before = candidates.len(); let active_candidates = Self::kick_stale_candidates(candidates); let removed = candidates_len_before - active_candidates.len(); diff --git a/pallets/collator-selection/src/tests.rs b/pallets/collator-selection/src/tests.rs index 459b107ecc5..935f1e41779 100644 --- a/pallets/collator-selection/src/tests.rs +++ b/pallets/collator-selection/src/tests.rs @@ -14,7 +14,9 @@ // limitations under the License. use crate as collator_selection; -use crate::{mock::*, CandidateInfo, Error}; +use crate::{ + mock::*, CandidacyBond, CandidateInfo, Candidates, DesiredCandidates, Error, Invulnerables, +}; use frame_support::{ assert_noop, assert_ok, traits::{Currency, GenesisBuild, OnInitialize}, @@ -25,11 +27,11 @@ use sp_runtime::traits::BadOrigin; #[test] fn basic_setup_works() { new_test_ext().execute_with(|| { - assert_eq!(CollatorSelection::desired_candidates(), 2); - assert_eq!(CollatorSelection::candidacy_bond(), 10); + assert_eq!(DesiredCandidates::::get(), 2); + assert_eq!(CandidacyBond::::get(), 10); - assert!(CollatorSelection::candidates().is_empty()); - assert_eq!(CollatorSelection::invulnerables(), vec![1, 2]); + assert!(Candidates::::get().is_empty()); + assert_eq!(Invulnerables::::get(), vec![1, 2]); }); } @@ -41,7 +43,7 @@ fn it_should_set_invulnerables() { RuntimeOrigin::signed(RootAccount::get()), new_set.clone() )); - assert_eq!(CollatorSelection::invulnerables(), new_set); + assert_eq!(Invulnerables::::get(), new_set); // cannot set with non-root. assert_noop!( @@ -65,14 +67,14 @@ fn it_should_set_invulnerables() { fn set_desired_candidates_works() { new_test_ext().execute_with(|| { // given - assert_eq!(CollatorSelection::desired_candidates(), 2); + assert_eq!(DesiredCandidates::::get(), 2); // can set assert_ok!(CollatorSelection::set_desired_candidates( RuntimeOrigin::signed(RootAccount::get()), 7 )); - assert_eq!(CollatorSelection::desired_candidates(), 7); + assert_eq!(DesiredCandidates::::get(), 7); // rejects bad origin assert_noop!( @@ -86,14 +88,14 @@ fn set_desired_candidates_works() { fn set_candidacy_bond() { new_test_ext().execute_with(|| { // given - assert_eq!(CollatorSelection::candidacy_bond(), 10); + assert_eq!(CandidacyBond::::get(), 10); // can set assert_ok!(CollatorSelection::set_candidacy_bond( RuntimeOrigin::signed(RootAccount::get()), 7 )); - assert_eq!(CollatorSelection::candidacy_bond(), 7); + assert_eq!(CandidacyBond::::get(), 7); // rejects bad origin. assert_noop!(CollatorSelection::set_candidacy_bond(RuntimeOrigin::signed(1), 8), BadOrigin); @@ -142,7 +144,7 @@ fn cannot_unregister_candidate_if_too_few() { #[test] fn cannot_register_as_candidate_if_invulnerable() { new_test_ext().execute_with(|| { - assert_eq!(CollatorSelection::invulnerables(), vec![1, 2]); + assert_eq!(Invulnerables::::get(), vec![1, 2]); // can't 1 because it is invulnerable. assert_noop!( @@ -169,7 +171,7 @@ fn cannot_register_dupe_candidate() { // can add 3 as candidate assert_ok!(CollatorSelection::register_as_candidate(RuntimeOrigin::signed(3))); let addition = CandidateInfo { who: 3, deposit: 10 }; - assert_eq!(CollatorSelection::candidates(), vec![addition]); + assert_eq!(Candidates::::get(), vec![addition]); assert_eq!(CollatorSelection::last_authored_block(3), 10); assert_eq!(Balances::free_balance(3), 90); @@ -202,10 +204,10 @@ fn cannot_register_as_candidate_if_poor() { fn register_as_candidate_works() { new_test_ext().execute_with(|| { // given - assert_eq!(CollatorSelection::desired_candidates(), 2); - assert_eq!(CollatorSelection::candidacy_bond(), 10); - assert_eq!(CollatorSelection::candidates(), Vec::new()); - assert_eq!(CollatorSelection::invulnerables(), vec![1, 2]); + assert_eq!(DesiredCandidates::::get(), 2); + assert_eq!(CandidacyBond::::get(), 10); + assert_eq!(Candidates::::get(), Vec::new()); + assert_eq!(Invulnerables::::get(), vec![1, 2]); // take two endowed, non-invulnerables accounts. assert_eq!(Balances::free_balance(&3), 100); @@ -217,7 +219,7 @@ fn register_as_candidate_works() { assert_eq!(Balances::free_balance(&3), 90); assert_eq!(Balances::free_balance(&4), 90); - assert_eq!(CollatorSelection::candidates().len(), 2); + assert_eq!(Candidates::::get().len(), 2); }); } @@ -259,7 +261,7 @@ fn authorship_event_handler() { let collator = CandidateInfo { who: 4, deposit: 10 }; - assert_eq!(CollatorSelection::candidates(), vec![collator]); + assert_eq!(Candidates::::get(), vec![collator]); assert_eq!(CollatorSelection::last_authored_block(4), 0); // half of the pot goes to the collator who's the author (4 in tests). @@ -284,7 +286,7 @@ fn fees_edgecases() { let collator = CandidateInfo { who: 4, deposit: 10 }; - assert_eq!(CollatorSelection::candidates(), vec![collator]); + assert_eq!(Candidates::::get(), vec![collator]); assert_eq!(CollatorSelection::last_authored_block(4), 0); // Nothing received assert_eq!(Balances::free_balance(4), 90); @@ -312,14 +314,14 @@ fn session_management_works() { // session won't see this. assert_eq!(SessionHandlerCollators::get(), vec![1, 2]); // but we have a new candidate. - assert_eq!(CollatorSelection::candidates().len(), 1); + assert_eq!(Candidates::::get().len(), 1); initialize_to_block(10); assert_eq!(SessionChangeBlock::get(), 10); // pallet-session has 1 session delay; current validators are the same. - assert_eq!(Session::validators(), vec![1, 2]); + assert_eq!(pallet_session::Validators::::get(), vec![1, 2]); // queued ones are changed, and now we have 3. - assert_eq!(Session::queued_keys().len(), 3); + assert_eq!(pallet_session::QueuedKeys::::get().len(), 3); // session handlers (aura, et. al.) cannot see this yet. assert_eq!(SessionHandlerCollators::get(), vec![1, 2]); @@ -337,15 +339,15 @@ fn kick_mechanism() { assert_ok!(CollatorSelection::register_as_candidate(RuntimeOrigin::signed(3))); assert_ok!(CollatorSelection::register_as_candidate(RuntimeOrigin::signed(4))); initialize_to_block(10); - assert_eq!(CollatorSelection::candidates().len(), 2); + assert_eq!(Candidates::::get().len(), 2); initialize_to_block(20); assert_eq!(SessionChangeBlock::get(), 20); // 4 authored this block, gets to stay 3 was kicked - assert_eq!(CollatorSelection::candidates().len(), 1); + assert_eq!(Candidates::::get().len(), 1); // 3 will be kicked after 1 session delay assert_eq!(SessionHandlerCollators::get(), vec![1, 2, 3, 4]); let collator = CandidateInfo { who: 4, deposit: 10 }; - assert_eq!(CollatorSelection::candidates(), vec![collator]); + assert_eq!(Candidates::::get(), vec![collator]); assert_eq!(CollatorSelection::last_authored_block(4), 20); initialize_to_block(30); // 3 gets kicked after 1 session delay @@ -362,15 +364,15 @@ fn should_not_kick_mechanism_too_few() { assert_ok!(CollatorSelection::register_as_candidate(RuntimeOrigin::signed(3))); assert_ok!(CollatorSelection::register_as_candidate(RuntimeOrigin::signed(5))); initialize_to_block(10); - assert_eq!(CollatorSelection::candidates().len(), 2); + assert_eq!(Candidates::::get().len(), 2); initialize_to_block(20); assert_eq!(SessionChangeBlock::get(), 20); // 4 authored this block, 5 gets to stay too few 3 was kicked - assert_eq!(CollatorSelection::candidates().len(), 1); + assert_eq!(Candidates::::get().len(), 1); // 3 will be kicked after 1 session delay assert_eq!(SessionHandlerCollators::get(), vec![1, 2, 3, 5]); let collator = CandidateInfo { who: 5, deposit: 10 }; - assert_eq!(CollatorSelection::candidates(), vec![collator]); + assert_eq!(Candidates::::get(), vec![collator]); assert_eq!(CollatorSelection::last_authored_block(4), 20); initialize_to_block(30); // 3 gets kicked after 1 session delay diff --git a/pallets/parachain-system/src/lib.rs b/pallets/parachain-system/src/lib.rs index 97c6cfe368d..dd8e53fd0ee 100644 --- a/pallets/parachain-system/src/lib.rs +++ b/pallets/parachain-system/src/lib.rs @@ -210,7 +210,7 @@ pub mod pallet { "set_validation_data inherent needs to be present in every block!" ); - let host_config = match Self::host_configuration() { + let host_config = match HostConfiguration::::get() { Some(ok) => ok, None => { debug_assert!( @@ -220,7 +220,7 @@ pub mod pallet { return }, }; - let relevant_messaging_state = match Self::relevant_messaging_state() { + let relevant_messaging_state = match RelevantMessagingState::::get() { Some(ok) => ok, None => { debug_assert!( @@ -325,7 +325,7 @@ pub mod pallet { // than the announced, we would waste some of weight. In the case the actual value is // greater than the announced, we will miss opportunity to send a couple of messages. weight += T::DbWeight::get().reads_writes(1, 1); - let hrmp_max_message_num_per_candidate = Self::host_configuration() + let hrmp_max_message_num_per_candidate = HostConfiguration::::get() .map(|cfg| cfg.hrmp_max_message_num_per_candidate) .unwrap_or(0); >::put(hrmp_max_message_num_per_candidate); @@ -781,7 +781,7 @@ impl GetChannelInfo for Pallet { // // Here it a similar case, with the difference that the realization that the channel is // closed came the same block. - let channels = match Self::relevant_messaging_state() { + let channels = match RelevantMessagingState::::get() { None => { log::warn!("calling `get_channel_status` with no RelevantMessagingState?!"); return ChannelStatus::Closed @@ -809,7 +809,7 @@ impl GetChannelInfo for Pallet { } fn get_channel_max(id: ParaId) -> Option { - let channels = Self::relevant_messaging_state()?.egress_channels; + let channels = RelevantMessagingState::::get()?.egress_channels; let index = channels.binary_search_by_key(&id, |item| item.0).ok()?; Some(channels[index].1.max_message_size as usize) } @@ -989,7 +989,7 @@ impl Pallet { ensure!(>::get().is_none(), Error::::ProhibitedByPolkadot); ensure!(!>::exists(), Error::::OverlappingUpgrades); - let cfg = Self::host_configuration().ok_or(Error::::HostConfigurationNotAvailable)?; + let cfg = HostConfiguration::::get().ok_or(Error::::HostConfigurationNotAvailable)?; ensure!(validation_function.len() <= cfg.max_code_size as usize, Error::::TooBig); // When a code upgrade is scheduled, it has to be applied in two @@ -1066,7 +1066,7 @@ impl Pallet { // may change so that the message is no longer valid. // // However, changing this setting is expected to be rare. - match Self::host_configuration() { + match HostConfiguration::::get() { Some(cfg) => if message.len() > cfg.max_upward_message_size as usize { return Err(MessageSendError::TooBig) @@ -1157,9 +1157,7 @@ impl BlockNumberProvider for RelaychainBlockNumberProvider { type BlockNumber = relay_chain::BlockNumber; fn current_block_number() -> relay_chain::BlockNumber { - Pallet::::validation_data() - .map(|d| d.relay_parent_number) - .unwrap_or_default() + ValidationData::::get().map(|d| d.relay_parent_number).unwrap_or_default() } #[cfg(feature = "runtime-benchmarks")] @@ -1204,7 +1202,7 @@ impl BlockNumberProvider for RelaychainDataProvider { #[cfg(feature = "runtime-benchmarks")] fn set_block_number(block: Self::BlockNumber) { - let mut validation_data = Pallet::::validation_data().unwrap_or_else(|| + let mut validation_data = ValidationData::::get().unwrap_or_else(|| // PersistedValidationData does not impl default in non-std PersistedValidationData { parent_head: vec![].into(), diff --git a/parachain-template/pallets/template/src/lib.rs b/parachain-template/pallets/template/src/lib.rs index 5f3252bfc3a..24226d6cf40 100644 --- a/parachain-template/pallets/template/src/lib.rs +++ b/parachain-template/pallets/template/src/lib.rs @@ -32,7 +32,6 @@ pub mod pallet { // The pallet's runtime storage items. // https://docs.substrate.io/v3/runtime/storage #[pallet::storage] - #[pallet::getter(fn something)] // Learn more about declaring storage items: // https://docs.substrate.io/v3/runtime/storage#declaring-storage-items pub type Something = StorageValue<_, u32>; diff --git a/parachain-template/pallets/template/src/tests.rs b/parachain-template/pallets/template/src/tests.rs index 527aec8ed00..9ad3076be2c 100644 --- a/parachain-template/pallets/template/src/tests.rs +++ b/parachain-template/pallets/template/src/tests.rs @@ -1,4 +1,4 @@ -use crate::{mock::*, Error}; +use crate::{mock::*, Error, Something}; use frame_support::{assert_noop, assert_ok}; #[test] @@ -7,7 +7,7 @@ fn it_works_for_default_value() { // Dispatch a signed extrinsic. assert_ok!(TemplateModule::do_something(RuntimeOrigin::signed(1), 42)); // Read pallet storage and assert an expected result. - assert_eq!(TemplateModule::something(), Some(42)); + assert_eq!(Something::::get(), Some(42)); }); } diff --git a/parachain-template/runtime/src/xcm_config.rs b/parachain-template/runtime/src/xcm_config.rs index b82be7aebf0..2741d4668a2 100644 --- a/parachain-template/runtime/src/xcm_config.rs +++ b/parachain-template/runtime/src/xcm_config.rs @@ -12,6 +12,7 @@ use frame_system::EnsureRoot; use pallet_xcm::XcmPassthrough; use polkadot_parachain::primitives::Sibling; use polkadot_runtime_common::impls::ToAuthor; +use sp_core::Get; use xcm::{latest::prelude::*, CreateMatcher, MatchXcm}; use xcm_builder::{ AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowTopLevelPaidExecutionFrom, @@ -26,7 +27,7 @@ parameter_types! { pub const RelayLocation: MultiLocation = MultiLocation::parent(); pub const RelayNetwork: Option = None; pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into(); - pub UniversalLocation: InteriorMultiLocation = Parachain(ParachainInfo::parachain_id().into()).into(); + pub UniversalLocation: InteriorMultiLocation = Parachain(ParachainInfo::get().into()).into(); } /// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used diff --git a/parachains/pallets/parachain-info/src/lib.rs b/parachains/pallets/parachain-info/src/lib.rs index d61387aaeb6..9dccae3cc70 100644 --- a/parachains/pallets/parachain-info/src/lib.rs +++ b/parachains/pallets/parachain-info/src/lib.rs @@ -69,7 +69,7 @@ pub mod pallet { impl Get for Pallet { fn get() -> ParaId { - Self::parachain_id() + ParachainId::::get() } } } diff --git a/parachains/runtimes/assets/statemine/src/xcm_config.rs b/parachains/runtimes/assets/statemine/src/xcm_config.rs index 5d4c45fd4f3..f6ecc4bd700 100644 --- a/parachains/runtimes/assets/statemine/src/xcm_config.rs +++ b/parachains/runtimes/assets/statemine/src/xcm_config.rs @@ -34,6 +34,7 @@ use parachains_common::{ }, }; use polkadot_parachain::primitives::Sibling; +use sp_core::Get; use sp_runtime::traits::ConvertInto; use xcm::latest::prelude::*; use xcm_builder::{ @@ -51,7 +52,7 @@ parameter_types! { pub const RelayNetwork: Option = Some(NetworkId::Kusama); pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into(); pub UniversalLocation: InteriorMultiLocation = - X2(GlobalConsensus(RelayNetwork::get().unwrap()), Parachain(ParachainInfo::parachain_id().into())); + X2(GlobalConsensus(RelayNetwork::get().unwrap()), Parachain(ParachainInfo::get().into())); pub UniversalLocationNetworkId: NetworkId = UniversalLocation::get().global_consensus().unwrap(); pub TrustBackedAssetsPalletLocation: MultiLocation = PalletInstance(::index() as u8).into(); diff --git a/parachains/runtimes/assets/statemint/src/xcm_config.rs b/parachains/runtimes/assets/statemint/src/xcm_config.rs index 90b0ee85fef..bbacb2ef27c 100644 --- a/parachains/runtimes/assets/statemint/src/xcm_config.rs +++ b/parachains/runtimes/assets/statemint/src/xcm_config.rs @@ -31,6 +31,7 @@ use parachains_common::{ }, }; use polkadot_parachain::primitives::Sibling; +use sp_core::Get; use sp_runtime::traits::ConvertInto; use xcm::latest::prelude::*; use xcm_builder::{ @@ -48,7 +49,7 @@ parameter_types! { pub const RelayNetwork: Option = Some(NetworkId::Polkadot); pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into(); pub UniversalLocation: InteriorMultiLocation = - X2(GlobalConsensus(RelayNetwork::get().unwrap()), Parachain(ParachainInfo::parachain_id().into())); + X2(GlobalConsensus(RelayNetwork::get().unwrap()), Parachain(ParachainInfo::get().into())); pub TrustBackedAssetsPalletLocation: MultiLocation = PalletInstance(::index() as u8).into(); pub CheckingAccount: AccountId = PolkadotXcm::check_account(); diff --git a/parachains/runtimes/assets/westmint/src/xcm_config.rs b/parachains/runtimes/assets/westmint/src/xcm_config.rs index 1f57b34fcae..ce47ae03380 100644 --- a/parachains/runtimes/assets/westmint/src/xcm_config.rs +++ b/parachains/runtimes/assets/westmint/src/xcm_config.rs @@ -35,6 +35,7 @@ use parachains_common::{ }, }; use polkadot_parachain::primitives::Sibling; +use sp_core::Get; use sp_runtime::traits::ConvertInto; use xcm::latest::prelude::*; use xcm_builder::{ @@ -52,7 +53,7 @@ parameter_types! { pub RelayNetwork: Option = Some(NetworkId::Westend); pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into(); pub UniversalLocation: InteriorMultiLocation = - X2(GlobalConsensus(RelayNetwork::get().unwrap()), Parachain(ParachainInfo::parachain_id().into())); + X2(GlobalConsensus(RelayNetwork::get().unwrap()), Parachain(ParachainInfo::get().into())); pub UniversalLocationNetworkId: NetworkId = UniversalLocation::get().global_consensus().unwrap(); pub TrustBackedAssetsPalletLocation: MultiLocation = PalletInstance(::index() as u8).into(); diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs index cfe8662cb7c..1382bd0b224 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs @@ -29,6 +29,7 @@ use parachains_common::xcm_config::{ }; use polkadot_parachain::primitives::Sibling; use polkadot_runtime_common::impls::ToAuthor; +use sp_core::Get; use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, @@ -45,7 +46,7 @@ parameter_types! { pub const RelayNetwork: Option = Some(NetworkId::Kusama); pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into(); pub UniversalLocation: InteriorMultiLocation = - X2(GlobalConsensus(RelayNetwork::get().unwrap()), Parachain(ParachainInfo::parachain_id().into())); + X2(GlobalConsensus(RelayNetwork::get().unwrap()), Parachain(ParachainInfo::get().into())); pub const MaxInstructions: u32 = 100; pub const MaxAssetsIntoHolding: u32 = 64; pub const GovernanceLocation: MultiLocation = MultiLocation::parent(); diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs index 189e7c74f81..c6cfa5d1bc0 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs @@ -29,6 +29,7 @@ use parachains_common::xcm_config::{ }; use polkadot_parachain::primitives::Sibling; use polkadot_runtime_common::impls::ToAuthor; +use sp_core::Get; use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, @@ -45,7 +46,7 @@ parameter_types! { pub const RelayNetwork: Option = Some(NetworkId::Polkadot); pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into(); pub UniversalLocation: InteriorMultiLocation = - X2(GlobalConsensus(RelayNetwork::get().unwrap()), Parachain(ParachainInfo::parachain_id().into())); + X2(GlobalConsensus(RelayNetwork::get().unwrap()), Parachain(ParachainInfo::get().into())); pub const MaxInstructions: u32 = 100; pub const MaxAssetsIntoHolding: u32 = 64; pub FellowshipLocation: MultiLocation = MultiLocation::new(1, Parachain(1001)); diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs index 17ac293c62b..a72fd27193e 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs @@ -29,6 +29,7 @@ use parachains_common::xcm_config::{ }; use polkadot_parachain::primitives::Sibling; use polkadot_runtime_common::impls::ToAuthor; +use sp_core::Get; use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, @@ -45,7 +46,7 @@ parameter_types! { pub const RelayNetwork: Option = Some(NetworkId::Rococo); pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into(); pub UniversalLocation: InteriorMultiLocation = - X2(GlobalConsensus(RelayNetwork::get().unwrap()), Parachain(ParachainInfo::parachain_id().into())); + X2(GlobalConsensus(RelayNetwork::get().unwrap()), Parachain(ParachainInfo::get().into())); pub const MaxInstructions: u32 = 100; pub const MaxAssetsIntoHolding: u32 = 64; } diff --git a/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs b/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs index 3e726b5b4b7..22d7017abd1 100644 --- a/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs +++ b/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs @@ -29,6 +29,7 @@ use parachains_common::{ xcm_config::{ConcreteNativeAssetFrom, DenyReserveTransferToRelayChain, DenyThenTry}, }; use polkadot_parachain::primitives::Sibling; +use sp_core::Get; use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, @@ -45,7 +46,7 @@ parameter_types! { pub const RelayNetwork: Option = Some(NetworkId::Polkadot); pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into(); pub UniversalLocation: InteriorMultiLocation = - X2(GlobalConsensus(RelayNetwork::get().unwrap()), Parachain(ParachainInfo::parachain_id().into())); + X2(GlobalConsensus(RelayNetwork::get().unwrap()), Parachain(ParachainInfo::get().into())); pub CheckingAccount: AccountId = PolkadotXcm::check_account(); pub const GovernanceLocation: MultiLocation = MultiLocation::parent(); } diff --git a/parachains/runtimes/contracts/contracts-rococo/src/xcm_config.rs b/parachains/runtimes/contracts/contracts-rococo/src/xcm_config.rs index d8ed043fb54..3cd991d1ce3 100644 --- a/parachains/runtimes/contracts/contracts-rococo/src/xcm_config.rs +++ b/parachains/runtimes/contracts/contracts-rococo/src/xcm_config.rs @@ -26,6 +26,7 @@ use frame_system::EnsureRoot; use pallet_xcm::{EnsureXcm, IsMajorityOfBody, XcmPassthrough}; use parachains_common::xcm_config::{DenyReserveTransferToRelayChain, DenyThenTry}; use polkadot_parachain::primitives::Sibling; +use sp_core::Get; use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, @@ -41,7 +42,7 @@ parameter_types! { pub const RelayLocation: MultiLocation = MultiLocation::parent(); pub const RelayNetwork: Option = None; pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into(); - pub UniversalLocation: InteriorMultiLocation = Parachain(ParachainInfo::parachain_id().into()).into(); + pub UniversalLocation: InteriorMultiLocation = Parachain(ParachainInfo::get().into()).into(); pub const ExecutiveBody: BodyId = BodyId::Executive; } diff --git a/parachains/runtimes/starters/shell/src/xcm_config.rs b/parachains/runtimes/starters/shell/src/xcm_config.rs index 8a7b3f21339..c5d479d7955 100644 --- a/parachains/runtimes/starters/shell/src/xcm_config.rs +++ b/parachains/runtimes/starters/shell/src/xcm_config.rs @@ -22,6 +22,7 @@ use frame_support::{ traits::{Everything, Nothing}, weights::Weight, }; +use sp_core::Get; use xcm::latest::prelude::*; use xcm_builder::{ AllowExplicitUnpaidExecutionFrom, FixedWeightBounds, ParentAsSuperuser, ParentIsPreset, @@ -31,7 +32,7 @@ use xcm_builder::{ parameter_types! { pub const RococoLocation: MultiLocation = MultiLocation::parent(); pub const RococoNetwork: Option = Some(NetworkId::Rococo); - pub UniversalLocation: InteriorMultiLocation = X1(Parachain(ParachainInfo::parachain_id().into())); + pub UniversalLocation: InteriorMultiLocation = X1(Parachain(ParachainInfo::get().into())); } /// This is the type we use to convert an (incoming) XCM origin into a local `Origin` instance, diff --git a/parachains/runtimes/testing/penpal/src/xcm_config.rs b/parachains/runtimes/testing/penpal/src/xcm_config.rs index 89cfc2ced65..0cdb5ba4441 100644 --- a/parachains/runtimes/testing/penpal/src/xcm_config.rs +++ b/parachains/runtimes/testing/penpal/src/xcm_config.rs @@ -58,7 +58,7 @@ parameter_types! { pub const RelayLocation: MultiLocation = MultiLocation::parent(); pub const RelayNetwork: Option = None; pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into(); - pub UniversalLocation: InteriorMultiLocation = X1(Parachain(ParachainInfo::parachain_id().into())); + pub UniversalLocation: InteriorMultiLocation = X1(Parachain(ParachainInfo::get().into())); } /// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used diff --git a/parachains/runtimes/testing/rococo-parachain/src/lib.rs b/parachains/runtimes/testing/rococo-parachain/src/lib.rs index 532f39f368b..9a4bdbf9ad3 100644 --- a/parachains/runtimes/testing/rococo-parachain/src/lib.rs +++ b/parachains/runtimes/testing/rococo-parachain/src/lib.rs @@ -24,7 +24,7 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases; use sp_api::impl_runtime_apis; -use sp_core::OpaqueMetadata; +use sp_core::{Get, OpaqueMetadata}; use sp_runtime::{ create_runtime_str, generic, impl_opaque_keys, traits::{AccountIdLookup, BlakeTwo256, Block as BlockT}, @@ -282,7 +282,7 @@ parameter_types! { pub const RocLocation: MultiLocation = MultiLocation::parent(); pub const RococoNetwork: Option = Some(NetworkId::Rococo); pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into(); - pub UniversalLocation: InteriorMultiLocation = X1(Parachain(ParachainInfo::parachain_id().into())); + pub UniversalLocation: InteriorMultiLocation = X1(Parachain(ParachainInfo::get().into())); pub CheckingAccount: AccountId = PolkadotXcm::check_account(); } diff --git a/test/runtime/src/lib.rs b/test/runtime/src/lib.rs index 9d7e9f078da..b7093584e0f 100644 --- a/test/runtime/src/lib.rs +++ b/test/runtime/src/lib.rs @@ -452,7 +452,7 @@ impl_runtime_apis! { impl crate::GetLastTimestamp for Runtime { fn get_last_timestamp() -> u64 { - Timestamp::now() + Timestamp::get() } }