-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Change the Config of the MaxRococoNum Slot from a Constant to a Storage function #7217
Change the Config of the MaxRococoNum Slot from a Constant to a Storage function #7217
Conversation
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.
Left a comment, overall looking good.
fn on_runtime_upgrade() -> frame_support::weights::Weight { | ||
migration::migrate_to_v2::<T>() | ||
} |
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.
We should add the migration in the runtime, like these
Just as a good practice to follow, so it is easier to spot which migrations will get executed in the next upgrade.
This would also work, but the discoverability of this migration happening for other devs is worse.
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.
Done!
FYI, |
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.
You can also just change this
pub const MaxPermanentSlots: u32 = 100;
pub const MaxTemporarySlots: u32 = 100;
to this
pub storage MaxPermanentSlots: u32 = 100;
pub storage MaxTemporarySlots: u32 = 100;
since you require root any way. It is a two line change. Root can then use System::set_storage
to poke them.
But i guess your approach is less hacky.
Thanks for the feedback. Is great to know this approach, but as you said it looks more hacky. I believe it can be a bit confusing to see the 100 as a magic number in the Config if it can be changed in the storage with the |
@AlexD10S Command |
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, thanks!
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.
Looking good! Just need to tweak the migration and I left some other minor comments on things you may choose to address.
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
bot merge |
From the PR: Change the Config of the MaxRococoNum Slot from a Constant to a Storage function
Revamp the pallet to get MaxPermanentSlots and MaxTemporarySlots out of the Config trait of assigned_slots pallet.
And add two extrinsics so Root can modify these values without the need of a runtime upgrade.