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

Closed
Tracked by #2087
kulikthebird opened this issue Apr 18, 2024 · 1 comment · Fixed by #2212, CosmWasm/wasmd#1966 or CosmWasm/wasmvm#556
Assignees
Milestone

Comments

@kulikthebird
Copy link
Contributor

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.

Part 1: 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.

Part 2: 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>;
@webmaster128
Copy link
Member

I just split this ticket in Part1 and part 2. Part1 is already done in the latest release (CosmWasm 2.1 and wasmd). What is missing now is the information about the old and new migrate version in the migrate entry point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment