Skip to content

Commit

Permalink
Add type param al create rollup script
Browse files Browse the repository at this point in the history
  • Loading branch information
ignasirv committed Nov 29, 2024
1 parent 669345d commit 9744783
Show file tree
Hide file tree
Showing 6 changed files with 253 additions and 78 deletions.
42 changes: 21 additions & 21 deletions tools/addRollupType/addRollupTypeTimelock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ async function main() {

/*
* Check deploy parameters
* Check that every necessary parameter is fullfilled
* Check that every necessary parameter is fulfilled
*/
const mandatoryDeploymentParameters = [
"description",
Expand Down Expand Up @@ -86,11 +86,11 @@ async function main() {
} else {
console.log("Multiplier gas used: ", addRollupParameters.multiplierGas);
async function overrideFeeData() {
const feedata = await ethers.provider.getFeeData();
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
((feeData.maxFeePerGas as bigint) * BigInt(addRollupParameters.multiplierGas)) / 1000n,
((feeData.maxPriorityFeePerGas as bigint) * BigInt(addRollupParameters.multiplierGas)) / 1000n
);
}
currentProvider.getFeeData = overrideFeeData;
Expand All @@ -114,8 +114,8 @@ async function main() {
console.log("Using with: ", deployer.address);

// Load Rollup manager
const PolgonRollupManagerFactory = await ethers.getContractFactory("PolygonRollupManager", deployer);
const rollupManagerContract = PolgonRollupManagerFactory.attach(
const PolygonRollupManagerFactory = await ethers.getContractFactory("PolygonRollupManager", deployer);
const rollupManagerContract = PolygonRollupManagerFactory.attach(
polygonRollupManagerAddress
) as PolygonRollupManager;

Expand All @@ -133,7 +133,7 @@ async function main() {

// get bridge address in genesis file
let genesisBridgeAddress = ethers.ZeroAddress;
for (let i = 0; i < genesis.genesis.lenght; i++) {
for (let i = 0; i < genesis.genesis.length; i++) {
if (genesis.genesis[i].contractName === "PolygonZkEVMBridge proxy") {
genesisBridgeAddress = genesis.genesis[i].address;
break;
Expand All @@ -148,33 +148,33 @@ async function main() {
}

// Create consensus implementation if needed
const PolygonconsensusFactory = (await ethers.getContractFactory(consensusContract, deployer)) as any;
let PolygonconsensusContract;
let PolygonconsensusContractAddress;
const PolygonConsensusFactory = (await ethers.getContractFactory(consensusContract, deployer)) as any;
let PolygonConsensusContract;
let PolygonConsensusContractAddress;

if (
typeof addRollupParameters.consensusContractAddress !== "undefined" &&
ethers.isAddress(addRollupParameters.consensusContractAddress)
) {
PolygonconsensusContractAddress = addRollupParameters.consensusContractAddress;
PolygonConsensusContractAddress = addRollupParameters.consensusContractAddress;
} else {
PolygonconsensusContract = await PolygonconsensusFactory.deploy(
PolygonConsensusContract = await PolygonConsensusFactory.deploy(
polygonZkEVMGlobalExitRootAddress,
polTokenAddress,
polygonZkEVMBridgeAddress,
polygonRollupManagerAddress
);
await PolygonconsensusContract.waitForDeployment();
await PolygonConsensusContract.waitForDeployment();

PolygonconsensusContractAddress = PolygonconsensusContract.target;
PolygonConsensusContractAddress = PolygonConsensusContract.target;

console.log("#######################\n");
console.log(`new consensus name: ${consensusContract}`);
console.log(`new PolygonconsensusContract impl: ${PolygonconsensusContractAddress}`);
console.log(`new PolygonConsensusContract impl: ${PolygonConsensusContractAddress}`);

console.log("you can verify the new impl address with:");
console.log(
`npx hardhat verify --constructor-args upgrade/arguments.js ${PolygonconsensusContractAddress} --network ${process.env.HARDHAT_NETWORK}\n`
`npx hardhat verify --constructor-args upgrade/arguments.js ${PolygonConsensusContractAddress} --network ${process.env.HARDHAT_NETWORK}\n`
);
console.log("Copy the following constructor arguments on: upgrade/arguments.js \n", [
polygonZkEVMGlobalExitRootAddress,
Expand Down Expand Up @@ -205,8 +205,8 @@ async function main() {
const operation = genOperation(
polygonRollupManagerAddress,
0, // value
PolgonRollupManagerFactory.interface.encodeFunctionData("addNewRollupType", [
PolygonconsensusContractAddress,
PolygonRollupManagerFactory.interface.encodeFunctionData("addNewRollupType", [
PolygonConsensusContractAddress,
verifierAddress,
forkID,
rollupVerifierType,
Expand Down Expand Up @@ -246,7 +246,7 @@ async function main() {
outputJson.executeData = executeData;
outputJson.id = operation.id;

// Decode the scheduleData for better readibility
// Decode the scheduleData for better readability
const timelockTx = timelockContractFactory.interface.parseTransaction({data: scheduleData});
const paramsArray = timelockTx?.fragment.inputs;
const objectDecoded = {};
Expand All @@ -257,7 +257,7 @@ async function main() {
objectDecoded[currentParam.name] = timelockTx?.args[i];

if (currentParam.name == "data") {
const decodedRollupManagerData = PolgonRollupManagerFactory.interface.parseTransaction({
const decodedRollupManagerData = PolygonRollupManagerFactory.interface.parseTransaction({
data: timelockTx?.args[i],
});
const objectDecodedData = {};
Expand All @@ -273,7 +273,7 @@ async function main() {

outputJson.decodedScheduleData = objectDecoded;

// Decode the schedule data to better readibiltiy:
// Decode the schedule data to better readability:

fs.writeFileSync(pathOutputJson, JSON.stringify(outputJson, null, 1));
}
Expand Down
2 changes: 1 addition & 1 deletion tools/createNewRollup/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ create_new_rollup.json
genesis.json
genesis_sovereign.json
create_new_rollup_output.json
create_new_rollup_output*.json
create_new_rollup_output*.json
12 changes: 9 additions & 3 deletions tools/createNewRollup/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Script to call `createNewRollup` function.

- This script needs of a genesis as input only if we are trying to deploy a sovereign chain. The genesis will only be updated in case of trying to deploy a sovereign chain. In this case, a new `genesis_sovereign.json` will be created.
- This script needs of a genesis as input only if we are trying to deploy a sovereign chain. The genesis will only be updated in case of trying to deploy a sovereign chain. In this case, this new sovereign genesis will be appended at the output file

## Install

Expand All @@ -13,6 +13,10 @@ npm i
## Setup

- Config file
- `type`: Specify the type of rollup creation, only available:
- EOA: If creating the rollup from a wallet, the script will execute the creation of the rollup on the specified network
- Multisig: If creating the rollup from a multisig, the script will output the calldata of the transaction to execute for creating the rollup
- Timelock: If creating the rollup through a timelock, the script will output the execute and schedule data to send to the timelock contract
- `trustedSequencerURL`: Sequencer URL of the new created rollup
- `networkName`: Network name of the new created rollup
- `trustedSequencer`: Sequencer address of the new created rollup
Expand All @@ -24,8 +28,8 @@ npm i
- `maxFeePerGas(optional)`: string, Set `maxFeePerGas`, must define as well `maxPriorityFeePerGas` to use it
- `maxPriorityFeePerGas(optional)`: string, Set `maxPriorityFeePerGas`, must define as well `maxFeePerGas` to use it
- `multiplierGas(optional)`: number, Gas multiplier with 3 decimals. If `maxFeePerGas` and `maxPriorityFeePerGas` are set, this will not take effect
- `timelockDelay`: timelock delay, if is zero, no timelock is executed, direct deploy
- `timelockSalt(optional)`: timelock salt
- `timelockDelay(optional)`: timelock delay, only required on timelock type
- `timelockSalt(optional)`: timelock salt, only required on timelock type
- `rollupManagerAddress`: Address of deployed rollupManager contract
- `isVanillaClient`: Flag for vanilla/sovereign clients handling
- `sovereignParams`:
Expand Down Expand Up @@ -59,3 +63,5 @@ cp ./tools/createNewRollup/genesis.json.example ./tools/createNewRollup/genesis.
```
npx hardhat run ./tools/createNewRollup/createNewRollup.ts --network sepolia
```

Recommendation: run the tool from the interactive rollup manager cli -> https://github.com/0xPolygonHermez/rollup-manager-cli
Loading

0 comments on commit 9744783

Please sign in to comment.