Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conditional migrate call with extra MigrateInfo argument after contract update #2117

Open
Tracked by #2087
kulikthebird opened this issue Apr 18, 2024 · 0 comments
Open
Tracked by #2087

Comments

@kulikthebird
Copy link

kulikthebird commented Apr 18, 2024

The result of this task is an implementation of the conditional migrate entry point calling after a contract's code update on the blockchain. Currently migrate is called every time the contract's binary is updated on the chain.

Procedure

The following procedure should be implemented:

  1. Get the version of the on-chain state for the given contract by checking the Wasm binary before the code upgrade.
  2. Get the state version supported by the new contract's binary (from the Wasm binary code).
  3. Call migrate entry point if:
  • at least one of the two versions is not provided, or
  • both versions are provided and are different.

Migrate method

The migrate method needs to have a new parameter provided: info: MigrateInfo. In order to keep the backward compatibility, the VM should check the arity of the method implemented by the contract. If the arity is greater than 3, the following migrate signature should be assumed:

pub fn migrate(deps: DepsMut, env: Env, info: MigrateInfo, msg: MigrateMsg) -> StdResult<Response>;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants