dao-contracts
dao-contracts copied to clipboard
Devise a solution for large gas-inefficient state migrations
For a contract with a lot of proposals, for example, where the data model for the proposal struct has changed with a new code ID, how can we devise a solution to migrate the contract?
Would be useful to find prior art for this scenario if it exists.
Some ideas were discussed here: https://discord.com/channels/895922260047720449/935733580938768444/999011724659273779
2 main options:
- Do the state migration over multiple transactions (not ideal, kind of clunky and possibly infeasible due to the way that migrations work based on updating the contract's code ID)
- Do a 'lazy' migration, ie when deserializing a value from storage, try to backfit it into multiple versions of the struct, then update the struct. This is the preferred option and it can also be extended to become a more generic module where we can specify different valid types for a given state item
Before this work we should first verify whether state migrations are warranting this, ie will be out of gas