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

Update pallet-nis to support Block Number Provider #6764

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

Conversation

Doordashcon
Copy link
Contributor

@Doordashcon Doordashcon commented Dec 4, 2024

Part of #6297

Review Notes

  • Default Bound Requirement:ReceiptRecord & SummaryRecord types used in the Receipts and Summary storage items respectively, now adopts T::BlockNumberProvider with the condition that concrete types implement Default

@Doordashcon Doordashcon marked this pull request as ready for review December 8, 2024 16:34
@Doordashcon Doordashcon requested a review from a team as a code owner December 8, 2024 16:34
@Doordashcon
Copy link
Contributor Author

Hello @gui1117, please review

@@ -312,6 +317,8 @@ pub mod pallet {
#[pallet::constant]
type ThawThrottle: Get<(Perquintill, BlockNumberFor<Self>)>;

type BlockNumberProvider: BlockNumberProvider<BlockNumber: Default>;
Copy link
Member

Choose a reason for hiding this comment

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

Missing docs.

@@ -693,7 +702,7 @@ pub mod pallet {
let (owner, mut on_hold) = receipt.owner.ok_or(Error::<T>::AlreadyCommunal)?;
ensure!(owner == who, Error::<T>::NotOwner);

let now = frame_system::Pallet::<T>::block_number();
let now = T::BlockNumberProvider::current_block_number();
Copy link
Member

Choose a reason for hiding this comment

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

Misses a migration for the Receipts to change the expiry to the "new clock". (Not required when switched to System as block number provider.

Copy link
Contributor

@gui1117 gui1117 Dec 9, 2024

Choose a reason for hiding this comment

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

Most of those PR is for pallet in the relay chain to go to a parachain without requiring migration.

But in the wider scope I can see parachain could also make use of the relay chain block number provider when they are going more agile and skip some blocks.
In this case a migration would help indeed. We can just provide a function helper to do this migration, no need for storage versioning. Because parachain could change the configuration of the block number whenever they want, so unrelated to the version of the pallet.

@kianenigma do you think we should provide the block number migration function for all such pallets? I think some approved one don't have it.
Or should it be done on-demand when people ask for it?

Copy link
Contributor

Choose a reason for hiding this comment

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

I would not include a migration for the time being, assuming the PR and code-doc are super clear under which circumstances you do, and do not need a migration.

Copy link
Member

@bkchr bkchr Dec 9, 2024

Choose a reason for hiding this comment

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

But in the wider scope I can see parachain could also make use of the relay chain block number provider when they are going more agile and skip some blocks.

This is the entire point of this exercise. Otherwise it is quite useless. Not sure why we approve prs without a migration. Also requiring everyone to write their own migration is a little bit stupid. Especially as by just "reading the docs" it will not be that easy. Block numbers are stored internally in some structures and may not be that obvious for others to find them etc. This will just end up in a mess, if people are forced to write their own migrations.

);
Nis::on_initialize(
<Test as pallet_nis::Config>::BlockNumberProvider::current_block_number(),
);
Copy link
Contributor

Choose a reason for hiding this comment

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

on_finalize/on_initialize is taking system block number. Here is works because both pallet_nis block number and system block number are the same.
I think the code is cleaner if we use system block number same as before in this test no?

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.

4 participants