Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,7 @@ impl pallet_multisig::Config for Runtime {
type DepositFactor = DepositFactor;
type MaxSignatories = MaxSignatories;
type WeightInfo = weights::pallet_multisig::WeightInfo<Runtime>;
type BlockNumberProvider = frame_system::Pallet<Runtime>;
}

impl pallet_utility::Config for Runtime {
Expand Down Expand Up @@ -652,6 +653,7 @@ impl pallet_proxy::Config for Runtime {
type CallHasher = BlakeTwo256;
type AnnouncementDepositBase = AnnouncementDepositBase;
type AnnouncementDepositFactor = AnnouncementDepositFactor;
type BlockNumberProvider = frame_system::Pallet<Runtime>;
}

parameter_types! {
Expand Down Expand Up @@ -918,6 +920,7 @@ impl pallet_nfts::Config for Runtime {
type WeightInfo = weights::pallet_nfts::WeightInfo<Runtime>;
#[cfg(feature = "runtime-benchmarks")]
type Helper = ();
type BlockNumberProvider = frame_system::Pallet<Runtime>;
}

/// XCM router instance to BridgeHub with bridging capabilities for `Westend` global
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,7 @@ impl pallet_multisig::Config for Runtime {
type DepositFactor = DepositFactor;
type MaxSignatories = MaxSignatories;
type WeightInfo = weights::pallet_multisig::WeightInfo<Runtime>;
type BlockNumberProvider = frame_system::Pallet<Runtime>;
}

impl pallet_utility::Config for Runtime {
Expand Down Expand Up @@ -651,6 +652,7 @@ impl pallet_proxy::Config for Runtime {
type CallHasher = BlakeTwo256;
type AnnouncementDepositBase = AnnouncementDepositBase;
type AnnouncementDepositFactor = AnnouncementDepositFactor;
type BlockNumberProvider = frame_system::Pallet<Runtime>;
}

parameter_types! {
Expand Down Expand Up @@ -912,6 +914,7 @@ impl pallet_nfts::Config for Runtime {
type WeightInfo = weights::pallet_nfts::WeightInfo<Runtime>;
#[cfg(feature = "runtime-benchmarks")]
type Helper = ();
type BlockNumberProvider = frame_system::Pallet<Runtime>;
}

/// XCM router instance to BridgeHub with bridging capabilities for `Rococo` global
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,7 @@ impl pallet_multisig::Config for Runtime {
type DepositFactor = DepositFactor;
type MaxSignatories = ConstU32<100>;
type WeightInfo = weights::pallet_multisig::WeightInfo<Runtime>;
type BlockNumberProvider = frame_system::Pallet<Runtime>;
}

impl pallet_utility::Config for Runtime {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,7 @@ impl pallet_multisig::Config for Runtime {
type DepositFactor = DepositFactor;
type MaxSignatories = ConstU32<100>;
type WeightInfo = weights::pallet_multisig::WeightInfo<Runtime>;
type BlockNumberProvider = frame_system::Pallet<Runtime>;
}

impl pallet_utility::Config for Runtime {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ impl pallet_multisig::Config for Runtime {
type DepositFactor = DepositFactor;
type MaxSignatories = ConstU32<100>;
type WeightInfo = weights::pallet_multisig::WeightInfo<Runtime>;
type BlockNumberProvider = frame_system::Pallet<Runtime>;
}

impl pallet_utility::Config for Runtime {
Expand Down Expand Up @@ -382,6 +383,7 @@ impl pallet_proxy::Config for Runtime {
type CallHasher = BlakeTwo256;
type AnnouncementDepositBase = AnnouncementDepositBase;
type AnnouncementDepositFactor = AnnouncementDepositFactor;
type BlockNumberProvider = frame_system::Pallet<Runtime>;
}

parameter_types! {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ impl pallet_multisig::Config for Runtime {
type DepositFactor = DepositFactor;
type MaxSignatories = ConstU32<100>;
type WeightInfo = pallet_multisig::weights::SubstrateWeight<Runtime>;
type BlockNumberProvider = frame_system::Pallet<Runtime>;
}

impl pallet_utility::Config for Runtime {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ impl pallet_multisig::Config for Runtime {
type DepositFactor = DepositFactor;
type MaxSignatories = ConstU32<100>;
type WeightInfo = weights::pallet_multisig::WeightInfo<Runtime>;
type BlockNumberProvider = frame_system::Pallet<Runtime>;
}

/// The type used to represent the kinds of proxying allowed.
Expand Down Expand Up @@ -576,6 +577,7 @@ impl pallet_proxy::Config for Runtime {
type CallHasher = BlakeTwo256;
type AnnouncementDepositBase = AnnouncementDepositBase;
type AnnouncementDepositFactor = AnnouncementDepositFactor;
type BlockNumberProvider = frame_system::Pallet<Runtime>;
}

impl pallet_utility::Config for Runtime {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ impl pallet_multisig::Config for Runtime {
type DepositFactor = DepositFactor;
type MaxSignatories = ConstU32<100>;
type WeightInfo = weights::pallet_multisig::WeightInfo<Runtime>;
type BlockNumberProvider = frame_system::Pallet<Runtime>;
}

/// The type used to represent the kinds of proxying allowed.
Expand Down Expand Up @@ -577,6 +578,7 @@ impl pallet_proxy::Config for Runtime {
type CallHasher = BlakeTwo256;
type AnnouncementDepositBase = AnnouncementDepositBase;
type AnnouncementDepositFactor = AnnouncementDepositFactor;
type BlockNumberProvider = frame_system::Pallet<Runtime>;
}

impl pallet_utility::Config for Runtime {
Expand Down
2 changes: 2 additions & 0 deletions cumulus/parachains/runtimes/people/people-rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ impl pallet_multisig::Config for Runtime {
type DepositFactor = DepositFactor;
type MaxSignatories = ConstU32<100>;
type WeightInfo = weights::pallet_multisig::WeightInfo<Runtime>;
type BlockNumberProvider = frame_system::Pallet<Runtime>;
}

/// The type used to represent the kinds of proxying allowed.
Expand Down Expand Up @@ -520,6 +521,7 @@ impl pallet_proxy::Config for Runtime {
type CallHasher = BlakeTwo256;
type AnnouncementDepositBase = AnnouncementDepositBase;
type AnnouncementDepositFactor = AnnouncementDepositFactor;
type BlockNumberProvider = frame_system::Pallet<Runtime>;
}

impl pallet_utility::Config for Runtime {
Expand Down
2 changes: 2 additions & 0 deletions cumulus/parachains/runtimes/people/people-westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ impl pallet_multisig::Config for Runtime {
type DepositFactor = DepositFactor;
type MaxSignatories = ConstU32<100>;
type WeightInfo = weights::pallet_multisig::WeightInfo<Runtime>;
type BlockNumberProvider = frame_system::Pallet<Runtime>;
}

/// The type used to represent the kinds of proxying allowed.
Expand Down Expand Up @@ -519,6 +520,7 @@ impl pallet_proxy::Config for Runtime {
type CallHasher = BlakeTwo256;
type AnnouncementDepositBase = AnnouncementDepositBase;
type AnnouncementDepositFactor = AnnouncementDepositFactor;
type BlockNumberProvider = frame_system::Pallet<Runtime>;
}

impl pallet_utility::Config for Runtime {
Expand Down
2 changes: 2 additions & 0 deletions polkadot/runtime/rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,7 @@ impl pallet_multisig::Config for Runtime {
type DepositFactor = DepositFactor;
type MaxSignatories = MaxSignatories;
type WeightInfo = weights::pallet_multisig::WeightInfo<Runtime>;
type BlockNumberProvider = frame_system::Pallet<Runtime>;
}

parameter_types! {
Expand Down Expand Up @@ -970,6 +971,7 @@ impl pallet_proxy::Config for Runtime {
type CallHasher = BlakeTwo256;
type AnnouncementDepositBase = AnnouncementDepositBase;
type AnnouncementDepositFactor = AnnouncementDepositFactor;
type BlockNumberProvider = frame_system::Pallet<Runtime>;
}

impl parachains_origin::Config for Runtime {}
Expand Down
2 changes: 2 additions & 0 deletions polkadot/runtime/westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1002,6 +1002,7 @@ impl pallet_multisig::Config for Runtime {
type DepositFactor = DepositFactor;
type MaxSignatories = MaxSignatories;
type WeightInfo = weights::pallet_multisig::WeightInfo<Runtime>;
type BlockNumberProvider = frame_system::Pallet<Runtime>;
}

parameter_types! {
Expand Down Expand Up @@ -1202,6 +1203,7 @@ impl pallet_proxy::Config for Runtime {
type CallHasher = BlakeTwo256;
type AnnouncementDepositBase = AnnouncementDepositBase;
type AnnouncementDepositFactor = AnnouncementDepositFactor;
type BlockNumberProvider = frame_system::Pallet<Runtime>;
}

impl parachains_origin::Config for Runtime {}
Expand Down
24 changes: 24 additions & 0 deletions prdoc/pr_5723.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
title: Adds `BlockNumberProvider` in multisig, proxy and nft pallets

doc:
- audience: Runtime Dev
description: |
This PR adds the ability for these pallets to specify their source of the block number.
This is useful when these pallets are migrated from the relay chain to a parachain and
vice versa.

This change is backwards compatible:
1. If the `BlockNumberProvider` continues to use the system pallet's block number
2. When a pallet deployed on the relay chain is moved to a parachain, but still uses the
relay chain's block number

However, we would need migrations if the deployed pallets are upgraded on an existing parachain,
and the `BlockNumberProvider` uses the relay chain block number.

crates:
- name: pallet-multisig
bump: major
- name: pallet-proxy
bump: major
- name: pallet-nfts
bump: major
3 changes: 3 additions & 0 deletions substrate/bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ impl pallet_multisig::Config for Runtime {
type DepositFactor = DepositFactor;
type MaxSignatories = ConstU32<100>;
type WeightInfo = pallet_multisig::weights::SubstrateWeight<Runtime>;
type BlockNumberProvider = frame_system::Pallet<Runtime>;
}

parameter_types! {
Expand Down Expand Up @@ -441,6 +442,7 @@ impl pallet_proxy::Config for Runtime {
type CallHasher = BlakeTwo256;
type AnnouncementDepositBase = AnnouncementDepositBase;
type AnnouncementDepositFactor = AnnouncementDepositFactor;
type BlockNumberProvider = frame_system::Pallet<Runtime>;
}

parameter_types! {
Expand Down Expand Up @@ -2008,6 +2010,7 @@ impl pallet_nfts::Config for Runtime {
type Helper = ();
type CreateOrigin = AsEnsureOriginWithArg<EnsureSigned<AccountId>>;
type Locker = ();
type BlockNumberProvider = frame_system::Pallet<Runtime>;
}

impl pallet_transaction_storage::Config for Runtime {
Expand Down
1 change: 1 addition & 0 deletions substrate/frame/contracts/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ impl pallet_proxy::Config for Test {
type CallHasher = BlakeTwo256;
type AnnouncementDepositBase = ConstU64<1>;
type AnnouncementDepositFactor = ConstU64<1>;
type BlockNumberProvider = frame_system::Pallet<Test>;
}

impl pallet_dummy::Config for Test {}
Expand Down
7 changes: 5 additions & 2 deletions substrate/frame/multisig/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ extern crate alloc;
use alloc::{boxed::Box, vec, vec::Vec};
use frame::{
prelude::*,
traits::{Currency, ReservableCurrency},
traits::{BlockNumberProvider, Currency, ReservableCurrency},
};
use frame_system::RawOrigin;
pub use weights::WeightInfo;
Expand Down Expand Up @@ -153,6 +153,9 @@ pub mod pallet {

/// Weight information for extrinsics in this pallet.
type WeightInfo: weights::WeightInfo;

/// Provider for the block number. Normally this is the `frame_system` pallet.
type BlockNumberProvider: BlockNumberProvider<BlockNumber = BlockNumberFor<Self>>;
}

/// The in-code storage version.
Expand Down Expand Up @@ -626,7 +629,7 @@ impl<T: Config> Pallet<T> {
/// The current `Timepoint`.
pub fn timepoint() -> Timepoint<BlockNumberFor<T>> {
Timepoint {
height: <frame_system::Pallet<T>>::block_number(),
height: T::BlockNumberProvider::current_block_number(),
index: <frame_system::Pallet<T>>::extrinsic_index().unwrap_or_default(),
}
}
Expand Down
1 change: 1 addition & 0 deletions substrate/frame/multisig/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ impl Config for Test {
type DepositFactor = ConstU64<1>;
type MaxSignatories = ConstU32<3>;
type WeightInfo = ();
type BlockNumberProvider = frame_system::Pallet<Test>;
}

use pallet_balances::Call as BalancesCall;
Expand Down
1 change: 1 addition & 0 deletions substrate/frame/nft-fractionalization/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ impl pallet_nfts::Config for Test {
type OffchainSignature = Signature;
type OffchainPublic = AccountPublic;
type WeightInfo = ();
type BlockNumberProvider = frame_system::Pallet<Test>;
pallet_nfts::runtime_benchmarks_enabled! {
type Helper = ();
}
Expand Down
9 changes: 6 additions & 3 deletions substrate/frame/nfts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ use frame_support::traits::{
};
use frame_system::Config as SystemConfig;
use sp_runtime::{
traits::{IdentifyAccount, Saturating, StaticLookup, Verify, Zero},
traits::{BlockNumberProvider, IdentifyAccount, Saturating, StaticLookup, Verify, Zero},
RuntimeDebug,
};

Expand Down Expand Up @@ -242,6 +242,9 @@ pub mod pallet {

/// Weight information for extrinsics in this pallet.
type WeightInfo: WeightInfo;

/// Provider for the block number. Normally this is the `frame_system` pallet.
type BlockNumberProvider: BlockNumberProvider<BlockNumber = BlockNumberFor<Self>>;
}

/// Details of a collection.
Expand Down Expand Up @@ -857,7 +860,7 @@ pub mod pallet {
item_config,
|collection_details, collection_config| {
let mint_settings = collection_config.mint_settings;
let now = frame_system::Pallet::<T>::block_number();
let now = T::BlockNumberProvider::current_block_number();

if let Some(start_block) = mint_settings.start_block {
ensure!(start_block <= now, Error::<T, I>::MintNotStarted);
Expand Down Expand Up @@ -1029,7 +1032,7 @@ pub mod pallet {
let deadline =
details.approvals.get(&origin).ok_or(Error::<T, I>::NoPermission)?;
if let Some(d) = deadline {
let block_number = frame_system::Pallet::<T>::block_number();
let block_number = T::BlockNumberProvider::current_block_number();
ensure!(block_number <= *d, Error::<T, I>::ApprovalExpired);
}
}
Expand Down
1 change: 1 addition & 0 deletions substrate/frame/nfts/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ impl Config for Test {
type WeightInfo = ();
#[cfg(feature = "runtime-benchmarks")]
type Helper = ();
type BlockNumberProvider = frame_system::Pallet<Test>;
}

pub(crate) fn new_test_ext() -> sp_io::TestExternalities {
Expand Down
11 changes: 7 additions & 4 deletions substrate/frame/proxy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ extern crate alloc;
use alloc::{boxed::Box, vec};
use frame::{
prelude::*,
traits::{Currency, ReservableCurrency},
traits::{BlockNumberProvider, Currency, ReservableCurrency},
};
pub use pallet::*;
pub use weights::WeightInfo;
Expand Down Expand Up @@ -163,6 +163,9 @@ pub mod pallet {
/// into a pre-existing storage value.
#[pallet::constant]
type AnnouncementDepositFactor: Get<BalanceOf<Self>>;

/// Provider for the block number. Normally this is the `frame_system` pallet.
type BlockNumberProvider: BlockNumberProvider<BlockNumber = BlockNumberFor<Self>>;
}

#[pallet::call]
Expand Down Expand Up @@ -379,7 +382,7 @@ pub mod pallet {
let announcement = Announcement {
real: real.clone(),
call_hash,
height: frame_system::Pallet::<T>::block_number(),
height: T::BlockNumberProvider::current_block_number(),
};

Announcements::<T>::try_mutate(&who, |(ref mut pending, ref mut deposit)| {
Expand Down Expand Up @@ -490,7 +493,7 @@ pub mod pallet {
let def = Self::find_proxy(&real, &delegate, force_proxy_type)?;

let call_hash = T::CallHasher::hash_of(&call);
let now = frame_system::Pallet::<T>::block_number();
let now = T::BlockNumberProvider::current_block_number();
Self::edit_announcements(&delegate, |ann| {
ann.real != real ||
ann.call_hash != call_hash ||
Expand Down Expand Up @@ -626,7 +629,7 @@ impl<T: Config> Pallet<T> {
) -> T::AccountId {
let (height, ext_index) = maybe_when.unwrap_or_else(|| {
(
frame_system::Pallet::<T>::block_number(),
T::BlockNumberProvider::current_block_number(),
frame_system::Pallet::<T>::extrinsic_index().unwrap_or_default(),
)
});
Expand Down
1 change: 1 addition & 0 deletions substrate/frame/proxy/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ impl Config for Test {
type MaxPending = ConstU32<2>;
type AnnouncementDepositBase = ConstU64<1>;
type AnnouncementDepositFactor = ConstU64<1>;
type BlockNumberProvider = frame_system::Pallet<Test>;
}

use super::{Call as ProxyCall, Event as ProxyEvent};
Expand Down
1 change: 1 addition & 0 deletions substrate/frame/revive/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,7 @@ impl pallet_proxy::Config for Test {
type CallHasher = BlakeTwo256;
type AnnouncementDepositBase = ConstU64<1>;
type AnnouncementDepositFactor = ConstU64<1>;
type BlockNumberProvider = frame_system::Pallet<Test>;
}

parameter_types! {
Expand Down
1 change: 1 addition & 0 deletions substrate/frame/safe-mode/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ impl pallet_proxy::Config for Test {
type MaxPending = ConstU32<2>;
type AnnouncementDepositBase = ConstU64<1>;
type AnnouncementDepositFactor = ConstU64<1>;
type BlockNumberProvider = frame_system::Pallet<Test>;
}

/// The calls that can always bypass safe-mode.
Expand Down
Loading