Update Pallet Referenda to support Block Number Provider#6338
Conversation
…da_block_number_provider
…da_block_number_provider
|
can you help review this again @gui1117 |
bkchr
left a comment
There was a problem hiding this comment.
Could you also provide a migration that migrates from one block number type to another? Especially take into account the different block times.
|
@dharjeezy this is nearly done, will you take it over the finish line? |
i have updated the PR with the migration written. @acatangiu @bkchr |
substrate/frame/referenda/src/lib.rs
Outdated
| /// The preimage provider. | ||
| type Preimages: QueryPreimage<H = Self::Hashing> + StorePreimage; | ||
|
|
||
| /// Provider for the block number. Normally this is the `frame_system` pallet. |
There was a problem hiding this comment.
| /// Provider for the block number. Normally this is the `frame_system` pallet. | |
| /// Provider for the block number. | |
| /// | |
| /// Normally this is the `frame_system` pallet. |
| } | ||
| } | ||
|
|
||
| pub mod v2 { |
There was a problem hiding this comment.
| pub mod v2 { | |
| /// Migration for when changing the block number provider. | |
| pub mod switch_block_number_provider { |
| use super::*; | ||
|
|
||
| /// The log target. | ||
| const TARGET: &'static str = "runtime::referenda::migration::v2"; |
There was a problem hiding this comment.
| const TARGET: &'static str = "runtime::referenda::migration::v2"; | |
| const TARGET: &'static str = "runtime::referenda::migration::change_block_number_provider"; |
| pub trait BlockToRelayHeightConversion<T: Config<I>, I: 'static> { | ||
| fn convert_block_number_to_relay_height( | ||
| block_number: SystemBlockNumberFor<T>, | ||
| ) -> BlockNumberFor<T, I>; | ||
| } |
There was a problem hiding this comment.
| pub trait BlockToRelayHeightConversion<T: Config<I>, I: 'static> { | |
| fn convert_block_number_to_relay_height( | |
| block_number: SystemBlockNumberFor<T>, | |
| ) -> BlockNumberFor<T, I>; | |
| } | |
| /// Convert from one to another block number provider/type. | |
| pub trait BlockNumberConversion<Old, New> { | |
| /// Convert the `old` block number type to the new block number type. | |
| /// | |
| /// Any changes in the rate of blocks need to be taken into account. | |
| fn convert_block_number( | |
| block_number: Old, | |
| ) -> New; | |
| } |
| if on_chain_version != 1 { | ||
| log::warn!(target: TARGET, "skipping migration from v1 to v2."); | ||
| return weight | ||
| } |
There was a problem hiding this comment.
| if on_chain_version != 1 { | |
| log::warn!(target: TARGET, "skipping migration from v1 to v2."); | |
| return weight | |
| } |
Please add a comment to the migration that this is not guarded.
| } | ||
|
|
||
| /// Transforms SystemBlockNumberFor<T> to BlockNumberFor<T,I> | ||
| pub struct MigrateV1ToV2<BlockConversion, T, I = ()>( |
There was a problem hiding this comment.
IMO this should probably just be a standalone function. Downstream people need to write their own migration with some custom guarding or whatever to ensure that they don't apply it multiple times.
|
|
||
| impl BlockNumberConversion<SystemBlockNumberFor<T>, BlockNumberFor<T, ()>> for MockBlockConverter { | ||
| fn convert_block_number(block_number: SystemBlockNumberFor<T>) -> BlockNumberFor<T, ()> { | ||
| block_number as u64 |
There was a problem hiding this comment.
Better to make it not constant ? add a delay like block_number + 10
| pub struct MockBlockConverter; | ||
|
|
||
| impl BlockNumberConversion<SystemBlockNumberFor<T>, BlockNumberFor<T, ()>> for MockBlockConverter { | ||
| fn convert_block_number(block_number: SystemBlockNumberFor<T>) -> BlockNumberFor<T, ()> { |
There was a problem hiding this comment.
In the mock both are System but I think it is ok.
|
CI is failing because some unused variable |
| doc: | ||
| - audience: Runtime Dev | ||
| description: | | ||
| This PR makes the referenda pallet uses the relay chain as a block provider for a parachain on a regular schedule. |
There was a problem hiding this comment.
not sure what you mean with this sentence. the PR provides a new configuration
|
@dharjeezy please check this comment - #6297 (comment) |
f08bf1a
|
/tip small |
|
Only members of paritytech/tip-bot-approvers have permission to request the creation of the tip referendum from the bot. However, you can create the tip referendum yourself using Polkassembly or PolkadotJS Apps. |
|
/tip medium |
|
@ggwpez A referendum for a medium (80 DOT) tip was successfully submitted for @dharjeezy (12GyGD3QhT4i2JJpNzvMf96sxxBLWymz4RdGCxRH5Rj5agKW on polkadot). |
|
The referendum has appeared on Polkassembly. |
…6338) This PR introduces BlockNumberProvider config for the referenda pallet. closes part of paritytech#6297 Polkadot address: 12GyGD3QhT4i2JJpNzvMf96sxxBLWymz4RdGCxRH5Rj5agKW --------- Co-authored-by: muharem <ismailov.m.h@gmail.com>
## Polkadot upgrade 2503 In this PR, we upgrade form Polkadot SDK 2412 to Polkadot SDK 2503. In order to upgrade the SDK we need to upgrade some dependencies : StorageHub and frontier simultaneously. ## What changes ### Trivial changes * paritytech/polkadot-sdk#7634 -> The new trait is required in all the pallets using scale encoding. * paritytech/polkadot-sdk#7043 -> Remove deprecated `sp-std` and replace with `alloc` or `core`. * paritytech/polkadot-sdk#6140 -> Accurate weight reclaim with frame_system::WeightReclaim ### Breaking changes * paritytech/polkadot-sdk#2072 -> There is a change in `pallet-referenda`. Now, the tracks are retrieved as a list of `Track`s. Also, the names of the tracks might have some trailing null values (`\0`). This means display representation of the tracks' names must be sanitized. * paritytech/polkadot-sdk#5723 -> 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. (Not entirely sure it is breaking as it is being marked as backward compatible). * paritytech/polkadot-sdk#6338 -> Update Referenda to Support Block Number Provider ### Notable changes * paritytech/polkadot-sdk#5703 -> Not changes required in the codebase but impact fastSync mode. Should improve testing. * paritytech/polkadot-sdk#5842 -> Removes `libp2p` types in authority-discovery, and replace them with network backend agnostic types from `sc-network-types`. The `sc-network` interface is therefore updated accordingly. ## What changes in Frontier * polkadot-evm/frontier#1693 -> Add support for EIP 7702 which has been enable with Pectra. This EIP add a new field `AuthorizationList` in Ethereum transaction. Changes example : ```rust #[test] fn validate_transaction_fails_on_filtered_call() { ... pallet_evm::Call::<Runtime>::call { source: H160::default(), target: H160::default(), input: Vec::new(), value: sp_core::U256::zero(), gas_limit: 21000, max_fee_per_gas: sp_core::U256::zero(), max_priority_fee_per_gas: Some(sp_core::U256::zero()), nonce: None, access_list: Vec::new(), authorization_list: Vec::new(), } .into(), ``` ##⚠️ Breaking Changes⚠️ * Upgrade to Stirage hub v0.5.1 * Support for Ethereum latest upgrade (txs now have the `authoriation_list` for support EIP 7702) --------- Co-authored-by: Steve Degosserie <723552+stiiifff@users.noreply.github.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>

This PR introduces BlockNumberProvider config for the referenda pallet.
closes part of #6297
Polkadot address: 12GyGD3QhT4i2JJpNzvMf96sxxBLWymz4RdGCxRH5Rj5agKW