Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Add note about pallet hooks order #10023

Closed
wants to merge 2 commits into from
Closed

Add note about pallet hooks order #10023

wants to merge 2 commits into from

Conversation

apopiak
Copy link
Contributor

@apopiak apopiak commented Oct 13, 2021

Clarify Hooks execution order.

@apopiak apopiak added A0-please_review Pull request needs code review. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. D2-notlive 💤 PR contains changes in a runtime directory that is not deployed to a chain that requires an audit. labels Oct 13, 2021
/// # Note on Hooks Order
///
/// Pallet [`Hooks`] (e.g. `on_initialize`) are currently executed in *reverse* declaration order
/// (see https://github.com/paritytech/substrate/issues/6280).
Copy link
Contributor

Choose a reason for hiding this comment

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

to be more precise we should also say that frame_system is executed first, no matter its position.

Copy link
Contributor

Choose a reason for hiding this comment

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

hmm thinking again I don't know where we should write about the frame_system stuff, it is about frame-executive implementation. Maybe it worth mentioning here anyway ?

Copy link
Member

Choose a reason for hiding this comment

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

Maybe we should finally fix this? WDYT @thiolliere?

Copy link
Contributor

Choose a reason for hiding this comment

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

So on_initialize should be executed in declaration order, while for on_finalize I would actually expect reverse declaration order, right?. Basically mimicing PL constructor / destructor semantics.

Copy link
Member

Choose a reason for hiding this comment

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

Not really.

Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't such an order make sense in order to allow one pallet to depend on another pallet, including potential state changes? If not, why not?

Copy link
Contributor

Choose a reason for hiding this comment

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

yes I opened the fix #10043
about on_finalize in reverse order I don't know, I feel like we currently never had the need, and also that if such needs emerge then we should probably introduce a more fine-grained configuration of order of hooks.

@stale
Copy link

stale bot commented Nov 17, 2021

Hey, is anyone still working on this? Due to the inactivity this issue has been automatically marked as stale. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the A5-stale Pull request did not receive any updates in a long time. No review needed at this stage. Close it. label Nov 17, 2021
@kianenigma
Copy link
Contributor

Given that the main fix PR is already open and has 1 approve, we can skip this. Reopne if you think otherwise @apopiak

@kianenigma kianenigma closed this Nov 18, 2021
@bkchr bkchr deleted the apopiak-hooks-order branch November 18, 2021 10:58
@apopiak
Copy link
Contributor Author

apopiak commented Nov 18, 2021

Though we'll need to document the change.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-please_review Pull request needs code review. A5-stale Pull request did not receive any updates in a long time. No review needed at this stage. Close it. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. D2-notlive 💤 PR contains changes in a runtime directory that is not deployed to a chain that requires an audit.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants