-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Make sure pallet versions are set at genesis #7451
Conversation
This pr ensures that pallet versions are also set at genesis. It does this by hooking into the runtime `GenesisConfig` which means that it will only work when the storage is setup using this genesis config. So, the version will not be set in pallet local tests. However, I think this isn't such a problem. The genesis config will call `on_genesis` on all pallets. This function comes from the new trait `OnGenesis`. Currently the user is not able to provide any custom implementation of this trait. Besides that it also implements `Clone` and `Copy` for the pallet version struct. This pr also moves the macro for generating the runtime genesis config to `frame-support` as most of the other FRAME related macros.
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.
looks good to me
In the sense that they would have to implement the trait manually and cannot just define an |
The trait is always auto implemented, but they can write |
Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>
|
We already have |
The pallet genesis config is optional, this is why it can't be used here |
|
ok. but there is no need to store pallet version if it doesn’t have storage? at least you won’t have the migration issue if there isn’t anything to migrate |
|
But you can have a storage and no genesis config
|
As said in the original issue, its not only about storage migrations. It's also about the version of the pallet. |
This pr ensures that pallet versions are also set at genesis. It does
this by hooking into the runtime
GenesisConfigwhich means that itwill only work when the storage is setup using this genesis config. So,
the version will not be set in pallet local tests. However, I think this
isn't such a problem. The genesis config will call
on_genesison allpallets. This function comes from the new trait
OnGenesis. Currentlythe user is not able to provide any custom implementation of this trait.
Besides that it also implements
CloneandCopyfor the palletversion struct.
This pr also moves the macro for generating the runtime genesis config
to
frame-supportas most of the other FRAME related macros.