From 96db3c0924df72020d9a9246ff8e46915de38121 Mon Sep 17 00:00:00 2001 From: krlosMata Date: Sat, 16 Nov 2024 13:48:35 +0100 Subject: [PATCH 1/6] WIP --- tools/addRollupType/README.md | 8 ++++---- tools/verify-etherscan/.gitignore | 2 ++ tools/verify-etherscan/README.md | 11 +++++++++++ 3 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 tools/verify-etherscan/.gitignore create mode 100644 tools/verify-etherscan/README.md diff --git a/tools/addRollupType/README.md b/tools/addRollupType/README.md index c3863a17..a70dac32 100644 --- a/tools/addRollupType/README.md +++ b/tools/addRollupType/README.md @@ -1,5 +1,5 @@ # Add Rollup Type -Script to call `addNewRollupType` function with no timelock involved +Script to call `addNewRollupType` function ## Install ``` @@ -9,9 +9,9 @@ npm i ## Setup - Config file - `consensusContract`: select between consensus contract. Supported: `["PolygonZkEVMEtrog", "PolygonValidiumEtrog", "PolygonPessimisticConsensus"]` - - `consensusContractAddress`: gets this address instead of deployong a new consensus implementation - - `polygonRollupManagerAddress`: polygonRollupManager smart contract address - - `verifierAddress`: verifier to be used + - `consensusContractAddress`: gets this address instead of deploying a new consensus implementation + - `polygonRollupManagerAddress`: `PolygonRollupManager.sol` smart contract address + - `verifierAddress`: verifier address to be used - `description`: string to describe rollup type added. Example: "Type: Validium, Version: etrog, genesis: /ipfs/QmUXnRoPbUmZuEZCGyiHjEsoNcFVu3hLtSvhpnfBS2mAYU" - `forkID`: forkID to be used - `programVKey`: program key for pessimsitic consensus diff --git a/tools/verify-etherscan/.gitignore b/tools/verify-etherscan/.gitignore new file mode 100644 index 00000000..56993211 --- /dev/null +++ b/tools/verify-etherscan/.gitignore @@ -0,0 +1,2 @@ +constructor-args-example.js +constructor-args.js \ No newline at end of file diff --git a/tools/verify-etherscan/README.md b/tools/verify-etherscan/README.md new file mode 100644 index 00000000..ca92ceaf --- /dev/null +++ b/tools/verify-etherscan/README.md @@ -0,0 +1,11 @@ +# Verify etherscan +This is just an example of the `arguments.js` file to provide in etherscan verification command using hardhat. +- Copy example file: +``` +cp arguments +``` + +- Run hardhat command: +``` +npx hardhat verify --constructor-args tools/verify-etherscan/arguments.js ${address} --network ${network-name} +``` \ No newline at end of file From c3bfce60b75fa37449bd63dfc403377dff7f6d63 Mon Sep 17 00:00:00 2001 From: Laia Soler Date: Thu, 5 Dec 2024 16:52:19 +0100 Subject: [PATCH 2/6] update addRollupType tool --- tools/addRollupType/README.md | 8 ++++---- tools/addRollupType/add_rollup_type_output.json | 6 ------ 2 files changed, 4 insertions(+), 10 deletions(-) delete mode 100644 tools/addRollupType/add_rollup_type_output.json diff --git a/tools/addRollupType/README.md b/tools/addRollupType/README.md index a70dac32..e6dc1073 100644 --- a/tools/addRollupType/README.md +++ b/tools/addRollupType/README.md @@ -7,7 +7,7 @@ npm i ``` ## Setup -- Config file +- Config file `add_rollup_type.json`: - `consensusContract`: select between consensus contract. Supported: `["PolygonZkEVMEtrog", "PolygonValidiumEtrog", "PolygonPessimisticConsensus"]` - `consensusContractAddress`: gets this address instead of deploying a new consensus implementation - `polygonRollupManagerAddress`: `PolygonRollupManager.sol` smart contract address @@ -25,7 +25,7 @@ npm i - `maxPriorityFeePerGas(optional)`: string, Set `maxPriorityFeePerGas`, must define aswell `maxFeePerGas` to use it - `multiplierGas(optional)`: number, Gas multiplier with 3 decimals. If `maxFeePerGas` and `maxPriorityFeePerGas` are set, this will not take effect - A network should be selected when running the script - - examples: `-- sepolia` or `--mainnet` + - examples: `--sepolia` or `--mainnet` - This uses variables set in `hardhat.config.ts` - Which uses some environment variables that should be set in `.env` > All paths are from root repository @@ -47,7 +47,7 @@ cp ./tools/addRollupType/genesis.json.example ./tools/addRollupType/genesis.json - Set your parameters - Run tool: ``` -npx hardhat run ./tools/addRollupType/addRollupType.ts --network sepolia +npx hardhat run ./tools/addRollupType/addRollupType.ts --network ``` ### Generate 'addNewRollupType' to the Timelock SC @@ -60,7 +60,7 @@ cp ./tools/addRollupType/add_rollup_type.json.example ./tools/addRollupType/add_ - Set your parameters - Run tool: ``` -npx hardhat run ./tools/addRollupType/addRollupType.ts --network sepolia +npx hardhat run ./tools/addRollupType/addRollupTypeTimelock.ts --network ``` - Output: - scheduleData diff --git a/tools/addRollupType/add_rollup_type_output.json b/tools/addRollupType/add_rollup_type_output.json deleted file mode 100644 index 94b6cc4d..00000000 --- a/tools/addRollupType/add_rollup_type_output.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "genesis": "0xa598a6bb9cca27d437b9371331eb9d8f50fc5a509099f5af4c3c5cae08575f04", - "verifierAddress": "0xbD60710AA740c3210F811292866C2e59339cA273", - "consensusContract": "PolygonValidiumEtrog", - "rollupTypeID": "3" -} \ No newline at end of file From beec42b535c17c563167195ceeaead98b50136a4 Mon Sep 17 00:00:00 2001 From: Laia Soler Date: Thu, 5 Dec 2024 16:52:55 +0100 Subject: [PATCH 3/6] update createGenesis tool --- tools/createGenesis/.gitignore | 1 + tools/createGenesis/README.md | 32 +++++++++++++++++++ tools/createGenesis/generateGenesis.ts | 10 +++--- .../genesis_parameters.json.example | 6 ++++ 4 files changed, 44 insertions(+), 5 deletions(-) create mode 100644 tools/createGenesis/.gitignore create mode 100644 tools/createGenesis/README.md create mode 100644 tools/createGenesis/genesis_parameters.json.example diff --git a/tools/createGenesis/.gitignore b/tools/createGenesis/.gitignore new file mode 100644 index 00000000..90fb18d1 --- /dev/null +++ b/tools/createGenesis/.gitignore @@ -0,0 +1 @@ +genesis_parameters.json \ No newline at end of file diff --git a/tools/createGenesis/README.md b/tools/createGenesis/README.md new file mode 100644 index 00000000..e628bbaa --- /dev/null +++ b/tools/createGenesis/README.md @@ -0,0 +1,32 @@ +# Generate Genesis +Script to generate new genesis + +## Install +``` +npm i +``` + +## Setup +- Config file `genesis_parameters.json`: + - `test`: bool, Indicate if it's a test deployment, which will fund the deployer address with pre minted ether and will give more powers to the deployer address to make easier the flow. + - `timelockAdminAddress`: address, Timelock owner address, able to send start an upgradeability process via timelock + - `minDelayTimelock`: number, Minimum timelock delay, + - `initialZkEVMDeployerOwner`: address, Initial owner of the `PolygonZkEVMDeployer` +- A network should be selected when running the script + - examples: `--network sepolia` or `--network mainnet` + - This uses variables set in `hardhat.config.ts` + - Which uses some environment variables that should be set in `.env` + +## Usage + +- Copy configuration file: +``` +cp ./tools/createGenesis/genesis_parameters.json.example ./tools/createGenesis/genesis_parameters.json +``` +- Set your parameters +- Run tool: +``` +npx hardhat run ./tools/createGenesis/generateGenesis.ts +``` + +- Output: `new_genesis.json` \ No newline at end of file diff --git a/tools/createGenesis/generateGenesis.ts b/tools/createGenesis/generateGenesis.ts index 591c0139..a1726777 100644 --- a/tools/createGenesis/generateGenesis.ts +++ b/tools/createGenesis/generateGenesis.ts @@ -29,7 +29,7 @@ import {ProxyAdmin} from "../../typechain-types"; import {Addressable} from "ethers"; import "../../deployment/helpers/utils"; -const deployParameters = require("./deploy_parameters.json"); +const genesisParameters = require("./genesis_parameters.json"); const genesisBase = require("./genesis_base.json"); const pathOutputJson = path.join(__dirname, argv.out); @@ -72,9 +72,9 @@ const keylessDeployerMainnet = baseGenesisInfo.find( const deployerMainnet = baseGenesisInfo.find((account: any) => account.accountName === "deployer").address; -const mainnetMultisig = deployParameters.timelockAddress; -const mainnetInitialZkEVMDeployerOwner = deployParameters.initialZkEVMDeployerOwner; -const mainnetMinDelayTimelock = deployParameters.minDelayTimelock; +const mainnetMultisig = genesisParameters.timelockAddress; +const mainnetInitialZkEVMDeployerOwner = genesisParameters.initialZkEVMDeployerOwner; +const mainnetMinDelayTimelock = genesisParameters.minDelayTimelock; const globalExitRootL2Address = "0xa40d5f56745a118d0906a34e69aec8c0db1cb8fa"; const zkevmAddressL2 = ethers.ZeroAddress; @@ -383,7 +383,7 @@ async function main() { address: finalDeployer, }); - if (deployParameters.test) { + if (genesisParameters.test) { // Add tester account with ether genesis[genesis.length - 1].balance = "100000000000000000000000"; } diff --git a/tools/createGenesis/genesis_parameters.json.example b/tools/createGenesis/genesis_parameters.json.example new file mode 100644 index 00000000..b8fe8ff3 --- /dev/null +++ b/tools/createGenesis/genesis_parameters.json.example @@ -0,0 +1,6 @@ +{ + "timelockAddress": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", + "initialZkEVMDeployerOwner": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", + "minDelayTimelock": 3600, + "test": true +} \ No newline at end of file From bce0c8ab575225286f930cedcef60a87274c3e56 Mon Sep 17 00:00:00 2001 From: Laia Soler Date: Thu, 5 Dec 2024 16:53:45 +0100 Subject: [PATCH 4/6] update deployClaimCompressor & deployDataCommittee --- tools/deployClaimCompressor/.gitignore | 2 + tools/deployClaimCompressor/README.md | 57 +++++++++++++++++++ .../deployClaimCompressor.ts | 8 +++ tools/deployPolygonDataCommittee/.gitignore | 2 + tools/deployPolygonDataCommittee/README.md | 56 ++++++++++++++++++ ...loy_dataCommittee_parameters.json.example} | 0 6 files changed, 125 insertions(+) create mode 100644 tools/deployClaimCompressor/.gitignore create mode 100644 tools/deployClaimCompressor/README.md create mode 100644 tools/deployPolygonDataCommittee/.gitignore create mode 100644 tools/deployPolygonDataCommittee/README.md rename tools/deployPolygonDataCommittee/{deploy_dataCommittee_parameters.example => deploy_dataCommittee_parameters.json.example} (100%) diff --git a/tools/deployClaimCompressor/.gitignore b/tools/deployClaimCompressor/.gitignore new file mode 100644 index 00000000..a87ce843 --- /dev/null +++ b/tools/deployClaimCompressor/.gitignore @@ -0,0 +1,2 @@ +deploy_claimCompressor.json +deploy_claim_compressor_output.json diff --git a/tools/deployClaimCompressor/README.md b/tools/deployClaimCompressor/README.md new file mode 100644 index 00000000..f65c3b2f --- /dev/null +++ b/tools/deployClaimCompressor/README.md @@ -0,0 +1,57 @@ +# Deploy ClaimCompressor +Script to deploy `ClaimCompressor.sol` + +## Install +``` +npm i +``` + +## Setup +- Config file `deploy_claimCompressor.json`: + - `bridgeAddress`: polygonZkEVMBridgeAddress + - `networkId` + - `deployerPvtKey`: private key deployer + - First option will load `deployerPvtKey`. Otherwise, `process.env.MNEMONIC` will be loaded from the `.env` file + - `maxFeePerGas`: set custom gas + - `maxPriorityFeePerGas`: set custom gas + - `multiplierGas`: set custom gas +- A network should be selected when running the script + - examples: `--network sepolia` or `--network mainnet` + - This uses variables set in `hardhat.config.ts` + - Which uses some environment variables that should be set in `.env` +## Usage + +- Copy configuration file: +``` +cp ./tools/deployClaimCompressor/deploy_claimCompressor.json.example ./tools/deployClaimCompressor/deploy_claimCompressor.json +``` + +- Set your parameters +- Run tool: +``` +npx hardhat run ./tools/deployClaimCompressor/deployClaimCompressor.ts --network +``` + +- Output: + - `deploy_claim_compressor_output.json`: + ``` + { + "deployer": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", + "ClaimCompressorContract": "0x851356ae760d987E095750cCeb3bC6014560891C" + } + ``` + - logs: + ``` + deploying with: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 + ####################### + + Claim Compressor deployed to: 0xc5a5C42992dECbae36851359345FE25997F5C42d + ####################### + + you can verify the contract address with: + npx hardhat verify --constructor-args upgrade/arguments.js 0xc5a5C42992dECbae36851359345FE25997F5C42d --network localhost + + Copy the following constructor arguments on: upgrade/arguments.js + [ '0x124fBB77374f2D2F0d716973C23Ab06AE49ACde5', 0 ] + + ``` \ No newline at end of file diff --git a/tools/deployClaimCompressor/deployClaimCompressor.ts b/tools/deployClaimCompressor/deployClaimCompressor.ts index d182df6f..2e643109 100644 --- a/tools/deployClaimCompressor/deployClaimCompressor.ts +++ b/tools/deployClaimCompressor/deployClaimCompressor.ts @@ -8,6 +8,7 @@ import * as dotenv from "dotenv"; dotenv.config({path: path.resolve(__dirname, "../../../.env")}); import {ethers, network, upgrades} from "hardhat"; const deployParameters = require("./deploy_claimCompressor.json"); +const pathOutput = path.resolve(__dirname, "./deploy_claim_compressor_output.json") async function main() { // Load provider @@ -68,6 +69,11 @@ async function main() { const ClaimCompressorContract = await ClaimCompressor.deploy(bridgeAddress, networkId); await ClaimCompressorContract.waitForDeployment(); + const outputJson = { + deployer: deployer.address, + ClaimCompressorContract: ClaimCompressorContract.target + }; + console.log("#######################\n"); console.log("Claim Compressor deployed to:", ClaimCompressorContract.target); console.log("#######################\n"); @@ -77,6 +83,8 @@ async function main() { `npx hardhat verify --constructor-args upgrade/arguments.js ${ClaimCompressorContract.target} --network ${process.env.HARDHAT_NETWORK}\n` ); console.log("Copy the following constructor arguments on: upgrade/arguments.js \n", [bridgeAddress, networkId]); + + await fs.writeFileSync(pathOutput, JSON.stringify(outputJson, null, 1)); } main().catch((e) => { diff --git a/tools/deployPolygonDataCommittee/.gitignore b/tools/deployPolygonDataCommittee/.gitignore new file mode 100644 index 00000000..cb543216 --- /dev/null +++ b/tools/deployPolygonDataCommittee/.gitignore @@ -0,0 +1,2 @@ +deploy_dataCommittee_output.json +deploy_dataCommittee_parameters.json \ No newline at end of file diff --git a/tools/deployPolygonDataCommittee/README.md b/tools/deployPolygonDataCommittee/README.md new file mode 100644 index 00000000..84c9c780 --- /dev/null +++ b/tools/deployPolygonDataCommittee/README.md @@ -0,0 +1,56 @@ +# Deploy PolygonDataCommittee +Script to deploy `PolygonDataCommittee.sol` + +## Install +``` +npm i +``` + +## Setup +- Config file `deploy_dataCommittee_parameters.json`: + - `admin` + - `networkId` + - `deployerPvtKey`: private key deployer + - First option will load `deployerPvtKey`. Otherwise, `process.env.MNEMONIC` will be loaded from the `.env` file + - `maxFeePerGas`: set custom gas + - `maxPriorityFeePerGas`: set custom gas + - `multiplierGas`: set custom gas +- A network should be selected when running the script + - examples: `--network sepolia` or `--network mainnet` + - This uses variables set in `hardhat.config.ts` + - Which uses some environment variables that should be set in `.env` + +## Usage +> All commands are done from root repository. + +- Copy configuration file: +``` +cp ./tools/deployPolygonDataCommittee/deploy_dataCommittee_parameters.json.example ./tools/deployPolygonDataCommittee/deploy_dataCommittee_parameters.json +``` + +- Run tool: +``` +npx hardhat run ./tools/deployPolygonDataCommittee/deployPolygonDataCommittee.ts --network +``` + +- Output: + - `deploy_dataCommittee_output.json`: + ``` + { + "polygonDataCommitteeAddress": "0xc3e53F4d16Ae77Db1c982e75a937B9f60FE63690", + "proxyAdmin": "0xE6E340D132b5f46d1e472DebcD681B2aBc16e57E" + } + ``` + - logs: + ``` + deploying with: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 + + ####################### + + PolygonDataCommittee deployed to: 0xc3e53F4d16Ae77Db1c982e75a937B9f60FE63690 + ####################### + + polygonDataCommittee deployed to: 0xc3e53F4d16Ae77Db1c982e75a937B9f60FE63690 + you can verify the new polygonDataCommittee address with: + npx hardhat verify 0xc3e53F4d16Ae77Db1c982e75a937B9f60FE63690 --network localhost + ``` diff --git a/tools/deployPolygonDataCommittee/deploy_dataCommittee_parameters.example b/tools/deployPolygonDataCommittee/deploy_dataCommittee_parameters.json.example similarity index 100% rename from tools/deployPolygonDataCommittee/deploy_dataCommittee_parameters.example rename to tools/deployPolygonDataCommittee/deploy_dataCommittee_parameters.json.example From e2827f19e277a06c824ff287cec1acece2a245e3 Mon Sep 17 00:00:00 2001 From: Laia Soler Date: Thu, 5 Dec 2024 16:54:07 +0100 Subject: [PATCH 5/6] update tool deployVerifier --- tools/deployVerifier/.gitignore | 1 + tools/deployVerifier/README.md | 30 ++++++++++++++++--- tools/deployVerifier/deployVerifier.ts | 10 ++++++- ...> deploy_verifier_parameters.json.example} | 0 4 files changed, 36 insertions(+), 5 deletions(-) rename tools/deployVerifier/{deploy_verifier_parameters.example => deploy_verifier_parameters.json.example} (100%) diff --git a/tools/deployVerifier/.gitignore b/tools/deployVerifier/.gitignore index f5c01b98..f7240c80 100644 --- a/tools/deployVerifier/.gitignore +++ b/tools/deployVerifier/.gitignore @@ -1 +1,2 @@ +deploy_verifier_output.json deploy_verifier_parameters.json \ No newline at end of file diff --git a/tools/deployVerifier/README.md b/tools/deployVerifier/README.md index 1d2864d9..142da8e8 100644 --- a/tools/deployVerifier/README.md +++ b/tools/deployVerifier/README.md @@ -7,7 +7,7 @@ npm i ``` ## Setup -- Config file +- Config file `deploy_verifier_parameters.json`: - `realVerifier`: select between a real or a mock verifer - `forkID`: Select fork to verifier to be deployed (if a real verfifier is selected) - `deployerPvtKey`: private key deployer @@ -26,11 +26,33 @@ npm i - Copy configuration file: ``` -cp ./tools/deployVerifier/deploy_verifier_parameters.example ./tools/deployVerifier/deploy_verifier_parameters.json +cp ./tools/deployVerifier/deploy_verifier_parameters.json.example ./tools/deployVerifier/deploy_verifier_parameters.json ``` - - Set your parameters - Run tool: ``` -npx hardhat run ./tools/deployVerifier/deployVerifier.ts --network sepolia +npx hardhat run ./tools/deployVerifier/deployVerifier.ts --network ``` +- Output: + - `deploy_verifier_output.json`: + ``` + { + "deployer": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", + "verifier": "FflonkVerifier_12", + "verifierContract": "0x1613beB3B2C4f22Ee086B2b38C1476A3cE7f78E8" + } + ``` + - logs: + ``` + --> Deploying with: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 + --> Deploying verifier: FflonkVerifier_12 + + ####################### + Verifier deployed to: 0xa82fF9aFd8f496c3d6ac40E2a0F282E47488CFc9 + ####################### + + ####################### + you can verify the new verifierContract address with the following command: + npx hardhat verify 0xa82fF9aFd8f496c3d6ac40E2a0F282E47488CFc9 --network localhost + ####################### + ``` \ No newline at end of file diff --git a/tools/deployVerifier/deployVerifier.ts b/tools/deployVerifier/deployVerifier.ts index 89a1eecb..8049339d 100644 --- a/tools/deployVerifier/deployVerifier.ts +++ b/tools/deployVerifier/deployVerifier.ts @@ -8,12 +8,13 @@ import * as dotenv from "dotenv"; dotenv.config({path: path.resolve(__dirname, "../../../.env")}); import {ethers, upgrades} from "hardhat"; const deployParameters = require("./deploy_verifier_parameters.json"); +const pathOutput = path.resolve(__dirname, "./deploy_verifier_output.json") async function main() { // Load provider let currentProvider = ethers.provider; if (deployParameters.multiplierGas || deployParameters.maxFeePerGas) { - if (process.env.HARDHAT_NETWORK !== "hardhat") { + if (process.env.HARDHAT_NETWORK !== "hardhat" && process.env.HARDHAT_NETWORK !== "zkevmDevnet") { currentProvider = ethers.getDefaultProvider( `https://${process.env.HARDHAT_NETWORK}.infura.io/v3/${process.env.INFURA_PROJECT_ID}` ) as any; @@ -74,6 +75,11 @@ async function main() { verifierContract = await VerifierRollupHelperFactory.deploy(); await verifierContract.waitForDeployment(); } + const outputJson = { + deployer: deployer.address, + verifier: verifierName, + verifierContract: verifierContract.target + }; // print contract address deployed console.log("\n#######################"); console.log("Verifier deployed to:", verifierContract.target); @@ -83,6 +89,8 @@ async function main() { console.log("you can verify the new verifierContract address with the following command:"); console.log(`npx hardhat verify ${verifierContract.target} --network ${process.env.HARDHAT_NETWORK}`); console.log("#######################"); + + await fs.writeFileSync(pathOutput, JSON.stringify(outputJson, null, 1)); } main().catch((e) => { diff --git a/tools/deployVerifier/deploy_verifier_parameters.example b/tools/deployVerifier/deploy_verifier_parameters.json.example similarity index 100% rename from tools/deployVerifier/deploy_verifier_parameters.example rename to tools/deployVerifier/deploy_verifier_parameters.json.example From 390311bb12db26eb362096fad12cfce2e04357bb Mon Sep 17 00:00:00 2001 From: Laia Soler Date: Thu, 5 Dec 2024 16:54:32 +0100 Subject: [PATCH 6/6] update tool getRollupData & grantRole --- tools/getRollupData/.gitignore | 3 ++ tools/getRollupData/README.md | 54 ++++++++++++++++++++++ tools/getRollupData/getRollupData.ts | 59 +++++++++++++----------- tools/grantRole/.gitignore | 2 + tools/grantRole/README.md | 62 ++++++++++++++++++++++++++ tools/grantRole/grantRole.json.example | 6 +-- tools/grantRole/grantRole.ts | 60 +++---------------------- tools/updateRollup/README.md | 8 ++-- 8 files changed, 166 insertions(+), 88 deletions(-) create mode 100644 tools/getRollupData/.gitignore create mode 100644 tools/getRollupData/README.md create mode 100644 tools/grantRole/.gitignore create mode 100644 tools/grantRole/README.md diff --git a/tools/getRollupData/.gitignore b/tools/getRollupData/.gitignore new file mode 100644 index 00000000..655a5338 --- /dev/null +++ b/tools/getRollupData/.gitignore @@ -0,0 +1,3 @@ +create_rollup_output* +deploy_output.json +rollupDataParams.json \ No newline at end of file diff --git a/tools/getRollupData/README.md b/tools/getRollupData/README.md new file mode 100644 index 00000000..503ca59e --- /dev/null +++ b/tools/getRollupData/README.md @@ -0,0 +1,54 @@ +# Get Rollup Data +Script to get rollup data. + +## Install +``` +npm i +``` + +## Setup +- Config file `rollupDataParams.json`: + - `polygonRollupManagerAddress`: rollupManager address, + - `rollupID`: rollup ID +- A network should be selected when running the script + - examples: `--network sepolia` or `--network mainnet` + - This uses variables set in `hardhat.config.ts` + - Which uses some environment variables that should be set in `.env` +> All paths are from root repository + +## Usage +> All commands are done from root repository. + +- Copy configuration file: +``` +cp tools/getRollupData/rollupDataParams.json.example tools/getRollupData/rollupDataParams.json +``` +- Set your parameters +- Run tool: +``` +npx hardhat run tools/getRollupData/getRollupData.ts --network +``` +- Output: + - `deploy_output.json`: + ``` + { + "polygonRollupManagerAddress": "0xA51c1fc2f0D1a1b8494Ed1FE312d7C3a78Ed91C0", + "polygonZkEVMBridgeAddress": "0x124fBB77374f2D2F0d716973C23Ab06AE49ACde5", + "polygonZkEVMGlobalExitRootAddress": "0x610178dA211FEF7D417bC0e6FeD39F05609AD788", + "polTokenAddress": "0x5FbDB2315678afecb367f032d93F642f64180aa3", + "deploymentRollupManagerBlockNumber": 43 + } + ``` + + - `create_rollup_output_X`: + ``` + { + "genesis": "0x0000000000000000000000000000000000000000000000000000000000000000", + "createRollupBlockNumber": 49, + "rollupAddress": "0x1F708C24a0D3A740cD47cC0444E9480899f3dA7D", + "consensusContract": "0.0.1", + "rollupID": 1, + "L2ChainID": 1001, + "gasTokenAddress": "0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0" + } + ``` diff --git a/tools/getRollupData/getRollupData.ts b/tools/getRollupData/getRollupData.ts index b5b66d72..ec48cd17 100644 --- a/tools/getRollupData/getRollupData.ts +++ b/tools/getRollupData/getRollupData.ts @@ -10,7 +10,7 @@ import {ethers, upgrades} from "hardhat"; const getRollupParams = require("./rollupDataParams.json"); import {PolygonRollupManager} from "../../typechain-types"; const pathOutputJson = path.join(__dirname, "./deploy_output.json"); -const pathCreateRollupOutput = path.join(__dirname, "./create_rollup_output.json"); +const pathCreateRollupOutput = path.join(__dirname, "./create_rollup_output"); async function main() { const RollupManagerFactory = await ethers.getContractFactory("PolygonRollupManager"); @@ -22,7 +22,6 @@ async function main() { const polygonZkEVMBridgeAddress = await rollupManager.bridgeAddress(); const polygonZkEVMGlobalExitRootAddress = await rollupManager.globalExitRootManager(); const polTokenAddress = await rollupManager.pol(); - // FIlter first rollup ID ( the one on migration) const filterInit = rollupManager.filters.Initialized(undefined); const eventsInit = await rollupManager.queryFilter(filterInit, 0, "latest"); @@ -31,7 +30,12 @@ async function main() { // Filter first initialization (deployment) const filter = rollupManager.filters.AddExistingRollup(1); const eventsAddRollup = await rollupManager.queryFilter(filter, 0, "latest"); - const upgradeToULxLyBlockNumber = eventsAddRollup[0].blockNumber; + let upgradeToULxLyBlockNumber; + if (eventsAddRollup.length > 0) { + upgradeToULxLyBlockNumber = eventsAddRollup[0].blockNumber; + } else { + console.log("No event AddExistingRollup"); + } const deployOutput = { polygonRollupManagerAddress: rollupManager.target, polygonZkEVMBridgeAddress, @@ -40,7 +44,7 @@ async function main() { deploymentRollupManagerBlockNumber, upgradeToULxLyBlockNumber, }; - fs.writeFileSync(pathOutputJson, JSON.stringify(deployOutput, null, 1)); + await fs.writeFileSync(pathOutputJson, JSON.stringify(deployOutput, null, 1)); const filter2 = rollupManager.filters.CreateNewRollup( getRollupParams.rollupID, @@ -50,31 +54,36 @@ async function main() { undefined ); const eventsCreateNewRollup = await rollupManager.queryFilter(filter2, 0, "latest"); - const {rollupID, rollupAddress, chainID, gasTokenAddress, rollupTypeID} = eventsCreateNewRollup[0].args; - const filter3 = rollupManager.filters.AddNewRollupType( - rollupTypeID, - undefined, - undefined, - undefined, - undefined, - undefined - ); + if (eventsCreateNewRollup.length > 0) { + const {rollupID, rollupAddress, chainID, gasTokenAddress, rollupTypeID} = eventsCreateNewRollup[0].args; + + const filter3 = rollupManager.filters.AddNewRollupType( + rollupTypeID, + undefined, + undefined, + undefined, + undefined, + undefined + ); - const eventsAddRollupType = await rollupManager.queryFilter(filter3, 0, "latest"); - const {forkID, genesis, description} = eventsAddRollupType[0].args; + const eventsAddRollupType = await rollupManager.queryFilter(filter3, 0, "latest"); + const {forkID, genesis, description} = eventsAddRollupType[0].args; - // Add the first batch of the created rollup - const outputCreateRollup = {} as any; - outputCreateRollup.genesis = genesis; - outputCreateRollup.createRollupBlockNumber = eventsCreateNewRollup[0].blockNumber; - outputCreateRollup.rollupAddress = rollupAddress; - outputCreateRollup.consensusContract = description; - outputCreateRollup.rollupID = Number(rollupID); - outputCreateRollup.L2ChainID = Number(chainID); - outputCreateRollup.gasTokenAddress = gasTokenAddress; + // Add the first batch of the created rollup + const outputCreateRollup = {} as any; + outputCreateRollup.genesis = genesis; + outputCreateRollup.createRollupBlockNumber = eventsCreateNewRollup[0].blockNumber; + outputCreateRollup.rollupAddress = rollupAddress; + outputCreateRollup.consensusContract = description; + outputCreateRollup.rollupID = Number(rollupID); + outputCreateRollup.L2ChainID = Number(chainID); + outputCreateRollup.gasTokenAddress = gasTokenAddress; - fs.writeFileSync(pathCreateRollupOutput, JSON.stringify(outputCreateRollup, null, 1)); + await fs.writeFileSync(`${pathCreateRollupOutput}_${rollupID}.json`, JSON.stringify(outputCreateRollup, null, 1)); + } else { + console.log("No event AddNewRollupType"); + } } main().catch((e) => { diff --git a/tools/grantRole/.gitignore b/tools/grantRole/.gitignore new file mode 100644 index 00000000..dc198fa2 --- /dev/null +++ b/tools/grantRole/.gitignore @@ -0,0 +1,2 @@ +grantRoleOutput.json +grantRole.json \ No newline at end of file diff --git a/tools/grantRole/README.md b/tools/grantRole/README.md new file mode 100644 index 00000000..c264af6f --- /dev/null +++ b/tools/grantRole/README.md @@ -0,0 +1,62 @@ +# Get Rollup Data +Script to get rollup data. + +## Install +``` +npm i +``` + +## Setup +- Config file `grantRole.json`: + - `roleName`: + - "ADD_ROLLUP_TYPE_ROLE" + - "OBSOLETE_ROLLUP_TYPE_ROLE" + - "CREATE_ROLLUP_ROLE" + - "ADD_EXISTING_ROLLUP_ROLE" + - "UPDATE_ROLLUP_ROLE" + - "TRUSTED_AGGREGATOR_ROLE" + - "TRUSTED_AGGREGATOR_ROLE_ADMIN" + - "SET_FEE_ROLE" + - "STOP_EMERGENCY_ROLE" + - "EMERGENCY_COUNCIL_ROLE" + - `accountToGrantRole`: address to grantRole + - `polygonRollupManagerAddress`: rollupManager address + - `timelockDelay`: timelock delay +- A network should be selected when running the script + - examples: `--network sepolia` or `--network mainnet` + - This uses variables set in `hardhat.config.ts` + - Which uses some environment variables that should be set in `.env` +> All paths are from root repository + +## Usage +> All commands are done from root repository. + +- Copy configuration file: +``` +cp ./tools/grantRole/grantRole.json.example ./tools/grantRole/grantRole.json +``` +- Set your parameters +- Run tool: +``` +npx hardhat run tools/grantRole/grantRole.ts --network +``` +- Output: + - `granRoleOutput.json`: + ``` + { + "scheduleData": "0x01d5062a000000000000000000000000a51c1fc2f0d1a1b8494ed1fe312d7c3a78ed91c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e1000000000000000000000000000000000000000000000000000000000000000442f2ff15dac75d24dbb35ea80e25fab167da4dea46c1915260426570db84f184891f5f590000000000000000000000000a51c1fc2f0d1a1b8494ed1fe312d7c3a78ed91c000000000000000000000000000000000000000000000000000000000", + "executeData": "0x134008d3000000000000000000000000a51c1fc2f0d1a1b8494ed1fe312d7c3a78ed91c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000442f2ff15dac75d24dbb35ea80e25fab167da4dea46c1915260426570db84f184891f5f590000000000000000000000000a51c1fc2f0d1a1b8494ed1fe312d7c3a78ed91c000000000000000000000000000000000000000000000000000000000", + "decodedScheduleData": { + "target": "0xA51c1fc2f0D1a1b8494Ed1FE312d7C3a78Ed91C0", + "value": "0", + "data": "0x2f2ff15dac75d24dbb35ea80e25fab167da4dea46c1915260426570db84f184891f5f590000000000000000000000000a51c1fc2f0d1a1b8494ed1fe312d7c3a78ed91c0", + "decodedData": { + "role": "0xac75d24dbb35ea80e25fab167da4dea46c1915260426570db84f184891f5f590", + "account": "0xA51c1fc2f0D1a1b8494Ed1FE312d7C3a78Ed91C0" + }, + "predecessor": "0x0000000000000000000000000000000000000000000000000000000000000000", + "salt": "0x0000000000000000000000000000000000000000000000000000000000000000", + "delay": "3600" + } + } + ``` diff --git a/tools/grantRole/grantRole.json.example b/tools/grantRole/grantRole.json.example index fc6189db..2264e6ad 100644 --- a/tools/grantRole/grantRole.json.example +++ b/tools/grantRole/grantRole.json.example @@ -2,9 +2,5 @@ "roleName": "roleName", "accountToGrantRole": "0xaddress", "polygonRollupManagerAddress": "0xaddress", - "timelockDelay": 3600, - "deployerPvtKey": "", - "maxFeePerGas": "", - "maxPriorityFeePerGas": "", - "multiplierGas": "" + "timelockDelay": 3600 } diff --git a/tools/grantRole/grantRole.ts b/tools/grantRole/grantRole.ts index d9c5f91b..a486fb74 100644 --- a/tools/grantRole/grantRole.ts +++ b/tools/grantRole/grantRole.ts @@ -54,59 +54,11 @@ async function main() { } const roleID = ethers.id(roleName); - // Load provider - let currentProvider = ethers.provider; - if (addRollupParameters.multiplierGas || addRollupParameters.maxFeePerGas) { - if (process.env.HARDHAT_NETWORK !== "hardhat") { - currentProvider = ethers.getDefaultProvider( - `https://${process.env.HARDHAT_NETWORK}.infura.io/v3/${process.env.INFURA_PROJECT_ID}` - ) as any; - if (addRollupParameters.maxPriorityFeePerGas && addRollupParameters.maxFeePerGas) { - console.log( - `Hardcoded gas used: MaxPriority${addRollupParameters.maxPriorityFeePerGas} gwei, MaxFee${addRollupParameters.maxFeePerGas} gwei` - ); - const FEE_DATA = new ethers.FeeData( - null, - ethers.parseUnits(addRollupParameters.maxFeePerGas, "gwei"), - ethers.parseUnits(addRollupParameters.maxPriorityFeePerGas, "gwei") - ); - - currentProvider.getFeeData = async () => FEE_DATA; - } else { - console.log("Multiplier gas used: ", addRollupParameters.multiplierGas); - async function overrideFeeData() { - const feedata = await ethers.provider.getFeeData(); - return new ethers.FeeData( - null, - ((feedata.maxFeePerGas as bigint) * BigInt(addRollupParameters.multiplierGas)) / 1000n, - ((feedata.maxPriorityFeePerGas as bigint) * BigInt(addRollupParameters.multiplierGas)) / 1000n - ); - } - currentProvider.getFeeData = overrideFeeData; - } - } - } - - // Load deployer - let deployer; - if (addRollupParameters.deployerPvtKey) { - deployer = new ethers.Wallet(addRollupParameters.deployerPvtKey, currentProvider); - } else if (process.env.MNEMONIC) { - deployer = ethers.HDNodeWallet.fromMnemonic( - ethers.Mnemonic.fromPhrase(process.env.MNEMONIC), - "m/44'/60'/0'/0/0" - ).connect(currentProvider); - } else { - [deployer] = await ethers.getSigners(); - } - - console.log("Using with: ", deployer.address); - // load timelock - const timelockContractFactory = await ethers.getContractFactory("PolygonZkEVMTimelock", deployer); + const timelockContractFactory = await ethers.getContractFactory("PolygonZkEVMTimelock"); // Load Rollup manager - const PolgonRollupManagerFactory = await ethers.getContractFactory("PolygonRollupManager", deployer); + const PolgonRollupManagerFactory = await ethers.getContractFactory("PolygonRollupManager"); const operation = genOperation( polygonRollupManagerAddress, @@ -142,8 +94,8 @@ async function main() { // Decode the scheduleData for better readibility const timelockTx = timelockContractFactory.interface.parseTransaction({data: scheduleData}); - const paramsArray = timelockTx?.fragment.inputs; - const objectDecoded = {}; + const paramsArray = timelockTx?.fragment.inputs as any; + const objectDecoded = {} as any; for (let i = 0; i < paramsArray?.length; i++) { const currentParam = paramsArray[i]; @@ -153,8 +105,8 @@ async function main() { const decodedRollupManagerData = PolgonRollupManagerFactory.interface.parseTransaction({ data: timelockTx?.args[i], }); - const objectDecodedData = {}; - const paramsArrayData = decodedRollupManagerData?.fragment.inputs; + const objectDecodedData = {} as any; + const paramsArrayData = decodedRollupManagerData?.fragment.inputs as any; for (let j = 0; j < paramsArrayData?.length; j++) { const currentParam = paramsArrayData[j]; diff --git a/tools/updateRollup/README.md b/tools/updateRollup/README.md index 13193ff2..73a03963 100644 --- a/tools/updateRollup/README.md +++ b/tools/updateRollup/README.md @@ -7,7 +7,7 @@ npm i ``` ## Setup -- Config file +- Config file `updateRollup.json`: - `rollupAddress`: rollup address of the rollup that is going to be updated - `newRollupTypeID`: select which is the `rollupTypeID` to upgrade - `upgradeData`: data necessary to perform the upgrade (default to `0x`) @@ -27,7 +27,7 @@ npm i ## Usage > All commands are done from root repository. -### Call 'addNewRollupType' from an EOA +### Call 'updateRollup' from an EOA - Copy configuration file: ``` cp ./tools/updateRollup/updateRollup.json.example ./tools/updateRollup/updateRollup.json @@ -37,7 +37,7 @@ cp ./tools/updateRollup/updateRollup.json.example ./tools/updateRollup/updateRol - Run tool: - Standrad transaction: ``` -npx hardhat run ./tools/updateRollup/updateRollup.ts --network sepolia +npx hardhat run ./tools/updateRollup/updateRollup.ts --network ``` ### Generate 'updateRollup' data to the Timelock SC @@ -50,7 +50,7 @@ cp ./tools/updateRollup/updateRollup.json.example ./tools/updateRollup/updateRol - Set your parameters - Run tool: ``` -npx hardhat run ./tools/updateRollup/updateRollupTimelock.ts --network sepolia +npx hardhat run ./tools/updateRollup/updateRollupTimelock.ts --network ``` - Output: - scheduleData