From 44c089d509406ea3f068498993efc1fffc49f373 Mon Sep 17 00:00:00 2001 From: invocamanman Date: Tue, 5 Nov 2024 14:51:57 +0100 Subject: [PATCH 1/3] fix pp info upgrade --- .../upgradePessimistic/upgradePessimistic.ts | 35 ++++++++----------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/upgrade/upgradePessimistic/upgradePessimistic.ts b/upgrade/upgradePessimistic/upgradePessimistic.ts index c9bf51f1..c0bff2eb 100644 --- a/upgrade/upgradePessimistic/upgradePessimistic.ts +++ b/upgrade/upgradePessimistic/upgradePessimistic.ts @@ -9,6 +9,7 @@ import * as dotenv from "dotenv"; dotenv.config({path: path.resolve(__dirname, "../../.env")}); import {ethers, upgrades} from "hardhat"; import {PolygonRollupManager, PolygonZkEVM} from "../../typechain-types"; +import {proxy} from "../../typechain-types/@openzeppelin/contracts"; const pathOutputJson = path.join(__dirname, "./upgrade_output.json"); @@ -165,34 +166,28 @@ async function main() { // Decode the scheduleData for better readability 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]; objectDecoded[currentParam.name] = timelockTx?.args[i]; - if (currentParam.name == "payloads") { - // for each payload - const payloads = timelockTx?.args[i]; - for (let j = 0; j < payloads.length; j++) { - const data = payloads[j]; - const decodedProxyAdmin = proxyAdmin.interface.parseTransaction({ - data, - }); + if (currentParam.name == "data") { + const decodedProxyAdmin = proxyAdmin.interface.parseTransaction({ + data: timelockTx?.args[i], + }); + const objectDecodedData = {} as any; + const paramsArrayData = decodedProxyAdmin?.fragment.inputs as any; - const resultDecodeProxyAdmin = {}; - resultDecodeProxyAdmin.signature = decodedProxyAdmin?.signature; - resultDecodeProxyAdmin.selector = decodedProxyAdmin?.selector; + objectDecodedData.signature = decodedProxyAdmin?.signature; + objectDecodedData.selector = decodedProxyAdmin?.selector; - const paramsArrayData = decodedProxyAdmin?.fragment.inputs; - - for (let n = 0; n < paramsArrayData?.length; n++) { - const currentParam = paramsArrayData[n]; - resultDecodeProxyAdmin[currentParam.name] = decodedProxyAdmin?.args[n]; - } - objectDecoded[`decodePayload_${j}`] = resultDecodeProxyAdmin; + for (let j = 0; j < paramsArrayData?.length; j++) { + const currentParam = paramsArrayData[j]; + objectDecodedData[currentParam.name] = decodedProxyAdmin?.args[j]; } + objectDecoded["decodedData"] = objectDecodedData; } } From db4c974447cd3dace240e4c31e308609e4a3b62d Mon Sep 17 00:00:00 2001 From: invocamanman Date: Tue, 5 Nov 2024 15:09:51 +0100 Subject: [PATCH 2/3] update gastTOkens --- deployment/testnet/prepareTestnet.ts | 30 +++++++++++-------- deployment/v2/4_createRollup.ts | 17 ++++++----- .../v2/create_rollup_parameters_docker.json | 4 +-- 3 files changed, 28 insertions(+), 23 deletions(-) diff --git a/deployment/testnet/prepareTestnet.ts b/deployment/testnet/prepareTestnet.ts index 0a45e9d0..d8b189d5 100644 --- a/deployment/testnet/prepareTestnet.ts +++ b/deployment/testnet/prepareTestnet.ts @@ -23,6 +23,7 @@ const argv = yargs(process.argv.slice(2)) const pathDeployParameters = path.join(__dirname, argv.input); const deployParameters = require(argv.input); +const pathCreateRollupParameters = path.join(__dirname, argv.createRollupInput); const createRollupParameters = require(argv.createRollupInput); async function main() { @@ -133,19 +134,22 @@ async function main() { deployParameters.polTokenAddress = polTokenContract.target; - /* - * Deployment gasToken address - * A erc20 is deployed in this testnet in case it's wanted to deploy a rollup that uses this token as the gas token - */ - const gasTokenName = "Gas Token"; - const gasTokenSymbol = "GAS"; - - const gasTokenFactory = await ethers.getContractFactory("ERC20", deployer); - const gasTokenContract = await gasTokenFactory.deploy(gasTokenName, gasTokenSymbol); - await gasTokenContract.waitForDeployment(); - deployParameters.gasTokenAddress = gasTokenContract.target; - console.log("#######################\n"); - console.log("gas token deployed to:", gasTokenContract.target); + if (createRollupParameters.gasTokenAddress == "deploy") { + /* + * Deployment gasToken address + * A erc20 is deployed in this testnet in case it's wanted to deploy a rollup that uses this token as the gas token + */ + const gasTokenName = "Gas Token"; + const gasTokenSymbol = "GAS"; + + const gasTokenFactory = await ethers.getContractFactory("ERC20", deployer); + const gasTokenContract = await gasTokenFactory.deploy(gasTokenName, gasTokenSymbol); + await gasTokenContract.waitForDeployment(); + createRollupParameters.gasTokenAddress = gasTokenContract.target; + console.log("#######################\n"); + console.log("gas token deployed to:", gasTokenContract.target); + fs.writeFileSync(pathCreateRollupParameters, JSON.stringify(createRollupParameters, null, 1)); + } fs.writeFileSync(pathDeployParameters, JSON.stringify(deployParameters, null, 1)); } diff --git a/deployment/v2/4_createRollup.ts b/deployment/v2/4_createRollup.ts index 48937bfd..8f4e12ba 100644 --- a/deployment/v2/4_createRollup.ts +++ b/deployment/v2/4_createRollup.ts @@ -266,15 +266,13 @@ async function main() { createRollupParameters.gasTokenAddress !== "" && createRollupParameters.gasTokenAddress !== ethers.ZeroAddress ) { - // If gas token address is "deployed" use the one from deploy parameters, erc20 deployed at prepare testnet script - if(createRollupParameters.gasTokenAddress == "deployed") { - createRollupParameters.gasTokenAddress = deployParameters.gasTokenAddress; - } // Get token metadata gasTokenMetadata = await polygonZkEVMBridgeContract.getTokenMetadata(createRollupParameters.gasTokenAddress); // If gas token metadata includes `0x124e4f545f56414c49445f454e434f44494e47 (NOT_VALID_ENCODING)` means there is no erc20 token deployed at the selected gas token network - if(gasTokenMetadata.includes("124e4f545f56414c49445f454e434f44494e47")) { - throw new Error(`Invalid gas token address, no ERC20 token deployed at the selected gas token network ${createRollupParameters.gasTokenAddress}`); + if (gasTokenMetadata.includes("124e4f545f56414c49445f454e434f44494e47")) { + throw new Error( + `Invalid gas token address, no ERC20 token deployed at the selected gas token network ${createRollupParameters.gasTokenAddress}` + ); } const wrappedData = await polygonZkEVMBridgeContract.wrappedTokenToTokenInfo( createRollupParameters.gasTokenAddress @@ -391,9 +389,12 @@ async function main() { }; genesis = await updateVanillaGenesis(genesis, chainID, initializeParams); // Add weth address to deployment output if gas token address is provided and sovereignWETHAddress is not provided - if ( gasTokenAddress !== ethers.ZeroAddress && + if ( + gasTokenAddress !== ethers.ZeroAddress && ethers.isAddress(gasTokenAddress) && - (sovereignParams.sovereignWETHAddress === ethers.ZeroAddress || !ethers.isAddress(sovereignParams.sovereignWETHAddress))) { + (sovereignParams.sovereignWETHAddress === ethers.ZeroAddress || + !ethers.isAddress(sovereignParams.sovereignWETHAddress)) + ) { const wethObject = genesis.genesis.find(function (obj) { return obj.contractName == "WETH"; }); diff --git a/docker/scripts/v2/create_rollup_parameters_docker.json b/docker/scripts/v2/create_rollup_parameters_docker.json index 7e99c5a8..83f5bf27 100644 --- a/docker/scripts/v2/create_rollup_parameters_docker.json +++ b/docker/scripts/v2/create_rollup_parameters_docker.json @@ -8,7 +8,7 @@ "adminZkEVM": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", "forkID": 11, "consensusContract": "PolygonPessimisticConsensus", - "gasTokenAddress": "deployed", + "gasTokenAddress": "deploy", "deployerPvtKey": "", "maxFeePerGas": "", "maxPriorityFeePerGas": "", @@ -21,4 +21,4 @@ "sovereignWETHAddressIsNotMintable": false, "globalExitRootUpdater": "0xB55B27Cca633A73108893985350bc26B8A00C43a" } -} \ No newline at end of file +} From f9c1d0da40559998d81c2d19868e7973664919ce Mon Sep 17 00:00:00 2001 From: invocamanman Date: Tue, 5 Nov 2024 15:10:40 +0100 Subject: [PATCH 3/3] update gastTOkens --- upgrade/upgradePessimistic/upgradePessimistic.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/upgrade/upgradePessimistic/upgradePessimistic.ts b/upgrade/upgradePessimistic/upgradePessimistic.ts index c0bff2eb..7d3e2725 100644 --- a/upgrade/upgradePessimistic/upgradePessimistic.ts +++ b/upgrade/upgradePessimistic/upgradePessimistic.ts @@ -8,8 +8,7 @@ import {utils} from "ffjavascript"; import * as dotenv from "dotenv"; dotenv.config({path: path.resolve(__dirname, "../../.env")}); import {ethers, upgrades} from "hardhat"; -import {PolygonRollupManager, PolygonZkEVM} from "../../typechain-types"; -import {proxy} from "../../typechain-types/@openzeppelin/contracts"; +import {PolygonRollupManager} from "../../typechain-types"; const pathOutputJson = path.join(__dirname, "./upgrade_output.json");