Skip to content

Commit

Permalink
more upgrade scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
kelemeno committed May 13, 2024
1 parent 14191a4 commit 5be2477
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 26 deletions.
6 changes: 3 additions & 3 deletions l1-contracts/scripts/upgrade-consistency-checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ const validatorTimelockDeployTx = "0x420e0dddae4a1565fee430ecafa8f5ddbc3eebee266
const validatorTimelock = "0xc2d7a7Bd59a548249e64C1a587220c0E4F6F439E";
const upgradeHyperchains = "0xb2963DDc6694a989B527AED0B1E19f9F0675AE4d";

const verifier = "0x9D6c59D9A234F585B367b4ba3C62e5Ec7A6179FD";
const verifier = "0x353Ac6bB8d608B607f0443f033e2A89aDa16bcb0";
const proxyAdmin = "0xf2c1d17441074FFb18E9A918db81A17dB1752146";

const bridgeHubImpl = "0xF9D2E98Ed518eC6Daac0579a9707d83da55D5f89";
const bridgeHub = "0x5B5c82f4Da996e118B127880492a23391376F65c";

const executorFacet = "0x1a451d9bFBd176321966e9bc540596Ca9d39B4B1";
const executorFacet = "0x63f4c229F261c2576E8B5A405321769c08134c73";
const adminFacet = "0x342a09385E9BAD4AD32a6220765A6c333552e565";
const mailboxFacetDeployTx = "0x2fa6af6e9317089be2734ffae73771c8099382d390d4edbb6c35e2db7f73b152";
const mailboxFacet = "0x7814399116C17F2750Ca99cBFD2b75bA9a0793d7";
Expand Down Expand Up @@ -315,7 +315,7 @@ async function checkBridgehub() {

const owner = await contract.owner();
if (owner.toLowerCase() != expectedOwner.toLowerCase()) {
throw new Error("ValidatorTimelock owner is not correct");
throw new Error("Bridgehub owner is not correct");
}

const baseToken = await contract.baseToken(eraChainId);
Expand Down
3 changes: 2 additions & 1 deletion l1-contracts/scripts/verify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ function verifyPromise(address: string, constructorArguments?: Array<any>, libra
address,
constructorArguments,
libraries,
// contract:"contracts/bridge/L1ERC20Bridge.sol:L1ERC20Bridge"
})
.then(() => resolve(`Successfully verified ${address}`))
.catch((e) => reject(`Failed to verify ${address}\nError: ${e.message}`));
Expand Down Expand Up @@ -75,7 +76,7 @@ async function main() {
// promises.push(promise2);

// console.log("CONTRACTS_HYPERCHAIN_UPGRADE_ADDR", process.env.CONTRACTS_HYPERCHAIN_UPGRADE_ADDR);
// const promise3 = verifyPromise(process.env.CONTRACTS_HYPERCHAIN_UPGRADE_ADDR);
// const promise3 = verifyPromise(process.env.CONTRACTS_DEFAULT_UPGRADE_ADDR);
// promises.push(promise3);

// const promise5 = verifyPromise(addresses.TransparentProxyAdmin);
Expand Down
29 changes: 7 additions & 22 deletions l1-contracts/scripts/whatever.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { formatUnits, parseUnits } from "ethers/lib/utils";
import { web3Provider, GAS_MULTIPLIER } from "./utils";
import { deployedAddressesFromEnv } from "../src.ts/deploy-utils";
import { ethTestConfig } from "../src.ts/utils";
import { transferTokens } from "../src.ts/hyperchain-upgrade";
import { setInitialCutHash, upgradeProverFix } from "../src.ts/hyperchain-upgrade";

Check failure on line 11 in l1-contracts/scripts/whatever.ts

View workflow job for this annotation

GitHub Actions / lint

'upgradeProverFix' is defined but never used

Check failure on line 11 in l1-contracts/scripts/whatever.ts

View workflow job for this annotation

GitHub Actions / lint

'upgradeProverFix' is defined but never used

Check failure on line 11 in l1-contracts/scripts/whatever.ts

View workflow job for this annotation

GitHub Actions / lint

'upgradeProverFix' is defined but never used
import { IERC20Factory } from "../typechain/IERC20Factory";

Check failure on line 12 in l1-contracts/scripts/whatever.ts

View workflow job for this annotation

GitHub Actions / lint

'IERC20Factory' is defined but never used

Check failure on line 12 in l1-contracts/scripts/whatever.ts

View workflow job for this annotation

GitHub Actions / lint

'IERC20Factory' is defined but never used

Check failure on line 12 in l1-contracts/scripts/whatever.ts

View workflow job for this annotation

GitHub Actions / lint

'IERC20Factory' is defined but never used

const provider = web3Provider();
Expand Down Expand Up @@ -49,34 +49,19 @@ async function main() {
const nonce = cmd.nonce ? parseInt(cmd.nonce) : await deployWallet.getTransactionCount();
console.log(`Using nonce: ${nonce}`);

const create2Salt = cmd.create2Salt

Check failure on line 52 in l1-contracts/scripts/whatever.ts

View workflow job for this annotation

GitHub Actions / lint

'create2Salt' is assigned a value but never used

Check failure on line 52 in l1-contracts/scripts/whatever.ts

View workflow job for this annotation

GitHub Actions / lint

'create2Salt' is assigned a value but never used

Check failure on line 52 in l1-contracts/scripts/whatever.ts

View workflow job for this annotation

GitHub Actions / lint

'create2Salt' is assigned a value but never used
? cmd.create2Salt
: "0x0000000000000000000000000000000000000000000000000000000000000000";

const deployer = new Deployer({
deployWallet,
addresses: deployedAddressesFromEnv(),
ownerAddress,
verbose: true,
});
const startToken = 20;
const tokens = tokenList.slice(startToken);
console.log(`From ${startToken}`, tokens);
for (const tokenAddress of tokenList) {
const erc20contract = IERC20Factory.connect(tokenAddress, provider);
console.log(`Migrating token ${tokenAddress}`);
console.log(
`Balance before: ${await erc20contract.balanceOf(deployer.addresses.Bridges.ERC20BridgeProxy)}, ${await erc20contract.balanceOf(deployer.addresses.Bridges.SharedBridgeProxy)}`
);
await transferTokens(deployer, tokenAddress);
console.log(
`Balance after: ${await erc20contract.balanceOf(deployer.addresses.Bridges.ERC20BridgeProxy)}, ${await erc20contract.balanceOf(deployer.addresses.Bridges.SharedBridgeProxy)}`
);
}

// console.log("From 0", tokenList);
// for (const tokenAddress of tokenList) {
// const erc20contract = IERC20Factory.connect(tokenAddress, provider);
// if (!(await erc20contract.balanceOf(deployer.addresses.Bridges.ERC20BridgeProxy)).eq(0)) {
// console.log(`Failed to transfer all tokens ${tokenAddress}`);
// }
// }
// await upgradeProverFix(deployer, create2Salt, gasPrice);
await setInitialCutHash(deployer);
});

await program.parseAsync(process.argv);
Expand Down
38 changes: 38 additions & 0 deletions l1-contracts/src.ts/hyperchain-upgrade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,3 +346,41 @@ export async function transferTokens(deployer: Deployer, token: string) {
await tx.wait();
console.log("Receipt", tx.hash);
}

export async function upgradeProverFix(deployer: Deployer, create2Salt: string, gasPrice: BigNumberish) {
await deployer.deployVerifier(create2Salt, { gasPrice });
await deployer.deployExecutorFacet(create2Salt, { gasPrice });
// await deployer.deployDefaultUpgrade(create2Salt, { gasPrice }); // Not needed on mainnet
}

export async function setInitialCutHash(deployer: Deployer) {
const diamondCut = await deployer.initialZkSyncHyperchainDiamondCut([]);
const calldata = deployer
.stateTransitionManagerContract(deployer.deployWallet)
.interface.encodeFunctionData("setInitialCutHash", [diamondCut]);
await deployer.executeUpgrade(deployer.addresses.StateTransition.StateTransitionProxy, 0, calldata, "true");
}

export async function transferTokensOnForkedNetwork(deployer: Deployer) {

Check failure on line 364 in l1-contracts/src.ts/hyperchain-upgrade.ts

View workflow job for this annotation

GitHub Actions / lint

'deployer' is defined but never used

Check failure on line 364 in l1-contracts/src.ts/hyperchain-upgrade.ts

View workflow job for this annotation

GitHub Actions / lint

'deployer' is defined but never used

Check failure on line 364 in l1-contracts/src.ts/hyperchain-upgrade.ts

View workflow job for this annotation

GitHub Actions / lint

'deployer' is defined but never used
// const startToken = 20;
// const tokens = tokenList.slice(startToken);
// console.log(`From ${startToken}`, tokens);
// for (const tokenAddress of tokenList) {
// const erc20contract = IERC20Factory.connect(tokenAddress, provider);
// console.log(`Migrating token ${tokenAddress}`);
// console.log(
// `Balance before: ${await erc20contract.balanceOf(deployer.addresses.Bridges.ERC20BridgeProxy)}, ${await erc20contract.balanceOf(deployer.addresses.Bridges.SharedBridgeProxy)}`
// );
// await transferTokens(deployer, tokenAddress);
// console.log(
// `Balance after: ${await erc20contract.balanceOf(deployer.addresses.Bridges.ERC20BridgeProxy)}, ${await erc20contract.balanceOf(deployer.addresses.Bridges.SharedBridgeProxy)}`
// );
// }
// console.log("From 0", tokenList);
// for (const tokenAddress of tokenList) {
// const erc20contract = IERC20Factory.connect(tokenAddress, provider);
// if (!(await erc20contract.balanceOf(deployer.addresses.Bridges.ERC20BridgeProxy)).eq(0)) {
// console.log(`Failed to transfer all tokens ${tokenAddress}`);
// }
// }
}

0 comments on commit 5be2477

Please sign in to comment.