-
Notifications
You must be signed in to change notification settings - Fork 53
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
Implement pallet_registrar hooks #325
Conversation
Alows to execute code on register and deregsiter Also, change the pausing mechanism, now we have a separate `Paused` storage item. This was needed because otherwise pausing and unpausing could trigger hooks when it should not.
Coverage Report@@ Coverage Diff @@
## master tomasz-registrar-hooks +/- ##
==========================================================
+ Coverage 71.37% 71.39% +0.02%
+ Files 86 89 +3
+ Lines 19709 19791 +82
==========================================================
+ Hits 14067 14128 +61
+ Misses 5642 5663 +21
|
And some pr comments
Ideally I would like to see tests that capture the following cases:
|
pallets/registrar/src/lib.rs
Outdated
#[pallet::hooks] | ||
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> { | ||
#[cfg(feature = "std")] | ||
fn integrity_test() { |
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.
fn integrity_test() { | |
fn try_state(_block_number: u32) { |
The integrity_test
hook doesn't have access to the storage, despite docs saying otherwise.
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.
LGTM
Allows to execute code on container chain register and deregister. This PR only includes the deregister hooks:
These hooks are executed 2 sessions after calling deregister, which is when the container chain won't have any collators anymore. Unless the para id was never marked as valid_for_collating, in that case the hooks are executed immediately.
Also, change the pausing mechanism. Add a new extrinsic to unpause:
unpause_container_chain
. Previouslymark_valid_as_collating
was used to unpause, now that won't work anymore. This change was needed because otherwise pausing and unpausing could trigger the implemented hooks when it should not, so now paused container chains are stored in a new storage itemPaused
instead of being inPendingVerification
. Container chains that were paused before this PR will need to be unpaused usingmark_valid_for_collating
.