-
Notifications
You must be signed in to change notification settings - Fork 754
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update Pallet Referenda to support Block Number Provider #6338
base: master
Are you sure you want to change the base?
Update Pallet Referenda to support Block Number Provider #6338
Conversation
substrate/frame/referenda/src/lib.rs
Outdated
@@ -239,6 +240,9 @@ pub mod pallet { | |||
|
|||
/// The preimage provider. | |||
type Preimages: QueryPreimage<H = Self::Hashing> + StorePreimage; | |||
|
|||
/// Provider for the block number. Normally this is the `frame_system` pallet. | |||
type BlockNumberProvider: BlockNumberProvider<BlockNumber = BlockNumberFor<Self>>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we force the block number to be the one in system?
If the block number provider is RelayChainDataProvider
, then the block number can be different.
It would be more clean to keep it generic here.
Then we should use a new type:
type BlockNumberFor<T> = <<Self as Config>::BlockNumberProvider as BlockNumberProvider>::BlockNumber;
type BlockNumberProvider: BlockNumberProvider<BlockNumber = BlockNumberFor<Self>>; | |
type BlockNumberProvider: BlockNumberProvider; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, we should not require the same block number type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gui1117 shouldn't it be
pub type BlockNumberFor<T, I> = <<T as Config<I>>::BlockNumberProvider as BlockNumberProvider>::BlockNumber;
since the referenda pallet is an Instantiable one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, also we can name it ProvidedBlockNumberFor
to avoid conflict with system type alias.
…da_block_number_provider
…da_block_number_provider
can you help review this again @gui1117 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you also provide a migration that migrates from one block number type to another? Especially take into account the different block times.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good to me.
substrate/frame/referenda/src/lib.rs
Outdated
use super::*; | ||
use frame_support::{pallet_prelude::*, traits::EnsureOriginWithArg}; | ||
use frame_system::pallet_prelude::*; | ||
use frame_system::pallet_prelude::{OriginFor, BlockNumberFor as SystemBlockNumberFor, ensure_root, ensure_signed_or_root, ensure_signed}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that this could be replaced with:
use super::{*, BlockNumberFor};
use frame_support::{pallet_prelude::*, traits::EnsureOriginWithArg};
use frame_system::pallet_prelude::{*, BlockNumberFor as SystemBlockNumberFor};
But as you prefer.
This PR makes the referenda pallet uses the relay chain as a block provider for a parachain on a regular schedule. | ||
To migrate existing referenda implementations, simply add `type BlockNumberProvider = System` to have the same behavior as before. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't force the referenda pallet to use the relay chain block provider.
This PR makes the referenda pallet uses the relay chain as a block provider for a parachain on a regular schedule. | |
To migrate existing referenda implementations, simply add `type BlockNumberProvider = System` to have the same behavior as before. | |
This PR makes the block number provider used in the referenda pallet configurable. Before this PR, referenda pallet always used the system block number, with this PR some runtime can opt to use the relay chain block number instead. | |
To migrate existing referenda implementations, simply add `type BlockNumberProvider = System` to have the same behavior as before. |
This PR introduces BlockNumberProvider config for the referenda pallet.
closes part of #6297
Polkadot address: 12GyGD3QhT4i2JJpNzvMf96sxxBLWymz4RdGCxRH5Rj5agKW