Versioned state for on-chain upgrades #234
Stebalien
started this conversation in
Enhancements - Technical
Replies: 1 comment 1 reply
-
This should probably be in the discussion forum rather than an issue, following #215 How do other systems (e.g. contracts on Ethereum) handle migration? There must be significant prior art here. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Currently, every time an on-chain data structure changes, a state migration needs to be run to migrate all state from the old format to the new format.
There's a pretty simple solution: version the state. However, there are two options:
Versioned Actor State
This is the cleanest solution as migrations are atomic. Unfortunately, this would still force us to eventually migrate the entire actor's state as a whole, and that can get pretty expensive (e.g., if we need to migrate all sector infos).
Implementation wise, we'd:
Versioned Objects
At the cost of one extra byte per object (where our smallest objects are ~100bytes), we can prepend a version field to every object. Then:
The downside is:
The upside is that state never actually needs to be migrated. It'll just be transformed on read. Assuming these transforms are light weight (which is the usual case), this should add very little overhead.
Unfortunately, if we change the HAMT/AMT implementations, this solution won't be enough as HAMTs/AMTs are composed of multiple objects. However:
Beta Was this translation helpful? Give feedback.
All reactions