Correct state after failed v6 migration

Democracy
2yrs ago
2
Executed

Due to a bug in the v6 VaultRegistry migration all Vaults now have an incorrect number of issued_tokens which puts many below the liquidation threshold. Fortunately, the stake stored in VaultRewards is still correct which prevents liquidation since that number is smaller than the value trying to be liquidated.

This fix manually forces the VaultRegistry to the correct state which was determined by querying the storage prior to runtime upgrade and applying the expected migration function. More details to follow in our post-mortem.

Request for TC fast-track to minimize system downtime.

Edited
Reply
Up
Share
Votes
AyePassing thresholdNay
100%0%
Aye
61vKINT
Nay
0vKINT
Turnout
61vKINT
Electorate
0vKINT
Passed
How Kintsugi Governance Works.
Call
Metadata
Timeline3
Votes Bubble
Comments

How would a paranoid person check that the image above does what you say it does?
After the fact would be easy, I guess, but before?

Reply
Up

The call was generated with the following code:

import { ApiPromise, WsProvider } from '@polkadot/api';

async function main() {
    const wsProvider = new WsProvider('wss://api-kusama.interlay.io/parachain');
    const api = await ApiPromise.create({ provider: wsProvider });

    const preUpgradeApi = await api.at("0x3a4293ca2b4d24ea852b9510059cb8769e8321b3051bb690aef2703ebc74a65e");

    const allVaults = await preUpgradeApi.query.vaultRegistry.vaults.entries();
    const toSet = allVaults.map(([key, vault]) => {
        let vaultJSON: any = vault.toJSON();
        delete vaultJSON.wallet;
        if (vaultJSON.status.committedTheft === null) {
            vaultJSON.status = { liquidated: null };
        }
        const codec = api.createType("VaultRegistryVault", vaultJSON);

        return [key, codec.toHex()];
    });
    console.log(api.tx.system.setStorage(toSet).method.hash.toString());

    await api.disconnect();
}

main();
Reply
Up