Skip to content

Commit

Permalink
update astar
Browse files Browse the repository at this point in the history
  • Loading branch information
invocamanman committed Feb 26, 2024
1 parent c542878 commit a88da04
Show file tree
Hide file tree
Showing 7 changed files with 284 additions and 3 deletions.
19 changes: 19 additions & 0 deletions tools/addRollupType/addRollupMainnet3/add_rollup_type.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"consensusContract": "PolygonValidiumStorageMigration",
"polygonRollupManagerAddress": "0x5132A183E9F3CB7C848b0AAC5Ae0c4f0491B7aB2",
"polygonZkEVMBridgeAddress": "0x2a3DD3EB832aF982ec71669E178424b10Dca2EDe",
"polygonZkEVMGlobalExitRootAddress": "0x580bda1e7A0CFAe92Fa7F6c20A3794F169CE3CFb",
"polTokenAddress": "0x455e53CBB86018Ac2B8092FdCd39d8444aFFC3F6",
"verifierAddress": "0x4AaBBA26EA9E7A7fbD052d17a167e6aE3F8eC7Be",
"description": "Type: Validium, Version: incaberry, genesis: /ipfs/QmUXnRoPbUmZuEZCGyiHjEsoNcFVu3hLtSvhpnfBS2mAYU",
"forkID": 8,
"rollupCompatibilityID": 0,
"timelockDelay": 864000,
"predecessor": "0x8bae5e2a8aaf4501e263b917591e7fcf9b1d28c85962a8847a845aff916b50ad",
"gasTokenAddress": "",
"timelockSalt": "",
"deployerPvtKey": "",
"maxFeePerGas": "",
"maxPriorityFeePerGas": "",
"multiplierGas": ""
}
24 changes: 24 additions & 0 deletions tools/addRollupType/addRollupMainnet3/add_rollup_type_output.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"genesis": "0xe3a7d8bae497945ba8ddc51c69564f60ad4c1a990b9c7bdbd27f7929bfa8f272",
"verifierAddress": "0x4AaBBA26EA9E7A7fbD052d17a167e6aE3F8eC7Be",
"consensusContract": "PolygonValidiumStorageMigration",
"scheduleData": "0x01d5062a0000000000000000000000005132a183e9f3cb7c848b0aac5ae0c4f0491b7ab2000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c08bae5e2a8aaf4501e263b917591e7fcf9b1d28c85962a8847a845aff916b50ad000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000d2f000000000000000000000000000000000000000000000000000000000000000164f34eb8eb00000000000000000000000010d296e8add0535be71639e5d1d1c30ae1c6bd4c0000000000000000000000004aabba26ea9e7a7fbd052d17a167e6ae3f8ec7be00000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000e3a7d8bae497945ba8ddc51c69564f60ad4c1a990b9c7bdbd27f7929bfa8f27200000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000061547970653a2056616c696469756d2c2056657273696f6e3a20696e636162657272792c2067656e657369733a202f697066732f516d55586e526f5062556d5a75455a43477969486a45736f4e6346567533684c74537668706e664253326d4159550000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"executeData": "0x134008d30000000000000000000000005132a183e9f3cb7c848b0aac5ae0c4f0491b7ab2000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a08bae5e2a8aaf4501e263b917591e7fcf9b1d28c85962a8847a845aff916b50ad00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000164f34eb8eb00000000000000000000000010d296e8add0535be71639e5d1d1c30ae1c6bd4c0000000000000000000000004aabba26ea9e7a7fbd052d17a167e6ae3f8ec7be00000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000e3a7d8bae497945ba8ddc51c69564f60ad4c1a990b9c7bdbd27f7929bfa8f27200000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000061547970653a2056616c696469756d2c2056657273696f6e3a20696e636162657272792c2067656e657369733a202f697066732f516d55586e526f5062556d5a75455a43477969486a45736f4e6346567533684c74537668706e664253326d4159550000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"id": "0xd43e98454a4d7bef73956a5239de00d4858589ccf39f1d26a8c5bd9d1e5f671b",
"decodedScheduleData": {
"target": "0x5132A183E9F3CB7C848b0AAC5Ae0c4f0491B7aB2",
"value": "0",
"data": "0xf34eb8eb00000000000000000000000010d296e8add0535be71639e5d1d1c30ae1c6bd4c0000000000000000000000004aabba26ea9e7a7fbd052d17a167e6ae3f8ec7be00000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000e3a7d8bae497945ba8ddc51c69564f60ad4c1a990b9c7bdbd27f7929bfa8f27200000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000061547970653a2056616c696469756d2c2056657273696f6e3a20696e636162657272792c2067656e657369733a202f697066732f516d55586e526f5062556d5a75455a43477969486a45736f4e6346567533684c74537668706e664253326d41595500000000000000000000000000000000000000000000000000000000000000",
"decodedData": {
"consensusImplementation": "0x10D296e8aDd0535be71639E5D1d1c30ae1C6bD4C",
"verifier": "0x4AaBBA26EA9E7A7fbD052d17a167e6aE3F8eC7Be",
"forkID": "8",
"rollupCompatibilityID": "0",
"genesis": "0xe3a7d8bae497945ba8ddc51c69564f60ad4c1a990b9c7bdbd27f7929bfa8f272",
"description": "Type: Validium, Version: incaberry, genesis: /ipfs/QmUXnRoPbUmZuEZCGyiHjEsoNcFVu3hLtSvhpnfBS2mAYU"
},
"predecessor": "0x8bae5e2a8aaf4501e263b917591e7fcf9b1d28c85962a8847a845aff916b50ad",
"salt": "0x0000000000000000000000000000000000000000000000000000000000000000",
"delay": "864000"
}
}
22 changes: 22 additions & 0 deletions tools/addRollupType/addRollupMainnet3/deploy_output_mainnet.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"polygonZkEVMAddress": "0x5132A183E9F3CB7C848b0AAC5Ae0c4f0491B7aB2",
"polygonZkEVMBridgeAddress": "0x2a3DD3EB832aF982ec71669E178424b10Dca2EDe",
"polygonZkEVMGlobalExitRootAddress": "0x580bda1e7A0CFAe92Fa7F6c20A3794F169CE3CFb",
"maticTokenAddress": "0x7D1AfA7B718fb893dB30A3aBc0Cfc608AaCfeBB0",
"verifierAddress": "0x4F9A0e7FD2Bf6067db6994CF12E4495Df938E6e9",
"zkEVMDeployerContract": "0xCB19eDdE626906eB1EE52357a27F62dd519608C2",
"deployerAddress": "0x7c280C055CBf830F77D6DA3a6363e961E0B91C7d",
"timelockContractAddress": "0xEf1462451C30Ea7aD8555386226059Fe837CA4EF",
"deploymentBlockNumber": 16896721,
"genesisRoot": "0x3f86b09b43e3e49a41fc20a07579b79eba044253367817d5c241d23c0e2bc5c9",
"trustedSequencer": "0x148Ee7dAF16574cD020aFa34CC658f8F3fbd2800",
"trustedSequencerURL": "https://zkevm-rpc.com/",
"chainID": 1101,
"networkName": "polygon zkEVM",
"admin": "0x242daE44F5d8fb54B198D03a94dA45B5a4413e21",
"trustedAggregator": "0xdA87c4a76922598Ac0272F4D9503a35071D686eA",
"proxyAdminAddress": "0x0F99738B2Fc14D77308337f3e2596b63aE7BCC4A",
"forkID": 4,
"salt": "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa",
"version": "v1.1.0-fork.4"
}
92 changes: 92 additions & 0 deletions tools/addRollupType/addRollupMainnet3/genesis.json

Large diffs are not rendered by default.

107 changes: 107 additions & 0 deletions tools/addRollupType/addRollupMainnet3/testFork.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
/* eslint-disable no-await-in-loop, no-use-before-define, no-lonely-if */
/* eslint-disable no-console, no-inner-declarations, no-undef, import/no-unresolved */
import {expect} from "chai";
import path = require("path");
import fs = require("fs");

import * as dotenv from "dotenv";
dotenv.config({path: path.resolve(__dirname, "../../../.env")});
import {ethers, upgrades} from "hardhat";
import {PolygonRollupManager, PolygonZkEVMTimelock} from "../../../typechain-types";

import {takeSnapshot, time, reset, setBalance, setStorageAt} from "@nomicfoundation/hardhat-network-helpers";

const deployOutputParameters = require("./deploy_output_mainnet.json");
const updateOutput = require("./updateRollupOutput.json");
const addRollupTypeOutput = require("./add_rollup_type_output.json");

async function main() {
const polTokenAddress = "0x455e53CBB86018Ac2B8092FdCd39d8444aFFC3F6"; // mainnet address
const deployer = (await ethers.getSigners())[0];
console.log("using signer: ", deployer.address);

// hard fork
const rpc = `https://mainnet.infura.io/v3/${process.env.INFURA_PROJECT_ID}`;
await reset(rpc);
await setBalance(deployer.address, 100n ** 18n);

// Get timelock multisig
const timelockMultisig = "0x242daE44F5d8fb54B198D03a94dA45B5a4413e21";
await ethers.provider.send("hardhat_impersonateAccount", [timelockMultisig]);
const multisigSigner = await ethers.getSigner(timelockMultisig as any);
await setBalance(timelockMultisig, 100n ** 18n);

const timelockContractFactory = await ethers.getContractFactory("PolygonZkEVMTimelock");
const timelockContract = (await timelockContractFactory.attach(
deployOutputParameters.timelockContractAddress
)) as PolygonZkEVMTimelock;

const timelockDelay = await timelockContract.getMinDelay();

const polygonZkEVMFactory = await ethers.getContractFactory("PolygonValidiumEtrog");
const polygonValidiumContract = (await polygonZkEVMFactory.attach(
updateOutput.decodedScheduleData.decodedData.rollupContract
)) as PolygonZkEVM;

const dataAvailabilityProtocol = await polygonValidiumContract.dataAvailabilityProtocol();

await time.increase(timelockDelay);

const addRollupType2Output = require("../addRollupMainnet2/add_rollup_type_output.json");

const txExectureData = {
to: timelockContract.target,
data: addRollupType2Output.executeData,
};
await (await multisigSigner.sendTransaction(txExectureData)).wait();

// const txScheduleUpdate = {
// to: timelockContract.target,
// data: updateOutput.scheduleData,
// };

// await (await multisigSigner.sendTransaction(txScheduleUpdate)).wait();

// send mutlsig transaction
const txExecuteAddType = {
to: timelockContract.target,
data: addRollupTypeOutput.executeData,
};

await (await multisigSigner.sendTransaction(txExecuteAddType)).wait();

const txExecuteUpdate = {
to: timelockContract.target,
data: updateOutput.executeData,
};

await (await multisigSigner.sendTransaction(txExecuteUpdate)).wait();

const RollupMangerFactory = await ethers.getContractFactory("PolygonRollupManager");
const rollupManager = (await RollupMangerFactory.attach(
deployOutputParameters.polygonZkEVMAddress
)) as PolygonRollupManager;

expect(await rollupManager.rollupCount()).to.be.equal(2);
expect(await rollupManager.rollupTypeCount()).to.be.equal(3);
console.log("Contracts upgraded");

// Deploy a validium
const verifierAddress = addRollupTypeOutput.decodedScheduleData.decodedData.verifier;

const rollupDataFinal = await rollupManager.rollupIDToRollupData(2);
expect(rollupDataFinal.rollupContract).to.be.equal("0x1E163594e13030244DCAf4cDfC2cd0ba3206DA80");
expect(rollupDataFinal.chainID).to.be.equal(3776);
expect(rollupDataFinal.verifier).to.be.equal(verifierAddress);
expect(rollupDataFinal.forkID).to.be.equal(8);
expect(rollupDataFinal.rollupTypeID).to.be.equal(3);
expect(rollupDataFinal.rollupCompatibilityID).to.be.equal(0);

console.log("Updated zkevm Succedd");
expect(await polygonValidiumContract.dataAvailabilityProtocol()).to.be.equal(dataAvailabilityProtocol);
}

main().catch((e) => {
console.error(e);
process.exit(1);
});
17 changes: 17 additions & 0 deletions tools/addRollupType/addRollupMainnet3/updateRollupOutput.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"scheduleData": "0x01d5062a0000000000000000000000005132a183e9f3cb7c848b0aac5ae0c4f0491b7ab2000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000d2f0000000000000000000000000000000000000000000000000000000000000000a4c4c928c20000000000000000000000001e163594e13030244dcaf4cdfc2cd0ba3206da800000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000041c8b93700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"executeData": "0x134008d30000000000000000000000005132a183e9f3cb7c848b0aac5ae0c4f0491b7ab2000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a4c4c928c20000000000000000000000001e163594e13030244dcaf4cdfc2cd0ba3206da800000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000041c8b93700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"decodedScheduleData": {
"target": "0x5132A183E9F3CB7C848b0AAC5Ae0c4f0491B7aB2",
"value": "0",
"data": "0xc4c928c20000000000000000000000001e163594e13030244dcaf4cdfc2cd0ba3206da800000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000041c8b937000000000000000000000000000000000000000000000000000000000",
"decodedData": {
"rollupContract": "0x1E163594e13030244DCAf4cDfC2cd0ba3206DA80",
"newRollupTypeID": "3",
"upgradeData": "0x1c8b9370"
},
"predecessor": "0x0000000000000000000000000000000000000000000000000000000000000000",
"salt": "0x0000000000000000000000000000000000000000000000000000000000000000",
"delay": "864000"
}
}
6 changes: 3 additions & 3 deletions tools/addRollupType/addRollupTypeTimelock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ async function main() {
} = addRollupParameters;

const salt = addRollupParameters.timelockSalt || ethers.ZeroHash;
const predecesoor = addRollupParameters.predecesoor || ethers.ZeroHash;
const predecessor = addRollupParameters.predecessor || ethers.ZeroHash;

const supportedConensus = ["PolygonZkEVMEtrog", "PolygonValidiumEtrog"];
const supportedConensus = ["PolygonZkEVMEtrog", "PolygonValidiumEtrog", "PolygonValidiumStorageMigration"];

if (!supportedConensus.includes(consensusContract)) {
throw new Error(`Consensus contract not supported, supported contracts are: ${supportedConensus}`);
Expand Down Expand Up @@ -153,7 +153,7 @@ async function main() {
genesis.root,
description,
]),
predecesoor, // predecesoor
predecessor, // predecessor
salt // salt
);

Expand Down

0 comments on commit a88da04

Please sign in to comment.