Skip to content
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

Add block provider to core-fellowship #6978

Open
wants to merge 28 commits into
base: master
Choose a base branch
from

Conversation

PolkadotDom
Copy link
Contributor

@PolkadotDom PolkadotDom commented Dec 21, 2024

Following #3617, core fellowship and related code is to be made async backing friendly. This PR adds the block number provider config parameter to pallet-core-fellowship.

In addition it

  • Adds the migration code for those teams who want to transition and need it
  • Applies the migration on Westend
  • Shuffles some pre-existing core-fellowship migration code for ergonomics
  • Adds a bound to the BlockNumberProvider sp_runtime trait
  • Fixes a couple spelling & syntax issues

TODO:
Once Westend is updated I will write the migration for polkadot collectives.

Notes:
@xlc This will be my first migration and overall first PR with a bit more frame complexity, so please review carefully!
I've tested the migration for Westend using try-runtime. Unsure what the standard process is outside of that if any.
Also, the migration assumes consistent block times for westend and westend collectives, which is not the case, but I imagine this is not so much a concern and will largely be ameliorated when writing for polkadot collectives. Lastly, not confident in the runtime spec_version bump, that was a bit opaque to me, if you want to take a look.

Copy link

Sorry, only members of the organization paritytech members can run commands.

Copy link
Contributor

@gui1117 gui1117 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still have to review the migration

@@ -1,6 +1,6 @@
[package]
name = "collectives-westend-runtime"
version = "3.0.0"
version = "3.1.0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know exactly the process for versioning, but AFAIK we don't bump crate versions on master, instead we provide the prdoc, and from prdoc information crate versions will be changed on release

@@ -1,6 +1,6 @@
[package]
name = "sp-runtime"
version = "31.0.1"
version = "32.0.0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similarly I don't think we need to bump the version in this PR.

This PR adds a parameter 'BlockNumberProvider' to the pallet-core-fellowship
config such that a block provider can be set for use in the pallet. This would
usually be the local system pallet or the appropriate relay chain. Previously
it defaulted to the local system pallet.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

westend is a testnet, should we notify Runtime User that westend collective fellowship pallet migrated from using parachain block number to relay chain block number?

(More generally I wonder how easy it is for tools to differentiate between both types. Some tools have to be careful and get the correct meaning for the block number.)

local: CoreFellowshipLocalBlockNumber,
) -> CoreFellowshipNewBlockNumber {
let block_number = System::block_number();
let local_duration = block_number.saturating_sub(local);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if local represent a future block number, then the saturation will happen.
In the trait description it is not specified that local must be past.
I guess it works in our case because the pallet don't store any future block number.

Maybe we can handle the general case with a comparison if local<block_number ....
All similar migration will make use of a similar trait, and other pallet might store a future block number.

Copy link
Contributor

@gui1117 gui1117 left a 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, once the comments are resolved

where
BlockNumberConverter: ConvertBlockNumber<LocalBlockNumberFor<T>, NewBlockNumberFor<T, I>>,
{
fn on_runtime_upgrade() -> frame_support::weights::Weight {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could count the number of member in pre_upgrade and then ensure the number of member is same in post_upgrade
And same query if there is a value in params in pre_upgrade and then ensure there is a value in params in post_upgrade.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants