Skip to content

Commit

Permalink
Improve upgrade presimistic script
Browse files Browse the repository at this point in the history
  • Loading branch information
ignasirv committed Nov 4, 2024
1 parent d5b0cc1 commit dc40f70
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docker/scripts/v2/create_rollup_parameters_docker.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"adminZkEVM": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
"forkID": 11,
"consensusContract": "PolygonPessimisticConsensus",
"gasTokenAddress": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
"gasTokenAddress": "deployed",
"deployerPvtKey": "",
"maxFeePerGas": "",
"maxPriorityFeePerGas": "",
Expand Down
45 changes: 43 additions & 2 deletions upgrade/upgradePessimistic/upgradePessimistic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import {expect} from "chai";
import path = require("path");
import fs = require("fs");
import {utils} from "ffjavascript";

import * as dotenv from "dotenv";
dotenv.config({path: path.resolve(__dirname, "../../.env")});
Expand Down Expand Up @@ -125,7 +126,11 @@ async function main() {
const operationRollupManager = genOperation(
proxyAdmin.target,
0, // value
proxyAdmin.interface.encodeFunctionData("upgrade", [rollupManagerAddress, implRollupManager]), // data
proxyAdmin.interface.encodeFunctionData("upgradeAndCall", [
rollupManagerAddress,
implRollupManager,
PolygonRollupManagerFactory.interface.encodeFunctionData("initialize", []),
]), // data
ethers.ZeroHash, // predecessor
salt // salt
);
Expand Down Expand Up @@ -157,7 +162,43 @@ async function main() {
executeData,
timelockContractAddress: timelockAddress,
};
fs.writeFileSync(pathOutputJson, JSON.stringify(outputJson, null, 1));

// Decode the scheduleData for better readability
const timelockTx = timelockContractFactory.interface.parseTransaction({data: scheduleData});
const paramsArray = timelockTx?.fragment.inputs;
const objectDecoded = {};

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,
});

const resultDecodeProxyAdmin = {};
resultDecodeProxyAdmin.signature = decodedProxyAdmin?.signature;
resultDecodeProxyAdmin.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;
}
}
}

outputJson.decodedScheduleData = objectDecoded;

fs.writeFileSync(pathOutputJson, JSON.stringify(utils.stringifyBigInts(outputJson), null, 1));
}

main().catch((e) => {
Expand Down

0 comments on commit dc40f70

Please sign in to comment.