-
Notifications
You must be signed in to change notification settings - Fork 2.6k
allow to write pre and post runtime upgrade in pallet macro #8194
Conversation
@@ -154,6 +154,7 @@ std = [ | |||
"pallet-society/std", | |||
"pallet-recovery/std", | |||
"pallet-vesting/std", | |||
"frame-try-runtime/std", |
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 also added std here in order to be able to compile the crate with try-runtime and std.
(cargo check -p node-runtime --features try-runtime
)
Otherwise it fails.
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.
The problem with that is that Cargo currently doesn't support optional dependencies and features.
Not sure how this works 🤷
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.
AFAICT this will pull frame-try-runtime crate everytime std is activated, which is not what we want, but is not bothering too much either.
EDIT: and we do same for frame-benchmarking.
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 think given the same situation with benchmark, let's move on and let it be, but a refactor issue for it will be appreciated. Maybe we can do it nicer someday.
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.
yes I think there is plan to support it with something like "frame-try-runtime?/std"
Ok then I'll merge and open an issue: #8202
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.
Besides the one comment it looks okay.
@@ -154,6 +154,7 @@ std = [ | |||
"pallet-society/std", | |||
"pallet-recovery/std", | |||
"pallet-vesting/std", | |||
"frame-try-runtime/std", |
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.
The problem with that is that Cargo currently doesn't support optional dependencies and features.
Not sure how this works 🤷
I removed the default implementation of
pre_upgrade
andpost_upgrade
onOnRuntimeUpgrade
.Otherwise if node-runtime forget to activate the
my-pallet/try-runtime
then the pre_upgrade and post_upgrade of the pallet would simply be ignored without warning. Instead now it fails to compile saying pre_upgrade and post_upgrade needs to be implemented.But the error is:
So it is not super explicit (but still better than silently ignore it).
NOTE: the PR doesn't add the feature to decl_module, we can do in another one if we want.