Optional finishing upgrade
import { ArgumentParser } from 'argparse';
import { deployContract } from 'ethereum-waffle';
-import { constants, ethers } from 'ethers';
+import { ethers } from 'ethers';
import * as fs from 'fs';
import * as path from 'path';
import { web3Provider, storedBlockInfoParam } from './utils';
@@ -19,10 +19,10 @@ async function main() {
parser.addArgument('--masterPrivateKey');
parser.addArgument('--upgradeGatekeeperAddress');
parser.addArgument('--lastBlockInfo');
+ parser.addArgument('--finish');
+ parser.addArgument('--startPreparation');
const args = parser.parseArgs(process.argv.slice(2));
- const lastBlockInfo = JSON.parse(args.lastBlockInfo);
-
const provider = web3Provider();
const wallet = args.masterPrivateKey
? new ethers.Wallet(args.masterPrivateKey).connect(provider)
@@ -34,23 +34,36 @@ async function main() {
wallet
);
- const newTargetZkSync = await deployContract(wallet, testContracts.zkSync, [], {
+ console.log('Deploying new Governance target...');
+ const newTargetGov = await deployContract(wallet, testContracts.governance, [], {
gasLimit: 6500000
});
- const newTargetGov = await deployContract(wallet, testContracts.governance, [], {
+ console.log('Deploying new Verifier target...');
+ const newTargetVerifier = await deployContract(wallet, testContracts.verifier, [], {
gasLimit: 6500000
});
- const upgradeData = ethers.utils.defaultAbiCoder.encode([storedBlockInfoParam()], [lastBlockInfo]);
+ console.log('Deploying new zkSync target...');
+ const newTargetZkSync = await deployContract(wallet, testContracts.zkSync, [], {
+ gasLimit: 6500000
+ });
console.log('Starting upgrade');
await (
- await upgradeGatekeeper.startUpgrade([newTargetGov.address, constants.AddressZero, newTargetZkSync.address], {
+ await upgradeGatekeeper.startUpgrade(
+ [newTargetGov.address, newTargetVerifier.address, newTargetZkSync.address],
+ {
gasLimit: 500000
- })
+ }
+ )
).wait();
+ // No need to proceed further if we don't want to finish or startPreparation
+ if (!args.finish && !args.startPreparation) {
+ return;
+ }
+
// wait notice period
console.log('Waiting notice period');
while (parseInt(await upgradeGatekeeper.upgradeStatus()) !== 2 /*Preparation*/) {
@@ -58,8 +71,14 @@ async function main() {
await (await upgradeGatekeeper.startPreparation({ gasLimit: 300000 })).wait();
}
- console.log('Finish upgrade notice period');
- // console.log(await proxyContract.exodusMode());
+ if (!args.finish) {
+ return;
+ }
+
+ const lastBlockInfo = JSON.parse(args.lastBlockInfo);
+ const upgradeData = ethers.utils.defaultAbiCoder.encode([storedBlockInfoParam()], [lastBlockInfo]);
+
+ console.log('Finishing upgrade');
// finish upgrade
await (await upgradeGatekeeper.finishUpgrade([[], [], upgradeData], { gasLimit: 3000000 })).wait();
}
