Closed webmaster128 closed 3 days ago
In https://github.com/CosmWasm/cosmwasm/issues/2087 we discuss a more powerful solution that makes it easier to migrate from various old version of the contract
Done in #1924. With that if two contracts have the same migrate version, the migrate entry point is not called
When CosmWasm migrations were designed, we had 1 instance – 1 dev team in mind. The whole system assumes a small number of instances to handle. Recently we learned that more and more use cases are poping up in which many instances of a contract are created, dozens of pools, hundreds or DAOs, thousands of accounts. Having to send a
MsgMigrateContract
cand calling the contract for each message is gas intense and hard to manage.While this ticket does no solve the full problem at once, it is a first step and actionable. The idea is this: not every migration needs a state change. Often times state changes can be done lazily or are not required at all. In those cases we can avoid calling the
migrate
entry point of the contract. Just swap out the code and call it a day.This means not executing those lines: https://github.com/CosmWasm/wasmd/blob/7ea00e2ea858ed599141e322bd68171998a3259a/x/wasm/keeper/keeper.go#L475-L479
In such cases the
msg
field ofMsgMigrateContract
becomes optional.If a call to the
migrate
entry point is needed or not should be decided by the new code. There the contract author can decide if the state needs to change or not. Luckily we haveEntrypoints
inAnalysisReport
and can implement the following logic:migrate
entry point, requiremsg
to be non-empty JSON (current logic)msg
to be emptyThis avoids situations in which an expected msg is missing or a provided msg is ignored.