Moves Block to frame_system instead of construct_runtime and removes Header and BlockNumber (#7431)

* Companion for substrate

* Minor update

* Formatting

* Fixes for cumulus

* Fixes tests in polkadot-runtime-parachains

* Minor update

* Removes unused import

* Fixes tests in polkadot-runtime-common

* Minor fix

* Update roadmap/implementers-guide/src/runtime/configuration.md

Co-authored-by: ordian <write@reusable.software>

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

* update lockfile for {"substrate"}

---------

Co-authored-by: ordian <write@reusable.software>
Co-authored-by: command-bot <>
This commit is contained in:
gupnik
2023-07-13 18:07:50 +05:30
committed by GitHub
parent bfaec080cc
commit 2802414473
47 changed files with 562 additions and 643 deletions
+8 -8
View File
@@ -180,7 +180,7 @@ pub mod pallet {
/// A lockable currency.
// TODO: We should really use a trait which can handle multiple currencies.
type Currency: LockableCurrency<Self::AccountId, Moment = Self::BlockNumber>;
type Currency: LockableCurrency<Self::AccountId, Moment = BlockNumberFor<Self>>;
/// The `MultiAsset` matcher for `Currency`.
type CurrencyMatcher: MatchesFungible<BalanceOf<Self>>;
@@ -508,7 +508,7 @@ pub mod pallet {
#[pallet::storage]
#[pallet::getter(fn query)]
pub(super) type Queries<T: Config> =
StorageMap<_, Blake2_128Concat, QueryId, QueryStatus<T::BlockNumber>, OptionQuery>;
StorageMap<_, Blake2_128Concat, QueryId, QueryStatus<BlockNumberFor<T>>, OptionQuery>;
/// The existing asset traps.
///
@@ -743,7 +743,7 @@ pub mod pallet {
if on_chain_storage_version < 1 {
let mut count = 0;
Queries::<T>::translate::<QueryStatusV0<T::BlockNumber>, _>(|_key, value| {
Queries::<T>::translate::<QueryStatusV0<BlockNumberFor<T>>, _>(|_key, value| {
count += 1;
Some(value.into())
});
@@ -1130,14 +1130,14 @@ const MAX_ASSETS_FOR_TRANSFER: usize = 2;
impl<T: Config> QueryHandler for Pallet<T> {
type QueryId = u64;
type BlockNumber = T::BlockNumber;
type BlockNumber = BlockNumberFor<T>;
type Error = XcmError;
type UniversalLocation = T::UniversalLocation;
/// Attempt to create a new query ID and register it as a query that is yet to respond.
fn new_query(
responder: impl Into<MultiLocation>,
timeout: T::BlockNumber,
timeout: BlockNumberFor<T>,
match_querier: impl Into<MultiLocation>,
) -> Self::QueryId {
Self::do_new_query(responder, None, timeout, match_querier).into()
@@ -1540,7 +1540,7 @@ impl<T: Config> Pallet<T> {
fn do_new_query(
responder: impl Into<MultiLocation>,
maybe_notify: Option<(u8, u8)>,
timeout: T::BlockNumber,
timeout: BlockNumberFor<T>,
match_querier: impl Into<MultiLocation>,
) -> u64 {
QueryCounter::<T>::mutate(|q| {
@@ -1585,7 +1585,7 @@ impl<T: Config> Pallet<T> {
message: &mut Xcm<()>,
responder: impl Into<MultiLocation>,
notify: impl Into<<T as Config>::RuntimeCall>,
timeout: T::BlockNumber,
timeout: BlockNumberFor<T>,
) -> Result<(), XcmError> {
let responder = responder.into();
let destination = T::UniversalLocation::get()
@@ -1605,7 +1605,7 @@ impl<T: Config> Pallet<T> {
pub fn new_notify_query(
responder: impl Into<MultiLocation>,
notify: impl Into<<T as Config>::RuntimeCall>,
timeout: T::BlockNumber,
timeout: BlockNumberFor<T>,
match_querier: impl Into<MultiLocation>,
) -> u64 {
let notify = notify.into().using_encoded(|mut bytes| Decode::decode(&mut bytes)).expect(
+3 -8
View File
@@ -24,7 +24,7 @@ use frame_system::EnsureRoot;
use polkadot_parachain::primitives::Id as ParaId;
use polkadot_runtime_parachains::origin;
use sp_core::H256;
use sp_runtime::{testing::Header, traits::IdentityLookup, AccountId32, BuildStorage};
use sp_runtime::{traits::IdentityLookup, AccountId32, BuildStorage};
pub use sp_std::{cell::RefCell, fmt::Debug, marker::PhantomData};
use xcm::prelude::*;
use xcm_builder::{
@@ -40,7 +40,6 @@ use crate::{self as pallet_xcm, TestWeightInfo};
pub type AccountId = AccountId32;
pub type Balance = u128;
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
type Block = frame_system::mocking::MockBlock<Test>;
#[frame_support::pallet]
@@ -132,10 +131,7 @@ pub mod pallet_test_notifier {
}
construct_runtime!(
pub enum Test where
Block = Block,
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
pub enum Test
{
System: frame_system::{Pallet, Call, Storage, Config<T>, Event<T>},
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
@@ -205,12 +201,11 @@ impl frame_system::Config for Test {
type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall;
type Index = u64;
type BlockNumber = u64;
type Hash = H256;
type Hashing = ::sp_runtime::traits::BlakeTwo256;
type AccountId = AccountId;
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Block = Block;
type RuntimeEvent = RuntimeEvent;
type BlockHashCount = BlockHashCount;
type BlockWeights = ();