-
Notifications
You must be signed in to change notification settings - Fork 726
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
base: master
Are you sure you want to change the base?
Conversation
Hello @gui1117, please review |
@@ -312,6 +317,8 @@ pub mod pallet { | |||
#[pallet::constant] | |||
type ThawThrottle: Get<(Perquintill, BlockNumberFor<Self>)>; | |||
|
|||
type BlockNumberProvider: BlockNumberProvider<BlockNumber: Default>; |
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.
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(); |
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.
Misses a migration for the Receipts
to change the expiry
to the "new clock". (Not required when switched to System
as block number provider.
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.
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?
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.
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.
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.
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(), | ||
); |
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.
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?
Part of #6297
Review Notes
ReceiptRecord
&SummaryRecord
types used in theReceipts
andSummary
storage items respectively, now adoptsT::BlockNumberProvider
with the condition that concrete types implementDefault