Skip to content

Commit

Permalink
add before and after hooks to frankenstein
Browse files Browse the repository at this point in the history
  • Loading branch information
Maksandre committed Jun 9, 2023
1 parent e38520f commit cd2a1cb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ RUST_TOOLCHAIN=nightly-2022-11-15
POLKADOT_LAUNCH_BRANCH=unique-network
RELAY_CHAIN_TYPE=westend
CHAINQL=v0.4.1
DESTINATION_SPEC_VERSION=v942057

POLKADOT_MAINNET_BRANCH=release-v0.9.37
STATEMINT_BUILD_BRANCH=release-parachains-v9370
Expand Down
5 changes: 5 additions & 0 deletions tests/src/util/frankenstein.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import zombie from '@zombienet/orchestrator/dist';
import {readNetworkConfig} from '@zombienet/utils/dist';
import {resolve} from 'path';
import {usingPlaygrounds} from '.';
import {migrations} from './frankensteinMigrate';
import fs from 'fs';

const ZOMBIENET_CREDENTIALS = process.env.ZOMBIENET_CREDENTIALS || '../.env';
Expand Down Expand Up @@ -245,12 +246,14 @@ const raiseZombienet = async (): Promise<void> => {
await waitWithTimer(relayInfo.epochTime);
}

const migration = migrations[process.env.DESTINATION_SPEC_VERSION!];
for(const paraId in network.paras) {
console.log(`\n--- Upgrading the runtime of parachain ${paraId} \t---`);
const para = network.paras[paraId];

// Enable maintenance mode if present
await toggleMaintenanceMode(true, para.nodes[0].wsUri);
if(migration) await migration.before();

// Read the WASM code and authorize the upgrade with its hash and set it as the new runtime
const code = fs.readFileSync(NEW_PARA_WASM);
Expand Down Expand Up @@ -324,6 +327,8 @@ const raiseZombienet = async (): Promise<void> => {

// Disable maintenance mode if present
for(const paraId in network.paras) {
// TODO only if our parachain
if(migration) await migration.after();
await toggleMaintenanceMode(false, network.paras[paraId].nodes[0].wsUri);
}
} else {
Expand Down
9 changes: 9 additions & 0 deletions tests/src/util/frankensteinMigrate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import {migration as locksToFreezesMigration} from '../migrations/942057-appPromotion';
export interface Migration {
before: () => Promise<void>,
after: () => Promise<void>,
}

export const migrations: {[key: string]: Migration} = {
'v942057': locksToFreezesMigration,
};

0 comments on commit cd2a1cb

Please sign in to comment.