Fixed logic of the storage migration to triple reference counting.#10337
Conversation
|
Not sure whether it is relevant to mention here, but I signed the CLA, and yet, it does not seem to update that status. I cannot sign a second time, since the link does not work anymore. |
I think the problem is that you created the commit with an email that isn't linked to your github account. So, the tool can not connect you as a user to the commit. Could you please force push with a different email for the commit? |
…e previous behaviour made it impossible for any chain not already upgraded to dual reference counting to upgrade the runtime.
kianenigma
left a comment
There was a problem hiding this comment.
Sorry for blocking, the code is correct but at least make a step toward the right direction (#10308 #8713). The correct thing here is to make functions migrate_from_single_to_triple_ref_count and migrate_from_dual_to_triple_ref_count standalone and remove any automatic migration in on_runtime_upgrade. Then, in your own runtime file you can pass either of the above two functions to type Executive to do your upgrade.
|
Thanks for pointing this out! I think it totally makes sense to require that the migration logic can get controlled fully at runtime level. I was unaware of those discussions and It just took me a bit of time to grok all this also because I am unfamiliar with substrate. I tried to stick to the example, so I hope I am not misusing anything. I have tentatively implemented the changes you asked for, but unfortunately, I am unsure about the logic, and I have not been able to find out how to write tests for those. I would need help or pointers about how to do this. For Edgeware, we can try to see if that works during the testnet phase, but I guess there is a cleaner and more reliable way that just iterating version accross all testnet nodes to test and debug this. One issue I have is that there is now a storage variable that flags whether the migration to triple reference counting has been performed, but it seems to be a renaming of a previous variable that flagged whether the status was upgraded to dual reference counting. Does it mean that it theory I could still fetch out the previous storage flag using |
+Removed the specific migration .anciallaries from the frame-system pallet level. +Introducted a new module that hosts self-contained ancillary functions and logic to perform the storage migration. The current logic attempts to infer the state of the storage based on whether or not a given migration can be conducted.
I think it is better to just let the user call the correct function from the on_runtime_upgrade implementation when declaring the runtime. |
| /// (u32) to triple reference counting. | ||
| /// | ||
| /// If unsure about the behaviour, the standalone functions below have to be preferred. | ||
| pub fn apply<T: V2ToV3>() -> Weight { |
There was a problem hiding this comment.
personally I would just force user to use the correct migration explicitly.
Also iterating on storage is very heavy so I'm not sure it is good for any chain to try multiple migration.
There was a problem hiding this comment.
Right. I removed applied and update the booleans, return weight, etc. on each individual function instead. Is there a reason why the weight should be maxvalue? I saw it done this way everywhere, but I don't understand the logic behind this. Is it just because migrations have a massive cost so we always assume maximum weight regardless of what is done?
There was a problem hiding this comment.
Is it just because migrations have a massive cost so we always assume maximum weight regardless of what is done?
Yes this was the assumption, but it is a bad practice, because some chain must not go beyond max_block (like parachains), in those case having the exact weight is important.
Would you then suggest to remove apply overall and then maybe add weights in each of them? |
Yes, I personally think we can remove |
…ed during the runtime implementation of the trait V2ToV3. + Removed apply function. + Made the individual translation function self-sufficient.
|
/tip small |
|
Please fix the following problems before calling the tip bot again:
|
|
bot merge |
|
@remzrn you can still get a tip, just update your first post in this PR |
…aritytech#10337) * Fixed logic of the storage migration to triple reference counting. The previous behaviour made it impossible for any chain not already upgraded to dual reference counting to upgrade the runtime. * +Removed the on_runtime_upgrade() function from frame-system. +Removed the specific migration .anciallaries from the frame-system pallet level. +Introducted a new module that hosts self-contained ancillary functions and logic to perform the storage migration. The current logic attempts to infer the state of the storage based on whether or not a given migration can be conducted. * Formatting. * + Removed specific AccountData struct. AccountData must now be provided during the runtime implementation of the trait V2ToV3. + Removed apply function. + Made the individual translation function self-sufficient. * + Removed unused decorators.
…aritytech#10337) * Fixed logic of the storage migration to triple reference counting. The previous behaviour made it impossible for any chain not already upgraded to dual reference counting to upgrade the runtime. * +Removed the on_runtime_upgrade() function from frame-system. +Removed the specific migration .anciallaries from the frame-system pallet level. +Introducted a new module that hosts self-contained ancillary functions and logic to perform the storage migration. The current logic attempts to infer the state of the storage based on whether or not a given migration can be conducted. * Formatting. * + Removed specific AccountData struct. AccountData must now be provided during the runtime implementation of the trait V2ToV3. + Removed apply function. + Made the individual translation function self-sufficient. * + Removed unused decorators.
The previous behaviour made it impossible for any chain not already upgraded to dual reference counting to upgrade the runtime.
This proposed change is minimal, but attempts to fix this logical issue for runtime upgrades. Currently, migrations from single or u8 reference counting do not seem to be possible even with custom migrations, due to an enforced behaviour of the pallet migration. I tried to detail examples in the issue.
fixes #10336