Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/improve tools #365

Open
wants to merge 6 commits into
base: feature/ongoingPP
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions tools/addRollupType/README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# Add Rollup Type
Script to call `addNewRollupType` function with no timelock involved
Script to call `addNewRollupType` function

## Install
```
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 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
Expand All @@ -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
Expand All @@ -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 <network>
```

### Generate 'addNewRollupType' to the Timelock SC
Expand All @@ -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 <network>
```
- Output:
- scheduleData
Expand Down
6 changes: 0 additions & 6 deletions tools/addRollupType/add_rollup_type_output.json

This file was deleted.

1 change: 1 addition & 0 deletions tools/createGenesis/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
genesis_parameters.json
32 changes: 32 additions & 0 deletions tools/createGenesis/README.md
Original file line number Diff line number Diff line change
@@ -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`
10 changes: 5 additions & 5 deletions tools/createGenesis/generateGenesis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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";
}
Expand Down
6 changes: 6 additions & 0 deletions tools/createGenesis/genesis_parameters.json.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"timelockAddress": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
"initialZkEVMDeployerOwner": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
"minDelayTimelock": 3600,
"test": true
}
2 changes: 2 additions & 0 deletions tools/deployClaimCompressor/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
deploy_claimCompressor.json
deploy_claim_compressor_output.json
57 changes: 57 additions & 0 deletions tools/deployClaimCompressor/README.md
Original file line number Diff line number Diff line change
@@ -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 <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 ]

```
8 changes: 8 additions & 0 deletions tools/deployClaimCompressor/deployClaimCompressor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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");
Expand All @@ -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) => {
Expand Down
2 changes: 2 additions & 0 deletions tools/deployPolygonDataCommittee/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
deploy_dataCommittee_output.json
deploy_dataCommittee_parameters.json
56 changes: 56 additions & 0 deletions tools/deployPolygonDataCommittee/README.md
Original file line number Diff line number Diff line change
@@ -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 <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
```
1 change: 1 addition & 0 deletions tools/deployVerifier/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
deploy_verifier_output.json
deploy_verifier_parameters.json
30 changes: 26 additions & 4 deletions tools/deployVerifier/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 <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
#######################
```
10 changes: 9 additions & 1 deletion tools/deployVerifier/deployVerifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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) => {
Expand Down
3 changes: 3 additions & 0 deletions tools/getRollupData/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
create_rollup_output*
deploy_output.json
rollupDataParams.json
Loading
Loading