-
Notifications
You must be signed in to change notification settings - Fork 305
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ebc1f1b
commit a11a1bb
Showing
7 changed files
with
337 additions
and
6 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
tools/addRollupType/addRollupMainnet2/add_rollup_type_output.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"genesis": "0xe3a7d8bae497945ba8ddc51c69564f60ad4c1a990b9c7bdbd27f7929bfa8f272", | ||
"verifierAddress": "0x4AaBBA26EA9E7A7fbD052d17a167e6aE3F8eC7Be", | ||
"consensusContract": "PolygonZkEVMEtrog", | ||
"scheduleData": "0x01d5062a0000000000000000000000005132a183e9f3cb7c848b0aac5ae0c4f0491b7ab2000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000d2f000000000000000000000000000000000000000000000000000000000000000144f34eb8eb0000000000000000000000002650a9a4fc64f63f573ef0f405064ef54bc46f710000000000000000000000004aabba26ea9e7a7fbd052d17a167e6ae3f8ec7be00000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000e3a7d8bae497945ba8ddc51c69564f60ad4c1a990b9c7bdbd27f7929bfa8f27200000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000005e547970653a207a6b45564d2c2056657273696f6e3a20696e636162657272792c2067656e657369733a202f697066732f516d55586e526f5062556d5a75455a43477969486a45736f4e6346567533684c74537668706e664253326d415955000000000000000000000000000000000000000000000000000000000000", | ||
"executeData": "0x134008d30000000000000000000000005132a183e9f3cb7c848b0aac5ae0c4f0491b7ab2000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000144f34eb8eb0000000000000000000000002650a9a4fc64f63f573ef0f405064ef54bc46f710000000000000000000000004aabba26ea9e7a7fbd052d17a167e6ae3f8ec7be00000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000e3a7d8bae497945ba8ddc51c69564f60ad4c1a990b9c7bdbd27f7929bfa8f27200000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000005e547970653a207a6b45564d2c2056657273696f6e3a20696e636162657272792c2067656e657369733a202f697066732f516d55586e526f5062556d5a75455a43477969486a45736f4e6346567533684c74537668706e664253326d415955000000000000000000000000000000000000000000000000000000000000", | ||
"id": "0x66ee39ba3adb62a6fb90f0fbf71a043be2ddf5d65d6abdf0f3687b53682f153c", | ||
"decodedScheduleData": { | ||
"target": "0x5132A183E9F3CB7C848b0AAC5Ae0c4f0491B7aB2", | ||
"value": "0", | ||
"data": "0xf34eb8eb0000000000000000000000002650a9a4fc64f63f573ef0f405064ef54bc46f710000000000000000000000004aabba26ea9e7a7fbd052d17a167e6ae3f8ec7be00000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000e3a7d8bae497945ba8ddc51c69564f60ad4c1a990b9c7bdbd27f7929bfa8f27200000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000005e547970653a207a6b45564d2c2056657273696f6e3a20696e636162657272792c2067656e657369733a202f697066732f516d55586e526f5062556d5a75455a43477969486a45736f4e6346567533684c74537668706e664253326d4159550000", | ||
"decodedData": { | ||
"consensusImplementation": "0x2650a9a4fC64f63F573EF0F405064EF54BC46f71", | ||
"verifier": "0x4AaBBA26EA9E7A7fbD052d17a167e6aE3F8eC7Be", | ||
"forkID": "8", | ||
"rollupCompatibilityID": "0", | ||
"genesis": "0xe3a7d8bae497945ba8ddc51c69564f60ad4c1a990b9c7bdbd27f7929bfa8f272", | ||
"description": "Type: zkEVM, Version: incaberry, genesis: /ipfs/QmUXnRoPbUmZuEZCGyiHjEsoNcFVu3hLtSvhpnfBS2mAYU" | ||
}, | ||
"predecessor": "0x0000000000000000000000000000000000000000000000000000000000000000", | ||
"salt": "0x0000000000000000000000000000000000000000000000000000000000000000", | ||
"delay": "864000" | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
tools/addRollupType/addRollupMainnet2/deploy_output_mainnet.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
/* 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 upgradeOutput = require("./upgrade_output.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("PolygonZkEVM"); | ||
const polygonZkEVMContract = (await polygonZkEVMFactory.attach( | ||
deployOutputParameters.polygonZkEVMAddress | ||
)) as PolygonZkEVM; | ||
|
||
const lastBatchSequenced = await polygonZkEVMContract.lastBatchSequenced(); | ||
|
||
await setStorageAt(polygonZkEVMContract.target, 116, lastBatchSequenced); | ||
|
||
const lastBatchVerified = await polygonZkEVMContract.lastVerifiedBatch(); | ||
console.log({lastBatchSequenced}); | ||
console.log({lastBatchVerified}); | ||
|
||
await time.increase(timelockDelay); | ||
|
||
// Set storage slot | ||
|
||
// send mutlsig transaction | ||
const txUpgrade = { | ||
to: timelockContract.target, | ||
data: upgradeOutput.executeData, | ||
}; | ||
|
||
const receipt = await (await multisigSigner.sendTransaction(txUpgrade)).wait(); | ||
|
||
const RollupMangerFactory = await ethers.getContractFactory("PolygonRollupManager"); | ||
const rollupManager = (await RollupMangerFactory.attach( | ||
deployOutputParameters.polygonZkEVMAddress | ||
)) as PolygonRollupManager; | ||
|
||
expect(await rollupManager.rollupCount()).to.be.equal(1); | ||
|
||
console.log("Contracts upgraded"); | ||
|
||
// Deploy a validium | ||
const verifierAddress = upgradeOutput.verifierAddress; | ||
|
||
// send mutlsig transaction | ||
const txAddRollupType = { | ||
to: timelockContract.target, | ||
data: addRollupTypeOutput.executeData, | ||
}; | ||
const receiptAddRollupType = await (await multisigSigner.sendTransaction(txAddRollupType)).wait(); | ||
|
||
expect(await rollupManager.rollupTypeCount()).to.be.equal(1); | ||
|
||
// Create new rollup | ||
const chainID = 123213; | ||
const txDeployRollup = await rollupManager.connect(multisigSigner).createNewRollup( | ||
1, // rollupType | ||
chainID, | ||
deployer.address, // admin | ||
deployer.address, // sequencer | ||
ethers.ZeroAddress, // gas token address | ||
"trustedsequencer url", | ||
"network name" | ||
); | ||
|
||
console.log("Validum added"); | ||
|
||
const receiptDeployRollup = (await txDeployRollup.wait()) as any; | ||
expect(await rollupManager.rollupCount()).to.be.equal(2); | ||
|
||
// Update rollup to this type: this is just a test is NOT intended to update our zkevm to a validium | ||
await ethers.provider.send("hardhat_impersonateAccount", [deployOutputParameters.timelockContractAddress]); | ||
const tiemelockSigner = await ethers.getSigner(deployOutputParameters.timelockContractAddress as any); | ||
await setBalance(deployOutputParameters.timelockContractAddress, 100n ** 18n); | ||
const txUpdateRollup = await rollupManager.connect(tiemelockSigner).updateRollup( | ||
upgradeOutput.newPolygonZKEVM, //new poylgon zkevm | ||
1, // new rollupTypeID | ||
"0x" // upgradeData | ||
); | ||
|
||
const receiptUpdateRollup = (await txUpdateRollup.wait()) as any; | ||
|
||
const rollupDataFinal2 = await rollupManager.rollupIDToRollupData(2); | ||
//expect(rollupDataFinal2.rollupContract).to.be.equal(upgradeOutput.newPolygonZKEVM); | ||
expect(rollupDataFinal2.chainID).to.be.equal(chainID); | ||
expect(rollupDataFinal2.verifier).to.be.equal(verifierAddress); | ||
expect(rollupDataFinal2.forkID).to.be.equal(7); | ||
expect(rollupDataFinal2.lastBatchSequenced).to.be.equal(1); | ||
expect(rollupDataFinal2.lastVerifiedBatch).to.be.equal(0); | ||
expect(rollupDataFinal2.lastPendingState).to.be.equal(0); | ||
expect(rollupDataFinal2.lastPendingStateConsolidated).to.be.equal(0); | ||
expect(rollupDataFinal2.lastVerifiedBatchBeforeUpgrade).to.be.equal(0); | ||
expect(rollupDataFinal2.rollupTypeID).to.be.equal(1); | ||
expect(rollupDataFinal2.rollupCompatibilityID).to.be.equal(0); | ||
|
||
const rollupDataFinal = await rollupManager.rollupIDToRollupData(1); | ||
expect(rollupDataFinal.rollupContract).to.be.equal(upgradeOutput.newPolygonZKEVM); | ||
expect(rollupDataFinal.chainID).to.be.equal(1101); | ||
expect(rollupDataFinal.verifier).to.be.equal(verifierAddress); | ||
expect(rollupDataFinal.forkID).to.be.equal(7); | ||
expect(rollupDataFinal.lastBatchSequenced).to.be.equal(lastBatchSequenced + 1n); | ||
expect(rollupDataFinal.lastVerifiedBatch).to.be.equal(lastBatchSequenced); | ||
expect(rollupDataFinal.lastPendingState).to.be.equal(0); | ||
expect(rollupDataFinal.lastPendingStateConsolidated).to.be.equal(0); | ||
expect(rollupDataFinal.lastVerifiedBatchBeforeUpgrade).to.be.equal(lastBatchSequenced); | ||
expect(rollupDataFinal.rollupTypeID).to.be.equal(1); | ||
expect(rollupDataFinal.rollupCompatibilityID).to.be.equal(0); | ||
|
||
console.log("Updated zkevm Succedd"); | ||
} | ||
|
||
main().catch((e) => { | ||
console.error(e); | ||
process.exit(1); | ||
}); |
17 changes: 17 additions & 0 deletions
17
tools/addRollupType/addRollupMainnet2/updateRollupOutput.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"scheduleData": "0x01d5062a0000000000000000000000005132a183e9f3cb7c848b0aac5ae0c4f0491b7ab2000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000d2f000000000000000000000000000000000000000000000000000000000000000084c4c928c2000000000000000000000000519e42c24163192dca44cd3fbdcebf6be913098700000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", | ||
"executeData": "0x134008d30000000000000000000000005132a183e9f3cb7c848b0aac5ae0c4f0491b7ab2000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000084c4c928c2000000000000000000000000519e42c24163192dca44cd3fbdcebf6be913098700000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", | ||
"decodedScheduleData": { | ||
"target": "0x5132A183E9F3CB7C848b0AAC5Ae0c4f0491B7aB2", | ||
"value": "0", | ||
"data": "0xc4c928c2000000000000000000000000519e42c24163192dca44cd3fbdcebf6be9130987000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000", | ||
"decodedData": { | ||
"rollupContract": "0x519E42c24163192Dca44CD3fBDCEBF6be9130987", | ||
"newRollupTypeID": "2", | ||
"upgradeData": "0x" | ||
}, | ||
"predecessor": "0x0000000000000000000000000000000000000000000000000000000000000000", | ||
"salt": "0x0000000000000000000000000000000000000000000000000000000000000000", | ||
"delay": "864000" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,18 @@ | ||
{ | ||
"consensusContract": "PolygonValidiumEtrog", | ||
"consensusContract": "PolygonZkEVMEtrog", | ||
"polygonRollupManagerAddress": "0x5132A183E9F3CB7C848b0AAC5Ae0c4f0491B7aB2", | ||
"polygonZkEVMBridgeAddress": "0x2a3DD3EB832aF982ec71669E178424b10Dca2EDe", | ||
"polygonZkEVMGlobalExitRootAddress": "0x580bda1e7A0CFAe92Fa7F6c20A3794F169CE3CFb", | ||
"polTokenAddress": "0x455e53CBB86018Ac2B8092FdCd39d8444aFFC3F6", | ||
"verifierAddress": "0x1C3A3da552b8662CD69538356b1E7c2E9CC1EBD8", | ||
"description": "Type: Validium, Version: etrog, genesis: /ipfs/QmUXnRoPbUmZuEZCGyiHjEsoNcFVu3hLtSvhpnfBS2mAYU", | ||
"forkID": 7, | ||
"verifierAddress": "0x4AaBBA26EA9E7A7fbD052d17a167e6aE3F8eC7Be", | ||
"description": "Type: zkEVM, Version: incaberry, genesis: /ipfs/QmUXnRoPbUmZuEZCGyiHjEsoNcFVu3hLtSvhpnfBS2mAYU", | ||
"forkID": 8, | ||
"rollupCompatibilityID": 0, | ||
"timelockDelay": 864000, | ||
"gasTokenAddress": "", | ||
"timelockSalt": "", | ||
"deployerPvtKey": "", | ||
"maxFeePerGas":"", | ||
"maxPriorityFeePerGas":"", | ||
"maxFeePerGas": "", | ||
"maxPriorityFeePerGas": "", | ||
"multiplierGas": "" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters